tiddy 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiddy",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "typings": "./src/index.d.ts",
6
6
  "scripts": {
@@ -20,42 +20,41 @@
20
20
  "./*": "./src/components/*"
21
21
  },
22
22
  "dependencies": {
23
- "@vueuse/core": "^12.0.0",
23
+ "@vueuse/core": "^12.5.0",
24
24
  "async-validator": "^4.2.5",
25
25
  "vue": "^3.5.13",
26
- "yatter": "^1.8.0"
26
+ "yatter": "^2.2.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@biomejs/biome": "^1.9.4",
30
- "@playwright/test": "^1.49.1",
30
+ "@playwright/test": "^1.50.0",
31
31
  "@tsconfig/node22": "^22.0.0",
32
32
  "@types/jsdom": "^21.1.7",
33
- "@types/node": "^22.10.2",
33
+ "@types/node": "^22.10.10",
34
34
  "@vitejs/plugin-vue": "^5.2.1",
35
35
  "@vitejs/plugin-vue-jsx": "^4.1.1",
36
- "@vitest/eslint-plugin": "1.1.10",
37
- "@vue/eslint-config-prettier": "^10.1.0",
38
- "@vue/eslint-config-typescript": "^14.1.4",
36
+ "@vitest/eslint-plugin": "^1.1.25",
37
+ "@vue/eslint-config-prettier": "^10.2.0",
38
+ "@vue/eslint-config-typescript": "^14.3.0",
39
39
  "@vue/test-utils": "^2.4.6",
40
40
  "@vue/tsconfig": "^0.7.0",
41
- "element-plus": "^2.9.0",
42
- "eslint": "^9.16.0",
43
- "eslint-plugin-oxlint": "^0.11.1",
44
- "eslint-plugin-playwright": "^2.1.0",
41
+ "element-plus": "^2.9.3",
42
+ "eslint": "^9.19.0",
43
+ "eslint-plugin-oxlint": "^0.15.8",
44
+ "eslint-plugin-playwright": "^2.2.0",
45
45
  "eslint-plugin-vue": "^9.32.0",
46
- "jsdom": "^25.0.1",
47
- "npm-run-all2": "^7.0.1",
48
- "oxlint": "^0.11.1",
49
- "prettier": "^3.4.2",
50
- "sass-embedded": "^1.83.0",
51
- "typescript": "~5.6.3",
52
- "vite": "^6.0.3",
53
- "vite-plugin-vue-devtools": "^7.6.8",
54
- "vitest": "^2.1.8",
55
- "vue-tsc": "^2.1.10"
46
+ "jsdom": "^26.0.0",
47
+ "npm-run-all2": "^7.0.2",
48
+ "oxlint": "^0.15.8",
49
+ "sass-embedded": "^1.83.4",
50
+ "typescript": "^5.7.3",
51
+ "vite": "^6.0.11",
52
+ "vite-plugin-vue-devtools": "^7.7.1",
53
+ "vitest": "^3.0.4",
54
+ "vue-tsc": "^2.2.0"
56
55
  },
56
+ "files": ["src/components", "src/index.d.ts"],
57
57
  "peerDependencies": {
58
- "element-plus": "^2.9.0"
59
- },
60
- "files": ["src/components", "src/index.d.ts"]
58
+ "element-plus": "^2.9.3"
59
+ }
61
60
  }
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <ElDialog v-bind="props" ref="dialog" v-model="visible" @close="close">
3
- <template v-for="(Slot, name) in $slots" :key="name" #[name]="scope">
3
+ <template v-for="name in slotNames" :key="name" #[name]="scope">
4
4
  <slot :name="name" v-bind="scope" :ok="confirm" :close="close" :form="form" />
5
5
  </template>
6
6
  </ElDialog>
@@ -8,10 +8,10 @@
8
8
 
9
9
  <script setup lang="ts">
10
10
  import { dialogProps, ElDialog, type FormInstance } from 'element-plus';
11
- import { ref, useTemplateRef } from 'vue';
11
+ import { computed, ref, useSlots, useTemplateRef, type Slots } from 'vue';
12
12
 
13
13
  defineOptions({
14
- name: 'SeDialog',
14
+ name: 'TdDialog',
15
15
  });
