@iyulab/components 2.36.0 → 2.37.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.37.0] - 2026-10-31
4
+
5
+ ### Added
6
+
7
+ - **`:state(field)` on controls that draw an input box** — `u-input`, `u-select`, `u-textarea`, `u-date-picker`,
8
+ `u-date-range-picker`, `u-file-input` and the `u-field` wrapper. Toggles that sit beside their text (`u-checkbox`,
9
+ `u-switch`, `u-radio`) do not carry it. A layout that stands fields on their bottom edge and buttons, toggles and text
10
+ on one text line can select `:state(field)` instead of listing tags (write it as an override of a rule for every
11
+ item — Chromium does not recompute a negated `:not(:state(field))` when the state arrives). A `UFormControlElement` subclass from
12
+ another package opts in with `protected static override fieldBox = true`.
13
+
3
14
  ## [2.36.0] - 2026-10-30
4
15
 
5
16
  ### Added
@@ -88,6 +88,11 @@ export declare abstract class UFormControlElement<T> extends UElement {
88
88
  /** form-associated 표준 콜백 — 조상 fieldset 의 비활성 상태가 바뀔 때 UA 가 부른다. */
89
89
  formDisabledCallback(disabled: boolean): void;
90
90
  constructor();
91
+ /**
92
+ * 입력 상자를 그리는 컨트롤인가(`u-input` · `u-select` · 날짜 피커 …) — 참이면 `:state(field)` 를 싣는다.
93
+ * 체크박스 · 스위치처럼 글자 옆에 서는 토글은 거짓이다. 하위 클래스가 `static override fieldBox = true` 로 켠다.
94
+ */
95
+ protected static fieldBox: boolean;
91
96
  connectedCallback(): void;
92
97
  /** 자기 `validate()` 가 `internals.checkValidity()` 를 부르는 동안 — 그때 오는 `invalid` 는 보고가 아니다. */
93
98
  private quietCheck;
@@ -101,9 +101,13 @@ var UFormControlElement = class extends UElement {
101
101
  };
102
102
  this.addEventListener("invalid", this.handleInvalid);
103
103
  }
104
+ static {
105
+ this.fieldBox = false;
106
+ }
104
107
  connectedCallback() {
105
108
  super.connectedCallback();
106
109
  if (!this.internals && "attachInternals" in this) this.internals = this.attachInternals();
110
+ if (this.constructor.fieldBox) this.internals?.states.add("field");
107
111
  }
108
112
  /**
109
113
  * 검증 메시지는 `setValidity()` 가 `internals` 에 적어 둔 문장이다 — 다시 그리기만 하면 옛 언어가 그대로 나온다.
@@ -62,6 +62,7 @@ export type { DateDisabledFn } from '../calendar/dates.js';
62
62
  */
