mood-ui 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data-display/calendar/AgendaView.cjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.mjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.cjs +11 -6
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs +18 -13
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.cjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.mjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs +14 -9
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs +22 -17
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.cjs +1 -1
- package/dist/components/data-display/calendar/MonthView.cjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.mjs +1 -1
- package/dist/components/data-display/calendar/MonthView.mjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.cjs +15 -17
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs +18 -20
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.cjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.mjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.cjs +14 -9
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs +22 -17
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.cjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.mjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.cjs +14 -9
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs +22 -17
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs +3 -3
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.cjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.cjs +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs +3 -3
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Drawer.cjs.map +1 -1
- package/dist/components/feedback/Drawer.mjs.map +1 -1
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.cjs +4 -9
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs +9 -14
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Modal.cjs.map +1 -1
- package/dist/components/feedback/Modal.mjs.map +1 -1
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.cjs +4 -9
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs +9 -14
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Tooltip.cjs.map +1 -1
- package/dist/components/feedback/Tooltip.mjs.map +1 -1
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs +44 -17
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs +44 -17
- package/dist/components/feedback/Tooltip.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/Combobox.cjs.map +1 -1
- package/dist/components/forms/Combobox.mjs.map +1 -1
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/forms/Combobox.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/PhoneInput.cjs.map +1 -1
- package/dist/components/forms/PhoneInput.mjs.map +1 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.cjs +6 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.mjs +6 -1
- package/dist/components/forms/PhoneInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/forms/SearchInput.cjs.map +1 -1
- package/dist/components/forms/SearchInput.mjs.map +1 -1
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs +8 -6
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs +8 -6
- package/dist/components/forms/SearchInput.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/layout/PopoverPanel.cjs +1 -1
- package/dist/components/layout/PopoverPanel.cjs.map +1 -1
- package/dist/components/layout/PopoverPanel.mjs +1 -1
- package/dist/components/layout/PopoverPanel.mjs.map +1 -1
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs +2 -2
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/layout/PopoverPanel.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/navigation/Switcher.cjs.map +1 -1
- package/dist/components/navigation/Switcher.mjs.map +1 -1
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs +38 -40
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs +38 -40
- package/dist/components/navigation/Switcher.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/composables/eventColors.cjs +51 -27
- package/dist/composables/eventColors.cjs.map +1 -1
- package/dist/composables/eventColors.mjs +51 -27
- package/dist/composables/eventColors.mjs.map +1 -1
- package/dist/composables/useBodyScrollLock.cjs +44 -0
- package/dist/composables/useBodyScrollLock.cjs.map +1 -0
- package/dist/composables/useBodyScrollLock.mjs +43 -0
- package/dist/composables/useBodyScrollLock.mjs.map +1 -0
- package/dist/composables/useCalendarTheme.cjs +29 -8
- package/dist/composables/useCalendarTheme.cjs.map +1 -1
- package/dist/composables/useCalendarTheme.mjs +29 -8
- package/dist/composables/useCalendarTheme.mjs.map +1 -1
- package/dist/composables/usePopover.cjs +44 -12
- package/dist/composables/usePopover.cjs.map +1 -1
- package/dist/composables/usePopover.mjs +44 -12
- package/dist/composables/usePopover.mjs.map +1 -1
- package/dist/mood-ui.css +9 -9
- package/dist/types/composables/eventColors.d.ts +2 -2
- package/dist/types/composables/useBodyScrollLock.d.ts +19 -0
- package/dist/types/composables/useCalendarTheme.d.ts +2 -0
- package/dist/types/interfaces/data-display/calendar/AgendaView.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/DayView.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/MonthView.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/Scheduler.interface.d.ts +5 -0
- package/dist/types/interfaces/data-display/calendar/WeekView.interface.d.ts +5 -0
- package/dist/types/utils/calendarTooltip.d.ts +13 -0
- package/dist/types/utils/cssLength.d.ts +5 -0
- package/dist/types/utils/tooltipArrow.d.ts +34 -0
- package/dist/utils/calendarTooltip.cjs +18 -0
- package/dist/utils/calendarTooltip.cjs.map +1 -0
- package/dist/utils/calendarTooltip.mjs +18 -0
- package/dist/utils/calendarTooltip.mjs.map +1 -0
- package/dist/utils/cssLength.cjs +13 -0
- package/dist/utils/cssLength.cjs.map +1 -0
- package/dist/utils/cssLength.mjs +13 -0
- package/dist/utils/cssLength.mjs.map +1 -0
- package/dist/utils/tooltipArrow.cjs +37 -0
- package/dist/utils/tooltipArrow.cjs.map +1 -0
- package/dist/utils/tooltipArrow.mjs +36 -0
- package/dist/utils/tooltipArrow.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -1,33 +1,57 @@
|
|
|
1
1
|
//#region src/composables/eventColors.ts
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/** Translucent fill + text colour, soft variant used in timed grids. */
|
|
3
|
+
var FILL = {
|
|
4
|
+
default: "bg-foreground/10 text-foreground",
|
|
5
|
+
primary: "bg-primary/15 text-primary",
|
|
6
|
+
danger: "bg-destructive/15 text-destructive",
|
|
7
|
+
success: "bg-success/15 text-success",
|
|
8
|
+
warning: "bg-warning/15 text-warning",
|
|
9
|
+
info: "bg-info/15 text-info",
|
|
10
|
+
purple: "bg-purple/15 text-purple",
|
|
11
|
+
pink: "bg-pink/15 text-pink"
|
|
12
|
+
};
|
|
13
|
+
/** Same, a touch more opaque so compact MonthView pills stay readable. */
|
|
14
|
+
var FILL_STRONG = {
|
|
15
|
+
default: "bg-foreground/15 text-foreground",
|
|
16
|
+
primary: "bg-primary/20 text-primary",
|
|
17
|
+
danger: "bg-destructive/20 text-destructive",
|
|
18
|
+
success: "bg-success/20 text-success",
|
|
19
|
+
warning: "bg-warning/20 text-warning",
|
|
20
|
+
info: "bg-info/20 text-info",
|
|
21
|
+
purple: "bg-purple/20 text-purple",
|
|
22
|
+
pink: "bg-pink/20 text-pink"
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Left colour rule. Kept separate from the fill because it only works on a
|
|
26
|
+
* squarish event: `border-radius` sweeps a one-sided border around the corner
|
|
27
|
+
* arc, so at a large radius the rule tapers into a crescent instead of reading
|
|
28
|
+
* as a bar — see `EVENT_ACCENT_RADII` in `useCalendarTheme`.
|
|
29
|
+
*/
|
|
30
|
+
var ACCENT = {
|
|
31
|
+
default: "border-l-2 border-muted-foreground",
|
|
32
|
+
primary: "border-l-2 border-primary",
|
|
33
|
+
danger: "border-l-2 border-destructive",
|
|
34
|
+
success: "border-l-2 border-success",
|
|
35
|
+
warning: "border-l-2 border-warning",
|
|
36
|
+
info: "border-l-2 border-info",
|
|
37
|
+
purple: "border-l-2 border-purple",
|
|
38
|
+
pink: "border-l-2 border-pink"
|
|
39
|
+
};
|
|
40
|
+
var compose = (fills, c, accent) => {
|
|
41
|
+
const key = c ?? "primary";
|
|
42
|
+
return accent ? `${fills[key]} ${ACCENT[key]}` : fills[key];
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Soft variant used in timed grids (WeekView, DayView, Scheduler).
|
|
46
|
+
* Translucent fills (`/15`) so the underlying grid lines stay visible —
|
|
47
|
+
* matches the look of `colorHex` events that use `rgba(..., 0.12)`.
|
|
6
48
|
*/
|
|
7
|
-
var eventColorClass = (c) => (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
success: "bg-success/15 text-success border-l-2 border-success",
|
|
12
|
-
warning: "bg-warning/15 text-warning border-l-2 border-warning",
|
|
13
|
-
info: "bg-info/15 text-info border-l-2 border-info",
|
|
14
|
-
purple: "bg-purple/15 text-purple border-l-2 border-purple",
|
|
15
|
-
pink: "bg-pink/15 text-pink border-l-2 border-pink"
|
|
16
|
-
})[c ?? "primary"];
|
|
17
|
-
/**
|
|
18
|
-
* Stronger variant used in MonthView (pill-like events) — slightly more
|
|
19
|
-
* opaque to stay readable in compact pills.
|
|
49
|
+
var eventColorClass = (c, accent = true) => compose(FILL, c, accent);
|
|
50
|
+
/**
|
|
51
|
+
* Stronger variant used in MonthView (pill-like events) — slightly more
|
|
52
|
+
* opaque to stay readable in compact pills.
|
|
20
53
|
*/
|
|
21
|
-
var eventColorClassStrong = (c) => (
|
|
22
|
-
default: "bg-foreground/15 text-foreground border-l-2 border-muted-foreground",
|
|
23
|
-
primary: "bg-primary/20 text-primary border-l-2 border-primary",
|
|
24
|
-
danger: "bg-destructive/20 text-destructive border-l-2 border-destructive",
|
|
25
|
-
success: "bg-success/20 text-success border-l-2 border-success",
|
|
26
|
-
warning: "bg-warning/20 text-warning border-l-2 border-warning",
|
|
27
|
-
info: "bg-info/20 text-info border-l-2 border-info",
|
|
28
|
-
purple: "bg-purple/20 text-purple border-l-2 border-purple",
|
|
29
|
-
pink: "bg-pink/20 text-pink border-l-2 border-pink"
|
|
30
|
-
})[c ?? "primary"];
|
|
54
|
+
var eventColorClassStrong = (c, accent = true) => compose(FILL_STRONG, c, accent);
|
|
31
55
|
var hexToRgba = (hex, alpha) => {
|
|
32
56
|
const h = hex.replace("#", "");
|
|
33
57
|
const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventColors.mjs","names":[],"sources":["../../src/composables/eventColors.ts"],"sourcesContent":["export type EventColor = 'default' | 'primary' | 'danger' | 'success' | 'warning' | 'info' | 'purple' | 'pink'
|
|
1
|
+
{"version":3,"file":"eventColors.mjs","names":[],"sources":["../../src/composables/eventColors.ts"],"sourcesContent":["export type EventColor = 'default' | 'primary' | 'danger' | 'success' | 'warning' | 'info' | 'purple' | 'pink';\n\n/** Translucent fill + text colour, soft variant used in timed grids. */\nconst FILL: Record<EventColor, string> = {\n default: 'bg-foreground/10 text-foreground',\n primary: 'bg-primary/15 text-primary',\n danger: 'bg-destructive/15 text-destructive',\n success: 'bg-success/15 text-success',\n warning: 'bg-warning/15 text-warning',\n info: 'bg-info/15 text-info',\n purple: 'bg-purple/15 text-purple',\n pink: 'bg-pink/15 text-pink',\n};\n\n/** Same, a touch more opaque so compact MonthView pills stay readable. */\nconst FILL_STRONG: Record<EventColor, string> = {\n default: 'bg-foreground/15 text-foreground',\n primary: 'bg-primary/20 text-primary',\n danger: 'bg-destructive/20 text-destructive',\n success: 'bg-success/20 text-success',\n warning: 'bg-warning/20 text-warning',\n info: 'bg-info/20 text-info',\n purple: 'bg-purple/20 text-purple',\n pink: 'bg-pink/20 text-pink',\n};\n\n/**\n * Left colour rule. Kept separate from the fill because it only works on a\n * squarish event: `border-radius` sweeps a one-sided border around the corner\n * arc, so at a large radius the rule tapers into a crescent instead of reading\n * as a bar — see `EVENT_ACCENT_RADII` in `useCalendarTheme`.\n */\nconst ACCENT: Record<EventColor, string> = {\n default: 'border-l-2 border-muted-foreground',\n primary: 'border-l-2 border-primary',\n danger: 'border-l-2 border-destructive',\n success: 'border-l-2 border-success',\n warning: 'border-l-2 border-warning',\n info: 'border-l-2 border-info',\n purple: 'border-l-2 border-purple',\n pink: 'border-l-2 border-pink',\n};\n\nconst compose = (\n fills: Record<EventColor, string>,\n c: EventColor | null | undefined,\n accent: boolean,\n) => {\n const key = c ?? 'primary';\n return accent ? `${fills[key]} ${ACCENT[key]}` : fills[key];\n};\n\n/**\n * Soft variant used in timed grids (WeekView, DayView, Scheduler).\n * Translucent fills (`/15`) so the underlying grid lines stay visible —\n * matches the look of `colorHex` events that use `rgba(..., 0.12)`.\n */\nexport const eventColorClass = (c?: EventColor | null, accent = true) =>\n compose(FILL, c, accent);\n\n/**\n * Stronger variant used in MonthView (pill-like events) — slightly more\n * opaque to stay readable in compact pills.\n */\nexport const eventColorClassStrong = (c?: EventColor | null, accent = true) =>\n compose(FILL_STRONG, c, accent);\n\nexport const hexToRgba = (hex: string, alpha: number) => {\n const h = hex.replace('#', '');\n const full = h.length === 3 ? h.split('').map(c => c + c).join('') : h;\n const r = parseInt(full.slice(0, 2), 16);\n const g = parseInt(full.slice(2, 4), 16);\n const b = parseInt(full.slice(4, 6), 16);\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n};\n"],"mappings":";;AAGA,IAAM,OAAmC;CACrC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,MAAM;CACN,QAAQ;CACR,MAAM;CACT;;AAGD,IAAM,cAA0C;CAC5C,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,MAAM;CACN,QAAQ;CACR,MAAM;CACT;;;;;;;AAQD,IAAM,SAAqC;CACvC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,MAAM;CACN,QAAQ;CACR,MAAM;CACT;AAED,IAAM,WACF,OACA,GACA,WACC;CACD,MAAM,MAAM,KAAK;CACjB,OAAO,SAAS,GAAG,MAAM,KAAK,GAAG,OAAO,SAAS,MAAM;;;;;;;AAQ3D,IAAa,mBAAmB,GAAuB,SAAS,SAC5D,QAAQ,MAAM,GAAG,OAAO;;;;;AAM5B,IAAa,yBAAyB,GAAuB,SAAS,SAClE,QAAQ,aAAa,GAAG,OAAO;AAEnC,IAAa,aAAa,KAAa,UAAkB;CACrD,MAAM,IAAI,IAAI,QAAQ,KAAK,GAAG;CAC9B,MAAM,OAAO,EAAE,WAAW,IAAI,EAAE,MAAM,GAAG,CAAC,KAAI,MAAK,IAAI,EAAE,CAAC,KAAK,GAAG,GAAG;CAIrE,OAAO,QAHG,SAAS,KAAK,MAAM,GAAG,EAAE,EAAE,GAGtB,CAAE,IAFP,SAAS,KAAK,MAAM,GAAG,EAAE,EAAE,GAEhB,CAAE,IADb,SAAS,KAAK,MAAM,GAAG,EAAE,EAAE,GACV,CAAE,IAAI,MAAM"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/composables/useBodyScrollLock.ts
|
|
2
|
+
/**
|
|
3
|
+
* Reference-counted `<body>` scroll lock, shared by every overlay that needs
|
|
4
|
+
* one (Modal, Drawer, …).
|
|
5
|
+
*
|
|
6
|
+
* Each overlay used to save and restore `body.style.overflow` on its own. That
|
|
7
|
+
* breaks as soon as two overlays are open at once: the second one saves the
|
|
8
|
+
* *locked* value (`'hidden'`) as the thing to restore, so whichever releases
|
|
9
|
+
* last writes `overflow: hidden` back onto <body> and the page can never
|
|
10
|
+
* scroll again. Counting holders here means the original values are captured
|
|
11
|
+
* once, by the first lock, and restored once, by the last release.
|
|
12
|
+
*
|
|
13
|
+
* Callers must pair every `lockBodyScroll()` with exactly one
|
|
14
|
+
* `unlockBodyScroll()` — components track that with an instance-level flag so
|
|
15
|
+
* a double release cannot drop the count below zero.
|
|
16
|
+
*/
|
|
17
|
+
var holders = 0;
|
|
18
|
+
var previousOverflow = "";
|
|
19
|
+
var previousPaddingRight = "";
|
|
20
|
+
function lockBodyScroll() {
|
|
21
|
+
if (typeof document === "undefined") return;
|
|
22
|
+
if (holders === 0) {
|
|
23
|
+
const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
24
|
+
previousOverflow = document.body.style.overflow;
|
|
25
|
+
previousPaddingRight = document.body.style.paddingRight;
|
|
26
|
+
document.body.style.overflow = "hidden";
|
|
27
|
+
if (scrollBarWidth > 0) document.body.style.paddingRight = `${scrollBarWidth}px`;
|
|
28
|
+
}
|
|
29
|
+
holders += 1;
|
|
30
|
+
}
|
|
31
|
+
function unlockBodyScroll() {
|
|
32
|
+
if (typeof document === "undefined" || holders === 0) return;
|
|
33
|
+
holders -= 1;
|
|
34
|
+
if (holders > 0) return;
|
|
35
|
+
document.body.style.overflow = previousOverflow;
|
|
36
|
+
document.body.style.paddingRight = previousPaddingRight;
|
|
37
|
+
previousOverflow = "";
|
|
38
|
+
previousPaddingRight = "";
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.lockBodyScroll = lockBodyScroll;
|
|
42
|
+
exports.unlockBodyScroll = unlockBodyScroll;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=useBodyScrollLock.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBodyScrollLock.cjs","names":[],"sources":["../../src/composables/useBodyScrollLock.ts"],"sourcesContent":["/**\n * Reference-counted `<body>` scroll lock, shared by every overlay that needs\n * one (Modal, Drawer, …).\n *\n * Each overlay used to save and restore `body.style.overflow` on its own. That\n * breaks as soon as two overlays are open at once: the second one saves the\n * *locked* value (`'hidden'`) as the thing to restore, so whichever releases\n * last writes `overflow: hidden` back onto <body> and the page can never\n * scroll again. Counting holders here means the original values are captured\n * once, by the first lock, and restored once, by the last release.\n *\n * Callers must pair every `lockBodyScroll()` with exactly one\n * `unlockBodyScroll()` — components track that with an instance-level flag so\n * a double release cannot drop the count below zero.\n */\n\nlet holders = 0;\nlet previousOverflow = '';\nlet previousPaddingRight = '';\n\nexport function lockBodyScroll(): void {\n if (typeof document === 'undefined') return;\n\n if (holders === 0) {\n // Compensate for the scrollbar the lock is about to remove, so the\n // page underneath doesn't shift sideways.\n const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;\n previousOverflow = document.body.style.overflow;\n previousPaddingRight = document.body.style.paddingRight;\n document.body.style.overflow = 'hidden';\n if (scrollBarWidth > 0) {\n document.body.style.paddingRight = `${scrollBarWidth}px`;\n }\n }\n\n holders += 1;\n}\n\nexport function unlockBodyScroll(): void {\n if (typeof document === 'undefined' || holders === 0) return;\n\n holders -= 1;\n if (holders > 0) return;\n\n document.body.style.overflow = previousOverflow;\n document.body.style.paddingRight = previousPaddingRight;\n previousOverflow = '';\n previousPaddingRight = '';\n}\n\n/** Test-only escape hatch so specs can start from a known state. */\nexport function __resetBodyScrollLock(): void {\n holders = 0;\n previousOverflow = '';\n previousPaddingRight = '';\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAI,UAAU;AACd,IAAI,mBAAmB;AACvB,IAAI,uBAAuB;AAE3B,SAAgB,iBAAuB;CACnC,IAAI,OAAO,aAAa,aAAa;CAErC,IAAI,YAAY,GAAG;EAGf,MAAM,iBAAiB,OAAO,aAAa,SAAS,gBAAgB;EACpE,mBAAmB,SAAS,KAAK,MAAM;EACvC,uBAAuB,SAAS,KAAK,MAAM;EAC3C,SAAS,KAAK,MAAM,WAAW;EAC/B,IAAI,iBAAiB,GACjB,SAAS,KAAK,MAAM,eAAe,GAAG,eAAe;;CAI7D,WAAW;;AAGf,SAAgB,mBAAyB;CACrC,IAAI,OAAO,aAAa,eAAe,YAAY,GAAG;CAEtD,WAAW;CACX,IAAI,UAAU,GAAG;CAEjB,SAAS,KAAK,MAAM,WAAW;CAC/B,SAAS,KAAK,MAAM,eAAe;CACnC,mBAAmB;CACnB,uBAAuB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/composables/useBodyScrollLock.ts
|
|
2
|
+
/**
|
|
3
|
+
* Reference-counted `<body>` scroll lock, shared by every overlay that needs
|
|
4
|
+
* one (Modal, Drawer, …).
|
|
5
|
+
*
|
|
6
|
+
* Each overlay used to save and restore `body.style.overflow` on its own. That
|
|
7
|
+
* breaks as soon as two overlays are open at once: the second one saves the
|
|
8
|
+
* *locked* value (`'hidden'`) as the thing to restore, so whichever releases
|
|
9
|
+
* last writes `overflow: hidden` back onto <body> and the page can never
|
|
10
|
+
* scroll again. Counting holders here means the original values are captured
|
|
11
|
+
* once, by the first lock, and restored once, by the last release.
|
|
12
|
+
*
|
|
13
|
+
* Callers must pair every `lockBodyScroll()` with exactly one
|
|
14
|
+
* `unlockBodyScroll()` — components track that with an instance-level flag so
|
|
15
|
+
* a double release cannot drop the count below zero.
|
|
16
|
+
*/
|
|
17
|
+
var holders = 0;
|
|
18
|
+
var previousOverflow = "";
|
|
19
|
+
var previousPaddingRight = "";
|
|
20
|
+
function lockBodyScroll() {
|
|
21
|
+
if (typeof document === "undefined") return;
|
|
22
|
+
if (holders === 0) {
|
|
23
|
+
const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
24
|
+
previousOverflow = document.body.style.overflow;
|
|
25
|
+
previousPaddingRight = document.body.style.paddingRight;
|
|
26
|
+
document.body.style.overflow = "hidden";
|
|
27
|
+
if (scrollBarWidth > 0) document.body.style.paddingRight = `${scrollBarWidth}px`;
|
|
28
|
+
}
|
|
29
|
+
holders += 1;
|
|
30
|
+
}
|
|
31
|
+
function unlockBodyScroll() {
|
|
32
|
+
if (typeof document === "undefined" || holders === 0) return;
|
|
33
|
+
holders -= 1;
|
|
34
|
+
if (holders > 0) return;
|
|
35
|
+
document.body.style.overflow = previousOverflow;
|
|
36
|
+
document.body.style.paddingRight = previousPaddingRight;
|
|
37
|
+
previousOverflow = "";
|
|
38
|
+
previousPaddingRight = "";
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { lockBodyScroll, unlockBodyScroll };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=useBodyScrollLock.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBodyScrollLock.mjs","names":[],"sources":["../../src/composables/useBodyScrollLock.ts"],"sourcesContent":["/**\n * Reference-counted `<body>` scroll lock, shared by every overlay that needs\n * one (Modal, Drawer, …).\n *\n * Each overlay used to save and restore `body.style.overflow` on its own. That\n * breaks as soon as two overlays are open at once: the second one saves the\n * *locked* value (`'hidden'`) as the thing to restore, so whichever releases\n * last writes `overflow: hidden` back onto <body> and the page can never\n * scroll again. Counting holders here means the original values are captured\n * once, by the first lock, and restored once, by the last release.\n *\n * Callers must pair every `lockBodyScroll()` with exactly one\n * `unlockBodyScroll()` — components track that with an instance-level flag so\n * a double release cannot drop the count below zero.\n */\n\nlet holders = 0;\nlet previousOverflow = '';\nlet previousPaddingRight = '';\n\nexport function lockBodyScroll(): void {\n if (typeof document === 'undefined') return;\n\n if (holders === 0) {\n // Compensate for the scrollbar the lock is about to remove, so the\n // page underneath doesn't shift sideways.\n const scrollBarWidth = window.innerWidth - document.documentElement.clientWidth;\n previousOverflow = document.body.style.overflow;\n previousPaddingRight = document.body.style.paddingRight;\n document.body.style.overflow = 'hidden';\n if (scrollBarWidth > 0) {\n document.body.style.paddingRight = `${scrollBarWidth}px`;\n }\n }\n\n holders += 1;\n}\n\nexport function unlockBodyScroll(): void {\n if (typeof document === 'undefined' || holders === 0) return;\n\n holders -= 1;\n if (holders > 0) return;\n\n document.body.style.overflow = previousOverflow;\n document.body.style.paddingRight = previousPaddingRight;\n previousOverflow = '';\n previousPaddingRight = '';\n}\n\n/** Test-only escape hatch so specs can start from a known state. */\nexport function __resetBodyScrollLock(): void {\n holders = 0;\n previousOverflow = '';\n previousPaddingRight = '';\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAI,UAAU;AACd,IAAI,mBAAmB;AACvB,IAAI,uBAAuB;AAE3B,SAAgB,iBAAuB;CACnC,IAAI,OAAO,aAAa,aAAa;CAErC,IAAI,YAAY,GAAG;EAGf,MAAM,iBAAiB,OAAO,aAAa,SAAS,gBAAgB;EACpE,mBAAmB,SAAS,KAAK,MAAM;EACvC,uBAAuB,SAAS,KAAK,MAAM;EAC3C,SAAS,KAAK,MAAM,WAAW;EAC/B,IAAI,iBAAiB,GACjB,SAAS,KAAK,MAAM,eAAe,GAAG,eAAe;;CAI7D,WAAW;;AAGf,SAAgB,mBAAyB;CACrC,IAAI,OAAO,aAAa,eAAe,YAAY,GAAG;CAEtD,WAAW;CACX,IAAI,UAAU,GAAG;CAEjB,SAAS,KAAK,MAAM,WAAW;CAC/B,SAAS,KAAK,MAAM,eAAe;CACnC,mBAAmB;CACnB,uBAAuB"}
|
|
@@ -58,6 +58,18 @@ var PILL = {
|
|
|
58
58
|
large: "rounded-full",
|
|
59
59
|
full: "rounded-full"
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Radii at which an event still has enough straight left edge to carry the
|
|
63
|
+
* colour rule. Past these, `border-radius` sweeps the one-sided border around
|
|
64
|
+
* the corner arc and it renders as a crescent hugging the side of the event
|
|
65
|
+
* instead of a bar; the translucent fill and the text colour carry the event
|
|
66
|
+
* colour on their own there.
|
|
67
|
+
*/
|
|
68
|
+
var EVENT_ACCENT_RADII = [
|
|
69
|
+
"none",
|
|
70
|
+
"small",
|
|
71
|
+
"medium"
|
|
72
|
+
];
|
|
61
73
|
var DAY_NAME_CASE = {
|
|
62
74
|
upper: "uppercase",
|
|
63
75
|
lower: "lowercase",
|
|
@@ -74,15 +86,24 @@ function useCalendarTheme(input) {
|
|
|
74
86
|
const resolvedRadius = (0, vue.computed)(() => {
|
|
75
87
|
return input.radius() ?? cfg?.value.radius ?? "medium";
|
|
76
88
|
});
|
|
89
|
+
const todayTextClass = (0, vue.computed)(() => TEXT[resolvedColor.value] ?? TEXT.default);
|
|
90
|
+
const todayBgClass = (0, vue.computed)(() => BG[resolvedColor.value] ?? BG.default);
|
|
91
|
+
const rangeSelectClass = (0, vue.computed)(() => RANGE[resolvedColor.value] ?? RANGE.default);
|
|
92
|
+
const focusRingColorClass = (0, vue.computed)(() => RING[resolvedColor.value] ?? RING.default);
|
|
93
|
+
const highlightDotClass = (0, vue.computed)(() => DOT[resolvedColor.value] ?? DOT.default);
|
|
94
|
+
const containerRadiusClass = (0, vue.computed)(() => CONTAINER[resolvedRadius.value] ?? CONTAINER.large);
|
|
95
|
+
const eventRadiusClass = (0, vue.computed)(() => EVENT[resolvedRadius.value] ?? EVENT.small);
|
|
96
|
+
const pillRadiusClass = (0, vue.computed)(() => PILL[resolvedRadius.value] ?? PILL.full);
|
|
77
97
|
return {
|
|
78
|
-
todayTextClass
|
|
79
|
-
todayBgClass
|
|
80
|
-
rangeSelectClass
|
|
81
|
-
focusRingColorClass
|
|
82
|
-
highlightDotClass
|
|
83
|
-
containerRadiusClass
|
|
84
|
-
eventRadiusClass
|
|
85
|
-
|
|
98
|
+
todayTextClass,
|
|
99
|
+
todayBgClass,
|
|
100
|
+
rangeSelectClass,
|
|
101
|
+
focusRingColorClass,
|
|
102
|
+
highlightDotClass,
|
|
103
|
+
containerRadiusClass,
|
|
104
|
+
eventRadiusClass,
|
|
105
|
+
showEventAccent: (0, vue.computed)(() => EVENT_ACCENT_RADII.includes(resolvedRadius.value)),
|
|
106
|
+
pillRadiusClass,
|
|
86
107
|
dayNameCaseClass: (0, vue.computed)(() => DAY_NAME_CASE[input.dayNameCase?.() ?? "upper"] ?? DAY_NAME_CASE.upper),
|
|
87
108
|
resolvedColor
|
|
88
109
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCalendarTheme.cjs","names":[],"sources":["../../src/composables/useCalendarTheme.ts"],"sourcesContent":["import { computed, type ComputedRef } from 'vue'; \nimport { useModoConfig } from './useModoConfig'; \n \nexport type CalendarColor = 'default' | 'primary' | 'danger' | 'success' | 'warning'; \nexport type CalendarRadius = 'none' | 'small' | 'medium' | 'large' | 'full'; \nexport type DayNameCase = 'upper' | 'lower' | 'capitalize' | 'normal'; \n \nexport interface CalendarThemeInput { \n color: () => CalendarColor | undefined; \n radius: () => CalendarRadius | undefined; \n dayNameCase?: () => DayNameCase; \n} \n \nexport interface CalendarTheme { \n todayTextClass: ComputedRef<string>; \n todayBgClass: ComputedRef<string>; \n rangeSelectClass: ComputedRef<string>; \n focusRingColorClass: ComputedRef<string>; \n highlightDotClass: ComputedRef<string>; \n containerRadiusClass: ComputedRef<string>; \n eventRadiusClass: ComputedRef<string
|
|
1
|
+
{"version":3,"file":"useCalendarTheme.cjs","names":[],"sources":["../../src/composables/useCalendarTheme.ts"],"sourcesContent":["import { computed, type ComputedRef } from 'vue'; \nimport { useModoConfig } from './useModoConfig'; \n \nexport type CalendarColor = 'default' | 'primary' | 'danger' | 'success' | 'warning'; \nexport type CalendarRadius = 'none' | 'small' | 'medium' | 'large' | 'full'; \nexport type DayNameCase = 'upper' | 'lower' | 'capitalize' | 'normal'; \n \nexport interface CalendarThemeInput { \n color: () => CalendarColor | undefined; \n radius: () => CalendarRadius | undefined; \n dayNameCase?: () => DayNameCase; \n} \n \nexport interface CalendarTheme { \n todayTextClass: ComputedRef<string>; \n todayBgClass: ComputedRef<string>; \n rangeSelectClass: ComputedRef<string>; \n focusRingColorClass: ComputedRef<string>; \n highlightDotClass: ComputedRef<string>; \n containerRadiusClass: ComputedRef<string>; \n eventRadiusClass: ComputedRef<string>;\n /** Whether an event's left colour rule reads as a bar at the current radius. */\n showEventAccent: ComputedRef<boolean>;\n pillRadiusClass: ComputedRef<string>;\n dayNameCaseClass: ComputedRef<string>; \n resolvedColor: ComputedRef<CalendarColor>; \n} \n \nconst TEXT: Record<CalendarColor, string> = { \n default: 'text-foreground', \n primary: 'text-primary', \n danger: 'text-destructive', \n success: 'text-success', \n warning: 'text-warning', \n}; \n \nconst BG: Record<CalendarColor, string> = { \n default: 'bg-foreground text-background', \n primary: 'bg-primary text-primary-foreground', \n danger: 'bg-destructive text-destructive-foreground', \n success: 'bg-success text-success-foreground', \n warning: 'bg-warning text-warning-foreground', \n}; \n \nconst RANGE: Record<CalendarColor, string> = { \n default: 'border-foreground/40 bg-foreground/10', \n primary: 'border-primary/50 bg-primary/10', \n danger: 'border-destructive/50 bg-destructive/10', \n success: 'border-success/50 bg-success/10', \n warning: 'border-warning/50 bg-warning/10', \n}; \n \nconst RING: Record<CalendarColor, string> = { \n default: 'ring-ring', \n primary: 'ring-primary', \n danger: 'ring-destructive', \n success: 'ring-success', \n warning: 'ring-warning', \n}; \n \nconst DOT: Record<CalendarColor, string> = { \n default: 'bg-muted-foreground', \n primary: 'bg-primary', \n danger: 'bg-destructive', \n success: 'bg-success', \n warning: 'bg-warning', \n}; \n \nconst CONTAINER: Record<CalendarRadius, string> = { \n none: 'rounded-none', \n small: 'rounded', \n medium: 'rounded-md', \n large: 'rounded-xl', \n full: 'rounded-3xl', \n}; \n \nconst EVENT: Record<CalendarRadius, string> = { \n none: 'rounded-none', \n small: 'rounded-sm', \n medium: 'rounded', \n large: 'rounded-md', \n full: 'rounded-xl', \n}; \n \nconst PILL: Record<CalendarRadius, string> = { \n none: 'rounded-none', \n small: 'rounded-sm', \n medium: 'rounded-md', \n large: 'rounded-full', \n full: 'rounded-full', \n}; \n \n/**\n * Radii at which an event still has enough straight left edge to carry the\n * colour rule. Past these, `border-radius` sweeps the one-sided border around\n * the corner arc and it renders as a crescent hugging the side of the event\n * instead of a bar; the translucent fill and the text colour carry the event\n * colour on their own there.\n */\nconst EVENT_ACCENT_RADII: CalendarRadius[] = ['none', 'small', 'medium'];\n\nconst DAY_NAME_CASE: Record<DayNameCase, string> = {\n upper: 'uppercase', \n lower: 'lowercase', \n capitalize: 'capitalize', \n normal: 'normal-case', \n}; \n \nexport function useCalendarTheme(input: CalendarThemeInput): CalendarTheme { \n const cfg = useModoConfig(); \n const resolvedColor = computed<CalendarColor>(() => { \n const local = input.color(); \n if (local && local !== 'default') return local; \n return (cfg?.value.color as CalendarColor) ?? 'default'; \n }); \n const resolvedRadius = computed<CalendarRadius>(() => { \n const local = input.radius(); \n return local ?? (cfg?.value.radius as CalendarRadius) ?? 'medium'; \n }); \n \n const todayTextClass = computed(() => TEXT[resolvedColor.value] ?? TEXT.default); \n const todayBgClass = computed(() => BG[resolvedColor.value] ?? BG.default); \n const rangeSelectClass = computed(() => RANGE[resolvedColor.value] ?? RANGE.default); \n const focusRingColorClass = computed(() => RING[resolvedColor.value] ?? RING.default); \n const highlightDotClass = computed(() => DOT[resolvedColor.value] ?? DOT.default); \n const containerRadiusClass = computed(() => CONTAINER[resolvedRadius.value] ?? CONTAINER.large); \n const eventRadiusClass = computed(() => EVENT[resolvedRadius.value] ?? EVENT.small); \n const pillRadiusClass = computed(() => PILL[resolvedRadius.value] ?? PILL.full);\n const showEventAccent = computed(() => EVENT_ACCENT_RADII.includes(resolvedRadius.value));\n const dayNameCaseClass = computed(() => DAY_NAME_CASE[input.dayNameCase?.() ?? 'upper'] ?? DAY_NAME_CASE.upper); \n \n return { \n todayTextClass, \n todayBgClass, \n rangeSelectClass, \n focusRingColorClass, \n highlightDotClass, \n containerRadiusClass,\n eventRadiusClass,\n showEventAccent,\n pillRadiusClass,\n dayNameCaseClass, \n resolvedColor, \n }; \n}\n"],"mappings":";;;;AA4BA,IAAM,OAAsC;CACxC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACZ;AAED,IAAM,KAAoC;CACtC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACZ;AAED,IAAM,QAAuC;CACzC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACZ;AAED,IAAM,OAAsC;CACxC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACZ;AAED,IAAM,MAAqC;CACvC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACZ;AAED,IAAM,YA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;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA,kBAAA,GAAA,IAAA,gBAXmC,mBAAmB,SAAS,eAAe,MAAM,CAWpF;EACA;EACA,mBAAA,GAAA,IAAA,gBAZoC,cAAc,MAAM,eAAe,IAAI,YAAY,cAAc,MAYrG;EACA;EACH"}
|
|
@@ -57,6 +57,18 @@ var PILL = {
|
|
|
57
57
|
large: "rounded-full",
|
|
58
58
|
full: "rounded-full"
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Radii at which an event still has enough straight left edge to carry the
|
|
62
|
+
* colour rule. Past these, `border-radius` sweeps the one-sided border around
|
|
63
|
+
* the corner arc and it renders as a crescent hugging the side of the event
|
|
64
|
+
* instead of a bar; the translucent fill and the text colour carry the event
|
|
65
|
+
* colour on their own there.
|
|
66
|
+
*/
|
|
67
|
+
var EVENT_ACCENT_RADII = [
|
|
68
|
+
"none",
|
|
69
|
+
"small",
|
|
70
|
+
"medium"
|
|
71
|
+
];
|
|
60
72
|
var DAY_NAME_CASE = {
|
|
61
73
|
upper: "uppercase",
|
|
62
74
|
lower: "lowercase",
|
|
@@ -73,15 +85,24 @@ function useCalendarTheme(input) {
|
|
|
73
85
|
const resolvedRadius = computed(() => {
|
|
74
86
|
return input.radius() ?? cfg?.value.radius ?? "medium";
|
|
75
87
|
});
|
|
88
|
+
const todayTextClass = computed(() => TEXT[resolvedColor.value] ?? TEXT.default);
|
|
89
|
+
const todayBgClass = computed(() => BG[resolvedColor.value] ?? BG.default);
|
|
90
|
+
const rangeSelectClass = computed(() => RANGE[resolvedColor.value] ?? RANGE.default);
|
|
91
|
+
const focusRingColorClass = computed(() => RING[resolvedColor.value] ?? RING.default);
|
|
92
|
+
const highlightDotClass = computed(() => DOT[resolvedColor.value] ?? DOT.default);
|
|
93
|
+
const containerRadiusClass = computed(() => CONTAINER[resolvedRadius.value] ?? CONTAINER.large);
|
|
94
|
+
const eventRadiusClass = computed(() => EVENT[resolvedRadius.value] ?? EVENT.small);
|
|
95
|
+
const pillRadiusClass = computed(() => PILL[resolvedRadius.value] ?? PILL.full);
|
|
76
96
|
return {
|
|
77
|
-
todayTextClass
|
|
78
|
-
todayBgClass
|
|
79
|
-
rangeSelectClass
|
|
80
|
-
focusRingColorClass
|
|
81
|
-
highlightDotClass
|
|
82
|
-
containerRadiusClass
|
|
83
|
-
eventRadiusClass
|
|
84
|
-
|
|
97
|
+
todayTextClass,
|
|
98
|
+
todayBgClass,
|
|
99
|
+
rangeSelectClass,
|
|
100
|
+
focusRingColorClass,
|
|
101
|
+
highlightDotClass,
|
|
102
|
+
containerRadiusClass,
|
|
103
|
+
eventRadiusClass,
|
|
104
|
+
showEventAccent: computed(() => EVENT_ACCENT_RADII.includes(resolvedRadius.value)),
|
|
105
|
+
pillRadiusClass,
|
|
85
106
|
dayNameCaseClass: computed(() => DAY_NAME_CASE[input.dayNameCase?.() ?? "upper"] ?? DAY_NAME_CASE.upper),
|
|
86
107
|
resolvedColor
|
|
87
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCalendarTheme.mjs","names":[],"sources":["../../src/composables/useCalendarTheme.ts"],"sourcesContent":["import { computed, type ComputedRef } from 'vue'; \nimport { useModoConfig } from './useModoConfig'; \n \nexport type CalendarColor = 'default' | 'primary' | 'danger' | 'success' | 'warning'; \nexport type CalendarRadius = 'none' | 'small' | 'medium' | 'large' | 'full'; \nexport type DayNameCase = 'upper' | 'lower' | 'capitalize' | 'normal'; \n \nexport interface CalendarThemeInput { \n color: () => CalendarColor | undefined; \n radius: () => CalendarRadius | undefined; \n dayNameCase?: () => DayNameCase; \n} \n \nexport interface CalendarTheme { \n todayTextClass: ComputedRef<string>; \n todayBgClass: ComputedRef<string>; \n rangeSelectClass: ComputedRef<string>; \n focusRingColorClass: ComputedRef<string>; \n highlightDotClass: ComputedRef<string>; \n containerRadiusClass: ComputedRef<string>; \n eventRadiusClass: ComputedRef<string
|
|
1
|
+
{"version":3,"file":"useCalendarTheme.mjs","names":[],"sources":["../../src/composables/useCalendarTheme.ts"],"sourcesContent":["import { computed, type ComputedRef } from 'vue'; \nimport { useModoConfig } from './useModoConfig'; \n \nexport type CalendarColor = 'default' | 'primary' | 'danger' | 'success' | 'warning'; \nexport type CalendarRadius = 'none' | 'small' | 'medium' | 'large' | 'full'; \nexport type DayNameCase = 'upper' | 'lower' | 'capitalize' | 'normal'; \n \nexport interface CalendarThemeInput { \n color: () => CalendarColor | undefined; \n radius: () => CalendarRadius | undefined; \n dayNameCase?: () => DayNameCase; \n} \n \nexport interface CalendarTheme { \n todayTextClass: ComputedRef<string>; \n todayBgClass: ComputedRef<string>; \n rangeSelectClass: ComputedRef<string>; \n focusRingColorClass: ComputedRef<string>; \n highlightDotClass: ComputedRef<string>; \n containerRadiusClass: ComputedRef<string>; \n eventRadiusClass: ComputedRef<string>;\n /** Whether an event's left colour rule reads as a bar at the current radius. */\n showEventAccent: ComputedRef<boolean>;\n pillRadiusClass: ComputedRef<string>;\n dayNameCaseClass: ComputedRef<string>; \n resolvedColor: ComputedRef<CalendarColor>; \n} \n \nconst TEXT: Record<CalendarColor, string> = { \n default: 'text-foreground', \n primary: 'text-primary', \n danger: 'text-destructive', \n success: 'text-success', \n warning: 'text-warning', \n}; \n \nconst BG: Record<CalendarColor, string> = { \n default: 'bg-foreground text-background', \n primary: 'bg-primary text-primary-foreground', \n danger: 'bg-destructive text-destructive-foreground', \n success: 'bg-success text-success-foreground', \n warning: 'bg-warning text-warning-foreground', \n}; \n \nconst RANGE: Record<CalendarColor, string> = { \n default: 'border-foreground/40 bg-foreground/10', \n primary: 'border-primary/50 bg-primary/10', \n danger: 'border-destructive/50 bg-destructive/10', \n success: 'border-success/50 bg-success/10', \n warning: 'border-warning/50 bg-warning/10', \n}; \n \nconst RING: Record<CalendarColor, string> = { \n default: 'ring-ring', \n primary: 'ring-primary', \n danger: 'ring-destructive', \n success: 'ring-success', \n warning: 'ring-warning', \n}; \n \nconst DOT: Record<CalendarColor, string> = { \n default: 'bg-muted-foreground', \n primary: 'bg-primary', \n danger: 'bg-destructive', \n success: 'bg-success', \n warning: 'bg-warning', \n}; \n \nconst CONTAINER: Record<CalendarRadius, string> = { \n none: 'rounded-none', \n small: 'rounded', \n medium: 'rounded-md', \n large: 'rounded-xl', \n full: 'rounded-3xl', \n}; \n \nconst EVENT: Record<CalendarRadius, string> = { \n none: 'rounded-none', \n small: 'rounded-sm', \n medium: 'rounded', \n large: 'rounded-md', \n full: 'rounded-xl', \n}; \n \nconst PILL: Record<CalendarRadius, string> = { \n none: 'rounded-none', \n small: 'rounded-sm', \n medium: 'rounded-md', \n large: 'rounded-full', \n full: 'rounded-full', \n}; \n \n/**\n * Radii at which an event still has enough straight left edge to carry the\n * colour rule. Past these, `border-radius` sweeps the one-sided border around\n * the corner arc and it renders as a crescent hugging the side of the event\n * instead of a bar; the translucent fill and the text colour carry the event\n * colour on their own there.\n */\nconst EVENT_ACCENT_RADII: CalendarRadius[] = ['none', 'small', 'medium'];\n\nconst DAY_NAME_CASE: Record<DayNameCase, string> = {\n upper: 'uppercase', \n lower: 'lowercase', \n capitalize: 'capitalize', \n normal: 'normal-case', \n}; \n \nexport function useCalendarTheme(input: CalendarThemeInput): CalendarTheme { \n const cfg = useModoConfig(); \n const resolvedColor = computed<CalendarColor>(() => { \n const local = input.color(); \n if (local && local !== 'default') return local; \n return (cfg?.value.color as CalendarColor) ?? 'default'; \n }); \n const resolvedRadius = computed<CalendarRadius>(() => { \n const local = input.radius(); \n return local ?? (cfg?.value.radius as CalendarRadius) ?? 'medium'; \n }); \n \n const todayTextClass = computed(() => TEXT[resolvedColor.value] ?? TEXT.default); \n const todayBgClass = computed(() => BG[resolvedColor.value] ?? BG.default); \n const rangeSelectClass = computed(() => RANGE[resolvedColor.value] ?? RANGE.default); \n const focusRingColorClass = computed(() => RING[resolvedColor.value] ?? RING.default); \n const highlightDotClass = computed(() => DOT[resolvedColor.value] ?? DOT.default); \n const containerRadiusClass = computed(() => CONTAINER[resolvedRadius.value] ?? CONTAINER.large); \n const eventRadiusClass = computed(() => EVENT[resolvedRadius.value] ?? EVENT.small); \n const pillRadiusClass = computed(() => PILL[resolvedRadius.value] ?? PILL.full);\n const showEventAccent = computed(() => EVENT_ACCENT_RADII.includes(resolvedRadius.value));\n const dayNameCaseClass = computed(() => DAY_NAME_CASE[input.dayNameCase?.() ?? 'upper'] ?? DAY_NAME_CASE.upper); \n \n return { \n todayTextClass, \n todayBgClass, \n rangeSelectClass, \n focusRingColorClass, \n highlightDotClass, \n containerRadiusClass,\n eventRadiusClass,\n showEventAccent,\n pillRadiusClass,\n dayNameCaseClass, \n resolvedColor, \n }; \n}\n"],"mappings":";;;AA4BA,IAAM,OAAsC;CACxC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACZ;AAED,IAAM,KAAoC;CACtC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACZ;AAED,IAAM,QAAuC;CACzC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACZ;AAED,IAAM,OAAsC;CACxC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACZ;AAED,IAAM,MAAqC;CACvC,SAAS;CACT,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACZ;AAED,IAAM,YAA4C;CAC9C,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACT;AAED,IAAM,QAAwC;CAC1C,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACT;AAED,IAAM,OAAuC;CACzC,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACT;;;;;;;;AASD,IAAM,qBAAuC;CAAC;CAAQ;CAAS;CAAS;AAExE,IAAM,gBAA6C;CAC/C,OAAO;CACP,OAAO;CACP,YAAY;CACZ,QAAQ;CACX;AAED,SAAgB,iBAAiB,OAA0C;CACvE,MAAM,MAAM,eAAe;CAC3B,MAAM,gBAAgB,eAA8B;EAChD,MAAM,QAAQ,MAAM,OAAO;EAC3B,IAAI,SAAS,UAAU,WAAW,OAAO;EACzC,OAAQ,KAAK,MAAM,SAA2B;GAChD;CACF,MAAM,iBAAiB,eAA+B;EAElD,OADc,MAAM,QACb,IAAU,KAAK,MAAM,UAA6B;GAC3D;CAEF,MAAM,iBAAiB,eAAe,KAAK,cAAc,UAAU,KAAK,QAAQ;CAChF,MAAM,eAAe,eAAe,GAAG,cAAc,UAAU,GAAG,QAAQ;CAC1E,MAAM,mBAAmB,eAAe,MAAM,cAAc,UAAU,MAAM,QAAQ;CACpF,MAAM,sBAAsB,eAAe,KAAK,cAAc,UAAU,KAAK,QAAQ;CACrF,MAAM,oBAAoB,eAAe,IAAI,cAAc,UAAU,IAAI,QAAQ;CACjF,MAAM,uBAAuB,eAAe,UAAU,eAAe,UAAU,UAAU,MAAM;CAC/F,MAAM,mBAAmB,eAAe,MAAM,eAAe,UAAU,MAAM,MAAM;CACnF,MAAM,kBAAkB,eAAe,KAAK,eAAe,UAAU,KAAK,KAAK;CAI/E,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA,iBAXoB,eAAe,mBAAmB,SAAS,eAAe,MAAM,CAWpF;EACA;EACA,kBAZqB,eAAe,cAAc,MAAM,eAAe,IAAI,YAAY,cAAc,MAYrG;EACA;EACH"}
|
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let vue = require("vue");
|
|
3
3
|
//#region src/composables/usePopover.ts
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
4
|
+
/**
|
|
5
|
+
* Floor for the viewport cap. A trigger sitting a few pixels from the bottom
|
|
6
|
+
* edge would otherwise get a panel too short to show anything; below this we
|
|
7
|
+
* let the panel keep its own scroll instead.
|
|
8
|
+
*/
|
|
9
|
+
var MIN_PANEL_HEIGHT = 120;
|
|
10
|
+
/**
|
|
11
|
+
* Content height of a panel, independent of any `max-height` we have already
|
|
12
|
+
* applied to it. `getBoundingClientRect()` reports the *constrained* height
|
|
13
|
+
* once capped, so it can't be used to decide whether the panel still needs a
|
|
14
|
+
* cap. The panel clips vertically and its inner wrapper is the scroll
|
|
15
|
+
* container, so that wrapper's `scrollHeight` (plus the panel's own vertical
|
|
16
|
+
* borders) is the height the panel would take if nothing constrained it.
|
|
17
|
+
*/
|
|
18
|
+
function naturalHeight(panel) {
|
|
19
|
+
const inner = panel.firstElementChild;
|
|
20
|
+
if (!inner) return panel.getBoundingClientRect().height;
|
|
21
|
+
const styles = getComputedStyle(panel);
|
|
22
|
+
const borders = Number.parseFloat(styles.borderTopWidth || "0") + Number.parseFloat(styles.borderBottomWidth || "0");
|
|
23
|
+
return Math.max(inner.scrollHeight + borders, panel.getBoundingClientRect().height);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Headless composable para lógica de popover/dropdown:
|
|
6
27
|
* - estado abierto/cerrado
|
|
7
28
|
* - click outside + Escape
|
|
8
29
|
* - posición absoluta relativa al viewport (para usar con `position: fixed`)
|
|
@@ -40,9 +61,8 @@ function usePopover(options = {}) {
|
|
|
40
61
|
const initialPlacement = (0, vue.toValue)(placementOption);
|
|
41
62
|
const matchTriggerWidth = (0, vue.toValue)(matchTriggerWidthOption);
|
|
42
63
|
const tRect = trigger.getBoundingClientRect();
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const panelH = pRect?.height ?? 0;
|
|
64
|
+
const panelW = (panel?.getBoundingClientRect())?.width ?? tRect.width;
|
|
65
|
+
const panelH = panel ? naturalHeight(panel) : 0;
|
|
46
66
|
const vw = window.innerWidth;
|
|
47
67
|
const vh = window.innerHeight;
|
|
48
68
|
const margin = 8;
|
|
@@ -56,22 +76,23 @@ function usePopover(options = {}) {
|
|
|
56
76
|
}
|
|
57
77
|
const isBottom = resolved.startsWith("bottom");
|
|
58
78
|
const align = resolved.split("-")[1];
|
|
59
|
-
|
|
79
|
+
const availableH = isBottom ? vh - margin - (tRect.bottom + offset) : tRect.top - offset - margin;
|
|
80
|
+
const maxHeight = Math.max(Math.min(availableH, vh - margin * 2), MIN_PANEL_HEIGHT);
|
|
81
|
+
const renderedH = Math.min(panelH, maxHeight);
|
|
82
|
+
let top = isBottom ? tRect.bottom + offset : tRect.top - renderedH - offset;
|
|
60
83
|
let left;
|
|
61
84
|
if (align === "start") left = tRect.left;
|
|
62
85
|
else if (align === "end") left = tRect.right - panelW;
|
|
63
86
|
else left = tRect.left + tRect.width / 2 - panelW / 2;
|
|
64
87
|
if (left + panelW > vw - margin) left = vw - panelW - margin;
|
|
65
88
|
if (left < margin) left = margin;
|
|
66
|
-
|
|
67
|
-
const clampedMaxH = panelH > availableH ? Math.max(availableH, 120) : void 0;
|
|
68
|
-
if (top + panelH > vh - margin) top = Math.max(margin, vh - panelH - margin);
|
|
89
|
+
if (top + renderedH > vh - margin) top = Math.max(margin, vh - renderedH - margin);
|
|
69
90
|
if (top < margin) top = margin;
|
|
70
91
|
position.value = {
|
|
71
92
|
top,
|
|
72
93
|
left,
|
|
73
94
|
width: matchTriggerWidth ? tRect.width : void 0,
|
|
74
|
-
maxHeight
|
|
95
|
+
maxHeight,
|
|
75
96
|
placement: resolved
|
|
76
97
|
};
|
|
77
98
|
}
|
|
@@ -129,6 +150,17 @@ function usePopover(options = {}) {
|
|
|
129
150
|
close();
|
|
130
151
|
}
|
|
131
152
|
let resizeObserver = null;
|
|
153
|
+
/**
|
|
154
|
+
* Observe the panel *and* its scroll container. The panel itself stops
|
|
155
|
+
* changing size once it hits the viewport cap, so growing content (async
|
|
156
|
+
* search results, a longer list) would never notify us if we only watched
|
|
157
|
+
* the outer box.
|
|
158
|
+
*/
|
|
159
|
+
function observePanel(el) {
|
|
160
|
+
resizeObserver?.observe(el);
|
|
161
|
+
const inner = el.firstElementChild;
|
|
162
|
+
if (inner instanceof HTMLElement) resizeObserver?.observe(inner);
|
|
163
|
+
}
|
|
132
164
|
(0, vue.watch)(isOpen, (open) => {
|
|
133
165
|
if (open) {
|
|
134
166
|
document.addEventListener("pointerdown", onDocumentPointerDown, true);
|
|
@@ -138,7 +170,7 @@ function usePopover(options = {}) {
|
|
|
138
170
|
if (triggerRef.value && typeof ResizeObserver !== "undefined") {
|
|
139
171
|
resizeObserver = new ResizeObserver(onScrollOrResize);
|
|
140
172
|
resizeObserver.observe(triggerRef.value);
|
|
141
|
-
if (panelRef.value)
|
|
173
|
+
if (panelRef.value) observePanel(panelRef.value);
|
|
142
174
|
}
|
|
143
175
|
} else {
|
|
144
176
|
document.removeEventListener("pointerdown", onDocumentPointerDown, true);
|
|
@@ -150,7 +182,7 @@ function usePopover(options = {}) {
|
|
|
150
182
|
}
|
|
151
183
|
});
|
|
152
184
|
(0, vue.watch)(panelRef, (el) => {
|
|
153
|
-
if (isOpen.value && el && resizeObserver)
|
|
185
|
+
if (isOpen.value && el && resizeObserver) observePanel(el);
|
|
154
186
|
});
|
|
155
187
|
(0, vue.watch)(() => [(0, vue.toValue)(placementOption), (0, vue.toValue)(matchTriggerWidthOption)], () => {
|
|
156
188
|
if (isOpen.value) measure();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePopover.cjs","names":[],"sources":["../../src/composables/usePopover.ts"],"sourcesContent":["import { ref, computed, onBeforeUnmount, watch, toValue, type Ref, type MaybeRefOrGetter } from 'vue'; \n \nexport type PopoverPlacement = \n | 'bottom-start' | 'bottom-end' | 'bottom-center' \n | 'top-start' | 'top-end' | 'top-center'; \n \nexport interface UsePopoverOptions { \n /** Placement inicial. @default 'bottom-start' */ \n placement?: MaybeRefOrGetter<PopoverPlacement>; \n /** Offset vertical entre trigger y panel (px). @default 6 */ \n offset?: number; \n /** Auto-flip cuando no cabe en el viewport. @default true */ \n flip?: boolean; \n /** Hacer que el panel tenga el mismo ancho del trigger. @default false */ \n matchTriggerWidth?: MaybeRefOrGetter<boolean>; \n /** Cerrar al hacer click fuera del trigger y del panel. @default true */\n closeOnClickOutside?: boolean;\n /** Cerrar con Escape. @default true */\n closeOnEscape?: boolean;\n /**\n * Cerrar cuando la página hace scroll (fuera del panel). @default true\n * Con `false` el popover se reposiciona en vez de cerrarse — útil para un\n * dropdown de búsqueda que no debe desaparecer si enfocar el input provoca\n * un pequeño auto-scroll.\n */\n closeOnScroll?: boolean;\n /** Callback cuando se abre. */ \n onOpen?: () => void; \n /** Callback cuando se cierra. */ \n onClose?: () => void; \n} \n \nexport interface PopoverPosition {\n top: number;\n left: number;\n width?: number;\n maxHeight?: number;\n /** Placement final (puede diferir del solicitado si hubo flip). */\n placement: PopoverPlacement;\n} \n \n/** \n * Headless composable para lógica de popover/dropdown: \n * - estado abierto/cerrado \n * - click outside + Escape \n * - posición absoluta relativa al viewport (para usar con `position: fixed`) \n * - auto-flip vertical cuando no cabe \n * - reposicionado en scroll + resize + ResizeObserver del trigger \n * \n * El caller se encarga de renderizar el trigger y el panel; este composable \n * sólo devuelve refs y estado. \n */ \nexport function usePopover(options: UsePopoverOptions = {}) { \n const { \n placement: placementOption = 'bottom-start', \n offset = 6, \n flip = true, \n matchTriggerWidth: matchTriggerWidthOption = false, \n closeOnClickOutside = true,\n closeOnEscape = true,\n closeOnScroll = true,\n onOpen,\n onClose,\n } = options;\n \n const triggerRef = ref<HTMLElement | null>(null); \n const panelRef = ref<HTMLElement | null>(null); \n const isOpen = ref(false); \n \n const position = ref<PopoverPosition>({ \n top: 0, \n left: 0, \n placement: toValue(placementOption), \n }); \n \n const panelStyle = computed(() => {\n const style: Record<string, string> = {\n position: 'fixed',\n top: `${position.value.top}px`,\n left: `${position.value.left}px`,\n zIndex: '1300',\n };\n if (position.value.width !== undefined) {\n style.width = `${position.value.width}px`;\n }\n if (position.value.maxHeight !== undefined) {\n style.maxHeight = `${position.value.maxHeight}px`;\n }\n return style;\n }); \n \n function measure(): void { \n const trigger = triggerRef.value; \n const panel = panelRef.value; \n if (!trigger) return; \n \n const initialPlacement = toValue(placementOption); \n const matchTriggerWidth = toValue(matchTriggerWidthOption); \n \n const tRect = trigger.getBoundingClientRect(); \n const pRect = panel?.getBoundingClientRect(); \n const panelW = pRect?.width ?? tRect.width; \n const panelH = pRect?.height ?? 0; \n const vw = window.innerWidth; \n const vh = window.innerHeight; \n const margin = 8; \n \n let resolved: PopoverPlacement = initialPlacement; \n \n // Vertical flip check. \n if (flip) { \n const wantsTop = initialPlacement.startsWith('top'); \n const spaceBelow = vh - tRect.bottom - margin; \n const spaceAbove = tRect.top - margin; \n if (!wantsTop && spaceBelow < panelH && spaceAbove > spaceBelow) { \n resolved = initialPlacement.replace('bottom', 'top') as PopoverPlacement; \n } else if (wantsTop && spaceAbove < panelH && spaceBelow > spaceAbove) { \n resolved = initialPlacement.replace('top', 'bottom') as PopoverPlacement; \n } \n } \n \n const isBottom = resolved.startsWith('bottom'); \n const align = resolved.split('-')[1] as 'start' | 'end' | 'center'; \n \n let top = isBottom ? tRect.bottom + offset : tRect.top - panelH - offset; \n \n let left: number; \n if (align === 'start') left = tRect.left; \n else if (align === 'end') left = tRect.right - panelW; \n else left = tRect.left + tRect.width / 2 - panelW / 2; \n \n // Horizontal clamp (simple, sin variante de flip lateral). \n if (left + panelW > vw - margin) left = vw - panelW - margin; \n if (left < margin) left = margin; \n \n // Vertical clamp: if panel taller than available space, cap it so it stays in viewport.\n const availableH = isBottom\n ? vh - margin - (tRect.bottom + offset)\n : tRect.top - offset - margin;\n const clampedMaxH = panelH > availableH ? Math.max(availableH, 120) : undefined;\n\n if (top + panelH > vh - margin) top = Math.max(margin, vh - panelH - margin);\n if (top < margin) top = margin;\n\n position.value = {\n top,\n left,\n width: matchTriggerWidth ? tRect.width : undefined,\n maxHeight: clampedMaxH,\n placement: resolved,\n }; \n } \n \n /* ---------- API ---------- */ \n \n function open() { \n if (isOpen.value) return; \n isOpen.value = true; \n onOpen?.(); \n // Medir en el próximo frame, cuando el panel ya esté en el DOM. \n requestAnimationFrame(() => { \n measure(); \n // Segunda pasada para corregir si aparecieron scrollbars. \n requestAnimationFrame(measure); \n }); \n } \n \n function close() { \n if (!isOpen.value) return; \n isOpen.value = false; \n onClose?.(); \n } \n \n function toggle() { \n isOpen.value ? close() : open(); \n } \n \n /* ---------- Listeners ---------- */ \n \n function onDocumentPointerDown(e: PointerEvent) { \n if (!isOpen.value || !closeOnClickOutside) return; \n const target = e.target as Element | null; \n if (!target) return; \n if (triggerRef.value?.contains(target)) return; \n if (panelRef.value?.contains(target)) return; \n // Click landed inside a *different* popover (e.g. a Select's \n // dropdown teleported to <body> from a child of our panel). \n // Treat any click on a `.modo-popover` ancestor as \"inside\" so \n // nested popovers don't close their parent. The parent will be \n // closed normally when the user clicks truly outside. \n if (typeof (target as Element).closest === 'function' && (target as Element).closest('.modo-popover')) { \n return; \n } \n close(); \n } \n \n function onDocumentKeyDown(e: KeyboardEvent) { \n if (!isOpen.value) return; \n if (closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n triggerRef.value?.focus?.(); \n } \n } \n \n function onScrollOrResize() { \n if (isOpen.value) measure(); \n } \n \n /** \n * Scroll outside del panel → cerrar. Scroll dentro del panel (p. ej. lista \n * de opciones) → no hace nada. Scroll en window/body → cerrar. \n * Se usa el evento \"scroll\" con capture para recibir cualquier scroll. \n */ \n function onWindowScroll(e: Event) {\n if (!isOpen.value) return;\n const target = e.target as Node | null;\n if (target && panelRef.value && panelRef.value.contains(target)) {\n // Scroll interno del panel — ignorar.\n return;\n }\n // Scroll inside a nested popover (Select's option list teleported\n // to <body>) should not close us either.\n if (target instanceof Element && target.closest('.modo-popover')) {\n return;\n }\n // Reposition instead of closing when the caller opted out of scroll-close.\n if (!closeOnScroll) { measure(); return; }\n close();\n }\n \n let resizeObserver: ResizeObserver | null = null; \n \n watch(isOpen, (open) => { \n if (open) { \n document.addEventListener('pointerdown', onDocumentPointerDown, true); \n document.addEventListener('keydown', onDocumentKeyDown); \n // Scroll en cualquier contenedor (incluido window) cierra el popover \n // salvo si el scroll viene desde dentro del propio panel. \n window.addEventListener('scroll', onWindowScroll, true); \n window.addEventListener('resize', onScrollOrResize); \n if (triggerRef.value && typeof ResizeObserver !== 'undefined') { \n resizeObserver = new ResizeObserver(onScrollOrResize); \n resizeObserver.observe(triggerRef.value); \n if (panelRef.value) resizeObserver.observe(panelRef.value); \n } \n } else { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n resizeObserver = null; \n } \n }); \n \n // Si el panel se monta después de open, vincularlo al ResizeObserver. \n watch(panelRef, (el) => { \n if (isOpen.value && el && resizeObserver) resizeObserver.observe(el); \n }); \n \n // Re-measure when reactive placement / matchTriggerWidth options change \n // while the popover is open (allows playgrounds to switch placement live). \n watch( \n () => [toValue(placementOption), toValue(matchTriggerWidthOption)], \n () => { if (isOpen.value) measure(); }, \n ); \n \n onBeforeUnmount(() => { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n }); \n \n return { \n triggerRef: triggerRef as Ref<HTMLElement | null>, \n panelRef: panelRef as Ref<HTMLElement | null>, \n isOpen, \n position, \n panelStyle, \n open, \n close, \n toggle, \n measure, \n }; \n}\n"],"mappings":";;;;;;;;;;;;;;AAoDA,SAAgB,WAAW,UAA6B,EAAE,EAAE;CACxD,MAAM,EACF,WAAW,kBAAkB,gBAC7B,SAAS,GACT,OAAO,MACP,mBAAmB,0BAA0B,OAC7C,sBAAsB,MACtB,gBAAgB,MAChB,gBAAgB,MAChB,QACA,YACA;CAEJ,MAAM,cAAA,GAAA,IAAA,KAAqC,KAAK;CAChD,MAAM,YAAA,GAAA,IAAA,KAAmC,KAAK;CAC9C,MAAM,UAAA,GAAA,IAAA,KAAa,MAAM;CAEzB,MAAM,Y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IAAI,OAAO,OAAO,SAAS;GACtC;CAED,CAAA,GAAA,IAAA,uBAAsB;EAClB,SAAS,oBAAoB,eAAe,uBAAuB,KAAK;EACxE,SAAS,oBAAoB,WAAW,kBAAkB;EAC1D,OAAO,oBAAoB,UAAU,gBAAgB,KAAK;EAC1D,OAAO,oBAAoB,UAAU,iBAAiB;EACtD,gBAAgB,YAAY;GAC9B;CAEF,OAAO;EACS;EACF;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACH"}
|
|
1
|
+
{"version":3,"file":"usePopover.cjs","names":[],"sources":["../../src/composables/usePopover.ts"],"sourcesContent":["import { ref, computed, onBeforeUnmount, watch, toValue, type Ref, type MaybeRefOrGetter } from 'vue'; \n \nexport type PopoverPlacement = \n | 'bottom-start' | 'bottom-end' | 'bottom-center' \n | 'top-start' | 'top-end' | 'top-center'; \n \nexport interface UsePopoverOptions { \n /** Placement inicial. @default 'bottom-start' */ \n placement?: MaybeRefOrGetter<PopoverPlacement>; \n /** Offset vertical entre trigger y panel (px). @default 6 */ \n offset?: number; \n /** Auto-flip cuando no cabe en el viewport. @default true */ \n flip?: boolean; \n /** Hacer que el panel tenga el mismo ancho del trigger. @default false */ \n matchTriggerWidth?: MaybeRefOrGetter<boolean>; \n /** Cerrar al hacer click fuera del trigger y del panel. @default true */\n closeOnClickOutside?: boolean;\n /** Cerrar con Escape. @default true */\n closeOnEscape?: boolean;\n /**\n * Cerrar cuando la página hace scroll (fuera del panel). @default true\n * Con `false` el popover se reposiciona en vez de cerrarse — útil para un\n * dropdown de búsqueda que no debe desaparecer si enfocar el input provoca\n * un pequeño auto-scroll.\n */\n closeOnScroll?: boolean;\n /** Callback cuando se abre. */ \n onOpen?: () => void; \n /** Callback cuando se cierra. */ \n onClose?: () => void; \n} \n \nexport interface PopoverPosition {\n top: number;\n left: number;\n width?: number;\n maxHeight?: number;\n /** Placement final (puede diferir del solicitado si hubo flip). */\n placement: PopoverPlacement;\n} \n \n/**\n * Floor for the viewport cap. A trigger sitting a few pixels from the bottom\n * edge would otherwise get a panel too short to show anything; below this we\n * let the panel keep its own scroll instead.\n */\nconst MIN_PANEL_HEIGHT = 120;\n\n/**\n * Content height of a panel, independent of any `max-height` we have already\n * applied to it. `getBoundingClientRect()` reports the *constrained* height\n * once capped, so it can't be used to decide whether the panel still needs a\n * cap. The panel clips vertically and its inner wrapper is the scroll\n * container, so that wrapper's `scrollHeight` (plus the panel's own vertical\n * borders) is the height the panel would take if nothing constrained it.\n */\nfunction naturalHeight(panel: HTMLElement): number {\n const inner = panel.firstElementChild as HTMLElement | null;\n if (!inner) return panel.getBoundingClientRect().height;\n const styles = getComputedStyle(panel);\n const borders =\n Number.parseFloat(styles.borderTopWidth || '0')\n + Number.parseFloat(styles.borderBottomWidth || '0');\n return Math.max(inner.scrollHeight + borders, panel.getBoundingClientRect().height);\n}\n\n/**\n * Headless composable para lógica de popover/dropdown:\n * - estado abierto/cerrado \n * - click outside + Escape \n * - posición absoluta relativa al viewport (para usar con `position: fixed`) \n * - auto-flip vertical cuando no cabe \n * - reposicionado en scroll + resize + ResizeObserver del trigger \n * \n * El caller se encarga de renderizar el trigger y el panel; este composable \n * sólo devuelve refs y estado. \n */ \nexport function usePopover(options: UsePopoverOptions = {}) { \n const { \n placement: placementOption = 'bottom-start', \n offset = 6, \n flip = true, \n matchTriggerWidth: matchTriggerWidthOption = false, \n closeOnClickOutside = true,\n closeOnEscape = true,\n closeOnScroll = true,\n onOpen,\n onClose,\n } = options;\n \n const triggerRef = ref<HTMLElement | null>(null); \n const panelRef = ref<HTMLElement | null>(null); \n const isOpen = ref(false); \n \n const position = ref<PopoverPosition>({ \n top: 0, \n left: 0, \n placement: toValue(placementOption), \n }); \n \n const panelStyle = computed(() => {\n const style: Record<string, string> = {\n position: 'fixed',\n top: `${position.value.top}px`,\n left: `${position.value.left}px`,\n zIndex: '1300',\n };\n if (position.value.width !== undefined) {\n style.width = `${position.value.width}px`;\n }\n if (position.value.maxHeight !== undefined) {\n style.maxHeight = `${position.value.maxHeight}px`;\n }\n return style;\n }); \n \n function measure(): void {\n const trigger = triggerRef.value;\n const panel = panelRef.value;\n if (!trigger) return;\n\n const initialPlacement = toValue(placementOption);\n const matchTriggerWidth = toValue(matchTriggerWidthOption);\n\n const tRect = trigger.getBoundingClientRect();\n const pRect = panel?.getBoundingClientRect();\n const panelW = pRect?.width ?? tRect.width;\n // Height the panel *wants*, ignoring any cap we applied on a previous\n // pass. The panel clips its own overflow, so its scroll container holds\n // the real content height — without this, once we cap the panel its\n // measured height equals the cap and every later decision (flip, fit)\n // would be made against our own constraint instead of the content.\n const panelH = panel ? naturalHeight(panel) : 0;\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n const margin = 8;\n\n let resolved: PopoverPlacement = initialPlacement; \n \n // Vertical flip check. \n if (flip) { \n const wantsTop = initialPlacement.startsWith('top'); \n const spaceBelow = vh - tRect.bottom - margin; \n const spaceAbove = tRect.top - margin; \n if (!wantsTop && spaceBelow < panelH && spaceAbove > spaceBelow) { \n resolved = initialPlacement.replace('bottom', 'top') as PopoverPlacement; \n } else if (wantsTop && spaceAbove < panelH && spaceBelow > spaceAbove) { \n resolved = initialPlacement.replace('top', 'bottom') as PopoverPlacement; \n } \n } \n \n const isBottom = resolved.startsWith('bottom');\n const align = resolved.split('-')[1] as 'start' | 'end' | 'center';\n\n // Vertical clamp: the panel may never grow past the edge of the\n // viewport, so cap it to whatever room the resolved side leaves. This\n // is applied unconditionally — capping only when the panel currently\n // overflows would make the cap oscillate: capped panel measures as\n // \"fits\", cap drops, content grows back past the edge, repeat.\n const availableH = isBottom\n ? vh - margin - (tRect.bottom + offset)\n : tRect.top - offset - margin;\n // A trigger scrolled past the edge of the viewport reports space that\n // does not exist on screen (`closeOnScroll: false` keeps the popover\n // open in exactly that state), so the room on the chosen side is not\n // enough on its own — the panel can never be taller than the viewport.\n const maxHeight = Math.max(\n Math.min(availableH, vh - margin * 2),\n MIN_PANEL_HEIGHT,\n );\n const renderedH = Math.min(panelH, maxHeight);\n\n let top = isBottom ? tRect.bottom + offset : tRect.top - renderedH - offset;\n\n let left: number; \n if (align === 'start') left = tRect.left; \n else if (align === 'end') left = tRect.right - panelW; \n else left = tRect.left + tRect.width / 2 - panelW / 2; \n \n // Horizontal clamp (simple, sin variante de flip lateral). \n if (left + panelW > vw - margin) left = vw - panelW - margin; \n if (left < margin) left = margin; \n \n if (top + renderedH > vh - margin) top = Math.max(margin, vh - renderedH - margin);\n if (top < margin) top = margin;\n\n position.value = {\n top,\n left,\n width: matchTriggerWidth ? tRect.width : undefined,\n maxHeight,\n placement: resolved,\n };\n }\n\n /* ---------- API ---------- */ \n \n function open() { \n if (isOpen.value) return; \n isOpen.value = true; \n onOpen?.(); \n // Medir en el próximo frame, cuando el panel ya esté en el DOM. \n requestAnimationFrame(() => { \n measure(); \n // Segunda pasada para corregir si aparecieron scrollbars. \n requestAnimationFrame(measure); \n }); \n } \n \n function close() { \n if (!isOpen.value) return; \n isOpen.value = false; \n onClose?.(); \n } \n \n function toggle() { \n isOpen.value ? close() : open(); \n } \n \n /* ---------- Listeners ---------- */ \n \n function onDocumentPointerDown(e: PointerEvent) { \n if (!isOpen.value || !closeOnClickOutside) return; \n const target = e.target as Element | null; \n if (!target) return; \n if (triggerRef.value?.contains(target)) return; \n if (panelRef.value?.contains(target)) return; \n // Click landed inside a *different* popover (e.g. a Select's \n // dropdown teleported to <body> from a child of our panel). \n // Treat any click on a `.modo-popover` ancestor as \"inside\" so \n // nested popovers don't close their parent. The parent will be \n // closed normally when the user clicks truly outside. \n if (typeof (target as Element).closest === 'function' && (target as Element).closest('.modo-popover')) { \n return; \n } \n close(); \n } \n \n function onDocumentKeyDown(e: KeyboardEvent) { \n if (!isOpen.value) return; \n if (closeOnEscape && e.key === 'Escape') { \n e.preventDefault(); \n close(); \n triggerRef.value?.focus?.(); \n } \n } \n \n function onScrollOrResize() { \n if (isOpen.value) measure(); \n } \n \n /** \n * Scroll outside del panel → cerrar. Scroll dentro del panel (p. ej. lista \n * de opciones) → no hace nada. Scroll en window/body → cerrar. \n * Se usa el evento \"scroll\" con capture para recibir cualquier scroll. \n */ \n function onWindowScroll(e: Event) {\n if (!isOpen.value) return;\n const target = e.target as Node | null;\n if (target && panelRef.value && panelRef.value.contains(target)) {\n // Scroll interno del panel — ignorar.\n return;\n }\n // Scroll inside a nested popover (Select's option list teleported\n // to <body>) should not close us either.\n if (target instanceof Element && target.closest('.modo-popover')) {\n return;\n }\n // Reposition instead of closing when the caller opted out of scroll-close.\n if (!closeOnScroll) { measure(); return; }\n close();\n }\n \n let resizeObserver: ResizeObserver | null = null;\n\n /**\n * Observe the panel *and* its scroll container. The panel itself stops\n * changing size once it hits the viewport cap, so growing content (async\n * search results, a longer list) would never notify us if we only watched\n * the outer box.\n */\n function observePanel(el: HTMLElement): void {\n resizeObserver?.observe(el);\n const inner = el.firstElementChild;\n if (inner instanceof HTMLElement) resizeObserver?.observe(inner);\n }\n\n watch(isOpen, (open) => { \n if (open) { \n document.addEventListener('pointerdown', onDocumentPointerDown, true); \n document.addEventListener('keydown', onDocumentKeyDown); \n // Scroll en cualquier contenedor (incluido window) cierra el popover \n // salvo si el scroll viene desde dentro del propio panel. \n window.addEventListener('scroll', onWindowScroll, true); \n window.addEventListener('resize', onScrollOrResize); \n if (triggerRef.value && typeof ResizeObserver !== 'undefined') { \n resizeObserver = new ResizeObserver(onScrollOrResize);\n resizeObserver.observe(triggerRef.value);\n if (panelRef.value) observePanel(panelRef.value);\n }\n } else { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n resizeObserver = null; \n } \n }); \n \n // Si el panel se monta después de open, vincularlo al ResizeObserver. \n watch(panelRef, (el) => {\n if (isOpen.value && el && resizeObserver) observePanel(el);\n });\n \n // Re-measure when reactive placement / matchTriggerWidth options change \n // while the popover is open (allows playgrounds to switch placement live). \n watch( \n () => [toValue(placementOption), toValue(matchTriggerWidthOption)], \n () => { if (isOpen.value) measure(); }, \n ); \n \n onBeforeUnmount(() => { \n document.removeEventListener('pointerdown', onDocumentPointerDown, true); \n document.removeEventListener('keydown', onDocumentKeyDown); \n window.removeEventListener('scroll', onWindowScroll, true); \n window.removeEventListener('resize', onScrollOrResize); \n resizeObserver?.disconnect(); \n }); \n \n return { \n triggerRef: triggerRef as Ref<HTMLElement | null>, \n panelRef: panelRef as Ref<HTMLElement | null>, \n isOpen, \n position, \n panelStyle, \n open, \n close, \n toggle, \n measure, \n }; \n}\n"],"mappings":";;;;;;;;AA8CA,IAAM,mBAAmB;;;;;;;;;AAUzB,SAAS,cAAc,OAA4B;CAC/C,MAAM,QAAQ,MAAM;CACpB,IAAI,CAAC,OAAO,OAAO,MAAM,uBAAuB,CAAC;CACjD,MAAM,SAAS,iBAAiB,MAAM;CACtC,MAAM,UACF,OAAO,WAAW,OAAO,kBAAkB,IAAI,GAC7C,OAAO,WAAW,OAAO,qBAAqB,IAAI;CACxD,OAAO,KAAK,IAAI,MAAM,eAAe,SAAS,MAAM,uBAAuB,CAAC,OAAO;;;;;;;;;;;;;AAcvF,SAAgB,WAAW,UAA6B,EAAE,EAAE;CACxD,MAAM,EACF,WAAW,kBAAkB,gBAC7B,SAAS,GACT,OAAO,MACP,mBAAmB,0BAA0B,OAC7C,sBAAsB,MACtB,gBAAgB,MAChB,gBAAgB,MAChB,QACA,YACA;CAEJ,MAAM,cAAA,GAAA,IAAA,KAAqC,KAAK;CAChD,MAAM,YAAA,GAAA,IAAA,KAAmC,KAAK;CAC9C,MAAM,UAAA,GAAA,IAAA,KAAa,MAAM;CAEzB,MAAM,YAAA,GAAA,IAAA,KAAgC;EAClC,KAAK;EACL,MAAM;EACN,YAAA,GAAA,IAAA,SAAmB,gBAAgB;EACtC,CAAC;CAEF,MAAM,cAAA,GAAA,IAAA,gBAA4B;EAC9B,MAAM,QAAgC;GAClC,UAAU;GACV,K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