@iyulab/components 2.7.0 → 2.8.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 +20 -0
- package/dist/components/UElement.d.ts +10 -0
- package/dist/components/UElement.js +18 -0
- package/dist/components/UFormControlElement.d.ts +5 -0
- package/dist/components/UFormControlElement.js +8 -0
- package/dist/components/alert/UAlert.js +16 -2
- package/dist/components/breadcrumb/UBreadcrumb.js +1 -1
- package/dist/components/calendar/UCalendar.js +1 -1
- package/dist/components/carousel/UCarousel.d.ts +2 -0
- package/dist/components/carousel/UCarousel.js +7 -1
- package/dist/components/checkbox/UCheckbox.js +1 -1
- package/dist/components/chip/UChip.js +1 -1
- package/dist/components/copy-button/UCopyButton.js +1 -1
- package/dist/components/date-picker/UDatePicker.js +1 -1
- package/dist/components/date-range-picker/UDateRangePicker.js +1 -1
- package/dist/components/dialog/UDialog.js +1 -1
- package/dist/components/drawer/UDrawer.js +1 -1
- package/dist/components/file-input/UFileInput.js +1 -1
- package/dist/components/input/UInput.d.ts +2 -0
- package/dist/components/input/UInput.js +6 -1
- package/dist/components/radio/URadio.js +1 -1
- package/dist/components/rating/URating.js +1 -1
- package/dist/components/select/USelect.js +1 -1
- package/dist/components/slider/USlider.js +1 -1
- package/dist/components/spinner/USpinner.d.ts +4 -0
- package/dist/components/spinner/USpinner.js +8 -1
- package/dist/components/split-panel/USplitPanel.d.ts +2 -0
- package/dist/components/split-panel/USplitPanel.js +6 -1
- package/dist/components/steps/USteps.js +1 -1
- package/dist/components/switch/USwitch.js +1 -1
- package/dist/components/tab/UTab.js +1 -1
- package/dist/components/textarea/UTextarea.js +1 -1
- package/dist/index.js +1 -1
- package/dist/utilities/Dialog.js +1 -1
- package/dist/utilities/Locale.d.ts +11 -0
- package/dist/utilities/Locale.js +32 -0
- package/package.json +1 -1
- package/skills/iyulab-components/references/components/alert.md +1 -1
- package/skills/iyulab-components/references/utilities/locale.md +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.8.0] - 2026-10-07
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Switching the locale at runtime updates what is already on screen.** `Locale.set()` and `Locale.register()` now
|
|
8
|
+
notify, and every connected component re-renders — including text it keeps outside its template: form validation
|
|
9
|
+
messages, `u-spinner`'s default name, `u-split-panel`'s handle name, `u-carousel`'s descriptions and slide names, the
|
|
10
|
+
decimal separator shown by `u-input type="number"`. An element detached during the change catches up when attached
|
|
11
|
+
again. Before, the old language stayed until something else re-rendered the component.
|
|
12
|
+
- `Locale.subscribe(listener)` (returns the unsubscribe function) and `Locale.revision` for your own code —
|
|
13
|
+
`useSyncExternalStore(Locale.subscribe, () => Locale.revision)` in React.
|
|
14
|
+
- `UElement.localeChanged()` — a protected hook for subclasses that keep localized text outside `render()`.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **An unknown `u-alert` `status` warning names the likely word** — `status="danger"` now warns "Did you mean
|
|
19
|
+
status="error"?" (also `warn`, `critical`, `positive` …). `status` is an outcome (`error`) while a button's or
|
|
20
|
+
badge's `color` is a palette role (`danger`); a value carried over from `color` rendered as a neutral notice with only
|
|
21
|
+
the list of valid values to go on.
|
|
22
|
+
|
|
3
23
|
## [2.7.0] - 2026-10-07
|
|
4
24
|
|
|
5
25
|
### Added
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { LitElement, CSSResultGroup, RenderOptions } from 'lit';
|
|
2
2
|
export declare class UElement extends LitElement {
|
|
3
3
|
static styles: CSSResultGroup;
|
|
4
|
+
/** 연결된 동안의 로케일 구독 해제 함수 · 떨어질 때 본 로케일 판(다시 붙을 때 그 사이 바뀌었는가를 묻는다). */
|
|
5
|
+
private unsubscribeLocale?;
|
|
6
|
+
private detachedLocaleRevision?;
|
|
4
7
|
connectedCallback(): void;
|
|
8
|
+
disconnectedCallback(): void;
|
|
9
|
+
/**
|
|
10
|
+
* 로케일이 바뀌었다(`Locale.set` · `Locale.register`) — 기본은 다시 그린다. 렌더 밖에서 로케일 문장을 담아 둔
|
|
11
|
+
* 컴포넌트(속성·`ElementInternals`·필드에 적어 둔 이름)는 이것을 재정의해 그 값을 다시 적고 `super` 를 부른다.
|
|
12
|
+
* 종전에는 런타임에 언어를 바꿔도 이미 그려진 문장이 다음 재렌더까지 옛 언어로 남았다.
|
|
13
|
+
*/
|
|
14
|
+
protected localeChanged(): void;
|
|
5
15
|
/**
|
|
6
16
|
* 커스텀 이벤트를 생성하여 발행합니다.
|
|
7
17
|
* 기본적으로 bubbles, composed, cancelable이 활성화됩니다.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { styles } from "./UElement.styles.js";
|
|
2
|
+
import { Locale } from "../utilities/Locale.js";
|
|
2
3
|
import { LitElement, render } from "lit";
|
|
3
4
|
//#region src/components/UElement.ts
|
|
4
5
|
/**
|
|
@@ -32,6 +33,23 @@ var UElement = class extends LitElement {
|
|
|
32
33
|
connectedCallback() {
|
|
33
34
|
super.connectedCallback();
|
|
34
35
|
if (process.env.NODE_ENV !== "production") warnIfTokensMissing();
|
|
36
|
+
this.unsubscribeLocale = Locale.subscribe(() => this.localeChanged());
|
|
37
|
+
if (this.detachedLocaleRevision !== void 0 && this.detachedLocaleRevision !== Locale.revision) this.localeChanged();
|
|
38
|
+
this.detachedLocaleRevision = void 0;
|
|
39
|
+
}
|
|
40
|
+
disconnectedCallback() {
|
|
41
|
+
this.unsubscribeLocale?.();
|
|
42
|
+
this.unsubscribeLocale = void 0;
|
|
43
|
+
this.detachedLocaleRevision = Locale.revision;
|
|
44
|
+
super.disconnectedCallback();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 로케일이 바뀌었다(`Locale.set` · `Locale.register`) — 기본은 다시 그린다. 렌더 밖에서 로케일 문장을 담아 둔
|
|
48
|
+
* 컴포넌트(속성·`ElementInternals`·필드에 적어 둔 이름)는 이것을 재정의해 그 값을 다시 적고 `super` 를 부른다.
|
|
49
|
+
* 종전에는 런타임에 언어를 바꿔도 이미 그려진 문장이 다음 재렌더까지 옛 언어로 남았다.
|
|
50
|
+
*/
|
|
51
|
+
localeChanged() {
|
|
52
|
+
this.requestUpdate();
|
|
35
53
|
}
|
|
36
54
|
/**
|
|
37
55
|
* 커스텀 이벤트를 생성하여 발행합니다.
|
|
@@ -75,6 +75,11 @@ export declare abstract class UFormControlElement<T> extends UElement {
|
|
|
75
75
|
/** form-associated 표준 콜백 — 조상 fieldset 의 비활성 상태가 바뀔 때 UA 가 부른다. */
|
|
76
76
|
formDisabledCallback(disabled: boolean): void;
|
|
77
77
|
connectedCallback(): void;
|
|
78
|
+
/**
|
|
79
|
+
* 검증 메시지는 `setValidity()` 가 `internals` 에 적어 둔 문장이다 — 다시 그리기만 하면 옛 언어가 그대로 나온다.
|
|
80
|
+
* 첫 렌더 뒤라면(검증이 참조하는 안쪽 컨트롤이 있을 때) 다시 계산하고 그린다.
|
|
81
|
+
*/
|
|
82
|
+
protected localeChanged(): void;
|
|
78
83
|
/**
|
|
79
84
|
* 호스트에 세팅된 `aria-label`/`aria-description` 은 접근성 트리에 노출되는 노드가 아니다 —
|
|
80
85
|
* 그것은 shadow DOM 안쪽의 네이티브 컨트롤이고, 섀도우 경계를 넘지 않으므로 자동으로
|
|
@@ -88,6 +88,14 @@ var UFormControlElement = class extends UElement {
|
|
|
88
88
|
if (!this.internals && "attachInternals" in this) this.internals = this.attachInternals();
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
|
+
* 검증 메시지는 `setValidity()` 가 `internals` 에 적어 둔 문장이다 — 다시 그리기만 하면 옛 언어가 그대로 나온다.
|
|
92
|
+
* 첫 렌더 뒤라면(검증이 참조하는 안쪽 컨트롤이 있을 때) 다시 계산하고 그린다.
|
|
93
|
+
*/
|
|
94
|
+
localeChanged() {
|
|
95
|
+
if (this.hasUpdated) this.setValidity();
|
|
96
|
+
super.localeChanged();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
91
99
|
* 호스트에 세팅된 `aria-label`/`aria-description` 은 접근성 트리에 노출되는 노드가 아니다 —
|
|
92
100
|
* 그것은 shadow DOM 안쪽의 네이티브 컨트롤이고, 섀도우 경계를 넘지 않으므로 자동으로
|
|
93
101
|
* 반영되지 않는다(속성은 붙어 있는데 접근 가능한 이름이 빈 채로 남는다).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import { UElement } from "../UElement.js";
|
|
2
3
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
3
4
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../button/UButton.js";
|
|
6
6
|
import { devWarnOnce } from "../../utilities/devWarning.js";
|
|
7
7
|
import "../icon/UIcon.js";
|
|
@@ -17,6 +17,19 @@ var ALERT_STATUSES = [
|
|
|
17
17
|
"info",
|
|
18
18
|
"notice"
|
|
19
19
|
];
|
|
20
|
+
/**
|
|
21
|
+
* 다른 축의 낱말로 쓴 `status` → 이 축의 낱말. `status` 는 **결과 상태**(alert · progress · Toast 가 `error`)이고,
|
|
22
|
+
* 버튼·배지·태그의 `color` 는 **팔레트 역할**(`danger`)이다 — 두 축이 다른 낱말을 쓰는 것은 의도지만, 소비자가
|
|
23
|
+
* `color` 의 낱말을 그대로 옮겨 `status="danger"` 로 화면 셋을 내보낸 실측이 있어 경고가 맞는 낱말을 함께 말한다.
|
|
24
|
+
*/
|
|
25
|
+
var STATUS_SYNONYMS = {
|
|
26
|
+
danger: "error",
|
|
27
|
+
critical: "error",
|
|
28
|
+
negative: "error",
|
|
29
|
+
warn: "warning",
|
|
30
|
+
positive: "success",
|
|
31
|
+
information: "info"
|
|
32
|
+
};
|
|
20
33
|
var UAlert = class UAlert extends UElement {
|
|
21
34
|
constructor(..._args) {
|
|
22
35
|
super(..._args);
|
|
@@ -125,7 +138,8 @@ var UAlert = class UAlert extends UElement {
|
|
|
125
138
|
warnUnknownStatus() {
|
|
126
139
|
const status = this.status;
|
|
127
140
|
if (!status || ALERT_STATUSES.includes(status)) return;
|
|
128
|
-
|
|
141
|
+
const suggestion = STATUS_SYNONYMS[status.toLowerCase()];
|
|
142
|
+
devWarnOnce(`u-alert:status:${status}`, `<u-alert status="${status}"> is not a known status, so it renders as a neutral notice. ` + (suggestion ? `Did you mean status="${suggestion}"? ` : "") + `Use one of: ${ALERT_STATUSES.join(", ")}.`);
|
|
129
143
|
}
|
|
130
144
|
/** Alert 상태에 따른 아이콘 이름을 반환합니다. */
|
|
131
145
|
mapIcon(status) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import { UElement } from "../UElement.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
4
4
|
import "../icon/UIcon.js";
|
|
5
5
|
import { styles } from "./UBreadcrumb.styles.js";
|
|
6
6
|
import { html } from "lit";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import { UElement } from "../UElement.js";
|
|
2
3
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
3
4
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../icon-button/UIconButton.js";
|
|
6
6
|
import { formatDate } from "../../utilities/format.js";
|
|
7
7
|
import { addDays, addMonths, daysInMonth, isDayUnavailable, isSameDay, monthDiff, parseISODate, startOfMonth, toISODate } from "./dates.js";
|
|
@@ -80,6 +80,8 @@ export declare class UCarousel extends UElement {
|
|
|
80
80
|
private startAutoplay;
|
|
81
81
|
private stopAutoplay;
|
|
82
82
|
private handleSlotChange;
|
|
83
|
+
/** 렌더 밖에서 적어 둔 로케일 문장(호스트 역할 설명 · 슬라이드 이름)을 새 로케일로 다시 적는다. */
|
|
84
|
+
protected localeChanged(): void;
|
|
83
85
|
/** 슬라이드를 «n / 전체» 이름의 그룹으로 — 처음 볼 때 비어 있던 속성만 우리 것으로 삼고, 그것만 갱신한다. */
|
|
84
86
|
private labelSlide;
|
|
85
87
|
/** 슬롯을 떠난 슬라이드에서 우리가 단 속성을 걷는다. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import { UElement } from "../UElement.js";
|
|
2
3
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
3
4
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../button/UButton.js";
|
|
6
6
|
import "../icon/UIcon.js";
|
|
7
7
|
import { styles } from "./UCarousel.styles.js";
|
|
@@ -243,6 +243,12 @@ var UCarousel = class UCarousel extends UElement {
|
|
|
243
243
|
this.slideCount = next.length;
|
|
244
244
|
if (this.index >= this.slideCount) this.index = Math.max(0, this.slideCount - 1);
|
|
245
245
|
}
|
|
246
|
+
/** 렌더 밖에서 적어 둔 로케일 문장(호스트 역할 설명 · 슬라이드 이름)을 새 로케일로 다시 적는다. */
|
|
247
|
+
localeChanged() {
|
|
248
|
+
if (this.internals) this.internals.ariaRoleDescription = Locale.getValue("carousel");
|
|
249
|
+
this.slides.forEach((slide, i) => this.labelSlide(slide, i, this.slides.length));
|
|
250
|
+
super.localeChanged();
|
|
251
|
+
}
|
|
246
252
|
/** 슬라이드를 «n / 전체» 이름의 그룹으로 — 처음 볼 때 비어 있던 속성만 우리 것으로 삼고, 그것만 갱신한다. */
|
|
247
253
|
labelSlide(slide, i, total) {
|
|
248
254
|
let owned = this.ownedSlideAttrs.get(slide);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../icon/UIcon.js";
|
|
6
6
|
import { styles } from "./UCheckbox.styles.js";
|
|
7
7
|
import { html } from "lit";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import { UElement } from "../UElement.js";
|
|
2
3
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
3
4
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../button/UButton.js";
|
|
6
6
|
import "../icon/UIcon.js";
|
|
7
7
|
import "../tooltip/UTooltip.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import { UElement } from "../UElement.js";
|
|
2
3
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
3
4
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../button/UButton.js";
|
|
6
6
|
import "../icon/UIcon.js";
|
|
7
7
|
import "../icon-button/UIconButton.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../button/UButton.js";
|
|
6
6
|
import "../icon/UIcon.js";
|
|
7
7
|
import { dateTextPattern, formatDateText, formatDateTimeText, parseDate, parseDateTime } from "../../utilities/format.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../button/UButton.js";
|
|
6
6
|
import { devWarnOnce } from "../../utilities/devWarning.js";
|
|
7
7
|
import "../icon/UIcon.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UOverlayElement } from "../UOverlayElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../button/UButton.js";
|
|
6
6
|
import "../icon/UIcon.js";
|
|
7
7
|
import { styles } from "./UDialog.styles.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UOverlayElement } from "../UOverlayElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../button/UButton.js";
|
|
6
6
|
import "../icon/UIcon.js";
|
|
7
7
|
import { styles } from "./UDrawer.styles.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../icon/UIcon.js";
|
|
6
6
|
import "../field/UField.js";
|
|
7
7
|
import { styles } from "./UFileInput.styles.js";
|
|
@@ -115,6 +115,8 @@ export declare class UInput extends UFormControlElement<string> {
|
|
|
115
115
|
* `string`이라 `valueAsString` 같은 변환 없이 그대로 넘긴다. */
|
|
116
116
|
protected willUpdate(changedProperties: PropertyValues): void;
|
|
117
117
|
protected updated(changedProperties: PropertyValues): void;
|
|
118
|
+
/** The shown number uses the locale's decimal separator — re-show it in the new locale (unless the user is typing in it). */
|
|
119
|
+
protected localeChanged(): void;
|
|
118
120
|
/** Canonical `value` → the text shown: the locale's decimal separator, no grouping inserted. */
|
|
119
121
|
private displayNumber;
|
|
120
122
|
/** Writes what the user typed into `value` (canonical, or `""` when it is not a number). */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
5
|
import { isImeComposing } from "../../utilities/keyboard.js";
|
|
5
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
6
6
|
import "../spinner/USpinner.js";
|
|
7
7
|
import "../icon/UIcon.js";
|
|
8
8
|
import { parseNumber } from "../../utilities/format.js";
|
|
@@ -305,6 +305,11 @@ var UInput = class UInput extends UFormControlElement {
|
|
|
305
305
|
super.updated(changedProperties);
|
|
306
306
|
if (changedProperties.has("value")) this.internals?.setFormValue(this.value ?? "");
|
|
307
307
|
}
|
|
308
|
+
/** The shown number uses the locale's decimal separator — re-show it in the new locale (unless the user is typing in it). */
|
|
309
|
+
localeChanged() {
|
|
310
|
+
if (this.type === "number" && this.shadowRoot?.activeElement !== this.inputEl) this.numberText = this.displayNumber(this.value ?? "");
|
|
311
|
+
super.localeChanged();
|
|
312
|
+
}
|
|
308
313
|
/** Canonical `value` → the text shown: the locale's decimal separator, no grouping inserted. */
|
|
309
314
|
displayNumber(value) {
|
|
310
315
|
if ((value ? parseNumber(value, "en") : null) === null) return value;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../field/UField.js";
|
|
6
6
|
import { UOption } from "../option/UOption.js";
|
|
7
7
|
import { styles } from "./URadio.styles.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../icon/UIcon.js";
|
|
6
6
|
import "../field/UField.js";
|
|
7
7
|
import { styles } from "./URating.styles.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../spinner/USpinner.js";
|
|
6
6
|
import "../icon/UIcon.js";
|
|
7
7
|
import "../field/UField.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../tooltip/UTooltip.js";
|
|
6
6
|
import "../field/UField.js";
|
|
7
7
|
import { styles } from "./USlider.styles.js";
|
|
@@ -25,7 +25,11 @@ export declare class USpinner extends UElement {
|
|
|
25
25
|
*/
|
|
26
26
|
private readonly internals;
|
|
27
27
|
connectedCallback(): void;
|
|
28
|
+
/** 이름으로 쓰는 보이는 글자(없으면 로케일의 «로딩 중»). */
|
|
29
|
+
private slotText;
|
|
28
30
|
private nameFrom;
|
|
31
|
+
/** 글자가 없을 때의 기본 이름은 로케일 문장이다 — 새 로케일로 다시 적는다. */
|
|
32
|
+
protected localeChanged(): void;
|
|
29
33
|
render(): import('lit-html').TemplateResult<1>;
|
|
30
34
|
private handleSlotChange;
|
|
31
35
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import { UElement } from "../UElement.js";
|
|
2
3
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
3
4
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
5
|
import { styles } from "./USpinner.styles.js";
|
|
5
6
|
import { attachProgressbar } from "../../utilities/progressAria.js";
|
|
6
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
7
7
|
import { html } from "lit";
|
|
8
8
|
import { customElement, property, state } from "lit/decorators.js";
|
|
9
9
|
//#region src/components/spinner/USpinner.ts
|
|
@@ -12,6 +12,7 @@ var USpinner = class USpinner extends UElement {
|
|
|
12
12
|
super(..._args);
|
|
13
13
|
this.hasLabel = false;
|
|
14
14
|
this.internals = attachProgressbar(this);
|
|
15
|
+
this.slotText = "";
|
|
15
16
|
}
|
|
16
17
|
static {
|
|
17
18
|
this.styles = [super.styles, styles];
|
|
@@ -21,8 +22,14 @@ var USpinner = class USpinner extends UElement {
|
|
|
21
22
|
this.nameFrom("");
|
|
22
23
|
}
|
|
23
24
|
nameFrom(text) {
|
|
25
|
+
this.slotText = text;
|
|
24
26
|
if (this.internals) this.internals.ariaLabel = text || Locale.getValue("loading");
|
|
25
27
|
}
|
|
28
|
+
/** 글자가 없을 때의 기본 이름은 로케일 문장이다 — 새 로케일로 다시 적는다. */
|
|
29
|
+
localeChanged() {
|
|
30
|
+
this.nameFrom(this.slotText);
|
|
31
|
+
super.localeChanged();
|
|
32
|
+
}
|
|
26
33
|
render() {
|
|
27
34
|
return html`
|
|
28
35
|
<svg class="spinner" part="svg">
|
|
@@ -68,6 +68,8 @@ export declare class USplitPanel extends UElement {
|
|
|
68
68
|
* 값은 **앞 패널(primary pane)의 몫**이다. 패널이 셋 이상이면 한 핸들은 이웃한 두 패널 사이만
|
|
69
69
|
* 옮기므로 최대값은 100 이 아니라 그 두 패널의 몫의 합이다.
|
|
70
70
|
*/
|
|
71
|
+
/** 핸들 이름(«패널 크기 조절»)은 템플릿 밖에 적어 둔 로케일 문장이다 — 새 로케일로 다시 적는다. */
|
|
72
|
+
protected localeChanged(): void;
|
|
71
73
|
private syncSplitterAria;
|
|
72
74
|
/** 방향키 한 번이 옮기는 앞 패널의 몫(나머지 공간 기준 %). */
|
|
73
75
|
private static readonly KEY_STEP;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import { UElement } from "../UElement.js";
|
|
2
3
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
3
4
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
5
|
import { arrayAttrConverter } from "../../utilities/converters.js";
|
|
5
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
6
6
|
import { devWarnOnce } from "../../utilities/devWarning.js";
|
|
7
7
|
import { styles } from "./USplitPanel.styles.js";
|
|
8
8
|
import { html } from "lit";
|
|
@@ -287,6 +287,11 @@ var USplitPanel = class USplitPanel extends UElement {
|
|
|
287
287
|
* 값은 **앞 패널(primary pane)의 몫**이다. 패널이 셋 이상이면 한 핸들은 이웃한 두 패널 사이만
|
|
288
288
|
* 옮기므로 최대값은 100 이 아니라 그 두 패널의 몫의 합이다.
|
|
289
289
|
*/
|
|
290
|
+
/** 핸들 이름(«패널 크기 조절»)은 템플릿 밖에 적어 둔 로케일 문장이다 — 새 로케일로 다시 적는다. */
|
|
291
|
+
localeChanged() {
|
|
292
|
+
this.syncSplitterAria();
|
|
293
|
+
super.localeChanged();
|
|
294
|
+
}
|
|
290
295
|
syncSplitterAria() {
|
|
291
296
|
const root = this.renderRoot;
|
|
292
297
|
if (!root) return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import { UElement } from "../UElement.js";
|
|
2
3
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
3
4
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import { styles } from "./USteps.styles.js";
|
|
6
6
|
import { html, nothing } from "lit";
|
|
7
7
|
import { customElement, property } from "lit/decorators.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import { styles } from "./USwitch.styles.js";
|
|
6
6
|
import { html } from "lit";
|
|
7
7
|
import { customElement, property, query } from "lit/decorators.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import { UElement } from "../UElement.js";
|
|
2
3
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
3
4
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../button/UButton.js";
|
|
6
6
|
import "../icon/UIcon.js";
|
|
7
7
|
import { styles } from "./UTab.styles.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Locale } from "../../utilities/Locale.js";
|
|
1
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorateMetadata.js";
|
|
2
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/decorate.js";
|
|
3
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
4
|
-
import { Locale } from "../../utilities/Locale.js";
|
|
5
5
|
import "../field/UField.js";
|
|
6
6
|
import { styles } from "./UTextarea.styles.js";
|
|
7
7
|
import { html } from "lit";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Locale } from "./utilities/Locale.js";
|
|
1
2
|
import { UElement } from "./components/UElement.js";
|
|
2
3
|
import { getParentElement, isCoarsePointer, isFocusCandidate, querySelectorAllWithin, querySelectorDeep, querySelectorWithin } from "./utilities/elements.js";
|
|
3
4
|
import { UFloatingElement } from "./components/UFloatingElement.js";
|
|
@@ -6,7 +7,6 @@ import { isImeComposing } from "./utilities/keyboard.js";
|
|
|
6
7
|
import { OverlayManager } from "./utilities/OverlayManager.js";
|
|
7
8
|
import { arrayAttrConverter, booleanAttrConverter, dateAttrConverter, jsonAttrConverter, urlAttrConverter } from "./utilities/converters.js";
|
|
8
9
|
import { UOverlayElement } from "./components/UOverlayElement.js";
|
|
9
|
-
import { Locale } from "./utilities/Locale.js";
|
|
10
10
|
import { USpinner } from "./components/spinner/USpinner.js";
|
|
11
11
|
import { UButton } from "./components/button/UButton.js";
|
|
12
12
|
import { IconCache, IconRegistry, getDefaultBaseUrl, setDefaultBaseUrl } from "./utilities/icons.js";
|
package/dist/utilities/Dialog.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isImeComposing } from "./keyboard.js";
|
|
2
1
|
import { Locale } from "./Locale.js";
|
|
2
|
+
import { isImeComposing } from "./keyboard.js";
|
|
3
3
|
import "../components/button/UButton.js";
|
|
4
4
|
import { UDialog } from "../components/dialog/UDialog.js";
|
|
5
5
|
import "../components/input/UInput.js";
|
|
@@ -53,6 +53,17 @@ export declare class Locale {
|
|
|
53
53
|
private constructor();
|
|
54
54
|
/** 전역 활성 로케일을 지정합니다. */
|
|
55
55
|
static set(locale: LocaleTag): void;
|
|
56
|
+
/**
|
|
57
|
+
* 로케일이 바뀔 때(활성 로케일 전환 · 표 등록) 부를 함수를 등록하고, **구독을 푸는 함수**를 돌려줍니다.
|
|
58
|
+
* `UElement` 계열은 연결된 동안 스스로 구독해 다시 그리므로, 이것은 그 밖의 코드 — 직접 만든 요소, 앱 상태 —
|
|
59
|
+
* 를 위한 것입니다. React 에서는 `useSyncExternalStore(Locale.subscribe, () => Locale.revision)`.
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* 로케일이 바뀔 때마다(구독자에게 알릴 때마다) 하나씩 느는 수 — «내가 마지막으로 본 뒤 바뀌었는가» 를 묻는 값.
|
|
63
|
+
* `get()` 은 표 등록으로 문장이 바뀌어도 그대로이므로, 스냅샷·캐시 키로는 이것을 쓴다.
|
|
64
|
+
*/
|
|
65
|
+
static get revision(): number;
|
|
66
|
+
static subscribe(listener: () => void): () => void;
|
|
56
67
|
/** 전역 활성 로케일을 반환합니다 (초기값은 `<html lang>` → 브라우저 언어 자동 감지, 실패 시 'en'). */
|
|
57
68
|
static get(): LocaleTag;
|
|
58
69
|
/**
|
package/dist/utilities/Locale.js
CHANGED
|
@@ -50,6 +50,16 @@ function detectLocale() {
|
|
|
50
50
|
}
|
|
51
51
|
var active = detectLocale();
|
|
52
52
|
/**
|
|
53
|
+
* 로케일이 바뀌었음을 들을 곳 — 활성 로케일 전환(`set`)과 표 등록(`register`, 네임스페이스 포함).
|
|
54
|
+
* 이것이 없으면 이미 그려진 문장은 다음 재렌더까지 옛 언어로 남았다(런타임 언어 전환의 절반이 비었다).
|
|
55
|
+
*/
|
|
56
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
57
|
+
var revision = 0;
|
|
58
|
+
function notify() {
|
|
59
|
+
revision++;
|
|
60
|
+
for (const listener of [...listeners]) listener();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
53
63
|
* 내장 표가 **지역형으로만** 있는 언어의 기본 지역형 — 키는 태그의 접두(소문자).
|
|
54
64
|
*
|
|
55
65
|
* ⚠`lang="zh"`·`"pt"` 처럼 지역 없는 태그는 흔하고 정당하다(BCP 47). 사슬이 접두를 줄여 가기만
|
|
@@ -103,7 +113,27 @@ var Locale = class {
|
|
|
103
113
|
constructor() {}
|
|
104
114
|
/** 전역 활성 로케일을 지정합니다. */
|
|
105
115
|
static set(locale) {
|
|
116
|
+
if (locale === active) return;
|
|
106
117
|
active = locale;
|
|
118
|
+
notify();
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* 로케일이 바뀔 때(활성 로케일 전환 · 표 등록) 부를 함수를 등록하고, **구독을 푸는 함수**를 돌려줍니다.
|
|
122
|
+
* `UElement` 계열은 연결된 동안 스스로 구독해 다시 그리므로, 이것은 그 밖의 코드 — 직접 만든 요소, 앱 상태 —
|
|
123
|
+
* 를 위한 것입니다. React 에서는 `useSyncExternalStore(Locale.subscribe, () => Locale.revision)`.
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
* 로케일이 바뀔 때마다(구독자에게 알릴 때마다) 하나씩 느는 수 — «내가 마지막으로 본 뒤 바뀌었는가» 를 묻는 값.
|
|
127
|
+
* `get()` 은 표 등록으로 문장이 바뀌어도 그대로이므로, 스냅샷·캐시 키로는 이것을 쓴다.
|
|
128
|
+
*/
|
|
129
|
+
static get revision() {
|
|
130
|
+
return revision;
|
|
131
|
+
}
|
|
132
|
+
static subscribe(listener) {
|
|
133
|
+
listeners.add(listener);
|
|
134
|
+
return () => {
|
|
135
|
+
listeners.delete(listener);
|
|
136
|
+
};
|
|
107
137
|
}
|
|
108
138
|
/** 전역 활성 로케일을 반환합니다 (초기값은 `<html lang>` → 브라우저 언어 자동 감지, 실패 시 'en'). */
|
|
109
139
|
static get() {
|
|
@@ -120,6 +150,7 @@ var Locale = class {
|
|
|
120
150
|
...current,
|
|
121
151
|
...table
|
|
122
152
|
});
|
|
153
|
+
notify();
|
|
123
154
|
}
|
|
124
155
|
/**
|
|
125
156
|
* 현재 활성 로케일 기준으로 메시지를 조회합니다.
|
|
@@ -155,6 +186,7 @@ var Locale = class {
|
|
|
155
186
|
...table
|
|
156
187
|
});
|
|
157
188
|
namespaces.set(name, byLocale);
|
|
189
|
+
notify();
|
|
158
190
|
},
|
|
159
191
|
text: (key, params) => textIn(void 0, key, params),
|
|
160
192
|
textIn
|
package/package.json
CHANGED
|
@@ -35,7 +35,7 @@ Closable message banner with status icons, auto-dismiss timer, and open/hide tra
|
|
|
35
35
|
| `open` | `boolean` | `false` | ✓ | Show/hide the alert |
|
|
36
36
|
| `closable` | `boolean` | `false` | ✓ | Show close button |
|
|
37
37
|
| `appearance` | `'soft'\|'outlined'` | `'soft'` | ✓ | `soft` status-colour tint, no outline · `outlined` status-colour border on a transparent face |
|
|
38
|
-
| `status` | `'error'\|'warning'\|'success'\|'info'\|'notice'` | — | ✓ | Status type; controls icon and color |
|
|
38
|
+
| `status` | `'error'\|'warning'\|'success'\|'info'\|'notice'` | — | ✓ | Status type; controls icon, color and role (`error`/`warning` are `role="alert"`). An outcome word, not a palette word — buttons and badges say `color="danger"`, an alert says `status="error"`; an unknown value renders as a neutral notice and warns in development, naming the likely word |
|
|
39
39
|
| `title` | `string` | `''` | — | Title label. Left empty, the status name in the current locale is shown (`Locale.set('ko')` → 「오류」), not the raw status value |
|
|
40
40
|
| `duration` | `number` | `0` | — | Auto-dismiss delay in ms; `0` disables |
|
|
41
41
|
|
|
@@ -40,6 +40,21 @@ same chain.
|
|
|
40
40
|
| `Locale.register(locale, table)` | Register/override locale messages (partial merge supported) |
|
|
41
41
|
| `Locale.getValue(key, params?, locale?)` | Resolve a localized message for the current locale (or `locale`, along its fallback chain) |
|
|
42
42
|
| `Locale.namespace(name)` | A string table for a package or app area, keyed by its own union — returns a handle (below) |
|
|
43
|
+
| `Locale.subscribe(listener)` | Call `listener` whenever the locale changes (`set` to another locale, any `register`) — returns the unsubscribe function |
|
|
44
|
+
| `Locale.revision` | A number that grows on every change — a snapshot or cache key (`get()` stays the same when only a table changes) |
|
|
45
|
+
|
|
46
|
+
### Switching at runtime
|
|
47
|
+
|
|
48
|
+
`Locale.set()` and `Locale.register()` take effect on screen at once: every connected component
|
|
49
|
+
re-renders, including text it keeps outside its template — validation messages, accessible names,
|
|
50
|
+
the decimal separator of a number field. An element detached during the change catches up when it
|
|
51
|
+
is attached again. Your own code subscribes the same way:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const off = Locale.subscribe(() => renderMyView());
|
|
55
|
+
// React
|
|
56
|
+
const revision = useSyncExternalStore(Locale.subscribe, () => Locale.revision);
|
|
57
|
+
```
|
|
43
58
|
|
|
44
59
|
### Namespaces
|
|
45
60
|
|