@itguy614/clean-ui 1.2.2 → 1.3.1
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 +12 -0
- package/dist/clean-ui.css +1 -1
- package/dist/components/CuiAccordion.vue.js +2 -2
- package/dist/components/CuiAlert.vue.d.ts +3 -5
- package/dist/components/CuiAlert.vue.d.ts.map +1 -1
- package/dist/components/CuiAlert.vue.js +1 -1
- package/dist/components/CuiAlert.vue2.js +54 -50
- package/dist/components/CuiBadge.vue.js +3 -3
- package/dist/components/CuiBadge.vue2.js +23 -23
- package/dist/components/CuiBanner.vue.d.ts +15 -10
- package/dist/components/CuiBanner.vue.d.ts.map +1 -1
- package/dist/components/CuiBanner.vue.js +5 -80
- package/dist/components/CuiBanner.vue2.js +90 -2
- package/dist/components/CuiButton.vue.d.ts +9 -0
- package/dist/components/CuiButton.vue.d.ts.map +1 -1
- package/dist/components/CuiButton.vue.js +1 -1
- package/dist/components/CuiButton.vue2.js +77 -83
- package/dist/components/CuiButtonGroup.vue.d.ts +4 -2
- package/dist/components/CuiButtonGroup.vue.d.ts.map +1 -1
- package/dist/components/CuiButtonGroup.vue.js +1 -1
- package/dist/components/CuiButtonGroup.vue2.js +18 -9
- package/dist/components/CuiCard.vue.d.ts.map +1 -1
- package/dist/components/CuiCard.vue.js +5 -33
- package/dist/components/CuiCard.vue2.js +32 -2
- package/dist/components/CuiCardBody.vue.d.ts.map +1 -1
- package/dist/components/CuiCardBody.vue.js +5 -18
- package/dist/components/CuiCardBody.vue2.js +18 -2
- package/dist/components/CuiCardFooter.vue.d.ts.map +1 -1
- package/dist/components/CuiCardFooter.vue.js +5 -30
- package/dist/components/CuiCardFooter.vue2.js +25 -2
- package/dist/components/CuiCardHeader.vue.d.ts +5 -4
- package/dist/components/CuiCardHeader.vue.d.ts.map +1 -1
- package/dist/components/CuiCardHeader.vue.js +5 -49
- package/dist/components/CuiCardHeader.vue2.js +40 -2
- package/dist/components/CuiCardMedia.vue.d.ts.map +1 -1
- package/dist/components/CuiCardMedia.vue.js +3 -3
- package/dist/components/CuiCardMedia.vue2.js +6 -6
- package/dist/components/CuiCheckbox.vue.d.ts +2 -2
- package/dist/components/CuiCheckbox.vue.d.ts.map +1 -1
- package/dist/components/CuiCheckbox.vue.js +1 -1
- package/dist/components/CuiCheckbox.vue2.js +46 -34
- package/dist/components/CuiCheckboxGroup.vue.d.ts +2 -2
- package/dist/components/CuiCheckboxGroup.vue.d.ts.map +1 -1
- package/dist/components/CuiCheckboxGroup.vue.js +2 -2
- package/dist/components/CuiCheckboxGroup.vue2.js +45 -35
- package/dist/components/CuiCodeBlock.vue.d.ts.map +1 -1
- package/dist/components/CuiCodeBlock.vue.js +14 -11
- package/dist/components/CuiColorPicker.vue.d.ts +2 -2
- package/dist/components/CuiColorPicker.vue.d.ts.map +1 -1
- package/dist/components/CuiColorPicker.vue.js +117 -104
- package/dist/components/CuiCombobox.vue.d.ts +2 -2
- package/dist/components/CuiCombobox.vue.d.ts.map +1 -1
- package/dist/components/CuiCombobox.vue.js +5 -330
- package/dist/components/CuiCombobox.vue2.js +330 -2
- package/dist/components/CuiConfirmDialog.vue.d.ts +5 -4
- package/dist/components/CuiConfirmDialog.vue.d.ts.map +1 -1
- package/dist/components/CuiConfirmDialog.vue.js +84 -73
- package/dist/components/CuiContextMenu.vue.d.ts +40 -1
- package/dist/components/CuiContextMenu.vue.d.ts.map +1 -1
- package/dist/components/CuiContextMenu.vue.js +1 -1
- package/dist/components/CuiContextMenu.vue2.js +149 -91
- package/dist/components/CuiCopyButton.vue.d.ts.map +1 -1
- package/dist/components/CuiCopyButton.vue.js +5 -61
- package/dist/components/CuiCopyButton.vue2.js +68 -2
- package/dist/components/CuiDataGridCardView.vue.d.ts.map +1 -1
- package/dist/components/CuiDataGridCardView.vue.js +10 -9
- package/dist/components/CuiDataGridColumnManager.vue.d.ts.map +1 -1
- package/dist/components/CuiDataGridColumnManager.vue.js +12 -11
- package/dist/components/CuiDataGridPagination.vue.d.ts.map +1 -1
- package/dist/components/CuiDataGridPagination.vue.js +9 -8
- package/dist/components/CuiDataGridSearch.vue.d.ts.map +1 -1
- package/dist/components/CuiDataGridSearch.vue.js +12 -9
- package/dist/components/CuiDataGridTable.vue.d.ts.map +1 -1
- package/dist/components/CuiDataGridTable.vue.js +213 -190
- package/dist/components/CuiDataGridViewManager.vue.d.ts.map +1 -1
- package/dist/components/CuiDataGridViewManager.vue.js +21 -20
- package/dist/components/CuiDatePicker.vue.d.ts +2 -2
- package/dist/components/CuiDatePicker.vue.d.ts.map +1 -1
- package/dist/components/CuiDatePicker.vue.js +257 -173
- package/dist/components/CuiDateRangePicker.vue.d.ts +2 -2
- package/dist/components/CuiDateRangePicker.vue.d.ts.map +1 -1
- package/dist/components/CuiDateRangePicker.vue.js +262 -179
- package/dist/components/CuiDivider.vue.d.ts +1 -3
- package/dist/components/CuiDivider.vue.d.ts.map +1 -1
- package/dist/components/CuiDivider.vue.js +47 -59
- package/dist/components/CuiDropdownMenu.vue.js +2 -2
- package/dist/components/CuiDropdownRadioGroup.vue.d.ts +4 -1
- package/dist/components/CuiDropdownRadioGroup.vue.d.ts.map +1 -1
- package/dist/components/CuiDropdownRadioGroup.vue.js +27 -14
- package/dist/components/CuiDropdownSub.vue.js +2 -2
- package/dist/components/CuiEmptyState.vue.d.ts +5 -4
- package/dist/components/CuiEmptyState.vue.d.ts.map +1 -1
- package/dist/components/CuiEmptyState.vue.js +1 -1
- package/dist/components/CuiEmptyState.vue2.js +30 -24
- package/dist/components/CuiFieldset.vue.d.ts.map +1 -1
- package/dist/components/CuiFieldset.vue.js +1 -1
- package/dist/components/CuiFieldset.vue2.js +21 -21
- package/dist/components/CuiFileUpload.vue.d.ts +2 -2
- package/dist/components/CuiFileUpload.vue.d.ts.map +1 -1
- package/dist/components/CuiFileUpload.vue.js +70 -57
- package/dist/components/CuiFormField.vue.d.ts.map +1 -1
- package/dist/components/CuiFormField.vue.js +2 -2
- package/dist/components/CuiFormField.vue2.js +48 -42
- package/dist/components/CuiInput.vue.d.ts +2 -2
- package/dist/components/CuiInput.vue.d.ts.map +1 -1
- package/dist/components/CuiInput.vue.js +1 -1
- package/dist/components/CuiInput.vue2.js +97 -85
- package/dist/components/CuiInputStepper.vue.d.ts +2 -2
- package/dist/components/CuiInputStepper.vue.d.ts.map +1 -1
- package/dist/components/CuiInputStepper.vue.js +5 -187
- package/dist/components/CuiInputStepper.vue2.js +237 -2
- package/dist/components/CuiKbd.vue.d.ts.map +1 -1
- package/dist/components/CuiKbd.vue.js +6 -5
- package/dist/components/CuiMaskedInput.vue.d.ts +9 -3
- package/dist/components/CuiMaskedInput.vue.d.ts.map +1 -1
- package/dist/components/CuiMaskedInput.vue.js +132 -117
- package/dist/components/CuiModal.vue.d.ts +10 -2
- package/dist/components/CuiModal.vue.d.ts.map +1 -1
- package/dist/components/CuiModal.vue.js +2 -2
- package/dist/components/CuiModal.vue2.js +48 -44
- package/dist/components/CuiModalBody.vue.d.ts.map +1 -1
- package/dist/components/CuiModalBody.vue.js +16 -13
- package/dist/components/CuiModalFooter.vue.d.ts.map +1 -1
- package/dist/components/CuiModalFooter.vue.js +3 -2
- package/dist/components/CuiModalHeader.vue.d.ts +13 -4
- package/dist/components/CuiModalHeader.vue.d.ts.map +1 -1
- package/dist/components/CuiModalHeader.vue.js +54 -42
- package/dist/components/CuiPagination.vue.d.ts.map +1 -1
- package/dist/components/CuiPagination.vue.js +1 -1
- package/dist/components/CuiPagination.vue2.js +28 -25
- package/dist/components/CuiPopover.vue.d.ts.map +1 -1
- package/dist/components/CuiPopover.vue.js +80 -72
- package/dist/components/CuiRadio.vue.d.ts +2 -4
- package/dist/components/CuiRadio.vue.d.ts.map +1 -1
- package/dist/components/CuiRadio.vue.js +2 -2
- package/dist/components/CuiRadio.vue2.js +88 -74
- package/dist/components/CuiRadioGroup.vue.d.ts +2 -2
- package/dist/components/CuiRadioGroup.vue.d.ts.map +1 -1
- package/dist/components/CuiRadioGroup.vue.js +3 -3
- package/dist/components/CuiRadioGroup.vue2.js +47 -37
- package/dist/components/CuiRating.vue.d.ts.map +1 -1
- package/dist/components/CuiRating.vue.js +15 -14
- package/dist/components/CuiResizablePanels.vue.d.ts.map +1 -1
- package/dist/components/CuiResizablePanels.vue.js +10 -9
- package/dist/components/CuiSelect.vue.d.ts +2 -2
- package/dist/components/CuiSelect.vue.d.ts.map +1 -1
- package/dist/components/CuiSelect.vue.js +2 -2
- package/dist/components/CuiSelect.vue2.js +161 -151
- package/dist/components/CuiSkeleton.vue.js +2 -2
- package/dist/components/CuiSkeleton.vue2.js +10 -10
- package/dist/components/CuiSlideover.vue.d.ts +2 -2
- package/dist/components/CuiSlideover.vue.d.ts.map +1 -1
- package/dist/components/CuiSlideover.vue.js +34 -30
- package/dist/components/CuiSlider.vue.d.ts +2 -2
- package/dist/components/CuiSlider.vue.d.ts.map +1 -1
- package/dist/components/CuiSlider.vue.js +5 -154
- package/dist/components/CuiSlider.vue2.js +171 -2
- package/dist/components/CuiSpinner.vue.d.ts.map +1 -1
- package/dist/components/CuiSpinner.vue.js +5 -4
- package/dist/components/CuiTable.vue.d.ts.map +1 -1
- package/dist/components/CuiTable.vue.js +4 -1
- package/dist/components/CuiTableBody.vue.d.ts.map +1 -1
- package/dist/components/CuiTableBody.vue.js +6 -6
- package/dist/components/CuiTableCell.vue.d.ts.map +1 -1
- package/dist/components/CuiTableCell.vue.js +11 -10
- package/dist/components/CuiTableFoot.vue.d.ts.map +1 -1
- package/dist/components/CuiTableFoot.vue.js +7 -7
- package/dist/components/CuiTableHead.vue.d.ts.map +1 -1
- package/dist/components/CuiTableHead.vue.js +7 -7
- package/dist/components/CuiTabs.vue.d.ts.map +1 -1
- package/dist/components/CuiTabs.vue.js +2 -2
- package/dist/components/CuiTabs.vue2.js +81 -76
- package/dist/components/CuiTagInput.vue.d.ts +2 -2
- package/dist/components/CuiTagInput.vue.d.ts.map +1 -1
- package/dist/components/CuiTagInput.vue.js +5 -294
- package/dist/components/CuiTagInput.vue2.js +276 -2
- package/dist/components/CuiTextarea.vue.d.ts +2 -2
- package/dist/components/CuiTextarea.vue.d.ts.map +1 -1
- package/dist/components/CuiTextarea.vue.js +4 -4
- package/dist/components/CuiTextarea.vue2.js +73 -59
- package/dist/components/CuiTimePicker.vue.d.ts +2 -2
- package/dist/components/CuiTimePicker.vue.d.ts.map +1 -1
- package/dist/components/CuiTimePicker.vue.js +172 -97
- package/dist/components/CuiTimeline.vue.d.ts.map +1 -1
- package/dist/components/CuiTimeline.vue.js +6 -5
- package/dist/components/CuiTimelineItem.vue.d.ts.map +1 -1
- package/dist/components/CuiTimelineItem.vue.js +11 -10
- package/dist/components/CuiToast.vue.d.ts +8 -10
- package/dist/components/CuiToast.vue.d.ts.map +1 -1
- package/dist/components/CuiToast.vue.js +2 -2
- package/dist/components/CuiToast.vue2.js +69 -67
- package/dist/components/CuiToggle.vue.d.ts +2 -2
- package/dist/components/CuiToggle.vue.d.ts.map +1 -1
- package/dist/components/CuiToggle.vue.js +2 -2
- package/dist/components/CuiToggle.vue2.js +71 -59
- package/dist/components/CuiToggleGroup.vue.d.ts +2 -2
- package/dist/components/CuiToggleGroup.vue.d.ts.map +1 -1
- package/dist/components/CuiToggleGroup.vue.js +2 -2
- package/dist/components/CuiToggleGroup.vue2.js +45 -35
- package/dist/components/CuiTooltip.vue.d.ts.map +1 -1
- package/dist/components/CuiTooltip.vue.js +2 -2
- package/dist/components/CuiTooltip.vue2.js +49 -45
- package/dist/components/CuiTransferList.vue.d.ts.map +1 -1
- package/dist/components/CuiTransferList.vue.js +31 -30
- package/dist/components/CuiTreeNode.vue.d.ts +9 -2
- package/dist/components/CuiTreeNode.vue.d.ts.map +1 -1
- package/dist/components/CuiTreeNode.vue.js +5 -179
- package/dist/components/CuiTreeNode.vue2.js +198 -2
- package/dist/components/CuiTreeView.vue.d.ts +33 -5
- package/dist/components/CuiTreeView.vue.d.ts.map +1 -1
- package/dist/components/CuiTreeView.vue.js +187 -44
- package/dist/composables/useCalendarKeyboard.d.ts +48 -0
- package/dist/composables/useCalendarKeyboard.d.ts.map +1 -0
- package/dist/composables/useCalendarKeyboard.js +91 -0
- package/dist/composables/useFieldDescribedBy.d.ts +30 -0
- package/dist/composables/useFieldDescribedBy.d.ts.map +1 -0
- package/dist/composables/useFieldDescribedBy.js +11 -0
- package/dist/composables/useMessages.d.ts.map +1 -1
- package/dist/composables/useMessages.js +6 -6
- package/dist/composables/usePopover.d.ts.map +1 -1
- package/dist/composables/usePopover.js +10 -0
- package/dist/composables/useScrollShadows.d.ts +3 -0
- package/dist/composables/useScrollShadows.d.ts.map +1 -1
- package/dist/composables/useScrollShadows.js +15 -12
- package/dist/icons/builtin.d.ts.map +1 -1
- package/dist/icons/builtin.js +38 -37
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +185 -182
- package/dist/messages.d.ts +39 -4
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +8 -7
- package/dist/types/common.d.ts +90 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/utils/colorIconMap.d.ts +47 -3
- package/dist/utils/colorIconMap.d.ts.map +1 -1
- package/dist/utils/colorIconMap.js +20 -5
- package/dist/utils/date.d.ts +13 -0
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js +46 -40
- package/dist/utils/sizing.d.ts +26 -1
- package/dist/utils/sizing.d.ts.map +1 -1
- package/dist/utils/sizing.js +22 -21
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,332 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { useMessages as we } from "../composables/useMessages.js";
|
|
6
|
-
import Z from "./CuiSpinner.vue.js";
|
|
7
|
-
/* empty css */
|
|
8
|
-
const ke = {
|
|
9
|
-
key: 0,
|
|
10
|
-
style: { display: "block", marginBottom: "calc(0.25rem * var(--cui-density-scale, 1))", fontSize: "0.875rem", fontWeight: "500", color: "var(--cui-text-secondary)" }
|
|
11
|
-
}, Se = ["src"], ze = ["value", "placeholder", "disabled"], $e = { style: { display: "flex", alignItems: "center", gap: "calc(0.25rem * var(--cui-density-scale, 1))", flexShrink: "0" } }, Ce = {
|
|
12
|
-
key: 1,
|
|
13
|
-
style: { fontSize: "0.75rem", color: "var(--cui-error)", marginTop: "calc(0.25rem * var(--cui-density-scale, 1))" }
|
|
14
|
-
}, Re = {
|
|
15
|
-
key: 0,
|
|
16
|
-
style: { padding: "calc(1rem * var(--cui-density-scale, 1))", textAlign: "center" }
|
|
17
|
-
}, Oe = {
|
|
18
|
-
key: 1,
|
|
19
|
-
style: { padding: "calc(0.75rem * var(--cui-density-scale, 1))", textAlign: "center", fontSize: "0.8125rem", color: "var(--cui-text-tertiary)" }
|
|
20
|
-
}, Te = {
|
|
21
|
-
key: 2,
|
|
22
|
-
style: { padding: "calc(0.75rem * var(--cui-density-scale, 1))", textAlign: "center", fontSize: "0.8125rem", color: "var(--cui-text-tertiary)" }
|
|
23
|
-
}, Ve = ["data-index", "onClick", "onMouseenter"], Be = ["src"], Me = { style: { flex: "1", minWidth: "0" } }, De = {
|
|
24
|
-
key: 0,
|
|
25
|
-
style: { fontSize: "0.75rem", color: "var(--cui-text-tertiary)", lineHeight: "1.3", marginTop: "calc(0.0625rem * var(--cui-density-scale, 1))" }
|
|
26
|
-
}, Ne = /* @__PURE__ */ ue({
|
|
27
|
-
__name: "CuiCombobox",
|
|
28
|
-
props: {
|
|
29
|
-
modelValue: {},
|
|
30
|
-
options: { default: () => [] },
|
|
31
|
-
multiple: { type: Boolean, default: !1 },
|
|
32
|
-
placeholder: { default: "Search..." },
|
|
33
|
-
fetchOptions: {},
|
|
34
|
-
debounce: { default: 300 },
|
|
35
|
-
minChars: { default: 0 },
|
|
36
|
-
maxVisible: { default: 8 },
|
|
37
|
-
loading: { type: Boolean, default: !1 },
|
|
38
|
-
label: {},
|
|
39
|
-
error: { type: Boolean, default: !1 },
|
|
40
|
-
errorMessage: {},
|
|
41
|
-
noResultsText: { default: "No results found" },
|
|
42
|
-
rounded: { default: "md" },
|
|
43
|
-
hidden: { type: Boolean, default: !1 },
|
|
44
|
-
color: { default: "primary" },
|
|
45
|
-
size: { default: "md" },
|
|
46
|
-
disabled: { type: Boolean, default: !1 }
|
|
47
|
-
},
|
|
48
|
-
emits: ["update:modelValue", "search"],
|
|
49
|
-
setup(l, { expose: G, emit: J }) {
|
|
50
|
-
const r = l, Q = {
|
|
51
|
-
none: "0",
|
|
52
|
-
sm: "0.25rem",
|
|
53
|
-
md: "var(--cui-button-radius, 0.375rem)",
|
|
54
|
-
lg: "0.5rem",
|
|
55
|
-
full: "9999px"
|
|
56
|
-
}, R = J, u = v(""), c = v(!1), d = v(-1), B = v(!1), O = v([]), f = v(null), M = v(null), S = v(null), I = v({});
|
|
57
|
-
let z = null;
|
|
58
|
-
const g = w(() => r.modelValue == null ? /* @__PURE__ */ new Set() : Array.isArray(r.modelValue) ? new Set(r.modelValue) : /* @__PURE__ */ new Set([r.modelValue])), $ = v([]);
|
|
59
|
-
L(() => r.options, (e) => {
|
|
60
|
-
for (const a of e)
|
|
61
|
-
$.value.find((t) => t.value === a.value) || $.value.push(a);
|
|
62
|
-
}, { immediate: !0 }), L(O, (e) => {
|
|
63
|
-
for (const a of e)
|
|
64
|
-
$.value.find((t) => t.value === a.value) || $.value.push(a);
|
|
65
|
-
});
|
|
66
|
-
const y = w(
|
|
67
|
-
() => [...g.value].map((e) => $.value.find((a) => a.value === e)).filter(Boolean)
|
|
68
|
-
), h = w(() => {
|
|
69
|
-
const e = r.fetchOptions ? O.value : r.options;
|
|
70
|
-
if (!u.value || r.fetchOptions) return e;
|
|
71
|
-
const a = u.value.toLowerCase();
|
|
72
|
-
return e.filter(
|
|
73
|
-
(t) => t.label.toLowerCase().includes(a) || t.description && t.description.toLowerCase().includes(a)
|
|
74
|
-
);
|
|
75
|
-
}), P = w(() => r.loading || B.value), X = ["sm", "md", "lg"], _ = {
|
|
76
|
-
sm: { fontSize: "0.8125rem", padding: `${o("0.25rem")} ${o("0.5rem")}`, tagSize: "sm", itemPadding: `${o("0.375rem")} ${o("0.625rem")}`, inputHeight: o("2rem") },
|
|
77
|
-
md: { fontSize: "0.875rem", padding: `${o("0.3125rem")} ${o("0.625rem")}`, tagSize: "sm", itemPadding: `${o("0.5rem")} ${o("0.75rem")}`, inputHeight: o("2.375rem") },
|
|
78
|
-
lg: { fontSize: "0.9375rem", padding: `${o("0.4375rem")} ${o("0.75rem")}`, tagSize: "md", itemPadding: `${o("0.625rem")} ${o("0.875rem")}`, inputHeight: o("2.75rem") }
|
|
79
|
-
}, x = w(() => _[be(r.size, X)]);
|
|
80
|
-
function T() {
|
|
81
|
-
if (!S.value) return;
|
|
82
|
-
const e = S.value.getBoundingClientRect(), a = window.innerHeight, t = a - e.bottom, i = e.top, E = Math.min(320, Math.max(t, i) - 16), oe = t < 200 && i > t, H = {
|
|
83
|
-
position: "fixed",
|
|
84
|
-
zIndex: "9990",
|
|
85
|
-
left: `${e.left}px`,
|
|
86
|
-
width: `${e.width}px`,
|
|
87
|
-
maxHeight: `${E}px`,
|
|
88
|
-
overflowY: "auto",
|
|
89
|
-
background: "var(--cui-surface-base)",
|
|
90
|
-
border: "1px solid var(--cui-border)",
|
|
91
|
-
borderRadius: "0.5rem",
|
|
92
|
-
boxShadow: "0 8px 24px -4px rgba(0,0,0,0.12), 0 2px 8px -2px rgba(0,0,0,0.08)",
|
|
93
|
-
padding: "calc(0.25rem * var(--cui-density-scale, 1))"
|
|
94
|
-
};
|
|
95
|
-
oe ? H.bottom = `${a - e.top + 4}px` : H.top = `${e.bottom + 4}px`, I.value = H;
|
|
96
|
-
}
|
|
97
|
-
function ee(e) {
|
|
98
|
-
if (u.value = e.target.value, d.value = -1, c.value || D(), R("search", u.value), r.fetchOptions) {
|
|
99
|
-
if (u.value.length < r.minChars) {
|
|
100
|
-
O.value = [];
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
z && clearTimeout(z), z = setTimeout(async () => {
|
|
104
|
-
B.value = !0;
|
|
105
|
-
try {
|
|
106
|
-
O.value = await r.fetchOptions(u.value);
|
|
107
|
-
} finally {
|
|
108
|
-
B.value = !1;
|
|
109
|
-
}
|
|
110
|
-
}, r.debounce);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function F(e) {
|
|
114
|
-
var a;
|
|
115
|
-
if (!e.disabled)
|
|
116
|
-
if (r.multiple) {
|
|
117
|
-
const t = new Set(g.value);
|
|
118
|
-
t.has(e.value) ? t.delete(e.value) : t.add(e.value), R("update:modelValue", [...t]), u.value = "", V(() => {
|
|
119
|
-
var i;
|
|
120
|
-
return (i = f.value) == null ? void 0 : i.focus();
|
|
121
|
-
});
|
|
122
|
-
} else
|
|
123
|
-
R("update:modelValue", e.value), u.value = "", c.value = !1, (a = f.value) == null || a.blur();
|
|
124
|
-
}
|
|
125
|
-
function N(e) {
|
|
126
|
-
if (r.disabled) return;
|
|
127
|
-
const a = [...g.value];
|
|
128
|
-
R("update:modelValue", a.filter((t) => t !== e)), V(() => {
|
|
129
|
-
var t;
|
|
130
|
-
return (t = f.value) == null ? void 0 : t.focus();
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
function te(e) {
|
|
134
|
-
if (e.key === "ArrowDown") {
|
|
135
|
-
if (e.preventDefault(), !c.value) {
|
|
136
|
-
D();
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
d.value = Math.min(d.value + 1, h.value.length - 1), W();
|
|
140
|
-
} else e.key === "ArrowUp" ? (e.preventDefault(), d.value = Math.max(d.value - 1, 0), W()) : e.key === "Enter" ? (e.preventDefault(), d.value >= 0 && d.value < h.value.length && F(h.value[d.value])) : e.key === "Escape" ? c.value = !1 : e.key === "Backspace" && !u.value && r.multiple && y.value.length > 0 && N(y.value[y.value.length - 1].value);
|
|
141
|
-
}
|
|
142
|
-
function W() {
|
|
143
|
-
V(() => {
|
|
144
|
-
var e, a;
|
|
145
|
-
(a = (e = M.value) == null ? void 0 : e.querySelector(`[data-index="${d.value}"]`)) == null || a.scrollIntoView({ block: "nearest" });
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function D() {
|
|
149
|
-
r.disabled || (c.value = !0, T());
|
|
150
|
-
}
|
|
151
|
-
function ae() {
|
|
152
|
-
D();
|
|
153
|
-
}
|
|
154
|
-
function q(e) {
|
|
155
|
-
var t, i;
|
|
156
|
-
const a = e.target;
|
|
157
|
-
(t = S.value) != null && t.contains(a) || (i = M.value) != null && i.contains(a) || (c.value = !1);
|
|
158
|
-
}
|
|
159
|
-
se(() => {
|
|
160
|
-
document.addEventListener("mousedown", q), window.addEventListener("scroll", () => {
|
|
161
|
-
c.value && T();
|
|
162
|
-
}, !0), window.addEventListener("resize", () => {
|
|
163
|
-
c.value && T();
|
|
164
|
-
});
|
|
165
|
-
}), ce(() => {
|
|
166
|
-
document.removeEventListener("mousedown", q), z && clearTimeout(z);
|
|
167
|
-
});
|
|
168
|
-
const le = w(() => r.multiple ? "" : y.value.length > 0 ? y.value[0].label : "");
|
|
169
|
-
L(c, (e) => {
|
|
170
|
-
e || (u.value = ""), e && V(T);
|
|
171
|
-
});
|
|
172
|
-
function re(e) {
|
|
173
|
-
var a;
|
|
174
|
-
(a = f.value) == null || a.focus(e);
|
|
175
|
-
}
|
|
176
|
-
function ne() {
|
|
177
|
-
var e;
|
|
178
|
-
(e = f.value) == null || e.blur();
|
|
179
|
-
}
|
|
180
|
-
G({ el: S, focus: re, blur: ne });
|
|
181
|
-
function ie(e, a) {
|
|
182
|
-
const t = g.value.has(a.value), i = d.value === e;
|
|
183
|
-
return {
|
|
184
|
-
display: "flex",
|
|
185
|
-
alignItems: "center",
|
|
186
|
-
gap: "calc(0.5rem * var(--cui-density-scale, 1))",
|
|
187
|
-
padding: x.value.itemPadding,
|
|
188
|
-
cursor: a.disabled ? "default" : "pointer",
|
|
189
|
-
fontSize: x.value.fontSize,
|
|
190
|
-
color: a.disabled ? "var(--cui-text-tertiary)" : "var(--cui-text-body)",
|
|
191
|
-
opacity: a.disabled ? "0.5" : "1",
|
|
192
|
-
background: i ? "var(--cui-primary-bg)" : t ? "color-mix(in srgb, var(--cui-primary-bg) 50%, transparent)" : "transparent",
|
|
193
|
-
transition: "background 0.1s ease",
|
|
194
|
-
borderRadius: "0.25rem"
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
const U = we();
|
|
198
|
-
return (e, a) => de((n(), s("div", {
|
|
199
|
-
ref_key: "wrapperRef",
|
|
200
|
-
ref: S,
|
|
201
|
-
style: { position: "relative" }
|
|
202
|
-
}, [
|
|
203
|
-
l.label ? (n(), s("label", ke, p(l.label), 1)) : m("", !0),
|
|
204
|
-
C("div", {
|
|
205
|
-
style: b({
|
|
206
|
-
display: "flex",
|
|
207
|
-
flexWrap: "wrap",
|
|
208
|
-
alignItems: "center",
|
|
209
|
-
gap: "calc(0.25rem * var(--cui-density-scale, 1))",
|
|
210
|
-
padding: x.value.padding,
|
|
211
|
-
border: `1px solid ${l.error ? "var(--cui-error)" : "var(--cui-border-strong, var(--cui-border))"}`,
|
|
212
|
-
borderRadius: Q[l.rounded],
|
|
213
|
-
background: "var(--cui-surface-base, white)",
|
|
214
|
-
cursor: l.disabled ? "default" : "text",
|
|
215
|
-
opacity: l.disabled ? "0.5" : "1",
|
|
216
|
-
minHeight: x.value.inputHeight
|
|
217
|
-
}),
|
|
218
|
-
onClick: a[0] || (a[0] = (t) => {
|
|
219
|
-
var i;
|
|
220
|
-
return (i = f.value) == null ? void 0 : i.focus();
|
|
221
|
-
})
|
|
222
|
-
}, [
|
|
223
|
-
(n(!0), s(j, null, K(l.multiple ? y.value : [], (t) => (n(), k(xe, {
|
|
224
|
-
key: String(t.value),
|
|
225
|
-
color: l.color,
|
|
226
|
-
size: x.value.tagSize,
|
|
227
|
-
removable: "",
|
|
228
|
-
onRemove: (i) => N(t.value)
|
|
229
|
-
}, {
|
|
230
|
-
default: ve(() => [
|
|
231
|
-
t.image ? (n(), s("img", {
|
|
232
|
-
key: 0,
|
|
233
|
-
src: t.image,
|
|
234
|
-
style: { width: "1rem", height: "1rem", borderRadius: "50%", objectFit: "cover", marginRight: "calc(0.125rem * var(--cui-density-scale, 1))" }
|
|
235
|
-
}, null, 8, Se)) : m("", !0),
|
|
236
|
-
me(" " + p(t.label), 1)
|
|
237
|
-
]),
|
|
238
|
-
_: 2
|
|
239
|
-
}, 1032, ["color", "size", "onRemove"]))), 128)),
|
|
240
|
-
C("input", {
|
|
241
|
-
ref_key: "inputRef",
|
|
242
|
-
ref: f,
|
|
243
|
-
value: c.value ? u.value : le.value,
|
|
244
|
-
placeholder: y.value.length > 0 ? "" : l.placeholder,
|
|
245
|
-
disabled: l.disabled,
|
|
246
|
-
style: b({
|
|
247
|
-
flex: "1",
|
|
248
|
-
minWidth: "4rem",
|
|
249
|
-
border: "none",
|
|
250
|
-
outline: "none",
|
|
251
|
-
background: "transparent",
|
|
252
|
-
fontSize: x.value.fontSize,
|
|
253
|
-
color: "var(--cui-text-body)",
|
|
254
|
-
padding: "calc(0.125rem * var(--cui-density-scale, 1)) 0",
|
|
255
|
-
fontFamily: "inherit"
|
|
256
|
-
}),
|
|
257
|
-
onInput: ee,
|
|
258
|
-
onFocus: ae,
|
|
259
|
-
onKeydown: te
|
|
260
|
-
}, null, 44, ze),
|
|
261
|
-
C("div", $e, [
|
|
262
|
-
P.value ? (n(), k(Z, {
|
|
263
|
-
key: 0,
|
|
264
|
-
size: "xs"
|
|
265
|
-
})) : (n(), k(A, {
|
|
266
|
-
key: 1,
|
|
267
|
-
name: "caret-down",
|
|
268
|
-
size: "0.875rem",
|
|
269
|
-
style: b({ color: "var(--cui-text-tertiary)", transform: c.value ? "rotate(180deg)" : "none", transition: "transform 0.15s ease" })
|
|
270
|
-
}, null, 8, ["style"]))
|
|
271
|
-
])
|
|
272
|
-
], 4),
|
|
273
|
-
l.error && l.errorMessage ? (n(), s("div", Ce, p(l.errorMessage), 1)) : m("", !0),
|
|
274
|
-
(n(), k(fe, { to: "body" }, [
|
|
275
|
-
c.value ? (n(), s("div", {
|
|
276
|
-
key: 0,
|
|
277
|
-
ref_key: "dropdownRef",
|
|
278
|
-
ref: M,
|
|
279
|
-
style: b(I.value)
|
|
280
|
-
}, [
|
|
281
|
-
P.value && h.value.length === 0 ? (n(), s("div", Re, [
|
|
282
|
-
ge(Z, {
|
|
283
|
-
size: "sm",
|
|
284
|
-
"show-label": "",
|
|
285
|
-
label: Y(U).combobox.searching
|
|
286
|
-
}, null, 8, ["label"])
|
|
287
|
-
])) : h.value.length === 0 && (u.value.length >= l.minChars || !l.fetchOptions) ? (n(), s("div", Oe, p(l.noResultsText), 1)) : h.value.length === 0 && l.fetchOptions && u.value.length < l.minChars ? (n(), s("div", Te, p(Y(U).combobox.typeMore(l.minChars - u.value.length)), 1)) : m("", !0),
|
|
288
|
-
(n(!0), s(j, null, K(h.value, (t, i) => (n(), s("div", {
|
|
289
|
-
key: String(t.value),
|
|
290
|
-
"data-index": i,
|
|
291
|
-
style: b(ie(i, t)),
|
|
292
|
-
onClick: ye((E) => F(t), ["stop"]),
|
|
293
|
-
onMouseenter: (E) => d.value = i
|
|
294
|
-
}, [
|
|
295
|
-
he(e.$slots, "option", {
|
|
296
|
-
option: t,
|
|
297
|
-
selected: g.value.has(t.value)
|
|
298
|
-
}, () => [
|
|
299
|
-
t.image ? (n(), s("img", {
|
|
300
|
-
key: 0,
|
|
301
|
-
src: t.image,
|
|
302
|
-
style: { width: "1.75rem", height: "1.75rem", borderRadius: "50%", objectFit: "cover", flexShrink: "0" }
|
|
303
|
-
}, null, 8, Be)) : t.icon ? (n(), k(A, {
|
|
304
|
-
key: 1,
|
|
305
|
-
name: t.icon,
|
|
306
|
-
size: "1rem",
|
|
307
|
-
style: { flexShrink: "0", color: "var(--cui-text-secondary)" }
|
|
308
|
-
}, null, 8, ["name"])) : m("", !0),
|
|
309
|
-
C("div", Me, [
|
|
310
|
-
C("div", {
|
|
311
|
-
style: b({ lineHeight: "1.3", fontWeight: g.value.has(t.value) ? "600" : "400" })
|
|
312
|
-
}, p(t.label), 5),
|
|
313
|
-
t.description ? (n(), s("div", De, p(t.description), 1)) : m("", !0)
|
|
314
|
-
]),
|
|
315
|
-
g.value.has(t.value) ? (n(), k(A, {
|
|
316
|
-
key: 2,
|
|
317
|
-
name: "check",
|
|
318
|
-
size: "0.875rem",
|
|
319
|
-
style: b({ color: `var(--cui-${l.color})`, flexShrink: "0" })
|
|
320
|
-
}, null, 8, ["style"])) : m("", !0)
|
|
321
|
-
])
|
|
322
|
-
], 44, Ve))), 128))
|
|
323
|
-
], 4)) : m("", !0)
|
|
324
|
-
]))
|
|
325
|
-
], 512)), [
|
|
326
|
-
[pe, !l.hidden]
|
|
327
|
-
]);
|
|
328
|
-
}
|
|
329
|
-
});
|
|
1
|
+
import o from "./CuiCombobox.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import t from "../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-a05525e3"]]);
|
|
330
5
|
export {
|
|
331
|
-
|
|
6
|
+
p as default
|
|
332
7
|
};
|
|
@@ -1,4 +1,332 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { defineComponent as me, ref as d, computed as g, watch as I, onMounted as fe, onUnmounted as be, nextTick as O, withDirectives as ye, openBlock as r, createElementBlock as u, normalizeStyle as x, toDisplayString as h, createCommentVNode as v, createElementVNode as S, normalizeClass as Y, Fragment as Z, renderList as G, createBlock as w, withCtx as he, createTextVNode as ge, unref as L, Teleport as xe, createVNode as we, withModifiers as pe, renderSlot as ke, vShow as Se } from "vue";
|
|
2
|
+
import { INPUT_SIZE_SCALE as ze, scaleDensity as J, nestedSize as Ce } from "../utils/sizing.js";
|
|
3
|
+
import { useFieldDescribedBy as Re } from "../composables/useFieldDescribedBy.js";
|
|
4
|
+
import q from "./CuiIcon.vue.js";
|
|
5
|
+
import $e from "./CuiBadge.vue.js";
|
|
6
|
+
import { useMessages as Be } from "../composables/useMessages.js";
|
|
7
|
+
import Q from "./CuiSpinner.vue.js";
|
|
8
|
+
/* empty css */
|
|
9
|
+
const Oe = {
|
|
10
|
+
key: 0,
|
|
11
|
+
style: { display: "block", marginBottom: "calc(0.25rem * var(--cui-density-scale, 1))", fontSize: "0.875rem", fontWeight: "500", color: "var(--cui-text-secondary)" }
|
|
12
|
+
}, Le = ["src"], Te = ["id", "name", "autocomplete", "aria-describedby", "aria-required", "aria-labelledby", "value", "placeholder", "disabled"], Ve = { style: { display: "flex", alignItems: "center", gap: "calc(0.25rem * var(--cui-density-scale, 1))", flexShrink: "0" } }, Me = ["id"], Ee = {
|
|
13
|
+
key: 0,
|
|
14
|
+
style: { padding: "calc(1rem * var(--cui-density-scale, 1))", textAlign: "center" }
|
|
15
|
+
}, De = {
|
|
16
|
+
key: 1,
|
|
17
|
+
style: { padding: "calc(0.75rem * var(--cui-density-scale, 1))", textAlign: "center", fontSize: "0.8125rem", color: "var(--cui-text-tertiary)" }
|
|
18
|
+
}, Ae = {
|
|
19
|
+
key: 2,
|
|
20
|
+
style: { padding: "calc(0.75rem * var(--cui-density-scale, 1))", textAlign: "center", fontSize: "0.8125rem", color: "var(--cui-text-tertiary)" }
|
|
21
|
+
}, Ie = ["data-index", "onClick", "onMouseenter"], qe = ["src"], Fe = { style: { flex: "1", minWidth: "0" } }, He = {
|
|
22
|
+
key: 0,
|
|
23
|
+
style: { fontSize: "0.75rem", color: "var(--cui-text-tertiary)", lineHeight: "1.3", marginTop: "calc(0.0625rem * var(--cui-density-scale, 1))" }
|
|
24
|
+
}, Ze = /* @__PURE__ */ me({
|
|
25
|
+
__name: "CuiCombobox",
|
|
26
|
+
props: {
|
|
27
|
+
modelValue: {},
|
|
28
|
+
options: { default: () => [] },
|
|
29
|
+
multiple: { type: Boolean, default: !1 },
|
|
30
|
+
placeholder: { default: "Search..." },
|
|
31
|
+
fetchOptions: {},
|
|
32
|
+
debounce: { default: 300 },
|
|
33
|
+
minChars: { default: 0 },
|
|
34
|
+
maxVisible: { default: 8 },
|
|
35
|
+
loading: { type: Boolean, default: !1 },
|
|
36
|
+
label: {},
|
|
37
|
+
error: { type: Boolean, default: !1 },
|
|
38
|
+
errorMessage: {},
|
|
39
|
+
noResultsText: { default: "No results found" },
|
|
40
|
+
rounded: { default: "md" },
|
|
41
|
+
name: {},
|
|
42
|
+
autocomplete: {},
|
|
43
|
+
id: {},
|
|
44
|
+
ariaDescribedby: {},
|
|
45
|
+
ariaLabelledby: {},
|
|
46
|
+
ariaRequired: { type: Boolean },
|
|
47
|
+
hidden: { type: Boolean, default: !1 },
|
|
48
|
+
color: { default: "primary" },
|
|
49
|
+
size: { default: "md" },
|
|
50
|
+
disabled: { type: Boolean, default: !1 }
|
|
51
|
+
},
|
|
52
|
+
emits: ["update:modelValue", "search"],
|
|
53
|
+
setup(a, { expose: X, emit: ee }) {
|
|
54
|
+
const o = a, { errorId: te, describedBy: le } = Re(o), ae = {
|
|
55
|
+
none: "0",
|
|
56
|
+
sm: "var(--cui-radius-sm, 0.25rem)",
|
|
57
|
+
md: "var(--cui-button-radius, var(--cui-radius-md, 0.375rem))",
|
|
58
|
+
lg: "var(--cui-radius-lg, 0.5rem)",
|
|
59
|
+
full: "9999px"
|
|
60
|
+
}, z = ee, n = d(""), s = d(!1), c = d(-1), T = d(!1), C = d([]), m = d(null), V = d(null), R = d(null), F = d(null), H = d({});
|
|
61
|
+
let p = null;
|
|
62
|
+
const f = g(() => o.modelValue == null ? /* @__PURE__ */ new Set() : Array.isArray(o.modelValue) ? new Set(o.modelValue) : /* @__PURE__ */ new Set([o.modelValue])), k = d([]);
|
|
63
|
+
I(() => o.options, (e) => {
|
|
64
|
+
for (const l of e)
|
|
65
|
+
k.value.find((t) => t.value === l.value) || k.value.push(l);
|
|
66
|
+
}, { immediate: !0 }), I(C, (e) => {
|
|
67
|
+
for (const l of e)
|
|
68
|
+
k.value.find((t) => t.value === l.value) || k.value.push(l);
|
|
69
|
+
});
|
|
70
|
+
const b = g(
|
|
71
|
+
() => [...f.value].map((e) => k.value.find((l) => l.value === e)).filter(Boolean)
|
|
72
|
+
), y = g(() => {
|
|
73
|
+
const e = o.fetchOptions ? C.value : o.options;
|
|
74
|
+
if (!n.value || o.fetchOptions) return e;
|
|
75
|
+
const l = n.value.toLowerCase();
|
|
76
|
+
return e.filter(
|
|
77
|
+
(t) => t.label.toLowerCase().includes(l) || t.description && t.description.toLowerCase().includes(l)
|
|
78
|
+
);
|
|
79
|
+
}), N = g(() => o.loading || T.value), oe = J("0.25rem"), M = g(() => {
|
|
80
|
+
const e = ze[o.size];
|
|
81
|
+
return {
|
|
82
|
+
tagSize: Ce(o.size),
|
|
83
|
+
style: {
|
|
84
|
+
"--_combobox-font-size": e.fontSize,
|
|
85
|
+
"--_combobox-padding": `${oe} ${e.px}`,
|
|
86
|
+
"--_combobox-item-padding": `${J("0.5rem")} ${e.px}`,
|
|
87
|
+
"--_combobox-min-height": e.height
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
function E() {
|
|
92
|
+
const e = F.value ?? R.value;
|
|
93
|
+
if (!e) return;
|
|
94
|
+
const l = e.getBoundingClientRect(), t = window.innerHeight, i = t - l.bottom, B = l.top, K = i < 200 && B > i, ve = Math.max(0, Math.min(320, (K ? B : i) - 16)), A = {
|
|
95
|
+
// The panel is teleported to <body>, so it inherits nothing from the component — it
|
|
96
|
+
// has to carry the size-derived properties itself (#123).
|
|
97
|
+
...M.value.style,
|
|
98
|
+
position: "fixed",
|
|
99
|
+
zIndex: "9990",
|
|
100
|
+
left: `${l.left}px`,
|
|
101
|
+
width: `${l.width}px`,
|
|
102
|
+
maxHeight: `${ve}px`
|
|
103
|
+
// Only the geometry the positioner computes stays inline; the panel's paint lives in
|
|
104
|
+
// the stylesheet so it can be themed (#123).
|
|
105
|
+
};
|
|
106
|
+
K ? A.bottom = `${t - l.top + 4}px` : A.top = `${l.bottom + 4}px`, H.value = A;
|
|
107
|
+
}
|
|
108
|
+
function re(e) {
|
|
109
|
+
if (n.value = e.target.value, c.value = -1, s.value || D(), z("search", n.value), o.fetchOptions) {
|
|
110
|
+
if (n.value.length < o.minChars) {
|
|
111
|
+
C.value = [];
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
p && clearTimeout(p), p = setTimeout(async () => {
|
|
115
|
+
T.value = !0;
|
|
116
|
+
try {
|
|
117
|
+
C.value = await o.fetchOptions(n.value);
|
|
118
|
+
} finally {
|
|
119
|
+
T.value = !1;
|
|
120
|
+
}
|
|
121
|
+
}, o.debounce);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function P(e) {
|
|
125
|
+
var l;
|
|
126
|
+
if (!e.disabled)
|
|
127
|
+
if (o.multiple) {
|
|
128
|
+
const t = new Set(f.value);
|
|
129
|
+
t.has(e.value) ? t.delete(e.value) : t.add(e.value), z("update:modelValue", [...t]), n.value = "", O(() => {
|
|
130
|
+
var i;
|
|
131
|
+
return (i = m.value) == null ? void 0 : i.focus();
|
|
132
|
+
});
|
|
133
|
+
} else
|
|
134
|
+
z("update:modelValue", e.value), n.value = "", s.value = !1, (l = m.value) == null || l.blur();
|
|
135
|
+
}
|
|
136
|
+
function W(e) {
|
|
137
|
+
if (o.disabled) return;
|
|
138
|
+
const l = [...f.value];
|
|
139
|
+
z("update:modelValue", l.filter((t) => t !== e)), O(() => {
|
|
140
|
+
var t;
|
|
141
|
+
return (t = m.value) == null ? void 0 : t.focus();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function ie(e) {
|
|
145
|
+
if (e.key === "ArrowDown") {
|
|
146
|
+
if (e.preventDefault(), !s.value) {
|
|
147
|
+
D();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
c.value = Math.min(c.value + 1, y.value.length - 1), _();
|
|
151
|
+
} else e.key === "ArrowUp" ? (e.preventDefault(), c.value = Math.max(c.value - 1, 0), _()) : e.key === "Enter" ? (e.preventDefault(), c.value >= 0 && c.value < y.value.length && P(y.value[c.value])) : e.key === "Escape" ? s.value = !1 : e.key === "Backspace" && !n.value && o.multiple && b.value.length > 0 && W(b.value[b.value.length - 1].value);
|
|
152
|
+
}
|
|
153
|
+
function _() {
|
|
154
|
+
O(() => {
|
|
155
|
+
var e, l;
|
|
156
|
+
(l = (e = V.value) == null ? void 0 : e.querySelector(`[data-index="${c.value}"]`)) == null || l.scrollIntoView({ block: "nearest" });
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function D() {
|
|
160
|
+
o.disabled || (s.value = !0, E());
|
|
161
|
+
}
|
|
162
|
+
function ne() {
|
|
163
|
+
D();
|
|
164
|
+
}
|
|
165
|
+
function U(e) {
|
|
166
|
+
var t, i;
|
|
167
|
+
const l = e.target;
|
|
168
|
+
(t = R.value) != null && t.contains(l) || (i = V.value) != null && i.contains(l) || (s.value = !1);
|
|
169
|
+
}
|
|
170
|
+
function $() {
|
|
171
|
+
s.value && E();
|
|
172
|
+
}
|
|
173
|
+
fe(() => {
|
|
174
|
+
document.addEventListener("mousedown", U), window.addEventListener("scroll", $, !0), window.addEventListener("resize", $);
|
|
175
|
+
}), be(() => {
|
|
176
|
+
document.removeEventListener("mousedown", U), window.removeEventListener("scroll", $, !0), window.removeEventListener("resize", $), p && clearTimeout(p);
|
|
177
|
+
});
|
|
178
|
+
const ue = g(() => o.multiple ? "" : b.value.length > 0 ? b.value[0].label : "");
|
|
179
|
+
I(s, (e) => {
|
|
180
|
+
e || (n.value = ""), e && O(E);
|
|
181
|
+
});
|
|
182
|
+
function se(e) {
|
|
183
|
+
var l;
|
|
184
|
+
(l = m.value) == null || l.focus(e);
|
|
185
|
+
}
|
|
186
|
+
function ce() {
|
|
187
|
+
var e;
|
|
188
|
+
(e = m.value) == null || e.blur();
|
|
189
|
+
}
|
|
190
|
+
X({ el: R, focus: se, blur: ce });
|
|
191
|
+
function de(e, l) {
|
|
192
|
+
return {
|
|
193
|
+
"cui-combobox__option": !0,
|
|
194
|
+
"cui-combobox__option--focused": c.value === e,
|
|
195
|
+
"cui-combobox__option--selected": f.value.has(l.value),
|
|
196
|
+
"cui-combobox__option--disabled": !!l.disabled
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const j = Be();
|
|
200
|
+
return (e, l) => ye((r(), u("div", {
|
|
201
|
+
class: "cui-combobox",
|
|
202
|
+
ref_key: "wrapperRef",
|
|
203
|
+
ref: R,
|
|
204
|
+
style: x(M.value.style)
|
|
205
|
+
}, [
|
|
206
|
+
a.label ? (r(), u("label", Oe, h(a.label), 1)) : v("", !0),
|
|
207
|
+
S("div", {
|
|
208
|
+
ref_key: "controlRef",
|
|
209
|
+
ref: F,
|
|
210
|
+
class: Y(["cui-combobox__control", { "cui-combobox__control--disabled": a.disabled }]),
|
|
211
|
+
style: x({
|
|
212
|
+
"--_combobox-radius": ae[a.rounded],
|
|
213
|
+
"--_combobox-border": a.error ? "var(--cui-error)" : "var(--cui-border-strong, var(--cui-border))",
|
|
214
|
+
"--_combobox-focus-ring": a.error ? "var(--cui-error-focus-ring)" : `var(--cui-${a.color}-focus-ring)`,
|
|
215
|
+
"--_combobox-focus-border": a.error ? "var(--cui-error)" : `var(--cui-${a.color})`
|
|
216
|
+
}),
|
|
217
|
+
onClick: l[0] || (l[0] = (t) => {
|
|
218
|
+
var i;
|
|
219
|
+
return (i = m.value) == null ? void 0 : i.focus();
|
|
220
|
+
})
|
|
221
|
+
}, [
|
|
222
|
+
(r(!0), u(Z, null, G(a.multiple ? b.value : [], (t) => (r(), w($e, {
|
|
223
|
+
key: String(t.value),
|
|
224
|
+
color: a.color,
|
|
225
|
+
size: M.value.tagSize,
|
|
226
|
+
removable: "",
|
|
227
|
+
onRemove: (i) => W(t.value)
|
|
228
|
+
}, {
|
|
229
|
+
default: he(() => [
|
|
230
|
+
t.image ? (r(), u("img", {
|
|
231
|
+
key: 0,
|
|
232
|
+
src: t.image,
|
|
233
|
+
style: { width: "1rem", height: "1rem", borderRadius: "50%", objectFit: "cover", marginRight: "calc(0.125rem * var(--cui-density-scale, 1))" }
|
|
234
|
+
}, null, 8, Le)) : v("", !0),
|
|
235
|
+
ge(" " + h(t.label), 1)
|
|
236
|
+
]),
|
|
237
|
+
_: 2
|
|
238
|
+
}, 1032, ["color", "size", "onRemove"]))), 128)),
|
|
239
|
+
S("input", {
|
|
240
|
+
ref_key: "inputRef",
|
|
241
|
+
ref: m,
|
|
242
|
+
id: a.id,
|
|
243
|
+
name: a.name,
|
|
244
|
+
autocomplete: a.autocomplete,
|
|
245
|
+
"aria-describedby": L(le),
|
|
246
|
+
"aria-required": a.ariaRequired || void 0,
|
|
247
|
+
"aria-labelledby": a.ariaLabelledby,
|
|
248
|
+
value: s.value ? n.value : ue.value,
|
|
249
|
+
placeholder: b.value.length > 0 ? "" : a.placeholder,
|
|
250
|
+
disabled: a.disabled,
|
|
251
|
+
class: "cui-combobox__input",
|
|
252
|
+
onInput: re,
|
|
253
|
+
onFocus: ne,
|
|
254
|
+
onKeydown: ie
|
|
255
|
+
}, null, 40, Te),
|
|
256
|
+
S("div", Ve, [
|
|
257
|
+
N.value ? (r(), w(Q, {
|
|
258
|
+
key: 0,
|
|
259
|
+
size: "xs"
|
|
260
|
+
})) : (r(), w(q, {
|
|
261
|
+
key: 1,
|
|
262
|
+
name: "caret-down",
|
|
263
|
+
size: "0.875rem",
|
|
264
|
+
style: x({ color: "var(--cui-text-tertiary)", transform: s.value ? "rotate(180deg)" : "none", transition: "transform 0.15s ease" })
|
|
265
|
+
}, null, 8, ["style"]))
|
|
266
|
+
])
|
|
267
|
+
], 6),
|
|
268
|
+
a.error && a.errorMessage ? (r(), u("div", {
|
|
269
|
+
key: 1,
|
|
270
|
+
id: L(te),
|
|
271
|
+
style: { fontSize: "0.75rem", color: "var(--cui-error)", marginTop: "calc(0.25rem * var(--cui-density-scale, 1))" }
|
|
272
|
+
}, h(a.errorMessage), 9, Me)) : v("", !0),
|
|
273
|
+
(r(), w(xe, { to: "body" }, [
|
|
274
|
+
s.value ? (r(), u("div", {
|
|
275
|
+
key: 0,
|
|
276
|
+
ref_key: "dropdownRef",
|
|
277
|
+
ref: V,
|
|
278
|
+
class: "cui-combobox__dropdown",
|
|
279
|
+
style: x(H.value)
|
|
280
|
+
}, [
|
|
281
|
+
N.value && y.value.length === 0 ? (r(), u("div", Ee, [
|
|
282
|
+
we(Q, {
|
|
283
|
+
size: "sm",
|
|
284
|
+
"show-label": "",
|
|
285
|
+
label: L(j).combobox.searching
|
|
286
|
+
}, null, 8, ["label"])
|
|
287
|
+
])) : y.value.length === 0 && (n.value.length >= a.minChars || !a.fetchOptions) ? (r(), u("div", De, h(a.noResultsText), 1)) : y.value.length === 0 && a.fetchOptions && n.value.length < a.minChars ? (r(), u("div", Ae, h(L(j).combobox.typeMore(a.minChars - n.value.length)), 1)) : v("", !0),
|
|
288
|
+
(r(!0), u(Z, null, G(y.value, (t, i) => (r(), u("div", {
|
|
289
|
+
key: String(t.value),
|
|
290
|
+
"data-index": i,
|
|
291
|
+
class: Y(de(i, t)),
|
|
292
|
+
onClick: pe((B) => P(t), ["stop"]),
|
|
293
|
+
onMouseenter: (B) => c.value = i
|
|
294
|
+
}, [
|
|
295
|
+
ke(e.$slots, "option", {
|
|
296
|
+
option: t,
|
|
297
|
+
selected: f.value.has(t.value)
|
|
298
|
+
}, () => [
|
|
299
|
+
t.image ? (r(), u("img", {
|
|
300
|
+
key: 0,
|
|
301
|
+
src: t.image,
|
|
302
|
+
style: { width: "1.75rem", height: "1.75rem", borderRadius: "50%", objectFit: "cover", flexShrink: "0" }
|
|
303
|
+
}, null, 8, qe)) : t.icon ? (r(), w(q, {
|
|
304
|
+
key: 1,
|
|
305
|
+
name: t.icon,
|
|
306
|
+
size: "1rem",
|
|
307
|
+
style: { flexShrink: "0", color: "var(--cui-text-secondary)" }
|
|
308
|
+
}, null, 8, ["name"])) : v("", !0),
|
|
309
|
+
S("div", Fe, [
|
|
310
|
+
S("div", {
|
|
311
|
+
style: x({ lineHeight: "1.3", fontWeight: f.value.has(t.value) ? "600" : "400" })
|
|
312
|
+
}, h(t.label), 5),
|
|
313
|
+
t.description ? (r(), u("div", He, h(t.description), 1)) : v("", !0)
|
|
314
|
+
]),
|
|
315
|
+
f.value.has(t.value) ? (r(), w(q, {
|
|
316
|
+
key: 2,
|
|
317
|
+
name: "check",
|
|
318
|
+
size: "0.875rem",
|
|
319
|
+
style: x({ color: `var(--cui-${a.color})`, flexShrink: "0" })
|
|
320
|
+
}, null, 8, ["style"])) : v("", !0)
|
|
321
|
+
], !0)
|
|
322
|
+
], 42, Ie))), 128))
|
|
323
|
+
], 4)) : v("", !0)
|
|
324
|
+
]))
|
|
325
|
+
], 4)), [
|
|
326
|
+
[Se, !a.hidden]
|
|
327
|
+
]);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
2
330
|
export {
|
|
3
|
-
|
|
331
|
+
Ze as default
|
|
4
332
|
};
|