@mistriwork/ui 1.0.0-rc.58 → 1.0.0-rc.60
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 +46 -12
- package/dist/Avatar.js +3 -3
- package/dist/Button.d.ts +4 -14
- package/dist/Button.js +26 -13
- package/dist/Carousel.d.ts +6 -5
- package/dist/Carousel.js +58 -67
- package/dist/Choices.d.ts +2 -9
- package/dist/Choices.js +127 -64
- package/dist/DateField.d.ts +9 -4
- package/dist/DateField.js +102 -119
- package/dist/Drawer.d.ts +1 -19
- package/dist/Drawer.js +8 -9
- package/dist/DropMenu.d.ts +8 -21
- package/dist/DropMenu.js +84 -30
- package/dist/Dropdown.d.ts +9 -8
- package/dist/Dropdown.js +69 -65
- package/dist/Field.d.ts +2 -1
- package/dist/Field.js +12 -18
- package/dist/FileField.d.ts +3 -10
- package/dist/FileField.js +12 -9
- package/dist/FormParts.d.ts +17 -10
- package/dist/FormParts.js +26 -41
- package/dist/HeroBlocks.d.ts +7 -3
- package/dist/HeroBlocks.js +11 -6
- package/dist/Modal.d.ts +6 -17
- package/dist/Modal.js +90 -21
- package/dist/Pagination.d.ts +1 -12
- package/dist/Pagination.js +17 -3
- package/dist/Popover.d.ts +1 -15
- package/dist/Popover.js +10 -15
- package/dist/Resizable.d.ts +3 -21
- package/dist/Resizable.js +14 -91
- package/dist/ScrollArea.d.ts +4 -2
- package/dist/ScrollArea.js +11 -11
- package/dist/Select.d.ts +1 -6
- package/dist/Select.js +16 -7
- package/dist/SensitiveField.d.ts +1 -8
- package/dist/SensitiveField.js +6 -4
- package/dist/Slider.d.ts +1 -5
- package/dist/Slider.js +13 -5
- package/dist/Switch.d.ts +1 -11
- package/dist/Switch.js +10 -9
- package/dist/Tabs.d.ts +3 -3
- package/dist/Tabs.js +3 -3
- package/dist/TextArea.d.ts +4 -6
- package/dist/TextArea.js +14 -5
- package/dist/TextField.d.ts +5 -9
- package/dist/TextField.js +67 -9
- package/dist/Tooltip.d.ts +1 -21
- package/dist/Tooltip.js +13 -31
- package/dist/Typeahead.d.ts +15 -18
- package/dist/Typeahead.js +151 -86
- package/dist/UiKit.d.ts +63 -4
- package/dist/UiKit.js +46 -5
- package/dist/behaviors/DaysParts.js +28 -0
- package/dist/behaviors/EditableParts.js +21 -0
- package/dist/behaviors/PickParts.js +30 -0
- package/dist/behaviors/ScrubParts.js +21 -0
- package/dist/behaviors/SortableParts.js +32 -0
- package/dist/behaviors/SpansParts.js +12 -0
- package/dist/behaviors/TransferParts.js +37 -0
- package/dist/behaviors/TurnsParts.js +31 -0
- package/dist/behaviors/WidthsParts.js +27 -0
- package/dist/behaviors/days.js +216 -0
- package/dist/behaviors/dress.js +86 -0
- package/dist/behaviors/editable.js +104 -0
- package/dist/behaviors/heard.js +22 -0
- package/dist/behaviors/index.d.ts +310 -0
- package/dist/behaviors/index.js +44 -0
- package/dist/behaviors/pick.js +158 -0
- package/dist/behaviors/scrub.js +152 -0
- package/dist/behaviors/sortable.js +170 -0
- package/dist/behaviors/spans.js +240 -0
- package/dist/behaviors/testing.js +48 -0
- package/dist/behaviors/transfer.js +202 -0
- package/dist/behaviors/turns.js +106 -0
- package/dist/behaviors/widths.js +150 -0
- package/dist/behaviors.css +309 -0
- package/dist/changeDetails.d.ts +4 -8
- package/dist/changeDetails.js +0 -6
- package/dist/conformance.js +107 -1
- package/dist/controls.css +36 -0
- package/dist/fieldFrame.d.ts +2 -15
- package/dist/fieldFrame.js +1 -17
- package/dist/index.d.ts +6 -5
- package/dist/index.js +6 -5
- package/dist/internal/Frame.d.ts +6 -0
- package/dist/internal/Frame.js +25 -0
- package/dist/internal/HelpTip.d.ts +5 -0
- package/dist/internal/HelpTip.js +37 -0
- package/dist/internal/layers.d.ts +21 -0
- package/dist/internal/layers.js +66 -0
- package/dist/internal/popups.d.ts +12 -10
- package/dist/internal/popups.js +18 -14
- package/dist/internal/told.d.ts +14 -0
- package/dist/internal/told.js +20 -0
- package/dist/internal/uiKitContext.js +6 -4
- package/dist/preferences.css +2 -3
- package/dist/style.css +5 -16
- package/dist/styles/extras.css +463 -0
- package/dist/styles/forms.css +346 -0
- package/dist/styles/guard.css +114 -0
- package/dist/styles/kit-fields.css +181 -0
- package/dist/styles/kit-parts.css +130 -0
- package/dist/styles/kit.css +558 -0
- package/dist/styles/layers.css +4 -0
- package/dist/styles/looks.css +374 -0
- package/dist/styles/m-tokens.css +173 -0
- package/dist/styles/overlays.css +107 -0
- package/dist/styles/parts.css +456 -0
- package/dist/styles/screens.css +76 -0
- package/dist/styles/ui-sdk.css +1635 -0
- package/dist/tokens.css +15 -4
- package/dist/uiKitSlots.d.ts +1 -1
- package/dist/uiKitSlots.js +18 -2
- package/package.json +13 -11
- package/dist/forms.css +0 -225
- package/dist/hero.css +0 -23
- package/dist/internal/anchor.d.ts +0 -19
- package/dist/internal/anchor.js +0 -52
- package/dist/primitives.css +0 -200
- package/dist/standalone.css +0 -478
package/dist/fieldFrame.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What every form control says about its frame, once: the label, the hint, the problem, the word for an optional
|
|
3
|
-
* field and a help tip.
|
|
3
|
+
* field and a help tip. internal/Frame.tsx draws it around the control, so a control never joins them by hand.
|
|
4
4
|
*/
|
|
5
5
|
import type { ReactNode } from 'react';
|
|
6
6
|
import type { AnswerKind } from './Field.js';
|
|
7
|
-
import {
|
|
7
|
+
import type { HelpTipProps } from './FormParts.js';
|
|
8
8
|
export interface FieldFrame {
|
|
9
9
|
label: ReactNode;
|
|
10
10
|
/** A sentence under the control that helps before anything goes wrong. */
|
|
@@ -26,16 +26,3 @@ export interface FieldFrame {
|
|
|
26
26
|
id?: string;
|
|
27
27
|
className?: string;
|
|
28
28
|
}
|
|
29
|
-
export declare function frameOf(p: FieldFrame): {
|
|
30
|
-
label: ReactNode;
|
|
31
|
-
hint: ReactNode;
|
|
32
|
-
problem: ReactNode;
|
|
33
|
-
required: boolean | undefined;
|
|
34
|
-
labelHidden: boolean | undefined;
|
|
35
|
-
id: string | undefined;
|
|
36
|
-
kind: AnswerKind | undefined;
|
|
37
|
-
className: string | undefined;
|
|
38
|
-
optional: ReactNode;
|
|
39
|
-
labelAside: import("react").JSX.Element | undefined;
|
|
40
|
-
reserve: boolean;
|
|
41
|
-
};
|
package/dist/fieldFrame.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { HelpTip } from './FormParts.js';
|
|
3
|
-
export function frameOf(p) {
|
|
4
|
-
return {
|
|
5
|
-
label: p.label,
|
|
6
|
-
hint: p.hint,
|
|
7
|
-
problem: p.problem,
|
|
8
|
-
required: p.required,
|
|
9
|
-
labelHidden: p.labelHidden,
|
|
10
|
-
id: p.id,
|
|
11
|
-
kind: p.kind,
|
|
12
|
-
className: p.className,
|
|
13
|
-
optional: p.optional,
|
|
14
|
-
labelAside: p.tip ? _jsx(HelpTip, { ...p.tip }) : undefined,
|
|
15
|
-
reserve: p.reserve ?? true,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mistriwork/ui: the primitives every dialog, menu, listbox, icon and form here is drawn with, over
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* @mistriwork/ui: the primitives every dialog, menu, listbox, icon and form here is drawn with, over UI SDK (`@ui-sdk/core`,
|
|
3
|
+
* `@ui-sdk/react`). A part is known by the `data-slot` it carries and its state by attributes (`data-variant`,
|
|
4
|
+
* `data-checked`, `data-open`), never by a class, and the package's own stylesheet dresses them
|
|
5
|
+
* (`@mistriwork/ui/controls.css`; `@mistriwork/ui/style.css` is that with the tokens and the reader's settings, for a page
|
|
6
|
+
* with no kit). A primitive reads no walk, no address, no transport and no copy catalog: its words, its
|
|
5
7
|
* icons, its answers and its hooks are props (scripts/check-boundary.mjs holds the `ui` layer to importing only
|
|
6
8
|
* itself).
|
|
7
9
|
*/
|
|
@@ -26,7 +28,6 @@ export { ActionBar, Columns, HelpTip, ProgressBar, ReviewList, StepHeader, type
|
|
|
26
28
|
export { Badge, IconRows, PhotoTiles, type BadgeProps, type IconRowsProps, type PhotoTile, type PhotoTilesProps } from './HeroBlocks.js';
|
|
27
29
|
export { digits, grouped, isoDay, maskNamed, masks, type Mask, type MaskName } from './masks.js';
|
|
28
30
|
export { ComponentStyleScope } from './internal/ComponentStyleScope.js';
|
|
29
|
-
export { layoutViewport, zoomAnchor } from './internal/anchor.js';
|
|
30
31
|
export { popupContainer, drawPopupsIn } from './internal/popups.js';
|
|
31
32
|
export { measureFrom, refreshViewportScale, viewportBox, viewportScale, viewportSize } from './internal/ruler.js';
|
|
32
33
|
export { Switch, type SwitchProps } from './Switch.js';
|
|
@@ -39,4 +40,4 @@ export { Carousel, type CarouselProps, type CarouselSlide } from './Carousel.js'
|
|
|
39
40
|
export { Resizable, type ResizablePanel, type ResizableProps } from './Resizable.js';
|
|
40
41
|
export { ScrollArea, type ScrollAreaProps } from './ScrollArea.js';
|
|
41
42
|
export { Tooltip, type TooltipProps } from './Tooltip.js';
|
|
42
|
-
export { SLOT_NAMES, UiKitProvider, defaultUiKit, defineUiKit, installUiKit, uiKitProblems, type SlotName, type UiKit, type UiKitSlots, } from './UiKit.js';
|
|
43
|
+
export { SLOT_NAMES, UiKitProvider, defaultUiKit, defineUiKit, dress, extendUiKit, installUiKit, uiKitProblems, useComponentScope, usePopupHost, type SlotName, type SlotProps, type UiKit, type UiKitSlots, } from './UiKit.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mistriwork/ui: the primitives every dialog, menu, listbox, icon and form here is drawn with, over
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* @mistriwork/ui: the primitives every dialog, menu, listbox, icon and form here is drawn with, over UI SDK (`@ui-sdk/core`,
|
|
3
|
+
* `@ui-sdk/react`). A part is known by the `data-slot` it carries and its state by attributes (`data-variant`,
|
|
4
|
+
* `data-checked`, `data-open`), never by a class, and the package's own stylesheet dresses them
|
|
5
|
+
* (`@mistriwork/ui/controls.css`; `@mistriwork/ui/style.css` is that with the tokens and the reader's settings, for a page
|
|
6
|
+
* with no kit). A primitive reads no walk, no address, no transport and no copy catalog: its words, its
|
|
5
7
|
* icons, its answers and its hooks are props (scripts/check-boundary.mjs holds the `ui` layer to importing only
|
|
6
8
|
* itself).
|
|
7
9
|
*/
|
|
@@ -27,7 +29,6 @@ export { ActionBar, Columns, HelpTip, ProgressBar, ReviewList, StepHeader, } fro
|
|
|
27
29
|
export { Badge, IconRows, PhotoTiles } from './HeroBlocks.js';
|
|
28
30
|
export { digits, grouped, isoDay, maskNamed, masks } from './masks.js';
|
|
29
31
|
export { ComponentStyleScope } from './internal/ComponentStyleScope.js';
|
|
30
|
-
export { layoutViewport, zoomAnchor } from './internal/anchor.js';
|
|
31
32
|
export { popupContainer, drawPopupsIn } from './internal/popups.js';
|
|
32
33
|
export { measureFrom, refreshViewportScale, viewportBox, viewportScale, viewportSize } from './internal/ruler.js';
|
|
33
34
|
/* The standalone primitives added for the showcase's missing list: a switch, tabs, a drawer, a popover, an avatar disc and pagination. Preview, like the controls. */
|
|
@@ -43,4 +44,4 @@ export { Resizable } from './Resizable.js';
|
|
|
43
44
|
export { ScrollArea } from './ScrollArea.js';
|
|
44
45
|
export { Tooltip } from './Tooltip.js';
|
|
45
46
|
/* The seam a control kit plugs into: the slots, their props, and a kit's declaration. Preview. */
|
|
46
|
-
export { SLOT_NAMES, UiKitProvider, defaultUiKit, defineUiKit, installUiKit, uiKitProblems, } from './UiKit.js';
|
|
47
|
+
export { SLOT_NAMES, UiKitProvider, defaultUiKit, defineUiKit, dress, extendUiKit, installUiKit, uiKitProblems, useComponentScope, usePopupHost, } from './UiKit.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { FieldFrame } from '../fieldFrame.js';
|
|
3
|
+
export declare function Frame({ label, hint, problem, required, labelHidden, optional, tip, reserve, kind, className, check, children, }: FieldFrame & {
|
|
4
|
+
check?: boolean;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The frame every form control stands in, from what it says of itself (../fieldFrame.tsx): the label over it, the
|
|
4
|
+
* mark that says required or the word that says optional beside the label (never in it, so the control's name is
|
|
5
|
+
* the same either way), a help tip (the one a form uses on its own, ./HelpTip.tsx), the hint, and the problem
|
|
6
|
+
* under it. `reserve` keeps the problem's line in the flow while it is empty, so a problem that arrives moves
|
|
7
|
+
* nothing below it.
|
|
8
|
+
*
|
|
9
|
+
* UI SDK's field is the root and does the wiring: its own parts inside (a text box, a listbox's button, a
|
|
10
|
+
* checkbox) read their id, their name, what describes them and `aria-invalid` from it, and the label finds its
|
|
11
|
+
* control whichever of them that is.
|
|
12
|
+
*
|
|
13
|
+
* A control that is not UI SDK's cannot read that field, so one is made the field's control part where it is drawn
|
|
14
|
+
* (`<FieldControl render={…} />`, as ../Choices.tsx does for its cards and ../FileField.tsx for the file input): the
|
|
15
|
+
* field then hands it its id and `aria-labelledby`, `aria-describedby` and `aria-invalid` as props, which is how a
|
|
16
|
+
* control kit's drawing of a slot hears them too.
|
|
17
|
+
*/
|
|
18
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from '@ui-sdk/react/field';
|
|
19
|
+
import { HelpTip } from './HelpTip.js';
|
|
20
|
+
export function Frame({ label, hint, problem, required, labelHidden, optional, tip, reserve = true, kind, className, check, children, }) {
|
|
21
|
+
const holdsProblem = problem !== undefined && problem !== null && problem !== false && problem !== '';
|
|
22
|
+
const name = (_jsxs("div", { "data-slot": "field-head", "data-kind": labelHidden ? 'visually-hidden' : undefined, children: [_jsx(FieldLabel, { children: label }), required ? (_jsx("span", { "data-slot": "field-required", "aria-hidden": "true", children: "*" })) : optional ? (_jsx("span", { "data-slot": "field-optional", children: optional })) : null, tip && _jsx(HelpTip, { ...tip })] }));
|
|
23
|
+
const lines = (_jsxs(_Fragment, { children: [hint && _jsx(FieldDescription, { children: hint }), holdsProblem ? _jsx(FieldError, { children: problem }) : reserve ? _jsx("p", { "data-slot": "field-reserve", "aria-hidden": "true" }) : null] }));
|
|
24
|
+
return (_jsx(Field, { invalid: holdsProblem ? true : undefined, className: className, "data-kind": check ? 'check' : undefined, "data-answer": kind, "data-required": required ? '' : undefined, children: check ? (_jsxs(_Fragment, { children: [children, _jsxs("div", { children: [name, lines] })] })) : (_jsxs(_Fragment, { children: [name, children, lines] })) }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The help tip's drawing (FormParts.tsx hands it out), in a module of its own: every field's frame draws one
|
|
4
|
+
* (./Frame.tsx), and a page with one field should not load the rest of a form's parts to do it.
|
|
5
|
+
*/
|
|
6
|
+
import { Tooltip as Note, TooltipContent, TooltipTrigger } from '@ui-sdk/react/tooltip';
|
|
7
|
+
import { useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { slotted } from './uiKitContext.js';
|
|
9
|
+
import { popupContainer, useDialogContainer } from './popups.js';
|
|
10
|
+
/* Help beside a label: a button that opens it, so it works under a finger and from the keyboard, and what it
|
|
11
|
+
says is the button's description while it is open. UI SDK's tooltip is the note (its role, its place by the
|
|
12
|
+
button, Escape), made to open on a press and stay; a press anywhere else closes it. */
|
|
13
|
+
function DefaultHelpTip({ text, label, icon }) {
|
|
14
|
+
const [open, setOpen] = useState(false);
|
|
15
|
+
const button = useRef(null);
|
|
16
|
+
// Drawn where the page's other layers are: inside an enclosing dialog, else where the page says its popups go.
|
|
17
|
+
const container = useDialogContainer(button);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!open)
|
|
20
|
+
return undefined;
|
|
21
|
+
const outside = (event) => {
|
|
22
|
+
if (!button.current?.contains(event.target))
|
|
23
|
+
setOpen(false);
|
|
24
|
+
};
|
|
25
|
+
document.addEventListener('pointerdown', outside);
|
|
26
|
+
return () => document.removeEventListener('pointerdown', outside);
|
|
27
|
+
}, [open]);
|
|
28
|
+
return (_jsxs(Note, { toggleable: true, open: open, onOpenChange: (next, details) => {
|
|
29
|
+
// Pointing at the button is not asking: the note opens on a press, as a finger has to open it.
|
|
30
|
+
if (next && details.reason !== 'trigger-press')
|
|
31
|
+
return details.cancel();
|
|
32
|
+
setOpen(next);
|
|
33
|
+
}, children: [_jsx(TooltipTrigger, { ref: button, "aria-label": label, "aria-expanded": open, "data-kind": "help-tip", children: icon ?? _jsx("span", { "aria-hidden": "true", children: "i" }) }), _jsx(TooltipContent, { render: _jsx("span", {}), "data-kind": "help-tip", side: "bottom", align: "start", sideOffset: 6, collisionPadding: 8, container: container ?? popupContainer(), children: text })] }));
|
|
34
|
+
}
|
|
35
|
+
/* The slot is made here, beside its default, so the frame that draws a field's tip draws the kit's where a kit has
|
|
36
|
+
one. FormParts.tsx hands the same component out. */
|
|
37
|
+
export const HelpTip = slotted('HelpTip', DefaultHelpTip);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the layers share (Modal, Drawer, Popover, Tooltip, DropMenu): the word a caller hears for why one opened or
|
|
3
|
+
* closed, and the caller's own element drawn as a layer's trigger.
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
6
|
+
import type { ChangeDetails } from '../changeDetails.js';
|
|
7
|
+
/** UI SDK's open-change details in this package's shape (changeDetails.ts). */
|
|
8
|
+
export declare function heard<Reason extends string>(said: {
|
|
9
|
+
reason?: string;
|
|
10
|
+
source?: string;
|
|
11
|
+
event?: unknown;
|
|
12
|
+
} | undefined): ChangeDetails<Reason>;
|
|
13
|
+
type Props = Record<string, unknown>;
|
|
14
|
+
/** The trigger is rendered as the trigger, not inside one: a button passed in would otherwise nest in a button. */
|
|
15
|
+
export declare const triggerElement: (trigger: ReactNode) => ReactElement<Props>;
|
|
16
|
+
/**
|
|
17
|
+
* The trigger with a part's props under its own, as UI SDK lays them, but for what describes it: a note is added to
|
|
18
|
+
* a description the trigger already had (a field's hint, a problem) and does not take its place.
|
|
19
|
+
*/
|
|
20
|
+
export declare const describedTrigger: (trigger: ReactNode) => (part: Props) => ReactElement<Props, string | import("react").JSXElementConstructor<any>>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* What the layers share (Modal, Drawer, Popover, Tooltip, DropMenu): the word a caller hears for why one opened or
|
|
4
|
+
* closed, and the caller's own element drawn as a layer's trigger.
|
|
5
|
+
*/
|
|
6
|
+
import { cloneElement, isValidElement } from 'react';
|
|
7
|
+
import { told } from './told.js';
|
|
8
|
+
/* Why a layer opened or closed, in the words callers already read: UI SDK's own word where it is one a callback's
|
|
9
|
+
type lists, `imperative-action` for a change the page made through the layer's handle, and `implicit` for a
|
|
10
|
+
change UI SDK has a word for that no caller reads (a parent closing, an unmount). */
|
|
11
|
+
const SHARED = new Set([
|
|
12
|
+
'trigger-hover',
|
|
13
|
+
'trigger-focus',
|
|
14
|
+
'trigger-press',
|
|
15
|
+
'outside-press',
|
|
16
|
+
'focus-out',
|
|
17
|
+
'list-navigation',
|
|
18
|
+
'escape-key',
|
|
19
|
+
'item-press',
|
|
20
|
+
'close-press',
|
|
21
|
+
'swipe',
|
|
22
|
+
]);
|
|
23
|
+
/** UI SDK's open-change details in this package's shape (changeDetails.ts). */
|
|
24
|
+
export function heard(said) {
|
|
25
|
+
const reason = said?.reason && SHARED.has(said.reason) ? said.reason : said?.reason === 'imperative' ? 'imperative-action' : 'implicit';
|
|
26
|
+
return told(reason, said);
|
|
27
|
+
}
|
|
28
|
+
/** The trigger is rendered as the trigger, not inside one: a button passed in would otherwise nest in a button. */
|
|
29
|
+
export const triggerElement = (trigger) => isValidElement(trigger) ? trigger : _jsx("button", { type: "button", children: trigger });
|
|
30
|
+
const bothRefs = (a, b) => (node) => {
|
|
31
|
+
for (const ref of [a, b]) {
|
|
32
|
+
if (typeof ref === 'function')
|
|
33
|
+
ref(node);
|
|
34
|
+
else if (ref)
|
|
35
|
+
ref.current = node;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The trigger with a part's props under its own, as UI SDK lays them, but for what describes it: a note is added to
|
|
40
|
+
* a description the trigger already had (a field's hint, a problem) and does not take its place.
|
|
41
|
+
*/
|
|
42
|
+
export const describedTrigger = (trigger) => (part) => {
|
|
43
|
+
const own = triggerElement(trigger);
|
|
44
|
+
const merged = { ...part };
|
|
45
|
+
for (const [key, value] of Object.entries(own.props)) {
|
|
46
|
+
const under = part[key];
|
|
47
|
+
if (value === undefined)
|
|
48
|
+
continue;
|
|
49
|
+
if (/^on[A-Z]/.test(key) && typeof under === 'function' && typeof value === 'function')
|
|
50
|
+
merged[key] = (...args) => {
|
|
51
|
+
value(...args);
|
|
52
|
+
// A handler of the caller's that prevents the event's default keeps the part's own from running.
|
|
53
|
+
if (!args[0]?.defaultPrevented)
|
|
54
|
+
under(...args);
|
|
55
|
+
};
|
|
56
|
+
else if (key === 'className' && under)
|
|
57
|
+
merged[key] = `${String(under)} ${String(value)}`;
|
|
58
|
+
else if (key === 'aria-describedby' && under)
|
|
59
|
+
merged[key] = `${String(value)} ${String(under)}`;
|
|
60
|
+
else if (key === 'ref' && under)
|
|
61
|
+
merged[key] = bothRefs(under, value);
|
|
62
|
+
else
|
|
63
|
+
merged[key] = value;
|
|
64
|
+
}
|
|
65
|
+
return cloneElement(own, merged);
|
|
66
|
+
};
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Where the primitives'
|
|
2
|
+
* Where the primitives' layers — a dialog, a menu, a listbox, a popover — are drawn.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* On the page: the document's body, unless a shell drawn inside another page (an embed) names its own container
|
|
5
|
+
* with `drawPopupsIn` (packages/mistri/src/embed/seams/shellHost.ts). UI SDK left to itself draws a layer where its
|
|
6
|
+
* trigger is, in the top layer, which looks the same and is not: a menu opened from a column's head is then inside
|
|
7
|
+
* the table and its keys go up through the grid's, a picker's form is a form inside the form its button stands in,
|
|
8
|
+
* a press on an option inside a label presses the label's control, and a dialog opened from a dialog is counted
|
|
9
|
+
* among the first one's fields. A layer opened inside a dialog is the exception, and is drawn in that dialog
|
|
10
|
+
* (`useDialogContainer`), so it shares the dialog's focus and is not made inert with the page behind it.
|
|
9
11
|
*/
|
|
10
|
-
/** The container handed to
|
|
12
|
+
/** The container handed to UI SDK's layers: the named one, else the page. */
|
|
11
13
|
export declare const popupContainer: () => HTMLElement | undefined;
|
|
12
14
|
/** Draw every popup in this container from now on. */
|
|
13
15
|
export declare function drawPopupsIn(where: () => HTMLElement | undefined): void;
|
|
14
16
|
/**
|
|
15
|
-
* The dialog a trigger stands in, read once it is mounted:
|
|
16
|
-
*
|
|
17
|
-
*
|
|
17
|
+
* The dialog a trigger stands in, read once it is mounted: its layer is drawn there and not on the page, so it
|
|
18
|
+
* shares the dialog's stacking context and focus trap rather than landing behind it, inert, on the body. A popover
|
|
19
|
+
* is a dialog too.
|
|
18
20
|
*/
|
|
19
21
|
export declare function useDialogContainer(trigger: {
|
|
20
22
|
current: Element | null;
|
package/dist/internal/popups.js
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Where the primitives'
|
|
2
|
+
* Where the primitives' layers — a dialog, a menu, a listbox, a popover — are drawn.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* On the page: the document's body, unless a shell drawn inside another page (an embed) names its own container
|
|
5
|
+
* with `drawPopupsIn` (packages/mistri/src/embed/seams/shellHost.ts). UI SDK left to itself draws a layer where its
|
|
6
|
+
* trigger is, in the top layer, which looks the same and is not: a menu opened from a column's head is then inside
|
|
7
|
+
* the table and its keys go up through the grid's, a picker's form is a form inside the form its button stands in,
|
|
8
|
+
* a press on an option inside a label presses the label's control, and a dialog opened from a dialog is counted
|
|
9
|
+
* among the first one's fields. A layer opened inside a dialog is the exception, and is drawn in that dialog
|
|
10
|
+
* (`useDialogContainer`), so it shares the dialog's focus and is not made inert with the page behind it.
|
|
9
11
|
*/
|
|
10
|
-
import {
|
|
12
|
+
import { useLayoutEffect, useState } from 'react';
|
|
11
13
|
let container = () => undefined;
|
|
12
|
-
/** The container handed to
|
|
13
|
-
export const popupContainer = () => container();
|
|
14
|
+
/** The container handed to UI SDK's layers: the named one, else the page. */
|
|
15
|
+
export const popupContainer = () => container() ?? (typeof document === 'undefined' ? undefined : document.body);
|
|
14
16
|
/** Draw every popup in this container from now on. */
|
|
15
17
|
export function drawPopupsIn(where) {
|
|
16
18
|
container = where;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
|
-
* The dialog a trigger stands in, read once it is mounted:
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* The dialog a trigger stands in, read once it is mounted: its layer is drawn there and not on the page, so it
|
|
22
|
+
* shares the dialog's stacking context and focus trap rather than landing behind it, inert, on the body. A popover
|
|
23
|
+
* is a dialog too.
|
|
22
24
|
*/
|
|
23
25
|
export function useDialogContainer(trigger) {
|
|
24
26
|
const [dialog, setDialog] = useState(null);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
/* Before the first paint: a control that opens as it mounts (a cell's editor) would otherwise draw its list on
|
|
28
|
+
the page and then again in the dialog, and whoever held an option from the first drawing held nothing. */
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
setDialog(trigger.current?.closest('dialog, [role="dialog"]') ?? null);
|
|
27
31
|
}, [trigger]);
|
|
28
32
|
return dialog;
|
|
29
33
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What UI SDK says of a change, in the words every caller here reads second (changeDetails.ts): the primitive's own
|
|
3
|
+
* reason, the hand that did it, and the DOM event where there was one. UI SDK names more hands than a caller does
|
|
4
|
+
* (a pen, a touch, a screen reader's virtual click, an agent); to a caller each is a pointer or the page itself.
|
|
5
|
+
*/
|
|
6
|
+
import { type ChangeDetails } from '../changeDetails.js';
|
|
7
|
+
/** The part of UI SDK's change details this reads. */
|
|
8
|
+
type Said = {
|
|
9
|
+
source?: string;
|
|
10
|
+
event?: unknown;
|
|
11
|
+
} | undefined;
|
|
12
|
+
/** UI SDK's details in this package's shape, under the reason the primitive gives its callers. */
|
|
13
|
+
export declare function told<Reason extends string>(reason: Reason, said: Said): ChangeDetails<Reason>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What UI SDK says of a change, in the words every caller here reads second (changeDetails.ts): the primitive's own
|
|
3
|
+
* reason, the hand that did it, and the DOM event where there was one. UI SDK names more hands than a caller does
|
|
4
|
+
* (a pen, a touch, a screen reader's virtual click, an agent); to a caller each is a pointer or the page itself.
|
|
5
|
+
*/
|
|
6
|
+
import { changeSource } from '../changeDetails.js';
|
|
7
|
+
/** UI SDK's details in this package's shape, under the reason the primitive gives its callers. */
|
|
8
|
+
export function told(reason, said) {
|
|
9
|
+
const event = typeof Event !== 'undefined' && said?.event instanceof Event ? said.event : undefined;
|
|
10
|
+
/* UI SDK calls an event a script sent `programmatic`. The rule here is that a change with an event behind it came
|
|
11
|
+
from a hand, and only a change with none is the page's, so the event is read for its hand as any other is. */
|
|
12
|
+
const source = said?.source === 'keyboard'
|
|
13
|
+
? 'keyboard'
|
|
14
|
+
: !said || said.source === 'agent'
|
|
15
|
+
? 'program'
|
|
16
|
+
: said.source === 'programmatic'
|
|
17
|
+
? changeSource(event)
|
|
18
|
+
: 'pointer';
|
|
19
|
+
return event ? { reason, source, event } : { reason, source };
|
|
20
|
+
}
|
|
@@ -29,7 +29,8 @@ export function slotted(name, Default, fills) {
|
|
|
29
29
|
return createElement(Kit ?? Default, Kit && fills ? filled(props, fills, latest, wrappers.current) : props);
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
/* A kit may call a change callback with the value alone, or with details of its own that name no hand (
|
|
32
|
+
/* A kit may call a change callback with the value alone, or with details of its own that name no hand (a kit built over
|
|
33
|
+
Base UI passes Base UI's); every
|
|
33
34
|
caller reads `{ reason, source }` second, so the seam fills in what is missing. Only under a kit: the defaults always
|
|
34
35
|
give them. A wrapper's identity is stable, so a kit that puts the callback in an effect's dependencies does not rerun it
|
|
35
36
|
on every render. */
|
|
@@ -50,8 +51,9 @@ function filled(props, fills, latest, wrappers) {
|
|
|
50
51
|
}
|
|
51
52
|
return out;
|
|
52
53
|
}
|
|
53
|
-
/* Details as the kit gave them, a hand and a word added where they lack one. A raw `none` is
|
|
54
|
-
|
|
54
|
+
/* Details as the kit gave them, a hand and a word added where they lack one. A raw `none` is what a kit built over
|
|
55
|
+
Base UI passes for a change Base UI does not name, and no caller hears it. Filled in place where it can be: such
|
|
56
|
+
details carry `cancel()` and an `isCanceled` that must stay live. */
|
|
55
57
|
function withSource(given, reason) {
|
|
56
58
|
const kept = keptDetails(reason);
|
|
57
59
|
if (typeof given !== 'object' || given === null)
|
|
@@ -60,7 +62,7 @@ function withSource(given, reason) {
|
|
|
60
62
|
if (details.source !== undefined)
|
|
61
63
|
return given;
|
|
62
64
|
const word = typeof details.reason === 'string' && details.reason !== 'none' ? details.reason : reason;
|
|
63
|
-
// Base UI's stand-in event, named `base-ui`, says the page made the change (changeDetails.ts).
|
|
65
|
+
// Under such a kit, Base UI's stand-in event, named `base-ui`, says the page made the change (changeDetails.ts).
|
|
64
66
|
const source = details.event instanceof Event ? (details.event.type === 'base-ui' ? 'program' : changeSource(details.event)) : kept.source;
|
|
65
67
|
if (!Object.isExtensible(given))
|
|
66
68
|
return { ...details, reason: word, source };
|
package/dist/preferences.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* @mistriwork/ui's answers to the reader's own settings: more contrast, and less transparency. Apart from
|
|
2
|
-
|
|
1
|
+
/* @mistriwork/ui's answers to the reader's own settings: more contrast, and less transparency. Apart from controls.css, whose
|
|
2
|
+
sheets say nothing !important but in the same cause (styles/preferences.css): this one is, on purpose. A worn theme writes its colours on the root as
|
|
3
3
|
inline custom properties, which nothing but !important beats, and the reader's setting must beat the theme's. Loaded
|
|
4
4
|
beside the form controls (formControls.css) because the first stylesheet has no bytes to spare for it; a page that
|
|
5
5
|
draws no control keeps its themed ink and scrims. Moving it to tokens.css costs about 0.5 KB raw there. */
|
|
@@ -22,5 +22,4 @@
|
|
|
22
22
|
--scrim-light: color-mix(in srgb, black 45%, var(--ground)) !important;
|
|
23
23
|
--lightbox-ground: rgb(10 12 16) !important;
|
|
24
24
|
}
|
|
25
|
-
.modal-backdrop { background: var(--scrim-light); }
|
|
26
25
|
}
|
package/dist/style.css
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
/* @mistriwork/ui's stylesheet, for a page drawn with the primitives alone: the tokens, the
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
controls' rules (forms.css) and the hero blocks' (hero.css) wait there for the first control a page draws. */
|
|
1
|
+
/* @mistriwork/ui's stylesheet, for a page drawn with the primitives alone: the tokens, what the controls wear, and
|
|
2
|
+
the answers to the reader's own settings. All of it stands in the `mistri-ui` layer, so any rule of the page's own,
|
|
3
|
+
in a later layer or in none, wins over it. The kit's stylesheet takes tokens.css and controls.css into its base
|
|
4
|
+
layer instead (packages/kit/src/client/style.css says why). */
|
|
6
5
|
@layer mistri-ui;
|
|
7
6
|
@import './tokens.css' layer(mistri-ui);
|
|
8
|
-
@import './
|
|
9
|
-
@import './standalone.css' layer(mistri-ui);
|
|
10
|
-
@import './forms.css' layer(mistri-ui);
|
|
11
|
-
@import './hero.css' layer(mistri-ui);
|
|
7
|
+
@import './controls.css' layer(mistri-ui);
|
|
12
8
|
@import './preferences.css' layer(mistri-ui);
|
|
13
|
-
|
|
14
|
-
@layer mistri-ui {
|
|
15
|
-
.btn { border: 1px solid transparent; border-radius: var(--radius); background: var(--accent); color: var(--on-accent); cursor: pointer; }
|
|
16
|
-
.btn.btn-secondary { background: transparent; color: var(--ink-muted); border-color: var(--line-strong); }
|
|
17
|
-
.btn.btn-danger { background: var(--status-critical); color: var(--surface); border-color: var(--status-critical); }
|
|
18
|
-
.btn:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
|
|
19
|
-
}
|