@jobber/components 6.15.0 → 6.16.0

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.
@@ -1,392 +1,4 @@
1
- import { tokens, darkTokens } from '@jobber/design';
2
- import React, { createContext, useState, useCallback, useEffect, useContext } from 'react';
3
- import { g as getDefaultExportFromCjs } from './_commonjsHelpers-es.js';
4
- import { e as eq_1, b as _Stack } from './identity-es.js';
5
- import { _ as _baseAssignValue } from './_baseAssignValue-es.js';
6
- import { _ as _baseFor } from './_baseFor-es.js';
7
- import { _ as _copyObject, k as keysIn_1, a as _cloneBufferExports, b as _cloneTypedArray, c as _copyArray, d as _initCloneObject, i as isPlainObject_1 } from './keysIn-es.js';
8
- import { b as isArrayLike_1, i as isArguments_1, a as isArray_1, c as isBufferExports, j as isFunction_1, d as isTypedArray_1 } from './isTypedArray-es.js';
9
- import { a as isObjectLike_1, i as isObject_1 } from './isObjectLike-es.js';
10
- import { _ as _baseRest, a as _isIterateeCall } from './_isIterateeCall-es.js';
11
-
12
- var baseAssignValue = _baseAssignValue,
13
- eq = eq_1;
14
-
15
- /**
16
- * This function is like `assignValue` except that it doesn't assign
17
- * `undefined` values.
18
- *
19
- * @private
20
- * @param {Object} object The object to modify.
21
- * @param {string} key The key of the property to assign.
22
- * @param {*} value The value to assign.
23
- */
24
- function assignMergeValue$2(object, key, value) {
25
- if ((value !== undefined && !eq(object[key], value)) ||
26
- (value === undefined && !(key in object))) {
27
- baseAssignValue(object, key, value);
28
- }
29
- }
30
-
31
- var _assignMergeValue = assignMergeValue$2;
32
-
33
- var isArrayLike = isArrayLike_1,
34
- isObjectLike = isObjectLike_1;
35
-
36
- /**
37
- * This method is like `_.isArrayLike` except that it also checks if `value`
38
- * is an object.
39
- *
40
- * @static
41
- * @memberOf _
42
- * @since 4.0.0
43
- * @category Lang
44
- * @param {*} value The value to check.
45
- * @returns {boolean} Returns `true` if `value` is an array-like object,
46
- * else `false`.
47
- * @example
48
- *
49
- * _.isArrayLikeObject([1, 2, 3]);
50
- * // => true
51
- *
52
- * _.isArrayLikeObject(document.body.children);
53
- * // => true
54
- *
55
- * _.isArrayLikeObject('abc');
56
- * // => false
57
- *
58
- * _.isArrayLikeObject(_.noop);
59
- * // => false
60
- */
61
- function isArrayLikeObject$1(value) {
62
- return isObjectLike(value) && isArrayLike(value);
63
- }
64
-
65
- var isArrayLikeObject_1 = isArrayLikeObject$1;
66
-
67
- /**
68
- * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
69
- *
70
- * @private
71
- * @param {Object} object The object to query.
72
- * @param {string} key The key of the property to get.
73
- * @returns {*} Returns the property value.
74
- */
75
-
76
- function safeGet$2(object, key) {
77
- if (key === 'constructor' && typeof object[key] === 'function') {
78
- return;
79
- }
80
-
81
- if (key == '__proto__') {
82
- return;
83
- }
84
-
85
- return object[key];
86
- }
87
-
88
- var _safeGet = safeGet$2;
89
-
90
- var copyObject = _copyObject,
91
- keysIn$1 = keysIn_1;
92
-
93
- /**
94
- * Converts `value` to a plain object flattening inherited enumerable string
95
- * keyed properties of `value` to own properties of the plain object.
96
- *
97
- * @static
98
- * @memberOf _
99
- * @since 3.0.0
100
- * @category Lang
101
- * @param {*} value The value to convert.
102
- * @returns {Object} Returns the converted plain object.
103
- * @example
104
- *
105
- * function Foo() {
106
- * this.b = 2;
107
- * }
108
- *
109
- * Foo.prototype.c = 3;
110
- *
111
- * _.assign({ 'a': 1 }, new Foo);
112
- * // => { 'a': 1, 'b': 2 }
113
- *
114
- * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
115
- * // => { 'a': 1, 'b': 2, 'c': 3 }
116
- */
117
- function toPlainObject$1(value) {
118
- return copyObject(value, keysIn$1(value));
119
- }
120
-
121
- var toPlainObject_1 = toPlainObject$1;
122
-
123
- var assignMergeValue$1 = _assignMergeValue,
124
- cloneBuffer = _cloneBufferExports,
125
- cloneTypedArray = _cloneTypedArray,
126
- copyArray = _copyArray,
127
- initCloneObject = _initCloneObject,
128
- isArguments = isArguments_1,
129
- isArray = isArray_1,
130
- isArrayLikeObject = isArrayLikeObject_1,
131
- isBuffer = isBufferExports,
132
- isFunction = isFunction_1,
133
- isObject$1 = isObject_1,
134
- isPlainObject = isPlainObject_1,
135
- isTypedArray = isTypedArray_1,
136
- safeGet$1 = _safeGet,
137
- toPlainObject = toPlainObject_1;
138
-
139
- /**
140
- * A specialized version of `baseMerge` for arrays and objects which performs
141
- * deep merges and tracks traversed objects enabling objects with circular
142
- * references to be merged.
143
- *
144
- * @private
145
- * @param {Object} object The destination object.
146
- * @param {Object} source The source object.
147
- * @param {string} key The key of the value to merge.
148
- * @param {number} srcIndex The index of `source`.
149
- * @param {Function} mergeFunc The function to merge values.
150
- * @param {Function} [customizer] The function to customize assigned values.
151
- * @param {Object} [stack] Tracks traversed source values and their merged
152
- * counterparts.
153
- */
154
- function baseMergeDeep$1(object, source, key, srcIndex, mergeFunc, customizer, stack) {
155
- var objValue = safeGet$1(object, key),
156
- srcValue = safeGet$1(source, key),
157
- stacked = stack.get(srcValue);
158
-
159
- if (stacked) {
160
- assignMergeValue$1(object, key, stacked);
161
- return;
162
- }
163
- var newValue = customizer
164
- ? customizer(objValue, srcValue, (key + ''), object, source, stack)
165
- : undefined;
166
-
167
- var isCommon = newValue === undefined;
168
-
169
- if (isCommon) {
170
- var isArr = isArray(srcValue),
171
- isBuff = !isArr && isBuffer(srcValue),
172
- isTyped = !isArr && !isBuff && isTypedArray(srcValue);
173
-
174
- newValue = srcValue;
175
- if (isArr || isBuff || isTyped) {
176
- if (isArray(objValue)) {
177
- newValue = objValue;
178
- }
179
- else if (isArrayLikeObject(objValue)) {
180
- newValue = copyArray(objValue);
181
- }
182
- else if (isBuff) {
183
- isCommon = false;
184
- newValue = cloneBuffer(srcValue, true);
185
- }
186
- else if (isTyped) {
187
- isCommon = false;
188
- newValue = cloneTypedArray(srcValue, true);
189
- }
190
- else {
191
- newValue = [];
192
- }
193
- }
194
- else if (isPlainObject(srcValue) || isArguments(srcValue)) {
195
- newValue = objValue;
196
- if (isArguments(objValue)) {
197
- newValue = toPlainObject(objValue);
198
- }
199
- else if (!isObject$1(objValue) || isFunction(objValue)) {
200
- newValue = initCloneObject(srcValue);
201
- }
202
- }
203
- else {
204
- isCommon = false;
205
- }
206
- }
207
- if (isCommon) {
208
- // Recursively merge objects and arrays (susceptible to call stack limits).
209
- stack.set(srcValue, newValue);
210
- mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
211
- stack['delete'](srcValue);
212
- }
213
- assignMergeValue$1(object, key, newValue);
214
- }
215
-
216
- var _baseMergeDeep = baseMergeDeep$1;
217
-
218
- var Stack = _Stack,
219
- assignMergeValue = _assignMergeValue,
220
- baseFor = _baseFor,
221
- baseMergeDeep = _baseMergeDeep,
222
- isObject = isObject_1,
223
- keysIn = keysIn_1,
224
- safeGet = _safeGet;
225
-
226
- /**
227
- * The base implementation of `_.merge` without support for multiple sources.
228
- *
229
- * @private
230
- * @param {Object} object The destination object.
231
- * @param {Object} source The source object.
232
- * @param {number} srcIndex The index of `source`.
233
- * @param {Function} [customizer] The function to customize merged values.
234
- * @param {Object} [stack] Tracks traversed source values and their merged
235
- * counterparts.
236
- */
237
- function baseMerge$1(object, source, srcIndex, customizer, stack) {
238
- if (object === source) {
239
- return;
240
- }
241
- baseFor(source, function(srcValue, key) {
242
- stack || (stack = new Stack);
243
- if (isObject(srcValue)) {
244
- baseMergeDeep(object, source, key, srcIndex, baseMerge$1, customizer, stack);
245
- }
246
- else {
247
- var newValue = customizer
248
- ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
249
- : undefined;
250
-
251
- if (newValue === undefined) {
252
- newValue = srcValue;
253
- }
254
- assignMergeValue(object, key, newValue);
255
- }
256
- }, keysIn);
257
- }
258
-
259
- var _baseMerge = baseMerge$1;
260
-
261
- var baseRest = _baseRest,
262
- isIterateeCall = _isIterateeCall;
263
-
264
- /**
265
- * Creates a function like `_.assign`.
266
- *
267
- * @private
268
- * @param {Function} assigner The function to assign values.
269
- * @returns {Function} Returns the new assigner function.
270
- */
271
- function createAssigner$1(assigner) {
272
- return baseRest(function(object, sources) {
273
- var index = -1,
274
- length = sources.length,
275
- customizer = length > 1 ? sources[length - 1] : undefined,
276
- guard = length > 2 ? sources[2] : undefined;
277
-
278
- customizer = (assigner.length > 3 && typeof customizer == 'function')
279
- ? (length--, customizer)
280
- : undefined;
281
-
282
- if (guard && isIterateeCall(sources[0], sources[1], guard)) {
283
- customizer = length < 3 ? undefined : customizer;
284
- length = 1;
285
- }
286
- object = Object(object);
287
- while (++index < length) {
288
- var source = sources[index];
289
- if (source) {
290
- assigner(object, source, index, customizer);
291
- }
292
- }
293
- return object;
294
- });
295
- }
296
-
297
- var _createAssigner = createAssigner$1;
298
-
299
- var baseMerge = _baseMerge,
300
- createAssigner = _createAssigner;
301
-
302
- /**
303
- * This method is like `_.assign` except that it recursively merges own and
304
- * inherited enumerable string keyed properties of source objects into the
305
- * destination object. Source properties that resolve to `undefined` are
306
- * skipped if a destination value exists. Array and plain object properties
307
- * are merged recursively. Other objects and value types are overridden by
308
- * assignment. Source objects are applied from left to right. Subsequent
309
- * sources overwrite property assignments of previous sources.
310
- *
311
- * **Note:** This method mutates `object`.
312
- *
313
- * @static
314
- * @memberOf _
315
- * @since 0.5.0
316
- * @category Object
317
- * @param {Object} object The destination object.
318
- * @param {...Object} [sources] The source objects.
319
- * @returns {Object} Returns `object`.
320
- * @example
321
- *
322
- * var object = {
323
- * 'a': [{ 'b': 2 }, { 'd': 4 }]
324
- * };
325
- *
326
- * var other = {
327
- * 'a': [{ 'c': 3 }, { 'e': 5 }]
328
- * };
329
- *
330
- * _.merge(object, other);
331
- * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
332
- */
333
- var merge = createAssigner(function(object, source, srcIndex) {
334
- baseMerge(object, source, srcIndex);
335
- });
336
-
337
- var merge_1 = merge;
338
-
339
- var merge$1 = /*@__PURE__*/getDefaultExportFromCjs(merge_1);
340
-
341
- const THEME_CHANGE_EVENT = "atlantis.toggle-theme";
342
-
343
- var styles = {"staticThemeProviderWrapper":"P6HrDSaI0Ac-","spinning":"iq03qkKnXBA-"};
344
-
345
- const atlantisThemeContextDefaultValues = {
346
- theme: "light",
347
- tokens: tokens,
348
- };
349
- const actualDarkTokens = merge$1({}, tokens, darkTokens);
350
- const AtlantisThemeContext = createContext(atlantisThemeContextDefaultValues);
351
- function AtlantisThemeContextProvider({ children, dangerouslyOverrideTheme, }) {
352
- if (dangerouslyOverrideTheme) {
353
- return (React.createElement(InternalStaticThemeProvider, { dangerouslyOverrideTheme: dangerouslyOverrideTheme }, children));
354
- }
355
- return (React.createElement(InternalDynamicThemeProvider, null, children));
356
- }
357
- function InternalDynamicThemeProvider({ children }) {
358
- var _a;
359
- const initialTheme = (_a = globalThis.document.documentElement.dataset.theme) !== null && _a !== void 0 ? _a : "light";
360
- const [internalTheme, setInternalTheme] = useState(initialTheme);
361
- const currentTokens = internalTheme === "dark" ? actualDarkTokens : tokens;
362
- const handleThemeChangeEvent = useCallback((event) => {
363
- const newTheme = event.detail.theme;
364
- setInternalTheme(newTheme);
365
- }, []);
366
- useEffect(() => {
367
- if (!globalThis.window)
368
- return;
369
- globalThis.window.addEventListener(THEME_CHANGE_EVENT, handleThemeChangeEvent);
370
- return () => {
371
- globalThis.window.removeEventListener(THEME_CHANGE_EVENT, handleThemeChangeEvent);
372
- };
373
- }, [handleThemeChangeEvent]);
374
- return (React.createElement(AtlantisThemeContext.Provider, { value: {
375
- theme: internalTheme,
376
- tokens: currentTokens,
377
- } }, children));
378
- }
379
- function InternalStaticThemeProvider({ dangerouslyOverrideTheme, children, }) {
380
- const currentTokens = dangerouslyOverrideTheme === "dark" ? actualDarkTokens : tokens;
381
- return (React.createElement(AtlantisThemeContext.Provider, { value: {
382
- theme: dangerouslyOverrideTheme,
383
- tokens: currentTokens,
384
- } },
385
- React.createElement("div", { "data-theme": dangerouslyOverrideTheme, className: styles.staticThemeProviderWrapper }, children)));
386
- }
387
- function useAtlantisTheme() {
388
- return useContext(AtlantisThemeContext);
389
- }
1
+ import { T as THEME_CHANGE_EVENT } from './AtlantisThemeContext-es.js';
390
2
 
