@aristobyte-ui/button 1.0.112 → 2.1.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/dist/index.mjs DELETED
@@ -1,154 +0,0 @@
1
- "use client";
2
-
3
- // components/Button.tsx
4
- import * as React from "react";
5
-
6
- // ../../node_modules/clsx/dist/clsx.mjs
7
- function r(e) {
8
- var t, f, n = "";
9
- if ("string" == typeof e || "number" == typeof e) n += e;
10
- else if ("object" == typeof e) if (Array.isArray(e)) {
11
- var o = e.length;
12
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
13
- } else for (f in e) e[f] && (n && (n += " "), n += f);
14
- return n;
15
- }
16
- function clsx() {
17
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
18
- return n;
19
- }
20
- var clsx_default = clsx;
21
-
22
- // components/Button.tsx
23
- import { Spinner } from "@aristobyte-ui/spinner";
24
- import { renderRipple } from "@aristobyte-ui/utils";
25
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
26
- var Button = ({
27
- onClick,
28
- text = "",
29
- href = "",
30
- target = "_self",
31
- children = "",
32
- type = "button",
33
- variant = "default",
34
- appearance = "solid",
35
- size = "md",
36
- radius = "md",
37
- icon,
38
- spinnerType = "default",
39
- transparent = false,
40
- isLoading = false,
41
- disabled = false,
42
- className = "",
43
- style = {}
44
- }) => {
45
- const uniqueId = React.useId();
46
- const ref = React.useRef(null);
47
- const handleClick = (e) => {
48
- const { clientX, clientY } = e;
49
- renderRipple({ ref, clientX, clientY });
50
- onClick == null ? void 0 : onClick(e);
51
- };
52
- const buttonClasses = clsx_default(
53
- "button",
54
- transparent && "button-transparent",
55
- `button-${variant}-${appearance}`,
56
- `button-${size}`,
57
- `button-radius-${radius}`,
58
- isLoading && "button-loading",
59
- className
60
- );
61
- const renderContent = () => /* @__PURE__ */ jsxs(Fragment, { children: [
62
- isLoading && /* @__PURE__ */ jsx(
63
- Spinner,
64
- {
65
- size,
66
- variant,
67
- type: spinnerType,
68
- className: "inline-block"
69
- }
70
- ),
71
- icon && /* @__PURE__ */ jsx(
72
- "span",
73
- {
74
- className: clsx_default(
75
- "button-icon",
76
- icon.align === "right" && "button-icon-right"
77
- ),
78
- children: icon.component({ color: icon.color, size: icon.size })
79
- }
80
- ),
81
- text || children
82
- ] });
83
- if (type === "link") {
84
- return /* @__PURE__ */ jsx(
85
- "a",
86
- {
87
- ref,
88
- href,
89
- target,
90
- style,
91
- className: buttonClasses,
92
- onClick: handleClick,
93
- children: renderContent()
94
- },
95
- uniqueId
96
- );
97
- }
98
- return /* @__PURE__ */ jsx(
99
- "button",
100
- {
101
- ref,
102
- type: "button",
103
- disabled: disabled || isLoading,
104
- style,
105
- className: buttonClasses,
106
- onClick: handleClick,
107
- children: renderContent()
108
- },
109
- uniqueId
110
- );
111
- };
112
-
113
- // components/ButtonGroup.tsx
114
- import * as React2 from "react";
115
- import { jsx as jsx2 } from "react/jsx-runtime";
116
- import { createElement } from "react";
117
- var ButtonGroup = ({
118
- children,
119
- align = "horizontal",
120
- variant = "default",
121
- size = "md",
122
- radius = "md",
123
- disabled = false,
124
- className = "",
125
- style = {}
126
- }) => {
127
- const groupClasses = clsx_default(
128
- "button-group",
129
- `button-group-${align}`,
130
- `button-group-variant-${variant}`,
131
- `button-group-radius-${radius}`,
132
- `button-group-size-${size}`,
133
- className
134
- );
135
- const buttons = React2.Children.toArray(
136
- children
137
- );
138
- return /* @__PURE__ */ jsx2("div", { className: groupClasses, style, children: buttons.map(({ props }, index) => /* @__PURE__ */ createElement(
139
- Button,
140
- {
141
- ...props,
142
- key: index,
143
- size: props.size || size,
144
- disabled: props.disabled || disabled,
145
- variant: props.variant || variant,
146
- radius: "none"
147
- }
148
- )) });
149
- };
150
- export {
151
- Button,
152
- ButtonGroup
153
- };
154
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../components/Button.tsx","../../../node_modules/clsx/dist/clsx.mjs","../components/ButtonGroup.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport clsx from \"clsx\";\nimport { Spinner } from \"@aristobyte-ui/spinner\";\nimport { type IconPropsType, renderRipple } from \"@aristobyte-ui/utils\";\n\nexport interface IButton {\n type?: \"button\" | \"link\";\n text?: string;\n children?: React.ReactNode;\n href?: string;\n target?: \"_self\" | \"_blank\" | \"_parent\" | \"_top\";\n onClick?: (\n e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>\n ) => void | Promise<void>;\n disabled?: boolean;\n transparent?: boolean;\n variant?:\n | \"default\"\n | \"primary\"\n | \"secondary\"\n | \"success\"\n | \"error\"\n | \"warning\";\n appearance?:\n | \"solid\"\n | \"outline\"\n | \"outline-dashed\"\n | \"no-outline\"\n | \"glowing\";\n size?: \"xsm\" | \"sm\" | \"md\" | \"lg\" | \"xlg\";\n radius?: \"none\" | \"sm\" | \"md\" | \"lg\" | \"full\";\n icon?: {\n component: (props: IconPropsType) => React.ReactElement;\n color?: string;\n size?: number;\n align?: \"left\" | \"right\";\n };\n isLoading?: boolean;\n spinnerType?: \"default\" | \"duo\" | \"gradient\" | \"pulse\" | \"pulse-duo\";\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport const Button: React.FC<IButton> = ({\n onClick,\n text = \"\",\n href = \"\",\n target = \"_self\",\n children = \"\",\n type = \"button\",\n variant = \"default\",\n appearance = \"solid\",\n size = \"md\",\n radius = \"md\",\n icon,\n spinnerType = \"default\",\n transparent = false,\n isLoading = false,\n disabled = false,\n className = \"\",\n style = {},\n}) => {\n const uniqueId = React.useId();\n const ref = React.useRef<HTMLButtonElement | HTMLAnchorElement>(null);\n\n const handleClick = (\n e: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>\n ) => {\n const { clientX, clientY } = e;\n renderRipple({ ref, clientX, clientY });\n onClick?.(e);\n };\n\n const buttonClasses = clsx(\n \"button\",\n transparent && \"button-transparent\",\n `button-${variant}-${appearance}`,\n `button-${size}`,\n `button-radius-${radius}`,\n isLoading && \"button-loading\",\n className\n );\n\n const renderContent = () => (\n <>\n {isLoading && (\n <Spinner\n size={size}\n variant={variant}\n type={spinnerType}\n className=\"inline-block\"\n />\n )}\n {icon && (\n <span\n className={clsx(\n \"button-icon\",\n icon.align === \"right\" && \"button-icon-right\"\n )}\n >\n {icon.component({ color: icon.color, size: icon.size })}\n </span>\n )}\n {text || children}\n </>\n );\n\n if (type === \"link\") {\n return (\n <a\n key={uniqueId}\n ref={ref as React.RefObject<HTMLAnchorElement>}\n href={href}\n target={target}\n style={style}\n className={buttonClasses}\n onClick={handleClick}\n >\n {renderContent()}\n </a>\n );\n }\n\n return (\n <button\n key={uniqueId}\n ref={ref as React.RefObject<HTMLButtonElement>}\n type=\"button\"\n disabled={disabled || isLoading}\n style={style}\n className={buttonClasses}\n onClick={handleClick}\n >\n {renderContent()}\n </button>\n );\n};\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","\"use client\";\n\nimport * as React from \"react\";\nimport { type IButton, Button } from \"./Button\";\nimport clsx from \"clsx\";\n\nexport interface IButtonGroup {\n children:\n | React.ReactElement<IButton, typeof Button>\n | React.ReactElement<IButton, typeof Button>[];\n align?: \"vertical\" | \"horizontal\";\n variant?:\n | \"default\"\n | \"primary\"\n | \"secondary\"\n | \"success\"\n | \"error\"\n | \"warning\";\n size?: \"xsm\" | \"sm\" | \"md\" | \"lg\" | \"xlg\";\n radius?: \"none\" | \"sm\" | \"md\" | \"lg\" | \"full\";\n disabled?: boolean;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport const ButtonGroup: React.FC<IButtonGroup> = ({\n children,\n align = \"horizontal\",\n variant = \"default\",\n size = \"md\",\n radius = \"md\",\n disabled = false,\n className = \"\",\n style = {},\n}) => {\n const groupClasses = clsx(\n \"button-group\",\n `button-group-${align}`,\n `button-group-variant-${variant}`,\n `button-group-radius-${radius}`,\n `button-group-size-${size}`,\n className\n );\n\n const buttons = React.Children.toArray(\n children\n ) as React.ReactElement<IButton>[];\n\n return (\n <div className={groupClasses} style={style}>\n {buttons.map(({ props }, index) => (\n <Button\n {...props}\n key={index}\n size={props.size || size}\n disabled={props.disabled || disabled}\n variant={props.variant || variant}\n radius=\"none\"\n />\n ))}\n </div>\n );\n};\n"],"mappings":";;;AAEA,YAAY,WAAW;;;ACFvB,SAAS,EAAE,GAAE;AAAC,MAAI,GAAE,GAAE,IAAE;AAAG,MAAG,YAAU,OAAO,KAAG,YAAU,OAAO,EAAE,MAAG;AAAA,WAAU,YAAU,OAAO,EAAE,KAAG,MAAM,QAAQ,CAAC,GAAE;AAAC,QAAI,IAAE,EAAE;AAAO,SAAI,IAAE,GAAE,IAAE,GAAE,IAAI,GAAE,CAAC,MAAI,IAAE,EAAE,EAAE,CAAC,CAAC,OAAK,MAAI,KAAG,MAAK,KAAG;AAAA,EAAE,MAAM,MAAI,KAAK,EAAE,GAAE,CAAC,MAAI,MAAI,KAAG,MAAK,KAAG;AAAG,SAAO;AAAC;AAAQ,SAAS,OAAM;AAAC,WAAQ,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,IAAI,EAAC,IAAE,UAAU,CAAC,OAAK,IAAE,EAAE,CAAC,OAAK,MAAI,KAAG,MAAK,KAAG;AAAG,SAAO;AAAC;AAAC,IAAO,eAAQ;;;ADI/X,SAAS,eAAe;AACxB,SAA6B,oBAAoB;AAiF7C,mBAEI,KAFJ;AAzCG,IAAM,SAA4B,CAAC;AA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