@allxsmith/bestax-bulma 5.26.2 → 5.26.4

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 (82) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/extras.css +1 -1
  4. package/dist/extras.css.map +1 -1
  5. package/dist/index.cjs +992 -580
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.esm.js +992 -580
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/types/elements/Progress.d.ts +6 -1
  10. package/dist/types/form/Checkboxes.d.ts +7 -0
  11. package/dist/types/form/Control.d.ts +14 -2
  12. package/dist/types/form/DateInput.d.ts +28 -3
  13. package/dist/types/form/DateInputBase.d.ts +17 -3
  14. package/dist/types/form/DateTimeInput.d.ts +28 -3
  15. package/dist/types/form/DateTimeInputBase.d.ts +17 -3
  16. package/dist/types/form/File.d.ts +6 -0
  17. package/dist/types/form/FormContext.d.ts +39 -7
  18. package/dist/types/form/Input.d.ts +21 -4
  19. package/dist/types/form/InputBase.d.ts +5 -2
  20. package/dist/types/form/Radios.d.ts +7 -0
  21. package/dist/types/form/Rate.d.ts +7 -0
  22. package/dist/types/form/Select.d.ts +13 -2
  23. package/dist/types/form/Slider.d.ts +7 -0
  24. package/dist/types/form/Taginput.d.ts +6 -0
  25. package/dist/types/form/TextArea.d.ts +9 -2
  26. package/dist/types/form/TextAreaBase.d.ts +12 -3
  27. package/dist/types/form/TimeInput.d.ts +28 -3
  28. package/dist/types/form/TimeInputBase.d.ts +21 -4
  29. package/dist/types/form/_pickerInternals/Calendar.d.ts +17 -2
  30. package/dist/types/form/_pickerInternals/PickerPopover.d.ts +6 -0
  31. package/dist/types/form/_pickerInternals/dateUtils.d.ts +17 -0
  32. package/dist/types/form/controlLoading.d.ts +4 -0
  33. package/dist/types/helpers/Theme.d.ts +13 -4
  34. package/dist/types/helpers/portal.d.ts +2 -1
  35. package/dist/types/helpers/useAnchoredPosition.d.ts +10 -1
  36. package/dist/types/helpers/useFocusTrap.d.ts +13 -5
  37. package/dist/types/helpers/useOtherClasses.d.ts +13 -1
  38. package/dist/types-cjs/elements/Progress.d.ts +6 -1
  39. package/dist/types-cjs/form/Checkboxes.d.ts +7 -0
  40. package/dist/types-cjs/form/Control.d.ts +14 -2
  41. package/dist/types-cjs/form/DateInput.d.ts +28 -3
  42. package/dist/types-cjs/form/DateInputBase.d.ts +17 -3
  43. package/dist/types-cjs/form/DateTimeInput.d.ts +28 -3
  44. package/dist/types-cjs/form/DateTimeInputBase.d.ts +17 -3
  45. package/dist/types-cjs/form/File.d.ts +6 -0
  46. package/dist/types-cjs/form/FormContext.d.ts +39 -7
  47. package/dist/types-cjs/form/Input.d.ts +21 -4
  48. package/dist/types-cjs/form/InputBase.d.ts +5 -2
  49. package/dist/types-cjs/form/Radios.d.ts +7 -0
  50. package/dist/types-cjs/form/Rate.d.ts +7 -0
  51. package/dist/types-cjs/form/Select.d.ts +13 -2
  52. package/dist/types-cjs/form/Slider.d.ts +7 -0
  53. package/dist/types-cjs/form/Taginput.d.ts +6 -0
  54. package/dist/types-cjs/form/TextArea.d.ts +9 -2
  55. package/dist/types-cjs/form/TextAreaBase.d.ts +12 -3
  56. package/dist/types-cjs/form/TimeInput.d.ts +28 -3
  57. package/dist/types-cjs/form/TimeInputBase.d.ts +21 -4
  58. package/dist/types-cjs/form/_pickerInternals/Calendar.d.ts +17 -2
  59. package/dist/types-cjs/form/_pickerInternals/PickerPopover.d.ts +6 -0
  60. package/dist/types-cjs/form/_pickerInternals/dateUtils.d.ts +17 -0
  61. package/dist/types-cjs/form/controlLoading.d.ts +4 -0
  62. package/dist/types-cjs/helpers/Theme.d.ts +13 -4
  63. package/dist/types-cjs/helpers/portal.d.ts +2 -1
  64. package/dist/types-cjs/helpers/useAnchoredPosition.d.ts +10 -1
  65. package/dist/types-cjs/helpers/useFocusTrap.d.ts +13 -5
  66. package/dist/types-cjs/helpers/useOtherClasses.d.ts +13 -1
  67. package/dist/versions/bestax-no-dark-mode.css +1 -1
  68. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  69. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  70. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  71. package/dist/versions/bestax-no-helpers.css +1 -1
  72. package/dist/versions/bestax-no-helpers.css.map +1 -1
  73. package/dist/versions/bestax-prefixed.css +1 -1
  74. package/dist/versions/bestax-prefixed.css.map +1 -1
  75. package/package.json +1 -1
  76. package/src/scss/elements/_index.scss +2 -0
  77. package/src/scss/elements/_progress.scss +17 -0
  78. package/src/scss/elements/_skeleton.scss +21 -0
  79. package/src/scss/form/_datetimeinput.scss +9 -0
  80. package/src/scss/form/_picker-popover.scss +23 -4
  81. package/src/scss/form/_rate.scss +3 -1
  82. package/src/scss/form/_timeinput.scss +12 -2
