@iyulab/components 2.21.0 → 2.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/components/UElement.d.ts +5 -1
  3. package/dist/components/UElement.js +9 -2
  4. package/dist/components/UFormControlElement.d.ts +7 -0
  5. package/dist/components/UFormControlElement.js +11 -0
  6. package/dist/components/checkbox/UCheckbox.d.ts +3 -0
  7. package/dist/components/checkbox/UCheckbox.js +7 -0
  8. package/dist/components/field/UField.d.ts +54 -0
  9. package/dist/components/field/UField.js +107 -2
  10. package/dist/components/field/UField.styles.js +20 -0
  11. package/dist/components/form/UForm.js +2 -2
  12. package/dist/components/input/UInput.js +2 -2
  13. package/dist/components/option/UOption.d.ts +5 -0
  14. package/dist/components/option/UOption.js +5 -0
  15. package/dist/components/option/UOption.styles.js +7 -3
  16. package/dist/components/select/USelect.d.ts +34 -5
  17. package/dist/components/select/USelect.js +56 -11
  18. package/dist/components/switch/USwitch.d.ts +3 -0
  19. package/dist/components/switch/USwitch.js +7 -0
  20. package/dist/components/tooltip/UTooltip.d.ts +1 -1
  21. package/dist/components/tooltip/UTooltip.js +8 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +3 -1
  24. package/dist/react/USelect.d.ts +2 -1
  25. package/dist/utilities/Locale.d.ts +21 -9
  26. package/dist/utilities/Locale.js +26 -0
  27. package/dist/utilities/composition.d.ts +43 -0
  28. package/dist/utilities/composition.js +76 -0
  29. package/dist/utilities/search.d.ts +29 -0
  30. package/dist/utilities/search.js +151 -0
  31. package/package.json +1 -1
  32. package/skills/iyulab-components/SKILL.md +2 -2
  33. package/skills/iyulab-components/references/components/field.md +20 -1
  34. package/skills/iyulab-components/references/components/form.md +2 -2
  35. package/skills/iyulab-components/references/components/option.md +1 -0
  36. package/skills/iyulab-components/references/components/select.md +5 -2
  37. package/skills/iyulab-components/references/components/tooltip.md +1 -1
  38. package/skills/iyulab-components/references/extensions/element.md +1 -1
  39. package/skills/iyulab-components/references/extensions/form-control.md +6 -0
  40. package/skills/iyulab-components/references/utilities/keyboard.md +38 -0
  41. package/skills/iyulab-components/references/utilities/locale.md +26 -0
@@ -142,11 +142,11 @@ set on the host yourself always wins and is never overwritten.
142
142
  - [`IconRegistry`](./references/utilities/icons.md) — Register and resolve icon libraries
143
143
  - [`BrowserStorage`](./references/utilities/browser-storage.md) — Unified localStorage / Cookie API
144
144
  - [`converters`](./references/utilities/converters.md) — Lit property attribute converters (array, JSON, date, url…)
145
- - [`Locale`](./references/utilities/locale.md) — Validation-message locale registry and lookup utility
145
+ - [`Locale`](./references/utilities/locale.md) — Validation-message locale registry and lookup utility · search matching (`matchesSearch` — Hangul jamo and initials)
146
146
  - [`elements`](./references/utilities/elements.md) — Shadow-DOM-aware DOM query helpers
147
147
  - [`format`](./references/utilities/format.md) — Locale-aware number, currency and date formatting
148
148
  - [`clipboard`](./references/utilities/clipboard.md) — `copyFromKey` / `pasteFromKey` / `isTextEntry`, Ctrl/Cmd + C · X · V for a grid or list selection in every browser (Safari fires no copy event without a text selection)
149
- - [`keyboard`](./references/utilities/keyboard.md) — `isImeComposing` for Enter handlers that must not fire mid-composition (Korean/Japanese/Chinese input)
149
+ - [`keyboard`](./references/utilities/keyboard.md) — `isImeComposing` for Enter handlers that must not fire mid-composition (Korean/Japanese/Chinese input) · `CompositionTracker` / `replayInput` for inputs that filter as you type
150
150
  - [`tsv`](./references/utilities/tsv.md) — `encodeTsv` / `decodeTsv`, the spreadsheet clipboard format with RFC 4180 quoting
151
151
  - [`OverlayManager`](./references/utilities/overlay-manager.md) — Internal overlay stack and z-index manager
152
152
 
