@leavepulse/ui 0.78.1 → 0.78.2
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/dist/chunks/{DropzoneLinkField-CLLhd3WB.js → DropzoneLinkField-CyE7TJ5f.js} +1 -1
- package/dist/chunks/LpAddressInput-ft8fQOGx.js +401 -0
- package/dist/chunks/{LpAppShell-BKbYCHkx.js → LpAppShell-DkvU6IBB.js} +1 -1
- package/dist/chunks/LpAutocomplete-CrZbd0uv.js +310 -0
- package/dist/chunks/LpCheckbox-CCWCwD0y.js +129 -0
- package/dist/chunks/{LpCodeDisplay-D3BUAhV1.js → LpCodeDisplay-D59uPwRb.js} +1 -1
- package/dist/chunks/LpColorPicker-BONURBFN.js +574 -0
- package/dist/chunks/LpDatePicker-C2AOtxgF.js +171 -0
- package/dist/chunks/{LpDateRangePicker-CNQXdTVv.js → LpDateRangePicker-CiXdIAyh.js} +43 -35
- package/dist/chunks/{LpFileTree-C-rJKzEQ.js → LpFileTree-CpNurwZp.js} +2 -2
- package/dist/chunks/{LpFileTreeNode-BgYn4U1J.js → LpFileTreeNode-DdF8Cq-s.js} +1 -1
- package/dist/chunks/{LpInput-D0O6dpuA.js → LpInput-CbI7z5fQ.js} +3 -4
- package/dist/chunks/{LpLogInspector-BdQlX6S-.js → LpLogInspector-CcSJSGan.js} +1 -1
- package/dist/chunks/{LpLogViewer-umCZBapN.js → LpLogViewer-CWu49Dko.js} +2 -2
- package/dist/chunks/{LpModalNav-gOi1Giz1.js → LpModalNav-DI3BW5ff.js} +1 -1
- package/dist/chunks/LpNumberField-C8LfUz_R.js +154 -0
- package/dist/chunks/LpOtpInput-B1X9l9no.js +140 -0
- package/dist/chunks/{LpPaletteTheme-BIXpZLGe.js → LpPaletteTheme-B-xuZiKK.js} +2 -2
- package/dist/chunks/{LpPasswordInput-D4HPhqfV.js → LpPasswordInput-Duc_3wPv.js} +1 -1
- package/dist/chunks/{LpPhoneInput-BSL7NX4z.js → LpPhoneInput-CctcRK9K.js} +124 -118
- package/dist/chunks/LpRadioGroup-DTM0nd9G.js +103 -0
- package/dist/chunks/LpRangeSlider-DJsEZXad.js +97 -0
- package/dist/chunks/LpRepeater-Czib3rmv.js +193 -0
- package/dist/chunks/{LpSecretField-B2roc4Iz.js → LpSecretField-BtlCk3IH.js} +1 -1
- package/dist/chunks/LpSegmented-sskrJKJJ.js +128 -0
- package/dist/chunks/LpSelect-JFZehOkd.js +515 -0
- package/dist/chunks/{LpSidebar-DDNJzb69.js → LpSidebar-CvRvVBTt.js} +1 -1
- package/dist/chunks/LpSlider-C4ilCtZX.js +76 -0
- package/dist/chunks/LpSwitch-DyAYTchz.js +122 -0
- package/dist/chunks/{LpTableFilter-B_XMOeAh.js → LpTableFilter-CJg5eIcV.js} +2 -2
- package/dist/chunks/{LpTagsInput-Dt0mteSj.js → LpTagsInput-CkNxpNYa.js} +4 -3
- package/dist/chunks/{LpTextarea-Co0b9PVx.js → LpTextarea-CFK_5QB8.js} +3 -2
- package/dist/chunks/{LpThemeStudio-ChU0_Ga8.js → LpThemeStudio-R-wohbCY.js} +2 -2
- package/dist/chunks/{LpThemeSwitcher-DmCZ21P_.js → LpThemeSwitcher-Bzy15MCP.js} +1 -1
- package/dist/chunks/LpTimeField-B5n0m8m0.js +115 -0
- package/dist/chunks/{LpTopologyCanvas-jqz1KCq2.js → LpTopologyCanvas-BNgw9RyZ.js} +2 -2
- package/dist/chunks/{LpWorkspaceSwitcher-BeNHCLd5.js → LpWorkspaceSwitcher-ugv-fyig.js} +1 -1
- package/dist/components/DropzoneLinkField.vue.js +1 -1
- package/dist/components/LpAddressInput.vue.d.ts +4 -0
- package/dist/components/LpAddressInput.vue.js +1 -1
- package/dist/components/LpAlert.vue.d.ts +3 -3
- package/dist/components/LpAppShell.vue.d.ts +1 -1
- package/dist/components/LpAppShell.vue.js +1 -1
- package/dist/components/LpAutocomplete.vue.d.ts +4 -0
- package/dist/components/LpAutocomplete.vue.js +1 -1
- package/dist/components/LpBadge.vue.d.ts +2 -2
- package/dist/components/LpChart.vue.d.ts +1 -1
- package/dist/components/LpCheckbox.vue.d.ts +4 -0
- package/dist/components/LpCheckbox.vue.js +1 -1
- package/dist/components/LpCodeDisplay.vue.js +1 -1
- package/dist/components/LpCollapse.vue.d.ts +1 -1
- package/dist/components/LpColorPicker.vue.d.ts +5 -3
- package/dist/components/LpColorPicker.vue.js +1 -1
- package/dist/components/LpDatePicker.vue.js +1 -1
- package/dist/components/LpDateRangePicker.vue.js +1 -1
- package/dist/components/LpDropzone.vue.js +1 -1
- package/dist/components/LpFileTree.vue.js +1 -1
- package/dist/components/LpFileTreeNode.vue.js +1 -1
- package/dist/components/LpImageEditor.vue.d.ts +1 -1
- package/dist/components/LpInput.vue.js +1 -1
- package/dist/components/LpLogInspector.vue.js +1 -1
- package/dist/components/LpLogViewer.vue.js +1 -1
- package/dist/components/LpModalNav.vue.js +1 -1
- package/dist/components/LpNumberField.vue.d.ts +4 -0
- package/dist/components/LpNumberField.vue.js +1 -1
- package/dist/components/LpOtpInput.vue.d.ts +4 -0
- package/dist/components/LpOtpInput.vue.js +1 -1
- package/dist/components/LpPaletteTheme.vue.js +1 -1
- package/dist/components/LpPasswordInput.vue.js +1 -1
- package/dist/components/LpPhoneInput.vue.d.ts +4 -0
- package/dist/components/LpPhoneInput.vue.js +1 -1
- package/dist/components/LpRadioGroup.vue.d.ts +4 -0
- package/dist/components/LpRadioGroup.vue.js +1 -1
- package/dist/components/LpRangeSlider.vue.d.ts +4 -0
- package/dist/components/LpRangeSlider.vue.js +1 -1
- package/dist/components/LpRepeater.vue.d.ts +2 -0
- package/dist/components/LpRepeater.vue.js +1 -1
- package/dist/components/LpScrollArea.vue.d.ts +1 -1
- package/dist/components/LpSecretField.vue.js +1 -1
- package/dist/components/LpSegmented.vue.d.ts +4 -0
- package/dist/components/LpSegmented.vue.js +1 -1
- package/dist/components/LpSelect.vue.d.ts +2 -0
- package/dist/components/LpSelect.vue.js +1 -1
- package/dist/components/LpShinyText.vue.d.ts +1 -1
- package/dist/components/LpSidebar.vue.d.ts +1 -1
- package/dist/components/LpSidebar.vue.js +1 -1
- package/dist/components/LpSlider.vue.d.ts +4 -0
- package/dist/components/LpSlider.vue.js +1 -1
- package/dist/components/LpSwitch.vue.d.ts +4 -0
- package/dist/components/LpSwitch.vue.js +1 -1
- package/dist/components/LpTable.vue.js +2 -2
- package/dist/components/LpTableFilter.vue.js +1 -1
- package/dist/components/LpTabs.vue.d.ts +1 -1
- package/dist/components/LpTagsInput.vue.js +1 -1
- package/dist/components/LpTextarea.vue.js +1 -1
- package/dist/components/LpThemeStudio.vue.js +1 -1
- package/dist/components/LpThemeSwitcher.vue.js +1 -1
- package/dist/components/LpTimeField.vue.d.ts +4 -0
- package/dist/components/LpTimeField.vue.js +1 -1
- package/dist/components/LpTopologyCanvas.vue.js +1 -1
- package/dist/components/LpWorkspaceSwitcher.vue.js +1 -1
- package/dist/components/calendar.d.ts +2 -0
- package/dist/composables/useField.d.ts +50 -0
- package/dist/composables/useField.js +31 -2
- package/dist/composables/useMergedClass.d.ts +6 -2
- package/dist/composables/useMergedClass.js +6 -6
- package/dist/index.js +34 -34
- package/package.json +1 -1
- package/src/components/LpAddressInput.vue +8 -4
- package/src/components/LpAutocomplete.vue +11 -5
- package/src/components/LpCheckbox.vue +8 -6
- package/src/components/LpColorPicker.vue +7 -4
- package/src/components/LpDatePicker.vue +8 -4
- package/src/components/LpDateRangePicker.vue +8 -4
- package/src/components/LpInput.vue +3 -4
- package/src/components/LpNumberField.vue +11 -6
- package/src/components/LpOtpInput.vue +8 -6
- package/src/components/LpPhoneInput.vue +11 -6
- package/src/components/LpRadioGroup.vue +9 -5
- package/src/components/LpRangeSlider.vue +8 -4
- package/src/components/LpRepeater.vue +16 -4
- package/src/components/LpSegmented.vue +8 -4
- package/src/components/LpSelect.vue +8 -7
- package/src/components/LpSlider.vue +8 -4
- package/src/components/LpSwitch.vue +8 -5
- package/src/components/LpTagsInput.vue +4 -3
- package/src/components/LpTextarea.vue +3 -2
- package/src/components/LpTimeField.vue +8 -6
- package/src/components/calendar.ts +2 -0
- package/src/composables/useField.ts +52 -0
- package/src/composables/useMergedClass.ts +11 -5
- package/dist/chunks/LpAddressInput-BSS49jpm.js +0 -393
- package/dist/chunks/LpAutocomplete-DkY6CSyD.js +0 -302
- package/dist/chunks/LpCheckbox-D6RuDW4X.js +0 -124
- package/dist/chunks/LpColorPicker-COHzV68R.js +0 -567
- package/dist/chunks/LpDatePicker-DwSDY0mt.js +0 -163
- package/dist/chunks/LpNumberField-Csg-1Zh_.js +0 -148
- package/dist/chunks/LpOtpInput-BRpLBbOD.js +0 -132
- package/dist/chunks/LpRadioGroup-BrazjLY_.js +0 -95
- package/dist/chunks/LpRangeSlider-fz61tzc-.js +0 -89
- package/dist/chunks/LpRepeater-BkJHSPI1.js +0 -180
- package/dist/chunks/LpSegmented-DbEJhbv-.js +0 -123
- package/dist/chunks/LpSelect-Y-iuSymW.js +0 -512
- package/dist/chunks/LpSlider-A4ixovgS.js +0 -68
- package/dist/chunks/LpSwitch-DnC2-0aV.js +0 -115
- package/dist/chunks/LpTimeField-DeOcKWJq.js +0 -110
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { defineComponent, computed, useAttrs, ref, watch, useId, openBlock, createBlock, normalizeProps, guardReactiveProps, unref, withCtx, createVNode, normalizeStyle, normalizeClass, createElementBlock, createCommentVNode, createElementVNode, mergeProps, Transition, toDisplayString, withModifiers, createTextVNode, Fragment, renderList, nextTick } from "vue";
|
|
2
|
+
import { _ as _sfc_main$1 } from "./FieldWrapper-DnuMTrqW.js";
|
|
3
|
+
import { _ as _sfc_main$3 } from "./IconCloseButton-COZEsa9u.js";
|
|
4
|
+
import { CONTROL_SIZE } from "../components/controlSize.js";
|
|
5
|
+
import { usePaletteControl } from "../composables/usePaletteCommands.js";
|
|
6
|
+
import { ComboboxRoot, ComboboxAnchor, ComboboxInput, ComboboxPortal, ComboboxContent, ComboboxViewport, ComboboxEmpty, ComboboxItem } from "reka-ui";
|
|
7
|
+
import { useOwnField, mergeDescribedBy } from "../composables/useField.js";
|
|
8
|
+
import { useInputFilter } from "../composables/useInputFilter.js";
|
|
9
|
+
import { useLabels } from "../composables/useLpConfig.js";
|
|
10
|
+
import { COMBOBOX_PANEL, POPOVER_PANEL, OPTION_ITEM, optionStagger } from "../components/dropdown.js";
|
|
11
|
+
import { _ as _sfc_main$2 } from "./LpIcon-C6JpQ5td.js";
|
|
12
|
+
import { _ as _sfc_main$4 } from "./OptionContent-CGb8QlHA.js";
|
|
13
|
+
import { usePortalTarget, useOutsideGuard } from "../composables/useView.js";
|
|
14
|
+
const _hoisted_1 = ["src"];
|
|
15
|
+
const _hoisted_2 = { class: "relative flex min-w-0 flex-1 self-stretch" };
|
|
16
|
+
const _hoisted_3 = {
|
|
17
|
+
key: 0,
|
|
18
|
+
class: "pointer-events-none absolute inset-0 flex min-w-0 items-center gap-1.5",
|
|
19
|
+
"aria-hidden": "true"
|
|
20
|
+
};
|
|
21
|
+
const _hoisted_4 = ["id"];
|
|
22
|
+
const _hoisted_5 = {
|
|
23
|
+
key: 0,
|
|
24
|
+
class: "px-3 py-4 text-center text-sm italic text-muted"
|
|
25
|
+
};
|
|
26
|
+
const __default__ = { inheritAttrs: false };
|
|
27
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
28
|
+
...__default__,
|
|
29
|
+
__name: "LpAutocomplete",
|
|
30
|
+
props: {
|
|
31
|
+
palette: { type: [Boolean, Object], default: void 0 },
|
|
32
|
+
modelValue: {},
|
|
33
|
+
options: {},
|
|
34
|
+
placeholder: {},
|
|
35
|
+
disabled: { type: Boolean },
|
|
36
|
+
clearable: { type: Boolean, default: false },
|
|
37
|
+
size: { default: "md" },
|
|
38
|
+
icon: {},
|
|
39
|
+
invalid: { type: Boolean },
|
|
40
|
+
error: {},
|
|
41
|
+
emptyText: {},
|
|
42
|
+
loading: { type: Boolean, default: false },
|
|
43
|
+
loadingText: {},
|
|
44
|
+
filter: { type: Boolean, default: true },
|
|
45
|
+
minChars: { default: 1 },
|
|
46
|
+
pattern: {},
|
|
47
|
+
restrict: {},
|
|
48
|
+
selected: {},
|
|
49
|
+
labels: {}
|
|
50
|
+
},
|
|
51
|
+
emits: ["update:modelValue", "select"],
|
|
52
|
+
setup(__props, { emit: __emit }) {
|
|
53
|
+
const props = __props;
|
|
54
|
+
const emit = __emit;
|
|
55
|
+
const { isInvalid, onBeforeInput, onInput: filterInput, onCompositionEnd, onPaste } = useInputFilter({
|
|
56
|
+
pattern: () => props.pattern,
|
|
57
|
+
restrict: () => props.restrict
|
|
58
|
+
});
|
|
59
|
+
const text = computed({
|
|
60
|
+
get: () => props.modelValue ?? "",
|
|
61
|
+
set: (v) => emit("update:modelValue", v)
|
|
62
|
+
});
|
|
63
|
+
const inputAttrs = computed(() => {
|
|
64
|
+
const { class: _c, style: _s, ...rest } = attrs;
|
|
65
|
+
return rest;
|
|
66
|
+
});
|
|
67
|
+
const attrs = useAttrs();
|
|
68
|
+
const { field, wrapper, ownAttrs } = useOwnField(() => ({ error: props.error, invalid: props.invalid || isInvalid(props.modelValue), disabled: props.disabled }));
|
|
69
|
+
const isInvalidState = computed(() => field.value.invalid);
|
|
70
|
+
const labels = useLabels(
|
|
71
|
+
"autocomplete",
|
|
72
|
+
{ clear: "Clear", placeholder: "Type…", empty: "No suggestions", loading: "Searching…" },
|
|
73
|
+
() => props.labels
|
|
74
|
+
);
|
|
75
|
+
const placeholderText = computed(() => props.placeholder ?? labels.value.placeholder);
|
|
76
|
+
const items = computed(
|
|
77
|
+
() => (props.options ?? []).map(
|
|
78
|
+
(o) => typeof o === "string" ? { value: o } : o
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
const typing = ref(false);
|
|
82
|
+
const filtered = computed(() => {
|
|
83
|
+
const q = text.value.trim().toLowerCase();
|
|
84
|
+
if (!props.filter || !typing.value || !q) return items.value;
|
|
85
|
+
return items.value.filter((o) => {
|
|
86
|
+
const hay = `${o.label ?? o.value} ${o.description ?? ""}`.toLowerCase();
|
|
87
|
+
return hay.includes(q);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
const open = ref(false);
|
|
91
|
+
const focused = ref(false);
|
|
92
|
+
const showSelected = computed(() => !!props.selected?.label && !focused.value);
|
|
93
|
+
const draft = ref(null);
|
|
94
|
+
const showImage = computed(() => !!props.selected?.image && (!focused.value || draft.value !== null));
|
|
95
|
+
watch(
|
|
96
|
+
() => props.selected?.label,
|
|
97
|
+
(label) => {
|
|
98
|
+
if (draft.value !== null) draft.value = label ?? null;
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
const selectedId = useId();
|
|
102
|
+
const describedBy = computed(
|
|
103
|
+
() => mergeDescribedBy(attrs["aria-describedby"], field.value.describedBy, showSelected.value ? selectedId : void 0)
|
|
104
|
+
);
|
|
105
|
+
const canOpen = computed(
|
|
106
|
+
() => text.value.length >= props.minChars && (props.loading || filtered.value.length > 0)
|
|
107
|
+
);
|
|
108
|
+
watch(canOpen, (can) => {
|
|
109
|
+
if (focused.value && can) open.value = true;
|
|
110
|
+
});
|
|
111
|
+
function onOpenChange(next) {
|
|
112
|
+
open.value = next && canOpen.value;
|
|
113
|
+
}
|
|
114
|
+
const hasValue = computed(() => (props.modelValue ?? "").length > 0);
|
|
115
|
+
const anchorSize = CONTROL_SIZE;
|
|
116
|
+
function onInput(event) {
|
|
117
|
+
filterInput(event);
|
|
118
|
+
typing.value = true;
|
|
119
|
+
draft.value = null;
|
|
120
|
+
text.value = event.target.value;
|
|
121
|
+
}
|
|
122
|
+
let pointerFocus = false;
|
|
123
|
+
function onPointerDown() {
|
|
124
|
+
if (!focused.value) pointerFocus = true;
|
|
125
|
+
}
|
|
126
|
+
function onFocus(event) {
|
|
127
|
+
typing.value = false;
|
|
128
|
+
focused.value = true;
|
|
129
|
+
const input = event.target;
|
|
130
|
+
if (props.selected?.label) {
|
|
131
|
+
draft.value = props.selected.label;
|
|
132
|
+
if (pointerFocus) input.addEventListener("mouseup", (e) => e.preventDefault(), { once: true });
|
|
133
|
+
void nextTick(() => input.select());
|
|
134
|
+
}
|
|
135
|
+
pointerFocus = false;
|
|
136
|
+
if (canOpen.value) open.value = true;
|
|
137
|
+
}
|
|
138
|
+
function onBlur() {
|
|
139
|
+
focused.value = false;
|
|
140
|
+
draft.value = null;
|
|
141
|
+
}
|
|
142
|
+
function choose(opt) {
|
|
143
|
+
typing.value = false;
|
|
144
|
+
draft.value = null;
|
|
145
|
+
emit("update:modelValue", opt.value);
|
|
146
|
+
emit("select", opt.value);
|
|
147
|
+
open.value = false;
|
|
148
|
+
}
|
|
149
|
+
function clear() {
|
|
150
|
+
if (field.value.disabled) return;
|
|
151
|
+
typing.value = false;
|
|
152
|
+
draft.value = null;
|
|
153
|
+
emit("update:modelValue", "");
|
|
154
|
+
open.value = false;
|
|
155
|
+
}
|
|
156
|
+
const portalTo = usePortalTarget();
|
|
157
|
+
const guardOutside = useOutsideGuard();
|
|
158
|
+
usePaletteControl({ disabled: () => field.value.disabled, invalid: () => field.value.invalid });
|
|
159
|
+
return (_ctx, _cache) => {
|
|
160
|
+
return openBlock(), createBlock(_sfc_main$1, normalizeProps(guardReactiveProps(unref(wrapper))), {
|
|
161
|
+
default: withCtx(() => [
|
|
162
|
+
createVNode(unref(ComboboxRoot), {
|
|
163
|
+
open: open.value,
|
|
164
|
+
"ignore-filter": true,
|
|
165
|
+
"reset-search-term-on-blur": false,
|
|
166
|
+
"reset-search-term-on-select": false,
|
|
167
|
+
disabled: unref(field).disabled,
|
|
168
|
+
class: normalizeClass(["relative", unref(ownAttrs)() ? unref(attrs).class : void 0]),
|
|
169
|
+
style: normalizeStyle(unref(ownAttrs)() ? unref(attrs).style : void 0),
|
|
170
|
+
"onUpdate:open": onOpenChange
|
|
171
|
+
}, {
|
|
172
|
+
default: withCtx(() => [
|
|
173
|
+
createVNode(unref(ComboboxAnchor), {
|
|
174
|
+
"data-lp-ring-owner": "",
|
|
175
|
+
class: normalizeClass(["flex w-full items-center gap-2 rounded-control border bg-surface-soft px-3 text-ink transition-colors duration-[var(--duration-fast)] focus-within:ring-2 focus-within:ring-ring data-[disabled]:cursor-not-allowed data-[disabled]:opacity-55", [
|
|
176
|
+
unref(anchorSize)[__props.size],
|
|
177
|
+
isInvalidState.value ? "border-danger focus-within:border-danger focus-within:ring-danger-soft" : "border-line focus-within:border-brand"
|
|
178
|
+
]])
|
|
179
|
+
}, {
|
|
180
|
+
default: withCtx(() => [
|
|
181
|
+
__props.icon || __props.selected?.image ? (openBlock(), createElementBlock("span", {
|
|
182
|
+
key: 0,
|
|
183
|
+
class: normalizeClass(["relative grid shrink-0 place-items-center", __props.selected === void 0 ? "size-4" : "size-5"])
|
|
184
|
+
}, [
|
|
185
|
+
__props.icon ? (openBlock(), createBlock(_sfc_main$2, {
|
|
186
|
+
key: 0,
|
|
187
|
+
name: __props.icon,
|
|
188
|
+
size: 16,
|
|
189
|
+
class: normalizeClass(["col-start-1 row-start-1 text-muted transition-[opacity,scale] duration-[var(--duration-fast)] motion-reduce:transition-none", showImage.value ? "scale-75 opacity-0" : "opacity-100"])
|
|
190
|
+
}, null, 8, ["name", "class"])) : createCommentVNode("", true),
|
|
191
|
+
__props.selected?.image ? (openBlock(), createElementBlock("img", {
|
|
192
|
+
key: 1,
|
|
193
|
+
src: __props.selected.image,
|
|
194
|
+
alt: "",
|
|
195
|
+
class: normalizeClass(["col-start-1 row-start-1 size-5 rounded-full object-cover transition-[opacity,scale] duration-[var(--duration-fast)] motion-reduce:transition-none", showImage.value ? "opacity-100" : "scale-75 opacity-0"])
|
|
196
|
+
}, null, 10, _hoisted_1)) : createCommentVNode("", true)
|
|
197
|
+
], 2)) : createCommentVNode("", true),
|
|
198
|
+
createElementVNode("div", _hoisted_2, [
|
|
199
|
+
createVNode(unref(ComboboxInput), mergeProps(inputAttrs.value, {
|
|
200
|
+
id: unref(field).id,
|
|
201
|
+
"model-value": draft.value ?? text.value,
|
|
202
|
+
placeholder: placeholderText.value,
|
|
203
|
+
disabled: unref(field).disabled,
|
|
204
|
+
required: unref(field).required || void 0,
|
|
205
|
+
"aria-invalid": isInvalidState.value || void 0,
|
|
206
|
+
"aria-describedby": describedBy.value,
|
|
207
|
+
class: ["lp-autofill min-w-0 flex-1 self-stretch bg-transparent outline-none placeholder:text-muted", showSelected.value && "text-transparent placeholder:text-transparent"],
|
|
208
|
+
onBeforeinput: unref(onBeforeInput),
|
|
209
|
+
onPaste: unref(onPaste),
|
|
210
|
+
onCompositionend: unref(onCompositionEnd),
|
|
211
|
+
onInput,
|
|
212
|
+
onPointerdown: onPointerDown,
|
|
213
|
+
onFocus,
|
|
214
|
+
onBlur
|
|
215
|
+
}), null, 16, ["id", "model-value", "placeholder", "disabled", "required", "aria-invalid", "aria-describedby", "class", "onBeforeinput", "onPaste", "onCompositionend"]),
|
|
216
|
+
createVNode(Transition, {
|
|
217
|
+
"enter-active-class": "transition-opacity duration-[var(--duration-fast)] motion-reduce:transition-none",
|
|
218
|
+
"leave-active-class": "transition-opacity duration-[var(--duration-fast)] motion-reduce:transition-none",
|
|
219
|
+
"enter-from-class": "opacity-0",
|
|
220
|
+
"leave-to-class": "opacity-0"
|
|
221
|
+
}, {
|
|
222
|
+
default: withCtx(() => [
|
|
223
|
+
__props.selected?.label ? (openBlock(), createElementBlock("span", _hoisted_3, [
|
|
224
|
+
createElementVNode("span", {
|
|
225
|
+
id: unref(selectedId),
|
|
226
|
+
class: "sr-only"
|
|
227
|
+
}, toDisplayString(__props.selected.hint ? `${__props.selected.label}, ${__props.selected.hint}` : __props.selected.label), 9, _hoisted_4),
|
|
228
|
+
createElementVNode("span", {
|
|
229
|
+
class: normalizeClass(["max-w-full shrink-0 truncate", showSelected.value ? "" : "invisible"])
|
|
230
|
+
}, toDisplayString(__props.selected.label), 3),
|
|
231
|
+
__props.selected.hint ? (openBlock(), createElementBlock("span", {
|
|
232
|
+
key: 0,
|
|
233
|
+
class: normalizeClass(["min-w-0 truncate text-sm text-muted transition-[opacity,translate] duration-[var(--duration-fast)] motion-reduce:transition-none", showSelected.value ? "opacity-100" : "-translate-x-1 opacity-0"])
|
|
234
|
+
}, toDisplayString(__props.selected.hint), 3)) : createCommentVNode("", true)
|
|
235
|
+
])) : createCommentVNode("", true)
|
|
236
|
+
]),
|
|
237
|
+
_: 1
|
|
238
|
+
})
|
|
239
|
+
]),
|
|
240
|
+
__props.clearable && hasValue.value && !unref(field).disabled ? (openBlock(), createBlock(_sfc_main$3, {
|
|
241
|
+
key: 1,
|
|
242
|
+
inline: "",
|
|
243
|
+
label: unref(labels).clear,
|
|
244
|
+
onPointerdown: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
245
|
+
}, ["prevent"])),
|
|
246
|
+
onClick: clear
|
|
247
|
+
}, null, 8, ["label"])) : createCommentVNode("", true)
|
|
248
|
+
]),
|
|
249
|
+
_: 1
|
|
250
|
+
}, 8, ["class"]),
|
|
251
|
+
createVNode(unref(ComboboxPortal), { to: unref(portalTo) }, {
|
|
252
|
+
default: withCtx(() => [
|
|
253
|
+
createVNode(unref(ComboboxContent), mergeProps({
|
|
254
|
+
onInteractOutside: unref(guardOutside),
|
|
255
|
+
onEscapeKeyDown: unref(guardOutside)
|
|
256
|
+
}, unref(COMBOBOX_PANEL), {
|
|
257
|
+
class: [unref(POPOVER_PANEL), "z-(--z-popover) max-h-72 w-(--reka-combobox-trigger-width) overflow-hidden"],
|
|
258
|
+
onOpenAutoFocus: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
259
|
+
}, ["prevent"])),
|
|
260
|
+
onMousedown: _cache[2] || (_cache[2] = withModifiers(() => {
|
|
261
|
+
}, ["prevent"]))
|
|
262
|
+
}), {
|
|
263
|
+
default: withCtx(() => [
|
|
264
|
+
createVNode(unref(ComboboxViewport), { class: "max-h-72 overflow-y-auto p-1" }, {
|
|
265
|
+
default: withCtx(() => [
|
|
266
|
+
__props.loading ? (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(__props.loadingText ?? unref(labels).loading), 1)) : (openBlock(), createBlock(unref(ComboboxEmpty), {
|
|
267
|
+
key: 1,
|
|
268
|
+
class: "px-3 py-4 text-center text-sm italic text-muted"
|
|
269
|
+
}, {
|
|
270
|
+
default: withCtx(() => [
|
|
271
|
+
createTextVNode(toDisplayString(__props.emptyText ?? unref(labels).empty), 1)
|
|
272
|
+
]),
|
|
273
|
+
_: 1
|
|
274
|
+
})),
|
|
275
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(filtered.value, (opt, i) => {
|
|
276
|
+
return openBlock(), createBlock(unref(ComboboxItem), {
|
|
277
|
+
key: opt.value,
|
|
278
|
+
value: opt.value,
|
|
279
|
+
disabled: opt.disabled,
|
|
280
|
+
style: normalizeStyle(unref(optionStagger)(i)),
|
|
281
|
+
class: normalizeClass([unref(OPTION_ITEM), "justify-between data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50"]),
|
|
282
|
+
onSelect: withModifiers(($event) => choose(opt), ["prevent"])
|
|
283
|
+
}, {
|
|
284
|
+
default: withCtx(() => [
|
|
285
|
+
createVNode(_sfc_main$4, { option: opt }, null, 8, ["option"])
|
|
286
|
+
]),
|
|
287
|
+
_: 2
|
|
288
|
+
}, 1032, ["value", "disabled", "style", "class", "onSelect"]);
|
|
289
|
+
}), 128))
|
|
290
|
+
]),
|
|
291
|
+
_: 1
|
|
292
|
+
})
|
|
293
|
+
]),
|
|
294
|
+
_: 1
|
|
295
|
+
}, 16, ["onInteractOutside", "onEscapeKeyDown", "class"])
|
|
296
|
+
]),
|
|
297
|
+
_: 1
|
|
298
|
+
}, 8, ["to"])
|
|
299
|
+
]),
|
|
300
|
+
_: 1
|
|
301
|
+
}, 8, ["open", "disabled", "class", "style"])
|
|
302
|
+
]),
|
|
303
|
+
_: 1
|
|
304
|
+
}, 16);
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
export {
|
|
309
|
+
_sfc_main as _
|
|
310
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { defineComponent, computed, useId, openBlock, createBlock, normalizeProps, guardReactiveProps, unref, withCtx, createElementVNode, mergeProps, createVNode, normalizeClass, createCommentVNode, createElementBlock, renderSlot, createTextVNode, toDisplayString } from "vue";
|
|
2
|
+
import { _ as _sfc_main$1 } from "./FieldWrapper-DnuMTrqW.js";
|
|
3
|
+
import { usePaletteControl } from "../composables/usePaletteCommands.js";
|
|
4
|
+
import { CheckboxRoot, CheckboxIndicator } from "reka-ui";
|
|
5
|
+
import { _ as _sfc_main$2 } from "./LpIcon-C6JpQ5td.js";
|
|
6
|
+
import { _ as _sfc_main$3 } from "./LpLoader-Bf1yZwaU.js";
|
|
7
|
+
import { useOwnField, isAttrOn, mergeDescribedBy } from "../composables/useField.js";
|
|
8
|
+
import { useOptimisticToggle } from "../composables/useOptimisticToggle.js";
|
|
9
|
+
import { useMergedAttrs } from "../composables/useMergedClass.js";
|
|
10
|
+
const _hoisted_1 = {
|
|
11
|
+
key: 0,
|
|
12
|
+
class: "flex min-w-0 flex-col"
|
|
13
|
+
};
|
|
14
|
+
const __default__ = { inheritAttrs: false };
|
|
15
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
16
|
+
...__default__,
|
|
17
|
+
__name: "LpCheckbox",
|
|
18
|
+
props: {
|
|
19
|
+
palette: { type: [Boolean, Object], default: void 0 },
|
|
20
|
+
modelValue: { type: Boolean },
|
|
21
|
+
indeterminate: { type: Boolean },
|
|
22
|
+
disabled: { type: Boolean },
|
|
23
|
+
error: {},
|
|
24
|
+
label: {},
|
|
25
|
+
description: {},
|
|
26
|
+
id: {},
|
|
27
|
+
name: {},
|
|
28
|
+
action: {}
|
|
29
|
+
},
|
|
30
|
+
emits: ["update:modelValue", "update:indeterminate", "change", "done", "error"],
|
|
31
|
+
setup(__props, { emit: __emit }) {
|
|
32
|
+
const props = __props;
|
|
33
|
+
const emit = __emit;
|
|
34
|
+
let wasMixed = false;
|
|
35
|
+
const { pending, set } = useOptimisticToggle(() => props.action, emit, () => {
|
|
36
|
+
if (wasMixed) emit("update:indeterminate", true);
|
|
37
|
+
});
|
|
38
|
+
function onUpdate(v) {
|
|
39
|
+
const checked = v === true;
|
|
40
|
+
if (pending.value) return;
|
|
41
|
+
wasMixed = !!props.indeterminate;
|
|
42
|
+
if (wasMixed) emit("update:indeterminate", false);
|
|
43
|
+
void set(checked);
|
|
44
|
+
emit("change", checked);
|
|
45
|
+
}
|
|
46
|
+
const { class: rootClass, attrs: rest } = useMergedAttrs(() => [
|
|
47
|
+
"group/check inline-flex cursor-pointer gap-2 text-sm text-ink",
|
|
48
|
+
props.description ? "items-start" : "items-center"
|
|
49
|
+
].join(" "), () => ownAttrs());
|
|
50
|
+
const FOCUS_LISTENER = /^on(Focus|Blur)/;
|
|
51
|
+
const LISTENER = /^on[A-Z]/;
|
|
52
|
+
const parts = computed(() => {
|
|
53
|
+
const label = {};
|
|
54
|
+
const control = {};
|
|
55
|
+
for (const [key, value] of Object.entries(rest.value)) {
|
|
56
|
+
const onLabel = key === "style" || LISTENER.test(key) && !FOCUS_LISTENER.test(key);
|
|
57
|
+
if (onLabel) label[key] = value;
|
|
58
|
+
else control[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return { label, control };
|
|
61
|
+
});
|
|
62
|
+
const { field, wrapper, ownAttrs } = useOwnField(() => ({
|
|
63
|
+
error: props.error,
|
|
64
|
+
id: props.id,
|
|
65
|
+
required: isAttrOn(rest.value.required),
|
|
66
|
+
disabled: props.disabled
|
|
67
|
+
}));
|
|
68
|
+
const descriptionId = `${useId()}-description`;
|
|
69
|
+
const describedBy = computed(
|
|
70
|
+
() => mergeDescribedBy(rest.value["aria-describedby"], props.description ? descriptionId : void 0, field.value.describedBy)
|
|
71
|
+
);
|
|
72
|
+
usePaletteControl({ label: () => props.label, disabled: () => field.value.disabled || pending.value, editorProps: () => ({ action: void 0, "onUpdate:modelValue": onUpdate, onChange: void 0 }) });
|
|
73
|
+
return (_ctx, _cache) => {
|
|
74
|
+
return openBlock(), createBlock(_sfc_main$1, normalizeProps(guardReactiveProps(unref(wrapper))), {
|
|
75
|
+
default: withCtx(() => [
|
|
76
|
+
createElementVNode("label", mergeProps({ class: unref(rootClass) }, parts.value.label), [
|
|
77
|
+
createVNode(unref(CheckboxRoot), mergeProps(parts.value.control, {
|
|
78
|
+
id: unref(field).id,
|
|
79
|
+
name: __props.name,
|
|
80
|
+
"model-value": __props.indeterminate ? "indeterminate" : __props.modelValue,
|
|
81
|
+
disabled: unref(field).disabled,
|
|
82
|
+
required: unref(field).required,
|
|
83
|
+
"aria-describedby": describedBy.value,
|
|
84
|
+
"aria-busy": unref(pending) || void 0,
|
|
85
|
+
class: [__props.description ? "mt-px" : "", "relative flex size-[18px] shrink-0 items-center justify-center rounded-[5px] border border-line-strong bg-surface-soft outline-none transition-[color,background-color,border-color,box-shadow,scale] duration-[var(--duration-fast)] ease-[var(--ease-emphasized)] not-data-[state=checked]:not-data-[state=indeterminate]:group-hover/check:border-brand active:scale-90 motion-reduce:active:scale-100 focus-visible:ring-2 focus-visible:ring-ring data-[state=checked]:border-transparent data-[state=checked]:bg-brand data-[state=indeterminate]:border-transparent data-[state=indeterminate]:bg-brand disabled:cursor-not-allowed disabled:opacity-55"],
|
|
86
|
+
"onUpdate:modelValue": onUpdate
|
|
87
|
+
}), {
|
|
88
|
+
default: withCtx(() => [
|
|
89
|
+
createVNode(unref(CheckboxIndicator), { class: "flex items-center justify-center text-ink-inverse data-[state=checked]:animate-[indicator-in_140ms_var(--ease-emphasized)] data-[state=indeterminate]:animate-[indicator-in_140ms_var(--ease-emphasized)]" }, {
|
|
90
|
+
default: withCtx(() => [
|
|
91
|
+
createVNode(_sfc_main$2, {
|
|
92
|
+
name: __props.indeterminate ? "lucide:minus" : "lucide:check",
|
|
93
|
+
size: 13,
|
|
94
|
+
class: normalizeClass(unref(pending) && "opacity-0")
|
|
95
|
+
}, null, 8, ["name", "class"])
|
|
96
|
+
]),
|
|
97
|
+
_: 1
|
|
98
|
+
}),
|
|
99
|
+
unref(pending) ? (openBlock(), createBlock(_sfc_main$3, {
|
|
100
|
+
key: 0,
|
|
101
|
+
size: "inline",
|
|
102
|
+
delay: 0,
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
class: normalizeClass(["absolute text-[12px]", __props.modelValue ? "text-ink-inverse" : "text-muted"])
|
|
105
|
+
}, null, 8, ["class"])) : createCommentVNode("", true)
|
|
106
|
+
]),
|
|
107
|
+
_: 1
|
|
108
|
+
}, 16, ["id", "name", "model-value", "disabled", "required", "aria-describedby", "aria-busy", "class"]),
|
|
109
|
+
__props.description ? (openBlock(), createElementBlock("span", _hoisted_1, [
|
|
110
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
111
|
+
createTextVNode(toDisplayString(__props.label), 1)
|
|
112
|
+
]),
|
|
113
|
+
createElementVNode("span", {
|
|
114
|
+
id: descriptionId,
|
|
115
|
+
class: "text-xs text-muted"
|
|
116
|
+
}, toDisplayString(__props.description), 1)
|
|
117
|
+
])) : renderSlot(_ctx.$slots, "default", { key: 1 }, () => [
|
|
118
|
+
createTextVNode(toDisplayString(__props.label), 1)
|
|
119
|
+
])
|
|
120
|
+
], 16)
|
|
121
|
+
]),
|
|
122
|
+
_: 3
|
|
123
|
+
}, 16);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
export {
|
|
128
|
+
_sfc_main as _
|
|
129
|
+
};
|
|
@@ -2,7 +2,7 @@ import { defineComponent, useModel, computed, ref, watch, openBlock, createEleme
|
|
|
2
2
|
import { useLabels } from "../composables/useLpConfig.js";
|
|
3
3
|
import { useMergedAttrs } from "../composables/useMergedClass.js";
|
|
4
4
|
import { useNow } from "../composables/useNow.js";
|
|
5
|
-
import { _ as _sfc_main$6 } from "./LpCheckbox-
|
|
5
|
+
import { _ as _sfc_main$6 } from "./LpCheckbox-CCWCwD0y.js";
|
|
6
6
|
import { _ as _sfc_main$3 } from "./LpCopyButton-sAMvWeLP.js";
|
|
7
7
|
import { _ as _sfc_main$5 } from "./LpCountdown-DVl7vXI1.js";
|
|
8
8
|
import { _ as _sfc_main$4 } from "./LpIcon-C6JpQ5td.js";
|