@iyulab/components 2.12.0 → 2.12.1

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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.12.1] - 2026-10-07
4
+
5
+ ### Fixed
6
+
7
+ - **A `chars` field measures again when an inherited font changes** (`u-input`, `u-select`, `u-date-picker`,
8
+ `u-date-range-picker`). The field was measured when it rendered, so a font change coming from outside the
9
+ component — a page switching its density or text size at runtime — left it at the old width: too wide after
10
+ shrinking, cutting the last characters after growing. The field now notices inherited font size, family and
11
+ letter-spacing changes and measures again.
12
+
3
13
  ## [2.12.0] - 2026-10-07
4
14
 
5
15
  ### Added
@@ -17,12 +17,19 @@ export interface CharsWidthOptions {
17
17
  * 자간(`letter-spacing`)을 주면 N자가 `Nch` 를 넘어, «N자리 숫자 칸» 이 마지막 숫자를 잘랐다(Pretendard 14px 에서 자당
18
18
  * 0.33px — 6자리면 2px). 그래서 글자 요소의 계산된 글꼴을 옮긴 보이지 않는 요소에 `0` N개를 실제로 그리고 그 폭을 쓴다.
19
19
  * 크기는 `ResizeObserver` 로 따른다 — 웹 글꼴이 늦게 실리거나 크기 단(`size`)이 바뀌어 폭이 달라지면 다시 읽는다.
20
+ *
21
+ * 측정 요소는 글꼴을 계산값(px)으로 **복사**하므로, 호스트 밖에서 상속된 글꼴이 바뀌어도(밀도·글자 크기 단을 루트에서
22
+ * 런타임에 전환) 스스로는 달라지지 않는다 — 호스트는 다시 그려지지 않고 복사본은 옛 값을 들고 있다. 그래서 같은 자리에
23
+ * 글꼴을 복사하지 않고 **상속하는** 감시 요소를 하나 더 두고, 그 크기가 바뀌면 다시 복사해 잰다. 복사를 버리지 않는
24
+ * 이유: 글자 요소 자신에 걸린 글꼴(`::part(input)` 의 글꼴 기능 등)은 상속으로 오지 않는다.
20
25
  * 재기 전(첫 그림)에는 `Nch` 로 그린다.
21
26
  */
22
27
  export declare class CharsWidthController implements ReactiveController {
23
28
  private readonly host;
24
29
  private readonly options;
25
30
  private sizer?;
31
+ /** 글꼴을 상속하는 감시 요소 — 상속된 글꼴이 바뀌면 크기가 바뀐다. */
32
+ private watch?;
26
33
  private observer?;
27
34
  private measured?;
28
35
  constructor(host: ReactiveControllerHost & HTMLElement, options: CharsWidthOptions);
@@ -23,6 +23,11 @@ var FONT_PROPS = [
23
23
  * 자간(`letter-spacing`)을 주면 N자가 `Nch` 를 넘어, «N자리 숫자 칸» 이 마지막 숫자를 잘랐다(Pretendard 14px 에서 자당
24
24
  * 0.33px — 6자리면 2px). 그래서 글자 요소의 계산된 글꼴을 옮긴 보이지 않는 요소에 `0` N개를 실제로 그리고 그 폭을 쓴다.
25
25
  * 크기는 `ResizeObserver` 로 따른다 — 웹 글꼴이 늦게 실리거나 크기 단(`size`)이 바뀌어 폭이 달라지면 다시 읽는다.
26
+ *
27
+ * 측정 요소는 글꼴을 계산값(px)으로 **복사**하므로, 호스트 밖에서 상속된 글꼴이 바뀌어도(밀도·글자 크기 단을 루트에서
28
+ * 런타임에 전환) 스스로는 달라지지 않는다 — 호스트는 다시 그려지지 않고 복사본은 옛 값을 들고 있다. 그래서 같은 자리에
29
+ * 글꼴을 복사하지 않고 **상속하는** 감시 요소를 하나 더 두고, 그 크기가 바뀌면 다시 복사해 잰다. 복사를 버리지 않는
30
+ * 이유: 글자 요소 자신에 걸린 글꼴(`::part(input)` 의 글꼴 기능 등)은 상속으로 오지 않는다.
26
31
  * 재기 전(첫 그림)에는 `Nch` 로 그린다.
27
32
  */
28
33
  var CharsWidthController = class {
@@ -60,17 +65,29 @@ var CharsWidthController = class {
60
65
  frame.style.cssText = "position:absolute;inset-block-start:0;inset-inline-start:0;inline-size:0;block-size:0;overflow:hidden;visibility:hidden;pointer-events:none";
61
66
  const sizer = document.createElement("span");
62
67
  sizer.style.cssText = "display:inline-block;white-space:pre";
63
- frame.appendChild(sizer);
68
+ const watch = document.createElement("span");
69
+ watch.style.cssText = "display:inline-block;white-space:pre";
70
+ frame.append(sizer, watch);
64
71
  box.appendChild(frame);
65
72
  this.sizer = sizer;
66
- this.observer = new ResizeObserver((entries) => this.read(entries[entries.length - 1].contentRect.width));
73
+ this.watch = watch;
74
+ this.observer = new ResizeObserver((entries) => {
75
+ let sized;
76
+ let inherited = false;
77
+ for (const entry of entries) if (entry.target === sizer) sized = entry.contentRect.width;
78
+ else inherited = true;
79
+ if (inherited) this.measure();
80
+ if (sized != null) this.read(sized);
81
+ });
67
82
  this.observer.observe(sizer);
83
+ this.observer.observe(watch);
68
84
  }
69
85
  const sizer = this.sizer;
70
86
  const source = getComputedStyle(this.options.text() ?? box);
71
87
  for (const prop of FONT_PROPS) sizer.style.setProperty(prop, source.getPropertyValue(prop));
72
88
  const digits = "0".repeat(n);
73
89
  if (sizer.textContent !== digits) sizer.textContent = digits;
90
+ if (this.watch && this.watch.textContent !== digits) this.watch.textContent = digits;
74
91
  }
75
92
  read(width) {
76
93
  if (!(width > 0)) return;
@@ -84,6 +101,7 @@ var CharsWidthController = class {
84
101
  this.observer = void 0;
85
102
  this.sizer?.parentElement?.remove();
86
103
  this.sizer = void 0;
104
+ this.watch = void 0;
87
105
  this.measured = void 0;
88
106
  }
89
107
  };
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.12.0",
4
+ "version": "2.12.1",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",