contour-ds 1.1.2 → 1.5.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.
Files changed (71) hide show
  1. package/README.md +7 -1
  2. package/dist/agent-rules.json +5 -1
  3. package/dist/build-manifest.json +93 -92
  4. package/dist/contour-wc.esm.js +4113 -480
  5. package/dist/contour-wc.esm.min.js +1 -1
  6. package/dist/contour-wc.js +4115 -478
  7. package/dist/contour-wc.min.js +1 -1
  8. package/dist/contour.components.json +2597 -135
  9. package/dist/contour.css +625 -27
  10. package/dist/contour.d.ts +109 -61
  11. package/dist/contour.esm.js +16 -0
  12. package/dist/contour.js +16 -0
  13. package/dist/contour.min.css +1 -1
  14. package/dist/contour.tokens.json +37 -0
  15. package/dist/docs/actions.md +6 -2
  16. package/dist/docs/affordances.md +19 -3
  17. package/dist/docs/colour.md +2 -2
  18. package/dist/docs/componentindex.md +39 -0
  19. package/dist/docs/data.md +38 -3
  20. package/dist/docs/docs.md +6 -2
  21. package/dist/docs/feedback.md +13 -3
  22. package/dist/docs/field.md +7 -2
  23. package/dist/docs/forms.md +35 -3
  24. package/dist/docs/index.json +32 -76
  25. package/dist/docs/install.md +4 -2
  26. package/dist/docs/landing.md +3 -2
  27. package/dist/docs/mapengine.md +9 -3
  28. package/dist/docs/motion.md +5 -2
  29. package/dist/docs/navigation.md +10 -3
  30. package/dist/docs/overlays.md +26 -3
  31. package/dist/docs/overview.md +2 -2
  32. package/dist/docs/patterns.md +38 -3
  33. package/dist/docs/playground.md +5 -2
  34. package/dist/docs/principles.md +2 -2
  35. package/dist/docs/recipes.md +7 -3
  36. package/dist/docs/space.md +2 -2
  37. package/dist/docs/status.md +19 -3
  38. package/dist/docs/surfaces.md +7 -3
  39. package/dist/docs/theming.md +5 -2
  40. package/dist/docs/type.md +2 -2
  41. package/dist/docs/webcomponents.md +26 -3
  42. package/dist/map-chrome.mapbox.css +4 -4
  43. package/dist/map-chrome.maplibre.css +4 -4
  44. package/dist/registry/items/contour-core.json +2 -2
  45. package/dist/registry/items/contour-data.json +2 -2
  46. package/dist/registry/items/contour-docs.json +2 -2
  47. package/dist/registry/items/contour-landing.json +2 -2
  48. package/dist/registry/registry.json +8 -8
  49. package/dist/surfaces/contour-core.min.css +1 -1
  50. package/dist/surfaces/contour-data.min.css +1 -1
  51. package/dist/surfaces/contour-docs.min.css +1 -1
  52. package/dist/surfaces/contour-landing.min.css +1 -1
  53. package/dist/wc/behaviours.mjs +69 -11
  54. package/dist/wc/content.mjs +163 -8
  55. package/dist/wc/core.mjs +145 -34
  56. package/dist/wc/dashboard.mjs +69 -4
  57. package/dist/wc/data.mjs +866 -115
  58. package/dist/wc/docs.mjs +1 -0
  59. package/dist/wc/feedback.mjs +75 -13
  60. package/dist/wc/forms.mjs +371 -34
  61. package/dist/wc/index.mjs +7 -3
  62. package/dist/wc/interaction.mjs +11 -6
  63. package/dist/wc/map.mjs +121 -38
  64. package/dist/wc/misc.mjs +29 -1
  65. package/dist/wc/navigation.mjs +424 -75
  66. package/dist/wc/registration.mjs +8 -4
  67. package/dist/wc/shadow.mjs +29 -12
  68. package/dist/wc/states.mjs +15 -0
  69. package/dist/wc/svg.mjs +10 -0
  70. package/dist/wc/ui.mjs +1710 -126
  71. package/package.json +39 -6
package/dist/wc/forms.mjs CHANGED
@@ -1,10 +1,31 @@
1
+ /**
2
+ * Form controls: field, field-group, form, combobox, select, check, radio,
3
+ * switch, textarea, input, input-group, range, radio-list, version.
4
+ *
5
+ * All form controls are `ContourBase` subclasses. They render light-DOM markup
6
+ * from observed attributes, reflect properties back to attributes, take part in
7
+ * form association (`formAssociated`, `_internals.setFormValue`) where the
8
+ * platform allows it, and emit `contour:input` / `contour:change` / `contour:submit`
9
+ * events. Inline validation (blur-driven `aria-invalid`) is handled by
10
+ * `ContourField`; `ContourForm` owns submission state and a live-region summary.
11
+ * @module contour-wc/forms
12
+ */
13
+
1
14
  import { ContourBase, define, contourId } from './core.mjs';
2
15
  import { wireCombobox } from './behaviours.mjs';
3
16
  import { loadRemote, remoteData, renderStates, renderEmpty, wireStates } from './states.mjs';