@@ -83,12 +83,31 @@ because their name normally comes from their own content:
83
83
  | Property | Type | Default | Reflect | Description |
84
84
  |----------|------|---------|---------|-------------|
85
85
  | `label` | `string` | — | — | Label text |
86
- | `description` | `string` | — | — | Helper text shown below the control |
86
+ | `description` | `string` | — | — | Helper text — below the control, or in a tooltip beside the label (see `descriptionDisplay`) |
87
+ | `descriptionDisplay` | `'inline' \| 'hint'` | — | — | Where the description shows: `inline` (under the control) or `hint` (info icon beside the label, text on hover). Unset follows `UField.descriptionDisplay` |
87
88
  | `validationMessage` | `string` | — | — | Error message shown when `invalid` |
88
89
  | `required` | `boolean` | `false` | ✓ | Show the required marker and make the slotted control required (a single control — with several controls the field only shows the marker). Turning it off removes only the `required` the field set |
89
90
  | `invalid` | `boolean` | `false` | ✓ | Show validation error state |
90
91
  | `disabled` | `boolean` | `false` | ✓ | Disable state forwarding |
91
92
 
93
+ ## App-wide description display
94
+
95
+ ```ts
96
+ import { UField } from '@iyulab/components';
97
+
98
+ UField.descriptionDisplay = 'hint'; // once, before the first render — default 'inline'
99
+ ```
100
+
101
+ Sets where every field shows its description, including the fields that `u-input`, `u-select` and the other controls
102
+ render inside their own shadow roots. A field's own `description-display` wins. In `hint` mode a validation message
103
+ still shows under the control, the control keeps the text as `aria-description`, and a field without a label shows the
104
+ description inline (there is no label to put the icon beside).
105
+
106
+ The hint opens three ways — hovering the icon, entering the field's control from the keyboard (Tab, or a programmatic
107
+ `focus()`; a click into the control does not, the mouse has hover), and tapping the icon (touch has no hover; the tap
108
+ pins it until a tap elsewhere or a second tap). Escape closes it, and so does focus leaving the field. The icon itself
109
+ is not a Tab stop — a form of dozens of fields would otherwise double its Tabs.
110
+
92
111
  ## Methods
93
112
 
94
113
  | Method | Description |
@@ -52,7 +52,7 @@ form.reset();
52
52
 
53
53
  | Property | Type | Default | Description |
54
54
  |----------|------|---------|-------------|
55
- | `model` | `Record<string, unknown>` | — | Two-way bound data model |
55
+ | `model` | `Record<string, unknown>` | — | Two-way bound data model, keyed by control `name`. Each control exchanges its `modelValue` — `value` for most controls, the `checked` boolean for `u-checkbox` and `u-switch` |
56
56
  | `includes` | `string[]` | `[]` | Only include these field names (empty = all) |
57
57
  | `excludes` | `string[]` | `[]` | Exclude these field names |
58
58
 
@@ -60,7 +60,7 @@ form.reset();
60
60
 
61
61
  | Event | Description |
62
62
  |-------|-------------|
63
- | `change` | Fires when any control value changes |
63
+ | `change` | Fires when a control in the form changes through user input, after `model` is updated |
64
64
 
65
65
  ## Methods
66
66
 
