@wirekyt/react 0.0.1 → 0.0.2

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 (285) hide show
  1. package/dist/accordion.cjs +209 -0
  2. package/dist/accordion.d.cts +69 -0
  3. package/dist/accordion.d.ts +69 -0
  4. package/dist/accordion.js +184 -0
  5. package/dist/angle-slider.cjs +193 -0
  6. package/dist/angle-slider.d.cts +73 -0
  7. package/dist/angle-slider.d.ts +73 -0
  8. package/dist/angle-slider.js +168 -0
  9. package/dist/avatar.cjs +120 -0
  10. package/dist/avatar.d.cts +48 -0
  11. package/dist/avatar.d.ts +48 -0
  12. package/dist/avatar.js +100 -0
  13. package/dist/carousel.cjs +246 -0
  14. package/dist/carousel.d.cts +94 -0
  15. package/dist/carousel.d.ts +94 -0
  16. package/dist/carousel.js +223 -0
  17. package/dist/checkbox.cjs +284 -0
  18. package/dist/checkbox.d.cts +115 -0
  19. package/dist/checkbox.d.ts +115 -0
  20. package/dist/checkbox.js +263 -0
  21. package/dist/client-only.cjs +12 -0
  22. package/dist/client-only.d.cts +8 -0
  23. package/dist/client-only.d.ts +8 -0
  24. package/dist/client-only.js +11 -0
  25. package/dist/clipboard.cjs +174 -0
  26. package/dist/clipboard.d.cts +70 -0
  27. package/dist/clipboard.d.ts +70 -0
  28. package/dist/clipboard.js +150 -0
  29. package/dist/collapsible-B62i_oPJ.cjs +185 -0
  30. package/dist/collapsible-CiTNjCNf.js +131 -0
  31. package/dist/collapsible.cjs +23 -0
  32. package/dist/collapsible.d.cts +56 -0
  33. package/dist/collapsible.d.ts +56 -0
  34. package/dist/collapsible.js +2 -0
  35. package/dist/collection-BFjWNdUS.cjs +223 -0
  36. package/dist/collection-BJOl6a4H.js +180 -0
  37. package/dist/collection.cjs +9 -0
  38. package/dist/collection.d.cts +2 -0
  39. package/dist/collection.d.ts +2 -0
  40. package/dist/collection.js +2 -0
  41. package/dist/color-picker.cjs +575 -0
  42. package/dist/color-picker.d.cts +179 -0
  43. package/dist/color-picker.d.ts +179 -0
  44. package/dist/color-picker.js +530 -0
  45. package/dist/combobox.cjs +390 -0
  46. package/dist/combobox.d.cts +128 -0
  47. package/dist/combobox.d.ts +128 -0
  48. package/dist/combobox.js +359 -0
  49. package/dist/core-CBFAnVIP.cjs +375 -0
  50. package/dist/core-CEYOEcVI.js +357 -0
  51. package/dist/date-input.cjs +217 -0
  52. package/dist/date-input.d.cts +69 -0
  53. package/dist/date-input.d.ts +69 -0
  54. package/dist/date-input.js +193 -0
  55. package/dist/date-picker.cjs +588 -0
  56. package/dist/date-picker.d.cts +190 -0
  57. package/dist/date-picker.d.ts +190 -0
  58. package/dist/date-picker.js +543 -0
  59. package/dist/dialog.cjs +199 -0
  60. package/dist/dialog.d.cts +78 -0
  61. package/dist/dialog.d.ts +78 -0
  62. package/dist/dialog.js +174 -0
  63. package/dist/download-trigger.cjs +53 -0
  64. package/dist/download-trigger.d.cts +22 -0
  65. package/dist/download-trigger.d.ts +22 -0
  66. package/dist/download-trigger.js +51 -0
  67. package/dist/drawer.cjs +296 -0
  68. package/dist/drawer.d.cts +115 -0
  69. package/dist/drawer.d.ts +115 -0
  70. package/dist/drawer.js +264 -0
  71. package/dist/editable.cjs +228 -0
  72. package/dist/editable.d.cts +79 -0
  73. package/dist/editable.d.ts +79 -0
  74. package/dist/editable.js +202 -0
  75. package/dist/environment-B6IaCAuQ.cjs +59 -0
  76. package/dist/environment-BTgKwk5E.js +42 -0
  77. package/dist/factory--dkoVnFK.d.cts +14 -0
  78. package/dist/factory--dkoVnFK.d.ts +14 -0
  79. package/dist/factory-CFFufs5e.cjs +59 -0
  80. package/dist/factory-Nm__-4xn.js +48 -0
  81. package/dist/field-Cy1E02DH.js +349 -0
  82. package/dist/field-x8H5uXB9.cjs +438 -0
  83. package/dist/field.cjs +22 -0
  84. package/dist/field.d.cts +129 -0
  85. package/dist/field.d.ts +129 -0
  86. package/dist/field.js +2 -0
  87. package/dist/fieldset-DWZXj1t5.cjs +232 -0
  88. package/dist/fieldset-fx44GCtM.js +178 -0
  89. package/dist/fieldset.cjs +18 -0
  90. package/dist/fieldset.d.cts +71 -0
  91. package/dist/fieldset.d.ts +71 -0
  92. package/dist/fieldset.js +3 -0
  93. package/dist/file-upload.cjs +328 -0
  94. package/dist/file-upload.d.cts +101 -0
  95. package/dist/file-upload.d.ts +101 -0
  96. package/dist/file-upload.js +298 -0
  97. package/dist/floating-panel.cjs +271 -0
  98. package/dist/floating-panel.d.cts +98 -0
  99. package/dist/floating-panel.d.ts +98 -0
  100. package/dist/floating-panel.js +242 -0
  101. package/dist/format.cjs +64 -0
  102. package/dist/format.d.cts +44 -0
  103. package/dist/format.d.ts +44 -0
  104. package/dist/format.js +54 -0
  105. package/dist/frame.cjs +85 -0
  106. package/dist/frame.d.cts +12 -0
  107. package/dist/frame.d.ts +12 -0
  108. package/dist/frame.js +84 -0
  109. package/dist/highlight.cjs +29 -0
  110. package/dist/highlight.d.cts +13 -0
  111. package/dist/highlight.d.ts +13 -0
  112. package/dist/highlight.js +27 -0
  113. package/dist/hover-card.cjs +154 -0
  114. package/dist/hover-card.d.cts +68 -0
  115. package/dist/hover-card.d.ts +68 -0
  116. package/dist/hover-card.js +131 -0
  117. package/dist/image-cropper.cjs +0 -0
  118. package/dist/image-cropper.d.cts +1 -0
  119. package/dist/image-cropper.d.ts +1 -0
  120. package/dist/image-cropper.js +0 -0
  121. package/dist/index-3Al0R5bH.d.cts +73 -0
  122. package/dist/index-B7wAg5Wf.d.ts +146 -0
  123. package/dist/index-BAn8qiCM.d.ts +73 -0
  124. package/dist/index-BSX88T_g.d.cts +146 -0
  125. package/dist/index-CQAbOgb7.d.cts +23 -0
  126. package/dist/index-CUyHBXOI.d.cts +33 -0
  127. package/dist/index-CW-Aj6aT.d.ts +95 -0
  128. package/dist/index-CxWYgVJk.d.ts +23 -0
  129. package/dist/index-D7JH9e9E.d.ts +33 -0
  130. package/dist/index-DTLK6Fuh.d.cts +95 -0
  131. package/dist/index-srZfUQNt.d.cts +20 -0
  132. package/dist/index-srZfUQNt.d.ts +20 -0
  133. package/dist/index.cjs +45 -0
  134. package/dist/index.d.cts +6 -0
  135. package/dist/index.d.ts +6 -0
  136. package/dist/index.js +6 -0
  137. package/dist/json-tree-view.cjs +244 -0
  138. package/dist/json-tree-view.d.cts +45 -0
  139. package/dist/json-tree-view.d.ts +45 -0
  140. package/dist/json-tree-view.js +234 -0
  141. package/dist/listbox.cjs +290 -0
  142. package/dist/listbox.d.cts +109 -0
  143. package/dist/listbox.d.ts +109 -0
  144. package/dist/listbox.js +264 -0
  145. package/dist/marquee.cjs +164 -0
  146. package/dist/marquee.d.cts +60 -0
  147. package/dist/marquee.d.ts +60 -0
  148. package/dist/marquee.js +142 -0
  149. package/dist/menu.cjs +506 -0
  150. package/dist/menu.d.cts +162 -0
  151. package/dist/menu.d.ts +162 -0
  152. package/dist/menu.js +469 -0
  153. package/dist/navigation-menu.cjs +331 -0
  154. package/dist/navigation-menu.d.cts +89 -0
  155. package/dist/navigation-menu.d.ts +89 -0
  156. package/dist/navigation-menu.js +303 -0
  157. package/dist/number-input.cjs +222 -0
  158. package/dist/number-input.d.cts +73 -0
  159. package/dist/number-input.d.ts +73 -0
  160. package/dist/number-input.js +197 -0
  161. package/dist/pagination.cjs +183 -0
  162. package/dist/pagination.d.cts +68 -0
  163. package/dist/pagination.d.ts +68 -0
  164. package/dist/pagination.js +159 -0
  165. package/dist/password-input.cjs +179 -0
  166. package/dist/password-input.d.cts +65 -0
  167. package/dist/password-input.d.ts +65 -0
  168. package/dist/password-input.js +156 -0
  169. package/dist/pin-input.cjs +180 -0
  170. package/dist/pin-input.d.cts +58 -0
  171. package/dist/pin-input.d.ts +58 -0
  172. package/dist/pin-input.js +158 -0
  173. package/dist/popover.cjs +222 -0
  174. package/dist/popover.d.cts +93 -0
  175. package/dist/popover.d.ts +93 -0
  176. package/dist/popover.js +194 -0
  177. package/dist/portal-6_XzBXiA.cjs +33 -0
  178. package/dist/portal-QYL_2wB0.js +28 -0
  179. package/dist/portal.cjs +3 -0
  180. package/dist/portal.d.cts +9 -0
  181. package/dist/portal.d.ts +9 -0
  182. package/dist/portal.js +2 -0
  183. package/dist/presence-BOs-D6Cv.cjs +96 -0
  184. package/dist/presence-I8Rceflw.js +65 -0
  185. package/dist/presence.cjs +7 -0
  186. package/dist/presence.d.cts +2 -0
  187. package/dist/presence.d.ts +2 -0
  188. package/dist/presence.js +2 -0
  189. package/dist/progress.cjs +206 -0
  190. package/dist/progress.d.cts +78 -0
  191. package/dist/progress.d.ts +78 -0
  192. package/dist/progress.js +180 -0
  193. package/dist/providers-DrJEJcrE.cjs +128 -0
  194. package/dist/providers-FEHnDTvb.js +87 -0
  195. package/dist/qr-code.cjs +154 -0
  196. package/dist/qr-code.d.cts +58 -0
  197. package/dist/qr-code.d.ts +58 -0
  198. package/dist/qr-code.js +132 -0
  199. package/dist/radio-group.cjs +222 -0
  200. package/dist/radio-group.d.cts +78 -0
  201. package/dist/radio-group.d.ts +78 -0
  202. package/dist/radio-group.js +196 -0
  203. package/dist/rating-group.cjs +186 -0
  204. package/dist/rating-group.d.cts +68 -0
  205. package/dist/rating-group.d.ts +68 -0
  206. package/dist/rating-group.js +162 -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 +166 -0
  210. package/dist/scroll-area.d.cts +67 -0
  211. package/dist/scroll-area.d.ts +67 -0
  212. package/dist/scroll-area.js +143 -0
  213. package/dist/segment-group.cjs +215 -0
  214. package/dist/segment-group.d.cts +81 -0
  215. package/dist/segment-group.d.ts +81 -0
  216. package/dist/segment-group.js +194 -0
  217. package/dist/select.cjs +395 -0
  218. package/dist/select.d.cts +132 -0
  219. package/dist/select.d.ts +132 -0
  220. package/dist/select.js +358 -0
  221. package/dist/signature-pad.cjs +197 -0
  222. package/dist/signature-pad.d.cts +68 -0
  223. package/dist/signature-pad.d.ts +68 -0
  224. package/dist/signature-pad.js +173 -0
  225. package/dist/slider.cjs +260 -0
  226. package/dist/slider.d.cts +88 -0
  227. package/dist/slider.d.ts +88 -0
  228. package/dist/slider.js +232 -0
  229. package/dist/steps.cjs +271 -0
  230. package/dist/steps.d.cts +104 -0
  231. package/dist/steps.d.ts +104 -0
  232. package/dist/steps.js +241 -0
  233. package/dist/swap.cjs +134 -0
  234. package/dist/swap.d.cts +49 -0
  235. package/dist/swap.d.ts +49 -0
  236. package/dist/swap.js +121 -0
  237. package/dist/switch.cjs +166 -0
  238. package/dist/switch.d.cts +58 -0
  239. package/dist/switch.d.ts +58 -0
  240. package/dist/switch.js +144 -0
  241. package/dist/tabs.cjs +177 -0
  242. package/dist/tabs.d.cts +59 -0
  243. package/dist/tabs.d.ts +59 -0
  244. package/dist/tabs.js +155 -0
  245. package/dist/tags-input.cjs +298 -0
  246. package/dist/tags-input.d.cts +98 -0
  247. package/dist/tags-input.d.ts +98 -0
  248. package/dist/tags-input.js +268 -0
  249. package/dist/timer.cjs +167 -0
  250. package/dist/timer.d.cts +63 -0
  251. package/dist/timer.d.ts +63 -0
  252. package/dist/timer.js +144 -0
  253. package/dist/toast.cjs +154 -0
  254. package/dist/toast.d.cts +59 -0
  255. package/dist/toast.d.ts +59 -0
  256. package/dist/toast.js +132 -0
  257. package/dist/toggle-group.cjs +118 -0
  258. package/dist/toggle-group.d.cts +43 -0
  259. package/dist/toggle-group.d.ts +43 -0
  260. package/dist/toggle-group.js +99 -0
  261. package/dist/toggle.cjs +85 -0
  262. package/dist/toggle.d.cts +38 -0
  263. package/dist/toggle.d.ts +38 -0
  264. package/dist/toggle.js +71 -0
  265. package/dist/tooltip.cjs +154 -0
  266. package/dist/tooltip.d.cts +68 -0
  267. package/dist/tooltip.d.ts +68 -0
  268. package/dist/tooltip.js +131 -0
  269. package/dist/tour.cjs +290 -0
  270. package/dist/tour.d.cts +112 -0
  271. package/dist/tour.d.ts +112 -0
  272. package/dist/tour.js +246 -0
  273. package/dist/tree-view-CNTEWXlu.js +339 -0
  274. package/dist/tree-view-CU4Hl5X1.cjs +484 -0
  275. package/dist/tree-view.cjs +41 -0
  276. package/dist/tree-view.d.cts +3 -0
  277. package/dist/tree-view.d.ts +3 -0
  278. package/dist/tree-view.js +3 -0
  279. package/dist/types-BQQfrr86.d.cts +6 -0
  280. package/dist/types-BQQfrr86.d.ts +6 -0
  281. package/dist/use-context-38DKWHsx.cjs +20 -0
  282. package/dist/use-context-CITa6pn9.js +10 -0
  283. package/dist/utils-Cfwm9WW1.cjs +166 -0
  284. package/dist/utils-CqLmqrgj.js +107 -0
  285. package/package.json +274 -6
