contour-ds 1.11.0 → 1.12.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/dist/build-manifest.json +30 -30
- package/dist/contour-wc-core.esm.js +1 -1
- package/dist/contour-wc-core.esm.min.js +1 -1
- package/dist/contour-wc-dashboard.esm.js +81 -9
- package/dist/contour-wc-dashboard.esm.min.js +1 -1
- package/dist/contour-wc-data.esm.js +81 -9
- package/dist/contour-wc-data.esm.min.js +1 -1
- package/dist/contour-wc-map.esm.js +38 -5
- package/dist/contour-wc-map.esm.min.js +1 -1
- package/dist/contour-wc.esm.js +120 -15
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +120 -15
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.components.json +88 -16
- package/dist/contour.css +48 -0
- package/dist/contour.d.ts +2 -2
- package/dist/contour.html-data.json +14 -2
- package/dist/contour.min.css +1 -1
- package/dist/contour.single.html +1 -1
- package/dist/contour.single.min.css +1 -1
- package/dist/contour.web-types.json +14 -2
- package/dist/custom-elements.json +54 -0
- 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 +1 -1
- 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 +2 -2
- 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 +1 -1
- package/dist/docs/type.md +1 -1
- package/dist/docs/webcomponents.md +1 -1
- package/dist/register.js +15 -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/data-chart.mjs +81 -9
- package/dist/wc/index.mjs +1 -1
- package/dist/wc/map.mjs +38 -5
- package/integrations/libreship/contract.json +6 -3
- package/package.json +2 -1
|
@@ -3107,18 +3107,24 @@ class ContourReferenceRule extends ContourBase {
|
|
|
3107
3107
|
|
|
3108
3108
|
/**
|
|
3109
3109
|
* Small Multiples (R33-45): a grid of charts that share axes. Attributes:
|
|
3110
|
-
* `columns` (grid column count) and `
|
|
3111
|
-
* responsive grid; the group is the shared-axis frame, the
|
|
3112
|
-
* individual multiples.
|
|
3110
|
+
* `columns` (grid column count), `label` and `multiples`. Slotted charts are
|
|
3111
|
+
* laid out in a responsive grid; the group is the shared-axis frame, the
|
|
3112
|
+
* children are the individual multiples.
|
|
3113
3113
|
*
|
|
3114
|
-
*
|
|
3115
|
-
* `
|
|
3116
|
-
*
|
|
3117
|
-
*
|
|
3114
|
+
* Data contract (U4): `multiples` is a JSON array of
|
|
3115
|
+
* `{ label, points, key?, value? }`. When it is present the frame renders one
|
|
3116
|
+
* cell per entry — a caption and an inline sparkline — so a consumer can drive
|
|
3117
|
+
* the grid from data without hand-authoring a child per multiple. Each cell is
|
|
3118
|
+
* a focusable `role="button"` that emits `contour:select` with
|
|
3119
|
+
* `{ index, key, label, value }`, where `value` defaults to the entry's last
|
|
3120
|
+
* finite point. When `multiples` is absent the frame is layout-only and slotted
|
|
3121
|
+
* children supply the marks, so the two forms are alternatives: a child that
|
|
3122
|
+
* selects bubbles its own `contour:select` through the frame, and a page still
|
|
3123
|
+
* listens once.
|
|
3118
3124
|
*/
|
|
3119
3125
|
class ContourSmallMultiples extends ContourBase {
|
|
3120
|
-
static get observed() { return ["columns", "label"]; }
|
|
3121
|
-
static get properties() { return { columns: { attribute: "columns", type: Number }, label: { attribute: "label" } }; }
|
|
3126
|
+
static get observed() { return ["columns", "label", "multiples"]; }
|
|
3127
|
+
static get properties() { return { columns: { attribute: "columns", type: Number }, label: { attribute: "label" }, multiples: { attribute: "multiples" } }; }
|
|
3122
3128
|
render() {
|
|
3123
3129
|
this.classList.add("c-small-multiples");
|
|
3124
3130
|
if (!this.hasAttribute("role")) this.setAttribute("role", "group");
|
|
@@ -3126,6 +3132,72 @@ class ContourSmallMultiples extends ContourBase {
|
|
|
3126
3132
|
if (label) this.setAttribute("aria-label", label); else this.removeAttribute("aria-label");
|
|
3127
3133
|
const cols = this.getAttribute("columns");
|
|
3128
3134
|
if (cols) this.style.setProperty("--sm-cols", cols); else this.style.removeProperty("--sm-cols");
|
|
3135
|
+
this._smEntries = null;
|
|
3136
|
+
const raw = this.getAttribute("multiples");
|
|
3137
|
+
if (!raw) return;
|
|
3138
|
+
let parsed;
|
|
3139
|
+
try { parsed = JSON.parse(raw); } catch (e) { return; } // malformed JSON leaves the frame layout-only
|
|
3140
|
+
if (!Array.isArray(parsed)) return;
|
|
3141
|
+
this._smEntries = parsed;
|
|
3142
|
+
parsed.forEach((entry, i) => this._renderCell(entry, i));
|
|
3143
|
+
}
|
|
3144
|
+
_renderCell(entry, index) {
|
|
3145
|
+
const item = entry && typeof entry === "object" ? entry : {};
|
|
3146
|
+
const points = Array.isArray(item.points) ? item.points.filter(Number.isFinite) : [];
|
|
3147
|
+
const name = item.label != null ? String(item.label) : `Multiple ${index + 1}`;
|
|
3148
|
+
const cell = document.createElement("figure");
|
|
3149
|
+
cell.className = "c-small-multiples__cell";
|
|
3150
|
+
cell.setAttribute("data-sm-index", String(index));
|
|
3151
|
+
cell.setAttribute("role", "button");
|
|
3152
|
+
cell.setAttribute("tabindex", "0");
|
|
3153
|
+
cell.setAttribute("aria-label", name);
|
|
3154
|
+
const cap = document.createElement("figcaption");
|
|
3155
|
+
cap.className = "c-small-multiples__label";
|
|
3156
|
+
cap.textContent = name;
|
|
3157
|
+
cell.appendChild(cap);
|
|
3158
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
3159
|
+
svg.setAttribute("class", "c-small-multiples__mark");
|
|
3160
|
+
svg.setAttribute("viewBox", "0 0 100 30");
|
|
3161
|
+
svg.setAttribute("preserveAspectRatio", "none");
|
|
3162
|
+
svg.setAttribute("aria-hidden", "true");
|
|
3163
|
+
if (points.length >= 2) {
|
|
3164
|
+
const min = Math.min(...points);
|
|
3165
|
+
const range = (Math.max(...points) - min) || 1;
|
|
3166
|
+
const n = points.length;
|
|
3167
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
3168
|
+
path.setAttribute("d", points.map((p, i) => (i === 0 ? "M" : "L") + " " + (i * 100 / (n - 1)) + " " + (30 - ((p - min) / range) * 30)).join(" "));
|
|
3169
|
+
svg.appendChild(path);
|
|
3170
|
+
}
|
|
3171
|
+
cell.appendChild(svg);
|
|
3172
|
+
this.appendChild(cell);
|
|
3173
|
+
}
|
|
3174
|
+
enhance() {
|
|
3175
|
+
if (this._wiredSmallMultiples) return;
|
|
3176
|
+
this._wiredSmallMultiples = true;
|
|
3177
|
+
// Delegated on the host (rule 12): render() rebuilds the cells on every
|
|
3178
|
+
// attribute change, so a listener bound to a cell would be lost.
|
|
3179
|
+
const select = (e) => {
|
|
3180
|
+
const cell = e.target && e.target.closest ? e.target.closest(".c-small-multiples__cell[data-sm-index]") : null;
|
|
3181
|
+
if (!cell || !this.contains(cell)) return;
|
|
3182
|
+
const index = Number(cell.getAttribute("data-sm-index"));
|
|
3183
|
+
const entry = (this._smEntries || [])[index] || {};
|
|
3184
|
+
const points = Array.isArray(entry.points) ? entry.points.filter(Number.isFinite) : [];
|
|
3185
|
+
const value = entry.value != null ? entry.value : (points.length ? points[points.length - 1] : null);
|
|
3186
|
+
this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: {
|
|
3187
|
+
index,
|
|
3188
|
+
key: entry.key != null ? entry.key : null,
|
|
3189
|
+
label: entry.label != null ? String(entry.label) : "",
|
|
3190
|
+
value,
|
|
3191
|
+
} }));
|
|
3192
|
+
};
|
|
3193
|
+
this.addEventListener("click", select);
|
|
3194
|
+
this.addEventListener("keydown", (e) => {
|
|
3195
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
3196
|
+
const cell = e.target && e.target.closest ? e.target.closest(".c-small-multiples__cell[data-sm-index]") : null;
|
|
3197
|
+
if (!cell || !this.contains(cell)) return;
|
|
3198
|
+
e.preventDefault();
|
|
3199
|
+
select(e);
|
|
3200
|
+
});
|
|
3129
3201
|
}
|
|
3130
3202
|
}
|
|
3131
3203
|
define("contour-small-multiples", ContourSmallMultiples);
|