@algorisys/zen-ui-vanilla 13.11.1 → 13.12.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.
Files changed (83) hide show
  1. package/dist/_core/calendar-follow.d.ts +39 -0
  2. package/dist/_core/index.d.ts +1 -0
  3. package/dist/components/event-calendar/event-calendar-model.d.ts +6 -0
  4. package/dist/components/event-calendar/event-calendar-model.d.ts.map +1 -1
  5. package/dist/components/event-calendar/event-calendar.d.ts.map +1 -1
  6. package/dist/components/planning-calendar/planning-calendar.d.ts.map +1 -1
  7. package/dist/index112.js +174 -165
  8. package/dist/index112.js.map +1 -1
  9. package/dist/index113.js +158 -145
  10. package/dist/index113.js.map +1 -1
  11. package/dist/index114.js +1 -1
  12. package/dist/index115.js +1 -1
  13. package/dist/index116.js +1 -1
  14. package/dist/index118.js +2 -2
  15. package/dist/index120.js +2 -2
  16. package/dist/index168.js +1 -1
  17. package/dist/index175.js +1 -1
  18. package/dist/index187.js +1 -1
  19. package/dist/index191.js +1 -1
  20. package/dist/index194.js +2 -2
  21. package/dist/index199.js +1 -1
  22. package/dist/index231.js +1 -1
  23. package/dist/index232.js +7 -7
  24. package/dist/index232.js.map +1 -1
  25. package/dist/index233.js +7 -48
  26. package/dist/index233.js.map +1 -1
  27. package/dist/index234.js +45 -37
  28. package/dist/index234.js.map +1 -1
  29. package/dist/index235.js +38 -149
  30. package/dist/index235.js.map +1 -1
  31. package/dist/index236.js +138 -177
  32. package/dist/index236.js.map +1 -1
  33. package/dist/index237.js +190 -90
  34. package/dist/index237.js.map +1 -1
  35. package/dist/index238.js +90 -444
  36. package/dist/index238.js.map +1 -1
  37. package/dist/index239.js +436 -98
  38. package/dist/index239.js.map +1 -1
  39. package/dist/index240.js +106 -2
  40. package/dist/index240.js.map +1 -1
  41. package/dist/index241.js +2 -18804
  42. package/dist/index241.js.map +1 -1
  43. package/dist/index242.js +18798 -117
  44. package/dist/index242.js.map +1 -1
  45. package/dist/index243.js +122 -13
  46. package/dist/index243.js.map +1 -1
  47. package/dist/index244.js +13 -3012
  48. package/dist/index244.js.map +1 -1
  49. package/dist/index245.js +3006 -123
  50. package/dist/index245.js.map +1 -1
  51. package/dist/index246.js +125 -140
  52. package/dist/index246.js.map +1 -1
  53. package/dist/index247.js +138 -93
  54. package/dist/index247.js.map +1 -1
  55. package/dist/index248.js +91 -104
  56. package/dist/index248.js.map +1 -1
  57. package/dist/index249.js +95 -111
  58. package/dist/index249.js.map +1 -1
  59. package/dist/index250.js +127 -4
  60. package/dist/index250.js.map +1 -1
  61. package/dist/index251.js +5 -34
  62. package/dist/index251.js.map +1 -1
  63. package/dist/index252.js +34 -9
  64. package/dist/index252.js.map +1 -1
  65. package/dist/index253.js +10 -7
  66. package/dist/index253.js.map +1 -1
  67. package/dist/index254.js +6 -15
  68. package/dist/index254.js.map +1 -1
  69. package/dist/index255.js +15 -11
  70. package/dist/index255.js.map +1 -1
  71. package/dist/index256.js +11 -3
  72. package/dist/index256.js.map +1 -1
  73. package/dist/index257.js +7 -0
  74. package/dist/index257.js.map +1 -0
  75. package/dist/previews/analytic-chart.jpg +0 -0
  76. package/dist/previews/chunk-uploader.jpg +0 -0
  77. package/dist/previews/code-editor.jpg +0 -0
  78. package/dist/previews/countdown.jpg +0 -0
  79. package/dist/previews/dynamic-date-range.jpg +0 -0
  80. package/dist/previews/loading.jpg +0 -0
  81. package/dist/previews/map.jpg +0 -0
  82. package/package.json +1 -1
  83. package/skills/zen-ui/references/api/event-calendar-event-calendar.md +1 -0
