@xds/react 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +19 -2
- package/dist/Accordion.d.ts +20 -0
- package/dist/Accordion.js +197 -0
- package/dist/Avatar.d.ts +9 -0
- package/dist/Avatar.js +69 -0
- package/dist/AvatarStack.d.ts +8 -0
- package/dist/AvatarStack.js +105 -0
- package/dist/Badge.d.ts +13 -0
- package/dist/Badge.js +66 -0
- package/dist/Banner.d.ts +23 -0
- package/dist/Banner.js +166 -0
- package/dist/Button.d.ts +14 -0
- package/dist/Button.js +159 -0
- package/dist/Card.d.ts +18 -0
- package/dist/Card.js +173 -0
- package/dist/Checkbox.d.ts +10 -0
- package/dist/Checkbox.js +140 -0
- package/dist/Chip.d.ts +12 -0
- package/dist/Chip.js +74 -0
- package/dist/ChipBar.d.ts +12 -0
- package/dist/ChipBar.js +38 -0
- package/dist/CountBadge.d.ts +12 -0
- package/dist/CountBadge.js +64 -0
- package/dist/DatePicker.d.ts +20 -0
- package/dist/DatePicker.js +429 -0
- package/dist/DateRangePicker.d.ts +24 -0
- package/dist/DateRangePicker.js +370 -0
- package/dist/Defaults.d.ts +17 -0
- package/dist/Defaults.js +48 -0
- package/dist/Dialog.d.ts +20 -0
- package/dist/Dialog.js +137 -0
- package/dist/Divider.d.ts +4 -0
- package/dist/Divider.js +31 -0
- package/dist/EmptyState.d.ts +12 -0
- package/dist/EmptyState.js +86 -0
- package/dist/Icon.d.ts +9 -0
- package/dist/Icon.js +79 -0
- package/dist/IconButton.d.ts +12 -0
- package/dist/IconButton.js +119 -0
- package/dist/ListRow.d.ts +21 -0
- package/dist/ListRow.js +185 -0
- package/dist/MediaCard.d.ts +20 -0
- package/dist/MediaCard.js +279 -0
- package/dist/Menu.d.ts +18 -0
- package/dist/Menu.js +244 -0
- package/dist/ProgressBar.d.ts +8 -0
- package/dist/ProgressBar.js +65 -0
- package/dist/RadioGroup.d.ts +15 -0
- package/dist/RadioGroup.js +176 -0
- package/dist/SearchField.d.ts +15 -0
- package/dist/SearchField.js +152 -0
- package/dist/SectionHeader.d.ts +14 -0
- package/dist/SectionHeader.js +124 -0
- package/dist/SegmentedControl.d.ts +12 -0
- package/dist/SegmentedControl.js +106 -0
- package/dist/Select.d.ts +18 -0
- package/dist/Select.js +318 -0
- package/dist/Sidebar.d.ts +21 -0
- package/dist/Sidebar.js +220 -0
- package/dist/Skeleton.d.ts +11 -0
- package/dist/Skeleton.js +64 -0
- package/dist/Slider.d.ts +13 -0
- package/dist/Slider.js +151 -0
- package/dist/Spinner.d.ts +9 -0
- package/dist/Spinner.js +97 -0
- package/dist/Switch.d.ts +13 -0
- package/dist/Switch.js +116 -0
- package/dist/Tabs.d.ts +14 -0
- package/dist/Tabs.js +137 -0
- package/dist/Text.d.ts +10 -0
- package/dist/Text.js +46 -0
- package/dist/TextField.d.ts +22 -0
- package/dist/TextField.js +213 -0
- package/dist/Thumbnail.d.ts +9 -0
- package/dist/Thumbnail.js +152 -0
- package/dist/Toast.d.ts +14 -0
- package/dist/Toast.js +121 -0
- package/dist/Tooltip.d.ts +26 -0
- package/dist/Tooltip.js +166 -0
- package/dist/base.d.ts +11 -0
- package/dist/base.js +10 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +39 -0
- package/dist/modal-popover.d.ts +7 -0
- package/dist/modal-popover.js +37 -0
- package/dist/picture.d.ts +13 -0
- package/dist/picture.js +76 -0
- package/dist/portal.d.ts +9 -0
- package/dist/portal.js +27 -0
- package/dist/presence.d.ts +6 -0
- package/dist/presence.js +34 -0
- package/dist/preview.d.ts +17 -0
- package/dist/preview.js +126 -0
- package/dist/root.d.ts +12 -0
- package/dist/root.js +1 -0
- package/dist/trigger.d.ts +24 -0
- package/dist/trigger.js +47 -0
- 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 +66 -4
- package/page.css +20 -0
- package/styles.css +3252 -0
- package/tailwind.css +2665 -0
package/dist/Slider.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { classes, focusThumbOnPress, sliderArrowValue, sliderPageSize, sliderValueText } from "@xds/core";
|
|
3
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
4
|
+
import * as slider from "@zag-js/slider";
|
|
5
|
+
import { useId, useRef } from "react";
|
|
6
|
+
import { useMergedProps } from "./trigger.js";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
export function Slider(t0) {
|
|
9
|
+
const $ = _c(10);
|
|
10
|
+
const {
|
|
11
|
+
label,
|
|
12
|
+
value,
|
|
13
|
+
onChange,
|
|
14
|
+
min: t1,
|
|
15
|
+
max: t2,
|
|
16
|
+
step: t3,
|
|
17
|
+
disabled: t4,
|
|
18
|
+
showValue: t5,
|
|
19
|
+
className,
|
|
20
|
+
style
|
|
21
|
+
} = t0;
|
|
22
|
+
const min = t1 === undefined ? 0 : t1;
|
|
23
|
+
const max = t2 === undefined ? 100 : t2;
|
|
24
|
+
const step = t3 === undefined ? 1 : t3;
|
|
25
|
+
const disabled = t4 === undefined ? false : t4;
|
|
26
|
+
const showValue = t5 === undefined ? false : t5;
|
|
27
|
+
const pageSize = sliderPageSize({
|
|
28
|
+
min,
|
|
29
|
+
max,
|
|
30
|
+
step
|
|
31
|
+
});
|
|
32
|
+
let t6;
|
|
33
|
+
if ($[0] !== min || $[1] !== onChange) {
|
|
34
|
+
t6 = details => onChange(details.value[0] ?? min);
|
|
35
|
+
$[0] = min;
|
|
36
|
+
$[1] = onChange;
|
|
37
|
+
$[2] = t6;
|
|
38
|
+
} else {
|
|
39
|
+
t6 = $[2];
|
|
40
|
+
}
|
|
41
|
+
const service = useMachine(slider.machine, {
|
|
42
|
+
id: useId(),
|
|
43
|
+
value: [value],
|
|
44
|
+
onValueChange: t6,
|
|
45
|
+
min,
|
|
46
|
+
max,
|
|
47
|
+
step,
|
|
48
|
+
largeStep: pageSize,
|
|
49
|
+
disabled,
|
|
50
|
+
thumbAlignment: "center",
|
|
51
|
+
getAriaValueText: _temp
|
|
52
|
+
});
|
|
53
|
+
const api = slider.connect(service, normalizeProps);
|
|
54
|
+
const thumbElement = useRef(null);
|
|
55
|
+
const thumb = mergeProps(api.getThumbProps({
|
|
56
|
+
index: 0
|
|
57
|
+
}), {
|
|
58
|
+
onKeyDown: event => {
|
|
59
|
+
if (disabled) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const next = sliderArrowValue(event, {
|
|
63
|
+
value: api.value[0] ?? min,
|
|
64
|
+
min,
|
|
65
|
+
max,
|
|
66
|
+
step,
|
|
67
|
+
pageSize
|
|
68
|
+
});
|
|
69
|
+
if (next !== undefined) {
|
|
70
|
+
api.setThumbValue(0, next);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
let t7;
|
|
75
|
+
if ($[3] !== disabled) {
|
|
76
|
+
t7 = {
|
|
77
|
+
onPointerDown: event_0 => {
|
|
78
|
+
if (!disabled) {
|
|
79
|
+
focusThumbOnPress(event_0, thumbElement.current);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
$[3] = disabled;
|
|
84
|
+
$[4] = t7;
|
|
85
|
+
} else {
|
|
86
|
+
t7 = $[4];
|
|
87
|
+
}
|
|
88
|
+
const control = useMergedProps(api.getControlProps(), t7);
|
|
89
|
+
const t8 = mergeProps(api.getRootProps(), {
|
|
90
|
+
className: classes("xds-slider", className),
|
|
91
|
+
style
|
|
92
|
+
});
|
|
93
|
+
const t9 = api.getLabelProps().id;
|
|
94
|
+
const t10 = "xds-slider__thumb";
|
|
95
|
+
const t11 = api.getHiddenInputProps({
|
|
96
|
+
index: 0
|
|
97
|
+
});
|
|
98
|
+
let t12;
|
|
99
|
+
if ($[5] !== t11) {
|
|
100
|
+
t12 = /*#__PURE__*/_jsx("input", {
|
|
101
|
+
...t11
|
|
102
|
+
});
|
|
103
|
+
$[5] = t11;
|
|
104
|
+
$[6] = t12;
|
|
105
|
+
} else {
|
|
106
|
+
t12 = $[6];
|
|
107
|
+
}
|
|
108
|
+
let t13;
|
|
109
|
+
if ($[7] !== t12 || $[8] !== thumb) {
|
|
110
|
+
t13 = /*#__PURE__*/_jsx("div", {
|
|
111
|
+
...thumb,
|
|
112
|
+
ref: thumbElement,
|
|
113
|
+
className: t10,
|
|
114
|
+
children: t12
|
|
115
|
+
});
|
|
116
|
+
$[7] = t12;
|
|
117
|
+
$[8] = thumb;
|
|
118
|
+
$[9] = t13;
|
|
119
|
+
} else {
|
|
120
|
+
t13 = $[9];
|
|
121
|
+
}
|
|
122
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
123
|
+
...t8,
|
|
124
|
+
role: "group",
|
|
125
|
+
"aria-labelledby": t9,
|
|
126
|
+
children: [/*#__PURE__*/_jsx("label", {
|
|
127
|
+
...api.getLabelProps(),
|
|
128
|
+
className: "xds-slider__label",
|
|
129
|
+
children: label
|
|
130
|
+
}), showValue && /*#__PURE__*/_jsx("output", {
|
|
131
|
+
...api.getValueTextProps(),
|
|
132
|
+
"aria-live": "off",
|
|
133
|
+
className: "xds-slider__output",
|
|
134
|
+
children: sliderValueText(api.value[0] ?? value)
|
|
135
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
136
|
+
...control,
|
|
137
|
+
className: "xds-slider__control",
|
|
138
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
139
|
+
...api.getTrackProps(),
|
|
140
|
+
className: "xds-slider__track",
|
|
141
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
142
|
+
...api.getRangeProps(),
|
|
143
|
+
className: "xds-slider__range"
|
|
144
|
+
})
|
|
145
|
+
}), t13]
|
|
146
|
+
})]
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function _temp(details_0) {
|
|
150
|
+
return sliderValueText(details_0.value);
|
|
151
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SpinnerBaseProps } from "@xds/core";
|
|
2
|
+
import type { RootProps } from "./root.ts";
|
|
3
|
+
export type SpinnerProps = SpinnerBaseProps & RootProps;
|
|
4
|
+
/**
|
|
5
|
+
* Says that something is in progress and how long is unknown. Takes the color of the text around
|
|
6
|
+
* it. With `label` it is announced; without one it is decoration next to text that already says
|
|
7
|
+
* what is happening.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Spinner(props: SpinnerProps): import("react").JSX.Element;
|
package/dist/Spinner.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { classes, rootPart, spinnerClass } from "@xds/core";
|
|
3
|
+
import { useDefaults } from "./Defaults.js";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export function Spinner(props) {
|
|
6
|
+
const $ = _c(15);
|
|
7
|
+
const defaults = useDefaults("Spinner");
|
|
8
|
+
const {
|
|
9
|
+
label,
|
|
10
|
+
className,
|
|
11
|
+
style
|
|
12
|
+
} = props;
|
|
13
|
+
const size = props.size ?? defaults.size;
|
|
14
|
+
let t0;
|
|
15
|
+
if ($[0] !== className) {
|
|
16
|
+
t0 = classes(rootPart("Spinner"), "inline-flex shrink-0", className);
|
|
17
|
+
$[0] = className;
|
|
18
|
+
$[1] = t0;
|
|
19
|
+
} else {
|
|
20
|
+
t0 = $[1];
|
|
21
|
+
}
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[2] !== label) {
|
|
24
|
+
t1 = label ? {
|
|
25
|
+
role: "status",
|
|
26
|
+
"aria-label": label
|
|
27
|
+
} : {
|
|
28
|
+
"aria-hidden": true
|
|
29
|
+
};
|
|
30
|
+
$[2] = label;
|
|
31
|
+
$[3] = t1;
|
|
32
|
+
} else {
|
|
33
|
+
t1 = $[3];
|
|
34
|
+
}
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[4] !== size) {
|
|
37
|
+
t2 = spinnerClass(size);
|
|
38
|
+
$[4] = size;
|
|
39
|
+
$[5] = t2;
|
|
40
|
+
} else {
|
|
41
|
+
t2 = $[5];
|
|
42
|
+
}
|
|
43
|
+
let t3;
|
|
44
|
+
let t4;
|
|
45
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
46
|
+
t3 = /*#__PURE__*/_jsx("circle", {
|
|
47
|
+
cx: "12",
|
|
48
|
+
cy: "12",
|
|
49
|
+
r: "9",
|
|
50
|
+
stroke: "currentColor",
|
|
51
|
+
strokeWidth: "3",
|
|
52
|
+
opacity: "0.25"
|
|
53
|
+
});
|
|
54
|
+
t4 = /*#__PURE__*/_jsx("path", {
|
|
55
|
+
d: "M21 12a9 9 0 0 0-9-9",
|
|
56
|
+
stroke: "currentColor",
|
|
57
|
+
strokeWidth: "3",
|
|
58
|
+
strokeLinecap: "round"
|
|
59
|
+
});
|
|
60
|
+
$[6] = t3;
|
|
61
|
+
$[7] = t4;
|
|
62
|
+
} else {
|
|
63
|
+
t3 = $[6];
|
|
64
|
+
t4 = $[7];
|
|
65
|
+
}
|
|
66
|
+
let t5;
|
|
67
|
+
if ($[8] !== t2) {
|
|
68
|
+
t5 = /*#__PURE__*/_jsxs("svg", {
|
|
69
|
+
viewBox: "0 0 24 24",
|
|
70
|
+
fill: "none",
|
|
71
|
+
"aria-hidden": "true",
|
|
72
|
+
className: t2,
|
|
73
|
+
children: [t3, t4]
|
|
74
|
+
});
|
|
75
|
+
$[8] = t2;
|
|
76
|
+
$[9] = t5;
|
|
77
|
+
} else {
|
|
78
|
+
t5 = $[9];
|
|
79
|
+
}
|
|
80
|
+
let t6;
|
|
81
|
+
if ($[10] !== style || $[11] !== t0 || $[12] !== t1 || $[13] !== t5) {
|
|
82
|
+
t6 = /*#__PURE__*/_jsx("span", {
|
|
83
|
+
className: t0,
|
|
84
|
+
style: style,
|
|
85
|
+
...t1,
|
|
86
|
+
children: t5
|
|
87
|
+
});
|
|
88
|
+
$[10] = style;
|
|
89
|
+
$[11] = t0;
|
|
90
|
+
$[12] = t1;
|
|
91
|
+
$[13] = t5;
|
|
92
|
+
$[14] = t6;
|
|
93
|
+
} else {
|
|
94
|
+
t6 = $[14];
|
|
95
|
+
}
|
|
96
|
+
return t6;
|
|
97
|
+
}
|
package/dist/Switch.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type SwitchBaseProps } from "@xds/core";
|
|
2
|
+
import type { RootProps } from "./root.ts";
|
|
3
|
+
export type SwitchProps = SwitchBaseProps & RootProps & {
|
|
4
|
+
onChange: (checked: boolean) => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Turns a setting on or off, and takes effect at once. For a choice that is applied later,
|
|
8
|
+
* with a form, use a Checkbox.
|
|
9
|
+
*
|
|
10
|
+
* It is a native checkbox with the switch role, so the keyboard, forms and screen readers
|
|
11
|
+
* treat it as one. The input is hidden and the track is drawn beside it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function Switch({ checked, onChange, label, disabled, className, style, ...aria }: SwitchProps): import("react").JSX.Element;
|
package/dist/Switch.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { classes, rootPart, switchClass, switchLabelClass, switchThumbClass, switchTrackClass } from "@xds/core";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
export function Switch(t0) {
|
|
5
|
+
const $ = _c(25);
|
|
6
|
+
let aria;
|
|
7
|
+
let checked;
|
|
8
|
+
let className;
|
|
9
|
+
let label;
|
|
10
|
+
let onChange;
|
|
11
|
+
let style;
|
|
12
|
+
let t1;
|
|
13
|
+
if ($[0] !== t0) {
|
|
14
|
+
({
|
|
15
|
+
checked,
|
|
16
|
+
onChange,
|
|
17
|
+
label,
|
|
18
|
+
disabled: t1,
|
|
19
|
+
className,
|
|
20
|
+
style,
|
|
21
|
+
...aria
|
|
22
|
+
} = t0);
|
|
23
|
+
$[0] = t0;
|
|
24
|
+
$[1] = aria;
|
|
25
|
+
$[2] = checked;
|
|
26
|
+
$[3] = className;
|
|
27
|
+
$[4] = label;
|
|
28
|
+
$[5] = onChange;
|
|
29
|
+
$[6] = style;
|
|
30
|
+
$[7] = t1;
|
|
31
|
+
} else {
|
|
32
|
+
aria = $[1];
|
|
33
|
+
checked = $[2];
|
|
34
|
+
className = $[3];
|
|
35
|
+
label = $[4];
|
|
36
|
+
onChange = $[5];
|
|
37
|
+
style = $[6];
|
|
38
|
+
t1 = $[7];
|
|
39
|
+
}
|
|
40
|
+
const disabled = t1 === undefined ? false : t1;
|
|
41
|
+
let t2;
|
|
42
|
+
if ($[8] !== className) {
|
|
43
|
+
t2 = classes(rootPart("Switch"), switchClass, className);
|
|
44
|
+
$[8] = className;
|
|
45
|
+
$[9] = t2;
|
|
46
|
+
} else {
|
|
47
|
+
t2 = $[9];
|
|
48
|
+
}
|
|
49
|
+
let t3;
|
|
50
|
+
if ($[10] !== onChange) {
|
|
51
|
+
t3 = event => onChange(event.target.checked);
|
|
52
|
+
$[10] = onChange;
|
|
53
|
+
$[11] = t3;
|
|
54
|
+
} else {
|
|
55
|
+
t3 = $[11];
|
|
56
|
+
}
|
|
57
|
+
let t4;
|
|
58
|
+
if ($[12] !== aria || $[13] !== checked || $[14] !== disabled || $[15] !== t3) {
|
|
59
|
+
t4 = /*#__PURE__*/_jsx("input", {
|
|
60
|
+
...aria,
|
|
61
|
+
type: "checkbox",
|
|
62
|
+
role: "switch",
|
|
63
|
+
"aria-checked": checked,
|
|
64
|
+
className: "peer sr-only",
|
|
65
|
+
checked: checked,
|
|
66
|
+
disabled: disabled,
|
|
67
|
+
onChange: t3
|
|
68
|
+
});
|
|
69
|
+
$[12] = aria;
|
|
70
|
+
$[13] = checked;
|
|
71
|
+
$[14] = disabled;
|
|
72
|
+
$[15] = t3;
|
|
73
|
+
$[16] = t4;
|
|
74
|
+
} else {
|
|
75
|
+
t4 = $[16];
|
|
76
|
+
}
|
|
77
|
+
let t5;
|
|
78
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
79
|
+
t5 = /*#__PURE__*/_jsx("span", {
|
|
80
|
+
className: switchTrackClass,
|
|
81
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
82
|
+
className: switchThumbClass
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
$[17] = t5;
|
|
86
|
+
} else {
|
|
87
|
+
t5 = $[17];
|
|
88
|
+
}
|
|
89
|
+
let t6;
|
|
90
|
+
if ($[18] !== label) {
|
|
91
|
+
t6 = label && /*#__PURE__*/_jsx("span", {
|
|
92
|
+
className: switchLabelClass,
|
|
93
|
+
children: label
|
|
94
|
+
});
|
|
95
|
+
$[18] = label;
|
|
96
|
+
$[19] = t6;
|
|
97
|
+
} else {
|
|
98
|
+
t6 = $[19];
|
|
99
|
+
}
|
|
100
|
+
let t7;
|
|
101
|
+
if ($[20] !== style || $[21] !== t2 || $[22] !== t4 || $[23] !== t6) {
|
|
102
|
+
t7 = /*#__PURE__*/_jsxs("label", {
|
|
103
|
+
className: t2,
|
|
104
|
+
style: style,
|
|
105
|
+
children: [t4, t5, t6]
|
|
106
|
+
});
|
|
107
|
+
$[20] = style;
|
|
108
|
+
$[21] = t2;
|
|
109
|
+
$[22] = t4;
|
|
110
|
+
$[23] = t6;
|
|
111
|
+
$[24] = t7;
|
|
112
|
+
} else {
|
|
113
|
+
t7 = $[24];
|
|
114
|
+
}
|
|
115
|
+
return t7;
|
|
116
|
+
}
|
package/dist/Tabs.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type TabsBaseProps } from "@xds/core";
|
|
2
|
+
import type { RootProps } from "./root.ts";
|
|
3
|
+
export type TabsProps<Value extends string> = TabsBaseProps<Value> & RootProps & {
|
|
4
|
+
onChange: (value: Value) => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Switches between views inside one screen. For two to four short modes a SegmentedControl is
|
|
8
|
+
* lighter; tabs are for more items, longer labels, or a row that may have to scroll.
|
|
9
|
+
*
|
|
10
|
+
* The selected tab is underlined as well as darker, so the choice does not depend on color.
|
|
11
|
+
* This is only the row: the app shows the view that matches `value`. The arrow keys move
|
|
12
|
+
* between tabs.
|
|
13
|
+
*/
|
|
14
|
+
export declare function Tabs<Value extends string>({ items, value, onChange, label, fullWidth, className, style, }: TabsProps<Value>): import("react").JSX.Element;
|
package/dist/Tabs.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { classes, tabStopIndex, tabsClass } from "@xds/core";
|
|
3
|
+
import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
|
|
4
|
+
import * as tabs from "@zag-js/tabs";
|
|
5
|
+
import { useId } from "react";
|
|
6
|
+
import { Icon } from "./Icon.js";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
export function Tabs(t0) {
|
|
9
|
+
const $ = _c(29);
|
|
10
|
+
const {
|
|
11
|
+
items,
|
|
12
|
+
value,
|
|
13
|
+
onChange,
|
|
14
|
+
label,
|
|
15
|
+
fullWidth: t1,
|
|
16
|
+
className,
|
|
17
|
+
style
|
|
18
|
+
} = t0;
|
|
19
|
+
const fullWidth = t1 === undefined ? false : t1;
|
|
20
|
+
const t2 = useId();
|
|
21
|
+
let t3;
|
|
22
|
+
if ($[0] !== onChange) {
|
|
23
|
+
t3 = details => onChange(details.value);
|
|
24
|
+
$[0] = onChange;
|
|
25
|
+
$[1] = t3;
|
|
26
|
+
} else {
|
|
27
|
+
t3 = $[1];
|
|
28
|
+
}
|
|
29
|
+
let t4;
|
|
30
|
+
if ($[2] !== t2 || $[3] !== t3 || $[4] !== value) {
|
|
31
|
+
t4 = {
|
|
32
|
+
id: t2,
|
|
33
|
+
value,
|
|
34
|
+
onValueChange: t3
|
|
35
|
+
};
|
|
36
|
+
$[2] = t2;
|
|
37
|
+
$[3] = t3;
|
|
38
|
+
$[4] = value;
|
|
39
|
+
$[5] = t4;
|
|
40
|
+
} else {
|
|
41
|
+
t4 = $[5];
|
|
42
|
+
}
|
|
43
|
+
const service = useMachine(tabs.machine, t4);
|
|
44
|
+
let t10;
|
|
45
|
+
let t5;
|
|
46
|
+
let t6;
|
|
47
|
+
let t7;
|
|
48
|
+
let t8;
|
|
49
|
+
let t9;
|
|
50
|
+
if ($[6] !== className || $[7] !== fullWidth || $[8] !== items || $[9] !== label || $[10] !== service || $[11] !== style) {
|
|
51
|
+
const api = tabs.connect(service, normalizeProps);
|
|
52
|
+
t10 = mergeProps(api.getRootProps(), {
|
|
53
|
+
className: classes(tabsClass(fullWidth), className),
|
|
54
|
+
style
|
|
55
|
+
});
|
|
56
|
+
t6 = api.getListProps();
|
|
57
|
+
t7 = label;
|
|
58
|
+
t8 = "xds-tabs__list";
|
|
59
|
+
t9 = items.map(item => {
|
|
60
|
+
const trigger = api.getTriggerProps({
|
|
61
|
+
value: item.value
|
|
62
|
+
});
|
|
63
|
+
return /*#__PURE__*/_jsxs("button", {
|
|
64
|
+
...trigger,
|
|
65
|
+
tabIndex: tabStopIndex(api.focusedValue, item.value, trigger.tabIndex),
|
|
66
|
+
"aria-controls": undefined,
|
|
67
|
+
type: "button",
|
|
68
|
+
className: "xds-tabs__tab",
|
|
69
|
+
children: [item.icon && /*#__PURE__*/_jsx(Icon, {
|
|
70
|
+
name: item.icon,
|
|
71
|
+
size: "sm"
|
|
72
|
+
}), item.label]
|
|
73
|
+
}, item.value);
|
|
74
|
+
});
|
|
75
|
+
t5 = api.getIndicatorProps();
|
|
76
|
+
$[6] = className;
|
|
77
|
+
$[7] = fullWidth;
|
|
78
|
+
$[8] = items;
|
|
79
|
+
$[9] = label;
|
|
80
|
+
$[10] = service;
|
|
81
|
+
$[11] = style;
|
|
82
|
+
$[12] = t10;
|
|
83
|
+
$[13] = t5;
|
|
84
|
+
$[14] = t6;
|
|
85
|
+
$[15] = t7;
|
|
86
|
+
$[16] = t8;
|
|
87
|
+
$[17] = t9;
|
|
88
|
+
} else {
|
|
89
|
+
t10 = $[12];
|
|
90
|
+
t5 = $[13];
|
|
91
|
+
t6 = $[14];
|
|
92
|
+
t7 = $[15];
|
|
93
|
+
t8 = $[16];
|
|
94
|
+
t9 = $[17];
|
|
95
|
+
}
|
|
96
|
+
let t11;
|
|
97
|
+
if ($[18] !== t5) {
|
|
98
|
+
t11 = /*#__PURE__*/_jsx("div", {
|
|
99
|
+
...t5,
|
|
100
|
+
className: "xds-tabs__indicator"
|
|
101
|
+
});
|
|
102
|
+
$[18] = t5;
|
|
103
|
+
$[19] = t11;
|
|
104
|
+
} else {
|
|
105
|
+
t11 = $[19];
|
|
106
|
+
}
|
|
107
|
+
let t12;
|
|
108
|
+
if ($[20] !== t11 || $[21] !== t6 || $[22] !== t7 || $[23] !== t8 || $[24] !== t9) {
|
|
109
|
+
t12 = /*#__PURE__*/_jsxs("div", {
|
|
110
|
+
...t6,
|
|
111
|
+
"aria-label": t7,
|
|
112
|
+
className: t8,
|
|
113
|
+
children: [t9, t11]
|
|
114
|
+
});
|
|
115
|
+
$[20] = t11;
|
|
116
|
+
$[21] = t6;
|
|
117
|
+
$[22] = t7;
|
|
118
|
+
$[23] = t8;
|
|
119
|
+
$[24] = t9;
|
|
120
|
+
$[25] = t12;
|
|
121
|
+
} else {
|
|
122
|
+
t12 = $[25];
|
|
123
|
+
}
|
|
124
|
+
let t13;
|
|
125
|
+
if ($[26] !== t10 || $[27] !== t12) {
|
|
126
|
+
t13 = /*#__PURE__*/_jsx("div", {
|
|
127
|
+
...t10,
|
|
128
|
+
children: t12
|
|
129
|
+
});
|
|
130
|
+
$[26] = t10;
|
|
131
|
+
$[27] = t12;
|
|
132
|
+
$[28] = t13;
|
|
133
|
+
} else {
|
|
134
|
+
t13 = $[28];
|
|
135
|
+
}
|
|
136
|
+
return t13;
|
|
137
|
+
}
|
package/dist/Text.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type TextBaseProps } from "@xds/core";
|
|
2
|
+
import type { ElementType, ReactNode } from "react";
|
|
3
|
+
import type { RootProps } from "./root.ts";
|
|
4
|
+
export type { TextTone, TextVariant } from "@xds/core";
|
|
5
|
+
export type TextProps = TextBaseProps & RootProps & {
|
|
6
|
+
/** The element to render. Pick it for the document outline (`h1`, `h2`, `p`), not for looks. */
|
|
7
|
+
as?: ElementType;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
export declare function Text(props: TextProps): import("react").JSX.Element;
|
package/dist/Text.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { classes, rootPart, textClass } from "@xds/core";
|
|
3
|
+
import { useDefaults } from "./Defaults.js";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export function Text(props) {
|
|
6
|
+
const $ = _c(9);
|
|
7
|
+
const defaults = useDefaults("Text");
|
|
8
|
+
const {
|
|
9
|
+
as: t0,
|
|
10
|
+
className,
|
|
11
|
+
style,
|
|
12
|
+
children
|
|
13
|
+
} = props;
|
|
14
|
+
const Element = t0 === undefined ? "p" : t0;
|
|
15
|
+
const variant = props.variant ?? defaults.variant;
|
|
16
|
+
const tone = props.tone ?? defaults.tone;
|
|
17
|
+
let t1;
|
|
18
|
+
if ($[0] !== className || $[1] !== tone || $[2] !== variant) {
|
|
19
|
+
t1 = classes(rootPart("Text"), textClass({
|
|
20
|
+
variant,
|
|
21
|
+
tone
|
|
22
|
+
}), className);
|
|
23
|
+
$[0] = className;
|
|
24
|
+
$[1] = tone;
|
|
25
|
+
$[2] = variant;
|
|
26
|
+
$[3] = t1;
|
|
27
|
+
} else {
|
|
28
|
+
t1 = $[3];
|
|
29
|
+
}
|
|
30
|
+
let t2;
|
|
31
|
+
if ($[4] !== Element || $[5] !== children || $[6] !== style || $[7] !== t1) {
|
|
32
|
+
t2 = /*#__PURE__*/_jsx(Element, {
|
|
33
|
+
className: t1,
|
|
34
|
+
style: style,
|
|
35
|
+
children: children
|
|
36
|
+
});
|
|
37
|
+
$[4] = Element;
|
|
38
|
+
$[5] = children;
|
|
39
|
+
$[6] = style;
|
|
40
|
+
$[7] = t1;
|
|
41
|
+
$[8] = t2;
|
|
42
|
+
} else {
|
|
43
|
+
t2 = $[8];
|
|
44
|
+
}
|
|
45
|
+
return t2;
|
|
46
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type TextFieldBaseProps } from "@xds/core";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import type { RootProps } from "./root.ts";
|
|
4
|
+
export type TextFieldProps = TextFieldBaseProps & RootProps & {
|
|
5
|
+
onChange: (value: string) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Inside the box, in front of the text: an icon, a unit. It takes the placeholder's color
|
|
8
|
+
* unless it sets its own.
|
|
9
|
+
*/
|
|
10
|
+
leading?: ReactNode;
|
|
11
|
+
/** Inside the box, after the text: an icon, a unit, a small button. */
|
|
12
|
+
trailing?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A labelled text field, of one line or several. The label, the description and the error
|
|
16
|
+
* message are tied to the input for assistive technology, and the error is announced when it
|
|
17
|
+
* appears.
|
|
18
|
+
*
|
|
19
|
+
* An invalid field blocks its form from being submitted, so `error` has to be cleared as soon as
|
|
20
|
+
* the person edits the value.
|
|
21
|
+
*/
|
|
22
|
+
export declare function TextField({ label, value, onChange, description, error, placeholder, leading, trailing, multiline, rows, maxLength, name, type, inputMode, autoComplete, autoFocus, required, disabled, className, style, }: TextFieldProps): import("react").JSX.Element;
|