@xds/react 0.1.0 → 1.0.0-rc.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/dist/Accordion.js +191 -33
- package/dist/Avatar.js +65 -6
- package/dist/AvatarStack.js +101 -6
- package/dist/Badge.js +61 -4
- package/dist/Banner.js +161 -5
- package/dist/Button.js +152 -24
- package/dist/Card.js +171 -12
- package/dist/Checkbox.js +138 -3
- package/dist/Chip.js +71 -4
- package/dist/ChipBar.js +36 -3
- package/dist/CountBadge.js +62 -9
- package/dist/DatePicker.js +421 -25
- package/dist/DateRangePicker.js +362 -40
- package/dist/Defaults.js +42 -7
- package/dist/Dialog.js +128 -24
- package/dist/Divider.js +29 -3
- package/dist/EmptyState.js +83 -3
- package/dist/Icon.js +74 -4
- package/dist/IconButton.js +113 -18
- package/dist/ListRow.js +180 -10
- package/dist/MediaCard.js +273 -11
- package/dist/Menu.js +234 -58
- package/dist/ProgressBar.js +63 -4
- package/dist/RadioGroup.js +173 -12
- package/dist/SearchField.js +148 -16
- package/dist/SectionHeader.js +121 -5
- package/dist/SegmentedControl.js +104 -5
- package/dist/Select.js +307 -55
- package/dist/Sidebar.js +212 -19
- package/dist/Skeleton.js +61 -5
- package/dist/Slider.js +142 -35
- package/dist/Spinner.js +93 -4
- package/dist/Switch.js +114 -3
- package/dist/Tabs.js +130 -14
- package/dist/Text.js +42 -4
- package/dist/TextField.js +209 -26
- package/dist/Thumbnail.js +146 -7
- package/dist/Toast.js +118 -30
- package/dist/Tooltip.js +154 -20
- package/dist/base.d.ts +11 -0
- package/dist/base.js +10 -0
- package/dist/modal-popover.js +32 -10
- package/dist/picture.d.ts +6 -4
- package/dist/picture.js +72 -17
- package/dist/portal.js +24 -4
- package/dist/presence.js +30 -9
- package/dist/preview.d.ts +14 -3
- package/dist/preview.js +118 -74
- package/dist/root.js +1 -0
- package/dist/trigger.d.ts +7 -0
- package/dist/trigger.js +41 -8
- package/eject/files/Accordion.tsx +157 -0
- package/eject/files/Avatar.tsx +41 -0
- package/eject/files/AvatarStack.tsx +47 -0
- package/eject/files/Badge.tsx +33 -0
- package/eject/files/Banner.tsx +70 -0
- package/eject/files/Button.tsx +88 -0
- package/eject/files/Card.tsx +85 -0
- package/eject/files/Checkbox.tsx +59 -0
- package/eject/files/Chip.tsx +43 -0
- package/eject/files/ChipBar.tsx +31 -0
- package/eject/files/CountBadge.tsx +50 -0
- package/eject/files/DatePicker.tsx +192 -0
- package/eject/files/DateRangePicker.tsx +271 -0
- package/eject/files/Dialog.tsx +108 -0
- package/eject/files/Divider.tsx +13 -0
- package/eject/files/EmptyState.tsx +39 -0
- package/eject/files/Icon.tsx +38 -0
- package/eject/files/IconButton.tsx +62 -0
- package/eject/files/ListRow.tsx +86 -0
- package/eject/files/MediaCard.tsx +111 -0
- package/eject/files/Menu.tsx +168 -0
- package/eject/files/ProgressBar.tsx +34 -0
- package/eject/files/RadioGroup.tsx +112 -0
- package/eject/files/SearchField.tsx +88 -0
- package/eject/files/SectionHeader.tsx +56 -0
- package/eject/files/SegmentedControl.tsx +57 -0
- package/eject/files/Select.tsx +228 -0
- package/eject/files/Sidebar.tsx +149 -0
- package/eject/files/Skeleton.tsx +28 -0
- package/eject/files/Slider.tsx +109 -0
- package/eject/files/Spinner.tsx +36 -0
- package/eject/files/Switch.tsx +53 -0
- package/eject/files/Tabs.tsx +71 -0
- package/eject/files/Text.tsx +31 -0
- package/eject/files/TextField.tsx +122 -0
- package/eject/files/Thumbnail.tsx +66 -0
- package/eject/files/Toast.tsx +88 -0
- package/eject/files/Tooltip.tsx +120 -0
- package/eject/files/accordion.css +89 -0
- package/eject/files/accordion.ts +67 -0
- package/eject/files/avatar-stack.ts +57 -0
- package/eject/files/avatar.ts +42 -0
- package/eject/files/badge.ts +30 -0
- package/eject/files/banner.ts +68 -0
- package/eject/files/base.css +38 -0
- package/eject/files/button.css +241 -0
- package/eject/files/button.ts +106 -0
- package/eject/files/card.ts +58 -0
- package/eject/files/checkbox.ts +32 -0
- package/eject/files/chip-bar.ts +16 -0
- package/eject/files/chip.ts +35 -0
- package/eject/files/count-badge.ts +32 -0
- package/eject/files/date-picker.css +352 -0
- package/eject/files/date-picker.ts +250 -0
- package/eject/files/date-range-picker.ts +323 -0
- package/eject/files/dialog.css +139 -0
- package/eject/files/dialog.ts +15 -0
- package/eject/files/divider.ts +5 -0
- package/eject/files/empty-state.ts +22 -0
- package/eject/files/icon.ts +36 -0
- package/eject/files/list-row.ts +66 -0
- package/eject/files/media-card.ts +66 -0
- package/eject/files/menu.css +176 -0
- package/eject/files/menu.ts +84 -0
- package/eject/files/parts.ts +17 -0
- package/eject/files/progress-bar.ts +23 -0
- package/eject/files/radio-group.css +160 -0
- package/eject/files/radio-group.ts +24 -0
- package/eject/files/section-header.ts +32 -0
- package/eject/files/segmented-control.ts +30 -0
- package/eject/files/select.css +285 -0
- package/eject/files/select.ts +36 -0
- package/eject/files/sidebar.ts +75 -0
- package/eject/files/skeleton.ts +51 -0
- package/eject/files/slider.css +136 -0
- package/eject/files/slider.ts +65 -0
- package/eject/files/spinner.ts +22 -0
- package/eject/files/switch.ts +34 -0
- package/eject/files/tabs.css +112 -0
- package/eject/files/tabs.ts +35 -0
- package/eject/files/text-field.css +229 -0
- package/eject/files/text-field.ts +48 -0
- package/eject/files/text.ts +38 -0
- package/eject/files/thumbnail.ts +51 -0
- package/eject/files/toast.ts +31 -0
- package/eject/files/tooltip.css +104 -0
- package/eject/files/tooltip.ts +21 -0
- package/eject/manifest.json +814 -0
- package/package.json +9 -4
package/dist/Tooltip.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { motion, space } from "@xds/tokens";
|
|
3
3
|
import { classes, tooltipEndSide } from "@xds/core";
|
|
4
4
|
import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
@@ -7,26 +7,160 @@ import { useId, useRef } from "react";
|
|
|
7
7
|
import { Portal } from "./portal.js";
|
|
8
8
|
import { usePresence } from "./presence.js";
|
|
9
9
|
import { TriggerContext, useProvideTrigger } from "./trigger.js";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
export function Tooltip(t0) {
|
|
12
|
+
const $ = _c(7);
|
|
13
|
+
const {
|
|
14
|
+
label,
|
|
15
|
+
shortcut,
|
|
16
|
+
placement: t1,
|
|
17
|
+
className,
|
|
18
|
+
style,
|
|
19
|
+
children
|
|
20
|
+
} = t0;
|
|
21
|
+
const placement = t1 === undefined ? "top" : t1;
|
|
22
|
+
let t2;
|
|
23
|
+
if ($[0] !== children || $[1] !== className || $[2] !== label || $[3] !== placement || $[4] !== shortcut || $[5] !== style) {
|
|
24
|
+
t2 = /*#__PURE__*/_jsx(Overlay, {
|
|
25
|
+
label: label,
|
|
26
|
+
shortcut: shortcut,
|
|
27
|
+
placement: placement,
|
|
28
|
+
className: className,
|
|
29
|
+
style: style,
|
|
30
|
+
children: children
|
|
31
|
+
});
|
|
32
|
+
$[0] = children;
|
|
33
|
+
$[1] = className;
|
|
34
|
+
$[2] = label;
|
|
35
|
+
$[3] = placement;
|
|
36
|
+
$[4] = shortcut;
|
|
37
|
+
$[5] = style;
|
|
38
|
+
$[6] = t2;
|
|
39
|
+
} else {
|
|
40
|
+
t2 = $[6];
|
|
41
|
+
}
|
|
42
|
+
return t2;
|
|
12
43
|
}
|
|
13
|
-
export function TooltipBeside(
|
|
14
|
-
|
|
44
|
+
export function TooltipBeside(t0) {
|
|
45
|
+
const $ = _c(4);
|
|
46
|
+
const {
|
|
47
|
+
label,
|
|
48
|
+
children
|
|
49
|
+
} = t0;
|
|
50
|
+
let t1;
|
|
51
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
52
|
+
t1 = tooltipEndSide();
|
|
53
|
+
$[0] = t1;
|
|
54
|
+
} else {
|
|
55
|
+
t1 = $[0];
|
|
56
|
+
}
|
|
57
|
+
let t2;
|
|
58
|
+
if ($[1] !== children || $[2] !== label) {
|
|
59
|
+
t2 = /*#__PURE__*/_jsx(Overlay, {
|
|
60
|
+
label: label,
|
|
61
|
+
placement: t1,
|
|
62
|
+
children: children
|
|
63
|
+
});
|
|
64
|
+
$[1] = children;
|
|
65
|
+
$[2] = label;
|
|
66
|
+
$[3] = t2;
|
|
67
|
+
} else {
|
|
68
|
+
t2 = $[3];
|
|
69
|
+
}
|
|
70
|
+
return t2;
|
|
15
71
|
}
|
|
16
|
-
function Overlay(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
72
|
+
function Overlay(t0) {
|
|
73
|
+
const $ = _c(12);
|
|
74
|
+
const {
|
|
75
|
+
label,
|
|
76
|
+
shortcut,
|
|
77
|
+
placement,
|
|
78
|
+
className,
|
|
79
|
+
style,
|
|
80
|
+
children
|
|
81
|
+
} = t0;
|
|
82
|
+
const t1 = useId();
|
|
83
|
+
let t2;
|
|
84
|
+
if ($[0] !== placement) {
|
|
85
|
+
t2 = {
|
|
86
|
+
placement,
|
|
87
|
+
gutter: space[1]
|
|
88
|
+
};
|
|
89
|
+
$[0] = placement;
|
|
90
|
+
$[1] = t2;
|
|
91
|
+
} else {
|
|
92
|
+
t2 = $[1];
|
|
93
|
+
}
|
|
94
|
+
let t3;
|
|
95
|
+
if ($[2] !== t1 || $[3] !== t2) {
|
|
96
|
+
t3 = {
|
|
97
|
+
id: t1,
|
|
98
|
+
openDelay: motion.duration.tooltipDelay,
|
|
99
|
+
closeDelay: 0,
|
|
100
|
+
closeOnScroll: false,
|
|
101
|
+
positioning: t2
|
|
102
|
+
};
|
|
103
|
+
$[2] = t1;
|
|
104
|
+
$[3] = t2;
|
|
105
|
+
$[4] = t3;
|
|
106
|
+
} else {
|
|
107
|
+
t3 = $[4];
|
|
108
|
+
}
|
|
109
|
+
const service = useMachine(tooltip.machine, t3);
|
|
110
|
+
const api = tooltip.connect(service, normalizeProps);
|
|
111
|
+
const trigger = useProvideTrigger(api.getTriggerProps());
|
|
112
|
+
const content = useRef(null);
|
|
113
|
+
let t4;
|
|
114
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
115
|
+
t4 = () => [content.current];
|
|
116
|
+
$[5] = t4;
|
|
117
|
+
} else {
|
|
118
|
+
t4 = $[5];
|
|
119
|
+
}
|
|
120
|
+
const present = usePresence(api.open, t4);
|
|
121
|
+
let t5;
|
|
122
|
+
if ($[6] !== children || $[7] !== trigger) {
|
|
123
|
+
t5 = /*#__PURE__*/_jsx(TriggerContext, {
|
|
124
|
+
value: trigger,
|
|
125
|
+
children: children
|
|
126
|
+
});
|
|
127
|
+
$[6] = children;
|
|
128
|
+
$[7] = trigger;
|
|
129
|
+
$[8] = t5;
|
|
130
|
+
} else {
|
|
131
|
+
t5 = $[8];
|
|
132
|
+
}
|
|
133
|
+
const t6 = present && /*#__PURE__*/_jsx(Portal, {
|
|
134
|
+
children: /*#__PURE__*/_jsx(TriggerContext, {
|
|
135
|
+
value: null,
|
|
136
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
137
|
+
...api.getPositionerProps(),
|
|
138
|
+
className: "xds-tooltip__positioner",
|
|
139
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
140
|
+
...mergeProps(api.getContentProps(), {
|
|
141
|
+
className: classes("xds-tooltip", className),
|
|
142
|
+
style
|
|
143
|
+
}),
|
|
144
|
+
ref: content,
|
|
145
|
+
hidden: false,
|
|
146
|
+
children: [label, shortcut && /*#__PURE__*/_jsx("kbd", {
|
|
147
|
+
className: "xds-tooltip__shortcut",
|
|
148
|
+
children: shortcut
|
|
149
|
+
})]
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
let t7;
|
|
155
|
+
if ($[9] !== t5 || $[10] !== t6) {
|
|
156
|
+
t7 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
157
|
+
children: [t5, t6]
|
|
23
158
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}), ref: content, hidden: false, children: [label, shortcut && _jsx("kbd", { className: "xds-tooltip__shortcut", children: shortcut })] }) }) }) }))] }));
|
|
159
|
+
$[9] = t5;
|
|
160
|
+
$[10] = t6;
|
|
161
|
+
$[11] = t7;
|
|
162
|
+
} else {
|
|
163
|
+
t7 = $[11];
|
|
164
|
+
}
|
|
165
|
+
return t7;
|
|
32
166
|
}
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { type IconName, icons, motion, space } from "@xds/tokens";
|
|
2
|
+
export { AVATAR_SIZE, type AvatarSize, afterAnimations, buttonClass, focusWithoutRing, type IconSize, initials, keepListKeys, leaveEscapeToFields, PEER_FOCUS, PRESSABLE_ROW, pictureClass, switchClass, switchLabelClass, type ThumbnailRatio, } from "@xds/core";
|
|
3
|
+
export { useDefaults } from "./Defaults.tsx";
|
|
4
|
+
export { PlaceRow } from "./ListRow.tsx";
|
|
5
|
+
export { useModalPopover } from "./modal-popover.ts";
|
|
6
|
+
export { usePicture } from "./picture.ts";
|
|
7
|
+
export { Portal } from "./portal.tsx";
|
|
8
|
+
export { usePresence } from "./presence.ts";
|
|
9
|
+
export type { RootProps } from "./root.ts";
|
|
10
|
+
export { TooltipBeside } from "./Tooltip.tsx";
|
|
11
|
+
export { TriggerContext, type TriggerProps, useMergedProps, useProvideTrigger, useTrigger, } from "./trigger.ts";
|
package/dist/base.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { icons, motion, space } from "@xds/tokens";
|
|
2
|
+
export { AVATAR_SIZE, afterAnimations, buttonClass, focusWithoutRing, initials, keepListKeys, leaveEscapeToFields, PEER_FOCUS, PRESSABLE_ROW, pictureClass, switchClass, switchLabelClass } from "@xds/core";
|
|
3
|
+
export { useDefaults } from "./Defaults.js";
|
|
4
|
+
export { PlaceRow } from "./ListRow.js";
|
|
5
|
+
export { useModalPopover } from "./modal-popover.js";
|
|
6
|
+
export { usePicture } from "./picture.js";
|
|
7
|
+
export { Portal } from "./portal.js";
|
|
8
|
+
export { usePresence } from "./presence.js";
|
|
9
|
+
export { TooltipBeside } from "./Tooltip.js";
|
|
10
|
+
export { TriggerContext, useMergedProps, useProvideTrigger, useTrigger } from "./trigger.js";
|
package/dist/modal-popover.js
CHANGED
|
@@ -1,15 +1,37 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
1
2
|
import { ariaHidden } from "@zag-js/aria-hidden";
|
|
2
3
|
import { preventBodyScroll } from "@zag-js/remove-scroll";
|
|
3
4
|
import { useEffect } from "react";
|
|
4
5
|
export function useModalPopover(open, popup) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const $ = _c(5);
|
|
7
|
+
let t0;
|
|
8
|
+
if ($[0] !== open || $[1] !== popup) {
|
|
9
|
+
t0 = () => {
|
|
10
|
+
if (!open) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const unlock = preventBodyScroll(document);
|
|
14
|
+
const reveal = ariaHidden(() => [popup()], {
|
|
15
|
+
defer: true
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
reveal();
|
|
19
|
+
unlock();
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
$[0] = open;
|
|
23
|
+
$[1] = popup;
|
|
24
|
+
$[2] = t0;
|
|
25
|
+
} else {
|
|
26
|
+
t0 = $[2];
|
|
27
|
+
}
|
|
28
|
+
let t1;
|
|
29
|
+
if ($[3] !== open) {
|
|
30
|
+
t1 = [open];
|
|
31
|
+
$[3] = open;
|
|
32
|
+
$[4] = t1;
|
|
33
|
+
} else {
|
|
34
|
+
t1 = $[4];
|
|
35
|
+
}
|
|
36
|
+
useEffect(t0, t1);
|
|
15
37
|
}
|
package/dist/picture.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Follows the loading of the picture at `src`. `loaded` is undefined while it loads, then true
|
|
3
3
|
* or false. The result is remembered with the address it belongs to, so a new `src` starts
|
|
4
|
-
* over without an effect.
|
|
4
|
+
* over without an effect. Spread `image` on the `<img>`.
|
|
5
5
|
*/
|
|
6
6
|
export declare function usePicture(src: string | undefined): {
|
|
7
7
|
loaded: boolean | undefined;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
image: {
|
|
9
|
+
ref: (image: HTMLImageElement | null) => void;
|
|
10
|
+
onLoad: () => void;
|
|
11
|
+
onError: () => void;
|
|
12
|
+
};
|
|
11
13
|
};
|
package/dist/picture.js
CHANGED
|
@@ -1,21 +1,76 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
1
2
|
import { useState } from "react";
|
|
2
3
|
export function usePicture(src) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
onError: () => {
|
|
17
|
-
if (src)
|
|
18
|
-
setPicture({ src, loaded: false });
|
|
19
|
-
},
|
|
4
|
+
const $ = _c(13);
|
|
5
|
+
const [picture, setPicture] = useState();
|
|
6
|
+
const loaded = picture !== undefined && picture.src === src ? picture.loaded : undefined;
|
|
7
|
+
let t0;
|
|
8
|
+
if ($[0] !== loaded || $[1] !== src) {
|
|
9
|
+
t0 = image => {
|
|
10
|
+
if (src && image?.complete && image.naturalWidth > 0 && loaded === undefined) {
|
|
11
|
+
setPicture({
|
|
12
|
+
src,
|
|
13
|
+
loaded: true
|
|
14
|
+
});
|
|
15
|
+
}
|
|
20
16
|
};
|
|
17
|
+
$[0] = loaded;
|
|
18
|
+
$[1] = src;
|
|
19
|
+
$[2] = t0;
|
|
20
|
+
} else {
|
|
21
|
+
t0 = $[2];
|
|
22
|
+
}
|
|
23
|
+
let t1;
|
|
24
|
+
let t2;
|
|
25
|
+
if ($[3] !== src) {
|
|
26
|
+
t1 = () => {
|
|
27
|
+
if (src) {
|
|
28
|
+
setPicture({
|
|
29
|
+
src,
|
|
30
|
+
loaded: true
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
t2 = () => {
|
|
35
|
+
if (src) {
|
|
36
|
+
setPicture({
|
|
37
|
+
src,
|
|
38
|
+
loaded: false
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
$[3] = src;
|
|
43
|
+
$[4] = t1;
|
|
44
|
+
$[5] = t2;
|
|
45
|
+
} else {
|
|
46
|
+
t1 = $[4];
|
|
47
|
+
t2 = $[5];
|
|
48
|
+
}
|
|
49
|
+
let t3;
|
|
50
|
+
if ($[6] !== t0 || $[7] !== t1 || $[8] !== t2) {
|
|
51
|
+
t3 = {
|
|
52
|
+
ref: t0,
|
|
53
|
+
onLoad: t1,
|
|
54
|
+
onError: t2
|
|
55
|
+
};
|
|
56
|
+
$[6] = t0;
|
|
57
|
+
$[7] = t1;
|
|
58
|
+
$[8] = t2;
|
|
59
|
+
$[9] = t3;
|
|
60
|
+
} else {
|
|
61
|
+
t3 = $[9];
|
|
62
|
+
}
|
|
63
|
+
let t4;
|
|
64
|
+
if ($[10] !== loaded || $[11] !== t3) {
|
|
65
|
+
t4 = {
|
|
66
|
+
loaded,
|
|
67
|
+
image: t3
|
|
68
|
+
};
|
|
69
|
+
$[10] = loaded;
|
|
70
|
+
$[11] = t3;
|
|
71
|
+
$[12] = t4;
|
|
72
|
+
} else {
|
|
73
|
+
t4 = $[12];
|
|
74
|
+
}
|
|
75
|
+
return t4;
|
|
21
76
|
}
|
package/dist/portal.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
1
2
|
import { useSyncExternalStore } from "react";
|
|
2
3
|
import { createPortal } from "react-dom";
|
|
3
|
-
const subscribe = () => () => {
|
|
4
|
-
export function Portal(
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const subscribe = () => () => {};
|
|
5
|
+
export function Portal(t0) {
|
|
6
|
+
const $ = _c(3);
|
|
7
|
+
const {
|
|
8
|
+
children
|
|
9
|
+
} = t0;
|
|
10
|
+
const client = useSyncExternalStore(subscribe, _temp, _temp2);
|
|
11
|
+
let t1;
|
|
12
|
+
if ($[0] !== children || $[1] !== client) {
|
|
13
|
+
t1 = client ? createPortal(children, document.body) : null;
|
|
14
|
+
$[0] = children;
|
|
15
|
+
$[1] = client;
|
|
16
|
+
$[2] = t1;
|
|
17
|
+
} else {
|
|
18
|
+
t1 = $[2];
|
|
19
|
+
}
|
|
20
|
+
return t1;
|
|
21
|
+
}
|
|
22
|
+
function _temp2() {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
function _temp() {
|
|
26
|
+
return true;
|
|
7
27
|
}
|
package/dist/presence.js
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
1
2
|
import { afterAnimations } from "@xds/core";
|
|
2
3
|
import { useEffect, useState } from "react";
|
|
3
4
|
export function usePresence(open, parts) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const $ = _c(5);
|
|
6
|
+
const [exited, setExited] = useState(!open);
|
|
7
|
+
if (open && exited) {
|
|
8
|
+
setExited(false);
|
|
9
|
+
}
|
|
10
|
+
let t0;
|
|
11
|
+
if ($[0] !== open || $[1] !== parts) {
|
|
12
|
+
t0 = () => {
|
|
13
|
+
if (open) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return afterAnimations(parts(), () => setExited(true));
|
|
17
|
+
};
|
|
18
|
+
$[0] = open;
|
|
19
|
+
$[1] = parts;
|
|
20
|
+
$[2] = t0;
|
|
21
|
+
} else {
|
|
22
|
+
t0 = $[2];
|
|
23
|
+
}
|
|
24
|
+
let t1;
|
|
25
|
+
if ($[3] !== open) {
|
|
26
|
+
t1 = [open];
|
|
27
|
+
$[3] = open;
|
|
28
|
+
$[4] = t1;
|
|
29
|
+
} else {
|
|
30
|
+
t1 = $[4];
|
|
31
|
+
}
|
|
32
|
+
useEffect(t0, t1);
|
|
33
|
+
return open || !exited;
|
|
13
34
|
}
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import { type Screen } from "@xds/core/preview";
|
|
2
|
-
import { type ReactNode } from "react";
|
|
1
|
+
import { type ComponentName, type Components, type Screen } from "@xds/core/preview";
|
|
2
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
3
3
|
export { designPreview } from "@xds/core/preview";
|
|
4
|
-
|
|
4
|
+
type Given<N extends ComponentName> = Omit<Components<ReactNode>[N], "class"> & ("class" extends keyof Components<ReactNode>[N] ? {
|
|
5
|
+
className?: Components<ReactNode>[N]["class"];
|
|
6
|
+
} : unknown);
|
|
7
|
+
/**
|
|
8
|
+
* Components to draw in place of the library's, by name: an app's ejected copies (`xds eject`),
|
|
9
|
+
* which the design preview then shows as it shows the library's.
|
|
10
|
+
*/
|
|
11
|
+
export type PreviewComponents = {
|
|
12
|
+
[N in ComponentName]?: ComponentType<Given<N>>;
|
|
13
|
+
};
|
|
14
|
+
export declare function Preview({ screen, components, }: {
|
|
5
15
|
screen: Screen;
|
|
16
|
+
components?: PreviewComponents;
|
|
6
17
|
}): ReactNode;
|
package/dist/preview.js
CHANGED
|
@@ -1,82 +1,126 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { isNode, resolve } from "@xds/core/preview";
|
|
3
|
+
import { createElement, Fragment, useEffect, useState } from "react";
|
|
4
|
+
import { Accordion, Avatar, AvatarStack, Badge, Banner, Button, Card, Checkbox, Chip, ChipBar, CountBadge, DatePicker, DateRangePicker, Defaults, Dialog, Divider, EmptyState, Icon, IconButton, ListRow, MediaCard, Menu, ProgressBar, RadioGroup, SearchField, SectionHeader, SegmentedControl, Select, Sidebar, Skeleton, Slider, Spinner, Switch, Tabs, Text, TextField, Thumbnail, Toast, Tooltip } from "./index.js";
|
|
4
5
|
export { designPreview } from "@xds/core/preview";
|
|
5
6
|
const COMPONENTS = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
7
|
+
Accordion,
|
|
8
|
+
Avatar,
|
|
9
|
+
AvatarStack,
|
|
10
|
+
Badge,
|
|
11
|
+
Banner,
|
|
12
|
+
Button,
|
|
13
|
+
Card,
|
|
14
|
+
Checkbox,
|
|
15
|
+
Chip,
|
|
16
|
+
ChipBar,
|
|
17
|
+
CountBadge,
|
|
18
|
+
DatePicker,
|
|
19
|
+
DateRangePicker,
|
|
20
|
+
Defaults,
|
|
21
|
+
Dialog,
|
|
22
|
+
Divider,
|
|
23
|
+
EmptyState,
|
|
24
|
+
Icon,
|
|
25
|
+
IconButton,
|
|
26
|
+
ListRow,
|
|
27
|
+
MediaCard,
|
|
28
|
+
Menu,
|
|
29
|
+
ProgressBar,
|
|
30
|
+
RadioGroup,
|
|
31
|
+
SearchField,
|
|
32
|
+
SectionHeader,
|
|
33
|
+
SegmentedControl,
|
|
34
|
+
Select,
|
|
35
|
+
Sidebar,
|
|
36
|
+
Skeleton,
|
|
37
|
+
Slider,
|
|
38
|
+
Spinner,
|
|
39
|
+
Switch,
|
|
40
|
+
Tabs,
|
|
41
|
+
Text,
|
|
42
|
+
TextField,
|
|
43
|
+
Thumbnail,
|
|
44
|
+
Toast,
|
|
45
|
+
Tooltip
|
|
45
46
|
};
|
|
46
47
|
const _lacking = {};
|
|
47
|
-
const camel =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const camel = name => name.startsWith("--") ? name : name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
49
|
+
export function Preview(t0) {
|
|
50
|
+
const $ = _c(8);
|
|
51
|
+
const {
|
|
52
|
+
screen,
|
|
53
|
+
components
|
|
54
|
+
} = t0;
|
|
55
|
+
const [state, setState] = useState(screen.state);
|
|
56
|
+
let t1;
|
|
57
|
+
let t2;
|
|
58
|
+
if ($[0] !== screen) {
|
|
59
|
+
t1 = () => screen.mount?.();
|
|
60
|
+
t2 = [screen];
|
|
61
|
+
$[0] = screen;
|
|
62
|
+
$[1] = t1;
|
|
63
|
+
$[2] = t2;
|
|
64
|
+
} else {
|
|
65
|
+
t1 = $[1];
|
|
66
|
+
t2 = $[2];
|
|
67
|
+
}
|
|
68
|
+
useEffect(t1, t2);
|
|
69
|
+
let t3;
|
|
70
|
+
if ($[3] !== components || $[4] !== screen.root || $[5] !== state) {
|
|
71
|
+
let t4;
|
|
72
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
73
|
+
t4 = patch => setState(current => ({
|
|
74
|
+
...current,
|
|
75
|
+
...patch
|
|
76
|
+
}));
|
|
77
|
+
$[7] = t4;
|
|
78
|
+
} else {
|
|
79
|
+
t4 = $[7];
|
|
80
|
+
}
|
|
53
81
|
const host = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
state,
|
|
83
|
+
set: t4,
|
|
84
|
+
draw: slot => {
|
|
85
|
+
if (Array.isArray(slot)) {
|
|
86
|
+
return createElement(Fragment, null, ...slot.map(host.draw));
|
|
87
|
+
}
|
|
88
|
+
if (typeof slot === "function") {
|
|
89
|
+
return slot(state);
|
|
90
|
+
}
|
|
91
|
+
if (!isNode(slot)) {
|
|
92
|
+
return slot;
|
|
93
|
+
}
|
|
94
|
+
if (slot.kind === "show") {
|
|
95
|
+
return host.draw(slot.when(state) ? slot.children : slot.fallback);
|
|
96
|
+
}
|
|
97
|
+
const props = {};
|
|
98
|
+
for (const [key, value] of Object.entries(slot.props)) {
|
|
99
|
+
if (key === "class") {
|
|
100
|
+
props.className = resolve(value, key, host);
|
|
101
|
+
} else {
|
|
102
|
+
if (key === "style") {
|
|
103
|
+
props.style = Object.fromEntries(Object.entries(value).map(_temp));
|
|
104
|
+
} else {
|
|
105
|
+
props[key] = resolve(value, key, host);
|
|
74
106
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const type = slot.kind === "element" ? slot.tag : components?.[slot.name] ?? COMPONENTS[slot.name];
|
|
110
|
+
return createElement(type, props, ...slot.children.map(host.draw));
|
|
111
|
+
}
|
|
80
112
|
};
|
|
81
|
-
|
|
113
|
+
t3 = host.draw(screen.root);
|
|
114
|
+
$[3] = components;
|
|
115
|
+
$[4] = screen.root;
|
|
116
|
+
$[5] = state;
|
|
117
|
+
$[6] = t3;
|
|
118
|
+
} else {
|
|
119
|
+
t3 = $[6];
|
|
120
|
+
}
|
|
121
|
+
return t3;
|
|
122
|
+
}
|
|
123
|
+
function _temp(t0) {
|
|
124
|
+
const [name, css] = t0;
|
|
125
|
+
return [camel(name), css];
|
|
82
126
|
}
|
package/dist/root.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|