@allxsmith/bestax-bulma 5.31.0 → 5.32.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/index.esm.js CHANGED
@@ -14,6 +14,7 @@ export { Navbar, NavbarBrand, NavbarBurger, NavbarDivider, NavbarDropdown, Navba
14
14
  export { Pagination, PaginationEllipsis, PaginationLink, PaginationList, PaginationNext, PaginationPrevious } from './esm/components/Pagination.js';
15
15
  export { Panel, PanelBlock, PanelButtonBlock, PanelCheckboxBlock, PanelHeading, PanelIcon, PanelInputBlock, PanelTabs } from './esm/components/Panel.js';
16
16
  export { Tab, TabContentItem, TabItem, TabList, Tabs, TabsContent } from './esm/components/Tabs.js';
17
+ export { SegmentedControl } from './esm/components/SegmentedControl.js';
17
18
  export { Loading } from './esm/components/Loading.js';
18
19
  export { Collapse } from './esm/components/Collapse.js';
19
20
  export { Collapses } from './esm/components/Collapses.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,116 @@
1
+ import React from 'react';
2
+ import { type ButtonOwnProps } from '../elements/Button.js';
3
+ import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
4
+ /**
5
+ * The fills the checked segment takes: `Button`'s colors, minus `text` and
6
+ * `ghost`, which don't fill, and `white`, `light`, `dark` and `black`, which in
7
+ * one theme or the other fill about as light or dark as an unchecked segment
8
+ * already is. The same set `ToggleButton` takes.
9
+ */
10
+ export type SegmentedControlColor = 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
11
+ /**
12
+ * Props for the SegmentedControl component. The helper props, the other `<div>`
13
+ * attributes and the `ref` all land on the row.
14
+ *
15
+ * @extraProp {string} [aria-label] - Names the group for a screen reader, such as "Text alignment". A radio group needs a name, so pass this or `aria-labelledby`, and a development build warns when it has neither.
16
+ * @extraProp {string} [aria-labelledby] - The id of a visible heading or label that names the group, in place of `aria-label`.
17
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the row's `<div>`.
18
+ */
19
+ export interface SegmentedControlProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue' | 'color' | 'role'>, Omit<BulmaClassesProps, 'color' | 'colorShade' | 'backgroundColor' | 'backgroundColorShade'> {
20
+ /**
21
+ * The checked segment's `value`, when you hold the state. Setting it makes
22
+ * the group controlled: picking a segment only calls `onChange`, and nothing
23
+ * changes until you pass the new value. `null` checks nothing, with the
24
+ * tab stop `defaultValue` describes for that. Pick this or `defaultValue`
25
+ * for the group's lifetime.
26
+ */
27
+ value?: string | null;
28
+ /**
29
+ * The segment checked to begin with, when the group holds its own state.
30
+ * Leave it out and nothing is checked until someone picks one, and Tab
31
+ * lands on the first enabled segment meanwhile. That fallback takes hold
32
+ * once the row has rendered in the browser: server markup with nothing
33
+ * checked has no tab stop until then, while a checked segment is the stop
34
+ * from the server markup on.
35
+ */
36
+ defaultValue?: string;
37
+ /**
38
+ * Called with the newly checked segment's `value`, whether or not `value`
39
+ * is set. The arrow keys, Home and End check the segment they move to, so
40
+ * each of those calls it too: the check follows focus, as in a native radio
41
+ * group. Pressing the checked segment again doesn't call it, since a
42
+ * segmented control can't be cleared: one stays checked once one is.
43
+ */
44
+ onChange?: (value: string) => void;
45
+ /**
46
+ * The checked segment's fill. The others are plain buttons, so the fill is
47
+ * the difference people see. Takes the same colors as `ToggleButton`, for
48
+ * the same reason: `white`, `light`, `dark` and `black` fill about as light
49
+ * or dark as a plain button already is in one theme or the other.
50
+ */
51
+ color?: SegmentedControlColor;
52
+ /** Size of every segment, through Bulma's `are-<size>` on the row. */
53
+ size?: 'small' | 'medium' | 'large';
54
+ /**
55
+ * Joins the segments into one row with no gap between them, Bulma's
56
+ * `has-addons`. Set it to `false` for separate buttons.
57
+ */
58
+ hasAddons?: boolean;
59
+ /** Centers the row. */
60
+ isCentered?: boolean;
61
+ /** Aligns the row to the right. */
62
+ isRight?: boolean;
63
+ /** Additional CSS classes to apply. */
64
+ className?: string;
65
+ /** The `SegmentedControl.Segment`s, each with a `value` of its own. */
66
+ children?: React.ReactNode;
67
+ }
68
+ /**
69
+ * Props for SegmentedControl.Segment. The helper props, the other button
70
+ * attributes and the `ref` all land on the `<button>`.
71
+ *
72
+ * Some of `Button`'s props are left out on purpose. `as`, `type`, `role` and
73
+ * `tabIndex`, since a segment is always a `<button type="button" role="radio">`
74
+ * and the group decides which segment Tab reaches. `color`, which the group
75
+ * sets for the checked segment, and the props that change the fill
76
+ * (`isActive`, `isLight`, `isOutlined`, `isInverted`, `textColor`, `bgColor`
77
+ * and their shades), since each would color it whether checked or not. `size`
78
+ * and the width and shape props, which the row sets for every segment. And
79
+ * `isStatic` and `isLoading`, a segment you couldn't pick.
80
+ *
81
+ * @extraProp {React.Ref<HTMLButtonElement>} [ref] - Ref forwarded to the `<button>`.
82
+ */
83
+ export interface SegmentedControlSegmentProps extends Omit<ButtonOwnProps, 'color' | 'size' | 'isActive' | 'isStatic' | 'isLoading' | 'isLight' | 'isOutlined' | 'isInverted' | 'isRounded' | 'isFullwidth' | 'isFullWidth' | 'textColor' | 'bgColor' | 'colorShade' | 'backgroundColorShade'>, Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonOwnProps | 'type' | 'value' | 'role' | 'tabIndex' | 'aria-checked' | 'aria-pressed'> {
84
+ /**
85
+ * **Required.** What `onChange` reports when this segment is checked, and
86
+ * what the group's `value` and `defaultValue` name it by. Unique within the
87
+ * group.
88
+ */
89
+ value: string;
90
+ /**
91
+ * The label. An icon on its own needs an `aria-label`, so a screen reader
92
+ * has something to say.
93
+ */
94
+ children?: React.ReactNode;
95
+ /**
96
+ * Disables the segment, the same as `disabled`: it can't be clicked, the
97
+ * arrow keys, Home and End skip it, and it never holds the row's tab stop.
98
+ * A checked one keeps its fill under Bulma's disabled look.
99
+ */
100
+ isDisabled?: boolean;
101
+ /**
102
+ * Not accepted: `aria-checked` follows the group's value. Declared because
103
+ * JSX lets a hyphenated attribute through when the props don't name it.
104
+ * @internal
105
+ */
106
+ 'aria-checked'?: never;
107
+ /**
108
+ * Not accepted: a segment is a radio, which says checked, not pressed.
109
+ * @internal
110
+ */
111
+ 'aria-pressed'?: never;
112
+ }
113
+ export declare const SegmentedControl: React.ForwardRefExoticComponent<SegmentedControlProps & React.RefAttributes<HTMLDivElement>> & {
114
+ Segment: React.ForwardRefExoticComponent<SegmentedControlSegmentProps & React.RefAttributes<HTMLButtonElement>>;
115
+ };
116
+ export default SegmentedControl;
@@ -78,7 +78,8 @@ export interface ToggleButtonProps extends Omit<ButtonOwnProps, 'color' | 'isAct
78
78
  * carries no form value: a setting saved with a form is a `Checkbox` or a
