@ark-ui/solid 3.2.2 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -14
- package/dist/cjs/index.js +2005 -33
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1970 -23
- package/dist/esm/index.js.map +1 -1
- package/dist/source/components/checkbox/checkbox-group.jsx +18 -0
- package/dist/source/components/checkbox/checkbox.js +1 -0
- package/dist/source/components/checkbox/index.js +3 -0
- package/dist/source/components/checkbox/use-checkbox-group-context.jsx +6 -0
- package/dist/source/components/checkbox/use-checkbox-group.js +52 -0
- package/dist/source/components/checkbox/use-checkbox.js +9 -4
- package/dist/source/components/index.js +2 -0
- package/dist/source/components/presence/split-presence-props.js +1 -0
- package/dist/source/components/qr-code/index.js +9 -0
- package/dist/source/components/qr-code/qr-code-context.js +2 -0
- package/dist/source/components/qr-code/qr-code-frame.jsx +8 -0
- package/dist/source/components/qr-code/qr-code-overlay.jsx +8 -0
- package/dist/source/components/qr-code/qr-code-pattern.jsx +8 -0
- package/dist/source/components/qr-code/qr-code-root-provider.jsx +11 -0
- package/dist/source/components/qr-code/qr-code-root.jsx +18 -0
- package/dist/source/components/qr-code/qr-code.js +6 -0
- package/dist/source/components/qr-code/use-qr-code-context.js +5 -0
- package/dist/source/components/qr-code/use-qr-code.js +19 -0
- package/dist/source/components/select/index.js +1 -0
- package/dist/source/components/select/select-list.jsx +8 -0
- package/dist/source/components/select/select.js +1 -0
- package/dist/source/components/signature-pad/index.js +11 -0
- package/dist/source/components/signature-pad/signature-pad-clear-trigger.jsx +8 -0
- package/dist/source/components/signature-pad/signature-pad-context.jsx +2 -0
- package/dist/source/components/signature-pad/signature-pad-control.jsx +8 -0
- package/dist/source/components/signature-pad/signature-pad-guide.jsx +8 -0
- package/dist/source/components/signature-pad/signature-pad-label.jsx +8 -0
- package/dist/source/components/signature-pad/signature-pad-root-provider.jsx +13 -0
- package/dist/source/components/signature-pad/signature-pad-root.jsx +22 -0
- package/dist/source/components/signature-pad/signature-pad-segment.jsx +18 -0
- package/dist/source/components/signature-pad/signature-pad.js +8 -0
- package/dist/source/components/signature-pad/use-signature-pad-context.js +5 -0
- package/dist/source/components/signature-pad/use-signature-pad.js +17 -0
- package/dist/source/components/tabs/tab-content.jsx +4 -1
- package/dist/source/components/toast/toast-root.jsx +3 -1
- package/dist/source/utils/use-controllable-state.js +18 -0
- package/dist/types/components/checkbox/checkbox-group.d.ts +6 -0
- package/dist/types/components/checkbox/checkbox.d.ts +1 -0
- package/dist/types/components/checkbox/index.d.ts +3 -0
- package/dist/types/components/checkbox/use-checkbox-group-context.d.ts +4 -0
- package/dist/types/components/checkbox/use-checkbox-group.d.ts +42 -0
- package/dist/types/components/checkbox/use-checkbox.d.ts +1 -1
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/presence/split-presence-props.d.ts +1 -1
- package/dist/types/components/qr-code/index.d.ts +10 -0
- package/dist/types/components/qr-code/qr-code-context.d.ts +6 -0
- package/dist/types/components/qr-code/qr-code-frame.d.ts +4 -0
- package/dist/types/components/qr-code/qr-code-overlay.d.ts +4 -0
- package/dist/types/components/qr-code/qr-code-pattern.d.ts +4 -0
- package/dist/types/components/qr-code/qr-code-root-provider.d.ts +9 -0
- package/dist/types/components/qr-code/qr-code-root.d.ts +6 -0
- package/dist/types/components/qr-code/qr-code.d.ts +7 -0
- package/dist/types/components/qr-code/use-qr-code-context.d.ts +4 -0
- package/dist/types/components/qr-code/use-qr-code.d.ts +9 -0
- package/dist/types/components/select/index.d.ts +1 -0
- package/dist/types/components/select/select-list.d.ts +4 -0
- package/dist/types/components/select/select.d.ts +1 -0
- package/dist/types/components/signature-pad/index.d.ts +12 -0
- package/dist/types/components/signature-pad/signature-pad-clear-trigger.d.ts +4 -0
- package/dist/types/components/signature-pad/signature-pad-context.d.ts +6 -0
- package/dist/types/components/signature-pad/signature-pad-control.d.ts +4 -0
- package/dist/types/components/signature-pad/signature-pad-guide.d.ts +4 -0
- package/dist/types/components/signature-pad/signature-pad-label.d.ts +4 -0
- package/dist/types/components/signature-pad/signature-pad-root-provider.d.ts +9 -0
- package/dist/types/components/signature-pad/signature-pad-root.d.ts +6 -0
- package/dist/types/components/signature-pad/signature-pad-segment.d.ts +4 -0
- package/dist/types/components/signature-pad/signature-pad.d.ts +9 -0
- package/dist/types/components/signature-pad/use-signature-pad-context.d.ts +4 -0
- package/dist/types/components/signature-pad/use-signature-pad.d.ts +9 -0
- package/dist/types/utils/use-controllable-state.d.ts +7 -0
- package/package.json +45 -44
package/dist/cjs/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var solid = require('@zag-js/solid');
|
|
|
6
6
|
var collapsible$1 = require('@zag-js/collapsible');
|
|
7
7
|
var accordion$1 = require('@zag-js/accordion');
|
|
8
8
|
var avatar$1 = require('@zag-js/avatar');
|
|
9
|
-
var anatomy = require('@ark-ui/anatomy');
|
|
9
|
+
var anatomy$1 = require('@ark-ui/anatomy');
|
|
10
10
|
var carousel$1 = require('@zag-js/carousel');
|
|
11
11
|
var checkbox$1 = require('@zag-js/checkbox');
|
|
12
12
|
var clipboard$1 = require('@zag-js/clipboard');
|
|
@@ -25,9 +25,12 @@ var pagination$1 = require('@zag-js/pagination');
|
|
|
25
25
|
var pinInput$1 = require('@zag-js/pin-input');
|
|
26
26
|
var popover$1 = require('@zag-js/popover');
|
|
27
27
|
var progress$1 = require('@zag-js/progress');
|
|
28
|
+
var qrCode$1 = require('@zag-js/qr-code');
|
|
28
29
|
var radio = require('@zag-js/radio-group');
|
|
29
30
|
var rating = require('@zag-js/rating-group');
|
|
30
31
|
var select$1 = require('@zag-js/select');
|
|
32
|
+
var domQuery = require('@zag-js/dom-query');
|
|
33
|
+
var types = require('@zag-js/types');
|
|
31
34
|
var slider$1 = require('@zag-js/slider');
|
|
32
35
|
var splitter$1 = require('@zag-js/splitter');
|
|
33
36
|
var zagSwitch = require('@zag-js/switch');
|
|
@@ -37,7 +40,6 @@ var toast$1 = require('@zag-js/toast');
|
|
|
37
40
|
var toggleGroup$1 = require('@zag-js/toggle-group');
|
|
38
41
|
var tooltip$1 = require('@zag-js/tooltip');
|
|
39
42
|
var treeView$1 = require('@zag-js/tree-view');
|
|
40
|
-
var domQuery = require('@zag-js/dom-query');
|
|
41
43
|
|
|
42
44
|
function _interopNamespaceDefault(e) {
|
|
43
45
|
var n = Object.create(null);
|
|
@@ -76,6 +78,7 @@ var pagination__namespace = /*#__PURE__*/_interopNamespaceDefault(pagination$1);
|
|
|
76
78
|
var pinInput__namespace = /*#__PURE__*/_interopNamespaceDefault(pinInput$1);
|
|
77
79
|
var popover__namespace = /*#__PURE__*/_interopNamespaceDefault(popover$1);
|
|
78
80
|
var progress__namespace = /*#__PURE__*/_interopNamespaceDefault(progress$1);
|
|
81
|
+
var qrCode__namespace = /*#__PURE__*/_interopNamespaceDefault(qrCode$1);
|
|
79
82
|
var radio__namespace = /*#__PURE__*/_interopNamespaceDefault(radio);
|
|
80
83
|
var rating__namespace = /*#__PURE__*/_interopNamespaceDefault(rating);
|
|
81
84
|
var select__namespace = /*#__PURE__*/_interopNamespaceDefault(select$1);
|
|
@@ -184,8 +187,8 @@ const CollapsibleContent = props => {
|
|
|
184
187
|
|
|
185
188
|
const CollapsibleContext = props => props.children(useCollapsibleContext());
|
|
186
189
|
|
|
187
|
-
const isFunction = value => typeof value === 'function';
|
|
188
|
-
const runIfFn = (valueOrFn, ...args) => isFunction(valueOrFn) ? valueOrFn(...args) : valueOrFn;
|
|
190
|
+
const isFunction$1 = value => typeof value === 'function';
|
|
191
|
+
const runIfFn$1 = (valueOrFn, ...args) => isFunction$1(valueOrFn) ? valueOrFn(...args) : valueOrFn;
|
|
189
192
|
|
|
190
193
|
const [EnvironmentContextProvider, useEnvironmentContext] = createContext({
|
|
191
194
|
hookName: 'useEnvironmentContext',
|
|
@@ -198,10 +201,10 @@ const [EnvironmentContextProvider, useEnvironmentContext] = createContext({
|
|
|
198
201
|
})
|
|
199
202
|
});
|
|
200
203
|
|
|
201
|
-
var _tmpl$$
|
|
204
|
+
var _tmpl$$5 = /*#__PURE__*/web.template(`<span hidden>`);
|
|
202
205
|
const EnvironmentProvider = props => {
|
|
203
206
|
const [spanRef, setSpanRef] = solidJs.createSignal();
|
|
204
|
-
const getRootNode = () => runIfFn(props.value) ?? spanRef()?.ownerDocument ?? document;
|
|
207
|
+
const getRootNode = () => runIfFn$1(props.value) ?? spanRef()?.ownerDocument ?? document;
|
|
205
208
|
const environment = solidJs.createMemo(() => ({
|
|
206
209
|
getRootNode,
|
|
207
210
|
getDocument: () => domQuery.getDocument(getRootNode()),
|
|
@@ -215,7 +218,7 @@ const EnvironmentProvider = props => {
|
|
|
215
218
|
return !props.value;
|
|
216
219
|
},
|
|
217
220
|
get children() {
|
|
218
|
-
var _el$ = _tmpl$$
|
|
221
|
+
var _el$ = _tmpl$$5();
|
|
219
222
|
web.use(setSpanRef, _el$);
|
|
220
223
|
return _el$;
|
|
221
224
|
}
|
|
@@ -528,7 +531,7 @@ const [CarouselProvider, useCarouselContext] = createContext({
|
|
|
528
531
|
const CarouselContext = props => props.children(useCarouselContext());
|
|
529
532
|
|
|
530
533
|
const CarouselControl = props => {
|
|
531
|
-
const mergedProps = solid.mergeProps(() => anatomy.carouselAnatomy.build().control.attrs, props);
|
|
534
|
+
const mergedProps = solid.mergeProps(() => anatomy$1.carouselAnatomy.build().control.attrs, props);
|
|
532
535
|
return web.createComponent(ark.div, mergedProps);
|
|
533
536
|
};
|
|
534
537
|
|
|
@@ -646,6 +649,88 @@ const CheckboxControl = props => {
|
|
|
646
649
|
return web.createComponent(ark.div, mergedProps);
|
|
647
650
|
};
|
|
648
651
|
|
|
652
|
+
function useControllableState(props) {
|
|
653
|
+
const [uncontrolledValue, setUncontrolledValue] = solidJs.createSignal(runIfFn$1(props.defaultValue));
|
|
654
|
+
const controlled = solidJs.createMemo(() => props.value?.() !== undefined);
|
|
655
|
+
const currentValue = solidJs.createMemo(() => controlled() ? props.value?.() : uncontrolledValue());
|
|
656
|
+
const setValue = next => {
|
|
657
|
+
solidJs.untrack(() => {
|
|
658
|
+
const nextValue = runIfFn$1(next, currentValue());
|
|
659
|
+
if (controlled()) {
|
|
660
|
+
return props.onChange?.(nextValue);
|
|
661
|
+
}
|
|
662
|
+
setUncontrolledValue(nextValue);
|
|
663
|
+
return props.onChange?.(nextValue);
|
|
664
|
+
});
|
|
665
|
+
};
|
|
666
|
+
return [currentValue, setValue];
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
function useCheckboxGroup(props = {}) {
|
|
670
|
+
const interative = solidJs.createMemo(() => !(props.disabled || props.readOnly));
|
|
671
|
+
const [value, setValue] = useControllableState({
|
|
672
|
+
value: props.value,
|
|
673
|
+
defaultValue: props.defaultValue || [],
|
|
674
|
+
onChange: props.onValueChange
|
|
675
|
+
});
|
|
676
|
+
return solidJs.createMemo(() => {
|
|
677
|
+
const isChecked = val => {
|
|
678
|
+
return value().some(v => String(v) === String(val));
|
|
679
|
+
};
|
|
680
|
+
const toggleValue = val => {
|
|
681
|
+
isChecked(val) ? removeValue(val) : addValue(val);
|
|
682
|
+
};
|
|
683
|
+
const addValue = val => {
|
|
684
|
+
if (!interative()) return;
|
|
685
|
+
if (isChecked(val)) return;
|
|
686
|
+
setValue(value().concat(val));
|
|
687
|
+
};
|
|
688
|
+
const removeValue = val => {
|
|
689
|
+
if (!interative()) return;
|
|
690
|
+
setValue(value().filter(v => String(v) !== String(val)));
|
|
691
|
+
};
|
|
692
|
+
const getItemProps = itemProps => {
|
|
693
|
+
return {
|
|
694
|
+
checked: itemProps.value != null ? isChecked(itemProps.value) : undefined,
|
|
695
|
+
onCheckedChange() {
|
|
696
|
+
if (itemProps.value != null) {
|
|
697
|
+
toggleValue(itemProps.value);
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
disabled: props.disabled,
|
|
701
|
+
readOnly: props.readOnly
|
|
702
|
+
};
|
|
703
|
+
};
|
|
704
|
+
return {
|
|
705
|
+
isChecked,
|
|
706
|
+
value,
|
|
707
|
+
disabled: props.disabled,
|
|
708
|
+
readOnly: props.readOnly,
|
|
709
|
+
setValue,
|
|
710
|
+
addValue,
|
|
711
|
+
toggleValue,
|
|
712
|
+
getItemProps
|
|
713
|
+
};
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
const [CheckboxGroupContextProvider, useCheckboxGroupContext] = createContext({
|
|
718
|
+
hookName: 'useCheckboxGroupContext',
|
|
719
|
+
providerName: '<CheckboxGroupProvider />',
|
|
720
|
+
strict: false
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
const CheckboxGroup = props => {
|
|
724
|
+
const [checkboxGroupProps, localProps] = createSplitProps()(props, ['defaultValue', 'value', 'onValueChange', 'disabled', 'readOnly']);
|
|
725
|
+
const checkboxGroup = useCheckboxGroup(checkboxGroupProps);
|
|
726
|
+
return web.createComponent(CheckboxGroupContextProvider, {
|
|
727
|
+
value: checkboxGroup,
|
|
728
|
+
get children() {
|
|
729
|
+
return web.createComponent(ark.div, web.mergeProps(localProps, () => anatomy$1.checkboxAnatomy.build().group.attrs));
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
};
|
|
733
|
+
|
|
649
734
|
const CheckboxHiddenInput = props => {
|
|
650
735
|
const checkbox = useCheckboxContext();
|
|
651
736
|
const mergedProps = solid.mergeProps(() => checkbox().getHiddenInputProps(), props);
|
|
@@ -669,7 +754,13 @@ const CheckboxLabel = props => {
|
|
|
669
754
|
return web.createComponent(ark.span, mergedProps);
|
|
670
755
|
};
|
|
671
756
|
|
|
672
|
-
const useCheckbox =
|
|
757
|
+
const useCheckbox = ownProps => {
|
|
758
|
+
const checkboxGroup = useCheckboxGroupContext();
|
|
759
|
+
const props = solidJs.createMemo(() => {
|
|
760
|
+
return solid.mergeProps(ownProps, checkboxGroup?.().getItemProps({
|
|
761
|
+
value: ownProps.value
|
|
762
|
+
}) ?? {});
|
|
763
|
+
}, [ownProps, checkboxGroup]);
|
|
673
764
|
const locale = useLocaleContext();
|
|
674
765
|
const environment = useEnvironmentContext();
|
|
675
766
|
const id = solidJs.createUniqueId();
|
|
@@ -677,8 +768,8 @@ const useCheckbox = props => {
|
|
|
677
768
|
id,
|
|
678
769
|
dir: locale().dir,
|
|
679
770
|
getRootNode: environment().getRootNode,
|
|
680
|
-
checked: props.defaultChecked,
|
|
681
|
-
...props
|
|
771
|
+
checked: props().defaultChecked,
|
|
772
|
+
...props()
|
|
682
773
|
}));
|
|
683
774
|
const [state, send] = solid.useMachine(checkbox__namespace.machine(context()), {
|
|
684
775
|
context
|
|
@@ -715,6 +806,7 @@ var checkbox = /*#__PURE__*/Object.freeze({
|
|
|
715
806
|
__proto__: null,
|
|
716
807
|
Context: CheckboxContext,
|
|
717
808
|
Control: CheckboxControl,
|
|
809
|
+
Group: CheckboxGroup,
|
|
718
810
|
HiddenInput: CheckboxHiddenInput,
|
|
719
811
|
Indicator: CheckboxIndicator,
|
|
720
812
|
Label: CheckboxLabel,
|
|
@@ -902,7 +994,7 @@ const ColorPickerChannelSliderTrack = props => {
|
|
|
902
994
|
return web.createComponent(ark.div, mergedProps);
|
|
903
995
|
};
|
|
904
996
|
|
|
905
|
-
const splitPresenceProps = props => createSplitProps()(props, ['lazyMount', 'onExitComplete', 'present', 'unmountOnExit']);
|
|
997
|
+
const splitPresenceProps = props => createSplitProps()(props, ['immediate', 'lazyMount', 'onExitComplete', 'present', 'unmountOnExit']);
|
|
906
998
|
|
|
907
999
|
const usePresence = props => {
|
|
908
1000
|
const [renderStrategyProps, context] = splitRenderStrategyProps(props);
|
|
@@ -1142,7 +1234,7 @@ const ColorPickerTrigger = props => {
|
|
|
1142
1234
|
|
|
1143
1235
|
const ColorPickerValueText = props => {
|
|
1144
1236
|
const api = useColorPickerContext();
|
|
1145
|
-
const mergedProps = solid.mergeProps(() => anatomy.colorPickerAnatomy.build().valueText.attrs, props);
|
|
1237
|
+
const mergedProps = solid.mergeProps(() => anatomy$1.colorPickerAnatomy.build().valueText.attrs, props);
|
|
1146
1238
|
return web.createComponent(ark.span, web.mergeProps(mergedProps, {
|
|
1147
1239
|
get children() {
|
|
1148
1240
|
return api().valueAsString || props.children;
|
|
@@ -1152,7 +1244,7 @@ const ColorPickerValueText = props => {
|
|
|
1152
1244
|
|
|
1153
1245
|
const ColorPickerView = props => {
|
|
1154
1246
|
const api = useColorPickerContext();
|
|
1155
|
-
const mergedProps = solid.mergeProps(() => anatomy.colorPickerAnatomy.build().view.attrs, props);
|
|
1247
|
+
const mergedProps = solid.mergeProps(() => anatomy$1.colorPickerAnatomy.build().view.attrs, props);
|
|
1156
1248
|
return web.createComponent(solidJs.Show, {
|
|
1157
1249
|
get when() {
|
|
1158
1250
|
return api().format === props.format;
|
|
@@ -1474,14 +1566,14 @@ const DatePickerLabel = props => {
|
|
|
1474
1566
|
return web.createComponent(ark.label, mergedProps);
|
|
1475
1567
|
};
|
|
1476
1568
|
|
|
1477
|
-
var _tmpl$$
|
|
1569
|
+
var _tmpl$$4 = /*#__PURE__*/web.template(`<option>`);
|
|
1478
1570
|
const DatePickerMonthSelect = props => {
|
|
1479
1571
|
const api = useDatePickerContext();
|
|
1480
1572
|
const mergedProps = solid.mergeProps(() => api().getMonthSelectProps(), props);
|
|
1481
1573
|
return web.createComponent(ark.select, web.mergeProps(mergedProps, {
|
|
1482
1574
|
get children() {
|
|
1483
1575
|
return api().getMonths().map(month => (() => {
|
|
1484
|
-
var _el$ = _tmpl$$
|
|
1576
|
+
var _el$ = _tmpl$$4();
|
|
1485
1577
|
web.insert(_el$, () => month.label);
|
|
1486
1578
|
web.effect(() => _el$.value = month.value);
|
|
1487
1579
|
return _el$;
|
|
@@ -1719,7 +1811,7 @@ const DatePickerTrigger = props => {
|
|
|
1719
1811
|
const DatePickerView = props => {
|
|
1720
1812
|
const [viewProps, localProps] = createSplitProps()(props, ['view']);
|
|
1721
1813
|
const api = useDatePickerContext();
|
|
1722
|
-
const mergedProps = solid.mergeProps(() => anatomy.datePickerAnatomy.build().view.attrs, localProps);
|
|
1814
|
+
const mergedProps = solid.mergeProps(() => anatomy$1.datePickerAnatomy.build().view.attrs, localProps);
|
|
1723
1815
|
return web.createComponent(DatePickerViewProvider, {
|
|
1724
1816
|
value: viewProps,
|
|
1725
1817
|
get children() {
|
|
@@ -1746,7 +1838,7 @@ const DatePickerViewTrigger = props => {
|
|
|
1746
1838
|
return web.createComponent(ark.button, mergedProps);
|
|
1747
1839
|
};
|
|
1748
1840
|
|
|
1749
|
-
var _tmpl$$
|
|
1841
|
+
var _tmpl$$3 = /*#__PURE__*/web.template(`<option>`);
|
|
1750
1842
|
const DatePickerYearSelect = props => {
|
|
1751
1843
|
const api = useDatePickerContext();
|
|
1752
1844
|
const mergedProps = solid.mergeProps(() => api().getYearSelectProps(), props);
|
|
@@ -1756,7 +1848,7 @@ const DatePickerYearSelect = props => {
|
|
|
1756
1848
|
from: 1_000,
|
|
1757
1849
|
to: 4_000
|
|
1758
1850
|
}).map(year => (() => {
|
|
1759
|
-
var _el$ = _tmpl$$
|
|
1851
|
+
var _el$ = _tmpl$$3();
|
|
1760
1852
|
_el$.value = year;
|
|
1761
1853
|
web.insert(_el$, year);
|
|
1762
1854
|
return _el$;
|
|
@@ -3279,6 +3371,82 @@ var progress = /*#__PURE__*/Object.freeze({
|
|
|
3279
3371
|
View: ProgressView
|
|
3280
3372
|
});
|
|
3281
3373
|
|
|
3374
|
+
const [QrCodeProvider, useQrCodeContext] = createContext({
|
|
3375
|
+
hookName: 'useQrCodeContext',
|
|
3376
|
+
providerName: '<QrCodeProvider />'
|
|
3377
|
+
});
|
|
3378
|
+
|
|
3379
|
+
const QrCodeContext = props => props.children(useQrCodeContext());
|
|
3380
|
+
|
|
3381
|
+
const QrCodeFrame = props => {
|
|
3382
|
+
const qrCode = useQrCodeContext();
|
|
3383
|
+
const mergedProps = solid.mergeProps(() => qrCode().getFrameProps(), props);
|
|
3384
|
+
return web.createComponent(ark.svg, mergedProps);
|
|
3385
|
+
};
|
|
3386
|
+
|
|
3387
|
+
const QrCodeOverlay = props => {
|
|
3388
|
+
const qrCode = useQrCodeContext();
|
|
3389
|
+
const mergedProps = solid.mergeProps(() => qrCode().getOverlayProps(), props);
|
|
3390
|
+
return web.createComponent(ark.div, mergedProps);
|
|
3391
|
+
};
|
|
3392
|
+
|
|
3393
|
+
const QrCodePattern = props => {
|
|
3394
|
+
const qrCode = useQrCodeContext();
|
|
3395
|
+
const mergedProps = solid.mergeProps(() => qrCode().getPatternProps(), props);
|
|
3396
|
+
return web.createComponent(ark.path, mergedProps);
|
|
3397
|
+
};
|
|
3398
|
+
|
|
3399
|
+
const useQrCode = props => {
|
|
3400
|
+
const locale = useLocaleContext();
|
|
3401
|
+
const environment = useEnvironmentContext();
|
|
3402
|
+
const id = solidJs.createUniqueId();
|
|
3403
|
+
const context = solidJs.createMemo(() => ({
|
|
3404
|
+
id,
|
|
3405
|
+
dir: locale().dir,
|
|
3406
|
+
getRootNode: environment().getRootNode,
|
|
3407
|
+
...props
|
|
3408
|
+
}));
|
|
3409
|
+
const [state, send] = solid.useMachine(qrCode__namespace.machine(context()), {
|
|
3410
|
+
context
|
|
3411
|
+
});
|
|
3412
|
+
return solidJs.createMemo(() => qrCode__namespace.connect(state, send, solid.normalizeProps));
|
|
3413
|
+
};
|
|
3414
|
+
|
|
3415
|
+
const QrCodeRoot = props => {
|
|
3416
|
+
const [useQrCodeProps, restProps] = createSplitProps()(props, ['encoding', 'id', 'ids', 'value']);
|
|
3417
|
+
const api = useQrCode(useQrCodeProps);
|
|
3418
|
+
const mergedProps = solid.mergeProps(() => api().getRootProps(), restProps);
|
|
3419
|
+
return web.createComponent(QrCodeProvider, {
|
|
3420
|
+
value: api,
|
|
3421
|
+
get children() {
|
|
3422
|
+
return web.createComponent(ark.div, mergedProps);
|
|
3423
|
+
}
|
|
3424
|
+
});
|
|
3425
|
+
};
|
|
3426
|
+
|
|
3427
|
+
const QrCodeRootProvider = props => {
|
|
3428
|
+
const [{
|
|
3429
|
+
value: qrCode
|
|
3430
|
+
}, localProps] = createSplitProps()(props, ['value']);
|
|
3431
|
+
const mergedProps = solid.mergeProps(() => qrCode().getRootProps(), localProps);
|
|
3432
|
+
return web.createComponent(QrCodeProvider, {
|
|
3433
|
+
value: qrCode,
|
|
3434
|
+
get children() {
|
|
3435
|
+
return web.createComponent(ark.div, mergedProps);
|
|
3436
|
+
}
|
|
3437
|
+
});
|
|
3438
|
+
};
|
|
3439
|
+
|
|
3440
|
+
var qrCode = /*#__PURE__*/Object.freeze({
|
|
3441
|
+
__proto__: null,
|
|
3442
|
+
Frame: QrCodeFrame,
|
|
3443
|
+
Overlay: QrCodeOverlay,
|
|
3444
|
+
Pattern: QrCodePattern,
|
|
3445
|
+
QrCodeContext: QrCodeContext,
|
|
3446
|
+
Root: QrCodeRoot,
|
|
3447
|
+
RootProvider: QrCodeRootProvider
|
|
3448
|
+
});
|
|
3449
|
+
|
|
3282
3450
|
const [RadioGroupProvider, useRadioGroupContext] = createContext({
|
|
3283
3451
|
hookName: 'useRadioGroupContext',
|
|
3284
3452
|
providerName: '<RadioGroupProvider />'
|
|
@@ -3512,7 +3680,7 @@ const SegmentGroupContext = props => props.children(useSegmentGroupContext());
|
|
|
3512
3680
|
|
|
3513
3681
|
const SegmentGroupIndicator = props => {
|
|
3514
3682
|
const segmentGroup = useSegmentGroupContext();
|
|
3515
|
-
const mergedProps = solid.mergeProps(() => segmentGroup().getIndicatorProps(), anatomy.segmentGroupAnatomy.build().indicator.attrs, props);
|
|
3683
|
+
const mergedProps = solid.mergeProps(() => segmentGroup().getIndicatorProps(), anatomy$1.segmentGroupAnatomy.build().indicator.attrs, props);
|
|
3516
3684
|
return web.createComponent(ark.div, mergedProps);
|
|
3517
3685
|
};
|
|
3518
3686
|
|
|
@@ -3529,7 +3697,7 @@ const [SegmentGroupItemPropsProvider, useSegmentGroupItemPropsContext] = createC
|
|
|
3529
3697
|
const SegmentGroupItem = props => {
|
|
3530
3698
|
const [itemProps, localProps] = createSplitProps()(props, ['value', 'disabled', 'invalid']);
|
|
3531
3699
|
const segmentGroup = useSegmentGroupContext();
|
|
3532
|
-
const mergedProps = solid.mergeProps(() => segmentGroup().getItemProps(itemProps), anatomy.segmentGroupAnatomy.build().item.attrs, localProps);
|
|
3700
|
+
const mergedProps = solid.mergeProps(() => segmentGroup().getItemProps(itemProps), anatomy$1.segmentGroupAnatomy.build().item.attrs, localProps);
|
|
3533
3701
|
const itemState = solidJs.createMemo(() => segmentGroup().getItemState(itemProps));
|
|
3534
3702
|
return web.createComponent(SegmentGroupItemPropsProvider, {
|
|
3535
3703
|
value: itemProps,
|
|
@@ -3549,7 +3717,7 @@ const SegmentGroupItemContext = props => props.children(useSegmentGroupItemConte
|
|
|
3549
3717
|
const SegmentGroupItemControl = props => {
|
|
3550
3718
|
const segmentGroup = useSegmentGroupContext();
|
|
3551
3719
|
const itemProps = useSegmentGroupItemPropsContext();
|
|
3552
|
-
const mergedProps = solid.mergeProps(() => segmentGroup().getItemControlProps(itemProps), anatomy.segmentGroupAnatomy.build().itemControl.attrs, props);
|
|
3720
|
+
const mergedProps = solid.mergeProps(() => segmentGroup().getItemControlProps(itemProps), anatomy$1.segmentGroupAnatomy.build().itemControl.attrs, props);
|
|
3553
3721
|
return web.createComponent(ark.div, mergedProps);
|
|
3554
3722
|
};
|
|
3555
3723
|
|
|
@@ -3563,13 +3731,13 @@ const SegmentGroupItemHiddenInput = props => {
|
|
|
3563
3731
|
const SegmentGroupItemText = props => {
|
|
3564
3732
|
const segmentGroup = useSegmentGroupContext();
|
|
3565
3733
|
const itemProps = useSegmentGroupItemPropsContext();
|
|
3566
|
-
const mergedProps = solid.mergeProps(() => segmentGroup().getItemTextProps(itemProps), anatomy.segmentGroupAnatomy.build().itemText.attrs, props);
|
|
3734
|
+
const mergedProps = solid.mergeProps(() => segmentGroup().getItemTextProps(itemProps), anatomy$1.segmentGroupAnatomy.build().itemText.attrs, props);
|
|
3567
3735
|
return web.createComponent(ark.span, mergedProps);
|
|
3568
3736
|
};
|
|
3569
3737
|
|
|
3570
3738
|
const SegmentGroupLabel = props => {
|
|
3571
3739
|
const segmentGroup = useSegmentGroupContext();
|
|
3572
|
-
const mergedProps = solid.mergeProps(() => segmentGroup().getLabelProps(), anatomy.segmentGroupAnatomy.build().label.attrs, props);
|
|
3740
|
+
const mergedProps = solid.mergeProps(() => segmentGroup().getLabelProps(), anatomy$1.segmentGroupAnatomy.build().label.attrs, props);
|
|
3573
3741
|
return web.createComponent(ark.label, mergedProps);
|
|
3574
3742
|
};
|
|
3575
3743
|
|
|
@@ -3593,7 +3761,7 @@ const useSegmentGroup = props => {
|
|
|
3593
3761
|
const SegmentGroupRoot = props => {
|
|
3594
3762
|
const [useSegmentGroupProps, localProps] = createSplitProps()(props, ['defaultValue', 'disabled', 'form', 'id', 'ids', 'name', 'onValueChange', 'orientation', 'readOnly', 'value']);
|
|
3595
3763
|
const segmentGroup = useSegmentGroup(useSegmentGroupProps);
|
|
3596
|
-
const mergedProps = solid.mergeProps(() => segmentGroup().getRootProps(), anatomy.segmentGroupAnatomy.build().root.attrs, localProps);
|
|
3764
|
+
const mergedProps = solid.mergeProps(() => segmentGroup().getRootProps(), anatomy$1.segmentGroupAnatomy.build().root.attrs, localProps);
|
|
3597
3765
|
return web.createComponent(SegmentGroupProvider, {
|
|
3598
3766
|
value: segmentGroup,
|
|
3599
3767
|
get children() {
|
|
@@ -3606,7 +3774,7 @@ const SegmentGroupRootProvider = props => {
|
|
|
3606
3774
|
const [{
|
|
3607
3775
|
value: segmentGroup
|
|
3608
3776
|
}, localProps] = createSplitProps()(props, ['value']);
|
|
3609
|
-
const mergedProps = solid.mergeProps(() => segmentGroup().getRootProps(), anatomy.segmentGroupAnatomy.build().root.attrs, localProps);
|
|
3777
|
+
const mergedProps = solid.mergeProps(() => segmentGroup().getRootProps(), anatomy$1.segmentGroupAnatomy.build().root.attrs, localProps);
|
|
3610
3778
|
return web.createComponent(SegmentGroupProvider, {
|
|
3611
3779
|
value: segmentGroup,
|
|
3612
3780
|
get children() {
|
|
@@ -3662,8 +3830,8 @@ const SelectControl = props => {
|
|
|
3662
3830
|
return web.createComponent(ark.div, mergedProps);
|
|
3663
3831
|
};
|
|
3664
3832
|
|
|
3665
|
-
var _tmpl$$
|
|
3666
|
-
_tmpl$2 = /*#__PURE__*/web.template(`<option>`);
|
|
3833
|
+
var _tmpl$$2 = /*#__PURE__*/web.template(`<option value="">`),
|
|
3834
|
+
_tmpl$2$1 = /*#__PURE__*/web.template(`<option>`);
|
|
3667
3835
|
const SelectHiddenSelect = props => {
|
|
3668
3836
|
const select = useSelectContext();
|
|
3669
3837
|
const mergedProps = solid.mergeProps(() => select().getControlProps(), props);
|
|
@@ -3675,14 +3843,14 @@ const SelectHiddenSelect = props => {
|
|
|
3675
3843
|
return isValueEmpty();
|
|
3676
3844
|
},
|
|
3677
3845
|
get children() {
|
|
3678
|
-
return _tmpl$$
|
|
3846
|
+
return _tmpl$$2();
|
|
3679
3847
|
}
|
|
3680
3848
|
}), web.createComponent(solidJs.Index, {
|
|
3681
3849
|
get each() {
|
|
3682
3850
|
return select().collection.toArray();
|
|
3683
3851
|
},
|
|
3684
3852
|
children: option => (() => {
|
|
3685
|
-
var _el$2 = _tmpl$2();
|
|
3853
|
+
var _el$2 = _tmpl$2$1();
|
|
3686
3854
|
web.insert(_el$2, () => option().label);
|
|
3687
3855
|
web.effect(() => _el$2.value = option().value);
|
|
3688
3856
|
return _el$2;
|
|
@@ -3777,6 +3945,12 @@ const SelectLabel = props => {
|
|
|
3777
3945
|
return web.createComponent(ark.label, mergedProps);
|
|
3778
3946
|
};
|
|
3779
3947
|
|
|
3948
|
+
const SelectList = props => {
|
|
3949
|
+
const select = useSelectContext();
|
|
3950
|
+
const mergedProps = solid.mergeProps(() => select().getListProps(), props);
|
|
3951
|
+
return web.createComponent(ark.div, mergedProps);
|
|
3952
|
+
};
|
|
3953
|
+
|
|
3780
3954
|
const SelectPositioner = props => {
|
|
3781
3955
|
const select = useSelectContext();
|
|
3782
3956
|
const presenceApi = usePresenceContext();
|
|
@@ -3864,7 +4038,7 @@ const SelectTrigger = props => {
|
|
|
3864
4038
|
|
|
3865
4039
|
const SelectValueText = props => {
|
|
3866
4040
|
const select = useSelectContext();
|
|
3867
|
-
const mergedProps = solid.mergeProps(() => anatomy.selectAnatomy.build().valueText.attrs, props);
|
|
4041
|
+
const mergedProps = solid.mergeProps(() => anatomy$1.selectAnatomy.build().valueText.attrs, props);
|
|
3868
4042
|
return web.createComponent(ark.span, web.mergeProps(mergedProps, {
|
|
3869
4043
|
get children() {
|
|
3870
4044
|
return select().valueAsString || props.placeholder;
|
|
@@ -3887,6 +4061,7 @@ var select = /*#__PURE__*/Object.freeze({
|
|
|
3887
4061
|
ItemIndicator: SelectItemIndicator,
|
|
3888
4062
|
ItemText: SelectItemText,
|
|
3889
4063
|
Label: SelectLabel,
|
|
4064
|
+
List: SelectList,
|
|
3890
4065
|
Positioner: SelectPositioner,
|
|
3891
4066
|
Root: SelectRoot,
|
|
3892
4067
|
RootProvider: SelectRootProvider,
|
|
@@ -3894,6 +4069,1777 @@ var select = /*#__PURE__*/Object.freeze({
|
|
|
3894
4069
|
ValueText: SelectValueText
|
|
3895
4070
|
});
|
|
3896
4071
|
|
|
4072
|
+
const [SignaturePadProvider, useSignaturePadContext] = createContext({
|
|
4073
|
+
hookName: 'useSignaturePadContext',
|
|
4074
|
+
providerName: '<SignaturePadProvider />'
|
|
4075
|
+
});
|
|
4076
|
+
|
|
4077
|
+
const SignaturePadClearTrigger = props => {
|
|
4078
|
+
const signaturePad = useSignaturePadContext();
|
|
4079
|
+
const mergedProps = solid.mergeProps(() => signaturePad().getClearTriggerProps(), props);
|
|
4080
|
+
return web.createComponent(ark.button, mergedProps);
|
|
4081
|
+
};
|
|
4082
|
+
|
|
4083
|
+
const SignaturePadContext = props => props.children(useSignaturePadContext());
|
|
4084
|
+
|
|
4085
|
+
const SignaturePadControl = props => {
|
|
4086
|
+
const signaturePad = useSignaturePadContext();
|
|
4087
|
+
const mergedProps = solid.mergeProps(() => signaturePad().getControlProps(), props);
|
|
4088
|
+
return web.createComponent(ark.div, web.mergeProps({
|
|
4089
|
+
role: "application"
|
|
4090
|
+
}, mergedProps));
|
|
4091
|
+
};
|
|
4092
|
+
|
|
4093
|
+
const SignaturePadGuide = props => {
|
|
4094
|
+
const signaturePad = useSignaturePadContext();
|
|
4095
|
+
const mergedProps = solid.mergeProps(() => signaturePad().getGuideProps(), props);
|
|
4096
|
+
return web.createComponent(ark.div, mergedProps);
|
|
4097
|
+
};
|
|
4098
|
+
|
|
4099
|
+
const SignaturePadLabel = props => {
|
|
4100
|
+
const signaturePad = useSignaturePadContext();
|
|
4101
|
+
const mergedProps = solid.mergeProps(() => signaturePad().getLabelProps(), props);
|
|
4102
|
+
return web.createComponent(ark.label, mergedProps);
|
|
4103
|
+
};
|
|
4104
|
+
|
|
4105
|
+
// src/create-anatomy.ts
|
|
4106
|
+
var createAnatomy = (name, parts = []) => ({
|
|
4107
|
+
parts: (...values) => {
|
|
4108
|
+
if (isEmpty(parts)) {
|
|
4109
|
+
return createAnatomy(name, values);
|
|
4110
|
+
}
|
|
4111
|
+
throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?");
|
|
4112
|
+
},
|
|
4113
|
+
extendWith: (...values) => createAnatomy(name, [...parts, ...values]),
|
|
4114
|
+
rename: (newName) => createAnatomy(newName, parts),
|
|
4115
|
+
keys: () => parts,
|
|
4116
|
+
build: () => [...new Set(parts)].reduce(
|
|
4117
|
+
(prev, part) => Object.assign(prev, {
|
|
4118
|
+
[part]: {
|
|
4119
|
+
selector: [
|
|
4120
|
+
`&[data-scope="${toKebabCase(name)}"][data-part="${toKebabCase(part)}"]`,
|
|
4121
|
+
`& [data-scope="${toKebabCase(name)}"][data-part="${toKebabCase(part)}"]`
|
|
4122
|
+
].join(", "),
|
|
4123
|
+
attrs: { "data-scope": toKebabCase(name), "data-part": toKebabCase(part) }
|
|
4124
|
+
}
|
|
4125
|
+
}),
|
|
4126
|
+
{}
|
|
4127
|
+
)
|
|
4128
|
+
});
|
|
4129
|
+
var toKebabCase = (value) => value.replace(/([A-Z])([A-Z])/g, "$1-$2").replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
4130
|
+
var isEmpty = (v) => v.length === 0;
|
|
4131
|
+
|
|
4132
|
+
// src/index.ts
|
|
4133
|
+
var state = "default";
|
|
4134
|
+
var userSelect = "";
|
|
4135
|
+
var elementMap = /* @__PURE__ */ new WeakMap();
|
|
4136
|
+
function disableTextSelectionImpl(options = {}) {
|
|
4137
|
+
const { target, doc } = options;
|
|
4138
|
+
const docNode = doc ?? document;
|
|
4139
|
+
const rootEl = docNode.documentElement;
|
|
4140
|
+
if (domQuery.isIos()) {
|
|
4141
|
+
if (state === "default") {
|
|
4142
|
+
userSelect = rootEl.style.webkitUserSelect;
|
|
4143
|
+
rootEl.style.webkitUserSelect = "none";
|
|
4144
|
+
}
|
|
4145
|
+
state = "disabled";
|
|
4146
|
+
} else if (target) {
|
|
4147
|
+
elementMap.set(target, target.style.userSelect);
|
|
4148
|
+
target.style.userSelect = "none";
|
|
4149
|
+
}
|
|
4150
|
+
return () => restoreTextSelection({ target, doc: docNode });
|
|
4151
|
+
}
|
|
4152
|
+
function restoreTextSelection(options = {}) {
|
|
4153
|
+
const { target, doc } = options;
|
|
4154
|
+
const docNode = doc ?? document;
|
|
4155
|
+
const rootEl = docNode.documentElement;
|
|
4156
|
+
if (domQuery.isIos()) {
|
|
4157
|
+
if (state !== "disabled") return;
|
|
4158
|
+
state = "restoring";
|
|
4159
|
+
setTimeout(() => {
|
|
4160
|
+
domQuery.nextTick(() => {
|
|
4161
|
+
if (state === "restoring") {
|
|
4162
|
+
if (rootEl.style.webkitUserSelect === "none") {
|
|
4163
|
+
rootEl.style.webkitUserSelect = userSelect || "";
|
|
4164
|
+
}
|
|
4165
|
+
userSelect = "";
|
|
4166
|
+
state = "default";
|
|
4167
|
+
}
|
|
4168
|
+
});
|
|
4169
|
+
}, 300);
|
|
4170
|
+
} else {
|
|
4171
|
+
if (target && elementMap.has(target)) {
|
|
4172
|
+
const prevUserSelect = elementMap.get(target);
|
|
4173
|
+
if (target.style.userSelect === "none") {
|
|
4174
|
+
target.style.userSelect = prevUserSelect ?? "";
|
|
4175
|
+
}
|
|
4176
|
+
if (target.getAttribute("style") === "") {
|
|
4177
|
+
target.removeAttribute("style");
|
|
4178
|
+
}
|
|
4179
|
+
elementMap.delete(target);
|
|
4180
|
+
}
|
|
4181
|
+
}
|
|
4182
|
+
}
|
|
4183
|
+
function disableTextSelection(options = {}) {
|
|
4184
|
+
const { defer, target, ...restOptions } = options;
|
|
4185
|
+
const func = defer ? domQuery.raf : (v) => v();
|
|
4186
|
+
const cleanups = [];
|
|
4187
|
+
cleanups.push(
|
|
4188
|
+
func(() => {
|
|
4189
|
+
const node = typeof target === "function" ? target() : target;
|
|
4190
|
+
cleanups.push(disableTextSelectionImpl({ ...restOptions, target: node }));
|
|
4191
|
+
})
|
|
4192
|
+
);
|
|
4193
|
+
return () => {
|
|
4194
|
+
cleanups.forEach((fn) => fn?.());
|
|
4195
|
+
};
|
|
4196
|
+
}
|
|
4197
|
+
|
|
4198
|
+
// src/add-dom-event.ts
|
|
4199
|
+
var addDomEvent = (target, eventName, handler, options) => {
|
|
4200
|
+
const node = typeof target === "function" ? target() : target;
|
|
4201
|
+
node?.addEventListener(eventName, handler, options);
|
|
4202
|
+
return () => {
|
|
4203
|
+
node?.removeEventListener(eventName, handler, options);
|
|
4204
|
+
};
|
|
4205
|
+
};
|
|
4206
|
+
var isLeftClick = (e) => e.button === 0;
|
|
4207
|
+
var isModifierKey = (e) => e.ctrlKey || e.altKey || e.metaKey;
|
|
4208
|
+
|
|
4209
|
+
// src/get-event-point.ts
|
|
4210
|
+
function pointFromTouch(e, type = "client") {
|
|
4211
|
+
const point = e.touches[0] || e.changedTouches[0];
|
|
4212
|
+
return { x: point[`${type}X`], y: point[`${type}Y`] };
|
|
4213
|
+
}
|
|
4214
|
+
function pointFromMouse(point, type = "client") {
|
|
4215
|
+
return { x: point[`${type}X`], y: point[`${type}Y`] };
|
|
4216
|
+
}
|
|
4217
|
+
var isTouchEvent = (event) => "touches" in event && event.touches.length > 0;
|
|
4218
|
+
function getEventPoint(event, type = "client") {
|
|
4219
|
+
return isTouchEvent(event) ? pointFromTouch(event, type) : pointFromMouse(event, type);
|
|
4220
|
+
}
|
|
4221
|
+
|
|
4222
|
+
// src/get-point-value.ts
|
|
4223
|
+
function clamp(value) {
|
|
4224
|
+
return Math.max(0, Math.min(1, value));
|
|
4225
|
+
}
|
|
4226
|
+
function getRelativePoint(point, element) {
|
|
4227
|
+
const { left, top, width, height } = element.getBoundingClientRect();
|
|
4228
|
+
const offset = { x: point.x - left, y: point.y - top };
|
|
4229
|
+
const percent = { x: clamp(offset.x / width), y: clamp(offset.y / height) };
|
|
4230
|
+
function getPercentValue(options = {}) {
|
|
4231
|
+
const { dir = "ltr", orientation = "horizontal", inverted } = options;
|
|
4232
|
+
const invertX = typeof inverted === "object" ? inverted.x : inverted;
|
|
4233
|
+
const invertY = typeof inverted === "object" ? inverted.y : inverted;
|
|
4234
|
+
if (orientation === "horizontal") {
|
|
4235
|
+
return dir === "rtl" || invertX ? 1 - percent.x : percent.x;
|
|
4236
|
+
}
|
|
4237
|
+
return invertY ? 1 - percent.y : percent.y;
|
|
4238
|
+
}
|
|
4239
|
+
return { offset, percent, getPercentValue };
|
|
4240
|
+
}
|
|
4241
|
+
function trackPointerMove(doc, handlers) {
|
|
4242
|
+
const { onPointerMove, onPointerUp } = handlers;
|
|
4243
|
+
const history = [];
|
|
4244
|
+
const handleMove = (event) => {
|
|
4245
|
+
const point = getEventPoint(event);
|
|
4246
|
+
history.push({ ...point, timestamp: performance.now() });
|
|
4247
|
+
const distance = Math.sqrt(point.x ** 2 + point.y ** 2);
|
|
4248
|
+
const moveBuffer = event.pointerType === "touch" ? 10 : 5;
|
|
4249
|
+
if (distance < moveBuffer) return;
|
|
4250
|
+
if (event.pointerType === "mouse" && event.button === 0) {
|
|
4251
|
+
onPointerUp();
|
|
4252
|
+
return;
|
|
4253
|
+
}
|
|
4254
|
+
onPointerMove({ point, event, velocity: getVelocity(history, 0.1) });
|
|
4255
|
+
};
|
|
4256
|
+
const cleanups = [
|
|
4257
|
+
addDomEvent(doc, "pointermove", handleMove, false),
|
|
4258
|
+
addDomEvent(doc, "pointerup", onPointerUp, false),
|
|
4259
|
+
addDomEvent(doc, "pointercancel", onPointerUp, false),
|
|
4260
|
+
addDomEvent(doc, "contextmenu", onPointerUp, false),
|
|
4261
|
+
disableTextSelection({ doc })
|
|
4262
|
+
];
|
|
4263
|
+
return () => {
|
|
4264
|
+
cleanups.forEach((cleanup) => cleanup());
|
|
4265
|
+
history.length = 0;
|
|
4266
|
+
};
|
|
4267
|
+
}
|
|
4268
|
+
function lastDevicePoint(history) {
|
|
4269
|
+
return history[history.length - 1];
|
|
4270
|
+
}
|
|
4271
|
+
function ms(seconds) {
|
|
4272
|
+
return seconds * 1e3;
|
|
4273
|
+
}
|
|
4274
|
+
function sec(milliseconds) {
|
|
4275
|
+
return milliseconds / 1e3;
|
|
4276
|
+
}
|
|
4277
|
+
function getVelocity(history, timeDelta) {
|
|
4278
|
+
if (history.length < 2) return { x: 0, y: 0 };
|
|
4279
|
+
let i = history.length - 1;
|
|
4280
|
+
let timestampedPoint = null;
|
|
4281
|
+
const lastPoint = lastDevicePoint(history);
|
|
4282
|
+
while (i >= 0) {
|
|
4283
|
+
timestampedPoint = history[i];
|
|
4284
|
+
if (lastPoint.timestamp - timestampedPoint.timestamp > ms(timeDelta)) {
|
|
4285
|
+
break;
|
|
4286
|
+
}
|
|
4287
|
+
i--;
|
|
4288
|
+
}
|
|
4289
|
+
if (!timestampedPoint) return { x: 0, y: 0 };
|
|
4290
|
+
const time = sec(lastPoint.timestamp - timestampedPoint.timestamp);
|
|
4291
|
+
if (time === 0) return { x: 0, y: 0 };
|
|
4292
|
+
const currentVelocity = {
|
|
4293
|
+
x: (lastPoint.x - timestampedPoint.x) / time,
|
|
4294
|
+
y: (lastPoint.y - timestampedPoint.y) / time
|
|
4295
|
+
};
|
|
4296
|
+
if (currentVelocity.x === Infinity) currentVelocity.x = 0;
|
|
4297
|
+
if (currentVelocity.y === Infinity) currentVelocity.y = 0;
|
|
4298
|
+
return {
|
|
4299
|
+
x: Math.abs(currentVelocity.x),
|
|
4300
|
+
y: Math.abs(currentVelocity.y)
|
|
4301
|
+
};
|
|
4302
|
+
}
|
|
4303
|
+
|
|
4304
|
+
/* eslint @typescript-eslint/no-explicit-any: off */
|
|
4305
|
+
// symbols
|
|
4306
|
+
const GET_ORIGINAL_SYMBOL = Symbol();
|
|
4307
|
+
// get object prototype
|
|
4308
|
+
const getProto = Object.getPrototypeOf;
|
|
4309
|
+
const objectsToTrack = new WeakMap();
|
|
4310
|
+
// check if obj is a plain object or an array
|
|
4311
|
+
const isObjectToTrack = obj => obj && (objectsToTrack.has(obj) ? objectsToTrack.get(obj) : getProto(obj) === Object.prototype || getProto(obj) === Array.prototype);
|
|
4312
|
+
/**
|
|
4313
|
+
* Unwrap proxy to get the original object.
|
|
4314
|
+
*
|
|
4315
|
+
* Used to retrieve the original object used to create the proxy instance with `createProxy`.
|
|
4316
|
+
*
|
|
4317
|
+
* @param {Proxy<object>} obj - The proxy wrapper of the originial object.
|
|
4318
|
+
* @returns {object | null} - Return either the unwrapped object if exists.
|
|
4319
|
+
*
|
|
4320
|
+
* @example
|
|
4321
|
+
* import { createProxy, getUntracked } from 'proxy-compare';
|
|
4322
|
+
*
|
|
4323
|
+
* const original = { a: "1", c: "2", d: { e: "3" } };
|
|
4324
|
+
* const affected = new WeakMap();
|
|
4325
|
+
*
|
|
4326
|
+
* const proxy = createProxy(original, affected);
|
|
4327
|
+
* const originalFromProxy = getUntracked(proxy)
|
|
4328
|
+
*
|
|
4329
|
+
* Object.is(original, originalFromProxy) // true
|
|
4330
|
+
* isChanged(original, originalFromProxy, affected) // false
|
|
4331
|
+
*/
|
|
4332
|
+
const getUntracked = obj => {
|
|
4333
|
+
if (isObjectToTrack(obj)) {
|
|
4334
|
+
return obj[GET_ORIGINAL_SYMBOL] || null;
|
|
4335
|
+
}
|
|
4336
|
+
return null;
|
|
4337
|
+
};
|
|
4338
|
+
/**
|
|
4339
|
+
* Mark object to be tracked.
|
|
4340
|
+
*
|
|
4341
|
+
* This function marks an object that will be passed into `createProxy`
|
|
4342
|
+
* as marked to track or not. By default only Array and Object are marked to track,
|
|
4343
|
+
* so this is useful for example to mark a class instance to track or to mark a object
|
|
4344
|
+
* to be untracked when creating your proxy.
|
|
4345
|
+
*
|
|
4346
|
+
* @param obj - Object to mark as tracked or not.
|
|
4347
|
+
* @param mark - Boolean indicating whether you want to track this object or not.
|
|
4348
|
+
* @returns - No return.
|
|
4349
|
+
*
|
|
4350
|
+
* @example
|
|
4351
|
+
* import { createProxy, markToTrack, isChanged } from 'proxy-compare';
|
|
4352
|
+
*
|
|
4353
|
+
* const nested = { e: "3" }
|
|
4354
|
+
*
|
|
4355
|
+
* markToTrack(nested, false)
|
|
4356
|
+
*
|
|
4357
|
+
* const original = { a: "1", c: "2", d: nested };
|
|
4358
|
+
* const affected = new WeakMap();
|
|
4359
|
+
*
|
|
4360
|
+
* const proxy = createProxy(original, affected);
|
|
4361
|
+
*
|
|
4362
|
+
* proxy.d.e
|
|
4363
|
+
*
|
|
4364
|
+
* isChanged(original, { d: { e: "3" } }, affected) // true
|
|
4365
|
+
*/
|
|
4366
|
+
const markToTrack = (obj, mark = true) => {
|
|
4367
|
+
objectsToTrack.set(obj, mark);
|
|
4368
|
+
};
|
|
4369
|
+
|
|
4370
|
+
// src/global.ts
|
|
4371
|
+
function getGlobal() {
|
|
4372
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
|
4373
|
+
if (typeof self !== "undefined") return self;
|
|
4374
|
+
if (typeof window !== "undefined") return window;
|
|
4375
|
+
if (typeof global !== "undefined") return global;
|
|
4376
|
+
}
|
|
4377
|
+
function makeGlobal(key, value) {
|
|
4378
|
+
const g = getGlobal();
|
|
4379
|
+
if (!g) return value();
|
|
4380
|
+
g[key] || (g[key] = value());
|
|
4381
|
+
return g[key];
|
|
4382
|
+
}
|
|
4383
|
+
var isDev$1 = process.env.NODE_ENV !== "production";
|
|
4384
|
+
var isObject$1 = (x) => typeof x === "object" && x !== null;
|
|
4385
|
+
var proxyStateMap = makeGlobal("__zag__proxyStateMap", () => /* @__PURE__ */ new WeakMap());
|
|
4386
|
+
var refSet = makeGlobal("__zag__refSet", () => /* @__PURE__ */ new WeakSet());
|
|
4387
|
+
var buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject$1(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), defaultHandlePromise = (promise) => {
|
|
4388
|
+
switch (promise.status) {
|
|
4389
|
+
case "fulfilled":
|
|
4390
|
+
return promise.value;
|
|
4391
|
+
case "rejected":
|
|
4392
|
+
throw promise.reason;
|
|
4393
|
+
default:
|
|
4394
|
+
throw promise;
|
|
4395
|
+
}
|
|
4396
|
+
}, snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version, handlePromise = defaultHandlePromise) => {
|
|
4397
|
+
const cache = snapCache.get(target);
|
|
4398
|
+
if (cache?.[0] === version) {
|
|
4399
|
+
return cache[1];
|
|
4400
|
+
}
|
|
4401
|
+
const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
|
|
4402
|
+
markToTrack(snap, true);
|
|
4403
|
+
snapCache.set(target, [version, snap]);
|
|
4404
|
+
Reflect.ownKeys(target).forEach((key) => {
|
|
4405
|
+
const value = Reflect.get(target, key);
|
|
4406
|
+
if (refSet.has(value)) {
|
|
4407
|
+
markToTrack(value, false);
|
|
4408
|
+
snap[key] = value;
|
|
4409
|
+
} else if (value instanceof Promise) {
|
|
4410
|
+
Object.defineProperty(snap, key, {
|
|
4411
|
+
get() {
|
|
4412
|
+
return handlePromise(value);
|
|
4413
|
+
}
|
|
4414
|
+
});
|
|
4415
|
+
} else if (proxyStateMap.has(value)) {
|
|
4416
|
+
snap[key] = snapshot(value, handlePromise);
|
|
4417
|
+
} else {
|
|
4418
|
+
snap[key] = value;
|
|
4419
|
+
}
|
|
4420
|
+
});
|
|
4421
|
+
return Object.freeze(snap);
|
|
4422
|
+
}, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = (initialObject) => {
|
|
4423
|
+
if (!isObject$1(initialObject)) {
|
|
4424
|
+
throw new Error("object required");
|
|
4425
|
+
}
|
|
4426
|
+
const found = proxyCache.get(initialObject);
|
|
4427
|
+
if (found) {
|
|
4428
|
+
return found;
|
|
4429
|
+
}
|
|
4430
|
+
let version = versionHolder[0];
|
|
4431
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
4432
|
+
const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => {
|
|
4433
|
+
if (version !== nextVersion) {
|
|
4434
|
+
version = nextVersion;
|
|
4435
|
+
listeners.forEach((listener) => listener(op, nextVersion));
|
|
4436
|
+
}
|
|
4437
|
+
};
|
|
4438
|
+
let checkVersion = versionHolder[1];
|
|
4439
|
+
const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => {
|
|
4440
|
+
if (checkVersion !== nextCheckVersion && !listeners.size) {
|
|
4441
|
+
checkVersion = nextCheckVersion;
|
|
4442
|
+
propProxyStates.forEach(([propProxyState]) => {
|
|
4443
|
+
const propVersion = propProxyState[1](nextCheckVersion);
|
|
4444
|
+
if (propVersion > version) {
|
|
4445
|
+
version = propVersion;
|
|
4446
|
+
}
|
|
4447
|
+
});
|
|
4448
|
+
}
|
|
4449
|
+
return version;
|
|
4450
|
+
};
|
|
4451
|
+
const createPropListener = (prop) => (op, nextVersion) => {
|
|
4452
|
+
const newOp = [...op];
|
|
4453
|
+
newOp[1] = [prop, ...newOp[1]];
|
|
4454
|
+
notifyUpdate(newOp, nextVersion);
|
|
4455
|
+
};
|
|
4456
|
+
const propProxyStates = /* @__PURE__ */ new Map();
|
|
4457
|
+
const addPropListener = (prop, propProxyState) => {
|
|
4458
|
+
if (isDev$1 && propProxyStates.has(prop)) {
|
|
4459
|
+
throw new Error("prop listener already exists");
|
|
4460
|
+
}
|
|
4461
|
+
if (listeners.size) {
|
|
4462
|
+
const remove = propProxyState[3](createPropListener(prop));
|
|
4463
|
+
propProxyStates.set(prop, [propProxyState, remove]);
|
|
4464
|
+
} else {
|
|
4465
|
+
propProxyStates.set(prop, [propProxyState]);
|
|
4466
|
+
}
|
|
4467
|
+
};
|
|
4468
|
+
const removePropListener = (prop) => {
|
|
4469
|
+
const entry = propProxyStates.get(prop);
|
|
4470
|
+
if (entry) {
|
|
4471
|
+
propProxyStates.delete(prop);
|
|
4472
|
+
entry[1]?.();
|
|
4473
|
+
}
|
|
4474
|
+
};
|
|
4475
|
+
const addListener = (listener) => {
|
|
4476
|
+
listeners.add(listener);
|
|
4477
|
+
if (listeners.size === 1) {
|
|
4478
|
+
propProxyStates.forEach(([propProxyState, prevRemove], prop) => {
|
|
4479
|
+
if (isDev$1 && prevRemove) {
|
|
4480
|
+
throw new Error("remove already exists");
|
|
4481
|
+
}
|
|
4482
|
+
const remove = propProxyState[3](createPropListener(prop));
|
|
4483
|
+
propProxyStates.set(prop, [propProxyState, remove]);
|
|
4484
|
+
});
|
|
4485
|
+
}
|
|
4486
|
+
const removeListener = () => {
|
|
4487
|
+
listeners.delete(listener);
|
|
4488
|
+
if (listeners.size === 0) {
|
|
4489
|
+
propProxyStates.forEach(([propProxyState, remove], prop) => {
|
|
4490
|
+
if (remove) {
|
|
4491
|
+
remove();
|
|
4492
|
+
propProxyStates.set(prop, [propProxyState]);
|
|
4493
|
+
}
|
|
4494
|
+
});
|
|
4495
|
+
}
|
|
4496
|
+
};
|
|
4497
|
+
return removeListener;
|
|
4498
|
+
};
|
|
4499
|
+
const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
|
|
4500
|
+
const handler = {
|
|
4501
|
+
deleteProperty(target, prop) {
|
|
4502
|
+
const prevValue = Reflect.get(target, prop);
|
|
4503
|
+
removePropListener(prop);
|
|
4504
|
+
const deleted = Reflect.deleteProperty(target, prop);
|
|
4505
|
+
if (deleted) {
|
|
4506
|
+
notifyUpdate(["delete", [prop], prevValue]);
|
|
4507
|
+
}
|
|
4508
|
+
return deleted;
|
|
4509
|
+
},
|
|
4510
|
+
set(target, prop, value, receiver) {
|
|
4511
|
+
const hasPrevValue = Reflect.has(target, prop);
|
|
4512
|
+
const prevValue = Reflect.get(target, prop, receiver);
|
|
4513
|
+
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) {
|
|
4514
|
+
return true;
|
|
4515
|
+
}
|
|
4516
|
+
removePropListener(prop);
|
|
4517
|
+
if (isObject$1(value)) {
|
|
4518
|
+
value = getUntracked(value) || value;
|
|
4519
|
+
}
|
|
4520
|
+
let nextValue = value;
|
|
4521
|
+
if (Object.getOwnPropertyDescriptor(target, prop)?.set) ; else if (value instanceof Promise) {
|
|
4522
|
+
value.then((v) => {
|
|
4523
|
+
Object.assign(value, { status: "fulfilled", value: v });
|
|
4524
|
+
notifyUpdate(["resolve", [prop], v]);
|
|
4525
|
+
}).catch((e) => {
|
|
4526
|
+
Object.assign(value, { status: "rejected", reason: e });
|
|
4527
|
+
notifyUpdate(["reject", [prop], e]);
|
|
4528
|
+
});
|
|
4529
|
+
} else {
|
|
4530
|
+
if (!proxyStateMap.has(value) && canProxy(value)) {
|
|
4531
|
+
nextValue = proxy(value);
|
|
4532
|
+
}
|
|
4533
|
+
const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue);
|
|
4534
|
+
if (childProxyState) {
|
|
4535
|
+
addPropListener(prop, childProxyState);
|
|
4536
|
+
}
|
|
4537
|
+
}
|
|
4538
|
+
Reflect.set(target, prop, nextValue, receiver);
|
|
4539
|
+
notifyUpdate(["set", [prop], value, prevValue]);
|
|
4540
|
+
return true;
|
|
4541
|
+
}
|
|
4542
|
+
};
|
|
4543
|
+
const proxyObject = newProxy(baseObject, handler);
|
|
4544
|
+
proxyCache.set(initialObject, proxyObject);
|
|
4545
|
+
const proxyState = [baseObject, ensureVersion, createSnapshot, addListener];
|
|
4546
|
+
proxyStateMap.set(proxyObject, proxyState);
|
|
4547
|
+
Reflect.ownKeys(initialObject).forEach((key) => {
|
|
4548
|
+
const desc = Object.getOwnPropertyDescriptor(initialObject, key);
|
|
4549
|
+
if (desc.get || desc.set) {
|
|
4550
|
+
Object.defineProperty(baseObject, key, desc);
|
|
4551
|
+
} else {
|
|
4552
|
+
proxyObject[key] = initialObject[key];
|
|
4553
|
+
}
|
|
4554
|
+
});
|
|
4555
|
+
return proxyObject;
|
|
4556
|
+
}) => [
|
|
4557
|
+
// public functions
|
|
4558
|
+
proxyFunction2,
|
|
4559
|
+
// shared state
|
|
4560
|
+
proxyStateMap,
|
|
4561
|
+
refSet,
|
|
4562
|
+
// internal things
|
|
4563
|
+
objectIs,
|
|
4564
|
+
newProxy,
|
|
4565
|
+
canProxy,
|
|
4566
|
+
defaultHandlePromise,
|
|
4567
|
+
snapCache,
|
|
4568
|
+
createSnapshot,
|
|
4569
|
+
proxyCache,
|
|
4570
|
+
versionHolder
|
|
4571
|
+
];
|
|
4572
|
+
var [proxyFunction] = buildProxyFunction();
|
|
4573
|
+
function proxy(initialObject = {}) {
|
|
4574
|
+
return proxyFunction(initialObject);
|
|
4575
|
+
}
|
|
4576
|
+
function subscribe(proxyObject, callback, notifyInSync) {
|
|
4577
|
+
const proxyState = proxyStateMap.get(proxyObject);
|
|
4578
|
+
if (isDev$1 && !proxyState) {
|
|
4579
|
+
console.warn("Please use proxy object");
|
|
4580
|
+
}
|
|
4581
|
+
let promise;
|
|
4582
|
+
const ops = [];
|
|
4583
|
+
const addListener = proxyState[3];
|
|
4584
|
+
let isListenerActive = false;
|
|
4585
|
+
const listener = (op) => {
|
|
4586
|
+
ops.push(op);
|
|
4587
|
+
if (notifyInSync) {
|
|
4588
|
+
callback(ops.splice(0));
|
|
4589
|
+
return;
|
|
4590
|
+
}
|
|
4591
|
+
if (!promise) {
|
|
4592
|
+
promise = Promise.resolve().then(() => {
|
|
4593
|
+
promise = void 0;
|
|
4594
|
+
if (isListenerActive) {
|
|
4595
|
+
callback(ops.splice(0));
|
|
4596
|
+
}
|
|
4597
|
+
});
|
|
4598
|
+
}
|
|
4599
|
+
};
|
|
4600
|
+
const removeListener = addListener(listener);
|
|
4601
|
+
isListenerActive = true;
|
|
4602
|
+
return () => {
|
|
4603
|
+
isListenerActive = false;
|
|
4604
|
+
removeListener();
|
|
4605
|
+
};
|
|
4606
|
+
}
|
|
4607
|
+
function snapshot(proxyObject, handlePromise) {
|
|
4608
|
+
const proxyState = proxyStateMap.get(proxyObject);
|
|
4609
|
+
if (isDev$1 && !proxyState) {
|
|
4610
|
+
console.warn("Please use proxy object");
|
|
4611
|
+
}
|
|
4612
|
+
const [target, ensureVersion, createSnapshot] = proxyState;
|
|
4613
|
+
return createSnapshot(target, ensureVersion(), handlePromise);
|
|
4614
|
+
}
|
|
4615
|
+
function ref(obj) {
|
|
4616
|
+
refSet.add(obj);
|
|
4617
|
+
return obj;
|
|
4618
|
+
}
|
|
4619
|
+
|
|
4620
|
+
// src/proxy-computed.ts
|
|
4621
|
+
function proxyWithComputed(initialObject, computedFns) {
|
|
4622
|
+
const keys = Object.keys(computedFns);
|
|
4623
|
+
keys.forEach((key) => {
|
|
4624
|
+
if (Object.getOwnPropertyDescriptor(initialObject, key)) {
|
|
4625
|
+
throw new Error("object property already defined");
|
|
4626
|
+
}
|
|
4627
|
+
const computedFn = computedFns[key];
|
|
4628
|
+
const { get, set } = typeof computedFn === "function" ? { get: computedFn } : computedFn;
|
|
4629
|
+
const desc = {};
|
|
4630
|
+
desc.get = () => get(snapshot(proxyObject));
|
|
4631
|
+
if (set) {
|
|
4632
|
+
desc.set = (newValue) => set(proxyObject, newValue);
|
|
4633
|
+
}
|
|
4634
|
+
Object.defineProperty(initialObject, key, desc);
|
|
4635
|
+
});
|
|
4636
|
+
const proxyObject = proxy(initialObject);
|
|
4637
|
+
return proxyObject;
|
|
4638
|
+
}
|
|
4639
|
+
|
|
4640
|
+
function set(obj, key, val) {
|
|
4641
|
+
if (typeof val.value === 'object') val.value = klona(val.value);
|
|
4642
|
+
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === '__proto__') {
|
|
4643
|
+
Object.defineProperty(obj, key, val);
|
|
4644
|
+
} else obj[key] = val.value;
|
|
4645
|
+
}
|
|
4646
|
+
|
|
4647
|
+
function klona(x) {
|
|
4648
|
+
if (typeof x !== 'object') return x;
|
|
4649
|
+
|
|
4650
|
+
var i=0, k, list, tmp, str=Object.prototype.toString.call(x);
|
|
4651
|
+
|
|
4652
|
+
if (str === '[object Object]') {
|
|
4653
|
+
tmp = Object.create(x.__proto__ || null);
|
|
4654
|
+
} else if (str === '[object Array]') {
|
|
4655
|
+
tmp = Array(x.length);
|
|
4656
|
+
} else if (str === '[object Set]') {
|
|
4657
|
+
tmp = new Set;
|
|
4658
|
+
x.forEach(function (val) {
|
|
4659
|
+
tmp.add(klona(val));
|
|
4660
|
+
});
|
|
4661
|
+
} else if (str === '[object Map]') {
|
|
4662
|
+
tmp = new Map;
|
|
4663
|
+
x.forEach(function (val, key) {
|
|
4664
|
+
tmp.set(klona(key), klona(val));
|
|
4665
|
+
});
|
|
4666
|
+
} else if (str === '[object Date]') {
|
|
4667
|
+
tmp = new Date(+x);
|
|
4668
|
+
} else if (str === '[object RegExp]') {
|
|
4669
|
+
tmp = new RegExp(x.source, x.flags);
|
|
4670
|
+
} else if (str === '[object DataView]') {
|
|
4671
|
+
tmp = new x.constructor( klona(x.buffer) );
|
|
4672
|
+
} else if (str === '[object ArrayBuffer]') {
|
|
4673
|
+
tmp = x.slice(0);
|
|
4674
|
+
} else if (str.slice(-6) === 'Array]') {
|
|
4675
|
+
// ArrayBuffer.isView(x)
|
|
4676
|
+
// ~> `new` bcuz `Buffer.slice` => ref
|
|
4677
|
+
tmp = new x.constructor(x);
|
|
4678
|
+
}
|
|
4679
|
+
|
|
4680
|
+
if (tmp) {
|
|
4681
|
+
for (list=Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
4682
|
+
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
4683
|
+
}
|
|
4684
|
+
|
|
4685
|
+
for (i=0, list=Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
4686
|
+
if (Object.hasOwnProperty.call(tmp, k=list[i]) && tmp[k] === x[k]) continue;
|
|
4687
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
4688
|
+
}
|
|
4689
|
+
}
|
|
4690
|
+
|
|
4691
|
+
return tmp || x;
|
|
4692
|
+
}
|
|
4693
|
+
|
|
4694
|
+
var __defProp = Object.defineProperty;
|
|
4695
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4696
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4697
|
+
|
|
4698
|
+
// ../utilities/core/src/array.ts
|
|
4699
|
+
function clear(v) {
|
|
4700
|
+
while (v.length > 0) v.pop();
|
|
4701
|
+
return v;
|
|
4702
|
+
}
|
|
4703
|
+
|
|
4704
|
+
// ../utilities/core/src/functions.ts
|
|
4705
|
+
var runIfFn = (v, ...a) => {
|
|
4706
|
+
const res = typeof v === "function" ? v(...a) : v;
|
|
4707
|
+
return res ?? void 0;
|
|
4708
|
+
};
|
|
4709
|
+
var cast = (v) => v;
|
|
4710
|
+
var noop = () => {
|
|
4711
|
+
};
|
|
4712
|
+
var uuid = /* @__PURE__ */ (() => {
|
|
4713
|
+
let id = 0;
|
|
4714
|
+
return () => {
|
|
4715
|
+
id++;
|
|
4716
|
+
return id.toString(36);
|
|
4717
|
+
};
|
|
4718
|
+
})();
|
|
4719
|
+
|
|
4720
|
+
// ../utilities/core/src/guard.ts
|
|
4721
|
+
var isDev = () => process.env.NODE_ENV !== "production";
|
|
4722
|
+
var isArray = (v) => Array.isArray(v);
|
|
4723
|
+
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
4724
|
+
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
|
|
4725
|
+
var isString = (v) => typeof v === "string";
|
|
4726
|
+
var isFunction = (v) => typeof v === "function";
|
|
4727
|
+
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
4728
|
+
|
|
4729
|
+
// ../utilities/core/src/object.ts
|
|
4730
|
+
function compact$1(obj) {
|
|
4731
|
+
if (!isPlainObject$1(obj) || obj === void 0) {
|
|
4732
|
+
return obj;
|
|
4733
|
+
}
|
|
4734
|
+
const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
|
|
4735
|
+
const filtered = {};
|
|
4736
|
+
for (const key of keys) {
|
|
4737
|
+
const value = obj[key];
|
|
4738
|
+
if (value !== void 0) {
|
|
4739
|
+
filtered[key] = compact$1(value);
|
|
4740
|
+
}
|
|
4741
|
+
}
|
|
4742
|
+
return filtered;
|
|
4743
|
+
}
|
|
4744
|
+
var isPlainObject$1 = (value) => {
|
|
4745
|
+
return value && typeof value === "object" && value.constructor === Object;
|
|
4746
|
+
};
|
|
4747
|
+
|
|
4748
|
+
// ../utilities/core/src/warning.ts
|
|
4749
|
+
function warn(...a) {
|
|
4750
|
+
const m = a.length === 1 ? a[0] : a[1];
|
|
4751
|
+
const c = a.length === 2 ? a[0] : true;
|
|
4752
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
4753
|
+
console.warn(m);
|
|
4754
|
+
}
|
|
4755
|
+
}
|
|
4756
|
+
function invariant(...a) {
|
|
4757
|
+
const m = a.length === 1 ? a[0] : a[1];
|
|
4758
|
+
const c = a.length === 2 ? a[0] : true;
|
|
4759
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
4760
|
+
throw new Error(m);
|
|
4761
|
+
}
|
|
4762
|
+
}
|
|
4763
|
+
|
|
4764
|
+
// src/deep-merge.ts
|
|
4765
|
+
function deepMerge(source, ...objects) {
|
|
4766
|
+
for (const obj of objects) {
|
|
4767
|
+
const target = compact$1(obj);
|
|
4768
|
+
for (const key in target) {
|
|
4769
|
+
if (isObject(obj[key])) {
|
|
4770
|
+
if (!source[key]) {
|
|
4771
|
+
source[key] = {};
|
|
4772
|
+
}
|
|
4773
|
+
deepMerge(source[key], obj[key]);
|
|
4774
|
+
} else {
|
|
4775
|
+
source[key] = obj[key];
|
|
4776
|
+
}
|
|
4777
|
+
}
|
|
4778
|
+
}
|
|
4779
|
+
return source;
|
|
4780
|
+
}
|
|
4781
|
+
function structuredClone(v) {
|
|
4782
|
+
return klona(v);
|
|
4783
|
+
}
|
|
4784
|
+
function toEvent(event) {
|
|
4785
|
+
const obj = isString(event) ? { type: event } : event;
|
|
4786
|
+
return obj;
|
|
4787
|
+
}
|
|
4788
|
+
function toArray(value) {
|
|
4789
|
+
if (!value) return [];
|
|
4790
|
+
return isArray(value) ? value.slice() : [value];
|
|
4791
|
+
}
|
|
4792
|
+
function isGuardHelper(value) {
|
|
4793
|
+
return isObject(value) && value.predicate != null;
|
|
4794
|
+
}
|
|
4795
|
+
|
|
4796
|
+
// src/guard-utils.ts
|
|
4797
|
+
var Truthy = () => true;
|
|
4798
|
+
function determineGuardFn(guard, guardMap) {
|
|
4799
|
+
guard = guard ?? Truthy;
|
|
4800
|
+
return (context, event, meta) => {
|
|
4801
|
+
if (isString(guard)) {
|
|
4802
|
+
const value = guardMap[guard];
|
|
4803
|
+
return isFunction(value) ? value(context, event, meta) : value;
|
|
4804
|
+
}
|
|
4805
|
+
if (isGuardHelper(guard)) {
|
|
4806
|
+
return guard.predicate(guardMap)(context, event, meta);
|
|
4807
|
+
}
|
|
4808
|
+
return guard?.(context, event, meta);
|
|
4809
|
+
};
|
|
4810
|
+
}
|
|
4811
|
+
function determineActionsFn(values, guardMap) {
|
|
4812
|
+
return (context, event, meta) => {
|
|
4813
|
+
if (isGuardHelper(values)) {
|
|
4814
|
+
return values.predicate(guardMap)(context, event, meta);
|
|
4815
|
+
}
|
|
4816
|
+
return values;
|
|
4817
|
+
};
|
|
4818
|
+
}
|
|
4819
|
+
function createProxy(config) {
|
|
4820
|
+
const computedContext = config.computed ?? cast({});
|
|
4821
|
+
const initialContext = config.context ?? cast({});
|
|
4822
|
+
const initialTags = config.initial ? config.states?.[config.initial]?.tags : [];
|
|
4823
|
+
const state = proxy({
|
|
4824
|
+
value: config.initial ?? "",
|
|
4825
|
+
previousValue: "",
|
|
4826
|
+
event: cast({}),
|
|
4827
|
+
previousEvent: cast({}),
|
|
4828
|
+
context: proxyWithComputed(initialContext, computedContext),
|
|
4829
|
+
done: false,
|
|
4830
|
+
tags: initialTags ?? [],
|
|
4831
|
+
hasTag(tag) {
|
|
4832
|
+
return this.tags.includes(tag);
|
|
4833
|
+
},
|
|
4834
|
+
matches(...value) {
|
|
4835
|
+
return value.includes(this.value);
|
|
4836
|
+
},
|
|
4837
|
+
can(event) {
|
|
4838
|
+
return cast(this).nextEvents.includes(event);
|
|
4839
|
+
},
|
|
4840
|
+
get nextEvents() {
|
|
4841
|
+
const stateEvents = config.states?.[this.value]?.["on"] ?? {};
|
|
4842
|
+
const globalEvents = config?.on ?? {};
|
|
4843
|
+
return Object.keys({ ...stateEvents, ...globalEvents });
|
|
4844
|
+
},
|
|
4845
|
+
get changed() {
|
|
4846
|
+
if (this.event.value === "machine.init" /* Init */ || !this.previousValue) return false;
|
|
4847
|
+
return this.value !== this.previousValue;
|
|
4848
|
+
}
|
|
4849
|
+
});
|
|
4850
|
+
return cast(state);
|
|
4851
|
+
}
|
|
4852
|
+
|
|
4853
|
+
// src/delay-utils.ts
|
|
4854
|
+
function determineDelayFn(delay, delaysMap) {
|
|
4855
|
+
return (context, event) => {
|
|
4856
|
+
if (isNumber(delay)) return delay;
|
|
4857
|
+
if (isFunction(delay)) {
|
|
4858
|
+
return delay(context, event);
|
|
4859
|
+
}
|
|
4860
|
+
if (isString(delay)) {
|
|
4861
|
+
const value = Number.parseFloat(delay);
|
|
4862
|
+
if (!Number.isNaN(value)) {
|
|
4863
|
+
return value;
|
|
4864
|
+
}
|
|
4865
|
+
if (delaysMap) {
|
|
4866
|
+
const valueOrFn = delaysMap?.[delay];
|
|
4867
|
+
invariant(
|
|
4868
|
+
valueOrFn == null,
|
|
4869
|
+
`[@zag-js/core > determine-delay] Cannot determine delay for \`${delay}\`. It doesn't exist in \`options.delays\``
|
|
4870
|
+
);
|
|
4871
|
+
return isFunction(valueOrFn) ? valueOrFn(context, event) : valueOrFn;
|
|
4872
|
+
}
|
|
4873
|
+
}
|
|
4874
|
+
};
|
|
4875
|
+
}
|
|
4876
|
+
|
|
4877
|
+
// src/transition-utils.ts
|
|
4878
|
+
function toTarget(target) {
|
|
4879
|
+
return isString(target) ? { target } : target;
|
|
4880
|
+
}
|
|
4881
|
+
function determineTransitionFn(transitions, guardMap) {
|
|
4882
|
+
return (context, event, meta) => {
|
|
4883
|
+
return toArray(transitions).map(toTarget).find((transition) => {
|
|
4884
|
+
const determineGuard = determineGuardFn(transition.guard, guardMap);
|
|
4885
|
+
const guard = determineGuard(context, event, meta);
|
|
4886
|
+
return guard ?? transition.target ?? transition.actions;
|
|
4887
|
+
});
|
|
4888
|
+
};
|
|
4889
|
+
}
|
|
4890
|
+
|
|
4891
|
+
// src/machine.ts
|
|
4892
|
+
var Machine = class {
|
|
4893
|
+
// Let's get started!
|
|
4894
|
+
constructor(config, options) {
|
|
4895
|
+
__publicField(this, "status", "Not Started" /* NotStarted */);
|
|
4896
|
+
__publicField(this, "state");
|
|
4897
|
+
__publicField(this, "initialState");
|
|
4898
|
+
__publicField(this, "initialContext");
|
|
4899
|
+
__publicField(this, "id");
|
|
4900
|
+
__publicField(this, "type", "machine" /* Machine */);
|
|
4901
|
+
// Cleanup function map (per state)
|
|
4902
|
+
__publicField(this, "activityEvents", /* @__PURE__ */ new Map());
|
|
4903
|
+
__publicField(this, "delayedEvents", /* @__PURE__ */ new Map());
|
|
4904
|
+
// state update listeners the user can opt-in for
|
|
4905
|
+
__publicField(this, "stateListeners", /* @__PURE__ */ new Set());
|
|
4906
|
+
__publicField(this, "doneListeners", /* @__PURE__ */ new Set());
|
|
4907
|
+
__publicField(this, "contextWatchers", /* @__PURE__ */ new Set());
|
|
4908
|
+
// Cleanup functions (for `subscribe`)
|
|
4909
|
+
__publicField(this, "removeStateListener", noop);
|
|
4910
|
+
// For Parent <==> Spawned Actor relationship
|
|
4911
|
+
__publicField(this, "parent");
|
|
4912
|
+
__publicField(this, "children", /* @__PURE__ */ new Map());
|
|
4913
|
+
// A map of guard, action, delay implementations
|
|
4914
|
+
__publicField(this, "guardMap");
|
|
4915
|
+
__publicField(this, "actionMap");
|
|
4916
|
+
__publicField(this, "delayMap");
|
|
4917
|
+
__publicField(this, "activityMap");
|
|
4918
|
+
__publicField(this, "sync");
|
|
4919
|
+
__publicField(this, "options");
|
|
4920
|
+
__publicField(this, "config");
|
|
4921
|
+
__publicField(this, "_created", () => {
|
|
4922
|
+
const event = toEvent("machine.created" /* Created */);
|
|
4923
|
+
this.executeActions(this.config?.created, event);
|
|
4924
|
+
});
|
|
4925
|
+
// Starts the interpreted machine.
|
|
4926
|
+
__publicField(this, "start", (init) => {
|
|
4927
|
+
this.state.value = "";
|
|
4928
|
+
this.state.tags = [];
|
|
4929
|
+
if (this.status === "Running" /* Running */) {
|
|
4930
|
+
return this;
|
|
4931
|
+
}
|
|
4932
|
+
this.status = "Running" /* Running */;
|
|
4933
|
+
this.removeStateListener = subscribe(
|
|
4934
|
+
this.state,
|
|
4935
|
+
() => {
|
|
4936
|
+
this.stateListeners.forEach((listener) => {
|
|
4937
|
+
listener(this.stateSnapshot);
|
|
4938
|
+
});
|
|
4939
|
+
},
|
|
4940
|
+
this.sync
|
|
4941
|
+
);
|
|
4942
|
+
this.setupContextWatchers();
|
|
4943
|
+
this.executeActivities(toEvent("machine.start" /* Start */), toArray(this.config.activities), "machine.start" /* Start */);
|
|
4944
|
+
this.executeActions(this.config.entry, toEvent("machine.start" /* Start */));
|
|
4945
|
+
const event = toEvent("machine.init" /* Init */);
|
|
4946
|
+
const target = isObject(init) ? init.value : init;
|
|
4947
|
+
const context = isObject(init) ? init.context : void 0;
|
|
4948
|
+
if (context) {
|
|
4949
|
+
this.setContext(context);
|
|
4950
|
+
}
|
|
4951
|
+
const transition = {
|
|
4952
|
+
target: target ?? this.config.initial
|
|
4953
|
+
};
|
|
4954
|
+
const next = this.getNextStateInfo(transition, event);
|
|
4955
|
+
this.initialState = next;
|
|
4956
|
+
this.performStateChangeEffects(this.state.value, next, event);
|
|
4957
|
+
return this;
|
|
4958
|
+
});
|
|
4959
|
+
__publicField(this, "setupContextWatchers", () => {
|
|
4960
|
+
const { watch } = this.config;
|
|
4961
|
+
if (!watch) return;
|
|
4962
|
+
let prev = snapshot(this.state.context);
|
|
4963
|
+
const cleanup = subscribe(this.state.context, () => {
|
|
4964
|
+
const next = snapshot(this.state.context);
|
|
4965
|
+
for (const [key, fn] of Object.entries(watch)) {
|
|
4966
|
+
const isEqual = this.options.compareFns?.[key] ?? Object.is;
|
|
4967
|
+
if (isEqual(prev[key], next[key])) continue;
|
|
4968
|
+
this.executeActions(fn, this.state.event);
|
|
4969
|
+
}
|
|
4970
|
+
prev = next;
|
|
4971
|
+
});
|
|
4972
|
+
this.contextWatchers.add(cleanup);
|
|
4973
|
+
});
|
|
4974
|
+
// Stops the interpreted machine
|
|
4975
|
+
__publicField(this, "stop", () => {
|
|
4976
|
+
if (this.status === "Stopped" /* Stopped */) return;
|
|
4977
|
+
this.performExitEffects(this.state.value, toEvent("machine.stop" /* Stop */));
|
|
4978
|
+
this.executeActions(this.config.exit, toEvent("machine.stop" /* Stop */));
|
|
4979
|
+
this.setState("");
|
|
4980
|
+
this.setEvent("machine.stop" /* Stop */);
|
|
4981
|
+
this.stopStateListeners();
|
|
4982
|
+
this.stopChildren();
|
|
4983
|
+
this.stopActivities();
|
|
4984
|
+
this.stopDelayedEvents();
|
|
4985
|
+
this.stopContextWatchers();
|
|
4986
|
+
this.status = "Stopped" /* Stopped */;
|
|
4987
|
+
return this;
|
|
4988
|
+
});
|
|
4989
|
+
__publicField(this, "stopStateListeners", () => {
|
|
4990
|
+
this.removeStateListener();
|
|
4991
|
+
this.stateListeners.clear();
|
|
4992
|
+
});
|
|
4993
|
+
__publicField(this, "stopContextWatchers", () => {
|
|
4994
|
+
this.contextWatchers.forEach((fn) => fn());
|
|
4995
|
+
this.contextWatchers.clear();
|
|
4996
|
+
});
|
|
4997
|
+
__publicField(this, "stopDelayedEvents", () => {
|
|
4998
|
+
this.delayedEvents.forEach((state) => {
|
|
4999
|
+
state.forEach((stop) => stop());
|
|
5000
|
+
});
|
|
5001
|
+
this.delayedEvents.clear();
|
|
5002
|
+
});
|
|
5003
|
+
// Cleanup running activities (e.g `setInterval`, invoked callbacks, promises)
|
|
5004
|
+
__publicField(this, "stopActivities", (state) => {
|
|
5005
|
+
if (state) {
|
|
5006
|
+
this.activityEvents.get(state)?.forEach((stop) => stop());
|
|
5007
|
+
this.activityEvents.get(state)?.clear();
|
|
5008
|
+
this.activityEvents.delete(state);
|
|
5009
|
+
} else {
|
|
5010
|
+
this.activityEvents.forEach((state2) => {
|
|
5011
|
+
state2.forEach((stop) => stop());
|
|
5012
|
+
state2.clear();
|
|
5013
|
+
});
|
|
5014
|
+
this.activityEvents.clear();
|
|
5015
|
+
}
|
|
5016
|
+
});
|
|
5017
|
+
/**
|
|
5018
|
+
* Function to send event to spawned child machine or actor
|
|
5019
|
+
*/
|
|
5020
|
+
__publicField(this, "sendChild", (evt, to) => {
|
|
5021
|
+
const event = toEvent(evt);
|
|
5022
|
+
const id = runIfFn(to, this.contextSnapshot);
|
|
5023
|
+
const child = this.children.get(id);
|
|
5024
|
+
if (!child) {
|
|
5025
|
+
invariant(`[@zag-js/core] Cannot send '${event.type}' event to unknown child`);
|
|
5026
|
+
}
|
|
5027
|
+
child.send(event);
|
|
5028
|
+
});
|
|
5029
|
+
/**
|
|
5030
|
+
* Function to stop a running child machine or actor
|
|
5031
|
+
*/
|
|
5032
|
+
__publicField(this, "stopChild", (id) => {
|
|
5033
|
+
if (!this.children.has(id)) {
|
|
5034
|
+
invariant(`[@zag-js/core > stop-child] Cannot stop unknown child ${id}`);
|
|
5035
|
+
}
|
|
5036
|
+
this.children.get(id).stop();
|
|
5037
|
+
this.children.delete(id);
|
|
5038
|
+
});
|
|
5039
|
+
__publicField(this, "removeChild", (id) => {
|
|
5040
|
+
this.children.delete(id);
|
|
5041
|
+
});
|
|
5042
|
+
// Stop and delete spawned actors
|
|
5043
|
+
__publicField(this, "stopChildren", () => {
|
|
5044
|
+
this.children.forEach((child) => child.stop());
|
|
5045
|
+
this.children.clear();
|
|
5046
|
+
});
|
|
5047
|
+
__publicField(this, "setParent", (parent) => {
|
|
5048
|
+
this.parent = parent;
|
|
5049
|
+
});
|
|
5050
|
+
__publicField(this, "spawn", (src, id) => {
|
|
5051
|
+
const actor = runIfFn(src);
|
|
5052
|
+
if (id) actor.id = id;
|
|
5053
|
+
actor.type = "machine.actor" /* Actor */;
|
|
5054
|
+
actor.setParent(this);
|
|
5055
|
+
this.children.set(actor.id, cast(actor));
|
|
5056
|
+
actor.onDone(() => {
|
|
5057
|
+
this.removeChild(actor.id);
|
|
5058
|
+
}).start();
|
|
5059
|
+
return cast(ref(actor));
|
|
5060
|
+
});
|
|
5061
|
+
__publicField(this, "stopActivity", (key) => {
|
|
5062
|
+
if (!this.state.value) return;
|
|
5063
|
+
const cleanups = this.activityEvents.get(this.state.value);
|
|
5064
|
+
cleanups?.get(key)?.();
|
|
5065
|
+
cleanups?.delete(key);
|
|
5066
|
+
});
|
|
5067
|
+
__publicField(this, "addActivityCleanup", (state, key, cleanup) => {
|
|
5068
|
+
if (!state) return;
|
|
5069
|
+
if (!this.activityEvents.has(state)) {
|
|
5070
|
+
this.activityEvents.set(state, /* @__PURE__ */ new Map([[key, cleanup]]));
|
|
5071
|
+
} else {
|
|
5072
|
+
this.activityEvents.get(state)?.set(key, cleanup);
|
|
5073
|
+
}
|
|
5074
|
+
});
|
|
5075
|
+
__publicField(this, "setState", (target) => {
|
|
5076
|
+
this.state.previousValue = this.state.value;
|
|
5077
|
+
this.state.value = target;
|
|
5078
|
+
const stateNode = this.getStateNode(target);
|
|
5079
|
+
if (target == null) {
|
|
5080
|
+
clear(this.state.tags);
|
|
5081
|
+
} else {
|
|
5082
|
+
this.state.tags = toArray(stateNode?.tags);
|
|
5083
|
+
}
|
|
5084
|
+
});
|
|
5085
|
+
/**
|
|
5086
|
+
* To used within side effects for React or Vue to update context
|
|
5087
|
+
*/
|
|
5088
|
+
__publicField(this, "setContext", (context) => {
|
|
5089
|
+
if (!context) return;
|
|
5090
|
+
deepMerge(this.state.context, compact$1(context));
|
|
5091
|
+
});
|
|
5092
|
+
__publicField(this, "setOptions", (options) => {
|
|
5093
|
+
const opts = compact$1(options);
|
|
5094
|
+
this.actionMap = { ...this.actionMap, ...opts.actions };
|
|
5095
|
+
this.delayMap = { ...this.delayMap, ...opts.delays };
|
|
5096
|
+
this.activityMap = { ...this.activityMap, ...opts.activities };
|
|
5097
|
+
this.guardMap = { ...this.guardMap, ...opts.guards };
|
|
5098
|
+
});
|
|
5099
|
+
__publicField(this, "getStateNode", (state) => {
|
|
5100
|
+
if (!state) return;
|
|
5101
|
+
return this.config.states?.[state];
|
|
5102
|
+
});
|
|
5103
|
+
__publicField(this, "getNextStateInfo", (transitions, event) => {
|
|
5104
|
+
const transition = this.determineTransition(transitions, event);
|
|
5105
|
+
const isTargetless = !transition?.target;
|
|
5106
|
+
const target = transition?.target ?? this.state.value;
|
|
5107
|
+
const changed = this.state.value !== target;
|
|
5108
|
+
const stateNode = this.getStateNode(target);
|
|
5109
|
+
const reenter = !isTargetless && !changed && !transition?.internal;
|
|
5110
|
+
const info = {
|
|
5111
|
+
reenter,
|
|
5112
|
+
transition,
|
|
5113
|
+
stateNode,
|
|
5114
|
+
target,
|
|
5115
|
+
changed
|
|
5116
|
+
};
|
|
5117
|
+
this.log("NextState:", `[${event.type}]`, this.state.value, "---->", info.target);
|
|
5118
|
+
return info;
|
|
5119
|
+
});
|
|
5120
|
+
__publicField(this, "getAfterActions", (transition, delay) => {
|
|
5121
|
+
let id;
|
|
5122
|
+
return {
|
|
5123
|
+
entry: () => {
|
|
5124
|
+
id = globalThis.setTimeout(() => {
|
|
5125
|
+
const next = this.getNextStateInfo(transition, this.state.event);
|
|
5126
|
+
this.performStateChangeEffects(this.state.value, next, this.state.event);
|
|
5127
|
+
}, delay);
|
|
5128
|
+
},
|
|
5129
|
+
exit: () => {
|
|
5130
|
+
globalThis.clearTimeout(id);
|
|
5131
|
+
}
|
|
5132
|
+
};
|
|
5133
|
+
});
|
|
5134
|
+
/**
|
|
5135
|
+
* All `after` events leverage `setTimeout` and `clearTimeout`,
|
|
5136
|
+
* we invoke the `clearTimeout` on exit and `setTimeout` on entry.
|
|
5137
|
+
*
|
|
5138
|
+
* To achieve this, we split the `after` defintion into `entry` and `exit`
|
|
5139
|
+
* functions and append them to the state's `entry` and `exit` actions
|
|
5140
|
+
*/
|
|
5141
|
+
__publicField(this, "getDelayedEventActions", (state) => {
|
|
5142
|
+
const stateNode = this.getStateNode(state);
|
|
5143
|
+
const event = this.state.event;
|
|
5144
|
+
if (!stateNode || !stateNode.after) return;
|
|
5145
|
+
const entries = [];
|
|
5146
|
+
const exits = [];
|
|
5147
|
+
if (isArray(stateNode.after)) {
|
|
5148
|
+
const transition = this.determineTransition(stateNode.after, event);
|
|
5149
|
+
if (!transition) return;
|
|
5150
|
+
if (!hasProp(transition, "delay")) {
|
|
5151
|
+
throw new Error(`[@zag-js/core > after] Delay is required for after transition: ${JSON.stringify(transition)}`);
|
|
5152
|
+
}
|
|
5153
|
+
const determineDelay = determineDelayFn(transition.delay, this.delayMap);
|
|
5154
|
+
const __delay = determineDelay(this.contextSnapshot, event);
|
|
5155
|
+
const actions = this.getAfterActions(transition, __delay);
|
|
5156
|
+
entries.push(actions.entry);
|
|
5157
|
+
exits.push(actions.exit);
|
|
5158
|
+
return { entries, exits };
|
|
5159
|
+
}
|
|
5160
|
+
if (isObject(stateNode.after)) {
|
|
5161
|
+
for (const delay in stateNode.after) {
|
|
5162
|
+
const transition = stateNode.after[delay];
|
|
5163
|
+
const determineDelay = determineDelayFn(delay, this.delayMap);
|
|
5164
|
+
const __delay = determineDelay(this.contextSnapshot, event);
|
|
5165
|
+
const actions = this.getAfterActions(transition, __delay);
|
|
5166
|
+
entries.push(actions.entry);
|
|
5167
|
+
exits.push(actions.exit);
|
|
5168
|
+
}
|
|
5169
|
+
}
|
|
5170
|
+
return { entries, exits };
|
|
5171
|
+
});
|
|
5172
|
+
/**
|
|
5173
|
+
* Function to executes defined actions. It can accept actions as string
|
|
5174
|
+
* (referencing `options.actions`) or actual functions.
|
|
5175
|
+
*/
|
|
5176
|
+
__publicField(this, "executeActions", (actions, event) => {
|
|
5177
|
+
const pickedActions = determineActionsFn(actions, this.guardMap)(this.contextSnapshot, event, this.guardMeta);
|
|
5178
|
+
for (const action of toArray(pickedActions)) {
|
|
5179
|
+
const fn = isString(action) ? this.actionMap?.[action] : action;
|
|
5180
|
+
warn(
|
|
5181
|
+
isString(action) && !fn,
|
|
5182
|
+
`[@zag-js/core > execute-actions] No implementation found for action: \`${action}\``
|
|
5183
|
+
);
|
|
5184
|
+
fn?.(this.state.context, event, this.meta);
|
|
5185
|
+
}
|
|
5186
|
+
});
|
|
5187
|
+
/**
|
|
5188
|
+
* Function to execute running activities and registers
|
|
5189
|
+
* their cleanup function internally (to be called later on when we exit the state)
|
|
5190
|
+
*/
|
|
5191
|
+
__publicField(this, "executeActivities", (event, activities, state) => {
|
|
5192
|
+
for (const activity of activities) {
|
|
5193
|
+
const fn = isString(activity) ? this.activityMap?.[activity] : activity;
|
|
5194
|
+
if (!fn) {
|
|
5195
|
+
warn(`[@zag-js/core > execute-activity] No implementation found for activity: \`${activity}\``);
|
|
5196
|
+
continue;
|
|
5197
|
+
}
|
|
5198
|
+
const cleanup = fn(this.state.context, event, this.meta);
|
|
5199
|
+
if (cleanup) {
|
|
5200
|
+
const key = isString(activity) ? activity : activity.name || uuid();
|
|
5201
|
+
this.addActivityCleanup(state ?? this.state.value, key, cleanup);
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
});
|
|
5205
|
+
/**
|
|
5206
|
+
* Normalizes the `every` definition to transition. `every` can be:
|
|
5207
|
+
* - An array of possible actions to run (we need to pick the first match based on guard)
|
|
5208
|
+
* - An object of intervals and actions
|
|
5209
|
+
*/
|
|
5210
|
+
__publicField(this, "createEveryActivities", (every, callbackfn) => {
|
|
5211
|
+
if (!every) return;
|
|
5212
|
+
if (isArray(every)) {
|
|
5213
|
+
const picked = toArray(every).find((transition) => {
|
|
5214
|
+
const delayOrFn = transition.delay;
|
|
5215
|
+
const determineDelay2 = determineDelayFn(delayOrFn, this.delayMap);
|
|
5216
|
+
const delay2 = determineDelay2(this.contextSnapshot, this.state.event);
|
|
5217
|
+
const determineGuard = determineGuardFn(transition.guard, this.guardMap);
|
|
5218
|
+
const guard = determineGuard(this.contextSnapshot, this.state.event, this.guardMeta);
|
|
5219
|
+
return guard ?? delay2 != null;
|
|
5220
|
+
});
|
|
5221
|
+
if (!picked) return;
|
|
5222
|
+
const determineDelay = determineDelayFn(picked.delay, this.delayMap);
|
|
5223
|
+
const delay = determineDelay(this.contextSnapshot, this.state.event);
|
|
5224
|
+
const activity = () => {
|
|
5225
|
+
const id = globalThis.setInterval(() => {
|
|
5226
|
+
this.executeActions(picked.actions, this.state.event);
|
|
5227
|
+
}, delay);
|
|
5228
|
+
return () => {
|
|
5229
|
+
globalThis.clearInterval(id);
|
|
5230
|
+
};
|
|
5231
|
+
};
|
|
5232
|
+
callbackfn(activity);
|
|
5233
|
+
} else {
|
|
5234
|
+
for (const interval in every) {
|
|
5235
|
+
const actions = every?.[interval];
|
|
5236
|
+
const determineDelay = determineDelayFn(interval, this.delayMap);
|
|
5237
|
+
const delay = determineDelay(this.contextSnapshot, this.state.event);
|
|
5238
|
+
const activity = () => {
|
|
5239
|
+
const id = globalThis.setInterval(() => {
|
|
5240
|
+
this.executeActions(actions, this.state.event);
|
|
5241
|
+
}, delay);
|
|
5242
|
+
return () => {
|
|
5243
|
+
globalThis.clearInterval(id);
|
|
5244
|
+
};
|
|
5245
|
+
};
|
|
5246
|
+
callbackfn(activity);
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
});
|
|
5250
|
+
__publicField(this, "setEvent", (event) => {
|
|
5251
|
+
this.state.previousEvent = this.state.event;
|
|
5252
|
+
this.state.event = ref(toEvent(event));
|
|
5253
|
+
});
|
|
5254
|
+
__publicField(this, "performExitEffects", (current, event) => {
|
|
5255
|
+
const currentState = this.state.value;
|
|
5256
|
+
if (currentState === "") return;
|
|
5257
|
+
const stateNode = current ? this.getStateNode(current) : void 0;
|
|
5258
|
+
this.stopActivities(currentState);
|
|
5259
|
+
const _exit = determineActionsFn(stateNode?.exit, this.guardMap)(this.contextSnapshot, event, this.guardMeta);
|
|
5260
|
+
const exitActions = toArray(_exit);
|
|
5261
|
+
const afterExitActions = this.delayedEvents.get(currentState);
|
|
5262
|
+
if (afterExitActions) {
|
|
5263
|
+
exitActions.push(...afterExitActions);
|
|
5264
|
+
}
|
|
5265
|
+
this.executeActions(exitActions, event);
|
|
5266
|
+
});
|
|
5267
|
+
__publicField(this, "performEntryEffects", (next, event) => {
|
|
5268
|
+
const stateNode = this.getStateNode(next);
|
|
5269
|
+
const activities = toArray(stateNode?.activities);
|
|
5270
|
+
this.createEveryActivities(stateNode?.every, (activity) => {
|
|
5271
|
+
activities.unshift(activity);
|
|
5272
|
+
});
|
|
5273
|
+
if (activities.length > 0) {
|
|
5274
|
+
this.executeActivities(event, activities);
|
|
5275
|
+
}
|
|
5276
|
+
const pickedActions = determineActionsFn(stateNode?.entry, this.guardMap)(
|
|
5277
|
+
this.contextSnapshot,
|
|
5278
|
+
event,
|
|
5279
|
+
this.guardMeta
|
|
5280
|
+
);
|
|
5281
|
+
const entryActions = toArray(pickedActions);
|
|
5282
|
+
const afterActions = this.getDelayedEventActions(next);
|
|
5283
|
+
if (stateNode?.after && afterActions) {
|
|
5284
|
+
this.delayedEvents.set(next, afterActions?.exits);
|
|
5285
|
+
entryActions.push(...afterActions.entries);
|
|
5286
|
+
}
|
|
5287
|
+
this.executeActions(entryActions, event);
|
|
5288
|
+
if (stateNode?.type === "final") {
|
|
5289
|
+
this.state.done = true;
|
|
5290
|
+
this.doneListeners.forEach((listener) => {
|
|
5291
|
+
listener(this.stateSnapshot);
|
|
5292
|
+
});
|
|
5293
|
+
this.stop();
|
|
5294
|
+
}
|
|
5295
|
+
});
|
|
5296
|
+
__publicField(this, "performTransitionEffects", (transitions, event) => {
|
|
5297
|
+
const transition = this.determineTransition(transitions, event);
|
|
5298
|
+
this.executeActions(transition?.actions, event);
|
|
5299
|
+
});
|
|
5300
|
+
/**
|
|
5301
|
+
* Performs all the requires side-effects or reactions when
|
|
5302
|
+
* we move from state A => state B.
|
|
5303
|
+
*
|
|
5304
|
+
* The Effect order:
|
|
5305
|
+
* Exit actions (current state) => Transition actions => Go to state => Entry actions (next state)
|
|
5306
|
+
*/
|
|
5307
|
+
__publicField(this, "performStateChangeEffects", (current, next, event) => {
|
|
5308
|
+
this.setEvent(event);
|
|
5309
|
+
const changed = next.changed || next.reenter;
|
|
5310
|
+
if (changed) {
|
|
5311
|
+
this.performExitEffects(current, event);
|
|
5312
|
+
}
|
|
5313
|
+
this.performTransitionEffects(next.transition, event);
|
|
5314
|
+
this.setState(next.target);
|
|
5315
|
+
if (changed) {
|
|
5316
|
+
this.performEntryEffects(next.target, event);
|
|
5317
|
+
}
|
|
5318
|
+
});
|
|
5319
|
+
__publicField(this, "determineTransition", (transition, event) => {
|
|
5320
|
+
const fn = determineTransitionFn(transition, this.guardMap);
|
|
5321
|
+
return fn?.(this.contextSnapshot, event, this.guardMeta);
|
|
5322
|
+
});
|
|
5323
|
+
/**
|
|
5324
|
+
* Function to send event to parent machine from spawned child
|
|
5325
|
+
*/
|
|
5326
|
+
__publicField(this, "sendParent", (evt) => {
|
|
5327
|
+
if (!this.parent) {
|
|
5328
|
+
invariant("[@zag-js/core > send-parent] Cannot send event to an unknown parent");
|
|
5329
|
+
}
|
|
5330
|
+
const event = toEvent(evt);
|
|
5331
|
+
this.parent?.send(event);
|
|
5332
|
+
});
|
|
5333
|
+
__publicField(this, "log", (...args) => {
|
|
5334
|
+
if (isDev() && this.options.debug) {
|
|
5335
|
+
console.log(...args);
|
|
5336
|
+
}
|
|
5337
|
+
});
|
|
5338
|
+
/**
|
|
5339
|
+
* Function to send an event to current machine
|
|
5340
|
+
*/
|
|
5341
|
+
__publicField(this, "send", (evt) => {
|
|
5342
|
+
const event = toEvent(evt);
|
|
5343
|
+
this.transition(this.state.value, event);
|
|
5344
|
+
});
|
|
5345
|
+
__publicField(this, "transition", (state, evt) => {
|
|
5346
|
+
const stateNode = isString(state) ? this.getStateNode(state) : state?.stateNode;
|
|
5347
|
+
const event = toEvent(evt);
|
|
5348
|
+
if (!stateNode && !this.config.on) {
|
|
5349
|
+
const msg = this.status === "Stopped" /* Stopped */ ? "[@zag-js/core > transition] Cannot transition a stopped machine" : `[@zag-js/core > transition] State does not have a definition for \`state\`: ${state}, \`event\`: ${event.type}`;
|
|
5350
|
+
warn(msg);
|
|
5351
|
+
return;
|
|
5352
|
+
}
|
|
5353
|
+
const transitions = stateNode?.on?.[event.type] ?? this.config.on?.[event.type];
|
|
5354
|
+
const next = this.getNextStateInfo(transitions, event);
|
|
5355
|
+
this.performStateChangeEffects(this.state.value, next, event);
|
|
5356
|
+
return next.stateNode;
|
|
5357
|
+
});
|
|
5358
|
+
__publicField(this, "subscribe", (listener) => {
|
|
5359
|
+
this.stateListeners.add(listener);
|
|
5360
|
+
if (this.status === "Running" /* Running */) {
|
|
5361
|
+
listener(this.stateSnapshot);
|
|
5362
|
+
}
|
|
5363
|
+
return () => {
|
|
5364
|
+
this.stateListeners.delete(listener);
|
|
5365
|
+
};
|
|
5366
|
+
});
|
|
5367
|
+
__publicField(this, "onDone", (listener) => {
|
|
5368
|
+
this.doneListeners.add(listener);
|
|
5369
|
+
return this;
|
|
5370
|
+
});
|
|
5371
|
+
__publicField(this, "onTransition", (listener) => {
|
|
5372
|
+
this.stateListeners.add(listener);
|
|
5373
|
+
if (this.status === "Running" /* Running */) {
|
|
5374
|
+
listener(this.stateSnapshot);
|
|
5375
|
+
}
|
|
5376
|
+
return this;
|
|
5377
|
+
});
|
|
5378
|
+
this.config = structuredClone(config);
|
|
5379
|
+
this.options = structuredClone(options ?? {});
|
|
5380
|
+
this.id = this.config.id ?? `machine-${uuid()}`;
|
|
5381
|
+
this.guardMap = this.options?.guards ?? {};
|
|
5382
|
+
this.actionMap = this.options?.actions ?? {};
|
|
5383
|
+
this.delayMap = this.options?.delays ?? {};
|
|
5384
|
+
this.activityMap = this.options?.activities ?? {};
|
|
5385
|
+
this.sync = this.options?.sync ?? false;
|
|
5386
|
+
this.state = createProxy(this.config);
|
|
5387
|
+
this.initialContext = snapshot(this.state.context);
|
|
5388
|
+
}
|
|
5389
|
+
// immutable state value
|
|
5390
|
+
get stateSnapshot() {
|
|
5391
|
+
return cast(snapshot(this.state));
|
|
5392
|
+
}
|
|
5393
|
+
getState() {
|
|
5394
|
+
return this.stateSnapshot;
|
|
5395
|
+
}
|
|
5396
|
+
// immutable context value
|
|
5397
|
+
get contextSnapshot() {
|
|
5398
|
+
return this.stateSnapshot.context;
|
|
5399
|
+
}
|
|
5400
|
+
/**
|
|
5401
|
+
* A reference to the instance methods of the machine.
|
|
5402
|
+
* Useful when spawning child machines and managing the communication between them.
|
|
5403
|
+
*/
|
|
5404
|
+
get self() {
|
|
5405
|
+
const self = this;
|
|
5406
|
+
return {
|
|
5407
|
+
id: this.id,
|
|
5408
|
+
send: this.send.bind(this),
|
|
5409
|
+
sendParent: this.sendParent.bind(this),
|
|
5410
|
+
sendChild: this.sendChild.bind(this),
|
|
5411
|
+
stop: this.stop.bind(this),
|
|
5412
|
+
stopChild: this.stopChild.bind(this),
|
|
5413
|
+
spawn: this.spawn.bind(this),
|
|
5414
|
+
stopActivity: this.stopActivity.bind(this),
|
|
5415
|
+
get state() {
|
|
5416
|
+
return self.stateSnapshot;
|
|
5417
|
+
},
|
|
5418
|
+
get initialContext() {
|
|
5419
|
+
return self.initialContext;
|
|
5420
|
+
},
|
|
5421
|
+
get initialState() {
|
|
5422
|
+
return self.initialState?.target ?? "";
|
|
5423
|
+
}
|
|
5424
|
+
};
|
|
5425
|
+
}
|
|
5426
|
+
get meta() {
|
|
5427
|
+
return {
|
|
5428
|
+
state: this.stateSnapshot,
|
|
5429
|
+
guards: this.guardMap,
|
|
5430
|
+
send: this.send.bind(this),
|
|
5431
|
+
self: this.self,
|
|
5432
|
+
initialContext: this.initialContext,
|
|
5433
|
+
initialState: this.initialState?.target ?? "",
|
|
5434
|
+
getState: () => this.stateSnapshot,
|
|
5435
|
+
getAction: (key) => this.actionMap[key],
|
|
5436
|
+
getGuard: (key) => this.guardMap[key]
|
|
5437
|
+
};
|
|
5438
|
+
}
|
|
5439
|
+
get guardMeta() {
|
|
5440
|
+
return {
|
|
5441
|
+
state: this.stateSnapshot
|
|
5442
|
+
};
|
|
5443
|
+
}
|
|
5444
|
+
get [Symbol.toStringTag]() {
|
|
5445
|
+
return "Machine";
|
|
5446
|
+
}
|
|
5447
|
+
};
|
|
5448
|
+
var createMachine = (config, options) => new Machine(config, options);
|
|
5449
|
+
|
|
5450
|
+
// src/array.ts
|
|
5451
|
+
|
|
5452
|
+
// src/object.ts
|
|
5453
|
+
function compact(obj) {
|
|
5454
|
+
if (!isPlainObject(obj) || obj === void 0) {
|
|
5455
|
+
return obj;
|
|
5456
|
+
}
|
|
5457
|
+
const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
|
|
5458
|
+
const filtered = {};
|
|
5459
|
+
for (const key of keys) {
|
|
5460
|
+
const value = obj[key];
|
|
5461
|
+
if (value !== void 0) {
|
|
5462
|
+
filtered[key] = compact(value);
|
|
5463
|
+
}
|
|
5464
|
+
}
|
|
5465
|
+
return filtered;
|
|
5466
|
+
}
|
|
5467
|
+
var isPlainObject = (value) => {
|
|
5468
|
+
return value && typeof value === "object" && value.constructor === Object;
|
|
5469
|
+
};
|
|
5470
|
+
|
|
5471
|
+
function $(e,t,u,x=h=>h){return e*x(.5-t*(.5-u))}function se(e){return [-e[0],-e[1]]}function l(e,t){return [e[0]+t[0],e[1]+t[1]]}function a(e,t){return [e[0]-t[0],e[1]-t[1]]}function b(e,t){return [e[0]*t,e[1]*t]}function he(e,t){return [e[0]/t,e[1]/t]}function R(e){return [e[1],-e[0]]}function B(e,t){return e[0]*t[0]+e[1]*t[1]}function ue(e,t){return e[0]===t[0]&&e[1]===t[1]}function ge(e){return Math.hypot(e[0],e[1])}function de(e){return e[0]*e[0]+e[1]*e[1]}function A(e,t){return de(a(e,t))}function G(e){return he(e,ge(e))}function ie(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function L(e,t,u){let x=Math.sin(u),h=Math.cos(u),y=e[0]-t[0],n=e[1]-t[1],f=y*h-n*x,d=y*x+n*h;return [f+t[0],d+t[1]]}function K(e,t,u){return l(e,b(a(t,e),u))}function ee(e,t,u){return l(e,b(t,u))}var{min:C,PI:xe}=Math,pe=.275,V=xe+1e-4;function ce(e,t={}){let{size:u=16,smoothing:x=.5,thinning:h=.5,simulatePressure:y=!0,easing:n=r=>r,start:f={},end:d={},last:D=!1}=t,{cap:S=!0,easing:j=r=>r*(2-r)}=f,{cap:q=!0,easing:c=r=>--r*r*r+1}=d;if(e.length===0||u<=0)return [];let p=e[e.length-1].runningLength,g=f.taper===!1?0:f.taper===!0?Math.max(u,p):f.taper,T=d.taper===!1?0:d.taper===!0?Math.max(u,p):d.taper,te=Math.pow(u*x,2),_=[],M=[],H=e.slice(0,10).reduce((r,i)=>{let o=i.pressure;if(y){let s=C(1,i.distance/u),W=C(1,1-s);o=C(1,r+(W-r)*(s*pe));}return (r+o)/2},e[0].pressure),m=$(u,h,e[e.length-1].pressure,n),U,X=e[0].vector,z=e[0].point,F=z,O=z,E=F,J=!1;for(let r=0;r<e.length;r++){let{pressure:i}=e[r],{point:o,vector:s,distance:W,runningLength:I}=e[r];if(r<e.length-1&&p-I<3)continue;if(h){if(y){let v=C(1,W/u),Z=C(1,1-v);i=C(1,H+(Z-H)*(v*pe));}m=$(u,h,i,n);}else m=u/2;U===void 0&&(U=m);let le=I<g?j(I/g):1,fe=p-I<T?c((p-I)/T):1;m=Math.max(.01,m*Math.min(le,fe));let re=(r<e.length-1?e[r+1]:e[r]).vector,Y=r<e.length-1?B(s,re):1,be=B(s,X)<0&&!J,ne=Y!==null&&Y<0;if(be||ne){let v=b(R(X),m);for(let Z=1/13,w=0;w<=1;w+=Z)O=L(a(o,v),o,V*w),_.push(O),E=L(l(o,v),o,V*-w),M.push(E);z=O,F=E,ne&&(J=!0);continue}if(J=!1,r===e.length-1){let v=b(R(s),m);_.push(a(o,v)),M.push(l(o,v));continue}let oe=b(R(K(re,s,Y)),m);O=a(o,oe),(r<=1||A(z,O)>te)&&(_.push(O),z=O),E=l(o,oe),(r<=1||A(F,E)>te)&&(M.push(E),F=E),H=i,X=s;}let P=e[0].point.slice(0,2),k=e.length>1?e[e.length-1].point.slice(0,2):l(e[0].point,[1,1]),Q=[],N=[];if(e.length===1){if(!(g||T)||D){let r=ee(P,G(R(a(P,k))),-(U||m)),i=[];for(let o=1/13,s=o;s<=1;s+=o)i.push(L(r,P,V*2*s));return i}}else {if(!(g||T&&e.length===1))if(S)for(let i=1/13,o=i;o<=1;o+=i){let s=L(M[0],P,V*o);Q.push(s);}else {let i=a(_[0],M[0]),o=b(i,.5),s=b(i,.51);Q.push(a(P,o),a(P,s),l(P,s),l(P,o));}let r=R(se(e[e.length-1].vector));if(T||g&&e.length===1)N.push(k);else if(q){let i=ee(k,r,m);for(let o=1/29,s=o;s<1;s+=o)N.push(L(i,k,V*3*s));}else N.push(l(k,b(r,m)),l(k,b(r,m*.99)),a(k,b(r,m*.99)),a(k,b(r,m)));}return _.concat(N,M.reverse(),Q)}function me(e,t={}){var q;let{streamline:u=.5,size:x=16,last:h=!1}=t;if(e.length===0)return [];let y=.15+(1-u)*.85,n=Array.isArray(e[0])?e:e.map(({x:c,y:p,pressure:g=.5})=>[c,p,g]);if(n.length===2){let c=n[1];n=n.slice(0,-1);for(let p=1;p<5;p++)n.push(K(n[0],c,p/4));}n.length===1&&(n=[...n,[...l(n[0],[1,1]),...n[0].slice(2)]]);let f=[{point:[n[0][0],n[0][1]],pressure:n[0][2]>=0?n[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],d=!1,D=0,S=f[0],j=n.length-1;for(let c=1;c<n.length;c++){let p=h&&c===j?n[c].slice(0,2):K(S.point,n[c],y);if(ue(S.point,p))continue;let g=ie(p,S.point);if(D+=g,c<j&&!d){if(D<x)continue;d=!0;}S={point:p,pressure:n[c][2]>=0?n[c][2]:.5,vector:G(a(S.point,p)),distance:g,runningLength:D},f.push(S);}return f[0].vector=((q=f[1])==null?void 0:q.vector)||[0,0],f}function ae(e,t={}){return ce(me(e,t),t)}var _e=ae;
|
|
5472
|
+
|
|
5473
|
+
// src/signature-pad.anatomy.ts
|
|
5474
|
+
var anatomy = createAnatomy("signature-pad").parts(
|
|
5475
|
+
"root",
|
|
5476
|
+
"control",
|
|
5477
|
+
"segment",
|
|
5478
|
+
"segmentPath",
|
|
5479
|
+
"guide",
|
|
5480
|
+
"clearTrigger",
|
|
5481
|
+
"label"
|
|
5482
|
+
);
|
|
5483
|
+
var parts = anatomy.build();
|
|
5484
|
+
var dom = domQuery.createScope({
|
|
5485
|
+
getRootId: (ctx) => ctx.ids?.root ?? `signature-${ctx.id}`,
|
|
5486
|
+
getControlId: (ctx) => ctx.ids?.control ?? `signature-control-${ctx.id}`,
|
|
5487
|
+
getHiddenInputId: (ctx) => ctx.ids?.hiddenInput ?? `signature-input-${ctx.id}`,
|
|
5488
|
+
getControlEl: (ctx) => dom.getById(ctx, dom.getControlId(ctx)),
|
|
5489
|
+
getSegmentEl: (ctx) => domQuery.query(dom.getControlEl(ctx), "[data-part=segment]"),
|
|
5490
|
+
getHiddenInputEl: (ctx) => dom.getById(ctx, dom.getHiddenInputId(ctx)),
|
|
5491
|
+
getDataUrl: (ctx, options) => {
|
|
5492
|
+
if (ctx.isEmpty) return Promise.resolve("");
|
|
5493
|
+
return domQuery.getDataUrl(dom.getSegmentEl(ctx), options);
|
|
5494
|
+
}
|
|
5495
|
+
});
|
|
5496
|
+
|
|
5497
|
+
// src/signature-pad.connect.ts
|
|
5498
|
+
function connect(state, send, normalize) {
|
|
5499
|
+
const drawing = state.matches("drawing");
|
|
5500
|
+
const empty = state.context.isEmpty;
|
|
5501
|
+
const interactive = state.context.isInteractive;
|
|
5502
|
+
const disabled = !!state.context.disabled;
|
|
5503
|
+
return {
|
|
5504
|
+
empty,
|
|
5505
|
+
drawing,
|
|
5506
|
+
currentPath: state.context.currentPath,
|
|
5507
|
+
paths: state.context.paths,
|
|
5508
|
+
clear() {
|
|
5509
|
+
send({ type: "CLEAR" });
|
|
5510
|
+
},
|
|
5511
|
+
getDataUrl(type, quality) {
|
|
5512
|
+
return dom.getDataUrl(state.context, { type, quality });
|
|
5513
|
+
},
|
|
5514
|
+
getLabelProps() {
|
|
5515
|
+
return normalize.element({
|
|
5516
|
+
...parts.label.attrs,
|
|
5517
|
+
"data-disabled": domQuery.dataAttr(disabled),
|
|
5518
|
+
htmlFor: dom.getControlId(state.context)
|
|
5519
|
+
});
|
|
5520
|
+
},
|
|
5521
|
+
getRootProps() {
|
|
5522
|
+
return normalize.element({
|
|
5523
|
+
...parts.root.attrs,
|
|
5524
|
+
"data-disabled": domQuery.dataAttr(disabled),
|
|
5525
|
+
id: dom.getRootId(state.context)
|
|
5526
|
+
});
|
|
5527
|
+
},
|
|
5528
|
+
getControlProps() {
|
|
5529
|
+
return normalize.element({
|
|
5530
|
+
...parts.control.attrs,
|
|
5531
|
+
tabIndex: disabled ? void 0 : 0,
|
|
5532
|
+
id: dom.getControlId(state.context),
|
|
5533
|
+
"aria-label": "Signature Pad",
|
|
5534
|
+
"aria-roledescription": "signature pad",
|
|
5535
|
+
"aria-disabled": disabled,
|
|
5536
|
+
"data-disabled": domQuery.dataAttr(disabled),
|
|
5537
|
+
onPointerDown(event) {
|
|
5538
|
+
if (!isLeftClick(event)) return;
|
|
5539
|
+
if (isModifierKey(event)) return;
|
|
5540
|
+
if (!interactive) return;
|
|
5541
|
+
const target = domQuery.getEventTarget(event);
|
|
5542
|
+
if (target?.closest("[data-part=clear-trigger]")) return;
|
|
5543
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
5544
|
+
const point = { x: event.clientX, y: event.clientY };
|
|
5545
|
+
const { offset } = getRelativePoint(point, dom.getControlEl(state.context));
|
|
5546
|
+
send({ type: "POINTER_DOWN", point: offset, pressure: event.pressure });
|
|
5547
|
+
},
|
|
5548
|
+
onPointerUp(event) {
|
|
5549
|
+
if (!interactive) return;
|
|
5550
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
5551
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
5552
|
+
}
|
|
5553
|
+
},
|
|
5554
|
+
style: {
|
|
5555
|
+
position: "relative",
|
|
5556
|
+
touchAction: "none",
|
|
5557
|
+
userSelect: "none"
|
|
5558
|
+
}
|
|
5559
|
+
});
|
|
5560
|
+
},
|
|
5561
|
+
getSegmentProps() {
|
|
5562
|
+
return normalize.svg({
|
|
5563
|
+
...parts.segment.attrs,
|
|
5564
|
+
style: {
|
|
5565
|
+
position: "absolute",
|
|
5566
|
+
top: 0,
|
|
5567
|
+
left: 0,
|
|
5568
|
+
width: "100%",
|
|
5569
|
+
height: "100%",
|
|
5570
|
+
pointerEvents: "none",
|
|
5571
|
+
fill: state.context.drawing.fill
|
|
5572
|
+
}
|
|
5573
|
+
});
|
|
5574
|
+
},
|
|
5575
|
+
getSegmentPathProps(props2) {
|
|
5576
|
+
return normalize.path({
|
|
5577
|
+
...parts.segmentPath.attrs,
|
|
5578
|
+
d: props2.path
|
|
5579
|
+
});
|
|
5580
|
+
},
|
|
5581
|
+
getGuideProps() {
|
|
5582
|
+
return normalize.element({
|
|
5583
|
+
...parts.guide.attrs,
|
|
5584
|
+
"data-disabled": domQuery.dataAttr(disabled)
|
|
5585
|
+
});
|
|
5586
|
+
},
|
|
5587
|
+
getClearTriggerProps() {
|
|
5588
|
+
return normalize.button({
|
|
5589
|
+
...parts.clearTrigger.attrs,
|
|
5590
|
+
type: "button",
|
|
5591
|
+
"aria-label": "Clear Signature",
|
|
5592
|
+
hidden: !state.context.paths.length || drawing,
|
|
5593
|
+
disabled,
|
|
5594
|
+
onClick() {
|
|
5595
|
+
send({ type: "CLEAR" });
|
|
5596
|
+
}
|
|
5597
|
+
});
|
|
5598
|
+
},
|
|
5599
|
+
getHiddenInputProps(props2) {
|
|
5600
|
+
return normalize.input({
|
|
5601
|
+
type: "text",
|
|
5602
|
+
hidden: true,
|
|
5603
|
+
disabled,
|
|
5604
|
+
name: state.context.name,
|
|
5605
|
+
value: props2.value
|
|
5606
|
+
});
|
|
5607
|
+
}
|
|
5608
|
+
};
|
|
5609
|
+
}
|
|
5610
|
+
|
|
5611
|
+
// src/get-svg-path.ts
|
|
5612
|
+
var average = (a, b) => (a + b) / 2;
|
|
5613
|
+
function getSvgPathFromStroke(points, closed = true) {
|
|
5614
|
+
const len = points.length;
|
|
5615
|
+
if (len < 4) {
|
|
5616
|
+
return "";
|
|
5617
|
+
}
|
|
5618
|
+
let a = points[0];
|
|
5619
|
+
let b = points[1];
|
|
5620
|
+
const c = points[2];
|
|
5621
|
+
let result = `M${a[0].toFixed(2)},${a[1].toFixed(2)} Q${b[0].toFixed(2)},${b[1].toFixed(2)} ${average(b[0], c[0]).toFixed(2)},${average(
|
|
5622
|
+
b[1],
|
|
5623
|
+
c[1]
|
|
5624
|
+
).toFixed(2)} T`;
|
|
5625
|
+
for (let i = 2, max = len - 1; i < max; i++) {
|
|
5626
|
+
a = points[i];
|
|
5627
|
+
b = points[i + 1];
|
|
5628
|
+
result += `${average(a[0], b[0]).toFixed(2)},${average(a[1], b[1]).toFixed(2)} `;
|
|
5629
|
+
}
|
|
5630
|
+
if (closed) {
|
|
5631
|
+
result += "Z";
|
|
5632
|
+
}
|
|
5633
|
+
return result;
|
|
5634
|
+
}
|
|
5635
|
+
|
|
5636
|
+
// src/signature-pad.machine.ts
|
|
5637
|
+
function machine(userContext) {
|
|
5638
|
+
const ctx = compact(userContext);
|
|
5639
|
+
return createMachine(
|
|
5640
|
+
{
|
|
5641
|
+
id: "signature-pad",
|
|
5642
|
+
initial: "idle",
|
|
5643
|
+
context: {
|
|
5644
|
+
readOnly: false,
|
|
5645
|
+
disabled: false,
|
|
5646
|
+
...ctx,
|
|
5647
|
+
paths: [],
|
|
5648
|
+
currentPoints: [],
|
|
5649
|
+
currentPath: null,
|
|
5650
|
+
drawing: {
|
|
5651
|
+
size: 2,
|
|
5652
|
+
simulatePressure: false,
|
|
5653
|
+
thinning: 0.7,
|
|
5654
|
+
smoothing: 0.4,
|
|
5655
|
+
streamline: 0.6,
|
|
5656
|
+
...ctx.drawing
|
|
5657
|
+
}
|
|
5658
|
+
},
|
|
5659
|
+
computed: {
|
|
5660
|
+
isInteractive: (ctx2) => !(ctx2.disabled || ctx2.readOnly),
|
|
5661
|
+
isEmpty: (ctx2) => ctx2.paths.length === 0
|
|
5662
|
+
},
|
|
5663
|
+
on: {
|
|
5664
|
+
CLEAR: {
|
|
5665
|
+
actions: ["clearPoints", "invokeOnDrawEnd", "focusCanvasEl"]
|
|
5666
|
+
}
|
|
5667
|
+
},
|
|
5668
|
+
states: {
|
|
5669
|
+
idle: {
|
|
5670
|
+
on: {
|
|
5671
|
+
POINTER_DOWN: {
|
|
5672
|
+
target: "drawing",
|
|
5673
|
+
actions: ["addPoint"]
|
|
5674
|
+
}
|
|
5675
|
+
}
|
|
5676
|
+
},
|
|
5677
|
+
drawing: {
|
|
5678
|
+
activities: ["trackPointerMove"],
|
|
5679
|
+
on: {
|
|
5680
|
+
POINTER_MOVE: {
|
|
5681
|
+
actions: ["addPoint", "invokeOnDraw"]
|
|
5682
|
+
},
|
|
5683
|
+
POINTER_UP: {
|
|
5684
|
+
target: "idle",
|
|
5685
|
+
actions: ["endStroke", "invokeOnDrawEnd"]
|
|
5686
|
+
}
|
|
5687
|
+
}
|
|
5688
|
+
}
|
|
5689
|
+
}
|
|
5690
|
+
},
|
|
5691
|
+
{
|
|
5692
|
+
activities: {
|
|
5693
|
+
trackPointerMove(ctx2, _evt, { send }) {
|
|
5694
|
+
const doc = dom.getDoc(ctx2);
|
|
5695
|
+
return trackPointerMove(doc, {
|
|
5696
|
+
onPointerMove({ event, point }) {
|
|
5697
|
+
const { offset } = getRelativePoint(point, dom.getControlEl(ctx2));
|
|
5698
|
+
send({ type: "POINTER_MOVE", point: offset, pressure: event.pressure });
|
|
5699
|
+
},
|
|
5700
|
+
onPointerUp() {
|
|
5701
|
+
send({ type: "POINTER_UP" });
|
|
5702
|
+
}
|
|
5703
|
+
});
|
|
5704
|
+
}
|
|
5705
|
+
},
|
|
5706
|
+
actions: {
|
|
5707
|
+
addPoint(ctx2, evt) {
|
|
5708
|
+
ctx2.currentPoints.push(evt.point);
|
|
5709
|
+
const stroke = _e(ctx2.currentPoints, ctx2.drawing);
|
|
5710
|
+
ctx2.currentPath = getSvgPathFromStroke(stroke);
|
|
5711
|
+
},
|
|
5712
|
+
endStroke(ctx2) {
|
|
5713
|
+
ctx2.paths.push(ctx2.currentPath);
|
|
5714
|
+
ctx2.currentPoints = [];
|
|
5715
|
+
ctx2.currentPath = null;
|
|
5716
|
+
},
|
|
5717
|
+
clearPoints(ctx2) {
|
|
5718
|
+
ctx2.currentPoints = [];
|
|
5719
|
+
ctx2.paths = [];
|
|
5720
|
+
},
|
|
5721
|
+
focusCanvasEl(ctx2) {
|
|
5722
|
+
queueMicrotask(() => {
|
|
5723
|
+
dom.getControlEl(ctx2)?.focus({ preventScroll: true });
|
|
5724
|
+
});
|
|
5725
|
+
},
|
|
5726
|
+
invokeOnDraw(ctx2) {
|
|
5727
|
+
ctx2.onDraw?.({
|
|
5728
|
+
paths: [...ctx2.paths, ctx2.currentPath]
|
|
5729
|
+
});
|
|
5730
|
+
},
|
|
5731
|
+
invokeOnDrawEnd(ctx2) {
|
|
5732
|
+
ctx2.onDrawEnd?.({
|
|
5733
|
+
paths: [...ctx2.paths],
|
|
5734
|
+
getDataUrl(type, quality = 0.92) {
|
|
5735
|
+
return dom.getDataUrl(ctx2, { type, quality });
|
|
5736
|
+
}
|
|
5737
|
+
});
|
|
5738
|
+
}
|
|
5739
|
+
}
|
|
5740
|
+
}
|
|
5741
|
+
);
|
|
5742
|
+
}
|
|
5743
|
+
types.createProps()([
|
|
5744
|
+
"dir",
|
|
5745
|
+
"disabled",
|
|
5746
|
+
"getRootNode",
|
|
5747
|
+
"id",
|
|
5748
|
+
"ids",
|
|
5749
|
+
"onDraw",
|
|
5750
|
+
"onDrawEnd",
|
|
5751
|
+
"readOnly",
|
|
5752
|
+
"drawing",
|
|
5753
|
+
"name"
|
|
5754
|
+
]);
|
|
5755
|
+
|
|
5756
|
+
const useSignaturePad = props => {
|
|
5757
|
+
const locale = useLocaleContext();
|
|
5758
|
+
const environment = useEnvironmentContext();
|
|
5759
|
+
const id = solidJs.createUniqueId();
|
|
5760
|
+
const context = solidJs.createMemo(() => ({
|
|
5761
|
+
id,
|
|
5762
|
+
dir: locale().dir,
|
|
5763
|
+
getRootNode: environment().getRootNode,
|
|
5764
|
+
...props
|
|
5765
|
+
}));
|
|
5766
|
+
const [state, send] = solid.useMachine(machine(context()), {
|
|
5767
|
+
context
|
|
5768
|
+
});
|
|
5769
|
+
return solidJs.createMemo(() => connect(state, send, solid.normalizeProps));
|
|
5770
|
+
};
|
|
5771
|
+
|
|
5772
|
+
const SignaturePadRoot = props => {
|
|
5773
|
+
const [useSignaturePadProps, localProps] = createSplitProps()(props, ['id', 'ids', 'drawing', 'disabled', 'readOnly', 'name', 'onDraw', 'onDrawEnd']);
|
|
5774
|
+
const signaturePad = useSignaturePad(useSignaturePadProps);
|
|
5775
|
+
const mergedProps = solid.mergeProps(() => signaturePad().getRootProps(), localProps);
|
|
5776
|
+
return web.createComponent(SignaturePadProvider, {
|
|
5777
|
+
value: signaturePad,
|
|
5778
|
+
get children() {
|
|
5779
|
+
return web.createComponent(ark.div, mergedProps);
|
|
5780
|
+
}
|
|
5781
|
+
});
|
|
5782
|
+
};
|
|
5783
|
+
|
|
5784
|
+
const SignaturePadRootProvider = props => {
|
|
5785
|
+
const [{
|
|
5786
|
+
value: signaturePad
|
|
5787
|
+
}, localProps] = createSplitProps()(props, ['value']);
|
|
5788
|
+
const mergedProps = solid.mergeProps(() => signaturePad().getRootProps(), localProps);
|
|
5789
|
+
return web.createComponent(SignaturePadProvider, {
|
|
5790
|
+
value: signaturePad,
|
|
5791
|
+
get children() {
|
|
5792
|
+
return web.createComponent(ark.div, mergedProps);
|
|
5793
|
+
}
|
|
5794
|
+
});
|
|
5795
|
+
};
|
|
5796
|
+
|
|
5797
|
+
var _tmpl$$1 = /*#__PURE__*/web.template(`<title>Signature`),
|
|
5798
|
+
_tmpl$2 = /*#__PURE__*/web.template(`<svg><path></svg>`, false, true);
|
|
5799
|
+
const SignaturePadSegment = props => {
|
|
5800
|
+
const signaturePad = useSignaturePadContext();
|
|
5801
|
+
const mergedProps = solid.mergeProps(() => signaturePad().getSegmentProps(), props);
|
|
5802
|
+
return web.createComponent(ark.svg, web.mergeProps(mergedProps, {
|
|
5803
|
+
get children() {
|
|
5804
|
+
return [_tmpl$$1(), web.createComponent(solidJs.For, {
|
|
5805
|
+
get each() {
|
|
5806
|
+
return signaturePad().paths;
|
|
5807
|
+
},
|
|
5808
|
+
children: path => (() => {
|
|
5809
|
+
var _el$3 = _tmpl$2();
|
|
5810
|
+
web.spread(_el$3, web.mergeProps(() => signaturePad().getSegmentPathProps({
|
|
5811
|
+
path
|
|
5812
|
+
})), true, false);
|
|
5813
|
+
return _el$3;
|
|
5814
|
+
})()
|
|
5815
|
+
}), web.createComponent(solidJs.Show, {
|
|
5816
|
+
get when() {
|
|
5817
|
+
return signaturePad().currentPath;
|
|
5818
|
+
},
|
|
5819
|
+
get children() {
|
|
5820
|
+
var _el$2 = _tmpl$2();
|
|
5821
|
+
web.spread(_el$2, web.mergeProps(() => signaturePad().getSegmentPathProps({
|
|
5822
|
+
path: signaturePad().currentPath
|
|
5823
|
+
})), true, false);
|
|
5824
|
+
return _el$2;
|
|
5825
|
+
}
|
|
5826
|
+
})];
|
|
5827
|
+
}
|
|
5828
|
+
}));
|
|
5829
|
+
};
|
|
5830
|
+
|
|
5831
|
+
var signaturePad = /*#__PURE__*/Object.freeze({
|
|
5832
|
+
__proto__: null,
|
|
5833
|
+
ClearTrigger: SignaturePadClearTrigger,
|
|
5834
|
+
Context: SignaturePadContext,
|
|
5835
|
+
Control: SignaturePadControl,
|
|
5836
|
+
Guide: SignaturePadGuide,
|
|
5837
|
+
Label: SignaturePadLabel,
|
|
5838
|
+
Root: SignaturePadRoot,
|
|
5839
|
+
RootProvider: SignaturePadRootProvider,
|
|
5840
|
+
Segment: SignaturePadSegment
|
|
5841
|
+
});
|
|
5842
|
+
|
|
3897
5843
|
const [SliderProvider, useSliderContext] = createContext({
|
|
3898
5844
|
hookName: 'useSliderContext',
|
|
3899
5845
|
providerName: '<SliderProvider />'
|
|
@@ -4196,7 +6142,8 @@ const TabContent = props => {
|
|
|
4196
6142
|
const api = useTabsContext();
|
|
4197
6143
|
const renderStrategyProps = useRenderStrategyContext();
|
|
4198
6144
|
const presenceApi = usePresence(solid.mergeProps(renderStrategyProps, () => ({
|
|
4199
|
-
present: api().value === contentProps.value
|
|
6145
|
+
present: api().value === contentProps.value,
|
|
6146
|
+
immediate: true
|
|
4200
6147
|
})));
|
|
4201
6148
|
const mergedProps = solid.mergeProps(() => api().getContentProps(contentProps), () => presenceApi().presenceProps, localProps);
|
|
4202
6149
|
return web.createComponent(PresenceProvider, {
|
|
@@ -4495,11 +6442,12 @@ const ToastDescription = props => {
|
|
|
4495
6442
|
var _tmpl$ = /*#__PURE__*/web.template(`<div><div></div><div>`);
|
|
4496
6443
|
const ToastRoot = props => {
|
|
4497
6444
|
const toast = useToastContext();
|
|
6445
|
+
const mergedProps = solid.mergeProps(() => toast().getRootProps(), props);
|
|
4498
6446
|
return (() => {
|
|
4499
6447
|
var _el$ = _tmpl$(),
|
|
4500
6448
|
_el$2 = _el$.firstChild,
|
|
4501
6449
|
_el$3 = _el$2.nextSibling;
|
|
4502
|
-
web.spread(_el$,
|
|
6450
|
+
web.spread(_el$, mergedProps, false, true);
|
|
4503
6451
|
web.spread(_el$2, web.mergeProps(() => toast().getGhostBeforeProps()), false, false);
|
|
4504
6452
|
web.insert(_el$, () => props.children, _el$3);
|
|
4505
6453
|
web.spread(_el$3, web.mergeProps(() => toast().getGhostAfterProps()), false, false);
|
|
@@ -4974,6 +6922,7 @@ exports.CarouselViewport = CarouselViewport;
|
|
|
4974
6922
|
exports.Checkbox = checkbox;
|
|
4975
6923
|
exports.CheckboxContext = CheckboxContext;
|
|
4976
6924
|
exports.CheckboxControl = CheckboxControl;
|
|
6925
|
+
exports.CheckboxGroup = CheckboxGroup;
|
|
4977
6926
|
exports.CheckboxHiddenInput = CheckboxHiddenInput;
|
|
4978
6927
|
exports.CheckboxIndicator = CheckboxIndicator;
|
|
4979
6928
|
exports.CheckboxLabel = CheckboxLabel;
|
|
@@ -5194,6 +7143,13 @@ exports.ProgressRootProvider = ProgressRootProvider;
|
|
|
5194
7143
|
exports.ProgressTrack = ProgressTrack;
|
|
5195
7144
|
exports.ProgressValueText = ProgressValueText;
|
|
5196
7145
|
exports.ProgressView = ProgressView;
|
|
7146
|
+
exports.QrCode = qrCode;
|
|
7147
|
+
exports.QrCodeContext = QrCodeContext;
|
|
7148
|
+
exports.QrCodeFrame = QrCodeFrame;
|
|
7149
|
+
exports.QrCodeOverlay = QrCodeOverlay;
|
|
7150
|
+
exports.QrCodePattern = QrCodePattern;
|
|
7151
|
+
exports.QrCodeRoot = QrCodeRoot;
|
|
7152
|
+
exports.QrCodeRootProvider = QrCodeRootProvider;
|
|
5197
7153
|
exports.RadioGroup = radioGroup;
|
|
5198
7154
|
exports.RadioGroupContext = RadioGroupContext;
|
|
5199
7155
|
exports.RadioGroupIndicator = RadioGroupIndicator;
|
|
@@ -5239,11 +7195,21 @@ exports.SelectItemGroupLabel = SelectItemGroupLabel;
|
|
|
5239
7195
|
exports.SelectItemIndicator = SelectItemIndicator;
|
|
5240
7196
|
exports.SelectItemText = SelectItemText;
|
|
5241
7197
|
exports.SelectLabel = SelectLabel;
|
|
7198
|
+
exports.SelectList = SelectList;
|
|
5242
7199
|
exports.SelectPositioner = SelectPositioner;
|
|
5243
7200
|
exports.SelectRoot = SelectRoot;
|
|
5244
7201
|
exports.SelectRootProvider = SelectRootProvider;
|
|
5245
7202
|
exports.SelectTrigger = SelectTrigger;
|
|
5246
7203
|
exports.SelectValueText = SelectValueText;
|
|
7204
|
+
exports.SignaturePad = signaturePad;
|
|
7205
|
+
exports.SignaturePadClearTrigger = SignaturePadClearTrigger;
|
|
7206
|
+
exports.SignaturePadContext = SignaturePadContext;
|
|
7207
|
+
exports.SignaturePadControl = SignaturePadControl;
|
|
7208
|
+
exports.SignaturePadGuide = SignaturePadGuide;
|
|
7209
|
+
exports.SignaturePadLabel = SignaturePadLabel;
|
|
7210
|
+
exports.SignaturePadRoot = SignaturePadRoot;
|
|
7211
|
+
exports.SignaturePadRootProvider = SignaturePadRootProvider;
|
|
7212
|
+
exports.SignaturePadSegment = SignaturePadSegment;
|
|
5247
7213
|
exports.Slider = slider;
|
|
5248
7214
|
exports.SliderContext = SliderContext;
|
|
5249
7215
|
exports.SliderControl = SliderControl;
|
|
@@ -5344,6 +7310,8 @@ exports.useCarousel = useCarousel;
|
|
|
5344
7310
|
exports.useCarouselContext = useCarouselContext;
|
|
5345
7311
|
exports.useCheckbox = useCheckbox;
|
|
5346
7312
|
exports.useCheckboxContext = useCheckboxContext;
|
|
7313
|
+
exports.useCheckboxGroup = useCheckboxGroup;
|
|
7314
|
+
exports.useCheckboxGroupContext = useCheckboxGroupContext;
|
|
5347
7315
|
exports.useClipboard = useClipboard;
|
|
5348
7316
|
exports.useClipboardContext = useClipboardContext;
|
|
5349
7317
|
exports.useCollapsible = useCollapsible;
|
|
@@ -5380,6 +7348,8 @@ exports.usePresence = usePresence;
|
|
|
5380
7348
|
exports.usePresenceContext = usePresenceContext;
|
|
5381
7349
|
exports.useProgress = useProgress;
|
|
5382
7350
|
exports.useProgressContext = useProgressContext;
|
|
7351
|
+
exports.useQrCode = useQrCode;
|
|
7352
|
+
exports.useQrCodeContext = useQrCodeContext;
|
|
5383
7353
|
exports.useRadioGroup = useRadioGroup;
|
|
5384
7354
|
exports.useRadioGroupContext = useRadioGroupContext;
|
|
5385
7355
|
exports.useRadioGroupItemContext = useRadioGroupItemContext;
|
|
@@ -5392,6 +7362,8 @@ exports.useSegmentGroupItemContext = useSegmentGroupItemContext;
|
|
|
5392
7362
|
exports.useSelect = useSelect;
|
|
5393
7363
|
exports.useSelectContext = useSelectContext;
|
|
5394
7364
|
exports.useSelectItemContext = useSelectItemContext;
|
|
7365
|
+
exports.useSignaturePad = useSignaturePad;
|
|
7366
|
+
exports.useSignaturePadContext = useSignaturePadContext;
|
|
5395
7367
|
exports.useSlider = useSlider;
|
|
5396
7368
|
exports.useSliderContext = useSliderContext;
|
|
5397
7369
|
exports.useSplitter = useSplitter;
|