@sparklingopinions/sparkling-ui 0.3.0 → 0.4.0
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/aliases.d.ts +47 -10
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Calendar/Calendar.vue.d.ts +2 -2
- package/dist/components/Calendar/Calendar.vue_vue_type_script_setup_true_lang.js +6 -14
- package/dist/components/Calendar/Calendar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Dialog/Dialog.vue_vue_type_script_setup_true_lang.js +26 -29
- package/dist/components/Dialog/Dialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/Filters/FilterChip.js.map +1 -1
- package/dist/components/Filters/FilterChip.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/components/Filters/FilterChip.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/Filters/FilterMenu.js.map +1 -1
- package/dist/components/Filters/FilterMenu.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/Filters/FilterMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/Filters/SortMenu.js.map +1 -1
- package/dist/components/Filters/SortMenu.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/Filters/SortMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/Input.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/Input/Input.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Popover/Popover.vue.d.ts +3 -0
- package/dist/components/Popover/Popover.vue_vue_type_script_setup_true_lang.js +38 -30
- package/dist/components/Popover/Popover.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/PropertyList/Editable.js.map +1 -1
- package/dist/components/PropertyList/Editable.vue_vue_type_script_setup_true_lang.js +6 -4
- package/dist/components/PropertyList/Editable.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/PropertyList/PropertyList.js.map +1 -1
- package/dist/components/PropertyList/PropertyList.vue.d.ts +17 -2
- package/dist/components/PropertyList/PropertyList.vue_vue_type_script_setup_true_lang.js +19 -14
- package/dist/components/PropertyList/PropertyList.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/PropertyRow/Collapsible.js.map +1 -1
- package/dist/components/PropertyRow/Collapsible.vue.d.ts +1 -1
- package/dist/components/PropertyRow/Collapsible.vue_vue_type_script_setup_true_lang.js +12 -12
- package/dist/components/PropertyRow/Collapsible.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Radio/Radio.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/Radio/Radio.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/Select.vue.d.ts +10 -1
- package/dist/components/Select/Select.vue_vue_type_script_setup_true_lang.js +125 -101
- package/dist/components/Select/Select.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/Textarea/Textarea.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/Textarea/Textarea.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/package.json +1 -1
- package/src/styles/tailwind.css +4 -2
package/dist/aliases.d.ts
CHANGED
|
@@ -589,15 +589,39 @@ export declare const InlineField: import("vue").DefineComponent<EditableProps &
|
|
|
589
589
|
/** @deprecated Renamed to EditableProps. */
|
|
590
590
|
export type InlineFieldProps = EditableProps;
|
|
591
591
|
/** @deprecated Renamed to PropertyList. */
|
|
592
|
-
export declare const InlineForm:
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
592
|
+
export declare const InlineForm: {
|
|
593
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<{
|
|
594
|
+
fields: PropertyListField[];
|
|
595
|
+
} & {
|
|
596
|
+
modelValue: Record<string, unknown>;
|
|
597
|
+
}> & Readonly<{
|
|
598
|
+
onChange?: ((id: string, value: unknown) => any) | undefined;
|
|
599
|
+
onSubmit?: (() => any) | undefined;
|
|
600
|
+
"onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
|
|
601
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
602
|
+
change: (id: string, value: unknown) => any;
|
|
603
|
+
submit: () => any;
|
|
604
|
+
"update:modelValue": (value: Record<string, unknown>) => any;
|
|
605
|
+
}, import("vue").PublicProps, {}, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
606
|
+
P: {};
|
|
607
|
+
B: {};
|
|
608
|
+
D: {};
|
|
609
|
+
C: {};
|
|
610
|
+
M: {};
|
|
611
|
+
Defaults: {};
|
|
612
|
+
}, Readonly<{
|
|
613
|
+
fields: PropertyListField[];
|
|
614
|
+
} & {
|
|
615
|
+
modelValue: Record<string, unknown>;
|
|
616
|
+
}> & Readonly<{
|
|
617
|
+
onChange?: ((id: string, value: unknown) => any) | undefined;
|
|
618
|
+
onSubmit?: (() => any) | undefined;
|
|
619
|
+
"onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
|
|
620
|
+
}>, {}, {}, {}, {}, {}>;
|
|
621
|
+
__isFragment?: never;
|
|
622
|
+
__isTeleport?: never;
|
|
623
|
+
__isSuspense?: never;
|
|
624
|
+
} & import("vue").ComponentOptionsBase<Readonly<{
|
|
601
625
|
fields: PropertyListField[];
|
|
602
626
|
} & {
|
|
603
627
|
modelValue: Record<string, unknown>;
|
|
@@ -605,7 +629,20 @@ export declare const InlineForm: import("vue").DefineComponent<{
|
|
|
605
629
|
onChange?: ((id: string, value: unknown) => any) | undefined;
|
|
606
630
|
onSubmit?: (() => any) | undefined;
|
|
607
631
|
"onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
|
|
608
|
-
}>, {}, {}, {}, {},
|
|
632
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
633
|
+
change: (id: string, value: unknown) => any;
|
|
634
|
+
submit: () => any;
|
|
635
|
+
"update:modelValue": (value: Record<string, unknown>) => any;
|
|
636
|
+
}, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
637
|
+
$slots: {
|
|
638
|
+
[x: `field-${string}`]: ((props: {
|
|
639
|
+
id: string;
|
|
640
|
+
field: PropertyListField;
|
|
641
|
+
update: (value: unknown) => void;
|
|
642
|
+
value: unknown;
|
|
643
|
+
}) => any) | undefined;
|
|
644
|
+
};
|
|
645
|
+
});
|
|
609
646
|
/** @deprecated Renamed to PropertyListField. */
|
|
610
647
|
export type InlineFormField = PropertyListField;
|
|
611
648
|
/** @deprecated Renamed to Collapsible. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","names":["_sfc_main","Calendar_vue_vue_type_script_setup_true_lang_default","Calendar_default"],"sources":["../../../src/components/Calendar/Calendar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, watch } from 'vue'\n\nimport {\n addDays,\n addMonths,\n differenceInDays,\n isSameDay,\n isSameMonth,\n startOfDay,\n startOfMonth,\n startOfWeek\n} from '../../utils/dates'\nimport Tooltip from '../Tooltip/Tooltip.vue'\nimport ChevronIcon from '../internal/ChevronIcon.vue'\n\nexport interface CalendarProps {\n /** Selects a day; with `end`, a range. */\n start?: Date | null\n end?: Date | null\n /** For the month's name; the browser's language by default. */\n locale?: string\n /** Monday first. */\n weekdays?: string[]\n previousLabel?: string\n nextLabel?: string\n}\n\nconst props = withDefaults(defineProps<CalendarProps>(), {\n start: null,\n end: null,\n locale: undefined,\n weekdays:
|
|
1
|
+
{"version":3,"file":"Calendar.js","names":["_sfc_main","Calendar_vue_vue_type_script_setup_true_lang_default","Calendar_default"],"sources":["../../../src/components/Calendar/Calendar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, watch } from 'vue'\n\nimport {\n addDays,\n addMonths,\n differenceInDays,\n isSameDay,\n isSameMonth,\n startOfDay,\n startOfMonth,\n startOfWeek\n} from '../../utils/dates'\nimport Tooltip from '../Tooltip/Tooltip.vue'\nimport ChevronIcon from '../internal/ChevronIcon.vue'\n\nexport interface CalendarProps {\n /** Selects a day; with `end`, a range. */\n start?: Date | null\n end?: Date | null\n /** For the month's name and the weekdays; the browser's language by default. */\n locale?: string\n /** Monday first; the locale's narrow names by default. */\n weekdays?: string[]\n previousLabel?: string\n nextLabel?: string\n}\n\nconst props = withDefaults(defineProps<CalendarProps>(), {\n start: null,\n end: null,\n locale: undefined,\n weekdays: undefined,\n previousLabel: 'Previous month',\n nextLabel: 'Next month'\n})\n\nconst emit = defineEmits<{ pick: [date: Date] }>()\n\nconst view = ref(startOfMonth(props.end ?? props.start ?? new Date()))\n\n// Follows the selection to its month, when it's picked elsewhere (a shortcut, say).\nwatch(\n () => props.end ?? props.start,\n (date) => {\n if (date) view.value = startOfMonth(date)\n }\n)\n\nconst title = computed(() =>\n new Intl.DateTimeFormat(props.locale, { month: 'long', year: 'numeric' }).format(view.value)\n)\n\n// 1 January 2024 was a Monday.\nconst dayNames = computed(\n () =>\n props.weekdays ??\n Array.from({ length: 7 }, (_, i) =>\n new Intl.DateTimeFormat(props.locale, { weekday: 'narrow' }).format(new Date(2024, 0, 1 + i))\n )\n)\n\nconst shiftMonth = (months: number) => (view.value = addMonths(view.value, months))\n\nconst cells = computed(() => {\n const first = startOfWeek(view.value)\n const last = addDays(addMonths(view.value, 1), -1)\n const count = Math.ceil((differenceInDays(last, first) + 1) / 7) * 7\n const today = startOfDay(new Date())\n const [start, end] = [props.start, props.end].map((date) => (date ? startOfDay(date) : null))\n const ranged = !!start && !!end && !isSameDay(start, end)\n const [low, high] = ranged ? [start!, end!].sort((a, b) => a.getTime() - b.getTime()) : []\n\n return Array.from({ length: count }, (_, i) => {\n const date = addDays(first, i)\n const isStart = !!start && isSameDay(date, start)\n const isEnd = !!end && isSameDay(date, end)\n const selected = isStart || isEnd\n const inRange = ranged && date >= low! && date <= high!\n const isToday = isSameDay(date, today)\n const column = i % 7\n\n return {\n key: date.toISOString(),\n date,\n label: date.getDate(),\n selected,\n isToday,\n // The range is a band behind the days, rounded where it starts, ends or wraps.\n band: inRange\n ? ['bg-sui-accent-wash', (isStart || column === 0) && 'rounded-l-lg', (isEnd || column === 6) && 'rounded-r-lg']\n : '',\n classes: selected\n ? 'bg-sui-accent-solid font-semibold text-sui-on-accent'\n : [\n 'hover:bg-sui-sunken',\n isToday\n ? 'font-semibold text-sui-accent ring-1 ring-sui-accent-line ring-inset'\n : inRange\n ? 'font-medium text-sui-accent'\n : !isSameMonth(date, view.value) || date > today\n ? 'text-sui-ink-muted'\n : 'text-sui-ink'\n ]\n }\n })\n})\n</script>\n\n<!-- A month of days, weeks from Monday: today outlined with a dot, future days and other months muted. Picking a day\n emits it; the host decides what it selects. -->\n<template>\n <div>\n <div class=\"flex h-11 items-center justify-between\">\n <span class=\"pl-1.5 text-13 font-semibold text-sui-ink\">{{ title }}</span>\n <div class=\"flex gap-0.5\">\n <Tooltip :text=\"previousLabel\">\n <button\n :aria-label=\"previousLabel\"\n class=\"flex h-7 w-7 items-center justify-center rounded-lg transition-colors hover:bg-sui-sunken focus-visible:sui-ring\"\n type=\"button\"\n @click=\"shiftMonth(-1)\"\n >\n <ChevronIcon class=\"h-4 w-4 fill-sui-ink-body stroke-sui-ink-body\" direction=\"left\" />\n </button>\n </Tooltip>\n <Tooltip :text=\"nextLabel\">\n <button\n :aria-label=\"nextLabel\"\n class=\"flex h-7 w-7 items-center justify-center rounded-lg transition-colors hover:bg-sui-sunken focus-visible:sui-ring\"\n type=\"button\"\n @click=\"shiftMonth(1)\"\n >\n <ChevronIcon class=\"h-4 w-4 fill-sui-ink-body stroke-sui-ink-body\" direction=\"right\" />\n </button>\n </Tooltip>\n </div>\n </div>\n <div aria-hidden=\"true\" class=\"grid h-5.5 grid-cols-7 items-center\">\n <span v-for=\"(day, i) in dayNames\" :key=\"i\" class=\"text-center text-11 font-semibold text-sui-ink-muted\">\n {{ day }}\n </span>\n </div>\n <div class=\"mt-0.5 grid grid-cols-7 gap-y-0.5\">\n <button\n v-for=\"cell in cells\"\n :key=\"cell.key\"\n :aria-current=\"cell.isToday ? 'date' : undefined\"\n :aria-label=\"cell.date.toLocaleDateString(locale, { dateStyle: 'full' })\"\n :aria-pressed=\"cell.selected\"\n :class=\"['group flex h-9 items-center justify-center outline-hidden', cell.band]\"\n type=\"button\"\n @click=\"emit('pick', cell.date)\"\n >\n <span\n class=\"relative flex h-8.5 w-9 items-center justify-center rounded-lg text-13 tabular-nums transition-colors group-focus-visible:sui-ring\"\n :class=\"cell.classes\"\n >\n {{ cell.label }}\n <span\n v-if=\"cell.isToday\"\n class=\"absolute bottom-1 left-1/2 h-1 w-1 -translate-x-1/2 rounded-full\"\n :class=\"cell.selected ? 'bg-sui-on-accent' : 'bg-sui-accent-solid'\"\n />\n </span>\n </button>\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -2,9 +2,9 @@ export interface CalendarProps {
|
|
|
2
2
|
/** Selects a day; with `end`, a range. */
|
|
3
3
|
start?: Date | null;
|
|
4
4
|
end?: Date | null;
|
|
5
|
-
/** For the month's name; the browser's language by default. */
|
|
5
|
+
/** For the month's name and the weekdays; the browser's language by default. */
|
|
6
6
|
locale?: string;
|
|
7
|
-
/** Monday first. */
|
|
7
|
+
/** Monday first; the locale's narrow names by default. */
|
|
8
8
|
weekdays?: string[];
|
|
9
9
|
previousLabel?: string;
|
|
10
10
|
nextLabel?: string;
|
|
@@ -17,15 +17,7 @@ var T = { class: "flex h-11 items-center justify-between" }, E = { class: "pl-1.
|
|
|
17
17
|
start: { default: null },
|
|
18
18
|
end: { default: null },
|
|
19
19
|
locale: { default: void 0 },
|
|
20
|
-
weekdays: { default:
|
|
21
|
-
"M",
|
|
22
|
-
"T",
|
|
23
|
-
"W",
|
|
24
|
-
"T",
|
|
25
|
-
"F",
|
|
26
|
-
"S",
|
|
27
|
-
"S"
|
|
28
|
-
] },
|
|
20
|
+
weekdays: { default: void 0 },
|
|
29
21
|
previousLabel: { default: "Previous month" },
|
|
30
22
|
nextLabel: { default: "Next month" }
|
|
31
23
|
},
|
|
@@ -38,7 +30,7 @@ var T = { class: "flex h-11 items-center justify-between" }, E = { class: "pl-1.
|
|
|
38
30
|
let L = d(() => new Intl.DateTimeFormat(P.locale, {
|
|
39
31
|
month: "long",
|
|
40
32
|
year: "numeric"
|
|
41
|
-
}).format(I.value)), R = (e) => I.value = n(I.value, e),
|
|
33
|
+
}).format(I.value)), R = d(() => P.weekdays ?? Array.from({ length: 7 }, (e, t) => new Intl.DateTimeFormat(P.locale, { weekday: "narrow" }).format(new Date(2024, 0, 1 + t)))), z = (e) => I.value = n(I.value, e), B = d(() => {
|
|
42
34
|
let e = c(I.value), s = t(n(I.value, 1), -1), l = Math.ceil((r(s, e) + 1) / 7) * 7, u = o(/* @__PURE__ */ new Date()), [d, f] = [P.start, P.end].map((e) => e ? o(e) : null), p = !!d && !!f && !i(d, f), [m, h] = p ? [d, f].sort((e, t) => e.getTime() - t.getTime()) : [];
|
|
43
35
|
return Array.from({ length: l }, (n, r) => {
|
|
44
36
|
let o = t(e, r), s = !!d && i(o, d), c = !!f && i(o, f), l = s || c, g = p && o >= m && o <= h, _ = i(o, u), v = r % 7;
|
|
@@ -63,7 +55,7 @@ var T = { class: "flex h-11 items-center justify-between" }, E = { class: "pl-1.
|
|
|
63
55
|
"aria-label": _.previousLabel,
|
|
64
56
|
class: "flex h-7 w-7 items-center justify-center rounded-lg transition-colors hover:bg-sui-sunken focus-visible:sui-ring",
|
|
65
57
|
type: "button",
|
|
66
|
-
onClick: n[0] ||= (e) =>
|
|
58
|
+
onClick: n[0] ||= (e) => z(-1)
|
|
67
59
|
}, [g(l, {
|
|
68
60
|
class: "h-4 w-4 fill-sui-ink-body stroke-sui-ink-body",
|
|
69
61
|
direction: "left"
|
|
@@ -74,18 +66,18 @@ var T = { class: "flex h-11 items-center justify-between" }, E = { class: "pl-1.
|
|
|
74
66
|
"aria-label": _.nextLabel,
|
|
75
67
|
class: "flex h-7 w-7 items-center justify-center rounded-lg transition-colors hover:bg-sui-sunken focus-visible:sui-ring",
|
|
76
68
|
type: "button",
|
|
77
|
-
onClick: n[1] ||= (e) =>
|
|
69
|
+
onClick: n[1] ||= (e) => z(1)
|
|
78
70
|
}, [g(l, {
|
|
79
71
|
class: "h-4 w-4 fill-sui-ink-body stroke-sui-ink-body",
|
|
80
72
|
direction: "right"
|
|
81
73
|
})], 8, k)]),
|
|
82
74
|
_: 1
|
|
83
75
|
}, 8, ["text"])])]),
|
|
84
|
-
m("div", A, [(y(!0), p(u, null, x(
|
|
76
|
+
m("div", A, [(y(!0), p(u, null, x(R.value, (e, t) => (y(), p("span", {
|
|
85
77
|
key: t,
|
|
86
78
|
class: "text-center text-11 font-semibold text-sui-ink-muted"
|
|
87
79
|
}, S(e), 1))), 128))]),
|
|
88
|
-
m("div", j, [(y(!0), p(u, null, x(
|
|
80
|
+
m("div", j, [(y(!0), p(u, null, x(B.value, (e) => (y(), p("button", {
|
|
89
81
|
key: e.key,
|
|
90
82
|
"aria-current": e.isToday ? "date" : void 0,
|
|
91
83
|
"aria-label": e.date.toLocaleDateString(_.locale, { dateStyle: "full" }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","Tooltip","_withCtx","ChevronIcon","_Fragment","_renderList","_normalizeClass","_createTextVNode","_createCommentVNode","Tooltip_default","ChevronIcon_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","Calendar_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","view","ref","startOfMonth","date","title","computed","shiftMonth","addMonths","months","cells","first","startOfWeek","last","addDays","count","differenceInDays","today","startOfDay","start","end","ranged","isSameDay","low","high","a","b","i","isStart","isEnd","selected","inRange","isToday","column","isSameMonth","openBlock","createElementBlock","createElementVNode","toDisplayString","createVNode","withCtx","_cache","Fragment","renderList","day","cell","normalizeClass","createTextVNode","createCommentVNode"],"sources":["../../../src/components/Calendar/Calendar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, watch } from 'vue'\n\nimport {\n addDays,\n addMonths,\n differenceInDays,\n isSameDay,\n isSameMonth,\n startOfDay,\n startOfMonth,\n startOfWeek\n} from '../../utils/dates'\nimport Tooltip from '../Tooltip/Tooltip.vue'\nimport ChevronIcon from '../internal/ChevronIcon.vue'\n\nexport interface CalendarProps {\n /** Selects a day; with `end`, a range. */\n start?: Date | null\n end?: Date | null\n /** For the month's name; the browser's language by default. */\n locale?: string\n /** Monday first. */\n weekdays?: string[]\n previousLabel?: string\n nextLabel?: string\n}\n\nconst props = withDefaults(defineProps<CalendarProps>(), {\n start: null,\n end: null,\n locale: undefined,\n weekdays: () => ['M', 'T', 'W', 'T', 'F', 'S', 'S'],\n previousLabel: 'Previous month',\n nextLabel: 'Next month'\n})\n\nconst emit = defineEmits<{ pick: [date: Date] }>()\n\nconst view = ref(startOfMonth(props.end ?? props.start ?? new Date()))\n\n// Follows the selection to its month, when it's picked elsewhere (a shortcut, say).\nwatch(\n () => props.end ?? props.start,\n (date) => {\n if (date) view.value = startOfMonth(date)\n }\n)\n\nconst title = computed(() =>\n new Intl.DateTimeFormat(props.locale, { month: 'long', year: 'numeric' }).format(view.value)\n)\n\nconst shiftMonth = (months: number) => (view.value = addMonths(view.value, months))\n\nconst cells = computed(() => {\n const first = startOfWeek(view.value)\n const last = addDays(addMonths(view.value, 1), -1)\n const count = Math.ceil((differenceInDays(last, first) + 1) / 7) * 7\n const today = startOfDay(new Date())\n const [start, end] = [props.start, props.end].map((date) => (date ? startOfDay(date) : null))\n const ranged = !!start && !!end && !isSameDay(start, end)\n const [low, high] = ranged ? [start!, end!].sort((a, b) => a.getTime() - b.getTime()) : []\n\n return Array.from({ length: count }, (_, i) => {\n const date = addDays(first, i)\n const isStart = !!start && isSameDay(date, start)\n const isEnd = !!end && isSameDay(date, end)\n const selected = isStart || isEnd\n const inRange = ranged && date >= low! && date <= high!\n const isToday = isSameDay(date, today)\n const column = i % 7\n\n return {\n key: date.toISOString(),\n date,\n label: date.getDate(),\n selected,\n isToday,\n // The range is a band behind the days, rounded where it starts, ends or wraps.\n band: inRange\n ? ['bg-sui-accent-wash', (isStart || column === 0) && 'rounded-l-lg', (isEnd || column === 6) && 'rounded-r-lg']\n : '',\n classes: selected\n ? 'bg-sui-accent-solid font-semibold text-sui-on-accent'\n : [\n 'hover:bg-sui-sunken',\n isToday\n ? 'font-semibold text-sui-accent ring-1 ring-sui-accent-line ring-inset'\n : inRange\n ? 'font-medium text-sui-accent'\n : !isSameMonth(date, view.value) || date > today\n ? 'text-sui-ink-muted'\n : 'text-sui-ink'\n ]\n }\n })\n})\n</script>\n\n<!-- A month of days, weeks from Monday: today outlined with a dot, future days and other months muted. Picking a day\n emits it; the host decides what it selects. -->\n<template>\n <div>\n <div class=\"flex h-11 items-center justify-between\">\n <span class=\"pl-1.5 text-13 font-semibold text-sui-ink\">{{ title }}</span>\n <div class=\"flex gap-0.5\">\n <Tooltip :text=\"previousLabel\">\n <button\n :aria-label=\"previousLabel\"\n class=\"flex h-7 w-7 items-center justify-center rounded-lg transition-colors hover:bg-sui-sunken focus-visible:sui-ring\"\n type=\"button\"\n @click=\"shiftMonth(-1)\"\n >\n <ChevronIcon class=\"h-4 w-4 fill-sui-ink-body stroke-sui-ink-body\" direction=\"left\" />\n </button>\n </Tooltip>\n <Tooltip :text=\"nextLabel\">\n <button\n :aria-label=\"nextLabel\"\n class=\"flex h-7 w-7 items-center justify-center rounded-lg transition-colors hover:bg-sui-sunken focus-visible:sui-ring\"\n type=\"button\"\n @click=\"shiftMonth(1)\"\n >\n <ChevronIcon class=\"h-4 w-4 fill-sui-ink-body stroke-sui-ink-body\" direction=\"right\" />\n </button>\n </Tooltip>\n </div>\n </div>\n <div aria-hidden=\"true\" class=\"grid h-5.5 grid-cols-7 items-center\">\n <span v-for=\"(day, i) in weekdays\" :key=\"i\" class=\"text-center text-11 font-semibold text-sui-ink-muted\">\n {{ day }}\n </span>\n </div>\n <div class=\"mt-0.5 grid grid-cols-7 gap-y-0.5\">\n <button\n v-for=\"cell in cells\"\n :key=\"cell.key\"\n :aria-current=\"cell.isToday ? 'date' : undefined\"\n :aria-label=\"cell.date.toLocaleDateString(locale, { dateStyle: 'full' })\"\n :aria-pressed=\"cell.selected\"\n :class=\"['group flex h-9 items-center justify-center outline-hidden', cell.band]\"\n type=\"button\"\n @click=\"emit('pick', cell.date)\"\n >\n <span\n class=\"relative flex h-8.5 w-9 items-center justify-center rounded-lg text-13 tabular-nums transition-colors group-focus-visible:sui-ring\"\n :class=\"cell.classes\"\n >\n {{ cell.label }}\n <span\n v-if=\"cell.isToday\"\n class=\"absolute bottom-1 left-1/2 h-1 w-1 -translate-x-1/2 rounded-full\"\n :class=\"cell.selected ? 'bg-sui-on-accent' : 'bg-sui-accent-solid'\"\n />\n </span>\n </button>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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D;IAAG,OAAM;GAC7C,GAAAnD,EAAAoE,CAAG,GAAA,CAAA,E;GAGVrE,EAuBM,OAvBNmB,GAuBM,EAtBJrB,EAAA,EAAA,GAAAC,EAqBSO,GAAA,MAAAC,EApBQ4B,EAAA,QAAR,OADTrC,EAAA,GAAAC,EAqBS,UAAA;IAnBN,KAAKuE,EAAK;IACV,gBAAcA,EAAK,UAAO,SAAY,KAAA;IACtC,cAAYA,EAAK,KAAK,mBAAmB9C,EAAA,QAAM,EAAA,WAAA,OAAA,CAAA;IAC/C,gBAAc8C,EAAK;IACnB,OAAK9D,EAAA,CAAA,6DAAgE8D,EAAK,IAAI,CAAA;IAC/E,MAAK;IACJ,UAAK,MAAE7C,EAAI,QAAS6C,EAAK,IAAI;G,IAE9BtE,EAUO,QAAA,EATL,OAAKQ,EAAA,CAAC,sIACE8D,EAAK,OAAO,CAAA,E,IAEjB7D,EAAAR,EAAAqE,EAAK,KAAK,IAAG,KAChB,CAAA,GACQA,EAAK,WADbxE,EAAA,GAAAC,EAIE,QAAA;;IAFA,OAAKS,EAAA,CAAC,oEACE8D,EAAK,WAAQ,qBAAA,qBAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"Calendar.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_toDisplayString","_createVNode","Tooltip","_withCtx","ChevronIcon","_Fragment","_renderList","_normalizeClass","_createTextVNode","_createCommentVNode","Tooltip_default","ChevronIcon_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","Calendar_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","view","ref","startOfMonth","date","title","computed","dayNames","i","shiftMonth","addMonths","months","cells","first","startOfWeek","last","addDays","count","differenceInDays","today","startOfDay","start","end","ranged","isSameDay","low","high","a","b","isStart","isEnd","selected","inRange","isToday","column","isSameMonth","openBlock","createElementBlock","createElementVNode","toDisplayString","createVNode","withCtx","_cache","Fragment","renderList","day","cell","normalizeClass","createTextVNode","createCommentVNode"],"sources":["../../../src/components/Calendar/Calendar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, watch } from 'vue'\n\nimport {\n addDays,\n addMonths,\n differenceInDays,\n isSameDay,\n isSameMonth,\n startOfDay,\n startOfMonth,\n startOfWeek\n} from '../../utils/dates'\nimport Tooltip from '../Tooltip/Tooltip.vue'\nimport ChevronIcon from '../internal/ChevronIcon.vue'\n\nexport interface CalendarProps {\n /** Selects a day; with `end`, a range. */\n start?: Date | null\n end?: Date | null\n /** For the month's name and the weekdays; the browser's language by default. */\n locale?: string\n /** Monday first; the locale's narrow names by default. */\n weekdays?: string[]\n previousLabel?: string\n nextLabel?: string\n}\n\nconst props = withDefaults(defineProps<CalendarProps>(), {\n start: null,\n end: null,\n locale: undefined,\n weekdays: undefined,\n previousLabel: 'Previous month',\n nextLabel: 'Next month'\n})\n\nconst emit = defineEmits<{ pick: [date: Date] }>()\n\nconst view = ref(startOfMonth(props.end ?? props.start ?? new Date()))\n\n// Follows the selection to its month, when it's picked elsewhere (a shortcut, say).\nwatch(\n () => props.end ?? props.start,\n (date) => {\n if (date) view.value = startOfMonth(date)\n }\n)\n\nconst title = computed(() =>\n new Intl.DateTimeFormat(props.locale, { month: 'long', year: 'numeric' }).format(view.value)\n)\n\n// 1 January 2024 was a Monday.\nconst dayNames = computed(\n () =>\n props.weekdays ??\n Array.from({ length: 7 }, (_, i) =>\n new Intl.DateTimeFormat(props.locale, { weekday: 'narrow' }).format(new Date(2024, 0, 1 + i))\n )\n)\n\nconst shiftMonth = (months: number) => (view.value = addMonths(view.value, months))\n\nconst cells = computed(() => {\n const first = startOfWeek(view.value)\n const last = addDays(addMonths(view.value, 1), -1)\n const count = Math.ceil((differenceInDays(last, first) + 1) / 7) * 7\n const today = startOfDay(new Date())\n const [start, end] = [props.start, props.end].map((date) => (date ? startOfDay(date) : null))\n const ranged = !!start && !!end && !isSameDay(start, end)\n const [low, high] = ranged ? [start!, end!].sort((a, b) => a.getTime() - b.getTime()) : []\n\n return Array.from({ length: count }, (_, i) => {\n const date = addDays(first, i)\n const isStart = !!start && isSameDay(date, start)\n const isEnd = !!end && isSameDay(date, end)\n const selected = isStart || isEnd\n const inRange = ranged && date >= low! && date <= high!\n const isToday = isSameDay(date, today)\n const column = i % 7\n\n return {\n key: date.toISOString(),\n date,\n label: date.getDate(),\n selected,\n isToday,\n // The range is a band behind the days, rounded where it starts, ends or wraps.\n band: inRange\n ? ['bg-sui-accent-wash', (isStart || column === 0) && 'rounded-l-lg', (isEnd || column === 6) && 'rounded-r-lg']\n : '',\n classes: selected\n ? 'bg-sui-accent-solid font-semibold text-sui-on-accent'\n : [\n 'hover:bg-sui-sunken',\n isToday\n ? 'font-semibold text-sui-accent ring-1 ring-sui-accent-line ring-inset'\n : inRange\n ? 'font-medium text-sui-accent'\n : !isSameMonth(date, view.value) || date > today\n ? 'text-sui-ink-muted'\n : 'text-sui-ink'\n ]\n }\n })\n})\n</script>\n\n<!-- A month of days, weeks from Monday: today outlined with a dot, future days and other months muted. Picking a day\n emits it; the host decides what it selects. -->\n<template>\n <div>\n <div class=\"flex h-11 items-center justify-between\">\n <span class=\"pl-1.5 text-13 font-semibold text-sui-ink\">{{ title }}</span>\n <div class=\"flex gap-0.5\">\n <Tooltip :text=\"previousLabel\">\n <button\n :aria-label=\"previousLabel\"\n class=\"flex h-7 w-7 items-center justify-center rounded-lg transition-colors hover:bg-sui-sunken focus-visible:sui-ring\"\n type=\"button\"\n @click=\"shiftMonth(-1)\"\n >\n <ChevronIcon class=\"h-4 w-4 fill-sui-ink-body stroke-sui-ink-body\" direction=\"left\" />\n </button>\n </Tooltip>\n <Tooltip :text=\"nextLabel\">\n <button\n :aria-label=\"nextLabel\"\n class=\"flex h-7 w-7 items-center justify-center rounded-lg transition-colors hover:bg-sui-sunken focus-visible:sui-ring\"\n type=\"button\"\n @click=\"shiftMonth(1)\"\n >\n <ChevronIcon class=\"h-4 w-4 fill-sui-ink-body stroke-sui-ink-body\" direction=\"right\" />\n </button>\n </Tooltip>\n </div>\n </div>\n <div aria-hidden=\"true\" class=\"grid h-5.5 grid-cols-7 items-center\">\n <span v-for=\"(day, i) in dayNames\" :key=\"i\" class=\"text-center text-11 font-semibold text-sui-ink-muted\">\n {{ day }}\n </span>\n </div>\n <div class=\"mt-0.5 grid grid-cols-7 gap-y-0.5\">\n <button\n v-for=\"cell in cells\"\n :key=\"cell.key\"\n :aria-current=\"cell.isToday ? 'date' : undefined\"\n :aria-label=\"cell.date.toLocaleDateString(locale, { dateStyle: 'full' })\"\n :aria-pressed=\"cell.selected\"\n :class=\"['group flex h-9 items-center justify-center outline-hidden', cell.band]\"\n type=\"button\"\n @click=\"emit('pick', cell.date)\"\n >\n <span\n class=\"relative flex h-8.5 w-9 items-center justify-center rounded-lg text-13 tabular-nums transition-colors group-focus-visible:sui-ring\"\n :class=\"cell.classes\"\n >\n {{ cell.label }}\n <span\n v-if=\"cell.isToday\"\n class=\"absolute bottom-1 left-1/2 h-1 w-1 -translate-x-1/2 rounded-full\"\n :class=\"cell.selected ? 'bg-sui-on-accent' : 'bg-sui-accent-solid'\"\n />\n </span>\n </button>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EA4BA,IAAMyB,IAAQC,GASRC,IAAOH,GAEPI,IAAOC,EAAIC,EAAaL,EAAM,OAAOA,EAAM,yBAAS,IAAI,KAAK,CAAC,CAAC;EAGrE,QACQA,EAAM,OAAOA,EAAM,QACxB,MAAS;GACR,AAAIM,MAAM,EAAK,QAAQD,EAAaC,CAAI;EAC1C,CACF;EAEA,IAAMC,IAAQC,QACZ,IAAI,KAAK,eAAeR,EAAM,QAAQ;GAAE,OAAO;GAAQ,MAAM;EAAU,CAAC,CAAC,CAAC,OAAOG,EAAK,KAAK,CAC7F,GAGMM,IAAWD,QAEbR,EAAM,YACN,MAAM,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,MAC5B,IA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gBAAcA,EAAK,UAAO,SAAY,KAAA;IACtC,cAAYA,EAAK,KAAK,mBAAmB/C,EAAA,QAAM,EAAA,WAAA,OAAA,CAAA;IAC/C,gBAAc+C,EAAK;IACnB,OAAK/D,EAAA,CAAA,6DAAgE+D,EAAK,IAAI,CAAA;IAC/E,MAAK;IACJ,UAAK,MAAE9C,EAAI,QAAS8C,EAAK,IAAI;G,IAE9BvE,EAUO,QAAA,EATL,OAAKQ,EAAA,CAAC,sIACE+D,EAAK,OAAO,CAAA,E,IAEjB9D,EAAAR,EAAAsE,EAAK,KAAK,IAAG,KAChB,CAAA,GACQA,EAAK,WADbzE,EAAA,GAAAC,EAIE,QAAA;;IAFA,OAAKS,EAAA,CAAC,oEACE+D,EAAK,WAAQ,qBAAA,qBAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["_sfc_main","Dialog_vue_vue_type_script_setup_true_lang_default","Dialog_default"],"sources":["../../../src/components/Dialog/Dialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useSlots } from 'vue'\n\nimport { DialogContent, DialogOverlay, DialogPortal, DialogRoot, DialogTitle } from 'reka-ui'\n\nimport Button from '../Button/Button.vue'\nimport Icon from '../Icon/Icon.vue'\nimport Tooltip from '../Tooltip/Tooltip.vue'\nimport CloseIcon from '../internal/CloseIcon.vue'\nimport { focusFirst } from './focus'\n\nexport interface DialogProps {\n title?: string\n /** The close button in the header. */\n closable?: boolean\n closeLabel?: string\n cancelLabel?: string\n /** Shows the standard footer's confirm button, which emits `confirm`, as ⌘ or Ctrl Enter does. */\n confirmLabel?: string\n confirmIcon?: string\n confirmVariant?: 'primary' | 'danger' | 'contrast'\n confirmDisabled?: boolean\n /** sm 432px, md 512px, record 520px (the default with a band), lg 672px, xl 768px. */\n size?: 'sm' | 'md' | 'record' | 'lg' | 'xl'\n /** A record form's tinted header band: a CSS colour such as `rgb(var(--sui-hue-blue-soft))`, or `true` for the accent\n * wash. The `hero` slot sits centred in it. */\n band?: string | boolean\n /** Muted text at the footer's start, e.g. `saveHint()`. */\n hint?: string\n /** The body draws its own header, edge to edge. */\n headerless?: boolean\n}\n\nconst props = withDefaults(defineProps<DialogProps>(), {\n title: undefined,\n closable: true,\n closeLabel: 'Close',\n cancelLabel: 'Cancel',\n confirmLabel: undefined,\n confirmIcon: undefined,\n confirmVariant: 'primary',\n size: undefined,\n band: undefined,\n hint: undefined\n})\n\nconst emit = defineEmits<{ confirm: []; cancel: [] }>()\n\nconst open = defineModel<boolean>('open', { default: false })\n\nconst slots = useSlots()\nconst hasFooter = computed(() => !!slots.footer || !!props.confirmLabel)\nconst banded = computed(() => !!props.band || !!slots.hero)\n\nconst sizes = {\n sm: 'max-w-[27rem]',\n md: 'max-w-lg',\n record: 'max-w-130',\n lg: 'max-w-2xl',\n xl: 'max-w-3xl'\n}\nconst width = computed(() => sizes[props.size ?? (banded.value ? 'record' : 'md')])\nconst bandColour = computed(() => (typeof props.band === 'string' ? props.band : 'rgb(var(--sui-accent-wash))'))\n\nconst iconColours = { primary: 'on-accent', danger: 'on-danger', contrast: 'on-contrast' } as const\n\nfunction cancel() {\n emit('cancel')\n open.value = false\n}\n\nfunction confirmFromKeyboard(event: KeyboardEvent) {\n if (!event.metaKey && !event.ctrlKey) return\n event.preventDefault()\n if (props.confirmLabel && !props.confirmDisabled) emit('confirm')\n}\n</script>\n\n<!-- The one dialog: a header, body and canvas footer; or, with a `band` or `hero`, a record form under a tinted band. -->\n<template>\n <DialogRoot v-model:open=\"open\">\n <DialogPortal>\n <DialogOverlay\n class=\"fixed inset-0 z-[1100] flex items-center justify-center bg-sui-scrim/40 backdrop-blur-[4px] data-[state=closed]:animate-sui-scrim-out data-[state=open]:animate-sui-scrim-in\"\n >\n <DialogContent\n :aria-describedby=\"undefined\"\n class=\"flex max-h-[90vh] w-full flex-col bg-sui-surface shadow-xl outline-hidden data-[state=closed]:animate-sui-dialog-out data-[state=open]:animate-sui-dialog-in\"\n :class=\"[width, banded ? 'rounded-2xl' : 'rounded-xl']\"\n @escape-key-down=\"emit('cancel')\"\n @interact-outside.prevent\n @keydown.enter=\"confirmFromKeyboard\"\n @open-auto-focus=\"focusFirst\"\n >\n <div\n v-if=\"banded\"\n class=\"shrink-0 rounded-t-2xl pt-3.5 pr-3.5 pb-4.5 pl-5 transition-colors duration-200\"\n data-modal-header\n :style=\"{ backgroundColor: bandColour }\"\n >\n <div class=\"flex items-center justify-between gap-3\">\n <DialogTitle class=\"text-13 leading-5 font-medium text-sui-ink-body\">{{ title }}</DialogTitle>\n <Tooltip v-if=\"closable\" :text=\"closeLabel\">\n <Button :aria-label=\"closeLabel\" class=\"shrink-0\" icon-only size=\"sm\" variant=\"ghost\" @click=\"cancel\">\n <CloseIcon class=\"fill-sui-ink-muted stroke-sui-ink-muted\" />\n </Button>\n </Tooltip>\n </div>\n <div v-if=\"$slots.hero\" class=\"mt-0.5 flex flex-col items-center gap-1.5 pr-1.5\">\n <slot name=\"hero\" />\n </div>\n </div>\n <div\n v-else-if=\"!headerless\"\n class=\"flex shrink-0 items-center justify-between gap-3 rounded-t-xl border-b border-sui-line-subtle bg-sui-surface px-5 py-4 text-sui-ink\"\n data-modal-header\n >\n <DialogTitle class=\"min-w-0
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["_sfc_main","Dialog_vue_vue_type_script_setup_true_lang_default","Dialog_default"],"sources":["../../../src/components/Dialog/Dialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useSlots } from 'vue'\n\nimport { DialogContent, DialogOverlay, DialogPortal, DialogRoot, DialogTitle } from 'reka-ui'\n\nimport Button from '../Button/Button.vue'\nimport Icon from '../Icon/Icon.vue'\nimport Tooltip from '../Tooltip/Tooltip.vue'\nimport CloseIcon from '../internal/CloseIcon.vue'\nimport { focusFirst } from './focus'\n\nexport interface DialogProps {\n title?: string\n /** The close button in the header. */\n closable?: boolean\n closeLabel?: string\n cancelLabel?: string\n /** Shows the standard footer's confirm button, which emits `confirm`, as ⌘ or Ctrl Enter does. */\n confirmLabel?: string\n confirmIcon?: string\n confirmVariant?: 'primary' | 'danger' | 'contrast'\n confirmDisabled?: boolean\n /** sm 432px, md 512px, record 520px (the default with a band), lg 672px, xl 768px. */\n size?: 'sm' | 'md' | 'record' | 'lg' | 'xl'\n /** A record form's tinted header band: a CSS colour such as `rgb(var(--sui-hue-blue-soft))`, or `true` for the accent\n * wash. The `hero` slot sits centred in it. */\n band?: string | boolean\n /** Muted text at the footer's start, e.g. `saveHint()`. */\n hint?: string\n /** The body draws its own header, edge to edge. */\n headerless?: boolean\n}\n\nconst props = withDefaults(defineProps<DialogProps>(), {\n title: undefined,\n closable: true,\n closeLabel: 'Close',\n cancelLabel: 'Cancel',\n confirmLabel: undefined,\n confirmIcon: undefined,\n confirmVariant: 'primary',\n size: undefined,\n band: undefined,\n hint: undefined\n})\n\nconst emit = defineEmits<{ confirm: []; cancel: [] }>()\n\nconst open = defineModel<boolean>('open', { default: false })\n\nconst slots = useSlots()\nconst hasFooter = computed(() => !!slots.footer || !!props.confirmLabel)\nconst banded = computed(() => !!props.band || !!slots.hero)\n\nconst sizes = {\n sm: 'max-w-[27rem]',\n md: 'max-w-lg',\n record: 'max-w-130',\n lg: 'max-w-2xl',\n xl: 'max-w-3xl'\n}\nconst width = computed(() => sizes[props.size ?? (banded.value ? 'record' : 'md')])\nconst bandColour = computed(() => (typeof props.band === 'string' ? props.band : 'rgb(var(--sui-accent-wash))'))\n\nconst iconColours = { primary: 'on-accent', danger: 'on-danger', contrast: 'on-contrast' } as const\n\nfunction cancel() {\n emit('cancel')\n open.value = false\n}\n\nfunction confirmFromKeyboard(event: KeyboardEvent) {\n if (!event.metaKey && !event.ctrlKey) return\n event.preventDefault()\n if (props.confirmLabel && !props.confirmDisabled) emit('confirm')\n}\n</script>\n\n<!-- The one dialog: a header, body and canvas footer; or, with a `band` or `hero`, a record form under a tinted band. -->\n<template>\n <DialogRoot v-model:open=\"open\">\n <DialogPortal>\n <DialogOverlay\n class=\"fixed inset-0 z-[1100] flex items-center justify-center bg-sui-scrim/40 backdrop-blur-[4px] data-[state=closed]:animate-sui-scrim-out data-[state=open]:animate-sui-scrim-in\"\n >\n <DialogContent\n :aria-describedby=\"undefined\"\n class=\"flex max-h-[90vh] w-full flex-col bg-sui-surface shadow-xl outline-hidden data-[state=closed]:animate-sui-dialog-out data-[state=open]:animate-sui-dialog-in\"\n :class=\"[width, banded ? 'rounded-2xl' : 'rounded-xl']\"\n @escape-key-down=\"emit('cancel')\"\n @interact-outside.prevent\n @keydown.enter=\"confirmFromKeyboard\"\n @open-auto-focus=\"focusFirst\"\n >\n <div\n v-if=\"banded\"\n class=\"shrink-0 rounded-t-2xl pt-3.5 pr-3.5 pb-4.5 pl-5 transition-colors duration-200\"\n data-modal-header\n :style=\"{ backgroundColor: bandColour }\"\n >\n <div class=\"flex items-center justify-between gap-3\">\n <DialogTitle class=\"text-13 leading-5 font-medium text-sui-ink-body\">{{ title }}</DialogTitle>\n <Tooltip v-if=\"closable\" :text=\"closeLabel\">\n <Button :aria-label=\"closeLabel\" class=\"shrink-0\" icon-only size=\"sm\" variant=\"ghost\" @click=\"cancel\">\n <CloseIcon class=\"fill-sui-ink-muted stroke-sui-ink-muted\" />\n </Button>\n </Tooltip>\n </div>\n <div v-if=\"$slots.hero\" class=\"mt-0.5 flex flex-col items-center gap-1.5 pr-1.5\">\n <slot name=\"hero\" />\n </div>\n </div>\n <div\n v-else-if=\"!headerless\"\n class=\"flex shrink-0 items-center justify-between gap-3 rounded-t-xl border-b border-sui-line-subtle bg-sui-surface px-5 py-4 text-sui-ink\"\n data-modal-header\n >\n <DialogTitle class=\"min-w-0 truncate text-base font-semibold text-sui-ink\">\n <slot name=\"title\">{{ title }}</slot>\n </DialogTitle>\n <Tooltip v-if=\"closable\" :text=\"closeLabel\">\n <Button :aria-label=\"closeLabel\" class=\"shrink-0\" icon-only size=\"sm\" variant=\"ghost\" @click=\"cancel\">\n <CloseIcon class=\"fill-sui-ink-subtle stroke-sui-ink-subtle\" />\n </Button>\n </Tooltip>\n </div>\n <DialogTitle v-else class=\"sr-only\">{{ title }}</DialogTitle>\n\n <div\n class=\"overflow-y-auto bg-sui-surface text-sm text-sui-ink-emphasis\"\n :class=\"[banded ? 'px-5 pt-0.5 pb-4' : 'p-5', !hasFooter && (banded ? 'rounded-b-2xl' : 'rounded-b-xl')]\"\n data-modal-body\n >\n <slot />\n </div>\n\n <div\n v-if=\"hasFooter\"\n class=\"flex shrink-0 items-center border-t border-sui-line-subtle bg-sui-canvas text-sui-ink\"\n :class=\"banded ? 'gap-2 rounded-b-2xl py-3 pr-4 pl-5' : 'gap-3 rounded-b-xl px-5 py-4'\"\n data-modal-footer\n >\n <slot name=\"footer\">\n <slot name=\"footer-start\" />\n <span v-if=\"hint\" class=\"min-w-0 truncate text-xs text-sui-ink-muted\">{{ hint }}</span>\n <span class=\"flex-1\" />\n <Button type=\"button\" variant=\"ghost\" @click=\"cancel\">{{ cancelLabel }}</Button>\n <Button :disabled=\"confirmDisabled\" type=\"button\" :variant=\"confirmVariant\" @click=\"emit('confirm')\">\n <Icon v-if=\"confirmIcon\" :color=\"iconColours[confirmVariant]\" :name=\"confirmIcon\" />\n {{ confirmLabel }}\n </Button>\n </slot>\n </div>\n </DialogContent>\n </DialogOverlay>\n </DialogPortal>\n </DialogRoot>\n</template>\n"],"mappings":""}
|
|
@@ -14,12 +14,9 @@ var A = { class: "flex items-center justify-between gap-3" }, j = {
|
|
|
14
14
|
class: "flex shrink-0 items-center justify-between gap-3 rounded-t-xl border-b border-sui-line-subtle bg-sui-surface px-5 py-4 text-sui-ink",
|
|
15
15
|
"data-modal-header": ""
|
|
16
16
|
}, N = {
|
|
17
|
-
key: 0,
|
|
18
|
-
class: "truncate text-base font-semibold text-sui-ink"
|
|
19
|
-
}, P = {
|
|
20
17
|
key: 0,
|
|
21
18
|
class: "min-w-0 truncate text-xs text-sui-ink-muted"
|
|
22
|
-
},
|
|
19
|
+
}, P = /*@__PURE__*/ f({
|
|
23
20
|
__name: "Dialog",
|
|
24
21
|
props: /*@__PURE__*/ p({
|
|
25
22
|
title: { default: void 0 },
|
|
@@ -49,43 +46,43 @@ var A = { class: "flex items-center justify-between gap-3" }, j = {
|
|
|
49
46
|
}),
|
|
50
47
|
emits: /*@__PURE__*/ p(["confirm", "cancel"], ["update:open"]),
|
|
51
48
|
setup(f, { emit: p }) {
|
|
52
|
-
let
|
|
49
|
+
let P = f, F = p, I = b(f, "open"), L = x(), R = a(() => !!L.footer || !!P.confirmLabel), z = a(() => !!P.band || !!L.hero), B = {
|
|
53
50
|
sm: "max-w-[27rem]",
|
|
54
51
|
md: "max-w-lg",
|
|
55
52
|
record: "max-w-130",
|
|
56
53
|
lg: "max-w-2xl",
|
|
57
54
|
xl: "max-w-3xl"
|
|
58
|
-
},
|
|
55
|
+
}, V = a(() => B[P.size ?? (z.value ? "record" : "md")]), H = a(() => typeof P.band == "string" ? P.band : "rgb(var(--sui-accent-wash))"), U = {
|
|
59
56
|
primary: "on-accent",
|
|
60
57
|
danger: "on-danger",
|
|
61
58
|
contrast: "on-contrast"
|
|
62
59
|
};
|
|
63
|
-
function
|
|
64
|
-
|
|
60
|
+
function W() {
|
|
61
|
+
F("cancel"), I.value = !1;
|
|
65
62
|
}
|
|
66
|
-
function
|
|
67
|
-
(e.metaKey || e.ctrlKey) && (e.preventDefault(),
|
|
63
|
+
function G(e) {
|
|
64
|
+
(e.metaKey || e.ctrlKey) && (e.preventDefault(), P.confirmLabel && !P.confirmDisabled && F("confirm"));
|
|
68
65
|
}
|
|
69
66
|
return (a, p) => (g(), o(y(O), {
|
|
70
|
-
open:
|
|
71
|
-
"onUpdate:open": p[3] ||= (e) =>
|
|
67
|
+
open: I.value,
|
|
68
|
+
"onUpdate:open": p[3] ||= (e) => I.value = e
|
|
72
69
|
}, {
|
|
73
70
|
default: S(() => [d(y(D), null, {
|
|
74
71
|
default: S(() => [d(y(E), { class: "fixed inset-0 z-[1100] flex items-center justify-center bg-sui-scrim/40 backdrop-blur-[4px] data-[state=closed]:animate-sui-scrim-out data-[state=open]:animate-sui-scrim-in" }, {
|
|
75
72
|
default: S(() => [d(y(T), {
|
|
76
73
|
"aria-describedby": void 0,
|
|
77
|
-
class: m(["flex max-h-[90vh] w-full flex-col bg-sui-surface shadow-xl outline-hidden data-[state=closed]:animate-sui-dialog-out data-[state=open]:animate-sui-dialog-in", [
|
|
78
|
-
onEscapeKeyDown: p[1] ||= (e) =>
|
|
74
|
+
class: m(["flex max-h-[90vh] w-full flex-col bg-sui-surface shadow-xl outline-hidden data-[state=closed]:animate-sui-dialog-out data-[state=open]:animate-sui-dialog-in", [V.value, z.value ? "rounded-2xl" : "rounded-xl"]]),
|
|
75
|
+
onEscapeKeyDown: p[1] ||= (e) => F("cancel"),
|
|
79
76
|
onInteractOutside: p[2] ||= w(() => {}, ["prevent"]),
|
|
80
|
-
onKeydown: C(
|
|
77
|
+
onKeydown: C(G, ["enter"]),
|
|
81
78
|
onOpenAutoFocus: y(i)
|
|
82
79
|
}, {
|
|
83
80
|
default: S(() => [
|
|
84
|
-
|
|
81
|
+
z.value ? (g(), c("div", {
|
|
85
82
|
key: 0,
|
|
86
83
|
class: "shrink-0 rounded-t-2xl pt-3.5 pr-3.5 pb-4.5 pl-5 transition-colors duration-200",
|
|
87
84
|
"data-modal-header": "",
|
|
88
|
-
style: h({ backgroundColor:
|
|
85
|
+
style: h({ backgroundColor: H.value })
|
|
89
86
|
}, [l("div", A, [d(y(k), { class: "text-13 leading-5 font-medium text-sui-ink-body" }, {
|
|
90
87
|
default: S(() => [u(v(f.title), 1)]),
|
|
91
88
|
_: 1
|
|
@@ -99,7 +96,7 @@ var A = { class: "flex items-center justify-between gap-3" }, j = {
|
|
|
99
96
|
"icon-only": "",
|
|
100
97
|
size: "sm",
|
|
101
98
|
variant: "ghost",
|
|
102
|
-
onClick:
|
|
99
|
+
onClick: W
|
|
103
100
|
}, {
|
|
104
101
|
default: S(() => [d(r, { class: "fill-sui-ink-muted stroke-sui-ink-muted" })]),
|
|
105
102
|
_: 1
|
|
@@ -111,8 +108,8 @@ var A = { class: "flex items-center justify-between gap-3" }, j = {
|
|
|
111
108
|
}, {
|
|
112
109
|
default: S(() => [u(v(f.title), 1)]),
|
|
113
110
|
_: 1
|
|
114
|
-
})) : (g(), c("div", M, [d(y(k), { class: "min-w-0" }, {
|
|
115
|
-
default: S(() => [_(a.$slots, "title", {}, () => [
|
|
111
|
+
})) : (g(), c("div", M, [d(y(k), { class: "min-w-0 truncate text-base font-semibold text-sui-ink" }, {
|
|
112
|
+
default: S(() => [_(a.$slots, "title", {}, () => [u(v(f.title), 1)])]),
|
|
116
113
|
_: 3
|
|
117
114
|
}), f.closable ? (g(), o(n, {
|
|
118
115
|
key: 0,
|
|
@@ -124,7 +121,7 @@ var A = { class: "flex items-center justify-between gap-3" }, j = {
|
|
|
124
121
|
"icon-only": "",
|
|
125
122
|
size: "sm",
|
|
126
123
|
variant: "ghost",
|
|
127
|
-
onClick:
|
|
124
|
+
onClick: W
|
|
128
125
|
}, {
|
|
129
126
|
default: S(() => [d(r, { class: "fill-sui-ink-subtle stroke-sui-ink-subtle" })]),
|
|
130
127
|
_: 1
|
|
@@ -132,21 +129,21 @@ var A = { class: "flex items-center justify-between gap-3" }, j = {
|
|
|
132
129
|
_: 1
|
|
133
130
|
}, 8, ["text"])) : s("", !0)])),
|
|
134
131
|
l("div", {
|
|
135
|
-
class: m(["overflow-y-auto bg-sui-surface text-sm text-sui-ink-emphasis", [
|
|
132
|
+
class: m(["overflow-y-auto bg-sui-surface text-sm text-sui-ink-emphasis", [z.value ? "px-5 pt-0.5 pb-4" : "p-5", !R.value && (z.value ? "rounded-b-2xl" : "rounded-b-xl")]]),
|
|
136
133
|
"data-modal-body": ""
|
|
137
134
|
}, [_(a.$slots, "default")], 2),
|
|
138
|
-
|
|
135
|
+
R.value ? (g(), c("div", {
|
|
139
136
|
key: 3,
|
|
140
|
-
class: m(["flex shrink-0 items-center border-t border-sui-line-subtle bg-sui-canvas text-sui-ink",
|
|
137
|
+
class: m(["flex shrink-0 items-center border-t border-sui-line-subtle bg-sui-canvas text-sui-ink", z.value ? "gap-2 rounded-b-2xl py-3 pr-4 pl-5" : "gap-3 rounded-b-xl px-5 py-4"]),
|
|
141
138
|
"data-modal-footer": ""
|
|
142
139
|
}, [_(a.$slots, "footer", {}, () => [
|
|
143
140
|
_(a.$slots, "footer-start"),
|
|
144
|
-
f.hint ? (g(), c("span",
|
|
141
|
+
f.hint ? (g(), c("span", N, v(f.hint), 1)) : s("", !0),
|
|
145
142
|
p[4] ||= l("span", { class: "flex-1" }, null, -1),
|
|
146
143
|
d(e, {
|
|
147
144
|
type: "button",
|
|
148
145
|
variant: "ghost",
|
|
149
|
-
onClick:
|
|
146
|
+
onClick: W
|
|
150
147
|
}, {
|
|
151
148
|
default: S(() => [u(v(f.cancelLabel), 1)]),
|
|
152
149
|
_: 1
|
|
@@ -155,11 +152,11 @@ var A = { class: "flex items-center justify-between gap-3" }, j = {
|
|
|
155
152
|
disabled: f.confirmDisabled,
|
|
156
153
|
type: "button",
|
|
157
154
|
variant: f.confirmVariant,
|
|
158
|
-
onClick: p[0] ||= (e) =>
|
|
155
|
+
onClick: p[0] ||= (e) => F("confirm")
|
|
159
156
|
}, {
|
|
160
157
|
default: S(() => [f.confirmIcon ? (g(), o(t, {
|
|
161
158
|
key: 0,
|
|
162
|
-
color:
|
|
159
|
+
color: U[f.confirmVariant],
|
|
163
160
|
name: f.confirmIcon
|
|
164
161
|
}, null, 8, ["color", "name"])) : s("", !0), u(" " + v(f.confirmLabel), 1)]),
|
|
165
162
|
_: 1
|
|
@@ -177,6 +174,6 @@ var A = { class: "flex items-center justify-between gap-3" }, j = {
|
|
|
177
174
|
}
|
|
178
175
|
});
|
|
179
176
|
//#endregion
|
|
180
|
-
export {
|
|
177
|
+
export { P as default };
|
|
181
178
|
|
|
182
179
|
//# sourceMappingURL=Dialog.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.vue_vue_type_script_setup_true_lang.js","names":["$slots","_useModel","_openBlock","_createBlock","_unref","_withCtx","_createVNode","_normalizeClass","_withModifiers","_withKeys","_createElementBlock","_normalizeStyle","_createElementVNode","_createTextVNode","_toDisplayString","Tooltip","Button","CloseIcon","_createCommentVNode","_renderSlot","Icon","Button_default","Icon_default","Tooltip_default","CloseIcon_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","Dialog_vue_vue_type_script_setup_true_lang_default","\"open\"","\"openModifiers\"","__emit","props","__props","emit","open","useModel","slots","useSlots","hasFooter","computed","banded","sizes","width","bandColour","iconColours","cancel","confirmFromKeyboard","event","openBlock","createBlock","unref","DialogRoot","_cache","$event","withCtx","createVNode","DialogPortal","DialogOverlay","DialogContent","normalizeClass","withModifiers","withKeys","focusFirst","createElementBlock","normalizeStyle","createElementVNode","DialogTitle","createTextVNode","toDisplayString","createCommentVNode","_ctx","renderSlot"],"sources":["../../../src/components/Dialog/Dialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useSlots } from 'vue'\n\nimport { DialogContent, DialogOverlay, DialogPortal, DialogRoot, DialogTitle } from 'reka-ui'\n\nimport Button from '../Button/Button.vue'\nimport Icon from '../Icon/Icon.vue'\nimport Tooltip from '../Tooltip/Tooltip.vue'\nimport CloseIcon from '../internal/CloseIcon.vue'\nimport { focusFirst } from './focus'\n\nexport interface DialogProps {\n title?: string\n /** The close button in the header. */\n closable?: boolean\n closeLabel?: string\n cancelLabel?: string\n /** Shows the standard footer's confirm button, which emits `confirm`, as ⌘ or Ctrl Enter does. */\n confirmLabel?: string\n confirmIcon?: string\n confirmVariant?: 'primary' | 'danger' | 'contrast'\n confirmDisabled?: boolean\n /** sm 432px, md 512px, record 520px (the default with a band), lg 672px, xl 768px. */\n size?: 'sm' | 'md' | 'record' | 'lg' | 'xl'\n /** A record form's tinted header band: a CSS colour such as `rgb(var(--sui-hue-blue-soft))`, or `true` for the accent\n * wash. The `hero` slot sits centred in it. */\n band?: string | boolean\n /** Muted text at the footer's start, e.g. `saveHint()`. */\n hint?: string\n /** The body draws its own header, edge to edge. */\n headerless?: boolean\n}\n\nconst props = withDefaults(defineProps<DialogProps>(), {\n title: undefined,\n closable: true,\n closeLabel: 'Close',\n cancelLabel: 'Cancel',\n confirmLabel: undefined,\n confirmIcon: undefined,\n confirmVariant: 'primary',\n size: undefined,\n band: undefined,\n hint: undefined\n})\n\nconst emit = defineEmits<{ confirm: []; cancel: [] }>()\n\nconst open = defineModel<boolean>('open', { default: false })\n\nconst slots = useSlots()\nconst hasFooter = computed(() => !!slots.footer || !!props.confirmLabel)\nconst banded = computed(() => !!props.band || !!slots.hero)\n\nconst sizes = {\n sm: 'max-w-[27rem]',\n md: 'max-w-lg',\n record: 'max-w-130',\n lg: 'max-w-2xl',\n xl: 'max-w-3xl'\n}\nconst width = computed(() => sizes[props.size ?? (banded.value ? 'record' : 'md')])\nconst bandColour = computed(() => (typeof props.band === 'string' ? props.band : 'rgb(var(--sui-accent-wash))'))\n\nconst iconColours = { primary: 'on-accent', danger: 'on-danger', contrast: 'on-contrast' } as const\n\nfunction cancel() {\n emit('cancel')\n open.value = false\n}\n\nfunction confirmFromKeyboard(event: KeyboardEvent) {\n if (!event.metaKey && !event.ctrlKey) return\n event.preventDefault()\n if (props.confirmLabel && !props.confirmDisabled) emit('confirm')\n}\n</script>\n\n<!-- The one dialog: a header, body and canvas footer; or, with a `band` or `hero`, a record form under a tinted band. -->\n<template>\n <DialogRoot v-model:open=\"open\">\n <DialogPortal>\n <DialogOverlay\n class=\"fixed inset-0 z-[1100] flex items-center justify-center bg-sui-scrim/40 backdrop-blur-[4px] data-[state=closed]:animate-sui-scrim-out data-[state=open]:animate-sui-scrim-in\"\n >\n <DialogContent\n :aria-describedby=\"undefined\"\n class=\"flex max-h-[90vh] w-full flex-col bg-sui-surface shadow-xl outline-hidden data-[state=closed]:animate-sui-dialog-out data-[state=open]:animate-sui-dialog-in\"\n :class=\"[width, banded ? 'rounded-2xl' : 'rounded-xl']\"\n @escape-key-down=\"emit('cancel')\"\n @interact-outside.prevent\n @keydown.enter=\"confirmFromKeyboard\"\n @open-auto-focus=\"focusFirst\"\n >\n <div\n v-if=\"banded\"\n class=\"shrink-0 rounded-t-2xl pt-3.5 pr-3.5 pb-4.5 pl-5 transition-colors duration-200\"\n data-modal-header\n :style=\"{ backgroundColor: bandColour }\"\n >\n <div class=\"flex items-center justify-between gap-3\">\n <DialogTitle class=\"text-13 leading-5 font-medium text-sui-ink-body\">{{ title }}</DialogTitle>\n <Tooltip v-if=\"closable\" :text=\"closeLabel\">\n <Button :aria-label=\"closeLabel\" class=\"shrink-0\" icon-only size=\"sm\" variant=\"ghost\" @click=\"cancel\">\n <CloseIcon class=\"fill-sui-ink-muted stroke-sui-ink-muted\" />\n </Button>\n </Tooltip>\n </div>\n <div v-if=\"$slots.hero\" class=\"mt-0.5 flex flex-col items-center gap-1.5 pr-1.5\">\n <slot name=\"hero\" />\n </div>\n </div>\n <div\n v-else-if=\"!headerless\"\n class=\"flex shrink-0 items-center justify-between gap-3 rounded-t-xl border-b border-sui-line-subtle bg-sui-surface px-5 py-4 text-sui-ink\"\n data-modal-header\n >\n <DialogTitle class=\"min-w-0\">\n <slot name=\"title\">\n <h2 v-if=\"title\" class=\"truncate text-base font-semibold text-sui-ink\">{{ title }}</h2>\n </slot>\n </DialogTitle>\n <Tooltip v-if=\"closable\" :text=\"closeLabel\">\n <Button :aria-label=\"closeLabel\" class=\"shrink-0\" icon-only size=\"sm\" variant=\"ghost\" @click=\"cancel\">\n <CloseIcon class=\"fill-sui-ink-subtle stroke-sui-ink-subtle\" />\n </Button>\n </Tooltip>\n </div>\n <DialogTitle v-else class=\"sr-only\">{{ title }}</DialogTitle>\n\n <div\n class=\"overflow-y-auto bg-sui-surface text-sm text-sui-ink-emphasis\"\n :class=\"[banded ? 'px-5 pt-0.5 pb-4' : 'p-5', !hasFooter && (banded ? 'rounded-b-2xl' : 'rounded-b-xl')]\"\n data-modal-body\n >\n <slot />\n </div>\n\n <div\n v-if=\"hasFooter\"\n class=\"flex shrink-0 items-center border-t border-sui-line-subtle bg-sui-canvas text-sui-ink\"\n :class=\"banded ? 'gap-2 rounded-b-2xl py-3 pr-4 pl-5' : 'gap-3 rounded-b-xl px-5 py-4'\"\n data-modal-footer\n >\n <slot name=\"footer\">\n <slot name=\"footer-start\" />\n <span v-if=\"hint\" class=\"min-w-0 truncate text-xs text-sui-ink-muted\">{{ hint }}</span>\n <span class=\"flex-1\" />\n <Button type=\"button\" variant=\"ghost\" @click=\"cancel\">{{ cancelLabel }}</Button>\n <Button :disabled=\"confirmDisabled\" type=\"button\" :variant=\"confirmVariant\" @click=\"emit('confirm')\">\n <Icon v-if=\"confirmIcon\" :color=\"iconColours[confirmVariant]\" :name=\"confirmIcon\" />\n {{ confirmLabel }}\n </Button>\n </slot>\n </div>\n </DialogContent>\n </DialogOverlay>\n </DialogPortal>\n </DialogRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCA,IAAMkC,IAAQC,GAaRC,IAAOH,GAEPI,IAAOpC,EAAoBkC,GAAC,MAA0B,GAEtDI,IAAQC,EAAS,GACjBC,IAAYC,QAAe,CAAC,CAACH,EAAM,UAAU,CAAC,CAACL,EAAM,YAAY,GACjES,IAASD,QAAe,CAAC,CAACR,EAAM,QAAQ,CAAC,CAACK,EAAM,IAAI,GAEpDK,IAAQ;GACZ,IAAI;GACJ,IAAI;GACJ,QAAQ;GACR,IAAI;GACJ,IAAI;EACN,GACMC,IAAQH,QAAeE,EAAMV,EAAM,SAASS,EAAO,QAAQ,WAAW,MAAM,GAC5EG,IAAaJ,QAAgB,OAAOR,EAAM,QAAS,WAAWA,EAAM,OAAO,6BAA8B,GAEzGa,IAAc;GAAE,SAAS;GAAa,QAAQ;GAAa,UAAU;EAAc;E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AAQsD,EAAA,QAAA,SAAA,C;OAIFhC,EAAA,SADRvC,EAAA,GAAAQ,EAgBM,OAAA;;QAdJ,OAAKH,EAAA,CAAC,yFACEoC,EAAA,QAAM,uCAAA,8BAAA,CAAA;QACd,qBAAA;O,IAEAxB,EASOsD,EAAA,QAAA,UAAA,CAAA,SAAA;QARLtD,EAA4BsD,EAAA,QAAA,cAAA;QAChBtC,EAAA,QAAZjC,EAAA,GAAAQ,EAAuF,QAAvFmB,GAAuFf,EAAdqB,EAAA,IAAI,GAAA,CAAA,K;QAC7E,AAAAoB,EAAA,OAAA3C,EAAuB,QAAA,EAAjB,OAAM,SAAQ,GAAA,MAAA,EAAA;QACpBN,EAAgFU,GAAA;SAAxE,MAAK;SAAS,SAAQ;SAAS,SAAOgC;;SAAQ,SAAA3C,QAAiB,CAAdQ,EAAAC,EAAAqB,EAAA,WAAW,GAAA,CAAA,C;;;QACpE7B,EAGSU,GAAA;SAHA,UAAUmB,EAAA;SAAiB,MAAK;SAAU,SAASA,EAAA;SAAiB,SAAK,AAAAoB,EAAA,QAAA,MAAEnB,EAAI,SAAA;;SACtF,SAAA/B,QAAoF,CAAxE8B,EAAA,eAAZjC,EAAA,GAAAC,EAAoFiB,GAAA;;UAA1D,OAAO2B,EAAYZ,EAAA;UAAkB,MAAMA,EAAA;S,6CAAetB,EAAA,MACpFC,EAAGqB,EAAA,YAAY,GAAA,CAAA,C"}
|
|
1
|
+
{"version":3,"file":"Dialog.vue_vue_type_script_setup_true_lang.js","names":["$slots","_useModel","_openBlock","_createBlock","_unref","_withCtx","_createVNode","_normalizeClass","_withModifiers","_withKeys","_createElementBlock","_normalizeStyle","_createElementVNode","_createTextVNode","_toDisplayString","Tooltip","Button","CloseIcon","_createCommentVNode","_renderSlot","Icon","Button_default","Icon_default","Tooltip_default","CloseIcon_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","Dialog_vue_vue_type_script_setup_true_lang_default","\"open\"","\"openModifiers\"","__emit","props","__props","emit","open","useModel","slots","useSlots","hasFooter","computed","banded","sizes","width","bandColour","iconColours","cancel","confirmFromKeyboard","event","openBlock","createBlock","unref","DialogRoot","_cache","$event","withCtx","createVNode","DialogPortal","DialogOverlay","DialogContent","normalizeClass","withModifiers","withKeys","focusFirst","createElementBlock","normalizeStyle","createElementVNode","DialogTitle","createTextVNode","toDisplayString","createCommentVNode","_ctx","renderSlot"],"sources":["../../../src/components/Dialog/Dialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useSlots } from 'vue'\n\nimport { DialogContent, DialogOverlay, DialogPortal, DialogRoot, DialogTitle } from 'reka-ui'\n\nimport Button from '../Button/Button.vue'\nimport Icon from '../Icon/Icon.vue'\nimport Tooltip from '../Tooltip/Tooltip.vue'\nimport CloseIcon from '../internal/CloseIcon.vue'\nimport { focusFirst } from './focus'\n\nexport interface DialogProps {\n title?: string\n /** The close button in the header. */\n closable?: boolean\n closeLabel?: string\n cancelLabel?: string\n /** Shows the standard footer's confirm button, which emits `confirm`, as ⌘ or Ctrl Enter does. */\n confirmLabel?: string\n confirmIcon?: string\n confirmVariant?: 'primary' | 'danger' | 'contrast'\n confirmDisabled?: boolean\n /** sm 432px, md 512px, record 520px (the default with a band), lg 672px, xl 768px. */\n size?: 'sm' | 'md' | 'record' | 'lg' | 'xl'\n /** A record form's tinted header band: a CSS colour such as `rgb(var(--sui-hue-blue-soft))`, or `true` for the accent\n * wash. The `hero` slot sits centred in it. */\n band?: string | boolean\n /** Muted text at the footer's start, e.g. `saveHint()`. */\n hint?: string\n /** The body draws its own header, edge to edge. */\n headerless?: boolean\n}\n\nconst props = withDefaults(defineProps<DialogProps>(), {\n title: undefined,\n closable: true,\n closeLabel: 'Close',\n cancelLabel: 'Cancel',\n confirmLabel: undefined,\n confirmIcon: undefined,\n confirmVariant: 'primary',\n size: undefined,\n band: undefined,\n hint: undefined\n})\n\nconst emit = defineEmits<{ confirm: []; cancel: [] }>()\n\nconst open = defineModel<boolean>('open', { default: false })\n\nconst slots = useSlots()\nconst hasFooter = computed(() => !!slots.footer || !!props.confirmLabel)\nconst banded = computed(() => !!props.band || !!slots.hero)\n\nconst sizes = {\n sm: 'max-w-[27rem]',\n md: 'max-w-lg',\n record: 'max-w-130',\n lg: 'max-w-2xl',\n xl: 'max-w-3xl'\n}\nconst width = computed(() => sizes[props.size ?? (banded.value ? 'record' : 'md')])\nconst bandColour = computed(() => (typeof props.band === 'string' ? props.band : 'rgb(var(--sui-accent-wash))'))\n\nconst iconColours = { primary: 'on-accent', danger: 'on-danger', contrast: 'on-contrast' } as const\n\nfunction cancel() {\n emit('cancel')\n open.value = false\n}\n\nfunction confirmFromKeyboard(event: KeyboardEvent) {\n if (!event.metaKey && !event.ctrlKey) return\n event.preventDefault()\n if (props.confirmLabel && !props.confirmDisabled) emit('confirm')\n}\n</script>\n\n<!-- The one dialog: a header, body and canvas footer; or, with a `band` or `hero`, a record form under a tinted band. -->\n<template>\n <DialogRoot v-model:open=\"open\">\n <DialogPortal>\n <DialogOverlay\n class=\"fixed inset-0 z-[1100] flex items-center justify-center bg-sui-scrim/40 backdrop-blur-[4px] data-[state=closed]:animate-sui-scrim-out data-[state=open]:animate-sui-scrim-in\"\n >\n <DialogContent\n :aria-describedby=\"undefined\"\n class=\"flex max-h-[90vh] w-full flex-col bg-sui-surface shadow-xl outline-hidden data-[state=closed]:animate-sui-dialog-out data-[state=open]:animate-sui-dialog-in\"\n :class=\"[width, banded ? 'rounded-2xl' : 'rounded-xl']\"\n @escape-key-down=\"emit('cancel')\"\n @interact-outside.prevent\n @keydown.enter=\"confirmFromKeyboard\"\n @open-auto-focus=\"focusFirst\"\n >\n <div\n v-if=\"banded\"\n class=\"shrink-0 rounded-t-2xl pt-3.5 pr-3.5 pb-4.5 pl-5 transition-colors duration-200\"\n data-modal-header\n :style=\"{ backgroundColor: bandColour }\"\n >\n <div class=\"flex items-center justify-between gap-3\">\n <DialogTitle class=\"text-13 leading-5 font-medium text-sui-ink-body\">{{ title }}</DialogTitle>\n <Tooltip v-if=\"closable\" :text=\"closeLabel\">\n <Button :aria-label=\"closeLabel\" class=\"shrink-0\" icon-only size=\"sm\" variant=\"ghost\" @click=\"cancel\">\n <CloseIcon class=\"fill-sui-ink-muted stroke-sui-ink-muted\" />\n </Button>\n </Tooltip>\n </div>\n <div v-if=\"$slots.hero\" class=\"mt-0.5 flex flex-col items-center gap-1.5 pr-1.5\">\n <slot name=\"hero\" />\n </div>\n </div>\n <div\n v-else-if=\"!headerless\"\n class=\"flex shrink-0 items-center justify-between gap-3 rounded-t-xl border-b border-sui-line-subtle bg-sui-surface px-5 py-4 text-sui-ink\"\n data-modal-header\n >\n <DialogTitle class=\"min-w-0 truncate text-base font-semibold text-sui-ink\">\n <slot name=\"title\">{{ title }}</slot>\n </DialogTitle>\n <Tooltip v-if=\"closable\" :text=\"closeLabel\">\n <Button :aria-label=\"closeLabel\" class=\"shrink-0\" icon-only size=\"sm\" variant=\"ghost\" @click=\"cancel\">\n <CloseIcon class=\"fill-sui-ink-subtle stroke-sui-ink-subtle\" />\n </Button>\n </Tooltip>\n </div>\n <DialogTitle v-else class=\"sr-only\">{{ title }}</DialogTitle>\n\n <div\n class=\"overflow-y-auto bg-sui-surface text-sm text-sui-ink-emphasis\"\n :class=\"[banded ? 'px-5 pt-0.5 pb-4' : 'p-5', !hasFooter && (banded ? 'rounded-b-2xl' : 'rounded-b-xl')]\"\n data-modal-body\n >\n <slot />\n </div>\n\n <div\n v-if=\"hasFooter\"\n class=\"flex shrink-0 items-center border-t border-sui-line-subtle bg-sui-canvas text-sui-ink\"\n :class=\"banded ? 'gap-2 rounded-b-2xl py-3 pr-4 pl-5' : 'gap-3 rounded-b-xl px-5 py-4'\"\n data-modal-footer\n >\n <slot name=\"footer\">\n <slot name=\"footer-start\" />\n <span v-if=\"hint\" class=\"min-w-0 truncate text-xs text-sui-ink-muted\">{{ hint }}</span>\n <span class=\"flex-1\" />\n <Button type=\"button\" variant=\"ghost\" @click=\"cancel\">{{ cancelLabel }}</Button>\n <Button :disabled=\"confirmDisabled\" type=\"button\" :variant=\"confirmVariant\" @click=\"emit('confirm')\">\n <Icon v-if=\"confirmIcon\" :color=\"iconColours[confirmVariant]\" :name=\"confirmIcon\" />\n {{ confirmLabel }}\n </Button>\n </slot>\n </div>\n </DialogContent>\n </DialogOverlay>\n </DialogPortal>\n </DialogRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCA,IAAMiC,IAAQC,GAaRC,IAAOH,GAEPI,IAAOnC,EAAoBiC,GAAC,MAA0B,GAEtDI,IAAQC,EAAS,GACjBC,IAAYC,QAAe,CAAC,CAACH,EAAM,UAAU,CAAC,CAACL,EAAM,YAAY,GACjES,IAASD,QAAe,CAAC,CAACR,EAAM,QAAQ,CAAC,CAACK,EAAM,IAAI,GAEpDK,IAAQ;GACZ,IAAI;GACJ,IAAI;GACJ,QAAQ;GACR,IAAI;GACJ,IAAI;EACN,GACMC,IAAQH,QAAeE,EAAMV,EAAM,SAASS,EAAO,QAAQ,WAAW,MAAM,GAC5EG,IAAaJ,QAAgB,OAAOR,EAAM,QAAS,WAAWA,EAAM,OAAO,6BAA8B,GAEzGa,IAAc;GAAE,SAAS;GAAa,QAAQ;GAAa,UAAU;EAAc;EAEzF,SAASC,IAAS;GAEhB,AADAZ,EAAK,QAAQ,GACb,EAAK,QAAQ;EACf;EAEA,SAASa,EAAoB,GAAsB;GACjD,CAAKC,EAAM,WAAYA,EAAM,aAC7BA,EAAM,eAAe,GACjBhB,EAAM,gBAAgB,CAACA,EAAM,mBAAiBE,EAAK,SAAS;EAClE;E,kBAKEjC,EAAA,GAAAC,EA4EaC,EAAAiD,CAAA,GAAA;GA5EO,MAAMjB,EAAA;GAAA,iBAAA,AAAAkB,EAAA,QAAA,MAAA,EAAI,QAAAC;;GAC5B,SAAAlD,QA0Ee,CA1EfC,EA0EeF,EAAAsD,CAAA,GAAA,MAAA;IAzEb,SAAArD,QA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AS,SAAO+B;;SAAQ,SAAA1C,QAAiB,CAAdQ,EAAAC,EAAAoB,EAAA,WAAW,GAAA,CAAA,C;;;QACpE5B,EAGSU,GAAA;SAHA,UAAUkB,EAAA;SAAiB,MAAK;SAAU,SAASA,EAAA;SAAiB,SAAK,AAAAoB,EAAA,QAAA,MAAEnB,EAAI,SAAA;;SACtF,SAAA9B,QAAoF,CAAxE6B,EAAA,eAAZhC,EAAA,GAAAC,EAAoFiB,GAAA;;UAA1D,OAAO0B,EAAYZ,EAAA;UAAkB,MAAMA,EAAA;S,6CAAerB,EAAA,MACpFC,EAAGoB,EAAA,YAAY,GAAA,CAAA,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.js","names":["_sfc_main","DropdownMenu_vue_vue_type_script_setup_true_lang_default","DropdownMenu_default"],"sources":["../../../src/components/DropdownMenu/DropdownMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref } from 'vue'\n\nimport {\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuPortal,\n DropdownMenuRoot,\n DropdownMenuSeparator,\n DropdownMenuTrigger\n} from 'reka-ui'\n\nimport { useConfirm } from '../../composables/useConfirm'\nimport Button from '../Button/Button.vue'\nimport Icon from '../Icon/Icon.vue'\nimport Tooltip from '../Tooltip/Tooltip.vue'\n\nexport interface DropdownMenuAction {\n type: 'action'\n label: string\n action?: string\n icon?: string\n variant?: 'danger'\n shortcut?: string\n /** Asks first, with this wording; `confirmed: true` asks with the generic wording. */\n confirm?: { message: string; title?: string; acceptLabel?: string }\n confirmed?: boolean\n [key: string]: unknown\n}\n\nexport type DropdownMenuEntry = DropdownMenuAction | { type: 'separator' }\n\nexport interface DropdownMenuProps {\n /** Passed back with every clicked item, e.g. the record the menu acts on. */\n id?: string\n items?: DropdownMenuEntry[]\n buttonIcon?: string\n /** A label beside the icon; without one the button is icon-only, named by the tooltip. */\n buttonLabel?: string\n /** The trigger's tooltip and name; null for none. */\n tooltip?: string | null\n /** Lines the menu up with the trigger's start or end edge. */\n align?: 'start' | 'end'\n confirmTitle?: string\n confirmMessage?: string\n confirmLabel?: string\n deleteLabel?: string\n cancelLabel?: string\n}\n\nconst props = withDefaults(defineProps<DropdownMenuProps>(), {\n id: undefined,\n items: () => [],\n buttonIcon: 'more-vertical',\n buttonLabel: undefined,\n tooltip: 'More actions',\n align: 'start',\n confirmTitle: 'Are you sure?',\n confirmMessage: \"This can't be undone.\",\n confirmLabel: 'Confirm',\n deleteLabel: 'Delete',\n cancelLabel: 'Cancel'\n})\n\nconst emit = defineEmits<{ 'click-item': [item: DropdownMenuAction & { id?: string }]; show: []; hide: [] }>()\n\nconst open = ref(false)\nconst confirm = useConfirm()\n\nasync function select(item: DropdownMenuAction) {\n if (item.confirm || item.confirmed) {\n const destructive = item.variant === 'danger' || item.action === 'delete'\n const confirmed = await confirm({\n title: item.confirm?.title ?? props.confirmTitle,\n message: item.confirm?.message ?? props.confirmMessage,\n cancelLabel: props.cancelLabel,\n confirmLabel: item.confirm?.acceptLabel ?? (item.action === 'delete' ? props.deleteLabel : props.confirmLabel),\n confirmVariant: destructive ? 'danger' : 'primary'\n })\n if (!confirmed) return\n }\n emit('click-item', { id: props.id, ...item })\n}\n\nfunction onOpenChange(value: boolean) {\n open.value = value\n if (value) emit('show')\n else emit('hide')\n}\n</script>\n\n<template>\n <div>\n <!-- Not modal: the page stays live (hover, scroll) while it's open. -->\n <DropdownMenuRoot :modal=\"false\" :open=\"open\" @update:open=\"onOpenChange\">\n <!-- The tooltip inside the menu's trigger: Reka's anchors attach to the nearest popper, which must be the menu's. -->\n <DropdownMenuTrigger as-child>\n <Tooltip :disabled=\"!tooltip || open\" :text=\"tooltip ?? undefined\">\n <slot name=\"trigger\" :open=\"open\">\n <Button\n :aria-label=\"buttonLabel ? undefined : (tooltip ?? undefined)\"\n :icon-only=\"!buttonLabel\"\n size=\"sm\"\n type=\"button\"\n variant=\"ghost\"\n @click.stop\n >\n <span v-if=\"buttonLabel\">{{ buttonLabel }}</span>\n <Icon v-if=\"buttonIcon\" color=\"ink-subtle\" :name=\"buttonIcon\" />\n </Button>\n </slot>\n </Tooltip>\n </DropdownMenuTrigger>\n <DropdownMenuPortal>\n <DropdownMenuContent\n :align=\"align\"\n class=\"z-[
|
|
1
|
+
{"version":3,"file":"DropdownMenu.js","names":["_sfc_main","DropdownMenu_vue_vue_type_script_setup_true_lang_default","DropdownMenu_default"],"sources":["../../../src/components/DropdownMenu/DropdownMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref } from 'vue'\n\nimport {\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuPortal,\n DropdownMenuRoot,\n DropdownMenuSeparator,\n DropdownMenuTrigger\n} from 'reka-ui'\n\nimport { useConfirm } from '../../composables/useConfirm'\nimport Button from '../Button/Button.vue'\nimport Icon from '../Icon/Icon.vue'\nimport Tooltip from '../Tooltip/Tooltip.vue'\n\nexport interface DropdownMenuAction {\n type: 'action'\n label: string\n action?: string\n icon?: string\n variant?: 'danger'\n shortcut?: string\n /** Asks first, with this wording; `confirmed: true` asks with the generic wording. */\n confirm?: { message: string; title?: string; acceptLabel?: string }\n confirmed?: boolean\n [key: string]: unknown\n}\n\nexport type DropdownMenuEntry = DropdownMenuAction | { type: 'separator' }\n\nexport interface DropdownMenuProps {\n /** Passed back with every clicked item, e.g. the record the menu acts on. */\n id?: string\n items?: DropdownMenuEntry[]\n buttonIcon?: string\n /** A label beside the icon; without one the button is icon-only, named by the tooltip. */\n buttonLabel?: string\n /** The trigger's tooltip and name; null for none. */\n tooltip?: string | null\n /** Lines the menu up with the trigger's start or end edge. */\n align?: 'start' | 'end'\n confirmTitle?: string\n confirmMessage?: string\n confirmLabel?: string\n deleteLabel?: string\n cancelLabel?: string\n}\n\nconst props = withDefaults(defineProps<DropdownMenuProps>(), {\n id: undefined,\n items: () => [],\n buttonIcon: 'more-vertical',\n buttonLabel: undefined,\n tooltip: 'More actions',\n align: 'start',\n confirmTitle: 'Are you sure?',\n confirmMessage: \"This can't be undone.\",\n confirmLabel: 'Confirm',\n deleteLabel: 'Delete',\n cancelLabel: 'Cancel'\n})\n\nconst emit = defineEmits<{ 'click-item': [item: DropdownMenuAction & { id?: string }]; show: []; hide: [] }>()\n\nconst open = ref(false)\nconst confirm = useConfirm()\n\nasync function select(item: DropdownMenuAction) {\n if (item.confirm || item.confirmed) {\n const destructive = item.variant === 'danger' || item.action === 'delete'\n const confirmed = await confirm({\n title: item.confirm?.title ?? props.confirmTitle,\n message: item.confirm?.message ?? props.confirmMessage,\n cancelLabel: props.cancelLabel,\n confirmLabel: item.confirm?.acceptLabel ?? (item.action === 'delete' ? props.deleteLabel : props.confirmLabel),\n confirmVariant: destructive ? 'danger' : 'primary'\n })\n if (!confirmed) return\n }\n emit('click-item', { id: props.id, ...item })\n}\n\nfunction onOpenChange(value: boolean) {\n open.value = value\n if (value) emit('show')\n else emit('hide')\n}\n</script>\n\n<template>\n <div>\n <!-- Not modal: the page stays live (hover, scroll) while it's open. -->\n <DropdownMenuRoot :modal=\"false\" :open=\"open\" @update:open=\"onOpenChange\">\n <!-- The tooltip inside the menu's trigger: Reka's anchors attach to the nearest popper, which must be the menu's. -->\n <DropdownMenuTrigger as-child>\n <Tooltip :disabled=\"!tooltip || open\" :text=\"tooltip ?? undefined\">\n <slot name=\"trigger\" :open=\"open\">\n <Button\n :aria-label=\"buttonLabel ? undefined : (tooltip ?? undefined)\"\n :icon-only=\"!buttonLabel\"\n size=\"sm\"\n type=\"button\"\n variant=\"ghost\"\n @click.stop\n >\n <span v-if=\"buttonLabel\">{{ buttonLabel }}</span>\n <Icon v-if=\"buttonIcon\" color=\"ink-subtle\" :name=\"buttonIcon\" />\n </Button>\n </slot>\n </Tooltip>\n </DropdownMenuTrigger>\n <DropdownMenuPortal>\n <DropdownMenuContent\n :align=\"align\"\n class=\"z-[1100] min-w-[max(12rem,var(--reka-dropdown-menu-trigger-width))] rounded-xl border border-sui-line-subtle bg-sui-surface p-1 shadow-lg outline-hidden data-[state=open]:animate-sui-menu-in\"\n side=\"bottom\"\n >\n <template v-for=\"(item, index) in items\" :key=\"index\">\n <DropdownMenuSeparator v-if=\"item.type === 'separator'\" class=\"my-1 border-t border-sui-line-subtle\" />\n <DropdownMenuItem\n v-else\n class=\"relative rounded-lg text-sm text-sui-ink transition-colors duration-150 outline-hidden hover:bg-sui-sunken focus-visible:sui-ring-inset data-highlighted:bg-sui-sunken\"\n @select=\"select(item)\"\n >\n <div\n class=\"flex cursor-pointer items-center gap-2.5 px-2.5 py-1.5\"\n :class=\"item.variant === 'danger' ? 'text-sui-danger' : 'text-sui-ink'\"\n >\n <Icon\n v-if=\"item.icon\"\n class=\"h-4 w-4 shrink-0\"\n :color=\"item.variant === 'danger' ? 'danger' : 'ink-muted'\"\n :name=\"item.icon\"\n />\n <span class=\"flex-1 text-13\">{{ item.label }}</span>\n <span v-if=\"item.shortcut\" class=\"text-11 text-sui-ink-muted\">{{ item.shortcut }}</span>\n </div>\n </DropdownMenuItem>\n </template>\n </DropdownMenuContent>\n </DropdownMenuPortal>\n </DropdownMenuRoot>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -80,7 +80,7 @@ var E = { key: 0 }, D = { class: "flex-1 text-13" }, O = {
|
|
|
80
80
|
}), l(_(S), null, {
|
|
81
81
|
default: v(() => [l(_(b), {
|
|
82
82
|
align: u.align,
|
|
83
|
-
class: "z-[
|
|
83
|
+
class: "z-[1100] min-w-[max(12rem,var(--reka-dropdown-menu-trigger-width))] rounded-xl border border-sui-line-subtle bg-sui-surface p-1 shadow-lg outline-hidden data-[state=open]:animate-sui-menu-in",
|
|
84
84
|
side: "bottom"
|
|
85
85
|
}, {
|
|
86
86
|
default: v(() => [(f(!0), s(i, null, m(u.items, (e, n) => (f(), s(i, { key: n }, [e.type === "separator" ? (f(), a(_(w), {
|
package/dist/components/DropdownMenu/DropdownMenu.vue_vue_type_script_setup_true_lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createVNode","_unref","_withCtx","Tooltip","_renderSlot","Button","_withModifiers","_toDisplayString","_createCommentVNode","_createBlock","Icon","_Fragment","_renderList","_createElementVNode","_normalizeClass","Button_default","Icon_default","Tooltip_default","_hoisted_1","_hoisted_2","_hoisted_3","DropdownMenu_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","open","ref","confirm","useConfirm","select","item","destructive","onOpenChange","value","openBlock","createElementBlock","createVNode","unref","DropdownMenuRoot","withCtx","DropdownMenuTrigger","renderSlot","_ctx","_cache","withModifiers","toDisplayString","createCommentVNode","createBlock","DropdownMenuPortal","DropdownMenuContent","Fragment","renderList","index","DropdownMenuSeparator","DropdownMenuItem","createElementVNode","normalizeClass"],"sources":["../../../src/components/DropdownMenu/DropdownMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref } from 'vue'\n\nimport {\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuPortal,\n DropdownMenuRoot,\n DropdownMenuSeparator,\n DropdownMenuTrigger\n} from 'reka-ui'\n\nimport { useConfirm } from '../../composables/useConfirm'\nimport Button from '../Button/Button.vue'\nimport Icon from '../Icon/Icon.vue'\nimport Tooltip from '../Tooltip/Tooltip.vue'\n\nexport interface DropdownMenuAction {\n type: 'action'\n label: string\n action?: string\n icon?: string\n variant?: 'danger'\n shortcut?: string\n /** Asks first, with this wording; `confirmed: true` asks with the generic wording. */\n confirm?: { message: string; title?: string; acceptLabel?: string }\n confirmed?: boolean\n [key: string]: unknown\n}\n\nexport type DropdownMenuEntry = DropdownMenuAction | { type: 'separator' }\n\nexport interface DropdownMenuProps {\n /** Passed back with every clicked item, e.g. the record the menu acts on. */\n id?: string\n items?: DropdownMenuEntry[]\n buttonIcon?: string\n /** A label beside the icon; without one the button is icon-only, named by the tooltip. */\n buttonLabel?: string\n /** The trigger's tooltip and name; null for none. */\n tooltip?: string | null\n /** Lines the menu up with the trigger's start or end edge. */\n align?: 'start' | 'end'\n confirmTitle?: string\n confirmMessage?: string\n confirmLabel?: string\n deleteLabel?: string\n cancelLabel?: string\n}\n\nconst props = withDefaults(defineProps<DropdownMenuProps>(), {\n id: undefined,\n items: () => [],\n buttonIcon: 'more-vertical',\n buttonLabel: undefined,\n tooltip: 'More actions',\n align: 'start',\n confirmTitle: 'Are you sure?',\n confirmMessage: \"This can't be undone.\",\n confirmLabel: 'Confirm',\n deleteLabel: 'Delete',\n cancelLabel: 'Cancel'\n})\n\nconst emit = defineEmits<{ 'click-item': [item: DropdownMenuAction & { id?: string }]; show: []; hide: [] }>()\n\nconst open = ref(false)\nconst confirm = useConfirm()\n\nasync function select(item: DropdownMenuAction) {\n if (item.confirm || item.confirmed) {\n const destructive = item.variant === 'danger' || item.action === 'delete'\n const confirmed = await confirm({\n title: item.confirm?.title ?? props.confirmTitle,\n message: item.confirm?.message ?? props.confirmMessage,\n cancelLabel: props.cancelLabel,\n confirmLabel: item.confirm?.acceptLabel ?? (item.action === 'delete' ? props.deleteLabel : props.confirmLabel),\n confirmVariant: destructive ? 'danger' : 'primary'\n })\n if (!confirmed) return\n }\n emit('click-item', { id: props.id, ...item })\n}\n\nfunction onOpenChange(value: boolean) {\n open.value = value\n if (value) emit('show')\n else emit('hide')\n}\n</script>\n\n<template>\n <div>\n <!-- Not modal: the page stays live (hover, scroll) while it's open. -->\n <DropdownMenuRoot :modal=\"false\" :open=\"open\" @update:open=\"onOpenChange\">\n <!-- The tooltip inside the menu's trigger: Reka's anchors attach to the nearest popper, which must be the menu's. -->\n <DropdownMenuTrigger as-child>\n <Tooltip :disabled=\"!tooltip || open\" :text=\"tooltip ?? undefined\">\n <slot name=\"trigger\" :open=\"open\">\n <Button\n :aria-label=\"buttonLabel ? undefined : (tooltip ?? undefined)\"\n :icon-only=\"!buttonLabel\"\n size=\"sm\"\n type=\"button\"\n variant=\"ghost\"\n @click.stop\n >\n <span v-if=\"buttonLabel\">{{ buttonLabel }}</span>\n <Icon v-if=\"buttonIcon\" color=\"ink-subtle\" :name=\"buttonIcon\" />\n </Button>\n </slot>\n </Tooltip>\n </DropdownMenuTrigger>\n <DropdownMenuPortal>\n <DropdownMenuContent\n :align=\"align\"\n class=\"z-[
|
|
1
|
+
{"version":3,"file":"DropdownMenu.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createVNode","_unref","_withCtx","Tooltip","_renderSlot","Button","_withModifiers","_toDisplayString","_createCommentVNode","_createBlock","Icon","_Fragment","_renderList","_createElementVNode","_normalizeClass","Button_default","Icon_default","Tooltip_default","_hoisted_1","_hoisted_2","_hoisted_3","DropdownMenu_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","open","ref","confirm","useConfirm","select","item","destructive","onOpenChange","value","openBlock","createElementBlock","createVNode","unref","DropdownMenuRoot","withCtx","DropdownMenuTrigger","renderSlot","_ctx","_cache","withModifiers","toDisplayString","createCommentVNode","createBlock","DropdownMenuPortal","DropdownMenuContent","Fragment","renderList","index","DropdownMenuSeparator","DropdownMenuItem","createElementVNode","normalizeClass"],"sources":["../../../src/components/DropdownMenu/DropdownMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref } from 'vue'\n\nimport {\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuPortal,\n DropdownMenuRoot,\n DropdownMenuSeparator,\n DropdownMenuTrigger\n} from 'reka-ui'\n\nimport { useConfirm } from '../../composables/useConfirm'\nimport Button from '../Button/Button.vue'\nimport Icon from '../Icon/Icon.vue'\nimport Tooltip from '../Tooltip/Tooltip.vue'\n\nexport interface DropdownMenuAction {\n type: 'action'\n label: string\n action?: string\n icon?: string\n variant?: 'danger'\n shortcut?: string\n /** Asks first, with this wording; `confirmed: true` asks with the generic wording. */\n confirm?: { message: string; title?: string; acceptLabel?: string }\n confirmed?: boolean\n [key: string]: unknown\n}\n\nexport type DropdownMenuEntry = DropdownMenuAction | { type: 'separator' }\n\nexport interface DropdownMenuProps {\n /** Passed back with every clicked item, e.g. the record the menu acts on. */\n id?: string\n items?: DropdownMenuEntry[]\n buttonIcon?: string\n /** A label beside the icon; without one the button is icon-only, named by the tooltip. */\n buttonLabel?: string\n /** The trigger's tooltip and name; null for none. */\n tooltip?: string | null\n /** Lines the menu up with the trigger's start or end edge. */\n align?: 'start' | 'end'\n confirmTitle?: string\n confirmMessage?: string\n confirmLabel?: string\n deleteLabel?: string\n cancelLabel?: string\n}\n\nconst props = withDefaults(defineProps<DropdownMenuProps>(), {\n id: undefined,\n items: () => [],\n buttonIcon: 'more-vertical',\n buttonLabel: undefined,\n tooltip: 'More actions',\n align: 'start',\n confirmTitle: 'Are you sure?',\n confirmMessage: \"This can't be undone.\",\n confirmLabel: 'Confirm',\n deleteLabel: 'Delete',\n cancelLabel: 'Cancel'\n})\n\nconst emit = defineEmits<{ 'click-item': [item: DropdownMenuAction & { id?: string }]; show: []; hide: [] }>()\n\nconst open = ref(false)\nconst confirm = useConfirm()\n\nasync function select(item: DropdownMenuAction) {\n if (item.confirm || item.confirmed) {\n const destructive = item.variant === 'danger' || item.action === 'delete'\n const confirmed = await confirm({\n title: item.confirm?.title ?? props.confirmTitle,\n message: item.confirm?.message ?? props.confirmMessage,\n cancelLabel: props.cancelLabel,\n confirmLabel: item.confirm?.acceptLabel ?? (item.action === 'delete' ? props.deleteLabel : props.confirmLabel),\n confirmVariant: destructive ? 'danger' : 'primary'\n })\n if (!confirmed) return\n }\n emit('click-item', { id: props.id, ...item })\n}\n\nfunction onOpenChange(value: boolean) {\n open.value = value\n if (value) emit('show')\n else emit('hide')\n}\n</script>\n\n<template>\n <div>\n <!-- Not modal: the page stays live (hover, scroll) while it's open. -->\n <DropdownMenuRoot :modal=\"false\" :open=\"open\" @update:open=\"onOpenChange\">\n <!-- The tooltip inside the menu's trigger: Reka's anchors attach to the nearest popper, which must be the menu's. -->\n <DropdownMenuTrigger as-child>\n <Tooltip :disabled=\"!tooltip || open\" :text=\"tooltip ?? undefined\">\n <slot name=\"trigger\" :open=\"open\">\n <Button\n :aria-label=\"buttonLabel ? undefined : (tooltip ?? undefined)\"\n :icon-only=\"!buttonLabel\"\n size=\"sm\"\n type=\"button\"\n variant=\"ghost\"\n @click.stop\n >\n <span v-if=\"buttonLabel\">{{ buttonLabel }}</span>\n <Icon v-if=\"buttonIcon\" color=\"ink-subtle\" :name=\"buttonIcon\" />\n </Button>\n </slot>\n </Tooltip>\n </DropdownMenuTrigger>\n <DropdownMenuPortal>\n <DropdownMenuContent\n :align=\"align\"\n class=\"z-[1100] min-w-[max(12rem,var(--reka-dropdown-menu-trigger-width))] rounded-xl border border-sui-line-subtle bg-sui-surface p-1 shadow-lg outline-hidden data-[state=open]:animate-sui-menu-in\"\n side=\"bottom\"\n >\n <template v-for=\"(item, index) in items\" :key=\"index\">\n <DropdownMenuSeparator v-if=\"item.type === 'separator'\" class=\"my-1 border-t border-sui-line-subtle\" />\n <DropdownMenuItem\n v-else\n class=\"relative rounded-lg text-sm text-sui-ink transition-colors duration-150 outline-hidden hover:bg-sui-sunken focus-visible:sui-ring-inset data-highlighted:bg-sui-sunken\"\n @select=\"select(item)\"\n >\n <div\n class=\"flex cursor-pointer items-center gap-2.5 px-2.5 py-1.5\"\n :class=\"item.variant === 'danger' ? 'text-sui-danger' : 'text-sui-ink'\"\n >\n <Icon\n v-if=\"item.icon\"\n class=\"h-4 w-4 shrink-0\"\n :color=\"item.variant === 'danger' ? 'danger' : 'ink-muted'\"\n :name=\"item.icon\"\n />\n <span class=\"flex-1 text-13\">{{ item.label }}</span>\n <span v-if=\"item.shortcut\" class=\"text-11 text-sui-ink-muted\">{{ item.shortcut }}</span>\n </div>\n </DropdownMenuItem>\n </template>\n </DropdownMenuContent>\n </DropdownMenuPortal>\n </DropdownMenuRoot>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkDA,IAAMyB,IAAQC,GAcRC,IAAOH,GAEPI,IAAOC,EAAI,EAAK,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