@mistriwork/ui 1.0.0-rc.58 → 1.0.0-rc.59

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.
Files changed (122) hide show
  1. package/README.md +46 -12
  2. package/dist/Avatar.js +3 -3
  3. package/dist/Button.d.ts +4 -14
  4. package/dist/Button.js +26 -13
  5. package/dist/Carousel.d.ts +6 -5
  6. package/dist/Carousel.js +58 -67
  7. package/dist/Choices.d.ts +2 -9
  8. package/dist/Choices.js +127 -64
  9. package/dist/DateField.d.ts +9 -4
  10. package/dist/DateField.js +102 -119
  11. package/dist/Drawer.d.ts +1 -19
  12. package/dist/Drawer.js +8 -9
  13. package/dist/DropMenu.d.ts +8 -21
  14. package/dist/DropMenu.js +84 -30
  15. package/dist/Dropdown.d.ts +9 -8
  16. package/dist/Dropdown.js +69 -65
  17. package/dist/Field.d.ts +2 -1
  18. package/dist/Field.js +12 -18
  19. package/dist/FileField.d.ts +3 -10
  20. package/dist/FileField.js +12 -9
  21. package/dist/FormParts.d.ts +17 -10
  22. package/dist/FormParts.js +26 -41
  23. package/dist/HeroBlocks.d.ts +7 -3
  24. package/dist/HeroBlocks.js +11 -6
  25. package/dist/Modal.d.ts +6 -17
  26. package/dist/Modal.js +90 -21
  27. package/dist/Pagination.d.ts +1 -12
  28. package/dist/Pagination.js +17 -3
  29. package/dist/Popover.d.ts +1 -15
  30. package/dist/Popover.js +10 -15
  31. package/dist/Resizable.d.ts +3 -21
  32. package/dist/Resizable.js +14 -91
  33. package/dist/ScrollArea.d.ts +4 -2
  34. package/dist/ScrollArea.js +11 -11
  35. package/dist/Select.d.ts +1 -6
  36. package/dist/Select.js +16 -7
  37. package/dist/SensitiveField.d.ts +1 -8
  38. package/dist/SensitiveField.js +6 -4
  39. package/dist/Slider.d.ts +1 -5
  40. package/dist/Slider.js +13 -5
  41. package/dist/Switch.d.ts +1 -11
  42. package/dist/Switch.js +10 -9
  43. package/dist/Tabs.d.ts +3 -3
  44. package/dist/Tabs.js +3 -3
  45. package/dist/TextArea.d.ts +4 -6
  46. package/dist/TextArea.js +14 -5
  47. package/dist/TextField.d.ts +5 -9
  48. package/dist/TextField.js +67 -9
  49. package/dist/Tooltip.d.ts +1 -21
  50. package/dist/Tooltip.js +13 -31
  51. package/dist/Typeahead.d.ts +15 -18
  52. package/dist/Typeahead.js +151 -86
  53. package/dist/UiKit.d.ts +63 -4
  54. package/dist/UiKit.js +46 -5
  55. package/dist/behaviors/DaysParts.js +28 -0
  56. package/dist/behaviors/EditableParts.js +21 -0
  57. package/dist/behaviors/PickParts.js +30 -0
  58. package/dist/behaviors/ScrubParts.js +21 -0
  59. package/dist/behaviors/SortableParts.js +32 -0
  60. package/dist/behaviors/SpansParts.js +12 -0
  61. package/dist/behaviors/TransferParts.js +37 -0
  62. package/dist/behaviors/TurnsParts.js +31 -0
  63. package/dist/behaviors/WidthsParts.js +27 -0
  64. package/dist/behaviors/days.js +216 -0
  65. package/dist/behaviors/dress.js +86 -0
  66. package/dist/behaviors/editable.js +104 -0
  67. package/dist/behaviors/heard.js +22 -0
  68. package/dist/behaviors/index.d.ts +310 -0
  69. package/dist/behaviors/index.js +44 -0
  70. package/dist/behaviors/pick.js +158 -0
  71. package/dist/behaviors/scrub.js +152 -0
  72. package/dist/behaviors/sortable.js +170 -0
  73. package/dist/behaviors/spans.js +240 -0
  74. package/dist/behaviors/testing.js +48 -0
  75. package/dist/behaviors/transfer.js +202 -0
  76. package/dist/behaviors/turns.js +106 -0
  77. package/dist/behaviors/widths.js +150 -0
  78. package/dist/behaviors.css +309 -0
  79. package/dist/changeDetails.d.ts +4 -8
  80. package/dist/changeDetails.js +0 -6
  81. package/dist/conformance.js +107 -1
  82. package/dist/controls.css +36 -0
  83. package/dist/fieldFrame.d.ts +2 -15
  84. package/dist/fieldFrame.js +1 -17
  85. package/dist/index.d.ts +6 -5
  86. package/dist/index.js +6 -5
  87. package/dist/internal/Frame.d.ts +6 -0
  88. package/dist/internal/Frame.js +25 -0
  89. package/dist/internal/HelpTip.d.ts +5 -0
  90. package/dist/internal/HelpTip.js +37 -0
  91. package/dist/internal/layers.d.ts +21 -0
  92. package/dist/internal/layers.js +66 -0
  93. package/dist/internal/popups.d.ts +12 -10
  94. package/dist/internal/popups.js +18 -14
  95. package/dist/internal/told.d.ts +14 -0
  96. package/dist/internal/told.js +20 -0
  97. package/dist/internal/uiKitContext.js +6 -4
  98. package/dist/preferences.css +2 -3
  99. package/dist/style.css +5 -16
  100. package/dist/styles/extras.css +461 -0
  101. package/dist/styles/forms.css +346 -0
  102. package/dist/styles/guard.css +114 -0
  103. package/dist/styles/kit-fields.css +181 -0
  104. package/dist/styles/kit-parts.css +130 -0
  105. package/dist/styles/kit.css +558 -0
  106. package/dist/styles/layers.css +4 -0
  107. package/dist/styles/looks.css +374 -0
  108. package/dist/styles/m-tokens.css +173 -0
  109. package/dist/styles/overlays.css +107 -0
  110. package/dist/styles/parts.css +456 -0
  111. package/dist/styles/screens.css +76 -0
  112. package/dist/styles/ui-sdk.css +1635 -0
  113. package/dist/tokens.css +15 -4
  114. package/dist/uiKitSlots.d.ts +1 -1
  115. package/dist/uiKitSlots.js +18 -2
  116. package/package.json +13 -11
  117. package/dist/forms.css +0 -225
  118. package/dist/hero.css +0 -23
  119. package/dist/internal/anchor.d.ts +0 -19
  120. package/dist/internal/anchor.js +0 -52
  121. package/dist/primitives.css +0 -200
  122. package/dist/standalone.css +0 -478
