@iyulab/components 1.3.4 → 1.4.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 (126) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/_virtual/_glob-assets_raw/dark.css.e8ac080d.js +1 -1
  3. package/dist/assets/locales/ar.json.js +23 -0
  4. package/dist/assets/locales/de.json.js +23 -0
  5. package/dist/assets/locales/en.json.js +23 -0
  6. package/dist/assets/locales/es.json.js +23 -0
  7. package/dist/assets/locales/fr.json.js +23 -0
  8. package/dist/assets/locales/id.json.js +23 -0
  9. package/dist/assets/locales/ja.json.js +23 -0
  10. package/dist/assets/locales/ko.json.js +23 -0
  11. package/dist/assets/locales/pt-BR.json.js +23 -0
  12. package/dist/assets/locales/ru.json.js +23 -0
  13. package/dist/assets/locales/th.json.js +23 -0
  14. package/dist/assets/locales/vi.json.js +23 -0
  15. package/dist/assets/locales/zh-CN.json.js +23 -0
  16. package/dist/assets/locales/zh-TW.json.js +23 -0
  17. package/dist/components/UFloatingElement.js +13 -4
  18. package/dist/components/UFormControlElement.d.ts +38 -8
  19. package/dist/components/UFormControlElement.js +61 -6
  20. package/dist/components/UOverlayElement.d.ts +4 -0
  21. package/dist/components/UOverlayElement.js +14 -4
  22. package/dist/components/alert/UAlert.js +10 -4
  23. package/dist/components/alert/UAlert.styles.js +0 -6
  24. package/dist/components/avatar/UAvatar.js +1 -1
  25. package/dist/components/badge/UBadge.d.ts +1 -1
  26. package/dist/components/badge/UBadge.js +2 -2
  27. package/dist/components/badge/UBadge.styles.js +1 -1
  28. package/dist/components/breadcrumb/UBreadcrumb.js +1 -1
  29. package/dist/components/breadcrumb-item/UBreadcrumbItem.js +1 -1
  30. package/dist/components/button/UButton.d.ts +6 -11
  31. package/dist/components/button/UButton.js +1 -1
  32. package/dist/components/button/UButton.styles.js +50 -51
  33. package/dist/components/button-group/UButtonGroup.js +1 -1
  34. package/dist/components/card/UCard.js +1 -1
  35. package/dist/components/carousel/UCarousel.js +2 -2
  36. package/dist/components/checkbox/UCheckbox.d.ts +4 -1
  37. package/dist/components/checkbox/UCheckbox.js +11 -8
  38. package/dist/components/checkbox/UCheckbox.styles.js +12 -7
  39. package/dist/components/chip/UChip.js +6 -3
  40. package/dist/components/dialog/UDialog.js +2 -2
  41. package/dist/components/divider/UDivider.js +1 -1
  42. package/dist/components/drawer/UDrawer.js +2 -2
  43. package/dist/components/drawer/UDrawer.styles.js +0 -6
  44. package/dist/components/field/UField.js +1 -1
  45. package/dist/components/form/UForm.js +1 -1
  46. package/dist/components/icon/UIcon.js +1 -1
  47. package/dist/components/icon-button/UIconButton.d.ts +0 -1
  48. package/dist/components/icon-button/UIconButton.js +2 -7
  49. package/dist/components/input/UInput.d.ts +2 -3
  50. package/dist/components/input/UInput.js +37 -9
  51. package/dist/components/input/UInput.styles.js +1 -4
  52. package/dist/components/menu/UMenu.js +1 -1
  53. package/dist/components/menu-item/UMenuItem.js +1 -1
  54. package/dist/components/menu-item/UMenuItem.styles.js +4 -3
  55. package/dist/components/option/UOption.d.ts +4 -1
  56. package/dist/components/option/UOption.js +10 -4
  57. package/dist/components/option/UOption.styles.js +5 -4
  58. package/dist/components/panel/UPanel.js +1 -1
  59. package/dist/components/popover/UPopover.js +1 -1
  60. package/dist/components/progress-bar/UProgressBar.js +1 -1
  61. package/dist/components/progress-bar/UProgressBar.styles.js +2 -2
  62. package/dist/components/progress-ring/UProgressRing.js +1 -1
  63. package/dist/components/progress-ring/UProgressRing.styles.js +2 -2
  64. package/dist/components/radio/URadio.d.ts +1 -1
  65. package/dist/components/radio/URadio.js +5 -6
  66. package/dist/components/radio/URadio.styles.js +21 -16
  67. package/dist/components/rating/URating.d.ts +3 -2
  68. package/dist/components/rating/URating.js +30 -37
  69. package/dist/components/select/USelect.d.ts +8 -5
  70. package/dist/components/select/USelect.js +29 -41
  71. package/dist/components/select/USelect.styles.js +5 -5
  72. package/dist/components/skeleton/USkeleton.js +1 -1
  73. package/dist/components/slider/USlider.d.ts +3 -2
  74. package/dist/components/slider/USlider.js +20 -30
  75. package/dist/components/slider/USlider.styles.js +2 -2
  76. package/dist/components/spinner/USpinner.js +1 -1
  77. package/dist/components/spinner/USpinner.styles.js +1 -1
  78. package/dist/components/split-panel/USplitPanel.js +25 -13
  79. package/dist/components/switch/USwitch.d.ts +4 -1
  80. package/dist/components/switch/USwitch.js +11 -8
  81. package/dist/components/switch/USwitch.styles.js +5 -1
  82. package/dist/components/tab/UTab.js +6 -3
  83. package/dist/components/tab-panel/UTabPanel.d.ts +5 -0
  84. package/dist/components/tab-panel/UTabPanel.js +12 -4
  85. package/dist/components/tab-panel/UTabPanel.styles.js +7 -3
  86. package/dist/components/tag/UTag.js +1 -1
  87. package/dist/components/tag/UTag.styles.js +14 -13
  88. package/dist/components/textarea/UTextarea.d.ts +1 -1
  89. package/dist/components/textarea/UTextarea.js +17 -6
  90. package/dist/components/tooltip/UTooltip.js +1 -1
  91. package/dist/components/tree/UTree.js +1 -1
  92. package/dist/components/tree-item/UTreeItem.js +10 -4
  93. package/dist/components/tree-item/UTreeItem.styles.js +5 -4
  94. package/dist/index.d.ts +2 -4
  95. package/dist/index.js +6 -8
  96. package/dist/react/UTabPanel.d.ts +1 -0
  97. package/dist/react/UTabPanel.js +3 -1
  98. package/dist/styles/dark.css +99 -99
  99. package/dist/utilities/Locale.d.ts +38 -0
  100. package/dist/utilities/Locale.js +93 -0
  101. package/dist/utilities/Toast.d.ts +9 -0
  102. package/dist/utilities/Toast.js +15 -7
  103. package/dist/utilities/elements.d.ts +0 -23
  104. package/dist/utilities/elements.js +1 -34
  105. package/package.json +2 -3
  106. package/skills/iyulab-components/SKILL.md +2 -3
  107. package/skills/iyulab-components/references/components/input.md +1 -2
  108. package/skills/iyulab-components/references/components/option.md +1 -0
  109. package/skills/iyulab-components/references/components/select.md +1 -2
  110. package/skills/iyulab-components/references/components/tab-panel.md +6 -0
  111. package/skills/iyulab-components/references/extensions/form-control.md +22 -6
  112. package/skills/iyulab-components/references/usage.md +11 -0
  113. package/skills/iyulab-components/references/utilities/elements.md +1 -17
  114. package/skills/iyulab-components/references/utilities/locale.md +36 -0
  115. package/skills/iyulab-components/references/utilities/theme.md +12 -0
  116. package/skills/iyulab-components/references/utilities/toast.md +6 -0
  117. package/dist/components/UDataElement.d.ts +0 -44
  118. package/dist/components/UDataElement.js +0 -101
  119. package/dist/components/UDataElement.styles.d.ts +0 -1
  120. package/dist/components/UDataElement.styles.js +0 -95
  121. package/dist/core/locale.d.ts +0 -69
  122. package/dist/core/locale.js +0 -85
  123. package/dist/utilities/sanitizers.d.ts +0 -35
  124. package/dist/utilities/sanitizers.js +0 -75
  125. package/skills/iyulab-components/references/extensions/data.md +0 -60
  126. package/skills/iyulab-components/references/utilities/sanitizers.md +0 -32
