react-restyle-components 0.1.44 → 0.1.45
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/lib/cjs/App.js +36 -12
- package/lib/cjs/App.test.js +10 -8
- package/lib/cjs/core-components/atoms/buttons/button.stories.js +26 -24
- package/lib/cjs/core-components/atoms/buttons/buttons.component.js +27 -9
- package/lib/cjs/core-components/atoms/buttons/buttons.test.js +15 -7
- package/lib/cjs/core-components/atoms/check-box/checkBox.component.js +102 -35
- package/lib/cjs/core-components/atoms/check-box/checkBox.stories.js +17 -17
- package/lib/cjs/core-components/atoms/check-box/checkBox.test.js +15 -7
- package/lib/cjs/core-components/atoms/date-picker/date-picker.component.js +98 -37
- package/lib/cjs/core-components/atoms/date-picker/date-picker.stories.js +17 -15
- package/lib/cjs/core-components/atoms/date-picker/date-picker.test.js +16 -7
- package/lib/cjs/core-components/atoms/form/form.component.js +571 -159
- package/lib/cjs/core-components/atoms/form/form.test.js +87 -59
- package/lib/cjs/core-components/atoms/icons/icons.component.js +40 -26
- package/lib/cjs/core-components/atoms/input/input-otp.component.js +118 -76
- package/lib/cjs/core-components/atoms/input/input-pin.component.js +180 -98
- package/lib/cjs/core-components/atoms/input/input-pin.stories.js +14 -14
- package/lib/cjs/core-components/atoms/input/input-pin.test.js +28 -10
- package/lib/cjs/core-components/atoms/input/input.component.js +104 -33
- package/lib/cjs/core-components/atoms/input/input.stories.js +15 -15
- package/lib/cjs/core-components/atoms/input/input.test.js +30 -10
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.js +127 -53
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.stories.js +12 -12
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.test.js +16 -7
- package/lib/cjs/core-components/atoms/loader/loader.component.js +83 -21
- package/lib/cjs/core-components/atoms/loader/loader.stories.js +8 -8
- package/lib/cjs/core-components/atoms/loader/loader.test.js +11 -7
- package/lib/cjs/core-components/atoms/radio/radio.component.js +102 -37
- package/lib/cjs/core-components/atoms/radio/radio.stories.js +16 -16
- package/lib/cjs/core-components/atoms/radio/radio.test.js +15 -7
- package/lib/cjs/core-components/atoms/stepper/stepper.component.js +77 -34
- package/lib/cjs/core-components/atoms/stepper/stepper.stories.js +13 -13
- package/lib/cjs/core-components/atoms/stepper/stepper.test.js +16 -7
- package/lib/cjs/core-components/atoms/stepper/stepper.test.js.map +1 -1
- package/lib/cjs/core-components/atoms/tabs/tabs.component.js +95 -0
- package/lib/cjs/core-components/atoms/tabs/tabs.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/tabs/tabs.stories.js +26 -0
- package/lib/cjs/core-components/atoms/tabs/tabs.stories.js.map +1 -0
- package/lib/cjs/core-components/atoms/tabs/tabs.test.js +26 -0
- package/lib/cjs/core-components/atoms/tabs/tabs.test.js.map +1 -0
- package/lib/cjs/core-components/atoms/timer/timer.component.js +119 -92
- package/lib/cjs/core-components/atoms/timer/timer.test.js +20 -10
- package/lib/cjs/core-components/atoms/tooltip/tooltip.component.js +85 -45
- package/lib/cjs/core-components/atoms/tooltip/tooltip.component.test.js +13 -9
- package/lib/cjs/core-components/atoms/tooltip/tooltip.stories.js +8 -8
- package/lib/cjs/core-components/index.js +65 -27
- package/lib/cjs/core-components/index.js.map +1 -1
- package/lib/cjs/core-components/molecules/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.js +210 -106
- package/lib/cjs/core-components/molecules/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.test.js +23 -9
- package/lib/cjs/core-components/molecules/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.stories.js +38 -36
- package/lib/cjs/core-components/molecules/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.js +209 -104
- package/lib/cjs/core-components/molecules/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.test.js +28 -16
- package/lib/cjs/core-components/molecules/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.stories.js +24 -22
- package/lib/cjs/core-components/molecules/css-multiline-input/css-multiline-input.component.js +203 -106
- package/lib/cjs/core-components/molecules/css-multiline-input/css-multiline-input.stories.js +8 -8
- package/lib/cjs/core-components/molecules/css-multiline-input/css-multiline-input.test.js +14 -7
- package/lib/cjs/core-components/molecules/css-multiline-input/css-properties.js +159 -159
- package/lib/cjs/core-utils/index.js +31 -15
- package/lib/cjs/core-utils/unit-test.utils.js +8 -6
- package/lib/cjs/index.js +31 -15
- package/lib/cjs/library/assets/svg/index.js +39 -13
- package/lib/cjs/reportWebVitals.js +1 -1
- package/lib/cjs/setupTests.js +1 -1
- package/lib/esm/App.js +34 -12
- package/lib/esm/App.test.js +8 -8
- package/lib/esm/core-components/atoms/buttons/button.stories.js +24 -24
- package/lib/esm/core-components/atoms/buttons/buttons.component.js +23 -7
- package/lib/esm/core-components/atoms/buttons/buttons.test.js +13 -7
- package/lib/esm/core-components/atoms/check-box/checkBox.component.js +65 -19
- package/lib/esm/core-components/atoms/check-box/checkBox.stories.js +18 -18
- package/lib/esm/core-components/atoms/check-box/checkBox.test.js +13 -7
- package/lib/esm/core-components/atoms/date-picker/date-picker.component.js +54 -21
- package/lib/esm/core-components/atoms/date-picker/date-picker.stories.js +14 -14
- package/lib/esm/core-components/atoms/date-picker/date-picker.test.js +15 -8
- package/lib/esm/core-components/atoms/form/form.component.js +513 -138
- package/lib/esm/core-components/atoms/form/form.test.js +78 -60
- package/lib/esm/core-components/atoms/icons/icons.component.js +36 -24
- package/lib/esm/core-components/atoms/input/input-otp.component.js +80 -59
- package/lib/esm/core-components/atoms/input/input-pin.component.js +142 -81
- package/lib/esm/core-components/atoms/input/input-pin.stories.js +15 -15
- package/lib/esm/core-components/atoms/input/input-pin.test.js +26 -10
- package/lib/esm/core-components/atoms/input/input.component.js +66 -16
- package/lib/esm/core-components/atoms/input/input.stories.js +16 -16
- package/lib/esm/core-components/atoms/input/input.test.js +28 -10
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.js +95 -36
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.stories.js +13 -13
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.test.js +14 -7
- package/lib/esm/core-components/atoms/loader/loader.component.js +80 -20
- package/lib/esm/core-components/atoms/loader/loader.stories.js +9 -9
- package/lib/esm/core-components/atoms/loader/loader.test.js +7 -7
- package/lib/esm/core-components/atoms/radio/radio.component.js +65 -21
- package/lib/esm/core-components/atoms/radio/radio.stories.js +17 -17
- package/lib/esm/core-components/atoms/radio/radio.test.js +13 -7
- package/lib/esm/core-components/atoms/stepper/stepper.component.js +74 -32
- package/lib/esm/core-components/atoms/stepper/stepper.stories.js +14 -14
- package/lib/esm/core-components/atoms/stepper/stepper.test.js +14 -7
- package/lib/esm/core-components/atoms/stepper/stepper.test.js.map +1 -1
- package/lib/esm/core-components/atoms/tabs/tabs.component.js +47 -0
- package/lib/esm/core-components/atoms/tabs/tabs.component.js.map +1 -0
- package/lib/esm/core-components/atoms/tabs/tabs.stories.js +23 -0
- package/lib/esm/core-components/atoms/tabs/tabs.stories.js.map +1 -0
- package/lib/esm/core-components/atoms/tabs/tabs.test.js +19 -0
- package/lib/esm/core-components/atoms/tabs/tabs.test.js.map +1 -0
- package/lib/esm/core-components/atoms/timer/timer.component.js +81 -75
- package/lib/esm/core-components/atoms/timer/timer.test.js +10 -10
- package/lib/esm/core-components/atoms/tooltip/tooltip.component.js +46 -25
- package/lib/esm/core-components/atoms/tooltip/tooltip.component.test.js +9 -9
- package/lib/esm/core-components/atoms/tooltip/tooltip.stories.js +9 -9
- package/lib/esm/core-components/index.js +19 -18
- package/lib/esm/core-components/index.js.map +1 -1
- package/lib/esm/core-components/molecules/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.js +170 -88
- package/lib/esm/core-components/molecules/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.test.js +17 -9
- package/lib/esm/core-components/molecules/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.stories.js +38 -37
- package/lib/esm/core-components/molecules/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.js +169 -86
- package/lib/esm/core-components/molecules/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.component.test.js +22 -16
- package/lib/esm/core-components/molecules/auto-complete-filter-single-select-multiple-fields-display/auto-complete-filter-single-select-multiple-fields-display.stories.js +24 -23
- package/lib/esm/core-components/molecules/css-multiline-input/css-multiline-input.component.js +166 -90
- package/lib/esm/core-components/molecules/css-multiline-input/css-multiline-input.stories.js +9 -9
- package/lib/esm/core-components/molecules/css-multiline-input/css-multiline-input.test.js +9 -7
- package/lib/esm/core-components/molecules/css-multiline-input/css-properties.js +159 -159
- package/lib/esm/core-utils/index.js +2 -2
- package/lib/esm/core-utils/unit-test.utils.js +5 -5
- package/lib/esm/index.js +2 -2
- package/lib/esm/library/assets/svg/index.js +19 -10
- package/lib/esm/reportWebVitals.js +1 -1
- package/lib/esm/setupTests.js +2 -2
- package/package.json +3 -1
|
@@ -1,94 +1,177 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import React, { useState, useEffect, useRef } from
|
|
3
|
-
import { Icon } from
|
|
4
|
-
export const AutoCompleteFilterSingleSelectMultiFieldsDisplay = ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
const wrapperRef = useRef(null);
|
|
24
|
-
useOutsideAlerter(wrapperRef);
|
|
2
|
+
import React, { useState, useEffect, useRef } from "react";
|
|
3
|
+
import { Icon } from "../..";
|
|
4
|
+
export const AutoCompleteFilterSingleSelectMultiFieldsDisplay = ({
|
|
5
|
+
disable = false,
|
|
6
|
+
loader = false,
|
|
7
|
+
displayValue = "",
|
|
8
|
+
placeholder = "Search...",
|
|
9
|
+
data,
|
|
10
|
+
hasError = false,
|
|
11
|
+
className,
|
|
12
|
+
posstion = "absolute",
|
|
13
|
+
onFilter,
|
|
14
|
+
onSelect,
|
|
15
|
+
onBlur,
|
|
16
|
+
}) => {
|
|
17
|
+
const [value, setValue] = useState(displayValue);
|
|
18
|
+
const [options, setOptions] = useState(data.list);
|
|
19
|
+
const [isListOpen, setIsListOpen] = useState(false);
|
|
20
|
+
const [filterValue, setFilterValue] = useState();
|
|
21
|
+
const useOutsideAlerter = (ref) => {
|
|
25
22
|
useEffect(() => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}, [displayValue]);
|
|
31
|
-
const onChange = (e) => {
|
|
32
|
-
var _a;
|
|
33
|
-
const search = (_a = e.target.value) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
34
|
-
setValue(search);
|
|
35
|
-
setFilterValue(search);
|
|
36
|
-
onFilter && onFilter(search);
|
|
37
|
-
};
|
|
38
|
-
const onKeyUp = (e) => {
|
|
39
|
-
const charCode = e.which ? e.which : e.keyCode;
|
|
40
|
-
if (charCode === 8) {
|
|
41
|
-
const search = e.target.value;
|
|
42
|
-
onFilter && onFilter(search);
|
|
23
|
+
function handleClickOutside(event) {
|
|
24
|
+
if (ref.current && !ref.current.contains(event.target) && isListOpen) {
|
|
25
|
+
setIsListOpen(false);
|
|
26
|
+
//setValue('');
|
|
43
27
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
28
|
+
}
|
|
29
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
30
|
+
return () => {
|
|
31
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
32
|
+
};
|
|
33
|
+
}, [ref, isListOpen]);
|
|
34
|
+
};
|
|
35
|
+
const wrapperRef = useRef(null);
|
|
36
|
+
useOutsideAlerter(wrapperRef);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
setOptions(data.list);
|
|
39
|
+
}, [data]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
setValue(displayValue);
|
|
42
|
+
}, [displayValue]);
|
|
43
|
+
const onChange = (e) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const search =
|
|
46
|
+
(_a = e.target.value) === null || _a === void 0
|
|
47
|
+
? void 0
|
|
48
|
+
: _a.toUpperCase();
|
|
49
|
+
setValue(search);
|
|
50
|
+
setFilterValue(search);
|
|
51
|
+
onFilter && onFilter(search);
|
|
52
|
+
};
|
|
53
|
+
const onKeyUp = (e) => {
|
|
54
|
+
const charCode = e.which ? e.which : e.keyCode;
|
|
55
|
+
if (charCode === 8) {
|
|
56
|
+
const search = e.target.value;
|
|
57
|
+
onFilter && onFilter(search);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const onKeyDown = (e) => {
|
|
61
|
+
if (e.key === "Enter" || e.key === "Tab") {
|
|
62
|
+
if (options.length > 0) {
|
|
63
|
+
const selectedItem = options.find(
|
|
64
|
+
(item) => item.labId === Number(value),
|
|
65
|
+
);
|
|
66
|
+
if (selectedItem) {
|
|
67
|
+
setValue(
|
|
68
|
+
data.displayKey.map((key) => `${selectedItem[key]}`).join(" - "),
|
|
69
|
+
);
|
|
70
|
+
setIsListOpen(false);
|
|
71
|
+
onSelect && onSelect(selectedItem);
|
|
55
72
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return React.createElement(
|
|
77
|
+
React.Fragment,
|
|
78
|
+
null,
|
|
79
|
+
React.createElement(
|
|
80
|
+
"div",
|
|
81
|
+
{ ref: wrapperRef, className: "w-full relative" },
|
|
82
|
+
React.createElement(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: `flex items-center leading-4 p-2 focus:outline-none focus:ring w-full shadow-sm sm:text-base border-2 ${hasError ? "border-red" : "border-gray-300"} rounded-md dark:text-black`,
|
|
86
|
+
},
|
|
87
|
+
React.createElement("input", {
|
|
88
|
+
placeholder: placeholder,
|
|
89
|
+
value: value,
|
|
90
|
+
className: `${className} w-full focus:outline-none bg-none dark:text-black`,
|
|
91
|
+
onKeyUp: onKeyUp,
|
|
92
|
+
onChange: onChange,
|
|
93
|
+
onClick: () => setIsListOpen(true),
|
|
94
|
+
disabled: disable,
|
|
95
|
+
onMouseDown: () => setValue(""),
|
|
96
|
+
onBlur: (e) => onBlur && onBlur(e),
|
|
97
|
+
onKeyDown: onKeyDown,
|
|
98
|
+
}),
|
|
99
|
+
isListOpen
|
|
100
|
+
? React.createElement(Icon, {
|
|
101
|
+
nameIcon: "FaChevronUp",
|
|
102
|
+
propsIcon: {
|
|
103
|
+
color: "#000000",
|
|
104
|
+
size: 22,
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
: React.createElement(Icon, {
|
|
108
|
+
nameIcon: "FaChevronDown",
|
|
109
|
+
propsIcon: {
|
|
110
|
+
color: "#000000",
|
|
111
|
+
size: 22,
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
),
|
|
115
|
+
options && isListOpen
|
|
116
|
+
? options.length > 0 &&
|
|
117
|
+
React.createElement(
|
|
118
|
+
"div",
|
|
119
|
+
{
|
|
120
|
+
className: `mt-1 absolute w-full bg-gray-100 p-2 rounded-sm `,
|
|
121
|
+
style: {
|
|
122
|
+
zIndex: 500,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
React.createElement(
|
|
126
|
+
"ul",
|
|
127
|
+
null,
|
|
128
|
+
options === null || options === void 0
|
|
129
|
+
? void 0
|
|
130
|
+
: options.map((item, index) =>
|
|
131
|
+
React.createElement(
|
|
132
|
+
"li",
|
|
133
|
+
{
|
|
134
|
+
key: index,
|
|
135
|
+
className: "text-gray-400 flex items-center",
|
|
136
|
+
onClick: () => {
|
|
137
|
+
setValue(
|
|
138
|
+
data.displayKey
|
|
74
139
|
.map((key) => `${item[key]}`)
|
|
75
|
-
.join(
|
|
140
|
+
.join(" - "),
|
|
141
|
+
);
|
|
76
142
|
setIsListOpen(false);
|
|
77
143
|
onSelect && onSelect(item);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
" ",
|
|
147
|
+
React.createElement(
|
|
148
|
+
"label",
|
|
149
|
+
{
|
|
150
|
+
className: "ml-2 mt-1 text-black",
|
|
151
|
+
style: {
|
|
152
|
+
textOverflow: "ellipsis",
|
|
153
|
+
minWidth: 0,
|
|
154
|
+
overflow: "hidden",
|
|
155
|
+
maxWidth: "334px",
|
|
156
|
+
whiteSpace: "nowrap",
|
|
157
|
+
},
|
|
158
|
+
title: data.displayKey
|
|
159
|
+
.map((key) => item[key])
|
|
160
|
+
.join(" - "),
|
|
161
|
+
},
|
|
162
|
+
data.displayKey
|
|
163
|
+
.map(
|
|
164
|
+
(key) => `${item[key]}
|
|
165
|
+
`,
|
|
166
|
+
)
|
|
167
|
+
.join(" - "),
|
|
168
|
+
),
|
|
169
|
+
),
|
|
170
|
+
),
|
|
171
|
+
),
|
|
172
|
+
)
|
|
173
|
+
: null,
|
|
174
|
+
),
|
|
175
|
+
);
|
|
93
176
|
};
|
|
94
|
-
//# sourceMappingURL=auto-complete-filter-single-select-multiple-fields-display.component.js.map
|
|
177
|
+
//# sourceMappingURL=auto-complete-filter-single-select-multiple-fields-display.component.js.map
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render } from
|
|
3
|
-
import { AutoCompleteFilterSingleSelectMultiFieldsDisplay } from
|
|
4
|
-
describe(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import { AutoCompleteFilterSingleSelectMultiFieldsDisplay } from "./auto-complete-filter-single-select-multiple-fields-display.component";
|
|
4
|
+
describe("AutoCompleteFilterSingleSelectMultiFieldsDisplay component", () => {
|
|
5
|
+
it("render autoCompleteFilterSingleSelectMultiFieldsDisplay correctly", () => {
|
|
6
|
+
const autoCompleteFilterSingleSelectMultiFieldsDisplay = render(
|
|
7
|
+
React.createElement(AutoCompleteFilterSingleSelectMultiFieldsDisplay, {
|
|
8
|
+
data: {
|
|
9
|
+
list: [
|
|
10
|
+
{ code: "Lims", name: "plus" },
|
|
11
|
+
{ code: "Lims", name: "plus" },
|
|
12
|
+
{ code: "Lims", name: "plus" },
|
|
13
|
+
],
|
|
14
|
+
displayKey: ["name"],
|
|
15
|
+
},
|
|
16
|
+
onSelect: () => jest.fn(),
|
|
17
|
+
onFilter: () => jest.fn(),
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
expect(autoCompleteFilterSingleSelectMultiFieldsDisplay).toMatchSnapshot();
|
|
21
|
+
});
|
|
16
22
|
});
|
|
17
|
-
//# sourceMappingURL=auto-complete-filter-single-select-multiple-fields-display.component.test.js.map
|
|
23
|
+
//# sourceMappingURL=auto-complete-filter-single-select-multiple-fields-display.component.test.js.map
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { AutoCompleteFilterSingleSelectMultiFieldsDisplay } from
|
|
1
|
+
import { AutoCompleteFilterSingleSelectMultiFieldsDisplay } from "./auto-complete-filter-single-select-multiple-fields-display.component";
|
|
2
2
|
const meta = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
3
|
+
title:
|
|
4
|
+
"Design System/Molecules/AutoCompleteFilterSingleSelectMultiFieldsDisplay",
|
|
5
|
+
component: AutoCompleteFilterSingleSelectMultiFieldsDisplay,
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
parameters: {
|
|
8
|
+
componentSubtitle: `import { AutoCompleteFilterSingleSelectMultiFieldsDisplay } from 'react-restyle-components'`,
|
|
9
|
+
// backgrounds: {
|
|
10
|
+
// default: 'light-gray',
|
|
11
|
+
// },
|
|
12
|
+
},
|
|
12
13
|
};
|
|
13
14
|
export default meta;
|
|
14
15
|
export const Primary = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
16
|
+
args: {
|
|
17
|
+
data: {
|
|
18
|
+
list: [
|
|
19
|
+
{ code: "Code1", name: "Value1" },
|
|
20
|
+
{ code: "Code2", name: "Value2" },
|
|
21
|
+
{ code: "Code3", name: "Value3" },
|
|
22
|
+
],
|
|
23
|
+
displayKey: ["name"],
|
|
24
|
+
},
|
|
25
|
+
onSelect: (item) => {
|
|
26
|
+
console.log({ item });
|
|
27
27
|
},
|
|
28
|
+
},
|
|
28
29
|
};
|
|
29
|
-
//# sourceMappingURL=auto-complete-filter-single-select-multiple-fields-display.stories.js.map
|
|
30
|
+
//# sourceMappingURL=auto-complete-filter-single-select-multiple-fields-display.stories.js.map
|
package/lib/esm/core-components/molecules/css-multiline-input/css-multiline-input.component.js
CHANGED
|
@@ -1,102 +1,178 @@
|
|
|
1
|
-
import React, { useEffect, useState, useRef } from
|
|
2
|
-
import { Form } from
|
|
3
|
-
import { properties as propertiesObj } from
|
|
1
|
+
import React, { useEffect, useState, useRef } from "react";
|
|
2
|
+
import { Form } from "../..";
|
|
3
|
+
import { properties as propertiesObj } from "./css-properties";
|
|
4
4
|
const mapToArray = (arr) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const res = [];
|
|
6
|
+
arr.forEach(function (obj, index) {
|
|
7
|
+
const key = Object.keys(obj)[0];
|
|
8
|
+
const value = key;
|
|
9
|
+
res.push([value, obj[key]]);
|
|
10
|
+
});
|
|
11
|
+
return res;
|
|
12
12
|
};
|
|
13
13
|
const data = mapToArray(propertiesObj);
|
|
14
|
-
export const CSSMultiline = ({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
export const CSSMultiline = ({
|
|
15
|
+
label = "Main Box CSS",
|
|
16
|
+
defaultValue = "",
|
|
17
|
+
className = "",
|
|
18
|
+
style = {},
|
|
19
|
+
placeholder = "Like fontSize: 12,backgroundColor:'#000000',",
|
|
20
|
+
onChange,
|
|
21
|
+
}) => {
|
|
22
|
+
const value = useRef("");
|
|
23
|
+
const [properties, setProperties] = useState([]);
|
|
24
|
+
const [isListOpen, setIsListOpen] = useState(false);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
value.current = defaultValue;
|
|
27
|
+
setProperties(data);
|
|
28
|
+
}, [defaultValue]);
|
|
29
|
+
const useOutsideAlerter = (ref) => {
|
|
18
30
|
useEffect(() => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
function handleClickOutside(event) {
|
|
25
|
-
if (ref.current && !ref.current.contains(event.target)) {
|
|
26
|
-
setIsListOpen(false);
|
|
27
|
-
onChange(value.current);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
31
|
-
return () => {
|
|
32
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
33
|
-
};
|
|
34
|
-
}, [ref]);
|
|
35
|
-
};
|
|
36
|
-
const wrapperRef = useRef(null);
|
|
37
|
-
useOutsideAlerter(wrapperRef);
|
|
38
|
-
const list = [];
|
|
39
|
-
const filter = (css) => {
|
|
40
|
-
let matchString = css === null || css === void 0 ? void 0 : css.split(',');
|
|
41
|
-
matchString = matchString[(matchString === null || matchString === void 0 ? void 0 : matchString.length) - 1];
|
|
42
|
-
matchString = matchString === null || matchString === void 0 ? void 0 : matchString.split(':')[0];
|
|
43
|
-
matchString = matchString === null || matchString === void 0 ? void 0 : matchString.split("'")[0];
|
|
44
|
-
if ((css === null || css === void 0 ? void 0 : css.length) == 0)
|
|
45
|
-
return setProperties(data);
|
|
46
|
-
else {
|
|
47
|
-
data === null || data === void 0 ? void 0 : data.map((item) => {
|
|
48
|
-
var _a;
|
|
49
|
-
const innerItem = [];
|
|
50
|
-
const isItems = (_a = item[0]) === null || _a === void 0 ? void 0 : _a.startsWith(matchString);
|
|
51
|
-
if (isItems)
|
|
52
|
-
innerItem.push(item[0]);
|
|
53
|
-
if ((innerItem === null || innerItem === void 0 ? void 0 : innerItem.length) > 0)
|
|
54
|
-
list.push([item[0], item[1]]);
|
|
55
|
-
});
|
|
56
|
-
setProperties(list);
|
|
31
|
+
function handleClickOutside(event) {
|
|
32
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
33
|
+
setIsListOpen(false);
|
|
34
|
+
onChange(value.current);
|
|
57
35
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
36
|
+
}
|
|
37
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
38
|
+
return () => {
|
|
39
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
40
|
+
};
|
|
41
|
+
}, [ref]);
|
|
42
|
+
};
|
|
43
|
+
const wrapperRef = useRef(null);
|
|
44
|
+
useOutsideAlerter(wrapperRef);
|
|
45
|
+
const list = [];
|
|
46
|
+
const filter = (css) => {
|
|
47
|
+
let matchString = css === null || css === void 0 ? void 0 : css.split(",");
|
|
48
|
+
matchString =
|
|
49
|
+
matchString[
|
|
50
|
+
(matchString === null || matchString === void 0
|
|
51
|
+
? void 0
|
|
52
|
+
: matchString.length) - 1
|
|
53
|
+
];
|
|
54
|
+
matchString =
|
|
55
|
+
matchString === null || matchString === void 0
|
|
56
|
+
? void 0
|
|
57
|
+
: matchString.split(":")[0];
|
|
58
|
+
matchString =
|
|
59
|
+
matchString === null || matchString === void 0
|
|
60
|
+
? void 0
|
|
61
|
+
: matchString.split("'")[0];
|
|
62
|
+
if ((css === null || css === void 0 ? void 0 : css.length) == 0)
|
|
63
|
+
return setProperties(data);
|
|
64
|
+
else {
|
|
65
|
+
data === null || data === void 0
|
|
66
|
+
? void 0
|
|
67
|
+
: data.map((item) => {
|
|
68
|
+
var _a;
|
|
69
|
+
const innerItem = [];
|
|
70
|
+
const isItems =
|
|
71
|
+
(_a = item[0]) === null || _a === void 0
|
|
72
|
+
? void 0
|
|
73
|
+
: _a.startsWith(matchString);
|
|
74
|
+
if (isItems) innerItem.push(item[0]);
|
|
75
|
+
if (
|
|
76
|
+
(innerItem === null || innerItem === void 0
|
|
77
|
+
? void 0
|
|
78
|
+
: innerItem.length) > 0
|
|
79
|
+
)
|
|
80
|
+
list.push([item[0], item[1]]);
|
|
81
|
+
});
|
|
82
|
+
setProperties(list);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const onKeyUp = (e) => {
|
|
86
|
+
setIsListOpen(true);
|
|
87
|
+
};
|
|
88
|
+
return React.createElement(
|
|
89
|
+
"div",
|
|
90
|
+
{ className: "flex flex-col w-full", ref: wrapperRef },
|
|
91
|
+
React.createElement(Form.MultilineInput, {
|
|
92
|
+
label: label,
|
|
93
|
+
style: Object.assign(
|
|
94
|
+
{ color: "#ffffff", backgroundColor: "#000000" },
|
|
95
|
+
style,
|
|
96
|
+
),
|
|
97
|
+
placeholder: placeholder,
|
|
98
|
+
value: value.current,
|
|
99
|
+
className: className,
|
|
100
|
+
onKeyUp: onKeyUp,
|
|
101
|
+
onChange: (css) => {
|
|
102
|
+
value.current = css;
|
|
103
|
+
filter(css);
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
106
|
+
isListOpen &&
|
|
107
|
+
React.createElement(
|
|
108
|
+
"div",
|
|
109
|
+
{ style: { marginTop: -10 } },
|
|
110
|
+
React.createElement(
|
|
111
|
+
"ul",
|
|
112
|
+
{
|
|
113
|
+
className:
|
|
114
|
+
"flex flex-col max-h-40 bg-black m-2 text-white overflow-y-scroll ",
|
|
115
|
+
},
|
|
116
|
+
properties === null || properties === void 0
|
|
117
|
+
? void 0
|
|
118
|
+
: properties.map((item, index) => {
|
|
69
119
|
var _a;
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
120
|
+
return React.createElement(
|
|
121
|
+
"li",
|
|
122
|
+
{ key: index, className: "flex flex-col gap-4 p-2" },
|
|
123
|
+
React.createElement(
|
|
124
|
+
"span",
|
|
125
|
+
{ className: "underline" },
|
|
126
|
+
item[0],
|
|
127
|
+
),
|
|
128
|
+
(_a = item[1]) === null || _a === void 0
|
|
129
|
+
? void 0
|
|
130
|
+
: _a.map((prop) =>
|
|
131
|
+
React.createElement(
|
|
132
|
+
"li",
|
|
133
|
+
{
|
|
134
|
+
className:
|
|
135
|
+
"flex -mt-2 px-2 h-8 bg-slate-800 rounded-md items-center cursor-pointer",
|
|
136
|
+
onClick: () => {
|
|
137
|
+
var _a;
|
|
138
|
+
let existsString =
|
|
139
|
+
(_a = value.current) === null || _a === void 0
|
|
140
|
+
? void 0
|
|
141
|
+
: _a.split(",");
|
|
142
|
+
if (value.current.includes(",")) {
|
|
76
143
|
existsString = existsString.map((item) => {
|
|
77
|
-
|
|
78
|
-
|
|
144
|
+
if (
|
|
145
|
+
item === null || item === void 0
|
|
146
|
+
? void 0
|
|
147
|
+
: item.includes(":")
|
|
148
|
+
)
|
|
149
|
+
return item;
|
|
79
150
|
});
|
|
80
|
-
if (prop !=
|
|
81
|
-
|
|
82
|
-
else
|
|
83
|
-
existsString.push(`${item[0]}:1,`);
|
|
151
|
+
if (prop != "number")
|
|
152
|
+
existsString.push(`${item[0]}:'${prop}',`);
|
|
153
|
+
else existsString.push(`${item[0]}:1,`);
|
|
84
154
|
value.current = existsString
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
value.current = `${item[0]}:'${prop}',`;
|
|
155
|
+
.join(",")
|
|
156
|
+
.replaceAll(",,", ",");
|
|
157
|
+
} else {
|
|
158
|
+
if (prop != "number")
|
|
159
|
+
value.current = `${item[0]}:'${prop}',`;
|
|
91
160
|
else {
|
|
92
|
-
|
|
161
|
+
value.current = `${item[0]}:1,`;
|
|
93
162
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
163
|
+
}
|
|
164
|
+
filter(existsString.join(""));
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
" ",
|
|
168
|
+
prop,
|
|
169
|
+
" ",
|
|
170
|
+
),
|
|
171
|
+
),
|
|
172
|
+
);
|
|
173
|
+
}),
|
|
174
|
+
),
|
|
175
|
+
),
|
|
176
|
+
);
|
|
101
177
|
};
|
|
102
|
-
//# sourceMappingURL=css-multiline-input.component.js.map
|
|
178
|
+
//# sourceMappingURL=css-multiline-input.component.js.map
|
package/lib/esm/core-components/molecules/css-multiline-input/css-multiline-input.stories.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { CSSMultiline } from
|
|
1
|
+
import { CSSMultiline } from "./css-multiline-input.component";
|
|
2
2
|
const meta = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
title: "Design System/Molecules/CSSMultiline",
|
|
4
|
+
component: CSSMultiline,
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
parameters: {
|
|
7
|
+
componentSubtitle: `import { CSSMultiline } from 'react-restyle-components'`,
|
|
8
|
+
},
|
|
9
9
|
};
|
|
10
10
|
export default meta;
|
|
11
11
|
export const Primary = {
|
|
12
|
-
|
|
12
|
+
args: {},
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=css-multiline-input.stories.js.map
|
|
14
|
+
//# sourceMappingURL=css-multiline-input.stories.js.map
|