@wirekyt/react 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.
- package/dist/accordion.cjs +209 -0
- package/dist/accordion.d.cts +69 -0
- package/dist/accordion.d.ts +69 -0
- package/dist/accordion.js +184 -0
- package/dist/angle-slider.cjs +193 -0
- package/dist/angle-slider.d.cts +73 -0
- package/dist/angle-slider.d.ts +73 -0
- package/dist/angle-slider.js +168 -0
- package/dist/avatar.cjs +120 -0
- package/dist/avatar.d.cts +48 -0
- package/dist/avatar.d.ts +48 -0
- package/dist/avatar.js +100 -0
- package/dist/carousel.cjs +246 -0
- package/dist/carousel.d.cts +94 -0
- package/dist/carousel.d.ts +94 -0
- package/dist/carousel.js +223 -0
- package/dist/checkbox.cjs +284 -0
- package/dist/checkbox.d.cts +115 -0
- package/dist/checkbox.d.ts +115 -0
- package/dist/checkbox.js +263 -0
- package/dist/client-only.cjs +12 -0
- package/dist/client-only.d.cts +8 -0
- package/dist/client-only.d.ts +8 -0
- package/dist/client-only.js +11 -0
- package/dist/clipboard.cjs +174 -0
- package/dist/clipboard.d.cts +70 -0
- package/dist/clipboard.d.ts +70 -0
- package/dist/clipboard.js +150 -0
- package/dist/collapsible-B62i_oPJ.cjs +185 -0
- package/dist/collapsible-CiTNjCNf.js +131 -0
- package/dist/collapsible.cjs +23 -0
- package/dist/collapsible.d.cts +56 -0
- package/dist/collapsible.d.ts +56 -0
- package/dist/collapsible.js +2 -0
- package/dist/collection-BFjWNdUS.cjs +223 -0
- package/dist/collection-BJOl6a4H.js +180 -0
- package/dist/collection.cjs +9 -0
- package/dist/collection.d.cts +2 -0
- package/dist/collection.d.ts +2 -0
- package/dist/collection.js +2 -0
- package/dist/color-picker.cjs +575 -0
- package/dist/color-picker.d.cts +179 -0
- package/dist/color-picker.d.ts +179 -0
- package/dist/color-picker.js +530 -0
- package/dist/combobox.cjs +390 -0
- package/dist/combobox.d.cts +128 -0
- package/dist/combobox.d.ts +128 -0
- package/dist/combobox.js +359 -0
- package/dist/core-CBFAnVIP.cjs +375 -0
- package/dist/core-CEYOEcVI.js +357 -0
- package/dist/date-input.cjs +217 -0
- package/dist/date-input.d.cts +69 -0
- package/dist/date-input.d.ts +69 -0
- package/dist/date-input.js +193 -0
- package/dist/date-picker.cjs +588 -0
- package/dist/date-picker.d.cts +190 -0
- package/dist/date-picker.d.ts +190 -0
- package/dist/date-picker.js +543 -0
- package/dist/dialog.cjs +199 -0
- package/dist/dialog.d.cts +78 -0
- package/dist/dialog.d.ts +78 -0
- package/dist/dialog.js +174 -0
- package/dist/download-trigger.cjs +53 -0
- package/dist/download-trigger.d.cts +22 -0
- package/dist/download-trigger.d.ts +22 -0
- package/dist/download-trigger.js +51 -0
- package/dist/drawer.cjs +296 -0
- package/dist/drawer.d.cts +115 -0
- package/dist/drawer.d.ts +115 -0
- package/dist/drawer.js +264 -0
- package/dist/editable.cjs +228 -0
- package/dist/editable.d.cts +79 -0
- package/dist/editable.d.ts +79 -0
- package/dist/editable.js +202 -0
- package/dist/environment-B6IaCAuQ.cjs +59 -0
- package/dist/environment-BTgKwk5E.js +42 -0
- package/dist/factory--dkoVnFK.d.cts +14 -0
- package/dist/factory--dkoVnFK.d.ts +14 -0
- package/dist/factory-CFFufs5e.cjs +59 -0
- package/dist/factory-Nm__-4xn.js +48 -0
- package/dist/field-Cy1E02DH.js +349 -0
- package/dist/field-x8H5uXB9.cjs +438 -0
- package/dist/field.cjs +22 -0
- package/dist/field.d.cts +129 -0
- package/dist/field.d.ts +129 -0
- package/dist/field.js +2 -0
- package/dist/fieldset-DWZXj1t5.cjs +232 -0
- package/dist/fieldset-fx44GCtM.js +178 -0
- package/dist/fieldset.cjs +18 -0
- package/dist/fieldset.d.cts +71 -0
- package/dist/fieldset.d.ts +71 -0
- package/dist/fieldset.js +3 -0
- package/dist/file-upload.cjs +328 -0
- package/dist/file-upload.d.cts +101 -0
- package/dist/file-upload.d.ts +101 -0
- package/dist/file-upload.js +298 -0
- package/dist/floating-panel.cjs +271 -0
- package/dist/floating-panel.d.cts +98 -0
- package/dist/floating-panel.d.ts +98 -0
- package/dist/floating-panel.js +242 -0
- package/dist/format.cjs +64 -0
- package/dist/format.d.cts +44 -0
- package/dist/format.d.ts +44 -0
- package/dist/format.js +54 -0
- package/dist/frame.cjs +85 -0
- package/dist/frame.d.cts +12 -0
- package/dist/frame.d.ts +12 -0
- package/dist/frame.js +84 -0
- package/dist/highlight.cjs +29 -0
- package/dist/highlight.d.cts +13 -0
- package/dist/highlight.d.ts +13 -0
- package/dist/highlight.js +27 -0
- package/dist/hover-card.cjs +154 -0
- package/dist/hover-card.d.cts +68 -0
- package/dist/hover-card.d.ts +68 -0
- package/dist/hover-card.js +131 -0
- package/dist/image-cropper.cjs +0 -0
- package/dist/image-cropper.d.cts +1 -0
- package/dist/image-cropper.d.ts +1 -0
- package/dist/image-cropper.js +0 -0
- package/dist/index-3Al0R5bH.d.cts +73 -0
- package/dist/index-B7wAg5Wf.d.ts +146 -0
- package/dist/index-BAn8qiCM.d.ts +73 -0
- package/dist/index-BSX88T_g.d.cts +146 -0
- package/dist/index-CQAbOgb7.d.cts +23 -0
- package/dist/index-CW-Aj6aT.d.ts +95 -0
- package/dist/index-CxWYgVJk.d.ts +23 -0
- package/dist/index-DRnET7mJ.d.ts +33 -0
- package/dist/index-DTLK6Fuh.d.cts +95 -0
- package/dist/index-DyTY8HEb.d.cts +33 -0
- package/dist/index-srZfUQNt.d.cts +20 -0
- package/dist/index-srZfUQNt.d.ts +20 -0
- package/dist/index.cjs +45 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/json-tree-view.cjs +244 -0
- package/dist/json-tree-view.d.cts +45 -0
- package/dist/json-tree-view.d.ts +45 -0
- package/dist/json-tree-view.js +234 -0
- package/dist/listbox.cjs +290 -0
- package/dist/listbox.d.cts +109 -0
- package/dist/listbox.d.ts +109 -0
- package/dist/listbox.js +264 -0
- package/dist/marquee.cjs +164 -0
- package/dist/marquee.d.cts +60 -0
- package/dist/marquee.d.ts +60 -0
- package/dist/marquee.js +142 -0
- package/dist/menu.cjs +506 -0
- package/dist/menu.d.cts +162 -0
- package/dist/menu.d.ts +162 -0
- package/dist/menu.js +469 -0
- package/dist/navigation-menu.cjs +331 -0
- package/dist/navigation-menu.d.cts +89 -0
- package/dist/navigation-menu.d.ts +89 -0
- package/dist/navigation-menu.js +303 -0
- package/dist/number-input.cjs +222 -0
- package/dist/number-input.d.cts +73 -0
- package/dist/number-input.d.ts +73 -0
- package/dist/number-input.js +197 -0
- package/dist/pagination.cjs +183 -0
- package/dist/pagination.d.cts +68 -0
- package/dist/pagination.d.ts +68 -0
- package/dist/pagination.js +159 -0
- package/dist/password-input.cjs +179 -0
- package/dist/password-input.d.cts +65 -0
- package/dist/password-input.d.ts +65 -0
- package/dist/password-input.js +156 -0
- package/dist/pin-input.cjs +180 -0
- package/dist/pin-input.d.cts +58 -0
- package/dist/pin-input.d.ts +58 -0
- package/dist/pin-input.js +158 -0
- package/dist/popover.cjs +222 -0
- package/dist/popover.d.cts +93 -0
- package/dist/popover.d.ts +93 -0
- package/dist/popover.js +194 -0
- package/dist/portal-6_XzBXiA.cjs +33 -0
- package/dist/portal-QYL_2wB0.js +28 -0
- package/dist/portal.cjs +3 -0
- package/dist/portal.d.cts +9 -0
- package/dist/portal.d.ts +9 -0
- package/dist/portal.js +2 -0
- package/dist/presence-BOs-D6Cv.cjs +96 -0
- package/dist/presence-I8Rceflw.js +65 -0
- package/dist/presence.cjs +7 -0
- package/dist/presence.d.cts +2 -0
- package/dist/presence.d.ts +2 -0
- package/dist/presence.js +2 -0
- package/dist/progress.cjs +206 -0
- package/dist/progress.d.cts +78 -0
- package/dist/progress.d.ts +78 -0
- package/dist/progress.js +180 -0
- package/dist/providers-DrJEJcrE.cjs +128 -0
- package/dist/providers-FEHnDTvb.js +87 -0
- package/dist/qr-code.cjs +154 -0
- package/dist/qr-code.d.cts +58 -0
- package/dist/qr-code.d.ts +58 -0
- package/dist/qr-code.js +132 -0
- package/dist/radio-group.cjs +222 -0
- package/dist/radio-group.d.cts +78 -0
- package/dist/radio-group.d.ts +78 -0
- package/dist/radio-group.js +196 -0
- package/dist/rating-group.cjs +186 -0
- package/dist/rating-group.d.cts +68 -0
- package/dist/rating-group.d.ts +68 -0
- package/dist/rating-group.js +162 -0
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/rolldown-runtime-DakpK96I.cjs +43 -0
- package/dist/scroll-area.cjs +166 -0
- package/dist/scroll-area.d.cts +67 -0
- package/dist/scroll-area.d.ts +67 -0
- package/dist/scroll-area.js +143 -0
- package/dist/segment-group.cjs +215 -0
- package/dist/segment-group.d.cts +81 -0
- package/dist/segment-group.d.ts +81 -0
- package/dist/segment-group.js +194 -0
- package/dist/select.cjs +395 -0
- package/dist/select.d.cts +132 -0
- package/dist/select.d.ts +132 -0
- package/dist/select.js +358 -0
- package/dist/signature-pad.cjs +197 -0
- package/dist/signature-pad.d.cts +68 -0
- package/dist/signature-pad.d.ts +68 -0
- package/dist/signature-pad.js +173 -0
- package/dist/slider.cjs +260 -0
- package/dist/slider.d.cts +88 -0
- package/dist/slider.d.ts +88 -0
- package/dist/slider.js +232 -0
- package/dist/steps.cjs +271 -0
- package/dist/steps.d.cts +104 -0
- package/dist/steps.d.ts +104 -0
- package/dist/steps.js +241 -0
- package/dist/swap.cjs +134 -0
- package/dist/swap.d.cts +49 -0
- package/dist/swap.d.ts +49 -0
- package/dist/swap.js +121 -0
- package/dist/switch.cjs +166 -0
- package/dist/switch.d.cts +58 -0
- package/dist/switch.d.ts +58 -0
- package/dist/switch.js +144 -0
- package/dist/tabs.cjs +177 -0
- package/dist/tabs.d.cts +59 -0
- package/dist/tabs.d.ts +59 -0
- package/dist/tabs.js +155 -0
- package/dist/tags-input.cjs +298 -0
- package/dist/tags-input.d.cts +98 -0
- package/dist/tags-input.d.ts +98 -0
- package/dist/tags-input.js +268 -0
- package/dist/timer.cjs +167 -0
- package/dist/timer.d.cts +63 -0
- package/dist/timer.d.ts +63 -0
- package/dist/timer.js +144 -0
- package/dist/toast.cjs +154 -0
- package/dist/toast.d.cts +59 -0
- package/dist/toast.d.ts +59 -0
- package/dist/toast.js +132 -0
- package/dist/toggle-group.cjs +118 -0
- package/dist/toggle-group.d.cts +43 -0
- package/dist/toggle-group.d.ts +43 -0
- package/dist/toggle-group.js +99 -0
- package/dist/toggle.cjs +85 -0
- package/dist/toggle.d.cts +38 -0
- package/dist/toggle.d.ts +38 -0
- package/dist/toggle.js +71 -0
- package/dist/tooltip.cjs +154 -0
- package/dist/tooltip.d.cts +68 -0
- package/dist/tooltip.d.ts +68 -0
- package/dist/tooltip.js +131 -0
- package/dist/tour.cjs +290 -0
- package/dist/tour.d.cts +112 -0
- package/dist/tour.d.ts +112 -0
- package/dist/tour.js +246 -0
- package/dist/tree-view-CNTEWXlu.js +339 -0
- package/dist/tree-view-CU4Hl5X1.cjs +484 -0
- package/dist/tree-view.cjs +41 -0
- package/dist/tree-view.d.cts +3 -0
- package/dist/tree-view.d.ts +3 -0
- package/dist/tree-view.js +3 -0
- package/dist/types-BQQfrr86.d.cts +6 -0
- package/dist/types-BQQfrr86.d.ts +6 -0
- package/dist/use-context-38DKWHsx.cjs +20 -0
- package/dist/use-context-CITa6pn9.js +10 -0
- package/dist/utils-Cfwm9WW1.cjs +166 -0
- package/dist/utils-CqLmqrgj.js +107 -0
- package/package.json +274 -6
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
let _wirekyt_dom_utils = require("@wirekyt/dom/utils");
|
|
2
|
+
let react = require("react");
|
|
3
|
+
//#region src/utils/create-context.ts
|
|
4
|
+
function getErrorMessage(hook, provider) {
|
|
5
|
+
return `${hook} returned \`undefined\`. Seems you forgot to wrap component within ${provider}`;
|
|
6
|
+
}
|
|
7
|
+
function createContext(options = {}) {
|
|
8
|
+
const { name, strict = true, hookName = "useContext", providerName = "Provider", errorMessage, defaultValue } = options;
|
|
9
|
+
const Context = (0, react.createContext)(defaultValue);
|
|
10
|
+
Context.displayName = name;
|
|
11
|
+
function useContext() {
|
|
12
|
+
const context = (0, react.useContext)(Context);
|
|
13
|
+
if (!context && strict) {
|
|
14
|
+
const error = new Error(errorMessage ?? getErrorMessage(hookName, providerName));
|
|
15
|
+
error.name = "ContextError";
|
|
16
|
+
if ((0, _wirekyt_dom_utils.hasProp)(Error, "captureStackTrace") && (0, _wirekyt_dom_utils.isFunction)(Error.captureStackTrace)) Error.captureStackTrace(error, useContext);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
21
|
+
return [
|
|
22
|
+
Context.Provider,
|
|
23
|
+
useContext,
|
|
24
|
+
Context
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/utils/compose-refs.ts
|
|
29
|
+
function composeRefs(...refs) {
|
|
30
|
+
return (node) => {
|
|
31
|
+
const cleanUps = [];
|
|
32
|
+
for (const ref of refs) if (typeof ref === "function") {
|
|
33
|
+
const cb = ref(node);
|
|
34
|
+
if (typeof cb === "function") cleanUps.push(cb);
|
|
35
|
+
} else if (ref) ref.current = node;
|
|
36
|
+
if (cleanUps.length) return () => {
|
|
37
|
+
for (const cleanUp of cleanUps) cleanUp();
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function useComposedRefs(...refs) {
|
|
42
|
+
return (0, react.useCallback)(composeRefs(...refs), refs);
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/utils/create-split-props.ts
|
|
46
|
+
const createSplitProps = () => (props, keys) => keys.reduce((previousValue, currentValue) => {
|
|
47
|
+
const [target, source] = previousValue;
|
|
48
|
+
const key = currentValue;
|
|
49
|
+
if (source[key] !== void 0) target[key] = source[key];
|
|
50
|
+
delete source[key];
|
|
51
|
+
return [target, source];
|
|
52
|
+
}, [{}, { ...props }]);
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/utils/render-strategy.ts
|
|
55
|
+
const [RenderStrategyPropsProvider, useRenderStrategyPropsContext] = createContext({
|
|
56
|
+
name: "RenderStrategyContext",
|
|
57
|
+
hookName: "useRenderStrategyContext",
|
|
58
|
+
providerName: "<RenderStrategyPropsProvider />"
|
|
59
|
+
});
|
|
60
|
+
const splitRenderStrategyProps = (props) => createSplitProps()(props, ["lazyMount", "unmountOnExit"]);
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/utils/use-controllable-state.ts
|
|
63
|
+
function useControllableState(props) {
|
|
64
|
+
const { value, onChange, defaultValue } = props;
|
|
65
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, react.useState)(defaultValue);
|
|
66
|
+
const controlled = value !== void 0;
|
|
67
|
+
return [controlled ? value : uncontrolledValue, (0, react.useCallback)((value) => {
|
|
68
|
+
if (controlled) return onChange?.(value);
|
|
69
|
+
setUncontrolledValue(value);
|
|
70
|
+
return onChange?.(value);
|
|
71
|
+
}, [controlled, onChange])];
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/utils/use-event.ts
|
|
75
|
+
function useEvent(callback, opts = {}) {
|
|
76
|
+
const { sync = false } = opts;
|
|
77
|
+
const callbackRef = useLatestRef(callback);
|
|
78
|
+
return (0, react.useCallback)((...args) => {
|
|
79
|
+
if (sync) return queueMicrotask(() => callbackRef.current?.(...args));
|
|
80
|
+
return callbackRef.current?.(...args);
|
|
81
|
+
}, [sync, callbackRef]);
|
|
82
|
+
}
|
|
83
|
+
function useLatestRef(value) {
|
|
84
|
+
const ref = (0, react.useRef)(value);
|
|
85
|
+
ref.current = value;
|
|
86
|
+
return ref;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/utils/use-safe-layout-effect.ts
|
|
90
|
+
const useSafeLayoutEffect = typeof window !== "undefined" ? react.useLayoutEffect : react.useEffect;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/utils/use-effect-once.ts
|
|
93
|
+
const useEffectOnce = (cb) => {
|
|
94
|
+
const savedCallback = (0, react.useRef)(cb);
|
|
95
|
+
const effectGuard = (0, react.useRef)(false);
|
|
96
|
+
(0, react.useEffect)(() => {
|
|
97
|
+
savedCallback.current = cb;
|
|
98
|
+
});
|
|
99
|
+
(0, react.useEffect)(() => {
|
|
100
|
+
if (effectGuard.current !== true) {
|
|
101
|
+
effectGuard.current = true;
|
|
102
|
+
savedCallback.current();
|
|
103
|
+
}
|
|
104
|
+
}, []);
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
Object.defineProperty(exports, "RenderStrategyPropsProvider", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function() {
|
|
110
|
+
return RenderStrategyPropsProvider;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, "createContext", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function() {
|
|
116
|
+
return createContext;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(exports, "createSplitProps", {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function() {
|
|
122
|
+
return createSplitProps;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(exports, "splitRenderStrategyProps", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function() {
|
|
128
|
+
return splitRenderStrategyProps;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(exports, "useComposedRefs", {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function() {
|
|
134
|
+
return useComposedRefs;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(exports, "useControllableState", {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function() {
|
|
140
|
+
return useControllableState;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(exports, "useEffectOnce", {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function() {
|
|
146
|
+
return useEffectOnce;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
Object.defineProperty(exports, "useEvent", {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get: function() {
|
|
152
|
+
return useEvent;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
Object.defineProperty(exports, "useRenderStrategyPropsContext", {
|
|
156
|
+
enumerable: true,
|
|
157
|
+
get: function() {
|
|
158
|
+
return useRenderStrategyPropsContext;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(exports, "useSafeLayoutEffect", {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
get: function() {
|
|
164
|
+
return useSafeLayoutEffect;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { hasProp, isFunction } from "@wirekyt/dom/utils";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
//#region src/utils/create-context.ts
|
|
4
|
+
function getErrorMessage(hook, provider) {
|
|
5
|
+
return `${hook} returned \`undefined\`. Seems you forgot to wrap component within ${provider}`;
|
|
6
|
+
}
|
|
7
|
+
function createContext$1(options = {}) {
|
|
8
|
+
const { name, strict = true, hookName = "useContext", providerName = "Provider", errorMessage, defaultValue } = options;
|
|
9
|
+
const Context = createContext(defaultValue);
|
|
10
|
+
Context.displayName = name;
|
|
11
|
+
function useContext$1() {
|
|
12
|
+
const context = useContext(Context);
|
|
13
|
+
if (!context && strict) {
|
|
14
|
+
const error = new Error(errorMessage ?? getErrorMessage(hookName, providerName));
|
|
15
|
+
error.name = "ContextError";
|
|
16
|
+
if (hasProp(Error, "captureStackTrace") && isFunction(Error.captureStackTrace)) Error.captureStackTrace(error, useContext$1);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
21
|
+
return [
|
|
22
|
+
Context.Provider,
|
|
23
|
+
useContext$1,
|
|
24
|
+
Context
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/utils/compose-refs.ts
|
|
29
|
+
function composeRefs(...refs) {
|
|
30
|
+
return (node) => {
|
|
31
|
+
const cleanUps = [];
|
|
32
|
+
for (const ref of refs) if (typeof ref === "function") {
|
|
33
|
+
const cb = ref(node);
|
|
34
|
+
if (typeof cb === "function") cleanUps.push(cb);
|
|
35
|
+
} else if (ref) ref.current = node;
|
|
36
|
+
if (cleanUps.length) return () => {
|
|
37
|
+
for (const cleanUp of cleanUps) cleanUp();
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function useComposedRefs(...refs) {
|
|
42
|
+
return useCallback(composeRefs(...refs), refs);
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/utils/create-split-props.ts
|
|
46
|
+
const createSplitProps = () => (props, keys) => keys.reduce((previousValue, currentValue) => {
|
|
47
|
+
const [target, source] = previousValue;
|
|
48
|
+
const key = currentValue;
|
|
49
|
+
if (source[key] !== void 0) target[key] = source[key];
|
|
50
|
+
delete source[key];
|
|
51
|
+
return [target, source];
|
|
52
|
+
}, [{}, { ...props }]);
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/utils/render-strategy.ts
|
|
55
|
+
const [RenderStrategyPropsProvider, useRenderStrategyPropsContext] = createContext$1({
|
|
56
|
+
name: "RenderStrategyContext",
|
|
57
|
+
hookName: "useRenderStrategyContext",
|
|
58
|
+
providerName: "<RenderStrategyPropsProvider />"
|
|
59
|
+
});
|
|
60
|
+
const splitRenderStrategyProps = (props) => createSplitProps()(props, ["lazyMount", "unmountOnExit"]);
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/utils/use-controllable-state.ts
|
|
63
|
+
function useControllableState(props) {
|
|
64
|
+
const { value, onChange, defaultValue } = props;
|
|
65
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
66
|
+
const controlled = value !== void 0;
|
|
67
|
+
return [controlled ? value : uncontrolledValue, useCallback((value) => {
|
|
68
|
+
if (controlled) return onChange?.(value);
|
|
69
|
+
setUncontrolledValue(value);
|
|
70
|
+
return onChange?.(value);
|
|
71
|
+
}, [controlled, onChange])];
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/utils/use-event.ts
|
|
75
|
+
function useEvent(callback, opts = {}) {
|
|
76
|
+
const { sync = false } = opts;
|
|
77
|
+
const callbackRef = useLatestRef(callback);
|
|
78
|
+
return useCallback((...args) => {
|
|
79
|
+
if (sync) return queueMicrotask(() => callbackRef.current?.(...args));
|
|
80
|
+
return callbackRef.current?.(...args);
|
|
81
|
+
}, [sync, callbackRef]);
|
|
82
|
+
}
|
|
83
|
+
function useLatestRef(value) {
|
|
84
|
+
const ref = useRef(value);
|
|
85
|
+
ref.current = value;
|
|
86
|
+
return ref;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/utils/use-safe-layout-effect.ts
|
|
90
|
+
const useSafeLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/utils/use-effect-once.ts
|
|
93
|
+
const useEffectOnce = (cb) => {
|
|
94
|
+
const savedCallback = useRef(cb);
|
|
95
|
+
const effectGuard = useRef(false);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
savedCallback.current = cb;
|
|
98
|
+
});
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (effectGuard.current !== true) {
|
|
101
|
+
effectGuard.current = true;
|
|
102
|
+
savedCallback.current();
|
|
103
|
+
}
|
|
104
|
+
}, []);
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
export { RenderStrategyPropsProvider as a, createSplitProps as c, useControllableState as i, useComposedRefs as l, useSafeLayoutEffect as n, splitRenderStrategyProps as o, useEvent as r, useRenderStrategyPropsContext as s, useEffectOnce as t, createContext$1 as u };
|
package/package.json
CHANGED
|
@@ -1,7 +1,275 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@wirekyt/react",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@wirekyt/react",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "React adapter for Wirekyt",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.cts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./accordion": {
|
|
18
|
+
"import": "./dist/accordion.js",
|
|
19
|
+
"require": "./dist/accordion.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./angle-slider": {
|
|
22
|
+
"import": "./dist/angle-slider.js",
|
|
23
|
+
"require": "./dist/angle-slider.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./avatar": {
|
|
26
|
+
"import": "./dist/avatar.js",
|
|
27
|
+
"require": "./dist/avatar.cjs"
|
|
28
|
+
},
|
|
29
|
+
"./carousel": {
|
|
30
|
+
"import": "./dist/carousel.js",
|
|
31
|
+
"require": "./dist/carousel.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./checkbox": {
|
|
34
|
+
"import": "./dist/checkbox.js",
|
|
35
|
+
"require": "./dist/checkbox.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./client-only": {
|
|
38
|
+
"import": "./dist/client-only.js",
|
|
39
|
+
"require": "./dist/client-only.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./clipboard": {
|
|
42
|
+
"import": "./dist/clipboard.js",
|
|
43
|
+
"require": "./dist/clipboard.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./collapsible": {
|
|
46
|
+
"import": "./dist/collapsible.js",
|
|
47
|
+
"require": "./dist/collapsible.cjs"
|
|
48
|
+
},
|
|
49
|
+
"./collection": {
|
|
50
|
+
"import": "./dist/collection.js",
|
|
51
|
+
"require": "./dist/collection.cjs"
|
|
52
|
+
},
|
|
53
|
+
"./color-picker": {
|
|
54
|
+
"import": "./dist/color-picker.js",
|
|
55
|
+
"require": "./dist/color-picker.cjs"
|
|
56
|
+
},
|
|
57
|
+
"./combobox": {
|
|
58
|
+
"import": "./dist/combobox.js",
|
|
59
|
+
"require": "./dist/combobox.cjs"
|
|
60
|
+
},
|
|
61
|
+
"./date-input": {
|
|
62
|
+
"import": "./dist/date-input.js",
|
|
63
|
+
"require": "./dist/date-input.cjs"
|
|
64
|
+
},
|
|
65
|
+
"./date-picker": {
|
|
66
|
+
"import": "./dist/date-picker.js",
|
|
67
|
+
"require": "./dist/date-picker.cjs"
|
|
68
|
+
},
|
|
69
|
+
"./dialog": {
|
|
70
|
+
"import": "./dist/dialog.js",
|
|
71
|
+
"require": "./dist/dialog.cjs"
|
|
72
|
+
},
|
|
73
|
+
"./download-trigger": {
|
|
74
|
+
"import": "./dist/download-trigger.js",
|
|
75
|
+
"require": "./dist/download-trigger.cjs"
|
|
76
|
+
},
|
|
77
|
+
"./drawer": {
|
|
78
|
+
"import": "./dist/drawer.js",
|
|
79
|
+
"require": "./dist/drawer.cjs"
|
|
80
|
+
},
|
|
81
|
+
"./editable": {
|
|
82
|
+
"import": "./dist/editable.js",
|
|
83
|
+
"require": "./dist/editable.cjs"
|
|
84
|
+
},
|
|
85
|
+
"./field": {
|
|
86
|
+
"import": "./dist/field.js",
|
|
87
|
+
"require": "./dist/field.cjs"
|
|
88
|
+
},
|
|
89
|
+
"./fieldset": {
|
|
90
|
+
"import": "./dist/fieldset.js",
|
|
91
|
+
"require": "./dist/fieldset.cjs"
|
|
92
|
+
},
|
|
93
|
+
"./file-upload": {
|
|
94
|
+
"import": "./dist/file-upload.js",
|
|
95
|
+
"require": "./dist/file-upload.cjs"
|
|
96
|
+
},
|
|
97
|
+
"./floating-panel": {
|
|
98
|
+
"import": "./dist/floating-panel.js",
|
|
99
|
+
"require": "./dist/floating-panel.cjs"
|
|
100
|
+
},
|
|
101
|
+
"./format": {
|
|
102
|
+
"import": "./dist/format.js",
|
|
103
|
+
"require": "./dist/format.cjs"
|
|
104
|
+
},
|
|
105
|
+
"./frame": {
|
|
106
|
+
"import": "./dist/frame.js",
|
|
107
|
+
"require": "./dist/frame.cjs"
|
|
108
|
+
},
|
|
109
|
+
"./highlight": {
|
|
110
|
+
"import": "./dist/highlight.js",
|
|
111
|
+
"require": "./dist/highlight.cjs"
|
|
112
|
+
},
|
|
113
|
+
"./hover-card": {
|
|
114
|
+
"import": "./dist/hover-card.js",
|
|
115
|
+
"require": "./dist/hover-card.cjs"
|
|
116
|
+
},
|
|
117
|
+
"./image-cropper": {
|
|
118
|
+
"import": "./dist/image-cropper.js",
|
|
119
|
+
"require": "./dist/image-cropper.cjs"
|
|
120
|
+
},
|
|
121
|
+
"./json-tree-view": {
|
|
122
|
+
"import": "./dist/json-tree-view.js",
|
|
123
|
+
"require": "./dist/json-tree-view.cjs"
|
|
124
|
+
},
|
|
125
|
+
"./listbox": {
|
|
126
|
+
"import": "./dist/listbox.js",
|
|
127
|
+
"require": "./dist/listbox.cjs"
|
|
128
|
+
},
|
|
129
|
+
"./marquee": {
|
|
130
|
+
"import": "./dist/marquee.js",
|
|
131
|
+
"require": "./dist/marquee.cjs"
|
|
132
|
+
},
|
|
133
|
+
"./menu": {
|
|
134
|
+
"import": "./dist/menu.js",
|
|
135
|
+
"require": "./dist/menu.cjs"
|
|
136
|
+
},
|
|
137
|
+
"./navigation-menu": {
|
|
138
|
+
"import": "./dist/navigation-menu.js",
|
|
139
|
+
"require": "./dist/navigation-menu.cjs"
|
|
140
|
+
},
|
|
141
|
+
"./number-input": {
|
|
142
|
+
"import": "./dist/number-input.js",
|
|
143
|
+
"require": "./dist/number-input.cjs"
|
|
144
|
+
},
|
|
145
|
+
"./pagination": {
|
|
146
|
+
"import": "./dist/pagination.js",
|
|
147
|
+
"require": "./dist/pagination.cjs"
|
|
148
|
+
},
|
|
149
|
+
"./password-input": {
|
|
150
|
+
"import": "./dist/password-input.js",
|
|
151
|
+
"require": "./dist/password-input.cjs"
|
|
152
|
+
},
|
|
153
|
+
"./pin-input": {
|
|
154
|
+
"import": "./dist/pin-input.js",
|
|
155
|
+
"require": "./dist/pin-input.cjs"
|
|
156
|
+
},
|
|
157
|
+
"./popover": {
|
|
158
|
+
"import": "./dist/popover.js",
|
|
159
|
+
"require": "./dist/popover.cjs"
|
|
160
|
+
},
|
|
161
|
+
"./portal": {
|
|
162
|
+
"import": "./dist/portal.js",
|
|
163
|
+
"require": "./dist/portal.cjs"
|
|
164
|
+
},
|
|
165
|
+
"./presence": {
|
|
166
|
+
"import": "./dist/presence.js",
|
|
167
|
+
"require": "./dist/presence.cjs"
|
|
168
|
+
},
|
|
169
|
+
"./progress": {
|
|
170
|
+
"import": "./dist/progress.js",
|
|
171
|
+
"require": "./dist/progress.cjs"
|
|
172
|
+
},
|
|
173
|
+
"./qr-code": {
|
|
174
|
+
"import": "./dist/qr-code.js",
|
|
175
|
+
"require": "./dist/qr-code.cjs"
|
|
176
|
+
},
|
|
177
|
+
"./radio-group": {
|
|
178
|
+
"import": "./dist/radio-group.js",
|
|
179
|
+
"require": "./dist/radio-group.cjs"
|
|
180
|
+
},
|
|
181
|
+
"./rating-group": {
|
|
182
|
+
"import": "./dist/rating-group.js",
|
|
183
|
+
"require": "./dist/rating-group.cjs"
|
|
184
|
+
},
|
|
185
|
+
"./scroll-area": {
|
|
186
|
+
"import": "./dist/scroll-area.js",
|
|
187
|
+
"require": "./dist/scroll-area.cjs"
|
|
188
|
+
},
|
|
189
|
+
"./segment-group": {
|
|
190
|
+
"import": "./dist/segment-group.js",
|
|
191
|
+
"require": "./dist/segment-group.cjs"
|
|
192
|
+
},
|
|
193
|
+
"./select": {
|
|
194
|
+
"import": "./dist/select.js",
|
|
195
|
+
"require": "./dist/select.cjs"
|
|
196
|
+
},
|
|
197
|
+
"./signature-pad": {
|
|
198
|
+
"import": "./dist/signature-pad.js",
|
|
199
|
+
"require": "./dist/signature-pad.cjs"
|
|
200
|
+
},
|
|
201
|
+
"./slider": {
|
|
202
|
+
"import": "./dist/slider.js",
|
|
203
|
+
"require": "./dist/slider.cjs"
|
|
204
|
+
},
|
|
205
|
+
"./steps": {
|
|
206
|
+
"import": "./dist/steps.js",
|
|
207
|
+
"require": "./dist/steps.cjs"
|
|
208
|
+
},
|
|
209
|
+
"./swap": {
|
|
210
|
+
"import": "./dist/swap.js",
|
|
211
|
+
"require": "./dist/swap.cjs"
|
|
212
|
+
},
|
|
213
|
+
"./switch": {
|
|
214
|
+
"import": "./dist/switch.js",
|
|
215
|
+
"require": "./dist/switch.cjs"
|
|
216
|
+
},
|
|
217
|
+
"./tabs": {
|
|
218
|
+
"import": "./dist/tabs.js",
|
|
219
|
+
"require": "./dist/tabs.cjs"
|
|
220
|
+
},
|
|
221
|
+
"./tags-input": {
|
|
222
|
+
"import": "./dist/tags-input.js",
|
|
223
|
+
"require": "./dist/tags-input.cjs"
|
|
224
|
+
},
|
|
225
|
+
"./timer": {
|
|
226
|
+
"import": "./dist/timer.js",
|
|
227
|
+
"require": "./dist/timer.cjs"
|
|
228
|
+
},
|
|
229
|
+
"./toast": {
|
|
230
|
+
"import": "./dist/toast.js",
|
|
231
|
+
"require": "./dist/toast.cjs"
|
|
232
|
+
},
|
|
233
|
+
"./toggle": {
|
|
234
|
+
"import": "./dist/toggle.js",
|
|
235
|
+
"require": "./dist/toggle.cjs"
|
|
236
|
+
},
|
|
237
|
+
"./toggle-group": {
|
|
238
|
+
"import": "./dist/toggle-group.js",
|
|
239
|
+
"require": "./dist/toggle-group.cjs"
|
|
240
|
+
},
|
|
241
|
+
"./tooltip": {
|
|
242
|
+
"import": "./dist/tooltip.js",
|
|
243
|
+
"require": "./dist/tooltip.cjs"
|
|
244
|
+
},
|
|
245
|
+
"./tour": {
|
|
246
|
+
"import": "./dist/tour.js",
|
|
247
|
+
"require": "./dist/tour.cjs"
|
|
248
|
+
},
|
|
249
|
+
"./tree-view": {
|
|
250
|
+
"import": "./dist/tree-view.js",
|
|
251
|
+
"require": "./dist/tree-view.cjs"
|
|
252
|
+
},
|
|
253
|
+
"./package.json": "./package.json"
|
|
254
|
+
},
|
|
255
|
+
"publishConfig": {
|
|
256
|
+
"access": "public",
|
|
257
|
+
"provenance": true
|
|
258
|
+
},
|
|
259
|
+
"dependencies": {
|
|
260
|
+
"@internationalized/date": "^3.12.3",
|
|
261
|
+
"@internationalized/number": "^3.6.7",
|
|
262
|
+
"@wirekyt/dom": "0.0.3"
|
|
263
|
+
},
|
|
264
|
+
"peerDependencies": {
|
|
265
|
+
"react": ">=19.0.0",
|
|
266
|
+
"react-dom": ">=19.0.0"
|
|
267
|
+
},
|
|
268
|
+
"scripts": {
|
|
269
|
+
"build": "tsdown",
|
|
270
|
+
"test": "vitest",
|
|
271
|
+
"lint": "oxlint",
|
|
272
|
+
"format": "oxfmt --write",
|
|
273
|
+
"typecheck": "tsc --noEmit"
|
|
274
|
+
}
|
|
7
275
|
}
|