@mistriwork/ui 1.0.0-rc.33 → 1.0.0-rc.34
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/README.md +1 -1
- package/dist/FileField.d.ts +19 -0
- package/dist/FileField.js +25 -0
- package/dist/forms.css +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ DateField over [Base UI](https://base-ui.com), the tokens and stylesheet they
|
|
|
8
8
|
are drawn with, and the zoom-aware ruler their popups are placed by.
|
|
9
9
|
|
|
10
10
|
The form controls are built on them (**Preview**: @mistriwork/ui is Preview at 1.0): `TextField`, `MaskedField`,
|
|
11
|
-
`MoneyField`, `SensitiveField`, `Select`, `MultiSelect`, `YesNo`, `ChoiceCards`, `Checkbox`, `Consent`, `Slider`,
|
|
11
|
+
`MoneyField`, `SensitiveField`, `FileField`, `Select`, `MultiSelect`, `YesNo`, `ChoiceCards`, `Checkbox`, `Consent`, `Slider`,
|
|
12
12
|
`HelpTip`, `ProgressBar`, `StepHeader`, `ActionBar`, `Columns` and `ReviewList`, with the `masks` they take
|
|
13
13
|
(`phone`, `date`, `month`, `ssn`, `zip`, `money`). Each takes a value and an `onChange` and draws what it is told. A
|
|
14
14
|
typed MM/DD/YYYY date is `MaskedField` with `masks.date` (and `isoDay` to read it); the calendar field is `DateField`.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A file chosen in the browser, handed to the page as a `File` (or null): for a page that reads a file before any
|
|
3
|
+
* command runs, a CSV parsed and shown, say. It is the browser's own picker in a field's box, so the label, hint and
|
|
4
|
+
* problem are wired in as they are for a text box, and the keyboard and the file dialog are the platform's. A command's
|
|
5
|
+
* form has `field.file`, which sends the bytes; this sends nothing. Props only. Preview: @mistriwork/ui is Preview at 1.0.
|
|
6
|
+
*/
|
|
7
|
+
import { type ReactNode, type Ref } from 'react';
|
|
8
|
+
import { type FieldFrame } from './fieldFrame.js';
|
|
9
|
+
export interface FileFieldProps extends FieldFrame {
|
|
10
|
+
/** The chosen file; null while there is none. Set it to null to clear the choice. */
|
|
11
|
+
value: File | null;
|
|
12
|
+
onChange: (file: File | null) => void;
|
|
13
|
+
/** What the picker offers, as the input's `accept`: `.csv`, `text/csv`, `image/*`, separated by commas. */
|
|
14
|
+
accept?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
18
|
+
}
|
|
19
|
+
export declare function FileField(props: FileFieldProps): ReactNode;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A file chosen in the browser, handed to the page as a `File` (or null): for a page that reads a file before any
|
|
4
|
+
* command runs, a CSV parsed and shown, say. It is the browser's own picker in a field's box, so the label, hint and
|
|
5
|
+
* problem are wired in as they are for a text box, and the keyboard and the file dialog are the platform's. A command's
|
|
6
|
+
* form has `field.file`, which sends the bytes; this sends nothing. Props only. Preview: @mistriwork/ui is Preview at 1.0.
|
|
7
|
+
*/
|
|
8
|
+
import { useEffect, useRef } from 'react';
|
|
9
|
+
import { Field } from './Field.js';
|
|
10
|
+
import { frameOf } from './fieldFrame.js';
|
|
11
|
+
export function FileField(props) {
|
|
12
|
+
const own = useRef(null);
|
|
13
|
+
// The input keeps its own file, so a page that clears the value (null) has to clear it too.
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (props.value === null && own.current && own.current.value !== '')
|
|
16
|
+
own.current.value = '';
|
|
17
|
+
}, [props.value]);
|
|
18
|
+
return (_jsx(Field, { ...frameOf(props), children: (control) => (_jsx("input", { ...control, ref: (node) => {
|
|
19
|
+
own.current = node;
|
|
20
|
+
if (typeof props.inputRef === 'function')
|
|
21
|
+
props.inputRef(node);
|
|
22
|
+
else if (props.inputRef)
|
|
23
|
+
props.inputRef.current = node;
|
|
24
|
+
}, className: "field-control field-file", type: "file", name: props.name, accept: props.accept, disabled: props.disabled, onChange: (e) => props.onChange(e.target.files?.[0] ?? null) })) }));
|
|
25
|
+
}
|
package/dist/forms.css
CHANGED
|
@@ -29,6 +29,13 @@
|
|
|
29
29
|
.field-note { display: flex; align-items: center; gap: var(--space-3); margin: 0; font-size: var(--text-sm); line-height: 1.45; color: var(--ink-muted); }
|
|
30
30
|
.field-note > svg { flex: none; width: 14px; height: 14px; }
|
|
31
31
|
|
|
32
|
+
/* The file picker is the browser's own input in a field's box (`field-control`); only its button is dressed, in the
|
|
33
|
+
quiet button's tokens, and the box's own padding keeps the button off its edge. */
|
|
34
|
+
.field-control.field-file { padding: calc(var(--space-2) - var(--control-border-w)) var(--space-2); color: var(--ink-muted); cursor: pointer; }
|
|
35
|
+
.field-control.field-file::file-selector-button { margin-inline-end: var(--space-3); padding: var(--space-1h) var(--space-3); font: inherit; font-size: var(--text-sm); color: var(--ink); background: var(--raised); border: 1px solid var(--line-control); border-radius: var(--field-radius, var(--radius)); cursor: pointer; }
|
|
36
|
+
.field-control.field-file:is(:disabled, [aria-disabled="true"]) { cursor: not-allowed; }
|
|
37
|
+
.field-control.field-file:is(:disabled, [aria-disabled="true"])::file-selector-button { color: var(--ink-muted); cursor: not-allowed; }
|
|
38
|
+
|
|
32
39
|
/* The form's listbox is the Dropdown dressed as a field box. */
|
|
33
40
|
.dd-button.field-select { min-height: var(--control-h); border-width: var(--control-border-w); padding: var(--space-2h) var(--space-3h); font: inherit; font-size: var(--text-base); background: var(--field-fill); border-radius: var(--field-radius, var(--radius)); text-align: start; }
|
|
34
41
|
.dd-button.field-select[aria-invalid="true"] { border-color: var(--status-critical); }
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { DateField, type DateFieldProps, type DateFieldWords } from './DateField
|
|
|
16
16
|
export type { FieldFrame } from './fieldFrame.js';
|
|
17
17
|
export { TextField, MaskedField, MoneyField, ValidMark, type MaskedFieldProps, type TextFieldProps } from './TextField.js';
|
|
18
18
|
export { SensitiveField, type SensitiveFieldProps } from './SensitiveField.js';
|
|
19
|
+
export { FileField, type FileFieldProps } from './FileField.js';
|
|
19
20
|
export { Select, MultiSelect } from './Select.js';
|
|
20
21
|
export { CheckCards, ChoiceCards, Checkbox, Consent, YesNo, type CheckCard, type CheckCardsProps, type CheckboxProps, type ChoiceCardsProps, type ChoiceOption, type YesNoProps, } from './Choices.js';
|
|
21
22
|
export { Slider, type SliderProps } from './Slider.js';
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export { Icon, loadIconsWith, registerIcons, weighIconsWith, } from './Icon.js';
|
|
|
15
15
|
export { DateField } from './DateField.js';
|
|
16
16
|
export { TextField, MaskedField, MoneyField, ValidMark } from './TextField.js';
|
|
17
17
|
export { SensitiveField } from './SensitiveField.js';
|
|
18
|
+
export { FileField } from './FileField.js';
|
|
18
19
|
export { Select, MultiSelect } from './Select.js';
|
|
19
20
|
export { CheckCards, ChoiceCards, Checkbox, Consent, YesNo, } from './Choices.js';
|
|
20
21
|
export { Slider } from './Slider.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistriwork/ui",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.34",
|
|
4
4
|
"description": "The standalone React primitives both shells are drawn with: Modal, DropMenu, Dropdown, Typeahead, Button, Field, Icon and DateField over Base UI, Switch, Tabs, Drawer, Popover, Avatar, Pagination, Carousel, Resizable, ScrollArea and Tooltip, the form controls built on them (text, masked, money and sensitive boxes, listboxes, choices, slider, progress and action bar; Preview), the landing hero's blocks (badge, photo tiles, icon rows; Preview), their tokens and stylesheet, and the zoom-aware ruler their popups are placed by.",
|
|
5
5
|
"homepage": "https://mistriwork.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"./Resizable.js": "./dist/Resizable.js",
|
|
44
44
|
"./ScrollArea.js": "./dist/ScrollArea.js",
|
|
45
45
|
"./Popover.js": "./dist/Popover.js",
|
|
46
|
+
"./FileField.js": "./dist/FileField.js",
|
|
46
47
|
"./Select.js": "./dist/Select.js",
|
|
47
48
|
"./SensitiveField.js": "./dist/SensitiveField.js",
|
|
48
49
|
"./Slider.js": "./dist/Slider.js",
|