sag_components 1.0.640 → 1.0.641
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/stories/components/DropdownMultiNew.js +248 -0
- package/dist/stories/components/DropdownMultiNew.style.js +29 -0
- package/dist/stories/components/DropdownNew.js +54 -116
- package/dist/stories/components/DropdownNew.style.js +4 -11
- package/dist/stories/components/DropdownSingleNew.js +207 -0
- package/dist/stories/components/DropdownSingleNew.style.js +27 -0
- package/dist/stories/components/TabMenu.js +7 -0
- package/dist/stories/components/TotalCostModal.js +143 -0
- package/package.json +1 -1
- package/dist/stories/CampaignTool/PopupContent.stories.js +0 -284
- package/dist/stories/components/EventInfo.js +0 -92
- package/dist/stories/components/EventInfo.style.js +0 -20
- package/dist/stories/components/FilterButton.js +0 -47
- package/dist/stories/components/FilterButton.style.js +0 -12
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.DropdownMultiNew = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _CloseXIcon = require("./icons/CloseXIcon");
|
|
10
|
+
var _MenuItemUpIcon = require("./icons/MenuItemUpIcon");
|
|
11
|
+
var _MenuItemOpenIcon = require("./icons/MenuItemOpenIcon");
|
|
12
|
+
var _CheckBoxCheckedIcon = require("./icons/CheckBoxCheckedIcon");
|
|
13
|
+
var _CheckBoxNotCheckedIcon = require("./icons/CheckBoxNotCheckedIcon");
|
|
14
|
+
var _DropdownMultiNew = require("./DropdownMultiNew.style");
|
|
15
|
+
/* eslint-disable react/prop-types */
|
|
16
|
+
|
|
17
|
+
const DropdownMultiNew = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
label,
|
|
20
|
+
labelEmptyValue,
|
|
21
|
+
options,
|
|
22
|
+
selectedValue,
|
|
23
|
+
placeHolder,
|
|
24
|
+
onChange,
|
|
25
|
+
required,
|
|
26
|
+
disabled,
|
|
27
|
+
width,
|
|
28
|
+
error,
|
|
29
|
+
errorMessage,
|
|
30
|
+
labelColor,
|
|
31
|
+
checkBoxColor
|
|
32
|
+
} = _ref;
|
|
33
|
+
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
34
|
+
const [showOptions, setShowOptions] = (0, _react.useState)(false);
|
|
35
|
+
const [inputValue, setInputValue] = (0, _react.useState)('');
|
|
36
|
+
const [selectedOptions, setSelectedOptions] = (0, _react.useState)([]);
|
|
37
|
+
const [hoverInputContainer, setHoverInputContainer] = (0, _react.useState)(false);
|
|
38
|
+
const [hoverOptionsContainer, setHoverOptionsContainer] = (0, _react.useState)(false);
|
|
39
|
+
const inputRef = (0, _react.useRef)(null);
|
|
40
|
+
const containerRef = (0, _react.useRef)(null);
|
|
41
|
+
const filteredoptions = options === null || options === void 0 ? void 0 : options.filter(option => option.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
42
|
+
(0, _react.useEffect)(() => {
|
|
43
|
+
if (selectedValue) {
|
|
44
|
+
setSelectedOptions(selectedValue);
|
|
45
|
+
}
|
|
46
|
+
}, [selectedValue]);
|
|
47
|
+
(0, _react.useEffect)(() => {
|
|
48
|
+
if (isFocused && inputRef !== null && inputRef !== void 0 && inputRef.current) {
|
|
49
|
+
var _inputRef$current;
|
|
50
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
51
|
+
}
|
|
52
|
+
}, [isFocused]);
|
|
53
|
+
(0, _react.useEffect)(() => {
|
|
54
|
+
if (!hoverInputContainer && !hoverOptionsContainer) {
|
|
55
|
+
setIsFocused(false);
|
|
56
|
+
setShowOptions(false);
|
|
57
|
+
}
|
|
58
|
+
}, [hoverInputContainer, hoverOptionsContainer]);
|
|
59
|
+
const handleFocus = () => {
|
|
60
|
+
setIsFocused(true);
|
|
61
|
+
setShowOptions(true);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// const handleBlur = () => {
|
|
65
|
+
// if (isMulti) return;
|
|
66
|
+
// setIsFocused(false);
|
|
67
|
+
// setTimeout(() => setShowOptions(false), 200); // Delay hiding options to allow clicking on them
|
|
68
|
+
// };
|
|
69
|
+
|
|
70
|
+
const toggleOption = option => {
|
|
71
|
+
if (disabled) return;
|
|
72
|
+
const selectedIndex = selectedOptions.findIndex(selectedOption => selectedOption.value === option.value);
|
|
73
|
+
let newDropdownedOptions;
|
|
74
|
+
if (selectedIndex === -1) {
|
|
75
|
+
newDropdownedOptions = [...selectedOptions, option];
|
|
76
|
+
setSelectedOptions([...selectedOptions, option]);
|
|
77
|
+
} else {
|
|
78
|
+
newDropdownedOptions = [...selectedOptions];
|
|
79
|
+
newDropdownedOptions.splice(selectedIndex, 1);
|
|
80
|
+
setSelectedOptions(newDropdownedOptions);
|
|
81
|
+
}
|
|
82
|
+
onChange({
|
|
83
|
+
newValue: newDropdownedOptions
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const handleInputChange = e => {
|
|
87
|
+
setIsFocused(true);
|
|
88
|
+
setInputValue(e.target.value);
|
|
89
|
+
};
|
|
90
|
+
const isDropdowned = option => selectedOptions.some(selectedOption => selectedOption.value === option.value);
|
|
91
|
+
const handleLabelClick = () => {
|
|
92
|
+
if (disabled) return;
|
|
93
|
+
setIsFocused(true);
|
|
94
|
+
setShowOptions(true);
|
|
95
|
+
};
|
|
96
|
+
const handleOpenCloseMenuClick = () => {
|
|
97
|
+
if (disabled) return;
|
|
98
|
+
if (showOptions) {
|
|
99
|
+
setShowOptions(false);
|
|
100
|
+
setIsFocused(false);
|
|
101
|
+
} else {
|
|
102
|
+
setShowOptions(true);
|
|
103
|
+
setIsFocused(true);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const handleClearClick = () => {
|
|
107
|
+
if (disabled) return;
|
|
108
|
+
setSelectedOptions([]);
|
|
109
|
+
setIsFocused(true);
|
|
110
|
+
if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
|
|
111
|
+
var _inputRef$current2;
|
|
112
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const displaySelectedOptions = () => {
|
|
116
|
+
const content = /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.SelectedOptionsContainer, {
|
|
117
|
+
className: "SelectedOptionsContainer"
|
|
118
|
+
}, selectedOptions.map((option, index) => {
|
|
119
|
+
var _option$label, _option$label2;
|
|
120
|
+
return index < 2 ? /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.SelectedOptionItem, {
|
|
121
|
+
className: "SelectedOptionItem",
|
|
122
|
+
key: option.value,
|
|
123
|
+
onClick: () => {
|
|
124
|
+
toggleOption(option);
|
|
125
|
+
setIsFocused(true);
|
|
126
|
+
if (inputRef !== null && inputRef !== void 0 && inputRef.current) {
|
|
127
|
+
var _inputRef$current3;
|
|
128
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}, option.label && ((_option$label = option.label) === null || _option$label === void 0 ? void 0 : _option$label.length) > 10 ? "".concat((_option$label2 = option.label) === null || _option$label2 === void 0 ? void 0 : _option$label2.substring(0, 10), "... ") : option.label, /*#__PURE__*/_react.default.createElement(_CloseXIcon.CloseXIcon, {
|
|
132
|
+
width: "8px",
|
|
133
|
+
height: "8px",
|
|
134
|
+
fill: "#212121"
|
|
135
|
+
})) : ' ';
|
|
136
|
+
}), selectedOptions.length > 2 ? /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.SelectedOptionItem, {
|
|
137
|
+
className: "SelectedOptionItem"
|
|
138
|
+
}, selectedOptions.length - 2, "+") : '');
|
|
139
|
+
return content;
|
|
140
|
+
};
|
|
141
|
+
return /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.DropdownWrapper, {
|
|
142
|
+
className: "DropdownWrapper",
|
|
143
|
+
width: width,
|
|
144
|
+
onMouseEnter: () => setHoverInputContainer(true),
|
|
145
|
+
onMouseLeave: () => setHoverInputContainer(false)
|
|
146
|
+
}, /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.InputContainer, {
|
|
147
|
+
className: "InputContainer",
|
|
148
|
+
labelColor: labelColor,
|
|
149
|
+
disabled: disabled,
|
|
150
|
+
error: error,
|
|
151
|
+
isFocused: isFocused
|
|
152
|
+
}, /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.InputSubContainer, {
|
|
153
|
+
className: "InputSubContainer",
|
|
154
|
+
ref: containerRef,
|
|
155
|
+
labelColor: labelColor,
|
|
156
|
+
disabled: disabled,
|
|
157
|
+
error: error,
|
|
158
|
+
onClick: handleLabelClick
|
|
159
|
+
}, /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.Label, {
|
|
160
|
+
className: "Label",
|
|
161
|
+
isFocused: isFocused,
|
|
162
|
+
labelColor: labelColor,
|
|
163
|
+
hasValue: (selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length) > 0 || inputValue,
|
|
164
|
+
disabled: disabled,
|
|
165
|
+
error: error,
|
|
166
|
+
errorMessage: errorMessage,
|
|
167
|
+
onClick: handleLabelClick
|
|
168
|
+
}, (selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length) > 0 ? label : labelEmptyValue, required && /*#__PURE__*/_react.default.createElement("span", {
|
|
169
|
+
style: {
|
|
170
|
+
color: 'red'
|
|
171
|
+
}
|
|
172
|
+
}, "*")), displaySelectedOptions(), showOptions ? /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.StyledInput, {
|
|
173
|
+
className: "StyledInput",
|
|
174
|
+
ref: inputRef,
|
|
175
|
+
value: inputValue,
|
|
176
|
+
onChange: handleInputChange,
|
|
177
|
+
onFocus: handleFocus,
|
|
178
|
+
onClick: handleLabelClick,
|
|
179
|
+
type: "search",
|
|
180
|
+
disabled: disabled,
|
|
181
|
+
placeholder: placeHolder || 'Type to search...' // {isFocused ? placeHolder || 'Type to search...' : ''}
|
|
182
|
+
,
|
|
183
|
+
error: error,
|
|
184
|
+
isFocused: isFocused
|
|
185
|
+
}) : ' '), selectedOptions.length > 0 && /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.IconContainer, {
|
|
186
|
+
className: "IconContainer",
|
|
187
|
+
onClick: handleClearClick
|
|
188
|
+
}, /*#__PURE__*/_react.default.createElement(_CloseXIcon.CloseXIcon, {
|
|
189
|
+
width: "12px",
|
|
190
|
+
height: "12px",
|
|
191
|
+
fill: "#B1B1B1"
|
|
192
|
+
})), /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.IconContainer, {
|
|
193
|
+
className: "IconContainer",
|
|
194
|
+
onClick: handleOpenCloseMenuClick
|
|
195
|
+
}, showOptions ? /*#__PURE__*/_react.default.createElement(_MenuItemUpIcon.MenuItemUpIcon, {
|
|
196
|
+
width: "12px",
|
|
197
|
+
height: "12px",
|
|
198
|
+
color: "#B1B1B1"
|
|
199
|
+
}) : /*#__PURE__*/_react.default.createElement(_MenuItemOpenIcon.MenuItemOpenIcon, {
|
|
200
|
+
width: "12px",
|
|
201
|
+
height: "12px",
|
|
202
|
+
color: "#B1B1B1"
|
|
203
|
+
}))), error && (errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.length) > 0 && /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.ErrorMessage, null, errorMessage), /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.OptionsContainer, {
|
|
204
|
+
className: "OptionsContainer",
|
|
205
|
+
onMouseEnter: () => setHoverOptionsContainer(true),
|
|
206
|
+
onMouseLeave: () => setHoverOptionsContainer(false),
|
|
207
|
+
showoptions: showOptions,
|
|
208
|
+
disabled: disabled,
|
|
209
|
+
filteredoptions: filteredoptions
|
|
210
|
+
}, /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.OptionsSubContainer, {
|
|
211
|
+
className: "OptionsSubContainer",
|
|
212
|
+
showoptions: showOptions,
|
|
213
|
+
disabled: disabled,
|
|
214
|
+
filteredoptions: filteredoptions
|
|
215
|
+
}, filteredoptions.map(option => /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.OptionItem, {
|
|
216
|
+
className: "OptionItem",
|
|
217
|
+
key: option.value,
|
|
218
|
+
onClick: () => toggleOption(option),
|
|
219
|
+
selected: isDropdowned(option)
|
|
220
|
+
}, ' ', /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.IconContainer, {
|
|
221
|
+
className: "IconContainer"
|
|
222
|
+
}, selectedOptions.find(itemSelectedOptions => option.value === itemSelectedOptions.value) ? /*#__PURE__*/_react.default.createElement(_CheckBoxCheckedIcon.CheckBoxCheckedIcon, {
|
|
223
|
+
width: "14px",
|
|
224
|
+
height: "14px",
|
|
225
|
+
color: disabled ? '#888' : checkBoxColor
|
|
226
|
+
}) : /*#__PURE__*/_react.default.createElement(_CheckBoxNotCheckedIcon.CheckBoxNotCheckedIcon, {
|
|
227
|
+
width: "14px",
|
|
228
|
+
height: "14px",
|
|
229
|
+
color: disabled ? '#888' : '#212121'
|
|
230
|
+
})), option.label)))));
|
|
231
|
+
};
|
|
232
|
+
exports.DropdownMultiNew = DropdownMultiNew;
|
|
233
|
+
var _default = exports.default = DropdownMultiNew;
|
|
234
|
+
DropdownMultiNew.defaultProps = {
|
|
235
|
+
placeHolder: 'Type...',
|
|
236
|
+
label: 'Label',
|
|
237
|
+
labelEmptyValue: 'All Labels',
|
|
238
|
+
labelColor: '#066768',
|
|
239
|
+
checkBoxColor: '#229E38',
|
|
240
|
+
required: true,
|
|
241
|
+
width: '300px',
|
|
242
|
+
disabled: false,
|
|
243
|
+
error: false,
|
|
244
|
+
errorMessage: '',
|
|
245
|
+
options: [],
|
|
246
|
+
selectedValue: [],
|
|
247
|
+
onChange: () => {}
|
|
248
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.StyledInput = exports.SelectedOptionsContainer = exports.SelectedOptionItem = exports.OptionsSubContainer = exports.OptionsContainer = exports.OptionItem = exports.Label = exports.InputSubContainer = exports.InputContainer = exports.IconContainer = exports.ErrorMessage = exports.DropdownWrapper = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
9
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
|
11
|
+
/* eslint-disable no-nested-ternary */
|
|
12
|
+
const DropdownWrapper = exports.DropdownWrapper = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n display: flex;\n flex-direction: column;\n align-content: center;\n justify-content: center;\n align-items: flex-start;\n width: ", "; \n font-family: \"Poppins\", sans-serif;\n font-weight: 400;\n font-size: 14px;\n border-radius: 10px;\n"])), props => props.width || '300px');
|
|
13
|
+
const Label = exports.Label = _styledComponents.default.label(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n\n font-size: ", ";\n font-weight: 400;\n padding-inline-end: 5px;\n padding-inline-start: 5px;\n margin-right: 10px;\n z-index: 2;\n color: ", ";\n background-color: white;\n position: absolute;\n top: ", ";\n left: ", ";\n font-family: Poppins; \n transform: translateY(-50%);\n transition: top 0.3s ease, font-size 0.3s ease, color 0.3s ease;\n display: flex;\n align-items: center;\n box-sizing: border-box;\n gap: 4px;\n &:focus {\n border-radius: 12px 12px 0 0 ;\n }\n"])), props => props.isFocused || props.hasValue ? '14px' : '14px', props => props.error ? 'red' : props.disabled ? '#888' : props.labelColor, props => props.isFocused || props.hasValue ? '0px' : '27px', props => props.isFocused || props.hasValue ? '23px' : '10px');
|
|
14
|
+
const InputContainer = exports.InputContainer = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n\n display: flex; \n flex-direction: row;\n flex-wrap: nowrap; \n justify-content: flex-start;\n align-content: center; \n white-space: pre-wrap;\n align-items: center;\n overflow: hidden;\n padding: 0 5px 0 0;\n gap: 4px;\n width: 100%;\n height: 100%; \n box-sizing: border-box;\n background-color: #fff;\n border: ", " solid ", ";\n font-family: \"Poppins\", sans-serif;\n font-weight: 400;\n font-size: 14px;\n border-radius: 12px;\n outline: none;\n color: ", ";\n \n &:hover {\n border: 2px solid ", ";\n }\n\n &:focus { \n border: 2px solid ", "; \n }\n \n"])), props => props.isFocused ? '2px' : '1px', props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.labelColor, props => props.disabled ? '#888' : '#212121', props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.labelColor || '#212121', props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.labelColor || '#212121');
|
|
15
|
+
const InputSubContainer = exports.InputSubContainer = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n\n display: flex; \n flex-direction: column;\n flex-wrap: nowrap; \n align-content: center; \n align-items: flex-start;\n justify-content: center;\n white-space: pre-wrap;\n overflow: hidden;\n padding: 10px 4px 10px 10px;\n width: 100%;\n height: 100%;\n min-height: 53px;\n box-sizing: border-box;\n background-color: #fff; \n border-radius: 12px;\n outline: none;\n color: ", "; \n"])), props => props.disabled ? '#888' : '#212121');
|
|
16
|
+
const StyledInput = exports.StyledInput = _styledComponents.default.input(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n width: calc(100% - 20px);\n height: 25px;\n font-family: Poppins;\n font-weight: 400;\n font-size: 14px;\n outline: none; \n color: ", "; \n border: none; \n"])), props => props.disabled ? '#888' : '#212121');
|
|
17
|
+
const OptionsContainer = exports.OptionsContainer = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)([" \n margin: 0; \n top: 100%; \n left: 0;\n z-index: 10;\n width: 100%;\n height: 8px;\n background-color: #fff; \n display: ", "; \n"])), props => {
|
|
18
|
+
var _props$filteredoption;
|
|
19
|
+
return props.showoptions && ((_props$filteredoption = props.filteredoptions) === null || _props$filteredoption === void 0 ? void 0 : _props$filteredoption.length) > 0 ? 'block' : 'none';
|
|
20
|
+
});
|
|
21
|
+
const OptionsSubContainer = exports.OptionsSubContainer = _styledComponents.default.ul(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n list-style: none;\n font-weight: 400;\n margin: 0;\n padding: 8px 12px;\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 10;\n width: calc(100% - 23px);\n font-family: Poppins; \n border-radius: 4px; \n background-color: #fff; \n display: ", ";\n box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.1);\n"])), props => {
|
|
22
|
+
var _props$filteredoption2;
|
|
23
|
+
return props.showoptions && ((_props$filteredoption2 = props.filteredoptions) === null || _props$filteredoption2 === void 0 ? void 0 : _props$filteredoption2.length) > 0 ? 'block' : 'none';
|
|
24
|
+
});
|
|
25
|
+
const OptionItem = exports.OptionItem = _styledComponents.default.li(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)([" \n display: flex;\n flex-direction: row;\n justify-content: flex-start;\n align-items: center;\n gap: 8px;\n padding: 10px;\n cursor: pointer;\n color: #212121;\n font-family: Poppins;\n font-size: 14px;\n font-style: normal;\n font-weight: 400;\n transition: background-color 0.3s;\n\n &:hover {\n background-color: #EDF6FF;\n }\n"])));
|
|
26
|
+
const ErrorMessage = exports.ErrorMessage = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 12px;\n color: red;\n margin-top: 5px;\n"])));
|
|
27
|
+
const SelectedOptionsContainer = exports.SelectedOptionsContainer = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n display: flex; \n flex-direction: row;\n flex-wrap: nowrap; \n justify-content: flex-start;\n align-content: center; \n align-items: center;\n white-space: pre-wrap;\n overflow: hidden;\n padding: 0;\n font-weight: 400;\n border-top: none;\n border-radius: 4px; \n background-color: #fff; \n gap: 4px; \n"])));
|
|
28
|
+
const SelectedOptionItem = exports.SelectedOptionItem = _styledComponents.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)([" \n display: flex; \n margin: 0;\n flex-wrap: nowrap; \n white-space: pre-wrap;\n overflow: hidden;\n cursor: pointer;\n color: #212121;\n background-color: #E3E4E5;\n border-radius: 4px; \n align-items: center;\n padding: 4px 6px;\n font-size: 12px;\n"])));
|
|
29
|
+
const IconContainer = exports.IconContainer = _styledComponents.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)([" \n display: flex; \n padding: 2px;\n cursor: pointer; \n"])));
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.DropdownNew = void 0;
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _DropdownSingleNew = require("./DropdownSingleNew");
|
|
10
|
+
var _DropdownMultiNew = require("./DropdownMultiNew");
|
|
9
11
|
var _DropdownNew = require("./DropdownNew.style");
|
|
10
12
|
/* eslint-disable react/prop-types */
|
|
11
13
|
|
|
@@ -13,132 +15,68 @@ const DropdownNew = _ref => {
|
|
|
13
15
|
let {
|
|
14
16
|
isMulti,
|
|
15
17
|
label,
|
|
18
|
+
labelEmptyValue,
|
|
16
19
|
options,
|
|
17
|
-
|
|
20
|
+
selectedValue,
|
|
18
21
|
placeHolder,
|
|
19
22
|
onChange,
|
|
20
23
|
required,
|
|
21
|
-
borderRadius,
|
|
22
24
|
disabled,
|
|
23
25
|
width,
|
|
24
|
-
height,
|
|
25
26
|
error,
|
|
26
27
|
errorMessage,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
labelFontColor,
|
|
30
|
-
radius
|
|
28
|
+
labelColor,
|
|
29
|
+
checkBoxColor
|
|
31
30
|
} = _ref;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const [inputValue, setInputValue] = (0, _react.useState)('');
|
|
35
|
-
const [selectedOptions, setDropdownedOptions] = (0, _react.useState)([]);
|
|
36
|
-
const inputRef = (0, _react.useRef)(null);
|
|
37
|
-
const filteredoptions = options.filter(option => option.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
38
|
-
const handleFocus = () => {
|
|
39
|
-
setIsFocused(true);
|
|
40
|
-
setShowOptions(true);
|
|
41
|
-
};
|
|
42
|
-
const handleBlur = () => {
|
|
43
|
-
// if (isMulti) return;
|
|
44
|
-
setIsFocused(false);
|
|
45
|
-
setTimeout(() => setShowOptions(false), 200); // Delay hiding options to allow clicking on them
|
|
46
|
-
};
|
|
47
|
-
const handleOptionClick = option => {
|
|
48
|
-
onChange({
|
|
49
|
-
target: {
|
|
50
|
-
value: option.value
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
setIsFocused(true);
|
|
54
|
-
setShowOptions(false);
|
|
55
|
-
setInputValue(option.label);
|
|
56
|
-
};
|
|
57
|
-
const handleInputChange = e => {
|
|
58
|
-
onChange({
|
|
59
|
-
target: {
|
|
60
|
-
value: e.target.value
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
handleOptionClick(e.target.value);
|
|
64
|
-
setInputValue(e.target.value);
|
|
65
|
-
};
|
|
66
|
-
const toggleOption = option => {
|
|
67
|
-
const selectedIndex = selectedOptions.findIndex(selectedOption => selectedOption.value === option.value);
|
|
68
|
-
if (selectedIndex === -1) {
|
|
69
|
-
setDropdownedOptions([...selectedOptions, option]);
|
|
70
|
-
} else {
|
|
71
|
-
const newDropdownedOptions = [...selectedOptions];
|
|
72
|
-
newDropdownedOptions.splice(selectedIndex, 1);
|
|
73
|
-
setDropdownedOptions(newDropdownedOptions);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const isDropdowned = option => selectedOptions.some(selectedOption => selectedOption.value === option.value);
|
|
77
|
-
console.log('props', showOptions, filteredoptions === null || filteredoptions === void 0 ? void 0 : filteredoptions.length);
|
|
78
|
-
return /*#__PURE__*/_react.default.createElement(_DropdownNew.DropdownWrapper, {
|
|
79
|
-
className: "DropdownWrapper",
|
|
31
|
+
return /*#__PURE__*/_react.default.createElement(_DropdownNew.DropdownMain, {
|
|
32
|
+
className: "DropdownMain",
|
|
80
33
|
width: width
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
34
|
+
}, isMulti ? /*#__PURE__*/_react.default.createElement(_DropdownMultiNew.DropdownMultiNew, {
|
|
35
|
+
className: "DropdownMultiNew",
|
|
36
|
+
placeHolder: placeHolder,
|
|
37
|
+
label: label,
|
|
38
|
+
labelEmptyValue: labelEmptyValue,
|
|
39
|
+
labelColor: labelColor,
|
|
40
|
+
checkBoxColor: checkBoxColor,
|
|
41
|
+
required: required,
|
|
42
|
+
options: options,
|
|
43
|
+
width: width,
|
|
88
44
|
disabled: disabled,
|
|
89
|
-
error: error
|
|
90
|
-
}, label, required && /*#__PURE__*/_react.default.createElement("span", {
|
|
91
|
-
style: {
|
|
92
|
-
color: 'red'
|
|
93
|
-
}
|
|
94
|
-
}, "*")), /*#__PURE__*/_react.default.createElement(_DropdownNew.StyledInput, {
|
|
95
|
-
className: "StyledInput",
|
|
96
|
-
ref: inputRef,
|
|
97
|
-
radius: radius,
|
|
98
|
-
labelFontColor: labelFontColor,
|
|
99
|
-
borderColor: borderColor,
|
|
100
|
-
borderColorFoucs: borderColorFoucs,
|
|
101
|
-
value: inputValue,
|
|
102
|
-
onChange: handleInputChange,
|
|
103
|
-
onFocus: handleFocus,
|
|
104
|
-
onBlur: handleBlur,
|
|
105
|
-
type: "search",
|
|
106
|
-
disabled: disabled,
|
|
107
|
-
placeholder: isFocused ? placeHolder || 'Type to search...' : '',
|
|
108
|
-
style: {
|
|
109
|
-
width,
|
|
110
|
-
height
|
|
111
|
-
},
|
|
112
|
-
borderRadius: borderRadius,
|
|
113
45
|
error: error,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
46
|
+
errorMessage: errorMessage,
|
|
47
|
+
selectedValue: selectedValue,
|
|
48
|
+
onChange: onChange
|
|
49
|
+
}) : /*#__PURE__*/_react.default.createElement(_DropdownSingleNew.DropdownSingleNew, {
|
|
50
|
+
className: "DropdownSingleNew",
|
|
51
|
+
placeHolder: placeHolder,
|
|
52
|
+
label: label,
|
|
53
|
+
labelEmptyValue: labelEmptyValue,
|
|
54
|
+
labelColor: labelColor,
|
|
55
|
+
checkBoxColor: checkBoxColor,
|
|
56
|
+
required: required,
|
|
57
|
+
options: options,
|
|
58
|
+
width: width,
|
|
123
59
|
disabled: disabled,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
toggleOption(option);
|
|
130
|
-
setIsFocused(true);
|
|
131
|
-
},
|
|
132
|
-
selected: isDropdowned(option)
|
|
133
|
-
}, ' ', /*#__PURE__*/_react.default.createElement("input", {
|
|
134
|
-
type: "checkbox",
|
|
135
|
-
checked: isDropdowned(option),
|
|
136
|
-
onChange: () => toggleOption(option),
|
|
137
|
-
style: {
|
|
138
|
-
marginRight: '8px'
|
|
139
|
-
},
|
|
140
|
-
disabled: disabled
|
|
141
|
-
}), option.label))));
|
|
60
|
+
error: error,
|
|
61
|
+
errorMessage: errorMessage,
|
|
62
|
+
selectedValue: selectedValue,
|
|
63
|
+
onChange: onChange
|
|
64
|
+
}));
|
|
142
65
|
};
|
|
143
66
|
exports.DropdownNew = DropdownNew;
|
|
144
|
-
var _default = exports.default = DropdownNew;
|
|
67
|
+
var _default = exports.default = DropdownNew;
|
|
68
|
+
DropdownNew.defaultProps = {
|
|
69
|
+
placeHolder: 'Type...',
|
|
70
|
+
label: 'Label',
|
|
71
|
+
labelEmptyValue: 'All Labels',
|
|
72
|
+
labelColor: '#066768',
|
|
73
|
+
checkBoxColor: '#229E38',
|
|
74
|
+
required: true,
|
|
75
|
+
width: '300px',
|
|
76
|
+
disabled: false,
|
|
77
|
+
error: false,
|
|
78
|
+
errorMessage: '',
|
|
79
|
+
options: [],
|
|
80
|
+
selectedValue: [],
|
|
81
|
+
onChange: () => {}
|
|
82
|
+
};
|
|
@@ -4,17 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.DropdownMain = void 0;
|
|
8
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
9
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
|
-
var _templateObject
|
|
10
|
+
var _templateObject;
|
|
11
11
|
/* eslint-disable no-nested-ternary */
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const StyledInput = exports.StyledInput = _styledComponents.default.input(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n width: 200px;\n //height: 40px;\n padding: 16px;\n font-family: \"Poppins\", sans-serif;\n font-weight: 400;\n font-size: 14px;\n //line-height: 18px;\n /* border:\n ", "; */\n\n border: 1px solid ", ";\n border-radius: ", ";\n font-family: Poppins;\n outline: none;\n box-sizing: border-box;\n //color: ", ";\n color: ", ";\n \n &:hover {\n border: 1px solid ", ";\n\n // border-color: ", ";\n }\n\n &:focus {\n // border-radius: 12px 12px 0 0 ;\n // border-bottom: none;\n border: 2px solid ", ";\n //border-color: ", ";\n }\n\n"])), props => props.disabled ? '1px solid \'#bdbdbd\'' : props.error ? '1px solid \'red\'' : props.isFocused ? "2px solid ".concat(props.borderColorFocus) : "1px solid ".concat(props.borderColor) || '1px solid \'#bdbdbd\'', props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.borderColor, props => props.radius, props => props.disabled ? '#888' : '#333', props => props.disabled ? '#888' : (props.isFocused || props.value ? props.labelFontColor : '#757575') || '#333', props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.labelFontColor || '#bdbdbd', props => props.disabled ? '#bdbdbd' : props.borderColor || '#1976d2', props => props.disabled ? '#bdbdbd' : props.error ? 'red' : props.labelFontColor || '#bdbdbd', props => props.disabled ? '#bdbdbd' : props.borderColorFoucs);
|
|
15
|
-
const OptionsContainer = exports.OptionsContainer = _styledComponents.default.ul(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n list-style: none;\n font-weight: 400;\n margin: 0;\n padding: 0;\n position: absolute;\n top: calc(100% + 8px);\n left: 0;\n z-index: 10;\n width: 100%;\n font-family: Poppins;\n border-top: none;\n border-radius: 4px; \n background-color: #fff; \n display: ", ";\n box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.1);\n"])), props => {
|
|
16
|
-
var _props$filteredoption;
|
|
17
|
-
return props.showoptions && ((_props$filteredoption = props.filteredoptions) === null || _props$filteredoption === void 0 ? void 0 : _props$filteredoption.length) > 0 ? 'block' : 'none';
|
|
18
|
-
});
|
|
19
|
-
const OptionItem = exports.OptionItem = _styledComponents.default.li(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)([" \n padding: 10px 10px 10px 15px;\n cursor: pointer;\n color: rgba(33, 33, 33, 0.80);\n font-family: Poppins;\n font-size: 12px;\n font-style: normal;\n font-weight: 400;\n transition: background-color 0.3s;\n\n &:hover {\n background-color: #f0f0f0;\n }\n"])));
|
|
20
|
-
const ErrorMessage = exports.ErrorMessage = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 12px;\n color: red;\n margin-top: 5px;\n"])));
|
|
12
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
13
|
+
const DropdownMain = exports.DropdownMain = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n display: flex;\n flex-direction: column;\n align-content: center;\n justify-content: center;\n align-items: flex-start;\n width: ", "; \n font-family: \"Poppins\", sans-serif;\n font-weight: 400;\n font-size: 14px;\n border-radius: 10px;\n"])), props => props.width || '300px');
|