@ttoss/fsl-ui 0.2.4
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 +76 -0
- package/dist/_virtual/_rolldown/runtime.cjs +30 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +129 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.cts +61 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.mts +61 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.mjs +126 -0
- package/dist/components/Button/Button.cjs +80 -0
- package/dist/components/Button/Button.d.cts +68 -0
- package/dist/components/Button/Button.d.mts +68 -0
- package/dist/components/Button/Button.mjs +79 -0
- package/dist/components/Checkbox/Checkbox.cjs +183 -0
- package/dist/components/Checkbox/Checkbox.d.cts +45 -0
- package/dist/components/Checkbox/Checkbox.d.mts +45 -0
- package/dist/components/Checkbox/Checkbox.mjs +182 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.cjs +97 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.d.cts +56 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.d.mts +56 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.mjs +96 -0
- package/dist/components/FileTrigger/FileTrigger.cjs +51 -0
- package/dist/components/FileTrigger/FileTrigger.d.cts +52 -0
- package/dist/components/FileTrigger/FileTrigger.d.mts +52 -0
- package/dist/components/FileTrigger/FileTrigger.mjs +50 -0
- package/dist/components/GridList/GridList.cjs +220 -0
- package/dist/components/GridList/GridList.d.cts +72 -0
- package/dist/components/GridList/GridList.d.mts +72 -0
- package/dist/components/GridList/GridList.mjs +217 -0
- package/dist/components/Group/Group.cjs +77 -0
- package/dist/components/Group/Group.d.cts +61 -0
- package/dist/components/Group/Group.d.mts +61 -0
- package/dist/components/Group/Group.mjs +74 -0
- package/dist/components/Icon/Icon.cjs +52 -0
- package/dist/components/Icon/Icon.mjs +52 -0
- package/dist/components/Icon/glyphs.cjs +72 -0
- package/dist/components/Icon/glyphs.mjs +63 -0
- package/dist/components/Link/Link.cjs +62 -0
- package/dist/components/Link/Link.d.cts +38 -0
- package/dist/components/Link/Link.d.mts +38 -0
- package/dist/components/Link/Link.mjs +61 -0
- package/dist/components/ListBox/ListBox.cjs +126 -0
- package/dist/components/ListBox/ListBox.d.cts +63 -0
- package/dist/components/ListBox/ListBox.d.mts +63 -0
- package/dist/components/ListBox/ListBox.mjs +123 -0
- package/dist/components/Meter/Meter.cjs +126 -0
- package/dist/components/Meter/Meter.d.cts +63 -0
- package/dist/components/Meter/Meter.d.mts +63 -0
- package/dist/components/Meter/Meter.mjs +125 -0
- package/dist/components/NumberField/NumberField.cjs +221 -0
- package/dist/components/NumberField/NumberField.d.cts +68 -0
- package/dist/components/NumberField/NumberField.d.mts +68 -0
- package/dist/components/NumberField/NumberField.mjs +220 -0
- package/dist/components/ProgressBar/ProgressBar.cjs +132 -0
- package/dist/components/ProgressBar/ProgressBar.d.cts +56 -0
- package/dist/components/ProgressBar/ProgressBar.d.mts +56 -0
- package/dist/components/ProgressBar/ProgressBar.mjs +129 -0
- package/dist/components/RadioGroup/RadioGroup.cjs +218 -0
- package/dist/components/RadioGroup/RadioGroup.d.cts +82 -0
- package/dist/components/RadioGroup/RadioGroup.d.mts +82 -0
- package/dist/components/RadioGroup/RadioGroup.mjs +215 -0
- package/dist/components/Select/Select.cjs +253 -0
- package/dist/components/Select/Select.d.cts +86 -0
- package/dist/components/Select/Select.d.mts +86 -0
- package/dist/components/Select/Select.mjs +250 -0
- package/dist/components/Separator/Separator.cjs +64 -0
- package/dist/components/Separator/Separator.d.cts +44 -0
- package/dist/components/Separator/Separator.d.mts +44 -0
- package/dist/components/Separator/Separator.mjs +63 -0
- package/dist/components/Slider/Slider.cjs +160 -0
- package/dist/components/Slider/Slider.d.cts +45 -0
- package/dist/components/Slider/Slider.d.mts +45 -0
- package/dist/components/Slider/Slider.mjs +159 -0
- package/dist/components/Switch/Switch.cjs +176 -0
- package/dist/components/Switch/Switch.d.cts +43 -0
- package/dist/components/Switch/Switch.d.mts +43 -0
- package/dist/components/Switch/Switch.mjs +175 -0
- package/dist/components/Tabs/Tabs.cjs +180 -0
- package/dist/components/Tabs/Tabs.d.cts +85 -0
- package/dist/components/Tabs/Tabs.d.mts +85 -0
- package/dist/components/Tabs/Tabs.mjs +173 -0
- package/dist/components/Toast/Toast.cjs +218 -0
- package/dist/components/Toast/Toast.d.cts +96 -0
- package/dist/components/Toast/Toast.d.mts +96 -0
- package/dist/components/Toast/Toast.mjs +214 -0
- package/dist/components/ToggleButton/ToggleButton.cjs +125 -0
- package/dist/components/ToggleButton/ToggleButton.d.cts +43 -0
- package/dist/components/ToggleButton/ToggleButton.d.mts +43 -0
- package/dist/components/ToggleButton/ToggleButton.mjs +124 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.cjs +48 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.d.cts +41 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.d.mts +41 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.mjs +47 -0
- package/dist/components/Toolbar/Toolbar.cjs +67 -0
- package/dist/components/Toolbar/Toolbar.d.cts +60 -0
- package/dist/components/Toolbar/Toolbar.d.mts +60 -0
- package/dist/components/Toolbar/Toolbar.mjs +66 -0
- package/dist/composites/Accordion/Accordion.cjs +279 -0
- package/dist/composites/Accordion/Accordion.d.cts +176 -0
- package/dist/composites/Accordion/Accordion.d.mts +176 -0
- package/dist/composites/Accordion/Accordion.mjs +270 -0
- package/dist/composites/ConfirmationDialog/ConfirmationDialog.cjs +206 -0
- package/dist/composites/ConfirmationDialog/ConfirmationDialog.d.cts +166 -0
- package/dist/composites/ConfirmationDialog/ConfirmationDialog.d.mts +166 -0
- package/dist/composites/ConfirmationDialog/ConfirmationDialog.mjs +203 -0
- package/dist/composites/Dialog/Dialog.cjs +372 -0
- package/dist/composites/Dialog/Dialog.d.cts +234 -0
- package/dist/composites/Dialog/Dialog.d.mts +234 -0
- package/dist/composites/Dialog/Dialog.mjs +360 -0
- package/dist/composites/Disclosure/Disclosure.cjs +214 -0
- package/dist/composites/Disclosure/Disclosure.d.cts +118 -0
- package/dist/composites/Disclosure/Disclosure.d.mts +118 -0
- package/dist/composites/Disclosure/Disclosure.mjs +207 -0
- package/dist/composites/Form/Form.cjs +161 -0
- package/dist/composites/Form/Form.d.cts +176 -0
- package/dist/composites/Form/Form.d.mts +176 -0
- package/dist/composites/Form/Form.mjs +156 -0
- package/dist/composites/Menu/Menu.cjs +190 -0
- package/dist/composites/Menu/Menu.d.cts +158 -0
- package/dist/composites/Menu/Menu.d.mts +158 -0
- package/dist/composites/Menu/Menu.mjs +186 -0
- package/dist/composites/Popover/Popover.cjs +80 -0
- package/dist/composites/Popover/Popover.d.cts +56 -0
- package/dist/composites/Popover/Popover.d.mts +56 -0
- package/dist/composites/Popover/Popover.mjs +78 -0
- package/dist/composites/SearchField/SearchField.cjs +194 -0
- package/dist/composites/SearchField/SearchField.d.cts +81 -0
- package/dist/composites/SearchField/SearchField.d.mts +81 -0
- package/dist/composites/SearchField/SearchField.mjs +189 -0
- package/dist/composites/TagGroup/TagGroup.cjs +212 -0
- package/dist/composites/TagGroup/TagGroup.d.cts +84 -0
- package/dist/composites/TagGroup/TagGroup.d.mts +84 -0
- package/dist/composites/TagGroup/TagGroup.mjs +209 -0
- package/dist/composites/TextArea/TextArea.cjs +190 -0
- package/dist/composites/TextArea/TextArea.d.cts +95 -0
- package/dist/composites/TextArea/TextArea.d.mts +95 -0
- package/dist/composites/TextArea/TextArea.mjs +181 -0
- package/dist/composites/TextField/TextField.cjs +200 -0
- package/dist/composites/TextField/TextField.d.cts +111 -0
- package/dist/composites/TextField/TextField.d.mts +111 -0
- package/dist/composites/TextField/TextField.mjs +191 -0
- package/dist/composites/Tooltip/Tooltip.cjs +79 -0
- package/dist/composites/Tooltip/Tooltip.d.cts +53 -0
- package/dist/composites/Tooltip/Tooltip.d.mts +53 -0
- package/dist/composites/Tooltip/Tooltip.mjs +77 -0
- package/dist/composites/Wizard/Wizard.cjs +333 -0
- package/dist/composites/Wizard/Wizard.d.cts +206 -0
- package/dist/composites/Wizard/Wizard.d.mts +206 -0
- package/dist/composites/Wizard/Wizard.mjs +324 -0
- package/dist/composites/scope.cjs +124 -0
- package/dist/composites/scope.mjs +121 -0
- package/dist/index.cjs +186 -0
- package/dist/index.d.cts +37 -0
- package/dist/index.d.mts +37 -0
- package/dist/index.mjs +39 -0
- package/dist/semantics/componentMeta.d.cts +37 -0
- package/dist/semantics/componentMeta.d.mts +37 -0
- package/dist/semantics/index.cjs +16 -0
- package/dist/semantics/index.d.cts +4 -0
- package/dist/semantics/index.d.mts +4 -0
- package/dist/semantics/index.mjs +3 -0
- package/dist/semantics/taxonomy.cjs +150 -0
- package/dist/semantics/taxonomy.d.cts +153 -0
- package/dist/semantics/taxonomy.d.mts +153 -0
- package/dist/semantics/taxonomy.mjs +140 -0
- package/dist/tokens/escapeHatch.cjs +13 -0
- package/dist/tokens/escapeHatch.mjs +13 -0
- package/dist/tokens/focusRing.cjs +28 -0
- package/dist/tokens/focusRing.mjs +28 -0
- package/dist/tokens/keyframes.cjs +76 -0
- package/dist/tokens/keyframes.mjs +75 -0
- package/dist/tokens/resolveInteractiveStyle.cjs +41 -0
- package/dist/tokens/resolveInteractiveStyle.mjs +41 -0
- package/llms.txt +142 -0
- package/package.json +70 -0
- package/src/tokens/CONTRACT.md +505 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
const require_focusRing = require('../../tokens/focusRing.cjs');
|
|
3
|
+
const require_resolveInteractiveStyle = require('../../tokens/resolveInteractiveStyle.cjs');
|
|
4
|
+
const require_Icon = require('../Icon/Icon.cjs');
|
|
5
|
+
let _ttoss_fsl_theme_vars = require("@ttoss/fsl-theme/vars");
|
|
6
|
+
let react_aria_components = require("react-aria-components");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
|
|
9
|
+
//#region src/components/Toast/Toast.tsx
|
|
10
|
+
/** Formal semantic identity — Toast root (Feedback entity). */
|
|
11
|
+
var toastMeta = {
|
|
12
|
+
displayName: "Toast",
|
|
13
|
+
entity: "Feedback",
|
|
14
|
+
structure: "root"
|
|
15
|
+
};
|
|
16
|
+
var TOAST_MIN_WIDTH = "240px";
|
|
17
|
+
var TOAST_REGION_MAX_WIDTH = "min(420px, calc(100vw - 2rem))";
|
|
18
|
+
/** Root surface style — raised feedback card chrome. */
|
|
19
|
+
var buildToastRootStyle = c => {
|
|
20
|
+
return {
|
|
21
|
+
boxSizing: "border-box",
|
|
22
|
+
display: "flex",
|
|
23
|
+
alignItems: "flex-start",
|
|
24
|
+
gap: _ttoss_fsl_theme_vars.vars.spacing.gap.inline.md,
|
|
25
|
+
minWidth: TOAST_MIN_WIDTH,
|
|
26
|
+
padding: _ttoss_fsl_theme_vars.vars.spacing.inset.surface.md,
|
|
27
|
+
borderRadius: _ttoss_fsl_theme_vars.vars.radii.surface,
|
|
28
|
+
borderWidth: _ttoss_fsl_theme_vars.vars.border.outline.surface.width,
|
|
29
|
+
borderStyle: _ttoss_fsl_theme_vars.vars.border.outline.surface.style,
|
|
30
|
+
borderColor: c?.border?.default,
|
|
31
|
+
backgroundColor: c?.background?.default,
|
|
32
|
+
color: c?.text?.default,
|
|
33
|
+
boxShadow: _ttoss_fsl_theme_vars.vars.elevation.surface.raised,
|
|
34
|
+
outline: "none"
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/** Close-button (closeTrigger) style — icon button, transparent by default. */
|
|
38
|
+
var buildCloseTriggerStyle = ({
|
|
39
|
+
c,
|
|
40
|
+
isHovered,
|
|
41
|
+
isPressed,
|
|
42
|
+
isDisabled,
|
|
43
|
+
isFocusVisible
|
|
44
|
+
}) => {
|
|
45
|
+
const flags = {
|
|
46
|
+
isHovered,
|
|
47
|
+
isPressed,
|
|
48
|
+
isDisabled,
|
|
49
|
+
isFocusVisible
|
|
50
|
+
};
|
|
51
|
+
const text = c?.text;
|
|
52
|
+
return {
|
|
53
|
+
boxSizing: "border-box",
|
|
54
|
+
flexShrink: 0,
|
|
55
|
+
display: "inline-flex",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
justifyContent: "center",
|
|
58
|
+
width: _ttoss_fsl_theme_vars.vars.sizing.icon.lg,
|
|
59
|
+
height: _ttoss_fsl_theme_vars.vars.sizing.icon.lg,
|
|
60
|
+
padding: 0,
|
|
61
|
+
border: "none",
|
|
62
|
+
borderRadius: _ttoss_fsl_theme_vars.vars.radii.control,
|
|
63
|
+
background: require_resolveInteractiveStyle.resolveInteractiveStyle(c?.background, flags) ?? "transparent",
|
|
64
|
+
color: require_resolveInteractiveStyle.resolveInteractiveStyle(text, flags) ?? text?.default,
|
|
65
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
66
|
+
opacity: isDisabled ? _ttoss_fsl_theme_vars.vars.opacity.disabled : void 0,
|
|
67
|
+
outline: require_focusRing.focusRingOutline(isFocusVisible),
|
|
68
|
+
outlineOffset: "2px"
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/** Formal semantic identity — ToastRegion (Feedback entity, root host). */
|
|
72
|
+
var toastRegionMeta = {
|
|
73
|
+
displayName: "ToastRegion",
|
|
74
|
+
entity: "Feedback",
|
|
75
|
+
structure: "root"
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Factory for a typed toast queue. Call once (typically at module scope of
|
|
79
|
+
* your app) and pass the result to `<ToastRegion queue={queue} />`.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* import { createToastQueue } from '@ttoss/fsl-ui';
|
|
84
|
+
*
|
|
85
|
+
* export const toastQueue = createToastQueue();
|
|
86
|
+
*
|
|
87
|
+
* // Somewhere in your app:
|
|
88
|
+
* toastQueue.add(
|
|
89
|
+
* { title: 'Saved', description: 'Your changes are live.', evaluation: 'positive' },
|
|
90
|
+
* { timeout: 5000 }
|
|
91
|
+
* );
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
var createToastQueue = options => {
|
|
95
|
+
return new react_aria_components.UNSTABLE_ToastQueue(options);
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* A single Feedback toast surface. Renders `title`, `description`, and a
|
|
99
|
+
* dismiss button.
|
|
100
|
+
*
|
|
101
|
+
* This component is rendered by `ToastRegion` for each queued item — you
|
|
102
|
+
* rarely instantiate it directly. Use `createToastQueue` + `queue.add(...)`
|
|
103
|
+
* in application code, and place a single `<ToastRegion />` at the root.
|
|
104
|
+
*/
|
|
105
|
+
var Toast = ({
|
|
106
|
+
toast
|
|
107
|
+
}) => {
|
|
108
|
+
const evaluation = toast.content.evaluation ?? "primary";
|
|
109
|
+
const c = _ttoss_fsl_theme_vars.vars.colors.feedback[evaluation];
|
|
110
|
+
const textColor = c?.text?.default;
|
|
111
|
+
return /* @__PURE__ */(0, react_jsx_runtime.jsxs)(react_aria_components.UNSTABLE_Toast, {
|
|
112
|
+
toast,
|
|
113
|
+
"data-scope": "toast",
|
|
114
|
+
"data-part": "root",
|
|
115
|
+
"data-evaluation": evaluation,
|
|
116
|
+
style: buildToastRootStyle(c),
|
|
117
|
+
children: [/* @__PURE__ */(0, react_jsx_runtime.jsxs)(react_aria_components.UNSTABLE_ToastContent, {
|
|
118
|
+
"data-scope": "toast",
|
|
119
|
+
"data-part": "content",
|
|
120
|
+
style: {
|
|
121
|
+
flex: 1,
|
|
122
|
+
display: "flex",
|
|
123
|
+
flexDirection: "column",
|
|
124
|
+
gap: _ttoss_fsl_theme_vars.vars.spacing.gap.stack.xs,
|
|
125
|
+
minWidth: 0
|
|
126
|
+
},
|
|
127
|
+
children: [/* @__PURE__ */(0, react_jsx_runtime.jsx)(react_aria_components.Text, {
|
|
128
|
+
slot: "title",
|
|
129
|
+
"data-scope": "toast",
|
|
130
|
+
"data-part": "title",
|
|
131
|
+
style: {
|
|
132
|
+
..._ttoss_fsl_theme_vars.vars.text.label.md,
|
|
133
|
+
color: textColor
|
|
134
|
+
},
|
|
135
|
+
children: toast.content.title
|
|
136
|
+
}), toast.content.description !== void 0 && /* @__PURE__ */(0, react_jsx_runtime.jsx)(react_aria_components.Text, {
|
|
137
|
+
slot: "description",
|
|
138
|
+
"data-scope": "toast",
|
|
139
|
+
"data-part": "body",
|
|
140
|
+
style: {
|
|
141
|
+
..._ttoss_fsl_theme_vars.vars.text.body.md,
|
|
142
|
+
color: textColor
|
|
143
|
+
},
|
|
144
|
+
children: toast.content.description
|
|
145
|
+
})]
|
|
146
|
+
}), /* @__PURE__ */(0, react_jsx_runtime.jsx)(react_aria_components.Button, {
|
|
147
|
+
slot: "close",
|
|
148
|
+
"data-scope": "toast",
|
|
149
|
+
"data-part": "closeTrigger",
|
|
150
|
+
style: ({
|
|
151
|
+
isHovered,
|
|
152
|
+
isPressed,
|
|
153
|
+
isDisabled,
|
|
154
|
+
isFocusVisible
|
|
155
|
+
}) => {
|
|
156
|
+
return buildCloseTriggerStyle({
|
|
157
|
+
c,
|
|
158
|
+
isHovered,
|
|
159
|
+
isPressed,
|
|
160
|
+
isDisabled,
|
|
161
|
+
isFocusVisible
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
children: /* @__PURE__ */(0, react_jsx_runtime.jsx)(require_Icon.Icon, {
|
|
165
|
+
intent: "action.close",
|
|
166
|
+
size: "sm"
|
|
167
|
+
})
|
|
168
|
+
})]
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
Toast.displayName = toastMeta.displayName;
|
|
172
|
+
/**
|
|
173
|
+
* The Toast host — place once near the root of your app and pass the queue
|
|
174
|
+
* created with `createToastQueue`. Renders each queued toast as a
|
|
175
|
+
* `Toast` surface.
|
|
176
|
+
*
|
|
177
|
+
* Uses `vars.elevation.raised` — the first component in the system that
|
|
178
|
+
* lifts off the page plane without being a full overlay.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```tsx
|
|
182
|
+
* <ToastRegion queue={toastQueue} />
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
var ToastRegion = props => {
|
|
186
|
+
return /* @__PURE__ */(0, react_jsx_runtime.jsx)(react_aria_components.UNSTABLE_ToastRegion, {
|
|
187
|
+
...props,
|
|
188
|
+
"data-scope": "toast-region",
|
|
189
|
+
"data-part": "root",
|
|
190
|
+
style: {
|
|
191
|
+
boxSizing: "border-box",
|
|
192
|
+
position: "fixed",
|
|
193
|
+
insetBlockEnd: _ttoss_fsl_theme_vars.vars.spacing.inset.surface.md,
|
|
194
|
+
insetInlineEnd: _ttoss_fsl_theme_vars.vars.spacing.inset.surface.md,
|
|
195
|
+
display: "flex",
|
|
196
|
+
flexDirection: "column",
|
|
197
|
+
gap: _ttoss_fsl_theme_vars.vars.spacing.gap.stack.sm,
|
|
198
|
+
zIndex: _ttoss_fsl_theme_vars.vars.zIndex.layer.transient,
|
|
199
|
+
maxWidth: TOAST_REGION_MAX_WIDTH,
|
|
200
|
+
outline: "none"
|
|
201
|
+
},
|
|
202
|
+
children: ({
|
|
203
|
+
toast
|
|
204
|
+
}) => {
|
|
205
|
+
return /* @__PURE__ */(0, react_jsx_runtime.jsx)(Toast, {
|
|
206
|
+
toast
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
ToastRegion.displayName = toastRegionMeta.displayName;
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
exports.Toast = Toast;
|
|
215
|
+
exports.ToastRegion = ToastRegion;
|
|
216
|
+
exports.createToastQueue = createToastQueue;
|
|
217
|
+
exports.toastMeta = toastMeta;
|
|
218
|
+
exports.toastRegionMeta = toastRegionMeta;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
import { EvaluationsFor } from "../../semantics/taxonomy.cjs";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { QueuedToast, ToastRegionProps, UNSTABLE_ToastQueue } from "react-aria-components";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Toast/Toast.d.ts
|
|
7
|
+
/** Formal semantic identity — Toast root (Feedback entity). */
|
|
8
|
+
declare const toastMeta: {
|
|
9
|
+
readonly displayName: "Toast";
|
|
10
|
+
readonly entity: "Feedback";
|
|
11
|
+
readonly structure: "root";
|
|
12
|
+
};
|
|
13
|
+
/** Formal semantic identity — ToastRegion (Feedback entity, root host). */
|
|
14
|
+
declare const toastRegionMeta: {
|
|
15
|
+
readonly displayName: "ToastRegion";
|
|
16
|
+
readonly entity: "Feedback";
|
|
17
|
+
readonly structure: "root";
|
|
18
|
+
};
|
|
19
|
+
/** The payload each toast carries on the queue. */
|
|
20
|
+
interface ToastContent {
|
|
21
|
+
/** Short heading for the toast. */
|
|
22
|
+
title: React.ReactNode;
|
|
23
|
+
/** Optional longer description. */
|
|
24
|
+
description?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Authorial valence. Feedback toasts encode meaning through color.
|
|
27
|
+
* @default 'primary'
|
|
28
|
+
*/
|
|
29
|
+
evaluation?: EvaluationsFor<'Feedback'>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Factory for a typed toast queue. Call once (typically at module scope of
|
|
33
|
+
* your app) and pass the result to `<ToastRegion queue={queue} />`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* import { createToastQueue } from '@ttoss/fsl-ui';
|
|
38
|
+
*
|
|
39
|
+
* export const toastQueue = createToastQueue();
|
|
40
|
+
*
|
|
41
|
+
* // Somewhere in your app:
|
|
42
|
+
* toastQueue.add(
|
|
43
|
+
* { title: 'Saved', description: 'Your changes are live.', evaluation: 'positive' },
|
|
44
|
+
* { timeout: 5000 }
|
|
45
|
+
* );
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare const createToastQueue: (options?: {
|
|
49
|
+
maxVisibleToasts?: number;
|
|
50
|
+
}) => UNSTABLE_ToastQueue<ToastContent>;
|
|
51
|
+
/** Re-exported type of the queue produced by `createToastQueue`. */
|
|
52
|
+
type ToastQueue = UNSTABLE_ToastQueue<ToastContent>;
|
|
53
|
+
/**
|
|
54
|
+
* Props for the Toast component.
|
|
55
|
+
*/
|
|
56
|
+
interface ToastProps {
|
|
57
|
+
/** The queued toast supplied by the `ToastRegion` render callback. */
|
|
58
|
+
toast: QueuedToast<ToastContent>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A single Feedback toast surface. Renders `title`, `description`, and a
|
|
62
|
+
* dismiss button.
|
|
63
|
+
*
|
|
64
|
+
* This component is rendered by `ToastRegion` for each queued item — you
|
|
65
|
+
* rarely instantiate it directly. Use `createToastQueue` + `queue.add(...)`
|
|
66
|
+
* in application code, and place a single `<ToastRegion />` at the root.
|
|
67
|
+
*/
|
|
68
|
+
declare const Toast: {
|
|
69
|
+
({
|
|
70
|
+
toast
|
|
71
|
+
}: ToastProps): import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
displayName: "Toast";
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Props for the ToastRegion component.
|
|
76
|
+
*/
|
|
77
|
+
type ToastRegionProps$1 = Omit<ToastRegionProps<ToastContent>, 'children' | 'style' | 'className'>;
|
|
78
|
+
/**
|
|
79
|
+
* The Toast host — place once near the root of your app and pass the queue
|
|
80
|
+
* created with `createToastQueue`. Renders each queued toast as a
|
|
81
|
+
* `Toast` surface.
|
|
82
|
+
*
|
|
83
|
+
* Uses `vars.elevation.raised` — the first component in the system that
|
|
84
|
+
* lifts off the page plane without being a full overlay.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* <ToastRegion queue={toastQueue} />
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare const ToastRegion: {
|
|
92
|
+
(props: ToastRegionProps$1): import("react/jsx-runtime").JSX.Element;
|
|
93
|
+
displayName: "ToastRegion";
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { Toast, ToastContent, ToastProps, ToastQueue, ToastRegion, ToastRegionProps$1 as ToastRegionProps, createToastQueue, toastMeta, toastRegionMeta };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
import { EvaluationsFor } from "../../semantics/taxonomy.mjs";
|
|
3
|
+
import { QueuedToast, ToastRegionProps, UNSTABLE_ToastQueue } from "react-aria-components";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Toast/Toast.d.ts
|
|
7
|
+
/** Formal semantic identity — Toast root (Feedback entity). */
|
|
8
|
+
declare const toastMeta: {
|
|
9
|
+
readonly displayName: "Toast";
|
|
10
|
+
readonly entity: "Feedback";
|
|
11
|
+
readonly structure: "root";
|
|
12
|
+
};
|
|
13
|
+
/** Formal semantic identity — ToastRegion (Feedback entity, root host). */
|
|
14
|
+
declare const toastRegionMeta: {
|
|
15
|
+
readonly displayName: "ToastRegion";
|
|
16
|
+
readonly entity: "Feedback";
|
|
17
|
+
readonly structure: "root";
|
|
18
|
+
};
|
|
19
|
+
/** The payload each toast carries on the queue. */
|
|
20
|
+
interface ToastContent {
|
|
21
|
+
/** Short heading for the toast. */
|
|
22
|
+
title: React.ReactNode;
|
|
23
|
+
/** Optional longer description. */
|
|
24
|
+
description?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Authorial valence. Feedback toasts encode meaning through color.
|
|
27
|
+
* @default 'primary'
|
|
28
|
+
*/
|
|
29
|
+
evaluation?: EvaluationsFor<'Feedback'>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Factory for a typed toast queue. Call once (typically at module scope of
|
|
33
|
+
* your app) and pass the result to `<ToastRegion queue={queue} />`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* import { createToastQueue } from '@ttoss/fsl-ui';
|
|
38
|
+
*
|
|
39
|
+
* export const toastQueue = createToastQueue();
|
|
40
|
+
*
|
|
41
|
+
* // Somewhere in your app:
|
|
42
|
+
* toastQueue.add(
|
|
43
|
+
* { title: 'Saved', description: 'Your changes are live.', evaluation: 'positive' },
|
|
44
|
+
* { timeout: 5000 }
|
|
45
|
+
* );
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare const createToastQueue: (options?: {
|
|
49
|
+
maxVisibleToasts?: number;
|
|
50
|
+
}) => UNSTABLE_ToastQueue<ToastContent>;
|
|
51
|
+
/** Re-exported type of the queue produced by `createToastQueue`. */
|
|
52
|
+
type ToastQueue = UNSTABLE_ToastQueue<ToastContent>;
|
|
53
|
+
/**
|
|
54
|
+
* Props for the Toast component.
|
|
55
|
+
*/
|
|
56
|
+
interface ToastProps {
|
|
57
|
+
/** The queued toast supplied by the `ToastRegion` render callback. */
|
|
58
|
+
toast: QueuedToast<ToastContent>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A single Feedback toast surface. Renders `title`, `description`, and a
|
|
62
|
+
* dismiss button.
|
|
63
|
+
*
|
|
64
|
+
* This component is rendered by `ToastRegion` for each queued item — you
|
|
65
|
+
* rarely instantiate it directly. Use `createToastQueue` + `queue.add(...)`
|
|
66
|
+
* in application code, and place a single `<ToastRegion />` at the root.
|
|
67
|
+
*/
|
|
68
|
+
declare const Toast: {
|
|
69
|
+
({
|
|
70
|
+
toast
|
|
71
|
+
}: ToastProps): import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
displayName: "Toast";
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Props for the ToastRegion component.
|
|
76
|
+
*/
|
|
77
|
+
type ToastRegionProps$1 = Omit<ToastRegionProps<ToastContent>, 'children' | 'style' | 'className'>;
|
|
78
|
+
/**
|
|
79
|
+
* The Toast host — place once near the root of your app and pass the queue
|
|
80
|
+
* created with `createToastQueue`. Renders each queued toast as a
|
|
81
|
+
* `Toast` surface.
|
|
82
|
+
*
|
|
83
|
+
* Uses `vars.elevation.raised` — the first component in the system that
|
|
84
|
+
* lifts off the page plane without being a full overlay.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* <ToastRegion queue={toastQueue} />
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare const ToastRegion: {
|
|
92
|
+
(props: ToastRegionProps$1): import("react/jsx-runtime").JSX.Element;
|
|
93
|
+
displayName: "ToastRegion";
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { Toast, ToastContent, ToastProps, ToastQueue, ToastRegion, ToastRegionProps$1 as ToastRegionProps, createToastQueue, toastMeta, toastRegionMeta };
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
import { focusRingOutline } from "../../tokens/focusRing.mjs";
|
|
3
|
+
import { resolveInteractiveStyle } from "../../tokens/resolveInteractiveStyle.mjs";
|
|
4
|
+
import { Icon } from "../Icon/Icon.mjs";
|
|
5
|
+
import { vars } from "@ttoss/fsl-theme/vars";
|
|
6
|
+
import { Button, Text, UNSTABLE_Toast, UNSTABLE_ToastContent, UNSTABLE_ToastQueue, UNSTABLE_ToastRegion } from "react-aria-components";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/components/Toast/Toast.tsx
|
|
10
|
+
/** Formal semantic identity — Toast root (Feedback entity). */
|
|
11
|
+
var toastMeta = {
|
|
12
|
+
displayName: "Toast",
|
|
13
|
+
entity: "Feedback",
|
|
14
|
+
structure: "root"
|
|
15
|
+
};
|
|
16
|
+
var TOAST_MIN_WIDTH = "240px";
|
|
17
|
+
var TOAST_REGION_MAX_WIDTH = "min(420px, calc(100vw - 2rem))";
|
|
18
|
+
/** Root surface style — raised feedback card chrome. */
|
|
19
|
+
var buildToastRootStyle = c => {
|
|
20
|
+
return {
|
|
21
|
+
boxSizing: "border-box",
|
|
22
|
+
display: "flex",
|
|
23
|
+
alignItems: "flex-start",
|
|
24
|
+
gap: vars.spacing.gap.inline.md,
|
|
25
|
+
minWidth: TOAST_MIN_WIDTH,
|
|
26
|
+
padding: vars.spacing.inset.surface.md,
|
|
27
|
+
borderRadius: vars.radii.surface,
|
|
28
|
+
borderWidth: vars.border.outline.surface.width,
|
|
29
|
+
borderStyle: vars.border.outline.surface.style,
|
|
30
|
+
borderColor: c?.border?.default,
|
|
31
|
+
backgroundColor: c?.background?.default,
|
|
32
|
+
color: c?.text?.default,
|
|
33
|
+
boxShadow: vars.elevation.surface.raised,
|
|
34
|
+
outline: "none"
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/** Close-button (closeTrigger) style — icon button, transparent by default. */
|
|
38
|
+
var buildCloseTriggerStyle = ({
|
|
39
|
+
c,
|
|
40
|
+
isHovered,
|
|
41
|
+
isPressed,
|
|
42
|
+
isDisabled,
|
|
43
|
+
isFocusVisible
|
|
44
|
+
}) => {
|
|
45
|
+
const flags = {
|
|
46
|
+
isHovered,
|
|
47
|
+
isPressed,
|
|
48
|
+
isDisabled,
|
|
49
|
+
isFocusVisible
|
|
50
|
+
};
|
|
51
|
+
const text = c?.text;
|
|
52
|
+
return {
|
|
53
|
+
boxSizing: "border-box",
|
|
54
|
+
flexShrink: 0,
|
|
55
|
+
display: "inline-flex",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
justifyContent: "center",
|
|
58
|
+
width: vars.sizing.icon.lg,
|
|
59
|
+
height: vars.sizing.icon.lg,
|
|
60
|
+
padding: 0,
|
|
61
|
+
border: "none",
|
|
62
|
+
borderRadius: vars.radii.control,
|
|
63
|
+
background: resolveInteractiveStyle(c?.background, flags) ?? "transparent",
|
|
64
|
+
color: resolveInteractiveStyle(text, flags) ?? text?.default,
|
|
65
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
66
|
+
opacity: isDisabled ? vars.opacity.disabled : void 0,
|
|
67
|
+
outline: focusRingOutline(isFocusVisible),
|
|
68
|
+
outlineOffset: "2px"
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/** Formal semantic identity — ToastRegion (Feedback entity, root host). */
|
|
72
|
+
var toastRegionMeta = {
|
|
73
|
+
displayName: "ToastRegion",
|
|
74
|
+
entity: "Feedback",
|
|
75
|
+
structure: "root"
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Factory for a typed toast queue. Call once (typically at module scope of
|
|
79
|
+
* your app) and pass the result to `<ToastRegion queue={queue} />`.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* import { createToastQueue } from '@ttoss/fsl-ui';
|
|
84
|
+
*
|
|
85
|
+
* export const toastQueue = createToastQueue();
|
|
86
|
+
*
|
|
87
|
+
* // Somewhere in your app:
|
|
88
|
+
* toastQueue.add(
|
|
89
|
+
* { title: 'Saved', description: 'Your changes are live.', evaluation: 'positive' },
|
|
90
|
+
* { timeout: 5000 }
|
|
91
|
+
* );
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
var createToastQueue = options => {
|
|
95
|
+
return new UNSTABLE_ToastQueue(options);
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* A single Feedback toast surface. Renders `title`, `description`, and a
|
|
99
|
+
* dismiss button.
|
|
100
|
+
*
|
|
101
|
+
* This component is rendered by `ToastRegion` for each queued item — you
|
|
102
|
+
* rarely instantiate it directly. Use `createToastQueue` + `queue.add(...)`
|
|
103
|
+
* in application code, and place a single `<ToastRegion />` at the root.
|
|
104
|
+
*/
|
|
105
|
+
var Toast = ({
|
|
106
|
+
toast
|
|
107
|
+
}) => {
|
|
108
|
+
const evaluation = toast.content.evaluation ?? "primary";
|
|
109
|
+
const c = vars.colors.feedback[evaluation];
|
|
110
|
+
const textColor = c?.text?.default;
|
|
111
|
+
return /* @__PURE__ */jsxs(UNSTABLE_Toast, {
|
|
112
|
+
toast,
|
|
113
|
+
"data-scope": "toast",
|
|
114
|
+
"data-part": "root",
|
|
115
|
+
"data-evaluation": evaluation,
|
|
116
|
+
style: buildToastRootStyle(c),
|
|
117
|
+
children: [/* @__PURE__ */jsxs(UNSTABLE_ToastContent, {
|
|
118
|
+
"data-scope": "toast",
|
|
119
|
+
"data-part": "content",
|
|
120
|
+
style: {
|
|
121
|
+
flex: 1,
|
|
122
|
+
display: "flex",
|
|
123
|
+
flexDirection: "column",
|
|
124
|
+
gap: vars.spacing.gap.stack.xs,
|
|
125
|
+
minWidth: 0
|
|
126
|
+
},
|
|
127
|
+
children: [/* @__PURE__ */jsx(Text, {
|
|
128
|
+
slot: "title",
|
|
129
|
+
"data-scope": "toast",
|
|
130
|
+
"data-part": "title",
|
|
131
|
+
style: {
|
|
132
|
+
...vars.text.label.md,
|
|
133
|
+
color: textColor
|
|
134
|
+
},
|
|
135
|
+
children: toast.content.title
|
|
136
|
+
}), toast.content.description !== void 0 && /* @__PURE__ */jsx(Text, {
|
|
137
|
+
slot: "description",
|
|
138
|
+
"data-scope": "toast",
|
|
139
|
+
"data-part": "body",
|
|
140
|
+
style: {
|
|
141
|
+
...vars.text.body.md,
|
|
142
|
+
color: textColor
|
|
143
|
+
},
|
|
144
|
+
children: toast.content.description
|
|
145
|
+
})]
|
|
146
|
+
}), /* @__PURE__ */jsx(Button, {
|
|
147
|
+
slot: "close",
|
|
148
|
+
"data-scope": "toast",
|
|
149
|
+
"data-part": "closeTrigger",
|
|
150
|
+
style: ({
|
|
151
|
+
isHovered,
|
|
152
|
+
isPressed,
|
|
153
|
+
isDisabled,
|
|
154
|
+
isFocusVisible
|
|
155
|
+
}) => {
|
|
156
|
+
return buildCloseTriggerStyle({
|
|
157
|
+
c,
|
|
158
|
+
isHovered,
|
|
159
|
+
isPressed,
|
|
160
|
+
isDisabled,
|
|
161
|
+
isFocusVisible
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
children: /* @__PURE__ */jsx(Icon, {
|
|
165
|
+
intent: "action.close",
|
|
166
|
+
size: "sm"
|
|
167
|
+
})
|
|
168
|
+
})]
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
Toast.displayName = toastMeta.displayName;
|
|
172
|
+
/**
|
|
173
|
+
* The Toast host — place once near the root of your app and pass the queue
|
|
174
|
+
* created with `createToastQueue`. Renders each queued toast as a
|
|
175
|
+
* `Toast` surface.
|
|
176
|
+
*
|
|
177
|
+
* Uses `vars.elevation.raised` — the first component in the system that
|
|
178
|
+
* lifts off the page plane without being a full overlay.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```tsx
|
|
182
|
+
* <ToastRegion queue={toastQueue} />
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
var ToastRegion = props => {
|
|
186
|
+
return /* @__PURE__ */jsx(UNSTABLE_ToastRegion, {
|
|
187
|
+
...props,
|
|
188
|
+
"data-scope": "toast-region",
|
|
189
|
+
"data-part": "root",
|
|
190
|
+
style: {
|
|
191
|
+
boxSizing: "border-box",
|
|
192
|
+
position: "fixed",
|
|
193
|
+
insetBlockEnd: vars.spacing.inset.surface.md,
|
|
194
|
+
insetInlineEnd: vars.spacing.inset.surface.md,
|
|
195
|
+
display: "flex",
|
|
196
|
+
flexDirection: "column",
|
|
197
|
+
gap: vars.spacing.gap.stack.sm,
|
|
198
|
+
zIndex: vars.zIndex.layer.transient,
|
|
199
|
+
maxWidth: TOAST_REGION_MAX_WIDTH,
|
|
200
|
+
outline: "none"
|
|
201
|
+
},
|
|
202
|
+
children: ({
|
|
203
|
+
toast
|
|
204
|
+
}) => {
|
|
205
|
+
return /* @__PURE__ */jsx(Toast, {
|
|
206
|
+
toast
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
ToastRegion.displayName = toastRegionMeta.displayName;
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
export { Toast, ToastRegion, createToastQueue, toastMeta, toastRegionMeta };
|