@allxsmith/bestax-bulma 5.62.0 → 5.64.0

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 (89) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/EmptyState.js +2 -6
  4. package/dist/esm/components/EmptyState.js.map +1 -1
  5. package/dist/esm/components/ScrollArea.js +7 -7
  6. package/dist/esm/components/ScrollArea.js.map +1 -1
  7. package/dist/esm/components/TableOfContents.js +85 -0
  8. package/dist/esm/components/TableOfContents.js.map +1 -0
  9. package/dist/esm/components/Timeline.js +5 -9
  10. package/dist/esm/components/Timeline.js.map +1 -1
  11. package/dist/esm/components/TreeView.js +3 -7
  12. package/dist/esm/components/TreeView.js.map +1 -1
  13. package/dist/esm/elements/Buttons.js +2 -0
  14. package/dist/esm/elements/Buttons.js.map +1 -1
  15. package/dist/esm/elements/CopyButton.js +132 -0
  16. package/dist/esm/elements/CopyButton.js.map +1 -0
  17. package/dist/esm/elements/DescriptionList.js +1 -5
  18. package/dist/esm/elements/DescriptionList.js.map +1 -1
  19. package/dist/esm/elements/Stat.js +196 -0
  20. package/dist/esm/elements/Stat.js.map +1 -0
  21. package/dist/esm/elements/Stats.js +48 -0
  22. package/dist/esm/elements/Stats.js.map +1 -0
  23. package/dist/esm/elements/statContext.js +10 -0
  24. package/dist/esm/elements/statContext.js.map +1 -0
  25. package/dist/esm/form/Combobox.js +2 -1
  26. package/dist/esm/form/Combobox.js.map +1 -1
  27. package/dist/esm/form/PasswordInput.js +105 -0
  28. package/dist/esm/form/PasswordInput.js.map +1 -0
  29. package/dist/esm/form/PasswordInputBase.js +177 -0
  30. package/dist/esm/form/PasswordInputBase.js.map +1 -0
  31. package/dist/esm/helpers/checkIcon.js +20 -0
  32. package/dist/esm/helpers/checkIcon.js.map +1 -0
  33. package/dist/esm/helpers/isGiven.js +13 -0
  34. package/dist/esm/helpers/isGiven.js.map +1 -0
  35. package/dist/esm/helpers/statusRegion.js +3 -3
  36. package/dist/esm/helpers/useClipboard.js +176 -0
  37. package/dist/esm/helpers/useClipboard.js.map +1 -0
  38. package/dist/esm/helpers/useScrollSpy.js +286 -0
  39. package/dist/esm/helpers/useScrollSpy.js.map +1 -0
  40. package/dist/extras.css +1 -1
  41. package/dist/extras.css.map +1 -1
  42. package/dist/index.cjs +2671 -1544
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.esm.js +8 -0
  45. package/dist/index.esm.js.map +1 -1
  46. package/dist/types/components/TableOfContents.d.ts +87 -0
  47. package/dist/types/elements/Buttons.d.ts +1 -0
  48. package/dist/types/elements/CopyButton.d.ts +105 -0
  49. package/dist/types/elements/Stat.d.ts +242 -0
  50. package/dist/types/elements/Stats.d.ts +40 -0
  51. package/dist/types/elements/statContext.d.ts +18 -0
  52. package/dist/types/form/PasswordInput.d.ts +98 -0
  53. package/dist/types/form/PasswordInputBase.d.ts +91 -0
  54. package/dist/types/helpers/checkIcon.d.ts +10 -0
  55. package/dist/types/helpers/isGiven.d.ts +7 -0
  56. package/dist/types/helpers/useClipboard.d.ts +65 -0
  57. package/dist/types/helpers/useScrollSpy.d.ts +61 -0
  58. package/dist/types/index.d.ts +10 -0
  59. package/dist/types-cjs/components/TableOfContents.d.ts +87 -0
  60. package/dist/types-cjs/elements/Buttons.d.ts +1 -0
  61. package/dist/types-cjs/elements/CopyButton.d.ts +105 -0
  62. package/dist/types-cjs/elements/Stat.d.ts +242 -0
  63. package/dist/types-cjs/elements/Stats.d.ts +40 -0
  64. package/dist/types-cjs/elements/statContext.d.ts +18 -0
  65. package/dist/types-cjs/form/PasswordInput.d.ts +98 -0
  66. package/dist/types-cjs/form/PasswordInputBase.d.ts +91 -0
  67. package/dist/types-cjs/helpers/checkIcon.d.ts +10 -0
  68. package/dist/types-cjs/helpers/isGiven.d.ts +7 -0
  69. package/dist/types-cjs/helpers/useClipboard.d.ts +65 -0
  70. package/dist/types-cjs/helpers/useScrollSpy.d.ts +61 -0
  71. package/dist/types-cjs/index.d.ts +10 -0
  72. package/dist/versions/bestax-no-dark-mode.css +1 -1
  73. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  74. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  75. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  76. package/dist/versions/bestax-no-helpers.css +1 -1
  77. package/dist/versions/bestax-no-helpers.css.map +1 -1
  78. package/dist/versions/bestax-prefixed.css +1 -1
  79. package/dist/versions/bestax-prefixed.css.map +1 -1
  80. package/package.json +1 -1
  81. package/src/scss/CLAUDE.md +3 -0
  82. package/src/scss/_input-trigger.scss +76 -0
  83. package/src/scss/components/_index.scss +1 -0
  84. package/src/scss/components/_tableofcontents.scss +42 -0
  85. package/src/scss/elements/_index.scss +1 -0
  86. package/src/scss/elements/_stat.scss +153 -0
  87. package/src/scss/form/_index.scss +1 -0
  88. package/src/scss/form/_passwordinput.scss +112 -0
  89. package/src/scss/form/_picker-popover.scss +24 -63
