@stokr/components-library 2.3.64 → 2.3.65-beta.10
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/components/2FA/main-flow.js +28 -7
- package/dist/components/2FA/main-flow.stories.js +144 -15
- package/dist/components/AdminDashboard/Table/ReactTable.js +123 -7
- package/dist/components/AdminDashboard/Table/ReactTable.stories.js +509 -2
- package/dist/components/Chips/Chip.js +1 -2
- package/dist/components/Icon/Icon.stories.js +108 -0
- package/dist/components/InfoIcon/InfoIcon.js +9 -4
- package/dist/components/InfoIcon/InfoIcon.styles.js +3 -3
- package/dist/components/Input/Input.js +33 -33
- package/dist/components/Input/Input.stories.js +83 -8
- package/dist/components/Input/MultiSelect.js +319 -0
- package/dist/components/Input/MultiSelect.stories.js +264 -0
- package/dist/components/Input/SearchInput.js +78 -0
- package/dist/components/Input/SearchInput.stories.js +366 -0
- package/dist/components/Input/SearchInput.styles.js +25 -0
- package/dist/components/Input/Select.js +51 -28
- package/dist/components/Input/Select.stories.js +345 -6
- package/dist/components/Modal/SideModal.js +82 -0
- package/dist/components/Modal/SideModal.stories.js +342 -0
- package/dist/components/Modal/SideModal.styles.js +21 -0
- package/dist/components/Payment/PaymentDetailsCard.js +189 -0
- package/dist/components/Payment/PaymentDetailsCard.stories.js +198 -0
- package/dist/components/Payment/PaymentDisplay.js +2 -12
- package/dist/components/ProfileBox/ProfileBox.js +2 -1
- package/dist/components/Snackbar/Snackbar.js +193 -0
- package/dist/components/Snackbar/Snackbar.stories.js +292 -0
- package/dist/components/Snackbar/Snackbar.styles.js +97 -0
- package/dist/components/Snackbar/SnackbarProvider.js +81 -0
- package/dist/components/Snackbar/index.js +32 -0
- package/dist/components/Snackbar/useSnackbar.js +43 -0
- package/dist/components/StatusTag/StatusTag.js +175 -0
- package/dist/components/StatusTag/StatusTag.stories.js +262 -0
- package/dist/components/StatusTag/StatusTag.styles.js +37 -0
- package/dist/components/StepsProgress/StepIndicator.js +59 -0
- package/dist/components/StepsProgress/StepIndicator.stories.js +153 -0
- package/dist/components/StepsProgress/StepIndicator.styles.js +30 -0
- package/dist/components/TextLink/TextLink.stories.js +35 -0
- package/dist/components/TextLink/TextLink.styles.js +1 -1
- package/dist/components/Timeline/Timeline.js +0 -2
- package/dist/components/Timeline/TimelineStep.js +2 -2
- package/dist/components/logo/Logo.stories.js +260 -0
- package/dist/constants/globalVariables.js +41 -2
- package/dist/context/Checkbox/CheckboxContext.js +80 -7
- package/dist/index.js +66 -0
- package/dist/static/images/bmn2-logo.svg +9 -0
- package/dist/static/images/document-icon.svg +3 -0
- package/dist/static/images/plus-icon.svg +4 -0
- package/dist/static/images/search-icon.svg +3 -0
- package/dist/static/images/sent-icon.svg +10 -0
- package/dist/static/images/transfer-icon.svg +10 -0
- package/dist/utils/formatCurrencyValue.js +43 -3
- package/package.json +1 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithoutIcon = exports.WithInitialValue = exports.WithCustomIcon = exports.Variants = exports.Outlined = exports.LongText = exports.Disabled = exports.DifferentWidths = exports.Default = exports.CustomStyling = exports.CustomPlaceholder = exports.AllStates = exports.AccessibilityExample = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _SearchInput = _interopRequireDefault(require("./SearchInput"));
|
|
9
|
+
var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
|
|
10
|
+
var _colors = _interopRequireDefault(require("../../styles/colors"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
|
+
var _default = exports.default = {
|
|
15
|
+
title: 'Components Library/Inputs/SearchInput',
|
|
16
|
+
component: _SearchInput.default,
|
|
17
|
+
argTypes: {
|
|
18
|
+
value: {
|
|
19
|
+
control: 'text',
|
|
20
|
+
description: 'The search input value (controlled)'
|
|
21
|
+
},
|
|
22
|
+
onChange: {
|
|
23
|
+
action: 'changed',
|
|
24
|
+
description: 'Callback fired when the value changes'
|
|
25
|
+
},
|
|
26
|
+
placeholder: {
|
|
27
|
+
control: 'text',
|
|
28
|
+
description: 'Placeholder text',
|
|
29
|
+
defaultValue: 'Search'
|
|
30
|
+
},
|
|
31
|
+
variant: {
|
|
32
|
+
control: {
|
|
33
|
+
type: 'select'
|
|
34
|
+
},
|
|
35
|
+
options: ['filled', 'outlined'],
|
|
36
|
+
description: 'Visual variant of the input',
|
|
37
|
+
defaultValue: 'filled'
|
|
38
|
+
},
|
|
39
|
+
showIcon: {
|
|
40
|
+
control: 'boolean',
|
|
41
|
+
description: 'Show/hide the search icon',
|
|
42
|
+
defaultValue: true
|
|
43
|
+
},
|
|
44
|
+
disabled: {
|
|
45
|
+
control: 'boolean',
|
|
46
|
+
description: 'Disable the input',
|
|
47
|
+
defaultValue: false
|
|
48
|
+
},
|
|
49
|
+
icon: {
|
|
50
|
+
control: false,
|
|
51
|
+
description: 'Custom icon component (React node)'
|
|
52
|
+
},
|
|
53
|
+
onFocus: {
|
|
54
|
+
action: 'focused',
|
|
55
|
+
description: 'Callback fired when input receives focus'
|
|
56
|
+
},
|
|
57
|
+
onBlur: {
|
|
58
|
+
action: 'blurred',
|
|
59
|
+
description: 'Callback fired when input loses focus'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}; // Controlled component wrapper for stories
|
|
63
|
+
const ControlledSearchInput = args => {
|
|
64
|
+
const [value, setValue] = (0, _react.useState)(args.value || '');
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_SearchInput.default, _extends({}, args, {
|
|
66
|
+
value: value,
|
|
67
|
+
onChange: (newValue, e) => {
|
|
68
|
+
var _args$onChange;
|
|
69
|
+
setValue(newValue);
|
|
70
|
+
(_args$onChange = args.onChange) === null || _args$onChange === void 0 || _args$onChange.call(args, newValue, e);
|
|
71
|
+
}
|
|
72
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
73
|
+
style: {
|
|
74
|
+
marginTop: '12px',
|
|
75
|
+
fontSize: '12px',
|
|
76
|
+
color: _colors.default.grey2
|
|
77
|
+
}
|
|
78
|
+
}, "Current value: ", /*#__PURE__*/_react.default.createElement("strong", null, value || '(empty)')));
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Default example
|
|
82
|
+
const Default = exports.Default = ControlledSearchInput.bind({});
|
|
83
|
+
Default.args = {
|
|
84
|
+
placeholder: 'Search'
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// Without icon
|
|
88
|
+
const WithoutIcon = exports.WithoutIcon = ControlledSearchInput.bind({});
|
|
89
|
+
WithoutIcon.args = {
|
|
90
|
+
placeholder: 'Search',
|
|
91
|
+
showIcon: false
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// With custom placeholder
|
|
95
|
+
const CustomPlaceholder = exports.CustomPlaceholder = ControlledSearchInput.bind({});
|
|
96
|
+
CustomPlaceholder.args = {
|
|
97
|
+
placeholder: 'Search users, projects, or tags...'
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Disabled state
|
|
101
|
+
const Disabled = exports.Disabled = ControlledSearchInput.bind({});
|
|
102
|
+
Disabled.args = {
|
|
103
|
+
placeholder: 'Search',
|
|
104
|
+
value: 'Sample search text',
|
|
105
|
+
disabled: true
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// With initial value
|
|
109
|
+
const WithInitialValue = exports.WithInitialValue = ControlledSearchInput.bind({});
|
|
110
|
+
WithInitialValue.args = {
|
|
111
|
+
placeholder: 'Search',
|
|
112
|
+
value: 'Initial search term'
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// Custom icon example
|
|
116
|
+
const WithCustomIcon = () => {
|
|
117
|
+
const [value, setValue] = (0, _react.useState)('');
|
|
118
|
+
const CustomIcon = () => /*#__PURE__*/_react.default.createElement("svg", {
|
|
119
|
+
width: "20",
|
|
120
|
+
height: "20",
|
|
121
|
+
viewBox: "0 0 20 20",
|
|
122
|
+
fill: "none",
|
|
123
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
124
|
+
}, /*#__PURE__*/_react.default.createElement("circle", {
|
|
125
|
+
cx: "9",
|
|
126
|
+
cy: "9",
|
|
127
|
+
r: "6",
|
|
128
|
+
stroke: "currentColor",
|
|
129
|
+
strokeWidth: "2"
|
|
130
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
131
|
+
d: "M15 15L12 12",
|
|
132
|
+
stroke: "currentColor",
|
|
133
|
+
strokeWidth: "2"
|
|
134
|
+
}));
|
|
135
|
+
return /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
136
|
+
value: value,
|
|
137
|
+
onChange: setValue,
|
|
138
|
+
placeholder: "Search with custom icon",
|
|
139
|
+
icon: /*#__PURE__*/_react.default.createElement(CustomIcon, null)
|
|
140
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
141
|
+
style: {
|
|
142
|
+
marginTop: '12px',
|
|
143
|
+
fontSize: '12px',
|
|
144
|
+
color: _colors.default.grey2
|
|
145
|
+
}
|
|
146
|
+
}, "Current value: ", /*#__PURE__*/_react.default.createElement("strong", null, value || '(empty)')));
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// Different widths
|
|
150
|
+
exports.WithCustomIcon = WithCustomIcon;
|
|
151
|
+
const DifferentWidths = () => {
|
|
152
|
+
const [value1, setValue1] = (0, _react.useState)('');
|
|
153
|
+
const [value2, setValue2] = (0, _react.useState)('');
|
|
154
|
+
const [value3, setValue3] = (0, _react.useState)('');
|
|
155
|
+
return /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
156
|
+
style: {
|
|
157
|
+
marginBottom: '16px'
|
|
158
|
+
}
|
|
159
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
160
|
+
style: {
|
|
161
|
+
marginBottom: '8px',
|
|
162
|
+
fontSize: '14px'
|
|
163
|
+
}
|
|
164
|
+
}, "Full width"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
165
|
+
value: value1,
|
|
166
|
+
onChange: setValue1,
|
|
167
|
+
placeholder: "Search (full width)"
|
|
168
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
169
|
+
style: {
|
|
170
|
+
marginBottom: '16px',
|
|
171
|
+
maxWidth: '400px'
|
|
172
|
+
}
|
|
173
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
174
|
+
style: {
|
|
175
|
+
marginBottom: '8px',
|
|
176
|
+
fontSize: '14px'
|
|
177
|
+
}
|
|
178
|
+
}, "Max width 400px"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
179
|
+
value: value2,
|
|
180
|
+
onChange: setValue2,
|
|
181
|
+
placeholder: "Search (400px max)"
|
|
182
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
183
|
+
style: {
|
|
184
|
+
marginBottom: '16px',
|
|
185
|
+
maxWidth: '200px'
|
|
186
|
+
}
|
|
187
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
188
|
+
style: {
|
|
189
|
+
marginBottom: '8px',
|
|
190
|
+
fontSize: '14px'
|
|
191
|
+
}
|
|
192
|
+
}, "Max width 200px"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
193
|
+
value: value3,
|
|
194
|
+
onChange: setValue3,
|
|
195
|
+
placeholder: "Search (200px max)"
|
|
196
|
+
})));
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Long text example
|
|
200
|
+
exports.DifferentWidths = DifferentWidths;
|
|
201
|
+
const LongText = exports.LongText = ControlledSearchInput.bind({});
|
|
202
|
+
LongText.args = {
|
|
203
|
+
placeholder: 'Search',
|
|
204
|
+
value: 'This is a very long search query that might overflow the input field'
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// All states
|
|
208
|
+
const AllStates = () => {
|
|
209
|
+
const [value1, setValue1] = (0, _react.useState)('');
|
|
210
|
+
const [value2, setValue2] = (0, _react.useState)('');
|
|
211
|
+
const [value3, setValue3] = (0, _react.useState)('Sample text');
|
|
212
|
+
const [value4, setValue4] = (0, _react.useState)('Disabled with text');
|
|
213
|
+
return /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
214
|
+
style: {
|
|
215
|
+
marginBottom: '24px'
|
|
216
|
+
}
|
|
217
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
218
|
+
style: {
|
|
219
|
+
marginBottom: '8px',
|
|
220
|
+
fontSize: '14px'
|
|
221
|
+
}
|
|
222
|
+
}, "Empty (default)"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
223
|
+
value: value1,
|
|
224
|
+
onChange: setValue1,
|
|
225
|
+
placeholder: "Search"
|
|
226
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
227
|
+
style: {
|
|
228
|
+
marginBottom: '24px'
|
|
229
|
+
}
|
|
230
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
231
|
+
style: {
|
|
232
|
+
marginBottom: '8px',
|
|
233
|
+
fontSize: '14px'
|
|
234
|
+
}
|
|
235
|
+
}, "Without icon"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
236
|
+
value: value2,
|
|
237
|
+
onChange: setValue2,
|
|
238
|
+
placeholder: "Search",
|
|
239
|
+
showIcon: false
|
|
240
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
241
|
+
style: {
|
|
242
|
+
marginBottom: '24px'
|
|
243
|
+
}
|
|
244
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
245
|
+
style: {
|
|
246
|
+
marginBottom: '8px',
|
|
247
|
+
fontSize: '14px'
|
|
248
|
+
}
|
|
249
|
+
}, "With value"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
250
|
+
value: value3,
|
|
251
|
+
onChange: setValue3,
|
|
252
|
+
placeholder: "Search"
|
|
253
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
254
|
+
style: {
|
|
255
|
+
marginBottom: '24px'
|
|
256
|
+
}
|
|
257
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
258
|
+
style: {
|
|
259
|
+
marginBottom: '8px',
|
|
260
|
+
fontSize: '14px'
|
|
261
|
+
}
|
|
262
|
+
}, "Disabled"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
263
|
+
value: value4,
|
|
264
|
+
onChange: setValue4,
|
|
265
|
+
placeholder: "Search",
|
|
266
|
+
disabled: true
|
|
267
|
+
})));
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// Accessibility example
|
|
271
|
+
exports.AllStates = AllStates;
|
|
272
|
+
const AccessibilityExample = exports.AccessibilityExample = ControlledSearchInput.bind({});
|
|
273
|
+
AccessibilityExample.args = {
|
|
274
|
+
placeholder: 'Search',
|
|
275
|
+
'aria-label': 'Search for products',
|
|
276
|
+
'aria-describedby': 'search-help-text'
|
|
277
|
+
};
|
|
278
|
+
AccessibilityExample.decorators = [Story => /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(Story, null), /*#__PURE__*/_react.default.createElement("div", {
|
|
279
|
+
id: "search-help-text",
|
|
280
|
+
style: {
|
|
281
|
+
marginTop: '8px',
|
|
282
|
+
fontSize: '12px',
|
|
283
|
+
color: _colors.default.grey2
|
|
284
|
+
}
|
|
285
|
+
}, "Use this search to find products by name, category, or description."))];
|
|
286
|
+
|
|
287
|
+
// Outlined variant
|
|
288
|
+
const Outlined = () => {
|
|
289
|
+
const [value, setValue] = (0, _react.useState)('');
|
|
290
|
+
return /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
291
|
+
value: value,
|
|
292
|
+
onChange: setValue,
|
|
293
|
+
placeholder: "Search",
|
|
294
|
+
variant: "outlined"
|
|
295
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
296
|
+
style: {
|
|
297
|
+
marginTop: '12px',
|
|
298
|
+
fontSize: '12px',
|
|
299
|
+
color: _colors.default.grey2
|
|
300
|
+
}
|
|
301
|
+
}, "Current value: ", /*#__PURE__*/_react.default.createElement("strong", null, value || '(empty)')));
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// Both variants side by side
|
|
305
|
+
exports.Outlined = Outlined;
|
|
306
|
+
const Variants = () => {
|
|
307
|
+
const [value1, setValue1] = (0, _react.useState)('');
|
|
308
|
+
const [value2, setValue2] = (0, _react.useState)('');
|
|
309
|
+
return /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
310
|
+
style: {
|
|
311
|
+
marginBottom: '24px'
|
|
312
|
+
}
|
|
313
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
314
|
+
style: {
|
|
315
|
+
marginBottom: '8px',
|
|
316
|
+
fontSize: '14px'
|
|
317
|
+
}
|
|
318
|
+
}, "Filled (default)"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
319
|
+
value: value1,
|
|
320
|
+
onChange: setValue1,
|
|
321
|
+
placeholder: "Search",
|
|
322
|
+
variant: "filled"
|
|
323
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
324
|
+
style: {
|
|
325
|
+
marginBottom: '24px'
|
|
326
|
+
}
|
|
327
|
+
}, /*#__PURE__*/_react.default.createElement("h4", {
|
|
328
|
+
style: {
|
|
329
|
+
marginBottom: '8px',
|
|
330
|
+
fontSize: '14px'
|
|
331
|
+
}
|
|
332
|
+
}, "Outlined"), /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
333
|
+
value: value2,
|
|
334
|
+
onChange: setValue2,
|
|
335
|
+
placeholder: "Search",
|
|
336
|
+
variant: "outlined"
|
|
337
|
+
})));
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// Custom styling
|
|
341
|
+
exports.Variants = Variants;
|
|
342
|
+
const CustomStyling = () => {
|
|
343
|
+
const [value, setValue] = (0, _react.useState)('');
|
|
344
|
+
return /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(_SearchInput.default, {
|
|
345
|
+
value: value,
|
|
346
|
+
onChange: setValue,
|
|
347
|
+
placeholder: "Search with custom styling",
|
|
348
|
+
containerStyle: {
|
|
349
|
+
maxWidth: '500px',
|
|
350
|
+
margin: '0 auto'
|
|
351
|
+
},
|
|
352
|
+
inputStyle: {
|
|
353
|
+
fontSize: '16px'
|
|
354
|
+
},
|
|
355
|
+
iconStyle: {
|
|
356
|
+
color: _colors.default.blue
|
|
357
|
+
}
|
|
358
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
359
|
+
style: {
|
|
360
|
+
marginTop: '12px',
|
|
361
|
+
fontSize: '12px',
|
|
362
|
+
color: _colors.default.grey2
|
|
363
|
+
}
|
|
364
|
+
}, "Current value: ", /*#__PURE__*/_react.default.createElement("strong", null, value || '(empty)')));
|
|
365
|
+
};
|
|
366
|
+
exports.CustomStyling = CustomStyling;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SearchInputWrapper = exports.SearchInputField = exports.SearchInputContainer = exports.SearchIconWrapper = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
+
var _colors = _interopRequireDefault(require("../../styles/colors"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const SearchInputContainer = exports.SearchInputContainer = _styledComponents.default.div.withConfig({
|
|
11
|
+
displayName: "SearchInputstyles__SearchInputContainer",
|
|
12
|
+
componentId: "sc-dcxztv-0"
|
|
13
|
+
})(["width:100%;display:flex;"]);
|
|
14
|
+
const SearchInputWrapper = exports.SearchInputWrapper = _styledComponents.default.div.withConfig({
|
|
15
|
+
displayName: "SearchInputstyles__SearchInputWrapper",
|
|
16
|
+
componentId: "sc-dcxztv-1"
|
|
17
|
+
})(["position:relative;display:flex;align-items:center;width:100%;border-radius:8px;padding:0 16px;min-height:40px;transition:all 0.2s ease;background-color:", ";border:", ";", " &:focus-within{background-color:", ";border-color:", ";box-shadow:", ";}&:hover{border-color:", ";}"], props => props.variant === 'outlined' ? 'transparent' : _colors.default.grey3, props => props.variant === 'outlined' ? "1px solid ".concat(_colors.default.lightGrey) : '1px solid transparent', props => props.disabled && "\n opacity: 0.6;\n cursor: not-allowed;\n ", props => props.variant === 'outlined' ? 'transparent' : _colors.default.white, props => props.variant === 'outlined' ? _colors.default.grey2 : 'transparent', props => props.variant === 'outlined' ? 'none' : "0 0 0 2px ".concat(_colors.default.lightGrey), props => props.variant === 'outlined' ? _colors.default.grey2 : 'transparent');
|
|
18
|
+
const SearchIconWrapper = exports.SearchIconWrapper = _styledComponents.default.div.withConfig({
|
|
19
|
+
displayName: "SearchInputstyles__SearchIconWrapper",
|
|
20
|
+
componentId: "sc-dcxztv-2"
|
|
21
|
+
})(["display:flex;align-items:center;justify-content:center;margin-right:12px;color:", ";flex-shrink:0;width:16px;height:16px;svg{width:100%;height:100%;}", ":focus-within &{color:", ";}"], _colors.default.grey2, SearchInputWrapper, _colors.default.black);
|
|
22
|
+
const SearchInputField = exports.SearchInputField = _styledComponents.default.input.withConfig({
|
|
23
|
+
displayName: "SearchInputstyles__SearchInputField",
|
|
24
|
+
componentId: "sc-dcxztv-3"
|
|
25
|
+
})(["flex:1;border:none;outline:none;background:transparent;font-size:14px;font-weight:400;line-height:18px;color:", ";width:100%;min-width:0;letter-spacing:0.6px;&::placeholder{color:", ";opacity:1;}&:disabled{cursor:not-allowed;opacity:0.6;}&::-webkit-search-decoration,&::-webkit-search-cancel-button,&::-webkit-search-results-button,&::-webkit-search-results-decoration{-webkit-appearance:none;}"], _colors.default.black, _colors.default.grey2);
|
|
@@ -7,9 +7,10 @@ exports.default = exports.Select = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _reactSelect = _interopRequireWildcard(require("react-select"));
|
|
10
|
+
var _creatable = _interopRequireDefault(require("react-select/creatable"));
|
|
10
11
|
var _Input = require("./Input.styles");
|
|
11
12
|
var _Select = require("./Select.styles");
|
|
12
|
-
const _excluded = ["id", "name", "label", "options", "search", "error", "touched", "value", "disabled", "menuHeight"];
|
|
13
|
+
const _excluded = ["id", "name", "label", "options", "search", "error", "touched", "value", "disabled", "menuHeight", "creatable", "formatCreateLabel"];
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
16
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
@@ -59,7 +60,9 @@ const Select = props => {
|
|
|
59
60
|
touched,
|
|
60
61
|
value,
|
|
61
62
|
disabled,
|
|
62
|
-
menuHeight
|
|
63
|
+
menuHeight,
|
|
64
|
+
creatable,
|
|
65
|
+
formatCreateLabel
|
|
63
66
|
} = props,
|
|
64
67
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
65
68
|
const [labelUp, setLabelUp] = (0, _react.useState)(!!value);
|
|
@@ -72,7 +75,7 @@ const Select = props => {
|
|
|
72
75
|
name,
|
|
73
76
|
value
|
|
74
77
|
});
|
|
75
|
-
if (search) {
|
|
78
|
+
if (search || creatable) {
|
|
76
79
|
setHasFocus(true);
|
|
77
80
|
}
|
|
78
81
|
};
|
|
@@ -94,12 +97,46 @@ const Select = props => {
|
|
|
94
97
|
setHasFocus(true);
|
|
95
98
|
}, 1);
|
|
96
99
|
};
|
|
100
|
+
|
|
101
|
+
// Choose component based on creatable prop
|
|
102
|
+
const SelectComponent = creatable ? _creatable.default : _reactSelect.default;
|
|
103
|
+
|
|
104
|
+
// Common styles for both components
|
|
105
|
+
const selectStyles = {
|
|
106
|
+
control: () => _Select.SelectControl,
|
|
107
|
+
menu: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
108
|
+
marginTop: 0,
|
|
109
|
+
zIndex: 1000,
|
|
110
|
+
SelectMenu: _Select.SelectMenu
|
|
111
|
+
}),
|
|
112
|
+
option: (baseStyle, state) => _objectSpread({
|
|
113
|
+
fontWeight: state.isSelected || state.isFocused ? 'bold' : 'normal',
|
|
114
|
+
cursor: 'pointer'
|
|
115
|
+
}, _Select.SelectOption),
|
|
116
|
+
selectContainer: () => _Select.SelectContainer,
|
|
117
|
+
valueContainer: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
118
|
+
padding: 0
|
|
119
|
+
})
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Common components for both
|
|
123
|
+
const selectComponents = {
|
|
124
|
+
DropdownIndicator,
|
|
125
|
+
IndicatorSeparator: null,
|
|
126
|
+
MenuList: SelectMenuListWithScroll
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Get current value - for creatable, also check if value exists even if not in options
|
|
130
|
+
const currentValue = creatable ? (options === null || options === void 0 ? void 0 : options.find(option => option.value === value)) || (value ? {
|
|
131
|
+
value,
|
|
132
|
+
label: value
|
|
133
|
+
} : null) : options === null || options === void 0 ? void 0 : options.find(option => option.value === value);
|
|
97
134
|
return /*#__PURE__*/_react.default.createElement(_Input.Wrapper, null, label && /*#__PURE__*/_react.default.createElement(_Input.Label, {
|
|
98
135
|
isUp: labelUp,
|
|
99
136
|
active: hasFocus,
|
|
100
137
|
error: error && touched,
|
|
101
138
|
htmlFor: id
|
|
102
|
-
}, label), /*#__PURE__*/_react.default.createElement(
|
|
139
|
+
}, label), /*#__PURE__*/_react.default.createElement(SelectComponent, _extends({}, otherProps, {
|
|
103
140
|
id: id,
|
|
104
141
|
name: name,
|
|
105
142
|
options: options,
|
|
@@ -107,32 +144,14 @@ const Select = props => {
|
|
|
107
144
|
onChange: onChange,
|
|
108
145
|
onBlur: onBlur,
|
|
109
146
|
onFocus: onFocus,
|
|
110
|
-
value:
|
|
147
|
+
value: currentValue,
|
|
111
148
|
placeholder: "",
|
|
112
|
-
isSearchable: search,
|
|
149
|
+
isSearchable: creatable || search,
|
|
113
150
|
maxMenuHeight: menuHeight,
|
|
114
|
-
styles:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
zIndex: 1000,
|
|
119
|
-
SelectMenu: _Select.SelectMenu
|
|
120
|
-
}),
|
|
121
|
-
option: (baseStyle, state) => _objectSpread({
|
|
122
|
-
fontWeight: state.isSelected || state.isFocused ? 'bold' : 'normal',
|
|
123
|
-
cursor: 'pointer'
|
|
124
|
-
}, _Select.SelectOption),
|
|
125
|
-
selectContainer: () => _Select.SelectContainer,
|
|
126
|
-
valueContainer: baseStyle => _objectSpread(_objectSpread({}, baseStyle), {}, {
|
|
127
|
-
padding: 0
|
|
128
|
-
//marginLeft: '-2px',
|
|
129
|
-
})
|
|
130
|
-
},
|
|
131
|
-
components: {
|
|
132
|
-
DropdownIndicator,
|
|
133
|
-
IndicatorSeparator: null,
|
|
134
|
-
MenuList: SelectMenuListWithScroll
|
|
135
|
-
}
|
|
151
|
+
styles: selectStyles,
|
|
152
|
+
components: selectComponents
|
|
153
|
+
}, creatable && {
|
|
154
|
+
formatCreateLabel: formatCreateLabel || (inputValue => "Create \"".concat(inputValue, "\""))
|
|
136
155
|
})));
|
|
137
156
|
};
|
|
138
157
|
exports.Select = Select;
|
|
@@ -149,6 +168,8 @@ Select.propTypes = {
|
|
|
149
168
|
label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired
|
|
150
169
|
})).isRequired,
|
|
151
170
|
search: _propTypes.default.bool,
|
|
171
|
+
creatable: _propTypes.default.bool,
|
|
172
|
+
formatCreateLabel: _propTypes.default.func,
|
|
152
173
|
onChange: _propTypes.default.func,
|
|
153
174
|
onBlur: _propTypes.default.func,
|
|
154
175
|
onFocus: _propTypes.default.func
|
|
@@ -157,6 +178,8 @@ Select.defaultProps = {
|
|
|
157
178
|
label: '',
|
|
158
179
|
value: '',
|
|
159
180
|
search: false,
|
|
181
|
+
creatable: false,
|
|
182
|
+
formatCreateLabel: null,
|
|
160
183
|
error: false,
|
|
161
184
|
touched: false,
|
|
162
185
|
onChange: () => {},
|