391
3
  /**
392
4
  * Toggle the theme of the application. If subscribed, the tokens will be updated accordingly.
@@ -403,4 +15,4 @@ function updateTheme(theme) {
403
15
  globalThis.window.dispatchEvent(event);
404
16
  }
405
17
 
406
- export { AtlantisThemeContextProvider as A, THEME_CHANGE_EVENT as T, atlantisThemeContextDefaultValues as a, updateTheme as b, useAtlantisTheme as u };
18
+ export { updateTheme as u };
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var debounce = require('./debounce-cjs.js');
5
+
6
+ /**
7
+ * A hook to easily manage debounced functions, including their cleanup.
8
+ * @param func The function to debounce.
9
+ * @param wait The number of milliseconds to delay.
10
+ * @param options Optional debounce settings.
11
+ * @returns The debounced function.
12
+ */
13
+ function useDebounce(func, wait, options) {
14
+ const funcRef = React.useRef(func);
15
+ // We're keeping the provided func wrapped in a ref to avoid forcing the consumer to memoize it.
16
+ // This is a defense against consumers who aren't memoizing their functions.. or if they are
17
+ // memoized but invalidating too frequently due to possible bugs.
18
+ if (funcRef.current !== func) {
19
+ funcRef.current = func;
20
+ }
21
+ const debounced = React.useMemo(() => {
22
+ return debounce.debounce(() => funcRef.current(), wait, options);
23
+ // Note: do not add any dependencies! There is currently no use case where we would change
24
+ // the wait delay or options between renders. By not tracking as dependencies, this allows
25
+ // consumers of useDebounce to provide a raw object for options rather than forcing them to
26
+ // memoize that param. Same with the func they provide, we're using a ref to keep that up
27
+ // to date and to avoid forcing the consumer to memoize it.
28
+ }, []);
29
+ React.useEffect(() => {
30
+ // If the debounced function is recreated (or unmounted), cancel the last call.
31
+ return () => debounced.cancel();
32
+ }, [debounced]);
33
+ return debounced;
34
+ }
35
+
36
+ exports.useDebounce = useDebounce;
@@ -0,0 +1,34 @@
1
+ import { useRef, useMemo, useEffect } from 'react';
2
+ import { d as debounce } from './debounce-es.js';
3
+
4
+ /**
5
+ * A hook to easily manage debounced functions, including their cleanup.
6
+ * @param func The function to debounce.
7
+ * @param wait The number of milliseconds to delay.
8
+ * @param options Optional debounce settings.
9
+ * @returns The debounced function.
10
+ */
11
+ function useDebounce(func, wait, options) {
12
+ const funcRef = useRef(func);
13
+ // We're keeping the provided func wrapped in a ref to avoid forcing the consumer to memoize it.
14
+ // This is a defense against consumers who aren't memoizing their functions.. or if they are
15
+ // memoized but invalidating too frequently due to possible bugs.
16
+ if (funcRef.current !== func) {
17
+ funcRef.current = func;
18
+ }
19
+ const debounced = useMemo(() => {
20
+ return debounce(() => funcRef.current(), wait, options);
21
+ // Note: do not add any dependencies! There is currently no use case where we would change
22
+ // the wait delay or options between renders. By not tracking as dependencies, this allows
23
+ // consumers of useDebounce to provide a raw object for options rather than forcing them to
24
+ // memoize that param. Same with the func they provide, we're using a ref to keep that up
25
+ // to date and to avoid forcing the consumer to memoize it.
26
+ }, []);
27
+ useEffect(() => {
28
+ // If the debounced function is recreated (or unmounted), cancel the last call.
29
+ return () => debounced.cancel();
30
+ }, [debounced]);
31
+ return debounced;
32
+ }
33
+
34
+ export { useDebounce as u };
@@ -7,7 +7,7 @@ import { b as isArrayLike_1, k as _baseUnary, a as isArray_1 } from './isTypedAr
7
7
  import { i as isSymbol_1 } from './isSymbol-es.js';
8
8
  import { i as identity_1 } from './identity-es.js';
9
9
  import { _ as _baseRest, a as _isIterateeCall } from './_isIterateeCall-es.js';
10
- import { a as debounce } from './debounce-es.js';
10
+ import { d as debounce } from './debounce-es.js';
11
11
  import { I as Icon } from './Icon-es.js';
12
12
  import { usePopper } from 'react-popper';
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.15.0",
3
+ "version": "6.16.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -489,5 +489,5 @@
489
489
  "> 1%",
490
490
  "IE 10"
491
491
  ],
492
- "gitHead": "e4f81d6b108b7ef516bc061c0e38d6db6575b6c5"
492
+ "gitHead": "2e308bcccf914e471f8d82a72573e90d15e59bf8"
493
493
  }