inconel 0.1.20 → 0.1.21
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/cjs/components/Button/Button.cjs +1 -1
- package/dist/cjs/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.d.ts +3 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.js +68 -64
- package/dist/components/Button/Button.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("react"),h=require("../shared/classNames.cjs");;/* empty css */const O=require("./constants.cjs");;/* empty css */const P=require("./utils.cjs"),R=require("../Svg/Svg.cjs");function Y({loading:n=!1,fullWidth:S=!1,variant:q="primary",label:v,buttonType:M,icon:s,iconClassName:k,iconWidth:l,iconHeight:o,iconRight:r=!1,render:w=!0,debounceTime:b,isActive:i,onClick:f,disabled:a,className:A,children:E,size:T="md",fixedHeight:g=!0,height:t,pill:B=!1,count:m,progress:p,progressColor:C,style:_,...N}){const I=M??q,$=!g&&t!==void 0?{..._,"--inconel-control-height":typeof t=="number"?`${t}px`:t}:_,c=j.useMemo(()=>P.createDebouncedCallback(f,b??0),[f,b]);if(j.useEffect(()=>()=>c.cancel(),[c]),!w)return null;const x=v??E,u=typeof p=="number"?Math.max(0,Math.min(100,p)):null,y=typeof s=="string"&&s?e.jsx("span",{className:h.classNames("inconel-button__icon",r?"inconel-button__icon--right":"inconel-button__icon--left",k),style:{width:l??void 0,height:o??void 0},"aria-hidden":"true",children:e.jsx(R.default,{src:s,renumerateIRIElements:!1,loading:()=>null,fallback:()=>null,beforeInjection:d=>{l&&d.setAttribute("width",String(l)),o&&d.setAttribute("height",String(o)),d.setAttribute("preserveAspectRatio","xMidYMid meet")}})}):null;return e.jsxs("button",{...N,style:$,disabled:a||n,"aria-pressed":typeof i=="boolean"?i:N["aria-pressed"],onClick:a||n?void 0:c,className:h.classNames("inconel-button",`inconel-size-${T}`,O.BUTTON_TYPE_CLASS_NAMES[I],S&&"inconel-button--full-width",u!==null&&"inconel-button--has-progress",B&&"inconel-button--pill",n&&"inconel-is-loading",a&&"inconel-is-disabled",i&&"inconel-is-active",A),children:[u!==null&&e.jsx("span",{className:"inconel-button__progress",style:{width:`${u}%`,background:C??void 0}}),n&&e.jsx("span",{className:"inconel-button__spinner","aria-hidden":"true"}),!r&&y,x!==void 0&&e.jsx("span",{className:"inconel-button__title",children:x}),r&&y,m!=null&&e.jsx("span",{className:"inconel-button__count",children:m})]})}exports.Button=Y;
|
|
2
2
|
//# sourceMappingURL=Button.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.cjs","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["import {\n useEffect,\n useMemo,\n type ButtonHTMLAttributes,\n type ReactNode,\n} from 'react'\n\nimport { classNames } from '../shared/classNames'\nimport '../shared/sizes.css'\nimport type { ControlSize } from '../shared/types'\nimport { Svg } from '../Svg'\nimport {\n BUTTON_TYPE_CLASS_NAMES,\n type ButtonType,\n} from './constants'\nimport './styles.css'\nimport { createDebouncedCallback } from './utils'\n\nexport interface ButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {\n label?: ReactNode\n buttonType?: ButtonType\n icon?: string | null\n iconClassName?: string\n iconWidth?: number | null\n iconHeight?: number | null\n iconRight?: boolean\n render?: boolean\n debounceTime?: number | null\n isActive?: boolean | null\n onChange?: ButtonHTMLAttributes<HTMLButtonElement>['onChange']\n loading?: boolean\n fullWidth?: boolean\n variant?: 'primary' | 'secondary' | 'danger' | 'ghost' | 'warning' | 'dark'\n size?: ControlSize\n pill?: boolean\n count?: ReactNode\n progress?: number | null\n progressColor?: string | null\n}\n\nexport function Button({\n loading = false,\n fullWidth = false,\n variant = 'primary',\n label,\n buttonType,\n icon,\n iconClassName,\n iconWidth,\n iconHeight,\n iconRight = false,\n render = true,\n debounceTime,\n isActive,\n onClick,\n disabled,\n className,\n children,\n size = 'md',\n pill = false,\n count,\n progress,\n progressColor,\n ...props\n}: ButtonProps) {\n const resolvedType = buttonType ?? variant\n const debouncedClick = useMemo(\n () => createDebouncedCallback(onClick, debounceTime ?? 0),\n [onClick, debounceTime],\n )\n\n useEffect(() => () => debouncedClick.cancel(), [debouncedClick])\n\n if (!render) return null\n\n const content = label ?? children\n const progressWidth =\n typeof progress === 'number' ? Math.max(0, Math.min(100, progress)) : null\n const iconNode = typeof icon === 'string' && icon ? (\n <span\n className={classNames(\n 'inconel-button__icon',\n iconRight\n ? 'inconel-button__icon--right'\n : 'inconel-button__icon--left',\n iconClassName,\n )}\n style={{ width: iconWidth ?? undefined, height: iconHeight ?? undefined }}\n aria-hidden=\"true\"\n >\n <Svg\n src={icon}\n renumerateIRIElements={false}\n loading={() => null}\n fallback={() => null}\n beforeInjection={(svg) => {\n if (iconWidth) svg.setAttribute('width', String(iconWidth))\n if (iconHeight) svg.setAttribute('height', String(iconHeight))\n svg.setAttribute('preserveAspectRatio', 'xMidYMid meet')\n }}\n />\n </span>\n ) : null\n\n return (\n <button\n {...props}\n disabled={disabled || loading}\n aria-pressed={\n typeof isActive === 'boolean' ? isActive : props['aria-pressed']\n }\n onClick={disabled || loading ? undefined : debouncedClick}\n className={classNames(\n 'inconel-button',\n `inconel-size-${size}`,\n BUTTON_TYPE_CLASS_NAMES[resolvedType],\n fullWidth && 'inconel-button--full-width',\n progressWidth !== null && 'inconel-button--has-progress',\n pill && 'inconel-button--pill',\n loading && 'inconel-is-loading',\n disabled && 'inconel-is-disabled',\n isActive && 'inconel-is-active',\n className,\n )}\n >\n {progressWidth !== null && (\n <span\n className=\"inconel-button__progress\"\n style={{\n width: `${progressWidth}%`,\n background: progressColor ?? undefined,\n }}\n />\n )}\n {loading && <span className=\"inconel-button__spinner\" aria-hidden=\"true\" />}\n {!iconRight && iconNode}\n {content !== undefined && (\n <span className=\"inconel-button__title\">{content}</span>\n )}\n {iconRight && iconNode}\n {count != null && <span className=\"inconel-button__count\">{count}</span>}\n </button>\n )\n}\n"],"names":["Button","loading","fullWidth","variant","label","buttonType","icon","iconClassName","iconWidth","iconHeight","iconRight","render","debounceTime","isActive","onClick","disabled","className","children","size","pill","count","progress","progressColor","props","resolvedType","debouncedClick","useMemo","createDebouncedCallback","useEffect","content","progressWidth","iconNode","jsx","classNames","Svg","svg","jsxs","BUTTON_TYPE_CLASS_NAMES"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.cjs","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["import {\n useEffect,\n useMemo,\n type ButtonHTMLAttributes,\n type ReactNode,\n} from 'react'\n\nimport { classNames } from '../shared/classNames'\nimport '../shared/sizes.css'\nimport type { ControlSize } from '../shared/types'\nimport { Svg } from '../Svg'\nimport {\n BUTTON_TYPE_CLASS_NAMES,\n type ButtonType,\n} from './constants'\nimport './styles.css'\nimport { createDebouncedCallback } from './utils'\n\nexport interface ButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {\n label?: ReactNode\n buttonType?: ButtonType\n icon?: string | null\n iconClassName?: string\n iconWidth?: number | null\n iconHeight?: number | null\n iconRight?: boolean\n render?: boolean\n debounceTime?: number | null\n isActive?: boolean | null\n onChange?: ButtonHTMLAttributes<HTMLButtonElement>['onChange']\n loading?: boolean\n fullWidth?: boolean\n variant?: 'primary' | 'secondary' | 'danger' | 'ghost' | 'warning' | 'dark'\n size?: ControlSize\n fixedHeight?: boolean\n height?: number | string\n pill?: boolean\n count?: ReactNode\n progress?: number | null\n progressColor?: string | null\n}\n\nexport function Button({\n loading = false,\n fullWidth = false,\n variant = 'primary',\n label,\n buttonType,\n icon,\n iconClassName,\n iconWidth,\n iconHeight,\n iconRight = false,\n render = true,\n debounceTime,\n isActive,\n onClick,\n disabled,\n className,\n children,\n size = 'md',\n fixedHeight = true,\n height,\n pill = false,\n count,\n progress,\n progressColor,\n style,\n ...props\n}: ButtonProps) {\n const resolvedType = buttonType ?? variant\n const resolvedStyle = !fixedHeight && height !== undefined\n ? { ...style, '--inconel-control-height': typeof height === 'number' ? `${height}px` : height } as typeof style\n : style\n const debouncedClick = useMemo(\n () => createDebouncedCallback(onClick, debounceTime ?? 0),\n [onClick, debounceTime],\n )\n\n useEffect(() => () => debouncedClick.cancel(), [debouncedClick])\n\n if (!render) return null\n\n const content = label ?? children\n const progressWidth =\n typeof progress === 'number' ? Math.max(0, Math.min(100, progress)) : null\n const iconNode = typeof icon === 'string' && icon ? (\n <span\n className={classNames(\n 'inconel-button__icon',\n iconRight\n ? 'inconel-button__icon--right'\n : 'inconel-button__icon--left',\n iconClassName,\n )}\n style={{ width: iconWidth ?? undefined, height: iconHeight ?? undefined }}\n aria-hidden=\"true\"\n >\n <Svg\n src={icon}\n renumerateIRIElements={false}\n loading={() => null}\n fallback={() => null}\n beforeInjection={(svg) => {\n if (iconWidth) svg.setAttribute('width', String(iconWidth))\n if (iconHeight) svg.setAttribute('height', String(iconHeight))\n svg.setAttribute('preserveAspectRatio', 'xMidYMid meet')\n }}\n />\n </span>\n ) : null\n\n return (\n <button\n {...props}\n style={resolvedStyle}\n disabled={disabled || loading}\n aria-pressed={\n typeof isActive === 'boolean' ? isActive : props['aria-pressed']\n }\n onClick={disabled || loading ? undefined : debouncedClick}\n className={classNames(\n 'inconel-button',\n `inconel-size-${size}`,\n BUTTON_TYPE_CLASS_NAMES[resolvedType],\n fullWidth && 'inconel-button--full-width',\n progressWidth !== null && 'inconel-button--has-progress',\n pill && 'inconel-button--pill',\n loading && 'inconel-is-loading',\n disabled && 'inconel-is-disabled',\n isActive && 'inconel-is-active',\n className,\n )}\n >\n {progressWidth !== null && (\n <span\n className=\"inconel-button__progress\"\n style={{\n width: `${progressWidth}%`,\n background: progressColor ?? undefined,\n }}\n />\n )}\n {loading && <span className=\"inconel-button__spinner\" aria-hidden=\"true\" />}\n {!iconRight && iconNode}\n {content !== undefined && (\n <span className=\"inconel-button__title\">{content}</span>\n )}\n {iconRight && iconNode}\n {count != null && <span className=\"inconel-button__count\">{count}</span>}\n </button>\n )\n}\n"],"names":["Button","loading","fullWidth","variant","label","buttonType","icon","iconClassName","iconWidth","iconHeight","iconRight","render","debounceTime","isActive","onClick","disabled","className","children","size","fixedHeight","height","pill","count","progress","progressColor","style","props","resolvedType","resolvedStyle","debouncedClick","useMemo","createDebouncedCallback","useEffect","content","progressWidth","iconNode","jsx","classNames","Svg","svg","jsxs","BUTTON_TYPE_CLASS_NAMES"],"mappings":"2UA2CO,SAASA,EAAO,CACrB,QAAAC,EAAU,GACV,UAAAC,EAAY,GACZ,QAAAC,EAAU,UACV,MAAAC,EACA,WAAAC,EACA,KAAAC,EACA,cAAAC,EACA,UAAAC,EACA,WAAAC,EACA,UAAAC,EAAY,GACZ,OAAAC,EAAS,GACT,aAAAC,EACA,SAAAC,EACA,QAAAC,EACA,SAAAC,EACA,UAAAC,EACA,SAAAC,EACA,KAAAC,EAAO,KACP,YAAAC,EAAc,GACd,OAAAC,EACA,KAAAC,EAAO,GACP,MAAAC,EACA,SAAAC,EACA,cAAAC,EACA,MAAAC,EACA,GAAGC,CACL,EAAgB,CACd,MAAMC,EAAetB,GAAcF,EAC7ByB,EAAgB,CAACT,GAAeC,IAAW,OAC7C,CAAE,GAAGK,EAAO,2BAA4B,OAAOL,GAAW,SAAW,GAAGA,CAAM,KAAOA,GACrFK,EACEI,EAAiBC,EAAAA,QACrB,IAAMC,0BAAwBjB,EAASF,GAAgB,CAAC,EACxD,CAACE,EAASF,CAAY,CAAA,EAKxB,GAFAoB,EAAAA,UAAU,IAAM,IAAMH,EAAe,SAAU,CAACA,CAAc,CAAC,EAE3D,CAAClB,EAAQ,OAAO,KAEpB,MAAMsB,EAAU7B,GAASa,EACnBiB,EACJ,OAAOX,GAAa,SAAW,KAAK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S,MAAQc,EAAAA,IAAC,OAAA,CAAK,UAAU,wBAAyB,SAAAd,CAAA,CAAM,CAAA,CAAA,CAAA,CAGvE"}
|
|
@@ -17,10 +17,12 @@ export interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement
|
|
|
17
17
|
fullWidth?: boolean;
|
|
18
18
|
variant?: 'primary' | 'secondary' | 'danger' | 'ghost' | 'warning' | 'dark';
|
|
19
19
|
size?: ControlSize;
|
|
20
|
+
fixedHeight?: boolean;
|
|
21
|
+
height?: number | string;
|
|
20
22
|
pill?: boolean;
|
|
21
23
|
count?: ReactNode;
|
|
22
24
|
progress?: number | null;
|
|
23
25
|
progressColor?: string | null;
|
|
24
26
|
}
|
|
25
|
-
export declare function Button({ loading, fullWidth, variant, label, buttonType, icon, iconClassName, iconWidth, iconHeight, iconRight, render, debounceTime, isActive, onClick, disabled, className, children, size, pill, count, progress, progressColor, ...props }: ButtonProps): import("react").JSX.Element | null;
|
|
27
|
+
export declare function Button({ loading, fullWidth, variant, label, buttonType, icon, iconClassName, iconWidth, iconHeight, iconRight, render, debounceTime, isActive, onClick, disabled, className, children, size, fixedHeight, height, pill, count, progress, progressColor, style, ...props }: ButtonProps): import("react").JSX.Element | null;
|
|
26
28
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAGd,OAAO,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,OAAO,EAEL,KAAK,UAAU,EAChB,MAAM,aAAa,CAAA;AACpB,OAAO,cAAc,CAAA;AAGrB,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;I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,SAAS,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED,wBAAgB,MAAM,CAAC,EACrB,OAAe,EACf,SAAiB,EACjB,OAAmB,EACnB,KAAK,EACL,UAAU,EACV,IAAI,EACJ,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAiB,EACjB,MAAa,EACb,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,IAAW,EACX,WAAkB,EAClB,MAAM,EACN,IAAY,EACZ,KAAK,EACL,QAAQ,EACR,aAAa,EACb,KAAK,EACL,GAAG,KAAK,EACT,EAAE,WAAW,sCAmFb"}
|
|
@@ -1,105 +1,109 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { classNames as
|
|
1
|
+
import { jsx as e, jsxs as g } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as z, useEffect as D } from "react";
|
|
3
|
+
import { classNames as v } from "../shared/classNames.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { BUTTON_TYPE_CLASS_NAMES as
|
|
5
|
+
import { BUTTON_TYPE_CLASS_NAMES as L } from "./constants.js";
|
|
6
6
|
/* empty css */
|
|
7
|
-
import { createDebouncedCallback as
|
|
8
|
-
import
|
|
9
|
-
function
|
|
7
|
+
import { createDebouncedCallback as O } from "./utils.js";
|
|
8
|
+
import P from "../Svg/Svg.js";
|
|
9
|
+
function V({
|
|
10
10
|
loading: n = !1,
|
|
11
|
-
fullWidth:
|
|
12
|
-
variant:
|
|
13
|
-
label:
|
|
14
|
-
buttonType:
|
|
15
|
-
icon:
|
|
16
|
-
iconClassName:
|
|
17
|
-
iconWidth:
|
|
18
|
-
iconHeight:
|
|
19
|
-
iconRight:
|
|
20
|
-
render:
|
|
21
|
-
debounceTime:
|
|
22
|
-
isActive:
|
|
23
|
-
onClick:
|
|
24
|
-
disabled:
|
|
25
|
-
className:
|
|
26
|
-
children:
|
|
27
|
-
size:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
fullWidth: S = !1,
|
|
12
|
+
variant: x = "primary",
|
|
13
|
+
label: M,
|
|
14
|
+
buttonType: k,
|
|
15
|
+
icon: o,
|
|
16
|
+
iconClassName: w,
|
|
17
|
+
iconWidth: l,
|
|
18
|
+
iconHeight: r,
|
|
19
|
+
iconRight: s = !1,
|
|
20
|
+
render: A = !0,
|
|
21
|
+
debounceTime: d,
|
|
22
|
+
isActive: i,
|
|
23
|
+
onClick: p,
|
|
24
|
+
disabled: a,
|
|
25
|
+
className: E,
|
|
26
|
+
children: j,
|
|
27
|
+
size: C = "md",
|
|
28
|
+
fixedHeight: I = !0,
|
|
29
|
+
height: t,
|
|
30
|
+
pill: T = !1,
|
|
31
|
+
count: f,
|
|
32
|
+
progress: b,
|
|
33
|
+
progressColor: $,
|
|
34
|
+
style: _,
|
|
35
|
+
...N
|
|
33
36
|
}) {
|
|
34
|
-
const
|
|
35
|
-
() =>
|
|
36
|
-
[
|
|
37
|
+
const B = k ?? x, Y = !I && t !== void 0 ? { ..._, "--inconel-control-height": typeof t == "number" ? `${t}px` : t } : _, c = z(
|
|
38
|
+
() => O(p, d ?? 0),
|
|
39
|
+
[p, d]
|
|
37
40
|
);
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
41
|
+
if (D(() => () => c.cancel(), [c]), !A) return null;
|
|
42
|
+
const h = M ?? j, u = typeof b == "number" ? Math.max(0, Math.min(100, b)) : null, y = typeof o == "string" && o ? /* @__PURE__ */ e(
|
|
40
43
|
"span",
|
|
41
44
|
{
|
|
42
|
-
className:
|
|
45
|
+
className: v(
|
|
43
46
|
"inconel-button__icon",
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
s ? "inconel-button__icon--right" : "inconel-button__icon--left",
|
|
48
|
+
w
|
|
46
49
|
),
|
|
47
|
-
style: { width:
|
|
50
|
+
style: { width: l ?? void 0, height: r ?? void 0 },
|
|
48
51
|
"aria-hidden": "true",
|
|
49
52
|
children: /* @__PURE__ */ e(
|
|
50
|
-
|
|
53
|
+
P,
|
|
51
54
|
{
|
|
52
|
-
src:
|
|
55
|
+
src: o,
|
|
53
56
|
renumerateIRIElements: !1,
|
|
54
57
|
loading: () => null,
|
|
55
58
|
fallback: () => null,
|
|
56
|
-
beforeInjection: (
|
|
57
|
-
|
|
59
|
+
beforeInjection: (m) => {
|
|
60
|
+
l && m.setAttribute("width", String(l)), r && m.setAttribute("height", String(r)), m.setAttribute("preserveAspectRatio", "xMidYMid meet");
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
)
|
|
61
64
|
}
|
|
62
65
|
) : null;
|
|
63
|
-
return /* @__PURE__ */
|
|
66
|
+
return /* @__PURE__ */ g(
|
|
64
67
|
"button",
|
|
65
68
|
{
|
|
66
|
-
...
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
...N,
|
|
70
|
+
style: Y,
|
|
71
|
+
disabled: a || n,
|
|
72
|
+
"aria-pressed": typeof i == "boolean" ? i : N["aria-pressed"],
|
|
73
|
+
onClick: a || n ? void 0 : c,
|
|
74
|
+
className: v(
|
|
71
75
|
"inconel-button",
|
|
72
|
-
`inconel-size-${
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
`inconel-size-${C}`,
|
|
77
|
+
L[B],
|
|
78
|
+
S && "inconel-button--full-width",
|
|
79
|
+
u !== null && "inconel-button--has-progress",
|
|
80
|
+
T && "inconel-button--pill",
|
|
77
81
|
n && "inconel-is-loading",
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
a && "inconel-is-disabled",
|
|
83
|
+
i && "inconel-is-active",
|
|
84
|
+
E
|
|
81
85
|
),
|
|
82
86
|
children: [
|
|
83
|
-
|
|
87
|
+
u !== null && /* @__PURE__ */ e(
|
|
84
88
|
"span",
|
|
85
89
|
{
|
|
86
90
|
className: "inconel-button__progress",
|
|
87
91
|
style: {
|
|
88
|
-
width: `${
|
|
89
|
-
background:
|
|
92
|
+
width: `${u}%`,
|
|
93
|
+
background: $ ?? void 0
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
),
|
|
93
97
|
n && /* @__PURE__ */ e("span", { className: "inconel-button__spinner", "aria-hidden": "true" }),
|
|
94
|
-
!
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
!s && y,
|
|
99
|
+
h !== void 0 && /* @__PURE__ */ e("span", { className: "inconel-button__title", children: h }),
|
|
100
|
+
s && y,
|
|
101
|
+
f != null && /* @__PURE__ */ e("span", { className: "inconel-button__count", children: f })
|
|
98
102
|
]
|
|
99
103
|
}
|
|
100
104
|
);
|
|
101
105
|
}
|
|
102
106
|
export {
|
|
103
|
-
|
|
107
|
+
V as Button
|
|
104
108
|
};
|
|
105
109
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import {\n useEffect,\n useMemo,\n type ButtonHTMLAttributes,\n type ReactNode,\n} from 'react'\n\nimport { classNames } from '../shared/classNames'\nimport '../shared/sizes.css'\nimport type { ControlSize } from '../shared/types'\nimport { Svg } from '../Svg'\nimport {\n BUTTON_TYPE_CLASS_NAMES,\n type ButtonType,\n} from './constants'\nimport './styles.css'\nimport { createDebouncedCallback } from './utils'\n\nexport interface ButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {\n label?: ReactNode\n buttonType?: ButtonType\n icon?: string | null\n iconClassName?: string\n iconWidth?: number | null\n iconHeight?: number | null\n iconRight?: boolean\n render?: boolean\n debounceTime?: number | null\n isActive?: boolean | null\n onChange?: ButtonHTMLAttributes<HTMLButtonElement>['onChange']\n loading?: boolean\n fullWidth?: boolean\n variant?: 'primary' | 'secondary' | 'danger' | 'ghost' | 'warning' | 'dark'\n size?: ControlSize\n pill?: boolean\n count?: ReactNode\n progress?: number | null\n progressColor?: string | null\n}\n\nexport function Button({\n loading = false,\n fullWidth = false,\n variant = 'primary',\n label,\n buttonType,\n icon,\n iconClassName,\n iconWidth,\n iconHeight,\n iconRight = false,\n render = true,\n debounceTime,\n isActive,\n onClick,\n disabled,\n className,\n children,\n size = 'md',\n pill = false,\n count,\n progress,\n progressColor,\n ...props\n}: ButtonProps) {\n const resolvedType = buttonType ?? variant\n const debouncedClick = useMemo(\n () => createDebouncedCallback(onClick, debounceTime ?? 0),\n [onClick, debounceTime],\n )\n\n useEffect(() => () => debouncedClick.cancel(), [debouncedClick])\n\n if (!render) return null\n\n const content = label ?? children\n const progressWidth =\n typeof progress === 'number' ? Math.max(0, Math.min(100, progress)) : null\n const iconNode = typeof icon === 'string' && icon ? (\n <span\n className={classNames(\n 'inconel-button__icon',\n iconRight\n ? 'inconel-button__icon--right'\n : 'inconel-button__icon--left',\n iconClassName,\n )}\n style={{ width: iconWidth ?? undefined, height: iconHeight ?? undefined }}\n aria-hidden=\"true\"\n >\n <Svg\n src={icon}\n renumerateIRIElements={false}\n loading={() => null}\n fallback={() => null}\n beforeInjection={(svg) => {\n if (iconWidth) svg.setAttribute('width', String(iconWidth))\n if (iconHeight) svg.setAttribute('height', String(iconHeight))\n svg.setAttribute('preserveAspectRatio', 'xMidYMid meet')\n }}\n />\n </span>\n ) : null\n\n return (\n <button\n {...props}\n disabled={disabled || loading}\n aria-pressed={\n typeof isActive === 'boolean' ? isActive : props['aria-pressed']\n }\n onClick={disabled || loading ? undefined : debouncedClick}\n className={classNames(\n 'inconel-button',\n `inconel-size-${size}`,\n BUTTON_TYPE_CLASS_NAMES[resolvedType],\n fullWidth && 'inconel-button--full-width',\n progressWidth !== null && 'inconel-button--has-progress',\n pill && 'inconel-button--pill',\n loading && 'inconel-is-loading',\n disabled && 'inconel-is-disabled',\n isActive && 'inconel-is-active',\n className,\n )}\n >\n {progressWidth !== null && (\n <span\n className=\"inconel-button__progress\"\n style={{\n width: `${progressWidth}%`,\n background: progressColor ?? undefined,\n }}\n />\n )}\n {loading && <span className=\"inconel-button__spinner\" aria-hidden=\"true\" />}\n {!iconRight && iconNode}\n {content !== undefined && (\n <span className=\"inconel-button__title\">{content}</span>\n )}\n {iconRight && iconNode}\n {count != null && <span className=\"inconel-button__count\">{count}</span>}\n </button>\n )\n}\n"],"names":["Button","loading","fullWidth","variant","label","buttonType","icon","iconClassName","iconWidth","iconHeight","iconRight","render","debounceTime","isActive","onClick","disabled","className","children","size","pill","count","progress","progressColor","props","resolvedType","debouncedClick","useMemo","createDebouncedCallback","useEffect","content","progressWidth","iconNode","jsx","classNames","Svg","svg","jsxs","BUTTON_TYPE_CLASS_NAMES"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import {\n useEffect,\n useMemo,\n type ButtonHTMLAttributes,\n type ReactNode,\n} from 'react'\n\nimport { classNames } from '../shared/classNames'\nimport '../shared/sizes.css'\nimport type { ControlSize } from '../shared/types'\nimport { Svg } from '../Svg'\nimport {\n BUTTON_TYPE_CLASS_NAMES,\n type ButtonType,\n} from './constants'\nimport './styles.css'\nimport { createDebouncedCallback } from './utils'\n\nexport interface ButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> {\n label?: ReactNode\n buttonType?: ButtonType\n icon?: string | null\n iconClassName?: string\n iconWidth?: number | null\n iconHeight?: number | null\n iconRight?: boolean\n render?: boolean\n debounceTime?: number | null\n isActive?: boolean | null\n onChange?: ButtonHTMLAttributes<HTMLButtonElement>['onChange']\n loading?: boolean\n fullWidth?: boolean\n variant?: 'primary' | 'secondary' | 'danger' | 'ghost' | 'warning' | 'dark'\n size?: ControlSize\n fixedHeight?: boolean\n height?: number | string\n pill?: boolean\n count?: ReactNode\n progress?: number | null\n progressColor?: string | null\n}\n\nexport function Button({\n loading = false,\n fullWidth = false,\n variant = 'primary',\n label,\n buttonType,\n icon,\n iconClassName,\n iconWidth,\n iconHeight,\n iconRight = false,\n render = true,\n debounceTime,\n isActive,\n onClick,\n disabled,\n className,\n children,\n size = 'md',\n fixedHeight = true,\n height,\n pill = false,\n count,\n progress,\n progressColor,\n style,\n ...props\n}: ButtonProps) {\n const resolvedType = buttonType ?? variant\n const resolvedStyle = !fixedHeight && height !== undefined\n ? { ...style, '--inconel-control-height': typeof height === 'number' ? `${height}px` : height } as typeof style\n : style\n const debouncedClick = useMemo(\n () => createDebouncedCallback(onClick, debounceTime ?? 0),\n [onClick, debounceTime],\n )\n\n useEffect(() => () => debouncedClick.cancel(), [debouncedClick])\n\n if (!render) return null\n\n const content = label ?? children\n const progressWidth =\n typeof progress === 'number' ? Math.max(0, Math.min(100, progress)) : null\n const iconNode = typeof icon === 'string' && icon ? (\n <span\n className={classNames(\n 'inconel-button__icon',\n iconRight\n ? 'inconel-button__icon--right'\n : 'inconel-button__icon--left',\n iconClassName,\n )}\n style={{ width: iconWidth ?? undefined, height: iconHeight ?? undefined }}\n aria-hidden=\"true\"\n >\n <Svg\n src={icon}\n renumerateIRIElements={false}\n loading={() => null}\n fallback={() => null}\n beforeInjection={(svg) => {\n if (iconWidth) svg.setAttribute('width', String(iconWidth))\n if (iconHeight) svg.setAttribute('height', String(iconHeight))\n svg.setAttribute('preserveAspectRatio', 'xMidYMid meet')\n }}\n />\n </span>\n ) : null\n\n return (\n <button\n {...props}\n style={resolvedStyle}\n disabled={disabled || loading}\n aria-pressed={\n typeof isActive === 'boolean' ? isActive : props['aria-pressed']\n }\n onClick={disabled || loading ? undefined : debouncedClick}\n className={classNames(\n 'inconel-button',\n `inconel-size-${size}`,\n BUTTON_TYPE_CLASS_NAMES[resolvedType],\n fullWidth && 'inconel-button--full-width',\n progressWidth !== null && 'inconel-button--has-progress',\n pill && 'inconel-button--pill',\n loading && 'inconel-is-loading',\n disabled && 'inconel-is-disabled',\n isActive && 'inconel-is-active',\n className,\n )}\n >\n {progressWidth !== null && (\n <span\n className=\"inconel-button__progress\"\n style={{\n width: `${progressWidth}%`,\n background: progressColor ?? undefined,\n }}\n />\n )}\n {loading && <span className=\"inconel-button__spinner\" aria-hidden=\"true\" />}\n {!iconRight && iconNode}\n {content !== undefined && (\n <span className=\"inconel-button__title\">{content}</span>\n )}\n {iconRight && iconNode}\n {count != null && <span className=\"inconel-button__count\">{count}</span>}\n </button>\n )\n}\n"],"names":["Button","loading","fullWidth","variant","label","buttonType","icon","iconClassName","iconWidth","iconHeight","iconRight","render","debounceTime","isActive","onClick","disabled","className","children","size","fixedHeight","height","pill","count","progress","progressColor","style","props","resolvedType","resolvedStyle","debouncedClick","useMemo","createDebouncedCallback","useEffect","content","progressWidth","iconNode","jsx","classNames","Svg","svg","jsxs","BUTTON_TYPE_CLASS_NAMES"],"mappings":";;;;;;;;AA2CO,SAASA,EAAO;AAAA,EACrB,SAAAC,IAAU;AAAA,EACV,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU;AAAA,EACV,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC;AAAA,EACA,eAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,QAAAC,IAAS;AAAA,EACT,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,aAAAC,IAAc;AAAA,EACd,QAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,GAAgB;AACd,QAAMC,IAAetB,KAAcF,GAC7ByB,IAAgB,CAACT,KAAeC,MAAW,SAC7C,EAAE,GAAGK,GAAO,4BAA4B,OAAOL,KAAW,WA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