contour-ds 1.9.0 → 1.10.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.
- package/README.md +4 -4
- package/dist/build-manifest.json +205 -204
- package/dist/contour-wc-content.esm.js +1 -1
- package/dist/contour-wc-content.esm.min.js +1 -1
- package/dist/contour-wc-core.esm.js +712 -45
- package/dist/contour-wc-core.esm.min.js +1 -1
- package/dist/contour-wc-dashboard.esm.js +596 -90
- package/dist/contour-wc-dashboard.esm.min.js +1 -1
- package/dist/contour-wc-data.esm.js +467 -70
- package/dist/contour-wc-data.esm.min.js +1 -1
- package/dist/contour-wc-docs.esm.js +1 -1
- package/dist/contour-wc-docs.esm.min.js +1 -1
- package/dist/contour-wc-feedback.esm.js +260 -29
- package/dist/contour-wc-feedback.esm.min.js +1 -1
- package/dist/contour-wc-forms.esm.js +133 -40
- package/dist/contour-wc-forms.esm.min.js +1 -1
- package/dist/contour-wc-interaction.esm.js +64 -5
- package/dist/contour-wc-interaction.esm.min.js +1 -1
- package/dist/contour-wc-layout.esm.js +72 -10
- package/dist/contour-wc-layout.esm.min.js +1 -1
- package/dist/contour-wc-map.esm.js +69 -9
- package/dist/contour-wc-map.esm.min.js +1 -1
- package/dist/contour-wc-misc.esm.js +1 -1
- package/dist/contour-wc-misc.esm.min.js +1 -1
- package/dist/contour-wc-navigation.esm.js +136 -20
- package/dist/contour-wc-navigation.esm.min.js +1 -1
- package/dist/contour-wc-ui.esm.js +505 -80
- package/dist/contour-wc-ui.esm.min.js +1 -1
- package/dist/contour-wc.esm.js +2539 -320
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +2539 -320
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.code-snippets +44 -0
- package/dist/contour.components.json +12064 -135
- package/dist/contour.css +1368 -451
- package/dist/contour.d.ts +42 -21
- package/dist/contour.esm.js +138 -21
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.html-data.json +249 -9
- package/dist/contour.js +138 -21
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.react.d.ts +5 -1
- package/dist/contour.single.html +2 -2
- package/dist/contour.single.min.css +1 -1
- package/dist/contour.tokens.json +36 -1
- package/dist/contour.vue.d.ts +5 -1
- package/dist/contour.web-types.json +241 -9
- package/dist/custom-elements.json +1225 -55
- package/dist/docs/actions.md +1 -1
- package/dist/docs/affordances.md +1 -1
- package/dist/docs/apireference.md +1 -1
- package/dist/docs/colour.md +1 -1
- package/dist/docs/componentindex.md +1 -1
- package/dist/docs/data.md +6 -2
- package/dist/docs/docs.md +1 -1
- package/dist/docs/feedback.md +1 -1
- package/dist/docs/field.md +1 -1
- package/dist/docs/forms.md +1 -1
- package/dist/docs/index.json +8 -8
- package/dist/docs/install.md +1 -1
- package/dist/docs/landing.md +1 -1
- package/dist/docs/mapengine.md +1 -1
- package/dist/docs/motion.md +1 -1
- package/dist/docs/navigation.md +1 -1
- package/dist/docs/overlays.md +1 -1
- package/dist/docs/overview.md +1 -1
- package/dist/docs/patterns.md +1 -1
- package/dist/docs/playground.md +1 -1
- package/dist/docs/principles.md +1 -1
- package/dist/docs/recipes.md +1 -1
- package/dist/docs/space.md +1 -1
- package/dist/docs/status.md +1 -1
- package/dist/docs/surfaces.md +1 -1
- package/dist/docs/theming.md +5 -2
- package/dist/docs/type.md +1 -1
- package/dist/docs/webcomponents.md +1 -1
- package/dist/hljs.css +34 -17
- package/dist/map-chrome-contract.json +26 -0
- package/dist/map-chrome.mapbox.css +121 -0
- package/dist/map-chrome.maplibre.css +121 -0
- package/dist/registry/items/contour-core.json +2 -2
- package/dist/registry/items/contour-data.json +2 -2
- package/dist/registry/items/contour-docs.json +2 -2
- package/dist/registry/items/contour-landing.json +2 -2
- package/dist/registry/registry.json +8 -8
- package/dist/surfaces/contour-core.min.css +1 -1
- package/dist/surfaces/contour-data.min.css +1 -1
- package/dist/surfaces/contour-docs.min.css +1 -1
- package/dist/surfaces/contour-landing.min.css +1 -1
- package/dist/wc/behaviours.mjs +11 -3
- package/dist/wc/core.mjs +307 -32
- package/dist/wc/dashboard.mjs +129 -20
- package/dist/wc/data-chart.mjs +170 -22
- package/dist/wc/data-export.mjs +150 -29
- package/dist/wc/data-gauge.mjs +11 -4
- package/dist/wc/data-geo.mjs +1 -1
- package/dist/wc/data-legend.mjs +15 -2
- package/dist/wc/data-readout.mjs +12 -1
- package/dist/wc/data-series.mjs +73 -5
- package/dist/wc/data-table.mjs +37 -8
- package/dist/wc/feedback.mjs +259 -28
- package/dist/wc/forms-controls.mjs +44 -16
- package/dist/wc/forms-field.mjs +46 -4
- package/dist/wc/forms-groups.mjs +31 -8
- package/dist/wc/forms-input.mjs +11 -11
- package/dist/wc/index.mjs +1 -1
- package/dist/wc/interaction.mjs +63 -4
- package/dist/wc/layout.mjs +72 -10
- package/dist/wc/map.mjs +68 -8
- package/dist/wc/navigation-menu.mjs +43 -9
- package/dist/wc/navigation-shell.mjs +39 -6
- package/dist/wc/navigation-tree.mjs +53 -4
- package/dist/wc/states.mjs +350 -9
- package/dist/wc/svg.mjs +43 -0
- package/dist/wc/ui-data.mjs +268 -28
- package/dist/wc/ui-feedback.mjs +36 -11
- package/dist/wc/ui-inputs.mjs +63 -25
- package/dist/wc/ui-overlays.mjs +138 -16
- package/integrations/ai/v0-prompt.md +1 -1
- package/integrations/frameworks/fixtures/authored/sample.jsx +15 -0
- package/integrations/frameworks/fixtures/authored/sample.vue +15 -0
- package/integrations/frameworks/fixtures/dist/rendered.html +32 -0
- package/integrations/libreship/contract.json +1025 -0
- package/integrations/native/README.md +24 -4
- package/integrations/native/build/android/colors.xml +278 -0
- package/integrations/native/build/flutter/contour_tokens.dart +280 -0
- package/integrations/native/build/ios/ContourTokens.swift +280 -0
- package/integrations/validate-markup.mjs +57 -7
- package/package.json +45 -18
package/dist/wc/behaviours.mjs
CHANGED
|
@@ -210,8 +210,11 @@ export function wireTabs(host) {
|
|
|
210
210
|
try { restored = localStorage.getItem("contour-tabs:" + host.id); } catch (e) { restored = null; }
|
|
211
211
|
} else if (persist === "url") {
|
|
212
212
|
try {
|
|
213
|
+
// R34-13: scope the URL key to the host id so two tab sets on one page
|
|
214
|
+
// do not share (and overwrite) a single `c-tabs` parameter.
|
|
215
|
+
const urlKey = host.id ? "c-tabs-" + host.id : "c-tabs";
|
|
213
216
|
const params = new URLSearchParams(window.location.search);
|
|
214
|
-
const v = params.get(
|
|
217
|
+
const v = params.get(urlKey);
|
|
215
218
|
if (v !== null) restored = v;
|
|
216
219
|
} catch (e) { restored = null; }
|
|
217
220
|
}
|
|
@@ -231,7 +234,8 @@ export function wireTabs(host) {
|
|
|
231
234
|
wcTrack(host, host, "contour:tab-change", (e) => {
|
|
232
235
|
try {
|
|
233
236
|
const url = new URL(window.location.href);
|
|
234
|
-
|
|
237
|
+
const urlKey = host.id ? "c-tabs-" + host.id : "c-tabs"; // R34-13
|
|
238
|
+
url.searchParams.set(urlKey, String(e.detail && e.detail.index));
|
|
235
239
|
window.history.replaceState(null, "", url.toString());
|
|
236
240
|
} catch (err) { /* no history API */ }
|
|
237
241
|
});
|
|
@@ -1170,7 +1174,11 @@ export function modalContain(host, open) {
|
|
|
1170
1174
|
for (const el of modalInerted) el.inert = false;
|
|
1171
1175
|
modalInerted.clear();
|
|
1172
1176
|
document.documentElement.style.overflow = modalSavedOverflow || "";
|
|
1173
|
-
window.scrollTo
|
|
1177
|
+
// jsdom defines window.scrollTo but logs "Not implemented" and throws;
|
|
1178
|
+
// skip it there. Real browsers restore the scroll position.
|
|
1179
|
+
if (typeof window.scrollTo === "function" && !navigator.userAgent.includes("jsdom")) {
|
|
1180
|
+
try { window.scrollTo(modalSavedX, modalSavedY); } catch (err) { /* jsdom */ }
|
|
1181
|
+
}
|
|
1174
1182
|
if (modalTrapWired) {
|
|
1175
1183
|
document.removeEventListener("keydown", modalTrapHandler);
|
|
1176
1184
|
modalTrapWired = false;
|
package/dist/wc/core.mjs
CHANGED
|
@@ -89,10 +89,83 @@
|
|
|
89
89
|
*/
|
|
90
90
|
const JSON_TYPE = Symbol("JSON");
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* R34-46: the complete, executable property-descriptor model. Every declared
|
|
94
|
+
* property resolves to exactly these fields — the ones a framework wrapper (or
|
|
95
|
+
* a generated declaration) needs to agree with the runtime about:
|
|
96
|
+
*
|
|
97
|
+
* attribute the reflected attribute name (or the property name).
|
|
98
|
+
* type String | Number | Boolean | JSON_TYPE (runtime constructor/sentinel).
|
|
99
|
+
* reflect assignment writes the attribute (default true). `false` keeps
|
|
100
|
+
* the value in an internal store and never touches the attribute.
|
|
101
|
+
* controlled the parent owns the value (value/checked/selected); the host
|
|
102
|
+
* never treats its own write as the source of truth.
|
|
103
|
+
* null "clear" removes the attribute on null/undefined (default), or
|
|
104
|
+
* "preserve" keeps the previous value.
|
|
105
|
+
* collection "none" (default) | "copy" (a JSON value is parsed fresh on
|
|
106
|
+
* each read, so a caller cannot mutate the host's state) | "mutate"
|
|
107
|
+
* (the same object reference is handed back).
|
|
108
|
+
* json the value is JSON-serialised (default: type === JSON_TYPE).
|
|
109
|
+
*/
|
|
110
|
+
export const PROPERTY_FIELDS = Object.freeze(["attribute", "type", "reflect", "controlled", "null", "collection", "json"]);
|
|
111
|
+
|
|
112
|
+
/** The artifact-facing type name for a runtime `type` (symbol/constructor). */
|
|
113
|
+
export function propertyTypeOf(type) {
|
|
114
|
+
if (type === Boolean) return "boolean";
|
|
115
|
+
if (type === Number) return "number";
|
|
116
|
+
if (type === JSON_TYPE) return "json";
|
|
117
|
+
return "string";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Resolve a raw `properties` entry to the complete descriptor, filling every
|
|
122
|
+
* field with its default so an unannotated property is still *complete* (the
|
|
123
|
+
* defaults are the correct semantics for the common case). The runtime install
|
|
124
|
+
* and the generators both call this, so the published metadata cannot disagree
|
|
125
|
+
* with what the element actually does.
|
|
126
|
+
*/
|
|
127
|
+
export function normalizeProperty(name, spec) {
|
|
128
|
+
const s = spec || {};
|
|
129
|
+
const type = s.type || String;
|
|
130
|
+
const json = s.json !== undefined ? !!s.json : type === JSON_TYPE;
|
|
131
|
+
let collection = s.collection;
|
|
132
|
+
if (collection !== "copy" && collection !== "mutate") collection = json ? "copy" : "none";
|
|
133
|
+
return {
|
|
134
|
+
name,
|
|
135
|
+
attribute: s.attribute || name,
|
|
136
|
+
type,
|
|
137
|
+
reflect: s.reflect !== undefined ? !!s.reflect : true,
|
|
138
|
+
controlled: !!s.controlled,
|
|
139
|
+
null: s.null === "preserve" ? "preserve" : "clear",
|
|
140
|
+
collection,
|
|
141
|
+
json,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The complete descriptor as a compact JSON-safe record (for generated
|
|
147
|
+
* artifacts). `name` is the map key and `attribute` is omitted when it equals
|
|
148
|
+
* the name, so the common case carries only the six behavioural fields; a
|
|
149
|
+
* consumer fills the two implied defaults (name = key, attribute = name).
|
|
150
|
+
*/
|
|
151
|
+
export function propertyDescriptor(name, spec) {
|
|
152
|
+
const d = normalizeProperty(name, spec);
|
|
153
|
+
const rec = {};
|
|
154
|
+
if (d.attribute !== name) rec.attribute = d.attribute;
|
|
155
|
+
rec.type = propertyTypeOf(d.type);
|
|
156
|
+
rec.reflect = d.reflect;
|
|
157
|
+
rec.controlled = d.controlled;
|
|
158
|
+
rec.null = d.null;
|
|
159
|
+
rec.collection = d.collection;
|
|
160
|
+
rec.json = d.json;
|
|
161
|
+
return rec;
|
|
162
|
+
}
|
|
163
|
+
|
|
92
164
|
/** Frozen event vocabulary with the public detail keys for each event. */
|
|
93
165
|
export const CONTOUR_EVENTS = Object.freeze({
|
|
94
166
|
"contour:activate": { payload: ["files", "label", "row", "value"], composed: true },
|
|
95
167
|
"contour:add": { payload: ["value"], composed: true },
|
|
168
|
+
"contour:annotation-action": { payload: ["action", "kind", "label"], composed: true },
|
|
96
169
|
"contour:activity-clear": { payload: [], composed: true },
|
|
97
170
|
"contour:activity-filter": { payload: ["unread"], composed: true },
|
|
98
171
|
"contour:activity-select": { payload: ["index", "text"], composed: true },
|
|
@@ -109,17 +182,20 @@
|
|
|
109
182
|
"contour:brush-start": { payload: ["end", "range", "start", "value"], composed: true },
|
|
110
183
|
"contour:brush-end": { payload: ["end", "range", "start", "value"], composed: true },
|
|
111
184
|
"contour:brush": { payload: ["end", "range", "start", "value"], composed: true },
|
|
112
|
-
"contour:change": { payload: ["checked", "color", "direction", "end", "files", "high", "index", "low", "month", "name", "paused", "query", "speed", "start", "unit", "value", "values", "year"], composed: true },
|
|
185
|
+
"contour:change": { payload: ["checked", "color", "direction", "draft", "end", "files", "high", "index", "low", "month", "name", "paused", "query", "speed", "start", "unit", "value", "values", "year"], composed: true },
|
|
113
186
|
"contour:collapse": { payload: ["collapsed"], composed: true },
|
|
114
187
|
"contour:cluster-toggle": { payload: ["count", "expanded"], composed: true },
|
|
115
188
|
"contour:clear": { payload: [], composed: true },
|
|
116
189
|
"contour:clear-all": { payload: [], composed: true },
|
|
117
190
|
"contour:close": { payload: ["count", "index", "label", "message", "open", "value"], composed: true },
|
|
118
191
|
"contour:copy": { payload: ["text"], composed: true },
|
|
192
|
+
"contour:default": { payload: ["default", "name"], composed: true },
|
|
193
|
+
"contour:duplicate": { payload: ["name"], composed: true },
|
|
119
194
|
"contour:apply": { payload: ["name"], composed: true },
|
|
120
195
|
"contour:dash-action": { payload: ["label"], composed: true },
|
|
121
196
|
"contour:diff-activate": { payload: ["kind", "text"], composed: true },
|
|
122
197
|
"contour:dismiss": { payload: ["label"], composed: true },
|
|
198
|
+
"contour:toast-action": { payload: ["action"], composed: true },
|
|
123
199
|
"contour:draw-start": { payload: ["mode"], composed: true },
|
|
124
200
|
"contour:drag": { payload: ["delta", "key", "value"], composed: true },
|
|
125
201
|
"contour:do-dont-activate": { payload: ["kind", "text"], composed: true },
|
|
@@ -131,7 +207,7 @@
|
|
|
131
207
|
"contour:filter": { payload: ["query"], composed: true },
|
|
132
208
|
"contour:filter-change": { payload: ["source", "filter"], composed: true },
|
|
133
209
|
"contour:error": { payload: ["src", "message", "name", "status"], composed: true },
|
|
134
|
-
"contour:export": { payload: ["format"], composed: true },
|
|
210
|
+
"contour:export": { payload: ["format", "scope", "count", "total", "filename", "crs", "provenance"], composed: true },
|
|
135
211
|
"contour:refresh": { payload: [], composed: true },
|
|
136
212
|
"contour:hide": { payload: [], composed: true, deprecated: "use contour:close instead" },
|
|
137
213
|
"contour:hover": { payload: ["row"], composed: true },
|
|
@@ -166,17 +242,26 @@
|
|
|
166
242
|
"contour:ready": { payload: ["version", "count"], composed: true },
|
|
167
243
|
"contour:read": { payload: ["label"], composed: true },
|
|
168
244
|
"contour:remove": { payload: ["key", "label", "name", "value"], composed: true },
|
|
245
|
+
"contour:rename": { payload: ["name"], composed: true },
|
|
246
|
+
"contour:share": { payload: ["name"], composed: true },
|
|
169
247
|
"contour:reorder": { payload: ["from", "to"], composed: true },
|
|
248
|
+
"contour:row-action": { payload: ["index", "item", "label"], composed: true },
|
|
170
249
|
"contour:range-change": { payload: ["value"], composed: true },
|
|
171
250
|
"contour:resize": { payload: ["column", "delta", "height", "value", "width"], composed: true },
|
|
172
251
|
"contour:retry": { payload: ["src"], composed: true },
|
|
252
|
+
"contour:chart-zoom": { payload: ["zoom", "panX", "panY"], composed: true },
|
|
253
|
+
"contour:brownout": { payload: ["level", "reason", "shed", "recovery"], composed: true },
|
|
254
|
+
"contour:offline": { payload: ["reason"], composed: true },
|
|
255
|
+
"contour:online": { payload: [], composed: true },
|
|
256
|
+
"contour:parse-error": { payload: ["src", "reason", "partial"], composed: true },
|
|
173
257
|
"contour:loop-change": { payload: ["loop"], composed: true },
|
|
174
258
|
"contour:pause": { payload: [], composed: true },
|
|
175
259
|
"contour:play": { payload: [], composed: true },
|
|
176
260
|
"contour:seek": { payload: ["progress", "value"], composed: true },
|
|
177
261
|
"contour:select": { payload: ["area", "col", "expanded", "href", "index", "key", "label", "labels", "level", "path", "range", "result", "row", "rows", "series", "value"], composed: true },
|
|
262
|
+
"contour:selection": { payload: ["mode", "value"], composed: true },
|
|
178
263
|
"contour:search": { payload: ["query"], composed: true },
|
|
179
|
-
"contour:spatial-filter": { payload: ["action", "mode", "operator"], composed: true },
|
|
264
|
+
"contour:spatial-filter": { payload: ["action", "count", "crs", "mode", "operator"], composed: true },
|
|
180
265
|
"contour:split-change": { payload: ["value", "width", "height"], composed: true },
|
|
181
266
|
"contour:speed-change": { payload: ["speed"], composed: true },
|
|
182
267
|
"contour:showcase-activate": { payload: ["title"], composed: true },
|
|
@@ -188,10 +273,10 @@
|
|
|
188
273
|
"contour:submit": { payload: ["submitting"], composed: true },
|
|
189
274
|
"contour:stream-state": { payload: ["running"], composed: true },
|
|
190
275
|
"contour:tab-change": { payload: ["index", "label"], composed: true },
|
|
191
|
-
"contour:theme-change": { payload: ["theme"], composed: true },
|
|
192
|
-
"contour:tick": { payload: ["frame"], composed: true },
|
|
276
|
+
"contour:theme-change": { payload: ["source", "theme", "value"], composed: true },
|
|
277
|
+
"contour:tick": { payload: ["frame", "interval", "timestamp"], composed: true },
|
|
193
278
|
"contour:time-change": { payload: ["progress", "value"], composed: true },
|
|
194
|
-
"contour:time-range-change": { payload: ["value"], composed: true },
|
|
279
|
+
"contour:time-range-change": { payload: ["end", "preset", "start", "timezone", "value"], composed: true },
|
|
195
280
|
"contour:toggle": { payload: ["collapsed", "expanded", "label", "open", "path", "playing"], composed: true },
|
|
196
281
|
"contour:view-enter": { payload: [], composed: true },
|
|
197
282
|
"contour:view-leave": { payload: [], composed: true },
|
|
@@ -377,7 +462,12 @@
|
|
|
377
462
|
"autocomplete", "levels", "submit-label",
|
|
378
463
|
"fields", "gap",
|
|
379
464
|
"flush", "head", "preview", "tags", "url",
|
|
380
|
-
|
|
465
|
+
// R34-154/156: the brownout detail and offline lifecycle are read by the
|
|
466
|
+
// base brownout/offline mixins, so they belong in the shared vocabulary.
|
|
467
|
+
"brownout-reason", "brownout-recovery", "offline",
|
|
468
|
+
// `custom-error` is written by the field itself (setCustomValidity) and
|
|
469
|
+
// observed per-class (forms-field), so it is NOT in the shared list: a
|
|
470
|
+
// shared entry plus the self-write is the re-entrant arm wc-contract flags.
|
|
381
471
|
];
|
|
382
472
|
|
|
383
473
|
/** Resolve an authored heading level while keeping the fallback valid. */
|
|
@@ -441,6 +531,10 @@
|
|
|
441
531
|
}
|
|
442
532
|
}
|
|
443
533
|
|
|
534
|
+
// R35: hosts that have already logged the contour:show/hide deprecation
|
|
535
|
+
// warning, so the warning fires once per host rather than on every emission.
|
|
536
|
+
let wcOverlayDeprecationWarned = null;
|
|
537
|
+
|
|
444
538
|
/**
|
|
445
539
|
* R24-93: Emit an overlay visibility event. `contour:open`/`contour:close`
|
|
446
540
|
* are the canonical pair; `contour:show`/`contour:hide` are deprecated
|
|
@@ -463,12 +557,18 @@
|
|
|
463
557
|
}
|
|
464
558
|
// Canonical event first.
|
|
465
559
|
host.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }));
|
|
466
|
-
// Deprecated alias with a one-minor deprecation warning
|
|
560
|
+
// Deprecated alias with a one-minor deprecation warning — once per host,
|
|
561
|
+
// not on every emission (R35: the per-emit warning spammed every open/close
|
|
562
|
+
// in tests and the guide).
|
|
467
563
|
const alias = isOpen ? "contour:show" : "contour:hide";
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
564
|
+
if (!wcOverlayDeprecationWarned) wcOverlayDeprecationWarned = new WeakSet();
|
|
565
|
+
if (!wcOverlayDeprecationWarned.has(host)) {
|
|
566
|
+
wcOverlayDeprecationWarned.add(host);
|
|
567
|
+
console.warn(
|
|
568
|
+
`[Contour] ${alias} is deprecated, use ${type} instead. ` +
|
|
569
|
+
`Will be removed in v2.0. (host: ${host.tagName || host.constructor.name})`
|
|
570
|
+
);
|
|
571
|
+
}
|
|
472
572
|
host.dispatchEvent(new CustomEvent(alias, { detail, bubbles: true, composed: true }));
|
|
473
573
|
}
|
|
474
574
|
|
|
@@ -571,8 +671,17 @@
|
|
|
571
671
|
const _ContourBaseParent = (typeof HTMLElement !== "undefined") ? HTMLElement : Object;
|
|
572
672
|
// R31-39: constructors whose property accessors are already installed.
|
|
573
673
|
const INSTALLED_PROPS = new WeakSet();
|
|
674
|
+
// R34-35: opt-in lifecycle diagnostics (page-wide, off by default).
|
|
675
|
+
let DIAG = typeof location !== "undefined" && /[?&]contour-diag\b/.test(location.search || "");
|
|
676
|
+
export function contourDiagnosticsEnabled() { return DIAG; }
|
|
677
|
+
export function setContourDiagnostics(on) { DIAG = !!on; }
|
|
574
678
|
export class ContourBase extends _ContourBaseParent {
|
|
575
679
|
static formAssociated = false;
|
|
680
|
+
// R35: a behavior-only subclass (a withResilience/withBrownout mixin that
|
|
681
|
+
// adds lifecycle without drawing markup) has nothing to render. Default to
|
|
682
|
+
// a no-op so connectedCallback/attributeChangedCallback do not throw
|
|
683
|
+
// "this.render is not a function" — subclasses that draw override it.
|
|
684
|
+
render() {}
|
|
576
685
|
constructor() {
|
|
577
686
|
super();
|
|
578
687
|
if (this.constructor.formAssociated && typeof this.attachInternals === "function") {
|
|
@@ -622,6 +731,24 @@
|
|
|
622
731
|
return this._contourRenderCount || 0;
|
|
623
732
|
}
|
|
624
733
|
|
|
734
|
+
/**
|
|
735
|
+
* R34-35: opt-in lifecycle diagnostic. Returns a snapshot of the host's
|
|
736
|
+
* render/observer/listener counters so a page (or a test) can see what the
|
|
737
|
+
* component is doing without a devtools trace. Enabled globally with
|
|
738
|
+
* `?contour-diag` (or `contourDiagnosticsEnabled()`); when off it is a pure
|
|
739
|
+
* read with no side effects.
|
|
740
|
+
*/
|
|
741
|
+
contourDiagnostics() {
|
|
742
|
+
return {
|
|
743
|
+
tag: this.tagName.toLowerCase(),
|
|
744
|
+
updateMode: this.constructor.updateMode,
|
|
745
|
+
renderCount: this.renderCount,
|
|
746
|
+
observed: [...(this.constructor.observedAttributes || [])],
|
|
747
|
+
hostListeners: this._contourHostListeners ? this._contourHostListeners.length : 0,
|
|
748
|
+
childNodes: this.childNodes.length,
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
|
|
625
752
|
/**
|
|
626
753
|
* Resolves one microtask after the last render has settled (render →
|
|
627
754
|
* enhance → restore for a re-render, render → enhance for a first paint).
|
|
@@ -658,6 +785,8 @@
|
|
|
658
785
|
|
|
659
786
|
_countRender() {
|
|
660
787
|
this._contourRenderCount = (this._contourRenderCount || 0) + 1;
|
|
788
|
+
// R34-35: opt-in lifecycle trace — one line per render, only when enabled.
|
|
789
|
+
if (DIAG) console.debug("[contour:diag] render", this.tagName.toLowerCase(), this._contourRenderCount);
|
|
661
790
|
}
|
|
662
791
|
|
|
663
792
|
// Install accessors once per class, so `el.value = 42` writes the attribute
|
|
@@ -683,12 +812,25 @@
|
|
|
683
812
|
}
|
|
684
813
|
return raw;
|
|
685
814
|
};
|
|
686
|
-
for (const [name,
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
815
|
+
for (const [name, rawSpec] of Object.entries(props)) {
|
|
816
|
+
// R34-46: resolve the complete descriptor; the runtime honours every
|
|
817
|
+
// field, and the defaults reproduce the historical behaviour exactly
|
|
818
|
+
// (reflect true, null clears, JSON copied) so an unannotated property
|
|
819
|
+
// is unchanged.
|
|
820
|
+
const spec = normalizeProperty(name, rawSpec);
|
|
821
|
+
const attr = spec.attribute;
|
|
822
|
+
const type = spec.type;
|
|
823
|
+
const reflect = spec.reflect;
|
|
824
|
+
const nullMode = spec.null;
|
|
825
|
+
const collection = spec.collection;
|
|
826
|
+
if (reflect) declared.add(attr);
|
|
827
|
+
const store = () => (this._contourPropValues || (this._contourPropValues = {}));
|
|
690
828
|
Object.defineProperty(ctor.prototype, name, {
|
|
691
829
|
get() {
|
|
830
|
+
if (!reflect) {
|
|
831
|
+
const s = store.call(this);
|
|
832
|
+
return name in s ? s[name] : (rawSpec && rawSpec.default !== undefined ? rawSpec.default : null);
|
|
833
|
+
}
|
|
692
834
|
const raw = this.getAttribute(attr);
|
|
693
835
|
// R31-37: a boolean property must agree with what render() draws.
|
|
694
836
|
// The render path reads flags through flagOn()/flagOnValue(), which
|
|
@@ -696,19 +838,40 @@
|
|
|
696
838
|
// `el.closable` true for `closable="false"` while the close button
|
|
697
839
|
// was absent. Presence with a false-y string is off.
|
|
698
840
|
if (type === Boolean) return flagOnValue(raw);
|
|
699
|
-
if (raw === null) return
|
|
841
|
+
if (raw === null) return rawSpec && rawSpec.default !== undefined ? rawSpec.default : null;
|
|
700
842
|
if (type === Number) { const n = Number(raw); return Number.isNaN(n) ? null : n; }
|
|
701
|
-
if (type === JSON_TYPE)
|
|
843
|
+
if (type === JSON_TYPE) {
|
|
844
|
+
if (collection === "mutate") { const s = store.call(this); if (name in s) return s[name]; }
|
|
845
|
+
return deserialize(raw);
|
|
846
|
+
}
|
|
702
847
|
return raw;
|
|
703
848
|
},
|
|
704
849
|
set(v) {
|
|
705
|
-
if (
|
|
706
|
-
|
|
707
|
-
|
|
850
|
+
if (!reflect) {
|
|
851
|
+
if (v === null || v === undefined) {
|
|
852
|
+
if (nullMode === "preserve") return;
|
|
853
|
+
delete store.call(this)[name];
|
|
854
|
+
} else store.call(this)[name] = v;
|
|
855
|
+
this.requestRender();
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
if (v === null || v === undefined) {
|
|
859
|
+
if (nullMode === "preserve") return;
|
|
860
|
+
this.removeAttribute(attr);
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
// R24-91: `false` removes a reflected attribute (a boolean's off
|
|
864
|
+
// state and the historical non-boolean behaviour agree here).
|
|
865
|
+
if (v === false) { this.removeAttribute(attr); return; }
|
|
866
|
+
if (type === Boolean) {
|
|
867
|
+
// route string negatives ("false", "0", "no", "off", …) through
|
|
868
|
+
// the flagOn vocabulary so el.disabled = "false" stays off.
|
|
708
869
|
if (!flagOnValue(v)) this.removeAttribute(attr);
|
|
709
870
|
else this.setAttribute(attr, "");
|
|
871
|
+
return;
|
|
710
872
|
}
|
|
711
|
-
|
|
873
|
+
if (type === JSON_TYPE && collection === "mutate") store.call(this)[name] = v;
|
|
874
|
+
this.setAttribute(attr, serialize(v));
|
|
712
875
|
},
|
|
713
876
|
configurable: true,
|
|
714
877
|
});
|
|
@@ -1086,15 +1249,33 @@
|
|
|
1086
1249
|
}
|
|
1087
1250
|
|
|
1088
1251
|
// Form lifecycle (form-associated components only). The platform calls these on <form>.reset(), on disable by a fieldse...
|
|
1252
|
+
// R35-001/003: the single capability-safe writers. jsdom's attachInternals()
|
|
1253
|
+
// returns an ElementInternals without setFormValue/setValidity; a direct call
|
|
1254
|
+
// throws an unhandled async TypeError (the unit lane then exits non-zero
|
|
1255
|
+
// despite every test passing). Every form family routes through these two
|
|
1256
|
+
// helpers instead of touching `this._internals` directly, so one partial
|
|
1257
|
+
// platform implementation degrades cleanly across the whole family.
|
|
1258
|
+
_setFormValue(value) {
|
|
1259
|
+
if (!this._internals || typeof this._internals.setFormValue !== "function") return;
|
|
1260
|
+
this._internals.setFormValue(value);
|
|
1261
|
+
}
|
|
1262
|
+
_setValidity(flags, msg) {
|
|
1263
|
+
if (!this._internals || typeof this._internals.setValidity !== "function") return;
|
|
1264
|
+
this._internals.setValidity(flags, msg);
|
|
1265
|
+
}
|
|
1089
1266
|
_syncFormValue() {
|
|
1090
|
-
|
|
1267
|
+
// jsdom's attachInternals() returns an ElementInternals without
|
|
1268
|
+
// setFormValue/setValidity; guard so a form-associated component under
|
|
1269
|
+
// test does not throw an unhandled async TypeError (the unit lane then
|
|
1270
|
+
// exits non-zero despite every test passing).
|
|
1271
|
+
if (!this._internals || typeof this._internals.setFormValue !== "function") return;
|
|
1091
1272
|
// A boolean group (a contour-radio-list) submits the *checked* item's
|
|
1092
1273
|
// value, so prefer the checked control over the first one found.
|
|
1093
1274
|
const ctl = this.querySelector("input:checked, textarea, select") || this.querySelector("input, textarea, select");
|
|
1094
1275
|
if (!ctl) return;
|
|
1095
1276
|
const boolean = ctl.type === "checkbox" || ctl.type === "radio";
|
|
1096
1277
|
const value = boolean ? (ctl.checked ? (ctl.value || "on") : null) : ctl.value;
|
|
1097
|
-
this.
|
|
1278
|
+
this._setFormValue(value);
|
|
1098
1279
|
this._syncValidity(this.hasAttribute("required") && !value);
|
|
1099
1280
|
}
|
|
1100
1281
|
|
|
@@ -1120,7 +1301,7 @@
|
|
|
1120
1301
|
if (v.tooShort) { flags.tooShort = true; msg = msg || "Value is too short."; }
|
|
1121
1302
|
if (v.badInput) { flags.badInput = true; msg = msg || "Invalid input."; }
|
|
1122
1303
|
}
|
|
1123
|
-
this.
|
|
1304
|
+
this._setValidity(flags, msg);
|
|
1124
1305
|
this._setCustomState("data-invalid", Object.keys(flags).length > 0);
|
|
1125
1306
|
}
|
|
1126
1307
|
|
|
@@ -1204,10 +1385,20 @@
|
|
|
1204
1385
|
|
|
1205
1386
|
// Keep internals in step with the group. Checking radio B fires `change` on B only — the deselected host A hears nothin...
|
|
1206
1387
|
_wireFormData() {
|
|
1207
|
-
if (!this._internals
|
|
1388
|
+
if (!this._internals) return;
|
|
1389
|
+
// R34-45: rebind when the form owner changes. The `form` attribute can be
|
|
1390
|
+
// set, removed or changed after the host is connected (and a host can be
|
|
1391
|
+
// moved between forms); the platform updates `_internals.form` and fires
|
|
1392
|
+
// `formAssociatedCallback`, but listeners added for the previous owner
|
|
1393
|
+
// would keep firing on the old form and never on the new one. `_wiredForm`
|
|
1394
|
+
// is the owner the current listeners are bound to; a mismatch detaches the
|
|
1395
|
+
// old listeners before binding the new, so exactly one form is listened to.
|
|
1208
1396
|
const form = this._internals.form;
|
|
1397
|
+
if (form === this._wiredForm) return; // already bound to this owner
|
|
1398
|
+
if (this._formDataCleanup) { this._formDataCleanup(); this._formDataCleanup = null; }
|
|
1399
|
+
this._wiredForm = form || null;
|
|
1400
|
+
this._wiredFormData = !!form;
|
|
1209
1401
|
if (!form) return;
|
|
1210
|
-
this._wiredFormData = true;
|
|
1211
1402
|
const myName = this.getAttribute("name");
|
|
1212
1403
|
const onFormChange = (e) => {
|
|
1213
1404
|
const t = e.target;
|
|
@@ -1216,10 +1407,28 @@
|
|
|
1216
1407
|
form.addEventListener("change", onFormChange);
|
|
1217
1408
|
const onFormData = () => this._syncFormValue();
|
|
1218
1409
|
form.addEventListener("formdata", onFormData);
|
|
1219
|
-
|
|
1410
|
+
this._formDataCleanup = () => {
|
|
1220
1411
|
form.removeEventListener("change", onFormChange);
|
|
1221
1412
|
form.removeEventListener("formdata", onFormData);
|
|
1222
|
-
}
|
|
1413
|
+
};
|
|
1414
|
+
// One onDispose per mount (not per rebind): it runs the *current* cleanup
|
|
1415
|
+
// and resets the guard so a reconnect re-registers against the new owner.
|
|
1416
|
+
if (!this._formDataDisposeWired) {
|
|
1417
|
+
this._formDataDisposeWired = true;
|
|
1418
|
+
onDispose(this, () => {
|
|
1419
|
+
if (this._formDataCleanup) { this._formDataCleanup(); this._formDataCleanup = null; }
|
|
1420
|
+
this._wiredForm = null;
|
|
1421
|
+
this._wiredFormData = false;
|
|
1422
|
+
this._formDataDisposeWired = false;
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
// The form owner changed (the `form` attribute was set/removed/changed, or
|
|
1428
|
+
// the host was moved between forms). Rebind the form listeners to the new
|
|
1429
|
+
// owner (R34-45); a no-op for non-form components.
|
|
1430
|
+
formAssociatedCallback() {
|
|
1431
|
+
this._wireFormData();
|
|
1223
1432
|
}
|
|
1224
1433
|
|
|
1225
1434
|
// User-dirty value tracking (R20 T-02). The restore path only fills controls a render left empty, so a host with an aut...
|
|
@@ -1294,6 +1503,27 @@
|
|
|
1294
1503
|
});
|
|
1295
1504
|
}
|
|
1296
1505
|
|
|
1506
|
+
// R33-42: state serialization. `toJSON()` captures the author-controlled
|
|
1507
|
+
// surface (the observed attributes that are present) as a plain object;
|
|
1508
|
+
// `fromJSON(obj)` restores it. This is the state a host copies, shares or
|
|
1509
|
+
// undoes — it deliberately excludes internal/generated state.
|
|
1510
|
+
toJSON() {
|
|
1511
|
+
const out = {};
|
|
1512
|
+
for (const attr of this.constructor.observed || []) {
|
|
1513
|
+
const v = this.getAttribute(attr);
|
|
1514
|
+
if (v !== null) out[attr] = v;
|
|
1515
|
+
}
|
|
1516
|
+
return out;
|
|
1517
|
+
}
|
|
1518
|
+
fromJSON(obj) {
|
|
1519
|
+
if (!obj || typeof obj !== "object") return this;
|
|
1520
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1521
|
+
if (value === null || value === undefined) this.removeAttribute(key);
|
|
1522
|
+
else this.setAttribute(key, String(value));
|
|
1523
|
+
}
|
|
1524
|
+
return this;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1297
1527
|
// R31-15: the light layer no longer writes `part=` on generated nodes.
|
|
1298
1528
|
// `::part()` matches only shadow parts, so the attribute was inert on every
|
|
1299
1529
|
// light component while `_applyParts` scanned every `[class]` on every
|
|
@@ -1370,11 +1600,29 @@
|
|
|
1370
1600
|
return class extends Base {
|
|
1371
1601
|
static get observed() {
|
|
1372
1602
|
const base = (super.observed && Array.isArray(super.observed)) ? super.observed : [];
|
|
1373
|
-
const extra = ["brownout", "brownout-level"];
|
|
1603
|
+
const extra = ["brownout", "brownout-level", "brownout-reason", "brownout-recovery"];
|
|
1374
1604
|
return Array.from(new Set(base.concat(extra)));
|
|
1375
1605
|
}
|
|
1376
1606
|
brownoutLevel() { return super.brownoutLevel ? super.brownoutLevel() : (parseInt(this.getAttribute("brownout-level") || this.getAttribute("brownout") || "0", 10) || 0); }
|
|
1377
1607
|
shed(kind, threshold) { return this.brownoutLevel() >= (threshold || 1); }
|
|
1608
|
+
// R34-154: the degraded-state contract — why it is degraded, what was
|
|
1609
|
+
// shed, and the action that recovers it — published as one event so a
|
|
1610
|
+
// shell can badge the widget and a consumer can offer the recovery.
|
|
1611
|
+
brownoutDetail() {
|
|
1612
|
+
const level = this.brownoutLevel();
|
|
1613
|
+
return {
|
|
1614
|
+
level,
|
|
1615
|
+
reason: this.getAttribute("brownout-reason") || "",
|
|
1616
|
+
shed: level > 0,
|
|
1617
|
+
recovery: this.getAttribute("brownout-recovery") || "",
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
attributeChangedCallback(name, old, val) {
|
|
1621
|
+
if (super.attributeChangedCallback) super.attributeChangedCallback(name, old, val);
|
|
1622
|
+
if (name === "brownout" || name === "brownout-level" || name === "brownout-reason" || name === "brownout-recovery") {
|
|
1623
|
+
this.dispatchEvent(new CustomEvent("contour:brownout", { bubbles: true, composed: true, detail: this.brownoutDetail() }));
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1378
1626
|
};
|
|
1379
1627
|
}
|
|
1380
1628
|
/** Pure helper: compute brownout level from an attribute bag (framework-neutral). */
|
|
@@ -1426,9 +1674,13 @@
|
|
|
1426
1674
|
export function formatValue(value, format, locale, unit) {
|
|
1427
1675
|
if (!format) return value;
|
|
1428
1676
|
const loc = locale || (typeof navigator !== "undefined" && navigator.language) || "en";
|
|
1429
|
-
|
|
1677
|
+
// R34-59: a JSON format string is Intl options, so a consumer can name the
|
|
1678
|
+
// calendar system, numbering system and time zone (DST is resolved by Intl
|
|
1679
|
+
// for the named zone) rather than being stuck with the runtime defaults.
|
|
1680
|
+
const jsonOpts = (() => { if (typeof format === "string" && format.trim()[0] === "{") { try { return JSON.parse(format); } catch (e) { return null; } } return null; })();
|
|
1681
|
+
if (format === "date" || format === "time" || (jsonOpts && ("dateStyle" in jsonOpts || "timeStyle" in jsonOpts || "calendar" in jsonOpts || "timeZone" in jsonOpts))) {
|
|
1430
1682
|
try {
|
|
1431
|
-
const opts = format === "time" ? { timeStyle: "short" } : undefined;
|
|
1683
|
+
const opts = jsonOpts || (format === "time" ? { timeStyle: "short" } : undefined);
|
|
1432
1684
|
return new Intl.DateTimeFormat(loc, opts).format(new Date(value));
|
|
1433
1685
|
} catch (e) { return value; }
|
|
1434
1686
|
}
|
|
@@ -1460,6 +1712,29 @@
|
|
|
1460
1712
|
catch (e) { return value; }
|
|
1461
1713
|
}
|
|
1462
1714
|
|
|
1715
|
+
/**
|
|
1716
|
+
* R34-59: the locale's first day of the week (0=Sunday … 6=Saturday), for a
|
|
1717
|
+
* calendar or date grid that must not assume Sunday. Uses `Intl.Locale`
|
|
1718
|
+
* `weekInfo`/`firstDay` where the platform exposes it, else a small region
|
|
1719
|
+
* table, else 0. DST and calendar-system edges are Intl's job; this is only
|
|
1720
|
+
* the week-start seam a grid needs.
|
|
1721
|
+
*/
|
|
1722
|
+
export function weekStart(locale) {
|
|
1723
|
+
const loc = locale || (typeof navigator !== "undefined" && navigator.language) || "en";
|
|
1724
|
+
try {
|
|
1725
|
+
const info = new Intl.Locale(loc).weekInfo || new Intl.Locale(loc).getWeekInfo?.();
|
|
1726
|
+
if (info && typeof info.firstDay === "number") return info.firstDay % 7;
|
|
1727
|
+
const fd = new Intl.Locale(loc).firstDay;
|
|
1728
|
+
if (typeof fd === "number") return fd % 7;
|
|
1729
|
+
} catch (e) { /* older platform without weekInfo */ }
|
|
1730
|
+
// Region fallback: most of the world starts Monday (1); the US/Canada/JP
|
|
1731
|
+
// start Sunday (0); much of the Middle East starts Saturday (6).
|
|
1732
|
+
const region = (() => { try { return new Intl.Locale(loc).region; } catch (e) { return ""; } })();
|
|
1733
|
+
if (/^(US|CA|JP|IL|MO|PH|IN|TW|HK|KR|ZA|NG|KE|GH|ET|UG|TZ|ZW|ZM|MW|NA|BW|LS|SZ|SS|SD|MU|SC|AO|MZ|CV|ST|GW|GQ|GA|CF|TD|CD|CG|CM|CI|BJ|BF|ML|NE|SN|TG|LR|SL|GM|GN|GW|MR|DJ|SO|ER|BI|RW|AF|IR|SY|IQ|JO|LB|PS|YE|OM|AE|QA|BH|KW|SA|EG|LY|TN|DZ|MA|EH|SU|NP|BD|PK|MM|LA|KH|TH|VN|MY|SG|BN|TL|PG|FJ|SB|VU|WS|TO|KI|TV|NR|MH|FM|PW|CL|PE|CO|VE|EC|GY|SR|PY|UY|BO|AR|CR|DO|GT|HN|NI|PA|SV|BZ|JM|TT|GD|LC|VC|BB|BS|KN|DM|AG|AW|CW|SX|BQ|AI|GP|MQ|MS|KY|TC|VG|PR|VI|GU|AS|MP|UM|FK|GS|IO|TF|HM|NF|CX|CC|AQ|BV|HK|MO|TW|KR|KP|JP)$/.test(region)) return 0;
|
|
1734
|
+
if (/^(IL|IR|AF|BD|PK|MM|NP|BT|MV|SD|DJ|SO|YE|OM|QA|BH|KW|AE|SA|JO|LB|SY|IQ|PS|EG|LY|TN|DZ|MA|EH)$/.test(region)) return 6;
|
|
1735
|
+
return 1;
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1463
1738
|
// Shared keyboard navigation for roving-tabindex patterns. Options: { wrap=true, enter=true, homeEnd=false, onKey(key,idx,item)→truthy prevents default, onNavigate(newIdx), rtl (defaults to dir attr) }.
|
|
1464
1739
|
/** Navigate a roving-tabindex group with arrow keys, Home/End, Enter/Space. */
|
|
1465
1740
|
export function navKey(e, items, { wrap = true, enter = true, homeEnd = false, onKey, onNavigate, rtl } = {}) {
|