quicksnack 3.34.4 → 3.35.1

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.
Files changed (77) hide show
  1. package/package.json +5 -2
  2. package/dist/UiProvider.d.ts +0 -8
  3. package/dist/UiStateProvider.d.ts +0 -9
  4. package/dist/UiWrapper.d.ts +0 -7
  5. package/dist/animation/SlideInFromTop/SlideInFromTop.d.ts +0 -4
  6. package/dist/animation/SlideOpen/SlideOpen.d.ts +0 -9
  7. package/dist/bundle.js +0 -4730
  8. package/dist/bundle.min.js +0 -910
  9. package/dist/components/Alert/Alert.d.ts +0 -8
  10. package/dist/components/AnimatedCheckmark/AnimatedCheckmark.d.ts +0 -2
  11. package/dist/components/Box/Box.d.ts +0 -23
  12. package/dist/components/BreadCrumbs/BreadCrumbs.d.ts +0 -522
  13. package/dist/components/CollapsiblePanel/CollapsiblePanel.d.ts +0 -7
  14. package/dist/components/ConfirmButton/ConfirmButton.d.ts +0 -8
  15. package/dist/components/ConfirmModal/ConfirmModal.d.ts +0 -15
  16. package/dist/components/ConfirmModal/hooks/useConfirmModal.d.ts +0 -11
  17. package/dist/components/Details/Details.d.ts +0 -7
  18. package/dist/components/Dropdown/Dropdown.d.ts +0 -530
  19. package/dist/components/Dropzone/Dropzone.d.ts +0 -8
  20. package/dist/components/Feedback/Feedback.d.ts +0 -10
  21. package/dist/components/Floater/Floater.d.ts +0 -14
  22. package/dist/components/Floater/FloaterItem.d.ts +0 -8
  23. package/dist/components/Footer/Footer.d.ts +0 -2
  24. package/dist/components/HorizontalScroller/HorizontalScroller.d.ts +0 -2
  25. package/dist/components/Menu/HamburgerButton.d.ts +0 -276
  26. package/dist/components/Menu/Menu.d.ts +0 -268
  27. package/dist/components/Menu/MenuCloseButton.d.ts +0 -276
  28. package/dist/components/Menu/MenuSlideOpenIndicator.d.ts +0 -2
  29. package/dist/components/Menu/SideBar.d.ts +0 -271
  30. package/dist/components/Menu/SideBarHeader.d.ts +0 -6
  31. package/dist/components/Menu/useCloseSidebarOnNavigate.d.ts +0 -1
  32. package/dist/components/Menu/useToggleMobileMenu.d.ts +0 -10
  33. package/dist/components/Modal/Modal.d.ts +0 -8
  34. package/dist/components/Overlay/Overlay.d.ts +0 -261
  35. package/dist/components/Paginator/Paginator.d.ts +0 -8
  36. package/dist/components/Panel/Panel.d.ts +0 -13
  37. package/dist/components/Section/Section.d.ts +0 -3
  38. package/dist/components/Statistic/Statistic.d.ts +0 -11
  39. package/dist/components/Table/Table.d.ts +0 -27
  40. package/dist/components/Tabs/Tab.d.ts +0 -12
  41. package/dist/components/Tabs/TabContent.d.ts +0 -3
  42. package/dist/components/Tabs/Tabs.d.ts +0 -279
  43. package/dist/components/Timeline/Timeline.d.ts +0 -18
  44. package/dist/components/TopBar/TopBar.d.ts +0 -7
  45. package/dist/fonts.d.ts +0 -1
  46. package/dist/form/Button/Button.d.ts +0 -13
  47. package/dist/form/Checkbox/Checkbox.d.ts +0 -8
  48. package/dist/form/FileField/FileField.d.ts +0 -8
  49. package/dist/form/PasswordStrengthField/PasswordStrenghField.d.ts +0 -9
  50. package/dist/form/ScaffoldForm/FormGrid/FormGrid.d.ts +0 -7
  51. package/dist/form/ScaffoldForm/FormGrid/FormGridCell.d.ts +0 -14
  52. package/dist/form/ScaffoldForm/FormGrid/FormGridWrapper.d.ts +0 -10
  53. package/dist/form/ScaffoldForm/ScaffoldField.d.ts +0 -9
  54. package/dist/form/ScaffoldForm/ScaffoldForm.d.ts +0 -10
  55. package/dist/form/ScaffoldForm/ScaffoldFormProvider.d.ts +0 -7
  56. package/dist/form/ScaffoldForm/hooks/useScaffoldFormContext.d.ts +0 -1
  57. package/dist/form/ScaffoldForm/scaffoldFormProps.d.ts +0 -80
  58. package/dist/form/ScaffoldForm/scaffoldPasswordProps.d.ts +0 -19
  59. package/dist/form/ScaffoldForm/types.d.ts +0 -34
  60. package/dist/form/ScaffoldForm/utils/FormPositioner.d.ts +0 -36
  61. package/dist/form/ScaffoldForm/utils/Grid.d.ts +0 -38
  62. package/dist/form/ScaffoldForm/utils/Grid.test.d.ts +0 -1
  63. package/dist/form/ScaffoldForm/utils/assertGridIsValid.d.ts +0 -6
  64. package/dist/form/ScaffoldForm/utils/assertGridIsValid.test.d.ts +0 -1
  65. package/dist/form/ScaffoldForm/utils/equalColumns.d.ts +0 -1
  66. package/dist/form/Select/Select.d.ts +0 -6
  67. package/dist/form/TextField/TextField.d.ts +0 -9
  68. package/dist/index.d.ts +0 -57
  69. package/dist/layouts/BasicLayout/BasicLayout.d.ts +0 -13
  70. package/dist/layouts/FloatingPanelLayout/FloatingPanelLayout.d.ts +0 -12
  71. package/dist/layouts/constants.d.ts +0 -2
  72. package/dist/responsiveness/responsiveProps.d.ts +0 -17
  73. package/dist/responsiveness/useResponsiveBreakpoints.d.ts +0 -6
  74. package/dist/theme.d.ts +0 -2
  75. package/dist/typography/Fonts.d.ts +0 -2
  76. package/dist/typography/Header/Header.d.ts +0 -6
  77. package/dist/typography/Paragraph/Paragraph.d.ts +0 -261
