@seeqdev/qomponents 0.0.67 → 0.0.69
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/Button.types.d.ts +5 -1
- package/dist/index.esm.js +6 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,9 +4,11 @@ import React from 'react';
|
|
|
4
4
|
export declare const buttonTypes: readonly ["button", "reset", "submit", "link"];
|
|
5
5
|
export declare const buttonSizes: readonly ["sm", "lg"];
|
|
6
6
|
export declare const buttonVariants: readonly ["outline", "theme", "theme-light", "warning", "danger", "no-border"];
|
|
7
|
+
export declare const iconPositions: string[];
|
|
7
8
|
export type ButtonType = typeof buttonTypes[number];
|
|
8
9
|
export type ButtonSize = typeof buttonSizes[number];
|
|
9
10
|
export type ButtonVariant = typeof buttonVariants[number];
|
|
11
|
+
export type IconPosition = typeof iconPositions[number];
|
|
10
12
|
export interface ButtonProps {
|
|
11
13
|
/** function to call when clicking the button (takes no parameters) */
|
|
12
14
|
onClick?: (e: React.MouseEvent) => void;
|
|
@@ -23,10 +25,12 @@ export interface ButtonProps {
|
|
|
23
25
|
extraClassNames?: string;
|
|
24
26
|
/** icon class to be used if an icon should go before the text (i.e. fc-zoom) */
|
|
25
27
|
icon?: string;
|
|
26
|
-
/** icon color option (text, white, theme, color
|
|
28
|
+
/** icon color option (text, white, theme, color; default is "text") */
|
|
27
29
|
iconStyle?: IconType;
|
|
28
30
|
/** color of the icon if it is custom (required if iconStyle is "color") */
|
|
29
31
|
iconColor?: string;
|
|
32
|
+
/** where the icon should be positioned relative to the provided text (left or right; default is left) */
|
|
33
|
+
iconPosition?: IconPosition;
|
|
30
34
|
/** normally we want for Icon to prefix FontAwesome icons with the fa-sharp fa-regular prefix however there are a
|
|
31
35
|
* select few icons that are not pulled from that set. For those we need to pass specific prefixes instead.*/
|
|
32
36
|
iconPrefix?: string;
|
package/dist/index.esm.js
CHANGED
|
@@ -99,7 +99,7 @@ const Icon = ({ onClick, icon, iconPrefix = undefined, type = 'theme', extraClas
|
|
|
99
99
|
* - use "variant" to achieve the desired style
|
|
100
100
|
* - include tooltips and/or icons
|
|
101
101
|
*/
|
|
102
|
-
const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, tooltip, tooltipOptions, iconStyle = 'text', icon, iconColor, iconPrefix = undefined, preventBlur = false, isHtmlTooltip = false, tooltipTestId, }) => {
|
|
102
|
+
const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, tooltip, tooltipOptions, iconStyle = 'text', icon, iconColor, iconPosition = 'left', iconPrefix = undefined, preventBlur = false, isHtmlTooltip = false, tooltipTestId, }) => {
|
|
103
103
|
const baseClasses = 'tw-py-1 tw-px-2.5 tw-rounded-sm focus:tw-ring-0 disabled:tw-pointer-events-none';
|
|
104
104
|
const baseClassesByVariant = {
|
|
105
105
|
'outline': 'disabled:tw-opacity-50 tw-border-solid tw-border',
|
|
@@ -163,6 +163,8 @@ const Button = ({ onClick, label, variant = 'outline', type = 'button', size = '
|
|
|
163
163
|
'data-qtip-delay': tooltipOptions?.delay ?? DEFAULT_TOOL_TIP_DELAY,
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
+
const iconClass = (iconPosition === 'left' ? 'tw-mr-1' : 'tw-ml-1');
|
|
167
|
+
const iconElement = icon && (React__default.createElement(Icon, { icon: icon, iconPrefix: iconPrefix, type: iconStyle, color: iconColor, extraClassNames: label ? `${iconClass} ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]}` : '', testId: `${id}_spinner` }));
|
|
166
168
|
return (React__default.createElement("button", { id: id, ...tooltipData, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
|
|
167
169
|
stopPropagation && e.stopPropagation();
|
|
168
170
|
onClick && onClick(e);
|
|
@@ -171,8 +173,9 @@ const Button = ({ onClick, label, variant = 'outline', type = 'button', size = '
|
|
|
171
173
|
e.preventDefault();
|
|
172
174
|
}
|
|
173
175
|
}, className: appliedClasses },
|
|
174
|
-
|
|
175
|
-
label
|
|
176
|
+
iconPosition === 'left' && iconElement,
|
|
177
|
+
label,
|
|
178
|
+
iconPosition === 'right' && iconElement));
|
|
176
179
|
};
|
|
177
180
|
|
|
178
181
|
function _extends() {
|