base-ui-vue 0.1.0 → 0.2.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/README.md +41 -1
- package/dist/button/Button.cjs +53 -12
- package/dist/button/Button.cjs.map +1 -1
- package/dist/button/Button.js +26 -15
- package/dist/button/Button.js.map +1 -1
- package/dist/button/ToolbarButton.cjs +367 -0
- package/dist/button/ToolbarButton.cjs.map +1 -0
- package/dist/button/ToolbarButton.js +320 -0
- package/dist/button/ToolbarButton.js.map +1 -0
- package/dist/button/ToolbarButtonDataAttributes.cjs +27 -0
- package/dist/button/ToolbarButtonDataAttributes.cjs.map +1 -0
- package/dist/button/ToolbarButtonDataAttributes.js +21 -0
- package/dist/button/ToolbarButtonDataAttributes.js.map +1 -0
- package/dist/checkbox/index.cjs +1173 -0
- package/dist/checkbox/index.cjs.map +1 -0
- package/dist/checkbox/index.js +1048 -0
- package/dist/checkbox/index.js.map +1 -0
- package/dist/checkbox-group/CheckboxGroup.cjs +629 -0
- package/dist/checkbox-group/CheckboxGroup.cjs.map +1 -0
- package/dist/checkbox-group/CheckboxGroup.js +540 -0
- package/dist/checkbox-group/CheckboxGroup.js.map +1 -0
- package/dist/checkbox-group/CheckboxGroupDataAttributes.cjs +18 -0
- package/dist/checkbox-group/CheckboxGroupDataAttributes.cjs.map +1 -0
- package/dist/checkbox-group/CheckboxGroupDataAttributes.js +12 -0
- package/dist/checkbox-group/CheckboxGroupDataAttributes.js.map +1 -0
- package/dist/composite/composite.cjs +167 -0
- package/dist/composite/composite.cjs.map +1 -1
- package/dist/composite/composite.js +96 -1
- package/dist/composite/composite.js.map +1 -1
- package/dist/composite/constants.cjs +12 -0
- package/dist/composite/constants.cjs.map +1 -0
- package/dist/composite/constants.js +6 -0
- package/dist/composite/constants.js.map +1 -0
- package/dist/control/FieldControl.cjs +18 -343
- package/dist/control/FieldControl.cjs.map +1 -1
- package/dist/control/FieldControl.js +14 -285
- package/dist/control/FieldControl.js.map +1 -1
- package/dist/control/SliderControl.cjs +636 -0
- package/dist/control/SliderControl.cjs.map +1 -0
- package/dist/control/SliderControl.js +553 -0
- package/dist/control/SliderControl.js.map +1 -0
- package/dist/control/SliderControlDataAttributes.cjs +47 -0
- package/dist/control/SliderControlDataAttributes.cjs.map +1 -0
- package/dist/control/SliderControlDataAttributes.js +41 -0
- package/dist/control/SliderControlDataAttributes.js.map +1 -0
- package/dist/csp-provider/CSPContext.cjs +32 -0
- package/dist/csp-provider/CSPContext.cjs.map +1 -0
- package/dist/csp-provider/CSPContext.js +21 -0
- package/dist/csp-provider/CSPContext.js.map +1 -0
- package/dist/csp-provider/CSPProvider.cjs +46 -0
- package/dist/csp-provider/CSPProvider.cjs.map +1 -0
- package/dist/csp-provider/CSPProvider.js +41 -0
- package/dist/csp-provider/CSPProvider.js.map +1 -0
- package/dist/description/FieldDescription.cjs +5 -5
- package/dist/description/FieldDescription.cjs.map +1 -1
- package/dist/description/FieldDescription.js +1 -1
- package/dist/direction-provider/DirectionProvider.cjs +2 -2
- package/dist/direction-provider/DirectionProvider.cjs.map +1 -1
- package/dist/direction-provider/DirectionProvider.js +1 -1
- package/dist/error/FieldError.cjs +10 -288
- package/dist/error/FieldError.cjs.map +1 -1
- package/dist/error/FieldError.js +4 -246
- package/dist/error/FieldError.js.map +1 -1
- package/dist/form/Form.cjs +5 -4
- package/dist/form/Form.cjs.map +1 -1
- package/dist/form/Form.js +5 -4
- package/dist/form/Form.js.map +1 -1
- package/dist/group/ToolbarGroup.cjs +92 -0
- package/dist/group/ToolbarGroup.cjs.map +1 -0
- package/dist/group/ToolbarGroup.js +87 -0
- package/dist/group/ToolbarGroup.js.map +1 -0
- package/dist/group/ToolbarGroupDataAttributes.cjs +23 -0
- package/dist/group/ToolbarGroupDataAttributes.cjs.map +1 -0
- package/dist/group/ToolbarGroupDataAttributes.js +17 -0
- package/dist/group/ToolbarGroupDataAttributes.js.map +1 -0
- package/dist/header/AccordionHeader.cjs +2 -2
- package/dist/header/AccordionHeader.js +1 -1
- package/dist/image/AvatarImage.cjs +4 -4
- package/dist/image/AvatarImage.cjs.map +1 -1
- package/dist/image/AvatarImage.js +1 -1
- package/dist/index.cjs +80 -10
- package/dist/index.d.cts +2751 -612
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2751 -612
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index2.cjs +3651 -370
- package/dist/index2.cjs.map +1 -1
- package/dist/index2.js +3365 -270
- package/dist/index2.js.map +1 -1
- package/package.json +8 -4
- package/src/accordion/root/AccordionRoot.vue +2 -1
- package/src/checkbox/index.ts +23 -0
- package/src/checkbox/indicator/CheckboxIndicator.vue +102 -0
- package/src/checkbox/indicator/CheckboxIndicatorDataAttributes.ts +61 -0
- package/src/checkbox/root/CheckboxRoot.vue +632 -0
- package/src/checkbox/root/CheckboxRootContext.ts +22 -0
- package/src/checkbox/root/CheckboxRootDataAttributes.ts +54 -0
- package/src/checkbox/utils/useStateAttributesMapping.ts +30 -0
- package/src/checkbox-group/CheckboxGroup.vue +241 -0
- package/src/checkbox-group/CheckboxGroupContext.ts +39 -0
- package/src/checkbox-group/CheckboxGroupDataAttributes.ts +6 -0
- package/src/checkbox-group/index.ts +11 -0
- package/src/checkbox-group/useCheckboxGroupParent.ts +173 -0
- package/src/collapsible/panel/useCollapsiblePanel.ts +2 -1
- package/src/collapsible/root/useCollapsibleRoot.ts +3 -1
- package/src/composite/composite.ts +2 -0
- package/src/composite/item/CompositeItem.vue +7 -8
- package/src/composite/root/CompositeRoot.vue +12 -1
- package/src/csp-provider/CSPContext.ts +26 -0
- package/src/csp-provider/CSPProvider.vue +40 -0
- package/src/csp-provider/index.ts +5 -0
- package/src/field/item/FieldItem.vue +6 -1
- package/src/field/label/FieldLabel.vue +10 -51
- package/src/field/root/FieldRoot.vue +16 -3
- package/src/floating-ui-vue/types.ts +1 -4
- package/src/floating-ui-vue/utils/element.ts +12 -0
- package/src/floating-ui-vue/utils/shadowDom.ts +44 -0
- package/src/floating-ui-vue/utils.ts +3 -0
- package/src/form/Form.vue +5 -3
- package/src/index.ts +9 -0
- package/src/labelable-provider/LabelableContext.ts +2 -2
- package/src/labelable-provider/LabelableProvider.vue +21 -4
- package/src/labelable-provider/index.ts +2 -0
- package/src/labelable-provider/useAriaLabelledBy.ts +9 -9
- package/src/labelable-provider/useLabel.ts +115 -0
- package/src/labelable-provider/useLabelableId.ts +12 -10
- package/src/separator/Separator.vue +65 -0
- package/src/separator/SeparatorDataAttributes.ts +7 -0
- package/src/separator/index.ts +3 -0
- package/src/slider/control/SliderControl.vue +497 -0
- package/src/slider/control/SliderControlDataAttributes.ts +35 -0
- package/src/slider/index.ts +35 -0
- package/src/slider/indicator/SliderIndicator.vue +144 -0
- package/src/slider/indicator/SliderIndicatorDataAttributes.ts +35 -0
- package/src/slider/label/SliderLabel.vue +75 -0
- package/src/slider/root/SliderRoot.vue +557 -0
- package/src/slider/root/SliderRootContext.ts +126 -0
- package/src/slider/root/SliderRootDataAttributes.ts +35 -0
- package/src/slider/root/stateAttributesMapping.ts +13 -0
- package/src/slider/thumb/SliderThumb.vue +601 -0
- package/src/slider/thumb/SliderThumbDataAttributes.ts +39 -0
- package/src/slider/thumb/prehydrationScript.min.ts +5 -0
- package/src/slider/thumb/prehydrationScript.template.js +69 -0
- package/src/slider/track/SliderTrack.vue +48 -0
- package/src/slider/track/SliderTrackDataAttributes.ts +10 -0
- package/src/slider/utils/asc.ts +3 -0
- package/src/slider/utils/getMidpoint.ts +9 -0
- package/src/slider/utils/getPushedThumbValues.ts +68 -0
- package/src/slider/utils/getSliderValue.ts +25 -0
- package/src/slider/utils/replaceArrayItemAtIndex.ts +15 -0
- package/src/slider/utils/resolveThumbCollision.ts +177 -0
- package/src/slider/utils/roundValueToStep.ts +19 -0
- package/src/slider/utils/test-utils.ts +25 -0
- package/src/slider/utils/validateMinimumDistance.ts +20 -0
- package/src/slider/utils/valueArrayToPercentages.ts +10 -0
- package/src/slider/value/SliderValue.vue +90 -0
- package/src/slider/value/SliderValueDataAttributes.ts +35 -0
- package/src/switch/index.ts +14 -0
- package/src/switch/root/SwitchRoot.vue +448 -0
- package/src/switch/root/SwitchRootContext.ts +22 -0
- package/src/switch/root/SwitchRootDataAttributes.ts +46 -0
- package/src/switch/stateAttributesMapping.ts +23 -0
- package/src/switch/thumb/SwitchThumb.vue +59 -0
- package/src/switch/thumb/SwitchThumbDataAttributes.ts +46 -0
- package/src/toggle/Toggle.vue +211 -0
- package/src/toggle/ToggleDataAttributes.ts +6 -0
- package/src/toggle/index.ts +3 -0
- package/src/toggle-group/ToggleGroup.vue +224 -0
- package/src/toggle-group/ToggleGroupContext.ts +45 -0
- package/src/toggle-group/ToggleGroupDataAttributes.ts +15 -0
- package/src/toggle-group/index.ts +5 -0
- package/src/toolbar/button/ToolbarButton.vue +99 -0
- package/src/toolbar/button/ToolbarButtonDataAttributes.ts +15 -0
- package/src/toolbar/group/ToolbarGroup.vue +70 -0
- package/src/toolbar/group/ToolbarGroupContext.ts +23 -0
- package/src/toolbar/group/ToolbarGroupDataAttributes.ts +11 -0
- package/src/toolbar/index.ts +27 -0
- package/src/toolbar/input/ToolbarInput.vue +114 -0
- package/src/toolbar/input/ToolbarInputDataAttributes.ts +15 -0
- package/src/toolbar/link/ToolbarLink.vue +54 -0
- package/src/toolbar/link/ToolbarLinkDataAttributes.ts +7 -0
- package/src/toolbar/root/ToolbarRoot.vue +144 -0
- package/src/toolbar/root/ToolbarRootContext.ts +29 -0
- package/src/toolbar/root/ToolbarRootDataAttributes.ts +11 -0
- package/src/toolbar/separator/ToolbarSeparator.vue +41 -0
- package/src/toolbar/separator/ToolbarSeparatorDataAttributes.ts +7 -0
- package/src/use-button/useButton.ts +2 -1
- package/src/utils/areArraysEqual.ts +12 -0
- package/src/utils/clamp.ts +7 -0
- package/src/utils/createBaseUIEventDetails.ts +9 -0
- package/src/utils/formatNumber.ts +7 -0
- package/src/utils/owner.ts +5 -0
- package/src/utils/resolveAriaLabelledBy.ts +10 -0
- package/src/utils/useControllableState.ts +78 -14
- package/src/utils/useFocusableWhenDisabled.ts +6 -1
- package/src/utils/useMergedRefs.ts +26 -2
- package/src/utils/useRegisteredLabelId.ts +21 -0
- package/src/utils/valueToPercent.ts +7 -0
- package/src/utils/visuallyHidden.ts +24 -0
- package/dist/direction-provider/DirectionContext.cjs +0 -26
- package/dist/direction-provider/DirectionContext.cjs.map +0 -1
- package/dist/direction-provider/DirectionContext.js +0 -15
- package/dist/direction-provider/DirectionContext.js.map +0 -1
package/dist/index2.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { EMPTY_OBJECT, mergeProps as mergeProps$1, useButton, useMergedRefs, useRenderElement } from "./button/Button.js";
|
|
1
|
+
import { EMPTY_OBJECT, compositeRootContextKey, error, mergeProps as mergeProps$1, useButton, useFocusableWhenDisabled, useMergedRefs, useRenderElement } from "./button/Button.js";
|
|
2
2
|
import { CollapsiblePanelDataAttributes, accordionItemContextKey, accordionStateAttributesMapping, collapsibleOpenStateMapping, triggerOpenStateMapping, useAccordionItemContext } from "./header/AccordionHeader.js";
|
|
3
|
-
import { AnimationFrame, transitionStatusMapping, useAnimationFrame, useAnimationsFinished, useOpenChangeComplete, useTransitionStatus } from "./
|
|
4
|
-
import { DEFAULT_VALIDITY_STATE, fieldRootContextKey, fieldValidityMapping, getCombinedFieldValidityData, labelableContextKey, useBaseUiId, useFieldRootContext, useFormContext, useLabelableContext } from "./
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { AnimationFrame, REASONS, createChangeEventDetails, createGenericEventDetails, fieldItemContextKey, transitionStatusMapping, useAnimationFrame, useAnimationsFinished, useAriaLabelledBy, useOpenChangeComplete, useTransitionStatus, visuallyHidden, visuallyHiddenInput } from "./checkbox/index.js";
|
|
4
|
+
import { DEFAULT_VALIDITY_STATE, fieldRootContextKey, fieldValidityMapping, getCombinedFieldValidityData, labelableContextKey, useBaseUiId, useCheckboxGroupContext, useControllableState, useField, useFieldRootContext, useFormContext, useLabelableContext } from "./checkbox-group/CheckboxGroup.js";
|
|
5
|
+
import { CompositeItem_default, compositeListContextKey, toolbarRootContextKey, useCompositeListItem, useToolbarGroupContext, useToolbarRootContext } from "./button/ToolbarButton.js";
|
|
6
|
+
import { activeElement, clamp, contains, getMidpoint, getTarget, ownerDocument, roundValueToStep, sliderRootContextKey, sliderStateAttributesMapping, useDirection, useSliderRootContext, validateMinimumDistance } from "./control/SliderControl.js";
|
|
7
|
+
import { ALL_KEYS, ARROW_DOWN as ARROW_DOWN$1, ARROW_KEYS, ARROW_LEFT as ARROW_LEFT$1, ARROW_RIGHT as ARROW_RIGHT$1, ARROW_UP as ARROW_UP$1, COMPOSITE_KEYS, END, HOME, HORIZONTAL_KEYS, HORIZONTAL_KEYS_WITH_EXTRA_KEYS, MODIFIER_KEYS, PAGE_DOWN, PAGE_UP, VERTICAL_KEYS, VERTICAL_KEYS_WITH_EXTRA_KEYS, isNativeInput, scrollIntoViewIfNeeded } from "./composite/composite.js";
|
|
7
8
|
import { AvatarRootContextKey, avatarStateAttributesMapping, useTimeout } from "./fallback/AvatarFallback.js";
|
|
8
|
-
import {
|
|
9
|
+
import { useCSPContext } from "./csp-provider/CSPContext.js";
|
|
10
|
+
import { useLabelableId } from "./control/FieldControl.js";
|
|
11
|
+
import { ACTIVE_COMPOSITE_ITEM } from "./composite/constants.js";
|
|
12
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, defineComponent, getCurrentInstance, guardReactiveProps, inject, mergeProps, normalizeClass, normalizeProps, normalizeStyle, onBeforeUnmount, onMounted, onUnmounted, openBlock, provide, reactive, readonly, ref, renderSlot, resolveDynamicComponent, shallowReadonly, shallowRef, toDisplayString, toValue, unref, useAttrs, watch, watchEffect, watchSyncEffect, withCtx } from "vue";
|
|
13
|
+
import { isHTMLElement } from "@floating-ui/utils/dom";
|
|
14
|
+
import { floor } from "@floating-ui/utils";
|
|
9
15
|
|
|
10
16
|
//#region src/collapsible/root/CollapsibleRootContext.ts
|
|
11
17
|
const collapsibleRootContextKey = Symbol("CollapsibleRootContext");
|
|
@@ -15,133 +21,6 @@ function useCollapsibleRootContext() {
|
|
|
15
21
|
return context;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/utils/createBaseUIEventDetails.ts
|
|
20
|
-
/**
|
|
21
|
-
* Creates a Base UI event details object with the given reason and utilities
|
|
22
|
-
* for preventing Base UI's internal event handling.
|
|
23
|
-
*/
|
|
24
|
-
function createChangeEventDetails(reason, event, trigger, customProperties) {
|
|
25
|
-
let canceled = false;
|
|
26
|
-
let propagationAllowed = false;
|
|
27
|
-
const custom = customProperties ?? EMPTY_OBJECT;
|
|
28
|
-
return {
|
|
29
|
-
reason,
|
|
30
|
-
event: event ?? new Event("base-ui"),
|
|
31
|
-
cancel() {
|
|
32
|
-
canceled = true;
|
|
33
|
-
},
|
|
34
|
-
allowPropagation() {
|
|
35
|
-
propagationAllowed = true;
|
|
36
|
-
},
|
|
37
|
-
get isCanceled() {
|
|
38
|
-
return canceled;
|
|
39
|
-
},
|
|
40
|
-
get isPropagationAllowed() {
|
|
41
|
-
return propagationAllowed;
|
|
42
|
-
},
|
|
43
|
-
trigger,
|
|
44
|
-
...custom
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/utils/reasons.ts
|
|
50
|
-
const none = "none";
|
|
51
|
-
const triggerPress = "trigger-press";
|
|
52
|
-
const triggerHover = "trigger-hover";
|
|
53
|
-
const triggerFocus = "trigger-focus";
|
|
54
|
-
const outsidePress = "outside-press";
|
|
55
|
-
const itemPress = "item-press";
|
|
56
|
-
const closePress = "close-press";
|
|
57
|
-
const linkPress = "link-press";
|
|
58
|
-
const clearPress = "clear-press";
|
|
59
|
-
const chipRemovePress = "chip-remove-press";
|
|
60
|
-
const trackPress = "track-press";
|
|
61
|
-
const incrementPress = "increment-press";
|
|
62
|
-
const decrementPress = "decrement-press";
|
|
63
|
-
const inputChange = "input-change";
|
|
64
|
-
const inputClear = "input-clear";
|
|
65
|
-
const inputBlur = "input-blur";
|
|
66
|
-
const inputPaste = "input-paste";
|
|
67
|
-
const inputPress = "input-press";
|
|
68
|
-
const focusOut = "focus-out";
|
|
69
|
-
const escapeKey = "escape-key";
|
|
70
|
-
const closeWatcher = "close-watcher";
|
|
71
|
-
const listNavigation = "list-navigation";
|
|
72
|
-
const keyboard = "keyboard";
|
|
73
|
-
const pointer = "pointer";
|
|
74
|
-
const drag = "drag";
|
|
75
|
-
const swipe = "swipe";
|
|
76
|
-
const wheel = "wheel";
|
|
77
|
-
const scrub = "scrub";
|
|
78
|
-
const cancelOpen = "cancel-open";
|
|
79
|
-
const siblingOpen = "sibling-open";
|
|
80
|
-
const disabled = "disabled";
|
|
81
|
-
const imperativeAction = "imperative-action";
|
|
82
|
-
const windowResize = "window-resize";
|
|
83
|
-
const REASONS = {
|
|
84
|
-
none,
|
|
85
|
-
triggerPress,
|
|
86
|
-
triggerHover,
|
|
87
|
-
triggerFocus,
|
|
88
|
-
outsidePress,
|
|
89
|
-
itemPress,
|
|
90
|
-
closePress,
|
|
91
|
-
linkPress,
|
|
92
|
-
clearPress,
|
|
93
|
-
chipRemovePress,
|
|
94
|
-
trackPress,
|
|
95
|
-
incrementPress,
|
|
96
|
-
decrementPress,
|
|
97
|
-
inputChange,
|
|
98
|
-
inputClear,
|
|
99
|
-
inputBlur,
|
|
100
|
-
inputPaste,
|
|
101
|
-
inputPress,
|
|
102
|
-
focusOut,
|
|
103
|
-
escapeKey,
|
|
104
|
-
closeWatcher,
|
|
105
|
-
listNavigation,
|
|
106
|
-
keyboard,
|
|
107
|
-
pointer,
|
|
108
|
-
drag,
|
|
109
|
-
swipe,
|
|
110
|
-
wheel,
|
|
111
|
-
scrub,
|
|
112
|
-
cancelOpen,
|
|
113
|
-
siblingOpen,
|
|
114
|
-
disabled,
|
|
115
|
-
imperativeAction,
|
|
116
|
-
windowResize
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/utils/useControllableState.ts
|
|
121
|
-
/**
|
|
122
|
-
* Manages controlled / uncontrolled state following the same semantics as
|
|
123
|
-
* React's `useControlled` hook.
|
|
124
|
-
*
|
|
125
|
-
* - When `controlled()` returns a non-`undefined` value the component is
|
|
126
|
-
* considered **controlled** and the internal state is ignored.
|
|
127
|
-
* - When `controlled()` returns `undefined` the component is **uncontrolled**
|
|
128
|
-
* and the internal ref drives the value.
|
|
129
|
-
*/
|
|
130
|
-
function useControllableState(params) {
|
|
131
|
-
const internalValue = ref(params.default);
|
|
132
|
-
const value = computed(() => {
|
|
133
|
-
const c = params.controlled();
|
|
134
|
-
return c !== void 0 ? c : internalValue.value;
|
|
135
|
-
});
|
|
136
|
-
function setValue(next) {
|
|
137
|
-
internalValue.value = next;
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
value,
|
|
141
|
-
setValue
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
24
|
//#endregion
|
|
146
25
|
//#region src/collapsible/root/useCollapsibleRoot.ts
|
|
147
26
|
function useCollapsibleRoot(parameters) {
|
|
@@ -152,7 +31,9 @@ function useCollapsibleRoot(parameters) {
|
|
|
152
31
|
});
|
|
153
32
|
const { value: open, setValue: setOpen } = useControllableState({
|
|
154
33
|
controlled: () => isControlled.value ? openParam?.() : void 0,
|
|
155
|
-
default: defaultOpen
|
|
34
|
+
default: () => defaultOpen,
|
|
35
|
+
name: "CollapsibleRoot",
|
|
36
|
+
state: "open"
|
|
156
37
|
});
|
|
157
38
|
const { mounted, setMounted, transitionStatus } = useTransitionStatus(open, true, true);
|
|
158
39
|
const visible = ref(open.value);
|
|
@@ -237,83 +118,6 @@ function useCollapsibleRoot(parameters) {
|
|
|
237
118
|
};
|
|
238
119
|
}
|
|
239
120
|
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region src/composite/list/CompositeListContext.ts
|
|
242
|
-
const compositeListContextKey = Symbol("CompositeListContext");
|
|
243
|
-
function useCompositeListContext() {
|
|
244
|
-
return inject(compositeListContextKey);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
//#endregion
|
|
248
|
-
//#region src/composite/list/useCompositeListItem.ts
|
|
249
|
-
let IndexGuessBehavior = /* @__PURE__ */ function(IndexGuessBehavior) {
|
|
250
|
-
IndexGuessBehavior[IndexGuessBehavior["None"] = 0] = "None";
|
|
251
|
-
IndexGuessBehavior[IndexGuessBehavior["GuessFromOrder"] = 1] = "GuessFromOrder";
|
|
252
|
-
return IndexGuessBehavior;
|
|
253
|
-
}({});
|
|
254
|
-
/**
|
|
255
|
-
* Used to register a list item and its index (DOM position) in the `CompositeList`.
|
|
256
|
-
*/
|
|
257
|
-
function useCompositeListItem(params = {}) {
|
|
258
|
-
const externalIndex = computed(() => params.index?.());
|
|
259
|
-
const label = computed(() => params.label?.());
|
|
260
|
-
const metadata = computed(() => params.metadata?.());
|
|
261
|
-
const textRef = computed(() => params.textRef?.());
|
|
262
|
-
const indexGuessBehavior = computed(() => params.indexGuessBehavior?.());
|
|
263
|
-
const { register, unregister, subscribeMapChange, elementsRef, labelsRef, nextIndexRef } = useCompositeListContext();
|
|
264
|
-
const indexRef = ref(-1);
|
|
265
|
-
function initializeIndex() {
|
|
266
|
-
if (externalIndex.value != null) return externalIndex.value;
|
|
267
|
-
if (indexGuessBehavior.value === IndexGuessBehavior.GuessFromOrder) {
|
|
268
|
-
if (indexRef.value === -1) {
|
|
269
|
-
const newIndex = nextIndexRef.value;
|
|
270
|
-
nextIndexRef.value += 1;
|
|
271
|
-
indexRef.value = newIndex;
|
|
272
|
-
}
|
|
273
|
-
return indexRef.value;
|
|
274
|
-
}
|
|
275
|
-
return -1;
|
|
276
|
-
}
|
|
277
|
-
const internalIndex = ref(initializeIndex());
|
|
278
|
-
const index = computed(() => externalIndex.value ?? internalIndex.value);
|
|
279
|
-
const componentRef = ref(null);
|
|
280
|
-
function setRef(node) {
|
|
281
|
-
const el = node?.$el || node;
|
|
282
|
-
componentRef.value = el;
|
|
283
|
-
if (index.value !== -1 && el !== null) {
|
|
284
|
-
elementsRef.value[index.value] = el;
|
|
285
|
-
if (labelsRef) {
|
|
286
|
-
const isLabelDefined = label.value !== void 0;
|
|
287
|
-
labelsRef.value[index.value] = isLabelDefined ? label.value : textRef.value?.value?.textContent ?? el.textContent;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
watchEffect((onCleanup) => {
|
|
292
|
-
if (externalIndex.value != null) return;
|
|
293
|
-
const node = componentRef.value;
|
|
294
|
-
if (node) {
|
|
295
|
-
register(node, metadata.value);
|
|
296
|
-
onCleanup(() => {
|
|
297
|
-
unregister(node);
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
}, { flush: "post" });
|
|
301
|
-
watchEffect((onCleanup) => {
|
|
302
|
-
if (externalIndex.value != null) return;
|
|
303
|
-
const unsubscribe = subscribeMapChange((map) => {
|
|
304
|
-
const i = componentRef.value ? map.get(componentRef.value)?.index : null;
|
|
305
|
-
if (i != null) internalIndex.value = i;
|
|
306
|
-
});
|
|
307
|
-
onCleanup(() => {
|
|
308
|
-
unsubscribe();
|
|
309
|
-
});
|
|
310
|
-
}, { flush: "post" });
|
|
311
|
-
return {
|
|
312
|
-
ref: setRef,
|
|
313
|
-
index
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
|
|
317
121
|
//#endregion
|
|
318
122
|
//#region src/accordion/root/AccordionRootContext.ts
|
|
319
123
|
const accordionRootContextKey = Symbol("AccordionRootContext");
|
|
@@ -446,6 +250,20 @@ var AccordionItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
446
250
|
//#region src/accordion/item/AccordionItem.vue
|
|
447
251
|
var AccordionItem_default = AccordionItem_vue_vue_type_script_setup_true_lang_default;
|
|
448
252
|
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/accordion/root/AccordionRootDataAttributes.ts
|
|
255
|
+
let AccordionRootDataAttributes = /* @__PURE__ */ function(AccordionRootDataAttributes) {
|
|
256
|
+
/**
|
|
257
|
+
* Present when the accordion is disabled.
|
|
258
|
+
*/
|
|
259
|
+
AccordionRootDataAttributes["disabled"] = "data-disabled";
|
|
260
|
+
/**
|
|
261
|
+
* Indicates the orientation of the accordion.
|
|
262
|
+
*/
|
|
263
|
+
AccordionRootDataAttributes["orientation"] = "data-orientation";
|
|
264
|
+
return AccordionRootDataAttributes;
|
|
265
|
+
}({});
|
|
266
|
+
|
|
449
267
|
//#endregion
|
|
450
268
|
//#region src/utils/warn.ts
|
|
451
269
|
let set;
|
|
@@ -501,7 +319,7 @@ function useCollapsiblePanel(parameters) {
|
|
|
501
319
|
* transitions in order to set the value of width/height to `0px` momentarily.
|
|
502
320
|
* Setting both to `0px` will break layout.
|
|
503
321
|
*/
|
|
504
|
-
if (element.getAttribute(
|
|
322
|
+
if (element.getAttribute(AccordionRootDataAttributes.orientation) === "horizontal" || panelStyles.transitionProperty.includes("width")) transitionDimensionRef.value = "width";
|
|
505
323
|
else transitionDimensionRef.value = "height";
|
|
506
324
|
}
|
|
507
325
|
if (animationTypeRef.value !== "css-transition") return;
|
|
@@ -1092,7 +910,8 @@ var AccordionRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
1092
910
|
const accordionItemRefs = _compositeRefs.elementsRef;
|
|
1093
911
|
const { value: openValues, setValue: setOpenValues } = useControllableState({
|
|
1094
912
|
controlled: () => isValueControlled.value ? props.value : void 0,
|
|
1095
|
-
default: props.defaultValue ?? []
|
|
913
|
+
default: () => props.defaultValue ?? [],
|
|
914
|
+
name: "AccordionRoot"
|
|
1096
915
|
});
|
|
1097
916
|
function handleValueChange(newValue, nextOpen) {
|
|
1098
917
|
const details = createChangeEventDetails(REASONS.none);
|
|
@@ -1162,6 +981,13 @@ var AccordionRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
1162
981
|
//#region src/accordion/root/AccordionRoot.vue
|
|
1163
982
|
var AccordionRoot_default = AccordionRoot_vue_vue_type_script_setup_true_lang_default;
|
|
1164
983
|
|
|
984
|
+
//#endregion
|
|
985
|
+
//#region src/floating-ui-vue/utils/constants.ts
|
|
986
|
+
const ARROW_LEFT = "ArrowLeft";
|
|
987
|
+
const ARROW_RIGHT = "ArrowRight";
|
|
988
|
+
const ARROW_UP = "ArrowUp";
|
|
989
|
+
const ARROW_DOWN = "ArrowDown";
|
|
990
|
+
|
|
1165
991
|
//#endregion
|
|
1166
992
|
//#region src/floating-ui-vue/utils/event.ts
|
|
1167
993
|
function stopEvent(event) {
|
|
@@ -1169,6 +995,245 @@ function stopEvent(event) {
|
|
|
1169
995
|
event.stopPropagation();
|
|
1170
996
|
}
|
|
1171
997
|
|
|
998
|
+
//#endregion
|
|
999
|
+
//#region src/floating-ui-vue/utils/composite.ts
|
|
1000
|
+
function isDifferentGridRow(index, cols, prevRow) {
|
|
1001
|
+
return Math.floor(index / cols) !== prevRow;
|
|
1002
|
+
}
|
|
1003
|
+
function isIndexOutOfListBounds(listRef, index) {
|
|
1004
|
+
return index < 0 || index >= listRef.value.length;
|
|
1005
|
+
}
|
|
1006
|
+
function getMinListIndex(listRef, disabledIndices) {
|
|
1007
|
+
return findNonDisabledListIndex(listRef, { disabledIndices });
|
|
1008
|
+
}
|
|
1009
|
+
function getMaxListIndex(listRef, disabledIndices) {
|
|
1010
|
+
return findNonDisabledListIndex(listRef, {
|
|
1011
|
+
decrement: true,
|
|
1012
|
+
startingIndex: listRef.value.length,
|
|
1013
|
+
disabledIndices
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
function findNonDisabledListIndex(listRef, { startingIndex = -1, decrement = false, disabledIndices, amount = 1 } = {}) {
|
|
1017
|
+
let index = startingIndex;
|
|
1018
|
+
do
|
|
1019
|
+
index += decrement ? -amount : amount;
|
|
1020
|
+
while (index >= 0 && index <= listRef.value.length - 1 && isListIndexDisabled(listRef, index, disabledIndices));
|
|
1021
|
+
return index;
|
|
1022
|
+
}
|
|
1023
|
+
function getGridNavigatedIndex(listRef, { event, orientation, loopFocus, rtl, cols, disabledIndices, minIndex, maxIndex, prevIndex, stopEvent: stop = false }) {
|
|
1024
|
+
let nextIndex = prevIndex;
|
|
1025
|
+
const rows = [];
|
|
1026
|
+
const rowIndexMap = {};
|
|
1027
|
+
let hasRoleRow = false;
|
|
1028
|
+
{
|
|
1029
|
+
let currentRowEl = null;
|
|
1030
|
+
let currentRowIndex = -1;
|
|
1031
|
+
listRef.value.forEach((el, idx) => {
|
|
1032
|
+
if (el == null) return;
|
|
1033
|
+
const rowEl = el.closest("[role=\"row\"]");
|
|
1034
|
+
if (rowEl) hasRoleRow = true;
|
|
1035
|
+
if (rowEl !== currentRowEl || currentRowIndex === -1) {
|
|
1036
|
+
currentRowEl = rowEl;
|
|
1037
|
+
currentRowIndex += 1;
|
|
1038
|
+
rows[currentRowIndex] = [];
|
|
1039
|
+
}
|
|
1040
|
+
rows[currentRowIndex].push(idx);
|
|
1041
|
+
rowIndexMap[idx] = currentRowIndex;
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
const hasDomRows = hasRoleRow && rows.length > 0 && rows.some((row) => row.length !== cols);
|
|
1045
|
+
function navigateVertically(direction) {
|
|
1046
|
+
if (!hasDomRows || prevIndex === -1) return;
|
|
1047
|
+
const currentRow = rowIndexMap[prevIndex];
|
|
1048
|
+
if (currentRow == null) return;
|
|
1049
|
+
const colInRow = rows[currentRow].indexOf(prevIndex);
|
|
1050
|
+
let nextRow = direction === "up" ? currentRow - 1 : currentRow + 1;
|
|
1051
|
+
if (loopFocus) {
|
|
1052
|
+
if (nextRow < 0) nextRow = rows.length - 1;
|
|
1053
|
+
else if (nextRow >= rows.length) nextRow = 0;
|
|
1054
|
+
}
|
|
1055
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1056
|
+
const _listRef = listRef;
|
|
1057
|
+
while (nextRow >= 0 && nextRow < rows.length && !visited.has(nextRow)) {
|
|
1058
|
+
visited.add(nextRow);
|
|
1059
|
+
const targetRow = rows[nextRow];
|
|
1060
|
+
if (targetRow.length === 0) {
|
|
1061
|
+
nextRow = direction === "up" ? nextRow - 1 : nextRow + 1;
|
|
1062
|
+
continue;
|
|
1063
|
+
}
|
|
1064
|
+
const clampedCol = Math.min(colInRow, targetRow.length - 1);
|
|
1065
|
+
for (let col = clampedCol; col >= 0; col -= 1) {
|
|
1066
|
+
const candidate = targetRow[col];
|
|
1067
|
+
if (!isListIndexDisabled(_listRef, candidate, disabledIndices)) return candidate;
|
|
1068
|
+
}
|
|
1069
|
+
nextRow = direction === "up" ? nextRow - 1 : nextRow + 1;
|
|
1070
|
+
if (loopFocus) {
|
|
1071
|
+
if (nextRow < 0) nextRow = rows.length - 1;
|
|
1072
|
+
else if (nextRow >= rows.length) nextRow = 0;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
const _listRef = listRef;
|
|
1077
|
+
if (event.key === ARROW_UP) {
|
|
1078
|
+
const domBasedCandidate = navigateVertically("up");
|
|
1079
|
+
if (domBasedCandidate !== void 0) {
|
|
1080
|
+
if (stop) stopEvent(event);
|
|
1081
|
+
nextIndex = domBasedCandidate;
|
|
1082
|
+
} else {
|
|
1083
|
+
if (stop) stopEvent(event);
|
|
1084
|
+
if (prevIndex === -1) nextIndex = maxIndex;
|
|
1085
|
+
else {
|
|
1086
|
+
nextIndex = findNonDisabledListIndex(_listRef, {
|
|
1087
|
+
startingIndex: nextIndex,
|
|
1088
|
+
amount: cols,
|
|
1089
|
+
decrement: true,
|
|
1090
|
+
disabledIndices
|
|
1091
|
+
});
|
|
1092
|
+
if (loopFocus && (prevIndex - cols < minIndex || nextIndex < 0)) {
|
|
1093
|
+
const col = prevIndex % cols;
|
|
1094
|
+
const maxCol = maxIndex % cols;
|
|
1095
|
+
const offset = maxIndex - (maxCol - col);
|
|
1096
|
+
if (maxCol === col) nextIndex = maxIndex;
|
|
1097
|
+
else nextIndex = maxCol > col ? offset : offset - cols;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
if (isIndexOutOfListBounds(listRef, nextIndex)) nextIndex = prevIndex;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
if (event.key === ARROW_DOWN) {
|
|
1104
|
+
const domBasedCandidate = navigateVertically("down");
|
|
1105
|
+
if (domBasedCandidate !== void 0) {
|
|
1106
|
+
if (stop) stopEvent(event);
|
|
1107
|
+
nextIndex = domBasedCandidate;
|
|
1108
|
+
} else {
|
|
1109
|
+
if (stop) stopEvent(event);
|
|
1110
|
+
if (prevIndex === -1) nextIndex = minIndex;
|
|
1111
|
+
else {
|
|
1112
|
+
nextIndex = findNonDisabledListIndex(_listRef, {
|
|
1113
|
+
startingIndex: prevIndex,
|
|
1114
|
+
amount: cols,
|
|
1115
|
+
disabledIndices
|
|
1116
|
+
});
|
|
1117
|
+
if (loopFocus && prevIndex + cols > maxIndex) nextIndex = findNonDisabledListIndex(_listRef, {
|
|
1118
|
+
startingIndex: prevIndex % cols - cols,
|
|
1119
|
+
amount: cols,
|
|
1120
|
+
disabledIndices
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
if (isIndexOutOfListBounds(listRef, nextIndex)) nextIndex = prevIndex;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
if (orientation === "both") {
|
|
1127
|
+
const prevRow = floor(prevIndex / cols);
|
|
1128
|
+
if (event.key === (rtl ? ARROW_LEFT : ARROW_RIGHT)) {
|
|
1129
|
+
if (stop) stopEvent(event);
|
|
1130
|
+
if (prevIndex % cols !== cols - 1) {
|
|
1131
|
+
nextIndex = findNonDisabledListIndex(_listRef, {
|
|
1132
|
+
startingIndex: prevIndex,
|
|
1133
|
+
disabledIndices
|
|
1134
|
+
});
|
|
1135
|
+
if (loopFocus && isDifferentGridRow(nextIndex, cols, prevRow)) nextIndex = findNonDisabledListIndex(_listRef, {
|
|
1136
|
+
startingIndex: prevIndex - prevIndex % cols - 1,
|
|
1137
|
+
disabledIndices
|
|
1138
|
+
});
|
|
1139
|
+
} else if (loopFocus) nextIndex = findNonDisabledListIndex(_listRef, {
|
|
1140
|
+
startingIndex: prevIndex - prevIndex % cols - 1,
|
|
1141
|
+
disabledIndices
|
|
1142
|
+
});
|
|
1143
|
+
if (isDifferentGridRow(nextIndex, cols, prevRow)) nextIndex = prevIndex;
|
|
1144
|
+
}
|
|
1145
|
+
if (event.key === (rtl ? ARROW_RIGHT : ARROW_LEFT)) {
|
|
1146
|
+
if (stop) stopEvent(event);
|
|
1147
|
+
if (prevIndex % cols !== 0) {
|
|
1148
|
+
nextIndex = findNonDisabledListIndex(_listRef, {
|
|
1149
|
+
startingIndex: prevIndex,
|
|
1150
|
+
decrement: true,
|
|
1151
|
+
disabledIndices
|
|
1152
|
+
});
|
|
1153
|
+
if (loopFocus && isDifferentGridRow(nextIndex, cols, prevRow)) nextIndex = findNonDisabledListIndex(_listRef, {
|
|
1154
|
+
startingIndex: prevIndex + (cols - prevIndex % cols),
|
|
1155
|
+
decrement: true,
|
|
1156
|
+
disabledIndices
|
|
1157
|
+
});
|
|
1158
|
+
} else if (loopFocus) nextIndex = findNonDisabledListIndex(_listRef, {
|
|
1159
|
+
startingIndex: prevIndex + (cols - prevIndex % cols),
|
|
1160
|
+
decrement: true,
|
|
1161
|
+
disabledIndices
|
|
1162
|
+
});
|
|
1163
|
+
if (isDifferentGridRow(nextIndex, cols, prevRow)) nextIndex = prevIndex;
|
|
1164
|
+
}
|
|
1165
|
+
const lastRow = floor(maxIndex / cols) === prevRow;
|
|
1166
|
+
if (isIndexOutOfListBounds(listRef, nextIndex)) if (loopFocus && lastRow) nextIndex = event.key === (rtl ? ARROW_RIGHT : ARROW_LEFT) ? maxIndex : findNonDisabledListIndex(_listRef, {
|
|
1167
|
+
startingIndex: prevIndex - prevIndex % cols - 1,
|
|
1168
|
+
disabledIndices
|
|
1169
|
+
});
|
|
1170
|
+
else nextIndex = prevIndex;
|
|
1171
|
+
}
|
|
1172
|
+
return nextIndex;
|
|
1173
|
+
}
|
|
1174
|
+
/** For each cell index, gets the item index that occupies that cell */
|
|
1175
|
+
function createGridCellMap(sizes, cols, dense) {
|
|
1176
|
+
const cellMap = [];
|
|
1177
|
+
let startIndex = 0;
|
|
1178
|
+
sizes.forEach(({ width, height }, index) => {
|
|
1179
|
+
if (width > cols) {
|
|
1180
|
+
if (process.env.NODE_ENV !== "production") throw new Error(`[Base UI Vue]: Invalid grid - item width at index ${index} is greater than grid columns`);
|
|
1181
|
+
}
|
|
1182
|
+
let itemPlaced = false;
|
|
1183
|
+
if (dense) startIndex = 0;
|
|
1184
|
+
while (!itemPlaced) {
|
|
1185
|
+
const targetCells = [];
|
|
1186
|
+
for (let i = 0; i < width; i += 1) for (let j = 0; j < height; j += 1) targetCells.push(startIndex + i + j * cols);
|
|
1187
|
+
if (startIndex % cols + width <= cols && targetCells.every((cell) => cellMap[cell] == null)) {
|
|
1188
|
+
targetCells.forEach((cell) => {
|
|
1189
|
+
cellMap[cell] = index;
|
|
1190
|
+
});
|
|
1191
|
+
itemPlaced = true;
|
|
1192
|
+
} else startIndex += 1;
|
|
1193
|
+
}
|
|
1194
|
+
});
|
|
1195
|
+
return [...cellMap];
|
|
1196
|
+
}
|
|
1197
|
+
/** Gets cell index of an item's corner or -1 when index is -1. */
|
|
1198
|
+
function getGridCellIndexOfCorner(index, sizes, cellMap, cols, corner) {
|
|
1199
|
+
if (index === -1) return -1;
|
|
1200
|
+
const firstCellIndex = cellMap.indexOf(index);
|
|
1201
|
+
const sizeItem = sizes[index];
|
|
1202
|
+
switch (corner) {
|
|
1203
|
+
case "tl": return firstCellIndex;
|
|
1204
|
+
case "tr":
|
|
1205
|
+
if (!sizeItem) return firstCellIndex;
|
|
1206
|
+
return firstCellIndex + sizeItem.width - 1;
|
|
1207
|
+
case "bl":
|
|
1208
|
+
if (!sizeItem) return firstCellIndex;
|
|
1209
|
+
return firstCellIndex + (sizeItem.height - 1) * cols;
|
|
1210
|
+
case "br": return cellMap.lastIndexOf(index);
|
|
1211
|
+
default: return -1;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
/** Gets all cell indices that correspond to the specified indices */
|
|
1215
|
+
function getGridCellIndices(indices, cellMap) {
|
|
1216
|
+
return cellMap.flatMap((index, cellIndex) => indices.includes(index) ? [cellIndex] : []);
|
|
1217
|
+
}
|
|
1218
|
+
function isListIndexDisabled(listRef, index, disabledIndices) {
|
|
1219
|
+
if (typeof disabledIndices === "function") return disabledIndices(index);
|
|
1220
|
+
if (disabledIndices) return disabledIndices.includes(index);
|
|
1221
|
+
const element = listRef.value[index];
|
|
1222
|
+
if (!element) return false;
|
|
1223
|
+
return element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true";
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
//#endregion
|
|
1227
|
+
//#region src/floating-ui-vue/utils/element.ts
|
|
1228
|
+
function matchesFocusVisible(element) {
|
|
1229
|
+
if (!element) return true;
|
|
1230
|
+
try {
|
|
1231
|
+
return element.matches(":focus-visible");
|
|
1232
|
+
} catch {
|
|
1233
|
+
return true;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1172
1237
|
//#endregion
|
|
1173
1238
|
//#region src/utils/isElementDisabled.ts
|
|
1174
1239
|
function isElementDisabled(element) {
|
|
@@ -1237,10 +1302,10 @@ var AccordionTrigger_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
1237
1302
|
itemCtx.setTriggerId(void 0);
|
|
1238
1303
|
});
|
|
1239
1304
|
const SUPPORTED_KEYS = new Set([
|
|
1240
|
-
ARROW_DOWN,
|
|
1241
|
-
ARROW_UP,
|
|
1242
|
-
ARROW_RIGHT,
|
|
1243
|
-
ARROW_LEFT,
|
|
1305
|
+
ARROW_DOWN$1,
|
|
1306
|
+
ARROW_UP$1,
|
|
1307
|
+
ARROW_RIGHT$1,
|
|
1308
|
+
ARROW_LEFT$1,
|
|
1244
1309
|
HOME,
|
|
1245
1310
|
END
|
|
1246
1311
|
]);
|
|
@@ -1275,17 +1340,17 @@ var AccordionTrigger_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
1275
1340
|
else nextIndex = thisIndex - 1;
|
|
1276
1341
|
}
|
|
1277
1342
|
switch (event.key) {
|
|
1278
|
-
case ARROW_DOWN:
|
|
1343
|
+
case ARROW_DOWN$1:
|
|
1279
1344
|
if (!isHorizontal) toNext();
|
|
1280
1345
|
break;
|
|
1281
|
-
case ARROW_UP:
|
|
1346
|
+
case ARROW_UP$1:
|
|
1282
1347
|
if (!isHorizontal) toPrev();
|
|
1283
1348
|
break;
|
|
1284
|
-
case ARROW_RIGHT:
|
|
1349
|
+
case ARROW_RIGHT$1:
|
|
1285
1350
|
if (isHorizontal) if (isRtl) toPrev();
|
|
1286
1351
|
else toNext();
|
|
1287
1352
|
break;
|
|
1288
|
-
case ARROW_LEFT:
|
|
1353
|
+
case ARROW_LEFT$1:
|
|
1289
1354
|
if (isHorizontal) if (isRtl) toNext();
|
|
1290
1355
|
else toPrev();
|
|
1291
1356
|
break;
|
|
@@ -1759,12 +1824,21 @@ var LabelableProvider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
1759
1824
|
},
|
|
1760
1825
|
setup(__props) {
|
|
1761
1826
|
const props = __props;
|
|
1762
|
-
const
|
|
1827
|
+
const defaultId = useBaseUiId();
|
|
1828
|
+
const initialControlId = props.controlId === void 0 ? defaultId : props.controlId;
|
|
1829
|
+
const controlId = ref(initialControlId);
|
|
1763
1830
|
const labelId = ref(props.labelId);
|
|
1764
1831
|
const messageIds = ref([]);
|
|
1832
|
+
const registrations = /* @__PURE__ */ new Map();
|
|
1765
1833
|
const parent = useLabelableContext();
|
|
1766
|
-
function
|
|
1767
|
-
|
|
1834
|
+
function registerControlId(source, id) {
|
|
1835
|
+
if (id === void 0) registrations.delete(source);
|
|
1836
|
+
else registrations.set(source, id);
|
|
1837
|
+
if (registrations.size === 0) {
|
|
1838
|
+
controlId.value = initialControlId;
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1841
|
+
controlId.value = registrations.values().next().value;
|
|
1768
1842
|
}
|
|
1769
1843
|
function setLabelId(id) {
|
|
1770
1844
|
labelId.value = id;
|
|
@@ -1778,7 +1852,7 @@ var LabelableProvider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
1778
1852
|
}
|
|
1779
1853
|
provide(labelableContextKey, {
|
|
1780
1854
|
controlId,
|
|
1781
|
-
|
|
1855
|
+
registerControlId,
|
|
1782
1856
|
labelId,
|
|
1783
1857
|
setLabelId,
|
|
1784
1858
|
messageIds,
|
|
@@ -1795,14 +1869,6 @@ var LabelableProvider_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
1795
1869
|
//#region src/labelable-provider/LabelableProvider.vue
|
|
1796
1870
|
var LabelableProvider_default = LabelableProvider_vue_vue_type_script_setup_true_lang_default;
|
|
1797
1871
|
|
|
1798
|
-
//#endregion
|
|
1799
|
-
//#region src/field/item/FieldItemContext.ts
|
|
1800
|
-
const defaultContext = { disabled: ref(false) };
|
|
1801
|
-
const fieldItemContextKey = Symbol("FieldItemContext");
|
|
1802
|
-
function useFieldItemContext() {
|
|
1803
|
-
return inject(fieldItemContextKey, defaultContext);
|
|
1804
|
-
}
|
|
1805
|
-
|
|
1806
1872
|
//#endregion
|
|
1807
1873
|
//#region src/field/item/FieldItem.vue?vue&type=script&setup=true&lang.ts
|
|
1808
1874
|
var FieldItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
@@ -1842,7 +1908,12 @@ var FieldItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
1842
1908
|
const props = __props;
|
|
1843
1909
|
const attrs = useAttrs();
|
|
1844
1910
|
const { state, disabled: rootDisabled } = useFieldRootContext(false);
|
|
1845
|
-
|
|
1911
|
+
const disabled = computed(() => rootDisabled.value || props.disabled);
|
|
1912
|
+
const checkboxGroupContext = useCheckboxGroupContext(true);
|
|
1913
|
+
const parentId = computed(() => checkboxGroupContext?.parent.id);
|
|
1914
|
+
const hasParentCheckbox = computed(() => checkboxGroupContext?.allValues.value !== void 0);
|
|
1915
|
+
const controlId = computed(() => hasParentCheckbox.value ? parentId.value : void 0);
|
|
1916
|
+
provide(fieldItemContextKey, { disabled });
|
|
1846
1917
|
const { tag, mergedProps, renderless } = useRenderElement({
|
|
1847
1918
|
componentProps: props,
|
|
1848
1919
|
state,
|
|
@@ -1851,7 +1922,7 @@ var FieldItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
1851
1922
|
defaultTagName: "div"
|
|
1852
1923
|
});
|
|
1853
1924
|
return (_ctx, _cache) => {
|
|
1854
|
-
return openBlock(), createBlock(LabelableProvider_default,
|
|
1925
|
+
return openBlock(), createBlock(LabelableProvider_default, { "control-id": controlId.value }, {
|
|
1855
1926
|
default: withCtx(() => [unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
1856
1927
|
key: 0,
|
|
1857
1928
|
props: unref(mergedProps),
|
|
@@ -1861,7 +1932,7 @@ var FieldItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
1861
1932
|
_: 3
|
|
1862
1933
|
}, 16))]),
|
|
1863
1934
|
_: 3
|
|
1864
|
-
});
|
|
1935
|
+
}, 8, ["control-id"]);
|
|
1865
1936
|
};
|
|
1866
1937
|
}
|
|
1867
1938
|
});
|
|
@@ -1870,6 +1941,69 @@ var FieldItem_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
1870
1941
|
//#region src/field/item/FieldItem.vue
|
|
1871
1942
|
var FieldItem_default = FieldItem_vue_vue_type_script_setup_true_lang_default;
|
|
1872
1943
|
|
|
1944
|
+
//#endregion
|
|
1945
|
+
//#region src/utils/useRegisteredLabelId.ts
|
|
1946
|
+
function useRegisteredLabelId(idProp, setLabelId) {
|
|
1947
|
+
const generatedId = useBaseUiId();
|
|
1948
|
+
const id = computed(() => toValue(idProp) ?? generatedId);
|
|
1949
|
+
watchSyncEffect((onCleanup) => {
|
|
1950
|
+
setLabelId(id.value);
|
|
1951
|
+
onCleanup(() => {
|
|
1952
|
+
setLabelId(void 0);
|
|
1953
|
+
});
|
|
1954
|
+
});
|
|
1955
|
+
return id;
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
//#endregion
|
|
1959
|
+
//#region src/labelable-provider/useLabel.ts
|
|
1960
|
+
function useLabel(params = {}) {
|
|
1961
|
+
const { id: idProp, fallbackControlId, native, setLabelId: setLabelIdProp, focusControl: focusControlProp } = params;
|
|
1962
|
+
const { controlId: contextControlId, setLabelId: setContextLabelId } = useLabelableContext();
|
|
1963
|
+
const syncLabelId = (nextLabelId) => {
|
|
1964
|
+
setContextLabelId(nextLabelId);
|
|
1965
|
+
setLabelIdProp?.(nextLabelId);
|
|
1966
|
+
};
|
|
1967
|
+
const labelId = useRegisteredLabelId(idProp, syncLabelId);
|
|
1968
|
+
const resolvedControlId = computed(() => contextControlId.value ?? toValue(fallbackControlId));
|
|
1969
|
+
const isNative = computed(() => toValue(native) ?? false);
|
|
1970
|
+
function defaultFocusControl(event, controlId) {
|
|
1971
|
+
if (!controlId) return;
|
|
1972
|
+
const controlElement = ownerDocument(event.currentTarget)?.getElementById(controlId);
|
|
1973
|
+
if (isHTMLElement(controlElement)) focusElementWithVisible(controlElement);
|
|
1974
|
+
}
|
|
1975
|
+
function handleInteraction(event) {
|
|
1976
|
+
if (getTarget(event)?.closest("button,input,select,textarea")) return;
|
|
1977
|
+
if (!event.defaultPrevented && event.detail > 1) event.preventDefault();
|
|
1978
|
+
if (isNative.value) return;
|
|
1979
|
+
if (focusControlProp) {
|
|
1980
|
+
focusControlProp(event, resolvedControlId.value);
|
|
1981
|
+
return;
|
|
1982
|
+
}
|
|
1983
|
+
defaultFocusControl(event, resolvedControlId.value);
|
|
1984
|
+
}
|
|
1985
|
+
return {
|
|
1986
|
+
labelId,
|
|
1987
|
+
props: computed(() => {
|
|
1988
|
+
if (isNative.value) return {
|
|
1989
|
+
id: labelId.value,
|
|
1990
|
+
for: resolvedControlId.value ?? void 0,
|
|
1991
|
+
onMousedown: handleInteraction
|
|
1992
|
+
};
|
|
1993
|
+
return {
|
|
1994
|
+
id: labelId.value,
|
|
1995
|
+
onClick: handleInteraction,
|
|
1996
|
+
onPointerdown(event) {
|
|
1997
|
+
event.preventDefault();
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
})
|
|
2001
|
+
};
|
|
2002
|
+
}
|
|
2003
|
+
function focusElementWithVisible(element) {
|
|
2004
|
+
element.focus({ focusVisible: true });
|
|
2005
|
+
}
|
|
2006
|
+
|
|
1873
2007
|
//#endregion
|
|
1874
2008
|
//#region src/field/label/FieldLabel.vue?vue&type=script&setup=true&lang.ts
|
|
1875
2009
|
var FieldLabel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
@@ -1913,40 +2047,18 @@ var FieldLabel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1913
2047
|
const props = __props;
|
|
1914
2048
|
const attrs = useAttrs();
|
|
1915
2049
|
const fieldRootContext = useFieldRootContext(false);
|
|
1916
|
-
const {
|
|
1917
|
-
const
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
const id = labelId.value;
|
|
1921
|
-
setLabelId(id);
|
|
1922
|
-
onCleanup(() => setLabelId(void 0));
|
|
2050
|
+
const { labelId } = useLabelableContext();
|
|
2051
|
+
const label = useLabel({
|
|
2052
|
+
id: computed(() => labelId.value ?? props.id),
|
|
2053
|
+
native: computed(() => props.nativeLabel)
|
|
1923
2054
|
});
|
|
1924
|
-
function handleInteraction(event) {
|
|
1925
|
-
if (event.target?.closest("button,input,select,textarea")) return;
|
|
1926
|
-
if (!event.defaultPrevented && event.detail > 1) event.preventDefault();
|
|
1927
|
-
if (props.nativeLabel || !controlId.value) return;
|
|
1928
|
-
const controlElement = document.getElementById(controlId.value);
|
|
1929
|
-
if (controlElement) controlElement.focus();
|
|
1930
|
-
}
|
|
1931
2055
|
const { tag, mergedProps, renderless } = useRenderElement({
|
|
1932
2056
|
componentProps: props,
|
|
1933
2057
|
state: fieldRootContext.state,
|
|
1934
|
-
props: computed(() => {
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
for: controlId.value ?? void 0,
|
|
1939
|
-
onMousedown: handleInteraction
|
|
1940
|
-
};
|
|
1941
|
-
return {
|
|
1942
|
-
...attrs,
|
|
1943
|
-
id: labelId.value,
|
|
1944
|
-
onClick: handleInteraction,
|
|
1945
|
-
onPointerdown: (event) => {
|
|
1946
|
-
event.preventDefault();
|
|
1947
|
-
}
|
|
1948
|
-
};
|
|
1949
|
-
}),
|
|
2058
|
+
props: computed(() => ({
|
|
2059
|
+
...attrs,
|
|
2060
|
+
...label.props.value
|
|
2061
|
+
})),
|
|
1950
2062
|
stateAttributesMapping: fieldValidityMapping,
|
|
1951
2063
|
defaultTagName: "label"
|
|
1952
2064
|
});
|
|
@@ -2288,8 +2400,15 @@ var FieldRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
2288
2400
|
const controlId = ref(void 0);
|
|
2289
2401
|
const labelId = ref(void 0);
|
|
2290
2402
|
const messageIds = ref([]);
|
|
2291
|
-
|
|
2292
|
-
|
|
2403
|
+
const controlIdRegistrations = /* @__PURE__ */ new Map();
|
|
2404
|
+
function registerControlId(source, id) {
|
|
2405
|
+
if (id === void 0) controlIdRegistrations.delete(source);
|
|
2406
|
+
else controlIdRegistrations.set(source, id);
|
|
2407
|
+
if (controlIdRegistrations.size === 0) {
|
|
2408
|
+
controlId.value = void 0;
|
|
2409
|
+
return;
|
|
2410
|
+
}
|
|
2411
|
+
controlId.value = controlIdRegistrations.values().next().value;
|
|
2293
2412
|
}
|
|
2294
2413
|
function setLabelId(id) {
|
|
2295
2414
|
labelId.value = id;
|
|
@@ -2303,7 +2422,7 @@ var FieldRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
2303
2422
|
}
|
|
2304
2423
|
provide(labelableContextKey, {
|
|
2305
2424
|
controlId,
|
|
2306
|
-
|
|
2425
|
+
registerControlId,
|
|
2307
2426
|
labelId,
|
|
2308
2427
|
setLabelId,
|
|
2309
2428
|
messageIds,
|
|
@@ -2575,6 +2694,2982 @@ var FieldsetRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
|
|
|
2575
2694
|
//#region src/fieldset/root/FieldsetRoot.vue
|
|
2576
2695
|
var FieldsetRoot_default = FieldsetRoot_vue_vue_type_script_setup_true_lang_default;
|
|
2577
2696
|
|
|
2697
|
+
//#endregion
|
|
2698
|
+
//#region src/separator/Separator.vue?vue&type=script&setup=true&lang.ts
|
|
2699
|
+
/**
|
|
2700
|
+
* A separator element accessible to screen readers.
|
|
2701
|
+
* Renders a `<div>` element.
|
|
2702
|
+
*
|
|
2703
|
+
* Documentation: [Base UI Vue Separator](https://baseui-vue.com/docs/components/separator)
|
|
2704
|
+
*/
|
|
2705
|
+
var Separator_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
2706
|
+
name: "Separator",
|
|
2707
|
+
inheritAttrs: false,
|
|
2708
|
+
__name: "Separator",
|
|
2709
|
+
props: {
|
|
2710
|
+
orientation: {
|
|
2711
|
+
type: String,
|
|
2712
|
+
required: false,
|
|
2713
|
+
default: "horizontal"
|
|
2714
|
+
},
|
|
2715
|
+
as: {
|
|
2716
|
+
type: null,
|
|
2717
|
+
required: false,
|
|
2718
|
+
default: "div"
|
|
2719
|
+
},
|
|
2720
|
+
class: {
|
|
2721
|
+
type: Function,
|
|
2722
|
+
required: false,
|
|
2723
|
+
skipCheck: true
|
|
2724
|
+
},
|
|
2725
|
+
style: {
|
|
2726
|
+
type: [
|
|
2727
|
+
Boolean,
|
|
2728
|
+
null,
|
|
2729
|
+
String,
|
|
2730
|
+
Object,
|
|
2731
|
+
Array,
|
|
2732
|
+
Function
|
|
2733
|
+
],
|
|
2734
|
+
required: false,
|
|
2735
|
+
skipCheck: true
|
|
2736
|
+
}
|
|
2737
|
+
},
|
|
2738
|
+
setup(__props) {
|
|
2739
|
+
const props = __props;
|
|
2740
|
+
const attrs = useAttrs();
|
|
2741
|
+
const state = computed(() => ({ orientation: props.orientation }));
|
|
2742
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
2743
|
+
componentProps: props,
|
|
2744
|
+
state,
|
|
2745
|
+
props: computed(() => ({
|
|
2746
|
+
...attrs,
|
|
2747
|
+
"role": "separator",
|
|
2748
|
+
"aria-orientation": props.orientation
|
|
2749
|
+
})),
|
|
2750
|
+
defaultTagName: "div"
|
|
2751
|
+
});
|
|
2752
|
+
return (_ctx, _cache) => {
|
|
2753
|
+
return unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
2754
|
+
key: 0,
|
|
2755
|
+
ref: unref(renderRef),
|
|
2756
|
+
props: unref(mergedProps),
|
|
2757
|
+
state: state.value
|
|
2758
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
2759
|
+
key: 1,
|
|
2760
|
+
ref: unref(renderRef)
|
|
2761
|
+
}, unref(mergedProps)), {
|
|
2762
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { state: state.value })]),
|
|
2763
|
+
_: 3
|
|
2764
|
+
}, 16));
|
|
2765
|
+
};
|
|
2766
|
+
}
|
|
2767
|
+
});
|
|
2768
|
+
|
|
2769
|
+
//#endregion
|
|
2770
|
+
//#region src/separator/Separator.vue
|
|
2771
|
+
var Separator_default = Separator_vue_vue_type_script_setup_true_lang_default;
|
|
2772
|
+
|
|
2773
|
+
//#endregion
|
|
2774
|
+
//#region src/separator/SeparatorDataAttributes.ts
|
|
2775
|
+
let SeparatorDataAttributes = /* @__PURE__ */ function(SeparatorDataAttributes) {
|
|
2776
|
+
/**
|
|
2777
|
+
* Indicates the orientation of the separator.
|
|
2778
|
+
* @type {'horizontal' | 'vertical'}
|
|
2779
|
+
*/
|
|
2780
|
+
SeparatorDataAttributes["orientation"] = "data-orientation";
|
|
2781
|
+
return SeparatorDataAttributes;
|
|
2782
|
+
}({});
|
|
2783
|
+
|
|
2784
|
+
//#endregion
|
|
2785
|
+
//#region src/utils/valueToPercent.ts
|
|
2786
|
+
function valueToPercent(value, min, max) {
|
|
2787
|
+
if (max === min) return 0;
|
|
2788
|
+
return (value - min) * 100 / (max - min);
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
//#endregion
|
|
2792
|
+
//#region src/slider/indicator/SliderIndicator.vue?vue&type=script&setup=true&lang.ts
|
|
2793
|
+
/**
|
|
2794
|
+
* Visualizes the current value of the slider.
|
|
2795
|
+
* Renders a `<div>` element.
|
|
2796
|
+
*
|
|
2797
|
+
* Documentation: [Base UI Vue Slider](https://baseui-vue.com/docs/components/slider)
|
|
2798
|
+
*/
|
|
2799
|
+
var SliderIndicator_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
2800
|
+
name: "SliderIndicator",
|
|
2801
|
+
inheritAttrs: false,
|
|
2802
|
+
__name: "SliderIndicator",
|
|
2803
|
+
props: {
|
|
2804
|
+
as: {
|
|
2805
|
+
type: null,
|
|
2806
|
+
required: false,
|
|
2807
|
+
default: "div"
|
|
2808
|
+
},
|
|
2809
|
+
class: {
|
|
2810
|
+
type: Function,
|
|
2811
|
+
required: false,
|
|
2812
|
+
skipCheck: true
|
|
2813
|
+
},
|
|
2814
|
+
style: {
|
|
2815
|
+
type: [
|
|
2816
|
+
Boolean,
|
|
2817
|
+
null,
|
|
2818
|
+
String,
|
|
2819
|
+
Object,
|
|
2820
|
+
Array,
|
|
2821
|
+
Function
|
|
2822
|
+
],
|
|
2823
|
+
required: false,
|
|
2824
|
+
skipCheck: true
|
|
2825
|
+
}
|
|
2826
|
+
},
|
|
2827
|
+
setup(__props) {
|
|
2828
|
+
const props = __props;
|
|
2829
|
+
function getInsetStyles(vertical, range, start, end, renderBeforeHydration, mounted) {
|
|
2830
|
+
const visibility = start === void 0 || range && end === void 0 ? "hidden" : void 0;
|
|
2831
|
+
const startEdge = vertical ? "bottom" : "insetInlineStart";
|
|
2832
|
+
const mainSide = vertical ? "height" : "width";
|
|
2833
|
+
const styles = {
|
|
2834
|
+
visibility: renderBeforeHydration && !mounted ? "hidden" : visibility,
|
|
2835
|
+
position: vertical ? "absolute" : "relative",
|
|
2836
|
+
[vertical ? "width" : "height"]: "inherit"
|
|
2837
|
+
};
|
|
2838
|
+
styles["--start-position"] = `${start ?? 0}%`;
|
|
2839
|
+
if (!range) {
|
|
2840
|
+
styles[startEdge] = 0;
|
|
2841
|
+
styles[mainSide] = "var(--start-position)";
|
|
2842
|
+
return styles;
|
|
2843
|
+
}
|
|
2844
|
+
styles["--relative-size"] = `${(end ?? 0) - (start ?? 0)}%`;
|
|
2845
|
+
styles[startEdge] = "var(--start-position)";
|
|
2846
|
+
styles[mainSide] = "var(--relative-size)";
|
|
2847
|
+
return styles;
|
|
2848
|
+
}
|
|
2849
|
+
function getCenteredStyles(vertical, range, start, end) {
|
|
2850
|
+
const startEdge = vertical ? "bottom" : "insetInlineStart";
|
|
2851
|
+
const mainSide = vertical ? "height" : "width";
|
|
2852
|
+
const styles = {
|
|
2853
|
+
position: vertical ? "absolute" : "relative",
|
|
2854
|
+
[vertical ? "width" : "height"]: "inherit"
|
|
2855
|
+
};
|
|
2856
|
+
if (!range) {
|
|
2857
|
+
styles[startEdge] = 0;
|
|
2858
|
+
styles[mainSide] = `${start}%`;
|
|
2859
|
+
return styles;
|
|
2860
|
+
}
|
|
2861
|
+
styles[startEdge] = `${start}%`;
|
|
2862
|
+
styles[mainSide] = `${end - start}%`;
|
|
2863
|
+
return styles;
|
|
2864
|
+
}
|
|
2865
|
+
const attrs = useAttrs();
|
|
2866
|
+
const rootContext = useSliderRootContext();
|
|
2867
|
+
const isMounted = ref(false);
|
|
2868
|
+
onMounted(() => {
|
|
2869
|
+
isMounted.value = true;
|
|
2870
|
+
});
|
|
2871
|
+
const vertical = computed(() => rootContext.orientation.value === "vertical");
|
|
2872
|
+
const range = computed(() => rootContext.values.value.length > 1);
|
|
2873
|
+
const style = computed(() => rootContext.inset.value ? getInsetStyles(vertical.value, range.value, rootContext.indicatorPosition.value[0], rootContext.indicatorPosition.value[1], rootContext.renderBeforeHydration.value, isMounted.value) : getCenteredStyles(vertical.value, range.value, valueToPercent(rootContext.values.value[0], rootContext.min.value, rootContext.max.value), valueToPercent(rootContext.values.value[rootContext.values.value.length - 1], rootContext.min.value, rootContext.max.value)));
|
|
2874
|
+
const indicatorProps = computed(() => mergeProps$1(attrs, {
|
|
2875
|
+
"data-base-ui-slider-indicator": rootContext.renderBeforeHydration.value ? "" : void 0,
|
|
2876
|
+
"style": style.value,
|
|
2877
|
+
"suppressHydrationWarning": rootContext.renderBeforeHydration.value || void 0
|
|
2878
|
+
}));
|
|
2879
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
2880
|
+
componentProps: props,
|
|
2881
|
+
state: rootContext.state,
|
|
2882
|
+
props: indicatorProps,
|
|
2883
|
+
defaultTagName: "div",
|
|
2884
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
2885
|
+
});
|
|
2886
|
+
return (_ctx, _cache) => {
|
|
2887
|
+
return unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
2888
|
+
key: 0,
|
|
2889
|
+
ref: unref(renderRef),
|
|
2890
|
+
props: unref(mergedProps),
|
|
2891
|
+
state: unref(rootContext).state
|
|
2892
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
2893
|
+
key: 1,
|
|
2894
|
+
ref: unref(renderRef)
|
|
2895
|
+
}, unref(mergedProps)), {
|
|
2896
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
2897
|
+
_: 3
|
|
2898
|
+
}, 16));
|
|
2899
|
+
};
|
|
2900
|
+
}
|
|
2901
|
+
});
|
|
2902
|
+
|
|
2903
|
+
//#endregion
|
|
2904
|
+
//#region src/slider/indicator/SliderIndicator.vue
|
|
2905
|
+
var SliderIndicator_default = SliderIndicator_vue_vue_type_script_setup_true_lang_default;
|
|
2906
|
+
|
|
2907
|
+
//#endregion
|
|
2908
|
+
//#region src/slider/indicator/SliderIndicatorDataAttributes.ts
|
|
2909
|
+
let SliderIndicatorDataAttributes = /* @__PURE__ */ function(SliderIndicatorDataAttributes) {
|
|
2910
|
+
/**
|
|
2911
|
+
* Present while the user is dragging.
|
|
2912
|
+
*/
|
|
2913
|
+
SliderIndicatorDataAttributes["dragging"] = "data-dragging";
|
|
2914
|
+
/**
|
|
2915
|
+
* Indicates the orientation of the slider.
|
|
2916
|
+
* @type {'horizontal' | 'vertical'}
|
|
2917
|
+
*/
|
|
2918
|
+
SliderIndicatorDataAttributes["orientation"] = "data-orientation";
|
|
2919
|
+
/**
|
|
2920
|
+
* Present when the slider is disabled.
|
|
2921
|
+
*/
|
|
2922
|
+
SliderIndicatorDataAttributes["disabled"] = "data-disabled";
|
|
2923
|
+
/**
|
|
2924
|
+
* Present when the slider is in valid state (when wrapped in Field.Root).
|
|
2925
|
+
*/
|
|
2926
|
+
SliderIndicatorDataAttributes["valid"] = "data-valid";
|
|
2927
|
+
/**
|
|
2928
|
+
* Present when the slider is in invalid state (when wrapped in Field.Root).
|
|
2929
|
+
*/
|
|
2930
|
+
SliderIndicatorDataAttributes["invalid"] = "data-invalid";
|
|
2931
|
+
/**
|
|
2932
|
+
* Present when the slider has been touched (when wrapped in Field.Root).
|
|
2933
|
+
*/
|
|
2934
|
+
SliderIndicatorDataAttributes["touched"] = "data-touched";
|
|
2935
|
+
/**
|
|
2936
|
+
* Present when the slider's value has changed (when wrapped in Field.Root).
|
|
2937
|
+
*/
|
|
2938
|
+
SliderIndicatorDataAttributes["dirty"] = "data-dirty";
|
|
2939
|
+
/**
|
|
2940
|
+
* Present when the slider is focused (when wrapped in Field.Root).
|
|
2941
|
+
*/
|
|
2942
|
+
SliderIndicatorDataAttributes["focused"] = "data-focused";
|
|
2943
|
+
return SliderIndicatorDataAttributes;
|
|
2944
|
+
}({});
|
|
2945
|
+
|
|
2946
|
+
//#endregion
|
|
2947
|
+
//#region src/slider/label/SliderLabel.vue?vue&type=script&setup=true&lang.ts
|
|
2948
|
+
/**
|
|
2949
|
+
* An accessible label that is automatically associated with the slider thumbs.
|
|
2950
|
+
* Renders a `<div>` element.
|
|
2951
|
+
*
|
|
2952
|
+
* Documentation: [Base UI Vue Slider](https://baseui-vue.com/docs/components/slider)
|
|
2953
|
+
*/
|
|
2954
|
+
var SliderLabel_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
2955
|
+
name: "SliderLabel",
|
|
2956
|
+
inheritAttrs: false,
|
|
2957
|
+
__name: "SliderLabel",
|
|
2958
|
+
props: {
|
|
2959
|
+
as: {
|
|
2960
|
+
type: null,
|
|
2961
|
+
required: false,
|
|
2962
|
+
default: "div"
|
|
2963
|
+
},
|
|
2964
|
+
class: {
|
|
2965
|
+
type: Function,
|
|
2966
|
+
required: false,
|
|
2967
|
+
skipCheck: true
|
|
2968
|
+
},
|
|
2969
|
+
style: {
|
|
2970
|
+
type: [
|
|
2971
|
+
Boolean,
|
|
2972
|
+
null,
|
|
2973
|
+
String,
|
|
2974
|
+
Object,
|
|
2975
|
+
Array,
|
|
2976
|
+
Function
|
|
2977
|
+
],
|
|
2978
|
+
required: false,
|
|
2979
|
+
skipCheck: true
|
|
2980
|
+
}
|
|
2981
|
+
},
|
|
2982
|
+
setup(__props) {
|
|
2983
|
+
const props = __props;
|
|
2984
|
+
const attrs = useAttrs();
|
|
2985
|
+
const rootContext = useSliderRootContext();
|
|
2986
|
+
const label = useLabel({
|
|
2987
|
+
id: computed(() => rootContext.rootLabelId.value),
|
|
2988
|
+
fallbackControlId: computed(() => rootContext.controlRef.value?.id),
|
|
2989
|
+
setLabelId: rootContext.setLabelId,
|
|
2990
|
+
focusControl(_event, controlId) {
|
|
2991
|
+
if (controlId) {
|
|
2992
|
+
const controlElement = rootContext.controlRef.value ? ownerDocument(rootContext.controlRef.value)?.getElementById(controlId) : null;
|
|
2993
|
+
if (isHTMLElement(controlElement)) {
|
|
2994
|
+
focusElementWithVisible(controlElement);
|
|
2995
|
+
return;
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
const fallbackInputs = rootContext.controlRef.value?.querySelectorAll("input[type=\"range\"]");
|
|
2999
|
+
const fallbackInput = fallbackInputs?.length === 1 ? fallbackInputs[0] : null;
|
|
3000
|
+
if (isHTMLElement(fallbackInput)) focusElementWithVisible(fallbackInput);
|
|
3001
|
+
}
|
|
3002
|
+
});
|
|
3003
|
+
const labelProps = computed(() => mergeProps$1(attrs, label.props.value));
|
|
3004
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
3005
|
+
componentProps: props,
|
|
3006
|
+
state: rootContext.state,
|
|
3007
|
+
props: labelProps,
|
|
3008
|
+
defaultTagName: "div",
|
|
3009
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
3010
|
+
});
|
|
3011
|
+
return (_ctx, _cache) => {
|
|
3012
|
+
return unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
3013
|
+
key: 0,
|
|
3014
|
+
ref: unref(renderRef),
|
|
3015
|
+
props: unref(mergedProps),
|
|
3016
|
+
state: unref(rootContext).state
|
|
3017
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
3018
|
+
key: 1,
|
|
3019
|
+
ref: unref(renderRef)
|
|
3020
|
+
}, unref(mergedProps)), {
|
|
3021
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
3022
|
+
_: 3
|
|
3023
|
+
}, 16));
|
|
3024
|
+
};
|
|
3025
|
+
}
|
|
3026
|
+
});
|
|
3027
|
+
|
|
3028
|
+
//#endregion
|
|
3029
|
+
//#region src/slider/label/SliderLabel.vue
|
|
3030
|
+
var SliderLabel_default = SliderLabel_vue_vue_type_script_setup_true_lang_default;
|
|
3031
|
+
|
|
3032
|
+
//#endregion
|
|
3033
|
+
//#region src/utils/areArraysEqual.ts
|
|
3034
|
+
function areArraysEqual(array1, array2, itemComparer = (a, b) => a === b) {
|
|
3035
|
+
return array1.length === array2.length && array1.every((value, index) => itemComparer(value, array2[index]));
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
//#endregion
|
|
3039
|
+
//#region src/utils/resolveAriaLabelledBy.ts
|
|
3040
|
+
function getDefaultLabelId(id) {
|
|
3041
|
+
return id == null ? void 0 : `${id}-label`;
|
|
3042
|
+
}
|
|
3043
|
+
function resolveAriaLabelledBy(fieldLabelId, localLabelId) {
|
|
3044
|
+
return fieldLabelId ?? localLabelId;
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
//#endregion
|
|
3048
|
+
//#region src/slider/utils/asc.ts
|
|
3049
|
+
function asc(a, b) {
|
|
3050
|
+
return a - b;
|
|
3051
|
+
}
|
|
3052
|
+
|
|
3053
|
+
//#endregion
|
|
3054
|
+
//#region src/slider/utils/replaceArrayItemAtIndex.ts
|
|
3055
|
+
function replaceArrayItemAtIndex(array, index, newValue) {
|
|
3056
|
+
if (!Number.isInteger(index) || index < 0 || index >= array.length) throw new RangeError(`replaceArrayItemAtIndex index out of bounds: ${index}`);
|
|
3057
|
+
const output = array.slice();
|
|
3058
|
+
output[index] = newValue;
|
|
3059
|
+
return output.sort(asc);
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
//#endregion
|
|
3063
|
+
//#region src/slider/utils/getSliderValue.ts
|
|
3064
|
+
function getSliderValue(valueInput, index, min, max, range, values) {
|
|
3065
|
+
let newValue = valueInput;
|
|
3066
|
+
newValue = clamp(newValue, min, max);
|
|
3067
|
+
if (range) newValue = replaceArrayItemAtIndex(values, index, clamp(newValue, values[index - 1] ?? -Infinity, values[index + 1] ?? Infinity));
|
|
3068
|
+
return newValue;
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
//#endregion
|
|
3072
|
+
//#region src/slider/root/SliderRoot.vue?vue&type=script&setup=true&lang.ts
|
|
3073
|
+
/**
|
|
3074
|
+
* Groups all parts of the slider.
|
|
3075
|
+
* Renders a `<div>` element.
|
|
3076
|
+
*
|
|
3077
|
+
* Documentation: [Base UI Vue Slider](https://baseui-vue.com/docs/components/slider)
|
|
3078
|
+
*/
|
|
3079
|
+
var SliderRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
3080
|
+
name: "SliderRoot",
|
|
3081
|
+
inheritAttrs: false,
|
|
3082
|
+
__name: "SliderRoot",
|
|
3083
|
+
props: {
|
|
3084
|
+
defaultValue: {
|
|
3085
|
+
type: null,
|
|
3086
|
+
required: false
|
|
3087
|
+
},
|
|
3088
|
+
disabled: {
|
|
3089
|
+
type: Boolean,
|
|
3090
|
+
required: false,
|
|
3091
|
+
default: false
|
|
3092
|
+
},
|
|
3093
|
+
format: {
|
|
3094
|
+
type: null,
|
|
3095
|
+
required: false
|
|
3096
|
+
},
|
|
3097
|
+
locale: {
|
|
3098
|
+
type: null,
|
|
3099
|
+
required: false
|
|
3100
|
+
},
|
|
3101
|
+
max: {
|
|
3102
|
+
type: Number,
|
|
3103
|
+
required: false,
|
|
3104
|
+
default: 100
|
|
3105
|
+
},
|
|
3106
|
+
min: {
|
|
3107
|
+
type: Number,
|
|
3108
|
+
required: false,
|
|
3109
|
+
default: 0
|
|
3110
|
+
},
|
|
3111
|
+
minStepsBetweenValues: {
|
|
3112
|
+
type: Number,
|
|
3113
|
+
required: false,
|
|
3114
|
+
default: 0
|
|
3115
|
+
},
|
|
3116
|
+
name: {
|
|
3117
|
+
type: String,
|
|
3118
|
+
required: false
|
|
3119
|
+
},
|
|
3120
|
+
form: {
|
|
3121
|
+
type: String,
|
|
3122
|
+
required: false
|
|
3123
|
+
},
|
|
3124
|
+
orientation: {
|
|
3125
|
+
type: String,
|
|
3126
|
+
required: false,
|
|
3127
|
+
default: "horizontal"
|
|
3128
|
+
},
|
|
3129
|
+
step: {
|
|
3130
|
+
type: Number,
|
|
3131
|
+
required: false,
|
|
3132
|
+
default: 1
|
|
3133
|
+
},
|
|
3134
|
+
largeStep: {
|
|
3135
|
+
type: Number,
|
|
3136
|
+
required: false,
|
|
3137
|
+
default: 10
|
|
3138
|
+
},
|
|
3139
|
+
thumbAlignment: {
|
|
3140
|
+
type: String,
|
|
3141
|
+
required: false,
|
|
3142
|
+
default: "center"
|
|
3143
|
+
},
|
|
3144
|
+
thumbCollisionBehavior: {
|
|
3145
|
+
type: String,
|
|
3146
|
+
required: false,
|
|
3147
|
+
default: "push"
|
|
3148
|
+
},
|
|
3149
|
+
value: {
|
|
3150
|
+
type: null,
|
|
3151
|
+
required: false
|
|
3152
|
+
},
|
|
3153
|
+
id: {
|
|
3154
|
+
type: String,
|
|
3155
|
+
required: false
|
|
3156
|
+
},
|
|
3157
|
+
ariaLabelledby: {
|
|
3158
|
+
type: String,
|
|
3159
|
+
required: false
|
|
3160
|
+
},
|
|
3161
|
+
as: {
|
|
3162
|
+
type: null,
|
|
3163
|
+
required: false,
|
|
3164
|
+
default: "div"
|
|
3165
|
+
},
|
|
3166
|
+
class: {
|
|
3167
|
+
type: Function,
|
|
3168
|
+
required: false,
|
|
3169
|
+
skipCheck: true
|
|
3170
|
+
},
|
|
3171
|
+
style: {
|
|
3172
|
+
type: [
|
|
3173
|
+
Boolean,
|
|
3174
|
+
null,
|
|
3175
|
+
String,
|
|
3176
|
+
Object,
|
|
3177
|
+
Array,
|
|
3178
|
+
Function
|
|
3179
|
+
],
|
|
3180
|
+
required: false,
|
|
3181
|
+
skipCheck: true
|
|
3182
|
+
}
|
|
3183
|
+
},
|
|
3184
|
+
emits: ["valueChange", "valueCommitted"],
|
|
3185
|
+
setup(__props, { emit: __emit }) {
|
|
3186
|
+
const props = __props;
|
|
3187
|
+
const emit = __emit;
|
|
3188
|
+
const attrs = useAttrs();
|
|
3189
|
+
const attrsObject = attrs;
|
|
3190
|
+
const explicitAriaLabelledBy = computed(() => props.ariaLabelledby ?? attrs["aria-labelledby"]);
|
|
3191
|
+
const id = useBaseUiId(props.id);
|
|
3192
|
+
const idRef = computed(() => id);
|
|
3193
|
+
const defaultLabelId = computed(() => getDefaultLabelId(id));
|
|
3194
|
+
const { clearErrors } = useFormContext();
|
|
3195
|
+
const { state: fieldState, disabled: fieldDisabled, name: fieldName, setTouched, setDirty, validation, validityData, shouldValidateOnChange } = useFieldRootContext();
|
|
3196
|
+
const { labelId: fieldLabelId } = useLabelableContext();
|
|
3197
|
+
const localLabelId = ref(void 0);
|
|
3198
|
+
const ariaLabelledBy = computed(() => explicitAriaLabelledBy.value ?? resolveAriaLabelledBy(fieldLabelId.value, localLabelId.value));
|
|
3199
|
+
const disabled = computed(() => fieldDisabled.value || props.disabled);
|
|
3200
|
+
const name = computed(() => fieldName.value ?? props.name);
|
|
3201
|
+
const controllableValue = useControllableState({
|
|
3202
|
+
controlled: () => props.value,
|
|
3203
|
+
default: () => props.defaultValue ?? props.min,
|
|
3204
|
+
name: "Slider",
|
|
3205
|
+
state: "value"
|
|
3206
|
+
});
|
|
3207
|
+
const valueUnwrapped = controllableValue.value;
|
|
3208
|
+
const setValueUnwrapped = controllableValue.setValue;
|
|
3209
|
+
const sliderRef = ref(null);
|
|
3210
|
+
const controlRef = ref(null);
|
|
3211
|
+
const thumbRefs = ref([]);
|
|
3212
|
+
const pressedInputRef = ref(null);
|
|
3213
|
+
const pressedThumbCenterOffsetRef = ref(null);
|
|
3214
|
+
const pressedThumbIndexRef = ref(-1);
|
|
3215
|
+
const pressedValuesRef = ref(null);
|
|
3216
|
+
const lastChangedValueRef = ref(null);
|
|
3217
|
+
const lastChangeReasonRef = ref(REASONS.none);
|
|
3218
|
+
const formatOptionsRef = computed(() => props.format);
|
|
3219
|
+
const active = ref(-1);
|
|
3220
|
+
const lastUsedThumbIndex = ref(-1);
|
|
3221
|
+
const dragging = ref(false);
|
|
3222
|
+
const thumbMap = shallowRef(/* @__PURE__ */ new Map());
|
|
3223
|
+
const indicatorPosition = ref([void 0, void 0]);
|
|
3224
|
+
function setActive(value) {
|
|
3225
|
+
active.value = value;
|
|
3226
|
+
if (value !== -1) lastUsedThumbIndex.value = value;
|
|
3227
|
+
}
|
|
3228
|
+
function registerFieldControlRef(element) {
|
|
3229
|
+
if (element) controlRef.value = element;
|
|
3230
|
+
}
|
|
3231
|
+
function setThumbMap(nextMap) {
|
|
3232
|
+
thumbMap.value = nextMap;
|
|
3233
|
+
}
|
|
3234
|
+
const compositeListProps = {
|
|
3235
|
+
elementsRef: thumbRefs,
|
|
3236
|
+
onMapChange: setThumbMap
|
|
3237
|
+
};
|
|
3238
|
+
const range = computed(() => Array.isArray(valueUnwrapped.value));
|
|
3239
|
+
const values = computed(() => {
|
|
3240
|
+
if (!range.value) return [clamp(valueUnwrapped.value, props.min, props.max)];
|
|
3241
|
+
return [...valueUnwrapped.value].sort(asc);
|
|
3242
|
+
});
|
|
3243
|
+
useField({
|
|
3244
|
+
id: idRef,
|
|
3245
|
+
commit: (value) => validation.commit(value),
|
|
3246
|
+
value: computed(() => valueUnwrapped.value),
|
|
3247
|
+
controlRef,
|
|
3248
|
+
name,
|
|
3249
|
+
getValue: () => valueUnwrapped.value
|
|
3250
|
+
});
|
|
3251
|
+
watch(() => valueUnwrapped.value, () => {
|
|
3252
|
+
clearErrors(name.value);
|
|
3253
|
+
if (shouldValidateOnChange()) validation.commit(valueUnwrapped.value);
|
|
3254
|
+
else validation.commit(valueUnwrapped.value, true);
|
|
3255
|
+
const initialValue = validityData.value.initialValue;
|
|
3256
|
+
let isDirty;
|
|
3257
|
+
if (Array.isArray(valueUnwrapped.value) && Array.isArray(initialValue)) isDirty = !areArraysEqual(valueUnwrapped.value, initialValue);
|
|
3258
|
+
else isDirty = valueUnwrapped.value !== initialValue;
|
|
3259
|
+
setDirty(isDirty);
|
|
3260
|
+
});
|
|
3261
|
+
function areValuesEqual(newValue, oldValue) {
|
|
3262
|
+
if (typeof newValue === "number" && typeof oldValue === "number") return newValue === oldValue;
|
|
3263
|
+
if (Array.isArray(newValue) && Array.isArray(oldValue)) return areArraysEqual(newValue, oldValue);
|
|
3264
|
+
return false;
|
|
3265
|
+
}
|
|
3266
|
+
function setValue(newValue, details) {
|
|
3267
|
+
if (Number.isNaN(newValue) || areValuesEqual(newValue, valueUnwrapped.value)) return;
|
|
3268
|
+
const changeDetails = details ?? createChangeEventDetails(REASONS.none, void 0, void 0, { activeThumbIndex: -1 });
|
|
3269
|
+
lastChangeReasonRef.value = changeDetails.reason;
|
|
3270
|
+
const nativeEvent = changeDetails.event;
|
|
3271
|
+
const clonedEvent = new (nativeEvent.constructor ?? Event)(nativeEvent.type, nativeEvent);
|
|
3272
|
+
Object.defineProperty(clonedEvent, "target", {
|
|
3273
|
+
writable: true,
|
|
3274
|
+
value: {
|
|
3275
|
+
value: newValue,
|
|
3276
|
+
name: name.value
|
|
3277
|
+
}
|
|
3278
|
+
});
|
|
3279
|
+
changeDetails.event = clonedEvent;
|
|
3280
|
+
lastChangedValueRef.value = newValue;
|
|
3281
|
+
emit("valueChange", newValue, changeDetails);
|
|
3282
|
+
if (changeDetails.isCanceled) return;
|
|
3283
|
+
setValueUnwrapped(newValue);
|
|
3284
|
+
}
|
|
3285
|
+
function getSliderChangeEventReason(event) {
|
|
3286
|
+
return event instanceof KeyboardEvent ? REASONS.keyboard : REASONS.inputChange;
|
|
3287
|
+
}
|
|
3288
|
+
function handleInputChange(valueInput, index, event) {
|
|
3289
|
+
const newValue = getSliderValue(valueInput, index, props.min, props.max, range.value, values.value);
|
|
3290
|
+
if (validateMinimumDistance(newValue, props.step, props.minStepsBetweenValues)) {
|
|
3291
|
+
const reason = getSliderChangeEventReason(event);
|
|
3292
|
+
setValue(newValue, createChangeEventDetails(reason, event, void 0, { activeThumbIndex: index }));
|
|
3293
|
+
setTouched(true);
|
|
3294
|
+
emit("valueCommitted", lastChangedValueRef.value ?? newValue, createGenericEventDetails(reason, event));
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
if (process.env.NODE_ENV !== "production" && props.min >= props.max) warn("Slider `max` must be greater than `min`.");
|
|
3298
|
+
watch(() => disabled.value, (nextDisabled) => {
|
|
3299
|
+
const activeEl = sliderRef.value ? activeElement(ownerDocument(sliderRef.value)) : null;
|
|
3300
|
+
if (nextDisabled && activeEl instanceof HTMLElement && contains(sliderRef.value, activeEl)) activeEl.blur();
|
|
3301
|
+
if (nextDisabled && active.value !== -1) setActive(-1);
|
|
3302
|
+
});
|
|
3303
|
+
const state = computed(() => ({
|
|
3304
|
+
...fieldState.value,
|
|
3305
|
+
activeThumbIndex: active.value,
|
|
3306
|
+
disabled: disabled.value,
|
|
3307
|
+
dragging: dragging.value,
|
|
3308
|
+
orientation: props.orientation,
|
|
3309
|
+
max: props.max,
|
|
3310
|
+
min: props.min,
|
|
3311
|
+
minStepsBetweenValues: props.minStepsBetweenValues,
|
|
3312
|
+
step: props.step,
|
|
3313
|
+
values: values.value
|
|
3314
|
+
}));
|
|
3315
|
+
provide(sliderRootContextKey, {
|
|
3316
|
+
active,
|
|
3317
|
+
lastUsedThumbIndex,
|
|
3318
|
+
controlRef,
|
|
3319
|
+
dragging,
|
|
3320
|
+
disabled,
|
|
3321
|
+
validation,
|
|
3322
|
+
formatOptionsRef,
|
|
3323
|
+
handleInputChange,
|
|
3324
|
+
indicatorPosition,
|
|
3325
|
+
inset: computed(() => props.thumbAlignment !== "center"),
|
|
3326
|
+
labelId: computed(() => ariaLabelledBy.value),
|
|
3327
|
+
rootLabelId: defaultLabelId,
|
|
3328
|
+
largeStep: computed(() => props.largeStep),
|
|
3329
|
+
lastChangedValueRef,
|
|
3330
|
+
lastChangeReasonRef,
|
|
3331
|
+
locale: computed(() => props.locale),
|
|
3332
|
+
max: computed(() => props.max),
|
|
3333
|
+
min: computed(() => props.min),
|
|
3334
|
+
minStepsBetweenValues: computed(() => props.minStepsBetweenValues),
|
|
3335
|
+
form: computed(() => props.form),
|
|
3336
|
+
name,
|
|
3337
|
+
onValueCommitted(value, details) {
|
|
3338
|
+
emit("valueCommitted", value, details);
|
|
3339
|
+
},
|
|
3340
|
+
orientation: computed(() => props.orientation),
|
|
3341
|
+
pressedInputRef,
|
|
3342
|
+
pressedThumbCenterOffsetRef,
|
|
3343
|
+
pressedThumbIndexRef,
|
|
3344
|
+
pressedValuesRef,
|
|
3345
|
+
registerFieldControlRef,
|
|
3346
|
+
renderBeforeHydration: computed(() => props.thumbAlignment === "edge"),
|
|
3347
|
+
setActive,
|
|
3348
|
+
setDragging(value) {
|
|
3349
|
+
dragging.value = value;
|
|
3350
|
+
},
|
|
3351
|
+
setIndicatorPosition(updater) {
|
|
3352
|
+
indicatorPosition.value = updater(indicatorPosition.value);
|
|
3353
|
+
},
|
|
3354
|
+
setLabelId(value) {
|
|
3355
|
+
localLabelId.value = value;
|
|
3356
|
+
},
|
|
3357
|
+
setValue,
|
|
3358
|
+
state,
|
|
3359
|
+
step: computed(() => props.step),
|
|
3360
|
+
thumbCollisionBehavior: computed(() => props.thumbCollisionBehavior),
|
|
3361
|
+
thumbMap,
|
|
3362
|
+
thumbRefs,
|
|
3363
|
+
values
|
|
3364
|
+
});
|
|
3365
|
+
const rootProps = computed(() => mergeProps$1(attrsObject, validation.getValidationProps(), {
|
|
3366
|
+
"aria-labelledby": ariaLabelledBy.value,
|
|
3367
|
+
"id": id,
|
|
3368
|
+
"role": "group"
|
|
3369
|
+
}));
|
|
3370
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
3371
|
+
componentProps: props,
|
|
3372
|
+
state,
|
|
3373
|
+
ref: useMergedRefs(sliderRef),
|
|
3374
|
+
props: rootProps,
|
|
3375
|
+
defaultTagName: "div",
|
|
3376
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
3377
|
+
});
|
|
3378
|
+
return (_ctx, _cache) => {
|
|
3379
|
+
return openBlock(), createBlock(CompositeList_default, normalizeProps(guardReactiveProps(compositeListProps)), {
|
|
3380
|
+
default: withCtx(() => [unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
3381
|
+
key: 0,
|
|
3382
|
+
ref: unref(renderRef),
|
|
3383
|
+
props: unref(mergedProps),
|
|
3384
|
+
state: state.value
|
|
3385
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
3386
|
+
key: 1,
|
|
3387
|
+
ref: unref(renderRef)
|
|
3388
|
+
}, unref(mergedProps)), {
|
|
3389
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
3390
|
+
_: 3
|
|
3391
|
+
}, 16))]),
|
|
3392
|
+
_: 3
|
|
3393
|
+
}, 16);
|
|
3394
|
+
};
|
|
3395
|
+
}
|
|
3396
|
+
});
|
|
3397
|
+
|
|
3398
|
+
//#endregion
|
|
3399
|
+
//#region src/slider/root/SliderRoot.vue
|
|
3400
|
+
var SliderRoot_default = SliderRoot_vue_vue_type_script_setup_true_lang_default;
|
|
3401
|
+
|
|
3402
|
+
//#endregion
|
|
3403
|
+
//#region src/slider/root/SliderRootDataAttributes.ts
|
|
3404
|
+
let SliderRootDataAttributes = /* @__PURE__ */ function(SliderRootDataAttributes) {
|
|
3405
|
+
/**
|
|
3406
|
+
* Present while the user is dragging.
|
|
3407
|
+
*/
|
|
3408
|
+
SliderRootDataAttributes["dragging"] = "data-dragging";
|
|
3409
|
+
/**
|
|
3410
|
+
* Indicates the orientation of the slider.
|
|
3411
|
+
* @type {'horizontal' | 'vertical'}
|
|
3412
|
+
*/
|
|
3413
|
+
SliderRootDataAttributes["orientation"] = "data-orientation";
|
|
3414
|
+
/**
|
|
3415
|
+
* Present when the slider is disabled.
|
|
3416
|
+
*/
|
|
3417
|
+
SliderRootDataAttributes["disabled"] = "data-disabled";
|
|
3418
|
+
/**
|
|
3419
|
+
* Present when the slider is in valid state (when wrapped in Field.Root).
|
|
3420
|
+
*/
|
|
3421
|
+
SliderRootDataAttributes["valid"] = "data-valid";
|
|
3422
|
+
/**
|
|
3423
|
+
* Present when the slider is in invalid state (when wrapped in Field.Root).
|
|
3424
|
+
*/
|
|
3425
|
+
SliderRootDataAttributes["invalid"] = "data-invalid";
|
|
3426
|
+
/**
|
|
3427
|
+
* Present when the slider has been touched (when wrapped in Field.Root).
|
|
3428
|
+
*/
|
|
3429
|
+
SliderRootDataAttributes["touched"] = "data-touched";
|
|
3430
|
+
/**
|
|
3431
|
+
* Present when the slider's value has changed (when wrapped in Field.Root).
|
|
3432
|
+
*/
|
|
3433
|
+
SliderRootDataAttributes["dirty"] = "data-dirty";
|
|
3434
|
+
/**
|
|
3435
|
+
* Present when the slider is focused (when wrapped in Field.Root).
|
|
3436
|
+
*/
|
|
3437
|
+
SliderRootDataAttributes["focused"] = "data-focused";
|
|
3438
|
+
return SliderRootDataAttributes;
|
|
3439
|
+
}({});
|
|
3440
|
+
|
|
3441
|
+
//#endregion
|
|
3442
|
+
//#region src/utils/formatNumber.ts
|
|
3443
|
+
function formatNumber(value, locale, options) {
|
|
3444
|
+
return new Intl.NumberFormat(locale, options).format(value);
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
//#endregion
|
|
3448
|
+
//#region src/slider/thumb/prehydrationScript.min.ts
|
|
3449
|
+
const script = "(function prehydration() {\n const firstThumb = document.currentScript?.parentElement\n if (!firstThumb) {\n return\n }\n\n const control = firstThumb.closest('[data-base-ui-slider-control]')\n if (!control) {\n return\n }\n\n const indicator = control.querySelector('[data-base-ui-slider-indicator]')\n const controlRect = control.getBoundingClientRect()\n const vertical = control.getAttribute('data-orientation') === 'vertical'\n const side = vertical ? 'height' : 'width'\n const inputElems = control.querySelectorAll('input[type=\"range\"]')\n const range = inputElems.length > 1\n const lastIndex = inputElems.length - 1\n\n let startPosition = null\n let relativeSize = null\n\n for (let i = 0; i < inputElems.length; i += 1) {\n const input = inputElems[i]\n\n const value = Number.parseFloat(input.getAttribute('value') ?? '')\n\n if (Number.isNaN(value)) {\n return\n }\n\n const thumb = input.parentElement\n if (!thumb) {\n return\n }\n\n const max = Number.parseFloat(input.getAttribute('max') ?? '100')\n const min = Number.parseFloat(input.getAttribute('min') ?? '0')\n\n const thumbRect = thumb?.getBoundingClientRect()\n\n const controlSize = controlRect[side] - thumbRect[side]\n const thumbValuePercent = max === min ? 0 : ((value - min) * 100) / (max - min)\n const thumbOffsetFromControlEdge\n = thumbRect[side] / 2 + (controlSize * thumbValuePercent) / 100\n const percent = (thumbOffsetFromControlEdge / controlRect[side]) * 100\n\n if (Number.isFinite(percent)) {\n thumb.style.setProperty(`--position`, `${percent}%`)\n thumb.style.removeProperty('visibility')\n\n if (indicator) {\n if (i === 0) {\n startPosition = percent\n indicator.style.setProperty('--start-position', `${percent}%`)\n if (!range) {\n indicator.style.removeProperty('visibility')\n }\n }\n else if (i === lastIndex) {\n relativeSize = percent - (startPosition ?? 0)\n indicator.style.setProperty('--end-position', `${percent}%`)\n indicator.style.setProperty('--relative-size', `${relativeSize}%`)\n indicator.style.removeProperty('visibility')\n }\n }\n }\n }\n})()";
|
|
3450
|
+
|
|
3451
|
+
//#endregion
|
|
3452
|
+
//#region src/slider/thumb/SliderThumbDataAttributes.ts
|
|
3453
|
+
let SliderThumbDataAttributes = /* @__PURE__ */ function(SliderThumbDataAttributes) {
|
|
3454
|
+
/**
|
|
3455
|
+
* Indicates the index of the thumb in range sliders.
|
|
3456
|
+
*/
|
|
3457
|
+
SliderThumbDataAttributes["index"] = "data-index";
|
|
3458
|
+
/**
|
|
3459
|
+
* Present while the user is dragging.
|
|
3460
|
+
*/
|
|
3461
|
+
SliderThumbDataAttributes["dragging"] = "data-dragging";
|
|
3462
|
+
/**
|
|
3463
|
+
* Indicates the orientation of the slider.
|
|
3464
|
+
* @type {'horizontal' | 'vertical'}
|
|
3465
|
+
*/
|
|
3466
|
+
SliderThumbDataAttributes["orientation"] = "data-orientation";
|
|
3467
|
+
/**
|
|
3468
|
+
* Present when the slider is disabled.
|
|
3469
|
+
*/
|
|
3470
|
+
SliderThumbDataAttributes["disabled"] = "data-disabled";
|
|
3471
|
+
/**
|
|
3472
|
+
* Present when the slider is in valid state (when wrapped in Field.Root).
|
|
3473
|
+
*/
|
|
3474
|
+
SliderThumbDataAttributes["valid"] = "data-valid";
|
|
3475
|
+
/**
|
|
3476
|
+
* Present when the slider is in invalid state (when wrapped in Field.Root).
|
|
3477
|
+
*/
|
|
3478
|
+
SliderThumbDataAttributes["invalid"] = "data-invalid";
|
|
3479
|
+
/**
|
|
3480
|
+
* Present when the slider has been touched (when wrapped in Field.Root).
|
|
3481
|
+
*/
|
|
3482
|
+
SliderThumbDataAttributes["touched"] = "data-touched";
|
|
3483
|
+
/**
|
|
3484
|
+
* Present when the slider's value has changed (when wrapped in Field.Root).
|
|
3485
|
+
*/
|
|
3486
|
+
SliderThumbDataAttributes["dirty"] = "data-dirty";
|
|
3487
|
+
/**
|
|
3488
|
+
* Present when the slider is focused (when wrapped in Field.Root).
|
|
3489
|
+
*/
|
|
3490
|
+
SliderThumbDataAttributes["focused"] = "data-focused";
|
|
3491
|
+
return SliderThumbDataAttributes;
|
|
3492
|
+
}({});
|
|
3493
|
+
|
|
3494
|
+
//#endregion
|
|
3495
|
+
//#region src/slider/thumb/SliderThumb.vue?vue&type=script&setup=true&lang.ts
|
|
3496
|
+
var SliderThumb_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
3497
|
+
name: "SliderThumb",
|
|
3498
|
+
inheritAttrs: false,
|
|
3499
|
+
__name: "SliderThumb",
|
|
3500
|
+
props: {
|
|
3501
|
+
disabled: {
|
|
3502
|
+
type: Boolean,
|
|
3503
|
+
required: false,
|
|
3504
|
+
default: false
|
|
3505
|
+
},
|
|
3506
|
+
getAriaLabel: {
|
|
3507
|
+
type: [Function, null],
|
|
3508
|
+
required: false
|
|
3509
|
+
},
|
|
3510
|
+
getAriaValueText: {
|
|
3511
|
+
type: [Function, null],
|
|
3512
|
+
required: false
|
|
3513
|
+
},
|
|
3514
|
+
index: {
|
|
3515
|
+
type: Number,
|
|
3516
|
+
required: false
|
|
3517
|
+
},
|
|
3518
|
+
inputRef: {
|
|
3519
|
+
type: [
|
|
3520
|
+
Function,
|
|
3521
|
+
Object,
|
|
3522
|
+
null
|
|
3523
|
+
],
|
|
3524
|
+
required: false
|
|
3525
|
+
},
|
|
3526
|
+
tabIndex: {
|
|
3527
|
+
type: Number,
|
|
3528
|
+
required: false
|
|
3529
|
+
},
|
|
3530
|
+
id: {
|
|
3531
|
+
type: String,
|
|
3532
|
+
required: false
|
|
3533
|
+
},
|
|
3534
|
+
ariaLabel: {
|
|
3535
|
+
type: String,
|
|
3536
|
+
required: false
|
|
3537
|
+
},
|
|
3538
|
+
ariaLabelledby: {
|
|
3539
|
+
type: String,
|
|
3540
|
+
required: false
|
|
3541
|
+
},
|
|
3542
|
+
ariaDescribedby: {
|
|
3543
|
+
type: String,
|
|
3544
|
+
required: false
|
|
3545
|
+
},
|
|
3546
|
+
style: {
|
|
3547
|
+
type: [Object, Function],
|
|
3548
|
+
required: false
|
|
3549
|
+
},
|
|
3550
|
+
as: {
|
|
3551
|
+
type: null,
|
|
3552
|
+
required: false,
|
|
3553
|
+
default: "div"
|
|
3554
|
+
},
|
|
3555
|
+
class: {
|
|
3556
|
+
type: Function,
|
|
3557
|
+
required: false,
|
|
3558
|
+
skipCheck: true
|
|
3559
|
+
}
|
|
3560
|
+
},
|
|
3561
|
+
setup(__props) {
|
|
3562
|
+
const props = __props;
|
|
3563
|
+
const ALL_KEYS = new Set([
|
|
3564
|
+
ARROW_UP$1,
|
|
3565
|
+
ARROW_DOWN$1,
|
|
3566
|
+
ARROW_LEFT$1,
|
|
3567
|
+
ARROW_RIGHT$1,
|
|
3568
|
+
HOME,
|
|
3569
|
+
END,
|
|
3570
|
+
PAGE_UP,
|
|
3571
|
+
PAGE_DOWN
|
|
3572
|
+
]);
|
|
3573
|
+
function getDefaultAriaValueText(values, index, format, locale) {
|
|
3574
|
+
if (index < 0) return;
|
|
3575
|
+
if (values.length === 2) {
|
|
3576
|
+
if (index === 0) return `${formatNumber(values[index], locale, format)} start range`;
|
|
3577
|
+
return `${formatNumber(values[index], locale, format)} end range`;
|
|
3578
|
+
}
|
|
3579
|
+
return format ? formatNumber(values[index], locale, format) : void 0;
|
|
3580
|
+
}
|
|
3581
|
+
function getNewValue(thumbValue, step, direction, min, max) {
|
|
3582
|
+
return direction === 1 ? Math.min(thumbValue + step, max) : Math.max(thumbValue - step, min);
|
|
3583
|
+
}
|
|
3584
|
+
const attrs = useAttrs();
|
|
3585
|
+
const { nonce } = useCSPContext();
|
|
3586
|
+
const direction = useDirection();
|
|
3587
|
+
const rootContext = useSliderRootContext();
|
|
3588
|
+
const { setTouched, setFocused, validationMode, validation } = useFieldRootContext();
|
|
3589
|
+
const id = useBaseUiId(props.id);
|
|
3590
|
+
const disabled = computed(() => props.disabled || rootContext.disabled.value);
|
|
3591
|
+
const range = computed(() => rootContext.values.value.length > 1);
|
|
3592
|
+
const vertical = computed(() => rootContext.orientation.value === "vertical");
|
|
3593
|
+
const rtl = computed(() => direction.value === "rtl");
|
|
3594
|
+
const thumbRef = ref(null);
|
|
3595
|
+
const inputRef = ref(null);
|
|
3596
|
+
const restoringFocusVisibleRef = ref(false);
|
|
3597
|
+
const defaultInputId = useBaseUiId();
|
|
3598
|
+
const labelableId = useLabelableId();
|
|
3599
|
+
const inputId = computed(() => range.value ? defaultInputId : labelableId.value);
|
|
3600
|
+
const { ref: listItemRef, index: compositeIndex } = useCompositeListItem({
|
|
3601
|
+
metadata: () => ({ inputId }),
|
|
3602
|
+
index: () => props.index
|
|
3603
|
+
});
|
|
3604
|
+
const index = computed(() => !range.value ? 0 : props.index ?? compositeIndex.value);
|
|
3605
|
+
const last = computed(() => index.value === rootContext.values.value.length - 1);
|
|
3606
|
+
const thumbValue = computed(() => rootContext.values.value[index.value]);
|
|
3607
|
+
const thumbValuePercent = computed(() => valueToPercent(thumbValue.value, rootContext.min.value, rootContext.max.value));
|
|
3608
|
+
const isMounted = ref(false);
|
|
3609
|
+
const positionPercent = ref(void 0);
|
|
3610
|
+
onMounted(() => {
|
|
3611
|
+
isMounted.value = true;
|
|
3612
|
+
});
|
|
3613
|
+
const safeLastUsedThumbIndex = computed(() => rootContext.lastUsedThumbIndex.value >= 0 && rootContext.lastUsedThumbIndex.value < rootContext.values.value.length ? rootContext.lastUsedThumbIndex.value : -1);
|
|
3614
|
+
function setIndicatorPositionForIndex(nextInsetPosition) {
|
|
3615
|
+
rootContext.setIndicatorPosition((prevPosition) => {
|
|
3616
|
+
const next = [...prevPosition];
|
|
3617
|
+
if (index.value === 0) next[0] = nextInsetPosition;
|
|
3618
|
+
else if (last.value) next[1] = nextInsetPosition;
|
|
3619
|
+
return next;
|
|
3620
|
+
});
|
|
3621
|
+
}
|
|
3622
|
+
function getInsetPosition() {
|
|
3623
|
+
const control = rootContext.controlRef.value;
|
|
3624
|
+
const thumb = thumbRef.value;
|
|
3625
|
+
if (!control || !thumb) return;
|
|
3626
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
3627
|
+
const controlRect = control.getBoundingClientRect();
|
|
3628
|
+
const side = vertical.value ? "height" : "width";
|
|
3629
|
+
const controlSize = controlRect[side] - thumbRect[side];
|
|
3630
|
+
const nextPositionPercent = (thumbRect[side] / 2 + controlSize * thumbValuePercent.value / 100) / controlRect[side] * 100;
|
|
3631
|
+
const nextInsetPosition = Number.isFinite(nextPositionPercent) ? nextPositionPercent : void 0;
|
|
3632
|
+
positionPercent.value = nextInsetPosition;
|
|
3633
|
+
setIndicatorPositionForIndex(nextInsetPosition);
|
|
3634
|
+
}
|
|
3635
|
+
watch(() => [
|
|
3636
|
+
rootContext.inset.value,
|
|
3637
|
+
thumbValuePercent.value,
|
|
3638
|
+
isMounted.value
|
|
3639
|
+
], () => {
|
|
3640
|
+
if (rootContext.inset.value) queueMicrotask(getInsetPosition);
|
|
3641
|
+
}, { immediate: true });
|
|
3642
|
+
watchEffect((onCleanup) => {
|
|
3643
|
+
if (!rootContext.inset.value || typeof ResizeObserver !== "function") return;
|
|
3644
|
+
const control = rootContext.controlRef.value;
|
|
3645
|
+
const thumb = thumbRef.value;
|
|
3646
|
+
if (!control || !thumb) return;
|
|
3647
|
+
const observer = new ResizeObserver(getInsetPosition);
|
|
3648
|
+
observer.observe(control);
|
|
3649
|
+
observer.observe(thumb);
|
|
3650
|
+
onCleanup(() => {
|
|
3651
|
+
observer.disconnect();
|
|
3652
|
+
});
|
|
3653
|
+
});
|
|
3654
|
+
const thumbStyle = computed(() => {
|
|
3655
|
+
const startEdge = vertical.value ? "bottom" : "insetInlineStart";
|
|
3656
|
+
const crossOffsetProperty = vertical.value ? "left" : "top";
|
|
3657
|
+
let zIndex;
|
|
3658
|
+
if (range.value) {
|
|
3659
|
+
if (rootContext.active.value === index.value) zIndex = 2;
|
|
3660
|
+
else if (safeLastUsedThumbIndex.value === index.value) zIndex = 1;
|
|
3661
|
+
} else if (rootContext.active.value === index.value) zIndex = 1;
|
|
3662
|
+
if (!rootContext.inset.value) {
|
|
3663
|
+
if (!Number.isFinite(thumbValuePercent.value)) return visuallyHidden;
|
|
3664
|
+
return {
|
|
3665
|
+
position: "absolute",
|
|
3666
|
+
[startEdge]: `${thumbValuePercent.value}%`,
|
|
3667
|
+
[crossOffsetProperty]: "50%",
|
|
3668
|
+
translate: `${(vertical.value || !rtl.value ? -1 : 1) * 50}% ${(vertical.value ? 1 : -1) * 50}%`,
|
|
3669
|
+
zIndex
|
|
3670
|
+
};
|
|
3671
|
+
}
|
|
3672
|
+
return {
|
|
3673
|
+
"--position": `${positionPercent.value ?? 0}%`,
|
|
3674
|
+
"visibility": rootContext.renderBeforeHydration.value && !isMounted.value || positionPercent.value === void 0 ? "hidden" : void 0,
|
|
3675
|
+
"position": "absolute",
|
|
3676
|
+
[startEdge]: "var(--position)",
|
|
3677
|
+
[crossOffsetProperty]: "50%",
|
|
3678
|
+
"translate": `${(vertical.value || !rtl.value ? -1 : 1) * 50}% ${(vertical.value ? 1 : -1) * 50}%`,
|
|
3679
|
+
zIndex
|
|
3680
|
+
};
|
|
3681
|
+
});
|
|
3682
|
+
const cssWritingMode = computed(() => {
|
|
3683
|
+
if (rootContext.orientation.value === "vertical") return rtl.value ? "vertical-rl" : "vertical-lr";
|
|
3684
|
+
});
|
|
3685
|
+
const ariaLabel = computed(() => typeof props.getAriaLabel === "function" ? props.getAriaLabel(index.value) : props.ariaLabel);
|
|
3686
|
+
function setInputRef(node) {
|
|
3687
|
+
inputRef.value = node;
|
|
3688
|
+
validation.setInputRef(node);
|
|
3689
|
+
const forwardedInputRef = props.inputRef;
|
|
3690
|
+
if (!forwardedInputRef) return;
|
|
3691
|
+
if (typeof forwardedInputRef === "function") forwardedInputRef(node);
|
|
3692
|
+
else forwardedInputRef.value = node;
|
|
3693
|
+
}
|
|
3694
|
+
function setInputVNodeRef(node) {
|
|
3695
|
+
setInputRef(node instanceof HTMLInputElement ? node : null);
|
|
3696
|
+
}
|
|
3697
|
+
function handleBlur(event) {
|
|
3698
|
+
if (restoringFocusVisibleRef.value) {
|
|
3699
|
+
event.stopPropagation();
|
|
3700
|
+
return;
|
|
3701
|
+
}
|
|
3702
|
+
if (!thumbRef.value) return;
|
|
3703
|
+
rootContext.setActive(-1);
|
|
3704
|
+
setTouched(true);
|
|
3705
|
+
setFocused(false);
|
|
3706
|
+
if (validationMode.value === "onBlur") validation.commit(getSliderValue(thumbValue.value, index.value, rootContext.min.value, rootContext.max.value, range.value, rootContext.values.value));
|
|
3707
|
+
}
|
|
3708
|
+
function handleKeydown(event) {
|
|
3709
|
+
if (!ALL_KEYS.has(event.key)) return;
|
|
3710
|
+
if (COMPOSITE_KEYS.has(event.key)) event.stopPropagation();
|
|
3711
|
+
let newValue = null;
|
|
3712
|
+
const roundedValue = roundValueToStep(thumbValue.value, rootContext.step.value, rootContext.min.value);
|
|
3713
|
+
switch (event.key) {
|
|
3714
|
+
case ARROW_UP$1:
|
|
3715
|
+
newValue = getNewValue(roundedValue, event.shiftKey ? rootContext.largeStep.value : rootContext.step.value, 1, rootContext.min.value, rootContext.max.value);
|
|
3716
|
+
break;
|
|
3717
|
+
case ARROW_RIGHT$1:
|
|
3718
|
+
newValue = getNewValue(roundedValue, event.shiftKey ? rootContext.largeStep.value : rootContext.step.value, rtl.value ? -1 : 1, rootContext.min.value, rootContext.max.value);
|
|
3719
|
+
break;
|
|
3720
|
+
case ARROW_DOWN$1:
|
|
3721
|
+
newValue = getNewValue(roundedValue, event.shiftKey ? rootContext.largeStep.value : rootContext.step.value, -1, rootContext.min.value, rootContext.max.value);
|
|
3722
|
+
break;
|
|
3723
|
+
case ARROW_LEFT$1:
|
|
3724
|
+
newValue = getNewValue(roundedValue, event.shiftKey ? rootContext.largeStep.value : rootContext.step.value, rtl.value ? 1 : -1, rootContext.min.value, rootContext.max.value);
|
|
3725
|
+
break;
|
|
3726
|
+
case PAGE_UP:
|
|
3727
|
+
newValue = getNewValue(roundedValue, rootContext.largeStep.value, 1, rootContext.min.value, rootContext.max.value);
|
|
3728
|
+
break;
|
|
3729
|
+
case PAGE_DOWN:
|
|
3730
|
+
newValue = getNewValue(roundedValue, rootContext.largeStep.value, -1, rootContext.min.value, rootContext.max.value);
|
|
3731
|
+
break;
|
|
3732
|
+
case END:
|
|
3733
|
+
newValue = rootContext.max.value;
|
|
3734
|
+
if (range.value) newValue = Number.isFinite(rootContext.values.value[index.value + 1]) ? rootContext.values.value[index.value + 1] - rootContext.step.value * rootContext.minStepsBetweenValues.value : rootContext.max.value;
|
|
3735
|
+
break;
|
|
3736
|
+
case HOME:
|
|
3737
|
+
newValue = rootContext.min.value;
|
|
3738
|
+
if (range.value) newValue = Number.isFinite(rootContext.values.value[index.value - 1]) ? rootContext.values.value[index.value - 1] + rootContext.step.value * rootContext.minStepsBetweenValues.value : rootContext.min.value;
|
|
3739
|
+
break;
|
|
3740
|
+
default: break;
|
|
3741
|
+
}
|
|
3742
|
+
if (newValue !== null) {
|
|
3743
|
+
const input = event.currentTarget;
|
|
3744
|
+
if (!matchesFocusVisible(input)) {
|
|
3745
|
+
restoringFocusVisibleRef.value = true;
|
|
3746
|
+
input.blur();
|
|
3747
|
+
input.focus({
|
|
3748
|
+
preventScroll: true,
|
|
3749
|
+
focusVisible: true
|
|
3750
|
+
});
|
|
3751
|
+
}
|
|
3752
|
+
rootContext.handleInputChange(newValue, index.value, event);
|
|
3753
|
+
rootContext.onValueCommitted(rootContext.lastChangedValueRef.value ?? getSliderValue(newValue, index.value, rootContext.min.value, rootContext.max.value, range.value, rootContext.values.value), createGenericEventDetails(REASONS.keyboard, event));
|
|
3754
|
+
event.preventDefault();
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3757
|
+
const inputStyle = computed(() => ({
|
|
3758
|
+
...visuallyHidden,
|
|
3759
|
+
width: "100%",
|
|
3760
|
+
height: "100%",
|
|
3761
|
+
writingMode: cssWritingMode.value
|
|
3762
|
+
}));
|
|
3763
|
+
const inputValidationProps = computed(() => validation.getInputValidationProps());
|
|
3764
|
+
const forwardedInputAttrs = computed(() => {
|
|
3765
|
+
const attrsObject = attrs;
|
|
3766
|
+
return {
|
|
3767
|
+
onBlur: attrsObject.onBlur,
|
|
3768
|
+
onFocus: attrsObject.onFocus,
|
|
3769
|
+
onKeydown: attrsObject.onKeydown
|
|
3770
|
+
};
|
|
3771
|
+
});
|
|
3772
|
+
const thumbAttrs = computed(() => {
|
|
3773
|
+
const { onBlur: _onBlur, onFocus: _onFocus, onKeydown: _onKeydown, ...rest } = attrs;
|
|
3774
|
+
return rest;
|
|
3775
|
+
});
|
|
3776
|
+
const inputProps = computed(() => mergeProps$1(inputValidationProps.value, forwardedInputAttrs.value, {
|
|
3777
|
+
"aria-label": ariaLabel.value,
|
|
3778
|
+
"aria-labelledby": props.ariaLabelledby ?? (ariaLabel.value == null ? rootContext.labelId.value : void 0),
|
|
3779
|
+
"aria-describedby": props.ariaDescribedby ?? inputValidationProps.value["aria-describedby"],
|
|
3780
|
+
"aria-orientation": rootContext.orientation.value,
|
|
3781
|
+
"aria-valuenow": thumbValue.value,
|
|
3782
|
+
"aria-valuetext": typeof props.getAriaValueText === "function" ? props.getAriaValueText(formatNumber(thumbValue.value, rootContext.locale.value, rootContext.formatOptionsRef.value), thumbValue.value, index.value) : getDefaultAriaValueText(rootContext.values.value, index.value, rootContext.formatOptionsRef.value, rootContext.locale.value),
|
|
3783
|
+
"disabled": disabled.value,
|
|
3784
|
+
"form": rootContext.form.value,
|
|
3785
|
+
"id": inputId.value,
|
|
3786
|
+
"max": rootContext.max.value,
|
|
3787
|
+
"min": rootContext.min.value,
|
|
3788
|
+
"name": rootContext.name.value,
|
|
3789
|
+
onChange(event) {
|
|
3790
|
+
rootContext.handleInputChange(event.currentTarget.valueAsNumber, index.value, event);
|
|
3791
|
+
},
|
|
3792
|
+
onFocus(event) {
|
|
3793
|
+
const isRestoringFocusVisible = restoringFocusVisibleRef.value;
|
|
3794
|
+
restoringFocusVisibleRef.value = false;
|
|
3795
|
+
rootContext.setActive(index.value);
|
|
3796
|
+
setFocused(true);
|
|
3797
|
+
if (isRestoringFocusVisible) event.stopPropagation();
|
|
3798
|
+
},
|
|
3799
|
+
"onBlur": handleBlur,
|
|
3800
|
+
"onKeydown": handleKeydown,
|
|
3801
|
+
"step": rootContext.step.value,
|
|
3802
|
+
"style": inputStyle.value,
|
|
3803
|
+
"tabIndex": props.tabIndex ?? void 0,
|
|
3804
|
+
"type": "range",
|
|
3805
|
+
"value": thumbValue.value ?? ""
|
|
3806
|
+
}));
|
|
3807
|
+
const mergedRef = useMergedRefs(listItemRef, thumbRef);
|
|
3808
|
+
const thumbProps = computed(() => mergeProps$1(thumbAttrs.value, {
|
|
3809
|
+
[SliderThumbDataAttributes.index]: index.value,
|
|
3810
|
+
id,
|
|
3811
|
+
onPointerdown(event) {
|
|
3812
|
+
rootContext.pressedThumbIndexRef.value = index.value;
|
|
3813
|
+
if (thumbRef.value != null) {
|
|
3814
|
+
const axis = rootContext.orientation.value === "horizontal" ? "x" : "y";
|
|
3815
|
+
const midpoint = getMidpoint(thumbRef.value);
|
|
3816
|
+
const offset = (rootContext.orientation.value === "horizontal" ? event.clientX : event.clientY) - midpoint[axis];
|
|
3817
|
+
rootContext.pressedThumbCenterOffsetRef.value = offset;
|
|
3818
|
+
}
|
|
3819
|
+
if (inputRef.value != null && rootContext.pressedInputRef.value !== inputRef.value) rootContext.pressedInputRef.value = inputRef.value;
|
|
3820
|
+
},
|
|
3821
|
+
style: thumbStyle.value,
|
|
3822
|
+
suppressHydrationWarning: rootContext.renderBeforeHydration.value || void 0
|
|
3823
|
+
}));
|
|
3824
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
3825
|
+
componentProps: props,
|
|
3826
|
+
state: rootContext.state,
|
|
3827
|
+
props: thumbProps,
|
|
3828
|
+
defaultTagName: "div",
|
|
3829
|
+
ref: mergedRef,
|
|
3830
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
3831
|
+
});
|
|
3832
|
+
watch(() => rootContext.active.value, () => {
|
|
3833
|
+
if (disabled.value && rootContext.active.value === index.value) rootContext.setActive(-1);
|
|
3834
|
+
});
|
|
3835
|
+
return (_ctx, _cache) => {
|
|
3836
|
+
return unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
3837
|
+
key: 0,
|
|
3838
|
+
ref: unref(renderRef),
|
|
3839
|
+
props: unref(mergedProps),
|
|
3840
|
+
state: unref(rootContext).state
|
|
3841
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
3842
|
+
key: 1,
|
|
3843
|
+
ref: unref(renderRef)
|
|
3844
|
+
}, unref(mergedProps)), {
|
|
3845
|
+
default: withCtx(() => [
|
|
3846
|
+
renderSlot(_ctx.$slots, "default"),
|
|
3847
|
+
createElementVNode("input", mergeProps({ ref: setInputVNodeRef }, inputProps.value), null, 16),
|
|
3848
|
+
createCommentVNode(" eslint-disable-next-line vue/require-component-is "),
|
|
3849
|
+
unref(rootContext).inset.value && !isMounted.value && unref(rootContext).renderBeforeHydration.value && last.value ? (openBlock(), createBlock(resolveDynamicComponent("script"), {
|
|
3850
|
+
key: 0,
|
|
3851
|
+
nonce: unref(nonce),
|
|
3852
|
+
"suppress-hydration-warning": true
|
|
3853
|
+
}, {
|
|
3854
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(script)), 1)]),
|
|
3855
|
+
_: 1
|
|
3856
|
+
}, 8, ["nonce"])) : createCommentVNode("v-if", true)
|
|
3857
|
+
]),
|
|
3858
|
+
_: 3
|
|
3859
|
+
}, 16));
|
|
3860
|
+
};
|
|
3861
|
+
}
|
|
3862
|
+
});
|
|
3863
|
+
|
|
3864
|
+
//#endregion
|
|
3865
|
+
//#region src/slider/thumb/SliderThumb.vue
|
|
3866
|
+
var SliderThumb_default = SliderThumb_vue_vue_type_script_setup_true_lang_default;
|
|
3867
|
+
|
|
3868
|
+
//#endregion
|
|
3869
|
+
//#region src/slider/track/SliderTrack.vue?vue&type=script&setup=true&lang.ts
|
|
3870
|
+
var SliderTrack_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
3871
|
+
name: "SliderTrack",
|
|
3872
|
+
inheritAttrs: false,
|
|
3873
|
+
__name: "SliderTrack",
|
|
3874
|
+
props: {
|
|
3875
|
+
as: {
|
|
3876
|
+
type: null,
|
|
3877
|
+
required: false,
|
|
3878
|
+
default: "div"
|
|
3879
|
+
},
|
|
3880
|
+
class: {
|
|
3881
|
+
type: Function,
|
|
3882
|
+
required: false,
|
|
3883
|
+
skipCheck: true
|
|
3884
|
+
},
|
|
3885
|
+
style: {
|
|
3886
|
+
type: [
|
|
3887
|
+
Boolean,
|
|
3888
|
+
null,
|
|
3889
|
+
String,
|
|
3890
|
+
Object,
|
|
3891
|
+
Array,
|
|
3892
|
+
Function
|
|
3893
|
+
],
|
|
3894
|
+
required: false,
|
|
3895
|
+
skipCheck: true
|
|
3896
|
+
}
|
|
3897
|
+
},
|
|
3898
|
+
setup(__props) {
|
|
3899
|
+
const props = __props;
|
|
3900
|
+
const attrs = useAttrs();
|
|
3901
|
+
const rootContext = useSliderRootContext();
|
|
3902
|
+
const trackProps = computed(() => mergeProps$1(attrs, { style: { position: "relative" } }));
|
|
3903
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
3904
|
+
componentProps: props,
|
|
3905
|
+
state: rootContext.state,
|
|
3906
|
+
props: trackProps,
|
|
3907
|
+
defaultTagName: "div",
|
|
3908
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
3909
|
+
});
|
|
3910
|
+
return (_ctx, _cache) => {
|
|
3911
|
+
return unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
3912
|
+
key: 0,
|
|
3913
|
+
ref: unref(renderRef),
|
|
3914
|
+
props: unref(mergedProps),
|
|
3915
|
+
state: unref(rootContext).state
|
|
3916
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
3917
|
+
key: 1,
|
|
3918
|
+
ref: unref(renderRef)
|
|
3919
|
+
}, unref(mergedProps)), {
|
|
3920
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
3921
|
+
_: 3
|
|
3922
|
+
}, 16));
|
|
3923
|
+
};
|
|
3924
|
+
}
|
|
3925
|
+
});
|
|
3926
|
+
|
|
3927
|
+
//#endregion
|
|
3928
|
+
//#region src/slider/track/SliderTrack.vue
|
|
3929
|
+
var SliderTrack_default = SliderTrack_vue_vue_type_script_setup_true_lang_default;
|
|
3930
|
+
|
|
3931
|
+
//#endregion
|
|
3932
|
+
//#region src/slider/track/SliderTrackDataAttributes.ts
|
|
3933
|
+
let SliderTrackDataAttributes = /* @__PURE__ */ function(SliderTrackDataAttributes) {
|
|
3934
|
+
SliderTrackDataAttributes["dragging"] = "data-dragging";
|
|
3935
|
+
SliderTrackDataAttributes["orientation"] = "data-orientation";
|
|
3936
|
+
SliderTrackDataAttributes["disabled"] = "data-disabled";
|
|
3937
|
+
SliderTrackDataAttributes["valid"] = "data-valid";
|
|
3938
|
+
SliderTrackDataAttributes["invalid"] = "data-invalid";
|
|
3939
|
+
SliderTrackDataAttributes["touched"] = "data-touched";
|
|
3940
|
+
SliderTrackDataAttributes["dirty"] = "data-dirty";
|
|
3941
|
+
SliderTrackDataAttributes["focused"] = "data-focused";
|
|
3942
|
+
return SliderTrackDataAttributes;
|
|
3943
|
+
}({});
|
|
3944
|
+
|
|
3945
|
+
//#endregion
|
|
3946
|
+
//#region src/slider/value/SliderValue.vue?vue&type=script&setup=true&lang.ts
|
|
3947
|
+
/**
|
|
3948
|
+
* Displays the current value of the slider as text.
|
|
3949
|
+
* Renders an `<output>` element.
|
|
3950
|
+
*
|
|
3951
|
+
* Documentation: [Base UI Slider](https://baseui-vue.com/docs/components/slider)
|
|
3952
|
+
*/
|
|
3953
|
+
var SliderValue_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
3954
|
+
name: "SliderValue",
|
|
3955
|
+
inheritAttrs: false,
|
|
3956
|
+
__name: "SliderValue",
|
|
3957
|
+
props: {
|
|
3958
|
+
ariaLive: {
|
|
3959
|
+
type: String,
|
|
3960
|
+
required: false,
|
|
3961
|
+
default: "off"
|
|
3962
|
+
},
|
|
3963
|
+
as: {
|
|
3964
|
+
type: null,
|
|
3965
|
+
required: false,
|
|
3966
|
+
default: "output"
|
|
3967
|
+
},
|
|
3968
|
+
class: {
|
|
3969
|
+
type: Function,
|
|
3970
|
+
required: false,
|
|
3971
|
+
skipCheck: true
|
|
3972
|
+
},
|
|
3973
|
+
style: {
|
|
3974
|
+
type: [
|
|
3975
|
+
Boolean,
|
|
3976
|
+
null,
|
|
3977
|
+
String,
|
|
3978
|
+
Object,
|
|
3979
|
+
Array,
|
|
3980
|
+
Function
|
|
3981
|
+
],
|
|
3982
|
+
required: false,
|
|
3983
|
+
skipCheck: true
|
|
3984
|
+
}
|
|
3985
|
+
},
|
|
3986
|
+
setup(__props) {
|
|
3987
|
+
const props = __props;
|
|
3988
|
+
const attrs = useAttrs();
|
|
3989
|
+
const rootContext = useSliderRootContext();
|
|
3990
|
+
const outputFor = computed(() => {
|
|
3991
|
+
let htmlFor = "";
|
|
3992
|
+
for (const thumbMetadata of rootContext.thumbMap.value.values()) if (thumbMetadata?.inputId) htmlFor += `${thumbMetadata.inputId} `;
|
|
3993
|
+
return htmlFor.trim() === "" ? void 0 : htmlFor.trim();
|
|
3994
|
+
});
|
|
3995
|
+
const formattedValues = computed(() => rootContext.values.value.map((value) => formatNumber(value, rootContext.locale.value, rootContext.formatOptionsRef.value)));
|
|
3996
|
+
const defaultDisplayValue = computed(() => rootContext.values.value.map((value, index) => formattedValues.value[index] || String(value)).join(" – "));
|
|
3997
|
+
const valueProps = computed(() => mergeProps$1(attrs, {
|
|
3998
|
+
"aria-live": props.ariaLive,
|
|
3999
|
+
"for": outputFor.value
|
|
4000
|
+
}));
|
|
4001
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
4002
|
+
componentProps: props,
|
|
4003
|
+
state: rootContext.state,
|
|
4004
|
+
props: valueProps,
|
|
4005
|
+
defaultTagName: "output",
|
|
4006
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
4007
|
+
});
|
|
4008
|
+
return (_ctx, _cache) => {
|
|
4009
|
+
return unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
4010
|
+
key: 0,
|
|
4011
|
+
ref: unref(renderRef),
|
|
4012
|
+
props: unref(mergedProps),
|
|
4013
|
+
state: unref(rootContext).state,
|
|
4014
|
+
formattedValues: formattedValues.value,
|
|
4015
|
+
values: unref(rootContext).values.value
|
|
4016
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
4017
|
+
key: 1,
|
|
4018
|
+
ref: unref(renderRef)
|
|
4019
|
+
}, unref(mergedProps)), {
|
|
4020
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", {
|
|
4021
|
+
formattedValues: formattedValues.value,
|
|
4022
|
+
values: unref(rootContext).values.value
|
|
4023
|
+
}, () => [createTextVNode(toDisplayString(defaultDisplayValue.value), 1)])]),
|
|
4024
|
+
_: 3
|
|
4025
|
+
}, 16));
|
|
4026
|
+
};
|
|
4027
|
+
}
|
|
4028
|
+
});
|
|
4029
|
+
|
|
4030
|
+
//#endregion
|
|
4031
|
+
//#region src/slider/value/SliderValue.vue
|
|
4032
|
+
var SliderValue_default = SliderValue_vue_vue_type_script_setup_true_lang_default;
|
|
4033
|
+
|
|
4034
|
+
//#endregion
|
|
4035
|
+
//#region src/slider/value/SliderValueDataAttributes.ts
|
|
4036
|
+
let SliderValueDataAttributes = /* @__PURE__ */ function(SliderValueDataAttributes) {
|
|
4037
|
+
/**
|
|
4038
|
+
* Present while the user is dragging.
|
|
4039
|
+
*/
|
|
4040
|
+
SliderValueDataAttributes["dragging"] = "data-dragging";
|
|
4041
|
+
/**
|
|
4042
|
+
* Indicates the orientation of the slider.
|
|
4043
|
+
* @type {'horizontal' | 'vertical'}
|
|
4044
|
+
*/
|
|
4045
|
+
SliderValueDataAttributes["orientation"] = "data-orientation";
|
|
4046
|
+
/**
|
|
4047
|
+
* Present when the slider is disabled.
|
|
4048
|
+
*/
|
|
4049
|
+
SliderValueDataAttributes["disabled"] = "data-disabled";
|
|
4050
|
+
/**
|
|
4051
|
+
* Present when the slider is in valid state (when wrapped in Field.Root).
|
|
4052
|
+
*/
|
|
4053
|
+
SliderValueDataAttributes["valid"] = "data-valid";
|
|
4054
|
+
/**
|
|
4055
|
+
* Present when the slider is in invalid state (when wrapped in Field.Root).
|
|
4056
|
+
*/
|
|
4057
|
+
SliderValueDataAttributes["invalid"] = "data-invalid";
|
|
4058
|
+
/**
|
|
4059
|
+
* Present when the slider has been touched (when wrapped in Field.Root).
|
|
4060
|
+
*/
|
|
4061
|
+
SliderValueDataAttributes["touched"] = "data-touched";
|
|
4062
|
+
/**
|
|
4063
|
+
* Present when the slider's value has changed (when wrapped in Field.Root).
|
|
4064
|
+
*/
|
|
4065
|
+
SliderValueDataAttributes["dirty"] = "data-dirty";
|
|
4066
|
+
/**
|
|
4067
|
+
* Present when the slider is focused (when wrapped in Field.Root).
|
|
4068
|
+
*/
|
|
4069
|
+
SliderValueDataAttributes["focused"] = "data-focused";
|
|
4070
|
+
return SliderValueDataAttributes;
|
|
4071
|
+
}({});
|
|
4072
|
+
|
|
4073
|
+
//#endregion
|
|
4074
|
+
//#region src/switch/root/SwitchRootDataAttributes.ts
|
|
4075
|
+
let SwitchRootDataAttributes = /* @__PURE__ */ function(SwitchRootDataAttributes) {
|
|
4076
|
+
/**
|
|
4077
|
+
* Present when the switch is checked.
|
|
4078
|
+
*/
|
|
4079
|
+
SwitchRootDataAttributes["checked"] = "data-checked";
|
|
4080
|
+
/**
|
|
4081
|
+
* Present when the switch is not checked.
|
|
4082
|
+
*/
|
|
4083
|
+
SwitchRootDataAttributes["unchecked"] = "data-unchecked";
|
|
4084
|
+
/**
|
|
4085
|
+
* Present when the switch is disabled.
|
|
4086
|
+
*/
|
|
4087
|
+
SwitchRootDataAttributes["disabled"] = "data-disabled";
|
|
4088
|
+
/**
|
|
4089
|
+
* Present when the switch is readonly.
|
|
4090
|
+
*/
|
|
4091
|
+
SwitchRootDataAttributes["readonly"] = "data-readonly";
|
|
4092
|
+
/**
|
|
4093
|
+
* Present when the switch is required.
|
|
4094
|
+
*/
|
|
4095
|
+
SwitchRootDataAttributes["required"] = "data-required";
|
|
4096
|
+
/**
|
|
4097
|
+
* Present when the switch is in valid state (when wrapped in FieldRoot).
|
|
4098
|
+
*/
|
|
4099
|
+
SwitchRootDataAttributes["valid"] = "data-valid";
|
|
4100
|
+
/**
|
|
4101
|
+
* Present when the switch is in invalid state (when wrapped in FieldRoot).
|
|
4102
|
+
*/
|
|
4103
|
+
SwitchRootDataAttributes["invalid"] = "data-invalid";
|
|
4104
|
+
/**
|
|
4105
|
+
* Present when the switch has been touched (when wrapped in FieldRoot).
|
|
4106
|
+
*/
|
|
4107
|
+
SwitchRootDataAttributes["touched"] = "data-touched";
|
|
4108
|
+
/**
|
|
4109
|
+
* Present when the switch's value has changed (when wrapped in FieldRoot).
|
|
4110
|
+
*/
|
|
4111
|
+
SwitchRootDataAttributes["dirty"] = "data-dirty";
|
|
4112
|
+
/**
|
|
4113
|
+
* Present when the switch is active (when wrapped in FieldRoot).
|
|
4114
|
+
*/
|
|
4115
|
+
SwitchRootDataAttributes["filled"] = "data-filled";
|
|
4116
|
+
/**
|
|
4117
|
+
* Present when the switch is focused (when wrapped in FieldRoot).
|
|
4118
|
+
*/
|
|
4119
|
+
SwitchRootDataAttributes["focused"] = "data-focused";
|
|
4120
|
+
return SwitchRootDataAttributes;
|
|
4121
|
+
}({});
|
|
4122
|
+
|
|
4123
|
+
//#endregion
|
|
4124
|
+
//#region src/switch/stateAttributesMapping.ts
|
|
4125
|
+
const CHECKED_ATTRS = { [SwitchRootDataAttributes.checked]: "" };
|
|
4126
|
+
const UNCHECKED_ATTRS = { [SwitchRootDataAttributes.unchecked]: "" };
|
|
4127
|
+
const stateAttributesMapping = {
|
|
4128
|
+
...fieldValidityMapping,
|
|
4129
|
+
checked(value) {
|
|
4130
|
+
if (value) return CHECKED_ATTRS;
|
|
4131
|
+
return UNCHECKED_ATTRS;
|
|
4132
|
+
}
|
|
4133
|
+
};
|
|
4134
|
+
|
|
4135
|
+
//#endregion
|
|
4136
|
+
//#region src/switch/root/SwitchRootContext.ts
|
|
4137
|
+
const switchRootContextKey = Symbol("SwitchRootContext");
|
|
4138
|
+
function useSwitchRootContext(optional = false) {
|
|
4139
|
+
const context = inject(switchRootContextKey, void 0);
|
|
4140
|
+
if (!context && !optional) throw new Error("Base UI Vue: SwitchRootContext is missing. Switch parts must be placed within <SwitchRoot>.");
|
|
4141
|
+
return context;
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
//#endregion
|
|
4145
|
+
//#region src/switch/root/SwitchRoot.vue?vue&type=script&setup=true&lang.ts
|
|
4146
|
+
const _hoisted_1 = [
|
|
4147
|
+
"form",
|
|
4148
|
+
"name",
|
|
4149
|
+
"value"
|
|
4150
|
+
];
|
|
4151
|
+
/**
|
|
4152
|
+
* Represents the switch itself.
|
|
4153
|
+
* Renders a `<span>` element and a hidden `<input>` beside.
|
|
4154
|
+
*
|
|
4155
|
+
* Documentation: [Base UI Vue Switch](https://baseui-vue.com/docs/components/switch)
|
|
4156
|
+
*/
|
|
4157
|
+
var SwitchRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
4158
|
+
name: "SwitchRoot",
|
|
4159
|
+
inheritAttrs: false,
|
|
4160
|
+
__name: "SwitchRoot",
|
|
4161
|
+
props: {
|
|
4162
|
+
id: {
|
|
4163
|
+
type: String,
|
|
4164
|
+
required: false
|
|
4165
|
+
},
|
|
4166
|
+
checked: {
|
|
4167
|
+
type: Boolean,
|
|
4168
|
+
required: false
|
|
4169
|
+
},
|
|
4170
|
+
defaultChecked: {
|
|
4171
|
+
type: Boolean,
|
|
4172
|
+
required: false,
|
|
4173
|
+
default: false
|
|
4174
|
+
},
|
|
4175
|
+
disabled: {
|
|
4176
|
+
type: Boolean,
|
|
4177
|
+
required: false,
|
|
4178
|
+
default: false
|
|
4179
|
+
},
|
|
4180
|
+
inputRef: {
|
|
4181
|
+
type: [
|
|
4182
|
+
Object,
|
|
4183
|
+
Function,
|
|
4184
|
+
null
|
|
4185
|
+
],
|
|
4186
|
+
required: false
|
|
4187
|
+
},
|
|
4188
|
+
name: {
|
|
4189
|
+
type: String,
|
|
4190
|
+
required: false
|
|
4191
|
+
},
|
|
4192
|
+
form: {
|
|
4193
|
+
type: String,
|
|
4194
|
+
required: false
|
|
4195
|
+
},
|
|
4196
|
+
readOnly: {
|
|
4197
|
+
type: Boolean,
|
|
4198
|
+
required: false,
|
|
4199
|
+
default: false
|
|
4200
|
+
},
|
|
4201
|
+
required: {
|
|
4202
|
+
type: Boolean,
|
|
4203
|
+
required: false,
|
|
4204
|
+
default: false
|
|
4205
|
+
},
|
|
4206
|
+
value: {
|
|
4207
|
+
type: String,
|
|
4208
|
+
required: false
|
|
4209
|
+
},
|
|
4210
|
+
uncheckedValue: {
|
|
4211
|
+
type: String,
|
|
4212
|
+
required: false
|
|
4213
|
+
},
|
|
4214
|
+
"aria-labelledby": {
|
|
4215
|
+
type: String,
|
|
4216
|
+
required: false
|
|
4217
|
+
},
|
|
4218
|
+
nativeButton: {
|
|
4219
|
+
type: Boolean,
|
|
4220
|
+
required: false,
|
|
4221
|
+
default: false
|
|
4222
|
+
},
|
|
4223
|
+
as: {
|
|
4224
|
+
type: null,
|
|
4225
|
+
required: false,
|
|
4226
|
+
default: "span"
|
|
4227
|
+
},
|
|
4228
|
+
class: {
|
|
4229
|
+
type: Function,
|
|
4230
|
+
required: false,
|
|
4231
|
+
skipCheck: true
|
|
4232
|
+
},
|
|
4233
|
+
style: {
|
|
4234
|
+
type: [
|
|
4235
|
+
Boolean,
|
|
4236
|
+
null,
|
|
4237
|
+
String,
|
|
4238
|
+
Object,
|
|
4239
|
+
Array,
|
|
4240
|
+
Function
|
|
4241
|
+
],
|
|
4242
|
+
required: false,
|
|
4243
|
+
skipCheck: true
|
|
4244
|
+
}
|
|
4245
|
+
},
|
|
4246
|
+
emits: ["checkedChange"],
|
|
4247
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4248
|
+
const props = __props;
|
|
4249
|
+
const emit = __emit;
|
|
4250
|
+
const attrsObject = useAttrs();
|
|
4251
|
+
const instance = getCurrentInstance();
|
|
4252
|
+
const { clearErrors } = useFormContext();
|
|
4253
|
+
const { disabled: fieldDisabled, name: fieldName, setDirty, setFilled, setFocused, setTouched, state: fieldState, validationMode, validityData, shouldValidateOnChange, validation } = useFieldRootContext();
|
|
4254
|
+
const labelableContext = useLabelableContext();
|
|
4255
|
+
const disabled = computed(() => fieldDisabled.value || props.disabled);
|
|
4256
|
+
const name = computed(() => fieldName.value ?? props.name);
|
|
4257
|
+
const rootElementId = useBaseUiId();
|
|
4258
|
+
const controlId = useLabelableId({ id: () => props.id });
|
|
4259
|
+
const inputId = computed(() => props.nativeButton ? void 0 : controlId.value);
|
|
4260
|
+
const { value: checked, setValue: setCheckedState } = useControllableState({
|
|
4261
|
+
controlled: () => instance?.vnode.props && Object.prototype.hasOwnProperty.call(instance.vnode.props, "checked") ? props.checked : void 0,
|
|
4262
|
+
default: () => props.defaultChecked,
|
|
4263
|
+
name: "Switch",
|
|
4264
|
+
state: "checked"
|
|
4265
|
+
});
|
|
4266
|
+
const controlRef = ref(null);
|
|
4267
|
+
const inputElementRef = ref(null);
|
|
4268
|
+
const mergedInputRef = useMergedRefs(inputElementRef, props.inputRef);
|
|
4269
|
+
useField({
|
|
4270
|
+
id: computed(() => rootElementId),
|
|
4271
|
+
commit: (value) => validation.commit(value),
|
|
4272
|
+
value: checked,
|
|
4273
|
+
controlRef,
|
|
4274
|
+
name,
|
|
4275
|
+
getValue: () => checked.value
|
|
4276
|
+
});
|
|
4277
|
+
const ariaLabelledBy = useAriaLabelledBy({
|
|
4278
|
+
ariaLabelledBy: computed(() => props["aria-labelledby"]),
|
|
4279
|
+
labelId: labelableContext.labelId,
|
|
4280
|
+
labelSourceRef: inputElementRef,
|
|
4281
|
+
enableFallback: !props.nativeButton,
|
|
4282
|
+
labelSourceId: inputId
|
|
4283
|
+
});
|
|
4284
|
+
watchEffect(() => {
|
|
4285
|
+
if (checked.value) setFilled(true);
|
|
4286
|
+
});
|
|
4287
|
+
watchEffect(() => {
|
|
4288
|
+
if (!inputElementRef.value) return;
|
|
4289
|
+
validation.setInputRef(inputElementRef.value);
|
|
4290
|
+
});
|
|
4291
|
+
watch(() => checked.value, (nextChecked) => {
|
|
4292
|
+
clearErrors(name.value);
|
|
4293
|
+
setFilled(nextChecked);
|
|
4294
|
+
setDirty(nextChecked !== validityData.value.initialValue);
|
|
4295
|
+
if (shouldValidateOnChange()) validation.commit(nextChecked);
|
|
4296
|
+
else validation.commit(nextChecked, true);
|
|
4297
|
+
}, { flush: "sync" });
|
|
4298
|
+
const { getButtonProps, buttonRef } = useButton({
|
|
4299
|
+
disabled,
|
|
4300
|
+
native: computed(() => props.nativeButton)
|
|
4301
|
+
});
|
|
4302
|
+
function combineDescriptionProps(localProps, validationProps) {
|
|
4303
|
+
const localDescribedBy = localProps["aria-describedby"];
|
|
4304
|
+
const validationDescribedBy = validationProps["aria-describedby"];
|
|
4305
|
+
const describedBy = Array.from(new Set([localDescribedBy, validationDescribedBy].filter(Boolean).flatMap((value) => String(value).split(/\s+/).filter(Boolean)))).join(" ") || void 0;
|
|
4306
|
+
return {
|
|
4307
|
+
...localProps,
|
|
4308
|
+
...validationProps,
|
|
4309
|
+
"aria-describedby": describedBy
|
|
4310
|
+
};
|
|
4311
|
+
}
|
|
4312
|
+
function applyCheckedChange(nextChecked, event, onApplied) {
|
|
4313
|
+
const details = createChangeEventDetails(REASONS.none, event);
|
|
4314
|
+
emit("checkedChange", nextChecked, details);
|
|
4315
|
+
if (details.isCanceled) return false;
|
|
4316
|
+
onApplied?.();
|
|
4317
|
+
setCheckedState(nextChecked);
|
|
4318
|
+
return true;
|
|
4319
|
+
}
|
|
4320
|
+
function handleInputChange(event) {
|
|
4321
|
+
const target = event.currentTarget;
|
|
4322
|
+
if (props.readOnly || disabled.value) {
|
|
4323
|
+
event.preventDefault();
|
|
4324
|
+
event.stopPropagation();
|
|
4325
|
+
target.checked = checked.value;
|
|
4326
|
+
return;
|
|
4327
|
+
}
|
|
4328
|
+
if (!applyCheckedChange(target.checked, event)) target.checked = checked.value;
|
|
4329
|
+
}
|
|
4330
|
+
function handleRootClick(event) {
|
|
4331
|
+
if (props.readOnly || disabled.value) return;
|
|
4332
|
+
event.preventDefault();
|
|
4333
|
+
const nextChecked = !checked.value;
|
|
4334
|
+
applyCheckedChange(nextChecked, event, () => {
|
|
4335
|
+
if (inputElementRef.value) inputElementRef.value.checked = nextChecked;
|
|
4336
|
+
});
|
|
4337
|
+
}
|
|
4338
|
+
function handleFocus() {
|
|
4339
|
+
if (!disabled.value) setFocused(true);
|
|
4340
|
+
}
|
|
4341
|
+
function handleBlur() {
|
|
4342
|
+
if (disabled.value) return;
|
|
4343
|
+
setTouched(true);
|
|
4344
|
+
setFocused(false);
|
|
4345
|
+
if (validationMode.value === "onBlur") validation.commit(checked.value);
|
|
4346
|
+
}
|
|
4347
|
+
const state = computed(() => ({
|
|
4348
|
+
...fieldState.value,
|
|
4349
|
+
checked: checked.value,
|
|
4350
|
+
disabled: disabled.value,
|
|
4351
|
+
readOnly: props.readOnly,
|
|
4352
|
+
required: props.required
|
|
4353
|
+
}));
|
|
4354
|
+
provide(switchRootContextKey, state);
|
|
4355
|
+
__expose({ element: controlRef });
|
|
4356
|
+
const mergedRootRef = useMergedRefs(buttonRef, controlRef);
|
|
4357
|
+
const buttonInteractionAttrs = computed(() => ({
|
|
4358
|
+
onClick: attrsObject.onClick,
|
|
4359
|
+
onKeydown: attrsObject.onKeydown,
|
|
4360
|
+
onKeyup: attrsObject.onKeyup,
|
|
4361
|
+
onMousedown: attrsObject.onMousedown,
|
|
4362
|
+
onPointerdown: attrsObject.onPointerdown
|
|
4363
|
+
}));
|
|
4364
|
+
const passthroughAttrs = computed(() => {
|
|
4365
|
+
const { onClick, onKeydown, onKeyup, onMousedown, onPointerdown, ...rest } = attrsObject;
|
|
4366
|
+
return rest;
|
|
4367
|
+
});
|
|
4368
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
4369
|
+
componentProps: props,
|
|
4370
|
+
state,
|
|
4371
|
+
props: computed(() => {
|
|
4372
|
+
const localDescriptionProps = labelableContext.getDescriptionProps();
|
|
4373
|
+
const validationProps = validation.getValidationProps();
|
|
4374
|
+
return mergeProps$1(getButtonProps(mergeProps$1(buttonInteractionAttrs.value, { onClick: handleRootClick })), combineDescriptionProps(localDescriptionProps, validationProps), {
|
|
4375
|
+
"id": props.nativeButton ? controlId.value : rootElementId,
|
|
4376
|
+
"role": "switch",
|
|
4377
|
+
"aria-checked": checked.value,
|
|
4378
|
+
"aria-readonly": props.readOnly || void 0,
|
|
4379
|
+
"aria-required": props.required || void 0,
|
|
4380
|
+
"aria-labelledby": ariaLabelledBy.value,
|
|
4381
|
+
"onFocus": handleFocus,
|
|
4382
|
+
"onBlur": handleBlur
|
|
4383
|
+
}, passthroughAttrs.value);
|
|
4384
|
+
}),
|
|
4385
|
+
stateAttributesMapping,
|
|
4386
|
+
defaultTagName: "span",
|
|
4387
|
+
ref: mergedRootRef
|
|
4388
|
+
});
|
|
4389
|
+
const inputProps = computed(() => {
|
|
4390
|
+
const localDescriptionProps = labelableContext.getDescriptionProps();
|
|
4391
|
+
const validationProps = validation.getInputValidationProps();
|
|
4392
|
+
return mergeProps$1({
|
|
4393
|
+
"checked": checked.value,
|
|
4394
|
+
"disabled": disabled.value,
|
|
4395
|
+
"form": props.form,
|
|
4396
|
+
"id": props.nativeButton ? void 0 : inputId.value,
|
|
4397
|
+
"name": name.value,
|
|
4398
|
+
"required": props.required,
|
|
4399
|
+
"type": "checkbox",
|
|
4400
|
+
"aria-hidden": true,
|
|
4401
|
+
"tabindex": -1,
|
|
4402
|
+
"style": name.value ? visuallyHiddenInput : visuallyHidden,
|
|
4403
|
+
"onChange": handleInputChange,
|
|
4404
|
+
onFocus() {
|
|
4405
|
+
controlRef.value?.focus();
|
|
4406
|
+
}
|
|
4407
|
+
}, props.value !== void 0 ? { value: props.value } : EMPTY_OBJECT, combineDescriptionProps(localDescriptionProps, validationProps));
|
|
4408
|
+
});
|
|
4409
|
+
return (_ctx, _cache) => {
|
|
4410
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
4411
|
+
unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
4412
|
+
key: 0,
|
|
4413
|
+
ref: unref(renderRef),
|
|
4414
|
+
props: unref(mergedProps),
|
|
4415
|
+
state: state.value
|
|
4416
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
4417
|
+
key: 1,
|
|
4418
|
+
ref: unref(renderRef)
|
|
4419
|
+
}, unref(mergedProps)), {
|
|
4420
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { state: state.value })]),
|
|
4421
|
+
_: 3
|
|
4422
|
+
}, 16)),
|
|
4423
|
+
!unref(checked) && !disabled.value && name.value && __props.uncheckedValue !== void 0 ? (openBlock(), createElementBlock("input", {
|
|
4424
|
+
key: 2,
|
|
4425
|
+
type: "hidden",
|
|
4426
|
+
form: __props.form,
|
|
4427
|
+
name: name.value,
|
|
4428
|
+
value: __props.uncheckedValue
|
|
4429
|
+
}, null, 8, _hoisted_1)) : createCommentVNode("v-if", true),
|
|
4430
|
+
createElementVNode("input", mergeProps({ ref: unref(mergedInputRef) }, inputProps.value), null, 16)
|
|
4431
|
+
], 64);
|
|
4432
|
+
};
|
|
4433
|
+
}
|
|
4434
|
+
});
|
|
4435
|
+
|
|
4436
|
+
//#endregion
|
|
4437
|
+
//#region src/switch/root/SwitchRoot.vue
|
|
4438
|
+
var SwitchRoot_default = SwitchRoot_vue_vue_type_script_setup_true_lang_default;
|
|
4439
|
+
|
|
4440
|
+
//#endregion
|
|
4441
|
+
//#region src/switch/thumb/SwitchThumb.vue?vue&type=script&setup=true&lang.ts
|
|
4442
|
+
/**
|
|
4443
|
+
* The movable part of the switch that indicates whether the switch is on or off.
|
|
4444
|
+
* Renders a `<span>`.
|
|
4445
|
+
*
|
|
4446
|
+
* Documentation: [Base UI Vue Switch](https://baseui-vue.com/docs/components/switch)
|
|
4447
|
+
*/
|
|
4448
|
+
var SwitchThumb_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
4449
|
+
name: "SwitchThumb",
|
|
4450
|
+
inheritAttrs: false,
|
|
4451
|
+
__name: "SwitchThumb",
|
|
4452
|
+
props: {
|
|
4453
|
+
as: {
|
|
4454
|
+
type: null,
|
|
4455
|
+
required: false,
|
|
4456
|
+
default: "span"
|
|
4457
|
+
},
|
|
4458
|
+
class: {
|
|
4459
|
+
type: Function,
|
|
4460
|
+
required: false,
|
|
4461
|
+
skipCheck: true
|
|
4462
|
+
},
|
|
4463
|
+
style: {
|
|
4464
|
+
type: [
|
|
4465
|
+
Boolean,
|
|
4466
|
+
null,
|
|
4467
|
+
String,
|
|
4468
|
+
Object,
|
|
4469
|
+
Array,
|
|
4470
|
+
Function
|
|
4471
|
+
],
|
|
4472
|
+
required: false,
|
|
4473
|
+
skipCheck: true
|
|
4474
|
+
}
|
|
4475
|
+
},
|
|
4476
|
+
setup(__props) {
|
|
4477
|
+
const props = __props;
|
|
4478
|
+
const attrsObject = useAttrs();
|
|
4479
|
+
const { state: fieldState } = useFieldRootContext();
|
|
4480
|
+
const rootState = useSwitchRootContext();
|
|
4481
|
+
const state = computed(() => ({
|
|
4482
|
+
...fieldState.value,
|
|
4483
|
+
...rootState.value
|
|
4484
|
+
}));
|
|
4485
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
4486
|
+
componentProps: props,
|
|
4487
|
+
state,
|
|
4488
|
+
props: computed(() => attrsObject),
|
|
4489
|
+
stateAttributesMapping,
|
|
4490
|
+
defaultTagName: "span"
|
|
4491
|
+
});
|
|
4492
|
+
return (_ctx, _cache) => {
|
|
4493
|
+
return unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
4494
|
+
key: 0,
|
|
4495
|
+
ref: unref(renderRef),
|
|
4496
|
+
props: unref(mergedProps),
|
|
4497
|
+
state: state.value
|
|
4498
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
4499
|
+
key: 1,
|
|
4500
|
+
ref: unref(renderRef)
|
|
4501
|
+
}, unref(mergedProps)), {
|
|
4502
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { state: state.value })]),
|
|
4503
|
+
_: 3
|
|
4504
|
+
}, 16));
|
|
4505
|
+
};
|
|
4506
|
+
}
|
|
4507
|
+
});
|
|
4508
|
+
|
|
4509
|
+
//#endregion
|
|
4510
|
+
//#region src/switch/thumb/SwitchThumb.vue
|
|
4511
|
+
var SwitchThumb_default = SwitchThumb_vue_vue_type_script_setup_true_lang_default;
|
|
4512
|
+
|
|
4513
|
+
//#endregion
|
|
4514
|
+
//#region src/switch/thumb/SwitchThumbDataAttributes.ts
|
|
4515
|
+
let SwitchThumbDataAttributes = /* @__PURE__ */ function(SwitchThumbDataAttributes) {
|
|
4516
|
+
/**
|
|
4517
|
+
* Present when the switch is checked.
|
|
4518
|
+
*/
|
|
4519
|
+
SwitchThumbDataAttributes["checked"] = "data-checked";
|
|
4520
|
+
/**
|
|
4521
|
+
* Present when the switch is not checked.
|
|
4522
|
+
*/
|
|
4523
|
+
SwitchThumbDataAttributes["unchecked"] = "data-unchecked";
|
|
4524
|
+
/**
|
|
4525
|
+
* Present when the switch is disabled.
|
|
4526
|
+
*/
|
|
4527
|
+
SwitchThumbDataAttributes["disabled"] = "data-disabled";
|
|
4528
|
+
/**
|
|
4529
|
+
* Present when the switch is readonly.
|
|
4530
|
+
*/
|
|
4531
|
+
SwitchThumbDataAttributes["readonly"] = "data-readonly";
|
|
4532
|
+
/**
|
|
4533
|
+
* Present when the switch is required.
|
|
4534
|
+
*/
|
|
4535
|
+
SwitchThumbDataAttributes["required"] = "data-required";
|
|
4536
|
+
/**
|
|
4537
|
+
* Present when the switch is in valid state (when wrapped in FieldRoot).
|
|
4538
|
+
*/
|
|
4539
|
+
SwitchThumbDataAttributes["valid"] = "data-valid";
|
|
4540
|
+
/**
|
|
4541
|
+
* Present when the switch is in invalid state (when wrapped in FieldRoot).
|
|
4542
|
+
*/
|
|
4543
|
+
SwitchThumbDataAttributes["invalid"] = "data-invalid";
|
|
4544
|
+
/**
|
|
4545
|
+
* Present when the switch has been touched (when wrapped in FieldRoot).
|
|
4546
|
+
*/
|
|
4547
|
+
SwitchThumbDataAttributes["touched"] = "data-touched";
|
|
4548
|
+
/**
|
|
4549
|
+
* Present when the switch's value has changed (when wrapped in FieldRoot).
|
|
4550
|
+
*/
|
|
4551
|
+
SwitchThumbDataAttributes["dirty"] = "data-dirty";
|
|
4552
|
+
/**
|
|
4553
|
+
* Present when the switch is active (when wrapped in FieldRoot).
|
|
4554
|
+
*/
|
|
4555
|
+
SwitchThumbDataAttributes["filled"] = "data-filled";
|
|
4556
|
+
/**
|
|
4557
|
+
* Present when the switch is focused (when wrapped in FieldRoot).
|
|
4558
|
+
*/
|
|
4559
|
+
SwitchThumbDataAttributes["focused"] = "data-focused";
|
|
4560
|
+
return SwitchThumbDataAttributes;
|
|
4561
|
+
}({});
|
|
4562
|
+
|
|
4563
|
+
//#endregion
|
|
4564
|
+
//#region src/toggle-group/ToggleGroupContext.ts
|
|
4565
|
+
const toggleGroupContextKey = Symbol("ToggleGroupContext");
|
|
4566
|
+
function useToggleGroupContext(optional = false) {
|
|
4567
|
+
const context = inject(toggleGroupContextKey, void 0);
|
|
4568
|
+
if (context === void 0 && !optional) throw new Error("Base UI Vue: ToggleGroupContext is missing. ToggleGroup parts must be placed within <ToggleGroup>.");
|
|
4569
|
+
return context;
|
|
4570
|
+
}
|
|
4571
|
+
|
|
4572
|
+
//#endregion
|
|
4573
|
+
//#region src/toggle/Toggle.vue?vue&type=script&setup=true&lang.ts
|
|
4574
|
+
/**
|
|
4575
|
+
* A two-state button that can be on or off.
|
|
4576
|
+
* Renders a `<button>` element.
|
|
4577
|
+
*
|
|
4578
|
+
* Documentation: [Base UI Vue Toggle](https://baseui-vue.com/docs/components/toggle)
|
|
4579
|
+
*/
|
|
4580
|
+
var Toggle_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
4581
|
+
name: "Toggle",
|
|
4582
|
+
inheritAttrs: false,
|
|
4583
|
+
__name: "Toggle",
|
|
4584
|
+
props: {
|
|
4585
|
+
pressed: {
|
|
4586
|
+
type: Boolean,
|
|
4587
|
+
required: false
|
|
4588
|
+
},
|
|
4589
|
+
defaultPressed: {
|
|
4590
|
+
type: Boolean,
|
|
4591
|
+
required: false,
|
|
4592
|
+
default: false
|
|
4593
|
+
},
|
|
4594
|
+
disabled: {
|
|
4595
|
+
type: Boolean,
|
|
4596
|
+
required: false,
|
|
4597
|
+
default: false
|
|
4598
|
+
},
|
|
4599
|
+
value: {
|
|
4600
|
+
type: null,
|
|
4601
|
+
required: false
|
|
4602
|
+
},
|
|
4603
|
+
nativeButton: {
|
|
4604
|
+
type: Boolean,
|
|
4605
|
+
required: false,
|
|
4606
|
+
default: true
|
|
4607
|
+
},
|
|
4608
|
+
as: {
|
|
4609
|
+
type: null,
|
|
4610
|
+
required: false,
|
|
4611
|
+
default: "button"
|
|
4612
|
+
},
|
|
4613
|
+
class: {
|
|
4614
|
+
type: Function,
|
|
4615
|
+
required: false,
|
|
4616
|
+
skipCheck: true
|
|
4617
|
+
},
|
|
4618
|
+
style: {
|
|
4619
|
+
type: [
|
|
4620
|
+
Boolean,
|
|
4621
|
+
null,
|
|
4622
|
+
String,
|
|
4623
|
+
Object,
|
|
4624
|
+
Array,
|
|
4625
|
+
Function
|
|
4626
|
+
],
|
|
4627
|
+
required: false,
|
|
4628
|
+
skipCheck: true
|
|
4629
|
+
}
|
|
4630
|
+
},
|
|
4631
|
+
emits: ["pressedChange"],
|
|
4632
|
+
setup(__props, { emit: __emit }) {
|
|
4633
|
+
const props = __props;
|
|
4634
|
+
const emit = __emit;
|
|
4635
|
+
const attrs = useAttrs();
|
|
4636
|
+
const instance = getCurrentInstance();
|
|
4637
|
+
const groupContext = useToggleGroupContext(true);
|
|
4638
|
+
const generatedValue = useBaseUiId();
|
|
4639
|
+
const toggleValue = computed(() => props.value || generatedValue);
|
|
4640
|
+
const groupValue = computed(() => groupContext?.value.value ?? []);
|
|
4641
|
+
const disabled = computed(() => props.disabled || (groupContext?.disabled.value ?? false));
|
|
4642
|
+
if (process.env.NODE_ENV !== "production") watchEffect(() => {
|
|
4643
|
+
if (groupContext && props.value === void 0 && groupContext.isValueInitialized.value) error("A `<Toggle>` component rendered in a `<ToggleGroup>` has no explicit `value` prop.", "This will cause issues between the Toggle Group and Toggle values.", "Provide the `<Toggle>` with a `value` prop matching the `<ToggleGroup>` values prop type.");
|
|
4644
|
+
});
|
|
4645
|
+
const hasPressedProp = computed(() => Boolean(instance?.vnode.props && Object.prototype.hasOwnProperty.call(instance.vnode.props, "pressed")));
|
|
4646
|
+
const { value: pressed, setValue: setPressedState } = useControllableState({
|
|
4647
|
+
controlled: () => {
|
|
4648
|
+
if (groupContext) return toggleValue.value !== void 0 && groupValue.value.includes(toggleValue.value);
|
|
4649
|
+
return hasPressedProp.value ? props.pressed : void 0;
|
|
4650
|
+
},
|
|
4651
|
+
default: () => props.defaultPressed,
|
|
4652
|
+
name: "Toggle",
|
|
4653
|
+
state: "pressed"
|
|
4654
|
+
});
|
|
4655
|
+
function emitPressedChange(nextPressed, eventDetails) {
|
|
4656
|
+
if (toggleValue.value !== void 0) groupContext?.setGroupValue(toggleValue.value, nextPressed, eventDetails);
|
|
4657
|
+
emit("pressedChange", nextPressed, eventDetails);
|
|
4658
|
+
}
|
|
4659
|
+
const { getButtonProps, buttonRef } = useButton({
|
|
4660
|
+
disabled,
|
|
4661
|
+
native: () => props.nativeButton ?? true
|
|
4662
|
+
});
|
|
4663
|
+
const state = computed(() => ({
|
|
4664
|
+
disabled: disabled.value,
|
|
4665
|
+
pressed: pressed.value
|
|
4666
|
+
}));
|
|
4667
|
+
const buttonAttrs = computed(() => {
|
|
4668
|
+
const { form: _form, type: _type, ...rest } = attrs;
|
|
4669
|
+
return rest;
|
|
4670
|
+
});
|
|
4671
|
+
function createToggleButtonProps() {
|
|
4672
|
+
return mergeProps$1(getButtonProps(mergeProps$1(buttonAttrs.value, {
|
|
4673
|
+
"aria-pressed": pressed.value,
|
|
4674
|
+
onClick(event) {
|
|
4675
|
+
const nextPressed = !pressed.value;
|
|
4676
|
+
const details = createChangeEventDetails(REASONS.none, event);
|
|
4677
|
+
emitPressedChange(nextPressed, details);
|
|
4678
|
+
if (details.isCanceled) return;
|
|
4679
|
+
setPressedState(nextPressed);
|
|
4680
|
+
}
|
|
4681
|
+
})), groupContext ? { "aria-disabled": disabled.value ? "true" : "false" } : void 0);
|
|
4682
|
+
}
|
|
4683
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
4684
|
+
componentProps: props,
|
|
4685
|
+
state,
|
|
4686
|
+
props: computed(() => createToggleButtonProps()),
|
|
4687
|
+
defaultTagName: "button",
|
|
4688
|
+
ref: buttonRef
|
|
4689
|
+
});
|
|
4690
|
+
const itemRefs = [buttonRef];
|
|
4691
|
+
return (_ctx, _cache) => {
|
|
4692
|
+
return unref(groupContext) ? (openBlock(), createBlock(CompositeItem_default, {
|
|
4693
|
+
key: 0,
|
|
4694
|
+
as: __props.as,
|
|
4695
|
+
class: normalizeClass(props.class),
|
|
4696
|
+
style: normalizeStyle(props.style),
|
|
4697
|
+
state: state.value,
|
|
4698
|
+
refs: itemRefs,
|
|
4699
|
+
props: [() => createToggleButtonProps()]
|
|
4700
|
+
}, {
|
|
4701
|
+
default: withCtx((slotProps) => [renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(slotProps)))]),
|
|
4702
|
+
_: 3
|
|
4703
|
+
}, 8, [
|
|
4704
|
+
"as",
|
|
4705
|
+
"class",
|
|
4706
|
+
"style",
|
|
4707
|
+
"state",
|
|
4708
|
+
"props"
|
|
4709
|
+
])) : unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
4710
|
+
key: 1,
|
|
4711
|
+
ref: unref(renderRef),
|
|
4712
|
+
props: unref(mergedProps),
|
|
4713
|
+
state: state.value
|
|
4714
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
4715
|
+
key: 2,
|
|
4716
|
+
ref: unref(renderRef)
|
|
4717
|
+
}, unref(mergedProps)), {
|
|
4718
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { state: state.value })]),
|
|
4719
|
+
_: 3
|
|
4720
|
+
}, 16));
|
|
4721
|
+
};
|
|
4722
|
+
}
|
|
4723
|
+
});
|
|
4724
|
+
|
|
4725
|
+
//#endregion
|
|
4726
|
+
//#region src/toggle/Toggle.vue
|
|
4727
|
+
var Toggle_default = Toggle_vue_vue_type_script_setup_true_lang_default;
|
|
4728
|
+
|
|
4729
|
+
//#endregion
|
|
4730
|
+
//#region src/toggle/ToggleDataAttributes.ts
|
|
4731
|
+
let ToggleDataAttributes = /* @__PURE__ */ function(ToggleDataAttributes) {
|
|
4732
|
+
/**
|
|
4733
|
+
* Present when the toggle button is pressed.
|
|
4734
|
+
*/
|
|
4735
|
+
ToggleDataAttributes["pressed"] = "data-pressed";
|
|
4736
|
+
return ToggleDataAttributes;
|
|
4737
|
+
}({});
|
|
4738
|
+
|
|
4739
|
+
//#endregion
|
|
4740
|
+
//#region src/composite/root/useCompositeRoot.ts
|
|
4741
|
+
const EMPTY_ARRAY = [];
|
|
4742
|
+
function useCompositeRoot(params) {
|
|
4743
|
+
const orientation = computed(() => params.orientation?.() ?? "both");
|
|
4744
|
+
const cols = computed(() => params.cols?.() ?? 1);
|
|
4745
|
+
const loopFocus = computed(() => params.loopFocus?.() ?? true);
|
|
4746
|
+
const dense = computed(() => params.dense?.() ?? false);
|
|
4747
|
+
const itemSizes = computed(() => params.itemSizes?.());
|
|
4748
|
+
const enableHomeAndEndKeys = computed(() => params.enableHomeAndEndKeys?.() ?? false);
|
|
4749
|
+
const stopEventPropagation = computed(() => params.stopEventPropagation?.() ?? false);
|
|
4750
|
+
const disabledIndices = computed(() => params.disabledIndices?.() ?? EMPTY_ARRAY);
|
|
4751
|
+
const modifierKeys = computed(() => params.modifierKeys?.() ?? EMPTY_ARRAY);
|
|
4752
|
+
const externalHighlightedIndex = computed(() => params.highlightedIndex?.());
|
|
4753
|
+
const externalSetHighlightedIndex = params.onHighlightedIndexChange;
|
|
4754
|
+
const internalHighlightedIndex = ref(params.defaultHighlightedIndex?.() ?? 0);
|
|
4755
|
+
const isGrid = computed(() => cols.value > 1);
|
|
4756
|
+
const rootRef = ref(null);
|
|
4757
|
+
const mergedRef = useMergedRefs(rootRef, params.rootRef);
|
|
4758
|
+
const elementsRef = ref([]);
|
|
4759
|
+
let hasSetDefaultIndex = false;
|
|
4760
|
+
const highlightedIndex = computed(() => externalHighlightedIndex.value ?? internalHighlightedIndex.value);
|
|
4761
|
+
function onHighlightedIndexChange(index, shouldScrollIntoView = false) {
|
|
4762
|
+
if (externalHighlightedIndex.value !== void 0) {
|
|
4763
|
+
if (externalSetHighlightedIndex) externalSetHighlightedIndex(index);
|
|
4764
|
+
} else {
|
|
4765
|
+
internalHighlightedIndex.value = index;
|
|
4766
|
+
if (externalSetHighlightedIndex) externalSetHighlightedIndex(index);
|
|
4767
|
+
}
|
|
4768
|
+
if (shouldScrollIntoView) {
|
|
4769
|
+
const newActiveItem = elementsRef.value[index];
|
|
4770
|
+
scrollIntoViewIfNeeded(rootRef.value, newActiveItem, params.direction(), orientation.value);
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
function onMapChange(map) {
|
|
4774
|
+
if (map.size === 0 || hasSetDefaultIndex) return;
|
|
4775
|
+
hasSetDefaultIndex = true;
|
|
4776
|
+
const sortedElements = Array.from(map.keys());
|
|
4777
|
+
const activeItem = sortedElements.find((compositeElement) => compositeElement?.hasAttribute(ACTIVE_COMPOSITE_ITEM)) ?? null;
|
|
4778
|
+
const activeIndex = activeItem ? sortedElements.indexOf(activeItem) : -1;
|
|
4779
|
+
if (activeIndex !== -1) onHighlightedIndexChange(activeIndex);
|
|
4780
|
+
scrollIntoViewIfNeeded(rootRef.value, activeItem, params.direction(), orientation.value);
|
|
4781
|
+
}
|
|
4782
|
+
function handleFocus(event) {
|
|
4783
|
+
if (!rootRef.value || !isNativeInput(event.target)) return;
|
|
4784
|
+
const target = event.target;
|
|
4785
|
+
target.setSelectionRange(0, target.value.length ?? 0);
|
|
4786
|
+
}
|
|
4787
|
+
function handleKeydown(event) {
|
|
4788
|
+
const RELEVANT_KEYS = enableHomeAndEndKeys.value ? ALL_KEYS : ARROW_KEYS;
|
|
4789
|
+
if (!RELEVANT_KEYS.has(event.key)) return;
|
|
4790
|
+
if (isModifierKeySet(event, modifierKeys.value)) return;
|
|
4791
|
+
if (!rootRef.value) return;
|
|
4792
|
+
const isRtl = params.direction() === "rtl";
|
|
4793
|
+
const horizontalForwardKey = isRtl ? ARROW_LEFT$1 : ARROW_RIGHT$1;
|
|
4794
|
+
const forwardKey = {
|
|
4795
|
+
horizontal: horizontalForwardKey,
|
|
4796
|
+
vertical: ARROW_DOWN$1,
|
|
4797
|
+
both: horizontalForwardKey
|
|
4798
|
+
}[orientation.value];
|
|
4799
|
+
const horizontalBackwardKey = isRtl ? ARROW_RIGHT$1 : ARROW_LEFT$1;
|
|
4800
|
+
const backwardKey = {
|
|
4801
|
+
horizontal: horizontalBackwardKey,
|
|
4802
|
+
vertical: ARROW_UP$1,
|
|
4803
|
+
both: horizontalBackwardKey
|
|
4804
|
+
}[orientation.value];
|
|
4805
|
+
if (isNativeInput(event.target) && !isElementDisabled(event.target)) {
|
|
4806
|
+
const target = event.target;
|
|
4807
|
+
const selectionStart = target.selectionStart;
|
|
4808
|
+
const selectionEnd = target.selectionEnd;
|
|
4809
|
+
const textContent = target.value ?? "";
|
|
4810
|
+
if (selectionStart == null || event.shiftKey || selectionStart !== selectionEnd) return;
|
|
4811
|
+
if (event.key !== backwardKey && selectionStart < textContent.length) return;
|
|
4812
|
+
if (event.key !== forwardKey && selectionStart > 0) return;
|
|
4813
|
+
}
|
|
4814
|
+
let nextIndex = highlightedIndex.value;
|
|
4815
|
+
const minIndex = getMinListIndex(elementsRef, disabledIndices.value);
|
|
4816
|
+
const maxIndex = getMaxListIndex(elementsRef, disabledIndices.value);
|
|
4817
|
+
if (isGrid.value) {
|
|
4818
|
+
const sizes = itemSizes.value || Array.from({ length: elementsRef.value.length }, () => ({
|
|
4819
|
+
width: 1,
|
|
4820
|
+
height: 1
|
|
4821
|
+
}));
|
|
4822
|
+
const cellMap = createGridCellMap(sizes, cols.value, dense.value);
|
|
4823
|
+
const minGridIndex = cellMap.findIndex((index) => index != null && !isListIndexDisabled(elementsRef, index, disabledIndices.value));
|
|
4824
|
+
const maxGridIndex = cellMap.reduce((foundIndex, index, cellIndex) => index != null && !isListIndexDisabled(elementsRef, index, disabledIndices.value) ? cellIndex : foundIndex, -1);
|
|
4825
|
+
nextIndex = cellMap[getGridNavigatedIndex(elementsRef, {
|
|
4826
|
+
event,
|
|
4827
|
+
orientation: orientation.value,
|
|
4828
|
+
loopFocus: loopFocus.value,
|
|
4829
|
+
cols: cols.value,
|
|
4830
|
+
disabledIndices: getGridCellIndices([...(disabledIndices.value.length > 0 ? disabledIndices.value : void 0) || elementsRef.value.map((_, index) => isListIndexDisabled(elementsRef, index) ? index : void 0), void 0], cellMap),
|
|
4831
|
+
minIndex: minGridIndex,
|
|
4832
|
+
maxIndex: maxGridIndex,
|
|
4833
|
+
prevIndex: getGridCellIndexOfCorner(highlightedIndex.value > maxIndex ? minIndex : highlightedIndex.value, sizes, cellMap, cols.value, event.key === ARROW_DOWN$1 ? "bl" : event.key === ARROW_RIGHT$1 ? "tr" : "tl"),
|
|
4834
|
+
rtl: isRtl
|
|
4835
|
+
})];
|
|
4836
|
+
}
|
|
4837
|
+
const forwardKeys = {
|
|
4838
|
+
horizontal: [horizontalForwardKey],
|
|
4839
|
+
vertical: [ARROW_DOWN$1],
|
|
4840
|
+
both: [horizontalForwardKey, ARROW_DOWN$1]
|
|
4841
|
+
}[orientation.value];
|
|
4842
|
+
const backwardKeys = {
|
|
4843
|
+
horizontal: [horizontalBackwardKey],
|
|
4844
|
+
vertical: [ARROW_UP$1],
|
|
4845
|
+
both: [horizontalBackwardKey, ARROW_UP$1]
|
|
4846
|
+
}[orientation.value];
|
|
4847
|
+
const preventedKeys = isGrid.value ? RELEVANT_KEYS : {
|
|
4848
|
+
horizontal: enableHomeAndEndKeys.value ? HORIZONTAL_KEYS_WITH_EXTRA_KEYS : HORIZONTAL_KEYS,
|
|
4849
|
+
vertical: enableHomeAndEndKeys.value ? VERTICAL_KEYS_WITH_EXTRA_KEYS : VERTICAL_KEYS,
|
|
4850
|
+
both: RELEVANT_KEYS
|
|
4851
|
+
}[orientation.value];
|
|
4852
|
+
if (enableHomeAndEndKeys.value) {
|
|
4853
|
+
if (event.key === HOME) nextIndex = minIndex;
|
|
4854
|
+
else if (event.key === END) nextIndex = maxIndex;
|
|
4855
|
+
}
|
|
4856
|
+
if (nextIndex === highlightedIndex.value && (forwardKeys.includes(event.key) || backwardKeys.includes(event.key))) if (loopFocus.value && nextIndex === maxIndex && forwardKeys.includes(event.key)) nextIndex = minIndex;
|
|
4857
|
+
else if (loopFocus.value && nextIndex === minIndex && backwardKeys.includes(event.key)) nextIndex = maxIndex;
|
|
4858
|
+
else nextIndex = findNonDisabledListIndex(elementsRef, {
|
|
4859
|
+
startingIndex: nextIndex,
|
|
4860
|
+
decrement: backwardKeys.includes(event.key),
|
|
4861
|
+
disabledIndices: disabledIndices.value
|
|
4862
|
+
});
|
|
4863
|
+
if (nextIndex !== highlightedIndex.value && !isIndexOutOfListBounds(elementsRef, nextIndex)) {
|
|
4864
|
+
if (stopEventPropagation.value) event.stopPropagation();
|
|
4865
|
+
if (preventedKeys.has(event.key)) event.preventDefault();
|
|
4866
|
+
onHighlightedIndexChange(nextIndex, true);
|
|
4867
|
+
queueMicrotask(() => {
|
|
4868
|
+
elementsRef.value[nextIndex]?.focus();
|
|
4869
|
+
});
|
|
4870
|
+
}
|
|
4871
|
+
}
|
|
4872
|
+
return {
|
|
4873
|
+
getRootProps: (externalProps = {}) => ({
|
|
4874
|
+
...externalProps,
|
|
4875
|
+
"aria-orientation": orientation.value === "both" ? void 0 : orientation.value,
|
|
4876
|
+
onFocus(event) {
|
|
4877
|
+
externalProps.onFocus?.(event);
|
|
4878
|
+
if (!event.defaultPrevented) handleFocus(event);
|
|
4879
|
+
},
|
|
4880
|
+
onKeydown(event) {
|
|
4881
|
+
externalProps.onKeydown?.(event);
|
|
4882
|
+
if (!event.defaultPrevented) handleKeydown(event);
|
|
4883
|
+
}
|
|
4884
|
+
}),
|
|
4885
|
+
rootRef,
|
|
4886
|
+
mergedRef,
|
|
4887
|
+
highlightedIndex,
|
|
4888
|
+
onHighlightedIndexChange,
|
|
4889
|
+
elementsRef,
|
|
4890
|
+
disabledIndices,
|
|
4891
|
+
onMapChange,
|
|
4892
|
+
relayKeyboardEvent: handleKeydown
|
|
4893
|
+
};
|
|
4894
|
+
}
|
|
4895
|
+
function isModifierKeySet(event, ignoredModifierKeys) {
|
|
4896
|
+
for (const key of MODIFIER_KEYS.values()) {
|
|
4897
|
+
if (ignoredModifierKeys.includes(key)) continue;
|
|
4898
|
+
if (event.getModifierState(key)) return true;
|
|
4899
|
+
}
|
|
4900
|
+
return false;
|
|
4901
|
+
}
|
|
4902
|
+
|
|
4903
|
+
//#endregion
|
|
4904
|
+
//#region src/composite/root/CompositeRoot.vue?vue&type=script&setup=true&lang.ts
|
|
4905
|
+
var CompositeRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
4906
|
+
name: "BaseUICompositeRoot",
|
|
4907
|
+
inheritAttrs: false,
|
|
4908
|
+
__name: "CompositeRoot",
|
|
4909
|
+
props: {
|
|
4910
|
+
state: {
|
|
4911
|
+
type: Object,
|
|
4912
|
+
required: false
|
|
4913
|
+
},
|
|
4914
|
+
stateAttributesMapping: {
|
|
4915
|
+
type: null,
|
|
4916
|
+
required: false
|
|
4917
|
+
},
|
|
4918
|
+
orientation: {
|
|
4919
|
+
type: String,
|
|
4920
|
+
required: false,
|
|
4921
|
+
default: "both"
|
|
4922
|
+
},
|
|
4923
|
+
cols: {
|
|
4924
|
+
type: Number,
|
|
4925
|
+
required: false,
|
|
4926
|
+
default: 1
|
|
4927
|
+
},
|
|
4928
|
+
loopFocus: {
|
|
4929
|
+
type: Boolean,
|
|
4930
|
+
required: false,
|
|
4931
|
+
default: true
|
|
4932
|
+
},
|
|
4933
|
+
highlightedIndex: {
|
|
4934
|
+
type: Number,
|
|
4935
|
+
required: false
|
|
4936
|
+
},
|
|
4937
|
+
defaultHighlightedIndex: {
|
|
4938
|
+
type: Number,
|
|
4939
|
+
required: false
|
|
4940
|
+
},
|
|
4941
|
+
itemSizes: {
|
|
4942
|
+
type: Array,
|
|
4943
|
+
required: false
|
|
4944
|
+
},
|
|
4945
|
+
dense: {
|
|
4946
|
+
type: Boolean,
|
|
4947
|
+
required: false,
|
|
4948
|
+
default: false
|
|
4949
|
+
},
|
|
4950
|
+
enableHomeAndEndKeys: {
|
|
4951
|
+
type: Boolean,
|
|
4952
|
+
required: false,
|
|
4953
|
+
default: false
|
|
4954
|
+
},
|
|
4955
|
+
stopEventPropagation: {
|
|
4956
|
+
type: Boolean,
|
|
4957
|
+
required: false,
|
|
4958
|
+
default: true
|
|
4959
|
+
},
|
|
4960
|
+
disabledIndices: {
|
|
4961
|
+
type: Array,
|
|
4962
|
+
required: false
|
|
4963
|
+
},
|
|
4964
|
+
modifierKeys: {
|
|
4965
|
+
type: Array,
|
|
4966
|
+
required: false
|
|
4967
|
+
},
|
|
4968
|
+
highlightItemOnHover: {
|
|
4969
|
+
type: Boolean,
|
|
4970
|
+
required: false,
|
|
4971
|
+
default: false
|
|
4972
|
+
},
|
|
4973
|
+
as: {
|
|
4974
|
+
type: null,
|
|
4975
|
+
required: false,
|
|
4976
|
+
default: "div"
|
|
4977
|
+
},
|
|
4978
|
+
class: {
|
|
4979
|
+
type: Function,
|
|
4980
|
+
required: false,
|
|
4981
|
+
skipCheck: true
|
|
4982
|
+
},
|
|
4983
|
+
style: {
|
|
4984
|
+
type: [
|
|
4985
|
+
Boolean,
|
|
4986
|
+
null,
|
|
4987
|
+
String,
|
|
4988
|
+
Object,
|
|
4989
|
+
Array,
|
|
4990
|
+
Function
|
|
4991
|
+
],
|
|
4992
|
+
required: false,
|
|
4993
|
+
skipCheck: true
|
|
4994
|
+
}
|
|
4995
|
+
},
|
|
4996
|
+
emits: ["update:highlightedIndex", "mapChange"],
|
|
4997
|
+
setup(__props, { emit: __emit }) {
|
|
4998
|
+
const props = __props;
|
|
4999
|
+
const emit = __emit;
|
|
5000
|
+
const attrs = useAttrs();
|
|
5001
|
+
const direction = useDirection();
|
|
5002
|
+
const root = useCompositeRoot({
|
|
5003
|
+
orientation: () => props.orientation,
|
|
5004
|
+
cols: () => props.cols,
|
|
5005
|
+
loopFocus: () => props.loopFocus,
|
|
5006
|
+
highlightedIndex: () => props.highlightedIndex,
|
|
5007
|
+
defaultHighlightedIndex: () => props.defaultHighlightedIndex,
|
|
5008
|
+
onHighlightedIndexChange: (index) => {
|
|
5009
|
+
emit("update:highlightedIndex", index);
|
|
5010
|
+
},
|
|
5011
|
+
dense: () => props.dense,
|
|
5012
|
+
itemSizes: () => props.itemSizes,
|
|
5013
|
+
enableHomeAndEndKeys: () => props.enableHomeAndEndKeys,
|
|
5014
|
+
stopEventPropagation: () => props.stopEventPropagation,
|
|
5015
|
+
disabledIndices: () => props.disabledIndices,
|
|
5016
|
+
modifierKeys: () => props.modifierKeys,
|
|
5017
|
+
direction: () => direction.value
|
|
5018
|
+
});
|
|
5019
|
+
provide(compositeRootContextKey, reactive({
|
|
5020
|
+
highlightedIndex: root.highlightedIndex,
|
|
5021
|
+
onHighlightedIndexChange: root.onHighlightedIndexChange,
|
|
5022
|
+
highlightItemOnHover: computed(() => props.highlightItemOnHover),
|
|
5023
|
+
relayKeyboardEvent: root.relayKeyboardEvent
|
|
5024
|
+
}));
|
|
5025
|
+
const state = computed(() => props.state ?? {});
|
|
5026
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
5027
|
+
componentProps: props,
|
|
5028
|
+
state,
|
|
5029
|
+
props: computed(() => root.getRootProps(attrs)),
|
|
5030
|
+
stateAttributesMapping: props.stateAttributesMapping,
|
|
5031
|
+
defaultTagName: "div",
|
|
5032
|
+
ref: root.mergedRef
|
|
5033
|
+
});
|
|
5034
|
+
return (_ctx, _cache) => {
|
|
5035
|
+
return openBlock(), createBlock(CompositeList_default, {
|
|
5036
|
+
"elements-ref": unref(root).elementsRef,
|
|
5037
|
+
onMapChange: _cache[0] || (_cache[0] = (newMap) => {
|
|
5038
|
+
emit("mapChange", newMap);
|
|
5039
|
+
unref(root).onMapChange(newMap);
|
|
5040
|
+
})
|
|
5041
|
+
}, {
|
|
5042
|
+
default: withCtx(() => [unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
5043
|
+
key: 0,
|
|
5044
|
+
ref: unref(renderRef),
|
|
5045
|
+
props: unref(mergedProps),
|
|
5046
|
+
state: state.value
|
|
5047
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
5048
|
+
key: 1,
|
|
5049
|
+
ref: unref(renderRef)
|
|
5050
|
+
}, unref(mergedProps)), {
|
|
5051
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { state: state.value })]),
|
|
5052
|
+
_: 3
|
|
5053
|
+
}, 16))]),
|
|
5054
|
+
_: 3
|
|
5055
|
+
}, 8, ["elements-ref"]);
|
|
5056
|
+
};
|
|
5057
|
+
}
|
|
5058
|
+
});
|
|
5059
|
+
|
|
5060
|
+
//#endregion
|
|
5061
|
+
//#region src/composite/root/CompositeRoot.vue
|
|
5062
|
+
var CompositeRoot_default = CompositeRoot_vue_vue_type_script_setup_true_lang_default;
|
|
5063
|
+
|
|
5064
|
+
//#endregion
|
|
5065
|
+
//#region src/toggle-group/ToggleGroupDataAttributes.ts
|
|
5066
|
+
let ToggleGroupDataAttributes = /* @__PURE__ */ function(ToggleGroupDataAttributes) {
|
|
5067
|
+
/**
|
|
5068
|
+
* Present when the toggle group is disabled.
|
|
5069
|
+
*/
|
|
5070
|
+
ToggleGroupDataAttributes["disabled"] = "data-disabled";
|
|
5071
|
+
/**
|
|
5072
|
+
* Indicates the orientation of the toggle group.
|
|
5073
|
+
* @type {'horizontal' | 'vertical'}
|
|
5074
|
+
*/
|
|
5075
|
+
ToggleGroupDataAttributes["orientation"] = "data-orientation";
|
|
5076
|
+
/**
|
|
5077
|
+
* Present when the toggle group allows multiple buttons to be in the pressed state at the same time.
|
|
5078
|
+
*/
|
|
5079
|
+
ToggleGroupDataAttributes["multiple"] = "data-multiple";
|
|
5080
|
+
return ToggleGroupDataAttributes;
|
|
5081
|
+
}({});
|
|
5082
|
+
|
|
5083
|
+
//#endregion
|
|
5084
|
+
//#region src/toggle-group/ToggleGroup.vue?vue&type=script&setup=true&lang.ts
|
|
5085
|
+
/**
|
|
5086
|
+
* Provides a shared state to a series of toggle buttons.
|
|
5087
|
+
*
|
|
5088
|
+
* Documentation: [Base UI Vue Toggle Group](https://baseui-vue.com/docs/components/toggle-group)
|
|
5089
|
+
*/
|
|
5090
|
+
var ToggleGroup_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
5091
|
+
name: "ToggleGroup",
|
|
5092
|
+
inheritAttrs: false,
|
|
5093
|
+
__name: "ToggleGroup",
|
|
5094
|
+
props: {
|
|
5095
|
+
value: {
|
|
5096
|
+
type: Array,
|
|
5097
|
+
required: false
|
|
5098
|
+
},
|
|
5099
|
+
defaultValue: {
|
|
5100
|
+
type: Array,
|
|
5101
|
+
required: false
|
|
5102
|
+
},
|
|
5103
|
+
disabled: {
|
|
5104
|
+
type: Boolean,
|
|
5105
|
+
required: false,
|
|
5106
|
+
default: false
|
|
5107
|
+
},
|
|
5108
|
+
orientation: {
|
|
5109
|
+
type: String,
|
|
5110
|
+
required: false,
|
|
5111
|
+
default: "horizontal"
|
|
5112
|
+
},
|
|
5113
|
+
loopFocus: {
|
|
5114
|
+
type: Boolean,
|
|
5115
|
+
required: false,
|
|
5116
|
+
default: true
|
|
5117
|
+
},
|
|
5118
|
+
multiple: {
|
|
5119
|
+
type: Boolean,
|
|
5120
|
+
required: false,
|
|
5121
|
+
default: false
|
|
5122
|
+
},
|
|
5123
|
+
as: {
|
|
5124
|
+
type: null,
|
|
5125
|
+
required: false,
|
|
5126
|
+
default: "div"
|
|
5127
|
+
},
|
|
5128
|
+
class: {
|
|
5129
|
+
type: Function,
|
|
5130
|
+
required: false,
|
|
5131
|
+
skipCheck: true
|
|
5132
|
+
},
|
|
5133
|
+
style: {
|
|
5134
|
+
type: [
|
|
5135
|
+
Boolean,
|
|
5136
|
+
null,
|
|
5137
|
+
String,
|
|
5138
|
+
Object,
|
|
5139
|
+
Array,
|
|
5140
|
+
Function
|
|
5141
|
+
],
|
|
5142
|
+
required: false,
|
|
5143
|
+
skipCheck: true
|
|
5144
|
+
}
|
|
5145
|
+
},
|
|
5146
|
+
emits: ["valueChange"],
|
|
5147
|
+
setup(__props, { emit: __emit }) {
|
|
5148
|
+
const props = __props;
|
|
5149
|
+
const emit = __emit;
|
|
5150
|
+
const attrsObject = useAttrs();
|
|
5151
|
+
const toolbarContext = useToolbarRootContext(true);
|
|
5152
|
+
const disabled = computed(() => (toolbarContext?.disabled.value ?? false) || props.disabled);
|
|
5153
|
+
const isValueInitialized = computed(() => props.value !== void 0 || props.defaultValue !== void 0);
|
|
5154
|
+
const { value: groupValue, setValue: setValueState } = useControllableState({
|
|
5155
|
+
controlled: () => props.value,
|
|
5156
|
+
default: () => props.value === void 0 ? props.defaultValue ?? [] : [],
|
|
5157
|
+
name: "ToggleGroup"
|
|
5158
|
+
});
|
|
5159
|
+
function setGroupValue(newValue, nextPressed, eventDetails) {
|
|
5160
|
+
let newGroupValue;
|
|
5161
|
+
if (props.multiple) {
|
|
5162
|
+
newGroupValue = groupValue.value.slice();
|
|
5163
|
+
if (nextPressed) newGroupValue.push(newValue);
|
|
5164
|
+
else {
|
|
5165
|
+
const valueIndex = groupValue.value.indexOf(newValue);
|
|
5166
|
+
if (valueIndex >= 0) newGroupValue.splice(valueIndex, 1);
|
|
5167
|
+
}
|
|
5168
|
+
} else newGroupValue = nextPressed ? [newValue] : [];
|
|
5169
|
+
emit("valueChange", newGroupValue, eventDetails);
|
|
5170
|
+
if (eventDetails.isCanceled) return;
|
|
5171
|
+
setValueState(newGroupValue);
|
|
5172
|
+
}
|
|
5173
|
+
provide(toggleGroupContextKey, {
|
|
5174
|
+
disabled,
|
|
5175
|
+
orientation: computed(() => props.orientation),
|
|
5176
|
+
setGroupValue,
|
|
5177
|
+
value: groupValue,
|
|
5178
|
+
isValueInitialized
|
|
5179
|
+
});
|
|
5180
|
+
const state = computed(() => ({
|
|
5181
|
+
disabled: disabled.value,
|
|
5182
|
+
multiple: props.multiple,
|
|
5183
|
+
orientation: props.orientation
|
|
5184
|
+
}));
|
|
5185
|
+
const stateAttributesMapping = { multiple(value) {
|
|
5186
|
+
if (value) return { [ToggleGroupDataAttributes.multiple]: "" };
|
|
5187
|
+
return null;
|
|
5188
|
+
} };
|
|
5189
|
+
const forwardedAttrs = computed(() => {
|
|
5190
|
+
const { class: _class, style: _style, ...rest } = attrsObject;
|
|
5191
|
+
return rest;
|
|
5192
|
+
});
|
|
5193
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
5194
|
+
componentProps: props,
|
|
5195
|
+
state,
|
|
5196
|
+
props: computed(() => ({
|
|
5197
|
+
"role": "group",
|
|
5198
|
+
...forwardedAttrs.value,
|
|
5199
|
+
"aria-orientation": props.orientation
|
|
5200
|
+
})),
|
|
5201
|
+
stateAttributesMapping,
|
|
5202
|
+
defaultTagName: "div"
|
|
5203
|
+
});
|
|
5204
|
+
return (_ctx, _cache) => {
|
|
5205
|
+
return unref(toolbarContext) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
5206
|
+
key: 0,
|
|
5207
|
+
ref: unref(renderRef),
|
|
5208
|
+
props: unref(mergedProps),
|
|
5209
|
+
state: state.value
|
|
5210
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
5211
|
+
key: 1,
|
|
5212
|
+
ref: unref(renderRef)
|
|
5213
|
+
}, unref(mergedProps)), {
|
|
5214
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { state: state.value })]),
|
|
5215
|
+
_: 3
|
|
5216
|
+
}, 16))], 64)) : (openBlock(), createBlock(CompositeRoot_default, mergeProps({
|
|
5217
|
+
key: 1,
|
|
5218
|
+
as: __props.as,
|
|
5219
|
+
class: props.class,
|
|
5220
|
+
style: props.style,
|
|
5221
|
+
orientation: props.orientation,
|
|
5222
|
+
state: state.value,
|
|
5223
|
+
"state-attributes-mapping": stateAttributesMapping,
|
|
5224
|
+
"loop-focus": props.loopFocus,
|
|
5225
|
+
"enable-home-and-end-keys": true,
|
|
5226
|
+
role: "group"
|
|
5227
|
+
}, forwardedAttrs.value), createSlots({ _: 2 }, [unref(renderless) ? {
|
|
5228
|
+
name: "default",
|
|
5229
|
+
fn: withCtx(({ ref, props: compositeProps, state: compositeState }) => [renderSlot(_ctx.$slots, "default", {
|
|
5230
|
+
ref,
|
|
5231
|
+
props: compositeProps,
|
|
5232
|
+
state: compositeState
|
|
5233
|
+
})]),
|
|
5234
|
+
key: "0"
|
|
5235
|
+
} : {
|
|
5236
|
+
name: "default",
|
|
5237
|
+
fn: withCtx(({ state: compositeState }) => [renderSlot(_ctx.$slots, "default", { state: compositeState })]),
|
|
5238
|
+
key: "1"
|
|
5239
|
+
}]), 1040, [
|
|
5240
|
+
"as",
|
|
5241
|
+
"class",
|
|
5242
|
+
"style",
|
|
5243
|
+
"orientation",
|
|
5244
|
+
"state",
|
|
5245
|
+
"loop-focus"
|
|
5246
|
+
]));
|
|
5247
|
+
};
|
|
5248
|
+
}
|
|
5249
|
+
});
|
|
5250
|
+
|
|
5251
|
+
//#endregion
|
|
5252
|
+
//#region src/toggle-group/ToggleGroup.vue
|
|
5253
|
+
var ToggleGroup_default = ToggleGroup_vue_vue_type_script_setup_true_lang_default;
|
|
5254
|
+
|
|
5255
|
+
//#endregion
|
|
5256
|
+
//#region src/toolbar/input/ToolbarInput.vue?vue&type=script&setup=true&lang.ts
|
|
5257
|
+
/**
|
|
5258
|
+
* A native input element that integrates with Toolbar keyboard navigation.
|
|
5259
|
+
* Renders an `<input>` element.
|
|
5260
|
+
*
|
|
5261
|
+
* Documentation: [Base UI Vue Toolbar](https://baseui-vue.com/docs/components/toolbar)
|
|
5262
|
+
*/
|
|
5263
|
+
var ToolbarInput_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
5264
|
+
name: "ToolbarInput",
|
|
5265
|
+
inheritAttrs: false,
|
|
5266
|
+
__name: "ToolbarInput",
|
|
5267
|
+
props: {
|
|
5268
|
+
disabled: {
|
|
5269
|
+
type: Boolean,
|
|
5270
|
+
required: false,
|
|
5271
|
+
default: false
|
|
5272
|
+
},
|
|
5273
|
+
focusableWhenDisabled: {
|
|
5274
|
+
type: Boolean,
|
|
5275
|
+
required: false,
|
|
5276
|
+
default: true
|
|
5277
|
+
},
|
|
5278
|
+
defaultValue: {
|
|
5279
|
+
type: [String, Number],
|
|
5280
|
+
required: false
|
|
5281
|
+
},
|
|
5282
|
+
as: {
|
|
5283
|
+
type: null,
|
|
5284
|
+
required: false,
|
|
5285
|
+
default: "input"
|
|
5286
|
+
},
|
|
5287
|
+
class: {
|
|
5288
|
+
type: Function,
|
|
5289
|
+
required: false,
|
|
5290
|
+
skipCheck: true
|
|
5291
|
+
},
|
|
5292
|
+
style: {
|
|
5293
|
+
type: [
|
|
5294
|
+
Boolean,
|
|
5295
|
+
null,
|
|
5296
|
+
String,
|
|
5297
|
+
Object,
|
|
5298
|
+
Array,
|
|
5299
|
+
Function
|
|
5300
|
+
],
|
|
5301
|
+
required: false,
|
|
5302
|
+
skipCheck: true
|
|
5303
|
+
}
|
|
5304
|
+
},
|
|
5305
|
+
setup(__props) {
|
|
5306
|
+
const props = __props;
|
|
5307
|
+
const attrs = useAttrs();
|
|
5308
|
+
const toolbarRootContext = useToolbarRootContext();
|
|
5309
|
+
const toolbarGroupContext = useToolbarGroupContext(true);
|
|
5310
|
+
const disabled = computed(() => toolbarRootContext.disabled.value || (toolbarGroupContext?.disabled.value ?? false) || props.disabled);
|
|
5311
|
+
const { props: focusableWhenDisabledProps } = useFocusableWhenDisabled({
|
|
5312
|
+
composite: true,
|
|
5313
|
+
disabled,
|
|
5314
|
+
focusableWhenDisabled: () => props.focusableWhenDisabled,
|
|
5315
|
+
isNativeButton: false
|
|
5316
|
+
});
|
|
5317
|
+
const state = computed(() => ({
|
|
5318
|
+
disabled: disabled.value,
|
|
5319
|
+
orientation: toolbarRootContext.orientation.value,
|
|
5320
|
+
focusable: props.focusableWhenDisabled
|
|
5321
|
+
}));
|
|
5322
|
+
const allowedKeysWhenDisabled = computed(() => toolbarRootContext.orientation.value === "vertical" ? new Set([ARROW_UP$1, ARROW_DOWN$1]) : new Set([ARROW_LEFT$1, ARROW_RIGHT$1]));
|
|
5323
|
+
const defaultProps = computed(() => ({
|
|
5324
|
+
onClick(event) {
|
|
5325
|
+
if (disabled.value) event.preventDefault();
|
|
5326
|
+
},
|
|
5327
|
+
onKeydown(event) {
|
|
5328
|
+
if (disabled.value && !allowedKeysWhenDisabled.value.has(event.key)) stopEvent(event);
|
|
5329
|
+
},
|
|
5330
|
+
onPointerdown(event) {
|
|
5331
|
+
if (disabled.value) event.preventDefault();
|
|
5332
|
+
}
|
|
5333
|
+
}));
|
|
5334
|
+
return (_ctx, _cache) => {
|
|
5335
|
+
return openBlock(), createBlock(CompositeItem_default, {
|
|
5336
|
+
as: __props.as,
|
|
5337
|
+
class: normalizeClass(props.class),
|
|
5338
|
+
style: normalizeStyle(props.style),
|
|
5339
|
+
metadata: { focusableWhenDisabled: __props.focusableWhenDisabled },
|
|
5340
|
+
state: state.value,
|
|
5341
|
+
props: [
|
|
5342
|
+
defaultProps.value,
|
|
5343
|
+
unref(attrs),
|
|
5344
|
+
() => unref(focusableWhenDisabledProps)
|
|
5345
|
+
]
|
|
5346
|
+
}, null, 8, [
|
|
5347
|
+
"as",
|
|
5348
|
+
"class",
|
|
5349
|
+
"style",
|
|
5350
|
+
"metadata",
|
|
5351
|
+
"state",
|
|
5352
|
+
"props"
|
|
5353
|
+
]);
|
|
5354
|
+
};
|
|
5355
|
+
}
|
|
5356
|
+
});
|
|
5357
|
+
|
|
5358
|
+
//#endregion
|
|
5359
|
+
//#region src/toolbar/input/ToolbarInput.vue
|
|
5360
|
+
var ToolbarInput_default = ToolbarInput_vue_vue_type_script_setup_true_lang_default;
|
|
5361
|
+
|
|
5362
|
+
//#endregion
|
|
5363
|
+
//#region src/toolbar/input/ToolbarInputDataAttributes.ts
|
|
5364
|
+
let ToolbarInputDataAttributes = /* @__PURE__ */ function(ToolbarInputDataAttributes) {
|
|
5365
|
+
/**
|
|
5366
|
+
* Present when the input is disabled.
|
|
5367
|
+
*/
|
|
5368
|
+
ToolbarInputDataAttributes["disabled"] = "data-disabled";
|
|
5369
|
+
/**
|
|
5370
|
+
* Indicates the orientation of the toolbar.
|
|
5371
|
+
* @type {'horizontal' | 'vertical'}
|
|
5372
|
+
*/
|
|
5373
|
+
ToolbarInputDataAttributes["orientation"] = "data-orientation";
|
|
5374
|
+
/**
|
|
5375
|
+
* Present when the input remains focusable when disabled.
|
|
5376
|
+
*/
|
|
5377
|
+
ToolbarInputDataAttributes["focusable"] = "data-focusable";
|
|
5378
|
+
return ToolbarInputDataAttributes;
|
|
5379
|
+
}({});
|
|
5380
|
+
|
|
5381
|
+
//#endregion
|
|
5382
|
+
//#region src/toolbar/link/ToolbarLink.vue?vue&type=script&setup=true&lang.ts
|
|
5383
|
+
var ToolbarLink_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
5384
|
+
name: "ToolbarLink",
|
|
5385
|
+
inheritAttrs: false,
|
|
5386
|
+
__name: "ToolbarLink",
|
|
5387
|
+
props: {
|
|
5388
|
+
as: {
|
|
5389
|
+
type: null,
|
|
5390
|
+
required: false,
|
|
5391
|
+
default: "a"
|
|
5392
|
+
},
|
|
5393
|
+
class: {
|
|
5394
|
+
type: Function,
|
|
5395
|
+
required: false,
|
|
5396
|
+
skipCheck: true
|
|
5397
|
+
},
|
|
5398
|
+
style: {
|
|
5399
|
+
type: [
|
|
5400
|
+
Boolean,
|
|
5401
|
+
null,
|
|
5402
|
+
String,
|
|
5403
|
+
Object,
|
|
5404
|
+
Array,
|
|
5405
|
+
Function
|
|
5406
|
+
],
|
|
5407
|
+
required: false,
|
|
5408
|
+
skipCheck: true
|
|
5409
|
+
}
|
|
5410
|
+
},
|
|
5411
|
+
setup(__props) {
|
|
5412
|
+
const props = __props;
|
|
5413
|
+
const TOOLBAR_LINK_METADATA = { focusableWhenDisabled: true };
|
|
5414
|
+
const attrs = useAttrs();
|
|
5415
|
+
const toolbarRootContext = useToolbarRootContext();
|
|
5416
|
+
const state = computed(() => ({ orientation: toolbarRootContext.orientation.value }));
|
|
5417
|
+
return (_ctx, _cache) => {
|
|
5418
|
+
return openBlock(), createBlock(CompositeItem_default, {
|
|
5419
|
+
as: __props.as,
|
|
5420
|
+
class: normalizeClass(props.class),
|
|
5421
|
+
style: normalizeStyle(props.style),
|
|
5422
|
+
metadata: TOOLBAR_LINK_METADATA,
|
|
5423
|
+
state: state.value,
|
|
5424
|
+
props: [unref(attrs)]
|
|
5425
|
+
}, {
|
|
5426
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { state: state.value })]),
|
|
5427
|
+
_: 3
|
|
5428
|
+
}, 8, [
|
|
5429
|
+
"as",
|
|
5430
|
+
"class",
|
|
5431
|
+
"style",
|
|
5432
|
+
"state",
|
|
5433
|
+
"props"
|
|
5434
|
+
]);
|
|
5435
|
+
};
|
|
5436
|
+
}
|
|
5437
|
+
});
|
|
5438
|
+
|
|
5439
|
+
//#endregion
|
|
5440
|
+
//#region src/toolbar/link/ToolbarLink.vue
|
|
5441
|
+
var ToolbarLink_default = ToolbarLink_vue_vue_type_script_setup_true_lang_default;
|
|
5442
|
+
|
|
5443
|
+
//#endregion
|
|
5444
|
+
//#region src/toolbar/link/ToolbarLinkDataAttributes.ts
|
|
5445
|
+
let ToolbarLinkDataAttributes = /* @__PURE__ */ function(ToolbarLinkDataAttributes) {
|
|
5446
|
+
/**
|
|
5447
|
+
* Indicates the orientation of the toolbar.
|
|
5448
|
+
* @type {'horizontal' | 'vertical'}
|
|
5449
|
+
*/
|
|
5450
|
+
ToolbarLinkDataAttributes["orientation"] = "data-orientation";
|
|
5451
|
+
return ToolbarLinkDataAttributes;
|
|
5452
|
+
}({});
|
|
5453
|
+
|
|
5454
|
+
//#endregion
|
|
5455
|
+
//#region src/toolbar/root/ToolbarRoot.vue?vue&type=script&setup=true&lang.ts
|
|
5456
|
+
/**
|
|
5457
|
+
* A container for grouping a set of controls, such as buttons, toggle groups, or menus.
|
|
5458
|
+
* Renders a `<div>` element.
|
|
5459
|
+
*
|
|
5460
|
+
* Documentation: [Base UI Vue Toolbar](https://baseui-vue.com/docs/components/toolbar)
|
|
5461
|
+
*/
|
|
5462
|
+
var ToolbarRoot_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
5463
|
+
name: "ToolbarRoot",
|
|
5464
|
+
inheritAttrs: false,
|
|
5465
|
+
__name: "ToolbarRoot",
|
|
5466
|
+
props: {
|
|
5467
|
+
disabled: {
|
|
5468
|
+
type: Boolean,
|
|
5469
|
+
required: false,
|
|
5470
|
+
default: false
|
|
5471
|
+
},
|
|
5472
|
+
orientation: {
|
|
5473
|
+
type: String,
|
|
5474
|
+
required: false,
|
|
5475
|
+
default: "horizontal"
|
|
5476
|
+
},
|
|
5477
|
+
loopFocus: {
|
|
5478
|
+
type: Boolean,
|
|
5479
|
+
required: false,
|
|
5480
|
+
default: true
|
|
5481
|
+
},
|
|
5482
|
+
as: {
|
|
5483
|
+
type: null,
|
|
5484
|
+
required: false,
|
|
5485
|
+
default: "div"
|
|
5486
|
+
},
|
|
5487
|
+
class: {
|
|
5488
|
+
type: Function,
|
|
5489
|
+
required: false,
|
|
5490
|
+
skipCheck: true
|
|
5491
|
+
},
|
|
5492
|
+
style: {
|
|
5493
|
+
type: [
|
|
5494
|
+
Boolean,
|
|
5495
|
+
null,
|
|
5496
|
+
String,
|
|
5497
|
+
Object,
|
|
5498
|
+
Array,
|
|
5499
|
+
Function
|
|
5500
|
+
],
|
|
5501
|
+
required: false,
|
|
5502
|
+
skipCheck: true
|
|
5503
|
+
}
|
|
5504
|
+
},
|
|
5505
|
+
setup(__props) {
|
|
5506
|
+
const props = __props;
|
|
5507
|
+
const attrs = useAttrs();
|
|
5508
|
+
const direction = useDirection();
|
|
5509
|
+
const itemMap = ref(/* @__PURE__ */ new Map());
|
|
5510
|
+
const disabledIndices = computed(() => {
|
|
5511
|
+
const output = [];
|
|
5512
|
+
itemMap.value.forEach((itemMetadata, element) => {
|
|
5513
|
+
if (itemMetadata?.index != null && !itemMetadata.focusableWhenDisabled && isElementDisabled(element)) output.push(itemMetadata.index);
|
|
5514
|
+
});
|
|
5515
|
+
return output;
|
|
5516
|
+
});
|
|
5517
|
+
const state = computed(() => ({
|
|
5518
|
+
disabled: props.disabled,
|
|
5519
|
+
orientation: props.orientation
|
|
5520
|
+
}));
|
|
5521
|
+
const root = useCompositeRoot({
|
|
5522
|
+
orientation: () => props.orientation,
|
|
5523
|
+
loopFocus: () => props.loopFocus,
|
|
5524
|
+
direction: () => direction.value,
|
|
5525
|
+
disabledIndices: () => disabledIndices.value
|
|
5526
|
+
});
|
|
5527
|
+
provide(toolbarRootContextKey, {
|
|
5528
|
+
disabled: computed(() => props.disabled),
|
|
5529
|
+
orientation: computed(() => props.orientation)
|
|
5530
|
+
});
|
|
5531
|
+
provide(compositeRootContextKey, reactive({
|
|
5532
|
+
highlightedIndex: root.highlightedIndex,
|
|
5533
|
+
onHighlightedIndexChange: root.onHighlightedIndexChange,
|
|
5534
|
+
highlightItemOnHover: computed(() => false),
|
|
5535
|
+
relayKeyboardEvent: root.relayKeyboardEvent
|
|
5536
|
+
}));
|
|
5537
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
5538
|
+
componentProps: props,
|
|
5539
|
+
state,
|
|
5540
|
+
props: computed(() => ({
|
|
5541
|
+
...root.getRootProps(attrs),
|
|
5542
|
+
"role": "toolbar",
|
|
5543
|
+
"aria-orientation": props.orientation
|
|
5544
|
+
})),
|
|
5545
|
+
defaultTagName: "div",
|
|
5546
|
+
ref: root.mergedRef
|
|
5547
|
+
});
|
|
5548
|
+
function handleMapChange(newMap) {
|
|
5549
|
+
const typedMap = newMap;
|
|
5550
|
+
itemMap.value = typedMap;
|
|
5551
|
+
root.onMapChange(typedMap);
|
|
5552
|
+
}
|
|
5553
|
+
return (_ctx, _cache) => {
|
|
5554
|
+
return openBlock(), createBlock(CompositeList_default, {
|
|
5555
|
+
"elements-ref": unref(root).elementsRef,
|
|
5556
|
+
onMapChange: handleMapChange
|
|
5557
|
+
}, {
|
|
5558
|
+
default: withCtx(() => [unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
5559
|
+
key: 0,
|
|
5560
|
+
ref: unref(renderRef),
|
|
5561
|
+
props: unref(mergedProps),
|
|
5562
|
+
state: state.value
|
|
5563
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
5564
|
+
key: 1,
|
|
5565
|
+
ref: unref(renderRef)
|
|
5566
|
+
}, unref(mergedProps)), {
|
|
5567
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", { state: state.value })]),
|
|
5568
|
+
_: 3
|
|
5569
|
+
}, 16))]),
|
|
5570
|
+
_: 3
|
|
5571
|
+
}, 8, ["elements-ref"]);
|
|
5572
|
+
};
|
|
5573
|
+
}
|
|
5574
|
+
});
|
|
5575
|
+
|
|
5576
|
+
//#endregion
|
|
5577
|
+
//#region src/toolbar/root/ToolbarRoot.vue
|
|
5578
|
+
var ToolbarRoot_default = ToolbarRoot_vue_vue_type_script_setup_true_lang_default;
|
|
5579
|
+
|
|
5580
|
+
//#endregion
|
|
5581
|
+
//#region src/toolbar/root/ToolbarRootDataAttributes.ts
|
|
5582
|
+
let ToolbarRootDataAttributes = /* @__PURE__ */ function(ToolbarRootDataAttributes) {
|
|
5583
|
+
/**
|
|
5584
|
+
* Present when the toolbar is disabled.
|
|
5585
|
+
*/
|
|
5586
|
+
ToolbarRootDataAttributes["disabled"] = "data-disabled";
|
|
5587
|
+
/**
|
|
5588
|
+
* Indicates the orientation of the toolbar.
|
|
5589
|
+
* @type {'horizontal' | 'vertical'}
|
|
5590
|
+
*/
|
|
5591
|
+
ToolbarRootDataAttributes["orientation"] = "data-orientation";
|
|
5592
|
+
return ToolbarRootDataAttributes;
|
|
5593
|
+
}({});
|
|
5594
|
+
|
|
5595
|
+
//#endregion
|
|
5596
|
+
//#region src/toolbar/separator/ToolbarSeparator.vue?vue&type=script&setup=true&lang.ts
|
|
5597
|
+
/**
|
|
5598
|
+
* A separator element accessible to screen readers.
|
|
5599
|
+
* Renders a `<div>` element.
|
|
5600
|
+
*
|
|
5601
|
+
* Documentation: [Base UI Vue Toolbar](https://baseui-vue.com/docs/components/toolbar)
|
|
5602
|
+
*/
|
|
5603
|
+
var ToolbarSeparator_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
5604
|
+
name: "ToolbarSeparator",
|
|
5605
|
+
inheritAttrs: false,
|
|
5606
|
+
__name: "ToolbarSeparator",
|
|
5607
|
+
props: {
|
|
5608
|
+
orientation: {
|
|
5609
|
+
type: String,
|
|
5610
|
+
required: false
|
|
5611
|
+
},
|
|
5612
|
+
as: {
|
|
5613
|
+
type: null,
|
|
5614
|
+
required: false
|
|
5615
|
+
},
|
|
5616
|
+
class: {
|
|
5617
|
+
type: Function,
|
|
5618
|
+
required: false,
|
|
5619
|
+
skipCheck: true
|
|
5620
|
+
},
|
|
5621
|
+
style: {
|
|
5622
|
+
type: [
|
|
5623
|
+
Boolean,
|
|
5624
|
+
null,
|
|
5625
|
+
String,
|
|
5626
|
+
Object,
|
|
5627
|
+
Array,
|
|
5628
|
+
Function
|
|
5629
|
+
],
|
|
5630
|
+
required: false,
|
|
5631
|
+
skipCheck: true
|
|
5632
|
+
}
|
|
5633
|
+
},
|
|
5634
|
+
setup(__props) {
|
|
5635
|
+
const props = __props;
|
|
5636
|
+
const attrs = useAttrs();
|
|
5637
|
+
const toolbarRootContext = useToolbarRootContext();
|
|
5638
|
+
const orientation = computed(() => props.orientation ?? (toolbarRootContext.orientation.value === "vertical" ? "horizontal" : "vertical"));
|
|
5639
|
+
return (_ctx, _cache) => {
|
|
5640
|
+
return openBlock(), createBlock(Separator_default, mergeProps({
|
|
5641
|
+
as: props.as,
|
|
5642
|
+
class: props.class,
|
|
5643
|
+
style: props.style,
|
|
5644
|
+
orientation: orientation.value
|
|
5645
|
+
}, unref(attrs)), {
|
|
5646
|
+
default: withCtx((slotProps) => [renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(slotProps)))]),
|
|
5647
|
+
_: 3
|
|
5648
|
+
}, 16, [
|
|
5649
|
+
"as",
|
|
5650
|
+
"class",
|
|
5651
|
+
"style",
|
|
5652
|
+
"orientation"
|
|
5653
|
+
]);
|
|
5654
|
+
};
|
|
5655
|
+
}
|
|
5656
|
+
});
|
|
5657
|
+
|
|
5658
|
+
//#endregion
|
|
5659
|
+
//#region src/toolbar/separator/ToolbarSeparator.vue
|
|
5660
|
+
var ToolbarSeparator_default = ToolbarSeparator_vue_vue_type_script_setup_true_lang_default;
|
|
5661
|
+
|
|
5662
|
+
//#endregion
|
|
5663
|
+
//#region src/toolbar/separator/ToolbarSeparatorDataAttributes.ts
|
|
5664
|
+
let ToolbarSeparatorDataAttributes = /* @__PURE__ */ function(ToolbarSeparatorDataAttributes) {
|
|
5665
|
+
/**
|
|
5666
|
+
* Indicates the orientation of the toolbar.
|
|
5667
|
+
* @type {'horizontal' | 'vertical'}
|
|
5668
|
+
*/
|
|
5669
|
+
ToolbarSeparatorDataAttributes["orientation"] = "data-orientation";
|
|
5670
|
+
return ToolbarSeparatorDataAttributes;
|
|
5671
|
+
}({});
|
|
5672
|
+
|
|
2578
5673
|
//#endregion
|
|
2579
5674
|
//#region src/use-render/useRender.ts
|
|
2580
5675
|
/**
|
|
@@ -2614,5 +5709,5 @@ const name = "base-ui-vue";
|
|
|
2614
5709
|
const version = "0.0.0";
|
|
2615
5710
|
|
|
2616
5711
|
//#endregion
|
|
2617
|
-
export { AccordionItem_default, AccordionPanel_default, AccordionRoot_default, AccordionTrigger_default, AvatarRoot_default, CollapsiblePanel_default, CollapsibleRoot_default, CollapsibleTrigger_default, FieldItem_default, FieldLabel_default, FieldRoot_default, FieldValidity_default, FieldsetLegend_default, FieldsetRoot_default, accordionRootContextKey, collapsibleRootContextKey,
|
|
5712
|
+
export { AccordionItem_default, AccordionPanel_default, AccordionRoot_default, AccordionTrigger_default, AvatarRoot_default, CollapsiblePanel_default, CollapsibleRoot_default, CollapsibleTrigger_default, FieldItem_default, FieldLabel_default, FieldRoot_default, FieldValidity_default, FieldsetLegend_default, FieldsetRoot_default, SeparatorDataAttributes, Separator_default, SliderIndicatorDataAttributes, SliderIndicator_default, SliderLabel_default, SliderRootDataAttributes, SliderRoot_default, SliderThumbDataAttributes, SliderThumb_default, SliderTrackDataAttributes, SliderTrack_default, SliderValueDataAttributes, SliderValue_default, SwitchRootDataAttributes, SwitchRoot_default, SwitchThumbDataAttributes, SwitchThumb_default, ToggleDataAttributes, ToggleGroupDataAttributes, ToggleGroup_default, Toggle_default, ToolbarInputDataAttributes, ToolbarInput_default, ToolbarLinkDataAttributes, ToolbarLink_default, ToolbarRootDataAttributes, ToolbarRoot_default, ToolbarSeparatorDataAttributes, ToolbarSeparator_default, accordionRootContextKey, collapsibleRootContextKey, fieldsetRootContextKey, name, switchRootContextKey, toggleGroupContextKey, useAccordionRootContext, useCollapsibleRootContext, useFieldsetRootContext, useRender, useSwitchRootContext, useToggleGroupContext, version };
|
|
2618
5713
|
//# sourceMappingURL=index2.js.map
|