@iyulab/components 2.20.3 → 2.22.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 +64 -0
- package/dist/components/UElement.d.ts +5 -1
- package/dist/components/UElement.js +9 -2
- package/dist/components/UFormControlElement.d.ts +7 -0
- package/dist/components/UFormControlElement.js +11 -0
- package/dist/components/calendar/datetime.d.ts +2 -3
- package/dist/components/calendar/datetime.js +3 -15
- package/dist/components/checkbox/UCheckbox.d.ts +3 -0
- package/dist/components/checkbox/UCheckbox.js +7 -0
- package/dist/components/form/UForm.js +2 -2
- package/dist/components/input/UInput.js +2 -2
- package/dist/components/select/USelect.d.ts +25 -5
- package/dist/components/select/USelect.js +25 -10
- package/dist/components/switch/USwitch.d.ts +3 -0
- package/dist/components/switch/USwitch.js +7 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -1
- package/dist/react/USelect.d.ts +2 -1
- package/dist/utilities/Locale.d.ts +21 -9
- package/dist/utilities/Locale.js +26 -0
- package/dist/utilities/composition.d.ts +43 -0
- package/dist/utilities/composition.js +76 -0
- package/dist/utilities/dateValue.d.ts +36 -0
- package/dist/utilities/dateValue.js +79 -0
- package/dist/utilities/format.js +8 -17
- package/dist/utilities/search.d.ts +29 -0
- package/dist/utilities/search.js +151 -0
- package/package.json +1 -1
- package/skills/iyulab-components/SKILL.md +2 -2
- package/skills/iyulab-components/references/components/form.md +2 -2
- package/skills/iyulab-components/references/components/select.md +1 -1
- package/skills/iyulab-components/references/extensions/element.md +1 -1
- package/skills/iyulab-components/references/extensions/form-control.md +6 -0
- package/skills/iyulab-components/references/utilities/format.md +29 -3
- package/skills/iyulab-components/references/utilities/keyboard.md +38 -0
- package/skills/iyulab-components/references/utilities/locale.md +26 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,69 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.22.0] - 2026-10-13
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `u-select` `search` carries `detail.composing` — `true` while an IME composition (Korean, Japanese, Chinese) is in
|
|
8
|
+
progress, so `query` ends in a partial syllable (`ㅅ`, `성` on the way to `서울`). When the composition ends the event
|
|
9
|
+
fires again with `composing: false` and the finished text; Chromium sends no plain `input` at that point, so a
|
|
10
|
+
consumer that skipped composing events had no way to see the finished query. A consumer that searches a server can
|
|
11
|
+
now skip composing queries. `search` no longer repeats an unchanged query.
|
|
12
|
+
- **Search matching** — `Locale.matchesSearch(text, query, options?)` and `Locale.registerSearch(locale, matcher)`. The
|
|
13
|
+
default rule folds case and diacritics and compares Hangul syllables whole; with `composing: true` the query's last
|
|
14
|
+
syllable, still being typed, is compared as the jamo in typing order, so it matches the word it is becoming (`성`
|
|
15
|
+
and `서우` match `서울`). A query of consonants only matches initials (`ㅅㅇ` finds `서울`). `defaultSearchMatch`,
|
|
16
|
+
`foldForSearch`, `hangulKeystrokes` and `initialsOf` are exported from `utilities/search`;
|
|
17
|
+
`CompositionTracker.searchQuery(input)` gives the query and the flag together.
|
|
18
|
+
`u-select searchable` filters with it — typing `서울` with a Korean IME narrows to `서울` and `성남` at `성` and to
|
|
19
|
+
`서울` at `서우`, instead of waiting for the syllable to be committed. A language's own rule is registered with
|
|
20
|
+
`registerSearch`.
|
|
21
|
+
- `CompositionTracker` and `replayInput` (`utilities/composition`) — for an input that filters or searches as you type.
|
|
22
|
+
Attach a tracker to the input's `compositionstart`, `compositionupdate` and `compositionend`; `composing` says an IME
|
|
23
|
+
composition is in progress and `settled(input)` gives the text without the syllable still being composed. Filtering
|
|
24
|
+
on the settled text never hides an item the finished text would match. `new CompositionTracker(replayInput)` re-runs
|
|
25
|
+
the input's own `input` handler when the composition ends, for an input that waits until then.
|
|
26
|
+
- `modelValue` on form controls — the value a `u-form` reads into and writes from its `model`. It is `value` by
|
|
27
|
+
default; `u-checkbox` and `u-switch` exchange `checked`. A custom control whose state lives in another property
|
|
28
|
+
overrides it.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- `u-select searchable` no longer hides options or announces "No matches" for a syllable still being composed. It
|
|
33
|
+
filtered on every composition step, so typing «서울» with a Korean IME showed no options and announced "No matches"
|
|
34
|
+
at «ㅅ», and showed only «성남» at «성». While composing it now filters on the committed part only, which never hides
|
|
35
|
+
an option the finished text would match; "No matches" appears only when the committed part already matches nothing.
|
|
36
|
+
- `u-input` keeps `value` in step with the box during an IME composition. It used to update only when the composition
|
|
37
|
+
ended, so the `input` events an ancestor received during composition read an old value (`undefined` or the previous
|
|
38
|
+
syllable while the box showed «서울»). These events are now re-dispatched from the host and keep `isComposing`.
|
|
39
|
+
- Events re-dispatched from a control's host now bubble and cross shadow roots. `relay()` copied the original event
|
|
40
|
+
with object spread, which does not include `bubbles`, `composed`, `cancelable` or `InputEvent` fields (they are
|
|
41
|
+
prototype getters), so the re-dispatched event reached only listeners on the host itself. Affected: `change` from
|
|
42
|
+
`u-checkbox`, `u-switch`, `u-textarea` and `u-file-input`, and `input` from `u-input` and `u-textarea`. A listener
|
|
43
|
+
on an ancestor — a delegated handler, a dirty-state tracker, `u-form` — now receives each of these once, and
|
|
44
|
+
`InputEvent.data` and `inputType` are kept.
|
|
45
|
+
- `u-form` keeps `model` in step with checkboxes and switches in both directions. It used to read and write their
|
|
46
|
+
`value` (the submitted text), so a checked box put `undefined` in the model and `model.agree = true` did not check
|
|
47
|
+
the box. With the propagation fix above, user edits in a checkbox, switch, textarea or file input now update
|
|
48
|
+
`model` — before, only `u-input` reached it.
|
|
49
|
+
|
|
50
|
+
## [2.21.0] - 2026-10-12
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
|
|
54
|
+
- **Date values** — `readDateValue(value)` reads the three kinds of date text an app receives and says which
|
|
55
|
+
one it is: `instant` (a date-time with `Z` or an offset — that moment), `plainDateTime` (no offset — local wall
|
|
56
|
+
clock) and `plainDate` (`YYYY-MM-DD` — local midnight, not UTC midnight). It returns `null` for a day or time that
|
|
57
|
+
does not exist (`2026-02-30`) instead of a rolled-over date. `writeInstant`, `writePlainDateTime`,
|
|
58
|
+
`writePlainDate` and `localOffset` write a date back in the kind it was read. The date pickers and `formatDate`
|
|
59
|
+
read through it.
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
- `formatDate` shows ISO-shaped text that names no real day (`2026-02-30`) as the text itself, as it does for
|
|
64
|
+
other invalid input — it used to format the rolled-over date (March 2). Text that is not ISO-shaped still goes
|
|
65
|
+
to the platform parser.
|
|
66
|
+
|
|
3
67
|
## [2.20.3] - 2026-10-12
|
|
4
68
|
|
|
5
69
|
### Fixed
|
|
@@ -33,9 +33,13 @@ export declare class UElement extends LitElement {
|
|
|
33
33
|
protected fire<T>(name: string, options?: CustomEventInit): boolean;
|
|
34
34
|
/**
|
|
35
35
|
* 네이티브 이벤트를 호스트 엘리먼트에서 (재)발행합니다.
|
|
36
|
-
* 기존 이벤트를 전달하면 원본을 중단하고 동일
|
|
36
|
+
* 기존 이벤트를 전달하면 원본을 중단하고 동일 타입·동일 초기값으로 재발행하며,
|
|
37
37
|
* 새 이벤트를 직접 전달할 수도 있습니다.
|
|
38
38
|
*
|
|
39
|
+
* 재발행한 이벤트는 원본의 `bubbles`·`cancelable` 과 타입별 값(`InputEvent` 의 `data`·`inputType`,
|
|
40
|
+
* `CustomEvent` 의 `detail` 등)을 잇고, 호스트가 공개 경계이므로 `composed: true` 로 섀도를 넘는다
|
|
41
|
+
* (`fire()` 와 같은 전파). 네이티브 `change` 처럼 원본이 섀도 안에 머무는 이벤트도 호스트의 조상에 닿는다.
|
|
42
|
+
*
|
|
39
43
|
* @param event - 재발행할 이벤트 또는 새로 생성한 네이티브 이벤트
|
|
40
44
|
* @param options - EventInit 오버라이드
|
|
41
45
|
* @returns preventDefault가 호출되지 않았으면 true
|
|
@@ -90,18 +90,25 @@ var UElement = class extends LitElement {
|
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* 네이티브 이벤트를 호스트 엘리먼트에서 (재)발행합니다.
|
|
93
|
-
* 기존 이벤트를 전달하면 원본을 중단하고 동일
|
|
93
|
+
* 기존 이벤트를 전달하면 원본을 중단하고 동일 타입·동일 초기값으로 재발행하며,
|
|
94
94
|
* 새 이벤트를 직접 전달할 수도 있습니다.
|
|
95
95
|
*
|
|
96
|
+
* 재발행한 이벤트는 원본의 `bubbles`·`cancelable` 과 타입별 값(`InputEvent` 의 `data`·`inputType`,
|
|
97
|
+
* `CustomEvent` 의 `detail` 등)을 잇고, 호스트가 공개 경계이므로 `composed: true` 로 섀도를 넘는다
|
|
98
|
+
* (`fire()` 와 같은 전파). 네이티브 `change` 처럼 원본이 섀도 안에 머무는 이벤트도 호스트의 조상에 닿는다.
|
|
99
|
+
*
|
|
96
100
|
* @param event - 재발행할 이벤트 또는 새로 생성한 네이티브 이벤트
|
|
97
101
|
* @param options - EventInit 오버라이드
|
|
98
102
|
* @returns preventDefault가 호출되지 않았으면 true
|
|
99
103
|
*/
|
|
100
104
|
relay(event, options) {
|
|
101
105
|
event.stopImmediatePropagation();
|
|
106
|
+
const init = {};
|
|
107
|
+
for (const key in event) init[key] = event[key];
|
|
102
108
|
const ctor = event.constructor;
|
|
103
109
|
return this.dispatchEvent(new ctor(event.type, {
|
|
104
|
-
...
|
|
110
|
+
...init,
|
|
111
|
+
composed: true,
|
|
105
112
|
...options
|
|
106
113
|
}));
|
|
107
114
|
}
|
|
@@ -38,6 +38,13 @@ export declare abstract class UFormControlElement<T> extends UElement {
|
|
|
38
38
|
* (이전의 type: Object는 JSON.parse 실패로 일반 문자열 attribute가 silently null이 되는 갭이 있었다)
|
|
39
39
|
* string이 아닌 값 타입을 갖는 컨트롤(URating/USlider/USelect multiple)은 자신의 converter로 override한다. */
|
|
40
40
|
value?: T;
|
|
41
|
+
/**
|
|
42
|
+
* `u-form` 의 `model` 과 주고받는 값. 기본은 `value` 다.
|
|
43
|
+
* 상태를 다른 속성에 두는 컨트롤(체크박스 · 스위치의 `checked`)은 그 상태를 돌려주고 받도록 재정의한다 —
|
|
44
|
+
* 제출값(`value`)과 모델이 담을 상태는 다를 수 있다.
|
|
45
|
+
*/
|
|
46
|
+
get modelValue(): unknown;
|
|
47
|
+
set modelValue(value: unknown);
|
|
41
48
|
/**
|
|
42
49
|
* ElementInternals는 폼과의 연동, 유효성 검사 상태 관리 등을 지원하는 네이티브 API입니다.
|
|
43
50
|
*/
|
|
@@ -23,6 +23,17 @@ var UFormControlElement = class extends UElement {
|
|
|
23
23
|
return this.disabled || this.formDisabled;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
+
* `u-form` 의 `model` 과 주고받는 값. 기본은 `value` 다.
|
|
27
|
+
* 상태를 다른 속성에 두는 컨트롤(체크박스 · 스위치의 `checked`)은 그 상태를 돌려주고 받도록 재정의한다 —
|
|
28
|
+
* 제출값(`value`)과 모델이 담을 상태는 다를 수 있다.
|
|
29
|
+
*/
|
|
30
|
+
get modelValue() {
|
|
31
|
+
return this.value;
|
|
32
|
+
}
|
|
33
|
+
set modelValue(value) {
|
|
34
|
+
this.value = value;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
26
37
|
* 폼과의 연동을 위해 `form` 속성을 제공합니다. ElementInternals를 지원하는 브라우저에서 폼 요소에 접근할 수 있습니다.
|
|
27
38
|
* 지원하지 않는 브라우저에서는 null을 반환합니다.
|
|
28
39
|
*/
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare function localOffset(date: Date): string;
|
|
1
|
+
import { localOffset } from '../../utilities/dateValue.js';
|
|
2
|
+
export { localOffset };
|
|
4
3
|
/** ISO day + `HH:mm` or `HH:mm:ss` → `YYYY-MM-DDTHH:mm:ss±HH:mm` (the offset of that local day and time). */
|
|
5
4
|
export declare function toDateTimeOffset(day: string, time: string): string;
|
|
6
5
|
/** A date-time value as this browser's wall clock — `YYYY-MM-DDTHH:mm:ss±HH:mm` in the local offset.
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
+
import { localOffset, readDateValue, writeInstant } from "../../utilities/dateValue.js";
|
|
1
2
|
import { parseISODate } from "./dates.js";
|
|
2
3
|
//#region src/components/calendar/datetime.ts
|
|
3
|
-
/** `±HH:mm` for the browser's local timezone at `date` (DST-aware — recomputed per date,
|
|
4
|
-
* not cached — `getTimezoneOffset()`'s sign is the inverse of the ISO-8601 offset sign). */
|
|
5
|
-
function localOffset(date) {
|
|
6
|
-
const minutes = -date.getTimezoneOffset();
|
|
7
|
-
const sign = minutes >= 0 ? "+" : "-";
|
|
8
|
-
const abs = Math.abs(minutes);
|
|
9
|
-
return `${sign}${String(Math.floor(abs / 60)).padStart(2, "0")}:${String(abs % 60).padStart(2, "0")}`;
|
|
10
|
-
}
|
|
11
4
|
/** ISO day + `HH:mm` or `HH:mm:ss` → `YYYY-MM-DDTHH:mm:ss±HH:mm` (the offset of that local day and time). */
|
|
12
5
|
function toDateTimeOffset(day, time) {
|
|
13
6
|
const [h, m, s = 0] = time.split(":").map(Number);
|
|
@@ -15,19 +8,14 @@ function toDateTimeOffset(day, time) {
|
|
|
15
8
|
local.setHours(h, m, s);
|
|
16
9
|
return `${day}T${normalizeTime(time, true)}${localOffset(local)}`;
|
|
17
10
|
}
|
|
18
|
-
/** A date-time with a UTC designator or offset after its time (`…Z`, `…+09:00`, `…-0530`). */
|
|
19
|
-
var WITH_OFFSET = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
20
11
|
/** A date-time value as this browser's wall clock — `YYYY-MM-DDTHH:mm:ss±HH:mm` in the local offset.
|
|
21
12
|
* A value with an offset is an instant: `2026-09-06T22:22:34Z` reads `2026-09-07T07:22:34+09:00` in
|
|
22
13
|
* Seoul, the same moment. A value without one is already wall clock and comes back as it is, and so
|
|
23
14
|
* does anything that is not a date-time. Every read of a picker value goes through here, so what
|
|
24
15
|
* the picker shows and what it writes back describe the same instant. */
|
|
25
16
|
function toLocalDateTime(value) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (Number.isNaN(instant.getTime())) return value;
|
|
29
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
30
|
-
return toDateTimeOffset(`${instant.getFullYear()}-${pad(instant.getMonth() + 1)}-${pad(instant.getDate())}`, `${pad(instant.getHours())}:${pad(instant.getMinutes())}:${pad(instant.getSeconds())}`);
|
|
17
|
+
const read = readDateValue(value);
|
|
18
|
+
return read?.kind === "instant" ? writeInstant(read.date) : value;
|
|
31
19
|
}
|
|
32
20
|
/** Whether two picker values are the same — a day, a date-time, or a `start/end` interval of either,
|
|
33
21
|
* compared half by half as instants when they carry offsets. A value written back in the local
|
|
@@ -32,6 +32,9 @@ export declare class UCheckbox extends UFormControlElement<string> {
|
|
|
32
32
|
indeterminate: boolean;
|
|
33
33
|
/** 체크 여부 */
|
|
34
34
|
checked: boolean;
|
|
35
|
+
/** `u-form` 의 `model` 에는 제출값(`value`)이 아니라 켬/끔 상태를 싣는다. */
|
|
36
|
+
get modelValue(): unknown;
|
|
37
|
+
set modelValue(value: unknown);
|
|
35
38
|
/**
|
|
36
39
|
* 네이티브 `defaultChecked` 에 해당하는 값 — **처음 연결될 때의 `checked` 속성**.
|
|
37
40
|
* `checked` 는 반영(reflect)되는 속성이라 사용자가 바꾸면 속성도 바뀐다. 그래서 속성을
|
|
@@ -29,6 +29,13 @@ var UCheckbox = class UCheckbox extends UFormControlElement {
|
|
|
29
29
|
static {
|
|
30
30
|
this.styles = [super.styles, styles];
|
|
31
31
|
}
|
|
32
|
+
/** `u-form` 의 `model` 에는 제출값(`value`)이 아니라 켬/끔 상태를 싣는다. */
|
|
33
|
+
get modelValue() {
|
|
34
|
+
return this.checked;
|
|
35
|
+
}
|
|
36
|
+
set modelValue(value) {
|
|
37
|
+
this.checked = Boolean(value);
|
|
38
|
+
}
|
|
32
39
|
connectedCallback() {
|
|
33
40
|
this.defaultChecked ??= this.hasAttribute("checked");
|
|
34
41
|
super.connectedCallback();
|
|
@@ -20,7 +20,7 @@ var UForm = class UForm extends UElement {
|
|
|
20
20
|
const target = e.target;
|
|
21
21
|
if (!(target instanceof UFormControlElement)) return;
|
|
22
22
|
const name = target.name;
|
|
23
|
-
const value = target.
|
|
23
|
+
const value = target.modelValue;
|
|
24
24
|
if (!name) return;
|
|
25
25
|
if (!this.isIncluded(target)) return;
|
|
26
26
|
if (this.model && typeof this.model === "object") this.model[name] = value;
|
|
@@ -81,7 +81,7 @@ var UForm = class UForm extends UElement {
|
|
|
81
81
|
}
|
|
82
82
|
sync() {
|
|
83
83
|
if (!this.model) return;
|
|
84
|
-
for (const control of this.getControls()) if (control.name && control.name in this.model) control.
|
|
84
|
+
for (const control of this.getControls()) if (control.name && control.name in this.model) control.modelValue = this.model[control.name];
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* 포함된 컨트롤을 문서 순서로 모은다 — 슬롯에 배정된 요소 **와 그 자손**이 대상이다. 감싸개(`u-field` 등) 안의
|
|
@@ -53,8 +53,8 @@ var UInput = class UInput extends UFormControlElement {
|
|
|
53
53
|
this.inputEl?.dispatchEvent(new InputEvent("input", { bubbles: true }));
|
|
54
54
|
};
|
|
55
55
|
this.handleInputInput = (e) => {
|
|
56
|
-
if (this.composing) return;
|
|
57
56
|
if (this.type === "number") {
|
|
57
|
+
if (this.composing) return;
|
|
58
58
|
const text = this.inputEl?.value ?? "";
|
|
59
59
|
if (text === this.numberText) return;
|
|
60
60
|
this.syncNumberFromText(text);
|
|
@@ -62,7 +62,7 @@ var UInput = class UInput extends UFormControlElement {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
const next = this.inputEl?.value;
|
|
65
|
-
if (next === this.value) return;
|
|
65
|
+
if (!e.isTrusted && next === this.value) return;
|
|
66
66
|
this.value = next;
|
|
67
67
|
this.relay(e);
|
|
68
68
|
};
|
|
@@ -35,7 +35,7 @@ import { UPopover } from '../popover/UPopover.js';
|
|
|
35
35
|
*
|
|
36
36
|
* @event change - 사용자 상호작용(옵션 클릭·칩 제거·지우기)으로 선택 값이 변경될 때 발생.
|
|
37
37
|
* 네이티브 select와 동일하게 프로그램적 value 세팅·옵션 등록으로는 발화하지 않는다.
|
|
38
|
-
* @event search - `searchable`일 때
|
|
38
|
+
* @event search - `searchable`일 때 검색어가 바뀔 때마다 발생(`detail: { query: string; composing: boolean }` — IME 조합 중이면 `composing: true`, 조합이 끝나면 `false` 로 한 번 더).
|
|
39
39
|
* 로컬 필터링(이미 렌더된 `u-option`의 `hidden` 토글)과 별개로 발행되므로, 서버/원격 검색이
|
|
40
40
|
* 필요한 소비자는 이 이벤트를 구독해 자체적으로 옵션을 갱신할 수 있다.
|
|
41
41
|
*/
|
|
@@ -85,6 +85,8 @@ export declare class USelect extends UFormControlElement<string | string[]> {
|
|
|
85
85
|
private options;
|
|
86
86
|
/** 검색칸의 지금 검색어(소문자 · 앞뒤 공백 없음). */
|
|
87
87
|
private query;
|
|
88
|
+
/** `query` 의 마지막 음절이 아직 조합 중인가 — 검색 일치가 그 음절을 자모 앞부분으로 견준다. */
|
|
89
|
+
private queryComposing;
|
|
88
90
|
/** 검색어가 있는데 보이는 옵션이 없다 — 팝업에 «일치하는 항목 없음» 을 알린다. */
|
|
89
91
|
private noMatches;
|
|
90
92
|
/** aria-expanded 배선용 팝오버 열림 상태 */
|
|
@@ -128,7 +130,16 @@ export declare class USelect extends UFormControlElement<string | string[]> {
|
|
|
128
130
|
private handlePopoverHide;
|
|
129
131
|
private handleOptionClick;
|
|
130
132
|
private handleOptionKeydown;
|
|
133
|
+
/**
|
|
134
|
+
* 검색칸의 IME 조합. 조합 중인 음절(«ㅅ» · «성» → «서울» 의 가는 길)은 «진행 중» 이라 거르기에 쓰지 않는다 — 확정된
|
|
135
|
+
* 부분으로 거르면 사용자가 찾는 옵션을 숨기지 않고 «일치 없음» 도 정말 없을 때만 알린다. Chromium 은 조합의 마지막
|
|
136
|
+
* `input` 을 `isComposing: true` 로 내고 끝내므로, 확정된 질의는 조합 끝에 낸다.
|
|
137
|
+
*/
|
|
138
|
+
private readonly composition;
|
|
139
|
+
/** 마지막으로 낸 `search` — 조합 끝의 `search` 와 그 뒤 브라우저가 내는 `input`(Firefox)이 같은 질의를 두 번 내지 않게. */
|
|
140
|
+
private lastSearch?;
|
|
131
141
|
private handleSearchInput;
|
|
142
|
+
private updateSearch;
|
|
132
143
|
/**
|
|
133
144
|
* 지금 검색어를 지금 옵션에 적용한다 — 입력 때뿐 아니라 옵션이 바뀔 때도(재사용된 `u-option` 이 앞 검색의 `hidden` 을
|
|
134
145
|
* 들고 남지 않게). `filter="none"` 이면 아무것도 숨기지 않는다.
|
|
@@ -142,12 +153,21 @@ export declare class USelect extends UFormControlElement<string | string[]> {
|
|
|
142
153
|
private handleClearKeydown;
|
|
143
154
|
private handleChipRemove;
|
|
144
155
|
}
|
|
156
|
+
/** Detail of `<u-select>`'s `search` event. */
|
|
157
|
+
export interface USelectSearchDetail {
|
|
158
|
+
/** The search box text, trimmed and lower-cased — including a syllable still being composed. */
|
|
159
|
+
query: string;
|
|
160
|
+
/**
|
|
161
|
+
* `true` while an IME composition (Korean, Japanese, Chinese) is in progress, so `query` ends in a partial
|
|
162
|
+
* syllable (`ㅅ`, `성` on the way to `서울`). When the composition ends the event fires again with `false`. A consumer
|
|
163
|
+
* that searches a server can skip composing queries.
|
|
164
|
+
*/
|
|
165
|
+
composing: boolean;
|
|
166
|
+
}
|
|
145
167
|
/** Custom events `<u-select>` dispatches (its `change`/`input` are the native form-control events). */
|
|
146
168
|
export interface USelectEventMap {
|
|
147
|
-
/** The search box changed (`searchable`).
|
|
148
|
-
'search': CustomEvent<
|
|
149
|
-
query: string;
|
|
150
|
-
}>;
|
|
169
|
+
/** The search box changed (`searchable`). */
|
|
170
|
+
'search': CustomEvent<USelectSearchDetail>;
|
|
151
171
|
}
|
|
152
172
|
/** Typed listeners for {@link USelectEventMap} — element-scoped, the DOM's own pattern (`HTMLMediaElementEventMap`). */
|
|
153
173
|
export interface USelect {
|
|
@@ -9,6 +9,7 @@ import "../field/UField.js";
|
|
|
9
9
|
import "../popover/UPopover.js";
|
|
10
10
|
import { CharsWidthController } from "../../utilities/chars.js";
|
|
11
11
|
import { UOption } from "../option/UOption.js";
|
|
12
|
+
import { CompositionTracker } from "../../utilities/composition.js";
|
|
12
13
|
import { styles } from "./USelect.styles.js";
|
|
13
14
|
import { html } from "lit";
|
|
14
15
|
import { customElement, property, query, state } from "lit/decorators.js";
|
|
@@ -31,6 +32,7 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
31
32
|
this.loading = false;
|
|
32
33
|
this.options = [];
|
|
33
34
|
this.query = "";
|
|
35
|
+
this.queryComposing = false;
|
|
34
36
|
this.noMatches = false;
|
|
35
37
|
this.open = false;
|
|
36
38
|
this.idBase = `u-select-${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -97,14 +99,9 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
97
99
|
this.popoverEl?.hide();
|
|
98
100
|
}
|
|
99
101
|
};
|
|
102
|
+
this.composition = new CompositionTracker((input) => this.updateSearch(input));
|
|
100
103
|
this.handleSearchInput = (e) => {
|
|
101
|
-
|
|
102
|
-
this.query = input.value.toLowerCase().trim();
|
|
103
|
-
this.applyFilter();
|
|
104
|
-
this.fire("search", {
|
|
105
|
-
detail: { query: this.query },
|
|
106
|
-
cancelable: false
|
|
107
|
-
});
|
|
104
|
+
this.updateSearch(e.target);
|
|
108
105
|
};
|
|
109
106
|
this.handleSearchKeydown = (e) => {
|
|
110
107
|
const options = this.options.filter((o) => !o.hidden && !o.disabled);
|
|
@@ -248,6 +245,9 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
248
245
|
aria-label=${Locale.getValue("search")}
|
|
249
246
|
aria-controls=${this.listboxId}
|
|
250
247
|
@input=${this.handleSearchInput}
|
|
248
|
+
@compositionstart=${this.composition}
|
|
249
|
+
@compositionupdate=${this.composition}
|
|
250
|
+
@compositionend=${this.composition}
|
|
251
251
|
@keydown=${this.handleSearchKeydown}
|
|
252
252
|
/>
|
|
253
253
|
</div>
|
|
@@ -346,6 +346,22 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
346
346
|
composed: true
|
|
347
347
|
}));
|
|
348
348
|
}
|
|
349
|
+
updateSearch(input) {
|
|
350
|
+
const { query, composing } = this.composition.searchQuery(input);
|
|
351
|
+
this.query = query.trim();
|
|
352
|
+
this.queryComposing = composing;
|
|
353
|
+
this.applyFilter();
|
|
354
|
+
const detail = {
|
|
355
|
+
query: input.value.toLowerCase().trim(),
|
|
356
|
+
composing: this.composition.composing
|
|
357
|
+
};
|
|
358
|
+
if (this.lastSearch && this.lastSearch.query === detail.query && this.lastSearch.composing === detail.composing) return;
|
|
359
|
+
this.lastSearch = detail;
|
|
360
|
+
this.fire("search", {
|
|
361
|
+
detail,
|
|
362
|
+
cancelable: false
|
|
363
|
+
});
|
|
364
|
+
}
|
|
349
365
|
/**
|
|
350
366
|
* 지금 검색어를 지금 옵션에 적용한다 — 입력 때뿐 아니라 옵션이 바뀔 때도(재사용된 `u-option` 이 앞 검색의 `hidden` 을
|
|
351
367
|
* 들고 남지 않게). `filter="none"` 이면 아무것도 숨기지 않는다.
|
|
@@ -354,9 +370,8 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
354
370
|
const query = this.filter === "none" ? "" : this.query;
|
|
355
371
|
for (const option of this.options) if (!query) option.hidden = false;
|
|
356
372
|
else {
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
option.hidden = !label.includes(query) && !value.includes(query);
|
|
373
|
+
const options = { composing: this.queryComposing };
|
|
374
|
+
option.hidden = !Locale.matchesSearch(option.getText(), query, options) && !Locale.matchesSearch(option.value, query, options);
|
|
360
375
|
}
|
|
361
376
|
this.noMatches = !!this.query && !this.loading && !this.options.some((o) => !o.hidden);
|
|
362
377
|
}
|
|
@@ -32,6 +32,9 @@ export declare class USwitch extends UFormControlElement<string> {
|
|
|
32
32
|
static styles: import('lit').CSSResultGroup[];
|
|
33
33
|
/** 체크 여부 */
|
|
34
34
|
checked: boolean;
|
|
35
|
+
/** `u-form` 의 `model` 에는 제출값(`value`)이 아니라 켬/끔 상태를 싣는다. */
|
|
36
|
+
get modelValue(): unknown;
|
|
37
|
+
set modelValue(value: unknown);
|
|
35
38
|
/**
|
|
36
39
|
* 네이티브 `defaultChecked` 에 해당하는 값 — **처음 연결될 때의 `checked` 속성**.
|
|
37
40
|
* `checked` 는 반영(reflect)되는 속성이라 사용자가 바꾸면 속성도 바뀐다. 그래서 속성을
|
|
@@ -24,6 +24,13 @@ var USwitch = class USwitch extends UFormControlElement {
|
|
|
24
24
|
static {
|
|
25
25
|
this.styles = [super.styles, styles];
|
|
26
26
|
}
|
|
27
|
+
/** `u-form` 의 `model` 에는 제출값(`value`)이 아니라 켬/끔 상태를 싣는다. */
|
|
28
|
+
get modelValue() {
|
|
29
|
+
return this.checked;
|
|
30
|
+
}
|
|
31
|
+
set modelValue(value) {
|
|
32
|
+
this.checked = Boolean(value);
|
|
33
|
+
}
|
|
27
34
|
connectedCallback() {
|
|
28
35
|
this.defaultChecked ??= this.hasAttribute("checked");
|
|
29
36
|
super.connectedCallback();
|
package/dist/index.d.ts
CHANGED
|
@@ -63,12 +63,15 @@ export * from './events/ShowEvent';
|
|
|
63
63
|
export * from './utilities/BrowserStorage.js';
|
|
64
64
|
export * from './utilities/clipboard.js';
|
|
65
65
|
export * from './utilities/converters.js';
|
|
66
|
+
export * from './utilities/dateValue.js';
|
|
66
67
|
export * from './utilities/devWarning.js';
|
|
67
68
|
export * from './utilities/Dialog.js';
|
|
68
69
|
export * from './utilities/elements.js';
|
|
69
70
|
export * from './utilities/format.js';
|
|
70
71
|
export * from './utilities/icons.js';
|
|
71
72
|
export * from './utilities/keyboard.js';
|
|
73
|
+
export * from './utilities/composition.js';
|
|
74
|
+
export * from './utilities/search.js';
|
|
72
75
|
export * from './utilities/Locale.js';
|
|
73
76
|
export * from './utilities/OverlayManager.js';
|
|
74
77
|
export * from './utilities/Theme.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defaultSearchMatch, foldForSearch, hangulKeystrokes, initialsOf, isHangul } from "./utilities/search.js";
|
|
1
2
|
import { Locale } from "./utilities/Locale.js";
|
|
2
3
|
import { UElement } from "./components/UElement.js";
|
|
3
4
|
import { getParentElement, isCoarsePointer, isFocusCandidate, isFromControl, querySelectorAllWithin, querySelectorDeep, querySelectorWithin } from "./utilities/elements.js";
|
|
@@ -26,6 +27,7 @@ import { UCheckbox } from "./components/checkbox/UCheckbox.js";
|
|
|
26
27
|
import { UTag } from "./components/tag/UTag.js";
|
|
27
28
|
import { UChip } from "./components/chip/UChip.js";
|
|
28
29
|
import { UCopyButton } from "./components/copy-button/UCopyButton.js";
|
|
30
|
+
import { localOffset, readDateValue, writeInstant, writePlainDate, writePlainDateTime } from "./utilities/dateValue.js";
|
|
29
31
|
import { dateTextPattern, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber } from "./utilities/format.js";
|
|
30
32
|
import { UField } from "./components/field/UField.js";
|
|
31
33
|
import { UPopover } from "./components/popover/UPopover.js";
|
|
@@ -41,6 +43,7 @@ import { UOption } from "./components/option/UOption.js";
|
|
|
41
43
|
import { UInput } from "./components/input/UInput.js";
|
|
42
44
|
import { UMenuItem } from "./components/menu-item/UMenuItem.js";
|
|
43
45
|
import { UMenu } from "./components/menu/UMenu.js";
|
|
46
|
+
import { CompositionTracker, replayInput } from "./utilities/composition.js";
|
|
44
47
|
import { USelect } from "./components/select/USelect.js";
|
|
45
48
|
import { UPagination } from "./components/pagination/UPagination.js";
|
|
46
49
|
import { UPanel } from "./components/panel/UPanel.js";
|
|
@@ -65,4 +68,4 @@ import { Dialog } from "./utilities/Dialog.js";
|
|
|
65
68
|
import { Theme } from "./utilities/Theme.js";
|
|
66
69
|
import { Toast } from "./utilities/Toast.js";
|
|
67
70
|
import { decodeDelimited, decodeTsv, encodeTsv } from "./utilities/tsv.js";
|
|
68
|
-
export { ALERT_STATUSES, BrowserStorage, Dialog, IconCache, IconRegistry, Locale, OverlayManager, Theme, Toast, UAlert, UAvatar, UBadge, UBreadcrumb, UBreadcrumbItem, UButton, UButtonGroup, UCard, UCarousel, UCheckbox, UChip, UCopyButton, UDatePicker, UDateRangePicker, UDialog, UDivider, UDrawer, UElement, UExpander, UField, UFileInput, UFloatingElement, UForm, UFormControlElement, UIcon, UIconButton, UInput, UMenu, UMenuItem, UOption, UOverlayElement, UPagination, UPanel, UPopover, UProgressBar, UProgressRing, URadio, URating, USelect, USkeleton, USlider, USpinner, USplitPanel, USteps, USwitch, UTab, UTabPanel, UTag, UText, UTextarea, UTooltip, UTree, UTreeItem, arrayAttrConverter, booleanAttrConverter, copyFromKey, createDevWarner, dateAttrConverter, dateTextPattern, decodeDelimited, decodeTsv, devWarnOnce, encodeTsv, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isFromControl, isImeComposing, isTextEntry, jsonAttrConverter, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber, pasteFromKey, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter };
|
|
71
|
+
export { ALERT_STATUSES, BrowserStorage, CompositionTracker, Dialog, IconCache, IconRegistry, Locale, OverlayManager, Theme, Toast, UAlert, UAvatar, UBadge, UBreadcrumb, UBreadcrumbItem, UButton, UButtonGroup, UCard, UCarousel, UCheckbox, UChip, UCopyButton, UDatePicker, UDateRangePicker, UDialog, UDivider, UDrawer, UElement, UExpander, UField, UFileInput, UFloatingElement, UForm, UFormControlElement, UIcon, UIconButton, UInput, UMenu, UMenuItem, UOption, UOverlayElement, UPagination, UPanel, UPopover, UProgressBar, UProgressRing, URadio, URating, USelect, USkeleton, USlider, USpinner, USplitPanel, USteps, USwitch, UTab, UTabPanel, UTag, UText, UTextarea, UTooltip, UTree, UTreeItem, arrayAttrConverter, booleanAttrConverter, copyFromKey, createDevWarner, dateAttrConverter, dateTextPattern, decodeDelimited, decodeTsv, defaultSearchMatch, devWarnOnce, encodeTsv, foldForSearch, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, hangulKeystrokes, initialsOf, isCoarsePointer, isFocusCandidate, isFromControl, isHangul, isImeComposing, isTextEntry, jsonAttrConverter, localOffset, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber, pasteFromKey, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, readDateValue, replayInput, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter, writeInstant, writePlainDate, writePlainDateTime };
|
package/dist/react/USelect.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { USelect as USelectElement } from '@iyulab/components/dist/components/select/USelect.js';
|
|
3
|
+
import { type USelectSearchDetail } from '@iyulab/components/dist/components/select/USelect.js';
|
|
3
4
|
|
|
4
5
|
type EventOf<K extends string> = K extends keyof HTMLElementEventMap ? HTMLElementEventMap[K] : CustomEvent;
|
|
5
6
|
type USelectOwnProps = Omit<USelectElement, keyof HTMLElement>;
|
|
@@ -10,7 +11,7 @@ export declare const USelect: React.ForwardRefExoticComponent<
|
|
|
10
11
|
& React.RefAttributes<USelectElement>
|
|
11
12
|
& {
|
|
12
13
|
onChange?: (event: EventOf<'change'>) => void;
|
|
13
|
-
onSearch?: (event: CustomEvent<
|
|
14
|
+
onSearch?: (event: CustomEvent<USelectSearchDetail>) => void;
|
|
14
15
|
}
|
|
15
16
|
>;
|
|
16
17
|
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @iyulab/components 의 경량 로케일 유틸리티.
|
|
3
|
-
*
|
|
4
|
-
* 범위: 라이브러리가 스스로 생성하는 chrome 문자열(검증 메시지 등)만 대상.
|
|
5
|
-
* 일반 i18n 프레임워크가 아니다. 앱 콘텐츠 번역은 consumer 의 i18n 계층이 담당한다.
|
|
6
|
-
*
|
|
7
|
-
* `SupportedLocale` 의 14개 언어가 빌드 시점에 내장된다 (src/assets/locales/*.json).
|
|
8
|
-
* 그 외 언어는 register()로 테이블 단위 등록/오버라이드한다.
|
|
9
|
-
*/
|
|
1
|
+
import { SearchMatchOptions } from './search.js';
|
|
10
2
|
/** 라이브러리가 기본 제공하는 로케일. */
|
|
11
3
|
export type SupportedLocale = 'en' | 'ko' | 'ja' | 'zh-CN' | 'zh-TW' | 'es' | 'fr' | 'de' | 'pt-BR' | 'vi' | 'th' | 'id' | 'ru' | 'ar';
|
|
12
4
|
/** 내장 로케일은 자동완성되지만, 임의의 BCP47 태그도 그대로 받는다. */
|
|
@@ -14,6 +6,11 @@ export type LocaleTag = SupportedLocale | (string & {});
|
|
|
14
6
|
/** 라이브러리가 제공하는 chrome 문자열 키. 지금은 검증 메시지뿐이지만 이후 다른 UI 문구도 추가될 수 있다. */
|
|
15
7
|
export type LocaleMessageKey = 'valueMissing' | 'badInput' | 'typeMismatch' | 'patternMismatch' | 'rangeUnderflow' | 'rangeOverflow' | 'stepMismatch' | 'tooShort' | 'tooLong' | 'increment' | 'decrement' | 'clear' | 'today' | 'time' | 'showPassword' | 'hidePassword' | 'previousSlide' | 'nextSlide' | 'goToSlide' | 'carousel' | 'slide' | 'slideOf' | 'stopSlideRotation' | 'startSlideRotation' | 'chooseDate' | 'chooseDateRange' | 'yesterday' | 'last7Days' | 'last30Days' | 'thisWeek' | 'lastWeek' | 'thisMonth' | 'lastMonth' | 'thisYear' | 'quickRanges' | 'rangeStartChosen' | 'previousMonth' | 'nextMonth' | 'close' | 'copy' | 'copied' | 'chooseFile' | 'noFileChosen' | 'filesSelected' | 'resizePanels' | 'loading' | 'breadcrumb' | 'search' | 'noMatches' | 'alertError' | 'alertWarning' | 'alertSuccess' | 'alertInfo' | 'alertNotice' | 'alertMessage' | 'remove' | 'closeTab' | 'confirm' | 'cancel' | 'ok' | 'stepComplete' | 'stepOnHold' | 'apply' | 'dateUnavailable' | 'startTime' | 'endTime' | 'timeAm' | 'timePm' | 'pagination' | 'previousPage' | 'nextPage' | 'pageN' | 'rowsPerPage' | 'rangeOfTotal';
|
|
16
8
|
type LocaleTable = Record<LocaleMessageKey, string>;
|
|
9
|
+
/**
|
|
10
|
+
* 글자가 검색어를 담는가 — 사람이 «찾았다» 고 여기는 일치. 글자마다 거르는 칸(`u-select` 의 검색 등)이 쓴다.
|
|
11
|
+
* `text` 는 옵션 글자 같은 대상, `query` 는 사람이 친 검색어 — `options.composing` 이면 마지막 음절이 아직 조합 중이다.
|
|
12
|
+
*/
|
|
13
|
+
export type SearchMatcher = (text: string, query: string, options: SearchMatchOptions) => boolean;
|
|
17
14
|
/**
|
|
18
15
|
* 한 패키지(또는 앱 영역)의 문자열 묶음.
|
|
19
16
|
*
|
|
@@ -76,6 +73,21 @@ export declare class Locale {
|
|
|
76
73
|
* `params`가 있으면 템플릿의 `{name}` 자리를 치환합니다.
|
|
77
74
|
*/
|
|
78
75
|
static getValue(key: LocaleMessageKey, params?: Record<string, string | number>, locale?: LocaleTag): string;
|
|
76
|
+
/**
|
|
77
|
+
* 한 언어의 검색 일치를 등록합니다 — 그 언어에서 `u-select` 의 검색 같은 거르기가 이 규칙을 씁니다.
|
|
78
|
+
*
|
|
79
|
+
* 기본 규칙(대소문자 · 발음 구별 기호 접기, 한글 자모 · 초성 일치)은 문자 체계에 매여 있어 모든 언어에 이미 있습니다.
|
|
80
|
+
* 언어에 매인 규칙만 여기 둡니다 — 터키어의 `İ`/`ı` 처럼. 기본 규칙을 이어 쓰려면 `defaultSearchMatch` 를 부르세요.
|
|
81
|
+
*/
|
|
82
|
+
static registerSearch(locale: LocaleTag, matcher: SearchMatcher): void;
|
|
83
|
+
/**
|
|
84
|
+
* `text` 가 `query` 를 담는가 — 활성 로케일(또는 `options.locale`)에 등록된 검색 일치로, 없으면 기본 규칙으로.
|
|
85
|
+
* 빈 검색어는 모두를 담습니다. 질의의 마지막 음절이 아직 IME 로 조합 중이면 `composing: true` 를 넘기세요 — 그 음절은
|
|
86
|
+
* 자모 앞부분으로 견줍니다(`CompositionTracker.searchQuery()` 가 둘을 함께 줍니다).
|
|
87
|
+
*/
|
|
88
|
+
static matchesSearch(text: string, query: string, options?: SearchMatchOptions & {
|
|
89
|
+
locale?: LocaleTag;
|
|
90
|
+
}): boolean;
|
|
79
91
|
/**
|
|
80
92
|
* 네임스페이스 핸들을 얻습니다 — 같은 이름이면 **같은 저장소**를 가리킵니다.
|
|
81
93
|
*
|
package/dist/utilities/Locale.js
CHANGED
|
@@ -12,6 +12,7 @@ import th_default from "../assets/locales/th.json.js";
|
|
|
12
12
|
import vi_default from "../assets/locales/vi.json.js";
|
|
13
13
|
import zh_CN_default from "../assets/locales/zh-CN.json.js";
|
|
14
14
|
import zh_TW_default from "../assets/locales/zh-TW.json.js";
|
|
15
|
+
import { defaultSearchMatch } from "./search.js";
|
|
15
16
|
//#region src/utilities/Locale.ts
|
|
16
17
|
var builtins = new Map(Object.entries(/* #__PURE__ */ Object.assign({
|
|
17
18
|
"../assets/locales/ar.json": ar_default,
|
|
@@ -105,6 +106,8 @@ function lookup(locale, key) {
|
|
|
105
106
|
}
|
|
106
107
|
/** ns → 정규화 로케일 태그 → 테이블. */
|
|
107
108
|
var namespaces = /* @__PURE__ */ new Map();
|
|
109
|
+
/** 정규화 로케일 태그 → 그 언어에 등록된 검색 일치. 없으면 문자 체계 기본 규칙(`defaultSearchMatch`). */
|
|
110
|
+
var searchMatchers = /* @__PURE__ */ new Map();
|
|
108
111
|
/**
|
|
109
112
|
* 검증 메시지 로케일을 관리하는 정적 유틸리티입니다.
|
|
110
113
|
*/
|
|
@@ -160,6 +163,29 @@ var Locale = class {
|
|
|
160
163
|
return interpolate(lookup(locale ?? active, key), params);
|
|
161
164
|
}
|
|
162
165
|
/**
|
|
166
|
+
* 한 언어의 검색 일치를 등록합니다 — 그 언어에서 `u-select` 의 검색 같은 거르기가 이 규칙을 씁니다.
|
|
167
|
+
*
|
|
168
|
+
* 기본 규칙(대소문자 · 발음 구별 기호 접기, 한글 자모 · 초성 일치)은 문자 체계에 매여 있어 모든 언어에 이미 있습니다.
|
|
169
|
+
* 언어에 매인 규칙만 여기 둡니다 — 터키어의 `İ`/`ı` 처럼. 기본 규칙을 이어 쓰려면 `defaultSearchMatch` 를 부르세요.
|
|
170
|
+
*/
|
|
171
|
+
static registerSearch(locale, matcher) {
|
|
172
|
+
searchMatchers.set(locale.toLowerCase(), matcher);
|
|
173
|
+
notify();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* `text` 가 `query` 를 담는가 — 활성 로케일(또는 `options.locale`)에 등록된 검색 일치로, 없으면 기본 규칙으로.
|
|
177
|
+
* 빈 검색어는 모두를 담습니다. 질의의 마지막 음절이 아직 IME 로 조합 중이면 `composing: true` 를 넘기세요 — 그 음절은
|
|
178
|
+
* 자모 앞부분으로 견줍니다(`CompositionTracker.searchQuery()` 가 둘을 함께 줍니다).
|
|
179
|
+
*/
|
|
180
|
+
static matchesSearch(text, query, options = {}) {
|
|
181
|
+
const { locale, ...rest } = options;
|
|
182
|
+
for (const tag of chainOf(locale || active)) {
|
|
183
|
+
const matcher = searchMatchers.get(tag);
|
|
184
|
+
if (matcher) return matcher(text, query, rest);
|
|
185
|
+
}
|
|
186
|
+
return defaultSearchMatch(text, query, rest);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
163
189
|
* 네임스페이스 핸들을 얻습니다 — 같은 이름이면 **같은 저장소**를 가리킵니다.
|
|
164
190
|
*
|
|
165
191
|
* 상위 패키지가 자기 화면 문자열을 담는 자리입니다. 검증 메시지(`getValue`)의 키셋과
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IME 조합(한국어 · 일본어 · 중국어)을 따라가는 입력 도우미 — 조합 중인 음절을 뺀 «확정된 글자» 를 준다.
|
|
3
|
+
*
|
|
4
|
+
* 글자마다 거르거나 찾는 입력은 조합 단계(«서울» 의 가는 길 «ㅅ» · «서» · «성» · «서우»)마다 그 글자로 거른다. 조합 중인
|
|
5
|
+
* 음절은 아직 무엇이 될지 모르는 «진행 중» 이라, 그것으로 거르면 사용자가 찾는 항목을 숨기고 «결과 없음» 을 알린다.
|
|
6
|
+
* 확정된 부분을 담는 항목은 최종 글자를 담는 항목의 상위 집합이므로(포함 · 접두 일치 둘 다), 확정된 부분으로 거르면 찾는
|
|
7
|
+
* 항목을 숨기지 않는다.
|
|
8
|
+
*
|
|
9
|
+
* 리스너 객체로 입력 요소에 건다 — Lit 템플릿에서는
|
|
10
|
+
* `@compositionstart=${tracker} @compositionupdate=${tracker} @compositionend=${tracker}`.
|
|
11
|
+
*
|
|
12
|
+
* Chromium 은 조합의 마지막 `input` 을 `isComposing: true` 로 내고 `compositionend` 로 끝낸다 — 조합 끝의 확정 글자로
|
|
13
|
+
* 다시 거르려면 `onEnd` 를 받는다.
|
|
14
|
+
*/
|
|
15
|
+
export declare class CompositionTracker implements EventListenerObject {
|
|
16
|
+
private readonly onEnd?;
|
|
17
|
+
/** 조합이 시작된 자리 — 조합 중이 아니면 `null`. */
|
|
18
|
+
private start;
|
|
19
|
+
/** 지금 조합 중인 글자. */
|
|
20
|
+
private text;
|
|
21
|
+
/** @param onEnd 조합이 끝났을 때(확정 글자가 입력 요소에 들어간 뒤) 부른다. */
|
|
22
|
+
constructor(onEnd?: ((input: HTMLInputElement | HTMLTextAreaElement) => void) | undefined);
|
|
23
|
+
/** 조합이 진행 중인가. */
|
|
24
|
+
get composing(): boolean;
|
|
25
|
+
handleEvent(event: Event): void;
|
|
26
|
+
/**
|
|
27
|
+
* 검색 일치(`Locale.matchesSearch`)에 넘길 질의 — `{ query, composing }`. 글 끝에서 조합 중인 글자가 한글이면 그것까지
|
|
28
|
+
* 담고 `composing: true` 다: 한글의 조합 중 음절은 자모로 풀면 최종 글자 자모의 앞부분이라(`성` → `ㅅㅓㅇ` ⊂ `서울` →
|
|
29
|
+
* `ㅅㅓㅇㅜㄹ`) 검색 일치가 그 음절을 앞부분으로 견준다. 그 성질은 조합이 글 끝에 있을 때만 서고(가운데라면 뒤 글자가
|
|
30
|
+
* 붙는다), 다른 문자 체계의 조합 글자(가나 → 한자 변환 전)는 최종 글자와 견줄 수 없어 확정된 부분만 준다.
|
|
31
|
+
*/
|
|
32
|
+
searchQuery(input: HTMLInputElement | HTMLTextAreaElement): {
|
|
33
|
+
query: string;
|
|
34
|
+
composing: boolean;
|
|
35
|
+
};
|
|
36
|
+
/** 입력의 확정된 글자 — 조합 중인 음절을 뺀 값. 조합 중이 아니면 값 그대로. */
|
|
37
|
+
settled(input: HTMLInputElement | HTMLTextAreaElement): string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 입력 칸의 `input` 처리기를 다시 부른다 — 그 칸 자신의 처리기만(전파하지 않는다). 조합 중에는 거르기·검색을 멈추는
|
|
41
|
+
* 칸이 조합 끝에 확정 글자로 다시 돌게 하는 `onEnd`: `new CompositionTracker(replayInput)`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function replayInput(input: HTMLInputElement | HTMLTextAreaElement): void;
|