@bspk/ui 1.1.25 → 1.1.26
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/Button.js +5 -3
- package/dist/Button.js.map +1 -1
- package/package.json +1 -1
- package/src/Button.tsx +4 -5
package/dist/Button.js
CHANGED
|
@@ -27,11 +27,13 @@ import { useErrorLogger } from './utils/errors';
|
|
|
27
27
|
* @name Button
|
|
28
28
|
*/
|
|
29
29
|
function Button(props) {
|
|
30
|
-
const { size = 'medium', variant = 'primary', destructive = false, width = 'hug', as: As = 'button', disabled = false, label: labelProp, icon,
|
|
30
|
+
const { size = 'medium', variant = 'primary', destructive = false, width = 'hug', as: As = 'button', disabled = false, label: labelProp, icon,
|
|
31
|
+
// showLabel: showLabelProp = true,
|
|
32
|
+
showLabel = true, toolTip: toolTipProp, children, ...containerProps } = props;
|
|
31
33
|
const label = typeof children === 'string' ? children : labelProp || '';
|
|
32
34
|
// ignore showLabel=false if there is no icon
|
|
33
|
-
const hideLabel =
|
|
34
|
-
const toolTip = toolTipProp || hideLabel ? label : undefined;
|
|
35
|
+
const hideLabel = (showLabel === false) && icon;
|
|
36
|
+
const toolTip = toolTipProp || (hideLabel ? label : undefined);
|
|
35
37
|
const { logError } = useErrorLogger();
|
|
36
38
|
logError(!!icon && !isValidIcon(icon), 'Button - The icon prop must be a valid icon element.');
|
|
37
39
|
logError(!label, 'Button - The button must have a label.');
|
package/dist/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,EAA0B,cAAc,EAAE,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAA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AC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC/D,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAAC;IACtC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,sDAAsD,CAAC,CAAC;IAC/F,QAAQ,CAAC,CAAC,KAAK,EAAE,wCAAwC,CAAC,CAAC;IAE3D,MAAM,MAAM,GAAG,CACX,KAAC,EAAE,OACK,cAAc,gBACN,KAAK,eACP,QAAQ,sBACA,WAAW,IAAI,SAAS,eAC/B,IAAI,kBACD,OAAO,gBACT,KAAK,EACjB,QAAQ,EAAE,QAAQ,IAAI,SAAS,YAE9B,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CACxC,QAAQ,CACX,CAAC,CAAC,CAAC,CACA,8BACI,2CAA0B,EACzB,CAAC,CAAC,IAAI,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,mDAAwB,IAAI,GAAQ,EACtE,CAAC,SAAS,IAAI,oDAAyB,KAAK,GAAQ,IACtD,CACN,GACA,CACR,CAAC;IAEF,IAAI,OAAO,EAAE,CAAC;QACV,OAAO,CACH,KAAC,OAAO,IAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAC,KAAK,YACnC,MAAM,GACD,CACb,CAAC;IACN,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/Button.tsx
CHANGED
|
@@ -102,7 +102,8 @@ function Button<As extends ElementType = 'button'>(props: ElementProps<ButtonPro
|
|
|
102
102
|
disabled = false,
|
|
103
103
|
label: labelProp,
|
|
104
104
|
icon,
|
|
105
|
-
showLabel: showLabelProp = true,
|
|
105
|
+
// showLabel: showLabelProp = true,
|
|
106
|
+
showLabel= true,
|
|
106
107
|
toolTip: toolTipProp,
|
|
107
108
|
children,
|
|
108
109
|
...containerProps
|
|
@@ -110,10 +111,8 @@ function Button<As extends ElementType = 'button'>(props: ElementProps<ButtonPro
|
|
|
110
111
|
const label = typeof children === 'string' ? children : labelProp || '';
|
|
111
112
|
|
|
112
113
|
// ignore showLabel=false if there is no icon
|
|
113
|
-
const hideLabel =
|
|
114
|
-
|
|
115
|
-
const toolTip = toolTipProp || hideLabel ? label : undefined;
|
|
116
|
-
|
|
114
|
+
const hideLabel = (showLabel === false) && icon;
|
|
115
|
+
const toolTip = toolTipProp || (hideLabel ? label : undefined);
|
|
117
116
|
const { logError } = useErrorLogger();
|
|
118
117
|
logError(!!icon && !isValidIcon(icon), 'Button - The icon prop must be a valid icon element.');
|
|
119
118
|
logError(!label, 'Button - The button must have a label.');
|