@jobber/components 4.7.1-pre.5 → 4.7.1-pre.7

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.
@@ -5,13 +5,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var reactTable = require('@tanstack/react-table');
6
6
  var classnames = require('classnames');
7
7
  var React = require('react');
8
- var useResizeObserver = require('@jobber/hooks/dist/useResizeObserver');
8
+ var require$$0 = require('@apollo/client');
9
+ var require$$1 = require('lodash');
10
+ var require$$3 = require('@jobber/formatters');
11
+ var useEventListener = require('@use-it/event-listener');
12
+ var require$$1$1 = require('zxcvbn');
13
+ var require$$1$2 = require('use-resize-observer/polyfilled');
9
14
  var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
10
15
  var tslib_es6 = require('../tslib.es6-5b8768b7.js');
11
16
  var Option = require('../Option-1447547b.js');
12
17
  var Button = require('../Button-69409e46.js');
13
18
  var Text = require('../Text-e7ed0974.js');
14
- var jobberHooks = require('@jobber/hooks/dist/index');
19
+ var jobberHooks = require('@jobber/hooks/index');
15
20
  require('../FormField-03e36a98.js');
16
21
  require('uuid');
17
22
  require('react-hook-form');
@@ -26,27 +31,680 @@ require('../Typography-fd6f932a.js');
26
31
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
27
32
 
28
33
  function _interopNamespace(e) {
29
- if (e && e.__esModule) return e;
30
- var n = Object.create(null);
31
- if (e) {
32
- Object.keys(e).forEach(function (k) {
33
- if (k !== 'default') {
34
- var d = Object.getOwnPropertyDescriptor(e, k);
35
- Object.defineProperty(n, k, d.get ? d : {
36
- enumerable: true,
37
- get: function () { return e[k]; }
38
- });
39
- }
40
- });
41
- }
42
- n["default"] = e;
43
- return Object.freeze(n);
34
+ if (e && e.__esModule) return e;
35
+ var n = Object.create(null);
36
+ if (e) {
37
+ Object.keys(e).forEach(function (k) {
38
+ if (k !== 'default') {
39
+ var d = Object.getOwnPropertyDescriptor(e, k);
40
+ Object.defineProperty(n, k, d.get ? d : {
41
+ enumerable: true,
42
+ get: function () { return e[k]; }
43
+ });
44
+ }
45
+ });
46
+ }
47
+ n["default"] = e;
48
+ return Object.freeze(n);
44
49
  }
45
50
 
46
51
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
47
52
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
53
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
54
+ var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
55
+ var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
56
+ var useEventListener__default = /*#__PURE__*/_interopDefaultLegacy(useEventListener);
57
+ var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
58
+ var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
48
59
  var jobberHooks__namespace = /*#__PURE__*/_interopNamespace(jobberHooks);
49
60
 