@@ -1,95 +0,0 @@
1
- import { css } from "lit";
2
- //#region src/components/UDataElement.styles.ts
3
- var styles = css`
4
- .error-container {
5
- display: flex;
6
- flex-direction: column;
7
- border: 1px solid var(--u-red-200);
8
- border-radius: 10px;
9
- background: var(--u-red-0);
10
- color: var(--u-red-700);
11
- overflow: hidden;
12
- font-size: 0.875em;
13
- line-height: 1.5;
14
- }
15
-
16
- .error-header {
17
- display: flex;
18
- flex-direction: row;
19
- align-items: center;
20
- gap: 0.5em;
21
- padding: 0.55em 0.9em;
22
- background: var(--u-red-50);
23
- border-bottom: 1px solid var(--u-red-200);
24
- }
25
-
26
- .error-icon {
27
- font-size: 0.95em;
28
- color: var(--u-red-500);
29
- flex-shrink: 0;
30
- }
31
-
32
- .error-title {
33
- font-weight: 700;
34
- letter-spacing: 0.01em;
35
- flex: 1;
36
- }
37
-
38
- .error-tag {
39
- font-family: var(--u-font-mono);
40
- font-size: 0.85em;
41
- padding: 0.1em 0.45em;
42
- color: var(--u-red-600);
43
- border: 1px solid var(--u-red-200);
44
- border-radius: 4px;
45
- background: var(--u-red-100);
46
- }
47
-
48
- .error-body {
49
- display: flex;
50
- flex-direction: column;
51
- padding: 0.6em 0.9em;
52
- gap: 0.45em;
53
- }
54
-
55
- .error-row {
56
- display: flex;
57
- flex-direction: row;
58
- align-items: baseline;
59
- gap: 0.6em;
60
- min-height: 1.6em;
61
- }
62
-
63
- .error-label {
64
- flex-shrink: 0;
65
- width: 5em;
66
- font-size: 0.78em;
67
- font-weight: 700;
68
- text-transform: uppercase;
69
- letter-spacing: 0.06em;
70
- opacity: 0.55;
71
- padding-top: 0.15em;
72
- }
73
-
74
- .error-type {
75
- font-family: var(--u-font-mono);
76
- font-size: 0.85em;
77
- padding: 0.1em 0.4em;
78
- color: var(--u-red-700);
79
- background: var(--u-red-100);
80
- border-radius: 4px;
81
- }
82
-
83
- .error-message {
84
- margin: 0;
85
- flex: 1;
86
- white-space: pre-wrap;
87
- word-break: break-all;
88
- font-family: var(--u-font-mono);
89
- font-size: 0.9em;
90
- opacity: 0.85;
91
- line-height: 1.55;
92
- }
93
- `;
94
- //#endregion
95
- export { styles };
@@ -1,69 +0,0 @@
1
- /**
2
- * @iyulab/components 의 경량 로케일 레지스트리.
3
- *
4
- * 범위: 라이브러리가 스스로 생성하는 chrome 문자열(검증 메시지 등)만 대상.
5
- * 일반 i18n 프레임워크가 아니다. 앱 콘텐츠 번역은 consumer 의 i18n 계층(예:
6
- * modern-app 의 i18next)이 담당한다.
7
- *
8
- * 영어가 내장 기본값이며, 한국어 등 도메인 로케일은 consumer 가 등록한다:
9
- * registerLocale('ko', { required: '필수 항목입니다.', ... });
10
- * setDefaultLocale('ko');
11
- *
12
- * 모노레포 로케일 표준(packages/u-widgets/src/core/locale.ts)과 동일한 계약을 따른다.
13
- */
14
- export interface UComponentsLocaleStrings {
15
- required: string;
16
- minValue: string;
17
- maxValue: string;
18
- stepMismatch: string;
19
- minCount: string;
20
- maxCount: string;
21
- }
22
- /**
23
- * 로케일을 등록한다. 부분 등록은 영어 기본값에 병합된다.
24
- */
25
- export declare function registerLocale(lang: string, strings: Partial<UComponentsLocaleStrings>): void;
26
- /**
27
- * 주어진 언어 태그에 대한 로케일 문자열을 해석한다.
28
- *
29
- * 해석 순서:
30
- * 1. 정확히 일치 (예: 'ko-KR')
31
- * 2. 기반 언어 (예: 'ko')
32
- * 3. 영어 폴백
33
- */
34
- export declare function getLocaleStrings(lang?: string): UComponentsLocaleStrings;
35
- /**
36
- * 템플릿 문자열의 {key} 플레이스홀더를 치환한다.
37
- */
38
- export declare function formatTemplate(template: string, params: Record<string, string | number>): string;
39
- /**
40
- * 영어 기본값을 반환한다 (테스트/참조용).
41
- */
42
- export declare function getDefaultLocale(): UComponentsLocaleStrings;
43
- /**
44
- * 모든 컴포넌트에 적용되는 전역 기본 로케일을 설정한다.
45
- *
46
- * 해석 순서(우선순위 높은 순):
47
- * 1. 컴포넌트별 `locale` 속성/프로퍼티
48
- * 2. setDefaultLocale() 값
49
- * 3. document.documentElement.lang (브라우저)
50
- * 4. 영어 폴백
51
- *
52
- * @example
53
- * ```ts
54
- * import { setDefaultLocale } from '@iyulab/components';
55
- * setDefaultLocale('ko-KR');
56
- * ```
57
- */
58
- export declare function setDefaultLocale(lang: string | undefined): void;
59
- /**
60
- * setDefaultLocale() 로 설정된 전역 기본 로케일을 반환한다.
61
- * 설정되지 않았으면 undefined 를 반환한다.
62
- */
63
- export declare function getEffectiveLocale(): string | undefined;
64
- /**
65
- * 컴포넌트가 사용할 로케일을 해석한다.
66
- *
67
- * 우선순위: widgetLocale > setDefaultLocale() > document.lang > undefined
68
- */
69
- export declare function resolveLocale(widgetLocale?: string | null): string | undefined;
@@ -1,85 +0,0 @@
1
- //#region src/core/locale.ts
2
- var EN = {
3
- required: "This field is required",
4
- minValue: "Value must be at least {min}",
5
- maxValue: "Value must be at most {max}",
6
- stepMismatch: "Value must be a multiple of {step}",
7
- minCount: "Please select at least {min} items",
8
- maxCount: "Please select no more than {max} items"
9
- };
10
- var registry = /* @__PURE__ */ new Map();
11
- /**
12
- * 로케일을 등록한다. 부분 등록은 영어 기본값에 병합된다.
13
- */
14
- function registerLocale(lang, strings) {
15
- registry.set(lang.toLowerCase(), {
16
- ...EN,
17
- ...strings
18
- });
19
- }
20
- /**
21
- * 주어진 언어 태그에 대한 로케일 문자열을 해석한다.
22
- *
23
- * 해석 순서:
24
- * 1. 정확히 일치 (예: 'ko-KR')
25
- * 2. 기반 언어 (예: 'ko')
26
- * 3. 영어 폴백
27
- */
28
- function getLocaleStrings(lang) {
29
- if (!lang) return EN;
30
- const key = lang.toLowerCase();
31
- if (registry.has(key)) return registry.get(key);
32
- const base = key.split("-")[0];
33
- if (base !== key && registry.has(base)) return registry.get(base);
34
- return EN;
35
- }
36
- /**
37
- * 템플릿 문자열의 {key} 플레이스홀더를 치환한다.
38
- */
39
- function formatTemplate(template, params) {
40
- return template.replace(/\{(\w+)\}/g, (_, key) => params[key] != null ? String(params[key]) : `{${key}}`);
41
- }
42
- /**
43
- * 영어 기본값을 반환한다 (테스트/참조용).
44
- */
45
- function getDefaultLocale() {
46
- return { ...EN };
47
- }
48
- var _defaultLocale;
49
- /**
50
- * 모든 컴포넌트에 적용되는 전역 기본 로케일을 설정한다.
51
- *
52
- * 해석 순서(우선순위 높은 순):
53
- * 1. 컴포넌트별 `locale` 속성/프로퍼티
54
- * 2. setDefaultLocale() 값
55
- * 3. document.documentElement.lang (브라우저)
56
- * 4. 영어 폴백
57
- *
58
- * @example
59
- * ```ts
60
- * import { setDefaultLocale } from '@iyulab/components';
61
- * setDefaultLocale('ko-KR');
62
- * ```
63
- */
64
- function setDefaultLocale(lang) {
65
- _defaultLocale = lang;
66
- }
67
- /**
68
- * setDefaultLocale() 로 설정된 전역 기본 로케일을 반환한다.
69
- * 설정되지 않았으면 undefined 를 반환한다.
70
- */
71
- function getEffectiveLocale() {
72
- return _defaultLocale;
73
- }
74
- /**
75
- * 컴포넌트가 사용할 로케일을 해석한다.
76
- *
77
- * 우선순위: widgetLocale > setDefaultLocale() > document.lang > undefined
78
- */
79
- function resolveLocale(widgetLocale) {
80
- if (widgetLocale) return widgetLocale;
81
- if (_defaultLocale) return _defaultLocale;
82
- if (typeof document !== "undefined" && document.documentElement?.lang) return document.documentElement.lang;
83
- }
84
- //#endregion
85
- export { formatTemplate, getDefaultLocale, getEffectiveLocale, getLocaleStrings, registerLocale, resolveLocale, setDefaultLocale };
@@ -1,35 +0,0 @@
1
- /**
2
- * HTML 출력 시 XSS 방지를 위한 escape 유틸
3
- *
4
- * 컨텍스트에 맞는 함수를 사용해야 합니다.
5
- *
6
- * - escapeHtmlText : HTML 텍스트 노드에 삽입할 때
7
- * - escapeHtmlAttr : HTML attribute 값에 삽입할 때
8
- * - escapeHtmlHref : href/src 같은 URL attribute에 삽입할 때
9
- */
10
- /**
11
- * Zero Width Space / LTR / RTL mark / BOM 등
12
- * 화면에 표시되지 않는 유니코드 문자를 제거합니다.
13
- */
14
- export declare function stripZeroWidth(value: string): string;
15
- /**
16
- * HTML 텍스트 노드(context)에 삽입할 문자열을 escape합니다.
17
- *
18
- * 예:
19
- * <script> → &lt;script&gt;
20
- */
21
- export declare function escapeHtmlText(value: string): string;
22
- /**
23
- * HTML attribute 값(context)에 삽입할 문자열을 escape합니다.
24
- *
25
- * 예:
26
- * <div title="{value}">
27
- */
28
- export declare function escapeHtmlAttr(value: string): string;
29
- /**
30
- * href / src attribute용 문자열 처리
31
- *
32
- * 예:
33
- * <a href="{value}">
34
- */
35
- export declare function escapeHtmlHref(value: string): string;
@@ -1,75 +0,0 @@
1
- //#region src/utilities/sanitizers.ts
2
- /**
3
- * HTML 출력 시 XSS 방지를 위한 escape 유틸
4
- *
5
- * 컨텍스트에 맞는 함수를 사용해야 합니다.
6
- *
7
- * - escapeHtmlText : HTML 텍스트 노드에 삽입할 때
8
- * - escapeHtmlAttr : HTML attribute 값에 삽입할 때
9
- * - escapeHtmlHref : href/src 같은 URL attribute에 삽입할 때
10
- */
11
- /**
12
- * Zero Width Space / LTR / RTL mark / BOM 등
13
- * 화면에 표시되지 않는 유니코드 문자를 제거합니다.
14
- */
15
- function stripZeroWidth(value) {
16
- const ZERO_WIDTH_REGEX = /[\u200B\u200C\u200D\u200E\u200F\uFEFF]/g;
17
- return ZERO_WIDTH_REGEX.test(value) ? value.replace(ZERO_WIDTH_REGEX, "") : value;
18
- }
19
- /** HTML text context escape 대상 문자 */
20
- var HTML_TEXT_ESCAPE_REGEX = /[&<>"']/g;
21
- /** HTML text context escape용 문자 매핑 */
22
- var HTML_TEXT_ESCAPE_MAP = {
23
- "&": "&amp;",
24
- "<": "&lt;",
25
- ">": "&gt;",
26
- "\"": "&quot;",
27
- "'": "&#39;"
28
- };
29
- /**
30
- * HTML 텍스트 노드(context)에 삽입할 문자열을 escape합니다.
31
- *
32
- * 예:
33
- * <script> → &lt;script&gt;
34
- */
35
- function escapeHtmlText(value) {
36
- return HTML_TEXT_ESCAPE_REGEX.test(value) ? value.replace(HTML_TEXT_ESCAPE_REGEX, (ch) => HTML_TEXT_ESCAPE_MAP[ch]) : value;
37
- }
38
- /** HTML attribute escape 대상 문자 */
39
- var HTML_ATTR_ESCAPE_REGEX = /[&<>"]/g;
40
- /** HTML attribute escape용 문자 매핑 */
41
- var HTML_ATTR_ESCAPE_MAP = {
42
- "&": "&amp;",
43
- "<": "&lt;",
44
- ">": "&gt;",
45
- "\"": "&quot;"
46
- };
47
- /**
48
- * HTML attribute 값(context)에 삽입할 문자열을 escape합니다.
49
- *
50
- * 예:
51
- * <div title="{value}">
52
- */
53
- function escapeHtmlAttr(value) {
54
- return HTML_ATTR_ESCAPE_REGEX.test(value) ? value.replace(HTML_ATTR_ESCAPE_REGEX, (ch) => HTML_ATTR_ESCAPE_MAP[ch]) : value;
55
- }
56
- /** protocol 우회 공격 방지를 위한 공백/제어문자 제거 */
57
- var HREF_STRIP_CHARS_REGEX = /[\u0000-\u001F\u007F\s]+/g;
58
- /** href/src에서 차단해야 하는 위험 protocol */
59
- var HREF_UNSAFE_PROTOCOL_REGEX = /^(?:javascript|data|vbscript):/i;
60
- /**
61
- * href / src attribute용 문자열 처리
62
- *
63
- * 예:
64
- * <a href="{value}">
65
- */
66
- function escapeHtmlHref(value) {
67
- let normalized = stripZeroWidth(value).trim();
68
- if (HREF_STRIP_CHARS_REGEX.test(normalized)) normalized = normalized.replace(HREF_STRIP_CHARS_REGEX, "");
69
- normalized = normalized.replace(/\\/g, "/");
70
- if (normalized.startsWith("//")) return "#";
71
- if (HREF_UNSAFE_PROTOCOL_REGEX.test(normalized)) return "#";
72
- return escapeHtmlAttr(normalized);
73
- }
74
- //#endregion
75
- export { escapeHtmlAttr, escapeHtmlHref, escapeHtmlText, stripZeroWidth };
@@ -1,60 +0,0 @@
1
- # UDataElement
2
-
3
- ```ts
4
- import { UDataElement } from '@iyulab/components';
5
- ```
6
-
7
- Base class for data-driven components that load their initial data from an inline `<script type="application/json">` tag in the light DOM.
8
-
9
- ## When to extend
10
-
11
- Use when you want to declare component data directly in HTML without JavaScript, or when server-rendering initial state into the page.
12
-
13
- ```ts
14
- import { UDataElement } from '@iyulab/components';
15
- import { customElement } from 'lit/decorators.js';
16
- import { html } from 'lit';
17
-
18
- @customElement('my-list')
19
- export class MyList extends UDataElement {
20
- private items: string[] = [];
21
-
22
- protected override async load(data?: unknown) {
23
- if (Array.isArray(data)) {
24
- this.items = data as string[];
25
- }
26
- }
27
-
28
- render() {
29
- return html`
30
- <ul>${this.items.map(i => html`<li>${i}</li>`)}</ul>
31
- `;
32
- }
33
- }
34
- ```
35
-
36
- ```html
37
- <my-list>
38
- <script type="application/json">
39
- ["Item A", "Item B", "Item C"]
40
- </script>
41
- </my-list>
42
- ```
43
-
44
- ## Static Methods
45
-
46
- | Method | Returns | Description |
47
- |--------|---------|-------------|
48
- | `buildHTML(json, attrs?)` | `string` | Build a safe inline HTML string with JSON data embedded in a `<script type="application/json">` child |
49
-
50
- ```ts
51
- const html = MyList.buildHTML(['Item A', 'Item B'], { class: 'my-list' });
52
- // → '<my-list class="my-list"><script type="application/json">["Item A","Item B"]</script></my-list>'
53
- ```
54
-
55
- ## Protected Methods
56
-
57
- | Method | Returns | Description |
58
- |--------|---------|-------------|
59
- | `load(data?)` | `Promise<void>` | Called with the parsed JSON data after the element connects; override to handle data |
60
- | `error(error)` | `Promise<void>` | Called when JSON parsing fails; override to handle errors |
@@ -1,32 +0,0 @@
1
- # sanitizers
2
-
3
- ```ts
4
- import { escapeHtmlText, escapeHtmlAttr, escapeHtmlHref, stripZeroWidth } from '@iyulab/components';
5
- ```
6
-
7
- XSS-safe escaping helpers for HTML output. Use these whenever inserting user-supplied content into HTML strings (e.g. inside `buildElementHTML` or custom template rendering).
8
-
9
- ## Functions
10
-
11
- | Function | Use case | Description |
12
- |----------|----------|-------------|
13
- | `escapeHtmlText(value)` | Text node content | Escapes `&`, `<`, `>`, `"`, `'` |
14
- | `escapeHtmlAttr(value)` | HTML attribute values | Escapes `&`, `<`, `>`, `"` |
15
- | `escapeHtmlHref(value)` | `href` / `src` URLs | Escapes HTML entities + blocks `javascript:` and `data:` protocol injection |
16
- | `stripZeroWidth(value)` | Any string output | Removes zero-width Unicode characters (e.g. U+200B) |
17
-
18
- ## Example
19
-
20
- ```ts
21
- import { escapeHtmlText, escapeHtmlHref } from '@iyulab/components';
22
-
23
- const userInput = '<script>alert(1)</script>';
24
- const html = `<p>${escapeHtmlText(userInput)}</p>`;
25
- // → <p>&lt;script&gt;alert(1)&lt;/script&gt;</p>
26
-
27
- const url = 'javascript:alert(1)';
28
- const safe = escapeHtmlHref(url);
29
- // → '' (blocked)
30
- ```
31
-
32
- > Lit templates using `html` tagged literals automatically escape interpolated values. These helpers are needed when building raw HTML strings manually.