@xihan-ui/vue 1.0.0 → 1.1.0

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.
Files changed (110) hide show
  1. package/CHANGELOG.md +259 -0
  2. package/README.md +1 -1
  3. package/dist/components/anchor/anchor.d.ts +1 -1
  4. package/dist/components/back-top/back-top.d.ts +1 -1
  5. package/dist/components/calendar/calendar.d.ts +1 -1
  6. package/dist/components/carousel/carousel.d.ts +1 -1
  7. package/dist/components/cascader/cascader.d.ts +6 -6
  8. package/dist/components/color-picker/color-picker.d.ts +2 -2
  9. package/dist/components/combobox/combobox.d.ts +5 -5
  10. package/dist/components/combobox/combobox.d.ts.map +1 -1
  11. package/dist/components/combobox/combobox.js +2 -1
  12. package/dist/components/combobox/combobox.js.map +1 -1
  13. package/dist/components/context-menu/context-menu.d.ts +2 -2
  14. package/dist/components/date-field/date-field.d.ts +2 -2
  15. package/dist/components/date-picker/date-picker.d.ts +5 -5
  16. package/dist/components/date-picker/date-picker.d.ts.map +1 -1
  17. package/dist/components/descriptions/descriptions.d.ts +1 -1
  18. package/dist/components/dialog/dialog.d.ts +1 -1
  19. package/dist/components/drawer/drawer.d.ts +2 -2
  20. package/dist/components/float-button/float-button.d.ts +3 -3
  21. package/dist/components/floating-panel/floating-panel.d.ts +2 -2
  22. package/dist/components/form/form.d.ts +1 -1
  23. package/dist/components/hotkeys/hotkeys.d.ts +1 -1
  24. package/dist/components/hover-card/hover-card.d.ts +1 -1
  25. package/dist/components/image-viewer/image-viewer.d.ts +3 -3
  26. package/dist/components/json-viewer/json-viewer.d.ts +1 -1
  27. package/dist/components/list/list.d.ts +1 -1
  28. package/dist/components/listbox/listbox.d.ts +1 -1
  29. package/dist/components/mention/mention.d.ts +4 -4
  30. package/dist/components/menu/menu.d.ts +2 -2
  31. package/dist/components/notification/notification.d.ts +2 -2
  32. package/dist/components/number-animation/number-animation.d.ts +1 -1
  33. package/dist/components/number-field/number-field.d.ts +2 -2
  34. package/dist/components/pagination/pagination.d.ts +1 -1
  35. package/dist/components/password-input/password-input.d.ts +2 -2
  36. package/dist/components/pin-input/pin-input.d.ts +1 -1
  37. package/dist/components/popconfirm/popconfirm.d.ts +1 -1
  38. package/dist/components/popover/popover.d.ts +2 -2
  39. package/dist/components/popselect/popselect.d.ts +3 -3
  40. package/dist/components/popselect/popselect.d.ts.map +1 -1
  41. package/dist/components/popselect/popselect.js +2 -1
  42. package/dist/components/popselect/popselect.js.map +1 -1
  43. package/dist/components/resizable/context.d.ts +7 -0
  44. package/dist/components/resizable/context.d.ts.map +1 -0
  45. package/dist/components/resizable/context.js +15 -0
  46. package/dist/components/resizable/context.js.map +1 -0
  47. package/dist/components/resizable/resizable.d.ts +174 -0
  48. package/dist/components/resizable/resizable.d.ts.map +1 -0
  49. package/dist/components/resizable/resizable.js +108 -0
  50. package/dist/components/resizable/resizable.js.map +1 -0
  51. package/dist/components/resizable/use-resizable.d.ts +14 -0
  52. package/dist/components/resizable/use-resizable.d.ts.map +1 -0
  53. package/dist/components/resizable/use-resizable.js +25 -0
  54. package/dist/components/resizable/use-resizable.js.map +1 -0
  55. package/dist/components/select/select.d.ts +4 -4
  56. package/dist/components/side-nav/side-nav.d.ts +2 -2
  57. package/dist/components/slider/slider.d.ts +1 -1
  58. package/dist/components/sortable/context.d.ts +7 -0
  59. package/dist/components/sortable/context.d.ts.map +1 -0
  60. package/dist/components/sortable/context.js +15 -0
  61. package/dist/components/sortable/context.js.map +1 -0
  62. package/dist/components/sortable/sortable.d.ts +166 -0
  63. package/dist/components/sortable/sortable.d.ts.map +1 -0
  64. package/dist/components/sortable/sortable.js +128 -0
  65. package/dist/components/sortable/sortable.js.map +1 -0
  66. package/dist/components/sortable/use-sortable.d.ts +14 -0
  67. package/dist/components/sortable/use-sortable.d.ts.map +1 -0
  68. package/dist/components/sortable/use-sortable.js +26 -0
  69. package/dist/components/sortable/use-sortable.js.map +1 -0
  70. package/dist/components/steps/steps.d.ts +1 -1
  71. package/dist/components/switch/switch.d.ts +1 -1
  72. package/dist/components/table/table.d.ts +48 -4
  73. package/dist/components/table/table.d.ts.map +1 -1
  74. package/dist/components/table/table.js +58 -8
  75. package/dist/components/table/table.js.map +1 -1
  76. package/dist/components/table/use-table.d.ts +1 -1
  77. package/dist/components/table/use-table.d.ts.map +1 -1
  78. package/dist/components/table/use-table.js +3 -2
  79. package/dist/components/table/use-table.js.map +1 -1
  80. package/dist/components/tabs/tabs.d.ts +47 -2
  81. package/dist/components/tabs/tabs.d.ts.map +1 -1
  82. package/dist/components/tabs/tabs.js +45 -3
  83. package/dist/components/tabs/tabs.js.map +1 -1
  84. package/dist/components/tabs/use-tabs.d.ts +1 -1
  85. package/dist/components/tabs/use-tabs.d.ts.map +1 -1
  86. package/dist/components/tabs/use-tabs.js +3 -2
  87. package/dist/components/tabs/use-tabs.js.map +1 -1
  88. package/dist/components/tags-input/tags-input.d.ts +3 -3
  89. package/dist/components/text-field/text-field.d.ts +1 -1
  90. package/dist/components/text-field/text-field.d.ts.map +1 -1
  91. package/dist/components/text-field/text-field.js +2 -1
  92. package/dist/components/text-field/text-field.js.map +1 -1
  93. package/dist/components/time-field/time-field.d.ts +2 -2
  94. package/dist/components/time-picker/time-picker.d.ts +5 -5
  95. package/dist/components/toast/toast.d.ts +1 -1
  96. package/dist/components/tooltip/tooltip.d.ts +1 -1
  97. package/dist/components/tour/tour.d.ts +4 -4
  98. package/dist/components/tree/tree.d.ts +46 -2
  99. package/dist/components/tree/tree.d.ts.map +1 -1
  100. package/dist/components/tree/tree.js +45 -3
  101. package/dist/components/tree/tree.js.map +1 -1
  102. package/dist/components/tree/use-tree.d.ts +1 -1
  103. package/dist/components/tree/use-tree.d.ts.map +1 -1
  104. package/dist/components/tree/use-tree.js +3 -2
  105. package/dist/components/tree/use-tree.js.map +1 -1
  106. package/dist/components/tree-select/tree-select.d.ts +5 -5
  107. package/dist/index.d.ts +10 -4
  108. package/dist/index.js +10 -4
  109. package/dist/package.js +1 -1
  110. package/package.json +15 -14
