@ark-ui/solid 4.0.0 → 4.1.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/dist/cjs/index.js +145 -38
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +139 -39
- package/dist/esm/index.js.map +1 -1
- package/dist/source/components/file-upload/file-upload-item-preview-image.jsx +5 -2
- package/dist/source/components/index.js +1 -0
- package/dist/source/components/toggle/index.js +7 -0
- package/dist/source/components/toggle/toggle-context.jsx +2 -0
- package/dist/source/components/toggle/toggle-indicator.jsx +15 -0
- package/dist/source/components/toggle/toggle-root.jsx +17 -0
- package/dist/source/components/toggle/toggle.anatomy.js +3 -0
- package/dist/source/components/toggle/toggle.js +4 -0
- package/dist/source/components/toggle/use-toggle-context.js +5 -0
- package/dist/source/components/toggle/use-toggle.js +43 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/toggle/index.d.ts +7 -0
- package/dist/types/components/toggle/toggle-context.d.ts +6 -0
- package/dist/types/components/toggle/toggle-indicator.d.ts +8 -0
- package/dist/types/components/toggle/toggle-root.d.ts +7 -0
- package/dist/types/components/toggle/toggle.anatomy.d.ts +2 -0
- package/dist/types/components/toggle/toggle.d.ts +4 -0
- package/dist/types/components/toggle/use-toggle-context.d.ts +4 -0
- package/dist/types/components/toggle/use-toggle.d.ts +36 -0
- package/package.json +52 -52
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeProps } from '@zag-js/solid';
|
|
2
|
-
import { createSignal } from 'solid-js';
|
|
2
|
+
import { createEffect, createSignal, onCleanup } from 'solid-js';
|
|
3
3
|
import { ark } from '../factory';
|
|
4
4
|
import { useFileUploadContext } from './use-file-upload-context';
|
|
5
5
|
import { useFileUploadItemPropsContext } from './use-file-upload-item-props-context';
|
|
@@ -7,7 +7,10 @@ export const FileUploadItemPreviewImage = (props) => {
|
|
|
7
7
|
const fileUpload = useFileUploadContext();
|
|
8
8
|
const itemProps = useFileUploadItemPropsContext();
|
|
9
9
|
const [url, setUrl] = createSignal('');
|
|
10
|
-
|
|
10
|
+
createEffect(() => {
|
|
11
|
+
const cleanup = fileUpload().createFileUrl(itemProps.file, (url) => setUrl(url));
|
|
12
|
+
onCleanup(cleanup);
|
|
13
|
+
});
|
|
11
14
|
const mergedProps = mergeProps(fileUpload().getItemPreviewImageProps({ ...itemProps, url: url() }), props);
|
|
12
15
|
return <ark.img {...mergedProps}/>;
|
|
13
16
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ToggleContext } from './toggle-context';
|
|
2
|
+
export { ToggleIndicator, } from './toggle-indicator';
|
|
3
|
+
export { ToggleRoot } from './toggle-root';
|
|
4
|
+
export { toggleAnatomy } from './toggle.anatomy';
|
|
5
|
+
export { useToggle } from './use-toggle';
|
|
6
|
+
export { useToggleContext } from './use-toggle-context';
|
|
7
|
+
export * as Toggle from './toggle';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { Show } from 'solid-js';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useToggleContext } from './use-toggle-context';
|
|
5
|
+
export const ToggleIndicator = (props) => {
|
|
6
|
+
const { children, fallback, ...restProps } = props;
|
|
7
|
+
const toggle = useToggleContext();
|
|
8
|
+
const mergedProps = mergeProps(() => toggle().getIndicatorProps(), restProps);
|
|
9
|
+
return (<ark.div {...mergedProps}>
|
|
10
|
+
{/* @ts-ignore */}
|
|
11
|
+
<Show when={toggle().pressed} fallback={fallback}>
|
|
12
|
+
{children}
|
|
13
|
+
</Show>
|
|
14
|
+
</ark.div>);
|
|
15
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { useToggle } from './use-toggle';
|
|
4
|
+
import { ToggleProvider } from './use-toggle-context';
|
|
5
|
+
export const ToggleRoot = (props) => {
|
|
6
|
+
const [useToggleProps, localProps] = createSplitProps()(props, [
|
|
7
|
+
'pressed',
|
|
8
|
+
'defaultPressed',
|
|
9
|
+
'disabled',
|
|
10
|
+
'onPressedChange',
|
|
11
|
+
]);
|
|
12
|
+
const toggle = useToggle(useToggleProps);
|
|
13
|
+
const mergedProps = mergeProps(() => toggle().getRootProps(), localProps);
|
|
14
|
+
return (<ToggleProvider value={toggle}>
|
|
15
|
+
<button {...mergedProps}/>
|
|
16
|
+
</ToggleProvider>);
|
|
17
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { dataAttr } from '@zag-js/dom-query';
|
|
2
|
+
import { createMemo } from 'solid-js';
|
|
3
|
+
import { useControllableState } from '../../utils/use-controllable-state';
|
|
4
|
+
import { parts } from './toggle.anatomy';
|
|
5
|
+
export function useToggle(props) {
|
|
6
|
+
const { defaultPressed, pressed, onPressedChange, disabled } = props;
|
|
7
|
+
const [pressedState, setPressedState] = useControllableState({
|
|
8
|
+
defaultValue: !!defaultPressed,
|
|
9
|
+
value: pressed,
|
|
10
|
+
onChange: onPressedChange,
|
|
11
|
+
});
|
|
12
|
+
return createMemo(() => ({
|
|
13
|
+
pressed: pressedState(),
|
|
14
|
+
disabled: !!disabled,
|
|
15
|
+
setPressed: setPressedState,
|
|
16
|
+
getRootProps() {
|
|
17
|
+
return {
|
|
18
|
+
...parts.root.attrs,
|
|
19
|
+
type: 'button',
|
|
20
|
+
disabled,
|
|
21
|
+
'aria-pressed': pressedState(),
|
|
22
|
+
'data-state': pressedState() ? 'on' : 'off',
|
|
23
|
+
'data-pressed': dataAttr(pressedState()),
|
|
24
|
+
'data-disabled': dataAttr(disabled),
|
|
25
|
+
onClick(event) {
|
|
26
|
+
if (event.defaultPrevented)
|
|
27
|
+
return;
|
|
28
|
+
if (disabled)
|
|
29
|
+
return;
|
|
30
|
+
setPressedState(!pressedState());
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
getIndicatorProps() {
|
|
35
|
+
return {
|
|
36
|
+
...parts.indicator.attrs,
|
|
37
|
+
'data-disabled': dataAttr(disabled),
|
|
38
|
+
'data-pressed': dataAttr(pressedState()),
|
|
39
|
+
'data-state': pressedState() ? 'on' : 'off',
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ToggleContext, type ToggleContextProps } from './toggle-context';
|
|
2
|
+
export { ToggleIndicator, type ToggleIndicatorProps, type ToggleIndicatorBaseProps, } from './toggle-indicator';
|
|
3
|
+
export { ToggleRoot, type ToggleRootBaseProps, type ToggleRootProps } from './toggle-root';
|
|
4
|
+
export { toggleAnatomy } from './toggle.anatomy';
|
|
5
|
+
export { useToggle, type UseToggleProps, type UseToggleReturn } from './use-toggle';
|
|
6
|
+
export { useToggleContext, type UseToggleContext } from './use-toggle-context';
|
|
7
|
+
export * as Toggle from './toggle';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JSX } from 'solid-js';
|
|
2
|
+
import { type UseToggleContext } from './use-toggle-context';
|
|
3
|
+
export interface ToggleContextProps {
|
|
4
|
+
children: (context: UseToggleContext) => JSX.Element;
|
|
5
|
+
}
|
|
6
|
+
export declare const ToggleContext: (props: ToggleContextProps) => JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
import type { HTMLProps, PolymorphicProps } from '../factory';
|
|
3
|
+
export interface ToggleIndicatorBaseProps extends PolymorphicProps<'div'> {
|
|
4
|
+
fallback?: JSX.Element;
|
|
5
|
+
}
|
|
6
|
+
export interface ToggleIndicatorProps extends HTMLProps<'div'>, ToggleIndicatorBaseProps {
|
|
7
|
+
}
|
|
8
|
+
export declare const ToggleIndicator: (props: ToggleIndicatorProps) => JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HTMLProps, PolymorphicProps } from '../factory';
|
|
2
|
+
import { type UseToggleProps } from './use-toggle';
|
|
3
|
+
export interface ToggleRootBaseProps extends UseToggleProps, PolymorphicProps<'button'> {
|
|
4
|
+
}
|
|
5
|
+
export interface ToggleRootProps extends HTMLProps<'button'>, ToggleRootBaseProps {
|
|
6
|
+
}
|
|
7
|
+
export declare const ToggleRoot: (props: ToggleRootProps) => import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ToggleContext as Context, type ToggleContextProps as ContextProps } from './toggle-context';
|
|
2
|
+
export { ToggleIndicator as Indicator, type ToggleIndicatorProps as IndicatorProps, type ToggleIndicatorBaseProps as IndicatorBaseProps, } from './toggle-indicator';
|
|
3
|
+
export { ToggleRoot as Root, type ToggleRootBaseProps as RootBaseProps, type ToggleRootProps as RootProps, } from './toggle-root';
|
|
4
|
+
export { toggleAnatomy } from './toggle.anatomy';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Accessor } from 'solid-js';
|
|
2
|
+
export interface UseToggleProps {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the toggle is disabled.
|
|
5
|
+
*/
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The default pressed state of the toggle.
|
|
9
|
+
*/
|
|
10
|
+
defaultPressed?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The pressed state of the toggle.
|
|
13
|
+
*/
|
|
14
|
+
pressed?: Accessor<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Event handler called when the pressed state of the toggle changes.
|
|
17
|
+
*/
|
|
18
|
+
onPressedChange?: (pressed: boolean) => void;
|
|
19
|
+
}
|
|
20
|
+
export type UseToggleReturn = Accessor<{
|
|
21
|
+
/**
|
|
22
|
+
* Whether the toggle is pressed.
|
|
23
|
+
*/
|
|
24
|
+
pressed: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the toggle is disabled.
|
|
27
|
+
*/
|
|
28
|
+
disabled: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the pressed state of the toggle.
|
|
31
|
+
*/
|
|
32
|
+
setPressed(pressed: boolean): void;
|
|
33
|
+
getRootProps(): JSX.IntrinsicElements['button'];
|
|
34
|
+
getIndicatorProps(): JSX.IntrinsicElements['div'];
|
|
35
|
+
}>;
|
|
36
|
+
export declare function useToggle(props: UseToggleProps): UseToggleReturn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark-ui/solid",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "A collection of unstyled, accessible UI components for Solid, utilizing state machines for seamless interaction.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accordion",
|
|
@@ -86,73 +86,73 @@
|
|
|
86
86
|
"sideEffects": false,
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@internationalized/date": "3.5.5",
|
|
89
|
-
"@zag-js/accordion": "0.
|
|
90
|
-
"@zag-js/anatomy": "0.
|
|
91
|
-
"@zag-js/avatar": "0.
|
|
92
|
-
"@zag-js/carousel": "0.
|
|
93
|
-
"@zag-js/checkbox": "0.
|
|
94
|
-
"@zag-js/clipboard": "0.
|
|
95
|
-
"@zag-js/collapsible": "0.
|
|
96
|
-
"@zag-js/collection": "0.
|
|
97
|
-
"@zag-js/color-picker": "0.
|
|
98
|
-
"@zag-js/combobox": "0.
|
|
99
|
-
"@zag-js/date-picker": "0.
|
|
100
|
-
"@zag-js/dialog": "0.
|
|
101
|
-
"@zag-js/dom-query": "0.
|
|
102
|
-
"@zag-js/editable": "0.
|
|
103
|
-
"@zag-js/file-upload": "0.
|
|
104
|
-
"@zag-js/highlight-word": "0.
|
|
105
|
-
"@zag-js/hover-card": "0.
|
|
106
|
-
"@zag-js/file-utils": "0.
|
|
107
|
-
"@zag-js/i18n-utils": "0.
|
|
108
|
-
"@zag-js/menu": "0.
|
|
109
|
-
"@zag-js/number-input": "0.
|
|
110
|
-
"@zag-js/pagination": "0.
|
|
111
|
-
"@zag-js/pin-input": "0.
|
|
112
|
-
"@zag-js/popover": "0.
|
|
113
|
-
"@zag-js/presence": "0.
|
|
114
|
-
"@zag-js/progress": "0.
|
|
115
|
-
"@zag-js/qr-code": "0.
|
|
116
|
-
"@zag-js/radio-group": "0.
|
|
117
|
-
"@zag-js/rating-group": "0.
|
|
118
|
-
"@zag-js/select": "0.
|
|
119
|
-
"@zag-js/signature-pad": "0.
|
|
120
|
-
"@zag-js/slider": "0.
|
|
121
|
-
"@zag-js/solid": "0.
|
|
122
|
-
"@zag-js/splitter": "0.
|
|
123
|
-
"@zag-js/steps": "0.
|
|
124
|
-
"@zag-js/switch": "0.
|
|
125
|
-
"@zag-js/tabs": "0.
|
|
126
|
-
"@zag-js/tags-input": "0.
|
|
127
|
-
"@zag-js/timer": "0.
|
|
128
|
-
"@zag-js/time-picker": "0.
|
|
129
|
-
"@zag-js/toast": "0.
|
|
130
|
-
"@zag-js/toggle-group": "0.
|
|
131
|
-
"@zag-js/tooltip": "0.
|
|
132
|
-
"@zag-js/tree-view": "0.
|
|
133
|
-
"@zag-js/types": "0.
|
|
89
|
+
"@zag-js/accordion": "0.73.0",
|
|
90
|
+
"@zag-js/anatomy": "0.73.0",
|
|
91
|
+
"@zag-js/avatar": "0.73.0",
|
|
92
|
+
"@zag-js/carousel": "0.73.0",
|
|
93
|
+
"@zag-js/checkbox": "0.73.0",
|
|
94
|
+
"@zag-js/clipboard": "0.73.0",
|
|
95
|
+
"@zag-js/collapsible": "0.73.0",
|
|
96
|
+
"@zag-js/collection": "0.73.0",
|
|
97
|
+
"@zag-js/color-picker": "0.73.0",
|
|
98
|
+
"@zag-js/combobox": "0.73.0",
|
|
99
|
+
"@zag-js/date-picker": "0.73.0",
|
|
100
|
+
"@zag-js/dialog": "0.73.0",
|
|
101
|
+
"@zag-js/dom-query": "0.73.0",
|
|
102
|
+
"@zag-js/editable": "0.73.0",
|
|
103
|
+
"@zag-js/file-upload": "0.73.0",
|
|
104
|
+
"@zag-js/highlight-word": "0.73.0",
|
|
105
|
+
"@zag-js/hover-card": "0.73.0",
|
|
106
|
+
"@zag-js/file-utils": "0.73.0",
|
|
107
|
+
"@zag-js/i18n-utils": "0.73.0",
|
|
108
|
+
"@zag-js/menu": "0.73.0",
|
|
109
|
+
"@zag-js/number-input": "0.73.0",
|
|
110
|
+
"@zag-js/pagination": "0.73.0",
|
|
111
|
+
"@zag-js/pin-input": "0.73.0",
|
|
112
|
+
"@zag-js/popover": "0.73.0",
|
|
113
|
+
"@zag-js/presence": "0.73.0",
|
|
114
|
+
"@zag-js/progress": "0.73.0",
|
|
115
|
+
"@zag-js/qr-code": "0.73.0",
|
|
116
|
+
"@zag-js/radio-group": "0.73.0",
|
|
117
|
+
"@zag-js/rating-group": "0.73.0",
|
|
118
|
+
"@zag-js/select": "0.73.0",
|
|
119
|
+
"@zag-js/signature-pad": "0.73.0",
|
|
120
|
+
"@zag-js/slider": "0.73.0",
|
|
121
|
+
"@zag-js/solid": "0.73.0",
|
|
122
|
+
"@zag-js/splitter": "0.73.0",
|
|
123
|
+
"@zag-js/steps": "0.73.0",
|
|
124
|
+
"@zag-js/switch": "0.73.0",
|
|
125
|
+
"@zag-js/tabs": "0.73.0",
|
|
126
|
+
"@zag-js/tags-input": "0.73.0",
|
|
127
|
+
"@zag-js/timer": "0.73.0",
|
|
128
|
+
"@zag-js/time-picker": "0.73.0",
|
|
129
|
+
"@zag-js/toast": "0.73.0",
|
|
130
|
+
"@zag-js/toggle-group": "0.73.0",
|
|
131
|
+
"@zag-js/tooltip": "0.73.0",
|
|
132
|
+
"@zag-js/tree-view": "0.73.0",
|
|
133
|
+
"@zag-js/types": "0.73.0"
|
|
134
134
|
},
|
|
135
135
|
"devDependencies": {
|
|
136
136
|
"@biomejs/biome": "1.9.2",
|
|
137
137
|
"@release-it/keep-a-changelog": "5.0.0",
|
|
138
138
|
"@solidjs/testing-library": "0.8.10",
|
|
139
|
-
"@storybook/addon-a11y": "8.3.
|
|
140
|
-
"@storybook/docs-tools": "8.3.
|
|
141
|
-
"@storybook/addon-essentials": "8.3.
|
|
139
|
+
"@storybook/addon-a11y": "8.3.4",
|
|
140
|
+
"@storybook/docs-tools": "8.3.4",
|
|
141
|
+
"@storybook/addon-essentials": "8.3.4",
|
|
142
142
|
"@testing-library/dom": "10.4.0",
|
|
143
143
|
"@testing-library/jest-dom": "6.5.0",
|
|
144
144
|
"@testing-library/user-event": "14.5.2",
|
|
145
145
|
"@types/jsdom": "21.1.7",
|
|
146
|
-
"@zag-js/stringify-state": "0.
|
|
146
|
+
"@zag-js/stringify-state": "0.73.0",
|
|
147
147
|
"globby": "14.0.2",
|
|
148
148
|
"jsdom": "25.0.1",
|
|
149
149
|
"lucide-solid": "0.446.0",
|
|
150
150
|
"release-it": "17.6.0",
|
|
151
151
|
"resize-observer-polyfill": "1.5.1",
|
|
152
|
-
"rollup": "4.22.
|
|
152
|
+
"rollup": "4.22.5",
|
|
153
153
|
"rollup-preset-solid": "2.0.1",
|
|
154
154
|
"solid-js": "1.9.1",
|
|
155
|
-
"storybook": "8.3.
|
|
155
|
+
"storybook": "8.3.4",
|
|
156
156
|
"storybook-solidjs": "1.0.0-beta.2",
|
|
157
157
|
"storybook-solidjs-vite": "1.0.0-beta.2",
|
|
158
158
|
"typescript": "5.6.2",
|