package/dist/index187.js CHANGED
@@ -78,7 +78,7 @@ function et(E) {
78
78
  x = "loading", p();
79
79
  let c;
80
80
  try {
81
- c = await import("./index241.js");
81
+ c = await import("./index242.js");
82
82
  } catch {
83
83
  if (o !== f) return;
84
84
  U("This is a PDF, and pdfjs-dist is not installed. Add it to render PDFs.");
package/dist/index191.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ariaKeyshortcut as _, parseChord as P, chordLabel as S, chordParts as j, isTypingTarget as B, matchesChord as T, isReservedChord as I, sameChord as M } from "./index242.js";
1
+ import { ariaKeyshortcut as _, parseChord as P, chordLabel as S, chordParts as j, isTypingTarget as B, matchesChord as T, isReservedChord as I, sameChord as M } from "./index243.js";
2
2
  import { Disposer as K, applyProps as L, setChildren as R } from "./index195.js";
3
3
  import { Dialog as F } from "./index10.js";
4
4
  import { useLocale as G } from "./index31.js";
package/dist/index194.js CHANGED
@@ -1,5 +1,5 @@
1
- import { clsx as r } from "./index243.js";
2
- import { extendTailwindMerge as c } from "./index244.js";
1
+ import { clsx as r } from "./index244.js";
2
+ import { extendTailwindMerge as c } from "./index245.js";
3
3
  import { zenUnoTheme as e, ZEN_PREFIX as i } from "./index210.js";
4
4
  const m = new RegExp(`^(-?)${i}(.*)$`), d = Object.keys(e.borderRadius), b = Object.keys(e.boxShadow), p = /* @__PURE__ */ new Map([["outline", "outline-solid"]]), l = c({
5
5
  // The density keys are spacing, so `zen-h-zen-control` and a caller's
package/dist/index199.js CHANGED
@@ -1,4 +1,4 @@
1
- import { clsx as O } from "./index243.js";
1
+ import { clsx as O } from "./index244.js";
2
2
  const m = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, y = O, j = (e, l) => (n) => {
3
3
  var s;
4
4
  if (l?.variants == null) return y(e, n?.class, n?.className);
package/dist/index231.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LONG_PRESS_MS as U } from "./index246.js";
1
+ import { LONG_PRESS_MS as U } from "./index247.js";
2
2
  import { planningTimeAt as O, planningPointerMove as K } from "./index230.js";
3
3
  const j = 3, z = 8, m = 40, G = 14;
4
4
  function H(t, n, o) {
package/dist/index232.js CHANGED
@@ -1,10 +1,10 @@
1
- const t = { compact: 28, comfortable: 36, touch: 48 }, a = { compact: 14, comfortable: 18, touch: 32 }, e = { compact: 12, comfortable: 16, touch: 32 }, m = { compact: 24, comfortable: 30, touch: 54 }, n = { compact: 36, comfortable: 48, touch: 64 }, r = { compact: 20, comfortable: 24, touch: 44 }, l = (o = "comfortable", c) => c ?? t[o], s = (o = "comfortable") => a[o], b = (o = "comfortable") => e[o], f = (o = "comfortable", c) => c ?? m[o], E = (o = "comfortable", c) => c ?? n[o], u = (o = "comfortable") => r[o];
1
+ function u(n, r, o) {
2
+ const t = r.find((d) => d.id === n.id);
3
+ if (!t) return { done: !0, date: null };
4
+ const e = t.start.getTime();
5
+ return e === n.from ? { done: !1, date: null } : { done: !0, date: e < o.start.getTime() || e >= o.end.getTime() ? t.start : null };
6
+ }
2
7
  export {
3
- f as calendarLanePx,
4
- E as eventHourPx,
5
- u as eventRowPx,
6
- s as ganttBarPx,
7
- b as laneBarPx,
8
- l as scheduleRowPx
8
+ u as calendarFollow
9
9
  };
10
10
  //# sourceMappingURL=index232.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index232.js","sources":["../../core/src/density.ts"],"sourcesContent":["/**\n * Component density — the opt-in `density` prop on the schedules,\n * PlanningCalendar, SpreadsheetGrid and Tree.\n *\n * bun run check:density\n *\n * The same three names as the `data-density` tokens (tokens.css). This is a\n * PROP rather than a reading of that attribute on purpose: these components\n * never followed data-density, and starting to would reflow every app that\n * already sets data-density=\"touch\" for its controls. A prop changes only the\n * component it is set on.\n *\n * \"comfortable\" is the default and is exactly the size each component always\n * drew. \"touch\" reaches 48px targets, like data-density=\"touch\" for controls.\n * An explicit size (rowHeight, laneHeight) wins over density. The classes for\n * SpreadsheetGrid and Tree live in variants.ts, which Uno scans.\n */\n\nexport type Density = \"compact\" | \"comfortable\" | \"touch\";\nexport const DENSITIES: readonly Density[] = [\"compact\", \"comfortable\", \"touch\"];\n\nconst SCHEDULE_ROW: Record<Density, number> = { compact: 28, comfortable: 36, touch: 48 };\nconst GANTT_BAR: Record<Density, number> = { compact: 14, comfortable: 18, touch: 32 };\nconst LANE_BAR: Record<Density, number> = { compact: 12, comfortable: 16, touch: 32 };\n// A calendar block is its lane less 6px: touch's 54 makes a 48px block.\nconst CALENDAR_LANE: Record<Density, number> = { compact: 24, comfortable: 30, touch: 54 };\n// EventCalendar: one hour of the time grid, and one row of a month cell or the\n// all-day strip. Touch's row is 44, the smallest target WCAG's AAA level allows,\n// rather than 48: a month cell must still fit several of them.\nconst EVENT_HOUR: Record<Density, number> = { compact: 36, comfortable: 48, touch: 64 };\nconst EVENT_ROW: Record<Density, number> = { compact: 20, comfortable: 24, touch: 44 };\n\n/** A Gantt row, or ProductionSchedule's least row height. */\nexport const scheduleRowPx = (density: Density = \"comfortable\", explicit?: number): number =>\n explicit ?? SCHEDULE_ROW[density];\n/** A Gantt bar's height. */\nexport const ganttBarPx = (density: Density = \"comfortable\"): number => GANTT_BAR[density];\n/** One lane's bar in ProductionSchedule. */\nexport const laneBarPx = (density: Density = \"comfortable\"): number => LANE_BAR[density];\n/** A PlanningCalendar lane. */\nexport const calendarLanePx = (density: Density = \"comfortable\", explicit?: number): number =>\n explicit ?? CALENDAR_LANE[density];\n/** One hour of EventCalendar's time grid. */\nexport const eventHourPx = (density: Density = \"comfortable\", explicit?: number): number =>\n explicit ?? EVENT_HOUR[density];\n/** One event row in an EventCalendar month cell or all-day strip. */\nexport const eventRowPx = (density: Density = \"comfortable\"): number => EVENT_ROW[density];\n"],"names":["SCHEDULE_ROW","GANTT_BAR","LANE_BAR","CALENDAR_LANE","EVENT_HOUR","EVENT_ROW","scheduleRowPx","density","explicit","ganttBarPx","laneBarPx","calendarLanePx","eventHourPx","eventRowPx"],"mappings":"AAqBA,MAAMA,IAAwC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAC/EC,IAAqC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAC5EC,IAAoC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAE3EC,IAAyC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAIhFC,IAAsC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAC7EC,IAAqC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAGrEC,IAAgB,CAACC,IAAmB,eAAeC,MAC9DA,KAAYR,EAAaO,CAAO,GAErBE,IAAa,CAACF,IAAmB,kBAA0BN,EAAUM,CAAO,GAE5EG,IAAY,CAACH,IAAmB,kBAA0BL,EAASK,CAAO,GAE1EI,IAAiB,CAACJ,IAAmB,eAAeC,MAC/DA,KAAYL,EAAcI,CAAO,GAEtBK,IAAc,CAACL,IAAmB,eAAeC,MAC5DA,KAAYJ,EAAWG,CAAO,GAEnBM,IAAa,CAACN,IAAmB,kBAA0BF,EAAUE,CAAO;"}
1
+ {"version":3,"file":"index232.js","sources":["../../core/src/calendar-follow.ts"],"sourcesContent":["/**\n * When a keyboard move should take the view with it — for PlanningCalendar and\n * EventCalendar alike.\n *\n * Alt+arrow on an item at the edge of the view proposes a time outside it. The\n * calendars used to move the view to the proposal AT ONCE. But they only\n * propose: the caller may confirm, refuse, or ask first. A refused move left\n * the user looking at a week the item never went to (measured in a CRM with a\n * confirm dialog: Cancel, and the view was a week away from the project).\n *\n * So the view follows the item only once the caller has APPLIED the move,\n * which is visible the only way the calendar can see it: the item's start in\n * the next `rows` / `events` is no longer where it was when the move was\n * proposed. It then follows to where the item ACTUALLY is, which may differ\n * from the proposal if the caller adjusted it (a server snapping to a slot).\n *\n * Pure, so four renderers make the same call. Pinned by scripts/check-planning.ts.\n */\n\n/** A keyboard move proposed and not yet seen applied. */\nexport interface PendingFollow {\n id: string;\n /** The item's start, in ms, when the move was proposed. */\n from: number;\n}\n\nexport interface CalendarFollowRange {\n start: Date;\n /** Exclusive. */\n end: Date;\n}\n\nexport interface CalendarFollowDecision {\n /** The move has been applied (or can no longer be): forget the pending follow. */\n done: boolean;\n /** Move the view here. Null: stay — not applied yet, or applied inside the view. */\n date: Date | null;\n}\n\nexport function calendarFollow(\n pending: PendingFollow,\n items: readonly { id: string; start: Date }[],\n range: CalendarFollowRange,\n): CalendarFollowDecision {\n const item = items.find((i) => i.id === pending.id);\n // Gone (deleted, or filtered out): there is nothing to follow, now or later.\n if (!item) return { done: true, date: null };\n const at = item.start.getTime();\n // Still where it was: not applied yet. A confirm dialog may still be open.\n if (at === pending.from) return { done: false, date: null };\n const outside = at < range.start.getTime() || at >= range.end.getTime();\n return { done: true, date: outside ? item.start : null };\n}\n"],"names":["calendarFollow","pending","items","range","item","i","at"],"mappings":"AAuCO,SAASA,EACdC,GACAC,GACAC,GACwB;AACxB,QAAMC,IAAOF,EAAM,KAAK,CAACG,MAAMA,EAAE,OAAOJ,EAAQ,EAAE;AAElD,MAAI,CAACG,EAAM,QAAO,EAAE,MAAM,IAAM,MAAM,KAAA;AACtC,QAAME,IAAKF,EAAK,MAAM,QAAA;AAEtB,SAAIE,MAAOL,EAAQ,OAAa,EAAE,MAAM,IAAO,MAAM,KAAA,IAE9C,EAAE,MAAM,IAAM,MADLK,IAAKH,EAAM,MAAM,aAAaG,KAAMH,EAAM,IAAI,QAAA,IACzBC,EAAK,QAAQ,KAAA;AACpD;"}
package/dist/index233.js CHANGED
@@ -1,51 +1,10 @@
1
- import { agendaGroups as p, eventCalendarRange as m } from "./index117.js";
2
- import { toNodes as l } from "./index195.js";
3
- import { eventItem as f } from "./index245.js";
4
- import { el as o, sameDay as u, markMoving as c } from "./index234.js";
5
- import { cn as i } from "./index194.js";
6
- function b(n, z, d) {
7
- const s = o("ul", "zen-m-0 zen-flex zen-list-none zen-flex-col zen-gap-0.5 zen-p-0");
8
- for (const t of d) {
9
- const e = z[t.index], r = o("li", "zen-flex zen-min-w-0 zen-items-center zen-gap-3 zen-rounded-zen-sm hover:zen-bg-zen-muted"), a = o(
10
- "span",
11
- "zen-w-32 zen-shrink-0 zen-ps-1.5 zen-text-xs zen-tabular-nums zen-text-zen-muted-fg",
12
- t.allDay ? n.loc.t("eventCalendar.allDay") : n.timeLabel(e)
13
- );
14
- a.setAttribute("aria-hidden", "true"), r.append(
15
- a,
16
- f(n, e, {
17
- variant: "row",
18
- continuesBefore: t.continuesBefore,
19
- continuesAfter: t.continuesAfter,
20
- class: "zen-min-h-8 zen-flex-1"
21
- })
22
- ), s.append(r);
23
- }
24
- return s;
25
- }
26
- function w(n) {
27
- const z = n.props.events ?? [], d = p(z, m("agenda", n.anchor, n.options)), s = (e) => new Intl.DateTimeFormat(n.loc.locale, { weekday: "long", day: "numeric", month: "long" }).format(e), t = o("div", "zen-rounded-zen-md zen-border zen-border-zen-border");
28
- if (d.length === 0) {
29
- const e = o("p", "zen-m-0 zen-py-10 zen-text-center zen-text-sm zen-text-zen-muted-fg");
30
- e.append(...l(n.props.emptyMessage ?? n.loc.t("eventCalendar.noEvents"))), t.append(e);
31
- }
32
- for (const e of d) {
33
- const r = o(
34
- "section",
35
- i("zen-flex zen-flex-col zen-gap-1 zen-border-b zen-border-zen-border zen-px-3 zen-py-2 last:zen-border-b-0", n.props.dayClassName?.(e.date))
36
- );
37
- r.setAttribute("aria-label", s(e.date));
38
- const a = o(
39
- "p",
40
- i("zen-m-0 zen-text-sm zen-font-semibold", u(e.date, n.now) ? "zen-text-zen-primary" : "zen-text-zen-foreground"),
41
- s(e.date)
42
- );
43
- a.setAttribute("aria-hidden", "true"), r.append(a, b(n, z, e.items)), t.append(r);
44
- }
45
- return { el: t, applyPreview: (e) => c(n.root, e?.eventId) };
46
- }
1
+ const t = { compact: 28, comfortable: 36, touch: 48 }, a = { compact: 14, comfortable: 18, touch: 32 }, e = { compact: 12, comfortable: 16, touch: 32 }, m = { compact: 24, comfortable: 30, touch: 54 }, n = { compact: 36, comfortable: 48, touch: 64 }, r = { compact: 20, comfortable: 24, touch: 44 }, l = (o = "comfortable", c) => c ?? t[o], s = (o = "comfortable") => a[o], b = (o = "comfortable") => e[o], f = (o = "comfortable", c) => c ?? m[o], E = (o = "comfortable", c) => c ?? n[o], u = (o = "comfortable") => r[o];
47
2
  export {
48
- w as agenda,
49
- b as dayList
3
+ f as calendarLanePx,
4
+ E as eventHourPx,
5
+ u as eventRowPx,
6
+ s as ganttBarPx,
7
+ b as laneBarPx,
8
+ l as scheduleRowPx
50
9
  };
51
10
  //# sourceMappingURL=index233.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index233.js","sources":["../src/components/event-calendar/event-calendar-agenda.ts"],"sourcesContent":["import { agendaGroups, eventCalendarRange, type AgendaItem } from \"@algorisys/zen-ui-core/event-calendar\";\nimport { cn } from \"../../lib/cn\";\nimport { toNodes } from \"../../lib/component\";\nimport { eventItem } from \"./event-calendar-item\";\nimport { type CalendarContext, type CalendarEvent, type CalendarViewHandle, el, markMoving, sameDay } from \"./event-calendar-model\";\n\n/** One day's events as a list: the agenda's rows, and the month's \"+N more\" panel. */\nexport function dayList(cal: CalendarContext, events: CalendarEvent[], items: AgendaItem[]): HTMLElement {\n const list = el(\"ul\", \"zen-m-0 zen-flex zen-list-none zen-flex-col zen-gap-0.5 zen-p-0\");\n for (const item of items) {\n const event = events[item.index];\n const li = el(\"li\", \"zen-flex zen-min-w-0 zen-items-center zen-gap-3 zen-rounded-zen-sm hover:zen-bg-zen-muted\");\n const time = el(\n \"span\",\n \"zen-w-32 zen-shrink-0 zen-ps-1.5 zen-text-xs zen-tabular-nums zen-text-zen-muted-fg\",\n item.allDay ? cal.loc.t(\"eventCalendar.allDay\") : cal.timeLabel(event),\n );\n time.setAttribute(\"aria-hidden\", \"true\");\n li.append(\n time,\n eventItem(cal, event, {\n variant: \"row\",\n continuesBefore: item.continuesBefore,\n continuesAfter: item.continuesAfter,\n class: \"zen-min-h-8 zen-flex-1\",\n }),\n );\n list.append(li);\n }\n return list;\n}\n\nexport function agenda(cal: CalendarContext): CalendarViewHandle {\n const events = cal.props.events ?? [];\n const groups = agendaGroups(events, eventCalendarRange(\"agenda\", cal.anchor, cal.options));\n const heading = (d: Date) => new Intl.DateTimeFormat(cal.loc.locale, { weekday: \"long\", day: \"numeric\", month: \"long\" }).format(d);\n const box = el(\"div\", \"zen-rounded-zen-md zen-border zen-border-zen-border\");\n\n if (groups.length === 0) {\n const empty = el(\"p\", \"zen-m-0 zen-py-10 zen-text-center zen-text-sm zen-text-zen-muted-fg\");\n empty.append(...toNodes(cal.props.emptyMessage ?? cal.loc.t(\"eventCalendar.noEvents\")));\n box.append(empty);\n }\n for (const group of groups) {\n const section = el(\n \"section\",\n cn(\"zen-flex zen-flex-col zen-gap-1 zen-border-b zen-border-zen-border zen-px-3 zen-py-2 last:zen-border-b-0\", cal.props.dayClassName?.(group.date)),\n );\n section.setAttribute(\"aria-label\", heading(group.date));\n const label = el(\n \"p\",\n cn(\"zen-m-0 zen-text-sm zen-font-semibold\", sameDay(group.date, cal.now) ? \"zen-text-zen-primary\" : \"zen-text-zen-foreground\"),\n heading(group.date),\n );\n label.setAttribute(\"aria-hidden\", \"true\");\n section.append(label, dayList(cal, events, group.items));\n box.append(section);\n }\n\n return { el: box, applyPreview: (preview) => markMoving(cal.root, preview?.eventId) };\n}\n"],"names":["dayList","cal","events","items","list","el","item","event","li","time","eventItem","agenda","groups","agendaGroups","eventCalendarRange","heading","d","box","empty","toNodes","group","section","cn","label","sameDay","preview","markMoving"],"mappings":";;;;;AAOO,SAASA,EAAQC,GAAsBC,GAAyBC,GAAkC;AACvG,QAAMC,IAAOC,EAAG,MAAM,iEAAiE;AACvF,aAAWC,KAAQH,GAAO;AACxB,UAAMI,IAAQL,EAAOI,EAAK,KAAK,GACzBE,IAAKH,EAAG,MAAM,2FAA2F,GACzGI,IAAOJ;AAAA,MACX;AAAA,MACA;AAAA,MACAC,EAAK,SAASL,EAAI,IAAI,EAAE,sBAAsB,IAAIA,EAAI,UAAUM,CAAK;AAAA,IAAA;AAEvE,IAAAE,EAAK,aAAa,eAAe,MAAM,GACvCD,EAAG;AAAA,MACDC;AAAA,MACAC,EAAUT,GAAKM,GAAO;AAAA,QACpB,SAAS;AAAA,QACT,iBAAiBD,EAAK;AAAA,QACtB,gBAAgBA,EAAK;AAAA,QACrB,OAAO;AAAA,MAAA,CACR;AAAA,IAAA,GAEHF,EAAK,OAAOI,CAAE;AAAA,EAChB;AACA,SAAOJ;AACT;AAEO,SAASO,EAAOV,GAA0C;AAC/D,QAAMC,IAASD,EAAI,MAAM,UAAU,CAAA,GAC7BW,IAASC,EAAaX,GAAQY,EAAmB,UAAUb,EAAI,QAAQA,EAAI,OAAO,CAAC,GACnFc,IAAU,CAACC,MAAY,IAAI,KAAK,eAAef,EAAI,IAAI,QAAQ,EAAE,SAAS,QAAQ,KAAK,WAAW,OAAO,QAAQ,EAAE,OAAOe,CAAC,GAC3HC,IAAMZ,EAAG,OAAO,qDAAqD;AAE3E,MAAIO,EAAO,WAAW,GAAG;AACvB,UAAMM,IAAQb,EAAG,KAAK,qEAAqE;AAC3F,IAAAa,EAAM,OAAO,GAAGC,EAAQlB,EAAI,MAAM,gBAAgBA,EAAI,IAAI,EAAE,wBAAwB,CAAC,CAAC,GACtFgB,EAAI,OAAOC,CAAK;AAAA,EAClB;AACA,aAAWE,KAASR,GAAQ;AAC1B,UAAMS,IAAUhB;AAAA,MACd;AAAA,MACAiB,EAAG,4GAA4GrB,EAAI,MAAM,eAAemB,EAAM,IAAI,CAAC;AAAA,IAAA;AAErJ,IAAAC,EAAQ,aAAa,cAAcN,EAAQK,EAAM,IAAI,CAAC;AACtD,UAAMG,IAAQlB;AAAA,MACZ;AAAA,MACAiB,EAAG,yCAAyCE,EAAQJ,EAAM,MAAMnB,EAAI,GAAG,IAAI,yBAAyB,yBAAyB;AAAA,MAC7Hc,EAAQK,EAAM,IAAI;AAAA,IAAA;AAEpB,IAAAG,EAAM,aAAa,eAAe,MAAM,GACxCF,EAAQ,OAAOE,GAAOvB,EAAQC,GAAKC,GAAQkB,EAAM,KAAK,CAAC,GACvDH,EAAI,OAAOI,CAAO;AAAA,EACpB;AAEA,SAAO,EAAE,IAAIJ,GAAK,cAAc,CAACQ,MAAYC,EAAWzB,EAAI,MAAMwB,GAAS,OAAO,EAAA;AACpF;"}
1
+ {"version":3,"file":"index233.js","sources":["../../core/src/density.ts"],"sourcesContent":["/**\n * Component density — the opt-in `density` prop on the schedules,\n * PlanningCalendar, SpreadsheetGrid and Tree.\n *\n * bun run check:density\n *\n * The same three names as the `data-density` tokens (tokens.css). This is a\n * PROP rather than a reading of that attribute on purpose: these components\n * never followed data-density, and starting to would reflow every app that\n * already sets data-density=\"touch\" for its controls. A prop changes only the\n * component it is set on.\n *\n * \"comfortable\" is the default and is exactly the size each component always\n * drew. \"touch\" reaches 48px targets, like data-density=\"touch\" for controls.\n * An explicit size (rowHeight, laneHeight) wins over density. The classes for\n * SpreadsheetGrid and Tree live in variants.ts, which Uno scans.\n */\n\nexport type Density = \"compact\" | \"comfortable\" | \"touch\";\nexport const DENSITIES: readonly Density[] = [\"compact\", \"comfortable\", \"touch\"];\n\nconst SCHEDULE_ROW: Record<Density, number> = { compact: 28, comfortable: 36, touch: 48 };\nconst GANTT_BAR: Record<Density, number> = { compact: 14, comfortable: 18, touch: 32 };\nconst LANE_BAR: Record<Density, number> = { compact: 12, comfortable: 16, touch: 32 };\n// A calendar block is its lane less 6px: touch's 54 makes a 48px block.\nconst CALENDAR_LANE: Record<Density, number> = { compact: 24, comfortable: 30, touch: 54 };\n// EventCalendar: one hour of the time grid, and one row of a month cell or the\n// all-day strip. Touch's row is 44, the smallest target WCAG's AAA level allows,\n// rather than 48: a month cell must still fit several of them.\nconst EVENT_HOUR: Record<Density, number> = { compact: 36, comfortable: 48, touch: 64 };\nconst EVENT_ROW: Record<Density, number> = { compact: 20, comfortable: 24, touch: 44 };\n\n/** A Gantt row, or ProductionSchedule's least row height. */\nexport const scheduleRowPx = (density: Density = \"comfortable\", explicit?: number): number =>\n explicit ?? SCHEDULE_ROW[density];\n/** A Gantt bar's height. */\nexport const ganttBarPx = (density: Density = \"comfortable\"): number => GANTT_BAR[density];\n/** One lane's bar in ProductionSchedule. */\nexport const laneBarPx = (density: Density = \"comfortable\"): number => LANE_BAR[density];\n/** A PlanningCalendar lane. */\nexport const calendarLanePx = (density: Density = \"comfortable\", explicit?: number): number =>\n explicit ?? CALENDAR_LANE[density];\n/** One hour of EventCalendar's time grid. */\nexport const eventHourPx = (density: Density = \"comfortable\", explicit?: number): number =>\n explicit ?? EVENT_HOUR[density];\n/** One event row in an EventCalendar month cell or all-day strip. */\nexport const eventRowPx = (density: Density = \"comfortable\"): number => EVENT_ROW[density];\n"],"names":["SCHEDULE_ROW","GANTT_BAR","LANE_BAR","CALENDAR_LANE","EVENT_HOUR","EVENT_ROW","scheduleRowPx","density","explicit","ganttBarPx","laneBarPx","calendarLanePx","eventHourPx","eventRowPx"],"mappings":"AAqBA,MAAMA,IAAwC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAC/EC,IAAqC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAC5EC,IAAoC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAE3EC,IAAyC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAIhFC,IAAsC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAC7EC,IAAqC,EAAE,SAAS,IAAI,aAAa,IAAI,OAAO,GAAA,GAGrEC,IAAgB,CAACC,IAAmB,eAAeC,MAC9DA,KAAYR,EAAaO,CAAO,GAErBE,IAAa,CAACF,IAAmB,kBAA0BN,EAAUM,CAAO,GAE5EG,IAAY,CAACH,IAAmB,kBAA0BL,EAASK,CAAO,GAE1EI,IAAiB,CAACJ,IAAmB,eAAeC,MAC/DA,KAAYL,EAAcI,CAAO,GAEtBK,IAAc,CAACL,IAAmB,eAAeC,MAC5DA,KAAYJ,EAAWG,CAAO,GAEnBM,IAAa,CAACN,IAAmB,kBAA0BF,EAAUE,CAAO;"}
package/dist/index234.js CHANGED
@@ -1,43 +1,51 @@
1
- import { cn as r } from "./index194.js";
2
- const f = {
3
- default: "zen-bg-zen-primary-soft zen-text-zen-primary-soft-fg zen-border-zen-primary",
4
- info: "zen-bg-zen-info-soft zen-text-zen-info-soft-fg zen-border-zen-info",
5
- success: "zen-bg-zen-success-soft zen-text-zen-success-soft-fg zen-border-zen-success",
6
- warning: "zen-bg-zen-warning-soft zen-text-zen-warning-soft-fg zen-border-zen-warning",
7
- error: "zen-bg-zen-error-soft zen-text-zen-error-soft-fg zen-border-zen-error"
8
- }, g = {
9
- default: "zen-bg-zen-primary",
10
- info: "zen-bg-zen-info",
11
- success: "zen-bg-zen-success",
12
- warning: "zen-bg-zen-warning",
13
- error: "zen-bg-zen-error"
14
- }, s = "zen-opacity-40", z = "zen-bg-zen-primary-soft", i = (n) => !!n && getComputedStyle(n).direction === "rtl", a = (n, e) => n.getFullYear() === e.getFullYear() && n.getMonth() === e.getMonth() && n.getDate() === e.getDate(), l = (n, e, t) => {
15
- const o = document.createElement(n);
16
- return e && (o.className = e), t !== void 0 && (o.textContent = t), o;
17
- };
18
- function u(n, e, t) {
19
- !e || t === "chip" || t === "row" || (n.style.backgroundColor = `color-mix(in srgb, ${e} 18%, var(--zen-color-background))`, n.style.borderColor = e, n.style.color = "var(--zen-color-foreground)");
20
- }
21
- function b(n, e) {
22
- for (const t of n) {
23
- const o = e !== null && t.day >= e.start && t.day < e.end;
24
- t.node.className = r(t.base, o && z);
1
+ import { agendaGroups as p, eventCalendarRange as m } from "./index117.js";
2
+ import { toNodes as l } from "./index195.js";
3
+ import { eventItem as f } from "./index246.js";
4
+ import { el as o, sameDay as u, markMoving as c } from "./index235.js";
5
+ import { cn as i } from "./index194.js";
6
+ function b(n, z, d) {
7
+ const s = o("ul", "zen-m-0 zen-flex zen-list-none zen-flex-col zen-gap-0.5 zen-p-0");
8
+ for (const t of d) {
9
+ const e = z[t.index], r = o("li", "zen-flex zen-min-w-0 zen-items-center zen-gap-3 zen-rounded-zen-sm hover:zen-bg-zen-muted"), a = o(
10
+ "span",
11
+ "zen-w-32 zen-shrink-0 zen-ps-1.5 zen-text-xs zen-tabular-nums zen-text-zen-muted-fg",
12
+ t.allDay ? n.loc.t("eventCalendar.allDay") : n.timeLabel(e)
13
+ );
14
+ a.setAttribute("aria-hidden", "true"), r.append(
15
+ a,
16
+ f(n, e, {
17
+ variant: "row",
18
+ continuesBefore: t.continuesBefore,
19
+ continuesAfter: t.continuesAfter,
20
+ class: "zen-min-h-8 zen-flex-1"
21
+ })
22
+ ), s.append(r);
25
23
  }
24
+ return s;
26
25
  }
27
- function d(n, e) {
28
- for (const t of n.querySelectorAll("[data-cal-event]"))
29
- t.classList.toggle(s, e !== void 0 && t.getAttribute("data-cal-event") === e);
26
+ function w(n) {
27
+ const z = n.props.events ?? [], d = p(z, m("agenda", n.anchor, n.options)), s = (e) => new Intl.DateTimeFormat(n.loc.locale, { weekday: "long", day: "numeric", month: "long" }).format(e), t = o("div", "zen-rounded-zen-md zen-border zen-border-zen-border");
28
+ if (d.length === 0) {
29
+ const e = o("p", "zen-m-0 zen-py-10 zen-text-center zen-text-sm zen-text-zen-muted-fg");
30
+ e.append(...l(n.props.emptyMessage ?? n.loc.t("eventCalendar.noEvents"))), t.append(e);
31
+ }
32
+ for (const e of d) {
33
+ const r = o(
34
+ "section",
35
+ i("zen-flex zen-flex-col zen-gap-1 zen-border-b zen-border-zen-border zen-px-3 zen-py-2 last:zen-border-b-0", n.props.dayClassName?.(e.date))
36
+ );
37
+ r.setAttribute("aria-label", s(e.date));
38
+ const a = o(
39
+ "p",
40
+ i("zen-m-0 zen-text-sm zen-font-semibold", u(e.date, n.now) ? "zen-text-zen-primary" : "zen-text-zen-foreground"),
41
+ s(e.date)
42
+ );
43
+ a.setAttribute("aria-hidden", "true"), r.append(a, b(n, z, e.items)), t.append(r);
44
+ }
45
+ return { el: t, applyPreview: (e) => c(n.root, e?.eventId) };
30
46
  }
31
47
  export {
32
- g as DOT_CLASS,
33
- z as LIT_CLASS,
34
- s as MOVING_CLASS,
35
- f as STATE_CLASS,
36
- u as applyCustomColor,
37
- l as el,
38
- i as isRtl,
39
- d as markMoving,
40
- b as relight,
41
- a as sameDay
48
+ w as agenda,
49
+ b as dayList
42
50
  };
43
51
  //# sourceMappingURL=index234.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index234.js","sources":["../src/components/event-calendar/event-calendar-model.ts"],"sourcesContent":["import type {\n CalendarProposedSpan,\n EventCalendarOptions,\n SlotCursor,\n EventCalendarView,\n Weekday,\n} from \"@algorisys/zen-ui-core/event-calendar\";\nimport type { Density } from \"@algorisys/zen-ui-core/density\";\nimport { cn } from \"../../lib/cn\";\nimport type { AnyZenComponent, BaseProps, Child } from \"../../lib/component\";\nimport type { useLocale } from \"../locale/locale\";\n\nexport type CalendarEventState = \"default\" | \"info\" | \"success\" | \"warning\" | \"error\";\n\nexport interface CalendarEvent {\n id: string;\n title: string;\n start: Date;\n /** Exclusive. For an all-day event, the first day NOT included (or the same day for a one-day event). */\n end: Date;\n allDay?: boolean;\n /** Token colour. \"default\" is the primary tint. */\n state?: CalendarEventState;\n /** Any CSS colour; wins over `state`. For a per-calendar colour from your own map. */\n color?: string;\n location?: string;\n /** Minutes before the start. Shown as a mark; zen-ui does not fire reminders. */\n reminders?: number[];\n /** Shown as a mark. Expand the occurrences before passing them (see `expandRecurrence`). */\n recurring?: boolean;\n /** \"task\" draws a checkbox; `done` strikes it through. */\n kind?: \"event\" | \"task\";\n done?: boolean;\n /** Never offered for moving or resizing, whatever `canEditEvent` says. */\n readOnly?: boolean;\n /**\n * Render the event as a link to this URL, so middle-click and \"open in new\n * tab\" work. `onEventClick` still fires on a plain click; the browser then\n * follows the link.\n */\n href?: string;\n}\n\nexport interface CalendarSlot {\n start: Date;\n /** Exclusive. */\n end: Date;\n allDay: boolean;\n}\n\nexport interface CalendarEventChange {\n /** The event as you passed it. */\n event: CalendarEvent;\n start: Date;\n end: Date;\n allDay: boolean;\n kind: \"move\" | \"resize\";\n}\n\nexport type CalendarEventVariant = \"block\" | \"bar\" | \"chip\" | \"row\";\n\nexport interface CalendarEventRenderContext {\n view: EventCalendarView;\n /** \"block\" in a time grid, \"bar\" for multi-day and all-day, \"chip\" for a timed event in a month cell, \"row\" in lists. */\n variant: CalendarEventVariant;\n /** \"09:00 – 10:30\" or the localised \"All day\". */\n timeLabel: string;\n /** Too short for a second line. */\n compact: boolean;\n}\n\nexport interface EventCalendarProps extends BaseProps {\n events: CalendarEvent[];\n /** Starting view. The factory owns it after that; pass `view` (or call update) to control it. Default \"week\". */\n defaultView?: EventCalendarView;\n view?: EventCalendarView;\n onViewChange?: (view: EventCalendarView) => void;\n /** Which views the switcher offers, in order. Default month, week, day, agenda. */\n views?: EventCalendarView[];\n /** Any date inside the range to open on. Default today. */\n defaultDate?: Date;\n date?: Date;\n onDateChange?: (date: Date) => void;\n /** Reference \"now\" for today and the now line. Injectable for tests and demos. */\n now?: Date;\n /** First column of a week. Default 1 (Monday). */\n weekStartsOn?: Weekday;\n /** Shaded, and left out of the work-week view. Default [0, 6]. */\n nonWorkingDays?: number[];\n /** [from, to) hours drawn unshaded in the time grid. Default [9, 18]. */\n workingHours?: [number, number];\n /** Days shown by the agenda. Default 14. */\n agendaDays?: number;\n /** Hour scrolled to the top of the time grid when it opens. Default 8. */\n scrollToHour?: number;\n /** Pixels per hour in the time grid. Wins over `density`. */\n hourHeight?: number;\n /** \"compact\", \"comfortable\" (default) or \"touch\" (44px rows, 64px hours). */\n density?: Density;\n /** Height of the time grid's scrolling area in px. Default 576. */\n height?: number;\n /** Minutes a drag snaps to, and a keyboard step. Default 15. */\n snapMinutes?: number;\n /** Length of the slot a single click selects. Default 60. */\n newEventMinutes?: number;\n /** Rows of events in a month cell before \"+N more\". Default 3. */\n maxEventsPerDay?: number;\n onEventClick?: (event: CalendarEvent) => void;\n /** Empty time was clicked or dragged across. Without it, empty time is not interactive. */\n onSlotSelect?: (slot: CalendarSlot) => void;\n /** A move or resize, proposed. Nothing changes until you pass back new `events`. Without it the calendar is read-only. */\n onEventChange?: (change: CalendarEventChange) => void;\n /** Per-event gate for editing. A blocked event is not draggable at all, rather than refused on drop. */\n canEditEvent?: (event: CalendarEvent) => boolean;\n /** A task's checkbox was toggled. Without it the checkbox is shown but disabled. */\n onTaskToggle?: (event: CalendarEvent, done: boolean) => void;\n /** Replace an event's content (title, time, marks). The calendar keeps the box, the colour and the controls. */\n renderEvent?: (event: CalendarEvent, context: CalendarEventRenderContext) => Child;\n /** Extra classes on an event's box. */\n eventClassName?: (event: CalendarEvent) => string | undefined;\n /** Extra classes on a day: a month cell, a time-grid column and its header. Holidays, closures. */\n dayClassName?: (date: Date) => string | undefined;\n /** Extra classes on the row of day headers. */\n headerClassName?: string;\n /** Your own controls, at the end of the toolbar. */\n toolbarActions?: Child;\n /** Hide the toolbar when your page already has one (drive `view` and `date` yourself). */\n hideToolbar?: boolean;\n /** What the agenda says when nothing is on. */\n emptyMessage?: Child;\n}\n\nexport interface CalendarPreview {\n kind: \"move\" | \"resize\" | \"select\";\n /** Where the drag is happening, which decides how the preview is drawn. */\n surface: \"time\" | \"day\";\n /** The event being moved or resized. */\n eventId?: string;\n span: CalendarProposedSpan;\n}\n\n/**\n * What one render owns: the components it built and the listeners it added to\n * nodes it created. Both are released before the next render and on destroy,\n * because a full re-render with nothing released leaks a listener per event\n * per render.\n */\nexport interface RenderScope {\n keep<T extends AnyZenComponent>(component: T): T;\n on<K extends keyof HTMLElementEventMap>(\n node: HTMLElement,\n type: K,\n listener: (event: HTMLElementEventMap[K]) => void,\n ): void;\n /** Run when this render is released (an observer to disconnect, say). */\n onRelease(cleanup: () => void): void;\n}\n\n/**\n * View state that must outlive a render. The factory rebuilds its DOM when the\n * data changes; without this the slot cursor, the focused day and the grid's\n * scroll position would all reset every time the caller passed new events.\n */\nexport interface CalendarMemory {\n cursor?: SlotCursor;\n focusedDay?: Date;\n /** Set by keyboard paging only: focus `focusedDay` once the new page is built. */\n focusDayAfterRender?: boolean;\n scrollTop?: number;\n /** The view the scroll position belongs to; a new view scrolls to scrollToHour instead. */\n scrollView?: string;\n /** The day whose \"+N more\" panel is open, kept open across a re-render. */\n openMore?: string;\n}\n\n/** What the root hands every view for one render. */\nexport interface CalendarContext {\n memory: CalendarMemory;\n props: EventCalendarProps;\n loc: ReturnType<typeof useLocale>;\n scope: RenderScope;\n view: EventCalendarView;\n anchor: Date;\n now: Date;\n options: EventCalendarOptions;\n hourPx: number;\n rowPx: number;\n snap: number;\n root: HTMLElement;\n hintId: string;\n /** The preview in progress when this render started (a re-render during a drag). */\n preview: CalendarPreview | null;\n setPreview: (preview: CalendarPreview | null) => void;\n editable: (event: CalendarEvent) => boolean;\n selectable: boolean;\n canGoToDay: boolean;\n goToDay: (date: Date) => void;\n setDate: (date: Date) => void;\n openEvent: (event: CalendarEvent) => void;\n toggleTask: (event: CalendarEvent) => void;\n selectSlot: (slot: CalendarSlot) => void;\n propose: (event: CalendarEvent, span: CalendarProposedSpan, kind: \"move\" | \"resize\", fromKeyboard: boolean) => void;\n timeLabel: (span: { start: Date; end: Date; allDay?: boolean }) => string;\n announce: (text: string) => void;\n}\n\n/** A built view: its element, and how it shows a drag in progress without being rebuilt. */\nexport interface CalendarViewHandle {\n el: HTMLElement;\n /** Draw (or clear) the preview in place. A drag updates it every frame; rebuilding the view each frame would drop focus and thrash layout. */\n applyPreview(preview: CalendarPreview | null): void;\n /** Called once the view is in the document (scroll position, focus). */\n mounted?(): void;\n}\n\nexport const STATE_CLASS: Record<CalendarEventState, string> = {\n default: \"zen-bg-zen-primary-soft zen-text-zen-primary-soft-fg zen-border-zen-primary\",\n info: \"zen-bg-zen-info-soft zen-text-zen-info-soft-fg zen-border-zen-info\",\n success: \"zen-bg-zen-success-soft zen-text-zen-success-soft-fg zen-border-zen-success\",\n warning: \"zen-bg-zen-warning-soft zen-text-zen-warning-soft-fg zen-border-zen-warning\",\n error: \"zen-bg-zen-error-soft zen-text-zen-error-soft-fg zen-border-zen-error\",\n};\n\nexport const DOT_CLASS: Record<CalendarEventState, string> = {\n default: \"zen-bg-zen-primary\",\n info: \"zen-bg-zen-info\",\n success: \"zen-bg-zen-success\",\n warning: \"zen-bg-zen-warning\",\n error: \"zen-bg-zen-error\",\n};\n\n/** The class a drag adds to the event it is moving. */\nexport const MOVING_CLASS = \"zen-opacity-40\";\n/** The class a preview adds to a day it covers. */\nexport const LIT_CLASS = \"zen-bg-zen-primary-soft\";\n\nexport const isRtl = (node: Element | null | undefined): boolean => !!node && getComputedStyle(node).direction === \"rtl\";\n\nexport const sameDay = (a: Date, b: Date) =>\n a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();\n\nexport const el = <K extends keyof HTMLElementTagNameMap>(\n tag: K,\n className?: string,\n text?: string,\n): HTMLElementTagNameMap[K] => {\n const node = document.createElement(tag);\n if (className) node.className = className;\n if (text !== undefined) node.textContent = text;\n return node;\n};\n\n/**\n * A caller's colour as a tint with a solid edge, mixed against the theme's\n * background so it reads in dark mode; the text stays the theme's foreground.\n */\nexport function applyCustomColor(node: HTMLElement, color: string | undefined, variant: CalendarEventVariant): void {\n if (!color || variant === \"chip\" || variant === \"row\") return;\n node.style.backgroundColor = `color-mix(in srgb, ${color} 18%, var(--zen-color-background))`;\n node.style.borderColor = color;\n node.style.color = \"var(--zen-color-foreground)\";\n}\n\n/**\n * The cells a day-surface preview lights, by recomputing their class from the\n * base they were built with: adding the tint beside a weekend shade would leave\n * the two fighting on stylesheet order.\n */\nexport function relight(cells: Array<{ node: HTMLElement; base: string; day: Date }>, range: { start: Date; end: Date } | null): void {\n for (const cell of cells) {\n const lit = range !== null && cell.day >= range.start && cell.day < range.end;\n cell.node.className = cn(cell.base, lit && LIT_CLASS);\n }\n}\n\n/** Dim the event being dragged (every piece of it) and undim the rest. */\nexport function markMoving(root: HTMLElement, id: string | undefined): void {\n for (const node of root.querySelectorAll<HTMLElement>(\"[data-cal-event]\")) {\n node.classList.toggle(MOVING_CLASS, id !== undefined && node.getAttribute(\"data-cal-event\") === id);\n }\n}\n"],"names":["STATE_CLASS","DOT_CLASS","MOVING_CLASS","LIT_CLASS","isRtl","node","sameDay","a","b","el","tag","className","text","applyCustomColor","color","variant","relight","cells","range","cell","lit","cn","markMoving","root","id"],"mappings":";AAuNO,MAAMA,IAAkD;AAAA,EAC7D,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,GAEaC,IAAgD;AAAA,EAC3D,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,GAGaC,IAAe,kBAEfC,IAAY,2BAEZC,IAAQ,CAACC,MAA8C,CAAC,CAACA,KAAQ,iBAAiBA,CAAI,EAAE,cAAc,OAEtGC,IAAU,CAACC,GAASC,MAC/BD,EAAE,YAAA,MAAkBC,EAAE,YAAA,KAAiBD,EAAE,SAAA,MAAeC,EAAE,SAAA,KAAcD,EAAE,QAAA,MAAcC,EAAE,QAAA,GAE/EC,IAAK,CAChBC,GACAC,GACAC,MAC6B;AAC7B,QAAMP,IAAO,SAAS,cAAcK,CAAG;AACvC,SAAIC,QAAgB,YAAYA,IAC5BC,MAAS,WAAWP,EAAK,cAAcO,IACpCP;AACT;AAMO,SAASQ,EAAiBR,GAAmBS,GAA2BC,GAAqC;AAClH,EAAI,CAACD,KAASC,MAAY,UAAUA,MAAY,UAChDV,EAAK,MAAM,kBAAkB,sBAAsBS,CAAK,sCACxDT,EAAK,MAAM,cAAcS,GACzBT,EAAK,MAAM,QAAQ;AACrB;AAOO,SAASW,EAAQC,GAA8DC,GAAgD;AACpI,aAAWC,KAAQF,GAAO;AACxB,UAAMG,IAAMF,MAAU,QAAQC,EAAK,OAAOD,EAAM,SAASC,EAAK,MAAMD,EAAM;AAC1E,IAAAC,EAAK,KAAK,YAAYE,EAAGF,EAAK,MAAMC,KAAOjB,CAAS;AAAA,EACtD;AACF;AAGO,SAASmB,EAAWC,GAAmBC,GAA8B;AAC1E,aAAWnB,KAAQkB,EAAK,iBAA8B,kBAAkB;AACtE,IAAAlB,EAAK,UAAU,OAAOH,GAAcsB,MAAO,UAAanB,EAAK,aAAa,gBAAgB,MAAMmB,CAAE;AAEtG;"}
1
+ {"version":3,"file":"index234.js","sources":["../src/components/event-calendar/event-calendar-agenda.ts"],"sourcesContent":["import { agendaGroups, eventCalendarRange, type AgendaItem } from \"@algorisys/zen-ui-core/event-calendar\";\nimport { cn } from \"../../lib/cn\";\nimport { toNodes } from \"../../lib/component\";\nimport { eventItem } from \"./event-calendar-item\";\nimport { type CalendarContext, type CalendarEvent, type CalendarViewHandle, el, markMoving, sameDay } from \"./event-calendar-model\";\n\n/** One day's events as a list: the agenda's rows, and the month's \"+N more\" panel. */\nexport function dayList(cal: CalendarContext, events: CalendarEvent[], items: AgendaItem[]): HTMLElement {\n const list = el(\"ul\", \"zen-m-0 zen-flex zen-list-none zen-flex-col zen-gap-0.5 zen-p-0\");\n for (const item of items) {\n const event = events[item.index];\n const li = el(\"li\", \"zen-flex zen-min-w-0 zen-items-center zen-gap-3 zen-rounded-zen-sm hover:zen-bg-zen-muted\");\n const time = el(\n \"span\",\n \"zen-w-32 zen-shrink-0 zen-ps-1.5 zen-text-xs zen-tabular-nums zen-text-zen-muted-fg\",\n item.allDay ? cal.loc.t(\"eventCalendar.allDay\") : cal.timeLabel(event),\n );\n time.setAttribute(\"aria-hidden\", \"true\");\n li.append(\n time,\n eventItem(cal, event, {\n variant: \"row\",\n continuesBefore: item.continuesBefore,\n continuesAfter: item.continuesAfter,\n class: \"zen-min-h-8 zen-flex-1\",\n }),\n );\n list.append(li);\n }\n return list;\n}\n\nexport function agenda(cal: CalendarContext): CalendarViewHandle {\n const events = cal.props.events ?? [];\n const groups = agendaGroups(events, eventCalendarRange(\"agenda\", cal.anchor, cal.options));\n const heading = (d: Date) => new Intl.DateTimeFormat(cal.loc.locale, { weekday: \"long\", day: \"numeric\", month: \"long\" }).format(d);\n const box = el(\"div\", \"zen-rounded-zen-md zen-border zen-border-zen-border\");\n\n if (groups.length === 0) {\n const empty = el(\"p\", \"zen-m-0 zen-py-10 zen-text-center zen-text-sm zen-text-zen-muted-fg\");\n empty.append(...toNodes(cal.props.emptyMessage ?? cal.loc.t(\"eventCalendar.noEvents\")));\n box.append(empty);\n }\n for (const group of groups) {\n const section = el(\n \"section\",\n cn(\"zen-flex zen-flex-col zen-gap-1 zen-border-b zen-border-zen-border zen-px-3 zen-py-2 last:zen-border-b-0\", cal.props.dayClassName?.(group.date)),\n );\n section.setAttribute(\"aria-label\", heading(group.date));\n const label = el(\n \"p\",\n cn(\"zen-m-0 zen-text-sm zen-font-semibold\", sameDay(group.date, cal.now) ? \"zen-text-zen-primary\" : \"zen-text-zen-foreground\"),\n heading(group.date),\n );\n label.setAttribute(\"aria-hidden\", \"true\");\n section.append(label, dayList(cal, events, group.items));\n box.append(section);\n }\n\n return { el: box, applyPreview: (preview) => markMoving(cal.root, preview?.eventId) };\n}\n"],"names":["dayList","cal","events","items","list","el","item","event","li","time","eventItem","agenda","groups","agendaGroups","eventCalendarRange","heading","d","box","empty","toNodes","group","section","cn","label","sameDay","preview","markMoving"],"mappings":";;;;;AAOO,SAASA,EAAQC,GAAsBC,GAAyBC,GAAkC;AACvG,QAAMC,IAAOC,EAAG,MAAM,iEAAiE;AACvF,aAAWC,KAAQH,GAAO;AACxB,UAAMI,IAAQL,EAAOI,EAAK,KAAK,GACzBE,IAAKH,EAAG,MAAM,2FAA2F,GACzGI,IAAOJ;AAAA,MACX;AAAA,MACA;AAAA,MACAC,EAAK,SAASL,EAAI,IAAI,EAAE,sBAAsB,IAAIA,EAAI,UAAUM,CAAK;AAAA,IAAA;AAEvE,IAAAE,EAAK,aAAa,eAAe,MAAM,GACvCD,EAAG;AAAA,MACDC;AAAA,MACAC,EAAUT,GAAKM,GAAO;AAAA,QACpB,SAAS;AAAA,QACT,iBAAiBD,EAAK;AAAA,QACtB,gBAAgBA,EAAK;AAAA,QACrB,OAAO;AAAA,MAAA,CACR;AAAA,IAAA,GAEHF,EAAK,OAAOI,CAAE;AAAA,EAChB;AACA,SAAOJ;AACT;AAEO,SAASO,EAAOV,GAA0C;AAC/D,QAAMC,IAASD,EAAI,MAAM,UAAU,CAAA,GAC7BW,IAASC,EAAaX,GAAQY,EAAmB,UAAUb,EAAI,QAAQA,EAAI,OAAO,CAAC,GACnFc,IAAU,CAACC,MAAY,IAAI,KAAK,eAAef,EAAI,IAAI,QAAQ,EAAE,SAAS,QAAQ,KAAK,WAAW,OAAO,QAAQ,EAAE,OAAOe,CAAC,GAC3HC,IAAMZ,EAAG,OAAO,qDAAqD;AAE3E,MAAIO,EAAO,WAAW,GAAG;AACvB,UAAMM,IAAQb,EAAG,KAAK,qEAAqE;AAC3F,IAAAa,EAAM,OAAO,GAAGC,EAAQlB,EAAI,MAAM,gBAAgBA,EAAI,IAAI,EAAE,wBAAwB,CAAC,CAAC,GACtFgB,EAAI,OAAOC,CAAK;AAAA,EAClB;AACA,aAAWE,KAASR,GAAQ;AAC1B,UAAMS,IAAUhB;AAAA,MACd;AAAA,MACAiB,EAAG,4GAA4GrB,EAAI,MAAM,eAAemB,EAAM,IAAI,CAAC;AAAA,IAAA;AAErJ,IAAAC,EAAQ,aAAa,cAAcN,EAAQK,EAAM,IAAI,CAAC;AACtD,UAAMG,IAAQlB;AAAA,MACZ;AAAA,MACAiB,EAAG,yCAAyCE,EAAQJ,EAAM,MAAMnB,EAAI,GAAG,IAAI,yBAAyB,yBAAyB;AAAA,MAC7Hc,EAAQK,EAAM,IAAI;AAAA,IAAA;AAEpB,IAAAG,EAAM,aAAa,eAAe,MAAM,GACxCF,EAAQ,OAAOE,GAAOvB,EAAQC,GAAKC,GAAQkB,EAAM,KAAK,CAAC,GACvDH,EAAI,OAAOI,CAAO;AAAA,EACpB;AAEA,SAAO,EAAE,IAAIJ,GAAK,cAAc,CAACQ,MAAYC,EAAWzB,EAAI,MAAMwB,GAAS,OAAO,EAAA;AACpF;"}
package/dist/index235.js CHANGED
@@ -1,154 +1,43 @@
1
- import { monthGrid as N, weekdayLabels as U, eventCalendarRange as W, calendarDayDiff as _, segmentSpanning as X, isSpanning as q, agendaGroups as J, sameTimeDaysLater as f, eventDayRange as Q } from "./index117.js";
2
- import { calendarDayKey as y, startCalendarGesture as V } from "./index246.js";
3
- import { Popover as Z } from "./index58.js";
4
- import { dayList as ee } from "./index233.js";
5
- import { eventItem as te } from "./index245.js";
6
- import { el as d, markMoving as ne, relight as oe, isRtl as re } from "./index234.js";
7
- import { cn as M } from "./index194.js";
8
- const T = 28;
9
- function ze(n) {
10
- const { loc: g, props: b, scope: D, memory: l } = n, w = b.events ?? [], k = Math.max(1, b.maxEventsPerDay ?? 3), S = N(n.anchor, { ...n.options, now: n.now }), Y = U(n.options.weekStartsOn ?? 1, g.locale, "short"), I = T + k * (n.rowPx + 2) + 4, h = (t) => new Intl.DateTimeFormat(g.locale, { weekday: "long", day: "numeric", month: "long", year: "numeric" }).format(t), R = W("month", n.anchor, n.options), B = (t) => t >= R.start && t < R.end;
11
- let p = l.focusedDay;
12
- if (!p || p.getMonth() !== n.anchor.getMonth() || p.getFullYear() !== n.anchor.getFullYear()) {
13
- const t = p ?? n.anchor, o = new Date(n.anchor.getFullYear(), n.anchor.getMonth() + 1, 0).getDate();
14
- p = new Date(n.anchor.getFullYear(), n.anchor.getMonth(), Math.min(t.getDate(), o));
1
+ import { cn as r } from "./index194.js";
2
+ const f = {
3
+ default: "zen-bg-zen-primary-soft zen-text-zen-primary-soft-fg zen-border-zen-primary",
4
+ info: "zen-bg-zen-info-soft zen-text-zen-info-soft-fg zen-border-zen-info",
5
+ success: "zen-bg-zen-success-soft zen-text-zen-success-soft-fg zen-border-zen-success",
6
+ warning: "zen-bg-zen-warning-soft zen-text-zen-warning-soft-fg zen-border-zen-warning",
7
+ error: "zen-bg-zen-error-soft zen-text-zen-error-soft-fg zen-border-zen-error"
8
+ }, g = {
9
+ default: "zen-bg-zen-primary",
10
+ info: "zen-bg-zen-info",
11
+ success: "zen-bg-zen-success",
12
+ warning: "zen-bg-zen-warning",
13
+ error: "zen-bg-zen-error"
14
+ }, s = "zen-opacity-40", z = "zen-bg-zen-primary-soft", i = (n) => !!n && getComputedStyle(n).direction === "rtl", a = (n, e) => n.getFullYear() === e.getFullYear() && n.getMonth() === e.getMonth() && n.getDate() === e.getDate(), l = (n, e, t) => {
15
+ const o = document.createElement(n);
16
+ return e && (o.className = e), t !== void 0 && (o.textContent = t), o;
17
+ };
18
+ function u(n, e, t) {
19
+ !e || t === "chip" || t === "row" || (n.style.backgroundColor = `color-mix(in srgb, ${e} 18%, var(--zen-color-background))`, n.style.borderColor = e, n.style.color = "var(--zen-color-foreground)");
20
+ }
21
+ function b(n, e) {
22
+ for (const t of n) {
23
+ const o = e !== null && t.day >= e.start && t.day < e.end;
24
+ t.node.className = r(t.base, o && z);
15
25
  }
16
- l.focusedDay = p;
17
- const A = n.canGoToDay ? "day" : n.selectable ? "select" : null, O = (t) => {
18
- A === "day" ? n.goToDay(t) : A === "select" && n.selectSlot({ start: t, end: f(t, 1), allDay: !0 });
19
- }, $ = d("div", "zen-overflow-x-auto zen-rounded-zen-md zen-border zen-border-zen-border"), C = d("div", "zen-min-w-[560px]");
20
- $.append(C);
21
- const E = d("div", M("zen-grid zen-grid-cols-7 zen-border-b zen-border-zen-border zen-bg-zen-muted", b.headerClassName));
22
- for (const t of Y) E.append(d("div", "zen-px-2 zen-py-1.5 zen-text-center zen-text-xs zen-font-medium zen-text-zen-muted-fg", t));
23
- C.append(E);
24
- const P = /* @__PURE__ */ new Map(), G = (t) => {
25
- l.focusedDay = t;
26
- for (const [u, i] of P) i.tabIndex = u === y(t) ? 0 : -1;
27
- const o = P.get(y(t));
28
- o ? o.focus() : (l.focusDayAfterRender = !0, n.setDate(t));
29
- }, j = (t, o, u) => {
30
- const i = re(u), v = n.options.weekStartsOn ?? 1;
31
- let a = null;
32
- if (t.key === "ArrowRight") a = f(o, i ? -1 : 1);
33
- else if (t.key === "ArrowLeft") a = f(o, i ? 1 : -1);
34
- else if (t.key === "ArrowDown") a = f(o, 7);
35
- else if (t.key === "ArrowUp") a = f(o, -7);
36
- else if (t.key === "Home") a = f(o, -((o.getDay() - v + 7) % 7));
37
- else if (t.key === "End") a = f(o, 6 - (o.getDay() - v + 7) % 7);
38
- else if (t.key === "PageUp" || t.key === "PageDown") {
39
- const e = new Date(o.getFullYear(), o.getMonth() + (t.key === "PageDown" ? 1 : -1), 1), c = new Date(e.getFullYear(), e.getMonth() + 1, 0).getDate();
40
- a = new Date(e.getFullYear(), e.getMonth(), Math.min(o.getDate(), c));
41
- }
42
- if (a) {
43
- if (t.preventDefault(), a.getMonth() !== n.anchor.getMonth() || !B(a)) {
44
- l.focusedDay = a, l.focusDayAfterRender = !0, n.setDate(a);
45
- return;
46
- }
47
- G(a);
48
- }
49
- }, H = (t, o) => {
50
- if (!n.selectable) return;
51
- const u = t.target;
52
- u.closest("[data-cal-event]") || u.closest("button") || V({
53
- event: t,
54
- target: o,
55
- root: n.root,
56
- kind: "select",
57
- surface: "day",
58
- snap: n.snap,
59
- newEventMinutes: b.newEventMinutes ?? 60,
60
- onPreview: (i) => n.setPreview(i ? { kind: "select", surface: "day", span: i } : null),
61
- onCommit: (i) => n.selectSlot(i),
62
- onClick: (i) => i && n.selectSlot(i)
63
- });
64
- }, F = [];
65
- let L = null;
66
- return S.forEach((t, o) => {
67
- const u = d("div", "zen-relative zen-border-b zen-border-zen-border last:zen-border-b-0");
68
- u.style.height = `${I + (o < S.length - 1 ? 1 : 0)}px`;
69
- const i = d("div", "zen-absolute zen-inset-0 zen-grid zen-grid-cols-7");
70
- for (const e of t) {
71
- const c = M(
72
- "zen-flex zen-items-start zen-justify-end zen-border-s zen-border-zen-border zen-p-1 first:zen-border-s-0",
73
- e.nonWorking && "zen-bg-zen-muted",
74
- n.selectable && "zen-cursor-cell",
75
- b.dayClassName?.(e.date)
76
- ), s = d("div", c);
77
- s.setAttribute("data-cal-cell", y(e.date)), s.setAttribute("data-cal-month-cell", ""), D.on(s, "pointerdown", (r) => H(r, s));
78
- const z = M(
79
- "zen-flex zen-h-6 zen-min-w-6 zen-items-center zen-justify-center zen-rounded-zen-full zen-px-1 zen-text-xs zen-font-medium",
80
- e.today ? "zen-bg-zen-primary zen-text-zen-primary-fg" : e.inMonth ? "zen-text-zen-foreground" : "zen-text-zen-muted-fg"
81
- );
82
- if (A) {
83
- const r = d(
84
- "button",
85
- M(z, "focus-visible:zen-outline-none focus-visible:zen-ring-2 focus-visible:zen-ring-zen-ring", !e.today && "hover:zen-bg-zen-muted"),
86
- String(e.date.getDate())
87
- );
88
- r.type = "button", r.setAttribute("data-cal-daynum", ""), r.setAttribute("data-cal-focus", `day:${y(e.date)}`), r.tabIndex = _(e.date, p) === 0 ? 0 : -1, r.setAttribute(
89
- "aria-label",
90
- A === "day" ? g.t("eventCalendar.goToDay", { date: h(e.date) }) : g.t("eventCalendar.newEvent", { time: h(e.date) })
91
- ), e.today && r.setAttribute("aria-current", "date"), D.on(r, "click", () => {
92
- l.focusedDay = e.date, O(e.date);
93
- }), D.on(r, "keydown", (m) => j(m, e.date, r)), P.set(y(e.date), r), s.append(r);
94
- } else
95
- s.append(d("span", z, String(e.date.getDate())));
96
- F.push({ node: s, base: c, day: e.date }), i.append(s);
97
- }
98
- u.append(i);
99
- const v = X(w, t.map((e) => e.date), { maxSlots: k }), a = d("div", "zen-pointer-events-none zen-absolute zen-inset-0 zen-grid zen-grid-cols-7 zen-gap-y-0.5 zen-px-px");
100
- a.style.gridTemplateRows = `${T}px repeat(${k}, ${n.rowPx}px)`;
101
- for (const e of v.segments) {
102
- if (!e.visible) continue;
103
- const c = w[e.index], s = q(c) || e.endCol - e.startCol > 1 || e.continuesBefore || e.continuesAfter, z = te(n, c, {
104
- variant: s ? "bar" : "chip",
105
- surface: "day",
106
- weekRows: !0,
107
- resizable: !!c.allDay && !e.continuesAfter,
108
- continuesBefore: e.continuesBefore,
109
- continuesAfter: e.continuesAfter,
110
- class: "zen-pointer-events-auto zen-mx-0.5"
111
- });
112
- z.style.gridColumn = `${e.startCol + 1} / ${e.endCol + 1}`, z.style.gridRow = `${e.slot + 2}`, a.append(z);
113
- }
114
- v.hidden.forEach((e, c) => {
115
- if (e <= 0) return;
116
- const s = t[c].date, z = y(s), r = d(
117
- "button",
118
- "zen-w-full zen-truncate zen-rounded-zen-sm zen-px-1.5 zen-text-start zen-text-xs zen-font-medium zen-text-zen-muted-fg hover:zen-bg-zen-muted hover:zen-text-zen-foreground focus-visible:zen-outline-none focus-visible:zen-ring-2 focus-visible:zen-ring-zen-ring",
119
- g.t("eventCalendar.more", { count: e })
120
- );
121
- r.type = "button", r.setAttribute("data-cal-more", ""), r.setAttribute("data-cal-focus", `more:${z}`), r.setAttribute("aria-label", g.t("eventCalendar.moreLabel", { count: e, date: h(s) }));
122
- const m = d("div");
123
- m.setAttribute("data-cal-owner", n.hintId), m.setAttribute("aria-label", g.t("eventCalendar.eventsOn", { date: h(s) })), m.append(
124
- d("p", "zen-m-0 zen-mb-1 zen-px-1.5 zen-text-sm zen-font-semibold zen-text-zen-foreground", h(s)),
125
- ee(n, w, J(w, { start: s, end: f(s, 1) })[0]?.items ?? [])
126
- );
127
- const x = D.keep(
128
- Z({
129
- trigger: r,
130
- children: m,
131
- class: "zen-w-80 zen-p-2",
132
- onOpenChange: (K) => {
133
- K ? l.openMore = z : l.openMore === z && (l.openMore = void 0);
134
- }
135
- })
136
- );
137
- l.openMore === z && (L = x), x.el.classList.add("zen-pointer-events-auto", "zen-mx-0.5", "zen-min-w-0"), x.el.style.gridColumn = `${c + 1}`, x.el.style.gridRow = `${k + 1}`, a.append(x.el);
138
- }), u.append(a), C.append(u);
139
- }), {
140
- el: $,
141
- /* Reopened once the page is in the document, where the panel can measure
142
- its trigger: opening it while detached places it at the corner. */
143
- mounted() {
144
- L?.open();
145
- },
146
- applyPreview(t) {
147
- ne(n.root, t?.eventId), oe(F, t && t.surface === "day" ? Q(t.span) : null);
148
- }
149
- };
26
+ }
27
+ function d(n, e) {
28
+ for (const t of n.querySelectorAll("[data-cal-event]"))
29
+ t.classList.toggle(s, e !== void 0 && t.getAttribute("data-cal-event") === e);
150
30
  }
151
31
  export {
152
- ze as month
32
+ g as DOT_CLASS,
33
+ z as LIT_CLASS,
34
+ s as MOVING_CLASS,
35
+ f as STATE_CLASS,
36
+ u as applyCustomColor,
37
+ l as el,
38
+ i as isRtl,
39
+ d as markMoving,
40
+ b as relight,
41
+ a as sameDay
153
42
  };
154
43
  //# sourceMappingURL=index235.js.map