@qualtrics/ui-react 2.74.0 → 2.76.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 (178) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/__node_modules/@radix-ui/primitive/dist/index.js +54 -0
  3. package/dist/__node_modules/@radix-ui/react-arrow/dist/index.js +28 -0
  4. package/dist/__node_modules/@radix-ui/react-collection/dist/index.js +605 -0
  5. package/dist/__node_modules/@radix-ui/react-compose-refs/dist/index.js +45 -0
  6. package/dist/__node_modules/@radix-ui/react-context/dist/index.js +108 -0
  7. package/dist/__node_modules/@radix-ui/react-direction/dist/index.js +21 -0
  8. package/dist/__node_modules/@radix-ui/react-dismissable-layer/dist/index.js +223 -0
  9. package/dist/__node_modules/@radix-ui/react-dropdown-menu/dist/index.js +350 -0
  10. package/dist/__node_modules/@radix-ui/react-focus-guards/dist/index.js +35 -0
  11. package/dist/__node_modules/@radix-ui/react-focus-scope/dist/index.js +248 -0
  12. package/dist/__node_modules/@radix-ui/react-id/dist/index.js +15 -0
  13. package/dist/__node_modules/@radix-ui/react-menu/dist/index.js +911 -0
  14. package/dist/__node_modules/@radix-ui/react-popper/dist/index.js +325 -0
  15. package/dist/__node_modules/@radix-ui/react-portal/dist/index.js +25 -0
  16. package/dist/__node_modules/@radix-ui/react-presence/dist/index.js +141 -0
  17. package/dist/__node_modules/@radix-ui/react-primitive/dist/index.js +34 -0
  18. package/dist/__node_modules/@radix-ui/react-roving-focus/dist/index.js +216 -0
  19. package/dist/__node_modules/@radix-ui/react-slot/dist/index.js +127 -0
  20. package/dist/__node_modules/@radix-ui/react-use-callback-ref/dist/index.js +18 -0
  21. package/dist/__node_modules/@radix-ui/react-use-controllable-state/dist/index.js +141 -0
  22. package/dist/__node_modules/@radix-ui/react-use-effect-event/dist/index.js +32 -0
  23. package/dist/__node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +23 -0
  24. package/dist/__node_modules/@radix-ui/react-use-layout-effect/dist/index.js +6 -0
  25. package/dist/__node_modules/@radix-ui/react-use-size/dist/index.js +48 -0
  26. package/dist/__node_modules/aria-hidden/dist/es2015/index.js +169 -0
  27. package/dist/__node_modules/detect-node-es/esm/node.js +4 -0
  28. package/dist/__node_modules/get-nonce/dist/es2015/index.js +15 -0
  29. package/dist/__node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
  30. package/dist/__node_modules/react-remove-scroll/dist/es2015/SideEffect.js +169 -0
  31. package/dist/__node_modules/react-remove-scroll/dist/es2015/UI.js +39 -0
  32. package/dist/__node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
  33. package/dist/__node_modules/react-remove-scroll/dist/es2015/handleScroll.js +110 -0
  34. package/dist/__node_modules/react-remove-scroll/dist/es2015/index.js +1 -0
  35. package/dist/__node_modules/react-remove-scroll/dist/es2015/medium.js +6 -0
  36. package/dist/__node_modules/react-remove-scroll/dist/es2015/sidecar.js +8 -0
  37. package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/component.js +57 -0
  38. package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
  39. package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/index.js +3 -0
  40. package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
  41. package/dist/__node_modules/react-style-singleton/dist/es2015/component.js +19 -0
  42. package/dist/__node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
  43. package/dist/__node_modules/react-style-singleton/dist/es2015/index.js +3 -0
  44. package/dist/__node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
  45. package/dist/__node_modules/tslib/tslib.es6.js +403 -0
  46. package/dist/__node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
  47. package/dist/__node_modules/use-callback-ref/dist/es2015/createRef.js +25 -0
  48. package/dist/__node_modules/use-callback-ref/dist/es2015/index.js +8 -0
  49. package/dist/__node_modules/use-callback-ref/dist/es2015/mergeRef.js +21 -0
  50. package/dist/__node_modules/use-callback-ref/dist/es2015/refToCallback.js +50 -0
  51. package/dist/__node_modules/use-callback-ref/dist/es2015/transformRef.js +17 -0
  52. package/dist/__node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
  53. package/dist/__node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
  54. package/dist/__node_modules/use-callback-ref/dist/es2015/useTransformRef.js +21 -0
  55. package/dist/__node_modules/use-sidecar/dist/es2015/config.js +8 -0
  56. package/dist/__node_modules/use-sidecar/dist/es2015/env.js +8 -0
  57. package/dist/__node_modules/use-sidecar/dist/es2015/exports.js +21 -0
  58. package/dist/__node_modules/use-sidecar/dist/es2015/hoc.js +18 -0
  59. package/dist/__node_modules/use-sidecar/dist/es2015/hook.js +44 -0
  60. package/dist/__node_modules/use-sidecar/dist/es2015/index.js +6 -0
  61. package/dist/__node_modules/use-sidecar/dist/es2015/medium.js +81 -0
  62. package/dist/__node_modules/use-sidecar/dist/es2015/renderProp.js +38 -0
  63. package/dist/__shared/cjs/{index-be619849.js → index-87207072.js} +422 -371
  64. package/dist/__shared/cjs/{index-97d7b02b.js → index-b569963c.js} +3 -3
  65. package/dist/components/Accordion/Accordion2.js +3 -3
  66. package/dist/components/BreakpointSwitch/BreakpointSwitch.js +3 -2
  67. package/dist/components/Button/Button.js +3 -3
  68. package/dist/components/ButtonGroup/ButtonGroup.js +3 -2
  69. package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
  70. package/dist/components/Checkbox/Checkbox2.js +3 -3
  71. package/dist/components/ColorPicker/ColorPicker.js +7 -8
  72. package/dist/components/ColorPicker/ColorPicker2.js +3 -3
  73. package/dist/components/Combobox/Combobox.js +9 -8
  74. package/dist/components/Combobox/Combobox2.js +3 -3
  75. package/dist/components/Combobox/ComboboxList.js +5 -6
  76. package/dist/components/ConfigPane/ConfigPane2.js +3 -3
  77. package/dist/components/Divider/Divider2.js +3 -3
  78. package/dist/components/Dropdown/Dropdown.js +1 -1
  79. package/dist/components/Dropdown/Dropdown2.js +3 -3
  80. package/dist/components/Dropdown/DropdownButton.js +10 -9
  81. package/dist/components/Dropdown/DropdownList.js +6 -7
  82. package/dist/components/FilePicker/FilePicker2.js +3 -3
  83. package/dist/components/FormField/Caption.js +3 -3
  84. package/dist/components/FormField/FormField2.js +3 -3
  85. package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
  86. package/dist/components/IconButton/IconButton2.js +3 -3
  87. package/dist/components/InlineInput/InlineInput2.js +3 -3
  88. package/dist/components/Input/Input2.js +3 -3
  89. package/dist/components/InputGroup/InputGroup2.js +3 -3
  90. package/dist/components/Label/Label2.js +3 -3
  91. package/dist/components/Link/Link2.js +3 -3
  92. package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
  93. package/dist/components/LogicEditor/ConditionSet.js +2 -2
  94. package/dist/components/LogicEditor/LogicEditor2.js +3 -3
  95. package/dist/components/Modal/Modal.js +4 -2
  96. package/dist/components/Modal/Modal2.js +3 -3
  97. package/dist/components/NewMenu/BaseMenu.js +31 -25
  98. package/dist/components/NewMenu/Menu/Menu.js +1 -0
  99. package/dist/components/NewMenu/NewMenu.js +3 -3
  100. package/dist/components/NewMenu/SelectMenu/SelectMenu.js +3 -1
  101. package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +10 -4
  102. package/dist/components/NewMenu/parts/MenuItem.js +1 -1
  103. package/dist/components/NumberStepper/NumberStepper2.js +3 -3
  104. package/dist/components/PageLayout/PageLayout.js +3 -3
  105. package/dist/components/Pagination/Pagination2.js +3 -3
  106. package/dist/components/Popover/Popover.js +8 -14
  107. package/dist/components/Popover/Popover2.js +3 -3
  108. package/dist/components/QuickSearch/QuickSearch2.js +3 -3
  109. package/dist/components/Radio/Radio2.js +3 -3
  110. package/dist/components/SearchInput/SearchInput2.js +3 -3
  111. package/dist/components/SidebarNav/SidebarNav2.js +3 -3
  112. package/dist/components/Slider/Slider2.js +3 -3
  113. package/dist/components/Switch/Switch2.js +3 -3
  114. package/dist/components/Table/Table2.js +3 -3
  115. package/dist/components/Tabs/TabList.js +3 -2
  116. package/dist/components/Tabs/TabPanels.js +2 -1
  117. package/dist/components/Tabs/Tabs2.js +3 -3
  118. package/dist/components/Tooltip/Tooltip.js +6 -12
  119. package/dist/components/Tooltip/Tooltip2.js +3 -3
  120. package/dist/components/deprecated_ColorPicker/ColorPicker.js +5 -6
  121. package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
  122. package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
  123. package/dist/components/deprecated_Tabs/Tabs.js +3 -3
  124. package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
  125. package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
  126. package/dist/design-tokens/less/typography.js +3 -3
  127. package/dist/hooks/useOverlay/useOverlay2.js +3 -3
  128. package/dist/hooks/usePrevious/usePrevious.js +1 -1
  129. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +2 -2
  130. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
  131. package/dist/icons/Icon.js +3 -3
  132. package/dist/icons/index.js +1 -1
  133. package/dist/index.d.ts +18 -17
  134. package/dist/index.es.js +1 -1
  135. package/dist/index.js +4 -5
  136. package/dist/next/AdvancedTable/AdvancedTable.js +2 -0
  137. package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
  138. package/dist/next/AdvancedTable/AdvancedTablePagination.js +3 -1
  139. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
  140. package/dist/next/Combobox/Combobox2.js +3 -3
  141. package/dist/next/Combobox/ComboboxFlyout.js +6 -6
  142. package/dist/next/Combobox/ComboboxGroup.js +1 -1
  143. package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +1 -1
  144. package/dist/next/Combobox/hooks/useComboboxLoadingState/useComboboxLoadingState.js +1 -1
  145. package/dist/next/Drawer/Drawer2.js +3 -3
  146. package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
  147. package/dist/next/Form/FormFields/InputField.js +3 -3
  148. package/dist/next/Indicator/Indicator2.js +3 -3
  149. package/dist/next/Input/Input2.js +3 -3
  150. package/dist/next/LoadingSpinner/LoadingSpinner2.js +3 -3
  151. package/dist/next/Menu/Hooks/usePaneSearch.js +1 -1
  152. package/dist/next/Menu/Menu.js +2 -2
  153. package/dist/next/Menu/Menu2.js +3 -3
  154. package/dist/next/Menu/MenuButton.js +1 -1
  155. package/dist/next/Menu/MenuItem.js +2 -2
  156. package/dist/next/Menu/MenuPane.js +4 -3
  157. package/dist/next/Menu/SubMenu.js +8 -6
  158. package/dist/next/PhoneNumberInput/PhoneNumberInput.js +90 -41
  159. package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
  160. package/dist/next/Select/Select2.js +3 -3
  161. package/dist/next/SplitButton/SplitButton2.js +3 -3
  162. package/dist/next/TimePicker/TimeDropdown.js +5 -6
  163. package/dist/next/TimePicker/TimeInput.js +104 -37
  164. package/dist/next/TimePicker/TimePicker2.js +3 -3
  165. package/dist/next/ToggleButton/styles.js +3 -3
  166. package/dist/next/index.d.ts +27 -20
  167. package/dist/next/index.js +5605 -325
  168. package/dist/utils/Flyout/Flyout2.js +3 -3
  169. package/dist/utils/GridChildrenWrapper/GridChildrenWrapper.js +2 -1
  170. package/dist/utils/Popper/Popper.js +162 -114
  171. package/dist/utils/Portal/Portal.js +3 -2
  172. package/dist/utils/Text/Text.js +3 -2
  173. package/dist/utils/filterChildren/filterChildren.js +3 -2
  174. package/dist/utils/index.js +1 -0
  175. package/icons/package.json +3 -4
  176. package/next/package.json +4 -5
  177. package/package.json +17 -18
  178. package/dist/__shared/cjs/index-55082bc8.js +0 -13425
