@pure-ds/core 0.5.11 → 0.5.13
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
declare function
|
|
1
|
+
export { it as startLive };
|
|
2
|
+
declare function it(n: any, t: any, { emitReady: e, applyResolvedTheme: a, setupSystemListenerIfNeeded: r }: {
|
|
3
3
|
emitReady: any;
|
|
4
4
|
applyResolvedTheme: any;
|
|
5
5
|
setupSystemListenerIfNeeded: any;
|
|
@@ -604,8 +604,8 @@ declare function nt(n: any, t: any, { emitReady: e, applyResolvedTheme: a, setup
|
|
|
604
604
|
};
|
|
605
605
|
"__#private@#l"(t: any): number;
|
|
606
606
|
"__#private@#c"(t: any, e: any): number;
|
|
607
|
-
"__#private@#m"(t: any, e?: number): string;
|
|
608
607
|
"__#private@#h"(t: any, e?: number): string;
|
|
608
|
+
"__#private@#m"(t: any, e?: number): string;
|
|
609
609
|
"__#private@#z"(t: any, e: any, a?: number): string;
|
|
610
610
|
"__#private@#M"(t: any, e: any, a: any): string;
|
|
611
611
|
"__#private@#F"(t: any): {
|
|
@@ -718,10 +718,10 @@ declare function nt(n: any, t: any, { emitReady: e, applyResolvedTheme: a, setup
|
|
|
718
718
|
externalPath: any;
|
|
719
719
|
};
|
|
720
720
|
"__#private@#D"(t: any): string;
|
|
721
|
-
"__#private@#N"(t: any): string;
|
|
722
721
|
"__#private@#P"(t: any): string;
|
|
723
|
-
"__#private@#
|
|
722
|
+
"__#private@#N"(t: any): string;
|
|
724
723
|
"__#private@#U"(t: any): string;
|
|
724
|
+
"__#private@#I"(t: any): string;
|
|
725
725
|
"__#private@#O"(t: any): string;
|
|
726
726
|
"__#private@#H"(t: any): string;
|
|
727
727
|
"__#private@#q"(t: any): string;
|
|
@@ -748,8 +748,8 @@ declare function nt(n: any, t: any, { emitReady: e, applyResolvedTheme: a, setup
|
|
|
748
748
|
"__#private@#pe"(): string;
|
|
749
749
|
"__#private@#ue"(): string;
|
|
750
750
|
"__#private@#ge"(): string;
|
|
751
|
-
"__#private@#me"(): string;
|
|
752
751
|
"__#private@#he"(): string;
|
|
752
|
+
"__#private@#me"(): string;
|
|
753
753
|
"__#private@#o"(t: any): {
|
|
754
754
|
h: number;
|
|
755
755
|
s: number;
|
package/package.json
CHANGED
|
@@ -71,7 +71,7 @@ function buildIndexHtml({ version, generatedAt }) {
|
|
|
71
71
|
|
|
72
72
|
<body class="container">
|
|
73
73
|
<header class="stack-sm">
|
|
74
|
-
<p class="
|
|
74
|
+
<p class="auto-gen">Auto-generated by PDS ${version} at ${generatedAt}</p>
|
|
75
75
|
</header>
|
|
76
76
|
|
|
77
77
|
<main></main>
|
|
@@ -90,20 +90,18 @@ function buildDevReloadJs() {
|
|
|
90
90
|
|
|
91
91
|
if (shouldConnect) {
|
|
92
92
|
const reloadPort = 4174;
|
|
93
|
-
const endpoint =
|
|
94
|
-
|
|
95
|
-
source.onmessage = (event) => {
|
|
96
|
-
if (event.data === 'reload') {
|
|
97
|
-
This <code><wc-home></code> Web Component is lazy-loaded and styled with Pure Design System.
|
|
98
|
-
};
|
|
93
|
+
const endpoint = 'http://localhost:' + reloadPort + '/events';
|
|
94
|
+
const source = new EventSource(endpoint);
|
|
99
95
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
source.onmessage = (event) => {
|
|
97
|
+
if (event.data === 'reload') {
|
|
98
|
+
location.reload();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
source.onerror = () => {
|
|
103
|
+
source.close();
|
|
104
|
+
};
|
|
107
105
|
}
|
|
108
106
|
`;
|
|
109
107
|
}
|
|
@@ -113,52 +111,182 @@ function buildAppCss() {
|
|
|
113
111
|
opacity: 0;
|
|
114
112
|
}
|
|
115
113
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const pkgPath = path.join(projectRoot, 'node_modules', '@pure-ds', 'core', 'package.json');
|
|
119
|
-
const raw = await readFile(pkgPath, 'utf8');
|
|
120
|
-
const pkg = JSON.parse(raw);
|
|
121
|
-
return pkg?.version || 'unknown';
|
|
122
|
-
} catch {
|
|
123
|
-
return 'unknown';
|
|
124
|
-
}
|
|
114
|
+
main {
|
|
115
|
+
margin: auto;
|
|
125
116
|
}
|
|
126
117
|
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
h1 {
|
|
119
|
+
background: linear-gradient(var(--gradient-angle, 135deg),
|
|
120
|
+
var(--color-primary-400),
|
|
121
|
+
var(--color-accent-400)
|
|
122
|
+
);
|
|
123
|
+
background-clip: text;
|
|
124
|
+
-webkit-background-clip: text;
|
|
125
|
+
color: transparent;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.container {
|
|
129
|
+
display: grid;
|
|
130
|
+
grid-template-rows: auto 1fr auto;
|
|
131
|
+
height: 100dvh;
|
|
132
|
+
padding: 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
header, footer {
|
|
136
|
+
padding: var(--spacing-4);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
footer {
|
|
140
|
+
text-align: center;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.auto-gen {
|
|
144
|
+
color: var(--color-text-muted);
|
|
145
|
+
font-size: var(--font-size-xs);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
#settings-btn {
|
|
149
|
+
position: fixed;
|
|
150
|
+
top: var(--spacing-4);
|
|
151
|
+
right: var(--spacing-4);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.hero {
|
|
155
|
+
padding: var(--spacing-8);
|
|
156
|
+
zoom: 1.15;
|
|
157
|
+
text-align: center;
|
|
158
|
+
border: var(--border-width-medium) solid transparent;
|
|
159
|
+
background: linear-gradient(var(--color-surface-base), var(--color-surface-base)) padding-box,
|
|
160
|
+
linear-gradient(var(--gradient-angle, 135deg), var(--color-primary-400), var(--color-accent-400)) border-box;
|
|
161
|
+
max-width: var(--max-w-lg);
|
|
162
|
+
border-radius: var(--radius-lg);
|
|
163
|
+
border-width: 3px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.hero > div {
|
|
167
|
+
margin: var(--spacing-10) 0;
|
|
129
168
|
}
|
|
130
169
|
`;
|
|
131
170
|
}
|
|
132
171
|
|
|
133
|
-
function
|
|
134
|
-
return
|
|
135
|
-
|
|
172
|
+
function buildMyHome() {
|
|
173
|
+
return `/**
|
|
174
|
+
* @file my-home.js
|
|
175
|
+
* @description A simple home component for the app.
|
|
176
|
+
*/
|
|
177
|
+
customElements.define(
|
|
178
|
+
"my-home",
|
|
136
179
|
class extends HTMLElement {
|
|
137
180
|
connectedCallback() {
|
|
138
181
|
this.innerHTML = /*html*/ \`
|
|
139
|
-
<article class="
|
|
140
|
-
<
|
|
141
|
-
|
|
142
|
-
<h2 class="text-muted">Build on What Lasts</h2>
|
|
143
|
-
</header>
|
|
144
|
-
<div class="stack-lg">
|
|
182
|
+
<article class="hero">
|
|
183
|
+
<h1>Welcome to your new App</h1>
|
|
184
|
+
<div>
|
|
145
185
|
<p>
|
|
146
|
-
This
|
|
147
|
-
|
|
186
|
+
This <code><my-home></code> Web Component is lazy-loaded and styled with Pure Design System.
|
|
187
|
+
</p>
|
|
188
|
+
<p>
|
|
189
|
+
You can start building your app by editing the files in <code>public/assets/my/</code> and <code>src/js/</code>.
|
|
148
190
|
</p>
|
|
149
191
|
</div>
|
|
150
|
-
<nav
|
|
151
|
-
<
|
|
152
|
-
Get Started
|
|
153
|
-
</
|
|
154
|
-
<a href="https://
|
|
155
|
-
|
|
192
|
+
<nav>
|
|
193
|
+
<a target="_blank" href="https://github.com/Pure-Web-Foundation/pure-ds/blob/main/packages/pds-storybook/stories/GettingStarted.md" class="btn btn-primary btn-lg">
|
|
194
|
+
<pds-icon icon="rocket"></pds-icon> Get Started
|
|
195
|
+
</a>
|
|
196
|
+
<a target="_blank" href="https://puredesignsystem.z6.web.core.windows.net/storybook/" class="btn btn-secondary btn-lg">
|
|
197
|
+
<pds-icon icon="book-open"></pds-icon> Storybook
|
|
156
198
|
</a>
|
|
157
199
|
</nav>
|
|
158
200
|
</article>
|
|
159
201
|
\`;
|
|
160
202
|
}
|
|
161
|
-
}
|
|
203
|
+
},
|
|
204
|
+
);
|
|
205
|
+
`;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function buildMyTheme() {
|
|
209
|
+
return `/**
|
|
210
|
+
* my-theme Web Component - allows users to select the app theme (light, dark, system)
|
|
211
|
+
*
|
|
212
|
+
* Uses Pure Design System (PDS) for styling and theming.
|
|
213
|
+
*/
|
|
214
|
+
customElements.define(
|
|
215
|
+
"my-theme",
|
|
216
|
+
class extends HTMLElement {
|
|
217
|
+
constructor() {
|
|
218
|
+
super();
|
|
219
|
+
this.attachShadow({ mode: "open" });
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async connectedCallback() {
|
|
223
|
+
const componentStyles = PDS.createStylesheet(\`
|
|
224
|
+
:host {
|
|
225
|
+
display: block;
|
|
226
|
+
}
|
|
227
|
+
\`);
|
|
228
|
+
|
|
229
|
+
await PDS.adoptLayers(
|
|
230
|
+
this.shadowRoot,
|
|
231
|
+
["tokens", "primitives", "components", "utilities"],
|
|
232
|
+
[componentStyles],
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
this.shadowRoot.innerHTML += /*html*/ \`
|
|
236
|
+
<form>
|
|
237
|
+
<fieldset role="radiogroup" aria-label="Theme" class="buttons">
|
|
238
|
+
<legend>Theme</legend>
|
|
239
|
+
<label>
|
|
240
|
+
<input type="radio" name="theme" value="system">
|
|
241
|
+
<span>
|
|
242
|
+
<pds-icon icon="moon-stars"></pds-icon>
|
|
243
|
+
System
|
|
244
|
+
</span>
|
|
245
|
+
</label>
|
|
246
|
+
<label>
|
|
247
|
+
<input type="radio" name="theme" value="light">
|
|
248
|
+
<span>
|
|
249
|
+
<pds-icon icon="sun"></pds-icon>
|
|
250
|
+
Light
|
|
251
|
+
</span>
|
|
252
|
+
</label>
|
|
253
|
+
<label>
|
|
254
|
+
<input type="radio" name="theme" value="dark">
|
|
255
|
+
<span>
|
|
256
|
+
<pds-icon icon="moon"></pds-icon>
|
|
257
|
+
Dark
|
|
258
|
+
</span>
|
|
259
|
+
</label>
|
|
260
|
+
</fieldset>
|
|
261
|
+
</form>\`;
|
|
262
|
+
|
|
263
|
+
this.#updateCheckedState();
|
|
264
|
+
|
|
265
|
+
this.shadowRoot.addEventListener("change", (e) => {
|
|
266
|
+
if (e.target.type === "radio" && e.target.name === "theme") {
|
|
267
|
+
PDS.setTheme(e.target.value, { persist: true });
|
|
268
|
+
PDS.toast(\`Theme changed to \${e.target.value}\`, { duration: 2000 });
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
const observer = new MutationObserver(() => {
|
|
273
|
+
this.#updateCheckedState();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
observer.observe(document.documentElement, {
|
|
277
|
+
attributes: true,
|
|
278
|
+
attributeFilter: ["data-theme"],
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
#updateCheckedState() {
|
|
283
|
+
const currentTheme = PDS.theme || "system";
|
|
284
|
+
const radios = this.shadowRoot.querySelectorAll('input[type="radio"]');
|
|
285
|
+
radios.forEach((radio) => {
|
|
286
|
+
radio.checked = radio.value === currentTheme;
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
},
|
|
162
290
|
);
|
|
163
291
|
`;
|
|
164
292
|
}
|
|
@@ -170,12 +298,70 @@ import { config } from '../../pds.config.js';
|
|
|
170
298
|
await PDS.start(config);
|
|
171
299
|
PDS.theme = 'light';
|
|
172
300
|
|
|
173
|
-
await import('/assets/wc/wc-home.js');
|
|
174
|
-
|
|
175
301
|
const main = document.querySelector('main');
|
|
176
|
-
if (main && !main.querySelector('
|
|
177
|
-
main.innerHTML = '<
|
|
302
|
+
if (main && !main.querySelector('my-home')) {
|
|
303
|
+
main.innerHTML = '<my-home></my-home>';
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const settingsBtn = document.createElement('button');
|
|
307
|
+
settingsBtn.id = 'settings-btn';
|
|
308
|
+
settingsBtn.className = 'icon-only btn-xs btn-outline';
|
|
309
|
+
settingsBtn.setAttribute('aria-label', 'Settings');
|
|
310
|
+
settingsBtn.innerHTML = '<pds-icon icon="gear"></pds-icon>';
|
|
311
|
+
document.body.appendChild(settingsBtn);
|
|
312
|
+
|
|
313
|
+
const drawer = document.createElement('pds-drawer');
|
|
314
|
+
drawer.setAttribute('position', 'right');
|
|
315
|
+
drawer.innerHTML =
|
|
316
|
+
'<div slot="drawer-header">Settings</div>' +
|
|
317
|
+
'<div slot="drawer-content"><my-theme></my-theme></div>';
|
|
318
|
+
document.body.appendChild(drawer);
|
|
319
|
+
|
|
320
|
+
settingsBtn.addEventListener('click', () => {
|
|
321
|
+
drawer.open = true;
|
|
322
|
+
});
|
|
323
|
+
`;
|
|
178
324
|
}
|
|
325
|
+
|
|
326
|
+
function buildPdsConfig() {
|
|
327
|
+
return `let defaultEnhancers = [];
|
|
328
|
+
if (typeof window !== "undefined") defaultEnhancers = PDS.defaultEnhancers;
|
|
329
|
+
|
|
330
|
+
export const config = {
|
|
331
|
+
mode: "static",
|
|
332
|
+
preset: "social-feed",
|
|
333
|
+
|
|
334
|
+
autoDefine: {
|
|
335
|
+
predefine: ["pds-icon", "pds-drawer", "pds-toaster"],
|
|
336
|
+
|
|
337
|
+
// Custom component paths
|
|
338
|
+
mapper: (tag) => {
|
|
339
|
+
if (tag.startsWith("my-")) return "/assets/my/\${tag}.js";
|
|
340
|
+
|
|
341
|
+
// Return nothing to use PDS default mapping
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
enhancers: [
|
|
345
|
+
...defaultEnhancers,
|
|
346
|
+
{
|
|
347
|
+
selector: ".hero",
|
|
348
|
+
description: "Adds tooltip on hover",
|
|
349
|
+
run: (element) => {
|
|
350
|
+
let angle = 135;
|
|
351
|
+
const speed = 0.5;
|
|
352
|
+
|
|
353
|
+
function animate() {
|
|
354
|
+
angle = (angle + speed) % 360;
|
|
355
|
+
element.style.setProperty("--gradient-angle", \`\${angle}deg\`);
|
|
356
|
+
requestAnimationFrame(animate);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
animate();
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
},
|
|
364
|
+
};
|
|
179
365
|
`;
|
|
180
366
|
}
|
|
181
367
|
|
|
@@ -242,7 +428,7 @@ async function start() {
|
|
|
242
428
|
format: 'esm',
|
|
243
429
|
sourcemap: true,
|
|
244
430
|
publicPath: '/assets/js',
|
|
245
|
-
external: ['/assets/
|
|
431
|
+
external: ['/assets/my/*'],
|
|
246
432
|
logLevel: 'info',
|
|
247
433
|
plugins: [liveReloadPlugin()]
|
|
248
434
|
});
|
|
@@ -322,7 +508,7 @@ const ctx = await esbuild.context({
|
|
|
322
508
|
format: 'esm',
|
|
323
509
|
sourcemap: true,
|
|
324
510
|
publicPath: '/assets/js',
|
|
325
|
-
external: ['/assets/
|
|
511
|
+
external: ['/assets/my/*'],
|
|
326
512
|
logLevel: 'info',
|
|
327
513
|
plugins: [liveReloadPlugin()]
|
|
328
514
|
});
|
|
@@ -445,13 +631,18 @@ async function main() {
|
|
|
445
631
|
);
|
|
446
632
|
await writeFileIfMissing(path.join(projectRoot, 'public', 'assets', 'css', 'app.css'), buildAppCss());
|
|
447
633
|
await writeFileIfMissing(path.join(projectRoot, 'src', 'js', 'app.js'), buildAppJs());
|
|
634
|
+
await writeFileIfMissing(path.join(projectRoot, 'pds.config.js'), buildPdsConfig());
|
|
448
635
|
await writeFileIfMissing(
|
|
449
636
|
path.join(projectRoot, 'public', 'assets', 'js', 'dev-reload.js'),
|
|
450
637
|
buildDevReloadJs()
|
|
451
638
|
);
|
|
452
639
|
await writeFileIfMissing(
|
|
453
|
-
path.join(projectRoot, 'public', 'assets', '
|
|
454
|
-
|
|
640
|
+
path.join(projectRoot, 'public', 'assets', 'my', 'my-home.js'),
|
|
641
|
+
buildMyHome()
|
|
642
|
+
);
|
|
643
|
+
await writeFileIfMissing(
|
|
644
|
+
path.join(projectRoot, 'public', 'assets', 'my', 'my-theme.js'),
|
|
645
|
+
buildMyTheme()
|
|
455
646
|
);
|
|
456
647
|
|
|
457
648
|
const esbuildDevPath = path.join(projectRoot, 'esbuild-dev.js');
|