ionbase-ui 0.51.0 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordion.d.ts +54 -0
- package/dist/components/Accordion.d.ts.map +1 -0
- package/dist/components/Accordion.js +68 -0
- package/dist/components/Accordion.js.map +1 -0
- package/dist/components/AgentActivity.d.ts +2 -1
- package/dist/components/AgentActivity.d.ts.map +1 -1
- package/dist/components/AgentActivity.js +4 -17
- package/dist/components/AgentActivity.js.map +1 -1
- package/dist/components/Breadcrumb.d.ts +45 -0
- package/dist/components/Breadcrumb.d.ts.map +1 -0
- package/dist/components/Breadcrumb.js +31 -0
- package/dist/components/Breadcrumb.js.map +1 -0
- package/dist/components/Calendar.d.ts +20 -0
- package/dist/components/Calendar.d.ts.map +1 -0
- package/dist/components/Calendar.js +151 -0
- package/dist/components/Calendar.js.map +1 -0
- package/dist/components/CalendarPopover.d.ts +26 -0
- package/dist/components/CalendarPopover.d.ts.map +1 -0
- package/dist/components/CalendarPopover.js +45 -0
- package/dist/components/CalendarPopover.js.map +1 -0
- package/dist/components/Checkbox.d.ts +2 -1
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +4 -2
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Combobox.d.ts +86 -0
- package/dist/components/Combobox.d.ts.map +1 -0
- package/dist/components/Combobox.js +261 -0
- package/dist/components/Combobox.js.map +1 -0
- package/dist/components/DateField.d.ts +15 -0
- package/dist/components/DateField.d.ts.map +1 -0
- package/dist/components/DateField.js +74 -0
- package/dist/components/DateField.js.map +1 -0
- package/dist/components/DatePicker.d.ts +81 -0
- package/dist/components/DatePicker.d.ts.map +1 -0
- package/dist/components/DatePicker.js +102 -0
- package/dist/components/DatePicker.js.map +1 -0
- package/dist/components/DateRangePicker.d.ts +117 -0
- package/dist/components/DateRangePicker.d.ts.map +1 -0
- package/dist/components/DateRangePicker.js +152 -0
- package/dist/components/DateRangePicker.js.map +1 -0
- package/dist/components/Drawer.d.ts +52 -0
- package/dist/components/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer.js +66 -0
- package/dist/components/Drawer.js.map +1 -0
- package/dist/components/FileUpload.d.ts +79 -0
- package/dist/components/FileUpload.d.ts.map +1 -0
- package/dist/components/FileUpload.js +218 -0
- package/dist/components/FileUpload.js.map +1 -0
- package/dist/components/Header.d.ts +10 -0
- package/dist/components/Header.d.ts.map +1 -1
- package/dist/components/Header.js +18 -3
- package/dist/components/Header.js.map +1 -1
- package/dist/components/NumberInput.d.ts +63 -0
- package/dist/components/NumberInput.d.ts.map +1 -0
- package/dist/components/NumberInput.js +102 -0
- package/dist/components/NumberInput.js.map +1 -0
- package/dist/components/ProgressBar.d.ts +46 -0
- package/dist/components/ProgressBar.d.ts.map +1 -0
- package/dist/components/ProgressBar.js +52 -0
- package/dist/components/ProgressBar.js.map +1 -0
- package/dist/components/PromptInput.d.ts +89 -0
- package/dist/components/PromptInput.d.ts.map +1 -0
- package/dist/components/PromptInput.js +130 -0
- package/dist/components/PromptInput.js.map +1 -0
- package/dist/components/SegmentedControl.d.ts +63 -0
- package/dist/components/SegmentedControl.d.ts.map +1 -0
- package/dist/components/SegmentedControl.js +79 -0
- package/dist/components/SegmentedControl.js.map +1 -0
- package/dist/components/Select.d.ts +9 -2
- package/dist/components/Select.d.ts.map +1 -1
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Sidebar.d.ts +109 -0
- package/dist/components/Sidebar.d.ts.map +1 -0
- package/dist/components/Sidebar.js +106 -0
- package/dist/components/Sidebar.js.map +1 -0
- package/dist/components/Skeleton.d.ts +39 -0
- package/dist/components/Skeleton.d.ts.map +1 -0
- package/dist/components/Skeleton.js +50 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/Spinner.d.ts +45 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +44 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Stepper.d.ts +73 -0
- package/dist/components/Stepper.d.ts.map +1 -0
- package/dist/components/Stepper.js +82 -0
- package/dist/components/Stepper.js.map +1 -0
- package/dist/components/Toggle.d.ts +2 -1
- package/dist/components/Toggle.d.ts.map +1 -1
- package/dist/components/Toggle.js +4 -2
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/ToolCall.d.ts +66 -0
- package/dist/components/ToolCall.d.ts.map +1 -0
- package/dist/components/ToolCall.js +78 -0
- package/dist/components/ToolCall.js.map +1 -0
- package/dist/components/agent-status.d.ts +14 -0
- package/dist/components/agent-status.d.ts.map +1 -0
- package/dist/components/agent-status.js +16 -0
- package/dist/components/agent-status.js.map +1 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +16 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/iso-date.d.ts +53 -0
- package/dist/components/iso-date.d.ts.map +1 -0
- package/dist/components/iso-date.js +102 -0
- package/dist/components/iso-date.js.map +1 -0
- package/dist/components/resolve-selection.d.ts +36 -0
- package/dist/components/resolve-selection.d.ts.map +1 -0
- package/dist/components/resolve-selection.js +14 -0
- package/dist/components/resolve-selection.js.map +1 -0
- package/dist/figma-descriptions.json +255 -145
- package/dist/figma-map.json +3205 -1860
- package/dist/meta/Accordion.json +123 -0
- package/dist/meta/AccordionItem.json +90 -0
- package/dist/meta/AgentActivityStep.json +2 -2
- package/dist/meta/Breadcrumb.json +87 -0
- package/dist/meta/BreadcrumbItem.json +78 -0
- package/dist/meta/Checkbox.json +18 -1
- package/dist/meta/Combobox.json +265 -0
- package/dist/meta/DatePicker.json +270 -0
- package/dist/meta/DateRangePicker.json +284 -0
- package/dist/meta/Drawer.json +234 -0
- package/dist/meta/EmptyState.json +1 -1
- package/dist/meta/FileUpload.json +246 -0
- package/dist/meta/Header.json +32 -2
- package/dist/meta/NumberInput.json +407 -0
- package/dist/meta/PhoneInput.json +39 -39
- package/dist/meta/Popover.json +3 -3
- package/dist/meta/ProgressBar.json +166 -0
- package/dist/meta/PromptInput.json +212 -0
- package/dist/meta/SegmentedControl.json +217 -0
- package/dist/meta/SegmentedControlItem.json +122 -0
- package/dist/meta/Select.json +4 -3
- package/dist/meta/Sidebar.json +150 -0
- package/dist/meta/SidebarItem.json +184 -0
- package/dist/meta/SidebarSection.json +131 -0
- package/dist/meta/Skeleton.json +120 -0
- package/dist/meta/Spinner.json +123 -0
- package/dist/meta/Stepper.json +135 -0
- package/dist/meta/StepperStep.json +148 -0
- package/dist/meta/Tabs.json +5 -0
- package/dist/meta/Toggle.json +18 -1
- package/dist/meta/ToolCall.json +192 -0
- package/dist/meta/Tooltip.json +3 -3
- package/dist/meta/components.json +6759 -2705
- package/dist/meta/contrast.json +11075 -3098
- package/dist/meta/index.json +266 -8
- package/dist/meta/patterns/AgentRun.json +27 -0
- package/dist/meta/patterns/Form.json +9 -0
- package/dist/meta/patterns/PageShell.json +43 -3
- package/dist/meta/patterns/Wizard.json +20 -1
- package/dist/meta/patterns/index.json +10 -1
- package/dist/styles/accordion.css +102 -0
- package/dist/styles/breadcrumb.css +72 -0
- package/dist/styles/combobox.css +154 -0
- package/dist/styles/date-picker.css +420 -0
- package/dist/styles/date-range-picker.css +280 -0
- package/dist/styles/drawer.css +181 -0
- package/dist/styles/empty-state.css +16 -4
- package/dist/styles/file-upload.css +236 -0
- package/dist/styles/header.css +26 -0
- package/dist/styles/index.css +23 -0
- package/dist/styles/number-input.css +83 -0
- package/dist/styles/progress-bar.css +107 -0
- package/dist/styles/prompt-input.css +127 -0
- package/dist/styles/segmented-control.css +182 -0
- package/dist/styles/sidebar.css +307 -0
- package/dist/styles/skeleton.css +76 -0
- package/dist/styles/spinner.css +70 -0
- package/dist/styles/stepper.css +250 -0
- package/dist/styles/tool-call.css +202 -0
- package/llms.txt +2 -2
- package/package.json +2 -1
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useId, useRef, useState } from 'react';
|
|
4
|
+
const UploadIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M12 16V4m0 0L8 8m4-4 4 4M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
5
|
+
const RemoveIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M18 6 6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
6
|
+
/**
|
|
7
|
+
* Bytes as a person would say them.
|
|
8
|
+
*
|
|
9
|
+
* Decimal units, not binary: a disk sold as 500 GB and a browser reporting a
|
|
10
|
+
* file size both mean powers of 1000, and showing "476 MiB" for a 500 MB file
|
|
11
|
+
* is correct arithmetic and a confusing answer.
|
|
12
|
+
*/
|
|
13
|
+
const formatBytes = (bytes) => {
|
|
14
|
+
if (bytes < 1000)
|
|
15
|
+
return `${bytes} B`;
|
|
16
|
+
const units = ['kB', 'MB', 'GB', 'TB'];
|
|
17
|
+
let value = bytes / 1000;
|
|
18
|
+
let unit = 0;
|
|
19
|
+
while (value >= 1000 && unit < units.length - 1) {
|
|
20
|
+
value /= 1000;
|
|
21
|
+
unit += 1;
|
|
22
|
+
}
|
|
23
|
+
return `${value < 10 ? value.toFixed(1) : Math.round(value)} ${units[unit]}`;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Does a file match an `accept` list?
|
|
27
|
+
*
|
|
28
|
+
* The browser enforces `accept` in its own picker but NOT on drop, and not at
|
|
29
|
+
* all if the user switches the picker's filter to "All files" — which every
|
|
30
|
+
* platform picker offers. So the check is repeated here. Treating the native
|
|
31
|
+
* attribute as a guarantee is the standard way a drop zone ends up holding a
|
|
32
|
+
* .exe someone dragged into it.
|
|
33
|
+
*/
|
|
34
|
+
const matchesAccept = (file, accept) => {
|
|
35
|
+
if (!accept)
|
|
36
|
+
return true;
|
|
37
|
+
const name = file.name.toLowerCase();
|
|
38
|
+
const type = file.type.toLowerCase();
|
|
39
|
+
return accept.split(',').some((raw) => {
|
|
40
|
+
const token = raw.trim().toLowerCase();
|
|
41
|
+
if (!token)
|
|
42
|
+
return false;
|
|
43
|
+
if (token.startsWith('.'))
|
|
44
|
+
return name.endsWith(token);
|
|
45
|
+
if (token.endsWith('/*'))
|
|
46
|
+
return type.startsWith(token.slice(0, -1));
|
|
47
|
+
return type === token;
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* FileUpload — a drop target wrapped around a real `<input type="file">`.
|
|
52
|
+
*
|
|
53
|
+
* Drawn in Figma as `File Upload` (1367:2333) — two sizes by five states. The
|
|
54
|
+
* measurements came from `Input` and `EmptyState` rather than being invented:
|
|
55
|
+
* the border, radius and disabled treatment are Input's; the centred
|
|
56
|
+
* icon-over-text stack is EmptyState's. Figma draws the drop zone alone, the
|
|
57
|
+
* same split `Input` makes against `Form Field`.
|
|
58
|
+
*
|
|
59
|
+
* THE INPUT IS THE CONTROL. THE DROP ZONE IS DECORATION.
|
|
60
|
+
*
|
|
61
|
+
* The usual build of this component is a `<div>` with drag handlers and a
|
|
62
|
+
* click that calls `input.click()`. That version cannot be reached by keyboard,
|
|
63
|
+
* has no accessible name, does not participate in a form, and does not work in
|
|
64
|
+
* any environment without a pointer — which includes switch access, voice
|
|
65
|
+
* control and most screen-reader browse modes.
|
|
66
|
+
*
|
|
67
|
+
* Here the file input is a real, focusable, labelled control that is visually
|
|
68
|
+
* hidden but NOT `display: none` — it keeps its place in the tab order and its
|
|
69
|
+
* label. Drag-and-drop is layered on top as an enhancement, and every path it
|
|
70
|
+
* offers is also reachable without it. That ordering is the whole component.
|
|
71
|
+
*
|
|
72
|
+
* VALIDATION IS ADVISORY, NOT SECURITY. `accept` and `maxSize` are checked here
|
|
73
|
+
* so the user finds out immediately instead of after an upload. A server that
|
|
74
|
+
* trusts either one is trusting a value the client chose.
|
|
75
|
+
*/
|
|
76
|
+
export function FileUpload({ label, description, errorMessage, isInvalid, isDisabled: isDisabledProp, size = 'md', accept, multiple, maxSize, maxFiles, files: controlledFiles, onChange, onReject, prompt, hint, removeLabel = (name) => `Remove ${name}`, className, wrapperClassName, id: providedId, name: inputName, }) {
|
|
77
|
+
/* No `disabled` alias to resolve: FileUpload is new, so it never had one. */
|
|
78
|
+
const isDisabled = isDisabledProp ?? false;
|
|
79
|
+
const generatedId = useId();
|
|
80
|
+
const id = providedId ?? generatedId;
|
|
81
|
+
const helperId = `${id}-helper`;
|
|
82
|
+
const hintId = `${id}-hint`;
|
|
83
|
+
const inputRef = useRef(null);
|
|
84
|
+
const [uncontrolled, setUncontrolled] = useState([]);
|
|
85
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
86
|
+
/*
|
|
87
|
+
* A depth counter, not a boolean. `dragleave` fires every time the pointer
|
|
88
|
+
* crosses into a CHILD element, so a boolean flickers off whenever the
|
|
89
|
+
* cursor passes over the icon or the prompt text. Counting enter/leave pairs
|
|
90
|
+
* is the only version that survives having children.
|
|
91
|
+
*/
|
|
92
|
+
const dragDepth = useRef(0);
|
|
93
|
+
const files = controlledFiles ? [...controlledFiles] : uncontrolled;
|
|
94
|
+
const commit = useCallback((next) => {
|
|
95
|
+
if (!controlledFiles)
|
|
96
|
+
setUncontrolled(next);
|
|
97
|
+
onChange?.(next);
|
|
98
|
+
}, [controlledFiles, onChange]);
|
|
99
|
+
const add = useCallback((incoming) => {
|
|
100
|
+
if (isDisabled || incoming.length === 0)
|
|
101
|
+
return;
|
|
102
|
+
const accepted = [];
|
|
103
|
+
const rejected = [];
|
|
104
|
+
/*
|
|
105
|
+
* Room is counted against what is already held, so dropping four files
|
|
106
|
+
* onto a control holding two with maxFiles=3 accepts one and reports
|
|
107
|
+
* three — rather than accepting all four or refusing the lot.
|
|
108
|
+
*/
|
|
109
|
+
let room = multiple ? (maxFiles ?? Infinity) - files.length : 1;
|
|
110
|
+
for (const file of incoming) {
|
|
111
|
+
if (!matchesAccept(file, accept)) {
|
|
112
|
+
rejected.push({
|
|
113
|
+
file,
|
|
114
|
+
reason: 'type',
|
|
115
|
+
message: `${file.name} is not an accepted file type.`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else if (maxSize !== undefined && file.size > maxSize) {
|
|
119
|
+
rejected.push({
|
|
120
|
+
file,
|
|
121
|
+
reason: 'size',
|
|
122
|
+
message: `${file.name} is ${formatBytes(file.size)}, over the ${formatBytes(maxSize)} limit.`,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else if (room <= 0) {
|
|
126
|
+
rejected.push({
|
|
127
|
+
file,
|
|
128
|
+
reason: 'count',
|
|
129
|
+
message: multiple
|
|
130
|
+
? `${file.name} was not added — at most ${maxFiles} files.`
|
|
131
|
+
: `${file.name} was not added — only one file is allowed.`,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
accepted.push(file);
|
|
136
|
+
room -= 1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (accepted.length)
|
|
140
|
+
commit(multiple ? [...files, ...accepted] : accepted);
|
|
141
|
+
if (rejected.length)
|
|
142
|
+
onReject?.(rejected);
|
|
143
|
+
}, [accept, commit, files, isDisabled, maxFiles, maxSize, multiple, onReject]);
|
|
144
|
+
const remove = (index) => {
|
|
145
|
+
commit(files.filter((_, i) => i !== index));
|
|
146
|
+
/*
|
|
147
|
+
* Clearing the input's own value matters: a browser fires no `change` when
|
|
148
|
+
* the same file is picked twice in a row, so removing a file and picking it
|
|
149
|
+
* again would silently do nothing.
|
|
150
|
+
*/
|
|
151
|
+
if (inputRef.current)
|
|
152
|
+
inputRef.current.value = '';
|
|
153
|
+
};
|
|
154
|
+
const helper = isInvalid && errorMessage ? errorMessage : description;
|
|
155
|
+
const zoneClassNames = [
|
|
156
|
+
'ion-file-upload',
|
|
157
|
+
size !== 'md' ? `ion-file-upload--${size}` : '',
|
|
158
|
+
isDragging ? 'ion-file-upload--dragging' : '',
|
|
159
|
+
isInvalid ? 'ion-file-upload--invalid' : '',
|
|
160
|
+
isDisabled ? 'ion-file-upload--disabled' : '',
|
|
161
|
+
className || '',
|
|
162
|
+
]
|
|
163
|
+
.filter(Boolean)
|
|
164
|
+
.join(' ');
|
|
165
|
+
const zone = (_jsxs("div", { className: zoneClassNames, "data-dragging": isDragging || undefined, "data-invalid": isInvalid || undefined, "data-disabled": isDisabled || undefined, onDragEnter: (e) => {
|
|
166
|
+
if (isDisabled)
|
|
167
|
+
return;
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
dragDepth.current += 1;
|
|
170
|
+
setIsDragging(true);
|
|
171
|
+
}, onDragOver: (e) => {
|
|
172
|
+
if (isDisabled)
|
|
173
|
+
return;
|
|
174
|
+
// Without this the browser navigates to the dropped file. There is no
|
|
175
|
+
// other reason for a dragover handler that only calls preventDefault.
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
}, onDragLeave: () => {
|
|
178
|
+
dragDepth.current = Math.max(0, dragDepth.current - 1);
|
|
179
|
+
if (dragDepth.current === 0)
|
|
180
|
+
setIsDragging(false);
|
|
181
|
+
}, onDrop: (e) => {
|
|
182
|
+
if (isDisabled)
|
|
183
|
+
return;
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
dragDepth.current = 0;
|
|
186
|
+
setIsDragging(false);
|
|
187
|
+
add(Array.from(e.dataTransfer.files));
|
|
188
|
+
}, children: [_jsx("input", { ref: inputRef, type: "file", id: id, name: inputName, className: "ion-file-upload__input", accept: accept, multiple: multiple, disabled: isDisabled, "aria-describedby": [hint ? hintId : null, helper ? helperId : null]
|
|
189
|
+
.filter(Boolean)
|
|
190
|
+
.join(' ') || undefined, "aria-invalid": isInvalid || undefined, onChange: (e) => {
|
|
191
|
+
add(Array.from(e.target.files ?? []));
|
|
192
|
+
// Same reason as remove(): re-picking an identical file must fire.
|
|
193
|
+
e.target.value = '';
|
|
194
|
+
} }), _jsxs("label", { htmlFor: id, className: "ion-file-upload__target", children: [_jsx("span", { className: "ion-file-upload__icon", "aria-hidden": "true", children: _jsx(UploadIcon, {}) }), _jsx("span", { className: "ion-file-upload__prompt", children: prompt ??
|
|
195
|
+
(multiple
|
|
196
|
+
? 'Choose files or drag them here'
|
|
197
|
+
: 'Choose a file or drag it here') }), hint && (_jsx("span", { id: hintId, className: "ion-file-upload__hint", children: hint }))] })] }));
|
|
198
|
+
const list = files.length > 0 && (_jsx("ul", { className: "ion-file-upload__list", children: files.map((file, index) => (_jsxs("li", { className: "ion-file-upload__file", children: [_jsx("span", { className: "ion-file-upload__name", children: file.name }), _jsx("span", { className: "ion-file-upload__size", children: formatBytes(file.size) }), _jsx("button", { type: "button", className: "ion-file-upload__remove", "aria-label": removeLabel(file.name), disabled: isDisabled, onClick: () => remove(index), children: _jsx(RemoveIcon, {}) })] }, `${file.name}-${file.size}-${index}`))) }));
|
|
199
|
+
/*
|
|
200
|
+
* The count, announced. A file added by drop produces no focus change and no
|
|
201
|
+
* visible change anywhere near the user's attention, so without this a screen
|
|
202
|
+
* reader user gets no confirmation that the drop did anything at all. Polite,
|
|
203
|
+
* and the count rather than the names: reading six filenames over an
|
|
204
|
+
* assertive interruption is worse than saying how many there now are.
|
|
205
|
+
*/
|
|
206
|
+
const status = (_jsx("span", { className: "ion-visually-hidden", role: "status", "aria-live": "polite", children: files.length === 0
|
|
207
|
+
? ''
|
|
208
|
+
: `${files.length} file${files.length === 1 ? '' : 's'} selected` }));
|
|
209
|
+
return (_jsxs("div", { className: [
|
|
210
|
+
'ion-field',
|
|
211
|
+
isInvalid ? 'ion-field--error' : '',
|
|
212
|
+
wrapperClassName || '',
|
|
213
|
+
]
|
|
214
|
+
.filter(Boolean)
|
|
215
|
+
.join(' '), children: [label && (_jsx("label", { htmlFor: id, className: "ion-field__label", children: label })), zone, list, status, helper && (_jsx("span", { id: helperId, className: "ion-field__helper", children: helper }))] }));
|
|
216
|
+
}
|
|
217
|
+
FileUpload.displayName = 'FileUpload';
|
|
218
|
+
//# sourceMappingURL=FileUpload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUpload.js","sourceRoot":"","sources":["../../src/components/FileUpload.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAoDpE,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,CACvB,cAAK,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,YACvE,eACE,CAAC,EAAC,mEAAmE,EACrE,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,GACE,CACP,CAAC;AAEF,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,CACvB,cAAK,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,YACvE,eACE,CAAC,EAAC,sBAAsB,EACxB,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,GACE,CACP,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE;IAC5C,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtC,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,IAAI,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;IACzB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,OAAO,KAA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,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAClC,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,YAE5B,KAAC,UAAU,KAAG,GACP,KAfJ,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,KAAK,EAAE,CAgBtC,CACN,CAAC,GACC,CACN,CAAC;IAEF;;;;;;OAMG;IACH,MAAM,MAAM,GAAG,CACb,eAAM,SAAS,EAAC,qBAAqB,EAAC,IAAI,EAAC,QAAQ,eAAW,QAAQ,YACnE,KAAK,CAAC,MAAM,KAAK,CAAC;YACjB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,QAAQ,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,WAAW,GAC9D,CACR,CAAC;IAEF,OAAO,CACL,eACE,SAAS,EAAE;YACT,WAAW;YACX,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE;YACnC,gBAAgB,IAAI,EAAE;SACvB;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,aAEX,KAAK,IAAI,CACR,gBAAO,OAAO,EAAE,EAAE,EAAE,SAAS,EAAC,kBAAkB,YAC7C,KAAK,GACA,CACT,EACA,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,MAAM,IAAI,CACT,eAAM,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAC,mBAAmB,YAC9C,MAAM,GACF,CACR,IACG,CACP,CAAC;AACJ,CAAC;AAED,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC"}
|
|
@@ -15,6 +15,16 @@ export interface HeaderProps extends Omit<React.HTMLAttributes<HTMLElement>, 'on
|
|
|
15
15
|
onOpenChange?: (open: boolean) => void;
|
|
16
16
|
/** Accessible name for the mobile menu toggle. */
|
|
17
17
|
menuLabel?: string;
|
|
18
|
+
/**
|
|
19
|
+
* What the mobile toggle opens.
|
|
20
|
+
*
|
|
21
|
+
* `panel` (default) is Figma's Mobile-Open: `center` and `end` drop below the
|
|
22
|
+
* bar. `dialog` is for an app whose navigation lives in a Sidebar: the toggle
|
|
23
|
+
* sits at the start of the bar and only reports `onOpenChange`, the caller
|
|
24
|
+
* opens a Drawer with it, and `center` and `end` stay in the bar at every
|
|
25
|
+
* width — so keep `center` empty and `end` short.
|
|
26
|
+
*/
|
|
27
|
+
menuType?: 'panel' | 'dialog';
|
|
18
28
|
children?: React.ReactNode;
|
|
19
29
|
}
|
|
20
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AA2BxE,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EACjC,UAAU,CACX;IACC,+DAA+D;IAC/D,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;iEAC6D;IAC7D,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,kFAAkF;IAClF,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mDAAmD;IACnD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AA2BxE,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EACjC,UAAU,CACX;IACC,+DAA+D;IAC/D,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;iEAC6D;IAC7D,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,kFAAkF;IAClF,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mDAAmD;IACnD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC9B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,MAAM,iFAgGlB,CAAC"}
|
|
@@ -42,7 +42,7 @@ const CloseGlyph = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", "ari
|
|
|
42
42
|
* A `<header>` element with no explicit role: it is a landmark already when it
|
|
43
43
|
* is a direct child of body, which is where a page header sits.
|
|
44
44
|
*/
|
|
45
|
-
export const Header = forwardRef(({ brand, center, end, open: openProp, defaultOpen = false, onOpenChange, menuLabel = 'Menu', className, children, ...rest }, ref) => {
|
|
45
|
+
export const Header = forwardRef(({ brand, center, end, open: openProp, defaultOpen = false, onOpenChange, menuLabel = 'Menu', menuType = 'panel', className, children, ...rest }, ref) => {
|
|
46
46
|
const menuId = useId();
|
|
47
47
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
48
48
|
const isControlled = openProp !== undefined;
|
|
@@ -59,12 +59,27 @@ export const Header = forwardRef(({ brand, center, end, open: openProp, defaultO
|
|
|
59
59
|
* and it is handled on the header rather than the document so a header that
|
|
60
60
|
* is never open never listens.
|
|
61
61
|
*/
|
|
62
|
+
const isDialog = menuType === 'dialog';
|
|
62
63
|
const handleKeyDown = (event) => {
|
|
63
|
-
|
|
64
|
+
// A dialog owns its own Escape; the header only closes its own panel.
|
|
65
|
+
if (event.key === 'Escape' && isOpen && !isDialog)
|
|
64
66
|
toggle();
|
|
65
67
|
rest.onKeyDown?.(event);
|
|
66
68
|
};
|
|
67
|
-
|
|
69
|
+
/*
|
|
70
|
+
* As a panel the toggle discloses the menu wrapper, which is always in the
|
|
71
|
+
* DOM, so aria-controls can point at it. As a dialog it opens something the
|
|
72
|
+
* caller mounts only while open — an aria-controls pointing at a missing id
|
|
73
|
+
* is an error — so it says what it opens with aria-haspopup instead.
|
|
74
|
+
*/
|
|
75
|
+
const toggleButton = (_jsx("button", { type: "button", className: "ion-header__toggle", "aria-expanded": isOpen, "aria-controls": isDialog ? undefined : menuId, "aria-haspopup": isDialog ? 'dialog' : undefined, "aria-label": menuLabel, onClick: toggle, children: isOpen && !isDialog ? _jsx(CloseGlyph, {}) : _jsx(MenuGlyph, {}) }));
|
|
76
|
+
return (_jsxs("header", { ...rest, onKeyDown: handleKeyDown, ref: ref, "data-open": (isOpen && !isDialog) || undefined, className: [
|
|
77
|
+
'ion-header',
|
|
78
|
+
isDialog ? 'ion-header--dialog-menu' : '',
|
|
79
|
+
className,
|
|
80
|
+
]
|
|
81
|
+
.filter(Boolean)
|
|
82
|
+
.join(' '), children: [isDialog && toggleButton, brand && _jsx("div", { className: "ion-header__brand", children: brand }), _jsxs("div", { className: "ion-header__menu", id: menuId, children: [_jsx("div", { className: "ion-header__center", children: center }), _jsx("div", { className: "ion-header__end", children: end })] }), children, !isDialog && toggleButton] }));
|
|
68
83
|
});
|
|
69
84
|
Header.displayName = 'Header';
|
|
70
85
|
//# sourceMappingURL=Header.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExE;kFACkF;AAClF,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CACtB,cAAK,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,YACvE,eACE,CAAC,EAAC,yBAAyB,EAC3B,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,GACrB,GACE,CACP,CAAC;AAEF,gDAAgD;AAChD,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,CACvB,cAAK,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,YACvE,eACE,CAAC,EAAC,sBAAsB,EACxB,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,GACrB,GACE,CACP,CAAC;
|
|
1
|
+
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../src/components/Header.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExE;kFACkF;AAClF,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CACtB,cAAK,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,YACvE,eACE,CAAC,EAAC,yBAAyB,EAC3B,MAAM,EAAC,cAAc,EACrB,WAAW,E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AI,YAAY,IACnB,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AriaNumberFieldProps } from 'react-aria';
|
|
3
|
+
export type NumberInputSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
type NumberInputDOMProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof AriaNumberFieldProps | 'size' | 'type' | 'min' | 'max' | 'step' | 'disabled' | 'value' | 'defaultValue' | 'onChange'>;
|
|
5
|
+
export interface NumberInputProps extends Omit<AriaNumberFieldProps, 'value' | 'defaultValue' | 'onChange'>, NumberInputDOMProps {
|
|
6
|
+
/**
|
|
7
|
+
* Controlled value. `null` is empty — never `NaN`, which is what the
|
|
8
|
+
* underlying hook uses and which fails every `===` check a caller writes.
|
|
9
|
+
*/
|
|
10
|
+
value?: number | null;
|
|
11
|
+
/** Uncontrolled starting value. `null` for empty. */
|
|
12
|
+
defaultValue?: number | null;
|
|
13
|
+
/**
|
|
14
|
+
* Fires when the value is committed — on blur, Enter, a step button or an
|
|
15
|
+
* arrow key — not on every keystroke. `null` when the field was cleared.
|
|
16
|
+
*/
|
|
17
|
+
onChange?: (value: number | null) => void;
|
|
18
|
+
/** Matches Input's `size`: Small, Medium, Large. */
|
|
19
|
+
size?: NumberInputSize;
|
|
20
|
+
/**
|
|
21
|
+
* The − and + buttons. On by default; turn off for a dense table cell where
|
|
22
|
+
* the arrow keys are enough.
|
|
23
|
+
*/
|
|
24
|
+
showStepper?: boolean;
|
|
25
|
+
/** Class names for the control box (`.ion-input`). */
|
|
26
|
+
className?: string;
|
|
27
|
+
/** Class names for the `.ion-field` wrapper when a label or helper is shown. */
|
|
28
|
+
wrapperClassName?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* NumberInput — a quantity, with formatting, bounds and steps.
|
|
32
|
+
*
|
|
33
|
+
* NOT `<input type="number">`, and the list of reasons is the component:
|
|
34
|
+
*
|
|
35
|
+
* It scrolls. A focused `type="number"` changes value under the mouse wheel,
|
|
36
|
+
* so a user scrolling the page past a price field edits the price. The wheel
|
|
37
|
+
* is OFF here by default (`isWheelDisabled`), and a caller has to ask for it.
|
|
38
|
+
*
|
|
39
|
+
* It cannot format. "1,234.50", "€12", "15%" are text to the browser's number
|
|
40
|
+
* input, which rejects them. `formatOptions` takes `Intl.NumberFormatOptions`,
|
|
41
|
+
* so currency, percent and units display and parse in the user's locale —
|
|
42
|
+
* including "1.234,50" for a German user.
|
|
43
|
+
*
|
|
44
|
+
* It is not a number to the browser's validation either. `type="text"` with
|
|
45
|
+
* the right `inputMode` gets the numeric keyboard on a phone without
|
|
46
|
+
* Firefox letting letters in and Chrome silently reporting an empty value.
|
|
47
|
+
*
|
|
48
|
+
* EMPTY IS `null`, NOT `NaN`. React Aria reports an empty field as `NaN`, and
|
|
49
|
+
* `NaN === NaN` is false — so every "is it empty" check a caller writes is
|
|
50
|
+
* wrong. This converts at the boundary, both ways.
|
|
51
|
+
*
|
|
52
|
+
* − AND + SIT SIDE BY SIDE, NOT STACKED. Stacked chevrons split the field's
|
|
53
|
+
* height in two, which puts a Small field's targets at 16px — under the 24px
|
|
54
|
+
* WCAG 2.5.8 asks. Side by side, every size clears it. They are out of the tab
|
|
55
|
+
* order, as React Aria sets them: the arrow keys do the same job from the field,
|
|
56
|
+
* and two extra tab stops per number on a form is a tax on every keyboard user.
|
|
57
|
+
*
|
|
58
|
+
* The box is Input's, class for class, so every state — hover, focus, invalid,
|
|
59
|
+
* read-only, disabled — is Input's and cannot drift from it.
|
|
60
|
+
*/
|
|
61
|
+
export declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=NumberInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../src/components/NumberInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkD,MAAM,OAAO,CAAC;AASvE,OAAO,KAAK,EAAmB,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAIxE,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjD,KAAK,mBAAmB,GAAG,IAAI,CAC7B,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EACzC,MAAM,oBAAoB,GAC1B,MAAM,GACN,MAAM,GACN,KAAK,GACL,KAAK,GACL,MAAM,GACN,UAAU,GACV,OAAO,GACP,cAAc,GACd,UAAU,CACb,CAAC;AAEF,MAAM,WAAW,gBACf,SACE,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,cAAc,GAAG,UAAU,CAAC,EACjE,mBAAmB;IACrB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C,oDAAoD;IACpD,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAoDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,WAAW,2FA4HvB,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
4
|
+
import { mergeProps, useButton, useFocusRing, useHover, useLocale, useNumberField, } from 'react-aria';
|
|
5
|
+
import { useNumberFieldState } from 'react-stately';
|
|
6
|
+
import { ARIA_TEXT_FIELD_NON_DOM_PROPS, omitProps } from './dom-props.js';
|
|
7
|
+
/* Props this component or the number-field hook consume, on top of a text field's. */
|
|
8
|
+
const NUMBER_FIELD_NON_DOM_PROPS = [
|
|
9
|
+
...ARIA_TEXT_FIELD_NON_DOM_PROPS,
|
|
10
|
+
'minValue',
|
|
11
|
+
'maxValue',
|
|
12
|
+
'step',
|
|
13
|
+
'formatOptions',
|
|
14
|
+
'commitBehavior',
|
|
15
|
+
'isWheelDisabled',
|
|
16
|
+
'incrementAriaLabel',
|
|
17
|
+
'decrementAriaLabel',
|
|
18
|
+
];
|
|
19
|
+
const Minus = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M6 12h12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }));
|
|
20
|
+
const Plus = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M12 6v12M6 12h12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }));
|
|
21
|
+
function StepButton({ children, ...props }) {
|
|
22
|
+
const ref = useRef(null);
|
|
23
|
+
const { buttonProps } = useButton(props, ref);
|
|
24
|
+
return (_jsx("button", { ...buttonProps, ref: ref, className: "ion-number-input__step", children: children }));
|
|
25
|
+
}
|
|
26
|
+
const toHook = (v) => (v === null ? NaN : v);
|
|
27
|
+
/**
|
|
28
|
+
* NumberInput — a quantity, with formatting, bounds and steps.
|
|
29
|
+
*
|
|
30
|
+
* NOT `<input type="number">`, and the list of reasons is the component:
|
|
31
|
+
*
|
|
32
|
+
* It scrolls. A focused `type="number"` changes value under the mouse wheel,
|
|
33
|
+
* so a user scrolling the page past a price field edits the price. The wheel
|
|
34
|
+
* is OFF here by default (`isWheelDisabled`), and a caller has to ask for it.
|
|
35
|
+
*
|
|
36
|
+
* It cannot format. "1,234.50", "€12", "15%" are text to the browser's number
|
|
37
|
+
* input, which rejects them. `formatOptions` takes `Intl.NumberFormatOptions`,
|
|
38
|
+
* so currency, percent and units display and parse in the user's locale —
|
|
39
|
+
* including "1.234,50" for a German user.
|
|
40
|
+
*
|
|
41
|
+
* It is not a number to the browser's validation either. `type="text"` with
|
|
42
|
+
* the right `inputMode` gets the numeric keyboard on a phone without
|
|
43
|
+
* Firefox letting letters in and Chrome silently reporting an empty value.
|
|
44
|
+
*
|
|
45
|
+
* EMPTY IS `null`, NOT `NaN`. React Aria reports an empty field as `NaN`, and
|
|
46
|
+
* `NaN === NaN` is false — so every "is it empty" check a caller writes is
|
|
47
|
+
* wrong. This converts at the boundary, both ways.
|
|
48
|
+
*
|
|
49
|
+
* − AND + SIT SIDE BY SIDE, NOT STACKED. Stacked chevrons split the field's
|
|
50
|
+
* height in two, which puts a Small field's targets at 16px — under the 24px
|
|
51
|
+
* WCAG 2.5.8 asks. Side by side, every size clears it. They are out of the tab
|
|
52
|
+
* order, as React Aria sets them: the arrow keys do the same job from the field,
|
|
53
|
+
* and two extra tab stops per number on a form is a tax on every keyboard user.
|
|
54
|
+
*
|
|
55
|
+
* The box is Input's, class for class, so every state — hover, focus, invalid,
|
|
56
|
+
* read-only, disabled — is Input's and cannot drift from it.
|
|
57
|
+
*/
|
|
58
|
+
export const NumberInput = forwardRef((props, forwardedRef) => {
|
|
59
|
+
const { size = 'md', showStepper = true, isWheelDisabled = true, value, defaultValue, onChange, label, description, errorMessage, isDisabled, isReadOnly, className, wrapperClassName, ...rest } = props;
|
|
60
|
+
const { locale } = useLocale();
|
|
61
|
+
const hookProps = {
|
|
62
|
+
...props,
|
|
63
|
+
isWheelDisabled,
|
|
64
|
+
value: value === undefined ? undefined : toHook(value),
|
|
65
|
+
defaultValue: defaultValue === undefined ? undefined : toHook(defaultValue),
|
|
66
|
+
onChange: onChange
|
|
67
|
+
? (n) => onChange(Number.isNaN(n) ? null : n)
|
|
68
|
+
: undefined,
|
|
69
|
+
};
|
|
70
|
+
const state = useNumberFieldState({ ...hookProps, locale });
|
|
71
|
+
const ref = useRef(null);
|
|
72
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
73
|
+
const { labelProps, groupProps, inputProps, incrementButtonProps, decrementButtonProps, descriptionProps, errorMessageProps, isInvalid, } = useNumberField(hookProps, state, ref);
|
|
74
|
+
const { hoverProps, isHovered } = useHover({ isDisabled });
|
|
75
|
+
const { focusProps, isFocusVisible } = useFocusRing({ isTextInput: true });
|
|
76
|
+
const domProps = omitProps(rest, NUMBER_FIELD_NON_DOM_PROPS);
|
|
77
|
+
const box = (_jsxs("div", { ...mergeProps(groupProps, hoverProps), "data-hovered": isHovered || undefined, "data-focused": isFocusVisible || undefined, "data-invalid": isInvalid || undefined, "data-readonly": isReadOnly || undefined, "data-disabled": isDisabled || undefined, className: [
|
|
78
|
+
'ion-input',
|
|
79
|
+
'ion-number-input',
|
|
80
|
+
size !== 'md' ? `ion-input--${size}` : '',
|
|
81
|
+
showStepper ? 'ion-number-input--stepper' : '',
|
|
82
|
+
isInvalid ? 'ion-input--invalid' : '',
|
|
83
|
+
isReadOnly ? 'ion-input--readonly' : '',
|
|
84
|
+
isDisabled ? 'ion-input--disabled' : '',
|
|
85
|
+
className || '',
|
|
86
|
+
]
|
|
87
|
+
.filter(Boolean)
|
|
88
|
+
.join(' '), children: [_jsx("input", { ...domProps, ...mergeProps(inputProps, focusProps), ref: ref, className: "ion-input__field ion-number-input__field" }), showStepper && (_jsxs("span", { className: "ion-number-input__steps", children: [_jsx(StepButton, { ...decrementButtonProps, children: _jsx(Minus, {}) }), _jsx(StepButton, { ...incrementButtonProps, children: _jsx(Plus, {}) })] }))] }));
|
|
89
|
+
const helper = isInvalid && errorMessage ? errorMessage : description;
|
|
90
|
+
const helperProps = isInvalid && errorMessage ? errorMessageProps : descriptionProps;
|
|
91
|
+
if (!label && !helper)
|
|
92
|
+
return box;
|
|
93
|
+
return (_jsxs("div", { className: [
|
|
94
|
+
'ion-field',
|
|
95
|
+
isInvalid ? 'ion-field--error' : '',
|
|
96
|
+
wrapperClassName || '',
|
|
97
|
+
]
|
|
98
|
+
.filter(Boolean)
|
|
99
|
+
.join(' '), children: [label && (_jsx("label", { ...labelProps, className: "ion-field__label", children: label })), box, helper && (_jsx("span", { ...helperProps, className: "ion-field__helper", children: helper }))] }));
|
|
100
|
+
});
|
|
101
|
+
NumberInput.displayName = 'NumberInput';
|
|
102
|
+
//# sourceMappingURL=NumberInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberInput.js","sourceRoot":"","sources":["../../src/components/NumberInput.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA+C1E,sFAAsF;AACtF,MAAM,0BAA0B,GAAG;IACjC,GAAG,6BAA6B;IAChC,UAAU;IACV,UAAU;IACV,MAAM;IACN,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,oBAAoB;IACpB,oBAAoB;CACZ,CAAC;AAEX,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,CAClB,cAAK,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,YACvE,eACE,CAAC,EAAC,UAAU,EACZ,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,GACrB,GACE,CACP,CAAC;AAEF,MAAM,IAAI,GAAG,GAAG,EAAE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AAK,IAAI,CACR,mBAAW,UAAU,EAAE,SAAS,EAAC,kBAAkB,YAChD,KAAK,GACA,CACT,EACA,GAAG,EACH,MAAM,IAAI,CACT,kBAAU,WAAW,EAAE,SAAS,EAAC,mBAAmB,YACjD,MAAyB,GACrB,CACR,IACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,WAAW,CAAC,WAAW,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type ProgressBarIntent = 'primary' | 'success' | 'warning' | 'error';
|
|
3
|
+
export type ProgressBarSize = 'sm' | 'md';
|
|
4
|
+
export interface ProgressBarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
5
|
+
/** What is progressing. Required — a bare bar announces a number and no noun. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** 0 to `max`. Omit for an indeterminate bar. */
|
|
8
|
+
value?: number;
|
|
9
|
+
/** Defaults to 100. */
|
|
10
|
+
max?: number;
|
|
11
|
+
intent?: ProgressBarIntent;
|
|
12
|
+
size?: ProgressBarSize;
|
|
13
|
+
/** Show the label as text above the track. */
|
|
14
|
+
isLabelVisible?: boolean;
|
|
15
|
+
/** Show the percentage beside the label. Determinate bars only. */
|
|
16
|
+
isValueVisible?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Spoken instead of the percentage — "3 of 12 files". A percentage is rarely
|
|
19
|
+
* the thing a person wants read aloud.
|
|
20
|
+
*/
|
|
21
|
+
valueText?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* ProgressBar — a determinate or indeterminate measure of work.
|
|
25
|
+
*
|
|
26
|
+
* DETERMINATE AND INDETERMINATE ARE THE SAME COMPONENT ON PURPOSE
|
|
27
|
+
*
|
|
28
|
+
* Work that starts unmeasurable and becomes measurable is the common case — a
|
|
29
|
+
* upload that does not know its size until the first chunk lands. Splitting
|
|
30
|
+
* them into two components would make that transition a swap, which remounts
|
|
31
|
+
* the node and loses the live region with it.
|
|
32
|
+
*
|
|
33
|
+
* Omitting `value` is what makes it indeterminate. `aria-valuenow` is then
|
|
34
|
+
* omitted too, which is exactly what the ARIA spec asks for and is the detail
|
|
35
|
+
* hand-rolled progress bars get wrong most often — a bar reporting
|
|
36
|
+
* `aria-valuenow="0"` forever tells a screen reader the work is stuck at zero,
|
|
37
|
+
* not that it is unmeasured.
|
|
38
|
+
*
|
|
39
|
+
* WHY `label` IS REQUIRED
|
|
40
|
+
*
|
|
41
|
+
* `role="progressbar"` announces a number. Without a name the user hears "42
|
|
42
|
+
* percent" with no indication of what is at 42 percent, which is worse than
|
|
43
|
+
* silence because it sounds like information.
|
|
44
|
+
*/
|
|
45
|
+
export declare const ProgressBar: React.ForwardRefExoticComponent<ProgressBarProps & React.RefAttributes<HTMLDivElement>>;
|
|
46
|
+
//# sourceMappingURL=ProgressBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["../../src/components/ProgressBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAC5E,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1C,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EACpC,UAAU,CACX;IACC,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,8CAA8C;IAC9C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mEAAmE;IACnE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,yFA6EvB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId } from 'react';
|
|
3
|
+
const clamp = (n, max) => Math.min(Math.max(n, 0), max);
|
|
4
|
+
/**
|
|
5
|
+
* ProgressBar — a determinate or indeterminate measure of work.
|
|
6
|
+
*
|
|
7
|
+
* DETERMINATE AND INDETERMINATE ARE THE SAME COMPONENT ON PURPOSE
|
|
8
|
+
*
|
|
9
|
+
* Work that starts unmeasurable and becomes measurable is the common case — a
|
|
10
|
+
* upload that does not know its size until the first chunk lands. Splitting
|
|
11
|
+
* them into two components would make that transition a swap, which remounts
|
|
12
|
+
* the node and loses the live region with it.
|
|
13
|
+
*
|
|
14
|
+
* Omitting `value` is what makes it indeterminate. `aria-valuenow` is then
|
|
15
|
+
* omitted too, which is exactly what the ARIA spec asks for and is the detail
|
|
16
|
+
* hand-rolled progress bars get wrong most often — a bar reporting
|
|
17
|
+
* `aria-valuenow="0"` forever tells a screen reader the work is stuck at zero,
|
|
18
|
+
* not that it is unmeasured.
|
|
19
|
+
*
|
|
20
|
+
* WHY `label` IS REQUIRED
|
|
21
|
+
*
|
|
22
|
+
* `role="progressbar"` announces a number. Without a name the user hears "42
|
|
23
|
+
* percent" with no indication of what is at 42 percent, which is worse than
|
|
24
|
+
* silence because it sounds like information.
|
|
25
|
+
*/
|
|
26
|
+
export const ProgressBar = forwardRef(({ label, value, max = 100, intent = 'primary', size = 'md', isLabelVisible = false, isValueVisible = false, valueText, className, ...rest }, ref) => {
|
|
27
|
+
const labelId = useId();
|
|
28
|
+
const isIndeterminate = value === undefined;
|
|
29
|
+
const resolved = isIndeterminate ? 0 : clamp(value, max);
|
|
30
|
+
const pct = max > 0 ? (resolved / max) * 100 : 0;
|
|
31
|
+
const classNames = [
|
|
32
|
+
'ion-progress-bar',
|
|
33
|
+
intent !== 'primary' ? `ion-progress-bar--${intent}` : '',
|
|
34
|
+
size !== 'md' ? `ion-progress-bar--${size}` : '',
|
|
35
|
+
isIndeterminate ? 'ion-progress-bar--indeterminate' : '',
|
|
36
|
+
className || '',
|
|
37
|
+
]
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
.join(' ');
|
|
40
|
+
return (_jsxs("div", { ...rest, ref: ref, className: classNames, children: [_jsxs("div", { className: isLabelVisible ? 'ion-progress-bar__header' : 'ion-visually-hidden', children: [_jsx("span", { id: labelId, className: "ion-progress-bar__label", children: label }), isLabelVisible && isValueVisible && !isIndeterminate && (_jsx("span", { className: "ion-progress-bar__value", children: valueText ?? `${Math.round(pct)}%` }))] }), _jsx("div", { className: "ion-progress-bar__track", role: "progressbar", "aria-labelledby": labelId, "aria-valuemin": 0, "aria-valuemax": max, ...(isIndeterminate
|
|
41
|
+
? {}
|
|
42
|
+
: {
|
|
43
|
+
'aria-valuenow': resolved,
|
|
44
|
+
...(valueText ? { 'aria-valuetext': valueText } : {}),
|
|
45
|
+
}), children: _jsx("div", { className: "ion-progress-bar__fill", style: isIndeterminate
|
|
46
|
+
? undefined
|
|
47
|
+
: {
|
|
48
|
+
'--ion-progress-bar-pct': `${pct}%`,
|
|
49
|
+
} }) })] }));
|
|
50
|
+
});
|
|
51
|
+
ProgressBar.displayName = 'ProgressBar';
|
|
52
|
+
//# sourceMappingURL=ProgressBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","sourceRoot":"","sources":["../../src/components/ProgressBar.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AA4BjD,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,GAAW,EAAE,EAAE,CAAC,IAA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