@iyulab/components 1.53.0 → 1.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +1 -1
  3. package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/decorate.js +1 -1
  4. package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/decorateMetadata.js +1 -1
  5. package/dist/assets/locales/ar.json.js +23 -1
  6. package/dist/assets/locales/de.json.js +23 -1
  7. package/dist/assets/locales/en.json.js +23 -1
  8. package/dist/assets/locales/es.json.js +23 -1
  9. package/dist/assets/locales/fr.json.js +23 -1
  10. package/dist/assets/locales/id.json.js +23 -1
  11. package/dist/assets/locales/ja.json.js +23 -1
  12. package/dist/assets/locales/ko.json.js +23 -1
  13. package/dist/assets/locales/pt-BR.json.js +23 -1
  14. package/dist/assets/locales/ru.json.js +23 -1
  15. package/dist/assets/locales/th.json.js +23 -1
  16. package/dist/assets/locales/vi.json.js +23 -1
  17. package/dist/assets/locales/zh-CN.json.js +23 -1
  18. package/dist/assets/locales/zh-TW.json.js +23 -1
  19. package/dist/components/UFloatingElement.js +2 -2
  20. package/dist/components/UFormControlElement.js +2 -2
  21. package/dist/components/UOverlayElement.js +2 -2
  22. package/dist/components/alert/UAlert.js +2 -2
  23. package/dist/components/avatar/UAvatar.js +2 -2
  24. package/dist/components/badge/UBadge.js +2 -2
  25. package/dist/components/breadcrumb/UBreadcrumb.js +1 -1
  26. package/dist/components/breadcrumb-item/UBreadcrumbItem.js +2 -2
  27. package/dist/components/button/UButton.js +2 -2
  28. package/dist/components/button-group/UButtonGroup.js +2 -2
  29. package/dist/components/calendar/UCalendar.d.ts +101 -0
  30. package/dist/components/calendar/UCalendar.js +223 -0
  31. package/dist/components/calendar/UCalendar.styles.d.ts +1 -0
  32. package/dist/components/calendar/UCalendar.styles.js +137 -0
  33. package/dist/components/calendar/dates.d.ts +13 -0
  34. package/dist/components/calendar/dates.js +37 -0
  35. package/dist/components/calendar/picker.styles.d.ts +5 -0
  36. package/dist/components/calendar/picker.styles.js +78 -0
  37. package/dist/components/card/UCard.js +2 -2
  38. package/dist/components/carousel/UCarousel.js +2 -2
  39. package/dist/components/checkbox/UCheckbox.js +2 -2
  40. package/dist/components/chip/UChip.js +2 -2
  41. package/dist/components/copy-button/UCopyButton.js +2 -2
  42. package/dist/components/date-picker/UDatePicker.d.ts +8 -13
  43. package/dist/components/date-picker/UDatePicker.js +36 -165
  44. package/dist/components/date-picker/UDatePicker.styles.js +0 -135
  45. package/dist/components/date-range-picker/UDateRangePicker.d.ts +113 -0
  46. package/dist/components/date-range-picker/UDateRangePicker.js +276 -0
  47. package/dist/components/date-range-picker/UDateRangePicker.styles.d.ts +1 -0
  48. package/dist/components/date-range-picker/UDateRangePicker.styles.js +83 -0
  49. package/dist/components/date-range-picker/presets.d.ts +32 -0
  50. package/dist/components/date-range-picker/presets.js +78 -0
  51. package/dist/components/dialog/UDialog.js +2 -2
  52. package/dist/components/divider/UDivider.js +2 -2
  53. package/dist/components/drawer/UDrawer.js +2 -2
  54. package/dist/components/expander/UExpander.js +2 -2
  55. package/dist/components/field/UField.js +2 -2
  56. package/dist/components/file-input/UFileInput.js +2 -2
  57. package/dist/components/form/UForm.js +2 -2
  58. package/dist/components/icon/UIcon.js +2 -2
  59. package/dist/components/icon-button/UIconButton.js +2 -2
  60. package/dist/components/input/UInput.d.ts +31 -3
  61. package/dist/components/input/UInput.js +131 -24
  62. package/dist/components/menu/UMenu.js +2 -2
  63. package/dist/components/menu-item/UMenuItem.js +2 -2
  64. package/dist/components/option/UOption.js +2 -2
  65. package/dist/components/panel/UPanel.js +2 -2
  66. package/dist/components/popover/UPopover.js +2 -2
  67. package/dist/components/progress-bar/UProgressBar.js +2 -2
  68. package/dist/components/progress-ring/UProgressRing.js +2 -2
  69. package/dist/components/radio/URadio.js +2 -2
  70. package/dist/components/rating/URating.js +2 -2
  71. package/dist/components/select/USelect.js +2 -2
  72. package/dist/components/skeleton/USkeleton.js +2 -2
  73. package/dist/components/slider/USlider.js +2 -2
  74. package/dist/components/spinner/USpinner.js +2 -2
  75. package/dist/components/split-panel/USplitPanel.js +2 -2
  76. package/dist/components/switch/USwitch.js +2 -2
  77. package/dist/components/tab/UTab.js +2 -2
  78. package/dist/components/tab-panel/UTabPanel.js +2 -2
  79. package/dist/components/tag/UTag.js +2 -2
  80. package/dist/components/text/UText.js +2 -2
  81. package/dist/components/textarea/UTextarea.js +2 -2
  82. package/dist/components/tooltip/UTooltip.js +2 -2
  83. package/dist/components/tree/UTree.js +2 -2
  84. package/dist/components/tree-item/UTreeItem.js +2 -2
  85. package/dist/index.d.ts +1 -0
  86. package/dist/index.js +3 -2
  87. package/dist/plugins/vite-plugin-react-wrapper.d.ts +7 -0
  88. package/dist/plugins/vite-plugin-react-wrapper.js +11 -1
  89. package/dist/react/UDateRangePicker.d.ts +13 -0
  90. package/dist/react/UDateRangePicker.js +12 -0
  91. package/dist/react/index.d.ts +1 -0
  92. package/dist/react/index.js +1 -0
  93. package/dist/utilities/Locale.d.ts +1 -1
  94. package/dist/utilities/format.d.ts +27 -0
  95. package/dist/utilities/format.js +71 -1
  96. package/package.json +1 -1
  97. package/skills/iyulab-components/SKILL.md +1 -0
  98. package/skills/iyulab-components/references/components/date-picker.md +2 -0
  99. package/skills/iyulab-components/references/components/date-range-picker.md +147 -0
  100. package/skills/iyulab-components/references/components/input.md +14 -4
