@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/index.js CHANGED
@@ -119,7 +119,7 @@ const Icon = ({ onClick, icon, iconPrefix = undefined, type = 'theme', extraClas
119
119
  * - use "variant" to achieve the desired style
120
120
  * - include tooltips and/or icons
121
121
  */
122
- 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, }) => {
122
+ 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, }) => {
123
123
  const baseClasses = 'tw-py-1 tw-px-2.5 tw-rounded-sm focus:tw-ring-0 disabled:tw-pointer-events-none';
124
124
  const baseClassesByVariant = {
125
125
  'outline': 'disabled:tw-opacity-50 tw-border-solid tw-border',
@@ -183,6 +183,8 @@ const Button = ({ onClick, label, variant = 'outline', type = 'button', size = '
183
183
  'data-qtip-delay': tooltipOptions?.delay ?? DEFAULT_TOOL_TIP_DELAY,
184
184
  };
185
185
  }
186
+ const iconClass = (iconPosition === 'left' ? 'tw-mr-1' : 'tw-ml-1');
187
+ const iconElement = icon && (React.createElement(Icon, { icon: icon, iconPrefix: iconPrefix, type: iconStyle, color: iconColor, extraClassNames: label ? `${iconClass} ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]}` : '', testId: `${id}_spinner` }));
186
188
  return (React.createElement("button", { id: id, ...tooltipData, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
187
189
  stopPropagation && e.stopPropagation();
188
190
  onClick && onClick(e);
@@ -191,8 +193,9 @@ const Button = ({ onClick, label, variant = 'outline', type = 'button', size = '
191
193
  e.preventDefault();
192
194
  }
193
195
  }, className: appliedClasses },
194
- icon && (React.createElement(Icon, { icon: icon, iconPrefix: iconPrefix, type: iconStyle, color: iconColor, extraClassNames: label ? `tw-mr-1 ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]}` : '', testId: `${id}_spinner` })),
195
- label));
196
+ iconPosition === 'left' && iconElement,
197
+ label,
198
+ iconPosition === 'right' && iconElement));
196
199
  };
197
200
 
198
201
  function _extends() {