@octanejs/base-ui 0.1.31 → 0.1.33
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/dist/cjs/accordion.cjs +497 -0
- package/dist/cjs/alert-dialog.cjs +65 -0
- package/dist/cjs/avatar.cjs +234 -0
- package/dist/cjs/button.cjs +54 -0
- package/dist/cjs/checkbox-group.cjs +165 -0
- package/dist/cjs/checkbox.cjs +475 -0
- package/dist/cjs/collapsible.cjs +700 -0
- package/dist/cjs/context-menu.cjs +257 -0
- package/dist/cjs/csp-provider.cjs +40 -0
- package/dist/cjs/dialog.cjs +741 -0
- package/dist/cjs/direction-provider.cjs +35 -0
- package/dist/cjs/field.cjs +559 -0
- package/dist/cjs/fieldset.cjs +101 -0
- package/dist/cjs/form.cjs +177 -0
- package/dist/cjs/index.cjs +133 -0
- package/dist/cjs/input.cjs +32 -0
- package/dist/cjs/internal.cjs +51 -0
- package/dist/cjs/menu.cjs +2420 -0
- package/dist/cjs/menubar.cjs +132 -0
- package/dist/cjs/merge-props.cjs +34 -0
- package/dist/cjs/meter.cjs +169 -0
- package/dist/cjs/number-field.cjs +812 -0
- package/dist/cjs/popover.cjs +966 -0
- package/dist/cjs/preview-card.cjs +632 -0
- package/dist/cjs/progress.cjs +206 -0
- package/dist/cjs/radio-group.cjs +264 -0
- package/dist/cjs/radio.cjs +327 -0
- package/dist/cjs/separator.cjs +44 -0
- package/dist/cjs/slider.cjs +1384 -0
- package/dist/cjs/switch.cjs +306 -0
- package/dist/cjs/tabs.cjs +727 -0
- package/dist/cjs/toast.cjs +1766 -0
- package/dist/cjs/toggle-group.cjs +118 -0
- package/dist/cjs/toggle.cjs +121 -0
- package/dist/cjs/tooltip.cjs +835 -0
- package/dist/cjs/unstable-use-media-query.cjs +79 -0
- package/dist/cjs/use-render.cjs +40 -0
- package/dist/cjs/utils/CSPContext.cjs +38 -0
- package/dist/cjs/utils/CheckboxGroupContext.cjs +40 -0
- package/dist/cjs/utils/CompositeRootContext.cjs +40 -0
- package/dist/cjs/utils/ContextMenuRootContext.cjs +42 -0
- package/dist/cjs/utils/DirectionContext.cjs +34 -0
- package/dist/cjs/utils/FloatingPortalLite.cjs +47 -0
- package/dist/cjs/utils/InternalBackdrop.cjs +49 -0
- package/dist/cjs/utils/MenubarContext.cjs +40 -0
- package/dist/cjs/utils/RadioGroupContext.cjs +34 -0
- package/dist/cjs/utils/RequestQueue.cjs +111 -0
- package/dist/cjs/utils/TimeoutManager.cjs +50 -0
- package/dist/cjs/utils/ToggleGroupContext.cjs +40 -0
- package/dist/cjs/utils/adaptiveOriginMiddleware.cjs +94 -0
- package/dist/cjs/utils/addEventListener.cjs +33 -0
- package/dist/cjs/utils/areArraysEqual.cjs +30 -0
- package/dist/cjs/utils/clamp.cjs +30 -0
- package/dist/cjs/utils/closePart.cjs +70 -0
- package/dist/cjs/utils/collapsibleOpenStateMapping.cjs +42 -0
- package/dist/cjs/utils/composeRefs.cjs +68 -0
- package/dist/cjs/utils/composite/CompositeItem.cjs +59 -0
- package/dist/cjs/utils/composite/CompositeList.cjs +177 -0
- package/dist/cjs/utils/composite/CompositeListContext.cjs +43 -0
- package/dist/cjs/utils/composite/CompositeRoot.cjs +118 -0
- package/dist/cjs/utils/composite/grid-utils.cjs +343 -0
- package/dist/cjs/utils/composite/gridNavigation.cjs +92 -0
- package/dist/cjs/utils/composite/keys.cjs +174 -0
- package/dist/cjs/utils/composite/list-utils.cjs +90 -0
- package/dist/cjs/utils/composite/useCompositeItem.cjs +63 -0
- package/dist/cjs/utils/composite/useCompositeListItem.cjs +104 -0
- package/dist/cjs/utils/composite/useCompositeRoot.cjs +263 -0
- package/dist/cjs/utils/constants.cjs +56 -0
- package/dist/cjs/utils/contains.cjs +46 -0
- package/dist/cjs/utils/createChangeEventDetails.cjs +92 -0
- package/dist/cjs/utils/dom.cjs +35 -0
- package/dist/cjs/utils/empty.cjs +34 -0
- package/dist/cjs/utils/field/FieldItemContext.cjs +34 -0
- package/dist/cjs/utils/field/FieldRootContext.cjs +80 -0
- package/dist/cjs/utils/field/FormContext.cjs +41 -0
- package/dist/cjs/utils/field/LabelableContext.cjs +43 -0
- package/dist/cjs/utils/field/LabelableProvider.cjs +115 -0
- package/dist/cjs/utils/field/constants.cjs +68 -0
- package/dist/cjs/utils/field/getCombinedFieldValidityData.cjs +36 -0
- package/dist/cjs/utils/field/useAriaLabelledBy.cjs +87 -0
- package/dist/cjs/utils/field/useFieldControlRegistration.cjs +165 -0
- package/dist/cjs/utils/field/useFieldValidation.cjs +285 -0
- package/dist/cjs/utils/field/useLabel.cjs +99 -0
- package/dist/cjs/utils/field/useLabelableId.cjs +105 -0
- package/dist/cjs/utils/field/useRegisterFieldControl.cjs +60 -0
- package/dist/cjs/utils/findRootOwnerId.cjs +37 -0
- package/dist/cjs/utils/floating/FloatingDelayGroup.cjs +219 -0
- package/dist/cjs/utils/floating/FloatingFocusManager.cjs +685 -0
- package/dist/cjs/utils/floating/FloatingPortal.cjs +230 -0
- package/dist/cjs/utils/floating/FloatingRootStore.cjs +87 -0
- package/dist/cjs/utils/floating/FloatingTree.cjs +86 -0
- package/dist/cjs/utils/floating/FloatingTreeStore.cjs +41 -0
- package/dist/cjs/utils/floating/FocusGuard.cjs +54 -0
- package/dist/cjs/utils/floating/composite.cjs +42 -0
- package/dist/cjs/utils/floating/constants.cjs +34 -0
- package/dist/cjs/utils/floating/createAttribute.cjs +30 -0
- package/dist/cjs/utils/floating/createEventEmitter.cjs +44 -0
- package/dist/cjs/utils/floating/element.cjs +103 -0
- package/dist/cjs/utils/floating/enqueueFocus.cjs +51 -0
- package/dist/cjs/utils/floating/event.cjs +65 -0
- package/dist/cjs/utils/floating/getEmptyRootContext.cjs +42 -0
- package/dist/cjs/utils/floating/gridNavigation.cjs +45 -0
- package/dist/cjs/utils/floating/markOthers.cjs +181 -0
- package/dist/cjs/utils/floating/nodes.cjs +48 -0
- package/dist/cjs/utils/floating/safePolygon.cjs +301 -0
- package/dist/cjs/utils/floating/tabbable.cjs +242 -0
- package/dist/cjs/utils/floating/types.cjs +16 -0
- package/dist/cjs/utils/floating/useClick.cjs +153 -0
- package/dist/cjs/utils/floating/useClientPoint.cjs +225 -0
- package/dist/cjs/utils/floating/useDismiss.cjs +506 -0
- package/dist/cjs/utils/floating/useFloating.cjs +186 -0
- package/dist/cjs/utils/floating/useFloatingRootContext.cjs +75 -0
- package/dist/cjs/utils/floating/useFocus.cjs +184 -0
- package/dist/cjs/utils/floating/useHoverFloatingInteraction.cjs +231 -0
- package/dist/cjs/utils/floating/useHoverInteractionSharedState.cjs +113 -0
- package/dist/cjs/utils/floating/useHoverReferenceInteraction.cjs +380 -0
- package/dist/cjs/utils/floating/useHoverShared.cjs +65 -0
- package/dist/cjs/utils/floating/useListNavigation.cjs +665 -0
- package/dist/cjs/utils/floating/useSyncedFloatingRootContext.cjs +91 -0
- package/dist/cjs/utils/floating/useTypeahead.cjs +187 -0
- package/dist/cjs/utils/formatNumber.cjs +60 -0
- package/dist/cjs/utils/generateId.cjs +32 -0
- package/dist/cjs/utils/getCssDimensions.cjs +42 -0
- package/dist/cjs/utils/getDefaultFormSubmitter.cjs +42 -0
- package/dist/cjs/utils/getDisabledMountTransitionStyles.cjs +32 -0
- package/dist/cjs/utils/getElementRef.cjs +35 -0
- package/dist/cjs/utils/getPseudoElementBounds.cjs +56 -0
- package/dist/cjs/utils/getStateAttributesProps.cjs +46 -0
- package/dist/cjs/utils/hideMiddleware.cjs +42 -0
- package/dist/cjs/utils/inertValue.cjs +30 -0
- package/dist/cjs/utils/matchesFocusVisible.cjs +38 -0
- package/dist/cjs/utils/mergeCleanups.cjs +37 -0
- package/dist/cjs/utils/mergeObjects.cjs +39 -0
- package/dist/cjs/utils/mergeProps.cjs +182 -0
- package/dist/cjs/utils/noop.cjs +29 -0
- package/dist/cjs/utils/number/constants.cjs +34 -0
- package/dist/cjs/utils/number/parse.cjs +258 -0
- package/dist/cjs/utils/number/types.cjs +16 -0
- package/dist/cjs/utils/number/validate.cjs +104 -0
- package/dist/cjs/utils/owner.cjs +35 -0
- package/dist/cjs/utils/platform.cjs +83 -0
- package/dist/cjs/utils/popupStateMapping.cjs +74 -0
- package/dist/cjs/utils/popups/index.cjs +39 -0
- package/dist/cjs/utils/popups/inlineRect.cjs +218 -0
- package/dist/cjs/utils/popups/popupStoreUtils.cjs +379 -0
- package/dist/cjs/utils/popups/popupTriggerMap.cjs +76 -0
- package/dist/cjs/utils/popups/store.cjs +118 -0
- package/dist/cjs/utils/popups/useTriggerFocusGuards.cjs +72 -0
- package/dist/cjs/utils/resolveAriaLabelledBy.cjs +35 -0
- package/dist/cjs/utils/resolveClassName.cjs +30 -0
- package/dist/cjs/utils/resolveRef.cjs +33 -0
- package/dist/cjs/utils/resolveStyle.cjs +30 -0
- package/dist/cjs/utils/serializeValue.cjs +40 -0
- package/dist/cjs/utils/slider/asc.cjs +30 -0
- package/dist/cjs/utils/slider/getMidpoint.cjs +34 -0
- package/dist/cjs/utils/slider/getPushedThumbValues.cjs +73 -0
- package/dist/cjs/utils/slider/getSliderValue.cjs +42 -0
- package/dist/cjs/utils/slider/replaceArrayItemAtIndex.cjs +33 -0
- package/dist/cjs/utils/slider/resolveThumbCollision.cjs +155 -0
- package/dist/cjs/utils/slider/roundValueToStep.cjs +45 -0
- package/dist/cjs/utils/slider/validateMinimumDistance.cjs +40 -0
- package/dist/cjs/utils/slider/valueArrayToPercentages.cjs +36 -0
- package/dist/cjs/utils/store/ReactStore.cjs +135 -0
- package/dist/cjs/utils/store/Store.cjs +83 -0
- package/dist/cjs/utils/store/createSelector.cjs +74 -0
- package/dist/cjs/utils/store/useStore.cjs +51 -0
- package/dist/cjs/utils/stringifyLocale.cjs +36 -0
- package/dist/cjs/utils/useAnchorPositioning.cjs +421 -0
- package/dist/cjs/utils/useAnchoredPopupScrollLock.cjs +59 -0
- package/dist/cjs/utils/useAnimationFrame.cjs +93 -0
- package/dist/cjs/utils/useAnimationsFinished.cjs +98 -0
- package/dist/cjs/utils/useBaseUiId.cjs +36 -0
- package/dist/cjs/utils/useButton.cjs +177 -0
- package/dist/cjs/utils/useCheckboxGroupParent.cjs +114 -0
- package/dist/cjs/utils/useControlled.cjs +47 -0
- package/dist/cjs/utils/useEnhancedClickHandler.cjs +60 -0
- package/dist/cjs/utils/useFocusableWhenDisabled.cjs +77 -0
- package/dist/cjs/utils/useForcedRerendering.cjs +35 -0
- package/dist/cjs/utils/useIsHydrating.cjs +44 -0
- package/dist/cjs/utils/useMixedToggleClickHandler.cjs +66 -0
- package/dist/cjs/utils/useOnFirstRender.cjs +35 -0
- package/dist/cjs/utils/useOnMount.cjs +36 -0
- package/dist/cjs/utils/useOpenChangeComplete.cjs +57 -0
- package/dist/cjs/utils/useOpenInteractionType.cjs +69 -0
- package/dist/cjs/utils/usePopupAutoResize.cjs +191 -0
- package/dist/cjs/utils/usePopupViewport.cjs +283 -0
- package/dist/cjs/utils/usePositioner.cjs +53 -0
- package/dist/cjs/utils/usePressAndHold.cjs +51 -0
- package/dist/cjs/utils/usePreviousValue.cjs +47 -0
- package/dist/cjs/utils/useRefWithInit.cjs +41 -0
- package/dist/cjs/utils/useRegisteredLabelId.cjs +48 -0
- package/dist/cjs/utils/useRenderElement.cjs +106 -0
- package/dist/cjs/utils/useScrollLock.cjs +232 -0
- package/dist/cjs/utils/useStableCallback.cjs +41 -0
- package/dist/cjs/utils/useTimeout.cjs +66 -0
- package/dist/cjs/utils/useTransitionStatus.cjs +116 -0
- package/dist/cjs/utils/useValueAsRef.cjs +43 -0
- package/dist/cjs/utils/useValueChanged.cjs +55 -0
- package/dist/cjs/utils/valueToPercent.cjs +30 -0
- package/dist/cjs/utils/visuallyHidden.cjs +49 -0
- package/package.json +20 -8
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ToggleGroupContext_exports = {};
|
|
20
|
+
__export(ToggleGroupContext_exports, {
|
|
21
|
+
ToggleGroupContext: () => ToggleGroupContext,
|
|
22
|
+
useToggleGroupContext: () => useToggleGroupContext
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ToggleGroupContext_exports);
|
|
25
|
+
var import_octane = require("octane");
|
|
26
|
+
const ToggleGroupContext = (0, import_octane.createContext)(void 0);
|
|
27
|
+
function useToggleGroupContext(optional = true) {
|
|
28
|
+
const context = (0, import_octane.useContext)(ToggleGroupContext);
|
|
29
|
+
if (context === void 0 && !optional) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
"Base UI: ToggleGroupContext is missing. ToggleGroup parts must be placed within <ToggleGroup>."
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return context;
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
ToggleGroupContext,
|
|
39
|
+
useToggleGroupContext
|
|
40
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var adaptiveOriginMiddleware_exports = {};
|
|
20
|
+
__export(adaptiveOriginMiddleware_exports, {
|
|
21
|
+
DEFAULT_SIDES: () => DEFAULT_SIDES,
|
|
22
|
+
adaptiveOrigin: () => adaptiveOrigin
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(adaptiveOriginMiddleware_exports);
|
|
25
|
+
var import_utils = require("@floating-ui/utils");
|
|
26
|
+
var import_owner = require("./owner.cjs");
|
|
27
|
+
const DEFAULT_SIDES = {
|
|
28
|
+
sideX: "left",
|
|
29
|
+
sideY: "top"
|
|
30
|
+
};
|
|
31
|
+
const adaptiveOrigin = {
|
|
32
|
+
name: "adaptiveOrigin",
|
|
33
|
+
async fn(state) {
|
|
34
|
+
const {
|
|
35
|
+
x: rawX,
|
|
36
|
+
y: rawY,
|
|
37
|
+
rects: { floating: floatRect },
|
|
38
|
+
elements: { floating },
|
|
39
|
+
platform,
|
|
40
|
+
strategy,
|
|
41
|
+
placement
|
|
42
|
+
} = state;
|
|
43
|
+
const win = (0, import_owner.ownerWindow)(floating);
|
|
44
|
+
const styles = win.getComputedStyle(floating);
|
|
45
|
+
const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
|
|
46
|
+
if (!hasTransition) {
|
|
47
|
+
return {
|
|
48
|
+
x: rawX,
|
|
49
|
+
y: rawY,
|
|
50
|
+
data: DEFAULT_SIDES
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const offsetParent = await platform.getOffsetParent?.(floating);
|
|
54
|
+
let offsetDimensions = { width: 0, height: 0 };
|
|
55
|
+
if (strategy === "fixed" && win?.visualViewport) {
|
|
56
|
+
offsetDimensions = {
|
|
57
|
+
width: win.visualViewport.width,
|
|
58
|
+
height: win.visualViewport.height
|
|
59
|
+
};
|
|
60
|
+
} else if (offsetParent === win) {
|
|
61
|
+
const doc = (0, import_owner.ownerDocument)(floating);
|
|
62
|
+
offsetDimensions = {
|
|
63
|
+
width: doc.documentElement.clientWidth,
|
|
64
|
+
height: doc.documentElement.clientHeight
|
|
65
|
+
};
|
|
66
|
+
} else if (await platform.isElement?.(offsetParent)) {
|
|
67
|
+
offsetDimensions = await platform.getDimensions(offsetParent);
|
|
68
|
+
}
|
|
69
|
+
const currentSide = (0, import_utils.getSide)(placement);
|
|
70
|
+
let x = rawX;
|
|
71
|
+
let y = rawY;
|
|
72
|
+
if (currentSide === "left") {
|
|
73
|
+
x = offsetDimensions.width - (rawX + floatRect.width);
|
|
74
|
+
}
|
|
75
|
+
if (currentSide === "top") {
|
|
76
|
+
y = offsetDimensions.height - (rawY + floatRect.height);
|
|
77
|
+
}
|
|
78
|
+
const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
|
|
79
|
+
const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
|
|
80
|
+
return {
|
|
81
|
+
x,
|
|
82
|
+
y,
|
|
83
|
+
data: {
|
|
84
|
+
sideX,
|
|
85
|
+
sideY
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
DEFAULT_SIDES,
|
|
93
|
+
adaptiveOrigin
|
|
94
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var addEventListener_exports = {};
|
|
20
|
+
__export(addEventListener_exports, {
|
|
21
|
+
addEventListener: () => addEventListener
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(addEventListener_exports);
|
|
24
|
+
function addEventListener(target, type, listener, options) {
|
|
25
|
+
target.addEventListener(type, listener, options);
|
|
26
|
+
return () => {
|
|
27
|
+
target.removeEventListener(type, listener, options);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
addEventListener
|
|
33
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var areArraysEqual_exports = {};
|
|
20
|
+
__export(areArraysEqual_exports, {
|
|
21
|
+
areArraysEqual: () => areArraysEqual
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(areArraysEqual_exports);
|
|
24
|
+
function areArraysEqual(array1, array2, itemComparer = (a, b) => a === b) {
|
|
25
|
+
return array1.length === array2.length && array1.every((value, index) => itemComparer(value, array2[index]));
|
|
26
|
+
}
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
areArraysEqual
|
|
30
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var clamp_exports = {};
|
|
20
|
+
__export(clamp_exports, {
|
|
21
|
+
clamp: () => clamp
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(clamp_exports);
|
|
24
|
+
function clamp(val, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
|
|
25
|
+
return Math.max(min, Math.min(val, max));
|
|
26
|
+
}
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
clamp
|
|
30
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var closePart_exports = {};
|
|
20
|
+
__export(closePart_exports, {
|
|
21
|
+
ClosePartProvider: () => ClosePartProvider,
|
|
22
|
+
useClosePartCount: () => useClosePartCount,
|
|
23
|
+
useClosePartRegistration: () => useClosePartRegistration
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(closePart_exports);
|
|
26
|
+
var import_octane = require("octane");
|
|
27
|
+
var import_internal = require("../internal.cjs");
|
|
28
|
+
var import_useStableCallback = require("./useStableCallback.cjs");
|
|
29
|
+
const ClosePartContext = (0, import_octane.createContext)(void 0);
|
|
30
|
+
function useClosePartCount() {
|
|
31
|
+
const slot = (0, import_internal.S)("useClosePartCount");
|
|
32
|
+
const [closePartCount, setClosePartCount] = (0, import_octane.useState)(0, (0, import_internal.subSlot)(slot, "count"));
|
|
33
|
+
const register = (0, import_useStableCallback.useStableCallback)(
|
|
34
|
+
() => {
|
|
35
|
+
setClosePartCount((count) => count + 1);
|
|
36
|
+
return () => {
|
|
37
|
+
setClosePartCount((count) => Math.max(0, count - 1));
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
(0, import_internal.subSlot)(slot, "reg")
|
|
41
|
+
);
|
|
42
|
+
const context = (0, import_octane.useMemo)(() => ({ register }), [register], (0, import_internal.subSlot)(slot, "ctx"));
|
|
43
|
+
return {
|
|
44
|
+
context,
|
|
45
|
+
hasClosePart: closePartCount > 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function ClosePartProvider(props) {
|
|
49
|
+
return (0, import_octane.createElement)(ClosePartContext.Provider, {
|
|
50
|
+
value: props.value,
|
|
51
|
+
children: props.children
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function useClosePartRegistration() {
|
|
55
|
+
const slot = (0, import_internal.S)("useClosePartRegistration");
|
|
56
|
+
const context = (0, import_octane.useContext)(ClosePartContext);
|
|
57
|
+
(0, import_octane.useLayoutEffect)(
|
|
58
|
+
() => {
|
|
59
|
+
return context?.register();
|
|
60
|
+
},
|
|
61
|
+
[context],
|
|
62
|
+
(0, import_internal.subSlot)(slot, "eff")
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
ClosePartProvider,
|
|
68
|
+
useClosePartCount,
|
|
69
|
+
useClosePartRegistration
|
|
70
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var collapsibleOpenStateMapping_exports = {};
|
|
20
|
+
__export(collapsibleOpenStateMapping_exports, {
|
|
21
|
+
collapsibleOpenStateMapping: () => collapsibleOpenStateMapping,
|
|
22
|
+
collapsibleTriggerOpenStateMapping: () => collapsibleTriggerOpenStateMapping
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(collapsibleOpenStateMapping_exports);
|
|
25
|
+
const PANEL_OPEN_HOOK = { "data-open": "" };
|
|
26
|
+
const PANEL_CLOSED_HOOK = { "data-closed": "" };
|
|
27
|
+
const TRIGGER_PANEL_OPEN_HOOK = { "data-panel-open": "" };
|
|
28
|
+
const collapsibleOpenStateMapping = {
|
|
29
|
+
open(value) {
|
|
30
|
+
return value ? PANEL_OPEN_HOOK : PANEL_CLOSED_HOOK;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const collapsibleTriggerOpenStateMapping = {
|
|
34
|
+
open(value) {
|
|
35
|
+
return value ? TRIGGER_PANEL_OPEN_HOOK : null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
collapsibleOpenStateMapping,
|
|
41
|
+
collapsibleTriggerOpenStateMapping
|
|
42
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var composeRefs_exports = {};
|
|
20
|
+
__export(composeRefs_exports, {
|
|
21
|
+
composeRefs: () => composeRefs,
|
|
22
|
+
useComposedRefs: () => useComposedRefs
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(composeRefs_exports);
|
|
25
|
+
var import_octane = require("octane");
|
|
26
|
+
var import_internal = require("../internal.cjs");
|
|
27
|
+
function setRef(ref, value) {
|
|
28
|
+
if (typeof ref === "function") {
|
|
29
|
+
return ref(value);
|
|
30
|
+
} else if (ref !== null && ref !== void 0) {
|
|
31
|
+
ref.current = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function composeRefs(...refs) {
|
|
35
|
+
return (node) => {
|
|
36
|
+
let hasCleanup = false;
|
|
37
|
+
const cleanups = refs.map((ref) => {
|
|
38
|
+
const cleanup = setRef(ref, node);
|
|
39
|
+
if (!hasCleanup && typeof cleanup === "function") {
|
|
40
|
+
hasCleanup = true;
|
|
41
|
+
}
|
|
42
|
+
return cleanup;
|
|
43
|
+
});
|
|
44
|
+
if (hasCleanup) {
|
|
45
|
+
return () => {
|
|
46
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
47
|
+
const cleanup = cleanups[i];
|
|
48
|
+
if (typeof cleanup === "function") {
|
|
49
|
+
cleanup();
|
|
50
|
+
} else {
|
|
51
|
+
setRef(refs[i], null);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function useComposedRefs(...args) {
|
|
59
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
60
|
+
const slot = slotArg ?? (0, import_internal.S)("useComposedRefs");
|
|
61
|
+
const refs = user;
|
|
62
|
+
return (0, import_octane.useCallback)(composeRefs(...refs), refs, (0, import_internal.subSlot)(slot, "cb"));
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
composeRefs,
|
|
67
|
+
useComposedRefs
|
|
68
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var CompositeItem_exports = {};
|
|
20
|
+
__export(CompositeItem_exports, {
|
|
21
|
+
CompositeItem: () => CompositeItem
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(CompositeItem_exports);
|
|
24
|
+
var import_internal = require("../../internal.cjs");
|
|
25
|
+
var import_useRenderElement = require("../useRenderElement.cjs");
|
|
26
|
+
var import_useCompositeItem = require("./useCompositeItem.cjs");
|
|
27
|
+
const EMPTY_ARRAY = [];
|
|
28
|
+
const EMPTY_OBJECT = {};
|
|
29
|
+
function CompositeItem(componentProps) {
|
|
30
|
+
const slot = (0, import_internal.S)("CompositeItem");
|
|
31
|
+
const {
|
|
32
|
+
render,
|
|
33
|
+
className,
|
|
34
|
+
style,
|
|
35
|
+
state = EMPTY_OBJECT,
|
|
36
|
+
props = EMPTY_ARRAY,
|
|
37
|
+
refs = EMPTY_ARRAY,
|
|
38
|
+
metadata,
|
|
39
|
+
stateAttributesMapping,
|
|
40
|
+
tag = "div",
|
|
41
|
+
...elementProps
|
|
42
|
+
} = componentProps;
|
|
43
|
+
const { compositeProps, compositeRef } = (0, import_useCompositeItem.useCompositeItem)({ metadata }, (0, import_internal.subSlot)(slot, "item"));
|
|
44
|
+
return (0, import_useRenderElement.useRenderElement)(
|
|
45
|
+
tag,
|
|
46
|
+
{ render, className, style },
|
|
47
|
+
{
|
|
48
|
+
state,
|
|
49
|
+
ref: [...refs, compositeRef],
|
|
50
|
+
props: [compositeProps, ...props, elementProps],
|
|
51
|
+
stateAttributesMapping
|
|
52
|
+
},
|
|
53
|
+
(0, import_internal.subSlot)(slot, "re")
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
CompositeItem
|
|
59
|
+
});
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var CompositeList_exports = {};
|
|
20
|
+
__export(CompositeList_exports, {
|
|
21
|
+
CompositeList: () => CompositeList
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(CompositeList_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../../internal.cjs");
|
|
26
|
+
var import_useStableCallback = require("../useStableCallback.cjs");
|
|
27
|
+
var import_useRefWithInit = require("../useRefWithInit.cjs");
|
|
28
|
+
var import_CompositeListContext = require("./CompositeListContext.cjs");
|
|
29
|
+
function createMap() {
|
|
30
|
+
return /* @__PURE__ */ new Map();
|
|
31
|
+
}
|
|
32
|
+
function createListeners() {
|
|
33
|
+
return /* @__PURE__ */ new Set();
|
|
34
|
+
}
|
|
35
|
+
function sortByDocumentPosition(a, b) {
|
|
36
|
+
const position = a.compareDocumentPosition(b);
|
|
37
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING || position & Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
|
38
|
+
return -1;
|
|
39
|
+
}
|
|
40
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING || position & Node.DOCUMENT_POSITION_CONTAINS) {
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
function CompositeList(props) {
|
|
46
|
+
const slot = (0, import_internal.S)("CompositeList");
|
|
47
|
+
const { children, elementsRef, labelsRef, onMapChange: onMapChangeProp } = props;
|
|
48
|
+
const onMapChange = (0, import_useStableCallback.useStableCallback)(onMapChangeProp, (0, import_internal.subSlot)(slot, "omc"));
|
|
49
|
+
const nextIndexRef = (0, import_octane.useRef)(0, (0, import_internal.subSlot)(slot, "nextIdx"));
|
|
50
|
+
const listeners = (0, import_useRefWithInit.useRefWithInit)(
|
|
51
|
+
createListeners,
|
|
52
|
+
(0, import_internal.subSlot)(slot, "listeners")
|
|
53
|
+
).current;
|
|
54
|
+
const map = (0, import_useRefWithInit.useRefWithInit)(
|
|
55
|
+
createMap,
|
|
56
|
+
(0, import_internal.subSlot)(slot, "map")
|
|
57
|
+
).current;
|
|
58
|
+
const [mapTick, setMapTick] = (0, import_octane.useState)(0, (0, import_internal.subSlot)(slot, "tick"));
|
|
59
|
+
const lastTickRef = (0, import_octane.useRef)(mapTick, (0, import_internal.subSlot)(slot, "lastTick"));
|
|
60
|
+
const register = (0, import_useStableCallback.useStableCallback)(
|
|
61
|
+
(node, metadata) => {
|
|
62
|
+
map.set(node, metadata ?? null);
|
|
63
|
+
lastTickRef.current += 1;
|
|
64
|
+
setMapTick(lastTickRef.current);
|
|
65
|
+
},
|
|
66
|
+
(0, import_internal.subSlot)(slot, "reg")
|
|
67
|
+
);
|
|
68
|
+
const unregister = (0, import_useStableCallback.useStableCallback)(
|
|
69
|
+
(node) => {
|
|
70
|
+
map.delete(node);
|
|
71
|
+
lastTickRef.current += 1;
|
|
72
|
+
setMapTick(lastTickRef.current);
|
|
73
|
+
},
|
|
74
|
+
(0, import_internal.subSlot)(slot, "unreg")
|
|
75
|
+
);
|
|
76
|
+
const sortedMap = (0, import_octane.useMemo)(
|
|
77
|
+
() => {
|
|
78
|
+
const newMap = /* @__PURE__ */ new Map();
|
|
79
|
+
const sortedNodes = Array.from(map.keys()).filter((node) => node.isConnected).sort(sortByDocumentPosition);
|
|
80
|
+
sortedNodes.forEach((node, index) => {
|
|
81
|
+
const metadata = map.get(node) ?? {};
|
|
82
|
+
newMap.set(node, { ...metadata, index });
|
|
83
|
+
});
|
|
84
|
+
return newMap;
|
|
85
|
+
},
|
|
86
|
+
[map, mapTick],
|
|
87
|
+
(0, import_internal.subSlot)(slot, "sorted")
|
|
88
|
+
);
|
|
89
|
+
(0, import_octane.useLayoutEffect)(
|
|
90
|
+
() => {
|
|
91
|
+
if (typeof MutationObserver !== "function" || sortedMap.size === 0) {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
const mutationObserver = new MutationObserver((entries) => {
|
|
95
|
+
const diff = /* @__PURE__ */ new Set();
|
|
96
|
+
const updateDiff = (node) => diff.has(node) ? diff.delete(node) : diff.add(node);
|
|
97
|
+
entries.forEach((entry) => {
|
|
98
|
+
entry.removedNodes.forEach(updateDiff);
|
|
99
|
+
entry.addedNodes.forEach(updateDiff);
|
|
100
|
+
});
|
|
101
|
+
if (diff.size === 0) {
|
|
102
|
+
lastTickRef.current += 1;
|
|
103
|
+
setMapTick(lastTickRef.current);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
sortedMap.forEach((_, node) => {
|
|
107
|
+
if (node.parentElement) {
|
|
108
|
+
mutationObserver.observe(node.parentElement, { childList: true });
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return () => {
|
|
112
|
+
mutationObserver.disconnect();
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
[sortedMap],
|
|
116
|
+
(0, import_internal.subSlot)(slot, "e:mo")
|
|
117
|
+
);
|
|
118
|
+
(0, import_octane.useLayoutEffect)(
|
|
119
|
+
() => {
|
|
120
|
+
const shouldUpdateLengths = lastTickRef.current === mapTick;
|
|
121
|
+
if (shouldUpdateLengths) {
|
|
122
|
+
if (elementsRef.current.length !== sortedMap.size) {
|
|
123
|
+
elementsRef.current.length = sortedMap.size;
|
|
124
|
+
}
|
|
125
|
+
if (labelsRef && labelsRef.current.length !== sortedMap.size) {
|
|
126
|
+
labelsRef.current.length = sortedMap.size;
|
|
127
|
+
}
|
|
128
|
+
nextIndexRef.current = sortedMap.size;
|
|
129
|
+
}
|
|
130
|
+
onMapChange(sortedMap);
|
|
131
|
+
},
|
|
132
|
+
[onMapChange, sortedMap, elementsRef, labelsRef, mapTick],
|
|
133
|
+
(0, import_internal.subSlot)(slot, "e:len")
|
|
134
|
+
);
|
|
135
|
+
(0, import_octane.useLayoutEffect)(
|
|
136
|
+
() => () => {
|
|
137
|
+
elementsRef.current = [];
|
|
138
|
+
},
|
|
139
|
+
[elementsRef],
|
|
140
|
+
(0, import_internal.subSlot)(slot, "e:cleanEl")
|
|
141
|
+
);
|
|
142
|
+
(0, import_octane.useLayoutEffect)(
|
|
143
|
+
() => () => {
|
|
144
|
+
if (labelsRef) {
|
|
145
|
+
labelsRef.current = [];
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
[labelsRef],
|
|
149
|
+
(0, import_internal.subSlot)(slot, "e:cleanLbl")
|
|
150
|
+
);
|
|
151
|
+
const subscribeMapChange = (0, import_useStableCallback.useStableCallback)(
|
|
152
|
+
(fn) => {
|
|
153
|
+
listeners.add(fn);
|
|
154
|
+
return () => {
|
|
155
|
+
listeners.delete(fn);
|
|
156
|
+
};
|
|
157
|
+
},
|
|
158
|
+
(0, import_internal.subSlot)(slot, "sub")
|
|
159
|
+
);
|
|
160
|
+
(0, import_octane.useLayoutEffect)(
|
|
161
|
+
() => {
|
|
162
|
+
listeners.forEach((l) => l(sortedMap));
|
|
163
|
+
},
|
|
164
|
+
[listeners, sortedMap],
|
|
165
|
+
(0, import_internal.subSlot)(slot, "e:notify")
|
|
166
|
+
);
|
|
167
|
+
const contextValue = (0, import_octane.useMemo)(
|
|
168
|
+
() => ({ register, unregister, subscribeMapChange, elementsRef, labelsRef, nextIndexRef }),
|
|
169
|
+
[register, unregister, subscribeMapChange, elementsRef, labelsRef, nextIndexRef],
|
|
170
|
+
(0, import_internal.subSlot)(slot, "ctx")
|
|
171
|
+
);
|
|
172
|
+
return (0, import_octane.createElement)(import_CompositeListContext.CompositeListContext.Provider, { value: contextValue, children });
|
|
173
|
+
}
|
|
174
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
175
|
+
0 && (module.exports = {
|
|
176
|
+
CompositeList
|
|
177
|
+
});
|