@arc-ui/components 11.24.2 → 11.26.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.
Files changed (67) hide show
  1. package/dist/Button/Button.cjs.js +1 -1
  2. package/dist/Button/Button.esm.js +1 -1
  3. package/dist/DatePicker/DatePicker.cjs.js +1276 -22
  4. package/dist/DatePicker/DatePicker.esm.js +1245 -10
  5. package/dist/InformationCard/InformationCard.cjs.js +1 -1
  6. package/dist/InformationCard/InformationCard.esm.js +1 -1
  7. package/dist/Modal/Modal.cjs.js +438 -225
  8. package/dist/Modal/Modal.esm.js +420 -225
  9. package/dist/PaginationSimple/PaginationSimple.cjs.js +23 -2
  10. package/dist/PaginationSimple/PaginationSimple.esm.js +23 -2
  11. package/dist/Select/Select.cjs.js +1514 -1065
  12. package/dist/Select/Select.esm.js +1496 -1066
  13. package/dist/SiteHeader/SiteHeader.cjs.js +2 -2
  14. package/dist/SiteHeader/SiteHeader.esm.js +2 -2
  15. package/dist/SiteHeaderV2/SiteHeaderV2.cjs.js +2 -2
  16. package/dist/SiteHeaderV2/SiteHeaderV2.esm.js +2 -2
  17. package/dist/Tabs/Tabs.cjs.js +4 -6
  18. package/dist/Tabs/Tabs.esm.js +4 -6
  19. package/dist/TextArea/TextArea.cjs.js +10 -13
  20. package/dist/TextArea/TextArea.esm.js +10 -13
  21. package/dist/Toast/Toast.cjs.js +4 -6
  22. package/dist/Toast/Toast.esm.js +4 -6
  23. package/dist/UniversalHeader/UniversalHeader.cjs.js +2 -2
  24. package/dist/UniversalHeader/UniversalHeader.esm.js +2 -2
  25. package/dist/_shared/cjs/{Button-6ba21d3b.js → Button-5b28f0ce.js} +3 -3
  26. package/dist/_shared/cjs/{SiteHeader.rehydrator-9d8f3dad.js → SiteHeader.rehydrator-8fa9d174.js} +1 -1
  27. package/dist/_shared/cjs/{SiteHeaderV2-ce1c8737.js → SiteHeaderV2-ca2f13a8.js} +1 -1
  28. package/dist/_shared/cjs/{Tabs-bc9fac46.js → Tabs-89455281.js} +19 -15
  29. package/dist/_shared/cjs/{Toast-26207fef.js → Toast-c760c89d.js} +32 -14
  30. package/dist/_shared/cjs/{UniversalHeader-b8389447.js → UniversalHeader-73e154eb.js} +6 -2
  31. package/dist/_shared/cjs/component-4979b2e7.js +409 -0
  32. package/dist/_shared/cjs/{index-77ab5c6a.js → floating-ui.react-dom-08b8b87c.js} +12 -284
  33. package/dist/_shared/cjs/index-1efbba95.js +1252 -0
  34. package/dist/_shared/cjs/{index-74004a9c.js → index-4edec793.js} +1 -1
  35. package/dist/_shared/cjs/{index-dd1d18ea.js → index-7641213c.js} +127 -2
  36. package/dist/_shared/cjs/{index-9f99d686.js → index-af744fa9.js} +1 -1
  37. package/dist/_shared/cjs/{index-6eb396a3.js → index-fb0cad18.js} +1 -1
  38. package/dist/_shared/esm/{Button-a7d134c6.js → Button-5b48b7ce.js} +3 -3
  39. package/dist/_shared/esm/{SiteHeader.rehydrator-2ec02ee7.js → SiteHeader.rehydrator-8f3c5d6e.js} +1 -1
  40. package/dist/_shared/esm/{SiteHeaderV2-a7c1b1cb.js → SiteHeaderV2-cb081752.js} +1 -1
  41. package/dist/_shared/esm/{Tabs-9485cab6.js → Tabs-959e885d.js} +10 -6
  42. package/dist/_shared/esm/{Toast-fcbfc194.js → Toast-a590067d.js} +25 -7
  43. package/dist/_shared/esm/{UniversalHeader-80c7313f.js → UniversalHeader-96bfbacc.js} +6 -2
  44. package/dist/_shared/esm/component-d7b471ff.js +382 -0
  45. package/dist/_shared/esm/{index-b84a20c6.js → floating-ui.react-dom-1bb71aae.js} +4 -281
  46. package/dist/_shared/esm/{index-7b531fa7.js → index-0ae23b06.js} +126 -2
  47. package/dist/_shared/esm/index-307f1bbc.js +1212 -0
  48. package/dist/_shared/esm/{index-044da8d0.js → index-9e54cc7d.js} +1 -1
  49. package/dist/_shared/esm/{index-efa9be1a.js → index-af7b6e55.js} +1 -1
  50. package/dist/_shared/esm/{index-2cfab9f2.js → index-ebe72f34.js} +1 -1
  51. package/dist/index.es.js +3608 -2938
  52. package/dist/index.es.js.map +1 -1
  53. package/dist/index.js +3591 -2921
  54. package/dist/index.js.map +1 -1
  55. package/dist/styles.css +2 -2
  56. package/dist/types/components/Button/Button.d.ts +12 -0
  57. package/dist/types/components/PaginationSimple/PaginationSimple.d.ts +28 -0
  58. package/dist/types/components/UniversalHeader/UniversalHeader.d.ts +4 -0
  59. package/package.json +3 -3
  60. package/dist/_shared/cjs/Combination-9974f2e2.js +0 -1330
  61. package/dist/_shared/cjs/index-a31e64a9.js +0 -27
  62. package/dist/_shared/cjs/index-d38f1bd0.js +0 -131
  63. package/dist/_shared/cjs/index-dcfdd5da.js +0 -11
  64. package/dist/_shared/esm/Combination-e9f7e64e.js +0 -1301
  65. package/dist/_shared/esm/index-25a5b393.js +0 -25
  66. package/dist/_shared/esm/index-a624de47.js +0 -9
  67. package/dist/_shared/esm/index-ca72c9d5.js +0 -129
