@pure-ds/core 0.7.19 → 0.7.21

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.
Files changed (33) hide show
  1. package/.cursorrules +10 -0
  2. package/.github/copilot-instructions.md +10 -0
  3. package/custom-elements.json +232 -25
  4. package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
  5. package/dist/types/public/assets/pds/components/pds-code.d.ts +19 -0
  6. package/dist/types/public/assets/pds/components/pds-code.d.ts.map +1 -0
  7. package/dist/types/public/assets/pds/components/pds-icon.d.ts +31 -1
  8. package/dist/types/public/assets/pds/components/pds-icon.d.ts.map +1 -1
  9. package/dist/types/public/assets/pds/components/pds-treeview.d.ts +271 -16
  10. package/dist/types/public/assets/pds/components/pds-treeview.d.ts.map +1 -1
  11. package/dist/types/src/js/components/pds-code.d.ts +19 -0
  12. package/dist/types/src/js/components/pds-code.d.ts.map +1 -0
  13. package/dist/types/src/js/external/shiki.d.ts +3 -0
  14. package/dist/types/src/js/external/shiki.d.ts.map +1 -0
  15. package/dist/types/src/js/pds-core/pds-generator.d.ts.map +1 -1
  16. package/package.json +1 -1
  17. package/packages/pds-cli/bin/templates/bootstrap/public/assets/my/my-home.js +1 -1
  18. package/public/assets/js/app.js +1 -1
  19. package/public/assets/js/pds-manager.js +138 -148
  20. package/public/assets/pds/components/pds-calendar.js +504 -16
  21. package/public/assets/pds/components/pds-code.js +203 -0
  22. package/public/assets/pds/components/pds-icon.js +102 -27
  23. package/public/assets/pds/components/pds-live-importer.js +2 -2
  24. package/public/assets/pds/components/pds-scrollrow.js +27 -2
  25. package/public/assets/pds/components/pds-treeview.js +185 -0
  26. package/public/assets/pds/core/pds-manager.js +138 -148
  27. package/public/assets/pds/custom-elements.json +263 -18
  28. package/public/assets/pds/external/shiki.js +32 -0
  29. package/public/assets/pds/pds-css-complete.json +1 -1
  30. package/public/assets/pds/templates/feedback-ops-dashboard.html +1 -1
  31. package/public/assets/pds/templates/release-readiness-radar.html +2 -2
  32. package/public/assets/pds/templates/support-command-center.html +1 -1
  33. package/src/js/pds-core/pds-generator.js +142 -152
@@ -31,6 +31,36 @@ import { PDS } from "#pds";
31
31
  const LAYERS = ["tokens", "primitives", "components", "utilities"];
32
32
  const ROOT_SELECTOR = ".tv-tree";
33
33
 