17
+ /**
18
+ * Combobox: a filterable, keyboard-navigable listbox backed by a JSON `options`
19
+ * attribute or authored `<li>` options. Supports single and multi-select
20
+ * (`multiple`), fixed-row virtualization (`virtual`), async/remote options
21
+ * (`src`, `loading`, `error`, `retry`, `empty`, `skeleton`), a clear button and
22
+ * form association. Emits `contour:select` on commit and `contour:input` on
23
+ * filter. ArrowUp/Down/Home/End rove the cursor; Enter commits; Escape closes.
24
+ */
4
25
  class ContourCombobox extends ContourBase {
5
- static get observed() { return ["options", "placeholder", "label", "value", "multiple", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "empty", "skeleton"]; }
26
+ static get observed() { return ["options", "placeholder", "label", "value", "multiple", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "empty", "skeleton", "virtual"]; }
6
27
  static get formAssociated() { return true; }
7
- static get properties() { return { options: { attribute: "options" }, placeholder: { attribute: "placeholder" }, label: { attribute: "label" }, value: { attribute: "value" }, multiple: { attribute: "multiple", type: Boolean }, src: { attribute: "src" } }; }
28
+ static get properties() { return { options: { attribute: "options" }, placeholder: { attribute: "placeholder" }, label: { attribute: "label" }, value: { attribute: "value" }, multiple: { attribute: "multiple", type: Boolean }, virtual: { attribute: "virtual", type: Boolean }, src: { attribute: "src" } }; }
8
29
  render() {
9
30
  this.classList.add("c-combobox");
10
31
  wireStates(this);
@@ -25,15 +46,19 @@ class ContourCombobox extends ContourBase {
25
46
  const list = this.ensure(".c-combobox__list", () => { const el = document.createElement("ul"); el.className = "c-combobox__list"; el.setAttribute("hidden", ""); return el; });
26
47
  list.innerHTML = "";
27
48
  list.setAttribute("hidden", "");
28
- const selectedVals = (this.getAttribute("value") || "").split(",").map((v) => v.trim()).filter(Boolean);
29
- parsed.forEach((opt) => {
30
- const li = document.createElement("li");
31
- li.className = "c-combobox__option";
32
- const v = typeof opt === "string" ? opt : opt.value;
33
- li.textContent = typeof opt === "string" ? opt : opt.label;
34
- if (this.hasAttribute("multiple") && selectedVals.includes(String(v))) li.setAttribute("aria-selected", "true");
35
- list.appendChild(li);
36
- });
49
+ this._comboboxOptions = parsed;
50
+ this._comboboxVirtual = this.hasAttribute("virtual") && parsed.length > 100;
51
+ if (this._comboboxVirtual) {
52
+ list.classList.add("c-combobox__list--virtual");
53
+ list.style.maxBlockSize = "20rem";
54
+ list.style.overflow = "auto";
55
+ this._renderComboboxWindow("", true);
56
+ } else {
57
+ list.classList.remove("c-combobox__list--virtual");
58
+ list.style.maxBlockSize = "";
59
+ list.style.overflow = "";
60
+ this._renderComboboxWindow("", true);
61
+ }
37
62
  } catch (e) { /* keep existing */ }
38
63
  } else if (!authored.length && !options) {
39
64
  renderEmpty(this, "combobox");
@@ -52,6 +77,75 @@ class ContourCombobox extends ContourBase {
52
77
  const btn = this.querySelector(".c-combobox__clear");
53
78
  if (btn) btn.remove();
54
79
  }
80
+ }
81
+ _renderComboboxWindow(query = "", reset = false) {
82
+ const list = this.querySelector(".c-combobox__list");
83
+ const options = this._comboboxOptions || [];
84
+ if (!list) return;
85
+ const q = String(query || "").toLowerCase();
86
+ const filtered = options.map((opt, index) => ({
87
+ opt,
88
+ index,
89
+ label: typeof opt === "string" ? opt : opt.label,
90
+ value: typeof opt === "string" ? opt : opt.value,
91
+ })).filter((item) => !q || String(item.label).toLowerCase().includes(q));
92
+ this._comboboxFiltered = filtered;
93
+ const rowHeight = 32;
94
+ const windowSize = 20;
95
+ const overscan = 6;
96
+ const oldScrollTop = list.scrollTop;
97
+ const start = this._comboboxVirtual && !reset
98
+ ? Math.min(Math.max(0, filtered.length - windowSize), Math.max(0, Math.floor(oldScrollTop / rowHeight) - overscan))
99
+ : 0;
100
+ this._comboboxWindowStart = start;
101
+ const end = this._comboboxVirtual ? Math.min(filtered.length, start + windowSize + overscan * 2) : filtered.length;
102
+ const selectedVals = (this.getAttribute("value") || "").split(",").map((v) => v.trim()).filter(Boolean);
103
+ list.innerHTML = "";
104
+ const addSpacer = (height) => {
105
+ const spacer = document.createElement("li");
106
+ spacer.setAttribute("aria-hidden", "true");
107
+ spacer.style.blockSize = `${height}px`;
108
+ list.appendChild(spacer);
109
+ };
110
+ if (this._comboboxVirtual) addSpacer(start * rowHeight);
111
+ if (!filtered.length) {
112
+ const empty = document.createElement("li");
113
+ empty.className = "c-combobox__empty";
114
+ empty.setAttribute("role", "status");
115
+ empty.textContent = this.getAttribute("empty") || "No matches";
116
+ list.appendChild(empty);
117
+ }
118
+ if (this.hasAttribute("multiple")) list.setAttribute("aria-multiselectable", "true");
119
+ else list.removeAttribute("aria-multiselectable");
120
+ filtered.slice(start, end).forEach((item) => {
121
+ const li = document.createElement("li");
122
+ li.className = "c-combobox__option";
123
+ li.dataset.optionIndex = String(item.index);
124
+ li.setAttribute("role", "option");
125
+ const label = String(item.label);
126
+ const q = String(query || "").toLowerCase();
127
+ if (q && label.toLowerCase().includes(q)) {
128
+ const idx = label.toLowerCase().indexOf(q);
129
+ const before = label.slice(0, idx);
130
+ const match = label.slice(idx, idx + q.length);
131
+ const after = label.slice(idx + q.length);
132
+ li.innerHTML = "";
133
+ if (before) li.appendChild(document.createTextNode(before));
134
+ const mark = document.createElement("mark");
135
+ mark.className = "c-combobox__match";
136
+ mark.textContent = match;
137
+ li.appendChild(mark);
138
+ if (after) li.appendChild(document.createTextNode(after));
139
+ } else {
140
+ li.textContent = label;
141
+ }
142
+ const isSelected = this.hasAttribute("multiple") && selectedVals.includes(String(item.value));
143
+ li.setAttribute("aria-selected", String(isSelected));
144
+ if (isSelected) li.classList.add("c-combobox__option--selected");
145
+ list.appendChild(li);
146
+ });
147
+ if (this._comboboxVirtual) addSpacer(Math.max(0, filtered.length - end) * rowHeight);
148
+ if (this._comboboxVirtual && !reset) list.scrollTop = oldScrollTop;
55
149
  }
56
150
  enhance() {
57
151
  wireCombobox(this);
@@ -82,6 +176,13 @@ class ContourCombobox extends ContourBase {
82
176
  }
83
177
  }
84
178
  define("contour-combobox", ContourCombobox);
179
+ /**
180
+ * Field: a labelled form control wrapper. Renders an `<input>`/`<textarea>`/
181
+ * `<select>` (or adopts an authored one), associates a label via `for`/`id`,
182
+ * and attaches hint and error text with `aria-describedby`. Drives inline
183
+ * validation on blur (`aria-invalid`, `is-invalid`) and keeps the form value in
184
+ * sync via `_internals.setFormValue`. Emits `contour:input` / `contour:change`.
185
+ */
85
186
  class ContourField extends ContourBase {
86
187
  static get observed() { return ["label", "hint", "error", "placeholder", "type", "required"]; }
87
188
  static get formAssociated() { return true; }
@@ -109,7 +210,7 @@ class ContourField extends ContourBase {
109
210
  if (!input.id) input.id = contourId("contour-field");
110
211
  // Associate the label with the input so the control is labelled.
111
212
  const lbl = this.querySelector(".c-field__label");
112
- if (lbl) { if (!input.id) input.id = contourId("contour-field"); lbl.setAttribute("for", input.id); }
213
+ if (lbl) { if (!input.id) input.id = contourId("contour-field"); lbl.setAttribute("for", input.id); input.setAttribute("aria-label", lbl.textContent); }
113
214
  if (hint) {
114
215
  const h = this.ensure(".c-field__hint", () => { const el = document.createElement("span"); el.className = "c-field__hint"; return el; });
115
216
  h.textContent = hint;
@@ -190,10 +291,117 @@ class ContourField extends ContourBase {
190
291
  sync();
191
292
  };
192
293
  define("contour-field", ContourField);
193
- class ContourRange extends ContourBase {
194
- static get observed() { return ["min", "max", "value", "low", "high", "range", "sparkline", "label"]; }
294
+
295
+ /**
296
+ * Field-group: a grouped field with a shared label, optional hint and error
297
+ * text. Sets `role="group"` and `aria-required` when required; toggles
298
+ * `is-error` when an error is present. Child fields are labelled by the group.
299
+ */
300
+ class ContourFieldGroup extends ContourBase {
301
+ static get observed() { return ["label", "hint", "error", "required"]; }
302
+ static get properties() { return { label: { attribute: "label" }, hint: { attribute: "hint" }, error: { attribute: "error" }, required: { attribute: "required", type: Boolean } }; }
303
+ render() {
304
+ this.classList.add("c-field-group");
305
+ this.setAttribute("role", "group");
306
+ const label = this.getAttribute("label");
307
+ if (label) {
308
+ const lbl = this.ensure(".c-field-group__label", () => { const el = document.createElement("div"); el.className = "c-field-group__label"; return el; });
309
+ lbl.textContent = label;
310
+ } else {
311
+ const lbl = this.querySelector(".c-field-group__label");
312
+ if (lbl) lbl.remove();
313
+ }
314
+ const hint = this.getAttribute("hint");
315
+ if (hint) {
316
+ const h = this.ensure(".c-field-group__hint", () => { const el = document.createElement("span"); el.className = "c-field-group__hint"; return el; });
317
+ h.textContent = hint;
318
+ } else {
319
+ const h = this.querySelector(".c-field-group__hint");
320
+ if (h) h.remove();
321
+ }
322
+ const error = this.getAttribute("error");
323
+ if (error) {
324
+ const e = this.ensure(".c-field-group__error", () => { const el = document.createElement("span"); el.className = "c-field-group__error"; return el; });
325
+ e.textContent = error;
326
+ } else {
327
+ const e = this.querySelector(".c-field-group__error");
328
+ if (e) e.remove();
329
+ }
330
+ if (error) this.classList.add("is-error"); else this.classList.remove("is-error");
331
+ if (this.hasAttribute("required")) this.setAttribute("aria-required", "true");
332
+ else this.removeAttribute("aria-required");
333
+ }
334
+ enhance() {
335
+ if (this._wiredFieldGroup) return;
336
+ this._wiredFieldGroup = true;
337
+ }
338
+ }
339
+ define("contour-field-group", ContourFieldGroup);
340
+
341
+ /**
342
+ * Form: a form wrapper with submission state and a validation summary. Adds
343
+ * `is-submitting` and disables the submit button while `submitting` is set.
344
+ * On invalid submit, prevents default and renders a `role="alert"` summary
345
+ * listing the invalid fields. Emits `contour:submit` on valid submit.
346
+ */
347
+ class ContourForm extends ContourBase {
348
+ static get observed() { return ["submitting", "error", "summary"]; }
349
+ static get properties() { return { submitting: { attribute: "submitting", type: Boolean }, error: { attribute: "error" }, summary: { attribute: "summary" } }; }
350
+ render() {
351
+ this.classList.add("c-form");
352
+ if (this.hasAttribute("submitting")) this.classList.add("is-submitting"); else this.classList.remove("is-submitting");
353
+ const summaryText = this.getAttribute("summary") || this.getAttribute("error");
354
+ let summary = this.querySelector(".c-form__summary");
355
+ if (summaryText) {
356
+ if (!summary) { summary = document.createElement("div"); summary.className = "c-form__summary"; summary.setAttribute("role", "alert"); this.prepend(summary); }
357
+ summary.textContent = summaryText;
358
+ summary.removeAttribute("hidden");
359
+ } else if (summary) {
360
+ summary.setAttribute("hidden", "");
361
+ }
362
+ const submit = this.querySelector("[type='submit'], .c-form__submit");
363
+ if (submit) {
364
+ if (this.hasAttribute("submitting")) submit.setAttribute("disabled", "");
365
+ else submit.removeAttribute("disabled");
366
+ }
367
+ }
368
+ enhance() {
369
+ if (this._wiredForm) return;
370
+ this._wiredForm = true;
371
+ this.addEventListener("submit", (e) => {
372
+ const form = e.target;
373
+ if (form && typeof form.checkValidity === "function" && !form.checkValidity()) {
374
+ e.preventDefault();
375
+ const invalid = Array.from(form.querySelectorAll(":invalid"));
376
+ const names = invalid.map((el) => el.getAttribute("aria-label") || el.name || el.id || "field").join(", ");
377
+ // Update DOM directly (avoid setAttribute on observed attr -> re-entrancy).
378
+ let summary = this.querySelector(".c-form__summary");
379
+ if (!summary) { summary = document.createElement("div"); summary.className = "c-form__summary"; summary.setAttribute("role", "alert"); this.prepend(summary); }
380
+ summary.textContent = "Please fix: " + (names || "invalid fields");
381
+ summary.removeAttribute("hidden");
382
+ return;
383
+ }
384
+ // submitting state via class + button, not attribute.
385
+ this.classList.add("is-submitting");
386
+ const submit = this.querySelector("[type='submit'], .c-form__submit");
387
+ if (submit) submit.setAttribute("disabled", "");
388
+ this.dispatchEvent(new CustomEvent("contour:submit", { bubbles: true, composed: true, detail: { submitting: true } }));
389
+ });
390
+ }
391
+ }
392
+ define("contour-form", ContourForm);
393
+
394
+ /**
395
+ * Range: a native `<input type=range>` wrapper with optional dual-handle range
396
+ * mode (`range`, `low`, `high`) and a sparkline canvas (`sparkline`). Form
397
+ * associated; emits `contour:input` / `contour:change` with the current value
398
+ * (or `{low, high}` in range mode). Renders a `--fill` custom property for the
399
+ * filled track.
400
+ */
401
+ class ContourRange extends ContourBase {
402
+ static get observed() { return ["min", "max", "value", "low", "high", "range", "sparkline", "label", "disabled", "error", "help"]; }
195
403
  static get formAssociated() { return true; }
196
- static get properties() { return { min: { attribute: "min" }, max: { attribute: "max" }, value: { attribute: "value" }, label: { attribute: "label" } }; }
404
+ static get properties() { return { min: { attribute: "min" }, max: { attribute: "max" }, value: { attribute: "value" }, label: { attribute: "label" }, disabled: { attribute: "disabled", type: Boolean }, error: { attribute: "error" }, help: { attribute: "help" } }; }
197
405
  render() {
198
406
  this.classList.add("c-range");
199
407
  const min = this.getAttribute("min") || "0";
@@ -316,9 +524,15 @@ class ContourField extends ContourBase {
316
524
  sync();
317
525
  };
318
526
  define("contour-range", ContourRange);
527
+ /**
528
+ * Switch: a `role="switch"` checkbox control with label, required, disabled,
529
+ * error and help states. Form associated; emits `contour:change` on toggle.
530
+ * Renders a `c-switch__track` element after the input for the sheet's track
531
+ * styling.
532
+ */
319
533
  class ContourSwitch extends ContourBase {
320
- static get observed() { return ["label", "required", "checked"]; }
321
- static get properties() { return { label: { attribute: "label" }, required: { attribute: "required", type: Boolean }, checked: { attribute: "checked", type: Boolean } }; }
534
+ static get observed() { return ["label", "required", "checked", "disabled", "error", "help"]; }
535
+ static get properties() { return { label: { attribute: "label" }, required: { attribute: "required", type: Boolean }, checked: { attribute: "checked", type: Boolean }, disabled: { attribute: "disabled", type: Boolean }, error: { attribute: "error" }, help: { attribute: "help" } }; }
322
536
  static get formAssociated() { return true; }
323
537
  render() {
324
538
  this.classList.add("c-switch");
@@ -330,6 +544,17 @@ class ContourSwitch extends ContourBase {
330
544
  input.setAttribute("role", "switch");
331
545
  input.setAttribute("aria-checked", String(input.checked));
332
546
  this._setCustomState("data-checked", input.checked);
547
+ if (this.hasAttribute("disabled")) { input.setAttribute("disabled", ""); this.classList.add("is-disabled"); }
548
+ else { input.removeAttribute("disabled"); this.classList.remove("is-disabled"); }
549
+ const err = this.getAttribute("error");
550
+ const help = this.getAttribute("help");
551
+ let msg = this.querySelector(".c-switch__message");
552
+ if (err || help) {
553
+ if (!msg) { msg = document.createElement("div"); msg.className = "c-switch__message"; this.appendChild(msg); }
554
+ msg.textContent = err || help || "";
555
+ msg.classList.toggle("c-switch__message--error", !!err);
556
+ } else if (msg) { msg.remove(); }
557
+ if (err) this.classList.add("is-error"); else this.classList.remove("is-error");
333
558
  // Ensure track element follows the input (CSS: input + track).
334
559
  if (!input.nextElementSibling || !input.nextElementSibling.classList.contains("c-switch__track")) {
335
560
  const track = document.createElement("span");
@@ -366,9 +591,15 @@ class ContourSwitch extends ContourBase {
366
591
  }
367
592
  }
368
593
  define("contour-switch", ContourSwitch);
594
+ /**
595
+ * Check: a checkbox (or `type="radio"` when `type` is set) with label, name,
596
+ * value, required, checked, disabled, error and help states. Renders a
597
+ * `c-check__box` element after the input. Form associated; emits
598
+ * `contour:change` on toggle.
599
+ */
369
600
  class ContourCheck extends ContourBase {
370
- static get observed() { return ["label", "name", "value", "required", "type", "checked"]; }
371
- static get properties() { return { label: { attribute: "label" }, name: { attribute: "name" }, value: { attribute: "value" }, required: { attribute: "required", type: Boolean }, type: { attribute: "type" }, checked: { attribute: "checked", type: Boolean } }; }
601
+ static get observed() { return ["label", "name", "value", "required", "type", "checked", "disabled", "error", "help"]; }
602
+ static get properties() { return { label: { attribute: "label" }, name: { attribute: "name" }, value: { attribute: "value" }, required: { attribute: "required", type: Boolean }, type: { attribute: "type" }, checked: { attribute: "checked", type: Boolean }, disabled: { attribute: "disabled", type: Boolean }, error: { attribute: "error" }, help: { attribute: "help" } }; }
372
603
  static get formAssociated() { return true; }
373
604
  render() {
374
605
  this.classList.add("c-check");
@@ -390,6 +621,17 @@ class ContourCheck extends ContourBase {
390
621
  }
391
622
  if (this.hasAttribute("name")) input.name = this.getAttribute("name");
392
623
  if (this.hasAttribute("value")) input.value = this.getAttribute("value");
624
+ if (this.hasAttribute("disabled")) { input.setAttribute("disabled", ""); this.classList.add("is-disabled"); }
625
+ else { input.removeAttribute("disabled"); this.classList.remove("is-disabled"); }
626
+ const err = this.getAttribute("error");
627
+ const help = this.getAttribute("help");
628
+ let msg = this.querySelector(".c-check__message");
629
+ if (err || help) {
630
+ if (!msg) { msg = document.createElement("div"); msg.className = "c-check__message"; this.appendChild(msg); }
631
+ msg.textContent = err || help || "";
632
+ msg.classList.toggle("c-check__message--error", !!err);
633
+ } else if (msg) { msg.remove(); }
634
+ if (err) this.classList.add("is-error"); else this.classList.remove("is-error");
393
635
  }
394
636
  enhance() {
395
637
  const input = this.querySelector("input");
@@ -411,9 +653,14 @@ class ContourCheck extends ContourBase {
411
653
  }
412
654
  }
413
655
  define("contour-check", ContourCheck);
656
+ /**
657
+ * Radio: a radio button with label, name, value, required, checked, disabled,
658
+ * error and help states. Form associated; unchecking clears the stale FormData
659
+ * entry. Emits `contour:change` on toggle.
660
+ */
414
661
  class ContourRadio extends ContourBase {
415
- static get observed() { return ["label", "name", "value", "required", "checked"]; }
416
- static get properties() { return { label: { attribute: "label" }, name: { attribute: "name" }, value: { attribute: "value" }, required: { attribute: "required", type: Boolean }, checked: { attribute: "checked", type: Boolean } }; }
662
+ static get observed() { return ["label", "name", "value", "required", "checked", "disabled", "error", "help"]; }
663
+ static get properties() { return { label: { attribute: "label" }, name: { attribute: "name" }, value: { attribute: "value" }, required: { attribute: "required", type: Boolean }, checked: { attribute: "checked", type: Boolean }, disabled: { attribute: "disabled", type: Boolean }, error: { attribute: "error" }, help: { attribute: "help" } }; }
417
664
  static get formAssociated() { return true; }
418
665
  render() {
419
666
  this.classList.add("c-radio");
@@ -422,6 +669,17 @@ class ContourRadio extends ContourBase {
422
669
  input.checked = this.hasAttribute("checked");
423
670
  if (this.hasAttribute("name")) input.name = this.getAttribute("name");
424
671
  if (this.hasAttribute("value")) input.value = this.getAttribute("value");
672
+ if (this.hasAttribute("disabled")) { input.setAttribute("disabled", ""); this.classList.add("is-disabled"); }
673
+ else { input.removeAttribute("disabled"); this.classList.remove("is-disabled"); }
674
+ const err = this.getAttribute("error");
675
+ const help = this.getAttribute("help");
676
+ let msg = this.querySelector(".c-radio__message");
677
+ if (err || help) {
678
+ if (!msg) { msg = document.createElement("div"); msg.className = "c-radio__message"; this.appendChild(msg); }
679
+ msg.textContent = err || help || "";
680
+ msg.classList.toggle("c-radio__message--error", !!err);
681
+ } else if (msg) { msg.remove(); }
682
+ if (err) this.classList.add("is-error"); else this.classList.remove("is-error");
425
683
  if (label) {
426
684
  input.setAttribute("aria-label", label);
427
685
  const txt = this.querySelector(":scope > span:not([class])") || (() => { const el = document.createElement("span"); this.appendChild(el); return el; })();
@@ -450,9 +708,14 @@ class ContourRadio extends ContourBase {
450
708
  }
451
709
  }
452
710
  define("contour-radio", ContourRadio);
453
- class ContourSelect extends ContourBase {
454
- static get observed() { return ["options", "required", "label", "placeholder"]; }
455
- static get properties() { return { options: { attribute: "options" }, required: { attribute: "required", type: Boolean }, label: { attribute: "label" }, placeholder: { attribute: "placeholder" } }; }
711
+ /**
712
+ * Select: a native `<select>` wrapper populated from a JSON `options` attribute
713
+ * (with optgroup support) or an authored `<select>`. Supports label, placeholder,
714
+ * required, disabled, error and help. Form associated; emits `contour:change`.
715
+ */
716
+ class ContourSelect extends ContourBase {
717
+ static get observed() { return ["options", "required", "label", "placeholder", "disabled", "error", "help"]; }
718
+ static get properties() { return { options: { attribute: "options" }, required: { attribute: "required", type: Boolean }, label: { attribute: "label" }, placeholder: { attribute: "placeholder" }, disabled: { attribute: "disabled", type: Boolean }, error: { attribute: "error" }, help: { attribute: "help" } }; }
456
719
  static get formAssociated() { return true; }
457
720
  render() {
458
721
  this.classList.add("c-select");
@@ -468,10 +731,6 @@ class ContourRadio extends ContourBase {
468
731
  const label = this.getAttribute("label");
469
732
  if (label) {
470
733
  select.setAttribute("aria-label", label);
471
- // Associated label element.
472
- let lbl = this.querySelector("label.c-select__label");
473
- if (!lbl) { lbl = document.createElement("label"); lbl.className = "c-select__label"; lbl.textContent = label; this.insertBefore(lbl, select); }
474
- else lbl.textContent = label;
475
734
  }
476
735
  const placeholder = this.getAttribute("placeholder");
477
736
  if (placeholder) {
@@ -504,6 +763,35 @@ class ContourRadio extends ContourBase {
504
763
  select.classList.add("c-select");
505
764
  } catch (e) { /* keep existing */ }
506
765
  }
766
+ // Ensure authored select gets c-select styling.
767
+ const authoredSel = this.querySelector("select");
768
+ if (authoredSel && !authoredSel.classList.contains("c-select")) {
769
+ authoredSel.classList.add("c-select");
770
+ this.classList.remove("c-select");
771
+ }
772
+ // Disabled / error / help contract (applies to authored or generated select).
773
+ const sel = this.querySelector("select");
774
+ if (sel) {
775
+ if (this.hasAttribute("disabled")) { sel.setAttribute("disabled", ""); this.classList.add("is-disabled"); }
776
+ else { sel.removeAttribute("disabled"); this.classList.remove("is-disabled"); }
777
+ }
778
+ // Label (applies to both JSON and authored options).
779
+ const label = this.getAttribute("label");
780
+ if (label) {
781
+ let lbl = this.querySelector("label.c-select__label");
782
+ if (!lbl) { lbl = document.createElement("label"); lbl.className = "c-select__label"; this.insertBefore(lbl, sel || this.firstChild); }
783
+ lbl.textContent = label;
784
+ if (sel) sel.setAttribute("aria-label", label);
785
+ }
786
+ const err = this.getAttribute("error");
787
+ const help = this.getAttribute("help");
788
+ let msg = this.querySelector(".c-select__message");
789
+ if (err || help) {
790
+ if (!msg) { msg = document.createElement("div"); msg.className = "c-select__message"; this.appendChild(msg); }
791
+ msg.textContent = err || help || "";
792
+ msg.classList.toggle("c-select__message--error", !!err);
793
+ } else if (msg) { msg.remove(); }
794
+ if (err) this.classList.add("is-error"); else this.classList.remove("is-error");
507
795
  }
508
796
  enhance() {
509
797
  const select = this.querySelector("select");
@@ -523,6 +811,10 @@ class ContourRadio extends ContourBase {
523
811
  }
524
812
  }
525
813
  define("contour-select", ContourSelect);
814
+ /**
815
+ * Version: a `<select>` of version options from a JSON `options` attribute,
816
+ * with `selected` support per option. Form associated; emits `contour:change`.
817
+ */
526
818
  class ContourVersion extends ContourBase {
527
819
  static get observed() { return ["options"]; }
528
820
  static get formAssociated() { return true; }
@@ -568,17 +860,31 @@ class ContourVersion extends ContourBase {
568
860
  }
569
861
  }
570
862
  define("contour-version", ContourVersion);
863
+ /**
864
+ * Textarea: a `<textarea>` wrapper with placeholder, required, disabled, error
865
+ * and help states. Form associated; emits `contour:input` / `contour:change`.
866
+ */
571
867
  class ContourTextarea extends ContourBase {
572
- static get observed() { return ["placeholder", "required"]; }
573
- static get properties() { return { placeholder: { attribute: "placeholder" }, required: { attribute: "required", type: Boolean } }; }
868
+ static get observed() { return ["placeholder", "required", "disabled", "error", "help"]; }
869
+ static get properties() { return { placeholder: { attribute: "placeholder" }, required: { attribute: "required", type: Boolean }, disabled: { attribute: "disabled", type: Boolean }, error: { attribute: "error" }, help: { attribute: "help" } }; }
574
870
  static get formAssociated() { return true; }
575
871
  render() {
576
- this.classList.add("c-textarea");
577
872
  const ta = this.ensure("textarea", () => { const el = document.createElement("textarea"); el.className = "c-textarea"; return el; });
578
873
  ta.className = "c-textarea";
579
874
  ta.placeholder = this.getAttribute("placeholder") || "";
580
875
  if (this.hasAttribute("required")) ta.setAttribute("required", "");
581
876
  else ta.removeAttribute("required");
877
+ if (this.hasAttribute("disabled")) { ta.setAttribute("disabled", ""); this.classList.add("is-disabled"); }
878
+ else { ta.removeAttribute("disabled"); this.classList.remove("is-disabled"); }
879
+ const err = this.getAttribute("error");
880
+ const help = this.getAttribute("help");
881
+ let msg = this.querySelector(".c-textarea__message");
882
+ if (err || help) {
883
+ if (!msg) { msg = document.createElement("div"); msg.className = "c-textarea__message"; this.appendChild(msg); }
884
+ msg.textContent = err || help || "";
885
+ msg.classList.toggle("c-textarea__message--error", !!err);
886
+ } else if (msg) { msg.remove(); }
887
+ if (err) this.classList.add("is-error"); else this.classList.remove("is-error");
582
888
  }
583
889
  enhance() {
584
890
  const ta = this.querySelector("textarea");
@@ -605,19 +911,38 @@ class ContourTextarea extends ContourBase {
605
911
  }
606
912
  }
607
913
  define("contour-textarea", ContourTextarea);
914
+ /**
915
+ * Input: an `<input>` wrapper with type, placeholder, required, value, disabled,
916
+ * error and help states. Form associated; emits `contour:input` / `contour:change`.
917
+ */
608
918
  class ContourInputFull extends ContourBase {
609
- static get observed() { return ["type", "placeholder", "required", "value"]; }
610
- static get properties() { return { type: { attribute: "type" }, placeholder: { attribute: "placeholder" }, required: { attribute: "required", type: Boolean }, value: { attribute: "value" } }; }
919
+ static get observed() { return ["type", "placeholder", "required", "value", "disabled", "error", "help", "label"]; }
920
+ static get properties() { return { type: { attribute: "type" }, placeholder: { attribute: "placeholder" }, required: { attribute: "required", type: Boolean }, value: { attribute: "value" }, disabled: { attribute: "disabled", type: Boolean }, error: { attribute: "error" }, help: { attribute: "help" }, label: { attribute: "label" } }; }
611
921
  static get formAssociated() { return true; }
612
922
  render() {
613
923
  this.classList.add("c-input");
614
924
  const input = this.ensure("input", () => { const el = document.createElement("input"); el.className = "c-input"; return el; });
615
925
  input.className = "c-input";
616
926
  input.type = this.getAttribute("type") || "text";
617
- input.placeholder = this.getAttribute("placeholder") || "";
927
+ input.placeholder = this.getAttribute("placeholder") || "";
928
+ const label = this.getAttribute("label");
929
+ if (label) input.setAttribute("aria-label", label);
930
+ // else: keep any aria-label set by an ancestor (e.g. contour-field).
618
931
  if (this.hasAttribute("value")) input.value = this.getAttribute("value");
619
932
  if (this.hasAttribute("required")) input.setAttribute("required", "");
620
933
  else input.removeAttribute("required");
934
+ if (this.hasAttribute("disabled")) { input.setAttribute("disabled", ""); this.classList.add("is-disabled"); }
935
+ else { input.removeAttribute("disabled"); this.classList.remove("is-disabled"); }
936
+ // Error/help text
937
+ const err = this.getAttribute("error");
938
+ const help = this.getAttribute("help");
939
+ let msg = this.querySelector(".c-input__message");
940
+ if (err || help) {
941
+ if (!msg) { msg = document.createElement("div"); msg.className = "c-input__message"; this.appendChild(msg); }
942
+ msg.textContent = err || help || "";
943
+ msg.classList.toggle("c-input__message--error", !!err);
944
+ } else if (msg) { msg.remove(); }
945
+ if (err) this.classList.add("is-error"); else this.classList.remove("is-error");
621
946
  }
622
947
  enhance() {
623
948
  const input = this.querySelector("input");
@@ -644,6 +969,12 @@ class ContourInputFull extends ContourBase {
644
969
  }
645
970
  }
646
971
  define("contour-input", ContourInputFull);
972
+ /**
973
+ * InputGroup: a text input with an optional search icon, a clear (×) affordance
974
+ * and a submit (→) affordance. Attributes: `label`, `placeholder`, `clearable`,
975
+ * `submit`. Emits `contour:change` (bubbles, composed) with `{ value: "" }` on
976
+ * clear.
977
+ */
647
978
  class ContourInputGroup extends ContourBase {
648
979
  static get observed() { return ["label", "placeholder", "clearable", "submit"]; }
649
980
  static get properties() { return { label: { attribute: "label" }, placeholder: { attribute: "placeholder" }, clearable: { attribute: "clearable", type: Boolean }, submit: { attribute: "submit", type: Boolean } }; }
@@ -690,6 +1021,12 @@ class ContourInputGroup extends ContourBase {
690
1021
  }
691
1022
  }
692
1023
  define("contour-input-group", ContourInputGroup);
1024
+ /**
1025
+ * RadioList: a `role="radiogroup"` of radio options from a JSON `items`
1026
+ * attribute (or remote `src`). Supports roving tabindex, Home/End navigation,
1027
+ * RTL, empty/loading/error states, and `formResetCallback` that re-renders from
1028
+ * the authored `items` payload. Form associated; emits `contour:change`.
1029
+ */
693
1030
  class ContourRadioList extends ContourBase {
694
1031
  static get observed() { return ["items", "name", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
695
1032
  static get properties() { return { items: { attribute: "items" }, name: { attribute: "name" }, src: { attribute: "src" } }; }
package/dist/wc/index.mjs CHANGED
@@ -1,5 +1,8 @@
1
- // Entry point for the web-component modules. Importing this module registers
2
- // every Contour custom element as a side effect.
1
+ /**
2
+ * Contour web-component entry point.
3
+ * Importing this module registers every light-DOM and shadow-DOM element.
4
+ * @module contour-wc
5
+ */
3
6
 
4
7
  import { REGISTERED } from "./core.mjs";
5
8
  import "./core.mjs";
@@ -22,7 +25,8 @@ import "./shadow.mjs";
22
25
 
23
26
  // Published version + readiness signal. Fires after every fragment has run, so
24
27
  // a consumer listening for `contour:ready` can assume the full registry exists.
25
- export const CONTOUR_VERSION = "1.1.0";
28
+ /** Published component runtime version. */
29
+ export const CONTOUR_VERSION = "1.5.0";
26
30
  if (typeof window !== "undefined") {
27
31
  window.ContourVersion = CONTOUR_VERSION;
28
32
  queueMicrotask(() => {
@@ -1,4 +1,4 @@
1
- import { ContourBase, define } from './core.mjs';
1
+ import { ContourBase, define, onDispose } from './core.mjs';
2
2
  import { wireSegmented } from './behaviours.mjs';
3
3
  class ContourPressableFull extends ContourBase {
4
4
  static get observed() { return ["disabled"]; }
@@ -11,7 +11,7 @@ class ContourPressableFull extends ContourBase {
11
11
  this.setAttribute("tabindex", "-1");
12
12
  } else {
13
13
  this.removeAttribute("aria-disabled");
14
- if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
14
+ if (!this.hasAttribute("tabindex") || this.getAttribute("tabindex") === "-1") this.setAttribute("tabindex", "0");
15
15
  }
16
16
  }
17
17
  enhance() {
@@ -27,6 +27,9 @@ class ContourResizeHandleFull extends ContourBase {
27
27
  render() {
28
28
  this.classList.add("c-resize-handle");
29
29
  if (!this.hasAttribute("role")) this.setAttribute("role", "separator");
30
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", "Resize handle");
31
+ if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
32
+ if (!this.hasAttribute("aria-orientation")) this.setAttribute("aria-orientation", "horizontal");
30
33
  }
31
34
  }
32
35
  define("contour-resize-handle", ContourResizeHandleFull);
@@ -121,7 +124,7 @@ class ContourShortcutPanelFull extends ContourBase {
121
124
  if (this._wiredShortcutOverlay) return;
122
125
  this._wiredShortcutOverlay = true;
123
126
  // Global registry: "?" (Shift+/) toggles the overlay; Escape closes.
124
- document.addEventListener("keydown", (e) => {
127
+ const keyHandler = (e) => {
125
128
  if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey) {
126
129
  const tag = (e.target && e.target.tagName) || "";
127
130
  if (tag === "INPUT" || tag === "TEXTAREA" || (e.target && e.target.isContentEditable)) return;
@@ -130,7 +133,9 @@ class ContourShortcutPanelFull extends ContourBase {
130
133
  } else if (e.key === "Escape" && this.hasAttribute("open")) {
131
134
  this.hide();
132
135
  }
133
- });
136
+ };
137
+ document.addEventListener("keydown", keyHandler);
138
+ onDispose(this, () => document.removeEventListener("keydown", keyHandler));
134
139
  this.addEventListener("click", (e) => {
135
140
  if (e.target === this) this.hide();
136
141
  });
@@ -148,7 +153,7 @@ class ContourRowActionFull extends ContourBase {
148
153
  this.setAttribute("tabindex", "-1");
149
154
  } else {
150
155
  this.removeAttribute("aria-disabled");
151
- if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
156
+ if (!this.hasAttribute("tabindex") || this.getAttribute("tabindex") === "-1") this.setAttribute("tabindex", "0");
152
157
  }
153
158
  const label = this.getAttribute("label");
154
159
  if (label && !this.hasChildNodes()) this.textContent = label;
@@ -465,7 +470,7 @@ class ContourBtn extends ContourBase {
465
470
  this.setAttribute("tabindex", "-1");
466
471
  } else {
467
472
  this.removeAttribute("aria-disabled");
468
- if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
473
+ if (!this.hasAttribute("tabindex") || this.getAttribute("tabindex") === "-1") this.setAttribute("tabindex", "0");
469
474
  }
470
475
  const label = this.getAttribute("label");
471
476
  if (label && !this.hasChildNodes()) this.textContent = label;