@@ -0,0 +1,409 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var filterDataAttrs = require('./filter-data-attrs-1c9a530c.js');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n["default"] = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
25
+
26
+ var zeroRightClassName = 'right-scroll-bar-position';
27
+ var fullWidthClassName = 'width-before-scroll-bar';
28
+ var noScrollbarsClassName = 'with-scroll-bars-hidden';
29
+ /**
30
+ * Name of a CSS variable containing the amount of "hidden" scrollbar
31
+ * ! might be undefined ! use will fallback!
32
+ */
33
+ var removedBarSizeVariable = '--removed-body-scroll-bar-size';
34
+
35
+ /**
36
+ * Assigns a value for a given ref, no matter of the ref format
37
+ * @param {RefObject} ref - a callback function or ref object
38
+ * @param value - a new value
39
+ *
40
+ * @see https://github.com/theKashey/use-callback-ref#assignref
41
+ * @example
42
+ * const refObject = useRef();
43
+ * const refFn = (ref) => {....}
44
+ *
45
+ * assignRef(refObject, "refValue");
46
+ * assignRef(refFn, "refValue");
47
+ */
48
+ function assignRef(ref, value) {
49
+ if (typeof ref === 'function') {
50
+ ref(value);
51
+ }
52
+ else if (ref) {
53
+ ref.current = value;
54
+ }
55
+ return ref;
56
+ }
57
+
58
+ /**
59
+ * creates a MutableRef with ref change callback
60
+ * @param initialValue - initial ref value
61
+ * @param {Function} callback - a callback to run when value changes
62
+ *
63
+ * @example
64
+ * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
65
+ * ref.current = 1;
66
+ * // prints 0 -> 1
67
+ *
68
+ * @see https://reactjs.org/docs/hooks-reference.html#useref
69
+ * @see https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
70
+ * @returns {MutableRefObject}
71
+ */
72
+ function useCallbackRef(initialValue, callback) {
73
+ var ref = React.useState(function () { return ({
74
+ // value
75
+ value: initialValue,
76
+ // last callback
77
+ callback: callback,
78
+ // "memoized" public interface
79
+ facade: {
80
+ get current() {
81
+ return ref.value;
82
+ },
83
+ set current(value) {
84
+ var last = ref.value;
85
+ if (last !== value) {
86
+ ref.value = value;
87
+ ref.callback(value, last);
88
+ }
89
+ },
90
+ },
91
+ }); })[0];
92
+ // update callback
93
+ ref.callback = callback;
94
+ return ref.facade;
95
+ }
96
+
97
+ var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
98
+ var currentValues = new WeakMap();
99
+ /**
100
+ * Merges two or more refs together providing a single interface to set their value
101
+ * @param {RefObject|Ref} refs
102
+ * @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
103
+ *
104
+ * @see {@link mergeRefs} a version without buit-in memoization
105
+ * @see https://github.com/theKashey/use-callback-ref#usemergerefs
106
+ * @example
107
+ * const Component = React.forwardRef((props, ref) => {
108
+ * const ownRef = useRef();
109
+ * const domRef = useMergeRefs([ref, ownRef]); // 👈 merge together
110
+ * return <div ref={domRef}>...</div>
111
+ * }
112
+ */
113
+ function useMergeRefs(refs, defaultValue) {
114
+ var callbackRef = useCallbackRef(defaultValue || null, function (newValue) {
115
+ return refs.forEach(function (ref) { return assignRef(ref, newValue); });
116
+ });
117
+ // handle refs changes - added or removed
118
+ useIsomorphicLayoutEffect(function () {
119
+ var oldValue = currentValues.get(callbackRef);
120
+ if (oldValue) {
121
+ var prevRefs_1 = new Set(oldValue);
122
+ var nextRefs_1 = new Set(refs);
123
+ var current_1 = callbackRef.current;
124
+ prevRefs_1.forEach(function (ref) {
125
+ if (!nextRefs_1.has(ref)) {
126
+ assignRef(ref, null);
127
+ }
128
+ });
129
+ nextRefs_1.forEach(function (ref) {
130
+ if (!prevRefs_1.has(ref)) {
131
+ assignRef(ref, current_1);
132
+ }
133
+ });
134
+ }
135
+ currentValues.set(callbackRef, refs);
136
+ }, [refs]);
137
+ return callbackRef;
138
+ }
139
+
140
+ function ItoI(a) {
141
+ return a;
142
+ }
143
+ function innerCreateMedium(defaults, middleware) {
144
+ if (middleware === void 0) { middleware = ItoI; }
145
+ var buffer = [];
146
+ var assigned = false;
147
+ var medium = {
148
+ read: function () {
149
+ if (assigned) {
150
+ throw new Error('Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.');
151
+ }
152
+ if (buffer.length) {
153
+ return buffer[buffer.length - 1];
154
+ }
155
+ return defaults;
156
+ },
157
+ useMedium: function (data) {
158
+ var item = middleware(data, assigned);
159
+ buffer.push(item);
160
+ return function () {
161
+ buffer = buffer.filter(function (x) { return x !== item; });
162
+ };
163
+ },
164
+ assignSyncMedium: function (cb) {
165
+ assigned = true;
166
+ while (buffer.length) {
167
+ var cbs = buffer;
168
+ buffer = [];
169
+ cbs.forEach(cb);
170
+ }
171
+ buffer = {
172
+ push: function (x) { return cb(x); },
173
+ filter: function () { return buffer; },
174
+ };
175
+ },
176
+ assignMedium: function (cb) {
177
+ assigned = true;
178
+ var pendingQueue = [];
179
+ if (buffer.length) {
180
+ var cbs = buffer;
181
+ buffer = [];
182
+ cbs.forEach(cb);
183
+ pendingQueue = buffer;
184
+ }
185
+ var executeQueue = function () {
186
+ var cbs = pendingQueue;
187
+ pendingQueue = [];
188
+ cbs.forEach(cb);
189
+ };
190
+ var cycle = function () { return Promise.resolve().then(executeQueue); };
191
+ cycle();
192
+ buffer = {
193
+ push: function (x) {
194
+ pendingQueue.push(x);
195
+ cycle();
196
+ },
197
+ filter: function (filter) {
198
+ pendingQueue = pendingQueue.filter(filter);
199
+ return buffer;
200
+ },
201
+ };
202
+ },
203
+ };
204
+ return medium;
205
+ }
206
+ // eslint-disable-next-line @typescript-eslint/ban-types
207
+ function createSidecarMedium(options) {
208
+ if (options === void 0) { options = {}; }
209
+ var medium = innerCreateMedium(null);
210
+ medium.options = filterDataAttrs.__assign({ async: true, ssr: false }, options);
211
+ return medium;
212
+ }
213
+
214
+ var SideCar = function (_a) {
215
+ var sideCar = _a.sideCar, rest = filterDataAttrs.__rest(_a, ["sideCar"]);
216
+ if (!sideCar) {
217
+ throw new Error('Sidecar: please provide `sideCar` property to import the right car');
218
+ }
219
+ var Target = sideCar.read();
220
+ if (!Target) {
221
+ throw new Error('Sidecar medium not found');
222
+ }
223
+ return React__namespace.createElement(Target, filterDataAttrs.__assign({}, rest));
224
+ };
225
+ SideCar.isSideCarExport = true;
226
+ function exportSidecar(medium, exported) {
227
+ medium.useMedium(exported);
228
+ return SideCar;
229
+ }
230
+
231
+ var getNonce = function () {
232
+ if (typeof __webpack_nonce__ !== 'undefined') {
233
+ return __webpack_nonce__;
234
+ }
235
+ return undefined;
236
+ };
237
+
238
+ function makeStyleTag() {
239
+ if (!document)
240
+ return null;
241
+ var tag = document.createElement('style');
242
+ tag.type = 'text/css';
243
+ var nonce = getNonce();
244
+ if (nonce) {
245
+ tag.setAttribute('nonce', nonce);
246
+ }
247
+ return tag;
248
+ }
249
+ function injectStyles(tag, css) {
250
+ // @ts-ignore
251
+ if (tag.styleSheet) {
252
+ // @ts-ignore
253
+ tag.styleSheet.cssText = css;
254
+ }
255
+ else {
256
+ tag.appendChild(document.createTextNode(css));
257
+ }
258
+ }
259
+ function insertStyleTag(tag) {
260
+ var head = document.head || document.getElementsByTagName('head')[0];
261
+ head.appendChild(tag);
262
+ }
263
+ var stylesheetSingleton = function () {
264
+ var counter = 0;
265
+ var stylesheet = null;
266
+ return {
267
+ add: function (style) {
268
+ if (counter == 0) {
269
+ if ((stylesheet = makeStyleTag())) {
270
+ injectStyles(stylesheet, style);
271
+ insertStyleTag(stylesheet);
272
+ }
273
+ }
274
+ counter++;
275
+ },
276
+ remove: function () {
277
+ counter--;
278
+ if (!counter && stylesheet) {
279
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
280
+ stylesheet = null;
281
+ }
282
+ },
283
+ };
284
+ };
285
+
286
+ /**
287
+ * creates a hook to control style singleton
288
+ * @see {@link styleSingleton} for a safer component version
289
+ * @example
290
+ * ```tsx
291
+ * const useStyle = styleHookSingleton();
292
+ * ///
293
+ * useStyle('body { overflow: hidden}');
294
+ */
295
+ var styleHookSingleton = function () {
296
+ var sheet = stylesheetSingleton();
297
+ return function (styles, isDynamic) {
298
+ React__namespace.useEffect(function () {
299
+ sheet.add(styles);
300
+ return function () {
301
+ sheet.remove();
302
+ };
303
+ }, [styles && isDynamic]);
304
+ };
305
+ };
306
+
307
+ /**
308
+ * create a Component to add styles on demand
309
+ * - styles are added when first instance is mounted
310
+ * - styles are removed when the last instance is unmounted
311
+ * - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
312
+ */
313
+ var styleSingleton = function () {
314
+ var useStyle = styleHookSingleton();
315
+ var Sheet = function (_a) {
316
+ var styles = _a.styles, dynamic = _a.dynamic;
317
+ useStyle(styles, dynamic);
318
+ return null;
319
+ };
320
+ return Sheet;
321
+ };
322
+
323
+ var zeroGap = {
324
+ left: 0,
325
+ top: 0,
326
+ right: 0,
327
+ gap: 0,
328
+ };
329
+ var parse = function (x) { return parseInt(x || '', 10) || 0; };
330
+ var getOffset = function (gapMode) {
331
+ var cs = window.getComputedStyle(document.body);
332
+ var left = cs[gapMode === 'padding' ? 'paddingLeft' : 'marginLeft'];
333
+ var top = cs[gapMode === 'padding' ? 'paddingTop' : 'marginTop'];
334
+ var right = cs[gapMode === 'padding' ? 'paddingRight' : 'marginRight'];
335
+ return [parse(left), parse(top), parse(right)];
336
+ };
337
+ var getGapWidth = function (gapMode) {
338
+ if (gapMode === void 0) { gapMode = 'margin'; }
339
+ if (typeof window === 'undefined') {
340
+ return zeroGap;
341
+ }
342
+ var offsets = getOffset(gapMode);
343
+ var documentWidth = document.documentElement.clientWidth;
344
+ var windowWidth = window.innerWidth;
345
+ return {
346
+ left: offsets[0],
347
+ top: offsets[1],
348
+ right: offsets[2],
349
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]),
350
+ };
351
+ };
352
+
353
+ var Style = styleSingleton();
354
+ var lockAttribute = 'data-scroll-locked';
355
+ // important tip - once we measure scrollBar width and remove them
356
+ // we could not repeat this operation
357
+ // thus we are using style-singleton - only the first "yet correct" style will be applied.
358
+ var getStyles = function (_a, allowRelative, gapMode, important) {
359
+ var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
360
+ if (gapMode === void 0) { gapMode = 'margin'; }
361
+ return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
362
+ allowRelative && "position: relative ".concat(important, ";"),
363
+ gapMode === 'margin' &&
364
+ "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
365
+ gapMode === 'padding' && "padding-right: ".concat(gap, "px ").concat(important, ";"),
366
+ ]
367
+ .filter(Boolean)
368
+ .join(''), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
369
+ };
370
+ var getCurrentUseCounter = function () {
371
+ var counter = parseInt(document.body.getAttribute(lockAttribute) || '0', 10);
372
+ return isFinite(counter) ? counter : 0;
373
+ };
374
+ var useLockAttribute = function () {
375
+ React__namespace.useEffect(function () {
376
+ document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
377
+ return function () {
378
+ var newCounter = getCurrentUseCounter() - 1;
379
+ if (newCounter <= 0) {
380
+ document.body.removeAttribute(lockAttribute);
381
+ }
382
+ else {
383
+ document.body.setAttribute(lockAttribute, newCounter.toString());
384
+ }
385
+ };
386
+ }, []);
387
+ };
388
+ /**
389
+ * Removes page scrollbar and blocks page scroll when mounted
390
+ */
391
+ var RemoveScrollBar = function (_a) {
392
+ var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? 'margin' : _b;
393
+ useLockAttribute();
394
+ /*
395
+ gap will be measured on every component mount
396
+ however it will be used only by the "first" invocation
397
+ due to singleton nature of <Style
398
+ */
399
+ var gap = React__namespace.useMemo(function () { return getGapWidth(gapMode); }, [gapMode]);
400
+ return React__namespace.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? '!important' : '') });
401
+ };
402
+
403
+ exports.RemoveScrollBar = RemoveScrollBar;
404
+ exports.createSidecarMedium = createSidecarMedium;
405
+ exports.exportSidecar = exportSidecar;
406
+ exports.fullWidthClassName = fullWidthClassName;
407
+ exports.styleSingleton = styleSingleton;
408
+ exports.useMergeRefs = useMergeRefs;
409
+ exports.zeroRightClassName = zeroRightClassName;