@producteca/producteca-ui-kit 1.21.1-beta.0 → 1.21.1-beta.1
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.d.ts +17 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +15 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/button/button.d.ts +17 -0
- package/dist/components/chip/chip.d.ts +13 -0
- package/dist/components/chip/index.d.ts +2 -0
- package/dist/components/icons/customIcon/customIcon.d.ts +16 -0
- package/dist/components/icons/fileIcon/fileIcon.d.ts +5 -0
- package/dist/components/icons/{index.js → index.d.ts} +1 -1
- package/dist/components/icons/mailIcon/mailIcon.d.ts +5 -0
- package/dist/components/icons/parameters.d.ts +51 -0
- package/dist/components/icons/priceCloseIcon/priceCloseIcon.d.ts +5 -0
- package/dist/components/icons/priceDownIcon/priceDownIcon.d.ts +5 -0
- package/dist/components/icons/searchPublication/searchPublication.d.ts +5 -0
- package/dist/components/image/image.d.ts +11 -0
- package/dist/components/image/index.d.ts +1 -0
- package/dist/components/{index.js → index.d.ts} +1 -1
- package/dist/components/inputs/checkboxInput/checkboxInput.d.ts +9 -0
- package/dist/components/inputs/checkboxInput/checkboxInputGroup.d.ts +22 -0
- package/dist/components/inputs/checkboxInput/{index.js → index.d.ts} +2 -1
- package/dist/components/inputs/datePicker/datePicker.d.ts +5 -0
- package/dist/components/inputs/datePicker/datePickerCustomStyles.d.ts +8 -0
- package/dist/components/inputs/datePicker/datePickerTypes.d.ts +14 -0
- package/dist/components/inputs/datePicker/datePickerUtils.d.ts +68 -0
- package/dist/components/inputs/datePicker/index.d.ts +3 -0
- package/dist/components/inputs/dateRangePicker/dateFormater.d.ts +7 -0
- package/dist/components/inputs/dateRangePicker/dateRangePicker.d.ts +5 -0
- package/dist/components/inputs/dateRangePicker/dateRangePickerTypes.d.ts +14 -0
- package/dist/components/inputs/dateRangePicker/dateRangePickerUtils.d.ts +9 -0
- package/dist/components/inputs/dateRangePicker/index.d.ts +4 -0
- package/dist/components/inputs/formField/formField.d.ts +10 -0
- package/dist/components/inputs/formField/passwordInput.d.ts +4 -0
- package/dist/components/inputs/formField/textInput.d.ts +25 -0
- package/dist/components/inputs/{index.js → index.d.ts} +1 -1
- package/dist/components/inputs/searcher/searcher.d.ts +28 -0
- package/dist/components/inputs/selectField/selectField.d.ts +42 -0
- package/dist/components/inputs/switchInput/index.d.ts +4 -0
- package/dist/components/inputs/switchInput/switchInput.d.ts +31 -0
- package/dist/components/loaders/index.d.ts +2 -0
- package/dist/components/loaders/progressbar/progressbar.d.ts +8 -0
- package/dist/components/loaders/spinner/spinner.d.ts +6 -0
- package/dist/components/menuAction/index.d.ts +1 -0
- package/dist/components/menuAction/menuAction.d.ts +18 -0
- package/dist/components/menuAction/menuActionCustomStyles.d.ts +4 -0
- package/dist/components/modals/index.d.ts +1 -0
- package/dist/components/modals/warningModal/index.d.ts +1 -0
- package/dist/components/modals/warningModal/warningModal.d.ts +17 -0
- package/dist/components/patterns/actionBar/actionBar.d.ts +26 -0
- package/dist/components/patterns/copyButton/copyButton.d.ts +11 -0
- package/dist/components/patterns/copyButton/index.d.ts +1 -0
- package/dist/components/patterns/emptyState/emptyState.d.ts +11 -0
- package/dist/components/patterns/headerSection/headerSection.d.ts +14 -0
- package/dist/components/patterns/headerSection/index.d.ts +1 -0
- package/dist/components/patterns/iconWithIdentifier/iconWithIdentifier.d.ts +11 -0
- package/dist/components/patterns/iconWithIdentifier/index.d.ts +1 -0
- package/dist/components/patterns/{index.js → index.d.ts} +1 -1
- package/dist/components/patterns/linkWithIcon/index.d.ts +1 -0
- package/dist/components/patterns/linkWithIcon/linkWithIcon.d.ts +14 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/tabs.d.ts +17 -0
- package/dist/components/tooltip/index.d.ts +3 -0
- package/dist/components/tooltip/overflowChecker.d.ts +5 -0
- package/dist/components/tooltip/tooltip.d.ts +20 -0
- package/dist/favicon.svg +43 -0
- package/dist/hooks/useReduxFormField.d.ts +26 -0
- package/dist/{index.js → index.d.ts} +1 -1
- package/dist/locales/description.d.ts +15 -0
- package/dist/locales/es.d.ts +227 -0
- package/dist/locales/index.d.ts +2 -0
- package/dist/locales/translator.d.ts +3 -0
- package/dist/producteca-ui-kit.cjs.js +508 -3
- package/dist/producteca-ui-kit.es.js +43799 -3
- package/dist/producteca-ui-kit.umd.js +508 -9
- package/dist/style.css +1 -0
- package/dist/styles/colors.d.ts +25 -0
- package/dist/styles/theme.d.ts +2 -0
- package/dist/validators/errorMessage.d.ts +5 -0
- package/dist/validators/index.d.ts +2 -0
- package/dist/validators/validation.d.ts +21 -0
- package/package.json +4 -4
- package/dist/components/alert/alert.js +0 -37
- package/dist/components/breadcrumb/breadcrumb.js +0 -33
- package/dist/components/breadcrumb/index.js +0 -2
- package/dist/components/button/button.js +0 -34
- package/dist/components/chip/chip.js +0 -27
- package/dist/components/chip/index.js +0 -1
- package/dist/components/icons/customIcon/customIcon.js +0 -41
- package/dist/components/icons/fileIcon/fileIcon.js +0 -14
- package/dist/components/icons/mailIcon/mailIcon.js +0 -14
- package/dist/components/icons/parameters.js +0 -26
- package/dist/components/icons/priceCloseIcon/priceCloseIcon.js +0 -14
- package/dist/components/icons/priceDownIcon/priceDownIcon.js +0 -14
- package/dist/components/icons/searchPublication/searchPublication.js +0 -14
- package/dist/components/image/image.js +0 -26
- package/dist/components/image/index.js +0 -1
- package/dist/components/inputs/checkboxInput/checkboxInput.js +0 -35
- package/dist/components/inputs/checkboxInput/checkboxInputGroup.js +0 -58
- package/dist/components/inputs/datePicker/datePicker.js +0 -143
- package/dist/components/inputs/datePicker/datePickerCustomStyles.js +0 -145
- package/dist/components/inputs/datePicker/datePickerTypes.js +0 -1
- package/dist/components/inputs/datePicker/datePickerUtils.js +0 -109
- package/dist/components/inputs/datePicker/index.js +0 -2
- package/dist/components/inputs/dateRangePicker/dateFormater.js +0 -28
- package/dist/components/inputs/dateRangePicker/dateRangePicker.js +0 -118
- package/dist/components/inputs/dateRangePicker/dateRangePickerTypes.js +0 -1
- package/dist/components/inputs/dateRangePicker/dateRangePickerUtils.js +0 -67
- package/dist/components/inputs/dateRangePicker/index.js +0 -2
- package/dist/components/inputs/formField/formField.js +0 -35
- package/dist/components/inputs/formField/passwordInput.js +0 -22
- package/dist/components/inputs/formField/textInput.js +0 -79
- package/dist/components/inputs/searcher/searcher.js +0 -112
- package/dist/components/inputs/selectField/selectField.js +0 -183
- package/dist/components/inputs/switchInput/index.js +0 -2
- package/dist/components/inputs/switchInput/switchInput.js +0 -77
- package/dist/components/loaders/index.js +0 -2
- package/dist/components/loaders/progressbar/progressbar.js +0 -37
- package/dist/components/loaders/spinner/spinner.js +0 -15
- package/dist/components/menuAction/index.js +0 -1
- package/dist/components/menuAction/menuAction.js +0 -67
- package/dist/components/menuAction/menuActionCustomStyles.js +0 -13
- package/dist/components/modals/index.js +0 -1
- package/dist/components/modals/warningModal/index.js +0 -1
- package/dist/components/modals/warningModal/warningModal.js +0 -41
- package/dist/components/patterns/actionBar/actionBar.js +0 -38
- package/dist/components/patterns/copyButton/copyButton.js +0 -69
- package/dist/components/patterns/copyButton/index.js +0 -1
- package/dist/components/patterns/emptyState/emptyState.js +0 -17
- package/dist/components/patterns/headerSection/headerSection.js +0 -17
- package/dist/components/patterns/headerSection/index.js +0 -1
- package/dist/components/patterns/iconWithIdentifier/iconWithIdentifier.js +0 -12
- package/dist/components/patterns/iconWithIdentifier/index.js +0 -1
- package/dist/components/patterns/linkWithIcon/index.js +0 -1
- package/dist/components/patterns/linkWithIcon/linkWithIcon.js +0 -26
- package/dist/components/tabs/index.js +0 -1
- package/dist/components/tabs/tabs.js +0 -70
- package/dist/components/tooltip/index.js +0 -2
- package/dist/components/tooltip/overflowChecker.js +0 -27
- package/dist/components/tooltip/tooltip.js +0 -97
- package/dist/hooks/useReduxFormField.js +0 -34
- package/dist/locales/description.js +0 -15
- package/dist/locales/es.js +0 -227
- package/dist/locales/index.js +0 -2
- package/dist/locales/translator.js +0 -20
- package/dist/styles/colors.js +0 -67
- package/dist/styles/styles/colors.tsx +0 -88
- package/dist/styles/styles/global.module.scss +0 -85
- package/dist/styles/styles/theme.tsx +0 -24
- package/dist/styles/styles/variables.module.scss +0 -74
- package/dist/styles/theme.js +0 -22
- package/dist/validators/errorMessage.js +0 -15
- package/dist/validators/index.js +0 -2
- package/dist/validators/validation.js +0 -25
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "babel-runtime/helpers/slicedToArray";
|
|
2
|
-
import _typeof from "babel-runtime/helpers/typeof";
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import dayjs from 'dayjs';
|
|
5
|
-
import head from "lodash/head";
|
|
6
|
-
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
7
|
-
import { formatDate } from "./dateFormater";
|
|
8
|
-
dayjs.extend(customParseFormat);
|
|
9
|
-
export var fromInputValue = function fromInputValue(inputValue) {
|
|
10
|
-
if (!inputValue) return undefined;
|
|
11
|
-
if ((typeof inputValue === "undefined" ? "undefined" : _typeof(inputValue)) === 'object' && 'from' in inputValue && 'to' in inputValue) {
|
|
12
|
-
var rangeValue = inputValue;
|
|
13
|
-
return {
|
|
14
|
-
from: convertToDate(rangeValue.from),
|
|
15
|
-
to: convertToDate(rangeValue.to)
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
if (typeof inputValue === 'string' && inputValue.includes(' - ')) {
|
|
19
|
-
var _inputValue$split = inputValue.split(' - '),
|
|
20
|
-
_inputValue$split2 = _slicedToArray(_inputValue$split, 2),
|
|
21
|
-
fromStr = _inputValue$split2[0],
|
|
22
|
-
toStr = _inputValue$split2[1];
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
from: convertToDate(fromStr.trim()),
|
|
26
|
-
to: convertToDate(toStr.trim())
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
};
|
|
31
|
-
export var getDisplayRange = function getDisplayRange(range) {
|
|
32
|
-
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'DD/MM/YYYY';
|
|
33
|
-
|
|
34
|
-
if (!(range === null || range === void 0 ? void 0 : range.from)) return '';
|
|
35
|
-
var fromFormatted = formatDate(range.from, format);
|
|
36
|
-
var toFormatted = range.to ? formatDate(range.to, format) : '';
|
|
37
|
-
if (range.from && range.to) {
|
|
38
|
-
return fromFormatted + " - " + toFormatted;
|
|
39
|
-
}
|
|
40
|
-
return fromFormatted;
|
|
41
|
-
};
|
|
42
|
-
export var convertToDate = function convertToDate(val) {
|
|
43
|
-
if (!val) return undefined;
|
|
44
|
-
if (val instanceof Date) {
|
|
45
|
-
return val;
|
|
46
|
-
}
|
|
47
|
-
if (typeof val === 'string') {
|
|
48
|
-
var parsed = dayjs(val);
|
|
49
|
-
return parsed.isValid() ? parsed.toDate() : undefined;
|
|
50
|
-
}
|
|
51
|
-
if (typeof val === 'number') {
|
|
52
|
-
return dayjs(val).toDate();
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
55
|
-
};
|
|
56
|
-
export var CustomWeekday = function CustomWeekday(props) {
|
|
57
|
-
return _jsx("th", Object.assign({}, props, { children: head(props.children) }));
|
|
58
|
-
};
|
|
59
|
-
export var getDisabledDays = function getDisabledDays(disabled, minDate, maxDate) {
|
|
60
|
-
if (disabled) return true;
|
|
61
|
-
var min = convertToDate(minDate);
|
|
62
|
-
var max = convertToDate(maxDate);
|
|
63
|
-
if (min && max) return [{ before: min }, { after: max }];
|
|
64
|
-
if (min) return { before: min };
|
|
65
|
-
if (max) return { after: max };
|
|
66
|
-
return undefined;
|
|
67
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
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 { TextInput } from './textInput';
|
|
12
|
-
import { PasswordInput } from './passwordInput';
|
|
13
|
-
import { DatePickerInput } from '../datePicker';
|
|
14
|
-
import { DateRangePickerInput } from '../dateRangePicker';
|
|
15
|
-
import styles from './textInput.module.scss';
|
|
16
|
-
var inputByType = function inputByType(type) {
|
|
17
|
-
var inputs = {
|
|
18
|
-
password: PasswordInput,
|
|
19
|
-
text: TextInput,
|
|
20
|
-
number: TextInput,
|
|
21
|
-
date: DatePickerInput,
|
|
22
|
-
dateRange: DateRangePickerInput
|
|
23
|
-
};
|
|
24
|
-
return !!type ? inputs[type] : TextInput;
|
|
25
|
-
};
|
|
26
|
-
export var FormField = function FormField(_a) {
|
|
27
|
-
var label = _a.label,
|
|
28
|
-
rightAdornment = _a.rightAdornment,
|
|
29
|
-
children = _a.children,
|
|
30
|
-
props = __rest(_a, ["label", "rightAdornment", "children"]);
|
|
31
|
-
|
|
32
|
-
var InputComponent = inputByType(props.type);
|
|
33
|
-
return _jsxs("div", { className: styles['form-field'], children: [label && _jsx("label", { htmlFor: props.name, children: label }), _jsxs("div", { className: "" + styles['input-container'], children: [_jsx(InputComponent, Object.assign({}, props, { children: children })), !!rightAdornment && _jsx("div", { className: "" + styles['right-modifier'], children: rightAdornment })] })] });
|
|
34
|
-
};
|
|
35
|
-
export default FormField;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from 'babel-runtime/helpers/slicedToArray';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
import { Visibility, VisibilityOff } from '@mui/icons-material';
|
|
5
|
-
import { TextInput } from './textInput';
|
|
6
|
-
export var PasswordInput = function PasswordInput(props) {
|
|
7
|
-
var _useState = useState(false),
|
|
8
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
9
|
-
showPassword = _useState2[0],
|
|
10
|
-
setShowPassword = _useState2[1];
|
|
11
|
-
|
|
12
|
-
var type = showPassword ? 'text' : 'password';
|
|
13
|
-
return _jsx(TextInput, Object.assign({}, props, { type: type, "data-testid": "password-input", rightIcon: _jsx(VisibilityIcon, { showPassword: showPassword, setShowPassword: setShowPassword }) }));
|
|
14
|
-
};
|
|
15
|
-
var VisibilityIcon = function VisibilityIcon(_ref) {
|
|
16
|
-
var showPassword = _ref.showPassword,
|
|
17
|
-
setShowPassword = _ref.setShowPassword;
|
|
18
|
-
|
|
19
|
-
return _jsx("div", { "data-testid": "visibility-toggle", onClick: function onClick() {
|
|
20
|
-
return setShowPassword(!showPassword);
|
|
21
|
-
}, children: showPassword ? _jsx(Visibility, {}) : _jsx(VisibilityOff, {}) });
|
|
22
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
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 { formValidation, ErrorMessage } from '../../../validators';
|
|
14
|
-
import styles from './textInput.module.scss';
|
|
15
|
-
import errorStyles from '../../../validators/errorMessage.module.scss';
|
|
16
|
-
import clsx from 'clsx';
|
|
17
|
-
import _ from 'lodash';
|
|
18
|
-
import { ClearRounded } from '@mui/icons-material';
|
|
19
|
-
import CustomIcon from '../../icons/customIcon/customIcon';
|
|
20
|
-
import { useReduxFormField } from '../../../hooks/useReduxFormField';
|
|
21
|
-
export var TextInput = function TextInput(props) {
|
|
22
|
-
var _a;
|
|
23
|
-
|
|
24
|
-
var isValid = props.isValid,
|
|
25
|
-
onChange = props.onChange,
|
|
26
|
-
meta = props.meta,
|
|
27
|
-
_props$value = props.value,
|
|
28
|
-
value = _props$value === undefined ? '' : _props$value,
|
|
29
|
-
_props$noErrors = props.noErrors,
|
|
30
|
-
noErrors = _props$noErrors === undefined ? false : _props$noErrors,
|
|
31
|
-
_props$size = props.size,
|
|
32
|
-
size = _props$size === undefined ? 'md' : _props$size,
|
|
33
|
-
_props$type = props.type,
|
|
34
|
-
type = _props$type === undefined ? 'text' : _props$type,
|
|
35
|
-
isClearable = props.isClearable,
|
|
36
|
-
max = props.max,
|
|
37
|
-
min = props.min,
|
|
38
|
-
leftIcon = props.leftIcon,
|
|
39
|
-
rightIcon = props.rightIcon,
|
|
40
|
-
input = props.input,
|
|
41
|
-
inputRef = props.inputRef,
|
|
42
|
-
otherProps = __rest(props, ["isValid", "onChange", "meta", "value", "noErrors", "size", "type", "isClearable", "max", "min", "leftIcon", "rightIcon", "input", "inputRef"]);
|
|
43
|
-
|
|
44
|
-
var inputValue = (_a = input === null || input === void 0 ? void 0 : input.value) !== null && _a !== void 0 ? _a : value;
|
|
45
|
-
|
|
46
|
-
var _useState = useState(''),
|
|
47
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
-
currentValue = _useState2[0],
|
|
49
|
-
setCurrentValue = _useState2[1];
|
|
50
|
-
|
|
51
|
-
var validationProps = { meta: meta, value: inputValue, isValid: isValid, required: props.required };
|
|
52
|
-
var validated = formValidation(validationProps);
|
|
53
|
-
var numericLimits = type === 'number' ? { max: max, min: min } : {};
|
|
54
|
-
useEffect(function () {
|
|
55
|
-
setCurrentValue(inputValue);
|
|
56
|
-
}, [inputValue]);
|
|
57
|
-
|
|
58
|
-
var _useReduxFormField = useReduxFormField({
|
|
59
|
-
input: input,
|
|
60
|
-
onChange: onChange,
|
|
61
|
-
transformValue: function transformValue(event) {
|
|
62
|
-
var value = event.target.value;
|
|
63
|
-
setCurrentValue(value);
|
|
64
|
-
return value;
|
|
65
|
-
}
|
|
66
|
-
}),
|
|
67
|
-
fieldHandleChange = _useReduxFormField.handleChange,
|
|
68
|
-
handleBlur = _useReduxFormField.handleBlur;
|
|
69
|
-
|
|
70
|
-
var handleChange = function handleChange(event) {
|
|
71
|
-
fieldHandleChange(event);
|
|
72
|
-
};
|
|
73
|
-
var rightModifier = isClearable && !rightIcon && currentValue ? _jsx(CustomIcon, { "data-testid": "clear-icon", children: _jsx(ClearRounded, {}) }) : rightIcon;
|
|
74
|
-
var onClickRightModifier = isClearable && !rightIcon ? function () {
|
|
75
|
-
return handleChange({ target: { name: props.name, value: '' } });
|
|
76
|
-
} : _.identity;
|
|
77
|
-
var isSmall = size == 'sm';
|
|
78
|
-
return _jsxs("div", { "data-testid": "text-input-container", className: clsx(styles[size], styles['text-input-container'], validated ? errorStyles[validated] : '', !!leftIcon && !isSmall ? styles['with-left-icon'] : '', !!rightModifier && !isSmall ? styles['with-right-icon'] : ''), children: [!!leftIcon && !isSmall && _jsx("div", { className: "" + styles['left-icon'], children: leftIcon }), _jsx("input", Object.assign({ className: "text-input", "data-testid": "text-input", value: currentValue ? String(currentValue) : '', type: type, onChange: handleChange, onBlur: handleBlur, ref: inputRef }, numericLimits, otherProps)), !!rightModifier && !isSmall && _jsx("div", { className: "" + styles['right-icon'], onClick: onClickRightModifier, children: rightModifier }), !noErrors && _jsx(ErrorMessage, { validationProps: validationProps })] });
|
|
79
|
-
};
|
|
@@ -1,112 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,183 +0,0 @@
|
|
|
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;
|
|
@@ -1,77 +0,0 @@
|
|
|
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;
|
|
@@ -1,37 +0,0 @@
|
|
|
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;
|
|
@@ -1,15 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MenuAction } from './menuAction';
|