@@ -21,6 +21,17 @@ var goToSlide = "前往投影片{n}";
21
21
  var stopSlideRotation = "停止自動播放投影片";
22
22
  var startSlideRotation = "開始自動播放投影片";
23
23
  var chooseDate = "選擇日期";
24
+ var chooseDateRange = "選擇日期範圍";
25
+ var yesterday = "昨天";
26
+ var last7Days = "最近7天";
27
+ var last30Days = "最近30天";
28
+ var thisWeek = "本週";
29
+ var lastWeek = "上週";
30
+ var thisMonth = "本月";
31
+ var lastMonth = "上個月";
32
+ var thisYear = "今年";
33
+ var quickRanges = "快速選擇";
34
+ var rangeStartChosen = "開始日期 {date}。請選擇結束日期。";
24
35
  var previousMonth = "上個月";
25
36
  var nextMonth = "下個月";
26
37
  var close = "關閉";
@@ -65,6 +76,17 @@ var zh_TW_default = {
65
76
  stopSlideRotation,
66
77
  startSlideRotation,
67
78
  chooseDate,
79
+ chooseDateRange,
80
+ yesterday,
81
+ last7Days,
82
+ last30Days,
83
+ thisWeek,
84
+ lastWeek,
85
+ thisMonth,
86
+ lastMonth,
87
+ thisYear,
88
+ quickRanges,
89
+ rangeStartChosen,
68
90
  previousMonth,
69
91
  nextMonth,
70
92
  close,
@@ -88,4 +110,4 @@ var zh_TW_default = {
88
110
  cancel
89
111
  };
90
112
  //#endregion
91
- export { alertError, alertInfo, alertMessage, alertNotice, alertSuccess, alertWarning, badInput, breadcrumb, cancel, chooseDate, chooseFile, clear, close, closeTab, confirm, copied, copy, decrement, zh_TW_default as default, filesSelected, goToSlide, hidePassword, increment, nextMonth, nextSlide, noFileChosen, patternMismatch, previousMonth, previousSlide, rangeOverflow, rangeUnderflow, remove, resizePanels, search, showPassword, startSlideRotation, stepMismatch, stopSlideRotation, time, today, tooLong, tooShort, typeMismatch, valueMissing };
113
+ export { alertError, alertInfo, alertMessage, alertNotice, alertSuccess, alertWarning, badInput, breadcrumb, cancel, chooseDate, chooseDateRange, chooseFile, clear, close, closeTab, confirm, copied, copy, decrement, zh_TW_default as default, filesSelected, goToSlide, hidePassword, increment, last30Days, last7Days, lastMonth, lastWeek, nextMonth, nextSlide, noFileChosen, patternMismatch, previousMonth, previousSlide, quickRanges, rangeOverflow, rangeStartChosen, rangeUnderflow, remove, resizePanels, search, showPassword, startSlideRotation, stepMismatch, stopSlideRotation, thisMonth, thisWeek, thisYear, time, today, tooLong, tooShort, typeMismatch, valueMissing, yesterday };
@@ -1,8 +1,8 @@
1
1
  import { UElement } from "./UElement.js";
2
2
  import { getParentElement, querySelectorAllWithin } from "../utilities/elements.js";
3
3
  import { styles } from "./UFloatingElement.styles.js";
4
- import __decorateMetadata from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
5
- import __decorate from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
4
+ import __decorateMetadata from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
5
+ import __decorate from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
6
6
  import { property, state } from "lit/decorators.js";
7
7
  import { arrow, autoPlacement, autoUpdate, computePosition, flip, hide, offset, shift } from "@floating-ui/dom";
8
8
  //#region src/components/UFloatingElement.ts
@@ -1,6 +1,6 @@
1
1
  import { UElement } from "./UElement.js";
2
- import __decorateMetadata from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
3
- import __decorate from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
2
+ import __decorateMetadata from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
+ import __decorate from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
4
  import { styles } from "./UFormControlElement.styles.js";
5
5
  import { property, state } from "lit/decorators.js";
6
6
  //#region src/components/UFormControlElement.ts
@@ -1,7 +1,7 @@
1
1
  import { UElement } from "./UElement.js";
2
2
  import { isFocusCandidate, querySelectorDeep } from "../utilities/elements.js";
3
- import __decorateMetadata from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
4
- import __decorate from "../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
3
+ import __decorateMetadata from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
4
+ import __decorate from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
5
5
  import { OverlayManager } from "../utilities/OverlayManager.js";
6
6
  import { arrayAttrConverter } from "../utilities/converters.js";
7
7
  import { styles } from "./UOverlayElement.styles.js";
@@ -1,6 +1,6 @@
1
1
  import { UElement } from "../UElement.js";
2
- import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
3
- import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
2
+ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
+ import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
4
  import "../button/UButton.js";
5
5
  import { devWarnOnce } from "../../utilities/devWarning.js";
6
6
  import "../icon/UIcon.js";
@@ -1,6 +1,6 @@
1
1
  import { UElement } from "../UElement.js";
2
- import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
3
- import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
2
+ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
+ import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
4
  import { styles } from "./UAvatar.styles.js";
5
5
  import { html } from "lit";
6
6
  import { customElement, property } from "lit/decorators.js";
@@ -1,6 +1,6 @@
1
1
  import { UElement } from "../UElement.js";
2
- import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
3
- import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
2
+ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
+ import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
4
  import "../icon/UIcon.js";
5
5
  import { statusIcon } from "../../utilities/statusIcon.js";
6
6
  import { styles } from "./UBadge.styles.js";
@@ -1,5 +1,5 @@
1
1
  import { UElement } from "../UElement.js";
2
- import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
2
+ import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
3
3
  import "../icon/UIcon.js";
4
4
  import { Locale } from "../../utilities/Locale.js";
5
5
  import { styles } from "./UBreadcrumb.styles.js";
@@ -1,6 +1,6 @@
1
1
  import { UElement } from "../UElement.js";
2
- import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
3
- import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
2
+ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
+ import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
4
  import { styles } from "./UBreadcrumbItem.styles.js";
5
5
  import { html } from "lit";
6
6
  import { customElement, property } from "lit/decorators.js";
@@ -1,6 +1,6 @@
1
1
  import { UElement } from "../UElement.js";
2
- import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
3
- import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
2
+ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
+ import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
4
  import "../spinner/USpinner.js";
5
5
  import { styles } from "./UButton.styles.js";
6
6
  import { html } from "lit";
@@ -1,6 +1,6 @@
1
1
  import { UElement } from "../UElement.js";
2
- import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.js";
3
- import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.js";
2
+ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
+ import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
4
  import { UButton } from "../button/UButton.js";
5
5
  import { UIconButton } from "../icon-button/UIconButton.js";
6
6
  import { styles } from "./UButtonGroup.styles.js";
@@ -0,0 +1,101 @@
1
+ import { PropertyValues } from 'lit';
2
+ import { UElement } from '../UElement.js';
3
+ export interface CalendarDaySelectDetail {
4
+ /** The chosen day as ISO `YYYY-MM-DD`. */
5
+ date: string;
6
+ }
7
+ export interface CalendarRangeSelectDetail {
8
+ /** First day of the chosen range (ISO), never after `end`. */
9
+ start: string;
10
+ /** Last day of the chosen range (ISO), never before `start`. */
11
+ end: string;
12
+ }
13
+ export type CalendarSelection = 'single' | 'range';
14
+ /**
15
+ * 날짜 피커들이 공유하는 달력 격자 — **내부 요소**다(배럴에서 내보내지 않는다).
16
+ *
17
+ * 격자 조립, 키보드 이동(APG grid), `min`/`max` 비활성, 오늘 표시, 여러 달 나란히 보기를
18
+ * 소유한다. 값을 «확정»하지는 않는다 — 무엇을 골랐는지만 알리고, 그것을 값으로 삼을지는
19
+ * 감싸는 피커가 정한다(피커마다 확정 규칙이 다르다: 단일은 즉시, 범위·일시는 [적용]일 수 있다).
20
+ *
21
+ * `selection="range"` 에서는 두 번 고른다 — 첫 날이 «앵커» 가 되고, 포인터나 키보드 초점이
22
+ * 머무는 날까지가 미리 표시된다. 두 번째 날을 고르면 둘 중 앞선 날이 시작이 되어
23
+ * `range-select` 가 난다(순서는 구성으로 보장된다 — 뒤집힌 범위는 만들어지지 않는다).
24
+ * 앵커가 있는 동안 Escape 는 앵커만 지운다(그 Escape 는 감싸는 피커로 가지 않는다).
25
+ * 앵커를 고른 순간은 화면 밖 상태 영역(`role="status"`)이 «시작일 … 종료일을 고르세요» 로
26
+ * 알린다 — 화면에서는 띠가 보이지만 보조기술에는 «선택됨» 하나만 들린다.
27
+ *
28
+ * 감싸는 피커의 공개 `::part` 를 지키기 위해 파트 이름은 종전 `u-date-picker` 의 것을
29
+ * 그대로 쓰고, 피커가 `exportparts` 로 다시 내보낸다.
30
+ *
31
+ * @csspart calendar-month - one month block (header + weekdays + grid)
32
+ * @csspart calendar-header - the month navigation header
33
+ * @csspart calendar-title - the "Month Year" title
34
+ * @csspart calendar-weekdays - the weekday header row
35
+ * @csspart calendar-grid - the date grid
36
+ * @csspart calendar-week - one week row inside the date grid
37
+ * @csspart day - a date cell button
38
+ *
39
+ * @event day-select - a day cell was activated (click, Enter, Space) in `selection="single"`.
40
+ * `detail.date` is ISO. Never fires for an out-of-range day.
41
+ * @event range-select - the second day of a range was activated in `selection="range"`.
42
+ * `detail.start` ≤ `detail.end`, both ISO; the same day twice gives a one-day range.
43
+ *
44
+ * @internal
45
+ */
46
+ export declare class UCalendar extends UElement {
47
+ static styles: import('lit').CSSResultGroup[];
48
+ /** `single` picks one day (`value`); `range` picks two (`start`/`end`). */
49
+ selection: CalendarSelection;
50
+ /** Selected day (ISO `YYYY-MM-DD`) — drawn as `aria-selected`. `selection="single"` only. */
51
+ value?: string;
52
+ /** First day of the selected range (ISO). `selection="range"` only. */
53
+ start?: string;
54
+ /** Last day of the selected range (ISO). `selection="range"` only. */
55
+ end?: string;
56
+ /** Earliest selectable day (ISO), inclusive. */
57
+ min?: string;
58
+ /** Latest selectable day (ISO), inclusive. */
59
+ max?: string;
60
+ /** How many consecutive months to show side by side. */
61
+ visibleMonths: number;
62
+ /** First visible month (always the 1st of a month). */
63
+ private viewDate;
64
+ /** The one day cell in the tab order (roving tabindex). */
65
+ private focusedDate;
66
+ /** First day of a range being picked (`selection="range"`), until the second day is chosen. */
67
+ private anchor?;
68
+ /** The day the pointer rests on — previews the range while an anchor is set. */
69
+ private hoverDate?;
70
+ private grabFocusOnUpdate;
71
+ /**
72
+ * Shows the month containing `date` (ISO or `Date`) as the first visible month and makes
73
+ * that day the roving-tabindex target. Does not move DOM focus — call `focusDay()` for that.
74
+ */
75
+ showDate(date: string | Date): void;
76
+ /** Moves DOM focus to the roving-tabindex day cell once the current render has settled. */
77
+ focusDay(): Promise<void>;
78
+ protected updated(changed: PropertyValues): void;
79
+ render(): import('lit-html').TemplateResult<1>;
80
+ private renderMonth;
81
+ /** The range to draw: the preview while an anchor is set, otherwise the selected range. */
82
+ private shownRange;
83
+ private renderDay;
84
+ private dayButton;
85
+ private activate;
86
+ private handlePointerLeave;
87
+ private handlePrevMonth;
88
+ private handleNextMonth;
89
+ private navigateMonth;
90
+ private handleDayKeydown;
91
+ private moveFocus;
92
+ }
93
+ declare global {
94
+ interface HTMLElementTagNameMap {
95
+ 'u-calendar': UCalendar;
96
+ }
97
+ interface HTMLElementEventMap {
98
+ 'day-select': CustomEvent<CalendarDaySelectDetail>;
99
+ 'range-select': CustomEvent<CalendarRangeSelectDetail>;
100
+ }
101
+ }
@@ -0,0 +1,223 @@
1
+ import { UElement } from "../UElement.js";
2
+ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
3
+ import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
4
+ import { Locale } from "../../utilities/Locale.js";
5
+ import "../icon-button/UIconButton.js";
6
+ import { formatDate } from "../../utilities/format.js";
7
+ import { addDays, addMonths, daysInMonth, isOutOfRange, isSameDay, monthDiff, parseISODate, startOfMonth, toISODate } from "./dates.js";
8
+ import { styles } from "./UCalendar.styles.js";
9
+ import { html } from "lit";
10
+ import { customElement, property, state } from "lit/decorators.js";
11
+ import { ifDefined } from "lit/directives/if-defined.js";
12
+ //#region src/components/calendar/UCalendar.ts
13
+ /** Cells to render for one month — leading `null`s pad the previous month's weekday offset. */
14
+ function buildMonthGrid(month) {
15
+ const first = startOfMonth(month);
16
+ const cells = [];
17
+ for (let i = 0; i < first.getDay(); i++) cells.push(null);
18
+ for (let d = 1; d <= daysInMonth(month); d++) cells.push(new Date(month.getFullYear(), month.getMonth(), d));
19
+ return cells;
20
+ }
21
+ /** Splits the flat cell list into 7-day weeks — the `role="row"` grouping the APG grid pattern expects. */
22
+ function chunkWeeks(cells) {
23
+ const weeks = [];
24
+ for (let i = 0; i < cells.length; i += 7) weeks.push(cells.slice(i, i + 7));
25
+ return weeks;
26
+ }
27
+ /** The two days earliest-first — a range is never stored or reported reversed. */
28
+ function ordered(a, b) {
29
+ return a.getTime() <= b.getTime() ? [a, b] : [b, a];
30
+ }
31
+ /** 2023-01-01 was a Sunday — a fixed reference date that always yields Sun..Sat order regardless of today. */
32
+ function getWeekdayLabels(locale) {
33
+ const formatter = new Intl.DateTimeFormat(locale ?? Locale.get(), { weekday: "narrow" });
34
+ const sunday = new Date(2023, 0, 1);
35
+ return Array.from({ length: 7 }, (_, i) => formatter.format(addDays(sunday, i)));
36
+ }
37
+ var UCalendar = class UCalendar extends UElement {
38
+ constructor(..._args) {
39
+ super(..._args);
40
+ this.selection = "single";
41
+ this.visibleMonths = 1;
42
+ this.viewDate = startOfMonth(/* @__PURE__ */ new Date());
43
+ this.focusedDate = /* @__PURE__ */ new Date();
44
+ this.grabFocusOnUpdate = false;
45
+ this.handlePointerLeave = () => {
46
+ this.hoverDate = void 0;
47
+ };
48
+ this.handlePrevMonth = () => this.navigateMonth(-1);
49
+ this.handleNextMonth = () => this.navigateMonth(1);
50
+ this.handleDayKeydown = (e, date) => {
51
+ const deltas = {
52
+ ArrowRight: 1,
53
+ ArrowLeft: -1,
54
+ ArrowDown: 7,
55
+ ArrowUp: -7,
56
+ Home: -date.getDay(),
57
+ End: 6 - date.getDay()
58
+ };
59
+ if (e.key in deltas) {
60
+ e.preventDefault();
61
+ this.hoverDate = void 0;
62
+ this.moveFocus(date, deltas[e.key]);
63
+ } else if (e.key === "Enter" || e.key === " ") {
64
+ e.preventDefault();
65
+ this.activate(date);
66
+ } else if (e.key === "Escape" && this.anchor) {
67
+ e.preventDefault();
68
+ e.stopPropagation();
69
+ this.anchor = void 0;
70
+ this.hoverDate = void 0;
71
+ }
72
+ };
73
+ }
74
+ static {
75
+ this.styles = [super.styles, styles];
76
+ }
77
+ /**
78
+ * Shows the month containing `date` (ISO or `Date`) as the first visible month and makes
79
+ * that day the roving-tabindex target. Does not move DOM focus — call `focusDay()` for that.
80
+ */
81
+ showDate(date) {
82
+ const d = typeof date === "string" ? parseISODate(date) : date;
83
+ this.viewDate = startOfMonth(d);
84
+ this.focusedDate = d;
85
+ }
86
+ /** Moves DOM focus to the roving-tabindex day cell once the current render has settled. */
87
+ async focusDay() {
88
+ await this.updateComplete;
89
+ this.dayButton(this.focusedDate)?.focus();
90
+ }
91
+ updated(changed) {
92
+ super.updated(changed);
93
+ if (changed.has("focusedDate") && this.grabFocusOnUpdate) {
94
+ this.grabFocusOnUpdate = false;
95
+ this.dayButton(this.focusedDate)?.focus();
96
+ }
97
+ }
98
+ render() {
99
+ const months = Array.from({ length: Math.max(1, this.visibleMonths) }, (_, i) => addMonths(this.viewDate, i));
100
+ const weekdayLabels = getWeekdayLabels();
101
+ const range = this.shownRange();
102
+ return html`
103
+ <div class="months" @pointerleave=${this.handlePointerLeave}>
104
+ ${months.map((month, i) => this.renderMonth(month, weekdayLabels, i === 0, i === months.length - 1, range))}
105
+ </div>
106
+ <span class="status" role="status">${this.anchor ? Locale.getValue("rangeStartChosen", { date: formatDate(this.anchor, { dateStyle: "long" }) }) : ""}</span>
107
+ `;
108
+ }
109
+ renderMonth(month, weekdayLabels, first, last, range) {
110
+ const monthLabel = formatDate(month, {
111
+ year: "numeric",
112
+ month: "long"
113
+ });
114
+ return html`
115
+ <div class="month" part="calendar-month">
116
+ <div class="calendar-header" part="calendar-header">
117
+ ${first ? html`<u-icon-button lib="internal" name="chevron-left" aria-label=${Locale.getValue("previousMonth")} @click=${this.handlePrevMonth}></u-icon-button>` : html`<span class="nav-spacer"></span>`}
118
+ <span class="calendar-title" part="calendar-title">${monthLabel}</span>
119
+ ${last ? html`<u-icon-button lib="internal" name="chevron-right" aria-label=${Locale.getValue("nextMonth")} @click=${this.handleNextMonth}></u-icon-button>` : html`<span class="nav-spacer"></span>`}
120
+ </div>
121
+ <div class="calendar-weekdays" part="calendar-weekdays" role="row">
122
+ ${weekdayLabels.map((w) => html`<span class="weekday" role="columnheader">${w}</span>`)}
123
+ </div>
124
+ <div class="calendar-grid" part="calendar-grid" role="grid" aria-label=${monthLabel}
125
+ aria-multiselectable=${ifDefined(this.selection === "range" ? "true" : void 0)}>
126
+ ${chunkWeeks(buildMonthGrid(month)).map((week) => html`
127
+ <div class="calendar-week" part="calendar-week" role="row">
128
+ ${week.map((date) => date ? this.renderDay(date, range) : html`<span class="day-empty" role="gridcell" aria-hidden="true"></span>`)}
129
+ </div>
130
+ `)}
131
+ </div>
132
+ </div>
133
+ `;
134
+ }
135
+ /** The range to draw: the preview while an anchor is set, otherwise the selected range. */
136
+ shownRange() {
137
+ if (this.selection !== "range") return void 0;
138
+ if (this.anchor) return ordered(this.anchor, this.hoverDate ?? this.focusedDate);
139
+ if (this.start && this.end) return ordered(parseISODate(this.start), parseISODate(this.end));
140
+ }
141
+ renderDay(date, range) {
142
+ const outOfRange = isOutOfRange(date, this.min, this.max);
143
+ const t = date.getTime();
144
+ const inRange = !!range && t >= range[0].getTime() && t <= range[1].getTime();
145
+ const selected = this.selection === "range" ? this.anchor ? isSameDay(date, this.anchor) : inRange : this.value ? isSameDay(date, parseISODate(this.value)) : false;
146
+ return html`
147
+ <button type="button" class="day" part="day"
148
+ role="gridcell"
149
+ data-iso=${toISODate(date)}
150
+ tabindex=${isSameDay(date, this.focusedDate) ? 0 : -1}
151
+ aria-selected=${selected}
152
+ aria-disabled=${outOfRange}
153
+ ?data-today=${isSameDay(date, /* @__PURE__ */ new Date())}
154
+ ?data-in-range=${inRange}
155
+ ?data-range-start=${!!range && isSameDay(date, range[0])}
156
+ ?data-range-end=${!!range && isSameDay(date, range[1])}
157
+ ?data-preview=${inRange && !!this.anchor}
158
+ @click=${() => this.activate(date)}
159
+ @keydown=${(e) => this.handleDayKeydown(e, date)}
160
+ @focus=${() => {
161
+ this.focusedDate = date;
162
+ }}
163
+ @pointerenter=${() => {
164
+ if (this.anchor) this.hoverDate = date;
165
+ }}
166
+ >${date.getDate()}</button>
167
+ `;
168
+ }
169
+ dayButton(date) {
170
+ return this.renderRoot.querySelector(`button.day[data-iso="${toISODate(date)}"]`);
171
+ }
172
+ activate(date) {
173
+ if (isOutOfRange(date, this.min, this.max)) return;
174
+ if (this.selection !== "range") {
175
+ this.fire("day-select", { detail: { date: toISODate(date) } });
176
+ return;
177
+ }
178
+ if (!this.anchor) {
179
+ this.anchor = date;
180
+ this.hoverDate = void 0;
181
+ return;
182
+ }
183
+ const [start, end] = ordered(this.anchor, date);
184
+ this.anchor = void 0;
185
+ this.hoverDate = void 0;
186
+ this.fire("range-select", { detail: {
187
+ start: toISODate(start),
188
+ end: toISODate(end)
189
+ } });
190
+ }
191
+ navigateMonth(delta) {
192
+ this.grabFocusOnUpdate = false;
193
+ const next = addMonths(this.viewDate, delta);
194
+ this.viewDate = next;
195
+ const clampedDay = Math.min(this.focusedDate.getDate(), daysInMonth(next));
196
+ this.focusedDate = new Date(next.getFullYear(), next.getMonth(), clampedDay);
197
+ }
198
+ moveFocus(from, deltaDays) {
199
+ this.grabFocusOnUpdate = true;
200
+ const next = addDays(from, deltaDays);
201
+ const offset = monthDiff(this.viewDate, next);
202
+ if (offset < 0) this.viewDate = startOfMonth(next);
203
+ else if (offset >= this.visibleMonths) this.viewDate = addMonths(next, -(this.visibleMonths - 1));
204
+ this.focusedDate = next;
205
+ }
206
+ };
207
+ __decorate([property({ type: String }), __decorateMetadata("design:type", Object)], UCalendar.prototype, "selection", void 0);
208
+ __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UCalendar.prototype, "value", void 0);
209
+ __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UCalendar.prototype, "start", void 0);
210
+ __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UCalendar.prototype, "end", void 0);
211
+ __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UCalendar.prototype, "min", void 0);
212
+ __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UCalendar.prototype, "max", void 0);
213
+ __decorate([property({
214
+ type: Number,
215
+ attribute: "visible-months"
216
+ }), __decorateMetadata("design:type", Number)], UCalendar.prototype, "visibleMonths", void 0);
217
+ __decorate([state(), __decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date)], UCalendar.prototype, "viewDate", void 0);
218
+ __decorate([state(), __decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date)], UCalendar.prototype, "focusedDate", void 0);
219
+ __decorate([state(), __decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date)], UCalendar.prototype, "anchor", void 0);
220
+ __decorate([state(), __decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date)], UCalendar.prototype, "hoverDate", void 0);
221
+ UCalendar = __decorate([customElement("u-calendar")], UCalendar);
222
+ //#endregion
223
+ export { UCalendar };
@@ -0,0 +1 @@
1
+ export declare const styles: import('lit').CSSResult;
@@ -0,0 +1,137 @@
1
+ import { css } from "lit";
2
+ //#region src/components/calendar/UCalendar.styles.ts
3
+ var styles = css`
4
+ :host {
5
+ position: relative;
6
+ display: block;
7
+ color: var(--u-txt-color, #212121);
8
+ font-family: var(--u-font-base);
9
+ }
10
+
11
+ /* 여러 달은 나란히 두되, 한 달이 최소 폭(칸 7개 × 32px)을 못 받으면 다음 줄로 내린다 —
12
+ 좁은 화면에서 칸을 줄이는 대신 쌓는다(칸이 24px 아래로 내려가면 SC 2.5.8 미달이다). */
13
+ .months {
14
+ display: flex;
15
+ flex-direction: row;
16
+ flex-wrap: wrap;
17
+ gap: 16px;
18
+ }
19
+ .month {
20
+ flex: 1 1 224px;
21
+ min-width: 0;
22
+ }
23
+
24
+ .calendar-header {
25
+ display: flex;
26
+ flex-direction: row;
27
+ align-items: center;
28
+ justify-content: space-between;
29
+ padding: 0 4px 8px;
30
+ }
31
+ /* Keeps the title centered when a month in a multi-month view shows only one of the two
32
+ navigation buttons — the missing one leaves a same-sized gap instead of collapsing. */
33
+ .nav-spacer {
34
+ width: 2em;
35
+ }
36
+ .calendar-title {
37
+ font-size: var(--u-text-label-size, 13px);
38
+ font-weight: var(--u-text-label-weight, 600);
39
+ }
40
+
41
+ .calendar-weekdays,
42
+ .calendar-grid {
43
+ display: grid;
44
+ grid-template-columns: repeat(7, minmax(32px, 1fr));
45
+ }
46
+ .calendar-weekdays {
47
+ padding-bottom: 4px;
48
+ }
49
+ /* role="row" wrapper for APG grid semantics — display:contents keeps it out of the
50
+ CSS grid track so its day cells still lay out as direct grid items. */
51
+ .calendar-week {
52
+ display: contents;
53
+ }
54
+ .weekday {
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: center;
58
+ font-size: var(--u-text-caption-size, 12px);
59
+ color: var(--u-txt-color-weak, #616161);
60
+ }
61
+
62
+ .day,
63
+ .day-empty {
64
+ aspect-ratio: 1;
65
+ }
66
+ .day {
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ border: none;
71
+ border-radius: var(--u-radius-circle, 50%);
72
+ background: transparent;
73
+ color: var(--u-txt-color, #212121);
74
+ font-size: 1em;
75
+ font-family: inherit;
76
+ cursor: pointer;
77
+ }
78
+ .day:hover:not([aria-disabled="true"]) {
79
+ background-color: var(--u-bg-color-hover, #F5F5F5);
80
+ }
81
+ .day:focus-visible {
82
+ outline: none;
83
+ box-shadow: 0 0 0 2px var(--u-input-border-color-focus, #1565C0);
84
+ }
85
+ .day[data-today] {
86
+ font-weight: 700;
87
+ color: var(--u-primary-color, #1976D2);
88
+ }
89
+ .day[aria-selected="true"] {
90
+ background-color: var(--u-primary-color, #1976D2);
91
+ color: var(--u-primary-txt-color, #FFFFFF);
92
+ }
93
+ /* 범위 — 안쪽 날은 띠로 잇고(모서리 없음), 양 끝은 선택 원으로 둔다. 미리 표시(앵커를 고른 뒤
94
+ 두 번째 날을 고르기 전)는 띠 대신 위아래 점선으로 그려 아직 확정 전임을 구분한다. */
95
+ .day[data-in-range] {
96
+ border-radius: var(--u-radius-none, 0);
97
+ background-color: var(--u-primary-bg-color, #E3F2FD);
98
+ color: var(--u-txt-color, #212121);
99
+ }
100
+ .day[data-in-range][data-preview] {
101
+ background-color: transparent;
102
+ border-block: 1px dashed var(--u-primary-color, #1976D2);
103
+ }
104
+ .day[data-range-start] {
105
+ border-start-start-radius: var(--u-radius-circle, 50%);
106
+ border-end-start-radius: var(--u-radius-circle, 50%);
107
+ }
108
+ .day[data-range-end] {
109
+ border-start-end-radius: var(--u-radius-circle, 50%);
110
+ border-end-end-radius: var(--u-radius-circle, 50%);
111
+ }
112
+ .day[data-range-start]:not([data-preview]),
113
+ .day[data-range-end]:not([data-preview]),
114
+ .day[aria-selected="true"][data-preview] {
115
+ background-color: var(--u-primary-color, #1976D2);
116
+ color: var(--u-primary-txt-color, #FFFFFF);
117
+ }
118
+ .day[aria-disabled="true"] {
119
+ color: var(--u-txt-color-disabled, #BDBDBD);
120
+ cursor: not-allowed;
121
+ }
122
+
123
+ /* 상태 공지 — 화면에는 없고 보조기술만 읽는다. 영역은 늘 DOM 에 있어야 바뀐 내용이 읽힌다. */
124
+ .status {
125
+ position: absolute;
126
+ width: 1px;
127
+ height: 1px;
128
+ margin: -1px;
129
+ padding: 0;
130
+ overflow: hidden;
131
+ clip-path: inset(50%);
132
+ white-space: nowrap;
133
+ border: 0;
134
+ }
135
+ `;
136
+ //#endregion
137
+ export { styles };
@@ -0,0 +1,13 @@
1
+ /** ISO `YYYY-MM-DD` → 로컬 자정 `Date`. */
2
+ export declare function parseISODate(iso: string): Date;
3
+ /** 로컬 `Date` → ISO `YYYY-MM-DD`. */
4
+ export declare function toISODate(date: Date): string;
5
+ export declare function isSameDay(a: Date, b: Date): boolean;
6
+ export declare function startOfMonth(date: Date): Date;
7
+ export declare function addMonths(date: Date, delta: number): Date;
8
+ export declare function addDays(date: Date, delta: number): Date;
9
+ export declare function daysInMonth(date: Date): number;
10
+ /** 두 날의 달 차이(`b` 가 `a` 보다 몇 달 뒤인가). 일자는 무시한다. */
11
+ export declare function monthDiff(a: Date, b: Date): number;
12
+ /** `min`/`max`(ISO 날짜, 둘 다 선택)를 벗어나는가 — 경계일은 포함이다. */
13
+ export declare function isOutOfRange(date: Date, min?: string, max?: string): boolean;