@iyulab/components 1.52.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.
- package/CHANGELOG.md +73 -0
- package/README.md +54 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/decorate.js +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.151.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/decorateMetadata.js +1 -1
- package/dist/_virtual/_glob-assets_raw/player-pause-fill.svg.a756c400.js +4 -0
- package/dist/_virtual/_glob-assets_raw/player-play-fill.svg.768b6efc.js +4 -0
- package/dist/assets/locales/ar.json.js +27 -1
- package/dist/assets/locales/de.json.js +27 -1
- package/dist/assets/locales/en.json.js +27 -1
- package/dist/assets/locales/es.json.js +27 -1
- package/dist/assets/locales/fr.json.js +27 -1
- package/dist/assets/locales/id.json.js +27 -1
- package/dist/assets/locales/ja.json.js +27 -1
- package/dist/assets/locales/ko.json.js +27 -1
- package/dist/assets/locales/pt-BR.json.js +27 -1
- package/dist/assets/locales/ru.json.js +27 -1
- package/dist/assets/locales/th.json.js +27 -1
- package/dist/assets/locales/vi.json.js +27 -1
- package/dist/assets/locales/zh-CN.json.js +27 -1
- package/dist/assets/locales/zh-TW.json.js +27 -1
- package/dist/components/UFloatingElement.js +2 -2
- package/dist/components/UFormControlElement.js +2 -2
- package/dist/components/UOverlayElement.js +2 -2
- package/dist/components/alert/UAlert.js +2 -2
- package/dist/components/avatar/UAvatar.js +2 -2
- package/dist/components/badge/UBadge.js +2 -2
- package/dist/components/breadcrumb/UBreadcrumb.js +1 -1
- package/dist/components/breadcrumb-item/UBreadcrumbItem.js +2 -2
- package/dist/components/button/UButton.js +2 -2
- package/dist/components/button-group/UButtonGroup.js +2 -2
- package/dist/components/calendar/UCalendar.d.ts +101 -0
- package/dist/components/calendar/UCalendar.js +223 -0
- package/dist/components/calendar/UCalendar.styles.d.ts +1 -0
- package/dist/components/calendar/UCalendar.styles.js +137 -0
- package/dist/components/calendar/dates.d.ts +13 -0
- package/dist/components/calendar/dates.js +37 -0
- package/dist/components/calendar/picker.styles.d.ts +5 -0
- package/dist/components/calendar/picker.styles.js +78 -0
- package/dist/components/card/UCard.js +2 -2
- package/dist/components/carousel/UCarousel.d.ts +17 -0
- package/dist/components/carousel/UCarousel.js +53 -12
- package/dist/components/carousel/UCarousel.styles.js +20 -0
- package/dist/components/checkbox/UCheckbox.js +2 -2
- package/dist/components/chip/UChip.js +2 -2
- package/dist/components/copy-button/UCopyButton.js +2 -2
- package/dist/components/date-picker/UDatePicker.d.ts +8 -13
- package/dist/components/date-picker/UDatePicker.js +36 -165
- package/dist/components/date-picker/UDatePicker.styles.js +0 -135
- package/dist/components/date-range-picker/UDateRangePicker.d.ts +113 -0
- package/dist/components/date-range-picker/UDateRangePicker.js +276 -0
- package/dist/components/date-range-picker/UDateRangePicker.styles.d.ts +1 -0
- package/dist/components/date-range-picker/UDateRangePicker.styles.js +83 -0
- package/dist/components/date-range-picker/presets.d.ts +32 -0
- package/dist/components/date-range-picker/presets.js +78 -0
- package/dist/components/dialog/UDialog.js +2 -2
- package/dist/components/divider/UDivider.js +2 -2
- package/dist/components/drawer/UDrawer.js +2 -2
- package/dist/components/expander/UExpander.js +2 -2
- package/dist/components/field/UField.js +2 -2
- package/dist/components/file-input/UFileInput.js +2 -2
- package/dist/components/form/UForm.js +2 -2
- package/dist/components/icon/UIcon.js +2 -2
- package/dist/components/icon-button/UIconButton.js +2 -2
- package/dist/components/input/UInput.d.ts +31 -3
- package/dist/components/input/UInput.js +131 -24
- package/dist/components/menu/UMenu.js +2 -2
- package/dist/components/menu-item/UMenuItem.js +2 -2
- package/dist/components/option/UOption.js +2 -2
- package/dist/components/panel/UPanel.js +2 -2
- package/dist/components/popover/UPopover.js +2 -2
- package/dist/components/progress-bar/UProgressBar.js +2 -2
- package/dist/components/progress-ring/UProgressRing.js +2 -2
- package/dist/components/radio/URadio.js +2 -2
- package/dist/components/rating/URating.js +2 -2
- package/dist/components/select/USelect.js +2 -2
- package/dist/components/skeleton/USkeleton.js +2 -2
- package/dist/components/slider/USlider.js +2 -2
- package/dist/components/spinner/USpinner.js +2 -2
- package/dist/components/split-panel/USplitPanel.js +2 -2
- package/dist/components/switch/USwitch.js +2 -2
- package/dist/components/tab/UTab.js +2 -2
- package/dist/components/tab-panel/UTabPanel.js +2 -2
- package/dist/components/tag/UTag.js +2 -2
- package/dist/components/text/UText.js +2 -2
- package/dist/components/textarea/UTextarea.js +2 -2
- package/dist/components/tooltip/UTooltip.js +2 -2
- package/dist/components/tree/UTree.js +2 -2
- package/dist/components/tree-item/UTreeItem.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/plugins/vite-plugin-react-wrapper.d.ts +7 -0
- package/dist/plugins/vite-plugin-react-wrapper.js +11 -1
- package/dist/react/UDateRangePicker.d.ts +13 -0
- package/dist/react/UDateRangePicker.js +12 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/utilities/Locale.d.ts +1 -1
- package/dist/utilities/format.d.ts +27 -0
- package/dist/utilities/format.js +71 -1
- package/dist/utilities/icons.js +4 -0
- package/package.json +3 -3
- package/skills/iyulab-components/SKILL.md +1 -0
- package/skills/iyulab-components/references/components/carousel.md +6 -0
- package/skills/iyulab-components/references/components/date-picker.md +2 -0
- package/skills/iyulab-components/references/components/date-range-picker.md +147 -0
- package/skills/iyulab-components/references/components/input.md +14 -4
|
@@ -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;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/components/calendar/dates.ts
|
|
2
|
+
/** ISO `YYYY-MM-DD` → 로컬 자정 `Date`. */
|
|
3
|
+
function parseISODate(iso) {
|
|
4
|
+
const [y, m, d] = iso.split("-").map(Number);
|
|
5
|
+
return new Date(y, m - 1, d);
|
|
6
|
+
}
|
|
7
|
+
/** 로컬 `Date` → ISO `YYYY-MM-DD`. */
|
|
8
|
+
function toISODate(date) {
|
|
9
|
+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
10
|
+
}
|
|
11
|
+
function isSameDay(a, b) {
|
|
12
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
13
|
+
}
|
|
14
|
+
function startOfMonth(date) {
|
|
15
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
16
|
+
}
|
|
17
|
+
function addMonths(date, delta) {
|
|
18
|
+
return new Date(date.getFullYear(), date.getMonth() + delta, 1);
|
|
19
|
+
}
|
|
20
|
+
function addDays(date, delta) {
|
|
21
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + delta);
|
|
22
|
+
}
|
|
23
|
+
function daysInMonth(date) {
|
|
24
|
+
return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
|
|
25
|
+
}
|
|
26
|
+
/** 두 날의 달 차이(`b` 가 `a` 보다 몇 달 뒤인가). 일자는 무시한다. */
|
|
27
|
+
function monthDiff(a, b) {
|
|
28
|
+
return (b.getFullYear() - a.getFullYear()) * 12 + (b.getMonth() - a.getMonth());
|
|
29
|
+
}
|
|
30
|
+
/** `min`/`max`(ISO 날짜, 둘 다 선택)를 벗어나는가 — 경계일은 포함이다. */
|
|
31
|
+
function isOutOfRange(date, min, max) {
|
|
32
|
+
if (min && date.getTime() < parseISODate(min).getTime()) return true;
|
|
33
|
+
if (max && date.getTime() > parseISODate(max).getTime()) return true;
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { addDays, addMonths, daysInMonth, isOutOfRange, isSameDay, monthDiff, parseISODate, startOfMonth, toISODate };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
//#region src/components/calendar/picker.styles.ts
|
|
3
|
+
/**
|
|
4
|
+
* 날짜 피커들(`u-date-picker` · `u-date-range-picker`)이 함께 쓰는 트리거·팝오버·하단 줄 규칙.
|
|
5
|
+
* 호스트의 `display`/`width` 와 팝오버 폭은 피커마다 다르므로 각 피커의 시트가 갖는다.
|
|
6
|
+
*/
|
|
7
|
+
var styles = css`
|
|
8
|
+
.container {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: 0.4em;
|
|
13
|
+
padding: 0.3em 0.6em;
|
|
14
|
+
border: 1px solid var(--u-input-border-color, #E0E0E0);
|
|
15
|
+
border-radius: 0.25em;
|
|
16
|
+
background-color: var(--u-input-bg-color, #FFFFFF);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
transition: border-color var(--u-duration-normal, 220ms) var(--u-ease-standard, cubic-bezier(0.2, 0, 0, 1)),
|
|
19
|
+
box-shadow var(--u-duration-normal, 220ms) var(--u-ease-standard, cubic-bezier(0.2, 0, 0, 1));
|
|
20
|
+
}
|
|
21
|
+
:host([readonly]) .container,
|
|
22
|
+
:host(:disabled) .container {
|
|
23
|
+
cursor: not-allowed;
|
|
24
|
+
border-color: var(--u-border-color-weak, #EEEEEE);
|
|
25
|
+
background-color: var(--u-bg-color-disabled, #FAFAFA);
|
|
26
|
+
}
|
|
27
|
+
:host(:not([readonly]):not(:disabled)) .container:hover {
|
|
28
|
+
box-shadow: 0 0 0 1px var(--u-input-border-color-hover, #BDBDBD);
|
|
29
|
+
}
|
|
30
|
+
:host(:not([readonly]):not(:disabled)) .container:focus-within {
|
|
31
|
+
box-shadow: 0 0 0 1px var(--u-input-border-color-focus, #1565C0);
|
|
32
|
+
}
|
|
33
|
+
:host([invalid]:not([readonly]):not(:disabled)) .container {
|
|
34
|
+
box-shadow: 0 0 0 1px var(--u-input-border-color-invalid, #C62828);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.text-content {
|
|
38
|
+
flex: 1 0 auto;
|
|
39
|
+
min-width: 0;
|
|
40
|
+
font-size: 1em;
|
|
41
|
+
line-height: 1.5;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
text-overflow: ellipsis;
|
|
44
|
+
white-space: nowrap;
|
|
45
|
+
}
|
|
46
|
+
.text-content.placeholder {
|
|
47
|
+
color: var(--u-txt-color-weak, #616161);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.suffix-item {
|
|
51
|
+
color: var(--u-icon-color, #616161);
|
|
52
|
+
font-size: 1em;
|
|
53
|
+
transition: color var(--u-duration-normal, 220ms) var(--u-ease-standard, cubic-bezier(0.2, 0, 0, 1));
|
|
54
|
+
}
|
|
55
|
+
.suffix-item:hover {
|
|
56
|
+
color: var(--u-icon-color-hover, #1565C0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
u-popover {
|
|
60
|
+
padding: 8px;
|
|
61
|
+
border: 1px solid var(--u-border-color, #E0E0E0);
|
|
62
|
+
border-radius: var(--u-radius-lg, 6px);
|
|
63
|
+
background-color: var(--u-panel-bg-color, #FFFFFF);
|
|
64
|
+
box-shadow: var(--u-shadow-lg, 0 4px 12px rgba(0, 0, 0, 0.16), 0 2px 4px rgba(0, 0, 0, 0.06));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.calendar-footer {
|
|
68
|
+
display: flex;
|
|
69
|
+
justify-content: space-between;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: 8px;
|
|
72
|
+
padding-top: 8px;
|
|
73
|
+
margin-top: 4px;
|
|
74
|
+
border-top: 1px solid var(--u-border-color-weak, #EEEEEE);
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
//#endregion
|
|
78
|
+
export { styles };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UElement } from "../UElement.js";
|
|
2
|
-
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.
|
|
3
|
-
import __decorate from "../../_virtual/_@oxc-project_runtime@0.
|
|
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 "./UCard.styles.js";
|
|
5
5
|
import { html } from "lit";
|
|
6
6
|
import { customElement, property } from "lit/decorators.js";
|
|
@@ -5,11 +5,16 @@ import { UElement } from '../UElement.js';
|
|
|
5
5
|
*
|
|
6
6
|
* @slot - 슬라이드로 표시할 콘텐츠 (각 자식 요소가 하나의 슬라이드)
|
|
7
7
|
*
|
|
8
|
+
* `autoplay` 이면 회전 제어 버튼(정지/시작)이 인디케이터 줄의 첫 자리에 그려진다. 포인터가 캐러셀 위에
|
|
9
|
+
* 있는 동안은 잠시 멈추고, 키보드 초점이 안으로 들어오면 사용자가 다시 시작할 때까지 멈춘다
|
|
10
|
+
* (WAI-ARIA APG Carousel · WCAG 2.2.2).
|
|
11
|
+
*
|
|
8
12
|
* @csspart slides - 슬라이드 컨테이너
|
|
9
13
|
* @csspart prev-button - 이전 버튼
|
|
10
14
|
* @csspart next-button - 다음 버튼
|
|
11
15
|
* @csspart indicator - 페이지네이션 컨테이너
|
|
12
16
|
* @csspart dot - 페이지네이션 점
|
|
17
|
+
* @csspart rotation-button - 자동 넘김 정지/시작 버튼 (`autoplay` 일 때만, 인디케이터 안)
|
|
13
18
|
*/
|
|
14
19
|
export declare class UCarousel extends UElement {
|
|
15
20
|
static styles: import('lit').CSSResultGroup[];
|
|
@@ -36,10 +41,17 @@ export declare class UCarousel extends UElement {
|
|
|
36
41
|
private slideCount;
|
|
37
42
|
private isDragging;
|
|
38
43
|
private dragOffset;
|
|
44
|
+
/** 사용자가 회전을 멈췄다(정지 버튼, 또는 키보드 초점 진입). 다시 시작할 때까지 유지된다. */
|
|
45
|
+
private rotationStopped;
|
|
46
|
+
/** 포인터가 캐러셀 위에 있다 — 그동안만 잠시 멈춘다. */
|
|
47
|
+
private hovered;
|
|
39
48
|
private autoplayTimer?;
|
|
40
49
|
private dragStartX;
|
|
41
50
|
private dragStartTime;
|
|
42
51
|
private pointerDown;
|
|
52
|
+
/** 지금 자동으로 넘기고 있는가. */
|
|
53
|
+
private get rotating();
|
|
54
|
+
private get showDots();
|
|
43
55
|
private get perView();
|
|
44
56
|
private get perMove();
|
|
45
57
|
private get maxIndex();
|
|
@@ -60,6 +72,11 @@ export declare class UCarousel extends UElement {
|
|
|
60
72
|
private handlePointerDown;
|
|
61
73
|
private handlePointerMove;
|
|
62
74
|
private handlePointerUp;
|
|
75
|
+
private toggleRotation;
|
|
76
|
+
/** 키보드 초점이 들어오면 멈춘다 — 포인터로 누른 초점은 멈추지 않는다(누른 버튼이 정지 버튼이면 그 클릭이 결정한다). */
|
|
77
|
+
private handleFocusIn;
|
|
78
|
+
private handlePointerEnter;
|
|
79
|
+
private handlePointerLeave;
|
|
63
80
|
private handleClickCancel;
|
|
64
81
|
}
|
|
65
82
|
declare global {
|