@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,221 @@
|
|
|
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/NumberField/NumberField.tsx
|
|
10
|
+
/** Formal semantic identity — NumberField root (Input entity). */
|
|
11
|
+
var numberFieldMeta = {
|
|
12
|
+
displayName: "NumberField",
|
|
13
|
+
entity: "Input",
|
|
14
|
+
structure: "root"
|
|
15
|
+
};
|
|
16
|
+
/** Control box (the `Group`) chrome — the framed field around input + steppers. */
|
|
17
|
+
var buildControlBoxStyle = ({
|
|
18
|
+
c,
|
|
19
|
+
isDisabled,
|
|
20
|
+
isInvalid,
|
|
21
|
+
isFocusVisible
|
|
22
|
+
}) => {
|
|
23
|
+
return {
|
|
24
|
+
boxSizing: "border-box",
|
|
25
|
+
display: "inline-flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
minHeight: _ttoss_fsl_theme_vars.vars.sizing.hit.base,
|
|
28
|
+
borderRadius: _ttoss_fsl_theme_vars.vars.radii.control,
|
|
29
|
+
borderWidth: _ttoss_fsl_theme_vars.vars.border.outline.control.width,
|
|
30
|
+
borderStyle: _ttoss_fsl_theme_vars.vars.border.outline.control.style,
|
|
31
|
+
transitionProperty: "background-color, border-color",
|
|
32
|
+
transitionDuration: _ttoss_fsl_theme_vars.vars.motion.feedback.duration,
|
|
33
|
+
transitionTimingFunction: _ttoss_fsl_theme_vars.vars.motion.feedback.easing,
|
|
34
|
+
backgroundColor: require_resolveInteractiveStyle.resolveInteractiveStyle(c?.background, {
|
|
35
|
+
isDisabled,
|
|
36
|
+
isInvalid
|
|
37
|
+
}),
|
|
38
|
+
borderColor: require_resolveInteractiveStyle.resolveInteractiveStyle(c?.border, {
|
|
39
|
+
isDisabled,
|
|
40
|
+
isInvalid,
|
|
41
|
+
isFocusVisible
|
|
42
|
+
}),
|
|
43
|
+
outline: require_focusRing.focusRingOutline(isFocusVisible)
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/** Stepper button chrome — borderless Action-pattern control in Input chrome. */
|
|
47
|
+
var buildStepperStyle = ({
|
|
48
|
+
c,
|
|
49
|
+
isDisabled
|
|
50
|
+
}) => {
|
|
51
|
+
return {
|
|
52
|
+
boxSizing: "border-box",
|
|
53
|
+
display: "inline-flex",
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
justifyContent: "center",
|
|
56
|
+
flexShrink: 0,
|
|
57
|
+
border: 0,
|
|
58
|
+
background: "transparent",
|
|
59
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
60
|
+
opacity: isDisabled ? _ttoss_fsl_theme_vars.vars.opacity.disabled : void 0,
|
|
61
|
+
paddingBlock: _ttoss_fsl_theme_vars.vars.spacing.inset.control.sm,
|
|
62
|
+
paddingInline: _ttoss_fsl_theme_vars.vars.spacing.inset.control.sm,
|
|
63
|
+
color: c?.text?.default
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Resolve the field's text colors once (default for label/description/input,
|
|
68
|
+
* invalid for the validation message). Hoisted out of the render so the
|
|
69
|
+
* optional-chain reads keep the component's cyclomatic complexity low.
|
|
70
|
+
*/
|
|
71
|
+
var resolveFieldTextColors = c => {
|
|
72
|
+
const text = c?.text;
|
|
73
|
+
return {
|
|
74
|
+
base: text?.default,
|
|
75
|
+
invalid: text?.invalid ?? text?.default
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/** The `<input>` itself — borderless; the surrounding `Group` owns the frame. */
|
|
79
|
+
var buildInputStyle = c => {
|
|
80
|
+
return {
|
|
81
|
+
boxSizing: "border-box",
|
|
82
|
+
flex: 1,
|
|
83
|
+
minWidth: 0,
|
|
84
|
+
border: 0,
|
|
85
|
+
background: "transparent",
|
|
86
|
+
outline: "none",
|
|
87
|
+
textAlign: "center",
|
|
88
|
+
paddingBlock: _ttoss_fsl_theme_vars.vars.spacing.inset.control.sm,
|
|
89
|
+
color: c?.text?.default,
|
|
90
|
+
..._ttoss_fsl_theme_vars.vars.text.label.md
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A semantic numeric input built on React Aria's `NumberField`.
|
|
95
|
+
*
|
|
96
|
+
* Renders a labelled control box (`Group`) holding the `<input>` between a
|
|
97
|
+
* decrement (−) and increment (+) stepper. Entity = Input → reads
|
|
98
|
+
* `vars.colors.input.primary.*`. Supports `minValue`/`maxValue`/`step` and
|
|
99
|
+
* locale-aware `formatOptions` (currency, percent, units). Validation is the
|
|
100
|
+
* `invalid` State (via `isInvalid`/`validate`), never an `evaluation` variant.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```tsx
|
|
104
|
+
* <NumberField label="Quantity" minValue={0} defaultValue={1}>
|
|
105
|
+
* </NumberField>
|
|
106
|
+
* <NumberField
|
|
107
|
+
* label="Price"
|
|
108
|
+
* formatOptions={{ style: 'currency', currency: 'USD' }}
|
|
109
|
+
* />
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
var NumberField = ({
|
|
113
|
+
label,
|
|
114
|
+
description,
|
|
115
|
+
errorMessage,
|
|
116
|
+
decrementLabel = "Decrease",
|
|
117
|
+
incrementLabel = "Increase",
|
|
118
|
+
...props
|
|
119
|
+
}) => {
|
|
120
|
+
const c = _ttoss_fsl_theme_vars.vars.colors.input.primary;
|
|
121
|
+
const {
|
|
122
|
+
base,
|
|
123
|
+
invalid
|
|
124
|
+
} = resolveFieldTextColors(c);
|
|
125
|
+
return /* @__PURE__ */(0, react_jsx_runtime.jsxs)(react_aria_components.NumberField, {
|
|
126
|
+
...props,
|
|
127
|
+
"data-scope": "number-field",
|
|
128
|
+
"data-part": "root",
|
|
129
|
+
style: {
|
|
130
|
+
boxSizing: "border-box",
|
|
131
|
+
display: "flex",
|
|
132
|
+
flexDirection: "column",
|
|
133
|
+
gap: _ttoss_fsl_theme_vars.vars.spacing.gap.stack.xs
|
|
134
|
+
},
|
|
135
|
+
children: [label != null && /* @__PURE__ */(0, react_jsx_runtime.jsx)(react_aria_components.Label, {
|
|
136
|
+
"data-scope": "number-field",
|
|
137
|
+
"data-part": "label",
|
|
138
|
+
style: {
|
|
139
|
+
..._ttoss_fsl_theme_vars.vars.text.label.md,
|
|
140
|
+
color: base
|
|
141
|
+
},
|
|
142
|
+
children: label
|
|
143
|
+
}), /* @__PURE__ */(0, react_jsx_runtime.jsxs)(react_aria_components.Group, {
|
|
144
|
+
"data-scope": "number-field",
|
|
145
|
+
"data-part": "control",
|
|
146
|
+
style: ({
|
|
147
|
+
isDisabled,
|
|
148
|
+
isInvalid,
|
|
149
|
+
isFocusVisible
|
|
150
|
+
}) => {
|
|
151
|
+
return buildControlBoxStyle({
|
|
152
|
+
c,
|
|
153
|
+
isDisabled,
|
|
154
|
+
isInvalid,
|
|
155
|
+
isFocusVisible
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
children: [/* @__PURE__ */(0, react_jsx_runtime.jsx)(react_aria_components.Button, {
|
|
159
|
+
slot: "decrement",
|
|
160
|
+
"data-scope": "number-field",
|
|
161
|
+
"data-part": "trigger",
|
|
162
|
+
style: ({
|
|
163
|
+
isDisabled
|
|
164
|
+
}) => {
|
|
165
|
+
return buildStepperStyle({
|
|
166
|
+
c,
|
|
167
|
+
isDisabled
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
children: /* @__PURE__ */(0, react_jsx_runtime.jsx)(require_Icon.Icon, {
|
|
171
|
+
intent: "action.decrement",
|
|
172
|
+
size: "sm",
|
|
173
|
+
label: decrementLabel
|
|
174
|
+
})
|
|
175
|
+
}), /* @__PURE__ */(0, react_jsx_runtime.jsx)(react_aria_components.Input, {
|
|
176
|
+
"data-scope": "number-field",
|
|
177
|
+
"data-part": "control",
|
|
178
|
+
style: buildInputStyle(c)
|
|
179
|
+
}), /* @__PURE__ */(0, react_jsx_runtime.jsx)(react_aria_components.Button, {
|
|
180
|
+
slot: "increment",
|
|
181
|
+
"data-scope": "number-field",
|
|
182
|
+
"data-part": "trigger",
|
|
183
|
+
style: ({
|
|
184
|
+
isDisabled
|
|
185
|
+
}) => {
|
|
186
|
+
return buildStepperStyle({
|
|
187
|
+
c,
|
|
188
|
+
isDisabled
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
children: /* @__PURE__ */(0, react_jsx_runtime.jsx)(require_Icon.Icon, {
|
|
192
|
+
intent: "action.increment",
|
|
193
|
+
size: "sm",
|
|
194
|
+
label: incrementLabel
|
|
195
|
+
})
|
|
196
|
+
})]
|
|
197
|
+
}), description != null && /* @__PURE__ */(0, react_jsx_runtime.jsx)(react_aria_components.Text, {
|
|
198
|
+
slot: "description",
|
|
199
|
+
"data-scope": "number-field",
|
|
200
|
+
"data-part": "description",
|
|
201
|
+
style: {
|
|
202
|
+
..._ttoss_fsl_theme_vars.vars.text.label.sm,
|
|
203
|
+
color: base
|
|
204
|
+
},
|
|
205
|
+
children: description
|
|
206
|
+
}), /* @__PURE__ */(0, react_jsx_runtime.jsx)(react_aria_components.FieldError, {
|
|
207
|
+
"data-scope": "number-field",
|
|
208
|
+
"data-part": "validationMessage",
|
|
209
|
+
style: {
|
|
210
|
+
..._ttoss_fsl_theme_vars.vars.text.label.sm,
|
|
211
|
+
color: invalid
|
|
212
|
+
},
|
|
213
|
+
children: errorMessage
|
|
214
|
+
})]
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
NumberField.displayName = numberFieldMeta.displayName;
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
exports.NumberField = NumberField;
|
|
221
|
+
exports.numberFieldMeta = numberFieldMeta;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { NumberFieldProps } from "react-aria-components";
|
|
4
|
+
|
|
5
|
+
//#region src/components/NumberField/NumberField.d.ts
|
|
6
|
+
/** Formal semantic identity — NumberField root (Input entity). */
|
|
7
|
+
declare const numberFieldMeta: {
|
|
8
|
+
readonly displayName: "NumberField";
|
|
9
|
+
readonly entity: "Input";
|
|
10
|
+
readonly structure: "root";
|
|
11
|
+
};
|
|
12
|
+
/** Props for the NumberField component. */
|
|
13
|
+
interface NumberFieldProps$1 extends Omit<NumberFieldProps, 'style' | 'children' | 'className'> {
|
|
14
|
+
/** Visible label displayed above the field. */
|
|
15
|
+
label?: React.ReactNode;
|
|
16
|
+
/** Supplementary helper text linked to the field via `aria-describedby`. */
|
|
17
|
+
description?: React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Validation message shown when the field is invalid. Supply
|
|
20
|
+
* caller-localized copy (i18n rule / §6).
|
|
21
|
+
*/
|
|
22
|
+
errorMessage?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Accessible name for the decrement stepper (the icon is the sole carrier of
|
|
25
|
+
* meaning). Ships a documented English fallback (supplementary AT text, not
|
|
26
|
+
* a flow-critical label — i18n rule §6.2); localized hosts override it.
|
|
27
|
+
* @default 'Decrease'
|
|
28
|
+
*/
|
|
29
|
+
decrementLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Accessible name for the increment stepper. Documented English fallback,
|
|
32
|
+
* overridable (i18n rule §6.2).
|
|
33
|
+
* @default 'Increase'
|
|
34
|
+
*/
|
|
35
|
+
incrementLabel?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A semantic numeric input built on React Aria's `NumberField`.
|
|
39
|
+
*
|
|
40
|
+
* Renders a labelled control box (`Group`) holding the `<input>` between a
|
|
41
|
+
* decrement (−) and increment (+) stepper. Entity = Input → reads
|
|
42
|
+
* `vars.colors.input.primary.*`. Supports `minValue`/`maxValue`/`step` and
|
|
43
|
+
* locale-aware `formatOptions` (currency, percent, units). Validation is the
|
|
44
|
+
* `invalid` State (via `isInvalid`/`validate`), never an `evaluation` variant.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <NumberField label="Quantity" minValue={0} defaultValue={1}>
|
|
49
|
+
* </NumberField>
|
|
50
|
+
* <NumberField
|
|
51
|
+
* label="Price"
|
|
52
|
+
* formatOptions={{ style: 'currency', currency: 'USD' }}
|
|
53
|
+
* />
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
declare const NumberField: {
|
|
57
|
+
({
|
|
58
|
+
label,
|
|
59
|
+
description,
|
|
60
|
+
errorMessage,
|
|
61
|
+
decrementLabel,
|
|
62
|
+
incrementLabel,
|
|
63
|
+
...props
|
|
64
|
+
}: NumberFieldProps$1): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
displayName: "NumberField";
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { NumberField, NumberFieldProps$1 as NumberFieldProps, numberFieldMeta };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
import { NumberFieldProps } from "react-aria-components";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/NumberField/NumberField.d.ts
|
|
6
|
+
/** Formal semantic identity — NumberField root (Input entity). */
|
|
7
|
+
declare const numberFieldMeta: {
|
|
8
|
+
readonly displayName: "NumberField";
|
|
9
|
+
readonly entity: "Input";
|
|
10
|
+
readonly structure: "root";
|
|
11
|
+
};
|
|
12
|
+
/** Props for the NumberField component. */
|
|
13
|
+
interface NumberFieldProps$1 extends Omit<NumberFieldProps, 'style' | 'children' | 'className'> {
|
|
14
|
+
/** Visible label displayed above the field. */
|
|
15
|
+
label?: React.ReactNode;
|
|
16
|
+
/** Supplementary helper text linked to the field via `aria-describedby`. */
|
|
17
|
+
description?: React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Validation message shown when the field is invalid. Supply
|
|
20
|
+
* caller-localized copy (i18n rule / §6).
|
|
21
|
+
*/
|
|
22
|
+
errorMessage?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Accessible name for the decrement stepper (the icon is the sole carrier of
|
|
25
|
+
* meaning). Ships a documented English fallback (supplementary AT text, not
|
|
26
|
+
* a flow-critical label — i18n rule §6.2); localized hosts override it.
|
|
27
|
+
* @default 'Decrease'
|
|
28
|
+
*/
|
|
29
|
+
decrementLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Accessible name for the increment stepper. Documented English fallback,
|
|
32
|
+
* overridable (i18n rule §6.2).
|
|
33
|
+
* @default 'Increase'
|
|
34
|
+
*/
|
|
35
|
+
incrementLabel?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A semantic numeric input built on React Aria's `NumberField`.
|
|
39
|
+
*
|
|
40
|
+
* Renders a labelled control box (`Group`) holding the `<input>` between a
|
|
41
|
+
* decrement (−) and increment (+) stepper. Entity = Input → reads
|
|
42
|
+
* `vars.colors.input.primary.*`. Supports `minValue`/`maxValue`/`step` and
|
|
43
|
+
* locale-aware `formatOptions` (currency, percent, units). Validation is the
|
|
44
|
+
* `invalid` State (via `isInvalid`/`validate`), never an `evaluation` variant.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <NumberField label="Quantity" minValue={0} defaultValue={1}>
|
|
49
|
+
* </NumberField>
|
|
50
|
+
* <NumberField
|
|
51
|
+
* label="Price"
|
|
52
|
+
* formatOptions={{ style: 'currency', currency: 'USD' }}
|
|
53
|
+
* />
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
declare const NumberField$1: {
|
|
57
|
+
({
|
|
58
|
+
label,
|
|
59
|
+
description,
|
|
60
|
+
errorMessage,
|
|
61
|
+
decrementLabel,
|
|
62
|
+
incrementLabel,
|
|
63
|
+
...props
|
|
64
|
+
}: NumberFieldProps$1): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
displayName: "NumberField";
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { NumberField$1 as NumberField, NumberFieldProps$1 as NumberFieldProps, numberFieldMeta };
|
|
@@ -0,0 +1,220 @@
|
|
|
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, FieldError, Group, Input, Label, NumberField, Text } from "react-aria-components";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/components/NumberField/NumberField.tsx
|
|
10
|
+
/** Formal semantic identity — NumberField root (Input entity). */
|
|
11
|
+
var numberFieldMeta = {
|
|
12
|
+
displayName: "NumberField",
|
|
13
|
+
entity: "Input",
|
|
14
|
+
structure: "root"
|
|
15
|
+
};
|
|
16
|
+
/** Control box (the `Group`) chrome — the framed field around input + steppers. */
|
|
17
|
+
var buildControlBoxStyle = ({
|
|
18
|
+
c,
|
|
19
|
+
isDisabled,
|
|
20
|
+
isInvalid,
|
|
21
|
+
isFocusVisible
|
|
22
|
+
}) => {
|
|
23
|
+
return {
|
|
24
|
+
boxSizing: "border-box",
|
|
25
|
+
display: "inline-flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
minHeight: vars.sizing.hit.base,
|
|
28
|
+
borderRadius: vars.radii.control,
|
|
29
|
+
borderWidth: vars.border.outline.control.width,
|
|
30
|
+
borderStyle: vars.border.outline.control.style,
|
|
31
|
+
transitionProperty: "background-color, border-color",
|
|
32
|
+
transitionDuration: vars.motion.feedback.duration,
|
|
33
|
+
transitionTimingFunction: vars.motion.feedback.easing,
|
|
34
|
+
backgroundColor: resolveInteractiveStyle(c?.background, {
|
|
35
|
+
isDisabled,
|
|
36
|
+
isInvalid
|
|
37
|
+
}),
|
|
38
|
+
borderColor: resolveInteractiveStyle(c?.border, {
|
|
39
|
+
isDisabled,
|
|
40
|
+
isInvalid,
|
|
41
|
+
isFocusVisible
|
|
42
|
+
}),
|
|
43
|
+
outline: focusRingOutline(isFocusVisible)
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/** Stepper button chrome — borderless Action-pattern control in Input chrome. */
|
|
47
|
+
var buildStepperStyle = ({
|
|
48
|
+
c,
|
|
49
|
+
isDisabled
|
|
50
|
+
}) => {
|
|
51
|
+
return {
|
|
52
|
+
boxSizing: "border-box",
|
|
53
|
+
display: "inline-flex",
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
justifyContent: "center",
|
|
56
|
+
flexShrink: 0,
|
|
57
|
+
border: 0,
|
|
58
|
+
background: "transparent",
|
|
59
|
+
cursor: isDisabled ? "not-allowed" : "pointer",
|
|
60
|
+
opacity: isDisabled ? vars.opacity.disabled : void 0,
|
|
61
|
+
paddingBlock: vars.spacing.inset.control.sm,
|
|
62
|
+
paddingInline: vars.spacing.inset.control.sm,
|
|
63
|
+
color: c?.text?.default
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Resolve the field's text colors once (default for label/description/input,
|
|
68
|
+
* invalid for the validation message). Hoisted out of the render so the
|
|
69
|
+
* optional-chain reads keep the component's cyclomatic complexity low.
|
|
70
|
+
*/
|
|
71
|
+
var resolveFieldTextColors = c => {
|
|
72
|
+
const text = c?.text;
|
|
73
|
+
return {
|
|
74
|
+
base: text?.default,
|
|
75
|
+
invalid: text?.invalid ?? text?.default
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/** The `<input>` itself — borderless; the surrounding `Group` owns the frame. */
|
|
79
|
+
var buildInputStyle = c => {
|
|
80
|
+
return {
|
|
81
|
+
boxSizing: "border-box",
|
|
82
|
+
flex: 1,
|
|
83
|
+
minWidth: 0,
|
|
84
|
+
border: 0,
|
|
85
|
+
background: "transparent",
|
|
86
|
+
outline: "none",
|
|
87
|
+
textAlign: "center",
|
|
88
|
+
paddingBlock: vars.spacing.inset.control.sm,
|
|
89
|
+
color: c?.text?.default,
|
|
90
|
+
...vars.text.label.md
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A semantic numeric input built on React Aria's `NumberField`.
|
|
95
|
+
*
|
|
96
|
+
* Renders a labelled control box (`Group`) holding the `<input>` between a
|
|
97
|
+
* decrement (−) and increment (+) stepper. Entity = Input → reads
|
|
98
|
+
* `vars.colors.input.primary.*`. Supports `minValue`/`maxValue`/`step` and
|
|
99
|
+
* locale-aware `formatOptions` (currency, percent, units). Validation is the
|
|
100
|
+
* `invalid` State (via `isInvalid`/`validate`), never an `evaluation` variant.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```tsx
|
|
104
|
+
* <NumberField label="Quantity" minValue={0} defaultValue={1}>
|
|
105
|
+
* </NumberField>
|
|
106
|
+
* <NumberField
|
|
107
|
+
* label="Price"
|
|
108
|
+
* formatOptions={{ style: 'currency', currency: 'USD' }}
|
|
109
|
+
* />
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
var NumberField$1 = ({
|
|
113
|
+
label,
|
|
114
|
+
description,
|
|
115
|
+
errorMessage,
|
|
116
|
+
decrementLabel = "Decrease",
|
|
117
|
+
incrementLabel = "Increase",
|
|
118
|
+
...props
|
|
119
|
+
}) => {
|
|
120
|
+
const c = vars.colors.input.primary;
|
|
121
|
+
const {
|
|
122
|
+
base,
|
|
123
|
+
invalid
|
|
124
|
+
} = resolveFieldTextColors(c);
|
|
125
|
+
return /* @__PURE__ */jsxs(NumberField, {
|
|
126
|
+
...props,
|
|
127
|
+
"data-scope": "number-field",
|
|
128
|
+
"data-part": "root",
|
|
129
|
+
style: {
|
|
130
|
+
boxSizing: "border-box",
|
|
131
|
+
display: "flex",
|
|
132
|
+
flexDirection: "column",
|
|
133
|
+
gap: vars.spacing.gap.stack.xs
|
|
134
|
+
},
|
|
135
|
+
children: [label != null && /* @__PURE__ */jsx(Label, {
|
|
136
|
+
"data-scope": "number-field",
|
|
137
|
+
"data-part": "label",
|
|
138
|
+
style: {
|
|
139
|
+
...vars.text.label.md,
|
|
140
|
+
color: base
|
|
141
|
+
},
|
|
142
|
+
children: label
|
|
143
|
+
}), /* @__PURE__ */jsxs(Group, {
|
|
144
|
+
"data-scope": "number-field",
|
|
145
|
+
"data-part": "control",
|
|
146
|
+
style: ({
|
|
147
|
+
isDisabled,
|
|
148
|
+
isInvalid,
|
|
149
|
+
isFocusVisible
|
|
150
|
+
}) => {
|
|
151
|
+
return buildControlBoxStyle({
|
|
152
|
+
c,
|
|
153
|
+
isDisabled,
|
|
154
|
+
isInvalid,
|
|
155
|
+
isFocusVisible
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
children: [/* @__PURE__ */jsx(Button, {
|
|
159
|
+
slot: "decrement",
|
|
160
|
+
"data-scope": "number-field",
|
|
161
|
+
"data-part": "trigger",
|
|
162
|
+
style: ({
|
|
163
|
+
isDisabled
|
|
164
|
+
}) => {
|
|
165
|
+
return buildStepperStyle({
|
|
166
|
+
c,
|
|
167
|
+
isDisabled
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
children: /* @__PURE__ */jsx(Icon, {
|
|
171
|
+
intent: "action.decrement",
|
|
172
|
+
size: "sm",
|
|
173
|
+
label: decrementLabel
|
|
174
|
+
})
|
|
175
|
+
}), /* @__PURE__ */jsx(Input, {
|
|
176
|
+
"data-scope": "number-field",
|
|
177
|
+
"data-part": "control",
|
|
178
|
+
style: buildInputStyle(c)
|
|
179
|
+
}), /* @__PURE__ */jsx(Button, {
|
|
180
|
+
slot: "increment",
|
|
181
|
+
"data-scope": "number-field",
|
|
182
|
+
"data-part": "trigger",
|
|
183
|
+
style: ({
|
|
184
|
+
isDisabled
|
|
185
|
+
}) => {
|
|
186
|
+
return buildStepperStyle({
|
|
187
|
+
c,
|
|
188
|
+
isDisabled
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
children: /* @__PURE__ */jsx(Icon, {
|
|
192
|
+
intent: "action.increment",
|
|
193
|
+
size: "sm",
|
|
194
|
+
label: incrementLabel
|
|
195
|
+
})
|
|
196
|
+
})]
|
|
197
|
+
}), description != null && /* @__PURE__ */jsx(Text, {
|
|
198
|
+
slot: "description",
|
|
199
|
+
"data-scope": "number-field",
|
|
200
|
+
"data-part": "description",
|
|
201
|
+
style: {
|
|
202
|
+
...vars.text.label.sm,
|
|
203
|
+
color: base
|
|
204
|
+
},
|
|
205
|
+
children: description
|
|
206
|
+
}), /* @__PURE__ */jsx(FieldError, {
|
|
207
|
+
"data-scope": "number-field",
|
|
208
|
+
"data-part": "validationMessage",
|
|
209
|
+
style: {
|
|
210
|
+
...vars.text.label.sm,
|
|
211
|
+
color: invalid
|
|
212
|
+
},
|
|
213
|
+
children: errorMessage
|
|
214
|
+
})]
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
NumberField$1.displayName = numberFieldMeta.displayName;
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
export { NumberField$1 as NumberField, numberFieldMeta };
|