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/docs.mjs CHANGED
@@ -128,6 +128,7 @@ class ContourDocsShell extends ContourBase {
128
128
 
129
129
 
130
130
  class ContourFileTree extends ContourBase {
131
+ static get updateMode() { return "keyed"; }
131
132
  static get observed() { return ["items"]; }
132
133
  static get properties() { return { items: { attribute: "items" } }; }
133
134
  render() {
@@ -75,7 +75,9 @@ class ContourDialog extends ContourBase {
75
75
  modalContain(this, false);
76
76
  this.dispatchEvent(new CustomEvent("contour:close", { bubbles: true, composed: true }));
77
77
  const last = this._dialogLastFocus;
78
- if (last && typeof last.focus === "function") { try { last.focus(); } catch (e) {} }
78
+ if (last && typeof last.focus === "function") {
79
+ try { last.focus(); } catch (e) {}
80
+ }
79
81
  }
80
82
  };
81
83
  this.focus = () => {
@@ -339,6 +341,7 @@ class ContourEmpty extends ContourBase {
339
341
  static get properties() { return { state: { attribute: "state" }, title: { attribute: "title" }, body: { attribute: "body" }, action: { attribute: "action" }, icon: { attribute: "icon" }, illustration: { attribute: "illustration" } }; }
340
342
  render() {
341
343
  this.classList.add("c-empty");
344
+ if (!this.hasAttribute("role")) this.setAttribute("role", "status");
342
345
  const state = this.getAttribute("state") || "empty";
343
346
  const title = this.getAttribute("title") || (state === "filtered" ? "Nothing matches" : state === "error" ? "Could not load" : "No data yet");
344
347
  const body = this.getAttribute("body") || (state === "filtered" ? "Try clearing some filters." : state === "error" ? "Check your connection and try again." : "There is nothing to show here yet.");
@@ -578,7 +581,7 @@ class ContourDrawer extends ContourBase {
578
581
  // cannot re-enter the render — see the dialog); the `.is-open` class the
579
582
  // CSS keys off is re-derived here because the base restores the authored
580
583
  // class on every render and would otherwise drop it mid-lock.
581
- if (this.hasAttribute("open")) this.classList.add("is-open");
584
+ if (this.hasAttribute("open")) this.classList.add("is-open"); else this.classList.remove("is-open");
582
585
  const body = this.getAttribute("body");
583
586
  const b = this.querySelector(".c-drawer__body");
584
587
  const authored = b ? Array.from(b.children) : [];
@@ -675,7 +678,7 @@ class ContourSheet extends ContourBase {
675
678
  // Open state is the `open` attribute (written, never observed, so it
676
679
  // cannot re-enter the render); the `.is-open` class is re-derived because
677
680
  // the base restores the authored class on every render (see the drawer).
678
- if (this.hasAttribute("open")) this.classList.add("is-open");
681
+ if (this.hasAttribute("open")) this.classList.add("is-open"); else this.classList.remove("is-open");
679
682
  const body = this.getAttribute("body");
680
683
  const b = this.querySelector(".c-sheet__body");
681
684
  const authored = b ? Array.from(b.children) : [];
@@ -839,7 +842,8 @@ class ContourToastHost extends ContourBase {
839
842
  if (this._wiredToastHost) return;
840
843
  this._wiredToastHost = true;
841
844
  this._toastQueue = [];
842
- const showOne = (message, opts) => {
845
+ this._toastActive = null;
846
+ const buildToast = (message, opts) => {
843
847
  opts = opts || {};
844
848
  const toast = document.createElement("div");
845
849
  toast.className = "c-toast";
@@ -847,22 +851,80 @@ class ContourToastHost extends ContourBase {
847
851
  toast.setAttribute("aria-live", "polite");
848
852
  toast.setAttribute("aria-atomic", "true");
849
853
  if (opts.variant) toast.classList.add("c-toast--" + opts.variant);
850
- toast.textContent = message == null ? "" : String(message);
851
- this.appendChild(toast);
852
- const ms = (opts.duration && opts.duration > 0) ? opts.duration : 3000;
853
- const timer = setTimeout(() => {
854
- if (toast.parentNode) toast.parentNode.removeChild(toast);
855
- this.dispatchEvent(new CustomEvent("contour:close", { bubbles: true, composed: true }));
856
- }, ms);
857
- toast._timer = timer;
854
+ toast.dataset.message = message == null ? "" : String(message);
855
+ const text = document.createElement("span");
856
+ text.className = "c-toast__text";
857
+ text.textContent = message == null ? "" : String(message);
858
+ toast.appendChild(text);
859
+ if (opts.action && (typeof opts.action === "string" || (opts.action.label))) {
860
+ const label = (typeof opts.action === "string") ? opts.action : opts.action.label;
861
+ const btn = document.createElement("button");
862
+ btn.type = "button";
863
+ btn.className = "c-btn c-btn--ghost c-toast__action";
864
+ btn.textContent = label;
865
+ btn.addEventListener("click", (e) => {
866
+ e.stopPropagation();
867
+ if (typeof opts.action === "object" && typeof opts.action.onClick === "function") {
868
+ try { opts.action.onClick(); } catch (err) {}
869
+ }
870
+ dismiss(toast);
871
+ });
872
+ toast.appendChild(btn);
873
+ }
858
874
  return toast;
859
875
  };
860
- this.show = (message, opts) => showOne(message, opts);
876
+ const dismiss = (toast) => {
877
+ if (!toast || !toast.parentNode) return;
878
+ if (toast._timer) { clearTimeout(toast._timer); toast._timer = null; }
879
+ toast.parentNode.removeChild(toast);
880
+ if (this._toastActive === toast) this._toastActive = null;
881
+ this.dispatchEvent(new CustomEvent("contour:close", { bubbles: true, composed: true, detail: { message: toast.textContent } }));
882
+ pump();
883
+ };
884
+ const pump = () => {
885
+ if (this._toastActive && this._toastActive.parentNode) return;
886
+ // dedup: skip queued items whose message matches the one just shown
887
+ while (this._toastQueue.length) {
888
+ const next = this._toastQueue.shift();
889
+ if (next._deduped) continue;
890
+ const toast = buildToast(next.message, next.opts);
891
+ this._toastActive = toast;
892
+ this.appendChild(toast);
893
+ const ms = (next.opts && next.opts.duration && next.opts.duration > 0) ? next.opts.duration : 3000;
894
+ toast._timer = setTimeout(() => dismiss(toast), ms);
895
+ return;
896
+ }
897
+ this._toastActive = null;
898
+ };
899
+ this.show = (message, opts) => {
900
+ opts = opts || {};
901
+ const key = String(message == null ? "" : message);
902
+ // dedup: if an identical message is already queued or active, reset its timer instead of stacking
903
+ const active = this._toastActive;
904
+ if (active && active.dataset && active.dataset.message === key && key !== "") {
905
+ if (active._timer) { clearTimeout(active._timer); }
906
+ const ms = (opts.duration && opts.duration > 0) ? opts.duration : 3000;
907
+ active._timer = setTimeout(() => dismiss(active), ms);
908
+ return active;
909
+ }
910
+ const queuedDup = this._toastQueue.find((q) => String(q.message) === key && key !== "");
911
+ if (queuedDup) {
912
+ queuedDup.opts = Object.assign({}, queuedDup.opts, opts);
913
+ return null;
914
+ }
915
+ const entry = { message, opts, _deduped: false };
916
+ this._toastQueue.push(entry);
917
+ pump();
918
+ return this._toastActive;
919
+ };
861
920
  this.hide = () => {
921
+ if (this._toastActive) dismiss(this._toastActive);
922
+ this._toastQueue.length = 0;
862
923
  Array.from(this.querySelectorAll(".c-toast")).forEach((t) => {
863
924
  if (t._timer) clearTimeout(t._timer);
864
925
  if (t.parentNode) t.parentNode.removeChild(t);
865
926
  });
927
+ this._toastActive = null;
866
928
  };
867
929
  }
868
930
  }