@stokr/components-library 2.3.65-beta.1 → 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/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/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 +0 -1
- 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
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.SelectOptionStrings = exports.SelectOptionNodes = exports.SelectEmpty = void 0;
|
|
7
|
-
var _react =
|
|
6
|
+
exports.default = exports.SelectOptionStrings = exports.SelectOptionNodes = exports.SelectEmpty = exports.Searchable = exports.NotSearchable = exports.CreatableCustomLabel = exports.Creatable = exports.AllStates = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _Select = require("./Select");
|
|
9
9
|
var _ComponentWrapper = require("../ComponentWrapper/ComponentWrapper.styles");
|
|
10
10
|
var _Medium = require("../icons/Medium");
|
|
@@ -12,9 +12,12 @@ var _Share = require("../icons/Share");
|
|
|
12
12
|
var _Number = require("../Number/Number");
|
|
13
13
|
var _global = _interopRequireDefault(require("../../styles/global"));
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
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); }
|
|
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); }
|
|
15
17
|
var _default = exports.default = {
|
|
16
18
|
title: 'Components Library/Inputs/Select',
|
|
17
19
|
component: _Select.Select,
|
|
20
|
+
decorators: [Story => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_global.default, null), /*#__PURE__*/_react.default.createElement(_ComponentWrapper.ComponentWrapper, null, /*#__PURE__*/_react.default.createElement(Story, null)))],
|
|
18
21
|
argTypes: {
|
|
19
22
|
id: {
|
|
20
23
|
type: 'string',
|
|
@@ -55,7 +58,6 @@ var _default = exports.default = {
|
|
|
55
58
|
}],
|
|
56
59
|
required: true
|
|
57
60
|
},
|
|
58
|
-
// { required: true },
|
|
59
61
|
search: {
|
|
60
62
|
type: 'boolean',
|
|
61
63
|
defaultValue: false
|
|
@@ -79,8 +81,21 @@ var _default = exports.default = {
|
|
|
79
81
|
type: 'function'
|
|
80
82
|
}
|
|
81
83
|
}
|
|
84
|
+
}; // Controlled wrapper for interactive stories
|
|
85
|
+
const ControlledSelect = props => {
|
|
86
|
+
const [value, setValue] = (0, _react.useState)(props.value || '');
|
|
87
|
+
return /*#__PURE__*/_react.default.createElement(_Select.Select, _extends({}, props, {
|
|
88
|
+
value: value,
|
|
89
|
+
onChange: _ref => {
|
|
90
|
+
let {
|
|
91
|
+
value: newValue
|
|
92
|
+
} = _ref;
|
|
93
|
+
setValue(newValue);
|
|
94
|
+
console.log('Selected:', newValue);
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
82
97
|
};
|
|
83
|
-
const Template = args => /*#__PURE__*/_react.default.createElement(
|
|
98
|
+
const Template = args => /*#__PURE__*/_react.default.createElement(ControlledSelect, args);
|
|
84
99
|
const SelectOptionStrings = exports.SelectOptionStrings = Template.bind({});
|
|
85
100
|
SelectOptionStrings.args = {
|
|
86
101
|
label: 'click LABEL here for options',
|
|
@@ -134,6 +149,330 @@ SelectOptionNodes.args = {
|
|
|
134
149
|
const SelectEmpty = exports.SelectEmpty = Template.bind({});
|
|
135
150
|
SelectEmpty.args = {};
|
|
136
151
|
|
|
137
|
-
//
|
|
152
|
+
// Searchable Select - type to filter options
|
|
153
|
+
const Searchable = () => {
|
|
154
|
+
const [value, setValue] = (0, _react.useState)('');
|
|
155
|
+
const countryOptions = [{
|
|
156
|
+
key: 'us',
|
|
157
|
+
value: 'us',
|
|
158
|
+
label: 'United States'
|
|
159
|
+
}, {
|
|
160
|
+
key: 'uk',
|
|
161
|
+
value: 'uk',
|
|
162
|
+
label: 'United Kingdom'
|
|
163
|
+
}, {
|
|
164
|
+
key: 'de',
|
|
165
|
+
value: 'de',
|
|
166
|
+
label: 'Germany'
|
|
167
|
+
}, {
|
|
168
|
+
key: 'fr',
|
|
169
|
+
value: 'fr',
|
|
170
|
+
label: 'France'
|
|
171
|
+
}, {
|
|
172
|
+
key: 'es',
|
|
173
|
+
value: 'es',
|
|
174
|
+
label: 'Spain'
|
|
175
|
+
}, {
|
|
176
|
+
key: 'it',
|
|
177
|
+
value: 'it',
|
|
178
|
+
label: 'Italy'
|
|
179
|
+
}, {
|
|
180
|
+
key: 'nl',
|
|
181
|
+
value: 'nl',
|
|
182
|
+
label: 'Netherlands'
|
|
183
|
+
}, {
|
|
184
|
+
key: 'ch',
|
|
185
|
+
value: 'ch',
|
|
186
|
+
label: 'Switzerland'
|
|
187
|
+
}, {
|
|
188
|
+
key: 'at',
|
|
189
|
+
value: 'at',
|
|
190
|
+
label: 'Austria'
|
|
191
|
+
}, {
|
|
192
|
+
key: 'be',
|
|
193
|
+
value: 'be',
|
|
194
|
+
label: 'Belgium'
|
|
195
|
+
}];
|
|
196
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
197
|
+
style: {
|
|
198
|
+
marginBottom: '16px',
|
|
199
|
+
fontSize: '14px'
|
|
200
|
+
}
|
|
201
|
+
}, "Type to filter options (try typing \"United\" or \"Ger\")"), /*#__PURE__*/_react.default.createElement(_Select.Select, {
|
|
202
|
+
id: "country",
|
|
203
|
+
name: "country",
|
|
204
|
+
label: "Select Country",
|
|
205
|
+
options: countryOptions,
|
|
206
|
+
value: value,
|
|
207
|
+
search: true,
|
|
208
|
+
onChange: _ref2 => {
|
|
209
|
+
let {
|
|
210
|
+
value: newValue
|
|
211
|
+
} = _ref2;
|
|
212
|
+
return setValue(newValue);
|
|
213
|
+
}
|
|
214
|
+
}), /*#__PURE__*/_react.default.createElement("p", {
|
|
215
|
+
style: {
|
|
216
|
+
marginTop: '12px',
|
|
217
|
+
fontSize: '12px',
|
|
218
|
+
color: '#666'
|
|
219
|
+
}
|
|
220
|
+
}, "Selected: ", /*#__PURE__*/_react.default.createElement("strong", null, value || '(none)')));
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// Not Searchable (default)
|
|
224
|
+
exports.Searchable = Searchable;
|
|
225
|
+
const NotSearchable = () => {
|
|
226
|
+
const [value, setValue] = (0, _react.useState)('');
|
|
227
|
+
const options = [{
|
|
228
|
+
key: 'opt1',
|
|
229
|
+
value: 'option1',
|
|
230
|
+
label: 'Option 1'
|
|
231
|
+
}, {
|
|
232
|
+
key: 'opt2',
|
|
233
|
+
value: 'option2',
|
|
234
|
+
label: 'Option 2'
|
|
235
|
+
}, {
|
|
236
|
+
key: 'opt3',
|
|
237
|
+
value: 'option3',
|
|
238
|
+
label: 'Option 3'
|
|
239
|
+
}];
|
|
240
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
241
|
+
style: {
|
|
242
|
+
marginBottom: '16px',
|
|
243
|
+
fontSize: '14px'
|
|
244
|
+
}
|
|
245
|
+
}, "Click to open, no typing (search=false)"), /*#__PURE__*/_react.default.createElement(_Select.Select, {
|
|
246
|
+
id: "basic",
|
|
247
|
+
name: "basic",
|
|
248
|
+
label: "Select Option",
|
|
249
|
+
options: options,
|
|
250
|
+
value: value,
|
|
251
|
+
search: false,
|
|
252
|
+
onChange: _ref3 => {
|
|
253
|
+
let {
|
|
254
|
+
value: newValue
|
|
255
|
+
} = _ref3;
|
|
256
|
+
return setValue(newValue);
|
|
257
|
+
}
|
|
258
|
+
}), /*#__PURE__*/_react.default.createElement("p", {
|
|
259
|
+
style: {
|
|
260
|
+
marginTop: '12px',
|
|
261
|
+
fontSize: '12px',
|
|
262
|
+
color: '#666'
|
|
263
|
+
}
|
|
264
|
+
}, "Selected: ", /*#__PURE__*/_react.default.createElement("strong", null, value || '(none)')));
|
|
265
|
+
};
|
|
138
266
|
|
|
139
|
-
//
|
|
267
|
+
// All States
|
|
268
|
+
exports.NotSearchable = NotSearchable;
|
|
269
|
+
const AllStates = () => {
|
|
270
|
+
const [value1, setValue1] = (0, _react.useState)('');
|
|
271
|
+
const [value2, setValue2] = (0, _react.useState)('de');
|
|
272
|
+
const [value3, setValue3] = (0, _react.useState)('');
|
|
273
|
+
const options = [{
|
|
274
|
+
key: 'us',
|
|
275
|
+
value: 'us',
|
|
276
|
+
label: 'United States'
|
|
277
|
+
}, {
|
|
278
|
+
key: 'uk',
|
|
279
|
+
value: 'uk',
|
|
280
|
+
label: 'United Kingdom'
|
|
281
|
+
}, {
|
|
282
|
+
key: 'de',
|
|
283
|
+
value: 'de',
|
|
284
|
+
label: 'Germany'
|
|
285
|
+
}, {
|
|
286
|
+
key: 'fr',
|
|
287
|
+
value: 'fr',
|
|
288
|
+
label: 'France'
|
|
289
|
+
}];
|
|
290
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
291
|
+
style: {
|
|
292
|
+
display: 'flex',
|
|
293
|
+
flexDirection: 'column',
|
|
294
|
+
gap: '32px'
|
|
295
|
+
}
|
|
296
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
297
|
+
style: {
|
|
298
|
+
marginBottom: '8px',
|
|
299
|
+
fontSize: '12px',
|
|
300
|
+
color: '#666'
|
|
301
|
+
}
|
|
302
|
+
}, "Empty with search"), /*#__PURE__*/_react.default.createElement(_Select.Select, {
|
|
303
|
+
id: "empty",
|
|
304
|
+
name: "empty",
|
|
305
|
+
label: "Country",
|
|
306
|
+
options: options,
|
|
307
|
+
value: value1,
|
|
308
|
+
search: true,
|
|
309
|
+
onChange: _ref4 => {
|
|
310
|
+
let {
|
|
311
|
+
value
|
|
312
|
+
} = _ref4;
|
|
313
|
+
return setValue1(value);
|
|
314
|
+
}
|
|
315
|
+
})), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
316
|
+
style: {
|
|
317
|
+
marginBottom: '8px',
|
|
318
|
+
fontSize: '12px',
|
|
319
|
+
color: '#666'
|
|
320
|
+
}
|
|
321
|
+
}, "Pre-selected value"), /*#__PURE__*/_react.default.createElement(_Select.Select, {
|
|
322
|
+
id: "preselected",
|
|
323
|
+
name: "preselected",
|
|
324
|
+
label: "Country",
|
|
325
|
+
options: options,
|
|
326
|
+
value: value2,
|
|
327
|
+
search: true,
|
|
328
|
+
onChange: _ref5 => {
|
|
329
|
+
let {
|
|
330
|
+
value
|
|
331
|
+
} = _ref5;
|
|
332
|
+
return setValue2(value);
|
|
333
|
+
}
|
|
334
|
+
})), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
335
|
+
style: {
|
|
336
|
+
marginBottom: '8px',
|
|
337
|
+
fontSize: '12px',
|
|
338
|
+
color: '#666'
|
|
339
|
+
}
|
|
340
|
+
}, "Disabled"), /*#__PURE__*/_react.default.createElement(_Select.Select, {
|
|
341
|
+
id: "disabled",
|
|
342
|
+
name: "disabled",
|
|
343
|
+
label: "Country",
|
|
344
|
+
options: options,
|
|
345
|
+
value: "uk",
|
|
346
|
+
disabled: true,
|
|
347
|
+
onChange: () => {}
|
|
348
|
+
})), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
349
|
+
style: {
|
|
350
|
+
marginBottom: '8px',
|
|
351
|
+
fontSize: '12px',
|
|
352
|
+
color: '#666'
|
|
353
|
+
}
|
|
354
|
+
}, "Error state"), /*#__PURE__*/_react.default.createElement(_Select.Select, {
|
|
355
|
+
id: "error",
|
|
356
|
+
name: "error",
|
|
357
|
+
label: "Country",
|
|
358
|
+
options: options,
|
|
359
|
+
value: value3,
|
|
360
|
+
error: true,
|
|
361
|
+
touched: true,
|
|
362
|
+
onChange: _ref6 => {
|
|
363
|
+
let {
|
|
364
|
+
value
|
|
365
|
+
} = _ref6;
|
|
366
|
+
return setValue3(value);
|
|
367
|
+
}
|
|
368
|
+
})));
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// Creatable - type to add custom options
|
|
372
|
+
exports.AllStates = AllStates;
|
|
373
|
+
const Creatable = () => {
|
|
374
|
+
const [value, setValue] = (0, _react.useState)('');
|
|
375
|
+
const [options, setOptions] = (0, _react.useState)([{
|
|
376
|
+
key: 'react',
|
|
377
|
+
value: 'react',
|
|
378
|
+
label: 'React'
|
|
379
|
+
}, {
|
|
380
|
+
key: 'vue',
|
|
381
|
+
value: 'vue',
|
|
382
|
+
label: 'Vue'
|
|
383
|
+
}, {
|
|
384
|
+
key: 'angular',
|
|
385
|
+
value: 'angular',
|
|
386
|
+
label: 'Angular'
|
|
387
|
+
}, {
|
|
388
|
+
key: 'svelte',
|
|
389
|
+
value: 'svelte',
|
|
390
|
+
label: 'Svelte'
|
|
391
|
+
}]);
|
|
392
|
+
const handleChange = _ref7 => {
|
|
393
|
+
let {
|
|
394
|
+
value: newValue
|
|
395
|
+
} = _ref7;
|
|
396
|
+
setValue(newValue);
|
|
397
|
+
// Add new option to the list if it doesn't exist
|
|
398
|
+
if (!options.find(opt => opt.value === newValue)) {
|
|
399
|
+
setOptions([...options, {
|
|
400
|
+
key: newValue,
|
|
401
|
+
value: newValue,
|
|
402
|
+
label: newValue
|
|
403
|
+
}]);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
407
|
+
style: {
|
|
408
|
+
marginBottom: '16px',
|
|
409
|
+
fontSize: '14px'
|
|
410
|
+
}
|
|
411
|
+
}, "Type to search or create a new option (try typing \"Next.js\")"), /*#__PURE__*/_react.default.createElement(_Select.Select, {
|
|
412
|
+
id: "framework",
|
|
413
|
+
name: "framework",
|
|
414
|
+
label: "Framework",
|
|
415
|
+
options: options,
|
|
416
|
+
value: value,
|
|
417
|
+
creatable: true,
|
|
418
|
+
onChange: handleChange
|
|
419
|
+
}), /*#__PURE__*/_react.default.createElement("p", {
|
|
420
|
+
style: {
|
|
421
|
+
marginTop: '12px',
|
|
422
|
+
fontSize: '12px',
|
|
423
|
+
color: '#666'
|
|
424
|
+
}
|
|
425
|
+
}, "Selected: ", /*#__PURE__*/_react.default.createElement("strong", null, value || '(none)')), /*#__PURE__*/_react.default.createElement("p", {
|
|
426
|
+
style: {
|
|
427
|
+
marginTop: '8px',
|
|
428
|
+
fontSize: '12px',
|
|
429
|
+
color: '#666'
|
|
430
|
+
}
|
|
431
|
+
}, "Options: ", options.map(o => o.label).join(', ')));
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
// Creatable with custom label
|
|
435
|
+
exports.Creatable = Creatable;
|
|
436
|
+
const CreatableCustomLabel = () => {
|
|
437
|
+
const [value, setValue] = (0, _react.useState)('');
|
|
438
|
+
const tagOptions = [{
|
|
439
|
+
key: 'bug',
|
|
440
|
+
value: 'bug',
|
|
441
|
+
label: 'Bug'
|
|
442
|
+
}, {
|
|
443
|
+
key: 'feature',
|
|
444
|
+
value: 'feature',
|
|
445
|
+
label: 'Feature'
|
|
446
|
+
}, {
|
|
447
|
+
key: 'docs',
|
|
448
|
+
value: 'docs',
|
|
449
|
+
label: 'Documentation'
|
|
450
|
+
}];
|
|
451
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h4", {
|
|
452
|
+
style: {
|
|
453
|
+
marginBottom: '16px',
|
|
454
|
+
fontSize: '14px'
|
|
455
|
+
}
|
|
456
|
+
}, "Custom \"create\" label format"), /*#__PURE__*/_react.default.createElement(_Select.Select, {
|
|
457
|
+
id: "tag",
|
|
458
|
+
name: "tag",
|
|
459
|
+
label: "Add Tag",
|
|
460
|
+
options: tagOptions,
|
|
461
|
+
value: value,
|
|
462
|
+
creatable: true,
|
|
463
|
+
formatCreateLabel: inputValue => "+ Add new tag: ".concat(inputValue),
|
|
464
|
+
onChange: _ref8 => {
|
|
465
|
+
let {
|
|
466
|
+
value: newValue
|
|
467
|
+
} = _ref8;
|
|
468
|
+
return setValue(newValue);
|
|
469
|
+
}
|
|
470
|
+
}), /*#__PURE__*/_react.default.createElement("p", {
|
|
471
|
+
style: {
|
|
472
|
+
marginTop: '12px',
|
|
473
|
+
fontSize: '12px',
|
|
474
|
+
color: '#666'
|
|
475
|
+
}
|
|
476
|
+
}, "Selected: ", /*#__PURE__*/_react.default.createElement("strong", null, value || '(none)')));
|
|
477
|
+
};
|
|
478
|
+
exports.CreatableCustomLabel = CreatableCustomLabel;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.SideModal = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactDom = require("react-dom");
|
|
9
|
+
var _SideModal = require("./SideModal.styles");
|
|
10
|
+
var _Modal = require("./Modal.styles");
|
|
11
|
+
const _excluded = ["children", "isOpen", "onClose", "width", "minWidth", "className", "containerStyle", "closeOnDimmerClick", "showCloseButton"];
|
|
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
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
16
|
+
const SideModal = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
children,
|
|
19
|
+
isOpen,
|
|
20
|
+
onClose,
|
|
21
|
+
width = 40,
|
|
22
|
+
minWidth = 400,
|
|
23
|
+
className,
|
|
24
|
+
containerStyle,
|
|
25
|
+
closeOnDimmerClick = true,
|
|
26
|
+
showCloseButton = true
|
|
27
|
+
} = _ref,
|
|
28
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
const [isVisible, setIsVisible] = (0, _react.useState)(false);
|
|
30
|
+
(0, _react.useEffect)(() => {
|
|
31
|
+
// Disable scroll on background when modal is open
|
|
32
|
+
if (isOpen) {
|
|
33
|
+
document.body.style.overflow = 'hidden';
|
|
34
|
+
// Small delay to trigger animation
|
|
35
|
+
setTimeout(() => setIsVisible(true), 10);
|
|
36
|
+
} else {
|
|
37
|
+
document.body.style.overflow = 'unset';
|
|
38
|
+
setIsVisible(false);
|
|
39
|
+
}
|
|
40
|
+
return () => {
|
|
41
|
+
document.body.style.overflow = 'unset';
|
|
42
|
+
};
|
|
43
|
+
}, [isOpen]);
|
|
44
|
+
|
|
45
|
+
// Handle escape key
|
|
46
|
+
(0, _react.useEffect)(() => {
|
|
47
|
+
const handleEscape = e => {
|
|
48
|
+
if (e.key === 'Escape' && isOpen) {
|
|
49
|
+
onClose();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
if (isOpen) {
|
|
53
|
+
document.addEventListener('keydown', handleEscape);
|
|
54
|
+
}
|
|
55
|
+
return () => {
|
|
56
|
+
document.removeEventListener('keydown', handleEscape);
|
|
57
|
+
};
|
|
58
|
+
}, [isOpen, onClose]);
|
|
59
|
+
const handleDimmerClick = e => {
|
|
60
|
+
if (closeOnDimmerClick && e.target === e.currentTarget) {
|
|
61
|
+
onClose();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
if (!isOpen) return null;
|
|
65
|
+
const modalContent = /*#__PURE__*/_react.default.createElement(_SideModal.SideModalRoot, _extends({
|
|
66
|
+
className: className,
|
|
67
|
+
style: containerStyle
|
|
68
|
+
}, props), /*#__PURE__*/_react.default.createElement(_SideModal.Dimmer, {
|
|
69
|
+
onClick: handleDimmerClick,
|
|
70
|
+
isVisible: isVisible
|
|
71
|
+
}, /*#__PURE__*/_react.default.createElement(_SideModal.SideModalBox, {
|
|
72
|
+
width: width,
|
|
73
|
+
minWidth: minWidth,
|
|
74
|
+
isVisible: isVisible,
|
|
75
|
+
onClick: e => e.stopPropagation()
|
|
76
|
+
}, showCloseButton && /*#__PURE__*/_react.default.createElement(_Modal.ModalClose, {
|
|
77
|
+
onClick: onClose
|
|
78
|
+
}), children)));
|
|
79
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)(modalContent, document.body);
|
|
80
|
+
};
|
|
81
|
+
exports.SideModal = SideModal;
|
|
82
|
+
var _default = exports.default = SideModal;
|