package/dist/index.esm.js CHANGED
@@ -35,6 +35,7 @@ export { ScrollArea } from './esm/components/ScrollArea.js';
35
35
  export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from './esm/components/Command.js';
36
36
  export { DataTable } from './esm/components/DataTable.js';
37
37
  export { Affix } from './esm/components/Affix.js';
38
+ export { TableOfContents } from './esm/components/TableOfContents.js';
38
39
  export { Block } from './esm/elements/Block.js';
39
40
  export { Box } from './esm/elements/Box.js';
40
41
  export { Button } from './esm/elements/Button.js';
@@ -44,6 +45,7 @@ export { ToggleButton } from './esm/elements/ToggleButton.js';
44
45
  export { Code } from './esm/elements/Code.js';
45
46
  export { ColorSwatch } from './esm/elements/ColorSwatch.js';
46
47
  export { Content } from './esm/elements/Content.js';
48
+ export { CopyButton } from './esm/elements/CopyButton.js';
47
49
  export { Delete } from './esm/elements/Delete.js';
48
50
  export { DescriptionList, DescriptionListItem, DescriptionListLabel, DescriptionListValue } from './esm/elements/DescriptionList.js';
49
51
  export { Divider } from './esm/elements/Divider.js';
@@ -66,6 +68,8 @@ export { Progress } from './esm/elements/Progress.js';
66
68
  export { RingProgress } from './esm/elements/RingProgress.js';
67
69
  export { Skeleton } from './esm/elements/Skeleton.js';
68
70
  export { Span } from './esm/elements/Span.js';
71
+ export { Stat, StatChange, StatDescription, StatLabel, StatValue } from './esm/elements/Stat.js';
72
+ export { Stats } from './esm/elements/Stats.js';
69
73
  export { Strong } from './esm/elements/Strong.js';
70
74
  export { SubTitle } from './esm/elements/SubTitle.js';
71
75
  export { Table } from './esm/elements/Table.js';
