@toptal/picasso-button 2.0.7 → 2.0.8-alpha-fx-null-fix-button-e862ee8b7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/dist-package/src/ButtonAction/ButtonAction.js +7 -2
- package/dist-package/src/ButtonAction/ButtonAction.js.map +1 -1
- package/dist-package/src/ButtonBase/ButtonBase.d.ts +2 -0
- package/dist-package/src/ButtonBase/ButtonBase.d.ts.map +1 -1
- package/dist-package/src/ButtonBase/ButtonBase.js +11 -20
- package/dist-package/src/ButtonBase/ButtonBase.js.map +1 -1
- package/dist-package/src/ButtonControlLabel/ButtonControlLabel.d.ts.map +1 -1
- package/dist-package/src/ButtonControlLabel/ButtonControlLabel.js +1 -1
- package/dist-package/src/ButtonControlLabel/ButtonControlLabel.js.map +1 -1
- package/package.json +16 -15
- package/src/ButtonAction/ButtonAction.tsx +4 -4
- package/src/ButtonBase/ButtonBase.tsx +19 -32
- package/src/ButtonControlLabel/ButtonControlLabel.tsx +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2022 Toptal, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the “Software”), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -27,7 +27,12 @@ const getIcon = ({ children, icon, iconPosition, }) => {
|
|
|
27
27
|
};
|
|
28
28
|
const loaderIcon = React.createElement(Loader, { size: 'small', variant: 'inherit' });
|
|
29
29
|
export const ButtonAction = forwardRef(function ButtonAction(props, ref) {
|
|
30
|
-
const {
|
|
30
|
+
const {
|
|
31
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
32
|
+
// We use these props only to determine styles
|
|
33
|
+
active, focused, hovered,
|
|
34
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
35
|
+
className, disabled, loading, icon, iconPosition, onClick } = props, rest = __rest(props, ["active", "focused", "hovered", "className", "disabled", "loading", "icon", "iconPosition", "onClick"]);
|
|
31
36
|
const usedIcon = loading ? loaderIcon : icon;
|
|
32
37
|
const usedIconPosition = icon ? iconPosition : 'right';
|
|
33
38
|
const finalClassName = cx(createRootClassNames(props), className);
|
|
@@ -36,7 +41,7 @@ export const ButtonAction = forwardRef(function ButtonAction(props, ref) {
|
|
|
36
41
|
icon: usedIcon,
|
|
37
42
|
iconPosition: usedIconPosition,
|
|
38
43
|
});
|
|
39
|
-
return (React.createElement(ButtonBase, Object.assign({}, rest, { ref: ref, icon: finalIcon, iconPosition: usedIconPosition, onClick: loading ? undefined : onClick, className: finalClassName, contentClassName: 'font-semibold text-blue-500 text-md',
|
|
44
|
+
return (React.createElement(ButtonBase, Object.assign({}, rest, { ref: ref, icon: finalIcon, iconPosition: usedIconPosition, onClick: loading ? undefined : onClick, className: finalClassName, contentClassName: 'font-semibold text-blue-500 text-md', disabled: disabled })));
|
|
40
45
|
});
|
|
41
46
|
ButtonAction.defaultProps = {
|
|
42
47
|
iconPosition: 'left',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonAction.js","sourceRoot":"","sources":["../../../src/ButtonAction/ButtonAction.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,MAAM,YAAY,CAAA;AAM3B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAErE,MAAM,OAAO,GAAG,CAAC,EACf,QAAQ,EACR,IAAI,EACJ,YAAY,GAKb,EAAE,EAAE;IACH,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,cAAc,GAAG,oBAAoB,CAAC;QAC1C,YAAY,EAAE,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;KAClE,CAAC,CAAA;IAEF,OAAO,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE;QAC9B,SAAS,EAAE,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;KACpD,CAAC,CAAA;AACJ,CAAC,CAAA;AAyBD,MAAM,UAAU,GAAG,oBAAC,MAAM,IAAC,IAAI,EAAC,OAAO,EAAC,OAAO,EAAC,SAAS,GAAG,CAAA;AAE5D,MAAM,CAAC,MAAM,YAAY,GAAgC,UAAU,CAGjE,SAAS,YAAY,CAAC,KAAK,EAAE,GAAG;IAChC,MAAM,
|
|
1
|
+
{"version":3,"file":"ButtonAction.js","sourceRoot":"","s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,CAAC,CAAC,IAAI,CAAA;IAC5C,MAAM,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAA;IAEtD,MAAM,cAAc,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAA;IACjE,MAAM,SAAS,GAAG,OAAO,CAAC;QACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,gBAAgB;KAC/B,CAAC,CAAA;IAEF,OAAO,CACL,oBAAC,UAAU,oBACL,IAAI,IACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,gBAAgB,EAC9B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EACtC,SAAS,EAAE,cAAc,EACzB,gBAAgB,EAAC,qCAAqC,EACtD,QAAQ,EAAE,QAAQ,IAClB,CACH,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,YAAY,CAAC,YAAY,GAAG;IAC1B,YAAY,EAAE,MAAM;CACrB,CAAA;AAED,YAAY,CAAC,WAAW,GAAG,cAAc,CAAA;AAEzC,eAAe,YAAY,CAAA"}
|
|
@@ -23,6 +23,8 @@ export interface Props extends StandardProps, TextLabelProps, ButtonOrAnchorProp
|
|
|
23
23
|
title?: string;
|
|
24
24
|
/** HTML type of Button component */
|
|
25
25
|
type?: 'button' | 'reset' | 'submit';
|
|
26
|
+
/** The HTML element that is ultimately rendered, for example 'button', 'a' or 'label */
|
|
27
|
+
rootElementName?: keyof HTMLElementTagNameMap;
|
|
26
28
|
}
|
|
27
29
|
export declare const ButtonBase: OverridableComponent<Props>;
|
|
28
30
|
export default ButtonBase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.d.ts","sourceRoot":"","sources":["../../../src/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AAAA,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-27,33 +27,22 @@ const getIcon = ({ icon }) => {
|
|
|
27
27
|
key: 'button-icon',
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
30
|
+
const RootElement = forwardRef((props, ref) => {
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
+
const { ownerState, as: Root } = props, rest = __rest(props, ["ownerState", "as"]);
|
|
33
|
+
return React.createElement(Root, Object.assign({}, rest, { ref: ref }));
|
|
34
|
+
});
|
|
36
35
|
export const ButtonBase = forwardRef(function ButtonBase(props, ref) {
|
|
37
36
|
var _a, _b;
|
|
38
|
-
const { icon, iconPosition, loading, children, className, contentClassName, style, disabled, onClick, title, value, type, as = 'button', titleCase: propsTitleCase } = props, rest = __rest(props, ["icon", "iconPosition", "loading", "children", "className", "contentClassName", "style", "disabled", "onClick", "title", "value", "type", "as", "titleCase"]);
|
|
39
|
-
let RootElement = as;
|
|
40
|
-
if (isReactComponent(RootElement)) {
|
|
41
|
-
RootElement = forwardRef(
|
|
42
|
-
// We don't need to pass ownerState to the root component
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
|
-
(_a, rootRef) => {
|
|
45
|
-
var { ownerState } = _a, restProps = __rest(_a, ["ownerState"]);
|
|
46
|
-
const Root = as;
|
|
47
|
-
return React.createElement(Root, Object.assign({ ref: rootRef }, restProps));
|
|
48
|
-
});
|
|
49
|
-
}
|
|
37
|
+
const { icon, iconPosition, loading, children, className, contentClassName, style, disabled, onClick, title, value, type, as = 'button', rootElementName, titleCase: propsTitleCase } = props, rest = __rest(props, ["icon", "iconPosition", "loading", "children", "className", "contentClassName", "style", "disabled", "onClick", "title", "value", "type", "as", "rootElementName", "titleCase"]);
|
|
50
38
|
const titleCase = useTitleCase(propsTitleCase);
|
|
51
39
|
const finalChildren = [titleCase ? toTitleCase(children) : children];
|
|
52
40
|
/*
|
|
53
41
|
Workaround for the case: <Button as={Link} href='' /> (with empty href!), we have to determine "rootElementName" like below
|
|
54
42
|
Mui/base throws an error when "href" or "to" are empty
|
|
55
43
|
*/
|
|
56
|
-
const
|
|
44
|
+
const finalRootElementName = rootElementName ||
|
|
45
|
+
(as !== 'button' && ('href' in props || 'to' in props) ? 'a' : undefined);
|
|
57
46
|
if (icon) {
|
|
58
47
|
const iconComponent = getIcon({ icon });
|
|
59
48
|
if (iconPosition === 'left') {
|
|
@@ -64,7 +53,9 @@ export const ButtonBase = forwardRef(function ButtonBase(props, ref) {
|
|
|
64
53
|
}
|
|
65
54
|
}
|
|
66
55
|
const finalClassName = twMerge(createCoreClassNames({ disabled }), className);
|
|
67
|
-
return (React.createElement(MUIButtonBase, Object.assign({}, rest, { ref: ref, onClick: getClickHandler(loading, onClick), className: finalClassName, style: style, "aria-disabled": disabled, disabled: disabled, title: title, value: value, type: type, "data-component-type": 'button', tabIndex: ((_a = rest.tabIndex) !== null && _a !== void 0 ? _a : disabled) ? -1 : 0, role: (_b = rest.role) !== null && _b !== void 0 ? _b : 'button', rootElementName:
|
|
56
|
+
return (React.createElement(MUIButtonBase, Object.assign({}, rest, { ref: ref, onClick: getClickHandler(loading, onClick), className: finalClassName, style: style, "aria-disabled": disabled, disabled: disabled, title: title, value: value, type: type, "data-component-type": 'button', tabIndex: ((_a = rest.tabIndex) !== null && _a !== void 0 ? _a : disabled) ? -1 : 0, role: (_b = rest.role) !== null && _b !== void 0 ? _b : 'button', rootElementName: finalRootElementName, slots: { root: RootElement },
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
slotProps: { root: { as } } }),
|
|
68
59
|
React.createElement(Container, { as: 'span', inline: true, flex: true, direction: 'row', alignItems: 'center', className: contentClassName }, finalChildren),
|
|
69
60
|
loading && (React.createElement(Loader, { variant: 'inherit', className: 'absolute top-1/2 left-1/2 translate-x-[-50%] translate-y-[-50%]', inline: true, size: 'small' }))));
|
|
70
61
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.js","sourceRoot":"","sources":["../../../src/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ButtonBase.js","sourceRoot":"","sources":["../../../src/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAOxC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAiC/C,MAAM,eAAe,GAAG,CAAC,OAAiB,EAAE,OAA0B,EAAE,EAAE,CACxE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAA;AAE1B,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,EAA2B,EAAE,EAAE;IACpD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE;QAC9B,SAAS,EAAE,OAAO,CAAC,qBAAqB,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QAC/D,GAAG,EAAE,aAAa;KACnB,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,WAAW,GAAG,UAAU,CAC5B,CAAC,KAAgD,EAAE,GAAG,EAAE,EAAE;IACxD,6DAA6D;IAC7D,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,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CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonControlLabel.d.ts","sourceRoot":"","sources":["../../../src/ButtonControlLabel/ButtonControlLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAOjE,MAAM,WAAW,KAAM,SAAQ,SAAS;IACtC,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAA;IAC7C,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAC1C,OAAO,EAAE,OAAO,KACb,IAAI,CAAA;IACT,kBAAkB;IAClB,QAAQ,EAAE,SAAS,CAAA;IACnB,kCAAkC;IAClC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,0EAA0E;IAC1E,OAAO,EAAE,YAAY,CAAA;CACtB;AAED,QAAA,MAAM,kBAAkB;+FAWrB,KAAK;;;;
|
|
1
|
+
{"version":3,"file":"ButtonControlLabel.d.ts","sourceRoot":"","sources":["../../../src/ButtonControlLabel/ButtonControlLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAOjE,MAAM,WAAW,KAAM,SAAQ,SAAS;IACtC,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,uCAAuC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAA;IAC7C,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAC1C,OAAO,EAAE,OAAO,KACb,IAAI,CAAA;IACT,kBAAkB;IAClB,QAAQ,EAAE,SAAS,CAAA;IACnB,kCAAkC;IAClC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,0EAA0E;IAC1E,OAAO,EAAE,YAAY,CAAA;CACtB;AAED,QAAA,MAAM,kBAAkB;+FAWrB,KAAK;;;;CAuBP,CAAA;AAMD,eAAe,kBAAkB,CAAA"}
|
|
@@ -17,7 +17,7 @@ import { createSizeClassNames, createContentSizeClassNames } from './styles';
|
|
|
17
17
|
const ButtonControlLabel = (_a) => {
|
|
18
18
|
var { children, size = 'medium', className, checked, onChange, id, control, value, disabled } = _a, props = __rest(_a, ["children", "size", "className", "checked", "onChange", "id", "control", "value", "disabled"]);
|
|
19
19
|
const contentLeftSpacing = size === 'large' ? 1 : 0.5;
|
|
20
|
-
return (React.createElement(Button, Object.assign({}, props, { className: twMerge('text-center', createSizeClassNames(size), className), variant: 'secondary', size: size, as: 'label', htmlFor: id, disabled: disabled }),
|
|
20
|
+
return (React.createElement(Button, Object.assign({}, props, { className: twMerge('text-center', createSizeClassNames(size), className), variant: 'secondary', size: size, as: 'label', rootElementName: 'label', htmlFor: id, disabled: disabled }),
|
|
21
21
|
React.cloneElement(control, { id, checked, value, onChange, disabled }),
|
|
22
22
|
React.createElement(Container, { className: createContentSizeClassNames(size), left: contentLeftSpacing }, children)));
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonControlLabel.js","sourceRoot":"","sources":["../../../src/ButtonControlLabel/ButtonControlLabel.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAA;AA8B5E,MAAM,kBAAkB,GAAG,CAAC,EAWpB,EAAE,EAAE;QAXgB,EAC1B,QAAQ,EACR,IAAI,GAAG,QAAQ,EACf,SAAS,EACT,OAAO,EACP,QAAQ,EACR,EAAE,EACF,OAAO,EACP,KAAK,EACL,QAAQ,OAEF,EADH,KAAK,cAVkB,8FAW3B,CADS;IAER,MAAM,kBAAkB,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IAErD,OAAO,CACL,oBAAC,MAAM,oBACD,KAAK,IACT,SAAS,EAAE,OAAO,CAAC,aAAa,EAAE,oBAAoB,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,EACxE,OAAO,EAAC,WAAW,EACnB,IAAI,EAAE,IAAI,EACV,EAAE,EAAC,OAAO,EACV,OAAO,EAAE,EAAE,E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,EACV,EAAE,EAAC,OAAO,EACV,eAAe,EAAC,OAAO,EACvB,OAAO,EAAE,EAAE,EACX,QAAQ,EAAE,QAAQ;QAEjB,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QACxE,oBAAC,SAAS,IACR,SAAS,EAAE,2BAA2B,CAAC,IAAI,CAAC,EAC5C,IAAI,EAAE,kBAAkB,IAEvB,QAAQ,CACC,CACL,CACV,CAAA;AACH,CAAC,CAAA;AAED,kBAAkB,CAAC,YAAY,GAAG;IAChC,IAAI,EAAE,QAAQ;CACf,CAAA;AAED,eAAe,kBAAkB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-button",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8-alpha-fx-null-fix-button-e862ee8b7.0+e862ee8b7",
|
|
4
4
|
"description": "Toptal UI components library - Button",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@toptal/picasso-checkbox": "2.0.6",
|
|
26
|
-
"@toptal/picasso-container": "1.0.3",
|
|
27
|
-
"@toptal/picasso-dropdown": "2.0.3",
|
|
28
|
-
"@toptal/picasso-icons": "1.4.0",
|
|
29
|
-
"@toptal/picasso-loader": "1.0.3",
|
|
30
|
-
"@toptal/picasso-radio": "2.0.6",
|
|
31
|
-
"@toptal/picasso-shared": "15.0.0",
|
|
32
|
-
"@toptal/picasso-utils": "1.0.3",
|
|
33
|
-
"@toptal/picasso-link": "1.0.3",
|
|
34
|
-
"ap-style-title-case": "^1.1.2",
|
|
35
25
|
"@mui/base": "5.0.0-beta.40",
|
|
26
|
+
"@toptal/picasso-checkbox": "2.0.7-alpha-fx-null-fix-button-e862ee8b7.0+e862ee8b7",
|
|
27
|
+
"@toptal/picasso-container": "1.0.4-alpha-fx-null-fix-button-e862ee8b7.34+e862ee8b7",
|
|
28
|
+
"@toptal/picasso-dropdown": "2.0.4-alpha-fx-null-fix-button-e862ee8b7.32+e862ee8b7",
|
|
29
|
+
"@toptal/picasso-icons": "1.4.1-alpha-fx-null-fix-button-e862ee8b7.0+e862ee8b7",
|
|
30
|
+
"@toptal/picasso-link": "1.0.4-alpha-fx-null-fix-button-e862ee8b7.34+e862ee8b7",
|
|
31
|
+
"@toptal/picasso-loader": "1.0.4-alpha-fx-null-fix-button-e862ee8b7.34+e862ee8b7",
|
|
32
|
+
"@toptal/picasso-radio": "2.0.7-alpha-fx-null-fix-button-e862ee8b7.0+e862ee8b7",
|
|
33
|
+
"@toptal/picasso-shared": "15.0.1-alpha-fx-null-fix-button-e862ee8b7.34+e862ee8b7",
|
|
34
|
+
"@toptal/picasso-utils": "1.0.4-alpha-fx-null-fix-button-e862ee8b7.34+e862ee8b7",
|
|
35
|
+
"ap-style-title-case": "^1.1.2",
|
|
36
36
|
"classnames": "^2.5.1",
|
|
37
37
|
"tailwind-merge": "^2.2.2"
|
|
38
38
|
},
|
|
@@ -41,20 +41,21 @@
|
|
|
41
41
|
"**/styles.js"
|
|
42
42
|
],
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@toptal/picasso-tailwind": ">=2.5.0",
|
|
45
44
|
"@toptal/picasso-provider": "*",
|
|
45
|
+
"@toptal/picasso-tailwind": ">=2.5.0",
|
|
46
46
|
"react": ">=16.12.0 < 19.0.0"
|
|
47
47
|
},
|
|
48
48
|
"exports": {
|
|
49
49
|
".": "./dist-package/src/index.js"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@toptal/picasso-provider": "4.2.
|
|
53
|
-
"@toptal/picasso-test-utils": "1.1.
|
|
52
|
+
"@toptal/picasso-provider": "4.2.2-alpha-fx-null-fix-button-e862ee8b7.42+e862ee8b7",
|
|
53
|
+
"@toptal/picasso-test-utils": "1.1.2-alpha-fx-null-fix-button-e862ee8b7.34+e862ee8b7"
|
|
54
54
|
},
|
|
55
55
|
"files": [
|
|
56
56
|
"dist-package/**",
|
|
57
57
|
"!dist-package/tsconfig.tsbuildinfo",
|
|
58
58
|
"src"
|
|
59
|
-
]
|
|
59
|
+
],
|
|
60
|
+
"gitHead": "e862ee8b7dd480b508f5258999f409fe0ab1611c"
|
|
60
61
|
}
|
|
@@ -64,10 +64,13 @@ export const ButtonAction: OverridableComponent<Props> = forwardRef<
|
|
|
64
64
|
Props
|
|
65
65
|
>(function ButtonAction(props, ref) {
|
|
66
66
|
const {
|
|
67
|
-
|
|
67
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
68
|
+
// We use these props only to determine styles
|
|
68
69
|
active,
|
|
69
70
|
focused,
|
|
70
71
|
hovered,
|
|
72
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
73
|
+
className,
|
|
71
74
|
disabled,
|
|
72
75
|
loading,
|
|
73
76
|
icon,
|
|
@@ -95,9 +98,6 @@ export const ButtonAction: OverridableComponent<Props> = forwardRef<
|
|
|
95
98
|
onClick={loading ? undefined : onClick}
|
|
96
99
|
className={finalClassName}
|
|
97
100
|
contentClassName='font-semibold text-blue-500 text-md'
|
|
98
|
-
active={active}
|
|
99
|
-
hovered={hovered}
|
|
100
|
-
focused={focused}
|
|
101
101
|
disabled={disabled}
|
|
102
102
|
/>
|
|
103
103
|
)
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ReactNode,
|
|
3
|
-
ReactElement,
|
|
4
|
-
MouseEvent,
|
|
5
|
-
ElementType,
|
|
6
|
-
FC,
|
|
7
|
-
} from 'react'
|
|
1
|
+
import type { ReactNode, ReactElement, MouseEvent, ElementType } from 'react'
|
|
8
2
|
import React, { forwardRef } from 'react'
|
|
9
3
|
import { twMerge } from 'tailwind-merge'
|
|
10
4
|
import type {
|
|
@@ -15,6 +9,7 @@ import type {
|
|
|
15
9
|
} from '@toptal/picasso-shared'
|
|
16
10
|
import { useTitleCase } from '@toptal/picasso-shared'
|
|
17
11
|
import { Button as MUIButtonBase } from '@mui/base/Button'
|
|
12
|
+
import type { ButtonRootSlotProps } from '@mui/base/Button'
|
|
18
13
|
import { Loader } from '@toptal/picasso-loader'
|
|
19
14
|
import { Container } from '@toptal/picasso-container'
|
|
20
15
|
import { noop, toTitleCase } from '@toptal/picasso-utils'
|
|
@@ -48,6 +43,8 @@ export interface Props
|
|
|
48
43
|
title?: string
|
|
49
44
|
/** HTML type of Button component */
|
|
50
45
|
type?: 'button' | 'reset' | 'submit'
|
|
46
|
+
/** The HTML element that is ultimately rendered, for example 'button', 'a' or 'label */
|
|
47
|
+
rootElementName?: keyof HTMLElementTagNameMap
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
const getClickHandler = (loading?: boolean, handler?: Props['onClick']) =>
|
|
@@ -64,14 +61,14 @@ const getIcon = ({ icon }: { icon?: ReactElement }) => {
|
|
|
64
61
|
})
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
const RootElement = forwardRef(
|
|
65
|
+
(props: ButtonRootSlotProps & { as: ElementType }, ref) => {
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
67
|
+
const { ownerState, as: Root, ...rest } = props
|
|
68
|
+
|
|
69
|
+
return <Root {...rest} ref={ref} />
|
|
70
|
+
}
|
|
71
|
+
)
|
|
75
72
|
|
|
76
73
|
export const ButtonBase: OverridableComponent<Props> = forwardRef<
|
|
77
74
|
HTMLButtonElement,
|
|
@@ -91,32 +88,20 @@ export const ButtonBase: OverridableComponent<Props> = forwardRef<
|
|
|
91
88
|
value,
|
|
92
89
|
type,
|
|
93
90
|
as = 'button',
|
|
91
|
+
rootElementName,
|
|
94
92
|
titleCase: propsTitleCase,
|
|
95
93
|
...rest
|
|
96
94
|
} = props
|
|
97
95
|
|
|
98
|
-
let RootElement: ElementType | FC = as
|
|
99
|
-
|
|
100
|
-
if (isReactComponent(RootElement)) {
|
|
101
|
-
RootElement = forwardRef(
|
|
102
|
-
// We don't need to pass ownerState to the root component
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
104
|
-
({ ownerState, ...restProps }: { ownerState: object }, rootRef) => {
|
|
105
|
-
const Root = as
|
|
106
|
-
|
|
107
|
-
return <Root ref={rootRef} {...restProps} />
|
|
108
|
-
}
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
96
|
const titleCase = useTitleCase(propsTitleCase)
|
|
113
97
|
const finalChildren = [titleCase ? toTitleCase(children) : children]
|
|
114
98
|
/*
|
|
115
99
|
Workaround for the case: <Button as={Link} href='' /> (with empty href!), we have to determine "rootElementName" like below
|
|
116
100
|
Mui/base throws an error when "href" or "to" are empty
|
|
117
101
|
*/
|
|
118
|
-
const
|
|
119
|
-
|
|
102
|
+
const finalRootElementName =
|
|
103
|
+
rootElementName ||
|
|
104
|
+
(as !== 'button' && ('href' in props || 'to' in props) ? 'a' : undefined)
|
|
120
105
|
|
|
121
106
|
if (icon) {
|
|
122
107
|
const iconComponent = getIcon({ icon })
|
|
@@ -145,8 +130,10 @@ export const ButtonBase: OverridableComponent<Props> = forwardRef<
|
|
|
145
130
|
data-component-type='button'
|
|
146
131
|
tabIndex={rest.tabIndex ?? disabled ? -1 : 0}
|
|
147
132
|
role={rest.role ?? 'button'}
|
|
148
|
-
rootElementName={
|
|
133
|
+
rootElementName={finalRootElementName}
|
|
149
134
|
slots={{ root: RootElement }}
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
slotProps={{ root: { as } }}
|
|
150
137
|
>
|
|
151
138
|
<Container
|
|
152
139
|
as='span'
|