indicator-ui 0.0.205 → 0.0.207
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +128 -32
- package/dist/index.js.map +1 -1
- package/dist/types/src/ui/CascadeSelector/lib/getAllValues.d.ts +2 -0
- package/dist/types/src/ui/CascadeSelector/lib/index.d.ts +1 -0
- package/dist/types/src/ui/CascadeSelector/types/CascadeBlockTypes.d.ts +4 -2
- package/dist/types/src/ui/CascadeSelector/types/CascadeSelectorTypes.d.ts +8 -2
- package/dist/types/src/ui/CascadeSelector/ui/CascadeBlock.d.ts +1 -1
- package/dist/types/src/ui/CascadeSelector/ui/CascadeSelector.d.ts +1 -1
- package/dist/types/src/ui/Checkbox/types/CheckboxTypes.d.ts +4 -0
- package/dist/types/src/ui/Checkbox/ui/Checkbox.d.ts +1 -1
- package/dist/types/src/ui/CheckboxMark/types/CheckboxMarkTypes.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6723,6 +6723,52 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
6723
6723
|
|
|
6724
6724
|
|
|
6725
6725
|
|
|
6726
|
+
/***/ }),
|
|
6727
|
+
|
|
6728
|
+
/***/ "./src/ui/CascadeSelector/lib/getAllValues.ts":
|
|
6729
|
+
/*!****************************************************!*\
|
|
6730
|
+
!*** ./src/ui/CascadeSelector/lib/getAllValues.ts ***!
|
|
6731
|
+
\****************************************************/
|
|
6732
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
6733
|
+
|
|
6734
|
+
__webpack_require__.r(__webpack_exports__);
|
|
6735
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
6736
|
+
/* harmony export */ getAllValues: () => (/* binding */ getAllValues)
|
|
6737
|
+
/* harmony export */ });
|
|
6738
|
+
function getAllValues(options) {
|
|
6739
|
+
const res = [];
|
|
6740
|
+
const stack = [options];
|
|
6741
|
+
while (stack.length > 0) {
|
|
6742
|
+
const first = stack.pop();
|
|
6743
|
+
for (const option of first) {
|
|
6744
|
+
if ('value' in option) {
|
|
6745
|
+
res.push(option.value);
|
|
6746
|
+
}
|
|
6747
|
+
else if ('options' in option) {
|
|
6748
|
+
stack.push(option.options);
|
|
6749
|
+
}
|
|
6750
|
+
}
|
|
6751
|
+
}
|
|
6752
|
+
return res.reverse();
|
|
6753
|
+
}
|
|
6754
|
+
|
|
6755
|
+
|
|
6756
|
+
/***/ }),
|
|
6757
|
+
|
|
6758
|
+
/***/ "./src/ui/CascadeSelector/lib/index.ts":
|
|
6759
|
+
/*!*********************************************!*\
|
|
6760
|
+
!*** ./src/ui/CascadeSelector/lib/index.ts ***!
|
|
6761
|
+
\*********************************************/
|
|
6762
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
6763
|
+
|
|
6764
|
+
__webpack_require__.r(__webpack_exports__);
|
|
6765
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
6766
|
+
/* harmony export */ getAllValues: () => (/* reexport safe */ _getAllValues__WEBPACK_IMPORTED_MODULE_0__.getAllValues)
|
|
6767
|
+
/* harmony export */ });
|
|
6768
|
+
/* harmony import */ var _getAllValues__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./getAllValues */ "./src/ui/CascadeSelector/lib/getAllValues.ts");
|
|
6769
|
+
|
|
6770
|
+
|
|
6771
|
+
|
|
6726
6772
|
/***/ }),
|
|
6727
6773
|
|
|
6728
6774
|
/***/ "./src/ui/CascadeSelector/styles/index.ts":
|
|
@@ -6798,6 +6844,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
6798
6844
|
/* harmony import */ var _lib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/lib */ "./src/lib/index.ts");
|
|
6799
6845
|
/* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../styles */ "./src/ui/CascadeSelector/styles/index.ts");
|
|
6800
6846
|
/* harmony import */ var _assets__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/assets */ "./src/assets/index.ts");
|
|
6847
|
+
/* harmony import */ var _ui_CascadeSelector_lib__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/ui/CascadeSelector/lib */ "./src/ui/CascadeSelector/lib/index.ts");
|
|
6801
6848
|
|
|
6802
6849
|
|
|
6803
6850
|
|
|
@@ -6805,8 +6852,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
6805
6852
|
|
|
6806
6853
|
|
|
6807
6854
|
|
|
6808
|
-
|
|
6809
|
-
|
|
6855
|
+
|
|
6856
|
+
function CascadeBlock({ options, changeValue, addValues, removeValues, label, supportingText, noWrapper = false, defaultAllHidden = false, value }) {
|
|
6857
|
+
const [isOpen, setIsOpen] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(defaultAllHidden ? 'hide' : 'show');
|
|
6810
6858
|
const isActive = (keyValue) => {
|
|
6811
6859
|
return value.includes(keyValue);
|
|
6812
6860
|
};
|
|
@@ -6835,21 +6883,43 @@ function CascadeBlock({ options, onClick, label, supportingText, noWrapper = fal
|
|
|
6835
6883
|
}
|
|
6836
6884
|
return 'some';
|
|
6837
6885
|
};
|
|
6886
|
+
const cascadeState = getCountOfActiveCheckbox();
|
|
6838
6887
|
const getCascade = () => {
|
|
6839
6888
|
return options.map((item, idx) => {
|
|
6840
6889
|
if ('options' in item) {
|
|
6841
|
-
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(CascadeBlock, { value: value,
|
|
6890
|
+
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(CascadeBlock, { value: value, changeValue: changeValue, addValues: addValues, removeValues: removeValues, label: item.label, supportingText: item.supportingText, options: item.options }, idx);
|
|
6842
6891
|
}
|
|
6843
6892
|
else if ('value' in item) {
|
|
6844
|
-
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_ui__WEBPACK_IMPORTED_MODULE_3__.Checkbox, { text: item.label, supportingText: item.supportingText, width: 'hug', checked: isActive(item.value), onClick: () =>
|
|
6893
|
+
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_ui__WEBPACK_IMPORTED_MODULE_3__.Checkbox, { text: item.label, supportingText: item.supportingText, width: 'hug', checked: isActive(item.value), onClick: () => changeValue?.(item.value) }, idx);
|
|
6845
6894
|
}
|
|
6846
6895
|
});
|
|
6847
6896
|
};
|
|
6848
6897
|
if (noWrapper) {
|
|
6849
6898
|
return getCascade();
|
|
6850
6899
|
}
|
|
6851
|
-
const
|
|
6852
|
-
|
|
6900
|
+
const onCheckboxMarkClick = () => {
|
|
6901
|
+
const cascadeValues = (0,_ui_CascadeSelector_lib__WEBPACK_IMPORTED_MODULE_7__.getAllValues)(options);
|
|
6902
|
+
switch (cascadeState) {
|
|
6903
|
+
case 'empty':
|
|
6904
|
+
addValues?.(cascadeValues);
|
|
6905
|
+
break;
|
|
6906
|
+
case 'all':
|
|
6907
|
+
case 'some':
|
|
6908
|
+
removeValues?.(cascadeValues);
|
|
6909
|
+
break;
|
|
6910
|
+
}
|
|
6911
|
+
};
|
|
6912
|
+
const onClickCheckbox = () => {
|
|
6913
|
+
setIsOpen(prevState => {
|
|
6914
|
+
if (prevState === 'hide' || prevState === 'exit-up') {
|
|
6915
|
+
return 'enter-up';
|
|
6916
|
+
}
|
|
6917
|
+
else {
|
|
6918
|
+
return 'exit-up';
|
|
6919
|
+
}
|
|
6920
|
+
});
|
|
6921
|
+
};
|
|
6922
|
+
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { children: [(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_ui__WEBPACK_IMPORTED_MODULE_3__.Checkbox, { supportingText: supportingText, text: (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: (0,clsx__WEBPACK_IMPORTED_MODULE_2__["default"])(_styles__WEBPACK_IMPORTED_MODULE_5__.CascadeBlockStyle?.cascadeBlockLabel, { [_styles__WEBPACK_IMPORTED_MODULE_5__.CascadeBlockStyle?.open]: isOpen }), children: [(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span", { className: _styles__WEBPACK_IMPORTED_MODULE_5__.CascadeBlockStyle?.text, children: label }), (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_assets__WEBPACK_IMPORTED_MODULE_6__.ChevronDownSVG, {})] }), width: 'hug', checked: cascadeState === 'all', indeterminate: cascadeState === 'some', onCheckboxMarkClick: onCheckboxMarkClick, onClick: onClickCheckbox }), options.length > 0 && ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: _styles__WEBPACK_IMPORTED_MODULE_5__.CascadeBlockStyle?.cascadeBlock, children: (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_ui__WEBPACK_IMPORTED_MODULE_3__.SlideTransition, { animation: isOpen, className: _styles__WEBPACK_IMPORTED_MODULE_5__.CascadeBlockStyle.list, children: getCascade() }) }))] }));
|
|
6853
6923
|
}
|
|
6854
6924
|
|
|
6855
6925
|
|
|
@@ -6869,7 +6939,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
6869
6939
|
/* harmony import */ var _CascadeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CascadeBlock */ "./src/ui/CascadeSelector/ui/CascadeBlock.tsx");
|
|
6870
6940
|
|
|
6871
6941
|
|
|
6872
|
-
function CascadeSelector({ value, options, onChange, multiple = true, defaultAllHidden }) {
|
|
6942
|
+
function CascadeSelector({ value, options, onChange, multiple = true, defaultAllHidden, maxChosenOptions, }) {
|
|
6873
6943
|
const getValue = () => {
|
|
6874
6944
|
if (Array.isArray(value)) {
|
|
6875
6945
|
return [...value];
|
|
@@ -6879,22 +6949,41 @@ function CascadeSelector({ value, options, onChange, multiple = true, defaultAll
|
|
|
6879
6949
|
}
|
|
6880
6950
|
return [];
|
|
6881
6951
|
};
|
|
6882
|
-
const
|
|
6952
|
+
const handleChangeValue = (newValue) => {
|
|
6953
|
+
let res = newValue;
|
|
6954
|
+
if (maxChosenOptions) {
|
|
6955
|
+
res = newValue.slice(-maxChosenOptions);
|
|
6956
|
+
}
|
|
6957
|
+
else if (maxChosenOptions === 0) {
|
|
6958
|
+
res = [];
|
|
6959
|
+
}
|
|
6960
|
+
onChange?.(res);
|
|
6961
|
+
};
|
|
6962
|
+
const changeValue = (newValue) => {
|
|
6883
6963
|
const prevState = getValue();
|
|
6884
6964
|
const isInclude = prevState.includes(newValue);
|
|
6885
6965
|
if (isInclude) {
|
|
6886
|
-
|
|
6966
|
+
handleChangeValue(prevState.filter(item => item !== newValue));
|
|
6887
6967
|
}
|
|
6888
6968
|
else {
|
|
6889
6969
|
if (!multiple) {
|
|
6890
|
-
|
|
6970
|
+
handleChangeValue([newValue]);
|
|
6891
6971
|
}
|
|
6892
6972
|
else {
|
|
6893
|
-
|
|
6973
|
+
handleChangeValue([...prevState, newValue]);
|
|
6894
6974
|
}
|
|
6895
6975
|
}
|
|
6896
6976
|
};
|
|
6897
|
-
|
|
6977
|
+
const addValues = (newValues) => {
|
|
6978
|
+
const prevState = getValue();
|
|
6979
|
+
const filteredPrevState = prevState.filter(item => !newValues.includes(item));
|
|
6980
|
+
handleChangeValue([...filteredPrevState, ...newValues]);
|
|
6981
|
+
};
|
|
6982
|
+
const removeValues = (newValues) => {
|
|
6983
|
+
const prevState = getValue();
|
|
6984
|
+
handleChangeValue(prevState.filter(item => !newValues.includes(item)));
|
|
6985
|
+
};
|
|
6986
|
+
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_CascadeBlock__WEBPACK_IMPORTED_MODULE_1__.CascadeBlock, { options: options, noWrapper: true, changeValue: changeValue, addValues: addValues, removeValues: removeValues, defaultAllHidden: defaultAllHidden, value: getValue() });
|
|
6898
6987
|
}
|
|
6899
6988
|
|
|
6900
6989
|
|
|
@@ -7028,15 +7117,10 @@ const CheckboxMark = (0,react__WEBPACK_IMPORTED_MODULE_1__.forwardRef)(({ type =
|
|
|
7028
7117
|
}
|
|
7029
7118
|
return undefined;
|
|
7030
7119
|
};
|
|
7031
|
-
const handleOnClick = () => {
|
|
7032
|
-
if (onClick && !disabled) {
|
|
7033
|
-
onClick();
|
|
7034
|
-
}
|
|
7035
|
-
};
|
|
7036
7120
|
const wrapperComponent = isButton ? (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("button", {}) : (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span", {});
|
|
7037
7121
|
return react__WEBPACK_IMPORTED_MODULE_1___default().cloneElement(wrapperComponent, {
|
|
7038
7122
|
ref: ref,
|
|
7039
|
-
onClick:
|
|
7123
|
+
onClick: disabled ? undefined : onClick,
|
|
7040
7124
|
className: getClassName(),
|
|
7041
7125
|
children: getIcon(),
|
|
7042
7126
|
});
|
|
@@ -7141,7 +7225,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
7141
7225
|
|
|
7142
7226
|
|
|
7143
7227
|
|
|
7144
|
-
function Checkbox({ checked = false, type = 'checkbox', error = false, subtype = false, disabled = false, text, supportingText, indeterminate = false, onClick, width = 'fill', height = 'hug',
|
|
7228
|
+
function Checkbox({ checked = false, type = 'checkbox', error = false, subtype = false, disabled = false, text, supportingText, indeterminate = false, onClick, width = 'fill', height = 'hug', onCheckboxMarkClick, additionStyle, }) {
|
|
7145
7229
|
const [isHover, setIsHover] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
|
|
7146
7230
|
const [isFocused, setIsFocused] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
|
|
7147
7231
|
const clickHandler = () => {
|
|
@@ -7149,18 +7233,23 @@ function Checkbox({ checked = false, type = 'checkbox', error = false, subtype =
|
|
|
7149
7233
|
onClick();
|
|
7150
7234
|
setIsFocused(false);
|
|
7151
7235
|
};
|
|
7152
|
-
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("button", { onClick: clickHandler, onMouseEnter: () => setIsHover(true), onMouseLeave: () => setIsHover(false), onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), className: (0,clsx__WEBPACK_IMPORTED_MODULE_2__["default"])(
|
|
7153
|
-
[
|
|
7154
|
-
[
|
|
7155
|
-
[
|
|
7156
|
-
[
|
|
7157
|
-
[
|
|
7158
|
-
[
|
|
7159
|
-
}), children: [(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_ui__WEBPACK_IMPORTED_MODULE_3__.CheckboxMark, { type: type, indeterminate: indeterminate, disabled: disabled, error: error, checked: checked, isButton: false, hover: isHover || isFocused,
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
}
|
|
7236
|
+
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("button", { onClick: clickHandler, onMouseEnter: () => setIsHover(true), onMouseLeave: () => setIsHover(false), onFocus: () => setIsFocused(true), onBlur: () => setIsFocused(false), className: (0,clsx__WEBPACK_IMPORTED_MODULE_2__["default"])(_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.checkbox, {
|
|
7237
|
+
[_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.error]: error,
|
|
7238
|
+
[_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.disabled]: disabled,
|
|
7239
|
+
[_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.widthFill]: width === 'fill',
|
|
7240
|
+
[_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.widthHug]: width === 'hug',
|
|
7241
|
+
[_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.heightFill]: height === 'fill',
|
|
7242
|
+
[_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.heightHug]: height === 'hug',
|
|
7243
|
+
}, additionStyle), children: [(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_ui__WEBPACK_IMPORTED_MODULE_3__.CheckboxMark, { type: type, indeterminate: indeterminate, disabled: disabled, error: error, checked: checked, isButton: false, hover: isHover || isFocused, onClick: (e) => {
|
|
7244
|
+
if (onCheckboxMarkClick) {
|
|
7245
|
+
e.stopPropagation();
|
|
7246
|
+
onCheckboxMarkClick();
|
|
7247
|
+
}
|
|
7248
|
+
}, relation: subtype }), text &&
|
|
7249
|
+
(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: (0,clsx__WEBPACK_IMPORTED_MODULE_2__["default"])(_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.textBlock, {
|
|
7250
|
+
[_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.hover]: isHover,
|
|
7251
|
+
[_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.focus]: isFocused,
|
|
7252
|
+
}), children: [(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: (0,clsx__WEBPACK_IMPORTED_MODULE_2__["default"])(_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.text, { [_styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.textBold]: indeterminate || subtype }), children: text }), supportingText && (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: _styles__WEBPACK_IMPORTED_MODULE_4__.CheckboxStyle.supportingText, children: supportingText })] })] }));
|
|
7164
7253
|
}
|
|
7165
7254
|
|
|
7166
7255
|
|
|
@@ -8465,7 +8554,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
8465
8554
|
|
|
8466
8555
|
|
|
8467
8556
|
const getDate = (date) => {
|
|
8468
|
-
|
|
8557
|
+
let res;
|
|
8558
|
+
if (Array.isArray(date)) {
|
|
8559
|
+
res = date[0] || date[1];
|
|
8560
|
+
}
|
|
8561
|
+
else {
|
|
8562
|
+
res = date;
|
|
8563
|
+
}
|
|
8564
|
+
return res || new Date().toISOString();
|
|
8469
8565
|
};
|
|
8470
8566
|
function DatePicker({ date, onChangeDate, getInfo, isMark, isHoliday, onYearButtonClick, onMonthButtonClick, type = 'date', }) {
|
|
8471
8567
|
const [target, setTarget] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(getDate(date));
|