@@ -17,7 +17,11 @@ export interface TimeInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
17
17
  onOpen?: () => void;
18
18
  /** Fired when the popover closes. */
19
19
  onClose?: () => void;
20
- /** Earliest selectable time. */
20
+ /**
21
+ * Earliest selectable time. A `min` before year 1 is raised to midnight on
22
+ * 1 January of year 1, and a `value` dated before then is out of range, so
23
+ * the wheels and typing change nothing on it, as in the date pickers.
24
+ */
21
25
  min?: Date;
22
26
  /** Latest selectable time. */
23
27
  max?: Date;
@@ -32,7 +36,11 @@ export interface TimeInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
32
36
  * @defaultValue (see below)
33
37
  */
34
38
  format?: DateFormatOption;
35
- /** Custom parser. */
39
+ /**
40
+ * Custom parser. Enter and leaving the field call it only if the user
41
+ * changed the text, so focus passing through commits nothing and the value
42
+ * keeps what the format leaves out, such as seconds and the date.
43
+ */
36
44
  parse?: (s: string) => Date | null;
37
45
  /** BCP-47 locale tag for Intl formatting. */
38
46
  locale?: string;
@@ -55,7 +63,11 @@ export interface TimeInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
55
63
  closeOnSelect?: boolean;
56
64
  /** Popover anchor position relative to the input. */
57
65
  position?: PickerPosition;
58
- /** Render the popover into `document.body` via portal. */
66
+ /**
67
+ * Render the popover into `document.body` via portal. On a narrow screen
68
+ * an in-place popover spans the bottom of the viewport, while a portaled
69
+ * one stays on its `position` corner.
70
+ */
59
71
  appendToBody?: boolean;
60
72
  /**
61
73
  * Bulma color modifier for the input, also carried by the wheels, where it
@@ -83,7 +95,12 @@ export interface TimeInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
83
95
  unselectableTimes?: (d: Date) => boolean;
84
96
  /** Decorative left icon glyph for the wrapping `Control` (shown by default). Set `''` to hide. */
85
97
  iconLeftName?: string;
86
- /** Show a clickable launcher button on the right that toggles the popover. Default `true`. */
98
+ /**
99
+ * Show a clickable launcher button on the right that toggles the popover.
100
+ * Hidden by default while a `Control` it sits in shows its `isLoading`
101
+ * spinner, which shares that right edge.
102
+ * @defaultValue true
103
+ */
87
104
  triggerIcon?: boolean;
88
105
  /** Glyph for the right launcher button. */
89
106
  triggerIconName?: string;
