@kupola/kupola 2.0.0-alpha.1 → 2.0.0-beta.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/README.md +6 -4
- package/README.zh-CN.md +6 -4
- package/dist/css/components.css +273 -0
- package/dist/css/index.css +13 -0
- package/dist/css/tokens.css +182 -0
- package/dist/kupola-core-badge.cjs.js +1 -1
- package/dist/kupola-core-badge.esm.js +1 -1
- package/dist/kupola-core-dialog.cjs.js +2 -2
- package/dist/kupola-core-dialog.esm.js +2 -2
- package/dist/kupola-core-i18n.cjs.js +1 -0
- package/dist/kupola-core-i18n.esm.js +1 -0
- package/dist/kupola-core-modal.cjs.js +6 -6
- package/dist/kupola-core-modal.esm.js +6 -6
- package/dist/kupola-core-select.cjs.js +3 -3
- package/dist/kupola-core-select.esm.js +3 -3
- package/dist/kupola-core.cjs.js +1 -1
- package/dist/kupola-core.esm.js +1 -1
- package/package.json +17 -4
- package/packages/core/__tests__/component.test.js +4 -4
- package/packages/core/__tests__/components/breadcrumb.test.js +3 -3
- package/packages/core/__tests__/components/calendar.test.js +4 -4
- package/packages/core/__tests__/components/carousel.test.js +20 -20
- package/packages/core/__tests__/components/collapse.test.js +10 -10
- package/packages/core/__tests__/components/colorpicker.test.js +4 -4
- package/packages/core/__tests__/components/datepicker.test.js +1 -1
- package/packages/core/__tests__/components/dropdown.test.js +1 -1
- package/packages/core/__tests__/components/dynamictags.test.js +21 -21
- package/packages/core/__tests__/components/form.test.js +2 -2
- package/packages/core/__tests__/components/heatmap.test.js +1 -1
- package/packages/core/__tests__/components/imagepreview.test.js +1 -1
- package/packages/core/__tests__/components/menu.test.js +12 -12
- package/packages/core/__tests__/components/pagination.test.js +1 -1
- package/packages/core/__tests__/components/radio.test.js +4 -4
- package/packages/core/__tests__/components/select.test.js +7 -7
- package/packages/core/__tests__/components/table.test.js +24 -24
- package/packages/core/__tests__/components/timeline.test.js +7 -7
- package/packages/core/__tests__/components/tree.test.js +2 -2
- package/packages/core/__tests__/components/validation.test.js +2 -2
- package/packages/core/__tests__/components/virtuallist.test.js +3 -3
- package/packages/core/__tests__/core.test.js +3 -3
- package/packages/core/__tests__/server.test.js +3 -3
- package/packages/core/__tests__/template.test.js +2 -2
- package/packages/core/src/batch.js +1 -1
- package/packages/core/src/components/alert.js +3 -3
- package/packages/core/src/components/avatar.js +5 -5
- package/packages/core/src/components/badge.js +5 -5
- package/packages/core/src/components/calendar.js +19 -19
- package/packages/core/src/components/carousel.js +9 -9
- package/packages/core/src/components/checkbox.js +6 -6
- package/packages/core/src/components/collapse.js +7 -7
- package/packages/core/src/components/colorpicker.js +10 -10
- package/packages/core/src/components/countdown.js +7 -7
- package/packages/core/src/components/datepicker.js +27 -27
- package/packages/core/src/components/dialog.js +8 -8
- package/packages/core/src/components/drawer.js +6 -6
- package/packages/core/src/components/dropdown.js +27 -27
- package/packages/core/src/components/dynamictags.js +10 -10
- package/packages/core/src/components/empty.js +1 -1
- package/packages/core/src/components/fileupload.js +17 -17
- package/packages/core/src/components/form.js +15 -15
- package/packages/core/src/components/heatmap.js +12 -12
- package/packages/core/src/components/icons.js +3 -3
- package/packages/core/src/components/imagepreview.js +16 -16
- package/packages/core/src/components/input.js +5 -5
- package/packages/core/src/components/menu.js +1 -1
- package/packages/core/src/components/message.js +9 -9
- package/packages/core/src/components/modal.js +10 -7
- package/packages/core/src/components/notification.js +8 -8
- package/packages/core/src/components/numberinput.js +8 -8
- package/packages/core/src/components/pagination.js +5 -5
- package/packages/core/src/components/progress.js +4 -4
- package/packages/core/src/components/radio.js +3 -3
- package/packages/core/src/components/select.js +45 -45
- package/packages/core/src/components/skeleton.js +2 -2
- package/packages/core/src/components/slider.js +5 -5
- package/packages/core/src/components/statcard.js +4 -4
- package/packages/core/src/components/switch.js +4 -4
- package/packages/core/src/components/table.js +79 -79
- package/packages/core/src/components/tabs.js +6 -6
- package/packages/core/src/components/tag.js +3 -3
- package/packages/core/src/components/textarea.js +5 -5
- package/packages/core/src/components/timepicker.js +14 -14
- package/packages/core/src/components/tooltip.js +27 -27
- package/packages/core/src/components/tree.js +8 -8
- package/packages/core/src/components/validation.js +26 -26
- package/packages/core/src/components/virtuallist.js +4 -4
- package/packages/core/src/directives.js +28 -28
- package/packages/core/src/effect.js +2 -2
- package/packages/core/src/i18n.js +86 -0
- package/packages/core/src/index.js +3 -0
- package/packages/core/src/render.js +12 -12
- package/packages/core/src/scheduler.js +1 -1
- package/packages/core/src/server.js +8 -8
- package/packages/css/components.css +273 -0
- package/packages/css/index.css +13 -0
- package/packages/css/tokens.css +182 -0
- package/version.json +1 -1
package/README.md
CHANGED
|
@@ -51,16 +51,18 @@ Or use the programmatic API:
|
|
|
51
51
|
|
|
52
52
|
## Installation
|
|
53
53
|
|
|
54
|
+
> **Current version**: `2.0.0-alpha.1` (pre-release). Use `@next` tag to install:
|
|
55
|
+
|
|
54
56
|
```bash
|
|
55
|
-
npm install @kupola/kupola # Full package
|
|
57
|
+
npm install @kupola/kupola@next # Full package
|
|
56
58
|
# Or core engine only
|
|
57
|
-
npm install @kupola/kupola/core # signal + template + render + SSR
|
|
59
|
+
npm install @kupola/kupola/core@next # signal + template + render + SSR
|
|
58
60
|
```
|
|
59
61
|
|
|
60
62
|
```bash
|
|
61
63
|
# CDN
|
|
62
|
-
https://cdn.jsdelivr.net/npm/@kupola/kupola/dist/kupola-core.esm.js
|
|
63
|
-
https://cdn.jsdelivr.net/npm/@kupola/kupola/dist/kupola-core.cjs.js
|
|
64
|
+
https://cdn.jsdelivr.net/npm/@kupola/kupola@next/dist/kupola-core.esm.js
|
|
65
|
+
https://cdn.jsdelivr.net/npm/@kupola/kupola@next/dist/kupola-core.cjs.js
|
|
64
66
|
```
|
|
65
67
|
|
|
66
68
|
---
|
package/README.zh-CN.md
CHANGED
|
@@ -51,16 +51,18 @@
|
|
|
51
51
|
|
|
52
52
|
## 安装
|
|
53
53
|
|
|
54
|
+
> **当前版本**:`2.0.0-alpha.1`(预发布版)。请使用 `@next` 标签安装:
|
|
55
|
+
|
|
54
56
|
```bash
|
|
55
|
-
npm install @kupola/kupola # 完整包
|
|
57
|
+
npm install @kupola/kupola@next # 完整包
|
|
56
58
|
# 或仅核心引擎
|
|
57
|
-
npm install @kupola/kupola/core # signal + template + render + SSR
|
|
59
|
+
npm install @kupola/kupola/core@next # signal + template + render + SSR
|
|
58
60
|
```
|
|
59
61
|
|
|
60
62
|
```bash
|
|
61
63
|
# CDN
|
|
62
|
-
https://cdn.jsdelivr.net/npm/@kupola/kupola/dist/kupola-core.esm.js
|
|
63
|
-
https://cdn.jsdelivr.net/npm/@kupola/kupola/dist/kupola-core.cjs.js
|
|
64
|
+
https://cdn.jsdelivr.net/npm/@kupola/kupola@next/dist/kupola-core.esm.js
|
|
65
|
+
https://cdn.jsdelivr.net/npm/@kupola/kupola@next/dist/kupola-core.cjs.js
|
|
64
66
|
```
|
|
65
67
|
|
|
66
68
|
---
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kupola Component Styles
|
|
3
|
+
* Core ds-* class definitions using design tokens.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* ── Reset ────────────────────────────────────────────────── */
|
|
7
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
8
|
+
|
|
9
|
+
/* ── Base ─────────────────────────────────────────────────── */
|
|
10
|
+
body {
|
|
11
|
+
margin: 0;
|
|
12
|
+
background: var(--color-background);
|
|
13
|
+
color: var(--color-foreground);
|
|
14
|
+
font-family: var(--font-family-default);
|
|
15
|
+
font-size: var(--body-base-font-size);
|
|
16
|
+
line-height: var(--body-base-line-height);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* ── Button ───────────────────────────────────────────────── */
|
|
20
|
+
.ds-btn {
|
|
21
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
22
|
+
gap: var(--spacer-6); padding: 0 var(--spacer-12); height: 28px;
|
|
23
|
+
border-radius: var(--radius-4); border: 1px solid transparent;
|
|
24
|
+
cursor: pointer; user-select: none; white-space: nowrap;
|
|
25
|
+
font-size: var(--body-sm-font-size); font-weight: var(--font-weight-medium);
|
|
26
|
+
transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
|
|
27
|
+
}
|
|
28
|
+
.ds-btn--sm { height: 24px; padding: 0 var(--spacer-8); font-size: var(--body-xs-font-size); }
|
|
29
|
+
.ds-btn--lg { height: 32px; padding: 0 var(--spacer-16); font-size: var(--body-base-font-size); }
|
|
30
|
+
.ds-btn--primary { background: var(--bg-brand); color: var(--text-onbrand); border-color: var(--bg-brand); }
|
|
31
|
+
.ds-btn--primary:hover { background: var(--bg-brand-hover); }
|
|
32
|
+
.ds-btn--secondary { background: var(--bg-overlay-l2); color: var(--text-default); border-color: var(--border-neutral-l1); }
|
|
33
|
+
.ds-btn--secondary:hover { background: var(--bg-overlay-l3); }
|
|
34
|
+
.ds-btn--tertiary { background: transparent; color: var(--text-default); }
|
|
35
|
+
.ds-btn--tertiary:hover { background: var(--bg-overlay-l2); }
|
|
36
|
+
.ds-btn--danger { background: var(--status-error-default); color: #fff; }
|
|
37
|
+
.ds-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
|
|
38
|
+
|
|
39
|
+
/* ── Input ────────────────────────────────────────────────── */
|
|
40
|
+
.ds-input {
|
|
41
|
+
display: flex; align-items: center; gap: var(--spacer-8);
|
|
42
|
+
padding: 0 var(--spacer-12); height: 28px;
|
|
43
|
+
background: var(--bg-overlay-l1); border: 1px solid var(--border-neutral-l1);
|
|
44
|
+
border-radius: var(--radius-4); color: var(--text-default); width: 100%;
|
|
45
|
+
font-size: var(--body-sm-font-size);
|
|
46
|
+
}
|
|
47
|
+
.ds-input:focus-within { border-color: var(--bg-brand); }
|
|
48
|
+
.ds-input input { flex: 1; background: transparent; border: none; outline: none; color: inherit; font: inherit; }
|
|
49
|
+
.ds-input input::placeholder { color: var(--text-tertiary); }
|
|
50
|
+
.ds-input.is-error { border-color: var(--status-error-default); }
|
|
51
|
+
|
|
52
|
+
/* ── Modal ────────────────────────────────────────────────── */
|
|
53
|
+
.ds-modal-mask {
|
|
54
|
+
position: fixed; inset: 0; z-index: var(--z-index-modal);
|
|
55
|
+
background: rgba(0, 0, 0, 0.5);
|
|
56
|
+
display: none; align-items: center; justify-content: center;
|
|
57
|
+
}
|
|
58
|
+
.ds-modal-mask.is-visible { display: flex; }
|
|
59
|
+
.ds-modal {
|
|
60
|
+
background: var(--bg-base-secondary); border: 1px solid var(--border-neutral-l1);
|
|
61
|
+
border-radius: var(--radius-8); width: 100%; max-width: 480px;
|
|
62
|
+
outline: none;
|
|
63
|
+
}
|
|
64
|
+
.ds-modal__header {
|
|
65
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
66
|
+
padding: var(--spacer-16) var(--spacer-24);
|
|
67
|
+
border-bottom: 1px solid var(--border-neutral-l1);
|
|
68
|
+
}
|
|
69
|
+
.ds-modal__title { font-size: var(--heading-sm-font-size); font-weight: var(--font-weight-strong); }
|
|
70
|
+
.ds-modal__close {
|
|
71
|
+
width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
|
|
72
|
+
background: transparent; border: none; color: var(--icon-secondary);
|
|
73
|
+
cursor: pointer; border-radius: var(--radius-4);
|
|
74
|
+
}
|
|
75
|
+
.ds-modal__close:hover { background: var(--bg-overlay-l2); }
|
|
76
|
+
.ds-modal__body { padding: var(--spacer-16) var(--spacer-24); }
|
|
77
|
+
.ds-modal__footer {
|
|
78
|
+
display: flex; justify-content: flex-end; gap: var(--spacer-8);
|
|
79
|
+
padding: var(--spacer-12) var(--spacer-24);
|
|
80
|
+
border-top: 1px solid var(--border-neutral-l1);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* ── Drawer ───────────────────────────────────────────────── */
|
|
84
|
+
.ds-drawer-mask {
|
|
85
|
+
position: fixed; inset: 0; z-index: var(--z-index-drawer);
|
|
86
|
+
background: rgba(0, 0, 0, 0.5); display: none;
|
|
87
|
+
}
|
|
88
|
+
.ds-drawer-mask.is-visible { display: block; }
|
|
89
|
+
.ds-drawer {
|
|
90
|
+
position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-index-drawer);
|
|
91
|
+
width: 360px; max-width: 100vw;
|
|
92
|
+
background: var(--bg-base-secondary); border-left: 1px solid var(--border-neutral-l1);
|
|
93
|
+
display: flex; flex-direction: column;
|
|
94
|
+
transform: translateX(100%); transition: transform var(--transition-slow);
|
|
95
|
+
}
|
|
96
|
+
.ds-drawer.is-visible { transform: translateX(0); }
|
|
97
|
+
.ds-drawer__header {
|
|
98
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
99
|
+
padding: var(--spacer-16) var(--spacer-24);
|
|
100
|
+
border-bottom: 1px solid var(--border-neutral-l1);
|
|
101
|
+
}
|
|
102
|
+
.ds-drawer__body { padding: var(--spacer-16) var(--spacer-24); flex: 1; overflow-y: auto; }
|
|
103
|
+
|
|
104
|
+
/* ── Dropdown ─────────────────────────────────────────────── */
|
|
105
|
+
.ds-dropdown { position: relative; display: inline-block; }
|
|
106
|
+
.ds-dropdown__menu {
|
|
107
|
+
position: absolute; top: calc(100% + 4px); left: 0; min-width: 160px;
|
|
108
|
+
background: var(--bg-base-secondary); border: 1px solid var(--border-neutral-l2);
|
|
109
|
+
border-radius: var(--radius-4); box-shadow: 0 4px 16px rgba(0,0,0,0.2);
|
|
110
|
+
z-index: var(--z-index-dropdown); display: none; padding: var(--spacer-4);
|
|
111
|
+
}
|
|
112
|
+
.ds-dropdown__menu.is-open { display: block; }
|
|
113
|
+
.ds-dropdown__item {
|
|
114
|
+
display: flex; align-items: center; padding: var(--spacer-6) var(--spacer-8);
|
|
115
|
+
border-radius: var(--radius-2); color: var(--text-default);
|
|
116
|
+
font-size: var(--body-sm-font-size); cursor: pointer;
|
|
117
|
+
}
|
|
118
|
+
.ds-dropdown__item:hover { background: var(--bg-overlay-l1); }
|
|
119
|
+
|
|
120
|
+
/* ── Tooltip ──────────────────────────────────────────────── */
|
|
121
|
+
.ds-tooltip {
|
|
122
|
+
position: fixed; z-index: var(--z-index-tooltip);
|
|
123
|
+
padding: var(--spacer-4) var(--spacer-8);
|
|
124
|
+
background: var(--bg-base-tertiary); border: 1px solid var(--border-neutral-l1);
|
|
125
|
+
border-radius: var(--radius-4); font-size: var(--body-xs-font-size);
|
|
126
|
+
color: var(--text-default); pointer-events: none;
|
|
127
|
+
max-width: 280px; white-space: pre-wrap;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* ── Table ────────────────────────────────────────────────── */
|
|
131
|
+
.ds-table { width: 100%; border-collapse: collapse; }
|
|
132
|
+
.ds-table th, .ds-table td {
|
|
133
|
+
text-align: left; padding: var(--spacer-12) var(--spacer-8);
|
|
134
|
+
border-bottom: 1px solid var(--border-neutral-l1);
|
|
135
|
+
font-size: var(--body-sm-font-size);
|
|
136
|
+
}
|
|
137
|
+
.ds-table th { color: var(--text-tertiary); font-weight: var(--font-weight-default); font-size: var(--body-xs-font-size); text-transform: uppercase; letter-spacing: 0.04em; }
|
|
138
|
+
.ds-table td { color: var(--text-default); }
|
|
139
|
+
.ds-table--striped tbody tr:nth-child(even) { background: var(--bg-base-secondary); }
|
|
140
|
+
.ds-table--hover tbody tr:hover { background: var(--bg-overlay-l1); }
|
|
141
|
+
|
|
142
|
+
/* ── Form ─────────────────────────────────────────────────── */
|
|
143
|
+
.ds-form { display: flex; flex-direction: column; gap: var(--spacer-16); }
|
|
144
|
+
.ds-form__group { display: flex; flex-direction: column; gap: var(--spacer-6); }
|
|
145
|
+
.ds-form__label { font-size: var(--body-sm-font-size); font-weight: var(--font-weight-medium); color: var(--text-default); }
|
|
146
|
+
.ds-form__error { font-size: var(--body-xs-font-size); color: var(--status-error-default); }
|
|
147
|
+
.ds-form__actions { display: flex; justify-content: flex-end; gap: var(--spacer-8); margin-top: var(--spacer-16); }
|
|
148
|
+
|
|
149
|
+
/* ── Alert ────────────────────────────────────────────────── */
|
|
150
|
+
.ds-alert {
|
|
151
|
+
display: flex; gap: var(--spacer-12);
|
|
152
|
+
padding: var(--spacer-12) var(--spacer-16);
|
|
153
|
+
background: var(--bg-base-secondary); border: 1px solid var(--border-neutral-l1);
|
|
154
|
+
border-radius: var(--radius-4); color: var(--text-default);
|
|
155
|
+
}
|
|
156
|
+
.ds-alert--success { background: var(--status-success-surface-l1); border-color: var(--status-success-default); }
|
|
157
|
+
.ds-alert--warning { background: var(--status-warning-surface-l1); border-color: var(--status-warning-default); }
|
|
158
|
+
.ds-alert--error { background: var(--status-error-surface-l1); border-color: var(--status-error-default); }
|
|
159
|
+
.ds-alert--info { background: var(--status-info-surface-l1); border-color: var(--status-info-default); }
|
|
160
|
+
|
|
161
|
+
/* ── Tag / Badge ──────────────────────────────────────────── */
|
|
162
|
+
.ds-tag {
|
|
163
|
+
display: inline-flex; align-items: center;
|
|
164
|
+
padding: 0 var(--spacer-6); height: 18px;
|
|
165
|
+
border-radius: var(--radius-2); font-size: var(--body-xs-font-size);
|
|
166
|
+
background: var(--bg-overlay-l2); color: var(--text-secondary);
|
|
167
|
+
border: 1px solid var(--border-neutral-l1);
|
|
168
|
+
}
|
|
169
|
+
.ds-tag--success { background: var(--status-success-surface-l1); color: var(--status-success-default); }
|
|
170
|
+
.ds-tag--warning { background: var(--status-warning-surface-l1); color: var(--status-warning-default); }
|
|
171
|
+
.ds-tag--error { background: var(--status-error-surface-l1); color: var(--status-error-default); }
|
|
172
|
+
|
|
173
|
+
/* ── Tabs ─────────────────────────────────────────────────── */
|
|
174
|
+
.ds-tabs { display: flex; gap: var(--spacer-24); border-bottom: 1px solid var(--border-neutral-l1); }
|
|
175
|
+
.ds-tab {
|
|
176
|
+
padding: var(--spacer-12) 0; background: transparent; border: none;
|
|
177
|
+
color: var(--text-tertiary); cursor: pointer; font: inherit;
|
|
178
|
+
font-size: var(--body-sm-font-size); position: relative;
|
|
179
|
+
}
|
|
180
|
+
.ds-tab:hover { color: var(--text-default); }
|
|
181
|
+
.ds-tab.is-active { color: var(--text-default); }
|
|
182
|
+
.ds-tab.is-active::after {
|
|
183
|
+
content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
|
|
184
|
+
background: var(--icon-default);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* ── Message / Notification ───────────────────────────────── */
|
|
188
|
+
.ds-message {
|
|
189
|
+
position: fixed; top: var(--spacer-24); left: 50%; transform: translateX(-50%);
|
|
190
|
+
z-index: var(--z-index-notification);
|
|
191
|
+
padding: var(--spacer-8) var(--spacer-16);
|
|
192
|
+
background: var(--bg-base-secondary); border: 1px solid var(--border-neutral-l1);
|
|
193
|
+
border-radius: var(--radius-4); box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
|
194
|
+
font-size: var(--body-sm-font-size); color: var(--text-default);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* ── Progress ─────────────────────────────────────────────── */
|
|
198
|
+
.ds-progress { width: 100%; height: 4px; background: var(--bg-overlay-l2); border-radius: var(--radius-full); overflow: hidden; }
|
|
199
|
+
.ds-progress__bar { height: 100%; background: var(--bg-brand); border-radius: var(--radius-full); transition: width var(--transition-normal); }
|
|
200
|
+
|
|
201
|
+
/* ── Switch ───────────────────────────────────────────────── */
|
|
202
|
+
.ds-switch {
|
|
203
|
+
position: relative; width: 36px; height: 20px;
|
|
204
|
+
background: var(--bg-overlay-l3); border-radius: var(--radius-full);
|
|
205
|
+
cursor: pointer; transition: background var(--transition-fast);
|
|
206
|
+
}
|
|
207
|
+
.ds-switch.is-active { background: var(--bg-brand); }
|
|
208
|
+
.ds-switch::after {
|
|
209
|
+
content: ''; position: absolute; top: 2px; left: 2px;
|
|
210
|
+
width: 16px; height: 16px; border-radius: 50%;
|
|
211
|
+
background: #fff; transition: transform var(--transition-fast);
|
|
212
|
+
}
|
|
213
|
+
.ds-switch.is-active::after { transform: translateX(16px); }
|
|
214
|
+
|
|
215
|
+
/* ── Card ─────────────────────────────────────────────────── */
|
|
216
|
+
.ds-card {
|
|
217
|
+
background: var(--bg-base-secondary); border: 1px solid var(--border-neutral-l1);
|
|
218
|
+
border-radius: var(--radius-4); padding: var(--spacer-24);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* ── Skeleton ─────────────────────────────────────────────── */
|
|
222
|
+
.ds-skeleton {
|
|
223
|
+
background: var(--bg-overlay-l2); border-radius: var(--radius-4);
|
|
224
|
+
animation: ds-skeleton-pulse 1.5s ease-in-out infinite;
|
|
225
|
+
}
|
|
226
|
+
@keyframes ds-skeleton-pulse {
|
|
227
|
+
0%, 100% { opacity: 1; }
|
|
228
|
+
50% { opacity: 0.4; }
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* ── Empty ────────────────────────────────────────────────── */
|
|
232
|
+
.ds-empty {
|
|
233
|
+
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
|
234
|
+
padding: var(--spacer-40); color: var(--text-tertiary);
|
|
235
|
+
font-size: var(--body-sm-font-size);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* ── Divider ──────────────────────────────────────────────── */
|
|
239
|
+
.ds-divider { height: 1px; background: var(--border-neutral-l1); }
|
|
240
|
+
|
|
241
|
+
/* ── Avatar ───────────────────────────────────────────────── */
|
|
242
|
+
.ds-avatar {
|
|
243
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
244
|
+
width: 32px; height: 32px; border-radius: 50%;
|
|
245
|
+
background: var(--bg-overlay-l3); color: var(--text-default);
|
|
246
|
+
font-size: var(--body-sm-font-size); font-weight: var(--font-weight-strong);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/* ── Badge ────────────────────────────────────────────────── */
|
|
250
|
+
.ds-badge {
|
|
251
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
252
|
+
min-width: 18px; height: 18px; padding: 0 var(--spacer-4);
|
|
253
|
+
border-radius: var(--radius-full); font-size: 11px; font-weight: 600;
|
|
254
|
+
background: var(--status-error-default); color: #fff;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* ── Collapse ─────────────────────────────────────────────── */
|
|
258
|
+
.ds-collapse__header {
|
|
259
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
260
|
+
padding: var(--spacer-12) var(--spacer-16);
|
|
261
|
+
cursor: pointer; color: var(--text-default); font-weight: var(--font-weight-medium);
|
|
262
|
+
}
|
|
263
|
+
.ds-collapse__body { padding: 0 var(--spacer-16) var(--spacer-16); }
|
|
264
|
+
|
|
265
|
+
/* ── Spin / Loading ───────────────────────────────────────── */
|
|
266
|
+
.ds-spin {
|
|
267
|
+
display: inline-block; width: 24px; height: 24px;
|
|
268
|
+
border: 2px solid var(--bg-overlay-l3); border-top-color: var(--bg-brand);
|
|
269
|
+
border-radius: 50%; animation: ds-spin-rotate 0.8s linear infinite;
|
|
270
|
+
}
|
|
271
|
+
@keyframes ds-spin-rotate {
|
|
272
|
+
to { transform: rotate(360deg); }
|
|
273
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kupola CSS — Full stylesheet bundle.
|
|
3
|
+
*
|
|
4
|
+
* @module @kupola/kupola/css
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* <link rel="stylesheet" href="node_modules/@kupola/kupola/dist/kupola.css">
|
|
8
|
+
* // or in JS:
|
|
9
|
+
* import '@kupola/kupola/css';
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@import './tokens.css';
|
|
13
|
+
@import './components.css';
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kupola Design Tokens
|
|
3
|
+
* Primitives + semantic aliases for dark/light themes.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import '@kupola/kupola/css'; // full bundle
|
|
7
|
+
* import '@kupola/kupola/css/tokens.css'; // tokens only
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
:root {
|
|
11
|
+
/* ── Primitives: Radius ─────────────────────────────────── */
|
|
12
|
+
--radius-2: 2px;
|
|
13
|
+
--radius-4: 4px;
|
|
14
|
+
--radius-6: 6px;
|
|
15
|
+
--radius-8: 8px;
|
|
16
|
+
--radius-10: 10px;
|
|
17
|
+
--radius-full: 9999px;
|
|
18
|
+
|
|
19
|
+
/* ── Primitives: Spacing ────────────────────────────────── */
|
|
20
|
+
--spacer-0: 0px;
|
|
21
|
+
--spacer-4: 4px;
|
|
22
|
+
--spacer-6: 6px;
|
|
23
|
+
--spacer-8: 8px;
|
|
24
|
+
--spacer-12: 12px;
|
|
25
|
+
--spacer-16: 16px;
|
|
26
|
+
--spacer-24: 24px;
|
|
27
|
+
--spacer-32: 32px;
|
|
28
|
+
--spacer-40: 40px;
|
|
29
|
+
|
|
30
|
+
/* ── Typography: Font families ──────────────────────────── */
|
|
31
|
+
--font-family-default: system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
32
|
+
--font-family-heading: system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
33
|
+
--font-family-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
|
|
34
|
+
|
|
35
|
+
/* ── Typography: Body ───────────────────────────────────── */
|
|
36
|
+
--body-xs-font-size: 11px;
|
|
37
|
+
--body-xs-line-height: 16px;
|
|
38
|
+
--body-sm-font-size: 12px;
|
|
39
|
+
--body-sm-line-height: 18px;
|
|
40
|
+
--body-base-font-size: 13px;
|
|
41
|
+
--body-base-line-height: 20px;
|
|
42
|
+
|
|
43
|
+
/* ── Typography: Heading ────────────────────────────────── */
|
|
44
|
+
--heading-xs-font-size: 13px;
|
|
45
|
+
--heading-xs-line-height: 18px;
|
|
46
|
+
--heading-sm-font-size: 14px;
|
|
47
|
+
--heading-sm-line-height: 20px;
|
|
48
|
+
--heading-base-font-size: 16px;
|
|
49
|
+
--heading-base-line-height: 22px;
|
|
50
|
+
--heading-md-font-size: 18px;
|
|
51
|
+
--heading-md-line-height: 28px;
|
|
52
|
+
--heading-lg-font-size: 24px;
|
|
53
|
+
--heading-lg-line-height: 32px;
|
|
54
|
+
--heading-xl-font-size: 28px;
|
|
55
|
+
--heading-xl-line-height: 36px;
|
|
56
|
+
|
|
57
|
+
/* ── Typography: Code ───────────────────────────────────── */
|
|
58
|
+
--code-editor-font-family: var(--font-family-mono);
|
|
59
|
+
--code-editor-font-size: 13px;
|
|
60
|
+
--code-editor-line-height: 20px;
|
|
61
|
+
|
|
62
|
+
/* ── Font weights ───────────────────────────────────────── */
|
|
63
|
+
--font-weight-default: 400;
|
|
64
|
+
--font-weight-medium: 500;
|
|
65
|
+
--font-weight-strong: 600;
|
|
66
|
+
|
|
67
|
+
/* ── Z-index layers ─────────────────────────────────────── */
|
|
68
|
+
--z-index-dropdown: 2000;
|
|
69
|
+
--z-index-modal: 3000;
|
|
70
|
+
--z-index-drawer: 2500;
|
|
71
|
+
--z-index-tooltip: 4000;
|
|
72
|
+
--z-index-notification: 3500;
|
|
73
|
+
|
|
74
|
+
/* ── Transitions ────────────────────────────────────────── */
|
|
75
|
+
--transition-fast: 0.12s ease;
|
|
76
|
+
--transition-normal: 0.2s ease;
|
|
77
|
+
--transition-slow: 0.3s ease;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* ═══════════════════════════════════════════════════════════
|
|
81
|
+
Dark theme (default)
|
|
82
|
+
═══════════════════════════════════════════════════════════ */
|
|
83
|
+
:root,
|
|
84
|
+
[data-theme="dark"] {
|
|
85
|
+
color-scheme: dark;
|
|
86
|
+
|
|
87
|
+
/* Backgrounds */
|
|
88
|
+
--bg-base-default: #0C0C0D;
|
|
89
|
+
--bg-base-secondary: #1A1B1D;
|
|
90
|
+
--bg-base-tertiary: #222427;
|
|
91
|
+
--bg-overlay-l1: rgba(255, 255, 255, 0.04);
|
|
92
|
+
--bg-overlay-l2: rgba(255, 255, 255, 0.06);
|
|
93
|
+
--bg-overlay-l3: rgba(255, 255, 255, 0.08);
|
|
94
|
+
--bg-overlay-l4: rgba(255, 255, 255, 0.12);
|
|
95
|
+
|
|
96
|
+
/* Text */
|
|
97
|
+
--text-default: #E5E7EB;
|
|
98
|
+
--text-secondary: #B8BDCA;
|
|
99
|
+
--text-tertiary: #9CA3AF;
|
|
100
|
+
--text-disabled: #8B93A1;
|
|
101
|
+
--text-onbrand: #FFFFFF;
|
|
102
|
+
|
|
103
|
+
/* Icons */
|
|
104
|
+
--icon-default: #E5E7EB;
|
|
105
|
+
--icon-secondary: #B8BDCA;
|
|
106
|
+
--icon-tertiary: #9CA3AF;
|
|
107
|
+
--icon-disabled: #8B93A1;
|
|
108
|
+
|
|
109
|
+
/* Borders */
|
|
110
|
+
--border-neutral-l1: rgba(255, 255, 255, 0.12);
|
|
111
|
+
--border-neutral-l2: rgba(255, 255, 255, 0.18);
|
|
112
|
+
--border-neutral-l3: rgba(255, 255, 255, 0.25);
|
|
113
|
+
|
|
114
|
+
/* Brand */
|
|
115
|
+
--bg-brand: #32F08C;
|
|
116
|
+
--bg-brand-hover: #53F4A2;
|
|
117
|
+
--bg-brand-disabled: rgba(50, 240, 140, 0.3);
|
|
118
|
+
|
|
119
|
+
/* Status */
|
|
120
|
+
--status-success-default: #32F08C;
|
|
121
|
+
--status-warning-default: #FFAD5B;
|
|
122
|
+
--status-error-default: #FF9CA8;
|
|
123
|
+
--status-info-default: #79B8FF;
|
|
124
|
+
--status-success-surface-l1: rgba(50, 240, 140, 0.12);
|
|
125
|
+
--status-warning-surface-l1: rgba(255, 173, 91, 0.12);
|
|
126
|
+
--status-error-surface-l1: rgba(255, 156, 168, 0.12);
|
|
127
|
+
--status-info-surface-l1: rgba(121, 184, 255, 0.12);
|
|
128
|
+
|
|
129
|
+
/* Semantic aliases */
|
|
130
|
+
--color-background: var(--bg-base-default);
|
|
131
|
+
--color-surface: var(--bg-base-secondary);
|
|
132
|
+
--color-foreground: var(--text-default);
|
|
133
|
+
--color-border: var(--border-neutral-l1);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* ═══════════════════════════════════════════════════════════
|
|
137
|
+
Light theme
|
|
138
|
+
═══════════════════════════════════════════════════════════ */
|
|
139
|
+
[data-theme="light"] {
|
|
140
|
+
color-scheme: light;
|
|
141
|
+
|
|
142
|
+
--bg-base-default: #FFFFFF;
|
|
143
|
+
--bg-base-secondary: #F5F6F8;
|
|
144
|
+
--bg-base-tertiary: #EDF0F5;
|
|
145
|
+
--bg-overlay-l1: rgba(0, 0, 0, 0.04);
|
|
146
|
+
--bg-overlay-l2: rgba(0, 0, 0, 0.06);
|
|
147
|
+
--bg-overlay-l3: rgba(0, 0, 0, 0.08);
|
|
148
|
+
--bg-overlay-l4: rgba(0, 0, 0, 0.12);
|
|
149
|
+
|
|
150
|
+
--text-default: #0F1117;
|
|
151
|
+
--text-secondary: #4B5563;
|
|
152
|
+
--text-tertiary: #5B6370;
|
|
153
|
+
--text-disabled: #525A68;
|
|
154
|
+
--text-onbrand: #FFFFFF;
|
|
155
|
+
|
|
156
|
+
--icon-default: #0F1117;
|
|
157
|
+
--icon-secondary: #4B5563;
|
|
158
|
+
--icon-tertiary: #5B6370;
|
|
159
|
+
--icon-disabled: #525A68;
|
|
160
|
+
|
|
161
|
+
--border-neutral-l1: rgba(0, 0, 0, 0.12);
|
|
162
|
+
--border-neutral-l2: rgba(0, 0, 0, 0.18);
|
|
163
|
+
--border-neutral-l3: rgba(0, 0, 0, 0.25);
|
|
164
|
+
|
|
165
|
+
--bg-brand: #22C55E;
|
|
166
|
+
--bg-brand-hover: #16A34A;
|
|
167
|
+
--bg-brand-disabled: rgba(34, 197, 94, 0.3);
|
|
168
|
+
|
|
169
|
+
--status-success-default: #16A34A;
|
|
170
|
+
--status-warning-default: #CA8A04;
|
|
171
|
+
--status-error-default: #DC2626;
|
|
172
|
+
--status-info-default: #2E69FF;
|
|
173
|
+
--status-success-surface-l1: rgba(22, 163, 74, 0.08);
|
|
174
|
+
--status-warning-surface-l1: rgba(202, 138, 4, 0.08);
|
|
175
|
+
--status-error-surface-l1: rgba(220, 38, 38, 0.08);
|
|
176
|
+
--status-info-surface-l1: rgba(46, 105, 255, 0.08);
|
|
177
|
+
|
|
178
|
+
--color-background: var(--bg-base-default);
|
|
179
|
+
--color-surface: var(--bg-base-secondary);
|
|
180
|
+
--color-foreground: var(--text-default);
|
|
181
|
+
--color-border: var(--border-neutral-l1);
|
|
182
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||i(n)},i(n),()=>function(t){if(t.u)return;t.u=!0,o(t)}(n)}function i(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.h.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function u(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):c(o)?s.push(e(o.value)):"function"!=typeof o&&s.push(e(o??""))}return s.join("")}function f(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const o=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.l=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.l=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.l?.(),this.node?.remove()}}class l{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.l=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.l=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.l?.()}}class a{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,s){const i=new d,o=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):"function"==typeof o||c(o)?s.push(r(i)):s.push(e(o??""))}return s.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);i.fragment=f,y(f,n.values,o,i);for(const t of i.parts)t.mount();return s.appendChild(f),i}function y(t,n,s,i){const o=[...t.childNodes];for(const e of o)3===e.nodeType?g(e,n,s,i,t):1===e.nodeType&&m(e,n,s,i)}function g(t,n,s,i,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),l=e.indexOf(u);if(-1===l)continue;if("text"!==f(s,u).type)continue;const a=e.substring(0,l),d=e.substring(l+u.length);a&&o.insertBefore(document.createTextNode(a),t);const p=new h(o,n[c]);i.parts.push(p);let y=t;return d&&(y=document.createTextNode(d),o.insertBefore(y,t)),o.removeChild(t),p.p=y!==t?y:null,void(d&&g(y,n,s,i,o))}}function m(t,n,s,i){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const u=f(s,c);if("event"===u.type&&u.attrName===e.name){t.removeAttribute(e.name);const s=new a(t,e.name,n[o]);i.parts.push(s)}else if("attr"===u.type&&u.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new l(t,e.name,n[o]);i.parts.push(r)}}y(t,n,s,i)}exports.Badge=function(t={}){const{value:s="",max:i=99,type:o="",dot:e=!1,pulse:c=!1}=t;let r=s;const u=n`
|
|
2
2
|
<span class="ds-badge${o?` ds-badge--${o}`:""}${e?" ds-badge--dot":""}${c?" ds-badge--pulse":""}">${e?"":String(""!==r?function(){const t=Number(r);return!isNaN(t)&&t>i?i+"+":String(r)}():"")}</span>
|
|
3
|
-
`,f=document.createDocumentFragment(),h=p(u,f),l=f.querySelector(".ds-badge");return{get element(){return f},setValue:function(t){r=t,function(){if(!l)return;e||(l.textContent=function(){if(e)return"";const t=Number(r);
|
|
3
|
+
`,f=document.createDocumentFragment(),h=p(u,f),l=f.querySelector(".ds-badge");return{get element(){return f},setValue:function(t){r=t,function(){if(!l)return;e||(l.textContent=function(){if(e)return"";const t=Number(r);if(!isNaN(t)&&t>i)return i+"+";return String(r)}())}()},getValue:function(){return r},destroy:function(){h.destroy()}}};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,u:!1};return n.o=()=>{n.u||i(n)},i(n),()=>function(t){if(t.u)return;t.u=!0,o(t)}(n)}function i(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.h.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function u(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):c(o)?s.push(e(o.value)):"function"!=typeof o&&s.push(e(o??""))}return s.join("")}function f(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const o=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.l=null}mount(){const n=document.createTextNode("");if(this.p?this.container.insertBefore(n,this.p):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.l=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=u(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.l?.(),this.node?.remove()}}class l{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.l=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.l=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.l?.()}}class a{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function p(n,s){const i=new d,o=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(u(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(u).join("")):"function"==typeof o||c(o)?s.push(r(i)):s.push(e(o??""))}return s.join("")}(n),f=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);i.fragment=f,y(f,n.values,o,i);for(const t of i.parts)t.mount();return s.appendChild(f),i}function y(t,n,s,i){const o=[...t.childNodes];for(const e of o)3===e.nodeType?g(e,n,s,i,t):1===e.nodeType&&m(e,n,s,i)}function g(t,n,s,i,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const u=r(c),l=e.indexOf(u);if(-1===l)continue;if("text"!==f(s,u).type)continue;const a=e.substring(0,l),d=e.substring(l+u.length);a&&o.insertBefore(document.createTextNode(a),t);const p=new h(o,n[c]);i.parts.push(p);let y=t;return d&&(y=document.createTextNode(d),o.insertBefore(y,t)),o.removeChild(t),p.p=y!==t?y:null,void(d&&g(y,n,s,i,o))}}function m(t,n,s,i){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const u=f(s,c);if("event"===u.type&&u.attrName===e.name){t.removeAttribute(e.name);const s=new a(t,e.name,n[o]);i.parts.push(s)}else if("attr"===u.type&&u.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new l(t,e.name,n[o]);i.parts.push(r)}}y(t,n,s,i)}function b(t={}){const{value:s="",max:i=99,type:o="",dot:e=!1,pulse:c=!1}=t;let r=s;const u=n`
|
|
2
2
|
<span class="ds-badge${o?` ds-badge--${o}`:""}${e?" ds-badge--dot":""}${c?" ds-badge--pulse":""}">${e?"":String(""!==r?function(){const t=Number(r);return!isNaN(t)&&t>i?i+"+":String(r)}():"")}</span>
|
|
3
|
-
`,f=document.createDocumentFragment(),h=p(u,f),l=f.querySelector(".ds-badge");return{get element(){return f},setValue:function(t){r=t,function(){if(!l)return;e||(l.textContent=function(){if(e)return"";const t=Number(r);
|
|
3
|
+
`,f=document.createDocumentFragment(),h=p(u,f),l=f.querySelector(".ds-badge");return{get element(){return f},setValue:function(t){r=t,function(){if(!l)return;e||(l.textContent=function(){if(e)return"";const t=Number(r);if(!isNaN(t)&&t>i)return i+"+";return String(r)}())}()},getValue:function(){return r},destroy:function(){h.destroy()}}}export{b as Badge};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,l:!1};return n.o=()=>{n.l||i(n)},i(n),()=>function(t){if(t.l)return;t.l=!0,o(t)}(n)}function i(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.u.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function l(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(l).join("")):c(o)?s.push(e(o.value)):"function"!=typeof o&&s.push(e(o??""))}return s.join("")}function u(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const o=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.v?this.container.insertBefore(n,this.v):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=l(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class f{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class a{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,s){const i=new d,o=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(l).join("")):"function"==typeof o||c(o)?s.push(r(i)):s.push(e(o??""))}return s.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);i.fragment=u,v(u,n.values,o,i);for(const t of i.parts)t.mount();return s.appendChild(u),i}function v(t,n,s,i){const o=[...t.childNodes];for(const e of o)3===e.nodeType?g(e,n,s,i,t):1===e.nodeType&&m(e,n,s,i)}function g(t,n,s,i,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),f=e.indexOf(l);if(-1===f)continue;if("text"!==u(s,l).type)continue;const a=e.substring(0,f),d=e.substring(f+l.length);a&&o.insertBefore(document.createTextNode(a),t);const y=new h(o,n[c]);i.parts.push(y);let v=t;return d&&(v=document.createTextNode(d),o.insertBefore(v,t)),o.removeChild(t),y.v=v!==t?v:null,void(d&&g(v,n,s,i,o))}}function m(t,n,s,i){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const l=u(s,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const s=new a(t,e.name,n[o]);i.parts.push(s)}else if("attr"===l.type&&l.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new f(t,e.name,n[o]);i.parts.push(r)}}v(t,n,s,i)}const x={success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};function w(t={}){const{title:s="",content:i="",type:o="normal",confirmText:e="OK",cancelText:c="Cancel",showCancel:r=!0}=t;return new Promise(t=>{const l=()=>{
|
|
1
|
+
"use strict";class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...s){return new t(n,s)}function s(t){const n={t:t,i:new Set,o:null,l:!1};return n.o=()=>{n.l||i(n)},i(n),()=>function(t){if(t.l)return;t.l=!0,o(t)}(n)}function i(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.u.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const s=Object.getPrototypeOf(t);if(s){const t=Object.getOwnPropertyDescriptor(s,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function l(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(l).join("")):c(o)?s.push(e(o.value)):"function"!=typeof o&&s.push(e(o??""))}return s.join("")}function u(t,n){const s=t.indexOf(n);if(-1===s)return{type:"text"};const i=t.substring(0,s).lastIndexOf("<");if(-1===i)return{type:"text"};if(t.substring(i,s).includes(">"))return{type:"text"};const o=t.substring(i+1,s).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.v?this.container.insertBefore(n,this.v):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=l(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class f{constructor(t,n,s){this.element=t,this.attrName=n,this.rawValue=s,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=s(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class a{constructor(t,n,s){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=s,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,s){const i=new d,o=function(n){const s=[];for(let i=0;i<n.strings.length;i++)if(s.push(n.strings[i]),i<n.values.length){const o=n.values[i];o instanceof t?s.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?s.push(o.map(l).join("")):"function"==typeof o||c(o)?s.push(r(i)):s.push(e(o??""))}return s.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);i.fragment=u,v(u,n.values,o,i);for(const t of i.parts)t.mount();return s.appendChild(u),i}function v(t,n,s,i){const o=[...t.childNodes];for(const e of o)3===e.nodeType?g(e,n,s,i,t):1===e.nodeType&&m(e,n,s,i)}function g(t,n,s,i,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),f=e.indexOf(l);if(-1===f)continue;if("text"!==u(s,l).type)continue;const a=e.substring(0,f),d=e.substring(f+l.length);a&&o.insertBefore(document.createTextNode(a),t);const y=new h(o,n[c]);i.parts.push(y);let v=t;return d&&(v=document.createTextNode(d),o.insertBefore(v,t)),o.removeChild(t),y.v=v!==t?v:null,void(d&&g(v,n,s,i,o))}}function m(t,n,s,i){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const l=u(s,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const s=new a(t,e.name,n[o]);i.parts.push(s)}else if("attr"===l.type&&l.attrName===e.name){const s=e.value.replace(c,"");s?t.setAttribute(e.name,s):t.removeAttribute(e.name);const r=new f(t,e.name,n[o]);i.parts.push(r)}}v(t,n,s,i)}const x={success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};function w(t={}){const{title:s="",content:i="",type:o="normal",confirmText:e="OK",cancelText:c="Cancel",showCancel:r=!0}=t;return new Promise(t=>{const l=()=>{p(),t(!0)},u=()=>{p(),t(!1)},h=t=>{t.target===t.currentTarget&&u()},f=t=>{"Escape"===t.key&&u(),"Enter"===t.key&&l()},a=n`
|
|
2
2
|
<div class="ds-modal-mask">
|
|
3
3
|
<div class="ds-dialog">
|
|
4
4
|
<div class="ds-dialog__icon ds-dialog__icon--${o}">${x[o]||x.normal}</div>
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
</div>
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
|
-
`,
|
|
13
|
+
`,d=document.createDocumentFragment(),v=y(a,d);document.body.appendChild(d);const g=document.body.querySelector(".ds-modal-mask:last-of-type")||document.body.lastElementChild;g&&g.classList.add("is-visible"),document.body.style.overflow="hidden";const m=g.querySelector('[data-action="confirm"]'),w=g.querySelector('[data-action="cancel"]');function p(){document.removeEventListener("keydown",f),document.body.style.overflow="",g&&g.classList.remove("is-visible"),setTimeout(()=>{v.destroy(),g&&g.parentNode&&g.parentNode.removeChild(g)},50)}m&&m.addEventListener("click",l),w&&w.addEventListener("click",u),g&&g.addEventListener("click",h),document.addEventListener("keydown",f)})}const p={confirm:w,alert:function(t={}){return w({...t,showCancel:!1}).then(()=>{})}};exports.Dialog=p;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...i){return new t(n,i)}function i(t){const n={t:t,i:new Set,o:null,l:!1};return n.o=()=>{n.l||s(n)},s(n),()=>function(t){if(t.l)return;t.l=!0,o(t)}(n)}function s(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.u.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const i=Object.getPrototypeOf(t);if(i){const t=Object.getOwnPropertyDescriptor(i,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function l(n){const i=[];for(let s=0;s<n.strings.length;s++)if(i.push(n.strings[s]),s<n.values.length){const o=n.values[s];o instanceof t?i.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?i.push(o.map(l).join("")):c(o)?i.push(e(o.value)):"function"!=typeof o&&i.push(e(o??""))}return i.join("")}function u(t,n){const i=t.indexOf(n);if(-1===i)return{type:"text"};const s=t.substring(0,i).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,i).includes(">"))return{type:"text"};const o=t.substring(s+1,i).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.v?this.container.insertBefore(n,this.v):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=i(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=l(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class f{constructor(t,n,i){this.element=t,this.attrName=n,this.rawValue=i,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=i(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class a{constructor(t,n,i){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=i,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,i){const s=new d,o=function(n){const i=[];for(let s=0;s<n.strings.length;s++)if(i.push(n.strings[s]),s<n.values.length){const o=n.values[s];o instanceof t?i.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?i.push(o.map(l).join("")):"function"==typeof o||c(o)?i.push(r(s)):i.push(e(o??""))}return i.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);s.fragment=u,v(u,n.values,o,s);for(const t of s.parts)t.mount();return i.appendChild(u),s}function v(t,n,i,s){const o=[...t.childNodes];for(const e of o)3===e.nodeType?g(e,n,i,s,t):1===e.nodeType&&m(e,n,i,s)}function g(t,n,i,s,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),f=e.indexOf(l);if(-1===f)continue;if("text"!==u(i,l).type)continue;const a=e.substring(0,f),d=e.substring(f+l.length);a&&o.insertBefore(document.createTextNode(a),t);const y=new h(o,n[c]);s.parts.push(y);let v=t;return d&&(v=document.createTextNode(d),o.insertBefore(v,t)),o.removeChild(t),y.v=v!==t?v:null,void(d&&g(v,n,i,s,o))}}function m(t,n,i,s){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const l=u(i,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const i=new a(t,e.name,n[o]);s.parts.push(i)}else if("attr"===l.type&&l.attrName===e.name){const i=e.value.replace(c,"");i?t.setAttribute(e.name,i):t.removeAttribute(e.name);const r=new f(t,e.name,n[o]);s.parts.push(r)}}v(t,n,i,s)}const x={success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};function w(t={}){const{title:i="",content:s="",type:o="normal",confirmText:e="OK",cancelText:c="Cancel",showCancel:r=!0}=t;return new Promise(t=>{const l=()=>{
|
|
1
|
+
class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...i){return new t(n,i)}function i(t){const n={t:t,i:new Set,o:null,l:!1};return n.o=()=>{n.l||s(n)},s(n),()=>function(t){if(t.l)return;t.l=!0,o(t)}(n)}function s(t){o(t);try{t.t()}finally{}}function o(t){for(const n of t.i)n.u.delete(t);t.i.clear()}function e(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c(t){if(null==t||"object"!=typeof t)return!1;const n=Object.getOwnPropertyDescriptor(t,"value");if(n&&"function"==typeof n.get)return!0;const i=Object.getPrototypeOf(t);if(i){const t=Object.getOwnPropertyDescriptor(i,"value");if(t&&"function"==typeof t.get)return!0}return!1}const r=t=>`${t}`;function l(n){const i=[];for(let s=0;s<n.strings.length;s++)if(i.push(n.strings[s]),s<n.values.length){const o=n.values[s];o instanceof t?i.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?i.push(o.map(l).join("")):c(o)?i.push(e(o.value)):"function"!=typeof o&&i.push(e(o??""))}return i.join("")}function u(t,n){const i=t.indexOf(n);if(-1===i)return{type:"text"};const s=t.substring(0,i).lastIndexOf("<");if(-1===s)return{type:"text"};if(t.substring(s,i).includes(">"))return{type:"text"};const o=t.substring(s+1,i).match(/([\w\-@:.]+)\s*=\s*(?:"[^"]*|'[^']*|[^\s>]*?)$/);if(!o)return{type:"text"};const e=o[1];return e.startsWith("on")&&e.length>2?{type:"event",attrName:e}:{type:"attr",attrName:e}}class h{constructor(t,n){this.container=t,this.rawValue=n,this.node=null,this.h=null}mount(){const n=document.createTextNode("");if(this.v?this.container.insertBefore(n,this.v):this.container.appendChild(n),this.node=n,c(this.rawValue)){const t=this.rawValue;this.h=i(()=>{this.node.textContent=null!=t.value?String(t.value):""})}else this.rawValue instanceof t?this.node.textContent=l(this.rawValue):this.node.textContent=null!=this.rawValue?String(this.rawValue):""}destroy(){this.h?.(),this.node?.remove()}}class f{constructor(t,n,i){this.element=t,this.attrName=n,this.rawValue=i,this.h=null}mount(){if(c(this.rawValue)){const t=this.rawValue;this.h=i(()=>{const n=t.value;null==n||!1===n?this.element.removeAttribute(this.attrName):this.element.setAttribute(this.attrName,String(n))})}else null!=this.rawValue&&!1!==this.rawValue&&this.element.setAttribute(this.attrName,String(this.rawValue))}destroy(){this.h?.()}}class a{constructor(t,n,i){this.element=t,this.eventName=n.slice(2).toLowerCase(),this.handler=i,this.m=null}mount(){"function"==typeof this.handler&&(this.m=t=>this.handler(t),this.element.addEventListener(this.eventName,this.m))}destroy(){this.m&&(this.element.removeEventListener(this.eventName,this.m),this.m=null)}}class d{constructor(){this.parts=[],this.fragment=null}destroy(){for(const t of this.parts)t.destroy();this.parts.length=0}}function y(n,i){const s=new d,o=function(n){const i=[];for(let s=0;s<n.strings.length;s++)if(i.push(n.strings[s]),s<n.values.length){const o=n.values[s];o instanceof t?i.push(l(o)):Array.isArray(o)&&o.length>0&&o[0]instanceof t?i.push(o.map(l).join("")):"function"==typeof o||c(o)?i.push(r(s)):i.push(e(o??""))}return i.join("")}(n),u=function(t){const n=document.createElement("template");return n.innerHTML=t,n.content}(o);s.fragment=u,v(u,n.values,o,s);for(const t of s.parts)t.mount();return i.appendChild(u),s}function v(t,n,i,s){const o=[...t.childNodes];for(const e of o)3===e.nodeType?g(e,n,i,s,t):1===e.nodeType&&m(e,n,i,s)}function g(t,n,i,s,o){const e=t.textContent||"";for(let c=0;c<n.length;c++){const l=r(c),f=e.indexOf(l);if(-1===f)continue;if("text"!==u(i,l).type)continue;const a=e.substring(0,f),d=e.substring(f+l.length);a&&o.insertBefore(document.createTextNode(a),t);const y=new h(o,n[c]);s.parts.push(y);let v=t;return d&&(v=document.createTextNode(d),o.insertBefore(v,t)),o.removeChild(t),y.v=v!==t?v:null,void(d&&g(v,n,i,s,o))}}function m(t,n,i,s){const o=[...t.attributes];for(const e of o)for(let o=0;o<n.length;o++){const c=r(o);if(!e.value.includes(c))continue;const l=u(i,c);if("event"===l.type&&l.attrName===e.name){t.removeAttribute(e.name);const i=new a(t,e.name,n[o]);s.parts.push(i)}else if("attr"===l.type&&l.attrName===e.name){const i=e.value.replace(c,"");i?t.setAttribute(e.name,i):t.removeAttribute(e.name);const r=new f(t,e.name,n[o]);s.parts.push(r)}}v(t,n,i,s)}const x={success:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>',warning:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',error:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>',info:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',normal:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>'};function w(t={}){const{title:i="",content:s="",type:o="normal",confirmText:e="OK",cancelText:c="Cancel",showCancel:r=!0}=t;return new Promise(t=>{const l=()=>{p(),t(!0)},u=()=>{p(),t(!1)},h=t=>{t.target===t.currentTarget&&u()},f=t=>{"Escape"===t.key&&u(),"Enter"===t.key&&l()},a=n`
|
|
2
2
|
<div class="ds-modal-mask">
|
|
3
3
|
<div class="ds-dialog">
|
|
4
4
|
<div class="ds-dialog__icon ds-dialog__icon--${o}">${x[o]||x.normal}</div>
|
|
@@ -10,4 +10,4 @@ class t{constructor(t,n){this.strings=t,this.values=n}}function n(n,...i){return
|
|
|
10
10
|
</div>
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
|
-
`,
|
|
13
|
+
`,d=document.createDocumentFragment(),v=y(a,d);document.body.appendChild(d);const g=document.body.querySelector(".ds-modal-mask:last-of-type")||document.body.lastElementChild;g&&g.classList.add("is-visible"),document.body.style.overflow="hidden";const m=g.querySelector('[data-action="confirm"]'),w=g.querySelector('[data-action="cancel"]');function p(){document.removeEventListener("keydown",f),document.body.style.overflow="",g&&g.classList.remove("is-visible"),setTimeout(()=>{v.destroy(),g&&g.parentNode&&g.parentNode.removeChild(g)},50)}m&&m.addEventListener("click",l),w&&w.addEventListener("click",u),g&&g.addEventListener("click",h),document.addEventListener("keydown",f)})}const p={confirm:w,alert:function(t={}){return w({...t,showCancel:!1}).then(()=>{})}};export{p as Dialog};
|