@mattilsynet/design 2.1.12 → 2.2.1
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/mtds/_virtual/client.js +6 -0
- package/mtds/_virtual/client.js.map +1 -0
- package/mtds/_virtual/client2.js +5 -0
- package/mtds/_virtual/client2.js.map +1 -0
- package/mtds/_virtual/index.js +5 -0
- package/mtds/_virtual/index.js.map +1 -0
- package/mtds/_virtual/react-dom-client.development.js +5 -0
- package/mtds/_virtual/react-dom-client.development.js.map +1 -0
- package/mtds/_virtual/react-dom-client.production.js +5 -0
- package/mtds/_virtual/react-dom-client.production.js.map +1 -0
- package/mtds/_virtual/scheduler.development.js +5 -0
- package/mtds/_virtual/scheduler.development.js.map +1 -0
- package/mtds/_virtual/scheduler.production.js +5 -0
- package/mtds/_virtual/scheduler.production.js.map +1 -0
- package/mtds/analytics/analytics.js +16 -14
- package/mtds/analytics/analytics.js.map +1 -1
- package/mtds/app/app-observer.js +1 -1
- package/mtds/app/app-toggle.js +10 -26
- package/mtds/app/app-toggle.js.map +1 -1
- package/mtds/app/app-toggle2.js +26 -10
- package/mtds/app/app-toggle2.js.map +1 -1
- package/mtds/app/app.js +4 -3
- package/mtds/app/app.js.map +1 -1
- package/mtds/button/button.d.ts +2 -1
- package/mtds/button/button.js +12 -12
- package/mtds/button/button.js.map +1 -1
- package/mtds/chart/chart-element.d.ts +5 -4
- package/mtds/chart/chart-element.js +111 -0
- package/mtds/chart/chart-element.js.map +1 -0
- package/mtds/chart/chart.d.ts +6 -0
- package/mtds/chart/chart.module.css.js +325 -0
- package/mtds/chart/chart.module.css.js.map +1 -0
- package/mtds/chart/chart.stories.d.ts +10 -0
- package/mtds/external/@u-elements/u-details/dist/u-details.js +1 -1
- package/mtds/external/@u-elements/u-details/dist/u-details.js.map +1 -1
- package/mtds/external/react-dom/cjs/react-dom-client.development.js +15323 -0
- package/mtds/external/react-dom/cjs/react-dom-client.development.js.map +1 -0
- package/mtds/external/react-dom/cjs/react-dom-client.production.js +9409 -0
- package/mtds/external/react-dom/cjs/react-dom-client.production.js.map +1 -0
- package/mtds/external/react-dom/client.js +24 -0
- package/mtds/external/react-dom/client.js.map +1 -0
- package/mtds/external/scheduler/cjs/scheduler.development.js +237 -0
- package/mtds/external/scheduler/cjs/scheduler.development.js.map +1 -0
- package/mtds/external/scheduler/cjs/scheduler.production.js +234 -0
- package/mtds/external/scheduler/cjs/scheduler.production.js.map +1 -0
- package/mtds/external/scheduler/index.js +11 -0
- package/mtds/external/scheduler/index.js.map +1 -0
- package/mtds/field/field.js +36 -35
- package/mtds/field/field.js.map +1 -1
- package/mtds/illustrations/bunny.svg +1 -0
- package/mtds/illustrations/eagle.svg +1 -0
- package/mtds/illustrations/index.json +22 -2
- package/mtds/illustrations/moose.svg +1 -0
- package/mtds/illustrations/polarbear.svg +1 -0
- package/mtds/illustrations/puppy.svg +1 -0
- package/mtds/index.d.ts +7 -5
- package/mtds/index.iife.js +335 -15
- package/mtds/index.js +19 -15
- package/mtds/index.js.map +1 -1
- package/mtds/package.json.js +1 -1
- package/mtds/pagination/pagination.js +3 -2
- package/mtds/pagination/pagination.js.map +1 -1
- package/mtds/popover/popover-observer.js +24 -23
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/react.d.ts +1 -0
- package/mtds/react.js +16 -14
- package/mtds/react.js.map +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +41 -40
- package/mtds/styles.module.css.js +100 -92
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/table/table-observer.js +20 -15
- package/mtds/table/table-observer.js.map +1 -1
- package/mtds/table/table.d.ts +2 -2
- package/mtds/table/table.js.map +1 -1
- package/mtds/table/table.stories.d.ts +5 -4
- package/mtds/tailwind.css +1 -0
- package/mtds/toast/toast-helper.d.ts +11 -0
- package/mtds/toast/toast-helper.js +14 -0
- package/mtds/toast/toast-helper.js.map +1 -0
- package/mtds/toast/toast-observer.js +19 -0
- package/mtds/toast/toast-observer.js.map +1 -0
- package/mtds/toast/toast.d.ts +10 -2
- package/mtds/toast/toast.js +39 -0
- package/mtds/toast/toast.js.map +1 -0
- package/mtds/toast/toast.stories.d.ts +19 -0
- package/mtds/utils.d.ts +0 -7
- package/mtds/utils.js +36 -37
- package/mtds/utils.js.map +1 -1
- package/package.json +21 -14
- package/mtds/chart/chart-doughnut.d.ts +0 -1
- /package/mtds/{chart/chart-axis.d.ts → toast/toast-observer.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-element.js","sources":["../../designsystem/chart/chart-element.ts"],"sourcesContent":["import type * as ReactTypes from \"react\";\nimport { attr, IS_BROWSER, useId } from \"../utils\";\nimport css from \"./chart.module.css?raw\";\n\nconst MTDSElement =\n\ttypeof HTMLElement === \"undefined\"\n\t\t? (class {} as typeof HTMLElement)\n\t\t: HTMLElement;\n\nexport type ReactChart = ReactTypes.JSX.IntrinsicElements[\"div\"] & {\n\tclass?: string;\n};\n\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicElements {\n\t\t\t\"mtds-chart\": ReactChart;\n\t\t}\n\t}\n}\n\nconst xmlns = \"http://www.w3.org/2000/svg\";\nexport class MTDSChart extends MTDSElement {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" });\n\t}\n\tconnectedCallback() {\n\t\tlet max = 0;\n\t\tlet rowMax = 0;\n\t\tconst table = this.querySelector(\"table\");\n\t\tconst data = Array.from(table?.rows || [], (row, isTbody) => {\n\t\t\tlet rowTotal = 0;\n\t\t\tconst values = Array.from(row.cells, (cell, isTd) => {\n\t\t\t\tconst val = cell.textContent.trim() || \"\";\n\t\t\t\tconst num = Number(val) || 0;\n\t\t\t\tif (isTbody && isTd) {\n\t\t\t\t\tmax = Math.max(max, num);\n\t\t\t\t\trowTotal += num;\n\t\t\t\t}\n\t\t\t\treturn val;\n\t\t\t});\n\t\t\trowMax = Math.max(rowMax, rowTotal);\n\t\t\treturn values;\n\t\t});\n\n\t\tconst [variant, type] = (attr(this, \"data-variant\") || \"bar\").split(\"-\");\n\t\tconst isVertical = variant === \"column\";\n\t\tconst isStacked = type === \"stacked\";\n\n\t\tconst smoothing = Number(type || 10) || 0;\n\t\tconst style = createElement(\"style\", {}, css);\n\t\tconst axis = createElement(\"div\", {\n\t\t\t\"aria-label\": data[0][0] || null,\n\t\t\tclass: \"axis\",\n\t\t\trole: \"figure\",\n\t\t});\n\t\tconst groups = createElement(\"div\", { class: \"axisGroups\" });\n\t\tconst steps = toSteps(isStacked ? rowMax : max);\n\t\tconst legend = createElement(\"div\", { class: \"legends\" });\n\t\tconst legends = data\n\t\t\t.slice(1)\n\t\t\t.map(([text], index) =>\n\t\t\t\tcreateElement(\"div\", { class: `legend color-${index + 1}` }, text),\n\t\t\t);\n\t\tconst legendIds = legends.map(useId);\n\n\t\taxis.classList.toggle(\"is-horizontal\", !isVertical);\n\t\taxis.classList.toggle(\"is-vertical\", isVertical);\n\t\taxis.classList.toggle(\"is-stacked\", isStacked);\n\t\taxis.style.setProperty(\"--groups\", `${data.length - 1}`);\n\t\taxis.style.setProperty(\"--total\", `${steps.total}`);\n\t\taxis.append(steps.el, groups);\n\n\t\tif (variant === \"bar\" || variant === \"column\") {\n\t\t\tdata[0].forEach((groupLabel, index) => {\n\t\t\t\tif (index === 0) return; // Skip first column internally so index matches rest of data\n\t\t\t\tconst group = createElement(\"div\", { class: \"axisGroup\" });\n\t\t\t\tconst content = createElement(\"div\", { class: \"axisGroupContent\" });\n\t\t\t\tconst label = createElement(\"div\", { class: \"axisLabel\" }, groupLabel);\n\t\t\t\tgroup.append(content, label);\n\t\t\t\tgroups.append(group);\n\n\t\t\t\tdata.slice(1).forEach((values, legendIndex) => {\n\t\t\t\t\tcontent.append(\n\t\t\t\t\t\tcreateElement(\"div\", {\n\t\t\t\t\t\t\t\"aria-describedby\": legendIds[legendIndex],\n\t\t\t\t\t\t\tclass: `bar color-${legendIndex + 1}`,\n\t\t\t\t\t\t\trole: \"img\",\n\t\t\t\t\t\t\tstyle: `--value: ${values[index]}`,\n\t\t\t\t\t\t\ttabindex: \"0\",\n\t\t\t\t\t\t\ttitle: `${values[0]}: ${values[index]}`,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\tif (variant === \"line\" || variant === \"area\") {\n\t\t\tconst group = createElement(\"div\", { class: \"axisGroup\" });\n\t\t\tdata.slice(1).forEach(([legend, ...values], legendIndex) => {\n\t\t\t\tconst lineContainer = createElement(\"div\", {\n\t\t\t\t\tclass: `lineContainer color-${legendIndex + 1}`,\n\t\t\t\t\trole: \"list\",\n\t\t\t\t});\n\n\t\t\t\tconst line = document.createElementNS(xmlns, \"svg\");\n\t\t\t\tattr(line, \"aria-hidden\", \"true\");\n\t\t\t\tattr(line, \"preserveAspectRatio\", \"none\");\n\t\t\t\tattr(line, \"viewBox\", \"0 0 100 100\");\n\n\t\t\t\tconst path = toPath(\n\t\t\t\t\tvalues.map((value, index, { length }) => [\n\t\t\t\t\t\t(100 / (length - 1)) * index,\n\t\t\t\t\t\t100 - (Number(value) / steps.total) * 100,\n\t\t\t\t\t]),\n\t\t\t\t\tsmoothing / 100,\n\t\t\t\t);\n\n\t\t\t\tconst linePath = document.createElementNS(xmlns, \"path\");\n\t\t\t\tattr(linePath, \"class\", \"line\");\n\t\t\t\tattr(linePath, \"d\", path);\n\t\t\t\tattr(linePath, \"fill\", \"none\");\n\t\t\t\tattr(linePath, \"stroke\", \"currentColor\");\n\t\t\t\tconst lineBorder = linePath.cloneNode(true) as SVGPathElement;\n\t\t\t\tattr(lineBorder, \"class\", \"lineBorder\");\n\n\t\t\t\tif (variant === \"area\") {\n\t\t\t\t\tconst lineShade = linePath.cloneNode(true) as SVGPathElement;\n\t\t\t\t\tattr(lineShade, \"d\", `M-100,100 L${path.slice(1)}L200,100`);\n\t\t\t\t\tattr(lineShade, \"class\", \"lineShade\");\n\t\t\t\t\tline.append(lineShade);\n\t\t\t\t}\n\n\t\t\t\tvalues.forEach((value, index) => {\n\t\t\t\t\tconst col = createElement(\"div\", { role: \"listitem\" });\n\t\t\t\t\tcol.appendChild(\n\t\t\t\t\t\tcreateElement(\"div\", {\n\t\t\t\t\t\t\t\"aria-describedby\": legendIds[legendIndex],\n\t\t\t\t\t\t\ttabindex: \"0\",\n\t\t\t\t\t\t\ttitle: `${data[0][index + 1]}: ${value} (${legend})`,\n\t\t\t\t\t\t\tclass: \"linePoint\",\n\t\t\t\t\t\t\trole: \"img\",\n\t\t\t\t\t\t\tstyle: `--value: ${value}`,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tlineContainer.append(col);\n\t\t\t\t});\n\n\t\t\t\tline.append(lineBorder, linePath);\n\t\t\t\tlineContainer.append(line);\n\t\t\t\tgroup.append(lineContainer);\n\t\t\t});\n\t\t\tgroups.append(group);\n\t\t}\n\n\t\tif (variant === \"doughnut\") {\n\t\t\tconst doughnut = document.createElementNS(xmlns, \"svg\");\n\t\t\tconst tot = data.slice(1).reduce((acc, [, val]) => acc + Number(val), 0);\n\t\t\tattr(doughnut, \"class\", \"doughnut\");\n\t\t\tattr(doughnut, \"viewBox\", \"0 0 100 100\");\n\n\t\t\tlet offset = 0;\n\t\t\tconst radius = 50;\n\t\t\tconst inner = 25;\n\n\t\t\tdata.slice(1).forEach(([label, value], legendIndex) => {\n\t\t\t\tconst path = document.createElementNS(xmlns, \"path\");\n\t\t\t\tconst start = offset / tot;\n\t\t\t\toffset += Number(value);\n\t\t\t\tconst end = offset / tot;\n\t\t\t\tconst largeArc = end - start > 0.5 ? 1 : 0;\n\t\t\t\tconst a0 = 2 * Math.PI * (start - 0.25);\n\t\t\t\tconst a1 = 2 * Math.PI * (end - 0.25);\n\t\t\t\tconst x0 = Math.cos(a0);\n\t\t\t\tconst y0 = Math.sin(a0);\n\t\t\t\tconst x1 = Math.cos(a1);\n\t\t\t\tconst y1 = Math.sin(a1);\n\t\t\t\tconst d = `M ${radius + inner * x0} ${radius + inner * y0} L ${radius + radius * x0} ${radius + radius * y0} A ${radius} ${radius} 0 ${largeArc} 1 ${radius + radius * x1} ${radius + radius * y1} L ${radius + inner * x1} ${radius + inner * y1} A ${inner} ${inner} 0 ${largeArc} 0 ${radius + inner * x0} ${radius + inner * y0}`;\n\n\t\t\t\tattr(path, \"aria-describedby\", legendIds[legendIndex]);\n\t\t\t\tattr(path, \"class\", `color-${legendIndex + 1}`);\n\t\t\t\tattr(path, \"d\", d);\n\t\t\t\tattr(path, \"role\", \"img\");\n\t\t\t\tattr(path, \"tabindex\", \"0\");\n\t\t\t\tattr(path, \"title\", label || null);\n\t\t\t\tdoughnut.appendChild(path);\n\t\t\t\tthis.shadowRoot?.append(doughnut);\n\t\t\t});\n\t\t}\n\n\t\tif (variant !== \"doughnut\") this.shadowRoot?.append(axis);\n\n\t\tlegend.append(...legends);\n\n\t\tthis.shadowRoot?.append(style, legend);\n\t}\n}\n\nif (IS_BROWSER && !window.customElements.get(\"mtds-chart\"))\n\twindow.customElements.define(\"mtds-chart\", MTDSChart);\n\n// Based on https://observablehq.com/@ndry/smooth-a-svg-path-with-cubic-bezier-curves\nconst toPath = (points: number[][], s: number) =>\n\tpoints.map(([x, y], i, a) => (i ? smooth(i, a, s) : `M${x},${y}`)).join(\" \");\nconst add = ([ax, ay]: number[], [bx, by]: number[]) => [ax + bx, ay + by];\nconst sub = ([ax, ay]: number[], [bx, by]: number[]) => [ax - bx, ay - by];\nconst scale = (s: number, [x, y]: number[]) => [s * x, s * y];\nconst smooth = (i: number, all: number[][], smooth: number) => {\n\tconst start = all[i - 1];\n\tconst end = all[i];\n\tconst [csX, csY] = add(start, scale(smooth, sub(end, all[i - 2] || start))); // start control point\n\tconst [ceX, ceY] = add(end, scale(smooth, sub(start, all[i + 1] || end))); // end control point\n\treturn `C ${csX},${csY} ${ceX},${ceY} ${end[0]},${end[1]}`;\n};\n\nconst getNum = new Intl.NumberFormat().format;\nconst toSteps = (max: number) => {\n\tconst digits = 10 ** (`${~~max}`.length - 1); // Get amount of digits in total number\n\tconst step = max / digits < 5 ? digits / 2 : digits; // If we get less than 5 steps, make smaller steps\n\tconst total = Math.ceil(max / step) * step;\n\tconst el = createElement(\"div\");\n\n\tel.classList.add(\"axisSteps\");\n\tel.append(\n\t\t...Array.from({ length: total / step + 1 }, (_, i) => getNum(step * i))\n\t\t\t.reverse()\n\t\t\t.map((num) => {\n\t\t\t\tconst label = createElement(\"div\", { class: \"axisLabel\" }, num);\n\t\t\t\tconst value = createElement(\"div\", { class: \"axisStep\" });\n\t\t\t\tvalue.append(label);\n\t\t\t\treturn value;\n\t\t\t}),\n\t);\n\n\treturn { total, el };\n};\n\n/**\n * createElement\n * @description creates element and assigns properties\n * @param taName The tagname of element to create\n * @param props Optional properties to add to the element\n * @return HTMLElement with props\n */\nconst createElement = <TagName extends keyof HTMLElementTagNameMap>(\n\ttagName: TagName,\n\tattrs?: Record<string, string | null>,\n\ttext?: string | null,\n): HTMLElementTagNameMap[TagName] => {\n\tconst el = document.createElement(tagName);\n\tif (text) el.textContent = text;\n\tif (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n\treturn el;\n};\n"],"names":["MTDSElement","xmlns","MTDSChart","max","rowMax","table","data","row","isTbody","rowTotal","values","cell","isTd","val","num","variant","type","attr","isVertical","isStacked","smoothing","style","createElement","css","axis","groups","steps","toSteps","legend","legends","text","index","legendIds","useId","groupLabel","group","content","label","legendIndex","lineContainer","line","path","toPath","value","length","linePath","lineBorder","lineShade","col","doughnut","tot","acc","offset","radius","inner","start","end","largeArc","a0","a1","x0","y0","x1","y1","d","IS_BROWSER","points","x","y","i","a","smooth","add","ax","ay","bx","by","sub","scale","s","all","csX","csY","ceX","ceY","getNum","digits","step","total","el","_","tagName","attrs","key"],"mappings":";;AAIA,MAAMA,IACL,OAAO,cAAgB,MACnB,MAAM;AAAC,IACR,aAcEC,IAAQ;AACP,MAAMC,UAAkBF,EAAY;AAAA,E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AC,GACA9D,MACoC;AACpC,QAAM2D,IAAK,SAAS,cAAcE,CAAO;AAEzC,MADI7D,QAAS,cAAcA,IACvB8D,EAAO,YAAW,CAACC,GAAKhF,CAAG,KAAK,OAAO,QAAQ+E,CAAK,EAAG,CAAA3E,EAAKwE,GAAII,GAAKhF,CAAG;AAC5E,SAAO4E;AACR;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type ChartProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
2
|
+
"data-variant"?: "bar" | "column" | "column-stacked" | "area" | "line" | "doughnut";
|
|
3
|
+
};
|
|
4
|
+
export declare const Chart: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
5
|
+
"data-variant"?: "bar" | "column" | "column-stacked" | "area" | "line" | "doughnut";
|
|
6
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
const t = `:host(:not([hidden])) {
|
|
2
|
+
display: block;
|
|
3
|
+
--mtdsc-chart-aspect: 16 / 9;
|
|
4
|
+
--mtdsc-chart-axis-border: var(--mtds-border-width-default) solid
|
|
5
|
+
var(--mtds-color-border-subtle);
|
|
6
|
+
--mtdsc-chart-axis-gap: var(--mtds-2);
|
|
7
|
+
--mtdsc-chart-border-color: var(--mtds-color-border-default);
|
|
8
|
+
--mtdsc-chart-color-text: var(--mtds-color-text-default);
|
|
9
|
+
--mtdsc-chart-color: var(--mtds-color-surface-tinted);
|
|
10
|
+
--mtdsc-chart-color-1: #b4cea0;
|
|
11
|
+
--mtdsc-chart-color-2: #68b096;
|
|
12
|
+
--mtdsc-chart-color-3: #cde5f2;
|
|
13
|
+
--mtdsc-chart-border-color-1: var(--mtds-color-success-border-subtle);
|
|
14
|
+
--mtdsc-chart-border-color-2: var(--mtds-color-info-border-subtle);
|
|
15
|
+
--mtdsc-chart-border-color-3: var(--mtds-color-warning-border-subtle);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
:host([data-variant="doughnut"]) {
|
|
19
|
+
--mtdsc-chart-aspect: 1 / 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.doughnut {
|
|
23
|
+
overflow: visible;
|
|
24
|
+
height: 100%;
|
|
25
|
+
width: 100%;
|
|
26
|
+
}
|
|
27
|
+
.doughnut > path {
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
fill: var(--mtdsc-chart-color);
|
|
30
|
+
outline: none;
|
|
31
|
+
stroke-width: var(--mtds-border-width-default);
|
|
32
|
+
/* stroke: var(--mtds-color-border-default); */
|
|
33
|
+
transform-origin: center;
|
|
34
|
+
transition: scale 0.2s;
|
|
35
|
+
vector-effect: non-scaling-stroke;
|
|
36
|
+
}
|
|
37
|
+
.doughnut > path:focus-visible,
|
|
38
|
+
.doughnut > path:hover {
|
|
39
|
+
scale: 1.05;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.color-1 {
|
|
43
|
+
--mtdsc-chart-color: var(--mtdsc-chart-color-1);
|
|
44
|
+
--mtdsc-chart-border-color: var(--mtdsc-chart-border-color-1);
|
|
45
|
+
}
|
|
46
|
+
.color-2 {
|
|
47
|
+
--mtdsc-chart-color: var(--mtdsc-chart-color-2);
|
|
48
|
+
--mtdsc-chart-border-color: var(--mtdsc-chart-border-color-2);
|
|
49
|
+
}
|
|
50
|
+
.color-3 {
|
|
51
|
+
--mtdsc-chart-color: var(--mtdsc-chart-color-3);
|
|
52
|
+
--mtdsc-chart-border-color: var(--mtdsc-chart-border-color-3);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.axis {
|
|
56
|
+
aspect-ratio: var(--mtdsc-chart-aspect);
|
|
57
|
+
display: grid;
|
|
58
|
+
gap: calc(var(--mtdsc-chart-axis-gap) / 2);
|
|
59
|
+
grid-template-columns: fit-content(7em) 1fr;
|
|
60
|
+
grid-template-rows: 1fr auto;
|
|
61
|
+
grid-template-areas:
|
|
62
|
+
"y-axis chart"
|
|
63
|
+
"y-axis x-axis";
|
|
64
|
+
}
|
|
65
|
+
.axisSteps,
|
|
66
|
+
.axisStep,
|
|
67
|
+
.axisGroups,
|
|
68
|
+
.axisGroup {
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
display: grid;
|
|
71
|
+
position: relative; /* Help .lineContainer positioning */
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.is-horizontal .axisGroups {
|
|
75
|
+
column-gap: var(--mtdsc-chart-axis-gap);
|
|
76
|
+
grid-column: chart;
|
|
77
|
+
grid-row: chart / x-axis;
|
|
78
|
+
grid-template-rows: subgrid;
|
|
79
|
+
padding-inline: var(--mtdsc-chart-axis-gap);
|
|
80
|
+
text-align: center;
|
|
81
|
+
}
|
|
82
|
+
.is-horizontal .axisGroup {
|
|
83
|
+
grid-row: chart / x-axis;
|
|
84
|
+
grid-template-rows: inherit;
|
|
85
|
+
}
|
|
86
|
+
.is-horizontal .axisSteps {
|
|
87
|
+
grid-auto-rows: 1fr;
|
|
88
|
+
grid-column: y-axis / chart;
|
|
89
|
+
grid-row: chart;
|
|
90
|
+
grid-template-columns: subgrid;
|
|
91
|
+
grid-template-rows: 1px;
|
|
92
|
+
}
|
|
93
|
+
.is-horizontal .axisStep {
|
|
94
|
+
align-content: flex-end;
|
|
95
|
+
grid-column: inherit;
|
|
96
|
+
grid-template-columns: inherit;
|
|
97
|
+
text-align: right;
|
|
98
|
+
}
|
|
99
|
+
.is-horizontal .axisStep::after {
|
|
100
|
+
content: "";
|
|
101
|
+
border-bottom: var(--mtdsc-chart-axis-border);
|
|
102
|
+
}
|
|
103
|
+
.is-horizontal .axisStep .axisLabel {
|
|
104
|
+
transform: translateY(50%);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.is-vertical .axisSteps,
|
|
108
|
+
.is-vertical .axisGroup {
|
|
109
|
+
direction: rtl; /* Reverse orders */
|
|
110
|
+
}
|
|
111
|
+
.is-vertical .axisSteps > *,
|
|
112
|
+
.is-vertical .axisGroup > * {
|
|
113
|
+
direction: ltr;
|
|
114
|
+
}
|
|
115
|
+
.is-vertical .axisGroups {
|
|
116
|
+
grid-column: y-axis / chart;
|
|
117
|
+
grid-row: chart;
|
|
118
|
+
grid-template-columns: subgrid;
|
|
119
|
+
padding-block: var(--mtdsc-chart-axis-gap);
|
|
120
|
+
row-gap: var(--mtdsc-chart-axis-gap);
|
|
121
|
+
text-align: right;
|
|
122
|
+
}
|
|
123
|
+
.is-vertical .axisGroups .axisLabel {
|
|
124
|
+
align-self: center; /* Since text-align does not work vertically */
|
|
125
|
+
}
|
|
126
|
+
.is-vertical .axisGroup {
|
|
127
|
+
grid-column: inherit;
|
|
128
|
+
grid-template-columns: inherit;
|
|
129
|
+
}
|
|
130
|
+
.is-vertical .axisSteps {
|
|
131
|
+
grid-auto-columns: 1fr;
|
|
132
|
+
grid-column: chart;
|
|
133
|
+
grid-row: chart / x-axis;
|
|
134
|
+
grid-template-columns: 1px;
|
|
135
|
+
grid-template-rows: subgrid;
|
|
136
|
+
}
|
|
137
|
+
.is-vertical .axisStep {
|
|
138
|
+
grid-row: inherit;
|
|
139
|
+
grid-template-rows: inherit;
|
|
140
|
+
justify-content: flex-start;
|
|
141
|
+
text-align: center;
|
|
142
|
+
}
|
|
143
|
+
.is-vertical .axisStep::before {
|
|
144
|
+
content: "";
|
|
145
|
+
border-left: var(--mtdsc-chart-axis-border);
|
|
146
|
+
}
|
|
147
|
+
.is-vertical .axisStep .axisLabel {
|
|
148
|
+
transform: translateX(-50%);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.axisGroupContent {
|
|
152
|
+
display: flex;
|
|
153
|
+
/* gap: 1px; */
|
|
154
|
+
}
|
|
155
|
+
.is-horizontal.is-stacked .axisGroupContent {
|
|
156
|
+
flex-direction: column-reverse;
|
|
157
|
+
row-gap: 0px;
|
|
158
|
+
}
|
|
159
|
+
.is-vertical.is-stacked .axisGroupContent {
|
|
160
|
+
column-gap: 0px;
|
|
161
|
+
}
|
|
162
|
+
.is-vertical:not(.is-stacked) .axisGroupContent {
|
|
163
|
+
flex-direction: column;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.bar {
|
|
167
|
+
--size: calc(var(--value) / var(--total, 1) * 100%);
|
|
168
|
+
background: var(--mtdsc-chart-color);
|
|
169
|
+
/* border: 1px solid var(--mtdsc-chart-border-color); */
|
|
170
|
+
box-sizing: border-box;
|
|
171
|
+
color: var(--mtdsc-chart-color-text);
|
|
172
|
+
padding: var(--mtds-1);
|
|
173
|
+
position: relative; /* Place above .lineContainer */
|
|
174
|
+
}
|
|
175
|
+
.bar:hover,
|
|
176
|
+
.bar:focus-visible {
|
|
177
|
+
box-shadow: var(--mtdsc-focus-boxShadow);
|
|
178
|
+
outline: var(--mtdsc-focus-outline);
|
|
179
|
+
outline-offset: var(--mtds-border-width-focus);
|
|
180
|
+
z-index: 2; /* z-index to place on top when outlined */
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.is-horizontal .bar {
|
|
184
|
+
width: 100%;
|
|
185
|
+
height: var(--size);
|
|
186
|
+
align-self: flex-end;
|
|
187
|
+
grid-row: chart;
|
|
188
|
+
} /* grid-row is only used if placed directly in Chart.Axis */
|
|
189
|
+
.is-vertical .bar {
|
|
190
|
+
width: var(--size);
|
|
191
|
+
height: 100%;
|
|
192
|
+
grid-column: chart;
|
|
193
|
+
} /* grid-column is only used if placed directly in Chart.Axis */
|
|
194
|
+
.is-horizontal:not(.is-stacked) .axisGroup .bar + .bar {
|
|
195
|
+
/* margin-left: -1px; */
|
|
196
|
+
} /* Prevent double border - using margin to see border around bars */
|
|
197
|
+
.is-vertical:not(.is-stacked) .axisGroup .bar + .bar {
|
|
198
|
+
/* margin-top: -1px; */
|
|
199
|
+
} /* Prevent double border - using margin to see border around bars */
|
|
200
|
+
.is-horizontal.is-stacked .axisGroup .bar + .bar {
|
|
201
|
+
border-bottom: none;
|
|
202
|
+
} /* Prevent double border - using border to avoid affecting size */
|
|
203
|
+
.is-vertical.is-stacked .axisGroup .bar + .bar {
|
|
204
|
+
border-left: none;
|
|
205
|
+
} /* Prevent double border - using border to avoid affecting size */
|
|
206
|
+
|
|
207
|
+
.lineContainer {
|
|
208
|
+
align-items: flex-start;
|
|
209
|
+
display: flex;
|
|
210
|
+
justify-content: space-between;
|
|
211
|
+
pointer-events: none;
|
|
212
|
+
}
|
|
213
|
+
.lineContainer > svg,
|
|
214
|
+
.lineContainer {
|
|
215
|
+
position: absolute;
|
|
216
|
+
width: 100%;
|
|
217
|
+
height: 100%;
|
|
218
|
+
}
|
|
219
|
+
.lineContainer > svg:first-child {
|
|
220
|
+
z-index: 2;
|
|
221
|
+
}
|
|
222
|
+
.is-horizontal .lineContainer {
|
|
223
|
+
grid-row: chart;
|
|
224
|
+
}
|
|
225
|
+
.is-horizontal .lineContainer > svg {
|
|
226
|
+
overflow: clip visible;
|
|
227
|
+
}
|
|
228
|
+
.is-horizontal .lineContainer > div[role="listitem"] {
|
|
229
|
+
display: contents;
|
|
230
|
+
}
|
|
231
|
+
.is-horizontal .lineContainer .linePoint {
|
|
232
|
+
top: calc(100% - var(--value) / var(--total, 1) * 100%);
|
|
233
|
+
}
|
|
234
|
+
.is-vertical .lineContainer {
|
|
235
|
+
flex-direction: column;
|
|
236
|
+
grid-column: chart;
|
|
237
|
+
}
|
|
238
|
+
.is-vertical .lineContainer > svg {
|
|
239
|
+
overflow: visible clip;
|
|
240
|
+
}
|
|
241
|
+
.is-vertical .lineContainer .linePoint {
|
|
242
|
+
left: calc(var(--value) / var(--total, 1) * 100%);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.line,
|
|
246
|
+
.lineBorder,
|
|
247
|
+
.lineShade {
|
|
248
|
+
fill: none;
|
|
249
|
+
stroke: var(--mtdsc-chart-color);
|
|
250
|
+
stroke-linejoin: round;
|
|
251
|
+
stroke-linecap: round;
|
|
252
|
+
stroke-width: 3;
|
|
253
|
+
vector-effect: non-scaling-stroke;
|
|
254
|
+
}
|
|
255
|
+
.line.line {
|
|
256
|
+
/* fill: none; /* Use double selector as fill should always be drawn by .lineShade */
|
|
257
|
+
}
|
|
258
|
+
.lineBorder {
|
|
259
|
+
/* stroke-width: 5;
|
|
260
|
+
stroke: var(--mtdsc-chart-border-color); */
|
|
261
|
+
}
|
|
262
|
+
.lineShade {
|
|
263
|
+
stroke: none;
|
|
264
|
+
fill: var(--mtdsc-chart-color);
|
|
265
|
+
opacity: 0.15;
|
|
266
|
+
}
|
|
267
|
+
.linePoint {
|
|
268
|
+
--size: 0.625rem; /* 10px */
|
|
269
|
+
background-color: var(--mtdsc-chart-color);
|
|
270
|
+
border-radius: var(--mtds-border-radius-full);
|
|
271
|
+
/* border: 1px solid var(--mtdsc-chart-border-color); */
|
|
272
|
+
box-sizing: border-box;
|
|
273
|
+
margin: calc(var(--size) / -2);
|
|
274
|
+
padding: 0;
|
|
275
|
+
pointer-events: all;
|
|
276
|
+
position: relative;
|
|
277
|
+
transition: scale 0.2s;
|
|
278
|
+
width: var(--size);
|
|
279
|
+
height: var(--size);
|
|
280
|
+
z-index: 2;
|
|
281
|
+
}
|
|
282
|
+
.linePoint[hidden] {
|
|
283
|
+
display: block;
|
|
284
|
+
visibility: hidden;
|
|
285
|
+
} /* All dots need to render to make parent display: flex work, so instead hide visibility */
|
|
286
|
+
.linePoint:focus-visible,
|
|
287
|
+
.linePoint:hover {
|
|
288
|
+
scale: 1.3;
|
|
289
|
+
}
|
|
290
|
+
.linePoint::before {
|
|
291
|
+
content: "";
|
|
292
|
+
inset: calc(var(--mtds-2) * -1); /* Increase click surface */
|
|
293
|
+
position: absolute;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.legends {
|
|
297
|
+
align-items: center;
|
|
298
|
+
display: flex;
|
|
299
|
+
flex-wrap: wrap;
|
|
300
|
+
gap: var(--mtds-6);
|
|
301
|
+
justify-content: center;
|
|
302
|
+
margin-top: var(--mtds-6);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.legend {
|
|
306
|
+
display: flex;
|
|
307
|
+
align-items: center;
|
|
308
|
+
gap: var(--mtds-2);
|
|
309
|
+
}
|
|
310
|
+
.legend::before {
|
|
311
|
+
background-color: var(--mtdsc-chart-color);
|
|
312
|
+
border-radius: var(--mtds-border-radius-full);
|
|
313
|
+
/* border: 1px solid var(--mtdsc-chart-border-color); */
|
|
314
|
+
box-sizing: border-box;
|
|
315
|
+
content: "";
|
|
316
|
+
display: inline-block;
|
|
317
|
+
vertical-align: middle;
|
|
318
|
+
width: var(--mtds-6);
|
|
319
|
+
height: var(--mtds-6);
|
|
320
|
+
}
|
|
321
|
+
`;
|
|
322
|
+
export {
|
|
323
|
+
t as default
|
|
324
|
+
};
|
|
325
|
+
//# sourceMappingURL=chart.module.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.module.css.js","sources":["../../designsystem/chart/chart.module.css?raw"],"sourcesContent":["export default \":host(:not([hidden])) {\\n\\tdisplay: block;\\n\\t--mtdsc-chart-aspect: 16 / 9;\\n\\t--mtdsc-chart-axis-border: var(--ds-border-width-default) solid\\n\\t\\tvar(--ds-color-border-subtle);\\n\\t--mtdsc-chart-axis-gap: var(--ds-size-2);\\n\\t--mtdsc-chart-border-color: var(--ds-color-border-default);\\n\\t--mtdsc-chart-color-text: var(--ds-color-text-default);\\n\\t--mtdsc-chart-color: var(--ds-color-surface-tinted);\\n\\t--mtdsc-chart-color-1: #b4cea0;\\n\\t--mtdsc-chart-color-2: #68b096;\\n\\t--mtdsc-chart-color-3: #cde5f2;\\n\\t--mtdsc-chart-border-color-1: var(--ds-color-success-border-subtle);\\n\\t--mtdsc-chart-border-color-2: var(--ds-color-info-border-subtle);\\n\\t--mtdsc-chart-border-color-3: var(--ds-color-warning-border-subtle);\\n}\\n\\n:host([data-variant=\\\"doughnut\\\"]) {\\n\\t--mtdsc-chart-aspect: 1 / 1;\\n}\\n\\n.doughnut {\\n\\toverflow: visible;\\n\\theight: 100%;\\n\\twidth: 100%;\\n}\\n.doughnut > path {\\n\\tcursor: pointer;\\n\\tfill: var(--mtdsc-chart-color);\\n\\toutline: none;\\n\\tstroke-width: var(--ds-border-width-default);\\n\\t/* stroke: var(--ds-color-border-default); */\\n\\ttransform-origin: center;\\n\\ttransition: scale 0.2s;\\n\\tvector-effect: non-scaling-stroke;\\n}\\n.doughnut > path:focus-visible,\\n.doughnut > path:hover {\\n\\tscale: 1.05;\\n}\\n\\n.color-1 {\\n\\t--mtdsc-chart-color: var(--mtdsc-chart-color-1);\\n\\t--mtdsc-chart-border-color: var(--mtdsc-chart-border-color-1);\\n}\\n.color-2 {\\n\\t--mtdsc-chart-color: var(--mtdsc-chart-color-2);\\n\\t--mtdsc-chart-border-color: var(--mtdsc-chart-border-color-2);\\n}\\n.color-3 {\\n\\t--mtdsc-chart-color: var(--mtdsc-chart-color-3);\\n\\t--mtdsc-chart-border-color: var(--mtdsc-chart-border-color-3);\\n}\\n\\n.axis {\\n\\taspect-ratio: var(--mtdsc-chart-aspect);\\n\\tdisplay: grid;\\n\\tgap: calc(var(--mtdsc-chart-axis-gap) / 2);\\n\\tgrid-template-columns: fit-content(7em) 1fr;\\n\\tgrid-template-rows: 1fr auto;\\n\\tgrid-template-areas:\\n\\t\\t\\\"y-axis chart\\\"\\n\\t\\t\\\"y-axis x-axis\\\";\\n}\\n.axisSteps,\\n.axisStep,\\n.axisGroups,\\n.axisGroup {\\n\\tbox-sizing: border-box;\\n\\tdisplay: grid;\\n\\tposition: relative; /* Help .lineContainer positioning */\\n}\\n\\n.is-horizontal .axisGroups {\\n\\tcolumn-gap: var(--mtdsc-chart-axis-gap);\\n\\tgrid-column: chart;\\n\\tgrid-row: chart / x-axis;\\n\\tgrid-template-rows: subgrid;\\n\\tpadding-inline: var(--mtdsc-chart-axis-gap);\\n\\ttext-align: center;\\n}\\n.is-horizontal .axisGroup {\\n\\tgrid-row: chart / x-axis;\\n\\tgrid-template-rows: inherit;\\n}\\n.is-horizontal .axisSteps {\\n\\tgrid-auto-rows: 1fr;\\n\\tgrid-column: y-axis / chart;\\n\\tgrid-row: chart;\\n\\tgrid-template-columns: subgrid;\\n\\tgrid-template-rows: 1px;\\n}\\n.is-horizontal .axisStep {\\n\\talign-content: flex-end;\\n\\tgrid-column: inherit;\\n\\tgrid-template-columns: inherit;\\n\\ttext-align: right;\\n}\\n.is-horizontal .axisStep::after {\\n\\tcontent: \\\"\\\";\\n\\tborder-bottom: var(--mtdsc-chart-axis-border);\\n}\\n.is-horizontal .axisStep .axisLabel {\\n\\ttransform: translateY(50%);\\n}\\n\\n.is-vertical .axisSteps,\\n.is-vertical .axisGroup {\\n\\tdirection: rtl; /* Reverse orders */\\n}\\n.is-vertical .axisSteps > *,\\n.is-vertical .axisGroup > * {\\n\\tdirection: ltr;\\n}\\n.is-vertical .axisGroups {\\n\\tgrid-column: y-axis / chart;\\n\\tgrid-row: chart;\\n\\tgrid-template-columns: subgrid;\\n\\tpadding-block: var(--mtdsc-chart-axis-gap);\\n\\trow-gap: var(--mtdsc-chart-axis-gap);\\n\\ttext-align: right;\\n}\\n.is-vertical .axisGroups .axisLabel {\\n\\talign-self: center; /* Since text-align does not work vertically */\\n}\\n.is-vertical .axisGroup {\\n\\tgrid-column: inherit;\\n\\tgrid-template-columns: inherit;\\n}\\n.is-vertical .axisSteps {\\n\\tgrid-auto-columns: 1fr;\\n\\tgrid-column: chart;\\n\\tgrid-row: chart / x-axis;\\n\\tgrid-template-columns: 1px;\\n\\tgrid-template-rows: subgrid;\\n}\\n.is-vertical .axisStep {\\n\\tgrid-row: inherit;\\n\\tgrid-template-rows: inherit;\\n\\tjustify-content: flex-start;\\n\\ttext-align: center;\\n}\\n.is-vertical .axisStep::before {\\n\\tcontent: \\\"\\\";\\n\\tborder-left: var(--mtdsc-chart-axis-border);\\n}\\n.is-vertical .axisStep .axisLabel {\\n\\ttransform: translateX(-50%);\\n}\\n\\n.axisGroupContent {\\n\\tdisplay: flex;\\n\\t/* gap: 1px; */\\n}\\n.is-horizontal.is-stacked .axisGroupContent {\\n\\tflex-direction: column-reverse;\\n\\trow-gap: 0px;\\n}\\n.is-vertical.is-stacked .axisGroupContent {\\n\\tcolumn-gap: 0px;\\n}\\n.is-vertical:not(.is-stacked) .axisGroupContent {\\n\\tflex-direction: column;\\n}\\n\\n.bar {\\n\\t--size: calc(var(--value) / var(--total, 1) * 100%);\\n\\tbackground: var(--mtdsc-chart-color);\\n\\t/* border: 1px solid var(--mtdsc-chart-border-color); */\\n\\tbox-sizing: border-box;\\n\\tcolor: var(--mtdsc-chart-color-text);\\n\\tpadding: var(--ds-size-1);\\n\\tposition: relative; /* Place above .lineContainer */\\n}\\n.bar:hover,\\n.bar:focus-visible {\\n\\tbox-shadow: var(--dsc-focus-boxShadow);\\n\\toutline: var(--dsc-focus-outline);\\n\\toutline-offset: var(--ds-border-width-focus);\\n\\tz-index: 2; /* z-index to place on top when outlined */\\n}\\n\\n.is-horizontal .bar {\\n\\twidth: 100%;\\n\\theight: var(--size);\\n\\talign-self: flex-end;\\n\\tgrid-row: chart;\\n} /* grid-row is only used if placed directly in Chart.Axis */\\n.is-vertical .bar {\\n\\twidth: var(--size);\\n\\theight: 100%;\\n\\tgrid-column: chart;\\n} /* grid-column is only used if placed directly in Chart.Axis */\\n.is-horizontal:not(.is-stacked) .axisGroup .bar + .bar {\\n\\t/* margin-left: -1px; */\\n} /* Prevent double border - using margin to see border around bars */\\n.is-vertical:not(.is-stacked) .axisGroup .bar + .bar {\\n\\t/* margin-top: -1px; */\\n} /* Prevent double border - using margin to see border around bars */\\n.is-horizontal.is-stacked .axisGroup .bar + .bar {\\n\\tborder-bottom: none;\\n} /* Prevent double border - using border to avoid affecting size */\\n.is-vertical.is-stacked .axisGroup .bar + .bar {\\n\\tborder-left: none;\\n} /* Prevent double border - using border to avoid affecting size */\\n\\n.lineContainer {\\n\\talign-items: flex-start;\\n\\tdisplay: flex;\\n\\tjustify-content: space-between;\\n\\tpointer-events: none;\\n}\\n.lineContainer > svg,\\n.lineContainer {\\n\\tposition: absolute;\\n\\twidth: 100%;\\n\\theight: 100%;\\n}\\n.lineContainer > svg:first-child {\\n\\tz-index: 2;\\n}\\n.is-horizontal .lineContainer {\\n\\tgrid-row: chart;\\n}\\n.is-horizontal .lineContainer > svg {\\n\\toverflow: clip visible;\\n}\\n.is-horizontal .lineContainer > div[role=\\\"listitem\\\"] {\\n\\tdisplay: contents;\\n}\\n.is-horizontal .lineContainer .linePoint {\\n\\ttop: calc(100% - var(--value) / var(--total, 1) * 100%);\\n}\\n.is-vertical .lineContainer {\\n\\tflex-direction: column;\\n\\tgrid-column: chart;\\n}\\n.is-vertical .lineContainer > svg {\\n\\toverflow: visible clip;\\n}\\n.is-vertical .lineContainer .linePoint {\\n\\tleft: calc(var(--value) / var(--total, 1) * 100%);\\n}\\n\\n.line,\\n.lineBorder,\\n.lineShade {\\n\\tfill: none;\\n\\tstroke: var(--mtdsc-chart-color);\\n\\tstroke-linejoin: round;\\n\\tstroke-linecap: round;\\n\\tstroke-width: 3;\\n\\tvector-effect: non-scaling-stroke;\\n}\\n.line.line {\\n\\t/* fill: none; /* Use double selector as fill should always be drawn by .lineShade */\\n}\\n.lineBorder {\\n\\t/* stroke-width: 5;\\n\\tstroke: var(--mtdsc-chart-border-color); */\\n}\\n.lineShade {\\n\\tstroke: none;\\n\\tfill: var(--mtdsc-chart-color);\\n\\topacity: 0.15;\\n}\\n.linePoint {\\n\\t--size: 0.625rem; /* 10px */\\n\\tbackground-color: var(--mtdsc-chart-color);\\n\\tborder-radius: var(--ds-border-radius-full);\\n\\t/* border: 1px solid var(--mtdsc-chart-border-color); */\\n\\tbox-sizing: border-box;\\n\\tmargin: calc(var(--size) / -2);\\n\\tpadding: 0;\\n\\tpointer-events: all;\\n\\tposition: relative;\\n\\ttransition: scale 0.2s;\\n\\twidth: var(--size);\\n\\theight: var(--size);\\n\\tz-index: 2;\\n}\\n.linePoint[hidden] {\\n\\tdisplay: block;\\n\\tvisibility: hidden;\\n} /* All dots need to render to make parent display: flex work, so instead hide visibility */\\n.linePoint:focus-visible,\\n.linePoint:hover {\\n\\tscale: 1.3;\\n}\\n.linePoint::before {\\n\\tcontent: \\\"\\\";\\n\\tinset: calc(var(--ds-size-2) * -1); /* Increase click surface */\\n\\tposition: absolute;\\n}\\n\\n.legends {\\n\\talign-items: center;\\n\\tdisplay: flex;\\n\\tflex-wrap: wrap;\\n\\tgap: var(--ds-size-6);\\n\\tjustify-content: center;\\n\\tmargin-top: var(--ds-size-6);\\n}\\n\\n.legend {\\n\\tdisplay: flex;\\n\\talign-items: center;\\n\\tgap: var(--ds-size-2);\\n}\\n.legend::before {\\n\\tbackground-color: var(--mtdsc-chart-color);\\n\\tborder-radius: var(--ds-border-radius-full);\\n\\t/* border: 1px solid var(--mtdsc-chart-border-color); */\\n\\tbox-sizing: border-box;\\n\\tcontent: \\\"\\\";\\n\\tdisplay: inline-block;\\n\\tvertical-align: middle;\\n\\twidth: var(--ds-size-6);\\n\\theight: var(--ds-size-6);\\n}\\n\""],"names":["css"],"mappings":"AAAA,MAAAA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
@@ -49,7 +49,7 @@ var f = (t, e, n) => {
|
|
|
49
49
|
const i = "onbeforematch" in this ? "until-found" : !0, s = this.open;
|
|
50
50
|
for (const a of this.children)
|
|
51
51
|
a.nodeName === "U-SUMMARY" && o(a, "aria-expanded", `${s}`);
|
|
52
|
-
if (this._content && (o(this._content, "aria-hidden", `${!s}`), this._content.hidden = s ? !1 : i), s && this.name) {
|
|
52
|
+
if (this._content && (o(this._content, "aria-hidden", `${!s}`), o(this._content, "tabindex", s ? null : "-1"), this._content.hidden = s ? !1 : i), s && this.name) {
|
|
53
53
|
const a = g(this).querySelectorAll(
|
|
54
54
|
`${this.nodeName}[name="${this.name}"]`
|
|
55
55
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"u-details.js","sources":["../../../../../node_modules/@u-elements/u-details/dist/u-details.js"],"sourcesContent":["// ../utils.ts\nvar IS_BROWSER = typeof window !== \"undefined\" && typeof window.document !== \"undefined\" && typeof window.navigator !== \"undefined\";\nvar _a;\nIS_BROWSER && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474\n/^Mac/i.test(((_a = navigator.userAgentData) == null ? void 0 : _a.platform) || navigator.platform);\nvar DISPLAY_BLOCK = \":host(:not([hidden])) { display: block }\";\nvar UHTMLElement = typeof HTMLElement === \"undefined\" ? class {\n} : HTMLElement;\nfunction attr(el, name, value) {\n if (value === void 0) return el.getAttribute(name);\n if (value === null) el.removeAttribute(name);\n else if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n return null;\n}\nvar events = (action, element, rest) => {\n for (const type of rest[0].split(\",\")) {\n rest[0] = type;\n Element.prototype[`${action}EventListener`].apply(element, rest);\n }\n};\nvar on = (element, ...rest) => events(\"add\", element, rest);\nvar off = (element, ...rest) => events(\"remove\", element, rest);\nvar asButton = (event) => {\n const isClick = \"key\" in event && (event.key === \" \" || event.key === \"Enter\");\n if (isClick) event.preventDefault();\n if (isClick && event.target instanceof HTMLElement) event.target.click();\n return isClick;\n};\nvar getRoot = (node) => {\n var _a2;\n const root = ((_a2 = node.getRootNode) == null ? void 0 : _a2.call(node)) || node.ownerDocument;\n return root instanceof Document || root instanceof ShadowRoot ? root : document;\n};\nvar createElement = (tagName, text, attrs) => {\n const el = document.createElement(tagName);\n if (text) el.textContent = text;\n if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n return el;\n};\nvar customElements = {\n define: (name, instance) => !IS_BROWSER || window.customElements.get(name) || window.customElements.define(name, instance)\n};\nvar declarativeShadowRoot = (style, slot = \"<slot></slot>\") => `<template shadowrootmode=\"open\">${slot}<style>${style}</style></template>`;\n\n// u-details.ts\nvar UHTMLDetailsStyle = `${DISPLAY_BLOCK}\n::slotted(u-summary) { cursor: pointer; display: block }\n::slotted(u-summary)::before { content: ''; display: inline-block; vertical-align: middle; margin-inline: .05em .3125em; border-block: .3125em solid transparent; border-inline-start: .5em solid }\n::slotted(u-summary[aria-expanded=\"true\"])::before { rotate: 90deg }\n:host > [part=\"details-content\"]:not([hidden=\"\"]) { display: block }`;\nvar UHTMLDetailsShadowRoot = declarativeShadowRoot(\n UHTMLDetailsStyle,\n '<slot name=\"summary\"></slot><slot part=\"details-content\" hidden=\"until-found\"></slot>'\n);\nvar UHTMLDetailsElement = class extends UHTMLElement {\n constructor() {\n super();\n // Using underscore instead of private fields for backwards compatibility\n this._content = null;\n if (!this.shadowRoot)\n this.attachShadow({ mode: \"open\" }).append(\n createElement(\"slot\", null, { name: \"summary\" }),\n createElement(\"slot\", null, { part: \"details-content\" }),\n createElement(\"style\", UHTMLDetailsStyle)\n );\n }\n // Using ES2015 syntax for backwards compatibility\n static get observedAttributes() {\n return [\"open\"];\n }\n connectedCallback() {\n var _a2;\n this._content = (_a2 = this.shadowRoot) == null ? void 0 : _a2.children[1];\n attr(this, \"role\", \"group\");\n on(this._content, \"beforematch\", this);\n on(this, \"click,keydown\", this);\n this.attributeChangedCallback();\n }\n disconnectedCallback() {\n if (this._content) off(this._content, \"beforematch\", this);\n off(this, \"click,keydown\", this);\n this._content = null;\n }\n attributeChangedCallback(prop, prev, next) {\n const hide = \"onbeforematch\" in this ? \"until-found\" : true;\n const open = this.open;\n for (const el of this.children)\n if (el.nodeName === \"U-SUMMARY\") attr(el, \"aria-expanded\", `${open}`);\n if (this._content) {\n attr(this._content, \"aria-hidden\", `${!open}`);\n this._content.hidden = open ? false : hide;\n }\n if (open && this.name) {\n const uDetailsList = getRoot(this).querySelectorAll(\n `${this.nodeName}[name=\"${this.name}\"]`\n );\n for (const uDetails of uDetailsList)\n if (uDetails !== this) uDetails.open = false;\n }\n if (prop === \"open\" && prev === null !== (next === null))\n this.dispatchEvent(new Event(\"toggle\"));\n }\n handleEvent(event) {\n const summary = this.querySelector(\":scope > u-summary\");\n const isSummary = summary == null ? void 0 : summary.contains(event.target);\n if (event.defaultPrevented) return;\n if (event.type === \"beforematch\") this.open = true;\n if (isSummary && event.type === \"keydown\") asButton(event);\n if (isSummary && event.type === \"click\") this.open = !this.open;\n }\n get open() {\n return this.hasAttribute(\"open\");\n }\n set open(value) {\n attr(this, \"open\", value ? \"\" : null);\n }\n get name() {\n return attr(this, \"name\") || \"\";\n }\n set name(value) {\n attr(this, \"name\", value);\n }\n};\nvar UHTMLSummaryElement = class extends UHTMLElement {\n connectedCallback() {\n attr(this, \"role\", \"button\");\n this.slot = \"summary\";\n this.tabIndex = 0;\n }\n};\ncustomElements.define(\"u-details\", UHTMLDetailsElement);\ncustomElements.define(\"u-summary\", UHTMLSummaryElement);\n\nexport { UHTMLDetailsElement, UHTMLDetailsShadowRoot, UHTMLDetailsStyle, UHTMLSummaryElement };\n"],"names":["IS_BROWSER","_a","DISPLAY_BLOCK","UHTMLElement","attr","el","name","value","events","action","element","rest","type","on","off","asButton","event","isClick","getRoot","node","_a2","root","createElement","tagName","text","attrs","key","val","customElements","instance","UHTMLDetailsStyle","UHTMLDetailsElement","prop","prev","next","hide","open","uDetailsList","uDetails","summary","isSummary","UHTMLSummaryElement"],"mappings":"AACA,IAAIA,IAAa,OAAO,SAAW,OAAe,OAAO,OAAO,WAAa,OAAe,OAAO,OAAO,YAAc,KACpHC;AACJD;AACA,QAAQ,OAAOC,IAAK,UAAU,kBAAkB,OAAO,SAASA,EAAG,aAAa,UAAU,QAAQ;AAClG,IAAIC,IAAgB,4CAChBC,IAAe,OAAO,cAAgB,MAAc,MAAM;AAC9D,IAAI;AACJ,SAASC,EAAKC,GAAIC,GAAMC,GAAO;AAC7B,SAAIA,MAAU,SAAeF,EAAG,aAAaC,CAAI,KAC7CC,MAAU,OAAMF,EAAG,gBAAgBC,CAAI,IAClCD,EAAG,aAAaC,CAAI,MAAMC,KAAOF,EAAG,aAAaC,GAAMC,CAAK,GAC9D;AACT;AACA,IAAIC,IAAS,CAACC,GAAQC,GAASC,MAAS;AACtC,aAAWC,KAAQD,EAAK,CAAC,EAAE,MAAM,GAAG;AAClC,IAAAA,EAAK,CAAC,IAAIC,GACV,QAAQ,UAAU,GAAGH,CAAM,eAAe,EAAE,MAAMC,GAASC,CAAI;AAEnE,GACIE,IAAK,CAACH,MAAYC,MAASH,EAAO,OAAOE,GAASC,CAAI,GACtDG,IAAM,CAACJ,MAAYC,MAASH,EAAO,UAAUE,GAASC,CAAI,GAC1DI,IAAW,CAACC,MAAU;AACxB,QAAMC,IAAU,SAASD,MAAUA,EAAM,QAAQ,OAAOA,EAAM,QAAQ;AACtE,SAAIC,KAASD,EAAM,eAAc,GAC7BC,KAAWD,EAAM,kBAAkB,eAAaA,EAAM,OAAO,MAAK,GAC/DC;AACT,GACIC,IAAU,CAACC,MAAS;AACtB,MAAIC;AACJ,QAAMC,MAASD,IAAMD,EAAK,gBAAgB,OAAO,SAASC,EAAI,KAAKD,CAAI,MAAMA,EAAK;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AK,WAAW;AAAA,EAClB;AAAA,EACA,yBAAyBkB,GAAMC,GAAMC,GAAM;AACzC,UAAMC,IAAO,mBAAmB,OAAO,gBAAgB,IACjDC,IAAO,KAAK;AAClB,eAAW/B,KAAM,KAAK;AACpB,MAAIA,EAAG,aAAa,eAAaD,EAAKC,GAAI,iBAAiB,GAAG+B,CAAI,EAAE;
|
|
1
|
+
{"version":3,"file":"u-details.js","sources":["../../../../../node_modules/@u-elements/u-details/dist/u-details.js"],"sourcesContent":["// ../utils.ts\nvar IS_BROWSER = typeof window !== \"undefined\" && typeof window.document !== \"undefined\" && typeof window.navigator !== \"undefined\";\nvar _a;\nIS_BROWSER && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474\n/^Mac/i.test(((_a = navigator.userAgentData) == null ? void 0 : _a.platform) || navigator.platform);\nvar DISPLAY_BLOCK = \":host(:not([hidden])) { display: block }\";\nvar UHTMLElement = typeof HTMLElement === \"undefined\" ? class {\n} : HTMLElement;\nfunction attr(el, name, value) {\n if (value === void 0) return el.getAttribute(name);\n if (value === null) el.removeAttribute(name);\n else if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n return null;\n}\nvar events = (action, element, rest) => {\n for (const type of rest[0].split(\",\")) {\n rest[0] = type;\n Element.prototype[`${action}EventListener`].apply(element, rest);\n }\n};\nvar on = (element, ...rest) => events(\"add\", element, rest);\nvar off = (element, ...rest) => events(\"remove\", element, rest);\nvar asButton = (event) => {\n const isClick = \"key\" in event && (event.key === \" \" || event.key === \"Enter\");\n if (isClick) event.preventDefault();\n if (isClick && event.target instanceof HTMLElement) event.target.click();\n return isClick;\n};\nvar getRoot = (node) => {\n var _a2;\n const root = ((_a2 = node.getRootNode) == null ? void 0 : _a2.call(node)) || node.ownerDocument;\n return root instanceof Document || root instanceof ShadowRoot ? root : document;\n};\nvar createElement = (tagName, text, attrs) => {\n const el = document.createElement(tagName);\n if (text) el.textContent = text;\n if (attrs) for (const [key, val] of Object.entries(attrs)) attr(el, key, val);\n return el;\n};\nvar customElements = {\n define: (name, instance) => !IS_BROWSER || window.customElements.get(name) || window.customElements.define(name, instance)\n};\nvar declarativeShadowRoot = (style, slot = \"<slot></slot>\") => `<template shadowrootmode=\"open\">${slot}<style>${style}</style></template>`;\n\n// u-details.ts\nvar UHTMLDetailsStyle = `${DISPLAY_BLOCK}\n::slotted(u-summary) { cursor: pointer; display: block }\n::slotted(u-summary)::before { content: ''; display: inline-block; vertical-align: middle; margin-inline: .05em .3125em; border-block: .3125em solid transparent; border-inline-start: .5em solid }\n::slotted(u-summary[aria-expanded=\"true\"])::before { rotate: 90deg }\n:host > [part=\"details-content\"]:not([hidden=\"\"]) { display: block }`;\nvar UHTMLDetailsShadowRoot = declarativeShadowRoot(\n UHTMLDetailsStyle,\n '<slot name=\"summary\"></slot><slot part=\"details-content\" hidden=\"until-found\"></slot>'\n);\nvar UHTMLDetailsElement = class extends UHTMLElement {\n constructor() {\n super();\n // Using underscore instead of private fields for backwards compatibility\n this._content = null;\n if (!this.shadowRoot)\n this.attachShadow({ mode: \"open\" }).append(\n createElement(\"slot\", null, { name: \"summary\" }),\n createElement(\"slot\", null, { part: \"details-content\" }),\n createElement(\"style\", UHTMLDetailsStyle)\n );\n }\n // Using ES2015 syntax for backwards compatibility\n static get observedAttributes() {\n return [\"open\"];\n }\n connectedCallback() {\n var _a2;\n this._content = (_a2 = this.shadowRoot) == null ? void 0 : _a2.children[1];\n attr(this, \"role\", \"group\");\n on(this._content, \"beforematch\", this);\n on(this, \"click,keydown\", this);\n this.attributeChangedCallback();\n }\n disconnectedCallback() {\n if (this._content) off(this._content, \"beforematch\", this);\n off(this, \"click,keydown\", this);\n this._content = null;\n }\n attributeChangedCallback(prop, prev, next) {\n const hide = \"onbeforematch\" in this ? \"until-found\" : true;\n const open = this.open;\n for (const el of this.children)\n if (el.nodeName === \"U-SUMMARY\") attr(el, \"aria-expanded\", `${open}`);\n if (this._content) {\n attr(this._content, \"aria-hidden\", `${!open}`);\n attr(this._content, \"tabindex\", open ? null : \"-1\");\n this._content.hidden = open ? false : hide;\n }\n if (open && this.name) {\n const uDetailsList = getRoot(this).querySelectorAll(\n `${this.nodeName}[name=\"${this.name}\"]`\n );\n for (const uDetails of uDetailsList)\n if (uDetails !== this) uDetails.open = false;\n }\n if (prop === \"open\" && prev === null !== (next === null))\n this.dispatchEvent(new Event(\"toggle\"));\n }\n handleEvent(event) {\n const summary = this.querySelector(\":scope > u-summary\");\n const isSummary = summary == null ? void 0 : summary.contains(event.target);\n if (event.defaultPrevented) return;\n if (event.type === \"beforematch\") this.open = true;\n if (isSummary && event.type === \"keydown\") asButton(event);\n if (isSummary && event.type === \"click\") this.open = !this.open;\n }\n get open() {\n return this.hasAttribute(\"open\");\n }\n set open(value) {\n attr(this, \"open\", value ? \"\" : null);\n }\n get name() {\n return attr(this, \"name\") || \"\";\n }\n set name(value) {\n attr(this, \"name\", value);\n }\n};\nvar UHTMLSummaryElement = class extends UHTMLElement {\n connectedCallback() {\n attr(this, \"role\", \"button\");\n this.slot = \"summary\";\n this.tabIndex = 0;\n }\n};\ncustomElements.define(\"u-details\", UHTMLDetailsElement);\ncustomElements.define(\"u-summary\", UHTMLSummaryElement);\n\nexport { UHTMLDetailsElement, UHTMLDetailsShadowRoot, UHTMLDetailsStyle, UHTMLSummaryElement };\n"],"names":["IS_BROWSER","_a","DISPLAY_BLOCK","UHTMLElement","attr","el","name","value","events","action","element","rest","type","on","off","asButton","event","isClick","getRoot","node","_a2","root","createElement","tagName","text","attrs","key","val","customElements","instance","UHTMLDetailsStyle","UHTMLDetailsElement","prop","prev","next","hide","open","uDetailsList","uDetails","summary","isSummary","UHTMLSummaryElement"],"mappings":"AACA,IAAIA,IAAa,OAAO,SAAW,OAAe,OAAO,OAAO,WAAa,OAAe,OAAO,OAAO,YAAc,KACpHC;AACJD;AACA,QAAQ,OAAOC,IAAK,UAAU,kBAAkB,OAAO,SAASA,EAAG,aAAa,UAAU,QAAQ;AAClG,IAAIC,IAA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