@mistriwork/ui 1.0.0-rc.47 → 1.0.0-rc.49

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 (52) hide show
  1. package/README.md +1 -1
  2. package/dist/Carousel.d.ts +2 -1
  3. package/dist/Carousel.js +9 -8
  4. package/dist/Choices.d.ts +5 -4
  5. package/dist/Choices.js +18 -16
  6. package/dist/DateField.d.ts +8 -3
  7. package/dist/DateField.js +17 -14
  8. package/dist/Drawer.d.ts +2 -1
  9. package/dist/Drawer.js +4 -3
  10. package/dist/DropMenu.d.ts +2 -1
  11. package/dist/DropMenu.js +3 -2
  12. package/dist/Dropdown.d.ts +8 -3
  13. package/dist/Dropdown.js +10 -6
  14. package/dist/FileField.d.ts +3 -2
  15. package/dist/FileField.js +4 -2
  16. package/dist/Pagination.d.ts +2 -1
  17. package/dist/Pagination.js +3 -2
  18. package/dist/Popover.d.ts +2 -1
  19. package/dist/Popover.js +3 -2
  20. package/dist/Resizable.d.ts +2 -1
  21. package/dist/Resizable.js +10 -9
  22. package/dist/Select.d.ts +3 -3
  23. package/dist/Select.js +2 -2
  24. package/dist/SensitiveField.d.ts +2 -1
  25. package/dist/SensitiveField.js +6 -5
  26. package/dist/Slider.d.ts +2 -1
  27. package/dist/Slider.js +3 -2
  28. package/dist/Switch.d.ts +2 -2
  29. package/dist/Switch.js +4 -3
  30. package/dist/Tabs.d.ts +5 -2
  31. package/dist/Tabs.js +3 -2
  32. package/dist/TextArea.d.ts +24 -0
  33. package/dist/TextArea.js +7 -0
  34. package/dist/TextField.d.ts +3 -2
  35. package/dist/TextField.js +6 -5
  36. package/dist/Tooltip.d.ts +2 -1
  37. package/dist/Tooltip.js +3 -3
  38. package/dist/Typeahead.d.ts +5 -2
  39. package/dist/Typeahead.js +31 -10
  40. package/dist/UiKit.d.ts +8 -2
  41. package/dist/changeDetails.d.ts +28 -0
  42. package/dist/changeDetails.js +54 -0
  43. package/dist/conformance.d.ts +1 -1
  44. package/dist/conformance.js +83 -5
  45. package/dist/conformancePatterns.d.ts +27 -0
  46. package/dist/conformancePatterns.js +421 -0
  47. package/dist/forms.css +3 -0
  48. package/dist/index.d.ts +5 -3
  49. package/dist/index.js +3 -0
  50. package/dist/internal/uiKitContext.d.ts +4 -1
  51. package/dist/internal/uiKitContext.js +49 -3
  52. package/package.json +2 -1
package/README.md CHANGED
@@ -7,7 +7,7 @@ drawn with: Modal, DropMenu, Dropdown, Typeahead, Button, Field, Icon and
7
7
  DateField over [Base UI](https://base-ui.com), the tokens and stylesheet they
8
8
  are drawn with, and the zoom-aware ruler their popups are placed by.
9
9
 
10
- The form controls are built on them (**Preview**: @mistriwork/ui is Preview at 1.0): `TextField`, `MaskedField`,
10
+ The form controls are built on them (**Preview**: @mistriwork/ui is Preview at 1.0): `TextField`, `TextArea`, `MaskedField`,
11
11
  `MoneyField`, `SensitiveField`, `FileField`, `Select`, `MultiSelect`, `YesNo`, `ChoiceCards`, `Checkbox`, `Consent`, `Slider`,
12
12
  `HelpTip`, `ProgressBar`, `StepHeader`, `ActionBar`, `Columns` and `ReviewList`, with the `masks` they take
13
13
  (`phone`, `date`, `month`, `ssn`, `zip`, `money`). Each takes a value and an `onChange` and draws what it is told. A
@@ -17,6 +17,7 @@
17
17
  * hands focus to the other step, never to nowhere.
18
18
  */
19
19
  import { type ReactNode } from 'react';
20
+ import { type ChangeDetails } from './changeDetails.js';
20
21
  export interface CarouselSlide {
21
22
  /** The slide's short name, said after its number ("1 of 3: Studio"). */
22
23
  label?: string;
@@ -26,7 +27,7 @@ export interface CarouselProps {
26
27
  slides: readonly CarouselSlide[];
27
28
  index?: number;
28
29
  defaultIndex?: number;
29
- onIndexChange?: (index: number) => void;
30
+ onIndexChange?: (index: number, details: ChangeDetails<'navigate'>) => void;
30
31
  /** The region's accessible name, where the carousel needs one ("Project photos"). */
31
32
  ariaLabel?: string;
32
33
  /** Every word the carousel says, in the caller's language; any left out are English. */
package/dist/Carousel.js CHANGED
@@ -18,6 +18,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
18
  * hands focus to the other step, never to nowhere.
19
19
  */
20
20
  import { useEffect, useRef, useState } from 'react';
21
+ import { changeDetails } from './changeDetails.js';
21
22
  const ENGLISH = {
22
23
  region: 'Carousel',
23
24
  previous: 'Previous slide',
@@ -38,11 +39,11 @@ export function Carousel({ slides, index, defaultIndex = 0, onIndexChange, ariaL
38
39
  even where the browser already moved focus to the body on disable. */
39
40
  const lastStepRef = useRef(null);
40
41
  const current = slides.length ? Math.min(Math.max(index ?? uncontrolled, 0), slides.length - 1) : 0;
41
- const go = (next) => {
42
+ const go = (next, event) => {
42
43
  const clamped = Math.min(Math.max(next, 0), slides.length - 1);
43
44
  if (index === undefined)
44
45
  setUncontrolled(clamped);
45
- onIndexChange?.(clamped);
46
+ onIndexChange?.(clamped, changeDetails('navigate', event));
46
47
  };
47
48
  /* A step that disables under its own focus hands focus on: the other
48
49
  step where it is live, the region itself where both ends are shut
@@ -84,19 +85,19 @@ export function Carousel({ slides, index, defaultIndex = 0, onIndexChange, ariaL
84
85
  return;
85
86
  if (event.key === 'ArrowLeft') {
86
87
  event.preventDefault();
87
- go(current - 1);
88
+ go(current - 1, event);
88
89
  }
89
90
  else if (event.key === 'ArrowRight') {
90
91
  event.preventDefault();
91
- go(current + 1);
92
+ go(current + 1, event);
92
93
  }
93
94
  else if (event.key === 'Home') {
94
95
  event.preventDefault();
95
- go(0);
96
+ go(0, event);
96
97
  }
97
98
  else if (event.key === 'End') {
98
99
  event.preventDefault();
99
- go(slides.length - 1);
100
+ go(slides.length - 1, event);
100
101
  }
101
102
  };
102
103
  return (_jsxs("section", { ref: regionRef, className: ['ui-carousel', className].filter(Boolean).join(' '), "aria-roledescription": "carousel", "aria-label": ariaLabel ?? words.region,
@@ -104,7 +105,7 @@ export function Carousel({ slides, index, defaultIndex = 0, onIndexChange, ariaL
104
105
  -1 is no tab stop. */
105
106
  tabIndex: -1, onKeyDown: onRegionKeyDown, children: [_jsx("div", { className: "ui-carousel-viewport", children: _jsx("div", { className: "ui-carousel-track", style: { transform: `translateX(-${current * 100}%)` }, children: slides.map((slide, i) => (_jsx("div", { className: "ui-carousel-slide", role: "group", "aria-roledescription": "slide", "aria-label": words.slide(i + 1, slides.length, slide.label), "aria-hidden": i !== current || undefined, inert: i !== current || undefined, children: slide.children }, i))) }) }), _jsxs("div", { className: "ui-carousel-controls", ref: controlsRef, children: [_jsx("button", { ref: prevRef, type: "button", className: "ui-carousel-step", disabled: current === 0, onFocus: () => {
106
107
  lastStepRef.current = 'prev';
107
- }, onClick: () => go(current - 1), children: words.previous }), _jsx("span", { className: "ui-carousel-dots", role: "group", "aria-label": words.chooseSlide, children: slides.map((slide, i) => (_jsx("button", { type: "button", className: "ui-carousel-dot", "aria-label": words.goToSlide(i + 1, slide.label), "aria-current": i === current || undefined, onClick: () => go(i) }, i))) }), _jsx("button", { ref: nextRef, type: "button", className: "ui-carousel-step", disabled: current === slides.length - 1, onFocus: () => {
108
+ }, onClick: (event) => go(current - 1, event), children: words.previous }), _jsx("span", { className: "ui-carousel-dots", role: "group", "aria-label": words.chooseSlide, children: slides.map((slide, i) => (_jsx("button", { type: "button", className: "ui-carousel-dot", "aria-label": words.goToSlide(i + 1, slide.label), "aria-current": i === current || undefined, onClick: (event) => go(i, event) }, i))) }), _jsx("button", { ref: nextRef, type: "button", className: "ui-carousel-step", disabled: current === slides.length - 1, onFocus: () => {
108
109
  lastStepRef.current = 'next';
109
- }, onClick: () => go(current + 1), children: words.next })] }), _jsx("p", { className: "ui-carousel-status", "aria-live": "polite", children: words.status(current + 1, slides.length, slides[current]?.label) })] }));
110
+ }, onClick: (event) => go(current + 1, event), children: words.next })] }), _jsx("p", { className: "ui-carousel-status", "aria-live": "polite", children: words.status(current + 1, slides.length, slides[current]?.label) })] }));
110
111
  }
