@oneplatformdev/ui 0.1.99-beta.4 → 0.1.99-beta.5
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/Button/Button.d.ts +1 -7
- package/Button/Button.d.ts.map +1 -1
- package/Button/Button.js.map +1 -1
- package/Button/Button.stories.js +45 -53
- package/Button/Button.stories.js.map +1 -1
- package/Button/Button.types.d.ts +2 -1
- package/Button/Button.types.d.ts.map +1 -1
- package/ButtonIcon/ButtonIcon.d.ts +26 -20
- package/ButtonIcon/ButtonIcon.d.ts.map +1 -1
- package/ButtonIcon/ButtonIcon.js +44 -40
- package/ButtonIcon/ButtonIcon.js.map +1 -1
- package/ButtonIcon/ButtonIcon.stories.js +89 -73
- package/ButtonIcon/ButtonIcon.stories.js.map +1 -1
- package/ButtonIcon/ButtonIcon.types.d.ts +2 -1
- package/ButtonIcon/ButtonIcon.types.d.ts.map +1 -1
- package/CHANGELOG.md +8 -0
- package/package.json +7 -4
- package/Button/Button.s.d.ts +0 -83
- package/Button/Button.s.d.ts.map +0 -1
- package/Button/Button.s.js +0 -163
- package/Button/Button.s.js.map +0 -1
package/Button/Button.d.ts
CHANGED
|
@@ -51,18 +51,12 @@ import * as React from "react";
|
|
|
51
51
|
* ```tsx
|
|
52
52
|
* <Button disabled>Disabled</Button>
|
|
53
53
|
* ```
|
|
54
|
-
* > With custom variant props (CVA powered):
|
|
55
|
-
* ```tsx
|
|
56
|
-
* <Button variant="primary" color="blue" size="md">
|
|
57
|
-
* Save
|
|
58
|
-
* </Button>
|
|
59
|
-
* ```
|
|
60
54
|
*
|
|
61
55
|
* @remarks
|
|
62
56
|
* - Designed for texted usage. If you need icon-only, use `ButtonIcon`.
|
|
63
57
|
* - Works with any SVG React component or element, e.g. lucide-react, heroicons, custom icons.
|
|
64
58
|
*
|
|
65
|
-
* @see {@link
|
|
59
|
+
* @see {@link Button} for regular text buttons
|
|
66
60
|
*/
|
|
67
61
|
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
68
62
|
export default Button;
|
package/Button/Button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAqDxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,eAAO,MAAM,MAAM,uFAuElB,CAAA;AAED,eAAe,MAAM,CAAC"}
|
package/Button/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../src/Button/Button.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\n\nimport { cn } from \"@oneplatformdev/utils\"\nimport { ButtonCVAProps, buttonVariants } from './buttonVariants';\nimport { ButtonAdornmentProps, type ButtonProps } from './Button.types';\n\nimport { Tooltip } from '../Tooltip';\nimport { LoadedIcon } from \"../LoadedIcon\";\nimport { createElement, isValidElement } from \"react\";\n\nconst normalizedVariantProperties = (props: ButtonCVAProps): ButtonCVAProps => {\n const { variant, size, color } = props;\n const vls = { color, variant, size }\n if (variant === 'default') {\n console.warn('Button variant \"default\" is deprecated. Please use \"variant=contained color=primary\" instead.')\n vls.variant = 'contained'\n vls.color = 'primary'\n return vls\n }\n if ((size as string) === 'icon') {\n console.warn('Button size \"icon\" is deprecated. Please use \"<ButtonIcon/>\" component instead.')\n vls.variant = 'contained'\n vls.color = 'secondary'\n return vls\n // throw new Error('Button variant \"transparent\" is removed. Please use \"variant=none\" instead.')\n }\n if ((variant as string) === 'transparent') {\n console.warn('Button variant \"transparent\" is removed. Please use \"variant=none\" instead.')\n throw new Error('Button variant \"transparent\" is removed. Please use \"variant=none\" instead.')\n }\n if (variant === 'outline') {\n console.warn('Button variant \"outline\" is deprecated. Please use \"variant=outlined color=primary\" instead.')\n vls.variant = 'outlined'\n vls.color = 'primary'\n return vls\n }\n if (variant === 'secondary') {\n console.warn('Button variant \"secondary\" is deprecated. Please use \"variant=contained color=secondary\" instead.')\n vls.variant = 'contained'\n vls.color = 'secondary'\n return vls\n }\n if (variant === 'destructive') {\n console.warn('Button variant \"destructive\" is deprecated. Please use \"variant=contained color=error\" instead.')\n vls.variant = 'contained'\n vls.color = 'error'\n return vls\n }\n return vls;\n}\n\
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../src/Button/Button.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { Slot } from \"@radix-ui/react-slot\"\n\nimport { cn } from \"@oneplatformdev/utils\"\nimport { ButtonCVAProps, buttonVariants } from './buttonVariants';\nimport { ButtonAdornmentProps, type ButtonProps } from './Button.types';\n\nimport { Tooltip } from '../Tooltip';\nimport { LoadedIcon } from \"../LoadedIcon\";\nimport { createElement, isValidElement } from \"react\";\n\nconst normalizedVariantProperties = (props: ButtonCVAProps): ButtonCVAProps => {\n const { variant, size, color } = props;\n const vls = { color, variant, size }\n if (variant === 'default') {\n console.warn('Button variant \"default\" is deprecated. Please use \"variant=contained color=primary\" instead.')\n vls.variant = 'contained'\n vls.color = 'primary'\n return vls\n }\n if ((size as string) === 'icon') {\n console.warn('Button size \"icon\" is deprecated. Please use \"<ButtonIcon/>\" component instead.')\n vls.variant = 'contained'\n vls.color = 'secondary'\n return vls\n // throw new Error('Button variant \"transparent\" is removed. Please use \"variant=none\" instead.')\n }\n if ((variant as string) === 'transparent') {\n console.warn('Button variant \"transparent\" is removed. Please use \"variant=none\" instead.')\n throw new Error('Button variant \"transparent\" is removed. Please use \"variant=none\" instead.')\n }\n if (variant === 'outline') {\n console.warn('Button variant \"outline\" is deprecated. Please use \"variant=outlined color=primary\" instead.')\n vls.variant = 'outlined'\n vls.color = 'primary'\n return vls\n }\n if (variant === 'secondary') {\n console.warn('Button variant \"secondary\" is deprecated. Please use \"variant=contained color=secondary\" instead.')\n vls.variant = 'contained'\n vls.color = 'secondary'\n return vls\n }\n if (variant === 'destructive') {\n console.warn('Button variant \"destructive\" is deprecated. Please use \"variant=contained color=error\" instead.')\n vls.variant = 'contained'\n vls.color = 'error'\n return vls\n }\n return vls;\n}\n\nconst renderAdornment = (Adornment?: ButtonAdornmentProps) => {\n if (!Adornment) return null;\n if (isValidElement(Adornment)) return Adornment;\n return createElement(Adornment);\n};\n\n/**\n * Universal Button component used for triggering actions and UI interactions.\n * Supports variants, sizes, colors, start/end icon adornments, custom slot content,\n * tooltip integration, loading state, and polymorphic rendering via `asChild`.\n *\n * @public\n * @see [Documentation](#) // TODO: add link to docs\n *\n * @example\n * > Import:\n * ```tsx\n * import { Button } from '@oneplatformdev/ui/Button';\n * ```\n * > Basic usage:\n * ```tsx\n * <Button>Click me</Button>\n * ```\n * > Variant and size:\n * ```tsx\n * <Button variant=\"outline\" size=\"lg\">Large Button</Button>\n * ```\n * > With icons:\n * ```tsx\n * <Button startAdornment={<PlusIcon />}>Create</Button>\n * <Button endAdornment={<ArrowRightIcon />}>Next</Button>\n * ```\n * > Icon style button:\n * ```tsx\n * <Button size=\"icon\">\n * <PlusIcon />\n * </Button>\n * ```\n * > Polymorphic rendering (`asChild`):\n * ```tsx\n * <Button asChild>\n * <a href=\"/dashboard\">Go to Dashboard</a>\n * </Button>\n * ```\n * > Tooltip via `message` or native `title`:\n * ```tsx\n * <Button title=\"Tooltip text\">Hover me</Button>\n * <Button message=\"Tooltip content\">Hover me</Button>\n * ```\n * > Loading state:\n * ```tsx\n * <Button loading>Processing...</Button>\n * ```\n * > Disabled:\n * ```tsx\n * <Button disabled>Disabled</Button>\n * ```\n *\n * @remarks\n * - Designed for texted usage. If you need icon-only, use `ButtonIcon`.\n * - Works with any SVG React component or element, e.g. lucide-react, heroicons, custom icons.\n *\n * @see {@link Button} for regular text buttons\n */\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (props, ref) => {\n const {\n disabled,\n className,\n variant,\n color,\n size,\n asChild = false,\n title = '',\n tooltip,\n tooltipProps = {},\n message,\n loading = false,\n children,\n startAdornment,\n endAdornment,\n ...rest\n } = props;\n const Comp = asChild ? Slot : \"button\"\n const msg = message || tooltip || title;\n\n const content = asChild\n ? children\n : (\n <>\n {!!startAdornment && (\n <LoadedIcon loading={loading} size={size}>\n {renderAdornment(startAdornment)}\n </LoadedIcon>\n )}\n\n {children}\n\n {!!endAdornment && (\n <LoadedIcon loading={loading} size={size}>\n {renderAdornment(endAdornment)}\n </LoadedIcon>\n )}\n </>\n )\n\n const cmp = (\n <Comp\n type='button'\n ref={ref}\n disabled={disabled}\n className={cn(\n buttonVariants({\n ...normalizedVariantProperties({ variant, size, color }),\n className\n }),\n loading && 'pointer-events-none opacity-80 user-select-none',\n )}\n {...rest}\n >\n {content}\n </Comp>\n )\n\n if (!msg) return cmp\n return (\n <Tooltip\n {...(tooltipProps || {})}\n open={tooltipProps.open ?? (disabled || loading || !msg) ? false : undefined}\n message={msg}\n >\n {cmp}\n </Tooltip>\n )\n }\n)\nButton.displayName = \"Button\"\nexport default Button;\n"],"names":["normalizedVariantProperties","props","variant","size","color","vls","renderAdornment","Adornment","isValidElement","createElement","Button","React","ref","disabled","className","asChild","title","tooltip","tooltipProps","message","loading","children","startAdornment","endAdornment","rest","Comp","Slot","msg","content","jsxs","Fragment","jsx","LoadedIcon","cmp","cn","buttonVariants","Tooltip"],"mappings":";;;;;;;;;AAWA,MAAMA,IAA8B,CAACC,MAA0C;AAC7E,QAAM,EAAE,SAAAC,GAAS,MAAAC,GAAM,OAAAC,EAAA,IAAU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EAAW,SAAAZ,GAAkB,MAAAjB,GAC3B,UAAAG,EAAgBgB,CAAc,GACjC;AAAA,MAGDD;AAAA,MAEA,CAAC,CAACE,KACD,gBAAAQ,EAACC,KAAW,SAAAZ,GAAkB,MAAAjB,GAC3B,UAAAG,EAAgBiB,CAAY,EAAA,CAC/B;AAAA,IAAA,GAEJ,GAGEU,IACJ,gBAAAF;AAAA,MAACN;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,KAAAb;AAAA,QACA,UAAAC;AAAA,QACA,WAAWqB;AAAA,UACTC,EAAe;AAAA,YACb,GAAGnC,EAA4B,EAAE,SAAAE,GAAS,MAAAC,GAAM,OAAAC,GAAO;AAAA,YACvD,WAAAU;AAAA,UAAA,CACD;AAAA,UACDM,KAAW;AAAA,QAAA;AAAA,QAEZ,GAAGI;AAAA,QAEH,UAAAI;AAAA,MAAA;AAAA,IAAA;AAIL,WAAKD,IAEH,gBAAAI;AAAA,MAACK;AAAA,MAAA;AAAA,QACE,GAAIlB,KAAgB,CAAA;AAAA,QACrB,MAAMA,EAAa,SAASL,KAAYO,KAAW,CAACO,KAAO,KAAQ;AAAA,QACnE,SAASA;AAAA,QAER,UAAAM;AAAA,MAAA;AAAA,IAAA,IAPYA;AAAA,EAUnB;AACF;AACAvB,EAAO,cAAc;"}
|
package/Button/Button.stories.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as t, jsxs as i } from "react/jsx-runtime";
|
|
2
|
-
import { Button as
|
|
2
|
+
import { Button as o } from "./Button.js";
|
|
3
3
|
import { FileDownIcon as m, Trash2Icon as p, PlusIcon as n } from "lucide-react";
|
|
4
4
|
import { DashedWrapper as a } from "../.storybook/Wrappers.js";
|
|
5
|
-
const r = (
|
|
5
|
+
const r = (e) => /* @__PURE__ */ t(
|
|
6
6
|
"div",
|
|
7
7
|
{
|
|
8
8
|
style: {
|
|
@@ -12,13 +12,13 @@ const r = (o) => /* @__PURE__ */ t(
|
|
|
12
12
|
gap: "16px"
|
|
13
13
|
},
|
|
14
14
|
children: ["default", "hover", "focus", "active", "disabled", "loading"].map((l) => /* @__PURE__ */ t(
|
|
15
|
-
|
|
15
|
+
o,
|
|
16
16
|
{
|
|
17
17
|
id: l,
|
|
18
|
-
...
|
|
19
|
-
disabled: l === "disabled" ||
|
|
20
|
-
loading: l === "loading" ||
|
|
21
|
-
children:
|
|
18
|
+
...e,
|
|
19
|
+
disabled: l === "disabled" || e.disabled,
|
|
20
|
+
loading: l === "loading" || e.loading,
|
|
21
|
+
children: e.children
|
|
22
22
|
},
|
|
23
23
|
l
|
|
24
24
|
))
|
|
@@ -32,10 +32,8 @@ const r = (o) => /* @__PURE__ */ t(
|
|
|
32
32
|
Trash2Icon: p,
|
|
33
33
|
FileDownIcon: m
|
|
34
34
|
}, d = {
|
|
35
|
-
// title: 'Components/Button/Button',
|
|
36
|
-
// title: 'ui/Button',
|
|
37
35
|
title: "Button",
|
|
38
|
-
component:
|
|
36
|
+
component: o,
|
|
39
37
|
// render: Template,
|
|
40
38
|
args: {
|
|
41
39
|
tooltip: void 0,
|
|
@@ -58,7 +56,7 @@ const r = (o) => /* @__PURE__ */ t(
|
|
|
58
56
|
control: !1
|
|
59
57
|
},
|
|
60
58
|
asChild: {
|
|
61
|
-
name: "
|
|
59
|
+
name: "asChild",
|
|
62
60
|
description: "Button asChild from ButtonProps [boolean]",
|
|
63
61
|
control: !1
|
|
64
62
|
},
|
|
@@ -115,13 +113,7 @@ const r = (o) => /* @__PURE__ */ t(
|
|
|
115
113
|
control: { type: "object" }
|
|
116
114
|
}
|
|
117
115
|
},
|
|
118
|
-
tags: ["autodocs"],
|
|
119
116
|
parameters: {
|
|
120
|
-
docs: {
|
|
121
|
-
description: {
|
|
122
|
-
component: "Universal button component with variants, icons and tooltip support."
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
117
|
pseudo: {
|
|
126
118
|
hover: "#hover",
|
|
127
119
|
focus: "#focus",
|
|
@@ -140,11 +132,11 @@ const r = (o) => /* @__PURE__ */ t(
|
|
|
140
132
|
children: "_children_"
|
|
141
133
|
}
|
|
142
134
|
}, x = {
|
|
143
|
-
render: (
|
|
144
|
-
/* @__PURE__ */ t(
|
|
145
|
-
/* @__PURE__ */ t(
|
|
146
|
-
/* @__PURE__ */ t(
|
|
147
|
-
/* @__PURE__ */ t(
|
|
135
|
+
render: (e) => /* @__PURE__ */ i(a, { children: [
|
|
136
|
+
/* @__PURE__ */ t(o, { ...e }),
|
|
137
|
+
/* @__PURE__ */ t(o, { ...e, startAdornment: /* @__PURE__ */ t(n, {}) }),
|
|
138
|
+
/* @__PURE__ */ t(o, { ...e, startAdornment: /* @__PURE__ */ t(n, {}), endAdornment: /* @__PURE__ */ t(n, {}) }),
|
|
139
|
+
/* @__PURE__ */ t(o, { ...e, endAdornment: /* @__PURE__ */ t(n, {}) })
|
|
148
140
|
] }),
|
|
149
141
|
args: {
|
|
150
142
|
...d.args,
|
|
@@ -152,59 +144,59 @@ const r = (o) => /* @__PURE__ */ t(
|
|
|
152
144
|
children: "disabled"
|
|
153
145
|
}
|
|
154
146
|
}, S = {
|
|
155
|
-
render: (
|
|
156
|
-
/* @__PURE__ */ t(
|
|
157
|
-
/* @__PURE__ */ t(
|
|
158
|
-
/* @__PURE__ */ t(
|
|
159
|
-
/* @__PURE__ */ t(
|
|
147
|
+
render: (e) => /* @__PURE__ */ i(a, { children: [
|
|
148
|
+
/* @__PURE__ */ t(o, { ...e }),
|
|
149
|
+
/* @__PURE__ */ t(o, { ...e, startAdornment: /* @__PURE__ */ t(n, {}) }),
|
|
150
|
+
/* @__PURE__ */ t(o, { ...e, startAdornment: /* @__PURE__ */ t(n, {}), endAdornment: /* @__PURE__ */ t(n, {}) }),
|
|
151
|
+
/* @__PURE__ */ t(o, { ...e, endAdornment: /* @__PURE__ */ t(n, {}) })
|
|
160
152
|
] }),
|
|
161
153
|
args: {
|
|
162
154
|
children: "Loading…",
|
|
163
155
|
loading: !0
|
|
164
156
|
}
|
|
165
157
|
}, G = {
|
|
166
|
-
render: (
|
|
158
|
+
render: (e) => /* @__PURE__ */ t(a, { children: /* @__PURE__ */ i("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
167
159
|
/* @__PURE__ */ t(
|
|
168
|
-
|
|
160
|
+
o,
|
|
169
161
|
{
|
|
170
|
-
...
|
|
162
|
+
...e,
|
|
171
163
|
title: "delayDuration: 0",
|
|
172
164
|
tooltipProps: { delayDuration: 0 },
|
|
173
165
|
children: "delayDuration: 0"
|
|
174
166
|
}
|
|
175
167
|
),
|
|
176
168
|
/* @__PURE__ */ t(
|
|
177
|
-
|
|
169
|
+
o,
|
|
178
170
|
{
|
|
179
|
-
...
|
|
171
|
+
...e,
|
|
180
172
|
title: "delayDuration: 300 [default]",
|
|
181
173
|
tooltipProps: { delayDuration: 300 },
|
|
182
174
|
children: "delayDuration: 300"
|
|
183
175
|
}
|
|
184
176
|
),
|
|
185
177
|
/* @__PURE__ */ t(
|
|
186
|
-
|
|
178
|
+
o,
|
|
187
179
|
{
|
|
188
|
-
...
|
|
180
|
+
...e,
|
|
189
181
|
title: "delayDuration: 700",
|
|
190
182
|
tooltipProps: { delayDuration: 700 },
|
|
191
183
|
children: "delayDuration: 700"
|
|
192
184
|
}
|
|
193
185
|
),
|
|
194
|
-
/* @__PURE__ */ t(
|
|
195
|
-
/* @__PURE__ */ t(
|
|
186
|
+
/* @__PURE__ */ t(o, { ...e, title: "title_string", children: "title" }),
|
|
187
|
+
/* @__PURE__ */ t(o, { ...e, message: "message_string", children: "message: string" }),
|
|
196
188
|
/* @__PURE__ */ t(
|
|
197
|
-
|
|
189
|
+
o,
|
|
198
190
|
{
|
|
199
|
-
...
|
|
191
|
+
...e,
|
|
200
192
|
message: /* @__PURE__ */ t("span", { children: "message_node_span" }),
|
|
201
193
|
children: "message: ReactNode"
|
|
202
194
|
}
|
|
203
195
|
),
|
|
204
196
|
/* @__PURE__ */ t(
|
|
205
|
-
|
|
197
|
+
o,
|
|
206
198
|
{
|
|
207
|
-
...
|
|
199
|
+
...e,
|
|
208
200
|
message: "message_string",
|
|
209
201
|
tooltipProps: {
|
|
210
202
|
showQuestionMark: !0
|
|
@@ -212,7 +204,7 @@ const r = (o) => /* @__PURE__ */ t(
|
|
|
212
204
|
children: "showQuestionMark: true"
|
|
213
205
|
}
|
|
214
206
|
)
|
|
215
|
-
] }),
|
|
207
|
+
] }) }),
|
|
216
208
|
args: {
|
|
217
209
|
children: "tooltips",
|
|
218
210
|
tooltipProps: {
|
|
@@ -230,10 +222,10 @@ const r = (o) => /* @__PURE__ */ t(
|
|
|
230
222
|
variant: { control: !1 },
|
|
231
223
|
color: { control: !1 }
|
|
232
224
|
},
|
|
233
|
-
render: (
|
|
234
|
-
/* @__PURE__ */ t(r, { ...
|
|
235
|
-
/* @__PURE__ */ t(r, { ...
|
|
236
|
-
/* @__PURE__ */ t(r, { ...
|
|
225
|
+
render: (e) => /* @__PURE__ */ t("div", { className: "flex", children: /* @__PURE__ */ i(a, { children: [
|
|
226
|
+
/* @__PURE__ */ t(r, { ...e, variant: "contained" }),
|
|
227
|
+
/* @__PURE__ */ t(r, { ...e, variant: "outlined" }),
|
|
228
|
+
/* @__PURE__ */ t(r, { ...e, variant: "ghost" })
|
|
237
229
|
] }) })
|
|
238
230
|
}, T = {
|
|
239
231
|
args: {
|
|
@@ -246,10 +238,10 @@ const r = (o) => /* @__PURE__ */ t(
|
|
|
246
238
|
variant: { control: !1 },
|
|
247
239
|
color: { control: !1 }
|
|
248
240
|
},
|
|
249
|
-
render: (
|
|
250
|
-
/* @__PURE__ */ t(r, { ...
|
|
251
|
-
/* @__PURE__ */ t(r, { ...
|
|
252
|
-
/* @__PURE__ */ t(r, { ...
|
|
241
|
+
render: (e) => /* @__PURE__ */ t("div", { className: "flex", children: /* @__PURE__ */ i(a, { children: [
|
|
242
|
+
/* @__PURE__ */ t(r, { ...e, variant: "contained" }),
|
|
243
|
+
/* @__PURE__ */ t(r, { ...e, variant: "outlined" }),
|
|
244
|
+
/* @__PURE__ */ t(r, { ...e, variant: "ghost" })
|
|
253
245
|
] }) })
|
|
254
246
|
}, _ = {
|
|
255
247
|
args: {
|
|
@@ -262,10 +254,10 @@ const r = (o) => /* @__PURE__ */ t(
|
|
|
262
254
|
variant: { control: !1 },
|
|
263
255
|
color: { control: !1 }
|
|
264
256
|
},
|
|
265
|
-
render: (
|
|
266
|
-
/* @__PURE__ */ t(r, { ...
|
|
267
|
-
/* @__PURE__ */ t(r, { ...
|
|
268
|
-
/* @__PURE__ */ t(r, { ...
|
|
257
|
+
render: (e) => /* @__PURE__ */ t("div", { className: "flex", children: /* @__PURE__ */ i(a, { children: [
|
|
258
|
+
/* @__PURE__ */ t(r, { ...e, variant: "contained" }),
|
|
259
|
+
/* @__PURE__ */ t(r, { ...e, variant: "outlined" }),
|
|
260
|
+
/* @__PURE__ */ t(r, { ...e, variant: "ghost" })
|
|
269
261
|
] }) })
|
|
270
262
|
};
|
|
271
263
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.stories.js","sources":["../../src/Button/Button.stories.tsx"],"sourcesContent":["import type { Meta, StoryObj } from '@storybook/react';\n\nimport { Button } from './Button';\nimport { ButtonProps } from './Button.types';\nimport React from 'react';\nimport { PlusIcon, Trash2Icon, FileDownIcon } from 'lucide-react';\nimport { DashedWrapper } from \"../../.storybook/Wrappers\";\n\nconst States = (props: ButtonProps) => (\n <div\n style={{\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: '16px',\n }}\n >\n {[ 'default', 'hover', 'focus', 'active', 'disabled', 'loading' ]\n .map((state) => (\n <Button\n key={state}\n id={state}\n {...props}\n disabled={state === 'disabled' || props.disabled}\n loading={state === 'loading' || props.loading}\n >\n {props.children}\n </Button>\n ))}\n </div>\n);\n\nconst variants: ButtonProps['variant'][] = [ 'none', 'contained', 'outlined', 'ghost' ]\nconst colors: ButtonProps['color'][] = [ 'primary', 'secondary', 'error' ]\nconst sizes: ButtonProps['size'][] = [ 'xs', 'sm', 'md', 'lg' ]\n\nconst variant_default: ButtonProps['variant'] = 'contained';\nconst color_default: ButtonProps['color'] = 'primary';\nconst size_default: ButtonProps['size'] = 'lg';\n\nconst iconMap = {\n 'undefined': undefined,\n \"<PlusIcon />\": <PlusIcon/>,\n \"<Trash2Icon />\": <Trash2Icon/>,\n \"<FileDownIcon />\": <FileDownIcon/>,\n PlusIcon: PlusIcon,\n Trash2Icon: Trash2Icon,\n FileDownIcon: FileDownIcon,\n};\n\nconst meta = {\n // title: 'Components/Button/Button',\n // title: 'ui/Button',\n title: 'Button',\n component: Button,\n // render: Template,\n args: {\n tooltip: undefined,\n asChild: false,\n //\n variant: variant_default,\n color: color_default,\n size: size_default,\n loading: false,\n disabled: false,\n startAdornment: undefined,\n endAdornment: undefined,\n slotProps: {},\n tooltipProps: {}\n },\n argTypes: {\n tooltip: {\n name: 'tooltip',\n description: 'Button tooltip from ButtonProps [deprecated, use title and message instead]',\n control: false,\n },\n asChild: {\n name: 'tooltip',\n description: 'Button asChild from ButtonProps [boolean]',\n control: false\n },\n variant: {\n name: 'variant',\n description: 'Button variant from ButtonProps',\n options: variants,\n control: { type: 'inline-radio', }\n },\n color: {\n name: 'color',\n description: 'Button color from ButtonProps',\n options: colors,\n control: { type: 'inline-radio' }\n },\n size: {\n name: 'size',\n description: 'Button size from ButtonProps',\n options: sizes,\n control: { type: 'inline-radio' }\n },\n title: {\n name: 'title',\n description: \"Button tooltip title from HTMLAttributes<HTMLButtonElement> [string only]\",\n control: { type: 'text' },\n },\n message: {\n name: 'message',\n description: 'Button tooltip message from ButtonProps [ReactNode]',\n control: { type: \"object\" },\n },\n startAdornment: {\n name: 'startAdornment',\n description: 'Button startAdornment from ButtonProps [`undefined` | `ComponentType<SVGProps<SVGSVGElement>>` | `ReactElement<SVGProps<SVGSVGElement>>`]',\n options: Object.keys(iconMap),\n mapping: iconMap,\n control: { type: 'inline-radio' },\n },\n endAdornment: {\n name: 'endAdornment',\n description: 'Button endAdornment from ButtonProps [`undefined` | `ComponentType<SVGProps<SVGSVGElement>>` | `ReactElement<SVGProps<SVGSVGElement>>`]',\n options: Object.keys(iconMap),\n mapping: iconMap,\n control: { type: 'inline-radio' },\n },\n slotProps: {\n name: 'slotProps',\n description: 'Button slotProps from ButtonProps [object]',\n control: { type: \"object\" },\n },\n tooltipProps: {\n name: 'tooltipProps',\n description: 'Button tooltipProps from ButtonProps [object]',\n control: { type: \"object\" },\n },\n },\n tags: [ 'autodocs' ],\n parameters: {\n docs: {\n description: {\n component: 'Universal button component with variants, icons and tooltip support.',\n },\n },\n pseudo: {\n hover: '#hover',\n focus: '#focus',\n active: '#active',\n disabled: '#disabled',\n },\n }\n} satisfies Meta<typeof Button>;\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\nconst args: Story['args'] = {\n ...meta.args,\n startAdornment: <PlusIcon/>,\n endAdornment: <PlusIcon/>,\n children: 'children',\n}\n\nexport const Default: Story = {\n args: {\n ...meta.args,\n children: '_children_',\n }\n};\n\nexport const Disabled: Story = {\n render: (props) => (\n <DashedWrapper>\n <Button {...props} />\n <Button {...props} startAdornment={<PlusIcon/>}/>\n <Button {...props} startAdornment={<PlusIcon/>} endAdornment={<PlusIcon/>}/>\n <Button {...props} endAdornment={<PlusIcon/>}/>\n </DashedWrapper>\n ),\n args: {\n ...meta.args,\n disabled: true,\n children: 'disabled',\n }\n};\n\nexport const Loading: Story = {\n render: (props) => (\n <DashedWrapper>\n <Button {...props} />\n <Button {...props} startAdornment={<PlusIcon/>}/>\n <Button {...props} startAdornment={<PlusIcon/>} endAdornment={<PlusIcon/>}/>\n <Button {...props} endAdornment={<PlusIcon/>}/>\n </DashedWrapper>\n ),\n args: {\n children: 'Loading…',\n loading: true,\n },\n};\n\nexport const Tooltips: Story = {\n render: (props) => (\n <div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>\n <Button\n {...props}\n title='delayDuration: 0'\n tooltipProps={{ delayDuration: 0 }}\n >\n delayDuration: 0\n </Button>\n <Button\n {...props}\n title='delayDuration: 300 [default]'\n tooltipProps={{ delayDuration: 300 }}\n >\n delayDuration: 300\n </Button>\n <Button\n {...props}\n title='delayDuration: 700'\n tooltipProps={{ delayDuration: 700 }}\n >\n delayDuration: 700\n </Button>\n\n <Button {...props} title='title_string'>title</Button>\n <Button {...props} message='message_string'>message: string</Button>\n <Button\n {...props}\n message={<span>message_node_span</span>}\n >\n message: ReactNode\n </Button>\n <Button\n {...props}\n message='message_string'\n tooltipProps={{\n showQuestionMark: true\n }}\n >\n showQuestionMark: true\n </Button>\n </div>\n ),\n args: {\n children: 'tooltips',\n tooltipProps: {\n defaultOpen: true\n },\n },\n};\n\nexport const Primary: Story = {\n args: {\n ...args,\n color: 'primary',\n size: 'lg',\n children: 'Створити',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: (props) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n </div>\n ),\n};\n\nexport const Secondary: Story = {\n args: {\n ...args,\n color: 'secondary',\n size: 'lg',\n children: 'Створити',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: (props) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n </div>\n ),\n};\n\nexport const Error: Story = {\n args: {\n ...args,\n color: 'error',\n size: 'lg',\n children: 'Створити',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: (props) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n </div>\n ),\n};\n"],"names":["States","props","jsx","state","Button","variants","colors","sizes","variant_default","color_default","size_default","iconMap","PlusIcon","Trash2Icon","FileDownIcon","meta","args","Default","Disabled","jsxs","DashedWrapper","Loading","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AAC,EAACF,GAAA,EAAQ,GAAGC,GAAO,SAAQ,WAAA,CAAU;AAAA,IACrC,gBAAAC,EAACF,GAAA,EAAQ,GAAGC,GAAO,SAAQ,QAAA,CAAO;AAAA,EAAA,EAAA,CACpC,EAAA,CACF;AAEJ,GAEawB,IAAe;AAAA,EAC1B,MAAM;AAAA,IACJ,GAAGT;AAAA,IACH,OAAO;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,EAAA;AAAA,EAEZ,UAAU;AAAA,IACR,SAAS,EAAE,SAAS,GAAA;AAAA,IACpB,OAAO,EAAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAE1B,QAAQ,CAACf,MACP,gBAAAC,EAAC,SAAI,WAAU,QACb,4BAACkB,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAlB,EAACF,GAAA,EAAQ,GAAGC,GAAO,SAAQ,YAAA,CAAW;AAAA,IACtC,gBAAAC,EAACF,GAAA,EAAQ,GAAGC,GAAO,SAAQ,WAAA,CAAU;AAAA,IACrC,gBAAAC,EAACF,GAAA,EAAQ,GAAGC,GAAO,SAAQ,QAAA,CAAO;AAAA,EAAA,EAAA,CACpC,EAAA,CACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Button.stories.js","sources":["../../src/Button/Button.stories.tsx"],"sourcesContent":["import type { Meta, StoryObj } from '@storybook/react';\n\nimport { Button } from './Button';\nimport { ButtonProps } from './Button.types';\nimport React from 'react';\nimport { PlusIcon, Trash2Icon, FileDownIcon } from 'lucide-react';\nimport { DashedWrapper } from \"../../.storybook/Wrappers\";\n\nconst States = (props: ButtonProps) => (\n <div\n style={{\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: '16px',\n }}\n >\n {[ 'default', 'hover', 'focus', 'active', 'disabled', 'loading' ]\n .map((state) => (\n <Button\n key={state}\n id={state}\n {...props}\n disabled={state === 'disabled' || props.disabled}\n loading={state === 'loading' || props.loading}\n >\n {props.children}\n </Button>\n ))}\n </div>\n);\n\nconst variants: ButtonProps['variant'][] = [ 'none', 'contained', 'outlined', 'ghost' ]\nconst colors: ButtonProps['color'][] = [ 'primary', 'secondary', 'error' ]\nconst sizes: ButtonProps['size'][] = [ 'xs', 'sm', 'md', 'lg' ]\n\nconst variant_default: ButtonProps['variant'] = 'contained';\nconst color_default: ButtonProps['color'] = 'primary';\nconst size_default: ButtonProps['size'] = 'lg';\n\nconst iconMap = {\n 'undefined': undefined,\n \"<PlusIcon />\": <PlusIcon/>,\n \"<Trash2Icon />\": <Trash2Icon/>,\n \"<FileDownIcon />\": <FileDownIcon/>,\n PlusIcon: PlusIcon,\n Trash2Icon: Trash2Icon,\n FileDownIcon: FileDownIcon,\n};\n\nconst meta = {\n title: 'Button',\n component: Button,\n // render: Template,\n args: {\n tooltip: undefined,\n asChild: false,\n //\n variant: variant_default,\n color: color_default,\n size: size_default,\n loading: false,\n disabled: false,\n startAdornment: undefined,\n endAdornment: undefined,\n slotProps: {},\n tooltipProps: {}\n },\n argTypes: {\n tooltip: {\n name: 'tooltip',\n description: 'Button tooltip from ButtonProps [deprecated, use title and message instead]',\n control: false,\n },\n asChild: {\n name: 'asChild',\n description: 'Button asChild from ButtonProps [boolean]',\n control: false\n },\n variant: {\n name: 'variant',\n description: 'Button variant from ButtonProps',\n options: variants,\n control: { type: 'inline-radio', }\n },\n color: {\n name: 'color',\n description: 'Button color from ButtonProps',\n options: colors,\n control: { type: 'inline-radio' }\n },\n size: {\n name: 'size',\n description: 'Button size from ButtonProps',\n options: sizes,\n control: { type: 'inline-radio' }\n },\n title: {\n name: 'title',\n description: \"Button tooltip title from HTMLAttributes<HTMLButtonElement> [string only]\",\n control: { type: 'text' },\n },\n message: {\n name: 'message',\n description: 'Button tooltip message from ButtonProps [ReactNode]',\n control: { type: \"object\" },\n },\n startAdornment: {\n name: 'startAdornment',\n description: 'Button startAdornment from ButtonProps [`undefined` | `ComponentType<SVGProps<SVGSVGElement>>` | `ReactElement<SVGProps<SVGSVGElement>>`]',\n options: Object.keys(iconMap),\n mapping: iconMap,\n control: { type: 'inline-radio' },\n },\n endAdornment: {\n name: 'endAdornment',\n description: 'Button endAdornment from ButtonProps [`undefined` | `ComponentType<SVGProps<SVGSVGElement>>` | `ReactElement<SVGProps<SVGSVGElement>>`]',\n options: Object.keys(iconMap),\n mapping: iconMap,\n control: { type: 'inline-radio' },\n },\n slotProps: {\n name: 'slotProps',\n description: 'Button slotProps from ButtonProps [object]',\n control: { type: \"object\" },\n },\n tooltipProps: {\n name: 'tooltipProps',\n description: 'Button tooltipProps from ButtonProps [object]',\n control: { type: \"object\" },\n },\n },\n parameters: {\n pseudo: {\n hover: '#hover',\n focus: '#focus',\n active: '#active',\n disabled: '#disabled',\n },\n }\n} satisfies Meta<typeof Button>;\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\nconst args: Story['args'] = {\n ...meta.args,\n startAdornment: <PlusIcon/>,\n endAdornment: <PlusIcon/>,\n children: 'children',\n}\n\nexport const Default: Story = {\n args: {\n ...meta.args,\n children: '_children_',\n }\n};\n\nexport const Disabled: Story = {\n render: (props) => (\n <DashedWrapper>\n <Button {...props} />\n <Button {...props} startAdornment={<PlusIcon/>}/>\n <Button {...props} startAdornment={<PlusIcon/>} endAdornment={<PlusIcon/>}/>\n <Button {...props} endAdornment={<PlusIcon/>}/>\n </DashedWrapper>\n ),\n args: {\n ...meta.args,\n disabled: true,\n children: 'disabled',\n }\n};\n\nexport const Loading: Story = {\n render: (props) => (\n <DashedWrapper>\n <Button {...props} />\n <Button {...props} startAdornment={<PlusIcon/>}/>\n <Button {...props} startAdornment={<PlusIcon/>} endAdornment={<PlusIcon/>}/>\n <Button {...props} endAdornment={<PlusIcon/>}/>\n </DashedWrapper>\n ),\n args: {\n children: 'Loading…',\n loading: true,\n },\n};\n\nexport const Tooltips: Story = {\n render: (props) => (\n <DashedWrapper>\n <div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>\n <Button\n {...props}\n title='delayDuration: 0'\n tooltipProps={{ delayDuration: 0 }}\n >\n delayDuration: 0\n </Button>\n <Button\n {...props}\n title='delayDuration: 300 [default]'\n tooltipProps={{ delayDuration: 300 }}\n >\n delayDuration: 300\n </Button>\n <Button\n {...props}\n title='delayDuration: 700'\n tooltipProps={{ delayDuration: 700 }}\n >\n delayDuration: 700\n </Button>\n\n <Button {...props} title='title_string'>title</Button>\n <Button {...props} message='message_string'>message: string</Button>\n <Button\n {...props}\n message={<span>message_node_span</span>}\n >\n message: ReactNode\n </Button>\n <Button\n {...props}\n message='message_string'\n tooltipProps={{\n showQuestionMark: true\n }}\n >\n showQuestionMark: true\n </Button>\n </div>\n </DashedWrapper>\n ),\n args: {\n children: 'tooltips',\n tooltipProps: {\n defaultOpen: true\n },\n },\n};\n\nexport const Primary: Story = {\n args: {\n ...args,\n color: 'primary',\n size: 'lg',\n children: 'Створити',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: (props) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n </div>\n ),\n};\n\nexport const Secondary: Story = {\n args: {\n ...args,\n color: 'secondary',\n size: 'lg',\n children: 'Створити',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: (props) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n </div>\n ),\n};\n\nexport const Error: Story = {\n args: {\n ...args,\n color: 'error',\n size: 'lg',\n children: 'Створити',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: (props) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n </div>\n ),\n};\n"],"names":["States","props","jsx","state","Button","variants","colors","sizes","variant_default","color_default","size_default","iconMap","PlusIcon","Trash2Icon","FileDownIcon","meta","args","Default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A,CAAU;AAAA,IACrC,gBAAAC,EAACF,GAAA,EAAQ,GAAGC,GAAO,SAAQ,QAAA,CAAO;AAAA,EAAA,EAAA,CACpC,EAAA,CACF;AAEJ,GAEawB,IAAe;AAAA,EAC1B,MAAM;AAAA,IACJ,GAAGT;AAAA,IACH,OAAO;AAAA,IACP,MAAM;AAAA,IACN,UAAU;AAAA,EAAA;AAAA,EAEZ,UAAU;AAAA,IACR,SAAS,EAAE,SAAS,GAAA;AAAA,IACpB,OAAO,EAAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAE1B,QAAQ,CAACf,MACP,gBAAAC,EAAC,SAAI,WAAU,QACb,4BAACkB,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAlB,EAACF,GAAA,EAAQ,GAAGC,GAAO,SAAQ,YAAA,CAAW;AAAA,IACtC,gBAAAC,EAACF,GAAA,EAAQ,GAAGC,GAAO,SAAQ,WAAA,CAAU;AAAA,IACrC,gBAAAC,EAACF,GAAA,EAAQ,GAAGC,GAAO,SAAQ,QAAA,CAAO;AAAA,EAAA,EAAA,CACpC,EAAA,CACF;AAEJ;"}
|
package/Button/Button.types.d.ts
CHANGED
|
@@ -27,7 +27,8 @@ export type ButtonBaseProps<VariantProps extends object = object, SlotProps = un
|
|
|
27
27
|
};
|
|
28
28
|
export interface ButtonSlotProps {
|
|
29
29
|
}
|
|
30
|
-
export type
|
|
30
|
+
export type ButtonIconType = ComponentType<SVGProps<SVGSVGElement>> | ReactElement<SVGProps<SVGSVGElement>>;
|
|
31
|
+
export type ButtonAdornmentProps = ButtonIconType;
|
|
31
32
|
export interface ButtonProps extends ButtonBaseProps<ButtonVarianceProps, ButtonSlotProps> {
|
|
32
33
|
startAdornment?: ButtonAdornmentProps;
|
|
33
34
|
endAdornment?: ButtonAdornmentProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../src/Button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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AC1C,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,KAAK,gBAAgB,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AAEhE,MAAM,WAAW,kBACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IAC9D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAClC,wCAAwC;IACxC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,MAAM,eAAe,CACzB,YAAY,SAAS,MAAM,GAAG,MAAM,EACpC,SAAS,GAAG,OAAO,IAEnB,kBAAkB,GAClB,kBAAkB,GAClB,YAAY,GAAG;IACf,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,eAAe;CAAG;AAEnC,MAAM,MAAM,cAAc,GACtB,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,GACtC,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AAE1C,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAElD,MAAM,WAAW,WACf,SAAQ,eAAe,CAAC,mBAAmB,EAAE,eAAe,CAAC;IAC7D,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACrC"}
|
|
@@ -6,43 +6,49 @@ import * as React from "react";
|
|
|
6
6
|
* `ButtonIcon` is used for compact actions represented by an icon instead of text.
|
|
7
7
|
* Supports all core features of Button: variants, sizes, tooltips, disabled and loading state.
|
|
8
8
|
*
|
|
9
|
+
* @public
|
|
10
|
+
* @see [Documentation](#) // TODO: add link to docs
|
|
11
|
+
*
|
|
9
12
|
* @example
|
|
10
|
-
* >
|
|
13
|
+
* > Import:
|
|
11
14
|
* ```tsx
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
+
* import { ButtonIcon } from '@oneplatformdev/ui/ButtonIcon';
|
|
16
|
+
* ```
|
|
17
|
+
* > Basic usage by icon:
|
|
18
|
+
* ```tsx
|
|
19
|
+
*<ButtonIcon icon={<PlusIcon />}/>
|
|
20
|
+
*<ButtonIcon icon={PlusIcon}/>
|
|
21
|
+
* ```
|
|
22
|
+
* > Basic usage by children:
|
|
23
|
+
* ```tsx
|
|
24
|
+
*<ButtonIcon>
|
|
25
|
+
* <PlusIcon />
|
|
26
|
+
*</ButtonIcon>
|
|
15
27
|
* ```
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
28
|
* > With variant & color:
|
|
19
29
|
* ```tsx
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
|
|
30
|
+
*<ButtonIcon variant="outline" color="primary">
|
|
31
|
+
* <Search />
|
|
32
|
+
*</ButtonIcon>
|
|
23
33
|
* ```
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
34
|
* > With tooltip message:
|
|
27
35
|
* ```tsx
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
|
|
36
|
+
*<ButtonIcon message="Edit item">
|
|
37
|
+
* <PencilLine />
|
|
38
|
+
*</ButtonIcon>
|
|
31
39
|
* ```
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
40
|
* > Loading state:
|
|
35
41
|
* ```tsx
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
|
|
42
|
+
*<ButtonIcon loading>
|
|
43
|
+
* <Trash2 />
|
|
44
|
+
*</ButtonIcon>
|
|
39
45
|
* ```
|
|
40
46
|
*
|
|
41
47
|
* @remarks
|
|
42
48
|
* - Designed for icon-only usage. If you need text, use `Button`.
|
|
43
49
|
* - Works with any SVG React component or element, e.g. lucide-react, heroicons, custom icons.
|
|
44
50
|
*
|
|
45
|
-
* @see {@link
|
|
51
|
+
* @see {@link ButtonIcon} for icon-only buttons
|
|
46
52
|
*/
|
|
47
53
|
export declare const ButtonIcon: React.ForwardRefExoticComponent<ButtonIconProps & React.RefAttributes<HTMLButtonElement>>;
|
|
48
54
|
export default ButtonIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.d.ts","sourceRoot":"","sources":["../../src/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ButtonIcon.d.ts","sourceRoot":"","sources":["../../src/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAcrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,UAAU,2FA6DtB,CAAA;AAED,eAAe,UAAU,CAAC"}
|
package/ButtonIcon/ButtonIcon.js
CHANGED
|
@@ -1,61 +1,65 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import * as x from "react";
|
|
3
|
+
import { isValidElement as B, createElement as C } from "react";
|
|
4
|
+
import { cn as E } from "@oneplatformdev/utils";
|
|
5
|
+
import { buttonIconVariants as I } from "./buttonIconVariants.js";
|
|
6
|
+
import { Slot as R } from "@radix-ui/react-slot";
|
|
6
7
|
import "@radix-ui/react-tooltip";
|
|
7
|
-
import { Tooltip as
|
|
8
|
-
import { LoadedIcon as
|
|
9
|
-
const
|
|
10
|
-
(
|
|
8
|
+
import { Tooltip as V } from "../Tooltip/Tooltip.js";
|
|
9
|
+
import { LoadedIcon as j } from "../LoadedIcon/LoadedIcon.js";
|
|
10
|
+
const w = (t) => t ? B(t) ? t : C(t) : null, z = x.forwardRef(
|
|
11
|
+
(t, p) => {
|
|
11
12
|
const {
|
|
12
|
-
asChild:
|
|
13
|
-
children:
|
|
13
|
+
asChild: n,
|
|
14
|
+
children: i,
|
|
15
|
+
icon: d,
|
|
14
16
|
disabled: s = !1,
|
|
15
|
-
loading:
|
|
16
|
-
message:
|
|
17
|
-
title:
|
|
17
|
+
loading: o = !1,
|
|
18
|
+
message: f,
|
|
19
|
+
title: u = "",
|
|
18
20
|
tooltipProps: a = {},
|
|
19
|
-
className:
|
|
20
|
-
variant:
|
|
21
|
-
color:
|
|
22
|
-
size:
|
|
23
|
-
rounded:
|
|
24
|
-
...
|
|
25
|
-
} =
|
|
26
|
-
|
|
21
|
+
className: h,
|
|
22
|
+
variant: b,
|
|
23
|
+
color: g,
|
|
24
|
+
size: m,
|
|
25
|
+
rounded: v,
|
|
26
|
+
...y
|
|
27
|
+
} = t, N = n ? R : "button", e = f || u, l = n ? i : /* @__PURE__ */ r(j, { loading: o, size: m, children: w(d) ?? i });
|
|
28
|
+
if (!l) return null;
|
|
29
|
+
const c = /* @__PURE__ */ r(
|
|
30
|
+
N,
|
|
27
31
|
{
|
|
28
32
|
type: "button",
|
|
29
33
|
ref: p,
|
|
30
34
|
disabled: s,
|
|
31
|
-
className:
|
|
32
|
-
|
|
33
|
-
variant:
|
|
34
|
-
size:
|
|
35
|
-
color:
|
|
36
|
-
rounded:
|
|
37
|
-
className:
|
|
35
|
+
className: E(
|
|
36
|
+
I({
|
|
37
|
+
variant: b,
|
|
38
|
+
size: m,
|
|
39
|
+
color: g,
|
|
40
|
+
rounded: v,
|
|
41
|
+
className: h
|
|
38
42
|
}),
|
|
39
|
-
|
|
43
|
+
o && "pointer-events-none opacity-80"
|
|
40
44
|
),
|
|
41
|
-
...
|
|
42
|
-
children:
|
|
45
|
+
...y,
|
|
46
|
+
children: l
|
|
43
47
|
}
|
|
44
48
|
);
|
|
45
|
-
return e ? /* @__PURE__ */
|
|
46
|
-
|
|
49
|
+
return e ? /* @__PURE__ */ r(
|
|
50
|
+
V,
|
|
47
51
|
{
|
|
48
52
|
...a || {},
|
|
49
|
-
open: a.open ?? (s ||
|
|
53
|
+
open: a.open ?? (s || o || !e) ? !1 : void 0,
|
|
50
54
|
message: e,
|
|
51
|
-
children:
|
|
55
|
+
children: c
|
|
52
56
|
}
|
|
53
|
-
) :
|
|
57
|
+
) : c;
|
|
54
58
|
}
|
|
55
59
|
);
|
|
56
|
-
|
|
60
|
+
z.displayName = "Button";
|
|
57
61
|
export {
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
z as ButtonIcon,
|
|
63
|
+
z as default
|
|
60
64
|
};
|
|
61
65
|
//# sourceMappingURL=ButtonIcon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.js","sources":["../../src/ButtonIcon/ButtonIcon.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { cn } from \"@oneplatformdev/utils\"\nimport { buttonIconVariants } from './buttonIconVariants';\nimport { ButtonIconProps } from './ButtonIcon.types';\nimport { Slot } from \"@radix-ui/react-slot\"\n\nimport { Tooltip } from '../Tooltip';\nimport { LoadedIcon } from \"../LoadedIcon\";\n\n/**\n * Icon-only version of the Button component.\n *\n * `ButtonIcon` is used for compact actions represented by an icon instead of text.\n * Supports all core features of Button: variants, sizes, tooltips, disabled and loading state.\n *\n * @example\n * > Basic usage:\n * ```tsx\n
|
|
1
|
+
{"version":3,"file":"ButtonIcon.js","sources":["../../src/ButtonIcon/ButtonIcon.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { cn } from \"@oneplatformdev/utils\"\nimport { buttonIconVariants } from './buttonIconVariants';\nimport { ButtonIconProps } from './ButtonIcon.types';\nimport { Slot } from \"@radix-ui/react-slot\"\n\nimport { Tooltip } from '../Tooltip';\nimport { LoadedIcon } from \"../LoadedIcon\";\nimport { ButtonIconType } from \"../Button\";\nimport { createElement, isValidElement } from \"react\";\n\nconst renderInnerIcon = (Icon?: ButtonIconType) => {\n if (!Icon) return null;\n if (isValidElement(Icon)) return Icon;\n return createElement(Icon);\n};\n\n/**\n * Icon-only version of the Button component.\n *\n * `ButtonIcon` is used for compact actions represented by an icon instead of text.\n * Supports all core features of Button: variants, sizes, tooltips, disabled and loading state.\n *\n * @public\n * @see [Documentation](#) // TODO: add link to docs\n *\n * @example\n * > Import:\n * ```tsx\n * import { ButtonIcon } from '@oneplatformdev/ui/ButtonIcon';\n * ```\n * > Basic usage by icon:\n * ```tsx\n *<ButtonIcon icon={<PlusIcon />}/>\n *<ButtonIcon icon={PlusIcon}/>\n * ```\n * > Basic usage by children:\n * ```tsx\n *<ButtonIcon>\n * <PlusIcon />\n *</ButtonIcon>\n * ```\n * > With variant & color:\n * ```tsx\n *<ButtonIcon variant=\"outline\" color=\"primary\">\n * <Search />\n *</ButtonIcon>\n * ```\n * > With tooltip message:\n * ```tsx\n *<ButtonIcon message=\"Edit item\">\n * <PencilLine />\n *</ButtonIcon>\n * ```\n * > Loading state:\n * ```tsx\n *<ButtonIcon loading>\n * <Trash2 />\n *</ButtonIcon>\n * ```\n *\n * @remarks\n * - Designed for icon-only usage. If you need text, use `Button`.\n * - Works with any SVG React component or element, e.g. lucide-react, heroicons, custom icons.\n *\n * @see {@link ButtonIcon} for icon-only buttons\n */\nexport const ButtonIcon = React.forwardRef<HTMLButtonElement, ButtonIconProps>(\n (props, ref) => {\n const {\n asChild,\n children,\n icon,\n disabled = false,\n loading = false,\n message,\n title = '',\n tooltipProps = {},\n className,\n variant,\n color,\n size,\n rounded,\n ...rest\n } = props;\n\n const Comp = asChild ? Slot : \"button\"\n const msg = message || title;\n\n const content = asChild\n ? children\n : (\n <LoadedIcon loading={loading} size={size}>\n {renderInnerIcon(icon) ?? children}\n </LoadedIcon>\n )\n\n if (!content) return null;\n\n const cmp = (\n <Comp\n type='button'\n ref={ref}\n disabled={disabled}\n className={cn(\n buttonIconVariants({\n variant, size, color, rounded,\n className\n }),\n loading && 'pointer-events-none opacity-80',\n )}\n {...rest}\n >\n {content}\n </Comp>\n )\n\n if (!msg) return cmp\n return (\n <Tooltip\n {...(tooltipProps || {})}\n open={tooltipProps.open ?? (disabled || loading || !msg) ? false : undefined}\n message={msg}\n >\n {cmp}\n </Tooltip>\n )\n }\n)\nButtonIcon.displayName = \"Button\"\nexport default ButtonIcon;\n"],"names":["renderInnerIcon","Icon","isValidElement","createElement","ButtonIcon","React","props","ref","asChild","children","icon","disabled","loading","message","title","tooltipProps","className","variant","color","size","rounded","rest","Comp","Slot","msg","content","jsx","LoadedIcon","cmp","cn","buttonIconVariants","Tooltip"],"mappings":";;;;;;;;;AAYA,MAAMA,IAAkB,CAACC,MAClBA,IACDC,EAAeD,CAAI,IAAUA,IAC1BE,EAAcF,CAAI,IAFP,MAuDPG,IAAaC,EAAM;AAAA,EAC9B,CAACC,GAAOC,MAAQ;AACd,UAAM;AAAA,MACJ,SAAAC;AAAA,MACA,UAAAC;AAAA,MACA,MAAAC;AAAA,MACA,UAAAC,IAAW;AAAA,MACX,SAAAC,IAAU;AAAA,MACV,SAAAC;AAAA,MACA,OAAAC,IAAQ;AAAA,MACR,cAAAC,IAAe,CAAA;AAAA,MACf,WAAAC;AAAA,MACA,SAAAC;AAAA,MACA,OAAAC;AAAA,MACA,MAAAC;AAAA,MACA,SAAAC;AAAA,MACA,GAAGC;AAAA,IAAA,IACDf,GAEEgB,IAAOd,IAAUe,IAAO,UACxBC,IAAMX,KAAWC,GAEjBW,IAAUjB,IACZC,IAEA,gBAAAiB,EAACC,GAAA,EAAW,SAAAf,GAAkB,MAAAO,GAC3B,UAAAnB,EAAgBU,CAAI,KAAKD,EAAA,CAC5B;AAGJ,QAAI,CAACgB,EAAS,QAAO;AAErB,UAAMG,IACJ,gBAAAF;AAAA,MAACJ;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,KAAAf;AAAA,QACA,UAAAI;AAAA,QACA,WAAWkB;AAAA,UACTC,EAAmB;AAAA,YACjB,SAAAb;AAAA,YAAS,MAAAE;AAAA,YAAM,OAAAD;AAAA,YAAO,SAAAE;AAAA,YACtB,WAAAJ;AAAA,UAAA,CACD;AAAA,UACDJ,KAAW;AAAA,QAAA;AAAA,QAEZ,GAAGS;AAAA,QAEH,UAAAI;AAAA,MAAA;AAAA,IAAA;AAIL,WAAKD,IAEH,gBAAAE;AAAA,MAACK;AAAA,MAAA;AAAA,QACE,GAAIhB,KAAgB,CAAA;AAAA,QACrB,MAAMA,EAAa,SAASJ,KAAYC,KAAW,CAACY,KAAO,KAAQ;AAAA,QACnE,SAASA;AAAA,QAER,UAAAI;AAAA,MAAA;AAAA,IAAA,IAPYA;AAAA,EAUnB;AACF;AACAxB,EAAW,cAAc;"}
|
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
2
|
-
import { ButtonIcon as
|
|
3
|
-
import { PlusIcon as
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsx as o, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { ButtonIcon as c } from "./ButtonIcon.js";
|
|
3
|
+
import { FileDownIcon as r, Trash2Icon as l, PlusIcon as t } from "lucide-react";
|
|
4
|
+
import { DashedWrapper as u } from "../.storybook/Wrappers.js";
|
|
5
|
+
const h = (e) => /* @__PURE__ */ o(c, { ...e });
|
|
6
|
+
h.args = {
|
|
6
7
|
onClick: { action: (e) => e }
|
|
7
8
|
};
|
|
8
|
-
const
|
|
9
|
-
"div",
|
|
10
|
-
{
|
|
11
|
-
style: {
|
|
12
|
-
padding: "0px 20px",
|
|
13
|
-
display: "flex",
|
|
14
|
-
gap: "32px",
|
|
15
|
-
alignItems: "flex-start"
|
|
16
|
-
},
|
|
17
|
-
children: /* @__PURE__ */ o(
|
|
18
|
-
"div",
|
|
19
|
-
{
|
|
20
|
-
style: {
|
|
21
|
-
position: "relative",
|
|
22
|
-
border: "2px dashed rgba(139, 92, 246, 0.7)",
|
|
23
|
-
borderRadius: "24px",
|
|
24
|
-
padding: "24px 32px",
|
|
25
|
-
display: "flex",
|
|
26
|
-
gap: "32px"
|
|
27
|
-
},
|
|
28
|
-
children: e.children
|
|
29
|
-
}
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
), t = (e) => /* @__PURE__ */ o(
|
|
9
|
+
const n = (e) => /* @__PURE__ */ o(
|
|
33
10
|
"div",
|
|
34
11
|
{
|
|
35
12
|
style: {
|
|
@@ -39,7 +16,7 @@ const p = (e) => /* @__PURE__ */ o(
|
|
|
39
16
|
gap: "16px"
|
|
40
17
|
},
|
|
41
18
|
children: ["default", "hover", "focus", "active", "disabled"].map((a) => /* @__PURE__ */ o(
|
|
42
|
-
|
|
19
|
+
c,
|
|
43
20
|
{
|
|
44
21
|
id: a,
|
|
45
22
|
...e,
|
|
@@ -49,57 +26,76 @@ const p = (e) => /* @__PURE__ */ o(
|
|
|
49
26
|
a
|
|
50
27
|
))
|
|
51
28
|
}
|
|
52
|
-
),
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
/* @__PURE__ */ o(
|
|
55
|
-
/* @__PURE__ */ o(
|
|
56
|
-
/* @__PURE__ */ o(
|
|
29
|
+
), s = (e) => /* @__PURE__ */ i("div", { className: "flex", children: [
|
|
30
|
+
/* @__PURE__ */ i(u, { children: [
|
|
31
|
+
/* @__PURE__ */ o(n, { ...e, variant: "contained" }),
|
|
32
|
+
/* @__PURE__ */ o(n, { ...e, variant: "outlined" }),
|
|
33
|
+
/* @__PURE__ */ o(n, { ...e, variant: "ghost" })
|
|
57
34
|
] }),
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */ o(
|
|
60
|
-
/* @__PURE__ */ o(
|
|
61
|
-
/* @__PURE__ */ o(
|
|
35
|
+
/* @__PURE__ */ i(u, { children: [
|
|
36
|
+
/* @__PURE__ */ o(n, { ...e, variant: "contained", rounded: !0 }),
|
|
37
|
+
/* @__PURE__ */ o(n, { ...e, variant: "outlined", rounded: !0 }),
|
|
38
|
+
/* @__PURE__ */ o(n, { ...e, variant: "ghost", rounded: !0 })
|
|
62
39
|
] })
|
|
63
|
-
] }),
|
|
40
|
+
] }), p = ["contained", "outlined", "ghost"], m = ["primary", "secondary", "error"], f = ["xs", "sm", "md", "lg"], y = "contained", I = "primary", B = "lg", g = {
|
|
41
|
+
undefined: void 0,
|
|
42
|
+
"<PlusIcon />": /* @__PURE__ */ o(t, {}),
|
|
43
|
+
"<Trash2Icon />": /* @__PURE__ */ o(l, {}),
|
|
44
|
+
"<FileDownIcon />": /* @__PURE__ */ o(r, {}),
|
|
45
|
+
PlusIcon: t,
|
|
46
|
+
Trash2Icon: l,
|
|
47
|
+
FileDownIcon: r
|
|
48
|
+
}, v = {
|
|
49
|
+
"<PlusIcon />": /* @__PURE__ */ o(t, {}),
|
|
50
|
+
"<Trash2Icon />": /* @__PURE__ */ o(l, {}),
|
|
51
|
+
"<FileDownIcon />": /* @__PURE__ */ o(r, {})
|
|
52
|
+
}, b = {
|
|
64
53
|
title: "ButtonIcon",
|
|
65
|
-
component:
|
|
66
|
-
render:
|
|
54
|
+
component: c,
|
|
55
|
+
render: h,
|
|
67
56
|
args: {
|
|
68
57
|
asChild: !1,
|
|
69
58
|
disabled: !1,
|
|
70
59
|
loading: !1,
|
|
71
60
|
rounded: !1,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
61
|
+
variant: y,
|
|
62
|
+
color: I,
|
|
63
|
+
size: B,
|
|
64
|
+
children: /* @__PURE__ */ o(t, {}),
|
|
65
|
+
icon: void 0,
|
|
66
|
+
message: void 0,
|
|
67
|
+
title: void 0
|
|
77
68
|
},
|
|
78
69
|
argTypes: {
|
|
70
|
+
tooltip: {
|
|
71
|
+
name: "tooltip",
|
|
72
|
+
description: "ButtonIcon tooltip from ButtonIconProps [deprecated, use title and message instead]",
|
|
73
|
+
control: !1
|
|
74
|
+
},
|
|
79
75
|
asChild: {
|
|
80
76
|
name: "asChild",
|
|
81
|
-
description: "ButtonIcon asChild",
|
|
77
|
+
description: "ButtonIcon asChild from ButtonIconProps [boolean]",
|
|
82
78
|
control: !1
|
|
83
79
|
},
|
|
84
80
|
variant: {
|
|
85
81
|
name: "variant",
|
|
86
82
|
description: "ButtonIcon variant",
|
|
87
|
-
defaultValue:
|
|
88
|
-
options:
|
|
83
|
+
defaultValue: p[0],
|
|
84
|
+
options: p,
|
|
89
85
|
control: { type: "inline-radio" }
|
|
90
86
|
},
|
|
91
87
|
color: {
|
|
92
88
|
name: "color",
|
|
93
89
|
description: "ButtonIcon color",
|
|
94
|
-
defaultValue:
|
|
95
|
-
options:
|
|
90
|
+
defaultValue: m[0],
|
|
91
|
+
options: m,
|
|
96
92
|
control: { type: "inline-radio" }
|
|
97
93
|
},
|
|
98
94
|
size: {
|
|
99
95
|
name: "size",
|
|
100
96
|
description: "ButtonIcon size",
|
|
101
|
-
defaultValue:
|
|
102
|
-
options:
|
|
97
|
+
defaultValue: f[0],
|
|
98
|
+
options: f,
|
|
103
99
|
control: { type: "inline-radio" }
|
|
104
100
|
},
|
|
105
101
|
title: {
|
|
@@ -126,6 +122,20 @@ const p = (e) => /* @__PURE__ */ o(
|
|
|
126
122
|
name: "loading",
|
|
127
123
|
description: "ButtonIcon loading",
|
|
128
124
|
control: { type: "boolean" }
|
|
125
|
+
},
|
|
126
|
+
icon: {
|
|
127
|
+
name: "icon",
|
|
128
|
+
description: "ButtonIcon icon from ButtonIconProps [`undefined` | `ComponentType<SVGProps<SVGSVGElement>>` | `ReactElement<SVGProps<SVGSVGElement>>`]",
|
|
129
|
+
options: Object.keys(g),
|
|
130
|
+
mapping: g,
|
|
131
|
+
control: { type: "inline-radio" }
|
|
132
|
+
},
|
|
133
|
+
children: {
|
|
134
|
+
name: "children",
|
|
135
|
+
description: "ButtonIcon children from ButtonIconProps [`ReactNode`]",
|
|
136
|
+
options: Object.keys(v),
|
|
137
|
+
mapping: v,
|
|
138
|
+
control: { type: "inline-radio" }
|
|
129
139
|
}
|
|
130
140
|
},
|
|
131
141
|
parameters: {
|
|
@@ -136,15 +146,21 @@ const p = (e) => /* @__PURE__ */ o(
|
|
|
136
146
|
disabled: "#disabled"
|
|
137
147
|
}
|
|
138
148
|
}
|
|
139
|
-
},
|
|
149
|
+
}, d = {
|
|
140
150
|
asChild: !1,
|
|
141
151
|
disabled: !1,
|
|
142
152
|
loading: !1,
|
|
143
153
|
rounded: !1,
|
|
144
|
-
children: /* @__PURE__ */ o(
|
|
145
|
-
},
|
|
154
|
+
children: /* @__PURE__ */ o(t, {})
|
|
155
|
+
}, D = {
|
|
156
|
+
args: {
|
|
157
|
+
...b.args,
|
|
158
|
+
icon: r,
|
|
159
|
+
children: void 0
|
|
160
|
+
}
|
|
161
|
+
}, x = {
|
|
146
162
|
args: {
|
|
147
|
-
...
|
|
163
|
+
...d,
|
|
148
164
|
color: "primary",
|
|
149
165
|
size: "lg"
|
|
150
166
|
},
|
|
@@ -152,14 +168,14 @@ const p = (e) => /* @__PURE__ */ o(
|
|
|
152
168
|
variant: { control: !1 },
|
|
153
169
|
color: { control: !1 }
|
|
154
170
|
},
|
|
155
|
-
render:
|
|
171
|
+
render: s
|
|
156
172
|
};
|
|
157
|
-
|
|
173
|
+
x.parameters = {
|
|
158
174
|
controls: { exclude: ["variant", "color"] }
|
|
159
175
|
};
|
|
160
|
-
const
|
|
176
|
+
const P = {
|
|
161
177
|
args: {
|
|
162
|
-
...
|
|
178
|
+
...d,
|
|
163
179
|
color: "secondary",
|
|
164
180
|
size: "lg"
|
|
165
181
|
},
|
|
@@ -167,14 +183,14 @@ const g = {
|
|
|
167
183
|
variant: { control: !1 },
|
|
168
184
|
color: { control: !1 }
|
|
169
185
|
},
|
|
170
|
-
render:
|
|
186
|
+
render: s
|
|
171
187
|
};
|
|
172
|
-
|
|
188
|
+
P.parameters = {
|
|
173
189
|
controls: { exclude: ["variant", "color"] }
|
|
174
190
|
};
|
|
175
|
-
const
|
|
191
|
+
const T = {
|
|
176
192
|
args: {
|
|
177
|
-
...
|
|
193
|
+
...d,
|
|
178
194
|
color: "error",
|
|
179
195
|
size: "lg"
|
|
180
196
|
},
|
|
@@ -182,16 +198,16 @@ const v = {
|
|
|
182
198
|
variant: { control: !1 },
|
|
183
199
|
color: { control: !1 }
|
|
184
200
|
},
|
|
185
|
-
render:
|
|
201
|
+
render: s
|
|
186
202
|
};
|
|
187
|
-
|
|
203
|
+
T.parameters = {
|
|
188
204
|
controls: { exclude: ["variant", "color"] }
|
|
189
205
|
};
|
|
190
206
|
export {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
207
|
+
D as Default,
|
|
208
|
+
T as Error,
|
|
209
|
+
x as Primary,
|
|
210
|
+
P as Secondary,
|
|
195
211
|
b as default
|
|
196
212
|
};
|
|
197
213
|
//# sourceMappingURL=ButtonIcon.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.stories.js","sources":["../../src/ButtonIcon/ButtonIcon.stories.tsx"],"sourcesContent":["import type { Meta, StoryObj } from '@storybook/react';\n\nimport { ButtonIcon } from './ButtonIcon';\nimport type { ButtonIconProps } from './ButtonIcon.types';\nimport React, { PropsWithChildren } from 'react';\nimport { PlusIcon } from 'lucide-react'\n\nconst Template = (props: ButtonIconProps) => <ButtonIcon {...props}/>\nTemplate.args = {\n onClick: { action: (e: React.MouseEvent<HTMLButtonElement>) => e },\n};\n\nconst DashedWrapper = (props: PropsWithChildren) => {\n return (\n <div\n style={{\n padding: '0px 20px',\n display: 'flex',\n gap: '32px',\n alignItems: 'flex-start',\n }}\n >\n <div\n style={{\n position: 'relative',\n border: '2px dashed rgba(139, 92, 246, 0.7)',\n borderRadius: '24px',\n padding: '24px 32px',\n display: 'flex',\n gap: '32px',\n }}\n >\n {props.children}\n </div>\n </div>\n )\n}\n\nconst States = (props: ButtonIconProps) => (\n <div\n style={{\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: '16px',\n }}\n >\n {[ 'default', 'hover', 'focus', 'active', 'disabled' ]\n .map((state) => (\n <ButtonIcon\n key={state}\n id={state}\n {...props}\n disabled={state === 'disabled' || props.disabled}\n >\n {props.children}\n </ButtonIcon>\n ))}\n </div>\n);\n\nconst StateRender = (props: ButtonIconProps) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n <DashedWrapper>\n <States {...props} variant='contained' rounded/>\n <States {...props} variant='outlined' rounded/>\n <States {...props} variant='ghost' rounded/>\n </DashedWrapper>\n </div>\n);\n\nconst variants: ButtonIconProps['variant'][] = [ 'contained', 'outlined', 'ghost' ]\nconst colors: ButtonIconProps['color'][] = [ 'primary', 'secondary', 'error' ]\nconst sizes: ButtonIconProps['size'][] = [ 'xs', 'sm', 'md', 'lg' ]\n\nconst meta = {\n title: 'ButtonIcon',\n component: ButtonIcon,\n render: Template,\n args: {\n asChild: false,\n disabled: false,\n loading: false,\n rounded: false,\n children: <PlusIcon/>,\n variant: variants[0],\n color: colors[0],\n size: sizes[0],\n message: '',\n },\n argTypes: {\n asChild: {\n name: 'asChild',\n description: 'ButtonIcon asChild',\n control: false\n },\n variant: {\n name: 'variant',\n description: 'ButtonIcon variant',\n defaultValue: variants[0],\n options: variants,\n control: { type: 'inline-radio', },\n },\n color: {\n name: 'color',\n description: 'ButtonIcon color',\n defaultValue: colors[0],\n options: colors,\n control: { type: 'inline-radio' },\n },\n size: {\n name: 'size',\n description: 'ButtonIcon size',\n defaultValue: sizes[0],\n options: sizes,\n control: { type: 'inline-radio' },\n },\n title: {\n name: 'title',\n description: \"ButtonIcon tooltip title from HTMLAttributes<HTMLButtonElement> [string only]\",\n control: { type: 'text' },\n },\n message: {\n name: 'message',\n description: 'ButtonIcon tooltip message from ButtonProps [ReactNode]',\n control: { type: \"object\" },\n },\n disabled: {\n name: 'disabled',\n description: 'ButtonIcon disabled',\n control: { type: 'boolean' }\n },\n rounded: {\n name: 'rounded',\n description: 'ButtonIcon rounded',\n control: { type: 'boolean' }\n },\n loading: {\n name: 'loading',\n description: 'ButtonIcon loading',\n control: { type: 'boolean' }\n },\n },\n parameters: {\n pseudo: {\n hover: '#hover',\n focus: '#focus',\n active: '#active',\n disabled: '#disabled',\n },\n }\n} satisfies Meta<typeof ButtonIcon>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\nconst args: Story['args'] = {\n asChild: false,\n disabled: false,\n loading: false,\n rounded: false,\n children: <PlusIcon/>,\n}\n\nexport const Default: Story = { args };\n\nexport const Primary: Story = {\n args: {\n ...args,\n color: 'primary',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nPrimary.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n\nexport const Secondary: Story = {\n args: {\n ...args,\n color: 'secondary',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nSecondary.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n\nexport const Error: Story = {\n args: {\n ...args,\n color: 'error',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nError.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n"],"names":["Template","props","jsx","ButtonIcon","DashedWrapper","States","state","StateRender","jsxs","variants","colors","sizes","meta","PlusIcon","args","Default","Primary","Secondary","Error"],"mappings":";;;AAOA,MAAMA,IAAW,CAACC,MAA2B,gBAAAC,EAACC,GAAA,EAAY,GAAGF,GAAM;AACnED,EAAS,OAAO;AAAA,EACd,SAAS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MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,SAAS,EAAE,SAAS,GAAA;AAAA,IACpB,OAAO,EAAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAE1B,QAAQP;AACV;AACAU,EAAU,aAAa;AAAA,EACrB,UAAU,EAAE,SAAS,CAAE,WAAW,OAAQ,EAAA;AAC5C;AAEO,MAAMC,IAAe;AAAA,EAC1B,MAAM;AAAA,IACJ,GAAGJ;AAAA,IACH,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,SAAS,EAAE,SAAS,GAAA;AAAA,IACpB,OAAO,EAAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAE1B,QAAQP;AACV;AACAW,EAAM,aAAa;AAAA,EACjB,UAAU,EAAE,SAAS,CAAE,WAAW,OAAQ,EAAA;AAC5C;"}
|
|
1
|
+
{"version":3,"file":"ButtonIcon.stories.js","sources":["../../src/ButtonIcon/ButtonIcon.stories.tsx"],"sourcesContent":["import type { Meta, StoryObj } from '@storybook/react';\n\nimport { ButtonIcon } from './ButtonIcon';\nimport type { ButtonIconProps } from './ButtonIcon.types';\nimport React from 'react';\nimport { FileDownIcon, PlusIcon, Trash2Icon } from 'lucide-react'\nimport { DashedWrapper } from \"../../.storybook/Wrappers\";\nimport { ButtonProps } from \"../Button\";\n\nconst Template = (props: ButtonIconProps) => <ButtonIcon {...props}/>\nTemplate.args = {\n onClick: { action: (e: React.MouseEvent<HTMLButtonElement>) => e },\n};\n\nconst States = (props: ButtonIconProps) => (\n <div\n style={{\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: '16px',\n }}\n >\n {[ 'default', 'hover', 'focus', 'active', 'disabled' ]\n .map((state) => (\n <ButtonIcon\n key={state}\n id={state}\n {...props}\n disabled={state === 'disabled' || props.disabled}\n >\n {props.children}\n </ButtonIcon>\n ))}\n </div>\n);\n\nconst StateRender = (props: ButtonIconProps) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n <DashedWrapper>\n <States {...props} variant='contained' rounded/>\n <States {...props} variant='outlined' rounded/>\n <States {...props} variant='ghost' rounded/>\n </DashedWrapper>\n </div>\n);\n\nconst variants: ButtonIconProps['variant'][] = [ 'contained', 'outlined', 'ghost' ]\nconst colors: ButtonIconProps['color'][] = [ 'primary', 'secondary', 'error' ]\nconst sizes: ButtonIconProps['size'][] = [ 'xs', 'sm', 'md', 'lg' ]\n\nconst variant_default: ButtonProps['variant'] = 'contained';\nconst color_default: ButtonProps['color'] = 'primary';\nconst size_default: ButtonProps['size'] = 'lg';\n\nconst iconMap = {\n 'undefined': undefined,\n \"<PlusIcon />\": <PlusIcon/>,\n \"<Trash2Icon />\": <Trash2Icon/>,\n \"<FileDownIcon />\": <FileDownIcon/>,\n PlusIcon: PlusIcon,\n Trash2Icon: Trash2Icon,\n FileDownIcon: FileDownIcon,\n};\n\nconst iconChildrenMap = {\n \"<PlusIcon />\": <PlusIcon/>,\n \"<Trash2Icon />\": <Trash2Icon/>,\n \"<FileDownIcon />\": <FileDownIcon/>,\n};\n\nconst meta = {\n title: 'ButtonIcon',\n component: ButtonIcon,\n render: Template,\n args: {\n asChild: false,\n disabled: false,\n loading: false,\n rounded: false,\n variant: variant_default,\n color: color_default,\n size: size_default,\n children: <PlusIcon/>,\n icon: undefined,\n message: undefined,\n title: undefined,\n },\n argTypes: {\n tooltip: {\n name: 'tooltip',\n description: 'ButtonIcon tooltip from ButtonIconProps [deprecated, use title and message instead]',\n control: false,\n },\n asChild: {\n name: 'asChild',\n description: 'ButtonIcon asChild from ButtonIconProps [boolean]',\n control: false\n },\n variant: {\n name: 'variant',\n description: 'ButtonIcon variant',\n defaultValue: variants[0],\n options: variants,\n control: { type: 'inline-radio', },\n },\n color: {\n name: 'color',\n description: 'ButtonIcon color',\n defaultValue: colors[0],\n options: colors,\n control: { type: 'inline-radio' },\n },\n size: {\n name: 'size',\n description: 'ButtonIcon size',\n defaultValue: sizes[0],\n options: sizes,\n control: { type: 'inline-radio' },\n },\n title: {\n name: 'title',\n description: \"ButtonIcon tooltip title from HTMLAttributes<HTMLButtonElement> [string only]\",\n control: { type: 'text' },\n },\n message: {\n name: 'message',\n description: 'ButtonIcon tooltip message from ButtonProps [ReactNode]',\n control: { type: \"object\" },\n },\n disabled: {\n name: 'disabled',\n description: 'ButtonIcon disabled',\n control: { type: 'boolean' }\n },\n rounded: {\n name: 'rounded',\n description: 'ButtonIcon rounded',\n control: { type: 'boolean' }\n },\n loading: {\n name: 'loading',\n description: 'ButtonIcon loading',\n control: { type: 'boolean' }\n },\n icon: {\n name: 'icon',\n description: 'ButtonIcon icon from ButtonIconProps [`undefined` | `ComponentType<SVGProps<SVGSVGElement>>` | `ReactElement<SVGProps<SVGSVGElement>>`]',\n options: Object.keys(iconMap),\n mapping: iconMap,\n control: { type: 'inline-radio' },\n },\n children: {\n name: 'children',\n description: 'ButtonIcon children from ButtonIconProps [`ReactNode`]',\n options: Object.keys(iconChildrenMap),\n mapping: iconChildrenMap,\n control: { type: 'inline-radio' },\n },\n },\n parameters: {\n pseudo: {\n hover: '#hover',\n focus: '#focus',\n active: '#active',\n disabled: '#disabled',\n },\n }\n} satisfies Meta<typeof ButtonIcon>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\nconst args: Story['args'] = {\n asChild: false,\n disabled: false,\n loading: false,\n rounded: false,\n children: <PlusIcon/>,\n}\n\nexport const Default: Story = {\n args: {\n ...meta.args,\n icon: FileDownIcon,\n children: undefined,\n }\n};\n\nexport const Primary: Story = {\n args: {\n ...args,\n color: 'primary',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nPrimary.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n\nexport const Secondary: Story = {\n args: {\n ...args,\n color: 'secondary',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nSecondary.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n\nexport const Error: Story = {\n args: {\n ...args,\n color: 'error',\n size: 'lg',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: StateRender,\n};\nError.parameters = {\n controls: { exclude: [ 'variant', 'color' ] },\n}\n"],"names":["Template","props","jsx","ButtonIcon","States","state","StateRender","jsxs","DashedWrapper","variants","colors","sizes","variant_default","color_default","size_default","iconMap","PlusIcon","Trash2Icon","FileDownIcon","iconChildrenMap","meta","args","Default","Primary","Secondary","Error"],"mappings":";;;;AASA,MAAMA,IAAW,CAACC,MAA2B,gBAAAC,EAACC,GAAA,EAAY,GAAGF,GAAM;AACnED,EAAS,OAAO;AAAA,EACd,SAAS,EAAE,QAAQ,CAAC,MAA2C,EAAA;AACjE;AAEA,MAAMI,IAAS,CAACH,MACd,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,OAAO;AAAA,MACL,UAAU;AAAA,MACV,SAAS;AAAA,MACT,eAAe;AAAA,MACf,KAAK;AAAA,IAAA;AAAA,IAGN,UAAA,CAAE,WAAW,SAAS,SAAS,UAAU,UAAW,EAClD,IAAI,CAACG,MACJ,gBAAAH;AAAA,MAACC;AAAA,MAAA;AAAA,QAEC,IAAIE;AAAA,QACH,GAAGJ;AAAA,QACJ,UAAUI,MAAU,cAAcJ,EAAM;AAAA,QAEvC,UAAAA,EAAM;AAAA,MAAA;AAAA,MALFI;AAAA,IAAA,CAOR;AAAA,EAAA;AACL,GAGIC,IAAc,CAACL,MACnB,gBAAAM,EAAC,OAAA,EAAI,WAAU,QACb,UAAA;AAAA,EAAA,gBAAAA,EAACC,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAN,EAACE,GAAA,EAAQ,GAAGH,GAAO,SAAQ,YAAA,CAAW;AAAA,IACtC,gBAAAC,EAACE,GAAA,EAAQ,GAAGH,GAAO,SAAQ,WAAA,CAAU;AAAA,IACrC,g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A;AAAA,EAER,UAAU;AAAA,IACR,SAAS,EAAE,SAAS,GAAA;AAAA,IACpB,OAAO,EAAE,SAAS,GAAA;AAAA,EAAM;AAAA,EAE1B,QAAQf;AACV;AACAmB,EAAM,aAAa;AAAA,EACjB,UAAU,EAAE,SAAS,CAAE,WAAW,OAAQ,EAAA;AAC5C;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ButtonIconVarianceProps } from './buttonIconVariants';
|
|
2
|
-
import { ButtonBaseProps } from '../Button';
|
|
2
|
+
import { ButtonBaseProps, ButtonIconType } from '../Button';
|
|
3
3
|
export interface ButtonIconSlotProps {
|
|
4
4
|
}
|
|
5
5
|
export interface ButtonIconProps extends ButtonBaseProps<ButtonIconVarianceProps, ButtonIconSlotProps> {
|
|
6
|
+
icon?: ButtonIconType;
|
|
6
7
|
}
|
|
7
8
|
//# sourceMappingURL=ButtonIcon.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.types.d.ts","sourceRoot":"","sources":["../../src/ButtonIcon/ButtonIcon.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACL,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"ButtonIcon.types.d.ts","sourceRoot":"","sources":["../../src/ButtonIcon/ButtonIcon.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,mBAAmB;CAAG;AAEvC,MAAM,WAAW,eACf,SAAQ,eAAe,CAAC,uBAAuB,EAAE,mBAAmB,CAAC;IACrE,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB"}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.1.99-beta.5 (2025-12-29)
|
|
2
|
+
|
|
3
|
+
### 🧱 Updated Dependencies
|
|
4
|
+
|
|
5
|
+
- Updated @oneplatformdev/utils to 0.1.99-beta.5
|
|
6
|
+
- Updated @oneplatformdev/hooks to 0.1.99-beta.5
|
|
7
|
+
- Updated @oneplatformdev/tokens to 0.1.99-beta.5
|
|
8
|
+
|
|
1
9
|
## 0.1.99-beta.4 (2025-12-29)
|
|
2
10
|
|
|
3
11
|
### 🧱 Updated Dependencies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneplatformdev/ui",
|
|
3
|
-
"version": "0.1.99-beta.
|
|
3
|
+
"version": "0.1.99-beta.5",
|
|
4
4
|
"description": "UI component library for OnePlatform",
|
|
5
5
|
"author": "One Platform Development Team",
|
|
6
6
|
"keywords": [
|
|
@@ -105,8 +105,11 @@
|
|
|
105
105
|
"recharts": "^3.2.0",
|
|
106
106
|
"sonner": "^2.0.7",
|
|
107
107
|
"vaul": "^1.1.2",
|
|
108
|
-
"@oneplatformdev/tokens": "^0.1.99-beta.
|
|
109
|
-
"@oneplatformdev/
|
|
110
|
-
"@oneplatformdev/
|
|
108
|
+
"@oneplatformdev/tokens": "^0.1.99-beta.5",
|
|
109
|
+
"@oneplatformdev/utils": "^0.1.99-beta.5",
|
|
110
|
+
"@oneplatformdev/hooks": "^0.1.99-beta.5"
|
|
111
|
+
},
|
|
112
|
+
"scripts": {
|
|
113
|
+
"chromatic": "chromatic"
|
|
111
114
|
}
|
|
112
115
|
}
|
package/Button/Button.s.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { StoryObj } from '@storybook/react';
|
|
2
|
-
import { ButtonProps } from './Button.types';
|
|
3
|
-
declare const meta: {
|
|
4
|
-
title: string;
|
|
5
|
-
component: import('react').ForwardRefExoticComponent<ButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
6
|
-
render: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
args: {
|
|
8
|
-
tooltip: undefined;
|
|
9
|
-
asChild: false;
|
|
10
|
-
variant: "none" | "default" | "destructive" | "outline" | "secondary" | "contained" | "outlined" | "ghost" | null | undefined;
|
|
11
|
-
color: "secondary" | "primary" | "error" | null | undefined;
|
|
12
|
-
size: "xs" | "sm" | "md" | "lg" | null | undefined;
|
|
13
|
-
disabled: false;
|
|
14
|
-
};
|
|
15
|
-
argTypes: {
|
|
16
|
-
tooltip: {
|
|
17
|
-
control: false;
|
|
18
|
-
};
|
|
19
|
-
asChild: {
|
|
20
|
-
control: false;
|
|
21
|
-
};
|
|
22
|
-
variant: {
|
|
23
|
-
options: ("none" | "default" | "destructive" | "outline" | "secondary" | "contained" | "outlined" | "ghost" | null | undefined)[];
|
|
24
|
-
control: {
|
|
25
|
-
type: "inline-radio";
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
color: {
|
|
29
|
-
options: ("secondary" | "primary" | "error" | null | undefined)[];
|
|
30
|
-
control: {
|
|
31
|
-
type: "inline-radio";
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
size: {
|
|
35
|
-
options: ("xs" | "sm" | "md" | "lg" | null | undefined)[];
|
|
36
|
-
control: {
|
|
37
|
-
type: "inline-radio";
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
title: {
|
|
41
|
-
name: string;
|
|
42
|
-
description: string;
|
|
43
|
-
control: {
|
|
44
|
-
type: "text";
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
message: {
|
|
48
|
-
name: string;
|
|
49
|
-
description: string;
|
|
50
|
-
control: {
|
|
51
|
-
type: "object";
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
slotProps: {
|
|
55
|
-
name: string;
|
|
56
|
-
description: string;
|
|
57
|
-
control: {
|
|
58
|
-
type: "object";
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
tags: string[];
|
|
63
|
-
parameters: {
|
|
64
|
-
docs: {
|
|
65
|
-
description: {
|
|
66
|
-
component: string;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
pseudo: {
|
|
70
|
-
hover: string;
|
|
71
|
-
focus: string;
|
|
72
|
-
active: string;
|
|
73
|
-
disabled: string;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
export default meta;
|
|
78
|
-
type Story = StoryObj<typeof meta>;
|
|
79
|
-
export declare const Default: Story;
|
|
80
|
-
export declare const Primary: Story;
|
|
81
|
-
export declare const Secondary: Story;
|
|
82
|
-
export declare const Error: Story;
|
|
83
|
-
//# sourceMappingURL=Button.s.d.ts.map
|
package/Button/Button.s.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Button.s.d.ts","sourceRoot":"","sources":["../../src/Button/Button.s.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA2DlD,QAAA,MAAM,IAAI;;;oBAvDe,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwGL,CAAC;AAChC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAQnC,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAoBrB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAoBvB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAoBnB,CAAC"}
|
package/Button/Button.s.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { jsx as e, jsxs as n } from "react/jsx-runtime";
|
|
2
|
-
import { Button as i } from "./Button.js";
|
|
3
|
-
import { PlusIcon as s } from "lucide-react";
|
|
4
|
-
const g = (o) => /* @__PURE__ */ e(i, { ...o }), a = (o) => /* @__PURE__ */ e(
|
|
5
|
-
"div",
|
|
6
|
-
{
|
|
7
|
-
style: {
|
|
8
|
-
padding: "0px 20px",
|
|
9
|
-
display: "flex",
|
|
10
|
-
gap: "32px",
|
|
11
|
-
alignItems: "flex-start"
|
|
12
|
-
},
|
|
13
|
-
children: /* @__PURE__ */ e(
|
|
14
|
-
"div",
|
|
15
|
-
{
|
|
16
|
-
style: {
|
|
17
|
-
position: "relative",
|
|
18
|
-
border: "2px dashed rgba(139, 92, 246, 0.7)",
|
|
19
|
-
borderRadius: "24px",
|
|
20
|
-
padding: "24px 32px",
|
|
21
|
-
display: "flex",
|
|
22
|
-
gap: "32px"
|
|
23
|
-
},
|
|
24
|
-
children: o.children
|
|
25
|
-
}
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
), t = (o) => /* @__PURE__ */ e(
|
|
29
|
-
"div",
|
|
30
|
-
{
|
|
31
|
-
style: {
|
|
32
|
-
position: "relative",
|
|
33
|
-
display: "flex",
|
|
34
|
-
flexDirection: "column",
|
|
35
|
-
gap: "16px"
|
|
36
|
-
},
|
|
37
|
-
children: ["default", "hover", "focus", "active", "disabled"].map((r) => /* @__PURE__ */ e(
|
|
38
|
-
i,
|
|
39
|
-
{
|
|
40
|
-
id: r,
|
|
41
|
-
...o,
|
|
42
|
-
disabled: r === "disabled" || o.disabled,
|
|
43
|
-
children: o.children ?? r
|
|
44
|
-
},
|
|
45
|
-
r
|
|
46
|
-
))
|
|
47
|
-
}
|
|
48
|
-
), d = ["none", "contained", "outlined", "ghost"], c = ["primary", "secondary", "error"], p = ["xs", "sm", "md", "lg"], m = {
|
|
49
|
-
title: "Button",
|
|
50
|
-
component: i,
|
|
51
|
-
render: g,
|
|
52
|
-
args: {
|
|
53
|
-
tooltip: void 0,
|
|
54
|
-
asChild: !1,
|
|
55
|
-
//
|
|
56
|
-
variant: d[0],
|
|
57
|
-
color: c[0],
|
|
58
|
-
size: p[0],
|
|
59
|
-
disabled: !1
|
|
60
|
-
},
|
|
61
|
-
argTypes: {
|
|
62
|
-
tooltip: { control: !1 },
|
|
63
|
-
asChild: { control: !1 },
|
|
64
|
-
variant: { options: d, control: { type: "inline-radio" } },
|
|
65
|
-
color: { options: c, control: { type: "inline-radio" } },
|
|
66
|
-
size: { options: p, control: { type: "inline-radio" } },
|
|
67
|
-
title: {
|
|
68
|
-
name: "title",
|
|
69
|
-
description: "Button tooltip title from HTMLAttributes<HTMLButtonElement> [string only]",
|
|
70
|
-
control: { type: "text" }
|
|
71
|
-
},
|
|
72
|
-
message: {
|
|
73
|
-
name: "message",
|
|
74
|
-
description: "Button tooltip message from ButtonProps [ReactNode]",
|
|
75
|
-
control: { type: "object" }
|
|
76
|
-
},
|
|
77
|
-
slotProps: {
|
|
78
|
-
name: "slotProps",
|
|
79
|
-
description: "Button slotProps from ButtonProps [object]",
|
|
80
|
-
control: { type: "object" }
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
tags: ["autodocs"],
|
|
84
|
-
parameters: {
|
|
85
|
-
docs: {
|
|
86
|
-
description: {
|
|
87
|
-
component: "Universal button component with variants, icons and tooltip support."
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
pseudo: {
|
|
91
|
-
hover: "#hover",
|
|
92
|
-
focus: "#focus",
|
|
93
|
-
active: "#active",
|
|
94
|
-
disabled: "#disabled"
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}, l = {
|
|
98
|
-
...m.args,
|
|
99
|
-
startAdornment: /* @__PURE__ */ e(s, {}),
|
|
100
|
-
endAdornment: /* @__PURE__ */ e(s, {}),
|
|
101
|
-
children: "children"
|
|
102
|
-
}, u = {
|
|
103
|
-
args: {
|
|
104
|
-
...m.args,
|
|
105
|
-
children: "__children__"
|
|
106
|
-
}
|
|
107
|
-
}, y = {
|
|
108
|
-
args: {
|
|
109
|
-
...l,
|
|
110
|
-
color: "primary",
|
|
111
|
-
size: "lg",
|
|
112
|
-
children: "Створити"
|
|
113
|
-
},
|
|
114
|
-
argTypes: {
|
|
115
|
-
variant: { control: !1 },
|
|
116
|
-
color: { control: !1 }
|
|
117
|
-
},
|
|
118
|
-
render: (o) => /* @__PURE__ */ e("div", { className: "flex", children: /* @__PURE__ */ n(a, { children: [
|
|
119
|
-
/* @__PURE__ */ e(t, { ...o, variant: "contained" }),
|
|
120
|
-
/* @__PURE__ */ e(t, { ...o, variant: "outlined" }),
|
|
121
|
-
/* @__PURE__ */ e(t, { ...o, variant: "ghost" })
|
|
122
|
-
] }) })
|
|
123
|
-
}, x = {
|
|
124
|
-
args: {
|
|
125
|
-
...l,
|
|
126
|
-
color: "secondary",
|
|
127
|
-
size: "lg",
|
|
128
|
-
children: "Створити"
|
|
129
|
-
},
|
|
130
|
-
argTypes: {
|
|
131
|
-
variant: { control: !1 },
|
|
132
|
-
color: { control: !1 }
|
|
133
|
-
},
|
|
134
|
-
render: (o) => /* @__PURE__ */ e("div", { className: "flex", children: /* @__PURE__ */ n(a, { children: [
|
|
135
|
-
/* @__PURE__ */ e(t, { ...o, variant: "contained" }),
|
|
136
|
-
/* @__PURE__ */ e(t, { ...o, variant: "outlined" }),
|
|
137
|
-
/* @__PURE__ */ e(t, { ...o, variant: "ghost" })
|
|
138
|
-
] }) })
|
|
139
|
-
}, b = {
|
|
140
|
-
args: {
|
|
141
|
-
...l,
|
|
142
|
-
color: "error",
|
|
143
|
-
size: "lg",
|
|
144
|
-
children: "Створити"
|
|
145
|
-
},
|
|
146
|
-
argTypes: {
|
|
147
|
-
variant: { control: !1 },
|
|
148
|
-
color: { control: !1 }
|
|
149
|
-
},
|
|
150
|
-
render: (o) => /* @__PURE__ */ e("div", { className: "flex", children: /* @__PURE__ */ n(a, { children: [
|
|
151
|
-
/* @__PURE__ */ e(t, { ...o, variant: "contained" }),
|
|
152
|
-
/* @__PURE__ */ e(t, { ...o, variant: "outlined" }),
|
|
153
|
-
/* @__PURE__ */ e(t, { ...o, variant: "ghost" })
|
|
154
|
-
] }) })
|
|
155
|
-
};
|
|
156
|
-
export {
|
|
157
|
-
u as Default,
|
|
158
|
-
b as Error,
|
|
159
|
-
y as Primary,
|
|
160
|
-
x as Secondary,
|
|
161
|
-
m as default
|
|
162
|
-
};
|
|
163
|
-
//# sourceMappingURL=Button.s.js.map
|
package/Button/Button.s.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Button.s.js","sources":["../../src/Button/Button.s.tsx"],"sourcesContent":["import type { Meta, StoryObj } from '@storybook/react';\n\nimport { Button } from './Button';\nimport type { ButtonProps } from './Button.types';\nimport { PropsWithChildren } from 'react';\nimport { PlusIcon } from 'lucide-react'\n\nconst Template = (props: ButtonProps) => <Button {...props}/>;\n\nconst DashedWrapper = (props: PropsWithChildren) => {\n return (\n <div\n style={{\n padding: '0px 20px',\n display: 'flex',\n gap: '32px',\n alignItems: 'flex-start',\n }}\n >\n <div\n style={{\n position: 'relative',\n border: '2px dashed rgba(139, 92, 246, 0.7)',\n borderRadius: '24px',\n padding: '24px 32px',\n display: 'flex',\n gap: '32px',\n }}\n >\n {props.children}\n </div>\n </div>\n )\n}\n\nconst States = (props: ButtonProps) => (\n <div\n style={{\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: '16px',\n }}\n >\n {[ 'default', 'hover', 'focus', 'active', 'disabled' ]\n .map((state) => (\n <Button\n key={state}\n id={state}\n {...props}\n disabled={state === 'disabled' || props.disabled}\n >\n {props.children ?? state}\n </Button>\n ))}\n </div>\n);\n\nconst variants: ButtonProps['variant'][] = [ 'none', 'contained', 'outlined', 'ghost' ]\nconst colors: ButtonProps['color'][] = [ 'primary', 'secondary', 'error' ]\nconst sizes: ButtonProps['size'][] = [ 'xs', 'sm', 'md', 'lg' ]\n\nconst meta = {\n title: 'Button',\n component: Button,\n render: Template,\n args: {\n tooltip: undefined,\n asChild: false,\n //\n variant: variants[0],\n color: colors[0],\n size: sizes[0],\n disabled: false,\n },\n argTypes: {\n tooltip: { control: false },\n asChild: { control: false },\n variant: { options: variants, control: { type: 'inline-radio' } },\n color: { options: colors, control: { type: 'inline-radio' } },\n size: { options: sizes, control: { type: 'inline-radio' } },\n title: {\n name: 'title',\n description: \"Button tooltip title from HTMLAttributes<HTMLButtonElement> [string only]\",\n control: { type: 'text' },\n },\n message: {\n name: 'message',\n description: 'Button tooltip message from ButtonProps [ReactNode]',\n control: { type: \"object\" },\n },\n slotProps: {\n name: 'slotProps',\n description: 'Button slotProps from ButtonProps [object]',\n control: { type: \"object\" },\n },\n },\n tags: ['autodocs'],\n parameters: {\n docs: {\n description: {\n component: 'Universal button component with variants, icons and tooltip support.',\n },\n },\n pseudo: {\n hover: '#hover',\n focus: '#focus',\n active: '#active',\n disabled: '#disabled',\n },\n }\n} satisfies Meta<typeof Button>;\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\nconst args: Story['args'] = {\n ...meta.args,\n startAdornment: <PlusIcon/>,\n endAdornment: <PlusIcon/>,\n children: 'children',\n}\n\nexport const Default: Story = {\n args: {\n ...meta.args,\n children: '__children__',\n }\n};\n\nexport const Primary: Story = {\n args: {\n ...args,\n color: 'primary',\n size: 'lg',\n children: 'Створити',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: (props) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n </div>\n ),\n};\n\nexport const Secondary: Story = {\n args: {\n ...args,\n color: 'secondary',\n size: 'lg',\n children: 'Створити',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: (props) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n </div>\n ),\n};\n\nexport const Error: Story = {\n args: {\n ...args,\n color: 'error',\n size: 'lg',\n children: 'Створити',\n },\n argTypes: {\n variant: { control: false },\n color: { control: false },\n },\n render: (props) => (\n <div className='flex'>\n <DashedWrapper>\n <States {...props} variant='contained'/>\n <States {...props} variant='outlined'/>\n <States {...props} variant='ghost'/>\n </DashedWrapper>\n </div>\n ),\n};\n\n"],"names":["Template","props","jsx","Button","DashedWrapper","States","state","variants","colors","sizes","meta","args","PlusIcon","Default","Primary","Secondary","Error"],"mappings":";;;AAOA,MAAMA,IAAW,CAACC,MAAuB,gBAAAC,EAACC,GAAA,EAAQ,GAAGF,GAAM,GAErDG,IAAgB,CAACH,MAEnB,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,OAAO;AAAA,MACL,SAAS;AAAA,MACT,SAAS;AAAA,MACT,KAAK;AAAA,MACL,YAAY;AAAA,IAAA;AAAA,IAGd,UAAA,gBAAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO;AAAA,UACL,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,cAAc;AAAA,UACd,SAAS;AAAA,UACT,SAAS;AAAA,UACT,KAAK;AAAA,QAAA;AAAA,QAGN,UAAAD,EAAM;AAAA,MAAA;AAAA,IAAA;AAAA,EACT;AAAA,GAKAI,IAAS,CAACJ,MACd,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,OAAO;AAAA,MACL,UAAU;AAAA,MACV,SAAS;AAAA,MACT,eAAe;AAAA,MACf,KAAK;AAAA,IAAA;AAAA,IAGN,UAAA,CAAE,WAAW,SAAS,SAAS,UAAU,UAAW,EAClD,IAAI,CAACI,MACJ,gBAAAJ;AAAA,MAACC;AAAA,MAAA;AAAA,QAEC,IAAIG;AAAA,QACH,GAAGL;AAAA,QACJ,UAAUK,MAAU,cAAcL,EAAM;AAAA,QAEvC,YAAM,YAAYK;AAAA,MAAA;AAAA,MALdA;AAAA,IAAA,CAOR;AAAA,EAAA;AACL,GAGIC,IAAqC,CAAE,QAAQ,aAAa,YAAY,OAAQ,GAChFC,IAAiC,CA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