@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { checkboxAnatomy } from '@ark-ui/anatomy';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useCheckboxGroup } from './use-checkbox-group';
|
|
5
|
+
import { CheckboxGroupContextProvider } from './use-checkbox-group-context';
|
|
6
|
+
export const CheckboxGroup = (props) => {
|
|
7
|
+
const [checkboxGroupProps, localProps] = createSplitProps()(props, [
|
|
8
|
+
'defaultValue',
|
|
9
|
+
'value',
|
|
10
|
+
'onValueChange',
|
|
11
|
+
'disabled',
|
|
12
|
+
'readOnly',
|
|
13
|
+
]);
|
|
14
|
+
const checkboxGroup = useCheckboxGroup(checkboxGroupProps);
|
|
15
|
+
return (<CheckboxGroupContextProvider value={checkboxGroup}>
|
|
16
|
+
<ark.div {...localProps} {...checkboxAnatomy.build().group.attrs}/>
|
|
17
|
+
</CheckboxGroupContextProvider>);
|
|
18
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { CheckboxContext as Context, } from './checkbox-context';
|
|
2
2
|
export { CheckboxControl as Control, } from './checkbox-control';
|
|
3
|
+
export { CheckboxGroup as Group } from './checkbox-group';
|
|
3
4
|
export { CheckboxHiddenInput as HiddenInput, } from './checkbox-hidden-input';
|
|
4
5
|
export { CheckboxIndicator as Indicator, } from './checkbox-indicator';
|
|
5
6
|
export { CheckboxLabel as Label } from './checkbox-label';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { CheckboxContext } from './checkbox-context';
|
|
2
2
|
export { CheckboxControl } from './checkbox-control';
|
|
3
|
+
export { CheckboxGroup } from './checkbox-group';
|
|
3
4
|
export { CheckboxHiddenInput } from './checkbox-hidden-input';
|
|
4
5
|
export { CheckboxIndicator } from './checkbox-indicator';
|
|
5
6
|
export { CheckboxLabel } from './checkbox-label';
|
|
@@ -7,4 +8,6 @@ export { CheckboxRoot } from './checkbox-root';
|
|
|
7
8
|
export { CheckboxRootProvider } from './checkbox-root-provider';
|
|
8
9
|
export { useCheckbox } from './use-checkbox';
|
|
9
10
|
export { useCheckboxContext } from './use-checkbox-context';
|
|
11
|
+
export { useCheckboxGroup, } from './use-checkbox-group';
|
|
12
|
+
export { useCheckboxGroupContext } from './use-checkbox-group-context';
|
|
10
13
|
export * as Checkbox from './checkbox';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createMemo } from 'solid-js';
|
|
2
|
+
import { useControllableState } from '../../utils/use-controllable-state';
|
|
3
|
+
export function useCheckboxGroup(props = {}) {
|
|
4
|
+
const interative = createMemo(() => !(props.disabled || props.readOnly));
|
|
5
|
+
const [value, setValue] = useControllableState({
|
|
6
|
+
value: props.value,
|
|
7
|
+
defaultValue: props.defaultValue || [],
|
|
8
|
+
onChange: props.onValueChange,
|
|
9
|
+
});
|
|
10
|
+
return createMemo(() => {
|
|
11
|
+
const isChecked = (val) => {
|
|
12
|
+
return value().some((v) => String(v) === String(val));
|
|
13
|
+
};
|
|
14
|
+
const toggleValue = (val) => {
|
|
15
|
+
isChecked(val) ? removeValue(val) : addValue(val);
|
|
16
|
+
};
|
|
17
|
+
const addValue = (val) => {
|
|
18
|
+
if (!interative())
|
|
19
|
+
return;
|
|
20
|
+
if (isChecked(val))
|
|
21
|
+
return;
|
|
22
|
+
setValue(value().concat(val));
|
|
23
|
+
};
|
|
24
|
+
const removeValue = (val) => {
|
|
25
|
+
if (!interative())
|
|
26
|
+
return;
|
|
27
|
+
setValue(value().filter((v) => String(v) !== String(val)));
|
|
28
|
+
};
|
|
29
|
+
const getItemProps = (itemProps) => {
|
|
30
|
+
return {
|
|
31
|
+
checked: itemProps.value != null ? isChecked(itemProps.value) : undefined,
|
|
32
|
+
onCheckedChange() {
|
|
33
|
+
if (itemProps.value != null) {
|
|
34
|
+
toggleValue(itemProps.value);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
disabled: props.disabled,
|
|
38
|
+
readOnly: props.readOnly,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
isChecked,
|
|
43
|
+
value,
|
|
44
|
+
disabled: props.disabled,
|
|
45
|
+
readOnly: props.readOnly,
|
|
46
|
+
setValue,
|
|
47
|
+
addValue,
|
|
48
|
+
toggleValue,
|
|
49
|
+
getItemProps,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as checkbox from '@zag-js/checkbox';
|
|
2
|
-
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
2
|
+
import { mergeProps, normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
3
|
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
4
|
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
|
-
|
|
5
|
+
import { useCheckboxGroupContext } from './use-checkbox-group-context';
|
|
6
|
+
export const useCheckbox = (ownProps) => {
|
|
7
|
+
const checkboxGroup = useCheckboxGroupContext();
|
|
8
|
+
const props = createMemo(() => {
|
|
9
|
+
return mergeProps(ownProps, checkboxGroup?.().getItemProps({ value: ownProps.value }) ?? {});
|
|
10
|
+
}, [ownProps, checkboxGroup]);
|
|
6
11
|
const locale = useLocaleContext();
|
|
7
12
|
const environment = useEnvironmentContext();
|
|
8
13
|
const id = createUniqueId();
|
|
@@ -10,8 +15,8 @@ export const useCheckbox = (props) => {
|
|
|
10
15
|
id,
|
|
11
16
|
dir: locale().dir,
|
|
12
17
|
getRootNode: environment().getRootNode,
|
|
13
|
-
checked: props.defaultChecked,
|
|
14
|
-
...props,
|
|
18
|
+
checked: props().defaultChecked,
|
|
19
|
+
...props(),
|
|
15
20
|
}));
|
|
16
21
|
const [state, send] = useMachine(checkbox.machine(context()), { context });
|
|
17
22
|
return createMemo(() => checkbox.connect(state, send, normalizeProps));
|
|
@@ -20,10 +20,12 @@ export * from './pin-input';
|
|
|
20
20
|
export * from './popover';
|
|
21
21
|
export * from './presence';
|
|
22
22
|
export * from './progress';
|
|
23
|
+
export * from './qr-code';
|
|
23
24
|
export * from './radio-group';
|
|
24
25
|
export * from './rating-group';
|
|
25
26
|
export * from './segment-group';
|
|
26
27
|
export * from './select';
|
|
28
|
+
export * from './signature-pad';
|
|
27
29
|
export * from './slider';
|
|
28
30
|
export * from './splitter';
|
|
29
31
|
export * from './switch';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { QrCodeContext } from './qr-code-context';
|
|
2
|
+
export { QrCodeFrame } from './qr-code-frame';
|
|
3
|
+
export { QrCodeOverlay } from './qr-code-overlay';
|
|
4
|
+
export { QrCodePattern } from './qr-code-pattern';
|
|
5
|
+
export { QrCodeRoot } from './qr-code-root';
|
|
6
|
+
export { QrCodeRootProvider } from './qr-code-root-provider';
|
|
7
|
+
export { useQrCode } from './use-qr-code';
|
|
8
|
+
export { useQrCodeContext } from './use-qr-code-context';
|
|
9
|
+
export * as QrCode from './qr-code';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useQrCodeContext } from './use-qr-code-context';
|
|
4
|
+
export const QrCodeFrame = (props) => {
|
|
5
|
+
const qrCode = useQrCodeContext();
|
|
6
|
+
const mergedProps = mergeProps(() => qrCode().getFrameProps(), props);
|
|
7
|
+
return <ark.svg {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useQrCodeContext } from './use-qr-code-context';
|
|
4
|
+
export const QrCodeOverlay = (props) => {
|
|
5
|
+
const qrCode = useQrCodeContext();
|
|
6
|
+
const mergedProps = mergeProps(() => qrCode().getOverlayProps(), props);
|
|
7
|
+
return <ark.div {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useQrCodeContext } from './use-qr-code-context';
|
|
4
|
+
export const QrCodePattern = (props) => {
|
|
5
|
+
const qrCode = useQrCodeContext();
|
|
6
|
+
const mergedProps = mergeProps(() => qrCode().getPatternProps(), props);
|
|
7
|
+
return <ark.path {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { QrCodeProvider } from './use-qr-code-context';
|
|
5
|
+
export const QrCodeRootProvider = (props) => {
|
|
6
|
+
const [{ value: qrCode }, localProps] = createSplitProps()(props, ['value']);
|
|
7
|
+
const mergedProps = mergeProps(() => qrCode().getRootProps(), localProps);
|
|
8
|
+
return (<QrCodeProvider value={qrCode}>
|
|
9
|
+
<ark.div {...mergedProps}/>
|
|
10
|
+
</QrCodeProvider>);
|
|
11
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useQrCode } from './use-qr-code';
|
|
5
|
+
import { QrCodeProvider } from './use-qr-code-context';
|
|
6
|
+
export const QrCodeRoot = (props) => {
|
|
7
|
+
const [useQrCodeProps, restProps] = createSplitProps()(props, [
|
|
8
|
+
'encoding',
|
|
9
|
+
'id',
|
|
10
|
+
'ids',
|
|
11
|
+
'value',
|
|
12
|
+
]);
|
|
13
|
+
const api = useQrCode(useQrCodeProps);
|
|
14
|
+
const mergedProps = mergeProps(() => api().getRootProps(), restProps);
|
|
15
|
+
return (<QrCodeProvider value={api}>
|
|
16
|
+
<ark.div {...mergedProps}/>
|
|
17
|
+
</QrCodeProvider>);
|
|
18
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { QrCodeContext } from './qr-code-context';
|
|
2
|
+
export { QrCodeFrame as Frame } from './qr-code-frame';
|
|
3
|
+
export { QrCodeOverlay as Overlay, } from './qr-code-overlay';
|
|
4
|
+
export { QrCodePattern as Pattern, } from './qr-code-pattern';
|
|
5
|
+
export { QrCodeRoot as Root } from './qr-code-root';
|
|
6
|
+
export { QrCodeRootProvider as RootProvider, } from './qr-code-root-provider';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as qrCode from '@zag-js/qr-code';
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
|
+
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
|
+
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
|
+
export const useQrCode = (props) => {
|
|
6
|
+
const locale = useLocaleContext();
|
|
7
|
+
const environment = useEnvironmentContext();
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
...props,
|
|
14
|
+
}));
|
|
15
|
+
const [state, send] = useMachine(qrCode.machine(context()), {
|
|
16
|
+
context,
|
|
17
|
+
});
|
|
18
|
+
return createMemo(() => qrCode.connect(state, send, normalizeProps));
|
|
19
|
+
};
|
|
@@ -11,6 +11,7 @@ export { SelectItemGroupLabel } from './select-item-group-label';
|
|
|
11
11
|
export { SelectItemIndicator } from './select-item-indicator';
|
|
12
12
|
export { SelectItemText } from './select-item-text';
|
|
13
13
|
export { SelectLabel } from './select-label';
|
|
14
|
+
export { SelectList } from './select-list';
|
|
14
15
|
export { SelectPositioner } from './select-positioner';
|
|
15
16
|
export { SelectRoot } from './select-root';
|
|
16
17
|
export { SelectRootProvider } from './select-root-provider';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useSelectContext } from './use-select-context';
|
|
4
|
+
export const SelectList = (props) => {
|
|
5
|
+
const select = useSelectContext();
|
|
6
|
+
const mergedProps = mergeProps(() => select().getListProps(), props);
|
|
7
|
+
return <ark.div {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -11,6 +11,7 @@ export { SelectItemGroupLabel as ItemGroupLabel, } from './select-item-group-lab
|
|
|
11
11
|
export { SelectItemIndicator as ItemIndicator, } from './select-item-indicator';
|
|
12
12
|
export { SelectItemText as ItemText, } from './select-item-text';
|
|
13
13
|
export { SelectLabel as Label } from './select-label';
|
|
14
|
+
export { SelectList as List } from './select-list';
|
|
14
15
|
export { SelectPositioner as Positioner, } from './select-positioner';
|
|
15
16
|
export { SelectRoot as Root } from './select-root';
|
|
16
17
|
export { SelectRootProvider as RootProvider, } from './select-root-provider';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { SignaturePadClearTrigger, } from './signature-pad-clear-trigger';
|
|
2
|
+
export { SignaturePadContext } from './signature-pad-context';
|
|
3
|
+
export { SignaturePadControl } from './signature-pad-control';
|
|
4
|
+
export { SignaturePadGuide } from './signature-pad-guide';
|
|
5
|
+
export { SignaturePadLabel } from './signature-pad-label';
|
|
6
|
+
export { SignaturePadRoot } from './signature-pad-root';
|
|
7
|
+
export { SignaturePadRootProvider, } from './signature-pad-root-provider';
|
|
8
|
+
export { SignaturePadSegment } from './signature-pad-segment';
|
|
9
|
+
export { useSignaturePad, } from './use-signature-pad';
|
|
10
|
+
export { useSignaturePadContext } from './use-signature-pad-context';
|
|
11
|
+
export * as SignaturePad from './signature-pad';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useSignaturePadContext } from './use-signature-pad-context';
|
|
4
|
+
export const SignaturePadClearTrigger = (props) => {
|
|
5
|
+
const signaturePad = useSignaturePadContext();
|
|
6
|
+
const mergedProps = mergeProps(() => signaturePad().getClearTriggerProps(), props);
|
|
7
|
+
return <ark.button {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useSignaturePadContext } from './use-signature-pad-context';
|
|
4
|
+
export const SignaturePadControl = (props) => {
|
|
5
|
+
const signaturePad = useSignaturePadContext();
|
|
6
|
+
const mergedProps = mergeProps(() => signaturePad().getControlProps(), props);
|
|
7
|
+
return <ark.div role="application" {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useSignaturePadContext } from './use-signature-pad-context';
|
|
4
|
+
export const SignaturePadGuide = (props) => {
|
|
5
|
+
const signaturePad = useSignaturePadContext();
|
|
6
|
+
const mergedProps = mergeProps(() => signaturePad().getGuideProps(), props);
|
|
7
|
+
return <ark.div {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useSignaturePadContext } from './use-signature-pad-context';
|
|
4
|
+
export const SignaturePadLabel = (props) => {
|
|
5
|
+
const signaturePad = useSignaturePadContext();
|
|
6
|
+
const mergedProps = mergeProps(() => signaturePad().getLabelProps(), props);
|
|
7
|
+
return <ark.label {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { SignaturePadProvider } from './use-signature-pad-context';
|
|
5
|
+
export const SignaturePadRootProvider = (props) => {
|
|
6
|
+
const [{ value: signaturePad }, localProps] = createSplitProps()(props, [
|
|
7
|
+
'value',
|
|
8
|
+
]);
|
|
9
|
+
const mergedProps = mergeProps(() => signaturePad().getRootProps(), localProps);
|
|
10
|
+
return (<SignaturePadProvider value={signaturePad}>
|
|
11
|
+
<ark.div {...mergedProps}/>
|
|
12
|
+
</SignaturePadProvider>);
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useSignaturePad } from './use-signature-pad';
|
|
5
|
+
import { SignaturePadProvider } from './use-signature-pad-context';
|
|
6
|
+
export const SignaturePadRoot = (props) => {
|
|
7
|
+
const [useSignaturePadProps, localProps] = createSplitProps()(props, [
|
|
8
|
+
'id',
|
|
9
|
+
'ids',
|
|
10
|
+
'drawing',
|
|
11
|
+
'disabled',
|
|
12
|
+
'readOnly',
|
|
13
|
+
'name',
|
|
14
|
+
'onDraw',
|
|
15
|
+
'onDrawEnd',
|
|
16
|
+
]);
|
|
17
|
+
const signaturePad = useSignaturePad(useSignaturePadProps);
|
|
18
|
+
const mergedProps = mergeProps(() => signaturePad().getRootProps(), localProps);
|
|
19
|
+
return (<SignaturePadProvider value={signaturePad}>
|
|
20
|
+
<ark.div {...mergedProps}/>
|
|
21
|
+
</SignaturePadProvider>);
|
|
22
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { For, Show } from 'solid-js';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useSignaturePadContext } from './use-signature-pad-context';
|
|
5
|
+
export const SignaturePadSegment = (props) => {
|
|
6
|
+
const signaturePad = useSignaturePadContext();
|
|
7
|
+
const mergedProps = mergeProps(() => signaturePad().getSegmentProps(), props);
|
|
8
|
+
return (<ark.svg {...mergedProps}>
|
|
9
|
+
<title>Signature</title>
|
|
10
|
+
<For each={signaturePad().paths}>
|
|
11
|
+
{(path) => <path {...signaturePad().getSegmentPathProps({ path })}/>}
|
|
12
|
+
</For>
|
|
13
|
+
<Show when={signaturePad().currentPath}>
|
|
14
|
+
{/* @ts-expect-error */}
|
|
15
|
+
<path {...signaturePad().getSegmentPathProps({ path: signaturePad().currentPath })}/>
|
|
16
|
+
</Show>
|
|
17
|
+
</ark.svg>);
|
|
18
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SignaturePadClearTrigger as ClearTrigger, } from './signature-pad-clear-trigger';
|
|
2
|
+
export { SignaturePadContext as Context, } from './signature-pad-context';
|
|
3
|
+
export { SignaturePadControl as Control, } from './signature-pad-control';
|
|
4
|
+
export { SignaturePadGuide as Guide, } from './signature-pad-guide';
|
|
5
|
+
export { SignaturePadLabel as Label, } from './signature-pad-label';
|
|
6
|
+
export { SignaturePadRoot as Root, } from './signature-pad-root';
|
|
7
|
+
export { SignaturePadRootProvider as RootProvider, } from './signature-pad-root-provider';
|
|
8
|
+
export { SignaturePadSegment as Segment, } from './signature-pad-segment';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as signaturePad from '@zag-js/signature-pad';
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
|
+
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
|
+
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
5
|
+
export const useSignaturePad = (props) => {
|
|
6
|
+
const locale = useLocaleContext();
|
|
7
|
+
const environment = useEnvironmentContext();
|
|
8
|
+
const id = createUniqueId();
|
|
9
|
+
const context = createMemo(() => ({
|
|
10
|
+
id,
|
|
11
|
+
dir: locale().dir,
|
|
12
|
+
getRootNode: environment().getRootNode,
|
|
13
|
+
...props,
|
|
14
|
+
}));
|
|
15
|
+
const [state, send] = useMachine(signaturePad.machine(context()), { context });
|
|
16
|
+
return createMemo(() => signaturePad.connect(state, send, normalizeProps));
|
|
17
|
+
};
|
|
@@ -9,7 +9,10 @@ export const TabContent = (props) => {
|
|
|
9
9
|
const [contentProps, localProps] = createSplitProps()(props, ['value']);
|
|
10
10
|
const api = useTabsContext();
|
|
11
11
|
const renderStrategyProps = useRenderStrategyContext();
|
|
12
|
-
const presenceApi = usePresence(mergeProps(renderStrategyProps, () => ({
|
|
12
|
+
const presenceApi = usePresence(mergeProps(renderStrategyProps, () => ({
|
|
13
|
+
present: api().value === contentProps.value,
|
|
14
|
+
immediate: true,
|
|
15
|
+
})));
|
|
13
16
|
const mergedProps = mergeProps(() => api().getContentProps(contentProps), () => presenceApi().presenceProps, localProps);
|
|
14
17
|
return (<PresenceProvider value={presenceApi}>
|
|
15
18
|
<Show when={!presenceApi().unmounted}>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
1
2
|
import { useToastContext } from './use-toast-context';
|
|
2
3
|
export const ToastRoot = (props) => {
|
|
3
4
|
const toast = useToastContext();
|
|
4
|
-
|
|
5
|
+
const mergedProps = mergeProps(() => toast().getRootProps(), props);
|
|
6
|
+
return (<div {...mergedProps}>
|
|
5
7
|
<div {...toast().getGhostBeforeProps()}/>
|
|
6
8
|
{props.children}
|
|
7
9
|
<div {...toast().getGhostAfterProps()}/>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createMemo, createSignal, untrack } from 'solid-js';
|
|
2
|
+
import { runIfFn } from './run-if-fn';
|
|
3
|
+
export function useControllableState(props) {
|
|
4
|
+
const [uncontrolledValue, setUncontrolledValue] = createSignal(runIfFn(props.defaultValue));
|
|
5
|
+
const controlled = createMemo(() => props.value?.() !== undefined);
|
|
6
|
+
const currentValue = createMemo(() => (controlled() ? props.value?.() : uncontrolledValue()));
|
|
7
|
+
const setValue = (next) => {
|
|
8
|
+
untrack(() => {
|
|
9
|
+
const nextValue = runIfFn(next, currentValue());
|
|
10
|
+
if (controlled()) {
|
|
11
|
+
return props.onChange?.(nextValue);
|
|
12
|
+
}
|
|
13
|
+
setUncontrolledValue(nextValue);
|
|
14
|
+
return props.onChange?.(nextValue);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
return [currentValue, setValue];
|
|
18
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Assign } from '../../types';
|
|
2
|
+
import { type HTMLArkProps } from '../factory';
|
|
3
|
+
import { type UseCheckboxGroupProps } from './use-checkbox-group';
|
|
4
|
+
export interface CheckboxGroupProps extends Assign<HTMLArkProps<'div'>, UseCheckboxGroupProps> {
|
|
5
|
+
}
|
|
6
|
+
export declare const CheckboxGroup: (props: CheckboxGroupProps) => import("solid-js").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { CheckedChangeDetails, CheckedState } from '@zag-js/checkbox';
|
|
2
2
|
export { CheckboxContext as Context, type CheckboxContextProps as ContextProps, } from './checkbox-context';
|
|
3
3
|
export { CheckboxControl as Control, type CheckboxControlProps as ControlProps, } from './checkbox-control';
|
|
4
|
+
export { CheckboxGroup as Group, type CheckboxGroupProps as GroupProps } from './checkbox-group';
|
|
4
5
|
export { CheckboxHiddenInput as HiddenInput, type CheckboxHiddenInputProps as HiddenInputProps, } from './checkbox-hidden-input';
|
|
5
6
|
export { CheckboxIndicator as Indicator, type CheckboxIndicatorProps as IndicatorProps, } from './checkbox-indicator';
|
|
6
7
|
export { CheckboxLabel as Label, type CheckboxLabelProps as LabelProps } from './checkbox-label';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { CheckedChangeDetails as CheckboxCheckedChangeDetails, CheckedState as CheckboxCheckedState, } from '@zag-js/checkbox';
|
|
2
2
|
export { CheckboxContext, type CheckboxContextProps } from './checkbox-context';
|
|
3
3
|
export { CheckboxControl, type CheckboxControlProps } from './checkbox-control';
|
|
4
|
+
export { CheckboxGroup, type CheckboxGroupProps } from './checkbox-group';
|
|
4
5
|
export { CheckboxHiddenInput, type CheckboxHiddenInputProps } from './checkbox-hidden-input';
|
|
5
6
|
export { CheckboxIndicator, type CheckboxIndicatorProps } from './checkbox-indicator';
|
|
6
7
|
export { CheckboxLabel, type CheckboxLabelProps } from './checkbox-label';
|
|
@@ -8,4 +9,6 @@ export { CheckboxRoot, type CheckboxRootProps } from './checkbox-root';
|
|
|
8
9
|
export { CheckboxRootProvider, type CheckboxRootProviderProps } from './checkbox-root-provider';
|
|
9
10
|
export { useCheckbox, type UseCheckboxProps, type UseCheckboxReturn } from './use-checkbox';
|
|
10
11
|
export { useCheckboxContext, type UseCheckboxContext } from './use-checkbox-context';
|
|
12
|
+
export { useCheckboxGroup, type UseCheckboxGroupProps, type UseCheckboxGroupReturn, } from './use-checkbox-group';
|
|
13
|
+
export { useCheckboxGroupContext, type UseCheckboxGroupContext } from './use-checkbox-group-context';
|
|
11
14
|
export * as Checkbox from './checkbox';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { UseCheckboxGroupReturn } from './use-checkbox-group';
|
|
2
|
+
export interface UseCheckboxGroupContext extends UseCheckboxGroupReturn {
|
|
3
|
+
}
|
|
4
|
+
export declare const CheckboxGroupContextProvider: import("solid-js").ContextProviderComponent<UseCheckboxGroupContext>, useCheckboxGroupContext: () => UseCheckboxGroupContext;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Accessor } from 'solid-js';
|
|
2
|
+
export interface UseCheckboxGroupProps {
|
|
3
|
+
/**
|
|
4
|
+
* The initial value of `value` when uncontrolled
|
|
5
|
+
*/
|
|
6
|
+
defaultValue?: Accessor<string[]> | string[];
|
|
7
|
+
/**
|
|
8
|
+
* The controlled value of the checkbox group
|
|
9
|
+
*/
|
|
10
|
+
value?: Accessor<string[]>;
|
|
11
|
+
/**
|
|
12
|
+
* The callback to call when the value changes
|
|
13
|
+
*/
|
|
14
|
+
onValueChange?: (value: string[]) => void;
|
|
15
|
+
/**
|
|
16
|
+
* If `true`, the checkbox group is disabled
|
|
17
|
+
*/
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* If `true`, the checkbox group is read-only
|
|
21
|
+
*/
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface CheckboxGroupItemProps {
|
|
25
|
+
value: string | undefined;
|
|
26
|
+
}
|
|
27
|
+
export declare function useCheckboxGroup(props?: UseCheckboxGroupProps): Accessor<{
|
|
28
|
+
isChecked: (val: string | undefined) => boolean;
|
|
29
|
+
value: Accessor<string[]>;
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
readOnly: boolean;
|
|
32
|
+
setValue: (next: string[] | ((prev: string[]) => string[])) => void;
|
|
33
|
+
addValue: (val: string) => void;
|
|
34
|
+
toggleValue: (val: string) => void;
|
|
35
|
+
getItemProps: (itemProps: CheckboxGroupItemProps) => {
|
|
36
|
+
checked: boolean;
|
|
37
|
+
onCheckedChange(): void;
|
|
38
|
+
disabled: boolean;
|
|
39
|
+
readOnly: boolean;
|
|
40
|
+
};
|
|
41
|
+
}>;
|
|
42
|
+
export type UseCheckboxGroupReturn = ReturnType<typeof useCheckboxGroup>;
|
|
@@ -11,4 +11,4 @@ export interface UseCheckboxProps extends Optional<Omit<checkbox.Context, 'dir'
|
|
|
11
11
|
}
|
|
12
12
|
export interface UseCheckboxReturn extends Accessor<checkbox.Api<PropTypes>> {
|
|
13
13
|
}
|
|
14
|
-
export declare const useCheckbox: (
|
|
14
|
+
export declare const useCheckbox: (ownProps: UseCheckboxProps) => UseCheckboxReturn;
|
|
@@ -20,10 +20,12 @@ export * from './pin-input';
|
|
|
20
20
|
export * from './popover';
|
|
21
21
|
export * from './presence';
|
|
22
22
|
export * from './progress';
|
|
23
|
+
export * from './qr-code';
|
|
23
24
|
export * from './radio-group';
|
|
24
25
|
export * from './rating-group';
|
|
25
26
|
export * from './segment-group';
|
|
26
27
|
export * from './select';
|
|
28
|
+
export * from './signature-pad';
|
|
27
29
|
export * from './slider';
|
|
28
30
|
export * from './splitter';
|
|
29
31
|
export * from './switch';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { UsePresenceProps } from './use-presence';
|
|
2
|
-
export declare const splitPresenceProps: <T extends UsePresenceProps>(props: T) => [Pick<T, Extract<("lazyMount" | "unmountOnExit" | "onExitComplete" | "present")[], readonly (keyof T)[]>[number]>, { [P in keyof T as Exclude<P, "lazyMount" | "unmountOnExit" | "onExitComplete" | "present">]: T[P]; }];
|
|
2
|
+
export declare const splitPresenceProps: <T extends UsePresenceProps>(props: T) => [Pick<T, Extract<("lazyMount" | "unmountOnExit" | "onExitComplete" | "present" | "immediate")[], readonly (keyof T)[]>[number]>, { [P in keyof T as Exclude<P, "lazyMount" | "unmountOnExit" | "onExitComplete" | "present" | "immediate">]: T[P]; }];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { QrCodeGenerateOptions, QrCodeGenerateResult } from '@zag-js/qr-code';
|
|
2
|
+
export { QrCodeContext, type QrCodeContextProps } from './qr-code-context';
|
|
3
|
+
export { QrCodeFrame, type QrCodeFrameProps } from './qr-code-frame';
|
|
4
|
+
export { QrCodeOverlay, type QrCodeOverlayProps } from './qr-code-overlay';
|
|
5
|
+
export { QrCodePattern, type QrCodePatternProps } from './qr-code-pattern';
|
|
6
|
+
export { QrCodeRoot, type QrCodeRootProps } from './qr-code-root';
|
|
7
|
+
export { QrCodeRootProvider, type QrCodeRootProviderProps } from './qr-code-root-provider';
|
|
8
|
+
export { useQrCode, type UseQrCodeProps, type UseQrCodeReturn } from './use-qr-code';
|
|
9
|
+
export { useQrCodeContext, type UseQrCodeContext } from './use-qr-code-context';
|
|
10
|
+
export * as QrCode from './qr-code';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JSX } from 'solid-js';
|
|
2
|
+
import { type UseQrCodeContext } from './use-qr-code-context';
|
|
3
|
+
export interface QrCodeContextProps {
|
|
4
|
+
children: (context: UseQrCodeContext) => JSX.Element;
|
|
5
|
+
}
|
|
6
|
+
export declare const QrCodeContext: (props: QrCodeContextProps) => JSX.Element;
|