@wirekyt/vue 0.0.1 → 0.0.3

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 (291) hide show
  1. package/dist/accordion.cjs +273 -0
  2. package/dist/accordion.d.cts +195 -0
  3. package/dist/accordion.d.ts +195 -0
  4. package/dist/accordion.js +250 -0
  5. package/dist/angle-slider.cjs +268 -0
  6. package/dist/angle-slider.d.cts +228 -0
  7. package/dist/angle-slider.d.ts +228 -0
  8. package/dist/angle-slider.js +244 -0
  9. package/dist/avatar.cjs +145 -0
  10. package/dist/avatar.d.cts +114 -0
  11. package/dist/avatar.d.ts +114 -0
  12. package/dist/avatar.js +126 -0
  13. package/dist/boolean-BCaEpMxQ.js +6 -0
  14. package/dist/boolean-Dyu9-5Wp.cjs +11 -0
  15. package/dist/carousel.cjs +342 -0
  16. package/dist/carousel.d.cts +303 -0
  17. package/dist/carousel.d.ts +303 -0
  18. package/dist/carousel.js +320 -0
  19. package/dist/checkbox.cjs +345 -0
  20. package/dist/checkbox.d.cts +272 -0
  21. package/dist/checkbox.d.ts +272 -0
  22. package/dist/checkbox.js +324 -0
  23. package/dist/clean-props--1kqQE0Y.js +8 -0
  24. package/dist/clean-props-MyKqus13.cjs +13 -0
  25. package/dist/client-only.cjs +17 -0
  26. package/dist/client-only.d.cts +18 -0
  27. package/dist/client-only.d.ts +18 -0
  28. package/dist/client-only.js +16 -0
  29. package/dist/clipboard.cjs +229 -0
  30. package/dist/clipboard.d.cts +203 -0
  31. package/dist/clipboard.d.ts +203 -0
  32. package/dist/clipboard.js +206 -0
  33. package/dist/collapsible-BnUr4dTo.cjs +232 -0
  34. package/dist/collapsible-jvqnRz16.js +179 -0
  35. package/dist/collapsible.cjs +23 -0
  36. package/dist/collapsible.d.cts +161 -0
  37. package/dist/collapsible.d.ts +161 -0
  38. package/dist/collapsible.js +2 -0
  39. package/dist/collection-B0onOyyK.cjs +254 -0
  40. package/dist/collection-Dg6EtML_.js +211 -0
  41. package/dist/collection.cjs +9 -0
  42. package/dist/collection.d.cts +2 -0
  43. package/dist/collection.d.ts +2 -0
  44. package/dist/collection.js +2 -0
  45. package/dist/color-picker.cjs +804 -0
  46. package/dist/color-picker.d.cts +605 -0
  47. package/dist/color-picker.d.ts +605 -0
  48. package/dist/color-picker.js +759 -0
  49. package/dist/combobox.cjs +552 -0
  50. package/dist/combobox.d.cts +442 -0
  51. package/dist/combobox.d.ts +442 -0
  52. package/dist/combobox.js +521 -0
  53. package/dist/create-split-props-BBxrD7TV.js +10 -0
  54. package/dist/create-split-props-Jx-IEwdk.cjs +15 -0
  55. package/dist/date-input.cjs +293 -0
  56. package/dist/date-input.d.cts +212 -0
  57. package/dist/date-input.d.ts +212 -0
  58. package/dist/date-input.js +270 -0
  59. package/dist/date-picker.cjs +821 -0
  60. package/dist/date-picker.d.cts +637 -0
  61. package/dist/date-picker.d.ts +637 -0
  62. package/dist/date-picker.js +776 -0
  63. package/dist/dialog.cjs +333 -0
  64. package/dist/dialog.d.cts +272 -0
  65. package/dist/dialog.d.ts +272 -0
  66. package/dist/dialog.js +308 -0
  67. package/dist/download-trigger.cjs +65 -0
  68. package/dist/download-trigger.d.cts +34 -0
  69. package/dist/download-trigger.d.ts +34 -0
  70. package/dist/download-trigger.js +63 -0
  71. package/dist/drawer.cjs +448 -0
  72. package/dist/drawer.d.cts +346 -0
  73. package/dist/drawer.d.ts +346 -0
  74. package/dist/drawer.js +415 -0
  75. package/dist/editable.cjs +331 -0
  76. package/dist/editable.d.cts +285 -0
  77. package/dist/editable.d.ts +285 -0
  78. package/dist/editable.js +306 -0
  79. package/dist/factory-8Ao0DEy3.js +34 -0
  80. package/dist/factory-BNwuanv4.d.cts +21 -0
  81. package/dist/factory-BNwuanv4.d.ts +21 -0
  82. package/dist/factory-JL7MPjkk.cjs +45 -0
  83. package/dist/field-C3pLqz1S.js +435 -0
  84. package/dist/field-DRz-v4rB.cjs +524 -0
  85. package/dist/field.cjs +22 -0
  86. package/dist/field.d.cts +344 -0
  87. package/dist/field.d.ts +344 -0
  88. package/dist/field.js +2 -0
  89. package/dist/fieldset-ByP_r1Uq.js +216 -0
  90. package/dist/fieldset-C5aj6Ims.cjs +275 -0
  91. package/dist/fieldset.cjs +17 -0
  92. package/dist/fieldset.d.cts +159 -0
  93. package/dist/fieldset.d.ts +159 -0
  94. package/dist/fieldset.js +2 -0
  95. package/dist/file-upload.cjs +421 -0
  96. package/dist/file-upload.d.cts +327 -0
  97. package/dist/file-upload.d.ts +327 -0
  98. package/dist/file-upload.js +392 -0
  99. package/dist/floating-panel.cjs +412 -0
  100. package/dist/floating-panel.d.cts +337 -0
  101. package/dist/floating-panel.d.ts +337 -0
  102. package/dist/floating-panel.js +383 -0
  103. package/dist/focus-trap.cjs +79 -0
  104. package/dist/focus-trap.d.cts +46 -0
  105. package/dist/focus-trap.d.ts +46 -0
  106. package/dist/focus-trap.js +78 -0
  107. package/dist/format.cjs +116 -0
  108. package/dist/format.d.cts +46 -0
  109. package/dist/format.d.ts +46 -0
  110. package/dist/format.js +106 -0
  111. package/dist/frame.cjs +93 -0
  112. package/dist/frame.d.cts +37 -0
  113. package/dist/frame.d.ts +37 -0
  114. package/dist/frame.js +92 -0
  115. package/dist/highlight.cjs +44 -0
  116. package/dist/highlight.d.cts +32 -0
  117. package/dist/highlight.d.ts +32 -0
  118. package/dist/highlight.js +42 -0
  119. package/dist/hover-card.cjs +269 -0
  120. package/dist/hover-card.d.cts +202 -0
  121. package/dist/hover-card.d.ts +202 -0
  122. package/dist/hover-card.js +246 -0
  123. package/dist/image-cropper.cjs +252 -0
  124. package/dist/image-cropper.d.cts +207 -0
  125. package/dist/image-cropper.d.ts +207 -0
  126. package/dist/image-cropper.js +235 -0
  127. package/dist/index-B-o8jLyV.d.cts +31 -0
  128. package/dist/index-BSoF1D-v.d.ts +31 -0
  129. package/dist/index-BTNfeIXf.d.ts +104 -0
  130. package/dist/index-C8zR9eg3.d.ts +444 -0
  131. package/dist/index-Cc4qS0rQ.d.cts +38 -0
  132. package/dist/index-Cc4qS0rQ.d.ts +38 -0
  133. package/dist/index-DaLvr6SW.d.ts +37 -0
  134. package/dist/index-Di84rFjS.d.cts +444 -0
  135. package/dist/index-Dpm1wGVS.d.cts +74 -0
  136. package/dist/index-Zc9P69Ka.d.cts +104 -0
  137. package/dist/index-kCBQJqpU.d.ts +74 -0
  138. package/dist/index-vIbTjrJ-.d.cts +37 -0
  139. package/dist/index.cjs +43 -0
  140. package/dist/index.d.cts +5 -0
  141. package/dist/index.d.ts +5 -0
  142. package/dist/index.js +7 -0
  143. package/dist/json-tree-view.cjs +346 -0
  144. package/dist/json-tree-view.d.cts +86 -0
  145. package/dist/json-tree-view.d.ts +86 -0
  146. package/dist/json-tree-view.js +336 -0
  147. package/dist/listbox.cjs +386 -0
  148. package/dist/listbox.d.cts +323 -0
  149. package/dist/listbox.d.ts +323 -0
  150. package/dist/listbox.js +361 -0
  151. package/dist/marquee.cjs +256 -0
  152. package/dist/marquee.d.cts +208 -0
  153. package/dist/marquee.d.ts +208 -0
  154. package/dist/marquee.js +235 -0
  155. package/dist/menu.cjs +650 -0
  156. package/dist/menu.d.cts +501 -0
  157. package/dist/menu.d.ts +501 -0
  158. package/dist/menu.js +613 -0
  159. package/dist/navigation-menu.cjs +408 -0
  160. package/dist/navigation-menu.d.cts +271 -0
  161. package/dist/navigation-menu.d.ts +271 -0
  162. package/dist/navigation-menu.js +380 -0
  163. package/dist/number-input.cjs +298 -0
  164. package/dist/number-input.d.cts +253 -0
  165. package/dist/number-input.d.ts +253 -0
  166. package/dist/number-input.js +274 -0
  167. package/dist/pagination.cjs +249 -0
  168. package/dist/pagination.d.cts +209 -0
  169. package/dist/pagination.d.ts +209 -0
  170. package/dist/pagination.js +226 -0
  171. package/dist/password-input.cjs +232 -0
  172. package/dist/password-input.d.cts +208 -0
  173. package/dist/password-input.d.ts +208 -0
  174. package/dist/password-input.js +210 -0
  175. package/dist/pin-input.cjs +245 -0
  176. package/dist/pin-input.d.cts +199 -0
  177. package/dist/pin-input.d.ts +199 -0
  178. package/dist/pin-input.js +224 -0
  179. package/dist/popover.cjs +377 -0
  180. package/dist/popover.d.cts +324 -0
  181. package/dist/popover.d.ts +324 -0
  182. package/dist/popover.js +349 -0
  183. package/dist/presence-DD3l4Tgb.cjs +60 -0
  184. package/dist/presence-jaHZaD_O.js +43 -0
  185. package/dist/presence.cjs +7 -0
  186. package/dist/presence.d.cts +3 -0
  187. package/dist/presence.d.ts +3 -0
  188. package/dist/presence.js +3 -0
  189. package/dist/progress.cjs +270 -0
  190. package/dist/progress.d.cts +229 -0
  191. package/dist/progress.d.ts +229 -0
  192. package/dist/progress.js +245 -0
  193. package/dist/providers-5QhcwgSd.cjs +190 -0
  194. package/dist/providers-C3XQH-uu.js +119 -0
  195. package/dist/qr-code.cjs +195 -0
  196. package/dist/qr-code.d.cts +157 -0
  197. package/dist/qr-code.d.ts +157 -0
  198. package/dist/qr-code.js +174 -0
  199. package/dist/radio-group.cjs +274 -0
  200. package/dist/radio-group.d.cts +230 -0
  201. package/dist/radio-group.d.ts +230 -0
  202. package/dist/radio-group.js +249 -0
  203. package/dist/rating-group.cjs +243 -0
  204. package/dist/rating-group.d.cts +200 -0
  205. package/dist/rating-group.d.ts +200 -0
  206. package/dist/rating-group.js +220 -0
  207. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  208. package/dist/rolldown-runtime-DakpK96I.cjs +43 -0
  209. package/dist/scroll-area.cjs +206 -0
  210. package/dist/scroll-area.d.cts +169 -0
  211. package/dist/scroll-area.d.ts +169 -0
  212. package/dist/scroll-area.js +184 -0
  213. package/dist/segment-group.cjs +318 -0
  214. package/dist/segment-group.d.cts +229 -0
  215. package/dist/segment-group.d.ts +229 -0
  216. package/dist/segment-group.js +298 -0
  217. package/dist/select.cjs +560 -0
  218. package/dist/select.d.cts +430 -0
  219. package/dist/select.d.ts +430 -0
  220. package/dist/select.js +523 -0
  221. package/dist/signature-pad.cjs +260 -0
  222. package/dist/signature-pad.d.cts +200 -0
  223. package/dist/signature-pad.d.ts +200 -0
  224. package/dist/signature-pad.js +237 -0
  225. package/dist/slider.cjs +350 -0
  226. package/dist/slider.d.cts +299 -0
  227. package/dist/slider.d.ts +299 -0
  228. package/dist/slider.js +323 -0
  229. package/dist/splitter.cjs +225 -0
  230. package/dist/splitter.d.cts +166 -0
  231. package/dist/splitter.d.ts +166 -0
  232. package/dist/splitter.js +198 -0
  233. package/dist/steps.cjs +348 -0
  234. package/dist/steps.d.cts +289 -0
  235. package/dist/steps.d.ts +289 -0
  236. package/dist/steps.js +319 -0
  237. package/dist/swap.cjs +154 -0
  238. package/dist/swap.d.cts +98 -0
  239. package/dist/swap.d.ts +98 -0
  240. package/dist/swap.js +141 -0
  241. package/dist/switch.cjs +213 -0
  242. package/dist/switch.d.cts +177 -0
  243. package/dist/switch.d.ts +177 -0
  244. package/dist/switch.js +192 -0
  245. package/dist/tabs.cjs +240 -0
  246. package/dist/tabs.d.cts +179 -0
  247. package/dist/tabs.d.ts +179 -0
  248. package/dist/tabs.js +218 -0
  249. package/dist/tags-input.cjs +405 -0
  250. package/dist/tags-input.d.cts +340 -0
  251. package/dist/tags-input.d.ts +340 -0
  252. package/dist/tags-input.js +376 -0
  253. package/dist/timer.cjs +221 -0
  254. package/dist/timer.d.cts +176 -0
  255. package/dist/timer.d.ts +176 -0
  256. package/dist/timer.js +199 -0
  257. package/dist/toast.cjs +211 -0
  258. package/dist/toast.d.cts +157 -0
  259. package/dist/toast.d.ts +157 -0
  260. package/dist/toast.js +189 -0
  261. package/dist/toggle-group.cjs +150 -0
  262. package/dist/toggle-group.d.cts +122 -0
  263. package/dist/toggle-group.d.ts +122 -0
  264. package/dist/toggle-group.js +132 -0
  265. package/dist/toggle.cjs +107 -0
  266. package/dist/toggle.d.cts +98 -0
  267. package/dist/toggle.d.ts +98 -0
  268. package/dist/toggle.js +94 -0
  269. package/dist/tooltip.cjs +265 -0
  270. package/dist/tooltip.d.cts +204 -0
  271. package/dist/tooltip.d.ts +204 -0
  272. package/dist/tooltip.js +242 -0
  273. package/dist/tour.cjs +418 -0
  274. package/dist/tour.d.cts +304 -0
  275. package/dist/tour.d.ts +304 -0
  276. package/dist/tour.js +374 -0
  277. package/dist/tree-view-DnTVwhew.cjs +651 -0
  278. package/dist/tree-view-goUH3_RC.js +508 -0
  279. package/dist/tree-view.cjs +41 -0
  280. package/dist/tree-view.d.cts +3 -0
  281. package/dist/tree-view.d.ts +3 -0
  282. package/dist/tree-view.js +3 -0
  283. package/dist/types-rSRkzyd6.d.cts +13 -0
  284. package/dist/types-rSRkzyd6.d.ts +13 -0
  285. package/dist/use-presence-BSp_dR-C.d.cts +22 -0
  286. package/dist/use-presence-CtEY6ZT8.cjs +49 -0
  287. package/dist/use-presence-DkGU_j9h.d.ts +22 -0
  288. package/dist/use-presence-oNdFU2c2.js +42 -0
  289. package/dist/utils-D95V66v9.js +548 -0
  290. package/dist/utils-XrBZd2Yk.cjs +625 -0
  291. package/package.json +277 -6
