@ark-ui/react 1.1.0 → 1.2.1
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 +25 -0
- package/README.md +29 -16
- package/color-picker/color-picker.cjs +1 -1
- package/color-picker/color-picker.mjs +1 -1
- package/combobox/combobox.cjs +1 -1
- package/combobox/combobox.d.ts +1 -1
- package/combobox/combobox.mjs +1 -1
- package/date-picker/date-picker.cjs +2 -2
- package/date-picker/date-picker.mjs +2 -2
- package/date-picker/date-picker.stories.d.ts +1 -0
- package/dialog/dialog-backdrop.cjs +1 -1
- package/dialog/dialog-backdrop.mjs +1 -1
- package/dialog/dialog.cjs +2 -1
- package/dialog/dialog.mjs +2 -1
- package/editable/editable.cjs +2 -2
- package/editable/editable.mjs +2 -2
- package/factory.cjs +1 -2
- package/factory.d.ts +1 -1
- package/factory.mjs +2 -3
- package/factory.test.d.ts +1 -0
- package/file-upload/file-upload-item-preview-image.cjs +25 -0
- package/file-upload/file-upload-item-preview-image.d.ts +6 -0
- package/file-upload/file-upload-item-preview-image.mjs +21 -0
- package/file-upload/file-upload-item-preview.cjs +3 -9
- package/file-upload/file-upload-item-preview.d.ts +6 -1
- package/file-upload/file-upload-item-preview.mjs +4 -10
- package/file-upload/file-upload.cjs +6 -2
- package/file-upload/file-upload.mjs +6 -2
- package/file-upload/index.cjs +7 -5
- package/file-upload/index.d.ts +9 -7
- package/file-upload/index.mjs +7 -5
- package/file-upload/use-file-upload.cjs +2 -1
- package/file-upload/use-file-upload.mjs +2 -1
- package/hover-card/hover-card.cjs +2 -1
- package/hover-card/hover-card.mjs +2 -1
- package/index.cjs +8 -6
- package/index.mjs +4 -3
- package/menu/menu.cjs +4 -3
- package/menu/menu.mjs +2 -1
- package/number-input/index.cjs +3 -3
- package/number-input/index.d.ts +1 -1
- package/number-input/index.mjs +1 -1
- package/number-input/number-input.cjs +30 -33
- package/number-input/number-input.mjs +30 -33
- package/package.json +67 -55
- package/pagination/pagination-item.cjs +1 -1
- package/pagination/pagination-item.mjs +1 -1
- package/pagination/pagination.cjs +2 -2
- package/pagination/pagination.mjs +2 -2
- package/pin-input/index.cjs +3 -3
- package/pin-input/index.d.ts +1 -1
- package/pin-input/index.mjs +1 -1
- package/pin-input/pin-input.cjs +2 -2
- package/pin-input/pin-input.mjs +2 -2
- package/popover/popover.cjs +2 -1
- package/popover/popover.mjs +2 -1
- package/portal.cjs +2 -1
- package/portal.d.ts +2 -2
- package/portal.mjs +2 -1
- package/radio-group/radio-group-indicator.cjs +1 -2
- package/radio-group/radio-group-indicator.mjs +1 -2
- package/radio-group/radio-group-item.d.ts +1 -1
- package/radio-group/radio-group.cjs +2 -2
- package/radio-group/radio-group.mjs +2 -2
- package/rating-group/rating-group-control.cjs +2 -2
- package/rating-group/rating-group-control.mjs +2 -2
- package/rating-group/rating-group-item-context.d.ts +2 -2
- package/rating-group/rating-group-item.cjs +5 -4
- package/rating-group/rating-group-item.mjs +5 -4
- package/rating-group/rating-group.cjs +2 -2
- package/rating-group/rating-group.mjs +2 -2
- package/rating-group/use-rating-group.cjs +4 -4
- package/rating-group/use-rating-group.d.ts +4 -4
- package/rating-group/use-rating-group.mjs +3 -3
- package/segment-group/segment-group-indicator.cjs +2 -2
- package/segment-group/segment-group-indicator.mjs +2 -2
- package/segment-group/segment-group-item-context.d.ts +1 -13
- package/segment-group/segment-group-item-control.cjs +2 -2
- package/segment-group/segment-group-item-control.mjs +2 -2
- package/segment-group/segment-group-item-text.cjs +2 -2
- package/segment-group/segment-group-item-text.mjs +2 -2
- package/segment-group/segment-group-item.cjs +3 -3
- package/segment-group/segment-group-item.d.ts +3 -2
- package/segment-group/segment-group-item.mjs +3 -3
- package/segment-group/segment-group-label.cjs +2 -2
- package/segment-group/segment-group-label.mjs +2 -2
- package/segment-group/segment-group.cjs +4 -4
- package/segment-group/segment-group.mjs +4 -4
- package/select/select-item-group.cjs +2 -2
- package/select/select-item-group.mjs +2 -2
- package/select/select.cjs +1 -1
- package/select/select.d.ts +1 -1
- package/select/select.mjs +1 -1
- package/switch/switch.cjs +2 -2
- package/switch/switch.mjs +2 -2
- package/toast/create-toaster.cjs +2 -2
- package/toast/create-toaster.d.ts +1 -1
- package/toast/create-toaster.mjs +2 -2
- package/toast/index.cjs +5 -2
- package/toast/index.d.ts +6 -4
- package/toast/index.mjs +5 -3
- package/toast/toast-group.cjs +15 -0
- package/toast/toast-group.d.ts +6 -0
- package/toast/toast-group.mjs +11 -0
- package/tooltip/tooltip.cjs +2 -1
- package/tooltip/tooltip.mjs +2 -1
- package/use-is-server.cjs +16 -0
- package/use-is-server.d.ts +1 -0
- package/use-is-server.mjs +12 -0
- package/segment-group/segment-group.anatomy.cjs +0 -10
- package/segment-group/segment-group.anatomy.d.ts +0 -2
- package/segment-group/segment-group.anatomy.mjs +0 -6
- /package/number-input/{number-input-field.cjs → number-input-input.cjs} +0 -0
- /package/number-input/{number-input-field.d.ts → number-input-input.d.ts} +0 -0
- /package/number-input/{number-input-field.mjs → number-input-input.mjs} +0 -0
- /package/pin-input/{pin-input-field.cjs → pin-input-input.cjs} +0 -0
- /package/pin-input/{pin-input-field.d.ts → pin-input-input.d.ts} +0 -0
- /package/pin-input/{pin-input-field.mjs → pin-input-input.mjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,31 @@ description: All notable changes to this project will be documented in this file
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.2.1] - 2023-12-13
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Resolved an issue where the `ark` factory type was not being exported correctly.
|
|
14
|
+
|
|
15
|
+
## [1.2.0] - 2023-12-13
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Added the `ToastGroup` component.
|
|
20
|
+
- Added entrypoint for the `ark` factory at `@ark-ui/react/factory`
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Revised the `FileUpload` component. Check out the [documentation](https://ark-ui.com/docs/components/file-upload) for more information.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- Added an explicit return type for the `Portal` component to resolve an issue with online code editors.
|
|
29
|
+
- Resolved an issue where the `present` prop in the disclosure-type component was not being respected.
|
|
30
|
+
- Resolved an issue where the `ark` function would log a warning when the `asChild` prop was set to `false`.
|
|
31
|
+
- Fixed an issue where keyboard interactions within a submenu would bubble up to the parent `Menu`.
|
|
32
|
+
- Fixed an issue with hydration mismatch in the `Portal` component.
|
|
33
|
+
|
|
9
34
|
## [1.1.0] - 2023-11-21
|
|
10
35
|
|
|
11
36
|
### Added
|
package/README.md
CHANGED
|
@@ -62,22 +62,35 @@ To use a component from `@ark-ui/react`, import it and include it in your applic
|
|
|
62
62
|
|
|
63
63
|
```tsx
|
|
64
64
|
import { Slider, type SliderProps } from '@ark-ui/react'
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
65
|
+
import { useState } from 'react'
|
|
66
|
+
|
|
67
|
+
export const MySlider = (props: SliderProps) => {
|
|
68
|
+
const [value, setValue] = useState([42])
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<Slider.Root
|
|
72
|
+
min={0}
|
|
73
|
+
max={100}
|
|
74
|
+
value={value}
|
|
75
|
+
onValueChange={(e) => setValue(e.value)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
<Slider.Label>Label</Slider.Label>
|
|
79
|
+
<Slider.ValueText />
|
|
80
|
+
<Slider.Control>
|
|
81
|
+
<Slider.Track>
|
|
82
|
+
<Slider.Range />
|
|
83
|
+
</Slider.Track>
|
|
84
|
+
<Slider.Thumb key={0} index={0} />
|
|
85
|
+
</Slider.Control>
|
|
86
|
+
<Slider.MarkerGroup>
|
|
87
|
+
<Slider.Marker value={25}>25</Slider.Marker>
|
|
88
|
+
<Slider.Marker value={50}>50</Slider.Marker>
|
|
89
|
+
<Slider.Marker value={75}>75</Slider.Marker>
|
|
90
|
+
</Slider.MarkerGroup>
|
|
91
|
+
</Slider.Root>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
81
94
|
```
|
|
82
95
|
|
|
83
96
|
## Documentation
|
|
@@ -43,7 +43,7 @@ const ColorPicker = react.forwardRef((props, ref) => {
|
|
|
43
43
|
"value"
|
|
44
44
|
]);
|
|
45
45
|
const api = useColorPicker.useColorPicker(useColorPickerProps);
|
|
46
|
-
const presenceApi = usePresence.usePresence({
|
|
46
|
+
const presenceApi = usePresence.usePresence(react$1.mergeProps({ present: api.isOpen }, presenceProps));
|
|
47
47
|
const view = runIfFn.runIfFn(children, api);
|
|
48
48
|
const mergedProps = react$1.mergeProps(api.rootProps, localProps);
|
|
49
49
|
return /* @__PURE__ */ jsxRuntime.jsx(colorPickerContext.ColorPickerProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsxs(presenceContext.PresenceProvider, { value: presenceApi, children: [
|
|
@@ -39,7 +39,7 @@ const ColorPicker = forwardRef((props, ref) => {
|
|
|
39
39
|
"value"
|
|
40
40
|
]);
|
|
41
41
|
const api = useColorPicker(useColorPickerProps);
|
|
42
|
-
const presenceApi = usePresence({
|
|
42
|
+
const presenceApi = usePresence(mergeProps({ present: api.isOpen }, presenceProps));
|
|
43
43
|
const view = runIfFn(children, api);
|
|
44
44
|
const mergedProps = mergeProps(api.rootProps, localProps);
|
|
45
45
|
return /* @__PURE__ */ jsx(ColorPickerProvider, { value: api, children: /* @__PURE__ */ jsxs(PresenceProvider, { value: presenceApi, children: [
|
package/combobox/combobox.cjs
CHANGED
|
@@ -61,7 +61,7 @@ const ComboboxImpl = (props, ref) => {
|
|
|
61
61
|
]
|
|
62
62
|
);
|
|
63
63
|
const api = useCombobox.useCombobox(useComboboxProps);
|
|
64
|
-
const presenceApi = usePresence.usePresence({
|
|
64
|
+
const presenceApi = usePresence.usePresence(react$1.mergeProps({ present: api.isOpen }, presenceProps));
|
|
65
65
|
const view = runIfFn.runIfFn(children, api);
|
|
66
66
|
const mergedProps = react$1.mergeProps(api.rootProps, localProps);
|
|
67
67
|
return /* @__PURE__ */ jsxRuntime.jsx(comboboxContext.ComboboxProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(presenceContext.PresenceProvider, { value: presenceApi, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref, children: view }) }) });
|
package/combobox/combobox.d.ts
CHANGED
package/combobox/combobox.mjs
CHANGED
|
@@ -57,7 +57,7 @@ const ComboboxImpl = (props, ref) => {
|
|
|
57
57
|
]
|
|
58
58
|
);
|
|
59
59
|
const api = useCombobox(useComboboxProps);
|
|
60
|
-
const presenceApi = usePresence({
|
|
60
|
+
const presenceApi = usePresence(mergeProps({ present: api.isOpen }, presenceProps));
|
|
61
61
|
const view = runIfFn(children, api);
|
|
62
62
|
const mergedProps = mergeProps(api.rootProps, localProps);
|
|
63
63
|
return /* @__PURE__ */ jsx(ComboboxProvider, { value: api, children: /* @__PURE__ */ jsx(PresenceProvider, { value: presenceApi, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref, children: view }) }) });
|
|
@@ -35,7 +35,6 @@ const DatePicker = react.forwardRef((props, ref) => {
|
|
|
35
35
|
"isDateUnavailable",
|
|
36
36
|
"locale",
|
|
37
37
|
"max",
|
|
38
|
-
"messages",
|
|
39
38
|
"min",
|
|
40
39
|
"modal",
|
|
41
40
|
"name",
|
|
@@ -51,12 +50,13 @@ const DatePicker = react.forwardRef((props, ref) => {
|
|
|
51
50
|
"selectionMode",
|
|
52
51
|
"startOfWeek",
|
|
53
52
|
"timeZone",
|
|
53
|
+
"translations",
|
|
54
54
|
"value",
|
|
55
55
|
"view"
|
|
56
56
|
]
|
|
57
57
|
);
|
|
58
58
|
const api = useDatePicker.useDatePicker(useDatePickerProps);
|
|
59
|
-
const presenceApi = usePresence.usePresence({
|
|
59
|
+
const presenceApi = usePresence.usePresence(react$1.mergeProps({ present: api.isOpen }, presenceProps));
|
|
60
60
|
const view = runIfFn.runIfFn(children, api);
|
|
61
61
|
const mergedProps = react$1.mergeProps(api.rootProps, localProps);
|
|
62
62
|
return /* @__PURE__ */ jsxRuntime.jsx(datePickerContext.DatePickerProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(presenceContext.PresenceProvider, { value: presenceApi, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref, children: view }) }) });
|
|
@@ -31,7 +31,6 @@ const DatePicker = forwardRef((props, ref) => {
|
|
|
31
31
|
"isDateUnavailable",
|
|
32
32
|
"locale",
|
|
33
33
|
"max",
|
|
34
|
-
"messages",
|
|
35
34
|
"min",
|
|
36
35
|
"modal",
|
|
37
36
|
"name",
|
|
@@ -47,12 +46,13 @@ const DatePicker = forwardRef((props, ref) => {
|
|
|
47
46
|
"selectionMode",
|
|
48
47
|
"startOfWeek",
|
|
49
48
|
"timeZone",
|
|
49
|
+
"translations",
|
|
50
50
|
"value",
|
|
51
51
|
"view"
|
|
52
52
|
]
|
|
53
53
|
);
|
|
54
54
|
const api = useDatePicker(useDatePickerProps);
|
|
55
|
-
const presenceApi = usePresence({
|
|
55
|
+
const presenceApi = usePresence(mergeProps({ present: api.isOpen }, presenceProps));
|
|
56
56
|
const view = runIfFn(children, api);
|
|
57
57
|
const mergedProps = mergeProps(api.rootProps, localProps);
|
|
58
58
|
return /* @__PURE__ */ jsx(DatePickerProvider, { value: api, children: /* @__PURE__ */ jsx(PresenceProvider, { value: presenceApi, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref, children: view }) }) });
|
|
@@ -15,7 +15,7 @@ const usePresence = require('../presence/use-presence.cjs');
|
|
|
15
15
|
const DialogBackdrop = react.forwardRef((props, ref) => {
|
|
16
16
|
const api = dialogContext.useDialogContext();
|
|
17
17
|
const presenceProps = presencePropsContext.usePresencePropsContext();
|
|
18
|
-
const presenceApi = usePresence.usePresence({
|
|
18
|
+
const presenceApi = usePresence.usePresence(react$1.mergeProps({ present: api.isOpen }, presenceProps));
|
|
19
19
|
const mergedProps = react$1.mergeProps(api.backdropProps, presenceApi.getPresenceProps(ref), props);
|
|
20
20
|
if (presenceApi.isUnmounted) {
|
|
21
21
|
return null;
|
|
@@ -11,7 +11,7 @@ import { usePresence } from '../presence/use-presence.mjs';
|
|
|
11
11
|
const DialogBackdrop = forwardRef((props, ref) => {
|
|
12
12
|
const api = useDialogContext();
|
|
13
13
|
const presenceProps = usePresencePropsContext();
|
|
14
|
-
const presenceApi = usePresence({
|
|
14
|
+
const presenceApi = usePresence(mergeProps({ present: api.isOpen }, presenceProps));
|
|
15
15
|
const mergedProps = mergeProps(api.backdropProps, presenceApi.getPresenceProps(ref), props);
|
|
16
16
|
if (presenceApi.isUnmounted) {
|
|
17
17
|
return null;
|
package/dialog/dialog.cjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
5
|
|
|
6
6
|
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const core = require('@zag-js/core');
|
|
7
8
|
require('react');
|
|
8
9
|
require('../presence/index.cjs');
|
|
9
10
|
const splitPresenceProps = require('../presence/split-presence-props.cjs');
|
|
@@ -17,7 +18,7 @@ const presenceContext = require('../presence/presence-context.cjs');
|
|
|
17
18
|
const Dialog = (props) => {
|
|
18
19
|
const [presenceProps, { children, ...localProps }] = splitPresenceProps.splitPresenceProps(props);
|
|
19
20
|
const api = useDialog.useDialog(localProps);
|
|
20
|
-
const presenceApi = usePresence.usePresence({
|
|
21
|
+
const presenceApi = usePresence.usePresence(core.mergeProps({ present: api.isOpen }, presenceProps));
|
|
21
22
|
const view = runIfFn.runIfFn(children, api);
|
|
22
23
|
return /* @__PURE__ */ jsxRuntime.jsx(dialogContext.DialogProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(presencePropsContext.PresencePropsProvider, { value: presenceProps, children: /* @__PURE__ */ jsxRuntime.jsx(presenceContext.PresenceProvider, { value: presenceApi, children: view }) }) });
|
|
23
24
|
};
|
package/dialog/dialog.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { mergeProps } from '@zag-js/core';
|
|
3
4
|
import 'react';
|
|
4
5
|
import '../presence/index.mjs';
|
|
5
6
|
import { splitPresenceProps } from '../presence/split-presence-props.mjs';
|
|
@@ -13,7 +14,7 @@ import { PresenceProvider } from '../presence/presence-context.mjs';
|
|
|
13
14
|
const Dialog = (props) => {
|
|
14
15
|
const [presenceProps, { children, ...localProps }] = splitPresenceProps(props);
|
|
15
16
|
const api = useDialog(localProps);
|
|
16
|
-
const presenceApi = usePresence({
|
|
17
|
+
const presenceApi = usePresence(mergeProps({ present: api.isOpen }, presenceProps));
|
|
17
18
|
const view = runIfFn(children, api);
|
|
18
19
|
return /* @__PURE__ */ jsx(DialogProvider, { value: api, children: /* @__PURE__ */ jsx(PresencePropsProvider, { value: presenceProps, children: /* @__PURE__ */ jsx(PresenceProvider, { value: presenceApi, children: view }) }) });
|
|
19
20
|
};
|
package/editable/editable.cjs
CHANGED
|
@@ -13,7 +13,7 @@ const editableContext = require('./editable-context.cjs');
|
|
|
13
13
|
const useEditable = require('./use-editable.cjs');
|
|
14
14
|
|
|
15
15
|
const Editable = react.forwardRef((props, ref) => {
|
|
16
|
-
const [useEditableProps, { children, ...
|
|
16
|
+
const [useEditableProps, { children, ...localProps }] = createSplitProps.createSplitProps()(
|
|
17
17
|
props,
|
|
18
18
|
[
|
|
19
19
|
"activationMode",
|
|
@@ -46,7 +46,7 @@ const Editable = react.forwardRef((props, ref) => {
|
|
|
46
46
|
]
|
|
47
47
|
);
|
|
48
48
|
const api = useEditable.useEditable(useEditableProps);
|
|
49
|
-
const mergedProps = react$1.mergeProps(api.rootProps,
|
|
49
|
+
const mergedProps = react$1.mergeProps(api.rootProps, localProps);
|
|
50
50
|
const view = runIfFn.runIfFn(children, api);
|
|
51
51
|
return /* @__PURE__ */ jsxRuntime.jsx(editableContext.EditableProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref, children: view }) });
|
|
52
52
|
});
|
package/editable/editable.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { EditableProvider } from './editable-context.mjs';
|
|
|
9
9
|
import { useEditable } from './use-editable.mjs';
|
|
10
10
|
|
|
11
11
|
const Editable = forwardRef((props, ref) => {
|
|
12
|
-
const [useEditableProps, { children, ...
|
|
12
|
+
const [useEditableProps, { children, ...localProps }] = createSplitProps()(
|
|
13
13
|
props,
|
|
14
14
|
[
|
|
15
15
|
"activationMode",
|
|
@@ -42,7 +42,7 @@ const Editable = forwardRef((props, ref) => {
|
|
|
42
42
|
]
|
|
43
43
|
);
|
|
44
44
|
const api = useEditable(useEditableProps);
|
|
45
|
-
const mergedProps = mergeProps(api.rootProps,
|
|
45
|
+
const mergedProps = mergeProps(api.rootProps, localProps);
|
|
46
46
|
const view = runIfFn(children, api);
|
|
47
47
|
return /* @__PURE__ */ jsx(EditableProvider, { value: api, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref, children: view }) });
|
|
48
48
|
});
|
package/factory.cjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const jsxRuntime = require('react/jsx-runtime');
|
|
6
5
|
const core = require('@zag-js/core');
|
|
7
6
|
const react = require('react');
|
|
8
7
|
const composeRefs = require('./compose-refs.cjs');
|
|
@@ -11,7 +10,7 @@ const withAsChild = (Component) => {
|
|
|
11
10
|
const Comp = react.forwardRef((props, ref) => {
|
|
12
11
|
const { asChild, children, ...restProps } = props;
|
|
13
12
|
if (!asChild) {
|
|
14
|
-
return
|
|
13
|
+
return react.createElement(Component, { ...restProps, ref }, children);
|
|
15
14
|
}
|
|
16
15
|
const onlyChild = react.Children.only(children);
|
|
17
16
|
return react.isValidElement(onlyChild) ? react.cloneElement(onlyChild, {
|
package/factory.d.ts
CHANGED
package/factory.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
1
|
import { mergeProps } from '@zag-js/core';
|
|
3
|
-
import { forwardRef, Children, isValidElement, cloneElement } from 'react';
|
|
2
|
+
import { forwardRef, createElement, Children, isValidElement, cloneElement } from 'react';
|
|
4
3
|
import { composeRefs } from './compose-refs.mjs';
|
|
5
4
|
|
|
6
5
|
const withAsChild = (Component) => {
|
|
7
6
|
const Comp = forwardRef((props, ref) => {
|
|
8
7
|
const { asChild, children, ...restProps } = props;
|
|
9
8
|
if (!asChild) {
|
|
10
|
-
return
|
|
9
|
+
return createElement(Component, { ...restProps, ref }, children);
|
|
11
10
|
}
|
|
12
11
|
const onlyChild = Children.only(children);
|
|
13
12
|
return isValidElement(onlyChild) ? cloneElement(onlyChild, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const react$1 = require('@zag-js/react');
|
|
8
|
+
const react = require('react');
|
|
9
|
+
const factory = require('../factory.cjs');
|
|
10
|
+
const fileUploadContext = require('./file-upload-context.cjs');
|
|
11
|
+
const fileUploadItemContext = require('./file-upload-item-context.cjs');
|
|
12
|
+
|
|
13
|
+
const FileUploadItemPreviewImage = react.forwardRef((props, ref) => {
|
|
14
|
+
const [url, setUrl] = react.useState("");
|
|
15
|
+
const api = fileUploadContext.useFileUploadContext();
|
|
16
|
+
const item = fileUploadItemContext.useFileUploadItemContext();
|
|
17
|
+
const mergedProps = react$1.mergeProps(api.getItemPreviewImageProps({ ...item, url }), props);
|
|
18
|
+
react.useEffect(() => {
|
|
19
|
+
api.createFileUrl(item.file, (url2) => setUrl(url2));
|
|
20
|
+
}, [item, api]);
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.img, { ...mergedProps, ref });
|
|
22
|
+
});
|
|
23
|
+
FileUploadItemPreviewImage.displayName = "FileUploadItemPreviewImage";
|
|
24
|
+
|
|
25
|
+
exports.FileUploadItemPreviewImage = FileUploadItemPreviewImage;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import { type HTMLArkProps } from '../factory';
|
|
4
|
+
export interface FileUploadItemPreviewImageProps extends HTMLArkProps<'img'> {
|
|
5
|
+
}
|
|
6
|
+
export declare const FileUploadItemPreviewImage: ForwardRefExoticComponent<FileUploadItemPreviewImageProps & RefAttributes<HTMLImageElement>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { mergeProps } from '@zag-js/react';
|
|
4
|
+
import { forwardRef, useState, useEffect } from 'react';
|
|
5
|
+
import { ark } from '../factory.mjs';
|
|
6
|
+
import { useFileUploadContext } from './file-upload-context.mjs';
|
|
7
|
+
import { useFileUploadItemContext } from './file-upload-item-context.mjs';
|
|
8
|
+
|
|
9
|
+
const FileUploadItemPreviewImage = forwardRef((props, ref) => {
|
|
10
|
+
const [url, setUrl] = useState("");
|
|
11
|
+
const api = useFileUploadContext();
|
|
12
|
+
const item = useFileUploadItemContext();
|
|
13
|
+
const mergedProps = mergeProps(api.getItemPreviewImageProps({ ...item, url }), props);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
api.createFileUrl(item.file, (url2) => setUrl(url2));
|
|
16
|
+
}, [item, api]);
|
|
17
|
+
return /* @__PURE__ */ jsx(ark.img, { ...mergedProps, ref });
|
|
18
|
+
});
|
|
19
|
+
FileUploadItemPreviewImage.displayName = "FileUploadItemPreviewImage";
|
|
20
|
+
|
|
21
|
+
export { FileUploadItemPreviewImage };
|
|
@@ -12,18 +12,12 @@ const fileUploadItemContext = require('./file-upload-item-context.cjs');
|
|
|
12
12
|
|
|
13
13
|
const FileUploadItemPreview = react.forwardRef(
|
|
14
14
|
(props, ref) => {
|
|
15
|
-
const [url, setUrl] = react.useState("");
|
|
16
15
|
const api = fileUploadContext.useFileUploadContext();
|
|
17
16
|
const item = fileUploadItemContext.useFileUploadItemContext();
|
|
18
|
-
react.
|
|
19
|
-
|
|
20
|
-
}, [item, api]);
|
|
21
|
-
try {
|
|
22
|
-
const mergedProps = react$1.mergeProps(api.getItemPreviewProps({ ...item, url }), props);
|
|
23
|
-
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.img, { ...mergedProps, ref });
|
|
24
|
-
} catch (e) {
|
|
17
|
+
const mergedProps = react$1.mergeProps(api.getItemPreviewProps(item), props);
|
|
18
|
+
if (!item.file.type.match(props.type ?? ".*"))
|
|
25
19
|
return null;
|
|
26
|
-
}
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref });
|
|
27
21
|
}
|
|
28
22
|
);
|
|
29
23
|
FileUploadItemPreview.displayName = "FileUploadItemPreview";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
2
|
/// <reference types="react" />
|
|
3
3
|
import { type HTMLArkProps } from '../factory';
|
|
4
|
-
export interface FileUploadItemPreviewProps extends HTMLArkProps<'
|
|
4
|
+
export interface FileUploadItemPreviewProps extends HTMLArkProps<'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* The file type to match against. Matches all file types by default.
|
|
7
|
+
* @default '.*'
|
|
8
|
+
*/
|
|
9
|
+
type?: string;
|
|
5
10
|
}
|
|
6
11
|
export declare const FileUploadItemPreview: ForwardRefExoticComponent<FileUploadItemPreviewProps & RefAttributes<HTMLImageElement>>;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { mergeProps } from '@zag-js/react';
|
|
4
|
-
import { forwardRef
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
5
|
import { ark } from '../factory.mjs';
|
|
6
6
|
import { useFileUploadContext } from './file-upload-context.mjs';
|
|
7
7
|
import { useFileUploadItemContext } from './file-upload-item-context.mjs';
|
|
8
8
|
|
|
9
9
|
const FileUploadItemPreview = forwardRef(
|
|
10
10
|
(props, ref) => {
|
|
11
|
-
const [url, setUrl] = useState("");
|
|
12
11
|
const api = useFileUploadContext();
|
|
13
12
|
const item = useFileUploadItemContext();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}, [item, api]);
|
|
17
|
-
try {
|
|
18
|
-
const mergedProps = mergeProps(api.getItemPreviewProps({ ...item, url }), props);
|
|
19
|
-
return /* @__PURE__ */ jsx(ark.img, { ...mergedProps, ref });
|
|
20
|
-
} catch (e) {
|
|
13
|
+
const mergedProps = mergeProps(api.getItemPreviewProps(item), props);
|
|
14
|
+
if (!item.file.type.match(props.type ?? ".*"))
|
|
21
15
|
return null;
|
|
22
|
-
}
|
|
16
|
+
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
|
|
23
17
|
}
|
|
24
18
|
);
|
|
25
19
|
FileUploadItemPreview.displayName = "FileUploadItemPreview";
|
|
@@ -23,13 +23,17 @@ const FileUpload = react.forwardRef((props, ref) => {
|
|
|
23
23
|
"files",
|
|
24
24
|
"getRootNode",
|
|
25
25
|
"id",
|
|
26
|
-
"
|
|
26
|
+
"ids",
|
|
27
27
|
"locale",
|
|
28
28
|
"maxFiles",
|
|
29
29
|
"maxFileSize",
|
|
30
30
|
"minFileSize",
|
|
31
31
|
"name",
|
|
32
|
-
"
|
|
32
|
+
"onFileAccept",
|
|
33
|
+
"onFileReject",
|
|
34
|
+
"onFilesChange",
|
|
35
|
+
"translations",
|
|
36
|
+
"validate"
|
|
33
37
|
]
|
|
34
38
|
);
|
|
35
39
|
const api = useFileUpload.useFileUpload(useFileUploadProps);
|
|
@@ -19,13 +19,17 @@ const FileUpload = forwardRef((props, ref) => {
|
|
|
19
19
|
"files",
|
|
20
20
|
"getRootNode",
|
|
21
21
|
"id",
|
|
22
|
-
"
|
|
22
|
+
"ids",
|
|
23
23
|
"locale",
|
|
24
24
|
"maxFiles",
|
|
25
25
|
"maxFileSize",
|
|
26
26
|
"minFileSize",
|
|
27
27
|
"name",
|
|
28
|
-
"
|
|
28
|
+
"onFileAccept",
|
|
29
|
+
"onFileReject",
|
|
30
|
+
"onFilesChange",
|
|
31
|
+
"translations",
|
|
32
|
+
"validate"
|
|
29
33
|
]
|
|
30
34
|
);
|
|
31
35
|
const api = useFileUpload(useFileUploadProps);
|
package/file-upload/index.cjs
CHANGED
|
@@ -11,6 +11,7 @@ const fileUploadItemDeleteTrigger = require('./file-upload-item-delete-trigger.c
|
|
|
11
11
|
const fileUploadItemGroup = require('./file-upload-item-group.cjs');
|
|
12
12
|
const fileUploadItemName = require('./file-upload-item-name.cjs');
|
|
13
13
|
const fileUploadItemPreview = require('./file-upload-item-preview.cjs');
|
|
14
|
+
const fileUploadItemPreviewImage = require('./file-upload-item-preview-image.cjs');
|
|
14
15
|
const fileUploadItemSizeText = require('./file-upload-item-size-text.cjs');
|
|
15
16
|
const fileUploadLabel = require('./file-upload-label.cjs');
|
|
16
17
|
const fileUploadTrigger = require('./file-upload-trigger.cjs');
|
|
@@ -18,14 +19,15 @@ const fileUploadTrigger = require('./file-upload-trigger.cjs');
|
|
|
18
19
|
const FileUpload = Object.assign(fileUpload.FileUpload, {
|
|
19
20
|
Root: fileUpload.FileUpload,
|
|
20
21
|
Dropzone: fileUploadDropzone.FileUploadDropzone,
|
|
21
|
-
Label: fileUploadLabel.FileUploadLabel,
|
|
22
|
-
Trigger: fileUploadTrigger.FileUploadTrigger,
|
|
23
|
-
ItemGroup: fileUploadItemGroup.FileUploadItemGroup,
|
|
24
22
|
Item: fileUploadItem.FileUploadItem,
|
|
23
|
+
ItemDeleteTrigger: fileUploadItemDeleteTrigger.FileUploadItemDeleteTrigger,
|
|
24
|
+
ItemGroup: fileUploadItemGroup.FileUploadItemGroup,
|
|
25
25
|
ItemName: fileUploadItemName.FileUploadItemName,
|
|
26
26
|
ItemPreview: fileUploadItemPreview.FileUploadItemPreview,
|
|
27
|
+
ItemPreviewImage: fileUploadItemPreviewImage.FileUploadItemPreviewImage,
|
|
27
28
|
ItemSizeText: fileUploadItemSizeText.FileUploadItemSizeText,
|
|
28
|
-
|
|
29
|
+
Label: fileUploadLabel.FileUploadLabel,
|
|
30
|
+
Trigger: fileUploadTrigger.FileUploadTrigger
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
exports.useFileUploadContext = fileUploadContext.useFileUploadContext;
|
|
@@ -34,7 +36,7 @@ exports.FileUploadItem = fileUploadItem.FileUploadItem;
|
|
|
34
36
|
exports.FileUploadItemDeleteTrigger = fileUploadItemDeleteTrigger.FileUploadItemDeleteTrigger;
|
|
35
37
|
exports.FileUploadItemGroup = fileUploadItemGroup.FileUploadItemGroup;
|
|
36
38
|
exports.FileUploadItemName = fileUploadItemName.FileUploadItemName;
|
|
37
|
-
exports.
|
|
39
|
+
exports.FileUploadItemPreviewImage = fileUploadItemPreviewImage.FileUploadItemPreviewImage;
|
|
38
40
|
exports.FileUploadItemSizeText = fileUploadItemSizeText.FileUploadItemSizeText;
|
|
39
41
|
exports.FileUploadLabel = fileUploadLabel.FileUploadLabel;
|
|
40
42
|
exports.FileUploadTrigger = fileUploadTrigger.FileUploadTrigger;
|
package/file-upload/index.d.ts
CHANGED
|
@@ -7,21 +7,23 @@ import { FileUploadItem, type FileUploadItemProps } from './file-upload-item';
|
|
|
7
7
|
import { FileUploadItemDeleteTrigger, type FileUploadItemDeleteTriggerProps } from './file-upload-item-delete-trigger';
|
|
8
8
|
import { FileUploadItemGroup, type FileUploadItemGroupProps } from './file-upload-item-group';
|
|
9
9
|
import { FileUploadItemName, type FileUploadItemNameProps } from './file-upload-item-name';
|
|
10
|
-
import {
|
|
10
|
+
import { type FileUploadItemPreviewProps } from './file-upload-item-preview';
|
|
11
|
+
import { FileUploadItemPreviewImage, type FileUploadItemPreviewImageProps } from './file-upload-item-preview-image';
|
|
11
12
|
import { FileUploadItemSizeText, type FileUploadItemSizeTextProps } from './file-upload-item-size-text';
|
|
12
13
|
import { FileUploadLabel, type FileUploadLabelProps } from './file-upload-label';
|
|
13
14
|
import { FileUploadTrigger, type FileUploadTriggerProps } from './file-upload-trigger';
|
|
14
15
|
declare const FileUpload: ForwardRefExoticComponent<FileUploadProps & RefAttributes<HTMLDivElement>> & {
|
|
15
16
|
Root: ForwardRefExoticComponent<FileUploadProps & RefAttributes<HTMLDivElement>>;
|
|
16
17
|
Dropzone: ForwardRefExoticComponent<FileUploadDropzoneProps & RefAttributes<HTMLDivElement>>;
|
|
17
|
-
Label: ForwardRefExoticComponent<FileUploadLabelProps & RefAttributes<HTMLLabelElement>>;
|
|
18
|
-
Trigger: ForwardRefExoticComponent<FileUploadTriggerProps & RefAttributes<HTMLButtonElement>>;
|
|
19
|
-
ItemGroup: ForwardRefExoticComponent<FileUploadItemGroupProps & RefAttributes<HTMLUListElement>>;
|
|
20
18
|
Item: ForwardRefExoticComponent<FileUploadItemProps & RefAttributes<HTMLLIElement>>;
|
|
19
|
+
ItemDeleteTrigger: ForwardRefExoticComponent<FileUploadItemDeleteTriggerProps & RefAttributes<HTMLButtonElement>>;
|
|
20
|
+
ItemGroup: ForwardRefExoticComponent<FileUploadItemGroupProps & RefAttributes<HTMLUListElement>>;
|
|
21
21
|
ItemName: ForwardRefExoticComponent<FileUploadItemNameProps & RefAttributes<HTMLDivElement>>;
|
|
22
22
|
ItemPreview: ForwardRefExoticComponent<FileUploadItemPreviewProps & RefAttributes<HTMLImageElement>>;
|
|
23
|
+
ItemPreviewImage: ForwardRefExoticComponent<FileUploadItemPreviewImageProps & RefAttributes<HTMLImageElement>>;
|
|
23
24
|
ItemSizeText: ForwardRefExoticComponent<FileUploadItemSizeTextProps & RefAttributes<HTMLDivElement>>;
|
|
24
|
-
|
|
25
|
+
Label: ForwardRefExoticComponent<FileUploadLabelProps & RefAttributes<HTMLLabelElement>>;
|
|
26
|
+
Trigger: ForwardRefExoticComponent<FileUploadTriggerProps & RefAttributes<HTMLButtonElement>>;
|
|
25
27
|
};
|
|
26
|
-
export { FileUpload, FileUploadDropzone, FileUploadItem, FileUploadItemDeleteTrigger, FileUploadItemGroup, FileUploadItemName,
|
|
27
|
-
export type { FileUploadContext, FileUploadDropzoneProps, FileUploadItemDeleteTriggerProps, FileUploadItemGroupProps, FileUploadItemNameProps, FileUploadItemPreviewProps, FileUploadItemProps, FileUploadItemSizeTextProps, FileUploadLabelProps, FileUploadProps, FileUploadTriggerProps, };
|
|
28
|
+
export { FileUpload, FileUploadDropzone, FileUploadItem, FileUploadItemDeleteTrigger, FileUploadItemGroup, FileUploadItemName, FileUploadItemPreviewImage, FileUploadItemSizeText, FileUploadLabel, FileUploadTrigger, useFileUploadContext, };
|
|
29
|
+
export type { FileUploadContext, FileUploadDropzoneProps, FileUploadItemDeleteTriggerProps, FileUploadItemGroupProps, FileUploadItemNameProps, FileUploadItemPreviewImageProps, FileUploadItemPreviewProps, FileUploadItemProps, FileUploadItemSizeTextProps, FileUploadLabelProps, FileUploadProps, FileUploadTriggerProps, };
|
package/file-upload/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { FileUploadItemDeleteTrigger } from './file-upload-item-delete-trigger.m
|
|
|
7
7
|
import { FileUploadItemGroup } from './file-upload-item-group.mjs';
|
|
8
8
|
import { FileUploadItemName } from './file-upload-item-name.mjs';
|
|
9
9
|
import { FileUploadItemPreview } from './file-upload-item-preview.mjs';
|
|
10
|
+
import { FileUploadItemPreviewImage } from './file-upload-item-preview-image.mjs';
|
|
10
11
|
import { FileUploadItemSizeText } from './file-upload-item-size-text.mjs';
|
|
11
12
|
import { FileUploadLabel } from './file-upload-label.mjs';
|
|
12
13
|
import { FileUploadTrigger } from './file-upload-trigger.mjs';
|
|
@@ -14,14 +15,15 @@ import { FileUploadTrigger } from './file-upload-trigger.mjs';
|
|
|
14
15
|
const FileUpload = Object.assign(FileUpload$1, {
|
|
15
16
|
Root: FileUpload$1,
|
|
16
17
|
Dropzone: FileUploadDropzone,
|
|
17
|
-
Label: FileUploadLabel,
|
|
18
|
-
Trigger: FileUploadTrigger,
|
|
19
|
-
ItemGroup: FileUploadItemGroup,
|
|
20
18
|
Item: FileUploadItem,
|
|
19
|
+
ItemDeleteTrigger: FileUploadItemDeleteTrigger,
|
|
20
|
+
ItemGroup: FileUploadItemGroup,
|
|
21
21
|
ItemName: FileUploadItemName,
|
|
22
22
|
ItemPreview: FileUploadItemPreview,
|
|
23
|
+
ItemPreviewImage: FileUploadItemPreviewImage,
|
|
23
24
|
ItemSizeText: FileUploadItemSizeText,
|
|
24
|
-
|
|
25
|
+
Label: FileUploadLabel,
|
|
26
|
+
Trigger: FileUploadTrigger
|
|
25
27
|
});
|
|
26
28
|
|
|
27
|
-
export { FileUpload, FileUploadDropzone, FileUploadItem, FileUploadItemDeleteTrigger, FileUploadItemGroup, FileUploadItemName,
|
|
29
|
+
export { FileUpload, FileUploadDropzone, FileUploadItem, FileUploadItemDeleteTrigger, FileUploadItemGroup, FileUploadItemName, FileUploadItemPreviewImage, FileUploadItemSizeText, FileUploadLabel, FileUploadTrigger };
|
|
@@ -37,7 +37,8 @@ const useFileUpload = (props = {}) => {
|
|
|
37
37
|
};
|
|
38
38
|
const context = {
|
|
39
39
|
...initialContext,
|
|
40
|
-
|
|
40
|
+
onFileAccept: useEvent.useEvent(props.onFileAccept),
|
|
41
|
+
onFileReject: useEvent.useEvent(props.onFileReject),
|
|
41
42
|
onFilesChange: useEvent.useEvent(props.onFilesChange, { sync: true })
|
|
42
43
|
};
|
|
43
44
|
const [state, send] = react$1.useMachine(fileUpload__namespace.machine(initialContext), { context });
|
|
@@ -14,7 +14,8 @@ const useFileUpload = (props = {}) => {
|
|
|
14
14
|
};
|
|
15
15
|
const context = {
|
|
16
16
|
...initialContext,
|
|
17
|
-
|
|
17
|
+
onFileAccept: useEvent(props.onFileAccept),
|
|
18
|
+
onFileReject: useEvent(props.onFileReject),
|
|
18
19
|
onFilesChange: useEvent(props.onFilesChange, { sync: true })
|
|
19
20
|
};
|
|
20
21
|
const [state, send] = useMachine(fileUpload.machine(initialContext), { context });
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
5
|
|
|
6
6
|
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const react = require('@zag-js/react');
|
|
7
8
|
require('react');
|
|
8
9
|
require('../presence/index.cjs');
|
|
9
10
|
const splitPresenceProps = require('../presence/split-presence-props.cjs');
|
|
@@ -16,7 +17,7 @@ const presenceContext = require('../presence/presence-context.cjs');
|
|
|
16
17
|
const HoverCard = (props) => {
|
|
17
18
|
const [presenceProps, { children, ...localProps }] = splitPresenceProps.splitPresenceProps(props);
|
|
18
19
|
const api = useHoverCard.useHoverCard(localProps);
|
|
19
|
-
const presenceApi = usePresence.usePresence({
|
|
20
|
+
const presenceApi = usePresence.usePresence(react.mergeProps({ present: api.isOpen }, presenceProps));
|
|
20
21
|
const view = runIfFn.runIfFn(children, api);
|
|
21
22
|
return /* @__PURE__ */ jsxRuntime.jsx(hoverCardContext.HoverCardProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(presenceContext.PresenceProvider, { value: presenceApi, children: view }) });
|
|
22
23
|
};
|