@monimesl/dot-renderer-react 0.1.0-alpha.8 → 0.1.0-alpha.9
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/README.md +39 -1
- package/dist/LICENSE-PHOSPHOR +21 -21
- package/dist/_virtual/_rolldown/runtime.js +14 -0
- package/dist/_virtual/builtin_esm-external-require-react.js +9 -0
- package/dist/color.js +105 -0
- package/dist/components/amount-input.d.ts +6 -0
- package/dist/components/amount-input.js +106 -0
- package/dist/components/button.d.ts +6 -0
- package/dist/components/button.js +42 -0
- package/dist/components/carousel.d.ts +6 -0
- package/dist/components/carousel.js +254 -0
- package/dist/components/chip.d.ts +6 -0
- package/dist/components/chip.js +41 -0
- package/dist/components/code-input.d.ts +6 -0
- package/dist/components/code-input.js +97 -0
- package/dist/components/detail-row.d.ts +6 -0
- package/dist/components/detail-row.js +40 -0
- package/dist/components/divider.d.ts +6 -0
- package/dist/components/divider.js +18 -0
- package/dist/components/empty-state.d.ts +6 -0
- package/dist/components/empty-state.js +66 -0
- package/dist/components/feedback.d.ts +8 -0
- package/dist/components/feedback.js +85 -0
- package/dist/components/field-box.js +44 -0
- package/dist/components/field.js +43 -0
- package/dist/components/footer.d.ts +6 -0
- package/dist/components/footer.js +24 -0
- package/dist/components/grid.d.ts +7 -0
- package/dist/components/grid.js +98 -0
- package/dist/components/icon-artwork.js +74 -0
- package/dist/components/icon.d.ts +6 -0
- package/dist/components/icon.js +40 -0
- package/dist/components/image.d.ts +6 -0
- package/dist/components/image.js +40 -0
- package/dist/components/index.d.ts +30 -0
- package/dist/components/index.js +72 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.js +86 -0
- package/dist/components/link.d.ts +6 -0
- package/dist/components/link.js +39 -0
- package/dist/components/list.d.ts +7 -0
- package/dist/components/list.js +143 -0
- package/dist/components/option-place.js +9 -0
- package/dist/components/option.d.ts +6 -0
- package/dist/components/option.js +43 -0
- package/dist/components/padding.d.ts +2 -0
- package/dist/components/padding.js +27 -0
- package/dist/components/pressable.js +17 -0
- package/dist/components/qr-code.d.ts +6 -0
- package/dist/components/qr-code.js +58 -0
- package/dist/components/scroll.d.ts +6 -0
- package/dist/components/scroll.js +55 -0
- package/dist/components/select.d.ts +6 -0
- package/dist/components/select.js +92 -0
- package/dist/components/sheet.d.ts +8 -0
- package/dist/components/sheet.js +105 -0
- package/dist/components/skeleton.d.ts +6 -0
- package/dist/components/skeleton.js +55 -0
- package/dist/components/spinner.d.ts +6 -0
- package/dist/components/spinner.js +48 -0
- package/dist/components/tabs.d.ts +7 -0
- package/dist/components/tabs.js +91 -0
- package/dist/components/text-area.d.ts +6 -0
- package/dist/components/text-area.js +42 -0
- package/dist/components/text.d.ts +6 -0
- package/dist/components/text.js +46 -0
- package/dist/components/toast.d.ts +6 -0
- package/dist/components/toast.js +56 -0
- package/dist/components/toggles.d.ts +9 -0
- package/dist/components/toggles.js +149 -0
- package/dist/components/tokens.js +37 -0
- package/dist/components/tones.js +24 -0
- package/dist/components/typed-text.js +28 -0
- package/dist/components/view.d.ts +6 -0
- package/dist/components/view.js +51 -0
- package/dist/index.d.ts +35 -64
- package/dist/index.js +32 -22636
- package/dist/page-root.d.ts +2 -0
- package/dist/page-root.js +20 -0
- package/dist/portal.js +8 -0
- package/dist/renderer.d.ts +17 -0
- package/dist/renderer.js +33 -0
- package/dist/root.d.ts +10 -0
- package/dist/root.js +51 -0
- package/dist/styles.css +95 -1
- package/dist/theme.d.ts +25 -0
- package/dist/theme.js +84 -0
- package/dist/types.d.ts +7 -0
- package/dist/vendor/@base-ui/react/checkbox/indicator/CheckboxIndicator.js +51 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRoot.js +265 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/checkbox/utils/getCheckboxStateAttributesMapping.js +15 -0
- package/dist/vendor/@base-ui/react/checkbox-group/CheckboxGroupContext.js +10 -0
- package/dist/vendor/@base-ui/react/dialog/backdrop/DialogBackdrop.js +40 -0
- package/dist/vendor/@base-ui/react/dialog/close/DialogClose.js +39 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopup.js +92 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupCssVars.js +8 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupDataAttributes.js +7 -0
- package/dist/vendor/@base-ui/react/dialog/portal/DialogPortal.js +38 -0
- package/dist/vendor/@base-ui/react/dialog/portal/DialogPortalContext.js +13 -0
- package/dist/vendor/@base-ui/react/dialog/root/DialogRoot.js +16 -0
- package/dist/vendor/@base-ui/react/dialog/root/DialogRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/dialog/root/useDialogRoot.js +77 -0
- package/dist/vendor/@base-ui/react/dialog/root/useRenderDialogRoot.js +65 -0
- package/dist/vendor/@base-ui/react/dialog/store/DialogStore.js +70 -0
- package/dist/vendor/@base-ui/react/dialog/title/DialogTitle.js +25 -0
- package/dist/vendor/@base-ui/react/dialog/utils/stateAttributesMapping.js +17 -0
- package/dist/vendor/@base-ui/react/field/control/FieldControlDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/field/item/FieldItemContext.js +10 -0
- package/dist/vendor/@base-ui/react/field/root/useFieldValidation.js +18 -0
- package/dist/vendor/@base-ui/react/fieldset/root/FieldsetRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingFocusManager.js +477 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingPortal.js +165 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingRootStore.js +65 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingTree.js +22 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useDismiss.js +373 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.js +58 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/composite.js +40 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/constants.js +5 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/createAttribute.js +6 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/createEventEmitter.js +18 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/element.js +26 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/enqueueFocus.js +25 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/event.js +25 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/markOthers.js +116 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/nodes.js +16 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/tabbable.js +135 -0
- package/dist/vendor/@base-ui/react/internals/TransitionStatusDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/internals/composite/composite.js +89 -0
- package/dist/vendor/@base-ui/react/internals/composite/constants.js +4 -0
- package/dist/vendor/@base-ui/react/internals/composite/item/CompositeItem.js +21 -0
- package/dist/vendor/@base-ui/react/internals/composite/item/useCompositeItem.js +31 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/CompositeList.js +180 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/CompositeListContext.js +15 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/useCompositeListItem.js +54 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRoot.js +62 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/useCompositeRoot.js +170 -0
- package/dist/vendor/@base-ui/react/internals/constants.js +18 -0
- package/dist/vendor/@base-ui/react/internals/createBaseUIEventDetails.js +40 -0
- package/dist/vendor/@base-ui/react/internals/direction-context/DirectionContext.js +10 -0
- package/dist/vendor/@base-ui/react/internals/field-constants/constants.js +33 -0
- package/dist/vendor/@base-ui/react/internals/field-register-control/useRegisterFieldControl.js +40 -0
- package/dist/vendor/@base-ui/react/internals/field-root-context/FieldRootContext.js +45 -0
- package/dist/vendor/@base-ui/react/internals/form-context/FormContext.js +18 -0
- package/dist/vendor/@base-ui/react/internals/getStateAttributesProps.js +17 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/LabelableContext.js +24 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/useAriaLabelledBy.js +35 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/useLabelableId.js +57 -0
- package/dist/vendor/@base-ui/react/internals/reason-parts.js +14 -0
- package/dist/vendor/@base-ui/react/internals/serializeValue.js +12 -0
- package/dist/vendor/@base-ui/react/internals/stateAttributesMapping.js +11 -0
- package/dist/vendor/@base-ui/react/internals/use-button/useButton.js +137 -0
- package/dist/vendor/@base-ui/react/internals/useAnimationsFinished.js +94 -0
- package/dist/vendor/@base-ui/react/internals/useBaseUiId.js +13 -0
- package/dist/vendor/@base-ui/react/internals/useOpenChangeComplete.js +28 -0
- package/dist/vendor/@base-ui/react/internals/useRenderElement.js +109 -0
- package/dist/vendor/@base-ui/react/internals/useTransitionStatus.js +70 -0
- package/dist/vendor/@base-ui/react/internals/useValueChanged.js +15 -0
- package/dist/vendor/@base-ui/react/merge-props/mergeProps.js +153 -0
- package/dist/vendor/@base-ui/react/radio/indicator/RadioIndicator.js +46 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRoot.js +179 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/radio/utils/stateAttributesMapping.js +14 -0
- package/dist/vendor/@base-ui/react/radio-group/RadioGroup.js +170 -0
- package/dist/vendor/@base-ui/react/radio-group/RadioGroupContext.js +10 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRoot.js +170 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/switch/stateAttributesMapping.js +12 -0
- package/dist/vendor/@base-ui/react/switch/thumb/SwitchThumb.js +25 -0
- package/dist/vendor/@base-ui/react/tabs/list/TabsList.js +98 -0
- package/dist/vendor/@base-ui/react/tabs/list/TabsListContext.js +13 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRoot.js +213 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRootContext.js +16 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRootDataAttributes.js +8 -0
- package/dist/vendor/@base-ui/react/tabs/root/stateAttributesMapping.js +5 -0
- package/dist/vendor/@base-ui/react/tabs/tab/TabsTab.js +137 -0
- package/dist/vendor/@base-ui/react/utils/CommonPopupDataAttributes.js +24 -0
- package/dist/vendor/@base-ui/react/utils/CommonTriggerDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/utils/FocusGuard.js +32 -0
- package/dist/vendor/@base-ui/react/utils/InternalBackdrop.js +30 -0
- package/dist/vendor/@base-ui/react/utils/dispatchClickWithModifiers.js +25 -0
- package/dist/vendor/@base-ui/react/utils/popupStateMapping.js +22 -0
- package/dist/vendor/@base-ui/react/utils/popups/popupStoreUtils.js +247 -0
- package/dist/vendor/@base-ui/react/utils/popups/popupTriggerMap.js +96 -0
- package/dist/vendor/@base-ui/react/utils/popups/store.js +94 -0
- package/dist/vendor/@base-ui/react/utils/resolveClassName.js +13 -0
- package/dist/vendor/@base-ui/react/utils/resolveRef.js +11 -0
- package/dist/vendor/@base-ui/react/utils/resolveStyle.js +13 -0
- package/dist/vendor/@base-ui/react/utils/useFocusableWhenDisabled.js +30 -0
- package/dist/vendor/@base-ui/utils/addEventListener.js +12 -0
- package/dist/vendor/@base-ui/utils/createLogOnce.js +20 -0
- package/dist/vendor/@base-ui/utils/empty.js +6 -0
- package/dist/vendor/@base-ui/utils/error.js +5 -0
- package/dist/vendor/@base-ui/utils/fastHooks.js +68 -0
- package/dist/vendor/@base-ui/utils/formatErrorMessage.js +27 -0
- package/dist/vendor/@base-ui/utils/getDefaultFormSubmitter.js +25 -0
- package/dist/vendor/@base-ui/utils/getReactElementRef.js +14 -0
- package/dist/vendor/@base-ui/utils/inertValue.js +8 -0
- package/dist/vendor/@base-ui/utils/isElementDisabled.js +6 -0
- package/dist/vendor/@base-ui/utils/mergeCleanups.js +14 -0
- package/dist/vendor/@base-ui/utils/mergeObjects.js +11 -0
- package/dist/vendor/@base-ui/utils/owner.js +7 -0
- package/dist/vendor/@base-ui/utils/platform/engine.js +8 -0
- package/dist/vendor/@base-ui/utils/platform/env.js +6 -0
- package/dist/vendor/@base-ui/utils/platform/os.js +15 -0
- package/dist/vendor/@base-ui/utils/platform/screen-reader.js +9 -0
- package/dist/vendor/@base-ui/utils/platform/shared.js +36 -0
- package/dist/vendor/@base-ui/utils/reactVersion.js +8 -0
- package/dist/vendor/@base-ui/utils/safeReact.js +13 -0
- package/dist/vendor/@base-ui/utils/shadowDom.js +26 -0
- package/dist/vendor/@base-ui/utils/store/ReactStore.js +181 -0
- package/dist/vendor/@base-ui/utils/store/Store.js +102 -0
- package/dist/vendor/@base-ui/utils/store/useStore.js +97 -0
- package/dist/vendor/@base-ui/utils/useAnimationFrame.js +87 -0
- package/dist/vendor/@base-ui/utils/useControlled.js +52 -0
- package/dist/vendor/@base-ui/utils/useId.js +32 -0
- package/dist/vendor/@base-ui/utils/useIsoLayoutEffect.js +7 -0
- package/dist/vendor/@base-ui/utils/useMergedRefs.js +87 -0
- package/dist/vendor/@base-ui/utils/useOnMount.js +12 -0
- package/dist/vendor/@base-ui/utils/useRefWithInit.js +18 -0
- package/dist/vendor/@base-ui/utils/useScrollLock.js +206 -0
- package/dist/vendor/@base-ui/utils/useStableCallback.js +38 -0
- package/dist/vendor/@base-ui/utils/useTimeout.js +43 -0
- package/dist/vendor/@base-ui/utils/useValueAsRef.js +27 -0
- package/dist/vendor/@base-ui/utils/visuallyHidden.js +23 -0
- package/dist/vendor/@base-ui/utils/warn.js +5 -0
- package/dist/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js +49 -0
- package/dist/vendor/uqr/dist/index.js +858 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +74 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +77 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +69 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +64 -0
- package/dist/vendor/use-sync-external-store/shim/index.js +11 -0
- package/dist/vendor/use-sync-external-store/shim/with-selector.js +11 -0
- package/package.json +8 -14
- package/dist/garra-versions.json +0 -7
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useIsoLayoutEffect } from "../../../../utils/useIsoLayoutEffect.js";
|
|
3
|
+
import { useCompositeListContext } from "./CompositeListContext.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/composite/list/useCompositeListItem.mjs
|
|
6
|
+
/**
|
|
7
|
+
* Used to register a list item and its index (DOM position) in the `CompositeList`.
|
|
8
|
+
*/
|
|
9
|
+
function useCompositeListItem(params = {}) {
|
|
10
|
+
const { guess, label, metadata, textRef, index: externalIndex } = params;
|
|
11
|
+
const { register, unregister, subscribeMapChange, nextIndexRef } = useCompositeListContext();
|
|
12
|
+
const indexRef = React.useRef(-1);
|
|
13
|
+
const [internalIndex, setInternalIndex] = React.useState(externalIndex == null && guess ? () => {
|
|
14
|
+
if (indexRef.current === -1) {
|
|
15
|
+
const newIndex = nextIndexRef.current;
|
|
16
|
+
nextIndexRef.current += 1;
|
|
17
|
+
indexRef.current = newIndex;
|
|
18
|
+
}
|
|
19
|
+
return indexRef.current;
|
|
20
|
+
} : -1);
|
|
21
|
+
const index = externalIndex ?? internalIndex;
|
|
22
|
+
const componentRef = React.useRef(null);
|
|
23
|
+
const ref = React.useCallback((node) => {
|
|
24
|
+
const previousNode = componentRef.current;
|
|
25
|
+
if (previousNode) unregister(previousNode);
|
|
26
|
+
componentRef.current = node;
|
|
27
|
+
if (node) register(node, {
|
|
28
|
+
metadata: metadata ?? null,
|
|
29
|
+
index: externalIndex ?? null,
|
|
30
|
+
label,
|
|
31
|
+
textRef
|
|
32
|
+
});
|
|
33
|
+
}, [
|
|
34
|
+
externalIndex,
|
|
35
|
+
register,
|
|
36
|
+
unregister,
|
|
37
|
+
metadata,
|
|
38
|
+
label,
|
|
39
|
+
textRef
|
|
40
|
+
]);
|
|
41
|
+
useIsoLayoutEffect(() => {
|
|
42
|
+
if (externalIndex != null) return;
|
|
43
|
+
return subscribeMapChange((map) => {
|
|
44
|
+
const i = componentRef.current ? map.get(componentRef.current)?.index : null;
|
|
45
|
+
if (i != null) setInternalIndex(i);
|
|
46
|
+
});
|
|
47
|
+
}, [externalIndex, subscribeMapChange]);
|
|
48
|
+
return {
|
|
49
|
+
ref,
|
|
50
|
+
index
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { useCompositeListItem };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { EMPTY_ARRAY, EMPTY_OBJECT } from "../../../../utils/empty.js";
|
|
3
|
+
import { useRenderElement } from "../../useRenderElement.js";
|
|
4
|
+
import { CompositeRootContext } from "./CompositeRootContext.js";
|
|
5
|
+
import { CompositeList } from "../list/CompositeList.js";
|
|
6
|
+
import { useCompositeRoot } from "./useCompositeRoot.js";
|
|
7
|
+
import { useDirection } from "../../direction-context/DirectionContext.js";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/composite/root/CompositeRoot.mjs
|
|
11
|
+
function CompositeRoot(componentProps) {
|
|
12
|
+
const { render, className, style, refs = EMPTY_ARRAY, props = EMPTY_ARRAY, state = EMPTY_OBJECT, stateAttributesMapping, highlightedIndex: highlightedIndexProp, onHighlightedIndexChange: onHighlightedIndexChangeProp, orientation, grid, loopFocus, onLoop, enableHomeAndEndKeys, onMapChange: onMapChangeProp, stopEventPropagation = true, rootRef, disabledIndices, modifierKeys, highlightItemOnHover = false, tag = "div", ...elementProps } = componentProps;
|
|
13
|
+
const direction = useDirection();
|
|
14
|
+
const { props: defaultProps, highlightedIndex, onHighlightedIndexChange, elementsRef, onMapChange: onMapChangeUnwrapped, relayKeyboardEvent } = useCompositeRoot({
|
|
15
|
+
grid,
|
|
16
|
+
loopFocus,
|
|
17
|
+
onLoop,
|
|
18
|
+
orientation,
|
|
19
|
+
highlightedIndex: highlightedIndexProp,
|
|
20
|
+
onHighlightedIndexChange: onHighlightedIndexChangeProp,
|
|
21
|
+
rootRef,
|
|
22
|
+
stopEventPropagation,
|
|
23
|
+
enableHomeAndEndKeys,
|
|
24
|
+
direction,
|
|
25
|
+
disabledIndices,
|
|
26
|
+
modifierKeys
|
|
27
|
+
});
|
|
28
|
+
const element = useRenderElement(tag, componentProps, {
|
|
29
|
+
state,
|
|
30
|
+
ref: refs,
|
|
31
|
+
props: [
|
|
32
|
+
defaultProps,
|
|
33
|
+
...props,
|
|
34
|
+
elementProps
|
|
35
|
+
],
|
|
36
|
+
stateAttributesMapping
|
|
37
|
+
});
|
|
38
|
+
const contextValue = React.useMemo(() => ({
|
|
39
|
+
highlightedIndex,
|
|
40
|
+
onHighlightedIndexChange,
|
|
41
|
+
highlightItemOnHover,
|
|
42
|
+
relayKeyboardEvent
|
|
43
|
+
}), [
|
|
44
|
+
highlightedIndex,
|
|
45
|
+
onHighlightedIndexChange,
|
|
46
|
+
highlightItemOnHover,
|
|
47
|
+
relayKeyboardEvent
|
|
48
|
+
]);
|
|
49
|
+
return /*#__PURE__*/ jsx(CompositeRootContext.Provider, {
|
|
50
|
+
value: contextValue,
|
|
51
|
+
children: /*#__PURE__*/ jsx(CompositeList, {
|
|
52
|
+
elementsRef,
|
|
53
|
+
onMapChange: (newMap) => {
|
|
54
|
+
onMapChangeProp?.(newMap);
|
|
55
|
+
onMapChangeUnwrapped(newMap);
|
|
56
|
+
},
|
|
57
|
+
children: element
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { CompositeRoot };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import formatErrorMessage from "../../../../utils/formatErrorMessage.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/composite/root/CompositeRootContext.mjs
|
|
5
|
+
const CompositeRootContext = /*#__PURE__*/ React.createContext(void 0);
|
|
6
|
+
if (process.env.NODE_ENV !== "production") CompositeRootContext.displayName = "CompositeRootContext";
|
|
7
|
+
function useCompositeRootContext(optional = false) {
|
|
8
|
+
const context = React.useContext(CompositeRootContext);
|
|
9
|
+
if (context === void 0 && !optional) throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage(16));
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CompositeRootContext, useCompositeRootContext };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMergedRefs } from "../../../../utils/useMergedRefs.js";
|
|
3
|
+
import { EMPTY_ARRAY } from "../../../../utils/empty.js";
|
|
4
|
+
import { useStableCallback } from "../../../../utils/useStableCallback.js";
|
|
5
|
+
import { useIsoLayoutEffect } from "../../../../utils/useIsoLayoutEffect.js";
|
|
6
|
+
import { getTarget } from "../../../../utils/shadowDom.js";
|
|
7
|
+
import { findNonDisabledListIndex, getMaxListIndex, getMinListIndex, isIndexOutOfListBounds, isListIndexDisabled } from "../../../floating-ui-react/utils/composite.js";
|
|
8
|
+
import { ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, COMPOSITE_KEYS, MODIFIER_KEYS, isNativeInput, scrollIntoViewIfNeeded } from "../composite.js";
|
|
9
|
+
import "../constants.js";
|
|
10
|
+
import { isElementDisabled } from "../../../../utils/isElementDisabled.js";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/composite/root/useCompositeRoot.mjs
|
|
13
|
+
function useCompositeRoot(params) {
|
|
14
|
+
const { loopFocus = true, orientation = "both", grid, onLoop, direction, highlightedIndex: externalHighlightedIndex, onHighlightedIndexChange: externalSetHighlightedIndex, rootRef: externalRef, enableHomeAndEndKeys = false, stopEventPropagation, disabledIndices, modifierKeys = EMPTY_ARRAY } = params;
|
|
15
|
+
const [internalHighlightedIndex, internalSetHighlightedIndex] = React.useState(0);
|
|
16
|
+
const isGrid = grid != null;
|
|
17
|
+
const rootRef = React.useRef(null);
|
|
18
|
+
const mergedRef = useMergedRefs(rootRef, externalRef);
|
|
19
|
+
const elementsRef = React.useRef([]);
|
|
20
|
+
const hasSetDefaultIndexRef = React.useRef(false);
|
|
21
|
+
const highlightedElementRef = React.useRef(null);
|
|
22
|
+
const highlightedIndex = externalHighlightedIndex ?? internalHighlightedIndex;
|
|
23
|
+
const onHighlightedIndexChange = useStableCallback((index, shouldScrollIntoView = false) => {
|
|
24
|
+
highlightedElementRef.current = elementsRef.current[index] ?? null;
|
|
25
|
+
(externalSetHighlightedIndex ?? internalSetHighlightedIndex)(index);
|
|
26
|
+
if (shouldScrollIntoView) {
|
|
27
|
+
const newActiveItem = elementsRef.current[index];
|
|
28
|
+
scrollIntoViewIfNeeded(rootRef.current, newActiveItem, direction, orientation);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const onMapChange = useStableCallback((map) => {
|
|
32
|
+
if (map.size === 0) return;
|
|
33
|
+
if (hasSetDefaultIndexRef.current) {
|
|
34
|
+
const elements = elementsRef.current;
|
|
35
|
+
const nextIndex = elements.indexOf(highlightedElementRef.current);
|
|
36
|
+
if (nextIndex === -1) {
|
|
37
|
+
const replacement = elements[highlightedIndex];
|
|
38
|
+
if (!replacement || isListIndexDisabled(elements, highlightedIndex, disabledIndices)) onHighlightedIndexChange(getFallbackIndex(elements, disabledIndices));
|
|
39
|
+
else highlightedElementRef.current = replacement;
|
|
40
|
+
} else if (nextIndex !== highlightedIndex) onHighlightedIndexChange(nextIndex);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
hasSetDefaultIndexRef.current = true;
|
|
44
|
+
const sortedElements = Array.from(map.keys());
|
|
45
|
+
const activeItem = sortedElements.find((compositeElement) => compositeElement?.hasAttribute("data-composite-item-active")) ?? null;
|
|
46
|
+
const activeIndex = activeItem ? map.get(activeItem)?.index ?? -1 : -1;
|
|
47
|
+
if (activeIndex !== -1) onHighlightedIndexChange(activeIndex);
|
|
48
|
+
else if (isListIndexDisabled(sortedElements, highlightedIndex, disabledIndices)) {
|
|
49
|
+
const firstEnabledIndex = findNonDisabledListIndex(sortedElements, { disabledIndices });
|
|
50
|
+
if (!isIndexOutOfListBounds(sortedElements, firstEnabledIndex)) onHighlightedIndexChange(firstEnabledIndex);
|
|
51
|
+
}
|
|
52
|
+
scrollIntoViewIfNeeded(rootRef.current, activeItem, direction, orientation);
|
|
53
|
+
});
|
|
54
|
+
useIsoLayoutEffect(() => {
|
|
55
|
+
if (disabledIndices == null || externalHighlightedIndex != null || !hasSetDefaultIndexRef.current) return;
|
|
56
|
+
const elements = elementsRef.current;
|
|
57
|
+
if (isListIndexDisabled(elements, highlightedIndex, disabledIndices)) {
|
|
58
|
+
const firstEnabledIndex = findNonDisabledListIndex(elements, { disabledIndices });
|
|
59
|
+
if (!isIndexOutOfListBounds(elements, firstEnabledIndex)) onHighlightedIndexChange(firstEnabledIndex);
|
|
60
|
+
}
|
|
61
|
+
}, [
|
|
62
|
+
disabledIndices,
|
|
63
|
+
externalHighlightedIndex,
|
|
64
|
+
highlightedIndex,
|
|
65
|
+
elementsRef,
|
|
66
|
+
onHighlightedIndexChange
|
|
67
|
+
]);
|
|
68
|
+
const wrappedOnLoop = useStableCallback((event, prevIndex, nextIndex) => {
|
|
69
|
+
if (!onLoop) return nextIndex;
|
|
70
|
+
return onLoop(event, prevIndex, nextIndex, elementsRef);
|
|
71
|
+
});
|
|
72
|
+
const onKeyDown = useStableCallback((event) => {
|
|
73
|
+
const isHomeOrEnd = event.key === "Home" || event.key === "End";
|
|
74
|
+
if (!COMPOSITE_KEYS.has(event.key) || !enableHomeAndEndKeys && isHomeOrEnd) return;
|
|
75
|
+
if (isModifierKeySet(event, modifierKeys)) return;
|
|
76
|
+
if (!rootRef.current) return;
|
|
77
|
+
const isRtl = direction === "rtl";
|
|
78
|
+
const horizontalForwardKey = isRtl ? ARROW_LEFT : ARROW_RIGHT;
|
|
79
|
+
const horizontalBackwardKey = isRtl ? ARROW_RIGHT : ARROW_LEFT;
|
|
80
|
+
const forwardKey = orientation === "vertical" ? ARROW_DOWN : horizontalForwardKey;
|
|
81
|
+
const backwardKey = orientation === "vertical" ? ARROW_UP : horizontalBackwardKey;
|
|
82
|
+
const target = getTarget(event.nativeEvent);
|
|
83
|
+
if (target != null && isNativeInput(target) && !isElementDisabled(target)) {
|
|
84
|
+
const selectionStart = target.selectionStart;
|
|
85
|
+
const selectionEnd = target.selectionEnd;
|
|
86
|
+
const textContent = target.value;
|
|
87
|
+
if (selectionStart == null || event.shiftKey || selectionStart !== selectionEnd) return;
|
|
88
|
+
if (event.key !== backwardKey && selectionStart < textContent.length) return;
|
|
89
|
+
if (event.key !== forwardKey && selectionStart > 0) return;
|
|
90
|
+
}
|
|
91
|
+
let nextIndex = highlightedIndex;
|
|
92
|
+
const minIndex = getMinListIndex(elementsRef, disabledIndices);
|
|
93
|
+
const maxIndex = getMaxListIndex(elementsRef, disabledIndices);
|
|
94
|
+
if (grid != null) nextIndex = grid({
|
|
95
|
+
disabledIndices,
|
|
96
|
+
elementsRef,
|
|
97
|
+
event,
|
|
98
|
+
highlightedIndex,
|
|
99
|
+
loopFocus,
|
|
100
|
+
maxIndex,
|
|
101
|
+
minIndex,
|
|
102
|
+
onLoop: wrappedOnLoop,
|
|
103
|
+
orientation,
|
|
104
|
+
rtl: isRtl
|
|
105
|
+
});
|
|
106
|
+
const isForwardKey = orientation !== "vertical" && event.key === horizontalForwardKey || orientation !== "horizontal" && event.key === "ArrowDown";
|
|
107
|
+
const isBackwardKey = orientation !== "vertical" && event.key === horizontalBackwardKey || orientation !== "horizontal" && event.key === "ArrowUp";
|
|
108
|
+
if (enableHomeAndEndKeys) {
|
|
109
|
+
if (event.key === "Home") nextIndex = minIndex;
|
|
110
|
+
else if (event.key === "End") nextIndex = maxIndex;
|
|
111
|
+
}
|
|
112
|
+
if (nextIndex === highlightedIndex && (isForwardKey || isBackwardKey)) {
|
|
113
|
+
if (loopFocus && nextIndex === maxIndex && isForwardKey) {
|
|
114
|
+
nextIndex = minIndex;
|
|
115
|
+
if (onLoop) nextIndex = onLoop(event, highlightedIndex, nextIndex, elementsRef);
|
|
116
|
+
} else if (loopFocus && nextIndex === minIndex && isBackwardKey) {
|
|
117
|
+
nextIndex = maxIndex;
|
|
118
|
+
if (onLoop) nextIndex = onLoop(event, highlightedIndex, nextIndex, elementsRef);
|
|
119
|
+
} else nextIndex = findNonDisabledListIndex(elementsRef.current, {
|
|
120
|
+
startingIndex: nextIndex,
|
|
121
|
+
decrement: isBackwardKey,
|
|
122
|
+
disabledIndices
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (nextIndex !== highlightedIndex && !isIndexOutOfListBounds(elementsRef.current, nextIndex)) {
|
|
126
|
+
if (stopEventPropagation) event.stopPropagation();
|
|
127
|
+
if (isGrid || isHomeOrEnd || isForwardKey || isBackwardKey) event.preventDefault();
|
|
128
|
+
onHighlightedIndexChange(nextIndex, true);
|
|
129
|
+
queueMicrotask(() => {
|
|
130
|
+
elementsRef.current[nextIndex]?.focus();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
props: {
|
|
136
|
+
ref: mergedRef,
|
|
137
|
+
onFocus(event) {
|
|
138
|
+
const element = rootRef.current;
|
|
139
|
+
const target = getTarget(event.nativeEvent);
|
|
140
|
+
if (!element || target == null || !isNativeInput(target)) return;
|
|
141
|
+
target.setSelectionRange(0, target.value.length);
|
|
142
|
+
},
|
|
143
|
+
onKeyDown
|
|
144
|
+
},
|
|
145
|
+
highlightedIndex,
|
|
146
|
+
onHighlightedIndexChange,
|
|
147
|
+
elementsRef,
|
|
148
|
+
onMapChange,
|
|
149
|
+
relayKeyboardEvent: onKeyDown
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function getFallbackIndex(elements, disabledIndices) {
|
|
153
|
+
let fallbackIndex = -1;
|
|
154
|
+
for (let index = 0; index < elements.length; index += 1) {
|
|
155
|
+
const element = elements[index];
|
|
156
|
+
if (!element || isListIndexDisabled(elements, index, disabledIndices)) continue;
|
|
157
|
+
if (element.hasAttribute("data-composite-item-active")) return index;
|
|
158
|
+
if (fallbackIndex === -1) fallbackIndex = index;
|
|
159
|
+
}
|
|
160
|
+
return Math.max(fallbackIndex, 0);
|
|
161
|
+
}
|
|
162
|
+
function isModifierKeySet(event, ignoredModifierKeys) {
|
|
163
|
+
for (const key of MODIFIER_KEYS) {
|
|
164
|
+
if (ignoredModifierKeys.includes(key)) continue;
|
|
165
|
+
if (event.getModifierState(key)) return true;
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
export { useCompositeRoot };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/constants.mjs
|
|
2
|
+
const CLICK_TRIGGER_IDENTIFIER = "data-base-ui-click-trigger";
|
|
3
|
+
const BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
|
|
4
|
+
const LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
|
|
5
|
+
/**
|
|
6
|
+
* Special visually hidden styles for the aria-owns owner element to ensure owned element
|
|
7
|
+
* accessibility in iOS/Safari/VoiceControl.
|
|
8
|
+
* The owner element is an empty span, so most of the common visually hidden styles are not needed.
|
|
9
|
+
* @see https://github.com/floating-ui/floating-ui/issues/3403
|
|
10
|
+
*/
|
|
11
|
+
const ownerVisuallyHidden = {
|
|
12
|
+
clipPath: "inset(50%)",
|
|
13
|
+
position: "fixed",
|
|
14
|
+
top: 0,
|
|
15
|
+
left: 0
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { BASE_UI_SWIPE_IGNORE_ATTRIBUTE, CLICK_TRIGGER_IDENTIFIER, LEGACY_SWIPE_IGNORE_ATTRIBUTE, ownerVisuallyHidden };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { EMPTY_OBJECT } from "../../utils/empty.js";
|
|
2
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Maps a change `reason` string to the corresponding native event type.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Details of custom change events emitted by Base UI components.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Details of custom generic events emitted by Base UI components.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Base UI event details object with the given reason and utilities
|
|
14
|
+
* for preventing Base UI's internal event handling.
|
|
15
|
+
*/
|
|
16
|
+
function createChangeEventDetails(reason, event, trigger, customProperties) {
|
|
17
|
+
let canceled = false;
|
|
18
|
+
let allowPropagation = false;
|
|
19
|
+
const custom = customProperties ?? EMPTY_OBJECT;
|
|
20
|
+
return {
|
|
21
|
+
reason,
|
|
22
|
+
event: event ?? new Event("base-ui"),
|
|
23
|
+
cancel() {
|
|
24
|
+
canceled = true;
|
|
25
|
+
},
|
|
26
|
+
allowPropagation() {
|
|
27
|
+
allowPropagation = true;
|
|
28
|
+
},
|
|
29
|
+
get isCanceled() {
|
|
30
|
+
return canceled;
|
|
31
|
+
},
|
|
32
|
+
get isPropagationAllowed() {
|
|
33
|
+
return allowPropagation;
|
|
34
|
+
},
|
|
35
|
+
trigger,
|
|
36
|
+
...custom
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { createChangeEventDetails };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
|
|
4
|
+
const DirectionContext = /*#__PURE__*/ React.createContext(void 0);
|
|
5
|
+
if (process.env.NODE_ENV !== "production") DirectionContext.displayName = "DirectionContext";
|
|
6
|
+
function useDirection() {
|
|
7
|
+
return React.useContext(DirectionContext)?.direction ?? "ltr";
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { DirectionContext, useDirection };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { invalid, valid } from "../../field/control/FieldControlDataAttributes.js";
|
|
2
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/field-constants/constants.mjs
|
|
3
|
+
const DEFAULT_VALIDITY_STATE = {
|
|
4
|
+
badInput: false,
|
|
5
|
+
customError: false,
|
|
6
|
+
patternMismatch: false,
|
|
7
|
+
rangeOverflow: false,
|
|
8
|
+
rangeUnderflow: false,
|
|
9
|
+
stepMismatch: false,
|
|
10
|
+
tooLong: false,
|
|
11
|
+
tooShort: false,
|
|
12
|
+
typeMismatch: false,
|
|
13
|
+
valid: null,
|
|
14
|
+
valueMissing: false
|
|
15
|
+
};
|
|
16
|
+
const DEFAULT_FIELD_STATE_ATTRIBUTES = {
|
|
17
|
+
valid: null,
|
|
18
|
+
touched: false,
|
|
19
|
+
dirty: false,
|
|
20
|
+
filled: false,
|
|
21
|
+
focused: false
|
|
22
|
+
};
|
|
23
|
+
const DEFAULT_FIELD_ROOT_STATE = {
|
|
24
|
+
disabled: false,
|
|
25
|
+
...DEFAULT_FIELD_STATE_ATTRIBUTES
|
|
26
|
+
};
|
|
27
|
+
const fieldValidityMapping = { valid(value) {
|
|
28
|
+
if (value === null) return null;
|
|
29
|
+
if (value) return { [valid]: "" };
|
|
30
|
+
return { [invalid]: "" };
|
|
31
|
+
} };
|
|
32
|
+
//#endregion
|
|
33
|
+
export { DEFAULT_FIELD_ROOT_STATE, DEFAULT_FIELD_STATE_ATTRIBUTES, DEFAULT_VALIDITY_STATE, fieldValidityMapping };
|
package/dist/vendor/@base-ui/react/internals/field-register-control/useRegisterFieldControl.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRefWithInit } from "../../../utils/useRefWithInit.js";
|
|
3
|
+
import { useIsoLayoutEffect } from "../../../utils/useIsoLayoutEffect.js";
|
|
4
|
+
import { useFieldRootContext } from "../field-root-context/FieldRootContext.js";
|
|
5
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/field-register-control/useRegisterFieldControl.mjs
|
|
6
|
+
function useRegisterFieldControl(controlRef, id, value, getFormValueOverride, enabled = true, name) {
|
|
7
|
+
const { registerFieldControl } = useFieldRootContext();
|
|
8
|
+
const sourceRef = useRefWithInit(() => Symbol());
|
|
9
|
+
useIsoLayoutEffect(() => {
|
|
10
|
+
const source = sourceRef.current;
|
|
11
|
+
if (!enabled) {
|
|
12
|
+
registerFieldControl(source, void 0);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
registerFieldControl(source, {
|
|
16
|
+
controlRef,
|
|
17
|
+
getValue: getFormValueOverride,
|
|
18
|
+
id,
|
|
19
|
+
name,
|
|
20
|
+
value
|
|
21
|
+
});
|
|
22
|
+
}, [
|
|
23
|
+
controlRef,
|
|
24
|
+
enabled,
|
|
25
|
+
getFormValueOverride,
|
|
26
|
+
id,
|
|
27
|
+
name,
|
|
28
|
+
registerFieldControl,
|
|
29
|
+
sourceRef,
|
|
30
|
+
value
|
|
31
|
+
]);
|
|
32
|
+
useIsoLayoutEffect(() => {
|
|
33
|
+
const source = sourceRef.current;
|
|
34
|
+
return () => {
|
|
35
|
+
registerFieldControl(source, void 0);
|
|
36
|
+
};
|
|
37
|
+
}, [registerFieldControl, sourceRef]);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { useRegisterFieldControl };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import formatErrorMessage from "../../../utils/formatErrorMessage.js";
|
|
3
|
+
import { EMPTY_OBJECT, NOOP } from "../../../utils/empty.js";
|
|
4
|
+
import { DEFAULT_FIELD_ROOT_STATE, DEFAULT_VALIDITY_STATE } from "../field-constants/constants.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/field-root-context/FieldRootContext.mjs
|
|
7
|
+
const DEFAULT_FIELD_ROOT_CONTEXT = {
|
|
8
|
+
invalid: void 0,
|
|
9
|
+
name: void 0,
|
|
10
|
+
validityData: {
|
|
11
|
+
state: DEFAULT_VALIDITY_STATE,
|
|
12
|
+
errors: [],
|
|
13
|
+
error: "",
|
|
14
|
+
value: "",
|
|
15
|
+
initialValue: null
|
|
16
|
+
},
|
|
17
|
+
setValidityData: NOOP,
|
|
18
|
+
disabled: void 0,
|
|
19
|
+
setTouched: NOOP,
|
|
20
|
+
setDirty: NOOP,
|
|
21
|
+
setFilled: NOOP,
|
|
22
|
+
setFocused: NOOP,
|
|
23
|
+
validationMode: "onSubmit",
|
|
24
|
+
shouldValidateOnChange: () => false,
|
|
25
|
+
state: DEFAULT_FIELD_ROOT_STATE,
|
|
26
|
+
registerFieldControl: NOOP,
|
|
27
|
+
validation: {
|
|
28
|
+
getValidationProps: (_disabled, props = EMPTY_OBJECT) => props,
|
|
29
|
+
inputRef: { current: null },
|
|
30
|
+
registeredInputs: /* @__PURE__ */ new Map(),
|
|
31
|
+
registerInput: NOOP,
|
|
32
|
+
getInputControl: () => null,
|
|
33
|
+
commit: async () => {},
|
|
34
|
+
change: NOOP
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const FieldRootContext = /*#__PURE__*/ React.createContext(DEFAULT_FIELD_ROOT_CONTEXT);
|
|
38
|
+
if (process.env.NODE_ENV !== "production") FieldRootContext.displayName = "FieldRootContext";
|
|
39
|
+
function useFieldRootContext(optional = true) {
|
|
40
|
+
const context = React.useContext(FieldRootContext);
|
|
41
|
+
if (context.setValidityData === NOOP && !optional) throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: FieldRootContext is missing. Field parts must be placed within <Field.Root>." : formatErrorMessage(28));
|
|
42
|
+
return context;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { DEFAULT_FIELD_ROOT_CONTEXT, FieldRootContext, useFieldRootContext };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { NOOP } from "../../../utils/empty.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/form-context/FormContext.mjs
|
|
5
|
+
const FormContext = /*#__PURE__*/ React.createContext({
|
|
6
|
+
elementRef: { current: null },
|
|
7
|
+
formRef: { current: { fields: /* @__PURE__ */ new Map() } },
|
|
8
|
+
errors: {},
|
|
9
|
+
clearErrors: NOOP,
|
|
10
|
+
validationMode: "onSubmit",
|
|
11
|
+
submitCountRef: { current: 0 }
|
|
12
|
+
});
|
|
13
|
+
if (process.env.NODE_ENV !== "production") FormContext.displayName = "FormContext";
|
|
14
|
+
function useFormContext() {
|
|
15
|
+
return React.useContext(FormContext);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { FormContext, useFormContext };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
|
|
2
|
+
function getStateAttributesProps(state, customMapping) {
|
|
3
|
+
const props = {};
|
|
4
|
+
for (const key in state) {
|
|
5
|
+
const value = state[key];
|
|
6
|
+
if (customMapping?.hasOwnProperty(key)) {
|
|
7
|
+
const customProps = customMapping[key](value);
|
|
8
|
+
if (customProps != null) Object.assign(props, customProps);
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
if (value === true) props[`data-${key.toLowerCase()}`] = "";
|
|
12
|
+
else if (value) props[`data-${key.toLowerCase()}`] = value.toString();
|
|
13
|
+
}
|
|
14
|
+
return props;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { getStateAttributesProps };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { NOOP } from "../../../utils/empty.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/labelable-provider/LabelableContext.mjs
|
|
5
|
+
/**
|
|
6
|
+
* A context for providing [labelable elements](https://html.spec.whatwg.org/multipage/forms.html#category-label)\
|
|
7
|
+
* with an accessible name (label) and description.
|
|
8
|
+
*/
|
|
9
|
+
const LabelableContext = /*#__PURE__*/ React.createContext({
|
|
10
|
+
controlId: void 0,
|
|
11
|
+
registerControlId: NOOP,
|
|
12
|
+
resetControlId: NOOP,
|
|
13
|
+
labelId: void 0,
|
|
14
|
+
setLabelId: NOOP,
|
|
15
|
+
messageIds: [],
|
|
16
|
+
setMessageIds: NOOP,
|
|
17
|
+
getDescriptionProps: (externalProps) => externalProps
|
|
18
|
+
});
|
|
19
|
+
if (process.env.NODE_ENV !== "production") LabelableContext.displayName = "LabelableContext";
|
|
20
|
+
function useLabelableContext() {
|
|
21
|
+
return React.useContext(LabelableContext);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { LabelableContext, useLabelableContext };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useIsoLayoutEffect } from "../../../utils/useIsoLayoutEffect.js";
|
|
3
|
+
import { useBaseUiId } from "../useBaseUiId.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/labelable-provider/useAriaLabelledBy.mjs
|
|
6
|
+
function useAriaLabelledBy(explicitAriaLabelledBy, labelId, labelSourceRef, enableFallback = true, labelSourceId) {
|
|
7
|
+
const [fallbackAriaLabelledBy, setFallbackAriaLabelledBy] = React.useState();
|
|
8
|
+
const generatedLabelId = useBaseUiId(labelSourceId ? `${labelSourceId}-label` : void 0);
|
|
9
|
+
const ariaLabelledBy = explicitAriaLabelledBy ?? labelId ?? fallbackAriaLabelledBy;
|
|
10
|
+
useIsoLayoutEffect(() => {
|
|
11
|
+
const nextAriaLabelledBy = explicitAriaLabelledBy || labelId || !enableFallback ? void 0 : getAriaLabelledBy(labelSourceRef.current, generatedLabelId);
|
|
12
|
+
if (fallbackAriaLabelledBy !== nextAriaLabelledBy) setFallbackAriaLabelledBy(nextAriaLabelledBy);
|
|
13
|
+
});
|
|
14
|
+
return ariaLabelledBy;
|
|
15
|
+
}
|
|
16
|
+
function getAriaLabelledBy(labelSource, generatedLabelId) {
|
|
17
|
+
const label = findAssociatedLabel(labelSource);
|
|
18
|
+
if (!label) return;
|
|
19
|
+
if (!label.id && generatedLabelId) label.id = generatedLabelId;
|
|
20
|
+
return label.id || void 0;
|
|
21
|
+
}
|
|
22
|
+
function findAssociatedLabel(labelSource) {
|
|
23
|
+
if (!labelSource) return;
|
|
24
|
+
const parent = labelSource.parentElement;
|
|
25
|
+
if (parent && parent.tagName === "LABEL") return parent;
|
|
26
|
+
const controlId = labelSource.id;
|
|
27
|
+
if (controlId) {
|
|
28
|
+
const nextSibling = labelSource.nextElementSibling;
|
|
29
|
+
if (nextSibling && nextSibling.htmlFor === controlId) return nextSibling;
|
|
30
|
+
}
|
|
31
|
+
const labels = labelSource.labels;
|
|
32
|
+
return labels && labels[0];
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { useAriaLabelledBy };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRefWithInit } from "../../../utils/useRefWithInit.js";
|
|
3
|
+
import { NOOP } from "../../../utils/empty.js";
|
|
4
|
+
import { useStableCallback } from "../../../utils/useStableCallback.js";
|
|
5
|
+
import { useIsoLayoutEffect } from "../../../utils/useIsoLayoutEffect.js";
|
|
6
|
+
import { useBaseUiId } from "../useBaseUiId.js";
|
|
7
|
+
import { useLabelableContext } from "./LabelableContext.js";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/labelable-provider/useLabelableId.mjs
|
|
10
|
+
function useLabelableId(params = {}) {
|
|
11
|
+
const { id, enabled = true } = params;
|
|
12
|
+
const { controlId, registerControlId, resetControlId } = useLabelableContext();
|
|
13
|
+
const defaultId = useBaseUiId();
|
|
14
|
+
const controlSourceRef = useRefWithInit(() => Symbol());
|
|
15
|
+
const hasRegisteredRef = React.useRef(false);
|
|
16
|
+
const hadExplicitIdRef = React.useRef(false);
|
|
17
|
+
const unregisterControlId = useStableCallback(() => {
|
|
18
|
+
if (!hasRegisteredRef.current || registerControlId === NOOP) return;
|
|
19
|
+
hasRegisteredRef.current = false;
|
|
20
|
+
registerControlId(controlSourceRef.current, void 0);
|
|
21
|
+
});
|
|
22
|
+
useIsoLayoutEffect(() => {
|
|
23
|
+
if (!enabled || registerControlId === NOOP) {
|
|
24
|
+
unregisterControlId();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let nextId;
|
|
28
|
+
if (id !== void 0) {
|
|
29
|
+
hadExplicitIdRef.current = true;
|
|
30
|
+
nextId = id;
|
|
31
|
+
} else if (hadExplicitIdRef.current) nextId = defaultId;
|
|
32
|
+
else {
|
|
33
|
+
resetControlId();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (nextId === void 0) {
|
|
37
|
+
unregisterControlId();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
hasRegisteredRef.current = true;
|
|
41
|
+
registerControlId(controlSourceRef.current, nextId);
|
|
42
|
+
}, [
|
|
43
|
+
id,
|
|
44
|
+
enabled,
|
|
45
|
+
registerControlId,
|
|
46
|
+
resetControlId,
|
|
47
|
+
defaultId,
|
|
48
|
+
controlSourceRef,
|
|
49
|
+
unregisterControlId
|
|
50
|
+
]);
|
|
51
|
+
useIsoLayoutEffect(() => {
|
|
52
|
+
return unregisterControlId;
|
|
53
|
+
}, [unregisterControlId]);
|
|
54
|
+
return (enabled ? controlId : void 0) ?? id ?? defaultId;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { useLabelableId };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/internals/reason-parts.mjs
|
|
2
|
+
const none = "none";
|
|
3
|
+
const triggerPress = "trigger-press";
|
|
4
|
+
const triggerHover = "trigger-hover";
|
|
5
|
+
const outsidePress = "outside-press";
|
|
6
|
+
const closePress = "close-press";
|
|
7
|
+
const focusOut = "focus-out";
|
|
8
|
+
const escapeKey = "escape-key";
|
|
9
|
+
const disabled = "disabled";
|
|
10
|
+
const missing = "missing";
|
|
11
|
+
const initial = "initial";
|
|
12
|
+
const imperativeAction = "imperative-action";
|
|
13
|
+
//#endregion
|
|
14
|
+
export { closePress, disabled, escapeKey, focusOut, imperativeAction, initial, missing, none, outsidePress, triggerHover, triggerPress };
|