ropav 0.1.6 → 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 +7 -1
- package/dist/accordion.css +17 -17
- package/dist/accordion.js +123 -155
- package/dist/alert.css +18 -18
- package/dist/alert.js +10 -11
- package/dist/ancestry.js +136 -0
- package/dist/aria.js +14 -0
- package/dist/aspect-ratio.js +1 -1
- package/dist/attributes.js +9 -0
- package/dist/attributes2.js +29 -0
- package/dist/avatar.css +19 -19
- package/dist/avatar.js +9 -17
- package/dist/badge.css +16 -16
- package/dist/badge.js +5 -5
- package/dist/button-group.js +1 -1
- package/dist/button-link.js +4 -3
- package/dist/button.js +4 -3
- package/dist/button.scss_vue_type_style_index_0_src_true_lang.js +1 -1
- package/dist/calendar.css +173 -0
- package/dist/calendar.js +714 -0
- package/dist/calendar2.js +37 -0
- package/dist/card.js +1 -1
- package/dist/checkbox.css +32 -32
- package/dist/checkbox.js +22 -28
- package/dist/chevron-left.js +12 -0
- package/dist/collapse.css +6 -6
- package/dist/collapse.js +7 -6
- package/dist/collectionNavigation.js +2 -99
- package/dist/color-input.css +19 -19
- package/dist/color-input.js +14 -13
- package/dist/color-picker.css +40 -40
- package/dist/color-picker.js +247 -276
- package/dist/color-picker2.js +1 -9
- package/dist/color-swatch.css +4 -4
- package/dist/color-swatch.js +6 -8
- package/dist/color.js +5 -10
- package/dist/combobox.css +251 -0
- package/dist/combobox.js +410 -0
- package/dist/componentColors.js +125 -84
- package/dist/componentRef.js +26 -0
- package/dist/components/accordion/accordionContext.d.ts +3 -0
- package/dist/components/accordion/accordionModel.d.ts +14 -0
- package/dist/components/accordion/index.d.ts +2 -1
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/accordion/types.d.ts +1 -2
- package/dist/components/accordion/useAccordion.d.ts +2 -2
- package/dist/components/accordion/useAccordionItem.d.ts +2 -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/checkbox/useCheckbox.d.ts +1 -2
- package/dist/components/color-picker/index.js +2 -2
- package/dist/components/color-picker/types.d.ts +2 -2
- package/dist/components/color-picker/useColorPickerDrag.d.ts +1 -1
- package/dist/components/color-picker/useColorPickerSaturation.d.ts +22 -0
- package/dist/components/color-picker/useColorPickerSlider.d.ts +20 -0
- package/dist/components/color-picker/useColorPickerValue.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/dialog/{dialog-core.d.ts → dialogContext.d.ts} +1 -5
- package/dist/components/dialog/useDialogContentInteractions.d.ts +18 -0
- package/dist/components/dialog/useDialogRootState.d.ts +19 -0
- package/dist/components/dropdown-menu/dropdown-menu-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-item-row.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-model.d.ts +8 -0
- package/dist/components/dropdown-menu/dropdown-menu-root.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-trigger.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/components/dropdown-menu/{dropdown-menu-primitive-core.d.ts → dropdownMenuContext.d.ts} +17 -30
- package/dist/components/dropdown-menu/dropdownMenuDataModel.d.ts +20 -0
- package/dist/components/dropdown-menu/dropdownMenuInteraction.d.ts +3 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionNavigation.d.ts +24 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionRegistry.d.ts +42 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionTypes.d.ts +114 -0
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts +11 -11
- package/dist/components/dropdown-menu/useDropdownMenuContextTrigger.d.ts +9 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataController.d.ts +35 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataRegistration.d.ts +24 -0
- package/dist/components/dropdown-menu/useDropdownMenuHoverIntent.d.ts +6 -5
- package/dist/components/dropdown-menu/useDropdownMenuInteractionDismissal.d.ts +17 -0
- package/dist/components/dropdown-menu/useDropdownMenuInteractionKeyboard.d.ts +19 -0
- package/dist/components/dropdown-menu/useDropdownMenuPortalPosition.d.ts +0 -1
- package/dist/components/dropdown-menu/useDropdownMenuPresentation.d.ts +28 -0
- package/dist/components/dropdown-menu/useDropdownMenuPrimitiveContent.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +1 -1
- package/dist/components/dropdown-menu/useDropdownMenuTargetBindings.d.ts +19 -0
- 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 +2 -2
- package/dist/components/floating/useFloatingPosition.d.ts +1 -14
- 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/numberInputModel.d.ts +15 -0
- package/dist/components/number-input/useNumberInput.d.ts +3 -19
- package/dist/components/pagination/index.d.ts +1 -1
- package/dist/components/pagination/index.js +1 -1
- package/dist/components/pagination/paginationModel.d.ts +4 -0
- package/dist/components/pagination/types.d.ts +15 -0
- package/dist/components/pagination/usePagination.d.ts +3 -19
- package/dist/components/popover/usePopoverBindings.d.ts +13 -0
- package/dist/components/progress/progressModel.d.ts +8 -0
- package/dist/components/progress/useProgress.d.ts +0 -6
- package/dist/components/radio/useRadio.d.ts +1 -2
- package/dist/components/scroll-area/scroll-area.d.ts +1 -1
- package/dist/components/scroll-area/scrollAreaModel.d.ts +64 -0
- package/dist/components/scroll-area/useScrollArea.d.ts +70 -53
- package/dist/components/scroll-area/{useScrollAreaPresentation.d.ts → useScrollAreaAttributes.d.ts} +37 -17
- package/dist/components/scroll-area/useScrollAreaDerivedState.d.ts +8 -0
- package/dist/components/scroll-area/useScrollAreaMeasurement.d.ts +35 -0
- package/dist/components/scroll-area/useScrollAreaPointer.d.ts +11 -9
- package/dist/components/scroll-area/useScrollAreaVisibility.d.ts +15 -20
- 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/rangeSliderModel.d.ts +41 -0
- package/dist/components/slider/{sliderCore.d.ts → sliderModel.d.ts} +0 -1
- package/dist/components/slider/useRangeSlider.d.ts +9 -17
- package/dist/components/slider/useRangeSliderPointer.d.ts +1 -1
- package/dist/components/slider/useRangeSliderValueState.d.ts +40 -0
- package/dist/components/slider/useSlider.d.ts +7 -13
- package/dist/components/slider/useSliderPointerPreview.d.ts +22 -0
- package/dist/components/slider/useSliderTooltipState.d.ts +40 -0
- package/dist/components/slider/useSliderValueState.d.ts +33 -0
- 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/teleport-provider/index.js +1 -1
- package/dist/components/teleport-provider/useTeleportTarget.d.ts +1 -2
- package/dist/components/toast/useToastLifecycle.d.ts +19 -0
- package/dist/components/tooltip/useTooltip.d.ts +1 -2
- package/dist/components/tooltip/useTooltipTargetBindings.d.ts +12 -0
- package/dist/css.js +12 -0
- package/dist/date-picker.css +49 -0
- package/dist/date-picker.js +809 -0
- package/dist/dialog.js +215 -218
- package/dist/direction.js +6 -0
- package/dist/dropdown-menu.css +21 -3
- package/dist/dropdown-menu.js +1626 -1185
- package/dist/dropzone.css +135 -0
- package/dist/dropzone.js +431 -0
- package/dist/events.js +59 -0
- package/dist/field.css +8 -8
- package/dist/field.js +13 -25
- package/dist/file-input.css +135 -0
- package/dist/file-input.js +198 -0
- package/dist/floatingOffset.js +11 -0
- package/dist/focus-trap.js +7 -5
- package/dist/focusNavigation.js +37 -0
- package/dist/hover-card.css +80 -0
- package/dist/hover-card.js +402 -0
- package/dist/icon-button.css +8 -8
- package/dist/icon-button.js +7 -6
- package/dist/index.d.ts +9 -0
- package/dist/index.js +20 -9
- package/dist/input.css +24 -24
- package/dist/input.js +19 -31
- package/dist/interactive.js +18 -0
- package/dist/internal/composables/useOverlayLayer.d.ts +12 -0
- package/dist/modal.js +2 -2
- 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 +44 -44
- package/dist/number.js +22 -0
- package/dist/overlay.js +3 -2
- package/dist/pagination.css +28 -28
- package/dist/pagination.js +66 -73
- package/dist/pointerSession.js +130 -0
- package/dist/popover.css +55 -37
- package/dist/popover.js +75 -101
- package/dist/progress.js +10 -13
- package/dist/query.js +40 -0
- package/dist/radio.css +18 -18
- package/dist/radio.js +30 -36
- package/dist/rafScheduler.js +34 -0
- package/dist/scroll-area.css +28 -28
- package/dist/scroll-area.js +540 -554
- package/dist/segmented-control.css +176 -0
- package/dist/segmented-control.js +382 -0
- package/dist/select.css +50 -48
- package/dist/select.js +131 -289
- package/dist/slider.css +191 -191
- package/dist/slider.js +720 -706
- package/dist/styles-api.d.ts +0 -1
- package/dist/styles-api.js +1 -4
- package/dist/switch.css +17 -17
- package/dist/switch.js +14 -15
- package/dist/tabs.css +43 -43
- package/dist/tabs.js +29 -56
- package/dist/tags-input.css +197 -0
- package/dist/tags-input.js +380 -0
- package/dist/text.js +17 -0
- package/dist/textarea.css +26 -26
- package/dist/textarea.js +21 -32
- package/dist/toast.css +26 -26
- package/dist/toast.js +141 -118
- package/dist/tooltip.css +12 -12
- package/dist/tooltip.js +64 -63
- package/dist/useCollapse.js +8 -11
- package/dist/useControlState.js +3 -6
- package/dist/useEditableOptionList.js +216 -0
- package/dist/useFlatOptionCollection.js +134 -0
- package/dist/useFloatingPosition.js +14 -40
- package/dist/useFloatingTargetLifecycle.js +127 -0
- package/dist/useFormControl.js +1 -0
- package/dist/useHoverDisclosure.js +561 -0
- package/dist/useNativeChoiceTransaction.js +46 -0
- package/dist/useNativeFileSelection.js +86 -0
- package/dist/useOverlayZIndex.js +246 -19
- package/dist/useTeleportTarget.js +3 -14
- package/dist/useTypeahead.js +94 -0
- package/dist/utils/aria.d.ts +3 -0
- package/dist/utils/attributes.d.ts +2 -0
- package/dist/utils/bem.d.ts +3 -0
- package/dist/utils/collectionNavigation.d.ts +2 -0
- package/dist/utils/color.d.ts +7 -0
- package/dist/{components/color-picker/color-picker-utils.d.ts → utils/colorPicker.d.ts} +5 -4
- package/dist/utils/componentColors.d.ts +7 -0
- package/dist/utils/css.d.ts +3 -0
- package/dist/utils/date.d.ts +13 -0
- package/dist/utils/dateAvailability.d.ts +7 -0
- package/dist/utils/dom/ancestry.d.ts +8 -0
- package/dist/utils/dom/attributes.d.ts +16 -0
- package/dist/utils/dom/componentRef.d.ts +4 -0
- package/dist/utils/dom/direction.d.ts +2 -0
- package/dist/utils/dom/events.d.ts +5 -0
- package/dist/utils/dom/files.d.ts +3 -0
- package/dist/utils/dom/focusNavigation.d.ts +7 -0
- package/dist/utils/dom/interactive.d.ts +2 -0
- package/dist/utils/dom/nativeChoice.d.ts +17 -0
- package/dist/utils/dom/pointerSession.d.ts +20 -0
- package/dist/utils/dom/query.d.ts +4 -0
- package/dist/utils/dom/scroll.d.ts +24 -0
- package/dist/utils/floatingOffset.d.ts +10 -0
- package/dist/utils/geometry.d.ts +14 -0
- package/dist/utils/indexPath.d.ts +6 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/optionFilter.d.ts +5 -0
- package/dist/utils/rafScheduler.d.ts +4 -0
- package/dist/utils/text.d.ts +2 -0
- package/docs/code-architecture.md +118 -0
- package/docs/public-floating-api.md +13 -9
- package/docs/public-styles-api.md +25 -12
- package/package.json +51 -14
- package/src/styles/_mixins.scss +26 -0
- package/src/styles/styles-manifest.json +1 -2
- package/dist/components/dropdown-menu/dropdown-menu-outside.d.ts +0 -3
- package/dist/components/dropdown-menu/dropdown-menu-utils.d.ts +0 -21
- package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +0 -36
- package/dist/components/dropdown-menu/useDropdownMenuDom.d.ts +0 -29
- package/dist/components/dropdown-menu/useDropdownMenuInteractions.d.ts +0 -52
- package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +0 -17
- package/dist/components/dropdown-menu/useDropdownSubmenus.d.ts +0 -18
- package/dist/components/scroll-area/scrollAreaCore.d.ts +0 -30
- package/dist/components/scroll-area/useScrollAreaControls.d.ts +0 -25
- package/dist/components/scroll-area/useScrollAreaMetrics.d.ts +0 -38
- package/dist/components/select/useSelectNativeControl.d.ts +0 -9
- package/dist/components/select/useSelectNativeValue.d.ts +0 -9
- package/dist/floating.js +0 -415
- /package/dist/components/alert/{useAlertColor.d.ts → alertColor.d.ts} +0 -0
- /package/dist/components/avatar/{useAvatarColor.d.ts → avatarColor.d.ts} +0 -0
- /package/dist/components/badge/{useBadgeColor.d.ts → badgeColor.d.ts} +0 -0
- /package/dist/components/button/{useButtonColor.d.ts → buttonColor.d.ts} +0 -0
- /package/dist/components/color-swatch/{useColorSwatchColor.d.ts → colorSwatchColor.d.ts} +0 -0
- /package/dist/components/toast/{useToastColor.d.ts → toastColor.d.ts} +0 -0
package/dist/combobox.js
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import './combobox.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 { o as splitCompatibilityAttributes, t as composeEventHandlers } from "./attributes2.js";
|
|
8
|
+
import { t as useControlState } from "./useControlState.js";
|
|
9
|
+
import { t as resolveHTMLElementRef } from "./componentRef.js";
|
|
10
|
+
import { t as useFloatingPosition } from "./useFloatingPosition.js";
|
|
11
|
+
import { r as chevrons_up_down_default } from "./useFlatOptionCollection.js";
|
|
12
|
+
import { t as scroll_area_default } from "./scroll-area.js";
|
|
13
|
+
import { t as useEditableOptionList } from "./useEditableOptionList.js";
|
|
14
|
+
import { i as useHiddenSelectChoiceTransaction, n as createSingleNativeChoiceAdapter } from "./nativeChoice.js";
|
|
15
|
+
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";
|
|
16
|
+
//#region src/components/combobox/comboboxModel.ts
|
|
17
|
+
function hasComboboxValue(value) {
|
|
18
|
+
return value !== null;
|
|
19
|
+
}
|
|
20
|
+
function getComboboxDisplayLabel(options, value) {
|
|
21
|
+
if (!hasComboboxValue(value)) return "";
|
|
22
|
+
return options?.find((option) => option.value === value)?.label ?? "";
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/components/combobox/useCombobox.ts
|
|
26
|
+
function useComboboxTransaction(props, emitUpdate, inputRef, onFormReset) {
|
|
27
|
+
const transaction = useHiddenSelectChoiceTransaction({
|
|
28
|
+
value: {
|
|
29
|
+
modelValue: () => props.modelValue,
|
|
30
|
+
defaultValue: () => props.defaultValue ?? null,
|
|
31
|
+
onChange: emitUpdate
|
|
32
|
+
},
|
|
33
|
+
native: {
|
|
34
|
+
adapter: createSingleNativeChoiceAdapter({
|
|
35
|
+
emptyValue: null,
|
|
36
|
+
options: () => props.options
|
|
37
|
+
}),
|
|
38
|
+
className: "rp-combobox__native",
|
|
39
|
+
focusVisible: () => inputRef.value?.focus(),
|
|
40
|
+
validationMessage: () => props.validationMessage
|
|
41
|
+
},
|
|
42
|
+
onFormReset
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
nativeSelectRef: transaction.nativeSelectRef,
|
|
46
|
+
nativeSelectAttrs: transaction.nativeSelectAttrs,
|
|
47
|
+
requestValueUpdate: transaction.requestValueUpdate,
|
|
48
|
+
selectedValue: transaction.value
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function useCombobox(props, callbacks) {
|
|
52
|
+
const rootRef = ref(null);
|
|
53
|
+
const inputRef = ref(null);
|
|
54
|
+
const dropdownRef = ref(null);
|
|
55
|
+
const generatedId = useId();
|
|
56
|
+
const comboboxId = props.id ?? generatedId;
|
|
57
|
+
const transaction = useComboboxTransaction(props, callbacks.valueChange, inputRef, resetAfterFormReset);
|
|
58
|
+
const selectedValue = transaction.selectedValue;
|
|
59
|
+
const control = useControlState(props);
|
|
60
|
+
const displayLabel = computed(() => getComboboxDisplayLabel(props.options, selectedValue.value));
|
|
61
|
+
const optionList = useEditableOptionList({
|
|
62
|
+
baseId: comboboxId,
|
|
63
|
+
clearable: () => Boolean(props.clearable),
|
|
64
|
+
disabled: () => control.disabled,
|
|
65
|
+
filter: () => props.filter,
|
|
66
|
+
getKey: (option) => option.value,
|
|
67
|
+
inputRef,
|
|
68
|
+
isDisabled: (option) => Boolean(option.disabled),
|
|
69
|
+
items: () => props.options,
|
|
70
|
+
onSearch: callbacks.search,
|
|
71
|
+
rootRef,
|
|
72
|
+
selection: {
|
|
73
|
+
kind: "single",
|
|
74
|
+
clear() {
|
|
75
|
+
if (hasComboboxValue(selectedValue.value)) transaction.requestValueUpdate(null);
|
|
76
|
+
},
|
|
77
|
+
displayValue: () => displayLabel.value,
|
|
78
|
+
hasSelection: () => hasComboboxValue(selectedValue.value),
|
|
79
|
+
isSelected: (option) => option.value === selectedValue.value,
|
|
80
|
+
select: (option) => transaction.requestValueUpdate(option.value)
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const { activeDescendantId, canClear, isOpen, renderedOptions, searchValue, visibleOptions } = optionList.state;
|
|
84
|
+
const { listbox: listboxId, popup: popupId } = optionList.ids;
|
|
85
|
+
const floating = useFloatingPosition({
|
|
86
|
+
reference: rootRef,
|
|
87
|
+
floating: dropdownRef,
|
|
88
|
+
open: isOpen,
|
|
89
|
+
placement: "bottom-start"
|
|
90
|
+
});
|
|
91
|
+
const placementSide = computed(() => floating.actualPlacement.value.split("-")[0]);
|
|
92
|
+
const rootClass = computed(() => bem("rp-combobox", {
|
|
93
|
+
open: isOpen.value,
|
|
94
|
+
[`size-${props.size}`]: Boolean(props.size),
|
|
95
|
+
[`radius-${props.radius}`]: Boolean(props.radius),
|
|
96
|
+
disabled: control.disabled,
|
|
97
|
+
invalid: control.invalid
|
|
98
|
+
}));
|
|
99
|
+
function setDropdownElement(elementRef) {
|
|
100
|
+
resolveHTMLElementRef(elementRef, popupId, (resolved) => {
|
|
101
|
+
dropdownRef.value = resolved;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function resetAfterFormReset() {
|
|
105
|
+
optionList.actions.resetAfterFormReset();
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
templateRefs: {
|
|
109
|
+
root: rootRef,
|
|
110
|
+
input: inputRef,
|
|
111
|
+
native: transaction.nativeSelectRef
|
|
112
|
+
},
|
|
113
|
+
nativeSelectAttrs: transaction.nativeSelectAttrs,
|
|
114
|
+
isOpen,
|
|
115
|
+
popupId,
|
|
116
|
+
listboxId,
|
|
117
|
+
control,
|
|
118
|
+
visibleOptions,
|
|
119
|
+
renderedOptions,
|
|
120
|
+
activeDescendantId,
|
|
121
|
+
rootClass,
|
|
122
|
+
floatingStyle: floating.floatingStyle,
|
|
123
|
+
actualPlacement: floating.actualPlacement,
|
|
124
|
+
placementSide,
|
|
125
|
+
searchValue,
|
|
126
|
+
displayLabel,
|
|
127
|
+
canClear,
|
|
128
|
+
setDropdownElement,
|
|
129
|
+
toggle: optionList.actions.toggle,
|
|
130
|
+
selectOption: optionList.actions.selectOption,
|
|
131
|
+
clearSelection: optionList.actions.clearSelection,
|
|
132
|
+
onOptionMouseenter: optionList.handlers.onOptionMouseenter,
|
|
133
|
+
onFocusout: optionList.handlers.onFocusout,
|
|
134
|
+
onInput: optionList.handlers.onInput,
|
|
135
|
+
onInputFocus: optionList.handlers.onInputFocus,
|
|
136
|
+
onInputClick: optionList.handlers.onInputClick,
|
|
137
|
+
onInputKeydown: optionList.handlers.onInputKeydown
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/components/combobox/combobox.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
142
|
+
var t0 = template("<option data-v-b9882cdc> ");
|
|
143
|
+
var t1 = template("<button data-v-b9882cdc></button>");
|
|
144
|
+
var t2 = template("No options", 2);
|
|
145
|
+
var t3 = template("<div data-v-b9882cdc>");
|
|
146
|
+
var t4 = template(" ");
|
|
147
|
+
var t5 = template("<div data-v-b9882cdc><select data-v-b9882cdc><option data-v-b9882cdc value></option></select><input data-v-b9882cdc><span data-v-b9882cdc><button data-v-b9882cdc>", 1);
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/components/combobox/combobox.vue
|
|
150
|
+
var combobox_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
151
|
+
name: "RpCombobox",
|
|
152
|
+
inheritAttrs: false,
|
|
153
|
+
__name: "combobox",
|
|
154
|
+
props: {
|
|
155
|
+
id: {},
|
|
156
|
+
name: {},
|
|
157
|
+
form: {},
|
|
158
|
+
modelValue: { default: void 0 },
|
|
159
|
+
defaultValue: { default: null },
|
|
160
|
+
options: { default: () => [] },
|
|
161
|
+
filter: {
|
|
162
|
+
type: [Function, Boolean],
|
|
163
|
+
default: void 0
|
|
164
|
+
},
|
|
165
|
+
size: {},
|
|
166
|
+
radius: {},
|
|
167
|
+
placeholder: { default: "Search..." },
|
|
168
|
+
clearable: {
|
|
169
|
+
type: Boolean,
|
|
170
|
+
default: false
|
|
171
|
+
},
|
|
172
|
+
clearLabel: { default: "Clear selection" },
|
|
173
|
+
toggleLabel: { default: "Toggle options" },
|
|
174
|
+
disabled: {
|
|
175
|
+
type: Boolean,
|
|
176
|
+
default: void 0
|
|
177
|
+
},
|
|
178
|
+
required: {
|
|
179
|
+
type: Boolean,
|
|
180
|
+
default: void 0
|
|
181
|
+
},
|
|
182
|
+
invalid: {
|
|
183
|
+
type: Boolean,
|
|
184
|
+
default: void 0
|
|
185
|
+
},
|
|
186
|
+
ariaLabel: {},
|
|
187
|
+
describedby: {},
|
|
188
|
+
labelledby: {},
|
|
189
|
+
inputAttrs: {},
|
|
190
|
+
validationMessage: {},
|
|
191
|
+
classNames: {},
|
|
192
|
+
styles: {}
|
|
193
|
+
},
|
|
194
|
+
emits: ["update:modelValue", "search"],
|
|
195
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
196
|
+
const props = __props;
|
|
197
|
+
const emit = __emit;
|
|
198
|
+
const { templateRefs, nativeSelectAttrs, isOpen, popupId, listboxId, control, visibleOptions, renderedOptions, activeDescendantId, rootClass, floatingStyle, actualPlacement, placementSide, searchValue, canClear, setDropdownElement, toggle, selectOption, clearSelection, onOptionMouseenter, onFocusout, onInput, onInputFocus, onInputClick, onInputKeydown } = useCombobox(props, {
|
|
199
|
+
valueChange: (value) => emit("update:modelValue", value),
|
|
200
|
+
search: (value) => emit("search", value)
|
|
201
|
+
});
|
|
202
|
+
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
203
|
+
const rootAttrs = computed(() => getRootAttrs({
|
|
204
|
+
class: rootClass.value,
|
|
205
|
+
onFocusout,
|
|
206
|
+
"data-state": isOpen.value ? "open" : "closed",
|
|
207
|
+
"data-disabled": toPresenceAttribute(control.disabled),
|
|
208
|
+
"data-invalid": toPresenceAttribute(control.invalid)
|
|
209
|
+
}));
|
|
210
|
+
const contentAttrs = computed(() => ({
|
|
211
|
+
...getPartAttrs("content", {
|
|
212
|
+
class: "rp-combobox__dropdown",
|
|
213
|
+
style: floatingStyle.value
|
|
214
|
+
}),
|
|
215
|
+
"data-placement": actualPlacement.value,
|
|
216
|
+
"data-side": placementSide.value
|
|
217
|
+
}));
|
|
218
|
+
const visibleInputAttrs = computed(() => {
|
|
219
|
+
const attrs = props.inputAttrs ?? {};
|
|
220
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(attrs);
|
|
221
|
+
return {
|
|
222
|
+
...forwardedAttributes,
|
|
223
|
+
...getPartAttrs("input", {
|
|
224
|
+
class: "rp-combobox__input",
|
|
225
|
+
compatibilityClass,
|
|
226
|
+
compatibilityStyle
|
|
227
|
+
}),
|
|
228
|
+
id: control.id,
|
|
229
|
+
name: void 0,
|
|
230
|
+
form: "",
|
|
231
|
+
type: "text",
|
|
232
|
+
value: searchValue.value,
|
|
233
|
+
placeholder: props.placeholder,
|
|
234
|
+
disabled: control.disabled || void 0,
|
|
235
|
+
required: void 0,
|
|
236
|
+
autocomplete: forwardedAttributes.autocomplete ?? "off",
|
|
237
|
+
role: "combobox",
|
|
238
|
+
"aria-autocomplete": "list",
|
|
239
|
+
"aria-expanded": isOpen.value,
|
|
240
|
+
"aria-haspopup": "listbox",
|
|
241
|
+
"aria-activedescendant": activeDescendantId.value,
|
|
242
|
+
"aria-controls": listboxId,
|
|
243
|
+
"aria-disabled": control.disabled || void 0,
|
|
244
|
+
"aria-invalid": control.invalid || void 0,
|
|
245
|
+
"aria-required": control.required || void 0,
|
|
246
|
+
"aria-label": props.ariaLabel || void 0,
|
|
247
|
+
"aria-labelledby": control.ariaLabelledby,
|
|
248
|
+
"aria-describedby": control.ariaDescribedby,
|
|
249
|
+
"data-state": isOpen.value ? "open" : "closed",
|
|
250
|
+
"data-disabled": toPresenceAttribute(control.disabled),
|
|
251
|
+
"data-invalid": toPresenceAttribute(control.invalid),
|
|
252
|
+
onInput: composeEventHandlers(onInput, attrs.onInput),
|
|
253
|
+
onFocus: composeEventHandlers(onInputFocus, attrs.onFocus),
|
|
254
|
+
onClick: composeEventHandlers(onInputClick, attrs.onClick),
|
|
255
|
+
onKeydown: composeEventHandlers(onInputKeydown, attrs.onKeydown)
|
|
256
|
+
};
|
|
257
|
+
});
|
|
258
|
+
__expose({
|
|
259
|
+
nativeElement: templateRefs.native,
|
|
260
|
+
inputElement: templateRefs.input,
|
|
261
|
+
focus: () => templateRefs.input.value?.focus()
|
|
262
|
+
});
|
|
263
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
264
|
+
const n28 = t5();
|
|
265
|
+
const n3 = child(n28);
|
|
266
|
+
const n4 = next(n3, 1);
|
|
267
|
+
const n11 = next(n4, 2);
|
|
268
|
+
const n10 = child(n11, 1);
|
|
269
|
+
renderEffect(() => {
|
|
270
|
+
const _control = unref(control);
|
|
271
|
+
setDynamicProps(n28, [rootAttrs.value]);
|
|
272
|
+
setDynamicProps(n3, [unref(nativeSelectAttrs), {
|
|
273
|
+
name: __props.name,
|
|
274
|
+
form: _control.form,
|
|
275
|
+
disabled: _control.disabled || void 0,
|
|
276
|
+
required: _control.required || void 0,
|
|
277
|
+
tabindex: "-1",
|
|
278
|
+
"aria-hidden": "true"
|
|
279
|
+
}]);
|
|
280
|
+
});
|
|
281
|
+
setInsertionState(n3, null, 1);
|
|
282
|
+
createFor(() => __props.options, (_for_item0) => {
|
|
283
|
+
const n2 = t0();
|
|
284
|
+
const x2 = txt(n2);
|
|
285
|
+
renderEffect(() => {
|
|
286
|
+
const _option = _for_item0.value;
|
|
287
|
+
setValue(n2, String(_option.value));
|
|
288
|
+
setProp(n2, "disabled", _option.disabled || void 0);
|
|
289
|
+
setText(x2, toDisplayString(_option.label));
|
|
290
|
+
});
|
|
291
|
+
return n2;
|
|
292
|
+
}, (option) => option.value, 8);
|
|
293
|
+
renderEffect(() => {
|
|
294
|
+
const _templateRefs = unref(templateRefs);
|
|
295
|
+
_setTemplateRef(n3, _templateRefs.native);
|
|
296
|
+
setDynamicProps(n4, [visibleInputAttrs.value]);
|
|
297
|
+
_setTemplateRef(n4, _templateRefs.input);
|
|
298
|
+
setDynamicProps(n11, [unref(getPartAttrs)("indicator", { class: "rp-combobox__indicator" })]);
|
|
299
|
+
});
|
|
300
|
+
setInsertionState(n11, 0);
|
|
301
|
+
createIf(() => unref(canClear), () => {
|
|
302
|
+
const n8 = t1();
|
|
303
|
+
renderEffect(() => setDynamicProps(n8, [
|
|
304
|
+
{ type: "button" },
|
|
305
|
+
unref(getPartAttrs)("clear", { class: "rp-combobox__clear" }),
|
|
306
|
+
{
|
|
307
|
+
"aria-label": __props.clearLabel,
|
|
308
|
+
tabindex: "-1"
|
|
309
|
+
}
|
|
310
|
+
]));
|
|
311
|
+
setInsertionState(n8, null, 0);
|
|
312
|
+
createComponent(unref(x_default));
|
|
313
|
+
on(n8, "mousedown", withModifiers(() => {}, ["prevent"]));
|
|
314
|
+
on(n8, "click", withModifiers((e) => unref(clearSelection)(e), ["stop"]));
|
|
315
|
+
return n8;
|
|
316
|
+
});
|
|
317
|
+
renderEffect(() => setDynamicProps(n10, [
|
|
318
|
+
{ type: "button" },
|
|
319
|
+
unref(getPartAttrs)("toggle", { class: "rp-combobox__toggle" }),
|
|
320
|
+
{
|
|
321
|
+
"aria-label": __props.toggleLabel,
|
|
322
|
+
"aria-expanded": unref(isOpen),
|
|
323
|
+
disabled: unref(control).disabled || void 0,
|
|
324
|
+
tabindex: "-1"
|
|
325
|
+
}
|
|
326
|
+
]));
|
|
327
|
+
setInsertionState(n10, null, 0);
|
|
328
|
+
createComponent(unref(chevrons_up_down_default));
|
|
329
|
+
on(n10, "mousedown", withModifiers(() => {}, ["prevent"]));
|
|
330
|
+
on(n10, "click", withModifiers((e) => unref(toggle)(e), ["stop"]));
|
|
331
|
+
setInsertionState(n28, null, 3);
|
|
332
|
+
createComponent(VaporTransition, { name: "rp-combobox-dropdown" }, extend(() => {
|
|
333
|
+
return createIf(() => unref(isOpen), () => {
|
|
334
|
+
const n26 = createComponent(scroll_area_default, { $: [() => contentAttrs.value, {
|
|
335
|
+
id: () => unref(popupId),
|
|
336
|
+
embedded: "",
|
|
337
|
+
type: "auto",
|
|
338
|
+
scrollbars: "y",
|
|
339
|
+
"viewport-attrs": () => ({
|
|
340
|
+
role: "listbox",
|
|
341
|
+
tabindex: -1
|
|
342
|
+
}),
|
|
343
|
+
"data-state": () => unref(isOpen) ? "open" : "closed"
|
|
344
|
+
}] }, extend(() => {
|
|
345
|
+
return [createIf(() => unref(visibleOptions).length === 0, () => {
|
|
346
|
+
const n19 = t3();
|
|
347
|
+
renderEffect(() => setDynamicProps(n19, [unref(getPartAttrs)("empty", { class: "rp-combobox__empty" })]));
|
|
348
|
+
setInsertionState(n19, null, 0);
|
|
349
|
+
createSlot("empty", { searchValue: () => unref(searchValue) }, () => {
|
|
350
|
+
return t2();
|
|
351
|
+
}, 1);
|
|
352
|
+
return n19;
|
|
353
|
+
}, null, 129), createFor(() => unref(renderedOptions), (_for_item0) => {
|
|
354
|
+
const n25 = t3();
|
|
355
|
+
renderEffect(() => {
|
|
356
|
+
const _optionState = _for_item0.value;
|
|
357
|
+
const _optionState_selected = _optionState.selected;
|
|
358
|
+
const _optionState_disabled = _optionState.disabled;
|
|
359
|
+
setDynamicProps(n25, [{
|
|
360
|
+
id: _optionState.id,
|
|
361
|
+
role: "option",
|
|
362
|
+
"aria-selected": _optionState_selected,
|
|
363
|
+
"aria-disabled": _optionState_disabled || void 0,
|
|
364
|
+
"data-selected": unref(toPresenceAttribute)(_optionState.selected),
|
|
365
|
+
"data-highlighted": unref(toPresenceAttribute)(_optionState.active),
|
|
366
|
+
"data-disabled": unref(toPresenceAttribute)(_optionState.disabled)
|
|
367
|
+
}, unref(getPartAttrs)("option", { class: ["rp-combobox__option", {
|
|
368
|
+
"rp-combobox__option--selected": _optionState_selected,
|
|
369
|
+
"rp-combobox__option--highlighted": _optionState.active,
|
|
370
|
+
"rp-combobox__option--disabled": _optionState_disabled
|
|
371
|
+
}] })]);
|
|
372
|
+
});
|
|
373
|
+
setInsertionState(n25, null, 0);
|
|
374
|
+
createSlot("option", {
|
|
375
|
+
option: () => _for_item0.value.option,
|
|
376
|
+
selected: () => _for_item0.value.selected,
|
|
377
|
+
highlighted: () => _for_item0.value.active
|
|
378
|
+
}, () => {
|
|
379
|
+
const n24 = t4();
|
|
380
|
+
renderEffect(() => setText(n24, toDisplayString(_for_item0.value.option.label)));
|
|
381
|
+
return n24;
|
|
382
|
+
}, 1);
|
|
383
|
+
on(n25, "mousedown", withModifiers(() => {}, ["prevent"]));
|
|
384
|
+
on(n25, "click", () => unref(selectOption)(_for_item0.value.option));
|
|
385
|
+
on(n25, "mouseenter", () => unref(onOptionMouseenter)(_for_item0.value.option));
|
|
386
|
+
return n25;
|
|
387
|
+
}, (optionState) => optionState.option.value, 40)];
|
|
388
|
+
}, { _: 8 }));
|
|
389
|
+
setTemplateRefBinding(n26, () => setDropdownElement, _setTemplateRef, void 0, "setDropdownElement");
|
|
390
|
+
return n26;
|
|
391
|
+
}, null, 129);
|
|
392
|
+
}, { _: 8 }));
|
|
393
|
+
setTemplateRefBinding(n28, () => unref(templateRefs).root);
|
|
394
|
+
return n28;
|
|
395
|
+
}
|
|
396
|
+
}), [["__scopeId", "data-v-b9882cdc"]]);
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/components/combobox/types.ts
|
|
399
|
+
var comboboxParts = [
|
|
400
|
+
"root",
|
|
401
|
+
"input",
|
|
402
|
+
"indicator",
|
|
403
|
+
"clear",
|
|
404
|
+
"toggle",
|
|
405
|
+
"content",
|
|
406
|
+
"option",
|
|
407
|
+
"empty"
|
|
408
|
+
];
|
|
409
|
+
//#endregion
|
|
410
|
+
export { combobox_default as n, comboboxParts as t };
|
package/dist/componentColors.js
CHANGED
|
@@ -61,6 +61,18 @@ function getComponentColorValue(color) {
|
|
|
61
61
|
function getComponentContrastColor(color, options = {}) {
|
|
62
62
|
return getComponentContrastColorRoles(color, options).color;
|
|
63
63
|
}
|
|
64
|
+
function getComponentCheckedColorStyle({ color, colorProperty, checkedColorProperty, defaultColor = "primary", autoContrast, contrastColor }) {
|
|
65
|
+
const colorValue = getComponentColorValue(color);
|
|
66
|
+
if (color && !colorValue) return void 0;
|
|
67
|
+
if (!colorValue && autoContrast === false && contrastColor === void 0) return void 0;
|
|
68
|
+
const style = {};
|
|
69
|
+
if (colorValue) style[colorProperty] = colorValue;
|
|
70
|
+
if (autoContrast !== false || contrastColor !== void 0) style[checkedColorProperty] = getComponentContrastColor(color ?? defaultColor, {
|
|
71
|
+
autoContrast,
|
|
72
|
+
contrastColor
|
|
73
|
+
});
|
|
74
|
+
return style;
|
|
75
|
+
}
|
|
64
76
|
function getComponentContrastColorRoles(color, options = {}) {
|
|
65
77
|
if (options.contrastColor !== void 0) return createContrastColorRoles(options.contrastColor);
|
|
66
78
|
if (options.autoContrast === false) return createContrastColorRoles("var(--rp-color-white)");
|
|
@@ -76,8 +88,17 @@ function getComponentContrastColorRoles(color, options = {}) {
|
|
|
76
88
|
}
|
|
77
89
|
function getComponentColorRoles(color) {
|
|
78
90
|
const parsed = parseComponentColor(color);
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
switch (parsed.kind) {
|
|
92
|
+
case "empty":
|
|
93
|
+
case "invalid": return;
|
|
94
|
+
case "primary": return createPrimaryColorRoles();
|
|
95
|
+
case "preset": return createPresetColorRoles(parsed.color);
|
|
96
|
+
case "shade": return createShadeColorRoles(parsed.color, parsed.shade);
|
|
97
|
+
case "custom": return createCustomColorRoles(parsed.value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function createPrimaryColorRoles() {
|
|
101
|
+
return createComponentColorRoles("var(--rp-primary-color-filled)", {
|
|
81
102
|
hover: "var(--rp-primary-color-filled-hover)",
|
|
82
103
|
contrast: "var(--rp-primary-color-contrast)",
|
|
83
104
|
light: "var(--rp-primary-color-light)",
|
|
@@ -86,119 +107,139 @@ function getComponentColorRoles(color) {
|
|
|
86
107
|
outlineHover: "color-mix(in srgb, var(--rp-primary-color-outline) 62%, transparent)",
|
|
87
108
|
foreground: "var(--rp-primary-color-light-color)"
|
|
88
109
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
110
|
+
}
|
|
111
|
+
function createPresetColorRoles(color) {
|
|
112
|
+
return createComponentColorRoles(`var(--rp-color-${color}-filled)`, {
|
|
113
|
+
hover: `var(--rp-color-${color}-filled-hover)`,
|
|
114
|
+
contrast: `var(--rp-color-${color}-contrast)`,
|
|
115
|
+
light: `var(--rp-color-${color}-light)`,
|
|
116
|
+
lightHover: `var(--rp-color-${color}-light-hover)`,
|
|
117
|
+
outline: `var(--rp-color-${color}-outline)`,
|
|
118
|
+
outlineHover: `color-mix(in srgb, var(--rp-color-${color}-outline) 62%, transparent)`,
|
|
119
|
+
foreground: `var(--rp-color-${color}-light-color)`
|
|
97
120
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
}
|
|
122
|
+
function createShadeColorRoles(color, shade) {
|
|
123
|
+
const base = `var(--rp-color-${color}-${shade})`;
|
|
124
|
+
const hoverShade = Math.min(Number(shade) + 1, 9);
|
|
125
|
+
return createComponentColorRoles(base, {
|
|
126
|
+
hover: `var(--rp-color-${color}-${hoverShade})`,
|
|
127
|
+
contrast: `var(--rp-color-${color}-${shade}-contrast)`,
|
|
128
|
+
contrastHover: `var(--rp-color-${color}-${hoverShade}-contrast)`,
|
|
129
|
+
contrastActive: `var(--rp-color-${color}-${shade}-active-contrast)`,
|
|
130
|
+
foreground: base
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function createCustomColorRoles(color) {
|
|
134
|
+
const contrast = getCustomContrastColorRoles(color);
|
|
135
|
+
return createComponentColorRoles(color, {
|
|
111
136
|
contrast: contrast.color,
|
|
112
137
|
contrastHover: contrast.hover,
|
|
113
138
|
contrastActive: contrast.active,
|
|
114
|
-
foreground: getCustomForegroundColor(
|
|
139
|
+
foreground: getCustomForegroundColor(color)
|
|
115
140
|
});
|
|
116
141
|
}
|
|
117
142
|
function getComponentVariantColorRoles({ color, variant, defaultColor = "primary", autoContrast, contrastColor }) {
|
|
118
|
-
const
|
|
143
|
+
const resolvedColor = color ?? defaultColor;
|
|
144
|
+
const roles = getComponentColorRoles(resolvedColor);
|
|
119
145
|
if (!roles) return void 0;
|
|
120
|
-
if (variant === "solid") {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
if (variant === "solid") return createSolidVariantColorRoles(roles, getComponentContrastColorRoles(resolvedColor, {
|
|
147
|
+
autoContrast,
|
|
148
|
+
contrastColor
|
|
149
|
+
}));
|
|
150
|
+
return createForegroundVariantColorRoles(roles, variant);
|
|
151
|
+
}
|
|
152
|
+
function createSolidVariantColorRoles(roles, contrast) {
|
|
153
|
+
return {
|
|
154
|
+
background: roles.filled,
|
|
155
|
+
hover: roles.hover,
|
|
156
|
+
active: roles.active,
|
|
157
|
+
color: contrast.color,
|
|
158
|
+
colorHover: contrast.hover,
|
|
159
|
+
colorActive: contrast.active,
|
|
160
|
+
border: roles.filled,
|
|
161
|
+
borderHover: roles.hover,
|
|
162
|
+
borderActive: roles.active
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function createForegroundVariantColorRoles(roles, variant) {
|
|
166
|
+
return {
|
|
167
|
+
...getForegroundVariantSurfaces(roles, variant),
|
|
168
|
+
color: roles.foreground,
|
|
169
|
+
colorHover: roles.foreground,
|
|
170
|
+
colorActive: roles.foreground
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function getForegroundVariantSurfaces(roles, variant) {
|
|
174
|
+
switch (variant) {
|
|
175
|
+
case "subtle": return createSubtleVariantSurfaces(roles);
|
|
176
|
+
case "surface": return createSurfaceVariantSurfaces(roles);
|
|
177
|
+
case "outline": return createOutlineVariantSurfaces(roles);
|
|
178
|
+
case "ghost": return createGhostVariantSurfaces(roles);
|
|
179
|
+
case "plain": return createPlainVariantSurfaces();
|
|
180
|
+
default: return createDefaultVariantSurfaces(roles);
|
|
136
181
|
}
|
|
137
|
-
|
|
182
|
+
}
|
|
183
|
+
function createSubtleVariantSurfaces(roles) {
|
|
184
|
+
return createVariantSurfaces({
|
|
138
185
|
background: roles.light,
|
|
139
186
|
hover: roles.lightHover,
|
|
140
187
|
active: roles.lightActive,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
borderActive: "transparent"
|
|
147
|
-
};
|
|
148
|
-
if (variant === "surface") return {
|
|
188
|
+
border: "transparent"
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function createSurfaceVariantSurfaces(roles) {
|
|
192
|
+
return createVariantSurfaces({
|
|
149
193
|
background: roles.light,
|
|
150
194
|
hover: roles.lightHover,
|
|
151
195
|
active: roles.lightActive,
|
|
152
|
-
color: roles.foreground,
|
|
153
|
-
colorHover: roles.foreground,
|
|
154
|
-
colorActive: roles.foreground,
|
|
155
196
|
border: roles.outline,
|
|
156
197
|
borderHover: roles.lightHover,
|
|
157
198
|
borderActive: roles.outlineHover
|
|
158
|
-
};
|
|
159
|
-
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function createOutlineVariantSurfaces(roles) {
|
|
202
|
+
return createVariantSurfaces({
|
|
160
203
|
background: "transparent",
|
|
161
204
|
hover: roles.lightHover,
|
|
162
205
|
active: roles.lightActive,
|
|
163
|
-
color: roles.foreground,
|
|
164
|
-
colorHover: roles.foreground,
|
|
165
|
-
colorActive: roles.foreground,
|
|
166
206
|
border: roles.outline,
|
|
167
|
-
borderHover: roles.outlineHover
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
207
|
+
borderHover: roles.outlineHover
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function createGhostVariantSurfaces(roles) {
|
|
211
|
+
return createVariantSurfaces({
|
|
171
212
|
background: "transparent",
|
|
172
213
|
hover: roles.lightHover,
|
|
173
214
|
active: roles.lightActive,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
borderActive: "transparent"
|
|
180
|
-
};
|
|
181
|
-
if (variant === "plain") return {
|
|
215
|
+
border: "transparent"
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function createPlainVariantSurfaces() {
|
|
219
|
+
return createVariantSurfaces({
|
|
182
220
|
background: "transparent",
|
|
183
221
|
hover: "transparent",
|
|
184
222
|
active: "transparent",
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
borderActive: "transparent"
|
|
191
|
-
};
|
|
192
|
-
return {
|
|
223
|
+
border: "transparent"
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
function createDefaultVariantSurfaces(roles) {
|
|
227
|
+
return createVariantSurfaces({
|
|
193
228
|
background: "var(--rp-color-default)",
|
|
194
229
|
hover: roles.lightHover,
|
|
195
230
|
active: roles.lightActive,
|
|
196
|
-
color: roles.foreground,
|
|
197
|
-
colorHover: roles.foreground,
|
|
198
|
-
colorActive: roles.foreground,
|
|
199
231
|
border: roles.outline,
|
|
200
|
-
borderHover: roles.outlineHover
|
|
201
|
-
|
|
232
|
+
borderHover: roles.outlineHover
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function createVariantSurfaces({ background, hover, active, border, borderHover = border, borderActive = borderHover }) {
|
|
236
|
+
return {
|
|
237
|
+
background,
|
|
238
|
+
hover,
|
|
239
|
+
active,
|
|
240
|
+
border,
|
|
241
|
+
borderHover,
|
|
242
|
+
borderActive
|
|
202
243
|
};
|
|
203
244
|
}
|
|
204
245
|
function createComponentColorRoles(color, overrides = {}) {
|
|
@@ -322,4 +363,4 @@ function relativeLuminance(color) {
|
|
|
322
363
|
return .2126 * red + .7152 * green + .0722 * blue;
|
|
323
364
|
}
|
|
324
365
|
//#endregion
|
|
325
|
-
export { getComponentVariantColorRoles as a,
|
|
366
|
+
export { getComponentVariantColorRoles as a, getComponentColorValue as i, getComponentCheckedColorStyle as n, getComponentColorRoles as r, componentColors as t };
|