@edux-design/buttons 0.0.2 → 0.0.4

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,20 @@
1
1
  # @edux-design/buttons
2
2
 
3
+ ## 0.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - b9d0d32: Added documentation
8
+ - Updated dependencies [b9d0d32]
9
+ - Updated dependencies
10
+ - @edux-design/utils@0.0.3
11
+
12
+ ## 0.0.3
13
+
14
+ ### Patch Changes
15
+
16
+ - Popovers
17
+
3
18
  ## 0.0.2
4
19
 
5
20
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # @edux-design/buttons
2
+
3
+ Headless-ish button primitives wired to the Edux design tokens. The package ships four components:
4
+
5
+ - `Button` – primary action button with size + variant helpers.
6
+ - `IconButton` – circular/square icon surface that reuses the same states.
7
+ - `MenuButton` – trigger wrapper that pairs nicely with popovers/menus.
8
+ - `ButtonGroup` – segmented control with a sliding active state meant for contextual filters.
9
+
10
+ Everything is built with Tailwind utilities via the shared `cx` helper so styling stays consistent with the rest of the system.
11
+
12
+ ---
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add @edux-design/buttons @edux-design/utils
18
+ # or
19
+ npm install @edux-design/buttons @edux-design/utils
20
+ ```
21
+
22
+ Peer deps: `react@^19.1.0`, `react-dom@^19.1.0`.
23
+
24
+ ---
25
+
26
+ ## Usage
27
+
28
+ ```jsx
29
+ import { Button, IconButton, MenuButton } from "@edux-design/buttons";
30
+ import { Close, Chevron } from "@edux-design/icons";
31
+
32
+ export function Actions() {
33
+ return (
34
+ <div className="flex gap-4">
35
+ <Button size="small">Save</Button>
36
+ <Button isSecondary isStretched>
37
+ Cancel
38
+ </Button>
39
+ <Button isDanger disabled>
40
+ Delete
41
+ </Button>
42
+ <IconButton icon={<Close />} aria-label="Close dialog" />
43
+ <MenuButton caret={<Chevron />} onClick={() => null}>
44
+ Options
45
+ </MenuButton>
46
+ </div>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ### ButtonGroup
52
+
53
+ ```jsx
54
+ import React from "react";
55
+ import { ButtonGroup } from "@edux-design/buttons";
56
+ import { Warning } from "@edux-design/icons";
57
+
58
+ export function SegmentedFilter() {
59
+ const [value, setValue] = React.useState("inbox");
60
+
61
+ return (
62
+ <ButtonGroup
63
+ value={value}
64
+ onChange={(nextValue) => setValue(nextValue)}
65
+ options={[
66
+ { value: "inbox", label: "Label (11)" },
67
+ { value: "drafts", label: "Label (11)" },
68
+ {
69
+ value: "alerts",
70
+ label: "Label",
71
+ endAdornment: <Warning className="h-4 w-4 text-warning-600" />,
72
+ },
73
+ ]}
74
+ />
75
+ );
76
+ }
77
+ ```
78
+
79
+ Provide `options` as strings or objects (`{ value, label, startAdornment, endAdornment, disabled }`). The active pill animates over the newly selected option and the group behaves like an accessible radiogroup (arrow keys + home/end). Use `isStretched` when the control should fill the parent width.
80
+
81
+ ### Key props
82
+
83
+ | Component | Important props |
84
+ | ------------- | --------------- |
85
+ | `Button` | `size="small"|"medium"|"large"`, `isSecondary`, `isDanger`, `isBare`, `isStretched`, `disabled` |
86
+ | `IconButton` | `icon`, `size`, `isBare`, `isDanger`, `disabled` |
87
+ | `MenuButton` | Accepts all `Button` props plus caret slot and ARIA attributes for menu triggers |
88
+ | `ButtonGroup` | `options`, `value` / `defaultValue`, `onChange`, `size`, `isStretched`, per-option `startAdornment` / `endAdornment`, `disabled` |
89
+
90
+ Buttons warn in development if you pass conflicting variant booleans so you know which style wins.
91
+
92
+ ---
93
+
94
+ ## Development
95
+
96
+ ```bash
97
+ pnpm --filter @edux-design/buttons lint
98
+ pnpm --filter @edux-design/buttons check-types
99
+ pnpm --filter @edux-design/buttons build
100
+ ```
101
+
102
+ Stories live under `src/demo` (e.g. `Button.stories.jsx`, `ButtonGroup.stories.jsx`) for quick visual verification.
103
+
104
+ ---
105
+
106
+ ## Notes
107
+
108
+ - Variants map directly to the design tokens defined in `@edux-design/tokens`.
109
+ - Hover/focus styles are already applied; avoid overriding unless you have a matching token.
110
+ - If you need new variants (ghost, link, destructive-secondary, etc.), add them in `Button.jsx` and update the stories + README accordingly.
@@ -0,0 +1,159 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+
4
+ /**
5
+ * Props for the IconButton component.
6
+ *
7
+ * Extends all native HTML `<button>` attributes and accepts an icon prop.
8
+ * Designed for circular icon-only buttons that follow the same
9
+ * design-system patterns as the regular Button.
10
+ *
11
+ * @typedef {React.ButtonHTMLAttributes<HTMLButtonElement> & {
12
+ * icon: React.ReactNode,
13
+ * size?: "small"|"medium"|"large",
14
+ * isSecondary?: boolean,
15
+ * isDanger?: boolean,
16
+ * isBare?: boolean,
17
+ * disabled?: boolean,
18
+ * className?: string
19
+ * }} IconButtonProps
20
+ */
21
+ /**
22
+ * IconButton component.
23
+ *
24
+ * Provides a circular button used for icon-only actions, matching
25
+ * the design-system variants and states of the main Button component.
26
+ *
27
+ * @component
28
+ * @type {React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>}
29
+ *
30
+ * @example
31
+ * ```jsx
32
+ * <IconButton icon={<XIcon />} aria-label="Close" />
33
+ * <IconButton icon={<EditIcon />} isSecondary />
34
+ * <IconButton icon={<TrashIcon />} isDanger disabled />
35
+ * ```
36
+ */
37
+ declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
38
+ /**
39
+ * Props for the IconButton component.
40
+ *
41
+ * Extends all native HTML `<button>` attributes and accepts an icon prop.
42
+ * Designed for circular icon-only buttons that follow the same
43
+ * design-system patterns as the regular Button.
44
+ */
45
+ type IconButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
46
+ icon: React.ReactNode;
47
+ size?: "small" | "medium" | "large";
48
+ isSecondary?: boolean;
49
+ isDanger?: boolean;
50
+ isBare?: boolean;
51
+ disabled?: boolean;
52
+ className?: string;
53
+ };
54
+
55
+ /**
56
+ * Props for the Button component.
57
+ *
58
+ * Extends all native HTML `<button>` attributes, while adding
59
+ * design-system variants and state controls.
60
+ *
61
+ * @typedef {React.ButtonHTMLAttributes<HTMLButtonElement> & {
62
+ * children?: React.ReactNode,
63
+ * size?: "small"|"medium"|"large",
64
+ * isSecondary?: boolean,
65
+ * isDanger?: boolean,
66
+ * isBare?: boolean,
67
+ * isStretched?: boolean,
68
+ * disabled?: boolean,
69
+ * className?: string
70
+ * }} ButtonProps
71
+ */
72
+ /**
73
+ * Button component.
74
+ *
75
+ * Provides design-system styled button with support for
76
+ * multiple visual variants, sizing, and states.
77
+ *
78
+ * @component
79
+ * @type {React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>}
80
+ *
81
+ * @example
82
+ * ```jsx
83
+ * <Button size="small">Save</Button>
84
+ * <Button isSecondary>Cancel</Button>
85
+ * <Button isDanger disabled>Delete</Button>
86
+ * ```
87
+ */
88
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
89
+ /**
90
+ * Props for the Button component.
91
+ *
92
+ * Extends all native HTML `<button>` attributes, while adding
93
+ * design-system variants and state controls.
94
+ */
95
+ type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
96
+ children?: React.ReactNode;
97
+ size?: "small" | "medium" | "large";
98
+ isSecondary?: boolean;
99
+ isDanger?: boolean;
100
+ isBare?: boolean;
101
+ isStretched?: boolean;
102
+ disabled?: boolean;
103
+ className?: string;
104
+ };
105
+
106
+ /**
107
+ * Props for the MenuButton component.
108
+ *
109
+ * @typedef {Object} MenuButtonProps
110
+ * @property {React.ReactNode} [children] - Content to display inside the button (usually label or icon).
111
+ * @property {"small"|"medium"} [size="medium"] - Size variant controlling button height.
112
+ */
113
+ /**
114
+ * MenuButton component.
115
+ *
116
+ * Provides a styled menu trigger button with optional sizing.
117
+ * It uses a `MenuButtonContext` provider to share internal state
118
+ * with child menu items.
119
+ *
120
+ * @component
121
+ * @type {React.FC<MenuButtonProps>}
122
+ *
123
+ * @example
124
+ * ```jsx
125
+ * <MenuButton size="small">Options</MenuButton>
126
+ * ```
127
+ */
128
+ declare function MenuButton({ children, size }: {
129
+ children: any;
130
+ size: any;
131
+ }): react_jsx_runtime.JSX.Element;
132
+
133
+ /**
134
+ * @typedef {Object} ButtonGroupOption
135
+ * @property {React.ReactNode} [label] - Main label for the option.
136
+ * @property {React.ReactNode} [startAdornment] - Optional leading element (icon, badge, etc.).
137
+ * @property {React.ReactNode} [endIcon] - Optional trailing element.
138
+ * @property {string|number} [value] - Unique value used for selection.
139
+ * @property {boolean} [disabled] - Whether the option is disabled.
140
+ */
141
+ /**
142
+ * Segmented button group with animated active state.
143
+ *
144
+ * @typedef {React.HTMLAttributes<HTMLDivElement> & {
145
+ * value?: string|number,
146
+ * defaultValue?: string|number,
147
+ * onChange?: (value: string|number, option: ButtonGroupOption) => void,
148
+ * size?: "small"|"medium"|"large",
149
+ * isStretched?: boolean,
150
+ * }} ButtonGroupProps
151
+ */
152
+ declare const ButtonGroup: react.ForwardRefExoticComponent<react.RefAttributes<any>>;
153
+
154
+ declare function ButtonGroupItem(_props: any): any;
155
+ declare namespace ButtonGroupItem {
156
+ let displayName: string;
157
+ }
158
+
159
+ export { Button, ButtonGroup, ButtonGroupItem, IconButton, MenuButton };
@@ -0,0 +1,159 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+
4
+ /**
5
+ * Props for the IconButton component.
6
+ *
7
+ * Extends all native HTML `<button>` attributes and accepts an icon prop.
8
+ * Designed for circular icon-only buttons that follow the same
9
+ * design-system patterns as the regular Button.
10
+ *
11
+ * @typedef {React.ButtonHTMLAttributes<HTMLButtonElement> & {
12
+ * icon: React.ReactNode,
13
+ * size?: "small"|"medium"|"large",
14
+ * isSecondary?: boolean,
15
+ * isDanger?: boolean,
16
+ * isBare?: boolean,
17
+ * disabled?: boolean,
18
+ * className?: string
19
+ * }} IconButtonProps
20
+ */
21
+ /**
22
+ * IconButton component.
23
+ *
24
+ * Provides a circular button used for icon-only actions, matching
25
+ * the design-system variants and states of the main Button component.
26
+ *
27
+ * @component
28
+ * @type {React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>}
29
+ *
30
+ * @example
31
+ * ```jsx
32
+ * <IconButton icon={<XIcon />} aria-label="Close" />
33
+ * <IconButton icon={<EditIcon />} isSecondary />
34
+ * <IconButton icon={<TrashIcon />} isDanger disabled />
35
+ * ```
36
+ */
37
+ declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
38
+ /**
39
+ * Props for the IconButton component.
40
+ *
41
+ * Extends all native HTML `<button>` attributes and accepts an icon prop.
42
+ * Designed for circular icon-only buttons that follow the same
43
+ * design-system patterns as the regular Button.
44
+ */
45
+ type IconButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
46
+ icon: React.ReactNode;
47
+ size?: "small" | "medium" | "large";
48
+ isSecondary?: boolean;
49
+ isDanger?: boolean;
50
+ isBare?: boolean;
51
+ disabled?: boolean;
52
+ className?: string;
53
+ };
54
+
55
+ /**
56
+ * Props for the Button component.
57
+ *
58
+ * Extends all native HTML `<button>` attributes, while adding
59
+ * design-system variants and state controls.
60
+ *
61
+ * @typedef {React.ButtonHTMLAttributes<HTMLButtonElement> & {
62
+ * children?: React.ReactNode,
63
+ * size?: "small"|"medium"|"large",
64
+ * isSecondary?: boolean,
65
+ * isDanger?: boolean,
66
+ * isBare?: boolean,
67
+ * isStretched?: boolean,
68
+ * disabled?: boolean,
69
+ * className?: string
70
+ * }} ButtonProps
71
+ */
72
+ /**
73
+ * Button component.
74
+ *
75
+ * Provides design-system styled button with support for
76
+ * multiple visual variants, sizing, and states.
77
+ *
78
+ * @component
79
+ * @type {React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>}
80
+ *
81
+ * @example
82
+ * ```jsx
83
+ * <Button size="small">Save</Button>
84
+ * <Button isSecondary>Cancel</Button>
85
+ * <Button isDanger disabled>Delete</Button>
86
+ * ```
87
+ */
88
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
89
+ /**
90
+ * Props for the Button component.
91
+ *
92
+ * Extends all native HTML `<button>` attributes, while adding
93
+ * design-system variants and state controls.
94
+ */
95
+ type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
96
+ children?: React.ReactNode;
97
+ size?: "small" | "medium" | "large";
98
+ isSecondary?: boolean;
99
+ isDanger?: boolean;
100
+ isBare?: boolean;
101
+ isStretched?: boolean;
102
+ disabled?: boolean;
103
+ className?: string;
104
+ };
105
+
106
+ /**
107
+ * Props for the MenuButton component.
108
+ *
109
+ * @typedef {Object} MenuButtonProps
110
+ * @property {React.ReactNode} [children] - Content to display inside the button (usually label or icon).
111
+ * @property {"small"|"medium"} [size="medium"] - Size variant controlling button height.
112
+ */
113
+ /**
114
+ * MenuButton component.
115
+ *
116
+ * Provides a styled menu trigger button with optional sizing.
117
+ * It uses a `MenuButtonContext` provider to share internal state
118
+ * with child menu items.
119
+ *
120
+ * @component
121
+ * @type {React.FC<MenuButtonProps>}
122
+ *
123
+ * @example
124
+ * ```jsx
125
+ * <MenuButton size="small">Options</MenuButton>
126
+ * ```
127
+ */
128
+ declare function MenuButton({ children, size }: {
129
+ children: any;
130
+ size: any;
131
+ }): react_jsx_runtime.JSX.Element;
132
+
133
+ /**
134
+ * @typedef {Object} ButtonGroupOption
135
+ * @property {React.ReactNode} [label] - Main label for the option.
136
+ * @property {React.ReactNode} [startAdornment] - Optional leading element (icon, badge, etc.).
137
+ * @property {React.ReactNode} [endIcon] - Optional trailing element.
138
+ * @property {string|number} [value] - Unique value used for selection.
139
+ * @property {boolean} [disabled] - Whether the option is disabled.
140
+ */
141
+ /**
142
+ * Segmented button group with animated active state.
143
+ *
144
+ * @typedef {React.HTMLAttributes<HTMLDivElement> & {
145
+ * value?: string|number,
146
+ * defaultValue?: string|number,
147
+ * onChange?: (value: string|number, option: ButtonGroupOption) => void,
148
+ * size?: "small"|"medium"|"large",
149
+ * isStretched?: boolean,
150
+ * }} ButtonGroupProps
151
+ */
152
+ declare const ButtonGroup: react.ForwardRefExoticComponent<react.RefAttributes<any>>;
153
+
154
+ declare function ButtonGroupItem(_props: any): any;
155
+ declare namespace ButtonGroupItem {
156
+ let displayName: string;
157
+ }
158
+
159
+ export { Button, ButtonGroup, ButtonGroupItem, IconButton, MenuButton };