@@ -0,0 +1,625 @@
1
+ let vue = require("vue");
2
+ let _wirekyt_dom = require("@wirekyt/dom");
3
+ let _wirekyt_dom_types = require("@wirekyt/dom/types");
4
+ let _wirekyt_dom_utils = require("@wirekyt/dom/utils");
5
+ //#region src/utils/create-context.ts
6
+ const createContext = (id) => {
7
+ const contextId = Symbol(id);
8
+ const provider = (value) => (0, vue.provide)(contextId, value);
9
+ const consumer = (fallback) => (0, vue.inject)(contextId, fallback);
10
+ return [
11
+ provider,
12
+ consumer,
13
+ contextId
14
+ ];
15
+ };
16
+ //#endregion
17
+ //#region src/utils/use-emits-as-props.ts
18
+ function useEmitAsProps(emit) {
19
+ const vm = (0, vue.getCurrentInstance)();
20
+ const events = vm?.type.emits;
21
+ const result = {};
22
+ if (!events?.length) console.warn(`No emitted event found. Please check component: ${vm?.type.__name}`);
23
+ for (const event of events) result[(0, vue.toHandlerKey)((0, vue.camelize)(event))] = (...arg) => emit(event, ...arg);
24
+ return result;
25
+ }
26
+ //#endregion
27
+ //#region src/utils/unref-element.ts
28
+ function unrefElement(elRef) {
29
+ const plain = (0, vue.toValue)(elRef);
30
+ return plain?.$el ?? plain;
31
+ }
32
+ //#endregion
33
+ //#region src/utils/use-forward-expose.ts
34
+ const isElement = (el) => Object.prototype.hasOwnProperty.call(el, "nodeName") && typeof el.nodeName === "string";
35
+ function useForwardExpose() {
36
+ const instance = (0, vue.getCurrentInstance)();
37
+ const currentRef = (0, vue.ref)();
38
+ const currentElement = (0, vue.computed)(() => {
39
+ return ["#text", "#comment"].includes(currentRef.value?.$el.nodeName) ? currentRef.value?.$el.nextElementSibling : unrefElement(currentRef);
40
+ });
41
+ const localExpose = Object.assign({}, instance.exposed);
42
+ const ret = {};
43
+ for (const key in instance.props) Object.defineProperty(ret, key, {
44
+ enumerable: true,
45
+ configurable: true,
46
+ get: () => instance.props[key]
47
+ });
48
+ if (Object.keys(localExpose).length > 0) for (const key in localExpose) Object.defineProperty(ret, key, {
49
+ enumerable: true,
50
+ configurable: true,
51
+ get: () => localExpose[key]
52
+ });
53
+ Object.defineProperty(ret, "$el", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ get: () => instance.vnode.el
57
+ });
58
+ instance.exposed = ret;
59
+ function forwardRef(ref) {
60
+ currentRef.value = ref;
61
+ if (!ref) return;
62
+ Object.defineProperty(ret, "$el", {
63
+ enumerable: true,
64
+ configurable: true,
65
+ get: () => isElement(ref) ? ref : ref.$el
66
+ });
67
+ instance.exposed = ret;
68
+ }
69
+ return {
70
+ forwardRef,
71
+ currentRef,
72
+ currentElement
73
+ };
74
+ }
75
+ //#endregion
76
+ //#region src/utils/use-forward-props.ts
77
+ function useForwardProps(props) {
78
+ const vm = (0, vue.getCurrentInstance)();
79
+ const propOptions = vm?.type.props ?? {};
80
+ const defaultProps = Object.keys(propOptions).reduce((prev, curr) => {
81
+ const defaultValue = propOptions[curr].default;
82
+ if (defaultValue !== void 0) prev[curr] = defaultValue;
83
+ return prev;
84
+ }, {});
85
+ const refProps = (0, vue.toRef)(props);
86
+ return (0, vue.computed)(() => {
87
+ const preservedProps = {};
88
+ const assignedProps = vm?.vnode.props ?? {};
89
+ Object.keys(assignedProps).forEach((key) => {
90
+ preservedProps[(0, vue.camelize)(key)] = assignedProps[key];
91
+ });
92
+ return Object.keys({
93
+ ...defaultProps,
94
+ ...preservedProps
95
+ }).reduce((prev, curr) => {
96
+ if (refProps.value[curr] !== void 0) prev[curr] = refProps.value[curr];
97
+ return prev;
98
+ }, {});
99
+ });
100
+ }
101
+ //#endregion
102
+ //#region src/utils/use-forward-props-emits.ts
103
+ function useForwardPropsEmits(props, emit) {
104
+ const parsedProps = useForwardProps(props);
105
+ const emitsAsProps = emit ? useEmitAsProps(emit) : {};
106
+ return (0, vue.computed)(() => ({
107
+ ...parsedProps.value,
108
+ ...emitsAsProps
109
+ }));
110
+ }
111
+ //#endregion
112
+ //#region src/core/normalize-props.ts
113
+ function toCase(txt) {
114
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
115
+ }
116
+ const propMap = {
117
+ htmlFor: "for",
118
+ className: "class",
119
+ onDoubleClick: "onDblclick",
120
+ onChange: "onInput",
121
+ onFocus: "onFocusin",
122
+ onBlur: "onFocusout",
123
+ defaultValue: "value",
124
+ defaultChecked: "checked"
125
+ };
126
+ const preserveKeys = "viewBox,className,preserveAspectRatio,fillRule,clipPath,clipRule,strokeWidth,strokeLinecap,strokeLinejoin,strokeDasharray,strokeDashoffset,strokeMiterlimit".split(",");
127
+ function toVueProp(prop) {
128
+ if (prop in propMap) return propMap[prop];
129
+ if (prop.startsWith("on")) return `on${toCase(prop.substr(2))}`;
130
+ if (preserveKeys.includes(prop)) return prop;
131
+ return prop.toLowerCase();
132
+ }
133
+ const normalizeProps = (0, _wirekyt_dom_types.createNormalizer)((props) => {
134
+ const normalized = {};
135
+ for (const key in props) {
136
+ const value = props[key];
137
+ if (key === "children") {
138
+ if (typeof value === "string") normalized["innerHTML"] = value;
139
+ else if (process.env.NODE_ENV !== "production" && value != null) console.warn("[Vue Normalize Prop] : avoid passing non-primitive value as `children`");
140
+ } else normalized[toVueProp(key)] = props[key];
141
+ }
142
+ return normalized;
143
+ });
144
+ //#endregion
145
+ //#region src/core/bindable.ts
146
+ function bindable(props) {
147
+ const initial = props().defaultValue ?? props().value;
148
+ const eq = props().isEqual ?? Object.is;
149
+ const v = (0, vue.shallowRef)(initial);
150
+ const controlled = (0, vue.computed)(() => props().value !== void 0);
151
+ return {
152
+ initial,
153
+ ref: (0, vue.shallowRef)(controlled.value ? props().value : v.value),
154
+ get() {
155
+ return controlled.value ? props().value : v.value;
156
+ },
157
+ set(val) {
158
+ const prev = controlled.value ? props().value : v.value;
159
+ const next = (0, _wirekyt_dom_utils.isFunction)(val) ? val(prev) : val;
160
+ if (props().debug) console.log(`[bindable > ${props().debug}] setValue`, {
161
+ next,
162
+ prev
163
+ });
164
+ if (!controlled.value) v.value = next;
165
+ if (!eq(next, prev)) props().onChange?.(next, prev);
166
+ },
167
+ invoke(nextValue, prevValue) {
168
+ props().onChange?.(nextValue, prevValue);
169
+ },
170
+ hash(value) {
171
+ return props().hash?.(value) ?? String(value);
172
+ }
173
+ };
174
+ }
175
+ bindable.cleanup = (fn) => {
176
+ (0, vue.onUnmounted)(() => fn());
177
+ };
178
+ bindable.ref = (defaultValue) => {
179
+ let value = defaultValue;
180
+ return {
181
+ get: () => value,
182
+ set: (next) => {
183
+ value = next;
184
+ }
185
+ };
186
+ };
187
+ //#endregion
188
+ //#region src/core/refs.ts
189
+ function useRefs(refs) {
190
+ const ref = { current: refs };
191
+ return {
192
+ get(key) {
193
+ return ref.current[key];
194
+ },
195
+ set(key, value) {
196
+ ref.current[key] = value;
197
+ }
198
+ };
199
+ }
200
+ //#endregion
201
+ //#region src/core/track.ts
202
+ const useTrack = (deps, effect) => {
203
+ (0, vue.watch)(() => deps.map((d) => d()), (current, previous) => {
204
+ let changed = false;
205
+ for (let i = 0; i < current.length; i++) if (!(0, _wirekyt_dom_utils.isEqual)(previous[i], (0, vue.toValue)(current[i]))) {
206
+ changed = true;
207
+ break;
208
+ }
209
+ if (changed) effect();
210
+ });
211
+ };
212
+ //#endregion
213
+ //#region src/core/machine.ts
214
+ function useMachine(machine, userProps = {}) {
215
+ const scope = (0, vue.computed)(() => {
216
+ const { id, ids, getRootNode } = (0, vue.toValue)(userProps);
217
+ return (0, _wirekyt_dom.createScope)({
218
+ id,
219
+ ids,
220
+ getRootNode
221
+ });
222
+ });
223
+ const debug = (...args) => {
224
+ if (machine.debug) console.log(...args);
225
+ };
226
+ const prop = useProp((0, vue.computed)(() => machine.props?.({
227
+ props: (0, _wirekyt_dom_utils.compact)((0, vue.toValue)(userProps)),
228
+ get scope() {
229
+ return scope.value;
230
+ }
231
+ }) ?? (0, vue.toValue)(userProps)));
232
+ const context = machine.context?.({
233
+ prop,
234
+ bindable,
235
+ get scope() {
236
+ return scope.value;
237
+ },
238
+ flush,
239
+ getContext() {
240
+ return ctx;
241
+ },
242
+ getComputed() {
243
+ return computed;
244
+ },
245
+ getRefs() {
246
+ return refs;
247
+ },
248
+ getEvent() {
249
+ return getEvent();
250
+ }
251
+ });
252
+ const ctx = {
253
+ get(key) {
254
+ return context[key]?.get();
255
+ },
256
+ set(key, value) {
257
+ context[key]?.set(value);
258
+ },
259
+ initial(key) {
260
+ return context[key]?.initial;
261
+ },
262
+ hash(key) {
263
+ const current = context[key]?.get();
264
+ return context[key]?.hash(current);
265
+ }
266
+ };
267
+ let effects = /* @__PURE__ */ new Map();
268
+ let transitionRef = null;
269
+ let previousEventRef = { current: null };
270
+ let eventRef = { current: { type: "" } };
271
+ const getEvent = () => ({
272
+ ...eventRef.current,
273
+ current() {
274
+ return eventRef.current;
275
+ },
276
+ previous() {
277
+ return previousEventRef.current;
278
+ }
279
+ });
280
+ const getState = () => ({
281
+ ...state,
282
+ matches(...values) {
283
+ const currentState = state.get();
284
+ return values.some((value) => (0, _wirekyt_dom.matchesState)(currentState, value));
285
+ },
286
+ hasTag(tag) {
287
+ return (0, _wirekyt_dom.hasTag)(machine, state.get(), tag);
288
+ }
289
+ });
290
+ const refs = useRefs(machine.refs?.({
291
+ prop,
292
+ context: ctx
293
+ }) ?? {});
294
+ const getParams = () => ({
295
+ state: getState(),
296
+ context: ctx,
297
+ event: getEvent(),
298
+ prop,
299
+ send,
300
+ action,
301
+ guard,
302
+ track: useTrack,
303
+ refs,
304
+ computed,
305
+ flush,
306
+ get scope() {
307
+ return scope.value;
308
+ },
309
+ choose
310
+ });
311
+ const action = (keys) => {
312
+ const strs = (0, _wirekyt_dom_utils.isFunction)(keys) ? keys(getParams()) : keys;
313
+ if (!strs) return;
314
+ const fns = strs.map((s) => {
315
+ const fn = machine.implementations?.actions?.[s];
316
+ if (!fn) (0, _wirekyt_dom_utils.warn)(`[wirekyt] No implementation found for action "${JSON.stringify(s)}"`);
317
+ return fn;
318
+ });
319
+ for (const fn of fns) fn?.(getParams());
320
+ };
321
+ const guard = (str) => {
322
+ if ((0, _wirekyt_dom_utils.isFunction)(str)) return str(getParams());
323
+ const fn = machine.implementations?.guards?.[str];
324
+ if (!fn) (0, _wirekyt_dom_utils.warn)(`[wirekyt] No implementation found for guard "${JSON.stringify(str)}"`);
325
+ return fn?.(getParams());
326
+ };
327
+ const effect = (keys) => {
328
+ const strs = (0, _wirekyt_dom_utils.isFunction)(keys) ? keys(getParams()) : keys;
329
+ if (!strs) return;
330
+ const fns = strs.map((s) => {
331
+ const fn = machine.implementations?.effects?.[s];
332
+ if (!fn) (0, _wirekyt_dom_utils.warn)(`[wirekyt] No implementation found for effect "${JSON.stringify(s)}"`);
333
+ return fn;
334
+ });
335
+ const cleanups = [];
336
+ for (const fn of fns) {
337
+ const cleanup = fn?.(getParams());
338
+ if (cleanup) cleanups.push(cleanup);
339
+ }
340
+ return () => cleanups.forEach((fn) => fn?.());
341
+ };
342
+ const choose = (transitions) => {
343
+ return (0, _wirekyt_dom_utils.toArray)(transitions).find((t) => {
344
+ let result = !t.guard;
345
+ if ((0, _wirekyt_dom_utils.isString)(t.guard)) result = !!guard(t.guard);
346
+ else if ((0, _wirekyt_dom_utils.isFunction)(t.guard)) result = t.guard(getParams());
347
+ return result;
348
+ });
349
+ };
350
+ const computed = (key) => {
351
+ (0, _wirekyt_dom_utils.ensure)(machine.computed, () => `[wirekyt] No computed object found on machine`);
352
+ const fn = machine.computed[key];
353
+ return fn({
354
+ context: ctx,
355
+ event: getEvent(),
356
+ prop,
357
+ refs,
358
+ get scope() {
359
+ return scope.value;
360
+ },
361
+ computed
362
+ });
363
+ };
364
+ const state = bindable(() => ({
365
+ defaultValue: (0, _wirekyt_dom.resolveStateValue)(machine, machine.initialState({ prop })),
366
+ onChange(nextState, prevState) {
367
+ const { exiting, entering } = (0, _wirekyt_dom.getExitEnterStates)(machine, prevState, nextState, transitionRef?.reenter);
368
+ exiting.forEach((item) => {
369
+ effects.get(item.path)?.();
370
+ effects.delete(item.path);
371
+ });
372
+ exiting.forEach((item) => {
373
+ action(item.state?.exit);
374
+ });
375
+ action(transitionRef?.actions);
376
+ entering.forEach((item) => {
377
+ const cleanup = effect(item.state?.effects);
378
+ if (cleanup) {
379
+ const existing = effects.get(item.path);
380
+ effects.set(item.path, existing ? (0, _wirekyt_dom_utils.callAll)(existing, cleanup) : cleanup);
381
+ }
382
+ });
383
+ if (prevState === _wirekyt_dom.INIT_STATE) {
384
+ action(machine.entry);
385
+ const cleanup = effect(machine.effects);
386
+ if (cleanup) {
387
+ const existing = effects.get(_wirekyt_dom.INIT_STATE);
388
+ effects.set(_wirekyt_dom.INIT_STATE, existing ? (0, _wirekyt_dom_utils.callAll)(existing, cleanup) : cleanup);
389
+ }
390
+ }
391
+ entering.forEach((item) => {
392
+ action(item.state?.entry);
393
+ });
394
+ }
395
+ }));
396
+ let status = _wirekyt_dom.MachineStatus.NotStarted;
397
+ let pendingEvents = [];
398
+ (0, vue.onMounted)(() => {
399
+ const started = status === _wirekyt_dom.MachineStatus.Started;
400
+ status = _wirekyt_dom.MachineStatus.Started;
401
+ debug(started ? "rehydrating..." : "initializing...");
402
+ state.invoke(state.initial, _wirekyt_dom.INIT_STATE);
403
+ const events = pendingEvents;
404
+ pendingEvents = [];
405
+ for (const event of events) send(event);
406
+ });
407
+ (0, vue.onBeforeUnmount)(() => {
408
+ status = _wirekyt_dom.MachineStatus.Stopped;
409
+ pendingEvents = [];
410
+ debug("unmounting...");
411
+ const fns = effects.values();
412
+ for (const fn of fns) fn?.();
413
+ effects = /* @__PURE__ */ new Map();
414
+ action(machine.exit);
415
+ });
416
+ const send = (event) => {
417
+ if (status !== _wirekyt_dom.MachineStatus.Started) {
418
+ pendingEvents.push(event);
419
+ return;
420
+ }
421
+ previousEventRef.current = eventRef.current;
422
+ eventRef.current = event;
423
+ let currentState = state.get();
424
+ const { transitions, source } = (0, _wirekyt_dom.findTransition)(machine, currentState, event.type);
425
+ const transition = choose(transitions);
426
+ if (!transition) return;
427
+ transitionRef = transition;
428
+ const target = (0, _wirekyt_dom.resolveStateValue)(machine, transition.target ?? currentState, source);
429
+ debug("transition", event.type, transition.target || currentState, `(${transition.actions})`);
430
+ if (target !== currentState) state.set(target);
431
+ else if (transition.reenter) state.invoke(currentState, currentState);
432
+ else action(transition.actions);
433
+ };
434
+ machine.watch?.(getParams());
435
+ return {
436
+ state: getState(),
437
+ send,
438
+ context: ctx,
439
+ prop,
440
+ get scope() {
441
+ return scope.value;
442
+ },
443
+ refs,
444
+ computed,
445
+ event: getEvent(),
446
+ getStatus: () => status
447
+ };
448
+ }
449
+ function useProp(valueRef) {
450
+ return function get(key) {
451
+ return valueRef.value[key];
452
+ };
453
+ }
454
+ const flush = (fn) => {
455
+ (0, vue.nextTick)().then(() => {
456
+ fn();
457
+ });
458
+ };
459
+ //#endregion
460
+ //#region src/core/use-sync-external-store.ts
461
+ function useSyncExternalStore(subscribe, getSnapshot, _getServerSnapshot) {
462
+ const snapshot = (0, vue.shallowRef)(getSnapshot());
463
+ let unsubscribe;
464
+ (0, vue.onMounted)(() => {
465
+ snapshot.value = getSnapshot();
466
+ unsubscribe = subscribe(() => {
467
+ snapshot.value = getSnapshot();
468
+ });
469
+ });
470
+ (0, vue.onUnmounted)(() => {
471
+ unsubscribe?.();
472
+ });
473
+ return (0, vue.readonly)(snapshot);
474
+ }
475
+ //#endregion
476
+ //#region src/utils/dynamic.ts
477
+ const Dynamic = (0, vue.defineComponent)({
478
+ name: "Dynamic",
479
+ inheritAttrs: false,
480
+ setup(_, { attrs, slots }) {
481
+ return () => {
482
+ if (!slots.default) return null;
483
+ const children = renderSlotFragments(slots.default());
484
+ const [firstChildren, ...otherChildren] = children;
485
+ if (firstChildren && Object.keys(attrs).length > 0) {
486
+ delete firstChildren.props?.ref;
487
+ const mergedProps = (0, _wirekyt_dom.mergeProps)(attrs, firstChildren.props ?? {});
488
+ const cloned = (0, vue.cloneVNode)(firstChildren, mergedProps);
489
+ for (const prop in mergedProps) if (prop.startsWith("on")) {
490
+ cloned.props ||= {};
491
+ cloned.props[prop] = mergedProps[prop];
492
+ }
493
+ return children.length === 1 ? cloned : [cloned, ...otherChildren];
494
+ }
495
+ return children;
496
+ };
497
+ }
498
+ });
499
+ function renderSlotFragments(children) {
500
+ if (!children) return [];
501
+ return children.flatMap((child) => {
502
+ if (child.type === vue.Fragment) return renderSlotFragments(child.children);
503
+ return [child];
504
+ });
505
+ }
506
+ //#endregion
507
+ //#region src/utils/use-render-strategy.ts
508
+ const [RenderStrategyPropsProvider, useRenderStrategyProps] = createContext("RenderStrategyProps");
509
+ //#endregion
510
+ //#region src/utils/use-v-model.ts
511
+ function useVModel(props, key, emit, options = {}) {
512
+ const { passive = false, eventName, defaultValue } = options;
513
+ const vm = (0, vue.getCurrentInstance)();
514
+ const _emit = emit || vm?.emit || vm?.$emit?.bind(vm) || vm?.proxy?.$emit?.bind(vm?.proxy);
515
+ const prop = key || "modelValue";
516
+ const getValue = () => props[prop] ?? defaultValue;
517
+ const triggerEmit = (value) => {
518
+ if (!eventName) _emit(eventName || `update:${prop.toString()}`, value);
519
+ else for (const event of eventName) _emit(event, value);
520
+ };
521
+ if (passive) {
522
+ const proxy = (0, vue.ref)(getValue());
523
+ let isUpdating = false;
524
+ (0, vue.watch)(() => props[prop], (v) => {
525
+ if (!isUpdating) {
526
+ isUpdating = true;
527
+ proxy.value = v;
528
+ (0, vue.nextTick)(() => {
529
+ isUpdating = false;
530
+ });
531
+ }
532
+ });
533
+ (0, vue.watch)(proxy, (v) => {
534
+ if (!isUpdating && v !== props[prop]) triggerEmit(v);
535
+ });
536
+ return proxy;
537
+ }
538
+ return (0, vue.computed)({
539
+ get() {
540
+ return getValue();
541
+ },
542
+ set(value) {
543
+ triggerEmit(value);
544
+ }
545
+ });
546
+ }
547
+ //#endregion
548
+ Object.defineProperty(exports, "Dynamic", {
549
+ enumerable: true,
550
+ get: function() {
551
+ return Dynamic;
552
+ }
553
+ });
554
+ Object.defineProperty(exports, "RenderStrategyPropsProvider", {
555
+ enumerable: true,
556
+ get: function() {
557
+ return RenderStrategyPropsProvider;
558
+ }
559
+ });
560
+ Object.defineProperty(exports, "createContext", {
561
+ enumerable: true,
562
+ get: function() {
563
+ return createContext;
564
+ }
565
+ });
566
+ Object.defineProperty(exports, "normalizeProps", {
567
+ enumerable: true,
568
+ get: function() {
569
+ return normalizeProps;
570
+ }
571
+ });
572
+ Object.defineProperty(exports, "unrefElement", {
573
+ enumerable: true,
574
+ get: function() {
575
+ return unrefElement;
576
+ }
577
+ });
578
+ Object.defineProperty(exports, "useEmitAsProps", {
579
+ enumerable: true,
580
+ get: function() {
581
+ return useEmitAsProps;
582
+ }
583
+ });
584
+ Object.defineProperty(exports, "useForwardExpose", {
585
+ enumerable: true,
586
+ get: function() {
587
+ return useForwardExpose;
588
+ }
589
+ });
590
+ Object.defineProperty(exports, "useForwardProps", {
591
+ enumerable: true,
592
+ get: function() {
593
+ return useForwardProps;
594
+ }
595
+ });
596
+ Object.defineProperty(exports, "useForwardPropsEmits", {
597
+ enumerable: true,
598
+ get: function() {
599
+ return useForwardPropsEmits;
600
+ }
601
+ });
602
+ Object.defineProperty(exports, "useMachine", {
603
+ enumerable: true,
604
+ get: function() {
605
+ return useMachine;
606
+ }
607
+ });
608
+ Object.defineProperty(exports, "useRenderStrategyProps", {
609
+ enumerable: true,
610
+ get: function() {
611
+ return useRenderStrategyProps;
612
+ }
613
+ });
614
+ Object.defineProperty(exports, "useSyncExternalStore", {
615
+ enumerable: true,
616
+ get: function() {
617
+ return useSyncExternalStore;
618
+ }
619
+ });
620
+ Object.defineProperty(exports, "useVModel", {
621
+ enumerable: true,
622
+ get: function() {
623
+ return useVModel;
624
+ }
625
+ });