@coveord/plasma-mantine
Version:
A Plasma flavoured Mantine theme
116 lines (115 loc) • 4.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Button", {
enumerable: true,
get: function() {
return Button;
}
});
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
var _to_array = require("@swc/helpers/_/_to_array");
var _jsxruntime = require("react/jsx-runtime");
var _core = require("@mantine/core");
var _useClickWithLoading = require("../../hooks/useClickWithLoading.js");
var _ButtonWithDisabledTooltip = require("./ButtonWithDisabledTooltip.js");
var Button = (0, _core.polymorphicFactory)(function(_0, _1) {
var _ref = [
_0,
_1
], _ref1 = _to_array._(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), disabledTooltip = _ref2.disabledTooltip, disabled = _ref2.disabled, disabledTooltipProps = _ref2.disabledTooltipProps, loading = _ref2.loading, onClick = _ref2.onClick, dataDisabled = _ref2['data-disabled'], others = _object_without_properties._(_ref2, [
"disabledTooltip",
"disabled",
"disabledTooltipProps",
"loading",
"onClick",
'data-disabled'
]), _rest1 = _sliced_to_array._(_rest, 1), ref = _rest1[0];
var _useClickWithLoading1 = (0, _useClickWithLoading.useClickWithLoading)(onClick), isLoading = _useClickWithLoading1.isLoading, handleClick = _useClickWithLoading1.handleClick;
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ButtonWithDisabledTooltip.ButtonWithDisabledTooltip, {
disabled: disabled || dataDisabled,
disabledTooltip: disabledTooltip,
disabledTooltipProps: disabledTooltipProps,
fullWidth: others.fullWidth,
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_core.Button, _object_spread._({
loaderProps: {
variant: 'oval'
},
ref: ref,
loading: isLoading || loading,
onClick: dataDisabled ? function(e) {
return e.preventDefault();
} : handleClick,
disabled: disabled || dataDisabled,
"data-loading": isLoading || loading || undefined
}, others))
});
});
var ButtonPrimary = Button.withProps({
variant: 'filled'
});
var ButtonSecondary = Button.withProps({
variant: 'light',
color: 'var(--coveo-color-text-primary)'
});
var ButtonTertiary = Button.withProps({
variant: 'default',
vars: function vars(theme) {
return {
root: {
'--button-color': 'var(--coveo-color-text-primary)',
'--button-padding-x': theme.spacing.sm
}
};
}
});
var ButtonQuaternary = Button.withProps({
variant: 'subtle',
color: 'var(--coveo-color-text-primary)'
});
var ButtonDestructive = Button.withProps({
variant: 'filled',
color: 'var(--mantine-color-error)'
});
var ButtonDestructiveSecondary = Button.withProps({
variant: 'light',
color: 'var(--mantine-color-error)'
});
var ButtonDestructiveTertiary = Button.withProps({
variant: 'default',
vars: function vars(theme) {
return {
root: {
'--button-color': 'var(--mantine-color-error)',
'--button-padding-x': theme.spacing.sm
}
};
}
});
var ButtonDestructiveQuaternary = Button.withProps({
variant: 'subtle',
color: 'var(--mantine-color-error)'
});
Button.Group = _core.Button.Group;
Button.Group.displayName = 'Button.Group';
Button.Primary = ButtonPrimary;
Button.Secondary = ButtonSecondary;
Button.Tertiary = ButtonTertiary;
Button.Quaternary = ButtonQuaternary;
Button.DestructivePrimary = ButtonDestructive;
Button.DestructiveSecondary = ButtonDestructiveSecondary;
Button.DestructiveTertiary = ButtonDestructiveTertiary;
Button.DestructiveQuaternary = ButtonDestructiveQuaternary;
ButtonPrimary.displayName = 'Button.Primary';
ButtonSecondary.displayName = 'Button.Secondary';
ButtonTertiary.displayName = 'Button.Tertiary';
ButtonQuaternary.displayName = 'Button.Quaternary';
ButtonDestructive.displayName = 'Button.DestructivePrimary';
ButtonDestructiveSecondary.displayName = 'Button.DestructiveSecondary';
ButtonDestructiveTertiary.displayName = 'Button.DestructiveTertiary';
ButtonDestructiveQuaternary.displayName = 'Button.DestructiveQuaternary';
Button.displayName = 'Button';
//# sourceMappingURL=Button.js.map