@mistriwork/ui 1.0.0-rc.41 → 1.0.0-rc.43

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.
@@ -1,8 +1,10 @@
1
1
  /**
2
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.
3
+ * command runs, a CSV parsed and shown, say. It is drawn as the look draws a control, the kit's button and the chosen
4
+ * names beside it, not the browser's grey "Choose Files"; underneath it is still the browser's own input (hidden
5
+ * visually, never removed), so the label, hint and problem are wired in as they are for a text box, and the keyboard
6
+ * (Tab to it, Enter or Space) and the file dialog are the platform's. A command's form has `field.file`, which sends
7
+ * the bytes; this sends nothing. Props only. Preview: @mistriwork/ui is Preview at 1.0.
6
8
  */
7
9
  import { type ReactNode, type Ref } from 'react';
8
10
  import { type FieldFrame } from './fieldFrame.js';
@@ -12,6 +14,10 @@ interface FileFieldBase extends FieldFrame {
12
14
  name?: string;
13
15
  disabled?: boolean;
14
16
  inputRef?: Ref<HTMLInputElement>;
17
+ /** The button's words, in the caller's language: "Choose file" ("Choose files" with `multiple`) unless said. */
18
+ chooseLabel?: string;
19
+ /** What the names say while there is no file: "No file chosen". */
20
+ noneLabel?: string;
15
21
  }
16
22
  /**
17
23
  * One file by default: `value` is the chosen File (null while there is none) and `onChange` hands up one. With `multiple`
package/dist/FileField.js CHANGED
@@ -1,11 +1,14 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
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.
4
+ * command runs, a CSV parsed and shown, say. It is drawn as the look draws a control, the kit's button and the chosen
5
+ * names beside it, not the browser's grey "Choose Files"; underneath it is still the browser's own input (hidden
6
+ * visually, never removed), so the label, hint and problem are wired in as they are for a text box, and the keyboard
7
+ * (Tab to it, Enter or Space) and the file dialog are the platform's. A command's form has `field.file`, which sends
8
+ * the bytes; this sends nothing. Props only. Preview: @mistriwork/ui is Preview at 1.0.
7
9
  */
8
10
  import { useEffect, useRef } from 'react';
11
+ import { buttonClass } from './Button.js';
9
12
  import { Field } from './Field.js';
10
13
  import { frameOf } from './fieldFrame.js';
11
14
  export function FileField(props) {
@@ -16,17 +19,20 @@ export function FileField(props) {
16
19
  if (cleared && own.current && own.current.value !== '')
17
20
  own.current.value = '';
18
21
  }, [cleared]);
