@edux-design/buttons 0.2.0 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @edux-design/buttons
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Correct ButtonGroupItem declarations to describe its render-null option marker and seven existing fields. DOM refs and handlers remain on Button or ButtonGroup; JavaScript behaviour is unchanged.
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Add toolbar controls, toggles, groups and separators with native attributes, labelled keyboard navigation and compact semantic control sizing.
14
+
15
+ Correct primary Button, IconButton and ButtonCounter foregrounds in dark mode using the existing inverse foreground token; geometry and danger colours are unchanged.
16
+
17
+ Retain native ButtonGroup props, refs and typed selection callbacks in generated declarations.
18
+
3
19
  ## 0.2.0
4
20
 
5
21
  ### Minor Changes
package/README.md CHANGED
@@ -120,3 +120,7 @@ pnpm --filter @edux-design/buttons build
120
120
  ```
121
121
 
122
122
  Stories live under `src/demo` (for example `Button.stories.jsx` and `ButtonGroup.stories.jsx`) for quick visual verification.
123
+
124
+ ## Additional components
125
+
126
+ [Toolbar controls](./docs/toolbar.md).
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import * as react from 'react';
1
+ import React from 'react';
2
2
 
3
3
  /**
4
4
  * Props for the IconButton component.
@@ -160,7 +160,7 @@ type MenuButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
160
160
  /**
161
161
  * Segmented button group with animated active state.
162
162
  *
163
- * @typedef {React.HTMLAttributes<HTMLDivElement> & {
163
+ * @typedef {Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"|"defaultValue"> & {
164
164
  * value?: string|number,
165
165
  * defaultValue?: string|number,
166
166
  * onChange?: (value: string|number, option: ButtonGroupOption) => void,
@@ -168,12 +168,98 @@ type MenuButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
168
168
  * isStretched?: boolean,
169
169
  * }} ButtonGroupProps
170
170
  */
171
- declare const ButtonGroup: react.ForwardRefExoticComponent<react.RefAttributes<any>>;
171
+ /** @type {React.ForwardRefExoticComponent<ButtonGroupProps & React.RefAttributes<HTMLDivElement>>} */
172
+ declare const ButtonGroup: React.ForwardRefExoticComponent<ButtonGroupProps & React.RefAttributes<HTMLDivElement>>;
173
+ type ButtonGroupOption = {
174
+ /**
175
+ * - Main label for the option.
176
+ */
177
+ label?: React.ReactNode;
178
+ /**
179
+ * - Optional leading element (icon, badge, etc.).
180
+ */
181
+ startAdornment?: React.ReactNode;
182
+ /**
183
+ * - Optional trailing element (legacy alias).
184
+ */
185
+ endIcon?: React.ReactNode;
186
+ /**
187
+ * - Optional trailing element.
188
+ */
189
+ endAdornment?: React.ReactNode;
190
+ /**
191
+ * - Unique value used for selection.
192
+ */
193
+ value?: string | number;
194
+ /**
195
+ * - Whether the option is disabled.
196
+ */
197
+ disabled?: boolean;
198
+ };
199
+ /**
200
+ * Segmented button group with animated active state.
201
+ */
202
+ type ButtonGroupProps = Omit<React.HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> & {
203
+ value?: string | number;
204
+ defaultValue?: string | number;
205
+ onChange?: (value: string | number, option: ButtonGroupOption) => void;
206
+ size?: "small" | "medium" | "large";
207
+ isStretched?: boolean;
208
+ };
172
209
 
173
- declare function ButtonGroupItem(_props: any): any;
210
+ /**
211
+ * Option marker consumed by ButtonGroup; it does not render a DOM element.
212
+ *
213
+ * @typedef {Object} ButtonGroupItemProps
214
+ * @property {React.ReactNode} [children] - Label used when label is omitted.
215
+ * @property {React.ReactNode} [label] - Main label for the option.
216
+ * @property {React.ReactNode} [startAdornment] - Optional leading element.
217
+ * @property {React.ReactNode} [endAdornment] - Optional trailing element.
218
+ * @property {React.ReactNode} [endIcon] - Legacy trailing-element alias.
219
+ * @property {string|number} [value] - Selection value; defaults to the option index.
220
+ * @property {boolean} [disabled] - Whether the option is disabled.
221
+ */
222
+ /**
223
+ * @param {ButtonGroupItemProps} _props
224
+ * @returns {null}
225
+ */
226
+ declare function ButtonGroupItem(_props: ButtonGroupItemProps): null;
174
227
  declare namespace ButtonGroupItem {
175
228
  let displayName: string;
176
229
  }
230
+ /**
231
+ * Option marker consumed by ButtonGroup; it does not render a DOM element.
232
+ */
233
+ type ButtonGroupItemProps = {
234
+ /**
235
+ * - Label used when label is omitted.
236
+ */
237
+ children?: React.ReactNode;
238
+ /**
239
+ * - Main label for the option.
240
+ */
241
+ label?: React.ReactNode;
242
+ /**
243
+ * - Optional leading element.
244
+ */
245
+ startAdornment?: React.ReactNode;
246
+ /**
247
+ * - Optional trailing element.
248
+ */
249
+ endAdornment?: React.ReactNode;
250
+ /**
251
+ * - Legacy trailing-element alias.
252
+ */
253
+ endIcon?: React.ReactNode;
254
+ /**
255
+ * - Selection value; defaults to the option index.
256
+ */
257
+ value?: string | number;
258
+ /**
259
+ * - Whether the option is disabled.
260
+ */
261
+ disabled?: boolean;
262
+ };
177
263
 
178
264
  /**
179
265
  * ButtonCounter (stepper) component.
@@ -241,4 +327,49 @@ type ButtonCounterProps = React.HTMLAttributes<HTMLDivElement> & {
241
327
  className?: string;
242
328
  };
243
329
 
244
- export { Button, ButtonCounter, ButtonGroup, ButtonGroupItem, IconButton, MenuButton };
330
+ interface ToolbarProps extends React.HTMLAttributes<HTMLDivElement> {
331
+ /** Native Tab order is the default. Adopt roving arrow-key focus explicitly. */
332
+ keyboardNavigation?: "native" | "roving";
333
+ /** Arrow-key navigation follows this axis. It never activates an action. */
334
+ orientation?: "horizontal" | "vertical";
335
+ /** Whether arrow navigation wraps at the first and last enabled action. */
336
+ loop?: boolean;
337
+ }
338
+ /**
339
+ * A labelled action toolbar with native Tab order by default.
340
+ * Opt into roving navigation for one tab stop and arrow-key focus.
341
+ * Place ToolbarButton/ToolbarToggleButton children directly or in ToolbarGroup.
342
+ * Nested toolbars maintain independent focus. Editor command handling stays local.
343
+ */
344
+ declare const Toolbar: React.ForwardRefExoticComponent<ToolbarProps & React.RefAttributes<HTMLDivElement>>;
345
+ interface ToolbarGroupProps extends React.HTMLAttributes<HTMLDivElement> {
346
+ orientation?: "horizontal" | "vertical";
347
+ }
348
+ /** A labelled, non-selecting action group. Selection state belongs to its buttons. */
349
+ declare const ToolbarGroup: React.ForwardRefExoticComponent<ToolbarGroupProps & React.RefAttributes<HTMLDivElement>>;
350
+ interface ToolbarSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
351
+ /** The separator line's orientation, perpendicular to a horizontal toolbar by default. */
352
+ orientation?: "horizontal" | "vertical";
353
+ }
354
+ declare const ToolbarSeparator: React.ForwardRefExoticComponent<ToolbarSeparatorProps & React.RefAttributes<HTMLDivElement>>;
355
+
356
+ interface ToolbarButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
357
+ /** Compatibility visual state. Defaults aria-pressed to true; explicit native ARIA wins. */
358
+ active?: boolean;
359
+ size?: "small" | "medium" | "large";
360
+ variant?: "neutral" | "primary" | "danger";
361
+ icon?: React.ReactNode;
362
+ /** Square geometry. Provide aria-label or aria-labelledby when there is no visible text. */
363
+ iconOnly?: boolean;
364
+ }
365
+ /** Compact native action button; compose a Tooltip around it when an explanation is needed. */
366
+ declare const ToolbarButton: React.ForwardRefExoticComponent<ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>>;
367
+ interface ToolbarToggleButtonProps extends Omit<ToolbarButtonProps, "aria-pressed" | "active"> {
368
+ pressed?: boolean;
369
+ defaultPressed?: boolean;
370
+ onPressedChange?: (pressed: boolean, event: React.MouseEvent<HTMLButtonElement>) => void;
371
+ }
372
+ /** A controlled or uncontrolled independent toggle, with native button keyboard activation. */
373
+ declare const ToolbarToggleButton: React.ForwardRefExoticComponent<ToolbarToggleButtonProps & React.RefAttributes<HTMLButtonElement>>;
374
+
375
+ export { Button, ButtonCounter, ButtonGroup, ButtonGroupItem, IconButton, MenuButton, Toolbar, ToolbarButton, type ToolbarButtonProps, ToolbarGroup, type ToolbarGroupProps, type ToolbarProps, ToolbarSeparator, type ToolbarSeparatorProps, ToolbarToggleButton, type ToolbarToggleButtonProps };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as react from 'react';
1
+ import React from 'react';
2
2
 
3
3
  /**
4
4
  * Props for the IconButton component.
@@ -160,7 +160,7 @@ type MenuButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
160
160
  /**
161
161
  * Segmented button group with animated active state.
162
162
  *
163
- * @typedef {React.HTMLAttributes<HTMLDivElement> & {
163
+ * @typedef {Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"|"defaultValue"> & {
164
164
  * value?: string|number,
165
165
  * defaultValue?: string|number,
166
166
  * onChange?: (value: string|number, option: ButtonGroupOption) => void,
@@ -168,12 +168,98 @@ type MenuButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
168
168
  * isStretched?: boolean,
169
169
  * }} ButtonGroupProps
170
170
  */
171
- declare const ButtonGroup: react.ForwardRefExoticComponent<react.RefAttributes<any>>;
171
+ /** @type {React.ForwardRefExoticComponent<ButtonGroupProps & React.RefAttributes<HTMLDivElement>>} */
172
+ declare const ButtonGroup: React.ForwardRefExoticComponent<ButtonGroupProps & React.RefAttributes<HTMLDivElement>>;
173
+ type ButtonGroupOption = {
174
+ /**
175
+ * - Main label for the option.
176
+ */
177
+ label?: React.ReactNode;
178
+ /**
179
+ * - Optional leading element (icon, badge, etc.).
180
+ */
181
+ startAdornment?: React.ReactNode;
182
+ /**
183
+ * - Optional trailing element (legacy alias).
184
+ */
185
+ endIcon?: React.ReactNode;
186
+ /**
187
+ * - Optional trailing element.
188
+ */
189
+ endAdornment?: React.ReactNode;
190
+ /**
191
+ * - Unique value used for selection.
192
+ */
193
+ value?: string | number;
194
+ /**
195
+ * - Whether the option is disabled.
196
+ */
197
+ disabled?: boolean;
198
+ };
199
+ /**
200
+ * Segmented button group with animated active state.
201
+ */
202
+ type ButtonGroupProps = Omit<React.HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> & {
203
+ value?: string | number;
204
+ defaultValue?: string | number;
205
+ onChange?: (value: string | number, option: ButtonGroupOption) => void;
206
+ size?: "small" | "medium" | "large";
207
+ isStretched?: boolean;
208
+ };
172
209
 
173
- declare function ButtonGroupItem(_props: any): any;
210
+ /**
211
+ * Option marker consumed by ButtonGroup; it does not render a DOM element.
212
+ *
213
+ * @typedef {Object} ButtonGroupItemProps
214
+ * @property {React.ReactNode} [children] - Label used when label is omitted.
215
+ * @property {React.ReactNode} [label] - Main label for the option.
216
+ * @property {React.ReactNode} [startAdornment] - Optional leading element.
217
+ * @property {React.ReactNode} [endAdornment] - Optional trailing element.
218
+ * @property {React.ReactNode} [endIcon] - Legacy trailing-element alias.
219
+ * @property {string|number} [value] - Selection value; defaults to the option index.
220
+ * @property {boolean} [disabled] - Whether the option is disabled.
221
+ */
222
+ /**
223
+ * @param {ButtonGroupItemProps} _props
224
+ * @returns {null}
225
+ */
226
+ declare function ButtonGroupItem(_props: ButtonGroupItemProps): null;
174
227
  declare namespace ButtonGroupItem {
175
228
  let displayName: string;
176
229
  }
230
+ /**
231
+ * Option marker consumed by ButtonGroup; it does not render a DOM element.
232
+ */
233
+ type ButtonGroupItemProps = {
234
+ /**
235
+ * - Label used when label is omitted.
236
+ */
237
+ children?: React.ReactNode;
238
+ /**
239
+ * - Main label for the option.
240
+ */
241
+ label?: React.ReactNode;
242
+ /**
243
+ * - Optional leading element.
244
+ */
245
+ startAdornment?: React.ReactNode;
246
+ /**
247
+ * - Optional trailing element.
248
+ */
249
+ endAdornment?: React.ReactNode;
250
+ /**
251
+ * - Legacy trailing-element alias.
252
+ */
253
+ endIcon?: React.ReactNode;
254
+ /**
255
+ * - Selection value; defaults to the option index.
256
+ */
257
+ value?: string | number;
258
+ /**
259
+ * - Whether the option is disabled.
260
+ */
261
+ disabled?: boolean;
262
+ };
177
263
 
178
264
  /**
179
265
  * ButtonCounter (stepper) component.
@@ -241,4 +327,49 @@ type ButtonCounterProps = React.HTMLAttributes<HTMLDivElement> & {
241
327
  className?: string;
242
328
  };
243
329
 
244
- export { Button, ButtonCounter, ButtonGroup, ButtonGroupItem, IconButton, MenuButton };
330
+ interface ToolbarProps extends React.HTMLAttributes<HTMLDivElement> {
331
+ /** Native Tab order is the default. Adopt roving arrow-key focus explicitly. */
332
+ keyboardNavigation?: "native" | "roving";
333
+ /** Arrow-key navigation follows this axis. It never activates an action. */
334
+ orientation?: "horizontal" | "vertical";
335
+ /** Whether arrow navigation wraps at the first and last enabled action. */
336
+ loop?: boolean;
337
+ }
338
+ /**
339
+ * A labelled action toolbar with native Tab order by default.
340
+ * Opt into roving navigation for one tab stop and arrow-key focus.
341
+ * Place ToolbarButton/ToolbarToggleButton children directly or in ToolbarGroup.
342
+ * Nested toolbars maintain independent focus. Editor command handling stays local.
343
+ */
344
+ declare const Toolbar: React.ForwardRefExoticComponent<ToolbarProps & React.RefAttributes<HTMLDivElement>>;
345
+ interface ToolbarGroupProps extends React.HTMLAttributes<HTMLDivElement> {
346
+ orientation?: "horizontal" | "vertical";
347
+ }
348
+ /** A labelled, non-selecting action group. Selection state belongs to its buttons. */
349
+ declare const ToolbarGroup: React.ForwardRefExoticComponent<ToolbarGroupProps & React.RefAttributes<HTMLDivElement>>;
350
+ interface ToolbarSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
351
+ /** The separator line's orientation, perpendicular to a horizontal toolbar by default. */
352
+ orientation?: "horizontal" | "vertical";
353
+ }
354
+ declare const ToolbarSeparator: React.ForwardRefExoticComponent<ToolbarSeparatorProps & React.RefAttributes<HTMLDivElement>>;
355
+
356
+ interface ToolbarButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
357
+ /** Compatibility visual state. Defaults aria-pressed to true; explicit native ARIA wins. */
358
+ active?: boolean;
359
+ size?: "small" | "medium" | "large";
360
+ variant?: "neutral" | "primary" | "danger";
361
+ icon?: React.ReactNode;
362
+ /** Square geometry. Provide aria-label or aria-labelledby when there is no visible text. */
363
+ iconOnly?: boolean;
364
+ }
365
+ /** Compact native action button; compose a Tooltip around it when an explanation is needed. */
366
+ declare const ToolbarButton: React.ForwardRefExoticComponent<ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>>;
367
+ interface ToolbarToggleButtonProps extends Omit<ToolbarButtonProps, "aria-pressed" | "active"> {
368
+ pressed?: boolean;
369
+ defaultPressed?: boolean;
370
+ onPressedChange?: (pressed: boolean, event: React.MouseEvent<HTMLButtonElement>) => void;
371
+ }
372
+ /** A controlled or uncontrolled independent toggle, with native button keyboard activation. */
373
+ declare const ToolbarToggleButton: React.ForwardRefExoticComponent<ToolbarToggleButtonProps & React.RefAttributes<HTMLButtonElement>>;
374
+
375
+ export { Button, ButtonCounter, ButtonGroup, ButtonGroupItem, IconButton, MenuButton, Toolbar, ToolbarButton, type ToolbarButtonProps, ToolbarGroup, type ToolbarGroupProps, type ToolbarProps, ToolbarSeparator, type ToolbarSeparatorProps, ToolbarToggleButton, type ToolbarToggleButtonProps };