@vielzeug/refine 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.cjs.map +1 -1
- package/dist/calendar.js +1 -1
- package/dist/calendar.js.map +1 -1
- package/dist/core/date-picker.cjs +1 -1
- package/dist/core/date-picker.cjs.map +1 -1
- package/dist/core/date-picker.d.ts.map +1 -1
- package/dist/core/date-picker.js +7 -7
- package/dist/core/date-picker.js.map +1 -1
- package/dist/custom-elements.json +7299 -7299
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.cjs.map +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/date-picker.js.map +1 -1
- package/dist/overlay/shared/use-floating-trigger.cjs +1 -1
- package/dist/overlay/shared/use-floating-trigger.cjs.map +1 -1
- package/dist/overlay/shared/use-floating-trigger.d.ts.map +1 -1
- package/dist/overlay/shared/use-floating-trigger.js +13 -7
- package/dist/overlay/shared/use-floating-trigger.js.map +1 -1
- package/dist/refine.cjs +4 -4
- package/dist/refine.cjs.map +1 -1
- package/dist/refine.iife.js +4 -4
- package/dist/refine.iife.js.map +1 -1
- package/dist/refine.js +5 -5
- package/dist/refine.js.map +1 -1
- package/package.json +206 -10
package/dist/calendar.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./styles/mixins/accessibility.css.cjs"),t=require("./styles/mixins/theme.css.cjs"),n=require("./core/date-picker.cjs"),r=require("./shared/prop-bundles.cjs"),i=require("./inputs/calendar/calendar.css.cjs");let a=require("@vielzeug/ore"),o=require("@vielzeug/ripple"),s=require("@vielzeug/tempo");var c=`ore-calendar`,l=3;(0,a.define)(c,{formAssociated:!0,props:{...r.themableBundle,...r.sizableBundle,...r.disablableBundle,...r.roundableBundle,events:a.prop.json([]),expanded:a.prop.bool(!1),fullwidth:a.prop.bool(!1),locale:a.prop.string(),max:a.prop.string(),min:a.prop.string(),name:a.prop.string(),required:a.prop.bool(!1),value:a.prop.string(),"weekend-days":a.prop.json([])},setup(e){let t=(0,a.useEmit)(),r=(0,o.computed)(()=>e.disabled.value===!0),i=(0,o.computed)(()=>e.expanded.value===!0),c=(0,o.signal)(void 0),u=(0,o.computed)(()=>c.value===void 0?n.parseIso(e.value.value):c.value),d=n.createDatePickerControl({get locale(){return e.locale.value??(typeof navigator<`u`?navigator.language:`en`)},get max(){return n.parseIso(e.max.value)},get min(){return n.parseIso(e.min.value)},onChange(e){c.value=e,f.value=`day`,p.value=d.displayYear(),m.value=d.displayMonth(),t(`change`,{isoValue:n.toIsoString(e)})},get value(){return u.value},get weekendDays(){return e[`weekend-days`].value??[]}}),f=(0,o.signal)(`day`),p=(0,o.signal)(d.displayYear()),m=(0,o.signal)(d.displayMonth());(0,a.useField)({disabled:r,toFormValue:e=>e||null,value:(0,o.computed)(()=>n.toIsoString(u.value)??``)});let h=(0,o.computed)(()=>{let t=new Map;for(let n of e.events.value??[]){let e=t.get(n.date)??[];e.push(n),t.set(n.date,e)}return t}),g=(0,o.computed)(()=>(p.value,m.value,u.value,d.dayCells())),_=(0,o.computed)(()=>(p.value,d.monthCells())),v=(0,o.computed)(()=>(p.value,d.yearCells())),y=(0,o.computed)(()=>d.weekdayLabels()),b=(0,o.computed)(()=>{let t=s.Temporal.PlainDate.from({day:1,month:m.value,year:p.value}),n=e.locale.value??(typeof navigator<`u`?navigator.language:`en`);return(0,s.format)(t,{intl:{month:`long`},locale:n,
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./styles/mixins/accessibility.css.cjs"),t=require("./styles/mixins/theme.css.cjs"),n=require("./core/date-picker.cjs"),r=require("./shared/prop-bundles.cjs"),i=require("./inputs/calendar/calendar.css.cjs");let a=require("@vielzeug/ore"),o=require("@vielzeug/ripple"),s=require("@vielzeug/tempo");var c=`ore-calendar`,l=3;(0,a.define)(c,{formAssociated:!0,props:{...r.themableBundle,...r.sizableBundle,...r.disablableBundle,...r.roundableBundle,events:a.prop.json([]),expanded:a.prop.bool(!1),fullwidth:a.prop.bool(!1),locale:a.prop.string(),max:a.prop.string(),min:a.prop.string(),name:a.prop.string(),required:a.prop.bool(!1),value:a.prop.string(),"weekend-days":a.prop.json([])},setup(e){let t=(0,a.useEmit)(),r=(0,o.computed)(()=>e.disabled.value===!0),i=(0,o.computed)(()=>e.expanded.value===!0),c=(0,o.signal)(void 0),u=(0,o.computed)(()=>c.value===void 0?n.parseIso(e.value.value):c.value),d=n.createDatePickerControl({get locale(){return e.locale.value??(typeof navigator<`u`?navigator.language:`en`)},get max(){return n.parseIso(e.max.value)},get min(){return n.parseIso(e.min.value)},onChange(e){c.value=e,f.value=`day`,p.value=d.displayYear(),m.value=d.displayMonth(),t(`change`,{isoValue:n.toIsoString(e)})},get value(){return u.value},get weekendDays(){return e[`weekend-days`].value??[]}}),f=(0,o.signal)(`day`),p=(0,o.signal)(d.displayYear()),m=(0,o.signal)(d.displayMonth());(0,a.useField)({disabled:r,toFormValue:e=>e||null,value:(0,o.computed)(()=>n.toIsoString(u.value)??``)});let h=(0,o.computed)(()=>{let t=new Map;for(let n of e.events.value??[]){let e=t.get(n.date)??[];e.push(n),t.set(n.date,e)}return t}),g=(0,o.computed)(()=>(p.value,m.value,u.value,d.dayCells())),_=(0,o.computed)(()=>(p.value,d.monthCells())),v=(0,o.computed)(()=>(p.value,d.yearCells())),y=(0,o.computed)(()=>d.weekdayLabels()),b=(0,o.computed)(()=>{let t=s.Temporal.PlainDate.from({day:1,month:m.value,year:p.value}),n=e.locale.value??(typeof navigator<`u`?navigator.language:`en`);return(0,s.format)(t,{intl:{month:`long`},locale:n,timeZone:`UTC`})}),x=(0,o.computed)(()=>String(p.value)),S=(0,o.computed)(()=>`${b.value} ${x.value}`);function C(){f.value===`day`?d.prevMonth():d.prevYear(),p.value=d.displayYear(),m.value=d.displayMonth()}function w(){f.value===`day`?d.nextMonth():d.nextYear(),p.value=d.displayYear(),m.value=d.displayMonth()}function T(){let e=[`day`,`month`,`year`],t=e[(e.indexOf(f.value)+1)%e.length];d.setView(t),f.value=t}function E(e){r.value||(d.goTo(d.displayYear(),e),d.setView(`day`),p.value=d.displayYear(),m.value=d.displayMonth(),f.value=`day`)}function D(e){r.value||(d.goTo(e,d.displayMonth()),d.setView(`month`),p.value=d.displayYear(),f.value=`month`)}function O(e){if(r.value)return;let t=n.parseIso(e);t&&d.select(t)}function k(e){let t=e.currentTarget,n=t.closest(`.cal-grid-days`);if(!n)return;let r=Array.from(n.querySelectorAll(`.cal-cell-day`)),i=r.indexOf(t);if(i===-1)return;let a;if(e.key===`Enter`||e.key===` `){e.preventDefault(),O(t.dataset.iso??``);return}if(e.key===`ArrowRight`)a=r[i+1];else if(e.key===`ArrowLeft`)a=r[i-1];else if(e.key===`ArrowDown`)a=r[i+7];else if(e.key===`ArrowUp`)a=r[i-7];else if(e.key===`Home`)a=r[Math.floor(i/7)*7];else if(e.key===`End`)a=r[Math.floor(i/7)*7+6];else return;e.preventDefault(),a?.focus()}function A(e,t,n,r){let i=e.currentTarget,a=i.closest(`.cal-grid`);if(!a)return;let o=Array.from(a.querySelectorAll(t)),s=o.indexOf(i);if(s===-1)return;let c;if(e.key===`Enter`||e.key===` `){e.preventDefault(),r();return}if(e.key===`ArrowRight`)c=o[s+1];else if(e.key===`ArrowLeft`)c=o[s-1];else if(e.key===`ArrowDown`)c=o[s+n];else if(e.key===`ArrowUp`)c=o[s-n];else if(e.key===`Home`)c=o[Math.floor(s/n)*n];else if(e.key===`End`)c=o[Math.min(Math.floor(s/n)*n+n-1,o.length-1)];else return;e.preventDefault(),c?.focus()}return(0,a.bind)({attr:{"aria-disabled":()=>r.value?`true`:null,"aria-label":()=>S.value,role:`group`},class:{"is-disabled":r}}),a.html`
|
|
2
2
|
<div class="calendar" part="calendar" role="presentation">
|
|
3
3
|
<!-- Header -->
|
|
4
4
|
<div class="cal-header" part="header">
|
package/dist/calendar.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.cjs","names":[],"sources":["../src/inputs/calendar/calendar.ts"],"sourcesContent":["import { define, html, prop, bind, useEmit, styleMap } from '@vielzeug/ore';\nimport { useField } from '@vielzeug/ore';\nimport { computed, signal } from '@vielzeug/ripple';\nimport { Temporal, format } from '@vielzeug/tempo';\n\nimport type { ComponentSize, RoundedSize, ThemeColor } from '../../shared';\n\nimport '../../content/icon/icon';\nimport '../../feedback/badge/badge';\nimport { createDatePickerControl, parseIso, toIsoString, type DatePickerView } from '../../core';\nimport { disablableBundle, roundableBundle, sizableBundle, themableBundle } from '../../shared';\nimport { colorThemeMixin, reducedMotionMixin } from '../../styles';\nimport componentStyles from './calendar.css?inline';\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type OreCalendarEvents = {\n change: { isoValue: string | null };\n};\n\n/**\n * A calendar event entry.\n * Dates must be ISO 8601 strings (yyyy-MM-dd).\n *\n * The `color` field accepts any valid CSS color value (e.g. `'#e11d48'`,\n * `'var(--color-primary)'`). An invalid value silently falls back to the\n * component's theme color. Only pass values you control.\n */\nexport type CalendarEvent = {\n /**\n * Any CSS color value for the event dot / pill.\n * Defaults to the component's theme color when omitted.\n * Rendered via `styleMap()`, which strips `;`/`{`/`}` so the value can't break out of\n * its custom-property declaration — it is not a full CSS-color syntax validator, so an\n * invalid (but injection-safe) value may still render as no color.\n */\n color?: string;\n /** ISO date the event falls on (yyyy-MM-dd) */\n date: string;\n /** Unique identifier */\n id: string;\n /** Short label shown in the calendar cell */\n label: string;\n};\n\nexport type OreCalendarProps = {\n /** Theme color */\n color?: ThemeColor;\n /** Disable all date selection */\n disabled?: boolean;\n /**\n * Array of calendar events to display on day cells.\n * In normal mode each event renders as a small colored dot (max 3 dots, then \"+N\").\n * In expanded mode each event renders as a full-width colored pill with its label.\n * Pass as a JS property or as a JSON-encoded attribute.\n * @example\n * ```js\n * calendar.events = [\n * { id: '1', date: '2025-06-15', label: 'Team standup', color: 'var(--color-primary)' },\n * { id: '2', date: '2025-06-20', label: 'Release', color: '#e11d48' },\n * ];\n * ```\n */\n events?: CalendarEvent[];\n /**\n * Expanded layout — large cells with top-aligned day numbers suitable\n * for a full-page calendar app view.\n */\n expanded?: boolean;\n /** Expand to container width */\n fullwidth?: boolean;\n /** Locale for day/month names (default: browser locale) */\n locale?: string;\n /** Latest selectable date in ISO 8601 format (yyyy-MM-dd) */\n max?: string;\n /** Earliest selectable date in ISO 8601 format (yyyy-MM-dd) */\n min?: string;\n /** Form field name (when used inside a form) */\n name?: string;\n /** Mark field as required */\n required?: boolean;\n /** Border radius override */\n rounded?: RoundedSize;\n /** Component size */\n size?: ComponentSize;\n /**\n * Selected date in ISO 8601 format (yyyy-MM-dd).\n * @example '2025-06-15'\n */\n value?: string;\n /**\n * Day-of-week indices to disable (0 = Sunday … 6 = Saturday).\n * Pass as a JSON array attribute or a JS property.\n * @example\n * ```html\n * <ore-calendar weekend-days=\"[0,6]\"></ore-calendar>\n * ```\n */\n 'weekend-days'?: number[];\n};\n\n/**\n * An accessible, keyboard-navigable inline calendar component.\n * Supports day/month/year drill-down views, min/max bounds, disabled weekend\n * days, and optional form association.\n *\n * @element ore-calendar\n *\n * @attr {string} value - Selected date in ISO 8601 format (yyyy-MM-dd)\n * @attr {string} min - Minimum selectable date (yyyy-MM-dd)\n * @attr {string} max - Maximum selectable date (yyyy-MM-dd)\n * @attr {boolean} disabled - Disable all interaction\n * @attr {boolean} required - Required field (form association)\n * @attr {string} name - Form field name\n * @attr {string} color - Theme color: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'\n * @attr {string} size - Component size: 'sm' | 'md' | 'lg'\n * @attr {string} rounded - Border radius: 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full'\n * @attr {string} locale - BCP 47 locale string\n * @attr {string} weekend-days - JSON array of day indices to disable (0=Sun…6=Sat)\n * @attr {boolean} fullwidth - Expand to full container width\n * @attr {boolean} expanded - Large-cell calendar-app layout with top-aligned day numbers\n *\n * @fires change - Fired when a date is selected. detail: { isoValue: string | null }\n *\n * @cssprop --calendar-bg - Calendar background\n * @cssprop --calendar-border-color - Calendar border color\n * @cssprop --calendar-radius - Calendar border radius\n * @cssprop --calendar-shadow - Calendar drop shadow\n * @cssprop --calendar-day-selected-bg - Background of selected day cell\n * @cssprop --calendar-day-today-color - Colour of today's date number\n * @cssprop --calendar-day-outside-opacity - Opacity of days outside visible month\n *\n * @part calendar - The root calendar panel\n * @part header - Calendar header (nav + label)\n * @part grid - Day grid\n * @part day - Individual day cell\n *\n * @example\n * ```html\n * <!-- Single date with bounds -->\n * <ore-calendar value=\"2025-06-15\" min=\"2025-01-01\" max=\"2025-12-31\" color=\"primary\"></ore-calendar>\n *\n * <!-- Expanded calendar-app layout -->\n * <ore-calendar expanded fullwidth color=\"primary\"></ore-calendar>\n * ```\n */\nexport const CALENDAR_TAG = 'ore-calendar' as const;\n\n/** Maximum event dots/pills shown per cell before \"+N\" overflow */\nconst MAX_EVENTS = 3;\n\n// ── Component ────────────────────────────────────────────────────────────────\n\ndefine<OreCalendarProps>(CALENDAR_TAG, {\n formAssociated: true,\n props: {\n ...themableBundle,\n ...sizableBundle,\n ...disablableBundle,\n ...roundableBundle,\n events: prop.json([] as CalendarEvent[]),\n expanded: prop.bool(false),\n fullwidth: prop.bool(false),\n locale: prop.string(),\n max: prop.string(),\n min: prop.string(),\n name: prop.string(),\n required: prop.bool(false),\n value: prop.string(),\n 'weekend-days': prop.json([] as number[]),\n },\n\n setup(props) {\n const emit = useEmit<OreCalendarEvents>();\n\n // ── Derived flags ────────────────────────────────────────────────────────\n\n const isDisabled = computed(() => props.disabled.value === true);\n const isExpanded = computed(() => props.expanded.value === true);\n\n // ── Selected date: local-override pattern ─────────────────────────────────\n // `localSelection` holds a user-initiated pick (or undefined = no override).\n // `selectedDate` derives from it, falling back to the value prop reactively.\n // This eliminates setInterval polling — external prop changes propagate\n // through the computed graph automatically.\n\n const localSelection = signal<Temporal.PlainDate | null | undefined>(undefined);\n\n const selectedDate = computed(() =>\n localSelection.value !== undefined ? localSelection.value : parseIso(props.value.value),\n );\n\n // ── Date-picker control ──────────────────────────────────────────────────\n\n const ctrl = createDatePickerControl({\n get locale() {\n return props.locale.value ?? (typeof navigator !== 'undefined' ? navigator.language : 'en');\n },\n get max() {\n return parseIso(props.max.value);\n },\n get min() {\n return parseIso(props.min.value);\n },\n onChange(date) {\n localSelection.value = date;\n currentView.value = 'day';\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n emit('change', { isoValue: toIsoString(date) });\n },\n get value() {\n return selectedDate.value;\n },\n get weekendDays() {\n return props['weekend-days'].value ?? [];\n },\n });\n\n // ── Reactive display state ────────────────────────────────────────────────\n // Three separate primitive signals — the proven pattern. Mutating any one\n // of them invalidates only the computeds that read it.\n\n const currentView = signal<DatePickerView>('day');\n const displayYear = signal(ctrl.displayYear());\n const displayMonth = signal(ctrl.displayMonth()); // 1-indexed (Temporal)\n\n // ── Form value ───────────────────────────────────────────────────────────\n\n useField<string>({\n disabled: isDisabled,\n toFormValue: (v) => v || null,\n value: computed(() => toIsoString(selectedDate.value) ?? ''),\n });\n\n // ── Events lookup ─────────────────────────────────────────────────────────\n\n const eventsByDate = computed(() => {\n const map = new Map<string, CalendarEvent[]>();\n\n for (const evt of props.events.value ?? []) {\n const list = map.get(evt.date) ?? [];\n\n list.push(evt);\n map.set(evt.date, list);\n }\n\n return map;\n });\n\n // ── Derived cells ─────────────────────────────────────────────────────────\n // Each reads a display signal so they re-run when navigation changes.\n\n const dayCells = computed(() => {\n void displayYear.value;\n void displayMonth.value;\n void selectedDate.value; // re-run when selection changes to refresh isSelected flags\n\n return ctrl.dayCells();\n });\n const monthCells = computed(() => {\n void displayYear.value;\n\n return ctrl.monthCells();\n });\n const yearCells = computed(() => {\n void displayYear.value;\n\n return ctrl.yearCells();\n });\n const weekdayLabels = computed(() => ctrl.weekdayLabels());\n\n const displayMonth_ = computed(() => {\n const d = Temporal.PlainDate.from({ day: 1, month: displayMonth.value, year: displayYear.value });\n const loc = props.locale.value ?? (typeof navigator !== 'undefined' ? navigator.language : 'en');\n\n return format(d, { intl: { month: 'long' }, locale: loc, tz: 'UTC' });\n });\n\n const displayYear_ = computed(() => String(displayYear.value));\n const displayLabel = computed(() => `${displayMonth_.value} ${displayYear_.value}`);\n\n // ── Navigation ───────────────────────────────────────────────────────────\n\n function handlePrev(): void {\n if (currentView.value === 'day') ctrl.prevMonth();\n else ctrl.prevYear();\n\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n }\n\n function handleNext(): void {\n if (currentView.value === 'day') ctrl.nextMonth();\n else ctrl.nextYear();\n\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n }\n\n function handleHeaderClick(): void {\n const views: DatePickerView[] = ['day', 'month', 'year'];\n const next = views[(views.indexOf(currentView.value) + 1) % views.length];\n\n ctrl.setView(next);\n currentView.value = next;\n }\n\n // ── Selection handlers — all disabled guards live here ────────────────────\n\n function handleSelectMonth(month: number): void {\n if (isDisabled.value) return;\n\n ctrl.goTo(ctrl.displayYear(), month);\n ctrl.setView('day');\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n currentView.value = 'day';\n }\n\n function handleSelectYear(year: number): void {\n if (isDisabled.value) return;\n\n ctrl.goTo(year, ctrl.displayMonth());\n ctrl.setView('month');\n displayYear.value = ctrl.displayYear();\n currentView.value = 'month';\n }\n\n function handleSelectDay(isoStr: string): void {\n if (isDisabled.value) return;\n\n const date = parseIso(isoStr);\n\n if (!date) return;\n\n ctrl.select(date); // ctrl.select() internally rejects disabled/out-of-range dates\n }\n\n // ── Day-cell keyboard navigation (full ARIA grid pattern) ─────────────────\n\n function handleDayKeydown(e: KeyboardEvent): void {\n const cell = e.currentTarget as HTMLElement;\n const grid = cell.closest('.cal-grid-days');\n\n if (!grid) return;\n\n const allCells = Array.from(grid.querySelectorAll<HTMLElement>('.cal-cell-day'));\n const idx = allCells.indexOf(cell);\n\n if (idx === -1) return;\n\n let target: HTMLElement | undefined;\n\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n handleSelectDay(cell.dataset.iso ?? '');\n\n return;\n } else if (e.key === 'ArrowRight') {\n target = allCells[idx + 1];\n } else if (e.key === 'ArrowLeft') {\n target = allCells[idx - 1];\n } else if (e.key === 'ArrowDown') {\n target = allCells[idx + 7];\n } else if (e.key === 'ArrowUp') {\n target = allCells[idx - 7];\n } else if (e.key === 'Home') {\n target = allCells[Math.floor(idx / 7) * 7]; // first cell in same row\n } else if (e.key === 'End') {\n target = allCells[Math.floor(idx / 7) * 7 + 6]; // last cell in same row\n } else {\n return;\n }\n\n e.preventDefault();\n target?.focus();\n }\n\n // ── Month/year-cell keyboard navigation (fixed 4-column grid) ─────────────\n\n function handleGridKeydown(e: KeyboardEvent, cellSelector: string, columns: number, onSelect: () => void): void {\n const cell = e.currentTarget as HTMLElement;\n const grid = cell.closest('.cal-grid');\n\n if (!grid) return;\n\n const allCells = Array.from(grid.querySelectorAll<HTMLElement>(cellSelector));\n const idx = allCells.indexOf(cell);\n\n if (idx === -1) return;\n\n let target: HTMLElement | undefined;\n\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onSelect();\n\n return;\n } else if (e.key === 'ArrowRight') {\n target = allCells[idx + 1];\n } else if (e.key === 'ArrowLeft') {\n target = allCells[idx - 1];\n } else if (e.key === 'ArrowDown') {\n target = allCells[idx + columns];\n } else if (e.key === 'ArrowUp') {\n target = allCells[idx - columns];\n } else if (e.key === 'Home') {\n target = allCells[Math.floor(idx / columns) * columns];\n } else if (e.key === 'End') {\n target = allCells[Math.min(Math.floor(idx / columns) * columns + columns - 1, allCells.length - 1)];\n } else {\n return;\n }\n\n e.preventDefault();\n target?.focus();\n }\n\n // ── Host bindings ────────────────────────────────────────────────────────\n\n bind({\n attr: {\n 'aria-disabled': () => (isDisabled.value ? 'true' : null),\n 'aria-label': () => displayLabel.value,\n role: 'group',\n },\n class: {\n 'is-disabled': isDisabled,\n },\n });\n\n // ── Template ─────────────────────────────────────────────────────────────\n\n return html`\n <div class=\"calendar\" part=\"calendar\" role=\"presentation\">\n <!-- Header -->\n <div class=\"cal-header\" part=\"header\">\n <button class=\"nav-btn\" type=\"button\" aria-label=\"Previous\" ?disabled=\"${isDisabled}\" @click=\"${handlePrev}\">\n <ore-icon name=\"chevron-left\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </button>\n\n <button\n class=\"cal-label-btn\"\n type=\"button\"\n aria-label=\"${() =>\n `Switch to ${currentView.value === 'day' ? 'month' : currentView.value === 'month' ? 'year' : 'day'} view`}\"\n ?disabled=\"${isDisabled}\"\n @click=\"${handleHeaderClick}\">\n <span class=\"cal-label-month\">${displayMonth_}</span>\n <span class=\"cal-label-sep\" aria-hidden=\"true\">/</span>\n <span class=\"cal-label-year\">${displayYear_}</span>\n </button>\n\n <button class=\"nav-btn\" type=\"button\" aria-label=\"Next\" ?disabled=\"${isDisabled}\" @click=\"${handleNext}\">\n <ore-icon name=\"chevron-right\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </button>\n </div>\n\n <!-- Day view -->\n <div\n class=\"cal-grid cal-grid-days\"\n role=\"grid\"\n part=\"grid\"\n aria-label=\"${() => displayLabel.value}\"\n ?hidden=\"${() => currentView.value !== 'day'}\">\n <div role=\"row\" class=\"cal-grid-row\">\n ${() =>\n weekdayLabels.value.map(\n (lbl) => html`\n <div class=\"cal-cell cal-cell-head\" role=\"columnheader\" aria-label=\"${lbl}\">${lbl}</div>\n `,\n )}\n </div>\n ${() => {\n const cells = dayCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 7) rows.push(cells.slice(i, i + 7));\n\n return rows.map(\n (row) => html`\n <div role=\"row\" class=\"cal-grid-row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-day\"\n role=\"gridcell\"\n part=\"day\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n aria-current=\"${() => (cell.isToday ? 'date' : null)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-today=\"${() => cell.isToday}\"\n ?data-outside=\"${() => cell.isOutsideMonth}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n data-iso=\"${cell.iso}\"\n data-day=\"${String(cell.day)}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectDay(cell.iso)}\"\n @keydown=\"${handleDayKeydown}\">\n ${String(cell.day)}\n ${() => {\n const evts = eventsByDate.value.get(cell.iso) ?? [];\n\n if (!evts.length) return html``;\n\n const shown = evts.slice(0, MAX_EVENTS);\n const overflow = evts.length - MAX_EVENTS;\n\n if (isExpanded.value) {\n // Text node is written tag-tight (no inner line breaks) — this custom\n // `html` tagged template does not collapse whitespace at runtime like a\n // browser parser would, so a pretty-printed multi-line `<span>...</span>`\n // here would render literal newlines/indentation into `textContent`.\n // prettier-ignore\n const overflowPill = overflow > 0\n ? html`<span class=\"cal-event-pill-overflow\" aria-hidden=\"true\"\n >+${overflow} more</span\n >`\n : html``;\n\n return html`\n <div\n class=\"cal-events\"\n aria-label=\"${() => `${evts.length} event${evts.length > 1 ? 's' : ''}`}\">\n ${shown.map(\n (evt) => html`\n <ore-badge\n class=\"cal-event-pill\"\n size=\"xs\"\n rounded=\"sm\"\n aria-label=\"${evt.label}\"\n style=\"${styleMap({\n '--badge-bg': evt.color,\n '--badge-border-color': evt.color,\n })}\">\n ${evt.label}\n </ore-badge>\n `,\n )}\n ${overflowPill}\n </div>\n `;\n }\n\n return html`\n <div\n class=\"cal-dots\"\n aria-label=\"${() => `${evts.length} event${evts.length > 1 ? 's' : ''}`}\">\n ${shown.map(\n (evt) => html`\n <ore-badge\n class=\"cal-dot\"\n dot\n size=\"xs\"\n aria-hidden=\"true\"\n style=\"${styleMap({\n '--badge-bg': evt.color,\n '--badge-border-color': evt.color,\n })}\"></ore-badge>\n `,\n )}\n ${\n overflow > 0\n ? html`\n <span class=\"cal-dot-overflow\" aria-hidden=\"true\">+${overflow}</span>\n `\n : html``\n }\n </div>\n `;\n }}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n\n <!-- Month view -->\n <div\n class=\"cal-grid cal-grid-months\"\n role=\"grid\"\n aria-label=\"${() => displayYear_.value}\"\n ?hidden=\"${() => currentView.value !== 'month'}\">\n ${() => {\n const cells = monthCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 4) rows.push(cells.slice(i, i + 4));\n\n return rows.map(\n (row) => html`\n <div role=\"row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-month\"\n role=\"gridcell\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectMonth(cell.month)}\"\n @keydown=\"${(e: KeyboardEvent) =>\n handleGridKeydown(e, '.cal-cell-month', 4, () => handleSelectMonth(cell.month))}\">\n ${cell.shortLabel}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n\n <!-- Year view -->\n <div\n class=\"cal-grid cal-grid-years\"\n role=\"grid\"\n aria-label=\"Select year\"\n ?hidden=\"${() => currentView.value !== 'year'}\">\n ${() => {\n const cells = yearCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 4) rows.push(cells.slice(i, i + 4));\n\n return rows.map(\n (row) => html`\n <div role=\"row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-year\"\n role=\"gridcell\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectYear(cell.year)}\"\n @keydown=\"${(e: KeyboardEvent) =>\n handleGridKeydown(e, '.cal-cell-year', 4, () => handleSelectYear(cell.year))}\">\n ${String(cell.year)}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n </div>\n `;\n },\n shadow: { delegatesFocus: true },\n styles: [colorThemeMixin, reducedMotionMixin, componentStyles],\n});\n"],"mappings":"4XAkJA,IAAa,EAAe,eAGtB,EAAa,GAInB,EAAA,EAAA,OAAA,CAAyB,EAAc,CACrC,eAAgB,GAChB,MAAO,CACL,GAAG,EAAA,eACH,GAAG,EAAA,cACH,GAAG,EAAA,iBACH,GAAG,EAAA,gBACH,OAAQ,EAAA,KAAK,KAAK,CAAC,CAAoB,EACvC,SAAU,EAAA,KAAK,KAAK,EAAK,EACzB,UAAW,EAAA,KAAK,KAAK,EAAK,EAC1B,OAAQ,EAAA,KAAK,OAAO,EACpB,IAAK,EAAA,KAAK,OAAO,EACjB,IAAK,EAAA,KAAK,OAAO,EACjB,KAAM,EAAA,KAAK,OAAO,EAClB,SAAU,EAAA,KAAK,KAAK,EAAK,EACzB,MAAO,EAAA,KAAK,OAAO,EACnB,eAAgB,EAAA,KAAK,KAAK,CAAC,CAAa,CAC1C,EAEA,MAAM,EAAO,CACX,IAAM,GAAA,EAAO,EAAA,QAAA,CAA2B,EAIlC,GAAA,EAAa,EAAA,SAAA,KAAe,EAAM,SAAS,QAAU,EAAI,EACzD,GAAA,EAAa,EAAA,SAAA,KAAe,EAAM,SAAS,QAAU,EAAI,EAQzD,GAAA,EAAiB,EAAA,OAAA,CAA8C,IAAA,EAAS,EAExE,GAAA,EAAe,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;6CAIa,OAAO,EAAK,UAAU,EAAE;6CACxB,OAAO,EAAK,YAAc,EAAW,KAAK,EAAE;8CAC3C,EAAK,WAAW;8CAChB,EAAK,YAAc,EAAW,MAAM;wCACzC,EAAK,YAAc,EAAW,MAAQ,KAAO,IAAK;sCACrD,EAAiB,EAAK,IAAI,EAAE;oCAC/B,GACX,EAAkB,EAAG,iBAAkB,MAAS,EAAiB,EAAK,IAAI,CAAC,EAAE;0BAC7E,OAAO,EAAK,IAAI,EAAE;;qBAG1B,EAAE;;eAGR,CACF,EAAE;;;KAIV,EACA,OAAQ,CAAE,eAAgB,EAAK,EAC/B,OAAQ,CAAC,EAAA,gBAAiB,EAAA,mBAAoB,EAAA,OAAe,CAC/D,CAAC"}
|
|
1
|
+
{"version":3,"file":"calendar.cjs","names":[],"sources":["../src/inputs/calendar/calendar.ts"],"sourcesContent":["import { define, html, prop, bind, useEmit, styleMap } from '@vielzeug/ore';\nimport { useField } from '@vielzeug/ore';\nimport { computed, signal } from '@vielzeug/ripple';\nimport { Temporal, format } from '@vielzeug/tempo';\n\nimport type { ComponentSize, RoundedSize, ThemeColor } from '../../shared';\n\nimport '../../content/icon/icon';\nimport '../../feedback/badge/badge';\nimport { createDatePickerControl, parseIso, toIsoString, type DatePickerView } from '../../core';\nimport { disablableBundle, roundableBundle, sizableBundle, themableBundle } from '../../shared';\nimport { colorThemeMixin, reducedMotionMixin } from '../../styles';\nimport componentStyles from './calendar.css?inline';\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type OreCalendarEvents = {\n change: { isoValue: string | null };\n};\n\n/**\n * A calendar event entry.\n * Dates must be ISO 8601 strings (yyyy-MM-dd).\n *\n * The `color` field accepts any valid CSS color value (e.g. `'#e11d48'`,\n * `'var(--color-primary)'`). An invalid value silently falls back to the\n * component's theme color. Only pass values you control.\n */\nexport type CalendarEvent = {\n /**\n * Any CSS color value for the event dot / pill.\n * Defaults to the component's theme color when omitted.\n * Rendered via `styleMap()`, which strips `;`/`{`/`}` so the value can't break out of\n * its custom-property declaration — it is not a full CSS-color syntax validator, so an\n * invalid (but injection-safe) value may still render as no color.\n */\n color?: string;\n /** ISO date the event falls on (yyyy-MM-dd) */\n date: string;\n /** Unique identifier */\n id: string;\n /** Short label shown in the calendar cell */\n label: string;\n};\n\nexport type OreCalendarProps = {\n /** Theme color */\n color?: ThemeColor;\n /** Disable all date selection */\n disabled?: boolean;\n /**\n * Array of calendar events to display on day cells.\n * In normal mode each event renders as a small colored dot (max 3 dots, then \"+N\").\n * In expanded mode each event renders as a full-width colored pill with its label.\n * Pass as a JS property or as a JSON-encoded attribute.\n * @example\n * ```js\n * calendar.events = [\n * { id: '1', date: '2025-06-15', label: 'Team standup', color: 'var(--color-primary)' },\n * { id: '2', date: '2025-06-20', label: 'Release', color: '#e11d48' },\n * ];\n * ```\n */\n events?: CalendarEvent[];\n /**\n * Expanded layout — large cells with top-aligned day numbers suitable\n * for a full-page calendar app view.\n */\n expanded?: boolean;\n /** Expand to container width */\n fullwidth?: boolean;\n /** Locale for day/month names (default: browser locale) */\n locale?: string;\n /** Latest selectable date in ISO 8601 format (yyyy-MM-dd) */\n max?: string;\n /** Earliest selectable date in ISO 8601 format (yyyy-MM-dd) */\n min?: string;\n /** Form field name (when used inside a form) */\n name?: string;\n /** Mark field as required */\n required?: boolean;\n /** Border radius override */\n rounded?: RoundedSize;\n /** Component size */\n size?: ComponentSize;\n /**\n * Selected date in ISO 8601 format (yyyy-MM-dd).\n * @example '2025-06-15'\n */\n value?: string;\n /**\n * Day-of-week indices to disable (0 = Sunday … 6 = Saturday).\n * Pass as a JSON array attribute or a JS property.\n * @example\n * ```html\n * <ore-calendar weekend-days=\"[0,6]\"></ore-calendar>\n * ```\n */\n 'weekend-days'?: number[];\n};\n\n/**\n * An accessible, keyboard-navigable inline calendar component.\n * Supports day/month/year drill-down views, min/max bounds, disabled weekend\n * days, and optional form association.\n *\n * @element ore-calendar\n *\n * @attr {string} value - Selected date in ISO 8601 format (yyyy-MM-dd)\n * @attr {string} min - Minimum selectable date (yyyy-MM-dd)\n * @attr {string} max - Maximum selectable date (yyyy-MM-dd)\n * @attr {boolean} disabled - Disable all interaction\n * @attr {boolean} required - Required field (form association)\n * @attr {string} name - Form field name\n * @attr {string} color - Theme color: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'\n * @attr {string} size - Component size: 'sm' | 'md' | 'lg'\n * @attr {string} rounded - Border radius: 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full'\n * @attr {string} locale - BCP 47 locale string\n * @attr {string} weekend-days - JSON array of day indices to disable (0=Sun…6=Sat)\n * @attr {boolean} fullwidth - Expand to full container width\n * @attr {boolean} expanded - Large-cell calendar-app layout with top-aligned day numbers\n *\n * @fires change - Fired when a date is selected. detail: { isoValue: string | null }\n *\n * @cssprop --calendar-bg - Calendar background\n * @cssprop --calendar-border-color - Calendar border color\n * @cssprop --calendar-radius - Calendar border radius\n * @cssprop --calendar-shadow - Calendar drop shadow\n * @cssprop --calendar-day-selected-bg - Background of selected day cell\n * @cssprop --calendar-day-today-color - Colour of today's date number\n * @cssprop --calendar-day-outside-opacity - Opacity of days outside visible month\n *\n * @part calendar - The root calendar panel\n * @part header - Calendar header (nav + label)\n * @part grid - Day grid\n * @part day - Individual day cell\n *\n * @example\n * ```html\n * <!-- Single date with bounds -->\n * <ore-calendar value=\"2025-06-15\" min=\"2025-01-01\" max=\"2025-12-31\" color=\"primary\"></ore-calendar>\n *\n * <!-- Expanded calendar-app layout -->\n * <ore-calendar expanded fullwidth color=\"primary\"></ore-calendar>\n * ```\n */\nexport const CALENDAR_TAG = 'ore-calendar' as const;\n\n/** Maximum event dots/pills shown per cell before \"+N\" overflow */\nconst MAX_EVENTS = 3;\n\n// ── Component ────────────────────────────────────────────────────────────────\n\ndefine<OreCalendarProps>(CALENDAR_TAG, {\n formAssociated: true,\n props: {\n ...themableBundle,\n ...sizableBundle,\n ...disablableBundle,\n ...roundableBundle,\n events: prop.json([] as CalendarEvent[]),\n expanded: prop.bool(false),\n fullwidth: prop.bool(false),\n locale: prop.string(),\n max: prop.string(),\n min: prop.string(),\n name: prop.string(),\n required: prop.bool(false),\n value: prop.string(),\n 'weekend-days': prop.json([] as number[]),\n },\n\n setup(props) {\n const emit = useEmit<OreCalendarEvents>();\n\n // ── Derived flags ────────────────────────────────────────────────────────\n\n const isDisabled = computed(() => props.disabled.value === true);\n const isExpanded = computed(() => props.expanded.value === true);\n\n // ── Selected date: local-override pattern ─────────────────────────────────\n // `localSelection` holds a user-initiated pick (or undefined = no override).\n // `selectedDate` derives from it, falling back to the value prop reactively.\n // This eliminates setInterval polling — external prop changes propagate\n // through the computed graph automatically.\n\n const localSelection = signal<Temporal.PlainDate | null | undefined>(undefined);\n\n const selectedDate = computed(() =>\n localSelection.value !== undefined ? localSelection.value : parseIso(props.value.value),\n );\n\n // ── Date-picker control ──────────────────────────────────────────────────\n\n const ctrl = createDatePickerControl({\n get locale() {\n return props.locale.value ?? (typeof navigator !== 'undefined' ? navigator.language : 'en');\n },\n get max() {\n return parseIso(props.max.value);\n },\n get min() {\n return parseIso(props.min.value);\n },\n onChange(date) {\n localSelection.value = date;\n currentView.value = 'day';\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n emit('change', { isoValue: toIsoString(date) });\n },\n get value() {\n return selectedDate.value;\n },\n get weekendDays() {\n return props['weekend-days'].value ?? [];\n },\n });\n\n // ── Reactive display state ────────────────────────────────────────────────\n // Three separate primitive signals — the proven pattern. Mutating any one\n // of them invalidates only the computeds that read it.\n\n const currentView = signal<DatePickerView>('day');\n const displayYear = signal(ctrl.displayYear());\n const displayMonth = signal(ctrl.displayMonth()); // 1-indexed (Temporal)\n\n // ── Form value ───────────────────────────────────────────────────────────\n\n useField<string>({\n disabled: isDisabled,\n toFormValue: (v) => v || null,\n value: computed(() => toIsoString(selectedDate.value) ?? ''),\n });\n\n // ── Events lookup ─────────────────────────────────────────────────────────\n\n const eventsByDate = computed(() => {\n const map = new Map<string, CalendarEvent[]>();\n\n for (const evt of props.events.value ?? []) {\n const list = map.get(evt.date) ?? [];\n\n list.push(evt);\n map.set(evt.date, list);\n }\n\n return map;\n });\n\n // ── Derived cells ─────────────────────────────────────────────────────────\n // Each reads a display signal so they re-run when navigation changes.\n\n const dayCells = computed(() => {\n void displayYear.value;\n void displayMonth.value;\n void selectedDate.value; // re-run when selection changes to refresh isSelected flags\n\n return ctrl.dayCells();\n });\n const monthCells = computed(() => {\n void displayYear.value;\n\n return ctrl.monthCells();\n });\n const yearCells = computed(() => {\n void displayYear.value;\n\n return ctrl.yearCells();\n });\n const weekdayLabels = computed(() => ctrl.weekdayLabels());\n\n const displayMonth_ = computed(() => {\n const d = Temporal.PlainDate.from({ day: 1, month: displayMonth.value, year: displayYear.value });\n const loc = props.locale.value ?? (typeof navigator !== 'undefined' ? navigator.language : 'en');\n\n return format(d, { intl: { month: 'long' }, locale: loc, timeZone: 'UTC' });\n });\n\n const displayYear_ = computed(() => String(displayYear.value));\n const displayLabel = computed(() => `${displayMonth_.value} ${displayYear_.value}`);\n\n // ── Navigation ───────────────────────────────────────────────────────────\n\n function handlePrev(): void {\n if (currentView.value === 'day') ctrl.prevMonth();\n else ctrl.prevYear();\n\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n }\n\n function handleNext(): void {\n if (currentView.value === 'day') ctrl.nextMonth();\n else ctrl.nextYear();\n\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n }\n\n function handleHeaderClick(): void {\n const views: DatePickerView[] = ['day', 'month', 'year'];\n const next = views[(views.indexOf(currentView.value) + 1) % views.length];\n\n ctrl.setView(next);\n currentView.value = next;\n }\n\n // ── Selection handlers — all disabled guards live here ────────────────────\n\n function handleSelectMonth(month: number): void {\n if (isDisabled.value) return;\n\n ctrl.goTo(ctrl.displayYear(), month);\n ctrl.setView('day');\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n currentView.value = 'day';\n }\n\n function handleSelectYear(year: number): void {\n if (isDisabled.value) return;\n\n ctrl.goTo(year, ctrl.displayMonth());\n ctrl.setView('month');\n displayYear.value = ctrl.displayYear();\n currentView.value = 'month';\n }\n\n function handleSelectDay(isoStr: string): void {\n if (isDisabled.value) return;\n\n const date = parseIso(isoStr);\n\n if (!date) return;\n\n ctrl.select(date); // ctrl.select() internally rejects disabled/out-of-range dates\n }\n\n // ── Day-cell keyboard navigation (full ARIA grid pattern) ─────────────────\n\n function handleDayKeydown(e: KeyboardEvent): void {\n const cell = e.currentTarget as HTMLElement;\n const grid = cell.closest('.cal-grid-days');\n\n if (!grid) return;\n\n const allCells = Array.from(grid.querySelectorAll<HTMLElement>('.cal-cell-day'));\n const idx = allCells.indexOf(cell);\n\n if (idx === -1) return;\n\n let target: HTMLElement | undefined;\n\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n handleSelectDay(cell.dataset.iso ?? '');\n\n return;\n } else if (e.key === 'ArrowRight') {\n target = allCells[idx + 1];\n } else if (e.key === 'ArrowLeft') {\n target = allCells[idx - 1];\n } else if (e.key === 'ArrowDown') {\n target = allCells[idx + 7];\n } else if (e.key === 'ArrowUp') {\n target = allCells[idx - 7];\n } else if (e.key === 'Home') {\n target = allCells[Math.floor(idx / 7) * 7]; // first cell in same row\n } else if (e.key === 'End') {\n target = allCells[Math.floor(idx / 7) * 7 + 6]; // last cell in same row\n } else {\n return;\n }\n\n e.preventDefault();\n target?.focus();\n }\n\n // ── Month/year-cell keyboard navigation (fixed 4-column grid) ─────────────\n\n function handleGridKeydown(e: KeyboardEvent, cellSelector: string, columns: number, onSelect: () => void): void {\n const cell = e.currentTarget as HTMLElement;\n const grid = cell.closest('.cal-grid');\n\n if (!grid) return;\n\n const allCells = Array.from(grid.querySelectorAll<HTMLElement>(cellSelector));\n const idx = allCells.indexOf(cell);\n\n if (idx === -1) return;\n\n let target: HTMLElement | undefined;\n\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onSelect();\n\n return;\n } else if (e.key === 'ArrowRight') {\n target = allCells[idx + 1];\n } else if (e.key === 'ArrowLeft') {\n target = allCells[idx - 1];\n } else if (e.key === 'ArrowDown') {\n target = allCells[idx + columns];\n } else if (e.key === 'ArrowUp') {\n target = allCells[idx - columns];\n } else if (e.key === 'Home') {\n target = allCells[Math.floor(idx / columns) * columns];\n } else if (e.key === 'End') {\n target = allCells[Math.min(Math.floor(idx / columns) * columns + columns - 1, allCells.length - 1)];\n } else {\n return;\n }\n\n e.preventDefault();\n target?.focus();\n }\n\n // ── Host bindings ────────────────────────────────────────────────────────\n\n bind({\n attr: {\n 'aria-disabled': () => (isDisabled.value ? 'true' : null),\n 'aria-label': () => displayLabel.value,\n role: 'group',\n },\n class: {\n 'is-disabled': isDisabled,\n },\n });\n\n // ── Template ─────────────────────────────────────────────────────────────\n\n return html`\n <div class=\"calendar\" part=\"calendar\" role=\"presentation\">\n <!-- Header -->\n <div class=\"cal-header\" part=\"header\">\n <button class=\"nav-btn\" type=\"button\" aria-label=\"Previous\" ?disabled=\"${isDisabled}\" @click=\"${handlePrev}\">\n <ore-icon name=\"chevron-left\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </button>\n\n <button\n class=\"cal-label-btn\"\n type=\"button\"\n aria-label=\"${() =>\n `Switch to ${currentView.value === 'day' ? 'month' : currentView.value === 'month' ? 'year' : 'day'} view`}\"\n ?disabled=\"${isDisabled}\"\n @click=\"${handleHeaderClick}\">\n <span class=\"cal-label-month\">${displayMonth_}</span>\n <span class=\"cal-label-sep\" aria-hidden=\"true\">/</span>\n <span class=\"cal-label-year\">${displayYear_}</span>\n </button>\n\n <button class=\"nav-btn\" type=\"button\" aria-label=\"Next\" ?disabled=\"${isDisabled}\" @click=\"${handleNext}\">\n <ore-icon name=\"chevron-right\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </button>\n </div>\n\n <!-- Day view -->\n <div\n class=\"cal-grid cal-grid-days\"\n role=\"grid\"\n part=\"grid\"\n aria-label=\"${() => displayLabel.value}\"\n ?hidden=\"${() => currentView.value !== 'day'}\">\n <div role=\"row\" class=\"cal-grid-row\">\n ${() =>\n weekdayLabels.value.map(\n (lbl) => html`\n <div class=\"cal-cell cal-cell-head\" role=\"columnheader\" aria-label=\"${lbl}\">${lbl}</div>\n `,\n )}\n </div>\n ${() => {\n const cells = dayCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 7) rows.push(cells.slice(i, i + 7));\n\n return rows.map(\n (row) => html`\n <div role=\"row\" class=\"cal-grid-row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-day\"\n role=\"gridcell\"\n part=\"day\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n aria-current=\"${() => (cell.isToday ? 'date' : null)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-today=\"${() => cell.isToday}\"\n ?data-outside=\"${() => cell.isOutsideMonth}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n data-iso=\"${cell.iso}\"\n data-day=\"${String(cell.day)}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectDay(cell.iso)}\"\n @keydown=\"${handleDayKeydown}\">\n ${String(cell.day)}\n ${() => {\n const evts = eventsByDate.value.get(cell.iso) ?? [];\n\n if (!evts.length) return html``;\n\n const shown = evts.slice(0, MAX_EVENTS);\n const overflow = evts.length - MAX_EVENTS;\n\n if (isExpanded.value) {\n // Text node is written tag-tight (no inner line breaks) — this custom\n // `html` tagged template does not collapse whitespace at runtime like a\n // browser parser would, so a pretty-printed multi-line `<span>...</span>`\n // here would render literal newlines/indentation into `textContent`.\n // prettier-ignore\n const overflowPill = overflow > 0\n ? html`<span class=\"cal-event-pill-overflow\" aria-hidden=\"true\"\n >+${overflow} more</span\n >`\n : html``;\n\n return html`\n <div\n class=\"cal-events\"\n aria-label=\"${() => `${evts.length} event${evts.length > 1 ? 's' : ''}`}\">\n ${shown.map(\n (evt) => html`\n <ore-badge\n class=\"cal-event-pill\"\n size=\"xs\"\n rounded=\"sm\"\n aria-label=\"${evt.label}\"\n style=\"${styleMap({\n '--badge-bg': evt.color,\n '--badge-border-color': evt.color,\n })}\">\n ${evt.label}\n </ore-badge>\n `,\n )}\n ${overflowPill}\n </div>\n `;\n }\n\n return html`\n <div\n class=\"cal-dots\"\n aria-label=\"${() => `${evts.length} event${evts.length > 1 ? 's' : ''}`}\">\n ${shown.map(\n (evt) => html`\n <ore-badge\n class=\"cal-dot\"\n dot\n size=\"xs\"\n aria-hidden=\"true\"\n style=\"${styleMap({\n '--badge-bg': evt.color,\n '--badge-border-color': evt.color,\n })}\"></ore-badge>\n `,\n )}\n ${\n overflow > 0\n ? html`\n <span class=\"cal-dot-overflow\" aria-hidden=\"true\">+${overflow}</span>\n `\n : html``\n }\n </div>\n `;\n }}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n\n <!-- Month view -->\n <div\n class=\"cal-grid cal-grid-months\"\n role=\"grid\"\n aria-label=\"${() => displayYear_.value}\"\n ?hidden=\"${() => currentView.value !== 'month'}\">\n ${() => {\n const cells = monthCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 4) rows.push(cells.slice(i, i + 4));\n\n return rows.map(\n (row) => html`\n <div role=\"row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-month\"\n role=\"gridcell\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectMonth(cell.month)}\"\n @keydown=\"${(e: KeyboardEvent) =>\n handleGridKeydown(e, '.cal-cell-month', 4, () => handleSelectMonth(cell.month))}\">\n ${cell.shortLabel}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n\n <!-- Year view -->\n <div\n class=\"cal-grid cal-grid-years\"\n role=\"grid\"\n aria-label=\"Select year\"\n ?hidden=\"${() => currentView.value !== 'year'}\">\n ${() => {\n const cells = yearCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 4) rows.push(cells.slice(i, i + 4));\n\n return rows.map(\n (row) => html`\n <div role=\"row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-year\"\n role=\"gridcell\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectYear(cell.year)}\"\n @keydown=\"${(e: KeyboardEvent) =>\n handleGridKeydown(e, '.cal-cell-year', 4, () => handleSelectYear(cell.year))}\">\n ${String(cell.year)}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n </div>\n `;\n },\n shadow: { delegatesFocus: true },\n styles: [colorThemeMixin, reducedMotionMixin, componentStyles],\n});\n"],"mappings":"4XAkJA,IAAa,EAAe,eAGtB,EAAa,GAInB,EAAA,EAAA,OAAA,CAAyB,EAAc,CACrC,eAAgB,GAChB,MAAO,CACL,GAAG,EAAA,eACH,GAAG,EAAA,cACH,GAAG,EAAA,iBACH,GAAG,EAAA,gBACH,OAAQ,EAAA,KAAK,KAAK,CAAC,CAAoB,EACvC,SAAU,EAAA,KAAK,KAAK,EAAK,EACzB,UAAW,EAAA,KAAK,KAAK,EAAK,EAC1B,OAAQ,EAAA,KAAK,OAAO,EACpB,IAAK,EAAA,KAAK,OAAO,EACjB,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kB,EAAK,KAAK,EAAE;oCACjC,GACX,EAAkB,EAAG,kBAAmB,MAAS,EAAkB,EAAK,KAAK,CAAC,EAAE;0BAChF,EAAK,WAAW;;qBAGxB,EAAE;;eAGR,CACF,EAAE;;;;;;;;yBAQe,EAAY,QAAU,OAAO;gBACtC,CACN,IAAM,EAAQ,EAAU,MAClB,EAAmC,CAAC,EAE1C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,GAAK,EAAG,EAAK,KAAK,EAAM,MAAM,EAAG,EAAI,CAAC,CAAC,EAEzE,OAAO,EAAK,IACT,GAAQ,EAAA,IAAI;;oBAEP,EAAI,IACH,GAAS,EAAA,IAAI;;;;6CAIa,OAAO,EAAK,UAAU,EAAE;6CACxB,OAAO,EAAK,YAAc,EAAW,KAAK,EAAE;8CAC3C,EAAK,WAAW;8CAChB,EAAK,YAAc,EAAW,MAAM;wCACzC,EAAK,YAAc,EAAW,MAAQ,KAAO,IAAK;sCACrD,EAAiB,EAAK,IAAI,EAAE;oCAC/B,GACX,EAAkB,EAAG,iBAAkB,MAAS,EAAiB,EAAK,IAAI,CAAC,EAAE;0BAC7E,OAAO,EAAK,IAAI,EAAE;;qBAG1B,EAAE;;eAGR,CACF,EAAE;;;KAIV,EACA,OAAQ,CAAE,eAAgB,EAAK,EAC/B,OAAQ,CAAC,EAAA,gBAAiB,EAAA,mBAAoB,EAAA,OAAe,CAC/D,CAAC"}
|
package/dist/calendar.js
CHANGED
package/dist/calendar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","names":[],"sources":["../src/inputs/calendar/calendar.ts"],"sourcesContent":["import { define, html, prop, bind, useEmit, styleMap } from '@vielzeug/ore';\nimport { useField } from '@vielzeug/ore';\nimport { computed, signal } from '@vielzeug/ripple';\nimport { Temporal, format } from '@vielzeug/tempo';\n\nimport type { ComponentSize, RoundedSize, ThemeColor } from '../../shared';\n\nimport '../../content/icon/icon';\nimport '../../feedback/badge/badge';\nimport { createDatePickerControl, parseIso, toIsoString, type DatePickerView } from '../../core';\nimport { disablableBundle, roundableBundle, sizableBundle, themableBundle } from '../../shared';\nimport { colorThemeMixin, reducedMotionMixin } from '../../styles';\nimport componentStyles from './calendar.css?inline';\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type OreCalendarEvents = {\n change: { isoValue: string | null };\n};\n\n/**\n * A calendar event entry.\n * Dates must be ISO 8601 strings (yyyy-MM-dd).\n *\n * The `color` field accepts any valid CSS color value (e.g. `'#e11d48'`,\n * `'var(--color-primary)'`). An invalid value silently falls back to the\n * component's theme color. Only pass values you control.\n */\nexport type CalendarEvent = {\n /**\n * Any CSS color value for the event dot / pill.\n * Defaults to the component's theme color when omitted.\n * Rendered via `styleMap()`, which strips `;`/`{`/`}` so the value can't break out of\n * its custom-property declaration — it is not a full CSS-color syntax validator, so an\n * invalid (but injection-safe) value may still render as no color.\n */\n color?: string;\n /** ISO date the event falls on (yyyy-MM-dd) */\n date: string;\n /** Unique identifier */\n id: string;\n /** Short label shown in the calendar cell */\n label: string;\n};\n\nexport type OreCalendarProps = {\n /** Theme color */\n color?: ThemeColor;\n /** Disable all date selection */\n disabled?: boolean;\n /**\n * Array of calendar events to display on day cells.\n * In normal mode each event renders as a small colored dot (max 3 dots, then \"+N\").\n * In expanded mode each event renders as a full-width colored pill with its label.\n * Pass as a JS property or as a JSON-encoded attribute.\n * @example\n * ```js\n * calendar.events = [\n * { id: '1', date: '2025-06-15', label: 'Team standup', color: 'var(--color-primary)' },\n * { id: '2', date: '2025-06-20', label: 'Release', color: '#e11d48' },\n * ];\n * ```\n */\n events?: CalendarEvent[];\n /**\n * Expanded layout — large cells with top-aligned day numbers suitable\n * for a full-page calendar app view.\n */\n expanded?: boolean;\n /** Expand to container width */\n fullwidth?: boolean;\n /** Locale for day/month names (default: browser locale) */\n locale?: string;\n /** Latest selectable date in ISO 8601 format (yyyy-MM-dd) */\n max?: string;\n /** Earliest selectable date in ISO 8601 format (yyyy-MM-dd) */\n min?: string;\n /** Form field name (when used inside a form) */\n name?: string;\n /** Mark field as required */\n required?: boolean;\n /** Border radius override */\n rounded?: RoundedSize;\n /** Component size */\n size?: ComponentSize;\n /**\n * Selected date in ISO 8601 format (yyyy-MM-dd).\n * @example '2025-06-15'\n */\n value?: string;\n /**\n * Day-of-week indices to disable (0 = Sunday … 6 = Saturday).\n * Pass as a JSON array attribute or a JS property.\n * @example\n * ```html\n * <ore-calendar weekend-days=\"[0,6]\"></ore-calendar>\n * ```\n */\n 'weekend-days'?: number[];\n};\n\n/**\n * An accessible, keyboard-navigable inline calendar component.\n * Supports day/month/year drill-down views, min/max bounds, disabled weekend\n * days, and optional form association.\n *\n * @element ore-calendar\n *\n * @attr {string} value - Selected date in ISO 8601 format (yyyy-MM-dd)\n * @attr {string} min - Minimum selectable date (yyyy-MM-dd)\n * @attr {string} max - Maximum selectable date (yyyy-MM-dd)\n * @attr {boolean} disabled - Disable all interaction\n * @attr {boolean} required - Required field (form association)\n * @attr {string} name - Form field name\n * @attr {string} color - Theme color: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'\n * @attr {string} size - Component size: 'sm' | 'md' | 'lg'\n * @attr {string} rounded - Border radius: 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full'\n * @attr {string} locale - BCP 47 locale string\n * @attr {string} weekend-days - JSON array of day indices to disable (0=Sun…6=Sat)\n * @attr {boolean} fullwidth - Expand to full container width\n * @attr {boolean} expanded - Large-cell calendar-app layout with top-aligned day numbers\n *\n * @fires change - Fired when a date is selected. detail: { isoValue: string | null }\n *\n * @cssprop --calendar-bg - Calendar background\n * @cssprop --calendar-border-color - Calendar border color\n * @cssprop --calendar-radius - Calendar border radius\n * @cssprop --calendar-shadow - Calendar drop shadow\n * @cssprop --calendar-day-selected-bg - Background of selected day cell\n * @cssprop --calendar-day-today-color - Colour of today's date number\n * @cssprop --calendar-day-outside-opacity - Opacity of days outside visible month\n *\n * @part calendar - The root calendar panel\n * @part header - Calendar header (nav + label)\n * @part grid - Day grid\n * @part day - Individual day cell\n *\n * @example\n * ```html\n * <!-- Single date with bounds -->\n * <ore-calendar value=\"2025-06-15\" min=\"2025-01-01\" max=\"2025-12-31\" color=\"primary\"></ore-calendar>\n *\n * <!-- Expanded calendar-app layout -->\n * <ore-calendar expanded fullwidth color=\"primary\"></ore-calendar>\n * ```\n */\nexport const CALENDAR_TAG = 'ore-calendar' as const;\n\n/** Maximum event dots/pills shown per cell before \"+N\" overflow */\nconst MAX_EVENTS = 3;\n\n// ── Component ────────────────────────────────────────────────────────────────\n\ndefine<OreCalendarProps>(CALENDAR_TAG, {\n formAssociated: true,\n props: {\n ...themableBundle,\n ...sizableBundle,\n ...disablableBundle,\n ...roundableBundle,\n events: prop.json([] as CalendarEvent[]),\n expanded: prop.bool(false),\n fullwidth: prop.bool(false),\n locale: prop.string(),\n max: prop.string(),\n min: prop.string(),\n name: prop.string(),\n required: prop.bool(false),\n value: prop.string(),\n 'weekend-days': prop.json([] as number[]),\n },\n\n setup(props) {\n const emit = useEmit<OreCalendarEvents>();\n\n // ── Derived flags ────────────────────────────────────────────────────────\n\n const isDisabled = computed(() => props.disabled.value === true);\n const isExpanded = computed(() => props.expanded.value === true);\n\n // ── Selected date: local-override pattern ─────────────────────────────────\n // `localSelection` holds a user-initiated pick (or undefined = no override).\n // `selectedDate` derives from it, falling back to the value prop reactively.\n // This eliminates setInterval polling — external prop changes propagate\n // through the computed graph automatically.\n\n const localSelection = signal<Temporal.PlainDate | null | undefined>(undefined);\n\n const selectedDate = computed(() =>\n localSelection.value !== undefined ? localSelection.value : parseIso(props.value.value),\n );\n\n // ── Date-picker control ──────────────────────────────────────────────────\n\n const ctrl = createDatePickerControl({\n get locale() {\n return props.locale.value ?? (typeof navigator !== 'undefined' ? navigator.language : 'en');\n },\n get max() {\n return parseIso(props.max.value);\n },\n get min() {\n return parseIso(props.min.value);\n },\n onChange(date) {\n localSelection.value = date;\n currentView.value = 'day';\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n emit('change', { isoValue: toIsoString(date) });\n },\n get value() {\n return selectedDate.value;\n },\n get weekendDays() {\n return props['weekend-days'].value ?? [];\n },\n });\n\n // ── Reactive display state ────────────────────────────────────────────────\n // Three separate primitive signals — the proven pattern. Mutating any one\n // of them invalidates only the computeds that read it.\n\n const currentView = signal<DatePickerView>('day');\n const displayYear = signal(ctrl.displayYear());\n const displayMonth = signal(ctrl.displayMonth()); // 1-indexed (Temporal)\n\n // ── Form value ───────────────────────────────────────────────────────────\n\n useField<string>({\n disabled: isDisabled,\n toFormValue: (v) => v || null,\n value: computed(() => toIsoString(selectedDate.value) ?? ''),\n });\n\n // ── Events lookup ─────────────────────────────────────────────────────────\n\n const eventsByDate = computed(() => {\n const map = new Map<string, CalendarEvent[]>();\n\n for (const evt of props.events.value ?? []) {\n const list = map.get(evt.date) ?? [];\n\n list.push(evt);\n map.set(evt.date, list);\n }\n\n return map;\n });\n\n // ── Derived cells ─────────────────────────────────────────────────────────\n // Each reads a display signal so they re-run when navigation changes.\n\n const dayCells = computed(() => {\n void displayYear.value;\n void displayMonth.value;\n void selectedDate.value; // re-run when selection changes to refresh isSelected flags\n\n return ctrl.dayCells();\n });\n const monthCells = computed(() => {\n void displayYear.value;\n\n return ctrl.monthCells();\n });\n const yearCells = computed(() => {\n void displayYear.value;\n\n return ctrl.yearCells();\n });\n const weekdayLabels = computed(() => ctrl.weekdayLabels());\n\n const displayMonth_ = computed(() => {\n const d = Temporal.PlainDate.from({ day: 1, month: displayMonth.value, year: displayYear.value });\n const loc = props.locale.value ?? (typeof navigator !== 'undefined' ? navigator.language : 'en');\n\n return format(d, { intl: { month: 'long' }, locale: loc, tz: 'UTC' });\n });\n\n const displayYear_ = computed(() => String(displayYear.value));\n const displayLabel = computed(() => `${displayMonth_.value} ${displayYear_.value}`);\n\n // ── Navigation ───────────────────────────────────────────────────────────\n\n function handlePrev(): void {\n if (currentView.value === 'day') ctrl.prevMonth();\n else ctrl.prevYear();\n\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n }\n\n function handleNext(): void {\n if (currentView.value === 'day') ctrl.nextMonth();\n else ctrl.nextYear();\n\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n }\n\n function handleHeaderClick(): void {\n const views: DatePickerView[] = ['day', 'month', 'year'];\n const next = views[(views.indexOf(currentView.value) + 1) % views.length];\n\n ctrl.setView(next);\n currentView.value = next;\n }\n\n // ── Selection handlers — all disabled guards live here ────────────────────\n\n function handleSelectMonth(month: number): void {\n if (isDisabled.value) return;\n\n ctrl.goTo(ctrl.displayYear(), month);\n ctrl.setView('day');\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n currentView.value = 'day';\n }\n\n function handleSelectYear(year: number): void {\n if (isDisabled.value) return;\n\n ctrl.goTo(year, ctrl.displayMonth());\n ctrl.setView('month');\n displayYear.value = ctrl.displayYear();\n currentView.value = 'month';\n }\n\n function handleSelectDay(isoStr: string): void {\n if (isDisabled.value) return;\n\n const date = parseIso(isoStr);\n\n if (!date) return;\n\n ctrl.select(date); // ctrl.select() internally rejects disabled/out-of-range dates\n }\n\n // ── Day-cell keyboard navigation (full ARIA grid pattern) ─────────────────\n\n function handleDayKeydown(e: KeyboardEvent): void {\n const cell = e.currentTarget as HTMLElement;\n const grid = cell.closest('.cal-grid-days');\n\n if (!grid) return;\n\n const allCells = Array.from(grid.querySelectorAll<HTMLElement>('.cal-cell-day'));\n const idx = allCells.indexOf(cell);\n\n if (idx === -1) return;\n\n let target: HTMLElement | undefined;\n\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n handleSelectDay(cell.dataset.iso ?? '');\n\n return;\n } else if (e.key === 'ArrowRight') {\n target = allCells[idx + 1];\n } else if (e.key === 'ArrowLeft') {\n target = allCells[idx - 1];\n } else if (e.key === 'ArrowDown') {\n target = allCells[idx + 7];\n } else if (e.key === 'ArrowUp') {\n target = allCells[idx - 7];\n } else if (e.key === 'Home') {\n target = allCells[Math.floor(idx / 7) * 7]; // first cell in same row\n } else if (e.key === 'End') {\n target = allCells[Math.floor(idx / 7) * 7 + 6]; // last cell in same row\n } else {\n return;\n }\n\n e.preventDefault();\n target?.focus();\n }\n\n // ── Month/year-cell keyboard navigation (fixed 4-column grid) ─────────────\n\n function handleGridKeydown(e: KeyboardEvent, cellSelector: string, columns: number, onSelect: () => void): void {\n const cell = e.currentTarget as HTMLElement;\n const grid = cell.closest('.cal-grid');\n\n if (!grid) return;\n\n const allCells = Array.from(grid.querySelectorAll<HTMLElement>(cellSelector));\n const idx = allCells.indexOf(cell);\n\n if (idx === -1) return;\n\n let target: HTMLElement | undefined;\n\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onSelect();\n\n return;\n } else if (e.key === 'ArrowRight') {\n target = allCells[idx + 1];\n } else if (e.key === 'ArrowLeft') {\n target = allCells[idx - 1];\n } else if (e.key === 'ArrowDown') {\n target = allCells[idx + columns];\n } else if (e.key === 'ArrowUp') {\n target = allCells[idx - columns];\n } else if (e.key === 'Home') {\n target = allCells[Math.floor(idx / columns) * columns];\n } else if (e.key === 'End') {\n target = allCells[Math.min(Math.floor(idx / columns) * columns + columns - 1, allCells.length - 1)];\n } else {\n return;\n }\n\n e.preventDefault();\n target?.focus();\n }\n\n // ── Host bindings ────────────────────────────────────────────────────────\n\n bind({\n attr: {\n 'aria-disabled': () => (isDisabled.value ? 'true' : null),\n 'aria-label': () => displayLabel.value,\n role: 'group',\n },\n class: {\n 'is-disabled': isDisabled,\n },\n });\n\n // ── Template ─────────────────────────────────────────────────────────────\n\n return html`\n <div class=\"calendar\" part=\"calendar\" role=\"presentation\">\n <!-- Header -->\n <div class=\"cal-header\" part=\"header\">\n <button class=\"nav-btn\" type=\"button\" aria-label=\"Previous\" ?disabled=\"${isDisabled}\" @click=\"${handlePrev}\">\n <ore-icon name=\"chevron-left\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </button>\n\n <button\n class=\"cal-label-btn\"\n type=\"button\"\n aria-label=\"${() =>\n `Switch to ${currentView.value === 'day' ? 'month' : currentView.value === 'month' ? 'year' : 'day'} view`}\"\n ?disabled=\"${isDisabled}\"\n @click=\"${handleHeaderClick}\">\n <span class=\"cal-label-month\">${displayMonth_}</span>\n <span class=\"cal-label-sep\" aria-hidden=\"true\">/</span>\n <span class=\"cal-label-year\">${displayYear_}</span>\n </button>\n\n <button class=\"nav-btn\" type=\"button\" aria-label=\"Next\" ?disabled=\"${isDisabled}\" @click=\"${handleNext}\">\n <ore-icon name=\"chevron-right\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </button>\n </div>\n\n <!-- Day view -->\n <div\n class=\"cal-grid cal-grid-days\"\n role=\"grid\"\n part=\"grid\"\n aria-label=\"${() => displayLabel.value}\"\n ?hidden=\"${() => currentView.value !== 'day'}\">\n <div role=\"row\" class=\"cal-grid-row\">\n ${() =>\n weekdayLabels.value.map(\n (lbl) => html`\n <div class=\"cal-cell cal-cell-head\" role=\"columnheader\" aria-label=\"${lbl}\">${lbl}</div>\n `,\n )}\n </div>\n ${() => {\n const cells = dayCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 7) rows.push(cells.slice(i, i + 7));\n\n return rows.map(\n (row) => html`\n <div role=\"row\" class=\"cal-grid-row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-day\"\n role=\"gridcell\"\n part=\"day\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n aria-current=\"${() => (cell.isToday ? 'date' : null)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-today=\"${() => cell.isToday}\"\n ?data-outside=\"${() => cell.isOutsideMonth}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n data-iso=\"${cell.iso}\"\n data-day=\"${String(cell.day)}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectDay(cell.iso)}\"\n @keydown=\"${handleDayKeydown}\">\n ${String(cell.day)}\n ${() => {\n const evts = eventsByDate.value.get(cell.iso) ?? [];\n\n if (!evts.length) return html``;\n\n const shown = evts.slice(0, MAX_EVENTS);\n const overflow = evts.length - MAX_EVENTS;\n\n if (isExpanded.value) {\n // Text node is written tag-tight (no inner line breaks) — this custom\n // `html` tagged template does not collapse whitespace at runtime like a\n // browser parser would, so a pretty-printed multi-line `<span>...</span>`\n // here would render literal newlines/indentation into `textContent`.\n // prettier-ignore\n const overflowPill = overflow > 0\n ? html`<span class=\"cal-event-pill-overflow\" aria-hidden=\"true\"\n >+${overflow} more</span\n >`\n : html``;\n\n return html`\n <div\n class=\"cal-events\"\n aria-label=\"${() => `${evts.length} event${evts.length > 1 ? 's' : ''}`}\">\n ${shown.map(\n (evt) => html`\n <ore-badge\n class=\"cal-event-pill\"\n size=\"xs\"\n rounded=\"sm\"\n aria-label=\"${evt.label}\"\n style=\"${styleMap({\n '--badge-bg': evt.color,\n '--badge-border-color': evt.color,\n })}\">\n ${evt.label}\n </ore-badge>\n `,\n )}\n ${overflowPill}\n </div>\n `;\n }\n\n return html`\n <div\n class=\"cal-dots\"\n aria-label=\"${() => `${evts.length} event${evts.length > 1 ? 's' : ''}`}\">\n ${shown.map(\n (evt) => html`\n <ore-badge\n class=\"cal-dot\"\n dot\n size=\"xs\"\n aria-hidden=\"true\"\n style=\"${styleMap({\n '--badge-bg': evt.color,\n '--badge-border-color': evt.color,\n })}\"></ore-badge>\n `,\n )}\n ${\n overflow > 0\n ? html`\n <span class=\"cal-dot-overflow\" aria-hidden=\"true\">+${overflow}</span>\n `\n : html``\n }\n </div>\n `;\n }}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n\n <!-- Month view -->\n <div\n class=\"cal-grid cal-grid-months\"\n role=\"grid\"\n aria-label=\"${() => displayYear_.value}\"\n ?hidden=\"${() => currentView.value !== 'month'}\">\n ${() => {\n const cells = monthCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 4) rows.push(cells.slice(i, i + 4));\n\n return rows.map(\n (row) => html`\n <div role=\"row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-month\"\n role=\"gridcell\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectMonth(cell.month)}\"\n @keydown=\"${(e: KeyboardEvent) =>\n handleGridKeydown(e, '.cal-cell-month', 4, () => handleSelectMonth(cell.month))}\">\n ${cell.shortLabel}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n\n <!-- Year view -->\n <div\n class=\"cal-grid cal-grid-years\"\n role=\"grid\"\n aria-label=\"Select year\"\n ?hidden=\"${() => currentView.value !== 'year'}\">\n ${() => {\n const cells = yearCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 4) rows.push(cells.slice(i, i + 4));\n\n return rows.map(\n (row) => html`\n <div role=\"row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-year\"\n role=\"gridcell\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectYear(cell.year)}\"\n @keydown=\"${(e: KeyboardEvent) =>\n handleGridKeydown(e, '.cal-cell-year', 4, () => handleSelectYear(cell.year))}\">\n ${String(cell.year)}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n </div>\n `;\n },\n shadow: { delegatesFocus: true },\n styles: [colorThemeMixin, reducedMotionMixin, componentStyles],\n});\n"],"mappings":";;;;;;;;;AAkJA,IAAa,IAAe,gBAGtB,IAAa;AAInB,EAAyB,GAAc;CACrC,gBAAgB;CAChB,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,QAAQ,EAAK,KAAK,CAAC,CAAoB;EACvC,UAAU,EAAK,KAAK,EAAK;EACzB,WAAW,EAAK,KAAK,EAAK;EAC1B,QAAQ,EAAK,OAAO;EACpB,KAAK,EAAK,OAAO;EACjB,KAAK,EAAK,OAAO;EACjB,MAAM,EAAK,OAAO;EAClB,UAAU,EAAK,KAAK,EAAK;EACzB,OAAO,EAAK,OAAO;EACnB,gBAAgB,EAAK,KAAK,CAAC,CAAa;CAC1C;CAEA,MAAM,GAAO;EACX,IAAM,IAAO,EAA2B,GAIlC,IAAa,QAAe,EAAM,SAAS,UAAU,EAAI,GACzD,IAAa,QAAe,EAAM,SAAS,UAAU,EAAI,GAQzD,IAAiB,EAA8C,KAAA,CAAS,GAExE,IAAe,QACnB,EAAe,UAAU,KAAA,IAAmC,EAAS,EAAM,MAAM,KAAK,IAAjD,EAAe,KACtD,GAIM,IAAO,EAAwB;GACnC,IAAI,SAAS;IACX,OAAO,EAAM,OAAO,UAAU,OAAO,YAAc,MAAc,UAAU,WAAW;GACxF;GACA,IAAI,MAAM;IACR,OAAO,EAAS,EAAM,IAAI,KAAK;GACjC;GACA,IAAI,MAAM;IACR,OAAO,EAAS,EAAM,IAAI,KAAK;GACjC;GACA,SAAS,GAAM;IAKb,AAJA,EAAe,QAAQ,GACvB,EAAY,QAAQ,OACpB,EAAY,QAAQ,EAAK,YAAY,GACrC,EAAa,QAAQ,EAAK,aAAa,GACvC,EAAK,UAAU,EAAE,UAAU,EAAY,CAAI,EAAE,CAAC;GAChD;GACA,IAAI,QAAQ;IAC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C,EAAE;0BAChF,EAAK,WAAW;;qBAGxB,EAAE;;eAGR;EACF,EAAE;;;;;;;;2BAQe,EAAY,UAAU,OAAO;kBACtC;GACN,IAAM,IAAQ,EAAU,OAClB,IAAmC,CAAC;GAE1C,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAAK,GAAG,EAAK,KAAK,EAAM,MAAM,GAAG,IAAI,CAAC,CAAC;GAEzE,OAAO,EAAK,KACT,MAAQ,CAAI;;oBAEP,EAAI,KACH,MAAS,CAAI;;;;+CAIa,OAAO,EAAK,UAAU,EAAE;+CACxB,OAAO,EAAK,cAAc,EAAW,KAAK,EAAE;gDAC3C,EAAK,WAAW;gDAChB,EAAK,cAAc,EAAW,MAAM;0CACzC,EAAK,cAAc,EAAW,QAAQ,OAAO,IAAK;wCACrD,EAAiB,EAAK,IAAI,EAAE;qCAC/B,MACX,EAAkB,GAAG,kBAAkB,SAAS,EAAiB,EAAK,IAAI,CAAC,EAAE;0BAC7E,OAAO,EAAK,IAAI,EAAE;;qBAG1B,EAAE;;eAGR;EACF,EAAE;;;;CAIV;CACA,QAAQ,EAAE,gBAAgB,GAAK;CAC/B,QAAQ;EAAC;EAAiB;EAAoB;CAAe;AAC/D,CAAC"}
|
|
1
|
+
{"version":3,"file":"calendar.js","names":[],"sources":["../src/inputs/calendar/calendar.ts"],"sourcesContent":["import { define, html, prop, bind, useEmit, styleMap } from '@vielzeug/ore';\nimport { useField } from '@vielzeug/ore';\nimport { computed, signal } from '@vielzeug/ripple';\nimport { Temporal, format } from '@vielzeug/tempo';\n\nimport type { ComponentSize, RoundedSize, ThemeColor } from '../../shared';\n\nimport '../../content/icon/icon';\nimport '../../feedback/badge/badge';\nimport { createDatePickerControl, parseIso, toIsoString, type DatePickerView } from '../../core';\nimport { disablableBundle, roundableBundle, sizableBundle, themableBundle } from '../../shared';\nimport { colorThemeMixin, reducedMotionMixin } from '../../styles';\nimport componentStyles from './calendar.css?inline';\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type OreCalendarEvents = {\n change: { isoValue: string | null };\n};\n\n/**\n * A calendar event entry.\n * Dates must be ISO 8601 strings (yyyy-MM-dd).\n *\n * The `color` field accepts any valid CSS color value (e.g. `'#e11d48'`,\n * `'var(--color-primary)'`). An invalid value silently falls back to the\n * component's theme color. Only pass values you control.\n */\nexport type CalendarEvent = {\n /**\n * Any CSS color value for the event dot / pill.\n * Defaults to the component's theme color when omitted.\n * Rendered via `styleMap()`, which strips `;`/`{`/`}` so the value can't break out of\n * its custom-property declaration — it is not a full CSS-color syntax validator, so an\n * invalid (but injection-safe) value may still render as no color.\n */\n color?: string;\n /** ISO date the event falls on (yyyy-MM-dd) */\n date: string;\n /** Unique identifier */\n id: string;\n /** Short label shown in the calendar cell */\n label: string;\n};\n\nexport type OreCalendarProps = {\n /** Theme color */\n color?: ThemeColor;\n /** Disable all date selection */\n disabled?: boolean;\n /**\n * Array of calendar events to display on day cells.\n * In normal mode each event renders as a small colored dot (max 3 dots, then \"+N\").\n * In expanded mode each event renders as a full-width colored pill with its label.\n * Pass as a JS property or as a JSON-encoded attribute.\n * @example\n * ```js\n * calendar.events = [\n * { id: '1', date: '2025-06-15', label: 'Team standup', color: 'var(--color-primary)' },\n * { id: '2', date: '2025-06-20', label: 'Release', color: '#e11d48' },\n * ];\n * ```\n */\n events?: CalendarEvent[];\n /**\n * Expanded layout — large cells with top-aligned day numbers suitable\n * for a full-page calendar app view.\n */\n expanded?: boolean;\n /** Expand to container width */\n fullwidth?: boolean;\n /** Locale for day/month names (default: browser locale) */\n locale?: string;\n /** Latest selectable date in ISO 8601 format (yyyy-MM-dd) */\n max?: string;\n /** Earliest selectable date in ISO 8601 format (yyyy-MM-dd) */\n min?: string;\n /** Form field name (when used inside a form) */\n name?: string;\n /** Mark field as required */\n required?: boolean;\n /** Border radius override */\n rounded?: RoundedSize;\n /** Component size */\n size?: ComponentSize;\n /**\n * Selected date in ISO 8601 format (yyyy-MM-dd).\n * @example '2025-06-15'\n */\n value?: string;\n /**\n * Day-of-week indices to disable (0 = Sunday … 6 = Saturday).\n * Pass as a JSON array attribute or a JS property.\n * @example\n * ```html\n * <ore-calendar weekend-days=\"[0,6]\"></ore-calendar>\n * ```\n */\n 'weekend-days'?: number[];\n};\n\n/**\n * An accessible, keyboard-navigable inline calendar component.\n * Supports day/month/year drill-down views, min/max bounds, disabled weekend\n * days, and optional form association.\n *\n * @element ore-calendar\n *\n * @attr {string} value - Selected date in ISO 8601 format (yyyy-MM-dd)\n * @attr {string} min - Minimum selectable date (yyyy-MM-dd)\n * @attr {string} max - Maximum selectable date (yyyy-MM-dd)\n * @attr {boolean} disabled - Disable all interaction\n * @attr {boolean} required - Required field (form association)\n * @attr {string} name - Form field name\n * @attr {string} color - Theme color: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error'\n * @attr {string} size - Component size: 'sm' | 'md' | 'lg'\n * @attr {string} rounded - Border radius: 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full'\n * @attr {string} locale - BCP 47 locale string\n * @attr {string} weekend-days - JSON array of day indices to disable (0=Sun…6=Sat)\n * @attr {boolean} fullwidth - Expand to full container width\n * @attr {boolean} expanded - Large-cell calendar-app layout with top-aligned day numbers\n *\n * @fires change - Fired when a date is selected. detail: { isoValue: string | null }\n *\n * @cssprop --calendar-bg - Calendar background\n * @cssprop --calendar-border-color - Calendar border color\n * @cssprop --calendar-radius - Calendar border radius\n * @cssprop --calendar-shadow - Calendar drop shadow\n * @cssprop --calendar-day-selected-bg - Background of selected day cell\n * @cssprop --calendar-day-today-color - Colour of today's date number\n * @cssprop --calendar-day-outside-opacity - Opacity of days outside visible month\n *\n * @part calendar - The root calendar panel\n * @part header - Calendar header (nav + label)\n * @part grid - Day grid\n * @part day - Individual day cell\n *\n * @example\n * ```html\n * <!-- Single date with bounds -->\n * <ore-calendar value=\"2025-06-15\" min=\"2025-01-01\" max=\"2025-12-31\" color=\"primary\"></ore-calendar>\n *\n * <!-- Expanded calendar-app layout -->\n * <ore-calendar expanded fullwidth color=\"primary\"></ore-calendar>\n * ```\n */\nexport const CALENDAR_TAG = 'ore-calendar' as const;\n\n/** Maximum event dots/pills shown per cell before \"+N\" overflow */\nconst MAX_EVENTS = 3;\n\n// ── Component ────────────────────────────────────────────────────────────────\n\ndefine<OreCalendarProps>(CALENDAR_TAG, {\n formAssociated: true,\n props: {\n ...themableBundle,\n ...sizableBundle,\n ...disablableBundle,\n ...roundableBundle,\n events: prop.json([] as CalendarEvent[]),\n expanded: prop.bool(false),\n fullwidth: prop.bool(false),\n locale: prop.string(),\n max: prop.string(),\n min: prop.string(),\n name: prop.string(),\n required: prop.bool(false),\n value: prop.string(),\n 'weekend-days': prop.json([] as number[]),\n },\n\n setup(props) {\n const emit = useEmit<OreCalendarEvents>();\n\n // ── Derived flags ────────────────────────────────────────────────────────\n\n const isDisabled = computed(() => props.disabled.value === true);\n const isExpanded = computed(() => props.expanded.value === true);\n\n // ── Selected date: local-override pattern ─────────────────────────────────\n // `localSelection` holds a user-initiated pick (or undefined = no override).\n // `selectedDate` derives from it, falling back to the value prop reactively.\n // This eliminates setInterval polling — external prop changes propagate\n // through the computed graph automatically.\n\n const localSelection = signal<Temporal.PlainDate | null | undefined>(undefined);\n\n const selectedDate = computed(() =>\n localSelection.value !== undefined ? localSelection.value : parseIso(props.value.value),\n );\n\n // ── Date-picker control ──────────────────────────────────────────────────\n\n const ctrl = createDatePickerControl({\n get locale() {\n return props.locale.value ?? (typeof navigator !== 'undefined' ? navigator.language : 'en');\n },\n get max() {\n return parseIso(props.max.value);\n },\n get min() {\n return parseIso(props.min.value);\n },\n onChange(date) {\n localSelection.value = date;\n currentView.value = 'day';\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n emit('change', { isoValue: toIsoString(date) });\n },\n get value() {\n return selectedDate.value;\n },\n get weekendDays() {\n return props['weekend-days'].value ?? [];\n },\n });\n\n // ── Reactive display state ────────────────────────────────────────────────\n // Three separate primitive signals — the proven pattern. Mutating any one\n // of them invalidates only the computeds that read it.\n\n const currentView = signal<DatePickerView>('day');\n const displayYear = signal(ctrl.displayYear());\n const displayMonth = signal(ctrl.displayMonth()); // 1-indexed (Temporal)\n\n // ── Form value ───────────────────────────────────────────────────────────\n\n useField<string>({\n disabled: isDisabled,\n toFormValue: (v) => v || null,\n value: computed(() => toIsoString(selectedDate.value) ?? ''),\n });\n\n // ── Events lookup ─────────────────────────────────────────────────────────\n\n const eventsByDate = computed(() => {\n const map = new Map<string, CalendarEvent[]>();\n\n for (const evt of props.events.value ?? []) {\n const list = map.get(evt.date) ?? [];\n\n list.push(evt);\n map.set(evt.date, list);\n }\n\n return map;\n });\n\n // ── Derived cells ─────────────────────────────────────────────────────────\n // Each reads a display signal so they re-run when navigation changes.\n\n const dayCells = computed(() => {\n void displayYear.value;\n void displayMonth.value;\n void selectedDate.value; // re-run when selection changes to refresh isSelected flags\n\n return ctrl.dayCells();\n });\n const monthCells = computed(() => {\n void displayYear.value;\n\n return ctrl.monthCells();\n });\n const yearCells = computed(() => {\n void displayYear.value;\n\n return ctrl.yearCells();\n });\n const weekdayLabels = computed(() => ctrl.weekdayLabels());\n\n const displayMonth_ = computed(() => {\n const d = Temporal.PlainDate.from({ day: 1, month: displayMonth.value, year: displayYear.value });\n const loc = props.locale.value ?? (typeof navigator !== 'undefined' ? navigator.language : 'en');\n\n return format(d, { intl: { month: 'long' }, locale: loc, timeZone: 'UTC' });\n });\n\n const displayYear_ = computed(() => String(displayYear.value));\n const displayLabel = computed(() => `${displayMonth_.value} ${displayYear_.value}`);\n\n // ── Navigation ───────────────────────────────────────────────────────────\n\n function handlePrev(): void {\n if (currentView.value === 'day') ctrl.prevMonth();\n else ctrl.prevYear();\n\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n }\n\n function handleNext(): void {\n if (currentView.value === 'day') ctrl.nextMonth();\n else ctrl.nextYear();\n\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n }\n\n function handleHeaderClick(): void {\n const views: DatePickerView[] = ['day', 'month', 'year'];\n const next = views[(views.indexOf(currentView.value) + 1) % views.length];\n\n ctrl.setView(next);\n currentView.value = next;\n }\n\n // ── Selection handlers — all disabled guards live here ────────────────────\n\n function handleSelectMonth(month: number): void {\n if (isDisabled.value) return;\n\n ctrl.goTo(ctrl.displayYear(), month);\n ctrl.setView('day');\n displayYear.value = ctrl.displayYear();\n displayMonth.value = ctrl.displayMonth();\n currentView.value = 'day';\n }\n\n function handleSelectYear(year: number): void {\n if (isDisabled.value) return;\n\n ctrl.goTo(year, ctrl.displayMonth());\n ctrl.setView('month');\n displayYear.value = ctrl.displayYear();\n currentView.value = 'month';\n }\n\n function handleSelectDay(isoStr: string): void {\n if (isDisabled.value) return;\n\n const date = parseIso(isoStr);\n\n if (!date) return;\n\n ctrl.select(date); // ctrl.select() internally rejects disabled/out-of-range dates\n }\n\n // ── Day-cell keyboard navigation (full ARIA grid pattern) ─────────────────\n\n function handleDayKeydown(e: KeyboardEvent): void {\n const cell = e.currentTarget as HTMLElement;\n const grid = cell.closest('.cal-grid-days');\n\n if (!grid) return;\n\n const allCells = Array.from(grid.querySelectorAll<HTMLElement>('.cal-cell-day'));\n const idx = allCells.indexOf(cell);\n\n if (idx === -1) return;\n\n let target: HTMLElement | undefined;\n\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n handleSelectDay(cell.dataset.iso ?? '');\n\n return;\n } else if (e.key === 'ArrowRight') {\n target = allCells[idx + 1];\n } else if (e.key === 'ArrowLeft') {\n target = allCells[idx - 1];\n } else if (e.key === 'ArrowDown') {\n target = allCells[idx + 7];\n } else if (e.key === 'ArrowUp') {\n target = allCells[idx - 7];\n } else if (e.key === 'Home') {\n target = allCells[Math.floor(idx / 7) * 7]; // first cell in same row\n } else if (e.key === 'End') {\n target = allCells[Math.floor(idx / 7) * 7 + 6]; // last cell in same row\n } else {\n return;\n }\n\n e.preventDefault();\n target?.focus();\n }\n\n // ── Month/year-cell keyboard navigation (fixed 4-column grid) ─────────────\n\n function handleGridKeydown(e: KeyboardEvent, cellSelector: string, columns: number, onSelect: () => void): void {\n const cell = e.currentTarget as HTMLElement;\n const grid = cell.closest('.cal-grid');\n\n if (!grid) return;\n\n const allCells = Array.from(grid.querySelectorAll<HTMLElement>(cellSelector));\n const idx = allCells.indexOf(cell);\n\n if (idx === -1) return;\n\n let target: HTMLElement | undefined;\n\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onSelect();\n\n return;\n } else if (e.key === 'ArrowRight') {\n target = allCells[idx + 1];\n } else if (e.key === 'ArrowLeft') {\n target = allCells[idx - 1];\n } else if (e.key === 'ArrowDown') {\n target = allCells[idx + columns];\n } else if (e.key === 'ArrowUp') {\n target = allCells[idx - columns];\n } else if (e.key === 'Home') {\n target = allCells[Math.floor(idx / columns) * columns];\n } else if (e.key === 'End') {\n target = allCells[Math.min(Math.floor(idx / columns) * columns + columns - 1, allCells.length - 1)];\n } else {\n return;\n }\n\n e.preventDefault();\n target?.focus();\n }\n\n // ── Host bindings ────────────────────────────────────────────────────────\n\n bind({\n attr: {\n 'aria-disabled': () => (isDisabled.value ? 'true' : null),\n 'aria-label': () => displayLabel.value,\n role: 'group',\n },\n class: {\n 'is-disabled': isDisabled,\n },\n });\n\n // ── Template ─────────────────────────────────────────────────────────────\n\n return html`\n <div class=\"calendar\" part=\"calendar\" role=\"presentation\">\n <!-- Header -->\n <div class=\"cal-header\" part=\"header\">\n <button class=\"nav-btn\" type=\"button\" aria-label=\"Previous\" ?disabled=\"${isDisabled}\" @click=\"${handlePrev}\">\n <ore-icon name=\"chevron-left\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </button>\n\n <button\n class=\"cal-label-btn\"\n type=\"button\"\n aria-label=\"${() =>\n `Switch to ${currentView.value === 'day' ? 'month' : currentView.value === 'month' ? 'year' : 'day'} view`}\"\n ?disabled=\"${isDisabled}\"\n @click=\"${handleHeaderClick}\">\n <span class=\"cal-label-month\">${displayMonth_}</span>\n <span class=\"cal-label-sep\" aria-hidden=\"true\">/</span>\n <span class=\"cal-label-year\">${displayYear_}</span>\n </button>\n\n <button class=\"nav-btn\" type=\"button\" aria-label=\"Next\" ?disabled=\"${isDisabled}\" @click=\"${handleNext}\">\n <ore-icon name=\"chevron-right\" size=\"16\" stroke-width=\"2\" aria-hidden=\"true\"></ore-icon>\n </button>\n </div>\n\n <!-- Day view -->\n <div\n class=\"cal-grid cal-grid-days\"\n role=\"grid\"\n part=\"grid\"\n aria-label=\"${() => displayLabel.value}\"\n ?hidden=\"${() => currentView.value !== 'day'}\">\n <div role=\"row\" class=\"cal-grid-row\">\n ${() =>\n weekdayLabels.value.map(\n (lbl) => html`\n <div class=\"cal-cell cal-cell-head\" role=\"columnheader\" aria-label=\"${lbl}\">${lbl}</div>\n `,\n )}\n </div>\n ${() => {\n const cells = dayCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 7) rows.push(cells.slice(i, i + 7));\n\n return rows.map(\n (row) => html`\n <div role=\"row\" class=\"cal-grid-row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-day\"\n role=\"gridcell\"\n part=\"day\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n aria-current=\"${() => (cell.isToday ? 'date' : null)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-today=\"${() => cell.isToday}\"\n ?data-outside=\"${() => cell.isOutsideMonth}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n data-iso=\"${cell.iso}\"\n data-day=\"${String(cell.day)}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectDay(cell.iso)}\"\n @keydown=\"${handleDayKeydown}\">\n ${String(cell.day)}\n ${() => {\n const evts = eventsByDate.value.get(cell.iso) ?? [];\n\n if (!evts.length) return html``;\n\n const shown = evts.slice(0, MAX_EVENTS);\n const overflow = evts.length - MAX_EVENTS;\n\n if (isExpanded.value) {\n // Text node is written tag-tight (no inner line breaks) — this custom\n // `html` tagged template does not collapse whitespace at runtime like a\n // browser parser would, so a pretty-printed multi-line `<span>...</span>`\n // here would render literal newlines/indentation into `textContent`.\n // prettier-ignore\n const overflowPill = overflow > 0\n ? html`<span class=\"cal-event-pill-overflow\" aria-hidden=\"true\"\n >+${overflow} more</span\n >`\n : html``;\n\n return html`\n <div\n class=\"cal-events\"\n aria-label=\"${() => `${evts.length} event${evts.length > 1 ? 's' : ''}`}\">\n ${shown.map(\n (evt) => html`\n <ore-badge\n class=\"cal-event-pill\"\n size=\"xs\"\n rounded=\"sm\"\n aria-label=\"${evt.label}\"\n style=\"${styleMap({\n '--badge-bg': evt.color,\n '--badge-border-color': evt.color,\n })}\">\n ${evt.label}\n </ore-badge>\n `,\n )}\n ${overflowPill}\n </div>\n `;\n }\n\n return html`\n <div\n class=\"cal-dots\"\n aria-label=\"${() => `${evts.length} event${evts.length > 1 ? 's' : ''}`}\">\n ${shown.map(\n (evt) => html`\n <ore-badge\n class=\"cal-dot\"\n dot\n size=\"xs\"\n aria-hidden=\"true\"\n style=\"${styleMap({\n '--badge-bg': evt.color,\n '--badge-border-color': evt.color,\n })}\"></ore-badge>\n `,\n )}\n ${\n overflow > 0\n ? html`\n <span class=\"cal-dot-overflow\" aria-hidden=\"true\">+${overflow}</span>\n `\n : html``\n }\n </div>\n `;\n }}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n\n <!-- Month view -->\n <div\n class=\"cal-grid cal-grid-months\"\n role=\"grid\"\n aria-label=\"${() => displayYear_.value}\"\n ?hidden=\"${() => currentView.value !== 'month'}\">\n ${() => {\n const cells = monthCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 4) rows.push(cells.slice(i, i + 4));\n\n return rows.map(\n (row) => html`\n <div role=\"row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-month\"\n role=\"gridcell\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectMonth(cell.month)}\"\n @keydown=\"${(e: KeyboardEvent) =>\n handleGridKeydown(e, '.cal-cell-month', 4, () => handleSelectMonth(cell.month))}\">\n ${cell.shortLabel}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n\n <!-- Year view -->\n <div\n class=\"cal-grid cal-grid-years\"\n role=\"grid\"\n aria-label=\"Select year\"\n ?hidden=\"${() => currentView.value !== 'year'}\">\n ${() => {\n const cells = yearCells.value;\n const rows: (typeof cells)[number][][] = [];\n\n for (let i = 0; i < cells.length; i += 4) rows.push(cells.slice(i, i + 4));\n\n return rows.map(\n (row) => html`\n <div role=\"row\">\n ${row.map(\n (cell) => html`\n <div\n class=\"cal-cell cal-cell-year\"\n role=\"gridcell\"\n aria-selected=\"${() => String(cell.isSelected)}\"\n aria-disabled=\"${() => String(cell.isDisabled || isDisabled.value)}\"\n ?data-selected=\"${() => cell.isSelected}\"\n ?data-disabled=\"${() => cell.isDisabled || isDisabled.value}\"\n tabindex=\"${() => (cell.isDisabled || isDisabled.value ? '-1' : '0')}\"\n @click=\"${() => handleSelectYear(cell.year)}\"\n @keydown=\"${(e: KeyboardEvent) =>\n handleGridKeydown(e, '.cal-cell-year', 4, () => handleSelectYear(cell.year))}\">\n ${String(cell.year)}\n </div>\n `,\n )}\n </div>\n `,\n );\n }}\n </div>\n </div>\n `;\n },\n shadow: { delegatesFocus: true },\n styles: [colorThemeMixin, reducedMotionMixin, componentStyles],\n});\n"],"mappings":";;;;;;;;;AAkJA,IAAa,IAAe,gBAGtB,IAAa;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,IAAI,EAAM,QAAQ,KAAK,GAAG,EAAK,KAAK,EAAM,MAAM,GAAG,IAAI,CAAC,CAAC;GAEzE,OAAO,EAAK,KACT,MAAQ,CAAI;;oBAEP,EAAI,KACH,MAAS,CAAI;;;;+CAIa,OAAO,EAAK,UAAU,EAAE;+CACxB,OAAO,EAAK,cAAc,EAAW,KAAK,EAAE;gDAC3C,EAAK,WAAW;gDAChB,EAAK,cAAc,EAAW,MAAM;0CACzC,EAAK,cAAc,EAAW,QAAQ,OAAO,IAAK;wCACrD,EAAiB,EAAK,IAAI,EAAE;qCAC/B,MACX,EAAkB,GAAG,kBAAkB,SAAS,EAAiB,EAAK,IAAI,CAAC,EAAE;0BAC7E,OAAO,EAAK,IAAI,EAAE;;qBAG1B,EAAE;;eAGR;EACF,EAAE;;;;CAIV;CACA,QAAQ,EAAE,gBAAgB,GAAK;CAC/B,QAAQ;EAAC;EAAiB;EAAoB;CAAe;AAC/D,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("@vielzeug/tempo");function t(t){if(!t)return null;try{return(0,e.
|
|
1
|
+
let e=require("@vielzeug/tempo");function t(t){if(!t)return null;try{return(0,e.parse)(t,{as:`plainDate`})}catch{return null}}function n(e){return e?e.toString():null}function r(t,n){return(0,e.format)(t,{intl:{day:`numeric`,month:`short`,year:`numeric`},locale:n,timeZone:`UTC`})}function i(){return e.Temporal.Now.plainDateISO()}function a(e){return e%7}function o(t){let n=t.value??null,r=`day`,o=n??i(),s=o.year,c=o.month;function l(){return t.locale??(typeof navigator<`u`?navigator.language:`en`)}function u(){return t.weekendDays??[]}function d(n){return!!(t.min&&e.Temporal.PlainDate.compare(n,t.min)<0||t.max&&e.Temporal.PlainDate.compare(n,t.max)>0)}function f(e){return!!(d(e)||u().includes(a(e.dayOfWeek)))}function p(){let t=i(),r=e.Temporal.PlainDate.from({day:1,month:c,year:s}),o=a(r.dayOfWeek),l=[];for(let i=o-1;i>=0;i--){let a=r.subtract({days:i+1});l.push({day:a.day,isDisabled:f(a),iso:a.toString(),isOutsideMonth:!0,isSelected:n!==null&&e.Temporal.PlainDate.compare(a,n)===0,isToday:e.Temporal.PlainDate.compare(a,t)===0,plain:a})}let u=r.daysInMonth;for(let r=1;r<=u;r++){let i=e.Temporal.PlainDate.from({day:r,month:c,year:s});l.push({day:r,isDisabled:f(i),iso:i.toString(),isOutsideMonth:!1,isSelected:n!==null&&e.Temporal.PlainDate.compare(i,n)===0,isToday:e.Temporal.PlainDate.compare(i,t)===0,plain:i})}let d=(7-l.length%7)%7,p=r.add({months:1});for(let r=0;r<d;r++){let i=p.add({days:r});l.push({day:i.day,isDisabled:f(i),iso:i.toString(),isOutsideMonth:!0,isSelected:n!==null&&e.Temporal.PlainDate.compare(i,n)===0,isToday:e.Temporal.PlainDate.compare(i,t)===0,plain:i})}return l}function m(){let r=[],i=l();for(let a=1;a<=12;a++){let o=e.Temporal.PlainDate.from({day:1,month:a,year:s}),c=o.with({day:o.daysInMonth}),l=t.min!==null&&t.min!==void 0&&e.Temporal.PlainDate.compare(c,t.min)<0||t.max!==null&&t.max!==void 0&&e.Temporal.PlainDate.compare(o,t.max)>0;r.push({isDisabled:l,isSelected:n!==null&&n.year===s&&n.month===a,label:(0,e.format)(o,{intl:{month:`long`},locale:i,timeZone:`UTC`}),month:a,shortLabel:(0,e.format)(o,{intl:{month:`short`},locale:i,timeZone:`UTC`})})}return r}function h(){let r=Math.floor(s/10)*10,i=[];for(let a=r;a<r+12;a++){let r=e.Temporal.PlainDate.from({day:1,month:1,year:a}),o=e.Temporal.PlainDate.from({day:31,month:12,year:a}),s=t.min!==null&&t.min!==void 0&&e.Temporal.PlainDate.compare(o,t.min)<0||t.max!==null&&t.max!==void 0&&e.Temporal.PlainDate.compare(r,t.max)>0;i.push({isDisabled:s,isSelected:n!==null&&n.year===a,year:a})}return i}function g(){let t=(0,e.parse)(`2024-01-07`,{as:`plainDate`}),n=l();return Array.from({length:7},(r,i)=>(0,e.format)(t.add({days:i}),{intl:{weekday:`short`},locale:n,timeZone:`UTC`}))}return{dayCells:p,displayMonth:()=>c,displayYear:()=>s,goTo(e,t){Number.isFinite(e)&&(s=e,c=Math.max(1,Math.min(12,t)))},monthCells:m,nextMonth(){c===12?(c=1,s++):c++},nextYear(){s++},prevMonth(){c===1?(c=12,s--):c--},prevYear(){s--},select(e){e!==null&&f(e)||(n=e,n&&(s=n.year,c=n.month),t.onChange(n))},selected:()=>n,setView(e){r=e},view:()=>r,weekdayLabels:g,yearCells:h}}exports.createDatePickerControl=o,exports.formatDisplayDate=r,exports.parseIso=t,exports.toIsoString=n;
|
|
2
2
|
//# sourceMappingURL=date-picker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.cjs","names":[],"sources":["../../src/core/date-picker.ts"],"sourcesContent":["import { Temporal, format, parsePlainDate } from '@vielzeug/tempo';\n\n// ── Public ISO helpers (single source of truth for both components) ───────────\n\n/**\n * Parses an ISO 8601 date string (`yyyy-MM-dd`) into a `Temporal.PlainDate`.\n * Returns `null` for any invalid / empty input — never throws.\n */\nexport function parseIso(iso: string | undefined | null): Temporal.PlainDate | null {\n if (!iso) return null;\n\n try {\n return parsePlainDate(iso);\n } catch {\n return null;\n }\n}\n\n/**\n * Serialises a `Temporal.PlainDate` (or `null`) to an ISO 8601 string (`yyyy-MM-dd`).\n * Returns `null` when the input is `null`.\n */\nexport function toIsoString(date: Temporal.PlainDate | null): string | null {\n return date ? date.toString() : null;\n}\n\n/**\n * Formats a `Temporal.PlainDate` for display in a given locale.\n * e.g. \"15 Jun 2025\" (default medium pattern).\n */\nexport function formatDisplayDate(date: Temporal.PlainDate, locale: string): string {\n return format(date, { intl: { day: 'numeric', month: 'short', year: 'numeric' }, locale, tz: 'UTC' });\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type DatePickerView = 'day' | 'month' | 'year';\n\nexport type DateCell = {\n /** Day-of-month number (1–31) */\n day: number;\n isDisabled: boolean;\n /** ISO date string yyyy-MM-dd — stable key for rendering */\n iso: string;\n isOutsideMonth: boolean;\n isSelected: boolean;\n isToday: boolean;\n plain: Temporal.PlainDate;\n};\n\nexport type MonthCell = {\n isDisabled: boolean;\n isSelected: boolean;\n label: string;\n /** 1-based month number (Temporal convention: 1 = January … 12 = December) */\n month: number;\n shortLabel: string;\n};\n\nexport type YearCell = {\n isDisabled: boolean;\n isSelected: boolean;\n year: number;\n};\n\nexport type DatePickerControlOptions = {\n /** Locale for day/month names, defaults to `navigator.language` or `'en'` */\n locale?: string;\n /** Maximum selectable date (inclusive) */\n max?: Temporal.PlainDate | null;\n /** Minimum selectable date (inclusive) */\n min?: Temporal.PlainDate | null;\n /** Called when a date is committed by the user */\n onChange: (date: Temporal.PlainDate | null) => void;\n /** Currently selected date */\n value?: Temporal.PlainDate | null;\n /**\n * Which days of the week to disable (0 = Sunday … 6 = Saturday).\n * @example [0, 6] disables weekends\n */\n weekendDays?: number[];\n};\n\nexport type DatePickerControl = {\n /** Ordered day cells for the visible month grid (includes leading/trailing days) */\n dayCells(): DateCell[];\n /** Month currently shown in the header (1-indexed, Temporal convention) */\n displayMonth(): number;\n /** Year currently shown in the header */\n displayYear(): number;\n /** Jump to a specific display month/year without selecting */\n goTo(year: number, month: number): void;\n /** All 12 month cells */\n monthCells(): MonthCell[];\n /** Move display month forward by one */\n nextMonth(): void;\n /** Move display year forward by one */\n nextYear(): void;\n /** Move display month backward by one */\n prevMonth(): void;\n /** Move display year backward by one */\n prevYear(): void;\n /** Select a date. Pass null to clear. */\n select(date: Temporal.PlainDate | null): void;\n /** The currently selected date, or null */\n selected(): Temporal.PlainDate | null;\n /** Switch the calendar view */\n setView(view: DatePickerView): void;\n /** Currently rendered calendar view */\n view(): DatePickerView;\n /** Short week-day labels in locale order e.g. [\"Su\",\"Mo\",…] */\n weekdayLabels(): string[];\n /** Year cells for the visible decade window */\n yearCells(): YearCell[];\n};\n\n// ── Internal helpers ──────────────────────────────────────────────────────────\n\n/**\n * Returns today as a `Temporal.PlainDate` in the ISO calendar.\n * @internal\n */\nfunction todayPlain(): Temporal.PlainDate {\n return Temporal.Now.plainDateISO();\n}\n\n/**\n * Converts a `Temporal.PlainDate.dayOfWeek` value (1=Mon…7=Sun) to the\n * 0-based weekday index (0=Sun…6=Sat) used in the `weekendDays` prop.\n * @internal\n */\nfunction temporalDowToIndex(dow: number): number {\n // Temporal: 1=Mon, 2=Tue, …, 7=Sun → 0=Sun, 1=Mon, …, 6=Sat\n return dow % 7;\n}\n\n// ── Factory ───────────────────────────────────────────────────────────────────\n\n/**\n * Pure, framework-agnostic date-picker state machine backed by `Temporal.PlainDate`.\n *\n * All state is held in plain mutable variables — suitable for wrapping in any\n * reactive layer (ore `signal`, Vue ref, etc.). The factory returns a stable\n * handle object; callers are responsible for reactivity.\n *\n * Options with getter-based live bindings (e.g. `get min() { ... }`) are read\n * on every call so the control always reflects the latest reactive state.\n *\n * @example\n * ```ts\n * const ctrl = createDatePickerControl({\n * value: Temporal.PlainDate.from('2025-06-15'),\n * locale: 'en-US',\n * onChange: (date) => console.log(date?.toString()),\n * });\n *\n * ctrl.nextMonth();\n * ctrl.select(Temporal.PlainDate.from('2025-07-04'));\n * ```\n */\nexport function createDatePickerControl(options: DatePickerControlOptions): DatePickerControl {\n // ── Mutable state ─────────────────────────────────────────────────────────\n\n let _selected: Temporal.PlainDate | null = options.value ?? null;\n let _view: DatePickerView = 'day';\n\n const initial = _selected ?? todayPlain();\n\n let _displayYear = initial.year;\n let _displayMonth = initial.month; // 1-indexed (Temporal convention)\n\n // ── Live option accessors (always read from options for reactive compat) ───\n\n function locale(): string {\n return options.locale ?? (typeof navigator !== 'undefined' ? navigator.language : 'en');\n }\n\n function weekendDays(): number[] {\n return options.weekendDays ?? [];\n }\n\n // ── Range / disabled helpers ───────────────────────────────────────────────\n\n function isOutOfRange(date: Temporal.PlainDate): boolean {\n if (options.min && Temporal.PlainDate.compare(date, options.min) < 0) return true;\n\n if (options.max && Temporal.PlainDate.compare(date, options.max) > 0) return true;\n\n return false;\n }\n\n function isDayDisabled(date: Temporal.PlainDate): boolean {\n if (isOutOfRange(date)) return true;\n\n if (weekendDays().includes(temporalDowToIndex(date.dayOfWeek))) return true;\n\n return false;\n }\n\n // ── Grid builders ─────────────────────────────────────────────────────────\n\n function buildDayCells(): DateCell[] {\n const todayDate = todayPlain();\n const firstOfMonth = Temporal.PlainDate.from({ day: 1, month: _displayMonth, year: _displayYear });\n\n // Sunday-start grid: Temporal dayOfWeek is 1=Mon…7=Sun, convert to 0=Sun offset\n const startOffset = temporalDowToIndex(firstOfMonth.dayOfWeek);\n const cells: DateCell[] = [];\n\n // Leading days from previous month\n for (let i = startOffset - 1; i >= 0; i--) {\n const d = firstOfMonth.subtract({ days: i + 1 });\n\n cells.push({\n day: d.day,\n isDisabled: isDayDisabled(d),\n iso: d.toString(),\n isOutsideMonth: true,\n isSelected: _selected !== null && Temporal.PlainDate.compare(d, _selected) === 0,\n isToday: Temporal.PlainDate.compare(d, todayDate) === 0,\n plain: d,\n });\n }\n\n // Days in current month\n const daysInMonth = firstOfMonth.daysInMonth;\n\n for (let day = 1; day <= daysInMonth; day++) {\n const d = Temporal.PlainDate.from({ day, month: _displayMonth, year: _displayYear });\n\n cells.push({\n day,\n isDisabled: isDayDisabled(d),\n iso: d.toString(),\n isOutsideMonth: false,\n isSelected: _selected !== null && Temporal.PlainDate.compare(d, _selected) === 0,\n isToday: Temporal.PlainDate.compare(d, todayDate) === 0,\n plain: d,\n });\n }\n\n // Trailing days to fill last row (always end at multiple of 7)\n const remaining = (7 - (cells.length % 7)) % 7;\n const firstOfNext = firstOfMonth.add({ months: 1 });\n\n for (let i = 0; i < remaining; i++) {\n const d = firstOfNext.add({ days: i });\n\n cells.push({\n day: d.day,\n isDisabled: isDayDisabled(d),\n iso: d.toString(),\n isOutsideMonth: true,\n isSelected: _selected !== null && Temporal.PlainDate.compare(d, _selected) === 0,\n isToday: Temporal.PlainDate.compare(d, todayDate) === 0,\n plain: d,\n });\n }\n\n return cells;\n }\n\n function buildMonthCells(): MonthCell[] {\n const cells: MonthCell[] = [];\n const loc = locale();\n\n for (let m = 1; m <= 12; m++) {\n const plain = Temporal.PlainDate.from({ day: 1, month: m, year: _displayYear });\n const lastOfMonth = plain.with({ day: plain.daysInMonth });\n\n const isDisabled =\n (options.min !== null && options.min !== undefined\n ? Temporal.PlainDate.compare(lastOfMonth, options.min) < 0\n : false) ||\n (options.max !== null && options.max !== undefined\n ? Temporal.PlainDate.compare(plain, options.max) > 0\n : false);\n\n cells.push({\n isDisabled,\n isSelected: _selected !== null && _selected.year === _displayYear && _selected.month === m,\n label: format(plain, { intl: { month: 'long' }, locale: loc, tz: 'UTC' }),\n month: m,\n shortLabel: format(plain, { intl: { month: 'short' }, locale: loc, tz: 'UTC' }),\n });\n }\n\n return cells;\n }\n\n function buildYearCells(): YearCell[] {\n const decadeStart = Math.floor(_displayYear / 10) * 10;\n const cells: YearCell[] = [];\n\n for (let y = decadeStart; y < decadeStart + 12; y++) {\n const firstOfYear = Temporal.PlainDate.from({ day: 1, month: 1, year: y });\n const lastOfYear = Temporal.PlainDate.from({ day: 31, month: 12, year: y });\n\n const isDisabled =\n (options.min !== null && options.min !== undefined\n ? Temporal.PlainDate.compare(lastOfYear, options.min) < 0\n : false) ||\n (options.max !== null && options.max !== undefined\n ? Temporal.PlainDate.compare(firstOfYear, options.max) > 0\n : false);\n\n cells.push({\n isDisabled,\n isSelected: _selected !== null && _selected.year === y,\n year: y,\n });\n }\n\n return cells;\n }\n\n function buildWeekdayLabels(): string[] {\n // 2024-01-07 is a Sunday — use it as the Sunday anchor\n const sunday = parsePlainDate('2024-01-07');\n const loc = locale();\n\n return Array.from({ length: 7 }, (_, i) =>\n format(sunday.add({ days: i }), { intl: { weekday: 'short' }, locale: loc, tz: 'UTC' }),\n );\n }\n\n // ── Handle ────────────────────────────────────────────────────────────────\n\n return {\n dayCells: buildDayCells,\n displayMonth: () => _displayMonth,\n displayYear: () => _displayYear,\n\n goTo(year: number, month: number): void {\n if (!Number.isFinite(year)) return;\n\n _displayYear = year;\n _displayMonth = Math.max(1, Math.min(12, month));\n },\n\n monthCells: buildMonthCells,\n\n nextMonth(): void {\n if (_displayMonth === 12) {\n _displayMonth = 1;\n _displayYear++;\n } else {\n _displayMonth++;\n }\n },\n\n nextYear(): void {\n _displayYear++;\n },\n\n prevMonth(): void {\n if (_displayMonth === 1) {\n _displayMonth = 12;\n _displayYear--;\n } else {\n _displayMonth--;\n }\n },\n\n prevYear(): void {\n _displayYear--;\n },\n\n select(date: Temporal.PlainDate | null): void {\n if (date !== null && isDayDisabled(date)) return;\n\n _selected = date;\n\n if (_selected) {\n _displayYear = _selected.year;\n _displayMonth = _selected.month;\n }\n\n options.onChange(_selected);\n },\n\n selected: () => _selected,\n\n setView(view: DatePickerView): void {\n _view = view;\n },\n\n view: () => _view,\n\n weekdayLabels: buildWeekdayLabels,\n\n yearCells: buildYearCells,\n };\n}\n"],"mappings":"iCAQA,SAAgB,EAAS,EAA2D,CAClF,GAAI,CAAC,EAAK,OAAO,KAEjB,GAAI,CACF,OAAA,EAAO,EAAA,eAAA,CAAe,CAAG,CAC3B,MAAQ,CACN,OAAO,IACT,CACF,CAMA,SAAgB,EAAY,EAAgD,CAC1E,OAAO,EAAO,EAAK,SAAS,EAAI,IAClC,CAMA,SAAgB,EAAkB,EAA0B,EAAwB,CAClF,OAAA,EAAO,EAAA,OAAA,CAAO,EAAM,CAAE,KAAM,CAAE,IAAK,UAAW,MAAO,QAAS,KAAM,SAAU,EAAG,SAAQ,GAAI,KAAM,CAAC,CACtG,CA0FA,SAAS,GAAiC,CACxC,OAAO,EAAA,SAAS,IAAI,aAAa,CACnC,CAOA,SAAS,EAAmB,EAAqB,CAE/C,OAAO,EAAM,CACf,CA0BA,SAAgB,EAAwB,EAAsD,CAG5F,IAAI,EAAuC,EAAQ,OAAS,KACxD,EAAwB,MAEtB,EAAU,GAAa,EAAW,EAEpC,EAAe,EAAQ,KACvB,EAA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AAO,SAAS,CAAI,IAEzB,EAAe,EACf,EAAgB,KAAK,IAAI,EAAG,KAAK,IAAI,GAAI,CAAK,CAAC,EACjD,EAEA,WAAY,EAEZ,WAAkB,CACZ,IAAkB,IACpB,EAAgB,EAChB,KAEA,GAEJ,EAEA,UAAiB,CACf,GACF,EAEA,WAAkB,CACZ,IAAkB,GACpB,EAAgB,GAChB,KAEA,GAEJ,EAEA,UAAiB,CACf,GACF,EAEA,OAAO,EAAuC,CACxC,IAAS,MAAQ,EAAc,CAAI,IAEvC,EAAY,EAER,IACF,EAAe,EAAU,KACzB,EAAgB,EAAU,OAG5B,EAAQ,SAAS,CAAS,EAC5B,EAEA,aAAgB,EAEhB,QAAQ,EAA4B,CAClC,EAAQ,CACV,EAEA,SAAY,EAEZ,cAAe,EAEf,UAAW,CACb,CACF"}
|
|
1
|
+
{"version":3,"file":"date-picker.cjs","names":[],"sources":["../../src/core/date-picker.ts"],"sourcesContent":["import { Temporal, format, parse } from '@vielzeug/tempo';\n\n// ── Public ISO helpers (single source of truth for both components) ───────────\n\n/**\n * Parses an ISO 8601 date string (`yyyy-MM-dd`) into a `Temporal.PlainDate`.\n * Returns `null` for any invalid / empty input — never throws.\n */\nexport function parseIso(iso: string | undefined | null): Temporal.PlainDate | null {\n if (!iso) return null;\n\n try {\n return parse(iso, { as: 'plainDate' });\n } catch {\n return null;\n }\n}\n\n/**\n * Serialises a `Temporal.PlainDate` (or `null`) to an ISO 8601 string (`yyyy-MM-dd`).\n * Returns `null` when the input is `null`.\n */\nexport function toIsoString(date: Temporal.PlainDate | null): string | null {\n return date ? date.toString() : null;\n}\n\n/**\n * Formats a `Temporal.PlainDate` for display in a given locale.\n * e.g. \"15 Jun 2025\" (default medium pattern).\n */\nexport function formatDisplayDate(date: Temporal.PlainDate, locale: string): string {\n return format(date, { intl: { day: 'numeric', month: 'short', year: 'numeric' }, locale, timeZone: 'UTC' });\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type DatePickerView = 'day' | 'month' | 'year';\n\nexport type DateCell = {\n /** Day-of-month number (1–31) */\n day: number;\n isDisabled: boolean;\n /** ISO date string yyyy-MM-dd — stable key for rendering */\n iso: string;\n isOutsideMonth: boolean;\n isSelected: boolean;\n isToday: boolean;\n plain: Temporal.PlainDate;\n};\n\nexport type MonthCell = {\n isDisabled: boolean;\n isSelected: boolean;\n label: string;\n /** 1-based month number (Temporal convention: 1 = January … 12 = December) */\n month: number;\n shortLabel: string;\n};\n\nexport type YearCell = {\n isDisabled: boolean;\n isSelected: boolean;\n year: number;\n};\n\nexport type DatePickerControlOptions = {\n /** Locale for day/month names, defaults to `navigator.language` or `'en'` */\n locale?: string;\n /** Maximum selectable date (inclusive) */\n max?: Temporal.PlainDate | null;\n /** Minimum selectable date (inclusive) */\n min?: Temporal.PlainDate | null;\n /** Called when a date is committed by the user */\n onChange: (date: Temporal.PlainDate | null) => void;\n /** Currently selected date */\n value?: Temporal.PlainDate | null;\n /**\n * Which days of the week to disable (0 = Sunday … 6 = Saturday).\n * @example [0, 6] disables weekends\n */\n weekendDays?: number[];\n};\n\nexport type DatePickerControl = {\n /** Ordered day cells for the visible month grid (includes leading/trailing days) */\n dayCells(): DateCell[];\n /** Month currently shown in the header (1-indexed, Temporal convention) */\n displayMonth(): number;\n /** Year currently shown in the header */\n displayYear(): number;\n /** Jump to a specific display month/year without selecting */\n goTo(year: number, month: number): void;\n /** All 12 month cells */\n monthCells(): MonthCell[];\n /** Move display month forward by one */\n nextMonth(): void;\n /** Move display year forward by one */\n nextYear(): void;\n /** Move display month backward by one */\n prevMonth(): void;\n /** Move display year backward by one */\n prevYear(): void;\n /** Select a date. Pass null to clear. */\n select(date: Temporal.PlainDate | null): void;\n /** The currently selected date, or null */\n selected(): Temporal.PlainDate | null;\n /** Switch the calendar view */\n setView(view: DatePickerView): void;\n /** Currently rendered calendar view */\n view(): DatePickerView;\n /** Short week-day labels in locale order e.g. [\"Su\",\"Mo\",…] */\n weekdayLabels(): string[];\n /** Year cells for the visible decade window */\n yearCells(): YearCell[];\n};\n\n// ── Internal helpers ──────────────────────────────────────────────────────────\n\n/**\n * Returns today as a `Temporal.PlainDate` in the ISO calendar.\n * @internal\n */\nfunction todayPlain(): Temporal.PlainDate {\n return Temporal.Now.plainDateISO();\n}\n\n/**\n * Converts a `Temporal.PlainDate.dayOfWeek` value (1=Mon…7=Sun) to the\n * 0-based weekday index (0=Sun…6=Sat) used in the `weekendDays` prop.\n * @internal\n */\nfunction temporalDowToIndex(dow: number): number {\n // Temporal: 1=Mon, 2=Tue, …, 7=Sun → 0=Sun, 1=Mon, …, 6=Sat\n return dow % 7;\n}\n\n// ── Factory ───────────────────────────────────────────────────────────────────\n\n/**\n * Pure, framework-agnostic date-picker state machine backed by `Temporal.PlainDate`.\n *\n * All state is held in plain mutable variables — suitable for wrapping in any\n * reactive layer (ore `signal`, Vue ref, etc.). The factory returns a stable\n * handle object; callers are responsible for reactivity.\n *\n * Options with getter-based live bindings (e.g. `get min() { ... }`) are read\n * on every call so the control always reflects the latest reactive state.\n *\n * @example\n * ```ts\n * const ctrl = createDatePickerControl({\n * value: Temporal.PlainDate.from('2025-06-15'),\n * locale: 'en-US',\n * onChange: (date) => console.log(date?.toString()),\n * });\n *\n * ctrl.nextMonth();\n * ctrl.select(Temporal.PlainDate.from('2025-07-04'));\n * ```\n */\nexport function createDatePickerControl(options: DatePickerControlOptions): DatePickerControl {\n // ── Mutable state ─────────────────────────────────────────────────────────\n\n let _selected: Temporal.PlainDate | null = options.value ?? null;\n let _view: DatePickerView = 'day';\n\n const initial = _selected ?? todayPlain();\n\n let _displayYear = initial.year;\n let _displayMonth = initial.month; // 1-indexed (Temporal convention)\n\n // ── Live option accessors (always read from options for reactive compat) ───\n\n function locale(): string {\n return options.locale ?? (typeof navigator !== 'undefined' ? navigator.language : 'en');\n }\n\n function weekendDays(): number[] {\n return options.weekendDays ?? [];\n }\n\n // ── Range / disabled helpers ───────────────────────────────────────────────\n\n function isOutOfRange(date: Temporal.PlainDate): boolean {\n if (options.min && Temporal.PlainDate.compare(date, options.min) < 0) return true;\n\n if (options.max && Temporal.PlainDate.compare(date, options.max) > 0) return true;\n\n return false;\n }\n\n function isDayDisabled(date: Temporal.PlainDate): boolean {\n if (isOutOfRange(date)) return true;\n\n if (weekendDays().includes(temporalDowToIndex(date.dayOfWeek))) return true;\n\n return false;\n }\n\n // ── Grid builders ─────────────────────────────────────────────────────────\n\n function buildDayCells(): DateCell[] {\n const todayDate = todayPlain();\n const firstOfMonth = Temporal.PlainDate.from({ day: 1, month: _displayMonth, year: _displayYear });\n\n // Sunday-start grid: Temporal dayOfWeek is 1=Mon…7=Sun, convert to 0=Sun offset\n const startOffset = temporalDowToIndex(firstOfMonth.dayOfWeek);\n const cells: DateCell[] = [];\n\n // Leading days from previous month\n for (let i = startOffset - 1; i >= 0; i--) {\n const d = firstOfMonth.subtract({ days: i + 1 });\n\n cells.push({\n day: d.day,\n isDisabled: isDayDisabled(d),\n iso: d.toString(),\n isOutsideMonth: true,\n isSelected: _selected !== null && Temporal.PlainDate.compare(d, _selected) === 0,\n isToday: Temporal.PlainDate.compare(d, todayDate) === 0,\n plain: d,\n });\n }\n\n // Days in current month\n const daysInMonth = firstOfMonth.daysInMonth;\n\n for (let day = 1; day <= daysInMonth; day++) {\n const d = Temporal.PlainDate.from({ day, month: _displayMonth, year: _displayYear });\n\n cells.push({\n day,\n isDisabled: isDayDisabled(d),\n iso: d.toString(),\n isOutsideMonth: false,\n isSelected: _selected !== null && Temporal.PlainDate.compare(d, _selected) === 0,\n isToday: Temporal.PlainDate.compare(d, todayDate) === 0,\n plain: d,\n });\n }\n\n // Trailing days to fill last row (always end at multiple of 7)\n const remaining = (7 - (cells.length % 7)) % 7;\n const firstOfNext = firstOfMonth.add({ months: 1 });\n\n for (let i = 0; i < remaining; i++) {\n const d = firstOfNext.add({ days: i });\n\n cells.push({\n day: d.day,\n isDisabled: isDayDisabled(d),\n iso: d.toString(),\n isOutsideMonth: true,\n isSelected: _selected !== null && Temporal.PlainDate.compare(d, _selected) === 0,\n isToday: Temporal.PlainDate.compare(d, todayDate) === 0,\n plain: d,\n });\n }\n\n return cells;\n }\n\n function buildMonthCells(): MonthCell[] {\n const cells: MonthCell[] = [];\n const loc = locale();\n\n for (let m = 1; m <= 12; m++) {\n const plain = Temporal.PlainDate.from({ day: 1, month: m, year: _displayYear });\n const lastOfMonth = plain.with({ day: plain.daysInMonth });\n\n const isDisabled =\n (options.min !== null && options.min !== undefined\n ? Temporal.PlainDate.compare(lastOfMonth, options.min) < 0\n : false) ||\n (options.max !== null && options.max !== undefined\n ? Temporal.PlainDate.compare(plain, options.max) > 0\n : false);\n\n cells.push({\n isDisabled,\n isSelected: _selected !== null && _selected.year === _displayYear && _selected.month === m,\n label: format(plain, { intl: { month: 'long' }, locale: loc, timeZone: 'UTC' }),\n month: m,\n shortLabel: format(plain, { intl: { month: 'short' }, locale: loc, timeZone: 'UTC' }),\n });\n }\n\n return cells;\n }\n\n function buildYearCells(): YearCell[] {\n const decadeStart = Math.floor(_displayYear / 10) * 10;\n const cells: YearCell[] = [];\n\n for (let y = decadeStart; y < decadeStart + 12; y++) {\n const firstOfYear = Temporal.PlainDate.from({ day: 1, month: 1, year: y });\n const lastOfYear = Temporal.PlainDate.from({ day: 31, month: 12, year: y });\n\n const isDisabled =\n (options.min !== null && options.min !== undefined\n ? Temporal.PlainDate.compare(lastOfYear, options.min) < 0\n : false) ||\n (options.max !== null && options.max !== undefined\n ? Temporal.PlainDate.compare(firstOfYear, options.max) > 0\n : false);\n\n cells.push({\n isDisabled,\n isSelected: _selected !== null && _selected.year === y,\n year: y,\n });\n }\n\n return cells;\n }\n\n function buildWeekdayLabels(): string[] {\n // 2024-01-07 is a Sunday — use it as the Sunday anchor\n const sunday = parse('2024-01-07', { as: 'plainDate' });\n const loc = locale();\n\n return Array.from({ length: 7 }, (_, i) =>\n format(sunday.add({ days: i }), { intl: { weekday: 'short' }, locale: loc, timeZone: 'UTC' }),\n );\n }\n\n // ── Handle ────────────────────────────────────────────────────────────────\n\n return {\n dayCells: buildDayCells,\n displayMonth: () => _displayMonth,\n displayYear: () => _displayYear,\n\n goTo(year: number, month: number): void {\n if (!Number.isFinite(year)) return;\n\n _displayYear = year;\n _displayMonth = Math.max(1, Math.min(12, month));\n },\n\n monthCells: buildMonthCells,\n\n nextMonth(): void {\n if (_displayMonth === 12) {\n _displayMonth = 1;\n _displayYear++;\n } else {\n _displayMonth++;\n }\n },\n\n nextYear(): void {\n _displayYear++;\n },\n\n prevMonth(): void {\n if (_displayMonth === 1) {\n _displayMonth = 12;\n _displayYear--;\n } else {\n _displayMonth--;\n }\n },\n\n prevYear(): void {\n _displayYear--;\n },\n\n select(date: Temporal.PlainDate | null): void {\n if (date !== null && isDayDisabled(date)) return;\n\n _selected = date;\n\n if (_selected) {\n _displayYear = _selected.year;\n _displayMonth = _selected.month;\n }\n\n options.onChange(_selected);\n },\n\n selected: () => _selected,\n\n setView(view: DatePickerView): void {\n _view = view;\n },\n\n view: () => _view,\n\n weekdayLabels: buildWeekdayLabels,\n\n yearCells: buildYearCells,\n };\n}\n"],"mappings":"iCAQA,SAAgB,EAAS,EAA2D,CAClF,GAAI,CAAC,EAAK,OAAO,KAEjB,GAAI,CACF,OAAA,EAAO,EAAA,MAAA,CAAM,EAAK,CAAE,GAAI,WAAY,CAAC,CACvC,MAAQ,CACN,OAAO,IACT,CACF,CAMA,SAAgB,EAAY,EAAgD,CAC1E,OAAO,EAAO,EAAK,SAAS,EAAI,IAClC,CAMA,SAAgB,EAAkB,EAA0B,EAAwB,CAClF,OAAA,EAAO,EAAA,OAAA,CAAO,EAAM,CAAE,KAAM,CAAE,IAAK,UAAW,MAAO,QAAS,KAAM,SAAU,EAAG,SAAQ,SAAU,KAAM,CAAC,CAC5G,CA0FA,SAAS,GAAiC,CACxC,OAAO,EAAA,SAAS,IAAI,aAAa,CACnC,CAOA,SAAS,EAAmB,EAAqB,CAE/C,OAAO,EAAM,CACf,CA0BA,SAAgB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AS,OAAQ,EAAG,OAAQ,EAAK,SAAU,KAAM,CAAC,CAC9F,CACF,CAIA,MAAO,CACL,SAAU,EACV,iBAAoB,EACpB,gBAAmB,EAEnB,KAAK,EAAc,EAAqB,CACjC,OAAO,SAAS,CAAI,IAEzB,EAAe,EACf,EAAgB,KAAK,IAAI,EAAG,KAAK,IAAI,GAAI,CAAK,CAAC,EACjD,EAEA,WAAY,EAEZ,WAAkB,CACZ,IAAkB,IACpB,EAAgB,EAChB,KAEA,GAEJ,EAEA,UAAiB,CACf,GACF,EAEA,WAAkB,CACZ,IAAkB,GACpB,EAAgB,GAChB,KAEA,GAEJ,EAEA,UAAiB,CACf,GACF,EAEA,OAAO,EAAuC,CACxC,IAAS,MAAQ,EAAc,CAAI,IAEvC,EAAY,EAER,IACF,EAAe,EAAU,KACzB,EAAgB,EAAU,OAG5B,EAAQ,SAAS,CAAS,EAC5B,EAEA,aAAgB,EAEhB,QAAQ,EAA4B,CAClC,EAAQ,CACV,EAEA,SAAY,EAEZ,cAAe,EAEf,UAAW,CACb,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../src/core/date-picker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../src/core/date-picker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,iBAAiB,CAAC;AAI1D;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,QAAQ,CAAC,SAAS,GAAG,IAAI,CAQlF;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAE1E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC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AC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,oFAAoF;IACpF,QAAQ,IAAI,QAAQ,EAAE,CAAC;IACvB,2EAA2E;IAC3E,YAAY,IAAI,MAAM,CAAC;IACvB,yCAAyC;IACzC,WAAW,IAAI,MAAM,CAAC;IACtB,8DAA8D;IAC9D,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,yBAAyB;IACzB,UAAU,IAAI,SAAS,EAAE,CAAC;IAC1B,wCAAwC;IACxC,SAAS,IAAI,IAAI,CAAC;IAClB,uCAAuC;IACvC,QAAQ,IAAI,IAAI,CAAC;IACjB,yCAAyC;IACzC,SAAS,IAAI,IAAI,CAAC;IAClB,wCAAwC;IACxC,QAAQ,IAAI,IAAI,CAAC;IACjB,yCAAyC;IACzC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;IAC9C,2CAA2C;IAC3C,QAAQ,IAAI,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC;IACtC,+BAA+B;IAC/B,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,uCAAuC;IACvC,IAAI,IAAI,cAAc,CAAC;IACvB,+DAA+D;IAC/D,aAAa,IAAI,MAAM,EAAE,CAAC;IAC1B,+CAA+C;IAC/C,SAAS,IAAI,QAAQ,EAAE,CAAC;CACzB,CAAC;AAwBF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAyO5F"}
|
package/dist/core/date-picker.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Temporal as e, format as t,
|
|
1
|
+
import { Temporal as e, format as t, parse as n } from "@vielzeug/tempo";
|
|
2
2
|
//#region src/core/date-picker.ts
|
|
3
3
|
function r(e) {
|
|
4
4
|
if (!e) return null;
|
|
5
5
|
try {
|
|
6
|
-
return n(e);
|
|
6
|
+
return n(e, { as: "plainDate" });
|
|
7
7
|
} catch {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
@@ -19,7 +19,7 @@ function a(e, n) {
|
|
|
19
19
|
year: "numeric"
|
|
20
20
|
},
|
|
21
21
|
locale: n,
|
|
22
|
-
|
|
22
|
+
timeZone: "UTC"
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
function o() {
|
|
@@ -106,13 +106,13 @@ function c(r) {
|
|
|
106
106
|
label: t(s, {
|
|
107
107
|
intl: { month: "long" },
|
|
108
108
|
locale: a,
|
|
109
|
-
|
|
109
|
+
timeZone: "UTC"
|
|
110
110
|
}),
|
|
111
111
|
month: o,
|
|
112
112
|
shortLabel: t(s, {
|
|
113
113
|
intl: { month: "short" },
|
|
114
114
|
locale: a,
|
|
115
|
-
|
|
115
|
+
timeZone: "UTC"
|
|
116
116
|
})
|
|
117
117
|
});
|
|
118
118
|
}
|
|
@@ -139,11 +139,11 @@ function c(r) {
|
|
|
139
139
|
return n;
|
|
140
140
|
}
|
|
141
141
|
function v() {
|
|
142
|
-
let e = n("2024-01-07"), r = d();
|
|
142
|
+
let e = n("2024-01-07", { as: "plainDate" }), r = d();
|
|
143
143
|
return Array.from({ length: 7 }, (n, i) => t(e.add({ days: i }), {
|
|
144
144
|
intl: { weekday: "short" },
|
|
145
145
|
locale: r,
|
|
146
|
-
|
|
146
|
+
timeZone: "UTC"
|
|
147
147
|
}));
|
|
148
148
|
}
|
|
149
149
|
return {
|