@allxsmith/bestax-bulma 5.61.0 → 5.63.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.
- package/dist/bestax.css +1 -1
- package/dist/bestax.css.map +1 -1
- package/dist/esm/components/EmptyState.js +2 -6
- package/dist/esm/components/EmptyState.js.map +1 -1
- package/dist/esm/components/Timeline.js +5 -9
- package/dist/esm/components/Timeline.js.map +1 -1
- package/dist/esm/components/TreeView.js +16 -16
- package/dist/esm/components/TreeView.js.map +1 -1
- package/dist/esm/elements/Buttons.js +2 -0
- package/dist/esm/elements/Buttons.js.map +1 -1
- package/dist/esm/elements/CopyButton.js +132 -0
- package/dist/esm/elements/CopyButton.js.map +1 -0
- package/dist/esm/elements/DescriptionList.js +1 -5
- package/dist/esm/elements/DescriptionList.js.map +1 -1
- package/dist/esm/elements/Stat.js +196 -0
- package/dist/esm/elements/Stat.js.map +1 -0
- package/dist/esm/elements/Stats.js +48 -0
- package/dist/esm/elements/Stats.js.map +1 -0
- package/dist/esm/elements/statContext.js +10 -0
- package/dist/esm/elements/statContext.js.map +1 -0
- package/dist/esm/form/Combobox.js +10 -14
- package/dist/esm/form/Combobox.js.map +1 -1
- package/dist/esm/form/Field.js.map +1 -1
- package/dist/esm/form/TreeSelect.js +395 -0
- package/dist/esm/form/TreeSelect.js.map +1 -0
- package/dist/esm/form/_pickerInternals/PickerPopover.js +5 -1
- package/dist/esm/form/_pickerInternals/PickerPopover.js.map +1 -1
- package/dist/esm/form/_selectInternals/DialogSelect.js +208 -0
- package/dist/esm/form/_selectInternals/DialogSelect.js.map +1 -0
- package/dist/esm/form/_selectInternals/ValueTags.js +28 -0
- package/dist/esm/form/_selectInternals/ValueTags.js.map +1 -0
- package/dist/esm/helpers/checkIcon.js +20 -0
- package/dist/esm/helpers/checkIcon.js.map +1 -0
- package/dist/esm/helpers/isGiven.js +13 -0
- package/dist/esm/helpers/isGiven.js.map +1 -0
- package/dist/esm/helpers/statusRegion.js +3 -3
- package/dist/esm/helpers/treeData.js +97 -0
- package/dist/esm/helpers/treeData.js.map +1 -0
- package/dist/esm/helpers/useClipboard.js +176 -0
- package/dist/esm/helpers/useClipboard.js.map +1 -0
- package/dist/esm/helpers/useComboboxEngine.js +2 -2
- package/dist/esm/helpers/useComboboxEngine.js.map +1 -1
- package/dist/esm/helpers/useControlled.js +30 -0
- package/dist/esm/helpers/useControlled.js.map +1 -0
- package/dist/esm/helpers/useTreeView.js +15 -13
- package/dist/esm/helpers/useTreeView.js.map +1 -1
- package/dist/extras.css +1 -1
- package/dist/extras.css.map +1 -1
- package/dist/index.cjs +10605 -9380
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +5 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/types/elements/Buttons.d.ts +1 -0
- package/dist/types/elements/CopyButton.d.ts +105 -0
- package/dist/types/elements/Stat.d.ts +242 -0
- package/dist/types/elements/Stats.d.ts +40 -0
- package/dist/types/elements/statContext.d.ts +18 -0
- package/dist/types/form/Field.d.ts +1 -1
- package/dist/types/form/TreeSelect.d.ts +308 -0
- package/dist/types/form/_pickerInternals/PickerPopover.d.ts +8 -0
- package/dist/types/form/_selectInternals/DialogSelect.d.ts +86 -0
- package/dist/types/form/_selectInternals/ValueTags.d.ts +40 -0
- package/dist/types/helpers/checkIcon.d.ts +10 -0
- package/dist/types/helpers/isGiven.d.ts +7 -0
- package/dist/types/helpers/treeData.d.ts +48 -0
- package/dist/types/helpers/useClipboard.d.ts +65 -0
- package/dist/types/helpers/useControlled.d.ts +14 -0
- package/dist/types/helpers/useTreeView.d.ts +30 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types-cjs/elements/Buttons.d.ts +1 -0
- package/dist/types-cjs/elements/CopyButton.d.ts +105 -0
- package/dist/types-cjs/elements/Stat.d.ts +242 -0
- package/dist/types-cjs/elements/Stats.d.ts +40 -0
- package/dist/types-cjs/elements/statContext.d.ts +18 -0
- package/dist/types-cjs/form/Field.d.ts +1 -1
- package/dist/types-cjs/form/TreeSelect.d.ts +308 -0
- package/dist/types-cjs/form/_pickerInternals/PickerPopover.d.ts +8 -0
- package/dist/types-cjs/form/_selectInternals/DialogSelect.d.ts +86 -0
- package/dist/types-cjs/form/_selectInternals/ValueTags.d.ts +40 -0
- package/dist/types-cjs/helpers/checkIcon.d.ts +10 -0
- package/dist/types-cjs/helpers/isGiven.d.ts +7 -0
- package/dist/types-cjs/helpers/treeData.d.ts +48 -0
- package/dist/types-cjs/helpers/useClipboard.d.ts +65 -0
- package/dist/types-cjs/helpers/useControlled.d.ts +14 -0
- package/dist/types-cjs/helpers/useTreeView.d.ts +30 -0
- package/dist/types-cjs/index.d.ts +6 -0
- package/dist/versions/bestax-no-dark-mode.css +1 -1
- package/dist/versions/bestax-no-dark-mode.css.map +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
- package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
- package/dist/versions/bestax-no-helpers.css +1 -1
- package/dist/versions/bestax-no-helpers.css.map +1 -1
- package/dist/versions/bestax-prefixed.css +1 -1
- package/dist/versions/bestax-prefixed.css.map +1 -1
- package/package.json +1 -1
- package/src/scss/elements/_index.scss +1 -0
- package/src/scss/elements/_stat.scss +153 -0
- package/src/scss/form/_index.scss +1 -0
- package/src/scss/form/_picker-popover.scss +6 -0
- package/src/scss/form/_treeselect.scss +146 -0
package/dist/index.esm.js
CHANGED
|
@@ -44,6 +44,7 @@ export { ToggleButton } from './esm/elements/ToggleButton.js';
|
|
|
44
44
|
export { Code } from './esm/elements/Code.js';
|
|
45
45
|
export { ColorSwatch } from './esm/elements/ColorSwatch.js';
|
|
46
46
|
export { Content } from './esm/elements/Content.js';
|
|
47
|
+
export { CopyButton } from './esm/elements/CopyButton.js';
|
|
47
48
|
export { Delete } from './esm/elements/Delete.js';
|
|
48
49
|
export { DescriptionList, DescriptionListItem, DescriptionListLabel, DescriptionListValue } from './esm/elements/DescriptionList.js';
|
|
49
50
|
export { Divider } from './esm/elements/Divider.js';
|
|
@@ -66,6 +67,8 @@ export { Progress } from './esm/elements/Progress.js';
|
|
|
66
67
|
export { RingProgress } from './esm/elements/RingProgress.js';
|
|
67
68
|
export { Skeleton } from './esm/elements/Skeleton.js';
|
|
68
69
|
export { Span } from './esm/elements/Span.js';
|
|
70
|
+
export { Stat, StatChange, StatDescription, StatLabel, StatValue } from './esm/elements/Stat.js';
|
|
71
|
+
export { Stats } from './esm/elements/Stats.js';
|
|
69
72
|
export { Strong } from './esm/elements/Strong.js';
|
|
70
73
|
export { SubTitle } from './esm/elements/SubTitle.js';
|
|
71
74
|
export { Table } from './esm/elements/Table.js';
|
|
@@ -97,6 +100,7 @@ export { PinInput } from './esm/form/PinInput.js';
|
|
|
97
100
|
export { Rate } from './esm/form/Rate.js';
|
|
98
101
|
export { Autocomplete } from './esm/form/Autocomplete.js';
|
|
99
102
|
export { Combobox, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxList, ComboboxMenu } from './esm/form/Combobox.js';
|
|
103
|
+
export { TreeSelect } from './esm/form/TreeSelect.js';
|
|
100
104
|
export { TagInput, Taginput } from './esm/form/Taginput.js';
|
|
101
105
|
export { ColorPicker, ColorPickerAlphaSlider, ColorPickerArea, ColorPickerHueSlider, ColorPickerInput, ColorPickerSwatches } from './esm/form/ColorPicker.js';
|
|
102
106
|
export { InputBase } from './esm/form/InputBase.js';
|
|
@@ -129,6 +133,7 @@ export { Portal } from './esm/helpers/portal.js';
|
|
|
129
133
|
export { LocaleProvider, useLocale } from './esm/helpers/LocaleProvider.js';
|
|
130
134
|
export { useNumberFormat } from './esm/helpers/localeFormat.js';
|
|
131
135
|
export { useFocusTrap } from './esm/helpers/useFocusTrap.js';
|
|
136
|
+
export { useClipboard } from './esm/helpers/useClipboard.js';
|
|
132
137
|
export { AppFrame, AppFrameAside, AppFrameBurger, AppFrameFooter, AppFrameHeader, AppFrameMain, AppFrameNav, useAppFrame } from './esm/layout/AppFrame.js';
|
|
133
138
|
export { Center } from './esm/layout/Center.js';
|
|
134
139
|
export { Container } from './esm/layout/Container.js';
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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>;
|
|
@@ -12,7 +12,7 @@ export interface FieldProps extends React.HTMLAttributes<HTMLDivElement>, Omit<B
|
|
|
12
12
|
hasAddons?: boolean | 'centered' | 'right';
|
|
13
13
|
/** Constrains the field to its content's width (used inside horizontal field bodies). */
|
|
14
14
|
narrow?: boolean;
|
|
15
|
-
/** Field label, rendered above the widget. Automatically names the one control the Field holds: a composed `InputBase`, `SelectBase`, `TextAreaBase`, `DateInputBase`, `TimeInputBase` or `DateTimeInputBase` (an `inline` picker has no input, so it takes nothing), or a bestax input that renders a single input of its own (`Input`, `Select`, `TextArea`, `Numberinput`, `PinInput`, `Slider`, `DateInput`, `TimeInput`, `DateTimeInput`, `Autocomplete`, `Combobox`, `Taginput`, `File`), adopts a generated id that the label's `htmlFor` points at, and a group (`Radios`, `Checkboxes`, `Rate`, `DateRangeInput`, or a composed `DateRangeInputBase`, `inline` or not) points `aria-labelledby` at the label's own id unless you gave the group an `aria-label` or `aria-labelledby`. A range `Slider` takes the id on its low thumb and also starts each thumb's name with the label through `aria-labelledby`, unless its `ariaLabel` names that thumb or its own `aria-label` or `aria-labelledby` takes the label's place. An `Autocomplete`, a `Combobox` or a `Taginput` also names its open list after the label through `aria-labelledby
|
|
15
|
+
/** Field label, rendered above the widget. Automatically names the one control the Field holds: a composed `InputBase`, `SelectBase`, `TextAreaBase`, `DateInputBase`, `TimeInputBase` or `DateTimeInputBase` (an `inline` picker has no input, so it takes nothing), or a bestax input that renders a single input of its own (`Input`, `Select`, `TextArea`, `Numberinput`, `PinInput`, `Slider`, `DateInput`, `TimeInput`, `DateTimeInput`, `Autocomplete`, `Combobox`, `TreeSelect`, `Taginput`, `File`), adopts a generated id that the label's `htmlFor` points at, and a group (`Radios`, `Checkboxes`, `Rate`, `DateRangeInput`, or a composed `DateRangeInputBase`, `inline` or not) points `aria-labelledby` at the label's own id unless you gave the group an `aria-label` or `aria-labelledby`. A range `Slider` takes the id on its low thumb and also starts each thumb's name with the label through `aria-labelledby`, unless its `ariaLabel` names that thumb or its own `aria-label` or `aria-labelledby` takes the label's place. An `Autocomplete`, a `Combobox` or a `Taginput` also names its open list after the label through `aria-labelledby`, and a `TreeSelect` its panel and the tree in it. `Checkbox`, `Radio` and `Switch` are named by their own children, and the label names one only when you wire it as you would any control with an `id` of its own, `labelProps={{ htmlFor }}` plus that control's `id`. Only the single inputs take the `htmlFor`, so once the Field's content has mounted the label keeps it only while one of them holds the id, and drops it over anything else: a group, a `Checkbox`, `Radio` or `Switch`, an `inline` picker, an inner `Field`, an input with an `id` of its own, markup of your own, or nothing at all. A server render, and the first render while hydrating, still write the `htmlFor`, which keeps hydration matching, and an input that mounts later puts it back. The label names an input with an `id` of your own only through `labelProps={{ htmlFor }}` set to that `id`, a `for` it always keeps; `labelProps={{ htmlFor: undefined }}` opts out. Skipped for `grouped`/`hasAddons` fields (multiple controls), and a nested `Field` starts its own scope, so a horizontal Field whose body holds an inner `Field` names the control there only when you wire it. Two controls in one plain labeled Field would both adopt the id, so give each an `id` of its own. */
|
|
16
16
|
label?: React.ReactNode;
|
|
17
17
|
/** Size for the label. */
|
|
18
18
|
labelSize?: 'small' | 'normal' | 'medium' | 'large';
|