Skip to content

Commit

Permalink
fix(type): 修复部分组件类型文件丢失问题 #2444
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu committed Jul 21, 2023
1 parent f8a6057 commit 6b11985
Show file tree
Hide file tree
Showing 8 changed files with 436 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/packages/__VUE/cellgroup/index.taro.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<view class="nut-cell-group">
<slot v-if="$slots.title" name="title"></slot>
<view v-else-if="title" class="nut-cell-group__title">{{ title }}</view>
<slot v-if="$slots.desc" name="desc"></slot>
<view v-else-if="desc" class="nut-cell-group__desc">{{ desc }}</view>
<view class="nut-cell-group__wrap">
<slot></slot>
</view>
</view>
</template>

<script lang="ts">
import { createComponent } from '@/packages/utils/create';
const { create } = createComponent('cell-group');
export default create({
props: {
title: { type: String, default: '' },
desc: { type: String, default: '' }
}
});
</script>
95 changes: 95 additions & 0 deletions src/packages/__VUE/checkboxgroup/index.taro.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<script lang="ts">
import { h, watch, provide, computed, ComponentInternalInstance, reactive, ComponentPublicInstance } from 'vue';
import { createComponent } from '@/packages/utils/create';
import { useExpose } from '@/packages/utils/useExpose/index';
const { create, componentName } = createComponent('checkbox-group');
export default create({
props: {
modelValue: {
type: Array,
default: () => []
},
disabled: {
type: Boolean,
default: false
},
max: {
type: Number,
default: 0
}
},
emits: ['change', 'update:modelValue'],
setup(props, { slots, emit }) {
const state = reactive({
children: [] as ComponentPublicInstance[]
});
const link = (child: ComponentInternalInstance) => {
child.proxy && state.children.push(child.proxy);
};
const unlink = (child: ComponentInternalInstance) => {
child.proxy && (state.children = state.children.filter((p) => p !== child.proxy));
};
const updateValue = (value: string[]) => {
emit('update:modelValue', value);
emit('change', value);
};
const toggleAll = (checked: boolean) => {
const values: string[] = [];
if (checked) {
state.children.forEach((item: any) => {
if (!item?.disabled) {
values.push(item?.label);
}
});
}
emit('update:modelValue', values);
};
const toggleReverse = () => {
const value = state.children
.filter((item: any) => {
if (item?.disabled) {
return false;
} else {
return !props.modelValue.includes(item.label);
}
})
.map((item: any) => item.label);
emit('update:modelValue', value);
};
provide('parent', {
value: computed(() => props.modelValue),
disabled: computed(() => props.disabled),
max: computed(() => props.max),
updateValue,
link,
unlink
});
watch(
() => props.modelValue,
(value) => {
emit('change', value);
}
);
useExpose({ toggleAll, toggleReverse });
return () => {
return h(
'view',
{
class: componentName
},
slots.default?.()
);
};
}
});
</script>
46 changes: 46 additions & 0 deletions src/packages/__VUE/col/index.taro.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<template>
<view :class="classes" :style="style">
<slot></slot>
</view>
</template>
<script lang="ts">
import { computed, inject } from 'vue';
import { createComponent } from '@/packages/utils/create';
const { componentName, create } = createComponent('col');
export default create({
props: {
span: {
type: [String, Number],
default: '24'
},
offset: {
type: [String, Number],
default: '0'
}
},
emits: [],
setup(props) {
const prefixCls = componentName;
const gutter = inject('gutter') as number;
const classes = computed(() => {
return {
[prefixCls]: true,
[prefixCls + '-gutter']: gutter,
['nut-col-' + props.span]: true,
['nut-col-offset-' + props.offset]: true
};
});
const style = computed(() => {
return {
paddingLeft: gutter / 2 + 'px',
paddingRight: gutter / 2 + 'px'
};
});
return {
classes,
style
};
}
});
</script>
47 changes: 47 additions & 0 deletions src/packages/__VUE/radiogroup/index.taro.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script lang="ts">
import { h, provide, computed, readonly, watch } from 'vue';
import { createComponent } from '@/packages/utils/create';
const { componentName, create } = createComponent('radio-group');
export default create({
props: {
modelValue: {
type: [Number, String, Boolean],
default: ''
},
direction: {
type: String,
default: 'vertical' //horizontal
},
textPosition: {
type: String,
default: 'right'
}
},
emits: ['change', 'update:modelValue'],
setup(props, { emit, slots }) {
const updateValue = (value: string | boolean | number) => emit('update:modelValue', value);
provide('parent', {
label: readonly(computed(() => props.modelValue)),
position: props.textPosition,
updateValue
});
watch(
() => props.modelValue,
(value) => emit('change', value)
);
return () => {
return h(
'view',
{
class: `${componentName} ${componentName}--${props.direction}`
},
slots.default?.()
);
};
}
});
</script>
55 changes: 55 additions & 0 deletions src/packages/__VUE/row/index.taro.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template>
<view :class="classes">
<slot></slot>
</view>
</template>
<script lang="ts">
import { provide, computed } from 'vue';
import { createComponent } from '@/packages/utils/create';
const { componentName, create } = createComponent('row');
export default create({
props: {
type: {
type: String,
default: ''
},
gutter: {
type: [String, Number],
default: ''
},
justify: {
type: String,
default: 'start'
},
align: {
type: String,
default: 'flex-start'
},
flexWrap: {
type: String,
default: 'nowrap'
}
},
emits: [],
setup(props) {
const prefixCls = componentName;
provide('gutter', props.gutter);
const getClass = (prefix: string, type: string) => {
return prefix ? (type ? `nut-row-${prefix}-${type}` : '') : `nut-row-${type}`;
};
const classes = computed(() => {
return [
prefixCls,
getClass('', props.type),
getClass('justify', props.justify),
getClass('align', props.align),
getClass('flex', props.flexWrap)
];
});
return {
classes
};
}
});
</script>
42 changes: 42 additions & 0 deletions src/packages/__VUE/sidenavbaritem/index.taro.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template>
<view :class="classes" @click.stop="handleClick" :ikey="ikey">
<span class="nut-side-navbar-item__title">
{{ title }}
</span>
</view>
</template>
<script lang="ts">
import { computed } from 'vue';
import { createComponent } from '@/packages/utils/create';
const { componentName, create } = createComponent('side-navbar-item');
export default create({
props: {
title: {
type: String,
default: ''
},
ikey: {
type: String,
default: ''
}
},
emits: ['click'],
setup: (props: any, context: any) => {
const classes = computed(() => {
const prefixCls = componentName;
return {
[prefixCls]: true
};
});
const handleClick = () => {
context.emit('click');
};
return {
classes,
handleClick
};
}
});
</script>
Loading

0 comments on commit 6b11985

Please sign in to comment.