@synerise/ds-factors 1.11.11 → 1.11.13
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 +8 -0
- package/dist/FactorTypeSelector/FactorTypeSelector.d.ts +2 -2
- package/dist/FactorTypeSelector/FactorTypeSelector.js +37 -58
- package/dist/FactorTypeSelector/FactorTypeSelector.styles.d.ts +18 -18
- package/dist/FactorTypeSelector/FactorTypeSelector.styles.js +10 -10
- package/dist/FactorValue/Array/Array.const.js +8 -3
- package/dist/FactorValue/Array/Array.d.ts +2 -2
- package/dist/FactorValue/Array/Array.js +45 -57
- package/dist/FactorValue/Array/Array.styles.d.ts +39 -39
- package/dist/FactorValue/Array/Array.styles.js +44 -33
- package/dist/FactorValue/Array/Array.types.d.ts +3 -3
- package/dist/FactorValue/Array/Array.types.js +1 -1
- package/dist/FactorValue/Array/Array.utils.d.ts +2 -2
- package/dist/FactorValue/Array/Array.utils.js +21 -18
- package/dist/FactorValue/Array/components/ArrayCollector.d.ts +2 -2
- package/dist/FactorValue/Array/components/ArrayCollector.js +70 -94
- package/dist/FactorValue/Array/components/ArrayCreator.d.ts +2 -2
- package/dist/FactorValue/Array/components/ArrayCreator.js +43 -75
- package/dist/FactorValue/Array/components/ArrayLimit.d.ts +2 -2
- package/dist/FactorValue/Array/components/ArrayLimit.js +16 -14
- package/dist/FactorValue/Array/components/ArrayModal.d.ts +2 -2
- package/dist/FactorValue/Array/components/ArrayModal.js +78 -143
- package/dist/FactorValue/Array/components/ArrayRaw.d.ts +2 -2
- package/dist/FactorValue/Array/components/ArrayRaw.js +47 -58
- package/dist/FactorValue/Array/components/CopyButton.d.ts +2 -2
- package/dist/FactorValue/Array/components/CopyButton.js +20 -30
- package/dist/FactorValue/Array/hooks/useCollector.d.ts +3 -3
- package/dist/FactorValue/Array/hooks/useCollector.js +21 -22
- package/dist/FactorValue/Date/Date.d.ts +2 -2
- package/dist/FactorValue/Date/Date.js +38 -53
- package/dist/FactorValue/DateRange/DateRange.d.ts +2 -2
- package/dist/FactorValue/DateRange/DateRange.js +26 -41
- package/dist/FactorValue/DynamicKey/DynamicKey.d.ts +2 -2
- package/dist/FactorValue/DynamicKey/DynamicKey.js +37 -66
- package/dist/FactorValue/DynamicKey/DynamicKey.style.d.ts +2 -2
- package/dist/FactorValue/DynamicKey/DynamicKey.style.js +10 -8
- package/dist/FactorValue/FactorValue.d.ts +2 -2
- package/dist/FactorValue/FactorValue.js +68 -70
- package/dist/FactorValue/FactorValue.style.d.ts +1 -1
- package/dist/FactorValue/FactorValue.style.js +20 -20
- package/dist/FactorValue/Formula/Formula.d.ts +2 -2
- package/dist/FactorValue/Formula/Formula.js +36 -54
- package/dist/FactorValue/Formula/Formula.styles.d.ts +1 -1
- package/dist/FactorValue/Formula/Formula.styles.js +6 -5
- package/dist/FactorValue/Formula/FormulaModal.d.ts +2 -2
- package/dist/FactorValue/Formula/FormulaModal.js +27 -42
- package/dist/FactorValue/Number/NumberInput.d.ts +2 -2
- package/dist/FactorValue/Number/NumberInput.js +21 -31
- package/dist/FactorValue/Parameter/Parameter.constants.d.ts +1 -1
- package/dist/FactorValue/Parameter/Parameter.constants.js +27 -13
- package/dist/FactorValue/Parameter/Parameter.d.ts +2 -2
- package/dist/FactorValue/Parameter/Parameter.js +82 -127
- package/dist/FactorValue/Parameter/Parameter.style.d.ts +28 -28
- package/dist/FactorValue/Parameter/Parameter.style.js +34 -31
- package/dist/FactorValue/Parameter/Parameter.types.d.ts +2 -2
- package/dist/FactorValue/Parameter/Parameter.types.js +1 -1
- package/dist/FactorValue/Parameter/ParameterDropdown.d.ts +2 -2
- package/dist/FactorValue/Parameter/ParameterDropdown.js +155 -226
- package/dist/FactorValue/Parameter/ParameterDropdownItem.d.ts +3 -3
- package/dist/FactorValue/Parameter/ParameterDropdownItem.js +27 -33
- package/dist/FactorValue/Parameter/useGroups.d.ts +2 -2
- package/dist/FactorValue/Parameter/useGroups.js +30 -42
- package/dist/FactorValue/Parameter/utils.d.ts +2 -2
- package/dist/FactorValue/Parameter/utils.js +22 -17
- package/dist/FactorValue/RelativeDate/RelativeDate.const.d.ts +1 -1
- package/dist/FactorValue/RelativeDate/RelativeDate.const.js +12 -5
- package/dist/FactorValue/RelativeDate/RelativeDate.d.ts +2 -2
- package/dist/FactorValue/RelativeDate/RelativeDate.js +57 -88
- package/dist/FactorValue/RelativeDate/RelativeDate.utils.d.ts +1 -1
- package/dist/FactorValue/RelativeDate/RelativeDate.utils.js +14 -10
- package/dist/FactorValue/RelativeDate/RelativeDateDropdown.d.ts +2 -2
- package/dist/FactorValue/RelativeDate/RelativeDateDropdown.js +56 -87
- package/dist/FactorValue/RelativeDate/RelativeDateDropdown.styles.d.ts +7 -7
- package/dist/FactorValue/RelativeDate/RelativeDateDropdown.styles.js +23 -20
- package/dist/FactorValue/Text/Text.d.ts +2 -2
- package/dist/FactorValue/Text/Text.js +56 -121
- package/dist/FactorValue/Text/Text.styles.d.ts +3 -3
- package/dist/FactorValue/Text/Text.styles.js +11 -10
- package/dist/FactorValue/Text/TextModal.d.ts +2 -2
- package/dist/FactorValue/Text/TextModal.js +19 -33
- package/dist/Factors.d.ts +2 -2
- package/dist/Factors.js +95 -132
- package/dist/Factors.types.d.ts +9 -9
- package/dist/Factors.types.js +8 -3
- package/dist/hooks/useTexts.d.ts +2 -2
- package/dist/hooks/useTexts.js +287 -291
- package/dist/index.js +7 -6
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/style/Factors.style.d.ts +1 -1
- package/dist/style/Factors.style.js +10 -11
- package/package.json +32 -32
|
@@ -1,158 +1,93 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
setSearchQuery = _useState3[1];
|
|
34
|
-
var _useState4 = useState(),
|
|
35
|
-
rawEditorError = _useState4[0],
|
|
36
|
-
setRawEditorError = _useState4[1];
|
|
37
|
-
var isMounted = useIsMounted();
|
|
38
|
-
useEffect(function () {
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useMemo, useCallback } from "react";
|
|
3
|
+
import { IconAlert } from "@synerise/ds-alert";
|
|
4
|
+
import Button, { ButtonToggle } from "@synerise/ds-button";
|
|
5
|
+
import ButtonGroup from "@synerise/ds-button-group";
|
|
6
|
+
import Icon, { TrashM, EditM, CodeM } from "@synerise/ds-icon";
|
|
7
|
+
import { SearchInput } from "@synerise/ds-search";
|
|
8
|
+
import { useIsMounted } from "@synerise/ds-utils";
|
|
9
|
+
import { MODAL_VIEWPORT_HEIGHT } from "../Array.const.js";
|
|
10
|
+
import { ModalFooterLeftSide, Modal, ModalSubHeader, LeftSide, RightSide, SearchWrapper } from "../Array.styles.js";
|
|
11
|
+
import { arrayWithUUID, sanitiseValues } from "../Array.utils.js";
|
|
12
|
+
import { ArrayCreator } from "./ArrayCreator.js";
|
|
13
|
+
import { ArrayLimit } from "./ArrayLimit.js";
|
|
14
|
+
import { ArrayRaw } from "./ArrayRaw.js";
|
|
15
|
+
import { CopyButton } from "./CopyButton.js";
|
|
16
|
+
const ArrayModal = ({
|
|
17
|
+
value,
|
|
18
|
+
itemType,
|
|
19
|
+
onApply,
|
|
20
|
+
onCancel,
|
|
21
|
+
visible,
|
|
22
|
+
readOnly,
|
|
23
|
+
texts,
|
|
24
|
+
limit,
|
|
25
|
+
collectorSuggestions
|
|
26
|
+
}) => {
|
|
27
|
+
const [arrayValue, setArrayValue] = useState(arrayWithUUID(value || []));
|
|
28
|
+
const [currentMode, setCurrentMode] = useState("creator");
|
|
29
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
30
|
+
const [rawEditorError, setRawEditorError] = useState();
|
|
31
|
+
const isMounted = useIsMounted();
|
|
32
|
+
useEffect(() => {
|
|
39
33
|
isMounted.current && setArrayValue(arrayWithUUID(value || []));
|
|
40
34
|
}, [value, isMounted]);
|
|
41
|
-
|
|
35
|
+
const handleRawEditorError = (errorMessage) => {
|
|
42
36
|
setRawEditorError(errorMessage);
|
|
43
37
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return typeof item.value === 'string' ? sanitiseValues(item.value) : item.value;
|
|
47
|
-
});
|
|
48
|
-
}, [arrayValue]);
|
|
49
|
-
var handleOk = useCallback(function () {
|
|
38
|
+
const plainArrayValue = useMemo(() => arrayValue.map((item) => typeof item.value === "string" ? sanitiseValues(item.value) : item.value), [arrayValue]);
|
|
39
|
+
const handleOk = useCallback(() => {
|
|
50
40
|
onApply(plainArrayValue);
|
|
51
|
-
setCurrentMode(
|
|
41
|
+
setCurrentMode("creator");
|
|
52
42
|
}, [onApply, plainArrayValue]);
|
|
53
|
-
|
|
43
|
+
const handleCancel = useCallback(() => {
|
|
54
44
|
onCancel();
|
|
55
45
|
setArrayValue(arrayWithUUID(value || []));
|
|
56
|
-
setCurrentMode(
|
|
46
|
+
setCurrentMode("creator");
|
|
57
47
|
}, [onCancel, value]);
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
const showClearButton = !!arrayValue?.length && !readOnly;
|
|
49
|
+
const handleClear = useCallback(() => {
|
|
60
50
|
setArrayValue([]);
|
|
61
51
|
}, []);
|
|
62
|
-
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
color: "red",
|
|
68
|
-
mode: "icon-label"
|
|
69
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
70
|
-
component: /*#__PURE__*/React.createElement(TrashM, null)
|
|
71
|
-
}), texts.array.clearButtonLabel));
|
|
52
|
+
const clearButton = useMemo(() => {
|
|
53
|
+
return /* @__PURE__ */ jsx(ModalFooterLeftSide, { children: showClearButton && /* @__PURE__ */ jsxs(Button, { onClick: handleClear, "data-testid": "array-modal-clear-button", type: "custom-color-ghost", color: "red", mode: "icon-label", children: [
|
|
54
|
+
/* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(TrashM, {}) }),
|
|
55
|
+
texts.array.clearButtonLabel
|
|
56
|
+
] }) });
|
|
72
57
|
}, [showClearButton, texts.array.clearButtonLabel, handleClear]);
|
|
73
|
-
|
|
74
|
-
setSearchQuery(query ||
|
|
58
|
+
const handleSearchQueryChange = (query) => {
|
|
59
|
+
setSearchQuery(query || "");
|
|
75
60
|
};
|
|
76
|
-
|
|
61
|
+
const handleValueChange = useCallback((updatedArray) => {
|
|
77
62
|
setArrayValue(updatedArray);
|
|
78
|
-
setSearchQuery(
|
|
63
|
+
setSearchQuery("");
|
|
79
64
|
}, []);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return setCurrentMode('creator');
|
|
110
|
-
}
|
|
111
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
112
|
-
component: /*#__PURE__*/React.createElement(EditM, null)
|
|
113
|
-
}), " ", texts.array.creatorButtonLabel), /*#__PURE__*/React.createElement(ButtonToggle, {
|
|
114
|
-
mode: "icon-label",
|
|
115
|
-
activated: currentMode === 'raw',
|
|
116
|
-
type: "ghost",
|
|
117
|
-
onClick: function onClick() {
|
|
118
|
-
return setCurrentMode('raw');
|
|
119
|
-
}
|
|
120
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
121
|
-
component: /*#__PURE__*/React.createElement(CodeM, null)
|
|
122
|
-
}), " ", texts.array.rawButtonLabel))), /*#__PURE__*/React.createElement(S.RightSide, null, rawEditorError ? /*#__PURE__*/React.createElement(IconAlert, {
|
|
123
|
-
iconAlert: true,
|
|
124
|
-
type: "alert",
|
|
125
|
-
message: rawEditorError
|
|
126
|
-
}) : /*#__PURE__*/React.createElement(React.Fragment, null, limit && /*#__PURE__*/React.createElement(ArrayLimit, {
|
|
127
|
-
limit: limit,
|
|
128
|
-
count: arrayValue.length,
|
|
129
|
-
texts: texts
|
|
130
|
-
})), /*#__PURE__*/React.createElement(CopyButton, {
|
|
131
|
-
texts: texts,
|
|
132
|
-
copyValue: (plainArrayValue == null ? void 0 : plainArrayValue.join(',')) || ''
|
|
133
|
-
}), /*#__PURE__*/React.createElement(S.SearchWrapper, null, /*#__PURE__*/React.createElement(SearchInput, {
|
|
134
|
-
disabled: currentMode === 'raw',
|
|
135
|
-
closeOnClickOutside: true,
|
|
136
|
-
value: searchQuery,
|
|
137
|
-
onChange: handleSearchQueryChange,
|
|
138
|
-
onClear: handleSearchQueryChange,
|
|
139
|
-
placeholder: texts.array.searchPlaceholder,
|
|
140
|
-
clearTooltip: texts.array.searchClearTooltip
|
|
141
|
-
})))),
|
|
142
|
-
closable: true,
|
|
143
|
-
onOk: !rawEditorError ? handleOk : undefined,
|
|
144
|
-
onCancel: handleCancel,
|
|
145
|
-
open: visible,
|
|
146
|
-
texts: {
|
|
147
|
-
okButton: texts.modalApply,
|
|
148
|
-
cancelButton: texts.modalCancel
|
|
149
|
-
},
|
|
150
|
-
bodyStyle: {
|
|
151
|
-
padding: 0
|
|
152
|
-
},
|
|
153
|
-
footer: readOnly ? null : undefined,
|
|
154
|
-
prefix: clearButton,
|
|
155
|
-
viewportHeight: MODAL_VIEWPORT_HEIGHT,
|
|
156
|
-
maxViewportHeight: currentMode === 'creator' ? MODAL_VIEWPORT_HEIGHT : undefined
|
|
157
|
-
}, /*#__PURE__*/React.createElement(React.Fragment, null, mainModalContent));
|
|
158
|
-
};
|
|
65
|
+
const mainModalContent = currentMode === "creator" ? /* @__PURE__ */ jsx(ArrayCreator, { texts, readOnly, itemType, value: arrayValue, limit, searchQuery, onValueChange: handleValueChange, collectorSuggestions }) : /* @__PURE__ */ jsx(ArrayRaw, { readOnly, onError: handleRawEditorError, itemType, limit, onValueChange: handleValueChange, texts, value: arrayValue });
|
|
66
|
+
return /* @__PURE__ */ jsx(Modal, { size: "medium", title: texts.array.modalTitle, headerBottomBar: /* @__PURE__ */ jsxs(ModalSubHeader, { children: [
|
|
67
|
+
/* @__PURE__ */ jsx(LeftSide, { children: /* @__PURE__ */ jsxs(ButtonGroup, { compact: false, children: [
|
|
68
|
+
/* @__PURE__ */ jsxs(ButtonToggle, { disabled: !!rawEditorError, mode: "icon-label", type: "ghost", activated: currentMode === "creator", onClick: () => setCurrentMode("creator"), children: [
|
|
69
|
+
/* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(EditM, {}) }),
|
|
70
|
+
" ",
|
|
71
|
+
texts.array.creatorButtonLabel
|
|
72
|
+
] }),
|
|
73
|
+
/* @__PURE__ */ jsxs(ButtonToggle, { mode: "icon-label", activated: currentMode === "raw", type: "ghost", onClick: () => setCurrentMode("raw"), children: [
|
|
74
|
+
/* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CodeM, {}) }),
|
|
75
|
+
" ",
|
|
76
|
+
texts.array.rawButtonLabel
|
|
77
|
+
] })
|
|
78
|
+
] }) }),
|
|
79
|
+
/* @__PURE__ */ jsxs(RightSide, { children: [
|
|
80
|
+
rawEditorError ? /* @__PURE__ */ jsx(IconAlert, { iconAlert: true, type: "alert", message: rawEditorError }) : /* @__PURE__ */ jsx(Fragment, { children: limit && /* @__PURE__ */ jsx(ArrayLimit, { limit, count: arrayValue.length, texts }) }),
|
|
81
|
+
/* @__PURE__ */ jsx(CopyButton, { texts, copyValue: plainArrayValue?.join(",") || "" }),
|
|
82
|
+
/* @__PURE__ */ jsx(SearchWrapper, { children: /* @__PURE__ */ jsx(SearchInput, { disabled: currentMode === "raw", closeOnClickOutside: true, value: searchQuery, onChange: handleSearchQueryChange, onClear: handleSearchQueryChange, placeholder: texts.array.searchPlaceholder, clearTooltip: texts.array.searchClearTooltip }) })
|
|
83
|
+
] })
|
|
84
|
+
] }), closable: true, onOk: !rawEditorError ? handleOk : void 0, onCancel: handleCancel, open: visible, texts: {
|
|
85
|
+
okButton: texts.modalApply,
|
|
86
|
+
cancelButton: texts.modalCancel
|
|
87
|
+
}, bodyStyle: {
|
|
88
|
+
padding: 0
|
|
89
|
+
}, footer: readOnly ? null : void 0, prefix: clearButton, viewportHeight: MODAL_VIEWPORT_HEIGHT, maxViewportHeight: currentMode === "creator" ? MODAL_VIEWPORT_HEIGHT : void 0, children: /* @__PURE__ */ jsx(Fragment, { children: mainModalContent }) });
|
|
90
|
+
};
|
|
91
|
+
export {
|
|
92
|
+
ArrayModal
|
|
93
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ArrayRawProps } from '../Array.types';
|
|
3
3
|
export declare const ArrayRaw: <ItemType extends "string" | "number">({ value, itemType, onValueChange, readOnly, texts, limit, onError, }: ArrayRawProps<ItemType>) => React.JSX.Element;
|
|
@@ -1,58 +1,56 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return itemType ===
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useMemo, useState, useEffect } from "react";
|
|
3
|
+
import { useDelimiterEscape } from "@synerise/ds-utils";
|
|
4
|
+
import { COMMA, BACKTICK } from "../Array.const.js";
|
|
5
|
+
import { TextArea } from "../Array.styles.js";
|
|
6
|
+
import { sanitiseValues, isArrayOfNumbersAsString, arrayWithUUID } from "../Array.utils.js";
|
|
7
|
+
const ArrayRaw = ({
|
|
8
|
+
value = [],
|
|
9
|
+
itemType,
|
|
10
|
+
onValueChange,
|
|
11
|
+
readOnly,
|
|
12
|
+
texts,
|
|
13
|
+
limit,
|
|
14
|
+
onError
|
|
15
|
+
}) => {
|
|
16
|
+
const {
|
|
17
|
+
isValidEscapedString,
|
|
18
|
+
joinWithEscape,
|
|
19
|
+
splitWithEscape
|
|
20
|
+
} = useDelimiterEscape({
|
|
21
|
+
openTag: BACKTICK,
|
|
22
|
+
closeTag: BACKTICK,
|
|
23
|
+
delimiter: COMMA
|
|
24
|
+
});
|
|
25
|
+
const ref = useRef(null);
|
|
26
|
+
const plainValues = useMemo(() => {
|
|
27
|
+
const items = value.map((item) => item.value);
|
|
28
|
+
return itemType === "string" ? joinWithEscape(items) : items.join(",");
|
|
29
29
|
}, [itemType, joinWithEscape, value]);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
setTextareaValue = _useState[1];
|
|
33
|
-
useEffect(function () {
|
|
30
|
+
const [textareaValue, setTextareaValue] = useState(plainValues || "");
|
|
31
|
+
useEffect(() => {
|
|
34
32
|
if (document.activeElement !== ref.current) {
|
|
35
|
-
setTextareaValue(plainValues ||
|
|
33
|
+
setTextareaValue(plainValues || "");
|
|
36
34
|
}
|
|
37
35
|
}, [plainValues]);
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const handleChange = (event) => {
|
|
37
|
+
const stringifiedValue = event.target.value;
|
|
40
38
|
setTextareaValue(stringifiedValue);
|
|
41
39
|
if (!stringifiedValue) {
|
|
42
40
|
onError(null);
|
|
43
41
|
onValueChange([]);
|
|
44
42
|
return;
|
|
45
43
|
}
|
|
46
|
-
if (itemType ===
|
|
44
|
+
if (itemType === "string" && !isValidEscapedString(stringifiedValue)) {
|
|
47
45
|
onError(texts.array.stringUnclosedBacktickError);
|
|
48
46
|
return;
|
|
49
47
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (itemType ===
|
|
48
|
+
const items = (itemType === "string" ? splitWithEscape(stringifiedValue) : stringifiedValue?.split(",")) || [];
|
|
49
|
+
const sanitisedItems = items.map(sanitiseValues);
|
|
50
|
+
const lastItemIsDelimiter = sanitisedItems.at(sanitisedItems.length - 1) === "";
|
|
51
|
+
const itemsToValidate = lastItemIsDelimiter ? [...sanitisedItems.slice(0, -1)] : sanitisedItems;
|
|
52
|
+
const exceedsLimit = limit && items.length > limit;
|
|
53
|
+
if (itemType === "number" && !isArrayOfNumbersAsString(itemsToValidate)) {
|
|
56
54
|
onError(texts.array.numericValidationError);
|
|
57
55
|
return;
|
|
58
56
|
}
|
|
@@ -61,23 +59,14 @@ export var ArrayRaw = function ArrayRaw(_ref) {
|
|
|
61
59
|
return;
|
|
62
60
|
}
|
|
63
61
|
onError(null);
|
|
64
|
-
if (itemType ===
|
|
62
|
+
if (itemType === "string") {
|
|
65
63
|
onValueChange(arrayWithUUID(itemsToValidate));
|
|
66
64
|
} else {
|
|
67
|
-
onValueChange(arrayWithUUID(itemsToValidate.map(
|
|
68
|
-
return parseFloat(item);
|
|
69
|
-
})));
|
|
65
|
+
onValueChange(arrayWithUUID(itemsToValidate.map((item) => parseFloat(item))));
|
|
70
66
|
}
|
|
71
67
|
};
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
autoCapitalize: "off",
|
|
78
|
-
autoCorrect: "off",
|
|
79
|
-
autoComplete: "off",
|
|
80
|
-
onChange: !readOnly ? handleChange : undefined,
|
|
81
|
-
value: textareaValue
|
|
82
|
-
});
|
|
83
|
-
};
|
|
68
|
+
return /* @__PURE__ */ jsx(TextArea, { ref, "data-testid": "array-raw-textarea", readOnly, spellCheck: "false", autoCapitalize: "off", autoCorrect: "off", autoComplete: "off", onChange: !readOnly ? handleChange : void 0, value: textareaValue });
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
ArrayRaw
|
|
72
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CopyButtonProps } from '../Array.types';
|
|
3
3
|
export declare const CopyButton: ({ copyValue, texts }: CopyButtonProps) => React.JSX.Element;
|
|
@@ -1,42 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
setTooltipTitle = _useState2[1];
|
|
15
|
-
var handleCopy = useCallback(function () {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import copy from "copy-to-clipboard";
|
|
3
|
+
import { useState, useCallback } from "react";
|
|
4
|
+
import Button from "@synerise/ds-button";
|
|
5
|
+
import Icon, { CopyClipboardM } from "@synerise/ds-icon";
|
|
6
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
7
|
+
const CopyButton = ({
|
|
8
|
+
copyValue,
|
|
9
|
+
texts
|
|
10
|
+
}) => {
|
|
11
|
+
const [tooltipOpen, setTooltipOpen] = useState(false);
|
|
12
|
+
const [tooltipTitle, setTooltipTitle] = useState(texts.array.copyTooltip);
|
|
13
|
+
const handleCopy = useCallback(() => {
|
|
16
14
|
if (copyValue && copy(copyValue)) {
|
|
17
15
|
setTooltipTitle(texts.array.copiedTooltip);
|
|
18
16
|
setTooltipOpen(true);
|
|
19
17
|
}
|
|
20
18
|
}, [copyValue, setTooltipTitle, texts.array.copiedTooltip]);
|
|
21
|
-
|
|
19
|
+
const handleMouseEnter = useCallback((event) => {
|
|
22
20
|
event.stopPropagation();
|
|
23
21
|
setTooltipTitle(texts.array.copyTooltip);
|
|
24
22
|
setTooltipOpen(true);
|
|
25
23
|
}, [setTooltipOpen, texts.array]);
|
|
26
|
-
|
|
24
|
+
const handleMouseLeave = useCallback((event) => {
|
|
27
25
|
event.stopPropagation();
|
|
28
26
|
setTooltipOpen(false);
|
|
29
27
|
}, [setTooltipOpen]);
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type: "ghost",
|
|
36
|
-
mode: "single-icon",
|
|
37
|
-
onMouseEnter: handleMouseEnter,
|
|
38
|
-
onMouseLeave: handleMouseLeave
|
|
39
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
40
|
-
component: /*#__PURE__*/React.createElement(CopyClipboardM, null)
|
|
41
|
-
})));
|
|
42
|
-
};
|
|
28
|
+
return /* @__PURE__ */ jsx(Tooltip, { title: tooltipTitle, open: tooltipOpen, children: /* @__PURE__ */ jsx(Button, { onClick: handleCopy, type: "ghost", mode: "single-icon", onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CopyClipboardM, {}) }) }) });
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
CopyButton
|
|
32
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FactorsTexts } from '../../../Factors.types';
|
|
2
2
|
type UseCollectorProps = {
|
|
3
3
|
limit?: number;
|
|
4
4
|
collectorCount: number;
|
|
@@ -8,8 +8,8 @@ type UseCollectorProps = {
|
|
|
8
8
|
export declare const useCollector: ({ limit, collectorCount, arrayValueCount, texts, }: UseCollectorProps) => {
|
|
9
9
|
disabled: boolean;
|
|
10
10
|
error: boolean;
|
|
11
|
-
errorMessage: import(
|
|
12
|
-
setHasTypeError: import(
|
|
11
|
+
errorMessage: import('react').ReactNode;
|
|
12
|
+
setHasTypeError: import('react').Dispatch<import('react').SetStateAction<boolean>>;
|
|
13
13
|
exceedsLimit: (newItems: number) => boolean;
|
|
14
14
|
addEnabled: boolean;
|
|
15
15
|
};
|
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
import { useCallback, useMemo
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
setHasTypeError = _useState[1];
|
|
11
|
-
var exceedsLimit = useCallback(function (newItems) {
|
|
1
|
+
import { useState, useCallback, useMemo } from "react";
|
|
2
|
+
const useCollector = ({
|
|
3
|
+
limit,
|
|
4
|
+
collectorCount,
|
|
5
|
+
arrayValueCount = 0,
|
|
6
|
+
texts
|
|
7
|
+
}) => {
|
|
8
|
+
const [hasTypeError, setHasTypeError] = useState(false);
|
|
9
|
+
const exceedsLimit = useCallback((newItems) => {
|
|
12
10
|
if (limit) {
|
|
13
11
|
return newItems + arrayValueCount > limit;
|
|
14
12
|
}
|
|
15
13
|
return false;
|
|
16
14
|
}, [arrayValueCount, limit]);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}, [exceedsLimit, collectorCount]);
|
|
20
|
-
var errorMessage = useMemo(function () {
|
|
15
|
+
const collectorExceedsLimit = useMemo(() => exceedsLimit(collectorCount), [exceedsLimit, collectorCount]);
|
|
16
|
+
const errorMessage = useMemo(() => {
|
|
21
17
|
if (hasTypeError) {
|
|
22
18
|
return texts.array.numericValidationError;
|
|
23
19
|
}
|
|
24
20
|
if (collectorExceedsLimit) {
|
|
25
21
|
return texts.array.limitExceeded;
|
|
26
22
|
}
|
|
27
|
-
return
|
|
23
|
+
return void 0;
|
|
28
24
|
}, [hasTypeError, collectorExceedsLimit, texts.array.limitExceeded, texts.array.numericValidationError]);
|
|
29
|
-
|
|
25
|
+
const addEnabled = useMemo(() => {
|
|
30
26
|
return !hasTypeError && !collectorExceedsLimit;
|
|
31
27
|
}, [hasTypeError, collectorExceedsLimit]);
|
|
32
28
|
return {
|
|
33
29
|
disabled: !!(limit && arrayValueCount >= limit),
|
|
34
30
|
error: !!errorMessage,
|
|
35
|
-
errorMessage
|
|
36
|
-
setHasTypeError
|
|
37
|
-
exceedsLimit
|
|
38
|
-
addEnabled
|
|
31
|
+
errorMessage,
|
|
32
|
+
setHasTypeError,
|
|
33
|
+
exceedsLimit,
|
|
34
|
+
addEnabled
|
|
39
35
|
};
|
|
40
|
-
};
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
useCollector
|
|
39
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FactorValueComponentProps } from '../../Factors.types';
|
|
3
3
|
declare const DateInput: ({ value, onChange, texts, opened, onDeactivate, onActivate, error, allowClear, readOnly, getPopupContainerOverride, uncontrolledComponent, }: FactorValueComponentProps) => React.JSX.Element;
|
|
4
4
|
export default DateInput;
|
|
@@ -1,64 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
useEffect(function () {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useCallback, useMemo } from "react";
|
|
3
|
+
import DatePicker from "@synerise/ds-date-picker";
|
|
4
|
+
import { getPopupContainer } from "@synerise/ds-utils";
|
|
5
|
+
const DateInput = ({
|
|
6
|
+
value,
|
|
7
|
+
onChange,
|
|
8
|
+
texts,
|
|
9
|
+
opened,
|
|
10
|
+
onDeactivate,
|
|
11
|
+
onActivate,
|
|
12
|
+
error,
|
|
13
|
+
allowClear,
|
|
14
|
+
readOnly = false,
|
|
15
|
+
getPopupContainerOverride,
|
|
16
|
+
uncontrolledComponent
|
|
17
|
+
}) => {
|
|
18
|
+
const [localValue, setLocalValue] = useState(value);
|
|
19
|
+
useEffect(() => {
|
|
21
20
|
if (!uncontrolledComponent) {
|
|
22
21
|
setLocalValue(value);
|
|
23
22
|
}
|
|
24
23
|
}, [value, uncontrolledComponent]);
|
|
25
|
-
|
|
24
|
+
const changeHandler = useCallback((date) => {
|
|
26
25
|
onChange(date);
|
|
27
26
|
}, [onChange]);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var handleClear = useCallback(function () {
|
|
32
|
-
onChange(undefined);
|
|
27
|
+
const localValueAsDate = useMemo(() => localValue ? new Date(String(localValue)) : void 0, [localValue]);
|
|
28
|
+
const handleClear = useCallback(() => {
|
|
29
|
+
onChange(void 0);
|
|
33
30
|
}, [onChange]);
|
|
34
|
-
|
|
31
|
+
const handleOpenChange = useCallback((open) => {
|
|
35
32
|
open && onActivate && onActivate();
|
|
36
33
|
}, [onActivate]);
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
value: localValueAsDate,
|
|
41
|
-
showTime: true,
|
|
42
|
-
useStartOfDay: true,
|
|
43
|
-
texts: texts.datePicker,
|
|
44
|
-
error: error,
|
|
45
|
-
readOnly: readOnly,
|
|
46
|
-
allowClear: allowClear,
|
|
47
|
-
autoFocus: opened,
|
|
48
|
-
inputProps: {
|
|
49
|
-
autoResize: {
|
|
50
|
-
minWidth: '123px'
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
onDropdownVisibleChange: handleOpenChange,
|
|
54
|
-
dropdownProps: {
|
|
55
|
-
open: opened,
|
|
56
|
-
onOpenChange: handleOpenChange,
|
|
57
|
-
getPopupContainer: getPopupContainerOverride || getPopupContainer,
|
|
58
|
-
onDismiss: function onDismiss() {
|
|
59
|
-
onDeactivate == null || onDeactivate();
|
|
60
|
-
}
|
|
34
|
+
return /* @__PURE__ */ jsx(DatePicker, { onClear: handleClear, onApply: changeHandler, value: localValueAsDate, showTime: true, useStartOfDay: true, texts: texts.datePicker, error, readOnly, allowClear, autoFocus: opened, inputProps: {
|
|
35
|
+
autoResize: {
|
|
36
|
+
minWidth: "123px"
|
|
61
37
|
}
|
|
62
|
-
}
|
|
38
|
+
}, onDropdownVisibleChange: handleOpenChange, dropdownProps: {
|
|
39
|
+
open: opened,
|
|
40
|
+
onOpenChange: handleOpenChange,
|
|
41
|
+
getPopupContainer: getPopupContainerOverride || getPopupContainer,
|
|
42
|
+
onDismiss: () => {
|
|
43
|
+
onDeactivate?.();
|
|
44
|
+
}
|
|
45
|
+
} });
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
DateInput as default
|
|
63
49
|
};
|
|
64
|
-
export default DateInput;
|