ropav 0.1.7 → 0.1.8
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 +1 -1
- package/dist/ancestry.js +136 -0
- package/dist/calendar.css +173 -0
- package/dist/calendar.js +714 -0
- package/dist/calendar2.js +37 -0
- package/dist/chevron-left.js +12 -0
- package/dist/color-picker.js +38 -88
- package/dist/combobox.css +251 -0
- package/dist/combobox.js +410 -0
- package/dist/components/calendar/calendar.d.ts +30 -0
- package/dist/components/calendar/calendarBehavior.d.ts +49 -0
- package/dist/components/calendar/index.d.ts +3 -0
- package/dist/components/calendar/index.js +3 -0
- package/dist/components/calendar/types.d.ts +53 -0
- package/dist/components/calendar/useCalendar.d.ts +24 -0
- package/dist/components/color-picker/useColorPickerDrag.d.ts +1 -1
- package/dist/components/color-picker/useColorPickerSaturation.d.ts +1 -1
- package/dist/components/color-picker/useColorPickerSlider.d.ts +1 -1
- package/dist/components/combobox/combobox.d.ts +29 -0
- package/dist/components/combobox/comboboxModel.d.ts +4 -0
- package/dist/components/combobox/index.d.ts +3 -0
- package/dist/components/combobox/index.js +2 -0
- package/dist/components/combobox/types.d.ts +43 -0
- package/dist/components/combobox/useCombobox.d.ts +45 -0
- package/dist/components/date-picker/date-picker.d.ts +33 -0
- package/dist/components/date-picker/datePickerModel.d.ts +10 -0
- package/dist/components/date-picker/index.d.ts +4 -0
- package/dist/components/date-picker/index.js +2 -0
- package/dist/components/date-picker/types.d.ts +57 -0
- package/dist/components/date-picker/useDatePicker.d.ts +29 -0
- package/dist/components/date-picker/useDatePickerValueState.d.ts +21 -0
- package/dist/components/dropdown-menu/dropdown-menu-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdownMenuContext.d.ts +7 -18
- package/dist/components/dropdown-menu/dropdownMenuInteraction.d.ts +3 -3
- package/dist/components/dropdown-menu/dropdownMenuInteractionTypes.d.ts +58 -29
- package/dist/components/dropdown-menu/useDropdownMenuDataController.d.ts +4 -3
- package/dist/components/dropdown-menu/useDropdownMenuDataRegistration.d.ts +6 -4
- package/dist/components/dropdown-menu/useDropdownMenuPresentation.d.ts +3 -4
- package/dist/components/dropdown-menu/useDropdownMenuTargetBindings.d.ts +5 -5
- package/dist/components/dropzone/dropzone.d.ts +31 -0
- package/dist/components/dropzone/dropzoneModel.d.ts +16 -0
- package/dist/components/dropzone/index.d.ts +3 -0
- package/dist/components/dropzone/index.js +2 -0
- package/dist/components/dropzone/types.d.ts +56 -0
- package/dist/components/dropzone/useDropzone.d.ts +25 -0
- package/dist/components/file-input/file-input.d.ts +29 -0
- package/dist/components/file-input/index.d.ts +3 -0
- package/dist/components/file-input/index.js +2 -0
- package/dist/components/file-input/types.d.ts +37 -0
- package/dist/components/file-input/useFileInput.d.ts +15 -0
- package/dist/components/floating/index.js +1 -1
- package/dist/components/floating/useFloatingPosition.d.ts +1 -13
- package/dist/components/floating/useFloatingTargetLifecycle.d.ts +32 -0
- package/dist/components/floating/useHoverDisclosure.d.ts +10 -0
- package/dist/components/hover-card/hover-card.d.ts +25 -0
- package/dist/components/hover-card/index.d.ts +3 -0
- package/dist/components/hover-card/index.js +2 -0
- package/dist/components/hover-card/types.d.ts +45 -0
- package/dist/components/hover-card/useHoverCard.d.ts +22 -0
- package/dist/components/hover-card/useHoverCardDisclosure.d.ts +19 -0
- package/dist/components/multi-select/index.d.ts +3 -0
- package/dist/components/multi-select/index.js +2 -0
- package/dist/components/multi-select/multi-select.d.ts +30 -0
- package/dist/components/multi-select/multiSelectModel.d.ts +3 -0
- package/dist/components/multi-select/types.d.ts +49 -0
- package/dist/components/multi-select/useMultiSelect.d.ts +46 -0
- package/dist/components/number-input/useNumberInput.d.ts +1 -3
- package/dist/components/popover/usePopoverBindings.d.ts +3 -6
- package/dist/components/scroll-area/useScrollArea.d.ts +4 -4
- package/dist/components/scroll-area/useScrollAreaAttributes.d.ts +3 -3
- package/dist/components/scroll-area/useScrollAreaPointer.d.ts +1 -1
- package/dist/components/segmented-control/index.d.ts +3 -0
- package/dist/components/segmented-control/index.js +2 -0
- package/dist/components/segmented-control/segmented-control.d.ts +26 -0
- package/dist/components/segmented-control/types.d.ts +47 -0
- package/dist/components/segmented-control/useSegmentedControl.d.ts +15 -0
- package/dist/components/select/useSelect.d.ts +31 -19
- package/dist/components/slider/useRangeSlider.d.ts +1 -1
- package/dist/components/slider/useRangeSliderPointer.d.ts +1 -1
- package/dist/components/tags-input/index.d.ts +3 -0
- package/dist/components/tags-input/index.js +2 -0
- package/dist/components/tags-input/tags-input.d.ts +27 -0
- package/dist/components/tags-input/tagsInputModel.d.ts +12 -0
- package/dist/components/tags-input/types.d.ts +37 -0
- package/dist/components/tags-input/useTagsInput.d.ts +23 -0
- package/dist/components/tooltip/useTooltipTargetBindings.d.ts +12 -0
- package/dist/date-picker.css +49 -0
- package/dist/date-picker.js +809 -0
- package/dist/dialog.js +9 -20
- package/dist/direction.js +6 -0
- package/dist/dropdown-menu.css +21 -3
- package/dist/dropdown-menu.js +341 -261
- package/dist/dropzone.css +135 -0
- package/dist/dropzone.js +431 -0
- package/dist/file-input.css +135 -0
- package/dist/file-input.js +198 -0
- package/dist/hover-card.css +80 -0
- package/dist/hover-card.js +402 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +14 -3
- package/dist/internal/composables/useOverlayLayer.d.ts +12 -0
- package/dist/modal.js +1 -1
- package/dist/multi-select.css +316 -0
- package/dist/multi-select.js +481 -0
- package/dist/nativeChoice.js +169 -0
- package/dist/number-input.css +18 -18
- package/dist/number-input.js +36 -38
- package/dist/pagination.js +1 -10
- package/dist/pointerSession.js +130 -0
- package/dist/popover.css +21 -3
- package/dist/popover.js +37 -62
- package/dist/scroll-area.js +52 -62
- package/dist/segmented-control.css +176 -0
- package/dist/segmented-control.js +382 -0
- package/dist/select.css +50 -48
- package/dist/select.js +121 -271
- package/dist/slider.js +70 -129
- package/dist/tags-input.css +197 -0
- package/dist/tags-input.js +380 -0
- package/dist/tooltip.js +35 -30
- package/dist/useEditableOptionList.js +216 -0
- package/dist/useFlatOptionCollection.js +134 -0
- package/dist/useFloatingPosition.js +4 -160
- package/dist/useFloatingTargetLifecycle.js +127 -0
- package/dist/useFormControl.js +1 -0
- package/dist/{floating.js → useHoverDisclosure.js} +338 -421
- package/dist/useNativeChoiceTransaction.js +46 -0
- package/dist/useNativeFileSelection.js +86 -0
- package/dist/useOverlayZIndex.js +246 -15
- package/dist/utils/date.d.ts +13 -0
- package/dist/utils/dateAvailability.d.ts +7 -0
- package/dist/utils/dom/ancestry.d.ts +1 -0
- package/dist/utils/dom/direction.d.ts +2 -0
- package/dist/utils/dom/files.d.ts +3 -0
- package/dist/utils/dom/nativeChoice.d.ts +17 -0
- package/dist/utils/dom/pointerSession.d.ts +20 -0
- package/dist/utils/dom/scroll.d.ts +2 -1
- package/dist/utils/optionFilter.d.ts +5 -0
- package/docs/public-floating-api.md +7 -4
- package/docs/public-styles-api.md +25 -12
- package/package.json +39 -3
- package/src/styles/_mixins.scss +26 -0
- package/src/styles/styles-manifest.json +1 -2
- package/dist/components/floating/hoverDisclosureInteractionModel.d.ts +0 -42
- package/dist/components/floating/useHoverDisclosureInteractions.d.ts +0 -32
- package/dist/components/floating/useHoverDisclosureOpenState.d.ts +0 -25
- package/dist/components/floating/useHoverDisclosureTargetBinding.d.ts +0 -27
- package/dist/components/select/useSelectNativeControl.d.ts +0 -9
- package/dist/components/select/useSelectNativeValue.d.ts +0 -9
- package/dist/pointer.js +0 -9
- package/dist/utils/dom/pointer.d.ts +0 -2
package/dist/select.js
CHANGED
|
@@ -1,124 +1,18 @@
|
|
|
1
1
|
import './select.css';
|
|
2
|
-
import { t as useControllableValue } from "./useControllableValue.js";
|
|
3
2
|
import { t as useStylesApi } from "./styles-api.js";
|
|
4
3
|
import { n as toPresenceAttribute } from "./attributes.js";
|
|
5
4
|
import { t as bem } from "./bem.js";
|
|
6
|
-
import { n as getNextEnabledIndex, t as getEnabledIndexes } from "./collectionNavigation.js";
|
|
7
5
|
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
8
6
|
import { t as x_default } from "./x.js";
|
|
9
|
-
import { i as useFormControl } from "./useFormControl.js";
|
|
10
|
-
import { o as splitCompatibilityAttributes, t as composeEventHandlers } from "./attributes2.js";
|
|
11
7
|
import { t as useControlState } from "./useControlState.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
8
|
+
import { t as resolveHTMLElementRef } from "./componentRef.js";
|
|
9
|
+
import { i as isNodeWithinElement } from "./events.js";
|
|
10
|
+
import { t as useFloatingPosition } from "./useFloatingPosition.js";
|
|
11
|
+
import { n as useClickOutside, r as chevrons_up_down_default, t as useFlatOptionCollection } from "./useFlatOptionCollection.js";
|
|
14
12
|
import { t as scroll_area_default } from "./scroll-area.js";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function render(_ctx) {
|
|
19
|
-
return t0$1();
|
|
20
|
-
}
|
|
21
|
-
var chevrons_up_down_default = markRaw(defineVaporComponent({
|
|
22
|
-
name: "lucide-chevrons-up-down",
|
|
23
|
-
render
|
|
24
|
-
}));
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/internal/composables/useClickOutside.ts
|
|
27
|
-
function useClickOutside(target, active, callback) {
|
|
28
|
-
const targets = Array.isArray(target) ? target : [target];
|
|
29
|
-
const listeningDocuments = /* @__PURE__ */ new Set();
|
|
30
|
-
let stopWatch;
|
|
31
|
-
function handler(event) {
|
|
32
|
-
if (!targets.some((current) => {
|
|
33
|
-
const element = current.value;
|
|
34
|
-
return element ? isEventWithinElement(event, element) : false;
|
|
35
|
-
})) callback(event);
|
|
36
|
-
}
|
|
37
|
-
function detachListeners() {
|
|
38
|
-
for (const document of listeningDocuments) document.removeEventListener("click", handler, true);
|
|
39
|
-
listeningDocuments.clear();
|
|
40
|
-
}
|
|
41
|
-
function syncListeners() {
|
|
42
|
-
detachListeners();
|
|
43
|
-
if (!active.value) return;
|
|
44
|
-
for (const current of targets) {
|
|
45
|
-
const document = current.value?.ownerDocument;
|
|
46
|
-
if (!document || listeningDocuments.has(document)) continue;
|
|
47
|
-
document.addEventListener("click", handler, true);
|
|
48
|
-
listeningDocuments.add(document);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
onMounted(() => {
|
|
52
|
-
stopWatch = watch([active, ...targets], syncListeners, { immediate: true });
|
|
53
|
-
});
|
|
54
|
-
onBeforeUnmount(() => {
|
|
55
|
-
stopWatch?.();
|
|
56
|
-
detachListeners();
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/internal/composables/useCollectionNavigation.ts
|
|
61
|
-
function useCollectionNavigation(options) {
|
|
62
|
-
const activeKey = shallowRef(null);
|
|
63
|
-
const isDisabled = options.isDisabled ?? (() => false);
|
|
64
|
-
const loop = options.loop ?? true;
|
|
65
|
-
const activeIndex = computed(() => {
|
|
66
|
-
if (activeKey.value == null) return -1;
|
|
67
|
-
return options.items().findIndex((item) => options.getKey(item) === activeKey.value && !isDisabled(item));
|
|
68
|
-
});
|
|
69
|
-
const enabledIndexes = computed(() => getEnabledIndexes(options.items(), isDisabled));
|
|
70
|
-
function resetActive() {
|
|
71
|
-
activeKey.value = null;
|
|
72
|
-
}
|
|
73
|
-
function setActiveIndex(index) {
|
|
74
|
-
const item = options.items()[index];
|
|
75
|
-
if (!item || isDisabled(item)) return false;
|
|
76
|
-
activeKey.value = options.getKey(item);
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
function focusSelected() {
|
|
80
|
-
const items = options.items();
|
|
81
|
-
const selectedIndex = options.isSelected ? items.findIndex((item) => options.isSelected(item) && !isDisabled(item)) : -1;
|
|
82
|
-
if (selectedIndex >= 0) setActiveIndex(selectedIndex);
|
|
83
|
-
else focusFirst();
|
|
84
|
-
}
|
|
85
|
-
function focusFirst() {
|
|
86
|
-
const first = enabledIndexes.value[0];
|
|
87
|
-
if (first === void 0) resetActive();
|
|
88
|
-
else setActiveIndex(first);
|
|
89
|
-
}
|
|
90
|
-
function focusLast() {
|
|
91
|
-
const indexes = enabledIndexes.value;
|
|
92
|
-
const last = indexes[indexes.length - 1];
|
|
93
|
-
if (last === void 0) resetActive();
|
|
94
|
-
else setActiveIndex(last);
|
|
95
|
-
}
|
|
96
|
-
function moveFocus(direction) {
|
|
97
|
-
if (activeIndex.value < 0) {
|
|
98
|
-
if (direction === 1) focusFirst();
|
|
99
|
-
else focusLast();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const nextIndex = getNextEnabledIndex(options.items(), activeIndex.value, direction, isDisabled, loop);
|
|
103
|
-
if (nextIndex === void 0) resetActive();
|
|
104
|
-
else setActiveIndex(nextIndex);
|
|
105
|
-
}
|
|
106
|
-
watch(activeIndex, (index) => {
|
|
107
|
-
if (activeKey.value != null && index < 0) resetActive();
|
|
108
|
-
}, { flush: "sync" });
|
|
109
|
-
return {
|
|
110
|
-
activeKey,
|
|
111
|
-
activeIndex,
|
|
112
|
-
enabledIndexes,
|
|
113
|
-
resetActive,
|
|
114
|
-
setActiveIndex,
|
|
115
|
-
focusSelected,
|
|
116
|
-
focusFirst,
|
|
117
|
-
focusLast,
|
|
118
|
-
moveFocus
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
//#endregion
|
|
13
|
+
import { i as useHiddenSelectChoiceTransaction, n as createSingleNativeChoiceAdapter } from "./nativeChoice.js";
|
|
14
|
+
import { t as useTypeahead } from "./useTypeahead.js";
|
|
15
|
+
import { VaporTransition, child, computed, createComponent, createFor, createIf, createSlot, createTemplateRefSetter, defineVaporComponent, extend, next, nextTick, on, ref, renderEffect, setDynamicProps, setInsertionState, setProp, setTemplateRefBinding, setText, setValue, template, toDisplayString, txt, unref, useId, withModifiers } from "vue";
|
|
122
16
|
//#region src/components/select/useSelect.ts
|
|
123
17
|
function hasSelectValue(value) {
|
|
124
18
|
return value != null && value !== "";
|
|
@@ -127,36 +21,72 @@ function getSelectDisplayLabel(options, value) {
|
|
|
127
21
|
if (!hasSelectValue(value)) return "";
|
|
128
22
|
return options?.find((option) => option.value === value)?.label ?? "";
|
|
129
23
|
}
|
|
130
|
-
function
|
|
131
|
-
|
|
24
|
+
function useSelectTransaction(props, emitUpdate, triggerRef) {
|
|
25
|
+
const transaction = useHiddenSelectChoiceTransaction({
|
|
26
|
+
value: {
|
|
27
|
+
modelValue: () => props.modelValue,
|
|
28
|
+
defaultValue: () => props.defaultValue ?? null,
|
|
29
|
+
onChange: emitUpdate
|
|
30
|
+
},
|
|
31
|
+
native: {
|
|
32
|
+
adapter: createSingleNativeChoiceAdapter({
|
|
33
|
+
emptyValue: null,
|
|
34
|
+
options: () => props.options
|
|
35
|
+
}),
|
|
36
|
+
attributes: () => props.inputAttrs,
|
|
37
|
+
className: "rp-select__native",
|
|
38
|
+
focusVisible: () => triggerRef.value?.focus(),
|
|
39
|
+
validationMessage: () => props.validationMessage
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
nativeSelectRef: transaction.nativeSelectRef,
|
|
44
|
+
nativeInputAttrs: transaction.nativeSelectAttrs,
|
|
45
|
+
requestValueUpdate: transaction.requestValueUpdate,
|
|
46
|
+
selectedValue: transaction.value
|
|
47
|
+
};
|
|
132
48
|
}
|
|
133
|
-
function useSelect(props, emitUpdate
|
|
49
|
+
function useSelect(props, emitUpdate) {
|
|
134
50
|
const selectRef = ref(null);
|
|
51
|
+
const triggerRef = ref(null);
|
|
52
|
+
const dropdownRef = ref(null);
|
|
135
53
|
const isOpen = ref(false);
|
|
54
|
+
const transaction = useSelectTransaction(props, emitUpdate, triggerRef);
|
|
55
|
+
const value = transaction.selectedValue;
|
|
136
56
|
const selectId = useId();
|
|
137
57
|
const popupId = `${selectId}-popup`;
|
|
138
58
|
const listboxId = `${popupId}-viewport`;
|
|
139
59
|
const control = useControlState(props);
|
|
140
60
|
const visibleOptions = computed(() => props.options ?? []);
|
|
141
|
-
const
|
|
142
|
-
const navigation = useCollectionNavigation({
|
|
61
|
+
const optionCollection = useFlatOptionCollection({
|
|
143
62
|
items: () => visibleOptions.value,
|
|
63
|
+
baseId: selectId,
|
|
64
|
+
isOpen: () => isOpen.value,
|
|
65
|
+
collectionRef: selectRef,
|
|
144
66
|
getKey: (item) => item.value,
|
|
145
67
|
isDisabled: (item) => Boolean(item.disabled),
|
|
146
68
|
isSelected: (item) => item.value === value.value
|
|
147
69
|
});
|
|
148
|
-
const
|
|
70
|
+
const renderedOptions = optionCollection.options;
|
|
71
|
+
const focusedIndex = optionCollection.activeIndex;
|
|
149
72
|
const selectedIndex = computed(() => visibleOptions.value.findIndex((option) => option.value === value.value && !option.disabled));
|
|
150
|
-
const activeDescendantId =
|
|
73
|
+
const activeDescendantId = optionCollection.activeDescendantId;
|
|
74
|
+
const floating = useFloatingPosition({
|
|
75
|
+
reference: triggerRef,
|
|
76
|
+
floating: dropdownRef,
|
|
77
|
+
open: isOpen,
|
|
78
|
+
placement: "bottom-start"
|
|
79
|
+
});
|
|
80
|
+
const placementSide = computed(() => floating.actualPlacement.value.split("-")[0]);
|
|
151
81
|
const typeahead = useTypeahead({
|
|
152
82
|
items: () => visibleOptions.value,
|
|
153
83
|
activeIndex: () => isOpen.value ? focusedIndex.value : selectedIndex.value,
|
|
154
84
|
getKey: (item) => item.value,
|
|
155
85
|
getTextValue: (item) => item.label,
|
|
156
86
|
isDisabled: (item) => Boolean(item.disabled),
|
|
157
|
-
onMatch(item
|
|
158
|
-
if (isOpen.value)
|
|
159
|
-
else if (item.value !== value.value)
|
|
87
|
+
onMatch(item) {
|
|
88
|
+
if (isOpen.value) optionCollection.activate(item);
|
|
89
|
+
else if (item.value !== value.value) transaction.requestValueUpdate(item.value);
|
|
160
90
|
}
|
|
161
91
|
});
|
|
162
92
|
const rootClass = computed(() => bem("rp-select", {
|
|
@@ -169,6 +99,11 @@ function useSelect(props, emitUpdate, getValue = () => props.modelValue ?? null,
|
|
|
169
99
|
const hasValue = computed(() => hasSelectValue(value.value));
|
|
170
100
|
const displayLabel = computed(() => getSelectDisplayLabel(props.options, value.value));
|
|
171
101
|
const canClear = computed(() => Boolean(props.clearable && hasValue.value && !control.disabled));
|
|
102
|
+
function setDropdownElement(elementRef) {
|
|
103
|
+
resolveHTMLElementRef(elementRef, popupId, (resolved) => {
|
|
104
|
+
dropdownRef.value = resolved;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
172
107
|
function focusTrigger() {
|
|
173
108
|
nextTick(() => triggerRef.value?.focus());
|
|
174
109
|
}
|
|
@@ -176,11 +111,11 @@ function useSelect(props, emitUpdate, getValue = () => props.modelValue ?? null,
|
|
|
176
111
|
if (control.disabled || isOpen.value) return;
|
|
177
112
|
typeahead.reset();
|
|
178
113
|
isOpen.value = true;
|
|
179
|
-
|
|
114
|
+
optionCollection.activate("selected");
|
|
180
115
|
}
|
|
181
116
|
function close() {
|
|
182
117
|
isOpen.value = false;
|
|
183
|
-
|
|
118
|
+
optionCollection.reset();
|
|
184
119
|
typeahead.reset();
|
|
185
120
|
}
|
|
186
121
|
function toggle() {
|
|
@@ -192,18 +127,18 @@ function useSelect(props, emitUpdate, getValue = () => props.modelValue ?? null,
|
|
|
192
127
|
}
|
|
193
128
|
function selectOption(option) {
|
|
194
129
|
if (option.disabled) return;
|
|
195
|
-
|
|
130
|
+
transaction.requestValueUpdate(option.value);
|
|
196
131
|
close();
|
|
197
132
|
focusTrigger();
|
|
198
133
|
}
|
|
199
134
|
function clearSelection() {
|
|
200
135
|
if (!canClear.value) return;
|
|
201
|
-
|
|
136
|
+
transaction.requestValueUpdate(null);
|
|
202
137
|
close();
|
|
203
138
|
focusTrigger();
|
|
204
139
|
}
|
|
205
|
-
function onOptionMouseenter(option
|
|
206
|
-
|
|
140
|
+
function onOptionMouseenter(option) {
|
|
141
|
+
optionCollection.activate(option);
|
|
207
142
|
}
|
|
208
143
|
function onFocusout(event) {
|
|
209
144
|
if (isNodeWithinElement(event.relatedTarget, selectRef.value)) return;
|
|
@@ -230,25 +165,25 @@ function useSelect(props, emitUpdate, getValue = () => props.modelValue ?? null,
|
|
|
230
165
|
case "ArrowDown":
|
|
231
166
|
e.preventDefault();
|
|
232
167
|
if (!isOpen.value) open();
|
|
233
|
-
else
|
|
168
|
+
else optionCollection.move(1);
|
|
234
169
|
break;
|
|
235
170
|
case "ArrowUp":
|
|
236
171
|
e.preventDefault();
|
|
237
172
|
if (!isOpen.value) {
|
|
238
173
|
open();
|
|
239
|
-
|
|
240
|
-
} else
|
|
174
|
+
optionCollection.activate("last");
|
|
175
|
+
} else optionCollection.move(-1);
|
|
241
176
|
break;
|
|
242
177
|
case "Home":
|
|
243
178
|
if (isOpen.value) {
|
|
244
179
|
e.preventDefault();
|
|
245
|
-
|
|
180
|
+
optionCollection.activate("first");
|
|
246
181
|
}
|
|
247
182
|
break;
|
|
248
183
|
case "End":
|
|
249
184
|
if (isOpen.value) {
|
|
250
185
|
e.preventDefault();
|
|
251
|
-
|
|
186
|
+
optionCollection.activate("last");
|
|
252
187
|
}
|
|
253
188
|
break;
|
|
254
189
|
case "Delete":
|
|
@@ -265,30 +200,31 @@ function useSelect(props, emitUpdate, getValue = () => props.modelValue ?? null,
|
|
|
265
200
|
break;
|
|
266
201
|
}
|
|
267
202
|
}
|
|
268
|
-
watch(focusedIndex, (index) => {
|
|
269
|
-
if (!isOpen.value || index < 0) return;
|
|
270
|
-
nextTick(() => {
|
|
271
|
-
if (!isOpen.value || focusedIndex.value !== index) return;
|
|
272
|
-
selectRef.value?.querySelector(`[id="${selectId}-option-${index}"]`)?.scrollIntoView?.({ block: "nearest" });
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
203
|
useClickOutside(selectRef, isOpen, close);
|
|
276
204
|
return {
|
|
277
|
-
|
|
278
|
-
|
|
205
|
+
templateRefs: {
|
|
206
|
+
select: selectRef,
|
|
207
|
+
trigger: triggerRef,
|
|
208
|
+
native: transaction.nativeSelectRef
|
|
209
|
+
},
|
|
210
|
+
nativeInputAttrs: transaction.nativeInputAttrs,
|
|
279
211
|
isOpen,
|
|
280
|
-
selectId,
|
|
281
212
|
popupId,
|
|
282
213
|
listboxId,
|
|
283
214
|
control,
|
|
284
215
|
visibleOptions,
|
|
216
|
+
renderedOptions,
|
|
285
217
|
focusedIndex,
|
|
286
218
|
activeDescendantId,
|
|
287
219
|
rootClass,
|
|
220
|
+
floatingStyle: floating.floatingStyle,
|
|
221
|
+
actualPlacement: floating.actualPlacement,
|
|
222
|
+
placementSide,
|
|
288
223
|
hasValue,
|
|
289
224
|
displayLabel,
|
|
290
|
-
value,
|
|
225
|
+
selectedValue: value,
|
|
291
226
|
canClear,
|
|
227
|
+
setDropdownElement,
|
|
292
228
|
toggle,
|
|
293
229
|
selectOption,
|
|
294
230
|
clearSelection,
|
|
@@ -298,102 +234,13 @@ function useSelect(props, emitUpdate, getValue = () => props.modelValue ?? null,
|
|
|
298
234
|
};
|
|
299
235
|
}
|
|
300
236
|
//#endregion
|
|
301
|
-
//#region src/components/select/useSelectNativeValue.ts
|
|
302
|
-
function useSelectNativeValue(props, emitUpdate) {
|
|
303
|
-
const nativeSelectRef = ref(null);
|
|
304
|
-
const controllable = useControllableValue({
|
|
305
|
-
modelValue: () => props.modelValue,
|
|
306
|
-
defaultValue: () => props.defaultValue ?? null,
|
|
307
|
-
onChange: emitUpdate
|
|
308
|
-
});
|
|
309
|
-
function getNativeValue(select) {
|
|
310
|
-
if (select.selectedIndex <= 0) return null;
|
|
311
|
-
return props.options?.[select.selectedIndex - 1]?.value ?? null;
|
|
312
|
-
}
|
|
313
|
-
function syncNativeSelection(value) {
|
|
314
|
-
const select = nativeSelectRef.value;
|
|
315
|
-
if (!select) return;
|
|
316
|
-
select.selectedIndex = (props.options?.findIndex((option) => option.value === value) ?? -1) + 1;
|
|
317
|
-
}
|
|
318
|
-
function syncNativeDefaultSelection() {
|
|
319
|
-
const select = nativeSelectRef.value;
|
|
320
|
-
if (!select) return;
|
|
321
|
-
const optionIndex = props.options?.findIndex((option) => option.value === controllable.initialValue) ?? -1;
|
|
322
|
-
for (const [index, option] of [...select.options].entries()) option.defaultSelected = index === optionIndex + 1;
|
|
323
|
-
}
|
|
324
|
-
function requestValueUpdate(value) {
|
|
325
|
-
const select = nativeSelectRef.value;
|
|
326
|
-
if (!select) {
|
|
327
|
-
controllable.setValue(value);
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
syncNativeSelection(value);
|
|
331
|
-
select.dispatchEvent(new Event("input", {
|
|
332
|
-
bubbles: true,
|
|
333
|
-
cancelable: true
|
|
334
|
-
}));
|
|
335
|
-
select.dispatchEvent(new Event("change", {
|
|
336
|
-
bubbles: true,
|
|
337
|
-
cancelable: true
|
|
338
|
-
}));
|
|
339
|
-
if (controllable.isControlled.value) queueMicrotask(() => syncNativeSelection(controllable.value.value));
|
|
340
|
-
}
|
|
341
|
-
watchEffect(syncNativeDefaultSelection, { flush: "post" });
|
|
342
|
-
watchEffect(() => syncNativeSelection(controllable.value.value), { flush: "post" });
|
|
343
|
-
return {
|
|
344
|
-
nativeSelectRef,
|
|
345
|
-
controllable,
|
|
346
|
-
getNativeValue,
|
|
347
|
-
syncNativeSelection,
|
|
348
|
-
requestValueUpdate
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
//#endregion
|
|
352
|
-
//#region src/components/select/useSelectNativeControl.ts
|
|
353
|
-
function useSelectNativeControl(props, emitUpdate, triggerRef) {
|
|
354
|
-
const nativeValue = useSelectNativeValue(props, emitUpdate);
|
|
355
|
-
const { nativeSelectRef, controllable, getNativeValue, syncNativeSelection } = nativeValue;
|
|
356
|
-
useFormControl({
|
|
357
|
-
elements: () => [nativeSelectRef.value],
|
|
358
|
-
isControlled: () => controllable.isControlled.value,
|
|
359
|
-
validationMessage: () => props.validationMessage,
|
|
360
|
-
readResetValue(elements) {
|
|
361
|
-
controllable.resetValue(getNativeValue(elements[0]));
|
|
362
|
-
},
|
|
363
|
-
syncControlledValue() {
|
|
364
|
-
syncNativeSelection(controllable.value.value);
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
const nativeInputAttrs = computed(() => {
|
|
368
|
-
const compatibilityAttrs = props.inputAttrs ?? {};
|
|
369
|
-
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(compatibilityAttrs);
|
|
370
|
-
return {
|
|
371
|
-
...forwardedAttributes,
|
|
372
|
-
class: ["rp-select__native", compatibilityClass],
|
|
373
|
-
style: compatibilityStyle,
|
|
374
|
-
onInput: composeEventHandlers((event) => controllable.setValue(getNativeValue(event.currentTarget)), compatibilityAttrs.onInput),
|
|
375
|
-
onChange: compatibilityAttrs.onChange,
|
|
376
|
-
onInvalid: composeEventHandlers((event) => {
|
|
377
|
-
event.preventDefault();
|
|
378
|
-
triggerRef.value?.focus();
|
|
379
|
-
}, compatibilityAttrs.onInvalid)
|
|
380
|
-
};
|
|
381
|
-
});
|
|
382
|
-
return {
|
|
383
|
-
nativeSelectRef,
|
|
384
|
-
selectedValue: controllable.value,
|
|
385
|
-
nativeInputAttrs,
|
|
386
|
-
requestValueUpdate: nativeValue.requestValueUpdate
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
//#endregion
|
|
390
237
|
//#region src/components/select/select.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
391
|
-
var t0 = template("<option data-v-
|
|
392
|
-
var t1 = template("<button data-v-
|
|
238
|
+
var t0 = template("<option data-v-097d7f90> ");
|
|
239
|
+
var t1 = template("<button data-v-097d7f90></button>");
|
|
393
240
|
var t2 = template("No options", 2);
|
|
394
|
-
var t3 = template("<div data-v-
|
|
395
|
-
var t4 = template("<div data-v-
|
|
396
|
-
var t5 = template("<div data-v-
|
|
241
|
+
var t3 = template("<div data-v-097d7f90>");
|
|
242
|
+
var t4 = template("<div data-v-097d7f90> ");
|
|
243
|
+
var t5 = template("<div data-v-097d7f90><select data-v-097d7f90><option data-v-097d7f90 value></option></select><div data-v-097d7f90><span data-v-097d7f90> </span><span data-v-097d7f90><span data-v-097d7f90 class=rp-select__arrow aria-hidden=true>", 1);
|
|
397
244
|
//#endregion
|
|
398
245
|
//#region src/components/select/select.vue
|
|
399
246
|
var select_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -439,10 +286,7 @@ var select_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
439
286
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
440
287
|
const props = __props;
|
|
441
288
|
const emit = __emit;
|
|
442
|
-
const
|
|
443
|
-
const { nativeSelectRef, selectedValue, nativeInputAttrs, requestValueUpdate } = useSelectNativeControl(props, (value) => emit("update:modelValue", value), triggerRef);
|
|
444
|
-
const { selectRef, isOpen, selectId, popupId, listboxId, control, visibleOptions, focusedIndex, activeDescendantId, rootClass, hasValue, displayLabel, canClear, toggle, selectOption, clearSelection, onOptionMouseenter, onFocusout, onTriggerKeydown } = useSelect(props, requestValueUpdate, () => selectedValue.value, triggerRef);
|
|
445
|
-
const templateRefs = { select: selectRef };
|
|
289
|
+
const { templateRefs, nativeInputAttrs, isOpen, popupId, listboxId, control, visibleOptions, renderedOptions, activeDescendantId, rootClass, floatingStyle, actualPlacement, placementSide, hasValue, displayLabel, canClear, setDropdownElement, toggle, selectOption, clearSelection, onOptionMouseenter, onFocusout, onTriggerKeydown } = useSelect(props, (value) => emit("update:modelValue", value));
|
|
446
290
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
447
291
|
const rootAttrs = computed(() => getRootAttrs({
|
|
448
292
|
class: rootClass.value,
|
|
@@ -451,9 +295,17 @@ var select_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
451
295
|
"data-disabled": toPresenceAttribute(control.disabled),
|
|
452
296
|
"data-invalid": toPresenceAttribute(control.invalid)
|
|
453
297
|
}));
|
|
298
|
+
const contentAttrs = computed(() => ({
|
|
299
|
+
...getPartAttrs("content", {
|
|
300
|
+
class: "rp-select__dropdown",
|
|
301
|
+
style: floatingStyle.value
|
|
302
|
+
}),
|
|
303
|
+
"data-placement": actualPlacement.value,
|
|
304
|
+
"data-side": placementSide.value
|
|
305
|
+
}));
|
|
454
306
|
__expose({
|
|
455
|
-
nativeElement:
|
|
456
|
-
focus: () =>
|
|
307
|
+
nativeElement: templateRefs.native,
|
|
308
|
+
focus: () => templateRefs.trigger.value?.focus()
|
|
457
309
|
});
|
|
458
310
|
const _setTemplateRef = createTemplateRefSetter();
|
|
459
311
|
const n26 = t5();
|
|
@@ -487,13 +339,13 @@ var select_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
487
339
|
});
|
|
488
340
|
return n2;
|
|
489
341
|
}, (option) => option.value, 8);
|
|
490
|
-
_setTemplateRef(n3, nativeSelectRef, null, "nativeSelectRef");
|
|
491
342
|
const x4 = txt(n4);
|
|
492
343
|
renderEffect(() => {
|
|
493
344
|
const _control = unref(control);
|
|
494
345
|
const _getPartAttrs = unref(getPartAttrs);
|
|
495
346
|
const _isOpen = unref(isOpen);
|
|
496
347
|
const _control_disabled = _control.disabled;
|
|
348
|
+
_setTemplateRef(n3, unref(templateRefs).native);
|
|
497
349
|
setDynamicProps(n12, [
|
|
498
350
|
{ id: _control.id },
|
|
499
351
|
_getPartAttrs("trigger", { class: "rp-select__trigger" }),
|
|
@@ -540,11 +392,11 @@ var select_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
540
392
|
createComponent(unref(chevrons_up_down_default));
|
|
541
393
|
on(n12, "click", (e) => unref(toggle)(e));
|
|
542
394
|
on(n12, "keydown", (e) => unref(onTriggerKeydown)(e));
|
|
543
|
-
|
|
395
|
+
setTemplateRefBinding(n12, () => unref(templateRefs).trigger);
|
|
544
396
|
setInsertionState(n26, null, 2);
|
|
545
397
|
createComponent(VaporTransition, { name: "rp-select-dropdown" }, extend(() => {
|
|
546
398
|
return createIf(() => unref(isOpen), () => {
|
|
547
|
-
|
|
399
|
+
const n24 = createComponent(scroll_area_default, { $: [() => contentAttrs.value, {
|
|
548
400
|
id: () => unref(popupId),
|
|
549
401
|
embedded: "",
|
|
550
402
|
type: "auto",
|
|
@@ -563,43 +415,41 @@ var select_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
563
415
|
return t2();
|
|
564
416
|
}, 1);
|
|
565
417
|
return n20;
|
|
566
|
-
}, null, 129), createFor(() => unref(
|
|
418
|
+
}, null, 129), createFor(() => unref(renderedOptions), (_for_item0) => {
|
|
567
419
|
const n23 = t4();
|
|
568
420
|
const x23 = txt(n23);
|
|
569
|
-
on(n23, "click", () => unref(selectOption)(_for_item0.value));
|
|
570
|
-
on(n23, "mouseenter", () => unref(onOptionMouseenter)(_for_item0.value
|
|
421
|
+
on(n23, "click", () => unref(selectOption)(_for_item0.value.option));
|
|
422
|
+
on(n23, "mouseenter", () => unref(onOptionMouseenter)(_for_item0.value.option));
|
|
571
423
|
renderEffect(() => {
|
|
572
|
-
const
|
|
573
|
-
const
|
|
574
|
-
const
|
|
575
|
-
const _toPresenceAttribute = unref(toPresenceAttribute);
|
|
576
|
-
const _focusedIndex = unref(focusedIndex);
|
|
577
|
-
const _option_value = _option.value;
|
|
578
|
-
const _option_disabled = _option.disabled;
|
|
424
|
+
const _optionState = _for_item0.value;
|
|
425
|
+
const _optionState_selected = _optionState.selected;
|
|
426
|
+
const _optionState_disabled = _optionState.disabled;
|
|
579
427
|
setDynamicProps(n23, [{
|
|
580
428
|
role: "option",
|
|
581
|
-
id:
|
|
582
|
-
"aria-selected":
|
|
583
|
-
"aria-disabled":
|
|
584
|
-
"data-selected":
|
|
585
|
-
"data-highlighted":
|
|
586
|
-
"data-disabled":
|
|
429
|
+
id: _optionState.id,
|
|
430
|
+
"aria-selected": _optionState_selected,
|
|
431
|
+
"aria-disabled": _optionState_disabled || void 0,
|
|
432
|
+
"data-selected": unref(toPresenceAttribute)(_optionState.selected),
|
|
433
|
+
"data-highlighted": unref(toPresenceAttribute)(_optionState.active),
|
|
434
|
+
"data-disabled": unref(toPresenceAttribute)(_optionState.disabled)
|
|
587
435
|
}, unref(getPartAttrs)("option", { class: ["rp-select__option", {
|
|
588
|
-
"rp-select__option--selected":
|
|
589
|
-
"rp-select__option--focused":
|
|
590
|
-
"rp-select__option--disabled":
|
|
436
|
+
"rp-select__option--selected": _optionState_selected,
|
|
437
|
+
"rp-select__option--focused": _optionState.active,
|
|
438
|
+
"rp-select__option--disabled": _optionState_disabled
|
|
591
439
|
}] })]);
|
|
592
|
-
setText(x23, toDisplayString(
|
|
440
|
+
setText(x23, toDisplayString(_optionState.option.label));
|
|
593
441
|
});
|
|
594
442
|
return n23;
|
|
595
|
-
}, (
|
|
443
|
+
}, (optionState) => optionState.option.value, 40)];
|
|
596
444
|
}, { _: 8 }));
|
|
445
|
+
setTemplateRefBinding(n24, () => setDropdownElement, _setTemplateRef, void 0, "setDropdownElement");
|
|
446
|
+
return n24;
|
|
597
447
|
}, null, 129);
|
|
598
448
|
}, { _: 8 }));
|
|
599
|
-
setTemplateRefBinding(n26, () => templateRefs.select);
|
|
449
|
+
setTemplateRefBinding(n26, () => unref(templateRefs).select);
|
|
600
450
|
return n26;
|
|
601
451
|
}
|
|
602
|
-
}), [["__scopeId", "data-v-
|
|
452
|
+
}), [["__scopeId", "data-v-097d7f90"]]);
|
|
603
453
|
//#endregion
|
|
604
454
|
//#region src/components/select/types.ts
|
|
605
455
|
var selectParts = [
|