@@ -0,0 +1,357 @@
1
+ import { callAll, compact, ensure, identity, isFunction, isString, toArray, warn } from "@wirekyt/dom/utils";
2
+ import * as React$1 from "react";
3
+ import { useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore as useSyncExternalStore$1 } from "react";
4
+ import { INIT_STATE, MachineStatus, createScope, findTransition, getExitEnterStates, hasTag, matchesState, mergeProps as mergeProps$1, resolveStateValue } from "@wirekyt/dom";
5
+ import { createPortal, flushSync } from "react-dom";
6
+ import { createNormalizer } from "@wirekyt/dom/types";
7
+ import { jsx } from "react/jsx-runtime";
8
+ //#region src/core/use-layout-effect.ts
9
+ const useSafeLayoutEffect = typeof globalThis.document !== "undefined" ? useLayoutEffect : useEffect;
10
+ //#endregion
11
+ //#region src/core/bindable.ts
12
+ function useBindable(props) {
13
+ const initial = props().value ?? props().defaultValue;
14
+ const eq = props().isEqual ?? Object.is;
15
+ const [initialValue] = useState(initial);
16
+ const [value, setValue] = useState(initialValue);
17
+ const controlled = props().value !== void 0;
18
+ const valueRef = useRef(value);
19
+ valueRef.current = controlled ? props().value : value;
20
+ const prevValue = useRef(valueRef.current);
21
+ useSafeLayoutEffect(() => {
22
+ prevValue.current = valueRef.current;
23
+ }, [value, props().value]);
24
+ const setFn = (value) => {
25
+ const prev = prevValue.current;
26
+ const next = isFunction(value) ? value(prev) : value;
27
+ if (props().debug) console.log(`[bindable > ${props().debug}] setValue`, {
28
+ next,
29
+ prev
30
+ });
31
+ if (!controlled) setValue(next);
32
+ if (!eq(next, prev)) props().onChange?.(next, prev);
33
+ };
34
+ function get() {
35
+ return controlled ? props().value : value;
36
+ }
37
+ return {
38
+ initial: initialValue,
39
+ ref: valueRef,
40
+ get,
41
+ set(value) {
42
+ (props().sync ? flushSync : identity)(() => setFn(value));
43
+ },
44
+ invoke(nextValue, prevValue) {
45
+ props().onChange?.(nextValue, prevValue);
46
+ },
47
+ hash(value) {
48
+ return props().hash?.(value) ?? String(value);
49
+ }
50
+ };
51
+ }
52
+ useBindable.cleanup = (fn) => {
53
+ useEffect(() => fn, []);
54
+ };
55
+ useBindable.ref = (defaultValue) => {
56
+ const value = useRef(defaultValue);
57
+ return {
58
+ get: () => value.current,
59
+ set: (next) => {
60
+ value.current = next;
61
+ }
62
+ };
63
+ };
64
+ //#endregion
65
+ //#region src/core/refs.ts
66
+ function useRefs(refs) {
67
+ const ref = useRef(refs);
68
+ return {
69
+ get(key) {
70
+ return ref.current[key];
71
+ },
72
+ set(key, value) {
73
+ ref.current[key] = value;
74
+ }
75
+ };
76
+ }
77
+ //#endregion
78
+ //#region src/core/track.ts
79
+ const useTrack = (deps, effect) => {
80
+ const render = useRef(false);
81
+ const called = useRef(false);
82
+ useEffect(() => {
83
+ if (render.current && called.current) return effect();
84
+ called.current = true;
85
+ }, (deps ?? []).map((d) => typeof d === "function" ? d() : d));
86
+ useEffect(() => {
87
+ render.current = true;
88
+ return () => {
89
+ render.current = false;
90
+ };
91
+ }, []);
92
+ };
93
+ //#endregion
94
+ //#region src/core/machine.ts
95
+ function useMachine(machine, userProps = {}) {
96
+ const scope = useMemo(() => {
97
+ const { id, ids, getRootNode } = userProps;
98
+ return createScope({
99
+ id,
100
+ ids,
101
+ getRootNode
102
+ });
103
+ }, [userProps]);
104
+ const debug = (...args) => {
105
+ if (machine.debug) console.log(...args);
106
+ };
107
+ const prop = useProp(machine.props?.({
108
+ props: compact(userProps),
109
+ scope
110
+ }) ?? userProps);
111
+ const context = machine.context?.({
112
+ prop,
113
+ bindable: useBindable,
114
+ scope,
115
+ flush,
116
+ getContext() {
117
+ return ctx;
118
+ },
119
+ getComputed() {
120
+ return computed;
121
+ },
122
+ getRefs() {
123
+ return refs;
124
+ },
125
+ getEvent() {
126
+ return getEvent();
127
+ }
128
+ });
129
+ const contextRef = useLiveRef(context);
130
+ const ctx = {
131
+ get(key) {
132
+ return contextRef.current?.[key].ref.current;
133
+ },
134
+ set(key, value) {
135
+ contextRef.current?.[key].set(value);
136
+ },
137
+ initial(key) {
138
+ return contextRef.current?.[key].initial;
139
+ },
140
+ hash(key) {
141
+ const current = contextRef.current?.[key].get();
142
+ return contextRef.current?.[key].hash(current);
143
+ }
144
+ };
145
+ const effects = useRef(/* @__PURE__ */ new Map());
146
+ const transitionRef = useRef(null);
147
+ const previousEventRef = useRef(null);
148
+ const eventRef = useRef({ type: "" });
149
+ const getEvent = () => ({
150
+ ...eventRef.current,
151
+ current() {
152
+ return eventRef.current;
153
+ },
154
+ previous() {
155
+ return previousEventRef.current;
156
+ }
157
+ });
158
+ const getState = () => ({
159
+ ...state,
160
+ matches(...values) {
161
+ return values.some((value) => matchesState(state.ref.current, value));
162
+ },
163
+ hasTag(tag) {
164
+ return hasTag(machine, state.ref.current, tag);
165
+ }
166
+ });
167
+ const refs = useRefs(machine.refs?.({
168
+ prop,
169
+ context: ctx
170
+ }) ?? {});
171
+ const getParams = () => ({
172
+ state: getState(),
173
+ context: ctx,
174
+ event: getEvent(),
175
+ prop,
176
+ send,
177
+ action,
178
+ guard,
179
+ track: useTrack,
180
+ refs,
181
+ computed,
182
+ flush,
183
+ scope,
184
+ choose
185
+ });
186
+ const action = (keys) => {
187
+ const strs = isFunction(keys) ? keys(getParams()) : keys;
188
+ if (!strs) return;
189
+ const fns = strs.map((s) => {
190
+ const fn = machine.implementations?.actions?.[s];
191
+ if (!fn) warn(`[wirekyt] No implementation found for action "${JSON.stringify(s)}"`);
192
+ return fn;
193
+ });
194
+ for (const fn of fns) fn?.(getParams());
195
+ };
196
+ const guard = (str) => {
197
+ if (isFunction(str)) return str(getParams());
198
+ const fn = machine.implementations?.guards?.[str];
199
+ if (!fn) warn(`[wirekyt] No implementation found for guard "${JSON.stringify(str)}"`);
200
+ return fn?.(getParams());
201
+ };
202
+ const effect = (keys) => {
203
+ const strs = isFunction(keys) ? keys(getParams()) : keys;
204
+ if (!strs) return;
205
+ const fns = strs.map((s) => {
206
+ const fn = machine.implementations?.effects?.[s];
207
+ if (!fn) warn(`[wirekyt] No implementation found for effect "${JSON.stringify(s)}"`);
208
+ return fn;
209
+ });
210
+ const cleanups = [];
211
+ for (const fn of fns) {
212
+ const cleanup = fn?.(getParams());
213
+ if (cleanup) cleanups.push(cleanup);
214
+ }
215
+ return () => cleanups.forEach((fn) => fn?.());
216
+ };
217
+ const choose = (transitions) => {
218
+ return toArray(transitions).find((t) => {
219
+ let result = !t.guard;
220
+ if (isString(t.guard)) result = !!guard(t.guard);
221
+ else if (isFunction(t.guard)) result = t.guard(getParams());
222
+ return result;
223
+ });
224
+ };
225
+ const computed = (key) => {
226
+ ensure(machine.computed, () => `[wirekyt] No computed object found on machine`);
227
+ const fn = machine.computed[key];
228
+ return fn({
229
+ context: ctx,
230
+ event: getEvent(),
231
+ prop,
232
+ refs,
233
+ scope,
234
+ computed
235
+ });
236
+ };
237
+ const state = useBindable(() => ({
238
+ defaultValue: resolveStateValue(machine, machine.initialState({ prop })),
239
+ onChange(nextState, prevState) {
240
+ const { exiting, entering } = getExitEnterStates(machine, prevState, nextState, transitionRef.current?.reenter);
241
+ exiting.forEach((item) => {
242
+ effects.current.get(item.path)?.();
243
+ effects.current.delete(item.path);
244
+ });
245
+ exiting.forEach((item) => {
246
+ action(item.state?.exit);
247
+ });
248
+ action(transitionRef.current?.actions);
249
+ entering.forEach((item) => {
250
+ const cleanup = effect(item.state?.effects);
251
+ if (cleanup) {
252
+ const existing = effects.current.get(item.path);
253
+ effects.current.set(item.path, existing ? callAll(existing, cleanup) : cleanup);
254
+ }
255
+ });
256
+ if (prevState === INIT_STATE) {
257
+ action(machine.entry);
258
+ const cleanup = effect(machine.effects);
259
+ if (cleanup) {
260
+ const existing = effects.current.get(INIT_STATE);
261
+ effects.current.set(INIT_STATE, existing ? callAll(existing, cleanup) : cleanup);
262
+ }
263
+ }
264
+ entering.forEach((item) => {
265
+ action(item.state?.entry);
266
+ });
267
+ }
268
+ }));
269
+ const hydratedStateRef = useRef(void 0);
270
+ const statusRef = useRef(MachineStatus.NotStarted);
271
+ useSafeLayoutEffect(() => {
272
+ queueMicrotask(() => {
273
+ const started = statusRef.current === MachineStatus.Started;
274
+ statusRef.current = MachineStatus.Started;
275
+ debug(started ? "rehydrating..." : "initializing...");
276
+ const initialState = hydratedStateRef.current ?? state.initial;
277
+ state.invoke(initialState, started ? state.get() : INIT_STATE);
278
+ });
279
+ const fns = effects.current;
280
+ return () => {
281
+ const currentState = getCurrentState();
282
+ debug("unmounting...");
283
+ hydratedStateRef.current = currentState;
284
+ statusRef.current = MachineStatus.Stopped;
285
+ fns.forEach((fn) => fn?.());
286
+ effects.current = /* @__PURE__ */ new Map();
287
+ transitionRef.current = null;
288
+ queueMicrotask(() => {
289
+ action(machine.exit);
290
+ statusRef.current = MachineStatus.Stopped;
291
+ });
292
+ };
293
+ }, []);
294
+ const getCurrentState = () => {
295
+ if ("ref" in state) return state.ref.current;
296
+ return state.get();
297
+ };
298
+ const send = (event) => {
299
+ queueMicrotask(() => {
300
+ if (statusRef.current !== MachineStatus.Started) return;
301
+ previousEventRef.current = eventRef.current;
302
+ eventRef.current = event;
303
+ let currentState = getCurrentState();
304
+ const { transitions, source } = findTransition(machine, currentState, event.type);
305
+ const transition = choose(transitions);
306
+ if (!transition) return;
307
+ transitionRef.current = transition;
308
+ const target = resolveStateValue(machine, transition.target ?? currentState, source);
309
+ debug("transition", event.type, transition.target || currentState, `(${transition.actions})`);
310
+ if (target !== currentState) flushSync(() => state.set(target));
311
+ else if (transition.reenter) state.invoke(currentState, currentState);
312
+ else action(transition.actions ?? []);
313
+ });
314
+ };
315
+ machine.watch?.(getParams());
316
+ return {
317
+ state: getState(),
318
+ send,
319
+ context: ctx,
320
+ prop,
321
+ scope,
322
+ refs,
323
+ computed,
324
+ event: getEvent(),
325
+ getStatus: () => statusRef.current
326
+ };
327
+ }
328
+ function useLiveRef(value) {
329
+ const ref = useRef(value);
330
+ ref.current = value;
331
+ return ref;
332
+ }
333
+ function useProp(value) {
334
+ const ref = useLiveRef(value);
335
+ return function get(key) {
336
+ return ref.current[key];
337
+ };
338
+ }
339
+ function flush(fn) {
340
+ queueMicrotask(() => {
341
+ flushSync(() => fn());
342
+ });
343
+ }
344
+ //#endregion
345
+ //#region src/core/normalize-props.ts
346
+ const normalizeProps = createNormalizer((v) => v);
347
+ //#endregion
348
+ //#region src/core/portal.tsx
349
+ const Portal = (props) => {
350
+ const { children, container, disabled, getRootNode } = props;
351
+ if (typeof window === "undefined" || disabled) return /* @__PURE__ */ jsx(React$1.Fragment, { children });
352
+ const doc = getRootNode?.().ownerDocument ?? document;
353
+ const mountNode = container?.current ?? doc.body;
354
+ return /* @__PURE__ */ jsx(React$1.Fragment, { children: React$1.Children.map(children, (child) => createPortal(child, mountNode)) });
355
+ };
356
+ //#endregion
357
+ export { useMachine as a, normalizeProps as i, useSyncExternalStore$1 as n, Portal as r, mergeProps$1 as t };
@@ -0,0 +1,217 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rolldown_runtime = require("./rolldown-runtime-DakpK96I.cjs");
3
+ const require_utils = require("./utils-Cfwm9WW1.cjs");
4
+ const require_environment = require("./environment-B6IaCAuQ.cjs");
5
+ const require_core = require("./core-CBFAnVIP.cjs");
6
+ const require_factory = require("./factory-CFFufs5e.cjs");
7
+ const require_providers = require("./providers-DrJEJcrE.cjs");
8
+ let react = require("react");
9
+ let react_jsx_runtime = require("react/jsx-runtime");
10
+ let _wirekyt_dom_machines_date_input = require("@wirekyt/dom/machines/date-input");
11
+ _wirekyt_dom_machines_date_input = require_rolldown_runtime.__toESM(_wirekyt_dom_machines_date_input, 1);
12
+ let _wirekyt_dom = require("@wirekyt/dom");
13
+ //#region src/components/date-input/use-date-input.ts
14
+ const useDateInput = (props = {}) => {
15
+ const id = (0, react.useId)();
16
+ const { dir, locale } = require_providers.useLocaleContext();
17
+ const { getRootNode } = require_environment.useEnvironmentContext();
18
+ const context = {
19
+ id,
20
+ dir,
21
+ locale,
22
+ getRootNode,
23
+ ...props
24
+ };
25
+ const service = require_core.useMachine(_wirekyt_dom_machines_date_input.machine, context);
26
+ return _wirekyt_dom_machines_date_input.connect(service, require_core.normalizeProps);
27
+ };
28
+ //#endregion
29
+ //#region src/components/date-input/use-date-input-context.ts
30
+ const [DateInputProvider, useDateInputContext] = require_utils.createContext({
31
+ name: "DateInputContext",
32
+ hookName: "useDateInputContext",
33
+ providerName: "<DateInput.Root />"
34
+ });
35
+ //#endregion
36
+ //#region src/components/date-input/context.tsx
37
+ const DateInputContext = (props) => props.children(useDateInputContext());
38
+ //#endregion
39
+ //#region src/components/date-input/label.tsx
40
+ const DateInputLabel = (0, react.forwardRef)((props, ref) => {
41
+ const mergedProps = (0, _wirekyt_dom.mergeProps)(useDateInputContext().getLabelProps(), props);
42
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.wire.label, {
43
+ ...mergedProps,
44
+ ref
45
+ });
46
+ });
47
+ DateInputLabel.displayName = "DateInputLabel";
48
+ //#endregion
49
+ //#region src/components/date-input/root.tsx
50
+ const splitRootProps = require_utils.createSplitProps();
51
+ const DateInputRoot = (0, react.forwardRef)((props, ref) => {
52
+ const [useDateInputProps, localProps] = splitRootProps(props, [
53
+ "dir",
54
+ "disabled",
55
+ "getRootNode",
56
+ "id",
57
+ "ids",
58
+ "invalid",
59
+ "locale",
60
+ "max",
61
+ "min",
62
+ "name",
63
+ "form",
64
+ "onFocusChange",
65
+ "onPlaceholderChange",
66
+ "onValueChange",
67
+ "readOnly",
68
+ "required",
69
+ "selectionMode",
70
+ "timeZone",
71
+ "hideTimeZone",
72
+ "translations",
73
+ "value",
74
+ "defaultValue",
75
+ "hourCycle",
76
+ "granularity",
77
+ "shouldForceLeadingZeros",
78
+ "allSegments",
79
+ "formatter",
80
+ "placeholderValue",
81
+ "defaultPlaceholderValue",
82
+ "format",
83
+ "createCalendar",
84
+ "isDateUnavailable"
85
+ ]);
86
+ const dateInput = useDateInput(useDateInputProps);
87
+ const mergedProps = (0, _wirekyt_dom.mergeProps)(dateInput.getRootProps(), localProps);
88
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateInputProvider, {
89
+ value: dateInput,
90
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.wire.div, {
91
+ ...mergedProps,
92
+ ref
93
+ })
94
+ });
95
+ });
96
+ DateInputRoot.displayName = "DateInputRoot";
97
+ //#endregion
98
+ //#region src/components/date-input/root-provider.tsx
99
+ const splitRootProviderProps = require_utils.createSplitProps();
100
+ const DateInputRootProvider = (0, react.forwardRef)((props, ref) => {
101
+ const [{ value: dateInput }, localProps] = splitRootProviderProps(props, ["value"]);
102
+ const mergedProps = (0, _wirekyt_dom.mergeProps)(dateInput.getRootProps(), localProps);
103
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateInputProvider, {
104
+ value: dateInput,
105
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.wire.div, {
106
+ ...mergedProps,
107
+ ref
108
+ })
109
+ });
110
+ });
111
+ DateInputRootProvider.displayName = "DateInputRootProvider";
112
+ //#endregion
113
+ //#region src/components/date-input/use-date-input-segment-group-props-context.ts
114
+ const [DateInputSegmentGroupPropsProvider, useDateInputSegmentGroupPropsContext] = require_utils.createContext({
115
+ name: "DateInputSegmentGroupPropsContext",
116
+ hookName: "useDateInputSegmentGroupPropsContext",
117
+ providerName: "<DateInput.SegmentGroup />",
118
+ strict: true
119
+ });
120
+ //#endregion
121
+ //#region src/components/date-input/segment.tsx
122
+ const splitSegmentProps = require_utils.createSplitProps();
123
+ const DateInputSegment = (0, react.forwardRef)((props, ref) => {
124
+ const [segmentProps, localProps] = splitSegmentProps(props, ["segment"]);
125
+ const segmentGroupProps = useDateInputSegmentGroupPropsContext();
126
+ const mergedProps = (0, _wirekyt_dom.mergeProps)(useDateInputContext().getSegmentProps({
127
+ ...segmentProps,
128
+ index: segmentGroupProps.index
129
+ }), localProps);
130
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.wire.span, {
131
+ ...mergedProps,
132
+ ref,
133
+ children: segmentProps.segment.text
134
+ });
135
+ });
136
+ DateInputSegment.displayName = "DateInputSegment";
137
+ //#endregion
138
+ //#region src/components/date-input/segment-group.tsx
139
+ const splitSegmentGroupProps = require_utils.createSplitProps();
140
+ const DateInputSegmentGroup = (0, react.forwardRef)((props, ref) => {
141
+ const [segmentGroupProps, localProps] = splitSegmentGroupProps(props, ["index"]);
142
+ const mergedProps = (0, _wirekyt_dom.mergeProps)(useDateInputContext().getSegmentGroupProps(segmentGroupProps), localProps);
143
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateInputSegmentGroupPropsProvider, {
144
+ value: segmentGroupProps,
145
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.wire.div, {
146
+ ...mergedProps,
147
+ ref
148
+ })
149
+ });
150
+ });
151
+ DateInputSegmentGroup.displayName = "DateInputSegmentGroup";
152
+ //#endregion
153
+ //#region src/components/date-input/hidden-input.tsx
154
+ const splitHiddenInputProps = require_utils.createSplitProps();
155
+ const DateInputHiddenInput = (0, react.forwardRef)((props, ref) => {
156
+ const [hiddenInputProps, localProps] = splitHiddenInputProps(props, ["index", "name"]);
157
+ const mergedProps = (0, _wirekyt_dom.mergeProps)(useDateInputContext().getHiddenInputProps(hiddenInputProps), localProps);
158
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.wire.input, {
159
+ ...mergedProps,
160
+ ref
161
+ });
162
+ });
163
+ DateInputHiddenInput.displayName = "DateInputHiddenInput";
164
+ //#endregion
165
+ //#region src/components/date-input/control.tsx
166
+ const DateInputControl = (0, react.forwardRef)((props, ref) => {
167
+ const mergedProps = (0, _wirekyt_dom.mergeProps)(useDateInputContext().getControlProps(), props);
168
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.wire.div, {
169
+ ...mergedProps,
170
+ ref
171
+ });
172
+ });
173
+ DateInputControl.displayName = "DateInputControl";
174
+ //#endregion
175
+ //#region src/components/date-input/segment-context.tsx
176
+ const DateInputSegmentContext = (props) => {
177
+ const dateInput = useDateInputContext();
178
+ const segmentGroupProps = useDateInputSegmentGroupPropsContext();
179
+ return dateInput.getSegments(segmentGroupProps).map((segment, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: props.children(segment) }, `${segment.type}-${index}`));
180
+ };
181
+ //#endregion
182
+ //#region src/components/date-input/date-input.ts
183
+ var date_input_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
184
+ Context: () => DateInputContext,
185
+ Control: () => DateInputControl,
186
+ HiddenInput: () => DateInputHiddenInput,
187
+ Label: () => DateInputLabel,
188
+ Root: () => DateInputRoot,
189
+ RootProvider: () => DateInputRootProvider,
190
+ Segment: () => DateInputSegment,
191
+ SegmentContext: () => DateInputSegmentContext,
192
+ SegmentGroup: () => DateInputSegmentGroup
193
+ });
194
+ //#endregion
195
+ Object.defineProperty(exports, "DateInput", {
196
+ enumerable: true,
197
+ get: function() {
198
+ return date_input_exports;
199
+ }
200
+ });
201
+ exports.DateInputContext = DateInputContext;
202
+ exports.DateInputControl = DateInputControl;
203
+ exports.DateInputHiddenInput = DateInputHiddenInput;
204
+ exports.DateInputLabel = DateInputLabel;
205
+ exports.DateInputRoot = DateInputRoot;
206
+ exports.DateInputRootProvider = DateInputRootProvider;
207
+ exports.DateInputSegment = DateInputSegment;
208
+ exports.DateInputSegmentContext = DateInputSegmentContext;
209
+ exports.DateInputSegmentGroup = DateInputSegmentGroup;
210
+ Object.defineProperty(exports, "dateInputAnatomy", {
211
+ enumerable: true,
212
+ get: function() {
213
+ return _wirekyt_dom_machines_date_input.anatomy;
214
+ }
215
+ });
216
+ exports.useDateInput = useDateInput;
217
+ exports.useDateInputContext = useDateInputContext;
@@ -0,0 +1,69 @@
1
+ import "./index-CQAbOgb7.cjs";
2
+ import { r as Optional, t as Assign } from "./types-BQQfrr86.cjs";
3
+ import { r as PolymorphicProps, t as HTMLProps } from "./factory--dkoVnFK.cjs";
4
+ import { ReactNode } from "react";
5
+ import * as dateInput from "@wirekyt/dom/machines/date-input";
6
+ import { DateSegment, DateValue as DateInputDateValue, FocusChangeDetails as DateInputFocusChangeDetails, HiddenInputProps, SegmentGroupProps, SegmentProps, SelectionMode as DateInputSelectionMode, ValueChangeDetails as DateInputValueChangeDetails, anatomy as dateInputAnatomy } from "@wirekyt/dom/machines/date-input";
7
+ //#region src/components/date-input/use-date-input.d.ts
8
+ interface UseDateInputProps extends Optional<dateInput.Props, "id"> {}
9
+ type UseDateInputReturn = ReturnType<typeof useDateInput>;
10
+ declare const useDateInput: (props?: UseDateInputProps) => dateInput.Api;
11
+ //#endregion
12
+ //#region src/components/date-input/use-date-input-context.d.ts
13
+ interface UseDateInputContext extends UseDateInputReturn {}
14
+ declare const DateInputProvider: import("react").Provider<UseDateInputContext>, useDateInputContext: () => UseDateInputContext;
15
+ //#endregion
16
+ //#region src/components/date-input/context.d.ts
17
+ interface DateInputContextProps {
18
+ children: (context: UseDateInputContext) => ReactNode;
19
+ }
20
+ declare const DateInputContext: (props: DateInputContextProps) => ReactNode;
21
+ //#endregion
22
+ //#region src/components/date-input/label.d.ts
23
+ interface DateInputLabelBaseProps extends PolymorphicProps {}
24
+ interface DateInputLabelProps extends HTMLProps<"label">, DateInputLabelBaseProps {}
25
+ declare const DateInputLabel: import("react").ForwardRefExoticComponent<DateInputLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
26
+ //#endregion
27
+ //#region src/components/date-input/root.d.ts
28
+ interface DateInputRootBaseProps extends UseDateInputProps, PolymorphicProps {}
29
+ interface DateInputRootProps extends Assign<HTMLProps<"div">, DateInputRootBaseProps> {}
30
+ declare const DateInputRoot: import("react").ForwardRefExoticComponent<DateInputRootProps & import("react").RefAttributes<HTMLDivElement>>;
31
+ //#endregion
32
+ //#region src/components/date-input/root-provider.d.ts
33
+ interface RootProviderProps {
34
+ value: UseDateInputReturn;
35
+ }
36
+ interface DateInputRootProviderBaseProps extends RootProviderProps, PolymorphicProps {}
37
+ interface DateInputRootProviderProps extends HTMLProps<"div">, DateInputRootProviderBaseProps {}
38
+ declare const DateInputRootProvider: import("react").ForwardRefExoticComponent<DateInputRootProviderProps & import("react").RefAttributes<HTMLDivElement>>;
39
+ //#endregion
40
+ //#region src/components/date-input/segment.d.ts
41
+ interface DateInputSegmentBaseProps extends PolymorphicProps, Pick<SegmentProps, "segment"> {}
42
+ interface DateInputSegmentProps extends HTMLProps<"span">, DateInputSegmentBaseProps {}
43
+ declare const DateInputSegment: import("react").ForwardRefExoticComponent<DateInputSegmentProps & import("react").RefAttributes<HTMLSpanElement>>;
44
+ //#endregion
45
+ //#region src/components/date-input/segment-group.d.ts
46
+ interface DateInputSegmentGroupBaseProps extends PolymorphicProps, SegmentGroupProps {}
47
+ interface DateInputSegmentGroupProps extends HTMLProps<"div">, DateInputSegmentGroupBaseProps {}
48
+ declare const DateInputSegmentGroup: import("react").ForwardRefExoticComponent<DateInputSegmentGroupProps & import("react").RefAttributes<HTMLDivElement>>;
49
+ //#endregion
50
+ //#region src/components/date-input/hidden-input.d.ts
51
+ interface DateInputHiddenInputBaseProps extends PolymorphicProps, HiddenInputProps {}
52
+ interface DateInputHiddenInputProps extends HTMLProps<"input">, DateInputHiddenInputBaseProps {}
53
+ declare const DateInputHiddenInput: import("react").ForwardRefExoticComponent<DateInputHiddenInputProps & import("react").RefAttributes<HTMLInputElement>>;
54
+ //#endregion
55
+ //#region src/components/date-input/control.d.ts
56
+ interface DateInputControlBaseProps extends PolymorphicProps {}
57
+ interface DateInputControlProps extends HTMLProps<"div">, DateInputControlBaseProps {}
58
+ declare const DateInputControl: import("react").ForwardRefExoticComponent<DateInputControlProps & import("react").RefAttributes<HTMLDivElement>>;
59
+ //#endregion
60
+ //#region src/components/date-input/segment-context.d.ts
61
+ interface DateInputSegmentContextProps {
62
+ children: (segment: DateSegment) => ReactNode;
63
+ }
64
+ declare const DateInputSegmentContext: (props: DateInputSegmentContextProps) => import("react").JSX.Element[];
65
+ declare namespace date_input_d_exports {
66
+ export { DateInputContext as Context, DateInputContextProps as ContextProps, DateInputControl as Control, DateInputControlBaseProps as ControlBaseProps, DateInputControlProps as ControlProps, DateInputHiddenInput as HiddenInput, DateInputHiddenInputBaseProps as HiddenInputBaseProps, DateInputHiddenInputProps as HiddenInputProps, DateInputLabel as Label, DateInputLabelBaseProps as LabelBaseProps, DateInputLabelProps as LabelProps, DateInputRoot as Root, DateInputRootBaseProps as RootBaseProps, DateInputRootProps as RootProps, DateInputRootProvider as RootProvider, DateInputRootProviderBaseProps as RootProviderBaseProps, DateInputRootProviderProps as RootProviderProps, DateInputSegment as Segment, DateInputSegmentBaseProps as SegmentBaseProps, DateInputSegmentContext as SegmentContext, DateInputSegmentContextProps as SegmentContextProps, DateInputSegmentGroup as SegmentGroup, DateInputSegmentGroupBaseProps as SegmentGroupBaseProps, DateInputSegmentGroupProps as SegmentGroupProps, DateInputSegmentProps as SegmentProps };
67
+ }
68
+ //#endregion
69
+ export { date_input_d_exports as DateInput, DateInputContext, type DateInputContextProps, DateInputControl, type DateInputControlBaseProps, type DateInputControlProps, type DateInputDateValue, type DateInputFocusChangeDetails, DateInputHiddenInput, type DateInputHiddenInputBaseProps, type DateInputHiddenInputProps, DateInputLabel, type DateInputLabelBaseProps, type DateInputLabelProps, DateInputRoot, type DateInputRootBaseProps, type DateInputRootProps, DateInputRootProvider, type DateInputRootProviderBaseProps, type DateInputRootProviderProps, DateInputSegment, type DateInputSegmentBaseProps, DateInputSegmentContext, type DateInputSegmentContextProps, DateInputSegmentGroup, type DateInputSegmentGroupBaseProps, type DateInputSegmentGroupProps, type DateInputSegmentProps, type DateInputSelectionMode, type DateInputValueChangeDetails, type UseDateInputContext, type UseDateInputProps, type UseDateInputReturn, dateInputAnatomy, useDateInput, useDateInputContext };