@liteforge/modal 1.0.0 → 1.1.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.
- package/css/styles.css +119 -0
- package/dist/styles.d.ts +0 -13
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +7 -165
- package/dist/styles.js.map +1 -1
- package/package.json +9 -5
package/css/styles.css
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* ─── CSS Variables (Customizable) ─────────────────────────── */
|
|
2
|
+
/* Default values reference @liteforge/theme semantic tokens. */
|
|
3
|
+
/* Dark mode cascades automatically through the theme selectors. */
|
|
4
|
+
|
|
5
|
+
:root {
|
|
6
|
+
--lf-modal-backdrop: var(--lf-color-bg-overlay, rgba(0, 0, 0, 0.5));
|
|
7
|
+
--lf-modal-bg: var(--lf-color-surface, #ffffff);
|
|
8
|
+
--lf-modal-border-radius: 10px;
|
|
9
|
+
--lf-modal-shadow: var(--lf-shadow-xl, 0 20px 60px rgba(0, 0, 0, 0.3));
|
|
10
|
+
--lf-modal-header-bg: var(--lf-color-bg-subtle, #f8fafc);
|
|
11
|
+
--lf-modal-header-color: var(--lf-color-text, #1e293b);
|
|
12
|
+
--lf-modal-body-color: var(--lf-color-text, #374151);
|
|
13
|
+
--lf-modal-close-color: var(--lf-color-text-muted, #6b7280);
|
|
14
|
+
--lf-modal-z-index: var(--lf-z-modal, 1000);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* ─── Provider ─────────────────────────────────────────────── */
|
|
18
|
+
|
|
19
|
+
.lf-modal-provider {
|
|
20
|
+
position: fixed;
|
|
21
|
+
inset: 0;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
z-index: var(--lf-modal-z-index);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* ─── Overlay ──────────────────────────────────────────────── */
|
|
27
|
+
|
|
28
|
+
.lf-modal-overlay {
|
|
29
|
+
position: fixed;
|
|
30
|
+
inset: 0;
|
|
31
|
+
background: var(--lf-modal-backdrop);
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
pointer-events: all;
|
|
36
|
+
opacity: 0;
|
|
37
|
+
transition: opacity var(--lf-transition-base, 0.2s ease);
|
|
38
|
+
padding: var(--lf-space-4, 16px);
|
|
39
|
+
box-sizing: border-box;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.lf-modal-overlay--open {
|
|
43
|
+
opacity: 1;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* ─── Size Variants ────────────────────────────────────────── */
|
|
47
|
+
|
|
48
|
+
.lf-modal-overlay--sm .lf-modal { max-width: 400px; }
|
|
49
|
+
.lf-modal-overlay--md .lf-modal { max-width: 560px; }
|
|
50
|
+
.lf-modal-overlay--lg .lf-modal { max-width: 720px; }
|
|
51
|
+
.lf-modal-overlay--xl .lf-modal { max-width: 1000px; }
|
|
52
|
+
.lf-modal-overlay--full .lf-modal { max-width: 100vw; margin: 0; border-radius: 0; }
|
|
53
|
+
|
|
54
|
+
/* ─── Modal ────────────────────────────────────────────────── */
|
|
55
|
+
|
|
56
|
+
.lf-modal {
|
|
57
|
+
background: var(--lf-modal-bg);
|
|
58
|
+
border-radius: var(--lf-modal-border-radius);
|
|
59
|
+
box-shadow: var(--lf-modal-shadow);
|
|
60
|
+
width: 100%;
|
|
61
|
+
max-height: calc(100vh - 32px);
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
transform: translateY(-8px);
|
|
65
|
+
transition: transform var(--lf-transition-base, 0.2s ease);
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
font-family: var(--lf-font-sans, system-ui, -apple-system, sans-serif);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.lf-modal-overlay--open .lf-modal {
|
|
71
|
+
transform: translateY(0);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* ─── Header ───────────────────────────────────────────────── */
|
|
75
|
+
|
|
76
|
+
.lf-modal-header {
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: space-between;
|
|
80
|
+
padding: var(--lf-space-4, 16px) var(--lf-space-5, 20px);
|
|
81
|
+
background: var(--lf-modal-header-bg);
|
|
82
|
+
border-bottom: 1px solid var(--lf-color-border, rgba(0, 0, 0, 0.08));
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.lf-modal-title {
|
|
87
|
+
font-size: var(--lf-text-md, 16px);
|
|
88
|
+
font-weight: var(--lf-font-semibold, 600);
|
|
89
|
+
color: var(--lf-modal-header-color);
|
|
90
|
+
line-height: 1.4;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.lf-modal-close {
|
|
94
|
+
background: none;
|
|
95
|
+
border: none;
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
color: var(--lf-modal-close-color);
|
|
98
|
+
font-size: 18px;
|
|
99
|
+
padding: 4px 8px;
|
|
100
|
+
border-radius: var(--lf-radius-sm, 4px);
|
|
101
|
+
line-height: 1;
|
|
102
|
+
transition: background-color var(--lf-transition-fast, 0.15s), color var(--lf-transition-fast, 0.15s);
|
|
103
|
+
flex-shrink: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.lf-modal-close:hover {
|
|
107
|
+
background: var(--lf-color-bg-muted, rgba(0, 0, 0, 0.06));
|
|
108
|
+
color: var(--lf-modal-header-color);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* ─── Body ─────────────────────────────────────────────────── */
|
|
112
|
+
|
|
113
|
+
.lf-modal-body {
|
|
114
|
+
padding: var(--lf-space-5, 20px);
|
|
115
|
+
color: var(--lf-modal-body-color);
|
|
116
|
+
font-size: var(--lf-text-base, 14px);
|
|
117
|
+
line-height: 1.6;
|
|
118
|
+
overflow-y: auto;
|
|
119
|
+
}
|
package/dist/styles.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @liteforge/modal - Default CSS Theme
|
|
3
|
-
*
|
|
4
|
-
* Minimal, clean default styles using CSS variables.
|
|
5
|
-
* Injected once when the first modal provider is created (unless unstyled: true).
|
|
6
|
-
*/
|
|
7
1
|
import type { ModalStyles } from './types.js';
|
|
8
2
|
/**
|
|
9
3
|
* Maps ModalStyles keys to their CSS variable names.
|
|
@@ -11,13 +5,6 @@ import type { ModalStyles } from './types.js';
|
|
|
11
5
|
* can override the global :root variables without affecting other modals.
|
|
12
6
|
*/
|
|
13
7
|
export declare const STYLE_TOKEN_MAP: ReadonlyArray<readonly [keyof ModalStyles, string]>;
|
|
14
|
-
/**
|
|
15
|
-
* Inject default styles into the document head.
|
|
16
|
-
* Called automatically when the first ModalProvider is created (unless unstyled: true).
|
|
17
|
-
*/
|
|
18
8
|
export declare function injectDefaultStyles(): void;
|
|
19
|
-
/**
|
|
20
|
-
* Reset styles injection flag (for testing)
|
|
21
|
-
*/
|
|
22
9
|
export declare function resetStylesInjection(): void;
|
|
23
10
|
//# sourceMappingURL=styles.d.ts.map
|
package/dist/styles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,WAAW,EAAE,MAAM,CAAC,CAStE,CAAA;AAIV,wBAAgB,mBAAmB,IAAI,IAAI,CAS1C;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAG3C"}
|
package/dist/styles.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @liteforge/modal - Default CSS Theme
|
|
3
|
-
*
|
|
4
|
-
* Minimal, clean default styles using CSS variables.
|
|
5
|
-
* Injected once when the first modal provider is created (unless unstyled: true).
|
|
6
|
-
*/
|
|
1
|
+
import stylesUrl from '../css/styles.css?url';
|
|
7
2
|
/**
|
|
8
3
|
* Maps ModalStyles keys to their CSS variable names.
|
|
9
4
|
* Applied as inline styles on the overlay element so each modal instance
|
|
@@ -20,173 +15,20 @@ export const STYLE_TOKEN_MAP = [
|
|
|
20
15
|
['borderRadius', '--lf-modal-border-radius'],
|
|
21
16
|
];
|
|
22
17
|
let stylesInjected = false;
|
|
23
|
-
const DEFAULT_STYLES = `
|
|
24
|
-
/* ─── CSS Variables (Customizable) ─────────────────────────── */
|
|
25
|
-
|
|
26
|
-
:root {
|
|
27
|
-
--lf-modal-backdrop: rgba(0, 0, 0, 0.5);
|
|
28
|
-
--lf-modal-bg: #ffffff;
|
|
29
|
-
--lf-modal-border-radius: 10px;
|
|
30
|
-
--lf-modal-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
31
|
-
--lf-modal-header-bg: #f8fafc;
|
|
32
|
-
--lf-modal-header-color: #1e293b;
|
|
33
|
-
--lf-modal-body-color: #374151;
|
|
34
|
-
--lf-modal-close-color: #6b7280;
|
|
35
|
-
--lf-modal-z-index: 1000;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/* ─── Provider ─────────────────────────────────────────────── */
|
|
39
|
-
|
|
40
|
-
.lf-modal-provider {
|
|
41
|
-
position: fixed;
|
|
42
|
-
inset: 0;
|
|
43
|
-
pointer-events: none;
|
|
44
|
-
z-index: var(--lf-modal-z-index);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/* ─── Overlay ──────────────────────────────────────────────── */
|
|
48
|
-
|
|
49
|
-
.lf-modal-overlay {
|
|
50
|
-
position: fixed;
|
|
51
|
-
inset: 0;
|
|
52
|
-
background: var(--lf-modal-backdrop);
|
|
53
|
-
display: flex;
|
|
54
|
-
align-items: center;
|
|
55
|
-
justify-content: center;
|
|
56
|
-
pointer-events: all;
|
|
57
|
-
opacity: 0;
|
|
58
|
-
transition: opacity 0.2s ease;
|
|
59
|
-
padding: 16px;
|
|
60
|
-
box-sizing: border-box;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.lf-modal-overlay--open {
|
|
64
|
-
opacity: 1;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/* ─── Size Variants ────────────────────────────────────────── */
|
|
68
|
-
|
|
69
|
-
.lf-modal-overlay--sm .lf-modal { max-width: 400px; }
|
|
70
|
-
.lf-modal-overlay--md .lf-modal { max-width: 560px; }
|
|
71
|
-
.lf-modal-overlay--lg .lf-modal { max-width: 720px; }
|
|
72
|
-
.lf-modal-overlay--xl .lf-modal { max-width: 1000px; }
|
|
73
|
-
.lf-modal-overlay--full .lf-modal { max-width: 100vw; margin: 0; border-radius: 0; }
|
|
74
|
-
|
|
75
|
-
/* ─── Modal ────────────────────────────────────────────────── */
|
|
76
|
-
|
|
77
|
-
.lf-modal {
|
|
78
|
-
background: var(--lf-modal-bg);
|
|
79
|
-
border-radius: var(--lf-modal-border-radius);
|
|
80
|
-
box-shadow: var(--lf-modal-shadow);
|
|
81
|
-
width: 100%;
|
|
82
|
-
max-height: calc(100vh - 32px);
|
|
83
|
-
display: flex;
|
|
84
|
-
flex-direction: column;
|
|
85
|
-
transform: translateY(-8px);
|
|
86
|
-
transition: transform 0.2s ease;
|
|
87
|
-
overflow: hidden;
|
|
88
|
-
font-family: system-ui, -apple-system, sans-serif;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.lf-modal-overlay--open .lf-modal {
|
|
92
|
-
transform: translateY(0);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/* ─── Header ───────────────────────────────────────────────── */
|
|
96
|
-
|
|
97
|
-
.lf-modal-header {
|
|
98
|
-
display: flex;
|
|
99
|
-
align-items: center;
|
|
100
|
-
justify-content: space-between;
|
|
101
|
-
padding: 16px 20px;
|
|
102
|
-
background: var(--lf-modal-header-bg);
|
|
103
|
-
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
|
|
104
|
-
flex-shrink: 0;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.lf-modal-title {
|
|
108
|
-
font-size: 16px;
|
|
109
|
-
font-weight: 600;
|
|
110
|
-
color: var(--lf-modal-header-color);
|
|
111
|
-
line-height: 1.4;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.lf-modal-close {
|
|
115
|
-
background: none;
|
|
116
|
-
border: none;
|
|
117
|
-
cursor: pointer;
|
|
118
|
-
color: var(--lf-modal-close-color);
|
|
119
|
-
font-size: 18px;
|
|
120
|
-
padding: 4px 8px;
|
|
121
|
-
border-radius: 4px;
|
|
122
|
-
line-height: 1;
|
|
123
|
-
transition: background-color 0.15s, color 0.15s;
|
|
124
|
-
flex-shrink: 0;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.lf-modal-close:hover {
|
|
128
|
-
background: rgba(0, 0, 0, 0.06);
|
|
129
|
-
color: var(--lf-modal-header-color);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/* ─── Body ─────────────────────────────────────────────────── */
|
|
133
|
-
|
|
134
|
-
.lf-modal-body {
|
|
135
|
-
padding: 20px;
|
|
136
|
-
color: var(--lf-modal-body-color);
|
|
137
|
-
font-size: 14px;
|
|
138
|
-
line-height: 1.6;
|
|
139
|
-
overflow-y: auto;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/* ─── Dark Mode Support ────────────────────────────────────── */
|
|
143
|
-
|
|
144
|
-
.dark,
|
|
145
|
-
[data-theme="dark"] {
|
|
146
|
-
--lf-modal-backdrop: rgba(0, 0, 0, 0.7);
|
|
147
|
-
--lf-modal-bg: #1e1e2e;
|
|
148
|
-
--lf-modal-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
|
|
149
|
-
--lf-modal-header-bg: #181825;
|
|
150
|
-
--lf-modal-header-color: #cdd6f4;
|
|
151
|
-
--lf-modal-body-color: #a6adc8;
|
|
152
|
-
--lf-modal-close-color: #6c7086;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
@media (prefers-color-scheme: dark) {
|
|
156
|
-
:root:not([data-theme="light"]) {
|
|
157
|
-
--lf-modal-backdrop: rgba(0, 0, 0, 0.7);
|
|
158
|
-
--lf-modal-bg: #1e1e2e;
|
|
159
|
-
--lf-modal-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
|
|
160
|
-
--lf-modal-header-bg: #181825;
|
|
161
|
-
--lf-modal-header-color: #cdd6f4;
|
|
162
|
-
--lf-modal-body-color: #a6adc8;
|
|
163
|
-
--lf-modal-close-color: #6c7086;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
`;
|
|
167
|
-
/**
|
|
168
|
-
* Inject default styles into the document head.
|
|
169
|
-
* Called automatically when the first ModalProvider is created (unless unstyled: true).
|
|
170
|
-
*/
|
|
171
18
|
export function injectDefaultStyles() {
|
|
172
19
|
if (stylesInjected)
|
|
173
20
|
return;
|
|
174
21
|
if (typeof document === 'undefined')
|
|
175
22
|
return; // SSR safety
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
23
|
+
const link = document.createElement('link');
|
|
24
|
+
link.rel = 'stylesheet';
|
|
25
|
+
link.href = stylesUrl;
|
|
26
|
+
link.setAttribute('data-lf-modal', '');
|
|
27
|
+
document.head.appendChild(link);
|
|
180
28
|
stylesInjected = true;
|
|
181
29
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Reset styles injection flag (for testing)
|
|
184
|
-
*/
|
|
185
30
|
export function resetStylesInjection() {
|
|
186
31
|
stylesInjected = false;
|
|
187
|
-
|
|
188
|
-
if (existing) {
|
|
189
|
-
existing.remove();
|
|
190
|
-
}
|
|
32
|
+
document.querySelector('link[data-lf-modal]')?.remove();
|
|
191
33
|
}
|
|
192
34
|
//# sourceMappingURL=styles.js.map
|
package/dist/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwD;IAClF,CAAC,IAAI,EAAY,eAAe,CAAC;IACjC,CAAC,UAAU,EAAM,sBAAsB,CAAC;IACxC,CAAC,aAAa,EAAG,yBAAyB,CAAC;IAC3C,CAAC,WAAW,EAAK,uBAAuB,CAAC;IACzC,CAAC,YAAY,EAAI,wBAAwB,CAAC;IAC1C,CAAC,UAAU,EAAM,qBAAqB,CAAC;IACvC,CAAC,QAAQ,EAAQ,mBAAmB,CAAC;IACrC,CAAC,cAAc,EAAE,0BAA0B,CAAC;CACpC,CAAA;AAEV,IAAI,cAAc,GAAG,KAAK,CAAA;AAE1B,MAAM,UAAU,mBAAmB;IACjC,IAAI,cAAc;QAAE,OAAM;IAC1B,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAM,CAAC,aAAa;IACzD,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3C,IAAI,CAAC,GAAG,GAAG,YAAY,CAAA;IACvB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAA;IACrB,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;IACtC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IAC/B,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,cAAc,GAAG,KAAK,CAAA;IACtB,QAAQ,CAAC,aAAa,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAA;AACzD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liteforge/modal",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Signal-based modal system. createModal, ModalProvider, confirm/alert/prompt presets.",
|
|
5
5
|
"author": "SchildW3rk <contact@schildw3rk.dev>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,14 +29,18 @@
|
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
31
|
"import": "./dist/index.js"
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
|
+
"./styles": "./css/styles.css"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"dist",
|
|
37
|
+
"css",
|
|
36
38
|
"README.md",
|
|
37
39
|
"LICENSE"
|
|
38
40
|
],
|
|
39
|
-
"sideEffects":
|
|
41
|
+
"sideEffects": [
|
|
42
|
+
"css/*.css"
|
|
43
|
+
],
|
|
40
44
|
"engines": {
|
|
41
45
|
"node": ">=18"
|
|
42
46
|
},
|
|
@@ -45,7 +49,7 @@
|
|
|
45
49
|
},
|
|
46
50
|
"peerDependencies": {
|
|
47
51
|
"@liteforge/core": ">=0.1.0",
|
|
48
|
-
"@liteforge/runtime": ">=0.4.
|
|
52
|
+
"@liteforge/runtime": ">=0.4.3"
|
|
49
53
|
},
|
|
50
54
|
"peerDependenciesMeta": {
|
|
51
55
|
"@liteforge/runtime": {
|
|
@@ -54,7 +58,7 @@
|
|
|
54
58
|
},
|
|
55
59
|
"devDependencies": {
|
|
56
60
|
"@liteforge/core": "0.1.0",
|
|
57
|
-
"@liteforge/runtime": "0.4.
|
|
61
|
+
"@liteforge/runtime": "0.4.3"
|
|
58
62
|
},
|
|
59
63
|
"scripts": {
|
|
60
64
|
"build": "tsc -p tsconfig.build.json",
|