@iyulab/components 1.57.1 → 2.0.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 +208 -0
- package/README.md +3 -1
- package/dist/_virtual/_glob-assets_raw/dark.css.e8ac080d.js +1 -1
- package/dist/_virtual/_glob-assets_raw/light.css.637cb2f8.js +1 -1
- package/dist/assets/locales/ar.json.js +16 -2
- package/dist/assets/locales/de.json.js +16 -2
- package/dist/assets/locales/en.json.js +16 -2
- package/dist/assets/locales/es.json.js +18 -2
- package/dist/assets/locales/fr.json.js +16 -2
- package/dist/assets/locales/id.json.js +16 -2
- package/dist/assets/locales/ja.json.js +18 -2
- package/dist/assets/locales/ko.json.js +18 -2
- package/dist/assets/locales/pt-BR.json.js +16 -2
- package/dist/assets/locales/ru.json.js +16 -2
- package/dist/assets/locales/th.json.js +18 -2
- package/dist/assets/locales/vi.json.js +16 -2
- package/dist/assets/locales/zh-CN.json.js +18 -2
- package/dist/assets/locales/zh-TW.json.js +18 -2
- package/dist/components/UElement.styles.js +2 -2
- package/dist/components/alert/UAlert.d.ts +12 -7
- package/dist/components/alert/UAlert.js +3 -3
- package/dist/components/alert/UAlert.styles.js +6 -23
- package/dist/components/badge/UBadge.d.ts +5 -5
- package/dist/components/badge/UBadge.js +3 -3
- package/dist/components/badge/UBadge.styles.js +4 -4
- package/dist/components/breadcrumb-item/UBreadcrumbItem.styles.js +1 -1
- package/dist/components/button/UButton.d.ts +32 -16
- package/dist/components/button/UButton.js +38 -5
- package/dist/components/button/UButton.styles.js +67 -50
- package/dist/components/button/forwarded-aria.d.ts +6 -0
- package/dist/components/button/forwarded-aria.js +15 -0
- package/dist/components/button-group/UButtonGroup.d.ts +4 -4
- package/dist/components/button-group/UButtonGroup.js +8 -8
- package/dist/components/button-group/UButtonGroup.styles.js +2 -2
- package/dist/components/calendar/UCalendar.d.ts +4 -0
- package/dist/components/calendar/UCalendar.js +5 -4
- package/dist/components/calendar/UCalendar.styles.js +4 -3
- package/dist/components/calendar/dates.d.ts +4 -0
- package/dist/components/calendar/dates.js +5 -1
- package/dist/components/calendar/datetime.d.ts +14 -0
- package/dist/components/calendar/datetime.js +35 -0
- package/dist/components/calendar/picker.styles.js +42 -2
- package/dist/components/card/UCard.d.ts +4 -3
- package/dist/components/card/UCard.js +3 -3
- package/dist/components/card/UCard.styles.js +2 -1
- package/dist/components/carousel/UCarousel.d.ts +7 -1
- package/dist/components/carousel/UCarousel.js +10 -3
- package/dist/components/carousel/UCarousel.styles.js +17 -6
- package/dist/components/checkbox/UCheckbox.d.ts +8 -9
- package/dist/components/checkbox/UCheckbox.js +3 -3
- package/dist/components/checkbox/UCheckbox.styles.js +22 -18
- package/dist/components/chip/UChip.d.ts +2 -2
- package/dist/components/chip/UChip.js +4 -4
- package/dist/components/copy-button/UCopyButton.d.ts +2 -2
- package/dist/components/copy-button/UCopyButton.js +4 -4
- package/dist/components/date-picker/UDatePicker.d.ts +32 -1
- package/dist/components/date-picker/UDatePicker.js +96 -33
- package/dist/components/date-picker/UDatePicker.styles.js +10 -18
- package/dist/components/date-range-picker/UDateRangePicker.d.ts +72 -7
- package/dist/components/date-range-picker/UDateRangePicker.js +210 -34
- package/dist/components/date-range-picker/UDateRangePicker.styles.js +13 -3
- package/dist/components/dialog/UDialog.js +1 -1
- package/dist/components/divider/UDivider.d.ts +3 -3
- package/dist/components/divider/UDivider.js +2 -2
- package/dist/components/divider/UDivider.styles.js +5 -5
- package/dist/components/drawer/UDrawer.js +1 -1
- package/dist/components/expander/UExpander.styles.js +2 -2
- package/dist/components/file-input/UFileInput.styles.js +5 -2
- package/dist/components/icon-button/UIconButton.d.ts +4 -3
- package/dist/components/icon-button/UIconButton.js +16 -6
- package/dist/components/icon-button/UIconButton.styles.js +2 -2
- package/dist/components/input/UInput.d.ts +12 -5
- package/dist/components/input/UInput.js +7 -4
- package/dist/components/input/UInput.styles.js +60 -30
- package/dist/components/menu/UMenu.d.ts +5 -4
- package/dist/components/menu/UMenu.js +3 -3
- package/dist/components/menu/UMenu.styles.js +1 -1
- package/dist/components/menu-item/UMenuItem.styles.js +1 -1
- package/dist/components/option/UOption.d.ts +1 -0
- package/dist/components/option/UOption.js +6 -3
- package/dist/components/option/UOption.styles.js +1 -1
- package/dist/components/progress-bar/UProgressBar.styles.js +11 -0
- package/dist/components/radio/URadio.d.ts +27 -6
- package/dist/components/radio/URadio.js +48 -12
- package/dist/components/radio/URadio.styles.js +47 -13
- package/dist/components/rating/URating.styles.js +5 -1
- package/dist/components/select/USelect.d.ts +9 -2
- package/dist/components/select/USelect.js +7 -2
- package/dist/components/select/USelect.styles.js +55 -26
- package/dist/components/slider/USlider.styles.js +4 -4
- package/dist/components/spinner/USpinner.styles.js +2 -0
- package/dist/components/split-panel/USplitPanel.styles.js +2 -1
- package/dist/components/steps/USteps.d.ts +57 -0
- package/dist/components/steps/USteps.js +58 -0
- package/dist/components/steps/USteps.styles.d.ts +1 -0
- package/dist/components/steps/USteps.styles.js +110 -0
- package/dist/components/switch/USwitch.styles.js +5 -3
- package/dist/components/tab/UTab.js +2 -2
- package/dist/components/tab/UTab.styles.js +1 -1
- package/dist/components/tab-panel/UTabPanel.d.ts +11 -2
- package/dist/components/tab-panel/UTabPanel.js +33 -5
- package/dist/components/tab-panel/UTabPanel.styles.js +29 -29
- package/dist/components/tag/UTag.d.ts +14 -6
- package/dist/components/tag/UTag.js +8 -3
- package/dist/components/tag/UTag.styles.js +33 -26
- package/dist/components/textarea/UTextarea.d.ts +9 -3
- package/dist/components/textarea/UTextarea.js +7 -2
- package/dist/components/textarea/UTextarea.styles.js +41 -22
- package/dist/components/tree-item/UTreeItem.styles.js +7 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/dist/plugins/vite-plugin-react-wrapper.js +14 -5
- package/dist/react/UAlert.d.ts +4 -2
- package/dist/react/UAvatar.d.ts +4 -2
- package/dist/react/UBadge.d.ts +4 -2
- package/dist/react/UBreadcrumb.d.ts +4 -2
- package/dist/react/UBreadcrumbItem.d.ts +4 -2
- package/dist/react/UButton.d.ts +4 -2
- package/dist/react/UButtonGroup.d.ts +4 -2
- package/dist/react/UCard.d.ts +4 -2
- package/dist/react/UCarousel.d.ts +4 -2
- package/dist/react/UCheckbox.d.ts +4 -2
- package/dist/react/UChip.d.ts +4 -2
- package/dist/react/UCopyButton.d.ts +4 -2
- package/dist/react/UDatePicker.d.ts +4 -2
- package/dist/react/UDateRangePicker.d.ts +4 -2
- package/dist/react/UDialog.d.ts +4 -2
- package/dist/react/UDivider.d.ts +4 -2
- package/dist/react/UDrawer.d.ts +4 -2
- package/dist/react/UExpander.d.ts +4 -2
- package/dist/react/UField.d.ts +4 -2
- package/dist/react/UFileInput.d.ts +4 -2
- package/dist/react/UForm.d.ts +4 -2
- package/dist/react/UIcon.d.ts +4 -2
- package/dist/react/UIconButton.d.ts +4 -2
- package/dist/react/UInput.d.ts +4 -2
- package/dist/react/UMenu.d.ts +4 -2
- package/dist/react/UMenuItem.d.ts +4 -2
- package/dist/react/UOption.d.ts +4 -2
- package/dist/react/UPanel.d.ts +4 -2
- package/dist/react/UPopover.d.ts +4 -2
- package/dist/react/UProgressBar.d.ts +4 -2
- package/dist/react/UProgressRing.d.ts +4 -2
- package/dist/react/URadio.d.ts +4 -2
- package/dist/react/URating.d.ts +4 -2
- package/dist/react/USelect.d.ts +4 -2
- package/dist/react/USkeleton.d.ts +4 -2
- package/dist/react/USlider.d.ts +4 -2
- package/dist/react/USpinner.d.ts +4 -2
- package/dist/react/USplitPanel.d.ts +4 -2
- package/dist/react/USteps.d.ts +14 -0
- package/dist/react/USteps.js +10 -0
- package/dist/react/USwitch.d.ts +4 -2
- package/dist/react/UTab.d.ts +4 -2
- package/dist/react/UTabPanel.d.ts +4 -2
- package/dist/react/UTag.d.ts +4 -2
- package/dist/react/UText.d.ts +4 -2
- package/dist/react/UTextarea.d.ts +4 -2
- package/dist/react/UTooltip.d.ts +4 -2
- package/dist/react/UTree.d.ts +4 -2
- package/dist/react/UTreeItem.d.ts +4 -2
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/styles/dark.css +42 -0
- package/dist/styles/light.css +44 -0
- package/dist/utilities/Dialog.d.ts +2 -2
- package/dist/utilities/Dialog.js +3 -3
- package/dist/utilities/Locale.d.ts +2 -2
- package/dist/utilities/Locale.js +2 -2
- package/dist/utilities/Toast.d.ts +2 -2
- package/dist/utilities/Toast.js +1 -1
- package/dist/utilities/format.d.ts +32 -4
- package/dist/utilities/format.js +131 -15
- package/dist/utilities/icons.d.ts +12 -3
- package/dist/utilities/icons.js +24 -6
- package/package.json +1 -1
- package/skills/iyulab-components/SKILL.md +3 -3
- package/skills/iyulab-components/references/components/alert.md +5 -5
- package/skills/iyulab-components/references/components/badge.md +3 -3
- package/skills/iyulab-components/references/components/button-group.md +3 -3
- package/skills/iyulab-components/references/components/button.md +34 -19
- package/skills/iyulab-components/references/components/card.md +3 -3
- package/skills/iyulab-components/references/components/carousel.md +3 -1
- package/skills/iyulab-components/references/components/checkbox.md +5 -5
- package/skills/iyulab-components/references/components/chip.md +2 -2
- package/skills/iyulab-components/references/components/copy-button.md +1 -1
- package/skills/iyulab-components/references/components/date-picker.md +35 -2
- package/skills/iyulab-components/references/components/date-range-picker.md +53 -5
- package/skills/iyulab-components/references/components/dialog.md +2 -2
- package/skills/iyulab-components/references/components/divider.md +2 -2
- package/skills/iyulab-components/references/components/drawer.md +1 -1
- package/skills/iyulab-components/references/components/field.md +1 -1
- package/skills/iyulab-components/references/components/icon-button.md +8 -2
- package/skills/iyulab-components/references/components/input.md +4 -2
- package/skills/iyulab-components/references/components/menu.md +1 -1
- package/skills/iyulab-components/references/components/radio.md +16 -4
- package/skills/iyulab-components/references/components/select.md +2 -1
- package/skills/iyulab-components/references/components/steps.md +66 -0
- package/skills/iyulab-components/references/components/tab-panel.md +10 -3
- package/skills/iyulab-components/references/components/tag.md +11 -7
- package/skills/iyulab-components/references/components/textarea.md +2 -1
- package/skills/iyulab-components/references/usage.md +1 -1
- package/skills/iyulab-components/references/utilities/dialog.md +2 -2
- package/skills/iyulab-components/references/utilities/icons.md +2 -2
- package/skills/iyulab-components/references/utilities/locale.md +1 -1
- package/skills/iyulab-components/references/utilities/theme.md +9 -5
- package/skills/iyulab-components/references/utilities/toast.md +2 -2
|
@@ -5,12 +5,13 @@ import "../button/UButton.js";
|
|
|
5
5
|
import { devWarnOnce } from "../../utilities/devWarning.js";
|
|
6
6
|
import "../icon/UIcon.js";
|
|
7
7
|
import { Locale } from "../../utilities/Locale.js";
|
|
8
|
-
import { dateTextPattern, formatDateRangeText, parseDateRange } from "../../utilities/format.js";
|
|
8
|
+
import { dateTextPattern, formatDateRangeText, formatDateTimeRangeText, parseDateRange, parseDateTimeRange } from "../../utilities/format.js";
|
|
9
9
|
import { parseISODate } from "../calendar/dates.js";
|
|
10
10
|
import { UCalendar } from "../calendar/UCalendar.js";
|
|
11
11
|
import "../field/UField.js";
|
|
12
12
|
import { UPopover } from "../popover/UPopover.js";
|
|
13
13
|
import { DateTextController } from "../calendar/date-text-controller.js";
|
|
14
|
+
import { normalizeTime, splitDateTime, toDateTimeOffset } from "../calendar/datetime.js";
|
|
14
15
|
import { styles } from "../calendar/picker.styles.js";
|
|
15
16
|
import { resolvePresets } from "./presets.js";
|
|
16
17
|
import { styles as styles$1 } from "./UDateRangePicker.styles.js";
|
|
@@ -19,34 +20,55 @@ import { customElement, property, query, state } from "lit/decorators.js";
|
|
|
19
20
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
20
21
|
//#region src/components/date-range-picker/UDateRangePicker.ts
|
|
21
22
|
var ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
var ISO_DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
|
|
24
|
+
/** Splits `"start/end"` into its two halves — ISO dates, or in `mode="datetime"` ISO date-times;
|
|
25
|
+
* `undefined` unless both halves have that shape. */
|
|
26
|
+
function parseInterval(value, mode) {
|
|
24
27
|
if (!value) return void 0;
|
|
25
28
|
const [start, end, ...rest] = value.split("/");
|
|
26
|
-
|
|
29
|
+
const shape = mode === "datetime" ? ISO_DATE_TIME : ISO_DATE;
|
|
30
|
+
if (rest.length || !shape.test(start ?? "") || !shape.test(end ?? "")) return void 0;
|
|
27
31
|
return {
|
|
28
32
|
start,
|
|
29
33
|
end
|
|
30
34
|
};
|
|
31
35
|
}
|
|
36
|
+
/** Whether `start` comes after `end` — by day in `date` mode, by instant in `datetime` mode. */
|
|
37
|
+
function reversed(start, end, mode) {
|
|
38
|
+
return mode === "datetime" ? new Date(start).getTime() > new Date(end).getTime() : start > end;
|
|
39
|
+
}
|
|
40
|
+
/** The ISO day of a half (`YYYY-MM-DD` either way). */
|
|
41
|
+
var dayPart = (half) => half.slice(0, 10);
|
|
32
42
|
var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
|
|
33
43
|
constructor(..._args) {
|
|
34
44
|
super(..._args);
|
|
45
|
+
this.size = "md";
|
|
35
46
|
this.clearable = false;
|
|
36
47
|
this.format = "iso";
|
|
37
48
|
this.presets = [];
|
|
49
|
+
this.confirm = false;
|
|
50
|
+
this.mode = "date";
|
|
51
|
+
this.seconds = false;
|
|
38
52
|
this.calendarId = `u-date-range-picker-calendar-${Math.random().toString(36).slice(2, 8)}`;
|
|
39
53
|
this.open = false;
|
|
40
54
|
this.textEntry = new DateTextController(this, {
|
|
41
55
|
toValue: (text) => {
|
|
42
56
|
if (!text.trim()) return void 0;
|
|
43
|
-
const range =
|
|
44
|
-
|
|
57
|
+
const range = this.parseTyped(text);
|
|
58
|
+
if (!range) return null;
|
|
59
|
+
return this.build(dayPart(range.start), dayPart(range.end), {
|
|
60
|
+
start: range.start.slice(11) || this.wholeDay.start,
|
|
61
|
+
end: range.end.slice(11) || this.wholeDay.end
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
dayOf: (text) => {
|
|
65
|
+
const start = this.parseTyped(text)?.start;
|
|
66
|
+
return start ? dayPart(start) : null;
|
|
45
67
|
},
|
|
46
|
-
dayOf: (text) => parseDateRange(text, { format: this.format })?.start ?? null,
|
|
47
68
|
shown: () => {
|
|
48
|
-
const range = parseInterval(this.value);
|
|
49
|
-
|
|
69
|
+
const range = parseInterval(this.value, this.mode);
|
|
70
|
+
if (!range) return this.value ?? "";
|
|
71
|
+
return this.mode === "datetime" ? formatDateTimeRangeText(range.start, range.end, this.format, void 0, this.seconds) : formatDateRangeText(range.start, range.end, this.format);
|
|
50
72
|
},
|
|
51
73
|
onChange: () => this.emitChange(),
|
|
52
74
|
onBadText: () => {
|
|
@@ -59,7 +81,7 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
|
|
|
59
81
|
interactive: () => !this.effectivelyDisabled && !this.readonly
|
|
60
82
|
});
|
|
61
83
|
this.handleRangeSelect = (e) => {
|
|
62
|
-
this.commitRange(e.detail.start, e.detail.end);
|
|
84
|
+
this.commitRange(e.detail.start, e.detail.end, this.workingTimes());
|
|
63
85
|
};
|
|
64
86
|
this.handleCalendarKeydown = (e) => {
|
|
65
87
|
if (e.key !== "Escape") return;
|
|
@@ -80,10 +102,21 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
|
|
|
80
102
|
this.textInputEl?.focus();
|
|
81
103
|
};
|
|
82
104
|
this.handleFooterResetClick = () => {
|
|
105
|
+
if (this.confirm) {
|
|
106
|
+
this.staged = void 0;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
83
109
|
this.resetValue();
|
|
84
110
|
this.popoverEl?.hide();
|
|
85
111
|
this.textInputEl?.focus();
|
|
86
112
|
};
|
|
113
|
+
this.handleApplyClick = () => {
|
|
114
|
+
this.commitValue(this.staged);
|
|
115
|
+
};
|
|
116
|
+
this.handleCancelClick = () => {
|
|
117
|
+
this.popoverEl?.hide();
|
|
118
|
+
this.textInputEl?.focus();
|
|
119
|
+
};
|
|
87
120
|
this.handleClearKeydown = (e) => {
|
|
88
121
|
if (e.key !== "Enter" && e.key !== " ") return;
|
|
89
122
|
e.preventDefault();
|
|
@@ -97,32 +130,78 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
|
|
|
97
130
|
styles$1
|
|
98
131
|
];
|
|
99
132
|
}
|
|
100
|
-
/**
|
|
133
|
+
/** Start of the range — the ISO day, or in `mode="datetime"` the ISO date-time; `undefined` when
|
|
134
|
+
* there is no complete range. */
|
|
101
135
|
get start() {
|
|
102
|
-
return parseInterval(this.value)?.start;
|
|
136
|
+
return parseInterval(this.value, this.mode)?.start;
|
|
103
137
|
}
|
|
104
|
-
/**
|
|
138
|
+
/** End of the range — the ISO day, or in `mode="datetime"` the ISO date-time; `undefined` when
|
|
139
|
+
* there is no complete range. */
|
|
105
140
|
get end() {
|
|
106
|
-
return parseInterval(this.value)?.end;
|
|
141
|
+
return parseInterval(this.value, this.mode)?.end;
|
|
142
|
+
}
|
|
143
|
+
/** Times a whole-day range takes in `mode="datetime"` — a preset or a first calendar pick: from
|
|
144
|
+
* the first minute (or second, with `seconds`) to the last. */
|
|
145
|
+
get wholeDay() {
|
|
146
|
+
return this.seconds ? {
|
|
147
|
+
start: "00:00:00",
|
|
148
|
+
end: "23:59:59"
|
|
149
|
+
} : {
|
|
150
|
+
start: "00:00",
|
|
151
|
+
end: "23:59"
|
|
152
|
+
};
|
|
107
153
|
}
|
|
108
154
|
willUpdate(changed) {
|
|
109
155
|
super.willUpdate(changed);
|
|
110
156
|
if (changed.has("value")) {
|
|
111
|
-
const range = parseInterval(this.value);
|
|
112
|
-
if (range && range.start
|
|
157
|
+
const range = parseInterval(this.value, this.mode);
|
|
158
|
+
if (range && reversed(range.start, range.end, this.mode)) this.value = `${range.end}/${range.start}`;
|
|
113
159
|
}
|
|
160
|
+
if (this.open && (changed.has("open") || changed.has("value"))) this.staged = this.value;
|
|
161
|
+
}
|
|
162
|
+
/** What the open calendar shows and edits: the staged range with `confirm`, otherwise the value. */
|
|
163
|
+
get working() {
|
|
164
|
+
return this.confirm && this.open ? this.staged : this.value;
|
|
165
|
+
}
|
|
166
|
+
/** The times the working range has — or, without one, the ones the next range takes. */
|
|
167
|
+
workingTimes() {
|
|
168
|
+
const range = parseInterval(this.working, this.mode);
|
|
169
|
+
if (this.mode !== "datetime" || !range) return this.pendingTimes ?? this.wholeDay;
|
|
170
|
+
return {
|
|
171
|
+
start: splitDateTime(range.start, true).time,
|
|
172
|
+
end: splitDateTime(range.end, true).time
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/** The value for two days (and, in `mode="datetime"`, two times), earlier first. */
|
|
176
|
+
build(startDay, endDay, times) {
|
|
177
|
+
if (this.mode !== "datetime") return `${startDay}/${endDay}`;
|
|
178
|
+
const start = toDateTimeOffset(startDay, times.start);
|
|
179
|
+
const end = toDateTimeOffset(endDay, times.end);
|
|
180
|
+
return reversed(start, end, this.mode) ? `${end}/${start}` : `${start}/${end}`;
|
|
181
|
+
}
|
|
182
|
+
/** Typed text as a range — days, or in `mode="datetime"` local date-times. A day typed without a
|
|
183
|
+
* time keeps the working range's time at that end. */
|
|
184
|
+
parseTyped(text) {
|
|
185
|
+
if (this.mode !== "datetime") return parseDateRange(text, { format: this.format });
|
|
186
|
+
const times = this.workingTimes();
|
|
187
|
+
return parseDateTimeRange(text, {
|
|
188
|
+
format: this.format,
|
|
189
|
+
startTime: times.start,
|
|
190
|
+
endTime: times.end,
|
|
191
|
+
seconds: this.seconds
|
|
192
|
+
});
|
|
114
193
|
}
|
|
115
194
|
shouldValidate(changed) {
|
|
116
|
-
return super.shouldValidate(changed) || changed.has("min") || changed.has("max");
|
|
195
|
+
return super.shouldValidate(changed) || changed.has("min") || changed.has("max") || changed.has("isDateDisabled");
|
|
117
196
|
}
|
|
118
197
|
updated(changed) {
|
|
119
198
|
super.updated(changed);
|
|
120
199
|
if (changed.has("value")) this.internals?.setFormValue(this.value ?? "");
|
|
121
200
|
if (changed.has("open")) this.internals?.states[this.open ? "add" : "delete"]("open");
|
|
122
|
-
if (changed.has("open") && this.open) this.textEntry.calendarOpened(this.start
|
|
201
|
+
if (changed.has("open") && this.open) this.textEntry.calendarOpened(this.start ? dayPart(this.start) : /* @__PURE__ */ new Date());
|
|
123
202
|
}
|
|
124
203
|
render() {
|
|
125
|
-
const pattern = dateTextPattern(this.format);
|
|
204
|
+
const pattern = this.mode === "datetime" ? `${dateTextPattern(this.format)} ${this.seconds ? "HH:mm:ss" : "HH:mm"}` : dateTextPattern(this.format);
|
|
126
205
|
return html`
|
|
127
206
|
<u-field part="field"
|
|
128
207
|
?required=${this.required}
|
|
@@ -192,6 +271,8 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
|
|
|
192
271
|
}
|
|
193
272
|
renderCalendar() {
|
|
194
273
|
const presets = resolvePresets(this.presets, /* @__PURE__ */ new Date(), (name) => devWarnOnce(`date-range-preset:${name}`, `u-date-range-picker: unknown preset "${name}" — it is not listed.`));
|
|
274
|
+
const working = parseInterval(this.working, this.mode);
|
|
275
|
+
const showClear = this.clearable && !!this.working;
|
|
195
276
|
return html`
|
|
196
277
|
<div class="body">
|
|
197
278
|
${presets.length ? this.renderPresets(presets) : ""}
|
|
@@ -200,43 +281,112 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
|
|
|
200
281
|
exportparts="calendar-month, calendar-header, calendar-title, calendar-weekdays, calendar-grid, calendar-week, day"
|
|
201
282
|
selection="range"
|
|
202
283
|
visible-months="2"
|
|
203
|
-
.start=${
|
|
204
|
-
.end=${
|
|
284
|
+
.start=${working && dayPart(working.start)}
|
|
285
|
+
.end=${working && dayPart(working.end)}
|
|
205
286
|
.min=${this.min}
|
|
206
287
|
.max=${this.max}
|
|
288
|
+
.isDateDisabled=${this.isDateDisabled}
|
|
207
289
|
@range-select=${this.handleRangeSelect}
|
|
208
290
|
@keydown=${this.handleCalendarKeydown}
|
|
209
291
|
></u-calendar>
|
|
210
|
-
${this.
|
|
292
|
+
${this.renderTimeRow()}
|
|
293
|
+
${showClear || this.confirm ? html`
|
|
211
294
|
<div class="calendar-footer" part="calendar-footer">
|
|
212
|
-
|
|
295
|
+
${showClear ? html`
|
|
296
|
+
<u-button appearance="plain" size="sm" @click=${this.handleFooterResetClick}>${Locale.getValue("clear")}</u-button>
|
|
297
|
+
` : ""}
|
|
298
|
+
${this.confirm ? html`
|
|
299
|
+
<span class="confirm-actions">
|
|
300
|
+
<u-button appearance="plain" size="sm" @click=${this.handleCancelClick}>${Locale.getValue("cancel")}</u-button>
|
|
301
|
+
<u-button size="sm" @click=${this.handleApplyClick}>${Locale.getValue("apply")}</u-button>
|
|
302
|
+
</span>
|
|
303
|
+
` : ""}
|
|
213
304
|
</div>
|
|
214
305
|
` : ""}
|
|
215
306
|
</div>
|
|
216
307
|
</div>
|
|
217
308
|
`;
|
|
218
309
|
}
|
|
310
|
+
renderTimeRow() {
|
|
311
|
+
if (this.mode !== "datetime") return "";
|
|
312
|
+
const times = this.workingTimes();
|
|
313
|
+
return html`
|
|
314
|
+
<div class="calendar-time" part="calendar-time">
|
|
315
|
+
<label class="time-field">${Locale.getValue("startTime")}
|
|
316
|
+
<input type="time" class="time-input" part="time-input"
|
|
317
|
+
step=${ifDefined(this.seconds ? "1" : void 0)}
|
|
318
|
+
.value=${normalizeTime(times.start, this.seconds)}
|
|
319
|
+
@change=${(e) => this.handleTimeChange("start", e)}
|
|
320
|
+
/>
|
|
321
|
+
</label>
|
|
322
|
+
<label class="time-field">${Locale.getValue("endTime")}
|
|
323
|
+
<input type="time" class="time-input" part="time-input"
|
|
324
|
+
step=${ifDefined(this.seconds ? "1" : void 0)}
|
|
325
|
+
.value=${normalizeTime(times.end, this.seconds)}
|
|
326
|
+
@change=${(e) => this.handleTimeChange("end", e)}
|
|
327
|
+
/>
|
|
328
|
+
</label>
|
|
329
|
+
</div>
|
|
330
|
+
`;
|
|
331
|
+
}
|
|
332
|
+
/** A time input changed — with a range, that end moves (committed at once, or staged with
|
|
333
|
+
* `confirm`; the calendar stays open); without one, the next range takes it. A start time set
|
|
334
|
+
* after the end on the same day swaps the two, as a reversed range always is. */
|
|
335
|
+
handleTimeChange(which, e) {
|
|
336
|
+
const time = normalizeTime(e.target.value || this.wholeDay[which], this.seconds);
|
|
337
|
+
const times = {
|
|
338
|
+
...this.workingTimes(),
|
|
339
|
+
[which]: time
|
|
340
|
+
};
|
|
341
|
+
this.pendingTimes = times;
|
|
342
|
+
const range = parseInterval(this.working, this.mode);
|
|
343
|
+
if (!range) return;
|
|
344
|
+
const next = this.build(dayPart(range.start), dayPart(range.end), times);
|
|
345
|
+
if (this.confirm) {
|
|
346
|
+
this.staged = next;
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const changed = next !== this.value;
|
|
350
|
+
this.textEntry.clear();
|
|
351
|
+
this.value = next;
|
|
352
|
+
if (changed) this.emitChange();
|
|
353
|
+
}
|
|
219
354
|
renderPresets(presets) {
|
|
220
355
|
return html`
|
|
221
356
|
<div class="presets" part="presets" role="group" aria-label=${Locale.getValue("quickRanges")}>
|
|
222
357
|
${presets.map((p) => html`
|
|
223
358
|
<button type="button" class="preset" part="preset"
|
|
224
|
-
aria-pressed=${
|
|
225
|
-
?disabled=${this.
|
|
226
|
-
@click=${() => this.commitRange(p.start, p.end)}
|
|
359
|
+
aria-pressed=${this.build(p.start, p.end, this.wholeDay) === this.working}
|
|
360
|
+
?disabled=${this.unavailable(p)}
|
|
361
|
+
@click=${() => this.commitRange(p.start, p.end, this.wholeDay)}
|
|
227
362
|
>${p.label}</button>
|
|
228
363
|
`)}
|
|
229
364
|
</div>
|
|
230
365
|
`;
|
|
231
366
|
}
|
|
232
|
-
/** A preset that reaches outside `min`/`max
|
|
233
|
-
*
|
|
234
|
-
|
|
235
|
-
return !!this.min && p.start < this.min || !!this.max && p.end > this.max;
|
|
367
|
+
/** A preset that reaches outside `min`/`max`, or starts or ends on a disabled day, is not
|
|
368
|
+
* offered — its label would promise a range the calendar itself refuses. */
|
|
369
|
+
unavailable(p) {
|
|
370
|
+
return !!this.min && p.start < this.min || !!this.max && p.end > this.max || this.endpointDisabled(p);
|
|
371
|
+
}
|
|
372
|
+
/** Whether `isDateDisabled` refuses either end of the range (the days between may be disabled). */
|
|
373
|
+
endpointDisabled(p) {
|
|
374
|
+
return !!this.isDateDisabled && (this.isDateDisabled(dayPart(p.start)) || this.isDateDisabled(dayPart(p.end)));
|
|
236
375
|
}
|
|
237
|
-
/** A user-chosen range (calendar or preset): set it,
|
|
238
|
-
|
|
239
|
-
|
|
376
|
+
/** A user-chosen range of days (calendar or preset) at `times` (`mode="datetime"`): set it,
|
|
377
|
+
* announce it, close the calendar — or, with `confirm`, stage it for Apply. A calendar pick keeps
|
|
378
|
+
* the times already set; a preset covers its days whole. */
|
|
379
|
+
commitRange(start, end, times) {
|
|
380
|
+
const next = this.build(start, end, times);
|
|
381
|
+
if (this.confirm) {
|
|
382
|
+
this.staged = next;
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
this.commitValue(next);
|
|
386
|
+
}
|
|
387
|
+
/** Commits `next` as the value (firing `change` when it differs), closes the calendar and
|
|
388
|
+
* returns focus to the text box. */
|
|
389
|
+
commitValue(next) {
|
|
240
390
|
const changed = next !== this.value;
|
|
241
391
|
this.textEntry.clear();
|
|
242
392
|
this.value = next;
|
|
@@ -263,7 +413,11 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
|
|
|
263
413
|
setValidity() {
|
|
264
414
|
let flags = {};
|
|
265
415
|
let message = "";
|
|
266
|
-
const
|
|
416
|
+
const parsed = parseInterval(this.value, this.mode);
|
|
417
|
+
const range = parsed && {
|
|
418
|
+
start: dayPart(parsed.start),
|
|
419
|
+
end: dayPart(parsed.end)
|
|
420
|
+
};
|
|
267
421
|
if (this.textEntry.badText) {
|
|
268
422
|
flags = { badInput: true };
|
|
269
423
|
message = Locale.getValue("badInput");
|
|
@@ -279,6 +433,9 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
|
|
|
279
433
|
} else if (range && this.max && parseISODate(range.end) > parseISODate(this.max)) {
|
|
280
434
|
flags = { rangeOverflow: true };
|
|
281
435
|
message = Locale.getValue("rangeOverflow", { max: this.max });
|
|
436
|
+
} else if (range && this.endpointDisabled(range)) {
|
|
437
|
+
flags = { stepMismatch: true };
|
|
438
|
+
message = Locale.getValue("dateUnavailable");
|
|
282
439
|
}
|
|
283
440
|
this.commit(flags, message, this.textInputEl ?? this.containerEl ?? void 0);
|
|
284
441
|
}
|
|
@@ -295,12 +452,17 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
|
|
|
295
452
|
this.textInputEl?.blur();
|
|
296
453
|
}
|
|
297
454
|
};
|
|
455
|
+
__decorate([property({
|
|
456
|
+
type: String,
|
|
457
|
+
reflect: true
|
|
458
|
+
}), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "size", void 0);
|
|
298
459
|
__decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDateRangePicker.prototype, "min", void 0);
|
|
299
460
|
__decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDateRangePicker.prototype, "max", void 0);
|
|
300
461
|
__decorate([property({
|
|
301
462
|
type: Boolean,
|
|
302
463
|
reflect: true
|
|
303
464
|
}), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "clearable", void 0);
|
|
465
|
+
__decorate([property({ attribute: false }), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "isDateDisabled", void 0);
|
|
304
466
|
__decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDateRangePicker.prototype, "placeholder", void 0);
|
|
305
467
|
__decorate([property({
|
|
306
468
|
type: String,
|
|
@@ -310,10 +472,24 @@ __decorate([property({
|
|
|
310
472
|
attribute: "presets",
|
|
311
473
|
converter: { fromAttribute: (v) => (v ?? "").split(/\s+/).filter(Boolean) }
|
|
312
474
|
}), __decorateMetadata("design:type", Array)], UDateRangePicker.prototype, "presets", void 0);
|
|
475
|
+
__decorate([property({
|
|
476
|
+
type: Boolean,
|
|
477
|
+
reflect: true
|
|
478
|
+
}), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "confirm", void 0);
|
|
479
|
+
__decorate([property({
|
|
480
|
+
type: String,
|
|
481
|
+
reflect: true
|
|
482
|
+
}), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "mode", void 0);
|
|
483
|
+
__decorate([property({
|
|
484
|
+
type: Boolean,
|
|
485
|
+
reflect: true
|
|
486
|
+
}), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "seconds", void 0);
|
|
313
487
|
__decorate([query(".container", true), __decorateMetadata("design:type", typeof HTMLElement === "undefined" ? Object : HTMLElement)], UDateRangePicker.prototype, "containerEl", void 0);
|
|
314
488
|
__decorate([query("u-popover", true), __decorateMetadata("design:type", typeof UPopover === "undefined" ? Object : UPopover)], UDateRangePicker.prototype, "popoverEl", void 0);
|
|
315
489
|
__decorate([query("u-calendar"), __decorateMetadata("design:type", typeof UCalendar === "undefined" ? Object : UCalendar)], UDateRangePicker.prototype, "calendarEl", void 0);
|
|
316
490
|
__decorate([state(), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "open", void 0);
|
|
491
|
+
__decorate([state(), __decorateMetadata("design:type", String)], UDateRangePicker.prototype, "staged", void 0);
|
|
492
|
+
__decorate([state(), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "pendingTimes", void 0);
|
|
317
493
|
UDateRangePicker = __decorate([customElement("u-date-range-picker")], UDateRangePicker);
|
|
318
494
|
//#endregion
|
|
319
495
|
export { UDateRangePicker };
|
|
@@ -6,7 +6,6 @@ var styles = css`
|
|
|
6
6
|
display: var(--u-date-range-picker-display, inline-block);
|
|
7
7
|
width: var(--u-date-range-picker-width, auto);
|
|
8
8
|
color: var(--u-txt-color, #212121);
|
|
9
|
-
font-size: inherit;
|
|
10
9
|
font-family: var(--u-font-base);
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -34,7 +33,7 @@ var styles = css`
|
|
|
34
33
|
.preset {
|
|
35
34
|
display: flex;
|
|
36
35
|
align-items: center;
|
|
37
|
-
min-height: 28px;
|
|
36
|
+
min-height: max(28px, var(--u-target-size, 0px));
|
|
38
37
|
padding: 0 10px;
|
|
39
38
|
border: none;
|
|
40
39
|
border-radius: var(--u-radius-md, 4px);
|
|
@@ -51,7 +50,7 @@ var styles = css`
|
|
|
51
50
|
}
|
|
52
51
|
.preset:focus-visible {
|
|
53
52
|
outline: none;
|
|
54
|
-
box-shadow: 0 0 0 2px var(--u-
|
|
53
|
+
box-shadow: 0 0 0 2px var(--u-focus-ring-color, #1565C0);
|
|
55
54
|
}
|
|
56
55
|
/* 지금 범위와 같은 프리셋 — 달력의 띠와 같은 색 축으로 «지금 이것» 을 보인다. */
|
|
57
56
|
.preset[aria-pressed="true"] {
|
|
@@ -97,6 +96,17 @@ var styles = css`
|
|
|
97
96
|
.calendar-button {
|
|
98
97
|
cursor: pointer;
|
|
99
98
|
}
|
|
99
|
+
|
|
100
|
+
/* === Size — 다른 필드·버튼과 같은 세 단 === */
|
|
101
|
+
:host {
|
|
102
|
+
font-size: var(--u-density, 14px);
|
|
103
|
+
}
|
|
104
|
+
:host([size="sm"]) {
|
|
105
|
+
font-size: 12px;
|
|
106
|
+
}
|
|
107
|
+
:host([size="lg"]) {
|
|
108
|
+
font-size: 16px;
|
|
109
|
+
}
|
|
100
110
|
`;
|
|
101
111
|
//#endregion
|
|
102
112
|
export { styles };
|
|
@@ -32,7 +32,7 @@ var UDialog = class UDialog extends UOverlayElement {
|
|
|
32
32
|
<slot name="header" @slotchange=${this.handleHeaderSlotChange}></slot>
|
|
33
33
|
<div style="flex: 1;"></div>
|
|
34
34
|
<u-button class="close-btn" part="close-btn"
|
|
35
|
-
|
|
35
|
+
appearance="plain"
|
|
36
36
|
?hidden=${!this.closable}
|
|
37
37
|
aria-label=${Locale.getValue("close")}
|
|
38
38
|
@click=${() => this.requestClose("button")}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UElement } from '../UElement.js';
|
|
2
|
-
export type
|
|
2
|
+
export type DividerLine = 'solid' | 'dashed' | 'dotted';
|
|
3
3
|
export type DividerAlign = 'start' | 'center' | 'end';
|
|
4
4
|
/**
|
|
5
5
|
* 요소 사이에 구분선을 제공하는 컴포넌트입니다.
|
|
@@ -19,8 +19,8 @@ export declare class UDivider extends UElement {
|
|
|
19
19
|
static styles: import('lit').CSSResultGroup[];
|
|
20
20
|
/** 수직 방향 여부 (기본값 수평) */
|
|
21
21
|
vertical: boolean;
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/** 선 모양 */
|
|
23
|
+
line: DividerLine;
|
|
24
24
|
/** 슬롯 콘텐츠 정렬 위치 */
|
|
25
25
|
align: DividerAlign;
|
|
26
26
|
protected render(): import('lit-html').TemplateResult<1>;
|
|
@@ -9,7 +9,7 @@ var UDivider = class UDivider extends UElement {
|
|
|
9
9
|
constructor(..._args) {
|
|
10
10
|
super(..._args);
|
|
11
11
|
this.vertical = false;
|
|
12
|
-
this.
|
|
12
|
+
this.line = "solid";
|
|
13
13
|
this.align = "center";
|
|
14
14
|
}
|
|
15
15
|
static {
|
|
@@ -38,7 +38,7 @@ __decorate([property({
|
|
|
38
38
|
__decorate([property({
|
|
39
39
|
type: String,
|
|
40
40
|
reflect: true
|
|
41
|
-
}), __decorateMetadata("design:type", Object)], UDivider.prototype, "
|
|
41
|
+
}), __decorateMetadata("design:type", Object)], UDivider.prototype, "line", void 0);
|
|
42
42
|
__decorate([property({
|
|
43
43
|
type: String,
|
|
44
44
|
reflect: true
|
|
@@ -27,11 +27,11 @@ var styles = css`
|
|
|
27
27
|
padding: var(--divider-spacing) 0;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/*
|
|
31
|
-
:host([
|
|
30
|
+
/* line */
|
|
31
|
+
:host([line="dashed"]) .line {
|
|
32
32
|
border-top-style: dashed;
|
|
33
33
|
}
|
|
34
|
-
:host([
|
|
34
|
+
:host([line="dotted"]) .line {
|
|
35
35
|
border-top-style: dotted;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -85,10 +85,10 @@ var styles = css`
|
|
|
85
85
|
border-left: var(--divider-size) solid var(--divider-color);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
:host([vertical][
|
|
88
|
+
:host([vertical][line="dashed"]) .line {
|
|
89
89
|
border-left-style: dashed;
|
|
90
90
|
}
|
|
91
|
-
:host([vertical][
|
|
91
|
+
:host([vertical][line="dotted"]) .line {
|
|
92
92
|
border-left-style: dotted;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -25,7 +25,7 @@ var UDrawer = class UDrawer extends UOverlayElement {
|
|
|
25
25
|
?hidden=${!this.hasHeader && !this.closable}>
|
|
26
26
|
<slot name="header" @slotchange=${this.handleHeaderSlotChange}></slot>
|
|
27
27
|
<u-button class="close-btn" part="close-btn"
|
|
28
|
-
|
|
28
|
+
appearance="plain"
|
|
29
29
|
?hidden=${!this.closable}
|
|
30
30
|
aria-label=${Locale.getValue("close")}
|
|
31
31
|
@click=${() => this.requestClose("button")}>
|
|
@@ -25,7 +25,7 @@ var styles = css`
|
|
|
25
25
|
width: 100%;
|
|
26
26
|
box-sizing: border-box;
|
|
27
27
|
padding: var(--u-space-sm, 8px) var(--u-space-md, 12px);
|
|
28
|
-
border: none;
|
|
28
|
+
border: none;\n /* 호스트 하한(--u-target-size, 미설정 = 0). */\n min-height: var(--u-target-size, 0px);
|
|
29
29
|
border-radius: inherit;
|
|
30
30
|
background: none;
|
|
31
31
|
color: var(--u-txt-color, #212121);
|
|
@@ -39,7 +39,7 @@ var styles = css`
|
|
|
39
39
|
cursor: default;
|
|
40
40
|
}
|
|
41
41
|
.header:focus-visible {
|
|
42
|
-
outline: 2px solid var(--u-
|
|
42
|
+
outline: 2px solid var(--u-focus-ring-color, #1565C0);
|
|
43
43
|
outline-offset: -2px;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -22,6 +22,9 @@ var styles = css`
|
|
|
22
22
|
align-items: center;
|
|
23
23
|
padding: 0.4em 0.9em;
|
|
24
24
|
border: 1px solid var(--u-input-border-color, #E0E0E0);
|
|
25
|
+
/* 호스트 하한(--u-target-size, 미설정 = 0). */
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
min-height: var(--u-target-size, 0px);
|
|
25
28
|
border-radius: 0.25em;
|
|
26
29
|
background-color: var(--u-panel-bg-color, #FFFFFF);
|
|
27
30
|
color: var(--u-primary-color, #1976D2);
|
|
@@ -36,8 +39,8 @@ var styles = css`
|
|
|
36
39
|
}
|
|
37
40
|
.trigger:focus-visible {
|
|
38
41
|
outline: none;
|
|
39
|
-
box-shadow: 0 0 0 1px var(--u-
|
|
40
|
-
0 0 0 3px color-mix(in srgb, var(--u-
|
|
42
|
+
box-shadow: 0 0 0 1px var(--u-focus-ring-color, #1565C0),
|
|
43
|
+
0 0 0 3px color-mix(in srgb, var(--u-focus-ring-color, #1565C0) 22%, transparent);
|
|
41
44
|
}
|
|
42
45
|
.trigger:disabled {
|
|
43
46
|
color: var(--u-txt-color-weak, #616161);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Placement, OffsetOptions } from '@floating-ui/dom';
|
|
2
2
|
import { UElement } from '../UElement.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ButtonAppearance } from '../button/UButton.js';
|
|
4
4
|
import { IconLibrary } from '../icon/UIcon.js';
|
|
5
5
|
/**
|
|
6
6
|
* 아이콘만 표시하는 정사각형 버튼 컴포넌트입니다.
|
|
@@ -17,7 +17,7 @@ export declare class UIconButton extends UElement {
|
|
|
17
17
|
/** 호스트의 `.focus()` 를 안쪽 컨트롤로 위임한다 — `UButton` 과 같은 계약(호스트는 포커스 가능하지 않다). */
|
|
18
18
|
static shadowRootOptions: ShadowRootInit;
|
|
19
19
|
/** 버튼 스타일 변형 */
|
|
20
|
-
|
|
20
|
+
appearance: ButtonAppearance;
|
|
21
21
|
/** 원형 표시 여부 */
|
|
22
22
|
rounded: boolean;
|
|
23
23
|
/** 비활성화 여부 */
|
|
@@ -41,7 +41,8 @@ export declare class UIconButton extends UElement {
|
|
|
41
41
|
/** 툴팁 거리 */
|
|
42
42
|
tooltipOffset: OffsetOptions;
|
|
43
43
|
/**
|
|
44
|
-
* 호스트에 세팅된 `aria-label
|
|
44
|
+
* 호스트에 세팅된 `aria-label`과 버튼 상태 ARIA(`FORWARDED_ARIA`)를 내부 `<u-button>`으로 옮긴다 —
|
|
45
|
+
* `UButton`과 같은 이유
|
|
45
46
|
* (섀도우 경계 안쪽 엘리먼트가 실제 접근 가능한 이름 대상). 아이콘 전용
|
|
46
47
|
* 버튼이라 텍스트 콘텐츠로 이름이 생기지 않으므로 이 전달이 없으면 접근 가능한 이름이
|
|
47
48
|
* 아예 비게 된다 — 내장 툴팁(`<u-tooltip>`)은 ARIA를 배선하지 않아 대체 경로가 안 된다.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UElement } from "../UElement.js";
|
|
2
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
3
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
|
+
import { FORWARDED_ARIA } from "../button/forwarded-aria.js";
|
|
4
5
|
import "../button/UButton.js";
|
|
5
6
|
import "../icon/UIcon.js";
|
|
6
7
|
import "../tooltip/UTooltip.js";
|
|
@@ -12,7 +13,7 @@ import { ifDefined } from "lit/directives/if-defined.js";
|
|
|
12
13
|
var UIconButton = class UIconButton extends UElement {
|
|
13
14
|
constructor(..._args) {
|
|
14
15
|
super(..._args);
|
|
15
|
-
this.
|
|
16
|
+
this.appearance = "plain";
|
|
16
17
|
this.rounded = false;
|
|
17
18
|
this.disabled = false;
|
|
18
19
|
this.loading = false;
|
|
@@ -29,26 +30,35 @@ var UIconButton = class UIconButton extends UElement {
|
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
|
-
* 호스트에 세팅된 `aria-label
|
|
33
|
+
* 호스트에 세팅된 `aria-label`과 버튼 상태 ARIA(`FORWARDED_ARIA`)를 내부 `<u-button>`으로 옮긴다 —
|
|
34
|
+
* `UButton`과 같은 이유
|
|
33
35
|
* (섀도우 경계 안쪽 엘리먼트가 실제 접근 가능한 이름 대상). 아이콘 전용
|
|
34
36
|
* 버튼이라 텍스트 콘텐츠로 이름이 생기지 않으므로 이 전달이 없으면 접근 가능한 이름이
|
|
35
37
|
* 아예 비게 된다 — 내장 툴팁(`<u-tooltip>`)은 ARIA를 배선하지 않아 대체 경로가 안 된다.
|
|
36
38
|
*/
|
|
37
39
|
static get observedAttributes() {
|
|
38
|
-
return [...super.observedAttributes,
|
|
40
|
+
return [...super.observedAttributes, ...FORWARDED_ARIA];
|
|
39
41
|
}
|
|
40
42
|
attributeChangedCallback(name, old, value) {
|
|
41
43
|
super.attributeChangedCallback(name, old, value);
|
|
42
|
-
if (name
|
|
44
|
+
if (FORWARDED_ARIA.includes(name)) this.requestUpdate();
|
|
43
45
|
}
|
|
44
46
|
render() {
|
|
45
47
|
const ariaLabel = this.getAttribute("aria-label") ?? void 0;
|
|
48
|
+
const pressed = this.getAttribute("aria-pressed") ?? void 0;
|
|
49
|
+
const expanded = this.getAttribute("aria-expanded") ?? void 0;
|
|
50
|
+
const haspopup = this.getAttribute("aria-haspopup") ?? void 0;
|
|
51
|
+
const controls = this.getAttribute("aria-controls") ?? void 0;
|
|
46
52
|
return html`
|
|
47
53
|
<u-button part="button"
|
|
48
54
|
aria-label=${ifDefined(ariaLabel)}
|
|
55
|
+
aria-pressed=${ifDefined(pressed)}
|
|
56
|
+
aria-expanded=${ifDefined(expanded)}
|
|
57
|
+
aria-haspopup=${ifDefined(haspopup)}
|
|
58
|
+
aria-controls=${ifDefined(controls)}
|
|
49
59
|
.disabled=${this.disabled}
|
|
50
60
|
.loading=${this.loading}
|
|
51
|
-
.
|
|
61
|
+
.appearance=${this.appearance}
|
|
52
62
|
.rounded=${this.rounded}
|
|
53
63
|
.href=${this.href}
|
|
54
64
|
.target=${this.target}
|
|
@@ -73,7 +83,7 @@ var UIconButton = class UIconButton extends UElement {
|
|
|
73
83
|
__decorate([property({
|
|
74
84
|
type: String,
|
|
75
85
|
reflect: true
|
|
76
|
-
}), __decorateMetadata("design:type", Object)], UIconButton.prototype, "
|
|
86
|
+
}), __decorateMetadata("design:type", Object)], UIconButton.prototype, "appearance", void 0);
|
|
77
87
|
__decorate([property({
|
|
78
88
|
type: Boolean,
|
|
79
89
|
reflect: true
|