@@ -103,9 +107,11 @@ export { ColorPicker, ColorPickerAlphaSlider, ColorPickerArea, ColorPickerHueSli
103
107
  export { InputBase } from './esm/form/InputBase.js';
104
108
  export { SelectBase } from './esm/form/SelectBase.js';
105
109
  export { TextAreaBase } from './esm/form/TextAreaBase.js';
110
+ export { PasswordInputBase } from './esm/form/PasswordInputBase.js';
106
111
  export { Input } from './esm/form/Input.js';
107
112
  export { Select } from './esm/form/Select.js';
108
113
  export { TextArea } from './esm/form/TextArea.js';
114
+ export { PasswordInput } from './esm/form/PasswordInput.js';
109
115
  export { DateInputBase } from './esm/form/DateInputBase.js';
110
116
  export { DateInput } from './esm/form/DateInput.js';
111
117
  export { TimeInputBase } from './esm/form/TimeInputBase.js';
@@ -130,6 +136,7 @@ export { Portal } from './esm/helpers/portal.js';
130
136
  export { LocaleProvider, useLocale } from './esm/helpers/LocaleProvider.js';
131
137
  export { useNumberFormat } from './esm/helpers/localeFormat.js';
132
138
  export { useFocusTrap } from './esm/helpers/useFocusTrap.js';
139
+ export { useClipboard } from './esm/helpers/useClipboard.js';
133
140
  export { AppFrame, AppFrameAside, AppFrameBurger, AppFrameFooter, AppFrameHeader, AppFrameMain, AppFrameNav, useAppFrame } from './esm/layout/AppFrame.js';
134
141
  export { Center } from './esm/layout/Center.js';
135
142
  export { Container } from './esm/layout/Container.js';
@@ -146,6 +153,7 @@ export { useColorClasses, useColorStyles } from './esm/helpers/useColorClasses.j
146
153
  export { useDataTable } from './esm/components/useDataTable.js';
147
154
  export { useFlexboxClasses } from './esm/helpers/useFlexboxClasses.js';
148
155
  export { useOtherClasses } from './esm/helpers/useOtherClasses.js';
156
+ export { useScrollSpy } from './esm/helpers/useScrollSpy.js';
149
157
  export { useSpacingClasses } from './esm/helpers/useSpacingClasses.js';
150
158
  export { useTypographyClasses } from './esm/helpers/useTypographyClasses.js';
151
159
  export { useVisibilityClasses } from './esm/helpers/useVisibilityClasses.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
3
+ export { useScrollSpy } from '../helpers/useScrollSpy.js';
4
+ export type { UseScrollSpyOptions } from '../helpers/useScrollSpy.js';
5
+ /** One entry in a TableOfContents. */
6
+ export interface TableOfContentsItem {
7
+ /** **Required.** The `id` of the section or heading it links to, without the `#`. Unique on the page. */
8
+ id: string;
9
+ /** **Required.** What the link says, usually the heading's own text. */
10
+ label: React.ReactNode;
11
+ /** Entries under this one, drawn as a nested list. */
12
+ children?: TableOfContentsItem[];
13
+ }
14
+ /** The visible strings, in your app's language. */
15
+ export interface TableOfContentsLabels {
16
+ /**
17
+ * The list's visible title, which also names its `<nav>`.
18
+ * @defaultValue 'On this page'
19
+ */
20
+ title?: string;
21
+ }
22
+ /**
23
+ * Props for the TableOfContents component. The helper props, the other
24
+ * attributes and the `ref` land on the `<nav>`.
25
+ *
26
+ * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<nav>`.
27
+ */
28
+ export interface TableOfContentsProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color' | 'children'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
29
+ /** Additional CSS classes to apply. */
30
+ className?: string;
31
+ /**
32
+ * **Required.** The sections, in page order, as links to their ids. Each
33
+ * link is a plain `<a href="#id">`, so following one is the browser's own
34
+ * jump: put `scroll-padding-top` on the page to land clear of a sticky
35
+ * header, and smooth scrolling, if you want it, in page CSS inside
36
+ * `@media (prefers-reduced-motion: no-preference)`.
37
+ */
38
+ items: TableOfContentsItem[];
39
+ /**
40
+ * Called with the current section's id when it changes, or `null` above
41
+ * the first section. Never called on the server or before hydration.
42
+ */
43
+ onCurrentChange?: (id: string | null) => void;
44
+ /**
45
+ * Pixels from the viewport's top where a section counts as reached.
46
+ * Unset, it's the page's `scroll-padding-top`, so the highlight agrees
47
+ * with where a jump lands under a sticky header.
48
+ */
49
+ offset?: number;
50
+ /**
51
+ * Sticks to the top of the viewport as the page scrolls, at
52
+ * `--bulma-table-of-contents-sticky-top`, and scrolls itself when it's
53
+ * taller than the viewport. Adds `is-sticky`.
54
+ */
55
+ isSticky?: boolean;
56
+ /** The visible strings, in your app's language. */
57
+ labels?: TableOfContentsLabels;
58
+ /** Text color helper. */
59
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
60
+ /** Background color helper. */
61
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
62
+ }
63
+ /**
64
+ * The `TableOfContents` component lists a long page's sections as links in Bulma's menu look, and marks the one being read.
65
+ *
66
+ * It's a `<nav>` named by its title, holding `MenuList` and `MenuItem` links
67
+ * to each `#id`, rendered in full on the server. `useScrollSpy` picks the
68
+ * current section, and its link alone gets `is-active` and
69
+ * `aria-current="location"`. Use the hook on its own to mark the section in
70
+ * view somewhere else, such as an app's nav `Menu`.
71
+ *
72
+ * @function
73
+ * @param {TableOfContentsProps} props - Props for the TableOfContents component.
74
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<nav>`.
75
+ * @returns {JSX.Element} The rendered table of contents.
76
+ *
77
+ * @example
78
+ * <TableOfContents
79
+ * isSticky
80
+ * items={[
81
+ * { id: 'install', label: 'Install' },
82
+ * { id: 'usage', label: 'Usage', children: [{ id: 'props', label: 'Props' }] },
83
+ * ]}
84
+ * />
85
+ */
86
+ export declare const TableOfContents: React.ForwardRefExoticComponent<TableOfContentsProps & React.RefAttributes<HTMLElement>>;
87
+ export default TableOfContents;
@@ -38,5 +38,6 @@ export declare const Buttons: React.FC<ButtonsProps> & {
38
38
  LinkButton: import("../index.js").PolymorphicComponent<import("./LinkButton.js").LinkButtonOwnProps, "button", never>;
39
39
  ToggleButton: React.ForwardRefExoticComponent<import("./ToggleButton.js").ToggleButtonProps & React.RefAttributes<HTMLButtonElement>>;
40
40
  IconButton: import("../index.js").PolymorphicComponent<import("./IconButton.js").IconButtonOwnProps & import("./IconButton.js").IconButtonName, "button", never>;
41
+ CopyButton: React.ForwardRefExoticComponent<import("./CopyButton.js").CopyButtonProps & React.RefAttributes<HTMLButtonElement>>;
41
42
  };