@@ -0,0 +1,31 @@
1
+ var zeroGap = {
2
+ left: 0,
3
+ top: 0,
4
+ right: 0,
5
+ gap: 0,
6
+ };
7
+ var parse = function (x) { return parseInt(x || '', 10) || 0; };
8
+ var getOffset = function (gapMode) {
9
+ var cs = window.getComputedStyle(document.body);
10
+ var left = cs[gapMode === 'padding' ? 'paddingLeft' : 'marginLeft'];
11
+ var top = cs[gapMode === 'padding' ? 'paddingTop' : 'marginTop'];
12
+ var right = cs[gapMode === 'padding' ? 'paddingRight' : 'marginRight'];
13
+ return [parse(left), parse(top), parse(right)];
14
+ };
15
+ var getGapWidth = function (gapMode) {
16
+ if (gapMode === void 0) { gapMode = 'margin'; }
17
+ if (typeof window === 'undefined') {
18
+ return zeroGap;
19
+ }
20
+ var offsets = getOffset(gapMode);
21
+ var documentWidth = document.documentElement.clientWidth;
22
+ var windowWidth = window.innerWidth;
23
+ return {
24
+ left: offsets[0],
25
+ top: offsets[1],
26
+ right: offsets[2],
27
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0]),
28
+ };
29
+ };
30
+
31
+ export { getGapWidth, zeroGap };
@@ -0,0 +1,19 @@
1
+ import { styleHookSingleton } from './hook.js';
2
+
3
+ /**
4
+ * create a Component to add styles on demand
5
+ * - styles are added when first instance is mounted
6
+ * - styles are removed when the last instance is unmounted
7
+ * - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
8
+ */
9
+ var styleSingleton = function () {
10
+ var useStyle = styleHookSingleton();
11
+ var Sheet = function (_a) {
12
+ var styles = _a.styles, dynamic = _a.dynamic;
13
+ useStyle(styles, dynamic);
14
+ return null;
15
+ };
16
+ return Sheet;
17
+ };
18
+
19
+ export { styleSingleton };
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { stylesheetSingleton } from './singleton.js';
3
+
4
+ /**
5
+ * creates a hook to control style singleton
6
+ * @see {@link styleSingleton} for a safer component version
7
+ * @example
8
+ * ```tsx
9
+ * const useStyle = styleHookSingleton();
10
+ * ///
11
+ * useStyle('body { overflow: hidden}');
12
+ */
13
+ var styleHookSingleton = function () {
14
+ var sheet = stylesheetSingleton();
15
+ return function (styles, isDynamic) {
16
+ React.useEffect(function () {
17
+ sheet.add(styles);
18
+ return function () {
19
+ sheet.remove();
20
+ };
21
+ }, [styles && isDynamic]);
22
+ };
23
+ };
24
+
25
+ export { styleHookSingleton };
@@ -0,0 +1,3 @@
1
+ export { styleSingleton } from './component.js';
2
+ export { stylesheetSingleton } from './singleton.js';
3
+ export { styleHookSingleton } from './hook.js';
@@ -0,0 +1,51 @@
1
+ import { getNonce } from '../../../get-nonce/dist/es2015/index.js';
2
+
3
+ function makeStyleTag() {
4
+ if (!document)
5
+ return null;
6
+ var tag = document.createElement('style');
7
+ tag.type = 'text/css';
8
+ var nonce = getNonce();
9
+ if (nonce) {
10
+ tag.setAttribute('nonce', nonce);
11
+ }
12
+ return tag;
13
+ }
14
+ function injectStyles(tag, css) {
15
+ // @ts-ignore
16
+ if (tag.styleSheet) {
17
+ // @ts-ignore
18
+ tag.styleSheet.cssText = css;
19
+ }
20
+ else {
21
+ tag.appendChild(document.createTextNode(css));
22
+ }
23
+ }
24
+ function insertStyleTag(tag) {
25
+ var head = document.head || document.getElementsByTagName('head')[0];
26
+ head.appendChild(tag);
27
+ }
28
+ var stylesheetSingleton = function () {
29
+ var counter = 0;
30
+ var stylesheet = null;
31
+ return {
32
+ add: function (style) {
33
+ if (counter == 0) {
34
+ if ((stylesheet = makeStyleTag())) {
35
+ injectStyles(stylesheet, style);
36
+ insertStyleTag(stylesheet);
37
+ }
38
+ }
39
+ counter++;
40
+ },
41
+ remove: function () {
42
+ counter--;
43
+ if (!counter && stylesheet) {
44
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
45
+ stylesheet = null;
46
+ }
47
+ },
48
+ };
49
+ };
50
+
51
+ export { stylesheetSingleton };
@@ -0,0 +1,403 @@
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
16
+
17
+ var extendStatics = function(d, b) {
18
+ extendStatics = Object.setPrototypeOf ||
19
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
21
+ return extendStatics(d, b);
22
+ };
23
+
24
+ function __extends(d, b) {
25
+ if (typeof b !== "function" && b !== null)
26
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
27
+ extendStatics(d, b);
28
+ function __() { this.constructor = d; }
29
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
+ }
31
+
32
+ var __assign = function() {
33
+ __assign = Object.assign || function __assign(t) {
34
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
35
+ s = arguments[i];
36
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
37
+ }
38
+ return t;
39
+ };
40
+ return __assign.apply(this, arguments);
41
+ };
42
+
43
+ function __rest(s, e) {
44
+ var t = {};
45
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
46
+ t[p] = s[p];
47
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
48
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
49
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
50
+ t[p[i]] = s[p[i]];
51
+ }
52
+ return t;
53
+ }
54
+
55
+ function __decorate(decorators, target, key, desc) {
56
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
57
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
58
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
59
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
60
+ }
61
+
62
+ function __param(paramIndex, decorator) {
63
+ return function (target, key) { decorator(target, key, paramIndex); }
64
+ }
65
+
66
+ function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
67
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
68
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
69
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
70
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
71
+ var _, done = false;
72
+ for (var i = decorators.length - 1; i >= 0; i--) {
73
+ var context = {};
74
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
75
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
76
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
77
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
78
+ if (kind === "accessor") {
79
+ if (result === void 0) continue;
80
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
81
+ if (_ = accept(result.get)) descriptor.get = _;
82
+ if (_ = accept(result.set)) descriptor.set = _;
83
+ if (_ = accept(result.init)) initializers.unshift(_);
84
+ }
85
+ else if (_ = accept(result)) {
86
+ if (kind === "field") initializers.unshift(_);
87
+ else descriptor[key] = _;
88
+ }
89
+ }
90
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
91
+ done = true;
92
+ };
93
+
94
+ function __runInitializers(thisArg, initializers, value) {
95
+ var useValue = arguments.length > 2;
96
+ for (var i = 0; i < initializers.length; i++) {
97
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
98
+ }
99
+ return useValue ? value : void 0;
100
+ };
101
+
102
+ function __propKey(x) {
103
+ return typeof x === "symbol" ? x : "".concat(x);
104
+ };
105
+
106
+ function __setFunctionName(f, name, prefix) {
107
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
108
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
109
+ };
110
+
111
+ function __metadata(metadataKey, metadataValue) {
112
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
113
+ }
114
+
115
+ function __awaiter(thisArg, _arguments, P, generator) {
116
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
117
+ return new (P || (P = Promise))(function (resolve, reject) {
118
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
119
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
120
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
121
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
122
+ });
123
+ }
124
+
125
+ function __generator(thisArg, body) {
126
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
127
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
128
+ function verb(n) { return function (v) { return step([n, v]); }; }
129
+ function step(op) {
130
+ if (f) throw new TypeError("Generator is already executing.");
131
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
132
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
133
+ if (y = 0, t) op = [op[0] & 2, t.value];
134
+ switch (op[0]) {
135
+ case 0: case 1: t = op; break;
136
+ case 4: _.label++; return { value: op[1], done: false };
137
+ case 5: _.label++; y = op[1]; op = [0]; continue;
138
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
139
+ default:
140
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
141
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
142
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
143
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
144
+ if (t[2]) _.ops.pop();
145
+ _.trys.pop(); continue;
146
+ }
147
+ op = body.call(thisArg, _);
148
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
149
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
150
+ }
151
+ }
152
+
153
+ var __createBinding = Object.create ? (function(o, m, k, k2) {
154
+ if (k2 === undefined) k2 = k;
155
+ var desc = Object.getOwnPropertyDescriptor(m, k);
156
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
157
+ desc = { enumerable: true, get: function() { return m[k]; } };
158
+ }
159
+ Object.defineProperty(o, k2, desc);
160
+ }) : (function(o, m, k, k2) {
161
+ if (k2 === undefined) k2 = k;
162
+ o[k2] = m[k];
163
+ });
164
+
165
+ function __exportStar(m, o) {
166
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
167
+ }
168
+
169
+ function __values(o) {
170
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
171
+ if (m) return m.call(o);
172
+ if (o && typeof o.length === "number") return {
173
+ next: function () {
174
+ if (o && i >= o.length) o = void 0;
175
+ return { value: o && o[i++], done: !o };
176
+ }
177
+ };
178
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
179
+ }
180
+
181
+ function __read(o, n) {
182
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
183
+ if (!m) return o;
184
+ var i = m.call(o), r, ar = [], e;
185
+ try {
186
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
187
+ }
188
+ catch (error) { e = { error: error }; }
189
+ finally {
190
+ try {
191
+ if (r && !r.done && (m = i["return"])) m.call(i);
192
+ }
193
+ finally { if (e) throw e.error; }
194
+ }
195
+ return ar;
196
+ }
197
+
198
+ /** @deprecated */
199
+ function __spread() {
200
+ for (var ar = [], i = 0; i < arguments.length; i++)
201
+ ar = ar.concat(__read(arguments[i]));
202
+ return ar;
203
+ }
204
+
205
+ /** @deprecated */
206
+ function __spreadArrays() {
207
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
208
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
209
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
210
+ r[k] = a[j];
211
+ return r;
212
+ }
213
+
214
+ function __spreadArray(to, from, pack) {
215
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
216
+ if (ar || !(i in from)) {
217
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
218
+ ar[i] = from[i];
219
+ }
220
+ }
221
+ return to.concat(ar || Array.prototype.slice.call(from));
222
+ }
223
+
224
+ function __await(v) {
225
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
226
+ }
227
+
228
+ function __asyncGenerator(thisArg, _arguments, generator) {
229
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
230
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
231
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
232
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
233
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
234
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
235
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
236
+ function fulfill(value) { resume("next", value); }
237
+ function reject(value) { resume("throw", value); }
238
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
239
+ }
240
+
241
+ function __asyncDelegator(o) {
242
+ var i, p;
243
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
244
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
245
+ }
246
+
247
+ function __asyncValues(o) {
248
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
249
+ var m = o[Symbol.asyncIterator], i;
250
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
251
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
252
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
253
+ }
254
+
255
+ function __makeTemplateObject(cooked, raw) {
256
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
257
+ return cooked;
258
+ };
259
+
260
+ var __setModuleDefault = Object.create ? (function(o, v) {
261
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
262
+ }) : function(o, v) {
263
+ o["default"] = v;
264
+ };
265
+
266
+ var ownKeys = function(o) {
267
+ ownKeys = Object.getOwnPropertyNames || function (o) {
268
+ var ar = [];
269
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
270
+ return ar;
271
+ };
272
+ return ownKeys(o);
273
+ };
274
+
275
+ function __importStar(mod) {
276
+ if (mod && mod.__esModule) return mod;
277
+ var result = {};
278
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
279
+ __setModuleDefault(result, mod);
280
+ return result;
281
+ }
282
+
283
+ function __importDefault(mod) {
284
+ return (mod && mod.__esModule) ? mod : { default: mod };
285
+ }
286
+
287
+ function __classPrivateFieldGet(receiver, state, kind, f) {
288
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
289
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
290
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
291
+ }
292
+
293
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
294
+ if (kind === "m") throw new TypeError("Private method is not writable");
295
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
296
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
297
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
298
+ }
299
+
300
+ function __classPrivateFieldIn(state, receiver) {
301
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
302
+ return typeof state === "function" ? receiver === state : state.has(receiver);
303
+ }
304
+
305
+ function __addDisposableResource(env, value, async) {
306
+ if (value !== null && value !== void 0) {
307
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
308
+ var dispose, inner;
309
+ if (async) {
310
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
311
+ dispose = value[Symbol.asyncDispose];
312
+ }
313
+ if (dispose === void 0) {
314
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
315
+ dispose = value[Symbol.dispose];
316
+ if (async) inner = dispose;
317
+ }
318
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
319
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
320
+ env.stack.push({ value: value, dispose: dispose, async: async });
321
+ }
322
+ else if (async) {
323
+ env.stack.push({ async: true });
324
+ }
325
+ return value;
326
+ }
327
+
328
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
329
+ var e = new Error(message);
330
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
331
+ };
332
+
333
+ function __disposeResources(env) {
334
+ function fail(e) {
335
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
336
+ env.hasError = true;
337
+ }
338
+ var r, s = 0;
339
+ function next() {
340
+ while (r = env.stack.pop()) {
341
+ try {
342
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
343
+ if (r.dispose) {
344
+ var result = r.dispose.call(r.value);
345
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
346
+ }
347
+ else s |= 1;
348
+ }
349
+ catch (e) {
350
+ fail(e);
351
+ }
352
+ }
353
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
354
+ if (env.hasError) throw env.error;
355
+ }
356
+ return next();
357
+ }
358
+
359
+ function __rewriteRelativeImportExtension(path, preserveJsx) {
360
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
361
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
362
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
363
+ });
364
+ }
365
+ return path;
366
+ }
367
+
368
+ var tslib_es6 = {
369
+ __extends,
370
+ __assign,
371
+ __rest,
372
+ __decorate,
373
+ __param,
374
+ __esDecorate,
375
+ __runInitializers,
376
+ __propKey,
377
+ __setFunctionName,
378
+ __metadata,
379
+ __awaiter,
380
+ __generator,
381
+ __createBinding,
382
+ __exportStar,
383
+ __values,
384
+ __read,
385
+ __spread,
386
+ __spreadArrays,
387
+ __spreadArray,
388
+ __await,
389
+ __asyncGenerator,
390
+ __asyncDelegator,
391
+ __asyncValues,
392
+ __makeTemplateObject,
393
+ __importStar,
394
+ __importDefault,
395
+ __classPrivateFieldGet,
396
+ __classPrivateFieldSet,
397
+ __classPrivateFieldIn,
398
+ __addDisposableResource,
399
+ __disposeResources,
400
+ __rewriteRelativeImportExtension,
401
+ };
402
+
403
+ export { __addDisposableResource, __assign, __asyncDelegator, __asyncGenerator, __asyncValues, __await, __awaiter, __classPrivateFieldGet, __classPrivateFieldIn, __classPrivateFieldSet, __createBinding, __decorate, __disposeResources, __esDecorate, __exportStar, __extends, __generator, __importDefault, __importStar, __makeTemplateObject, __metadata, __param, __propKey, __read, __rest, __rewriteRelativeImportExtension, __runInitializers, __setFunctionName, __spread, __spreadArray, __spreadArrays, __values, tslib_es6 as default };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Assigns a value for a given ref, no matter of the ref format
3
+ * @param {RefObject} ref - a callback function or ref object
4
+ * @param value - a new value
5
+ *
6
+ * @see https://github.com/theKashey/use-callback-ref#assignref
7
+ * @example
8
+ * const refObject = useRef();
9
+ * const refFn = (ref) => {....}
10
+ *
11
+ * assignRef(refObject, "refValue");
12
+ * assignRef(refFn, "refValue");
13
+ */
14
+ function assignRef(ref, value) {
15
+ if (typeof ref === 'function') {
16
+ ref(value);
17
+ }
18
+ else if (ref) {
19
+ ref.current = value;
20
+ }
21
+ return ref;
22
+ }
23
+
24
+ export { assignRef };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * creates a Ref object with on change callback
3
+ * @param callback
4
+ * @returns {RefObject}
5
+ *
6
+ * @see {@link useCallbackRef}
7
+ * @see https://reactjs.org/docs/refs-and-the-dom.html#creating-refs
8
+ */
9
+ function createCallbackRef(callback) {
10
+ var current = null;
11
+ return {
12
+ get current() {
13
+ return current;
14
+ },
15
+ set current(value) {
16
+ var last = current;
17
+ if (last !== value) {
18
+ current = value;
19
+ callback(value, last);
20
+ }
21
+ },
22
+ };
23
+ }
24
+
25
+ export { createCallbackRef };
@@ -0,0 +1,8 @@
1
+ export { assignRef } from './assignRef.js';
2
+ export { useCallbackRef } from './useRef.js';
3
+ export { createCallbackRef } from './createRef.js';
4
+ export { mergeRefs } from './mergeRef.js';
5
+ export { useMergeRefs } from './useMergeRef.js';
6
+ export { useTransformRef } from './useTransformRef.js';
7
+ export { transformRef } from './transformRef.js';
8
+ export { refToCallback, useRefToCallback } from './refToCallback.js';
@@ -0,0 +1,21 @@
1
+ import { assignRef } from './assignRef.js';
2
+ import { createCallbackRef } from './createRef.js';
3
+
4
+ /**
5
+ * Merges two or more refs together providing a single interface to set their value
6
+ * @param {RefObject|Ref} refs
7
+ * @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
8
+ *
9
+ * @see {@link useMergeRefs} to be used in ReactComponents
10
+ * @example
11
+ * const Component = React.forwardRef((props, ref) => {
12
+ * const ownRef = useRef();
13
+ * const domRef = mergeRefs([ref, ownRef]); // 👈 merge together
14
+ * return <div ref={domRef}>...</div>
15
+ * }
16
+ */
17
+ function mergeRefs(refs) {
18
+ return createCallbackRef(function (newValue) { return refs.forEach(function (ref) { return assignRef(ref, newValue); }); });
19
+ }
20
+
21
+ export { mergeRefs };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Unmemoized version of {@link useRefToCallback}
3
+ * @see {@link useRefToCallback}
4
+ * @param ref
5
+ */
6
+ function refToCallback(ref) {
7
+ return function (newValue) {
8
+ if (typeof ref === 'function') {
9
+ ref(newValue);
10
+ }
11
+ else if (ref) {
12
+ ref.current = newValue;
13
+ }
14
+ };
15
+ }
16
+ var nullCallback = function () { return null; };
17
+ // lets maintain a weak ref to, well, ref :)
18
+ // not using `kashe` to keep this package small
19
+ var weakMem = new WeakMap();
20
+ var weakMemoize = function (ref) {
21
+ var usedRef = ref || nullCallback;
22
+ var storedRef = weakMem.get(usedRef);
23
+ if (storedRef) {
24
+ return storedRef;
25
+ }
26
+ var cb = refToCallback(usedRef);
27
+ weakMem.set(usedRef, cb);
28
+ return cb;
29
+ };
30
+ /**
31
+ * Transforms a given `ref` into `callback`.
32
+ *
33
+ * To transform `callback` into ref use {@link useCallbackRef|useCallbackRef(undefined, callback)}
34
+ *
35
+ * @param {ReactRef} ref
36
+ * @returns {Function}
37
+ *
38
+ * @see https://github.com/theKashey/use-callback-ref#reftocallback
39
+ *
40
+ * @example
41
+ * const ref = useRef(0);
42
+ * const setRef = useRefToCallback(ref);
43
+ * 👉 setRef(10);
44
+ * ✅ ref.current === 10
45
+ */
46
+ function useRefToCallback(ref) {
47
+ return weakMemoize(ref);
48
+ }
49
+
50
+ export { refToCallback, useRefToCallback };