@@ -0,0 +1,108 @@
1
+ import { withXhConfig } from "../../config/config.js";
2
+ import { provideResizable, useResizableContext } from "./context.js";
3
+ import { useResizable } from "./use-resizable.js";
4
+ import { defineComponent, h } from "vue";
5
+ //#region src/components/resizable/resizable.ts
6
+ const XhResizableRoot = defineComponent({
7
+ name: "XhResizableRoot",
8
+ props: {
9
+ size: {
10
+ type: Object,
11
+ default: void 0
12
+ },
13
+ defaultSize: {
14
+ type: Object,
15
+ default: void 0
16
+ },
17
+ minWidth: {
18
+ type: Number,
19
+ default: void 0
20
+ },
21
+ minHeight: {
22
+ type: Number,
23
+ default: void 0
24
+ },
25
+ maxWidth: {
26
+ type: Number,
27
+ default: void 0
28
+ },
29
+ maxHeight: {
30
+ type: Number,
31
+ default: void 0
32
+ },
33
+ aspectRatio: {
34
+ type: Number,
35
+ default: void 0
36
+ },
37
+ step: {
38
+ type: Number,
39
+ default: void 0
40
+ },
41
+ keyboardStep: {
42
+ type: Number,
43
+ default: void 0
44
+ },
45
+ keyboardLargeStep: {
46
+ type: Number,
47
+ default: void 0
48
+ },
49
+ edges: {
50
+ type: Array,
51
+ default: void 0
52
+ },
53
+ disabled: Boolean,
54
+ dir: {
55
+ type: String,
56
+ default: void 0
57
+ },
58
+ translations: {
59
+ type: Object,
60
+ default: void 0
61
+ }
62
+ },
63
+ emits: {
64
+ "size-change": (_details) => true,
65
+ "update:size": (_size) => true,
66
+ "size-change-end": (_details) => true
67
+ },
68
+ slots: Object,
69
+ setup(props, { slots, emit }) {
70
+ const notify = (details) => {
71
+ emit("size-change", details);
72
+ emit("update:size", details.size);
73
+ };
74
+ const ctx = useResizable(withXhConfig("resizable", props), notify, (details) => emit("size-change-end", details));
75
+ provideResizable(ctx);
76
+ return () => h("div", {
77
+ ...ctx.api.value.getRootProps(),
78
+ ref: ctx.rootRef
79
+ }, slots.default?.({
80
+ size: ctx.api.value.size,
81
+ offset: ctx.api.value.offset,
82
+ resizing: ctx.api.value.resizing,
83
+ activeEdge: ctx.api.value.activeEdge
84
+ }));
85
+ }
86
+ });
87
+ /**
88
+ * 一条边上的把手。
89
+ *
90
+ * 推西边与北边时容器的起点会动,那段位移写成 root 的 left / top——皮肤已给
91
+ * `position: relative`,开箱即对。把 root 改成 static 会让这两个方向只变尺寸不移位。
92
+ */
93
+ const XhResizableHandle = defineComponent({
94
+ name: "XhResizableHandle",
95
+ props: { edge: {
96
+ type: String,
97
+ required: true
98
+ } },
99
+ slots: Object,
100
+ setup(props, { slots }) {
101
+ const ctx = useResizableContext();
102
+ return () => h("span", ctx.api.value.getHandleProps({ edge: props.edge }), slots.default?.());
103
+ }
104
+ });
105
+ //#endregion
106
+ export { XhResizableHandle, XhResizableRoot };
107
+
108
+ //# sourceMappingURL=resizable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resizable.js","names":[],"sources":["../../../src/components/resizable/resizable.ts"],"sourcesContent":["import type { ResizableOffset, ResizableSchema, ResizableSize, ResizableTranslations } from '@xihan-ui/headless'\nimport type { Direction } from '@xihan-ui/kernel'\nimport type { ResizeEdge } from '@xihan-ui/pointer'\nimport type { PropType, SlotsType, VNode } from 'vue'\nimport type { PayloadOf } from '../../runtime/payload'\nimport { defineComponent, h } from 'vue'\nimport { withXhConfig } from '../../config/config'\nimport { provideResizable, useResizableContext } from './context'\nimport { useResizable } from './use-resizable'\n\ntype ResizableProps = ResizableSchema['props']\n\n/** 默认插槽的载荷:当前尺寸、位移与调整态。 */\nexport interface ResizableRootSlotProps {\n size: ResizableSize\n offset: ResizableOffset\n resizing: boolean\n activeEdge: ResizeEdge | null\n}\n\nexport const XhResizableRoot = defineComponent({\n name: 'XhResizableRoot',\n props: {\n size: { type: Object as PropType<ResizableSize>, default: undefined },\n defaultSize: { type: Object as PropType<ResizableSize>, default: undefined },\n minWidth: { type: Number, default: undefined },\n minHeight: { type: Number, default: undefined },\n maxWidth: { type: Number, default: undefined },\n maxHeight: { type: Number, default: undefined },\n aspectRatio: { type: Number, default: undefined },\n step: { type: Number, default: undefined },\n keyboardStep: { type: Number, default: undefined },\n keyboardLargeStep: { type: Number, default: undefined },\n edges: { type: Array as PropType<ResizeEdge[]>, default: undefined },\n disabled: Boolean,\n dir: { type: String as PropType<Direction>, default: undefined },\n translations: { type: Object as PropType<Partial<ResizableTranslations>>, default: undefined },\n },\n // size-change 携带 { size },update:size 携带裸尺寸(v-model:size);\n // size-change-end 只在一次调整收尾时发一次,存尺寸用它\n emits: {\n 'size-change': (_details: PayloadOf<ResizableProps, 'onSizeChange'>) => true,\n 'update:size': (_size: PayloadOf<ResizableProps, 'onSizeChange'>['size']) => true,\n 'size-change-end': (_details: PayloadOf<ResizableProps, 'onSizeChangeEnd'>) => true,\n },\n slots: Object as SlotsType<{\n default?: (props: ResizableRootSlotProps) => VNode[]\n }>,\n setup(props, { slots, emit }) {\n const notify: ResizableProps['onSizeChange'] = (details) => {\n emit('size-change', details)\n emit('update:size', details.size)\n }\n const ctx = useResizable(withXhConfig('resizable', props) as ResizableProps, notify, details => emit('size-change-end', details))\n provideResizable(ctx)\n\n return () => h('div', {\n ...ctx.api.value.getRootProps() as Record<string, unknown>,\n ref: ctx.rootRef,\n }, slots.default?.({\n size: ctx.api.value.size,\n offset: ctx.api.value.offset,\n resizing: ctx.api.value.resizing,\n activeEdge: ctx.api.value.activeEdge,\n }))\n },\n})\n\n/**\n * 一条边上的把手。\n *\n * 推西边与北边时容器的起点会动,那段位移写成 root 的 left / top——皮肤已给\n * `position: relative`,开箱即对。把 root 改成 static 会让这两个方向只变尺寸不移位。\n */\nexport const XhResizableHandle = defineComponent({\n name: 'XhResizableHandle',\n props: {\n edge: { type: String as PropType<ResizeEdge>, required: true },\n },\n slots: Object as SlotsType<{\n default?: () => VNode[]\n }>,\n setup(props, { slots }) {\n const ctx = useResizableContext()\n return () => h(\n 'span',\n ctx.api.value.getHandleProps({ edge: props.edge }) as Record<string, unknown>,\n slots.default?.(),\n )\n },\n})\n"],"mappings":";;;;;AAoBA,MAAa,kBAAkB,gBAAgB;CAC7C,MAAM;CACN,OAAO;EACL,MAAM;GAAE,MAAM;GAAmC,SAAS,KAAA;EAAU;EACpE,aAAa;GAAE,MAAM;GAAmC,SAAS,KAAA;EAAU;EAC3E,UAAU;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EAC7C,WAAW;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EAC9C,UAAU;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EAC7C,WAAW;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EAC9C,aAAa;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EAChD,MAAM;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EACzC,cAAc;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EACjD,mBAAmB;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EACtD,OAAO;GAAE,MAAM;GAAiC,SAAS,KAAA;EAAU;EACnE,UAAU;EACV,KAAK;GAAE,MAAM;GAA+B,SAAS,KAAA;EAAU;EAC/D,cAAc;GAAE,MAAM;GAAoD,SAAS,KAAA;EAAU;CAC/F;CAGA,OAAO;EACL,gBAAgB,aAAwD;EACxE,gBAAgB,UAA6D;EAC7E,oBAAoB,aAA2D;CACjF;CACA,OAAO;CAGP,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,MAAM,UAA0C,YAAY;GAC1D,KAAK,eAAe,OAAO;GAC3B,KAAK,eAAe,QAAQ,IAAI;EAClC;EACA,MAAM,MAAM,aAAa,aAAa,aAAa,KAAK,GAAqB,SAAQ,YAAW,KAAK,mBAAmB,OAAO,CAAC;EAChI,iBAAiB,GAAG;EAEpB,aAAa,EAAE,OAAO;GACpB,GAAG,IAAI,IAAI,MAAM,aAAa;GAC9B,KAAK,IAAI;EACX,GAAG,MAAM,UAAU;GACjB,MAAM,IAAI,IAAI,MAAM;GACpB,QAAQ,IAAI,IAAI,MAAM;GACtB,UAAU,IAAI,IAAI,MAAM;GACxB,YAAY,IAAI,IAAI,MAAM;EAC5B,CAAC,CAAC;CACJ;AACF,CAAC;;;;;;;AAQD,MAAa,oBAAoB,gBAAgB;CAC/C,MAAM;CACN,OAAO,EACL,MAAM;EAAE,MAAM;EAAgC,UAAU;CAAK,EAC/D;CACA,OAAO;CAGP,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,MAAM,oBAAoB;EAChC,aAAa,EACX,QACA,IAAI,IAAI,MAAM,eAAe,EAAE,MAAM,MAAM,KAAK,CAAC,GACjD,MAAM,UAAU,CAClB;CACF;AACF,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { ComputedRef, Ref } from "vue";
2
+ import { ResizableApi, ResizableSchema } from "@xihan-ui/headless";
3
+ import { Service } from "@xihan-ui/machine";
4
+ //#region src/components/resizable/use-resizable.d.ts
5
+ interface ResizableContext {
6
+ api: ComputedRef<ResizableApi>;
7
+ service: Service<ResizableSchema>;
8
+ /** 容器节点,机器在按下时拿它量矩形。 */
9
+ rootRef: Ref<HTMLElement | null>;
10
+ }
11
+ declare function useResizable(props: ResizableSchema['props'], onSizeChange?: ResizableSchema['props']['onSizeChange'], onSizeChangeEnd?: ResizableSchema['props']['onSizeChangeEnd']): ResizableContext;
12
+ //#endregion
13
+ export { ResizableContext, useResizable };
14
+ //# sourceMappingURL=use-resizable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-resizable.d.ts","names":[],"sources":["../../../src/components/resizable/use-resizable.ts"],"mappings":";;;;UAUiB;EACf,KAAK,YAAY;EACjB,SAAS,QAAQ;;EAEjB,SAAS,IAAI;;iBAGC,aACd,OAAO,0BACP,eAAe,0CACf,kBAAkB,8CACjB"}
@@ -0,0 +1,25 @@
1
+ import { vueNormalize } from "../../runtime/normalize-props.js";
2
+ import { useMachine } from "../../runtime/use-machine.js";
3
+ import { createVueIdGenerator } from "../../runtime/vue-id.js";
4
+ import { computed, ref } from "vue";
5
+ import { connectResizable, resizableMachine } from "@xihan-ui/headless";
6
+ import { createScope } from "@xihan-ui/kernel";
7
+ //#region src/components/resizable/use-resizable.ts
8
+ function useResizable(props, onSizeChange, onSizeChangeEnd) {
9
+ const rootRef = ref(null);
10
+ const service = useMachine(resizableMachine, () => ({
11
+ ...props,
12
+ onSizeChange,
13
+ onSizeChangeEnd
14
+ }), createScope(null, createVueIdGenerator()));
15
+ service.refs.set("getRootEl", () => rootRef.value);
16
+ return {
17
+ api: computed(() => connectResizable(service, vueNormalize)),
18
+ service,
19
+ rootRef
20
+ };
21
+ }
22
+ //#endregion
23
+ export { useResizable };
24
+
25
+ //# sourceMappingURL=use-resizable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-resizable.js","names":[],"sources":["../../../src/components/resizable/use-resizable.ts"],"sourcesContent":["import type { ResizableApi, ResizableSchema } from '@xihan-ui/headless'\nimport type { Service } from '@xihan-ui/machine'\nimport type { ComputedRef, Ref } from 'vue'\nimport { connectResizable, resizableMachine } from '@xihan-ui/headless'\nimport { createScope } from '@xihan-ui/kernel'\nimport { computed, ref } from 'vue'\nimport { vueNormalize } from '../../runtime/normalize-props'\nimport { useMachine } from '../../runtime/use-machine'\nimport { createVueIdGenerator } from '../../runtime/vue-id'\n\nexport interface ResizableContext {\n api: ComputedRef<ResizableApi>\n service: Service<ResizableSchema>\n /** 容器节点,机器在按下时拿它量矩形。 */\n rootRef: Ref<HTMLElement | null>\n}\n\nexport function useResizable(\n props: ResizableSchema['props'],\n onSizeChange?: ResizableSchema['props']['onSizeChange'],\n onSizeChangeEnd?: ResizableSchema['props']['onSizeChangeEnd'],\n): ResizableContext {\n const rootRef = ref<HTMLElement | null>(null)\n\n const idGen = createVueIdGenerator()\n const scope = createScope(null, idGen)\n const service = useMachine(resizableMachine, () => ({ ...props, onSizeChange, onSizeChangeEnd }), scope)\n\n // 传 getter 而非节点,ref 在挂载后才有值\n service.refs.set('getRootEl', () => rootRef.value)\n\n const api = computed(() => connectResizable(service, vueNormalize))\n return { api, service, rootRef }\n}\n"],"mappings":";;;;;;;AAiBA,SAAgB,aACd,OACA,cACA,iBACkB;CAClB,MAAM,UAAU,IAAwB,IAAI;CAI5C,MAAM,UAAU,WAAW,yBAAyB;EAAE,GAAG;EAAO;EAAc;CAAgB,IADhF,YAAY,MADZ,qBACsB,CACkE,CAAC;CAGvG,QAAQ,KAAK,IAAI,mBAAmB,QAAQ,KAAK;CAGjD,OAAO;EAAE,KADG,eAAe,iBAAiB,SAAS,YAAY,CACtD;EAAG;EAAS;CAAQ;AACjC"}
@@ -192,15 +192,15 @@ declare const XhSelectRoot: import("vue").DefineComponent<import("vue").ExtractP
192
192
  tone: Tone;