42
43
  export {};
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+ import { type ButtonOwnProps } from './Button.js';
3
+ /**
4
+ * The strings CopyButton shows and announces, each with an English default. A
5
+ * key left out, or set to an empty string, keeps its default.
6
+ */
7
+ export interface CopyButtonLabels {
8
+ /**
9
+ * The button's label, and so its name, until a copy. With `showLabel` off
10
+ * it's the name in both states, given as `aria-label`.
11
+ * @defaultValue 'Copy'
12
+ */
13
+ copy?: string;
14
+ /**
15
+ * The label shown for `duration` after a copy, and so the name meanwhile.
16
+ * Not used with `showLabel` off, where only the glyph changes.
17
+ * @defaultValue 'Copied'
18
+ */
19
+ copied?: string;
20
+ /**
21
+ * Announced after a copy.
22
+ * @defaultValue 'Copied to the clipboard'
23
+ */
24
+ copiedStatus?: string;
25
+ /**
26
+ * Announced when the copy fails.
27
+ * @defaultValue "Couldn't copy to the clipboard"
28
+ */
29
+ failedStatus?: string;
30
+ }
31
+ /**
32
+ * Props for the CopyButton component. The helper props, the other button
33
+ * attributes and the `ref` land on the `<button>`.
34
+ *
35
+ * @extraProp {'button' | 'submit' | 'reset'} [type=button] - `button` unless you pass `submit` or `reset`.
36
+ * @extraProp {React.MouseEventHandler<HTMLButtonElement>} [onClick] - Runs before the copy. An `onClick` that calls `preventDefault()` stops the copy, and neither `onCopiedChange` nor `onCopyError` fires.
37
+ * @extraProp {React.Ref<HTMLButtonElement>} [ref] - Ref forwarded to the `<button>`.
38
+ */
39
+ export interface CopyButtonProps extends Omit<ButtonOwnProps, 'children'>, Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonOwnProps | 'value'> {
40
+ /**
41
+ * The text it copies. This is not the `<button>`'s form value, which it
42
+ * doesn't render.
43
+ */
44
+ value: string;
45
+ /**
46
+ * How long the "Copied" label stays, in milliseconds. Another copy
47
+ * restarts it. `0` turns the reset off, as Toast's `0` turns off its
48
+ * auto-close, so "Copied" stays until a later copy fails. A missing or `NaN`
49
+ * value uses the default, a negative one ends it at once, and `Infinity`,
50
+ * or anything longer than the longest delay `setTimeout` takes (about 24.8
51
+ * days), is that longest delay.
52
+ * @defaultValue 2000
53
+ */
54
+ duration?: number;
55
+ /**
56
+ * Shows the label beside the icon, which is then the button's name: it
57
+ * carries no `aria-label`, so the name reads "Copy" and then "Copied" as
58
+ * the words on it do. Turned off, it's a square icon-only button named by
59
+ * `labels.copy` through `aria-label` in both states, and only the glyph
60
+ * changes. An `aria-label` you pass yourself names it in either form.
61
+ * @defaultValue true
62
+ */
63
+ showLabel?: boolean;
64
+ /** Translations for the label and the announcements. */
65
+ labels?: CopyButtonLabels;
66
+ /**
67
+ * Called with `true` after each copy that worked, a repeat included, and
68
+ * with `false` when `duration` runs out or a later copy fails.
69
+ */
70
+ onCopiedChange?: (copied: boolean) => void;
71
+ /**
72
+ * Called when neither the Clipboard API nor the fallback could write. A
73
+ * copy field can select its text from here, so the reader can copy it
74
+ * themselves.
75
+ */
76
+ onCopyError?: (error: Error) => void;
77
+ }
78
+ /**
79
+ * The `CopyButton` component renders a button that copies a piece of text to the clipboard, says "Copied" for a moment, and announces the result.
80
+ *
81
+ * It's a `Button` with a copy icon and "Copy", and takes everything `Button`
82
+ * takes. A click writes `value` through the Clipboard API, or through the
83
+ * older copy command where that's missing or refused, and reports a failure
84
+ * rather than showing "Copied". Each outcome is announced through a polite
85
+ * status region portaled out of the button's place, so it stays the last
86
+ * child of a `Control` or `Buttons`: into the open modal dialog the button is
87
+ * in, otherwise where `Portal` puts portaled content (the `ConfigProvider`'s
88
+ * `portalContainer`, or the end of the page). With `showLabel={false}` it's an
89
+ * `IconButton`. For a trigger of your own, use `useClipboard`, which it's
90
+ * built on.
91
+ *
92
+ * @function
93
+ * @param {CopyButtonProps} props - Props for the CopyButton component.
94
+ * @param {React.Ref<HTMLButtonElement>} ref - Forwarded ref to the `<button>`.
95
+ * @returns {JSX.Element} The rendered button.
96
+ * @see {@link https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html | WCAG 4.1.3 Status Messages}
97
+ *
98
+ * @example
99
+ * <CopyButton value="https://bestax.io" />
100
+ *
101
+ * @example
102
+ * <CopyButton value={apiKey} showLabel={false} size="small" />
103
+ */
104
+ export declare const CopyButton: React.ForwardRefExoticComponent<CopyButtonProps & React.RefAttributes<HTMLButtonElement>>;
105
+ export default CopyButton;
@@ -0,0 +1,242 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
3
+ /** The colors a Stat's change can take, the union `messageColor` takes. */
4
+ export type StatChangeColor = 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
5
+ /**
6
+ * Props for the Stat component. The helper props, the other attributes and
7
+ * the `ref` land on its root: a `<div>` inside `Stats`, or its own `<dl>` on
8
+ * its own.
9
+ *
10
+ * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the root, a `<div>` inside `Stats` or a `<dl>` on its own.
11
+ */
12
+ export interface StatProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
13
+ /** Additional CSS classes to apply. */
14
+ className?: string;
15
+ /**
16
+ * What the figure is ("Revenue"), as a `Stat.Label` before the children.
17
+ * A Stat needs one, here or as a `Stat.Label` child: it's the figure's
18
+ * name for assistive tech, and a definition list's values belong to a
19
+ * term. A Stat with neither a `label` nor a `Stat.Label` child warns in
20
+ * development.
21
+ */
22
+ label?: React.ReactNode;
23
+ /**
24
+ * The figure, as a `Stat.Value` after the children. A number is written by
25
+ * `NumberFormatter` with `format` and `locale`; anything else, such as
26
+ * "N/A", renders as given, and `0` renders. `undefined`, `null`, a boolean
27
+ * and `''` leave it empty, and its `<dd>` still renders, one line of the
28
+ * figure tall, while the Stat has a label, so the label keeps its
29
+ * definition while the figure is missing. A `Stat.Value` child takes its
30
+ * place: with one, `value` and its `<dd>` are left out.
31
+ */
32
+ value?: React.ReactNode;
33
+ /**
34
+ * `Intl.NumberFormat` options for a number `value`, as NumberFormatter's
35
+ * `format`. A `value` that isn't a number ignores it.
36
+ */
37
+ format?: Intl.NumberFormatOptions;
38
+ /**
39
+ * The locale for `value` and `change`, as NumberFormatter's `locale`.
40
+ * Unset, it's the `LocaleProvider`'s around it, and with neither, the
41
+ * runtime's own, so give one, here or through a `LocaleProvider`, on a
42
+ * page rendered on the server.
43
+ */
44
+ locale?: string;
45
+ /**
46
+ * The change, as a `Stat.Change` after the value. With the default format
47
+ * it's a fraction (`0.12` for 12%); with your own `changeFormat`, it's in
48
+ * that format's terms. It's written with its sign, so the direction is in
49
+ * the text.
50
+ */
51
+ change?: number;
52
+ /**
53
+ * `Intl.NumberFormat` options for `change`. Yours replace the default, and
54
+ * `signDisplay: 'exceptZero'` is added unless you set a `signDisplay`. With
55
+ * `signDisplay: 'never'`, or `'negative'` on a rise, the text carries no
56
+ * direction: the arrow is hidden from assistive tech and the tone is color
57
+ * alone, so keep a sign, or say the direction in `description`.
58
+ * @defaultValue { style: 'percent', signDisplay: 'exceptZero', maximumFractionDigits: 1 }
59
+ */
60
+ changeFormat?: Intl.NumberFormatOptions;
61
+ /**
62
+ * The change's color. Unset, it's the sign's: `success` up, `danger` down,
63
+ * and none at zero. Set it where up is bad news, such as a cost or an
64
+ * error rate.
65
+ */
66
+ changeColor?: StatChangeColor;
67
+ /** A note under the figure ("since last month"), as a `Stat.Description` last. */
68
+ description?: React.ReactNode;
69
+ /**
70
+ * The figure's size, a step of Bulma's size scale. The label, the change
71
+ * and the note stay small.
72
+ */
73
+ size?: 'small' | 'medium' | 'large';
74
+ /**
75
+ * Shows a `Skeleton` in place of `value`, one line of the figure tall,
76
+ * and sets `aria-busy` on the Stat. The label, the change and the note
77
+ * render as given. With a `Stat.Value` child, it only sets `aria-busy`:
78
+ * the child renders as given, so put a `Skeleton` in it yourself.
79
+ */
80
+ loading?: boolean;
81
+ /**
82
+ * `Stat.Label`, `Stat.Value`, `Stat.Change` and `Stat.Description`, for
83
+ * anything the props don't cover, such as a unit or an info tip. They
84
+ * render between `label` and `value`. They're this Stat's own parts, so
85
+ * not another Stat: that would be a list inside this one's. The Stat finds
86
+ * a `Stat.Label` or `Stat.Value` among them by type, so one rendered from
87
+ * inside a component of your own isn't seen.
88
+ */
89
+ children?: React.ReactNode;
90
+ /**
91
+ * Text color helper. It colors the figure; the label, the change and the
92
+ * note keep their own colors. Inside `Stats`, a Stat without one takes the
93
+ * row's.
94
+ */
95
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
96
+ /** Background color helper. */
97
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
98
+ }
99
+ /**
100
+ * Props for Stat.Label, what the figure is. The helper props, the other
101
+ * attributes and the `ref` land on its `<dt>`.
102
+ *
103
+ * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<dt>`.
104
+ */
105
+ export interface StatLabelProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
106
+ /** Additional CSS classes to apply. */
107
+ className?: string;
108
+ /**
109
+ * The label. A button may sit in it, such as one that opens a `Popover`
110
+ * about the figure, but not a heading, which HTML doesn't allow here.
111
+ */
112
+ children?: React.ReactNode;
113
+ /** Text color helper. */
114
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
115
+ /** Background color helper. */
116
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
117
+ }
118
+ /**
119
+ * Props for Stat.Value, the figure. The helper props, the other attributes
120
+ * and the `ref` land on its `<dd>`.
121
+ *
122
+ * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<dd>`.
123
+ */
124
+ export interface StatValueProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
125
+ /** Additional CSS classes to apply. */
126
+ className?: string;
127
+ /**
128
+ * The figure, written as you give it, so write a number with
129
+ * `NumberFormatter`.
130
+ */
131
+ children?: React.ReactNode;
132
+ /** Text color helper. */
133
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
134
+ /** Background color helper. */
135
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
136
+ }
137
+ /**
138
+ * Props for Stat.Description, a note under the figure. The helper props, the
139
+ * other attributes and the `ref` land on its `<dd>`.
140
+ *
141
+ * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<dd>`.
142
+ */
143
+ export interface StatDescriptionProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
144
+ /** Additional CSS classes to apply. */
145
+ className?: string;
146
+ /** The note, such as "since last month". */
147
+ children?: React.ReactNode;
148
+ /** Text color helper. */
149
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
150
+ /** Background color helper. */
151
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
152
+ }
153
+ /**
154
+ * Props for Stat.Change, a change written with its sign. The helper props,
155
+ * the other attributes and the `ref` land on its `<dd>`.
156
+ *
157
+ * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<dd>`.
158
+ */
159
+ export interface StatChangeProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color' | 'children'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
160
+ /** Additional CSS classes to apply. */
161
+ className?: string;
162
+ /**
163
+ * The change, as Stat's `change`. One that rounds to zero in its format,
164
+ * such as `0.0004` at one decimal place of a percentage, reads as zero, so
165
+ * it gets no arrow and no color of its own.
166
+ */
167
+ value: number;
168
+ /**
169
+ * As Stat's `changeFormat`: yours replace the default, and
170
+ * `signDisplay: 'exceptZero'` is added unless you set a `signDisplay`.
171
+ * @defaultValue { style: 'percent', signDisplay: 'exceptZero', maximumFractionDigits: 1 }
172
+ */
173
+ format?: Intl.NumberFormatOptions;
174
+ /** As Stat's `locale`. Unset, the Stat's. */
175
+ locale?: string;
176
+ /**
177
+ * As Stat's `changeColor`. Unset, it's the sign's: `success` up, `danger`
178
+ * down, and none at zero. Set, it applies at zero too.
179
+ */
180
+ color?: StatChangeColor;
181
+ }
182
+ /**
183
+ * What the figure is: a `<dt>`, small and in the weaker text color.
184
+ *
185
+ * @function
186
+ * @param {StatLabelProps} props - Props for Stat.Label.
187
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dt>`.
188
+ * @returns {JSX.Element} The rendered label.
189
+ *
190
+ * @example
191
+ * <Stat.Label>Revenue</Stat.Label>
192
+ */
193
+ export declare const StatLabel: React.ForwardRefExoticComponent<StatLabelProps & React.RefAttributes<HTMLElement>>;
194
+ /**
195
+ * The figure: a `<dd>`, large, in the Stat's color, with digits of one width so a figure that updates doesn't shift.
196
+ *
197
+ * @function
198
+ * @param {StatValueProps} props - Props for Stat.Value.
199
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dd>`.
200
+ * @returns {JSX.Element} The rendered figure.
201
+ *
202
+ * @example
203
+ * <Stat.Value>
204
+ * <NumberFormatter value={182} format={{ style: 'unit', unit: 'millisecond' }} />
205
+ * </Stat.Value>
206
+ */
207
+ export declare const StatValue: React.ForwardRefExoticComponent<StatValueProps & React.RefAttributes<HTMLElement>>;
208
+ /**
209
+ * A note under the figure: a `<dd>`, small and in the weaker text color.
210
+ *
211
+ * @function
212
+ * @param {StatDescriptionProps} props - Props for Stat.Description.
213
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dd>`.
214
+ * @returns {JSX.Element} The rendered note.
215
+ *
216
+ * @example
217
+ * <Stat.Description>since last month</Stat.Description>
218
+ */
219
+ export declare const StatDescription: React.ForwardRefExoticComponent<StatDescriptionProps & React.RefAttributes<HTMLElement>>;
220
+ /**
221
+ * A change written with its sign, such as "+12%", after an arrow that repeats the direction: a `<dd>`, green when it's up and red when it's down unless `color` says otherwise.
222
+ *
223
+ * The sign is in the text, written by `Intl` for the locale, so a screen
224
+ * reader hears the direction; the arrow is hidden from assistive tech, and
225
+ * the color repeats the direction for sighted readers rather than carry it.
226
+ *
227
+ * @function
228
+ * @param {StatChangeProps} props - Props for Stat.Change.
229
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dd>`.
230
+ * @returns {JSX.Element} The rendered change.
231
+ *
232
+ * @example
233
+ * <Stat.Change value={-0.08} color="success" />
234
+ */
235
+ export declare const StatChange: React.ForwardRefExoticComponent<StatChangeProps & React.RefAttributes<HTMLElement>>;
236
+ export declare const Stat: React.ForwardRefExoticComponent<StatProps & React.RefAttributes<HTMLElement>> & {
237
+ Label: React.ForwardRefExoticComponent<StatLabelProps & React.RefAttributes<HTMLElement>>;
238
+ Value: React.ForwardRefExoticComponent<StatValueProps & React.RefAttributes<HTMLElement>>;
239
+ Change: React.ForwardRefExoticComponent<StatChangeProps & React.RefAttributes<HTMLElement>>;
240
+ Description: React.ForwardRefExoticComponent<StatDescriptionProps & React.RefAttributes<HTMLElement>>;
241
+ };
242
+ export default Stat;
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { BulmaClassesProps, validColors } from '../helpers/useBulmaClasses.js';
3
+ import type { BulmaMinColValue } from '../grid/Grid.js';
4
+ /**
5
+ * Props for the Stats component, a row of Stats on Bulma's smart grid. The
6
+ * helper props, the other attributes and the `ref` land on its `<dl>`.
7
+ *
8
+ * @extraProp {React.Ref<HTMLDListElement>} [ref] - Ref forwarded to the `<dl>`.
9
+ * @extraProp {BulmaGapStep} [gap] - The space between tiles (`is-gap-*`), the helper prop with the values Grid's `gap` takes.
10
+ * @extraProp {string} [aria-labelledby] - The id of the heading above the row, which names it.
11
+ */
12
+ export interface StatsProps extends Omit<React.HTMLAttributes<HTMLDListElement>, 'color'>, Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {
13
+ /** Additional CSS classes to apply. */
14
+ className?: string;
15
+ /** `Stat`s, one per figure, and nothing else: they're the groups of its `<dl>`. */
16
+ children?: React.ReactNode;
17
+ /**
18
+ * The narrowest a tile gets before the row wraps (`is-col-min-*`), as
19
+ * Grid's `minCol`: 1.5rem a step. Unset, it's Bulma's 9rem.
20
+ */
21
+ minCol?: BulmaMinColValue;
22
+ /**
23
+ * Text color helper: `has-text-*` on the `<dl>`, as on Buttons. Each Stat
24
+ * in the row without a `textColor` of its own takes it too, which colors
25
+ * its figure, since a Stat sets its own color. The labels, the changes and
26
+ * the notes keep theirs.
27
+ */
28
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
29
+ /** Background color helper. */
30
+ bgColor?: (typeof validColors)[number] | 'inherit' | 'current';
31
+ }
32
+ export declare const Stats: React.ForwardRefExoticComponent<StatsProps & React.RefAttributes<HTMLDListElement>> & {
33
+ Stat: React.ForwardRefExoticComponent<import("./Stat.js").StatProps & React.RefAttributes<HTMLElement>> & {
34
+ Label: React.ForwardRefExoticComponent<import("./Stat.js").StatLabelProps & React.RefAttributes<HTMLElement>>;
35
+ Value: React.ForwardRefExoticComponent<import("./Stat.js").StatValueProps & React.RefAttributes<HTMLElement>>;
36
+ Change: React.ForwardRefExoticComponent<import("./Stat.js").StatChangeProps & React.RefAttributes<HTMLElement>>;
37
+ Description: React.ForwardRefExoticComponent<import("./Stat.js").StatDescriptionProps & React.RefAttributes<HTMLElement>>;
38
+ };
39
+ };
40
+ export default Stats;
@@ -0,0 +1,18 @@
1
+ import type { validColors } from '../helpers/useBulmaClasses.js';
2
+ export interface StatScope {
3
+ /**
4
+ * Whether this is inside a `Stats` row, where a Stat is a `<div>` in the
5
+ * row's `<dl>` rather than a `<dl>` of its own. A Stat sets it back to
6
+ * `false` for its children. Those are meant to be its parts, so a Stat
7
+ * inside a part sits in a `<dd>`, where a `<dl>` of its own is valid. A
8
+ * Stat written straight among another's children isn't handled: it renders
9
+ * a `<dl>` inside the other's list, which HTML doesn't allow, and Stat's
10
+ * `children` TSDoc says not to.
11
+ */
12
+ row: boolean;
13
+ /** The row's `textColor`, which each Stat in it takes unless it has its own. */
14
+ textColor?: (typeof validColors)[number] | 'inherit' | 'current';
15
+ /** The Stat's `locale`, which a `Stat.Change` in it takes unless it has its own. */
16
+ locale?: string;
17
+ }
18
+ export declare const StatScopeContext: import("react").Context<StatScope>;
@@ -0,0 +1,98 @@
1
+ import React from 'react';
2
+ import { FieldProps } from './Field.js';
3
+ import { ControlBaseProps } from './Control.js';
4
+ import { PasswordInputBaseProps } from './PasswordInputBase.js';
5
+ /**
6
+ * Props for the PasswordInput component: PasswordInputBase's, plus Input's
7
+ * Field and Control props, except the right icon, whose place the toggle
8
+ * takes. Inside an existing `Control` it renders no `Control` of its own, so
9
+ * its Control-level props do nothing there and warn in development; set them
10
+ * on that `Control` instead. Inside an outer `Field`, or a `Control` with no
11
+ * `Field` around it, it renders no `Field` of its own either. The exception
12
+ * is `label`, `message`, `horizontal` or `fieldClassName` in that bare
13
+ * `Control`: it keeps a `Field` for them, nested in the `.control`, and warns
14
+ * in development. Wrap the `Control` in a `Field` instead, and set the
15
+ * `label`, `horizontal` and class name on that `Field`.
16
+ *
17
+ * @helperProps Helper props go on the `.password-input-container` `<div>`, with
18
+ * `className` and `style`, so they move and size the field and its toggle
19
+ * together. The other attributes go on the `<input>`.
20
+ * @extraProp {string} [autoComplete="current-password"] - Tells the browser and password managers this is an existing password. Pass `"new-password"` where the user makes one up, on a sign-up or change-password form.
21
+ * @extraProp {boolean} [spellCheck=false] - Off, so a browser's spellcheck never sees the password once it shows.
22
+ * @extraProp {string} [autoCorrect="off"] - Off, so a phone's keyboard doesn't change what's typed.
23
+ * @extraProp {string} [autoCapitalize="none"] - Off, so a phone's keyboard doesn't capitalize the first letter.
24
+ * @extraProp {string} [value] - The password, controlled. React writes a controlled input's value into its `value` attribute, as it does on any input, so the password sits in the page's markup. Uncontrolled, read with `FormData`, the field never puts what's typed there.
25
+ * @extraProp {React.Ref<HTMLInputElement>} [ref] - Ref forwarded to the `<input>`.
26
+ */
27
+ export interface PasswordInputProps extends PasswordInputBaseProps {
28
+ /** Field label. Automatically associated with the input via `htmlFor`, using your `id` when provided, otherwise a generated one. Dropped inside an outer `Field`, whose own label associates instead when that `Field` generates a target id (not `grouped`/`hasAddons`, no explicit `labelProps.htmlFor`) and you set no `id` here. */
29
+ label?: React.ReactNode;
30
+ /** Size for the label. */
31
+ labelSize?: FieldProps['labelSize'];
32
+ /** Props for the label element when the component renders its own `Field`; dropped inside an outer `Field` (use that `Field`'s `labelProps` instead). An explicit `htmlFor` key, even `undefined`, overrides the automatic association and no id is generated. */
33
+ labelProps?: FieldProps['labelProps'];
34
+ /** Horizontal field layout. */
35
+ horizontal?: boolean;
36
+ /**
37
+ * Icon props for the left icon.
38
+ * Bulma gives control icons `pointer-events: none`, so a clickable node here
39
+ * never receives a click.
40
+ */
41
+ iconLeft?: ControlBaseProps['iconLeft'];
42
+ /** Shortcut for the left icon's name. */
43
+ iconLeftName?: string;
44
+ /** Shortcut for the left icon's size. */
45
+ iconLeftSize?: ControlBaseProps['iconLeftSize'];
46
+ /** Force the left icon container. */
47
+ hasIconsLeft?: boolean;
48
+ /**
49
+ * Shows a loading spinner on the `Control` it renders, at the edge the
50
+ * toggle uses, so the toggle isn't drawn meanwhile, and a shown password is
51
+ * hidden until it's back. Inside your own
52
+ * `Control` it renders none, so this draws nothing and warns in
53
+ * development; set `isLoading` on that `Control`, which hides the toggle
54
+ * too.
55
+ */
56
+ isLoading?: boolean;
57
+ /** Expand the control. */
58
+ isExpanded?: boolean;
59
+ /** Control size. */
60
+ controlSize?: ControlBaseProps['size'];
61
+ /** Help/validation message below the input. */
62
+ message?: React.ReactNode;
63
+ /** Bulma color for the message. */
64
+ messageColor?: 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
65
+ /** Additional CSS classes for the Field. */
66
+ fieldClassName?: string;
67
+ /** Additional CSS classes for the Control. */
68
+ controlClassName?: string;
69
+ /** Not offered: the toggle takes the right icon's place. Warns in development if passed. @internal */
70
+ iconRight?: never;
71
+ /** Not offered, as `iconRight`. @internal */
72
+ iconRightName?: never;
73
+ /** Not offered, as `iconRight`. @internal */
74
+ iconRightSize?: never;
75
+ /** Not offered, as `iconRight`. @internal */
76
+ hasIconsRight?: never;
77
+ }
78
+ /**
79
+ * The `PasswordInput` component is a password field with a button inside it that shows what was typed.
80
+ *
81
+ * By default the button is an eye named "Show password" that reports
82
+ * whether the password shows with `aria-pressed`; `variant="text"` makes it
83
+ * the words "Show" and "Hide". The field asks for
84
+ * `autocomplete="current-password"` and no spellcheck, and hides the
85
+ * password again when its form submits.
86
+ *
87
+ * @function
88
+ * @param {PasswordInputProps} props - Props for PasswordInput.
89
+ * @returns {JSX.Element} The composed field element.
90
+ *
91
+ * @example
92
+ * <PasswordInput label="Password" />
93
+ *
94
+ * @example
95
+ * <PasswordInput label="New password" autoComplete="new-password" variant="text" />
96
+ */
97
+ export declare const PasswordInput: React.ForwardRefExoticComponent<PasswordInputProps & React.RefAttributes<HTMLInputElement>>;
98
+ export default PasswordInput;