@yamada-ui/button 1.0.52-next-20241126142838 → 1.0.52-next-20241127012228
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/dist/button-group.d.mts +17 -1
- package/dist/button-group.d.ts +17 -1
- package/dist/button-group.js +11 -7
- package/dist/button-group.js.map +1 -1
- package/dist/button-group.mjs +1 -1
- package/dist/button.d.mts +33 -1
- package/dist/button.d.ts +33 -1
- package/dist/button.js +30 -18
- package/dist/button.js.map +1 -1
- package/dist/button.mjs +2 -2
- package/dist/{chunk-O7L6NNFD.mjs → chunk-7PM7PDHG.mjs} +2 -2
- package/dist/{chunk-I3FAJDDX.mjs → chunk-AYY3OFJC.mjs} +12 -8
- package/dist/chunk-AYY3OFJC.mjs.map +1 -0
- package/dist/{chunk-L2TDLHUB.mjs → chunk-ZCBY5IMZ.mjs} +21 -13
- package/dist/chunk-ZCBY5IMZ.mjs.map +1 -0
- package/dist/icon-button.js +30 -18
- package/dist/icon-button.js.map +1 -1
- package/dist/icon-button.mjs +3 -3
- package/dist/index.js +30 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/package.json +6 -6
- package/dist/chunk-I3FAJDDX.mjs.map +0 -1
- package/dist/chunk-L2TDLHUB.mjs.map +0 -1
- /package/dist/{chunk-O7L6NNFD.mjs.map → chunk-7PM7PDHG.mjs.map} +0 -0
package/dist/button-group.d.mts
CHANGED
@@ -2,27 +2,43 @@ import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
2
|
import { HTMLUIProps, ThemeProps, CSSUIObject } from '@yamada-ui/core';
|
3
3
|
|
4
4
|
interface ButtonGroupOptions {
|
5
|
+
/**
|
6
|
+
* If `true`, the borderRadius of button that are direct children will be altered to look flushed together.
|
7
|
+
*
|
8
|
+
* @default false
|
9
|
+
*/
|
10
|
+
attached?: boolean;
|
5
11
|
/**
|
6
12
|
* The CSS `flex-direction` property.
|
7
13
|
*/
|
8
14
|
direction?: CSSUIObject["flexDirection"];
|
15
|
+
/**
|
16
|
+
* If `true`, all wrapped button will be disabled.
|
17
|
+
*
|
18
|
+
* @default false
|
19
|
+
*/
|
20
|
+
disabled?: boolean;
|
9
21
|
/**
|
10
22
|
* If `true`, the borderRadius of button that are direct children will be altered to look flushed together.
|
11
23
|
*
|
12
24
|
* @default false
|
25
|
+
*
|
26
|
+
* @deprecated Use `attached` instead.
|
13
27
|
*/
|
14
28
|
isAttached?: boolean;
|
15
29
|
/**
|
16
30
|
* If `true`, all wrapped button will be disabled.
|
17
31
|
*
|
18
32
|
* @default false
|
33
|
+
*
|
34
|
+
* @deprecated Use `disabled` instead.
|
19
35
|
*/
|
20
36
|
isDisabled?: boolean;
|
21
37
|
}
|
22
38
|
interface ButtonGroupProps extends Omit<HTMLUIProps, "direction">, ThemeProps<"Button">, ButtonGroupOptions {
|
23
39
|
}
|
24
40
|
interface ButtonGroupContext extends ThemeProps<"Button"> {
|
25
|
-
|
41
|
+
disabled?: boolean;
|
26
42
|
}
|
27
43
|
declare const useButtonGroup: () => ButtonGroupContext | undefined;
|
28
44
|
|
package/dist/button-group.d.ts
CHANGED
@@ -2,27 +2,43 @@ import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
2
|
import { HTMLUIProps, ThemeProps, CSSUIObject } from '@yamada-ui/core';
|
3
3
|
|
4
4
|
interface ButtonGroupOptions {
|
5
|
+
/**
|
6
|
+
* If `true`, the borderRadius of button that are direct children will be altered to look flushed together.
|
7
|
+
*
|
8
|
+
* @default false
|
9
|
+
*/
|
10
|
+
attached?: boolean;
|
5
11
|
/**
|
6
12
|
* The CSS `flex-direction` property.
|
7
13
|
*/
|
8
14
|
direction?: CSSUIObject["flexDirection"];
|
15
|
+
/**
|
16
|
+
* If `true`, all wrapped button will be disabled.
|
17
|
+
*
|
18
|
+
* @default false
|
19
|
+
*/
|
20
|
+
disabled?: boolean;
|
9
21
|
/**
|
10
22
|
* If `true`, the borderRadius of button that are direct children will be altered to look flushed together.
|
11
23
|
*
|
12
24
|
* @default false
|
25
|
+
*
|
26
|
+
* @deprecated Use `attached` instead.
|
13
27
|
*/
|
14
28
|
isAttached?: boolean;
|
15
29
|
/**
|
16
30
|
* If `true`, all wrapped button will be disabled.
|
17
31
|
*
|
18
32
|
* @default false
|
33
|
+
*
|
34
|
+
* @deprecated Use `disabled` instead.
|
19
35
|
*/
|
20
36
|
isDisabled?: boolean;
|
21
37
|
}
|
22
38
|
interface ButtonGroupProps extends Omit<HTMLUIProps, "direction">, ThemeProps<"Button">, ButtonGroupOptions {
|
23
39
|
}
|
24
40
|
interface ButtonGroupContext extends ThemeProps<"Button"> {
|
25
|
-
|
41
|
+
disabled?: boolean;
|
26
42
|
}
|
27
43
|
declare const useButtonGroup: () => ButtonGroupContext | undefined;
|
28
44
|
|
package/dist/button-group.js
CHANGED
@@ -40,8 +40,10 @@ var ButtonGroup = (0, import_core.forwardRef)(
|
|
40
40
|
className,
|
41
41
|
size,
|
42
42
|
variant,
|
43
|
+
attached,
|
43
44
|
columnGap,
|
44
45
|
direction: flexDirection,
|
46
|
+
disabled,
|
45
47
|
gap,
|
46
48
|
isAttached,
|
47
49
|
isDisabled,
|
@@ -49,19 +51,21 @@ var ButtonGroup = (0, import_core.forwardRef)(
|
|
49
51
|
...rest
|
50
52
|
}, ref) => {
|
51
53
|
const isColumn = flexDirection === "column" || flexDirection === "column-reverse";
|
54
|
+
attached != null ? attached : attached = isAttached;
|
55
|
+
disabled != null ? disabled : disabled = isDisabled;
|
52
56
|
const css = {
|
53
57
|
display: "inline-flex",
|
54
58
|
flexDirection
|
55
59
|
};
|
56
60
|
const context = (0, import_react.useMemo)(
|
57
|
-
() => ({ size, variant,
|
58
|
-
[size, variant,
|
61
|
+
() => ({ size, variant, disabled }),
|
62
|
+
[size, variant, disabled]
|
59
63
|
);
|
60
|
-
if (
|
64
|
+
if (attached) {
|
61
65
|
Object.assign(css, {
|
62
|
-
"> *:first-of-type:not(:last-of-type)": isColumn ? { borderBottomRadius: 0
|
63
|
-
"> *:not(:first-of-type):last-of-type": isColumn ? { borderTopRadius: 0,
|
64
|
-
"> *:not(:first-of-type):not(:last-of-type)": isColumn ? { borderRadius: 0,
|
66
|
+
"> *:first-of-type:not(:last-of-type)": isColumn ? { borderBottomRadius: 0 } : { borderRightRadius: 0, borderRightWidth: "0px" },
|
67
|
+
"> *:not(:first-of-type):last-of-type": isColumn ? { borderTopRadius: 0, borderTopWidth: "0px" } : { borderLeftRadius: 0 },
|
68
|
+
"> *:not(:first-of-type):not(:last-of-type)": isColumn ? { borderRadius: 0, borderTopWidth: "0px" } : { borderRadius: 0, borderRightWidth: "0px" }
|
65
69
|
});
|
66
70
|
} else {
|
67
71
|
Object.assign(css, {
|
@@ -75,7 +79,7 @@ var ButtonGroup = (0, import_core.forwardRef)(
|
|
75
79
|
{
|
76
80
|
ref,
|
77
81
|
className: (0, import_utils.cx)("ui-button-group", className),
|
78
|
-
"data-attached": (0, import_utils.dataAttr)(
|
82
|
+
"data-attached": (0, import_utils.dataAttr)(attached),
|
79
83
|
role: "group",
|
80
84
|
__css: css,
|
81
85
|
...rest
|
package/dist/button-group.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/button-group.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { createContext, cx, dataAttr } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\n\ninterface ButtonGroupOptions {\n /**\n * The CSS `flex-direction` property.\n */\n direction?: CSSUIObject[\"flexDirection\"]\n /**\n * If `true`, the borderRadius of button that are direct children will be altered to look flushed together.\n *\n * @default false\n */\n isAttached?: boolean\n /**\n * If `true`, all wrapped button will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n}\n\nexport interface ButtonGroupProps\n extends Omit<HTMLUIProps, \"direction\">,\n ThemeProps<\"Button\">,\n ButtonGroupOptions {}\n\ninterface ButtonGroupContext extends ThemeProps<\"Button\"> {\n
|
1
|
+
{"version":3,"sources":["../src/button-group.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { createContext, cx, dataAttr } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\n\ninterface ButtonGroupOptions {\n /**\n * If `true`, the borderRadius of button that are direct children will be altered to look flushed together.\n *\n * @default false\n */\n attached?: boolean\n /**\n * The CSS `flex-direction` property.\n */\n direction?: CSSUIObject[\"flexDirection\"]\n /**\n * If `true`, all wrapped button will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the borderRadius of button that are direct children will be altered to look flushed together.\n *\n * @default false\n *\n * @deprecated Use `attached` instead.\n */\n isAttached?: boolean\n /**\n * If `true`, all wrapped button will be disabled.\n *\n * @default false\n *\n * @deprecated Use `disabled` instead.\n */\n isDisabled?: boolean\n}\n\nexport interface ButtonGroupProps\n extends Omit<HTMLUIProps, \"direction\">,\n ThemeProps<\"Button\">,\n ButtonGroupOptions {}\n\ninterface ButtonGroupContext extends ThemeProps<\"Button\"> {\n disabled?: boolean\n}\n\nconst [ButtonGroupProvider, useButtonGroup] = createContext<ButtonGroupContext>(\n {\n name: \"ButtonGroupContext\",\n strict: false,\n },\n)\n\nexport { useButtonGroup }\n\nexport const ButtonGroup = forwardRef<ButtonGroupProps, \"div\">(\n (\n {\n className,\n size,\n variant,\n attached,\n columnGap,\n direction: flexDirection,\n disabled,\n gap,\n isAttached,\n isDisabled,\n rowGap,\n ...rest\n },\n ref,\n ) => {\n const isColumn =\n flexDirection === \"column\" || flexDirection === \"column-reverse\"\n\n attached ??= isAttached\n disabled ??= isDisabled\n\n const css: CSSUIObject = {\n display: \"inline-flex\",\n flexDirection,\n }\n\n const context: ButtonGroupContext = useMemo(\n () => ({ size, variant, disabled }),\n [size, variant, disabled],\n )\n\n if (attached) {\n Object.assign(css, {\n \"> *:first-of-type:not(:last-of-type)\": isColumn\n ? { borderBottomRadius: 0 }\n : { borderRightRadius: 0, borderRightWidth: \"0px\" },\n \"> *:not(:first-of-type):last-of-type\": isColumn\n ? { borderTopRadius: 0, borderTopWidth: \"0px\" }\n : { borderLeftRadius: 0 },\n \"> *:not(:first-of-type):not(:last-of-type)\": isColumn\n ? { borderRadius: 0, borderTopWidth: \"0px\" }\n : { borderRadius: 0, borderRightWidth: \"0px\" },\n })\n } else {\n Object.assign(css, {\n columnGap,\n gap,\n rowGap,\n })\n }\n\n return (\n <ButtonGroupProvider value={context}>\n <ui.div\n ref={ref}\n className={cx(\"ui-button-group\", className)}\n data-attached={dataAttr(attached)}\n role=\"group\"\n __css={css}\n {...rest}\n />\n </ButtonGroupProvider>\n )\n },\n)\n\nButtonGroup.displayName = \"ButtonGroup\"\nButtonGroup.__ui__ = \"ButtonGroup\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA+B;AAC/B,mBAA4C;AAC5C,mBAAwB;AA+GhB;AAjER,IAAM,CAAC,qBAAqB,cAAc,QAAI;AAAA,EAC5C;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,EACV;AACF;AAIO,IAAM,kBAAc;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,WACJ,kBAAkB,YAAY,kBAAkB;AAElD,6CAAa;AACb,6CAAa;AAEb,UAAM,MAAmB;AAAA,MACvB,SAAS;AAAA,MACT;AAAA,IACF;AAEA,UAAM,cAA8B;AAAA,MAClC,OAAO,EAAE,MAAM,SAAS,SAAS;AAAA,MACjC,CAAC,MAAM,SAAS,QAAQ;AAAA,IAC1B;AAEA,QAAI,UAAU;AACZ,aAAO,OAAO,KAAK;AAAA,QACjB,wCAAwC,WACpC,EAAE,oBAAoB,EAAE,IACxB,EAAE,mBAAmB,GAAG,kBAAkB,MAAM;AAAA,QACpD,wCAAwC,WACpC,EAAE,iBAAiB,GAAG,gBAAgB,MAAM,IAC5C,EAAE,kBAAkB,EAAE;AAAA,QAC1B,8CAA8C,WAC1C,EAAE,cAAc,GAAG,gBAAgB,MAAM,IACzC,EAAE,cAAc,GAAG,kBAAkB,MAAM;AAAA,MACjD,CAAC;AAAA,IACH,OAAO;AACL,aAAO,OAAO,KAAK;AAAA,QACjB;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WACE,4CAAC,uBAAoB,OAAO,SAC1B;AAAA,MAAC,eAAG;AAAA,MAAH;AAAA,QACC;AAAA,QACA,eAAW,iBAAG,mBAAmB,SAAS;AAAA,QAC1C,qBAAe,uBAAS,QAAQ;AAAA,QAChC,MAAK;AAAA,QACL,OAAO;AAAA,QACN,GAAG;AAAA;AAAA,IACN,GACF;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;AAC1B,YAAY,SAAS;","names":[]}
|
package/dist/button-group.mjs
CHANGED
package/dist/button.d.mts
CHANGED
@@ -10,6 +10,18 @@ interface ButtonOptions {
|
|
10
10
|
* @default 'button'
|
11
11
|
*/
|
12
12
|
type?: "button" | "reset" | "submit";
|
13
|
+
/**
|
14
|
+
* If `true`, the button is represented as active.
|
15
|
+
*
|
16
|
+
* @default false
|
17
|
+
*/
|
18
|
+
active?: boolean;
|
19
|
+
/**
|
20
|
+
* If `true`, the button is disabled.
|
21
|
+
*
|
22
|
+
* @default false
|
23
|
+
*/
|
24
|
+
disabled?: boolean;
|
13
25
|
/**
|
14
26
|
* If `true`, disable ripple effects when pressing a element.
|
15
27
|
*
|
@@ -20,28 +32,42 @@ interface ButtonOptions {
|
|
20
32
|
* The icon to display at the end side of the button.
|
21
33
|
*/
|
22
34
|
endIcon?: ReactElement;
|
35
|
+
/**
|
36
|
+
* If `true`, the button is full rounded. Else, it'll be slightly round.
|
37
|
+
*
|
38
|
+
* @default false
|
39
|
+
*/
|
40
|
+
fullRounded?: boolean;
|
23
41
|
/**
|
24
42
|
* If `true`, the button is represented as active.
|
25
43
|
*
|
26
44
|
* @default false
|
45
|
+
*
|
46
|
+
* @deprecated Use `active` instead.
|
27
47
|
*/
|
28
48
|
isActive?: boolean;
|
29
49
|
/**
|
30
50
|
* If `true`, the button is disabled.
|
31
51
|
*
|
32
52
|
* @default false
|
53
|
+
*
|
54
|
+
* @deprecated Use `disabled` instead.
|
33
55
|
*/
|
34
56
|
isDisabled?: boolean;
|
35
57
|
/**
|
36
58
|
* If `true`, the loading state of the button is represented.
|
37
59
|
*
|
38
60
|
* @default false
|
61
|
+
*
|
62
|
+
* @deprecated Use `loading` instead.
|
39
63
|
*/
|
40
64
|
isLoading?: boolean;
|
41
65
|
/**
|
42
|
-
* If true
|
66
|
+
* If `true`, the button is full rounded. Else, it'll be slightly round.
|
43
67
|
*
|
44
68
|
* @default false
|
69
|
+
*
|
70
|
+
* @deprecated Use `fullRounded` instead.
|
45
71
|
*/
|
46
72
|
isRounded?: boolean;
|
47
73
|
/**
|
@@ -50,6 +76,12 @@ interface ButtonOptions {
|
|
50
76
|
* @deprecated Use `startIcon` instead.
|
51
77
|
*/
|
52
78
|
leftIcon?: ReactElement;
|
79
|
+
/**
|
80
|
+
* If `true`, the loading state of the button is represented.
|
81
|
+
*
|
82
|
+
* @default false
|
83
|
+
*/
|
84
|
+
loading?: boolean;
|
53
85
|
/**
|
54
86
|
* The icon to display when the button is loading.
|
55
87
|
*/
|
package/dist/button.d.ts
CHANGED
@@ -10,6 +10,18 @@ interface ButtonOptions {
|
|
10
10
|
* @default 'button'
|
11
11
|
*/
|
12
12
|
type?: "button" | "reset" | "submit";
|
13
|
+
/**
|
14
|
+
* If `true`, the button is represented as active.
|
15
|
+
*
|
16
|
+
* @default false
|
17
|
+
*/
|
18
|
+
active?: boolean;
|
19
|
+
/**
|
20
|
+
* If `true`, the button is disabled.
|
21
|
+
*
|
22
|
+
* @default false
|
23
|
+
*/
|
24
|
+
disabled?: boolean;
|
13
25
|
/**
|
14
26
|
* If `true`, disable ripple effects when pressing a element.
|
15
27
|
*
|
@@ -20,28 +32,42 @@ interface ButtonOptions {
|
|
20
32
|
* The icon to display at the end side of the button.
|
21
33
|
*/
|
22
34
|
endIcon?: ReactElement;
|
35
|
+
/**
|
36
|
+
* If `true`, the button is full rounded. Else, it'll be slightly round.
|
37
|
+
*
|
38
|
+
* @default false
|
39
|
+
*/
|
40
|
+
fullRounded?: boolean;
|
23
41
|
/**
|
24
42
|
* If `true`, the button is represented as active.
|
25
43
|
*
|
26
44
|
* @default false
|
45
|
+
*
|
46
|
+
* @deprecated Use `active` instead.
|
27
47
|
*/
|
28
48
|
isActive?: boolean;
|
29
49
|
/**
|
30
50
|
* If `true`, the button is disabled.
|
31
51
|
*
|
32
52
|
* @default false
|
53
|
+
*
|
54
|
+
* @deprecated Use `disabled` instead.
|
33
55
|
*/
|
34
56
|
isDisabled?: boolean;
|
35
57
|
/**
|
36
58
|
* If `true`, the loading state of the button is represented.
|
37
59
|
*
|
38
60
|
* @default false
|
61
|
+
*
|
62
|
+
* @deprecated Use `loading` instead.
|
39
63
|
*/
|
40
64
|
isLoading?: boolean;
|
41
65
|
/**
|
42
|
-
* If true
|
66
|
+
* If `true`, the button is full rounded. Else, it'll be slightly round.
|
43
67
|
*
|
44
68
|
* @default false
|
69
|
+
*
|
70
|
+
* @deprecated Use `fullRounded` instead.
|
45
71
|
*/
|
46
72
|
isRounded?: boolean;
|
47
73
|
/**
|
@@ -50,6 +76,12 @@ interface ButtonOptions {
|
|
50
76
|
* @deprecated Use `startIcon` instead.
|
51
77
|
*/
|
52
78
|
leftIcon?: ReactElement;
|
79
|
+
/**
|
80
|
+
* If `true`, the loading state of the button is represented.
|
81
|
+
*
|
82
|
+
* @default false
|
83
|
+
*/
|
84
|
+
loading?: boolean;
|
53
85
|
/**
|
54
86
|
* The icon to display when the button is loading.
|
55
87
|
*/
|
package/dist/button.js
CHANGED
@@ -47,8 +47,10 @@ var ButtonGroup = (0, import_core.forwardRef)(
|
|
47
47
|
className,
|
48
48
|
size,
|
49
49
|
variant,
|
50
|
+
attached,
|
50
51
|
columnGap,
|
51
52
|
direction: flexDirection,
|
53
|
+
disabled,
|
52
54
|
gap,
|
53
55
|
isAttached,
|
54
56
|
isDisabled,
|
@@ -56,19 +58,21 @@ var ButtonGroup = (0, import_core.forwardRef)(
|
|
56
58
|
...rest
|
57
59
|
}, ref) => {
|
58
60
|
const isColumn = flexDirection === "column" || flexDirection === "column-reverse";
|
61
|
+
attached != null ? attached : attached = isAttached;
|
62
|
+
disabled != null ? disabled : disabled = isDisabled;
|
59
63
|
const css = {
|
60
64
|
display: "inline-flex",
|
61
65
|
flexDirection
|
62
66
|
};
|
63
67
|
const context = (0, import_react.useMemo)(
|
64
|
-
() => ({ size, variant,
|
65
|
-
[size, variant,
|
68
|
+
() => ({ size, variant, disabled }),
|
69
|
+
[size, variant, disabled]
|
66
70
|
);
|
67
|
-
if (
|
71
|
+
if (attached) {
|
68
72
|
Object.assign(css, {
|
69
|
-
"> *:first-of-type:not(:last-of-type)": isColumn ? { borderBottomRadius: 0
|
70
|
-
"> *:not(:first-of-type):last-of-type": isColumn ? { borderTopRadius: 0,
|
71
|
-
"> *:not(:first-of-type):not(:last-of-type)": isColumn ? { borderRadius: 0,
|
73
|
+
"> *:first-of-type:not(:last-of-type)": isColumn ? { borderBottomRadius: 0 } : { borderRightRadius: 0, borderRightWidth: "0px" },
|
74
|
+
"> *:not(:first-of-type):last-of-type": isColumn ? { borderTopRadius: 0, borderTopWidth: "0px" } : { borderLeftRadius: 0 },
|
75
|
+
"> *:not(:first-of-type):not(:last-of-type)": isColumn ? { borderRadius: 0, borderTopWidth: "0px" } : { borderRadius: 0, borderRightWidth: "0px" }
|
72
76
|
});
|
73
77
|
} else {
|
74
78
|
Object.assign(css, {
|
@@ -82,7 +86,7 @@ var ButtonGroup = (0, import_core.forwardRef)(
|
|
82
86
|
{
|
83
87
|
ref,
|
84
88
|
className: (0, import_utils.cx)("ui-button-group", className),
|
85
|
-
"data-attached": (0, import_utils.dataAttr)(
|
89
|
+
"data-attached": (0, import_utils.dataAttr)(attached),
|
86
90
|
role: "group",
|
87
91
|
__css: css,
|
88
92
|
...rest
|
@@ -106,17 +110,21 @@ var Button = (0, import_core2.forwardRef)(
|
|
106
110
|
},
|
107
111
|
{ isProcessSkip: __isProcessSkip, styles: __styles }
|
108
112
|
);
|
109
|
-
|
113
|
+
let {
|
110
114
|
as,
|
111
115
|
type,
|
112
116
|
className,
|
117
|
+
active,
|
118
|
+
disabled = group == null ? void 0 : group.disabled,
|
113
119
|
disableRipple,
|
114
120
|
endIcon,
|
121
|
+
fullRounded,
|
115
122
|
isActive,
|
116
|
-
isDisabled = group == null ? void 0 : group.
|
123
|
+
isDisabled = group == null ? void 0 : group.disabled,
|
117
124
|
isLoading,
|
118
125
|
isRounded,
|
119
126
|
leftIcon,
|
127
|
+
loading,
|
120
128
|
loadingIcon,
|
121
129
|
loadingPlacement = "start",
|
122
130
|
loadingText,
|
@@ -125,11 +133,15 @@ var Button = (0, import_core2.forwardRef)(
|
|
125
133
|
__css,
|
126
134
|
...rest
|
127
135
|
} = (0, import_core2.omitThemeProps)(mergedProps);
|
128
|
-
|
136
|
+
active != null ? active : active = isActive;
|
137
|
+
disabled != null ? disabled : disabled = isDisabled;
|
138
|
+
loading != null ? loading : loading = isLoading;
|
139
|
+
fullRounded != null ? fullRounded : fullRounded = isRounded;
|
140
|
+
const trulyDisabled = disabled || loading;
|
129
141
|
const { ref: buttonRef, type: defaultType } = useButtonType(as);
|
130
142
|
const { onPointerDown, ...rippleProps } = (0, import_ripple.useRipple)({
|
131
143
|
...rest,
|
132
|
-
|
144
|
+
disabled: disableRipple || trulyDisabled
|
133
145
|
});
|
134
146
|
const css = (0, import_react2.useMemo)(() => {
|
135
147
|
var _a;
|
@@ -149,9 +161,9 @@ var Button = (0, import_core2.forwardRef)(
|
|
149
161
|
...styles,
|
150
162
|
...__css,
|
151
163
|
...!!group ? { _focus } : {},
|
152
|
-
...
|
164
|
+
...fullRounded ? { borderRadius: "fallback(full, 9999px)" } : {}
|
153
165
|
};
|
154
|
-
}, [styles, __css, group,
|
166
|
+
}, [styles, __css, group, fullRounded]);
|
155
167
|
const contentProps = {
|
156
168
|
children,
|
157
169
|
endIcon,
|
@@ -170,22 +182,22 @@ var Button = (0, import_core2.forwardRef)(
|
|
170
182
|
as,
|
171
183
|
type: type != null ? type : defaultType,
|
172
184
|
className: (0, import_utils2.cx)("ui-button", className),
|
173
|
-
"data-active": (0, import_utils2.dataAttr)(
|
174
|
-
"data-loading": (0, import_utils2.dataAttr)(
|
185
|
+
"data-active": (0, import_utils2.dataAttr)(active),
|
186
|
+
"data-loading": (0, import_utils2.dataAttr)(loading),
|
175
187
|
disabled: trulyDisabled,
|
176
188
|
__css: css,
|
177
189
|
...rest,
|
178
190
|
onPointerDown,
|
179
191
|
children: [
|
180
|
-
|
192
|
+
loading && loadingPlacement === "start" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
181
193
|
ButtonLoading,
|
182
194
|
{
|
183
195
|
className: "ui-button__loading--start",
|
184
196
|
...loadingProps
|
185
197
|
}
|
186
198
|
) : null,
|
187
|
-
|
188
|
-
|
199
|
+
loading ? loadingText || /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { opacity: 0, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ButtonContent, { ...contentProps }) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ButtonContent, { ...contentProps }),
|
200
|
+
loading && loadingPlacement === "end" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
189
201
|
ButtonLoading,
|
190
202
|
{
|
191
203
|
className: "ui-button__loading--end",
|
package/dist/button.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/button.tsx","../src/button-group.tsx"],"sourcesContent":["import type { CSSUIObject, FC, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport type { LoadingProps } from \"@yamada-ui/loading\"\nimport type { ElementType, ReactElement } from \"react\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentStyle,\n} from \"@yamada-ui/core\"\nimport { Loading as LoadingIcon } from \"@yamada-ui/loading\"\nimport { Ripple, useRipple } from \"@yamada-ui/ripple\"\nimport { cx, dataAttr, merge, mergeRefs } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo, useRef } from \"react\"\nimport { useButtonGroup } from \"./button-group\"\n\ninterface ButtonOptions {\n /**\n * The type of button. Accepts `button`, `reset`, or `submit`.\n *\n * @default 'button'\n */\n type?: \"button\" | \"reset\" | \"submit\"\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n disableRipple?: boolean\n /**\n * The icon to display at the end side of the button.\n */\n endIcon?: ReactElement\n /**\n * If `true`, the button is represented as active.\n *\n * @default false\n */\n isActive?: boolean\n /**\n * If `true`, the button is disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n /**\n * If `true`, the loading state of the button is represented.\n *\n * @default false\n */\n isLoading?: boolean\n /**\n * If true, the button is full rounded. Else, it'll be slightly round.\n *\n * @default false\n */\n isRounded?: boolean\n /**\n * The icon to display at the left side of the button.\n *\n * @deprecated Use `startIcon` instead.\n */\n leftIcon?: ReactElement\n /**\n * The icon to display when the button is loading.\n */\n loadingIcon?: LoadingProps[\"variant\"] | ReactElement\n /**\n * The placement of the loading indicator. Accepts `start` or `end`.\n *\n * @default 'start'\n */\n loadingPlacement?: \"end\" | \"start\"\n /**\n * The text to display when the button is loading.\n */\n loadingText?: string\n /**\n * The icon to display at the right side of the button.\n *\n * @deprecated Use `endIcon` instead.\n */\n rightIcon?: ReactElement\n /**\n * The icon to display at the start side of the button.\n */\n startIcon?: ReactElement\n}\n\nexport interface ButtonProps\n extends HTMLUIProps<\"button\">,\n ThemeProps<\"Button\">,\n ButtonOptions {}\n\n/**\n * `Button` is an interactive component that allows users to perform actions such as submitting forms and toggling modals.\n *\n * @see Docs https://yamada-ui.com/components/forms/button\n */\nexport const Button = forwardRef<ButtonProps, \"button\">(\n ({ children, __isProcessSkip, __styles, ...props }, ref) => {\n const group = useButtonGroup()\n const [styles, mergedProps] = useComponentStyle(\n \"Button\",\n {\n ...group,\n ...props,\n },\n { isProcessSkip: __isProcessSkip, styles: __styles },\n )\n const {\n as,\n type,\n className,\n disableRipple,\n endIcon,\n isActive,\n isDisabled = group?.isDisabled,\n isLoading,\n isRounded,\n leftIcon,\n loadingIcon,\n loadingPlacement = \"start\",\n loadingText,\n rightIcon,\n startIcon,\n __css,\n ...rest\n } = omitThemeProps(mergedProps)\n\n const trulyDisabled = isDisabled || isLoading\n\n const { ref: buttonRef, type: defaultType } = useButtonType(as)\n const { onPointerDown, ...rippleProps } = useRipple({\n ...rest,\n isDisabled: disableRipple || trulyDisabled,\n })\n\n const css: CSSUIObject = useMemo(() => {\n const _focus =\n \"_focus\" in styles\n ? merge(styles._focus ?? {}, { zIndex: \"fallback(yamcha, 1)\" })\n : {}\n\n return {\n alignItems: \"center\",\n appearance: \"none\",\n display: \"inline-flex\",\n gap: \"fallback(2, 0.5rem)\",\n justifyContent: \"center\",\n outline: \"none\",\n overflow: \"hidden\",\n position: \"relative\",\n userSelect: \"none\",\n verticalAlign: \"middle\",\n whiteSpace: \"nowrap\",\n ...styles,\n ...__css,\n ...(!!group ? { _focus } : {}),\n ...(isRounded ? { borderRadius: \"fallback(full, 9999px)\" } : {}),\n }\n }, [styles, __css, group, isRounded])\n\n const contentProps = {\n children,\n endIcon,\n leftIcon,\n rightIcon,\n startIcon,\n }\n\n const loadingProps = {\n loadingIcon,\n loadingText,\n }\n\n return (\n <ui.button\n ref={mergeRefs(ref, buttonRef)}\n as={as}\n type={type ?? defaultType}\n className={cx(\"ui-button\", className)}\n data-active={dataAttr(isActive)}\n data-loading={dataAttr(isLoading)}\n disabled={trulyDisabled}\n __css={css}\n {...rest}\n onPointerDown={onPointerDown}\n >\n {isLoading && loadingPlacement === \"start\" ? (\n <ButtonLoading\n className=\"ui-button__loading--start\"\n {...loadingProps}\n />\n ) : null}\n\n {isLoading ? (\n loadingText || (\n <ui.span opacity={0}>\n <ButtonContent {...contentProps} />\n </ui.span>\n )\n ) : (\n <ButtonContent {...contentProps} />\n )}\n\n {isLoading && loadingPlacement === \"end\" ? (\n <ButtonLoading\n className=\"ui-button__loading--end\"\n {...loadingProps}\n />\n ) : null}\n\n <Ripple {...rippleProps} />\n </ui.button>\n )\n },\n)\n\nButton.displayName = \"Button\"\nButton.__ui__ = \"Button\"\n\ninterface ButtonLoadingProps\n extends Pick<ButtonProps, \"className\" | \"loadingIcon\" | \"loadingText\"> {}\n\nconst ButtonLoading: FC<ButtonLoadingProps> = ({\n className,\n loadingIcon,\n loadingText,\n}) => {\n const css = useMemo(\n (): CSSUIObject => ({\n alignItems: \"center\",\n display: \"flex\",\n fontSize: \"1em\",\n lineHeight: \"normal\",\n position: loadingText ? \"relative\" : \"absolute\",\n }),\n [loadingText],\n )\n\n const element = useMemo(() => {\n if (typeof loadingIcon === \"string\") {\n return <LoadingIcon variant={loadingIcon} color=\"current\" />\n } else {\n return loadingIcon || <LoadingIcon color=\"current\" />\n }\n }, [loadingIcon])\n\n return (\n <ui.div className={cx(\"ui-button__loading\", className)} __css={css}>\n {element}\n </ui.div>\n )\n}\n\nButtonLoading.displayName = \"ButtonLoading\"\nButtonLoading.__ui__ = \"ButtonLoading\"\n\ninterface ButtonContentProps\n extends Pick<\n ButtonProps,\n \"children\" | \"endIcon\" | \"leftIcon\" | \"rightIcon\" | \"startIcon\"\n > {}\n\nconst ButtonContent: FC<ButtonContentProps> = ({\n children,\n endIcon,\n leftIcon,\n rightIcon,\n startIcon,\n}) => {\n startIcon ??= leftIcon\n endIcon ??= rightIcon\n\n return (\n <>\n {startIcon ? <ButtonIcon>{startIcon}</ButtonIcon> : null}\n {children}\n {endIcon ? <ButtonIcon>{endIcon}</ButtonIcon> : null}\n </>\n )\n}\n\nButtonContent.displayName = \"ButtonContent\"\nButtonContent.__ui__ = \"ButtonContent\"\n\ninterface ButtonIconProps extends HTMLUIProps<\"span\"> {}\n\nconst ButtonIcon: FC<ButtonIconProps> = ({ className, children, ...rest }) => {\n return (\n <ui.span\n className={cx(\"ui-button__icon\", className)}\n aria-hidden\n alignSelf=\"center\"\n display=\"inline-flex\"\n flexShrink={0}\n {...rest}\n >\n {children}\n </ui.span>\n )\n}\n\nButtonIcon.displayName = \"ButtonIcon\"\nButtonIcon.__ui__ = \"ButtonIcon\"\n\nexport const useButtonType = (value?: ElementType) => {\n const isButton = useRef(!value)\n\n const ref = useCallback((node: HTMLElement | null) => {\n if (node) isButton.current = node.tagName === \"BUTTON\"\n }, [])\n\n const type = isButton.current ? \"button\" : undefined\n\n return { ref, type } as const\n}\n","import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { createContext, cx, dataAttr } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\n\ninterface ButtonGroupOptions {\n /**\n * The CSS `flex-direction` property.\n */\n direction?: CSSUIObject[\"flexDirection\"]\n /**\n * If `true`, the borderRadius of button that are direct children will be altered to look flushed together.\n *\n * @default false\n */\n isAttached?: boolean\n /**\n * If `true`, all wrapped button will be disabled.\n *\n * @default false\n */\n isDisabled?: boolean\n}\n\nexport interface ButtonGroupProps\n extends Omit<HTMLUIProps, \"direction\">,\n ThemeProps<\"Button\">,\n ButtonGroupOptions {}\n\ninterface ButtonGroupContext extends ThemeProps<\"Button\"> {\n isDisabled?: boolean\n}\n\nconst [ButtonGroupProvider, useButtonGroup] = createContext<ButtonGroupContext>(\n {\n name: \"ButtonGroupContext\",\n strict: false,\n },\n)\n\nexport { useButtonGroup }\n\nexport const ButtonGroup = forwardRef<ButtonGroupProps, \"div\">(\n (\n {\n className,\n size,\n variant,\n columnGap,\n direction: flexDirection,\n gap,\n isAttached,\n isDisabled,\n rowGap,\n ...rest\n },\n ref,\n ) => {\n const isColumn =\n flexDirection === \"column\" || flexDirection === \"column-reverse\"\n\n const css: CSSUIObject = {\n display: \"inline-flex\",\n flexDirection,\n }\n\n const context: ButtonGroupContext = useMemo(\n () => ({ size, variant, isDisabled }),\n [size, variant, isDisabled],\n )\n\n if (isAttached) {\n Object.assign(css, {\n \"> *:first-of-type:not(:last-of-type)\": isColumn\n ? { borderBottomRadius: 0, marginBlockEnd: \"-1px\" }\n : { borderRightRadius: 0, marginInlineEnd: \"-1px\" },\n \"> *:not(:first-of-type):last-of-type\": isColumn\n ? { borderTopRadius: 0, marginBlockStart: \"-1px\" }\n : { borderLeftRadius: 0 },\n \"> *:not(:first-of-type):not(:last-of-type)\": isColumn\n ? { borderRadius: 0, marginBlockStart: \"-1px\" }\n : { borderRadius: 0, marginInlineEnd: \"-1px\" },\n })\n } else {\n Object.assign(css, {\n columnGap,\n gap,\n rowGap,\n })\n }\n\n return (\n <ButtonGroupProvider value={context}>\n <ui.div\n ref={ref}\n className={cx(\"ui-button-group\", className)}\n data-attached={dataAttr(isAttached)}\n role=\"group\"\n __css={css}\n {...rest}\n />\n </ButtonGroupProvider>\n )\n },\n)\n\nButtonGroup.displayName = \"ButtonGroup\"\nButtonGroup.__ui__ = \"ButtonGroup\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAA,eAKO;AACP,qBAAuC;AACvC,oBAAkC;AAClC,IAAAC,gBAA+C;AAC/C,IAAAC,gBAA6C;;;ACX7C,kBAA+B;AAC/B,mBAA4C;AAC5C,mBAAwB;AA0FhB;AA5DR,IAAM,CAAC,qBAAqB,cAAc,QAAI;AAAA,EAC5C;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,EACV;AACF;AAIO,IAAM,kBAAc;AAAA,EACzB,CACE;A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IAC5D,OAAO;AACL,aAAO,eAAe,6CAAC,eAAAA,SAAA,EAAY,OAAM,WAAU;AAAA,IACrD;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,SACE,6CAAC,gBAAG,KAAH,EAAO,eAAW,kBAAG,sBAAsB,SAAS,GAAG,OAAO,KAC5D,mBACH;AAEJ;AAEA,cAAc,cAAc;AAC5B,cAAc,SAAS;AAQvB,IAAM,gBAAwC,CAAC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,8CAAc;AACd,wCAAY;AAEZ,SACE,8EACG;AAAA,gBAAY,6CAAC,cAAY,qBAAU,IAAgB;AAAA,IACnD;AAAA,IACA,UAAU,6CAAC,cAAY,mBAAQ,IAAgB;AAAA,KAClD;AAEJ;AAEA,cAAc,cAAc;AAC5B,cAAc,SAAS;AAIvB,IAAM,aAAkC,CAAC,EAAE,WAAW,UAAU,GAAG,KAAK,MAAM;AAC5E,SACE;AAAA,IAAC,gBAAG;AAAA,IAAH;AAAA,MACC,eAAW,kBAAG,mBAAmB,SAAS;AAAA,MAC1C,eAAW;AAAA,MACX,WAAU;AAAA,MACV,SAAQ;AAAA,MACR,YAAY;AAAA,MACX,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;AAEA,WAAW,cAAc;AACzB,WAAW,SAAS;AAEb,IAAM,gBAAgB,CAAC,UAAwB;AACpD,QAAM,eAAW,sBAAO,CAAC,KAAK;AAE9B,QAAM,UAAM,2BAAY,CAAC,SAA6B;AACpD,QAAI,KAAM,UAAS,UAAU,KAAK,YAAY;AAAA,EAChD,GAAG,CAAC,CAAC;AAEL,QAAM,OAAO,SAAS,UAAU,WAAW;AAE3C,SAAO,EAAE,KAAK,KAAK;AACrB;","names":["import_core","import_utils","import_react","import_jsx_runtime","LoadingIcon"]}
|
1
|
+
{"version":3,"sources":["../src/button.tsx","../src/button-group.tsx"],"sourcesContent":["import type { CSSUIObject, FC, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport type { LoadingProps } from \"@yamada-ui/loading\"\nimport type { ElementType, ReactElement } from \"react\"\nimport {\n forwardRef,\n omitThemeProps,\n ui,\n useComponentStyle,\n} from \"@yamada-ui/core\"\nimport { Loading as LoadingIcon } from \"@yamada-ui/loading\"\nimport { Ripple, useRipple } from \"@yamada-ui/ripple\"\nimport { cx, dataAttr, merge, mergeRefs } from \"@yamada-ui/utils\"\nimport { useCallback, useMemo, useRef } from \"react\"\nimport { useButtonGroup } from \"./button-group\"\n\ninterface ButtonOptions {\n /**\n * The type of button. Accepts `button`, `reset`, or `submit`.\n *\n * @default 'button'\n */\n type?: \"button\" | \"reset\" | \"submit\"\n /**\n * If `true`, the button is represented as active.\n *\n * @default false\n */\n active?: boolean\n /**\n * If `true`, the button is disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n disableRipple?: boolean\n /**\n * The icon to display at the end side of the button.\n */\n endIcon?: ReactElement\n /**\n * If `true`, the button is full rounded. Else, it'll be slightly round.\n *\n * @default false\n */\n fullRounded?: boolean\n /**\n * If `true`, the button is represented as active.\n *\n * @default false\n *\n * @deprecated Use `active` instead.\n */\n isActive?: boolean\n /**\n * If `true`, the button is disabled.\n *\n * @default false\n *\n * @deprecated Use `disabled` instead.\n */\n isDisabled?: boolean\n /**\n * If `true`, the loading state of the button is represented.\n *\n * @default false\n *\n * @deprecated Use `loading` instead.\n */\n isLoading?: boolean\n /**\n * If `true`, the button is full rounded. Else, it'll be slightly round.\n *\n * @default false\n *\n * @deprecated Use `fullRounded` instead.\n */\n isRounded?: boolean\n /**\n * The icon to display at the left side of the button.\n *\n * @deprecated Use `startIcon` instead.\n */\n leftIcon?: ReactElement\n /**\n * If `true`, the loading state of the button is represented.\n *\n * @default false\n */\n loading?: boolean\n /**\n * The icon to display when the button is loading.\n */\n loadingIcon?: LoadingProps[\"variant\"] | ReactElement\n /**\n * The placement of the loading indicator. Accepts `start` or `end`.\n *\n * @default 'start'\n */\n loadingPlacement?: \"end\" | \"start\"\n /**\n * The text to display when the button is loading.\n */\n loadingText?: string\n /**\n * The icon to display at the right side of the button.\n *\n * @deprecated Use `endIcon` instead.\n */\n rightIcon?: ReactElement\n /**\n * The icon to display at the start side of the button.\n */\n startIcon?: ReactElement\n}\n\nexport interface ButtonProps\n extends HTMLUIProps<\"button\">,\n ThemeProps<\"Button\">,\n ButtonOptions {}\n\n/**\n * `Button` is an interactive component that allows users to perform actions such as submitting forms and toggling modals.\n *\n * @see Docs https://yamada-ui.com/components/forms/button\n */\nexport const Button = forwardRef<ButtonProps, \"button\">(\n ({ children, __isProcessSkip, __styles, ...props }, ref) => {\n const group = useButtonGroup()\n const [styles, mergedProps] = useComponentStyle(\n \"Button\",\n {\n ...group,\n ...props,\n },\n { isProcessSkip: __isProcessSkip, styles: __styles },\n )\n let {\n as,\n type,\n className,\n active,\n disabled = group?.disabled,\n disableRipple,\n endIcon,\n fullRounded,\n isActive,\n isDisabled = group?.disabled,\n isLoading,\n isRounded,\n leftIcon,\n loading,\n loadingIcon,\n loadingPlacement = \"start\",\n loadingText,\n rightIcon,\n startIcon,\n __css,\n ...rest\n } = omitThemeProps(mergedProps)\n\n active ??= isActive\n disabled ??= isDisabled\n loading ??= isLoading\n fullRounded ??= isRounded\n\n const trulyDisabled = disabled || loading\n\n const { ref: buttonRef, type: defaultType } = useButtonType(as)\n const { onPointerDown, ...rippleProps } = useRipple({\n ...rest,\n disabled: disableRipple || trulyDisabled,\n })\n\n const css: CSSUIObject = useMemo(() => {\n const _focus =\n \"_focus\" in styles\n ? merge(styles._focus ?? {}, { zIndex: \"fallback(yamcha, 1)\" })\n : {}\n\n return {\n alignItems: \"center\",\n appearance: \"none\",\n display: \"inline-flex\",\n gap: \"fallback(2, 0.5rem)\",\n justifyContent: \"center\",\n outline: \"none\",\n overflow: \"hidden\",\n position: \"relative\",\n userSelect: \"none\",\n verticalAlign: \"middle\",\n whiteSpace: \"nowrap\",\n ...styles,\n ...__css,\n ...(!!group ? { _focus } : {}),\n ...(fullRounded ? { borderRadius: \"fallback(full, 9999px)\" } : {}),\n }\n }, [styles, __css, group, fullRounded])\n\n const contentProps = {\n children,\n endIcon,\n leftIcon,\n rightIcon,\n startIcon,\n }\n\n const loadingProps = {\n loadingIcon,\n loadingText,\n }\n\n return (\n <ui.button\n ref={mergeRefs(ref, buttonRef)}\n as={as}\n type={type ?? defaultType}\n className={cx(\"ui-button\", className)}\n data-active={dataAttr(active)}\n data-loading={dataAttr(loading)}\n disabled={trulyDisabled}\n __css={css}\n {...rest}\n onPointerDown={onPointerDown}\n >\n {loading && loadingPlacement === \"start\" ? (\n <ButtonLoading\n className=\"ui-button__loading--start\"\n {...loadingProps}\n />\n ) : null}\n\n {loading ? (\n loadingText || (\n <ui.span opacity={0}>\n <ButtonContent {...contentProps} />\n </ui.span>\n )\n ) : (\n <ButtonContent {...contentProps} />\n )}\n\n {loading && loadingPlacement === \"end\" ? (\n <ButtonLoading\n className=\"ui-button__loading--end\"\n {...loadingProps}\n />\n ) : null}\n\n <Ripple {...rippleProps} />\n </ui.button>\n )\n },\n)\n\nButton.displayName = \"Button\"\nButton.__ui__ = \"Button\"\n\ninterface ButtonLoadingProps\n extends Pick<ButtonProps, \"className\" | \"loadingIcon\" | \"loadingText\"> {}\n\nconst ButtonLoading: FC<ButtonLoadingProps> = ({\n className,\n loadingIcon,\n loadingText,\n}) => {\n const css = useMemo(\n (): CSSUIObject => ({\n alignItems: \"center\",\n display: \"flex\",\n fontSize: \"1em\",\n lineHeight: \"normal\",\n position: loadingText ? \"relative\" : \"absolute\",\n }),\n [loadingText],\n )\n\n const element = useMemo(() => {\n if (typeof loadingIcon === \"string\") {\n return <LoadingIcon variant={loadingIcon} color=\"current\" />\n } else {\n return loadingIcon || <LoadingIcon color=\"current\" />\n }\n }, [loadingIcon])\n\n return (\n <ui.div className={cx(\"ui-button__loading\", className)} __css={css}>\n {element}\n </ui.div>\n )\n}\n\nButtonLoading.displayName = \"ButtonLoading\"\nButtonLoading.__ui__ = \"ButtonLoading\"\n\ninterface ButtonContentProps\n extends Pick<\n ButtonProps,\n \"children\" | \"endIcon\" | \"leftIcon\" | \"rightIcon\" | \"startIcon\"\n > {}\n\nconst ButtonContent: FC<ButtonContentProps> = ({\n children,\n endIcon,\n leftIcon,\n rightIcon,\n startIcon,\n}) => {\n startIcon ??= leftIcon\n endIcon ??= rightIcon\n\n return (\n <>\n {startIcon ? <ButtonIcon>{startIcon}</ButtonIcon> : null}\n {children}\n {endIcon ? <ButtonIcon>{endIcon}</ButtonIcon> : null}\n </>\n )\n}\n\nButtonContent.displayName = \"ButtonContent\"\nButtonContent.__ui__ = \"ButtonContent\"\n\ninterface ButtonIconProps extends HTMLUIProps<\"span\"> {}\n\nconst ButtonIcon: FC<ButtonIconProps> = ({ className, children, ...rest }) => {\n return (\n <ui.span\n className={cx(\"ui-button__icon\", className)}\n aria-hidden\n alignSelf=\"center\"\n display=\"inline-flex\"\n flexShrink={0}\n {...rest}\n >\n {children}\n </ui.span>\n )\n}\n\nButtonIcon.displayName = \"ButtonIcon\"\nButtonIcon.__ui__ = \"ButtonIcon\"\n\nexport const useButtonType = (value?: ElementType) => {\n const isButton = useRef(!value)\n\n const ref = useCallback((node: HTMLElement | null) => {\n if (node) isButton.current = node.tagName === \"BUTTON\"\n }, [])\n\n const type = isButton.current ? \"button\" : undefined\n\n return { ref, type } as const\n}\n","import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { createContext, cx, dataAttr } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\n\ninterface ButtonGroupOptions {\n /**\n * If `true`, the borderRadius of button that are direct children will be altered to look flushed together.\n *\n * @default false\n */\n attached?: boolean\n /**\n * The CSS `flex-direction` property.\n */\n direction?: CSSUIObject[\"flexDirection\"]\n /**\n * If `true`, all wrapped button will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the borderRadius of button that are direct children will be altered to look flushed together.\n *\n * @default false\n *\n * @deprecated Use `attached` instead.\n */\n isAttached?: boolean\n /**\n * If `true`, all wrapped button will be disabled.\n *\n * @default false\n *\n * @deprecated Use `disabled` instead.\n */\n isDisabled?: boolean\n}\n\nexport interface ButtonGroupProps\n extends Omit<HTMLUIProps, \"direction\">,\n ThemeProps<\"Button\">,\n ButtonGroupOptions {}\n\ninterface ButtonGroupContext extends ThemeProps<\"Button\"> {\n disabled?: boolean\n}\n\nconst [ButtonGroupProvider, useButtonGroup] = createContext<ButtonGroupContext>(\n {\n name: \"ButtonGroupContext\",\n strict: false,\n },\n)\n\nexport { useButtonGroup }\n\nexport const ButtonGroup = forwardRef<ButtonGroupProps, \"div\">(\n (\n {\n className,\n size,\n variant,\n attached,\n columnGap,\n direction: flexDirection,\n disabled,\n gap,\n isAttached,\n isDisabled,\n rowGap,\n ...rest\n },\n ref,\n ) => {\n const isColumn =\n flexDirection === \"column\" || flexDirection === \"column-reverse\"\n\n attached ??= isAttached\n disabled ??= isDisabled\n\n const css: CSSUIObject = {\n display: \"inline-flex\",\n flexDirection,\n }\n\n const context: ButtonGroupContext = useMemo(\n () => ({ size, variant, disabled }),\n [size, variant, disabled],\n )\n\n if (attached) {\n Object.assign(css, {\n \"> *:first-of-type:not(:last-of-type)\": isColumn\n ? { borderBottomRadius: 0 }\n : { borderRightRadius: 0, borderRightWidth: \"0px\" },\n \"> *:not(:first-of-type):last-of-type\": isColumn\n ? { borderTopRadius: 0, borderTopWidth: \"0px\" }\n : { borderLeftRadius: 0 },\n \"> *:not(:first-of-type):not(:last-of-type)\": isColumn\n ? { borderRadius: 0, borderTopWidth: \"0px\" }\n : { borderRadius: 0, borderRightWidth: \"0px\" },\n })\n } else {\n Object.assign(css, {\n columnGap,\n gap,\n rowGap,\n })\n }\n\n return (\n <ButtonGroupProvider value={context}>\n <ui.div\n ref={ref}\n className={cx(\"ui-button-group\", className)}\n data-attached={dataAttr(attached)}\n role=\"group\"\n __css={css}\n {...rest}\n />\n </ButtonGroupProvider>\n )\n },\n)\n\nButtonGroup.displayName = \"ButtonGroup\"\nButtonGroup.__ui__ = \"ButtonGroup\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAA,eAKO;AACP,qBAAuC;AACvC,oBAAkC;AAClC,IAAAC,gBAA+C;AAC/C,IAAAC,gBAA6C;;;ACX7C,kBAA+B;AAC/B,mBAA4C;AAC5C,mBAAwB;AA+GhB;AAjER,IAAM,CAAC,qBAAqB,cAAc,QAAI;AAAA,EAC5C;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,EACV;AACF;AAIO,IAAM,kBAAc;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,WACJ,kBAAkB,YAAY,kBAAkB;AAElD,6CAAa;AACb,6CAAa;AAEb,UAAM,MAAmB;AAAA,MACvB,SAAS;AAAA,MACT;AAAA,IACF;AAEA,UAAM,cAA8B;AAAA,MAClC,OAAO,EAAE,MAAM,SAAS,SAAS;AAAA,MACjC,CAAC,MAAM,SAAS,QAAQ;AAAA,IAC1B;AAEA,QAAI,UAAU;AACZ,aAAO,OAAO,KAAK;AAAA,QACjB,wCAAwC,WACpC,EAAE,oBAAoB,EAAE,IACxB,EAAE,mBAAmB,GAAG,kBAAkB,MAAM;AAAA,QACpD,wCAAwC,WACpC,EAAE,iBAAiB,GAAG,gBAAgB,MAAM,IAC5C,EAAE,kBAAkB,EAAE;AAAA,QAC1B,8CAA8C,WAC1C,EAAE,cAAc,GAAG,gBAAgB,MAAM,IACzC,EAAE,cAAc,GAAG,kBAAkB,MAAM;AAAA,MACj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AW,UAAU,GAAG,KAAK,MAAM;AAC5E,SACE;AAAA,IAAC,gBAAG;AAAA,IAAH;AAAA,MACC,eAAW,kBAAG,mBAAmB,SAAS;AAAA,MAC1C,eAAW;AAAA,MACX,WAAU;AAAA,MACV,SAAQ;AAAA,MACR,YAAY;AAAA,MACX,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;AAEA,WAAW,cAAc;AACzB,WAAW,SAAS;AAEb,IAAM,gBAAgB,CAAC,UAAwB;AACpD,QAAM,eAAW,sBAAO,CAAC,KAAK;AAE9B,QAAM,UAAM,2BAAY,CAAC,SAA6B;AACpD,QAAI,KAAM,UAAS,UAAU,KAAK,YAAY;AAAA,EAChD,GAAG,CAAC,CAAC;AAEL,QAAM,OAAO,SAAS,UAAU,WAAW;AAE3C,SAAO,EAAE,KAAK,KAAK;AACrB;","names":["import_core","import_utils","import_react","import_jsx_runtime","LoadingIcon"]}
|
package/dist/button.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
Button
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-ZCBY5IMZ.mjs";
|
5
5
|
|
6
6
|
// src/icon-button.tsx
|
7
7
|
import { forwardRef } from "@yamada-ui/core";
|
@@ -27,4 +27,4 @@ IconButton.__ui__ = "IconButton";
|
|
27
27
|
export {
|
28
28
|
IconButton
|
29
29
|
};
|
30
|
-
//# sourceMappingURL=chunk-
|
30
|
+
//# sourceMappingURL=chunk-7PM7PDHG.mjs.map
|
@@ -16,8 +16,10 @@ var ButtonGroup = forwardRef(
|
|
16
16
|
className,
|
17
17
|
size,
|
18
18
|
variant,
|
19
|
+
attached,
|
19
20
|
columnGap,
|
20
21
|
direction: flexDirection,
|
22
|
+
disabled,
|
21
23
|
gap,
|
22
24
|
isAttached,
|
23
25
|
isDisabled,
|
@@ -25,19 +27,21 @@ var ButtonGroup = forwardRef(
|
|
25
27
|
...rest
|
26
28
|
}, ref) => {
|
27
29
|
const isColumn = flexDirection === "column" || flexDirection === "column-reverse";
|
30
|
+
attached != null ? attached : attached = isAttached;
|
31
|
+
disabled != null ? disabled : disabled = isDisabled;
|
28
32
|
const css = {
|
29
33
|
display: "inline-flex",
|
30
34
|
flexDirection
|
31
35
|
};
|
32
36
|
const context = useMemo(
|
33
|
-
() => ({ size, variant,
|
34
|
-
[size, variant,
|
37
|
+
() => ({ size, variant, disabled }),
|
38
|
+
[size, variant, disabled]
|
35
39
|
);
|
36
|
-
if (
|
40
|
+
if (attached) {
|
37
41
|
Object.assign(css, {
|
38
|
-
"> *:first-of-type:not(:last-of-type)": isColumn ? { borderBottomRadius: 0
|
39
|
-
"> *:not(:first-of-type):last-of-type": isColumn ? { borderTopRadius: 0,
|
40
|
-
"> *:not(:first-of-type):not(:last-of-type)": isColumn ? { borderRadius: 0,
|
42
|
+
"> *:first-of-type:not(:last-of-type)": isColumn ? { borderBottomRadius: 0 } : { borderRightRadius: 0, borderRightWidth: "0px" },
|
43
|
+
"> *:not(:first-of-type):last-of-type": isColumn ? { borderTopRadius: 0, borderTopWidth: "0px" } : { borderLeftRadius: 0 },
|
44
|
+
"> *:not(:first-of-type):not(:last-of-type)": isColumn ? { borderRadius: 0, borderTopWidth: "0px" } : { borderRadius: 0, borderRightWidth: "0px" }
|
41
45
|
});
|
42
46
|
} else {
|
43
47
|
Object.assign(css, {
|
@@ -51,7 +55,7 @@ var ButtonGroup = forwardRef(
|
|
51
55
|
{
|
52
56
|
ref,
|
53
57
|
className: cx("ui-button-group", className),
|
54
|
-
"data-attached": dataAttr(
|
58
|
+
"data-attached": dataAttr(attached),
|
55
59
|
role: "group",
|
56
60
|
__css: css,
|
57
61
|
...rest
|
@@ -66,4 +70,4 @@ export {
|
|
66
70
|
useButtonGroup,
|
67
71
|
ButtonGroup
|
68
72
|
};
|
69
|
-
//# sourceMappingURL=chunk-
|
73
|
+
//# sourceMappingURL=chunk-AYY3OFJC.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/button-group.tsx"],"sourcesContent":["import type { CSSUIObject, HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport { forwardRef, ui } from \"@yamada-ui/core\"\nimport { createContext, cx, dataAttr } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\n\ninterface ButtonGroupOptions {\n /**\n * If `true`, the borderRadius of button that are direct children will be altered to look flushed together.\n *\n * @default false\n */\n attached?: boolean\n /**\n * The CSS `flex-direction` property.\n */\n direction?: CSSUIObject[\"flexDirection\"]\n /**\n * If `true`, all wrapped button will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the borderRadius of button that are direct children will be altered to look flushed together.\n *\n * @default false\n *\n * @deprecated Use `attached` instead.\n */\n isAttached?: boolean\n /**\n * If `true`, all wrapped button will be disabled.\n *\n * @default false\n *\n * @deprecated Use `disabled` instead.\n */\n isDisabled?: boolean\n}\n\nexport interface ButtonGroupProps\n extends Omit<HTMLUIProps, \"direction\">,\n ThemeProps<\"Button\">,\n ButtonGroupOptions {}\n\ninterface ButtonGroupContext extends ThemeProps<\"Button\"> {\n disabled?: boolean\n}\n\nconst [ButtonGroupProvider, useButtonGroup] = createContext<ButtonGroupContext>(\n {\n name: \"ButtonGroupContext\",\n strict: false,\n },\n)\n\nexport { useButtonGroup }\n\nexport const ButtonGroup = forwardRef<ButtonGroupProps, \"div\">(\n (\n {\n className,\n size,\n variant,\n attached,\n columnGap,\n direction: flexDirection,\n disabled,\n gap,\n isAttached,\n isDisabled,\n rowGap,\n ...rest\n },\n ref,\n ) => {\n const isColumn =\n flexDirection === \"column\" || flexDirection === \"column-reverse\"\n\n attached ??= isAttached\n disabled ??= isDisabled\n\n const css: CSSUIObject = {\n display: \"inline-flex\",\n flexDirection,\n }\n\n const context: ButtonGroupContext = useMemo(\n () => ({ size, variant, disabled }),\n [size, variant, disabled],\n )\n\n if (attached) {\n Object.assign(css, {\n \"> *:first-of-type:not(:last-of-type)\": isColumn\n ? { borderBottomRadius: 0 }\n : { borderRightRadius: 0, borderRightWidth: \"0px\" },\n \"> *:not(:first-of-type):last-of-type\": isColumn\n ? { borderTopRadius: 0, borderTopWidth: \"0px\" }\n : { borderLeftRadius: 0 },\n \"> *:not(:first-of-type):not(:last-of-type)\": isColumn\n ? { borderRadius: 0, borderTopWidth: \"0px\" }\n : { borderRadius: 0, borderRightWidth: \"0px\" },\n })\n } else {\n Object.assign(css, {\n columnGap,\n gap,\n rowGap,\n })\n }\n\n return (\n <ButtonGroupProvider value={context}>\n <ui.div\n ref={ref}\n className={cx(\"ui-button-group\", className)}\n data-attached={dataAttr(attached)}\n role=\"group\"\n __css={css}\n {...rest}\n />\n </ButtonGroupProvider>\n )\n },\n)\n\nButtonGroup.displayName = \"ButtonGroup\"\nButtonGroup.__ui__ = \"ButtonGroup\"\n"],"mappings":";;;AACA,SAAS,YAAY,UAAU;AAC/B,SAAS,eAAe,IAAI,gBAAgB;AAC5C,SAAS,eAAe;AA+GhB;AAjER,IAAM,CAAC,qBAAqB,cAAc,IAAI;AAAA,EAC5C;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;AAAA,EACV;AACF;AAIO,IAAM,cAAc;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,WACJ,kBAAkB,YAAY,kBAAkB;AAElD,6CAAa;AACb,6CAAa;AAEb,UAAM,MAAmB;AAAA,MACvB,SAAS;AAAA,MACT;AAAA,IACF;AAEA,UAAM,UAA8B;AAAA,MAClC,OAAO,EAAE,MAAM,SAAS,SAAS;AAAA,MACjC,CAAC,MAAM,SAAS,QAAQ;AAAA,IAC1B;AAEA,QAAI,UAAU;AACZ,aAAO,OAAO,KAAK;AAAA,QACjB,wCAAwC,WACpC,EAAE,oBAAoB,EAA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