@@ -0,0 +1,86 @@
1
+ /* A carried copy is drawn on the page's top layer, outside the thing it was lifted from and outside whatever that
2
+ thing is in. A host that keeps a page's styles to the page (mistri scopes a page's sheet to the page's own
3
+ element) leaves the copy bare there: a card's name turns into a blue link and its parts fall into a heap. So
4
+ what each part looks like is written onto its copy as the copy leaves. UI SDK does this for the copy itself, for
5
+ the few properties a box has; these are the ones a layout adds, and everything for the parts inside. A
6
+ pseudo-element cannot be written this way and is missing from the copy. */
7
+ const BOX = ['display', 'grid-template-columns', 'row-gap', 'column-gap', 'align-items', 'color', 'font-family', 'font-size'];
8
+ function dress(from, to, whole = false) {
9
+ if (to instanceof HTMLElement || to instanceof SVGElement) {
10
+ const computed = getComputedStyle(from);
11
+ for (const name of whole ? computed : BOX)
12
+ to.style.setProperty(name, computed.getPropertyValue(name));
13
+ }
14
+ for (let at = 0; at < from.children.length; at += 1) {
15
+ const child = to.children[at];
16
+ if (child)
17
+ dress(from.children[at], child, true);
18
+ }
19
+ }
20
+ /* How much the page around an element is zoomed: what it measures on the screen over what it is laid out at. A
21
+ host may zoom its root (mistri does, for density: 1.12 at its default), and under a zoom a pointer's pixels and
22
+ the stylesheet's are not the same pixels, which every drag has to answer for. */
23
+ export function zoomOf(el) {
24
+ const laid = el.offsetWidth;
25
+ const zoom = laid ? el.getBoundingClientRect().width / laid : 1;
26
+ return Math.abs(zoom - 1) < 0.005 ? 1 : zoom;
27
+ }
28
+ /* Puts a carried copy right under a zoom. UI SDK places the copy and moves it in the screen's pixels, and the copy
29
+ stands inside the zoomed page, so it is drawn larger than what it copies by the zoom and runs ahead of the
30
+ pointer by the zoom: at mistri's widest density a card stood a hand's width from the pointer carrying it. The
31
+ copy is therefore taken back out of the zoom (so the place and the size UI SDK gave it are true), and what it
32
+ holds is put in a box that is zoomed again and wears the source's own look, so the card is the size it was. */
33
+ function unzoom(source, copy) {
34
+ const zoom = zoomOf(source);
35
+ if (zoom === 1)
36
+ return;
37
+ const inner = source.ownerDocument.createElement('div');
38
+ const look = getComputedStyle(source);
39
+ for (const name of look)
40
+ inner.style.setProperty(name, look.getPropertyValue(name));
41
+ Object.assign(inner.style, {
42
+ position: 'static',
43
+ boxSizing: 'border-box',
44
+ width: `${source.offsetWidth}px`,
45
+ height: `${source.offsetHeight}px`,
46
+ margin: '0',
47
+ translate: 'none',
48
+ rotate: 'none',
49
+ transform: 'none',
50
+ opacity: '1',
51
+ zoom: String(zoom),
52
+ });
53
+ while (copy.firstChild)
54
+ inner.append(copy.firstChild);
55
+ copy.append(inner);
56
+ Object.assign(copy.style, {
57
+ display: 'block',
58
+ padding: '0',
59
+ border: '0',
60
+ background: 'none',
61
+ borderRadius: `${parseFloat(look.borderTopLeftRadius) * zoom}px`,
62
+ zoom: String(1 / zoom),
63
+ });
64
+ }
65
+ /* Dresses the copy UI SDK's own drags make (`createReorder` with a preview, `createTransfer`), which appears on the
66
+ body some pixels after the press. Watches from the press until the pointer lifts, and returns the way to stop. */
67
+ export function dressCopyOf(source) {
68
+ const page = source.ownerDocument;
69
+ const seen = new MutationObserver((changes) => {
70
+ for (const change of changes)
71
+ for (const added of change.addedNodes)
72
+ if (added instanceof HTMLElement && added.hasAttribute('data-drag-preview')) {
73
+ dress(source, added);
74
+ unzoom(source, added);
75
+ }
76
+ });
77
+ const stop = () => {
78
+ seen.disconnect();
79
+ page.removeEventListener('pointerup', stop, true);
80
+ page.removeEventListener('pointercancel', stop, true);
81
+ };
82
+ seen.observe(page.body, { childList: true });
83
+ page.addEventListener('pointerup', stop, true);
84
+ page.addEventListener('pointercancel', stop, true);
85
+ return stop;
86
+ }
@@ -0,0 +1,104 @@
1
+ /* Values edited where they stand, as a UI SDK primitive over the inline edit `@ui-sdk/core` ships: one of a set
2
+ of values is being edited at a time, a box takes its place, Enter and Tab keep what was typed and Escape puts
3
+ the value back. A value is started on by Enter, F2, typing over it or a double press, and by a single press
4
+ where the composer says so (a record's value, which is nothing but its value; a table's cell is also a place
5
+ to select text and to open its row from, so there it takes two).
6
+
7
+ Tab keeps and goes on to the next value in the page's order, Shift with Tab to the one before, as a
8
+ spreadsheet does, so a row is filled in without the hand leaving the keys. What is kept is asked of the
9
+ composer, which may refuse it (`onCommit` returning false): the box then stays, with what was typed. */
10
+ import { createInlineEdit, definePrimitive } from '@ui-sdk/core';
11
+ const VALUE = '[data-slot="editable-value"]';
12
+ export const editable = definePrimitive({
13
+ name: 'editable',
14
+ options: {
15
+ text: 'action',
16
+ onCommit: 'action',
17
+ onCancel: 'callback',
18
+ locked: 'action',
19
+ },
20
+ state: (_options) => ({ editing: null }),
21
+ api: (context) => {
22
+ const edit = createInlineEdit(context, {
23
+ key: 'editing',
24
+ value: (id) => context.options().text?.(id) ?? '',
25
+ commit: (id, text, details) => context.options().onCommit?.(id, text, details) !== false,
26
+ disabled: (id) => context.options().locked?.(id) ?? false,
27
+ });
28
+ return {
29
+ edit,
30
+ locked: (id) => context.options().locked?.(id) ?? false,
31
+ now: () => context.store.get(),
32
+ canceled: (id) => context.options().onCancel?.(id),
33
+ /* The value after this one in the page's order (or before it) that can be edited, started on. */
34
+ onward(from, id, by, event) {
35
+ const root = from.closest('[data-slot="editable"]');
36
+ if (!root)
37
+ return false;
38
+ const values = [...root.querySelectorAll(VALUE)].filter((value) => !value.hasAttribute('data-locked'));
39
+ const at = values.findIndex((value) => value.dataset.editId === id);
40
+ const next = values[at + by]?.dataset.editId;
41
+ return at >= 0 && next !== undefined && edit.start(next, { reason: 'tab-key', event });
42
+ },
43
+ };
44
+ },
45
+ slots: (slot) => ({
46
+ root: slot({
47
+ state: (state) => ({ editing: state.editing }),
48
+ attrs: (state) => ({ 'data-editing': state.editing === null ? undefined : '' }),
49
+ }),
50
+ /* Where a value stands, whether it is shown or being edited. */
51
+ value: slot({
52
+ props: { value: 'string', press: 'boolean' },
53
+ state: (state, part) => ({ editing: state.editing === part.key }),
54
+ attrs: (state, part) => ({
55
+ 'data-edit-id': part.key,
56
+ 'data-editing': state.editing === part.key ? '' : undefined,
57
+ 'data-locked': part.api.locked(part.key) ? '' : undefined,
58
+ }),
59
+ on: {
60
+ keydown: (event, { api, key, el }) => {
61
+ // A key in the box is the box's; only one on the value itself starts an edit.
62
+ if (event.target !== el || api.now().editing === key)
63
+ return;
64
+ api.edit.keydown(event, key);
65
+ },
66
+ dblclick: (event, { api, key }) => {
67
+ if (api.now().editing !== key)
68
+ api.edit.dblclick(event, key);
69
+ },
70
+ click: (event, { api, key, props }) => {
71
+ if (!props.press || api.now().editing === key)
72
+ return;
73
+ if (event.target.closest('a, button, input'))
74
+ return;
75
+ api.edit.start(key, { reason: 'double-click', event });
76
+ },
77
+ },
78
+ }),
79
+ input: slot({
80
+ on: {
81
+ keydown: (event, { api, el }) => {
82
+ const id = api.now().editing;
83
+ const tab = event.key === 'Tab';
84
+ const escape = event.key === 'Escape';
85
+ // Escape is this box's alone: a sheet around it does not also close.
86
+ if (escape)
87
+ event.stopPropagation();
88
+ const handled = api.edit.inputKeydown(event);
89
+ if (id === null || !el)
90
+ return;
91
+ if (escape)
92
+ api.canceled(id);
93
+ // With no value to go on to, Tab is the page's own and moves to whatever is next.
94
+ else if (handled && tab && api.now().editing === null && api.onward(el, id, event.shiftKey ? -1 : 1, event))
95
+ event.preventDefault();
96
+ },
97
+ focusout: (event, { api }) => {
98
+ api.edit.end('focus-out', event);
99
+ },
100
+ },
101
+ bind: (el, part) => part.api.edit.bindInput(el),
102
+ }),
103
+ }),
104
+ });
@@ -0,0 +1,22 @@
1
+ import { told } from '../internal/told.js';
2
+ /* The details stand behind the ones handed on, so a field a behavior adds is read through, and `canceled` is asked
3
+ of UI SDK when it is read and not copied when the callback starts. */
4
+ function change(said) {
5
+ const ours = told(said.reason, said);
6
+ return Object.create(said, {
7
+ source: { value: ours.source, enumerable: true },
8
+ cancel: { value: () => said.cancel?.(), enumerable: true },
9
+ canceled: { get: () => said.canceled === true, enumerable: true },
10
+ });
11
+ }
12
+ /**
13
+ * A root's change callbacks, each hearing this package's details. Only the ones a caller gave are returned, so a root
14
+ * is not told of a callback that is not there.
15
+ */
16
+ export function heard(callbacks) {
17
+ const out = {};
18
+ for (const [name, callback] of Object.entries(callbacks))
19
+ if (callback)
20
+ out[name] = (value, said) => callback(value, change(said));
21
+ return out;
22
+ }
@@ -0,0 +1,310 @@
1
+ /**
2
+ * `@mistriwork/mistri/behaviors`: the behaviors a custom component is built on.
3
+ *
4
+ * A behavior is roles, keys, announcements and `data-*` on parts the component dresses itself: none draws anything.
5
+ * Each part takes what its element takes, with three props every part shares: `render` (your own element, or a
6
+ * function of the props and the part's state), and `className` and `style`, which may be functions of that state.
7
+ * A part carries `data-slot` (`sortable-item`, `transfer-list`, …) and says its state as attributes
8
+ * (`data-dragging`, `data-over`), which is what a component's stylesheet reads.
9
+ *
10
+ * A root's `onValueChange` hears the value and then why it changed: `reason`, the hand (`source`: a pointer, the
11
+ * keyboard, or the page itself), the DOM `event` where there was one, and `cancel()`, which leaves the value as it
12
+ * was. A root given `value` is controlled: it shows what it is given and asks for the change.
13
+ *
14
+ * The page fetches this module the first time a component imports it, so it adds nothing to an App that builds
15
+ * nothing on it. @preview
16
+ */
17
+ import type * as ReactTypes from 'react';
18
+
19
+ /** Why a value changed and what changed it, with the way to refuse the change. */
20
+ export type Change<Reason extends string = string, More = unknown> = {
21
+ reason: Reason;
22
+ /** The hand: a pointer, the keyboard, or the page itself (a change with no event behind it). */
23
+ source: 'pointer' | 'keyboard' | 'program';
24
+ event?: Event;
25
+ /** Leaves the value as it was. */
26
+ cancel: () => void;
27
+ readonly canceled: boolean;
28
+ } & More;
29
+
30
+ /** What every part takes beside its element's own attributes. */
31
+ export type PartProps<Tag extends keyof ReactTypes.JSX.IntrinsicElements, State = {}> = Omit<
32
+ ReactTypes.ComponentProps<Tag>,
33
+ 'className' | 'style' | 'children'
34
+ > & {
35
+ className?: string | ((state: State) => string | undefined);
36
+ style?: ReactTypes.CSSProperties | ((state: State) => ReactTypes.CSSProperties | undefined);
37
+ /** Your own element, which receives the part's props, or a function of the props and the part's state. */
38
+ render?: ReactTypes.ReactElement<Record<string, unknown>> | ((props: Record<string, unknown>, state: State) => ReactTypes.ReactElement);
39
+ children?: ReactTypes.ReactNode | ((state: State) => ReactTypes.ReactNode);
40
+ };
41
+
42
+ /* Without this a declaration file exports every name in it; `Part` is how the parts below are written, not one of them. */
43
+ export {};
44
+
45
+ type Part<Tag extends keyof ReactTypes.JSX.IntrinsicElements, Props = {}, State = {}> = (
46
+ props: PartProps<Tag, State> & Props,
47
+ ) => ReactTypes.ReactElement | null;
48
+
49
+ /* ---------- a list whose order is the reader's ---------- */
50
+
51
+ export type SortableReason = 'drag' | 'move-key' | 'imperative';
52
+ export interface SortableProps extends Omit<PartProps<'div', { order: string[]; moving: string | null }>, 'children' | 'defaultValue'> {
53
+ /** The order, as the items' keys. */
54
+ value?: string[];
55
+ defaultValue?: string[];
56
+ onValueChange?: (value: string[], details: Change<SortableReason>) => void;
57
+ orientation?: 'vertical' | 'horizontal' | 'grid';
58
+ /** What an item is picked up by: itself (the default), or the handle inside it, for an item with controls of its own. */
59
+ by?: 'item' | 'handle';
60
+ /** Carries a copy over the page while the item shows where it would land: for a list inside something that scrolls or clips. */
61
+ preview?: boolean;
62
+ /** How one item is drawn; the root draws them in the order they stand in now. */
63
+ children: (key: string, at: number) => ReactTypes.ReactNode;
64
+ }
65
+ /** The list. Space picks an item up, the arrows place it, Escape puts it back; a pointer drags it. `data-sorting`. */
66
+ export function Sortable(props: SortableProps): ReactTypes.ReactElement | null;
67
+ /** One item. `data-grabbed`, `data-dragging`, `data-disabled`. */
68
+ export const SortableItem: Part<'div', { value: string; disabled?: boolean }, { grabbed: boolean }>;
69
+ /** The button an item is picked up by, where the root says `by="handle"`. It takes its item's `value` from the item around it. */
70
+ export const SortableHandle: Part<'button', { value?: string }, { grabbed: boolean }>;
71
+
72
+ /* ---------- things carried between lists ---------- */
73
+
74
+ export type TransferReason = 'drag' | 'move-key' | 'imperative';
75
+ /** What moved: the item, the list it left, the list it is in, and its place there. */
76
+ export type TransferMove = { key: string; from: string; to: string; index: number };
77
+ export type TransferListState = { keys: string[]; over: boolean; takes: boolean; refuses: boolean; carrying: string | null };
78
+ export interface TransferProps extends Omit<PartProps<'div', { carrying: string | null }>, 'defaultValue'> {
79
+ /** Every list by its name, each the keys of its items in order. A key is in one list. */
80
+ value?: Record<string, string[]>;
81
+ defaultValue?: Record<string, string[]>;
82
+ onValueChange?: (value: Record<string, string[]>, details: Change<TransferReason, TransferMove>) => void;
83
+ /** Whether a list would take an item. Every list takes every item unless this says otherwise. */
84
+ accepts?: (key: string, list: string) => boolean;
85
+ /** The lists in the order the keyboard travels them: the order they are drawn in. */
86
+ order?: string[];
87
+ /** What a screen reader calls an item and a list, where their keys are not their names. */
88
+ label?: (key: string) => string | undefined;
89
+ listLabel?: (list: string) => string | undefined;
90
+ }
91
+ /** The lists together. `data-carrying` while something is carried. */
92
+ export function Transfer(props: TransferProps): ReactTypes.ReactElement | null;
93
+ /** One list. `data-over` under what is carried, `data-takes` or `data-refuses` by whether it would take it. */
94
+ export function TransferList(
95
+ props: Omit<PartProps<'ul', TransferListState>, 'children'> & {
96
+ value: string;
97
+ children: (key: string, at: number) => ReactTypes.ReactNode;
98
+ /** Draws something round the items (an empty list's words) from the list's state. */
99
+ around?: (items: ReactTypes.ReactNode, state: TransferListState) => ReactTypes.ReactNode;
100
+ },
101
+ ): ReactTypes.ReactElement | null;
102
+ /** One item. `data-carried`, `data-dragging`. */
103
+ export const TransferItem: Part<'li', { value: string }, { carried: boolean }>;
104
+ /** The button an item is carried by with the keyboard or a finger. */
105
+ export const TransferHandle: Part<'button', { value?: string }, { carried: boolean }>;
106
+
107
+ /* ---------- a month of days a keyboard walks ---------- */
108
+
109
+ export type DaysReason = 'move-key' | 'focus-in' | 'imperative';
110
+ export interface DaysProps extends Omit<PartProps<'div', { month: string; day: string; weeks: string[][] }>, 'children' | 'defaultValue'> {
111
+ /** The day the keyboard is on, as `2026-11-14`. */
112
+ value?: string;
113
+ defaultValue?: string;
114
+ onValueChange?: (day: string, details: Change<DaysReason>) => void;
115
+ /** The month in view, as `2026-11`. */
116
+ month?: string;
117
+ defaultMonth?: string;
118
+ onMonthChange?: (month: string, details: Change<DaysReason>) => void;
119
+ /** The first day of a week: 1 is Monday, 0 Sunday. */
120
+ weekStart?: number;
121
+ /** The day that is today, for a page that knows it in its own zone; else the reader's. */
122
+ today?: string;
123
+ min?: string;
124
+ max?: string;
125
+ /** A day the reader may not pick: it is still walked over, and said to be unavailable. */
126
+ unavailable?: (day: string) => boolean;
127
+ /** Enter or Space on a day, or a press on it where `press` is set. */
128
+ onPick?: (day: string, event: Event) => void;
129
+ press?: boolean;
130
+ children: (state: { month: string; day: string; weeks: string[][] }) => ReactTypes.ReactNode;
131
+ }
132
+ /** The grid: one Tab stop; arrows by day and week, Home and End to the week's edges, Page Up and Down by month. `data-month`. */
133
+ export function Days(props: DaysProps): ReactTypes.ReactElement | null;
134
+ /** One day. `data-day`, `data-outside` (another month's), `data-today`. */
135
+ export const DaysDay: Part<'div', { value: string }>;
136
+ /** A day as a date at midnight UTC. A day is said as `2026-11-14`, in no zone. */
137
+ export function dayAt(day: string): Date;
138
+ export function addDays(day: string, by: number): string;
139
+ export function monthOf(day: string): string;
140
+ export function addMonths(month: string, by: number): string;
141
+ /** The same day of the month in another month, held to that month's last day. */
142
+ export function inMonth(day: string, month: string): string;
143
+ /** Today where the reader is. */
144
+ export function localToday(): string;
145
+ /** A month's weeks, each seven days, from the days of the months beside it where a week runs over. */
146
+ export function weeksOf(month: string, weekStart: number): string[][];
147
+
148
+ /* ---------- stretches along tracks ---------- */
149
+
150
+ /** A stretch: the track it is on and where it starts and ends, in the track's own units. */
151
+ export type Span = { id: string; track: string; start: number; end: number };
152
+ export type SpansReason = 'drag' | 'move-key' | 'remove-press' | 'imperative';
153
+ export type SpanAction = 'draw' | 'move' | 'resize' | 'delete';
154
+ export interface SpansProps extends Omit<PartProps<'div', { spans: Span[]; changing: string | null }>, 'defaultValue'> {
155
+ value?: Span[];
156
+ defaultValue?: Span[];
157
+ onValueChange?: (value: Span[], details: Change<SpansReason, { id: string; action: SpanAction }>) => void;
158
+ /** Where a track starts and ends, and what a start and an end snap to. */
159
+ min?: number;
160
+ max?: number;
161
+ step?: number;
162
+ minSize?: number;
163
+ /** Which way tracks run: `x` across (a Gantt's rows), `y` down (a day's hours). */
164
+ axis?: 'x' | 'y';
165
+ /** A stretch keeps to the track it is on. */
166
+ stay?: boolean;
167
+ locked?: (span: Span) => boolean;
168
+ /** What a stretch is called, with where it is: what is said as it is changed. */
169
+ label?: (span: Span) => string | undefined;
170
+ onPick?: (id: string, event: Event) => void;
171
+ }
172
+ /** The stretches. Arrows walk between them; Alt with an arrow moves one, with Shift lengthens it. */
173
+ export function Spans(props: SpansProps): ReactTypes.ReactElement | null;
174
+ /** One track: draws the stretches on it. `data-track`. */
175
+ export function SpansTrack(
176
+ props: Omit<PartProps<'div', { spans: Span[] }>, 'children'> & { value: string; children: (spans: Span[]) => ReactTypes.ReactNode },
177
+ ): ReactTypes.ReactElement | null;
178
+ /** One stretch. An element inside with `data-span-edge="start"` or `"end"` is the edge a pointer lengthens it by. */
179
+ export const SpansSpan: Part<'div', { value: string }, { span: Span | undefined; action: SpanAction | undefined }>;
180
+
181
+ /* ---------- a position read along a line ---------- */
182
+
183
+ export type ScrubReason = 'scrub' | 'move-key' | 'focus-in' | 'focus-out' | 'escape-key';
184
+ export interface ScrubProps extends Omit<PartProps<'div', { at: number | null; last: number }>, 'children' | 'defaultValue'> {
185
+ /** How many positions the track has. */
186
+ count: number;
187
+ value?: number | null;
188
+ defaultValue?: number | null;
189
+ onValueChange?: (value: number | null, details: Change<ScrubReason>) => void;
190
+ /** `band`: each position owns an equal stretch of the track. `point`: the first and last are the track's ends. */
191
+ scale?: 'band' | 'point';
192
+ orientation?: 'horizontal' | 'vertical';
193
+ /** What is at a position, in words: what a screen reader hears as it changes. */
194
+ text?: (index: number) => string;
195
+ onPick?: (index: number, event: Event) => void;
196
+ children: (at: number | null, last: number) => ReactTypes.ReactNode;
197
+ }
198
+ /** The reader passes over a line and is told what is at each place. `data-scrubbing`. */
199
+ export function Scrub(props: ScrubProps): ReactTypes.ReactElement | null;
200
+ /** The line: a slider to the keyboard and a screen reader. `data-at`. */
201
+ export const ScrubTrack: Part<'div'>;
202
+
203
+ /* ---------- one of a list, shown beside it ---------- */
204
+
205
+ export type PickReason = 'move-key' | 'enter-key' | 'item-press' | 'escape-key' | 'close-press';
206
+ export interface PickProps extends Omit<PartProps<'div', { value: string | null; follow: boolean }>, 'defaultValue'> {
207
+ /** The rows, in order, by their keys. */
208
+ keys: string[];
209
+ value?: string | null;
210
+ defaultValue?: string | null;
211
+ onValueChange?: (value: string | null, details: Change<PickReason>) => void;
212
+ /** Walking the list picks as it goes. Off where the list and the pane are not both in view (a phone). */
213
+ follow?: boolean;
214
+ }
215
+ export function Pick(props: PickProps): ReactTypes.ReactElement | null;
216
+ export const PickList: Part<'ul'>;
217
+ /** One row. `data-picked`. */
218
+ export const PickOption: Part<'li', { value: string }, { picked: boolean }>;
219
+ /** Where the picked one is shown. Escape in it returns to its row. */
220
+ export const PickPane: Part<'section', {}, { value: string | null }>;
221
+ /** Unpicks and returns to the row, where only one of the two is in view. */
222
+ export const PickBack: Part<'button'>;
223
+
224
+ /* ---------- a list worked one at a time ---------- */
225
+
226
+ export type TurnsReason = 'next-press' | 'previous-press' | 'imperative';
227
+ export type TurnsState = { current: string | null; at: number; handled: string[]; left: string[]; total: number };
228
+ export interface TurnsProps extends Omit<PartProps<'div', TurnsState>, 'defaultValue'> {
229
+ /** Everything to go through, in order, by its key. */
230
+ keys: string[];
231
+ /** The keys that have been dealt with. */
232
+ value?: string[];
233
+ defaultValue?: string[];
234
+ onValueChange?: (value: string[], details: Change<TurnsReason>) => void;
235
+ }
236
+ /** One thing is in hand; dealing with it brings the next. `data-done` when none is left. */
237
+ export function Turns(props: TurnsProps): ReactTypes.ReactElement | null;
238
+ /** The name of the one in hand: the keyboard is put on it when it changes, so it is read out. */
239
+ export const TurnsName: Part<'h2'>;
240
+ /** Leaves the one in hand for the end. */
241
+ export const TurnsSkip: Part<'button'>;
242
+
243
+ /* ---------- column widths ---------- */
244
+
245
+ export type WidthsReason = 'drag' | 'move-key' | 'clear-press';
246
+ export interface WidthsProps extends Omit<PartProps<'div', { widths: Record<string, number>; sizing: string | null }>, 'children' | 'defaultValue'> {
247
+ /** The widths the reader has set, in CSS pixels, by column. A column that is not here is its own width. */
248
+ value?: Record<string, number>;
249
+ defaultValue?: Record<string, number>;
250
+ onValueChange?: (value: Record<string, number>, details: Change<WidthsReason, { key: string }>) => void;
251
+ min?: number;
252
+ max?: number;
253
+ /** How far an arrow key moves an edge; Shift moves it five times as far. */
254
+ step?: number;
255
+ /** What a screen reader hears when a key sets a width or gives one back (no width). English where unsaid. */
256
+ say?: (label: string, width: number | undefined) => string;
257
+ children: (widths: Record<string, number>, sizing: string | null) => ReactTypes.ReactNode;
258
+ }
259
+ /** The widths. Lays nothing out. `data-sizing` while a bar is dragged. */
260
+ export function Widths(props: WidthsProps): ReactTypes.ReactElement | null;
261
+ /** A column's header cell: Alt with Left and Right sets its width from the button inside, Alt with Backspace gives it back. `data-sized`. */
262
+ export const WidthsColumn: Part<'th', { value: string; label?: string }>;
263
+ /** The bar at a column's far edge. A double press gives the width back. `data-sizing`. */
264
+ export const WidthsHandle: Part<'span', { value?: string }>;
265
+
266
+ /* ---------- values edited where they stand ---------- */
267
+
268
+ export type EditableReason = 'edit-key' | 'type' | 'double-click' | 'enter-key' | 'escape-key' | 'focus-out' | 'tab-key' | 'imperative';
269
+ export interface EditableProps extends Omit<PartProps<'div', { editing: string | null }>, 'children'> {
270
+ /** What a value says now, by its id: what the box starts with. */
271
+ text: (id: string) => string;
272
+ /** Asked to keep what was typed. Return false to refuse it and keep the box open. */
273
+ onCommit?: (id: string, text: string, details: { reason: EditableReason; event?: Event }) => boolean | void;
274
+ /** The box was left by Escape. */
275
+ onCancel?: (id: string) => void;
276
+ locked?: (id: string) => boolean;
277
+ /** Draws the values; `editing` is the id of the one whose box is open, or none. */
278
+ children: (editing: string | null) => ReactTypes.ReactNode;
279
+ }
280
+ /** One value is edited at a time: Enter, F2 or typing starts on it, Enter and Tab keep, Escape puts it back. */
281
+ export function Editable(props: EditableProps): ReactTypes.ReactElement | null;
282
+ /** A value. `press` starts on it at a single press; without it, a double press. `data-editing`, `data-locked`. */
283
+ export const EditableValue: Part<'span', { value: string; press?: boolean }, { editing: boolean }>;
284
+ /** The box, drawn where the value being edited is. */
285
+ export const EditableInput: Part<'input'>;
286
+
287
+ import type { Primitive } from '@ui-sdk/core';
288
+ export { createParts } from '@ui-sdk/react/primitive';
289
+ /** How much the page is zoomed where an element stands. */
290
+ export declare function zoomOf(el: HTMLElement): number;
291
+ export type SortableOrientation = 'vertical' | 'horizontal' | 'grid';
292
+ export type SpansChange = Change<SpansReason, { id: string; action: SpanAction }>;
293
+ export declare const days: Primitive;
294
+ export type DaysOptions = Record<string, unknown>;
295
+ export declare const editable: Primitive;
296
+ export type EditableOptions = Record<string, unknown>;
297
+ export declare const pick: Primitive;
298
+ export type PickOptions = Record<string, unknown>;
299
+ export declare const scrub: Primitive;
300
+ export type ScrubOptions = Record<string, unknown>;
301
+ export declare const sortable: Primitive;
302
+ export type SortableOptions = Record<string, unknown>;
303
+ export declare const spans: Primitive;
304
+ export type SpansOptions = Record<string, unknown>;
305
+ export declare const transfer: Primitive;
306
+ export type TransferOptions = Record<string, unknown>;
307
+ export declare const turns: Primitive;
308
+ export type TurnsOptions = Record<string, unknown>;
309
+ export declare const widths: Primitive;
310
+ export type WidthsOptions = Record<string, unknown>;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The behaviors, to build components on: `@mistriwork/ui/behaviors/index.js`, and for an App's own components
3
+ * `@mistriwork/mistri/behaviors`.
4
+ *
5
+ * Each behavior is a UI SDK primitive (`definePrimitive`): state with changes a caller can hold, refuse or leave
6
+ * alone, an api, and slots that put the right roles, keys and `data-*` on whatever element they are given. Nothing
7
+ * here draws anything, and a component is made from three things:
8
+ *
9
+ * - the React parts (`Transfer`, `TransferList`, …): each takes `render`, `className` and `style`, carries
10
+ * `data-slot` and its state as `data-*`, and is dressed by the caller's stylesheet. A root's change callback hears
11
+ * this package's details second (./heard.ts): the reason, the hand, the event, and `cancel()` to refuse it;
12
+ * - the primitive itself (`transfer`, `days`, …), for parts on elements of the caller's choosing:
13
+ * `createParts(sortable, { root: 'ol', item: 'li', handle: 'button' })`, with `createParts` from here. A primitive
14
+ * says UI SDK's own details;
15
+ * - the helpers a behavior's callers need (a day's arithmetic, how much a page is zoomed).
16
+ *
17
+ * ../behaviors.css gives a behavior's slots only what the behavior needs to work wherever it stands (a dragged item
18
+ * follows the pointer, a carried thing is not selected as text, a finger on a track still scrolls the page) and a
19
+ * plain default for a grip and for a value that can be edited, which a rule of the caller's replaces. What a
20
+ * component looks like is said of that component, never of the slot.
21
+ *
22
+ * They are apart from the controls on purpose: no control imports one, so a page that draws no board and no calendar
23
+ * fetches none of this. What each one is for, its options and its slots are said at the top of its file.
24
+ */
25
+ export { createParts } from '@ui-sdk/react/primitive';
26
+ export { Days, DaysDay } from './DaysParts.js';
27
+ export { addDays, addMonths, dayAt, days, inMonth, localToday, monthOf, weeksOf } from './days.js';
28
+ export { zoomOf } from './dress.js';
29
+ export { Editable, EditableInput, EditableValue } from './EditableParts.js';
30
+ export { editable } from './editable.js';
31
+ export { Pick, PickBack, PickList, PickOption, PickPane } from './PickParts.js';
32
+ export { pick } from './pick.js';
33
+ export { Scrub, ScrubTrack } from './ScrubParts.js';
34
+ export { scrub } from './scrub.js';
35
+ export { Sortable, SortableHandle, SortableItem } from './SortableParts.js';
36
+ export { sortable } from './sortable.js';
37
+ export { Spans, SpansSpan, SpansTrack } from './SpansParts.js';
38
+ export { spans } from './spans.js';
39
+ export { Transfer, TransferHandle, TransferItem, TransferList } from './TransferParts.js';
40
+ export { transfer } from './transfer.js';
41
+ export { Turns, TurnsName, TurnsSkip } from './TurnsParts.js';
42
+ export { turns } from './turns.js';
43
+ export { Widths, WidthsColumn, WidthsHandle } from './WidthsParts.js';
44
+ export { widths } from './widths.js';