193
193
  size: Size;
194
194
  disabled: boolean;
195
- offset: number;
196
- translations: Partial<import("@xihan-ui/headless").SelectTranslations> | undefined;
197
195
  open: boolean;
198
196
  defaultOpen: boolean;
199
- variant: ControlVariant;
197
+ translations: Partial<import("@xihan-ui/headless").SelectTranslations> | undefined;
198
+ offset: number;
200
199
  readOnly: boolean;
201
- loop: boolean;
202
200
  placeholder: string;
201
+ loop: boolean;
203
202
  placement: Placement;
203
+ variant: ControlVariant;
204
204
  clearable: boolean;
205
205
  maxTagCount: number;
206
206
  }, SlotsType<{
@@ -110,11 +110,11 @@ declare const XhSideNavRoot: import("vue").DefineComponent<import("vue").Extract
110
110
  dir: import("@xihan-ui/kernel").Direction | undefined;
111
111
  disabled: boolean;
112
112
  translations: Partial<import("@xihan-ui/headless").SideNavTranslations> | undefined;
113
- accordion: boolean;
114
113
  loop: boolean;
114
+ accordion: boolean;
115
115
  expandedValue: string[];
116
- collapsed: boolean;
117
116
  defaultExpandedValue: string[];
117
+ collapsed: boolean;
118
118
  collapsedPopout: boolean;
119
119
  }, SlotsType<{
120
120
  default?: (props: SideNavRootSlotProps) => VNode[];
@@ -158,8 +158,8 @@ declare const XhSliderRoot: import("vue").DefineComponent<import("vue").ExtractP
158
158
  tone: Tone;
159
159
  size: Size;
160
160
  disabled: boolean;
161
- max: number;
162
161
  readOnly: boolean;
162
+ max: number;
163
163
  min: number;
164
164
  step: number;
165
165
  largeStep: number;
@@ -0,0 +1,7 @@
1
+ import { SortableContext } from "./use-sortable.js";
2
+ //#region src/components/sortable/context.d.ts
3
+ declare function provideSortable(ctx: SortableContext): void;
4
+ declare function useSortableContext(): SortableContext;
5
+ //#endregion
6
+ export { provideSortable, useSortableContext };
7
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/components/sortable/context.ts"],"mappings":";;iBAMgB,gBAAgB,KAAK;iBAIrB,sBAAsB"}
@@ -0,0 +1,15 @@
1
+ import { inject, provide } from "vue";
2
+ //#region src/components/sortable/context.ts
3
+ const KEY = Symbol.for("xh-sortable");
4
+ function provideSortable(ctx) {
5
+ provide(KEY, ctx);
6
+ }
7
+ function useSortableContext() {
8
+ const ctx = inject(KEY, null);
9
+ if (!ctx) throw new Error("[xh] Sortable 部件必须用在 XhSortableRoot 内");
10
+ return ctx;
11
+ }
12
+ //#endregion
13
+ export { provideSortable, useSortableContext };
14
+
15
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","names":[],"sources":["../../../src/components/sortable/context.ts"],"sourcesContent":["import type { InjectionKey } from 'vue'\nimport type { SortableContext } from './use-sortable'\nimport { inject, provide } from 'vue'\n\nconst KEY: InjectionKey<SortableContext> = Symbol.for('xh-sortable')\n\nexport function provideSortable(ctx: SortableContext): void {\n provide(KEY, ctx)\n}\n\nexport function useSortableContext(): SortableContext {\n const ctx = inject(KEY, null)\n if (!ctx)\n throw new Error('[xh] Sortable 部件必须用在 XhSortableRoot 内')\n return ctx\n}\n"],"mappings":";;AAIA,MAAM,MAAqC,OAAO,IAAI,aAAa;AAEnE,SAAgB,gBAAgB,KAA4B;CAC1D,QAAQ,KAAK,GAAG;AAClB;AAEA,SAAgB,qBAAsC;CACpD,MAAM,MAAM,OAAO,KAAK,IAAI;CAC5B,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,uCAAuC;CACzD,OAAO;AACT"}
@@ -0,0 +1,166 @@
1
+ import { PayloadOf } from "../../runtime/payload.js";
2
+ import { PropType, SlotsType, VNode } from "vue";
3
+ import { SortableItemState, SortableMode, SortableSchema, SortableTranslations } from "@xihan-ui/headless";
4
+ import { Direction } from "@xihan-ui/kernel";
5
+ import { SortableAxis } from "@xihan-ui/pointer";
6
+ //#region src/components/sortable/sortable.d.ts
7
+ type SortableProps = SortableSchema['props'];
8
+ /** 默认插槽的载荷:逐项呈现状态与整体拖动态。 */
9
+ interface SortableRootSlotProps {
10
+ items: SortableItemState[];
11
+ dragging: boolean;
12
+ activeId: string | null;
13
+ from: number;
14
+ to: number;
15
+ mode: SortableMode | null;
16
+ }
17
+ /** 每一项的插槽载荷。`dragging` 是「就是它被拖着」,不是「列表里有人在拖」。 */
18
+ interface SortableItemSlotProps {
19
+ dragging: boolean;
20
+ index: number;
21
+ }
22
+ declare const XhSortableRoot: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
23
+ ids: {
24
+ type: PropType<string[]>;
25
+ default: () => never[];
26
+ };
27
+ orientation: {
28
+ type: PropType<SortableAxis>;
29
+ default: undefined;
30
+ };
31
+ dir: {
32
+ type: PropType<Direction>;
33
+ default: undefined;
34
+ };
35
+ disabled: BooleanConstructor;
36
+ activationDistance: {
37
+ type: NumberConstructor;
38
+ default: undefined;
39
+ };
40
+ autoScroll: {
41
+ type: BooleanConstructor;
42
+ default: undefined;
43
+ };
44
+ translations: {
45
+ type: PropType<Partial<SortableTranslations>>;
46
+ default: undefined;
47
+ };
48
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
49
+ [key: string]: any;
50
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
51
+ sort: (_details: PayloadOf<SortableProps, "onSort">) => boolean;
52
+ 'update:ids': (_ids: PayloadOf<SortableProps, "onSort">["ids"]) => true;
53
+ 'drag-start': (_details: PayloadOf<SortableProps, "onDragStart">) => true;
54
+ 'drag-end': (_details: PayloadOf<SortableProps, "onDragEnd">) => true;
55
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
56
+ ids: {
57
+ type: PropType<string[]>;
58
+ default: () => never[];
59
+ };
60
+ orientation: {
61
+ type: PropType<SortableAxis>;
62
+ default: undefined;
63
+ };
64
+ dir: {
65
+ type: PropType<Direction>;
66
+ default: undefined;
67
+ };
68
+ disabled: BooleanConstructor;
69
+ activationDistance: {
70
+ type: NumberConstructor;
71
+ default: undefined;
72
+ };
73
+ autoScroll: {
74
+ type: BooleanConstructor;
75
+ default: undefined;
76
+ };
77
+ translations: {
78
+ type: PropType<Partial<SortableTranslations>>;
79
+ default: undefined;
80
+ };
81
+ }>> & Readonly<{
82
+ onSort?: ((_details: import("@xihan-ui/headless").SortableSortDetails) => any) | undefined;
83
+ "onDrag-start"?: ((_details: import("@xihan-ui/headless").SortableDragStartDetails) => any) | undefined;
84
+ "onDrag-end"?: ((_details: import("@xihan-ui/headless").SortableDragEndDetails) => any) | undefined;
85
+ "onUpdate:ids"?: ((_ids: string[]) => any) | undefined;
86
+ }>, {
87
+ orientation: SortableAxis;
88
+ dir: Direction;
89
+ disabled: boolean;
90
+ translations: Partial<SortableTranslations>;
91
+ ids: string[];
92
+ activationDistance: number;
93
+ autoScroll: boolean;
94
+ }, SlotsType<{
95
+ default?: (props: SortableRootSlotProps) => VNode[];
96
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
97
+ declare const XhSortableItem: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
98
+ /** 项标识,与 `ids` 里的值一一对应。 */
99
+ itemId: {
100
+ type: StringConstructor;
101
+ required: true;
102
+ };
103
+ /** 单独禁掉这一项。整份 `disabled` 在 Root 上,这条是项级的。 */
104
+ disabled: {
105
+ type: BooleanConstructor;
106
+ default: undefined;
107
+ };
108
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
109
+ [key: string]: any;
110
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
111
+ /** 项标识,与 `ids` 里的值一一对应。 */
112
+ itemId: {
113
+ type: StringConstructor;
114
+ required: true;
115
+ };
116
+ /** 单独禁掉这一项。整份 `disabled` 在 Root 上,这条是项级的。 */
117
+ disabled: {
118
+ type: BooleanConstructor;
119
+ default: undefined;
120
+ };
121
+ }>> & Readonly<{}>, {
122
+ disabled: boolean;
123
+ }, SlotsType<{
124
+ default?: (props: SortableItemSlotProps) => VNode[];
125
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
126
+ declare const XhSortableItemHandle: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
127
+ /** 项标识,与 `ids` 里的值一一对应。 */
128
+ itemId: {
129
+ type: StringConstructor;
130
+ required: true;
131
+ };
132
+ /** 单独禁掉这一项。整份 `disabled` 在 Root 上,这条是项级的。 */
133
+ disabled: {
134
+ type: BooleanConstructor;
135
+ default: undefined;
136
+ };
137
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
138
+ [key: string]: any;
139
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
140
+ /** 项标识,与 `ids` 里的值一一对应。 */
141
+ itemId: {
142
+ type: StringConstructor;
143
+ required: true;
144
+ };
145
+ /** 单独禁掉这一项。整份 `disabled` 在 Root 上,这条是项级的。 */
146
+ disabled: {
147
+ type: BooleanConstructor;
148
+ default: undefined;
149
+ };
150
+ }>> & Readonly<{}>, {
151
+ disabled: boolean;
152
+ }, SlotsType<{
153
+ default?: () => VNode[];
154
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
155
+ /**
156
+ * 拖动过程的读屏播报区,视觉上不可见。
157
+ *
158
+ * 放进列表里就行,位置不限。它必须在拖动开始**之前**就在 DOM 上——
159
+ * 读屏不播报后插入的节点,等到拾起才渲出来等于没有。
160
+ */
161
+ declare const XhSortableLiveRegion: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
162
+ [key: string]: any;
163
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
164
+ //#endregion
165
+ export { SortableItemSlotProps, SortableRootSlotProps, XhSortableItem, XhSortableItemHandle, XhSortableLiveRegion, XhSortableRoot };
166
+ //# sourceMappingURL=sortable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortable.d.ts","names":[],"sources":["../../../src/components/sortable/sortable.ts"],"mappings":";;;;;;KAUK,gBAAgB;;UAGJ;EACf,OAAO;EACP;EACA;EACA;EACA;EACA,MAAM;;;UAIS;EACf;EACA;;cAGW,8BAAc,8BAAA;;IAGD,MAAA;;;;IACS,MAAA,SAAS;;;;IACjB,MAAA,SAAS;;;;;;;;;;;;;IAIA,MAAA,SAAS,QAAQ;;;;;;EAI9B,OAAA,UAAA,UAAU;EACR,eAAA,MAAA,UAAU;EACN,eAAA,UAAA,UAAU;EACZ,aAAA,UAAA,UAAU;;;IAbX,MAAA;;;;IACS,MAAA,SAAS;;;;IACjB,MAAA,SAAS;;;;;;;;;;;;;IAIA,MAAA,SAAS,QAAQ;;;;;;;;;;;;;;;;;EAUvC,WAAC,OAAO,0BAA0B;kCA2B9C;cAEW,8BAAc,8BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;EASb,WAAC,OAAO,0BAA0B;kCAc9C;cAEW,oCAAoB,8BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;EASnB,gBAAM;kCAUlB;;;;;;;cAQW,oCAAoB,0BAAA,oBAAA,4BAAA;;8BAU/B,qCAAA,iDAAA,aAAA,eAAA,oDAAA"}
@@ -0,0 +1,128 @@
1
+ import { withXhConfig } from "../../config/config.js";
2
+ import { provideSortable, useSortableContext } from "./context.js";
3
+ import { useSortable } from "./use-sortable.js";
4
+ import { computed, defineComponent, h } from "vue";
5
+ //#region src/components/sortable/sortable.ts
6
+ const XhSortableRoot = defineComponent({
7
+ name: "XhSortableRoot",
8
+ props: {
9
+ ids: {
10
+ type: Array,
11
+ default: () => []
12
+ },
13
+ orientation: {
14
+ type: String,
15
+ default: void 0
16
+ },
17
+ dir: {
18
+ type: String,
19
+ default: void 0
20
+ },
21
+ disabled: Boolean,
22
+ activationDistance: {
23
+ type: Number,
24
+ default: void 0
25
+ },
26
+ autoScroll: {
27
+ type: Boolean,
28
+ default: void 0
29
+ },
30
+ translations: {
31
+ type: Object,
32
+ default: void 0
33
+ }
34
+ },
35
+ emits: {
36
+ "sort": (_details) => true,
37
+ "update:ids": (_ids) => true,
38
+ "drag-start": (_details) => true,
39
+ "drag-end": (_details) => true
40
+ },
41
+ slots: Object,
42
+ setup(props, { slots, emit }) {
43
+ const notifySort = (details) => {
44
+ emit("sort", details);
45
+ emit("update:ids", details.ids);
46
+ };
47
+ const ctx = useSortable(withXhConfig("sortable", props), notifySort, (details) => emit("drag-start", details), (details) => emit("drag-end", details));
48
+ provideSortable(ctx);
49
+ return () => h("div", {
50
+ ...ctx.api.value.getRootProps(),
51
+ ref: ctx.rootRef
52
+ }, slots.default?.({
53
+ items: ctx.api.value.items,
54
+ dragging: ctx.api.value.dragging,
55
+ activeId: ctx.api.value.activeId,
56
+ from: ctx.api.value.from,
57
+ to: ctx.api.value.to,
58
+ mode: ctx.api.value.mode
59
+ }));
60
+ }
61
+ });
62
+ const XhSortableItem = defineComponent({
63
+ name: "XhSortableItem",
64
+ props: {
65
+ /** 项标识,与 `ids` 里的值一一对应。 */
66
+ itemId: {
67
+ type: String,
68
+ required: true
69
+ },
70
+ /** 单独禁掉这一项。整份 `disabled` 在 Root 上,这条是项级的。 */
71
+ disabled: {
72
+ type: Boolean,
73
+ default: void 0
74
+ }
75
+ },
76
+ slots: Object,
77
+ setup(props, { slots }) {
78
+ const ctx = useSortableContext();
79
+ const state = computed(() => ctx.api.value.items.find((item) => item.id === props.itemId));
80
+ return () => h("div", ctx.api.value.getItemProps({
81
+ id: props.itemId,
82
+ disabled: props.disabled
83
+ }), slots.default?.({
84
+ dragging: state.value?.dragging ?? false,
85
+ index: state.value?.index ?? -1
86
+ }));
87
+ }
88
+ });
89
+ const XhSortableItemHandle = defineComponent({
90
+ name: "XhSortableItemHandle",
91
+ props: {
92
+ /** 项标识,与 `ids` 里的值一一对应。 */
93
+ itemId: {
94
+ type: String,
95
+ required: true
96
+ },
97
+ /** 单独禁掉这一项。整份 `disabled` 在 Root 上,这条是项级的。 */
98
+ disabled: {
99
+ type: Boolean,
100
+ default: void 0
101
+ }
102
+ },
103
+ slots: Object,
104
+ setup(props, { slots }) {
105
+ const ctx = useSortableContext();
106
+ return () => h("button", ctx.api.value.getItemHandleProps({
107
+ id: props.itemId,
108
+ disabled: props.disabled
109
+ }), slots.default?.());
110
+ }
111
+ });
112
+ /**
113
+ * 拖动过程的读屏播报区,视觉上不可见。
114
+ *
115
+ * 放进列表里就行,位置不限。它必须在拖动开始**之前**就在 DOM 上——
116
+ * 读屏不播报后插入的节点,等到拾起才渲出来等于没有。
117
+ */
118
+ const XhSortableLiveRegion = defineComponent({
119
+ name: "XhSortableLiveRegion",
120
+ setup() {
121
+ const ctx = useSortableContext();
122
+ return () => h("div", ctx.api.value.getLiveRegionProps(), ctx.service.context.get("announcement"));
123
+ }
124
+ });
125
+ //#endregion
126
+ export { XhSortableItem, XhSortableItemHandle, XhSortableLiveRegion, XhSortableRoot };
127
+
128
+ //# sourceMappingURL=sortable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortable.js","names":[],"sources":["../../../src/components/sortable/sortable.ts"],"sourcesContent":["import type { SortableItemState, SortableMode, SortableSchema, SortableTranslations } from '@xihan-ui/headless'\nimport type { Direction } from '@xihan-ui/kernel'\nimport type { SortableAxis } from '@xihan-ui/pointer'\nimport type { PropType, SlotsType, VNode } from 'vue'\nimport type { PayloadOf } from '../../runtime/payload'\nimport { computed, defineComponent, h } from 'vue'\nimport { withXhConfig } from '../../config/config'\nimport { provideSortable, useSortableContext } from './context'\nimport { useSortable } from './use-sortable'\n\ntype SortableProps = SortableSchema['props']\n\n/** 默认插槽的载荷:逐项呈现状态与整体拖动态。 */\nexport interface SortableRootSlotProps {\n items: SortableItemState[]\n dragging: boolean\n activeId: string | null\n from: number\n to: number\n mode: SortableMode | null\n}\n\n/** 每一项的插槽载荷。`dragging` 是「就是它被拖着」,不是「列表里有人在拖」。 */\nexport interface SortableItemSlotProps {\n dragging: boolean\n index: number\n}\n\nexport const XhSortableRoot = defineComponent({\n name: 'XhSortableRoot',\n props: {\n ids: { type: Array as PropType<string[]>, default: () => [] },\n orientation: { type: String as PropType<SortableAxis>, default: undefined },\n dir: { type: String as PropType<Direction>, default: undefined },\n disabled: Boolean,\n activationDistance: { type: Number, default: undefined },\n autoScroll: { type: Boolean, default: undefined },\n translations: { type: Object as PropType<Partial<SortableTranslations>>, default: undefined },\n },\n // sort 携带 { from, to, id, ids },update:ids 携带重排好的裸数组,可直接 v-model:ids\n emits: {\n 'sort': (_details: PayloadOf<SortableProps, 'onSort'>) => true,\n 'update:ids': (_ids: PayloadOf<SortableProps, 'onSort'>['ids']) => true,\n 'drag-start': (_details: PayloadOf<SortableProps, 'onDragStart'>) => true,\n 'drag-end': (_details: PayloadOf<SortableProps, 'onDragEnd'>) => true,\n },\n slots: Object as SlotsType<{\n default?: (props: SortableRootSlotProps) => VNode[]\n }>,\n setup(props, { slots, emit }) {\n const notifySort: SortableProps['onSort'] = (details) => {\n emit('sort', details)\n emit('update:ids', details.ids)\n }\n const ctx = useSortable(\n withXhConfig('sortable', props) as SortableProps,\n notifySort,\n details => emit('drag-start', details),\n details => emit('drag-end', details),\n )\n provideSortable(ctx)\n\n return () => h('div', {\n ...ctx.api.value.getRootProps() as Record<string, unknown>,\n ref: ctx.rootRef,\n }, slots.default?.({\n items: ctx.api.value.items,\n dragging: ctx.api.value.dragging,\n activeId: ctx.api.value.activeId,\n from: ctx.api.value.from,\n to: ctx.api.value.to,\n mode: ctx.api.value.mode,\n }))\n },\n})\n\nexport const XhSortableItem = defineComponent({\n name: 'XhSortableItem',\n props: {\n /** 项标识,与 `ids` 里的值一一对应。 */\n itemId: { type: String, required: true },\n /** 单独禁掉这一项。整份 `disabled` 在 Root 上,这条是项级的。 */\n disabled: { type: Boolean, default: undefined },\n },\n slots: Object as SlotsType<{\n default?: (props: SortableItemSlotProps) => VNode[]\n }>,\n setup(props, { slots }) {\n const ctx = useSortableContext()\n const state = computed(() => ctx.api.value.items.find(item => item.id === props.itemId))\n return () => h(\n 'div',\n ctx.api.value.getItemProps({ id: props.itemId, disabled: props.disabled }) as Record<string, unknown>,\n slots.default?.({\n dragging: state.value?.dragging ?? false,\n index: state.value?.index ?? -1,\n }),\n )\n },\n})\n\nexport const XhSortableItemHandle = defineComponent({\n name: 'XhSortableItemHandle',\n props: {\n /** 项标识,与 `ids` 里的值一一对应。 */\n itemId: { type: String, required: true },\n /** 单独禁掉这一项。整份 `disabled` 在 Root 上,这条是项级的。 */\n disabled: { type: Boolean, default: undefined },\n },\n slots: Object as SlotsType<{\n default?: () => VNode[]\n }>,\n setup(props, { slots }) {\n const ctx = useSortableContext()\n return () => h(\n 'button',\n ctx.api.value.getItemHandleProps({ id: props.itemId, disabled: props.disabled }) as Record<string, unknown>,\n slots.default?.(),\n )\n },\n})\n\n/**\n * 拖动过程的读屏播报区,视觉上不可见。\n *\n * 放进列表里就行,位置不限。它必须在拖动开始**之前**就在 DOM 上——\n * 读屏不播报后插入的节点,等到拾起才渲出来等于没有。\n */\nexport const XhSortableLiveRegion = defineComponent({\n name: 'XhSortableLiveRegion',\n setup() {\n const ctx = useSortableContext()\n return () => h(\n 'div',\n ctx.api.value.getLiveRegionProps() as Record<string, unknown>,\n ctx.service.context.get('announcement'),\n )\n },\n})\n"],"mappings":";;;;;AA4BA,MAAa,iBAAiB,gBAAgB;CAC5C,MAAM;CACN,OAAO;EACL,KAAK;GAAE,MAAM;GAA6B,eAAe,CAAC;EAAE;EAC5D,aAAa;GAAE,MAAM;GAAkC,SAAS,KAAA;EAAU;EAC1E,KAAK;GAAE,MAAM;GAA+B,SAAS,KAAA;EAAU;EAC/D,UAAU;EACV,oBAAoB;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;EACvD,YAAY;GAAE,MAAM;GAAS,SAAS,KAAA;EAAU;EAChD,cAAc;GAAE,MAAM;GAAmD,SAAS,KAAA;EAAU;CAC9F;CAEA,OAAO;EACL,SAAS,aAAiD;EAC1D,eAAe,SAAoD;EACnE,eAAe,aAAsD;EACrE,aAAa,aAAoD;CACnE;CACA,OAAO;CAGP,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,MAAM,cAAuC,YAAY;GACvD,KAAK,QAAQ,OAAO;GACpB,KAAK,cAAc,QAAQ,GAAG;EAChC;EACA,MAAM,MAAM,YACV,aAAa,YAAY,KAAK,GAC9B,aACA,YAAW,KAAK,cAAc,OAAO,IACrC,YAAW,KAAK,YAAY,OAAO,CACrC;EACA,gBAAgB,GAAG;EAEnB,aAAa,EAAE,OAAO;GACpB,GAAG,IAAI,IAAI,MAAM,aAAa;GAC9B,KAAK,IAAI;EACX,GAAG,MAAM,UAAU;GACjB,OAAO,IAAI,IAAI,MAAM;GACrB,UAAU,IAAI,IAAI,MAAM;GACxB,UAAU,IAAI,IAAI,MAAM;GACxB,MAAM,IAAI,IAAI,MAAM;GACpB,IAAI,IAAI,IAAI,MAAM;GAClB,MAAM,IAAI,IAAI,MAAM;EACtB,CAAC,CAAC;CACJ;AACF,CAAC;AAED,MAAa,iBAAiB,gBAAgB;CAC5C,MAAM;CACN,OAAO;;EAEL,QAAQ;GAAE,MAAM;GAAQ,UAAU;EAAK;;EAEvC,UAAU;GAAE,MAAM;GAAS,SAAS,KAAA;EAAU;CAChD;CACA,OAAO;CAGP,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,MAAM,mBAAmB;EAC/B,MAAM,QAAQ,eAAe,IAAI,IAAI,MAAM,MAAM,MAAK,SAAQ,KAAK,OAAO,MAAM,MAAM,CAAC;EACvF,aAAa,EACX,OACA,IAAI,IAAI,MAAM,aAAa;GAAE,IAAI,MAAM;GAAQ,UAAU,MAAM;EAAS,CAAC,GACzE,MAAM,UAAU;GACd,UAAU,MAAM,OAAO,YAAY;GACnC,OAAO,MAAM,OAAO,SAAS;EAC/B,CAAC,CACH;CACF;AACF,CAAC;AAED,MAAa,uBAAuB,gBAAgB;CAClD,MAAM;CACN,OAAO;;EAEL,QAAQ;GAAE,MAAM;GAAQ,UAAU;EAAK;;EAEvC,UAAU;GAAE,MAAM;GAAS,SAAS,KAAA;EAAU;CAChD;CACA,OAAO;CAGP,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,MAAM,mBAAmB;EAC/B,aAAa,EACX,UACA,IAAI,IAAI,MAAM,mBAAmB;GAAE,IAAI,MAAM;GAAQ,UAAU,MAAM;EAAS,CAAC,GAC/E,MAAM,UAAU,CAClB;CACF;AACF,CAAC;;;;;;;AAQD,MAAa,uBAAuB,gBAAgB;CAClD,MAAM;CACN,QAAQ;EACN,MAAM,MAAM,mBAAmB;EAC/B,aAAa,EACX,OACA,IAAI,IAAI,MAAM,mBAAmB,GACjC,IAAI,QAAQ,QAAQ,IAAI,cAAc,CACxC;CACF;AACF,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { ComputedRef, Ref } from "vue";
2
+ import { SortableApi, SortableSchema } from "@xihan-ui/headless";
3
+ import { Service } from "@xihan-ui/machine";
4
+ //#region src/components/sortable/use-sortable.d.ts
5
+ interface SortableContext {
6
+ api: ComputedRef<SortableApi>;
7
+ service: Service<SortableSchema>;
8
+ /** 容器节点,机器在拾起时拿它找项、量矩形。 */
9
+ rootRef: Ref<HTMLElement | null>;
10
+ }
11
+ declare function useSortable(props: SortableSchema['props'], onSort?: SortableSchema['props']['onSort'], onDragStart?: SortableSchema['props']['onDragStart'], onDragEnd?: SortableSchema['props']['onDragEnd']): SortableContext;
12
+ //#endregion
13
+ export { SortableContext, useSortable };
14
+ //# sourceMappingURL=use-sortable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-sortable.d.ts","names":[],"sources":["../../../src/components/sortable/use-sortable.ts"],"mappings":";;;;UAUiB;EACf,KAAK,YAAY;EACjB,SAAS,QAAQ;;EAEjB,SAAS,IAAI;;iBAGC,YACd,OAAO,yBACP,SAAS,mCACT,cAAc,wCACd,YAAY,uCACX"}
@@ -0,0 +1,26 @@
1
+ import { vueNormalize } from "../../runtime/normalize-props.js";
2
+ import { useMachine } from "../../runtime/use-machine.js";
3
+ import { createVueIdGenerator } from "../../runtime/vue-id.js";
4
+ import { computed, ref } from "vue";
5
+ import { connectSortable, sortableMachine } from "@xihan-ui/headless";
6
+ import { createScope } from "@xihan-ui/kernel";
7
+ //#region src/components/sortable/use-sortable.ts
8
+ function useSortable(props, onSort, onDragStart, onDragEnd) {
9
+ const rootRef = ref(null);
10
+ const service = useMachine(sortableMachine, () => ({
11
+ ...props,
12
+ onSort,
13
+ onDragStart,
14
+ onDragEnd
15
+ }), createScope(null, createVueIdGenerator()));
16
+ service.refs.set("getRootEl", () => rootRef.value);
17
+ return {
18
+ api: computed(() => connectSortable(service, vueNormalize)),
19
+ service,
20
+ rootRef
21
+ };
22
+ }
23
+ //#endregion
24
+ export { useSortable };
25
+
26
+ //# sourceMappingURL=use-sortable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-sortable.js","names":[],"sources":["../../../src/components/sortable/use-sortable.ts"],"sourcesContent":["import type { SortableApi, SortableSchema } from '@xihan-ui/headless'\nimport type { Service } from '@xihan-ui/machine'\nimport type { ComputedRef, Ref } from 'vue'\nimport { connectSortable, sortableMachine } from '@xihan-ui/headless'\nimport { createScope } from '@xihan-ui/kernel'\nimport { computed, ref } from 'vue'\nimport { vueNormalize } from '../../runtime/normalize-props'\nimport { useMachine } from '../../runtime/use-machine'\nimport { createVueIdGenerator } from '../../runtime/vue-id'\n\nexport interface SortableContext {\n api: ComputedRef<SortableApi>\n service: Service<SortableSchema>\n /** 容器节点,机器在拾起时拿它找项、量矩形。 */\n rootRef: Ref<HTMLElement | null>\n}\n\nexport function useSortable(\n props: SortableSchema['props'],\n onSort?: SortableSchema['props']['onSort'],\n onDragStart?: SortableSchema['props']['onDragStart'],\n onDragEnd?: SortableSchema['props']['onDragEnd'],\n): SortableContext {\n const rootRef = ref<HTMLElement | null>(null)\n\n const idGen = createVueIdGenerator()\n const scope = createScope(null, idGen)\n const service = useMachine(sortableMachine, () => ({ ...props, onSort, onDragStart, onDragEnd }), scope)\n\n // 传 getter 而非节点,ref 在挂载后才有值\n service.refs.set('getRootEl', () => rootRef.value)\n\n const api = computed(() => connectSortable(service, vueNormalize))\n return { api, service, rootRef }\n}\n"],"mappings":";;;;;;;AAiBA,SAAgB,YACd,OACA,QACA,aACA,WACiB;CACjB,MAAM,UAAU,IAAwB,IAAI;CAI5C,MAAM,UAAU,WAAW,wBAAwB;EAAE,GAAG;EAAO;EAAQ;EAAa;CAAU,IADhF,YAAY,MADZ,qBACsB,CACkE,CAAC;CAGvG,QAAQ,KAAK,IAAI,mBAAmB,QAAQ,KAAK;CAGjD,OAAO;EAAE,KADG,eAAe,gBAAgB,SAAS,YAAY,CACrD;EAAG;EAAS;CAAQ;AACjC"}
@@ -95,9 +95,9 @@ declare const XhStepsRoot: import("vue").DefineComponent<import("vue").ExtractPr
95
95
  size: Size;
96
96
  disabled: boolean;
97
97
  count: number;
98
+ linear: boolean;
98
99
  step: number;
99
100
  defaultStep: number;
100
- linear: boolean;
101
101
  }, SlotsType<{
102
102
  default?: (props: StepsRootSlotProps) => VNode[];
103
103
  }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -68,8 +68,8 @@ declare const XhSwitch: import("vue").DefineComponent<import("vue").ExtractPropT
68
68
  invalid: boolean;
69
69
  value: string;
70
70
  disabled: boolean;
71
- loading: boolean;
72
71
  readOnly: boolean;
72
+ loading: boolean;
73
73
  checked: boolean;
74
74
  defaultChecked: boolean;
75
75
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;