@ark-ui/solid 1.0.1 → 1.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/CHANGELOG.md +50 -0
- package/README.md +43 -40
- package/cjs/index.js +243 -31
- package/cjs/index.js.map +1 -1
- package/esm/index.js +228 -32
- package/esm/index.js.map +1 -1
- package/package.json +43 -40
- package/source/color-picker/color-picker-format-select.jsx +13 -0
- package/source/color-picker/color-picker-format-trigger.jsx +8 -0
- package/source/color-picker/color-picker-swatch-context.js +5 -0
- package/source/color-picker/color-picker-swatch-indicator.jsx +10 -0
- package/source/color-picker/color-picker-swatch-trigger.jsx +4 -1
- package/source/color-picker/color-picker-swatch.jsx +6 -3
- package/source/color-picker/color-picker.jsx +3 -1
- package/source/color-picker/index.js +7 -1
- package/source/dialog/dialog-close-trigger.jsx +1 -1
- package/source/file-upload/file-upload-context.js +5 -0
- package/source/file-upload/file-upload-dropzone.jsx +11 -0
- package/source/file-upload/file-upload-item-context.js +5 -0
- package/source/file-upload/file-upload-item-delete-trigger.jsx +10 -0
- package/source/file-upload/file-upload-item-group.jsx +10 -0
- package/source/file-upload/file-upload-item-name.jsx +12 -0
- package/source/file-upload/file-upload-item-preview.jsx +19 -0
- package/source/file-upload/file-upload-item-size-text.jsx +12 -0
- package/source/file-upload/file-upload-item.jsx +15 -0
- package/source/file-upload/file-upload-label.jsx +8 -0
- package/source/file-upload/file-upload-trigger.jsx +8 -0
- package/source/file-upload/file-upload.jsx +30 -0
- package/source/file-upload/index.js +24 -0
- package/source/file-upload/use-file-upload.js +10 -0
- package/source/index.jsx +1 -0
- package/source/number-input/number-input.jsx +4 -2
- package/source/toast/create-toaster.jsx +6 -7
- package/types/color-picker/color-picker-format-select.d.ts +4 -0
- package/types/color-picker/color-picker-format-trigger.d.ts +4 -0
- package/types/color-picker/color-picker-swatch-context.d.ts +4 -0
- package/types/color-picker/color-picker-swatch-indicator.d.ts +4 -0
- package/types/color-picker/color-picker-swatch-trigger.d.ts +1 -5
- package/types/color-picker/color-picker-transparency-grid.d.ts +2 -5
- package/types/color-picker/index.d.ts +10 -3
- package/types/color-picker/use-color-picker.d.ts +3 -0
- package/types/file-upload/file-upload-context.d.ts +4 -0
- package/types/file-upload/file-upload-dropzone.d.ts +4 -0
- package/types/file-upload/file-upload-item-context.d.ts +4 -0
- package/types/file-upload/file-upload-item-delete-trigger.d.ts +4 -0
- package/types/file-upload/file-upload-item-group.d.ts +8 -0
- package/types/file-upload/file-upload-item-name.d.ts +4 -0
- package/types/file-upload/file-upload-item-preview.d.ts +4 -0
- package/types/file-upload/file-upload-item-size-text.d.ts +4 -0
- package/types/file-upload/file-upload-item.d.ts +6 -0
- package/types/file-upload/file-upload-label.d.ts +4 -0
- package/types/file-upload/file-upload-trigger.d.ts +4 -0
- package/types/file-upload/file-upload.d.ts +9 -0
- package/types/file-upload/index.d.ts +25 -0
- package/types/file-upload/use-file-upload.d.ts +9 -0
- package/types/index.d.ts +1 -0
- package/types/number-input/number-input.d.ts +6 -3
- package/types/toast/create-toaster.d.ts +3 -2
- package/types/toast/toast-context.d.ts +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark-ui/solid",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.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",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"dialog",
|
|
14
14
|
"editable",
|
|
15
15
|
"environment",
|
|
16
|
+
"file upload",
|
|
16
17
|
"hover card",
|
|
17
18
|
"menu",
|
|
18
19
|
"number input",
|
|
@@ -79,39 +80,40 @@
|
|
|
79
80
|
"release-it": "release-it --config ../../../release-it.json"
|
|
80
81
|
},
|
|
81
82
|
"dependencies": {
|
|
82
|
-
"@ark-ui/anatomy": "1.
|
|
83
|
-
"@zag-js/accordion": "0.
|
|
84
|
-
"@zag-js/avatar": "0.
|
|
85
|
-
"@zag-js/carousel": "0.
|
|
86
|
-
"@zag-js/checkbox": "0.
|
|
87
|
-
"@zag-js/color-picker": "0.
|
|
88
|
-
"@zag-js/combobox": "0.
|
|
89
|
-
"@zag-js/date-picker": "0.
|
|
90
|
-
"@zag-js/dialog": "0.
|
|
91
|
-
"@zag-js/editable": "0.
|
|
92
|
-
"@zag-js/
|
|
93
|
-
"@zag-js/
|
|
94
|
-
"@zag-js/
|
|
95
|
-
"@zag-js/
|
|
96
|
-
"@zag-js/
|
|
97
|
-
"@zag-js/
|
|
98
|
-
"@zag-js/
|
|
99
|
-
"@zag-js/
|
|
100
|
-
"@zag-js/
|
|
101
|
-
"@zag-js/
|
|
102
|
-
"@zag-js/
|
|
103
|
-
"@zag-js/
|
|
104
|
-
"@zag-js/
|
|
105
|
-
"@zag-js/
|
|
106
|
-
"@zag-js/
|
|
107
|
-
"@zag-js/
|
|
108
|
-
"@zag-js/
|
|
109
|
-
"@zag-js/
|
|
110
|
-
"@zag-js/
|
|
111
|
-
"@zag-js/
|
|
83
|
+
"@ark-ui/anatomy": "1.1.0",
|
|
84
|
+
"@zag-js/accordion": "0.30.0",
|
|
85
|
+
"@zag-js/avatar": "0.30.0",
|
|
86
|
+
"@zag-js/carousel": "0.30.0",
|
|
87
|
+
"@zag-js/checkbox": "0.30.0",
|
|
88
|
+
"@zag-js/color-picker": "0.30.0",
|
|
89
|
+
"@zag-js/combobox": "0.30.0",
|
|
90
|
+
"@zag-js/date-picker": "0.30.0",
|
|
91
|
+
"@zag-js/dialog": "0.30.0",
|
|
92
|
+
"@zag-js/editable": "0.30.0",
|
|
93
|
+
"@zag-js/file-upload": "0.30.0",
|
|
94
|
+
"@zag-js/hover-card": "0.30.0",
|
|
95
|
+
"@zag-js/menu": "0.30.0",
|
|
96
|
+
"@zag-js/number-input": "0.30.0",
|
|
97
|
+
"@zag-js/pagination": "0.30.0",
|
|
98
|
+
"@zag-js/pin-input": "0.30.0",
|
|
99
|
+
"@zag-js/popover": "0.30.0",
|
|
100
|
+
"@zag-js/presence": "0.30.0",
|
|
101
|
+
"@zag-js/radio-group": "0.30.0",
|
|
102
|
+
"@zag-js/rating-group": "0.30.0",
|
|
103
|
+
"@zag-js/select": "0.30.0",
|
|
104
|
+
"@zag-js/slider": "0.30.0",
|
|
105
|
+
"@zag-js/solid": "0.30.0",
|
|
106
|
+
"@zag-js/splitter": "0.30.0",
|
|
107
|
+
"@zag-js/switch": "0.30.0",
|
|
108
|
+
"@zag-js/tabs": "0.30.0",
|
|
109
|
+
"@zag-js/tags-input": "0.30.0",
|
|
110
|
+
"@zag-js/toast": "0.30.0",
|
|
111
|
+
"@zag-js/toggle-group": "0.30.0",
|
|
112
|
+
"@zag-js/tooltip": "0.30.0",
|
|
113
|
+
"@zag-js/types": "0.30.0"
|
|
112
114
|
},
|
|
113
115
|
"devDependencies": {
|
|
114
|
-
"@release-it/keep-a-changelog": "
|
|
116
|
+
"@release-it/keep-a-changelog": "5.0.0",
|
|
115
117
|
"@solidjs/testing-library": "0.8.4",
|
|
116
118
|
"@storybook/addon-essentials": "7.5.3",
|
|
117
119
|
"@storybook/addon-interactions": "7.5.3",
|
|
@@ -121,25 +123,26 @@
|
|
|
121
123
|
"@testing-library/dom": "9.3.3",
|
|
122
124
|
"@testing-library/jest-dom": "6.1.4",
|
|
123
125
|
"@testing-library/user-event": "14.5.1",
|
|
124
|
-
"@types/jsdom": "21.1.
|
|
126
|
+
"@types/jsdom": "21.1.6",
|
|
125
127
|
"@types/testing-library__jest-dom": "5.14.9",
|
|
126
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
127
|
-
"@typescript-eslint/parser": "6.
|
|
128
|
+
"@typescript-eslint/eslint-plugin": "6.12.0",
|
|
129
|
+
"@typescript-eslint/parser": "6.12.0",
|
|
128
130
|
"@vitest/coverage-v8": "0.34.6",
|
|
129
|
-
"eslint": "8.
|
|
130
|
-
"globby": "
|
|
131
|
+
"eslint": "8.54.0",
|
|
132
|
+
"globby": "14.0.0",
|
|
131
133
|
"jsdom": "22.1.0",
|
|
134
|
+
"lucide-solid": "0.292.0",
|
|
132
135
|
"react": "18.2.0",
|
|
133
136
|
"react-dom": "18.2.0",
|
|
134
|
-
"release-it": "
|
|
137
|
+
"release-it": "17.0.0",
|
|
135
138
|
"resize-observer-polyfill": "1.5.1",
|
|
136
|
-
"rollup": "4.
|
|
139
|
+
"rollup": "4.5.0",
|
|
137
140
|
"rollup-preset-solid": "2.0.1",
|
|
138
141
|
"solid-js": "1.8.5",
|
|
139
142
|
"storybook": "7.5.3",
|
|
140
143
|
"storybook-solidjs": "1.0.0-beta.2",
|
|
141
144
|
"storybook-solidjs-vite": "1.0.0-beta.2",
|
|
142
|
-
"typescript": "5.
|
|
145
|
+
"typescript": "5.3.2",
|
|
143
146
|
"vite": "4.5.0",
|
|
144
147
|
"vite-plugin-solid": "2.7.2",
|
|
145
148
|
"vitest": "0.34.2"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { Index } from 'solid-js';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useColorPickerContext } from './color-picker-context';
|
|
5
|
+
export const ColorPickerFormatSelect = (props) => {
|
|
6
|
+
const api = useColorPickerContext();
|
|
7
|
+
const mergedProps = mergeProps(() => api().formatSelectProps, props);
|
|
8
|
+
return (<ark.select {...mergedProps}>
|
|
9
|
+
<Index each={['rgba', 'hsla', 'hsba']}>
|
|
10
|
+
{(format) => <ark.option value={format()}>{format()}</ark.option>}
|
|
11
|
+
</Index>
|
|
12
|
+
</ark.select>);
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useColorPickerContext } from './color-picker-context';
|
|
4
|
+
export const ColorPickerFormatTrigger = (props) => {
|
|
5
|
+
const api = useColorPickerContext();
|
|
6
|
+
const mergedProps = mergeProps(() => api().formatTriggerProps, props);
|
|
7
|
+
return <ark.button {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useColorPickerContext } from './color-picker-context';
|
|
4
|
+
import { useColorPickerSwatchContext } from './color-picker-swatch-context';
|
|
5
|
+
export const ColorPickerSwatchIndicator = (props) => {
|
|
6
|
+
const api = useColorPickerContext();
|
|
7
|
+
const swatchProps = useColorPickerSwatchContext();
|
|
8
|
+
const mergedProps = mergeProps(() => api().getSwatchIndicatorProps(swatchProps), props);
|
|
9
|
+
return <ark.div {...mergedProps}/>;
|
|
10
|
+
};
|
|
@@ -3,7 +3,10 @@ import { createSplitProps } from '../create-split-props';
|
|
|
3
3
|
import { ark } from '../factory';
|
|
4
4
|
import { useColorPickerContext } from './color-picker-context';
|
|
5
5
|
export const ColorPickerSwatchTrigger = (props) => {
|
|
6
|
-
const [triggerProps, localProps] = createSplitProps()(props, [
|
|
6
|
+
const [triggerProps, localProps] = createSplitProps()(props, [
|
|
7
|
+
'value',
|
|
8
|
+
'disabled',
|
|
9
|
+
]);
|
|
7
10
|
const api = useColorPickerContext();
|
|
8
11
|
const mergedProps = mergeProps(() => api().getSwatchTriggerProps(triggerProps), localProps);
|
|
9
12
|
return <ark.button {...mergedProps}/>;
|
|
@@ -2,12 +2,15 @@ import { mergeProps } from '@zag-js/solid';
|
|
|
2
2
|
import { createSplitProps } from '../create-split-props';
|
|
3
3
|
import { ark } from '../factory';
|
|
4
4
|
import { useColorPickerContext } from './color-picker-context';
|
|
5
|
+
import { ColorPickerSwatchProvider } from './color-picker-swatch-context';
|
|
5
6
|
export const ColorPickerSwatch = (props) => {
|
|
6
|
-
const [
|
|
7
|
+
const [swatchProps, localProps] = createSplitProps()(props, [
|
|
7
8
|
'respectAlpha',
|
|
8
9
|
'value',
|
|
9
10
|
]);
|
|
10
11
|
const api = useColorPickerContext();
|
|
11
|
-
const mergedProps = mergeProps(() => api().getSwatchProps(
|
|
12
|
-
return <
|
|
12
|
+
const mergedProps = mergeProps(() => api().getSwatchProps(swatchProps), localProps);
|
|
13
|
+
return (<ColorPickerSwatchProvider value={swatchProps}>
|
|
14
|
+
<ark.div {...mergedProps}/>
|
|
15
|
+
</ColorPickerSwatchProvider>);
|
|
13
16
|
};
|
|
@@ -8,9 +8,10 @@ import { useColorPicker, } from './use-color-picker';
|
|
|
8
8
|
export const ColorPicker = (props) => {
|
|
9
9
|
const [presenceProps, colorPickerProps] = splitPresenceProps(props);
|
|
10
10
|
const [useColorPickerProps, localProps] = createSplitProps()(colorPickerProps, [
|
|
11
|
-
'
|
|
11
|
+
'closeOnSelect',
|
|
12
12
|
'dir',
|
|
13
13
|
'disabled',
|
|
14
|
+
'format',
|
|
14
15
|
'getRootNode',
|
|
15
16
|
'id',
|
|
16
17
|
'ids',
|
|
@@ -18,6 +19,7 @@ export const ColorPicker = (props) => {
|
|
|
18
19
|
'name',
|
|
19
20
|
'name',
|
|
20
21
|
'onFocusOutside',
|
|
22
|
+
'onFormatChange',
|
|
21
23
|
'onInteractOutside',
|
|
22
24
|
'onOpenChange',
|
|
23
25
|
'onPointerDownOutside',
|
|
@@ -12,10 +12,13 @@ import { ColorPickerContent } from './color-picker-content';
|
|
|
12
12
|
import { useColorPickerContext } from './color-picker-context';
|
|
13
13
|
import { ColorPickerControl } from './color-picker-control';
|
|
14
14
|
import { ColorPickerEyeDropperTrigger, } from './color-picker-eye-dropper-trigger';
|
|
15
|
+
import { ColorPickerFormatSelect, } from './color-picker-format-select';
|
|
16
|
+
import { ColorPickerFormatTrigger, } from './color-picker-format-trigger';
|
|
15
17
|
import { ColorPickerLabel } from './color-picker-label';
|
|
16
18
|
import { ColorPickerPositioner } from './color-picker-positioner';
|
|
17
19
|
import { ColorPickerSwatch } from './color-picker-swatch';
|
|
18
20
|
import { ColorPickerSwatchGroup, } from './color-picker-swatch-group';
|
|
21
|
+
import { ColorPickerSwatchIndicator, } from './color-picker-swatch-indicator';
|
|
19
22
|
import { ColorPickerSwatchTrigger, } from './color-picker-swatch-trigger';
|
|
20
23
|
import { ColorPickerTransparencyGrid, } from './color-picker-transparency-grid';
|
|
21
24
|
import { ColorPickerTrigger } from './color-picker-trigger';
|
|
@@ -33,14 +36,17 @@ const ColorPicker = Object.assign(ColorPickerRoot, {
|
|
|
33
36
|
Content: ColorPickerContent,
|
|
34
37
|
Control: ColorPickerControl,
|
|
35
38
|
EyeDropperTrigger: ColorPickerEyeDropperTrigger,
|
|
39
|
+
FormatTrigger: ColorPickerFormatTrigger,
|
|
40
|
+
FormatSelect: ColorPickerFormatSelect,
|
|
36
41
|
Label: ColorPickerLabel,
|
|
37
42
|
Positioner: ColorPickerPositioner,
|
|
38
43
|
Swatch: ColorPickerSwatch,
|
|
39
44
|
SwatchGroup: ColorPickerSwatchGroup,
|
|
45
|
+
SwatchIndicator: ColorPickerSwatchIndicator,
|
|
40
46
|
SwatchTrigger: ColorPickerSwatchTrigger,
|
|
41
47
|
TransparencyGrid: ColorPickerTransparencyGrid,
|
|
42
48
|
Trigger: ColorPickerTrigger,
|
|
43
49
|
ValueText: ColorPickerValueText,
|
|
44
50
|
View: ColorPickerView,
|
|
45
51
|
});
|
|
46
|
-
export { ColorPicker, ColorPickerArea, ColorPickerAreaBackground, ColorPickerAreaThumb, ColorPickerChannelInput, ColorPickerChannelSlider, ColorPickerChannelSliderThumb, ColorPickerChannelSliderTrack, ColorPickerContent, ColorPickerControl, ColorPickerEyeDropperTrigger, ColorPickerLabel, ColorPickerPositioner, ColorPickerSwatch, ColorPickerSwatchGroup, ColorPickerSwatchTrigger, ColorPickerTransparencyGrid, ColorPickerTrigger, ColorPickerValueText, useColorPickerAreaContext, useColorPickerChannelSliderContext, useColorPickerContext, };
|
|
52
|
+
export { ColorPicker, ColorPickerArea, ColorPickerAreaBackground, ColorPickerAreaThumb, ColorPickerChannelInput, ColorPickerChannelSlider, ColorPickerChannelSliderThumb, ColorPickerChannelSliderTrack, ColorPickerContent, ColorPickerControl, ColorPickerEyeDropperTrigger, ColorPickerFormatSelect, ColorPickerFormatTrigger, ColorPickerLabel, ColorPickerPositioner, ColorPickerSwatch, ColorPickerSwatchGroup, ColorPickerSwatchIndicator, ColorPickerSwatchTrigger, ColorPickerTransparencyGrid, ColorPickerTrigger, ColorPickerValueText, ColorPickerView, useColorPickerAreaContext, useColorPickerChannelSliderContext, useColorPickerContext, };
|
|
@@ -3,6 +3,6 @@ import { ark } from '../factory';
|
|
|
3
3
|
import { useDialogContext } from './dialog-context';
|
|
4
4
|
export const DialogCloseTrigger = (props) => {
|
|
5
5
|
const dialog = useDialogContext();
|
|
6
|
-
const mergedProps = mergeProps(() => dialog().
|
|
6
|
+
const mergedProps = mergeProps(() => dialog().closeTriggerProps, props);
|
|
7
7
|
return <ark.button {...mergedProps}/>;
|
|
8
8
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useFileUploadContext } from './file-upload-context';
|
|
4
|
+
export const FileUploadDropzone = (props) => {
|
|
5
|
+
const api = useFileUploadContext();
|
|
6
|
+
const mergedProps = mergeProps(() => api().dropzoneProps, props);
|
|
7
|
+
return (<>
|
|
8
|
+
<ark.div {...mergedProps}/>
|
|
9
|
+
<input {...api().hiddenInputProps}/>
|
|
10
|
+
</>);
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useFileUploadContext } from './file-upload-context';
|
|
4
|
+
import { useFileUploadItemContext } from './file-upload-item-context';
|
|
5
|
+
export const FileUploadItemDeleteTrigger = (props) => {
|
|
6
|
+
const api = useFileUploadContext();
|
|
7
|
+
const item = useFileUploadItemContext();
|
|
8
|
+
const mergedProps = mergeProps(() => api().getItemDeleteTriggerProps(item), props);
|
|
9
|
+
return <ark.button {...mergedProps}/>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { runIfFn } from '../run-if-fn';
|
|
4
|
+
import { useFileUploadContext } from './file-upload-context';
|
|
5
|
+
export const FileUploadItemGroup = (props) => {
|
|
6
|
+
const api = useFileUploadContext();
|
|
7
|
+
const mergedProps = mergeProps(() => api().itemGroupProps, props);
|
|
8
|
+
const getChildren = () => runIfFn(props.children, () => api().files);
|
|
9
|
+
return <ark.ul {...mergedProps}>{getChildren()}</ark.ul>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { children } from 'solid-js';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useFileUploadContext } from './file-upload-context';
|
|
5
|
+
import { useFileUploadItemContext } from './file-upload-item-context';
|
|
6
|
+
export const FileUploadItemName = (props) => {
|
|
7
|
+
const api = useFileUploadContext();
|
|
8
|
+
const item = useFileUploadItemContext();
|
|
9
|
+
const mergedProps = mergeProps(() => api().getItemNameProps(item), props);
|
|
10
|
+
const getChildren = children(() => props.children);
|
|
11
|
+
return <ark.div {...mergedProps}>{getChildren() || item.file.name}</ark.div>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSignal } from 'solid-js';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useFileUploadContext } from './file-upload-context';
|
|
5
|
+
import { useFileUploadItemContext } from './file-upload-item-context';
|
|
6
|
+
export const FileUploadItemPreview = (props) => {
|
|
7
|
+
const api = useFileUploadContext();
|
|
8
|
+
const item = useFileUploadItemContext();
|
|
9
|
+
const [url, setUrl] = createSignal('');
|
|
10
|
+
api().createFileUrl(item.file, (url) => setUrl(url));
|
|
11
|
+
try {
|
|
12
|
+
const mergedProps = mergeProps(api().getItemPreviewProps({ ...item, url: url() }), props);
|
|
13
|
+
return <ark.img {...mergedProps}/>;
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
// TODO We could render a fallback component
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { children } from 'solid-js';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useFileUploadContext } from './file-upload-context';
|
|
5
|
+
import { useFileUploadItemContext } from './file-upload-item-context';
|
|
6
|
+
export const FileUploadItemSizeText = (props) => {
|
|
7
|
+
const api = useFileUploadContext();
|
|
8
|
+
const item = useFileUploadItemContext();
|
|
9
|
+
const mergedProps = mergeProps(() => api().getItemSizeTextProps(item), props);
|
|
10
|
+
const getChildren = children(() => props.children);
|
|
11
|
+
return <ark.div {...mergedProps}>{getChildren() || api().getFileSize(item.file)}</ark.div>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { runIfFn } from '../run-if-fn';
|
|
5
|
+
import { useFileUploadContext } from './file-upload-context';
|
|
6
|
+
import { FileUploadItemProvider } from './file-upload-item-context';
|
|
7
|
+
export const FileUploadItem = (props) => {
|
|
8
|
+
const [itemProps, localProps] = createSplitProps()(props, ['file']);
|
|
9
|
+
const api = useFileUploadContext();
|
|
10
|
+
const mergedProps = mergeProps(() => api().getItemProps(itemProps), localProps);
|
|
11
|
+
const getChildren = () => runIfFn(localProps.children);
|
|
12
|
+
return (<FileUploadItemProvider value={itemProps}>
|
|
13
|
+
<ark.li {...mergedProps}>{getChildren()}</ark.li>
|
|
14
|
+
</FileUploadItemProvider>);
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useFileUploadContext } from './file-upload-context';
|
|
4
|
+
export const FileUploadLabel = (props) => {
|
|
5
|
+
const api = useFileUploadContext();
|
|
6
|
+
const mergedProps = mergeProps(() => api().labelProps, props);
|
|
7
|
+
return <ark.label {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useFileUploadContext } from './file-upload-context';
|
|
4
|
+
export const FileUploadTrigger = (props) => {
|
|
5
|
+
const api = useFileUploadContext();
|
|
6
|
+
const mergedProps = mergeProps(() => api().triggerProps, props);
|
|
7
|
+
return <ark.button {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { runIfFn } from '../run-if-fn';
|
|
5
|
+
import { FileUploadProvider } from './file-upload-context';
|
|
6
|
+
import { useFileUpload } from './use-file-upload';
|
|
7
|
+
export const FileUpload = (props) => {
|
|
8
|
+
const [fileUploadProps, localProps] = createSplitProps()(props, [
|
|
9
|
+
'accept',
|
|
10
|
+
'allowDrop',
|
|
11
|
+
'dir',
|
|
12
|
+
'disabled',
|
|
13
|
+
'files',
|
|
14
|
+
'getRootNode',
|
|
15
|
+
'id',
|
|
16
|
+
'isValidFile',
|
|
17
|
+
'locale',
|
|
18
|
+
'maxFiles',
|
|
19
|
+
'maxFileSize',
|
|
20
|
+
'minFileSize',
|
|
21
|
+
'name',
|
|
22
|
+
'onFilesChange',
|
|
23
|
+
]);
|
|
24
|
+
const api = useFileUpload(fileUploadProps);
|
|
25
|
+
const mergedProps = mergeProps(() => api().rootProps, localProps);
|
|
26
|
+
const getChildren = () => runIfFn(localProps.children, api);
|
|
27
|
+
return (<FileUploadProvider value={api}>
|
|
28
|
+
<ark.div {...mergedProps}>{getChildren()}</ark.div>
|
|
29
|
+
</FileUploadProvider>);
|
|
30
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FileUpload as FileUploadRoot } from './file-upload';
|
|
2
|
+
import { useFileUploadContext } from './file-upload-context';
|
|
3
|
+
import { FileUploadDropzone } from './file-upload-dropzone';
|
|
4
|
+
import { FileUploadItem } from './file-upload-item';
|
|
5
|
+
import { FileUploadItemDeleteTrigger, } from './file-upload-item-delete-trigger';
|
|
6
|
+
import { FileUploadItemGroup } from './file-upload-item-group';
|
|
7
|
+
import { FileUploadItemName } from './file-upload-item-name';
|
|
8
|
+
import { FileUploadItemPreview } from './file-upload-item-preview';
|
|
9
|
+
import { FileUploadItemSizeText, } from './file-upload-item-size-text';
|
|
10
|
+
import { FileUploadLabel } from './file-upload-label';
|
|
11
|
+
import { FileUploadTrigger } from './file-upload-trigger';
|
|
12
|
+
const FileUpload = Object.assign(FileUploadRoot, {
|
|
13
|
+
Root: FileUploadRoot,
|
|
14
|
+
Dropzone: FileUploadDropzone,
|
|
15
|
+
Label: FileUploadLabel,
|
|
16
|
+
Trigger: FileUploadTrigger,
|
|
17
|
+
ItemGroup: FileUploadItemGroup,
|
|
18
|
+
Item: FileUploadItem,
|
|
19
|
+
ItemName: FileUploadItemName,
|
|
20
|
+
ItemPreview: FileUploadItemPreview,
|
|
21
|
+
ItemSizeText: FileUploadItemSizeText,
|
|
22
|
+
ItemDeleteTrigger: FileUploadItemDeleteTrigger,
|
|
23
|
+
});
|
|
24
|
+
export { FileUpload, FileUploadDropzone, FileUploadItem, FileUploadItemDeleteTrigger, FileUploadItemGroup, FileUploadItemName, FileUploadItemPreview, FileUploadItemSizeText, FileUploadLabel, FileUploadTrigger, useFileUploadContext, };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as fileUpload from '@zag-js/file-upload';
|
|
2
|
+
import { mergeProps, normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
|
+
import { createMemo, createUniqueId } from 'solid-js';
|
|
4
|
+
import { useEnvironmentContext } from '../environment';
|
|
5
|
+
export const useFileUpload = (props) => {
|
|
6
|
+
const getRootNode = useEnvironmentContext();
|
|
7
|
+
const context = mergeProps({ id: createUniqueId(), getRootNode }, props);
|
|
8
|
+
const [state, send] = useMachine(fileUpload.machine(context), { context });
|
|
9
|
+
return createMemo(() => fileUpload.connect(state, send, normalizeProps));
|
|
10
|
+
};
|
package/source/index.jsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { mergeProps } from '@zag-js/solid';
|
|
2
2
|
import { createSplitProps } from '../create-split-props';
|
|
3
3
|
import { ark } from '../factory';
|
|
4
|
+
import { runIfFn } from '../run-if-fn';
|
|
4
5
|
import { NumberInputProvider } from './number-input-context';
|
|
5
|
-
import { useNumberInput } from './use-number-input';
|
|
6
|
+
import { useNumberInput, } from './use-number-input';
|
|
6
7
|
export const NumberInput = (props) => {
|
|
7
8
|
const [useNumberInputProps, localProps] = createSplitProps()(props, [
|
|
8
9
|
'allowMouseWheel',
|
|
@@ -34,7 +35,8 @@ export const NumberInput = (props) => {
|
|
|
34
35
|
]);
|
|
35
36
|
const api = useNumberInput(useNumberInputProps);
|
|
36
37
|
const mergedProps = mergeProps(() => api().rootProps, localProps);
|
|
38
|
+
const getChildren = () => runIfFn(localProps.children, api);
|
|
37
39
|
return (<NumberInputProvider value={api}>
|
|
38
|
-
<ark.div {...mergedProps}
|
|
40
|
+
<ark.div {...mergedProps}>{getChildren()}</ark.div>
|
|
39
41
|
</NumberInputProvider>);
|
|
40
42
|
};
|
|
@@ -5,19 +5,18 @@ import { useEnvironmentContext } from '../environment';
|
|
|
5
5
|
import { ark } from '../factory';
|
|
6
6
|
import { ToastProvider } from './toast-context';
|
|
7
7
|
export const createToaster = (props) => {
|
|
8
|
-
const {
|
|
9
|
-
const service = toast.group.machine({ id: '1', placement, ...rest }).start();
|
|
8
|
+
const service = toast.group.machine({ id: '1', ...props }).start();
|
|
10
9
|
const [state, send] = useActor(service);
|
|
11
10
|
const api = createMemo(() => toast.group.connect(state, send, normalizeProps));
|
|
12
|
-
const Toaster = (
|
|
11
|
+
const Toaster = (toasterProps) => {
|
|
13
12
|
const getRootNode = useEnvironmentContext();
|
|
14
13
|
createEffect(() => {
|
|
15
14
|
service.setContext({ getRootNode });
|
|
16
15
|
onCleanup(() => service.stop());
|
|
17
16
|
});
|
|
18
|
-
const mergedProps = mergeProps(() => api().getGroupProps({ placement }),
|
|
17
|
+
const mergedProps = mergeProps(() => api().getGroupProps({ placement: props.placement }), toasterProps);
|
|
19
18
|
return (<ark.ol {...mergedProps}>
|
|
20
|
-
<Index each={api().toastsByPlacement[placement]}>
|
|
19
|
+
<Index each={api().toastsByPlacement[props.placement]}>
|
|
21
20
|
{(toast) => <ToastProviderFactory service={toast()}/>}
|
|
22
21
|
</Index>
|
|
23
22
|
</ark.ol>);
|
|
@@ -26,6 +25,6 @@ export const createToaster = (props) => {
|
|
|
26
25
|
};
|
|
27
26
|
const ToastProviderFactory = (props) => {
|
|
28
27
|
const [state, send] = useActor(props.service);
|
|
29
|
-
const api = toast.connect(state, send, normalizeProps);
|
|
30
|
-
return <ToastProvider value={
|
|
28
|
+
const api = createMemo(() => toast.connect(state, send, normalizeProps));
|
|
29
|
+
return <ToastProvider value={api}>{state.context.render?.(api)}</ToastProvider>;
|
|
31
30
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SwatchProps } from '@zag-js/color-picker';
|
|
2
|
+
export interface ColorPickerSwatchContext extends SwatchProps {
|
|
3
|
+
}
|
|
4
|
+
export declare const ColorPickerSwatchProvider: import("solid-js").ContextProviderComponent<ColorPickerSwatchContext>, useColorPickerSwatchContext: () => ColorPickerSwatchContext;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SwatchTriggerProps } from '@zag-js/color-picker';
|
|
2
2
|
import { type HTMLArkProps } from '../factory';
|
|
3
3
|
import type { Assign } from '../types';
|
|
4
|
-
interface SwatchTriggerProps {
|
|
5
|
-
value: string | Color;
|
|
6
|
-
}
|
|
7
4
|
export interface ColorPickerSwatchTriggerProps extends Assign<HTMLArkProps<'button'>, SwatchTriggerProps> {
|
|
8
5
|
}
|
|
9
6
|
export declare const ColorPickerSwatchTrigger: (props: ColorPickerSwatchTriggerProps) => import("solid-js").JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import type { TransparencyGridProps } from '@zag-js/color-picker';
|
|
1
2
|
import { type HTMLArkProps } from '../factory';
|
|
2
3
|
import type { Assign } from '../types';
|
|
3
|
-
interface
|
|
4
|
-
size: string;
|
|
5
|
-
}
|
|
6
|
-
export interface ColorPickerTransparencyGridProps extends Assign<HTMLArkProps<'div'>, TransparancyGridProps> {
|
|
4
|
+
export interface ColorPickerTransparencyGridProps extends Assign<HTMLArkProps<'div'>, TransparencyGridProps> {
|
|
7
5
|
}
|
|
8
6
|
export declare const ColorPickerTransparencyGrid: (props: ColorPickerTransparencyGridProps) => import("solid-js").JSX.Element;
|
|
9
|
-
export {};
|