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