package/dist/Choices.d.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import { type AriaAttributes, type ReactNode } from 'react';
9
9
  import { type FieldFrame } from './fieldFrame.js';
10
+ import { type ChangeDetails } from './changeDetails.js';
10
11
  export interface ChoiceOption {
11
12
  value: string;
12
13
  label: string;
@@ -17,7 +18,7 @@ export interface YesNoProps extends Omit<FieldFrame, 'label'> {
17
18
  /** The question. */
18
19
  label: ReactNode;
19
20
  value: 'yes' | 'no' | '';
20
- onChange: (value: 'yes' | 'no') => void;
21
+ onChange: (value: 'yes' | 'no', details: ChangeDetails<'select'>) => void;
21
22
  /** The two words, in the caller's language. */
22
23
  yes: string;
23
24
  no: string;
@@ -27,7 +28,7 @@ declare function DefaultYesNo(props: YesNoProps): ReactNode;
27
28
  export interface ChoiceCardsProps extends FieldFrame {
28
29
  options: ChoiceOption[];
29
30
  value: string[];
30
- onChange: (value: string[]) => void;
31
+ onChange: (value: string[], details: ChangeDetails<'select'>) => void;
31
32
  /** Several may be on. */
32
33
  multiple?: boolean;
33
34
  /** The card that stands alone ("None"): choosing it clears the rest, and choosing another clears it. */
@@ -47,7 +48,7 @@ export interface CheckCard {
47
48
  export interface CheckCardsProps {
48
49
  cards: readonly CheckCard[];
49
50
  /** The card at `index` turned on or off. */
50
- onToggle: (index: number, on: boolean) => void;
51
+ onToggle: (index: number, on: boolean, details: ChangeDetails<'toggle'>) => void;
51
52
  id?: string;
52
53
  disabled?: boolean;
53
54
  'aria-labelledby'?: string;
@@ -66,7 +67,7 @@ export interface CheckCardsProps {
66
67
  declare function DefaultCheckCards(props: CheckCardsProps): ReactNode;
67
68
  export interface CheckboxProps extends Omit<FieldFrame, 'label'> {
68
69
  checked: boolean;
69
- onChange: (on: boolean) => void;
70
+ onChange: (on: boolean, details: ChangeDetails<'toggle'>) => void;
70
71
  /** The text beside the box; it is the label, so it is a click target too. */
71
72
  label: ReactNode;
72
73
  disabled?: boolean;
package/dist/Choices.js CHANGED
@@ -9,28 +9,30 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  import { useId, useRef, useState } from 'react';
10
10
  import { Field } from './Field.js';
11
11
  import { frameOf } from './fieldFrame.js';
12
+ import { changeDetails } from './changeDetails.js';
12
13
  import { slotted } from './internal/uiKitContext.js';
13
14
  /** Two buttons answering a question. */
14
15
  function DefaultYesNo(props) {
15
16
  const name = useId();
16
- return (_jsx(Field, { ...frameOf(props), group: true, children: (control) => (_jsx("div", { className: "choice-pair", role: "radiogroup", "aria-labelledby": control['aria-labelledby'], "aria-describedby": control['aria-describedby'], "aria-invalid": control['aria-invalid'], children: ['yes', 'no'].map((v) => (_jsxs("label", { className: `choice-pick${props.value === v ? ' is-on' : ''}`, children: [_jsx("input", { type: "radio", name: name, className: "choice-input", checked: props.value === v, onChange: () => props.onChange(v) }), props[v]] }, v))) })) }));
17
+ return (_jsx(Field, { ...frameOf(props), group: true, children: (control) => (_jsx("div", { className: "choice-pair", role: "radiogroup", "aria-labelledby": control['aria-labelledby'], "aria-describedby": control['aria-describedby'], "aria-invalid": control['aria-invalid'], children: ['yes', 'no'].map((v) => (_jsxs("label", { className: `choice-pick${props.value === v ? ' is-on' : ''}`, children: [_jsx("input", { type: "radio", name: name, className: "choice-input", checked: props.value === v, onChange: (e) => props.onChange(v, changeDetails('select', e)) }), props[v]] }, v))) })) }));
17
18
  }
18
19
  /** Cards with an icon, a label and a box. One choice is a radio group; `multiple` a group of checkboxes. */
19
20
  function DefaultChoiceCards(props) {
20
21
  const name = useId();
21
- const toggle = (v, on) => {
22
+ const toggle = (v, on, event) => {
23
+ const details = changeDetails('select', event);
22
24
  if (!props.multiple)
23
- return props.onChange(on ? [v] : []);
25
+ return props.onChange(on ? [v] : [], details);
24
26
  if (v === props.exclusive)
25
- return props.onChange(on ? [v] : []);
27
+ return props.onChange(on ? [v] : [], details);
26
28
  const rest = props.value.filter((x) => x !== v && x !== props.exclusive);
27
- props.onChange(on ? props.options.map((o) => o.value).filter((x) => x === v || rest.includes(x)) : rest);
29
+ props.onChange(on ? props.options.map((o) => o.value).filter((x) => x === v || rest.includes(x)) : rest, details);
28
30
  };
29
31
  if (props.multiple)
30
- return (_jsx(Field, { ...frameOf(props), group: true, children: (control) => (_jsx(CheckCards, { "aria-labelledby": control['aria-labelledby'], "aria-describedby": control['aria-describedby'], "aria-invalid": control['aria-invalid'], cards: props.options.map((o) => ({ key: o.value, label: o.label, icon: o.icon, on: props.value.includes(o.value) })), onToggle: (index, on) => toggle(props.options[index].value, on) })) }));
32
+ return (_jsx(Field, { ...frameOf(props), group: true, children: (control) => (_jsx(CheckCards, { "aria-labelledby": control['aria-labelledby'], "aria-describedby": control['aria-describedby'], "aria-invalid": control['aria-invalid'], cards: props.options.map((o) => ({ key: o.value, label: o.label, icon: o.icon, on: props.value.includes(o.value) })), onToggle: (index, on, details) => toggle(props.options[index].value, on, details.event) })) }));
31
33
  return (_jsx(Field, { ...frameOf(props), group: true, children: (control) => (_jsx("div", { className: "choice-cards", role: "radiogroup", "aria-labelledby": control['aria-labelledby'], "aria-describedby": control['aria-describedby'], "aria-invalid": control['aria-invalid'], children: props.options.map((o) => {
32
34
  const on = props.value.includes(o.value);
33
- return (_jsxs("label", { className: `choice-card${on ? ' is-on' : ''}`, children: [o.icon ? (_jsx("span", { className: "choice-card-icon", "aria-hidden": "true", children: o.icon })) : null, _jsx("span", { className: "choice-card-label", children: o.label }), _jsx("input", { type: "radio", name: name, className: "choice-input", checked: on, onChange: (e) => toggle(o.value, e.target.checked) }), _jsx("span", { className: "choice-box", "aria-hidden": "true" })] }, o.value));
35
+ return (_jsxs("label", { className: `choice-card${on ? ' is-on' : ''}`, children: [o.icon ? (_jsx("span", { className: "choice-card-icon", "aria-hidden": "true", children: o.icon })) : null, _jsx("span", { className: "choice-card-label", children: o.label }), _jsx("input", { type: "radio", name: name, className: "choice-input", checked: on, onChange: (e) => toggle(o.value, e.target.checked, e.nativeEvent) }), _jsx("span", { className: "choice-box", "aria-hidden": "true" })] }, o.value));
34
36
  }) })) }));
35
37
  }
36
38
  /**
@@ -68,28 +70,28 @@ function DefaultCheckCards(props) {
68
70
  // Space is the box's own key; the page does not scroll under it.
69
71
  event.preventDefault();
70
72
  if (!props.disabled)
71
- props.onToggle(index, !cards[index].on);
73
+ props.onToggle(index, !cards[index].on, changeDetails('toggle', event));
72
74
  }
73
75
  };
74
76
  return (_jsx("div", { className: "choice-cards", role: "group", "data-fit": props.fit, id: props.id, "aria-labelledby": props['aria-labelledby'], "aria-describedby": props['aria-describedby'], "aria-invalid": props['aria-invalid'], children: cards.map((card, index) => (_jsxs("div", { ref: (face) => {
75
77
  faces.current[index] = face;
76
- }, role: "checkbox", "aria-checked": card.on, "aria-disabled": props.disabled || undefined, tabIndex: index === stop ? 0 : -1, className: `choice-card${card.on ? ' is-on' : ''}`, onClick: () => {
78
+ }, role: "checkbox", "aria-checked": card.on, "aria-disabled": props.disabled || undefined, tabIndex: index === stop ? 0 : -1, className: `choice-card${card.on ? ' is-on' : ''}`, onClick: (event) => {
77
79
  setHeld(index);
78
80
  if (!props.disabled)
79
- props.onToggle(index, !card.on);
81
+ props.onToggle(index, !card.on, changeDetails('toggle', event));
80
82
  }, onFocus: () => setHeld(index), onKeyDown: (event) => keys(event, index), children: [card.icon ? (_jsx("span", { className: "choice-card-icon", "aria-hidden": "true", children: card.icon })) : null, _jsxs("span", { className: "choice-card-label", children: [card.label, card.help ? _jsx("span", { className: "choice-card-help", children: card.help }) : null] }), _jsx("span", { className: "choice-box", "aria-hidden": "true" })] }, card.key))) }));
81
83
  }
82
84
  /** A checkbox beside its text. */
83
85
  function DefaultCheckbox(props) {
84
- return (_jsx(Field, { ...frameOf(props), check: true, children: (control) => (_jsx("input", { ...control, type: "checkbox", className: "field-check", checked: props.checked, disabled: props.disabled, onChange: (e) => props.onChange(e.target.checked) })) }));
86
+ return (_jsx(Field, { ...frameOf(props), check: true, children: (control) => (_jsx("input", { ...control, type: "checkbox", className: "field-check", checked: props.checked, disabled: props.disabled, onChange: (e) => props.onChange(e.target.checked, changeDetails('toggle', e)) })) }));
85
87
  }
86
88
  /** A checkbox for a long notice: the paragraph is the label, in the body's weight. */
87
89
  function DefaultConsent(props) {
88
90
  return _jsx(Checkbox, { ...props, className: ['form-field-consent', props.className].filter(Boolean).join(' ') });
89
91
  }
90
92
  /* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
91
- export const YesNo = slotted('YesNo', DefaultYesNo);
92
- export const ChoiceCards = slotted('ChoiceCards', DefaultChoiceCards);
93
- export const CheckCards = slotted('CheckCards', DefaultCheckCards);
94
- export const Checkbox = slotted('Checkbox', DefaultCheckbox);
95
- export const Consent = slotted('Consent', DefaultConsent);
93
+ export const YesNo = slotted('YesNo', DefaultYesNo, { onChange: [1, 'select'] });
94
+ export const ChoiceCards = slotted('ChoiceCards', DefaultChoiceCards, { onChange: [1, 'select'] });
95
+ export const CheckCards = slotted('CheckCards', DefaultCheckCards, { onToggle: [2, 'toggle'] });
96
+ export const Checkbox = slotted('Checkbox', DefaultCheckbox, { onChange: [1, 'toggle'] });
97
+ export const Consent = slotted('Consent', DefaultConsent, { onChange: [1, 'toggle'] });
@@ -7,6 +7,7 @@
7
7
  * calendar button's icon are props: the kit lends its catalog's and its icon.
8
8
  */
9
9
  import { type AriaAttributes, type KeyboardEvent, type ReactNode, type Ref } from 'react';
10
+ import { type ChangeDetails } from './changeDetails.js';
10
11
  /** What a date field says. A `format` is the locale's numeric date pattern ("MM/DD/YYYY"). */
11
12
  export interface DateFieldWords {
12
13
  /** The placeholder and the format a date and a time are typed in. */
@@ -36,8 +37,9 @@ export interface DateFieldProps {
36
37
  /** Drawn in the calendar button. */
37
38
  calendarIcon: ReactNode;
38
39
  value: string;
39
- /** Typed text is preserved, including an incomplete date; callers validate on commit. */
40
- onChange: (value: string) => void;
40
+ /** Typed text is preserved, including an incomplete date; callers validate on commit. `day-press` is a day (or Clear,
41
+ or Today) chosen in the calendar. */
42
+ onChange: (value: string, details: ChangeDetails<'input-change' | 'day-press'>) => void;
41
43
  /** Composite blur: never fired while focus moves between the input and calendar. */
42
44
  onBlur?: () => void;
43
45
  onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
@@ -59,11 +61,14 @@ export interface DateFieldProps {
59
61
  withTime?: boolean;
60
62
  /** The calendar is drawn in a portal; an owner that watches focus (an autosaving field) is told where. */
61
63
  popupRef?: (node: HTMLDivElement | null) => void;
62
- onOpenChange?: (open: boolean) => void;
64
+ /** Base UI's popover words, `day-press` when a choice closed it, `open-key` for Alt+ArrowDown, and `disabled` when the
65
+ field was disabled or its bounds stopped agreeing while it was open. */
66
+ onOpenChange?: (open: boolean, details: ChangeDetails<DateFieldOpenReason>) => void;
63
67
  'aria-label'?: string;
64
68
  'aria-invalid'?: AriaAttributes['aria-invalid'];
65
69
  'aria-describedby'?: string;
66
70
  }
71
+ export type DateFieldOpenReason = 'trigger-hover' | 'trigger-focus' | 'trigger-press' | 'outside-press' | 'escape-key' | 'close-press' | 'focus-out' | 'imperative-action' | 'implicit' | 'day-press' | 'open-key' | 'disabled';
67
72
  /** A date field, or a date and a wall-clock time. No input is parsed as an instant or shifted by a timezone. */
68
73
  declare function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, onKeyDown, disabled, required, min, max, locale, timezone, now, firstDay, className, name, inputRef, placeholder, withTime, popupRef, onOpenChange, 'aria-label': label, 'aria-invalid': invalid, 'aria-describedby': describedBy, }: DateFieldProps): import("react").JSX.Element;
69
74
  export declare const DateField: typeof DefaultDateField;
package/dist/DateField.js CHANGED
@@ -11,6 +11,7 @@ import { useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, us
11
11
  import { Popover } from '@base-ui/react/popover';
12
12
  import { layoutViewport, zoomAnchor } from './internal/anchor.js';
13
13
  import { addDateDays, addDateMonths, clampDate, dateBounds, dateFormat, dateParts, dateTimeWithinBounds, dateWithinBounds, isPickerDate, isPickerDateTime, monthGrid, monthLabel, splitDateTime, todayInZone, weekdayLabels, withDate, } from './internal/datePickerModel.js';
14
+ import { changeDetails, fromBaseUi } from './changeDetails.js';
14
15
  import { popupContainer } from './internal/popups.js';
15
16
  import { slotted } from './internal/uiKitContext.js';
16
17
  /** How a locale writes a numeric date: the order of its parts and its separator ("MM/DD/YYYY" in en-US). */
@@ -77,9 +78,9 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
77
78
  useLayoutEffect(() => {
78
79
  openCallback.current = onOpenChange;
79
80
  });
80
- const setOpen = (next) => {
81
+ const setOpen = (next, details) => {
81
82
  setOpenState(next);
82
- openCallback.current?.(next);
83
+ openCallback.current?.(next, details);
83
84
  };
84
85
  const [container, setContainer] = useState(null);
85
86
  const group = useRef(null);
@@ -131,7 +132,7 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
131
132
  if (!open)
132
133
  return;
133
134
  if (!configuredBounds || disabled) {
134
- setOpen(false);
135
+ setOpen(false, changeDetails('disabled'));
135
136
  return;
136
137
  }
137
138
  const next = clampDate(isPickerDate(datePart) ? datePart : active, configuredBounds);
@@ -174,12 +175,12 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
174
175
  if (!within(event.relatedTarget))
175
176
  commitBlur();
176
177
  };
177
- const changeOpen = (next) => {
178
+ const changeOpen = (next, details) => {
178
179
  if (next) {
179
180
  restoreFocus.current = false;
180
181
  setActive(seed());
181
182
  }
182
- setOpen(next);
183
+ setOpen(next, details);
183
184
  if (!next)
184
185
  checkBlur();
185
186
  };
@@ -189,14 +190,15 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
189
190
  target.focus({ preventScroll: true });
190
191
  }
191
192
  };
192
- const choose = (date) => {
193
+ const choose = (date, event) => {
194
+ const details = changeDetails('day-press', event);
193
195
  restoreFocus.current = true;
194
196
  setDraft(null);
195
197
  // Move focus before removing the focused day. Otherwise an enclosing
196
198
  // modal sees focus fall to body and starts its own recovery to the dialog.
197
199
  returnToTrigger();
198
- onChange(withTime && date ? withDate(value, date) : date);
199
- changeOpen(false);
200
+ onChange(withTime && date ? withDate(value, date) : date, details);
201
+ changeOpen(false, details);
200
202
  };
201
203
  const move = (date) => {
202
204
  moveFocus.current = true;
@@ -226,21 +228,22 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
226
228
  restoreFocus.current = !next && details.reason === 'escape-key';
227
229
  if (restoreFocus.current)
228
230
  returnToTrigger();
229
- changeOpen(next);
231
+ changeOpen(next, fromBaseUi(details, 'implicit'));
230
232
  }, children: _jsxs("span", { ref: group, className: withTime ? 'date-field with-time' : 'date-field', onFocus: () => {
231
233
  ownedFocus.current = true;
232
234
  }, onBlur: leave, children: [_jsx("input", { ref: input, id: id, name: name, type: "text", value: shown, className: `date-field-input ${className}`, placeholder: placeholder ?? (withTime ? words.dateTimePattern : mask.hint), autoComplete: "off", spellCheck: false, disabled: disabled, required: required, "aria-required": required, "aria-label": label, "aria-invalid": invalid || bad || undefined, "aria-describedby": [describedBy, hint].filter(Boolean).join(' '), onChange: (event) => {
233
235
  const text = event.target.value;
236
+ const details = changeDetails('input-change', event);
234
237
  if (withTime)
235
- return onChange(text);
238
+ return onChange(text, details);
236
239
  setDraft(text);
237
- onChange(readDate(text, mask) ?? text);
240
+ onChange(readDate(text, mask) ?? text, details);
238
241
  }, onKeyDown: (event) => {
239
242
  if (event.altKey && event.key === 'ArrowDown') {
240
243
  event.preventDefault();
241
244
  event.stopPropagation();
242
245
  if (configuredBounds)
243
- changeOpen(true);
246
+ changeOpen(true, changeDetails('open-key', event));
244
247
  }
245
248
  else
246
249
  onKeyDown?.(event);
@@ -252,7 +255,7 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
252
255
  (focused === target || focused === document.body || focused === container)
253
256
  ? target
254
257
  : false;
255
- }, className: "date-field-popup", "aria-label": words.calendar(label || undefined), initialFocus: () => popup.current?.querySelector(`[data-date="${active}"]`) ?? true, children: [_jsxs("div", { className: "date-field-head", children: [_jsx("button", { type: "button", "aria-label": words.previousMonth, disabled: previous.slice(0, 7) === active.slice(0, 7) || previous.slice(0, 7) < bounds.min.slice(0, 7), onClick: () => setActive(clampDate(previous, bounds)), children: "\u2190" }), _jsx("span", { id: caption, "aria-live": "polite", "aria-atomic": "true", children: monthLabel(active, locale) }), _jsx("button", { type: "button", "aria-label": words.nextMonth, disabled: next.slice(0, 7) === active.slice(0, 7) || next.slice(0, 7) > bounds.max.slice(0, 7), onClick: () => setActive(clampDate(next, bounds)), children: "\u2192" })] }), _jsxs("table", { className: "date-field-calendar", role: "grid", "aria-labelledby": caption, children: [_jsx("thead", { children: _jsx("tr", { children: weekdays.map((day) => (_jsx("th", { scope: "col", "aria-label": day.long, children: day.short }, day.long))) }) }), _jsx("tbody", { children: Array.from({ length: 6 }, (_, week) => (_jsx("tr", { children: days.slice(week * 7, week * 7 + 7).map((day, index) => (_jsx("td", { "aria-selected": day.date === datePart, children: day.date && (_jsx("button", { type: "button", "data-date": day.date, "data-outside": !day.inMonth || undefined, "data-selected": day.date === datePart || undefined, "aria-current": day.date === today ? 'date' : undefined, disabled: day.disabled, tabIndex: day.date === active ? 0 : -1, "aria-label": dayName(day.date), onKeyDown: onDayKey, onClick: () => choose(day.date), children: Number(day.date.slice(8)) })) }, day.date ?? index))) }, week))) })] }), _jsxs("div", { className: "date-field-foot", children: [_jsx("button", { type: "button", onClick: () => choose(''), children: words.clear }), _jsx("button", { type: "button", disabled: !dateWithinBounds(today, bounds), onClick: () => choose(today), children: words.today })] })] }) }) })] }) }));
258
+ }, className: "date-field-popup", "aria-label": words.calendar(label || undefined), initialFocus: () => popup.current?.querySelector(`[data-date="${active}"]`) ?? true, children: [_jsxs("div", { className: "date-field-head", children: [_jsx("button", { type: "button", "aria-label": words.previousMonth, disabled: previous.slice(0, 7) === active.slice(0, 7) || previous.slice(0, 7) < bounds.min.slice(0, 7), onClick: () => setActive(clampDate(previous, bounds)), children: "\u2190" }), _jsx("span", { id: caption, "aria-live": "polite", "aria-atomic": "true", children: monthLabel(active, locale) }), _jsx("button", { type: "button", "aria-label": words.nextMonth, disabled: next.slice(0, 7) === active.slice(0, 7) || next.slice(0, 7) > bounds.max.slice(0, 7), onClick: () => setActive(clampDate(next, bounds)), children: "\u2192" })] }), _jsxs("table", { className: "date-field-calendar", role: "grid", "aria-labelledby": caption, children: [_jsx("thead", { children: _jsx("tr", { children: weekdays.map((day) => (_jsx("th", { scope: "col", "aria-label": day.long, children: day.short }, day.long))) }) }), _jsx("tbody", { children: Array.from({ length: 6 }, (_, week) => (_jsx("tr", { children: days.slice(week * 7, week * 7 + 7).map((day, index) => (_jsx("td", { "aria-selected": day.date === datePart, children: day.date && (_jsx("button", { type: "button", "data-date": day.date, "data-outside": !day.inMonth || undefined, "data-selected": day.date === datePart || undefined, "aria-current": day.date === today ? 'date' : undefined, disabled: day.disabled, tabIndex: day.date === active ? 0 : -1, "aria-label": dayName(day.date), onKeyDown: onDayKey, onClick: (event) => choose(day.date, event), children: Number(day.date.slice(8)) })) }, day.date ?? index))) }, week))) })] }), _jsxs("div", { className: "date-field-foot", children: [_jsx("button", { type: "button", onClick: (event) => choose('', event), children: words.clear }), _jsx("button", { type: "button", disabled: !dateWithinBounds(today, bounds), onClick: (event) => choose(today, event), children: words.today })] })] }) }) })] }) }));
256
259
  }
