@gridui/button 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -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 +122 -5
- package/dist/index.js.map +4 -4
- package/dist/shared/group-context.d.ts +8 -0
- package/dist/styles.css +64 -4
- package/docs/catalog.json +24 -3
- package/docs/reference/README.md +6 -0
- package/docs/reference/button-group.md +71 -0
- package/docs/reference/button-link.md +107 -0
- package/docs/reference/button.md +115 -0
- package/package.json +3 -3
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.
|
|
@@ -180,3 +186,31 @@ icon slots, long labels, loading, and the existing variants. Divided-layout brow
|
|
|
180
186
|
checks cover one-action hit areas, native keyboard activation, busy-state
|
|
181
187
|
transitions, RTL seams and motion, long labels at text zoom, and the
|
|
182
188
|
viewport/theme/reduced-motion matrix.
|
|
189
|
+
|
|
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(
|
|
@@ -240,6 +241,8 @@ var ButtonContent = (props) => {
|
|
|
240
241
|
buttonStartIconStyles({ iconSize: startIconSize }),
|
|
241
242
|
dividedStart ? buttonStartRegionStyles({ size }) : "gridui-button-content"
|
|
242
243
|
),
|
|
244
|
+
"data-gridui-part": "icon",
|
|
245
|
+
"data-gridui-draw": "graphic",
|
|
243
246
|
"aria-hidden": "true",
|
|
244
247
|
inert: true,
|
|
245
248
|
children: dividedStart ? /* @__PURE__ */ jsx(
|
|
@@ -253,7 +256,15 @@ var ButtonContent = (props) => {
|
|
|
253
256
|
) : null;
|
|
254
257
|
const label = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
255
258
|
!dividedStart && startAdornment,
|
|
256
|
-
|
|
259
|
+
/* @__PURE__ */ jsx(
|
|
260
|
+
"span",
|
|
261
|
+
{
|
|
262
|
+
className: "gridui-button-label-content",
|
|
263
|
+
"data-gridui-part": "label",
|
|
264
|
+
"data-gridui-draw": layout === "icon" ? "graphic" : "text",
|
|
265
|
+
children
|
|
266
|
+
}
|
|
267
|
+
)
|
|
257
268
|
] });
|
|
258
269
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
259
270
|
dividedStart && startAdornment,
|
|
@@ -261,6 +272,8 @@ var ButtonContent = (props) => {
|
|
|
261
272
|
"span",
|
|
262
273
|
{
|
|
263
274
|
className: cn2("gridui-button-content", layout === "divided" ? buttonLabelStyles({ size }) : "gridui-button-body"),
|
|
275
|
+
"data-gridui-part": "content",
|
|
276
|
+
"data-gridui-draw": "group",
|
|
264
277
|
children: label
|
|
265
278
|
}
|
|
266
279
|
),
|
|
@@ -271,6 +284,8 @@ var ButtonContent = (props) => {
|
|
|
271
284
|
"gridui-button-adornment gridui-u-button--inline-flex gridui-u-button--shrink-0 gridui-u-button--items-center gridui-u-button--pointer-events-none",
|
|
272
285
|
layout === "divided" ? buttonEndRegionStyles({ size }) : "gridui-button-content"
|
|
273
286
|
),
|
|
287
|
+
"data-gridui-part": "icon",
|
|
288
|
+
"data-gridui-draw": "graphic",
|
|
274
289
|
"aria-hidden": "true",
|
|
275
290
|
inert: true,
|
|
276
291
|
children: layout === "divided" || iconMotion === "outward" ? /* @__PURE__ */ jsx(
|
|
@@ -285,7 +300,12 @@ var ButtonContent = (props) => {
|
|
|
285
300
|
] });
|
|
286
301
|
};
|
|
287
302
|
|
|
303
|
+
// src/shared/group-context.ts
|
|
304
|
+
import { createContext } from "react";
|
|
305
|
+
var ButtonGroupContext = createContext(void 0);
|
|
306
|
+
|
|
288
307
|
// src/button/button.tsx
|
|
308
|
+
import { useContext, useImperativeHandle, useLayoutEffect, useRef as useRef2 } from "react";
|
|
289
309
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
290
310
|
var Button = (props) => {
|
|
291
311
|
const {
|
|
@@ -295,6 +315,9 @@ var Button = (props) => {
|
|
|
295
315
|
iconMotion,
|
|
296
316
|
loading = false,
|
|
297
317
|
disabled,
|
|
318
|
+
ref: forwardedRef,
|
|
319
|
+
onClick,
|
|
320
|
+
onClickCapture,
|
|
298
321
|
type = "button",
|
|
299
322
|
className,
|
|
300
323
|
children,
|
|
@@ -304,6 +327,30 @@ var Button = (props) => {
|
|
|
304
327
|
endIcon,
|
|
305
328
|
...restProps
|
|
306
329
|
} = props;
|
|
330
|
+
const button = useRef2(null);
|
|
331
|
+
useImperativeHandle(forwardedRef, () => {
|
|
332
|
+
return button.current;
|
|
333
|
+
}, []);
|
|
334
|
+
const unavailable = disabled || restProps["aria-disabled"] === true || restProps["aria-disabled"] === "true";
|
|
335
|
+
const busy = loading && !unavailable;
|
|
336
|
+
useLayoutEffect(() => {
|
|
337
|
+
const element = button.current;
|
|
338
|
+
const form = element?.form;
|
|
339
|
+
if (!loading || type !== "submit" || !form) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const preventBusySubmit = (event) => {
|
|
343
|
+
if (event.submitter === element) {
|
|
344
|
+
event.preventDefault();
|
|
345
|
+
event.stopImmediatePropagation();
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
form.addEventListener("submit", preventBusySubmit, true);
|
|
349
|
+
return () => {
|
|
350
|
+
form.removeEventListener("submit", preventBusySubmit, true);
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
const groupLayout = useContext(ButtonGroupContext);
|
|
307
354
|
const variants = variant === "text" || variant === "underlined" ? {
|
|
308
355
|
variant,
|
|
309
356
|
size,
|
|
@@ -315,12 +362,40 @@ var Button = (props) => {
|
|
|
315
362
|
layout,
|
|
316
363
|
iconMotion
|
|
317
364
|
};
|
|
365
|
+
let drawing = "surface";
|
|
366
|
+
if (variant === "underlined") {
|
|
367
|
+
drawing = "atomic";
|
|
368
|
+
} else if (variant === "text" || variant === "quiet") {
|
|
369
|
+
drawing = "group";
|
|
370
|
+
}
|
|
318
371
|
return /* @__PURE__ */ jsx2(
|
|
319
372
|
"button",
|
|
320
373
|
{
|
|
321
374
|
...restProps,
|
|
375
|
+
"data-gridui-component": "button",
|
|
376
|
+
"data-gridui-draw": drawing,
|
|
377
|
+
"data-gridui-button-group-item": groupLayout,
|
|
322
378
|
type,
|
|
323
|
-
|
|
379
|
+
ref: button,
|
|
380
|
+
disabled,
|
|
381
|
+
"aria-disabled": loading || restProps["aria-disabled"],
|
|
382
|
+
"data-gridui-busy": busy || void 0,
|
|
383
|
+
onClickCapture: (event) => {
|
|
384
|
+
if (loading || unavailable) {
|
|
385
|
+
event.preventDefault();
|
|
386
|
+
event.stopPropagation();
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
onClickCapture?.(event);
|
|
390
|
+
},
|
|
391
|
+
onClick: (event) => {
|
|
392
|
+
if (loading || unavailable) {
|
|
393
|
+
event.preventDefault();
|
|
394
|
+
event.stopPropagation();
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
onClick?.(event);
|
|
398
|
+
},
|
|
324
399
|
"aria-busy": loading || restProps["aria-busy"],
|
|
325
400
|
className: buttonClass(variants, className),
|
|
326
401
|
children: /* @__PURE__ */ jsx2(
|
|
@@ -340,8 +415,39 @@ var Button = (props) => {
|
|
|
340
415
|
);
|
|
341
416
|
};
|
|
342
417
|
|
|
343
|
-
// src/button-
|
|
418
|
+
// src/button-group/button-group.tsx
|
|
419
|
+
import { cn as cn3 } from "@gridui/style-utils";
|
|
344
420
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
421
|
+
var ButtonGroup = (props) => {
|
|
422
|
+
const { layout = "standard", className, children, role = "group", ...restProps } = props;
|
|
423
|
+
return /* @__PURE__ */ jsx3(
|
|
424
|
+
ButtonGroupContext,
|
|
425
|
+
{
|
|
426
|
+
value: layout,
|
|
427
|
+
children: /* @__PURE__ */ jsx3(
|
|
428
|
+
"div",
|
|
429
|
+
{
|
|
430
|
+
...restProps,
|
|
431
|
+
role,
|
|
432
|
+
"data-layout": layout,
|
|
433
|
+
className: cn3("gridui-button-group", className),
|
|
434
|
+
children: /* @__PURE__ */ jsx3(
|
|
435
|
+
"div",
|
|
436
|
+
{
|
|
437
|
+
className: "gridui-button-group-items",
|
|
438
|
+
"data-layout": layout,
|
|
439
|
+
children
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
}
|
|
443
|
+
)
|
|
444
|
+
}
|
|
445
|
+
);
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// src/button-link/button-link.tsx
|
|
449
|
+
import { useContext as useContext2 } from "react";
|
|
450
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
345
451
|
var ButtonLink = (props) => {
|
|
346
452
|
const {
|
|
347
453
|
variant = "secondary",
|
|
@@ -356,6 +462,7 @@ var ButtonLink = (props) => {
|
|
|
356
462
|
endIcon,
|
|
357
463
|
...restProps
|
|
358
464
|
} = props;
|
|
465
|
+
const groupLayout = useContext2(ButtonGroupContext);
|
|
359
466
|
const variants = variant === "text" || variant === "underlined" ? {
|
|
360
467
|
variant,
|
|
361
468
|
size,
|
|
@@ -367,12 +474,21 @@ var ButtonLink = (props) => {
|
|
|
367
474
|
layout,
|
|
368
475
|
iconMotion
|
|
369
476
|
};
|
|
370
|
-
|
|
477
|
+
let drawing = "surface";
|
|
478
|
+
if (variant === "underlined") {
|
|
479
|
+
drawing = "atomic";
|
|
480
|
+
} else if (variant === "text" || variant === "quiet") {
|
|
481
|
+
drawing = "group";
|
|
482
|
+
}
|
|
483
|
+
return /* @__PURE__ */ jsx4(
|
|
371
484
|
"a",
|
|
372
485
|
{
|
|
373
486
|
...restProps,
|
|
487
|
+
"data-gridui-component": "button-link",
|
|
488
|
+
"data-gridui-draw": drawing,
|
|
489
|
+
"data-gridui-button-group-item": groupLayout,
|
|
374
490
|
className: buttonClass(variants, className),
|
|
375
|
-
children: /* @__PURE__ */
|
|
491
|
+
children: /* @__PURE__ */ jsx4(
|
|
376
492
|
ButtonContent,
|
|
377
493
|
{
|
|
378
494
|
layout: variants.layout,
|
|
@@ -390,6 +506,7 @@ var ButtonLink = (props) => {
|
|
|
390
506
|
};
|
|
391
507
|
export {
|
|
392
508
|
Button,
|
|
509
|
+
ButtonGroup,
|
|
393
510
|
ButtonLink,
|
|
394
511
|
buttonClass,
|
|
395
512
|
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 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 {children}\n </>);\n\n return (<>\n {dividedStart && startAdornment}\n <span\n className={cn(\"gridui-button-content\", layout === \"divided\" ? buttonLabelStyles({ size }) : \"gridui-button-body\")}\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 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 return (<button\n {...restProps}\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 return (<a\n {...restProps}\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,U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OAAO,kBAAkB;AAAA,MACzB,WAAW,sBAAsB;AAAA,MACjC,MAAM,iBAAiB;AAAA,MACvB,YAAY,uBAAuB;AAAA,IACvC;AAAA,IACA,MAAM;AAAA,MACF,OAAO,kBAAkB;AAAA,MACzB,UAAU,qBAAqB;AAAA,MAC/B,OAAO,kBAAkB;AAAA,MACzB,eAAe,uBAAuB;AAAA,IAC1C;AAAA,IACA,QAAQ;AAAA,MACJ,UAAU;AAAA,MACV,MAAM,iBAAiB;AAAA,MACvB,OAAO,kBAAkB;AAAA,MACzB,MAAM,iBAAiB;AAAA,MACvB,MAAM,iBAAiB;AAAA,MACvB,SAAS,oBAAoB;AAAA,IACjC;AAAA,IACA,YAAY;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,IACb;AAAA,EACJ;AAAA,EACA,kBAAkB;AAAA,IACd;AAAA,MACI,SAAS;AAAA,QACL;AAAA,QACA;AAAA,MACJ;AAAA,MACA,MAAM;AAAA,QACF;AAAA,QACA;AAAA,MACJ;AAAA,MACA,WAAW;AAAA,IACf;AAAA,EACJ;AAAA,EACA,iBAAiB;AAAA,IACb,SAAS;AAAA,IACT,MAAM;AAAA,EACV;AACJ,CAAC;AAeM,IAAM,cAAc,CAAC,WAA2B,CAAC,GAAG,cAA+B;AACtF,QAAM,cAAc,SAAS,YAAY,UAAU,SAAS,YAAY;AACxE,SAAO,GAAG,eAAe;AAAA,IACrB,SAAS,SAAS;AAAA,IAClB,MAAM,SAAS;AAAA,IACf,QAAQ,SAAS;AAAA,IACjB,YAAY,SAAS;AAAA,EACzB,CAAC,GAAG,eAAe,yBAAyB,SAAS;AACzD;;;
|
|
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(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 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,KAA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A,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/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;
|
|
@@ -275,6 +278,14 @@
|
|
|
275
278
|
.gridui-button-cell {
|
|
276
279
|
border: 0;
|
|
277
280
|
}
|
|
281
|
+
.gridui-button-label-content {
|
|
282
|
+
display: inline-flex;
|
|
283
|
+
min-width: 0;
|
|
284
|
+
flex-direction: inherit;
|
|
285
|
+
align-items: inherit;
|
|
286
|
+
justify-content: inherit;
|
|
287
|
+
gap: inherit;
|
|
288
|
+
}
|
|
278
289
|
.gridui-button-body {
|
|
279
290
|
display: inline-flex;
|
|
280
291
|
flex: 1;
|
|
@@ -284,7 +295,7 @@
|
|
|
284
295
|
justify-content: inherit;
|
|
285
296
|
gap: inherit;
|
|
286
297
|
}
|
|
287
|
-
.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 {
|
|
288
299
|
opacity: 0.5;
|
|
289
300
|
}
|
|
290
301
|
.gridui-button-start-region {
|
|
@@ -297,16 +308,65 @@
|
|
|
297
308
|
border-color: inherit;
|
|
298
309
|
}
|
|
299
310
|
@media (prefers-reduced-motion: no-preference) {
|
|
300
|
-
.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 {
|
|
301
312
|
transition: transform var(--gridui-motion-duration-quick) var(--gridui-motion-ease-out);
|
|
302
313
|
}
|
|
303
|
-
.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 {
|
|
304
315
|
transform: translate(var(--gridui-space-4), calc(-1 * var(--gridui-space-4)));
|
|
305
316
|
}
|
|
306
|
-
.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 {
|
|
307
318
|
transform: translate(calc(-1 * var(--gridui-space-4)), calc(-1 * var(--gridui-space-4)));
|
|
308
319
|
}
|
|
309
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
|
+
}
|
|
310
370
|
}
|
|
311
371
|
@property --tw-border-style {
|
|
312
372
|
syntax: "*";
|
package/docs/catalog.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "@gridui/button",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0",
|
|
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
|
-
"README.md"
|
|
9
|
+
"README.md",
|
|
10
|
+
"docs/reference/README.md",
|
|
11
|
+
"docs/reference/button-group.md",
|
|
12
|
+
"docs/reference/button-link.md",
|
|
13
|
+
"docs/reference/button.md"
|
|
10
14
|
],
|
|
11
15
|
"exports": [
|
|
12
16
|
{
|
|
@@ -19,6 +23,16 @@
|
|
|
19
23
|
"kind": "function",
|
|
20
24
|
"importPath": "@gridui/button"
|
|
21
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
|
+
},
|
|
22
36
|
{
|
|
23
37
|
"name": "ButtonLink",
|
|
24
38
|
"kind": "component",
|
|
@@ -50,6 +64,13 @@
|
|
|
50
64
|
"@gridui/button/styles.css"
|
|
51
65
|
],
|
|
52
66
|
"examples": [
|
|
67
|
+
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/actions.mdx",
|
|
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",
|
|
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",
|
|
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",
|
|
53
74
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/button-link.stories.tsx",
|
|
54
75
|
"https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/packages-core/button/stories/button.stories.tsx"
|
|
55
76
|
]
|
|
@@ -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
|
+
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# ButtonLink
|
|
3
|
+
|
|
4
|
+
Styles a native link as a button while preserving navigation behavior. Use Button for actions that do not navigate.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/button`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { ButtonLink } 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-link.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
|
+
### href
|
|
23
|
+
|
|
24
|
+
``string`` · Required
|
|
25
|
+
|
|
26
|
+
### children
|
|
27
|
+
|
|
28
|
+
``ReactNode`` · Optional
|
|
29
|
+
|
|
30
|
+
Content rendered inside the component.
|
|
31
|
+
|
|
32
|
+
### onFocus
|
|
33
|
+
|
|
34
|
+
``(event: FocusEvent<HTMLAnchorElement, Element>): void`` · Optional
|
|
35
|
+
|
|
36
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
37
|
+
|
|
38
|
+
### onBlur
|
|
39
|
+
|
|
40
|
+
``(event: FocusEvent<HTMLAnchorElement, Element>): void`` · Optional
|
|
41
|
+
|
|
42
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
43
|
+
|
|
44
|
+
### onChange
|
|
45
|
+
|
|
46
|
+
``(event: ChangeEvent<HTMLAnchorElement, Element>): void`` · Optional
|
|
47
|
+
|
|
48
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
49
|
+
|
|
50
|
+
### onSubmit
|
|
51
|
+
|
|
52
|
+
``(event: SubmitEvent<HTMLAnchorElement>): void`` · Optional
|
|
53
|
+
|
|
54
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
55
|
+
|
|
56
|
+
### onClick
|
|
57
|
+
|
|
58
|
+
``(event: MouseEvent<HTMLAnchorElement, MouseEvent>): void`` · Optional
|
|
59
|
+
|
|
60
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
61
|
+
|
|
62
|
+
### size
|
|
63
|
+
|
|
64
|
+
``"small" | "standard" | "large" | "extra-large" | null | undefined`` · Optional
|
|
65
|
+
|
|
66
|
+
Default: ``"standard"``
|
|
67
|
+
|
|
68
|
+
Component size preset.
|
|
69
|
+
|
|
70
|
+
### iconMotion
|
|
71
|
+
|
|
72
|
+
``"none" | "outward" | null | undefined`` · Optional
|
|
73
|
+
|
|
74
|
+
### variant
|
|
75
|
+
|
|
76
|
+
``"text" | "primary" | "secondary" | "quiet" | "highlight" | "underlined" | null | undefined`` · Optional
|
|
77
|
+
|
|
78
|
+
Default: ``"secondary"``
|
|
79
|
+
|
|
80
|
+
Visual variant.
|
|
81
|
+
|
|
82
|
+
### layout
|
|
83
|
+
|
|
84
|
+
``"cell" | "standard" | "icon" | "entry" | "rail" | "divided" | null | undefined`` · Optional
|
|
85
|
+
|
|
86
|
+
Layout within the containing region.
|
|
87
|
+
|
|
88
|
+
### startIcon
|
|
89
|
+
|
|
90
|
+
``ReactNode`` · Optional
|
|
91
|
+
|
|
92
|
+
### startIconLayout
|
|
93
|
+
|
|
94
|
+
``"divided" | "inline" | undefined`` · Optional
|
|
95
|
+
|
|
96
|
+
Default: ``"inline"``
|
|
97
|
+
|
|
98
|
+
### startIconSize
|
|
99
|
+
|
|
100
|
+
``"standard" | "large" | "extra-large" | undefined`` · Optional
|
|
101
|
+
|
|
102
|
+
Default: ``"standard"``
|
|
103
|
+
|
|
104
|
+
### endIcon
|
|
105
|
+
|
|
106
|
+
``ReactNode`` · Optional
|
|
107
|
+
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<!-- Generated from public Props and owned stories. Run pnpm docs:storybook. -->
|
|
2
|
+
# Button
|
|
3
|
+
|
|
4
|
+
Triggers an action such as saving, submitting, or opening a dialog. Choose a variant that reflects the action's importance.
|
|
5
|
+
|
|
6
|
+
Import from ``@gridui/button`` and load Theme before this family's stylesheet.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import { Button } 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.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
|
+
### type
|
|
23
|
+
|
|
24
|
+
``"button" | "submit" | "reset" | undefined`` · Optional
|
|
25
|
+
|
|
26
|
+
Default: ``"button"``
|
|
27
|
+
|
|
28
|
+
### children
|
|
29
|
+
|
|
30
|
+
``ReactNode`` · Optional
|
|
31
|
+
|
|
32
|
+
Content rendered inside the component.
|
|
33
|
+
|
|
34
|
+
### onFocus
|
|
35
|
+
|
|
36
|
+
``(event: FocusEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
37
|
+
|
|
38
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
39
|
+
|
|
40
|
+
### onBlur
|
|
41
|
+
|
|
42
|
+
``(event: FocusEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
43
|
+
|
|
44
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
45
|
+
|
|
46
|
+
### onChange
|
|
47
|
+
|
|
48
|
+
``(event: ChangeEvent<HTMLButtonElement, Element>): void`` · Optional
|
|
49
|
+
|
|
50
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
51
|
+
|
|
52
|
+
### onSubmit
|
|
53
|
+
|
|
54
|
+
``(event: SubmitEvent<HTMLButtonElement>): void`` · Optional
|
|
55
|
+
|
|
56
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
57
|
+
|
|
58
|
+
### onClick
|
|
59
|
+
|
|
60
|
+
``(event: MouseEvent<HTMLButtonElement, MouseEvent>): void`` · Optional
|
|
61
|
+
|
|
62
|
+
Called when the corresponding interaction occurs; inspect the arguments in Actions.
|
|
63
|
+
|
|
64
|
+
### size
|
|
65
|
+
|
|
66
|
+
``"small" | "standard" | "large" | "extra-large" | null | undefined`` · Optional
|
|
67
|
+
|
|
68
|
+
Default: ``"standard"``
|
|
69
|
+
|
|
70
|
+
Component size preset.
|
|
71
|
+
|
|
72
|
+
### iconMotion
|
|
73
|
+
|
|
74
|
+
``"none" | "outward" | null | undefined`` · Optional
|
|
75
|
+
|
|
76
|
+
### variant
|
|
77
|
+
|
|
78
|
+
``"text" | "primary" | "secondary" | "quiet" | "highlight" | "underlined" | null | undefined`` · Optional
|
|
79
|
+
|
|
80
|
+
Default: ``"primary"``
|
|
81
|
+
|
|
82
|
+
Visual variant.
|
|
83
|
+
|
|
84
|
+
### layout
|
|
85
|
+
|
|
86
|
+
``"cell" | "standard" | "icon" | "entry" | "rail" | "divided" | null | undefined`` · Optional
|
|
87
|
+
|
|
88
|
+
Layout within the containing region.
|
|
89
|
+
|
|
90
|
+
### startIcon
|
|
91
|
+
|
|
92
|
+
``ReactNode`` · Optional
|
|
93
|
+
|
|
94
|
+
### startIconLayout
|
|
95
|
+
|
|
96
|
+
``"divided" | "inline" | undefined`` · Optional
|
|
97
|
+
|
|
98
|
+
Default: ``"inline"``
|
|
99
|
+
|
|
100
|
+
### startIconSize
|
|
101
|
+
|
|
102
|
+
``"standard" | "large" | "extra-large" | undefined`` · Optional
|
|
103
|
+
|
|
104
|
+
Default: ``"standard"``
|
|
105
|
+
|
|
106
|
+
### endIcon
|
|
107
|
+
|
|
108
|
+
``ReactNode`` · Optional
|
|
109
|
+
|
|
110
|
+
### loading
|
|
111
|
+
|
|
112
|
+
``boolean | undefined`` · Optional
|
|
113
|
+
|
|
114
|
+
Default: ``false``
|
|
115
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/button",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "GridUI React buttons and action helpers",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@gridui/style-utils": "^
|
|
27
|
-
"@gridui/theme": "^2.5.
|
|
26
|
+
"@gridui/style-utils": "^4.0.0",
|
|
27
|
+
"@gridui/theme": "^2.5.4",
|
|
28
28
|
"class-variance-authority": "0.7.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|