@gridui/button 4.1.0 → 5.0.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/README.md +39 -7
- package/dist/button/button.d.ts +1 -1
- package/dist/button-group/button-group.d.ts +12 -0
- package/dist/button-link/button-link.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +232 -37
- package/dist/index.js.map +4 -4
- package/dist/shared/group-context.d.ts +8 -0
- package/dist/shared/style.d.ts +8 -1
- package/dist/styles.css +56 -4
- package/docs/catalog.json +16 -2
- package/docs/reference/README.md +1 -0
- package/docs/reference/button-group.md +71 -0
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Button
|
|
2
2
|
|
|
3
3
|
`@gridui/button` owns native buttons, button-styled links, shared button classes,
|
|
4
|
-
and async action scheduling. It has no domain,
|
|
4
|
+
ButtonGroup layouts, and async action scheduling. It has no domain,
|
|
5
5
|
route, locale, or Layout dependency. Load `@gridui/button/styles.css` after
|
|
6
6
|
the theme styles.
|
|
7
7
|
|
|
@@ -18,11 +18,17 @@ import "@gridui/button/styles.css";
|
|
|
18
18
|
## Native behavior
|
|
19
19
|
|
|
20
20
|
`Button` forwards native button props and refs. It defaults to `type="button"`;
|
|
21
|
-
use `type="submit"` for a form action. `loading`
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
use `type="submit"` for a form action. `loading` exposes `aria-busy` and
|
|
22
|
+
`aria-disabled`, preserves focus, label geometry, content opacity, and hover paint,
|
|
23
|
+
and blocks pointer, keyboard, and programmatic click activation. A busy submit
|
|
24
|
+
button also cancels form submissions that name it as the submitter. The form's
|
|
25
|
+
action owner must guard other submission paths, such as `requestSubmit()` without
|
|
26
|
+
a submitter, with its own in-flight lock.
|
|
27
|
+
|
|
28
|
+
Native `disabled` means unavailable and takes precedence over loading. Explicit
|
|
29
|
+
`aria-disabled` also blocks button activation while preserving focusability;
|
|
30
|
+
ARIA/data-disabled attributes share the unavailable appearance. Loading does not
|
|
31
|
+
set the native `disabled` property or remove the submitter from form data.
|
|
26
32
|
|
|
27
33
|
`ButtonLink` forwards native anchor props and refs and requires `href`. It
|
|
28
34
|
defaults to the secondary variant and retains navigation, modified-click,
|
|
@@ -72,7 +78,7 @@ retains its normal size. Graphical content remains caller-owned.
|
|
|
72
78
|
|
|
73
79
|
`iconMotion="outward"` opts the `endIcon` into a small hover translation upward
|
|
74
80
|
and toward the inline end. It follows inherited text direction, leaves any
|
|
75
|
-
dividing line fixed, and does not animate
|
|
81
|
+
dividing line fixed, and does not animate unavailable buttons. Loading preserves the existing hover motion. Reduced
|
|
76
82
|
motion removes both the translation and transition. The default is `none`;
|
|
77
83
|
keyboard focus never requires motion to remain visible. Supply an icon whose
|
|
78
84
|
direction matches the action and locale.
|
|
@@ -182,3 +188,29 @@ transitions, RTL seams and motion, long labels at text zoom, and the
|
|
|
182
188
|
viewport/theme/reduced-motion matrix.
|
|
183
189
|
|
|
184
190
|
[Component reference](docs/reference/README.md) contains focused API pages for each public component.
|
|
191
|
+
|
|
192
|
+
## Grouped actions
|
|
193
|
+
|
|
194
|
+
`ButtonGroup` composes independent `Button` and `ButtonLink` controls. `layout="standard"`
|
|
195
|
+
keeps separate controls with an 8px gap; `layout="cells"` removes their outer borders
|
|
196
|
+
and corner radii, fills equal-width cells, and owns one separator between visible
|
|
197
|
+
actions. Groups stack at 20rem or less of their own width, including in narrow
|
|
198
|
+
panels on wide screens. Actions retain native Tab order and event semantics.
|
|
199
|
+
The group has no selected value or toolbar keyboard model.
|
|
200
|
+
|
|
201
|
+
Context passes through non-DOM wrappers such as `DrawerClose asChild`. Render each
|
|
202
|
+
action as a direct DOM child of the group's owned grid. Nested groups reset their
|
|
203
|
+
own layout context. A surrounding Footer owns the outer frame, content boundary,
|
|
204
|
+
and safe area; groups draw internal seams only. Give groups available width from
|
|
205
|
+
their parent layout or explicitly size them in intrinsic flex/inline containers.
|
|
206
|
+
|
|
207
|
+
Cells default to 24px padding. `--gridui-button-group-padding-block` customizes
|
|
208
|
+
block padding; `--gridui-button-group-border` customizes internal separator color.
|
|
209
|
+
ModalActions connects its existing responsive footer spacing to this shared token.
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
<ButtonGroup layout="cells" aria-label="Project actions">
|
|
213
|
+
<Button variant="secondary" onClick={cancel}>Cancel</Button>
|
|
214
|
+
<Button loading={saving} onClick={save}>Save</Button>
|
|
215
|
+
</ButtonGroup>
|
|
216
|
+
```
|
package/dist/button/button.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type ButtonVariants } from "../shared/style";
|
|
8
8
|
import type { ButtonAdornmentProps } from "../shared/types";
|
|
9
|
-
import type
|
|
9
|
+
import { type ComponentPropsWithRef, type FC } from "react";
|
|
10
10
|
export type ButtonProps = ComponentPropsWithRef<"button"> & ButtonVariants & ButtonAdornmentProps & {
|
|
11
11
|
readonly loading?: boolean;
|
|
12
12
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Button
|
|
4
|
+
* @namespace ButtonGroup
|
|
5
|
+
* @description Button Group
|
|
6
|
+
*/
|
|
7
|
+
import { type ButtonGroupLayout } from "../shared/group-context";
|
|
8
|
+
import type { ComponentPropsWithRef, FC } from "react";
|
|
9
|
+
export type ButtonGroupProps = ComponentPropsWithRef<"div"> & {
|
|
10
|
+
readonly layout?: ButtonGroupLayout;
|
|
11
|
+
};
|
|
12
|
+
export declare const ButtonGroup: FC<ButtonGroupProps>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type ButtonVariants } from "../shared/style";
|
|
8
8
|
import type { ButtonAdornmentProps } from "../shared/types";
|
|
9
|
-
import type
|
|
9
|
+
import { type ComponentPropsWithRef, type FC } from "react";
|
|
10
10
|
export type ButtonLinkProps = ComponentPropsWithRef<"a"> & ButtonVariants & ButtonAdornmentProps & {
|
|
11
11
|
readonly href: string;
|
|
12
12
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
export { useAsyncAction } from "./button/async-action";
|
|
8
8
|
export type { ButtonProps } from "./button/button";
|
|
9
9
|
export { Button } from "./button/button";
|
|
10
|
+
export type { ButtonGroupProps } from "./button-group/button-group";
|
|
11
|
+
export { ButtonGroup } from "./button-group/button-group";
|
|
10
12
|
export type { ButtonLinkProps } from "./button-link/button-link";
|
|
11
13
|
export { ButtonLink } from "./button-link/button-link";
|
|
12
14
|
export type { ButtonVariants } from "./shared/style";
|
package/dist/index.js
CHANGED
|
@@ -48,6 +48,7 @@ var buttonStyles = cva(cn(
|
|
|
48
48
|
"gridui-u-button--disabled:cursor-not-allowed",
|
|
49
49
|
"gridui-u-button--aria-disabled:cursor-not-allowed",
|
|
50
50
|
"gridui-u-button--data-disabled:cursor-not-allowed",
|
|
51
|
+
"gridui-u-button--data-gridui-busy:cursor-wait",
|
|
51
52
|
"gridui-u-button--motion-reduce:transition-none"
|
|
52
53
|
));
|
|
53
54
|
var buttonStandardStyles = cva(cn(
|
|
@@ -115,19 +116,45 @@ var buttonDividedStyles = cva(cn(
|
|
|
115
116
|
"gridui-button-divided",
|
|
116
117
|
"gridui-u-button--w-full gridui-u-button--items-stretch gridui-u-button--justify-between gridui-u-button--gap-0 gridui-u-button--rounded-none gridui-u-button--p-0 gridui-u-button--text-start"
|
|
117
118
|
));
|
|
118
|
-
var buttonLabelStyles = cva(
|
|
119
|
-
"gridui-button-label",
|
|
120
|
-
"gridui-u-button--inline-flex gridui-u-button--min-w-0 gridui-u-button--flex-1 gridui-u-button--items-center gridui-u-button--gap-gridui-8"
|
|
121
|
-
), {
|
|
119
|
+
var buttonLabelStyles = cva("gridui-button-content", {
|
|
122
120
|
variants: {
|
|
121
|
+
divided: {
|
|
122
|
+
true: "gridui-button-label gridui-u-button--inline-flex gridui-u-button--min-w-0 gridui-u-button--flex-1 gridui-u-button--items-center gridui-u-button--gap-gridui-8",
|
|
123
|
+
false: "gridui-button-body"
|
|
124
|
+
},
|
|
123
125
|
size: {
|
|
124
|
-
small: "
|
|
125
|
-
standard: "
|
|
126
|
-
large: "
|
|
127
|
-
"extra-large": "
|
|
126
|
+
small: "",
|
|
127
|
+
standard: "",
|
|
128
|
+
large: "",
|
|
129
|
+
"extra-large": ""
|
|
128
130
|
}
|
|
129
131
|
},
|
|
130
|
-
|
|
132
|
+
compoundVariants: [
|
|
133
|
+
{
|
|
134
|
+
divided: true,
|
|
135
|
+
size: "small",
|
|
136
|
+
className: "gridui-u-button--py-gridui-4 gridui-u-button--px-gridui-8"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
divided: true,
|
|
140
|
+
size: "standard",
|
|
141
|
+
className: "gridui-u-button--py-gridui-8 gridui-u-button--px-gridui-16"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
divided: true,
|
|
145
|
+
size: "large",
|
|
146
|
+
className: "gridui-u-button--py-gridui-8 gridui-u-button--px-gridui-24"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
divided: true,
|
|
150
|
+
size: "extra-large",
|
|
151
|
+
className: "gridui-u-button--py-gridui-16 gridui-u-button--px-gridui-24"
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
defaultVariants: {
|
|
155
|
+
divided: false,
|
|
156
|
+
size: "standard"
|
|
157
|
+
}
|
|
131
158
|
});
|
|
132
159
|
var buttonStartIconStyles = cva(cn(
|
|
133
160
|
"gridui-button-adornment gridui-button-start-icon",
|
|
@@ -142,33 +169,97 @@ var buttonStartIconStyles = cva(cn(
|
|
|
142
169
|
},
|
|
143
170
|
defaultVariants: { iconSize: "standard" }
|
|
144
171
|
});
|
|
145
|
-
var buttonStartRegionStyles = cva(
|
|
146
|
-
"gridui-button-start-region",
|
|
147
|
-
"gridui-u-button--justify-center gridui-u-button--self-stretch gridui-u-button--py-gridui-8"
|
|
148
|
-
), {
|
|
172
|
+
var buttonStartRegionStyles = cva("", {
|
|
149
173
|
variants: {
|
|
174
|
+
divided: {
|
|
175
|
+
true: "gridui-button-start-region gridui-u-button--justify-center gridui-u-button--self-stretch gridui-u-button--py-gridui-8",
|
|
176
|
+
false: "gridui-button-content"
|
|
177
|
+
},
|
|
150
178
|
size: {
|
|
151
|
-
small: "
|
|
152
|
-
standard: "
|
|
153
|
-
large: "
|
|
154
|
-
"extra-large": "
|
|
179
|
+
small: "",
|
|
180
|
+
standard: "",
|
|
181
|
+
large: "",
|
|
182
|
+
"extra-large": ""
|
|
155
183
|
}
|
|
156
184
|
},
|
|
157
|
-
|
|
185
|
+
compoundVariants: [
|
|
186
|
+
{
|
|
187
|
+
divided: true,
|
|
188
|
+
size: "small",
|
|
189
|
+
className: "gridui-u-button--w-gridui-control-small"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
divided: true,
|
|
193
|
+
size: "standard",
|
|
194
|
+
className: "gridui-u-button--w-gridui-control"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
divided: true,
|
|
198
|
+
size: "large",
|
|
199
|
+
className: "gridui-u-button--w-gridui-control-large"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
divided: true,
|
|
203
|
+
size: "extra-large",
|
|
204
|
+
className: "gridui-u-button--w-gridui-64"
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
defaultVariants: {
|
|
208
|
+
divided: false,
|
|
209
|
+
size: "standard"
|
|
210
|
+
}
|
|
158
211
|
});
|
|
159
|
-
var buttonEndRegionStyles = cva(
|
|
160
|
-
"gridui-button-end-region",
|
|
161
|
-
"gridui-u-button--justify-center gridui-u-button--self-stretch"
|
|
162
|
-
), {
|
|
212
|
+
var buttonEndRegionStyles = cva("", {
|
|
163
213
|
variants: {
|
|
214
|
+
divided: {
|
|
215
|
+
true: "gridui-button-end-region gridui-u-button--justify-center gridui-u-button--self-stretch",
|
|
216
|
+
false: "gridui-button-content"
|
|
217
|
+
},
|
|
164
218
|
size: {
|
|
165
|
-
small: "
|
|
166
|
-
standard: "
|
|
167
|
-
large: "
|
|
168
|
-
"extra-large": "
|
|
219
|
+
small: "",
|
|
220
|
+
standard: "",
|
|
221
|
+
large: "",
|
|
222
|
+
"extra-large": ""
|
|
169
223
|
}
|
|
170
224
|
},
|
|
171
|
-
|
|
225
|
+
compoundVariants: [
|
|
226
|
+
{
|
|
227
|
+
divided: true,
|
|
228
|
+
size: "small",
|
|
229
|
+
className: "gridui-u-button--w-gridui-control-small"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
divided: true,
|
|
233
|
+
size: "standard",
|
|
234
|
+
className: "gridui-u-button--w-gridui-control"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
divided: true,
|
|
238
|
+
size: "large",
|
|
239
|
+
className: "gridui-u-button--w-gridui-control-large"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
divided: true,
|
|
243
|
+
size: "extra-large",
|
|
244
|
+
className: "gridui-u-button--w-gridui-64"
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
defaultVariants: {
|
|
248
|
+
divided: false,
|
|
249
|
+
size: "standard"
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
var buttonEndIconStyles = cva("gridui-u-button--inline-flex", {
|
|
253
|
+
variants: {
|
|
254
|
+
divided: {
|
|
255
|
+
true: "gridui-button-content",
|
|
256
|
+
false: ""
|
|
257
|
+
},
|
|
258
|
+
iconMotion: {
|
|
259
|
+
none: "",
|
|
260
|
+
outward: "gridui-button-end-icon"
|
|
261
|
+
}
|
|
262
|
+
}
|
|
172
263
|
});
|
|
173
264
|
var buttonVariants = cva(buttonStyles(), {
|
|
174
265
|
variants: {
|
|
@@ -200,6 +291,13 @@ var buttonVariants = cva(buttonStyles(), {
|
|
|
200
291
|
}
|
|
201
292
|
},
|
|
202
293
|
compoundVariants: [
|
|
294
|
+
{
|
|
295
|
+
variant: [
|
|
296
|
+
"text",
|
|
297
|
+
"underlined"
|
|
298
|
+
],
|
|
299
|
+
className: "gridui-u-button--px-0"
|
|
300
|
+
},
|
|
203
301
|
{
|
|
204
302
|
variant: [
|
|
205
303
|
"text",
|
|
@@ -218,13 +316,12 @@ var buttonVariants = cva(buttonStyles(), {
|
|
|
218
316
|
}
|
|
219
317
|
});
|
|
220
318
|
var buttonClass = (variants = {}, className) => {
|
|
221
|
-
const textVariant = variants.variant === "text" || variants.variant === "underlined";
|
|
222
319
|
return cn(buttonVariants({
|
|
223
320
|
variant: variants.variant,
|
|
224
321
|
size: variants.size,
|
|
225
322
|
layout: variants.layout,
|
|
226
323
|
iconMotion: variants.iconMotion
|
|
227
|
-
}),
|
|
324
|
+
}), className);
|
|
228
325
|
};
|
|
229
326
|
|
|
230
327
|
// src/shared/content.tsx
|
|
@@ -238,7 +335,10 @@ var ButtonContent = (props) => {
|
|
|
238
335
|
{
|
|
239
336
|
className: cn2(
|
|
240
337
|
buttonStartIconStyles({ iconSize: startIconSize }),
|
|
241
|
-
|
|
338
|
+
buttonStartRegionStyles({
|
|
339
|
+
divided: dividedStart,
|
|
340
|
+
size
|
|
341
|
+
})
|
|
242
342
|
),
|
|
243
343
|
"data-gridui-part": "icon",
|
|
244
344
|
"data-gridui-draw": "graphic",
|
|
@@ -270,7 +370,10 @@ var ButtonContent = (props) => {
|
|
|
270
370
|
/* @__PURE__ */ jsx(
|
|
271
371
|
"span",
|
|
272
372
|
{
|
|
273
|
-
className: cn2(
|
|
373
|
+
className: cn2(buttonLabelStyles({
|
|
374
|
+
divided: layout === "divided",
|
|
375
|
+
size
|
|
376
|
+
})),
|
|
274
377
|
"data-gridui-part": "content",
|
|
275
378
|
"data-gridui-draw": "group",
|
|
276
379
|
children: label
|
|
@@ -281,7 +384,10 @@ var ButtonContent = (props) => {
|
|
|
281
384
|
{
|
|
282
385
|
className: cn2(
|
|
283
386
|
"gridui-button-adornment gridui-u-button--inline-flex gridui-u-button--shrink-0 gridui-u-button--items-center gridui-u-button--pointer-events-none",
|
|
284
|
-
|
|
387
|
+
buttonEndRegionStyles({
|
|
388
|
+
divided: layout === "divided",
|
|
389
|
+
size
|
|
390
|
+
})
|
|
285
391
|
),
|
|
286
392
|
"data-gridui-part": "icon",
|
|
287
393
|
"data-gridui-draw": "graphic",
|
|
@@ -290,7 +396,10 @@ var ButtonContent = (props) => {
|
|
|
290
396
|
children: layout === "divided" || iconMotion === "outward" ? /* @__PURE__ */ jsx(
|
|
291
397
|
"span",
|
|
292
398
|
{
|
|
293
|
-
className: cn2(
|
|
399
|
+
className: cn2(buttonEndIconStyles({
|
|
400
|
+
divided: layout === "divided",
|
|
401
|
+
iconMotion
|
|
402
|
+
})),
|
|
294
403
|
children: endIcon
|
|
295
404
|
}
|
|
296
405
|
) : endIcon
|
|
@@ -299,7 +408,12 @@ var ButtonContent = (props) => {
|
|
|
299
408
|
] });
|
|
300
409
|
};
|
|
301
410
|
|
|
411
|
+
// src/shared/group-context.ts
|
|
412
|
+
import { createContext } from "react";
|
|
413
|
+
var ButtonGroupContext = createContext(void 0);
|
|
414
|
+
|
|
302
415
|
// src/button/button.tsx
|
|
416
|
+
import { useContext, useImperativeHandle, useLayoutEffect, useRef as useRef2 } from "react";
|
|
303
417
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
304
418
|
var Button = (props) => {
|
|
305
419
|
const {
|
|
@@ -309,6 +423,9 @@ var Button = (props) => {
|
|
|
309
423
|
iconMotion,
|
|
310
424
|
loading = false,
|
|
311
425
|
disabled,
|
|
426
|
+
ref: forwardedRef,
|
|
427
|
+
onClick,
|
|
428
|
+
onClickCapture,
|
|
312
429
|
type = "button",
|
|
313
430
|
className,
|
|
314
431
|
children,
|
|
@@ -318,6 +435,30 @@ var Button = (props) => {
|
|
|
318
435
|
endIcon,
|
|
319
436
|
...restProps
|
|
320
437
|
} = props;
|
|
438
|
+
const button = useRef2(null);
|
|
439
|
+
useImperativeHandle(forwardedRef, () => {
|
|
440
|
+
return button.current;
|
|
441
|
+
}, []);
|
|
442
|
+
const unavailable = disabled || restProps["aria-disabled"] === true || restProps["aria-disabled"] === "true";
|
|
443
|
+
const busy = loading && !unavailable;
|
|
444
|
+
useLayoutEffect(() => {
|
|
445
|
+
const element = button.current;
|
|
446
|
+
const form = element?.form;
|
|
447
|
+
if (!loading || type !== "submit" || !form) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
const preventBusySubmit = (event) => {
|
|
451
|
+
if (event.submitter === element) {
|
|
452
|
+
event.preventDefault();
|
|
453
|
+
event.stopImmediatePropagation();
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
form.addEventListener("submit", preventBusySubmit, true);
|
|
457
|
+
return () => {
|
|
458
|
+
form.removeEventListener("submit", preventBusySubmit, true);
|
|
459
|
+
};
|
|
460
|
+
});
|
|
461
|
+
const groupLayout = useContext(ButtonGroupContext);
|
|
321
462
|
const variants = variant === "text" || variant === "underlined" ? {
|
|
322
463
|
variant,
|
|
323
464
|
size,
|
|
@@ -341,8 +482,28 @@ var Button = (props) => {
|
|
|
341
482
|
...restProps,
|
|
342
483
|
"data-gridui-component": "button",
|
|
343
484
|
"data-gridui-draw": drawing,
|
|
485
|
+
"data-gridui-button-group-item": groupLayout,
|
|
344
486
|
type,
|
|
345
|
-
|
|
487
|
+
ref: button,
|
|
488
|
+
disabled,
|
|
489
|
+
"aria-disabled": loading || restProps["aria-disabled"],
|
|
490
|
+
"data-gridui-busy": busy || void 0,
|
|
491
|
+
onClickCapture: (event) => {
|
|
492
|
+
if (loading || unavailable) {
|
|
493
|
+
event.preventDefault();
|
|
494
|
+
event.stopPropagation();
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
onClickCapture?.(event);
|
|
498
|
+
},
|
|
499
|
+
onClick: (event) => {
|
|
500
|
+
if (loading || unavailable) {
|
|
501
|
+
event.preventDefault();
|
|
502
|
+
event.stopPropagation();
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
onClick?.(event);
|
|
506
|
+
},
|
|
346
507
|
"aria-busy": loading || restProps["aria-busy"],
|
|
347
508
|
className: buttonClass(variants, className),
|
|
348
509
|
children: /* @__PURE__ */ jsx2(
|
|
@@ -362,8 +523,39 @@ var Button = (props) => {
|
|
|
362
523
|
);
|
|
363
524
|
};
|
|
364
525
|
|
|
365
|
-
// src/button-
|
|
526
|
+
// src/button-group/button-group.tsx
|
|
527
|
+
import { cn as cn3 } from "@gridui/style-utils";
|
|
366
528
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
529
|
+
var ButtonGroup = (props) => {
|
|
530
|
+
const { layout = "standard", className, children, role = "group", ...restProps } = props;
|
|
531
|
+
return /* @__PURE__ */ jsx3(
|
|
532
|
+
ButtonGroupContext,
|
|
533
|
+
{
|
|
534
|
+
value: layout,
|
|
535
|
+
children: /* @__PURE__ */ jsx3(
|
|
536
|
+
"div",
|
|
537
|
+
{
|
|
538
|
+
...restProps,
|
|
539
|
+
role,
|
|
540
|
+
"data-layout": layout,
|
|
541
|
+
className: cn3("gridui-button-group", className),
|
|
542
|
+
children: /* @__PURE__ */ jsx3(
|
|
543
|
+
"div",
|
|
544
|
+
{
|
|
545
|
+
className: "gridui-button-group-items",
|
|
546
|
+
"data-layout": layout,
|
|
547
|
+
children
|
|
548
|
+
}
|
|
549
|
+
)
|
|
550
|
+
}
|
|
551
|
+
)
|
|
552
|
+
}
|
|
553
|
+
);
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
// src/button-link/button-link.tsx
|
|
557
|
+
import { useContext as useContext2 } from "react";
|
|
558
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
367
559
|
var ButtonLink = (props) => {
|
|
368
560
|
const {
|
|
369
561
|
variant = "secondary",
|
|
@@ -378,6 +570,7 @@ var ButtonLink = (props) => {
|
|
|
378
570
|
endIcon,
|
|
379
571
|
...restProps
|
|
380
572
|
} = props;
|
|
573
|
+
const groupLayout = useContext2(ButtonGroupContext);
|
|
381
574
|
const variants = variant === "text" || variant === "underlined" ? {
|
|
382
575
|
variant,
|
|
383
576
|
size,
|
|
@@ -395,14 +588,15 @@ var ButtonLink = (props) => {
|
|
|
395
588
|
} else if (variant === "text" || variant === "quiet") {
|
|
396
589
|
drawing = "group";
|
|
397
590
|
}
|
|
398
|
-
return /* @__PURE__ */
|
|
591
|
+
return /* @__PURE__ */ jsx4(
|
|
399
592
|
"a",
|
|
400
593
|
{
|
|
401
594
|
...restProps,
|
|
402
595
|
"data-gridui-component": "button-link",
|
|
403
596
|
"data-gridui-draw": drawing,
|
|
597
|
+
"data-gridui-button-group-item": groupLayout,
|
|
404
598
|
className: buttonClass(variants, className),
|
|
405
|
-
children: /* @__PURE__ */
|
|
599
|
+
children: /* @__PURE__ */ jsx4(
|
|
406
600
|
ButtonContent,
|
|
407
601
|
{
|
|
408
602
|
layout: variants.layout,
|
|
@@ -420,6 +614,7 @@ var ButtonLink = (props) => {
|
|
|
420
614
|
};
|
|
421
615
|
export {
|
|
422
616
|
Button,
|
|
617
|
+
ButtonGroup,
|
|
423
618
|
ButtonLink,
|
|
424
619
|
buttonClass,
|
|
425
620
|
useAsyncAction
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/button/async-action.ts", "../src/shared/style.ts", "../src/shared/content.tsx", "../src/button/button.tsx", "../src/button-link/button-link.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * @author WMXPY\n * @package Button\n * @namespace Button\n * @description Async Action\n */\n\nimport { useRef, useState } from \"react\";\n\ntype Action = () => void | Promise<void>;\n\nexport const performAsyncAction = async ({ action, onStart, onPendingChange }: {\n readonly action: Action;\n readonly onStart?: Action;\n readonly onPendingChange: (pending: boolean) => void;\n}): Promise<void> => {\n onPendingChange(true);\n try {\n await onStart?.();\n await new Promise<void>((resolve) => {\n setTimeout(resolve, 0);\n });\n await action();\n } finally {\n onPendingChange(false);\n }\n};\n\nexport const useAsyncAction = ({ action, onStart, disabled = false }: {\n readonly action: Action;\n readonly onStart?: Action;\n readonly disabled?: boolean;\n}) => {\n const [\n pending,\n setPending,\n ] = useState(false);\n const active = useRef(false);\n return {\n pending,\n async run(): Promise<void> {\n if (disabled || active.current) {\n return;\n }\n active.current = true;\n try {\n await performAsyncAction({\n action,\n ...(onStart ? { onStart } : {}),\n onPendingChange: setPending,\n });\n } finally {\n active.current = false;\n }\n },\n };\n};\n", "/**\n * @author WMXPY\n * @package Button\n * @namespace Shared\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nexport const buttonStyles = cva(cn(\n \"gridui-button\",\n \"gridui-u-button--inline-flex gridui-u-button--w-fit gridui-u-button--max-w-full gridui-u-button--min-w-0 gridui-u-button--items-center gridui-u-button--justify-center gridui-u-button--gap-gridui-8 gridui-u-button--rounded-control gridui-u-button--type-ui gridui-u-button--text-center gridui-u-button--no-underline gridui-u-button--wrap-anywhere gridui-u-button--cursor-pointer gridui-u-button--transition-colors gridui-u-button--duration-(--gridui-motion-duration-quick) gridui-u-button--ease-(--gridui-motion-ease-out)\",\n \"gridui-u-button--[--gridui-button-icon-size:var(--gridui-icon-size)] gridui-u-button--[&_svg]:w-(--gridui-button-icon-size) gridui-u-button--[&_svg]:h-(--gridui-button-icon-size) gridui-u-button--[&_svg]:shrink-0 gridui-u-button--[&_svg]:pointer-events-none\",\n \"gridui-u-button--disabled:cursor-not-allowed\",\n \"gridui-u-button--aria-disabled:cursor-not-allowed\",\n \"gridui-u-button--data-disabled:cursor-not-allowed\",\n \"gridui-u-button--motion-reduce:transition-none\",\n));\n\nexport const buttonStandardStyles = cva(cn(\n \"gridui-button-standard\",\n \"gridui-u-button--min-h-gridui-control gridui-u-button--py-gridui-8 gridui-u-button--px-gridui-16\",\n));\n\nexport const buttonSmallStyles = cva(cn(\n \"gridui-button-small\",\n \"gridui-u-button--min-h-gridui-control-small gridui-u-button--py-gridui-4 gridui-u-button--px-gridui-8\",\n));\n\nexport const buttonLargeStyles = cva(cn(\n \"gridui-button-large\",\n \"gridui-u-button--min-h-gridui-control-large gridui-u-button--py-gridui-8 gridui-u-button--px-gridui-24 gridui-u-button--[--gridui-button-icon-size:var(--gridui-icon-size-large)]\",\n));\n\nexport const buttonExtraLargeStyles = cva(cn(\n \"gridui-button-extra-large\",\n \"gridui-u-button--min-h-18 gridui-u-button--py-gridui-16 gridui-u-button--px-gridui-24 gridui-u-button--[--gridui-button-icon-size:var(--gridui-icon-size-large)]\",\n));\n\nexport const buttonPrimaryStyles = cva(cn(\n \"gridui-button-primary\",\n \"gridui-u-button--text-accent-foreground gridui-u-button--bg-accent-background gridui-u-button--border-accent-background\",\n));\n\nexport const buttonSecondaryStyles = cva(cn(\n \"gridui-button-secondary\",\n \"gridui-u-button--text-foreground gridui-u-button--bg-transparent gridui-u-button--border-border\",\n));\n\nexport const buttonQuietStyles = cva(cn(\n \"gridui-button-quiet\",\n \"gridui-u-button--text-foreground gridui-u-button--bg-transparent\",\n));\n\nexport const buttonHighlightStyles = cva(cn(\n \"gridui-button-highlight\",\n \"gridui-u-button--text-foreground gridui-u-button--bg-brand-tint\",\n));\n\nexport const buttonTextStyles = cva(cn(\n \"gridui-button-text\",\n \"gridui-u-button--text-foreground gridui-u-button--bg-transparent gridui-u-button--border-0 gridui-u-button--rounded-none\",\n));\n\nexport const buttonUnderlinedStyles = cva(cn(\n \"gridui-button-underlined\",\n \"gridui-u-button--text-foreground gridui-u-button--bg-transparent gridui-u-button--border-0 gridui-u-button--border-b gridui-u-button--border-foreground gridui-u-button--rounded-none\",\n));\n\nexport const buttonEntryStyles = cva(cn(\n \"gridui-button-entry\",\n \"gridui-u-button--justify-between gridui-u-button--w-full gridui-u-button--py-gridui-16 gridui-u-button--px-gridui-24\",\n));\n\nexport const buttonCellStyles = cva(cn(\n \"gridui-button-cell\",\n \"gridui-u-button--w-full gridui-u-button--h-full gridui-u-button--justify-start gridui-u-button--rounded-none gridui-u-button--py-gridui-16 gridui-u-button--px-gridui-24 gridui-u-button--text-left\",\n));\n\nexport const buttonRailStyles = cva(cn(\n \"gridui-button-rail\",\n \"gridui-u-button--w-full gridui-u-button--min-w-gridui-24 gridui-u-button--flex-col gridui-u-button--py-gridui-8 gridui-u-button--px-0\",\n \"gridui-u-button--[&_>_span]:[writing-mode:vertical-rl] gridui-u-button--[&_>_span]:whitespace-nowrap\",\n));\n\nexport const buttonIconStyles = cva(cn(\n \"gridui-button-icon\",\n \"gridui-u-button--w-gridui-control gridui-u-button--h-gridui-control gridui-u-button--shrink-0 gridui-u-button--p-0\",\n \"gridui-u-button--[&.gridui-button-small]:w-gridui-control-small gridui-u-button--[&.gridui-button-small]:h-gridui-control-small\",\n \"gridui-u-button--[&.gridui-button-large]:w-gridui-control-large gridui-u-button--[&.gridui-button-large]:h-gridui-control-large\",\n \"gridui-u-button--[&.gridui-button-extra-large]:w-18 gridui-u-button--[&.gridui-button-extra-large]:h-18\",\n \"gridui-u-button--pointer-coarse:[&.gridui-button-small]:w-gridui-control gridui-u-button--pointer-coarse:[&.gridui-button-small]:h-gridui-control\",\n));\n\nexport const buttonDividedStyles = cva(cn(\n \"gridui-button-divided\",\n \"gridui-u-button--w-full gridui-u-button--items-stretch gridui-u-button--justify-between gridui-u-button--gap-0 gridui-u-button--rounded-none gridui-u-button--p-0 gridui-u-button--text-start\",\n));\n\nexport const buttonLabelStyles = cva(cn(\n \"gridui-button-label\",\n \"gridui-u-button--inline-flex gridui-u-button--min-w-0 gridui-u-button--flex-1 gridui-u-button--items-center gridui-u-button--gap-gridui-8\",\n), {\n variants: {\n size: {\n small: \"gridui-u-button--py-gridui-4 gridui-u-button--px-gridui-8\",\n standard: \"gridui-u-button--py-gridui-8 gridui-u-button--px-gridui-16\",\n large: \"gridui-u-button--py-gridui-8 gridui-u-button--px-gridui-24\",\n \"extra-large\": \"gridui-u-button--py-gridui-16 gridui-u-button--px-gridui-24\",\n },\n },\n defaultVariants: { size: \"standard\" },\n});\n\nexport const buttonStartIconStyles = cva(cn(\n \"gridui-button-adornment gridui-button-start-icon\",\n \"gridui-u-button--inline-flex gridui-u-button--shrink-0 gridui-u-button--items-center gridui-u-button--pointer-events-none\",\n), {\n variants: {\n iconSize: {\n standard: \"\",\n large: \"gridui-u-button--[--gridui-button-icon-size:var(--gridui-space-32)]\",\n \"extra-large\": \"gridui-u-button--[--gridui-button-icon-size:var(--gridui-space-48)]\",\n },\n },\n defaultVariants: { iconSize: \"standard\" },\n});\n\nexport const buttonStartRegionStyles = cva(cn(\n \"gridui-button-start-region\",\n \"gridui-u-button--justify-center gridui-u-button--self-stretch gridui-u-button--py-gridui-8\",\n), {\n variants: {\n size: {\n small: \"gridui-u-button--w-gridui-control-small\",\n standard: \"gridui-u-button--w-gridui-control\",\n large: \"gridui-u-button--w-gridui-control-large\",\n \"extra-large\": \"gridui-u-button--w-gridui-64\",\n },\n },\n defaultVariants: { size: \"standard\" },\n});\n\nexport const buttonEndRegionStyles = cva(cn(\n \"gridui-button-end-region\",\n \"gridui-u-button--justify-center gridui-u-button--self-stretch\",\n), {\n variants: {\n size: {\n small: \"gridui-u-button--w-gridui-control-small\",\n standard: \"gridui-u-button--w-gridui-control\",\n large: \"gridui-u-button--w-gridui-control-large\",\n \"extra-large\": \"gridui-u-button--w-gridui-64\",\n },\n },\n defaultVariants: { size: \"standard\" },\n});\n\nexport const buttonVariants = cva(buttonStyles(), {\n variants: {\n variant: {\n primary: buttonPrimaryStyles(),\n secondary: buttonSecondaryStyles(),\n quiet: buttonQuietStyles(),\n highlight: buttonHighlightStyles(),\n text: buttonTextStyles(),\n underlined: buttonUnderlinedStyles(),\n },\n size: {\n small: buttonSmallStyles(),\n standard: buttonStandardStyles(),\n large: buttonLargeStyles(),\n \"extra-large\": buttonExtraLargeStyles(),\n },\n layout: {\n standard: \"\",\n icon: buttonIconStyles(),\n entry: buttonEntryStyles(),\n cell: buttonCellStyles(),\n rail: buttonRailStyles(),\n divided: buttonDividedStyles(),\n },\n iconMotion: {\n none: \"\",\n outward: \"gridui-button-icon-motion-outward\",\n },\n },\n compoundVariants: [\n {\n variant: [\n \"text\",\n \"underlined\",\n ],\n size: [\n \"large\",\n \"extra-large\",\n ],\n className: \"gridui-u-button--gap-gridui-32 gridui-u-button--type-supporting\",\n },\n ],\n defaultVariants: {\n variant: \"primary\",\n size: \"standard\",\n },\n});\n\ntype ButtonStyleVariants = VariantProps<typeof buttonVariants>;\n\nexport type ButtonVariants = Omit<ButtonStyleVariants, \"variant\" | \"layout\"> & (\n | {\n readonly variant: \"text\" | \"underlined\";\n readonly layout?: \"standard\" | null | undefined;\n }\n | {\n readonly variant?: Exclude<ButtonStyleVariants[\"variant\"], \"text\" | \"underlined\">;\n readonly layout?: ButtonStyleVariants[\"layout\"];\n }\n);\n\nexport const buttonClass = (variants: ButtonVariants = {}, className?: string): string => {\n const textVariant = variants.variant === \"text\" || variants.variant === \"underlined\";\n return cn(buttonVariants({\n variant: variants.variant,\n size: variants.size,\n layout: variants.layout,\n iconMotion: variants.iconMotion,\n }), textVariant && \"gridui-u-button--px-0\", className);\n};\n", "/**\n * @author WMXPY\n * @package Button\n * @namespace Shared\n * @description Content\n */\n\nimport { buttonEndRegionStyles, buttonLabelStyles, buttonStartIconStyles, buttonStartRegionStyles, type ButtonVariants } from \"./style\";\nimport type { ButtonAdornmentProps } from \"./types\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC, ReactNode } from \"react\";\n\nexport type ButtonContentProps = ButtonAdornmentProps & {\n readonly children?: ReactNode;\n readonly layout?: ButtonVariants[\"layout\"];\n readonly size?: ButtonVariants[\"size\"];\n readonly iconMotion?: ButtonVariants[\"iconMotion\"];\n};\n\nexport const ButtonContent: FC<ButtonContentProps> = (props: ButtonContentProps) => {\n const { children, startIcon, startIconLayout, startIconSize, endIcon, layout, size, iconMotion } = props;\n const dividedStart = layout === \"divided\" && startIconLayout === \"divided\";\n const startAdornment = startIcon !== undefined && startIcon !== null && typeof startIcon !== \"boolean\" ? (<span\n className={cn(\n buttonStartIconStyles({ iconSize: startIconSize }),\n dividedStart ? buttonStartRegionStyles({ size }) : \"gridui-button-content\",\n )}\n data-gridui-part=\"icon\"\n data-gridui-draw=\"graphic\"\n aria-hidden=\"true\"\n inert\n >\n {dividedStart ? (<span\n className=\"gridui-button-content gridui-u-button--inline-flex\"\n >\n {startIcon}\n </span>) : startIcon}\n </span>) : null;\n const label = (<>\n {!dividedStart && startAdornment}\n <span\n className=\"gridui-button-label-content\"\n data-gridui-part=\"label\"\n data-gridui-draw={layout === \"icon\" ? \"graphic\" : \"text\"}\n >\n {children}\n </span>\n </>);\n\n return (<>\n {dividedStart && startAdornment}\n <span\n className={cn(\"gridui-button-content\", layout === \"divided\" ? buttonLabelStyles({ size }) : \"gridui-button-body\")}\n data-gridui-part=\"content\"\n data-gridui-draw=\"group\"\n >\n {label}\n </span>\n {endIcon !== undefined && endIcon !== null && typeof endIcon !== \"boolean\" && (<span\n className={cn(\n \"gridui-button-adornment gridui-u-button--inline-flex gridui-u-button--shrink-0 gridui-u-button--items-center gridui-u-button--pointer-events-none\",\n layout === \"divided\" ? buttonEndRegionStyles({ size }) : \"gridui-button-content\",\n )}\n data-gridui-part=\"icon\"\n data-gridui-draw=\"graphic\"\n aria-hidden=\"true\"\n inert\n >\n {layout === \"divided\" || iconMotion === \"outward\" ? (<span\n className={cn(\"gridui-u-button--inline-flex\", layout === \"divided\" && \"gridui-button-content\", iconMotion === \"outward\" && \"gridui-button-end-icon\")}\n >\n {endIcon}\n </span>) : endIcon}\n </span>)}\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Button\n * @namespace Button\n * @description Button\n */\n\nimport { ButtonContent } from \"../shared/content\";\nimport { buttonClass, type ButtonVariants } from \"../shared/style\";\nimport type { ButtonAdornmentProps } from \"../shared/types\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ButtonProps = ComponentPropsWithRef<\"button\"> & ButtonVariants & ButtonAdornmentProps & {\n readonly loading?: boolean;\n};\n\nexport const Button: FC<ButtonProps> = (props: ButtonProps) => {\n const {\n variant,\n size,\n layout,\n iconMotion,\n loading = false,\n disabled,\n type = \"button\",\n className,\n children,\n startIcon,\n startIconLayout = \"inline\",\n startIconSize = \"standard\",\n endIcon,\n ...restProps\n } = props;\n const variants: ButtonVariants = (variant === \"text\" || variant === \"underlined\") ? {\n variant,\n size,\n layout: \"standard\",\n iconMotion,\n } : {\n variant,\n size,\n layout,\n iconMotion,\n };\n let drawing = \"surface\";\n if (variant === \"underlined\") {\n drawing = \"atomic\";\n } else if (variant === \"text\" || variant === \"quiet\") {\n drawing = \"group\";\n }\n return (<button\n {...restProps}\n data-gridui-component=\"button\"\n data-gridui-draw={drawing}\n type={type}\n disabled={disabled || loading}\n aria-busy={loading || restProps[\"aria-busy\"]}\n className={buttonClass(variants, className)}\n >\n <ButtonContent\n layout={variants.layout}\n size={size}\n iconMotion={iconMotion}\n startIcon={startIcon}\n startIconLayout={startIconLayout}\n startIconSize={startIconSize}\n endIcon={endIcon}\n >\n {children}\n </ButtonContent>\n </button>);\n};\n", "/**\n * @author WMXPY\n * @package Button\n * @namespace ButtonLink\n * @description Button Link\n */\n\nimport { ButtonContent } from \"../shared/content\";\nimport { buttonClass, type ButtonVariants } from \"../shared/style\";\nimport type { ButtonAdornmentProps } from \"../shared/types\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ButtonLinkProps = ComponentPropsWithRef<\"a\"> & ButtonVariants & ButtonAdornmentProps & {\n readonly href: string;\n};\n\nexport const ButtonLink: FC<ButtonLinkProps> = (props: ButtonLinkProps) => {\n const {\n variant = \"secondary\",\n size,\n layout,\n iconMotion,\n className,\n children,\n startIcon,\n startIconLayout = \"inline\",\n startIconSize = \"standard\",\n endIcon,\n ...restProps\n } = props;\n const variants: ButtonVariants = (variant === \"text\" || variant === \"underlined\") ? {\n variant,\n size,\n layout: \"standard\",\n iconMotion,\n } : {\n variant,\n size,\n layout,\n iconMotion,\n };\n let drawing = \"surface\";\n if (variant === \"underlined\") {\n drawing = \"atomic\";\n } else if (variant === \"text\" || variant === \"quiet\") {\n drawing = \"group\";\n }\n return (<a\n {...restProps}\n data-gridui-component=\"button-link\"\n data-gridui-draw={drawing}\n className={buttonClass(variants, className)}\n >\n <ButtonContent\n layout={variants.layout}\n size={size}\n iconMotion={iconMotion}\n startIcon={startIcon}\n startIconLayout={startIconLayout}\n startIconSize={startIconSize}\n endIcon={endIcon}\n >\n {children}\n </ButtonContent>\n </a>);\n};\n"],
|
|
5
|
-
"mappings": ";AAOA,SAAS,QAAQ,gBAAgB;AAI1B,IAAM,qBAAqB,OAAO,EAAE,QAAQ,SAAS,gBAAgB,MAIvD;AACjB,kBAAgB,IAAI;AACpB,MAAI;AACA,UAAM,UAAU;AAChB,UAAM,IAAI,QAAc,CAAC,YAAY;AACjC,iBAAW,SAAS,CAAC;AAAA,IACzB,CAAC;AACD,UAAM,OAAO;AAAA,EACjB,UAAE;AACE,oBAAgB,KAAK;AAAA,EACzB;AACJ;AAEO,IAAM,iBAAiB,CAAC,EAAE,QAAQ,SAAS,WAAW,MAAM,MAI7D;AACF,QAAM;AAAA,IACF;AAAA,IACA;AAAA,EACJ,IAAI,SAAS,KAAK;AAClB,QAAM,SAAS,OAAO,KAAK;AAC3B,SAAO;AAAA,IACH;AAAA,IACA,MAAM,MAAqB;AACvB,UAAI,YAAY,OAAO,SAAS;AAC5B;AAAA,MACJ;AACA,aAAO,UAAU;AACjB,UAAI;AACA,cAAM,mBAAmB;AAAA,UACrB;AAAA,UACA,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;AAAA,UAC7B,iBAAiB;AAAA,QACrB,CAAC;AAAA,MACL,UAAE;AACE,eAAO,UAAU;AAAA,MACrB;AAAA,IACJ;AAAA,EACJ;AACJ;;;ACjDA,SAAS,UAAU;AACnB,SAAS,WAA8B;AAEhC,IAAM,eAAe,IAAI;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,uBAAuB,IAAI;AAAA,EACpC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,oBAAoB,IAAI;AAAA,EACjC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,oBAAoB,IAAI;AAAA,EACjC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,yBAAyB,IAAI;AAAA,EACtC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,sBAAsB,IAAI;AAAA,EACnC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,wBAAwB,IAAI;AAAA,EACrC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,oBAAoB,IAAI;AAAA,EACjC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,wBAAwB,IAAI;AAAA,EACrC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,mBAAmB,IAAI;AAAA,EAChC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,yBAAyB,IAAI;AAAA,EACtC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,oBAAoB,IAAI;AAAA,EACjC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,mBAAmB,IAAI;AAAA,EAChC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,mBAAmB,IAAI;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,mBAAmB,IAAI;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,sBAAsB,IAAI;AAAA,EACnC;AAAA,EACA;AACJ,CAAC;AAEM,IAAM,oBAAoB,IAAI;AAAA,
|
|
6
|
-
"names": ["cn", "jsx", "jsx"]
|
|
3
|
+
"sources": ["../src/button/async-action.ts", "../src/shared/style.ts", "../src/shared/content.tsx", "../src/shared/group-context.ts", "../src/button/button.tsx", "../src/button-group/button-group.tsx", "../src/button-link/button-link.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Button\n * @namespace Button\n * @description Async Action\n */\n\nimport { useRef, useState } from \"react\";\n\ntype Action = () => void | Promise<void>;\n\nexport const performAsyncAction = async ({ action, onStart, onPendingChange }: {\n readonly action: Action;\n readonly onStart?: Action;\n readonly onPendingChange: (pending: boolean) => void;\n}): Promise<void> => {\n onPendingChange(true);\n try {\n await onStart?.();\n await new Promise<void>((resolve) => {\n setTimeout(resolve, 0);\n });\n await action();\n } finally {\n onPendingChange(false);\n }\n};\n\nexport const useAsyncAction = ({ action, onStart, disabled = false }: {\n readonly action: Action;\n readonly onStart?: Action;\n readonly disabled?: boolean;\n}) => {\n const [\n pending,\n setPending,\n ] = useState(false);\n const active = useRef(false);\n return {\n pending,\n async run(): Promise<void> {\n if (disabled || active.current) {\n return;\n }\n active.current = true;\n try {\n await performAsyncAction({\n action,\n ...(onStart ? { onStart } : {}),\n onPendingChange: setPending,\n });\n } finally {\n active.current = false;\n }\n },\n };\n};\n", "/**\n * @author WMXPY\n * @package Button\n * @namespace Shared\n * @description Style\n */\n\nimport { cn } from \"@gridui/style-utils\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nexport const buttonStyles = cva(cn(\n \"gridui-button\",\n \"gridui-u-button--inline-flex gridui-u-button--w-fit gridui-u-button--max-w-full gridui-u-button--min-w-0 gridui-u-button--items-center gridui-u-button--justify-center gridui-u-button--gap-gridui-8 gridui-u-button--rounded-control gridui-u-button--type-ui gridui-u-button--text-center gridui-u-button--no-underline gridui-u-button--wrap-anywhere gridui-u-button--cursor-pointer gridui-u-button--transition-colors gridui-u-button--duration-(--gridui-motion-duration-quick) gridui-u-button--ease-(--gridui-motion-ease-out)\",\n \"gridui-u-button--[--gridui-button-icon-size:var(--gridui-icon-size)] gridui-u-button--[&_svg]:w-(--gridui-button-icon-size) gridui-u-button--[&_svg]:h-(--gridui-button-icon-size) gridui-u-button--[&_svg]:shrink-0 gridui-u-button--[&_svg]:pointer-events-none\",\n \"gridui-u-button--disabled:cursor-not-allowed\",\n \"gridui-u-button--aria-disabled:cursor-not-allowed\",\n \"gridui-u-button--data-disabled:cursor-not-allowed\",\n \"gridui-u-button--data-gridui-busy:cursor-wait\",\n \"gridui-u-button--motion-reduce:transition-none\",\n));\n\nexport const buttonStandardStyles = cva(cn(\n \"gridui-button-standard\",\n \"gridui-u-button--min-h-gridui-control gridui-u-button--py-gridui-8 gridui-u-button--px-gridui-16\",\n));\n\nexport const buttonSmallStyles = cva(cn(\n \"gridui-button-small\",\n \"gridui-u-button--min-h-gridui-control-small gridui-u-button--py-gridui-4 gridui-u-button--px-gridui-8\",\n));\n\nexport const buttonLargeStyles = cva(cn(\n \"gridui-button-large\",\n \"gridui-u-button--min-h-gridui-control-large gridui-u-button--py-gridui-8 gridui-u-button--px-gridui-24 gridui-u-button--[--gridui-button-icon-size:var(--gridui-icon-size-large)]\",\n));\n\nexport const buttonExtraLargeStyles = cva(cn(\n \"gridui-button-extra-large\",\n \"gridui-u-button--min-h-18 gridui-u-button--py-gridui-16 gridui-u-button--px-gridui-24 gridui-u-button--[--gridui-button-icon-size:var(--gridui-icon-size-large)]\",\n));\n\nexport const buttonPrimaryStyles = cva(cn(\n \"gridui-button-primary\",\n \"gridui-u-button--text-accent-foreground gridui-u-button--bg-accent-background gridui-u-button--border-accent-background\",\n));\n\nexport const buttonSecondaryStyles = cva(cn(\n \"gridui-button-secondary\",\n \"gridui-u-button--text-foreground gridui-u-button--bg-transparent gridui-u-button--border-border\",\n));\n\nexport const buttonQuietStyles = cva(cn(\n \"gridui-button-quiet\",\n \"gridui-u-button--text-foreground gridui-u-button--bg-transparent\",\n));\n\nexport const buttonHighlightStyles = cva(cn(\n \"gridui-button-highlight\",\n \"gridui-u-button--text-foreground gridui-u-button--bg-brand-tint\",\n));\n\nexport const buttonTextStyles = cva(cn(\n \"gridui-button-text\",\n \"gridui-u-button--text-foreground gridui-u-button--bg-transparent gridui-u-button--border-0 gridui-u-button--rounded-none\",\n));\n\nexport const buttonUnderlinedStyles = cva(cn(\n \"gridui-button-underlined\",\n \"gridui-u-button--text-foreground gridui-u-button--bg-transparent gridui-u-button--border-0 gridui-u-button--border-b gridui-u-button--border-foreground gridui-u-button--rounded-none\",\n));\n\nexport const buttonEntryStyles = cva(cn(\n \"gridui-button-entry\",\n \"gridui-u-button--justify-between gridui-u-button--w-full gridui-u-button--py-gridui-16 gridui-u-button--px-gridui-24\",\n));\n\nexport const buttonCellStyles = cva(cn(\n \"gridui-button-cell\",\n \"gridui-u-button--w-full gridui-u-button--h-full gridui-u-button--justify-start gridui-u-button--rounded-none gridui-u-button--py-gridui-16 gridui-u-button--px-gridui-24 gridui-u-button--text-left\",\n));\n\nexport const buttonRailStyles = cva(cn(\n \"gridui-button-rail\",\n \"gridui-u-button--w-full gridui-u-button--min-w-gridui-24 gridui-u-button--flex-col gridui-u-button--py-gridui-8 gridui-u-button--px-0\",\n \"gridui-u-button--[&_>_span]:[writing-mode:vertical-rl] gridui-u-button--[&_>_span]:whitespace-nowrap\",\n));\n\nexport const buttonIconStyles = cva(cn(\n \"gridui-button-icon\",\n \"gridui-u-button--w-gridui-control gridui-u-button--h-gridui-control gridui-u-button--shrink-0 gridui-u-button--p-0\",\n \"gridui-u-button--[&.gridui-button-small]:w-gridui-control-small gridui-u-button--[&.gridui-button-small]:h-gridui-control-small\",\n \"gridui-u-button--[&.gridui-button-large]:w-gridui-control-large gridui-u-button--[&.gridui-button-large]:h-gridui-control-large\",\n \"gridui-u-button--[&.gridui-button-extra-large]:w-18 gridui-u-button--[&.gridui-button-extra-large]:h-18\",\n \"gridui-u-button--pointer-coarse:[&.gridui-button-small]:w-gridui-control gridui-u-button--pointer-coarse:[&.gridui-button-small]:h-gridui-control\",\n));\n\nexport const buttonDividedStyles = cva(cn(\n \"gridui-button-divided\",\n \"gridui-u-button--w-full gridui-u-button--items-stretch gridui-u-button--justify-between gridui-u-button--gap-0 gridui-u-button--rounded-none gridui-u-button--p-0 gridui-u-button--text-start\",\n));\n\nexport const buttonLabelStyles = cva(\"gridui-button-content\", {\n variants: {\n divided: {\n true: \"gridui-button-label gridui-u-button--inline-flex gridui-u-button--min-w-0 gridui-u-button--flex-1 gridui-u-button--items-center gridui-u-button--gap-gridui-8\",\n false: \"gridui-button-body\",\n },\n size: {\n small: \"\",\n standard: \"\",\n large: \"\",\n \"extra-large\": \"\",\n },\n },\n compoundVariants: [\n {\n divided: true,\n size: \"small\",\n className: \"gridui-u-button--py-gridui-4 gridui-u-button--px-gridui-8\",\n },\n {\n divided: true,\n size: \"standard\",\n className: \"gridui-u-button--py-gridui-8 gridui-u-button--px-gridui-16\",\n },\n {\n divided: true,\n size: \"large\",\n className: \"gridui-u-button--py-gridui-8 gridui-u-button--px-gridui-24\",\n },\n {\n divided: true,\n size: \"extra-large\",\n className: \"gridui-u-button--py-gridui-16 gridui-u-button--px-gridui-24\",\n },\n ],\n defaultVariants: {\n divided: false,\n size: \"standard\",\n },\n});\n\nexport const buttonStartIconStyles = cva(cn(\n \"gridui-button-adornment gridui-button-start-icon\",\n \"gridui-u-button--inline-flex gridui-u-button--shrink-0 gridui-u-button--items-center gridui-u-button--pointer-events-none\",\n), {\n variants: {\n iconSize: {\n standard: \"\",\n large: \"gridui-u-button--[--gridui-button-icon-size:var(--gridui-space-32)]\",\n \"extra-large\": \"gridui-u-button--[--gridui-button-icon-size:var(--gridui-space-48)]\",\n },\n },\n defaultVariants: { iconSize: \"standard\" },\n});\n\nexport const buttonStartRegionStyles = cva(\"\", {\n variants: {\n divided: {\n true: \"gridui-button-start-region gridui-u-button--justify-center gridui-u-button--self-stretch gridui-u-button--py-gridui-8\",\n false: \"gridui-button-content\",\n },\n size: {\n small: \"\",\n standard: \"\",\n large: \"\",\n \"extra-large\": \"\",\n },\n },\n compoundVariants: [\n {\n divided: true,\n size: \"small\",\n className: \"gridui-u-button--w-gridui-control-small\",\n },\n {\n divided: true,\n size: \"standard\",\n className: \"gridui-u-button--w-gridui-control\",\n },\n {\n divided: true,\n size: \"large\",\n className: \"gridui-u-button--w-gridui-control-large\",\n },\n {\n divided: true,\n size: \"extra-large\",\n className: \"gridui-u-button--w-gridui-64\",\n },\n ],\n defaultVariants: {\n divided: false,\n size: \"standard\",\n },\n});\n\nexport const buttonEndRegionStyles = cva(\"\", {\n variants: {\n divided: {\n true: \"gridui-button-end-region gridui-u-button--justify-center gridui-u-button--self-stretch\",\n false: \"gridui-button-content\",\n },\n size: {\n small: \"\",\n standard: \"\",\n large: \"\",\n \"extra-large\": \"\",\n },\n },\n compoundVariants: [\n {\n divided: true,\n size: \"small\",\n className: \"gridui-u-button--w-gridui-control-small\",\n },\n {\n divided: true,\n size: \"standard\",\n className: \"gridui-u-button--w-gridui-control\",\n },\n {\n divided: true,\n size: \"large\",\n className: \"gridui-u-button--w-gridui-control-large\",\n },\n {\n divided: true,\n size: \"extra-large\",\n className: \"gridui-u-button--w-gridui-64\",\n },\n ],\n defaultVariants: {\n divided: false,\n size: \"standard\",\n },\n});\n\nexport const buttonEndIconStyles = cva(\"gridui-u-button--inline-flex\", {\n variants: {\n divided: {\n true: \"gridui-button-content\",\n false: \"\",\n },\n iconMotion: {\n none: \"\",\n outward: \"gridui-button-end-icon\",\n },\n },\n});\n\nexport const buttonVariants = cva(buttonStyles(), {\n variants: {\n variant: {\n primary: buttonPrimaryStyles(),\n secondary: buttonSecondaryStyles(),\n quiet: buttonQuietStyles(),\n highlight: buttonHighlightStyles(),\n text: buttonTextStyles(),\n underlined: buttonUnderlinedStyles(),\n },\n size: {\n small: buttonSmallStyles(),\n standard: buttonStandardStyles(),\n large: buttonLargeStyles(),\n \"extra-large\": buttonExtraLargeStyles(),\n },\n layout: {\n standard: \"\",\n icon: buttonIconStyles(),\n entry: buttonEntryStyles(),\n cell: buttonCellStyles(),\n rail: buttonRailStyles(),\n divided: buttonDividedStyles(),\n },\n iconMotion: {\n none: \"\",\n outward: \"gridui-button-icon-motion-outward\",\n },\n },\n compoundVariants: [\n {\n variant: [\n \"text\",\n \"underlined\",\n ],\n className: \"gridui-u-button--px-0\",\n },\n {\n variant: [\n \"text\",\n \"underlined\",\n ],\n size: [\n \"large\",\n \"extra-large\",\n ],\n className: \"gridui-u-button--gap-gridui-32 gridui-u-button--type-supporting\",\n },\n ],\n defaultVariants: {\n variant: \"primary\",\n size: \"standard\",\n },\n});\n\ntype ButtonStyleVariants = VariantProps<typeof buttonVariants>;\n\nexport type ButtonVariants = Omit<ButtonStyleVariants, \"variant\" | \"layout\"> & (\n | {\n readonly variant: \"text\" | \"underlined\";\n readonly layout?: \"standard\" | null | undefined;\n }\n | {\n readonly variant?: Exclude<ButtonStyleVariants[\"variant\"], \"text\" | \"underlined\">;\n readonly layout?: ButtonStyleVariants[\"layout\"];\n }\n);\n\nexport const buttonClass = (variants: ButtonVariants = {}, className?: string): string => {\n return cn(buttonVariants({\n variant: variants.variant,\n size: variants.size,\n layout: variants.layout,\n iconMotion: variants.iconMotion,\n }), className);\n};\n", "/**\n * @author WMXPY\n * @package Button\n * @namespace Shared\n * @description Content\n */\n\nimport { buttonEndIconStyles, buttonEndRegionStyles, buttonLabelStyles, buttonStartIconStyles, buttonStartRegionStyles, type ButtonVariants } from \"./style\";\nimport type { ButtonAdornmentProps } from \"./types\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { FC, ReactNode } from \"react\";\n\nexport type ButtonContentProps = ButtonAdornmentProps & {\n readonly children?: ReactNode;\n readonly layout?: ButtonVariants[\"layout\"];\n readonly size?: ButtonVariants[\"size\"];\n readonly iconMotion?: ButtonVariants[\"iconMotion\"];\n};\n\nexport const ButtonContent: FC<ButtonContentProps> = (props: ButtonContentProps) => {\n const { children, startIcon, startIconLayout, startIconSize, endIcon, layout, size, iconMotion } = props;\n const dividedStart = layout === \"divided\" && startIconLayout === \"divided\";\n const startAdornment = startIcon !== undefined && startIcon !== null && typeof startIcon !== \"boolean\" ? (<span\n className={cn(\n buttonStartIconStyles({ iconSize: startIconSize }),\n buttonStartRegionStyles({\n divided: dividedStart,\n size,\n }),\n )}\n data-gridui-part=\"icon\"\n data-gridui-draw=\"graphic\"\n aria-hidden=\"true\"\n inert\n >\n {dividedStart ? (<span\n className=\"gridui-button-content gridui-u-button--inline-flex\"\n >\n {startIcon}\n </span>) : startIcon}\n </span>) : null;\n const label = (<>\n {!dividedStart && startAdornment}\n <span\n className=\"gridui-button-label-content\"\n data-gridui-part=\"label\"\n data-gridui-draw={layout === \"icon\" ? \"graphic\" : \"text\"}\n >\n {children}\n </span>\n </>);\n\n return (<>\n {dividedStart && startAdornment}\n <span\n className={cn(buttonLabelStyles({\n divided: layout === \"divided\",\n size,\n }))}\n data-gridui-part=\"content\"\n data-gridui-draw=\"group\"\n >\n {label}\n </span>\n {endIcon !== undefined && endIcon !== null && typeof endIcon !== \"boolean\" && (<span\n className={cn(\n \"gridui-button-adornment gridui-u-button--inline-flex gridui-u-button--shrink-0 gridui-u-button--items-center gridui-u-button--pointer-events-none\",\n buttonEndRegionStyles({\n divided: layout === \"divided\",\n size,\n }),\n )}\n data-gridui-part=\"icon\"\n data-gridui-draw=\"graphic\"\n aria-hidden=\"true\"\n inert\n >\n {layout === \"divided\" || iconMotion === \"outward\" ? (<span\n className={cn(buttonEndIconStyles({\n divided: layout === \"divided\",\n iconMotion,\n }))}\n >\n {endIcon}\n </span>) : endIcon}\n </span>)}\n </>);\n};\n", "/**\n * @author WMXPY\n * @package Button\n * @namespace Shared\n * @description Group Context\n */\n\nimport { createContext } from \"react\";\n\nexport type ButtonGroupLayout = \"standard\" | \"cells\";\nexport const ButtonGroupContext = createContext<ButtonGroupLayout | undefined>(undefined);\n", "/**\n * @author WMXPY\n * @package Button\n * @namespace Button\n * @description Button\n */\n\nimport { ButtonContent } from \"../shared/content\";\nimport { ButtonGroupContext } from \"../shared/group-context\";\nimport { buttonClass, type ButtonVariants } from \"../shared/style\";\nimport type { ButtonAdornmentProps } from \"../shared/types\";\nimport { type ComponentPropsWithRef, type FC, useContext, useImperativeHandle, useLayoutEffect, useRef } from \"react\";\n\nexport type ButtonProps = ComponentPropsWithRef<\"button\"> & ButtonVariants & ButtonAdornmentProps & {\n readonly loading?: boolean;\n};\n\nexport const Button: FC<ButtonProps> = (props: ButtonProps) => {\n const {\n variant,\n size,\n layout,\n iconMotion,\n loading = false,\n disabled,\n ref: forwardedRef,\n onClick,\n onClickCapture,\n type = \"button\",\n className,\n children,\n startIcon,\n startIconLayout = \"inline\",\n startIconSize = \"standard\",\n endIcon,\n ...restProps\n } = props;\n const button = useRef<HTMLButtonElement>(null);\n useImperativeHandle(forwardedRef, () => {\n return button.current!;\n }, []);\n const unavailable = disabled || restProps[\"aria-disabled\"] === true || restProps[\"aria-disabled\"] === \"true\";\n const busy = loading && !unavailable;\n useLayoutEffect(() => {\n const element = button.current;\n const form = element?.form;\n if (!loading || type !== \"submit\" || !form) {\n return;\n }\n const preventBusySubmit = (event: SubmitEvent) => {\n if (event.submitter === element) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n form.addEventListener(\"submit\", preventBusySubmit, true);\n return () => {\n form.removeEventListener(\"submit\", preventBusySubmit, true);\n };\n });\n const groupLayout = useContext(ButtonGroupContext);\n const variants: ButtonVariants = (variant === \"text\" || variant === \"underlined\") ? {\n variant,\n size,\n layout: \"standard\",\n iconMotion,\n } : {\n variant,\n size,\n layout,\n iconMotion,\n };\n let drawing = \"surface\";\n if (variant === \"underlined\") {\n drawing = \"atomic\";\n } else if (variant === \"text\" || variant === \"quiet\") {\n drawing = \"group\";\n }\n return (<button\n {...restProps}\n data-gridui-component=\"button\"\n data-gridui-draw={drawing}\n data-gridui-button-group-item={groupLayout}\n type={type}\n ref={button}\n disabled={disabled}\n aria-disabled={loading || restProps[\"aria-disabled\"]}\n data-gridui-busy={busy || undefined}\n onClickCapture={(event) => {\n if (loading || unavailable) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n onClickCapture?.(event);\n }}\n onClick={(event) => {\n if (loading || unavailable) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n onClick?.(event);\n }}\n aria-busy={loading || restProps[\"aria-busy\"]}\n className={buttonClass(variants, className)}\n >\n <ButtonContent\n layout={variants.layout}\n size={size}\n iconMotion={iconMotion}\n startIcon={startIcon}\n startIconLayout={startIconLayout}\n startIconSize={startIconSize}\n endIcon={endIcon}\n >\n {children}\n </ButtonContent>\n </button>);\n};\n", "/**\n * @author WMXPY\n * @package Button\n * @namespace ButtonGroup\n * @description Button Group\n */\n\nimport { ButtonGroupContext, type ButtonGroupLayout } from \"../shared/group-context\";\nimport { cn } from \"@gridui/style-utils\";\nimport type { ComponentPropsWithRef, FC } from \"react\";\n\nexport type ButtonGroupProps = ComponentPropsWithRef<\"div\"> & {\n readonly layout?: ButtonGroupLayout;\n};\n\nexport const ButtonGroup: FC<ButtonGroupProps> = (props: ButtonGroupProps) => {\n const { layout = \"standard\", className, children, role = \"group\", ...restProps } = props;\n return (<ButtonGroupContext\n value={layout}\n >\n <div\n {...restProps}\n role={role}\n data-layout={layout}\n className={cn(\"gridui-button-group\", className)}\n >\n <div\n className=\"gridui-button-group-items\"\n data-layout={layout}\n >\n {children}\n </div>\n </div>\n </ButtonGroupContext>);\n};\n", "/**\n * @author WMXPY\n * @package Button\n * @namespace ButtonLink\n * @description Button Link\n */\n\nimport { ButtonContent } from \"../shared/content\";\nimport { ButtonGroupContext } from \"../shared/group-context\";\nimport { buttonClass, type ButtonVariants } from \"../shared/style\";\nimport type { ButtonAdornmentProps } from \"../shared/types\";\nimport { type ComponentPropsWithRef, type FC, useContext } from \"react\";\n\nexport type ButtonLinkProps = ComponentPropsWithRef<\"a\"> & ButtonVariants & ButtonAdornmentProps & {\n readonly href: string;\n};\n\nexport const ButtonLink: FC<ButtonLinkProps> = (props: ButtonLinkProps) => {\n const {\n variant = \"secondary\",\n size,\n layout,\n iconMotion,\n className,\n children,\n startIcon,\n startIconLayout = \"inline\",\n startIconSize = \"standard\",\n endIcon,\n ...restProps\n } = props;\n const groupLayout = useContext(ButtonGroupContext);\n const variants: ButtonVariants = (variant === \"text\" || variant === \"underlined\") ? {\n variant,\n size,\n layout: \"standard\",\n iconMotion,\n } : {\n variant,\n size,\n layout,\n iconMotion,\n };\n let drawing = \"surface\";\n if (variant === \"underlined\") {\n drawing = \"atomic\";\n } else if (variant === \"text\" || variant === \"quiet\") {\n drawing = \"group\";\n }\n return (<a\n {...restProps}\n data-gridui-component=\"button-link\"\n data-gridui-draw={drawing}\n data-gridui-button-group-item={groupLayout}\n className={buttonClass(variants, className)}\n >\n <ButtonContent\n layout={variants.layout}\n size={size}\n iconMotion={iconMotion}\n startIcon={startIcon}\n startIconLayout={startIconLayout}\n startIconSize={startIconSize}\n endIcon={endIcon}\n >\n {children}\n </ButtonContent>\n </a>);\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,QAAQ,gBAAgB;AAI1B,IAAM,qBAAqB,OAAO,EAAE,QAAQ,SAAS,gBAAgB,MAIvD;AACjB,kBAAgB,IAAI;AACpB,MAAI;AACA,UAAM,UAAU;AAChB,UAAM,IAAI,QAAc,CAAC,YAAY;AACjC,iBAAW,SAAS,CAAC;AAAA,IACzB,CAAC;AACD,UAAM,OAAO;AAAA,EACjB,UAAE;AACE,oBAAgB,KAAK;AAAA,EACzB;AACJ;AAEO,IAAM,iBAAiB,CAAC,EAAE,QAAQ,SAAS,WAAW,MAAM,MAI7D;AACF,QAAM;AAAA,IACF;AAAA,IACA;AAAA,EACJ,IAAI,SAAS,KAAK;AAClB,QAAM,SAAS,OAAO,KAAK;AAC3B,SAAO;AAAA,IACH;AAAA,IACA,MAAM,MAAqB;AACvB,UAAI,YAAY,OAAO,SAAS;AAC5B;AAAA,MACJ;AACA,aAAO,UAAU;AACjB,UAAI;AACA,cAAM,mBAAmB;AAAA,UACrB;AAAA,UACA,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;AAAA,UAC7B,iBAAiB;AAAA,QACrB,CAAC;AAAA,MACL,UAAE;AACE,eAAO,UAAU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YAAC;AAAA;AAAA,cACG,WAAU;AAAA,cACV,eAAa;AAAA,cAEZ;AAAA;AAAA,UACL;AAAA;AAAA,MACJ;AAAA;AAAA,EACJ;AACJ;;;ACvBA,SAA8C,cAAAC,mBAAkB;AA6CxD,gBAAAC,YAAA;AAvCD,IAAM,aAAkC,CAAC,UAA2B;AACvE,QAAM;AAAA,IACF,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB;AAAA,IACA,GAAG;AAAA,EACP,IAAI;AACJ,QAAM,cAAcD,YAAW,kBAAkB;AACjD,QAAM,WAA4B,YAAY,UAAU,YAAY,eAAgB;AAAA,IAChF;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,EACJ,IAAI;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACA,MAAI,UAAU;AACd,MAAI,YAAY,cAAc;AAC1B,cAAU;AAAA,EACd,WAAW,YAAY,UAAU,YAAY,SAAS;AAClD,cAAU;AAAA,EACd;AACA,SAAQ,gBAAAC;AAAA,IAAC;AAAA;AAAA,MACJ,GAAG;AAAA,MACJ,yBAAsB;AAAA,MACtB,oBAAkB;AAAA,MAClB,iCAA+B;AAAA,MAC/B,WAAW,YAAY,UAAU,SAAS;AAAA,MAE1C,0BAAAA;AAAA,QAAC;AAAA;AAAA,UACG,QAAQ,SAAS;AAAA,UACjB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UAEC;AAAA;AAAA,MACL;AAAA;AAAA,EACJ;AACJ;",
|
|
6
|
+
"names": ["cn", "useRef", "jsx", "cn", "jsx", "useContext", "jsx"]
|
|
7
7
|
}
|
package/dist/shared/style.d.ts
CHANGED
|
@@ -22,21 +22,28 @@ export declare const buttonRailStyles: (props?: import("class-variance-authority
|
|
|
22
22
|
export declare const buttonIconStyles: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
23
23
|
export declare const buttonDividedStyles: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
24
24
|
export declare const buttonLabelStyles: (props?: ({
|
|
25
|
+
divided?: boolean | null | undefined;
|
|
25
26
|
size?: "small" | "standard" | "large" | "extra-large" | null | undefined;
|
|
26
27
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
27
28
|
export declare const buttonStartIconStyles: (props?: ({
|
|
28
29
|
iconSize?: "standard" | "large" | "extra-large" | null | undefined;
|
|
29
30
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
30
31
|
export declare const buttonStartRegionStyles: (props?: ({
|
|
32
|
+
divided?: boolean | null | undefined;
|
|
31
33
|
size?: "small" | "standard" | "large" | "extra-large" | null | undefined;
|
|
32
34
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
33
35
|
export declare const buttonEndRegionStyles: (props?: ({
|
|
36
|
+
divided?: boolean | null | undefined;
|
|
34
37
|
size?: "small" | "standard" | "large" | "extra-large" | null | undefined;
|
|
35
38
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
39
|
+
export declare const buttonEndIconStyles: (props?: ({
|
|
40
|
+
divided?: boolean | null | undefined;
|
|
41
|
+
iconMotion?: "none" | "outward" | null | undefined;
|
|
42
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
36
43
|
export declare const buttonVariants: (props?: ({
|
|
37
44
|
variant?: "primary" | "secondary" | "quiet" | "highlight" | "text" | "underlined" | null | undefined;
|
|
38
45
|
size?: "small" | "standard" | "large" | "extra-large" | null | undefined;
|
|
39
|
-
layout?: "standard" | "icon" | "entry" | "cell" | "rail" |
|
|
46
|
+
layout?: "divided" | "standard" | "icon" | "entry" | "cell" | "rail" | null | undefined;
|
|
40
47
|
iconMotion?: "none" | "outward" | null | undefined;
|
|
41
48
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
42
49
|
type ButtonStyleVariants = VariantProps<typeof buttonVariants>;
|
package/dist/styles.css
CHANGED
|
@@ -218,6 +218,9 @@
|
|
|
218
218
|
.gridui-u-button--data-disabled\:cursor-not-allowed[data-disabled] {
|
|
219
219
|
cursor: not-allowed;
|
|
220
220
|
}
|
|
221
|
+
.gridui-u-button--data-gridui-busy\:cursor-wait[data-gridui-busy] {
|
|
222
|
+
cursor: wait;
|
|
223
|
+
}
|
|
221
224
|
@media (prefers-reduced-motion: reduce) {
|
|
222
225
|
.gridui-u-button--motion-reduce\:transition-none {
|
|
223
226
|
transition-property: none;
|
|
@@ -292,7 +295,7 @@
|
|
|
292
295
|
justify-content: inherit;
|
|
293
296
|
gap: inherit;
|
|
294
297
|
}
|
|
295
|
-
.gridui-button:is(:disabled, [aria-disabled="true"], [data-disabled]) > .gridui-button-content, .gridui-button:is(:disabled, [aria-disabled="true"], [data-disabled]) > .gridui-button-start-region > .gridui-button-content, .gridui-button:is(:disabled, [aria-disabled="true"], [data-disabled]) > .gridui-button-end-region > .gridui-button-content {
|
|
298
|
+
.gridui-button:is(:disabled, [aria-disabled="true"]:not([data-gridui-busy]), [data-disabled]) > .gridui-button-content, .gridui-button:is(:disabled, [aria-disabled="true"]:not([data-gridui-busy]), [data-disabled]) > .gridui-button-start-region > .gridui-button-content, .gridui-button:is(:disabled, [aria-disabled="true"]:not([data-gridui-busy]), [data-disabled]) > .gridui-button-end-region > .gridui-button-content {
|
|
296
299
|
opacity: 0.5;
|
|
297
300
|
}
|
|
298
301
|
.gridui-button-start-region {
|
|
@@ -305,16 +308,65 @@
|
|
|
305
308
|
border-color: inherit;
|
|
306
309
|
}
|
|
307
310
|
@media (prefers-reduced-motion: no-preference) {
|
|
308
|
-
.gridui-button-icon-motion-outward:not(:disabled, [aria-disabled="true"], [data-disabled], [aria-readonly="true"], [data-readonly], [readonly]) .gridui-button-end-icon {
|
|
311
|
+
.gridui-button-icon-motion-outward:not(:disabled, [aria-disabled="true"]:not([data-gridui-busy]), [data-disabled], [aria-readonly="true"], [data-readonly], [readonly]) .gridui-button-end-icon {
|
|
309
312
|
transition: transform var(--gridui-motion-duration-quick) var(--gridui-motion-ease-out);
|
|
310
313
|
}
|
|
311
|
-
.gridui-button-icon-motion-outward:not(:disabled, [aria-disabled="true"], [data-disabled], [aria-readonly="true"], [data-readonly], [readonly]):hover .gridui-button-end-icon {
|
|
314
|
+
.gridui-button-icon-motion-outward:not(:disabled, [aria-disabled="true"]:not([data-gridui-busy]), [data-disabled], [aria-readonly="true"], [data-readonly], [readonly]):hover .gridui-button-end-icon {
|
|
312
315
|
transform: translate(var(--gridui-space-4), calc(-1 * var(--gridui-space-4)));
|
|
313
316
|
}
|
|
314
|
-
.gridui-button-icon-motion-outward:not(:disabled, [aria-disabled="true"], [data-disabled], [aria-readonly="true"], [data-readonly], [readonly]):dir(rtl):hover .gridui-button-end-icon {
|
|
317
|
+
.gridui-button-icon-motion-outward:not(:disabled, [aria-disabled="true"]:not([data-gridui-busy]), [data-disabled], [aria-readonly="true"], [data-readonly], [readonly]):dir(rtl):hover .gridui-button-end-icon {
|
|
315
318
|
transform: translate(calc(-1 * var(--gridui-space-4)), calc(-1 * var(--gridui-space-4)));
|
|
316
319
|
}
|
|
317
320
|
}
|
|
321
|
+
.gridui-button-group {
|
|
322
|
+
--gridui-button-group-padding-block: var(--gridui-space-24);
|
|
323
|
+
container: gridui-button-group / inline-size;
|
|
324
|
+
min-width: 0;
|
|
325
|
+
}
|
|
326
|
+
.gridui-button-group-items {
|
|
327
|
+
display: grid;
|
|
328
|
+
grid-auto-flow: column;
|
|
329
|
+
grid-auto-columns: minmax(0, 1fr);
|
|
330
|
+
align-items: stretch;
|
|
331
|
+
}
|
|
332
|
+
.gridui-button-group-items[data-layout="standard"] {
|
|
333
|
+
gap: var(--gridui-space-8);
|
|
334
|
+
}
|
|
335
|
+
.gridui-button-group-items[data-layout="cells"] > [data-gridui-button-group-item]:not([hidden]) ~ [data-gridui-button-group-item]:not([hidden])::before {
|
|
336
|
+
position: absolute;
|
|
337
|
+
inset-block: 0;
|
|
338
|
+
inset-inline-start: 0;
|
|
339
|
+
width: 1px;
|
|
340
|
+
background: var(--gridui-button-group-border, var(--gridui-border));
|
|
341
|
+
pointer-events: none;
|
|
342
|
+
content: "";
|
|
343
|
+
}
|
|
344
|
+
@container gridui-button-group (max-width: 20rem) {
|
|
345
|
+
.gridui-button-group-items {
|
|
346
|
+
grid-auto-flow: row;
|
|
347
|
+
grid-auto-rows: 1fr;
|
|
348
|
+
}
|
|
349
|
+
.gridui-button-group-items[data-layout="cells"] > [data-gridui-button-group-item]:not([hidden]) ~ [data-gridui-button-group-item]:not([hidden])::before {
|
|
350
|
+
inset-block: 0 auto;
|
|
351
|
+
inset-inline: 0;
|
|
352
|
+
width: auto;
|
|
353
|
+
height: 1px;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
@layer utilities {
|
|
358
|
+
.gridui-button-group-items > [data-gridui-button-group-item] {
|
|
359
|
+
position: relative;
|
|
360
|
+
width: 100%;
|
|
361
|
+
height: 100%;
|
|
362
|
+
min-width: 0;
|
|
363
|
+
}
|
|
364
|
+
.gridui-button-group-items[data-layout="cells"] > [data-gridui-button-group-item] {
|
|
365
|
+
min-height: 2.75rem;
|
|
366
|
+
padding: var(--gridui-button-group-padding-block) var(--gridui-space-24);
|
|
367
|
+
border: 0;
|
|
368
|
+
border-radius: 0;
|
|
369
|
+
}
|
|
318
370
|
}
|
|
319
371
|
@property --tw-border-style {
|
|
320
372
|
syntax: "*";
|
package/docs/catalog.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "@gridui/button",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.1",
|
|
5
5
|
"category": "core",
|
|
6
6
|
"description": "GridUI React buttons and action helpers",
|
|
7
|
-
"usage": "`@gridui/button` owns native buttons, button-styled links, shared button classes, and async action scheduling. It has no domain, route, locale, or Layout dependency. Load `@gridui/button/styles.css` after the theme styles.",
|
|
7
|
+
"usage": "`@gridui/button` owns native buttons, button-styled links, shared button classes, ButtonGroup layouts, and async action scheduling. It has no domain, route, locale, or Layout dependency. Load `@gridui/button/styles.css` after the theme styles.",
|
|
8
8
|
"documentation": [
|
|
9
9
|
"README.md",
|
|
10
10
|
"docs/reference/README.md",
|
|
11
|
+
"docs/reference/button-group.md",
|
|
11
12
|
"docs/reference/button-link.md",
|
|
12
13
|
"docs/reference/button.md"
|
|
13
14
|
],
|
|
@@ -22,6 +23,16 @@
|
|
|
22
23
|
"kind": "function",
|
|
23
24
|
"importPath": "@gridui/button"
|
|
24
25
|
},
|
|
26
|
+
{
|
|
27
|
+
"name": "ButtonGroup",
|
|
28
|
+
"kind": "component",
|
|
29
|
+
"importPath": "@gridui/button"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "ButtonGroupProps",
|
|
33
|
+
"kind": "type",
|
|
34
|
+
"importPath": "@gridui/button"
|
|
35
|
+
},
|
|
25
36
|
{
|
|
26
37
|
"name": "ButtonLink",
|
|
27
38
|
"kind": "component",
|
|
@@ -55,8 +66,11 @@
|
|
|
55
66
|
"examples": [
|
|
56
67
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/actions.mdx",
|
|
57
68
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/async-actions.mdx",
|
|
69
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/button-groups.mdx",
|
|
58
70
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/full-width-actions.mdx",
|
|
71
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/getting-started.mdx",
|
|
59
72
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/navigation.mdx",
|
|
73
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/button-group.stories.tsx",
|
|
60
74
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/button-link.stories.tsx",
|
|
61
75
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/button.stories.tsx"
|
|
62
76
|
]
|
package/docs/reference/README.md
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# ButtonGroup
|
|
3
|
+
|
|
4
|
+
Arranges independent actions with shared height, responsive columns, and optional cell separators. Each action retains native keyboard and activation behavior.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/button`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { ButtonGroup } from "@gridui/button";
|
|
10
|
+
import "@gridui/theme/styles.css";
|
|
11
|
+
import "@gridui/button/styles.css";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Read the [package contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/README.md) for shared behavior and stylesheet dependencies.
|
|
15
|
+
|
|
16
|
+
The [working composition](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/button-group.stories.tsx) demonstrates required context, state, and related components. Use View code in Storybook to inspect the actual implementation.
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
The public Props type is the source of these signatures. Defaults below are explicit implementation defaults; story presets are separate. Native attributes remain available through the exported Props type.
|
|
21
|
+
|
|
22
|
+
### role
|
|
23
|
+
|
|
24
|
+
``AriaRole | undefined`` · Optional
|
|
25
|
+
|
|
26
|
+
Default: ``"group"``
|
|
27
|
+
|
|
28
|
+
### children
|
|
29
|
+
|
|
30
|
+
``ReactNode`` · Optional
|
|
31
|
+
|
|
32
|
+
Content rendered inside the component.
|
|
33
|
+
|
|
34
|
+
### onFocus
|
|
35
|
+
|
|
36
|
+
``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
|
|
37
|
+
|
|
38
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
39
|
+
|
|
40
|
+
### onBlur
|
|
41
|
+
|
|
42
|
+
``(event: FocusEvent<HTMLDivElement, Element>): void`` · Optional
|
|
43
|
+
|
|
44
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
|
+
|
|
46
|
+
### onChange
|
|
47
|
+
|
|
48
|
+
``(event: ChangeEvent<HTMLDivElement, Element>): void`` · Optional
|
|
49
|
+
|
|
50
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
51
|
+
|
|
52
|
+
### onSubmit
|
|
53
|
+
|
|
54
|
+
``(event: SubmitEvent<HTMLDivElement>): void`` · Optional
|
|
55
|
+
|
|
56
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
57
|
+
|
|
58
|
+
### onClick
|
|
59
|
+
|
|
60
|
+
``(event: MouseEvent<HTMLDivElement, MouseEvent>): void`` · Optional
|
|
61
|
+
|
|
62
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
63
|
+
|
|
64
|
+
### layout
|
|
65
|
+
|
|
66
|
+
``ButtonGroupLayout | undefined`` · Optional
|
|
67
|
+
|
|
68
|
+
Default: ``"standard"``
|
|
69
|
+
|
|
70
|
+
Layout within the containing region.
|
|
71
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/button",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "GridUI React buttons and action helpers",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@gridui/style-utils": "^4.0.0",
|
|
27
|
-
"@gridui/theme": "^2.
|
|
27
|
+
"@gridui/theme": "^2.6.0",
|
|
28
28
|
"class-variance-authority": "0.7.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@gridui-internal/configuration": "0.0.0-internal",
|
|
32
32
|
"@jest/globals": "30.5.2",
|
|
33
|
-
"@storybook/react-vite": "10.6.
|
|
33
|
+
"@storybook/react-vite": "10.6.7",
|
|
34
34
|
"@types/jest": "30.0.0",
|
|
35
35
|
"@types/node": "26.6.6",
|
|
36
36
|
"@types/react": "19.3.0",
|
|
37
37
|
"@types/react-dom": "19.3.0",
|
|
38
38
|
"jest": "30.5.2",
|
|
39
|
-
"lucide-react": "1.
|
|
39
|
+
"lucide-react": "1.72.0",
|
|
40
40
|
"react": "19.3.1",
|
|
41
41
|
"react-dom": "19.3.1",
|
|
42
42
|
"typescript": "6.0.3"
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "node ../../scripts/compilation/package.ts",
|
|
50
50
|
"compile": "tsc --project tsconfig.json",
|
|
51
|
-
"test": "jest"
|
|
52
|
-
"coverage": "jest --coverage"
|
|
51
|
+
"test": "jest"
|
|
53
52
|
}
|
|
54
53
|
}
|