79
79
  * `Switch`. A set of toggles that each turn on and off on their own goes in
80
80
  * `Buttons hasAddons` with `role="group"` and an `aria-label`. A set where only
81
- * one can be on is a radio group rather than a row of these: use `Radios`.
81
+ * one can be on is a radio group rather than a row of these: use
82
+ * `SegmentedControl`, or `Radios` for a choice that's sent with a form.
82
83
  *
83
84
  * @function
84
85
  * @param {ToggleButtonProps} props - Props for the ToggleButton component.
@@ -13,6 +13,7 @@ export * from './components/Navbar.js';
13
13
  export * from './components/Pagination.js';
14
14
  export * from './components/Panel.js';
15
15
  export * from './components/Tabs.js';
16
+ export * from './components/SegmentedControl.js';
16
17
  export * from './components/Loading.js';
17
18
  export * from './components/Collapse.js';
18
19
  export * from './components/Collapses.js';
@@ -0,0 +1,116 @@
1
+ import React from 'react';
2
+ import { type ButtonOwnProps } from '../elements/Button.js';
3
+ import { BulmaClassesProps } from '../helpers/useBulmaClasses.js';
4
+ /**
5
+ * The fills the checked segment takes: `Button`'s colors, minus `text` and
6
+ * `ghost`, which don't fill, and `white`, `light`, `dark` and `black`, which in
7
+ * one theme or the other fill about as light or dark as an unchecked segment
8
+ * already is. The same set `ToggleButton` takes.
9
+ */
10
+ export type SegmentedControlColor = 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';
11
+ /**
12
+ * Props for the SegmentedControl component. The helper props, the other `<div>`
13
+ * attributes and the `ref` all land on the row.
14
+ *
15
+ * @extraProp {string} [aria-label] - Names the group for a screen reader, such as "Text alignment". A radio group needs a name, so pass this or `aria-labelledby`, and a development build warns when it has neither.
16
+ * @extraProp {string} [aria-labelledby] - The id of a visible heading or label that names the group, in place of `aria-label`.
17
+ * @extraProp {React.Ref<HTMLDivElement>} [ref] - Ref forwarded to the row's `<div>`.
18
+ */
19
+ export interface SegmentedControlProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue' | 'color' | 'role'>, Omit<BulmaClassesProps, 'color' | 'colorShade' | 'backgroundColor' | 'backgroundColorShade'> {
20
+ /**
21
+ * The checked segment's `value`, when you hold the state. Setting it makes
22
+ * the group controlled: picking a segment only calls `onChange`, and nothing
23
+ * changes until you pass the new value. `null` checks nothing, with the
24
+ * tab stop `defaultValue` describes for that. Pick this or `defaultValue`
25
+ * for the group's lifetime.
26
+ */
27
+ value?: string | null;
28
+ /**
29
+ * The segment checked to begin with, when the group holds its own state.
30
+ * Leave it out and nothing is checked until someone picks one, and Tab
31
+ * lands on the first enabled segment meanwhile. That fallback takes hold
32
+ * once the row has rendered in the browser: server markup with nothing
33
+ * checked has no tab stop until then, while a checked segment is the stop
34
+ * from the server markup on.
35
+ */
36
+ defaultValue?: string;
37
+ /**
38
+ * Called with the newly checked segment's `value`, whether or not `value`
39
+ * is set. The arrow keys, Home and End check the segment they move to, so
40
+ * each of those calls it too: the check follows focus, as in a native radio
41
+ * group. Pressing the checked segment again doesn't call it, since a
42
+ * segmented control can't be cleared: one stays checked once one is.
43
+ */
44
+ onChange?: (value: string) => void;
45
+ /**
46
+ * The checked segment's fill. The others are plain buttons, so the fill is
47
+ * the difference people see. Takes the same colors as `ToggleButton`, for
48
+ * the same reason: `white`, `light`, `dark` and `black` fill about as light
49
+ * or dark as a plain button already is in one theme or the other.
50
+ */
51
+ color?: SegmentedControlColor;
52
+ /** Size of every segment, through Bulma's `are-<size>` on the row. */
53
+ size?: 'small' | 'medium' | 'large';
54
+ /**
55
+ * Joins the segments into one row with no gap between them, Bulma's
56
+ * `has-addons`. Set it to `false` for separate buttons.
57
+ */
58
+ hasAddons?: boolean;
59
+ /** Centers the row. */
60
+ isCentered?: boolean;
61
+ /** Aligns the row to the right. */
62
+ isRight?: boolean;
63
+ /** Additional CSS classes to apply. */
64
+ className?: string;
65
+ /** The `SegmentedControl.Segment`s, each with a `value` of its own. */
66
+ children?: React.ReactNode;
67
+ }
68
+ /**
69
+ * Props for SegmentedControl.Segment. The helper props, the other button
70
+ * attributes and the `ref` all land on the `<button>`.
71
+ *
72
+ * Some of `Button`'s props are left out on purpose. `as`, `type`, `role` and
73
+ * `tabIndex`, since a segment is always a `<button type="button" role="radio">`
74
+ * and the group decides which segment Tab reaches. `color`, which the group
75
+ * sets for the checked segment, and the props that change the fill
76
+ * (`isActive`, `isLight`, `isOutlined`, `isInverted`, `textColor`, `bgColor`
77
+ * and their shades), since each would color it whether checked or not. `size`
78
+ * and the width and shape props, which the row sets for every segment. And
79
+ * `isStatic` and `isLoading`, a segment you couldn't pick.
80
+ *
81
+ * @extraProp {React.Ref<HTMLButtonElement>} [ref] - Ref forwarded to the `<button>`.
82
+ */
83
+ export interface SegmentedControlSegmentProps extends Omit<ButtonOwnProps, 'color' | 'size' | 'isActive' | 'isStatic' | 'isLoading' | 'isLight' | 'isOutlined' | 'isInverted' | 'isRounded' | 'isFullwidth' | 'isFullWidth' | 'textColor' | 'bgColor' | 'colorShade' | 'backgroundColorShade'>, Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonOwnProps | 'type' | 'value' | 'role' | 'tabIndex' | 'aria-checked' | 'aria-pressed'> {
84
+ /**
85
+ * **Required.** What `onChange` reports when this segment is checked, and
86
+ * what the group's `value` and `defaultValue` name it by. Unique within the
87
+ * group.
88
+ */
89
+ value: string;
90
+ /**
91
+ * The label. An icon on its own needs an `aria-label`, so a screen reader
92
+ * has something to say.
93
+ */
94
+ children?: React.ReactNode;
95
+ /**
96
+ * Disables the segment, the same as `disabled`: it can't be clicked, the
97
+ * arrow keys, Home and End skip it, and it never holds the row's tab stop.
98
+ * A checked one keeps its fill under Bulma's disabled look.
99
+ */
100
+ isDisabled?: boolean;
101
+ /**
102
+ * Not accepted: `aria-checked` follows the group's value. Declared because
103
+ * JSX lets a hyphenated attribute through when the props don't name it.
104
+ * @internal
105
+ */
106
+ 'aria-checked'?: never;
107
+ /**
108
+ * Not accepted: a segment is a radio, which says checked, not pressed.
109
+ * @internal
110
+ */
111
+ 'aria-pressed'?: never;
112
+ }
113
+ export declare const SegmentedControl: React.ForwardRefExoticComponent<SegmentedControlProps & React.RefAttributes<HTMLDivElement>> & {
114
+ Segment: React.ForwardRefExoticComponent<SegmentedControlSegmentProps & React.RefAttributes<HTMLButtonElement>>;
115
+ };
116
+ export default SegmentedControl;
@@ -78,7 +78,8 @@ export interface ToggleButtonProps extends Omit<ButtonOwnProps, 'color' | 'isAct
78
78
  * carries no form value: a setting saved with a form is a `Checkbox` or a
79
79
  * `Switch`. A set of toggles that each turn on and off on their own goes in
80
80
  * `Buttons hasAddons` with `role="group"` and an `aria-label`. A set where only
81
- * one can be on is a radio group rather than a row of these: use `Radios`.
81
+ * one can be on is a radio group rather than a row of these: use
82
+ * `SegmentedControl`, or `Radios` for a choice that's sent with a form.
82
83
  *
83
84
  * @function
84
85
  * @param {ToggleButtonProps} props - Props for the ToggleButton component.
@@ -13,6 +13,7 @@ export * from './components/Navbar.js';
13
13
  export * from './components/Pagination.js';
14
14
  export * from './components/Panel.js';
15
15
  export * from './components/Tabs.js';
16
+ export * from './components/SegmentedControl.js';
16
17
  export * from './components/Loading.js';
17
18
  export * from './components/Collapse.js';
18
19
  export * from './components/Collapses.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allxsmith/bestax-bulma",
3
- "version": "5.31.0",
3
+ "version": "5.32.0",
4
4
  "description": "A fully-typed React component library for the Bulma CSS framework. Build modern UIs quickly with reusable, accessible, and customizable Bulma-based React components.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.esm.js",