19
- return (_jsx(Field, { ...frameOf(props), children: (control) => (_jsx("input", { ...control, ref: (node) => {
20
- own.current = node;
21
- if (typeof props.inputRef === 'function')
22
- props.inputRef(node);
23
- else if (props.inputRef)
24
- props.inputRef.current = node;
25
- }, className: "field-control field-file", type: "file", name: props.name, accept: props.accept, disabled: props.disabled, multiple: props.multiple === true, onChange: (e) => {
26
- const files = Array.from(e.target.files ?? []);
27
- if (props.multiple === true)
28
- props.onChange(files);
29
- else
30
- props.onChange(files[0] ?? null);
31
- } })) }));
22
+ const chosen = props.value;
23
+ const names = Array.isArray(chosen) ? chosen.map((file) => file.name) : chosen ? [chosen.name] : [];
24
+ const said = names.join(', ');
25
+ return (_jsx(Field, { ...frameOf(props), children: (control) => (_jsxs("div", { className: "field-file", children: [_jsx("input", { ...control, ref: (node) => {
26
+ own.current = node;
27
+ if (typeof props.inputRef === 'function')
28
+ props.inputRef(node);
29
+ else if (props.inputRef)
30
+ props.inputRef.current = node;
31
+ }, className: "field-file-input", type: "file", name: props.name, accept: props.accept, disabled: props.disabled, multiple: props.multiple === true, onChange: (e) => {
32
+ const files = Array.from(e.target.files ?? []);
33
+ if (props.multiple === true)
34
+ props.onChange(files);
35
+ else
36
+ props.onChange(files[0] ?? null);
37
+ } }), _jsx("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: buttonClass({ intent: 'secondary', className: 'field-file-button' }), disabled: props.disabled, onClick: () => own.current?.click(), children: props.chooseLabel ?? (props.multiple ? 'Choose files' : 'Choose file') }), _jsx("span", { className: `field-file-names${names.length ? '' : ' is-none'}`, title: said || undefined, children: said || (props.noneLabel ?? 'No file chosen') })] })) }));
32
38
  }
package/dist/forms.css CHANGED
@@ -29,12 +29,15 @@
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; }
32
+ /* The file field (FileField.tsx): the kit's button and the chosen names, over the browser's input, which is clipped, not
33
+ removed, so the label names it and Tab and Enter reach it. Its focus is drawn on the button, the control a sighted
34
+ reader sees. A field's control is one control tall, whatever the button inside it. */
35
+ .field-file { position: relative; display: flex; align-items: center; gap: var(--space-3); min-width: 0; min-height: var(--control-h); }
36
+ .field-file-input { position: absolute; inset-block-start: 0; inset-inline-start: 0; width: 1px; height: 1px; margin: 0; opacity: 0; overflow: hidden; clip-path: inset(50%); }
37
+ .field-file-input:focus-visible ~ .field-file-button { outline: var(--focus-width, 2px) solid var(--focus); outline-offset: 2px; }
38
+ .field-file-button { flex: none; }
39
+ .field-file-names { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-base); color: var(--ink); }
40
+ .field-file-names.is-none { color: var(--ink-muted); }
38
41
 
39
42
  /* The form's listbox is the Dropdown dressed as a field box. */
40
43
  .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; }
@@ -193,13 +196,25 @@ a:active { opacity: 0.7; }
193
196
  .btn { transition: transform var(--t-press) var(--ease-out); }
194
197
  .btn:not(:disabled, [aria-disabled="true"]):active, .choice-pick:active, .choice-card:active { transform: scale(0.97); }
195
198
  }
196
- @media (pointer: coarse) {
197
- /* A finger needs 44px (WCAG 2.5.5) whatever height the theme draws, through the density's zoom (--row-h does the same). */
199
+ /* A finger needs 44px (WCAG 2.5.5) whatever height the theme draws, through the density's zoom (--row-h does the same):
200
+ under any coarse pointer, and at a phone's width, where a narrow window on a desk is read as a phone is (grade measures
201
+ the targets at 390px with no touch). A compact button stays compact: it is the one a toolbar asks for. */
202
+ @media (pointer: coarse), (max-width: 40rem) {
198
203
  /* A form's listbox may be the shell's (.form-field .dd-button) rather than @mistriwork/ui's Select: the same field, so the
199
204
  same height as the box beside it in a row. */
200
205
  .field-control, .dd-button.field-select, .form-field .dd-button, .choice-pick, .choice-card, .date-field .date-field-input, .btn:not(.btn-compact) {
201
206
  min-height: max(var(--control-h), calc(44px / var(--density-zoom, 1)));
202
207
  }
208
+ /* The calendar's button is the input's own height, not two pixels short of it on each side, and wide enough to be hit. */
209
+ .date-field .date-field-input {
210
+ padding-inline-end: calc(44px / var(--density-zoom, 1));
211
+ }
212
+ .date-field .date-field-trigger {
213
+ inset: 0 0 0 auto;
214
+ width: calc(44px / var(--density-zoom, 1));
215
+ }
216
+ }
217
+ @media (pointer: coarse) {
203
218
  /* iOS Safari zooms the page when a field under 16px is focused, and does not zoom back. The density zoom only
204
219
  enlarges (1, 1.12, 1.24), so a flat 16px is at least 16px drawn. Not verified on WebKit: it is not installed
205
220
  where this was written, so a real iPhone is the test of this rule. */
package/dist/tokens.css CHANGED
@@ -74,6 +74,9 @@
74
74
  words, a list's controls and rows, a board's first lane, a calendar and a
75
75
  record all start here, so nothing in a room starts a step off the rest. */
76
76
  --room-inset: 14px;
77
+ /* The one space under a room's head, to its first control or part: a list's filter bar and a free-form page's first
78
+ part stand this far below the head's rule, so no kind of page starts further down than another. */
79
+ --page-head-gap: var(--space-3);
77
80
  /* The space scale (docs/design.md, Space and text): every padding, margin
78
81
  and gap is a step of it or a semantic token over it. The steps from 16px
79
82
  up are the layout's and move with a theme's rhythm (themeFamilies.css);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/ui",
3
- "version": "1.0.0-rc.41",
3
+ "version": "1.0.0-rc.43",
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": {