@prunellejs/ui 0.1.1 → 0.5.3
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/llms.txt +9 -3
- package/package.json +2 -2
- package/src/CommandPalette.tsx +120 -67
- package/src/DataTable.tsx +27 -17
- package/src/Dialog.tsx +29 -13
- package/src/Menu.tsx +10 -8
- package/src/Select.tsx +16 -6
- package/src/Toaster.tsx +112 -2
- package/src/behaviors.ts +108 -6
- package/src/index.ts +1 -1
- package/src/plugin.ts +96 -32
- package/src/styles/bare.css +21 -312
- package/src/styles/base.css +55 -0
- package/src/styles/components/accordion.css +10 -0
- package/src/styles/components/badge.css +6 -0
- package/src/styles/components/button.css +11 -0
- package/src/styles/components/card.css +5 -0
- package/src/styles/components/checkbox.css +11 -0
- package/src/styles/components/command.css +25 -0
- package/src/styles/components/datatable.css +9 -0
- package/src/styles/components/dialog.css +16 -0
- package/src/styles/components/drawer.css +29 -0
- package/src/styles/components/field.css +8 -0
- package/src/styles/components/layout.css +69 -0
- package/src/styles/components/menu.css +21 -0
- package/src/styles/components/notice.css +5 -0
- package/src/styles/components/popover.css +8 -0
- package/src/styles/components/progress.css +14 -0
- package/src/styles/components/radio-group.css +11 -0
- package/src/styles/components/select.css +25 -0
- package/src/styles/components/switch.css +42 -0
- package/src/styles/components/tabs.css +4 -0
- package/src/styles/components/toast.css +28 -0
- package/src/styles/grammars/console.css +113 -256
- package/src/styles/grammars/editorial.css +99 -270
- package/src/styles/grammars/orbit.css +118 -388
- package/src/styles/grammars/prunelle.css +157 -360
- package/src/styles/grammars/soft.css +103 -237
- package/src/styles/grammars/workshop.css +104 -246
- package/src/styles/scan.ts +137 -0
- package/src/styles/split.ts +381 -0
- package/src/styles/theme.css +21 -0
- package/src/styles/themed/accordion.css +20 -0
- package/src/styles/themed/badge.css +20 -0
- package/src/styles/themed/button.css +21 -0
- package/src/styles/themed/card.css +23 -0
- package/src/styles/themed/checkbox.css +4 -0
- package/src/styles/themed/command.css +33 -0
- package/src/styles/themed/datatable.css +28 -0
- package/src/styles/themed/dialog.css +13 -0
- package/src/styles/themed/drawer.css +13 -0
- package/src/styles/themed/field.css +22 -0
- package/src/styles/themed/menu.css +21 -0
- package/src/styles/themed/notice.css +17 -0
- package/src/styles/themed/popover.css +11 -0
- package/src/styles/themed/radio-group.css +12 -0
- package/src/styles/themed/select.css +32 -0
- package/src/styles/themed/switch.css +18 -0
- package/src/styles/themed/tabs.css +17 -0
- package/src/styles/themed/toast.css +18 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Grammar: Workshop — tactile 2px ink frames, hard unblurred offset shadows, physical press travel.
|
|
2
2
|
* Inspired by print & craft studios (like jb-peinture). Eject via `prunelle ui-eject workshop`. */
|
|
3
3
|
|
|
4
|
-
@import '../
|
|
4
|
+
@import '../theme.css';
|
|
5
5
|
|
|
6
6
|
@layer kui {
|
|
7
7
|
:root {
|
|
@@ -27,287 +27,145 @@
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
[data-ui="button"] {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
gap: 0.5rem;
|
|
34
|
-
font: 700 0.88rem/1 var(--ui-font-body);
|
|
30
|
+
--ui-btn-f: 700 0.88rem/1 var(--ui-font-body);
|
|
31
|
+
--ui-btn-pad: 0.7rem 1.25rem;
|
|
32
|
+
--ui-btn-bd: var(--ui-border-w) solid var(--ui-line);
|
|
35
33
|
letter-spacing: 0.04em;
|
|
36
34
|
text-transform: uppercase;
|
|
37
|
-
padding: 0.7rem 1.25rem;
|
|
38
|
-
border-radius: var(--ui-radius);
|
|
39
|
-
border: var(--ui-border-w) solid var(--ui-line);
|
|
40
|
-
background: var(--ui-surface);
|
|
41
|
-
color: var(--ui-ink);
|
|
42
35
|
box-shadow: var(--ui-press-shadow);
|
|
43
|
-
text-decoration: none;
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
transition: transform var(--ui-motion), box-shadow var(--ui-motion), background var(--ui-motion);
|
|
46
|
-
|
|
47
36
|
&:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ui-line); }
|
|
48
37
|
&:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ui-line); }
|
|
49
|
-
|
|
50
|
-
&[data-tone="accent"] { background: var(--ui-accent); border-color: var(--ui-line); color: var(--ui-on-accent); }
|
|
51
|
-
&[data-tone="danger"] { background: var(--ui-danger); border-color: var(--ui-line); color: var(--ui-on-accent); }
|
|
52
|
-
&[data-variant="outline"] { background: transparent; }
|
|
53
|
-
&[data-variant="ghost"] { border-color: transparent; background: transparent; box-shadow: none; }
|
|
38
|
+
&[data-tone="accent"], &[data-tone="danger"], &[data-variant="outline"] { border-color: var(--ui-line); }
|
|
54
39
|
&[data-variant="ghost"]:hover:not(:disabled) { border-color: var(--ui-line); transform: none; box-shadow: none; }
|
|
55
|
-
&[data-size="sm"] { font-size: 0.78rem; padding: 0.45rem 0.85rem; }
|
|
56
|
-
&[data-size="lg"] { font-size: 0.98rem; padding: 0.9rem 1.6rem; }
|
|
57
40
|
}
|
|
58
41
|
|
|
59
|
-
/* Card: crisp framed print with hard unblurred drop shadow */
|
|
60
42
|
[data-ui="card"] {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
43
|
+
--ui-card-bd: var(--ui-border-w) solid var(--ui-line);
|
|
44
|
+
--ui-card-pad: 1.25rem;
|
|
45
|
+
--ui-card-hf: 800 1.1rem/1.3 var(--ui-font-display);
|
|
46
|
+
--ui-card-hpb: 0.75rem;
|
|
47
|
+
--ui-card-hmb: 0.75rem;
|
|
48
|
+
--ui-card-hbd: var(--ui-border-w) solid var(--ui-line);
|
|
49
|
+
--ui-card-fpt: 0.75rem;
|
|
50
|
+
--ui-card-fbd: var(--ui-border-w) solid var(--ui-line);
|
|
65
51
|
box-shadow: var(--ui-shadow);
|
|
66
|
-
padding: 1.25rem;
|
|
67
|
-
|
|
68
|
-
& [data-part="header"] {
|
|
69
|
-
font-family: var(--ui-font-display);
|
|
70
|
-
font-weight: 800;
|
|
71
|
-
font-size: 1.1rem;
|
|
72
|
-
padding-block-end: 0.75rem;
|
|
73
|
-
margin-block-end: 0.75rem;
|
|
74
|
-
border-bottom: var(--ui-border-w) solid var(--ui-line);
|
|
75
|
-
}
|
|
76
|
-
& [data-part="footer"] {
|
|
77
|
-
margin-block-start: 1rem;
|
|
78
|
-
padding-block-start: 0.75rem;
|
|
79
|
-
border-top: var(--ui-border-w) solid var(--ui-line);
|
|
80
|
-
}
|
|
81
52
|
}
|
|
82
53
|
|
|
83
54
|
[data-ui="badge"] {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
55
|
+
--ui-badge-f: 700 0.74rem/1 var(--ui-font-body);
|
|
56
|
+
--ui-badge-pad: 0.3rem 0.65rem;
|
|
57
|
+
--ui-badge-bd: var(--ui-border-w) solid var(--ui-line);
|
|
58
|
+
--ui-badge-bg: var(--ui-surface);
|
|
59
|
+
--ui-badge-fg: var(--ui-ink);
|
|
60
|
+
--ui-badge-tbg: 100%;
|
|
61
|
+
--ui-badge-tfg: var(--ui-on-accent);
|
|
62
|
+
--ui-badge-tbd: 0%;
|
|
63
|
+
--ui-badge-tbd0: var(--ui-line);
|
|
87
64
|
letter-spacing: 0.08em;
|
|
88
65
|
text-transform: uppercase;
|
|
89
|
-
padding: 0.3rem 0.65rem;
|
|
90
|
-
border: var(--ui-border-w) solid var(--ui-line);
|
|
91
|
-
border-radius: var(--ui-radius);
|
|
92
|
-
background: var(--ui-surface);
|
|
93
|
-
color: var(--ui-ink);
|
|
94
|
-
|
|
95
|
-
&[data-tone="accent"] { background: var(--ui-accent); color: var(--ui-on-accent); }
|
|
96
|
-
&[data-tone="success"] { background: var(--ui-success); color: var(--ui-on-accent); }
|
|
97
|
-
&[data-tone="warning"] { background: var(--ui-warning); color: var(--ui-on-accent); }
|
|
98
|
-
&[data-tone="danger"] { background: var(--ui-danger); color: var(--ui-on-accent); }
|
|
99
66
|
}
|
|
100
67
|
|
|
101
68
|
[data-ui="notice"] {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
background: var(--ui-surface);
|
|
69
|
+
--ui-notice-bw: var(--ui-border-w);
|
|
70
|
+
--ui-notice-pad: 0.9rem 1.1rem;
|
|
105
71
|
box-shadow: 4px 4px 0 var(--ui-shadow-color);
|
|
106
|
-
|
|
107
|
-
&[data-tone="accent"] { border-color: var(--ui-accent); }
|
|
108
|
-
&[data-tone="success"] { border-color: var(--ui-success); }
|
|
109
|
-
&[data-tone="warning"] { border-color: var(--ui-warning); }
|
|
110
|
-
&[data-tone="danger"] { border-color: var(--ui-danger); }
|
|
72
|
+
&[data-tone] { border-color: var(--ui-tone); }
|
|
111
73
|
}
|
|
112
74
|
|
|
113
75
|
[data-ui="field"] {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
&
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
[data-ui="
|
|
146
|
-
[data-ui="
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
background: var(--ui-paper);
|
|
152
|
-
}
|
|
153
|
-
[data-ui="tabs"] [data-part="trigger"] {
|
|
154
|
-
background: transparent;
|
|
155
|
-
border: 0;
|
|
156
|
-
border-right: var(--ui-border-w) solid var(--ui-line);
|
|
157
|
-
padding: 0.55rem 1rem;
|
|
158
|
-
font: 700 0.82rem/1 var(--ui-font-body);
|
|
159
|
-
text-transform: uppercase;
|
|
160
|
-
color: var(--ui-ink);
|
|
161
|
-
cursor: pointer;
|
|
162
|
-
&:last-child { border-right: 0; }
|
|
163
|
-
&[data-state="active"] { background: var(--ui-accent); color: var(--ui-on-accent); }
|
|
164
|
-
}
|
|
165
|
-
[data-ui="tabs"] [data-part="panel"] { padding-block-start: 1rem; }
|
|
166
|
-
|
|
167
|
-
dialog[data-ui="dialog"] {
|
|
168
|
-
border: var(--ui-border-w) solid var(--ui-line);
|
|
169
|
-
border-radius: var(--ui-radius);
|
|
170
|
-
background: var(--ui-surface);
|
|
171
|
-
color: var(--ui-ink);
|
|
172
|
-
box-shadow: 8px 8px 0 var(--ui-line);
|
|
173
|
-
padding: 0;
|
|
174
|
-
& > [data-part="panel"] { padding: 1.5rem; }
|
|
175
|
-
& [data-part="title"] { margin: 0 0 0.5rem; font-weight: 800; font-size: 1.25rem; }
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
[data-ui="popover"][popover],
|
|
179
|
-
[data-ui="menu"] [data-part="content"],
|
|
180
|
-
[data-ui="select"] [data-part="listbox"] {
|
|
181
|
-
background: var(--ui-surface);
|
|
182
|
-
color: var(--ui-ink);
|
|
183
|
-
border: var(--ui-border-w) solid var(--ui-line);
|
|
184
|
-
box-shadow: var(--ui-shadow);
|
|
185
|
-
padding: 0.35rem;
|
|
186
|
-
min-inline-size: 12rem;
|
|
76
|
+
--ui-fld-lf: 700 0.82rem/1.2 var(--ui-font-body);
|
|
77
|
+
--ui-in-f: 500 0.95rem/1.4 var(--ui-font-body);
|
|
78
|
+
--ui-in-bd: var(--ui-border-w) solid var(--ui-line);
|
|
79
|
+
--ui-in-pad: 0.6rem 0.85rem;
|
|
80
|
+
& [data-part="label"] { text-transform: uppercase; letter-spacing: 0.06em; }
|
|
81
|
+
& [data-part="error"] { font-weight: 600; }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
[data-ui="accordion"] {
|
|
85
|
+
--ui-acc-bd: var(--ui-border-w) solid var(--ui-line);
|
|
86
|
+
--ui-acc-bg: var(--ui-surface);
|
|
87
|
+
--ui-acc-gap: calc(-1 * var(--ui-border-w));
|
|
88
|
+
--ui-acc-tpad: 0.85rem 1rem;
|
|
89
|
+
--ui-acc-tf: 700 1rem/1.3 var(--ui-font-body);
|
|
90
|
+
--ui-acc-m: '▸';
|
|
91
|
+
--ui-acc-mo: '▾';
|
|
92
|
+
--ui-acc-cpad: 0 1rem 1rem;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
[data-ui="tabs"] {
|
|
96
|
+
--ui-tab-disp: inline-flex;
|
|
97
|
+
--ui-tab-gap: 0;
|
|
98
|
+
--ui-tab-pad: 0.55rem 1rem;
|
|
99
|
+
--ui-tab-f: 700 0.82rem/1 var(--ui-font-body);
|
|
100
|
+
--ui-tab-fg: var(--ui-ink);
|
|
101
|
+
--ui-tab-abg: var(--ui-accent);
|
|
102
|
+
--ui-tab-afg: var(--ui-on-accent);
|
|
103
|
+
& [data-part="list"] { border: var(--ui-border-w) solid var(--ui-line); background: var(--ui-paper); }
|
|
104
|
+
& [data-part="trigger"] { border-right: var(--ui-border-w) solid var(--ui-line); text-transform: uppercase; &:last-child { border-right: 0; } }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
dialog[data-ui="dialog"],
|
|
108
|
+
dialog[data-ui="drawer"],
|
|
109
|
+
dialog[data-ui="command"] {
|
|
110
|
+
--ui-dlg-bd: var(--ui-border-w) solid var(--ui-line);
|
|
111
|
+
--ui-dlg-sh: 8px 8px 0 var(--ui-line);
|
|
112
|
+
--ui-dlg-tf: 800 1.25rem/1.25 var(--ui-font-display);
|
|
187
113
|
}
|
|
188
114
|
|
|
189
|
-
[data-ui="
|
|
190
|
-
[data-ui="
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
background: transparent;
|
|
197
|
-
border: 0;
|
|
198
|
-
padding: 0.5rem 0.7rem;
|
|
199
|
-
font: 600 0.88rem/1.3 var(--ui-font-body);
|
|
200
|
-
color: var(--ui-ink);
|
|
201
|
-
cursor: pointer;
|
|
202
|
-
&:hover, &[data-highlighted="true"] { background: var(--ui-paper); }
|
|
203
|
-
&[data-selected="true"] { background: var(--ui-accent); color: var(--ui-on-accent); }
|
|
115
|
+
[data-ui="popover"],
|
|
116
|
+
[data-ui="menu"],
|
|
117
|
+
[data-ui="select"] {
|
|
118
|
+
--ui-pop-bd: var(--ui-border-w) solid var(--ui-line);
|
|
119
|
+
--ui-pop-sh: var(--ui-shadow);
|
|
120
|
+
--ui-it-f: 600 0.88rem/1.3 var(--ui-font-body);
|
|
121
|
+
--ui-it-hbg: var(--ui-paper);
|
|
204
122
|
}
|
|
205
123
|
|
|
206
|
-
[data-ui="select"]
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
background: var(--ui-surface);
|
|
213
|
-
color: var(--ui-ink);
|
|
214
|
-
border: var(--ui-border-w) solid var(--ui-line);
|
|
215
|
-
box-shadow: var(--ui-press-shadow);
|
|
216
|
-
padding: 0.55rem 0.85rem;
|
|
217
|
-
font: 600 0.9rem/1.3 var(--ui-font-body);
|
|
218
|
-
cursor: pointer;
|
|
124
|
+
[data-ui="select"] {
|
|
125
|
+
--ui-sel-bd: var(--ui-border-w) solid var(--ui-line);
|
|
126
|
+
--ui-sel-pad: 0.55rem 0.85rem;
|
|
127
|
+
--ui-sel-f: 600 0.9rem/1.3 var(--ui-font-body);
|
|
128
|
+
& [data-part="trigger"] { box-shadow: var(--ui-press-shadow); }
|
|
129
|
+
& [data-part="option"][data-selected="true"] { background: var(--ui-accent); color: var(--ui-on-accent); }
|
|
219
130
|
}
|
|
220
131
|
|
|
221
132
|
[data-ui="toast"] {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
padding: 0.8rem 1rem;
|
|
227
|
-
display: flex;
|
|
228
|
-
align-items: start;
|
|
229
|
-
justify-content: space-between;
|
|
230
|
-
gap: 0.75rem;
|
|
231
|
-
&[data-tone="accent"] { border-color: var(--ui-accent); }
|
|
232
|
-
&[data-tone="success"] { border-color: var(--ui-success); }
|
|
233
|
-
&[data-tone="warning"] { border-color: var(--ui-warning); }
|
|
234
|
-
&[data-tone="danger"] { border-color: var(--ui-danger); }
|
|
133
|
+
--ui-tst-bw: var(--ui-border-w);
|
|
134
|
+
--ui-tst-sh: var(--ui-shadow);
|
|
135
|
+
--ui-tst-pad: 0.8rem 1rem;
|
|
136
|
+
&[data-tone] { border-color: var(--ui-tone); }
|
|
235
137
|
}
|
|
236
138
|
|
|
237
|
-
[data-ui="
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
&::after { background: var(--ui-line); }
|
|
243
|
-
}
|
|
244
|
-
[data-ui="switch"] input:checked + [data-part="track"] {
|
|
245
|
-
background: var(--ui-accent);
|
|
246
|
-
&::after { background: var(--ui-on-accent); }
|
|
139
|
+
[data-ui="switch"] {
|
|
140
|
+
--ui-sw-bd: var(--ui-border-w) solid var(--ui-line);
|
|
141
|
+
--ui-sw-bg: var(--ui-surface);
|
|
142
|
+
--ui-sw-th: var(--ui-line);
|
|
143
|
+
--ui-sw-onbd: var(--ui-line);
|
|
247
144
|
}
|
|
248
|
-
[data-ui="radio-group"] [data-part="legend"] {
|
|
249
|
-
font-weight: 800;
|
|
250
|
-
font-size: 0.82rem;
|
|
251
|
-
text-transform: uppercase;
|
|
252
|
-
margin-block-end: 0.45rem;
|
|
253
|
-
}
|
|
254
|
-
[data-ui="radio-group"] [data-part="hint"] { font-size: 0.8rem; color: var(--ui-muted); }
|
|
255
145
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
color: var(--ui-ink);
|
|
261
|
-
box-shadow: 8px 8px 0 var(--ui-line);
|
|
262
|
-
padding: 0;
|
|
263
|
-
}
|
|
264
|
-
dialog[data-ui="drawer"] > [data-part="panel"] {
|
|
265
|
-
padding: 1.5rem;
|
|
146
|
+
[data-ui="radio-group"] {
|
|
147
|
+
--ui-rg-lf: 800 0.82rem/1.2 var(--ui-font-body);
|
|
148
|
+
--ui-rg-lc: uppercase;
|
|
149
|
+
--ui-rg-lfg: var(--ui-ink);
|
|
266
150
|
}
|
|
151
|
+
|
|
267
152
|
dialog[data-ui="command"] {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
padding: 0.85rem 1rem;
|
|
276
|
-
font: 600 0.95rem/1.3 var(--ui-font-body);
|
|
277
|
-
}
|
|
278
|
-
& [data-part="list"] { padding: 0.4rem; }
|
|
279
|
-
& [data-part="item"] {
|
|
280
|
-
display: flex;
|
|
281
|
-
justify-content: space-between;
|
|
282
|
-
align-items: center;
|
|
283
|
-
width: 100%;
|
|
284
|
-
border: 0;
|
|
285
|
-
background: transparent;
|
|
286
|
-
color: var(--ui-ink);
|
|
287
|
-
padding: 0.55rem 0.7rem;
|
|
288
|
-
font: 600 0.9rem/1.3 var(--ui-font-body);
|
|
289
|
-
cursor: pointer;
|
|
290
|
-
&[data-highlighted="true"] { background: var(--ui-accent); color: var(--ui-on-accent); }
|
|
291
|
-
}
|
|
292
|
-
& [data-part="kbd"] { font-size: 0.74rem; border: var(--ui-border-w) solid currentColor; padding: 0.05rem 0.35rem; font-weight: 700; }
|
|
293
|
-
& [data-part="empty"] { padding: 1rem; margin: 0; color: var(--ui-muted); }
|
|
153
|
+
--ui-cmd-ibb: var(--ui-border-w) solid var(--ui-line);
|
|
154
|
+
--ui-cmd-ibg: var(--ui-paper);
|
|
155
|
+
--ui-cmd-if: 600 0.95rem/1.3 var(--ui-font-body);
|
|
156
|
+
--ui-cmd-mf: 600 0.9rem/1.3 var(--ui-font-body);
|
|
157
|
+
--ui-cmd-hbg: var(--ui-accent);
|
|
158
|
+
--ui-cmd-hfg: var(--ui-on-accent);
|
|
159
|
+
& [data-part="kbd"] { color: currentColor; border: var(--ui-border-w) solid currentColor; font-weight: 700; }
|
|
294
160
|
}
|
|
161
|
+
|
|
295
162
|
[data-ui="datatable"] {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
padding: 0.45rem 0.7rem;
|
|
304
|
-
font: 600 0.88rem/1.3 var(--ui-font-body);
|
|
305
|
-
}
|
|
306
|
-
& [data-part="meta"] { font-size: 0.8rem; font-weight: 700; color: var(--ui-muted); }
|
|
307
|
-
& table { border: var(--ui-border-w) solid var(--ui-line); background: var(--ui-surface); box-shadow: var(--ui-shadow); }
|
|
308
|
-
& th { background: var(--ui-paper); border-bottom: var(--ui-border-w) solid var(--ui-line); padding: 0.55rem 0.7rem; font-size: 0.8rem; text-transform: uppercase; font-weight: 800; }
|
|
309
|
-
& td { border-bottom: 1px solid var(--ui-line); padding: 0.6rem 0.7rem; }
|
|
310
|
-
& tr[data-selected="true"] { background: color-mix(in srgb, var(--ui-accent) 16%, var(--ui-surface)); }
|
|
311
|
-
& [data-part="sort"] { background: transparent; border: 0; padding: 0; font: inherit; text-transform: inherit; color: inherit; cursor: pointer; }
|
|
163
|
+
--ui-srch-bd: var(--ui-border-w) solid var(--ui-line);
|
|
164
|
+
--ui-tbl-bd: var(--ui-border-w) solid var(--ui-line);
|
|
165
|
+
--ui-tbl-bg: var(--ui-surface);
|
|
166
|
+
--ui-th-bb: var(--ui-border-w) solid var(--ui-line);
|
|
167
|
+
--ui-tbl-sel: color-mix(in srgb, var(--ui-accent) 16%, var(--ui-surface));
|
|
168
|
+
& table { box-shadow: var(--ui-shadow); }
|
|
169
|
+
& th { background: var(--ui-paper); text-transform: uppercase; font-weight: 800; }
|
|
312
170
|
}
|
|
313
171
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// Static scanner detecting which `@prunellejs/ui` component parts a set of source files renders.
|
|
2
|
+
// Checks both named imports from `@prunellejs/ui` and literal `data-ui="..."` / `data-layout="..."` attributes.
|
|
3
|
+
|
|
4
|
+
import type { UiComponentPart } from './split'
|
|
5
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
6
|
+
import { resolve } from 'node:path'
|
|
7
|
+
import { UI_COMPONENT_PARTS, UI_EXPORT_TO_PARTS } from './split'
|
|
8
|
+
|
|
9
|
+
const PART_SET = new Set<string>(UI_COMPONENT_PARTS)
|
|
10
|
+
const UI_SRC_DIR = resolve(import.meta.dir, '..')
|
|
11
|
+
|
|
12
|
+
const IMPORT_STMT_RE = /import\s+(?!type\b)([\s\S]*?)\s+from\s+['"]([^'"]+)['"]/g
|
|
13
|
+
const NAMED_LIST_RE = /\{([\s\S]*?)\}/
|
|
14
|
+
const NAMESPACE_RE = /\*\s+as\s+[A-Za-z_$]/
|
|
15
|
+
const DATA_UI_ATTR_RE = /\bdata-ui\s*=\s*(?:["']([^"']+)["']|\{([^}]*)\})/g
|
|
16
|
+
const DATA_LAYOUT_ATTR_RE = /\bdata-layout\s*=/
|
|
17
|
+
const STATIC_QUOTED_RE = /^\s*["']([^"']+)["']\s*$/
|
|
18
|
+
|
|
19
|
+
const DATA_UI_ALIASES: Readonly<Record<string, readonly UiComponentPart[]>> = {
|
|
20
|
+
'table': ['datatable'],
|
|
21
|
+
'toaster': ['toast'],
|
|
22
|
+
'dialog-root': ['dialog', 'button', 'layout'],
|
|
23
|
+
'drawer-root': ['drawer', 'button', 'layout'],
|
|
24
|
+
'command-root': ['command', 'button'],
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function isUiImportSource(specifier: string): boolean {
|
|
28
|
+
if (specifier === '@prunellejs/ui')
|
|
29
|
+
return true
|
|
30
|
+
// Tests and monorepo apps may import the workspace package entry directly.
|
|
31
|
+
return specifier.endsWith('/packages/ui/src/index.ts') || specifier.endsWith('/packages/ui/src/index')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function isInsideUiPackage(file: string): boolean {
|
|
35
|
+
const norm = file.replace(/\\/g, '/')
|
|
36
|
+
return norm.startsWith(`${UI_SRC_DIR.replace(/\\/g, '/')}/`)
|
|
37
|
+
|| norm.includes('/node_modules/@prunellejs/ui/')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function addPartForAttr(value: string, out: Set<UiComponentPart>): void {
|
|
41
|
+
const aliased = DATA_UI_ALIASES[value]
|
|
42
|
+
if (aliased !== undefined) {
|
|
43
|
+
for (const p of aliased)
|
|
44
|
+
out.add(p)
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
if (PART_SET.has(value))
|
|
48
|
+
out.add(value as UiComponentPart)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface FileUiScan {
|
|
52
|
+
parts: readonly UiComponentPart[]
|
|
53
|
+
all: boolean
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function scanSingleFile(file: string): FileUiScan {
|
|
57
|
+
if (isInsideUiPackage(file) || !existsSync(file))
|
|
58
|
+
return { parts: [], all: false }
|
|
59
|
+
|
|
60
|
+
const code = readFileSync(file, 'utf8')
|
|
61
|
+
const parts = new Set<UiComponentPart>()
|
|
62
|
+
let all = false
|
|
63
|
+
|
|
64
|
+
for (const match of code.matchAll(IMPORT_STMT_RE)) {
|
|
65
|
+
const clause = match[1]!
|
|
66
|
+
const source = match[2]!
|
|
67
|
+
if (!isUiImportSource(source))
|
|
68
|
+
continue
|
|
69
|
+
if (NAMESPACE_RE.test(clause)) {
|
|
70
|
+
all = true
|
|
71
|
+
break
|
|
72
|
+
}
|
|
73
|
+
const named = NAMED_LIST_RE.exec(clause)
|
|
74
|
+
if (named !== null) {
|
|
75
|
+
for (const rawSpec of named[1]!.split(',')) {
|
|
76
|
+
const spec = rawSpec.trim()
|
|
77
|
+
if (spec === '' || spec.startsWith('type '))
|
|
78
|
+
continue
|
|
79
|
+
const imported = spec.split(/\s+as\s+/)[0]!.trim()
|
|
80
|
+
const mapped = UI_EXPORT_TO_PARTS[imported]
|
|
81
|
+
if (mapped !== undefined) {
|
|
82
|
+
for (const p of mapped)
|
|
83
|
+
parts.add(p)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!all) {
|
|
90
|
+
if (DATA_LAYOUT_ATTR_RE.test(code))
|
|
91
|
+
parts.add('layout')
|
|
92
|
+
for (const match of code.matchAll(DATA_UI_ATTR_RE)) {
|
|
93
|
+
const literal = match[1]
|
|
94
|
+
if (literal !== undefined) {
|
|
95
|
+
addPartForAttr(literal, parts)
|
|
96
|
+
continue
|
|
97
|
+
}
|
|
98
|
+
const expr = match[2] ?? ''
|
|
99
|
+
const staticMatch = STATIC_QUOTED_RE.exec(expr)
|
|
100
|
+
if (staticMatch !== null) {
|
|
101
|
+
addPartForAttr(staticMatch[1]!, parts)
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
all = true
|
|
105
|
+
break
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return all
|
|
111
|
+
? { parts: UI_COMPONENT_PARTS, all: true }
|
|
112
|
+
: { parts: [...parts], all: false }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Creates a per-build cached scanner resolving the set of `@prunellejs/ui` component parts used by a list of source files. */
|
|
116
|
+
export function createUiPartScanner(): (files: readonly string[]) => Set<UiComponentPart> {
|
|
117
|
+
const cache = new Map<string, FileUiScan>()
|
|
118
|
+
const scan = (file: string): FileUiScan => {
|
|
119
|
+
let entry = cache.get(file)
|
|
120
|
+
if (entry === undefined) {
|
|
121
|
+
entry = scanSingleFile(file)
|
|
122
|
+
cache.set(file, entry)
|
|
123
|
+
}
|
|
124
|
+
return entry
|
|
125
|
+
}
|
|
126
|
+
return (files: readonly string[]): Set<UiComponentPart> => {
|
|
127
|
+
const out = new Set<UiComponentPart>()
|
|
128
|
+
for (const file of files) {
|
|
129
|
+
const res = scan(file)
|
|
130
|
+
if (res.all)
|
|
131
|
+
return new Set(UI_COMPONENT_PARTS)
|
|
132
|
+
for (const p of res.parts)
|
|
133
|
+
out.add(p)
|
|
134
|
+
}
|
|
135
|
+
return out
|
|
136
|
+
}
|
|
137
|
+
}
|