@producteca/producteca-ui-kit 1.20.0 → 1.21.1-beta.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/dist/components/alert/alert.js +37 -0
- package/dist/components/breadcrumb/breadcrumb.js +33 -0
- package/dist/components/breadcrumb/index.js +2 -0
- package/dist/components/button/button.js +34 -0
- package/dist/components/chip/chip.js +27 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/icons/customIcon/customIcon.js +41 -0
- package/dist/components/icons/fileIcon/fileIcon.js +14 -0
- package/dist/components/icons/{index.d.ts → index.js} +1 -1
- package/dist/components/icons/mailIcon/mailIcon.js +14 -0
- package/dist/components/icons/parameters.js +26 -0
- package/dist/components/icons/priceCloseIcon/priceCloseIcon.js +14 -0
- package/dist/components/icons/priceDownIcon/priceDownIcon.js +14 -0
- package/dist/components/icons/searchPublication/searchPublication.js +14 -0
- package/dist/components/image/image.js +26 -0
- package/dist/components/image/index.js +1 -0
- package/dist/components/{index.d.ts → index.js} +1 -0
- package/dist/components/inputs/checkboxInput/checkboxInput.js +35 -0
- package/dist/components/inputs/checkboxInput/checkboxInputGroup.js +58 -0
- package/dist/components/inputs/checkboxInput/{index.d.ts → index.js} +1 -2
- package/dist/components/inputs/datePicker/datePicker.js +143 -0
- package/dist/components/inputs/datePicker/datePickerCustomStyles.js +145 -0
- package/dist/components/inputs/datePicker/datePickerTypes.js +1 -0
- package/dist/components/inputs/datePicker/datePickerUtils.js +109 -0
- package/dist/components/inputs/datePicker/index.js +2 -0
- package/dist/components/inputs/dateRangePicker/dateFormater.js +28 -0
- package/dist/components/inputs/dateRangePicker/dateRangePicker.js +118 -0
- package/dist/components/inputs/dateRangePicker/dateRangePickerTypes.js +1 -0
- package/dist/components/inputs/dateRangePicker/dateRangePickerUtils.js +67 -0
- package/dist/components/inputs/dateRangePicker/index.js +2 -0
- package/dist/components/inputs/formField/formField.js +35 -0
- package/dist/components/inputs/formField/passwordInput.js +22 -0
- package/dist/components/inputs/formField/textInput.js +79 -0
- package/dist/components/inputs/{index.d.ts → index.js} +1 -1
- package/dist/components/inputs/searcher/searcher.js +112 -0
- package/dist/components/inputs/selectField/selectField.js +183 -0
- package/dist/components/inputs/switchInput/index.js +2 -0
- package/dist/components/inputs/switchInput/switchInput.js +77 -0
- package/dist/components/loaders/index.js +2 -0
- package/dist/components/loaders/progressbar/progressbar.js +37 -0
- package/dist/components/loaders/spinner/spinner.js +15 -0
- package/dist/components/menuAction/index.js +1 -0
- package/dist/components/menuAction/menuAction.js +67 -0
- package/dist/components/menuAction/menuActionCustomStyles.js +13 -0
- package/dist/components/modals/index.js +1 -0
- package/dist/components/modals/warningModal/index.js +1 -0
- package/dist/components/modals/warningModal/warningModal.js +41 -0
- package/dist/components/patterns/actionBar/actionBar.js +38 -0
- package/dist/components/patterns/copyButton/copyButton.js +69 -0
- package/dist/components/patterns/copyButton/index.js +1 -0
- package/dist/components/patterns/emptyState/emptyState.js +17 -0
- package/dist/components/patterns/headerSection/headerSection.js +17 -0
- package/dist/components/patterns/headerSection/index.js +1 -0
- package/dist/components/patterns/iconWithIdentifier/iconWithIdentifier.js +12 -0
- package/dist/components/patterns/iconWithIdentifier/index.js +1 -0
- package/dist/components/patterns/{index.d.ts → index.js} +1 -1
- package/dist/components/patterns/linkWithIcon/index.js +1 -0
- package/dist/components/patterns/linkWithIcon/linkWithIcon.js +26 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/tabs/tabs.js +70 -0
- package/dist/components/tooltip/index.js +2 -0
- package/dist/components/tooltip/overflowChecker.js +27 -0
- package/dist/components/tooltip/tooltip.js +97 -0
- package/dist/hooks/useReduxFormField.js +34 -0
- package/dist/{index.d.ts → index.js} +1 -1
- package/dist/locales/description.js +15 -0
- package/dist/locales/es.js +227 -0
- package/dist/locales/index.js +2 -0
- package/dist/locales/translator.js +20 -0
- package/dist/producteca-ui-kit.cjs.js +3 -0
- package/dist/producteca-ui-kit.es.js +3 -53447
- package/dist/producteca-ui-kit.umd.js +9 -604
- package/dist/styles/colors.js +67 -0
- package/dist/styles/styles/colors.tsx +88 -0
- package/dist/styles/styles/global.module.scss +85 -0
- package/dist/styles/styles/theme.tsx +24 -0
- package/dist/styles/styles/variables.module.scss +74 -0
- package/dist/styles/theme.js +22 -0
- package/dist/validators/errorMessage.js +15 -0
- package/dist/validators/index.js +2 -0
- package/dist/validators/validation.js +25 -0
- package/package.json +42 -4
- package/dist/components/alert/alert.d.ts +0 -17
- package/dist/components/breadcrumb/breadcrumb.d.ts +0 -15
- package/dist/components/breadcrumb/index.d.ts +0 -2
- package/dist/components/button/button.d.ts +0 -17
- package/dist/components/chip/chip.d.ts +0 -13
- package/dist/components/chip/index.d.ts +0 -2
- package/dist/components/icons/customIcon/customIcon.d.ts +0 -16
- package/dist/components/icons/fileIcon/fileIcon.d.ts +0 -5
- package/dist/components/icons/mailIcon/mailIcon.d.ts +0 -5
- package/dist/components/icons/parameters.d.ts +0 -51
- package/dist/components/icons/priceCloseIcon/priceCloseIcon.d.ts +0 -5
- package/dist/components/icons/priceDownIcon/priceDownIcon.d.ts +0 -5
- package/dist/components/icons/searchPublication/searchPublication.d.ts +0 -5
- package/dist/components/image/image.d.ts +0 -11
- package/dist/components/image/index.d.ts +0 -1
- package/dist/components/inputs/checkboxInput/checkboxInput.d.ts +0 -9
- package/dist/components/inputs/checkboxInput/checkboxInputGroup.d.ts +0 -22
- package/dist/components/inputs/datePicker/datePicker.d.ts +0 -5
- package/dist/components/inputs/datePicker/datePickerCustomStyles.d.ts +0 -8
- package/dist/components/inputs/datePicker/datePickerTypes.d.ts +0 -14
- package/dist/components/inputs/datePicker/datePickerUtils.d.ts +0 -68
- package/dist/components/inputs/datePicker/index.d.ts +0 -3
- package/dist/components/inputs/dateRangePicker/dateFormater.d.ts +0 -7
- package/dist/components/inputs/dateRangePicker/dateRangePicker.d.ts +0 -5
- package/dist/components/inputs/dateRangePicker/dateRangePickerTypes.d.ts +0 -14
- package/dist/components/inputs/dateRangePicker/dateRangePickerUtils.d.ts +0 -9
- package/dist/components/inputs/dateRangePicker/index.d.ts +0 -4
- package/dist/components/inputs/formField/formField.d.ts +0 -10
- package/dist/components/inputs/formField/passwordInput.d.ts +0 -4
- package/dist/components/inputs/formField/textInput.d.ts +0 -25
- package/dist/components/inputs/searcher/searcher.d.ts +0 -28
- package/dist/components/inputs/selectField/selectField.d.ts +0 -42
- package/dist/components/inputs/switchInput/index.d.ts +0 -4
- package/dist/components/inputs/switchInput/switchInput.d.ts +0 -31
- package/dist/components/loaders/index.d.ts +0 -2
- package/dist/components/loaders/progressbar/progressbar.d.ts +0 -8
- package/dist/components/loaders/spinner/spinner.d.ts +0 -6
- package/dist/components/menuAction/index.d.ts +0 -1
- package/dist/components/menuAction/menuAction.d.ts +0 -18
- package/dist/components/menuAction/menuActionCustomStyles.d.ts +0 -4
- package/dist/components/modals/index.d.ts +0 -1
- package/dist/components/modals/warningModal/index.d.ts +0 -1
- package/dist/components/modals/warningModal/warningModal.d.ts +0 -17
- package/dist/components/patterns/actionBar/actionBar.d.ts +0 -26
- package/dist/components/patterns/copyButton/copyButton.d.ts +0 -11
- package/dist/components/patterns/copyButton/index.d.ts +0 -1
- package/dist/components/patterns/emptyState/emptyState.d.ts +0 -11
- package/dist/components/patterns/headerSection/headerSection.d.ts +0 -14
- package/dist/components/patterns/headerSection/index.d.ts +0 -1
- package/dist/components/patterns/iconWithIdentifier/iconWithIdentifier.d.ts +0 -11
- package/dist/components/patterns/iconWithIdentifier/index.d.ts +0 -1
- package/dist/components/patterns/linkWithIcon/index.d.ts +0 -1
- package/dist/components/patterns/linkWithIcon/linkWithIcon.d.ts +0 -14
- package/dist/components/tooltip/index.d.ts +0 -3
- package/dist/components/tooltip/overflowChecker.d.ts +0 -5
- package/dist/components/tooltip/tooltip.d.ts +0 -20
- package/dist/favicon.svg +0 -43
- package/dist/hooks/useReduxFormField.d.ts +0 -26
- package/dist/locales/description.d.ts +0 -15
- package/dist/locales/es.d.ts +0 -222
- package/dist/locales/index.d.ts +0 -2
- package/dist/locales/translator.d.ts +0 -3
- package/dist/style.css +0 -1
- package/dist/styles/colors.d.ts +0 -25
- package/dist/styles/theme.d.ts +0 -2
- package/dist/validators/errorMessage.d.ts +0 -5
- package/dist/validators/index.d.ts +0 -2
- package/dist/validators/validation.d.ts +0 -21
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import _slicedToArray from "babel-runtime/helpers/slicedToArray";
|
|
2
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) {
|
|
5
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { useEffect, useState } from 'react';
|
|
13
|
+
import Select from 'react-select';
|
|
14
|
+
import { ClearComponent, Option, SingleValue } from '../selectField/selectField';
|
|
15
|
+
import clsx from 'clsx';
|
|
16
|
+
import styles from '../selectField/selectField.module.scss';
|
|
17
|
+
import CustomIcon from '../../icons/customIcon/customIcon';
|
|
18
|
+
import { SearchRounded } from '@mui/icons-material';
|
|
19
|
+
import locale from '../../../locales';
|
|
20
|
+
import _ from 'lodash';
|
|
21
|
+
import Spinner from '../../loaders/spinner/spinner';
|
|
22
|
+
var SearchComponent = function SearchComponent() {
|
|
23
|
+
return _jsx("div", { className: styles['producteca-select-field__search-icon'], children: _jsx(CustomIcon, { children: _jsx(SearchRounded, {}) }) });
|
|
24
|
+
};
|
|
25
|
+
export var Searcher = function Searcher(props) {
|
|
26
|
+
var name = props.name,
|
|
27
|
+
label = props.label,
|
|
28
|
+
_props$placeholder = props.placeholder,
|
|
29
|
+
placeholder = _props$placeholder === undefined ? locale('selectPlaceholder') : _props$placeholder,
|
|
30
|
+
_props$noOptionsMessa = props.noOptionsMessage,
|
|
31
|
+
_noOptionsMessage = _props$noOptionsMessa === undefined ? locale('noFoundOptions') : _props$noOptionsMessa,
|
|
32
|
+
options = props.options,
|
|
33
|
+
_props$size = props.size,
|
|
34
|
+
size = _props$size === undefined ? 'md' : _props$size,
|
|
35
|
+
_props$isSearchable = props.isSearchable,
|
|
36
|
+
isSearchable = _props$isSearchable === undefined ? true : _props$isSearchable,
|
|
37
|
+
_props$isClearable = props.isClearable,
|
|
38
|
+
isClearable = _props$isClearable === undefined ? true : _props$isClearable,
|
|
39
|
+
_props$clearOnSelect = props.clearOnSelect,
|
|
40
|
+
clearOnSelect = _props$clearOnSelect === undefined ? false : _props$clearOnSelect,
|
|
41
|
+
required = props.required,
|
|
42
|
+
disabled = props.disabled,
|
|
43
|
+
rightModifier = props.rightModifier,
|
|
44
|
+
isOptionDisabled = props.isOptionDisabled,
|
|
45
|
+
onChange = props.onChange,
|
|
46
|
+
onInputChange = props.onInputChange,
|
|
47
|
+
input = props.input,
|
|
48
|
+
_props$isLoading = props.isLoading,
|
|
49
|
+
isLoading = _props$isLoading === undefined ? false : _props$isLoading,
|
|
50
|
+
otherProps = __rest(props, ["name", "label", "placeholder", "noOptionsMessage", "options", "size", "isSearchable", "isClearable", "clearOnSelect", "required", "disabled", "rightModifier", "isOptionDisabled", "onChange", "onInputChange", "input", "isLoading"]);
|
|
51
|
+
|
|
52
|
+
var _useState = useState(null),
|
|
53
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
54
|
+
optionSelected = _useState2[0],
|
|
55
|
+
setOptionSelected = _useState2[1];
|
|
56
|
+
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
setIsMenuOpen(!_.isEmpty(options) || isLoading);
|
|
59
|
+
}, [options, isLoading]);
|
|
60
|
+
|
|
61
|
+
var _useState3 = useState(false),
|
|
62
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
63
|
+
isMenuOpen = _useState4[0],
|
|
64
|
+
setIsMenuOpen = _useState4[1];
|
|
65
|
+
|
|
66
|
+
var handleInputChange = function handleInputChange(value) {
|
|
67
|
+
var fakeEvent = {
|
|
68
|
+
target: {
|
|
69
|
+
name: name,
|
|
70
|
+
value: value
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(fakeEvent);
|
|
74
|
+
setIsMenuOpen(!_.isEmpty(options) || isLoading);
|
|
75
|
+
};
|
|
76
|
+
var handleSelect = function handleSelect(selected) {
|
|
77
|
+
var fakeEvent = {
|
|
78
|
+
target: {
|
|
79
|
+
name: name,
|
|
80
|
+
value: selected === null || selected === void 0 ? void 0 : selected.value
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
setOptionSelected(selected);
|
|
84
|
+
if (input) {
|
|
85
|
+
input.onChange(selected === null || selected === void 0 ? void 0 : selected.value);
|
|
86
|
+
} else {
|
|
87
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(fakeEvent);
|
|
88
|
+
}
|
|
89
|
+
if (clearOnSelect && selected) {
|
|
90
|
+
setOptionSelected(null);
|
|
91
|
+
}
|
|
92
|
+
setIsMenuOpen(false);
|
|
93
|
+
};
|
|
94
|
+
var handleBlur = function handleBlur() {
|
|
95
|
+
if (input) {
|
|
96
|
+
input.onBlur();
|
|
97
|
+
}
|
|
98
|
+
setIsMenuOpen(false);
|
|
99
|
+
};
|
|
100
|
+
return _jsxs("div", { className: styles['producteca-select-field-container'], children: [label && _jsx("label", { htmlFor: name, children: label }), _jsxs("div", { className: clsx(styles[size], styles['producteca-select-field-body'], styles[isSearchable ? 'producteca-select-field--is-searchable' : ''], styles[isClearable ? 'producteca-select-field--is-clearable' : ''], styles[rightModifier ? 'producteca-select-field--with-modifier' : '']), children: [_jsxs("div", { className: styles['searcher-body'], children: [isSearchable && _jsx(SearchComponent, {}), _jsx(Select, Object.assign({}, otherProps, { name: name, placeholder: placeholder, classNamePrefix: "producteca-select-field", isDisabled: disabled, isClearable: isClearable, isOptionDisabled: isOptionDisabled, isSearchable: isSearchable, noOptionsMessage: function noOptionsMessage() {
|
|
101
|
+
return isLoading ? _jsx(Spinner, { size: 'sm' }) : _noOptionsMessage;
|
|
102
|
+
}, onInputChange: handleInputChange, onChange: handleSelect, onBlur: handleBlur, value: optionSelected, options: options, components: { Option: Option, SingleValue: SingleValue }, menuPortalTarget: document.body, menuIsOpen: isMenuOpen, onMenuOpen: function onMenuOpen() {
|
|
103
|
+
return setIsMenuOpen(!_.isEmpty(options) || isLoading);
|
|
104
|
+
}, onMenuClose: function onMenuClose() {
|
|
105
|
+
return setIsMenuOpen(false);
|
|
106
|
+
} })), _jsx(ClearComponent, { isClearable: isClearable, handleChange: function handleChange() {
|
|
107
|
+
setOptionSelected(null);
|
|
108
|
+
if (input) {
|
|
109
|
+
input.onChange(null);
|
|
110
|
+
}
|
|
111
|
+
} })] }), !!rightModifier && rightModifier] })] });
|
|
112
|
+
};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import _slicedToArray from 'babel-runtime/helpers/slicedToArray';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import Select, { components } from 'react-select';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
import locale from '../../../locales';
|
|
7
|
+
import styles from './selectField.module.scss';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import { ClearRounded, SearchRounded } from '@mui/icons-material';
|
|
10
|
+
import CustomIcon from '../../icons/customIcon/customIcon';
|
|
11
|
+
import { useReduxFormField } from '../../../hooks/useReduxFormField';
|
|
12
|
+
export var Option = function Option(props) {
|
|
13
|
+
var _useState = useState(false),
|
|
14
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15
|
+
showTooltip = _useState2[0],
|
|
16
|
+
setShowTooltip = _useState2[1];
|
|
17
|
+
|
|
18
|
+
var _useState3 = useState({ top: 0, left: 0 }),
|
|
19
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
20
|
+
tooltipPosition = _useState4[0],
|
|
21
|
+
setTooltipPosition = _useState4[1];
|
|
22
|
+
|
|
23
|
+
var optionRef = useRef(null);
|
|
24
|
+
var showDisabledTooltip = props.isDisabled && !!props.data.tooltipMessage;
|
|
25
|
+
var updateTooltipPosition = useCallback(function () {
|
|
26
|
+
if (optionRef.current && showTooltip) {
|
|
27
|
+
var rect = optionRef.current.getBoundingClientRect();
|
|
28
|
+
setTooltipPosition({
|
|
29
|
+
top: rect.top,
|
|
30
|
+
left: rect.right + 5
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, [showTooltip]);
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
if (optionRef.current) {
|
|
36
|
+
var hasOverflow = optionRef.current.scrollWidth > optionRef.current.offsetWidth;
|
|
37
|
+
setShowTooltip(showDisabledTooltip || hasOverflow);
|
|
38
|
+
}
|
|
39
|
+
}, [props.label, showDisabledTooltip]);
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
if (showTooltip) {
|
|
42
|
+
updateTooltipPosition();
|
|
43
|
+
window.addEventListener('scroll', updateTooltipPosition, true);
|
|
44
|
+
return function () {
|
|
45
|
+
return window.removeEventListener('scroll', updateTooltipPosition, true);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}, [showTooltip, updateTooltipPosition]);
|
|
49
|
+
return _jsx("div", { className: styles[showTooltip ? 'option-with-tooltip' : ''], "data-tooltip": showDisabledTooltip ? props.data.tooltipMessage : props.label, style: showTooltip ? {
|
|
50
|
+
'--tooltip-top': tooltipPosition.top + 'px',
|
|
51
|
+
'--tooltip-left': tooltipPosition.left + 'px'
|
|
52
|
+
} : undefined, children: _jsx(components.Option, Object.assign({}, props, { children: _jsxs("div", { className: clsx(styles[props.isDisabled ? 'disabled' : ''], styles[props.isMulti ? 'producteca-select-field__input-multiple' : '']), children: [props.isMulti && _jsx("input", { type: "checkbox", checked: props.isSelected, onChange: _.identity }), _jsx("label", { ref: optionRef, children: props.label })] }) })) });
|
|
53
|
+
};
|
|
54
|
+
var MultiValue = function MultiValue(props) {
|
|
55
|
+
return _jsx(components.MultiValue, Object.assign({}, props, { children: _jsx("span", { children: props.data.label }) }));
|
|
56
|
+
};
|
|
57
|
+
export var SingleValue = function SingleValue(props) {
|
|
58
|
+
return _jsx(components.SingleValue, Object.assign({}, props, { children: _jsx("span", { children: props.data.label }) }));
|
|
59
|
+
};
|
|
60
|
+
export var SearchComponent = function SearchComponent() {
|
|
61
|
+
return _jsx("div", { className: styles['producteca-select-field__search-icon'], children: _jsx(CustomIcon, { children: _jsx(SearchRounded, {}) }) });
|
|
62
|
+
};
|
|
63
|
+
var MultipleTextComponent = function MultipleTextComponent(_ref) {
|
|
64
|
+
var _ref$optionSelected = _ref.optionSelected,
|
|
65
|
+
optionSelected = _ref$optionSelected === undefined ? null : _ref$optionSelected;
|
|
66
|
+
|
|
67
|
+
var isArrayWithSome = optionSelected && _.isArray(optionSelected) && optionSelected.length > 0;
|
|
68
|
+
var text = optionSelected && _.isArray(optionSelected) && optionSelected.length === 1 ? locale('selected') : locale('selectedPlural');
|
|
69
|
+
return isArrayWithSome ? _jsx("div", { className: styles['producteca-select-field__is-multiple'], children: _jsxs("span", { children: [optionSelected.length, " ", text] }) }) : null;
|
|
70
|
+
};
|
|
71
|
+
var ValidationComponent = function ValidationComponent() {
|
|
72
|
+
return _jsx("div", { className: styles['producteca-select-field--is-required'], children: locale('selectRequiredText') });
|
|
73
|
+
};
|
|
74
|
+
export var ClearComponent = function ClearComponent(_ref2) {
|
|
75
|
+
var optionSelected = _ref2.optionSelected,
|
|
76
|
+
isClearable = _ref2.isClearable,
|
|
77
|
+
handleChange = _ref2.handleChange;
|
|
78
|
+
|
|
79
|
+
var isArrayWithSome = optionSelected && _.isArray(optionSelected) && optionSelected.length > 0;
|
|
80
|
+
var hasSelectedValue = !_.isArray(optionSelected) && optionSelected && 'value' in optionSelected && optionSelected.value;
|
|
81
|
+
return isClearable && (isArrayWithSome || hasSelectedValue) ? _jsx("a", { className: styles['producteca-select-field__is-clearable'], onClick: function onClick() {
|
|
82
|
+
return handleChange(null);
|
|
83
|
+
}, children: _jsx(CustomIcon, { children: _jsx(ClearRounded, {}) }) }) : null;
|
|
84
|
+
};
|
|
85
|
+
export var SelectField = function SelectField(props) {
|
|
86
|
+
var _a;
|
|
87
|
+
|
|
88
|
+
var name = props.name,
|
|
89
|
+
label = props.label,
|
|
90
|
+
_props$placeholder = props.placeholder,
|
|
91
|
+
placeholder = _props$placeholder === undefined ? locale('selectPlaceholder') : _props$placeholder,
|
|
92
|
+
_props$noOptionsMessa = props.noOptionsMessage,
|
|
93
|
+
_noOptionsMessage = _props$noOptionsMessa === undefined ? locale('noFoundOptions') : _props$noOptionsMessa,
|
|
94
|
+
options = props.options,
|
|
95
|
+
_props$size = props.size,
|
|
96
|
+
size = _props$size === undefined ? 'md' : _props$size,
|
|
97
|
+
_props$hideSelectedOp = props.hideSelectedOptions,
|
|
98
|
+
hideSelectedOptions = _props$hideSelectedOp === undefined ? true : _props$hideSelectedOp,
|
|
99
|
+
_props$isMultiple = props.isMultiple,
|
|
100
|
+
isMultiple = _props$isMultiple === undefined ? false : _props$isMultiple,
|
|
101
|
+
_props$isSearchable = props.isSearchable,
|
|
102
|
+
isSearchable = _props$isSearchable === undefined ? true : _props$isSearchable,
|
|
103
|
+
_props$isClearable = props.isClearable,
|
|
104
|
+
isClearable = _props$isClearable === undefined ? true : _props$isClearable,
|
|
105
|
+
required = props.required,
|
|
106
|
+
disabled = props.disabled,
|
|
107
|
+
rightModifier = props.rightModifier,
|
|
108
|
+
isOptionDisabled = props.isOptionDisabled,
|
|
109
|
+
_onChange = props.onChange,
|
|
110
|
+
defaultValue = props.defaultValue,
|
|
111
|
+
input = props.input,
|
|
112
|
+
propsOnBlur = props.onBlur;
|
|
113
|
+
|
|
114
|
+
var value = (_a = input === null || input === void 0 ? void 0 : input.value) !== null && _a !== void 0 ? _a : props.value;
|
|
115
|
+
var defaultOption = _.filter(options, function (_ref3) {
|
|
116
|
+
var optionValue = _ref3.value;
|
|
117
|
+
return _.includes(value, optionValue);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
var _useState5 = useState(defaultOption || null),
|
|
121
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
122
|
+
optionSelected = _useState6[0],
|
|
123
|
+
setOptionSelected = _useState6[1];
|
|
124
|
+
|
|
125
|
+
var _useState7 = useState(false),
|
|
126
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
127
|
+
touched = _useState8[0],
|
|
128
|
+
setTouched = _useState8[1];
|
|
129
|
+
|
|
130
|
+
var _useReduxFormField = useReduxFormField({
|
|
131
|
+
input: input,
|
|
132
|
+
onChange: function onChange(selected) {
|
|
133
|
+
var selectedValue = isMultiple ? _.map(selected, function (opt) {
|
|
134
|
+
return opt.value;
|
|
135
|
+
}) : selected === null || selected === void 0 ? void 0 : selected.value;
|
|
136
|
+
if (!input) {
|
|
137
|
+
var fakeEvent = {
|
|
138
|
+
target: {
|
|
139
|
+
name: name,
|
|
140
|
+
value: selectedValue
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(fakeEvent);
|
|
144
|
+
}
|
|
145
|
+
return selectedValue;
|
|
146
|
+
},
|
|
147
|
+
onBlur: propsOnBlur,
|
|
148
|
+
transformValue: function transformValue(selected) {
|
|
149
|
+
var selectedValue = isMultiple ? _.map(selected, function (opt) {
|
|
150
|
+
return opt.value;
|
|
151
|
+
}) : selected === null || selected === void 0 ? void 0 : selected.value;
|
|
152
|
+
return selectedValue;
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
fieldHandleChange = _useReduxFormField.handleChange,
|
|
156
|
+
handleBlur = _useReduxFormField.handleBlur;
|
|
157
|
+
|
|
158
|
+
var handleChange = function handleChange(selected) {
|
|
159
|
+
fieldHandleChange(selected);
|
|
160
|
+
setOptionSelected(selected);
|
|
161
|
+
setTouched(true);
|
|
162
|
+
};
|
|
163
|
+
useEffect(function () {
|
|
164
|
+
if (defaultValue && options.length > 0) {
|
|
165
|
+
var val = _.isArray(defaultValue) ? defaultValue : [defaultValue];
|
|
166
|
+
var matchingOptions = _.filter(options, function (_ref4) {
|
|
167
|
+
var value = _ref4.value;
|
|
168
|
+
return _.includes(val, value);
|
|
169
|
+
});
|
|
170
|
+
setOptionSelected(isMultiple ? matchingOptions : matchingOptions[0] || null);
|
|
171
|
+
}
|
|
172
|
+
}, [defaultValue, options]);
|
|
173
|
+
var _isValid = function _isValid() {
|
|
174
|
+
return !required || !touched || !_.isEmpty(optionSelected);
|
|
175
|
+
};
|
|
176
|
+
var optionComponent = isMultiple ? { Option: Option, MultiValue: MultiValue } : { Option: Option, SingleValue: SingleValue };
|
|
177
|
+
return _jsxs("div", { className: styles['producteca-select-field-container'], "data-testid": "producteca-select-field-container", children: [label && _jsx("label", { htmlFor: name, children: label }), _jsxs("div", { className: clsx(styles[size], styles['producteca-select-field-body'], styles[!_isValid() ? 'producteca-select-field--on-error' : ''], styles[isSearchable && !isMultiple ? 'producteca-select-field--is-searchable' : ''], styles[isClearable ? 'producteca-select-field--is-clearable' : ''], styles[rightModifier ? 'producteca-select-field--with-modifier' : '']), children: [_jsxs("div", { className: styles['body'], children: [isMultiple && _jsx(MultipleTextComponent, { optionSelected: optionSelected }), isSearchable && !isMultiple && _jsx(SearchComponent, {}), _jsx(Select, Object.assign({}, props, { name: name, classNamePrefix: "producteca-select-field", placeholder: placeholder, isDisabled: disabled, isMulti: isMultiple, closeMenuOnSelect: !isMultiple, hideSelectedOptions: hideSelectedOptions && !isMultiple, isClearable: isClearable, isOptionDisabled: isOptionDisabled, isSearchable: isSearchable && !isMultiple, noOptionsMessage: function noOptionsMessage() {
|
|
178
|
+
return _noOptionsMessage;
|
|
179
|
+
},
|
|
180
|
+
//@ts-ignore Because onChange receives a parameter (newValue) that is internal to react-select
|
|
181
|
+
onChange: handleChange, onBlur: handleBlur, value: optionSelected, options: options, components: optionComponent, menuPortalTarget: document.body })), _jsx(ClearComponent, { optionSelected: optionSelected, isClearable: isClearable, handleChange: handleChange })] }), !!rightModifier && rightModifier] }), !_isValid() && _jsx(ValidationComponent, {})] });
|
|
182
|
+
};
|
|
183
|
+
export default SelectField;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) {
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
5
|
+
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
6
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import styles from './switchInput.module.scss';
|
|
12
|
+
import _ from 'lodash';
|
|
13
|
+
import { useReduxFormField } from '../../../hooks/useReduxFormField';
|
|
14
|
+
export var SwitchInputGroup = function SwitchInputGroup(_a) {
|
|
15
|
+
var title = _a.title,
|
|
16
|
+
name = _a.name,
|
|
17
|
+
items = _a.items,
|
|
18
|
+
onChange = _a.onChange,
|
|
19
|
+
_a$size = _a.size,
|
|
20
|
+
size = _a$size === undefined ? 'sm' : _a$size,
|
|
21
|
+
input = _a.input,
|
|
22
|
+
props = __rest(_a, ["title", "name", "items", "onChange", "size", "input"]);
|
|
23
|
+
|
|
24
|
+
var _useReduxFormField = useReduxFormField({
|
|
25
|
+
input: input,
|
|
26
|
+
onChange: onChange,
|
|
27
|
+
transformValue: function transformValue(event) {
|
|
28
|
+
var _event$target = event.target,
|
|
29
|
+
checked = _event$target.checked,
|
|
30
|
+
inputName = _event$target.name;
|
|
31
|
+
|
|
32
|
+
if (input) {
|
|
33
|
+
var newValue = Object.assign({}, input.value);
|
|
34
|
+
newValue[inputName] = checked;
|
|
35
|
+
return newValue;
|
|
36
|
+
}
|
|
37
|
+
return event;
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
handleChange = _useReduxFormField.handleChange,
|
|
41
|
+
handleBlur = _useReduxFormField.handleBlur;
|
|
42
|
+
|
|
43
|
+
return _jsxs("div", { className: styles['switch-input-container'], "data-testid": "switch-input-container", children: [title && _jsxs("label", { className: styles['title'], "data-testid": "switch-title", children: [' ', title, ' '] }), _jsx("div", { className: styles['switch-input-items'] + " " + styles[size], "data-testid": "switch-input-items", children: _.map(items, function (_a) {
|
|
44
|
+
var id = _a.id,
|
|
45
|
+
itemName = _a.name,
|
|
46
|
+
label = _a.label,
|
|
47
|
+
disabled = _a.disabled,
|
|
48
|
+
checked = _a.checked,
|
|
49
|
+
value = _a.value,
|
|
50
|
+
itemProps = __rest(_a, ["id", "name", "label", "disabled", "checked", "value"]);
|
|
51
|
+
|
|
52
|
+
var inputId = id || itemName || name;
|
|
53
|
+
return _jsxs("label", { htmlFor: inputId, className: "" + (disabled ? styles['disabled'] : ''), "data-testid": "switch-label-" + inputId, children: [_jsxs("div", { className: styles['switch-wrapper'], children: [_jsx("input", Object.assign({}, props, itemProps, { id: inputId, type: "checkbox", name: itemName || name, checked: input && itemName ? _.get(input.value, itemName) : checked, disabled: disabled, onChange: handleChange, onBlur: handleBlur, className: styles['switch-input'], "data-testid": "switch-input-" + inputId })), _jsx("span", { className: styles['switch-slider'] })] }), _jsxs("span", { className: styles['switch-label'], children: [" ", label, " "] })] }, inputId);
|
|
54
|
+
}) })] });
|
|
55
|
+
};
|
|
56
|
+
export var SwitchInput = function SwitchInput(_a) {
|
|
57
|
+
var name = _a.name,
|
|
58
|
+
checked = _a.checked,
|
|
59
|
+
onChange = _a.onChange,
|
|
60
|
+
label = _a.label,
|
|
61
|
+
title = _a.title,
|
|
62
|
+
_a$disabled = _a.disabled,
|
|
63
|
+
disabled = _a$disabled === undefined ? false : _a$disabled,
|
|
64
|
+
_a$size2 = _a.size,
|
|
65
|
+
size = _a$size2 === undefined ? 'sm' : _a$size2,
|
|
66
|
+
input = _a.input,
|
|
67
|
+
props = __rest(_a, ["name", "checked", "onChange", "label", "title", "disabled", "size", "input"]);
|
|
68
|
+
|
|
69
|
+
var item = {
|
|
70
|
+
id: name + "-single",
|
|
71
|
+
label: label,
|
|
72
|
+
checked: checked,
|
|
73
|
+
disabled: disabled
|
|
74
|
+
};
|
|
75
|
+
return _jsx(SwitchInputGroup, Object.assign({}, props, { name: name, items: [item], onChange: onChange, title: title, size: size, input: input }));
|
|
76
|
+
};
|
|
77
|
+
export default SwitchInput;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _slicedToArray from 'babel-runtime/helpers/slicedToArray';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { LinearProgress } from '@mui/material';
|
|
4
|
+
import styles from './progressbar.module.scss';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
7
|
+
export var Progressbar = function Progressbar(_ref) {
|
|
8
|
+
var _ref$size = _ref.size,
|
|
9
|
+
size = _ref$size === undefined ? 'lg' : _ref$size,
|
|
10
|
+
_ref$progress = _ref.progress,
|
|
11
|
+
initialProgress = _ref$progress === undefined ? 0 : _ref$progress,
|
|
12
|
+
_ref$variant = _ref.variant,
|
|
13
|
+
variant = _ref$variant === undefined ? 'determinate' : _ref$variant;
|
|
14
|
+
|
|
15
|
+
var _useState = useState(initialProgress),
|
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
+
progress = _useState2[0],
|
|
18
|
+
setProgress = _useState2[1];
|
|
19
|
+
|
|
20
|
+
useEffect(function () {
|
|
21
|
+
if (variant === 'buffer') {
|
|
22
|
+
var timer = setInterval(function () {
|
|
23
|
+
setProgress(function (oldProgress) {
|
|
24
|
+
var newProgress = Math.min(100, oldProgress + Math.sqrt(100 - oldProgress) * 0.5);
|
|
25
|
+
return Math.round(newProgress);
|
|
26
|
+
});
|
|
27
|
+
}, 100);
|
|
28
|
+
return function () {
|
|
29
|
+
clearInterval(timer);
|
|
30
|
+
};
|
|
31
|
+
} else {
|
|
32
|
+
setProgress(initialProgress);
|
|
33
|
+
}
|
|
34
|
+
}, [variant, initialProgress]);
|
|
35
|
+
return _jsx(LinearProgress, { variant: variant == 'buffer' ? 'determinate' : variant, value: progress, className: clsx(styles['progressbar'], styles[size]), "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": progress });
|
|
36
|
+
};
|
|
37
|
+
export default Progressbar;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CircularProgress } from '@mui/material';
|
|
3
|
+
import styles from './spinner.module.scss';
|
|
4
|
+
export var Spinner = function Spinner(_ref) {
|
|
5
|
+
var _ref$size = _ref.size,
|
|
6
|
+
size = _ref$size === undefined ? 'lg' : _ref$size;
|
|
7
|
+
return _jsx(CircularProgress, { size: _size(size), className: styles.loader });
|
|
8
|
+
};
|
|
9
|
+
var _size = function _size(size) {
|
|
10
|
+
return {
|
|
11
|
+
sm: 18,
|
|
12
|
+
lg: 60
|
|
13
|
+
}[size];
|
|
14
|
+
};
|
|
15
|
+
export default Spinner;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MenuAction } from './menuAction';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _slicedToArray from "babel-runtime/helpers/slicedToArray";
|
|
2
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) {
|
|
5
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { useMemo, useState } from 'react';
|
|
13
|
+
import IconButton from '@mui/material/IconButton';
|
|
14
|
+
import Menu from '@mui/material/Menu';
|
|
15
|
+
import { Grow } from '@mui/material';
|
|
16
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
17
|
+
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
18
|
+
import { map } from "lodash";
|
|
19
|
+
import { getColor } from '../../styles/colors';
|
|
20
|
+
import { CustomIcon } from '../icons';
|
|
21
|
+
import { menuPaperStyles, menuItemStyles } from './menuActionCustomStyles';
|
|
22
|
+
var DEFAULT_ITEM_HEIGHT = 48;
|
|
23
|
+
export var MenuAction = function MenuAction(_a) {
|
|
24
|
+
var items = _a.items,
|
|
25
|
+
_a$id = _a.id,
|
|
26
|
+
id = _a$id === undefined ? 'menu-action-button' : _a$id,
|
|
27
|
+
_a$maxItemsVisible = _a.maxItemsVisible,
|
|
28
|
+
maxItemsVisible = _a$maxItemsVisible === undefined ? 6 : _a$maxItemsVisible,
|
|
29
|
+
icon = _a.icon,
|
|
30
|
+
otherProps = __rest(_a, ["items", "id", "maxItemsVisible", "icon"]);
|
|
31
|
+
|
|
32
|
+
var _useState = useState(null),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
anchorEl = _useState2[0],
|
|
35
|
+
setAnchorEl = _useState2[1];
|
|
36
|
+
|
|
37
|
+
var open = Boolean(anchorEl);
|
|
38
|
+
var handleClick = function handleClick(event) {
|
|
39
|
+
setAnchorEl(event.currentTarget);
|
|
40
|
+
};
|
|
41
|
+
var handleClose = function handleClose() {
|
|
42
|
+
setAnchorEl(null);
|
|
43
|
+
};
|
|
44
|
+
var paperStyle = useMemo(function () {
|
|
45
|
+
return {
|
|
46
|
+
maxHeight: DEFAULT_ITEM_HEIGHT * maxItemsVisible
|
|
47
|
+
};
|
|
48
|
+
}, [maxItemsVisible]);
|
|
49
|
+
return _jsxs("div", { children: [_jsx(IconButton, { id: id, "aria-controls": open ? id + "-menu" : undefined, "aria-expanded": open ? 'true' : undefined, "aria-haspopup": "true", onClick: handleClick, children: icon !== null && icon !== void 0 ? icon : _jsx(CustomIcon, { color: getColor("grey", "900"), children: _jsx(MoreVertIcon, {}) }) }), _jsx(Menu, Object.assign({ id: id + "-menu", anchorEl: anchorEl, open: open, onClose: handleClose, slotProps: {
|
|
50
|
+
paper: { style: paperStyle },
|
|
51
|
+
list: { 'aria-labelledby': id },
|
|
52
|
+
transition: Grow
|
|
53
|
+
}, anchorOrigin: {
|
|
54
|
+
vertical: 'bottom',
|
|
55
|
+
horizontal: 'right'
|
|
56
|
+
}, transformOrigin: {
|
|
57
|
+
vertical: 'top',
|
|
58
|
+
horizontal: 'right'
|
|
59
|
+
}, sx: menuPaperStyles }, otherProps, { children: map(items, function (item, index) {
|
|
60
|
+
return _jsx(MenuItem, Object.assign({ sx: menuItemStyles }, item, { onClick: function onClick() {
|
|
61
|
+
var _a;
|
|
62
|
+
handleClose();
|
|
63
|
+
(_a = item.onClick) === null || _a === void 0 ? void 0 : _a.call(item);
|
|
64
|
+
}, children: item.label }), index);
|
|
65
|
+
}) }))] });
|
|
66
|
+
};
|
|
67
|
+
export default MenuAction;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getColor } from '../../styles/colors';
|
|
2
|
+
export var menuPaperStyles = {
|
|
3
|
+
'& .MuiPopover-paper': {
|
|
4
|
+
boxShadow: '0px 5px 5px -3px rgb(205 205 205 / 20%), 0px 8px 14px 1px rgb(165 165 165 / 14%), 0px 3px 14px 2px rgb(219 219 219 / 6%)'
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
export var menuItemStyles = {
|
|
8
|
+
fontFamily: 'Poppins, Open Sans, Helvetica, Arial, sans-serif',
|
|
9
|
+
fontSize: '12px',
|
|
10
|
+
color: getColor('grey', '900'),
|
|
11
|
+
'&.Mui-selected': { backgroundColor: '#F2F4F7' },
|
|
12
|
+
'&.Mui-disabled': { opacity: 0.5 }
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './warningModal/warningModal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WarningModal } from "./warningModal";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) {
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
5
|
+
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
6
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import styles from './warningModal.module.scss';
|
|
12
|
+
import { CheckboxInput } from '../../inputs/checkboxInput/checkboxInput';
|
|
13
|
+
import { CustomIcon } from '../../icons';
|
|
14
|
+
import AutoStoriesIcon from '@mui/icons-material/AutoStories';
|
|
15
|
+
import ErrorIcon from '@mui/icons-material/Error';
|
|
16
|
+
import locale from '../../../locales';
|
|
17
|
+
import { ActionBar } from '../../patterns/actionBar/actionBar';
|
|
18
|
+
import { getColor } from "../../../styles/colors";
|
|
19
|
+
var DefaultIcon = _jsx(CustomIcon, { size: "32", color: getColor("secondary", "500"), children: _jsx(ErrorIcon, {}) });
|
|
20
|
+
export var WarningModal = function WarningModal(_a) {
|
|
21
|
+
var icon = _a.icon,
|
|
22
|
+
_a$title = _a.title,
|
|
23
|
+
title = _a$title === undefined ? locale('warningModal.warning') : _a$title,
|
|
24
|
+
description = _a.description,
|
|
25
|
+
_a$confirmLabel = _a.confirmLabel,
|
|
26
|
+
confirmLabel = _a$confirmLabel === undefined ? locale('continue') : _a$confirmLabel,
|
|
27
|
+
_a$cancelLabel = _a.cancelLabel,
|
|
28
|
+
cancelLabel = _a$cancelLabel === undefined ? locale('cancel') : _a$cancelLabel,
|
|
29
|
+
onSave = _a.onSave,
|
|
30
|
+
onCancel = _a.onCancel,
|
|
31
|
+
_a$dontShowAgainLabel = _a.dontShowAgainLabel,
|
|
32
|
+
dontShowAgainLabel = _a$dontShowAgainLabel === undefined ? locale('warningModal.dontShowAgain') : _a$dontShowAgainLabel,
|
|
33
|
+
onChangeDontShowAgain = _a.onChangeDontShowAgain,
|
|
34
|
+
onClickGuide = _a.onClickGuide,
|
|
35
|
+
props = __rest(_a, ["icon", "title", "description", "confirmLabel", "cancelLabel", "onSave", "onCancel", "dontShowAgainLabel", "onChangeDontShowAgain", "onClickGuide"]);
|
|
36
|
+
|
|
37
|
+
return _jsx("div", Object.assign({ className: styles['overlay'], role: "dialog", "aria-modal": "true" }, props, { children: _jsxs("div", { className: styles['modal'], children: [_jsxs("div", { className: styles['body'], children: [onClickGuide && _jsx("div", { className: styles['help-container'], children: _jsx(CustomIcon, { "aria-label": locale('guide'), color: getColor("primary", "500"), onClick: function onClick() {
|
|
38
|
+
return onClickGuide === null || onClickGuide === void 0 ? void 0 : onClickGuide(new MouseEvent('click'));
|
|
39
|
+
}, children: _jsx(AutoStoriesIcon, {}) }) }), _jsxs("div", { className: styles['header-icon'], children: [!!icon ? icon : DefaultIcon, _jsx("div", { className: styles['title'], children: title })] }), _jsxs("div", { className: styles['content'], children: [_jsxs("span", { children: [" ", description, " "] }), onChangeDontShowAgain && _jsx(CheckboxInput, { name: "dont-show-again", label: dontShowAgainLabel, onChange: onChangeDontShowAgain })] })] }), _jsx(ActionBar, { variant: "modal", cancelProps: { onCancel: onCancel, label: cancelLabel }, saveProps: { onSave: onSave, label: confirmLabel, variant: 'primary', size: 'md' } })] }) }));
|
|
40
|
+
};
|
|
41
|
+
export default WarningModal;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) {
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
5
|
+
}if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
6
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import styles from './actionBar.module.scss';
|
|
12
|
+
import { Button } from '../../button/button';
|
|
13
|
+
import locale from '../../../locales';
|
|
14
|
+
import clsx from 'clsx';
|
|
15
|
+
export var ActionBar = function ActionBar(_ref) {
|
|
16
|
+
var _ref$variant = _ref.variant,
|
|
17
|
+
variant = _ref$variant === undefined ? "page" : _ref$variant,
|
|
18
|
+
saveProps = _ref.saveProps,
|
|
19
|
+
cancelProps = _ref.cancelProps,
|
|
20
|
+
previousProps = _ref.previousProps;
|
|
21
|
+
|
|
22
|
+
var _ref2 = cancelProps || {},
|
|
23
|
+
onCancel = _ref2.onCancel,
|
|
24
|
+
_ref2$label = _ref2.label,
|
|
25
|
+
cancelText = _ref2$label === undefined ? locale('cancel') : _ref2$label;
|
|
26
|
+
|
|
27
|
+
var _a = previousProps || {},
|
|
28
|
+
onPrevious = _a.onPrevious,
|
|
29
|
+
_a$label = _a.label,
|
|
30
|
+
previousText = _a$label === undefined ? locale('previous') : _a$label,
|
|
31
|
+
previousOtherProps = __rest(_a, ["onPrevious", "label"]);var _b = saveProps || {},
|
|
32
|
+
onSave = _b.onSave,
|
|
33
|
+
_b$label = _b.label,
|
|
34
|
+
saveText = _b$label === undefined ? locale('save') : _b$label,
|
|
35
|
+
saveOtherProps = __rest(_b, ["onSave", "label"]);
|
|
36
|
+
return _jsxs("div", { className: clsx(styles['action-bar'], styles[variant]), children: [!!onCancel && _jsx(Button, { size: "md", variant: "link", label: cancelText, onClick: onCancel }), !!onPrevious && _jsx(Button, Object.assign({ outline: true, label: previousText, onClick: onPrevious }, previousOtherProps)), !!onSave && _jsx(Button, Object.assign({ label: saveText, onClick: onSave }, saveOtherProps))] });
|
|
37
|
+
};
|
|
38
|
+
export default ActionBar;
|