@mistriwork/ui 1.0.0-rc.16 → 1.0.0-rc.18
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/Field.d.ts +7 -1
- package/dist/Field.js +2 -2
- package/dist/TextField.js +1 -1
- package/dist/fieldFrame.d.ts +4 -0
- package/dist/fieldFrame.js +1 -0
- package/dist/forms.css +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/primitives.css +11 -0
- package/package.json +1 -1
package/dist/Field.d.ts
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* its focusable is.
|
|
13
13
|
*/
|
|
14
14
|
import { type ReactElement, type ReactNode } from 'react';
|
|
15
|
+
/** The short answers: a count, an amount, a day, a day and its time, a time of day. */
|
|
16
|
+
export type AnswerKind = 'number' | 'money' | 'date' | 'datetime' | 'time';
|
|
15
17
|
export interface FieldControlProps {
|
|
16
18
|
id: string;
|
|
17
19
|
'aria-describedby'?: string;
|
|
@@ -46,8 +48,12 @@ interface FieldProps {
|
|
|
46
48
|
reserve?: boolean;
|
|
47
49
|
/** Compact: a filter's or a dense row's size. */
|
|
48
50
|
size?: 'compact' | 'default';
|
|
51
|
+
/** What kind of answer the control takes, where it is a short one: the control is only as wide as that answer
|
|
52
|
+
(forms.css) and consecutive short fields share a row. Decided from the data, never measured, so no answer
|
|
53
|
+
resizes its field. Absent for text and for a choice, which take the column. */
|
|
54
|
+
kind?: AnswerKind;
|
|
49
55
|
className?: string;
|
|
50
56
|
children: ReactElement<Record<string, unknown>> | ((control: FieldControlProps) => ReactNode);
|
|
51
57
|
}
|
|
52
|
-
export declare function Field({ label, hint, problem, required, id, group, check, size, optional, labelAside, labelHidden, reserve, className, children, }: FieldProps): import("react").JSX.Element;
|
|
58
|
+
export declare function Field({ label, hint, problem, required, id, group, check, size, kind, optional, labelAside, labelHidden, reserve, className, children, }: FieldProps): import("react").JSX.Element;
|
|
53
59
|
export {};
|
package/dist/Field.js
CHANGED
|
@@ -13,7 +13,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
13
13
|
* its focusable is.
|
|
14
14
|
*/
|
|
15
15
|
import { cloneElement, isValidElement, useId } from 'react';
|
|
16
|
-
export function Field({ label, hint, problem, required = false, id, group = false, check = false, size = 'default', optional, labelAside, labelHidden = false, reserve = false, className = '', children, }) {
|
|
16
|
+
export function Field({ label, hint, problem, required = false, id, group = false, check = false, size = 'default', kind, optional, labelAside, labelHidden = false, reserve = false, className = '', children, }) {
|
|
17
17
|
const made = useId();
|
|
18
18
|
const controlId = id ?? `field-${made}`;
|
|
19
19
|
const hintId = hint ? `${controlId}-hint` : undefined;
|
|
@@ -38,7 +38,7 @@ export function Field({ label, hint, problem, required = false, id, group = fals
|
|
|
38
38
|
/* The star is the stylesheet's (`.is-required`), not text: a label's words
|
|
39
39
|
stay its name, to a query by label as to a screen reader, which hears
|
|
40
40
|
"required" from `aria-required` instead. */
|
|
41
|
-
return (_jsxs("div", { className: [
|
|
41
|
+
return (_jsxs("div", { "data-kind": kind, className: [
|
|
42
42
|
'form-field',
|
|
43
43
|
size === 'compact' ? 'form-field-compact' : '',
|
|
44
44
|
check ? 'form-field-check' : '',
|
package/dist/TextField.js
CHANGED
|
@@ -15,5 +15,5 @@ export function MaskedField({ mask, value, onChange, ...rest }) {
|
|
|
15
15
|
}
|
|
16
16
|
/** Whole money, drawn `$2,500` (or `25,000` with `symbol=""`). The value is the digits. */
|
|
17
17
|
export function MoneyField({ symbol = '$', ...rest }) {
|
|
18
|
-
return _jsx(MaskedField, { ...rest, mask: masks.money(symbol) });
|
|
18
|
+
return _jsx(MaskedField, { kind: "money", ...rest, mask: masks.money(symbol) });
|
|
19
19
|
}
|
package/dist/fieldFrame.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* field and a help tip. `frameOf` turns it into the Field's props, so a control never joins them by hand.
|
|
4
4
|
*/
|
|
5
5
|
import type { ReactNode } from 'react';
|
|
6
|
+
import type { AnswerKind } from './Field.js';
|
|
6
7
|
import { type HelpTipProps } from './FormParts.js';
|
|
7
8
|
export interface FieldFrame {
|
|
8
9
|
label: ReactNode;
|
|
@@ -19,6 +20,8 @@ export interface FieldFrame {
|
|
|
19
20
|
tip?: HelpTipProps;
|
|
20
21
|
/** Keep the problem's line in the flow while empty. On by default for a form's controls; turn it off for a dense row. */
|
|
21
22
|
reserve?: boolean;
|
|
23
|
+
/** A short answer's kind: the control is only as wide as the answer (Field's `kind`). */
|
|
24
|
+
kind?: AnswerKind;
|
|
22
25
|
/** The control's id; one is made when not given. */
|
|
23
26
|
id?: string;
|
|
24
27
|
className?: string;
|
|
@@ -30,6 +33,7 @@ export declare function frameOf(p: FieldFrame): {
|
|
|
30
33
|
required: boolean | undefined;
|
|
31
34
|
labelHidden: boolean | undefined;
|
|
32
35
|
id: string | undefined;
|
|
36
|
+
kind: AnswerKind | undefined;
|
|
33
37
|
className: string | undefined;
|
|
34
38
|
optional: ReactNode;
|
|
35
39
|
labelAside: import("react").JSX.Element | undefined;
|
package/dist/fieldFrame.js
CHANGED
package/dist/forms.css
CHANGED
|
@@ -122,6 +122,14 @@
|
|
|
122
122
|
@media (max-width: 22rem) { .form-columns { grid-template-columns: minmax(0, 1fr); } }
|
|
123
123
|
.review-list { display: grid; gap: var(--field-gap); }
|
|
124
124
|
|
|
125
|
+
/* A short choice (up to five words, none with a description) is a row of buttons that wraps, not a stack of cards:
|
|
126
|
+
five 48px cards took 270px to say five words. Each is a pick, so it wears the field's own box; the row never
|
|
127
|
+
scrolls sideways, it wraps whole picks onto the next line. */
|
|
128
|
+
.choice-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }
|
|
129
|
+
.choice-row > .choice-pick { gap: var(--space-3); }
|
|
130
|
+
.choice-pick-icon { display: inline-flex; flex: none; color: var(--accent-ink); }
|
|
131
|
+
.choice-pick-icon > svg { width: 16px; height: 16px; }
|
|
132
|
+
|
|
125
133
|
/* A theme's recipes for a form (themeRecipes.ts: required, checkbox, formStep, actionBar). Their rules are here, not
|
|
126
134
|
in a first stylesheet: they draw nothing a page without a control has. */
|
|
127
135
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* itself).
|
|
7
7
|
*/
|
|
8
8
|
export { Button, buttonClass, type ButtonIntent, type ButtonSize } from './Button.js';
|
|
9
|
-
export { Field, type FieldControlProps } from './Field.js';
|
|
9
|
+
export { Field, type AnswerKind, type FieldControlProps } from './Field.js';
|
|
10
10
|
export { Modal, type ModalHandle } from './Modal.js';
|
|
11
11
|
export { DropMenu, DropGroup, DropItem, DropSeparator } from './DropMenu.js';
|
|
12
12
|
export { Dropdown, MultiDropdown, type DropdownAction, type DropdownItem, type DropdownProps, type MultiDropdownProps, } from './Dropdown.js';
|
package/dist/primitives.css
CHANGED
|
@@ -43,6 +43,17 @@ a.btn.ghost { background: transparent; color: var(--ink-muted); border-color: va
|
|
|
43
43
|
.form-field-hint { margin: 0; font-size: var(--text-sm); line-height: 1.45; color: var(--ink-muted); }
|
|
44
44
|
.form-field-problem { margin: 0; font-size: var(--text-sm); line-height: 1.45; color: var(--status-critical); overflow-wrap: anywhere; }
|
|
45
45
|
.form-field-compact { gap: var(--space-2); }
|
|
46
|
+
/* A field is as wide as its answer (docs/design.md, Forms): a count, an amount, a day and a time are a few characters
|
|
47
|
+
long, and a box the width of the column for them says "write a paragraph". The cap is on the control, not the field,
|
|
48
|
+
so its label, hint and problem keep the column's measure. Set from the data kind the form already knows (Field's
|
|
49
|
+
`kind`), never measured, so no answer resizes its field. Here with the Field that carries the kind, not in forms.css,
|
|
50
|
+
which loads only beside a control of its own: a form of plain boxes never fetches it. Consecutive short fields share
|
|
51
|
+
a row where the form lays its fields on a grid (features.css, `.insert-group-fields` and `.command-fields`). */
|
|
52
|
+
.form-field[data-kind="number"], .form-field[data-kind="time"] { --answer-max: 160px; }
|
|
53
|
+
.form-field[data-kind="money"] { --answer-max: 200px; }
|
|
54
|
+
.form-field[data-kind="date"] { --answer-max: 240px; }
|
|
55
|
+
.form-field[data-kind="datetime"] { --answer-max: 280px; }
|
|
56
|
+
.form-field[data-kind] > :is(input, .field-box, .field-with-action, .date-field, .insert-affix, .picker) { max-inline-size: var(--answer-max); }
|
|
46
57
|
/* A checkbox field: the box, then its label beside it, the label a click
|
|
47
58
|
target too; the hint and the problem sit under the label, not the box. */
|
|
48
59
|
.form-field-check-row { display: flex; align-items: flex-start; gap: var(--space-3); min-width: 0; }
|
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.18",
|
|
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": {
|