@qualtrics/ui-react 2.75.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.
- package/CHANGELOG.md +9 -0
- package/dist/__node_modules/@radix-ui/primitive/dist/index.js +54 -0
- package/dist/__node_modules/@radix-ui/react-arrow/dist/index.js +28 -0
- package/dist/__node_modules/@radix-ui/react-collection/dist/index.js +605 -0
- package/dist/__node_modules/@radix-ui/react-compose-refs/dist/index.js +45 -0
- package/dist/__node_modules/@radix-ui/react-context/dist/index.js +108 -0
- package/dist/__node_modules/@radix-ui/react-direction/dist/index.js +21 -0
- package/dist/__node_modules/@radix-ui/react-dismissable-layer/dist/index.js +223 -0
- package/dist/__node_modules/@radix-ui/react-dropdown-menu/dist/index.js +350 -0
- package/dist/__node_modules/@radix-ui/react-focus-guards/dist/index.js +35 -0
- package/dist/__node_modules/@radix-ui/react-focus-scope/dist/index.js +248 -0
- package/dist/__node_modules/@radix-ui/react-id/dist/index.js +15 -0
- package/dist/__node_modules/@radix-ui/react-menu/dist/index.js +911 -0
- package/dist/__node_modules/@radix-ui/react-popper/dist/index.js +325 -0
- package/dist/__node_modules/@radix-ui/react-portal/dist/index.js +25 -0
- package/dist/__node_modules/@radix-ui/react-presence/dist/index.js +141 -0
- package/dist/__node_modules/@radix-ui/react-primitive/dist/index.js +34 -0
- package/dist/__node_modules/@radix-ui/react-roving-focus/dist/index.js +216 -0
- package/dist/__node_modules/@radix-ui/react-slot/dist/index.js +127 -0
- package/dist/__node_modules/@radix-ui/react-use-callback-ref/dist/index.js +18 -0
- package/dist/__node_modules/@radix-ui/react-use-controllable-state/dist/index.js +141 -0
- package/dist/__node_modules/@radix-ui/react-use-effect-event/dist/index.js +32 -0
- package/dist/__node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +23 -0
- package/dist/__node_modules/@radix-ui/react-use-layout-effect/dist/index.js +6 -0
- package/dist/__node_modules/@radix-ui/react-use-size/dist/index.js +48 -0
- package/dist/__node_modules/aria-hidden/dist/es2015/index.js +169 -0
- package/dist/__node_modules/detect-node-es/esm/node.js +4 -0
- package/dist/__node_modules/get-nonce/dist/es2015/index.js +15 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/SideEffect.js +169 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/UI.js +39 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/handleScroll.js +110 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/index.js +1 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/medium.js +6 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/sidecar.js +8 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/component.js +57 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/index.js +3 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/component.js +19 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/index.js +3 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
- package/dist/__node_modules/tslib/tslib.es6.js +403 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/createRef.js +25 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/index.js +8 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/mergeRef.js +21 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/refToCallback.js +50 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/transformRef.js +17 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/useTransformRef.js +21 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/config.js +8 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/env.js +8 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/exports.js +21 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/hoc.js +18 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/hook.js +44 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/index.js +6 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/medium.js +81 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/renderProp.js +38 -0
- package/dist/__shared/cjs/{index-9f6415a6.js → index-87207072.js} +422 -371
- package/dist/__shared/cjs/{index-98bc748b.js → index-b569963c.js} +3 -3
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/BreakpointSwitch/BreakpointSwitch.js +3 -2
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/ButtonGroup/ButtonGroup.js +3 -2
- package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
- package/dist/components/Checkbox/Checkbox2.js +3 -3
- package/dist/components/ColorPicker/ColorPicker.js +7 -8
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/Combobox/Combobox.js +9 -8
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/Combobox/ComboboxList.js +5 -6
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/Dropdown.js +1 -1
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/Dropdown/DropdownButton.js +10 -9
- package/dist/components/Dropdown/DropdownList.js +6 -7
- package/dist/components/FilePicker/FilePicker2.js +3 -3
- package/dist/components/FormField/Caption.js +3 -3
- package/dist/components/FormField/FormField2.js +3 -3
- package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
- package/dist/components/IconButton/IconButton2.js +3 -3
- package/dist/components/InlineInput/InlineInput2.js +3 -3
- package/dist/components/Input/Input2.js +3 -3
- package/dist/components/InputGroup/InputGroup2.js +3 -3
- package/dist/components/Label/Label2.js +3 -3
- package/dist/components/Link/Link2.js +3 -3
- package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/components/LogicEditor/ConditionSet.js +2 -2
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/Modal/Modal.js +4 -2
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/BaseMenu.js +31 -25
- package/dist/components/NewMenu/Menu/Menu.js +1 -0
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NewMenu/SelectMenu/SelectMenu.js +3 -1
- package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +10 -4
- package/dist/components/NewMenu/parts/MenuItem.js +1 -1
- package/dist/components/NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/PageLayout/PageLayout.js +3 -3
- package/dist/components/Pagination/Pagination2.js +3 -3
- package/dist/components/Popover/Popover.js +8 -14
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/Radio/Radio2.js +3 -3
- package/dist/components/SearchInput/SearchInput2.js +3 -3
- package/dist/components/SidebarNav/SidebarNav2.js +3 -3
- package/dist/components/Slider/Slider2.js +3 -3
- package/dist/components/Switch/Switch2.js +3 -3
- package/dist/components/Table/Table2.js +3 -3
- package/dist/components/Tabs/TabList.js +3 -2
- package/dist/components/Tabs/TabPanels.js +2 -1
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip.js +6 -12
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/deprecated_ColorPicker/ColorPicker.js +5 -6
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_Tabs/Tabs.js +3 -3
- package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
- package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
- package/dist/design-tokens/less/typography.js +3 -3
- package/dist/hooks/useOverlay/useOverlay2.js +3 -3
- package/dist/hooks/usePrevious/usePrevious.js +1 -1
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +2 -2
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +18 -17
- package/dist/index.es.js +1 -1
- package/dist/index.js +4 -5
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Combobox/ComboboxFlyout.js +6 -6
- package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +1 -1
- package/dist/next/Combobox/hooks/useComboboxLoadingState/useComboboxLoadingState.js +1 -1
- package/dist/next/Drawer/Drawer2.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Form/FormFields/InputField.js +3 -3
- package/dist/next/Indicator/Indicator2.js +3 -3
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/next/Menu/Hooks/usePaneSearch.js +1 -1
- package/dist/next/Menu/Menu.js +2 -2
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuButton.js +1 -1
- package/dist/next/Menu/MenuItem.js +2 -2
- package/dist/next/Menu/MenuPane.js +4 -3
- package/dist/next/Menu/SubMenu.js +8 -6
- package/dist/next/PhoneNumberInput/PhoneNumberInput.js +90 -41
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/Select/Select2.js +3 -3
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/TimePicker/TimeDropdown.js +5 -6
- package/dist/next/TimePicker/TimeInput.js +104 -37
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.d.ts +15 -13
- package/dist/next/index.js +5601 -324
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/dist/utils/GridChildrenWrapper/GridChildrenWrapper.js +2 -1
- package/dist/utils/Popper/Popper.js +162 -114
- package/dist/utils/Portal/Portal.js +3 -2
- package/dist/utils/Text/Text.js +3 -2
- package/dist/utils/filterChildren/filterChildren.js +3 -2
- package/dist/utils/index.js +1 -0
- package/icons/package.json +3 -4
- package/next/package.json +4 -5
- package/package.json +15 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
**All notable changes to `@qualtrics/ui-react` will be documented in this file. This project adheres to <a href="https://semver.org/spec/v2.0.0.html" target="_blank">Semantic Versioning</a>. To be notified of new releases, subscribe to the `design-system-changelog@qualtrics.com` email group in [Odo](https://odo.corp.qualtrics.com/)**
|
|
2
2
|
|
|
3
|
+
## 2.76.0 - March 17, 2026
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **Added support for React 19.**
|
|
8
|
+
- Migrated all components from **popperjs** to **floating-ui** especially Popover, Tooltip and from **react-input-mask** to **react-imask**, specifically PhoneNumberInput and TimePicker to support React 19 migration.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
3
12
|
## 2.75.0 - March 16, 2026
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/primitive.tsx
|
|
2
|
+
var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
3
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler) {
|
|
4
|
+
let {
|
|
5
|
+
checkForDefaultPrevented = true
|
|
6
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
7
|
+
return function handleEvent(event) {
|
|
8
|
+
originalEventHandler === null || originalEventHandler === void 0 || originalEventHandler(event);
|
|
9
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
10
|
+
return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function getOwnerWindow(element) {
|
|
15
|
+
var _element$ownerDocumen, _element$ownerDocumen2;
|
|
16
|
+
if (!canUseDOM) {
|
|
17
|
+
throw new Error("Cannot access window outside of the DOM");
|
|
18
|
+
}
|
|
19
|
+
return (_element$ownerDocumen = element === null || element === void 0 || (_element$ownerDocumen2 = element.ownerDocument) === null || _element$ownerDocumen2 === void 0 ? void 0 : _element$ownerDocumen2.defaultView) !== null && _element$ownerDocumen !== void 0 ? _element$ownerDocumen : window;
|
|
20
|
+
}
|
|
21
|
+
function getOwnerDocument(element) {
|
|
22
|
+
var _element$ownerDocumen3;
|
|
23
|
+
if (!canUseDOM) {
|
|
24
|
+
throw new Error("Cannot access document outside of the DOM");
|
|
25
|
+
}
|
|
26
|
+
return (_element$ownerDocumen3 = element === null || element === void 0 ? void 0 : element.ownerDocument) !== null && _element$ownerDocumen3 !== void 0 ? _element$ownerDocumen3 : document;
|
|
27
|
+
}
|
|
28
|
+
function getActiveElement(node) {
|
|
29
|
+
let activeDescendant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
30
|
+
const {
|
|
31
|
+
activeElement
|
|
32
|
+
} = getOwnerDocument(node);
|
|
33
|
+
if (!(activeElement !== null && activeElement !== void 0 && activeElement.nodeName)) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (isFrame(activeElement) && activeElement.contentDocument) {
|
|
37
|
+
return getActiveElement(activeElement.contentDocument.body, activeDescendant);
|
|
38
|
+
}
|
|
39
|
+
if (activeDescendant) {
|
|
40
|
+
const id = activeElement.getAttribute("aria-activedescendant");
|
|
41
|
+
if (id) {
|
|
42
|
+
const element = getOwnerDocument(activeElement).getElementById(id);
|
|
43
|
+
if (element) {
|
|
44
|
+
return element;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return activeElement;
|
|
49
|
+
}
|
|
50
|
+
function isFrame(element) {
|
|
51
|
+
return element.tagName === "IFRAME";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { canUseDOM, composeEventHandlers, getActiveElement, getOwnerDocument, getOwnerWindow, isFrame };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
3
|
+
|
|
4
|
+
// src/arrow.tsx
|
|
5
|
+
var NAME = "Arrow";
|
|
6
|
+
var Arrow = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
7
|
+
const {
|
|
8
|
+
children,
|
|
9
|
+
width = 10,
|
|
10
|
+
height = 5,
|
|
11
|
+
...arrowProps
|
|
12
|
+
} = props;
|
|
13
|
+
return /* @__PURE__ */React.createElement(Primitive.svg, {
|
|
14
|
+
...arrowProps,
|
|
15
|
+
ref: forwardedRef,
|
|
16
|
+
width,
|
|
17
|
+
height,
|
|
18
|
+
viewBox: "0 0 30 10",
|
|
19
|
+
preserveAspectRatio: "none",
|
|
20
|
+
children: props.asChild ? children : /* @__PURE__ */React.createElement("polygon", {
|
|
21
|
+
points: "0,0 30,0 15,10"
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
Arrow.displayName = NAME;
|
|
26
|
+
var Root = Arrow;
|
|
27
|
+
|
|
28
|
+
export { Arrow, Root };
|
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { createContextScope } from '../../react-context/dist/index.js';
|
|
3
|
+
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
4
|
+
import { createSlot } from '../../react-slot/dist/index.js';
|
|
5
|
+
|
|
6
|
+
"use client";
|
|
7
|
+
|
|
8
|
+
// src/collection-legacy.tsx
|
|
9
|
+
var _keys;
|
|
10
|
+
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
11
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
12
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
13
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
14
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
15
|
+
function createCollection(name) {
|
|
16
|
+
const PROVIDER_NAME = name + "CollectionProvider";
|
|
17
|
+
const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);
|
|
18
|
+
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
|
|
19
|
+
collectionRef: {
|
|
20
|
+
current: null
|
|
21
|
+
},
|
|
22
|
+
itemMap: /* @__PURE__ */new Map()
|
|
23
|
+
});
|
|
24
|
+
const CollectionProvider = props => {
|
|
25
|
+
const {
|
|
26
|
+
scope,
|
|
27
|
+
children
|
|
28
|
+
} = props;
|
|
29
|
+
const ref = React__default.useRef(null);
|
|
30
|
+
const itemMap = React__default.useRef(/* @__PURE__ */new Map()).current;
|
|
31
|
+
return /* @__PURE__ */React__default.createElement(CollectionProviderImpl, {
|
|
32
|
+
scope,
|
|
33
|
+
itemMap,
|
|
34
|
+
collectionRef: ref,
|
|
35
|
+
children
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
CollectionProvider.displayName = PROVIDER_NAME;
|
|
39
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
40
|
+
const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);
|
|
41
|
+
const CollectionSlot = /*#__PURE__*/React__default.forwardRef((props, forwardedRef) => {
|
|
42
|
+
const {
|
|
43
|
+
scope,
|
|
44
|
+
children
|
|
45
|
+
} = props;
|
|
46
|
+
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
47
|
+
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
48
|
+
return /* @__PURE__ */React__default.createElement(CollectionSlotImpl, {
|
|
49
|
+
ref: composedRefs,
|
|
50
|
+
children
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
54
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
55
|
+
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
56
|
+
const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);
|
|
57
|
+
const CollectionItemSlot = /*#__PURE__*/React__default.forwardRef((props, forwardedRef) => {
|
|
58
|
+
const {
|
|
59
|
+
scope,
|
|
60
|
+
children,
|
|
61
|
+
...itemData
|
|
62
|
+
} = props;
|
|
63
|
+
const ref = React__default.useRef(null);
|
|
64
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
65
|
+
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
66
|
+
React__default.useEffect(() => {
|
|
67
|
+
context.itemMap.set(ref, {
|
|
68
|
+
ref,
|
|
69
|
+
...itemData
|
|
70
|
+
});
|
|
71
|
+
return () => void context.itemMap.delete(ref);
|
|
72
|
+
});
|
|
73
|
+
return /* @__PURE__ */React__default.createElement(CollectionItemSlotImpl, {
|
|
74
|
+
...{
|
|
75
|
+
[ITEM_DATA_ATTR]: ""
|
|
76
|
+
},
|
|
77
|
+
ref: composedRefs,
|
|
78
|
+
children
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
82
|
+
function useCollection(scope) {
|
|
83
|
+
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
84
|
+
const getItems = React__default.useCallback(() => {
|
|
85
|
+
const collectionNode = context.collectionRef.current;
|
|
86
|
+
if (!collectionNode) return [];
|
|
87
|
+
const orderedNodes = Array.from(collectionNode.querySelectorAll("[".concat(ITEM_DATA_ATTR, "]")));
|
|
88
|
+
const items = Array.from(context.itemMap.values());
|
|
89
|
+
const orderedItems = items.sort((a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current));
|
|
90
|
+
return orderedItems;
|
|
91
|
+
}, [context.collectionRef, context.itemMap]);
|
|
92
|
+
return getItems;
|
|
93
|
+
}
|
|
94
|
+
return [{
|
|
95
|
+
Provider: CollectionProvider,
|
|
96
|
+
Slot: CollectionSlot,
|
|
97
|
+
ItemSlot: CollectionItemSlot
|
|
98
|
+
}, useCollection, createCollectionScope];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/ordered-dictionary.ts
|
|
102
|
+
var __instanciated = /* @__PURE__ */new WeakMap();
|
|
103
|
+
var OrderedDict = (_keys = /*#__PURE__*/new WeakMap(), class _OrderedDict extends Map {
|
|
104
|
+
constructor(entries) {
|
|
105
|
+
super(entries);
|
|
106
|
+
_classPrivateFieldInitSpec(this, _keys, void 0);
|
|
107
|
+
_classPrivateFieldSet(_keys, this, [...super.keys()]);
|
|
108
|
+
__instanciated.set(this, true);
|
|
109
|
+
}
|
|
110
|
+
set(key, value) {
|
|
111
|
+
if (__instanciated.get(this)) {
|
|
112
|
+
if (this.has(key)) {
|
|
113
|
+
_classPrivateFieldGet(_keys, this)[_classPrivateFieldGet(_keys, this).indexOf(key)] = key;
|
|
114
|
+
} else {
|
|
115
|
+
_classPrivateFieldGet(_keys, this).push(key);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
super.set(key, value);
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
insert(index, key, value) {
|
|
122
|
+
const has = this.has(key);
|
|
123
|
+
const length = _classPrivateFieldGet(_keys, this).length;
|
|
124
|
+
const relativeIndex = toSafeInteger(index);
|
|
125
|
+
let actualIndex = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;
|
|
126
|
+
const safeIndex = actualIndex < 0 || actualIndex >= length ? -1 : actualIndex;
|
|
127
|
+
if (safeIndex === this.size || has && safeIndex === this.size - 1 || safeIndex === -1) {
|
|
128
|
+
this.set(key, value);
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
const size = this.size + (has ? 0 : 1);
|
|
132
|
+
if (relativeIndex < 0) {
|
|
133
|
+
actualIndex++;
|
|
134
|
+
}
|
|
135
|
+
const keys = [..._classPrivateFieldGet(_keys, this)];
|
|
136
|
+
let nextValue;
|
|
137
|
+
let shouldSkip = false;
|
|
138
|
+
for (let i = actualIndex; i < size; i++) {
|
|
139
|
+
if (actualIndex === i) {
|
|
140
|
+
let nextKey = keys[i];
|
|
141
|
+
if (keys[i] === key) {
|
|
142
|
+
nextKey = keys[i + 1];
|
|
143
|
+
}
|
|
144
|
+
if (has) {
|
|
145
|
+
this.delete(key);
|
|
146
|
+
}
|
|
147
|
+
nextValue = this.get(nextKey);
|
|
148
|
+
this.set(key, value);
|
|
149
|
+
} else {
|
|
150
|
+
if (!shouldSkip && keys[i - 1] === key) {
|
|
151
|
+
shouldSkip = true;
|
|
152
|
+
}
|
|
153
|
+
const currentKey = keys[shouldSkip ? i : i - 1];
|
|
154
|
+
const currentValue = nextValue;
|
|
155
|
+
nextValue = this.get(currentKey);
|
|
156
|
+
this.delete(currentKey);
|
|
157
|
+
this.set(currentKey, currentValue);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
with(index, key, value) {
|
|
163
|
+
const copy = new _OrderedDict(this);
|
|
164
|
+
copy.insert(index, key, value);
|
|
165
|
+
return copy;
|
|
166
|
+
}
|
|
167
|
+
before(key) {
|
|
168
|
+
const index = _classPrivateFieldGet(_keys, this).indexOf(key) - 1;
|
|
169
|
+
if (index < 0) {
|
|
170
|
+
return void 0;
|
|
171
|
+
}
|
|
172
|
+
return this.entryAt(index);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Sets a new key-value pair at the position before the given key.
|
|
176
|
+
*/
|
|
177
|
+
setBefore(key, newKey, value) {
|
|
178
|
+
const index = _classPrivateFieldGet(_keys, this).indexOf(key);
|
|
179
|
+
if (index === -1) {
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
return this.insert(index, newKey, value);
|
|
183
|
+
}
|
|
184
|
+
after(key) {
|
|
185
|
+
let index = _classPrivateFieldGet(_keys, this).indexOf(key);
|
|
186
|
+
index = index === -1 || index === this.size - 1 ? -1 : index + 1;
|
|
187
|
+
if (index === -1) {
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
return this.entryAt(index);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Sets a new key-value pair at the position after the given key.
|
|
194
|
+
*/
|
|
195
|
+
setAfter(key, newKey, value) {
|
|
196
|
+
const index = _classPrivateFieldGet(_keys, this).indexOf(key);
|
|
197
|
+
if (index === -1) {
|
|
198
|
+
return this;
|
|
199
|
+
}
|
|
200
|
+
return this.insert(index + 1, newKey, value);
|
|
201
|
+
}
|
|
202
|
+
first() {
|
|
203
|
+
return this.entryAt(0);
|
|
204
|
+
}
|
|
205
|
+
last() {
|
|
206
|
+
return this.entryAt(-1);
|
|
207
|
+
}
|
|
208
|
+
clear() {
|
|
209
|
+
_classPrivateFieldSet(_keys, this, []);
|
|
210
|
+
return super.clear();
|
|
211
|
+
}
|
|
212
|
+
delete(key) {
|
|
213
|
+
const deleted = super.delete(key);
|
|
214
|
+
if (deleted) {
|
|
215
|
+
_classPrivateFieldGet(_keys, this).splice(_classPrivateFieldGet(_keys, this).indexOf(key), 1);
|
|
216
|
+
}
|
|
217
|
+
return deleted;
|
|
218
|
+
}
|
|
219
|
+
deleteAt(index) {
|
|
220
|
+
const key = this.keyAt(index);
|
|
221
|
+
if (key !== void 0) {
|
|
222
|
+
return this.delete(key);
|
|
223
|
+
}
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
at(index) {
|
|
227
|
+
const key = at(_classPrivateFieldGet(_keys, this), index);
|
|
228
|
+
if (key !== void 0) {
|
|
229
|
+
return this.get(key);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
entryAt(index) {
|
|
233
|
+
const key = at(_classPrivateFieldGet(_keys, this), index);
|
|
234
|
+
if (key !== void 0) {
|
|
235
|
+
return [key, this.get(key)];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
indexOf(key) {
|
|
239
|
+
return _classPrivateFieldGet(_keys, this).indexOf(key);
|
|
240
|
+
}
|
|
241
|
+
keyAt(index) {
|
|
242
|
+
return at(_classPrivateFieldGet(_keys, this), index);
|
|
243
|
+
}
|
|
244
|
+
from(key, offset) {
|
|
245
|
+
const index = this.indexOf(key);
|
|
246
|
+
if (index === -1) {
|
|
247
|
+
return void 0;
|
|
248
|
+
}
|
|
249
|
+
let dest = index + offset;
|
|
250
|
+
if (dest < 0) dest = 0;
|
|
251
|
+
if (dest >= this.size) dest = this.size - 1;
|
|
252
|
+
return this.at(dest);
|
|
253
|
+
}
|
|
254
|
+
keyFrom(key, offset) {
|
|
255
|
+
const index = this.indexOf(key);
|
|
256
|
+
if (index === -1) {
|
|
257
|
+
return void 0;
|
|
258
|
+
}
|
|
259
|
+
let dest = index + offset;
|
|
260
|
+
if (dest < 0) dest = 0;
|
|
261
|
+
if (dest >= this.size) dest = this.size - 1;
|
|
262
|
+
return this.keyAt(dest);
|
|
263
|
+
}
|
|
264
|
+
find(predicate, thisArg) {
|
|
265
|
+
let index = 0;
|
|
266
|
+
for (const entry of this) {
|
|
267
|
+
if (Reflect.apply(predicate, thisArg, [entry, index, this])) {
|
|
268
|
+
return entry;
|
|
269
|
+
}
|
|
270
|
+
index++;
|
|
271
|
+
}
|
|
272
|
+
return void 0;
|
|
273
|
+
}
|
|
274
|
+
findIndex(predicate, thisArg) {
|
|
275
|
+
let index = 0;
|
|
276
|
+
for (const entry of this) {
|
|
277
|
+
if (Reflect.apply(predicate, thisArg, [entry, index, this])) {
|
|
278
|
+
return index;
|
|
279
|
+
}
|
|
280
|
+
index++;
|
|
281
|
+
}
|
|
282
|
+
return -1;
|
|
283
|
+
}
|
|
284
|
+
filter(predicate, thisArg) {
|
|
285
|
+
const entries = [];
|
|
286
|
+
let index = 0;
|
|
287
|
+
for (const entry of this) {
|
|
288
|
+
if (Reflect.apply(predicate, thisArg, [entry, index, this])) {
|
|
289
|
+
entries.push(entry);
|
|
290
|
+
}
|
|
291
|
+
index++;
|
|
292
|
+
}
|
|
293
|
+
return new _OrderedDict(entries);
|
|
294
|
+
}
|
|
295
|
+
map(callbackfn, thisArg) {
|
|
296
|
+
const entries = [];
|
|
297
|
+
let index = 0;
|
|
298
|
+
for (const entry of this) {
|
|
299
|
+
entries.push([entry[0], Reflect.apply(callbackfn, thisArg, [entry, index, this])]);
|
|
300
|
+
index++;
|
|
301
|
+
}
|
|
302
|
+
return new _OrderedDict(entries);
|
|
303
|
+
}
|
|
304
|
+
reduce() {
|
|
305
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
306
|
+
args[_key] = arguments[_key];
|
|
307
|
+
}
|
|
308
|
+
const [callbackfn, initialValue] = args;
|
|
309
|
+
let index = 0;
|
|
310
|
+
let accumulator = initialValue !== null && initialValue !== void 0 ? initialValue : this.at(0);
|
|
311
|
+
for (const entry of this) {
|
|
312
|
+
if (index === 0 && args.length === 1) {
|
|
313
|
+
accumulator = entry;
|
|
314
|
+
} else {
|
|
315
|
+
accumulator = Reflect.apply(callbackfn, this, [accumulator, entry, index, this]);
|
|
316
|
+
}
|
|
317
|
+
index++;
|
|
318
|
+
}
|
|
319
|
+
return accumulator;
|
|
320
|
+
}
|
|
321
|
+
reduceRight() {
|
|
322
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
323
|
+
args[_key2] = arguments[_key2];
|
|
324
|
+
}
|
|
325
|
+
const [callbackfn, initialValue] = args;
|
|
326
|
+
let accumulator = initialValue !== null && initialValue !== void 0 ? initialValue : this.at(-1);
|
|
327
|
+
for (let index = this.size - 1; index >= 0; index--) {
|
|
328
|
+
const entry = this.at(index);
|
|
329
|
+
if (index === this.size - 1 && args.length === 1) {
|
|
330
|
+
accumulator = entry;
|
|
331
|
+
} else {
|
|
332
|
+
accumulator = Reflect.apply(callbackfn, this, [accumulator, entry, index, this]);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return accumulator;
|
|
336
|
+
}
|
|
337
|
+
toSorted(compareFn) {
|
|
338
|
+
const entries = [...this.entries()].sort(compareFn);
|
|
339
|
+
return new _OrderedDict(entries);
|
|
340
|
+
}
|
|
341
|
+
toReversed() {
|
|
342
|
+
const reversed = new _OrderedDict();
|
|
343
|
+
for (let index = this.size - 1; index >= 0; index--) {
|
|
344
|
+
const key = this.keyAt(index);
|
|
345
|
+
const element = this.get(key);
|
|
346
|
+
reversed.set(key, element);
|
|
347
|
+
}
|
|
348
|
+
return reversed;
|
|
349
|
+
}
|
|
350
|
+
toSpliced() {
|
|
351
|
+
const entries = [...this.entries()];
|
|
352
|
+
entries.splice(...arguments);
|
|
353
|
+
return new _OrderedDict(entries);
|
|
354
|
+
}
|
|
355
|
+
slice(start, end) {
|
|
356
|
+
const result = new _OrderedDict();
|
|
357
|
+
let stop = this.size - 1;
|
|
358
|
+
if (start === void 0) {
|
|
359
|
+
return result;
|
|
360
|
+
}
|
|
361
|
+
if (start < 0) {
|
|
362
|
+
start = start + this.size;
|
|
363
|
+
}
|
|
364
|
+
if (end !== void 0 && end > 0) {
|
|
365
|
+
stop = end - 1;
|
|
366
|
+
}
|
|
367
|
+
for (let index = start; index <= stop; index++) {
|
|
368
|
+
const key = this.keyAt(index);
|
|
369
|
+
const element = this.get(key);
|
|
370
|
+
result.set(key, element);
|
|
371
|
+
}
|
|
372
|
+
return result;
|
|
373
|
+
}
|
|
374
|
+
every(predicate, thisArg) {
|
|
375
|
+
let index = 0;
|
|
376
|
+
for (const entry of this) {
|
|
377
|
+
if (!Reflect.apply(predicate, thisArg, [entry, index, this])) {
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
index++;
|
|
381
|
+
}
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
some(predicate, thisArg) {
|
|
385
|
+
let index = 0;
|
|
386
|
+
for (const entry of this) {
|
|
387
|
+
if (Reflect.apply(predicate, thisArg, [entry, index, this])) {
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
index++;
|
|
391
|
+
}
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
function at(array, index) {
|
|
396
|
+
if ("at" in Array.prototype) {
|
|
397
|
+
return Array.prototype.at.call(array, index);
|
|
398
|
+
}
|
|
399
|
+
const actualIndex = toSafeIndex(array, index);
|
|
400
|
+
return actualIndex === -1 ? void 0 : array[actualIndex];
|
|
401
|
+
}
|
|
402
|
+
function toSafeIndex(array, index) {
|
|
403
|
+
const length = array.length;
|
|
404
|
+
const relativeIndex = toSafeInteger(index);
|
|
405
|
+
const actualIndex = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;
|
|
406
|
+
return actualIndex < 0 || actualIndex >= length ? -1 : actualIndex;
|
|
407
|
+
}
|
|
408
|
+
function toSafeInteger(number) {
|
|
409
|
+
return number !== number || number === 0 ? 0 : Math.trunc(number);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// src/collection.tsx
|
|
413
|
+
|
|
414
|
+
function createCollection2(name) {
|
|
415
|
+
const PROVIDER_NAME = name + "CollectionProvider";
|
|
416
|
+
const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);
|
|
417
|
+
const [CollectionContextProvider, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
|
|
418
|
+
collectionElement: null,
|
|
419
|
+
collectionRef: {
|
|
420
|
+
current: null
|
|
421
|
+
},
|
|
422
|
+
collectionRefObject: {
|
|
423
|
+
current: null
|
|
424
|
+
},
|
|
425
|
+
itemMap: new OrderedDict(),
|
|
426
|
+
setItemMap: () => void 0
|
|
427
|
+
});
|
|
428
|
+
const CollectionProvider = _ref => {
|
|
429
|
+
let {
|
|
430
|
+
state,
|
|
431
|
+
...props
|
|
432
|
+
} = _ref;
|
|
433
|
+
return state ? /* @__PURE__ */React__default.createElement(CollectionProviderImpl, {
|
|
434
|
+
...props,
|
|
435
|
+
state
|
|
436
|
+
}) : /* @__PURE__ */React__default.createElement(CollectionInit, {
|
|
437
|
+
...props
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
CollectionProvider.displayName = PROVIDER_NAME;
|
|
441
|
+
const CollectionInit = props => {
|
|
442
|
+
const state = useInitCollection();
|
|
443
|
+
return /* @__PURE__ */React__default.createElement(CollectionProviderImpl, {
|
|
444
|
+
...props,
|
|
445
|
+
state
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
CollectionInit.displayName = PROVIDER_NAME + "Init";
|
|
449
|
+
const CollectionProviderImpl = props => {
|
|
450
|
+
const {
|
|
451
|
+
scope,
|
|
452
|
+
children,
|
|
453
|
+
state
|
|
454
|
+
} = props;
|
|
455
|
+
const ref = React__default.useRef(null);
|
|
456
|
+
const [collectionElement, setCollectionElement] = React__default.useState(null);
|
|
457
|
+
const composeRefs = useComposedRefs(ref, setCollectionElement);
|
|
458
|
+
const [itemMap, setItemMap] = state;
|
|
459
|
+
React__default.useEffect(() => {
|
|
460
|
+
if (!collectionElement) return;
|
|
461
|
+
const observer = getChildListObserver(() => {});
|
|
462
|
+
observer.observe(collectionElement, {
|
|
463
|
+
childList: true,
|
|
464
|
+
subtree: true
|
|
465
|
+
});
|
|
466
|
+
return () => {
|
|
467
|
+
observer.disconnect();
|
|
468
|
+
};
|
|
469
|
+
}, [collectionElement]);
|
|
470
|
+
return /* @__PURE__ */React__default.createElement(CollectionContextProvider, {
|
|
471
|
+
scope,
|
|
472
|
+
itemMap,
|
|
473
|
+
setItemMap,
|
|
474
|
+
collectionRef: composeRefs,
|
|
475
|
+
collectionRefObject: ref,
|
|
476
|
+
collectionElement,
|
|
477
|
+
children
|
|
478
|
+
});
|
|
479
|
+
};
|
|
480
|
+
CollectionProviderImpl.displayName = PROVIDER_NAME + "Impl";
|
|
481
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
482
|
+
const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);
|
|
483
|
+
const CollectionSlot = /*#__PURE__*/React__default.forwardRef((props, forwardedRef) => {
|
|
484
|
+
const {
|
|
485
|
+
scope,
|
|
486
|
+
children
|
|
487
|
+
} = props;
|
|
488
|
+
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
489
|
+
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
490
|
+
return /* @__PURE__ */React__default.createElement(CollectionSlotImpl, {
|
|
491
|
+
ref: composedRefs,
|
|
492
|
+
children
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
496
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
497
|
+
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
498
|
+
const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);
|
|
499
|
+
const CollectionItemSlot = /*#__PURE__*/React__default.forwardRef((props, forwardedRef) => {
|
|
500
|
+
const {
|
|
501
|
+
scope,
|
|
502
|
+
children,
|
|
503
|
+
...itemData
|
|
504
|
+
} = props;
|
|
505
|
+
const ref = React__default.useRef(null);
|
|
506
|
+
const [element, setElement] = React__default.useState(null);
|
|
507
|
+
const composedRefs = useComposedRefs(forwardedRef, ref, setElement);
|
|
508
|
+
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
509
|
+
const {
|
|
510
|
+
setItemMap
|
|
511
|
+
} = context;
|
|
512
|
+
const itemDataRef = React__default.useRef(itemData);
|
|
513
|
+
if (!shallowEqual(itemDataRef.current, itemData)) {
|
|
514
|
+
itemDataRef.current = itemData;
|
|
515
|
+
}
|
|
516
|
+
const memoizedItemData = itemDataRef.current;
|
|
517
|
+
React__default.useEffect(() => {
|
|
518
|
+
const itemData2 = memoizedItemData;
|
|
519
|
+
setItemMap(map => {
|
|
520
|
+
if (!element) {
|
|
521
|
+
return map;
|
|
522
|
+
}
|
|
523
|
+
if (!map.has(element)) {
|
|
524
|
+
map.set(element, {
|
|
525
|
+
...itemData2,
|
|
526
|
+
element
|
|
527
|
+
});
|
|
528
|
+
return map.toSorted(sortByDocumentPosition);
|
|
529
|
+
}
|
|
530
|
+
return map.set(element, {
|
|
531
|
+
...itemData2,
|
|
532
|
+
element
|
|
533
|
+
}).toSorted(sortByDocumentPosition);
|
|
534
|
+
});
|
|
535
|
+
return () => {
|
|
536
|
+
setItemMap(map => {
|
|
537
|
+
if (!element || !map.has(element)) {
|
|
538
|
+
return map;
|
|
539
|
+
}
|
|
540
|
+
map.delete(element);
|
|
541
|
+
return new OrderedDict(map);
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
}, [element, memoizedItemData, setItemMap]);
|
|
545
|
+
return /* @__PURE__ */React__default.createElement(CollectionItemSlotImpl, {
|
|
546
|
+
...{
|
|
547
|
+
[ITEM_DATA_ATTR]: ""
|
|
548
|
+
},
|
|
549
|
+
ref: composedRefs,
|
|
550
|
+
children
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
554
|
+
function useInitCollection() {
|
|
555
|
+
return React__default.useState(new OrderedDict());
|
|
556
|
+
}
|
|
557
|
+
function useCollection(scope) {
|
|
558
|
+
const {
|
|
559
|
+
itemMap
|
|
560
|
+
} = useCollectionContext(name + "CollectionConsumer", scope);
|
|
561
|
+
return itemMap;
|
|
562
|
+
}
|
|
563
|
+
const functions = {
|
|
564
|
+
createCollectionScope,
|
|
565
|
+
useCollection,
|
|
566
|
+
useInitCollection
|
|
567
|
+
};
|
|
568
|
+
return [{
|
|
569
|
+
Provider: CollectionProvider,
|
|
570
|
+
Slot: CollectionSlot,
|
|
571
|
+
ItemSlot: CollectionItemSlot
|
|
572
|
+
}, functions];
|
|
573
|
+
}
|
|
574
|
+
function shallowEqual(a, b) {
|
|
575
|
+
if (a === b) return true;
|
|
576
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
577
|
+
if (a == null || b == null) return false;
|
|
578
|
+
const keysA = Object.keys(a);
|
|
579
|
+
const keysB = Object.keys(b);
|
|
580
|
+
if (keysA.length !== keysB.length) return false;
|
|
581
|
+
for (const key of keysA) {
|
|
582
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
583
|
+
if (a[key] !== b[key]) return false;
|
|
584
|
+
}
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
function isElementPreceding(a, b) {
|
|
588
|
+
return !!(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
589
|
+
}
|
|
590
|
+
function sortByDocumentPosition(a, b) {
|
|
591
|
+
return !a[1].element || !b[1].element ? 0 : isElementPreceding(a[1].element, b[1].element) ? -1 : 1;
|
|
592
|
+
}
|
|
593
|
+
function getChildListObserver(callback) {
|
|
594
|
+
const observer = new MutationObserver(mutationsList => {
|
|
595
|
+
for (const mutation of mutationsList) {
|
|
596
|
+
if (mutation.type === "childList") {
|
|
597
|
+
callback();
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
return observer;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
export { createCollection, createCollection2 as unstable_createCollection };
|