61
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
62
+
63
+ var useAssert$2 = {};
64
+
65
+ var useAssert$1 = {};
66
+
67
+ // for now just expose the builtin process global from node.js
68
+ var process = commonjsGlobal.process;
69
+
70
+ var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
71
+ return (mod && mod.__esModule) ? mod : { "default": mod };
72
+ };
73
+ Object.defineProperty(useAssert$1, "__esModule", { value: true });
74
+ useAssert$1.useAssert = void 0;
75
+ const process_1 = __importDefault$2(process);
76
+ function useAssert(shouldShow, message, options) {
77
+ if (process_1.default.env.NODE_ENV !== "production" && shouldShow) {
78
+ if (options === null || options === void 0 ? void 0 : options.warn) {
79
+ console.warn(message);
80
+ }
81
+ else {
82
+ throw new Error(message);
83
+ }
84
+ }
85
+ }
86
+ useAssert$1.useAssert = useAssert;
87
+
88
+ (function (exports) {
89
+ Object.defineProperty(exports, "__esModule", { value: true });
90
+ exports.useAssert = void 0;
91
+ var useAssert_1 = useAssert$1;
92
+ Object.defineProperty(exports, "useAssert", { enumerable: true, get: function () { return useAssert_1.useAssert; } });
93
+ } (useAssert$2));
94
+
95
+ var useCollectionQuery$2 = {};
96
+
97
+ var useCollectionQuery$1 = {};
98
+
99
+ var uniqueNodes$1 = {};
100
+
101
+ Object.defineProperty(uniqueNodes$1, "__esModule", { value: true });
102
+ uniqueNodes$1.uniqueNodes = void 0;
103
+ function uniqueNodes(nodes) {
104
+ const result = new Map();
105
+ nodes.forEach(node => {
106
+ result.set(`${node.__typename}-${node.id}`, node);
107
+ });
108
+ return Array.from(result.values());
109
+ }
110
+ uniqueNodes$1.uniqueNodes = uniqueNodes;
111
+
112
+ var uniqueEdges$1 = {};
113
+
114
+ Object.defineProperty(uniqueEdges$1, "__esModule", { value: true });
115
+ uniqueEdges$1.uniqueEdges = uniqueEdges$1.createEdge = void 0;
116
+ function createEdge(node) {
117
+ return {
118
+ node: node,
119
+ cursor: "",
120
+ __typename: `${node.__typename}Edge`,
121
+ };
122
+ }
123
+ uniqueEdges$1.createEdge = createEdge;
124
+ function uniqueEdges(edges) {
125
+ const result = new Map();
126
+ edges.forEach(edge => {
127
+ result.set(`${edge.__typename}-${edge.node.__typename}-${edge.node.id}`, edge);
128
+ });
129
+ return Array.from(result.values());
130
+ }
131
+ uniqueEdges$1.uniqueEdges = uniqueEdges;
132
+
133
+ var useIsMounted$2 = {};
134
+
135
+ var useIsMounted$1 = {};
136
+
137
+ Object.defineProperty(useIsMounted$1, "__esModule", { value: true });
138
+ useIsMounted$1.useIsMounted = void 0;
139
+ const react_1$6 = React__default["default"];
140
+ /**
141
+ * Why does this work?
142
+ *
143
+ * The following is from the react docs:
144
+ * [The return function from `useLayoutEffect`] is the optional cleanup mechanism for effects.
145
+ * Every effect may return a function that cleans up after it.
146
+ *
147
+ * When exactly does React clean up an effect? React performs the cleanup when the component unmounts.
148
+ * The cleanup for useLayoutEffect is called after component unmounts and before before browser painting
149
+ * the screen
150
+ *
151
+ * What does that mean for us? When this hook is initially loaded, we then trigger a `useLayoutEffect` that
152
+ * sets the isMounted to true right after the component is mounted.
153
+ * When the component unmounts, it calls the cleanup function that sets `isMounted` to false.
154
+ * This `useLayoutEffect` hook will only be run once.
155
+ */
156
+ function useIsMounted() {
157
+ const isMounted = (0, react_1$6.useRef)(false);
158
+ (0, react_1$6.useLayoutEffect)(() => {
159
+ isMounted.current = true;
160
+ return () => {
161
+ isMounted.current = false;
162
+ };
163
+ }, []);
164
+ return isMounted;
165
+ }
166
+ useIsMounted$1.useIsMounted = useIsMounted;
167
+
168
+ (function (exports) {
169
+ Object.defineProperty(exports, "__esModule", { value: true });
170
+ exports.useIsMounted = void 0;
171
+ var useIsMounted_1 = useIsMounted$1;
172
+ Object.defineProperty(exports, "useIsMounted", { enumerable: true, get: function () { return useIsMounted_1.useIsMounted; } });
173
+ } (useIsMounted$2));
174
+
175
+ Object.defineProperty(useCollectionQuery$1, "__esModule", { value: true });
176
+ useCollectionQuery$1.isAlreadyUpdated = useCollectionQuery$1.useCollectionQuery = void 0;
177
+ const client_1 = require$$0__default["default"];
178
+ const lodash_1 = require$$1__default["default"];
179
+ const react_1$5 = React__default["default"];
180
+ const formatters_1 = require$$3__default["default"];
181
+ const uniqueNodes_1 = uniqueNodes$1;
182
+ const uniqueEdges_1 = uniqueEdges$1;
183
+ const useIsMounted_1 = useIsMounted$2;
184
+ function useCollectionQuery({ query, queryOptions, getCollectionByPath, subscription, }) {
185
+ var _a, _b;
186
+ const { data, loading, refetch, error, fetchMore, subscribeToMore } = (0, client_1.useQuery)(query, queryOptions);
187
+ const isMounted = (0, useIsMounted_1.useIsMounted)();
188
+ const [loadingRefresh, setLoadingRefresh] = (0, react_1$5.useState)(false);
189
+ const [loadingNextPage, setLoadingNextPage] = (0, react_1$5.useState)(false);
190
+ const loadingInitialContent = loading && !loadingRefresh && !loadingNextPage;
191
+ const isSearching = !!((_a = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.variables) === null || _a === void 0 ? void 0 : _a.searchTerm);
192
+ const refresh = (0, react_1$5.useCallback)(() => {
193
+ if (loadingInitialContent || loadingRefresh) {
194
+ return;
195
+ }
196
+ setLoadingRefresh(true);
197
+ fetchMore({
198
+ // a workaround fix for the error described in this post
199
+ // https://github.com/apollographql/apollo-client/issues/7491#issuecomment-767985363
200
+ // These changes can be reverted once we can update to version 3.4
201
+ // (the current release candidate)
202
+ variables: {},
203
+ updateQuery: (prev, { fetchMoreResult }) => fetchMoreResult || prev,
204
+ })
205
+ .catch(err => formatters_1.config.errorNotifier("Refetch Error", err))
206
+ .finally(() => {
207
+ if (isMounted.current) {
208
+ setLoadingRefresh(false);
209
+ }
210
+ });
211
+ }, [
212
+ loadingInitialContent,
213
+ loadingRefresh,
214
+ setLoadingRefresh,
215
+ refetch,
216
+ isMounted,
217
+ ]);
218
+ const nextPage = (0, react_1$5.useCallback)(() => {
219
+ var _a;
220
+ if (loadingInitialContent || loadingRefresh || loadingNextPage) {
221
+ return;
222
+ }
223
+ const pageInfo = (_a = getCollectionByPath(data)) === null || _a === void 0 ? void 0 : _a.pageInfo;
224
+ if (!pageInfo || !pageInfo.hasNextPage) {
225
+ return;
226
+ }
227
+ setLoadingNextPage(true);
228
+ fetchMore({
229
+ variables: {
230
+ cursor: pageInfo.endCursor,
231
+ },
232
+ updateQuery: (prev, { fetchMoreResult }) => fetchMoreUpdateQueryHandler(prev, fetchMoreResult, getCollectionByPath),
233
+ })
234
+ .catch(err => formatters_1.config.errorNotifier("FetchMore Error", err))
235
+ .finally(() => {
236
+ if (isMounted.current) {
237
+ setLoadingNextPage(false);
238
+ }
239
+ });
240
+ }, [
241
+ data,
242
+ loadingInitialContent,
243
+ loadingRefresh,
244
+ fetchMore,
245
+ loadingNextPage,
246
+ setLoadingNextPage,
247
+ getCollectionByPath,
248
+ isMounted,
249
+ ]);
250
+ (0, react_1$5.useEffect)(() => {
251
+ if (subscription == undefined)
252
+ return;
253
+ const subscriptionOptions = subscription.options || {};
254
+ return subscribeToMore(Object.assign(Object.assign({}, subscriptionOptions), { document: subscription.document, updateQuery: (prev, { subscriptionData }) => subscribeToMoreHandler(isSearching, prev, getCollectionByPath, subscriptionData === null || subscriptionData === void 0 ? void 0 : subscriptionData.data, subscription.getNodeByPath), onError: err => formatters_1.config.errorNotifier("Subscribe to More Error", err) }));
255
+ },
256
+ // Disabling this linter so we can force this only run once. If we didn't
257
+ // do this we would need to ensure subscription, subscribeToMore, and getNodeByPath
258
+ // all use useCallback.
259
+ [(_b = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.variables) === null || _b === void 0 ? void 0 : _b.searchTerm]);
260
+ return {
261
+ data,
262
+ error,
263
+ refresh,
264
+ loadingRefresh,
265
+ nextPage,
266
+ loadingNextPage,
267
+ loadingInitialContent,
268
+ };
269
+ }
270
+ useCollectionQuery$1.useCollectionQuery = useCollectionQuery;
271
+ /**
272
+ * The following method uses an `output` variable, and indirectly modifies it through the `outputCollection` variable.
273
+ * This type of indirect modification is prone to bugs, but I couldn't think of a better way to write this code.
274
+ *
275
+ * Here's what I was balancing:
276
+ * 1. We need to copy the structure of prev to ensure that when we're combining two objects, we're not losing properties
277
+ * 2. We need to extract a key from an unknown path that's given to us by getCollectionByPath and then we need to modify
278
+ * that, and ensure that it's properly set on the cloned output object.
279
+ * 3. We want to keep the interface to this hook as simple and easy to use as possible
280
+ *
281
+ * The alternative approaches that were rejected:
282
+ * 1. We replace the getCollectionByPath with a keyPath string. (Eg. "data.conversation.message") and then we use lodash
283
+ * `get` and `set` which should remove all the object manipulation. But, this approach loses us the type safety that
284
+ * getCollectionByPath gives us
285
+ * 2. We could add a setCollection function to the list of arguments for this hook. This leaves us with type safety but
286
+ * makes the `useCollectionQuery` interface more complicated by adding arguments
287
+ */
288
+ function fetchMoreUpdateQueryHandler(prev, fetchMoreResult, getCollectionByPath) {
289
+ const nextCollection = getCollectionByPath(fetchMoreResult);
290
+ const output = (0, lodash_1.cloneDeep)(prev);
291
+ const outputCollection = getCollectionByPath(output);
292
+ if (outputCollection === undefined || nextCollection === undefined) {
293
+ return output;
294
+ }
295
+ if (outputCollection.nodes && nextCollection.nodes) {
296
+ outputCollection.nodes = getUpdatedNodes(outputCollection.nodes, nextCollection.nodes);
297
+ }
298
+ if (outputCollection.edges && nextCollection.edges) {
299
+ outputCollection.edges = getUpdatedEdges(outputCollection.edges, nextCollection.edges);
300
+ }
301
+ Object.assign(outputCollection, Object.assign({ pageInfo: (0, lodash_1.cloneDeep)(nextCollection.pageInfo) }, getTotalCount(nextCollection.totalCount)));
302
+ return output;
303
+ }
304
+ function subscribeToMoreHandler(isSearching, prev, getCollectionByPath, subscriptionData, getNodeByPath) {
305
+ const node = getNodeByPath(subscriptionData);
306
+ const output = (0, lodash_1.cloneDeep)(prev);
307
+ const outputCollection = getCollectionByPath(output);
308
+ if (outputCollection == undefined || node == undefined)
309
+ return output;
310
+ if (isAlreadyUpdated(outputCollection, node) || isSearching) {
311
+ return prev;
312
+ }
313
+ if (outputCollection.nodes) {
314
+ outputCollection.nodes = getUpdatedNodes(outputCollection.nodes, [node], false);
315
+ }
316
+ if (outputCollection.edges) {
317
+ outputCollection.edges = getUpdatedEdges(outputCollection.edges, [(0, uniqueEdges_1.createEdge)(node)], false);
318
+ }
319
+ Object.assign(outputCollection, Object.assign({ pageInfo: (0, lodash_1.cloneDeep)(outputCollection.pageInfo) }, getTotalCount(outputCollection.totalCount, 1)));
320
+ return output;
321
+ }
322
+ function getTotalCount(totalCount, additionalCount = 0) {
323
+ return totalCount !== undefined
324
+ ? { totalCount: totalCount + additionalCount }
325
+ : {};
326
+ }
327
+ function isAlreadyUpdated(outputCollection, newNode) {
328
+ let edgesAlreadyUpdated = true;
329
+ let nodesAlreadyUpdated = true;
330
+ if (outputCollection.edges) {
331
+ edgesAlreadyUpdated = outputCollection.edges.some(edge => {
332
+ return edge.node.id === newNode.id;
333
+ });
334
+ }
335
+ if (outputCollection.nodes) {
336
+ nodesAlreadyUpdated = outputCollection.nodes.some(node => {
337
+ return node.id === newNode.id;
338
+ });
339
+ }
340
+ return edgesAlreadyUpdated && nodesAlreadyUpdated;
341
+ }
342
+ useCollectionQuery$1.isAlreadyUpdated = isAlreadyUpdated;
343
+ function getUpdatedEdges(prevEdges, nextEdges, appendToEnd = true) {
344
+ const newEdges = appendToEnd
345
+ ? [...prevEdges, ...nextEdges]
346
+ : [...nextEdges, ...prevEdges];
347
+ return (0, uniqueEdges_1.uniqueEdges)(newEdges);
348
+ }
349
+ function getUpdatedNodes(prevNodes, nextNodes, appendToEnd = true) {
350
+ const newNodes = appendToEnd
351
+ ? [...prevNodes, ...nextNodes]
352
+ : [...nextNodes, ...prevNodes];
353
+ return (0, uniqueNodes_1.uniqueNodes)(newNodes);
354
+ }
355
+
356
+ (function (exports) {
357
+ Object.defineProperty(exports, "__esModule", { value: true });
358
+ exports.useCollectionQuery = void 0;
359
+ var useCollectionQuery_1 = useCollectionQuery$1;
360
+ Object.defineProperty(exports, "useCollectionQuery", { enumerable: true, get: function () { return useCollectionQuery_1.useCollectionQuery; } });
361
+ } (useCollectionQuery$2));
362
+
363
+ var useFocusTrap$2 = {};
364
+
365
+ var useFocusTrap$1 = {};
366
+
367
+ Object.defineProperty(useFocusTrap$1, "__esModule", { value: true });
368
+ useFocusTrap$1.useFocusTrap = void 0;
369
+ const react_1$4 = React__default["default"];
370
+ /**
371
+ * Traps the focus within the children of the ref element.
372
+ *
373
+ * @param active - Turns the focus trapping on or off. Also adds aria-hidden on the
374
+ * body but not the dialog.
375
+ *
376
+ * @returns ref
377
+ */
378
+ function useFocusTrap(active) {
379
+ // There's an ongoing issue with useRef return type clashing with an element's
380
+ // ref prop type. TLDR: Use null because useRef doesn't expect undefined.
381
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/35572
382
+ const ref = (0, react_1$4.useRef)(null);
383
+ function handleKeyDown(event) {
384
+ if (!(active && ref.current) || event.key !== "Tab") {
385
+ return;
386
+ }
387
+ const { firstElement, lastElement } = getElements(ref.current);
388
+ if (event.shiftKey) {
389
+ if (document.activeElement === firstElement) {
390
+ lastElement.focus();
391
+ event.preventDefault();
392
+ }
393
+ }
394
+ else {
395
+ if (document.activeElement === lastElement) {
396
+ firstElement.focus();
397
+ event.preventDefault();
398
+ }
399
+ }
400
+ }
401
+ (0, react_1$4.useEffect)(() => {
402
+ var _a, _b;
403
+ if (active) {
404
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
405
+ (_b = ref.current) === null || _b === void 0 ? void 0 : _b.addEventListener("keydown", handleKeyDown);
406
+ }
407
+ return () => {
408
+ var _a;
409
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", handleKeyDown);
410
+ };
411
+ }, [active]);
412
+ return ref;
413
+ }
414
+ useFocusTrap$1.useFocusTrap = useFocusTrap;
415
+ function getElements(ref) {
416
+ const focusables = [
417
+ "button",
418
+ "[href]",
419
+ "input",
420
+ "select",
421
+ "textarea",
422
+ '[tabindex]:not([tabindex="-1"])',
423
+ ];
424
+ const elements = ref.querySelectorAll(focusables.join(", "));
425
+ const firstElement = ref;
426
+ const lastElement = elements[elements.length - 1];
427
+ return { firstElement, lastElement };
428
+ }
429
+
430
+ (function (exports) {
431
+ Object.defineProperty(exports, "__esModule", { value: true });
432
+ exports.useFocusTrap = void 0;
433
+ var useFocusTrap_1 = useFocusTrap$1;
434
+ Object.defineProperty(exports, "useFocusTrap", { enumerable: true, get: function () { return useFocusTrap_1.useFocusTrap; } });
435
+ } (useFocusTrap$2));
436
+
437
+ var useFormState$2 = {};
438
+
439
+ var useFormState$1 = {};
440
+
441
+ Object.defineProperty(useFormState$1, "__esModule", { value: true });
442
+ useFormState$1.useFormState = void 0;
443
+ const react_1$3 = React__default["default"];
444
+ function useFormState() {
445
+ const [formState, setFormState] = (0, react_1$3.useState)({
446
+ isDirty: false,
447
+ isValid: true,
448
+ });
449
+ return [formState, setFormState];
450
+ }
451
+ useFormState$1.useFormState = useFormState;
452
+
453
+ (function (exports) {
454
+ Object.defineProperty(exports, "__esModule", { value: true });
455
+ exports.useFormState = void 0;
456
+ var useFormState_1 = useFormState$1;
457
+ Object.defineProperty(exports, "useFormState", { enumerable: true, get: function () { return useFormState_1.useFormState; } });
458
+ } (useFormState$2));
459
+
460
+ var useLiveAnnounce$2 = {};
461
+
462
+ var useLiveAnnounce$1 = {};
463
+
464
+ Object.defineProperty(useLiveAnnounce$1, "__esModule", { value: true });
465
+ useLiveAnnounce$1.useLiveAnnounce = void 0;
466
+ const react_1$2 = React__default["default"];
467
+ /**
468
+ * Announce a message on voice over whenever you do an action. This is
469
+ * especially helpful when you have an action that adds or deletes an element
470
+ * from the screen.
471
+ */
472
+ function useLiveAnnounce() {
473
+ const [announcedMessage, setAnnouncedMessage] = (0, react_1$2.useState)("");
474
+ (0, react_1$2.useEffect)(() => {
475
+ let target;
476
+ if (announcedMessage) {
477
+ target = createAnnouncedElement();
478
+ setTimeout(() => target.append(announcedMessage), 100);
479
+ }
480
+ return () => target === null || target === void 0 ? void 0 : target.remove();
481
+ }, [announcedMessage]);
482
+ return {
483
+ liveAnnounce: (message) => {
484
+ setAnnouncedMessage(message);
485
+ },
486
+ };
487
+ }
488
+ useLiveAnnounce$1.useLiveAnnounce = useLiveAnnounce;
489
+ // eslint-disable-next-line max-statements
490
+ function createAnnouncedElement() {
491
+ const el = document.createElement("div");
492
+ el.style.position = "absolute";
493
+ el.style.width = "1px";
494
+ el.style.height = "1px";
495
+ el.style.overflow = "hidden";
496
+ el.style.clipPath = " inset(100%)";
497
+ el.style.whiteSpace = " nowrap";
498
+ el.style.top = "0";
499
+ el.setAttribute("role", "status");
500
+ el.setAttribute("aria-atomic", "true");
501
+ el.setAttribute("aria-live", "assertive");
502
+ document.body.appendChild(el);
503
+ return el;
504
+ }
505
+
506
+ (function (exports) {
507
+ Object.defineProperty(exports, "__esModule", { value: true });
508
+ exports.useLiveAnnounce = void 0;
509
+ var useLiveAnnounce_1 = useLiveAnnounce$1;
510
+ Object.defineProperty(exports, "useLiveAnnounce", { enumerable: true, get: function () { return useLiveAnnounce_1.useLiveAnnounce; } });
511
+ } (useLiveAnnounce$2));
512
+
513
+ var useOnKeyDown$2 = {};
514
+
515
+ var useOnKeyDown$1 = {};
516
+
517
+ var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
518
+ return (mod && mod.__esModule) ? mod : { "default": mod };
519
+ };
520
+ Object.defineProperty(useOnKeyDown$1, "__esModule", { value: true });
521
+ useOnKeyDown$1.useOnKeyDown = void 0;
522
+ const event_listener_1 = __importDefault$1(useEventListener__default["default"]);
523
+ function useOnKeyDown(callback, keys) {
524
+ (0, event_listener_1.default)("keydown", handler);
525
+ function handler(event) {
526
+ const keyboardEvent = event;
527
+ if (typeof keys === "string" && keyboardEvent.key === keys) {
528
+ callback(event);
529
+ return;
530
+ }
531
+ if (Array.isArray(keys) &&
532
+ keys.some(item => {
533
+ if (typeof item === "string")
534
+ return keyboardEvent.key === item;
535
+ return Object.keys(item).every(index => keyboardEvent[index] === item[index]);
536
+ })) {
537
+ callback(event);
538
+ return;
539
+ }
540
+ if (!Array.isArray(keys) &&
541
+ typeof keys !== "string" &&
542
+ Object.keys(keys).every(index => keyboardEvent[index] === keys[index])) {
543
+ callback(event);
544
+ return;
545
+ }
546
+ }
547
+ }
548
+ useOnKeyDown$1.useOnKeyDown = useOnKeyDown;
549
+
550
+ (function (exports) {
551
+ Object.defineProperty(exports, "__esModule", { value: true });
552
+ exports.useOnKeyDown = void 0;
553
+ var useOnKeyDown_1 = useOnKeyDown$1;
554
+ Object.defineProperty(exports, "useOnKeyDown", { enumerable: true, get: function () { return useOnKeyDown_1.useOnKeyDown; } });
555
+ } (useOnKeyDown$2));
556
+
557
+ var usePasswordStrength$2 = {};
558
+
559
+ var usePasswordStrength$1 = {};
560
+
561
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
562
+ return (mod && mod.__esModule) ? mod : { "default": mod };
563
+ };
564
+ Object.defineProperty(usePasswordStrength$1, "__esModule", { value: true });
565
+ usePasswordStrength$1.usePasswordStrength = void 0;
566
+ const react_1$1 = React__default["default"];
567
+ const zxcvbn_1 = __importDefault(require$$1__default$1["default"]);
568
+ function usePasswordStrength(password, dictionary) {
569
+ const { guesses, score, feedback: { warning, suggestions }, crack_times_display: { offline_fast_hashing_1e10_per_second: timeToCrack }, } = (0, react_1$1.useMemo)(() => (0, zxcvbn_1.default)(password, dictionary), [password, dictionary]);
570
+ return {
571
+ guesses,
572
+ score,
573
+ warning,
574
+ suggestions,
575
+ timeToCrack,
576
+ };
577
+ }
578
+ usePasswordStrength$1.usePasswordStrength = usePasswordStrength;
579
+
580
+ (function (exports) {
581
+ Object.defineProperty(exports, "__esModule", { value: true });
582
+ exports.usePasswordStrength = void 0;
583
+ var usePasswordStrength_1 = usePasswordStrength$1;
584
+ Object.defineProperty(exports, "usePasswordStrength", { enumerable: true, get: function () { return usePasswordStrength_1.usePasswordStrength; } });
585
+ } (usePasswordStrength$2));
586
+
587
+ var useRefocusOnActivator$2 = {};
588
+
589
+ var useRefocusOnActivator$1 = {};
590
+
591
+ Object.defineProperty(useRefocusOnActivator$1, "__esModule", { value: true });
592
+ useRefocusOnActivator$1.useRefocusOnActivator = void 0;
593
+ const react_1 = React__default["default"];
594
+ /**
595
+ * Brings back the focus to the element that opened an overlaid element once
596
+ * said overlaid element is dismissed.
597
+ *
598
+ * @param active - Determines if it should focus or not
599
+ */
600
+ function useRefocusOnActivator(active) {
601
+ (0, react_1.useEffect)(() => {
602
+ let activator;
603
+ if (active && !activator) {
604
+ activator = document.activeElement;
605
+ }
606
+ return () => {
607
+ if (active) {
608
+ if (activator instanceof HTMLElement) {
609
+ activator.focus();
610
+ }
611
+ activator = undefined;
612
+ }
613
+ };
614
+ }, [active]);
615
+ }
616
+ useRefocusOnActivator$1.useRefocusOnActivator = useRefocusOnActivator;
617
+
618
+ (function (exports) {
619
+ Object.defineProperty(exports, "__esModule", { value: true });
620
+ exports.useRefocusOnActivator = void 0;
621
+ var useRefocusOnActivator_1 = useRefocusOnActivator$1;
622
+ Object.defineProperty(exports, "useRefocusOnActivator", { enumerable: true, get: function () { return useRefocusOnActivator_1.useRefocusOnActivator; } });
623
+ } (useRefocusOnActivator$2));
624
+
625
+ var useResizeObserver$1 = {};
626
+
627
+ var useResizeObserver = {};
628
+
629
+ (function (exports) {
630
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
631
+ return (mod && mod.__esModule) ? mod : { "default": mod };
632
+ };
633
+ Object.defineProperty(exports, "__esModule", { value: true });
634
+ exports.useResizeObserver = exports.Breakpoints = void 0;
635
+ const react_1 = React__default["default"];
636
+ // Importing the polyfilled version of ResizeObserver
637
+ // eslint-disable-next-line import/no-internal-modules
638
+ const polyfilled_1 = __importDefault(require$$1__default$2["default"]);
639
+ const lodash_1 = require$$1__default["default"];
640
+ exports.Breakpoints = {
641
+ base: 640,
642
+ small: 500,
643
+ smaller: 265,
644
+ large: 750,
645
+ larger: 1024,
646
+ };
647
+ const wait = 100;
648
+ function useResizeObserver({ widths = exports.Breakpoints, heights = exports.Breakpoints, } = {}) {
649
+ const [exactSize, setSize] = (0, react_1.useState)({
650
+ width: undefined,
651
+ height: undefined,
652
+ });
653
+ const onResize = (0, react_1.useMemo)(() => (0, lodash_1.throttle)(setSize, wait), [wait]);
654
+ const { ref } = (0, polyfilled_1.default)({
655
+ onResize,
656
+ });
657
+ const exactWidth = exactSize.width;
658
+ const exactHeight = exactSize.height;
659
+ const sizes = {
660
+ width: getSize(widths, exactSize.width),
661
+ height: getSize(heights, exactSize.height),
662
+ exactWidth,
663
+ exactHeight,
664
+ };
665
+ return [ref, sizes];
666
+ }
667
+ exports.useResizeObserver = useResizeObserver;
668
+ /**
669
+ * To get the proper size we want to make sure that our value is greater
670
+ * then the comparable, but less then the next largest number in our
671
+ * object.
672
+ */
673
+ function getSize(sizes, comparable) {
674
+ if (!comparable || !sizes) {
675
+ return undefined;
676
+ }
677
+ /**
678
+ * Sort the values of our object so that we know they are in proper
679
+ * order to be compared by
680
+ */
681
+ const sortedSizes = Object.values(sizes)
682
+ .sort((a, b) => a - b)
683
+ .reverse();
684
+ return (sortedSizes.find(value => value <= comparable) ||
685
+ sortedSizes[sortedSizes.length - 1]);
686
+ }
687
+ } (useResizeObserver));
688
+
689
+ (function (exports) {
690
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
691
+ if (k2 === undefined) k2 = k;
692
+ var desc = Object.getOwnPropertyDescriptor(m, k);
693
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
694
+ desc = { enumerable: true, get: function() { return m[k]; } };
695
+ }
696
+ Object.defineProperty(o, k2, desc);
697
+ }) : (function(o, m, k, k2) {
698
+ if (k2 === undefined) k2 = k;
699
+ o[k2] = m[k];
700
+ }));
701
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
702
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
703
+ };
704
+ Object.defineProperty(exports, "__esModule", { value: true });
705
+ __exportStar(useResizeObserver, exports);
706
+ } (useResizeObserver$1));
707
+
50
708
  var css_248z$3 = ".m5A5oeRFaMs- {\n position: relative;\n border: calc(16px / 16) solid rgb(225, 225, 225);\n border: var(--border-base) solid var(--color-border);\n border-radius: calc(16px / 8);\n border-radius: var(--radius-base);\n}\n\n.cY-5BrIIUg8- {\n overflow: auto;\n}\n\n.y8xnHe7fwrI- {\n width: 100%;\n border-collapse: collapse;\n text-align: left;\n}\n\n.y8xnHe7fwrI- thead tr th {\n padding: calc(16px * 1);\n padding: var(--space-base);\n border-bottom: calc(16px / 16) solid rgb(225, 225, 225);\n border-bottom: var(--border-base) solid var(--color-border);\n color: rgb(1, 41, 57);\n color: var(--color-heading);\n white-space: nowrap;\n}\n\n.y8xnHe7fwrI- thead tr th :first-child {\n display: -ms-flexbox;\n display: flex;\n}\n\n.y8xnHe7fwrI- tbody tr {\n border-bottom: calc(16px / 16) solid rgb(225, 225, 225);\n border-bottom: var(--border-base) solid var(--color-border);\n}\n\n.y8xnHe7fwrI- tbody tr:last-child {\n border-bottom: none;\n}\n\n.y8xnHe7fwrI- tbody tr td {\n padding: calc(16px * 1);\n padding: var(--space-base);\n}\n\n.y8xnHe7fwrI- tfoot {\n position: sticky;\n z-index: 1;\n width: 100%;\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n border-top: calc(16px / 8) solid rgb(225, 225, 225);\n border-top: var(--border-thick) solid var(--color-border);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n bottom: 0;\n}\n\n.y8xnHe7fwrI- tfoot tr th {\n padding: calc(16px * 1);\n padding: var(--space-base);\n}\n\n.t8QYvdtkQXQ- thead tr th:first-child,\n.t8QYvdtkQXQ- tbody tr td:first-child {\n position: sticky;\n left: 0;\n z-index: 1;\n height: calc((16px * 3) + (16px / 4));\n height: calc(calc(16px * 3) + calc(16px / 4));\n height: calc(var(--space-largest) + var(--space-smaller));\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.t8QYvdtkQXQ- th:first-child::after,\n.t8QYvdtkQXQ- td:first-child::after {\n content: \"\";\n display: block;\n position: absolute;\n top: 0;\n right: calc(-1 * (16px / 2));\n right: calc(-1 * calc(16px / 2));\n right: calc(-1 * var(--space-small));\n width: calc(16px / 2);\n width: var(--space-small);\n height: 100%;\n background: linear-gradient(\n 90deg,\n rgba(0, 0, 0, 0.1) 0%,\n rgba(0, 0, 0, 0) 80%\n );\n background: linear-gradient(\n 90deg,\n rgba(var(--color-black--rgb), 0.1) 0%,\n rgba(var(--color-black--rgb), 0) 80%\n );\n}\n\n.Y21JuHX6fhk- {\n position: sticky;\n top: 0;\n right: 0;\n left: 0;\n z-index: 2;\n box-shadow: 0px calc(16px / 16) calc(16px / 4) 0px\n rgba(0, 0, 0, 0.1),\n 0px calc(16px / 4) 12px 0px rgba(0, 0, 0, 0.05);\n box-shadow: var(--shadow-base);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n}\n\n.PJEX8dlqCMA-:first-child:hover {\n background: rgb(250, 246, 219);\n background: var(--color-surface--hover);\n cursor: pointer;\n}\n\n._9ps4aWGs8W0-:hover {\n background: rgb(250, 246, 219);\n background: var(--color-surface--hover);\n cursor: pointer;\n}\n\n._59XEEB8l5pI-:hover,\n._59XEEB8l5pI-:hover :first-child {\n background: rgb(244, 244, 244);\n background: var(--color-surface--background);\n cursor: pointer;\n}\n\n.a2BGGBkY5J8- {\n display: -ms-flexbox;\n display: flex;\n position: absolute;\n -ms-flex-direction: column;\n flex-direction: column;\n top: calc(16px * 3);\n top: var(--space-largest);\n right: 0;\n bottom: calc(16px * 3);\n bottom: var(--space-largest);\n left: 0;\n width: 100%;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-align: center;\n align-items: center;\n}\n";
