@calcifer-design/ui 0.3.0 → 0.5.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/Breadcrumb/Breadcrumb.d.ts +24 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +48 -0
- package/dist/components/Breadcrumb/Breadcrumb.module.js +10 -0
- package/dist/components/Breadcrumb/Breadcrumb_module.css +49 -0
- package/dist/components/CardList/CardList.d.ts +30 -0
- package/dist/components/CardList/CardList.js +35 -0
- package/dist/components/CardList/CardList.module.js +7 -0
- package/dist/components/CardList/CardList_module.css +20 -0
- package/dist/components/Checkbox/Checkbox.d.ts +23 -0
- package/dist/components/Checkbox/Checkbox.js +33 -0
- package/dist/components/Checkbox/Checkbox.module.js +6 -0
- package/dist/components/Checkbox/Checkbox_module.css +16 -0
- package/dist/components/DatePicker/Calendar.d.ts +19 -0
- package/dist/components/DatePicker/Calendar.js +207 -0
- package/dist/components/DatePicker/DatePicker.d.ts +72 -0
- package/dist/components/DatePicker/DatePicker.js +116 -0
- package/dist/components/DatePicker/DatePicker.module.js +14 -0
- package/dist/components/DatePicker/DatePicker_module.css +112 -0
- package/dist/components/DatePicker/calendarDate.d.ts +46 -0
- package/dist/components/DatePicker/calendarDate.js +117 -0
- package/dist/components/Descriptions/Descriptions.d.ts +25 -0
- package/dist/components/Descriptions/Descriptions.js +44 -0
- package/dist/components/Descriptions/Descriptions.module.js +8 -0
- package/dist/components/Descriptions/Descriptions_module.css +47 -0
- package/dist/components/Field/Field.d.ts +118 -0
- package/dist/components/Field/Field.js +90 -0
- package/dist/components/Field/PickerField.d.ts +41 -0
- package/dist/components/Field/PickerField.js +115 -0
- package/dist/components/Field/PickerField.module.js +8 -0
- package/dist/components/Field/PickerField_module.css +36 -0
- package/dist/components/FilterBar/FilterBar.d.ts +55 -0
- package/dist/components/FilterBar/FilterBar.js +138 -0
- package/dist/components/FilterBar/FilterBar.module.js +13 -0
- package/dist/components/FilterBar/FilterBar_module.css +98 -0
- package/dist/components/Form/Form.d.ts +48 -0
- package/dist/components/Form/Form.js +38 -0
- package/dist/components/Form/Form.module.js +5 -0
- package/dist/components/Form/FormContext.d.ts +15 -0
- package/dist/components/Form/FormContext.js +20 -0
- package/dist/components/Form/Form_module.css +6 -0
- package/dist/components/PageShell/PageShell.d.ts +27 -0
- package/dist/components/PageShell/PageShell.js +35 -0
- package/dist/components/PageShell/PageShell.module.js +9 -0
- package/dist/components/PageShell/PageShell_module.css +56 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +35 -0
- package/dist/components/RadioGroup/RadioGroup.js +64 -0
- package/dist/components/RadioGroup/RadioGroup.module.js +6 -0
- package/dist/components/RadioGroup/RadioGroup_module.css +13 -0
- package/dist/components/Segmented/Segmented.d.ts +49 -0
- package/dist/components/Segmented/Segmented.js +55 -0
- package/dist/components/Segmented/Segmented.module.js +7 -0
- package/dist/components/Segmented/Segmented_module.css +75 -0
- package/dist/components/Select/Select.d.ts +42 -0
- package/dist/components/Select/Select.js +90 -0
- package/dist/components/Select/Select.module.js +9 -0
- package/dist/components/Select/Select_module.css +70 -0
- package/dist/components/Steps/Steps.d.ts +30 -0
- package/dist/components/Steps/Steps.js +63 -0
- package/dist/components/Steps/Steps.module.js +10 -0
- package/dist/components/Steps/Steps_module.css +126 -0
- package/dist/components/Switch/Switch.d.ts +23 -0
- package/dist/components/Switch/Switch.js +25 -0
- package/dist/components/Switch/Switch.module.js +6 -0
- package/dist/components/Switch/Switch_module.css +41 -0
- package/dist/components/TextArea/TextArea.d.ts +16 -0
- package/dist/components/TextArea/TextArea.js +28 -0
- package/dist/components/TextArea/TextArea.module.js +5 -0
- package/dist/components/TextArea/TextArea_module.css +12 -0
- package/dist/components/TextInput/TextInput.d.ts +17 -0
- package/dist/components/TextInput/TextInput.js +18 -0
- package/dist/components/TimePicker/TimePicker.d.ts +19 -0
- package/dist/components/TimePicker/TimePicker.js +17 -0
- package/dist/components/Timeline/Timeline.d.ts +39 -0
- package/dist/components/Timeline/Timeline.js +109 -0
- package/dist/components/Timeline/Timeline.module.js +12 -0
- package/dist/components/Timeline/Timeline_module.css +99 -0
- package/dist/components/Toolbar/InsideToolbarContext.d.ts +6 -0
- package/dist/components/Toolbar/InsideToolbarContext.js +3 -0
- package/dist/components/Toolbar/Toolbar.d.ts +46 -0
- package/dist/components/Toolbar/Toolbar.js +43 -0
- package/dist/components/Toolbar/Toolbar.module.js +7 -0
- package/dist/components/Toolbar/Toolbar_module.css +26 -0
- package/dist/components/Tree/Tree.d.ts +81 -0
- package/dist/components/Tree/Tree.js +232 -0
- package/dist/components/Tree/Tree.module.js +12 -0
- package/dist/components/Tree/Tree_module.css +124 -0
- package/dist/components/Tree/treeIndex.d.ts +23 -0
- package/dist/components/Tree/treeIndex.js +33 -0
- package/dist/components/TreeSelect/TreeSelect.d.ts +61 -0
- package/dist/components/TreeSelect/TreeSelect.js +117 -0
- package/dist/components/TreeSelect/TreeSelect.module.js +7 -0
- package/dist/components/TreeSelect/TreeSelect_module.css +22 -0
- package/dist/components/Upload/Upload.d.ts +66 -0
- package/dist/components/Upload/Upload.js +287 -0
- package/dist/components/Upload/Upload.module.js +12 -0
- package/dist/components/Upload/Upload_module.css +96 -0
- package/dist/components/ViewField/ViewField.d.ts +26 -0
- package/dist/components/ViewField/ViewField.js +29 -0
- package/dist/components/ViewField/ViewField.module.js +6 -0
- package/dist/components/ViewField/ViewField_module.css +17 -0
- package/dist/hooks/useFormReset.d.ts +10 -0
- package/dist/hooks/useFormReset.js +34 -0
- package/dist/icons/CalendarIcon.d.ts +2 -0
- package/dist/icons/CalendarIcon.js +26 -0
- package/dist/icons/CheckIcon.d.ts +6 -0
- package/dist/icons/CheckIcon.js +17 -0
- package/dist/icons/ChevronDownIcon.d.ts +6 -0
- package/dist/icons/ChevronDownIcon.js +17 -0
- package/dist/icons/MinusIcon.d.ts +5 -0
- package/dist/icons/MinusIcon.js +16 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +23 -0
- package/dist/styles/field.module.js +15 -0
- package/dist/styles/field_module.css +133 -0
- package/dist/styles/pair.module.js +6 -0
- package/dist/styles/pair_module.css +18 -0
- package/dist/styles/popup_module.css +6 -0
- package/package.json +2 -2
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Field } from "@base-ui/react/field";
|
|
3
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
import { useFormReset } from "../../hooks/useFormReset.js";
|
|
5
|
+
import { CloseIcon } from "../../icons/CloseIcon.js";
|
|
6
|
+
import field_module from "../../styles/field.module.js";
|
|
7
|
+
import { Button } from "../Button/Button.js";
|
|
8
|
+
import { FieldMessages, RequiredMark } from "../Field/Field.js";
|
|
9
|
+
import { useFormValue } from "../Form/FormContext.js";
|
|
10
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
11
|
+
import { LiveRegion } from "../LiveRegion/LiveRegion.js";
|
|
12
|
+
import Upload_module from "./Upload.module.js";
|
|
13
|
+
const REJECTION_REASONS = {
|
|
14
|
+
type: 'that type of file is not allowed',
|
|
15
|
+
size: 'it is too large',
|
|
16
|
+
count: 'only one file can be chosen',
|
|
17
|
+
duplicate: 'it is already in the list'
|
|
18
|
+
};
|
|
19
|
+
const DEFAULT_LABELS = {
|
|
20
|
+
remove: (fileName)=>`Remove ${fileName}`,
|
|
21
|
+
added: (fileNames)=>`Added ${fileNames}.`,
|
|
22
|
+
removed: (fileName)=>`Removed ${fileName}.`,
|
|
23
|
+
rejected: (fileName, reason)=>`${fileName} was not added: ${REJECTION_REASONS[reason]}.`
|
|
24
|
+
};
|
|
25
|
+
function acceptsFile(file, accept) {
|
|
26
|
+
const tokens = (accept ?? '').split(',').map((token)=>token.trim().toLowerCase()).filter(Boolean);
|
|
27
|
+
if (0 === tokens.length) return true;
|
|
28
|
+
const fileName = file.name.toLowerCase();
|
|
29
|
+
const fileType = file.type.toLowerCase();
|
|
30
|
+
return tokens.some((token)=>{
|
|
31
|
+
if (token.startsWith('.')) return fileName.endsWith(token);
|
|
32
|
+
if ('*/*' === token) return true;
|
|
33
|
+
if (token.endsWith('/*')) return fileType.startsWith(token.slice(0, -1));
|
|
34
|
+
return fileType === token;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function signatureOf(file) {
|
|
38
|
+
return [
|
|
39
|
+
file.name,
|
|
40
|
+
file.size,
|
|
41
|
+
file.lastModified
|
|
42
|
+
].join(':');
|
|
43
|
+
}
|
|
44
|
+
function signaturesOf(files) {
|
|
45
|
+
return files.map(signatureOf).join('|');
|
|
46
|
+
}
|
|
47
|
+
function withoutPartners(list, other) {
|
|
48
|
+
const unmatched = other.map(signatureOf);
|
|
49
|
+
return list.filter((file)=>{
|
|
50
|
+
const partner = unmatched.indexOf(signatureOf(file));
|
|
51
|
+
if (-1 === partner) return true;
|
|
52
|
+
unmatched.splice(partner, 1);
|
|
53
|
+
return false;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function carriesFiles(event) {
|
|
57
|
+
return Array.from(event.dataTransfer.types ?? []).includes('Files');
|
|
58
|
+
}
|
|
59
|
+
function Upload({ label, name, description, error, required = false, disabled = false, files, defaultFiles, onFilesChange, accept, multiple = false, maxSizeBytes, onReject, onBlur, labels }) {
|
|
60
|
+
const inputRef = useRef(null);
|
|
61
|
+
const listRef = useRef(null);
|
|
62
|
+
const focusAfterRemoval = useRef(null);
|
|
63
|
+
const announcedFiles = useRef(files ?? defaultFiles ?? []);
|
|
64
|
+
const turnedAwayThisCommit = useRef('');
|
|
65
|
+
const [heldFiles, setHeldFiles] = useState(defaultFiles ?? []);
|
|
66
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
67
|
+
const [rejectionMessages, setRejectionMessages] = useState([]);
|
|
68
|
+
const [announcement, setAnnouncement] = useState({
|
|
69
|
+
message: '',
|
|
70
|
+
count: 0
|
|
71
|
+
});
|
|
72
|
+
const currentFiles = files ?? heldFiles;
|
|
73
|
+
const words = {
|
|
74
|
+
...DEFAULT_LABELS,
|
|
75
|
+
choose: multiple ? 'Choose files' : 'Choose a file',
|
|
76
|
+
dropHint: multiple ? 'or drop them here' : 'or drop it here',
|
|
77
|
+
...labels
|
|
78
|
+
};
|
|
79
|
+
useFormValue(disabled ? void 0 : name, currentFiles);
|
|
80
|
+
const announce = (message)=>setAnnouncement((previous)=>({
|
|
81
|
+
message,
|
|
82
|
+
count: previous.count + 1
|
|
83
|
+
}));
|
|
84
|
+
const showInInput = (list)=>{
|
|
85
|
+
if (null === inputRef.current || "u" < typeof DataTransfer) return;
|
|
86
|
+
const transfer = new DataTransfer();
|
|
87
|
+
list.forEach((file)=>transfer.items.add(file));
|
|
88
|
+
inputRef.current.files = transfer.files;
|
|
89
|
+
};
|
|
90
|
+
useLayoutEffect(()=>{
|
|
91
|
+
showInInput(currentFiles);
|
|
92
|
+
}, [
|
|
93
|
+
currentFiles
|
|
94
|
+
]);
|
|
95
|
+
useLayoutEffect(()=>{
|
|
96
|
+
if (null === focusAfterRemoval.current) return;
|
|
97
|
+
const buttons = listRef.current?.querySelectorAll('button') ?? [];
|
|
98
|
+
const target = buttons[Math.min(focusAfterRemoval.current, buttons.length - 1)];
|
|
99
|
+
(target ?? inputRef.current)?.focus();
|
|
100
|
+
focusAfterRemoval.current = null;
|
|
101
|
+
});
|
|
102
|
+
useLayoutEffect(()=>{
|
|
103
|
+
const addedNames = withoutPartners(currentFiles, announcedFiles.current).map((file)=>file.name).join(', ');
|
|
104
|
+
const changes = [
|
|
105
|
+
'' === addedNames ? null : words.added(addedNames),
|
|
106
|
+
...withoutPartners(announcedFiles.current, currentFiles).map((file)=>words.removed(file.name))
|
|
107
|
+
].filter(Boolean);
|
|
108
|
+
announcedFiles.current = currentFiles;
|
|
109
|
+
if (changes.length > 0) announce([
|
|
110
|
+
...changes,
|
|
111
|
+
turnedAwayThisCommit.current
|
|
112
|
+
].filter(Boolean).join(' '));
|
|
113
|
+
turnedAwayThisCommit.current = '';
|
|
114
|
+
});
|
|
115
|
+
const commit = (nextFiles)=>{
|
|
116
|
+
if (signaturesOf(nextFiles) !== signaturesOf(currentFiles)) {
|
|
117
|
+
setHeldFiles(nextFiles);
|
|
118
|
+
onFilesChange?.(nextFiles);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const receive = (incoming)=>{
|
|
122
|
+
if (0 === incoming.length) return;
|
|
123
|
+
const rejections = [];
|
|
124
|
+
const accepted = [];
|
|
125
|
+
const known = new Set(multiple ? currentFiles.map(signatureOf) : []);
|
|
126
|
+
for (const file of incoming)if (acceptsFile(file, accept)) if (void 0 !== maxSizeBytes && file.size > maxSizeBytes) rejections.push({
|
|
127
|
+
file,
|
|
128
|
+
reason: 'size'
|
|
129
|
+
});
|
|
130
|
+
else if (!multiple && accepted.length > 0) rejections.push({
|
|
131
|
+
file,
|
|
132
|
+
reason: 'count'
|
|
133
|
+
});
|
|
134
|
+
else if (known.has(signatureOf(file))) rejections.push({
|
|
135
|
+
file,
|
|
136
|
+
reason: 'duplicate'
|
|
137
|
+
});
|
|
138
|
+
else {
|
|
139
|
+
known.add(signatureOf(file));
|
|
140
|
+
accepted.push(file);
|
|
141
|
+
}
|
|
142
|
+
else rejections.push({
|
|
143
|
+
file,
|
|
144
|
+
reason: 'type'
|
|
145
|
+
});
|
|
146
|
+
if (accepted.length > 0) commit(multiple ? [
|
|
147
|
+
...currentFiles,
|
|
148
|
+
...accepted
|
|
149
|
+
] : accepted);
|
|
150
|
+
const messages = rejections.map(({ file, reason })=>words.rejected(file.name, reason));
|
|
151
|
+
setRejectionMessages(messages);
|
|
152
|
+
if (rejections.length > 0) {
|
|
153
|
+
onReject?.(rejections);
|
|
154
|
+
turnedAwayThisCommit.current = messages.join(' ');
|
|
155
|
+
announce(turnedAwayThisCommit.current);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
useFormReset(inputRef, ()=>{
|
|
159
|
+
const restored = files ?? defaultFiles ?? [];
|
|
160
|
+
setRejectionMessages([]);
|
|
161
|
+
commit(restored);
|
|
162
|
+
showInInput(restored);
|
|
163
|
+
});
|
|
164
|
+
const remove = (index)=>{
|
|
165
|
+
focusAfterRemoval.current = index;
|
|
166
|
+
setRejectionMessages([]);
|
|
167
|
+
commit(currentFiles.filter((_file, fileIndex)=>fileIndex !== index));
|
|
168
|
+
};
|
|
169
|
+
return /*#__PURE__*/ jsxs(Field.Root, {
|
|
170
|
+
className: field_module.frame,
|
|
171
|
+
name: name,
|
|
172
|
+
disabled: disabled,
|
|
173
|
+
invalid: void 0 !== error,
|
|
174
|
+
children: [
|
|
175
|
+
/*#__PURE__*/ jsxs(Field.Label, {
|
|
176
|
+
className: field_module.label,
|
|
177
|
+
children: [
|
|
178
|
+
label,
|
|
179
|
+
/*#__PURE__*/ jsx(RequiredMark, {
|
|
180
|
+
when: required
|
|
181
|
+
})
|
|
182
|
+
]
|
|
183
|
+
}),
|
|
184
|
+
/*#__PURE__*/ jsxs("div", {
|
|
185
|
+
className: Upload_module.zone,
|
|
186
|
+
"data-dragging": isDragging ? '' : void 0,
|
|
187
|
+
"data-disabled": disabled ? '' : void 0,
|
|
188
|
+
onDragOver: (event)=>{
|
|
189
|
+
if (!carriesFiles(event)) return;
|
|
190
|
+
event.preventDefault();
|
|
191
|
+
event.dataTransfer.dropEffect = disabled ? 'none' : 'copy';
|
|
192
|
+
setIsDragging(!disabled);
|
|
193
|
+
},
|
|
194
|
+
onDragLeave: (event)=>{
|
|
195
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setIsDragging(false);
|
|
196
|
+
},
|
|
197
|
+
onDrop: (event)=>{
|
|
198
|
+
if (!carriesFiles(event)) return;
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
setIsDragging(false);
|
|
201
|
+
if (!disabled) receive(Array.from(event.dataTransfer.files));
|
|
202
|
+
},
|
|
203
|
+
children: [
|
|
204
|
+
/*#__PURE__*/ jsx(Field.Control, {
|
|
205
|
+
ref: inputRef,
|
|
206
|
+
className: Upload_module.input,
|
|
207
|
+
value: signaturesOf(currentFiles),
|
|
208
|
+
onBlur: onBlur,
|
|
209
|
+
required: required && 0 === currentFiles.length,
|
|
210
|
+
onChange: (event)=>{
|
|
211
|
+
const picked = Array.from(event.currentTarget.files ?? []);
|
|
212
|
+
event.currentTarget.value = '';
|
|
213
|
+
showInInput(currentFiles);
|
|
214
|
+
receive(picked);
|
|
215
|
+
},
|
|
216
|
+
render: (controlProps)=>{
|
|
217
|
+
const { value: _signature, ...inputProps } = controlProps;
|
|
218
|
+
return /*#__PURE__*/ jsx("input", {
|
|
219
|
+
...inputProps,
|
|
220
|
+
type: "file",
|
|
221
|
+
accept: accept,
|
|
222
|
+
multiple: multiple,
|
|
223
|
+
title: ""
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}),
|
|
227
|
+
/*#__PURE__*/ jsxs("div", {
|
|
228
|
+
className: [
|
|
229
|
+
field_module.control,
|
|
230
|
+
Upload_module.face
|
|
231
|
+
].join(' '),
|
|
232
|
+
"aria-hidden": "true",
|
|
233
|
+
children: [
|
|
234
|
+
/*#__PURE__*/ jsx(Button, {
|
|
235
|
+
variant: "secondary",
|
|
236
|
+
size: "sm",
|
|
237
|
+
tabIndex: -1,
|
|
238
|
+
disabled: disabled,
|
|
239
|
+
children: words.choose
|
|
240
|
+
}),
|
|
241
|
+
/*#__PURE__*/ jsx("span", {
|
|
242
|
+
className: Upload_module.hint,
|
|
243
|
+
children: words.dropHint
|
|
244
|
+
})
|
|
245
|
+
]
|
|
246
|
+
})
|
|
247
|
+
]
|
|
248
|
+
}),
|
|
249
|
+
0 === currentFiles.length ? null : /*#__PURE__*/ jsx("ul", {
|
|
250
|
+
ref: listRef,
|
|
251
|
+
className: Upload_module.list,
|
|
252
|
+
role: "list",
|
|
253
|
+
children: currentFiles.map((file, index)=>/*#__PURE__*/ jsxs("li", {
|
|
254
|
+
className: Upload_module.file,
|
|
255
|
+
children: [
|
|
256
|
+
/*#__PURE__*/ jsx("span", {
|
|
257
|
+
className: Upload_module.fileName,
|
|
258
|
+
children: file.name
|
|
259
|
+
}),
|
|
260
|
+
/*#__PURE__*/ jsx(IconButton, {
|
|
261
|
+
size: "sm",
|
|
262
|
+
label: words.remove(file.name),
|
|
263
|
+
disabled: disabled,
|
|
264
|
+
onClick: ()=>remove(index),
|
|
265
|
+
children: /*#__PURE__*/ jsx(CloseIcon, {})
|
|
266
|
+
})
|
|
267
|
+
]
|
|
268
|
+
}, `${signatureOf(file)}-${index}`))
|
|
269
|
+
}),
|
|
270
|
+
rejectionMessages.map((message, index)=>/*#__PURE__*/ jsx("p", {
|
|
271
|
+
className: [
|
|
272
|
+
field_module.error,
|
|
273
|
+
Upload_module.rejection
|
|
274
|
+
].join(' '),
|
|
275
|
+
children: message
|
|
276
|
+
}, index)),
|
|
277
|
+
/*#__PURE__*/ jsx(FieldMessages, {
|
|
278
|
+
description: description,
|
|
279
|
+
error: error
|
|
280
|
+
}),
|
|
281
|
+
/*#__PURE__*/ jsx(LiveRegion, {
|
|
282
|
+
message: `${announcement.message}${announcement.count % 2 ? ' ' : ''}`
|
|
283
|
+
})
|
|
284
|
+
]
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
export { Upload };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "./Upload_module.css";
|
|
2
|
+
const Upload_module = {
|
|
3
|
+
zone: "zone-ZaTfF",
|
|
4
|
+
input: "input-nfdVe",
|
|
5
|
+
face: "face-ZjTYq",
|
|
6
|
+
hint: "hint-UVfUW",
|
|
7
|
+
list: "list-jDElN",
|
|
8
|
+
file: "file-Ui1KG",
|
|
9
|
+
fileName: "fileName-CHIc8",
|
|
10
|
+
rejection: "rejection-mI7_p"
|
|
11
|
+
};
|
|
12
|
+
export default Upload_module;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
.zone-ZaTfF {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.input-nfdVe {
|
|
6
|
+
opacity: 0;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
position: absolute;
|
|
11
|
+
inset: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.input-nfdVe::file-selector-button {
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.input-nfdVe:disabled {
|
|
19
|
+
cursor: not-allowed;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.input-nfdVe:disabled::file-selector-button {
|
|
23
|
+
cursor: not-allowed;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.zone-ZaTfF .face-ZjTYq {
|
|
27
|
+
gap: var(--space-3);
|
|
28
|
+
padding: var(--space-4);
|
|
29
|
+
border-style: dashed;
|
|
30
|
+
flex-wrap: wrap;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.hint-UVfUW {
|
|
34
|
+
color: var(--color-text-muted);
|
|
35
|
+
font-size: var(--text-sm);
|
|
36
|
+
line-height: var(--leading-snug);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.input-nfdVe:focus-visible + .face-ZjTYq {
|
|
40
|
+
border-color: var(--color-accent);
|
|
41
|
+
outline: var(--focus-ring-width) solid var(--color-focus);
|
|
42
|
+
outline-offset: var(--focus-ring-offset);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@media (hover: hover) {
|
|
46
|
+
.zone-ZaTfF:not([data-disabled]):hover .face-ZjTYq {
|
|
47
|
+
background: var(--color-surface-2);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.zone-ZaTfF[data-dragging] .face-ZjTYq {
|
|
52
|
+
border-style: solid;
|
|
53
|
+
border-color: var(--color-accent);
|
|
54
|
+
background: var(--color-accent-wash);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.input-nfdVe[data-invalid] + .face-ZjTYq {
|
|
58
|
+
border-color: var(--color-danger-border);
|
|
59
|
+
background: var(--color-danger-surface);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.zone-ZaTfF[data-disabled] .face-ZjTYq {
|
|
63
|
+
opacity: .55;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.list-jDElN {
|
|
67
|
+
gap: var(--space-1);
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
margin: 0;
|
|
70
|
+
padding: 0;
|
|
71
|
+
list-style: none;
|
|
72
|
+
display: flex;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.file-Ui1KG {
|
|
76
|
+
justify-content: space-between;
|
|
77
|
+
align-items: center;
|
|
78
|
+
gap: var(--space-2);
|
|
79
|
+
border: 1px solid var(--color-border);
|
|
80
|
+
border-radius: var(--radius-md);
|
|
81
|
+
color: var(--color-text);
|
|
82
|
+
font-size: var(--text-sm);
|
|
83
|
+
line-height: var(--leading-snug);
|
|
84
|
+
padding-inline-start: var(--space-3);
|
|
85
|
+
display: flex;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.fileName-CHIc8 {
|
|
89
|
+
overflow-wrap: anywhere;
|
|
90
|
+
min-width: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.rejection-mI7_p {
|
|
94
|
+
margin: 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** Shown for a value with nothing to show. Internal, shared with `Descriptions`. */
|
|
3
|
+
export declare const DEFAULT_EMPTY_TEXT = "\u2014";
|
|
4
|
+
/**
|
|
5
|
+
* The values that render as nothing and that a caller means as "no value". `0` is a value, and
|
|
6
|
+
* so is the word `none`. `true` and an empty array also render as nothing, but neither is what
|
|
7
|
+
* `{isSet && value}` or a missing field produces, so they stay the caller's to say. Internal,
|
|
8
|
+
* like `FieldMessages`: reachable across modules, absent from `src/index.ts`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isEmptyValue(value: ReactNode): boolean;
|
|
11
|
+
export type ViewFieldLayout = 'stacked' | 'inline';
|
|
12
|
+
export interface ViewFieldProps {
|
|
13
|
+
/** Names the value: the `<dt>`. */
|
|
14
|
+
label: ReactNode;
|
|
15
|
+
/** The value: the `<dd>`. */
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
/** `stacked` (default) puts the label above the value; `inline` beside it, wrapping if tight. */
|
|
18
|
+
layout?: ViewFieldLayout;
|
|
19
|
+
/** Shown instead of a value that is `undefined`, `null`, `false` or `''`. */
|
|
20
|
+
emptyText?: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One read-only label and value. For several together use `Descriptions`, which is one list
|
|
24
|
+
* rather than one list per pair.
|
|
25
|
+
*/
|
|
26
|
+
export declare function ViewField({ label, children, layout, emptyText, }: ViewFieldProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import pair_module from "../../styles/pair.module.js";
|
|
3
|
+
import ViewField_module from "./ViewField.module.js";
|
|
4
|
+
const DEFAULT_EMPTY_TEXT = '—';
|
|
5
|
+
function isEmptyValue(value) {
|
|
6
|
+
return null == value || false === value || '' === value;
|
|
7
|
+
}
|
|
8
|
+
function ViewField({ label, children, layout = 'stacked', emptyText = DEFAULT_EMPTY_TEXT }) {
|
|
9
|
+
const isEmpty = isEmptyValue(children);
|
|
10
|
+
return /*#__PURE__*/ jsx("dl", {
|
|
11
|
+
className: ViewField_module.root,
|
|
12
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
13
|
+
className: ViewField_module.group,
|
|
14
|
+
"data-layout": layout,
|
|
15
|
+
children: [
|
|
16
|
+
/*#__PURE__*/ jsx("dt", {
|
|
17
|
+
className: pair_module.label,
|
|
18
|
+
children: label
|
|
19
|
+
}),
|
|
20
|
+
/*#__PURE__*/ jsx("dd", {
|
|
21
|
+
className: pair_module.value,
|
|
22
|
+
"data-empty": isEmpty ? '' : void 0,
|
|
23
|
+
children: isEmpty ? emptyText : children
|
|
24
|
+
})
|
|
25
|
+
]
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export { DEFAULT_EMPTY_TEXT, ViewField, isEmptyValue };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.root-aO02E {
|
|
2
|
+
margin: 0;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.group-qyjwG {
|
|
6
|
+
gap: var(--space-1);
|
|
7
|
+
overflow-wrap: anywhere;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
display: flex;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.group-qyjwG[data-layout="inline"] {
|
|
13
|
+
align-items: baseline;
|
|
14
|
+
gap: var(--space-1) var(--space-3);
|
|
15
|
+
flex-flow: wrap;
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Internal, not exported from `src/index.ts`. Calls `onReset` after the form that owns `inputRef`'s
|
|
4
|
+
* input has been reset, for a control whose state a browser's reset cannot reach by itself.
|
|
5
|
+
*
|
|
6
|
+
* After, and on a timer, because the `reset` event comes before the browser resets anything: a
|
|
7
|
+
* value put in the input during the event would be wiped, and a later listener can still cancel it.
|
|
8
|
+
* A microtask is too soon, since one runs between listeners when a user presses a reset button.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useFormReset(inputRef: RefObject<HTMLInputElement | null>, onReset: () => void): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
2
|
+
function listenForReset(form, onReset) {
|
|
3
|
+
let pendingTimer;
|
|
4
|
+
const handleReset = (event)=>{
|
|
5
|
+
clearTimeout(pendingTimer);
|
|
6
|
+
pendingTimer = setTimeout(()=>{
|
|
7
|
+
if (!event.defaultPrevented) onReset();
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
form.addEventListener('reset', handleReset);
|
|
11
|
+
return ()=>{
|
|
12
|
+
clearTimeout(pendingTimer);
|
|
13
|
+
form.removeEventListener('reset', handleReset);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function useFormReset(inputRef, onReset) {
|
|
17
|
+
const latestOnReset = useRef(onReset);
|
|
18
|
+
const listening = useRef(null);
|
|
19
|
+
useLayoutEffect(()=>{
|
|
20
|
+
latestOnReset.current = onReset;
|
|
21
|
+
const form = inputRef.current?.form ?? null;
|
|
22
|
+
if (form === (listening.current?.form ?? null)) return;
|
|
23
|
+
listening.current?.stop();
|
|
24
|
+
listening.current = null === form ? null : {
|
|
25
|
+
form,
|
|
26
|
+
stop: listenForReset(form, ()=>latestOnReset.current())
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
useEffect(()=>()=>{
|
|
30
|
+
listening.current?.stop();
|
|
31
|
+
listening.current = null;
|
|
32
|
+
}, []);
|
|
33
|
+
}
|
|
34
|
+
export { useFormReset };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
function CalendarIcon() {
|
|
3
|
+
return /*#__PURE__*/ jsxs("svg", {
|
|
4
|
+
viewBox: "0 0 16 16",
|
|
5
|
+
fill: "none",
|
|
6
|
+
stroke: "currentColor",
|
|
7
|
+
strokeWidth: "1.5",
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
strokeLinejoin: "round",
|
|
10
|
+
"aria-hidden": "true",
|
|
11
|
+
focusable: "false",
|
|
12
|
+
children: [
|
|
13
|
+
/*#__PURE__*/ jsx("rect", {
|
|
14
|
+
x: "2",
|
|
15
|
+
y: "3",
|
|
16
|
+
width: "12",
|
|
17
|
+
height: "11",
|
|
18
|
+
rx: "1.5"
|
|
19
|
+
}),
|
|
20
|
+
/*#__PURE__*/ jsx("path", {
|
|
21
|
+
d: "M2 6.5h12M5.5 1.5v3M10.5 1.5v3"
|
|
22
|
+
})
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export { CalendarIcon };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tick inside a selected `Select` option and a ticked `Checkbox`. Internal, like
|
|
3
|
+
* `CloseIcon` and `ChevronDownIcon`; decorative in both places, because the option's text and
|
|
4
|
+
* the checkbox's label carry the meaning.
|
|
5
|
+
*/
|
|
6
|
+
export declare function CheckIcon(): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
function CheckIcon() {
|
|
3
|
+
return /*#__PURE__*/ jsx("svg", {
|
|
4
|
+
viewBox: "0 0 16 16",
|
|
5
|
+
fill: "none",
|
|
6
|
+
stroke: "currentColor",
|
|
7
|
+
strokeWidth: "2",
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
strokeLinejoin: "round",
|
|
10
|
+
"aria-hidden": "true",
|
|
11
|
+
focusable: "false",
|
|
12
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
13
|
+
d: "m3.5 8.5 3 3 6-7"
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { CheckIcon };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chevron on a `Select` trigger. Internal, exactly as `CloseIcon` is: the barrel does not
|
|
3
|
+
* export it, so consumers bring their own icon set. It is decorative — Base UI marks
|
|
4
|
+
* `Select.Icon` `aria-hidden` itself — and declares no size; the control that holds it sizes it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ChevronDownIcon(): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
function ChevronDownIcon() {
|
|
3
|
+
return /*#__PURE__*/ jsx("svg", {
|
|
4
|
+
viewBox: "0 0 16 16",
|
|
5
|
+
fill: "none",
|
|
6
|
+
stroke: "currentColor",
|
|
7
|
+
strokeWidth: "1.5",
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
strokeLinejoin: "round",
|
|
10
|
+
"aria-hidden": "true",
|
|
11
|
+
focusable: "false",
|
|
12
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
13
|
+
d: "m4 6.25 4 4 4-4"
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { ChevronDownIcon };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
function MinusIcon() {
|
|
3
|
+
return /*#__PURE__*/ jsx("svg", {
|
|
4
|
+
viewBox: "0 0 16 16",
|
|
5
|
+
fill: "none",
|
|
6
|
+
stroke: "currentColor",
|
|
7
|
+
strokeWidth: "2",
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
"aria-hidden": "true",
|
|
10
|
+
focusable: "false",
|
|
11
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
12
|
+
d: "M4 8h8"
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export { MinusIcon };
|