@@ -5,6 +5,10 @@ export interface CalendarProps {
5
5
  focusedDate: Date;
6
6
  onSelect: (d: Date) => void;
7
7
  onFocusedDateChange: (d: Date) => void;
8
+ /**
9
+ * Earliest selectable date. One before year 1, or none, counts as the start
10
+ * of year 1.
11
+ */
8
12
  min?: Date;
9
13
  max?: Date;
10
14
  shouldDisableDate?: (d: Date) => boolean;
@@ -18,13 +22,18 @@ export interface CalendarProps {
18
22
  size?: 'small' | 'medium' | 'large';
19
23
  className?: string;
20
24
  id?: string;
21
- /** When true, focus the cell matching `focusedDate` after each render. */
25
+ /**
26
+ * When true, the day or month grid takes focus as it renders, and again as
27
+ * it comes back from the year list. With or without it, once a grid has
28
+ * focus, focus follows its tab stop from cell to cell.
29
+ */
22
30
  autoFocusCell?: boolean;
23
31
  /** Optional translatable string overrides. */
24
32
  labels?: PickerLabels;
25
33
  /**
26
34
  * Inclusive `[min, max]` year range shown in the year-dropdown view.
27
- * Defaults to ±100 years around the focused year, clamped by `min`/`max`.
35
+ * Defaults to ±100 years around the focused year, clamped by `min`/`max`
36
+ * and never reaching below year 1.
28
37
  * At `'year'` granularity the window centres on the year focused when the
29
38
  * calendar mounted, so moving focus never reflows the list.
30
39
  */
@@ -38,5 +47,11 @@ export interface CalendarProps {
38
47
  */
39
48
  granularity?: DateGranularity;
40
49
  }
50
+ /**
51
+ * Selects the calendar's focused cell, the one tab stop of whichever grid or
52
+ * year list is on show, for a popover to put focus on as it opens. It runs
53
+ * against the whole panel, so it matches only inside the grid or the list.
54
+ */
55
+ export declare const CALENDAR_FOCUSED_CELL = "[role=\"grid\"] [data-focused=\"true\"], [role=\"listbox\"] [data-focused-year=\"true\"]";
41
56
  export declare const Calendar: React.FC<CalendarProps>;
42
57
  export default Calendar;
@@ -22,6 +22,12 @@ export interface PickerPopoverProps {
22
22
  * would be recorded instead, and that cell leaves with the panel.
23
23
  */
24
24
  restoreFocusRef?: React.RefObject<HTMLElement | null>;
25
+ /**
26
+ * Selects the element in the panel that takes focus as it opens, such as a
27
+ * calendar's focused date rather than the first button in its header. When
28
+ * nothing matches, or the match can't take focus, the first tab stop does.
29
+ */
30
+ initialFocusSelector?: string;
25
31
  }
26
32
  export declare const PickerPopover: React.FC<PickerPopoverProps>;
27
33
  export default PickerPopover;
@@ -19,6 +19,18 @@ export declare function endOfMonth(d: Date): Date;
19
19
  * turning into 1900–1999.
20
20
  */
21
21
  export declare function makeDate(year: number, month?: number, day?: number): Date;
22
+ /**
23
+ * The earliest year the pickers accept. HTML's date, month and datetime-local
24
+ * inputs hold no year below 1, so the calendar, typing and parsing stop there
25
+ * too.
26
+ */
27
+ export declare const FIRST_YEAR = 1;
28
+ /**
29
+ * The lower bound a picker applies: `min`, raised to local midnight on
30
+ * 1 January of {@link FIRST_YEAR} when it is earlier or absent. A `min` in
31
+ * range comes back as the same object.
32
+ */
33
+ export declare function floorMin(min?: Date): Date;
22
34
  /**
23
35
  * First instant of the day, month or year containing `d`. Works by setters on
24
36
  * a copy rather than the `Date(y, m, d)` constructor, which reads years 0–99
@@ -64,6 +76,11 @@ export declare function getTimeOfDay(d: Date): {
64
76
  minutes: number;
65
77
  seconds: number;
66
78
  };
79
+ /**
80
+ * A copy of `d` moved into `[min, max]`. When `min` is after `max` nothing is
81
+ * in range and `min` wins, so clamping twice gives the same date and a
82
+ * picker's focus stays off the years before 1 under a `max` before then.
83
+ */
67
84
  export declare function clampDate(d: Date, min?: Date, max?: Date): Date;
68
85
  /**
69
86
  * Snap a Date's time-of-day to the nearest grid defined by the given
@@ -0,0 +1,4 @@
1
+ /** Provider for the loading state, used internally by `Control`. */
2
+ export declare const ControlLoadingProvider: import("react").Provider<boolean>;
3
+ /** Whether the nearest enclosing `Control` is loading; `false` outside one. */
4
+ export declare const useControlLoading: () => boolean;
@@ -11,10 +11,6 @@ type BulmaVars = Partial<Record<BulmaVarKey, string>>;
11
11
  *
12
12
  * @property {React.ReactNode} children - Content to render inside the theme scope.
13
13
  * @property {string} [className] - Additional CSS classes (only when isRoot is false).
14
- * @property {'light' | 'dark' | 'system'} [colorMode] - Set Bulma's light/dark scheme by writing
15
- * the `data-theme` attribute on the document root (`<html>`). This is always global, even on a
16
- * scoped Theme. `'system'` removes the attribute so Bulma follows the OS `prefers-color-scheme`.
17
- * Omit to leave the current setting untouched.
18
14
  * @property {BulmaVars} [bulmaVars] - Object mapping Bulma CSS variable names to values.
19
15
  * @property {string} [schemeH] - Scheme hue value.
20
16
  * @property {string} [schemeS] - Scheme saturation value.
@@ -76,6 +72,19 @@ export interface ThemeProps extends Omit<BulmaClassesProps, 'color' | 'backgroun
76
72
  * server render does not include them.
77
73
  */
78
74
  isRoot?: boolean;
75
+ /**
76
+ * Set Bulma's light/dark scheme by writing its theme attribute on the
77
+ * document root (`<html>`). This is always global, even on a scoped Theme.
78
+ * `'system'` removes the attribute so Bulma follows the OS
79
+ * `prefers-color-scheme`. Omit to leave the current setting untouched.
80
+ *
81
+ * The attribute is `data-theme`. A stylesheet built with a class prefix
82
+ * reads Bulma's prefixed form instead (`data-bestax-theme` for the
83
+ * `bestax-prefixed` builds), so under a `ConfigProvider` `classPrefix`
84
+ * Theme writes both, and `'system'` or unmounting clears or restores both.
85
+ * If the prefix cannot form an attribute name, `'light'` and `'dark'`
86
+ * write only `data-theme` and warn in development.
87
+ */
79
88
  colorMode?: 'light' | 'dark' | 'system';
80
89
  bulmaVars?: BulmaVars;
81
90
  /**
@@ -56,7 +56,8 @@ export interface PortalProps {
56
56
  * Tab order and focus follow the DOM too. Content portaled from inside a
57
57
  * focus trap is no longer inside the trapped element, so the trap neither
58
58
  * reaches it nor holds focus there: render nested overlays inside the
59
- * trapped element, or give them a trap of their own.
59
+ * trapped element, or give them a trap of their own. To trap portaled
60
+ * content, put `useFocusTrap`'s ref on the element inside the `Portal`.
60
61
  *
61
62
  * @function
62
63
  * @param {PortalProps} props - Props for the Portal component.
@@ -28,7 +28,10 @@ export interface UseAnchoredPositionOptions {
28
28
  /**
29
29
  * The gap between the anchor and the panel, in pixels, that the hook puts
30
30
  * there itself: added to the fixed coordinates and to the room `auto` asks
31
- * for below the anchor.
31
+ * for below the anchor. Popover and the pickers' popover pass `0` and take
32
+ * their gap from a margin in their stylesheet, read through `styledGap`, so
33
+ * a theme's offset moves the panel and `auto` alike. A new panel should do
34
+ * the same rather than rely on this default, which no stylesheet sees.
32
35
  * @defaultValue 4
33
36
  */
34
37
  offset?: number;
@@ -39,6 +42,12 @@ export interface UseAnchoredPositionOptions {
39
42
  */
40
43
  styledGap?: (panel: HTMLElement) => number;
41
44
  }
45
+ /**
46
+ * A `styledGap` for a panel whose stylesheet puts the gap in a margin on the
47
+ * side facing the anchor, negative on a portaled panel above it, so the
48
+ * larger magnitude is the gap. In pixels.
49
+ */
50
+ export declare function marginGap(panel: HTMLElement): number;
42
51
  /**
43
52
  * Places a floating panel against its anchor: resolves `auto` to a corner
44
53
  * and, for a panel fixed to the viewport, works out its coordinates. It
@@ -61,12 +61,20 @@ export interface UseFocusTrapOptions {
61
61
  * behaviour, and a modal also has to block the page behind it, which `Modal`
62
62
  * does. Content the container renders through a portal lives elsewhere in
63
63
  * the DOM, so it is outside the trap: render nested overlays inside the
64
- * container, or give them a trap of their own.
64
+ * container, or give them a trap of their own. To trap content a `Portal`
65
+ * renders, pass a ref to the element inside the `Portal` as `containerRef`.
65
66
  *
66
- * The container has to be in the DOM when the trap turns on. The trap waits
67
- * for hydration, so a container that only appears once the page has
68
- * hydrated, the way portaled content does, still has it attach in the commit
69
- * where the container appears.
67
+ * The trap looks at `containerRef` again each time the component calling it
68
+ * renders. A container that mounts after the trap turns on, such as a panel
69
+ * waiting for a `Portal` target held in state, has it attach once that
70
+ * component renders with the container in the DOM. When the container leaves
71
+ * or is replaced, the trap lets go of it as it would turning off, handing
72
+ * focus back, and attaches to the next one.
73
+ * A child that mounts the container in a render of its own (from its own
74
+ * state, or as a `Suspense` boundary resolves) goes unseen until the
75
+ * component calling the hook renders again. The trap waits for hydration, so
76
+ * that component renders again when the page hydrates, and portaled content,
77
+ * which first appears then, is found.
70
78
  *
71
79
  * @function useFocusTrap
72
80
  * @param containerRef - Ref to the element focus stays inside.
@@ -25,7 +25,17 @@ export interface BulmaOtherProps {
25
25
  * on this axis.
26
26
  */
27
27
  overflowY?: (typeof validAxisOverflows)[number];
28
- /** Applies overlay styling if true. */
28
+ /**
29
+ * Covers the nearest positioned ancestor (`is-overlay`): `position:
30
+ * absolute` with `top`, `right`, `bottom` and `left` at 0.
31
+ *
32
+ * `pos` and `relative` set `position` with `!important`, so beside
33
+ * `overlay` either one replaces the `absolute` and keeps the zero offsets.
34
+ * `pos="fixed"` then covers the viewport instead of the ancestor. `sticky`,
35
+ * `relative` and `static` put the element back in the normal flow, where it
36
+ * covers nothing, and a sticky one sticks at every edge of its scroll
37
+ * container.
38
+ */
29
39
  overlay?: boolean;
30
40
  /** Interaction behavior (e.g., 'unselectable', 'clickable'). */
31
41
  interaction?: (typeof validInteractions)[number];
@@ -63,6 +73,8 @@ export interface BulmaOtherProps {
63
73
  * own CSS. `sticky` in particular does nothing until one is set.
64
74
  *
65
75
  * When `pos` is set it decides the position, and `relative` adds nothing.
76
+ * Beside `overlay` it replaces the overlay's `absolute` but not its zero
77
+ * offsets; see `overlay`.
66
78
  */
67
79
  pos?: (typeof validPositions)[number];
68
80
  /**
@@ -18,7 +18,12 @@ export interface ProgressProps extends React.ProgressHTMLAttributes<HTMLProgress
18
18
  color?: (typeof validColors)[number];
19
19
  /** Size modifier for the progress bar. */
20
20
  size?: 'small' | 'medium' | 'large';
21
- /** Current value of the progress bar. */
21
+ /**
22
+ * Current value of the progress bar. Leave it unset for an indeterminate
23
+ * bar, which sweeps across the track. Under `prefers-reduced-motion: reduce`
24
+ * that bar holds still (with bestax's CSS loaded), so it can read as
25
+ * partly filled.
26
+ */
22
27
  value?: number;
23
28
  /** Maximum value of the progress bar. */
24
29
  max?: number;
@@ -3,6 +3,13 @@ import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
3
3
  import { FormFieldProps } from './fieldProps.js';
4
4
  /**
5
5
  * Props for the Checkboxes component.
6
+ * Inside an existing `Control` it renders no `Control` of its own. Inside an
7
+ * outer `Field`, or a `Control` with no `Field` around it, it renders no
8
+ * `Field` of its own either. The exception is `label`, `message`, `horizontal`
9
+ * or `fieldClassName` in that bare `Control`: it keeps a `Field` for them,
10
+ * nested in the `.control`, and warns in development. Wrap the `Control` in a
11
+ * `Field` instead, and set the `label`, `horizontal` and class name on that
12
+ * `Field`.
6
13
  */
7
14
  export interface CheckboxesProps extends Omit<BulmaClassesProps, 'color'>, FormFieldProps {
8
15
  /** Field label naming the whole group. Automatically associated via `aria-labelledby` on the `role="group"` wrapper — uses your `labelProps.id` when provided, otherwise a generated one. Dropped inside an outer `Field` (label that `Field` yourself). */
@@ -13,6 +13,8 @@ export interface ControlBaseProps extends React.HTMLAttributes<HTMLDivElement>,
13
13
  * Shows a loading spinner inside the control.
14
14
  * Under `prefers-reduced-motion: reduce` the spinner stops and stays
15
15
  * drawn (with bestax's CSS loaded).
16
+ * The spinner sits at the right edge, where a right icon also sits, and the
17
+ * two overlap; leave the right icon out while loading.
16
18
  */
17
19
  isLoading?: boolean;
18
20
  /** Makes the control expand to fill available space. */
@@ -25,9 +27,19 @@ export interface ControlBaseProps extends React.HTMLAttributes<HTMLDivElement>,
25
27
  color?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
26
28
  /** Background color. */
27
29
  bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
28
- /** Icon props for left icon, or a custom node (an inline SVG, a `react-icons` component, …) rendered in place of a class-based glyph. */
30
+ /**
31
+ * Icon props for left icon, or a custom node (an inline SVG, a `react-icons` component, …) rendered in place of a class-based glyph.
32
+ * Bulma gives control icons `pointer-events: none`, so a click lands on
33
+ * the input and a clickable node placed here never receives one. Put a button beside the input
34
+ * in its own addon `Control` instead.
35
+ */
29
36
  iconLeft?: IconProps | React.ReactNode;
30
- /** Icon props for right icon, or a custom node (an inline SVG, a `react-icons` component, …) rendered in place of a class-based glyph. */
37
+ /**
38
+ * Icon props for right icon, or a custom node (an inline SVG, a `react-icons` component, …) rendered in place of a class-based glyph.
39
+ * Bulma gives control icons `pointer-events: none`, so a click lands on
40
+ * the input and a clickable node placed here never receives one. Put a button beside the input
41
+ * in its own addon `Control` instead.
42
+ */
31
43
  iconRight?: IconProps | React.ReactNode;
32
44
  /** Shortcut for left icon name. */
33
45
  iconLeftName?: string;
@@ -5,6 +5,13 @@ import { DateInputBaseProps } from './DateInputBase.js';
5
5
  /**
6
6
  * Props for the DateInput convenience wrapper. Extends `DateInputBaseProps`
7
7
  * with Field-level (label, horizontal) and Control-level (icons, loading) props.
8
+ * Inside an existing `Control` it renders no `Control` of its own, so set the
9
+ * Control-level props on that `Control` instead. Inside an outer `Field`, or a
10
+ * `Control` with no `Field` around it, it renders no `Field` of its own either.
11
+ * The exception is `label`, `message`, `horizontal` or `fieldClassName` in that
12
+ * bare `Control`: it keeps a `Field` for them, nested in the `.control`, and
13
+ * warns in development. Wrap the `Control` in a `Field` instead, and set the
14
+ * `label`, `horizontal` and class name on that `Field`.
8
15
  * @extraProp {string} [name] - Form field name. The text field submits the text it displays. The native input on touch devices submits the ISO value (`YYYY-MM-DD`, or `YYYY-MM` at month granularity), and an `inline` calendar, which has no visible input, submits it from a hidden input (`YYYY-MM-DD`, `YYYY-MM` or `YYYY`).
9
16
  * @extraProp {string} [form] - Form id the input belongs to.
10
17
  * @extraProp {boolean} [required=false] - Marks the input as required.
@@ -20,9 +27,17 @@ export interface DateInputProps extends DateInputBaseProps {
20
27
  labelProps?: FieldProps['labelProps'];
21
28
  /** Render the field with horizontal layout. */
22
29
  horizontal?: boolean;
23
- /** Icon props for the left icon. */
30
+ /**
31
+ * Icon props for the left icon.
32
+ * Bulma gives control icons `pointer-events: none`, so a clickable node here
33
+ * never receives a click. Put a button beside the input in its own addon `Control` instead.
34
+ */
24
35
  iconLeft?: ControlBaseProps['iconLeft'];
25
- /** Icon props for the right icon. */
36
+ /**
37
+ * Icon props for the right icon.
38
+ * Bulma gives control icons `pointer-events: none`, so a clickable node here
39
+ * never receives a click. Put a button beside the input in its own addon `Control` instead.
40
+ */
26
41
  iconRight?: ControlBaseProps['iconRight'];
27
42
  /** Shortcut for the right icon name. */
28
43
  iconRightName?: string;
@@ -35,11 +50,21 @@ export interface DateInputProps extends DateInputBaseProps {
35
50
  /** Force the right icon container. */
36
51
  hasIconsRight?: boolean;
37
52
  /**
38
- * Show a loading spinner on the control.
53
+ * Shows a loading spinner on the `Control` it renders, and hides the
54
+ * launcher (`triggerIcon`) while it does. Inside your own `Control` it
55
+ * renders none, so this draws nothing; set `isLoading` on that `Control`.
39
56
  * Under `prefers-reduced-motion: reduce` the spinner stops and stays
40
57
  * drawn (with bestax's CSS loaded).
41
58
  */
42
59
  isLoading?: boolean;
60
+ /**
61
+ * Show a clickable launcher button on the right that toggles the popover.
62
+ * Hidden by default while a spinner shows at the same right edge: this
63
+ * component's `isLoading` when it renders its own `Control`, or the
64
+ * enclosing `Control`'s `isLoading` inside one.
65
+ * @defaultValue true
66
+ */
67
+ triggerIcon?: boolean;
43
68
  /** Expand the control to fill its container. */
44
69
  isExpanded?: boolean;
45
70
  /** Size of the wrapping Control. */
@@ -17,7 +17,11 @@ export interface DateInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
17
17
  onOpen?: () => void;
18
18
  /** Fired when the popover closes. */
19
19
  onClose?: () => void;
20
- /** Earliest selectable date. */
20
+ /**
21
+ * Earliest selectable date. A `min` before year 1 is raised to 1 January of
22
+ * year 1, where the range starts without one too: HTML's date and month
23
+ * inputs hold no earlier year, so the calendar and typing stop there.
24
+ */
21
25
  min?: Date;
22
26
  /** Latest selectable date. */
23
27
  max?: Date;
@@ -54,7 +58,12 @@ export interface DateInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
54
58
  * @defaultValue 'YYYY-MM-DD'
55
59
  */
56
60
  format?: DateFormatOption;
57
- /** Custom parser (use when `format` is `Intl.DateTimeFormatOptions`). */
61
+ /**
62
+ * Custom parser (use when `format` is `Intl.DateTimeFormatOptions`).
63
+ * Enter and leaving the field call it only if the user changed the text,
64
+ * so focus passing through commits nothing and the value keeps what the
65
+ * format leaves out, such as the time of day.
66
+ */
58
67
  parse?: (s: string) => Date | null;
59
68
  /** BCP-47 locale tag for day/month names and Intl formatting. */
60
69
  locale?: string;
@@ -115,7 +124,12 @@ export interface DateInputBaseProps extends Omit<React.InputHTMLAttributes<HTMLI
115
124
  nearbyMonthDays?: boolean;
116
125
  /** Decorative left icon glyph for the wrapping `Control` (shown by default). Set `''` to hide. */
117
126
  iconLeftName?: string;
118
- /** Show a clickable launcher button on the right that toggles the popover. Default `true`. */
127
+ /**
128
+ * Show a clickable launcher button on the right that toggles the popover.
129
+ * Hidden by default while a `Control` it sits in shows its `isLoading`
130
+ * spinner, which shares that right edge.
131
+ * @defaultValue true
132
+ */
119
133
  triggerIcon?: boolean;
120
134
  /** Glyph for the right launcher button. */
121
135
  triggerIconName?: string;
@@ -5,6 +5,13 @@ import { DateTimeInputBaseProps } from './DateTimeInputBase.js';
5
5
  /**
6
6
  * Props for the DateTimeInput convenience wrapper. Extends
7
7
  * `DateTimeInputBaseProps` with Field-level and Control-level props.
8
+ * Inside an existing `Control` it renders no `Control` of its own, so set the
9
+ * Control-level props on that `Control` instead. Inside an outer `Field`, or a
10
+ * `Control` with no `Field` around it, it renders no `Field` of its own either.
11
+ * The exception is `label`, `message`, `horizontal` or `fieldClassName` in that
12
+ * bare `Control`: it keeps a `Field` for them, nested in the `.control`, and
13
+ * warns in development. Wrap the `Control` in a `Field` instead, and set the
14
+ * `label`, `horizontal` and class name on that `Field`.
8
15
  * @extraProp {string} [name] - Form field name.
9
16
  * @extraProp {string} [form] - Optional id of the form the input belongs to.
10
17
  * @extraProp {boolean} [required=false] - Marks the field as required for native HTML form validation.
@@ -18,9 +25,17 @@ export interface DateTimeInputProps extends DateTimeInputBaseProps {
18
25
  labelProps?: FieldProps['labelProps'];
19
26
  /** Render the field with horizontal layout. */
20
27
  horizontal?: boolean;
21
- /** Icon props for the left icon. */
28
+ /**
29
+ * Icon props for the left icon.
30
+ * Bulma gives control icons `pointer-events: none`, so a clickable node here
31
+ * never receives a click. Put a button beside the input in its own addon `Control` instead.
32
+ */
22
33
  iconLeft?: ControlBaseProps['iconLeft'];
23
- /** Icon props for the right icon. */
34
+ /**
35
+ * Icon props for the right icon.
36
+ * Bulma gives control icons `pointer-events: none`, so a clickable node here
37
+ * never receives a click. Put a button beside the input in its own addon `Control` instead.
38
+ */
24
39
  iconRight?: ControlBaseProps['iconRight'];
25
40
  /** Shortcut for the right icon name. */
26
41
  iconRightName?: string;
@@ -33,11 +48,21 @@ export interface DateTimeInputProps extends DateTimeInputBaseProps {
33
48
  /** Force the right icon container. */
34
49
  hasIconsRight?: boolean;
35
50
  /**
36
- * Show a loading spinner on the control.
51
+ * Shows a loading spinner on the `Control` it renders, and hides the
52
+ * launcher (`triggerIcon`) while it does. Inside your own `Control` it
53
+ * renders none, so this draws nothing; set `isLoading` on that `Control`.
37
54
  * Under `prefers-reduced-motion: reduce` the spinner stops and stays
38
55
  * drawn (with bestax's CSS loaded).
39
56
  */
40
57
  isLoading?: boolean;
58
+ /**
59
+ * Show a clickable launcher button on the right that toggles the popover.
60
+ * Hidden by default while a spinner shows at the same right edge: this
61
+ * component's `isLoading` when it renders its own `Control`, or the
62
+ * enclosing `Control`'s `isLoading` inside one.
63
+ * @defaultValue true
64
+ */
65
+ triggerIcon?: boolean;
41
66
  /** Expand the control to fill its container. */
42
67
  isExpanded?: boolean;
43
68
  /** Size of the wrapping Control. */
@@ -18,7 +18,12 @@ export interface DateTimeInputBaseProps extends Omit<React.InputHTMLAttributes<H
18
18
  onOpen?: () => void;
19
19
  /** Fired when the popover closes. */
20
20
  onClose?: () => void;
21
- /** Lower bound for the combined date-time. */
21
+ /**
22
+ * Lower bound for the combined date-time. A `min` before year 1 is raised
23
+ * to midnight on 1 January of year 1, where the range starts without one
24
+ * too: HTML's datetime-local input holds no earlier year, so the calendar,
25
+ * the time wheels and typing stop there.
26
+ */
22
27
  min?: Date;
23
28
  /** Upper bound for the combined date-time. */
24
29
  max?: Date;
@@ -33,7 +38,11 @@ export interface DateTimeInputBaseProps extends Omit<React.InputHTMLAttributes<H
33
38
  * @defaultValue 'YYYY-MM-DD HH:mm'
34
39
  */
35
40
  format?: DateFormatOption;
36
- /** Custom parser. */
41
+ /**
42
+ * Custom parser. Enter and leaving the field call it only if the user
43
+ * changed the text, so focus passing through commits nothing and the value
44
+ * keeps what the format leaves out, such as seconds.
45
+ */
37
46
  parse?: (s: string) => Date | null;
38
47
  /** BCP-47 locale tag. */
39
48
  locale?: string;
@@ -102,7 +111,12 @@ export interface DateTimeInputBaseProps extends Omit<React.InputHTMLAttributes<H
102
111
  unselectableTimes?: (d: Date) => boolean;
103
112
  /** Decorative left icon glyph for the wrapping `Control` (shown by default). Set `''` to hide. */
104
113
  iconLeftName?: string;
105
- /** Show a clickable launcher button on the right that toggles the popover. Default `true`. */
114
+ /**
115
+ * Show a clickable launcher button on the right that toggles the popover.
116
+ * Hidden by default while a `Control` it sits in shows its `isLoading`
117
+ * spinner, which shares that right edge.
118
+ * @defaultValue true
119
+ */
106
120
  triggerIcon?: boolean;
107
121
  /** Glyph for the right launcher button. */
108
122
  triggerIconName?: string;
@@ -3,6 +3,12 @@ import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
3
3
  import { FormFieldProps } from './fieldProps.js';
4
4
  /**
5
5
  * Props for the File component.
6
+ * Inside an outer `Field`, or a `Control` with no `Field` around it, it
7
+ * renders no `Field` of its own. The exception is `label`, `message`,
8
+ * `horizontal` or `fieldClassName` in that bare `Control`: it keeps a `Field`
9
+ * for them, nested in the `.control`, and warns in development. Wrap the
10
+ * `Control` in a `Field` instead, and set the `label`, `horizontal` and class
11
+ * name on that `Field`.
6
12
  */
7
13
  export interface FileProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'color' | 'type'>, Omit<BulmaClassesProps, 'color'>, FormFieldProps {
8
14
  /** Field label. Automatically associated with the file input via `htmlFor` — uses your `id` when provided, otherwise a generated one. The input then has two labels (this one plus the wrapping `file-label`); assistive tech reads both. Dropped inside an outer `Field` (label that `Field` yourself). */
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  /**
2
3
  * Hook to detect if the component is inside a Field wrapper.
3
4
  * Form components use this to skip rendering their own Field.
@@ -9,9 +10,39 @@ export declare const useInsideField: () => boolean;
9
10
  */
10
11
  export declare const useInsideControl: () => boolean;
11
12
  /** Provider for Field context — used internally by Field component. */
12
- export declare const FieldProvider: import("react").Provider<boolean>;
13
+ export declare const FieldProvider: React.Provider<boolean>;
13
14
  /** Provider for Control context — used internally by Control component. */
14
- export declare const ControlProvider: import("react").Provider<boolean>;
15
+ export declare const ControlProvider: React.Provider<boolean>;
16
+ /** The wrapper props that change what its own `Field` renders. */
17
+ interface FieldShapingProps {
18
+ /** Rendered as the `Field`'s label. */
19
+ label?: React.ReactNode;
20
+ /** Rendered as help text after the widget. */
21
+ message?: React.ReactNode;
22
+ /** Lays the `Field` out horizontally. */
23
+ horizontal?: boolean;
24
+ /** Set on the `Field` as its class. */
25
+ fieldClassName?: string;
26
+ }
27
+ interface OwnFieldOptions extends FieldShapingProps {
28
+ /** `useInsideField()` as the wrapper read it. */
29
+ insideField: boolean;
30
+ /** `useInsideControl()` as the wrapper read it. */
31
+ insideControl: boolean;
32
+ }
33
+ /**
34
+ * Whether a convenience form wrapper renders a `Field` of its own (#905).
35
+ * Never inside an outer `Field`. Inside a `Control` with no `Field` around
36
+ * it, a `Field` of its own would put a `.field` inside the `.control`, where
37
+ * Bulma's control styles break (its icon rules are sibling selectors on the
38
+ * input). So it renders one there only when a prop that shapes the `Field`'s
39
+ * markup is set (`label`, `message`, `horizontal`, `fieldClassName`), keeping
40
+ * the markup it always had, and warns in development that the fix is a
41
+ * `Field` around that `Control`. A prop counts when it is truthy, the same
42
+ * test that decides whether it changes the `Field`'s output.
43
+ * Internal; not part of the public API.
44
+ */
45
+ export declare const rendersOwnField: (component: string, options: OwnFieldOptions) => boolean;
15
46
  /**
16
47
  * The id a labeled Field wants its single composed control to adopt (#495).
17
48
  * `undefined` outside a Field, in unlabeled/grouped/addons Fields, or when the
@@ -21,7 +52,7 @@ export declare const ControlProvider: import("react").Provider<boolean>;
21
52
  */
22
53
  export declare const useFieldLabelId: () => string | undefined;
23
54
  /** Provider for the Field label-target id — used internally by Field. */
24
- export declare const FieldLabelIdProvider: import("react").Provider<string | undefined>;
55
+ export declare const FieldLabelIdProvider: React.Provider<string | undefined>;
25
56
  /**
26
57
  * Shape of the Radios group context. The group provides:
27
58
  * - `name`: shared form field name (Stage 1)
@@ -69,10 +100,11 @@ export declare const useRadiosName: () => string | undefined;
69
100
  */
70
101
  export declare const useCheckboxesName: () => string | undefined;
71
102
  /** Provider for the Radios group context — used internally by Radios. */
72
- export declare const RadiosProvider: import("react").Provider<RadiosGroupContextValue | undefined>;
103
+ export declare const RadiosProvider: React.Provider<RadiosGroupContextValue | undefined>;
73
104
  /** Provider for the Checkboxes group context — used internally by Checkboxes. */
74
- export declare const CheckboxesProvider: import("react").Provider<CheckboxesGroupContextValue | undefined>;
105
+ export declare const CheckboxesProvider: React.Provider<CheckboxesGroupContextValue | undefined>;
75
106
  /** @deprecated Use `RadiosProvider` (provides {name, value, onChange}). */
76
- export declare const RadiosNameProvider: import("react").Provider<RadiosGroupContextValue | undefined>;
107
+ export declare const RadiosNameProvider: React.Provider<RadiosGroupContextValue | undefined>;
77
108
  /** @deprecated Use `CheckboxesProvider` (provides {name, value, onChange}). */
78
- export declare const CheckboxesNameProvider: import("react").Provider<CheckboxesGroupContextValue | undefined>;
109
+ export declare const CheckboxesNameProvider: React.Provider<CheckboxesGroupContextValue | undefined>;
110
+ export {};