51
709
  var styles$3 = {"dataTableContainer":"m5A5oeRFaMs-","tableContainer":"cY-5BrIIUg8-","table":"y8xnHe7fwrI-","pinFirstColumn":"t8QYvdtkQXQ-","stickyHeader":"Y21JuHX6fhk-","pinFirstHeaderSortable":"PJEX8dlqCMA-","sortableColumn":"_9ps4aWGs8W0-","clickableRow":"_59XEEB8l5pI-","emptyState":"a2BGGBkY5J8-"};
52
710
  styleInject_es.styleInject(css_248z$3);
@@ -235,7 +893,7 @@ function Header({ table, stickyHeader, sorting, onRowClick, }) {
235
893
  }
236
894
 
237
895
  function DataTable({ data, columns, pagination, sorting, height, stickyHeader, pinFirstColumn, onRowClick, emptyState, }) {
238
- const [ref, { exactWidth }] = useResizeObserver.useResizeObserver();
896
+ const [ref, { exactWidth }] = useAssert$2.useResizeObserver();
239
897
  const tableSettings = createTableSettings(data, columns, {
240
898
  pagination,
241
899
  sorting,
@@ -251,10 +909,10 @@ function DataTable({ data, columns, pagination, sorting, height, stickyHeader, p
251
909
  React__default["default"].createElement(Body, { table: table, onRowClick: onRowClick, height: height ? height * 0.7 : undefined, emptyState: emptyState }),
252
910
  table.getRowModel().rows.length &&
253
911
  exactWidth &&
254
- exactWidth > useResizeObserver.Breakpoints.small ? (React__default["default"].createElement(Footer, { table: table, viewType: "desktop" })) : null)),
912
+ exactWidth > useAssert$2.Breakpoints.small ? (React__default["default"].createElement(Footer, { table: table, viewType: "desktop" })) : null)),
255
913
  table.getRowModel().rows.length &&
256
914
  exactWidth &&
257
- exactWidth <= useResizeObserver.Breakpoints.small ? (React__default["default"].createElement(Footer, { table: table })) : null,
915
+ exactWidth <= useAssert$2.Breakpoints.small ? (React__default["default"].createElement(Footer, { table: table })) : null,
258
916
  pagination && (React__default["default"].createElement(Pagination, { table: table, itemsPerPage: pagination.itemsPerPage, totalItems: pagination.manualPagination
259
917
  ? pagination.totalItems
260
918
  : table.getCoreRowModel().rows.length }))));
@@ -273,8 +931,8 @@ const mockContainerWidth = (exactWidth) => {
273
931
  };
274
932
 
275
933
  Object.defineProperty(exports, 'createColumnHelper', {
276
- enumerable: true,
277
- get: function () { return reactTable.createColumnHelper; }
934
+ enumerable: true,
935
+ get: function () { return reactTable.createColumnHelper; }
278
936
  });
279
937
  exports.DataTable = DataTable;
280
938
  exports.mockContainerWidth = mockContainerWidth;