@castui/cast-ui 4.2.0 → 4.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/dist/components/Alert/Alert.d.ts +0 -1
- package/dist/components/Alert/Alert.js +22 -20
- package/dist/components/Alert/index.d.ts +0 -1
- package/dist/components/Alert/index.js +5 -2
- package/dist/components/Avatar/Avatar.d.ts +0 -1
- package/dist/components/Avatar/Avatar.js +15 -13
- package/dist/components/Avatar/index.d.ts +0 -1
- package/dist/components/Avatar/index.js +5 -2
- package/dist/components/Badge/Badge.d.ts +0 -1
- package/dist/components/Badge/Badge.js +20 -18
- package/dist/components/Badge/index.d.ts +0 -1
- package/dist/components/Badge/index.js +5 -2
- package/dist/components/Button/Button.d.ts +0 -1
- package/dist/components/Button/Button.js +21 -19
- package/dist/components/Button/index.d.ts +0 -1
- package/dist/components/Button/index.js +5 -2
- package/dist/components/Card/Card.d.ts +0 -1
- package/dist/components/Card/Card.js +27 -25
- package/dist/components/Card/index.d.ts +0 -1
- package/dist/components/Card/index.js +5 -2
- package/dist/components/Checkbox/Checkbox.d.ts +0 -1
- package/dist/components/Checkbox/Checkbox.js +23 -21
- package/dist/components/Checkbox/index.d.ts +0 -1
- package/dist/components/Checkbox/index.js +5 -2
- package/dist/components/Chip/Chip.d.ts +0 -1
- package/dist/components/Chip/Chip.js +22 -20
- package/dist/components/Chip/index.d.ts +0 -1
- package/dist/components/Chip/index.js +5 -2
- package/dist/components/Dialog/Dialog.d.ts +0 -1
- package/dist/components/Dialog/Dialog.js +30 -27
- package/dist/components/Dialog/index.d.ts +0 -1
- package/dist/components/Dialog/index.js +6 -2
- package/dist/components/Divider/Divider.d.ts +0 -1
- package/dist/components/Divider/Divider.js +12 -10
- package/dist/components/Divider/index.d.ts +0 -1
- package/dist/components/Divider/index.js +5 -2
- package/dist/components/Icon/Icon.d.ts +0 -1
- package/dist/components/Icon/Icon.js +9 -7
- package/dist/components/Icon/index.d.ts +0 -1
- package/dist/components/Icon/index.js +5 -2
- package/dist/components/Input/Input.d.ts +0 -1
- package/dist/components/Input/Input.js +37 -35
- package/dist/components/Input/index.d.ts +0 -1
- package/dist/components/Input/index.js +5 -2
- package/dist/components/List/List.d.ts +0 -1
- package/dist/components/List/List.js +46 -41
- package/dist/components/List/index.d.ts +0 -1
- package/dist/components/List/index.js +8 -2
- package/dist/components/Popover/Popover.d.ts +0 -1
- package/dist/components/Popover/Popover.js +11 -9
- package/dist/components/Popover/index.d.ts +0 -1
- package/dist/components/Popover/index.js +5 -2
- package/dist/components/Radio/Radio.d.ts +0 -1
- package/dist/components/Radio/Radio.js +29 -26
- package/dist/components/Radio/index.d.ts +0 -1
- package/dist/components/Radio/index.js +6 -2
- package/dist/components/Select/Select.d.ts +0 -1
- package/dist/components/Select/Select.js +102 -95
- package/dist/components/Select/index.d.ts +0 -1
- package/dist/components/Select/index.js +10 -2
- package/dist/components/Skeleton/Skeleton.d.ts +0 -1
- package/dist/components/Skeleton/Skeleton.js +15 -13
- package/dist/components/Skeleton/index.d.ts +0 -1
- package/dist/components/Skeleton/index.js +5 -2
- package/dist/components/Toast/Toast.d.ts +0 -1
- package/dist/components/Toast/Toast.js +23 -21
- package/dist/components/Toast/index.d.ts +0 -1
- package/dist/components/Toast/index.js +5 -2
- package/dist/components/Toggle/Toggle.d.ts +0 -1
- package/dist/components/Toggle/Toggle.js +20 -18
- package/dist/components/Toggle/index.d.ts +0 -1
- package/dist/components/Toggle/index.js +5 -2
- package/dist/components/Tooltip/Tooltip.d.ts +0 -1
- package/dist/components/Tooltip/Tooltip.js +14 -12
- package/dist/components/Tooltip/index.d.ts +0 -1
- package/dist/components/Tooltip/index.js +5 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +81 -22
- package/dist/theme/ThemeContext.d.ts +0 -1
- package/dist/theme/ThemeContext.js +20 -17
- package/dist/theme/index.d.ts +0 -1
- package/dist/theme/index.js +8 -3
- package/dist/theme/themes.d.ts +0 -1
- package/dist/theme/themes.js +4 -2
- package/dist/theme/types.d.ts +0 -1
- package/dist/theme/types.js +2 -2
- package/dist/tokens/colors.d.ts +0 -1
- package/dist/tokens/colors.js +25 -23
- package/dist/tokens/index.d.ts +0 -1
- package/dist/tokens/index.js +29 -3
- package/dist/tokens/typography.d.ts +0 -1
- package/dist/tokens/typography.js +13 -11
- package/package.json +13 -2
- package/dist/components/Alert/Alert.d.ts.map +0 -1
- package/dist/components/Alert/Alert.js.map +0 -1
- package/dist/components/Alert/index.d.ts.map +0 -1
- package/dist/components/Alert/index.js.map +0 -1
- package/dist/components/Avatar/Avatar.d.ts.map +0 -1
- package/dist/components/Avatar/Avatar.js.map +0 -1
- package/dist/components/Avatar/index.d.ts.map +0 -1
- package/dist/components/Avatar/index.js.map +0 -1
- package/dist/components/Badge/Badge.d.ts.map +0 -1
- package/dist/components/Badge/Badge.js.map +0 -1
- package/dist/components/Badge/index.d.ts.map +0 -1
- package/dist/components/Badge/index.js.map +0 -1
- package/dist/components/Button/Button.d.ts.map +0 -1
- package/dist/components/Button/Button.js.map +0 -1
- package/dist/components/Button/index.d.ts.map +0 -1
- package/dist/components/Button/index.js.map +0 -1
- package/dist/components/Card/Card.d.ts.map +0 -1
- package/dist/components/Card/Card.js.map +0 -1
- package/dist/components/Card/index.d.ts.map +0 -1
- package/dist/components/Card/index.js.map +0 -1
- package/dist/components/Checkbox/Checkbox.d.ts.map +0 -1
- package/dist/components/Checkbox/Checkbox.js.map +0 -1
- package/dist/components/Checkbox/index.d.ts.map +0 -1
- package/dist/components/Checkbox/index.js.map +0 -1
- package/dist/components/Chip/Chip.d.ts.map +0 -1
- package/dist/components/Chip/Chip.js.map +0 -1
- package/dist/components/Chip/index.d.ts.map +0 -1
- package/dist/components/Chip/index.js.map +0 -1
- package/dist/components/Dialog/Dialog.d.ts.map +0 -1
- package/dist/components/Dialog/Dialog.js.map +0 -1
- package/dist/components/Dialog/index.d.ts.map +0 -1
- package/dist/components/Dialog/index.js.map +0 -1
- package/dist/components/Divider/Divider.d.ts.map +0 -1
- package/dist/components/Divider/Divider.js.map +0 -1
- package/dist/components/Divider/index.d.ts.map +0 -1
- package/dist/components/Divider/index.js.map +0 -1
- package/dist/components/Icon/Icon.d.ts.map +0 -1
- package/dist/components/Icon/Icon.js.map +0 -1
- package/dist/components/Icon/index.d.ts.map +0 -1
- package/dist/components/Icon/index.js.map +0 -1
- package/dist/components/Input/Input.d.ts.map +0 -1
- package/dist/components/Input/Input.js.map +0 -1
- package/dist/components/Input/index.d.ts.map +0 -1
- package/dist/components/Input/index.js.map +0 -1
- package/dist/components/List/List.d.ts.map +0 -1
- package/dist/components/List/List.js.map +0 -1
- package/dist/components/List/index.d.ts.map +0 -1
- package/dist/components/List/index.js.map +0 -1
- package/dist/components/Popover/Popover.d.ts.map +0 -1
- package/dist/components/Popover/Popover.js.map +0 -1
- package/dist/components/Popover/index.d.ts.map +0 -1
- package/dist/components/Popover/index.js.map +0 -1
- package/dist/components/Radio/Radio.d.ts.map +0 -1
- package/dist/components/Radio/Radio.js.map +0 -1
- package/dist/components/Radio/index.d.ts.map +0 -1
- package/dist/components/Radio/index.js.map +0 -1
- package/dist/components/Select/Select.d.ts.map +0 -1
- package/dist/components/Select/Select.js.map +0 -1
- package/dist/components/Select/index.d.ts.map +0 -1
- package/dist/components/Select/index.js.map +0 -1
- package/dist/components/Skeleton/Skeleton.d.ts.map +0 -1
- package/dist/components/Skeleton/Skeleton.js.map +0 -1
- package/dist/components/Skeleton/index.d.ts.map +0 -1
- package/dist/components/Skeleton/index.js.map +0 -1
- package/dist/components/Toast/Toast.d.ts.map +0 -1
- package/dist/components/Toast/Toast.js.map +0 -1
- package/dist/components/Toast/index.d.ts.map +0 -1
- package/dist/components/Toast/index.js.map +0 -1
- package/dist/components/Toggle/Toggle.d.ts.map +0 -1
- package/dist/components/Toggle/Toggle.js.map +0 -1
- package/dist/components/Toggle/index.d.ts.map +0 -1
- package/dist/components/Toggle/index.js.map +0 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +0 -1
- package/dist/components/Tooltip/Tooltip.js.map +0 -1
- package/dist/components/Tooltip/index.d.ts.map +0 -1
- package/dist/components/Tooltip/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/theme/ThemeContext.d.ts.map +0 -1
- package/dist/theme/ThemeContext.js.map +0 -1
- package/dist/theme/index.d.ts.map +0 -1
- package/dist/theme/index.js.map +0 -1
- package/dist/theme/themes.d.ts.map +0 -1
- package/dist/theme/themes.js.map +0 -1
- package/dist/theme/types.d.ts.map +0 -1
- package/dist/theme/types.js.map +0 -1
- package/dist/tokens/colors.d.ts.map +0 -1
- package/dist/tokens/colors.js.map +0 -1
- package/dist/tokens/index.d.ts.map +0 -1
- package/dist/tokens/index.js.map +0 -1
- package/dist/tokens/typography.d.ts.map +0 -1
- package/dist/tokens/typography.js.map +0 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SelectTag = SelectTag;
|
|
4
|
+
exports.SelectSeparator = SelectSeparator;
|
|
5
|
+
exports.SelectGroup = SelectGroup;
|
|
6
|
+
exports.SelectOption = SelectOption;
|
|
7
|
+
exports.SelectContent = SelectContent;
|
|
8
|
+
exports.Select = Select;
|
|
9
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
10
|
/**
|
|
3
11
|
* Select — form control for choosing from a list of options.
|
|
4
12
|
*
|
|
@@ -18,14 +26,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
18
26
|
* SelectTag — pill badge for multi-select (exported for standalone use)
|
|
19
27
|
* SelectContent — the dropdown card (exported for custom overlay use)
|
|
20
28
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const SelectCtx = createContext(null);
|
|
29
|
+
const react_1 = require("react");
|
|
30
|
+
const react_native_1 = require("react-native");
|
|
31
|
+
const theme_1 = require("../../theme");
|
|
32
|
+
const Icon_1 = require("../Icon");
|
|
33
|
+
const tokens_1 = require("../../tokens");
|
|
34
|
+
const SelectCtx = (0, react_1.createContext)(null);
|
|
27
35
|
function useSelectContext() {
|
|
28
|
-
const ctx = useContext(SelectCtx);
|
|
36
|
+
const ctx = (0, react_1.useContext)(SelectCtx);
|
|
29
37
|
if (!ctx)
|
|
30
38
|
throw new Error('Select sub-components must be used within <Select>');
|
|
31
39
|
return ctx;
|
|
@@ -63,10 +71,10 @@ const SHADOW_NATIVE = {
|
|
|
63
71
|
// ---------------------------------------------------------------------------
|
|
64
72
|
// SelectTag — pill badge for multi-select
|
|
65
73
|
// ---------------------------------------------------------------------------
|
|
66
|
-
|
|
67
|
-
const { scheme } = useTheme();
|
|
74
|
+
function SelectTag({ children, onRemove, disabled = false }) {
|
|
75
|
+
const { scheme } = (0, theme_1.useTheme)();
|
|
68
76
|
const tagTokens = scheme.tag;
|
|
69
|
-
return (
|
|
77
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: {
|
|
70
78
|
flexDirection: 'row',
|
|
71
79
|
alignItems: 'center',
|
|
72
80
|
gap: tagTokens.gap,
|
|
@@ -74,23 +82,23 @@ export function SelectTag({ children, onRemove, disabled = false }) {
|
|
|
74
82
|
borderRadius: tagTokens.borderRadius,
|
|
75
83
|
paddingHorizontal: tagTokens.paddingX,
|
|
76
84
|
paddingVertical: tagTokens.paddingY,
|
|
77
|
-
}, children: [
|
|
78
|
-
fontFamily: fontFamily.sans,
|
|
79
|
-
fontWeight: fontWeight.regular,
|
|
80
|
-
fontSize: caption.fontSize,
|
|
81
|
-
lineHeight: caption.lineHeight,
|
|
82
|
-
letterSpacing: caption.letterSpacing,
|
|
85
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
86
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
87
|
+
fontWeight: tokens_1.fontWeight.regular,
|
|
88
|
+
fontSize: tokens_1.caption.fontSize,
|
|
89
|
+
lineHeight: tokens_1.caption.lineHeight,
|
|
90
|
+
letterSpacing: tokens_1.caption.letterSpacing,
|
|
83
91
|
color: tagTokens.fg,
|
|
84
|
-
}, selectable: false, children: children }), onRemove && !disabled ? (
|
|
92
|
+
}, selectable: false, children: children }), onRemove && !disabled ? ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onPress: onRemove, hitSlop: 4, accessibilityRole: "button", accessibilityLabel: `Remove ${children}`, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "close", size: tagTokens.closeSize, color: tagTokens.fg }) })) : null] }));
|
|
85
93
|
}
|
|
86
94
|
// ---------------------------------------------------------------------------
|
|
87
95
|
// SelectSeparator — visual divider
|
|
88
96
|
// ---------------------------------------------------------------------------
|
|
89
|
-
|
|
90
|
-
const { components, scheme } = useTheme();
|
|
97
|
+
function SelectSeparator() {
|
|
98
|
+
const { components, scheme } = (0, theme_1.useTheme)();
|
|
91
99
|
const tokens = components.select.separator;
|
|
92
100
|
const selectColors = scheme.select;
|
|
93
|
-
return (
|
|
101
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: { paddingVertical: tokens.marginY }, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: {
|
|
94
102
|
height: 1,
|
|
95
103
|
backgroundColor: selectColors.separator,
|
|
96
104
|
} }) }));
|
|
@@ -98,19 +106,19 @@ export function SelectSeparator() {
|
|
|
98
106
|
// ---------------------------------------------------------------------------
|
|
99
107
|
// SelectGroup — labelled group of options
|
|
100
108
|
// ---------------------------------------------------------------------------
|
|
101
|
-
|
|
102
|
-
const { components, scheme } = useTheme();
|
|
109
|
+
function SelectGroup({ label: groupLabel, children }) {
|
|
110
|
+
const { components, scheme } = (0, theme_1.useTheme)();
|
|
103
111
|
const tokens = components.select.group;
|
|
104
112
|
const textTokens = scheme.text;
|
|
105
|
-
return (
|
|
113
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: {
|
|
106
114
|
paddingHorizontal: tokens.paddingX,
|
|
107
115
|
paddingVertical: tokens.labelPaddingY,
|
|
108
|
-
}, children:
|
|
109
|
-
fontFamily: fontFamily.sans,
|
|
110
|
-
fontWeight: fontWeight.regular,
|
|
111
|
-
fontSize: caption.fontSize,
|
|
112
|
-
lineHeight: caption.lineHeight,
|
|
113
|
-
letterSpacing: caption.letterSpacing,
|
|
116
|
+
}, children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
117
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
118
|
+
fontWeight: tokens_1.fontWeight.regular,
|
|
119
|
+
fontSize: tokens_1.caption.fontSize,
|
|
120
|
+
lineHeight: tokens_1.caption.lineHeight,
|
|
121
|
+
letterSpacing: tokens_1.caption.letterSpacing,
|
|
114
122
|
color: textTokens.description,
|
|
115
123
|
textTransform: 'uppercase',
|
|
116
124
|
}, selectable: false, children: groupLabel }) }), children] }));
|
|
@@ -118,18 +126,18 @@ export function SelectGroup({ label: groupLabel, children }) {
|
|
|
118
126
|
// ---------------------------------------------------------------------------
|
|
119
127
|
// SelectOption — individual option row
|
|
120
128
|
// ---------------------------------------------------------------------------
|
|
121
|
-
|
|
129
|
+
function SelectOption({ value, children: optionLabel, description, icon, disabled = false, }) {
|
|
122
130
|
const ctx = useSelectContext();
|
|
123
|
-
const { components, scheme } = useTheme();
|
|
131
|
+
const { components, scheme } = (0, theme_1.useTheme)();
|
|
124
132
|
const tokens = components.select.option;
|
|
125
133
|
const selectColors = scheme.select;
|
|
126
134
|
const textTokens = scheme.text;
|
|
127
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
135
|
+
const [isHovered, setIsHovered] = (0, react_1.useState)(false);
|
|
128
136
|
const isSelected = ctx.selectedValues.includes(value);
|
|
129
|
-
const labelTokens = label[BODY_SCALE[ctx.size]];
|
|
130
|
-
const bodyTokens = body[BODY_SCALE[ctx.size]];
|
|
137
|
+
const labelTokens = tokens_1.label[BODY_SCALE[ctx.size]];
|
|
138
|
+
const bodyTokens = tokens_1.body[BODY_SCALE[ctx.size]];
|
|
131
139
|
// Register this option with the parent Select
|
|
132
|
-
useEffect(() => {
|
|
140
|
+
(0, react_1.useEffect)(() => {
|
|
133
141
|
ctx.registerOption(value, { label: optionLabel, icon });
|
|
134
142
|
return () => ctx.unregisterOption(value);
|
|
135
143
|
// Only re-register when value or label change
|
|
@@ -145,8 +153,8 @@ export function SelectOption({ value, children: optionLabel, description, icon,
|
|
|
145
153
|
: isHovered
|
|
146
154
|
? selectColors.option.hover
|
|
147
155
|
: selectColors.option.default;
|
|
148
|
-
const resolvedIcon = typeof icon === 'string' ? (
|
|
149
|
-
return (
|
|
156
|
+
const resolvedIcon = typeof icon === 'string' ? ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: icon, size: ICON_SIZE, color: colors.fg })) : (icon);
|
|
157
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.Pressable, { onPress: () => {
|
|
150
158
|
if (!disabled)
|
|
151
159
|
ctx.onSelect(value);
|
|
152
160
|
}, onHoverIn: () => setIsHovered(true), onHoverOut: () => setIsHovered(false), disabled: disabled, accessibilityRole: "menuitem", accessibilityLabel: optionLabel, accessibilityState: { selected: isSelected, disabled }, style: {
|
|
@@ -157,59 +165,59 @@ export function SelectOption({ value, children: optionLabel, description, icon,
|
|
|
157
165
|
paddingVertical: tokens.paddingY,
|
|
158
166
|
borderRadius: tokens.borderRadius,
|
|
159
167
|
backgroundColor: colors.bg,
|
|
160
|
-
}, children: [resolvedIcon ? (
|
|
161
|
-
fontFamily: fontFamily.sans,
|
|
162
|
-
fontWeight: fontWeight.medium,
|
|
168
|
+
}, children: [resolvedIcon ? ((0, jsx_runtime_1.jsx)(react_native_1.View, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { width: ICON_SIZE, height: ICON_SIZE }, children: resolvedIcon })) : null, (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { flex: 1, justifyContent: 'center' }, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
169
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
170
|
+
fontWeight: tokens_1.fontWeight.medium,
|
|
163
171
|
fontSize: labelTokens.fontSize,
|
|
164
172
|
lineHeight: labelTokens.lineHeight,
|
|
165
173
|
letterSpacing: labelTokens.letterSpacing,
|
|
166
174
|
color: colors.fg,
|
|
167
|
-
}, selectable: false, children: optionLabel }), description ? (
|
|
168
|
-
fontFamily: fontFamily.sans,
|
|
169
|
-
fontWeight: fontWeight.regular,
|
|
175
|
+
}, selectable: false, children: optionLabel }), description ? ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
176
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
177
|
+
fontWeight: tokens_1.fontWeight.regular,
|
|
170
178
|
fontSize: bodyTokens.fontSize,
|
|
171
179
|
lineHeight: bodyTokens.lineHeight,
|
|
172
180
|
letterSpacing: bodyTokens.letterSpacing,
|
|
173
181
|
color: disabled ? colors.fg : textTokens.description,
|
|
174
|
-
}, numberOfLines: 1, selectable: false, children: description })) : null] }), isSelected && !disabled ? (
|
|
182
|
+
}, numberOfLines: 1, selectable: false, children: description })) : null] }), isSelected && !disabled ? ((0, jsx_runtime_1.jsx)(react_native_1.View, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { width: ICON_SIZE, height: ICON_SIZE }, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "check", size: ICON_SIZE, color: colors.fg }) })) : null] }));
|
|
175
183
|
}
|
|
176
|
-
|
|
177
|
-
const { components, scheme } = useTheme();
|
|
184
|
+
function SelectContent({ children, style }) {
|
|
185
|
+
const { components, scheme } = (0, theme_1.useTheme)();
|
|
178
186
|
const tokens = components.select.content;
|
|
179
187
|
const surfaceTokens = scheme.surface;
|
|
180
|
-
return (
|
|
188
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: [
|
|
181
189
|
{
|
|
182
190
|
backgroundColor: surfaceTokens.overlay.bg,
|
|
183
|
-
borderWidth: controlTokens.borderWidth,
|
|
191
|
+
borderWidth: tokens_1.controlTokens.borderWidth,
|
|
184
192
|
borderColor: surfaceTokens.overlay.border,
|
|
185
193
|
borderRadius: surfaceTokens.overlay.borderRadius,
|
|
186
194
|
paddingVertical: tokens.paddingY,
|
|
187
195
|
maxHeight: CONTENT_MAX_HEIGHT,
|
|
188
|
-
...(Platform.OS === 'web' ? SHADOW_WEB : SHADOW_NATIVE),
|
|
196
|
+
...(react_native_1.Platform.OS === 'web' ? SHADOW_WEB : SHADOW_NATIVE),
|
|
189
197
|
},
|
|
190
198
|
style,
|
|
191
|
-
], children:
|
|
199
|
+
], children: (0, jsx_runtime_1.jsx)(react_native_1.ScrollView, { nestedScrollEnabled: true, keyboardShouldPersistTaps: "handled", showsVerticalScrollIndicator: true, children: children }) }));
|
|
192
200
|
}
|
|
193
201
|
// ---------------------------------------------------------------------------
|
|
194
202
|
// Select — main component (trigger + dropdown overlay)
|
|
195
203
|
// ---------------------------------------------------------------------------
|
|
196
|
-
|
|
197
|
-
const { components, scheme } = useTheme();
|
|
204
|
+
function Select({ type = 'single', size = 'default', label: formLabel, helperText, placeholder = 'Select...', leadingIcon, disabled = false, error = false, value, onValueChange, values, onValuesChange, searchValue, onSearchChange, children, style, accessibilityLabel, }) {
|
|
205
|
+
const { components, scheme } = (0, theme_1.useTheme)();
|
|
198
206
|
const inputTokens = components.input[size];
|
|
199
207
|
const intentColors = scheme.intents;
|
|
200
208
|
const disabledColors = scheme.disabled;
|
|
201
209
|
const errorTokens = scheme.error;
|
|
202
210
|
const textTokens = scheme.text;
|
|
203
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
204
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
205
|
-
const optionRegistry = useRef(new Map());
|
|
206
|
-
const [, forceUpdate] = useState(0);
|
|
207
|
-
const selectedValues = useMemo(() => {
|
|
211
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
212
|
+
const [isHovered, setIsHovered] = (0, react_1.useState)(false);
|
|
213
|
+
const optionRegistry = (0, react_1.useRef)(new Map());
|
|
214
|
+
const [, forceUpdate] = (0, react_1.useState)(0);
|
|
215
|
+
const selectedValues = (0, react_1.useMemo)(() => {
|
|
208
216
|
if (type === 'multi')
|
|
209
217
|
return values ?? [];
|
|
210
218
|
return value != null ? [value] : [];
|
|
211
219
|
}, [type, value, values]);
|
|
212
|
-
const handleSelect = useCallback((optionValue) => {
|
|
220
|
+
const handleSelect = (0, react_1.useCallback)((optionValue) => {
|
|
213
221
|
if (type === 'multi') {
|
|
214
222
|
const current = values ?? [];
|
|
215
223
|
const next = current.includes(optionValue)
|
|
@@ -222,14 +230,14 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
222
230
|
setIsOpen(false);
|
|
223
231
|
}
|
|
224
232
|
}, [type, values, onValueChange, onValuesChange]);
|
|
225
|
-
const registerOption = useCallback((val, info) => {
|
|
233
|
+
const registerOption = (0, react_1.useCallback)((val, info) => {
|
|
226
234
|
optionRegistry.current.set(val, info);
|
|
227
235
|
forceUpdate((n) => n + 1);
|
|
228
236
|
}, []);
|
|
229
|
-
const unregisterOption = useCallback((val) => {
|
|
237
|
+
const unregisterOption = (0, react_1.useCallback)((val) => {
|
|
230
238
|
optionRegistry.current.delete(val);
|
|
231
239
|
}, []);
|
|
232
|
-
const ctxValue = useMemo(() => ({
|
|
240
|
+
const ctxValue = (0, react_1.useMemo)(() => ({
|
|
233
241
|
type,
|
|
234
242
|
size,
|
|
235
243
|
selectedValues,
|
|
@@ -238,8 +246,8 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
238
246
|
unregisterOption,
|
|
239
247
|
}), [type, size, selectedValues, handleSelect, registerOption, unregisterOption]);
|
|
240
248
|
// Resolve typography scales
|
|
241
|
-
const labelTypo = label[LABEL_SCALE[size]];
|
|
242
|
-
const bodyTypo = body[BODY_SCALE[size]];
|
|
249
|
+
const labelTypo = tokens_1.label[LABEL_SCALE[size]];
|
|
250
|
+
const bodyTypo = tokens_1.body[BODY_SCALE[size]];
|
|
243
251
|
// Resolve trigger border colour
|
|
244
252
|
const triggerBorderColor = disabled
|
|
245
253
|
? disabledColors.border
|
|
@@ -257,7 +265,7 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
257
265
|
? disabledColors.fg
|
|
258
266
|
: intentColors.neutral.default.default.fg;
|
|
259
267
|
// Resolve leading icon
|
|
260
|
-
const resolvedLeadingIcon = typeof leadingIcon === 'string' ? (
|
|
268
|
+
const resolvedLeadingIcon = typeof leadingIcon === 'string' ? ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: leadingIcon, size: ICON_SIZE, color: triggerFgColor })) : (leadingIcon);
|
|
261
269
|
// Get display text for single select
|
|
262
270
|
const getSelectedLabel = () => {
|
|
263
271
|
if (type === 'single' || type === 'combobox') {
|
|
@@ -270,8 +278,8 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
270
278
|
};
|
|
271
279
|
const displayText = getSelectedLabel();
|
|
272
280
|
// Escape key dismisses the dropdown (web)
|
|
273
|
-
useEffect(() => {
|
|
274
|
-
if (!isOpen || Platform.OS !== 'web')
|
|
281
|
+
(0, react_1.useEffect)(() => {
|
|
282
|
+
if (!isOpen || react_native_1.Platform.OS !== 'web')
|
|
275
283
|
return;
|
|
276
284
|
const handleKeyDown = (e) => {
|
|
277
285
|
if (e.key === 'Escape') {
|
|
@@ -282,17 +290,17 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
282
290
|
document.addEventListener('keydown', handleKeyDown);
|
|
283
291
|
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
284
292
|
}, [isOpen]);
|
|
285
|
-
return (
|
|
293
|
+
return ((0, jsx_runtime_1.jsx)(SelectCtx.Provider, { value: ctxValue, children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [
|
|
286
294
|
{ alignSelf: 'stretch', gap: components.input.fieldGap, zIndex: isOpen ? 1000 : 0 },
|
|
287
295
|
style,
|
|
288
|
-
], children: [formLabel ? (
|
|
289
|
-
fontFamily: fontFamily.sans,
|
|
290
|
-
fontWeight: fontWeight.medium,
|
|
296
|
+
], children: [formLabel ? ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
297
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
298
|
+
fontWeight: tokens_1.fontWeight.medium,
|
|
291
299
|
fontSize: labelTypo.fontSize,
|
|
292
300
|
lineHeight: labelTypo.lineHeight,
|
|
293
301
|
letterSpacing: labelTypo.letterSpacing,
|
|
294
302
|
color: triggerFgColor,
|
|
295
|
-
}, selectable: false, children: formLabel })) : null,
|
|
303
|
+
}, selectable: false, children: formLabel })) : null, (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { position: 'relative' }, children: [(0, jsx_runtime_1.jsxs)(react_native_1.Pressable, { onPress: () => {
|
|
296
304
|
if (!disabled)
|
|
297
305
|
setIsOpen(!isOpen);
|
|
298
306
|
}, onHoverIn: () => setIsHovered(true), onHoverOut: () => setIsHovered(false), disabled: disabled, accessibilityRole: "button", accessibilityLabel: accessibilityLabel || formLabel || 'Select option', accessibilityState: { disabled, expanded: isOpen }, style: {
|
|
@@ -302,10 +310,10 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
302
310
|
paddingHorizontal: inputTokens.paddingX,
|
|
303
311
|
paddingVertical: inputTokens.paddingY,
|
|
304
312
|
borderRadius: inputTokens.borderRadius,
|
|
305
|
-
borderWidth: controlTokens.borderWidth,
|
|
313
|
+
borderWidth: tokens_1.controlTokens.borderWidth,
|
|
306
314
|
borderColor: triggerBorderColor,
|
|
307
315
|
backgroundColor: triggerBgColor,
|
|
308
|
-
}, children: [resolvedLeadingIcon ? (
|
|
316
|
+
}, children: [resolvedLeadingIcon ? ((0, jsx_runtime_1.jsx)(react_native_1.View, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { width: ICON_SIZE, height: ICON_SIZE }, children: resolvedLeadingIcon })) : null, type === 'multi' ? ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: {
|
|
309
317
|
flex: 1,
|
|
310
318
|
flexDirection: 'row',
|
|
311
319
|
flexWrap: 'wrap',
|
|
@@ -314,14 +322,14 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
314
322
|
}, children: selectedValues.length > 0
|
|
315
323
|
? selectedValues.map((val) => {
|
|
316
324
|
const info = optionRegistry.current.get(val);
|
|
317
|
-
return (
|
|
325
|
+
return ((0, jsx_runtime_1.jsx)(SelectTag, { disabled: disabled, onRemove: disabled
|
|
318
326
|
? undefined
|
|
319
327
|
: () => {
|
|
320
328
|
const next = selectedValues.filter((v) => v !== val);
|
|
321
329
|
onValuesChange?.(next);
|
|
322
330
|
}, children: info?.label ?? val }, val));
|
|
323
331
|
})
|
|
324
|
-
: renderPlaceholder(placeholder, bodyTypo, textTokens.description) })) : type === 'combobox' ? (
|
|
332
|
+
: renderPlaceholder(placeholder, bodyTypo, textTokens.description) })) : type === 'combobox' ? ((0, jsx_runtime_1.jsx)(react_native_1.TextInput, { value: searchValue ?? displayText ?? '', onChangeText: (text) => {
|
|
325
333
|
onSearchChange?.(text);
|
|
326
334
|
if (!isOpen)
|
|
327
335
|
setIsOpen(true);
|
|
@@ -330,28 +338,28 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
330
338
|
setIsOpen(true);
|
|
331
339
|
}, placeholder: placeholder, placeholderTextColor: textTokens.description, editable: !disabled, style: {
|
|
332
340
|
flex: 1,
|
|
333
|
-
fontFamily: fontFamily.sans,
|
|
334
|
-
fontWeight: fontWeight.regular,
|
|
341
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
342
|
+
fontWeight: tokens_1.fontWeight.regular,
|
|
335
343
|
fontSize: bodyTypo.fontSize,
|
|
336
344
|
lineHeight: bodyTypo.lineHeight,
|
|
337
345
|
letterSpacing: bodyTypo.letterSpacing,
|
|
338
346
|
color: triggerFgColor,
|
|
339
347
|
padding: 0,
|
|
340
|
-
...(Platform.OS === 'web'
|
|
348
|
+
...(react_native_1.Platform.OS === 'web'
|
|
341
349
|
? { outlineWidth: 0 }
|
|
342
350
|
: {}),
|
|
343
|
-
}, accessibilityLabel: accessibilityLabel || formLabel || 'Search' })) : (
|
|
344
|
-
fontFamily: fontFamily.sans,
|
|
345
|
-
fontWeight: fontWeight.regular,
|
|
351
|
+
}, accessibilityLabel: accessibilityLabel || formLabel || 'Search' })) : ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: { flex: 1 }, children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { numberOfLines: 1, style: {
|
|
352
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
353
|
+
fontWeight: tokens_1.fontWeight.regular,
|
|
346
354
|
fontSize: bodyTypo.fontSize,
|
|
347
355
|
lineHeight: bodyTypo.lineHeight,
|
|
348
356
|
letterSpacing: bodyTypo.letterSpacing,
|
|
349
357
|
color: displayText
|
|
350
358
|
? triggerFgColor
|
|
351
359
|
: textTokens.description,
|
|
352
|
-
}, selectable: false, children: displayText ?? placeholder }) })),
|
|
360
|
+
}, selectable: false, children: displayText ?? placeholder }) })), (0, jsx_runtime_1.jsx)(react_native_1.View, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: isOpen
|
|
353
361
|
? { transform: [{ rotate: '180deg' }] }
|
|
354
|
-
: undefined, children:
|
|
362
|
+
: undefined, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "keyboard_arrow_down", size: CHEVRON_SIZE, color: triggerFgColor }) })] }), isOpen ? ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onPress: () => setIsOpen(false), accessibilityRole: "button", accessibilityLabel: "Close select", style: react_native_1.Platform.select({
|
|
355
363
|
web: {
|
|
356
364
|
position: 'fixed',
|
|
357
365
|
top: 0,
|
|
@@ -367,7 +375,7 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
367
375
|
width: 99999,
|
|
368
376
|
height: 99999,
|
|
369
377
|
},
|
|
370
|
-
}) })) : null,
|
|
378
|
+
}) })) : null, (0, jsx_runtime_1.jsx)(react_native_1.View, { style: [
|
|
371
379
|
{
|
|
372
380
|
position: 'absolute',
|
|
373
381
|
top: '100%',
|
|
@@ -377,12 +385,12 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
377
385
|
zIndex: 1,
|
|
378
386
|
},
|
|
379
387
|
!isOpen && { display: 'none' },
|
|
380
|
-
], children:
|
|
381
|
-
fontFamily: fontFamily.sans,
|
|
382
|
-
fontWeight: fontWeight.regular,
|
|
383
|
-
fontSize: caption.fontSize,
|
|
384
|
-
lineHeight: caption.lineHeight,
|
|
385
|
-
letterSpacing: caption.letterSpacing,
|
|
388
|
+
], children: (0, jsx_runtime_1.jsx)(SelectContent, { children: children }) })] }), helperText ? ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
389
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
390
|
+
fontWeight: tokens_1.fontWeight.regular,
|
|
391
|
+
fontSize: tokens_1.caption.fontSize,
|
|
392
|
+
lineHeight: tokens_1.caption.lineHeight,
|
|
393
|
+
letterSpacing: tokens_1.caption.letterSpacing,
|
|
386
394
|
color: error ? errorTokens.fg : textTokens.description,
|
|
387
395
|
}, selectable: false, children: helperText })) : null] }) }));
|
|
388
396
|
}
|
|
@@ -390,13 +398,12 @@ export function Select({ type = 'single', size = 'default', label: formLabel, he
|
|
|
390
398
|
// Helpers
|
|
391
399
|
// ---------------------------------------------------------------------------
|
|
392
400
|
function renderPlaceholder(text, typo, color) {
|
|
393
|
-
return (
|
|
394
|
-
fontFamily: fontFamily.sans,
|
|
395
|
-
fontWeight: fontWeight.regular,
|
|
401
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
402
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
403
|
+
fontWeight: tokens_1.fontWeight.regular,
|
|
396
404
|
fontSize: typo.fontSize,
|
|
397
405
|
lineHeight: typo.lineHeight,
|
|
398
406
|
letterSpacing: typo.letterSpacing,
|
|
399
407
|
color,
|
|
400
408
|
}, selectable: false, children: text }));
|
|
401
409
|
}
|
|
402
|
-
//# sourceMappingURL=Select.js.map
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
export { Select, SelectOption, SelectGroup, SelectSeparator, SelectTag, SelectContent, type SelectProps, type SelectSize, type SelectType, type SelectOptionProps, type SelectGroupProps, type SelectTagProps, type SelectContentProps, } from './Select';
|
|
2
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SelectContent = exports.SelectTag = exports.SelectSeparator = exports.SelectGroup = exports.SelectOption = exports.Select = void 0;
|
|
4
|
+
var Select_1 = require("./Select");
|
|
5
|
+
Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return Select_1.Select; } });
|
|
6
|
+
Object.defineProperty(exports, "SelectOption", { enumerable: true, get: function () { return Select_1.SelectOption; } });
|
|
7
|
+
Object.defineProperty(exports, "SelectGroup", { enumerable: true, get: function () { return Select_1.SelectGroup; } });
|
|
8
|
+
Object.defineProperty(exports, "SelectSeparator", { enumerable: true, get: function () { return Select_1.SelectSeparator; } });
|
|
9
|
+
Object.defineProperty(exports, "SelectTag", { enumerable: true, get: function () { return Select_1.SelectTag; } });
|
|
10
|
+
Object.defineProperty(exports, "SelectContent", { enumerable: true, get: function () { return Select_1.SelectContent; } });
|
|
@@ -31,4 +31,3 @@ export type SkeletonProps = {
|
|
|
31
31
|
accessibilityLabel?: string;
|
|
32
32
|
};
|
|
33
33
|
export declare function Skeleton({ shape, width, height, radius, animated, style, accessibilityLabel, }: SkeletonProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
-
//# sourceMappingURL=Skeleton.d.ts.map
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Skeleton = Skeleton;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
5
|
/**
|
|
3
6
|
* Skeleton — a placeholder block shown while content loads.
|
|
4
7
|
*
|
|
@@ -13,9 +16,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
16
|
* Sizing is intentionally constant across densities — skeletons mirror the
|
|
14
17
|
* layout of the real content they stand in for.
|
|
15
18
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const react_native_1 = require("react-native");
|
|
21
|
+
const theme_1 = require("../../theme");
|
|
19
22
|
/** Default size + corner radius per shape (radius/2, surface/overlay/radius, radius/full). */
|
|
20
23
|
const SHAPE_DEFAULTS = {
|
|
21
24
|
text: { width: 120, height: 12, radius: 4 },
|
|
@@ -25,23 +28,23 @@ const SHAPE_DEFAULTS = {
|
|
|
25
28
|
// ---------------------------------------------------------------------------
|
|
26
29
|
// Component
|
|
27
30
|
// ---------------------------------------------------------------------------
|
|
28
|
-
|
|
29
|
-
const { scheme } = useTheme();
|
|
31
|
+
function Skeleton({ shape = 'text', width, height, radius, animated = true, style, accessibilityLabel = 'Loading', }) {
|
|
32
|
+
const { scheme } = (0, theme_1.useTheme)();
|
|
30
33
|
const skeletonColors = scheme.skeleton;
|
|
31
34
|
const defaults = SHAPE_DEFAULTS[shape];
|
|
32
|
-
const opacity = useRef(new Animated.Value(1)).current;
|
|
33
|
-
useEffect(() => {
|
|
35
|
+
const opacity = (0, react_1.useRef)(new react_native_1.Animated.Value(1)).current;
|
|
36
|
+
(0, react_1.useEffect)(() => {
|
|
34
37
|
if (!animated) {
|
|
35
38
|
opacity.setValue(1);
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
|
-
const loop = Animated.loop(Animated.sequence([
|
|
39
|
-
Animated.timing(opacity, {
|
|
41
|
+
const loop = react_native_1.Animated.loop(react_native_1.Animated.sequence([
|
|
42
|
+
react_native_1.Animated.timing(opacity, {
|
|
40
43
|
toValue: 0.5,
|
|
41
44
|
duration: 700,
|
|
42
45
|
useNativeDriver: true,
|
|
43
46
|
}),
|
|
44
|
-
Animated.timing(opacity, {
|
|
47
|
+
react_native_1.Animated.timing(opacity, {
|
|
45
48
|
toValue: 1,
|
|
46
49
|
duration: 700,
|
|
47
50
|
useNativeDriver: true,
|
|
@@ -50,7 +53,7 @@ export function Skeleton({ shape = 'text', width, height, radius, animated = tru
|
|
|
50
53
|
loop.start();
|
|
51
54
|
return () => loop.stop();
|
|
52
55
|
}, [animated, opacity]);
|
|
53
|
-
return (
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Animated.View, { accessibilityRole: "image", accessibilityLabel: accessibilityLabel, style: [
|
|
54
57
|
{
|
|
55
58
|
width: width ?? defaults.width,
|
|
56
59
|
height: height ?? defaults.height,
|
|
@@ -61,4 +64,3 @@ export function Skeleton({ shape = 'text', width, height, radius, animated = tru
|
|
|
61
64
|
style,
|
|
62
65
|
] }));
|
|
63
66
|
}
|
|
64
|
-
//# sourceMappingURL=Skeleton.js.map
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Skeleton = void 0;
|
|
4
|
+
var Skeleton_1 = require("./Skeleton");
|
|
5
|
+
Object.defineProperty(exports, "Skeleton", { enumerable: true, get: function () { return Skeleton_1.Skeleton; } });
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Toast = Toast;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
const theme_1 = require("../../theme");
|
|
7
|
+
const Icon_1 = require("../Icon");
|
|
8
|
+
const tokens_1 = require("../../tokens");
|
|
6
9
|
// ---------------------------------------------------------------------------
|
|
7
10
|
// Constants
|
|
8
11
|
// ---------------------------------------------------------------------------
|
|
@@ -33,17 +36,17 @@ const SHADOW_NATIVE = {
|
|
|
33
36
|
// ---------------------------------------------------------------------------
|
|
34
37
|
// Component
|
|
35
38
|
// ---------------------------------------------------------------------------
|
|
36
|
-
|
|
37
|
-
const { components, scheme } = useTheme();
|
|
39
|
+
function Toast({ title, children, intent = 'neutral', size = 'default', icon, onClose, style, accessibilityLabel, }) {
|
|
40
|
+
const { components, scheme } = (0, theme_1.useTheme)();
|
|
38
41
|
const intentColors = scheme.intents;
|
|
39
42
|
const surfaceTokens = scheme.surface;
|
|
40
43
|
const tokens = components.toast;
|
|
41
44
|
const sizeTokens = tokens[size];
|
|
42
|
-
const titleTokens =
|
|
43
|
-
const bodyTokens = body[BODY_SCALE[size]];
|
|
45
|
+
const titleTokens = tokens_1.title[TITLE_SCALE[size]];
|
|
46
|
+
const bodyTokens = tokens_1.body[BODY_SCALE[size]];
|
|
44
47
|
const fg = intentColors[intent].default.default.fg;
|
|
45
|
-
const resolvedIcon = typeof icon === 'string' ? (
|
|
46
|
-
return (
|
|
48
|
+
const resolvedIcon = typeof icon === 'string' ? ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: icon, size: sizeTokens.iconSize, color: fg })) : (icon);
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { accessibilityRole: "alert", accessibilityLabel: accessibilityLabel || title, style: [
|
|
47
50
|
{
|
|
48
51
|
flexDirection: 'row',
|
|
49
52
|
alignItems: 'flex-start',
|
|
@@ -52,26 +55,25 @@ export function Toast({ title, children, intent = 'neutral', size = 'default', i
|
|
|
52
55
|
minWidth: tokens.minWidth,
|
|
53
56
|
maxWidth: tokens.maxWidth,
|
|
54
57
|
borderRadius: tokens.borderRadius,
|
|
55
|
-
borderWidth: controlTokens.borderWidth,
|
|
58
|
+
borderWidth: tokens_1.controlTokens.borderWidth,
|
|
56
59
|
borderColor: surfaceTokens.overlay.border,
|
|
57
60
|
backgroundColor: surfaceTokens.overlay.bg,
|
|
58
|
-
...(Platform.OS === 'web' ? SHADOW_WEB : SHADOW_NATIVE),
|
|
61
|
+
...(react_native_1.Platform.OS === 'web' ? SHADOW_WEB : SHADOW_NATIVE),
|
|
59
62
|
},
|
|
60
63
|
style,
|
|
61
|
-
], children: [resolvedIcon ? (
|
|
62
|
-
fontFamily: fontFamily.sans,
|
|
63
|
-
fontWeight: fontWeight.medium,
|
|
64
|
+
], children: [resolvedIcon ? ((0, jsx_runtime_1.jsx)(react_native_1.View, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { width: sizeTokens.iconSize, height: sizeTokens.iconSize }, children: resolvedIcon })) : null, (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
65
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
66
|
+
fontWeight: tokens_1.fontWeight.medium,
|
|
64
67
|
fontSize: titleTokens.fontSize,
|
|
65
68
|
lineHeight: titleTokens.lineHeight,
|
|
66
69
|
letterSpacing: titleTokens.letterSpacing,
|
|
67
70
|
color: fg,
|
|
68
|
-
}, selectable: false, children: title }), children ? (
|
|
69
|
-
fontFamily: fontFamily.sans,
|
|
70
|
-
fontWeight: fontWeight.regular,
|
|
71
|
+
}, selectable: false, children: title }), children ? ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: {
|
|
72
|
+
fontFamily: tokens_1.fontFamily.sans,
|
|
73
|
+
fontWeight: tokens_1.fontWeight.regular,
|
|
71
74
|
fontSize: bodyTokens.fontSize,
|
|
72
75
|
lineHeight: bodyTokens.lineHeight,
|
|
73
76
|
letterSpacing: bodyTokens.letterSpacing,
|
|
74
77
|
color: fg,
|
|
75
|
-
}, selectable: false, children: children })) : null] }), onClose ? (
|
|
78
|
+
}, selectable: false, children: children })) : null] }), onClose ? ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onPress: onClose, hitSlop: 8, accessibilityRole: "button", accessibilityLabel: "Dismiss", style: { width: sizeTokens.closeSize, height: sizeTokens.closeSize }, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "close", size: sizeTokens.closeSize, color: fg }) })) : null] }));
|
|
76
79
|
}
|
|
77
|
-
//# sourceMappingURL=Toast.js.map
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Toast = void 0;
|
|
4
|
+
var Toast_1 = require("./Toast");
|
|
5
|
+
Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Toast_1.Toast; } });
|
|
@@ -29,4 +29,3 @@ export type ToggleProps = {
|
|
|
29
29
|
accessibilityLabel?: string;
|
|
30
30
|
};
|
|
31
31
|
export declare function Toggle({ checked, onChange, children, size, disabled, style, accessibilityLabel, }: ToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
//# sourceMappingURL=Toggle.d.ts.map
|