package/dist/bundle.js DELETED
@@ -1,4730 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var styledComponents = require('styled-components');
5
- var immer = require('immer');
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise */
22
-
23
-
24
- function __rest(s, e) {
25
- var t = {};
26
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
27
- t[p] = s[p];
28
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
29
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
30
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
31
- t[p[i]] = s[p[i]];
32
- }
33
- return t;
34
- }
35
-
36
- function _extends() {
37
- _extends = Object.assign || function (target) {
38
- for (var i = 1; i < arguments.length; i++) {
39
- var source = arguments[i];
40
-
41
- for (var key in source) {
42
- if (Object.prototype.hasOwnProperty.call(source, key)) {
43
- target[key] = source[key];
44
- }
45
- }
46
- }
47
-
48
- return target;
49
- };
50
-
51
- return _extends.apply(this, arguments);
52
- }
53
-
54
- function _assertThisInitialized(self) {
55
- if (self === void 0) {
56
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
57
- }
58
-
59
- return self;
60
- }
61
-
62
- function _setPrototypeOf(o, p) {
63
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
64
- o.__proto__ = p;
65
- return o;
66
- };
67
-
68
- return _setPrototypeOf(o, p);
69
- }
70
-
71
- function _inheritsLoose(subClass, superClass) {
72
- subClass.prototype = Object.create(superClass.prototype);
73
- subClass.prototype.constructor = subClass;
74
- _setPrototypeOf(subClass, superClass);
75
- }
76
-
77
- function _getPrototypeOf(o) {
78
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
79
- return o.__proto__ || Object.getPrototypeOf(o);
80
- };
81
- return _getPrototypeOf(o);
82
- }
83
-
84
- function _isNativeFunction(fn) {
85
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
86
- }
87
-
88
- function _isNativeReflectConstruct() {
89
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
90
- if (Reflect.construct.sham) return false;
91
- if (typeof Proxy === "function") return true;
92
-
93
- try {
94
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
95
- return true;
96
- } catch (e) {
97
- return false;
98
- }
99
- }
100
-
101
- function _construct(Parent, args, Class) {
102
- if (_isNativeReflectConstruct()) {
103
- _construct = Reflect.construct;
104
- } else {
105
- _construct = function _construct(Parent, args, Class) {
106
- var a = [null];
107
- a.push.apply(a, args);
108
- var Constructor = Function.bind.apply(Parent, a);
109
- var instance = new Constructor();
110
- if (Class) _setPrototypeOf(instance, Class.prototype);
111
- return instance;
112
- };
113
- }
114
-
115
- return _construct.apply(null, arguments);
116
- }
117
-
118
- function _wrapNativeSuper(Class) {
119
- var _cache = typeof Map === "function" ? new Map() : undefined;
120
-
121
- _wrapNativeSuper = function _wrapNativeSuper(Class) {
122
- if (Class === null || !_isNativeFunction(Class)) return Class;
123
-
124
- if (typeof Class !== "function") {
125
- throw new TypeError("Super expression must either be null or a function");
126
- }
127
-
128
- if (typeof _cache !== "undefined") {
129
- if (_cache.has(Class)) return _cache.get(Class);
130
-
131
- _cache.set(Class, Wrapper);
132
- }
133
-
134
- function Wrapper() {
135
- return _construct(Class, arguments, _getPrototypeOf(this).constructor);
136
- }
137
-
138
- Wrapper.prototype = Object.create(Class.prototype, {
139
- constructor: {
140
- value: Wrapper,
141
- enumerable: false,
142
- writable: true,
143
- configurable: true
144
- }
145
- });
146
- return _setPrototypeOf(Wrapper, Class);
147
- };
148
-
149
- return _wrapNativeSuper(Class);
150
- }
151
-
152
- // based on https://github.com/styled-components/styled-components/blob/fcf6f3804c57a14dd7984dfab7bc06ee2edca044/src/utils/error.js
153
-
154
- /**
155
- * Parse errors.md and turn it into a simple hash of code: message
156
- * @private
157
- */
158
- var ERRORS = {
159
- "1": "Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",
160
- "2": "Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",
161
- "3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
162
- "4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
163
- "5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
164
- "6": "Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",
165
- "7": "Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",
166
- "8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
167
- "9": "Please provide a number of steps to the modularScale helper.\n\n",
168
- "10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
169
- "11": "Invalid value passed as base to modularScale, expected number or em string but got \"%s\"\n\n",
170
- "12": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got \"%s\" instead.\n\n",
171
- "13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
172
- "14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
173
- "15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
174
- "16": "You must provide a template to this method.\n\n",
175
- "17": "You passed an unsupported selector state to this method.\n\n",
176
- "18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
177
- "19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
178
- "20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
179
- "21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
180
- "22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
181
- "23": "fontFace expects a name of a font-family.\n\n",
182
- "24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
183
- "25": "fontFace expects localFonts to be an array.\n\n",
184
- "26": "fontFace expects fileFormats to be an array.\n\n",
185
- "27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
186
- "28": "Please supply a filename to retinaImage() as the first argument.\n\n",
187
- "29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
188
- "30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
189
- "31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
190
- "32": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",
191
- "33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
192
- "34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
193
- "35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
194
- "36": "Property must be a string value.\n\n",
195
- "37": "Syntax Error at %s.\n\n",
196
- "38": "Formula contains a function that needs parentheses at %s.\n\n",
197
- "39": "Formula is missing closing parenthesis at %s.\n\n",
198
- "40": "Formula has too many closing parentheses at %s.\n\n",
199
- "41": "All values in a formula must have the same unit or be unitless.\n\n",
200
- "42": "Please provide a number of steps to the modularScale helper.\n\n",
201
- "43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
202
- "44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
203
- "45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
204
- "46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
205
- "47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
206
- "48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
207
- "49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
208
- "50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
209
- "51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
210
- "52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
211
- "53": "fontFace expects localFonts to be an array.\n\n",
212
- "54": "fontFace expects fileFormats to be an array.\n\n",
213
- "55": "fontFace expects a name of a font-family.\n\n",
214
- "56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
215
- "57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
216
- "58": "Please supply a filename to retinaImage() as the first argument.\n\n",
217
- "59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
218
- "60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
219
- "61": "Property must be a string value.\n\n",
220
- "62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
221
- "63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
222
- "64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
223
- "65": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",
224
- "66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
225
- "67": "You must provide a template to this method.\n\n",
226
- "68": "You passed an unsupported selector state to this method.\n\n",
227
- "69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
228
- "70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
229
- "71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
230
- "72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
231
- "73": "Please provide a valid CSS variable.\n\n",
232
- "74": "CSS variable not found and no default was provided.\n\n",
233
- "75": "important requires a valid style object, got a %s instead.\n\n",
234
- "76": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",
235
- "77": "remToPx expects a value in \"rem\" but you provided it in \"%s\".\n\n",
236
- "78": "base must be set in \"px\" or \"%\" but you set it in \"%s\".\n"
237
- };
238
- /**
239
- * super basic version of sprintf
240
- * @private
241
- */
242
-
243
- function format() {
244
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
245
- args[_key] = arguments[_key];
246
- }
247
-
248
- var a = args[0];
249
- var b = [];
250
- var c;
251
-
252
- for (c = 1; c < args.length; c += 1) {
253
- b.push(args[c]);
254
- }
255
-
256
- b.forEach(function (d) {
257
- a = a.replace(/%[a-z]/, d);
258
- });
259
- return a;
260
- }
261
- /**
262
- * Create an error file out of errors.md for development and a simple web link to the full errors
263
- * in production mode.
264
- * @private
265
- */
266
-
267
-
268
- var PolishedError = /*#__PURE__*/function (_Error) {
269
- _inheritsLoose(PolishedError, _Error);
270
-
271
- function PolishedError(code) {
272
- var _this;
273
-
274
- if (process.env.NODE_ENV === 'production') {
275
- _this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
276
- } else {
277
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
278
- args[_key2 - 1] = arguments[_key2];
279
- }
280
-
281
- _this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
282
- }
283
-
284
- return _assertThisInitialized(_this);
285
- }
286
-
287
- return PolishedError;
288
- }( /*#__PURE__*/_wrapNativeSuper(Error));
289
-
290
- function colorToInt(color) {
291
- return Math.round(color * 255);
292
- }
293
-
294
- function convertToInt(red, green, blue) {
295
- return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
296
- }
297
-
298
- function hslToRgb(hue, saturation, lightness, convert) {
299
- if (convert === void 0) {
300
- convert = convertToInt;
301
- }
302
-
303
- if (saturation === 0) {
304
- // achromatic
305
- return convert(lightness, lightness, lightness);
306
- } // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
307
-
308
-
309
- var huePrime = (hue % 360 + 360) % 360 / 60;
310
- var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
311
- var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
312
- var red = 0;
313
- var green = 0;
314
- var blue = 0;
315
-
316
- if (huePrime >= 0 && huePrime < 1) {
317
- red = chroma;
318
- green = secondComponent;
319
- } else if (huePrime >= 1 && huePrime < 2) {
320
- red = secondComponent;
321
- green = chroma;
322
- } else if (huePrime >= 2 && huePrime < 3) {
323
- green = chroma;
324
- blue = secondComponent;
325
- } else if (huePrime >= 3 && huePrime < 4) {
326
- green = secondComponent;
327
- blue = chroma;
328
- } else if (huePrime >= 4 && huePrime < 5) {
329
- red = secondComponent;
330
- blue = chroma;
331
- } else if (huePrime >= 5 && huePrime < 6) {
332
- red = chroma;
333
- blue = secondComponent;
334
- }
335
-
336
- var lightnessModification = lightness - chroma / 2;
337
- var finalRed = red + lightnessModification;
338
- var finalGreen = green + lightnessModification;
339
- var finalBlue = blue + lightnessModification;
340
- return convert(finalRed, finalGreen, finalBlue);
341
- }
342
-
343
- var namedColorMap = {
344
- aliceblue: 'f0f8ff',
345
- antiquewhite: 'faebd7',
346
- aqua: '00ffff',
347
- aquamarine: '7fffd4',
348
- azure: 'f0ffff',
349
- beige: 'f5f5dc',
350
- bisque: 'ffe4c4',
351
- black: '000',
352
- blanchedalmond: 'ffebcd',
353
- blue: '0000ff',
354
- blueviolet: '8a2be2',
355
- brown: 'a52a2a',
356
- burlywood: 'deb887',
357
- cadetblue: '5f9ea0',
358
- chartreuse: '7fff00',
359
- chocolate: 'd2691e',
360
- coral: 'ff7f50',
361
- cornflowerblue: '6495ed',
362
- cornsilk: 'fff8dc',
363
- crimson: 'dc143c',
364
- cyan: '00ffff',
365
- darkblue: '00008b',
366
- darkcyan: '008b8b',
367
- darkgoldenrod: 'b8860b',
368
- darkgray: 'a9a9a9',
369
- darkgreen: '006400',
370
- darkgrey: 'a9a9a9',
371
- darkkhaki: 'bdb76b',
372
- darkmagenta: '8b008b',
373
- darkolivegreen: '556b2f',
374
- darkorange: 'ff8c00',
375
- darkorchid: '9932cc',
376
- darkred: '8b0000',
377
- darksalmon: 'e9967a',
378
- darkseagreen: '8fbc8f',
379
- darkslateblue: '483d8b',
380
- darkslategray: '2f4f4f',
381
- darkslategrey: '2f4f4f',
382
- darkturquoise: '00ced1',
383
- darkviolet: '9400d3',
384
- deeppink: 'ff1493',
385
- deepskyblue: '00bfff',
386
- dimgray: '696969',
387
- dimgrey: '696969',
388
- dodgerblue: '1e90ff',
389
- firebrick: 'b22222',
390
- floralwhite: 'fffaf0',
391
- forestgreen: '228b22',
392
- fuchsia: 'ff00ff',
393
- gainsboro: 'dcdcdc',
394
- ghostwhite: 'f8f8ff',
395
- gold: 'ffd700',
396
- goldenrod: 'daa520',
397
- gray: '808080',
398
- green: '008000',
399
- greenyellow: 'adff2f',
400
- grey: '808080',
401
- honeydew: 'f0fff0',
402
- hotpink: 'ff69b4',
403
- indianred: 'cd5c5c',
404
- indigo: '4b0082',
405
- ivory: 'fffff0',
406
- khaki: 'f0e68c',
407
- lavender: 'e6e6fa',
408
- lavenderblush: 'fff0f5',
409
- lawngreen: '7cfc00',
410
- lemonchiffon: 'fffacd',
411
- lightblue: 'add8e6',
412
- lightcoral: 'f08080',
413
- lightcyan: 'e0ffff',
414
- lightgoldenrodyellow: 'fafad2',
415
- lightgray: 'd3d3d3',
416
- lightgreen: '90ee90',
417
- lightgrey: 'd3d3d3',
418
- lightpink: 'ffb6c1',
419
- lightsalmon: 'ffa07a',
420
- lightseagreen: '20b2aa',
421
- lightskyblue: '87cefa',
422
- lightslategray: '789',
423
- lightslategrey: '789',
424
- lightsteelblue: 'b0c4de',
425
- lightyellow: 'ffffe0',
426
- lime: '0f0',
427
- limegreen: '32cd32',
428
- linen: 'faf0e6',
429
- magenta: 'f0f',
430
- maroon: '800000',
431
- mediumaquamarine: '66cdaa',
432
- mediumblue: '0000cd',
433
- mediumorchid: 'ba55d3',
434
- mediumpurple: '9370db',
435
- mediumseagreen: '3cb371',
436
- mediumslateblue: '7b68ee',
437
- mediumspringgreen: '00fa9a',
438
- mediumturquoise: '48d1cc',
439
- mediumvioletred: 'c71585',
440
- midnightblue: '191970',
441
- mintcream: 'f5fffa',
442
- mistyrose: 'ffe4e1',
443
- moccasin: 'ffe4b5',
444
- navajowhite: 'ffdead',
445
- navy: '000080',
446
- oldlace: 'fdf5e6',
447
- olive: '808000',
448
- olivedrab: '6b8e23',
449
- orange: 'ffa500',
450
- orangered: 'ff4500',
451
- orchid: 'da70d6',
452
- palegoldenrod: 'eee8aa',
453
- palegreen: '98fb98',
454
- paleturquoise: 'afeeee',
455
- palevioletred: 'db7093',
456
- papayawhip: 'ffefd5',
457
- peachpuff: 'ffdab9',
458
- peru: 'cd853f',
459
- pink: 'ffc0cb',
460
- plum: 'dda0dd',
461
- powderblue: 'b0e0e6',
462
- purple: '800080',
463
- rebeccapurple: '639',
464
- red: 'f00',
465
- rosybrown: 'bc8f8f',
466
- royalblue: '4169e1',
467
- saddlebrown: '8b4513',
468
- salmon: 'fa8072',
469
- sandybrown: 'f4a460',
470
- seagreen: '2e8b57',
471
- seashell: 'fff5ee',
472
- sienna: 'a0522d',
473
- silver: 'c0c0c0',
474
- skyblue: '87ceeb',
475
- slateblue: '6a5acd',
476
- slategray: '708090',
477
- slategrey: '708090',
478
- snow: 'fffafa',
479
- springgreen: '00ff7f',
480
- steelblue: '4682b4',
481
- tan: 'd2b48c',
482
- teal: '008080',
483
- thistle: 'd8bfd8',
484
- tomato: 'ff6347',
485
- turquoise: '40e0d0',
486
- violet: 'ee82ee',
487
- wheat: 'f5deb3',
488
- white: 'fff',
489
- whitesmoke: 'f5f5f5',
490
- yellow: 'ff0',
491
- yellowgreen: '9acd32'
492
- };
493
- /**
494
- * Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
495
- * @private
496
- */
497
-
498
- function nameToHex(color) {
499
- if (typeof color !== 'string') return color;
500
- var normalizedColorName = color.toLowerCase();
501
- return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
502
- }
503
-
504
- var hexRegex = /^#[a-fA-F0-9]{6}$/;
505
- var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
506
- var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
507
- var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
508
- var rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i;
509
- var rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
510
- var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
511
- var hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
512
- /**
513
- * Returns an RgbColor or RgbaColor object. This utility function is only useful
514
- * if want to extract a color component. With the color util `toColorString` you
515
- * can convert a RgbColor or RgbaColor object back to a string.
516
- *
517
- * @example
518
- * // Assigns `{ red: 255, green: 0, blue: 0 }` to color1
519
- * const color1 = parseToRgb('rgb(255, 0, 0)');
520
- * // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
521
- * const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
522
- */
523
-
524
- function parseToRgb(color) {
525
- if (typeof color !== 'string') {
526
- throw new PolishedError(3);
527
- }
528
-
529
- var normalizedColor = nameToHex(color);
530
-
531
- if (normalizedColor.match(hexRegex)) {
532
- return {
533
- red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
534
- green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
535
- blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
536
- };
537
- }
538
-
539
- if (normalizedColor.match(hexRgbaRegex)) {
540
- var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
541
- return {
542
- red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
543
- green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
544
- blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
545
- alpha: alpha
546
- };
547
- }
548
-
549
- if (normalizedColor.match(reducedHexRegex)) {
550
- return {
551
- red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
552
- green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
553
- blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
554
- };
555
- }
556
-
557
- if (normalizedColor.match(reducedRgbaHexRegex)) {
558
- var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
559
-
560
- return {
561
- red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
562
- green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
563
- blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
564
- alpha: _alpha
565
- };
566
- }
567
-
568
- var rgbMatched = rgbRegex.exec(normalizedColor);
569
-
570
- if (rgbMatched) {
571
- return {
572
- red: parseInt("" + rgbMatched[1], 10),
573
- green: parseInt("" + rgbMatched[2], 10),
574
- blue: parseInt("" + rgbMatched[3], 10)
575
- };
576
- }
577
-
578
- var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
579
-
580
- if (rgbaMatched) {
581
- return {
582
- red: parseInt("" + rgbaMatched[1], 10),
583
- green: parseInt("" + rgbaMatched[2], 10),
584
- blue: parseInt("" + rgbaMatched[3], 10),
585
- alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
586
- };
587
- }
588
-
589
- var hslMatched = hslRegex.exec(normalizedColor);
590
-
591
- if (hslMatched) {
592
- var hue = parseInt("" + hslMatched[1], 10);
593
- var saturation = parseInt("" + hslMatched[2], 10) / 100;
594
- var lightness = parseInt("" + hslMatched[3], 10) / 100;
595
- var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
596
- var hslRgbMatched = rgbRegex.exec(rgbColorString);
597
-
598
- if (!hslRgbMatched) {
599
- throw new PolishedError(4, normalizedColor, rgbColorString);
600
- }
601
-
602
- return {
603
- red: parseInt("" + hslRgbMatched[1], 10),
604
- green: parseInt("" + hslRgbMatched[2], 10),
605
- blue: parseInt("" + hslRgbMatched[3], 10)
606
- };
607
- }
608
-
609
- var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
610
-
611
- if (hslaMatched) {
612
- var _hue = parseInt("" + hslaMatched[1], 10);
613
-
614
- var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
615
-
616
- var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
617
-
618
- var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
619
-
620
- var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
621
-
622
- if (!_hslRgbMatched) {
623
- throw new PolishedError(4, normalizedColor, _rgbColorString);
624
- }
625
-
626
- return {
627
- red: parseInt("" + _hslRgbMatched[1], 10),
628
- green: parseInt("" + _hslRgbMatched[2], 10),
629
- blue: parseInt("" + _hslRgbMatched[3], 10),
630
- alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
631
- };
632
- }
633
-
634
- throw new PolishedError(5);
635
- }
636
-
637
- /**
638
- * Reduces hex values if possible e.g. #ff8866 to #f86
639
- * @private
640
- */
641
- var reduceHexValue = function reduceHexValue(value) {
642
- if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
643
- return "#" + value[1] + value[3] + value[5];
644
- }
645
-
646
- return value;
647
- };
648
-
649
- var reduceHexValue$1 = reduceHexValue;
650
-
651
- function numberToHex(value) {
652
- var hex = value.toString(16);
653
- return hex.length === 1 ? "0" + hex : hex;
654
- }
655
-
656
- /**
657
- * Returns a string value for the color. The returned result is the smallest possible hex notation.
658
- *
659
- * @example
660
- * // Styles as object usage
661
- * const styles = {
662
- * background: rgb(255, 205, 100),
663
- * background: rgb({ red: 255, green: 205, blue: 100 }),
664
- * }
665
- *
666
- * // styled-components usage
667
- * const div = styled.div`
668
- * background: ${rgb(255, 205, 100)};
669
- * background: ${rgb({ red: 255, green: 205, blue: 100 })};
670
- * `
671
- *
672
- * // CSS in JS Output
673
- *
674
- * element {
675
- * background: "#ffcd64";
676
- * background: "#ffcd64";
677
- * }
678
- */
679
- function rgb(value, green, blue) {
680
- if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
681
- return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
682
- } else if (typeof value === 'object' && green === undefined && blue === undefined) {
683
- return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
684
- }
685
-
686
- throw new PolishedError(6);
687
- }
688
-
689
- /**
690
- * Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
691
- *
692
- * Can also be used to fade a color by passing a hex value or named CSS color along with an alpha value.
693
- *
694
- * @example
695
- * // Styles as object usage
696
- * const styles = {
697
- * background: rgba(255, 205, 100, 0.7),
698
- * background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
699
- * background: rgba(255, 205, 100, 1),
700
- * background: rgba('#ffffff', 0.4),
701
- * background: rgba('black', 0.7),
702
- * }
703
- *
704
- * // styled-components usage
705
- * const div = styled.div`
706
- * background: ${rgba(255, 205, 100, 0.7)};
707
- * background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
708
- * background: ${rgba(255, 205, 100, 1)};
709
- * background: ${rgba('#ffffff', 0.4)};
710
- * background: ${rgba('black', 0.7)};
711
- * `
712
- *
713
- * // CSS in JS Output
714
- *
715
- * element {
716
- * background: "rgba(255,205,100,0.7)";
717
- * background: "rgba(255,205,100,0.7)";
718
- * background: "#ffcd64";
719
- * background: "rgba(255,255,255,0.4)";
720
- * background: "rgba(0,0,0,0.7)";
721
- * }
722
- */
723
- function rgba(firstValue, secondValue, thirdValue, fourthValue) {
724
- if (typeof firstValue === 'string' && typeof secondValue === 'number') {
725
- var rgbValue = parseToRgb(firstValue);
726
- return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
727
- } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
728
- return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
729
- } else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
730
- return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
731
- }
732
-
733
- throw new PolishedError(7);
734
- }
735
-
736
- // Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
737
- // eslint-disable-next-line no-unused-vars
738
- // eslint-disable-next-line no-unused-vars
739
- // eslint-disable-next-line no-redeclare
740
- function curried(f, length, acc) {
741
- return function fn() {
742
- // eslint-disable-next-line prefer-rest-params
743
- var combined = acc.concat(Array.prototype.slice.call(arguments));
744
- return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
745
- };
746
- } // eslint-disable-next-line no-redeclare
747
-
748
-
749
- function curry(f) {
750
- // eslint-disable-line no-redeclare
751
- return curried(f, f.length, []);
752
- }
753
-
754
- /**
755
- * Mixes the two provided colors together by calculating the average of each of the RGB components weighted to the first color by the provided weight.
756
- *
757
- * @example
758
- * // Styles as object usage
759
- * const styles = {
760
- * background: mix(0.5, '#f00', '#00f')
761
- * background: mix(0.25, '#f00', '#00f')
762
- * background: mix('0.5', 'rgba(255, 0, 0, 0.5)', '#00f')
763
- * }
764
- *
765
- * // styled-components usage
766
- * const div = styled.div`
767
- * background: ${mix(0.5, '#f00', '#00f')};
768
- * background: ${mix(0.25, '#f00', '#00f')};
769
- * background: ${mix('0.5', 'rgba(255, 0, 0, 0.5)', '#00f')};
770
- * `
771
- *
772
- * // CSS in JS Output
773
- *
774
- * element {
775
- * background: "#7f007f";
776
- * background: "#3f00bf";
777
- * background: "rgba(63, 0, 191, 0.75)";
778
- * }
779
- */
780
-
781
- function mix(weight, color, otherColor) {
782
- if (color === 'transparent') return otherColor;
783
- if (otherColor === 'transparent') return color;
784
- if (weight === 0) return otherColor;
785
- var parsedColor1 = parseToRgb(color);
786
-
787
- var color1 = _extends({}, parsedColor1, {
788
- alpha: typeof parsedColor1.alpha === 'number' ? parsedColor1.alpha : 1
789
- });
790
-
791
- var parsedColor2 = parseToRgb(otherColor);
792
-
793
- var color2 = _extends({}, parsedColor2, {
794
- alpha: typeof parsedColor2.alpha === 'number' ? parsedColor2.alpha : 1
795
- }); // The formula is copied from the original Sass implementation:
796
- // http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method
797
-
798
-
799
- var alphaDelta = color1.alpha - color2.alpha;
800
- var x = parseFloat(weight) * 2 - 1;
801
- var y = x * alphaDelta === -1 ? x : x + alphaDelta;
802
- var z = 1 + x * alphaDelta;
803
- var weight1 = (y / z + 1) / 2.0;
804
- var weight2 = 1 - weight1;
805
- var mixedColor = {
806
- red: Math.floor(color1.red * weight1 + color2.red * weight2),
807
- green: Math.floor(color1.green * weight1 + color2.green * weight2),
808
- blue: Math.floor(color1.blue * weight1 + color2.blue * weight2),
809
- alpha: color1.alpha * parseFloat(weight) + color2.alpha * (1 - parseFloat(weight))
810
- };
811
- return rgba(mixedColor);
812
- } // prettier-ignore
813
-
814
-
815
- var curriedMix = /*#__PURE__*/curry
816
- /* ::<number | string, string, string, string> */
817
- (mix);
818
- var mix$1 = curriedMix;
819
-
820
- /**
821
- * Shades a color by mixing it with black. `shade` can produce
822
- * hue shifts, where as `darken` manipulates the luminance channel and therefore
823
- * doesn't produce hue shifts.
824
- *
825
- * @example
826
- * // Styles as object usage
827
- * const styles = {
828
- * background: shade(0.25, '#00f')
829
- * }
830
- *
831
- * // styled-components usage
832
- * const div = styled.div`
833
- * background: ${shade(0.25, '#00f')};
834
- * `
835
- *
836
- * // CSS in JS Output
837
- *
838
- * element {
839
- * background: "#00003f";
840
- * }
841
- */
842
-
843
- function shade(percentage, color) {
844
- if (color === 'transparent') return color;
845
- return mix$1(parseFloat(percentage), 'rgb(0, 0, 0)', color);
846
- } // prettier-ignore
847
-
848
-
849
- var curriedShade = /*#__PURE__*/curry
850
- /* ::<number | string, string, string> */
851
- (shade);
852
- var curriedShade$1 = curriedShade;
853
-
854
- const SPACING = 4;
855
- const BLACK = 'rgba(0,0,0,.87)';
856
- const WHITE = '#fff';
857
- const darkenPalette = (amount, palette, colorsToDarken) => Object
858
- .entries(palette)
859
- .reduce((acc, [key, val]) => (Object.assign(Object.assign({}, acc), { [key]: colorsToDarken.includes(key)
860
- ? curriedShade$1(amount, val)
861
- : val })), palette);
862
- const createButtonPalette = (_a) => {
863
- var { colorsToDarken } = _a, palette = __rest(_a, ["colorsToDarken"]);
864
- return ({
865
- idle: palette,
866
- hover: darkenPalette(.1, palette, colorsToDarken),
867
- active: darkenPalette(.2, palette, colorsToDarken),
868
- });
869
- };
870
- const createPanePalette = (palette) => ({
871
- main: {
872
- idle: palette,
873
- hover: darkenPalette(.05, palette, ['background'])
874
- },
875
- alternate: {
876
- idle: darkenPalette(.02, palette, ['background']),
877
- hover: darkenPalette(.05, palette, ['background']),
878
- }
879
- });
880
- const theme = {
881
- spacing: (...args) => args.map(arg => `${arg * SPACING}px`).join(' '),
882
- palette: {
883
- common: {
884
- black: BLACK,
885
- white: WHITE,
886
- },
887
- colors: {
888
- blue: '#007bff',
889
- indigo: '#6610f2',
890
- purple: '#6f42c1',
891
- pink: '#e83e8c',
892
- red: '#e83e3e',
893
- orange: '#fd7e14',
894
- yellow: '#ffc107',
895
- green: '#23B294',
896
- teal: '#20c997',
897
- cyan: '#17a2b8',
898
- gray: '#6c757d',
899
- grayDark: '#343a40',
900
- light: '#f8f9fa',
901
- dark: '#343a40',
902
- },
903
- form: {
904
- hint: '#C7C7C7',
905
- error: '#9f3a38',
906
- },
907
- button: {
908
- basic: createButtonPalette({
909
- colorsToDarken: ['background', 'text'],
910
- background: WHITE,
911
- text: BLACK,
912
- }),
913
- default: createButtonPalette({
914
- colorsToDarken: ['background', 'text'],
915
- background: '#e0e1e2',
916
- text: BLACK,
917
- }),
918
- text: {
919
- idle: {
920
- text: '#999c9e',
921
- background: 'transparent'
922
- },
923
- active: {
924
- text: BLACK,
925
- background: 'transparent'
926
- },
927
- hover: {
928
- text: BLACK,
929
- background: 'transparent'
930
- }
931
- },
932
- danger: createButtonPalette({
933
- colorsToDarken: ['background'],
934
- background: '#EC5969',
935
- text: WHITE,
936
- }),
937
- primary: createButtonPalette({
938
- colorsToDarken: ['background'],
939
- background: '#2284C4',
940
- text: WHITE,
941
- }),
942
- secondary: createButtonPalette({
943
- colorsToDarken: ['background'],
944
- background: '#23B294',
945
- text: WHITE
946
- }),
947
- },
948
- pane: {
949
- basic: createPanePalette({
950
- text: BLACK,
951
- background: WHITE,
952
- border: '#ddd'
953
- }),
954
- emphasized: createPanePalette({
955
- text: BLACK,
956
- background: '#f3f3f3',
957
- border: '#ddd'
958
- }),
959
- info: createPanePalette({
960
- text: '#0c5460',
961
- background: '#d1ecf1',
962
- border: '#bee5eb'
963
- }),
964
- negative: createPanePalette({
965
- text: '#721c24',
966
- background: '#f8d7da',
967
- border: '#f5c6cb'
968
- }),
969
- positive: createPanePalette({
970
- text: '#155724',
971
- background: '#d4edda',
972
- border: '#c3e6cb',
973
- }),
974
- warning: createPanePalette({
975
- text: '#856404',
976
- background: '#fff3cd',
977
- border: '#ffeeba'
978
- })
979
- }
980
- }
981
- };
982
-
983
- // Fix for styled-components with react-18.
984
- // Can be removed once this issue is resolved.
985
- // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/59765#issuecomment-1092938253
986
- const ThemeProviderFixed = styledComponents.ThemeProvider;
987
- const UiProvider = ({ children, theme: themeOverride }) => (React.createElement(ThemeProviderFixed, { theme: themeOverride || theme }, children));
988
-
989
- const noop$1 = () => { };
990
- const UiState = React.createContext({
991
- isSideMenuOpen: false,
992
- closeSideMenu: noop$1,
993
- openSideMenu: noop$1,
994
- });
995
- const useUiStateContext = () => React.useContext(UiState);
996
- const UiStateProvider = ({ children }) => {
997
- const [isSideMenuOpen, setIsSideMenuOpen] = React.useState(false);
998
- const handleCloseSideMenu = React.useCallback(() => setIsSideMenuOpen(false), []);
999
- const handleOpenSideMenu = React.useCallback(() => setIsSideMenuOpen(true), []);
1000
- return (React.createElement(UiState.Provider, { value: {
1001
- isSideMenuOpen,
1002
- closeSideMenu: handleCloseSideMenu,
1003
- openSideMenu: handleOpenSideMenu,
1004
- } }, children));
1005
- };
1006
-
1007
- const Wrapper$d = styledComponents.styled.div `
1008
- display: flex;
1009
- flex-direction: column;
1010
- height: 100%;
1011
- font-family: Lato, "Helvetica Neue", Arial, Helvetica, sans-serif;
1012
- color: ${props => props.theme.palette.common.black};
1013
- font-size: 14px;
1014
- `;
1015
- const UiWrapper = ({ theme, children }) => (React.createElement(UiProvider, { theme: theme },
1016
- React.createElement(UiStateProvider, null,
1017
- React.createElement(Wrapper$d, null, children))));
1018
-
1019
- function memoize(fn) {
1020
- var cache = Object.create(null);
1021
- return function (arg) {
1022
- if (cache[arg] === undefined) cache[arg] = fn(arg);
1023
- return cache[arg];
1024
- };
1025
- }
1026
-
1027
- var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
1028
-
1029
- var isPropValid = /* #__PURE__ */memoize(function (prop) {
1030
- return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
1031
- /* o */
1032
- && prop.charCodeAt(1) === 110
1033
- /* n */
1034
- && prop.charCodeAt(2) < 91;
1035
- }
1036
- /* Z+1 */
1037
- );
1038
-
1039
- const slideInFromTop = styledComponents.keyframes `
1040
- 0% {
1041
- opacity: 0;
1042
- transform: translateY(-5px);
1043
- }
1044
- 100% {
1045
- opacity: 1;
1046
- transform: translateY(0);
1047
- }
1048
- `;
1049
- const SlideInFromTop = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
1050
- animation: ${slideInFromTop} ${props => props.speed || '.3s'} ease-in 0s 1;
1051
- `;
1052
-
1053
- const sharedStyles$1 = styledComponents.css `
1054
- margin: 0 0;
1055
- padding: 0 0;
1056
- font-weight: 700;
1057
- line-height: 1.28571429em;
1058
- `;
1059
- const H1 = styledComponents.styled.h1.withConfig({ shouldForwardProp: isPropValid }) `
1060
- font-size: 2rem;
1061
- min-height: 1rem;
1062
- ${sharedStyles$1}
1063
- `;
1064
- const H2 = styledComponents.styled.h2.withConfig({ shouldForwardProp: isPropValid }) `
1065
- font-size: 1.71428571rem;
1066
- ${sharedStyles$1}
1067
- `;
1068
- const H3 = styledComponents.styled.h3.withConfig({ shouldForwardProp: isPropValid }) `
1069
- font-size: 1.28571429rem;
1070
- ${sharedStyles$1}
1071
- `;
1072
- const H4 = styledComponents.styled.h4.withConfig({ shouldForwardProp: isPropValid }) `
1073
- font-size: 1.07142857rem;
1074
- ${sharedStyles$1}
1075
- `;
1076
- const H5 = styledComponents.styled.h5.withConfig({ shouldForwardProp: isPropValid }) `
1077
- font-size: 1rem;
1078
- ${sharedStyles$1}
1079
- `;
1080
- const mapping = {
1081
- 1: H1,
1082
- 2: H2,
1083
- 3: H3,
1084
- 4: H4,
1085
- 5: H5,
1086
- };
1087
- const Header = (_a) => {
1088
- var { level = 1 } = _a, restProps = __rest(_a, ["level"]);
1089
- const Component = mapping[level];
1090
- // @ts-ignore
1091
- return React.createElement(Component, Object.assign({}, restProps));
1092
- };
1093
-
1094
- const Paragraph = styledComponents.styled.p `
1095
- font-size: 14px;
1096
- line-height: 20px;
1097
- // margin: 0 0 1em;
1098
- margin: 0;
1099
- `;
1100
-
1101
- const breakPoints = [
1102
- "mobile",
1103
- "tablet",
1104
- "laptop",
1105
- "desktop",
1106
- ];
1107
- const BreakPointValues = {
1108
- mobile: 0,
1109
- tablet: 768,
1110
- laptop: 1024,
1111
- desktop: 1430,
1112
- };
1113
- /**
1114
- * Wraps given cssRules in the corresponding media-query:
1115
- */
1116
- const mq = (bk, cssRules) => styledComponents.css `
1117
- @media screen and (min-width: ${BreakPointValues[bk]}px) {
1118
- ${cssRules}
1119
- }
1120
- `;
1121
- const isResponsiveObject = (obj) => {
1122
- if (typeof obj !== "object") {
1123
- return false;
1124
- }
1125
- const keys = Object.keys(obj);
1126
- for (const breakPoint of breakPoints) {
1127
- if (keys.includes(breakPoint)) {
1128
- return true;
1129
- }
1130
- }
1131
- return false;
1132
- };
1133
- /**
1134
- * Wraps 'responsive-props' in media-queries if necessary.
1135
- */
1136
- const responsiveProps = (props, map) => {
1137
- const nonResponsiveRules = Object
1138
- .entries(map)
1139
- .filter(([key]) => props[key] !== undefined && !isResponsiveObject(props[key]))
1140
- .map(([key, fun]) => fun(props[key]));
1141
- const mediaQueries = breakPoints
1142
- .map(bp => {
1143
- // See if we can make css-rules for this breakpoint:
1144
- const responsiveCssRules = Object
1145
- .entries(map)
1146
- .filter(([key]) => { var _a; return ((_a = props === null || props === void 0 ? void 0 : props[key]) === null || _a === void 0 ? void 0 : _a[bp]) !== undefined; })
1147
- .map(([key, fun]) => fun(props[key][bp]));
1148
- return (responsiveCssRules.length > 0)
1149
- ? mq(bp, responsiveCssRules) // Wrap css-rules in a mediaQuery
1150
- : undefined; // Undefined -> filter out later
1151
- })
1152
- .filter(_ => _ !== undefined);
1153
- return [
1154
- mediaQueries, ...nonResponsiveRules
1155
- ];
1156
- };
1157
-
1158
- const Box = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
1159
- box-sizing: border-box;
1160
-
1161
- ${(props) => responsiveProps(props, {
1162
- "p": unit => styledComponents.css `padding: ${props.theme.spacing(unit)};`,
1163
- "pt": unit => styledComponents.css `padding-top: ${props.theme.spacing(unit)};`,
1164
- "pr": unit => styledComponents.css `padding-right: ${props.theme.spacing(unit)};`,
1165
- "pb": unit => styledComponents.css `padding-bottom: ${props.theme.spacing(unit)};`,
1166
- "pl": unit => styledComponents.css `padding-left: ${props.theme.spacing(unit)};`,
1167
- "m": unit => styledComponents.css `margin: ${props.theme.spacing(unit)};`,
1168
- "mt": unit => styledComponents.css `margin-top: ${props.theme.spacing(unit)};`,
1169
- "mr": unit => styledComponents.css `margin-right: ${props.theme.spacing(unit)};`,
1170
- "mb": unit => styledComponents.css `margin-bottom: ${props.theme.spacing(unit)};`,
1171
- "ml": unit => styledComponents.css `margin-left: ${props.theme.spacing(unit)};`,
1172
- "display": unit => styledComponents.css `display: ${unit};`,
1173
- "flexGrow": unit => styledComponents.css `flex-grow: ${unit};`,
1174
- "flexShrink": unit => styledComponents.css `flex-shrink: ${unit};`,
1175
- "flexDirection": unit => styledComponents.css `flex-direction: ${unit};`,
1176
- "alignItems": unit => styledComponents.css `align-items: ${unit};`,
1177
- "textAlign": unit => styledComponents.css `text-align: ${unit};`,
1178
- "justifyContent": unit => styledComponents.css `justify-content: ${unit};`,
1179
- "width": unit => styledComponents.css `width: ${typeof unit === 'number' ? props.theme.spacing(unit) : unit};`,
1180
- })}
1181
- `;
1182
-
1183
- const Wrapper$c = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
1184
- border-radius: 4px;
1185
- border: 1px solid ${props => props.theme.palette.pane[props.variant].main.idle.border};
1186
- background-color: ${props => props.theme.palette.pane[props.variant].main.idle.background};
1187
- color: ${props => props.theme.palette.pane[props.variant].main.idle.text};
1188
- `;
1189
- const Alert = ({ children, title, variant = "basic" }) => (React.createElement(Wrapper$c, { variant: variant },
1190
- React.createElement(Box, { p: 3 },
1191
- title && (React.createElement(Box, { pb: children ? 1 : 0 },
1192
- React.createElement(Header, { level: 4 }, title))),
1193
- children && React.createElement(Paragraph, null, children))));
1194
-
1195
- const green = '#20c997';
1196
- const Mask = styledComponents.styled.g `
1197
- fill: none;
1198
- stroke: ${green};
1199
- stroke-width: 10;
1200
- `;
1201
- const polyLineAnimation = styledComponents.keyframes `
1202
- 0% {
1203
- stroke-dashoffset: 100px
1204
- }
1205
- 100% {
1206
- stroke-dashoffset: 0px
1207
- }
1208
- `;
1209
- const Polyline = styledComponents.styled.polyline `
1210
- stroke-dasharray: 100px, 100px;
1211
- stroke-dashoffset: 200px;
1212
- animation: ${polyLineAnimation} 0.42s ease-in-out 0.8s backwards;
1213
- stroke: ${green};
1214
- stroke-width: 10;
1215
- `;
1216
- const circleAnimation = styledComponents.keyframes `
1217
- 0% {
1218
- stroke-dashoffset: 480px
1219
- }
1220
- 100% {
1221
- stroke-dashoffset: 960px
1222
- }
1223
- `;
1224
- const Circle$1 = styledComponents.styled.circle `
1225
- stroke-dasharray: 480px, 480px;
1226
- stroke-dashoffset: 960px;
1227
- animation: ${circleAnimation} 0.6s ease-in-out backwards;
1228
- stroke: ${green};
1229
- stroke-width: 10;
1230
- `;
1231
- const circleColoredAnimation = styledComponents.keyframes `
1232
- 0% {
1233
- opacity:0;
1234
- }
1235
- 100% {
1236
- opacity:100;
1237
- }
1238
- `;
1239
- const CircleColored = styledComponents.styled.circle `
1240
- stroke-dasharray: 480px, 480px;
1241
- stroke-dashoffset: 960px;
1242
- animation: ${circleColoredAnimation} 1.2s ease-in-out 1.4s backwards;
1243
- fill: #effaf8;
1244
- `;
1245
- const AnimatedCheckmark = () => (React.createElement("svg", { viewBox: "0 0 154 154" },
1246
- React.createElement(Mask, null,
1247
- React.createElement(Circle$1, { cx: '77', cy: '77', r: '72' }),
1248
- React.createElement(CircleColored, { cx: '77', cy: '77', r: '72' }),
1249
- React.createElement(Polyline, { points: "43.5,77.8 63.7,97.9 112.2,49.4" }))));
1250
-
1251
- const BreadCrumbs = styledComponents.styled.ul `
1252
- list-style: none;
1253
- padding: 0;
1254
- margin: 0;
1255
- display:flex;
1256
- `;
1257
- const Crumb = styledComponents.styled.li `
1258
- display: flex;
1259
-
1260
- &:not(:last-of-type):after {
1261
- content: "/";
1262
- color: ${props => props.theme.palette.colors.gray};
1263
- line-height: 1em;
1264
- content: "/";
1265
- margin: auto auto;
1266
- padding: ${props => props.theme.spacing(0, 2, 0, 0)};
1267
- }
1268
- `;
1269
-
1270
- const Wrapper$b = styledComponents.styled.div `
1271
- background-color: ${props => props.theme.palette.common.white};
1272
- border-radius: 4px;
1273
- border: 1px solid #DEDEDF;
1274
- box-shadow: 0px 2px 3px rgb(0 0 0 / 6%);
1275
- `;
1276
- const Meta = styledComponents.styled(Box) `
1277
- font-size: 12px;
1278
- font-style: italic;
1279
- `;
1280
- const Title = styledComponents.styled(Box) `
1281
- ${(props) => props.panelHasChildren && styledComponents.css `
1282
- border-radius: 4px;
1283
- border-bottom: 1px solid rgba(34,36,38,.15);
1284
- `}
1285
-
1286
- ${(props) => !!props.onClick && styledComponents.css `
1287
- cursor: pointer;
1288
- user-select: none;
1289
- `}
1290
- `;
1291
- const Footer$1 = styledComponents.styled(Box) `
1292
- border-radius: 4px;
1293
- background-color: #FFF;
1294
- border-top: 1px solid rgba(34,36,38,.15);
1295
- `;
1296
- const Panel = ({ children, className, title, titleAction, titleMeta, onClickTitle, footer, p = 3, titleLevel = 5 }) => (React.createElement(Wrapper$b, { className: className },
1297
- title && (React.createElement(Title, { p: 3, panelHasChildren: !!children, display: "flex", alignItems: "center", onClick: onClickTitle },
1298
- React.createElement(Box, { flexGrow: 1 },
1299
- React.createElement(Header, { level: titleLevel }, title)),
1300
- titleMeta && React.createElement(Meta, null, titleMeta),
1301
- titleAction && React.createElement(Box, { pl: 5 }, titleAction))),
1302
- children && (React.createElement(Box, { p: p }, children)),
1303
- footer && (React.createElement(Footer$1, { p: 3 }, footer))));
1304
-
1305
- const Animation = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
1306
- transform: ${props => props.isOpen ? `translate(0)` : `translateY(-101%)`};
1307
- transition-duration: ${props => props.duration || 0.25}s;
1308
- transition-property: transform;
1309
- }
1310
- `;
1311
- const Wrapper$a = styledComponents.styled.div `
1312
- overflow: hidden;
1313
- `;
1314
- const Hider = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
1315
- display: ${props => props.isHidden ? 'none' : 'block'};
1316
- `;
1317
- // Returns the boolean value in the next tick.
1318
- // Allows for transition to start when DOM is updated, it prevents a flickers.
1319
- const useOnNextTick = (val) => {
1320
- const [delayedVal, setDelayedVal] = React.useState(val);
1321
- React.useEffect(() => {
1322
- const timeout = setTimeout(() => setDelayedVal(val), 0);
1323
- return () => clearTimeout(timeout);
1324
- }, [val, setDelayedVal]);
1325
- return delayedVal;
1326
- };
1327
- const SlideOpen = ({ isOpen, children, duration, onChange }) => {
1328
- const isDelayedOpen = useOnNextTick(isOpen);
1329
- const [isHidden, setIsHidden] = React.useState(!isOpen);
1330
- const handleTransitionEnd = React.useCallback(() => {
1331
- if (!isOpen) {
1332
- setIsHidden(true);
1333
- onChange === null || onChange === void 0 ? void 0 : onChange(false);
1334
- }
1335
- }, [isOpen, onChange]);
1336
- React.useEffect(() => {
1337
- if (isOpen) {
1338
- setIsHidden(false);
1339
- onChange === null || onChange === void 0 ? void 0 : onChange(true);
1340
- }
1341
- }, [isOpen, onChange]);
1342
- return (React.createElement(Wrapper$a, null,
1343
- React.createElement(Animation, { isOpen: isDelayedOpen, onTransitionEndCapture: handleTransitionEnd, duration: duration },
1344
- React.createElement(Hider, { isHidden: isHidden }, children))));
1345
- };
1346
-
1347
- const TitleActionWrapper = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
1348
- transform: scaleY( ${props => props.isOpen ? '-1' : '1'} );
1349
- `;
1350
- const StyledPanel$2 = styledComponents.styled(Panel) `
1351
- ${props => !props.isOpen && styledComponents.css `border-bottom: 0;`}
1352
- `;
1353
- const CollapsiblePanel = (_a) => {
1354
- var { isInitiallyOpen, children, titleAction } = _a, rest = __rest(_a, ["isInitiallyOpen", "children", "titleAction"]);
1355
- const [isOpen, setIsOpen] = React.useState(isInitiallyOpen);
1356
- const toggleOpen = React.useCallback(() => setIsOpen(!isOpen), [setIsOpen, isOpen]);
1357
- return (React.createElement(StyledPanel$2, Object.assign({}, rest, { isOpen: isOpen, onClickTitle: toggleOpen, p: 0, titleAction: React.createElement(TitleActionWrapper, { isOpen: isOpen }, titleAction) }),
1358
- React.createElement(SlideOpen, { isOpen: isOpen },
1359
- React.createElement(Box, { p: 3 }, children))));
1360
- };
1361
-
1362
- const useConfirmModal = ({ onConfirm }) => {
1363
- const [isOpen, setIsOpen] = React.useState(false);
1364
- const onCancel = () => setIsOpen(false);
1365
- const handleOpen = () => setIsOpen(true);
1366
- const handleConfirm = () => {
1367
- onConfirm();
1368
- setIsOpen(false);
1369
- };
1370
- return [
1371
- {
1372
- onCancel,
1373
- onConfirm: handleConfirm,
1374
- isOpen,
1375
- },
1376
- handleOpen,
1377
- ];
1378
- };
1379
-
1380
- const delay = styledComponents.keyframes `
1381
- 0% {
1382
- opacity: 0;
1383
- }
1384
- 100% {
1385
- opacity: 1;
1386
- }
1387
- `;
1388
- const Overlay = styledComponents.styled.div `
1389
- position: fixed;
1390
- top: 0;
1391
- left: 0;
1392
- right: 0;
1393
- bottom: 0;
1394
- z-index: 10;
1395
- opacity: 0;
1396
- background-color: rgba(0,0,0,0.6);
1397
- animation: ${delay} 0.2s forwards;
1398
- `;
1399
-
1400
- const Wrapper$9 = styledComponents.styled.div `
1401
- position: fixed;
1402
- top: 0;
1403
- left: 0;
1404
- right: 0;
1405
- bottom: 0;
1406
-
1407
- display: flex;
1408
- align-items: center;
1409
- justify-content: center;
1410
-
1411
- z-index: 50;
1412
- `;
1413
- const StyledPanel$1 = styledComponents.styled(Panel) `
1414
- box-shadow: 0 8px 8px 0 rgba(34,36,38,.15);
1415
- `;
1416
- const Content = styledComponents.styled.div `
1417
- line-height: ${props => props.theme.spacing(6)};
1418
- font-size: 15px;
1419
- `;
1420
- const Modal = (_a) => {
1421
- var { children, handleClickOverlay, buttons } = _a, panelProps = __rest(_a, ["children", "handleClickOverlay", "buttons"]);
1422
- return (React.createElement(React.Fragment, null,
1423
- React.createElement(Overlay, { onClick: handleClickOverlay }),
1424
- React.createElement(Wrapper$9, null,
1425
- React.createElement(SlideInFromTop, null,
1426
- React.createElement(StyledPanel$1, Object.assign({ footer: buttons ? (React.createElement(Box, { display: "flex", justifyContent: "flex-end" }, buttons)) : undefined }, panelProps), children && (React.createElement(Content, null, children)))))));
1427
- };
1428
-
1429
- const Wrapper$8 = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
1430
- ${props => props.stretch && `width: 100%;`}
1431
- ${props => props.actionButton || props.stretch
1432
- ? styledComponents.css `margin: 0;`
1433
- : styledComponents.css `margin: ${props => props.theme.spacing(0, 2, 0, 0)};`}
1434
- `;
1435
- const StyledButton$1 = styledComponents.styled.button.withConfig({ shouldForwardProp: isPropValid }) `
1436
- font-size: 14px;
1437
- font-weight: bold;
1438
- letter-spacing: 1px;
1439
- line-height: 1em;
1440
- outline: 0;
1441
- border: none;
1442
- border-radius: 4px;
1443
- cursor: pointer;
1444
- text-decoration: none;
1445
- font-family: "Open Sans", Lato, "Helvetica Neue", Arial, Helvetica, sans-serif;
1446
- transition: background-color .1s ease, color .1s ease;
1447
- display: flex;
1448
- flex-direction: row;
1449
- align-items: center;
1450
- user-select: none;
1451
- min-height: ${props => props.inline ? 'auto' : '38px'};
1452
-
1453
- ${props => props.stretch && styledComponents.css `
1454
- width: 100%;
1455
- display: block;
1456
- `}
1457
-
1458
- ${props => props.actionButton && styledComponents.css `
1459
- width: 100%;
1460
- ${mq('laptop', `width: auto`)}
1461
- `}
1462
-
1463
-
1464
- ${props => props.variant !== 'text'
1465
- ? !props.icon
1466
- ? styledComponents.css `padding: ${props.theme.spacing(3, 5)}; min-width: ${props => props.theme.spacing(10)};`
1467
- : props.hasChildren && styledComponents.css `position: relative; padding: ${props.theme.spacing(3, 5, 3, 13)};`
1468
- : styledComponents.css `font-weight: 700; padding: 0;`}
1469
-
1470
- &:disabled {
1471
- opacity: .5;
1472
- cursor: default;
1473
- }
1474
-
1475
- &:focus {
1476
- background-blend-mode: darken;
1477
- }
1478
-
1479
- ${(props) => {
1480
- if (props.variant === "basic") {
1481
- return `
1482
- border: 1px solid rgba(34,36,38,.15);
1483
- `;
1484
- }
1485
- }}
1486
-
1487
- ${(props) => {
1488
- var _a;
1489
- const { idle, hover, active } = theme.palette.button[(_a = props.variant) !== null && _a !== void 0 ? _a : 'default'];
1490
- return `
1491
- color: ${idle.text};
1492
- background-color: ${idle.background};
1493
-
1494
- &:not(:disabled) {
1495
- &:hover, &:focus {
1496
- color: ${hover.text};
1497
- background-color: ${hover.background};
1498
- }
1499
-
1500
- &:active {
1501
- color: ${active.text};
1502
- background-color: ${active.background};
1503
- }
1504
- }
1505
-
1506
- `;
1507
- }}
1508
- `;
1509
- const IconWrapper$1 = styledComponents.styled.span.withConfig({ shouldForwardProp: isPropValid }) `
1510
- ${props => props.variant !== "text" && styledComponents.css `
1511
- min-width: ${props.theme.spacing(10)};
1512
- `}
1513
-
1514
- ${props => props.variant === "text"
1515
- ? props.hasChildren && styledComponents.css `
1516
- padding-right: ${props.theme.spacing(2)};
1517
- `
1518
- : props.hasChildren && styledComponents.css `
1519
- position: absolute;
1520
- left: 0;
1521
- top: 0;
1522
- width: ${props => props.theme.spacing(10)};
1523
- height: 100%;
1524
- background-color: rgba(0,0,0,.05);
1525
-
1526
- & > svg {
1527
- transform: translate(-50%, -50%);
1528
- position: absolute;
1529
- top: 50%;
1530
- left: 50%;
1531
- }
1532
- `}
1533
- `;
1534
- const Button$1 = React.forwardRef((_a, ref) => {
1535
- var { children, icon, stretch } = _a, props = __rest(_a, ["children", "icon", "stretch"]);
1536
- return (React.createElement(Wrapper$8, { actionButton: props.actionButton, stretch: stretch },
1537
- React.createElement(StyledButton$1, Object.assign({ ref: ref, icon: icon, hasChildren: !!children, stretch: stretch }, props),
1538
- icon && (React.createElement(IconWrapper$1, { variant: props.variant, hasChildren: !!children }, icon)),
1539
- children)));
1540
- });
1541
-
1542
- const ConfirmModal = ({ title, children, cancelLabel = "Nee, annuleren", confirmLabel = "Ja", confirmVariant = 'secondary', confirmIcon, cancelIcon, isOpen, onCancel, onConfirm, }) => {
1543
- return isOpen ? (React.createElement(Modal, { title: title, handleClickOverlay: onCancel, buttons: React.createElement(React.Fragment, null,
1544
- React.createElement(Button$1, { "data-testid": "btn-cancel", onClick: onCancel, variant: "basic", icon: cancelIcon }, cancelLabel),
1545
- React.createElement(Button$1, { "data-testid": "btn-confirm", onClick: onConfirm, variant: confirmVariant, icon: confirmIcon }, confirmLabel)) }, children)) : null;
1546
- };
1547
-
1548
- const noop = () => { };
1549
- const ConfirmButton = (_a) => {
1550
- var _b;
1551
- var { modalProps } = _a, buttonProps = __rest(_a, ["modalProps"]);
1552
- const [modalHandlerProps, openModal] = useConfirmModal({
1553
- onConfirm: (_b = modalProps.onConfirm) !== null && _b !== void 0 ? _b : noop
1554
- });
1555
- return React.createElement(React.Fragment, null,
1556
- React.createElement(Button$1, Object.assign({}, buttonProps, { onClick: openModal })),
1557
- React.createElement(ConfirmModal, Object.assign({ title: "Are you sure?" }, modalProps, modalHandlerProps)));
1558
- };
1559
-
1560
- const StyledTable = styledComponents.styled.table.withConfig({ shouldForwardProp: isPropValid }) `
1561
- border-radius: 4px;
1562
- width: 100%;
1563
- border-collapse: separate;
1564
- border-spacing: 0;
1565
-
1566
- ${(props) => responsiveProps(props, {
1567
- "tableLayout": unit => styledComponents.css `table-layout: ${unit};`,
1568
- })}
1569
- `;
1570
- const StyledTableRow = styledComponents.styled.tr.withConfig({ shouldForwardProp: isPropValid }) `
1571
- & > td {
1572
- transition: background-color .1s ease, color .1s ease;
1573
- }
1574
-
1575
- ${props => Object.entries(props.theme.palette.pane).map(([variant, value]) => `
1576
- &:nth-child(odd) > td.${variant} {
1577
- color: ${value.main.idle.text};
1578
- background-color: ${value.main.idle.background};
1579
- }
1580
- &:nth-child(even) > td.${variant} {
1581
- color: ${value.alternate.idle.text};
1582
- background-color: ${value.alternate.idle.background};
1583
- }
1584
-
1585
-
1586
- ${!props.disableHover && `
1587
- &:nth-child(odd):hover > td.${variant} {
1588
- color: ${value.main.hover.text};
1589
- background-color: ${value.main.hover.background};
1590
- }
1591
- &:nth-child(even):hover > td.${variant} {
1592
- color: ${value.alternate.hover.text};
1593
- background-color: ${value.alternate.hover.background};
1594
- }
1595
- `}
1596
- `)}
1597
- `;
1598
- const StyledTableCell = styledComponents.styled.td.withConfig({ shouldForwardProp: isPropValid }) `
1599
- border-top: 1px solid rgba(34,36,38,.1);
1600
- border-right: 1px solid rgba(34,36,38,.1);
1601
- padding: ${props => props.theme.spacing(2, 3)};
1602
-
1603
- &:last-of-type {
1604
- border-right: 0;
1605
- }
1606
-
1607
- ${(props) => responsiveProps(props, {
1608
- width: unit => styledComponents.css `width: ${unit};`,
1609
- })}
1610
- `;
1611
- const StyledTableHeadCell = styledComponents.styled.th.withConfig({ shouldForwardProp: isPropValid }) `
1612
- border-right: 1px solid rgba(34,36,38,.1);
1613
- text-align: left;
1614
- padding: ${props => props.theme.spacing(2, 3)};
1615
- font-weight: 700;
1616
- transition: background-color .1s ease, color .1s ease;
1617
-
1618
- &:last-of-type {
1619
- border-right: 0;
1620
- }
1621
-
1622
- ${props => !!props.variant && styledComponents.css `
1623
- color: ${props.theme.palette.pane[props.variant].main.idle.text};
1624
- background-color: ${props.theme.palette.pane[props.variant].main.idle.background};
1625
-
1626
- &:hover {
1627
- color: ${props.theme.palette.pane[props.variant].main.hover.text};
1628
- background-color: ${props.theme.palette.pane[props.variant].main.hover.background};
1629
- }
1630
- `}
1631
-
1632
- ${props => props.width ? `width: ${props.width};` : ''}
1633
-
1634
- ${props => props.sortable && `
1635
- cursor: pointer;
1636
- user-select: none;
1637
-
1638
- &:hover {
1639
- background-color: ${props.theme.palette.pane.basic.main.hover.background};
1640
- }
1641
- `}
1642
-
1643
- ${props => props.sortDirection && `
1644
- position:relative;
1645
-
1646
- &:after {
1647
- content: " ";
1648
- position: absolute;
1649
- right: 15px;
1650
- top: 50%;
1651
-
1652
- height: 0;
1653
- width: 0;
1654
- border: 5px solid transparent;
1655
-
1656
- ${props.sortDirection === 'asc' ? `
1657
- border-top-color: #000;
1658
- transform: translateY(-25%);
1659
- ` : `
1660
- border-bottom-color: #000;
1661
- transform: translateY(-75%);
1662
- `}
1663
- }
1664
- `}
1665
- `;
1666
- // Wrapper to allow for dot notated components:
1667
- const Table = (props) => (React.createElement(StyledTable, Object.assign({}, props)));
1668
- const TableCell = (_a) => {
1669
- var { variant, className } = _a, rest = __rest(_a, ["variant", "className"]);
1670
- return (React.createElement(StyledTableCell, Object.assign({ className: `${className || ''} ${variant || 'basic'}` }, rest)));
1671
- };
1672
- Table.Row = StyledTableRow;
1673
- Table.HeadCell = StyledTableHeadCell;
1674
- Table.Cell = TableCell;
1675
-
1676
- const StyledCell = styledComponents.styled(Table.Cell) `
1677
- ${(props) => props.firstRow && styledComponents.css ` border-top: 0px !important;`}
1678
- ${(props) => props.width && styledComponents.css ` width: ${props.width};`}
1679
- vertical-align: top;
1680
- `;
1681
- const Details = ({ details, firstColumnWidth }) => (React.createElement(Table, null,
1682
- React.createElement("tbody", null, Object.entries(details).map(([key, val], index) => (React.createElement(Table.Row, { key: key, disableHover: true },
1683
- React.createElement(StyledCell, { width: firstColumnWidth, firstRow: index === 0 }, key),
1684
- React.createElement(StyledCell, { firstRow: index === 0 }, val)))))));
1685
-
1686
- const Wrapper$7 = styledComponents.styled.div `
1687
- position: relative;
1688
- `;
1689
- const Dropper = styledComponents.styled.span.withConfig({ shouldForwardProp: isPropValid }) `
1690
- border-radius: 4px;
1691
- border: 1px solid rgba(34,36,38,.15);
1692
- position: absolute;
1693
- box-shadow: 0 8px 8px 0 rgba(34,36,38,.15);
1694
- background-color: ${props => props.theme.palette.common.white};
1695
- z-index: 100;
1696
-
1697
- ${props => props.align === 'right' ? styledComponents.css `right: 0;` : styledComponents.css `left: 0;`}
1698
- `;
1699
- const DropdownMenu = styledComponents.styled.ul `
1700
- list-style: none;
1701
- margin: 0;
1702
- padding: ${props => props.theme.spacing(2, 0)};
1703
- `;
1704
- const DropdownMenuItem = styledComponents.styled.li `
1705
- cursor: pointer;
1706
- padding: ${props => props.theme.spacing(0, 3)};
1707
- &:hover {
1708
- background-color: #ddd;
1709
- }
1710
- `;
1711
- const Dropdown = ({ buttonProps, align, children, stayOpenOnClick }) => {
1712
- const dropper = React.useRef(null);
1713
- const [isOpen, setIsOpen] = React.useState(false);
1714
- const handleOpen = React.useCallback(() => setIsOpen(true), [setIsOpen]);
1715
- const handleClose = React.useCallback((e) => {
1716
- var _a;
1717
- if (stayOpenOnClick && ((_a = dropper.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)))
1718
- return;
1719
- setIsOpen(false);
1720
- }, [setIsOpen, stayOpenOnClick]);
1721
- React.useEffect(() => {
1722
- if (isOpen) {
1723
- setTimeout(() => document.addEventListener('click', handleClose), 1);
1724
- }
1725
- return () => {
1726
- document.removeEventListener('click', handleClose);
1727
- };
1728
- }, [isOpen, handleClose]);
1729
- return (React.createElement(Wrapper$7, null,
1730
- React.createElement(Button$1, Object.assign({}, buttonProps, { onClick: handleOpen })),
1731
- isOpen && (React.createElement(SlideInFromTop, { speed: '.1s' },
1732
- React.createElement(Dropper, { ref: dropper, align: align || 'left' }, children)))));
1733
- };
1734
-
1735
- const HiddenInput$1 = styledComponents.styled.input `
1736
- display: none;
1737
- `;
1738
- const StyledDropZone = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
1739
- display: flex;
1740
- flex-direction: column;
1741
- align-items: center;
1742
- justify-content: center;
1743
- border-radius: 4px;
1744
- height: ${props => props.theme.spacing(25)};
1745
-
1746
- border-radius: 4px;
1747
- border: 1px solid rgba(34,36,38,.15);
1748
-
1749
- & > * {
1750
- pointerEvents: none;
1751
- }
1752
-
1753
- ${props => props.isReadyToDrop && styledComponents.css `
1754
- background-color: #FAFAFA;
1755
- `}
1756
- `;
1757
- const Dropzone = (_a) => {
1758
- var { onChange, icon, label } = _a, rest = __rest(_a, ["onChange", "icon", "label"]);
1759
- const fileInput = React.useRef(null);
1760
- const dropzone = React.useRef(null);
1761
- const [isReadyToDrop, setIsReadyToDrop] = React.useState(false);
1762
- const handleChange = React.useCallback((fileList) => {
1763
- if (fileList && onChange) {
1764
- onChange(Array.from(fileList));
1765
- }
1766
- }, [onChange]);
1767
- const handleDragOver = React.useCallback((e) => {
1768
- e.preventDefault();
1769
- setIsReadyToDrop(true);
1770
- }, []);
1771
- const handleDragLeave = React.useCallback((e) => {
1772
- e.preventDefault();
1773
- setIsReadyToDrop(false);
1774
- }, []);
1775
- const handleDrop = React.useCallback((e) => {
1776
- var _a;
1777
- e.preventDefault();
1778
- setIsReadyToDrop(false);
1779
- handleChange((_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files);
1780
- }, [handleChange]);
1781
- const handleClick = React.useCallback(() => {
1782
- var _a;
1783
- // We trigger the 'file pick' dialog by delegating the click to a hidden file-input.
1784
- (_a = fileInput.current) === null || _a === void 0 ? void 0 : _a.click();
1785
- }, [fileInput]);
1786
- const handleInputChange = React.useCallback(() => {
1787
- var _a;
1788
- handleChange((_a = fileInput === null || fileInput === void 0 ? void 0 : fileInput.current) === null || _a === void 0 ? void 0 : _a.files);
1789
- }, [fileInput, handleChange]);
1790
- return (React.createElement(StyledDropZone, Object.assign({ ref: dropzone, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: handleClick, isReadyToDrop: isReadyToDrop }, rest),
1791
- React.createElement(HiddenInput$1, { "data-testid": "dropzone-file-input", type: "file", ref: fileInput, onChange: handleInputChange, multiple: true }),
1792
- React.createElement(Box, null,
1793
- React.createElement(Button$1, { variant: "text", color: "secondary", type: "button", icon: icon }, label))));
1794
- };
1795
-
1796
- const StyledBox$6 = styledComponents.styled(Box) `
1797
- width: 300px;
1798
- `;
1799
- const Feedback = ({ onConfirm, buttonLabel, buttonIcon, title, subtitle }) => (React.createElement(Modal, { handleClickOverlay: onConfirm, buttons: React.createElement(Button$1, { "data-testid": 'confirm', stretch: true, icon: buttonIcon, variant: 'secondary', onClick: onConfirm }, buttonLabel) },
1800
- React.createElement(StyledBox$6, { pt: 3, pb: 3 },
1801
- React.createElement(Box, { pb: 5, textAlign: "center" },
1802
- React.createElement(Header, null, title),
1803
- subtitle && React.createElement(Box, { pt: 5 },
1804
- React.createElement(Header, { level: 5 }, subtitle))),
1805
- React.createElement(Box, { pt: 5, pb: 5, pl: 7, pr: 7 },
1806
- React.createElement(AnimatedCheckmark, null)))));
1807
-
1808
- const horizontalPadding = { laptop: 1 };
1809
- const verticalPadding = { mobile: 1, laptop: 0 };
1810
- const flexGrow = { laptop: 1 };
1811
- const FloaterItem = (_a) => {
1812
- var { stretch, laptopWidth } = _a, props = __rest(_a, ["stretch", "laptopWidth"]);
1813
- const width = React.useMemo(() => ({ laptop: laptopWidth }), [laptopWidth]);
1814
- return React.createElement(Box, Object.assign({ flexGrow: stretch ? flexGrow : undefined, width: width, pt: verticalPadding, pb: verticalPadding, pl: horizontalPadding, pr: horizontalPadding }, props));
1815
- };
1816
-
1817
- const horizontalMargin = { laptop: -1 };
1818
- const verticalMargin = { mobile: -1, laptop: 0 };
1819
- const display = { mobile: "block", laptop: "flex" };
1820
- const hasElement = (item) => !!item.element;
1821
- const Floater = (_a) => {
1822
- var { items, forceEqualWidth = false, stretch = false } = _a, props = __rest(_a, ["items", "forceEqualWidth", "stretch"]);
1823
- return React.createElement(Box, Object.assign({ mb: verticalMargin, mt: verticalMargin, ml: horizontalMargin, mr: horizontalMargin, display: display }, props), items
1824
- .filter(Boolean)
1825
- .map((item, i) => hasElement(item)
1826
- ? (React.createElement(FloaterItem, { key: i, laptopWidth: item.forceEqualWidth ? `${100 / items.length}%` : undefined, stretch: item.stretch || false }, item.element))
1827
- : React.createElement(FloaterItem, { key: i, laptopWidth: forceEqualWidth ? `${100 / items.length}%` : undefined, stretch: stretch }, item)));
1828
- };
1829
-
1830
- const SIDEBAR_COLLAPSED_WIDTH = 15;
1831
- const StyledSidebar = styledComponents.styled(Box) `
1832
- float: left;
1833
-
1834
- height: 100%;
1835
- width: 100%;
1836
-
1837
- background-color: #243646;
1838
-
1839
- position: fixed;
1840
- top: 0;
1841
- left: 0;
1842
- right: 0;
1843
- bottom: 0;
1844
-
1845
- z-index: 900;
1846
-
1847
- display: ${props => props.isMobileMenuOpen ? 'block' : 'none'};
1848
- pointer-events: auto;
1849
-
1850
- ${mq("laptop", styledComponents.css `
1851
- position: static;
1852
- display: block;
1853
- width: auto;
1854
- min-width: ${props => { var _a; return props.theme.spacing((_a = props.minWidth) !== null && _a !== void 0 ? _a : 75); }};
1855
- box-shadow: 2px 0px 6px -1px rgba(0,0,0,0.74);
1856
-
1857
- transition: transform .1s ease-out;
1858
- transform: ${props => props.isDesktopMenuOpen
1859
- ? 'transform: translateX(0);'
1860
- : styledComponents.css `translateX(calc(-100% + ${props => props.theme.spacing(SIDEBAR_COLLAPSED_WIDTH)}));`};
1861
-
1862
- & ul {
1863
- opacity: ${props => props.isDesktopMenuOpen ? '1' : '0'};
1864
- }
1865
- `)}
1866
- `;
1867
- const SideBar = (props) => {
1868
- const { closeSideMenu, openSideMenu, isSideMenuOpen } = useUiStateContext();
1869
- return React.createElement(StyledSidebar, Object.assign({ isDesktopMenuOpen: isSideMenuOpen }, props, { onMouseEnter: openSideMenu, onMouseLeave: closeSideMenu }));
1870
- };
1871
-
1872
- const StyledBox$5 = styledComponents.styled(Box) `
1873
- background-color: ${props => props.theme.palette.common.white};
1874
- border-top: 1px solid #DDDDDD;
1875
- box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.04);
1876
- box-sizing: border-box;
1877
- `;
1878
- const Footer = ({ children }) => (React.createElement(StyledBox$5, { pt: 2, pb: 2, pr: 5, pl: { mobile: 5, laptop: SIDEBAR_COLLAPSED_WIDTH + 5 } }, children));
1879
-
1880
- const Scroller = styledComponents.styled(Box) `
1881
- overflow-x: auto;
1882
- overflow-y: hidden;
1883
- `;
1884
- const HorizontalScroller = ({ children }) => (React.createElement(Scroller, null, children));
1885
-
1886
- const HamburgerButton = styledComponents.styled(Button$1) `
1887
- margin-right: ${props => props.theme.spacing(3)};
1888
- ${mq("laptop", `display: none;`)}
1889
- `;
1890
-
1891
- const Menu = styledComponents.styled.ul `
1892
- padding: 0;
1893
- margin: 0;
1894
- list-style: none;
1895
- `;
1896
- const StyledMenuItem = styledComponents.styled.li.withConfig({ shouldForwardProp: isPropValid }) `
1897
- padding: ${props => props.theme.spacing(.5, 5)};
1898
-
1899
- ${props => props.isOpen && styledComponents.css `
1900
- border-left: ${props.theme.spacing(1)} solid ${props.theme.palette.colors.blue};
1901
- background: #293846;
1902
-
1903
- & > * {
1904
- margin-left: ${props.theme.spacing(-1)};
1905
- }
1906
- `}
1907
-
1908
- & button:hover, & button:active, & button:focus {
1909
- color: ${props => props.theme.palette.common.white} !important;
1910
- }
1911
-
1912
- & button {
1913
- width: 100%;
1914
- }
1915
-
1916
- ${props => props.isActive && styledComponents.css `
1917
- & button {
1918
- color: ${props.theme.palette.common.white};
1919
- }
1920
- `}
1921
- `;
1922
- const MenuItem = ({ item, isOpen, isActive, children }) => {
1923
- const [isDelayedOpen, setDelayedOpen] = React.useState(!!isOpen);
1924
- return (React.createElement(StyledMenuItem, { isOpen: isDelayedOpen, isActive: !!isActive },
1925
- item,
1926
- children && (React.createElement(SlideOpen, { onChange: setDelayedOpen, isOpen: !!isOpen, duration: .25 }, children))));
1927
- };
1928
-
1929
- const MenuCloseButton = styledComponents.styled(Button$1) `
1930
- ${mq("laptop", `display: none;`)}
1931
- `;
1932
-
1933
- const StyledBox$4 = styledComponents.styled(Box) `
1934
- display: none;
1935
- ${mq("laptop", `display: flex;`)}
1936
-
1937
- height: 100%;
1938
- flex-direction: row;
1939
- align-items: center;
1940
-
1941
- width: ${props => props.theme.spacing(SIDEBAR_COLLAPSED_WIDTH)};
1942
-
1943
- & > svg {
1944
- margin: 0 auto;
1945
- }
1946
-
1947
- ${StyledSidebar}:hover & {
1948
- display:none;
1949
- }
1950
- `;
1951
- const MenuSlideOpenIndicator = ({ children }) => (React.createElement(StyledBox$4, null, children));
1952
-
1953
- const VerticalRhythmLaptop = 7;
1954
- const VerticalRhythmMobile = 4;
1955
-
1956
- const StyledBox$3 = styledComponents.styled(Box) `
1957
- box-sizing: border-box;
1958
- color: ${props => props.theme.palette.button.text.idle.text};
1959
- font-weight: bold;
1960
-
1961
- display: flex;
1962
- text-align: center;
1963
-
1964
- font-size: 14px;
1965
- font-weight: bold;
1966
- letter-spacing: 1px;
1967
- line-height: 1em;
1968
-
1969
- background-color: rgba(0,0,0,.2);
1970
-
1971
- ${mq('laptop', styledComponents.css `
1972
- min-height: ${props => props.theme.spacing(12)};
1973
- `)}
1974
- `;
1975
- const SideBarHeader = ({ children, right }) => (React.createElement(StyledBox$3, { mb: VerticalRhythmLaptop },
1976
- React.createElement(Box, { flexGrow: 1, display: "flex" },
1977
- React.createElement(Box, { flexGrow: 1, display: "flex", flexDirection: "column", justifyContent: "center" }, children)),
1978
- right && React.createElement(Box, null, right)));
1979
-
1980
- const useCloseSidebarOnNavigate = (pathName) => {
1981
- const { closeSideMenu } = useUiStateContext();
1982
- React.useEffect(() => {
1983
- closeSideMenu();
1984
- }, [pathName, closeSideMenu]);
1985
- };
1986
-
1987
- const useToggleMobileMenu = ({ currentRoute }) => {
1988
- const [isOpen, setIsOpen] = React.useState(false);
1989
- const toggle = React.useCallback(() => {
1990
- setIsOpen((val) => !val);
1991
- }, []);
1992
- const open = React.useCallback(() => {
1993
- setIsOpen(true);
1994
- }, []);
1995
- const close = React.useCallback(() => {
1996
- setIsOpen(false);
1997
- }, []);
1998
- React.useEffect(() => {
1999
- close();
2000
- }, [currentRoute, close]);
2001
- return {
2002
- isOpen,
2003
- open,
2004
- close,
2005
- toggle
2006
- };
2007
- };
2008
-
2009
- const useResponsiveBreakpoints = () => {
2010
- const [windowWidth, setWindowWidth] = React.useState(window.innerWidth);
2011
- React.useEffect(() => {
2012
- const onResize = () => setWindowWidth(window.innerWidth);
2013
- window.addEventListener('resize', onResize);
2014
- return () => window.removeEventListener('resize', onResize);
2015
- }, []);
2016
- const responsiveMap = React.useMemo(() => ({
2017
- isMobile: windowWidth >= BreakPointValues.mobile,
2018
- isTablet: windowWidth >= BreakPointValues.tablet,
2019
- isLaptop: windowWidth >= BreakPointValues.laptop,
2020
- isDesktop: windowWidth >= BreakPointValues.desktop
2021
- }), [windowWidth]);
2022
- return responsiveMap;
2023
- };
2024
-
2025
- const Wrapper$6 = styledComponents.styled.div `
2026
- display: flex;
2027
- `;
2028
- const Button = styledComponents.styled.button.withConfig({ shouldForwardProp: isPropValid }) `
2029
- user-select:none;
2030
- cursor: pointer;
2031
-
2032
- min-height: ${props => props.theme.spacing(8)};
2033
- padding: .2em 1.3em .2em;
2034
- margin: 0;
2035
- line-height: 1em;
2036
- outline: 0;
2037
- border: 1px solid rgba(34,36,38,.15);
2038
-
2039
- font-family: Lato, "Helvetica Neue", Arial, Helvetica, sans-serif;
2040
- background-color: ${props => props.active ? '#F2F2F2' : '#fff'};
2041
-
2042
- &:not(:first-of-type) {
2043
- border-left: 0;
2044
- }
2045
-
2046
- ${props => !props.disabled && (`
2047
- &:hover {
2048
- background-color: #E9E9E9;
2049
- }
2050
- `)}
2051
- `;
2052
- const range = (start, end) => {
2053
- let nums = [];
2054
- for (let i = start; i < end; i++) {
2055
- nums.push(i);
2056
- }
2057
- return nums;
2058
- };
2059
- const Paginator = (props) => {
2060
- const { isTablet } = useResponsiveBreakpoints();
2061
- const { pageCount, onChange } = props;
2062
- const currentPage = Math.min(Math.max(props.currentPage, 0), pageCount);
2063
- const clamSize = isTablet ? 2 : 0;
2064
- const clamLower = Math.max(1, currentPage - clamSize);
2065
- const clamUpper = Math.min(pageCount, currentPage + clamSize);
2066
- return (React.createElement(Wrapper$6, null,
2067
- React.createElement(Button, { "data-testid": "paginate-prev", disabled: currentPage === 1, onClick: () => onChange(currentPage - 1) }, "\u27E8"),
2068
- clamLower > 1 && (React.createElement(Button, { "data-testid": "paginate-page-1", active: currentPage === 1, onClick: () => onChange(1) }, "1")),
2069
- clamLower > 2 && (React.createElement(Button, { disabled: true }, "...")),
2070
- range(clamLower, clamUpper + 1).map((pageNumber) => (React.createElement(Button, { "data-testid": `paginate-page-${pageNumber}`, key: pageNumber, active: currentPage === pageNumber, onClick: () => onChange(pageNumber) }, pageNumber))),
2071
- clamUpper < pageCount - 1 && (React.createElement(Button, { disabled: true }, "...")),
2072
- clamUpper < pageCount && (React.createElement(Button, { "data-testid": `paginate-page-${pageCount}`, active: currentPage === pageCount, onClick: () => onChange(pageCount) }, pageCount)),
2073
- React.createElement(Button, { "data-testid": "paginate-next", disabled: currentPage === pageCount, onClick: () => onChange(currentPage + 1) }, "\u27E9")));
2074
- };
2075
-
2076
- const Section = (props) => (React.createElement(Box, Object.assign({ pb: { laptop: VerticalRhythmLaptop, mobile: VerticalRhythmMobile } }, props)));
2077
-
2078
- const Wrapper$5 = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
2079
- display: flex;
2080
- border-radius: ${props => props.theme.spacing(1)};
2081
- padding: ${props => props.theme.spacing(4)};
2082
- background-color: ${props => props.theme.palette.colors[props.backgroundColor]};
2083
- box-sizing: border-box;
2084
- height: 100%;
2085
- `;
2086
- const Label$2 = styledComponents.styled.div `
2087
- text-transform: uppercase;
2088
- color: ${props => props.theme.palette.common.white};
2089
- font-size: ${props => props.theme.spacing(3)};
2090
- `;
2091
- const Value = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
2092
- color: ${props => props.theme.palette.common.white};
2093
- font-weight: bold;
2094
- font-size: ${props => props.theme.spacing(props.smallerValue ? 5.5 : 7.5)};
2095
- `;
2096
- const IconWrapper = styledComponents.styled.div `
2097
- margin: ${props => props.theme.spacing(1)} 0 auto 0;
2098
- & svg {
2099
- height: 100%;
2100
- width: ${props => props.theme.spacing(10)};
2101
- color: white;
2102
- }
2103
- `;
2104
- const Statistic = ({ icon, value, label, backgroundColor, smallerValue }) => (React.createElement(Wrapper$5, { backgroundColor: backgroundColor },
2105
- React.createElement(IconWrapper, null, icon),
2106
- React.createElement(Box, { flexGrow: 1, textAlign: "right" },
2107
- React.createElement(Label$2, null, label),
2108
- React.createElement(Value, { smallerValue: smallerValue }, value))));
2109
-
2110
- const StyledBox$2 = styledComponents.styled(Box) `
2111
-
2112
- padding: ${props => props.theme.spacing(2.5, 5)};
2113
-
2114
- ${props => !props.isActive && styledComponents.css `
2115
- cursor: pointer;
2116
- color: #337ab7;
2117
- &:hover,
2118
- &:focus {
2119
- color: #23527c;
2120
- text-decoration: underline;
2121
- }
2122
- `}
2123
-
2124
- ${props => props.isActive && styledComponents.css `
2125
- font-weight: bold;
2126
- border: 1px solid rgba(34,36,38,.15);
2127
- border-bottom: 0px;
2128
- margin-bottom: -1px;
2129
- border-top-left-radius: 4px;
2130
- border-top-right-radius: 4px;
2131
- background-color: ${props => props.theme.palette.common.white};
2132
- `}
2133
-
2134
- ${props => props.variant && `
2135
- font-weight: bold;
2136
- color: ${props.theme.palette.form[props.variant]};
2137
- &:hover {
2138
- color: ${props.theme.palette.form[props.variant]};
2139
- }
2140
- `}
2141
-
2142
- `;
2143
- const Tab = (_a) => {
2144
- var { id, isActive, onClick } = _a, restProps = __rest(_a, ["id", "isActive", "onClick"]);
2145
- const handleClick = React.useCallback(() => {
2146
- if (!isActive) {
2147
- onClick === null || onClick === void 0 ? void 0 : onClick(id);
2148
- }
2149
- }, [id, isActive, onClick]);
2150
- return React.createElement(StyledBox$2, Object.assign({}, restProps, { onClick: handleClick, isActive: isActive }));
2151
- };
2152
-
2153
- const StyledBox$1 = styledComponents.styled(Box) `
2154
- background-color: ${props => props.theme.palette.common.white};
2155
- border: 1px solid rgba(34,36,38,.15);
2156
- border-top: 0px;
2157
- `;
2158
- const TabContent = (props) => React.createElement(StyledBox$1, Object.assign({ p: 3 }, props));
2159
-
2160
- const Tabs = styledComponents.styled(Box) `
2161
- display: flex;
2162
- border-bottom: 1px solid rgba(34,36,38,.15);
2163
- `;
2164
-
2165
- const FlatPanel = styledComponents.styled(Panel) `
2166
- box-shadow: none;
2167
- `;
2168
- const Wrapper$4 = styledComponents.styled(Box) `
2169
- display: flex;
2170
-
2171
- &:last-of-type .line:before {
2172
- background: none;
2173
- }
2174
- `;
2175
- const Line = styledComponents.styled(Box) `
2176
- position: relative;
2177
- margin-right: ${props => props.theme.spacing(4)};
2178
- top: 4px;
2179
-
2180
- &:before {
2181
- background: #e7eaec;
2182
- content: '';
2183
- position: absolute;
2184
- top: 0;
2185
- left: ${props => props.theme.spacing(4.5)};
2186
- height: 100%;
2187
- width: ${props => props.theme.spacing(1)};
2188
- }
2189
-
2190
- `;
2191
- const Circle = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
2192
- position: relative;
2193
- background-color: ${props => props.color};
2194
- color: #fff;
2195
-
2196
- left: 0;
2197
- width: ${props => props.theme.spacing(10)};
2198
- height: ${props => props.theme.spacing(10)};
2199
- border-radius: 50%;
2200
- font-size: ${props => props.theme.spacing(4)};
2201
-
2202
- & > * {
2203
- position: absolute;
2204
- top: 50%;
2205
- left: 50%;
2206
- transform: translate(-50%, -50%);
2207
- }
2208
- `;
2209
- const Timeline = ({ title, icon, color, isInitiallyOpen, titleMeta, chevron, children }) => (React.createElement(Wrapper$4, null,
2210
- React.createElement(Line, null,
2211
- React.createElement(Circle, { color: color }, icon)),
2212
- React.createElement(Box, { pb: 4, flexGrow: 1 },
2213
- React.createElement(CollapsiblePanel, { isInitiallyOpen: isInitiallyOpen, titleMeta: titleMeta, title: title, titleAction: chevron }, children))));
2214
- const SimpleTimeline = ({ color, icon, title, titleMeta }) => (React.createElement(Wrapper$4, null,
2215
- React.createElement(Line, { className: 'line' },
2216
- React.createElement(Circle, { color: color }, icon)),
2217
- React.createElement(Box, { pb: 4, flexGrow: 1 },
2218
- React.createElement(FlatPanel, { titleMeta: titleMeta, title: title }))));
2219
-
2220
- const StyledBox = styledComponents.styled(Box) `
2221
- background-color: #FFFFFF;
2222
- border-bottom: 1px solid #DDDDDD;
2223
- box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.04);
2224
- box-sizing: border-box;
2225
- `;
2226
- const TopBar = ({ left, right }) => (React.createElement(StyledBox, null,
2227
- React.createElement(Box, { display: "flex", alignItems: "center", pb: 1, pt: 1, pr: 5, pl: { mobile: 5, laptop: 5 + SIDEBAR_COLLAPSED_WIDTH } },
2228
- React.createElement(Box, { flexGrow: 1, display: "flex", pl: 2 }, left),
2229
- React.createElement(Box, { flexGrow: 1, display: "flex", justifyContent: 'flex-end' }, right))));
2230
-
2231
- const Label$1 = styledComponents.styled.label `
2232
- position: relative;
2233
- `;
2234
- const Input$1 = styledComponents.styled.input.withConfig({ shouldForwardProp: isPropValid }) `
2235
- position: absolute;
2236
- top: 0;
2237
- left: 0;
2238
-
2239
- width: 17px;
2240
- height: 17px;
2241
-
2242
- z-index: 99;
2243
- opacity: 0;
2244
- margin-right: ${props => props.theme.spacing(2)};
2245
- transform: translateY(1px);
2246
-
2247
- &~span {
2248
- user-select: none;
2249
- padding-left: 1.85714em;
2250
- cursor: pointer;
2251
- font-size: .92857143em;
2252
- }
2253
-
2254
- &~span:before, &~span:after {
2255
- position: absolute;
2256
- top: 0;
2257
- left: 0;
2258
- width: 17px;
2259
- height: 17px;
2260
- line-height: 17px;
2261
- content: '';
2262
- border-radius: 4px;
2263
- border: 1px solid rgba(34,36,38,.15);
2264
- z-index:0;
2265
- }
2266
-
2267
- &:checked~span {
2268
- font-style: italic;
2269
- }
2270
-
2271
- &:checked~span:before {
2272
- background: #fff;
2273
- border-color: rgba(34,36,38,.35);
2274
- }
2275
-
2276
- &:checked~span:after {
2277
- font-style: normal;
2278
- text-align: center;
2279
- content: '\\2714';
2280
- opacity: 1;
2281
- color: ${props => props.theme.palette.common.black}
2282
- }
2283
-
2284
- &:focus~span:before, &:focus~span:after {
2285
- border-color: #85b7d9;
2286
- border-radius: 4px;
2287
- background: #fff;
2288
- box-shadow: 0 0 0 0 rgba(34,36,38,.35) inset;
2289
- }
2290
-
2291
- &.error~span {
2292
- color: ${props => props.theme.palette.form.error};
2293
- }
2294
-
2295
- &.error~span:before, &.error~span:after {
2296
- background: #fff6f6;
2297
- border-color: #e0b4b4;
2298
- color: #9f3a38;
2299
- }
2300
- `;
2301
- const Span = styledComponents.styled.span.withConfig({ shouldForwardProp: isPropValid }) `
2302
- ${props => props.dimmed ? styledComponents.css `color: #999c9e;` : ''}
2303
- `;
2304
- const Checkbox = React.forwardRef((_a, ref) => {
2305
- var { options, spacing = 1, name, dimmed } = _a, restProps = __rest(_a, ["options", "spacing", "name", "dimmed"]);
2306
- return (React.createElement(React.Fragment, null, Object.entries(options).map(([value, label]) => (React.createElement(Box, { key: value, mt: spacing, mb: spacing },
2307
- React.createElement(Label$1, { key: value },
2308
- React.createElement(Input$1, Object.assign({ type: "checkbox", value: value, name: name, ref: ref }, restProps)),
2309
- React.createElement(Span, { dimmed: dimmed }, label)))))));
2310
- });
2311
-
2312
- const sharedStyles = styledComponents.css `
2313
- padding: .67857143em 1em;
2314
- line-height: 1.21428571em;
2315
- border-radius: 4px;
2316
- border: 1px solid rgba(34,36,38,.15);
2317
-
2318
- color: ${props => props.theme.palette.common.black};
2319
- font-family: Lato, "Helvetica Neue", Arial, Helvetica, sans-serif;
2320
-
2321
- font-size: 1em;
2322
- outline: none;
2323
-
2324
- &:disabled, &:read-only {
2325
- background-color: #FAFAFA;
2326
- }
2327
-
2328
- &:focus {
2329
- color: rgba(0,0,0,.95);
2330
- border-color: #85b7d9;
2331
- background: #fff;
2332
- box-shadow: 0 0 0 0 rgba(34,36,38,.35) inset;
2333
- }
2334
-
2335
- &.error {
2336
- background: #fff6f6;
2337
- border-color: #e0b4b4;
2338
- color: #9f3a38;
2339
- }
2340
-
2341
- &.error:focus {
2342
- background: #fff6f6;
2343
- }
2344
-
2345
- &:focus::placeholder {
2346
- color:rgba(115,115,115,.87)
2347
- }
2348
-
2349
- &::placeholder {
2350
- color:rgba(191,191,191,.87);
2351
- }
2352
-
2353
- &.error::placeholder {
2354
- color: #e7bdbc;
2355
- }
2356
-
2357
- &.error:focus::placeholder {
2358
- color: #da9796;
2359
- }
2360
- `;
2361
- const Input = styledComponents.styled.input.withConfig({ shouldForwardProp: isPropValid }) `
2362
- ${sharedStyles}
2363
- `;
2364
- const Textarea = styledComponents.styled.textarea.withConfig({ shouldForwardProp: isPropValid }) `
2365
- ${sharedStyles}
2366
- height: 100%;
2367
- `;
2368
- const TextField = React.forwardRef((_a, ref) => {
2369
- var { multiline = false } = _a, restProps = __rest(_a, ["multiline"]);
2370
- return multiline
2371
- ? React.createElement(Textarea, Object.assign({ ref: ref }, restProps))
2372
- : React.createElement(Input, Object.assign({ ref: ref, type: "text" }, restProps));
2373
- });
2374
-
2375
- const Wrapper$3 = styledComponents.styled.div `
2376
- position: relative;
2377
- display: flex;
2378
- `;
2379
- const HiddenInput = styledComponents.styled.input.withConfig({ shouldForwardProp: isPropValid }) `
2380
- position: absolute;
2381
- left: 0;
2382
- right: 0;
2383
- top: 0;
2384
- bottom: 0;
2385
- width: 100%;
2386
- opacity:0;
2387
- `;
2388
- const StyledButton = styledComponents.styled(Button$1) `
2389
- height: 40px;
2390
-
2391
- .has-error & {
2392
- background: #fff6f6;
2393
- border-color: #e0b4b4;
2394
- color: #9f3a38;
2395
- }
2396
- `;
2397
- const StyledTextField = styledComponents.styled(TextField) `
2398
- flex: 1;
2399
- padding-right: ${props => props.theme.spacing(8)}
2400
- `;
2401
- const DeleteButton = styledComponents.styled.button `
2402
- background-color: transparent;
2403
- border: 0;
2404
- outline: 0;
2405
- padding: 0;
2406
-
2407
- position: absolute;
2408
- right: 0;
2409
- height: 100%;
2410
-
2411
- cursor: pointer;
2412
-
2413
- &:after {
2414
- box-sizing: border-box;
2415
-
2416
- color: rgba(0, 0, 0, .3);
2417
- content: "×";
2418
-
2419
- text-align: center;
2420
- vertical-align: middle;
2421
- display: table-cell;
2422
-
2423
- font-size: 20px;
2424
- height: 38px;
2425
- width: 38px;
2426
- line-height: 38px;
2427
- padding: 0 8px;
2428
- }
2429
- `;
2430
- const FileField = React.forwardRef((_a, ref) => {
2431
- var { className, placeholder, chooseFileLabel = "Choose file", changeFileLabel = "Change file", onClear } = _a, props = __rest(_a, ["className", "placeholder", "chooseFileLabel", "changeFileLabel", "onClear"]);
2432
- const [originalRef, setOriginalRef] = React.useState();
2433
- const [fileName, setFilename] = React.useState("");
2434
- const handleChange = React.useCallback((e) => {
2435
- var _a;
2436
- const files = (e === null || e === void 0 ? void 0 : e.target).files;
2437
- setFilename(((_a = files === null || files === void 0 ? void 0 : files[0]) === null || _a === void 0 ? void 0 : _a.name) || "");
2438
- }, []);
2439
- const handleRemove = React.useCallback(() => {
2440
- if (originalRef) {
2441
- originalRef.value = '';
2442
- originalRef.files = null;
2443
- originalRef.dispatchEvent(new Event('change', { bubbles: true }));
2444
- if (onClear) {
2445
- onClear();
2446
- }
2447
- }
2448
- }, [originalRef, onClear]);
2449
- const extendedRef = React.useMemo(() => (el) => {
2450
- el === null || el === void 0 ? void 0 : el.addEventListener('change', handleChange);
2451
- setOriginalRef(el);
2452
- if (typeof ref === 'function') {
2453
- ref === null || ref === void 0 ? void 0 : ref(el);
2454
- }
2455
- }, [ref, handleChange]);
2456
- return (React.createElement(Wrapper$3, null,
2457
- React.createElement(HiddenInput, Object.assign({ type: 'file', ref: extendedRef }, props)),
2458
- React.createElement(StyledButton, { variant: 'basic' }, !!fileName ? changeFileLabel : chooseFileLabel),
2459
- React.createElement(StyledTextField, { placeholder: placeholder, className: className, disabled: true, value: fileName }),
2460
- !!fileName && onClear && React.createElement(DeleteButton, { "data-testid": 'file-clear', onClick: handleRemove })));
2461
- });
2462
-
2463
- const Wrapper$2 = styledComponents.styled.div `
2464
- position: relative;
2465
- `;
2466
- const StyledSelect = styledComponents.styled.select.withConfig({ shouldForwardProp: isPropValid }) `
2467
- width: 100%;
2468
-
2469
- padding: .67857143em 1em;
2470
- line-height: 1.21428571em;
2471
- border-radius: 4px;
2472
- border: 1px solid rgba(34,36,38,.15);
2473
-
2474
- color: ${props => props.theme.palette.common.black};
2475
- font-family: Lato, "Helvetica Neue", Arial, Helvetica, sans-serif;
2476
-
2477
- font-size: 1em;
2478
- outline: none;
2479
-
2480
- appearance: none;
2481
-
2482
- &.error {
2483
- background: #fff6f6;
2484
- border-color: #e0b4b4;
2485
- color: #9f3a38;
2486
- }
2487
-
2488
- &.error~div {
2489
- color: #9f3a38;
2490
- }
2491
- `;
2492
- const PaddingOverlay = styledComponents.styled.div `
2493
- pointer-events: none;
2494
- padding: 0 1em;
2495
- position:absolute;
2496
- height: 100%;
2497
- top: 0;
2498
- right: 0;
2499
- font-size: 17px;
2500
- line-height: 40px;
2501
- `;
2502
- const Select = React.forwardRef((_a, ref) => {
2503
- var { options } = _a, props = __rest(_a, ["options"]);
2504
- const optionsArray = Array.isArray(options)
2505
- ? options
2506
- : Object.entries(options);
2507
- return (React.createElement(Wrapper$2, null,
2508
- React.createElement(StyledSelect, Object.assign({ ref: ref }, props), optionsArray.map(([value, label]) => (React.createElement("option", { key: value, value: value }, label)))),
2509
- React.createElement(PaddingOverlay, null, "\u25BE")));
2510
- });
2511
-
2512
- const passwordMinLength = (val) => val.length >= 8;
2513
- const passwordHasNumbers = (val) => /\d/.test(val);
2514
- const passwordHasLowerAndUppercase = (val) => /[a-z]/.test(val) && /[A-Z]/.test(val);
2515
- const passwordHasSpecialChars = (val) => /[-’/`~!#*$@_%+=.,^&(){}[\]|;:”<>?\\]/.test(val);
2516
- const checks = [passwordMinLength, passwordHasNumbers, passwordHasLowerAndUppercase, passwordHasSpecialChars];
2517
- const maxScore = checks.length + 1;
2518
- const calculatePasswordScore = (val) => checks
2519
- .map((check) => check(val))
2520
- .reduce((acc, value) => value
2521
- ? acc + 1
2522
- : acc, 1);
2523
- const Progress = styledComponents.styled.div `
2524
- margin-top: ${props => props.theme.spacing(1)};
2525
- height: 3px;
2526
- background-color: #f5f5f5;
2527
- border-radius: 4px;
2528
- box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
2529
- `;
2530
- const ProgressBar = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
2531
- width: ${props => props.score ? (props.score / maxScore) * 100 : 0}%;
2532
- height: 100%;
2533
- background-color: ${props => props.score <= 2 ? '#e90f10' : props.score <= 3 ? '#ffad00' : '#02b502'} ;
2534
- transition: width .6s ease, background-color .6s ease;
2535
- `;
2536
- const PasswordStrengthField = React.forwardRef((props, ref) => {
2537
- const [score, setScore] = React.useState(0);
2538
- const handleChange = React.useCallback((e) => {
2539
- const target = e.target;
2540
- setScore(target.value ? calculatePasswordScore(target.value) : 0);
2541
- }, []);
2542
- const extendedRef = React.useMemo(() => (el) => {
2543
- el === null || el === void 0 ? void 0 : el.addEventListener('keyup', handleChange);
2544
- if (typeof ref === 'function') {
2545
- ref === null || ref === void 0 ? void 0 : ref(el);
2546
- }
2547
- }, [ref, handleChange]);
2548
- return React.createElement(React.Fragment, null,
2549
- React.createElement(TextField, Object.assign({}, props, { type: "password", ref: extendedRef })),
2550
- React.createElement(Progress, null,
2551
- React.createElement(ProgressBar, { score: score })));
2552
- });
2553
-
2554
- function toVal(mix) {
2555
- var k, y, str='';
2556
-
2557
- if (typeof mix === 'string' || typeof mix === 'number') {
2558
- str += mix;
2559
- } else if (typeof mix === 'object') {
2560
- if (Array.isArray(mix)) {
2561
- for (k=0; k < mix.length; k++) {
2562
- if (mix[k]) {
2563
- if (y = toVal(mix[k])) {
2564
- str && (str += ' ');
2565
- str += y;
2566
- }
2567
- }
2568
- }
2569
- } else {
2570
- for (k in mix) {
2571
- if (mix[k]) {
2572
- str && (str += ' ');
2573
- str += k;
2574
- }
2575
- }
2576
- }
2577
- }
2578
-
2579
- return str;
2580
- }
2581
-
2582
- function clsx () {
2583
- var i=0, tmp, x, str='';
2584
- while (i < arguments.length) {
2585
- if (tmp = arguments[i++]) {
2586
- if (x = toVal(tmp)) {
2587
- str && (str += ' ');
2588
- str += x;
2589
- }
2590
- }
2591
- }
2592
- return str;
2593
- }
2594
-
2595
- const NUM_ROWS_PER_FIELD = 2;
2596
- // NOTE:
2597
- //
2598
- // We have to implement our own version of -ms-grid.
2599
- // Styled-components does not automatically prefix it, as the specs do not completely overlap.
2600
- // https://github.com/thysultan/stylis.js/issues/51
2601
- //
2602
- // We can achieve our goals using both specs though.
2603
- const generateDimensionsCss = (position, rowOffset) => {
2604
- const parts = [];
2605
- if (position === undefined) {
2606
- return parts;
2607
- }
2608
- if (position.row !== undefined) {
2609
- parts.push(styledComponents.css `
2610
- grid-row-start: ${(position.row * NUM_ROWS_PER_FIELD) + 1 + rowOffset};
2611
- -ms-grid-row: ${(position.row * NUM_ROWS_PER_FIELD) + 1 + rowOffset};
2612
- `);
2613
- }
2614
- if (position.rowSpan && rowOffset) {
2615
- parts.push(styledComponents.css `
2616
- grid-row-end: span ${(position.rowSpan * NUM_ROWS_PER_FIELD) - 1};
2617
- -ms-grid-row-span: ${(position.rowSpan * NUM_ROWS_PER_FIELD) - 1};
2618
- `);
2619
- }
2620
- if (position.column !== undefined) {
2621
- parts.push(styledComponents.css `
2622
- grid-column-start: ${position.column + 1};
2623
- -ms-grid-column: ${position.column + 1};
2624
- `);
2625
- }
2626
- if (position.columnSpan !== undefined) {
2627
- parts.push(styledComponents.css `
2628
- grid-column-end: span ${position.columnSpan};
2629
- -ms-grid-column-span: ${position.columnSpan};
2630
- `);
2631
- }
2632
- return parts;
2633
- };
2634
- const FormGridCell = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
2635
- margin: 0px 8px;
2636
-
2637
- ${props => props.rowOffset !== undefined && styledComponents.css `
2638
- display: flex;
2639
- flex-direction: column;
2640
- margin-bottom: 16px;`}
2641
-
2642
- align-self: ${props => props.rowOffset === undefined ? "end" : "initial"};
2643
- -ms-grid-row-align: ${props => props.rowOffset === undefined ? "end" : "initial"};
2644
-
2645
- ${(props) => responsiveProps(props, {
2646
- "align": unit => styledComponents.css `text-align: ${unit};`,
2647
- "position": unit => { var _a; return generateDimensionsCss(unit, (_a = props.rowOffset) !== null && _a !== void 0 ? _a : 0); }
2648
- })}
2649
- `;
2650
- FormGridCell.displayName = "FormGridCell";
2651
-
2652
- const Label = styledComponents.styled.label.withConfig({ shouldForwardProp: isPropValid }) `
2653
- display: block;
2654
- color: ${(props => !!props.error ? props.theme.palette.form.error : props.theme.palette.common.black)} ;
2655
- font-weight: bold;
2656
- margin: ${props => props.theme.spacing(0, 0, 1, 0)};
2657
- line-height: 1.4em;
2658
- font-size: .92857143em;
2659
- `;
2660
- const Hint = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
2661
- color: ${(props => !!props.error ? "#da9796;" : props.theme.palette.form.hint)};
2662
- margin: ${props => props.theme.spacing(-1, 0, 1, 0)};
2663
- line-height: 1.4em;
2664
- font-size: .92857143em;
2665
- `;
2666
- const RequiredAsterisk = styledComponents.styled.span.withConfig({ shouldForwardProp: isPropValid }) `
2667
- color: ${props => props.theme.palette.form.hint};
2668
- `;
2669
- const Error$1 = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
2670
- color: ${props => props.theme.palette.form.error};
2671
- margin: ${props => props.theme.spacing(1, 0, 0, 0)};
2672
- font-weight: bold;
2673
- font-style: italic;
2674
- line-height: 1.4em;
2675
- font-size: .92857143em;
2676
- `;
2677
- const getFormGridWrapperProps = ({ position, align, label, hint, error, isRequired }) => ({ position, align, label, hint, error, isRequired });
2678
- const FormGridWrapper = ({ position, align, label, hint, error, isRequired, children }) => (React.createElement(React.Fragment, null,
2679
- React.createElement(FormGridCell, { position: position, align: align, className: 'form-grid-cell__label-hint' },
2680
- label && (React.createElement(Label, { error: error },
2681
- label,
2682
- isRequired && React.createElement(RequiredAsterisk, null, " *"))),
2683
- hint && (React.createElement(Hint, { error: error }, hint))),
2684
- React.createElement(FormGridCell, { position: position, align: align, rowOffset: 1, className: clsx({ 'form-grid-cell__field-error': true, 'has-error': !!error }) },
2685
- children,
2686
- error && (React.createElement(Error$1, null, error)))));
2687
-
2688
- const FormGrid = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
2689
- margin: 0 -8px -16px -8px;
2690
-
2691
- display: -ms-grid;
2692
- display: grid;
2693
-
2694
- -ms-grid-columns: 1fr;
2695
-
2696
- ${(props) => responsiveProps(props, {
2697
- columns: (string) => styledComponents.css `
2698
- -ms-grid-columns: ${string};
2699
- grid-template-columns: ${string};
2700
- `
2701
- })}
2702
- `;
2703
- FormGrid.displayName = "FormGrid";
2704
-
2705
- const Wrapper$1 = styledComponents.styled(Box) `
2706
- background-color: #F3F3F4;
2707
- `;
2708
- const WrapperInner = styledComponents.styled(Box) `
2709
- position: relative;
2710
- `;
2711
- const SidebarWrapper = styledComponents.styled(Box) `
2712
- position: absolute;
2713
- height: 100%;
2714
- z-index: 50;
2715
- pointer-events: none;
2716
- `;
2717
- const ContentBox = styledComponents.styled(Box) `
2718
- height: 100%;
2719
- `;
2720
- const BasicLayout = ({ sideBarProps, topBarProps, footerProps, isLoading, loader, children }) => {
2721
- return (React.createElement(Wrapper$1, { flexGrow: 1, display: "flex", flexDirection: "column" },
2722
- React.createElement(WrapperInner, { flexGrow: 1, flexShrink: 0 },
2723
- sideBarProps && (React.createElement(SidebarWrapper, null,
2724
- React.createElement(SideBar, Object.assign({}, sideBarProps)))),
2725
- React.createElement(ContentBox, { display: "flex", flexDirection: "column" },
2726
- React.createElement(TopBar, Object.assign({}, topBarProps)),
2727
- React.createElement(Box, { p: { laptop: VerticalRhythmLaptop, mobile: VerticalRhythmMobile }, pl: { laptop: VerticalRhythmLaptop + SIDEBAR_COLLAPSED_WIDTH }, flexGrow: 1 }, isLoading && loader
2728
- ? loader
2729
- : children),
2730
- React.createElement(Footer, Object.assign({}, footerProps))))));
2731
- };
2732
-
2733
- const Wrapper = styledComponents.styled(Box) `
2734
- background-color: ${props => props.baseColor || 'white'};
2735
- position: absolute;
2736
- min-width: 100%;
2737
- min-height: 100%;
2738
- `;
2739
- const Background = styledComponents.styled.div.withConfig({ shouldForwardProp: isPropValid }) `
2740
- position: absolute;
2741
- top: 0;
2742
- left: 0;
2743
- width: 100%;
2744
- height: 100%;
2745
-
2746
- opacity: ${props => { var _a; return (_a = props.opacity) !== null && _a !== void 0 ? _a : 1; }} ;
2747
- background: url("${props => props.imageUrl}");
2748
- background-size: cover;
2749
- `;
2750
- const StyledAnimation = styledComponents.styled(SlideInFromTop) `
2751
- z-index: 10;
2752
- margin: auto auto;
2753
- `;
2754
- const StyledPanel = styledComponents.styled(Panel) `
2755
- box-shadow: 0 8px 8px 0 rgba(34,36,38,.15);
2756
- min-width: 280px;
2757
- `;
2758
- const Logo = styledComponents.styled.img `
2759
- display:none;
2760
- position: absolute;
2761
- left: 0;
2762
- top: ${props => props.theme.spacing(8)};
2763
- ${mq("tablet", `display: block;`)}
2764
- `;
2765
- const FloatingPanelLayout = ({ panelProps, imageUrl, alert, logoUrl, backgroundBaseColor, backgroundOpacity }) => (React.createElement(Wrapper, { display: "flex", alignItems: "center", baseColor: backgroundBaseColor },
2766
- React.createElement(Background, { imageUrl: imageUrl, opacity: backgroundOpacity }),
2767
- logoUrl && (React.createElement(Logo, { src: logoUrl, alt: "Logo" })),
2768
- React.createElement(StyledAnimation, null,
2769
- alert && (React.createElement(Box, { pb: VerticalRhythmLaptop }, alert)),
2770
- React.createElement(StyledPanel, Object.assign({}, panelProps)))));
2771
-
2772
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2773
-
2774
- function getDefaultExportFromCjs (x) {
2775
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2776
- }
2777
-
2778
- /**
2779
- * lodash (Custom Build) <https://lodash.com/>
2780
- * Build: `lodash modularize exports="npm" -o ./`
2781
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
2782
- * Released under MIT license <https://lodash.com/license>
2783
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
2784
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
2785
- */
2786
-
2787
- /** Used as references for various `Number` constants. */
2788
- var INFINITY = 1 / 0,
2789
- MAX_SAFE_INTEGER$1 = 9007199254740991,
2790
- MAX_INTEGER = 1.7976931348623157e+308,
2791
- NAN = 0 / 0;
2792
-
2793
- /** `Object#toString` result references. */
2794
- var funcTag$1 = '[object Function]',
2795
- genTag$1 = '[object GeneratorFunction]',
2796
- symbolTag = '[object Symbol]';
2797
-
2798
- /** Used to match leading and trailing whitespace. */
2799
- var reTrim = /^\s+|\s+$/g;
2800
-
2801
- /** Used to detect bad signed hexadecimal string values. */
2802
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
2803
-
2804
- /** Used to detect binary string values. */
2805
- var reIsBinary = /^0b[01]+$/i;
2806
-
2807
- /** Used to detect octal string values. */
2808
- var reIsOctal = /^0o[0-7]+$/i;
2809
-
2810
- /** Used to detect unsigned integer values. */
2811
- var reIsUint = /^(?:0|[1-9]\d*)$/;
2812
-
2813
- /** Built-in method references without a dependency on `root`. */
2814
- var freeParseInt = parseInt;
2815
-
2816
- /** Used for built-in method references. */
2817
- var objectProto$1 = Object.prototype;
2818
-
2819
- /**
2820
- * Used to resolve the
2821
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
2822
- * of values.
2823
- */
2824
- var objectToString$1 = objectProto$1.toString;
2825
-
2826
- /* Built-in method references for those with the same name as other `lodash` methods. */
2827
- var nativeCeil = Math.ceil,
2828
- nativeMax$1 = Math.max;
2829
-
2830
- /**
2831
- * The base implementation of `_.slice` without an iteratee call guard.
2832
- *
2833
- * @private
2834
- * @param {Array} array The array to slice.
2835
- * @param {number} [start=0] The start position.
2836
- * @param {number} [end=array.length] The end position.
2837
- * @returns {Array} Returns the slice of `array`.
2838
- */
2839
- function baseSlice(array, start, end) {
2840
- var index = -1,
2841
- length = array.length;
2842
-
2843
- if (start < 0) {
2844
- start = -start > length ? 0 : (length + start);
2845
- }
2846
- end = end > length ? length : end;
2847
- if (end < 0) {
2848
- end += length;
2849
- }
2850
- length = start > end ? 0 : ((end - start) >>> 0);
2851
- start >>>= 0;
2852
-
2853
- var result = Array(length);
2854
- while (++index < length) {
2855
- result[index] = array[index + start];
2856
- }
2857
- return result;
2858
- }
2859
-
2860
- /**
2861
- * Checks if `value` is a valid array-like index.
2862
- *
2863
- * @private
2864
- * @param {*} value The value to check.
2865
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
2866
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
2867
- */
2868
- function isIndex(value, length) {
2869
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
2870
- return !!length &&
2871
- (typeof value == 'number' || reIsUint.test(value)) &&
2872
- (value > -1 && value % 1 == 0 && value < length);
2873
- }
2874
-
2875
- /**
2876
- * Checks if the given arguments are from an iteratee call.
2877
- *
2878
- * @private
2879
- * @param {*} value The potential iteratee value argument.
2880
- * @param {*} index The potential iteratee index or key argument.
2881
- * @param {*} object The potential iteratee object argument.
2882
- * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
2883
- * else `false`.
2884
- */
2885
- function isIterateeCall(value, index, object) {
2886
- if (!isObject$1(object)) {
2887
- return false;
2888
- }
2889
- var type = typeof index;
2890
- if (type == 'number'
2891
- ? (isArrayLike$1(object) && isIndex(index, object.length))
2892
- : (type == 'string' && index in object)
2893
- ) {
2894
- return eq$1(object[index], value);
2895
- }
2896
- return false;
2897
- }
2898
-
2899
- /**
2900
- * Creates an array of elements split into groups the length of `size`.
2901
- * If `array` can't be split evenly, the final chunk will be the remaining
2902
- * elements.
2903
- *
2904
- * @static
2905
- * @memberOf _
2906
- * @since 3.0.0
2907
- * @category Array
2908
- * @param {Array} array The array to process.
2909
- * @param {number} [size=1] The length of each chunk
2910
- * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
2911
- * @returns {Array} Returns the new array of chunks.
2912
- * @example
2913
- *
2914
- * _.chunk(['a', 'b', 'c', 'd'], 2);
2915
- * // => [['a', 'b'], ['c', 'd']]
2916
- *
2917
- * _.chunk(['a', 'b', 'c', 'd'], 3);
2918
- * // => [['a', 'b', 'c'], ['d']]
2919
- */
2920
- function chunk(array, size, guard) {
2921
- if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
2922
- size = 1;
2923
- } else {
2924
- size = nativeMax$1(toInteger(size), 0);
2925
- }
2926
- var length = array ? array.length : 0;
2927
- if (!length || size < 1) {
2928
- return [];
2929
- }
2930
- var index = 0,
2931
- resIndex = 0,
2932
- result = Array(nativeCeil(length / size));
2933
-
2934
- while (index < length) {
2935
- result[resIndex++] = baseSlice(array, index, (index += size));
2936
- }
2937
- return result;
2938
- }
2939
-
2940
- /**
2941
- * Performs a
2942
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2943
- * comparison between two values to determine if they are equivalent.
2944
- *
2945
- * @static
2946
- * @memberOf _
2947
- * @since 4.0.0
2948
- * @category Lang
2949
- * @param {*} value The value to compare.
2950
- * @param {*} other The other value to compare.
2951
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2952
- * @example
2953
- *
2954
- * var object = { 'a': 1 };
2955
- * var other = { 'a': 1 };
2956
- *
2957
- * _.eq(object, object);
2958
- * // => true
2959
- *
2960
- * _.eq(object, other);
2961
- * // => false
2962
- *
2963
- * _.eq('a', 'a');
2964
- * // => true
2965
- *
2966
- * _.eq('a', Object('a'));
2967
- * // => false
2968
- *
2969
- * _.eq(NaN, NaN);
2970
- * // => true
2971
- */
2972
- function eq$1(value, other) {
2973
- return value === other || (value !== value && other !== other);
2974
- }
2975
-
2976
- /**
2977
- * Checks if `value` is array-like. A value is considered array-like if it's
2978
- * not a function and has a `value.length` that's an integer greater than or
2979
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
2980
- *
2981
- * @static
2982
- * @memberOf _
2983
- * @since 4.0.0
2984
- * @category Lang
2985
- * @param {*} value The value to check.
2986
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
2987
- * @example
2988
- *
2989
- * _.isArrayLike([1, 2, 3]);
2990
- * // => true
2991
- *
2992
- * _.isArrayLike(document.body.children);
2993
- * // => true
2994
- *
2995
- * _.isArrayLike('abc');
2996
- * // => true
2997
- *
2998
- * _.isArrayLike(_.noop);
2999
- * // => false
3000
- */
3001
- function isArrayLike$1(value) {
3002
- return value != null && isLength$1(value.length) && !isFunction$1(value);
3003
- }
3004
-
3005
- /**
3006
- * Checks if `value` is classified as a `Function` object.
3007
- *
3008
- * @static
3009
- * @memberOf _
3010
- * @since 0.1.0
3011
- * @category Lang
3012
- * @param {*} value The value to check.
3013
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
3014
- * @example
3015
- *
3016
- * _.isFunction(_);
3017
- * // => true
3018
- *
3019
- * _.isFunction(/abc/);
3020
- * // => false
3021
- */
3022
- function isFunction$1(value) {
3023
- // The use of `Object#toString` avoids issues with the `typeof` operator
3024
- // in Safari 8-9 which returns 'object' for typed array and other constructors.
3025
- var tag = isObject$1(value) ? objectToString$1.call(value) : '';
3026
- return tag == funcTag$1 || tag == genTag$1;
3027
- }
3028
-
3029
- /**
3030
- * Checks if `value` is a valid array-like length.
3031
- *
3032
- * **Note:** This method is loosely based on
3033
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
3034
- *
3035
- * @static
3036
- * @memberOf _
3037
- * @since 4.0.0
3038
- * @category Lang
3039
- * @param {*} value The value to check.
3040
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
3041
- * @example
3042
- *
3043
- * _.isLength(3);
3044
- * // => true
3045
- *
3046
- * _.isLength(Number.MIN_VALUE);
3047
- * // => false
3048
- *
3049
- * _.isLength(Infinity);
3050
- * // => false
3051
- *
3052
- * _.isLength('3');
3053
- * // => false
3054
- */
3055
- function isLength$1(value) {
3056
- return typeof value == 'number' &&
3057
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
3058
- }
3059
-
3060
- /**
3061
- * Checks if `value` is the
3062
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3063
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
3064
- *
3065
- * @static
3066
- * @memberOf _
3067
- * @since 0.1.0
3068
- * @category Lang
3069
- * @param {*} value The value to check.
3070
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3071
- * @example
3072
- *
3073
- * _.isObject({});
3074
- * // => true
3075
- *
3076
- * _.isObject([1, 2, 3]);
3077
- * // => true
3078
- *
3079
- * _.isObject(_.noop);
3080
- * // => true
3081
- *
3082
- * _.isObject(null);
3083
- * // => false
3084
- */
3085
- function isObject$1(value) {
3086
- var type = typeof value;
3087
- return !!value && (type == 'object' || type == 'function');
3088
- }
3089
-
3090
- /**
3091
- * Checks if `value` is object-like. A value is object-like if it's not `null`
3092
- * and has a `typeof` result of "object".
3093
- *
3094
- * @static
3095
- * @memberOf _
3096
- * @since 4.0.0
3097
- * @category Lang
3098
- * @param {*} value The value to check.
3099
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3100
- * @example
3101
- *
3102
- * _.isObjectLike({});
3103
- * // => true
3104
- *
3105
- * _.isObjectLike([1, 2, 3]);
3106
- * // => true
3107
- *
3108
- * _.isObjectLike(_.noop);
3109
- * // => false
3110
- *
3111
- * _.isObjectLike(null);
3112
- * // => false
3113
- */
3114
- function isObjectLike$1(value) {
3115
- return !!value && typeof value == 'object';
3116
- }
3117
-
3118
- /**
3119
- * Checks if `value` is classified as a `Symbol` primitive or object.
3120
- *
3121
- * @static
3122
- * @memberOf _
3123
- * @since 4.0.0
3124
- * @category Lang
3125
- * @param {*} value The value to check.
3126
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
3127
- * @example
3128
- *
3129
- * _.isSymbol(Symbol.iterator);
3130
- * // => true
3131
- *
3132
- * _.isSymbol('abc');
3133
- * // => false
3134
- */
3135
- function isSymbol(value) {
3136
- return typeof value == 'symbol' ||
3137
- (isObjectLike$1(value) && objectToString$1.call(value) == symbolTag);
3138
- }
3139
-
3140
- /**
3141
- * Converts `value` to a finite number.
3142
- *
3143
- * @static
3144
- * @memberOf _
3145
- * @since 4.12.0
3146
- * @category Lang
3147
- * @param {*} value The value to convert.
3148
- * @returns {number} Returns the converted number.
3149
- * @example
3150
- *
3151
- * _.toFinite(3.2);
3152
- * // => 3.2
3153
- *
3154
- * _.toFinite(Number.MIN_VALUE);
3155
- * // => 5e-324
3156
- *
3157
- * _.toFinite(Infinity);
3158
- * // => 1.7976931348623157e+308
3159
- *
3160
- * _.toFinite('3.2');
3161
- * // => 3.2
3162
- */
3163
- function toFinite(value) {
3164
- if (!value) {
3165
- return value === 0 ? value : 0;
3166
- }
3167
- value = toNumber(value);
3168
- if (value === INFINITY || value === -INFINITY) {
3169
- var sign = (value < 0 ? -1 : 1);
3170
- return sign * MAX_INTEGER;
3171
- }
3172
- return value === value ? value : 0;
3173
- }
3174
-
3175
- /**
3176
- * Converts `value` to an integer.
3177
- *
3178
- * **Note:** This method is loosely based on
3179
- * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
3180
- *
3181
- * @static
3182
- * @memberOf _
3183
- * @since 4.0.0
3184
- * @category Lang
3185
- * @param {*} value The value to convert.
3186
- * @returns {number} Returns the converted integer.
3187
- * @example
3188
- *
3189
- * _.toInteger(3.2);
3190
- * // => 3
3191
- *
3192
- * _.toInteger(Number.MIN_VALUE);
3193
- * // => 0
3194
- *
3195
- * _.toInteger(Infinity);
3196
- * // => 1.7976931348623157e+308
3197
- *
3198
- * _.toInteger('3.2');
3199
- * // => 3
3200
- */
3201
- function toInteger(value) {
3202
- var result = toFinite(value),
3203
- remainder = result % 1;
3204
-
3205
- return result === result ? (remainder ? result - remainder : result) : 0;
3206
- }
3207
-
3208
- /**
3209
- * Converts `value` to a number.
3210
- *
3211
- * @static
3212
- * @memberOf _
3213
- * @since 4.0.0
3214
- * @category Lang
3215
- * @param {*} value The value to process.
3216
- * @returns {number} Returns the number.
3217
- * @example
3218
- *
3219
- * _.toNumber(3.2);
3220
- * // => 3.2
3221
- *
3222
- * _.toNumber(Number.MIN_VALUE);
3223
- * // => 5e-324
3224
- *
3225
- * _.toNumber(Infinity);
3226
- * // => Infinity
3227
- *
3228
- * _.toNumber('3.2');
3229
- * // => 3.2
3230
- */
3231
- function toNumber(value) {
3232
- if (typeof value == 'number') {
3233
- return value;
3234
- }
3235
- if (isSymbol(value)) {
3236
- return NAN;
3237
- }
3238
- if (isObject$1(value)) {
3239
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
3240
- value = isObject$1(other) ? (other + '') : other;
3241
- }
3242
- if (typeof value != 'string') {
3243
- return value === 0 ? value : +value;
3244
- }
3245
- value = value.replace(reTrim, '');
3246
- var isBinary = reIsBinary.test(value);
3247
- return (isBinary || reIsOctal.test(value))
3248
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
3249
- : (reIsBadHex.test(value) ? NAN : +value);
3250
- }
3251
-
3252
- var lodash_chunk = chunk;
3253
-
3254
- var _chunk = /*@__PURE__*/getDefaultExportFromCjs(lodash_chunk);
3255
-
3256
- /**
3257
- * Two dimensional array grid.
3258
- * Useful to position elements with.
3259
- *
3260
- * Example:
3261
- *
3262
- * new Grid([
3263
- * [1,2,3],
3264
- * [4,5,6],
3265
- * [7,8,9]
3266
- * ])
3267
- *
3268
- */
3269
- class Grid {
3270
- constructor(grid) {
3271
- this.grid = grid;
3272
- }
3273
- getValues() {
3274
- return this.grid;
3275
- }
3276
- /**
3277
- * Returns an array of distinct values in this grid
3278
- */
3279
- getDistinctValues() {
3280
- const values = [];
3281
- this.grid.forEach((row) => {
3282
- row.forEach((item) => {
3283
- if (!values.includes(item)) {
3284
- values.push(item);
3285
- }
3286
- });
3287
- });
3288
- return values;
3289
- }
3290
- sliceArea(topLeft, bottomRight) {
3291
- if (topLeft.x > bottomRight.x || topLeft.y > bottomRight.y) {
3292
- throw new Error("Coordinates are mixed up. Please ensure topLeft is actually in the top-left corner. And bottomRight is actually in the bottom-right corner");
3293
- }
3294
- return new Grid(this.grid
3295
- .slice(topLeft.y, bottomRight.y + 1)
3296
- .map(row => row.slice(topLeft.x, bottomRight.x + 1)));
3297
- }
3298
- getCoordinatesForValue(value) {
3299
- const x = [];
3300
- const y = [];
3301
- this.grid.forEach((row, yIndex) => {
3302
- row.forEach((item, xIndex) => {
3303
- if (item === value) {
3304
- x.push(xIndex);
3305
- y.push(yIndex);
3306
- }
3307
- });
3308
- });
3309
- return {
3310
- topLeft: { x: Math.min(...x), y: Math.min(...y) },
3311
- bottomRight: { x: Math.max(...x), y: Math.max(...y) }
3312
- };
3313
- }
3314
- }
3315
-
3316
- /**
3317
- * lodash (Custom Build) <https://lodash.com/>
3318
- * Build: `lodash modularize exports="npm" -o ./`
3319
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
3320
- * Released under MIT license <https://lodash.com/license>
3321
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
3322
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
3323
- */
3324
-
3325
- /** Used as the size to enable large array optimizations. */
3326
- var LARGE_ARRAY_SIZE = 200;
3327
-
3328
- /** Used to stand-in for `undefined` hash values. */
3329
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
3330
-
3331
- /** Used as references for various `Number` constants. */
3332
- var MAX_SAFE_INTEGER = 9007199254740991;
3333
-
3334
- /** `Object#toString` result references. */
3335
- var argsTag = '[object Arguments]',
3336
- funcTag = '[object Function]',
3337
- genTag = '[object GeneratorFunction]';
3338
-
3339
- /**
3340
- * Used to match `RegExp`
3341
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
3342
- */
3343
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
3344
-
3345
- /** Used to detect host constructors (Safari). */
3346
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
3347
-
3348
- /** Detect free variable `global` from Node.js. */
3349
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
3350
-
3351
- /** Detect free variable `self`. */
3352
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
3353
-
3354
- /** Used as a reference to the global object. */
3355
- var root = freeGlobal || freeSelf || Function('return this')();
3356
-
3357
- /**
3358
- * A faster alternative to `Function#apply`, this function invokes `func`
3359
- * with the `this` binding of `thisArg` and the arguments of `args`.
3360
- *
3361
- * @private
3362
- * @param {Function} func The function to invoke.
3363
- * @param {*} thisArg The `this` binding of `func`.
3364
- * @param {Array} args The arguments to invoke `func` with.
3365
- * @returns {*} Returns the result of `func`.
3366
- */
3367
- function apply(func, thisArg, args) {
3368
- switch (args.length) {
3369
- case 0: return func.call(thisArg);
3370
- case 1: return func.call(thisArg, args[0]);
3371
- case 2: return func.call(thisArg, args[0], args[1]);
3372
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
3373
- }
3374
- return func.apply(thisArg, args);
3375
- }
3376
-
3377
- /**
3378
- * A specialized version of `_.includes` for arrays without support for
3379
- * specifying an index to search from.
3380
- *
3381
- * @private
3382
- * @param {Array} [array] The array to inspect.
3383
- * @param {*} target The value to search for.
3384
- * @returns {boolean} Returns `true` if `target` is found, else `false`.
3385
- */
3386
- function arrayIncludes(array, value) {
3387
- var length = array ? array.length : 0;
3388
- return !!length && baseIndexOf(array, value, 0) > -1;
3389
- }
3390
-
3391
- /**
3392
- * This function is like `arrayIncludes` except that it accepts a comparator.
3393
- *
3394
- * @private
3395
- * @param {Array} [array] The array to inspect.
3396
- * @param {*} target The value to search for.
3397
- * @param {Function} comparator The comparator invoked per element.
3398
- * @returns {boolean} Returns `true` if `target` is found, else `false`.
3399
- */
3400
- function arrayIncludesWith(array, value, comparator) {
3401
- var index = -1,
3402
- length = array ? array.length : 0;
3403
-
3404
- while (++index < length) {
3405
- if (comparator(value, array[index])) {
3406
- return true;
3407
- }
3408
- }
3409
- return false;
3410
- }
3411
-
3412
- /**
3413
- * A specialized version of `_.map` for arrays without support for iteratee
3414
- * shorthands.
3415
- *
3416
- * @private
3417
- * @param {Array} [array] The array to iterate over.
3418
- * @param {Function} iteratee The function invoked per iteration.
3419
- * @returns {Array} Returns the new mapped array.
3420
- */
3421
- function arrayMap(array, iteratee) {
3422
- var index = -1,
3423
- length = array ? array.length : 0,
3424
- result = Array(length);
3425
-
3426
- while (++index < length) {
3427
- result[index] = iteratee(array[index], index, array);
3428
- }
3429
- return result;
3430
- }
3431
-
3432
- /**
3433
- * Appends the elements of `values` to `array`.
3434
- *
3435
- * @private
3436
- * @param {Array} array The array to modify.
3437
- * @param {Array} values The values to append.
3438
- * @returns {Array} Returns `array`.
3439
- */
3440
- function arrayPush(array, values) {
3441
- var index = -1,
3442
- length = values.length,
3443
- offset = array.length;
3444
-
3445
- while (++index < length) {
3446
- array[offset + index] = values[index];
3447
- }
3448
- return array;
3449
- }
3450
-
3451
- /**
3452
- * The base implementation of `_.findIndex` and `_.findLastIndex` without
3453
- * support for iteratee shorthands.
3454
- *
3455
- * @private
3456
- * @param {Array} array The array to inspect.
3457
- * @param {Function} predicate The function invoked per iteration.
3458
- * @param {number} fromIndex The index to search from.
3459
- * @param {boolean} [fromRight] Specify iterating from right to left.
3460
- * @returns {number} Returns the index of the matched value, else `-1`.
3461
- */
3462
- function baseFindIndex(array, predicate, fromIndex, fromRight) {
3463
- var length = array.length,
3464
- index = fromIndex + (fromRight ? 1 : -1);
3465
-
3466
- while ((fromRight ? index-- : ++index < length)) {
3467
- if (predicate(array[index], index, array)) {
3468
- return index;
3469
- }
3470
- }
3471
- return -1;
3472
- }
3473
-
3474
- /**
3475
- * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
3476
- *
3477
- * @private
3478
- * @param {Array} array The array to inspect.
3479
- * @param {*} value The value to search for.
3480
- * @param {number} fromIndex The index to search from.
3481
- * @returns {number} Returns the index of the matched value, else `-1`.
3482
- */
3483
- function baseIndexOf(array, value, fromIndex) {
3484
- if (value !== value) {
3485
- return baseFindIndex(array, baseIsNaN, fromIndex);
3486
- }
3487
- var index = fromIndex - 1,
3488
- length = array.length;
3489
-
3490
- while (++index < length) {
3491
- if (array[index] === value) {
3492
- return index;
3493
- }
3494
- }
3495
- return -1;
3496
- }
3497
-
3498
- /**
3499
- * The base implementation of `_.isNaN` without support for number objects.
3500
- *
3501
- * @private
3502
- * @param {*} value The value to check.
3503
- * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
3504
- */
3505
- function baseIsNaN(value) {
3506
- return value !== value;
3507
- }
3508
-
3509
- /**
3510
- * The base implementation of `_.unary` without support for storing metadata.
3511
- *
3512
- * @private
3513
- * @param {Function} func The function to cap arguments for.
3514
- * @returns {Function} Returns the new capped function.
3515
- */
3516
- function baseUnary(func) {
3517
- return function(value) {
3518
- return func(value);
3519
- };
3520
- }
3521
-
3522
- /**
3523
- * Checks if a cache value for `key` exists.
3524
- *
3525
- * @private
3526
- * @param {Object} cache The cache to query.
3527
- * @param {string} key The key of the entry to check.
3528
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
3529
- */
3530
- function cacheHas(cache, key) {
3531
- return cache.has(key);
3532
- }
3533
-
3534
- /**
3535
- * Gets the value at `key` of `object`.
3536
- *
3537
- * @private
3538
- * @param {Object} [object] The object to query.
3539
- * @param {string} key The key of the property to get.
3540
- * @returns {*} Returns the property value.
3541
- */
3542
- function getValue(object, key) {
3543
- return object == null ? undefined : object[key];
3544
- }
3545
-
3546
- /**
3547
- * Checks if `value` is a host object in IE < 9.
3548
- *
3549
- * @private
3550
- * @param {*} value The value to check.
3551
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
3552
- */
3553
- function isHostObject(value) {
3554
- // Many host objects are `Object` objects that can coerce to strings
3555
- // despite having improperly defined `toString` methods.
3556
- var result = false;
3557
- if (value != null && typeof value.toString != 'function') {
3558
- try {
3559
- result = !!(value + '');
3560
- } catch (e) {}
3561
- }
3562
- return result;
3563
- }
3564
-
3565
- /** Used for built-in method references. */
3566
- var arrayProto = Array.prototype,
3567
- funcProto = Function.prototype,
3568
- objectProto = Object.prototype;
3569
-
3570
- /** Used to detect overreaching core-js shims. */
3571
- var coreJsData = root['__core-js_shared__'];
3572
-
3573
- /** Used to detect methods masquerading as native. */
3574
- var maskSrcKey = (function() {
3575
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
3576
- return uid ? ('Symbol(src)_1.' + uid) : '';
3577
- }());
3578
-
3579
- /** Used to resolve the decompiled source of functions. */
3580
- var funcToString = funcProto.toString;
3581
-
3582
- /** Used to check objects for own properties. */
3583
- var hasOwnProperty = objectProto.hasOwnProperty;
3584
-
3585
- /**
3586
- * Used to resolve the
3587
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
3588
- * of values.
3589
- */
3590
- var objectToString = objectProto.toString;
3591
-
3592
- /** Used to detect if a method is native. */
3593
- var reIsNative = RegExp('^' +
3594
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
3595
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
3596
- );
3597
-
3598
- /** Built-in value references. */
3599
- var Symbol = root.Symbol,
3600
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
3601
- splice = arrayProto.splice,
3602
- spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
3603
-
3604
- /* Built-in method references for those with the same name as other `lodash` methods. */
3605
- var nativeMax = Math.max;
3606
-
3607
- /* Built-in method references that are verified to be native. */
3608
- var Map$1 = getNative(root, 'Map'),
3609
- nativeCreate = getNative(Object, 'create');
3610
-
3611
- /**
3612
- * Creates a hash object.
3613
- *
3614
- * @private
3615
- * @constructor
3616
- * @param {Array} [entries] The key-value pairs to cache.
3617
- */
3618
- function Hash(entries) {
3619
- var index = -1,
3620
- length = entries ? entries.length : 0;
3621
-
3622
- this.clear();
3623
- while (++index < length) {
3624
- var entry = entries[index];
3625
- this.set(entry[0], entry[1]);
3626
- }
3627
- }
3628
-
3629
- /**
3630
- * Removes all key-value entries from the hash.
3631
- *
3632
- * @private
3633
- * @name clear
3634
- * @memberOf Hash
3635
- */
3636
- function hashClear() {
3637
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
3638
- }
3639
-
3640
- /**
3641
- * Removes `key` and its value from the hash.
3642
- *
3643
- * @private
3644
- * @name delete
3645
- * @memberOf Hash
3646
- * @param {Object} hash The hash to modify.
3647
- * @param {string} key The key of the value to remove.
3648
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
3649
- */
3650
- function hashDelete(key) {
3651
- return this.has(key) && delete this.__data__[key];
3652
- }
3653
-
3654
- /**
3655
- * Gets the hash value for `key`.
3656
- *
3657
- * @private
3658
- * @name get
3659
- * @memberOf Hash
3660
- * @param {string} key The key of the value to get.
3661
- * @returns {*} Returns the entry value.
3662
- */
3663
- function hashGet(key) {
3664
- var data = this.__data__;
3665
- if (nativeCreate) {
3666
- var result = data[key];
3667
- return result === HASH_UNDEFINED ? undefined : result;
3668
- }
3669
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
3670
- }
3671
-
3672
- /**
3673
- * Checks if a hash value for `key` exists.
3674
- *
3675
- * @private
3676
- * @name has
3677
- * @memberOf Hash
3678
- * @param {string} key The key of the entry to check.
3679
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
3680
- */
3681
- function hashHas(key) {
3682
- var data = this.__data__;
3683
- return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
3684
- }
3685
-
3686
- /**
3687
- * Sets the hash `key` to `value`.
3688
- *
3689
- * @private
3690
- * @name set
3691
- * @memberOf Hash
3692
- * @param {string} key The key of the value to set.
3693
- * @param {*} value The value to set.
3694
- * @returns {Object} Returns the hash instance.
3695
- */
3696
- function hashSet(key, value) {
3697
- var data = this.__data__;
3698
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
3699
- return this;
3700
- }
3701
-
3702
- // Add methods to `Hash`.
3703
- Hash.prototype.clear = hashClear;
3704
- Hash.prototype['delete'] = hashDelete;
3705
- Hash.prototype.get = hashGet;
3706
- Hash.prototype.has = hashHas;
3707
- Hash.prototype.set = hashSet;
3708
-
3709
- /**
3710
- * Creates an list cache object.
3711
- *
3712
- * @private
3713
- * @constructor
3714
- * @param {Array} [entries] The key-value pairs to cache.
3715
- */
3716
- function ListCache(entries) {
3717
- var index = -1,
3718
- length = entries ? entries.length : 0;
3719
-
3720
- this.clear();
3721
- while (++index < length) {
3722
- var entry = entries[index];
3723
- this.set(entry[0], entry[1]);
3724
- }
3725
- }
3726
-
3727
- /**
3728
- * Removes all key-value entries from the list cache.
3729
- *
3730
- * @private
3731
- * @name clear
3732
- * @memberOf ListCache
3733
- */
3734
- function listCacheClear() {
3735
- this.__data__ = [];
3736
- }
3737
-
3738
- /**
3739
- * Removes `key` and its value from the list cache.
3740
- *
3741
- * @private
3742
- * @name delete
3743
- * @memberOf ListCache
3744
- * @param {string} key The key of the value to remove.
3745
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
3746
- */
3747
- function listCacheDelete(key) {
3748
- var data = this.__data__,
3749
- index = assocIndexOf(data, key);
3750
-
3751
- if (index < 0) {
3752
- return false;
3753
- }
3754
- var lastIndex = data.length - 1;
3755
- if (index == lastIndex) {
3756
- data.pop();
3757
- } else {
3758
- splice.call(data, index, 1);
3759
- }
3760
- return true;
3761
- }
3762
-
3763
- /**
3764
- * Gets the list cache value for `key`.
3765
- *
3766
- * @private
3767
- * @name get
3768
- * @memberOf ListCache
3769
- * @param {string} key The key of the value to get.
3770
- * @returns {*} Returns the entry value.
3771
- */
3772
- function listCacheGet(key) {
3773
- var data = this.__data__,
3774
- index = assocIndexOf(data, key);
3775
-
3776
- return index < 0 ? undefined : data[index][1];
3777
- }
3778
-
3779
- /**
3780
- * Checks if a list cache value for `key` exists.
3781
- *
3782
- * @private
3783
- * @name has
3784
- * @memberOf ListCache
3785
- * @param {string} key The key of the entry to check.
3786
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
3787
- */
3788
- function listCacheHas(key) {
3789
- return assocIndexOf(this.__data__, key) > -1;
3790
- }
3791
-
3792
- /**
3793
- * Sets the list cache `key` to `value`.
3794
- *
3795
- * @private
3796
- * @name set
3797
- * @memberOf ListCache
3798
- * @param {string} key The key of the value to set.
3799
- * @param {*} value The value to set.
3800
- * @returns {Object} Returns the list cache instance.
3801
- */
3802
- function listCacheSet(key, value) {
3803
- var data = this.__data__,
3804
- index = assocIndexOf(data, key);
3805
-
3806
- if (index < 0) {
3807
- data.push([key, value]);
3808
- } else {
3809
- data[index][1] = value;
3810
- }
3811
- return this;
3812
- }
3813
-
3814
- // Add methods to `ListCache`.
3815
- ListCache.prototype.clear = listCacheClear;
3816
- ListCache.prototype['delete'] = listCacheDelete;
3817
- ListCache.prototype.get = listCacheGet;
3818
- ListCache.prototype.has = listCacheHas;
3819
- ListCache.prototype.set = listCacheSet;
3820
-
3821
- /**
3822
- * Creates a map cache object to store key-value pairs.
3823
- *
3824
- * @private
3825
- * @constructor
3826
- * @param {Array} [entries] The key-value pairs to cache.
3827
- */
3828
- function MapCache(entries) {
3829
- var index = -1,
3830
- length = entries ? entries.length : 0;
3831
-
3832
- this.clear();
3833
- while (++index < length) {
3834
- var entry = entries[index];
3835
- this.set(entry[0], entry[1]);
3836
- }
3837
- }
3838
-
3839
- /**
3840
- * Removes all key-value entries from the map.
3841
- *
3842
- * @private
3843
- * @name clear
3844
- * @memberOf MapCache
3845
- */
3846
- function mapCacheClear() {
3847
- this.__data__ = {
3848
- 'hash': new Hash,
3849
- 'map': new (Map$1 || ListCache),
3850
- 'string': new Hash
3851
- };
3852
- }
3853
-
3854
- /**
3855
- * Removes `key` and its value from the map.
3856
- *
3857
- * @private
3858
- * @name delete
3859
- * @memberOf MapCache
3860
- * @param {string} key The key of the value to remove.
3861
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
3862
- */
3863
- function mapCacheDelete(key) {
3864
- return getMapData(this, key)['delete'](key);
3865
- }
3866
-
3867
- /**
3868
- * Gets the map value for `key`.
3869
- *
3870
- * @private
3871
- * @name get
3872
- * @memberOf MapCache
3873
- * @param {string} key The key of the value to get.
3874
- * @returns {*} Returns the entry value.
3875
- */
3876
- function mapCacheGet(key) {
3877
- return getMapData(this, key).get(key);
3878
- }
3879
-
3880
- /**
3881
- * Checks if a map value for `key` exists.
3882
- *
3883
- * @private
3884
- * @name has
3885
- * @memberOf MapCache
3886
- * @param {string} key The key of the entry to check.
3887
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
3888
- */
3889
- function mapCacheHas(key) {
3890
- return getMapData(this, key).has(key);
3891
- }
3892
-
3893
- /**
3894
- * Sets the map `key` to `value`.
3895
- *
3896
- * @private
3897
- * @name set
3898
- * @memberOf MapCache
3899
- * @param {string} key The key of the value to set.
3900
- * @param {*} value The value to set.
3901
- * @returns {Object} Returns the map cache instance.
3902
- */
3903
- function mapCacheSet(key, value) {
3904
- getMapData(this, key).set(key, value);
3905
- return this;
3906
- }
3907
-
3908
- // Add methods to `MapCache`.
3909
- MapCache.prototype.clear = mapCacheClear;
3910
- MapCache.prototype['delete'] = mapCacheDelete;
3911
- MapCache.prototype.get = mapCacheGet;
3912
- MapCache.prototype.has = mapCacheHas;
3913
- MapCache.prototype.set = mapCacheSet;
3914
-
3915
- /**
3916
- *
3917
- * Creates an array cache object to store unique values.
3918
- *
3919
- * @private
3920
- * @constructor
3921
- * @param {Array} [values] The values to cache.
3922
- */
3923
- function SetCache(values) {
3924
- var index = -1,
3925
- length = values ? values.length : 0;
3926
-
3927
- this.__data__ = new MapCache;
3928
- while (++index < length) {
3929
- this.add(values[index]);
3930
- }
3931
- }
3932
-
3933
- /**
3934
- * Adds `value` to the array cache.
3935
- *
3936
- * @private
3937
- * @name add
3938
- * @memberOf SetCache
3939
- * @alias push
3940
- * @param {*} value The value to cache.
3941
- * @returns {Object} Returns the cache instance.
3942
- */
3943
- function setCacheAdd(value) {
3944
- this.__data__.set(value, HASH_UNDEFINED);
3945
- return this;
3946
- }
3947
-
3948
- /**
3949
- * Checks if `value` is in the array cache.
3950
- *
3951
- * @private
3952
- * @name has
3953
- * @memberOf SetCache
3954
- * @param {*} value The value to search for.
3955
- * @returns {number} Returns `true` if `value` is found, else `false`.
3956
- */
3957
- function setCacheHas(value) {
3958
- return this.__data__.has(value);
3959
- }
3960
-
3961
- // Add methods to `SetCache`.
3962
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
3963
- SetCache.prototype.has = setCacheHas;
3964
-
3965
- /**
3966
- * Gets the index at which the `key` is found in `array` of key-value pairs.
3967
- *
3968
- * @private
3969
- * @param {Array} array The array to inspect.
3970
- * @param {*} key The key to search for.
3971
- * @returns {number} Returns the index of the matched value, else `-1`.
3972
- */
3973
- function assocIndexOf(array, key) {
3974
- var length = array.length;
3975
- while (length--) {
3976
- if (eq(array[length][0], key)) {
3977
- return length;
3978
- }
3979
- }
3980
- return -1;
3981
- }
3982
-
3983
- /**
3984
- * The base implementation of methods like `_.difference` without support
3985
- * for excluding multiple arrays or iteratee shorthands.
3986
- *
3987
- * @private
3988
- * @param {Array} array The array to inspect.
3989
- * @param {Array} values The values to exclude.
3990
- * @param {Function} [iteratee] The iteratee invoked per element.
3991
- * @param {Function} [comparator] The comparator invoked per element.
3992
- * @returns {Array} Returns the new array of filtered values.
3993
- */
3994
- function baseDifference(array, values, iteratee, comparator) {
3995
- var index = -1,
3996
- includes = arrayIncludes,
3997
- isCommon = true,
3998
- length = array.length,
3999
- result = [],
4000
- valuesLength = values.length;
4001
-
4002
- if (!length) {
4003
- return result;
4004
- }
4005
- if (iteratee) {
4006
- values = arrayMap(values, baseUnary(iteratee));
4007
- }
4008
- if (comparator) {
4009
- includes = arrayIncludesWith;
4010
- isCommon = false;
4011
- }
4012
- else if (values.length >= LARGE_ARRAY_SIZE) {
4013
- includes = cacheHas;
4014
- isCommon = false;
4015
- values = new SetCache(values);
4016
- }
4017
- outer:
4018
- while (++index < length) {
4019
- var value = array[index],
4020
- computed = iteratee ? iteratee(value) : value;
4021
-
4022
- value = (comparator || value !== 0) ? value : 0;
4023
- if (isCommon && computed === computed) {
4024
- var valuesIndex = valuesLength;
4025
- while (valuesIndex--) {
4026
- if (values[valuesIndex] === computed) {
4027
- continue outer;
4028
- }
4029
- }
4030
- result.push(value);
4031
- }
4032
- else if (!includes(values, computed, comparator)) {
4033
- result.push(value);
4034
- }
4035
- }
4036
- return result;
4037
- }
4038
-
4039
- /**
4040
- * The base implementation of `_.flatten` with support for restricting flattening.
4041
- *
4042
- * @private
4043
- * @param {Array} array The array to flatten.
4044
- * @param {number} depth The maximum recursion depth.
4045
- * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
4046
- * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
4047
- * @param {Array} [result=[]] The initial result value.
4048
- * @returns {Array} Returns the new flattened array.
4049
- */
4050
- function baseFlatten(array, depth, predicate, isStrict, result) {
4051
- var index = -1,
4052
- length = array.length;
4053
-
4054
- predicate || (predicate = isFlattenable);
4055
- result || (result = []);
4056
-
4057
- while (++index < length) {
4058
- var value = array[index];
4059
- if (depth > 0 && predicate(value)) {
4060
- if (depth > 1) {
4061
- // Recursively flatten arrays (susceptible to call stack limits).
4062
- baseFlatten(value, depth - 1, predicate, isStrict, result);
4063
- } else {
4064
- arrayPush(result, value);
4065
- }
4066
- } else if (!isStrict) {
4067
- result[result.length] = value;
4068
- }
4069
- }
4070
- return result;
4071
- }
4072
-
4073
- /**
4074
- * The base implementation of `_.isNative` without bad shim checks.
4075
- *
4076
- * @private
4077
- * @param {*} value The value to check.
4078
- * @returns {boolean} Returns `true` if `value` is a native function,
4079
- * else `false`.
4080
- */
4081
- function baseIsNative(value) {
4082
- if (!isObject(value) || isMasked(value)) {
4083
- return false;
4084
- }
4085
- var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
4086
- return pattern.test(toSource(value));
4087
- }
4088
-
4089
- /**
4090
- * The base implementation of `_.rest` which doesn't validate or coerce arguments.
4091
- *
4092
- * @private
4093
- * @param {Function} func The function to apply a rest parameter to.
4094
- * @param {number} [start=func.length-1] The start position of the rest parameter.
4095
- * @returns {Function} Returns the new function.
4096
- */
4097
- function baseRest(func, start) {
4098
- start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
4099
- return function() {
4100
- var args = arguments,
4101
- index = -1,
4102
- length = nativeMax(args.length - start, 0),
4103
- array = Array(length);
4104
-
4105
- while (++index < length) {
4106
- array[index] = args[start + index];
4107
- }
4108
- index = -1;
4109
- var otherArgs = Array(start + 1);
4110
- while (++index < start) {
4111
- otherArgs[index] = args[index];
4112
- }
4113
- otherArgs[start] = array;
4114
- return apply(func, this, otherArgs);
4115
- };
4116
- }
4117
-
4118
- /**
4119
- * Gets the data for `map`.
4120
- *
4121
- * @private
4122
- * @param {Object} map The map to query.
4123
- * @param {string} key The reference key.
4124
- * @returns {*} Returns the map data.
4125
- */
4126
- function getMapData(map, key) {
4127
- var data = map.__data__;
4128
- return isKeyable(key)
4129
- ? data[typeof key == 'string' ? 'string' : 'hash']
4130
- : data.map;
4131
- }
4132
-
4133
- /**
4134
- * Gets the native function at `key` of `object`.
4135
- *
4136
- * @private
4137
- * @param {Object} object The object to query.
4138
- * @param {string} key The key of the method to get.
4139
- * @returns {*} Returns the function if it's native, else `undefined`.
4140
- */
4141
- function getNative(object, key) {
4142
- var value = getValue(object, key);
4143
- return baseIsNative(value) ? value : undefined;
4144
- }
4145
-
4146
- /**
4147
- * Checks if `value` is a flattenable `arguments` object or array.
4148
- *
4149
- * @private
4150
- * @param {*} value The value to check.
4151
- * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
4152
- */
4153
- function isFlattenable(value) {
4154
- return isArray(value) || isArguments(value) ||
4155
- !!(spreadableSymbol && value && value[spreadableSymbol]);
4156
- }
4157
-
4158
- /**
4159
- * Checks if `value` is suitable for use as unique object key.
4160
- *
4161
- * @private
4162
- * @param {*} value The value to check.
4163
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
4164
- */
4165
- function isKeyable(value) {
4166
- var type = typeof value;
4167
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
4168
- ? (value !== '__proto__')
4169
- : (value === null);
4170
- }
4171
-
4172
- /**
4173
- * Checks if `func` has its source masked.
4174
- *
4175
- * @private
4176
- * @param {Function} func The function to check.
4177
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
4178
- */
4179
- function isMasked(func) {
4180
- return !!maskSrcKey && (maskSrcKey in func);
4181
- }
4182
-
4183
- /**
4184
- * Converts `func` to its source code.
4185
- *
4186
- * @private
4187
- * @param {Function} func The function to process.
4188
- * @returns {string} Returns the source code.
4189
- */
4190
- function toSource(func) {
4191
- if (func != null) {
4192
- try {
4193
- return funcToString.call(func);
4194
- } catch (e) {}
4195
- try {
4196
- return (func + '');
4197
- } catch (e) {}
4198
- }
4199
- return '';
4200
- }
4201
-
4202
- /**
4203
- * Creates an array of `array` values not included in the other given arrays
4204
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
4205
- * for equality comparisons. The order of result values is determined by the
4206
- * order they occur in the first array.
4207
- *
4208
- * **Note:** Unlike `_.pullAll`, this method returns a new array.
4209
- *
4210
- * @static
4211
- * @memberOf _
4212
- * @since 0.1.0
4213
- * @category Array
4214
- * @param {Array} array The array to inspect.
4215
- * @param {...Array} [values] The values to exclude.
4216
- * @returns {Array} Returns the new array of filtered values.
4217
- * @see _.without, _.xor
4218
- * @example
4219
- *
4220
- * _.difference([2, 1], [2, 3]);
4221
- * // => [1]
4222
- */
4223
- var difference = baseRest(function(array, values) {
4224
- return isArrayLikeObject(array)
4225
- ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
4226
- : [];
4227
- });
4228
-
4229
- /**
4230
- * Performs a
4231
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
4232
- * comparison between two values to determine if they are equivalent.
4233
- *
4234
- * @static
4235
- * @memberOf _
4236
- * @since 4.0.0
4237
- * @category Lang
4238
- * @param {*} value The value to compare.
4239
- * @param {*} other The other value to compare.
4240
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
4241
- * @example
4242
- *
4243
- * var object = { 'a': 1 };
4244
- * var other = { 'a': 1 };
4245
- *
4246
- * _.eq(object, object);
4247
- * // => true
4248
- *
4249
- * _.eq(object, other);
4250
- * // => false
4251
- *
4252
- * _.eq('a', 'a');
4253
- * // => true
4254
- *
4255
- * _.eq('a', Object('a'));
4256
- * // => false
4257
- *
4258
- * _.eq(NaN, NaN);
4259
- * // => true
4260
- */
4261
- function eq(value, other) {
4262
- return value === other || (value !== value && other !== other);
4263
- }
4264
-
4265
- /**
4266
- * Checks if `value` is likely an `arguments` object.
4267
- *
4268
- * @static
4269
- * @memberOf _
4270
- * @since 0.1.0
4271
- * @category Lang
4272
- * @param {*} value The value to check.
4273
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
4274
- * else `false`.
4275
- * @example
4276
- *
4277
- * _.isArguments(function() { return arguments; }());
4278
- * // => true
4279
- *
4280
- * _.isArguments([1, 2, 3]);
4281
- * // => false
4282
- */
4283
- function isArguments(value) {
4284
- // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
4285
- return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
4286
- (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
4287
- }
4288
-
4289
- /**
4290
- * Checks if `value` is classified as an `Array` object.
4291
- *
4292
- * @static
4293
- * @memberOf _
4294
- * @since 0.1.0
4295
- * @category Lang
4296
- * @param {*} value The value to check.
4297
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
4298
- * @example
4299
- *
4300
- * _.isArray([1, 2, 3]);
4301
- * // => true
4302
- *
4303
- * _.isArray(document.body.children);
4304
- * // => false
4305
- *
4306
- * _.isArray('abc');
4307
- * // => false
4308
- *
4309
- * _.isArray(_.noop);
4310
- * // => false
4311
- */
4312
- var isArray = Array.isArray;
4313
-
4314
- /**
4315
- * Checks if `value` is array-like. A value is considered array-like if it's
4316
- * not a function and has a `value.length` that's an integer greater than or
4317
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
4318
- *
4319
- * @static
4320
- * @memberOf _
4321
- * @since 4.0.0
4322
- * @category Lang
4323
- * @param {*} value The value to check.
4324
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
4325
- * @example
4326
- *
4327
- * _.isArrayLike([1, 2, 3]);
4328
- * // => true
4329
- *
4330
- * _.isArrayLike(document.body.children);
4331
- * // => true
4332
- *
4333
- * _.isArrayLike('abc');
4334
- * // => true
4335
- *
4336
- * _.isArrayLike(_.noop);
4337
- * // => false
4338
- */
4339
- function isArrayLike(value) {
4340
- return value != null && isLength(value.length) && !isFunction(value);
4341
- }
4342
-
4343
- /**
4344
- * This method is like `_.isArrayLike` except that it also checks if `value`
4345
- * is an object.
4346
- *
4347
- * @static
4348
- * @memberOf _
4349
- * @since 4.0.0
4350
- * @category Lang
4351
- * @param {*} value The value to check.
4352
- * @returns {boolean} Returns `true` if `value` is an array-like object,
4353
- * else `false`.
4354
- * @example
4355
- *
4356
- * _.isArrayLikeObject([1, 2, 3]);
4357
- * // => true
4358
- *
4359
- * _.isArrayLikeObject(document.body.children);
4360
- * // => true
4361
- *
4362
- * _.isArrayLikeObject('abc');
4363
- * // => false
4364
- *
4365
- * _.isArrayLikeObject(_.noop);
4366
- * // => false
4367
- */
4368
- function isArrayLikeObject(value) {
4369
- return isObjectLike(value) && isArrayLike(value);
4370
- }
4371
-
4372
- /**
4373
- * Checks if `value` is classified as a `Function` object.
4374
- *
4375
- * @static
4376
- * @memberOf _
4377
- * @since 0.1.0
4378
- * @category Lang
4379
- * @param {*} value The value to check.
4380
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
4381
- * @example
4382
- *
4383
- * _.isFunction(_);
4384
- * // => true
4385
- *
4386
- * _.isFunction(/abc/);
4387
- * // => false
4388
- */
4389
- function isFunction(value) {
4390
- // The use of `Object#toString` avoids issues with the `typeof` operator
4391
- // in Safari 8-9 which returns 'object' for typed array and other constructors.
4392
- var tag = isObject(value) ? objectToString.call(value) : '';
4393
- return tag == funcTag || tag == genTag;
4394
- }
4395
-
4396
- /**
4397
- * Checks if `value` is a valid array-like length.
4398
- *
4399
- * **Note:** This method is loosely based on
4400
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
4401
- *
4402
- * @static
4403
- * @memberOf _
4404
- * @since 4.0.0
4405
- * @category Lang
4406
- * @param {*} value The value to check.
4407
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
4408
- * @example
4409
- *
4410
- * _.isLength(3);
4411
- * // => true
4412
- *
4413
- * _.isLength(Number.MIN_VALUE);
4414
- * // => false
4415
- *
4416
- * _.isLength(Infinity);
4417
- * // => false
4418
- *
4419
- * _.isLength('3');
4420
- * // => false
4421
- */
4422
- function isLength(value) {
4423
- return typeof value == 'number' &&
4424
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
4425
- }
4426
-
4427
- /**
4428
- * Checks if `value` is the
4429
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
4430
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
4431
- *
4432
- * @static
4433
- * @memberOf _
4434
- * @since 0.1.0
4435
- * @category Lang
4436
- * @param {*} value The value to check.
4437
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
4438
- * @example
4439
- *
4440
- * _.isObject({});
4441
- * // => true
4442
- *
4443
- * _.isObject([1, 2, 3]);
4444
- * // => true
4445
- *
4446
- * _.isObject(_.noop);
4447
- * // => true
4448
- *
4449
- * _.isObject(null);
4450
- * // => false
4451
- */
4452
- function isObject(value) {
4453
- var type = typeof value;
4454
- return !!value && (type == 'object' || type == 'function');
4455
- }
4456
-
4457
- /**
4458
- * Checks if `value` is object-like. A value is object-like if it's not `null`
4459
- * and has a `typeof` result of "object".
4460
- *
4461
- * @static
4462
- * @memberOf _
4463
- * @since 4.0.0
4464
- * @category Lang
4465
- * @param {*} value The value to check.
4466
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
4467
- * @example
4468
- *
4469
- * _.isObjectLike({});
4470
- * // => true
4471
- *
4472
- * _.isObjectLike([1, 2, 3]);
4473
- * // => true
4474
- *
4475
- * _.isObjectLike(_.noop);
4476
- * // => false
4477
- *
4478
- * _.isObjectLike(null);
4479
- * // => false
4480
- */
4481
- function isObjectLike(value) {
4482
- return !!value && typeof value == 'object';
4483
- }
4484
-
4485
- var lodash_difference = difference;
4486
-
4487
- var _difference = /*@__PURE__*/getDefaultExportFromCjs(lodash_difference);
4488
-
4489
- /**
4490
- * Makes sure all values in the grid have a rectangular shape.
4491
- * We don't support Tetris types.
4492
- */
4493
- const assertGridIsValid = (availableKeys, grid) => {
4494
- const distinctValues = grid.getDistinctValues();
4495
- // Check if all `availableKeys` have a place in the given grid
4496
- if (distinctValues.length < availableKeys.length) {
4497
- throw new Error(`Not all given fields are present in the grid. Please add these fields ${_difference(distinctValues, availableKeys).map(_ => `"${_}"`).join(", ")}`);
4498
- }
4499
- // We don't support tetris-shaped values:
4500
- // E.g:
4501
- // [
4502
- // [1,1,1],
4503
- // [0,1,0]
4504
- // ]
4505
- distinctValues.forEach((value) => {
4506
- if (!availableKeys.includes(value)) {
4507
- throw new Error(`${value} is not an existing field. Existing fields are ${availableKeys.map(_ => `"${_}"`).join(", ")}.`);
4508
- }
4509
- const coordinates = grid.getCoordinatesForValue(value);
4510
- const subGrid = grid.sliceArea(coordinates.topLeft, coordinates.bottomRight);
4511
- const subGridDistinctValues = subGrid.getDistinctValues();
4512
- if (subGridDistinctValues.length !== 1 || subGridDistinctValues[0] !== value) {
4513
- throw new Error(`Grid contains an unsupported shape. Please make sure "${value}" has a rectangular shape.`);
4514
- }
4515
- });
4516
- return true;
4517
- };
4518
-
4519
- const equalColumns = (num, buttonGutter) => {
4520
- const fractions = [...Array(num)].map(_ => "1fr");
4521
- if (buttonGutter) {
4522
- fractions.push("auto");
4523
- }
4524
- return fractions.join(" ");
4525
- };
4526
-
4527
- class FormPositioner {
4528
- constructor(fields, columns = {} // -> ignore property, its used to pass along internally.
4529
- ) {
4530
- this.fields = fields;
4531
- this.columns = columns;
4532
- }
4533
- /**
4534
- * Position form elements responsively in a grid.
4535
- * Example usage:
4536
- *
4537
- *
4538
- * .setGrid("laptop", [ // Breakpoint from laptop to bigger
4539
- * ["title", "title", "title"], // NOTE: title has a colspan of 3
4540
- * ["street", "number", "city"],
4541
- * ["code", "description", "description"], // NOTE: description has a colspan of 2, and a rowspan of 2
4542
- * ["status", "description", "description"]
4543
- * ])
4544
- * .setVertical("mobileS", 1) // NOTE: align everything in a single column for mobileS until laptop
4545
- *
4546
- */
4547
- setGrid(breakPoint, columns, arrayGrid) {
4548
- // We save the columns setting in a different prop.
4549
- if (typeof this.columns === "object") {
4550
- this.columns[breakPoint] = columns;
4551
- }
4552
- // Wrap array grid in a Grid object.
4553
- // It has some nice utility functions to work with.
4554
- const grid = new Grid(arrayGrid);
4555
- // Make sure the given grid is a valid grid:
4556
- assertGridIsValid(Object.keys(this.fields), grid);
4557
- // Update position attributes for the given fields:
4558
- const fields = immer.produce(this.fields, draftState => {
4559
- Object
4560
- .keys(this.fields)
4561
- .forEach(key => {
4562
- const fieldProps = draftState[key].props;
4563
- const { topLeft, bottomRight } = grid.getCoordinatesForValue(key);
4564
- if (fieldProps.position === undefined) {
4565
- fieldProps.position = {};
4566
- }
4567
- if (!isResponsiveObject(fieldProps.position)) {
4568
- // When there already was a position set, but it wasn't marked responsive,
4569
- // We set that value to the lowest breakpoint:
4570
- fieldProps.position = { mobile: fieldProps.position };
4571
- }
4572
- // Set values to breakpoint.
4573
- // @ts-ignore
4574
- fieldProps.position[breakPoint] = {
4575
- column: topLeft.x,
4576
- columnSpan: bottomRight.x - topLeft.x + 1,
4577
- row: topLeft.y,
4578
- rowSpan: bottomRight.y - topLeft.y + 1
4579
- };
4580
- });
4581
- });
4582
- // Return a new formPositioner.
4583
- // It allows us to chain, while still being immutable.
4584
- return new FormPositioner(fields, this.columns);
4585
- }
4586
- /**
4587
- * Aligns all input-fields vertically.
4588
- */
4589
- setVertical(breakPoint, numColumns = 1, columns) {
4590
- return this.setGrid(breakPoint, columns !== null && columns !== void 0 ? columns : equalColumns(numColumns, false), _chunk(Object.keys(this.fields), numColumns));
4591
- }
4592
- /**
4593
- * Aligns all input-fields horizontally.
4594
- */
4595
- setHorizontal(breakPoint, columns) {
4596
- const keys = Object.keys(this.fields);
4597
- return this.setGrid(breakPoint, columns !== null && columns !== void 0 ? columns : equalColumns(keys.length, false), [keys]);
4598
- }
4599
- getColumns() {
4600
- return this.columns;
4601
- }
4602
- getFields() {
4603
- return this.fields;
4604
- }
4605
- getScaffoldProps() {
4606
- return {
4607
- fields: this.fields,
4608
- columns: this.columns
4609
- };
4610
- }
4611
- }
4612
-
4613
- const ScaffoldFormContext = React.createContext({ factory: undefined });
4614
- const ScaffoldFormProvider = ({ factory, children }) => (React.createElement(ScaffoldFormContext.Provider, { value: { factory: factory } }, children));
4615
-
4616
- const useScaffoldFormContext = () => React.useContext(ScaffoldFormContext);
4617
-
4618
- const getComponent = (field) => {
4619
- switch (field.type) {
4620
- case "Button":
4621
- return Button$1;
4622
- case "Checkbox":
4623
- return Checkbox;
4624
- case "Select":
4625
- return Select;
4626
- case "FileField":
4627
- return FileField;
4628
- case "PasswordStrengthField":
4629
- return PasswordStrengthField;
4630
- case "TextField":
4631
- default:
4632
- return TextField;
4633
- }
4634
- };
4635
- const ScaffoldField = React.forwardRef((_a, ref) => {
4636
- var { name, field } = _a, restProps = __rest(_a, ["name", "field"]);
4637
- const { factory } = useScaffoldFormContext();
4638
- const formGridWrapperProps = getFormGridWrapperProps(field.props);
4639
- const Component = (factory === null || factory === void 0 ? void 0 : factory(field)) || getComponent(field);
4640
- // @ts-ignore
4641
- if (field.type === "TextField" && field.props.type === "hidden") {
4642
- return React.createElement(Component, Object.assign({ ref: ref, name: name }, restProps, field.props));
4643
- }
4644
- return (React.createElement(FormGridWrapper, Object.assign({}, formGridWrapperProps),
4645
- React.createElement(Component, Object.assign({ ref: ref, name: name, placeholder: field.props.placeholder || formGridWrapperProps.label, className: clsx(!!formGridWrapperProps.error && 'error', field.props.className) }, restProps, field.props))));
4646
- });
4647
-
4648
- const ScaffoldForm = React.forwardRef((_a, ref) => {
4649
- var { children, columns, fields, prefixFieldNames } = _a, restProps = __rest(_a, ["children", "columns", "fields", "prefixFieldNames"]);
4650
- return (React.createElement(FormGrid, { columns: columns },
4651
- Object
4652
- .entries(fields)
4653
- .map(([key, fieldProps]) => (
4654
- // @ts-ignore
4655
- React.createElement(ScaffoldField, Object.assign({ name: `${prefixFieldNames !== null && prefixFieldNames !== void 0 ? prefixFieldNames : ''}${key}`, key: key, field: fieldProps, ref: ref }, restProps)))),
4656
- children));
4657
- });
4658
-
4659
- exports.Alert = Alert;
4660
- exports.AnimatedCheckmark = AnimatedCheckmark;
4661
- exports.BasicLayout = BasicLayout;
4662
- exports.Box = Box;
4663
- exports.BreadCrumbs = BreadCrumbs;
4664
- exports.BreakPointValues = BreakPointValues;
4665
- exports.Button = Button$1;
4666
- exports.Checkbox = Checkbox;
4667
- exports.CollapsiblePanel = CollapsiblePanel;
4668
- exports.ConfirmButton = ConfirmButton;
4669
- exports.ConfirmModal = ConfirmModal;
4670
- exports.Crumb = Crumb;
4671
- exports.Details = Details;
4672
- exports.Dropdown = Dropdown;
4673
- exports.DropdownMenu = DropdownMenu;
4674
- exports.DropdownMenuItem = DropdownMenuItem;
4675
- exports.Dropzone = Dropzone;
4676
- exports.Feedback = Feedback;
4677
- exports.FileField = FileField;
4678
- exports.Floater = Floater;
4679
- exports.FloatingPanelLayout = FloatingPanelLayout;
4680
- exports.Footer = Footer;
4681
- exports.FormGrid = FormGrid;
4682
- exports.FormGridWrapper = FormGridWrapper;
4683
- exports.FormPositioner = FormPositioner;
4684
- exports.HamburgerButton = HamburgerButton;
4685
- exports.Header = Header;
4686
- exports.HorizontalScroller = HorizontalScroller;
4687
- exports.Menu = Menu;
4688
- exports.MenuCloseButton = MenuCloseButton;
4689
- exports.MenuItem = MenuItem;
4690
- exports.MenuSlideOpenIndicator = MenuSlideOpenIndicator;
4691
- exports.Modal = Modal;
4692
- exports.Overlay = Overlay;
4693
- exports.Paginator = Paginator;
4694
- exports.Panel = Panel;
4695
- exports.Paragraph = Paragraph;
4696
- exports.PasswordStrengthField = PasswordStrengthField;
4697
- exports.ScaffoldForm = ScaffoldForm;
4698
- exports.ScaffoldFormContext = ScaffoldFormContext;
4699
- exports.ScaffoldFormProvider = ScaffoldFormProvider;
4700
- exports.Section = Section;
4701
- exports.Select = Select;
4702
- exports.SideBarHeader = SideBarHeader;
4703
- exports.SimpleTimeline = SimpleTimeline;
4704
- exports.SlideInFromTop = SlideInFromTop;
4705
- exports.Statistic = Statistic;
4706
- exports.StyledTable = StyledTable;
4707
- exports.Tab = Tab;
4708
- exports.TabContent = TabContent;
4709
- exports.Table = Table;
4710
- exports.Tabs = Tabs;
4711
- exports.TextField = TextField;
4712
- exports.Timeline = Timeline;
4713
- exports.TopBar = TopBar;
4714
- exports.UiProvider = UiProvider;
4715
- exports.UiWrapper = UiWrapper;
4716
- exports.VerticalRhythmLaptop = VerticalRhythmLaptop;
4717
- exports.VerticalRhythmMobile = VerticalRhythmMobile;
4718
- exports.calculatePasswordScore = calculatePasswordScore;
4719
- exports.getFormGridWrapperProps = getFormGridWrapperProps;
4720
- exports.isResponsiveObject = isResponsiveObject;
4721
- exports.mq = mq;
4722
- exports.passwordHasLowerAndUppercase = passwordHasLowerAndUppercase;
4723
- exports.passwordHasNumbers = passwordHasNumbers;
4724
- exports.passwordHasSpecialChars = passwordHasSpecialChars;
4725
- exports.passwordMinLength = passwordMinLength;
4726
- exports.responsiveProps = responsiveProps;
4727
- exports.theme = theme;
4728
- exports.useCloseSidebarOnNavigate = useCloseSidebarOnNavigate;
4729
- exports.useResponsiveBreakpoints = useResponsiveBreakpoints;
4730
- exports.useToggleMobileMenu = useToggleMobileMenu;