@snack-uikit/fields 0.57.2-preview-02d918ac.0 → 0.57.2
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/CHANGELOG.md +16 -0
- package/dist/cjs/components/FieldColor/FieldColor.js +60 -49
- package/dist/cjs/components/FieldDate/FieldDate.js +68 -60
- package/dist/cjs/components/FieldDecorator/FieldDecorator.js +18 -18
- package/dist/cjs/components/FieldDecorator/Footer.js +6 -7
- package/dist/cjs/components/FieldDecorator/Header.js +10 -9
- package/dist/cjs/components/FieldDecorator/utils.js +14 -16
- package/dist/cjs/components/FieldSecure/FieldSecure.js +76 -58
- package/dist/cjs/components/FieldSelect/FieldSelectMultiple.js +112 -97
- package/dist/cjs/components/FieldSelect/FieldSelectSingle.js +115 -99
- package/dist/cjs/components/FieldSelect/hooks/common.js +43 -43
- package/dist/cjs/components/FieldSelect/hooks/customOption.js +12 -18
- package/dist/cjs/components/FieldSelect/legacy/components/Items/hooks.js +18 -21
- package/dist/cjs/components/FieldSelect/legacy/utils.js +18 -26
- package/dist/cjs/components/FieldSelect/utils/checkisSearchUnavailable.js +3 -5
- package/dist/cjs/components/FieldSelect/utils/extractListProps.js +13 -15
- package/dist/cjs/components/FieldSelect/utils/getArrowIcon.js +2 -4
- package/dist/cjs/components/FieldSelect/utils/options.js +17 -18
- package/dist/cjs/components/FieldSelect/utils/updateItems.js +6 -10
- package/dist/cjs/components/FieldSlider/FieldSlider.js +55 -46
- package/dist/cjs/components/FieldStepper/FieldStepper.js +60 -42
- package/dist/cjs/components/FieldText/FieldText.js +76 -58
- package/dist/cjs/components/FieldText/helpers.js +1 -3
- package/dist/cjs/components/FieldTextArea/FieldTextArea.js +64 -50
- package/dist/cjs/components/FieldTime/FieldTime.js +71 -64
- package/dist/cjs/helperComponents/ButtonCopyValue/ButtonCopyValue.js +17 -15
- package/dist/cjs/helperComponents/ButtonCopyValue/helpers.js +2 -4
- package/dist/cjs/helperComponents/ButtonField/ButtonField.js +21 -21
- package/dist/cjs/helperComponents/ButtonFieldList/ButtonFieldList.js +12 -9
- package/dist/cjs/helperComponents/ButtonFieldList/helpers.js +1 -3
- package/dist/cjs/helperComponents/ButtonHideValue/ButtonHideValue.js +7 -8
- package/dist/cjs/helperComponents/FieldContainerPrivate/FieldContainerPrivate.js +14 -16
- package/dist/cjs/helperComponents/TextArea/TextArea.js +29 -21
- package/dist/cjs/hocs/withCharacterCount.js +3 -5
- package/dist/cjs/hooks/addonButton/useAddonButton.js +11 -13
- package/dist/cjs/hooks/addonButton/usePostfixButton.js +1 -3
- package/dist/cjs/hooks/addonButton/usePrefixButton.js +1 -3
- package/dist/cjs/hooks/dateHandlers/useDateField.js +29 -33
- package/dist/cjs/hooks/dateHandlers/useDateFieldHelpersForMode.js +15 -21
- package/dist/cjs/hooks/dateHandlers/useFocusHandlers.js +2 -4
- package/dist/cjs/hooks/useCopyButton.js +12 -14
- package/dist/cjs/hooks/useHideButton.js +7 -11
- package/dist/cjs/hooks/usePostfix.js +3 -7
- package/dist/cjs/hooks/usePrefix.js +3 -7
- package/dist/cjs/hooks/useValueControl.js +3 -5
- package/dist/cjs/utils/dateFields.js +15 -2
- package/dist/cjs/utils/getValidationState.js +2 -4
- package/package.json +10 -10
|
@@ -7,10 +7,8 @@ exports.useFieldSelectMultipleCustomOption = useFieldSelectMultipleCustomOption;
|
|
|
7
7
|
exports.useFieldSelectSingleCustomOption = useFieldSelectSingleCustomOption;
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
function useResolvedAddCustomOptionTriggers(_ref) {
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
addOptionByEnter
|
|
13
|
-
} = _ref;
|
|
10
|
+
let addCustomOptionTriggers = _ref.addCustomOptionTriggers,
|
|
11
|
+
addOptionByEnter = _ref.addOptionByEnter;
|
|
14
12
|
return (0, react_1.useMemo)(() => {
|
|
15
13
|
if (addCustomOptionTriggers !== undefined) {
|
|
16
14
|
return addCustomOptionTriggers;
|
|
@@ -19,14 +17,12 @@ function useResolvedAddCustomOptionTriggers(_ref) {
|
|
|
19
17
|
}, [addCustomOptionTriggers, addOptionByEnter]);
|
|
20
18
|
}
|
|
21
19
|
function useFieldSelectMultipleCustomOption(_ref2) {
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
updateInputValue
|
|
29
|
-
} = _ref2;
|
|
20
|
+
let addCustomOptionTriggers = _ref2.addCustomOptionTriggers,
|
|
21
|
+
addOptionByEnter = _ref2.addOptionByEnter,
|
|
22
|
+
inputValue = _ref2.inputValue,
|
|
23
|
+
value = _ref2.value,
|
|
24
|
+
setValue = _ref2.setValue,
|
|
25
|
+
updateInputValue = _ref2.updateInputValue;
|
|
30
26
|
const resolvedAddCustomOptionTriggers = useResolvedAddCustomOptionTriggers({
|
|
31
27
|
addCustomOptionTriggers,
|
|
32
28
|
addOptionByEnter
|
|
@@ -46,12 +42,10 @@ function useFieldSelectMultipleCustomOption(_ref2) {
|
|
|
46
42
|
};
|
|
47
43
|
}
|
|
48
44
|
function useFieldSelectSingleCustomOption(_ref3) {
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
handleSelectionChange
|
|
54
|
-
} = _ref3;
|
|
45
|
+
let addCustomOptionTriggers = _ref3.addCustomOptionTriggers,
|
|
46
|
+
addOptionByEnter = _ref3.addOptionByEnter,
|
|
47
|
+
inputValue = _ref3.inputValue,
|
|
48
|
+
handleSelectionChange = _ref3.handleSelectionChange;
|
|
55
49
|
const resolvedAddCustomOptionTriggers = useResolvedAddCustomOptionTriggers({
|
|
56
50
|
addCustomOptionTriggers,
|
|
57
51
|
addOptionByEnter
|
|
@@ -8,27 +8,24 @@ const react_1 = require("react");
|
|
|
8
8
|
const list_1 = require("@snack-uikit/list");
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
function useLegacyGroupItemSelection(_ref) {
|
|
11
|
-
let
|
|
12
|
-
id = '',
|
|
13
|
-
items,
|
|
14
|
-
disabled
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
allChildIds
|
|
29
|
-
items
|
|
30
|
-
})
|
|
31
|
-
}), [items]);
|
|
11
|
+
let _ref$id = _ref.id,
|
|
12
|
+
id = _ref$id === void 0 ? '' : _ref$id,
|
|
13
|
+
items = _ref.items,
|
|
14
|
+
disabled = _ref.disabled;
|
|
15
|
+
const _ref2 = (0, list_1.useSelectionContext)(),
|
|
16
|
+
value = _ref2.value,
|
|
17
|
+
setValue = _ref2.setValue,
|
|
18
|
+
isSelectionMultiple = _ref2.isSelectionMultiple;
|
|
19
|
+
const _ref3 = (0, react_1.useMemo)(() => ({
|
|
20
|
+
childIds: (0, utils_1.extractChildIds)({
|
|
21
|
+
items
|
|
22
|
+
}),
|
|
23
|
+
allChildIds: (0, utils_1.extractAllChildIds)({
|
|
24
|
+
items
|
|
25
|
+
})
|
|
26
|
+
}), [items]),
|
|
27
|
+
childIds = _ref3.childIds,
|
|
28
|
+
allChildIds = _ref3.allChildIds;
|
|
32
29
|
const isIndeterminate = isSelectionMultiple ? allChildIds.some(childId => value === null || value === void 0 ? void 0 : value.includes(childId)) : allChildIds.includes(value !== null && value !== void 0 ? value : '');
|
|
33
30
|
const checked = isSelectionMultiple ? allChildIds.every(childId => value === null || value === void 0 ? void 0 : value.includes(childId)) : undefined;
|
|
34
31
|
(0, react_1.useEffect)(() => {
|
|
@@ -10,10 +10,8 @@ exports.extractAllChildIds = extractAllChildIds;
|
|
|
10
10
|
exports.flattenItems = flattenItems;
|
|
11
11
|
const list_1 = require("@snack-uikit/list");
|
|
12
12
|
function withCollapsedItems(_ref) {
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
openCollapsedItems
|
|
16
|
-
} = _ref;
|
|
13
|
+
let items = _ref.items,
|
|
14
|
+
openCollapsedItems = _ref.openCollapsedItems;
|
|
17
15
|
let itemRefs = [];
|
|
18
16
|
let newItems = [];
|
|
19
17
|
let ids = [];
|
|
@@ -31,26 +29,24 @@ function withCollapsedItems(_ref) {
|
|
|
31
29
|
expandedIds = expandedIds.concat(item.id);
|
|
32
30
|
}
|
|
33
31
|
if ((0, list_1.isGroupItemProps)(item)) {
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
32
|
+
const _withCollapsedItems = withCollapsedItems({
|
|
33
|
+
items: item.items,
|
|
34
|
+
openCollapsedItems
|
|
35
|
+
}),
|
|
36
|
+
nestedItemsRefs = _withCollapsedItems.itemRefs,
|
|
37
|
+
nestedIds = _withCollapsedItems.ids;
|
|
41
38
|
ids = ids.concat(nestedIds);
|
|
42
39
|
itemRefs = itemRefs.concat(nestedItemsRefs);
|
|
43
40
|
}
|
|
44
41
|
if ((0, list_1.isAccordionItemProps)(item) && item.id && openCollapsedItems.includes(item.id)) {
|
|
45
|
-
const {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
42
|
+
const _withCollapsedItems2 = withCollapsedItems({
|
|
43
|
+
items: item.items,
|
|
44
|
+
openCollapsedItems
|
|
45
|
+
}),
|
|
46
|
+
nestedItemsRefs = _withCollapsedItems2.itemRefs,
|
|
47
|
+
nestedIds = _withCollapsedItems2.ids,
|
|
48
|
+
nestedItems = _withCollapsedItems2.items,
|
|
49
|
+
nestedExpandedIds = _withCollapsedItems2.expandedIds;
|
|
54
50
|
ids = ids.concat(nestedIds);
|
|
55
51
|
newItems = newItems.concat(nestedItems);
|
|
56
52
|
itemRefs = itemRefs.concat(nestedItemsRefs);
|
|
@@ -77,9 +73,7 @@ function extractItemIds(items) {
|
|
|
77
73
|
}, []);
|
|
78
74
|
}
|
|
79
75
|
function extractChildIds(_ref2) {
|
|
80
|
-
let
|
|
81
|
-
items
|
|
82
|
-
} = _ref2;
|
|
76
|
+
let items = _ref2.items;
|
|
83
77
|
return items.filter(item => (0, list_1.isAccordionItemProps)(item) || (0, list_1.isNextListItemProps)(item) || (0, list_1.isGroupItemProps)(item) || (0, list_1.isBaseItemProps)(item) && !item.disabled && !item.inactive).reduce((prev, item) => {
|
|
84
78
|
var _a;
|
|
85
79
|
if ((0, list_1.isAccordionItemProps)(item) || (0, list_1.isNextListItemProps)(item)) {
|
|
@@ -96,9 +90,7 @@ function extractChildIds(_ref2) {
|
|
|
96
90
|
}, []);
|
|
97
91
|
}
|
|
98
92
|
function extractAllChildIds(_ref3) {
|
|
99
|
-
let
|
|
100
|
-
items
|
|
101
|
-
} = _ref3;
|
|
93
|
+
let items = _ref3.items;
|
|
102
94
|
return items.filter(item => (0, list_1.isAccordionItemProps)(item) || (0, list_1.isNextListItemProps)(item) || (0, list_1.isGroupItemProps)(item) || (0, list_1.isBaseItemProps)(item) && !item.inactive).reduce((prev, item) => {
|
|
103
95
|
var _a;
|
|
104
96
|
if ((0, list_1.isAccordionItemProps)(item) || (0, list_1.isNextListItemProps)(item)) {
|
|
@@ -5,10 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.checkisSearchUnavailable = checkisSearchUnavailable;
|
|
7
7
|
function checkisSearchUnavailable(_ref) {
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
isSameValue
|
|
12
|
-
} = _ref;
|
|
8
|
+
let autocomplete = _ref.autocomplete,
|
|
9
|
+
searchable = _ref.searchable,
|
|
10
|
+
isSameValue = _ref.isSameValue;
|
|
13
11
|
return autocomplete || !searchable || isSameValue;
|
|
14
12
|
}
|
|
@@ -5,21 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.extractListProps = extractListProps;
|
|
7
7
|
function extractListProps(_ref) {
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
onScroll
|
|
22
|
-
} = _ref;
|
|
8
|
+
let dataError = _ref.dataError,
|
|
9
|
+
noDataState = _ref.noDataState,
|
|
10
|
+
noResultsState = _ref.noResultsState,
|
|
11
|
+
errorDataState = _ref.errorDataState,
|
|
12
|
+
dataFiltered = _ref.dataFiltered,
|
|
13
|
+
loading = _ref.loading,
|
|
14
|
+
footer = _ref.footer,
|
|
15
|
+
widthStrategy = _ref.widthStrategy,
|
|
16
|
+
scrollToSelectedItem = _ref.scrollToSelectedItem,
|
|
17
|
+
virtualized = _ref.virtualized,
|
|
18
|
+
scrollRef = _ref.scrollRef,
|
|
19
|
+
scrollContainerRef = _ref.scrollContainerRef,
|
|
20
|
+
onScroll = _ref.onScroll;
|
|
23
21
|
return {
|
|
24
22
|
dataError,
|
|
25
23
|
noDataState,
|
|
@@ -7,10 +7,8 @@ exports.getArrowIcon = getArrowIcon;
|
|
|
7
7
|
const icons_1 = require("@snack-uikit/icons");
|
|
8
8
|
const input_private_1 = require("@snack-uikit/input-private");
|
|
9
9
|
function getArrowIcon(_ref) {
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
open
|
|
13
|
-
} = _ref;
|
|
10
|
+
let size = _ref.size,
|
|
11
|
+
open = _ref.open;
|
|
14
12
|
return {
|
|
15
13
|
ArrowIcon: open ? icons_1.ChevronUpSVG : icons_1.ChevronDownSVG,
|
|
16
14
|
arrowIconSize: size === input_private_1.SIZE.S ? input_private_1.ICON_SIZE.Xs : input_private_1.ICON_SIZE.S
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
6
|
var t = {};
|
|
5
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -19,13 +21,11 @@ const typeGuards_1 = require("./typeGuards");
|
|
|
19
21
|
function transformOptionsToItems(options) {
|
|
20
22
|
return options.map(option => {
|
|
21
23
|
if ((0, typeGuards_1.isAccordionOptionProps)(option) || (0, typeGuards_1.isNextListOptionProps)(option)) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
value
|
|
28
|
-
} = option,
|
|
24
|
+
const description = option.description,
|
|
25
|
+
contentOption = option.option,
|
|
26
|
+
caption = option.caption,
|
|
27
|
+
options = option.options,
|
|
28
|
+
value = option.value,
|
|
29
29
|
rest = __rest(option, ["description", "option", "caption", "options", "value"]);
|
|
30
30
|
return Object.assign(Object.assign({
|
|
31
31
|
'data-test-id': 'field-select__list-option-' + option.value
|
|
@@ -40,22 +40,18 @@ function transformOptionsToItems(options) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
if ((0, typeGuards_1.isGroupOptionProps)(option)) {
|
|
43
|
-
const
|
|
44
|
-
options
|
|
45
|
-
} = option,
|
|
43
|
+
const options = option.options,
|
|
46
44
|
rest = __rest(option, ["options"]);
|
|
47
45
|
return Object.assign(Object.assign({}, rest), {
|
|
48
46
|
items: transformOptionsToItems(options)
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
49
|
const _a = option,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
appearance
|
|
58
|
-
} = _a,
|
|
50
|
+
description = _a.description,
|
|
51
|
+
contentOption = _a.option,
|
|
52
|
+
caption = _a.caption,
|
|
53
|
+
value = _a.value,
|
|
54
|
+
appearance = _a.appearance,
|
|
59
55
|
rest = __rest(_a, ["description", "option", "caption", "value", "appearance"]);
|
|
60
56
|
return Object.assign(Object.assign({
|
|
61
57
|
'data-test-id': 'field-select__list-option-' + option.value
|
|
@@ -93,7 +89,10 @@ function findSelectedOptions(items, value) {
|
|
|
93
89
|
let placeholderItems;
|
|
94
90
|
value.forEach(value => {
|
|
95
91
|
if (flatten) {
|
|
96
|
-
const
|
|
92
|
+
const _findSelectedOption = findSelectedOption(flatten, value),
|
|
93
|
+
_findSelectedOption2 = (0, _slicedToArray2.default)(_findSelectedOption, 2),
|
|
94
|
+
found = _findSelectedOption2[0],
|
|
95
|
+
placeholder = _findSelectedOption2[1];
|
|
97
96
|
if (found || foundItems) {
|
|
98
97
|
foundItems = (foundItems !== null && foundItems !== void 0 ? foundItems : []).concat(found !== null && found !== void 0 ? found : []);
|
|
99
98
|
}
|
|
@@ -18,11 +18,9 @@ function createPlaceholderItem(value) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
function updateItems(_ref) {
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
selectedItem
|
|
25
|
-
} = _ref;
|
|
21
|
+
let options = _ref.options,
|
|
22
|
+
value = _ref.value,
|
|
23
|
+
selectedItem = _ref.selectedItem;
|
|
26
24
|
if (options.length < 1) {
|
|
27
25
|
return {
|
|
28
26
|
selectedItem: undefined,
|
|
@@ -55,11 +53,9 @@ function updateItems(_ref) {
|
|
|
55
53
|
};
|
|
56
54
|
}
|
|
57
55
|
function updateMultipleItems(_ref2) {
|
|
58
|
-
let
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
selectedItems
|
|
62
|
-
} = _ref2;
|
|
56
|
+
let options = _ref2.options,
|
|
57
|
+
value = _ref2.value,
|
|
58
|
+
selectedItems = _ref2.selectedItems;
|
|
63
59
|
if (options.length < 1) {
|
|
64
60
|
return {
|
|
65
61
|
selectedItems: undefined,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
6
|
var t = {};
|
|
5
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -39,44 +41,54 @@ const getDefaultValue = (range, min, max, value) => {
|
|
|
39
41
|
return value !== null && value !== void 0 ? value : min;
|
|
40
42
|
};
|
|
41
43
|
exports.FieldSlider = (0, react_1.forwardRef)((_a, ref) => {
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
44
|
+
var id = _a.id,
|
|
45
|
+
name = _a.name,
|
|
46
|
+
min = _a.min,
|
|
47
|
+
max = _a.max,
|
|
48
|
+
step = _a.step,
|
|
49
|
+
marks = _a.marks,
|
|
50
|
+
_a$showScaleBar = _a.showScaleBar,
|
|
51
|
+
showScaleBar = _a$showScaleBar === void 0 ? true : _a$showScaleBar,
|
|
52
|
+
valueProp = _a.value,
|
|
53
|
+
_a$range = _a.range,
|
|
54
|
+
range = _a$range === void 0 ? false : _a$range,
|
|
55
|
+
_a$disabled = _a.disabled,
|
|
56
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
57
|
+
_a$readonly = _a.readonly,
|
|
58
|
+
readonly = _a$readonly === void 0 ? false : _a$readonly,
|
|
59
|
+
onChangeProp = _a.onChange,
|
|
60
|
+
onFocus = _a.onFocus,
|
|
61
|
+
onBlur = _a.onBlur,
|
|
62
|
+
className = _a.className,
|
|
63
|
+
label = _a.label,
|
|
64
|
+
labelTooltip = _a.labelTooltip,
|
|
65
|
+
labelTooltipPlacement = _a.labelTooltipPlacement,
|
|
66
|
+
required = _a.required,
|
|
67
|
+
caption = _a.caption,
|
|
68
|
+
hint = _a.hint,
|
|
69
|
+
showHintIcon = _a.showHintIcon,
|
|
70
|
+
_a$size = _a.size,
|
|
71
|
+
size = _a$size === void 0 ? input_private_1.SIZE.S : _a$size,
|
|
72
|
+
textInputFormatter = _a.textInputFormatter,
|
|
73
|
+
unbindInputFromMarks = _a.unbindInputFromMarks,
|
|
74
|
+
postfixIcon = _a.postfixIcon,
|
|
75
|
+
prefix = _a.prefix,
|
|
76
|
+
postfix = _a.postfix,
|
|
77
|
+
autoFocus = _a.autoFocus,
|
|
73
78
|
rest = __rest(_a, ["id", "name", "min", "max", "step", "marks", "showScaleBar", "value", "range", "disabled", "readonly", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "textInputFormatter", "unbindInputFromMarks", "postfixIcon", "prefix", "postfix", "autoFocus"]);
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
const _ref = (0, hooks_1.useValueControl)({
|
|
80
|
+
value: valueProp,
|
|
81
|
+
defaultValue: getDefaultValue(range, min, max, valueProp),
|
|
82
|
+
onChange: onChangeProp
|
|
83
|
+
}),
|
|
84
|
+
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
85
|
+
_ref2$ = _ref2[0],
|
|
86
|
+
value = _ref2$ === void 0 ? getDefaultValue(range, min, max, valueProp) : _ref2$,
|
|
87
|
+
onChange = _ref2[1];
|
|
88
|
+
const _ref3 = (0, react_1.useState)((0, helpers_1.getTextFieldValue)(value, textInputFormatter)),
|
|
89
|
+
_ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
90
|
+
textFieldInputValue = _ref4[0],
|
|
91
|
+
setTextFieldInputValue = _ref4[1];
|
|
80
92
|
const localRef = (0, react_1.useRef)(null);
|
|
81
93
|
const prefixSettings = (0, hooks_1.usePrefix)({
|
|
82
94
|
prefix,
|
|
@@ -125,9 +137,8 @@ exports.FieldSlider = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
125
137
|
handleChange(max);
|
|
126
138
|
return;
|
|
127
139
|
}
|
|
128
|
-
const
|
|
129
|
-
mark
|
|
130
|
-
} = (0, helpers_1.getClosestMark)(textFieldNumValue, allowedValues, mark => mark.value);
|
|
140
|
+
const _ref5 = (0, helpers_1.getClosestMark)(textFieldNumValue, allowedValues, mark => mark.value),
|
|
141
|
+
mark = _ref5.mark;
|
|
131
142
|
handleChange(mark.key);
|
|
132
143
|
};
|
|
133
144
|
const handleEqualMarksSliderChange = textFieldNumValue => {
|
|
@@ -150,9 +161,8 @@ exports.FieldSlider = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
150
161
|
handleChange(textFieldNumValue);
|
|
151
162
|
return;
|
|
152
163
|
}
|
|
153
|
-
const
|
|
154
|
-
mark
|
|
155
|
-
} = (0, helpers_1.getClosestMark)(textFieldNumValue, allowedValues, mark => mark);
|
|
164
|
+
const _ref6 = (0, helpers_1.getClosestMark)(textFieldNumValue, allowedValues, mark => mark),
|
|
165
|
+
mark = _ref6.mark;
|
|
156
166
|
handleChange(mark);
|
|
157
167
|
return;
|
|
158
168
|
}
|
|
@@ -161,9 +171,8 @@ exports.FieldSlider = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
161
171
|
handleChange(textFieldNumValue);
|
|
162
172
|
return;
|
|
163
173
|
}
|
|
164
|
-
const
|
|
165
|
-
mark
|
|
166
|
-
} = (0, helpers_1.getClosestMark)(textFieldNumValue, allowedValues, mark => mark);
|
|
174
|
+
const _ref7 = (0, helpers_1.getClosestMark)(textFieldNumValue, allowedValues, mark => mark),
|
|
175
|
+
mark = _ref7.mark;
|
|
167
176
|
handleChange(mark);
|
|
168
177
|
};
|
|
169
178
|
const handleTextValueChange = (0, utils_1.useEventHandler)(() => {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
6
|
var t = {};
|
|
5
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -50,47 +52,63 @@ const SymbolWidth = {
|
|
|
50
52
|
l: 10
|
|
51
53
|
};
|
|
52
54
|
exports.FieldStepper = (0, react_1.forwardRef)((_a, ref) => {
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
55
|
+
var id = _a.id,
|
|
56
|
+
name = _a.name,
|
|
57
|
+
valueProp = _a.value,
|
|
58
|
+
_a$min = _a.min,
|
|
59
|
+
min = _a$min === void 0 ? Number.NEGATIVE_INFINITY : _a$min,
|
|
60
|
+
_a$max = _a.max,
|
|
61
|
+
max = _a$max === void 0 ? Number.POSITIVE_INFINITY : _a$max,
|
|
62
|
+
plusButtonTooltip = _a.plusButtonTooltip,
|
|
63
|
+
minusButtonTooltip = _a.minusButtonTooltip,
|
|
64
|
+
_a$step = _a.step,
|
|
65
|
+
step = _a$step === void 0 ? 1 : _a$step,
|
|
66
|
+
_a$disabled = _a.disabled,
|
|
67
|
+
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
68
|
+
_a$readonly = _a.readonly,
|
|
69
|
+
readonly = _a$readonly === void 0 ? false : _a$readonly,
|
|
70
|
+
_a$allowMoreThanLimit = _a.allowMoreThanLimits,
|
|
71
|
+
allowMoreThanLimits = _a$allowMoreThanLimit === void 0 ? true : _a$allowMoreThanLimit,
|
|
72
|
+
onChangeProp = _a.onChange,
|
|
73
|
+
onFocus = _a.onFocus,
|
|
74
|
+
onBlur = _a.onBlur,
|
|
75
|
+
className = _a.className,
|
|
76
|
+
label = _a.label,
|
|
77
|
+
labelTooltip = _a.labelTooltip,
|
|
78
|
+
labelTooltipPlacement = _a.labelTooltipPlacement,
|
|
79
|
+
_a$required = _a.required,
|
|
80
|
+
required = _a$required === void 0 ? false : _a$required,
|
|
81
|
+
caption = _a.caption,
|
|
82
|
+
hint = _a.hint,
|
|
83
|
+
showHintIcon = _a.showHintIcon,
|
|
84
|
+
_a$size = _a.size,
|
|
85
|
+
size = _a$size === void 0 ? input_private_1.SIZE.S : _a$size,
|
|
86
|
+
_a$validationState = _a.validationState,
|
|
87
|
+
validationState = _a$validationState === void 0 ? constants_1.VALIDATION_STATE.Default : _a$validationState,
|
|
88
|
+
error = _a.error,
|
|
89
|
+
prefix = _a.prefix,
|
|
90
|
+
postfix = _a.postfix,
|
|
91
|
+
autoFocus = _a.autoFocus,
|
|
83
92
|
rest = __rest(_a, ["id", "name", "value", "min", "max", "plusButtonTooltip", "minusButtonTooltip", "step", "disabled", "readonly", "allowMoreThanLimits", "onChange", "onFocus", "onBlur", "className", "label", "labelTooltip", "labelTooltipPlacement", "required", "caption", "hint", "showHintIcon", "size", "validationState", "error", "prefix", "postfix", "autoFocus"]);
|
|
84
|
-
const
|
|
85
|
-
t
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
const _ref = (0, locale_1.useLocale)('Fields'),
|
|
94
|
+
t = _ref.t;
|
|
95
|
+
const _ref2 = (0, hooks_1.useValueControl)({
|
|
96
|
+
value: valueProp,
|
|
97
|
+
defaultValue: getDefaultValue(min, max),
|
|
98
|
+
onChange: onChangeProp
|
|
99
|
+
}),
|
|
100
|
+
_ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
101
|
+
_ref3$ = _ref3[0],
|
|
102
|
+
value = _ref3$ === void 0 ? 0 : _ref3$,
|
|
103
|
+
setValue = _ref3[1];
|
|
104
|
+
const _ref4 = (0, react_1.useState)(false),
|
|
105
|
+
_ref5 = (0, _slicedToArray2.default)(_ref4, 2),
|
|
106
|
+
tooltipOpen = _ref5[0],
|
|
107
|
+
setTooltipOpen = _ref5[1];
|
|
108
|
+
const _ref6 = (0, react_1.useState)(''),
|
|
109
|
+
_ref7 = (0, _slicedToArray2.default)(_ref6, 2),
|
|
110
|
+
tooltip = _ref7[0],
|
|
111
|
+
setTooltip = _ref7[1];
|
|
94
112
|
const timerRef = (0, react_1.useRef)();
|
|
95
113
|
const inputRef = (0, react_1.useRef)(null);
|
|
96
114
|
const isMinusButtonDisabled = typeof min === 'number' && value <= min || readonly || disabled;
|
|
@@ -121,11 +139,11 @@ exports.FieldStepper = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
121
139
|
const handleInputBlur = event => {
|
|
122
140
|
if (!allowMoreThanLimits) {
|
|
123
141
|
if (max !== undefined && value > max) {
|
|
124
|
-
setTooltip(
|
|
142
|
+
setTooltip("".concat(t('limitTooltip.max')).concat(max));
|
|
125
143
|
adjustValue(max);
|
|
126
144
|
}
|
|
127
145
|
if (min !== undefined && value < min) {
|
|
128
|
-
setTooltip(
|
|
146
|
+
setTooltip("".concat(t('limitTooltip.min')).concat(min));
|
|
129
147
|
adjustValue(min);
|
|
130
148
|
}
|
|
131
149
|
}
|