@pure-ds/core 0.4.11 → 0.4.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.
package/.cursorrules ADDED
@@ -0,0 +1,168 @@
1
+ # PDS (Pure Design System) - Copilot Instructions
2
+
3
+ > **CRITICAL**: This workspace uses **Pure Design System (PDS)**. All code generation MUST follow PDS patterns. Never use generic web patterns, inline styles, or hardcoded values.
4
+
5
+ ## Philosophy
6
+
7
+ PDS follows the [Pure Web Manifesto](https://pureweb.dev/manifesto): "The browser is the framework."
8
+
9
+ 1. **Standards-first**: Web Platform APIs only (no framework dependencies)
10
+ 2. **Configuration-driven**: `pds.config.js` generates everything
11
+ 3. **Progressive Enhancement**: Semantic HTML first, enhance where needed
12
+ 4. **Components as Last Resort**: Web Components only when native HTML cannot achieve it
13
+
14
+ ### The Three Layers
15
+
16
+ **Layer 1 — Styles**: From minimal config, PDS generates complete CSS: tokens, scales, semantics, surfaces, states. Zero specificity via `:where()`.
17
+
18
+ **Layer 2 — Enhancements**: Behavior added to semantic HTML via selector-based upgrades (`data-dropdown`, `data-toggle`, etc.).
19
+
20
+ **Layer 3 — Web Components**: `<pds-tabstrip>`, `<pds-drawer>`, etc. only when native HTML has no equivalent.
21
+
22
+ ---
23
+
24
+ ## 🔍 Single Sources of Truth (ALWAYS CONSULT THESE FIRST)
25
+
26
+ **Before generating code, read the relevant SSoT file to get accurate class names, tokens, and APIs.**
27
+
28
+ | Need | SSoT File | What It Contains |
29
+ |------|-----------|------------------|
30
+ | **CSS Tokens** | `public/assets/pds/pds.css-data.json` | All `--color-*`, `--spacing-*`, `--radius-*`, `--shadow-*`, `--font-*` |
31
+ | **Web Components** | `custom-elements.json` | Complete component APIs, attributes, methods, events, slots |
32
+ | **HTML Tags** | `public/assets/pds/vscode-custom-data.json` | Component HTML structure, attribute values |
33
+ | **Primitives & Utilities** | `src/js/pds-core/pds-ontology.js` | `.card`, `.badge`, `.btn-*`, `.flex`, `.gap-*`, `.surface-*` |
34
+ | **Enhancements** | `src/js/pds-core/pds-enhancer-metadata.js` | Selectors + `demoHtml` examples for each enhancement |
35
+ | **Generator Logic** | `src/js/pds-core/pds-generator.js` | How CSS is generated, token naming conventions |
36
+ | **Config** | `pds.config.js` | What's enabled in this workspace |
37
+
38
+ **For consuming projects** using `@pure-ds/core`, files are in `node_modules/@pure-ds/core/`:
39
+ - `custom-elements.json`
40
+ - `public/assets/pds/pds.css-data.json`
41
+ - `public/assets/pds/vscode-custom-data.json`
42
+ - `src/js/pds-core/pds-ontology.js`
43
+
44
+ ---
45
+
46
+ ## 🚫 Critical Anti-Patterns (NEVER DO THIS)
47
+
48
+ ```html
49
+ <!-- ❌ NEVER: Inline styles -->
50
+ <div style="display: flex; gap: 16px; padding: 20px;">
51
+
52
+ <!-- ❌ NEVER: Hardcoded colors -->
53
+ <button style="background: #007acc; color: white;">
54
+
55
+ <!-- ❌ NEVER: Non-semantic HTML -->
56
+ <div class="button" onclick="handleClick()">Click me</div>
57
+
58
+ <!-- ❌ NEVER: Custom CSS when primitives exist -->
59
+ <style>.my-card { border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }</style>
60
+ ```
61
+
62
+ ```javascript
63
+ // ❌ NEVER: Browser dialogs - Use PDS.ask() and PDS.toast()
64
+ alert("message"); // → PDS.toast("message", { type: "info" })
65
+ confirm("sure?"); // → await PDS.ask("sure?", { type: "confirm" })
66
+ prompt("name?"); // → await PDS.ask("name?", { type: "prompt" })
67
+
68
+ // ❌ NEVER: Manual dropdown/modal/tab implementations
69
+ // → Use <nav data-dropdown>, PDS.ask(), <pds-tabstrip>
70
+ ```
71
+
72
+ ---
73
+
74
+ ## ✅ Quick Reference Patterns
75
+
76
+ ```html
77
+ <!-- Buttons: semantic HTML + PDS classes (see pds-ontology.js → primitives) -->
78
+ <button class="btn-primary">Save</button>
79
+ <button class="btn-secondary">Cancel</button>
80
+ <button class="btn-outline">Details</button>
81
+ <button class="btn-primary icon-only" aria-label="Settings">
82
+ <pds-icon icon="gear"></pds-icon>
83
+ </button>
84
+
85
+ <!-- Layout: utility classes (see pds-ontology.js → layoutPatterns, utilities) -->
86
+ <div class="flex gap-md items-center">
87
+ <div class="grid grid-cols-3 gap-lg">
88
+ <div class="stack-md">
89
+
90
+ <!-- Cards & Surfaces: primitives -->
91
+ <article class="card surface-elevated">
92
+ <header class="flex justify-between items-center">
93
+ <h3>Title</h3>
94
+ </header>
95
+ <p class="text-muted">Content</p>
96
+ </article>
97
+
98
+ <!-- Icons: web component (see custom-elements.json) -->
99
+ <pds-icon icon="heart" size="sm"></pds-icon>
100
+ <pds-icon icon="check" size="lg" color="var(--color-success-500)"></pds-icon>
101
+
102
+ <!-- Enhancements: data attributes (see pds-enhancer-metadata.js) -->
103
+ <nav data-dropdown>
104
+ <button>Menu</button>
105
+ <menu><li><a href="#">Item</a></li></menu>
106
+ </nav>
107
+
108
+ <label data-toggle>
109
+ <input type="checkbox">
110
+ <span data-label>Enable feature</span>
111
+ </label>
112
+
113
+ <form data-required>
114
+ <label><span>Email</span><input type="email" required></label>
115
+ </form>
116
+
117
+ <!-- Tabs: web component -->
118
+ <pds-tabstrip>
119
+ <button slot="tab">Tab 1</button>
120
+ <div slot="panel">Content 1</div>
121
+ <button slot="tab">Tab 2</button>
122
+ <div slot="panel">Content 2</div>
123
+ </pds-tabstrip>
124
+ ```
125
+
126
+ ```javascript
127
+ // Dialogs & Toasts: PDS API
128
+ const confirmed = await PDS.ask("Delete this item?", {
129
+ type: "confirm",
130
+ buttons: { ok: { name: "Delete", variant: "danger" } }
131
+ });
132
+
133
+ PDS.toast("Saved successfully!", { type: "success" });
134
+
135
+ // Theme management
136
+ PDS.theme = 'dark'; // 'light' | 'dark' | 'system'
137
+
138
+ // Query the design system
139
+ const results = await PDS.query("border gradient classes");
140
+ ```
141
+
142
+ ---
143
+
144
+ ## How to Look Things Up
145
+
146
+ | Question | Action |
147
+ |----------|--------|
148
+ | "What CSS tokens exist?" | Read `pds.css-data.json` |
149
+ | "What components are available?" | Read `custom-elements.json` |
150
+ | "What utility classes exist?" | Read `pds-ontology.js` → `layoutPatterns`, `utilities` |
151
+ | "What primitives exist?" | Read `pds-ontology.js` → `primitives` |
152
+ | "How do I enhance HTML?" | Read `pds-enhancer-metadata.js` → `demoHtml` |
153
+ | "How are tokens named?" | Read `pds-generator.js` or `pds.css-data.json` |
154
+
155
+ ---
156
+
157
+ ## Summary Checklist
158
+
159
+ Before generating code:
160
+
161
+ 1. ✅ **Consult SSoT files** — Don't guess class names or token names
162
+ 2. ✅ **No inline styles** — Use CSS tokens via custom properties
163
+ 3. ✅ **No hardcoded values** — Colors, spacing, radii all have tokens
164
+ 4. ✅ **No alert/confirm/prompt** — Use `PDS.ask()` and `PDS.toast()`
165
+ 5. ✅ **Use semantic HTML** — `<button>`, `<nav>`, `<article>`, `<label>`, `<details>`
166
+ 6. ✅ **Apply enhancements via data-* attributes** — See `pds-enhancer-metadata.js`
167
+ 7. ✅ **Components as last resort** — Only when native HTML can't achieve it
168
+ 8. ✅ **Prefer primitives** — `.card`, `.badge`, `.alert` over custom components
@@ -0,0 +1,168 @@
1
+ # PDS (Pure Design System) - Copilot Instructions
2
+
3
+ > **CRITICAL**: This workspace uses **Pure Design System (PDS)**. All code generation MUST follow PDS and vanilla Web Platform patterns. Never use 3rd party framework patterns, non-PDS utility classes, inline styles, or hardcoded CSS values.
4
+
5
+ ## Philosophy
6
+
7
+ PDS follows the [Pure Web Manifesto](https://pureweb.dev/manifesto): "The browser is the framework."
8
+
9
+ 1. **Standards-first**: Web Platform APIs only (no framework dependencies)
10
+ 2. **Configuration-driven**: `pds.config.js` generates everything
11
+ 3. **Progressive Enhancement**: Semantic HTML first, enhance where needed
12
+ 4. **Components as Last Resort**: Web Components only when native HTML cannot achieve it
13
+
14
+ ### The Three Layers
15
+
16
+ **Layer 1 — Styles**: From minimal config, PDS generates complete CSS: tokens, scales, semantics, surfaces, states. Zero specificity via `:where()`.
17
+
18
+ **Layer 2 — Enhancements**: Behavior added to semantic HTML via selector-based upgrades (`data-dropdown`, `data-toggle`, etc.).
19
+
20
+ **Layer 3 — Web Components**: `<pds-tabstrip>`, `<pds-drawer>`, etc. only when native HTML has no equivalent.
21
+
22
+ ---
23
+
24
+ ## 🔍 Single Sources of Truth (ALWAYS CONSULT THESE FIRST)
25
+
26
+ **Before generating code, read the relevant SSoT file to get accurate class names, tokens, and APIs.**
27
+
28
+ | Need | SSoT File | What It Contains |
29
+ |------|-----------|------------------|
30
+ | **CSS Tokens** | `public/assets/pds/pds.css-data.json` | All `--color-*`, `--spacing-*`, `--radius-*`, `--shadow-*`, `--font-*` |
31
+ | **Web Components** | `custom-elements.json` | Complete component APIs, attributes, methods, events, slots |
32
+ | **HTML Tags** | `public/assets/pds/vscode-custom-data.json` | Component HTML structure, attribute values |
33
+ | **Primitives & Utilities** | `src/js/pds-core/pds-ontology.js` | `.card`, `.badge`, `.btn-*`, `.flex`, `.gap-*`, `.surface-*` |
34
+ | **Enhancements** | `src/js/pds-core/pds-enhancer-metadata.js` | Selectors + `demoHtml` examples for each enhancement |
35
+ | **Generator Logic** | `src/js/pds-core/pds-generator.js` | How CSS is generated, token naming conventions |
36
+ | **Config** | `pds.config.js` | What's enabled in this workspace |
37
+
38
+ **For consuming projects** using `@pure-ds/core`, files are in `node_modules/@pure-ds/core/`:
39
+ - `custom-elements.json`
40
+ - `public/assets/pds/pds.css-data.json`
41
+ - `public/assets/pds/vscode-custom-data.json`
42
+ - `src/js/pds-core/pds-ontology.js`
43
+
44
+ ---
45
+
46
+ ## 🚫 Critical Anti-Patterns (NEVER DO THIS)
47
+
48
+ ```html
49
+ <!-- ❌ NEVER: Inline styles -->
50
+ <div style="display: flex; gap: 16px; padding: 20px;">
51
+
52
+ <!-- ❌ NEVER: Hardcoded colors -->
53
+ <button style="background: #007acc; color: white;">
54
+
55
+ <!-- ❌ NEVER: Non-semantic HTML -->
56
+ <div class="button" onclick="handleClick()">Click me</div>
57
+
58
+ <!-- ❌ NEVER: Custom CSS when primitives exist -->
59
+ <style>.my-card { border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }</style>
60
+ ```
61
+
62
+ ```javascript
63
+ // ❌ NEVER: Browser dialogs - Use PDS.ask() and PDS.toast()
64
+ alert("message"); // → PDS.toast("message", { type: "info" })
65
+ confirm("sure?"); // → await PDS.ask("sure?", { type: "confirm" })
66
+ prompt("name?"); // → await PDS.ask("name?", { type: "prompt" })
67
+
68
+ // ❌ NEVER: Manual dropdown/modal/tab implementations
69
+ // → Use <nav data-dropdown>, PDS.ask(), <pds-tabstrip>
70
+ ```
71
+
72
+ ---
73
+
74
+ ## ✅ Quick Reference Patterns
75
+
76
+ ```html
77
+ <!-- Buttons: semantic HTML + PDS classes (see pds-ontology.js → primitives) -->
78
+ <button class="btn-primary">Save</button>
79
+ <button class="btn-secondary">Cancel</button>
80
+ <button class="btn-outline">Details</button>
81
+ <button class="btn-primary icon-only" aria-label="Settings">
82
+ <pds-icon icon="gear"></pds-icon>
83
+ </button>
84
+
85
+ <!-- Layout: utility classes (see pds-ontology.js → layoutPatterns, utilities) -->
86
+ <div class="flex gap-md items-center">
87
+ <div class="grid grid-cols-3 gap-lg">
88
+ <div class="stack-md">
89
+
90
+ <!-- Cards & Surfaces: primitives -->
91
+ <article class="card surface-elevated">
92
+ <header class="flex justify-between items-center">
93
+ <h3>Title</h3>
94
+ </header>
95
+ <p class="text-muted">Content</p>
96
+ </article>
97
+
98
+ <!-- Icons: web component (see custom-elements.json) -->
99
+ <pds-icon icon="heart" size="sm"></pds-icon>
100
+ <pds-icon icon="check" size="lg" color="var(--color-success-500)"></pds-icon>
101
+
102
+ <!-- Enhancements: data attributes (see pds-enhancer-metadata.js) -->
103
+ <nav data-dropdown>
104
+ <button>Menu</button>
105
+ <menu><li><a href="#">Item</a></li></menu>
106
+ </nav>
107
+
108
+ <label data-toggle>
109
+ <input type="checkbox">
110
+ <span data-label>Enable feature</span>
111
+ </label>
112
+
113
+ <form data-required>
114
+ <label><span>Email</span><input type="email" required></label>
115
+ </form>
116
+
117
+ <!-- Tabs: web component -->
118
+ <pds-tabstrip>
119
+ <button slot="tab">Tab 1</button>
120
+ <div slot="panel">Content 1</div>
121
+ <button slot="tab">Tab 2</button>
122
+ <div slot="panel">Content 2</div>
123
+ </pds-tabstrip>
124
+ ```
125
+
126
+ ```javascript
127
+ // Dialogs & Toasts: PDS API
128
+ const confirmed = await PDS.ask("Delete this item?", {
129
+ type: "confirm",
130
+ buttons: { ok: { name: "Delete", variant: "danger" } }
131
+ });
132
+
133
+ PDS.toast("Saved successfully!", { type: "success" });
134
+
135
+ // Theme management
136
+ PDS.theme = 'dark'; // 'light' | 'dark' | 'system'
137
+
138
+ // Query the design system
139
+ const results = await PDS.query("border gradient classes");
140
+ ```
141
+
142
+ ---
143
+
144
+ ## How to Look Things Up
145
+
146
+ | Question | Action |
147
+ |----------|--------|
148
+ | "What CSS tokens exist?" | Read `pds.css-data.json` |
149
+ | "What components are available?" | Read `custom-elements.json` |
150
+ | "What utility classes exist?" | Read `pds-ontology.js` → `layoutPatterns`, `utilities` |
151
+ | "What primitives exist?" | Read `pds-ontology.js` → `primitives` |
152
+ | "How do I enhance HTML?" | Read `pds-enhancer-metadata.js` → `demoHtml` |
153
+ | "How are tokens named?" | Read `pds-generator.js` or `pds.css-data.json` |
154
+
155
+ ---
156
+
157
+ ## Summary Checklist
158
+
159
+ Before generating code:
160
+
161
+ 1. ✅ **Consult SSoT files** — Don't guess class names or token names
162
+ 2. ✅ **No inline styles** — Use CSS tokens via custom properties
163
+ 3. ✅ **No hardcoded values** — Colors, spacing, radii all have tokens
164
+ 4. ✅ **No alert/confirm/prompt** — Use `PDS.ask()` and `PDS.toast()`
165
+ 5. ✅ **Use semantic HTML** — `<button>`, `<nav>`, `<article>`, `<label>`, `<details>`
166
+ 6. ✅ **Apply enhancements via data-* attributes** — See `pds-enhancer-metadata.js`
167
+ 7. ✅ **Components as last resort** — Only when native HTML can't achieve it
168
+ 8. ✅ **Prefer primitives** — `.card`, `.badge`, `.alert` over custom components