257
260
  /* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
258
- export const DateField = slotted('DateField', DefaultDateField);
261
+ export const DateField = slotted('DateField', DefaultDateField, { onChange: [1, 'input-change'], onOpenChange: [1, 'implicit'] });
package/dist/Drawer.d.ts CHANGED
@@ -17,10 +17,11 @@
17
17
  * the same).
18
18
  */
19
19
  import { type ReactNode } from 'react';
20
+ import { type ChangeDetails } from './changeDetails.js';
20
21
  export type DrawerSide = 'left' | 'right';
21
22
  interface DrawerBase {
22
23
  open: boolean;
23
- onOpenChange?: (open: boolean) => void;
24
+ onOpenChange?: (open: boolean, details: ChangeDetails<'trigger-press' | 'outside-press' | 'escape-key' | 'close-watcher' | 'close-press' | 'focus-out' | 'imperative-action' | 'swipe' | 'implicit'>) => void;
24
25
  side?: DrawerSide;
25
26
  children: ReactNode;
26
27
  className?: string;
package/dist/Drawer.js CHANGED
@@ -21,17 +21,18 @@ import { useContext } from 'react';
21
21
  import { Drawer as BaseDrawer } from '@base-ui/react/drawer';
22
22
  import { ComponentStyleScope } from './internal/ComponentStyleScope.js';
23
23
  import { popupContainer } from './internal/popups.js';
24
+ import { fromBaseUi } from './changeDetails.js';
24
25
  import { slotted } from './internal/uiKitContext.js';
25
26
  function DefaultDrawer({ open, onOpenChange, side = 'right', title, ariaLabel, children, className, closeDisabled = false, closeLabel = 'Close', }) {
26
27
  const componentScope = useContext(ComponentStyleScope);
27
- return (_jsx(BaseDrawer.Root, { open: open, disablePointerDismissal: closeDisabled, onOpenChange: (next) => {
28
+ return (_jsx(BaseDrawer.Root, { open: open, disablePointerDismissal: closeDisabled, onOpenChange: (next, details) => {
28
29
  /* A non-cancellable operation: a dismissal request (Escape, a
29
30
  click outside) is refused here, as Modal's beforeClose refuses
30
31
  one, and the controlled drawer stays open. */
31
32
  if (!next && closeDisabled)
32
33
  return;
33
- onOpenChange?.(next);
34
+ onOpenChange?.(next, fromBaseUi(details, 'implicit'));
34
35
  }, children: _jsxs(BaseDrawer.Portal, { container: popupContainer(), children: [_jsx(BaseDrawer.Backdrop, { className: "ui-drawer-backdrop" }), _jsx(BaseDrawer.Viewport, { className: ['ui-drawer-viewport', `ui-drawer-${side}`, className].filter(Boolean).join(' '), "data-component": componentScope, children: _jsxs(BaseDrawer.Popup, { className: "ui-drawer", "aria-label": ariaLabel ?? (typeof title === 'string' ? title : undefined), children: [_jsxs("div", { className: "ui-drawer-head", children: [title !== undefined ? _jsx(BaseDrawer.Title, { className: "ui-drawer-title", children: title }) : null, _jsx(BaseDrawer.Close, { className: "ui-drawer-close", "aria-label": closeLabel, disabled: closeDisabled, children: _jsx("svg", { viewBox: "0 0 16 16", width: "16", height: "16", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M3.5 3.5l9 9M12.5 3.5l-9 9", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) })] }), children] }) })] }) }));
35
36
  }
36
37
  /* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
37
- export const Drawer = slotted('Drawer', DefaultDrawer);
38
+ export const Drawer = slotted('Drawer', DefaultDrawer, { onOpenChange: [1, 'implicit'] });
@@ -14,6 +14,7 @@
14
14
  */
15
15
  import { type ReactNode, type Ref } from 'react';
16
16
  import { Menu } from '@base-ui/react/menu';
17
+ import { type ChangeDetails } from './changeDetails.js';
17
18
  interface DropMenuProps {
18
19
  /** The wrapper's class — where the stylesheet places the control. */
19
20
  className?: string;
@@ -29,7 +30,7 @@ interface DropMenuProps {
29
30
  align?: 'start' | 'end';
30
31
  sideOffset?: number;
31
32
  open?: boolean;
32
- onOpenChange?: (open: boolean) => void;
33
+ onOpenChange?: (open: boolean, details: ChangeDetails<'trigger-hover' | 'trigger-focus' | 'trigger-press' | 'outside-press' | 'focus-out' | 'list-navigation' | 'escape-key' | 'item-press' | 'close-press' | 'sibling-open' | 'cancel-open' | 'imperative-action' | 'implicit'>) => void;
33
34
  /** Where the focus goes when the menu closes; absent, back to the trigger. */
34
35
  finalFocus?: Menu.Popup.Props['finalFocus'];
35
36
  children: ReactNode;
package/dist/DropMenu.js CHANGED
@@ -18,6 +18,7 @@ import { Menu } from '@base-ui/react/menu';
18
18
  import { layoutViewport, zoomAnchor } from './internal/anchor.js';
19
19
  import { popupContainer } from './internal/popups.js';
20
20
  import { buttonClass } from './Button.js';
21
+ import { fromBaseUi } from './changeDetails.js';
21
22
  import { slotted } from './internal/uiKitContext.js';
22
23
  function DefaultDropMenu({ className, triggerClassName = buttonClass(), triggerTitle, triggerLabel, label, popupClassName = 'dd-list', side = 'bottom', align = 'end', sideOffset = 4, open, onOpenChange, finalFocus, children, }) {
23
24
  const trigger = useRef(null);
@@ -35,7 +36,7 @@ function DefaultDropMenu({ className, triggerClassName = buttonClass(), triggerT
35
36
  if (!next && details.reason === 'escape-key' && finalFocus === undefined)
36
37
  trigger.current?.focus({ preventScroll: true });
37
38
  setOwn(next);
38
- onOpenChange?.(next);
39
+ onOpenChange?.(next, fromBaseUi(details, 'implicit'));
39
40
  };
40
41
  return (_jsx("div", { className: className || undefined, children: _jsxs(Menu.Root, { open: isOpen, onOpenChange: change, children: [_jsx(Menu.Trigger, { render: _jsx("button", { type: "button", className: triggerClassName, title: triggerTitle, "aria-label": triggerLabel, ref: trigger }), children: label }), _jsx(Menu.Portal, { container: container ?? popupContainer(), children: _jsx(Menu.Positioner, { anchor: () => (trigger.current ? zoomAnchor(trigger.current) : null), positionMethod: "fixed", side: side, align: align, sideOffset: sideOffset, collisionBoundary: layoutViewport(), collisionPadding: 8, style: { zIndex: 90 }, children: _jsx(Menu.Popup, { className: popupClassName, finalFocus: finalFocus, children: children }) }) })] }) }));
41
42
  }
@@ -52,7 +53,7 @@ function DefaultDropItem({ className = 'dd-option', disabled, closeOnClick, onCl
52
53
  return (_jsx(Menu.Item, { render: _jsx("button", { type: "button", className: className, title: title, ref: ref }), nativeButton: true, disabled: disabled, closeOnClick: closeOnClick, onClick: onClick, children: children }));
53
54
  }
54
55
  /* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
55
- export const DropMenu = slotted('DropMenu', DefaultDropMenu);
56
+ export const DropMenu = slotted('DropMenu', DefaultDropMenu, { onOpenChange: [1, 'implicit'] });
56
57
  export const DropGroup = slotted('DropGroup', DefaultDropGroup);
57
58
  export const DropSeparator = slotted('DropSeparator', DefaultDropSeparator);
58
59
  export const DropItem = slotted('DropItem', DefaultDropItem);
@@ -15,6 +15,7 @@
15
15
  * it is, so choosing "re-read the schema" cannot select it.
16
16
  */
17
17
  import { type Ref } from 'react';
18
+ import { type ChangeDetails } from './changeDetails.js';
18
19
  export interface DropdownItem {
19
20
  value: string;
20
21
  label: string;
@@ -25,6 +26,10 @@ export interface DropdownItem {
25
26
  tone?: 'good' | 'warn' | 'bad' | 'info' | 'neutral';
26
27
  swatches?: string[];
27
28
  }
29
+ /** Why a dropdown's choice moved: an option pressed (or chosen by key); `autofill`, the browser filling the hidden
30
+ field; or `sync`, which Base UI reports with no event at all — a letter typed on the closed button, or a chosen option
31
+ that left the list — and cannot be told apart, so it reads as the page's own change. */
32
+ export type DropdownChange = ChangeDetails<'item-press' | 'autofill' | 'sync'>;
28
33
  interface DropdownBase {
29
34
  items: DropdownItem[];
30
35
  /** What a reader hears the list called; the kit's Dropdown supplies its catalog's word where a caller names none. */
@@ -38,7 +43,7 @@ interface DropdownBase {
38
43
  /** The button, for a form that needs to put focus on this control. */
39
44
  buttonRef?: Ref<HTMLButtonElement>;
40
45
  popupRef?: Ref<HTMLDivElement>;
41
- onOpenChange?: (open: boolean) => void;
46
+ onOpenChange?: (open: boolean, details: ChangeDetails<'trigger-press' | 'outside-press' | 'escape-key' | 'window-resize' | 'item-press' | 'focus-out' | 'list-navigation' | 'cancel-open' | 'implicit'>) => void;
42
47
  disabled?: boolean;
43
48
  readOnly?: boolean;
44
49
  /** A class on the shown value — a page title that is also a picker. */
@@ -56,12 +61,12 @@ interface DropdownBase {
56
61
  }
57
62
  export type DropdownProps = DropdownBase & {
58
63
  value: string;
59
- onChange: (value: string) => void;
64
+ onChange: (value: string, details: DropdownChange) => void;
60
65
  };
61
66
  /** `MultiDropdown`'s: the list of values taken and given, kept in the items' order. */
62
67
  export type MultiDropdownProps = DropdownBase & {
63
68
  value: string[];
64
- onChange: (value: string[]) => void;
69
+ onChange: (value: string[], details: DropdownChange) => void;
65
70
  };
66
71
  export interface DropdownAction {
67
72
  label: string;
package/dist/Dropdown.js CHANGED
@@ -19,6 +19,7 @@ import { useEffect, useId, useRef, useState } from 'react';
19
19
  import { Select } from '@base-ui/react/select';
20
20
  import { layoutViewport, zoomAnchor } from './internal/anchor.js';
21
21
  import { popupContainer } from './internal/popups.js';
22
+ import { fromBaseUi } from './changeDetails.js';
22
23
  import { slotted } from './internal/uiKitContext.js';
23
24
  /* A value no option could carry, so an action's row is told apart from an option's. */
24
25
  const ACTION = '~~action:';
@@ -65,10 +66,12 @@ function DropdownList(props) {
65
66
  else if (buttonRef)
66
67
  buttonRef.current = node;
67
68
  };
68
- return (_jsx("div", { className: "dd", ref: root, children: _jsxs(Select.Root, { multiple: many || undefined, value: (many ? chosen : selected ? selected.value : null), disabled: disabled, readOnly: readOnly, onOpenChange: onOpenChange,
69
+ return (_jsx("div", { className: "dd", ref: root, children: _jsxs(Select.Root, { multiple: many || undefined, value: (many ? chosen : selected ? selected.value : null), disabled: disabled, readOnly: readOnly, onOpenChange: onOpenChange && ((next, details) => onOpenChange(next, fromBaseUi(details, 'implicit'))),
69
70
  /* The labels, handed over: without them Base UI mounts the list
70
71
  once, hidden, to read the selected label off an item. */
71
- items: items.map((i) => ({ value: i.value, label: i.label })), onValueChange: (next) => {
72
+ items: items.map((i) => ({ value: i.value, label: i.label })), onValueChange: (next, details) => {
73
+ const unnamed = details.event?.type === 'base-ui' ? 'sync' : 'autofill';
74
+ const change = fromBaseUi(details, unnamed);
72
75
  if (props.multiple === true) {
73
76
  if (!Array.isArray(next))
74
77
  return;
@@ -76,7 +79,7 @@ function DropdownList(props) {
76
79
  if (ran)
77
80
  actions[Number(ran.slice(ACTION.length))]?.onSelect();
78
81
  else
79
- props.onChange(items.map((i) => i.value).filter((v) => next.includes(v)));
82
+ props.onChange(items.map((i) => i.value).filter((v) => next.includes(v)), change);
80
83
  return;
81
84
  }
82
85
  if (typeof next !== 'string')
@@ -86,9 +89,10 @@ function DropdownList(props) {
86
89
  return;
87
90
  }
88
91
  if (next !== props.value)
89
- props.onChange(next);
92
+ props.onChange(next, change);
90
93
  }, children: [_jsxs(Select.Trigger, { render: _jsx("button", { type: "button", role: "button", id: buttonId, className: buttonClassName ? `dd-button ${buttonClassName}` : 'dd-button', ref: setTrigger, "aria-label": ariaLabelledBy ? undefined : ariaLabel, "aria-labelledby": ariaLabelledBy ?? (ariaLabel ? `${buttonId} ${valueId ?? shownId}` : undefined), "aria-invalid": ariaInvalid || undefined, "aria-describedby": ariaDescribedBy, title: selected?.detail ?? '' }), children: [selected?.swatches && (_jsx("span", { className: "dd-swatches", "aria-hidden": "true", children: selected.swatches.map((color, index) => (_jsx("span", { style: { background: color } }, index))) })), _jsx("span", { id: valueId ?? shownId, className: `dd-value${valueClassName ? ` ${valueClassName}` : ''}${said ? '' : ' is-empty'}`, children: said || placeholder || '—' }), _jsx("span", { className: "dd-caret", "aria-hidden": "true", children: "\u25BE" })] }), _jsx(Select.Portal, { container: container ?? popupContainer(), children: _jsx(Select.Positioner, { anchor: () => (trigger.current ? zoomAnchor(trigger.current) : null), alignItemWithTrigger: false, positionMethod: "fixed", side: "bottom", align: "start", sideOffset: 4, collisionBoundary: layoutViewport(), collisionPadding: 8, style: { zIndex: 40 }, children: _jsx(Select.Popup, { ref: popupRef, className: "dd-popup", children: _jsxs(Select.List, { className: ['dd-list', many ? 'dd-list-multi' : '', listClassName].filter(Boolean).join(' '), "aria-label": ariaLabel, "aria-labelledby": ariaLabel ? undefined : ariaLabelledBy?.split(' ')[0], children: [items.map((item) => (_jsxs(Select.Item, { value: item.value, label: item.label, disabled: item.disabled, className: (s) => `dd-option${s.selected ? ' selected' : ''}${item.disabled ? ' disabled' : ''}${item.tone ? ` dd-tone-${item.tone}` : ''}${s.highlighted ? ' active' : ''}`, children: [many ? (_jsx("span", { className: "dd-box", "aria-hidden": "true" })) : (_jsx("span", { className: "dd-check", "aria-hidden": "true", children: item.value === props.value ? '✓' : '' })), item.swatches && (_jsx("span", { className: "dd-swatches", "aria-hidden": "true", children: item.swatches.map((color, index) => (_jsx("span", { style: { background: color } }, index))) })), _jsxs("span", { className: "dd-text", children: [_jsx("span", { className: "dd-label", children: item.label }), item.detail && _jsx("span", { className: "dd-detail", children: item.detail })] }), item.badge && _jsx("span", { className: "dd-badge", children: item.badge })] }, item.value))), actions.length ? _jsx("div", { className: "dd-divider", role: "presentation" }) : null, actions.map((action, i) => (_jsxs(Select.Item, { value: `${ACTION}${i}`, label: action.label, className: (s) => `dd-option dd-action${s.highlighted ? ' active' : ''}`, children: [_jsx("span", { className: "dd-check", "aria-hidden": "true" }), _jsx("span", { className: "dd-text", children: _jsx("span", { className: "dd-label", children: action.label }) })] }, action.label)))] }) }) }) })] }) }));
91
94
  }
95
+ const DROPDOWN_FILLS = { onChange: [1, 'item-press'], onOpenChange: [1, 'implicit'] };
92
96
  /* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
93
- export const Dropdown = slotted('Dropdown', DefaultDropdown);
94
- export const MultiDropdown = slotted('MultiDropdown', DefaultMultiDropdown);
97
+ export const Dropdown = slotted('Dropdown', DefaultDropdown, DROPDOWN_FILLS);
98
+ export const MultiDropdown = slotted('MultiDropdown', DefaultMultiDropdown, DROPDOWN_FILLS);
@@ -7,6 +7,7 @@
7
7
  * the bytes; this sends nothing. Props only. Preview: @mistriwork/ui is Preview at 1.0.
8
8
  */
9
9
  import { type ReactNode, type Ref } from 'react';
10
+ import { type ChangeDetails } from './changeDetails.js';
10
11
  import { type FieldFrame } from './fieldFrame.js';
11
12
  interface FileFieldBase extends FieldFrame {
12
13
  /** What the picker offers, as the input's `accept`: `.csv`, `text/csv`, `image/*`, separated by commas. */
@@ -28,12 +29,12 @@ export type FileFieldProps = FileFieldBase & ({
28
29
  multiple?: false;
29
30
  /** The chosen file; null while there is none. Set it to null to clear the choice. */
30
31
  value: File | null;
31
- onChange: (file: File | null) => void;
32
+ onChange: (file: File | null, details: ChangeDetails<'file-pick'>) => void;
32
33
  } | {
33
34
  multiple: true;
34
35
  /** The chosen files; empty while there are none. Set it to `[]` to clear the choice. */
35
36
  value: File[];
36
- onChange: (files: File[]) => void;
37
+ onChange: (files: File[], details: ChangeDetails<'file-pick'>) => void;
37
38
  });
38
39
  export declare function FileField(props: FileFieldProps): ReactNode;
39
40
  export {};
package/dist/FileField.js CHANGED
@@ -9,6 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  */
10
10
  import { useEffect, useRef } from 'react';
11
11
  import { buttonClass } from './Button.js';
12
+ import { changeDetails } from './changeDetails.js';
12
13
  import { Field } from './Field.js';
13
14
  import { frameOf } from './fieldFrame.js';
14
15
  export function FileField(props) {
@@ -30,9 +31,10 @@ export function FileField(props) {
30
31
  props.inputRef.current = node;
31
32
  }, className: "field-file-input", type: "file", name: props.name, accept: props.accept, disabled: props.disabled, multiple: props.multiple === true, onChange: (e) => {
32
33
  const files = Array.from(e.target.files ?? []);
34
+ const details = changeDetails('file-pick', e);
33
35
  if (props.multiple === true)
34
- props.onChange(files);
36
+ props.onChange(files, details);
35
37
  else
36
- props.onChange(files[0] ?? null);
38
+ props.onChange(files[0] ?? null, details);
37
39
  } }), _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') })] })) }));
38
40
  }
@@ -10,12 +10,13 @@
10
10
  * a pager for a single page is noise.
11
11
  */
12
12
  import type { ReactNode } from 'react';
13
+ import { type ChangeDetails } from './changeDetails.js';
13
14
  export interface PaginationProps {
14
15
  /** The current page, 1-based. */
15
16
  page: number;
16
17
  /** The number of pages. */
17
18
  pages: number;
18
- onPageChange: (page: number) => void;
19
+ onPageChange: (page: number, details: ChangeDetails<'page-press'>) => void;
19
20
  /** The list's accessible name, where the pager needs one ("Invoices, pages"). */
20
21
  ariaLabel?: string;
21
22
  /** Every word the pager says, in the caller's language; any left out are English. */