@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
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { defineComponent, useModel, ref, openBlock, createElementBlock, mergeProps, unref, createElementVNode, toDisplayString, createCommentVNode, createVNode, withCtx, createTextVNode, TransitionGroup, Fragment, renderList, renderSlot, mergeModels, nextTick } from "vue";
|
|
2
|
-
import { useFieldControl } from "../composables/useField.js";
|
|
3
|
-
import { useLabels } from "../composables/useLpConfig.js";
|
|
4
|
-
import { useMergedAttrs } from "../composables/useMergedClass.js";
|
|
5
|
-
import { useRepeater } from "../composables/useRepeater.js";
|
|
6
|
-
import { usePrefersReducedMotion } from "../composables/useReducedMotion.js";
|
|
7
|
-
import { _ as _sfc_main$1 } from "./LpButton-DSHioIfD.js";
|
|
8
|
-
import { _ as _sfc_main$2 } from "./LpIcon-C6JpQ5td.js";
|
|
9
|
-
import { _ as _sfc_main$3 } from "./LpShift-DAgS_d2x.js";
|
|
10
|
-
import '../assets/LpRepeater-C1Cw27hj.css';const _hoisted_1 = { class: "flex items-center justify-between gap-2" };
|
|
11
|
-
const _hoisted_2 = {
|
|
12
|
-
key: 0,
|
|
13
|
-
class: "text-sm font-medium text-ink"
|
|
14
|
-
};
|
|
15
|
-
const _hoisted_3 = { class: "min-w-0 flex-1" };
|
|
16
|
-
const _hoisted_4 = {
|
|
17
|
-
key: "empty",
|
|
18
|
-
class: "text-xs text-muted"
|
|
19
|
-
};
|
|
20
|
-
const focusable = 'input:not([type="hidden"]):not([disabled]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex="0"], [contenteditable="true"]';
|
|
21
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
22
|
-
...{ inheritAttrs: false },
|
|
23
|
-
__name: "LpRepeater",
|
|
24
|
-
props: /* @__PURE__ */ mergeModels({
|
|
25
|
-
createItem: { type: Function },
|
|
26
|
-
itemKey: { type: Function },
|
|
27
|
-
label: {},
|
|
28
|
-
disabled: { type: Boolean },
|
|
29
|
-
labels: {}
|
|
30
|
-
}, {
|
|
31
|
-
"modelValue": { default: () => [] },
|
|
32
|
-
"modelModifiers": {}
|
|
33
|
-
}),
|
|
34
|
-
emits: ["update:modelValue"],
|
|
35
|
-
setup(__props, { expose: __expose }) {
|
|
36
|
-
const props = __props;
|
|
37
|
-
const model = useModel(__props, "modelValue");
|
|
38
|
-
const field = useFieldControl(() => ({ wrapped: false, disabled: props.disabled }));
|
|
39
|
-
const text = useLabels("repeater", { add: "Add item", remove: "Remove item {index}", empty: "No items" }, () => props.labels);
|
|
40
|
-
const list = useRepeater({
|
|
41
|
-
value: () => model.value,
|
|
42
|
-
set: (items) => {
|
|
43
|
-
model.value = items;
|
|
44
|
-
},
|
|
45
|
-
createItem: () => props.createItem(),
|
|
46
|
-
itemKey: () => props.itemKey,
|
|
47
|
-
disabled: () => field.value.disabled
|
|
48
|
-
});
|
|
49
|
-
const { rows } = list;
|
|
50
|
-
const rowsHost = ref(null);
|
|
51
|
-
const reducedMotion = usePrefersReducedMotion();
|
|
52
|
-
const addButton = ref(null);
|
|
53
|
-
function focusRow(index) {
|
|
54
|
-
rowAt(index)?.querySelector(focusable)?.focus({ preventScroll: true });
|
|
55
|
-
}
|
|
56
|
-
function rowAt(index) {
|
|
57
|
-
return Array.from(rowsHost.value?.children ?? []).filter(
|
|
58
|
-
(node) => node.hasAttribute("data-lp-repeater-row") && !node.hasAttribute("inert")
|
|
59
|
-
)[index];
|
|
60
|
-
}
|
|
61
|
-
function beforeLeave(el) {
|
|
62
|
-
const row = el;
|
|
63
|
-
row.style.width = `${row.offsetWidth}px`;
|
|
64
|
-
row.style.top = `${row.offsetTop}px`;
|
|
65
|
-
row.setAttribute("inert", "");
|
|
66
|
-
row.setAttribute("aria-hidden", "true");
|
|
67
|
-
}
|
|
68
|
-
function beforeEnter(el) {
|
|
69
|
-
const row = el;
|
|
70
|
-
row.removeAttribute("inert");
|
|
71
|
-
row.removeAttribute("aria-hidden");
|
|
72
|
-
row.style.removeProperty("top");
|
|
73
|
-
row.style.removeProperty("width");
|
|
74
|
-
}
|
|
75
|
-
async function add() {
|
|
76
|
-
if (field.value.disabled) return;
|
|
77
|
-
list.add();
|
|
78
|
-
await nextTick();
|
|
79
|
-
focusRow(model.value.length - 1);
|
|
80
|
-
}
|
|
81
|
-
async function remove(index) {
|
|
82
|
-
if (field.value.disabled) return;
|
|
83
|
-
const row = rowAt(index);
|
|
84
|
-
const restore = row?.contains(row.ownerDocument.activeElement);
|
|
85
|
-
list.remove(index);
|
|
86
|
-
if (!restore) return;
|
|
87
|
-
await nextTick();
|
|
88
|
-
if (model.value.length) focusRow(Math.min(index, model.value.length - 1));
|
|
89
|
-
else addButton.value?.$el?.focus({ preventScroll: true });
|
|
90
|
-
}
|
|
91
|
-
__expose({ add, remove, update: list.update });
|
|
92
|
-
const { class: rootClass, attrs: rest } = useMergedAttrs("flex min-w-0 flex-col gap-2");
|
|
93
|
-
return (_ctx, _cache) => {
|
|
94
|
-
return openBlock(), createElementBlock("div", mergeProps(unref(rest), { class: unref(rootClass) }), [
|
|
95
|
-
createElementVNode("div", _hoisted_1, [
|
|
96
|
-
__props.label ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(__props.label), 1)) : createCommentVNode("", true),
|
|
97
|
-
createVNode(_sfc_main$1, {
|
|
98
|
-
ref_key: "addButton",
|
|
99
|
-
ref: addButton,
|
|
100
|
-
size: "xs",
|
|
101
|
-
variant: "ghost",
|
|
102
|
-
disabled: unref(field).disabled,
|
|
103
|
-
onClick: add
|
|
104
|
-
}, {
|
|
105
|
-
default: withCtx(() => [
|
|
106
|
-
createVNode(_sfc_main$2, {
|
|
107
|
-
name: "lucide:plus",
|
|
108
|
-
size: 14
|
|
109
|
-
}),
|
|
110
|
-
createTextVNode(toDisplayString(unref(text).add), 1)
|
|
111
|
-
]),
|
|
112
|
-
_: 1
|
|
113
|
-
}, 8, ["disabled"])
|
|
114
|
-
]),
|
|
115
|
-
createVNode(_sfc_main$3, { axis: "height" }, {
|
|
116
|
-
default: withCtx(() => [
|
|
117
|
-
createElementVNode("div", {
|
|
118
|
-
ref_key: "rowsHost",
|
|
119
|
-
ref: rowsHost,
|
|
120
|
-
class: "relative flex min-w-0 flex-col gap-2"
|
|
121
|
-
}, [
|
|
122
|
-
createVNode(TransitionGroup, {
|
|
123
|
-
name: "lp-repeater",
|
|
124
|
-
css: !unref(reducedMotion),
|
|
125
|
-
onBeforeEnter: beforeEnter,
|
|
126
|
-
onBeforeLeave: beforeLeave
|
|
127
|
-
}, {
|
|
128
|
-
default: withCtx(() => [
|
|
129
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(rows), ({ item, key }, index) => {
|
|
130
|
-
return openBlock(), createElementBlock("div", {
|
|
131
|
-
key,
|
|
132
|
-
"data-lp-repeater-row": "",
|
|
133
|
-
class: "flex min-w-0 items-start gap-2"
|
|
134
|
-
}, [
|
|
135
|
-
createElementVNode("div", _hoisted_3, [
|
|
136
|
-
renderSlot(_ctx.$slots, "default", {
|
|
137
|
-
item,
|
|
138
|
-
index,
|
|
139
|
-
disabled: unref(field).disabled,
|
|
140
|
-
update: (next) => unref(list).update(index, next),
|
|
141
|
-
remove: () => remove(index)
|
|
142
|
-
})
|
|
143
|
-
]),
|
|
144
|
-
createVNode(_sfc_main$1, {
|
|
145
|
-
variant: "ghost",
|
|
146
|
-
size: "sm",
|
|
147
|
-
square: "",
|
|
148
|
-
disabled: unref(field).disabled,
|
|
149
|
-
"aria-label": unref(text).remove.replace("{index}", String(index + 1)),
|
|
150
|
-
onClick: ($event) => remove(index)
|
|
151
|
-
}, {
|
|
152
|
-
default: withCtx(() => [
|
|
153
|
-
createVNode(_sfc_main$2, {
|
|
154
|
-
name: "lucide:x",
|
|
155
|
-
size: 14
|
|
156
|
-
})
|
|
157
|
-
]),
|
|
158
|
-
_: 1
|
|
159
|
-
}, 8, ["disabled", "aria-label", "onClick"])
|
|
160
|
-
]);
|
|
161
|
-
}), 128)),
|
|
162
|
-
!unref(rows).length ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
163
|
-
renderSlot(_ctx.$slots, "empty", {}, () => [
|
|
164
|
-
createTextVNode(toDisplayString(unref(text).empty), 1)
|
|
165
|
-
])
|
|
166
|
-
])) : createCommentVNode("", true)
|
|
167
|
-
]),
|
|
168
|
-
_: 3
|
|
169
|
-
}, 8, ["css"])
|
|
170
|
-
], 512)
|
|
171
|
-
]),
|
|
172
|
-
_: 3
|
|
173
|
-
})
|
|
174
|
-
], 16);
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
export {
|
|
179
|
-
_sfc_main as _
|
|
180
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { defineComponent, useId, ref, openBlock, createBlock, unref, mergeProps, withCtx, createElementBlock, Fragment, renderList, normalizeClass, createCommentVNode, createVNode, toDisplayString } from "vue";
|
|
2
|
-
import { CONTROL_SIZE } from "../components/controlSize.js";
|
|
3
|
-
import { isHTMLElement } from "../composables/realm.js";
|
|
4
|
-
import { usePaletteControl } from "../composables/usePaletteCommands.js";
|
|
5
|
-
import { Motion } from "motion-v";
|
|
6
|
-
import { ToggleGroupRoot, ToggleGroupItem } from "reka-ui";
|
|
7
|
-
import { useFieldControl, mergeDescribedBy } from "../composables/useField.js";
|
|
8
|
-
import { useMergedAttrs } from "../composables/useMergedClass.js";
|
|
9
|
-
import { usePillTransition } from "../composables/usePillTransition.js";
|
|
10
|
-
import { _ as _sfc_main$2 } from "./AttentionDot-DCBf4aWg.js";
|
|
11
|
-
import { _ as _sfc_main$1 } from "./LpIcon-C6JpQ5td.js";
|
|
12
|
-
const _hoisted_1 = {
|
|
13
|
-
key: 1,
|
|
14
|
-
class: "relative z-10 inline-flex shrink-0"
|
|
15
|
-
};
|
|
16
|
-
const _hoisted_2 = {
|
|
17
|
-
key: 2,
|
|
18
|
-
class: "relative z-10"
|
|
19
|
-
};
|
|
20
|
-
const __default__ = { inheritAttrs: false };
|
|
21
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
22
|
-
...__default__,
|
|
23
|
-
__name: "LpSegmented",
|
|
24
|
-
props: {
|
|
25
|
-
palette: { type: [Boolean, Object], default: void 0 },
|
|
26
|
-
modelValue: {},
|
|
27
|
-
options: {},
|
|
28
|
-
size: { default: "md" },
|
|
29
|
-
block: { type: Boolean, default: false },
|
|
30
|
-
disabled: { type: Boolean },
|
|
31
|
-
hoverFollow: { type: Boolean, default: true }
|
|
32
|
-
},
|
|
33
|
-
emits: ["update:modelValue"],
|
|
34
|
-
setup(__props, { emit: __emit }) {
|
|
35
|
-
const props = __props;
|
|
36
|
-
const emit = __emit;
|
|
37
|
-
function onChange(v) {
|
|
38
|
-
if (typeof v === "string" && v) emit("update:modelValue", v);
|
|
39
|
-
}
|
|
40
|
-
const sizeCls = CONTROL_SIZE;
|
|
41
|
-
const { class: rootClass, attrs: rest } = useMergedAttrs(
|
|
42
|
-
() => [
|
|
43
|
-
"inline-flex items-center gap-1 rounded-control border border-line bg-surface-soft p-1",
|
|
44
|
-
sizeCls[props.size],
|
|
45
|
-
// `w-fit`, not left to the parent: in a column a flex item stretches, and
|
|
46
|
-
// the options sat on the left of an empty bar (the theme studio met it).
|
|
47
|
-
props.block ? "flex w-full" : "w-fit"
|
|
48
|
-
].join(" ")
|
|
49
|
-
);
|
|
50
|
-
const field = useFieldControl(() => ({ wrapped: false, disabled: props.disabled }));
|
|
51
|
-
const pillId = `lp-segmented-${useId()}`;
|
|
52
|
-
const pillTransition = usePillTransition();
|
|
53
|
-
const hovered = ref(null);
|
|
54
|
-
function onEnter(opt) {
|
|
55
|
-
if (props.hoverFollow && !opt.disabled && !field.value.disabled) hovered.value = opt.value;
|
|
56
|
-
}
|
|
57
|
-
function pillUnder(value) {
|
|
58
|
-
return hovered.value ? hovered.value === value : value === props.modelValue;
|
|
59
|
-
}
|
|
60
|
-
function releaseFocusAfterPointer(event) {
|
|
61
|
-
const target = event.currentTarget;
|
|
62
|
-
if (isHTMLElement(target)) target.blur();
|
|
63
|
-
}
|
|
64
|
-
usePaletteControl({ disabled: () => field.value.disabled });
|
|
65
|
-
return (_ctx, _cache) => {
|
|
66
|
-
return openBlock(), createBlock(unref(ToggleGroupRoot), mergeProps({
|
|
67
|
-
"model-value": __props.modelValue,
|
|
68
|
-
type: "single",
|
|
69
|
-
disabled: unref(field).disabled,
|
|
70
|
-
"aria-labelledby": unref(field).labelId,
|
|
71
|
-
rovingFocus: true,
|
|
72
|
-
class: unref(rootClass)
|
|
73
|
-
}, unref(rest), {
|
|
74
|
-
"aria-describedby": unref(mergeDescribedBy)(unref(rest)["aria-describedby"], unref(field).describedBy),
|
|
75
|
-
"onUpdate:modelValue": onChange,
|
|
76
|
-
onPointerleave: _cache[0] || (_cache[0] = ($event) => hovered.value = null)
|
|
77
|
-
}), {
|
|
78
|
-
default: withCtx(() => [
|
|
79
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (opt) => {
|
|
80
|
-
return openBlock(), createBlock(unref(ToggleGroupItem), {
|
|
81
|
-
key: opt.value,
|
|
82
|
-
value: opt.value,
|
|
83
|
-
disabled: opt.disabled,
|
|
84
|
-
"aria-label": opt.ariaLabel ?? (opt.label ? void 0 : opt.value),
|
|
85
|
-
class: normalizeClass(["relative inline-flex h-full items-center justify-center gap-1.5 rounded-inner font-medium outline-none transition-colors duration-[var(--duration-fast)] ease-[var(--ease-emphasized)] focus-visible:ring-2 focus-visible:ring-ring data-[state=on]:text-ink data-[state=off]:text-muted data-[state=off]:hover:text-ink disabled:cursor-not-allowed disabled:opacity-55", [__props.block ? "flex-1" : "", __props.size === "lg" ? "px-4" : "px-3", hovered.value === opt.value ? "text-ink" : ""]]),
|
|
86
|
-
onPointerenter: ($event) => onEnter(opt),
|
|
87
|
-
onPointerup: releaseFocusAfterPointer
|
|
88
|
-
}, {
|
|
89
|
-
default: withCtx(() => [
|
|
90
|
-
pillUnder(opt.value) ? (openBlock(), createBlock(unref(Motion), {
|
|
91
|
-
key: 0,
|
|
92
|
-
"layout-id": pillId,
|
|
93
|
-
transition: unref(pillTransition),
|
|
94
|
-
class: "absolute inset-0 z-0 rounded-inner border border-line bg-surface-raised shadow-sm"
|
|
95
|
-
}, null, 8, ["transition"])) : createCommentVNode("", true),
|
|
96
|
-
opt.icon ? (openBlock(), createElementBlock("span", _hoisted_1, [
|
|
97
|
-
createVNode(_sfc_main$1, {
|
|
98
|
-
name: opt.icon,
|
|
99
|
-
size: __props.size === "lg" ? 16 : 14
|
|
100
|
-
}, null, 8, ["name", "size"]),
|
|
101
|
-
opt.dot && !opt.label ? (openBlock(), createBlock(_sfc_main$2, {
|
|
102
|
-
key: 0,
|
|
103
|
-
corner: ""
|
|
104
|
-
})) : createCommentVNode("", true)
|
|
105
|
-
])) : createCommentVNode("", true),
|
|
106
|
-
opt.label ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(opt.label), 1)) : createCommentVNode("", true),
|
|
107
|
-
opt.dot && opt.label ? (openBlock(), createBlock(_sfc_main$2, {
|
|
108
|
-
key: 3,
|
|
109
|
-
class: "mt-1.5"
|
|
110
|
-
})) : createCommentVNode("", true)
|
|
111
|
-
]),
|
|
112
|
-
_: 2
|
|
113
|
-
}, 1032, ["value", "disabled", "aria-label", "class", "onPointerenter"]);
|
|
114
|
-
}), 128))
|
|
115
|
-
]),
|
|
116
|
-
_: 1
|
|
117
|
-
}, 16, ["model-value", "disabled", "aria-labelledby", "class", "aria-describedby"]);
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
export {
|
|
122
|
-
_sfc_main as _
|
|
123
|
-
};
|