16
16
 
17
17
  const props = defineProps(dialogProps);
@@ -20,6 +20,9 @@ const visible = ref(false);
20
20
 
21
21
  const waiting: Partial<PromiseWithResolvers<any>> = {};
22
22
  const dialogRef = useTemplateRef('dialog');
23
+ const slots: Slots = useSlots();
24
+
25
+ const slotNames = computed(() => Object.keys(slots));
23
26
 
24
27
  async function waitPreStep(preStep?: any, data?: any) {
25
28
  let res = data;
@@ -30,10 +30,10 @@ export interface FormProps extends Partial<ElFormProps> {
30
30
  }
31
31
 
32
32
  defineOptions({
33
- name: 'SeForm',
33
+ name: 'TdForm',
34
34
  });
35
35
 
36
- type SeFormEmit = FormEmits & {
36
+ type TdFormEmit = FormEmits & {
37
37
  submit: [data: any];
38
38
  };
39
39
 
@@ -48,7 +48,7 @@ const props = defineProps({
48
48
  default: () => ({}),
49
49
  },
50
50
  });
51
- const emit = defineEmits<SeFormEmit>();
51
+ const emit = defineEmits<TdFormEmit>();
52
52
  const slots = useSlots();
53
53
 
54
54
  const subProps = computed(() => cut(props, ['fields']));
@@ -7,8 +7,6 @@ type IndexPropFunc<P, T> = P extends 'object' ? T : T | ((index: number) => T);
7
7
  export interface CommonFieldProps<T = 'object'> extends AllowedComponentProps {
8
8
  prop?: OrFunction<string>;
9
9
  fullProp?: string;
10
- slots?: OneOrMore<string>;
11
- rules?: OneOrMore<FormItemRule>;
12
10
  hide?: boolean | ComputedRef;
13
11
  hideLabel?: IndexProp<T, boolean>;
14
12
  label?: IndexProp<T, string>;
@@ -22,8 +20,11 @@ export interface WidgetFieldProps<T = 'object'> extends CommonFieldProps<T> {
22
20
  item?: FormItemProps;
23
21
  widget?: Record<string, any>;
24
22
  on?: Record<string, AnyFunction>;
25
- prependSlots?: OneOrMore<string>;
26
- appendSlots?: OneOrMore<string>;
23
+ rules?: OneOrMore<FormItemRule>;
24
+ slots?: OneOrMore<SlotDef>;
25
+ prependSlots?: OneOrMore<SlotDef>;
26
+ appendSlots?: OneOrMore<SlotDef>;
27
+ itemSlots?: OneOrMore<SlotDef>;
27
28
  default?: any;
28
29
  }
29
30
 
@@ -49,7 +50,7 @@ export interface ObjectFieldProps<P = 'object'> extends CommonFieldProps<P> {
49
50
  export interface LayoutFieldProps extends CommonFieldProps {
50
51
  type: 'layout';
51
52
  fields?: FieldProps[];
52
- slots?: SlotDef[];
53
+ slots?: OneOrMore<SlotDef>;
53
54
  }
54
55
 
55
56
  export type FieldProps = ArrayFieldProps | ObjectFieldProps | LayoutFieldProps | WidgetFieldProps;
@@ -19,6 +19,10 @@
19
19
  :scope="{ value: widgetModel }"
20
20
  :ctx-key="formCtxKey"
21
21
  ></SlotNest>
22
+
23
+ <template v-for="isc in itemSlots" :key="isc.name" #[isc.name]="scope">
24
+ <SlotNest v-bind="isc" :scope="scope" :ctx-key="formCtxKey"></SlotNest>
25
+ </template>
22
26
  </FormItem>
23
27
  </template>
24
28
 
@@ -74,6 +78,7 @@ if (!isNullOrUndef(props.default)) {
74
78
  const widgetSlots = formCtx.getParentSlots(ensureArray(props.slots));
75
79
  const preSlots = formCtx.getParentSlots(ensureArray(props.prependSlots));
76
80
  const sufSlots = formCtx.getParentSlots(ensureArray(props.appendSlots));
81
+ const itemSlots = formCtx.getParentSlots(ensureArray(props.itemSlots));
77
82
  </script>
78
83
 
79
84
  <style lang="scss" scoped>
@@ -14,14 +14,14 @@
14
14
 
15
15
  <script setup lang="ts" name="TableCol">
16
16
  import { ElTableColumn } from 'element-plus';
17
- import type { SeTableColumnProps } from './table.vue';
17
+ import type { TdTableColumnProps } from './table.vue';
18
18
  import { getDeepValue, ensureArray } from 'yatter';
19
19
  import { inject } from 'vue';
20
20
  import { tableCtxKey } from './util';
21
21
  import type { TableContext } from './interface';
22
22
  import SlotNest from '../slot-nest/slot-nest.vue';
23
23
 
24
- type TableCol = Pick<SeTableColumnProps, 'slots' | 'transform' | 'columns'>;
24
+ type TableCol = Pick<TdTableColumnProps, 'slots' | 'transform' | 'columns'>;
25
25
 
26
26
  const props = withDefaults(defineProps<TableCol>(), {
27
27
  slots: () => [],
@@ -1,39 +1,46 @@
1
1
  <template>
2
- <slot name="prepend"></slot>
3
- <ElTable ref="tableRef" :data="data" v-bind="$attrs">
2
+ <slot name="before"></slot>
3
+ <ElTable ref="tableRef" :data="data" v-bind="subProps">
4
4
  <TableCol v-for="col in columns" :key="col.label" v-bind="col" />
5
+ <template v-for="name in slotNames" :key="name" #[name]="scope">
6
+ <slot v-bind="scope" :name="name"></slot>
7
+ </template>
5
8
  </ElTable>
6
- <slot name="append"></slot>
9
+ <slot name="after"></slot>
7
10
  </template>
8
11
 
9
12
  <script setup lang="ts">
10
- import { ElTable, type ElTableColumn, type TableInstance } from 'element-plus';
13
+ import { ElTable, type TableColumnInstance, type TableInstance, type TableProps } from 'element-plus';
11
14
  import TableCol from './table-col.vue';
12
- import { provide, useSlots, useTemplateRef } from 'vue';
15
+ import { computed, provide, useSlots, useTemplateRef, type Slots } from 'vue';
13
16
  import { getSlotsFactory } from '../utils';
14
17
  import { tableCtxKey } from './util';
18
+ import { cut } from 'yatter';
15
19
 
16
20
  defineOptions({
17
- name: 'SeTable',
21
+ name: 'TdTable',
18
22
  });
19
23
 
20
- type TableColumnProps = InstanceType<typeof ElTableColumn>['$props'];
24
+ type TableColumnProps = TableColumnInstance['$props'];
21
25
 
22
- export interface SeTableColumnProps extends /* @vue-ignore */ TableColumnProps {
26
+ export interface TdTableColumnProps extends /* @vue-ignore */ TableColumnProps {
23
27
  slots?: OneOrMore<SlotDef>;
24
- columns?: SeTableColumnProps[];
28
+ columns?: TdTableColumnProps[];
25
29
  transform?: AnyFunction[];
26
30
  }
27
31
 
28
- export interface SeTableProps<T = unknown> {
29
- data: T[];
30
- columns: SeTableColumnProps[];
31
- }
32
-
33
- defineProps<SeTableProps>();
32
+ const props = defineProps({
33
+ ...ElTable.props,
34
+ columns: {
35
+ type: Array<TdTableColumnProps>,
36
+ default: () => [],
37
+ },
38
+ });
34
39
 
35
- const slots = useSlots();
40
+ const slots: Slots = useSlots();
36
41
  const tableRef = useTemplateRef<TableInstance>('tableRef');
42
+ const slotNames = computed<string[]>(() => Object.keys(slots));
43
+ const subProps = computed(() => cut(props, ['columns']));
37
44
 
38
45
  provide(tableCtxKey, {
39
46
  getParentSlots: getSlotsFactory(slots),
package/src/index.d.ts CHANGED
@@ -24,5 +24,5 @@ declare global {
24
24
 
25
25
  type GetSlotsFunction = (names: SlotDef[]) => ComponentSlot[];
26
26
 
27
- type SlotNestProps = SlotNest & ComponentSlot;
27
+ // type SlotNestProps = SlotNest & ComponentSlot;
28
28
  }