63
63
  export declare class UDatePicker extends UFormControlElement<string> {
64
64
  static styles: import('lit').CSSResultGroup[];
65
+ protected static fieldBox: boolean;
65
66
  /** 크기 — 다른 필드·버튼과 같은 세 단(`md` = `--u-density`(14px) · `sm` = 그 6/7(12px) · `lg` = 8/7(16px) — 밀도 단을 바꾸면 셋이 함께 움직인다). */
66
67
  size: FieldSize;
67
68
  /**
@@ -148,6 +148,9 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
148
148
  styles$1
149
149
  ];
150
150
  }
151
+ static {
152
+ this.fieldBox = true;
153
+ }
151
154
  shouldValidate(changed) {
152
155
  return super.shouldValidate(changed) || changed.has("min") || changed.has("max") || changed.has("isDateDisabled");
153
156
  }
@@ -76,6 +76,7 @@ export type { DateRangePreset, DateRangePresetName, DateRangePresetOption } from
76
76
  */
77
77
  export declare class UDateRangePicker extends UFormControlElement<string> {
78
78
  static styles: import('lit').CSSResultGroup[];
79
+ protected static fieldBox: boolean;
79
80
  /** 크기 — 다른 필드·버튼과 같은 세 단(`md` = `--u-density`(14px) · `sm` = 그 6/7(12px) · `lg` = 8/7(16px) — 밀도 단을 바꾸면 셋이 함께 움직인다). */
80
81
  size: FieldSize;
81
82
  /**
@@ -146,6 +146,9 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
146
146
  styles$1
147
147
  ];
148
148
  }
149
+ static {
150
+ this.fieldBox = true;
151
+ }
149
152
  textPattern() {
150
153
  return this.mode === "datetime" ? `${dateTextPattern(this.format)} ${this.seconds ? "HH:mm:ss" : "HH:mm"}` : dateTextPattern(this.format);
151
154
  }
@@ -21,9 +21,12 @@ export type FieldDescriptionDisplay = 'inline' | 'hint';
21
21
  * @csspart footer - 컨트롤 아래 줄(설명, 또는 `invalid` 일 때 검증 문구 — `u-field[invalid]::part(footer)` 로 가른다)
22
22
  * @csspart hint - `description-display="hint"` 의 정보 아이콘 감싸개
23
23
  * @csspart hint-tooltip - 그 툴팁
24
+ *
25
+ * 감싼 칸처럼 `:state(field)` 를 싣는다 — 줄 배치에서 아래 끝으로 서는 «입력 상자를 가진 컨트롤» 이다(`UFormControlElement.fieldBox`).
24
26
  */
25
27
  export declare class UField extends UElement {
26
28
  static styles: import('lit').CSSResultGroup[];
29
+ private readonly fieldInternals?;
27
30
  /** 비활성화 여부 */
28
31
  disabled: boolean;
29
32
  /** 필수 입력 여부 */
@@ -86,6 +86,7 @@ var UField = class UField extends UElement {
86
86
  }
87
87
  constructor(..._args) {
88
88
  super(..._args);
89
+ this.fieldInternals = typeof this.attachInternals === "function" ? this.attachInternals() : void 0;
89
90
  this.disabled = false;
90
91
  this.required = false;
91
92
  this.invalid = false;
@@ -197,6 +198,7 @@ var UField = class UField extends UElement {
197
198
  connectedCallback() {
198
199
  super.connectedCallback();
199
200
  tabNavigation.install();
201
+ this.fieldInternals?.states.add("field");
200
202
  this.addEventListener("pointerdown", this.handleHostPointerDown, true);
201
203
  this.addEventListener("focusin", this.handleFocusIn);
202
204
  this.addEventListener("focusout", this.handleFocusOut);
@@ -23,6 +23,7 @@ import { UFormControlElement } from '../UFormControlElement.js';
23
23
  */
24
24
  export declare class UFileInput extends UFormControlElement<File[] | null> {
25
25
  static styles: import('lit').CSSResultGroup[];
26
+ protected static fieldBox: boolean;
26
27
  /** 값은 attribute로 표현될 수 없다 — 항상 프로그램적으로만 설정된다. */
27
28
  value: File[] | null;
28
29
  /** 선택 가능한 파일 형식을 제한한다(네이티브 `accept` 속성 그대로 통과). */
@@ -47,6 +47,9 @@ var UFileInput = class UFileInput extends UFormControlElement {
47
47
  static {
48
48
  this.styles = [super.styles, styles];
49
49
  }
50
+ static {
51
+ this.fieldBox = true;
52
+ }
50
53
  /** `value`가 바뀌는 모든 경로(선택·지우기)에서 폼 제출값을 동기화한다 —
51
54
  * `UInput`/`UCheckbox`와 같은 경계. 파일은 문자열로 표현할 수
52
55
  * 없으므로 1개면 `File`을, 여러 개면 같은 키로 반복 append한 `FormData`를
@@ -52,6 +52,7 @@ export type FieldSize = 'sm' | 'md' | 'lg';
52
52
  */
53
53
  export declare class UInput extends UFormControlElement<string> {
54
54
  static styles: import('lit').CSSResultGroup[];
55
+ protected static fieldBox: boolean;
55
56
  /** 접두 · 접미 슬롯이 찼는가 — 그 옆 간격은 섀도 안 상자가 갖는다(`::slotted` 여백은 문서의 전역 리셋에 진다). */
56
57
  private readonly affixes;
57
58
  /** 외형 정도 */
@@ -171,6 +171,9 @@ var UInput = class UInput extends UFormControlElement {
171
171
  static {
172
172
  this.styles = [super.styles, styles];
173
173
  }
174
+ static {
175
+ this.fieldBox = true;
176
+ }
174
177
  /** The value as a number — `NaN` when empty or not a number (same as the native input). */
175
178
  get valueAsNumber() {
176
179
  if (this.type !== "number" || !this.value) return NaN;
@@ -41,6 +41,7 @@ import { UPopover } from '../popover/UPopover.js';
41
41
  */
42
42
  export declare class USelect extends UFormControlElement<string | string[]> {
43
43
  static styles: import('lit').CSSResultGroup[];
44
+ protected static fieldBox: boolean;
44
45
  /** 접두 · 접미 슬롯이 찼는가 — 그 옆 간격은 섀도 안 상자가 갖는다(`::slotted` 여백은 문서의 전역 리셋에 진다). */
45
46
  private readonly affixes;
46
47
  /** 트리거 영역의 스타일 변형 */
@@ -203,6 +203,9 @@ var USelect = class USelect extends UFormControlElement {
203
203
  static {
204
204
  this.styles = [super.styles, styles];
205
205
  }
206
+ static {
207
+ this.fieldBox = true;
208
+ }
206
209
  shouldValidate(changed) {
207
210
  return super.shouldValidate(changed) || [
208
211
  "minCount",
@@ -20,6 +20,7 @@ type TextareaResize = 'none' | 'vertical' | 'horizontal' | 'both' | 'auto';
20
20
  */
21
21
  export declare class UTextarea extends UFormControlElement<string> {
22
22
  static styles: import('lit').CSSResultGroup[];
23
+ protected static fieldBox: boolean;
23
24
  /** 스타일 변형 */
24
25
  /** 외형 정도 */
25
26
  appearance: FieldAppearance;
@@ -33,6 +33,9 @@ var UTextarea = class UTextarea extends UFormControlElement {
33
33
  static {
34
34
  this.styles = [super.styles, styles];
35
35
  }
36
+ static {
37
+ this.fieldBox = true;
38
+ }
36
39
  async updated(changedProperties) {
37
40
  super.updated(changedProperties);
38
41
  if (changedProperties.has("value")) this.internals?.setFormValue(this.value ?? "");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iyulab/components",
3
3
  "description": "web-components library based on lit-element made by iyulab",
4
- "version": "2.36.0",
4
+ "version": "2.37.0",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",
@@ -92,7 +92,7 @@
92
92
  "@vitest/browser-playwright": "^5.0.0",
93
93
  "eslint": "^10.1.0",
94
94
  "eslint-plugin-lit": "^2.3.1",
95
- "glob": "^13.0.6",
95
+ "glob": "^14.0.3",
96
96
  "globals": "^17.7.0",
97
97
  "happy-dom": "^21.0.1",
98
98
  "react": "^19.2.7",
@@ -274,6 +274,20 @@ input.reset(); // empties this control and clears its validation state
274
274
 
275
275
  A native `form.reset()` (or `u-button type="reset"`) returns each control to its default — the `value` attribute, `checked` for checkbox/switch — not to empty. A disabled `<fieldset>` disables every control inside it (and `u-button`), exactly like the control's own `disabled` attribute. Style disabled controls with `:disabled`, not `[disabled]`.
276
276
 
277
+ ### Lining up fields with buttons — `:state(field)`
278
+
279
+ Controls that draw an input box — `u-input`, `u-select`, `u-textarea`, `u-date-picker`, `u-date-range-picker`, `u-file-input` (and the `u-field` wrapper) — carry the custom state `:state(field)`. Toggles that sit beside their text (`u-checkbox`, `u-switch`, `u-radio`) do not. A row that mixes fields and buttons can stand the fields on their bottom edge and everything else on one text line, without listing tags:
280
+
281
+ ```css
282
+ .filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
283
+ .filters > * { align-self: last baseline; }
284
+ .filters > :state(field) { align-self: auto; }
285
+ ```
286
+
287
+ Write the rule in the positive form, as above. Chromium does not recompute a `:not(:state(field))` rule when the state arrives as the control connects, so a negated selector keeps matching a field.
288
+
289
+ A control from another package that draws a box sets the state the same way (`protected static override fieldBox = true` on a `UFormControlElement` subclass).
290
+
277
291
  ### Using `u-form` for model binding
278
292
 
279
293
  ```ts