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
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import './multi-select.css';
|
|
2
|
+
import { t as useStylesApi } from "./styles-api.js";
|
|
3
|
+
import { n as toPresenceAttribute } from "./attributes.js";
|
|
4
|
+
import { t as bem } from "./bem.js";
|
|
5
|
+
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
6
|
+
import { t as x_default } from "./x.js";
|
|
7
|
+
import { t as check_default } from "./check.js";
|
|
8
|
+
import { o as splitCompatibilityAttributes, t as composeEventHandlers } from "./attributes2.js";
|
|
9
|
+
import { t as useControlState } from "./useControlState.js";
|
|
10
|
+
import { t as resolveHTMLElementRef } from "./componentRef.js";
|
|
11
|
+
import { t as useFloatingPosition } from "./useFloatingPosition.js";
|
|
12
|
+
import { r as chevrons_up_down_default } from "./useFlatOptionCollection.js";
|
|
13
|
+
import { t as scroll_area_default } from "./scroll-area.js";
|
|
14
|
+
import { t as useEditableOptionList } from "./useEditableOptionList.js";
|
|
15
|
+
import { i as useHiddenSelectChoiceTransaction, t as createMultipleNativeChoiceAdapter } from "./nativeChoice.js";
|
|
16
|
+
import { VaporTransition, child, computed, createComponent, createFor, createIf, createSlot, createTemplateRefSetter, defineVaporComponent, extend, next, on, ref, renderEffect, setDynamicProps, setInsertionState, setProp, setTemplateRefBinding, setText, setValue, template, toDisplayString, txt, unref, useId, withModifiers } from "vue";
|
|
17
|
+
//#region src/components/multi-select/multiSelectModel.ts
|
|
18
|
+
function getMultiSelectSelectedOptions(options, values) {
|
|
19
|
+
return values.flatMap((value) => {
|
|
20
|
+
const option = options?.find((candidate) => candidate.value === value);
|
|
21
|
+
return option ? [option] : [];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function toggleMultiSelectValue(values, value, maxValues) {
|
|
25
|
+
if (values.includes(value)) return values.filter((candidate) => candidate !== value);
|
|
26
|
+
if (maxValues !== void 0 && values.length >= Math.max(0, maxValues)) return [...values];
|
|
27
|
+
return [...values, value];
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/components/multi-select/useMultiSelect.ts
|
|
31
|
+
function useMultiSelectTransaction(props, emitUpdate, inputRef, onFormReset) {
|
|
32
|
+
const transaction = useHiddenSelectChoiceTransaction({
|
|
33
|
+
value: {
|
|
34
|
+
modelValue: () => props.modelValue,
|
|
35
|
+
defaultValue: () => [...props.defaultValue ?? []],
|
|
36
|
+
onChange: emitUpdate
|
|
37
|
+
},
|
|
38
|
+
native: {
|
|
39
|
+
adapter: createMultipleNativeChoiceAdapter(() => props.options),
|
|
40
|
+
className: "rp-multi-select__native",
|
|
41
|
+
focusVisible: () => inputRef.value?.focus(),
|
|
42
|
+
validationMessage: () => props.validationMessage
|
|
43
|
+
},
|
|
44
|
+
onFormReset
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
nativeSelectRef: transaction.nativeSelectRef,
|
|
48
|
+
nativeSelectAttrs: transaction.nativeSelectAttrs,
|
|
49
|
+
requestValueUpdate: transaction.requestValueUpdate,
|
|
50
|
+
selectedValues: transaction.value
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function useMultiSelect(props, callbacks) {
|
|
54
|
+
const rootRef = ref(null);
|
|
55
|
+
const inputRef = ref(null);
|
|
56
|
+
const dropdownRef = ref(null);
|
|
57
|
+
const generatedId = useId();
|
|
58
|
+
const multiSelectId = props.id ?? generatedId;
|
|
59
|
+
const transaction = useMultiSelectTransaction(props, callbacks.valueChange, inputRef, resetAfterFormReset);
|
|
60
|
+
const selectedValues = transaction.selectedValues;
|
|
61
|
+
const control = useControlState(props);
|
|
62
|
+
const selectedOptions = computed(() => getMultiSelectSelectedOptions(props.options, selectedValues.value));
|
|
63
|
+
function isSelected(option) {
|
|
64
|
+
return selectedValues.value.includes(option.value);
|
|
65
|
+
}
|
|
66
|
+
function isAtLimit() {
|
|
67
|
+
return props.maxValues !== void 0 && selectedValues.value.length >= Math.max(0, props.maxValues);
|
|
68
|
+
}
|
|
69
|
+
function isOptionDisabled(option) {
|
|
70
|
+
return Boolean(option.disabled || isAtLimit() && !isSelected(option));
|
|
71
|
+
}
|
|
72
|
+
const optionList = useEditableOptionList({
|
|
73
|
+
baseId: multiSelectId,
|
|
74
|
+
clearable: () => Boolean(props.clearable),
|
|
75
|
+
disabled: () => control.disabled,
|
|
76
|
+
filter: () => props.filter,
|
|
77
|
+
getKey: (option) => option.value,
|
|
78
|
+
inputRef,
|
|
79
|
+
isDisabled: isOptionDisabled,
|
|
80
|
+
items: () => props.options,
|
|
81
|
+
onSearch: callbacks.search,
|
|
82
|
+
rootRef,
|
|
83
|
+
selection: {
|
|
84
|
+
kind: "multiple",
|
|
85
|
+
clear: () => transaction.requestValueUpdate([]),
|
|
86
|
+
hasSelection: () => selectedValues.value.length > 0,
|
|
87
|
+
isSelected,
|
|
88
|
+
removeLast() {
|
|
89
|
+
const option = selectedOptions.value.at(-1);
|
|
90
|
+
if (!option) return;
|
|
91
|
+
transaction.requestValueUpdate(selectedValues.value.filter((value) => value !== option.value));
|
|
92
|
+
},
|
|
93
|
+
select(option) {
|
|
94
|
+
transaction.requestValueUpdate(toggleMultiSelectValue(selectedValues.value, option.value, props.maxValues));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const { activeDescendantId, canClear, isOpen, renderedOptions, searchValue, visibleOptions } = optionList.state;
|
|
99
|
+
const { listbox: listboxId, popup: popupId } = optionList.ids;
|
|
100
|
+
const floating = useFloatingPosition({
|
|
101
|
+
reference: rootRef,
|
|
102
|
+
floating: dropdownRef,
|
|
103
|
+
open: isOpen,
|
|
104
|
+
placement: "bottom-start"
|
|
105
|
+
});
|
|
106
|
+
const placementSide = computed(() => floating.actualPlacement.value.split("-")[0]);
|
|
107
|
+
const rootClass = computed(() => bem("rp-multi-select", {
|
|
108
|
+
open: isOpen.value,
|
|
109
|
+
[`size-${props.size}`]: Boolean(props.size),
|
|
110
|
+
[`radius-${props.radius}`]: Boolean(props.radius),
|
|
111
|
+
disabled: control.disabled,
|
|
112
|
+
invalid: control.invalid
|
|
113
|
+
}));
|
|
114
|
+
function setDropdownElement(elementRef) {
|
|
115
|
+
resolveHTMLElementRef(elementRef, popupId, (resolved) => {
|
|
116
|
+
dropdownRef.value = resolved;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function resetAfterFormReset() {
|
|
120
|
+
optionList.actions.resetAfterFormReset();
|
|
121
|
+
}
|
|
122
|
+
function removeOption(option) {
|
|
123
|
+
if (control.disabled || !isSelected(option)) return;
|
|
124
|
+
transaction.requestValueUpdate(selectedValues.value.filter((value) => value !== option.value));
|
|
125
|
+
optionList.actions.focusInput();
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
templateRefs: {
|
|
129
|
+
root: rootRef,
|
|
130
|
+
input: inputRef,
|
|
131
|
+
native: transaction.nativeSelectRef
|
|
132
|
+
},
|
|
133
|
+
nativeSelectAttrs: transaction.nativeSelectAttrs,
|
|
134
|
+
isOpen,
|
|
135
|
+
popupId,
|
|
136
|
+
listboxId,
|
|
137
|
+
control,
|
|
138
|
+
visibleOptions,
|
|
139
|
+
renderedOptions,
|
|
140
|
+
selectedOptions,
|
|
141
|
+
activeDescendantId,
|
|
142
|
+
rootClass,
|
|
143
|
+
floatingStyle: floating.floatingStyle,
|
|
144
|
+
actualPlacement: floating.actualPlacement,
|
|
145
|
+
placementSide,
|
|
146
|
+
searchValue,
|
|
147
|
+
canClear,
|
|
148
|
+
setDropdownElement,
|
|
149
|
+
toggle: optionList.actions.toggle,
|
|
150
|
+
selectOption: optionList.actions.selectOption,
|
|
151
|
+
removeOption,
|
|
152
|
+
clearSelection: optionList.actions.clearSelection,
|
|
153
|
+
onOptionMouseenter: optionList.handlers.onOptionMouseenter,
|
|
154
|
+
onRootMousedown: optionList.handlers.onRootMousedown,
|
|
155
|
+
onFocusout: optionList.handlers.onFocusout,
|
|
156
|
+
onInput: optionList.handlers.onInput,
|
|
157
|
+
onInputFocus: optionList.handlers.onInputFocus,
|
|
158
|
+
onInputClick: optionList.handlers.onInputClick,
|
|
159
|
+
onInputKeydown: optionList.handlers.onInputKeydown
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/components/multi-select/multi-select.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
164
|
+
var t0 = template("<option data-v-b38d027f> ");
|
|
165
|
+
var t1 = template(" ");
|
|
166
|
+
var t2 = template("<span data-v-b38d027f><span data-v-b38d027f></span><button data-v-b38d027f></button>");
|
|
167
|
+
var t3 = template("<button data-v-b38d027f></button>");
|
|
168
|
+
var t4 = template("No options", 2);
|
|
169
|
+
var t5 = template("<div data-v-b38d027f>");
|
|
170
|
+
var t6 = template("<div data-v-b38d027f><select data-v-b38d027f></select><div data-v-b38d027f><input data-v-b38d027f></div><span data-v-b38d027f><button data-v-b38d027f>", 1);
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/components/multi-select/multi-select.vue
|
|
173
|
+
var multi_select_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
174
|
+
name: "RpMultiSelect",
|
|
175
|
+
inheritAttrs: false,
|
|
176
|
+
__name: "multi-select",
|
|
177
|
+
props: {
|
|
178
|
+
id: {},
|
|
179
|
+
name: {},
|
|
180
|
+
form: {},
|
|
181
|
+
modelValue: { default: void 0 },
|
|
182
|
+
defaultValue: { default: () => [] },
|
|
183
|
+
options: { default: () => [] },
|
|
184
|
+
filter: {
|
|
185
|
+
type: [Function, Boolean],
|
|
186
|
+
default: void 0
|
|
187
|
+
},
|
|
188
|
+
maxValues: { default: void 0 },
|
|
189
|
+
size: {},
|
|
190
|
+
radius: {},
|
|
191
|
+
placeholder: { default: "Select..." },
|
|
192
|
+
clearable: {
|
|
193
|
+
type: Boolean,
|
|
194
|
+
default: false
|
|
195
|
+
},
|
|
196
|
+
clearLabel: { default: "Clear selection" },
|
|
197
|
+
removeLabel: { default: "Remove" },
|
|
198
|
+
toggleLabel: { default: "Toggle options" },
|
|
199
|
+
disabled: {
|
|
200
|
+
type: Boolean,
|
|
201
|
+
default: void 0
|
|
202
|
+
},
|
|
203
|
+
required: {
|
|
204
|
+
type: Boolean,
|
|
205
|
+
default: void 0
|
|
206
|
+
},
|
|
207
|
+
invalid: {
|
|
208
|
+
type: Boolean,
|
|
209
|
+
default: void 0
|
|
210
|
+
},
|
|
211
|
+
ariaLabel: {},
|
|
212
|
+
describedby: {},
|
|
213
|
+
labelledby: {},
|
|
214
|
+
inputAttrs: {},
|
|
215
|
+
validationMessage: {},
|
|
216
|
+
classNames: {},
|
|
217
|
+
styles: {}
|
|
218
|
+
},
|
|
219
|
+
emits: ["update:modelValue", "search"],
|
|
220
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
221
|
+
const props = __props;
|
|
222
|
+
const emit = __emit;
|
|
223
|
+
const { templateRefs, nativeSelectAttrs, isOpen, popupId, listboxId, control, visibleOptions, renderedOptions, selectedOptions, activeDescendantId, rootClass, floatingStyle, actualPlacement, placementSide, searchValue, canClear, setDropdownElement, toggle, selectOption, removeOption, clearSelection, onOptionMouseenter, onRootMousedown, onFocusout, onInput, onInputFocus, onInputClick, onInputKeydown } = useMultiSelect(props, {
|
|
224
|
+
valueChange: (value) => emit("update:modelValue", value),
|
|
225
|
+
search: (value) => emit("search", value)
|
|
226
|
+
});
|
|
227
|
+
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
228
|
+
const rootAttrs = computed(() => getRootAttrs({
|
|
229
|
+
class: rootClass.value,
|
|
230
|
+
onMousedown: onRootMousedown,
|
|
231
|
+
onFocusout,
|
|
232
|
+
"data-state": isOpen.value ? "open" : "closed",
|
|
233
|
+
"data-disabled": toPresenceAttribute(control.disabled),
|
|
234
|
+
"data-invalid": toPresenceAttribute(control.invalid)
|
|
235
|
+
}));
|
|
236
|
+
const contentAttrs = computed(() => ({
|
|
237
|
+
...getPartAttrs("content", {
|
|
238
|
+
class: "rp-multi-select__dropdown",
|
|
239
|
+
style: floatingStyle.value
|
|
240
|
+
}),
|
|
241
|
+
"data-placement": actualPlacement.value,
|
|
242
|
+
"data-side": placementSide.value
|
|
243
|
+
}));
|
|
244
|
+
const listboxAttrs = computed(() => ({
|
|
245
|
+
role: "listbox",
|
|
246
|
+
tabindex: -1,
|
|
247
|
+
"aria-multiselectable": true
|
|
248
|
+
}));
|
|
249
|
+
const visibleInputAttrs = computed(() => {
|
|
250
|
+
const attrs = props.inputAttrs ?? {};
|
|
251
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(attrs);
|
|
252
|
+
return {
|
|
253
|
+
...forwardedAttributes,
|
|
254
|
+
...getPartAttrs("input", {
|
|
255
|
+
class: "rp-multi-select__input",
|
|
256
|
+
compatibilityClass,
|
|
257
|
+
compatibilityStyle
|
|
258
|
+
}),
|
|
259
|
+
id: control.id,
|
|
260
|
+
name: void 0,
|
|
261
|
+
form: "",
|
|
262
|
+
type: "text",
|
|
263
|
+
value: searchValue.value,
|
|
264
|
+
placeholder: selectedOptions.value.length === 0 ? props.placeholder : void 0,
|
|
265
|
+
disabled: control.disabled || void 0,
|
|
266
|
+
required: void 0,
|
|
267
|
+
autocomplete: forwardedAttributes.autocomplete ?? "off",
|
|
268
|
+
role: "combobox",
|
|
269
|
+
"aria-autocomplete": "list",
|
|
270
|
+
"aria-expanded": isOpen.value,
|
|
271
|
+
"aria-haspopup": "listbox",
|
|
272
|
+
"aria-activedescendant": activeDescendantId.value,
|
|
273
|
+
"aria-controls": listboxId,
|
|
274
|
+
"aria-disabled": control.disabled || void 0,
|
|
275
|
+
"aria-invalid": control.invalid || void 0,
|
|
276
|
+
"aria-required": control.required || void 0,
|
|
277
|
+
"aria-label": control.ariaLabelledby ? void 0 : props.ariaLabel || void 0,
|
|
278
|
+
"aria-labelledby": control.ariaLabelledby,
|
|
279
|
+
"aria-describedby": control.ariaDescribedby,
|
|
280
|
+
"data-state": isOpen.value ? "open" : "closed",
|
|
281
|
+
"data-disabled": toPresenceAttribute(control.disabled),
|
|
282
|
+
"data-invalid": toPresenceAttribute(control.invalid),
|
|
283
|
+
onInput: composeEventHandlers(onInput, attrs.onInput),
|
|
284
|
+
onFocus: composeEventHandlers(onInputFocus, attrs.onFocus),
|
|
285
|
+
onClick: composeEventHandlers(onInputClick, attrs.onClick),
|
|
286
|
+
onKeydown: composeEventHandlers(onInputKeydown, attrs.onKeydown)
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
__expose({
|
|
290
|
+
nativeElement: templateRefs.native,
|
|
291
|
+
inputElement: templateRefs.input,
|
|
292
|
+
focus: () => templateRefs.input.value?.focus()
|
|
293
|
+
});
|
|
294
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
295
|
+
const n41 = t6();
|
|
296
|
+
const n3 = child(n41);
|
|
297
|
+
const n14 = next(n3, 1);
|
|
298
|
+
const n13 = child(n14, 1);
|
|
299
|
+
const n21 = next(n14, 2);
|
|
300
|
+
const n20 = child(n21, 1);
|
|
301
|
+
renderEffect(() => {
|
|
302
|
+
const _control = unref(control);
|
|
303
|
+
setDynamicProps(n41, [rootAttrs.value]);
|
|
304
|
+
setDynamicProps(n3, [unref(nativeSelectAttrs), {
|
|
305
|
+
name: __props.name,
|
|
306
|
+
form: _control.form,
|
|
307
|
+
disabled: _control.disabled || void 0,
|
|
308
|
+
required: _control.required || void 0,
|
|
309
|
+
multiple: "",
|
|
310
|
+
tabindex: "-1",
|
|
311
|
+
"aria-hidden": "true"
|
|
312
|
+
}]);
|
|
313
|
+
});
|
|
314
|
+
setInsertionState(n3, null, 0);
|
|
315
|
+
createFor(() => __props.options, (_for_item0) => {
|
|
316
|
+
const n2 = t0();
|
|
317
|
+
const x2 = txt(n2);
|
|
318
|
+
renderEffect(() => {
|
|
319
|
+
const _option = _for_item0.value;
|
|
320
|
+
setValue(n2, String(_option.value));
|
|
321
|
+
setProp(n2, "disabled", _option.disabled || void 0);
|
|
322
|
+
setText(x2, toDisplayString(_option.label));
|
|
323
|
+
});
|
|
324
|
+
return n2;
|
|
325
|
+
}, (option) => option.value, 9);
|
|
326
|
+
renderEffect(() => {
|
|
327
|
+
_setTemplateRef(n3, unref(templateRefs).native);
|
|
328
|
+
setDynamicProps(n14, [unref(getPartAttrs)("pills", { class: "rp-multi-select__pills" })]);
|
|
329
|
+
});
|
|
330
|
+
setInsertionState(n14, 0);
|
|
331
|
+
createFor(() => unref(selectedOptions), (_for_item0) => {
|
|
332
|
+
const n12 = t2();
|
|
333
|
+
const n9 = child(n12);
|
|
334
|
+
const n11 = next(n9, 1);
|
|
335
|
+
renderEffect(() => {
|
|
336
|
+
const _getPartAttrs = unref(getPartAttrs);
|
|
337
|
+
setDynamicProps(n12, [_getPartAttrs("pill", { class: "rp-multi-select__pill" })]);
|
|
338
|
+
setDynamicProps(n9, [_getPartAttrs("pillLabel", { class: "rp-multi-select__pill-label" })]);
|
|
339
|
+
});
|
|
340
|
+
setInsertionState(n9, null, 0);
|
|
341
|
+
createSlot("pill", { option: () => _for_item0.value }, () => {
|
|
342
|
+
const n8 = t1();
|
|
343
|
+
renderEffect(() => setText(n8, toDisplayString(_for_item0.value.label)));
|
|
344
|
+
return n8;
|
|
345
|
+
}, 1);
|
|
346
|
+
renderEffect(() => setDynamicProps(n11, [
|
|
347
|
+
{ type: "button" },
|
|
348
|
+
unref(getPartAttrs)("pillRemove", { class: "rp-multi-select__pill-remove" }),
|
|
349
|
+
{
|
|
350
|
+
"aria-label": `${__props.removeLabel} ${_for_item0.value.label}`,
|
|
351
|
+
disabled: unref(control).disabled || void 0,
|
|
352
|
+
tabindex: "-1"
|
|
353
|
+
}
|
|
354
|
+
]));
|
|
355
|
+
setInsertionState(n11, null, 0);
|
|
356
|
+
createComponent(unref(x_default));
|
|
357
|
+
on(n11, "mousedown", withModifiers(() => {}, ["prevent"]));
|
|
358
|
+
on(n11, "click", withModifiers(() => unref(removeOption)(_for_item0.value), ["stop"]));
|
|
359
|
+
return n12;
|
|
360
|
+
}, (option) => option.value, 8);
|
|
361
|
+
renderEffect(() => {
|
|
362
|
+
setDynamicProps(n13, [visibleInputAttrs.value]);
|
|
363
|
+
_setTemplateRef(n13, unref(templateRefs).input);
|
|
364
|
+
setDynamicProps(n21, [unref(getPartAttrs)("indicator", { class: "rp-multi-select__indicator" })]);
|
|
365
|
+
});
|
|
366
|
+
setInsertionState(n21, 0);
|
|
367
|
+
createIf(() => unref(canClear), () => {
|
|
368
|
+
const n18 = t3();
|
|
369
|
+
renderEffect(() => setDynamicProps(n18, [
|
|
370
|
+
{ type: "button" },
|
|
371
|
+
unref(getPartAttrs)("clear", { class: "rp-multi-select__clear" }),
|
|
372
|
+
{
|
|
373
|
+
"aria-label": __props.clearLabel,
|
|
374
|
+
tabindex: "-1"
|
|
375
|
+
}
|
|
376
|
+
]));
|
|
377
|
+
setInsertionState(n18, null, 0);
|
|
378
|
+
createComponent(unref(x_default));
|
|
379
|
+
on(n18, "mousedown", withModifiers(() => {}, ["prevent"]));
|
|
380
|
+
on(n18, "click", withModifiers((e) => unref(clearSelection)(e), ["stop"]));
|
|
381
|
+
return n18;
|
|
382
|
+
});
|
|
383
|
+
renderEffect(() => setDynamicProps(n20, [
|
|
384
|
+
{ type: "button" },
|
|
385
|
+
unref(getPartAttrs)("toggle", { class: "rp-multi-select__toggle" }),
|
|
386
|
+
{
|
|
387
|
+
"aria-label": __props.toggleLabel,
|
|
388
|
+
"aria-expanded": unref(isOpen),
|
|
389
|
+
disabled: unref(control).disabled || void 0,
|
|
390
|
+
tabindex: "-1"
|
|
391
|
+
}
|
|
392
|
+
]));
|
|
393
|
+
setInsertionState(n20, null, 0);
|
|
394
|
+
createComponent(unref(chevrons_up_down_default));
|
|
395
|
+
on(n20, "mousedown", withModifiers(() => {}, ["prevent"]));
|
|
396
|
+
on(n20, "click", withModifiers((e) => unref(toggle)(e), ["stop"]));
|
|
397
|
+
setInsertionState(n41, null, 3);
|
|
398
|
+
createComponent(VaporTransition, { name: "rp-multi-select-dropdown" }, extend(() => {
|
|
399
|
+
return createIf(() => unref(isOpen), () => {
|
|
400
|
+
const n39 = createComponent(scroll_area_default, { $: [() => contentAttrs.value, {
|
|
401
|
+
id: () => unref(popupId),
|
|
402
|
+
embedded: "",
|
|
403
|
+
type: "auto",
|
|
404
|
+
scrollbars: "y",
|
|
405
|
+
"viewport-attrs": () => listboxAttrs.value,
|
|
406
|
+
"data-state": () => unref(isOpen) ? "open" : "closed"
|
|
407
|
+
}] }, extend(() => {
|
|
408
|
+
return [createIf(() => unref(visibleOptions).length === 0, () => {
|
|
409
|
+
const n29 = t5();
|
|
410
|
+
renderEffect(() => setDynamicProps(n29, [unref(getPartAttrs)("empty", { class: "rp-multi-select__empty" })]));
|
|
411
|
+
setInsertionState(n29, null, 0);
|
|
412
|
+
createSlot("empty", { searchValue: () => unref(searchValue) }, () => {
|
|
413
|
+
return t4();
|
|
414
|
+
}, 1);
|
|
415
|
+
return n29;
|
|
416
|
+
}, null, 129), createFor(() => unref(renderedOptions), (_for_item0) => {
|
|
417
|
+
const n38 = t5();
|
|
418
|
+
renderEffect(() => {
|
|
419
|
+
const _optionState = _for_item0.value;
|
|
420
|
+
const _optionState_selected = _optionState.selected;
|
|
421
|
+
const _optionState_disabled = _optionState.disabled;
|
|
422
|
+
setDynamicProps(n38, [{
|
|
423
|
+
id: _optionState.id,
|
|
424
|
+
role: "option",
|
|
425
|
+
"aria-selected": _optionState_selected,
|
|
426
|
+
"aria-disabled": _optionState_disabled || void 0,
|
|
427
|
+
"data-selected": unref(toPresenceAttribute)(_optionState.selected),
|
|
428
|
+
"data-highlighted": unref(toPresenceAttribute)(_optionState.active),
|
|
429
|
+
"data-disabled": unref(toPresenceAttribute)(_optionState.disabled)
|
|
430
|
+
}, unref(getPartAttrs)("option", { class: ["rp-multi-select__option", {
|
|
431
|
+
"rp-multi-select__option--selected": _optionState_selected,
|
|
432
|
+
"rp-multi-select__option--highlighted": _optionState.active,
|
|
433
|
+
"rp-multi-select__option--disabled": _optionState_disabled
|
|
434
|
+
}] })]);
|
|
435
|
+
});
|
|
436
|
+
setInsertionState(n38, null, 0);
|
|
437
|
+
createSlot("option", {
|
|
438
|
+
option: () => _for_item0.value.option,
|
|
439
|
+
selected: () => _for_item0.value.selected,
|
|
440
|
+
highlighted: () => _for_item0.value.active
|
|
441
|
+
}, () => {
|
|
442
|
+
const n34 = t1();
|
|
443
|
+
renderEffect(() => setText(n34, toDisplayString(_for_item0.value.option.label)));
|
|
444
|
+
return n34;
|
|
445
|
+
}, 1);
|
|
446
|
+
setInsertionState(n38, null, 1);
|
|
447
|
+
createIf(() => _for_item0.value.selected, () => {
|
|
448
|
+
return createComponent(unref(check_default), { "aria-hidden": "true" });
|
|
449
|
+
});
|
|
450
|
+
on(n38, "mousedown", withModifiers(() => {}, ["prevent"]));
|
|
451
|
+
on(n38, "click", () => unref(selectOption)(_for_item0.value.option));
|
|
452
|
+
on(n38, "mouseenter", () => unref(onOptionMouseenter)(_for_item0.value.option));
|
|
453
|
+
return n38;
|
|
454
|
+
}, (optionState) => optionState.option.value, 40)];
|
|
455
|
+
}, { _: 8 }));
|
|
456
|
+
setTemplateRefBinding(n39, () => setDropdownElement, _setTemplateRef, void 0, "setDropdownElement");
|
|
457
|
+
return n39;
|
|
458
|
+
}, null, 129);
|
|
459
|
+
}, { _: 8 }));
|
|
460
|
+
setTemplateRefBinding(n41, () => unref(templateRefs).root);
|
|
461
|
+
return n41;
|
|
462
|
+
}
|
|
463
|
+
}), [["__scopeId", "data-v-b38d027f"]]);
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/components/multi-select/types.ts
|
|
466
|
+
var multiSelectParts = [
|
|
467
|
+
"root",
|
|
468
|
+
"pills",
|
|
469
|
+
"pill",
|
|
470
|
+
"pillLabel",
|
|
471
|
+
"pillRemove",
|
|
472
|
+
"input",
|
|
473
|
+
"indicator",
|
|
474
|
+
"clear",
|
|
475
|
+
"toggle",
|
|
476
|
+
"content",
|
|
477
|
+
"option",
|
|
478
|
+
"empty"
|
|
479
|
+
];
|
|
480
|
+
//#endregion
|
|
481
|
+
export { multi_select_default as n, multiSelectParts as t };
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { o as splitCompatibilityAttributes, t as composeEventHandlers } from "./attributes2.js";
|
|
2
|
+
import { t as useNativeChoiceTransaction } from "./useNativeChoiceTransaction.js";
|
|
3
|
+
import { computed, ref } from "vue";
|
|
4
|
+
//#region src/internal/composables/useHiddenSelectChoiceTransaction.ts
|
|
5
|
+
function dispatchNativeSelectEvent(select, type) {
|
|
6
|
+
const EventConstructor = select.ownerDocument.defaultView?.Event ?? Event;
|
|
7
|
+
select.dispatchEvent(new EventConstructor(type, {
|
|
8
|
+
bubbles: true,
|
|
9
|
+
cancelable: true
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
function useHiddenSelectChoiceTransaction(options) {
|
|
13
|
+
const nativeSelectRef = ref(null);
|
|
14
|
+
const initialValue = options.value.defaultValue();
|
|
15
|
+
let handlingNativeInput = false;
|
|
16
|
+
let ignoreNativeInput = false;
|
|
17
|
+
function syncNativeValue(value, defaultValue) {
|
|
18
|
+
const select = nativeSelectRef.value;
|
|
19
|
+
if (select) options.native.adapter.sync(select, value, defaultValue);
|
|
20
|
+
}
|
|
21
|
+
const adapter = {
|
|
22
|
+
commitValue(value, defaultValue, applyValue) {
|
|
23
|
+
const select = nativeSelectRef.value;
|
|
24
|
+
if (!select || handlingNativeInput) {
|
|
25
|
+
applyValue();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
options.native.adapter.commit(select, value, defaultValue, applyValue);
|
|
29
|
+
ignoreNativeInput = true;
|
|
30
|
+
try {
|
|
31
|
+
dispatchNativeSelectEvent(select, "input");
|
|
32
|
+
dispatchNativeSelectEvent(select, "change");
|
|
33
|
+
} finally {
|
|
34
|
+
ignoreNativeInput = false;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
controls: () => [nativeSelectRef.value],
|
|
38
|
+
readResetValue([select], defaultValue) {
|
|
39
|
+
return options.native.adapter.resolveResetValue(select, defaultValue);
|
|
40
|
+
},
|
|
41
|
+
syncValue: syncNativeValue,
|
|
42
|
+
validationMessage: options.native.validationMessage
|
|
43
|
+
};
|
|
44
|
+
const transaction = useNativeChoiceTransaction({
|
|
45
|
+
value: {
|
|
46
|
+
...options.value,
|
|
47
|
+
defaultValue: () => initialValue
|
|
48
|
+
},
|
|
49
|
+
adapter,
|
|
50
|
+
onFormReset: options.onFormReset
|
|
51
|
+
});
|
|
52
|
+
function onNativeInput(event) {
|
|
53
|
+
if (ignoreNativeInput) return;
|
|
54
|
+
handlingNativeInput = true;
|
|
55
|
+
try {
|
|
56
|
+
transaction.requestValueUpdate(options.native.adapter.read(event.currentTarget));
|
|
57
|
+
} finally {
|
|
58
|
+
handlingNativeInput = false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function onNativeInvalid(event) {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
options.native.focusVisible();
|
|
64
|
+
}
|
|
65
|
+
const nativeSelectAttrs = computed(() => {
|
|
66
|
+
const compatibilityAttrs = options.native.attributes?.() ?? {};
|
|
67
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(compatibilityAttrs);
|
|
68
|
+
return {
|
|
69
|
+
...forwardedAttributes,
|
|
70
|
+
class: [options.native.className, compatibilityClass],
|
|
71
|
+
style: compatibilityStyle,
|
|
72
|
+
onInput: composeEventHandlers(onNativeInput, compatibilityAttrs.onInput),
|
|
73
|
+
onChange: compatibilityAttrs.onChange,
|
|
74
|
+
onInvalid: composeEventHandlers(onNativeInvalid, compatibilityAttrs.onInvalid)
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
isControlled: transaction.isControlled,
|
|
79
|
+
nativeSelectAttrs,
|
|
80
|
+
nativeSelectRef,
|
|
81
|
+
requestValueUpdate: transaction.requestValueUpdate,
|
|
82
|
+
value: transaction.value
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/utils/dom/nativeChoice.ts
|
|
87
|
+
function createSingleNativeChoiceAdapter(options) {
|
|
88
|
+
const placeholderOffset = 1;
|
|
89
|
+
function read(select) {
|
|
90
|
+
const optionIndex = select.selectedIndex - placeholderOffset;
|
|
91
|
+
if (optionIndex < 0) return options.emptyValue;
|
|
92
|
+
return options.options()?.[optionIndex]?.value ?? options.emptyValue;
|
|
93
|
+
}
|
|
94
|
+
function sync(select, value, defaultValue) {
|
|
95
|
+
const choices = options.options();
|
|
96
|
+
const selectedIndex = choices?.findIndex((choice) => choice.value === value) ?? -1;
|
|
97
|
+
const defaultIndex = choices?.findIndex((choice) => choice.value === defaultValue) ?? -1;
|
|
98
|
+
for (const [index, option] of [...select.options].entries()) option.defaultSelected = index === defaultIndex + placeholderOffset;
|
|
99
|
+
select.selectedIndex = selectedIndex + placeholderOffset;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
commit(select, value, defaultValue, applyValue) {
|
|
103
|
+
sync(select, value, defaultValue);
|
|
104
|
+
applyValue();
|
|
105
|
+
},
|
|
106
|
+
read,
|
|
107
|
+
resolveResetValue: read,
|
|
108
|
+
sync
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function createMultipleNativeChoiceAdapter(options) {
|
|
112
|
+
function sync(select, values, defaultValues) {
|
|
113
|
+
const choices = options();
|
|
114
|
+
for (const [index, nativeOption] of [...select.options].entries()) {
|
|
115
|
+
const choice = choices?.[index];
|
|
116
|
+
nativeOption.defaultSelected = Boolean(choice && defaultValues.includes(choice.value));
|
|
117
|
+
nativeOption.selected = Boolean(choice && values.includes(choice.value));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
commit(select, values, defaultValues, applyValue) {
|
|
122
|
+
applyValue();
|
|
123
|
+
sync(select, values, defaultValues);
|
|
124
|
+
},
|
|
125
|
+
read(select) {
|
|
126
|
+
const choices = options();
|
|
127
|
+
return [...select.options].flatMap((nativeOption, index) => {
|
|
128
|
+
const choice = choices?.[index];
|
|
129
|
+
return nativeOption.selected && choice ? [choice.value] : [];
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
resolveResetValue(_select, initialValue) {
|
|
133
|
+
return initialValue;
|
|
134
|
+
},
|
|
135
|
+
sync
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function syncStringListNativeChoice(select, values, defaultValues) {
|
|
139
|
+
const defaultCounts = /* @__PURE__ */ new Map();
|
|
140
|
+
for (const value of defaultValues) defaultCounts.set(value, (defaultCounts.get(value) ?? 0) + 1);
|
|
141
|
+
const options = values.map((value) => {
|
|
142
|
+
const option = select.ownerDocument.createElement("option");
|
|
143
|
+
const defaultCount = defaultCounts.get(value) ?? 0;
|
|
144
|
+
option.value = value;
|
|
145
|
+
option.textContent = value;
|
|
146
|
+
option.defaultSelected = defaultCount > 0;
|
|
147
|
+
option.selected = true;
|
|
148
|
+
if (defaultCount > 0) defaultCounts.set(value, defaultCount - 1);
|
|
149
|
+
return option;
|
|
150
|
+
});
|
|
151
|
+
select.replaceChildren(...options);
|
|
152
|
+
}
|
|
153
|
+
function createStringListNativeChoiceAdapter() {
|
|
154
|
+
return {
|
|
155
|
+
commit(select, values, defaultValues, applyValue) {
|
|
156
|
+
applyValue();
|
|
157
|
+
syncStringListNativeChoice(select, values, defaultValues);
|
|
158
|
+
},
|
|
159
|
+
read(select) {
|
|
160
|
+
return [...select.selectedOptions].map((option) => option.value);
|
|
161
|
+
},
|
|
162
|
+
resolveResetValue(_select, initialValue) {
|
|
163
|
+
return initialValue;
|
|
164
|
+
},
|
|
165
|
+
sync: syncStringListNativeChoice
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
169
|
+
export { useHiddenSelectChoiceTransaction as i, createSingleNativeChoiceAdapter as n, createStringListNativeChoiceAdapter as r, createMultipleNativeChoiceAdapter as t };
|