@capra/core 1.12.0 → 1.14.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.
@@ -0,0 +1,113 @@
1
+ # Core/ToggleButtonGroup - Usage
2
+
3
+ A group of toggle buttons for choosing one or more options from a set.
4
+
5
+ ## Basic usage
6
+
7
+ ```tsx
8
+ import { useState } from 'react';
9
+ import { ToggleButtonGroup, type Key } from '@capra/core';
10
+
11
+ function Example() {
12
+ const [selectedKeys, setSelectedKeys] = useState<Set<Key>>(new Set(['day']));
13
+ return (
14
+ <ToggleButtonGroup
15
+ aria-label="Time period"
16
+ selectedKeys={selectedKeys}
17
+ onSelectionChange={setSelectedKeys}
18
+ items={[
19
+ { key: 'day', text: 'Day' },
20
+ { key: 'week', text: 'Week' },
21
+ { key: 'month', text: 'Month' },
22
+ ]}
23
+ />
24
+ )
25
+ }
26
+ ```
27
+
28
+ ## Props
29
+
30
+ | Prop | Type | Required | Default | Description |
31
+ | --- | --- | --- | --- | --- |
32
+ | `items` | `ToggleButtonGroupItem[]` | Yes | `--` | Items to render as toggle buttons. |
33
+ | `size` | `Extract<ButtonSize, 'sm' \| 'md'>` | No | 'md' | Size forwarded to every rendered button. Defaults to `md`. |
34
+ | `disabled` | `boolean` | No | false | Whether the entire group is disabled. |
35
+ | `selectionMode` | `'single' \| 'multiple'` | No | 'single' | Whether single or multiple selection is enabled. Defaults to `single`. |
36
+ | `selectedKeys` | `Iterable<Key>` | No | `--` | Controlled selected keys. |
37
+ | `defaultSelectedKeys` | `Iterable<Key>` | No | `--` | Uncontrolled initial selected keys. |
38
+ | `onSelectionChange` | `(keys: Set<Key>) => void` | No | `--` | Handler called when the selection changes. |
39
+ | `disallowEmptySelection` | `boolean` | No | `--` | Whether the group must always have at least one selected item. |
40
+ | `className` | `never` | No | `--` | Use `FORCE__className` instead. |
41
+ | `style` | `never` | No | `--` | Inline styles are not supported; use component props or `FORCE__className`. |
42
+ | `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
43
+
44
+ ## Examples
45
+
46
+ ### Icons
47
+
48
+ Buttons can display icons in addition to text, or replace text entirely.
49
+
50
+ ```tsx
51
+ <ToggleButtonGroup
52
+ aria-label="Time period"
53
+ items={[
54
+ { key: 'align-left', text: 'Align left', icon: AlignLeft },
55
+ { key: 'align-center', text: 'Align center', icon: AlignCenter },
56
+ { key: 'align-right', text: 'Align right', icon: AlignRight },
57
+ ]}
58
+ ```
59
+
60
+ When using icons only, `aria-label` is required.
61
+
62
+ ```tsx
63
+ <ToggleButtonGroup
64
+ aria-label="Time period"
65
+ items={[
66
+ { key: 'align-left', icon: AlignLeft, 'aria-label': 'Align left' },
67
+ { key: 'align-center', icon: AlignCenter, 'aria-label': 'Align center' },
68
+ { key: 'align-right', icon: AlignRight, 'aria-label': 'Align right' },
69
+ ]}
70
+ ```
71
+
72
+ ### Multi-select
73
+
74
+ ```tsx
75
+ <ToggleButtonGroup
76
+ aria-label="Time period"
77
+ selectionMode="multiple"
78
+ items={[
79
+ { key: 'day', text: 'Day' },
80
+ { key: 'week', text: 'Week' },
81
+ { key: 'month', text: 'Month' },
82
+ ]}
83
+ />
84
+ ```
85
+
86
+ ### Disabled state
87
+
88
+ The entire `ToggleButtonGroup` can be disabled by setting the `disabled` prop.
89
+
90
+ ```tsx
91
+ <ToggleButtonGroup
92
+ aria-label="Time period"
93
+ disabled
94
+ items={[
95
+ { key: 'day', text: 'Day' },
96
+ { key: 'week', text: 'Week' },
97
+ { key: 'month', text: 'Month' },
98
+ ]}
99
+ />
100
+ ```
101
+
102
+ Alternatively, individual buttons can be disabled by setting the `disabled` prop on the individual item.
103
+
104
+ ```tsx
105
+ <ToggleButtonGroup
106
+ aria-label="Time period"
107
+ items={[
108
+ { key: 'day', text: 'Day', disabled: true },
109
+ { key: 'week', text: 'Week' },
110
+ { key: 'month', text: 'Month' },
111
+ ]}
112
+ />
113
+ ```
@@ -1,5 +1,36 @@
1
1
  # History/Changelogs/@capra-core
2
2
 
3
+ ### 1.14.0
4
+
5
+ #### Minor Changes
6
+
7
+ * [7539078](https://bitbucket.org/cribl/capra-ui/commits/7539078): Add `Table` component
8
+
9
+ * [43fbcd3](https://bitbucket.org/cribl/capra-ui/commits/43fbcd3): Prevent long Menu.Items from line-wrapping by default.
10
+
11
+ Add a prop `allowItemLineWrap` to override this default.
12
+
13
+ * [62b08fb](https://bitbucket.org/cribl/capra-ui/commits/62b08fb): Add `Badge` `decorative` prop. Named dots use `role="img"` and counters use `role="status"` so `aria-label` / `aria-labelledby` are valid without making the count presentational.
14
+
15
+ * [9d0734d](https://bitbucket.org/cribl/capra-ui/commits/9d0734d): Add the `ToggleButtonGroup` component
16
+
17
+ * [43b0618](https://bitbucket.org/cribl/capra-ui/commits/43b0618): Update TableToolbar to support filter and bulk edit modes
18
+
19
+ #### Patch Changes
20
+
21
+ * [2ac16c5](https://bitbucket.org/cribl/capra-ui/commits/2ac16c5): Updated `SelectField` dropdown options to use the appropriate colors.
22
+ * [6998527](https://bitbucket.org/cribl/capra-ui/commits/6998527): Fix an issue where the `NumberField` stepper was overflowing outside the input container
23
+
24
+ ### 1.13.0
25
+
26
+ #### Minor Changes
27
+
28
+ * [159e15b](https://bitbucket.org/cribl/capra-ui/commits/159e15b): Add a `SelectField` component.
29
+
30
+ #### Patch Changes
31
+
32
+ * [28df32f](https://bitbucket.org/cribl/capra-ui/commits/28df32f): Fix Switch background colors
33
+
3
34
  ### 1.12.0
4
35
 
5
36
  #### Minor Changes
package/docs/index.md CHANGED
@@ -77,6 +77,8 @@ Embedded documentation is available on the filesystem for each of these packages
77
77
  - [Core/RadioTile - Usage](./core-radiotile--usage.md)
78
78
  - [Core/Ribbon - Design](./core-ribbon--design.md)
79
79
  - [Core/Ribbon - Usage](./core-ribbon--usage.md)
80
+ - [Core/SelectField - Design](./core-selectfield--design.md)
81
+ - [Core/SelectField - Usage](./core-selectfield--usage.md)
80
82
  - [Core/Skeleton - Design](./core-skeleton--design.md)
81
83
  - [Core/Skeleton - Usage](./core-skeleton--usage.md)
82
84
  - [Core/SkeletonGroup - Design](./core-skeletongroup--design.md)
@@ -85,6 +87,8 @@ Embedded documentation is available on the filesystem for each of these packages
85
87
  - [Core/Spinner - Usage](./core-spinner--usage.md)
86
88
  - [Core/Switch - Design](./core-switch--design.md)
87
89
  - [Core/Switch - Usage](./core-switch--usage.md)
90
+ - [Core/Table - Design](./core-table--design.md)
91
+ - [Core/Table - Usage](./core-table--usage.md)
88
92
  - [Core/TabNav - Design](./core-tabnav--design.md)
89
93
  - [Core/TabNav - Usage](./core-tabnav--usage.md)
90
94
  - [Core/Tag - Design](./core-tag--design.md)
@@ -99,6 +103,8 @@ Embedded documentation is available on the filesystem for each of these packages
99
103
  - [Core/TextInput - Usage](./core-textinput--usage.md)
100
104
  - [Core/Toast - Design](./core-toast--design.md)
101
105
  - [Core/Toast - Usage](./core-toast--usage.md)
106
+ - [Core/ToggleButtonGroup - Design](./core-togglebuttongroup--design.md)
107
+ - [Core/ToggleButtonGroup - Usage](./core-togglebuttongroup--usage.md)
102
108
  - [Core/Tooltip - Design](./core-tooltip--design.md)
103
109
  - [Core/Tooltip - Usage](./core-tooltip--usage.md)
104
110
  - [Core/TopNav - Design](./core-topnav--design.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capra/core",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "type": "module",
6
6
  "description": "Core React components for the Capra design system",
@@ -43,9 +43,9 @@
43
43
  "antd": "4.24.16",
44
44
  "storybook": "^10.4.6",
45
45
  "tsdown": "^0.22.7",
46
+ "@private/building": "^0.1.1",
46
47
  "@private/linting": "^0.0.1",
47
- "@private/building": "^0.1.0",
48
- "@capra/theme": "^1.4.0",
48
+ "@capra/theme": "^1.6.0",
49
49
  "@private/stories": "^0.0.0",
50
50
  "@private/testing": "^0.0.7"
51
51
  },