@iyulab/components 2.2.2 → 2.3.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,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.3.1] - 2026-10-06
4
+
5
+ ### Fixed
6
+
7
+ - **`Toast` renders its message as text.** `Toast.success`/`error`/`info`/`warning`/`notice`/`message`/`show` set the
8
+ message as the alert's `innerHTML`, so markup inside it became elements — and toasts carry server error messages
9
+ (`Toast.error(err.message)`, a data service's `notify.error`) and user data. Same class as the `Dialog` fix in 2.3.0;
10
+ HTML in a toast was never documented.
11
+
12
+ ## [2.3.0] - 2026-10-06
13
+
14
+ ### Fixed
15
+
16
+ - **`Dialog.alert` and `Dialog.confirm` render a string `message` as text**, like `Dialog.prompt` always did. They passed
17
+ it to `show({ content })`, whose string `content` is HTML, so a confirmation that included user input (an item's
18
+ name) could inject markup — `<img src=x onerror=…>` ran. Nothing documented HTML in these messages; if you relied on
19
+ it, pass a `TemplateResult` (below) or use `Dialog.show({ content })`, which keeps its HTML-string contract.
20
+
21
+ ### Added
22
+
23
+ - `Dialog.alert` / `Dialog.confirm` accept `string | TemplateResult` — formatting goes through a Lit template, whose
24
+ interpolated values stay text.
25
+
3
26
  ## [2.2.2] - 2026-10-06
4
27
 
5
28
  ### Documentation
@@ -68,13 +68,16 @@ export declare class Dialog {
68
68
  private constructor();
69
69
  /**
70
70
  * 알림 다이얼로그를 표시합니다.
71
+ * @param message 본문 — **문자열은 글자로** 그린다(사용자 입력을 넣어도 마크업이 되지 않는다). 서식이 필요하면
72
+ * `TemplateResult`(`html\`…\``)를 넘긴다. HTML 문자열은 그것을 명시한 `show({ content })` 로만.
71
73
  */
72
- static alert(message: string, options?: DialogOptions): Promise<void>;
74
+ static alert(message: string | TemplateResult, options?: DialogOptions): Promise<void>;
73
75
  /**
74
76
  * 확인 다이얼로그를 표시합니다. (확인/취소 버튼)
77
+ * @param message 본문 — **문자열은 글자로** 그린다(`alert` 와 같다). 서식은 `TemplateResult` 로.
75
78
  * @returns 확인이면 true, 취소이면 false
76
79
  */
77
- static confirm(message: string, options?: ConfirmDialogOptions): Promise<boolean>;
80
+ static confirm(message: string | TemplateResult, options?: ConfirmDialogOptions): Promise<boolean>;
78
81
  /**
79
82
  * 입력 다이얼로그를 표시합니다. (텍스트 입력 + 확인/취소)
80
83
  * @returns 입력값 또는 취소 시 null
@@ -8,6 +8,13 @@ import { ifDefined } from "lit/directives/if-defined.js";
8
8
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
9
9
  //#region src/utilities/Dialog.ts
10
10
  /**
11
+ * 메시지를 본문 템플릿으로 — 문자열은 lit 이 글자로 이스케이프한다. `show` 는 문자열 `content` 를 HTML 로 해석하므로
12
+ * (그것이 `show` 의 계약이다) `alert`·`confirm` 이 문자열을 그대로 넘기면 그 계약을 조용히 물려받아 마크업 주입 싱크가 된다.
13
+ */
14
+ function asText(message) {
15
+ return html`${message}`;
16
+ }
17
+ /**
11
18
  * Dialog 유틸리티 클래스입니다.
12
19
  * 프로그래밍 방식으로 alert, confirm, prompt 다이얼로그를 표시합니다.
13
20
  */
@@ -16,21 +23,24 @@ var Dialog = class {
16
23
  constructor() {}
17
24
  /**
18
25
  * 알림 다이얼로그를 표시합니다.
26
+ * @param message 본문 — **문자열은 글자로** 그린다(사용자 입력을 넣어도 마크업이 되지 않는다). 서식이 필요하면
27
+ * `TemplateResult`(`html\`…\``)를 넘긴다. HTML 문자열은 그것을 명시한 `show({ content })` 로만.
19
28
  */
20
29
  static async alert(message, options) {
21
30
  await this.show({
22
31
  ...options,
23
- content: message
32
+ content: asText(message)
24
33
  });
25
34
  }
26
35
  /**
27
36
  * 확인 다이얼로그를 표시합니다. (확인/취소 버튼)
37
+ * @param message 본문 — **문자열은 글자로** 그린다(`alert` 와 같다). 서식은 `TemplateResult` 로.
28
38
  * @returns 확인이면 true, 취소이면 false
29
39
  */
30
40
  static async confirm(message, options) {
31
41
  return await this.show({
32
42
  ...options,
33
- content: message,
43
+ content: asText(message),
34
44
  actions: [{
35
45
  label: options?.cancelLabel || Locale.getValue("cancel"),
36
46
  value: "cancel",
@@ -45,7 +45,7 @@ var Toast = class {
45
45
  };
46
46
  const el = new UAlert();
47
47
  el.status = status;
48
- el.innerHTML = content || "";
48
+ el.textContent = content || "";
49
49
  el.appearance = merged.appearance || "soft";
50
50
  el.title = merged.title || "";
51
51
  el.closable = merged.closable ?? true;
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.2.2",
4
+ "version": "2.3.1",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",
@@ -45,6 +45,11 @@ const result = await Dialog.show({
45
45
  | `Dialog.prompt(message, options?)` | `Promise<string \| null>` | Text input dialog |
46
46
  | `Dialog.show(options)` | `Promise<string \| null>` | Custom dialog; resolves with clicked action `value` |
47
47
 
48
+ `message` is **text**: a string is rendered as text in `alert`, `confirm` and `prompt`, so a user-supplied name in a
49
+ confirmation cannot inject markup. For formatting pass a Lit `TemplateResult`
50
+ (`Dialog.confirm(html\`Delete <strong>${name}</strong>?\`)` — interpolated values stay text). Only
51
+ `Dialog.show({ content })` takes an HTML string, and says so.
52
+
48
53
  ## Types
49
54
 
50
55
  ```ts
@@ -6,6 +6,9 @@ import { Toast } from '@iyulab/components';
6
6
 
7
7
  Programmatically display toast notifications. Creates `u-alert` elements dynamically and mounts them in a toast container.
8
8
 
9
+ The message is **text** — it is set as the alert's text content, so an error message from a server or a name typed by
10
+ a user cannot inject markup.
11
+
9
12
  ## Usage
10
13
 
11
14
  ```ts