@@ -44,6 +44,7 @@ Selectable option item. Used inside `u-select`, `u-radio`, and `u-input` (combob
44
44
  | `value` | `string` | `''` | — | Submitted value |
45
45
  | `disabled` | `boolean` | `false` | ✓ | Disable the option |
46
46
  | `selected` | `boolean` | `false` | ✓ | Selected state |
47
+ | `active` | `boolean` | `false` | ✓ | The candidate `Enter` picks from the owning `u-select`'s search field — shown like a hovered option. Set by the select; not meant to be set by hand |
47
48
  | `marker` | `'radio'\|'check'` | — | ✓ | Show leading marker icon |
48
49
 
49
50
  ## Methods
@@ -62,7 +62,7 @@ Dropdown select with single or multiple selection, search, and clear support. Fo
62
62
  | Event | Description |
63
63
  |-------|-------------|
64
64
  | `change` | Fires when selection changes |
65
- | `search` | Fires on every search input change when `searchable` (`detail: { query: string }`). With `filter="none"` the select hides nothing, so the options you set from the server are shown as they are — otherwise the built-in local filter runs too |
65
+ | `search` | Fires when the search text changes, when `searchable` (`detail: { query: string; composing: boolean }`). While an IME composition is in progress (Korean, Japanese, Chinese) `composing` is `true` and `query` ends in a partial syllable; when it ends the event fires again with `false` — a server search can skip composing queries. While composing, the built-in filter uses only the committed part, so it never hides an option the finished text would match. With `filter="none"` the select hides nothing, so the options you set from the server are shown as they are — otherwise the built-in local filter runs too |
66
66
 
67
67
  ## Methods
68
68
 
@@ -78,7 +78,10 @@ Dropdown select with single or multiple selection, search, and clear support. Fo
78
78
  The trigger is a `role="combobox"`. Without `searchable` the dropdown holds a `role="listbox"`
79
79
  and opening it focuses the first option. With `searchable` the dropdown is a `role="dialog"`
80
80
  (named by `label`, or "Search") that holds the search field and the listbox; opening it focuses
81
- the search field, so typing filters at once. From the search field `ArrowDown`/`ArrowUp` move to
81
+ the search field, so typing filters at once. While there is a query, the first visible option is the
82
+ **active candidate** — shown like a hovered option and announced through the search field's
83
+ `aria-activedescendant` — and `Enter` picks it (closing the list, or toggling it with `multiple`); the
84
+ `Enter` that commits an IME composition does not. From the search field `ArrowDown`/`ArrowUp` move to
82
85
  the first/last visible option; on an option, arrows, `Home`/`End`, `Enter`/`Space` (select) and
83
86
  `Escape` (close) work as usual.
84
87
 
@@ -6,7 +6,7 @@ import '@iyulab/components/dist/components/tooltip/UTooltip.js';
6
6
 
7
7
  **Tag:** `u-tooltip`
8
8
 
9
- Hover/focus tooltip anchored to a `for` target. Opens and closes automatically.
9
+ Hover/focus tooltip anchored to a `for` target. Opens and closes automatically; Escape closes an open tooltip without moving the pointer or focus (WCAG 1.4.13) — inside a dialog, the first Escape closes the tooltip and the next one the dialog.
10
10
 
11
11
  ```html
12
12
  <u-button id="save-btn">Save</u-button>
@@ -30,7 +30,7 @@ export class MyBadge extends UElement {
30
30
  | Method | Signature | Description |
31
31
  |--------|-----------|-------------|
32
32
  | `fire` | `fire<T>(name, options?): boolean` | Dispatch a `CustomEvent` on the host. `bubbles`, `composed`, `cancelable` are `true` by default. Returns `false` if the event was cancelled. |
33
- | `relay` | `relay(event, options?): void` | Re-dispatch a native DOM event from the host (stops original event, re-fires as new). Useful for surfacing inner element events to light DOM. |
33
+ | `relay` | `relay(event, options?): boolean` | Re-dispatch a DOM event from the host: stops the original and fires the same type with the same init — `bubbles`, `cancelable` and type-specific fields (`InputEvent.data`/`inputType`, `CustomEvent.detail`) — and `composed: true`, so listeners on the host's ancestors receive it. Use it to surface inner element events (a native `change` stays inside the shadow root otherwise). Returns `false` if the event was cancelled. |
34
34
  | `replace` | `replace(value, options?): void` | Replace the entire shadow DOM render output with a new Lit `TemplateResult`. Preserves `<style>` tags. |
35
35
 
36
36
  ## Static members
@@ -78,6 +78,12 @@ export class MyInput extends UFormControlElement<string> {
78
78
  | `form` | `HTMLFormElement \| null` | Associated form element |
79
79
  | `validity` | `ValidityState \| undefined` | Native validity state |
80
80
 
81
+ ## Model value (`u-form`)
82
+
83
+ `modelValue` (getter/setter, `unknown`) is the value a `u-form` reads into and writes from its `model`. It defaults to
84
+ `value`. Override it when the control's state lives in another property — `u-checkbox` and `u-switch` exchange
85
+ `checked` (a boolean), not the submitted `value`.
86
+
81
87
  ## Abstract Methods (must implement)
82
88
 
83
89
  | Method | Returns | Description |
@@ -25,3 +25,41 @@ onKeydown(e: KeyboardEvent) {
25
25
  ```
26
26
 
27
27
  `u-input` (implicit form submission), `Dialog.prompt`, and the overlay Escape handling already use it.
28
+
29
+ ## Filtering as you type — `CompositionTracker`, `replayInput`
30
+
31
+ ```ts
32
+ import { CompositionTracker, replayInput } from '@iyulab/components';
33
+ // or: '@iyulab/components/dist/utilities/composition.js'
34
+ ```
35
+
36
+ An input that filters or searches on every `input` event sees each step of an IME composition: typing
37
+ «서울» in Korean passes through `ㅅ`, `서`, `성`, `서우`. Filtering on those hides what the person is
38
+ looking for, shows "No results", and — for a server search — sends queries for half-typed syllables.
39
+ Chromium sends the composition's last `input` with `isComposing: true` and then `compositionend`, so
40
+ a handler that only skips composing events never sees the finished text.
41
+
42
+ Attach a tracker to the input's composition events (it is an event listener object):
43
+
44
+ ```ts
45
+ private readonly ime = new CompositionTracker(replayInput);
46
+
47
+ render() {
48
+ return html`<input
49
+ @compositionstart=${this.ime} @compositionupdate=${this.ime} @compositionend=${this.ime}
50
+ @input=${this.onInput}>`;
51
+ }
52
+ ```
53
+
54
+ - `ime.composing` — a composition is in progress.
55
+ - `ime.settled(input)` — the text without the part still being composed. Items containing the settled
56
+ text are a superset of items containing the finished text, so filtering on it never hides a match.
57
+ - `ime.searchQuery(input)` — `{ query, composing }` for `Locale.matchesSearch(text, query, { composing })`:
58
+ the settled text plus a Hangul syllable being composed at the end, which the matcher compares as a
59
+ partial syllable.
60
+ - `replayInput` as the `onEnd` callback re-runs the input's own `input` handler when the composition
61
+ ends. Use it for an input that waits: a server search, or a filter whose rule is not «contains»
62
+ (equals, wildcard) or that announces its value to the outside.
63
+
64
+ Keep the text bound to the input (`.value=${…}`) as the whole box text — binding the settled text
65
+ re-renders the input mid-composition and cancels it.
@@ -42,6 +42,8 @@ same 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
43
  | `Locale.subscribe(listener)` | Call `listener` whenever the locale changes (`set` to another locale, any `register`) — returns the unsubscribe function |
44
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
+ | `Locale.matchesSearch(text, query, options?)` | Whether `text` contains `query` as a person searching means it — the rule registered for the locale (`options.locale`, or the active one), or the default (below). `options.composing`: the query's last syllable is still being composed with an IME |
46
+ | `Locale.registerSearch(locale, matcher)` | Register a language's own search rule, `(text, query, { composing }) => boolean` |
45
47
 
46
48
  ### Switching at runtime
47
49
 
@@ -75,6 +77,30 @@ t.textIn(el.locale, 'empty'); // a given locale (e.g. an element's own
75
77
  A key missing from every table in the chain returns the key itself, so a gap shows on screen
76
78
  instead of rendering as an empty string.
77
79
 
80
+ ### Search matching
81
+
82
+ `u-select`'s search filters options with `Locale.matchesSearch`. The default rule belongs to the
83
+ writing system, so it applies under every locale (`defaultSearchMatch`, `foldForSearch`,
84
+ `hangulKeystrokes` and `initialsOf` are exported from `utilities/search`):
85
+
86
+ - Case and diacritics fold — `Ä`, `ä` and `a` match. Hangul syllables are compared whole: `서` does
87
+ not match `성남`.
88
+ - With `composing: true`, the query's last syllable is still being typed, and it is compared as the
89
+ jamo in typing order (`과` → `ㄱㅗㅏ`, `닭` → `ㄷㅏㄹㄱ`) against the start of what follows: `성` and
90
+ `서우` on the way to `서울` both match `서울`. Unicode normalization cannot do this — a final `ㅇ`
91
+ and an initial `ㅇ` are different characters there. `CompositionTracker.searchQuery(input)` gives
92
+ the query and this flag together.
93
+ - A query of Hangul consonants only also matches initials: `ㅅㅇ` finds `서울`.
94
+
95
+ Register a rule only for what belongs to a language:
96
+
97
+ ```ts
98
+ import { Locale, defaultSearchMatch } from '@iyulab/components';
99
+
100
+ Locale.registerSearch('tr', (text, query, options) =>
101
+ text.toLocaleLowerCase('tr').includes(query.toLocaleLowerCase('tr')) || defaultSearchMatch(text, query, options));
102
+ ```
103
+
78
104
  ## Example
79
105
 
80
106
  ```ts