@daracl/dialog 0.0.6 → 0.0.8

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2024-current The Darainfo Authors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024-current The Darainfo Authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,78 +1,175 @@
1
- # dialog
2
-
3
- Simple dialog message
4
-
5
- [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/darainfo/daracl.dialog/blob/main/LICENSE)
6
- [![npm version](https://badge.fury.io/js/@daracl%2Fdialog.svg)](https://badge.fury.io/js/@daracl%2Fdialog)
7
- [![npm](https://img.shields.io/npm/dt/@daracl%2Fdialog)](https://github.com/darainfo/daracl.dialog/releases)
8
- [![minzipped size](https://img.shields.io/bundlephobia/minzip/@daracl%2Fdialog)](https://bundlephobia.com/package/@daracl%2Fdialog)
9
-
10
- ## Browser Support
11
-
12
- ![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![Internet Explorer](https://raw.githubusercontent.com/alrra/browser-logos/main/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png)
13
- --- | --- | --- | --- | --- | --- |
14
- Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | ie 11 > |
15
-
16
-
17
- <p>
18
- <img src="https://github.com/darainfo/daracl.dialog/blob/main/demo.gif?raw=true"/>
19
- </p>
20
-
21
- # build
22
- ```
23
- npm run build
24
-
25
- ```
26
-
27
- # 사용방법
28
- ```
29
- var dialogObj = Daracl.dialog.create({
30
- title: 'dialog', width: 500, height: 'auto', icon: "info", isModal: true, resizable: true, autoOpen: false, template: '<a href="https://varsql.com" target="_blank">링크 이동</a>', buttons: [
31
- {
32
- label: 'ok', styleClass: "info", callback: function (e) {
33
- alert('ok')
34
- }
35
- }
36
- , {
37
- label: 'Cancel', callback: function (e) {
38
- dialogObj.hide();
39
- }
40
- }
41
- ], afterOpen: function () {
42
- console.log('after open')
43
- }
44
- });
45
- ```
46
-
47
-
48
- # dialog 옵션
49
- | key | 설명 | 기본값 | 옵션값 |
50
- |-----|------|-----|-----|
51
- | width | 넓이 | 400 | |
52
- | height | 높이 | 300 | |
53
- | styleClass | css class | | |
54
- | isModal |모달 사용여부 | false | |
55
- | icon | icon | | primary, secondary, info, success, warning, danger |
56
- | autoOpen | 자동 열기 여부 | true | |
57
- | draggable | drag 가능여부 | true | |
58
- | resizable | 창 리사이즈 여부 | false | |
59
- | enableHeader | 헤더 영역 보일지 여부 | true | |
60
- | enableFooter | 하단 버튼 영역 보일지 여부 | true | |
61
- | enableMaxButton | 최대화 버튼 | true | |
62
- | enableCloseButton | 닫기 버튼 활성화 여부 | true | |
63
- | minHeight | 최소 높이 | 130 | |
64
- | minWidth | 최소 넓이 | 230 | |
65
- | zIndex | css z-index | 10000 | |
66
- | dragOverflow | darg 창 넘어서 drag 할지 여부 | true | |
67
- | buttons | dialog 하단 버튼 | [] | |
68
- | moveDelay | drag delay time | 15 | |
69
- | afterOpen | 오픈후 발생할 이벤트 | false | |
70
-
71
-
72
- # dialog button 옵션
73
- | key | 설명 | 기본값 | 옵션값 |
74
- |-----|------|-----|-----|
75
- | label | 버튼명 | '' | |
76
- | callback | 클릭시 callback | | |
77
-
78
- ```
1
+ # dialog
2
+
3
+ Simple dialog message
4
+
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/daracl/ui-dialog/blob/main/LICENSE)
6
+ [![npm version](https://badge.fury.io/js/@daracl%2Fdialog.svg)](https://badge.fury.io/js/@daracl%2Fdialog)
7
+ [![npm](https://img.shields.io/npm/dt/@daracl%2Fdialog)](https://github.com/daracl/ui-dialog/releases)
8
+ [![minzipped size](https://img.shields.io/bundlephobia/minzip/@daracl%2Fdialog)](https://bundlephobia.com/package/@daracl%2Fdialog)
9
+
10
+ ## Browser Support
11
+
12
+ ![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png)
13
+ --- | --- | --- | --- | --- |
14
+ Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
15
+
16
+ - 빌드는 vite 다 (ui-grid 와 같은 구조). UMD 는 `es2017`, ESM/CJS 는 vite 기본 대상(최신 브라우저)으로 만든다. **IE 11 은 지원하지 않는다** (0.0.7 까지는 webpack + babel 로 ES5 를 만들었다).
17
+ - 자동 테스트는 jsdom, 수동 확인은 Chrome 에서 했다 ([docs/testing/test-report.md](docs/testing/test-report.md)). 그 외 브라우저는 실제로 확인하지 않았다.
18
+
19
+
20
+ <p>
21
+ <img src="https://github.com/daracl/ui-dialog/blob/main/demo.gif?raw=true"/>
22
+ </p>
23
+
24
+ # 설치
25
+
26
+ ```
27
+ npm install @daracl/dialog
28
+ ```
29
+
30
+ - ESM / CJS : `import Dialog from "@daracl/dialog"` 또는 `import { Dialog } from "@daracl/dialog"`. 런타임 의존 `@daracl/core` 가 함께 설치된다. CSS 는 `@daracl/dialog/dist/daracl.dialog.min.css` (기존 경로 `dist/index.css` 도 유지).
31
+ - UMD (CDN) : `dist/daracl.dialog.min.umd.js` + `dist/daracl.dialog.min.css`. 기존 이름 `dist/daracl.dialog.min.js` · `daracl.dialog.js` 도 같은 파일로 계속 제공한다. `@daracl/core` 가 포함되어 있어 다른 스크립트가 필요 없다. 전역 `Daracl.dialog` (이미 있는 `window.Daracl` 의 다른 컴포넌트는 유지된다).
32
+
33
+ # build
34
+ ```
35
+ npm run build # vite: build:escjs(ESM/CJS) → build:umd(UMD) → mergenclean(병합 · d.ts · 기존 이름 복사)
36
+ npm run dev # 개발 서버 http://127.0.0.1:5182/uitest/index.html
37
+ npm test # jest (jsdom)
38
+ npm run lint
39
+ npm run typecheck
40
+ npm run audit:security
41
+ ```
42
+
43
+ # 사용방법
44
+ ```
45
+ var dialogObj = Daracl.dialog.create({
46
+ title: 'dialog', width: 500, height: 'auto', icon: "info", isModal: true, resizable: true, autoOpen: false, template: '<a href="https://varsql.com" target="_blank">링크 이동</a>', buttons: [
47
+ {
48
+ label: 'ok', styleClass: "info", callback: function (e) {
49
+ alert('ok')
50
+ }
51
+ }
52
+ , {
53
+ label: 'Cancel', callback: function (e) {
54
+ dialogObj.hide();
55
+ }
56
+ }
57
+ ], afterOpen: function () {
58
+ console.log('after open')
59
+ }
60
+ });
61
+ ```
62
+
63
+
64
+ # dialog 옵션
65
+ | key | 설명 | 기본값 | 옵션값 |
66
+ |-----|------|-----|-----|
67
+ | title | 제목. 문자열은 sanitize 된다 (HTML 보안 참고) | | string, Node |
68
+ | template | 본문. 문자열은 **신뢰된 HTML** 로 그대로 표시한다 | | string, Node, function |
69
+ | url | iframe 으로 표시할 주소. http, https, mailto, tel, 상대 경로만 | | |
70
+ | width | 넓이. 숫자는 px | 400 | number, "auto", "50%", "150px" … |
71
+ | height | 높이. 숫자는 px | 300 | |
72
+ | styleClass | css class | | |
73
+ | isModal |모달 사용여부 | false | |
74
+ | icon | icon | | primary, secondary, info, success, warning, danger |
75
+ | autoOpen | 자동 열기 여부 | true | |
76
+ | draggable | drag 가능여부 | true | |
77
+ | resizable | 창 리사이즈 여부 | false | |
78
+ | enableHeader | 헤더 영역 보일지 여부 | true | |
79
+ | enableFooter | 하단 버튼 영역 보일지 여부 | true | |
80
+ | enableMaxButton | 최대화 버튼 | true | |
81
+ | enableCloseButton | 닫기 버튼 활성화 여부 | true | |
82
+ | closeOnEscape | ESC 로 닫기 (enableCloseButton 이 false 이면 동작 안 함) | true | |
83
+ | autoFocus | 열 때 dialog 안으로 포커스 이동, 닫을 때 복원 | true | |
84
+ | sanitize | HTML 정리 방식 (아래 HTML 보안) | 지정 안 함 | true, false, function |
85
+ | theme | dialog 별 테마. 지정하지 않으면 상위 요소의 `data-daracl-theme` 를 따른다 | | light, dark |
86
+ | minHeight | 최소 높이 | 130 | |
87
+ | minWidth | 최소 넓이 | 230 | |
88
+ | zIndex | css z-index | 10000 | |
89
+ | dragOverflow | drag 시 창 밖으로 넘어갈 수 있는지 여부 | true | |
90
+ | buttons | dialog 하단 버튼 | [] | |
91
+ | moveDelay | drag delay time | 15 | |
92
+ | afterOpen | 오픈후 발생할 이벤트 (`this` 는 dialog, 인자는 wrapper 요소) | false | |
93
+
94
+
95
+ # dialog button 옵션
96
+ | key | 설명 | 기본값 | 옵션값 |
97
+ |-----|------|-----|-----|
98
+ | label | 버튼명. 문자열은 sanitize 된다 | '' | string, Node |
99
+ | styleClass | 버튼 class | success | primary, secondary, info, success, warning, danger, 사용자 class |
100
+ | callback | 클릭(mousedown) 또는 Enter / Space 시 callback | | |
101
+
102
+ # 메서드
103
+
104
+ | 메서드 | 설명 |
105
+ |-----|------|
106
+ | `Dialog.create(options)` | 생성 (`new Dialog(options)` 와 같다). 문자열을 넘기면 본문으로 쓴다 |
107
+ | `Dialog.setOptions(options)` | 기본 옵션 변경 |
108
+ | `Dialog.VERSION` | 버전 |
109
+ | `show()` / `hide()` | 열기 / 닫기. 인스턴스를 반환한다 |
110
+ | `isOpen()` | 열려 있는지 |
111
+ | `maximise()` / `isMaximise()` | 최대화 전환 / 상태 |
112
+ | `setTheme(name?)` | dialog 별 테마. 빈 값이면 해제 |
113
+ | `destroy()` | DOM · overlay · 이벤트 · 타이머 정리. 여러 번 호출해도 된다 |
114
+
115
+ # 키보드 · 접근성
116
+
117
+ - wrapper 는 `role="dialog"`, 모달이면 `aria-modal="true"`, 제목 텍스트가 `aria-label` 이 된다.
118
+ - 닫기 · 최대화 · 하단 버튼은 Tab 으로 이동하고 Enter / Space 로 실행한다.
119
+ - 모달은 Tab / Shift+Tab 이 dialog 안에서 순환한다. ESC 로 닫힌다.
120
+
121
+ # HTML 보안
122
+
123
+ 문자열 HTML 은 `@daracl/core` 의 `sanitizeHtml`(허용 목록: 서식 태그 유지, `script` · `iframe` · `form` · `input` · `svg` 등 제거, `on*` 속성 · `javascript:` URL · `url()` style 제거)로 정리한다.
124
+
125
+ | sanitize | title · 버튼 label | template |
126
+ |-----|-----|-----|
127
+ | 지정 안 함 (기본) | sanitize | **그대로 (신뢰된 HTML)** |
128
+ | `true` | sanitize | sanitize |
129
+ | `false` | 그대로 | 그대로 (0.0.7 동작) |
130
+ | `(html) => string \| Node` | 지정한 함수 | 지정한 함수 |
131
+
132
+ - **template 에 사용자 입력 · 서버 데이터 같은 신뢰할 수 없는 값을 넣을 때는 `sanitize: true` 를 지정하거나 DOM `Node` 를 넘긴다.** 기본값이 template 을 그대로 두는 이유는 폼(`input`, `button`)을 쓰는 기존 사용을 유지하기 위해서다.
133
+ - `url` 은 http, https, mailto, tel, 상대 경로만 iframe 으로 연다. 그 외(`javascript:` 등)는 열지 않고 `console.warn` 을 남긴다. 외부 사이트를 띄울 때는 `afterOpen` 에서 iframe 에 `sandbox` 를 지정하는 것을 권장한다.
134
+
135
+ ```js
136
+ Daracl.dialog.create({ title: userName, template: userComment, sanitize: true });
137
+ ```
138
+
139
+ # 테마
140
+
141
+ ui-grid 와 같은 구조다. 공통 색(글자 / 배경 / 테두리)은 [`@daracl/ui-style`](https://www.npmjs.com/package/@daracl/ui-style) 의 `--dui-*`, dialog 전용 색(overlay, 버튼)은 `--ddlg-*` 변수를 쓴다 (`style/themes/`).
142
+
143
+ dialog CSS 가 공통 변수 기본값을 특이도 0(`:where`)으로 포함하므로 **`theme-vars.css` 없이도** light / dark / OS 설정이 동작한다. 앱이 `theme-vars.css` 를 로드하거나 `:root` 에 값을 지정하면 그 값이 우선한다.
144
+
145
+ ```js
146
+ // 전체 전환
147
+ document.documentElement.setAttribute('data-daracl-theme', 'dark');
148
+
149
+ // dialog 하나만
150
+ Daracl.dialog.create({ title: 'dark', theme: 'dark', template: '...' });
151
+ dialogObj.setTheme('light');
152
+ dialogObj.setTheme(); // 해제 → 상위 요소를 따른다
153
+
154
+ // 색 재정의
155
+ // :root { --ddlg-btn-primary-bg: #0d6efd; --ddlg-btn-primary-color: #fff; }
156
+ ```
157
+
158
+ > `style/` 의 SCSS 원본을 직접 컴파일하는 경우 `@daracl/ui-style` 을 찾을 수 있어야 합니다. (sass CLI : `--load-path=node_modules`)
159
+
160
+ # 빌드 산출물 (dist)
161
+
162
+ | 파일 | 내용 |
163
+ |-----|------|
164
+ | `index.js` · `index.min.js` | ESM (`@daracl/core` external) |
165
+ | `index.cjs` · `index.min.cjs` | CJS |
166
+ | `daracl.dialog.umd.js` · `daracl.dialog.min.umd.js` | UMD (`window.Daracl.dialog`, core 포함) |
167
+ | `daracl.dialog.css` · `daracl.dialog.min.css` | 스타일 |
168
+ | `daracl.dialog.js` · `daracl.dialog.min.js` · `index.css` | 0.0.7 까지의 이름 (UMD · CSS 와 같은 내용) |
169
+ | `index.d.ts` · `dialog.d.ts` | 타입 선언 |
170
+
171
+ # 문서
172
+
173
+ - [마이그레이션 가이드](docs/migration/migration-guide.md)
174
+ - [npm 자동 배포 설정](docs/NPM_PUBLISH.md) · 예제: `npm run dev` → `uitest/index.html`
175
+ - [보안 점검](docs/security/security-audit.md) · [테스트 보고서](docs/testing/test-report.md) · [개선 보고서](docs/improvements/improvement-report.md)