@algorisys/zen-ui-vanilla 13.11.0 → 13.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) 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.d.ts.map +1 -1
  4. package/dist/components/planning-calendar/planning-calendar.d.ts +5 -1
  5. package/dist/components/planning-calendar/planning-calendar.d.ts.map +1 -1
  6. package/dist/index112.js +174 -165
  7. package/dist/index112.js.map +1 -1
  8. package/dist/index113.js +149 -143
  9. package/dist/index113.js.map +1 -1
  10. package/dist/index114.js +1 -1
  11. package/dist/index115.js +1 -1
  12. package/dist/index116.js +1 -1
  13. package/dist/index118.js +2 -2
  14. package/dist/index120.js +2 -2
  15. package/dist/index168.js +1 -1
  16. package/dist/index175.js +1 -1
  17. package/dist/index187.js +1 -1
  18. package/dist/index191.js +1 -1
  19. package/dist/index194.js +2 -2
  20. package/dist/index199.js +1 -1
  21. package/dist/index231.js +1 -1
  22. package/dist/index232.js +7 -7
  23. package/dist/index232.js.map +1 -1
  24. package/dist/index233.js +7 -48
  25. package/dist/index233.js.map +1 -1
  26. package/dist/index234.js +45 -37
  27. package/dist/index234.js.map +1 -1
  28. package/dist/index235.js +38 -149
  29. package/dist/index235.js.map +1 -1
  30. package/dist/index236.js +138 -177
  31. package/dist/index236.js.map +1 -1
  32. package/dist/index237.js +190 -90
  33. package/dist/index237.js.map +1 -1
  34. package/dist/index238.js +90 -444
  35. package/dist/index238.js.map +1 -1
  36. package/dist/index239.js +436 -98
  37. package/dist/index239.js.map +1 -1
  38. package/dist/index240.js +106 -2
  39. package/dist/index240.js.map +1 -1
  40. package/dist/index241.js +2 -18804
  41. package/dist/index241.js.map +1 -1
  42. package/dist/index242.js +18798 -117
  43. package/dist/index242.js.map +1 -1
  44. package/dist/index243.js +122 -13
  45. package/dist/index243.js.map +1 -1
  46. package/dist/index244.js +13 -3012
  47. package/dist/index244.js.map +1 -1
  48. package/dist/index245.js +3006 -123
  49. package/dist/index245.js.map +1 -1
  50. package/dist/index246.js +125 -140
  51. package/dist/index246.js.map +1 -1
  52. package/dist/index247.js +138 -93
  53. package/dist/index247.js.map +1 -1
  54. package/dist/index248.js +91 -104
  55. package/dist/index248.js.map +1 -1
  56. package/dist/index249.js +95 -111
  57. package/dist/index249.js.map +1 -1
  58. package/dist/index250.js +127 -4
  59. package/dist/index250.js.map +1 -1
  60. package/dist/index251.js +5 -34
  61. package/dist/index251.js.map +1 -1
  62. package/dist/index252.js +34 -9
  63. package/dist/index252.js.map +1 -1
  64. package/dist/index253.js +10 -7
  65. package/dist/index253.js.map +1 -1
  66. package/dist/index254.js +6 -15
  67. package/dist/index254.js.map +1 -1
  68. package/dist/index255.js +15 -11
  69. package/dist/index255.js.map +1 -1
  70. package/dist/index256.js +11 -3
  71. package/dist/index256.js.map +1 -1
  72. package/dist/index257.js +7 -0
  73. package/dist/index257.js.map +1 -0
  74. package/dist/previews/analytic-chart.jpg +0 -0
  75. package/dist/previews/code-editor.jpg +0 -0
  76. package/dist/previews/countdown.jpg +0 -0
  77. package/dist/previews/loading.jpg +0 -0
  78. package/dist/previews/map.jpg +0 -0
  79. package/dist/previews/skeleton.jpg +0 -0
  80. package/package.json +1 -1
  81. package/skills/zen-ui/references/api/planning-calendar.md +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index112.js","sources":["../src/components/planning-calendar/planning-calendar.ts"],"sourcesContent":["import type { IconName } from \"@algorisys/zen-ui-core/icons\";\nimport {\n formatTimeRange,\n layoutLanes,\n nowPct,\n placeAppointment,\n planningAxis,\n planningColumns,\n planningKeyboardMove,\n planningRange,\n planningRangeLabel,\n shiftPlanningAnchor,\n startPlanningGesture,\n type PlanningPlacement,\n type PlanningProposedMove,\n type PlanningRange,\n type PlanningView,\n type Weekday,\n} from \"@algorisys/zen-ui-core\";\nimport { cn } from \"../../lib/cn\";\nimport { Button } from \"../button/button\";\nimport { Icon } from \"../icon/icon\";\nimport {\n applyProps,\n Disposer,\n toNodes,\n type AnyZenComponent,\n type BaseProps,\n type Child,\n type ZenComponent,\n} from \"../../lib/component\";\nimport { useLocale, type MessageKey } from \"../locale/locale\";\n\n/**\n * PlanningCalendar — who is busy, and when.\n *\n * PlanningCalendar({ rows: people, defaultView: \"week\" }).el\n *\n * A resource-by-time grid: one row per person, room or machine, one axis of\n * time, appointments as blocks on it. The question it answers is a comparison\n * ACROSS rows, which is why a month is one long axis of 31 columns rather than a\n * 6×7 page — wrapping it into weeks would give each resource six separate rows.\n *\n * Vanilla port; see the React binding for the reasoning. Same API, same output.\n * All the arithmetic is imported from @algorisys/zen-ui-core/planning and pinned\n * by scripts/check-planning.ts, so four renderers cannot drift on where 09:30\n * is.\n *\n * It PROPOSES moves and never applies them. Pass `onAppointmentChange` and an\n * appointment can be dragged along its row (long press on touch) or moved with\n * Alt+Left / Alt+Right; `allowRowChange` adds other rows (Alt+Up / Alt+Down).\n * You get `{ appointment, row, toRow, start, end, source }` and apply it with\n * `update({ rows })`, or don't. Without `onAppointmentChange` nothing moves.\n * Same API as Solid and React.\n */\n\nexport type PlanningAppointmentState = \"default\" | \"info\" | \"success\" | \"warning\" | \"error\";\n\nconst BLOCK_CLASS: Record<PlanningAppointmentState, string> = {\n default: \"zen-bg-zen-muted zen-text-zen-foreground zen-border-zen-border\",\n info: \"zen-bg-zen-info-soft zen-text-zen-info zen-border-zen-info\",\n success: \"zen-bg-zen-success-soft zen-text-zen-success zen-border-zen-success\",\n warning: \"zen-bg-zen-warning-soft zen-text-zen-warning zen-border-zen-warning\",\n error: \"zen-bg-zen-error-soft zen-text-zen-error zen-border-zen-error\",\n};\n\nexport interface PlanningAppointment {\n id: string;\n start: Date;\n end: Date;\n title: string;\n /** Second line, when the block is wide enough to show it. */\n subtitle?: string;\n state?: PlanningAppointmentState;\n icon?: IconName;\n /**\n * A save is in flight (an optimistic move, say). The block is dimmed,\n * announced as busy, and cannot be moved again until it clears.\n */\n busy?: boolean;\n}\n\n/** A move the calendar proposes. Nothing has changed until you apply it. */\nexport interface PlanningAppointmentChange {\n appointment: PlanningAppointment;\n /** The row it is in now. */\n row: PlanningRow;\n /** The row it would move to: `row` unless `allowRowChange` let it cross. */\n toRow: PlanningRow;\n start: Date;\n end: Date;\n /** How it was proposed. A keyboard move fires once per key press. */\n source: \"pointer\" | \"keyboard\";\n}\n\nexport interface PlanningAppointmentRenderContext {\n row: PlanningRow;\n /** Too narrow for text (under ~3% of the axis): render a mark, not a label. */\n compact: boolean;\n /** \"09:00 – 10:30\", the same text the block's accessible name carries. */\n timeLabel: string;\n}\n\nexport interface PlanningRow {\n id: string;\n /** The resource: a person, a room, a machine. */\n title: string;\n subtitle?: string;\n appointments: PlanningAppointment[];\n}\n\nexport interface PlanningCalendarProps extends BaseProps {\n rows: PlanningRow[];\n /** Starting view. The factory owns it after that; call update() to control it. */\n defaultView?: PlanningView;\n view?: PlanningView;\n onViewChange?: (view: PlanningView) => void;\n /** Which views the switcher offers. Default all three. */\n views?: PlanningView[];\n /** Any date inside the range to open on. Default today. */\n defaultDate?: Date;\n date?: Date;\n onDateChange?: (date: Date) => void;\n onAppointmentClick?: (appointment: PlanningAppointment, row: PlanningRow) => void;\n /** Reference \"now\" for the marker and today highlight. Injectable for tests. */\n now?: Date;\n hideToolbar?: boolean;\n emptyMessage?: Child;\n /** Your own controls, at the end of the toolbar: a group-by switch, a count. */\n toolbarActions?: Child;\n /**\n * Propose a move. With it, appointments can be dragged (touch: long press)\n * and moved with Alt+arrow keys; without it, nothing moves. You apply it:\n * `update({ rows })`, or don't.\n */\n onAppointmentChange?: (change: PlanningAppointmentChange) => void;\n /** Per-appointment gate. A blocked one is not draggable at all, rather than refused on drop. Default: all. */\n canEditAppointment?: (appointment: PlanningAppointment, row: PlanningRow) => boolean;\n /** Let a move land in another row (re-assign, re-status). Default false: moves stay in their row. */\n allowRowChange?: boolean;\n /** Minutes a move snaps to in the day view. Default 15. Week and month move by whole days. */\n snapMinutes?: number;\n /** Replace a block's content. The calendar keeps the box, its placement, colour and controls. */\n renderAppointment?: (appointment: PlanningAppointment, context: PlanningAppointmentRenderContext) => Child;\n /** Extra classes on a block, e.g. a status colour of your own. */\n appointmentClass?: (appointment: PlanningAppointment, row: PlanningRow) => string | undefined;\n /** First column of a week view (0 = Sunday). Default 1, Monday. */\n weekStartsOn?: Weekday;\n /** First hour the day view draws. Default 0. */\n dayStartHour?: number;\n /** Hour the day view stops at (exclusive). Default 24. */\n dayEndHour?: number;\n /** Hours per column in the day view. Default 1. */\n hourStep?: number;\n /** [from, to) hours drawn unshaded in the day view. Default [9, 18]. */\n workingHours?: [number, number];\n /** Days shaded as non-working (0 = Sunday). Default [0, 6]. */\n nonWorkingDays?: number[];\n /** Height of one lane in px (appointments stack in lanes inside a row). Default 30. */\n laneHeight?: number;\n /**\n * How much room a lane takes: \"compact\", \"comfortable\" (the default, and the\n * size it always was) or \"touch\" (48px targets, for shop-floor tablets).\n * Opt-in: it does not follow data-density, so setting that on a page moves\n * nothing here. An explicit size prop wins over it.\n */\n density?: Density;\n}\n\nconst VIEW_LABEL: Record<PlanningView, MessageKey> = {\n day: \"planningCalendar.views.day\",\n week: \"planningCalendar.views.week\",\n month: \"planningCalendar.views.month\",\n};\nconst ALL_VIEWS: PlanningView[] = [\"day\", \"week\", \"month\"];\n\n/** Row height per lane. A block is 24px tall; lanes stack inside the row. */\nimport { calendarLanePx, type Density } from \"@algorisys/zen-ui-core/density\";\n\n/**\n * Below this width, a block renders no text at all.\n *\n * A 90-minute meeting is 0.9% of a week. At that size a label is not \"clipped\",\n * it is an empty bordered pill — which reads as a component that failed to\n * render rather than as a busy hour. Under the threshold the block is what it\n * actually is at that zoom: an occupancy mark, with its name and time still in\n * the accessible name and the tooltip.\n */\nconst TEXT_MIN_WIDTH_PCT = 3;\n\nconst 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\nlet uid = 0;\n\nexport function PlanningCalendar(\n props: PlanningCalendarProps,\n): ZenComponent<PlanningCalendarProps> {\n let current: PlanningCalendarProps = { ...props };\n // Never so short that a block (lane − 6px) has no height.\n const lanePx = (): number => Math.max(14, calendarLanePx(current.density, current.laneHeight));\n const loc = useLocale();\n const disposer = new Disposer();\n let removeProps: (() => void) | undefined;\n\n /* The factory owns the uncontrolled view and date, because there is no state\n hook here — `update({ view })` is how a caller takes control, and passing\n `view` explicitly wins over what the toolbar last set. */\n let innerView: PlanningView = props.defaultView ?? \"week\";\n let innerDate: Date = props.defaultDate ?? new Date();\n\n const hintId = `zen-planning-calendar-${++uid}`;\n const root = el(\"div\");\n /* What render() rebuilds lives in `body`, laid out as if its children were\n the root's own (display: contents). The hint and the live region sit\n outside it and survive every rebuild, so an announcement is not dropped\n with the DOM it described. */\n const body = el(\"div\", \"zen-contents\");\n const hint = el(\"span\", \"zen-sr-only\");\n hint.id = hintId;\n const live = el(\"div\", \"zen-sr-only\");\n live.setAttribute(\"aria-live\", \"polite\");\n live.setAttribute(\"aria-atomic\", \"true\");\n root.append(body, hint, live);\n\n /* Handles built by the CURRENT render, destroyed before the next one: a\n Button holds a real listener on a node this component created, and there is\n no unmount here to take it away. Without this every re-render — and the\n toolbar re-renders on every click — leaks a listener per control. */\n let owned: AnyZenComponent[] = [];\n const keep = <T extends AnyZenComponent>(comp: T): T => {\n owned.push(comp);\n return comp;\n };\n\n /* Listeners on plain nodes this file builds (blocks), released before the\n next render: the Disposer only runs at destroy(), so pushing there would\n grow by one entry per block on EVERY render. */\n let blockCleanups: Array<() => void> = [];\n const on = <K extends keyof HTMLElementEventMap>(\n node: HTMLElement,\n type: K,\n listener: (e: HTMLElementEventMap[K]) => void,\n ) => {\n node.addEventListener(type, listener);\n blockCleanups.push(() => node.removeEventListener(type, listener));\n };\n\n /* State of the last render the gesture and keyboard need: the axis, and each\n row's lane element (where a ghost is drawn). Not re-rendered during a drag —\n a rebuild per pointermove would cost a full DOM per frame. */\n let axis: PlanningRange = { start: new Date(), end: new Date() };\n let laneById = new Map<string, HTMLElement>();\n let ghost: HTMLElement | null = null;\n let dimmed: HTMLElement | null = null;\n\n const viewOf = () => current.view ?? innerView;\n const dateOf = () => current.date ?? innerDate;\n const weekStart = (): Weekday => current.weekStartsOn ?? 1;\n const snap = () => Math.max(1, current.snapMinutes ?? 15);\n\n const setView = (next: PlanningView) => {\n if (current.view === undefined) innerView = next;\n current.onViewChange?.(next);\n render();\n };\n const setDate = (next: Date) => {\n if (current.date === undefined) innerDate = next;\n current.onDateChange?.(next);\n render();\n };\n\n const editable = (appointment: PlanningAppointment, row: PlanningRow) =>\n !!current.onAppointmentChange && !appointment.busy && (current.canEditAppointment?.(appointment, row) ?? true);\n\n const blockFor = (id: string) => body.querySelector<HTMLElement>(`[data-plan-appointment=\"${CSS.escape(id)}\"]`);\n\n /* A rebuild replaces every block, so focus would fall to <body> on ANY update\n — including a caller applying someone else's save. Remember which block\n had it and put it back on the same appointment. */\n const focusedId = (): string | null => {\n const active = root.ownerDocument.activeElement as HTMLElement | null;\n return active && body.contains(active) ? active.getAttribute(\"data-plan-appointment\") : null;\n };\n /** Set by a keyboard move: refocus this id after the caller's update, which may come a little later. */\n let pendingFocus: { id: string; until: number } | null = null;\n\n const clearGhost = () => {\n ghost?.remove();\n ghost = null;\n dimmed?.classList.remove(\"zen-opacity-40\");\n dimmed = null;\n };\n\n const showGhost = (button: HTMLElement, move: PlanningProposedMove | null) => {\n ghost?.remove();\n ghost = null;\n if (!move) {\n clearGhost();\n return;\n }\n if (dimmed !== button) {\n dimmed?.classList.remove(\"zen-opacity-40\");\n dimmed = button;\n button.classList.add(\"zen-opacity-40\");\n }\n const lane = laneById.get(move.rowId);\n const placement = placeAppointment(move, axis);\n if (!lane || !placement) return;\n /* pointer-events: none, or it becomes the element under the pointer and the\n gesture's hit-test finds no lane. */\n const g = el(\n \"div\",\n \"zen-pointer-events-none zen-absolute zen-z-10 zen-flex zen-items-center zen-overflow-hidden zen-rounded-zen-sm zen-border-2 zen-border-dashed zen-border-zen-primary zen-bg-zen-primary-soft zen-px-1.5 zen-text-xs zen-font-medium zen-text-zen-foreground\",\n );\n g.setAttribute(\"aria-hidden\", \"true\");\n g.setAttribute(\"data-plan-ghost\", \"\");\n g.style.setProperty(\"inset-inline-start\", `${placement.startPct}%`);\n g.style.width = `${placement.widthPct}%`;\n g.style.top = \"4px\";\n g.style.height = `${lanePx() - 6}px`;\n g.append(el(\"span\", \"zen-truncate\", formatTimeRange(move.start, move.end)));\n lane.append(g);\n ghost = g;\n };\n\n const propose = (\n appointment: PlanningAppointment,\n row: PlanningRow,\n move: PlanningProposedMove,\n source: \"pointer\" | \"keyboard\",\n ) => {\n const toRow = (current.rows ?? []).find((r) => r.id === move.rowId) ?? row;\n if (source === \"keyboard\") pendingFocus = { id: appointment.id, until: Date.now() + 2000 };\n current.onAppointmentChange?.({ appointment, row, toRow, start: move.start, end: move.end, source });\n const time = formatTimeRange(move.start, move.end);\n live.textContent = \"\";\n live.textContent =\n toRow.id === row.id\n ? loc.t(\"planningCalendar.proposed\", { title: appointment.title, time })\n : loc.t(\"planningCalendar.proposedRow\", { title: appointment.title, row: toRow.title, time });\n if (source === \"keyboard\" && (move.start < axis.start || move.start >= axis.end)) {\n /* A keyboard move past the edge of the view follows the appointment, as a\n drag would have had to: otherwise it vanishes, and focus with it. */\n setDate(move.start);\n }\n };\n\n function toolbar(view: PlanningView, anchor: Date, now: Date): HTMLElement {\n const bar = el(\"div\", \"zen-flex zen-flex-wrap zen-items-center zen-gap-2\");\n\n const prev = keep(\n Button({\n variant: \"outline\",\n size: \"sm\",\n \"aria-label\": loc.t(\"planningCalendar.previous\"),\n // Logical, not physical: under RTL the axis runs the other way, so a\n // left-pointing chevron would send you forward.\n children: keep(Icon({ name: \"chevron-left\", size: 14, class: \"rtl:zen-rotate-180\" })),\n onClick: () => setDate(shiftPlanningAnchor(view, anchor, -1, weekStart())),\n }),\n );\n const today = keep(\n Button({ variant: \"outline\", size: \"sm\", children: loc.t(\"planningCalendar.today\"), onClick: () => setDate(now) }),\n );\n const next = keep(\n Button({\n variant: \"outline\",\n size: \"sm\",\n \"aria-label\": loc.t(\"planningCalendar.next\"),\n children: keep(Icon({ name: \"chevron-right\", size: 14, class: \"rtl:zen-rotate-180\" })),\n onClick: () => setDate(shiftPlanningAnchor(view, anchor, 1, weekStart())),\n }),\n );\n\n const label = el(\n \"span\",\n \"zen-mx-1 zen-text-sm zen-font-medium zen-text-zen-foreground\",\n planningRangeLabel(view, anchor, weekStart()),\n );\n\n const switcher = el(\"div\", \"zen-ms-auto zen-flex zen-gap-1\");\n switcher.setAttribute(\"role\", \"group\");\n switcher.setAttribute(\"aria-label\", loc.t(\"planningCalendar.view\"));\n for (const v of current.views ?? ALL_VIEWS) {\n switcher.append(\n keep(\n Button({\n variant: view === v ? \"solid\" : \"outline\",\n size: \"sm\",\n \"aria-pressed\": String(view === v),\n children: loc.t(VIEW_LABEL[v]),\n onClick: () => setView(v),\n }),\n ).el,\n );\n }\n\n bar.append(prev.el, today.el, next.el, label, switcher);\n if (current.toolbarActions != null) {\n const actions = el(\"div\", \"zen-flex zen-flex-wrap zen-items-center zen-gap-2\");\n actions.append(...toNodes(current.toolbarActions));\n bar.append(actions);\n }\n return bar;\n }\n\n function render(): void {\n const hadFocus = focusedId();\n clearGhost();\n for (const comp of owned) comp.destroy();\n owned = [];\n for (const off of blockCleanups) off();\n blockCleanups = [];\n body.replaceChildren();\n laneById = new Map();\n\n const {\n rows,\n emptyMessage,\n class: className,\n children: _children,\n defaultView: _dv,\n defaultDate: _dd,\n view: _v,\n date: _d,\n views: _vs,\n now: _n,\n hideToolbar: _ht,\n onViewChange: _ovc,\n onDateChange: _odc,\n onAppointmentClick: _oac,\n toolbarActions: _ta,\n onAppointmentChange: _oach,\n canEditAppointment: _cea,\n allowRowChange: _arc,\n snapMinutes: _sm,\n renderAppointment: _ra,\n appointmentClass: _ac,\n weekStartsOn: _ws,\n dayStartHour: _dsh,\n dayEndHour: _deh,\n hourStep: _hs,\n workingHours: _wh,\n nonWorkingDays: _nwd,\n laneHeight: _lh,\n density: _den,\n ...rest\n } = current;\n\n // w-full, because the grid is a chart: shrink-wrapped to its content it\n // reports a 490px week whose columns are too narrow to read.\n root.className = cn(\"zen-flex zen-w-full zen-flex-col zen-gap-3\", className);\n hint.textContent = loc.t(current.allowRowChange ? \"planningCalendar.editHintRows\" : \"planningCalendar.editHint\");\n\n const view = viewOf();\n const anchor = dateOf();\n const now = current.now ?? new Date();\n const columns = planningColumns(view, anchor, {\n now,\n weekStartsOn: weekStart(),\n dayStartHour: current.dayStartHour,\n dayEndHour: current.dayEndHour,\n hourStep: current.hourStep,\n workingHours: current.workingHours,\n nonWorkingDays: current.nonWorkingDays,\n });\n /* What the lanes DRAW, which is not the view's range once the day view is\n trimmed to working hours: placing against the whole day would put 09:00 a\n third of the way across a grid whose left edge says 08:00. */\n axis = planningAxis(columns, planningRange(view, anchor, weekStart()));\n const marker = nowPct(axis, now);\n\n const laidOut = (rows ?? []).map((row) => {\n const visible = row.appointments\n .map((appointment) => ({ appointment, placement: placeAppointment(appointment, axis) }))\n .filter((entry): entry is { appointment: PlanningAppointment; placement: PlanningPlacement } =>\n entry.placement !== null,\n );\n const { lanes, laneCount } = layoutLanes(visible.map((v) => v.appointment));\n return {\n row,\n blocks: visible.map((v, i) => ({ ...v, lane: lanes[i] })),\n laneCount: Math.max(laneCount, 1),\n };\n });\n\n /* The toolbar is gated on there being rows, not only on `hideToolbar`. With\n no resources, Previous / Today / Next and the view switcher cannot change\n anything the user can see. */\n if (!current.hideToolbar && laidOut.length > 0) {\n body.append(toolbar(view, anchor, now));\n }\n\n if (laidOut.length === 0) {\n const p = el(\"p\", \"zen-m-0 zen-py-6 zen-text-center zen-text-sm zen-text-zen-muted-fg\");\n p.append(...toNodes(emptyMessage ?? loc.t(\"planningCalendar.noResources\")));\n body.append(p);\n } else {\n // One horizontal scroller holding the header and every row, so the axis\n // and the blocks under it cannot scroll out of alignment.\n const scroller = el(\n \"div\",\n \"zen-overflow-x-auto zen-rounded-zen-md zen-border zen-border-zen-border\",\n );\n const inner = el(\"div\", \"zen-min-w-[45rem]\");\n\n const head = el(\"div\", \"zen-flex zen-border-b zen-border-zen-border zen-bg-zen-muted\");\n head.append(\n el(\n \"div\",\n \"zen-w-40 zen-shrink-0 zen-border-e zen-border-zen-border zen-px-3 zen-py-2 zen-text-xs zen-font-semibold zen-text-zen-muted-fg\",\n loc.t(\"planningCalendar.resource\"),\n ),\n );\n const headCols = el(\"div\", \"zen-flex zen-flex-1\");\n for (const column of columns) {\n const cell = el(\n \"div\",\n cn(\n \"zen-flex-1 zen-border-e zen-border-zen-border zen-px-1 zen-py-2 zen-text-center last:zen-border-e-0\",\n column.nonWorking && \"zen-bg-zen-muted\",\n column.today && \"zen-bg-zen-primary-soft\",\n ),\n );\n cell.append(el(\"div\", \"zen-text-xs zen-font-medium zen-text-zen-foreground\", column.label));\n if (column.sublabel) {\n cell.append(el(\"div\", \"zen-[font-size:var(--zen-schedule-label-font-size)] zen-text-zen-muted-fg\", column.sublabel));\n }\n headCols.append(cell);\n }\n head.append(headCols);\n inner.append(head);\n\n for (const entry of laidOut) {\n const rowEl = el(\"div\", \"zen-flex zen-border-b zen-border-zen-border last:zen-border-b-0\");\n\n const label = el(\n \"div\",\n \"zen-w-40 zen-shrink-0 zen-border-e zen-border-zen-border zen-px-3 zen-py-2\",\n );\n label.append(\n el(\"div\", \"zen-truncate zen-text-sm zen-font-medium zen-text-zen-foreground\", entry.row.title),\n );\n if (entry.row.subtitle) {\n label.append(el(\"div\", \"zen-truncate zen-text-xs zen-text-zen-muted-fg\", entry.row.subtitle));\n }\n rowEl.append(label);\n\n /* The lane is the drop target: the gesture hit-tests `data-plan-lane`\n under the pointer, so a block dropped anywhere along its row (or\n another row) lands. */\n const track = el(\"div\", \"zen-relative zen-flex-1\");\n track.setAttribute(\"data-plan-lane\", entry.row.id);\n track.style.minHeight = `${entry.laneCount * lanePx() + 8}px`;\n laneById.set(entry.row.id, track);\n\n // The column rules as a background layer rather than as parents of the\n // blocks: a block spanning four hours cannot live inside one column.\n const rules = el(\"div\", \"zen-absolute zen-inset-0 zen-flex\");\n rules.setAttribute(\"aria-hidden\", \"true\");\n for (const column of columns) {\n rules.append(\n el(\n \"div\",\n cn(\n \"zen-flex-1 zen-border-e zen-border-zen-border last:zen-border-e-0\",\n column.nonWorking && \"zen-bg-zen-muted\",\n column.today && \"zen-bg-zen-primary-soft\",\n ),\n ),\n );\n }\n track.append(rules);\n\n if (marker !== null) {\n const line = el(\"div\", \"zen-absolute zen-top-0 zen-bottom-0 zen-w-px zen-bg-zen-error\");\n line.setAttribute(\"aria-hidden\", \"true\");\n line.style.setProperty(\"inset-inline-start\", `${marker}%`);\n track.append(line);\n }\n\n for (const block of entry.blocks) {\n const { appointment } = block;\n const row = entry.row;\n const canEdit = editable(appointment, row);\n const compact = block.placement.widthPct < TEXT_MIN_WIDTH_PCT;\n /* A real <button> whether or not a handler was passed: these are the\n only things in the grid worth reaching by keyboard, and a div with\n no tabindex takes the whole calendar out of the tab order. */\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.setAttribute(\"data-plan-appointment\", appointment.id);\n button.className = cn(\n \"zen-absolute zen-flex zen-items-center zen-gap-1 zen-overflow-hidden zen-rounded-zen-sm zen-border zen-px-1.5 zen-text-start zen-text-xs\",\n \"focus-visible:zen-outline-none focus-visible:zen-ring-2 focus-visible:zen-ring-zen-ring\",\n BLOCK_CLASS[appointment.state ?? \"default\"],\n // Square off the cut edge so a block continuing past the view does\n // not look like it ends there.\n block.placement.clippedStart && \"zen-rounded-s-none zen-border-s-0\",\n block.placement.clippedEnd && \"zen-rounded-e-none zen-border-e-0\",\n current.onAppointmentClick && \"hover:zen-brightness-95\",\n canEdit && \"zen-cursor-grab\",\n appointment.busy && \"zen-cursor-wait zen-opacity-60\",\n current.appointmentClass?.(appointment, row),\n );\n button.style.setProperty(\"inset-inline-start\", `${block.placement.startPct}%`);\n button.style.width = `${block.placement.widthPct}%`;\n button.style.top = `${block.lane * lanePx() + 4}px`;\n button.style.height = `${lanePx() - 6}px`;\n if (canEdit) {\n // A long press starts a touch drag, so it must not select text or\n // open the iOS callout.\n button.style.userSelect = \"none\";\n button.style.setProperty(\"-webkit-touch-callout\", \"none\");\n button.setAttribute(\"aria-describedby\", hintId);\n button.setAttribute(\n \"aria-keyshortcuts\",\n current.allowRowChange\n ? \"Alt+ArrowLeft Alt+ArrowRight Alt+ArrowUp Alt+ArrowDown\"\n : \"Alt+ArrowLeft Alt+ArrowRight\",\n );\n }\n if (appointment.busy) button.setAttribute(\"aria-busy\", \"true\");\n const time = formatTimeRange(appointment.start, appointment.end);\n button.title = `${appointment.title} · ${time}`;\n\n // The time is in the accessible name, not only the title attribute: a\n // block narrow enough to drop its own label is exactly when someone\n // needs it, and title is not reliably announced.\n button.append(el(\"span\", \"zen-sr-only\", time));\n if (appointment.busy) button.append(el(\"span\", \"zen-sr-only\", loc.t(\"planningCalendar.busy\")));\n\n if (current.renderAppointment) {\n button.append(...toNodes(current.renderAppointment(appointment, { row, compact, timeLabel: time })));\n } else if (!compact) {\n if (appointment.icon) {\n button.append(keep(Icon({ name: appointment.icon, size: 12, class: \"zen-shrink-0\" })).el);\n }\n button.append(el(\"span\", \"zen-truncate zen-font-medium\", appointment.title));\n if (appointment.subtitle) {\n button.append(el(\"span\", \"zen-truncate zen-opacity-70\", appointment.subtitle));\n }\n }\n\n const handler = current.onAppointmentClick;\n if (handler) on(button, \"click\", () => handler(appointment, row));\n\n if (canEdit) {\n on(button, \"pointerdown\", (e) => {\n startPlanningGesture({\n event: e,\n target: button,\n root,\n axis,\n view,\n snapMinutes: snap(),\n appointment,\n rowId: row.id,\n allowRowChange: !!current.allowRowChange,\n scroller,\n onPreview: (move) => showGhost(button, move),\n onCommit: (move) => propose(appointment, row, move, \"pointer\"),\n });\n });\n on(button, \"keydown\", (e) => {\n if (!e.altKey || e.ctrlKey || e.metaKey) return;\n let move: PlanningProposedMove | null = null;\n if (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") {\n if (!current.allowRowChange) return;\n const list = current.rows ?? [];\n const next = list[list.findIndex((r) => r.id === row.id) + (e.key === \"ArrowDown\" ? 1 : -1)];\n if (!next) return;\n move = { start: appointment.start, end: appointment.end, rowId: next.id };\n } else {\n const rtl = getComputedStyle(button).direction === \"rtl\";\n const at = planningKeyboardMove(appointment, e.key, { view, rtl, snapMinutes: snap() });\n if (!at) return;\n move = { ...at, rowId: row.id };\n }\n e.preventDefault();\n e.stopPropagation();\n propose(appointment, row, move, \"keyboard\");\n });\n }\n\n track.append(button);\n }\n\n rowEl.append(track);\n inner.append(rowEl);\n }\n\n scroller.append(inner);\n body.append(scroller);\n }\n\n removeProps?.();\n removeProps = applyProps(root, rest as Record<string, unknown>);\n\n // Focus back where it was: the block that had it, or the one a keyboard move just proposed.\n const want = pendingFocus && pendingFocus.until > Date.now() ? pendingFocus.id : hadFocus;\n if (want) {\n const target = blockFor(want);\n if (target) {\n target.focus();\n if (pendingFocus?.id === want) pendingFocus = null;\n }\n }\n }\n\n render();\n disposer.add(() => removeProps?.());\n disposer.add(() => {\n clearGhost();\n for (const comp of owned) comp.destroy();\n owned = [];\n for (const off of blockCleanups) off();\n blockCleanups = [];\n });\n\n return {\n el: root,\n update(next) {\n current = { ...current, ...next };\n render();\n },\n destroy() {\n disposer.dispose();\n root.remove();\n },\n };\n}\n"],"names":["BLOCK_CLASS","VIEW_LABEL","ALL_VIEWS","TEXT_MIN_WIDTH_PCT","el","tag","className","text","node","uid","PlanningCalendar","props","current","lanePx","calendarLanePx","loc","useLocale","disposer","Disposer","removeProps","innerView","innerDate","hintId","root","body","hint","live","owned","keep","comp","blockCleanups","on","type","listener","axis","laneById","ghost","dimmed","viewOf","dateOf","weekStart","snap","setView","next","render","setDate","editable","appointment","row","blockFor","id","focusedId","active","pendingFocus","clearGhost","showGhost","button","move","lane","placement","placeAppointment","g","formatTimeRange","propose","source","toRow","r","time","toolbar","view","anchor","now","bar","prev","Button","Icon","shiftPlanningAnchor","today","label","planningRangeLabel","switcher","v","actions","toNodes","hadFocus","off","rows","emptyMessage","_children","_dv","_dd","_v","_d","_vs","_n","_ht","_ovc","_odc","_oac","_ta","_oach","_cea","_arc","_sm","_ra","_ac","_ws","_dsh","_deh","_hs","_wh","_nwd","_lh","_den","rest","cn","columns","planningColumns","planningAxis","planningRange","marker","nowPct","laidOut","visible","entry","lanes","laneCount","layoutLanes","i","p","scroller","inner","head","headCols","column","cell","rowEl","track","rules","line","block","canEdit","compact","handler","e","startPlanningGesture","list","rtl","at","planningKeyboardMove","applyProps","want","target"],"mappings":";;;;;;;;;;;;AA0DA,MAAMA,KAAwD;AAAA,EAC5D,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,GAyGMC,KAA+C;AAAA,EACnD,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AACT,GACMC,KAA4B,CAAC,OAAO,QAAQ,OAAO,GAcnDC,KAAqB,GAErBC,IAAK,CACTC,GACAC,GACAC,MAC6B;AAC7B,QAAMC,IAAO,SAAS,cAAcH,CAAG;AACvC,SAAIC,QAAgB,YAAYA,IAC5BC,MAAS,WAAWC,EAAK,cAAcD,IACpCC;AACT;AAEA,IAAIC,KAAM;AAEH,SAASC,GACdC,GACqC;AACrC,MAAIC,IAAiC,EAAE,GAAGD,EAAA;AAE1C,QAAME,IAAS,MAAc,KAAK,IAAI,IAAIC,GAAeF,EAAQ,SAASA,EAAQ,UAAU,CAAC,GACvFG,IAAMC,GAAA,GACNC,IAAW,IAAIC,GAAA;AACrB,MAAIC,GAKAC,KAA0BT,EAAM,eAAe,QAC/CU,KAAkBV,EAAM,eAAe,oBAAI,KAAA;AAE/C,QAAMW,KAAS,yBAAyB,EAAE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,UAAMqC,KAAOlG,KAAgBA,EAAa,QAAQ,KAAK,IAAA,IAAQA,EAAa,KAAK+B;AACjF,QAAImE,IAAM;AACR,YAAMC,IAASvG,GAASsG,EAAI;AAC5B,MAAIC,MACFA,EAAO,MAAA,GACHnG,GAAc,OAAOkG,OAAMlG,IAAe;AAAA,IAElD;AAAA,EACF;AAEA,SAAAT,EAAA,GACA3B,EAAS,IAAI,MAAME,KAAe,GAClCF,EAAS,IAAI,MAAM;AACjB,IAAAqC,EAAA;AACA,eAAWzB,KAAQF,EAAO,CAAAE,EAAK,QAAA;AAC/B,IAAAF,IAAQ,CAAA;AACR,eAAW0D,KAAOvD,EAAe,CAAAuD,EAAA;AACjC,IAAAvD,IAAgB,CAAA;AAAA,EAClB,CAAC,GAEM;AAAA,IACL,IAAIP;AAAA,IACJ,OAAOoB,GAAM;AACX,MAAA/B,IAAU,EAAE,GAAGA,GAAS,GAAG+B,EAAA,GAC3BC,EAAA;AAAA,IACF;AAAA,IACA,UAAU;AACR,MAAA3B,EAAS,QAAA,GACTM,EAAK,OAAA;AAAA,IACP;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"index112.js","sources":["../src/components/planning-calendar/planning-calendar.ts"],"sourcesContent":["import type { IconName } from \"@algorisys/zen-ui-core/icons\";\nimport {\n formatTimeRange,\n layoutLanes,\n nowPct,\n placeAppointment,\n planningAxis,\n planningColumns,\n planningKeyboardMove,\n planningRange,\n planningRangeLabel,\n shiftPlanningAnchor,\n startPlanningGesture,\n calendarFollow,\n type PendingFollow,\n type PlanningPlacement,\n type PlanningProposedMove,\n type PlanningRange,\n type PlanningView,\n type Weekday,\n} from \"@algorisys/zen-ui-core\";\nimport { cn } from \"../../lib/cn\";\nimport { Button } from \"../button/button\";\nimport { Icon } from \"../icon/icon\";\nimport {\n applyProps,\n Disposer,\n toNodes,\n type AnyZenComponent,\n type BaseProps,\n type Child,\n type ZenComponent,\n} from \"../../lib/component\";\nimport { useLocale, type MessageKey } from \"../locale/locale\";\n\n/**\n * PlanningCalendar — who is busy, and when.\n *\n * PlanningCalendar({ rows: people, defaultView: \"week\" }).el\n *\n * A resource-by-time grid: one row per person, room or machine, one axis of\n * time, appointments as blocks on it. The question it answers is a comparison\n * ACROSS rows, which is why a month is one long axis of 31 columns rather than a\n * 6×7 page — wrapping it into weeks would give each resource six separate rows.\n *\n * Vanilla port; see the React binding for the reasoning. Same API, same output.\n * All the arithmetic is imported from @algorisys/zen-ui-core/planning and pinned\n * by scripts/check-planning.ts, so four renderers cannot drift on where 09:30\n * is.\n *\n * It PROPOSES moves and never applies them. Pass `onAppointmentChange` and an\n * appointment can be dragged along its row (long press on touch) or moved with\n * Alt+Left / Alt+Right; `allowRowChange` adds other rows (Alt+Up / Alt+Down).\n * You get `{ appointment, row, toRow, start, end, source }` and apply it with\n * `update({ rows })`, or don't. Without `onAppointmentChange` nothing moves.\n * Same API as Solid and React.\n */\n\nexport type PlanningAppointmentState = \"default\" | \"info\" | \"success\" | \"warning\" | \"error\";\n\nconst BLOCK_CLASS: Record<PlanningAppointmentState, string> = {\n default: \"zen-bg-zen-muted zen-text-zen-foreground zen-border-zen-border\",\n info: \"zen-bg-zen-info-soft zen-text-zen-info zen-border-zen-info\",\n success: \"zen-bg-zen-success-soft zen-text-zen-success zen-border-zen-success\",\n warning: \"zen-bg-zen-warning-soft zen-text-zen-warning zen-border-zen-warning\",\n error: \"zen-bg-zen-error-soft zen-text-zen-error zen-border-zen-error\",\n};\n\nexport interface PlanningAppointment {\n id: string;\n start: Date;\n end: Date;\n title: string;\n /** Second line, when the block is wide enough to show it. */\n subtitle?: string;\n state?: PlanningAppointmentState;\n icon?: IconName;\n /**\n * A save is in flight (an optimistic move, say). The block is dimmed,\n * announced as busy, and cannot be moved again until it clears.\n */\n busy?: boolean;\n}\n\n/** A move the calendar proposes. Nothing has changed until you apply it. */\nexport interface PlanningAppointmentChange {\n appointment: PlanningAppointment;\n /** The row it is in now. */\n row: PlanningRow;\n /** The row it would move to: `row` unless `allowRowChange` let it cross. */\n toRow: PlanningRow;\n start: Date;\n end: Date;\n /** How it was proposed. A keyboard move fires once per key press. */\n source: \"pointer\" | \"keyboard\";\n}\n\nexport interface PlanningAppointmentRenderContext {\n row: PlanningRow;\n /** Too narrow for text (under ~3% of the axis): render a mark, not a label. */\n compact: boolean;\n /** \"09:00 – 10:30\", the same text the block's accessible name carries. */\n timeLabel: string;\n}\n\nexport interface PlanningRow {\n id: string;\n /** The resource: a person, a room, a machine. */\n title: string;\n subtitle?: string;\n appointments: PlanningAppointment[];\n}\n\nexport interface PlanningCalendarProps extends BaseProps {\n rows: PlanningRow[];\n /** Starting view. The factory owns it after that; call update() to control it. */\n defaultView?: PlanningView;\n view?: PlanningView;\n onViewChange?: (view: PlanningView) => void;\n /** Which views the switcher offers. Default all three. */\n views?: PlanningView[];\n /** Any date inside the range to open on. Default today. */\n defaultDate?: Date;\n date?: Date;\n onDateChange?: (date: Date) => void;\n onAppointmentClick?: (appointment: PlanningAppointment, row: PlanningRow) => void;\n /** Reference \"now\" for the marker and today highlight. Injectable for tests. */\n now?: Date;\n hideToolbar?: boolean;\n emptyMessage?: Child;\n /**\n * Your own controls, at the end of the toolbar: a group-by switch, a count.\n * With them, the toolbar stays when there are no rows, so a control that\n * emptied the calendar can also bring the rows back.\n */\n toolbarActions?: Child;\n /**\n * Propose a move. With it, appointments can be dragged (touch: long press)\n * and moved with Alt+arrow keys; without it, nothing moves. You apply it:\n * `update({ rows })`, or don't.\n */\n onAppointmentChange?: (change: PlanningAppointmentChange) => void;\n /** Per-appointment gate. A blocked one is not draggable at all, rather than refused on drop. Default: all. */\n canEditAppointment?: (appointment: PlanningAppointment, row: PlanningRow) => boolean;\n /** Let a move land in another row (re-assign, re-status). Default false: moves stay in their row. */\n allowRowChange?: boolean;\n /** Minutes a move snaps to in the day view. Default 15. Week and month move by whole days. */\n snapMinutes?: number;\n /** Replace a block's content. The calendar keeps the box, its placement, colour and controls. */\n renderAppointment?: (appointment: PlanningAppointment, context: PlanningAppointmentRenderContext) => Child;\n /** Extra classes on a block, e.g. a status colour of your own. */\n appointmentClass?: (appointment: PlanningAppointment, row: PlanningRow) => string | undefined;\n /** First column of a week view (0 = Sunday). Default 1, Monday. */\n weekStartsOn?: Weekday;\n /** First hour the day view draws. Default 0. */\n dayStartHour?: number;\n /** Hour the day view stops at (exclusive). Default 24. */\n dayEndHour?: number;\n /** Hours per column in the day view. Default 1. */\n hourStep?: number;\n /** [from, to) hours drawn unshaded in the day view. Default [9, 18]. */\n workingHours?: [number, number];\n /** Days shaded as non-working (0 = Sunday). Default [0, 6]. */\n nonWorkingDays?: number[];\n /** Height of one lane in px (appointments stack in lanes inside a row). Default 30. */\n laneHeight?: number;\n /**\n * How much room a lane takes: \"compact\", \"comfortable\" (the default, and the\n * size it always was) or \"touch\" (48px targets, for shop-floor tablets).\n * Opt-in: it does not follow data-density, so setting that on a page moves\n * nothing here. An explicit size prop wins over it.\n */\n density?: Density;\n}\n\nconst VIEW_LABEL: Record<PlanningView, MessageKey> = {\n day: \"planningCalendar.views.day\",\n week: \"planningCalendar.views.week\",\n month: \"planningCalendar.views.month\",\n};\nconst ALL_VIEWS: PlanningView[] = [\"day\", \"week\", \"month\"];\n\n/** Row height per lane. A block is 24px tall; lanes stack inside the row. */\nimport { calendarLanePx, type Density } from \"@algorisys/zen-ui-core/density\";\n\n/**\n * Below this width, a block renders no text at all.\n *\n * A 90-minute meeting is 0.9% of a week. At that size a label is not \"clipped\",\n * it is an empty bordered pill — which reads as a component that failed to\n * render rather than as a busy hour. Under the threshold the block is what it\n * actually is at that zoom: an occupancy mark, with its name and time still in\n * the accessible name and the tooltip.\n */\nconst TEXT_MIN_WIDTH_PCT = 3;\n\nconst 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\nlet uid = 0;\n\nexport function PlanningCalendar(\n props: PlanningCalendarProps,\n): ZenComponent<PlanningCalendarProps> {\n let current: PlanningCalendarProps = { ...props };\n // Never so short that a block (lane − 6px) has no height.\n const lanePx = (): number => Math.max(14, calendarLanePx(current.density, current.laneHeight));\n const loc = useLocale();\n const disposer = new Disposer();\n let removeProps: (() => void) | undefined;\n\n /* The factory owns the uncontrolled view and date, because there is no state\n hook here — `update({ view })` is how a caller takes control, and passing\n `view` explicitly wins over what the toolbar last set. */\n let innerView: PlanningView = props.defaultView ?? \"week\";\n let innerDate: Date = props.defaultDate ?? new Date();\n\n const hintId = `zen-planning-calendar-${++uid}`;\n const root = el(\"div\");\n /* What render() rebuilds lives in `body`, laid out as if its children were\n the root's own (display: contents). The hint and the live region sit\n outside it and survive every rebuild, so an announcement is not dropped\n with the DOM it described. */\n const body = el(\"div\", \"zen-contents\");\n const hint = el(\"span\", \"zen-sr-only\");\n hint.id = hintId;\n const live = el(\"div\", \"zen-sr-only\");\n live.setAttribute(\"aria-live\", \"polite\");\n live.setAttribute(\"aria-atomic\", \"true\");\n root.append(body, hint, live);\n\n /* Handles built by the CURRENT render, destroyed before the next one: a\n Button holds a real listener on a node this component created, and there is\n no unmount here to take it away. Without this every re-render — and the\n toolbar re-renders on every click — leaks a listener per control. */\n let owned: AnyZenComponent[] = [];\n const keep = <T extends AnyZenComponent>(comp: T): T => {\n owned.push(comp);\n return comp;\n };\n\n /* Listeners on plain nodes this file builds (blocks), released before the\n next render: the Disposer only runs at destroy(), so pushing there would\n grow by one entry per block on EVERY render. */\n let blockCleanups: Array<() => void> = [];\n const on = <K extends keyof HTMLElementEventMap>(\n node: HTMLElement,\n type: K,\n listener: (e: HTMLElementEventMap[K]) => void,\n ) => {\n node.addEventListener(type, listener);\n blockCleanups.push(() => node.removeEventListener(type, listener));\n };\n\n /* State of the last render the gesture and keyboard need: the axis, and each\n row's lane element (where a ghost is drawn). Not re-rendered during a drag —\n a rebuild per pointermove would cost a full DOM per frame. */\n let axis: PlanningRange = { start: new Date(), end: new Date() };\n let laneById = new Map<string, HTMLElement>();\n let ghost: HTMLElement | null = null;\n let dimmed: HTMLElement | null = null;\n\n const viewOf = () => current.view ?? innerView;\n const dateOf = () => current.date ?? innerDate;\n const weekStart = (): Weekday => current.weekStartsOn ?? 1;\n const snap = () => Math.max(1, current.snapMinutes ?? 15);\n\n /** A keyboard move proposed and not yet seen applied (core's calendarFollow decides, in update()). */\n let pending: PendingFollow | null = null;\n\n // The user navigating is a decision too: an old keyboard move must not pull\n // the view away later. The follow itself uses moveTo, which leaves it alone.\n const setView = (next: PlanningView) => {\n pending = null;\n if (current.view === undefined) innerView = next;\n current.onViewChange?.(next);\n render();\n };\n const moveTo = (next: Date) => {\n if (current.date === undefined) innerDate = next;\n current.onDateChange?.(next);\n };\n const setDate = (next: Date) => {\n pending = null;\n moveTo(next);\n render();\n };\n\n const editable = (appointment: PlanningAppointment, row: PlanningRow) =>\n !!current.onAppointmentChange && !appointment.busy && (current.canEditAppointment?.(appointment, row) ?? true);\n\n const blockFor = (id: string) => body.querySelector<HTMLElement>(`[data-plan-appointment=\"${CSS.escape(id)}\"]`);\n\n /* A rebuild replaces every block, so focus would fall to <body> on ANY update\n — including a caller applying someone else's save. Remember which block\n had it and put it back on the same appointment. */\n const focusedId = (): string | null => {\n const active = root.ownerDocument.activeElement as HTMLElement | null;\n return active && body.contains(active) ? active.getAttribute(\"data-plan-appointment\") : null;\n };\n /** Set by a keyboard move: refocus this id after the caller's update, which may come a little later. */\n let pendingFocus: { id: string; until: number } | null = null;\n\n const clearGhost = () => {\n ghost?.remove();\n ghost = null;\n dimmed?.classList.remove(\"zen-opacity-40\");\n dimmed = null;\n };\n\n const showGhost = (button: HTMLElement, move: PlanningProposedMove | null) => {\n ghost?.remove();\n ghost = null;\n if (!move) {\n clearGhost();\n return;\n }\n if (dimmed !== button) {\n dimmed?.classList.remove(\"zen-opacity-40\");\n dimmed = button;\n button.classList.add(\"zen-opacity-40\");\n }\n const lane = laneById.get(move.rowId);\n const placement = placeAppointment(move, axis);\n if (!lane || !placement) return;\n /* pointer-events: none, or it becomes the element under the pointer and the\n gesture's hit-test finds no lane. */\n const g = el(\n \"div\",\n \"zen-pointer-events-none zen-absolute zen-z-10 zen-flex zen-items-center zen-overflow-hidden zen-rounded-zen-sm zen-border-2 zen-border-dashed zen-border-zen-primary zen-bg-zen-primary-soft zen-px-1.5 zen-text-xs zen-font-medium zen-text-zen-foreground\",\n );\n g.setAttribute(\"aria-hidden\", \"true\");\n g.setAttribute(\"data-plan-ghost\", \"\");\n g.style.setProperty(\"inset-inline-start\", `${placement.startPct}%`);\n g.style.width = `${placement.widthPct}%`;\n g.style.top = \"4px\";\n g.style.height = `${lanePx() - 6}px`;\n g.append(el(\"span\", \"zen-truncate\", formatTimeRange(move.start, move.end)));\n lane.append(g);\n ghost = g;\n };\n\n const propose = (\n appointment: PlanningAppointment,\n row: PlanningRow,\n move: PlanningProposedMove,\n source: \"pointer\" | \"keyboard\",\n ) => {\n const toRow = (current.rows ?? []).find((r) => r.id === move.rowId) ?? row;\n if (source === \"keyboard\") pendingFocus = { id: appointment.id, until: Date.now() + 2000 };\n /* A keyboard move past the edge of the view should take the view with it,\n or the item vanishes and focus with it. But only once the caller has\n APPLIED it: following the proposal at once left a refused move (a\n cancelled confirm) showing a week the item never went to. Decided by\n core's calendarFollow when update({ rows }) arrives. Recorded BEFORE the\n callback: a caller that applies synchronously calls update() inside it.\n Same as Solid and React. */\n pending = source === \"keyboard\" ? { id: appointment.id, from: appointment.start.getTime() } : null;\n current.onAppointmentChange?.({ appointment, row, toRow, start: move.start, end: move.end, source });\n const time = formatTimeRange(move.start, move.end);\n live.textContent = \"\";\n live.textContent =\n toRow.id === row.id\n ? loc.t(\"planningCalendar.proposed\", { title: appointment.title, time })\n : loc.t(\"planningCalendar.proposedRow\", { title: appointment.title, row: toRow.title, time });\n };\n\n function toolbar(view: PlanningView, anchor: Date, now: Date): HTMLElement {\n const bar = el(\"div\", \"zen-flex zen-flex-wrap zen-items-center zen-gap-2\");\n\n const prev = keep(\n Button({\n variant: \"outline\",\n size: \"sm\",\n \"aria-label\": loc.t(\"planningCalendar.previous\"),\n // Logical, not physical: under RTL the axis runs the other way, so a\n // left-pointing chevron would send you forward.\n children: keep(Icon({ name: \"chevron-left\", size: 14, class: \"rtl:zen-rotate-180\" })),\n onClick: () => setDate(shiftPlanningAnchor(view, anchor, -1, weekStart())),\n }),\n );\n const today = keep(\n Button({ variant: \"outline\", size: \"sm\", children: loc.t(\"planningCalendar.today\"), onClick: () => setDate(now) }),\n );\n const next = keep(\n Button({\n variant: \"outline\",\n size: \"sm\",\n \"aria-label\": loc.t(\"planningCalendar.next\"),\n children: keep(Icon({ name: \"chevron-right\", size: 14, class: \"rtl:zen-rotate-180\" })),\n onClick: () => setDate(shiftPlanningAnchor(view, anchor, 1, weekStart())),\n }),\n );\n\n const label = el(\n \"span\",\n \"zen-mx-1 zen-text-sm zen-font-medium zen-text-zen-foreground\",\n planningRangeLabel(view, anchor, weekStart()),\n );\n\n const switcher = el(\"div\", \"zen-ms-auto zen-flex zen-gap-1\");\n switcher.setAttribute(\"role\", \"group\");\n switcher.setAttribute(\"aria-label\", loc.t(\"planningCalendar.view\"));\n for (const v of current.views ?? ALL_VIEWS) {\n switcher.append(\n keep(\n Button({\n variant: view === v ? \"solid\" : \"outline\",\n size: \"sm\",\n \"aria-pressed\": String(view === v),\n children: loc.t(VIEW_LABEL[v]),\n onClick: () => setView(v),\n }),\n ).el,\n );\n }\n\n bar.append(prev.el, today.el, next.el, label, switcher);\n if (current.toolbarActions != null) {\n const actions = el(\"div\", \"zen-flex zen-flex-wrap zen-items-center zen-gap-2\");\n actions.append(...toNodes(current.toolbarActions));\n bar.append(actions);\n }\n return bar;\n }\n\n function render(): void {\n const hadFocus = focusedId();\n clearGhost();\n for (const comp of owned) comp.destroy();\n owned = [];\n for (const off of blockCleanups) off();\n blockCleanups = [];\n body.replaceChildren();\n laneById = new Map();\n\n const {\n rows,\n emptyMessage,\n class: className,\n children: _children,\n defaultView: _dv,\n defaultDate: _dd,\n view: _v,\n date: _d,\n views: _vs,\n now: _n,\n hideToolbar: _ht,\n onViewChange: _ovc,\n onDateChange: _odc,\n onAppointmentClick: _oac,\n toolbarActions: _ta,\n onAppointmentChange: _oach,\n canEditAppointment: _cea,\n allowRowChange: _arc,\n snapMinutes: _sm,\n renderAppointment: _ra,\n appointmentClass: _ac,\n weekStartsOn: _ws,\n dayStartHour: _dsh,\n dayEndHour: _deh,\n hourStep: _hs,\n workingHours: _wh,\n nonWorkingDays: _nwd,\n laneHeight: _lh,\n density: _den,\n ...rest\n } = current;\n\n // w-full, because the grid is a chart: shrink-wrapped to its content it\n // reports a 490px week whose columns are too narrow to read.\n root.className = cn(\"zen-flex zen-w-full zen-flex-col zen-gap-3\", className);\n hint.textContent = loc.t(current.allowRowChange ? \"planningCalendar.editHintRows\" : \"planningCalendar.editHint\");\n\n const view = viewOf();\n const anchor = dateOf();\n const now = current.now ?? new Date();\n const columns = planningColumns(view, anchor, {\n now,\n weekStartsOn: weekStart(),\n dayStartHour: current.dayStartHour,\n dayEndHour: current.dayEndHour,\n hourStep: current.hourStep,\n workingHours: current.workingHours,\n nonWorkingDays: current.nonWorkingDays,\n });\n /* What the lanes DRAW, which is not the view's range once the day view is\n trimmed to working hours: placing against the whole day would put 09:00 a\n third of the way across a grid whose left edge says 08:00. */\n axis = planningAxis(columns, planningRange(view, anchor, weekStart()));\n const marker = nowPct(axis, now);\n\n const laidOut = (rows ?? []).map((row) => {\n const visible = row.appointments\n .map((appointment) => ({ appointment, placement: placeAppointment(appointment, axis) }))\n .filter((entry): entry is { appointment: PlanningAppointment; placement: PlanningPlacement } =>\n entry.placement !== null,\n );\n const { lanes, laneCount } = layoutLanes(visible.map((v) => v.appointment));\n return {\n row,\n blocks: visible.map((v, i) => ({ ...v, lane: lanes[i] })),\n laneCount: Math.max(laneCount, 1),\n };\n });\n\n /* The toolbar is gated on there being rows, not only on `hideToolbar`. With\n no resources and nothing of the caller's in it, Previous / Today / Next\n and the view switcher cannot change anything the user can see. With\n `toolbarActions` it stays: those controls usually decide the rows, and\n hiding them with the rows left the user stuck on an empty calendar.\n Same as Solid and React. */\n if (!current.hideToolbar && (laidOut.length > 0 || current.toolbarActions != null)) {\n body.append(toolbar(view, anchor, now));\n }\n\n if (laidOut.length === 0) {\n const p = el(\"p\", \"zen-m-0 zen-py-6 zen-text-center zen-text-sm zen-text-zen-muted-fg\");\n p.append(...toNodes(emptyMessage ?? loc.t(\"planningCalendar.noResources\")));\n body.append(p);\n } else {\n // One horizontal scroller holding the header and every row, so the axis\n // and the blocks under it cannot scroll out of alignment.\n const scroller = el(\n \"div\",\n \"zen-overflow-x-auto zen-rounded-zen-md zen-border zen-border-zen-border\",\n );\n const inner = el(\"div\", \"zen-min-w-[45rem]\");\n\n const head = el(\"div\", \"zen-flex zen-border-b zen-border-zen-border zen-bg-zen-muted\");\n head.append(\n el(\n \"div\",\n \"zen-w-40 zen-shrink-0 zen-border-e zen-border-zen-border zen-px-3 zen-py-2 zen-text-xs zen-font-semibold zen-text-zen-muted-fg\",\n loc.t(\"planningCalendar.resource\"),\n ),\n );\n const headCols = el(\"div\", \"zen-flex zen-flex-1\");\n for (const column of columns) {\n const cell = el(\n \"div\",\n cn(\n \"zen-flex-1 zen-border-e zen-border-zen-border zen-px-1 zen-py-2 zen-text-center last:zen-border-e-0\",\n column.nonWorking && \"zen-bg-zen-muted\",\n column.today && \"zen-bg-zen-primary-soft\",\n ),\n );\n cell.append(el(\"div\", \"zen-text-xs zen-font-medium zen-text-zen-foreground\", column.label));\n if (column.sublabel) {\n cell.append(el(\"div\", \"zen-[font-size:var(--zen-schedule-label-font-size)] zen-text-zen-muted-fg\", column.sublabel));\n }\n headCols.append(cell);\n }\n head.append(headCols);\n inner.append(head);\n\n for (const entry of laidOut) {\n const rowEl = el(\"div\", \"zen-flex zen-border-b zen-border-zen-border last:zen-border-b-0\");\n\n const label = el(\n \"div\",\n \"zen-w-40 zen-shrink-0 zen-border-e zen-border-zen-border zen-px-3 zen-py-2\",\n );\n label.append(\n el(\"div\", \"zen-truncate zen-text-sm zen-font-medium zen-text-zen-foreground\", entry.row.title),\n );\n if (entry.row.subtitle) {\n label.append(el(\"div\", \"zen-truncate zen-text-xs zen-text-zen-muted-fg\", entry.row.subtitle));\n }\n rowEl.append(label);\n\n /* The lane is the drop target: the gesture hit-tests `data-plan-lane`\n under the pointer, so a block dropped anywhere along its row (or\n another row) lands. */\n const track = el(\"div\", \"zen-relative zen-flex-1\");\n track.setAttribute(\"data-plan-lane\", entry.row.id);\n track.style.minHeight = `${entry.laneCount * lanePx() + 8}px`;\n laneById.set(entry.row.id, track);\n\n // The column rules as a background layer rather than as parents of the\n // blocks: a block spanning four hours cannot live inside one column.\n const rules = el(\"div\", \"zen-absolute zen-inset-0 zen-flex\");\n rules.setAttribute(\"aria-hidden\", \"true\");\n for (const column of columns) {\n rules.append(\n el(\n \"div\",\n cn(\n \"zen-flex-1 zen-border-e zen-border-zen-border last:zen-border-e-0\",\n column.nonWorking && \"zen-bg-zen-muted\",\n column.today && \"zen-bg-zen-primary-soft\",\n ),\n ),\n );\n }\n track.append(rules);\n\n if (marker !== null) {\n const line = el(\"div\", \"zen-absolute zen-top-0 zen-bottom-0 zen-w-px zen-bg-zen-error\");\n line.setAttribute(\"aria-hidden\", \"true\");\n line.style.setProperty(\"inset-inline-start\", `${marker}%`);\n track.append(line);\n }\n\n for (const block of entry.blocks) {\n const { appointment } = block;\n const row = entry.row;\n const canEdit = editable(appointment, row);\n const compact = block.placement.widthPct < TEXT_MIN_WIDTH_PCT;\n /* A real <button> whether or not a handler was passed: these are the\n only things in the grid worth reaching by keyboard, and a div with\n no tabindex takes the whole calendar out of the tab order. */\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.setAttribute(\"data-plan-appointment\", appointment.id);\n button.className = cn(\n \"zen-absolute zen-flex zen-items-center zen-gap-1 zen-overflow-hidden zen-rounded-zen-sm zen-border zen-px-1.5 zen-text-start zen-text-xs\",\n \"focus-visible:zen-outline-none focus-visible:zen-ring-2 focus-visible:zen-ring-zen-ring\",\n BLOCK_CLASS[appointment.state ?? \"default\"],\n // Square off the cut edge so a block continuing past the view does\n // not look like it ends there.\n block.placement.clippedStart && \"zen-rounded-s-none zen-border-s-0\",\n block.placement.clippedEnd && \"zen-rounded-e-none zen-border-e-0\",\n current.onAppointmentClick && \"hover:zen-brightness-95\",\n canEdit && \"zen-cursor-grab\",\n appointment.busy && \"zen-cursor-wait zen-opacity-60\",\n current.appointmentClass?.(appointment, row),\n );\n button.style.setProperty(\"inset-inline-start\", `${block.placement.startPct}%`);\n button.style.width = `${block.placement.widthPct}%`;\n button.style.top = `${block.lane * lanePx() + 4}px`;\n button.style.height = `${lanePx() - 6}px`;\n if (canEdit) {\n // A long press starts a touch drag, so it must not select text or\n // open the iOS callout.\n button.style.userSelect = \"none\";\n button.style.setProperty(\"-webkit-touch-callout\", \"none\");\n button.setAttribute(\"aria-describedby\", hintId);\n button.setAttribute(\n \"aria-keyshortcuts\",\n current.allowRowChange\n ? \"Alt+ArrowLeft Alt+ArrowRight Alt+ArrowUp Alt+ArrowDown\"\n : \"Alt+ArrowLeft Alt+ArrowRight\",\n );\n }\n if (appointment.busy) button.setAttribute(\"aria-busy\", \"true\");\n const time = formatTimeRange(appointment.start, appointment.end);\n button.title = `${appointment.title} · ${time}`;\n\n // The time is in the accessible name, not only the title attribute: a\n // block narrow enough to drop its own label is exactly when someone\n // needs it, and title is not reliably announced.\n button.append(el(\"span\", \"zen-sr-only\", time));\n if (appointment.busy) button.append(el(\"span\", \"zen-sr-only\", loc.t(\"planningCalendar.busy\")));\n\n if (current.renderAppointment) {\n button.append(...toNodes(current.renderAppointment(appointment, { row, compact, timeLabel: time })));\n } else if (!compact) {\n if (appointment.icon) {\n button.append(keep(Icon({ name: appointment.icon, size: 12, class: \"zen-shrink-0\" })).el);\n }\n button.append(el(\"span\", \"zen-truncate zen-font-medium\", appointment.title));\n if (appointment.subtitle) {\n button.append(el(\"span\", \"zen-truncate zen-opacity-70\", appointment.subtitle));\n }\n }\n\n const handler = current.onAppointmentClick;\n if (handler) on(button, \"click\", () => handler(appointment, row));\n\n if (canEdit) {\n on(button, \"pointerdown\", (e) => {\n startPlanningGesture({\n event: e,\n target: button,\n root,\n axis,\n view,\n snapMinutes: snap(),\n appointment,\n rowId: row.id,\n allowRowChange: !!current.allowRowChange,\n scroller,\n onPreview: (move) => showGhost(button, move),\n onCommit: (move) => propose(appointment, row, move, \"pointer\"),\n });\n });\n on(button, \"keydown\", (e) => {\n if (!e.altKey || e.ctrlKey || e.metaKey) return;\n let move: PlanningProposedMove | null = null;\n if (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") {\n if (!current.allowRowChange) return;\n const list = current.rows ?? [];\n const next = list[list.findIndex((r) => r.id === row.id) + (e.key === \"ArrowDown\" ? 1 : -1)];\n if (!next) return;\n move = { start: appointment.start, end: appointment.end, rowId: next.id };\n } else {\n const rtl = getComputedStyle(button).direction === \"rtl\";\n const at = planningKeyboardMove(appointment, e.key, { view, rtl, snapMinutes: snap() });\n if (!at) return;\n move = { ...at, rowId: row.id };\n }\n e.preventDefault();\n e.stopPropagation();\n propose(appointment, row, move, \"keyboard\");\n });\n }\n\n track.append(button);\n }\n\n rowEl.append(track);\n inner.append(rowEl);\n }\n\n scroller.append(inner);\n body.append(scroller);\n }\n\n removeProps?.();\n removeProps = applyProps(root, rest as Record<string, unknown>);\n\n // Focus back where it was: the block that had it, or the one a keyboard move just proposed.\n const want = pendingFocus && pendingFocus.until > Date.now() ? pendingFocus.id : hadFocus;\n if (want) {\n const target = blockFor(want);\n if (target) {\n target.focus();\n if (pendingFocus?.id === want) pendingFocus = null;\n }\n }\n }\n\n render();\n disposer.add(() => removeProps?.());\n disposer.add(() => {\n clearGhost();\n for (const comp of owned) comp.destroy();\n owned = [];\n for (const off of blockCleanups) off();\n blockCleanups = [];\n });\n\n return {\n el: root,\n update(next) {\n current = { ...current, ...next };\n if (pending && next.rows) {\n // Judged against the axis the last render drew: the view has not moved.\n const decision = calendarFollow(pending, next.rows.flatMap((r) => r.appointments), axis);\n if (decision.done) {\n pending = null;\n if (decision.date) moveTo(decision.date);\n }\n }\n // render() puts focus back on the moved block (pendingFocus), in view or not.\n render();\n },\n destroy() {\n disposer.dispose();\n root.remove();\n },\n };\n}\n"],"names":["BLOCK_CLASS","VIEW_LABEL","ALL_VIEWS","TEXT_MIN_WIDTH_PCT","el","tag","className","text","node","uid","PlanningCalendar","props","current","lanePx","calendarLanePx","loc","useLocale","disposer","Disposer","removeProps","innerView","innerDate","hintId","root","body","hint","live","owned","keep","comp","blockCleanups","on","type","listener","axis","laneById","ghost","dimmed","viewOf","dateOf","weekStart","snap","pending","setView","next","render","moveTo","setDate","editable","appointment","row","blockFor","id","focusedId","active","pendingFocus","clearGhost","showGhost","button","move","lane","placement","placeAppointment","g","formatTimeRange","propose","source","toRow","r","time","toolbar","view","anchor","now","bar","prev","Button","Icon","shiftPlanningAnchor","today","label","planningRangeLabel","switcher","v","actions","toNodes","hadFocus","off","rows","emptyMessage","_children","_dv","_dd","_v","_d","_vs","_n","_ht","_ovc","_odc","_oac","_ta","_oach","_cea","_arc","_sm","_ra","_ac","_ws","_dsh","_deh","_hs","_wh","_nwd","_lh","_den","rest","cn","columns","planningColumns","planningAxis","planningRange","marker","nowPct","laidOut","visible","entry","lanes","laneCount","layoutLanes","i","p","scroller","inner","head","headCols","column","cell","rowEl","track","rules","line","block","canEdit","compact","handler","e","startPlanningGesture","list","rtl","at","planningKeyboardMove","applyProps","want","target","decision","calendarFollow"],"mappings":";;;;;;;;;;;;;AA4DA,MAAMA,KAAwD;AAAA,EAC5D,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACT,GA6GMC,KAA+C;AAAA,EACnD,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AACT,GACMC,KAA4B,CAAC,OAAO,QAAQ,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EAAK,MAAM;AAExB,cAAM+G,IAAWC,GAAelH,GAASE,EAAK,KAAK,QAAQ,CAACwB,MAAMA,EAAE,YAAY,GAAGlC,CAAI;AACvF,QAAIyH,EAAS,SACXjH,IAAU,MACNiH,EAAS,QAAM7G,GAAO6G,EAAS,IAAI;AAAA,MAE3C;AAEA,MAAA9G,EAAA;AAAA,IACF;AAAA,IACA,UAAU;AACR,MAAA5B,EAAS,QAAA,GACTM,EAAK,OAAA;AAAA,IACP;AAAA,EAAA;AAEJ;"}
package/dist/index113.js CHANGED
@@ -1,99 +1,104 @@
1
- import { wallMinutes as ae, eventCalendarRange as re, shiftEventCalendarAnchor as G, eventCalendarTitle as se, formatEventTimeRange as ie } from "./index117.js";
2
- import { eventRowPx as le, eventHourPx as ce } from "./index232.js";
3
- import { Disposer as de, applyProps as ve, toNodes as ue } from "./index195.js";
4
- import { Button as E } from "./index4.js";
5
- import { Icon as B } from "./index6.js";
6
- import { useLocale as pe } from "./index31.js";
7
- import { agenda as we } from "./index233.js";
8
- import { el as l, sameDay as me } from "./index234.js";
9
- import { month as fe } from "./index235.js";
10
- import { timeGrid as he } from "./index236.js";
11
- import { registerMessages as ge } from "./index212.js";
12
- import { CALENDAR_MESSAGES as ye } from "./index237.js";
13
- import { cn as Ce } from "./index194.js";
14
- ge(ye);
15
- const De = {
1
+ import { calendarFollow as ie } from "./index232.js";
2
+ import { wallMinutes as le, shiftEventCalendarAnchor as J, eventCalendarTitle as se, formatEventTimeRange as ce, eventCalendarRange as de } from "./index117.js";
3
+ import { eventRowPx as ue, eventHourPx as ve } from "./index233.js";
4
+ import { Disposer as pe, applyProps as me, toNodes as we } from "./index195.js";
5
+ import { Button as x } from "./index4.js";
6
+ import { Icon as K } from "./index6.js";
7
+ import { useLocale as fe } from "./index31.js";
8
+ import { agenda as he } from "./index234.js";
9
+ import { el as l, sameDay as ge } from "./index235.js";
10
+ import { month as ye } from "./index236.js";
11
+ import { timeGrid as Ce } from "./index237.js";
12
+ import { registerMessages as De } from "./index212.js";
13
+ import { CALENDAR_MESSAGES as ke } from "./index238.js";
14
+ import { cn as _e } from "./index194.js";
15
+ De(ke);
16
+ const be = {
16
17
  month: "eventCalendar.views.month",
17
18
  week: "eventCalendar.views.week",
18
19
  workWeek: "eventCalendar.views.workWeek",
19
20
  day: "eventCalendar.views.day",
20
21
  agenda: "eventCalendar.views.agenda"
21
- }, ke = ["month", "week", "day", "agenda"];
22
- let _e = 0;
23
- function lt(x) {
24
- let t = { ...x };
25
- const r = pe(), k = new de(), d = `zen-event-calendar-${++_e}`, w = () => t.views?.length ? t.views : ke;
26
- let O = x.defaultView ?? (w().includes("week") ? "week" : w()[0]), A = x.defaultDate ?? /* @__PURE__ */ new Date(), _ = null;
27
- const m = {};
22
+ }, ze = ["month", "week", "day", "agenda"];
23
+ let Se = 0;
24
+ function vt(A) {
25
+ let t = { ...A };
26
+ const r = fe(), k = new pe(), d = `zen-event-calendar-${++Se}`, m = () => t.views?.length ? t.views : ze;
27
+ let V = A.defaultView ?? (m().includes("week") ? "week" : m()[0]), T = A.defaultDate ?? /* @__PURE__ */ new Date(), _ = null;
28
+ const w = {};
28
29
  let b = null;
29
30
  const a = l("div");
30
31
  a.setAttribute("role", "region"), a.setAttribute("data-cal-owner", d);
31
- const T = l("div"), V = l("div"), N = l("span", "zen-sr-only", r.t("eventCalendar.editHint"));
32
- N.id = d;
33
- const R = l("span", "zen-sr-only", r.t("eventCalendar.slotHint"));
34
- R.id = `${d}-slot`;
32
+ const $ = l("div"), N = l("div"), R = l("span", "zen-sr-only", r.t("eventCalendar.editHint"));
33
+ R.id = d;
34
+ const W = l("span", "zen-sr-only", r.t("eventCalendar.slotHint"));
35
+ W.id = `${d}-slot`;
35
36
  const f = l("div", "zen-sr-only");
36
- f.setAttribute("aria-live", "polite"), f.setAttribute("aria-atomic", "true"), a.append(T, V, N, R, f);
37
- let $ = [], z = [], h = null, H;
38
- const v = {
37
+ f.setAttribute("aria-live", "polite"), f.setAttribute("aria-atomic", "true"), a.append($, N, R, W, f);
38
+ let H = [], z = [], h = null, M;
39
+ const u = {
39
40
  keep(e) {
40
- return $.push(e), e;
41
+ return H.push(e), e;
41
42
  },
42
- on(e, n, s) {
43
- e.addEventListener(n, s), z.push(() => e.removeEventListener(n, s));
43
+ on(e, n, i) {
44
+ e.addEventListener(n, i), z.push(() => e.removeEventListener(n, i));
44
45
  },
45
46
  onRelease(e) {
46
47
  z.push(e);
47
48
  }
48
- }, W = () => {
49
- for (const e of $) e.destroy();
50
- $ = [];
49
+ }, F = () => {
50
+ for (const e of H) e.destroy();
51
+ H = [];
51
52
  for (const e of z) e();
52
53
  z = [];
53
- }, K = () => t.view ?? O, U = () => t.date ?? A, Y = () => t.now ?? y, j = () => ({
54
+ }, I = () => t.view ?? V, q = () => t.date ?? T, Q = () => t.now ?? g, G = () => ({
54
55
  weekStartsOn: t.weekStartsOn,
55
56
  nonWorkingDays: t.nonWorkingDays,
56
57
  agendaDays: t.agendaDays,
57
58
  locale: r.locale
58
- }), I = (e) => {
59
- t.view === void 0 && (O = e), t.onViewChange?.(e), C();
60
- }, g = (e) => {
61
- t.date === void 0 && (A = e), t.onDateChange?.(e), C();
62
- }, M = (e) => e.allDay ? r.t("eventCalendar.allDay") : ie(e.start, e.end, r.locale), P = (e) => {
59
+ });
60
+ let v = null;
61
+ const B = (e) => {
62
+ v = null, t.view === void 0 && (V = e), t.onViewChange?.(e), y();
63
+ }, U = (e) => {
64
+ t.date === void 0 && (T = e), t.onDateChange?.(e);
65
+ }, S = (e) => {
66
+ v = null, U(e), y();
67
+ }, P = (e) => e.allDay ? r.t("eventCalendar.allDay") : ce(e.start, e.end, r.locale), L = (e) => {
63
68
  f.textContent = "", requestAnimationFrame(() => {
64
69
  f.textContent = e;
65
70
  });
66
- }, q = () => {
71
+ }, Y = () => {
67
72
  const e = b;
68
73
  if (!e || (b = null, Date.now() > e.until)) return;
69
- const n = e.part === "main" ? "[data-cal-event-main]" : '[role="checkbox"]', s = `[data-cal-owner="${d}"] [data-cal-event="${CSS.escape(e.id)}"] ${n}`;
70
- a.ownerDocument.querySelector(s)?.focus({ preventScroll: e.part === "checkbox" });
74
+ const n = e.part === "main" ? "[data-cal-event-main]" : '[role="checkbox"]', i = `[data-cal-owner="${d}"] [data-cal-event="${CSS.escape(e.id)}"] ${n}`;
75
+ a.ownerDocument.querySelector(i)?.focus({ preventScroll: e.part === "checkbox" });
71
76
  };
72
- let y = /* @__PURE__ */ new Date();
73
- const J = setInterval(() => {
77
+ let g = /* @__PURE__ */ new Date();
78
+ const X = setInterval(() => {
74
79
  if (t.now !== void 0) return;
75
- const e = y;
76
- if (y = /* @__PURE__ */ new Date(), !me(e, y)) {
77
- C();
80
+ const e = g;
81
+ if (g = /* @__PURE__ */ new Date(), !ge(e, g)) {
82
+ y();
78
83
  return;
79
84
  }
80
85
  for (const n of a.querySelectorAll("[data-cal-now]"))
81
- n.style.top = `${ae(y) / 1440 * 100}%`;
86
+ n.style.top = `${le(g) / 1440 * 100}%`;
82
87
  }, 6e4);
83
- k.add(() => clearInterval(J));
84
- const Q = () => {
85
- const e = K(), n = U(), s = j();
88
+ k.add(() => clearInterval(X));
89
+ const Z = () => {
90
+ const e = I(), n = q(), i = G();
86
91
  return {
87
- memory: m,
92
+ memory: w,
88
93
  props: t,
89
94
  loc: r,
90
- scope: v,
95
+ scope: u,
91
96
  view: e,
92
97
  anchor: n,
93
- now: Y(),
94
- options: s,
95
- hourPx: Math.max(24, ce(t.density, t.hourHeight)),
96
- rowPx: le(t.density),
98
+ now: Q(),
99
+ options: i,
100
+ hourPx: Math.max(24, ve(t.density, t.hourHeight)),
101
+ rowPx: ue(t.density),
97
102
  snap: Math.max(1, t.snapMinutes ?? 15),
98
103
  root: a,
99
104
  hintId: d,
@@ -103,127 +108,128 @@ function lt(x) {
103
108
  },
104
109
  editable: (o) => t.onEventChange !== void 0 && !o.readOnly && (t.canEditEvent?.(o) ?? !0),
105
110
  selectable: t.onSlotSelect !== void 0,
106
- canGoToDay: w().includes("day"),
111
+ canGoToDay: m().includes("day"),
107
112
  goToDay: (o) => {
108
- t.date === void 0 && (A = o), t.onDateChange?.(o), I("day");
113
+ t.date === void 0 && (T = o), t.onDateChange?.(o), B("day");
109
114
  },
110
- setDate: g,
115
+ setDate: S,
111
116
  openEvent: (o) => t.onEventClick?.(o),
112
117
  toggleTask: (o) => {
113
118
  b = { id: o.id, part: "checkbox", until: Date.now() + 1e3 }, t.onTaskToggle?.(o, !o.done);
114
119
  },
115
120
  selectSlot: (o) => {
116
- t.onSlotSelect?.(o), P(r.t("eventCalendar.newEvent", { time: M(o) }));
121
+ t.onSlotSelect?.(o), L(r.t("eventCalendar.newEvent", { time: P(o) }));
117
122
  },
118
- propose: (o, i, D, u) => {
119
- if (u && (b = { id: o.id, part: "main", until: Date.now() + 1e3 }), t.onEventChange?.({ event: o, start: i.start, end: i.end, allDay: i.allDay, kind: D }), P(r.t("eventCalendar.proposed", { title: o.title, time: M(i) })), u) {
120
- const c = re(e, n, s);
121
- e !== "agenda" && (i.start < c.start || i.start >= c.end) ? g(i.start) : q();
122
- }
123
+ propose: (o, s, C, c) => {
124
+ c && (b = { id: o.id, part: "main", until: Date.now() + 1e3 }), v = c ? { id: o.id, from: o.start.getTime() } : null, t.onEventChange?.({ event: o, start: s.start, end: s.end, allDay: s.allDay, kind: C }), L(r.t("eventCalendar.proposed", { title: o.title, time: P(s) })), c && Y();
123
125
  },
124
- timeLabel: M,
125
- announce: P
126
+ timeLabel: P,
127
+ announce: L
126
128
  };
127
- }, X = () => {
129
+ }, ee = () => {
128
130
  const e = a.ownerDocument.activeElement;
129
131
  return !e || !e.closest(`[data-cal-owner="${d}"]`) ? null : e.closest("[data-cal-focus]")?.getAttribute("data-cal-focus") ?? null;
130
- }, Z = (e) => {
132
+ }, te = (e) => {
131
133
  if (!e) return;
132
134
  const n = a.ownerDocument.activeElement;
133
135
  n && n !== a.ownerDocument.body && a.contains(n) || a.ownerDocument.querySelector(`[data-cal-owner="${d}"] [data-cal-focus="${CSS.escape(e)}"]`)?.focus({ preventScroll: !0 });
134
- }, S = (e, n) => (e.el.setAttribute("data-cal-focus", n), e);
135
- function ee(e) {
136
- const n = l("div", "zen-flex zen-flex-wrap zen-items-center zen-gap-2"), s = v.keep(
137
- E({
136
+ }, E = (e, n) => (e.el.setAttribute("data-cal-focus", n), e);
137
+ function ne(e) {
138
+ const n = l("div", "zen-flex zen-flex-wrap zen-items-center zen-gap-2"), i = u.keep(
139
+ x({
138
140
  variant: "outline",
139
141
  size: "sm",
140
142
  "aria-label": r.t("eventCalendar.previous"),
141
- children: v.keep(B({ name: "chevron-left", size: 14, class: "rtl:zen-rotate-180" })),
142
- onClick: () => g(G(e.view, e.anchor, -1, e.options))
143
+ children: u.keep(K({ name: "chevron-left", size: 14, class: "rtl:zen-rotate-180" })),
144
+ onClick: () => S(J(e.view, e.anchor, -1, e.options))
143
145
  })
144
- ), o = v.keep(
145
- E({ variant: "outline", size: "sm", children: r.t("eventCalendar.today"), onClick: () => g(e.now) })
146
- ), i = v.keep(
147
- E({
146
+ ), o = u.keep(
147
+ x({ variant: "outline", size: "sm", children: r.t("eventCalendar.today"), onClick: () => S(e.now) })
148
+ ), s = u.keep(
149
+ x({
148
150
  variant: "outline",
149
151
  size: "sm",
150
152
  "aria-label": r.t("eventCalendar.next"),
151
- children: v.keep(B({ name: "chevron-right", size: 14, class: "rtl:zen-rotate-180" })),
152
- onClick: () => g(G(e.view, e.anchor, 1, e.options))
153
+ children: u.keep(K({ name: "chevron-right", size: 14, class: "rtl:zen-rotate-180" })),
154
+ onClick: () => S(J(e.view, e.anchor, 1, e.options))
153
155
  })
154
- ), D = l("span", "zen-mx-1 zen-text-base zen-font-semibold zen-text-zen-foreground", se(e.view, e.anchor, e.options));
155
- D.setAttribute("aria-live", "polite");
156
- const u = l("div", "zen-ms-auto zen-flex zen-flex-wrap zen-items-center zen-gap-2");
157
- if (u.append(...ue(t.toolbarActions)), w().length > 1) {
158
- const c = l("div", "zen-flex zen-gap-1");
159
- c.setAttribute("role", "group"), c.setAttribute("aria-label", r.t("eventCalendar.view"));
160
- for (const p of w()) {
161
- const F = v.keep(
162
- E({
156
+ ), C = l("span", "zen-mx-1 zen-text-base zen-font-semibold zen-text-zen-foreground", se(e.view, e.anchor, e.options));
157
+ C.setAttribute("aria-live", "polite");
158
+ const c = l("div", "zen-ms-auto zen-flex zen-flex-wrap zen-items-center zen-gap-2");
159
+ if (c.append(...we(t.toolbarActions)), m().length > 1) {
160
+ const D = l("div", "zen-flex zen-gap-1");
161
+ D.setAttribute("role", "group"), D.setAttribute("aria-label", r.t("eventCalendar.view"));
162
+ for (const p of m()) {
163
+ const j = u.keep(
164
+ x({
163
165
  variant: e.view === p ? "solid" : "outline",
164
166
  size: "sm",
165
167
  "aria-pressed": String(e.view === p),
166
- children: r.t(De[p]),
167
- onClick: () => I(p)
168
+ children: r.t(be[p]),
169
+ onClick: () => B(p)
168
170
  })
169
171
  );
170
- c.append(S(F, `view:${p}`).el);
172
+ D.append(E(j, `view:${p}`).el);
171
173
  }
172
- u.append(c);
174
+ c.append(D);
173
175
  }
174
- return S(s, "tool:prev"), S(o, "tool:today"), S(i, "tool:next"), n.append(s.el, o.el, i.el, D, u), n;
176
+ return E(i, "tool:prev"), E(o, "tool:today"), E(s, "tool:next"), n.append(i.el, o.el, s.el, C, c), n;
175
177
  }
176
- function C() {
177
- const e = X();
178
- W();
179
- const n = Q(), {
180
- events: s,
178
+ function y() {
179
+ const e = ee();
180
+ F();
181
+ const n = Z(), {
182
+ events: i,
181
183
  defaultView: o,
182
- view: i,
183
- onViewChange: D,
184
- views: u,
185
- defaultDate: c,
184
+ view: s,
185
+ onViewChange: C,
186
+ views: c,
187
+ defaultDate: D,
186
188
  date: p,
187
- onDateChange: F,
188
- now: be,
189
- weekStartsOn: ze,
190
- nonWorkingDays: Se,
191
- workingHours: Ee,
192
- agendaDays: xe,
193
- scrollToHour: Ae,
194
- hourHeight: Te,
195
- density: $e,
196
- height: He,
197
- snapMinutes: Me,
198
- newEventMinutes: Pe,
199
- maxEventsPerDay: Le,
200
- onEventClick: Oe,
201
- onSlotSelect: Ve,
202
- onEventChange: Ne,
203
- canEditEvent: Re,
204
- onTaskToggle: We,
205
- renderEvent: Ie,
206
- eventClassName: qe,
207
- dayClassName: Fe,
208
- headerClassName: Ge,
209
- toolbarActions: Be,
210
- hideToolbar: Ke,
211
- emptyMessage: Ue,
212
- class: te,
213
- children: Ye,
214
- ...ne
189
+ onDateChange: j,
190
+ now: Ee,
191
+ weekStartsOn: xe,
192
+ nonWorkingDays: Ae,
193
+ workingHours: Te,
194
+ agendaDays: $e,
195
+ scrollToHour: He,
196
+ hourHeight: Me,
197
+ density: Pe,
198
+ height: Le,
199
+ snapMinutes: Oe,
200
+ newEventMinutes: Ve,
201
+ maxEventsPerDay: Ne,
202
+ onEventClick: Re,
203
+ onSlotSelect: We,
204
+ onEventChange: Fe,
205
+ canEditEvent: Ie,
206
+ onTaskToggle: qe,
207
+ renderEvent: Ge,
208
+ eventClassName: Be,
209
+ dayClassName: Ue,
210
+ headerClassName: Ye,
211
+ toolbarActions: je,
212
+ hideToolbar: Je,
213
+ emptyMessage: Ke,
214
+ class: oe,
215
+ children: Qe,
216
+ ...ae
215
217
  } = t;
216
- if (a.className = Ce("zen-flex zen-w-full zen-flex-col zen-gap-3", te), a.setAttribute("aria-label", r.t("eventCalendar.calendar")), T.replaceChildren(...t.hideToolbar ? [] : [ee(n)]), T.style.display = t.hideToolbar ? "none" : "", h = n.view === "month" ? fe(n) : n.view === "agenda" ? we(n) : he(n), V.replaceChildren(h.el), h.mounted?.(), _ && h.applyPreview(_), n.view === "month" && m.focusDayAfterRender && m.focusedDay) {
217
- m.focusDayAfterRender = !1;
218
- const L = m.focusedDay, oe = `${L.getFullYear()}-${String(L.getMonth() + 1).padStart(2, "0")}-${String(L.getDate()).padStart(2, "0")}`;
219
- a.querySelector(`[data-cal-cell="${oe}"] [data-cal-daynum]`)?.focus();
218
+ if (a.className = _e("zen-flex zen-w-full zen-flex-col zen-gap-3", oe), a.setAttribute("aria-label", r.t("eventCalendar.calendar")), $.replaceChildren(...t.hideToolbar ? [] : [ne(n)]), $.style.display = t.hideToolbar ? "none" : "", h = n.view === "month" ? ye(n) : n.view === "agenda" ? he(n) : Ce(n), N.replaceChildren(h.el), h.mounted?.(), _ && h.applyPreview(_), n.view === "month" && w.focusDayAfterRender && w.focusedDay) {
219
+ w.focusDayAfterRender = !1;
220
+ const O = w.focusedDay, re = `${O.getFullYear()}-${String(O.getMonth() + 1).padStart(2, "0")}-${String(O.getDate()).padStart(2, "0")}`;
221
+ a.querySelector(`[data-cal-cell="${re}"] [data-cal-daynum]`)?.focus();
220
222
  }
221
- Z(e), q(), H?.(), H = ve(a, ne);
223
+ te(e), Y(), M?.(), M = me(a, ae);
222
224
  }
223
- return C(), k.add(() => H?.()), k.add(W), {
225
+ return y(), k.add(() => M?.()), k.add(F), {
224
226
  el: a,
225
227
  update(e) {
226
- t = { ...t, ...e }, C();
228
+ if (t = { ...t, ...e }, v && e.events) {
229
+ const n = I(), i = n === "agenda" ? { done: !0, date: null } : ie(v, e.events, de(n, q(), G()));
230
+ i.done && (v = null, i.date && U(i.date));
231
+ }
232
+ y();
227
233
  },
228
234
  destroy() {
229
235
  k.dispose(), a.remove();
@@ -231,6 +237,6 @@ function lt(x) {
231
237
  };
232
238
  }
233
239
  export {
234
- lt as EventCalendar
240
+ vt as EventCalendar
235
241
  };
236
242
  //# sourceMappingURL=index113.js.map