@negative-space/button 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +94 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +88 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -5
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlexProps } from '@negative-space/flex';
|
|
3
|
+
import { SpinnerProps } from '@negative-space/spinner';
|
|
4
|
+
|
|
5
|
+
interface ButtonProps extends Omit<FlexProps<'button'>, 'as' | 'prefix' | 'className' | 'style'> {
|
|
6
|
+
prefix?: React.ReactNode;
|
|
7
|
+
suffix?: React.ReactNode;
|
|
8
|
+
classNames?: {
|
|
9
|
+
btn?: string;
|
|
10
|
+
content?: string;
|
|
11
|
+
prefix?: string;
|
|
12
|
+
suffix?: string;
|
|
13
|
+
};
|
|
14
|
+
styles?: {
|
|
15
|
+
btn?: React.CSSProperties;
|
|
16
|
+
content?: React.CSSProperties;
|
|
17
|
+
prefix?: React.CSSProperties;
|
|
18
|
+
suffix?: React.CSSProperties;
|
|
19
|
+
};
|
|
20
|
+
isRippleDisabled?: boolean;
|
|
21
|
+
isLoading?: boolean;
|
|
22
|
+
spinner?: React.ReactNode;
|
|
23
|
+
spinnerPosition?: 'full' | 'prefix' | 'content' | 'suffix';
|
|
24
|
+
spinnerProps?: SpinnerProps;
|
|
25
|
+
}
|
|
26
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
27
|
+
|
|
28
|
+
export { Button, type ButtonProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlexProps } from '@negative-space/flex';
|
|
3
|
+
import { SpinnerProps } from '@negative-space/spinner';
|
|
4
|
+
|
|
5
|
+
interface ButtonProps extends Omit<FlexProps<'button'>, 'as' | 'prefix' | 'className' | 'style'> {
|
|
6
|
+
prefix?: React.ReactNode;
|
|
7
|
+
suffix?: React.ReactNode;
|
|
8
|
+
classNames?: {
|
|
9
|
+
btn?: string;
|
|
10
|
+
content?: string;
|
|
11
|
+
prefix?: string;
|
|
12
|
+
suffix?: string;
|
|
13
|
+
};
|
|
14
|
+
styles?: {
|
|
15
|
+
btn?: React.CSSProperties;
|
|
16
|
+
content?: React.CSSProperties;
|
|
17
|
+
prefix?: React.CSSProperties;
|
|
18
|
+
suffix?: React.CSSProperties;
|
|
19
|
+
};
|
|
20
|
+
isRippleDisabled?: boolean;
|
|
21
|
+
isLoading?: boolean;
|
|
22
|
+
spinner?: React.ReactNode;
|
|
23
|
+
spinnerPosition?: 'full' | 'prefix' | 'content' | 'suffix';
|
|
24
|
+
spinnerProps?: SpinnerProps;
|
|
25
|
+
}
|
|
26
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
27
|
+
|
|
28
|
+
export { Button, type ButtonProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var system = require('@negative-space/system');
|
|
5
|
+
var flex = require('@negative-space/flex');
|
|
6
|
+
var spinner = require('@negative-space/spinner');
|
|
7
|
+
var ripple = require('@negative-space/ripple');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
13
|
+
|
|
14
|
+
// src/Button.tsx
|
|
15
|
+
var Button = React__default.default.forwardRef(
|
|
16
|
+
({
|
|
17
|
+
children,
|
|
18
|
+
prefix,
|
|
19
|
+
suffix,
|
|
20
|
+
classNames,
|
|
21
|
+
styles,
|
|
22
|
+
disabled = false,
|
|
23
|
+
isRippleDisabled,
|
|
24
|
+
onClick,
|
|
25
|
+
isLoading = false,
|
|
26
|
+
spinner: spinner$1,
|
|
27
|
+
spinnerPosition = "full",
|
|
28
|
+
spinnerProps,
|
|
29
|
+
alignItems = "center",
|
|
30
|
+
justify = "center",
|
|
31
|
+
...props
|
|
32
|
+
}, ref) => {
|
|
33
|
+
const { global, components } = system.useNSUI();
|
|
34
|
+
const rippleDisabled = isRippleDisabled ?? components.button.isRippleDisabled;
|
|
35
|
+
const { createRipple } = ripple.useRipple(`${global.prefixCls}-ripple`);
|
|
36
|
+
const isDisabled = disabled || isLoading;
|
|
37
|
+
const resolvedSpinner = spinner$1 ?? /* @__PURE__ */ jsxRuntime.jsx(spinner.Spinner, { ...spinnerProps });
|
|
38
|
+
const handleClick = (e) => {
|
|
39
|
+
if (isDisabled) return;
|
|
40
|
+
const isKeyboard = e.detail === 0;
|
|
41
|
+
if (!rippleDisabled) createRipple(e, { centered: isKeyboard });
|
|
42
|
+
onClick?.(e);
|
|
43
|
+
};
|
|
44
|
+
const showPrefix = prefix || isLoading && spinnerPosition === "prefix";
|
|
45
|
+
const showContent = children || isLoading && spinnerPosition === "content";
|
|
46
|
+
const showSuffix = suffix || isLoading && spinnerPosition === "suffix";
|
|
47
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
48
|
+
flex.Flex,
|
|
49
|
+
{
|
|
50
|
+
...props,
|
|
51
|
+
ref,
|
|
52
|
+
as: "button",
|
|
53
|
+
alignItems,
|
|
54
|
+
justify,
|
|
55
|
+
disabled: isDisabled,
|
|
56
|
+
"data-disabled": isDisabled,
|
|
57
|
+
onClick: handleClick,
|
|
58
|
+
className: system.cn(`${global.prefixCls}-btn`, classNames?.btn),
|
|
59
|
+
style: styles?.btn,
|
|
60
|
+
children: spinnerPosition === "full" && isLoading ? resolvedSpinner : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
61
|
+
showPrefix && /* @__PURE__ */ jsxRuntime.jsx(
|
|
62
|
+
"span",
|
|
63
|
+
{
|
|
64
|
+
className: system.cn(`${global.prefixCls}-btn-prefix`, classNames?.prefix),
|
|
65
|
+
style: styles?.prefix,
|
|
66
|
+
children: spinnerPosition === "prefix" && isLoading ? resolvedSpinner : prefix
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
showContent && /* @__PURE__ */ jsxRuntime.jsx(
|
|
70
|
+
"span",
|
|
71
|
+
{
|
|
72
|
+
className: system.cn(`${global.prefixCls}-btn-content`, classNames?.content),
|
|
73
|
+
style: styles?.content,
|
|
74
|
+
children: spinnerPosition === "content" && isLoading ? resolvedSpinner : children
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
showSuffix && /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
|
+
"span",
|
|
79
|
+
{
|
|
80
|
+
className: system.cn(`${global.prefixCls}-btn-suffix`, classNames?.suffix),
|
|
81
|
+
style: styles?.suffix,
|
|
82
|
+
children: spinnerPosition === "suffix" && isLoading ? resolvedSpinner : suffix
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
] })
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
Button.displayName = "Button";
|
|
91
|
+
|
|
92
|
+
exports.Button = Button;
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Button.tsx"],"names":["React","spinner","useNSUI","useRipple","jsx","Spinner","Flex","cn","jsxs","Fragment"],"mappings":";;;;;;;;;;;;;;AA+BO,IAAM,SAASA,sBAAA,CAAM,UAAA;AAAA,EAC1B,CACE;AAAA,IACE,QAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA,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,eAAA,GAAkB;AAAA;AAAA;AACjE,SAAA,EAEJ;AAAA;AAAA,KAEJ;AAAA,EAEJ;AACF;AAEA,MAAA,CAAO,WAAA,GAAc,QAAA","file":"index.js","sourcesContent":["import React from 'react'\nimport { cn, useNSUI } from '@negative-space/system'\nimport { Flex, FlexProps } from '@negative-space/flex'\nimport { Spinner, type SpinnerProps } from '@negative-space/spinner'\nimport { useRipple } from '@negative-space/ripple'\n\nexport interface ButtonProps extends Omit<\n FlexProps<'button'>,\n 'as' | 'prefix' | 'className' | 'style'\n> {\n prefix?: React.ReactNode\n suffix?: React.ReactNode\n classNames?: {\n btn?: string\n content?: string\n prefix?: string\n suffix?: string\n }\n styles?: {\n btn?: React.CSSProperties\n content?: React.CSSProperties\n prefix?: React.CSSProperties\n suffix?: React.CSSProperties\n }\n isRippleDisabled?: boolean\n isLoading?: boolean\n spinner?: React.ReactNode\n spinnerPosition?: 'full' | 'prefix' | 'content' | 'suffix'\n spinnerProps?: SpinnerProps\n}\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n children,\n prefix,\n suffix,\n classNames,\n styles,\n disabled = false,\n isRippleDisabled,\n onClick,\n isLoading = false,\n spinner,\n spinnerPosition = 'full',\n spinnerProps,\n alignItems = 'center',\n justify = 'center',\n ...props\n },\n ref\n ) => {\n const { global, components } = useNSUI()\n const rippleDisabled = isRippleDisabled ?? components.button.isRippleDisabled\n\n const { createRipple } = useRipple(`${global.prefixCls}-ripple`)\n const isDisabled = disabled || isLoading\n\n const resolvedSpinner = spinner ?? <Spinner {...spinnerProps} />\n\n const handleClick: React.MouseEventHandler<HTMLButtonElement> = (e) => {\n if (isDisabled) return\n const isKeyboard = e.detail === 0\n if (!rippleDisabled) createRipple(e, { centered: isKeyboard })\n\n onClick?.(e)\n }\n\n const showPrefix = prefix || (isLoading && spinnerPosition === 'prefix')\n const showContent = children || (isLoading && spinnerPosition === 'content')\n const showSuffix = suffix || (isLoading && spinnerPosition === 'suffix')\n\n return (\n <Flex\n {...props}\n ref={ref}\n as=\"button\"\n alignItems={alignItems}\n justify={justify}\n disabled={isDisabled}\n data-disabled={isDisabled}\n onClick={handleClick}\n className={cn(`${global.prefixCls}-btn`, classNames?.btn)}\n style={styles?.btn}\n >\n {spinnerPosition === 'full' && isLoading ? (\n resolvedSpinner\n ) : (\n <>\n {showPrefix && (\n <span\n className={cn(`${global.prefixCls}-btn-prefix`, classNames?.prefix)}\n style={styles?.prefix}\n >\n {spinnerPosition === 'prefix' && isLoading ? resolvedSpinner : prefix}\n </span>\n )}\n\n {showContent && (\n <span\n className={cn(`${global.prefixCls}-btn-content`, classNames?.content)}\n style={styles?.content}\n >\n {spinnerPosition === 'content' && isLoading ? resolvedSpinner : children}\n </span>\n )}\n\n {showSuffix && (\n <span\n className={cn(`${global.prefixCls}-btn-suffix`, classNames?.suffix)}\n style={styles?.suffix}\n >\n {spinnerPosition === 'suffix' && isLoading ? resolvedSpinner : suffix}\n </span>\n )}\n </>\n )}\n </Flex>\n )\n }\n)\n\nButton.displayName = 'Button'\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useNSUI, cn } from '@negative-space/system';
|
|
3
|
+
import { Flex } from '@negative-space/flex';
|
|
4
|
+
import { Spinner } from '@negative-space/spinner';
|
|
5
|
+
import { useRipple } from '@negative-space/ripple';
|
|
6
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
// src/Button.tsx
|
|
9
|
+
var Button = React.forwardRef(
|
|
10
|
+
({
|
|
11
|
+
children,
|
|
12
|
+
prefix,
|
|
13
|
+
suffix,
|
|
14
|
+
classNames,
|
|
15
|
+
styles,
|
|
16
|
+
disabled = false,
|
|
17
|
+
isRippleDisabled,
|
|
18
|
+
onClick,
|
|
19
|
+
isLoading = false,
|
|
20
|
+
spinner,
|
|
21
|
+
spinnerPosition = "full",
|
|
22
|
+
spinnerProps,
|
|
23
|
+
alignItems = "center",
|
|
24
|
+
justify = "center",
|
|
25
|
+
...props
|
|
26
|
+
}, ref) => {
|
|
27
|
+
const { global, components } = useNSUI();
|
|
28
|
+
const rippleDisabled = isRippleDisabled ?? components.button.isRippleDisabled;
|
|
29
|
+
const { createRipple } = useRipple(`${global.prefixCls}-ripple`);
|
|
30
|
+
const isDisabled = disabled || isLoading;
|
|
31
|
+
const resolvedSpinner = spinner ?? /* @__PURE__ */ jsx(Spinner, { ...spinnerProps });
|
|
32
|
+
const handleClick = (e) => {
|
|
33
|
+
if (isDisabled) return;
|
|
34
|
+
const isKeyboard = e.detail === 0;
|
|
35
|
+
if (!rippleDisabled) createRipple(e, { centered: isKeyboard });
|
|
36
|
+
onClick?.(e);
|
|
37
|
+
};
|
|
38
|
+
const showPrefix = prefix || isLoading && spinnerPosition === "prefix";
|
|
39
|
+
const showContent = children || isLoading && spinnerPosition === "content";
|
|
40
|
+
const showSuffix = suffix || isLoading && spinnerPosition === "suffix";
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
42
|
+
Flex,
|
|
43
|
+
{
|
|
44
|
+
...props,
|
|
45
|
+
ref,
|
|
46
|
+
as: "button",
|
|
47
|
+
alignItems,
|
|
48
|
+
justify,
|
|
49
|
+
disabled: isDisabled,
|
|
50
|
+
"data-disabled": isDisabled,
|
|
51
|
+
onClick: handleClick,
|
|
52
|
+
className: cn(`${global.prefixCls}-btn`, classNames?.btn),
|
|
53
|
+
style: styles?.btn,
|
|
54
|
+
children: spinnerPosition === "full" && isLoading ? resolvedSpinner : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
55
|
+
showPrefix && /* @__PURE__ */ jsx(
|
|
56
|
+
"span",
|
|
57
|
+
{
|
|
58
|
+
className: cn(`${global.prefixCls}-btn-prefix`, classNames?.prefix),
|
|
59
|
+
style: styles?.prefix,
|
|
60
|
+
children: spinnerPosition === "prefix" && isLoading ? resolvedSpinner : prefix
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
showContent && /* @__PURE__ */ jsx(
|
|
64
|
+
"span",
|
|
65
|
+
{
|
|
66
|
+
className: cn(`${global.prefixCls}-btn-content`, classNames?.content),
|
|
67
|
+
style: styles?.content,
|
|
68
|
+
children: spinnerPosition === "content" && isLoading ? resolvedSpinner : children
|
|
69
|
+
}
|
|
70
|
+
),
|
|
71
|
+
showSuffix && /* @__PURE__ */ jsx(
|
|
72
|
+
"span",
|
|
73
|
+
{
|
|
74
|
+
className: cn(`${global.prefixCls}-btn-suffix`, classNames?.suffix),
|
|
75
|
+
style: styles?.suffix,
|
|
76
|
+
children: spinnerPosition === "suffix" && isLoading ? resolvedSpinner : suffix
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
] })
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
Button.displayName = "Button";
|
|
85
|
+
|
|
86
|
+
export { Button };
|
|
87
|
+
//# sourceMappingURL=index.mjs.map
|
|
88
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Button.tsx"],"names":[],"mappings":";;;;;;;;AA+BO,IAAM,SAAS,KAAA,CAAM,UAAA;AAAA,EAC1B,CACE;AAAA,IACE,QAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA,GAAW,KAAA;AAAA,IACX,gBAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA,GAAY,KAAA;AAAA,IACZ,OAAA;AAAA,IACA,eAAA,GAAkB,MAAA;AAAA,IAClB,YAAA;AAAA,IACA,UAAA,GAAa,QAAA;AAAA,IACb,OAAA,GAAU,QAAA;AAAA,IACV,GAAG;AAAA,KAEL,GAAA,KACG;AACH,IAAA,MAAM,EAAE,MAAA,EAAQ,UAAA,EAAW,GAAI,OAAA,EAAQ;AACvC,IAAA,MAAM,cAAA,GAAiB,g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A,mBAEA,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,UAAA,UAAA,oBACC,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,WAAW,EAAA,CAAG,CAAA,EAAG,OAAO,SAAS,CAAA,WAAA,CAAA,EAAe,YAAY,MAAM,CAAA;AAAA,cAClE,OAAO,MAAA,EAAQ,MAAA;AAAA,cAEd,QAAA,EAAA,eAAA,KAAoB,QAAA,IAAY,SAAA,GAAY,eAAA,GAAkB;AAAA;AAAA,WACjE;AAAA,UAGD,WAAA,oBACC,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,WAAW,EAAA,CAAG,CAAA,EAAG,OAAO,SAAS,CAAA,YAAA,CAAA,EAAgB,YAAY,OAAO,CAAA;AAAA,cACpE,OAAO,MAAA,EAAQ,OAAA;AAAA,cAEd,QAAA,EAAA,eAAA,KAAoB,SAAA,IAAa,SAAA,GAAY,eAAA,GAAkB;AAAA;AAAA,WAClE;AAAA,UAGD,UAAA,oBACC,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,WAAW,EAAA,CAAG,CAAA,EAAG,OAAO,SAAS,CAAA,WAAA,CAAA,EAAe,YAAY,MAAM,CAAA;AAAA,cAClE,OAAO,MAAA,EAAQ,MAAA;AAAA,cAEd,QAAA,EAAA,eAAA,KAAoB,QAAA,IAAY,SAAA,GAAY,eAAA,GAAkB;AAAA;AAAA;AACjE,SAAA,EAEJ;AAAA;AAAA,KAEJ;AAAA,EAEJ;AACF;AAEA,MAAA,CAAO,WAAA,GAAc,QAAA","file":"index.mjs","sourcesContent":["import React from 'react'\nimport { cn, useNSUI } from '@negative-space/system'\nimport { Flex, FlexProps } from '@negative-space/flex'\nimport { Spinner, type SpinnerProps } from '@negative-space/spinner'\nimport { useRipple } from '@negative-space/ripple'\n\nexport interface ButtonProps extends Omit<\n FlexProps<'button'>,\n 'as' | 'prefix' | 'className' | 'style'\n> {\n prefix?: React.ReactNode\n suffix?: React.ReactNode\n classNames?: {\n btn?: string\n content?: string\n prefix?: string\n suffix?: string\n }\n styles?: {\n btn?: React.CSSProperties\n content?: React.CSSProperties\n prefix?: React.CSSProperties\n suffix?: React.CSSProperties\n }\n isRippleDisabled?: boolean\n isLoading?: boolean\n spinner?: React.ReactNode\n spinnerPosition?: 'full' | 'prefix' | 'content' | 'suffix'\n spinnerProps?: SpinnerProps\n}\n\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n children,\n prefix,\n suffix,\n classNames,\n styles,\n disabled = false,\n isRippleDisabled,\n onClick,\n isLoading = false,\n spinner,\n spinnerPosition = 'full',\n spinnerProps,\n alignItems = 'center',\n justify = 'center',\n ...props\n },\n ref\n ) => {\n const { global, components } = useNSUI()\n const rippleDisabled = isRippleDisabled ?? components.button.isRippleDisabled\n\n const { createRipple } = useRipple(`${global.prefixCls}-ripple`)\n const isDisabled = disabled || isLoading\n\n const resolvedSpinner = spinner ?? <Spinner {...spinnerProps} />\n\n const handleClick: React.MouseEventHandler<HTMLButtonElement> = (e) => {\n if (isDisabled) return\n const isKeyboard = e.detail === 0\n if (!rippleDisabled) createRipple(e, { centered: isKeyboard })\n\n onClick?.(e)\n }\n\n const showPrefix = prefix || (isLoading && spinnerPosition === 'prefix')\n const showContent = children || (isLoading && spinnerPosition === 'content')\n const showSuffix = suffix || (isLoading && spinnerPosition === 'suffix')\n\n return (\n <Flex\n {...props}\n ref={ref}\n as=\"button\"\n alignItems={alignItems}\n justify={justify}\n disabled={isDisabled}\n data-disabled={isDisabled}\n onClick={handleClick}\n className={cn(`${global.prefixCls}-btn`, classNames?.btn)}\n style={styles?.btn}\n >\n {spinnerPosition === 'full' && isLoading ? (\n resolvedSpinner\n ) : (\n <>\n {showPrefix && (\n <span\n className={cn(`${global.prefixCls}-btn-prefix`, classNames?.prefix)}\n style={styles?.prefix}\n >\n {spinnerPosition === 'prefix' && isLoading ? resolvedSpinner : prefix}\n </span>\n )}\n\n {showContent && (\n <span\n className={cn(`${global.prefixCls}-btn-content`, classNames?.content)}\n style={styles?.content}\n >\n {spinnerPosition === 'content' && isLoading ? resolvedSpinner : children}\n </span>\n )}\n\n {showSuffix && (\n <span\n className={cn(`${global.prefixCls}-btn-suffix`, classNames?.suffix)}\n style={styles?.suffix}\n >\n {spinnerPosition === 'suffix' && isLoading ? resolvedSpinner : suffix}\n </span>\n )}\n </>\n )}\n </Flex>\n )\n }\n)\n\nButton.displayName = 'Button'\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@negative-space/button",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"url": "https://github.com/negative-space-ui/nsui/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@negative-space/flex": "1.1.
|
|
35
|
+
"@negative-space/flex": "1.1.1",
|
|
36
36
|
"@negative-space/ripple": "1.1.1",
|
|
37
|
-
"@negative-space/system": "1.0.
|
|
38
|
-
"@negative-space/spinner": "2.1.
|
|
37
|
+
"@negative-space/system": "1.0.1",
|
|
38
|
+
"@negative-space/spinner": "2.1.1"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"react": "^19.2.
|
|
41
|
+
"react": "^19.2.3"
|
|
42
42
|
},
|
|
43
43
|
"clean-package": "../../../../clean-package.config.json",
|
|
44
44
|
"exports": {
|