34
+ /**
35
+ * @typedef {object} PdsTreeviewNode
36
+ * @property {string} id
37
+ * @property {string} text
38
+ * @property {string} value
39
+ * @property {string|null} [link]
40
+ * @property {string|null} [icon]
41
+ * @property {string|null} [image]
42
+ * @property {object} [data]
43
+ * @property {boolean} hasChildren
44
+ * @property {boolean} childrenLoaded
45
+ * @property {boolean} loadingChildren
46
+ * @property {PdsTreeviewNode[]} children
47
+ */
48
+
49
+ /**
50
+ * @typedef {object} PdsTreeviewOptions
51
+ * @property {PdsTreeviewNode[]|object|Function|string} [source] Root data source.
52
+ * @property {PdsTreeviewNode[]|object} [items] Alias for `source`.
53
+ * @property {PdsTreeviewNode[]|object} [data] Alias for `source`.
54
+ * @property {(context: { host: PdsTreeview, options: PdsTreeviewOptions, settings: PdsTreeviewOptions }) => Promise<any>|any} [getItems] Async/sync root loader.
55
+ * @property {(context: { host: PdsTreeview, node: PdsTreeviewNode, nodeId: string, options: PdsTreeviewOptions, settings: PdsTreeviewOptions }) => Promise<any>|any} [getChildren] Lazy child loader called on first expand.
56
+ * @property {(source: any, context: { host: PdsTreeview, options: PdsTreeviewOptions, settings: PdsTreeviewOptions }) => Promise<any>|any} [transform] Root response transformer.
57
+ * @property {(source: any, context: { host: PdsTreeview, node: PdsTreeviewNode, nodeId: string, options: PdsTreeviewOptions, settings: PdsTreeviewOptions }) => Promise<any>|any} [transformChildren] Child response transformer.
58
+ * @property {RequestInit} [fetch] Fetch options used for URL-based sources.
59
+ * @property {boolean} [expandedAll] Expands all branches by default.
60
+ * @property {string[]} [defaultExpanded] Node ids expanded on initial render.
61
+ * @property {(node: PdsTreeviewNode, host: PdsTreeview) => void} [onSelect] Selection callback invoked for user-driven selection.
62
+ */
63
+
34
64
  export class PdsTreeview extends HTMLElement {
35
65
  static formAssociated = true;
36
66
 
@@ -136,46 +166,86 @@ export class PdsTreeview extends HTMLElement {
136
166
  this.selectByValue(this.value);
137
167
  }
138
168
 
169
+ /**
170
+ * Current runtime settings for data loading and behavior.
171
+ *
172
+ * @type {PdsTreeviewOptions}
173
+ */
139
174
  get settings() {
140
175
  return this.#settings;
141
176
  }
142
177
 
178
+ /**
179
+ * @param {PdsTreeviewOptions|null|undefined} value
180
+ */
143
181
  set settings(value) {
144
182
  this.#settings = value && typeof value === "object" ? value : {};
145
183
  void this.refresh();
146
184
  }
147
185
 
186
+ /**
187
+ * Alias for `settings`.
188
+ *
189
+ * @type {PdsTreeviewOptions}
190
+ */
148
191
  get options() {
149
192
  return this.settings;
150
193
  }
151
194
 
195
+ /**
196
+ * @param {PdsTreeviewOptions|null|undefined} value
197
+ */
152
198
  set options(value) {
153
199
  this.settings = value;
154
200
  }
155
201
 
202
+ /**
203
+ * Form field name used when participating in form submission.
204
+ *
205
+ * @type {string}
206
+ */
156
207
  get name() {
157
208
  return this.getAttribute("name") || "";
158
209
  }
159
210
 
211
+ /**
212
+ * @param {string|null|undefined} value
213
+ */
160
214
  set name(value) {
161
215
  if (value == null || value === "") this.removeAttribute("name");
162
216
  else this.setAttribute("name", value);
163
217
  }
164
218
 
219
+ /**
220
+ * Selected value for single-select mode.
221
+ *
222
+ * @type {string}
223
+ */
165
224
  get value() {
166
225
  return this.getAttribute("value") || "";
167
226
  }
168
227
 
228
+ /**
229
+ * @param {string|null|undefined} value
230
+ */
169
231
  set value(value) {
170
232
  const next = value == null ? "" : String(value);
171
233
  if (next === "") this.removeAttribute("value");
172
234
  else this.setAttribute("value", next);
173
235
  }
174
236
 
237
+ /**
238
+ * Selected values in multiselect mode.
239
+ *
240
+ * @type {string[]}
241
+ */
175
242
  get values() {
176
243
  return this.selectedNodes.map((node) => String(node.value));
177
244
  }
178
245
 
246
+ /**
247
+ * @param {Array<string|number>|null|undefined} values
248
+ */
179
249
  set values(values) {
180
250
  if (!Array.isArray(values)) {
181
251
  this.#selectedIds.clear();
@@ -187,46 +257,90 @@ export class PdsTreeview extends HTMLElement {
187
257
  this.selectByValues(values);
188
258
  }
189
259
 
260
+ /**
261
+ * Disables interactions when true.
262
+ *
263
+ * @type {boolean}
264
+ */
190
265
  get disabled() {
191
266
  return this.hasAttribute("disabled");
192
267
  }
193
268
 
269
+ /**
270
+ * @param {boolean} value
271
+ */
194
272
  set disabled(value) {
195
273
  if (value) this.setAttribute("disabled", "");
196
274
  else this.removeAttribute("disabled");
197
275
  }
198
276
 
277
+ /**
278
+ * Requires at least one selected node for form validity.
279
+ *
280
+ * @type {boolean}
281
+ */
199
282
  get required() {
200
283
  return this.hasAttribute("required");
201
284
  }
202
285
 
286
+ /**
287
+ * @param {boolean} value
288
+ */
203
289
  set required(value) {
204
290
  if (value) this.setAttribute("required", "");
205
291
  else this.removeAttribute("required");
206
292
  }
207
293
 
294
+ /**
295
+ * Read-only presentation mode; disables selection and form value syncing.
296
+ *
297
+ * @type {boolean}
298
+ */
208
299
  get displayOnly() {
209
300
  return this.hasAttribute("display-only");
210
301
  }
211
302
 
303
+ /**
304
+ * @param {boolean} value
305
+ */
212
306
  set displayOnly(value) {
213
307
  if (value) this.setAttribute("display-only", "");
214
308
  else this.removeAttribute("display-only");
215
309
  }
216
310
 
311
+ /**
312
+ * Expands all branch nodes after data load.
313
+ *
314
+ * @type {boolean}
315
+ */
217
316
  get expandedAll() {
218
317
  return this.hasAttribute("expanded-all");
219
318
  }
220
319
 
320
+ /**
321
+ * @param {boolean} value
322
+ */
221
323
  set expandedAll(value) {
222
324
  if (value) this.setAttribute("expanded-all", "");
223
325
  else this.removeAttribute("expanded-all");
224
326
  }
225
327
 
328
+ /**
329
+ * Selection mode.
330
+ *
331
+ * - `off`: single select
332
+ * - `checkboxes`: persistent multiselect with checkboxes
333
+ * - `auto`: touch/coarse pointer gets checkbox mode
334
+ *
335
+ * @type {"off"|"checkboxes"|"auto"}
336
+ */
226
337
  get multiselect() {
227
338
  return this.#normalizeMultiselect(this.getAttribute("multiselect"));
228
339
  }
229
340
 
341
+ /**
342
+ * @param {"off"|"checkboxes"|"auto"|string|null|undefined} value
343
+ */
230
344
  set multiselect(value) {
231
345
  const next = this.#normalizeMultiselect(value);
232
346
  if (next === "off") {
@@ -236,6 +350,11 @@ export class PdsTreeview extends HTMLElement {
236
350
  }
237
351
  }
238
352
 
353
+ /**
354
+ * First selected node (or active selected node in multiselect).
355
+ *
356
+ * @type {PdsTreeviewNode|null}
357
+ */
239
358
  get selectedNode() {
240
359
  const selectedId = this.#selectedId && this.#selectedIds.has(this.#selectedId)
241
360
  ? this.#selectedId
@@ -243,20 +362,40 @@ export class PdsTreeview extends HTMLElement {
243
362
  return selectedId ? this.#nodeById.get(selectedId) || null : null;
244
363
  }
245
364
 
365
+ /**
366
+ * All selected nodes.
367
+ *
368
+ * @type {PdsTreeviewNode[]}
369
+ */
246
370
  get selectedNodes() {
247
371
  return Array.from(this.#selectedIds)
248
372
  .map((id) => this.#nodeById.get(id))
249
373
  .filter(Boolean);
250
374
  }
251
375
 
376
+ /**
377
+ * Backward-compatible accessor for `selectedNode`.
378
+ *
379
+ * @returns {PdsTreeviewNode|null}
380
+ */
252
381
  getSelectedNode() {
253
382
  return this.selectedNode;
254
383
  }
255
384
 
385
+ /**
386
+ * Backward-compatible accessor for `selectedNodes`.
387
+ *
388
+ * @returns {PdsTreeviewNode[]}
389
+ */
256
390
  getSelectedNodes() {
257
391
  return this.selectedNodes;
258
392
  }
259
393
 
394
+ /**
395
+ * Reloads tree data from settings/source and re-renders the component.
396
+ *
397
+ * @returns {Promise<void>}
398
+ */
260
399
  async refresh() {
261
400
  const loadToken = ++this.#loadToken;
262
401
  const host = this.#root.querySelector(".tv-host");
@@ -298,6 +437,11 @@ export class PdsTreeview extends HTMLElement {
298
437
  }
299
438
  }
300
439
 
440
+ /**
441
+ * Expands every currently indexed branch node.
442
+ *
443
+ * @returns {void}
444
+ */
301
445
  expandAll() {
302
446
  for (const [id, node] of this.#nodeById.entries()) {
303
447
  if (node.children?.length) this.#expandedIds.add(id);
@@ -305,17 +449,34 @@ export class PdsTreeview extends HTMLElement {
305
449
  this.#renderTree();
306
450
  }
307
451
 
452
+ /**
453
+ * Collapses every expanded branch node.
454
+ *
455
+ * @returns {void}
456
+ */
308
457
  collapseAll() {
309
458
  this.#expandedIds.clear();
310
459
  this.#renderTree();
311
460
  }
312
461
 
462
+ /**
463
+ * Selects a node by node id.
464
+ *
465
+ * @param {string} id
466
+ * @returns {boolean} True when selection succeeds.
467
+ */
313
468
  selectById(id) {
314
469
  if (!id || !this.#nodeById.has(id)) return false;
315
470
  this.#selectNode(id, { user: false, focus: true, mode: "exclusive" });
316
471
  return true;
317
472
  }
318
473
 
474
+ /**
475
+ * Selects the first node whose `value` matches.
476
+ *
477
+ * @param {string|number|null|undefined} value
478
+ * @returns {boolean} True when a matching node is selected or selection is cleared.
479
+ */
319
480
  selectByValue(value) {
320
481
  const normalized = value == null ? "" : String(value);
321
482
  if (!normalized) {
@@ -335,6 +496,14 @@ export class PdsTreeview extends HTMLElement {
335
496
  return false;
336
497
  }
337
498
 
499
+ /**
500
+ * Selects multiple nodes by value.
501
+ *
502
+ * In single-select mode, only the first resolved value is selected.
503
+ *
504
+ * @param {Array<string|number>} values
505
+ * @returns {boolean} True when at least one matching value is resolved or selection is cleared.
506
+ */
338
507
  selectByValues(values) {
339
508
  if (!Array.isArray(values)) return false;
340
509
  const normalized = values
@@ -375,16 +544,32 @@ export class PdsTreeview extends HTMLElement {
375
544
  return this.selectById(selectedIds[0]);
376
545
  }
377
546
 
547
+ /**
548
+ * Runs form-associated validity checks.
549
+ *
550
+ * @returns {boolean}
551
+ */
378
552
  checkValidity() {
379
553
  this.#syncValidity();
380
554
  return this.#internals.checkValidity();
381
555
  }
382
556
 
557
+ /**
558
+ * Runs and reports form-associated validity checks.
559
+ *
560
+ * @returns {boolean}
561
+ */
383
562
  reportValidity() {
384
563
  this.#syncValidity();
385
564
  return this.#internals.reportValidity();
386
565
  }
387
566
 
567
+ /**
568
+ * Focuses the active/selected row, or first visible row as fallback.
569
+ *
570
+ * @param {FocusOptions} [options]
571
+ * @returns {void}
572
+ */
388
573
  focus(options) {
389
574
  const targetId =
390
575
  this.#focusedId || this.#selectedId || this.#selectedIds.values().next().value || this.#firstVisibleId();