@mattilsynet/design 3.3.10 → 3.4.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.
Files changed (191) hide show
  1. package/mtds/_virtual/_rolldown/runtime.js +17 -0
  2. package/mtds/ai/card.stories.tsx +54 -77
  3. package/mtds/ai/layout.mdx +37 -1
  4. package/mtds/ai/layout.stories.tsx +126 -1
  5. package/mtds/ai/print.mdx +1 -1
  6. package/mtds/ai/print.stories.tsx +1 -2
  7. package/mtds/alert/alert.js +16 -11
  8. package/mtds/alert/alert.js.map +1 -1
  9. package/mtds/analytics/analytics.js +118 -118
  10. package/mtds/analytics/analytics.js.map +1 -1
  11. package/mtds/app/app-observer.js +31 -36
  12. package/mtds/app/app-observer.js.map +1 -1
  13. package/mtds/app/app-toggle.js +12 -26
  14. package/mtds/app/app-toggle.js.map +1 -1
  15. package/mtds/app/app-toggle2.js +6 -11
  16. package/mtds/app/app-toggle2.js.map +1 -1
  17. package/mtds/app/app.js +66 -60
  18. package/mtds/app/app.js.map +1 -1
  19. package/mtds/atlas/atlas-element.js +83 -93
  20. package/mtds/atlas/atlas-element.js.map +1 -1
  21. package/mtds/atlas/atlas-marker.js +63 -52
  22. package/mtds/atlas/atlas-marker.js.map +1 -1
  23. package/mtds/atlas/atlas-matgeo.js +67 -61
  24. package/mtds/atlas/atlas-matgeo.js.map +1 -1
  25. package/mtds/atlas/atlas-wms.js +33 -28
  26. package/mtds/atlas/atlas-wms.js.map +1 -1
  27. package/mtds/atlas/atlas.js +6 -38
  28. package/mtds/atlas/atlas.js.map +1 -1
  29. package/mtds/atlas/atlas2.js +39 -0
  30. package/mtds/atlas/atlas2.js.map +1 -0
  31. package/mtds/atlas/cluster.js +759 -1149
  32. package/mtds/atlas/cluster.js.map +1 -1
  33. package/mtds/atlas.iife.js +3 -4
  34. package/mtds/atlas.js +6 -14
  35. package/mtds/avatar/avatar.js +14 -10
  36. package/mtds/avatar/avatar.js.map +1 -1
  37. package/mtds/badge/badge.js +15 -10
  38. package/mtds/badge/badge.js.map +1 -1
  39. package/mtds/breadcrumbs/breadcrumbs.js +15 -19
  40. package/mtds/breadcrumbs/breadcrumbs.js.map +1 -1
  41. package/mtds/button/button.js +18 -20
  42. package/mtds/button/button.js.map +1 -1
  43. package/mtds/card/card.js +22 -15
  44. package/mtds/card/card.js.map +1 -1
  45. package/mtds/chart/chart-axis.js +33 -21
  46. package/mtds/chart/chart-axis.js.map +1 -1
  47. package/mtds/chart/chart-bars.js +23 -21
  48. package/mtds/chart/chart-bars.js.map +1 -1
  49. package/mtds/chart/chart-element.js +94 -88
  50. package/mtds/chart/chart-element.js.map +1 -1
  51. package/mtds/chart/chart-lines.js +35 -37
  52. package/mtds/chart/chart-lines.js.map +1 -1
  53. package/mtds/chart/chart-pies.js +17 -17
  54. package/mtds/chart/chart-pies.js.map +1 -1
  55. package/mtds/chart/chart.js +6 -52
  56. package/mtds/chart/chart.js.map +1 -1
  57. package/mtds/chart/chart2.js +21 -0
  58. package/mtds/chart/chart2.js.map +1 -0
  59. package/mtds/chip/chip.js +15 -11
  60. package/mtds/chip/chip.js.map +1 -1
  61. package/mtds/deprecations.js +76 -158
  62. package/mtds/deprecations.js.map +1 -1
  63. package/mtds/details/details.js +21 -24
  64. package/mtds/details/details.js.map +1 -1
  65. package/mtds/dialog/dialog.js +17 -21
  66. package/mtds/dialog/dialog.js.map +1 -1
  67. package/mtds/divider/divider.js +15 -20
  68. package/mtds/divider/divider.js.map +1 -1
  69. package/mtds/errorsummary/errorsummary.js +14 -16
  70. package/mtds/errorsummary/errorsummary.js.map +1 -1
  71. package/mtds/external/@turf/boolean-point-in-polygon/dist/esm/index.js +22 -25
  72. package/mtds/external/@turf/boolean-point-in-polygon/dist/esm/index.js.map +1 -1
  73. package/mtds/external/@turf/helpers/dist/esm/index.js +21 -24
  74. package/mtds/external/@turf/helpers/dist/esm/index.js.map +1 -1
  75. package/mtds/external/@turf/invariant/dist/esm/index.js +15 -19
  76. package/mtds/external/@turf/invariant/dist/esm/index.js.map +1 -1
  77. package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js +270 -297
  78. package/mtds/external/@u-elements/u-combobox/dist/u-combobox.js.map +1 -1
  79. package/mtds/external/@u-elements/u-details/dist/u-details.js +75 -101
  80. package/mtds/external/@u-elements/u-details/dist/u-details.js.map +1 -1
  81. package/mtds/external/leaflet/dist/leaflet-src.js +4257 -6151
  82. package/mtds/external/leaflet/dist/leaflet-src.js.map +1 -1
  83. package/mtds/external/leaflet/dist/leaflet.css.js +5 -606
  84. package/mtds/external/leaflet/dist/leaflet.css.js.map +1 -1
  85. package/mtds/external/point-in-polygon-hao/dist/esm/index.js +24 -25
  86. package/mtds/external/point-in-polygon-hao/dist/esm/index.js.map +1 -1
  87. package/mtds/external/robust-predicates/esm/incircle.js +5 -0
  88. package/mtds/external/robust-predicates/esm/incircle.js.map +1 -0
  89. package/mtds/external/robust-predicates/esm/insphere.js +5 -0
  90. package/mtds/external/robust-predicates/esm/insphere.js.map +1 -0
  91. package/mtds/external/robust-predicates/esm/orient2d.js +20 -22
  92. package/mtds/external/robust-predicates/esm/orient2d.js.map +1 -1
  93. package/mtds/external/robust-predicates/esm/orient3d.js +5 -0
  94. package/mtds/external/robust-predicates/esm/orient3d.js.map +1 -0
  95. package/mtds/external/robust-predicates/esm/util.js +20 -28
  96. package/mtds/external/robust-predicates/esm/util.js.map +1 -1
  97. package/mtds/external/robust-predicates/index.js +5 -0
  98. package/mtds/field/field.js +167 -214
  99. package/mtds/field/field.js.map +1 -1
  100. package/mtds/fieldset/fieldset.js +32 -30
  101. package/mtds/fieldset/fieldset.js.map +1 -1
  102. package/mtds/fileupload/fileupload.js +16 -13
  103. package/mtds/fileupload/fileupload.js.map +1 -1
  104. package/mtds/helptext/helptext.js +25 -27
  105. package/mtds/helptext/helptext.js.map +1 -1
  106. package/mtds/identitet/illustrasjons-generator/illustrasjons-generator.d.ts +1 -0
  107. package/mtds/identitet/illustrasjons-generator/index-old-1.d.ts +1 -0
  108. package/mtds/identitet/infografikk-generator/infografikk-generator.d.ts +1 -0
  109. package/mtds/index.iife.js +21 -21
  110. package/mtds/index.js +38 -31
  111. package/mtds/index.js.map +1 -1
  112. package/mtds/input/input.js +33 -47
  113. package/mtds/input/input.js.map +1 -1
  114. package/mtds/law/law-helper.js +106 -95
  115. package/mtds/law/law-helper.js.map +1 -1
  116. package/mtds/law/law.js +15 -10
  117. package/mtds/law/law.js.map +1 -1
  118. package/mtds/layout/layout.js +21 -13
  119. package/mtds/layout/layout.js.map +1 -1
  120. package/mtds/layout/layout.stories.d.ts +1 -0
  121. package/mtds/link/link.js +15 -10
  122. package/mtds/link/link.js.map +1 -1
  123. package/mtds/logo/logo-observer.js +18 -18
  124. package/mtds/logo/logo-observer.js.map +1 -1
  125. package/mtds/logo/logo.js +18 -18
  126. package/mtds/logo/logo.js.map +1 -1
  127. package/mtds/package.js +6 -0
  128. package/mtds/package.js.map +1 -0
  129. package/mtds/package.json.d.ts +112 -0
  130. package/mtds/pagination/pagination.js +46 -60
  131. package/mtds/pagination/pagination.js.map +1 -1
  132. package/mtds/popover/popover-observer.js +15 -15
  133. package/mtds/popover/popover-observer.js.map +1 -1
  134. package/mtds/popover/popover.js +18 -20
  135. package/mtds/popover/popover.js.map +1 -1
  136. package/mtds/print/print.js +15 -10
  137. package/mtds/print/print.js.map +1 -1
  138. package/mtds/print/print.stories.d.ts +0 -1
  139. package/mtds/profilering/epost.d.ts +1 -0
  140. package/mtds/progress/progress.js +15 -13
  141. package/mtds/progress/progress.js.map +1 -1
  142. package/mtds/react-atlas.js +7 -16
  143. package/mtds/react.js +36 -84
  144. package/mtds/skeleton/skeleton.js +15 -11
  145. package/mtds/skeleton/skeleton.js.map +1 -1
  146. package/mtds/spinner/spinner.js +16 -13
  147. package/mtds/spinner/spinner.js.map +1 -1
  148. package/mtds/steps/steps.js +15 -10
  149. package/mtds/steps/steps.js.map +1 -1
  150. package/mtds/styles.css +2 -1
  151. package/mtds/styles.module.js +122 -0
  152. package/mtds/styles.module.js.map +1 -0
  153. package/mtds/table/table-observer.js +23 -28
  154. package/mtds/table/table-observer.js.map +1 -1
  155. package/mtds/table/table.js +88 -60
  156. package/mtds/table/table.js.map +1 -1
  157. package/mtds/tabs/tabs.js +32 -27
  158. package/mtds/tabs/tabs.js.map +1 -1
  159. package/mtds/tag/tag.js +16 -19
  160. package/mtds/tag/tag.js.map +1 -1
  161. package/mtds/tailwind.css +0 -4
  162. package/mtds/toast/toast-helper.js +45 -25
  163. package/mtds/toast/toast-helper.js.map +1 -1
  164. package/mtds/toast/toast-observer.js +18 -18
  165. package/mtds/toast/toast-observer.js.map +1 -1
  166. package/mtds/toast/toast.js +67 -54
  167. package/mtds/toast/toast.js.map +1 -1
  168. package/mtds/togglegroup/togglegroup.js +31 -40
  169. package/mtds/togglegroup/togglegroup.js.map +1 -1
  170. package/mtds/tooltip/tooltip-element.js +12 -25
  171. package/mtds/tooltip/tooltip-element.js.map +1 -1
  172. package/mtds/typography/typography.js +38 -21
  173. package/mtds/typography/typography.js.map +1 -1
  174. package/mtds/utils.js +53 -70
  175. package/mtds/utils.js.map +1 -1
  176. package/mtds/validation/validation-observer.js +40 -47
  177. package/mtds/validation/validation-observer.js.map +1 -1
  178. package/mtds/validation/validation.js +17 -21
  179. package/mtds/validation/validation.js.map +1 -1
  180. package/package.json +9 -9
  181. package/mtds/atlas/atlas.css.js +0 -138
  182. package/mtds/atlas/atlas.css.js.map +0 -1
  183. package/mtds/atlas.js.map +0 -1
  184. package/mtds/chart/chart.css.js +0 -187
  185. package/mtds/chart/chart.css.js.map +0 -1
  186. package/mtds/package.json.js +0 -5
  187. package/mtds/package.json.js.map +0 -1
  188. package/mtds/react-atlas.js.map +0 -1
  189. package/mtds/react.js.map +0 -1
  190. package/mtds/styles.module.css.js +0 -118
  191. package/mtds/styles.module.css.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"chart-element.js","sources":["../../designsystem/chart/chart-element.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport {\n\tattachStyle,\n\tattr,\n\tdebounce,\n\tdefineElement,\n\tisBrowser,\n\tMTDSElement,\n\toff,\n\ton,\n\tonMutation,\n\ttag,\n} from \"../utils\";\nimport css from \"./chart.css?raw\";\nimport { toAxis } from \"./chart-axis\";\nimport { toBars } from \"./chart-bars\";\nimport { toLines } from \"./chart-lines\";\nimport { toPies } from \"./chart-pies\";\n\nexport type ChartData = ReturnType<typeof toData>;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-chart\": MTDSChartElement;\n\t}\n}\n\nconst EVENTS = \"click keydown mousemove mouseout\";\nconst TOOLTIP_ID = \"mtds-chart-tooltip\";\nconst TOOLTIP = isBrowser()\n\t? document.getElementById(TOOLTIP_ID) ||\n\t\ttag(\"div\", {\n\t\t\t\"aria-hidden\": \"true\",\n\t\t\tclass: styles._tooltip,\n\t\t\thidden: \"\",\n\t\t\tid: TOOLTIP_ID,\n\t\t})\n\t: null;\n\nexport class MTDSChartElement extends MTDSElement {\n\t#unmutate?: () => void;\n\t#unresize?: () => void;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"data-variant\", \"data-aspect\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" });\n\t}\n\tconnectedCallback() {\n\t\tconst render = debounce(() => this.attributeChangedCallback(), 100);\n\t\tconst resize = new ResizeObserver(() => this.handleResize());\n\t\tresize.observe(this);\n\t\tthis.#unresize = () => resize.disconnect();\n\t\tthis.#unmutate = onMutation(this, render, {\n\t\t\tattributeFilter: [\"data-tooltip\"],\n\t\t\tattributes: true,\n\t\t\tcharacterData: true,\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t});\n\t\trequestAnimationFrame(() => this.attributeChangedCallback()); // Initial setup when children is mounted\n\t\ton(this, EVENTS, this);\n\t}\n\tdisconnectedCallback() {\n\t\tif (TOOLTIP) TOOLTIP.hidden = true;\n\t\toff(this, EVENTS, this);\n\t\tthis.#unresize?.();\n\t\tthis.#unmutate?.();\n\t\tthis.#unmutate = this.#unresize = undefined;\n\t}\n\tattributeChangedCallback() {\n\t\tconst data = toData(this.querySelector(\"table\"));\n\t\tif (!data[0]) return; // We require at least one row\n\n\t\tArray.from(this.shadowRoot?.children || []).map((el) => el.remove()); // Clear shadowRoot\n\t\tconst [variant, type] = (attr(this, \"data-variant\") || \"column\").split(\"-\");\n\t\tconst aspect = attr(this, \"data-aspect\") || undefined;\n\t\tconst legend = tag(\"div\", {\n\t\t\t\"aria-hidden\": \"hidden\",\n\t\t\tclass: \"legends\",\n\t\t\trole: \"group\",\n\t\t});\n\t\tdata.slice(1).forEach(([{ value, color }]) => {\n\t\t\tconst el = tag(\"div\", { class: \"legend\" }, value);\n\t\t\tlegend.appendChild(el).style.setProperty(\"--color\", color);\n\t\t});\n\n\t\tconst { axis, groups, total } = toAxis(data, { aspect, type });\n\t\tif (variant === \"column\" || variant === \"bar\")\n\t\t\tgroups.append(...toBars(data));\n\t\tif (variant === \"line\" || variant === \"area\")\n\t\t\tgroups.append(toLines(data, { total, variant, type }));\n\t\tif (variant === \"doughnut\" || variant === \"pie\")\n\t\t\tthis.shadowRoot?.append(toPies(data, { aspect, variant }));\n\n\t\tthis.shadowRoot?.append(axis, legend); // Axis must be first\n\t\tattachStyle(this, css);\n\t}\n\thandleEvent(e: Event) {\n\t\tif (e.type === \"click\" || e.type === \"keydown\") onClick(e, this);\n\t\telse onMoveTooltip(e as MouseEvent);\n\t}\n\thandleResize() {\n\t\tconst axis = this.shadowRoot?.firstElementChild as HTMLElement | null;\n\t\tconst steps = axis?.firstElementChild as HTMLElement | null;\n\t\taxis?.classList.toggle(\"axisStepsYHalf\", (steps?.offsetHeight || 0) < 400);\n\t\taxis?.classList.toggle(\"axisStepsXHalf\", (steps?.offsetWidth || 0) < 500);\n\t}\n}\n\nfunction onClick(event: Event, self: MTDSChartElement) {\n\tif (event instanceof KeyboardEvent && event.key !== \"Enter\") return; // Only handle enter key\n\tconst el = event.composedPath()[0];\n\tconst table = self.querySelector(\"table\");\n\tconst [tr, td] =\n\t\t(el instanceof Element && attr(el, \"data-event\")?.split(\"-\").map(Number)) ||\n\t\t[];\n\n\ttable?.rows[tr]?.cells[td]?.querySelector<HTMLElement>(\"a,button\")?.click?.();\n}\n\nlet TOOLTIP_TEXT = \"\";\nfunction onMoveTooltip(event: MouseEvent) {\n\tif (!TOOLTIP) return;\n\tif (!TOOLTIP?.isConnected) document.body.append(TOOLTIP); // Ensure connected\n\n\tconst el = event.composedPath()[0];\n\tconst tip = (el instanceof Element && el.getAttribute(\"aria-label\")) || \"\";\n\n\tif (tip)\n\t\tTOOLTIP.style.transform = `translate(${Math.min(event.clientX, window.innerWidth)}px, ${event.clientY}px)`;\n\tif (tip !== TOOLTIP_TEXT) {\n\t\tif (tip) TOOLTIP.textContent = tip;\n\t\tTOOLTIP_TEXT = tip;\n\t\tTOOLTIP.hidden = !tip;\n\t}\n}\n\nconst text = (el?: Element | null) => el?.textContent?.trim() || \"\"; // Helper to get trimmed text\nconst toData = (table?: HTMLTableElement | null) =>\n\tArray.from(table?.rows || []).map((row, rowIndex, { length }) =>\n\t\tArray.from(row.cells, (cell, cellIndex) => {\n\t\t\tconst rowHeading = text(row.cells[0]);\n\t\t\tconst colHeading = text(table?.rows[0].cells[cellIndex]);\n\t\t\tconst value = text(cell);\n\t\t\tconst tooltip =\n\t\t\t\tlength === 2 // If only header and one row, use simple tooltip only showing value\n\t\t\t\t\t? `${colHeading}: ${value}`\n\t\t\t\t\t: `${rowHeading}: ${value}${colHeading ? ` (${colHeading})` : \"\"}`;\n\t\t\tattr(cell, \"tabindex\", \"-1\");\n\n\t\t\treturn {\n\t\t\t\tnumber: (cellIndex && rowIndex && Number.parseFloat(value)) || 0, // First row and column is not a number\n\t\t\t\tevent: cell.querySelector(\"a,button\") && `${rowIndex}-${cellIndex}`, // Reference to proxy events\n\t\t\t\tcolor: `var(--mtdsc-chart-color-${rowIndex}-${cellIndex}, var(--mtdsc-chart-color-${rowIndex}, var(--mtdsc-chart-color-base)))`,\n\t\t\t\tvalue,\n\t\t\t\ttooltip: attr(cell, \"data-tooltip\") || tooltip,\n\t\t\t};\n\t\t}),\n\t);\n\ndefineElement(\"mtds-chart\", MTDSChartElement);\n"],"names":["EVENTS","TOOLTIP_ID","TOOLTIP","isBrowser","tag","styles","MTDSChartElement","MTDSElement","#unmutate","#unresize","render","debounce","resize","onMutation","on","off","data","toData","el","variant","type","attr","aspect","legend","value","color","axis","groups","total","toAxis","toBars","toLines","toPies","attachStyle","css","onClick","steps","event","self","table","tr","td","TOOLTIP_TEXT","onMoveTooltip","tip","text","row","rowIndex","length","cell","cellIndex","rowHeading","colHeading","tooltip","defineElement"],"mappings":";;;;;;;AA2BA,MAAMA,IAAS,oCACTC,IAAa,sBACbC,IAAUC,MACb,SAAS,eAAeF,CAAU,KACnCG,EAAI,OAAO;AAAA,EACV,eAAe;AAAA,EACf,OAAOC,EAAO;AAAA,EACd,QAAQ;AAAA,EACR,IAAIJ;AACL,CAAC,IACA;AAEI,MAAMK,UAAyBC,EAAY;AAAA,EACjDC;AAAA,EACAC;AAAA,EAEA,WAAW,qBAAqB;AAC/B,WAAO,CAAC,gBAAgB,aAAa;AAAA,EACtC;AAAA,EACA,cAAc;AACb,UAAA,GACA,KAAK,aAAa,EAAE,MAAM,OAAA,CAAQ;AAAA,EACnC;AAAA,EACA,oBAAoB;AACnB,UAAMC,IAASC,EAAS,MAAM,KAAK,yBAAA,GAA4B,GAAG,GAC5DC,IAAS,IAAI,eAAe,MAAM,KAAK,cAAc;AAC3D,IAAAA,EAAO,QAAQ,IAAI,GACnB,KAAKH,KAAY,MAAMG,EAAO,WAAA,GAC9B,KAAKJ,KAAYK,EAAW,MAAMH,GAAQ;AAAA,MACzC,iBAAiB,CAAC,cAAc;AAAA,MAChC,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,WAAW;AAAA,MACX,S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AAQF,MACPE,QAAa,cAAcA,IAC/BF,IAAeE,GACf1C,EAAQ,SAAS,CAAC0C;AAEpB;AAEA,MAAMC,IAAO,CAAC3B,MAAwBA,GAAI,aAAa,UAAU,IAC3DD,IAAS,CAACsB,MACf,MAAM,KAAKA,GAAO,QAAQ,CAAA,CAAE,EAAE;AAAA,EAAI,CAACO,GAAKC,GAAU,EAAE,QAAAC,QACnD,MAAM,KAAKF,EAAI,OAAO,CAACG,GAAMC,MAAc;AAC1C,UAAMC,IAAaN,EAAKC,EAAI,MAAM,CAAC,CAAC,GAC9BM,IAAaP,EAAKN,GAAO,KAAK,CAAC,EAAE,MAAMW,CAAS,CAAC,GACjD1B,IAAQqB,EAAKI,CAAI,GACjBI,IACLL,MAAW,IACR,GAAGI,CAAU,KAAK5B,CAAK,KACvB,GAAG2B,CAAU,KAAK3B,CAAK,GAAG4B,IAAa,KAAKA,CAAU,MAAM,EAAE;AAClE,WAAA/B,EAAK4B,GAAM,YAAY,IAAI,GAEpB;AAAA,MACN,QAASC,KAAaH,KAAY,OAAO,WAAWvB,CAAK,KAAM;AAAA;AAAA,MAC/D,OAAOyB,EAAK,cAAc,UAAU,KAAK,GAAGF,CAAQ,IAAIG,CAAS;AAAA;AAAA,MACjE,OAAO,2BAA2BH,CAAQ,IAAIG,CAAS,6BAA6BH,CAAQ;AAAA,MAC5F,OAAAvB;AAAA,MACA,SAASH,EAAK4B,GAAM,cAAc,KAAKI;AAAA,IAAA;AAAA,EAEzC,CAAC;AACF;AAEDC,EAAc,cAAchD,CAAgB;"}
1
+ {"version":3,"file":"chart-element.js","names":["#unresize","#unmutate"],"sources":["../../designsystem/chart/chart-element.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport {\n\tattachStyle,\n\tattr,\n\tdebounce,\n\tdefineElement,\n\tisBrowser,\n\tMTDSElement,\n\toff,\n\ton,\n\tonMutation,\n\ttag,\n} from \"../utils\";\nimport css from \"./chart.css?raw\";\nimport { toAxis } from \"./chart-axis\";\nimport { toBars } from \"./chart-bars\";\nimport { toLines } from \"./chart-lines\";\nimport { toPies } from \"./chart-pies\";\n\nexport type ChartData = ReturnType<typeof toData>;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mtds-chart\": MTDSChartElement;\n\t}\n}\n\nconst EVENTS = \"click keydown mousemove mouseout\";\nconst TOOLTIP_ID = \"mtds-chart-tooltip\";\nconst TOOLTIP = isBrowser()\n\t? document.getElementById(TOOLTIP_ID) ||\n\t\ttag(\"div\", {\n\t\t\t\"aria-hidden\": \"true\",\n\t\t\tclass: styles._tooltip,\n\t\t\thidden: \"\",\n\t\t\tid: TOOLTIP_ID,\n\t\t})\n\t: null;\n\nexport class MTDSChartElement extends MTDSElement {\n\t#unmutate?: () => void;\n\t#unresize?: () => void;\n\n\tstatic get observedAttributes() {\n\t\treturn [\"data-variant\", \"data-aspect\"]; // Using ES2015 syntax for backwards compatibility\n\t}\n\tconstructor() {\n\t\tsuper();\n\t\tthis.attachShadow({ mode: \"open\" });\n\t}\n\tconnectedCallback() {\n\t\tconst render = debounce(() => this.attributeChangedCallback(), 100);\n\t\tconst resize = new ResizeObserver(() => this.handleResize());\n\t\tresize.observe(this);\n\t\tthis.#unresize = () => resize.disconnect();\n\t\tthis.#unmutate = onMutation(this, render, {\n\t\t\tattributeFilter: [\"data-tooltip\"],\n\t\t\tattributes: true,\n\t\t\tcharacterData: true,\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t});\n\t\trequestAnimationFrame(() => this.attributeChangedCallback()); // Initial setup when children is mounted\n\t\ton(this, EVENTS, this);\n\t}\n\tdisconnectedCallback() {\n\t\tif (TOOLTIP) TOOLTIP.hidden = true;\n\t\toff(this, EVENTS, this);\n\t\tthis.#unresize?.();\n\t\tthis.#unmutate?.();\n\t\tthis.#unmutate = this.#unresize = undefined;\n\t}\n\tattributeChangedCallback() {\n\t\tconst data = toData(this.querySelector(\"table\"));\n\t\tif (!data[0]) return; // We require at least one row\n\n\t\tArray.from(this.shadowRoot?.children || []).map((el) => el.remove()); // Clear shadowRoot\n\t\tconst [variant, type] = (attr(this, \"data-variant\") || \"column\").split(\"-\");\n\t\tconst aspect = attr(this, \"data-aspect\") || undefined;\n\t\tconst legend = tag(\"div\", {\n\t\t\t\"aria-hidden\": \"hidden\",\n\t\t\tclass: \"legends\",\n\t\t\trole: \"group\",\n\t\t});\n\t\tdata.slice(1).forEach(([{ value, color }]) => {\n\t\t\tconst el = tag(\"div\", { class: \"legend\" }, value);\n\t\t\tlegend.appendChild(el).style.setProperty(\"--color\", color);\n\t\t});\n\n\t\tconst { axis, groups, total } = toAxis(data, { aspect, type });\n\t\tif (variant === \"column\" || variant === \"bar\")\n\t\t\tgroups.append(...toBars(data));\n\t\tif (variant === \"line\" || variant === \"area\")\n\t\t\tgroups.append(toLines(data, { total, variant, type }));\n\t\tif (variant === \"doughnut\" || variant === \"pie\")\n\t\t\tthis.shadowRoot?.append(toPies(data, { aspect, variant }));\n\n\t\tthis.shadowRoot?.append(axis, legend); // Axis must be first\n\t\tattachStyle(this, css);\n\t}\n\thandleEvent(e: Event) {\n\t\tif (e.type === \"click\" || e.type === \"keydown\") onClick(e, this);\n\t\telse onMoveTooltip(e as MouseEvent);\n\t}\n\thandleResize() {\n\t\tconst axis = this.shadowRoot?.firstElementChild as HTMLElement | null;\n\t\tconst steps = axis?.firstElementChild as HTMLElement | null;\n\t\taxis?.classList.toggle(\"axisStepsYHalf\", (steps?.offsetHeight || 0) < 400);\n\t\taxis?.classList.toggle(\"axisStepsXHalf\", (steps?.offsetWidth || 0) < 500);\n\t}\n}\n\nfunction onClick(event: Event, self: MTDSChartElement) {\n\tif (event instanceof KeyboardEvent && event.key !== \"Enter\") return; // Only handle enter key\n\tconst el = event.composedPath()[0];\n\tconst table = self.querySelector(\"table\");\n\tconst [tr, td] =\n\t\t(el instanceof Element && attr(el, \"data-event\")?.split(\"-\").map(Number)) ||\n\t\t[];\n\n\ttable?.rows[tr]?.cells[td]?.querySelector<HTMLElement>(\"a,button\")?.click?.();\n}\n\nlet TOOLTIP_TEXT = \"\";\nfunction onMoveTooltip(event: MouseEvent) {\n\tif (!TOOLTIP) return;\n\tif (!TOOLTIP?.isConnected) document.body.append(TOOLTIP); // Ensure connected\n\n\tconst el = event.composedPath()[0];\n\tconst tip = (el instanceof Element && el.getAttribute(\"aria-label\")) || \"\";\n\n\tif (tip)\n\t\tTOOLTIP.style.transform = `translate(${Math.min(event.clientX, window.innerWidth)}px, ${event.clientY}px)`;\n\tif (tip !== TOOLTIP_TEXT) {\n\t\tif (tip) TOOLTIP.textContent = tip;\n\t\tTOOLTIP_TEXT = tip;\n\t\tTOOLTIP.hidden = !tip;\n\t}\n}\n\nconst text = (el?: Element | null) => el?.textContent?.trim() || \"\"; // Helper to get trimmed text\nconst toData = (table?: HTMLTableElement | null) =>\n\tArray.from(table?.rows || []).map((row, rowIndex, { length }) =>\n\t\tArray.from(row.cells, (cell, cellIndex) => {\n\t\t\tconst rowHeading = text(row.cells[0]);\n\t\t\tconst colHeading = text(table?.rows[0].cells[cellIndex]);\n\t\t\tconst value = text(cell);\n\t\t\tconst tooltip =\n\t\t\t\tlength === 2 // If only header and one row, use simple tooltip only showing value\n\t\t\t\t\t? `${colHeading}: ${value}`\n\t\t\t\t\t: `${rowHeading}: ${value}${colHeading ? ` (${colHeading})` : \"\"}`;\n\t\t\tattr(cell, \"tabindex\", \"-1\");\n\n\t\t\treturn {\n\t\t\t\tnumber: (cellIndex && rowIndex && Number.parseFloat(value)) || 0, // First row and column is not a number\n\t\t\t\tevent: cell.querySelector(\"a,button\") && `${rowIndex}-${cellIndex}`, // Reference to proxy events\n\t\t\t\tcolor: `var(--mtdsc-chart-color-${rowIndex}-${cellIndex}, var(--mtdsc-chart-color-${rowIndex}, var(--mtdsc-chart-color-base)))`,\n\t\t\t\tvalue,\n\t\t\t\ttooltip: attr(cell, \"data-tooltip\") || tooltip,\n\t\t\t};\n\t\t}),\n\t);\n\ndefineElement(\"mtds-chart\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number.parseFloat(n || "0") || 0, r = m("div", { class: "axisGroup" });
4
- return e.slice(1).forEach(([, ...p]) => {
5
- const i = m("div", { class: "lineContainer", role: "list" });
6
- i.style.setProperty("--color", p[0].color);
7
- const h = x(
8
- p.map(({ number: a }, u, { length: v }) => [
9
- 100 / (v - 1) * u,
10
- 100 - a / t * 100
11
- ]),
12
- s / 100
13
- ), d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
14
- c(d, "aria-hidden", "true"), c(d, "preserveAspectRatio", "none"), c(d, "viewBox", "0 0 100 100");
15
- const l = document.createElementNS("http://www.w3.org/2000/svg", "path");
16
- if (c(l, "class", "line"), c(l, "d", h), c(l, "fill", "none"), c(l, "stroke", "currentColor"), o === "area") {
17
- const a = l.cloneNode(!0);
18
- c(a, "d", `M-100,100 L${h.slice(1)}L200,100`), c(a, "class", "lineShade"), d.append(a);
19
- }
20
- p.forEach(({ number: a, tooltip: u, event: v }, b) => {
21
- const $ = m("div", { role: "listitem" }), g = m("div", {
22
- "aria-label": u,
23
- "data-event": v,
24
- tabindex: "0",
25
- class: "linePoint",
26
- role: "img"
27
- });
28
- c($, "data-label", e[0][b + 1]?.value), g.style.setProperty("--value", `${a}`), $.appendChild(g), i.append($);
29
- }), i.appendChild(d).append(l), r.append(i);
30
- }), r;
1
+ import { attr as e, tag as t } from "../utils.js";
2
+ //#region designsystem/chart/chart-lines.ts
3
+ function n(n, { total: i, type: a, variant: o }) {
4
+ let s = Number.parseFloat(a || "0") || 0, c = t("div", { class: "axisGroup" });
5
+ return n.slice(1).forEach(([, ...a]) => {
6
+ let l = t("div", {
7
+ class: "lineContainer",
8
+ role: "list"
9
+ });
10
+ l.style.setProperty("--color", a[0].color);
11
+ let u = r(a.map(({ number: e }, t, { length: n }) => [100 / (n - 1) * t, 100 - e / i * 100]), s / 100), d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
12
+ e(d, "aria-hidden", "true"), e(d, "preserveAspectRatio", "none"), e(d, "viewBox", "0 0 100 100");
13
+ let f = document.createElementNS("http://www.w3.org/2000/svg", "path");
14
+ if (e(f, "class", "line"), e(f, "d", u), e(f, "fill", "none"), e(f, "stroke", "currentColor"), o === "area") {
15
+ let t = f.cloneNode(!0);
16
+ e(t, "d", `M-100,100 L${u.slice(1)}L200,100`), e(t, "class", "lineShade"), d.append(t);
17
+ }
18
+ a.forEach(({ number: r, tooltip: i, event: a }, o) => {
19
+ let s = t("div", { role: "listitem" }), c = t("div", {
20
+ "aria-label": i,
21
+ "data-event": a,
22
+ tabindex: "0",
23
+ class: "linePoint",
24
+ role: "img"
25
+ });
26
+ e(s, "data-label", n[0][o + 1]?.value), c.style.setProperty("--value", `${r}`), s.appendChild(c), l.append(s);
27
+ }), l.appendChild(d).append(f), c.append(l);
28
+ }), c;
31
29
  }
32
- const x = (e, t) => e.map(([n, o], s, r) => s ? y(s, r, t) : `M${n},${o}`).join(" "), w = ([e, t], [n, o]) => [e + n, t + o], f = ([e, t], [n, o]) => [e - n, t - o], C = (e, [t, n]) => [e * t, e * n], y = (e, t, n) => {
33
- const o = t[e - 1], s = t[e], [r, p] = w(o, C(n, f(s, t[e - 2] || o))), [i, h] = w(s, C(n, f(o, t[e + 1] || s)));
34
- return `C ${r},${p} ${i},${h} ${s[0]},${s[1]}`;
30
+ var r = (e, t) => e.map(([e, n], r, i) => r ? s(r, i, t) : `M${e},${n}`).join(" "), i = ([e, t], [n, r]) => [e + n, t + r], a = ([e, t], [n, r]) => [e - n, t - r], o = (e, [t, n]) => [e * t, e * n], s = (e, t, n) => {
31
+ let r = t[e - 1], s = t[e], [c, l] = i(r, o(n, a(s, t[e - 2] || r))), [u, d] = i(s, o(n, a(r, t[e + 1] || s)));
32
+ return `C ${c},${l} ${u},${d} ${s[0]},${s[1]}`;
35
33
  };
36
- export {
37
- N as toLines
38
- };
39
- //# sourceMappingURL=chart-lines.js.map
34
+ //#endregion
35
+ export { n as toLines };
36
+
37
+ //# sourceMappingURL=chart-lines.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-lines.js","sources":["../../designsystem/chart/chart-lines.ts"],"sourcesContent":["import { attr, tag } from \"../utils\";\nimport type { ChartData } from \"./chart-element\";\n\ntype Config = {\n\ttotal: number;\n\ttype: string;\n\tvariant: string;\n};\n\nexport function toLines(data: ChartData, { total, type, variant }: Config) {\n\tconst smoothing = Number.parseFloat(type || \"0\") || 0;\n\tconst group = tag(\"div\", { class: \"axisGroup\" });\n\tdata.slice(1).forEach(([, ...values]) => {\n\t\tconst lineContainer = tag(\"div\", { class: `lineContainer`, role: \"list\" });\n\t\tlineContainer.style.setProperty(\"--color\", values[0].color); // Use color of first column as default for line\n\n\t\tconst pathDefintion = toPath(\n\t\t\tvalues.map(({ number }, index, { length }) => [\n\t\t\t\t(100 / (length - 1)) * index,\n\t\t\t\t100 - (number / total) * 100,\n\t\t\t]),\n\t\t\tsmoothing / 100,\n\t\t);\n\n\t\tconst line = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\t\tattr(line, \"aria-hidden\", \"true\");\n\t\tattr(line, \"preserveAspectRatio\", \"none\");\n\t\tattr(line, \"viewBox\", \"0 0 100 100\");\n\n\t\tconst path = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n\t\tattr(path, \"class\", \"line\");\n\t\tattr(path, \"d\", pathDefintion);\n\t\tattr(path, \"fill\", \"none\");\n\t\tattr(path, \"stroke\", \"currentColor\");\n\n\t\tif (variant === \"area\") {\n\t\t\tconst lineShade = path.cloneNode(true) as SVGPathElement;\n\t\t\tattr(lineShade, \"d\", `M-100,100 L${pathDefintion.slice(1)}L200,100`);\n\t\t\tattr(lineShade, \"class\", \"lineShade\");\n\t\t\tline.append(lineShade);\n\t\t}\n\n\t\tvalues.forEach(({ number, tooltip, event }, index) => {\n\t\t\tconst col = tag(\"div\", { role: \"listitem\" });\n\t\t\tconst point = tag(\"div\", {\n\t\t\t\t\"aria-label\": tooltip,\n\t\t\t\t\"data-event\": event,\n\t\t\t\ttabindex: \"0\",\n\t\t\t\tclass: \"linePoint\",\n\t\t\t\trole: \"img\",\n\t\t\t});\n\n\t\t\tattr(col, \"data-label\", data[0][index + 1]?.value);\n\t\t\tpoint.style.setProperty(\"--value\", `${number}`); // Use color of first column as default for point\n\t\t\tcol.appendChild(point);\n\t\t\tlineContainer.append(col);\n\t\t});\n\n\t\tlineContainer.appendChild(line).append(path);\n\t\tgroup.append(lineContainer);\n\t});\n\treturn group;\n}\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"],"names":["toLines","data","total","type","variant","smoothing","group","tag","lineContainer","values","pathDefintion","toPath","number","index","length","line","attr","path","lineShade","tooltip","event","col","point","points","s","x","y","i","a","smooth","add","ax","ay","bx","by","sub","scale","all","start","end","csX","csY","ceX","ceY"],"mappings":";AASO,SAASA,EAAQC,GAAiB,EAAE,OAAAC,GAAO,MAAAC,GAAM,SAAAC,KAAmB;AAC1E,QAAMC,IAAY,OAAO,WAAWF,KAAQ,GAAG,KAAK,GAC9CG,IAAQC,EAAI,OAAO,EAAE,OAAO,aAAa;AAC/C,SAAAN,EAAK,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAA,MAAY,MAAM;AACxC,UAAMO,IAAgBD,EAAI,OAAO,EAAE,OA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ag } from \"../utils\";\nimport type { ChartData } from \"./chart-element\";\n\ntype Config = {\n\ttotal: number;\n\ttype: string;\n\tvariant: string;\n};\n\nexport function toLines(data: ChartData, { total, type, variant }: Config) {\n\tconst smoothing = Number.parseFloat(type || \"0\") || 0;\n\tconst group = tag(\"div\", { class: \"axisGroup\" });\n\tdata.slice(1).forEach(([, ...values]) => {\n\t\tconst lineContainer = tag(\"div\", { class: `lineContainer`, role: \"list\" });\n\t\tlineContainer.style.setProperty(\"--color\", values[0].color); // Use color of first column as default for line\n\n\t\tconst pathDefintion = toPath(\n\t\t\tvalues.map(({ number }, index, { length }) => [\n\t\t\t\t(100 / (length - 1)) * index,\n\t\t\t\t100 - (number / total) * 100,\n\t\t\t]),\n\t\t\tsmoothing / 100,\n\t\t);\n\n\t\tconst line = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\t\tattr(line, \"aria-hidden\", \"true\");\n\t\tattr(line, \"preserveAspectRatio\", \"none\");\n\t\tattr(line, \"viewBox\", \"0 0 100 100\");\n\n\t\tconst path = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n\t\tattr(path, \"class\", \"line\");\n\t\tattr(path, \"d\", pathDefintion);\n\t\tattr(path, \"fill\", \"none\");\n\t\tattr(path, \"stroke\", \"currentColor\");\n\n\t\tif (variant === \"area\") {\n\t\t\tconst lineShade = path.cloneNode(true) as SVGPathElement;\n\t\t\tattr(lineShade, \"d\", `M-100,100 L${pathDefintion.slice(1)}L200,100`);\n\t\t\tattr(lineShade, \"class\", \"lineShade\");\n\t\t\tline.append(lineShade);\n\t\t}\n\n\t\tvalues.forEach(({ number, tooltip, event }, index) => {\n\t\t\tconst col = tag(\"div\", { role: \"listitem\" });\n\t\t\tconst point = tag(\"div\", {\n\t\t\t\t\"aria-label\": tooltip,\n\t\t\t\t\"data-event\": event,\n\t\t\t\ttabindex: \"0\",\n\t\t\t\tclass: \"linePoint\",\n\t\t\t\trole: \"img\",\n\t\t\t});\n\n\t\t\tattr(col, \"data-label\", data[0][index + 1]?.value);\n\t\t\tpoint.style.setProperty(\"--value\", `${number}`); // Use color of first column as default for point\n\t\t\tcol.appendChild(point);\n\t\t\tlineContainer.append(col);\n\t\t});\n\n\t\tlineContainer.appendChild(line).append(path);\n\t\tgroup.append(lineContainer);\n\t});\n\treturn group;\n}\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"],"mappings":";;AASA,SAAgB,EAAQ,GAAiB,EAAE,UAAO,SAAM,cAAmB;CAC1E,IAAM,IAAY,OAAO,WAAW,KAAQ,GAAG,KAAK,GAC9C,IAAQ,EAAI,OAAO,EAAE,OAAO,YAAY,CAAC;CAkD/C,OAjDA,EAAK,MAAM,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,OAAY;EACxC,IAAM,IAAgB,EAAI,OAAO;GAAE,OAAO;GAAiB,MAAM;EAAO,CAAC;EACzE,EAAc,MAAM,YAAY,WAAW,EAAO,EAAE,CAAC,KAAK;EAE1D,IAAM,IAAgB,EACrB,EAAO,KAAK,EAAE,aAAU,GAAO,EAAE,gBAAa,CAC5C,OAAO,IAAS,KAAM,GACvB,MAAO,IAAS,IAAS,GAC1B,CAAC,GACD,IAAY,GACb,GAEM,IAAO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Ae,CAAC,GAAI,OAAkB,CAAC,IAAK,GAAI,IAAK,CAAE,GACnE,KAAS,GAAW,CAAC,GAAG,OAAiB,CAAC,IAAI,GAAG,IAAI,CAAC,GACtD,KAAU,GAAW,GAAiB,MAAmB;CAC9D,IAAM,IAAQ,EAAI,IAAI,IAChB,IAAM,EAAI,IACV,CAAC,GAAK,KAAO,EAAI,GAAO,EAAM,GAAQ,EAAI,GAAK,EAAI,IAAI,MAAM,CAAK,CAAC,CAAC,GACpE,CAAC,GAAK,KAAO,EAAI,GAAK,EAAM,GAAQ,EAAI,GAAO,EAAI,IAAI,MAAM,CAAG,CAAC,CAAC;CACxE,OAAO,KAAK,EAAI,GAAG,EAAI,GAAG,EAAI,GAAG,EAAI,GAAG,EAAI,GAAG,GAAG,EAAI;AACvD"}
@@ -1,18 +1,18 @@
1
- import { attr as s } from "../utils.js";
2
- function E(h, { aspect: l, variant: y }) {
3
- const n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
4
- l && n.style.setProperty("--mtdsc-chart-aspect", l), s(n, "class", "pie"), s(n, "viewBox", "0 0 100 100");
5
- let r = 0;
6
- const t = 50, e = y === "doughnut" ? 25 : 0, d = h.slice(1).reduce((a, [, c]) => a + c.number, 0);
7
- return h.slice(1).forEach(([, { tooltip: a, number: c, event: v, color: x }]) => {
8
- if (!c) return;
9
- const o = document.createElementNS("http://www.w3.org/2000/svg", "path"), p = r / d;
10
- r += c;
11
- const m = Math.min(r / d, 0.99999), u = m - p > 0.5 ? 1 : 0, w = 2 * Math.PI * (p - 0.25), g = 2 * Math.PI * (m - 0.25), i = Math.cos(w), $ = Math.sin(w), M = Math.cos(g), f = Math.sin(g), P = `M ${t + e * i} ${t + e * $} L ${t + t * i} ${t + t * $} A ${t} ${t} 0 ${u} 1 ${t + t * M} ${t + t * f} L ${t + e * M} ${t + e * f} A ${e} ${e} 0 ${u} 0 ${t + e * i} ${t + e * $}`;
12
- o.style.setProperty("--color", x), s(o, "aria-label", a), s(o, "data-event", v), s(o, "d", P), s(o, "role", "img"), s(o, "tabindex", "0"), n.appendChild(o);
13
- }), n;
1
+ import { attr as e } from "../utils.js";
2
+ //#region designsystem/chart/chart-pies.ts
3
+ function t(t, { aspect: n, variant: r }) {
4
+ let i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
5
+ n && i.style.setProperty("--mtdsc-chart-aspect", n), e(i, "class", "pie"), e(i, "viewBox", "0 0 100 100");
6
+ let a = 0, o = r === "doughnut" ? 25 : 0, s = t.slice(1).reduce((e, [, t]) => e + t.number, 0);
7
+ return t.slice(1).forEach(([, { tooltip: t, number: n, event: r, color: c }]) => {
8
+ if (!n) return;
9
+ let l = document.createElementNS("http://www.w3.org/2000/svg", "path"), u = a / s;
10
+ a += n;
11
+ let d = Math.min(a / s, .99999), f = +(d - u > .5), p = 2 * Math.PI * (u - .25), m = 2 * Math.PI * (d - .25), h = Math.cos(p), g = Math.sin(p), _ = Math.cos(m), v = Math.sin(m), y = `M ${50 + o * h} ${50 + o * g} L ${50 + 50 * h} ${50 + 50 * g} A 50 50 0 ${f} 1 ${50 + 50 * _} ${50 + 50 * v} L ${50 + o * _} ${50 + o * v} A ${o} ${o} 0 ${f} 0 ${50 + o * h} ${50 + o * g}`;
12
+ l.style.setProperty("--color", c), e(l, "aria-label", t), e(l, "data-event", r), e(l, "d", y), e(l, "role", "img"), e(l, "tabindex", "0"), i.appendChild(l);
13
+ }), i;
14
14
  }
15
- export {
16
- E as toPies
17
- };
18
- //# sourceMappingURL=chart-pies.js.map
15
+ //#endregion
16
+ export { t as toPies };
17
+
18
+ //# sourceMappingURL=chart-pies.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-pies.js","sources":["../../designsystem/chart/chart-pies.ts"],"sourcesContent":["import { attr } from \"../utils\";\nimport type { ChartData } from \"./chart-element\";\n\ntype Options = { aspect?: string; variant: string };\n\nexport function toPies(data: ChartData, { aspect, variant }: Options) {\n\tconst pie = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\tif (aspect) pie.style.setProperty(\"--mtdsc-chart-aspect\", aspect);\n\tattr(pie, \"class\", \"pie\");\n\tattr(pie, \"viewBox\", \"0 0 100 100\");\n\n\tlet offset = 0;\n\tconst radius = 50;\n\tconst inner = variant === \"doughnut\" ? 25 : 0;\n\tconst total = data.slice(1).reduce((tot, [, td]) => tot + td.number, 0);\n\n\tdata.slice(1).forEach(([, { tooltip, number, event, color }]) => {\n\t\tif (!number) return; // Skip empty\n\t\tconst path = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n\t\tconst start = offset / total;\n\t\toffset += number;\n\t\tconst end = Math.min(offset / total, 0.99999); // Ensure full circle works\n\t\tconst largeArc = end - start > 0.5 ? 1 : 0;\n\t\tconst a0 = 2 * Math.PI * (start - 0.25);\n\t\tconst a1 = 2 * Math.PI * (end - 0.25);\n\t\tconst x0 = Math.cos(a0);\n\t\tconst y0 = Math.sin(a0);\n\t\tconst x1 = Math.cos(a1);\n\t\tconst y1 = Math.sin(a1);\n\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\tpath.style.setProperty(\"--color\", color);\n\t\tattr(path, \"aria-label\", tooltip);\n\t\tattr(path, \"data-event\", event);\n\t\tattr(path, \"d\", d);\n\t\tattr(path, \"role\", \"img\");\n\t\tattr(path, \"tabindex\", \"0\");\n\t\tpie.appendChild(path);\n\t});\n\treturn pie;\n}\n"],"names":["toPies","data","aspect","variant","pie","attr","offset","radius","inner","total","tot","td","tooltip","number","event","color","path","start","end","largeArc","a0","a1","x0","y0","x1","y1","d"],"mappings":";AAKO,SAASA,EAAOC,GAAiB,EAAE,QAAAC,GAAQ,SAAAC,KAAoB;AACrE,QAAMC,IAAM,SAAS,gBAA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;AAEnU,IAAAP,EAAK,MAAM,YAAY,WAAWD,CAAK,GACvCV,EAAKW,GAAM,cAAcJ,CAAO,GAChCP,EAAKW,GAAM,cAAcF,CAAK,GAC9BT,EAAKW,GAAM,KAAKU,CAAC,GACjBrB,EAAKW,GAAM,QAAQ,KAAK,GACxBX,EAAKW,GAAM,YAAY,GAAG,GAC1BZ,EAAI,YAAYY,CAAI;AAAA,EACrB,CAAC,GACMZ;AACR;"}
1
+ {"version":3,"file":"chart-pies.js","names":[],"sources":["../../designsystem/chart/chart-pies.ts"],"sourcesContent":["import { attr } from \"../utils\";\nimport type { ChartData } from \"./chart-element\";\n\ntype Options = { aspect?: string; variant: string };\n\nexport function toPies(data: ChartData, { aspect, variant }: Options) {\n\tconst pie = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n\tif (aspect) pie.style.setProperty(\"--mtdsc-chart-aspect\", aspect);\n\tattr(pie, \"class\", \"pie\");\n\tattr(pie, \"viewBox\", \"0 0 100 100\");\n\n\tlet offset = 0;\n\tconst radius = 50;\n\tconst inner = variant === \"doughnut\" ? 25 : 0;\n\tconst total = data.slice(1).reduce((tot, [, td]) => tot + td.number, 0);\n\n\tdata.slice(1).forEach(([, { tooltip, number, event, color }]) => {\n\t\tif (!number) return; // Skip empty\n\t\tconst path = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n\t\tconst start = offset / total;\n\t\toffset += number;\n\t\tconst end = Math.min(offset / total, 0.99999); // Ensure full circle works\n\t\tconst largeArc = end - start > 0.5 ? 1 : 0;\n\t\tconst a0 = 2 * Math.PI * (start - 0.25);\n\t\tconst a1 = 2 * Math.PI * (end - 0.25);\n\t\tconst x0 = Math.cos(a0);\n\t\tconst y0 = Math.sin(a0);\n\t\tconst x1 = Math.cos(a1);\n\t\tconst y1 = Math.sin(a1);\n\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\tpath.style.setProperty(\"--color\", color);\n\t\tattr(path, \"aria-label\", tooltip);\n\t\tattr(path, \"data-event\", event);\n\t\tattr(path, \"d\", d);\n\t\tattr(path, \"role\", \"img\");\n\t\tattr(path, \"tabindex\", \"0\");\n\t\tpie.appendChild(path);\n\t});\n\treturn pie;\n}\n"],"mappings":";;AAKA,SAAgB,EAAO,GAAiB,EAAE,WAAQ,cAAoB;CACrE,IAAM,IAAM,SAAS,gBAAgB,8BAA8B,KAAK;CAGxE,AAFI,KAAQ,EAAI,MAAM,YAAY,wBAAwB,CAAM,GAChE,EAAK,GAAK,SAAS,KAAK,GACxB,EAAK,GAAK,WAAW,aAAa;CAElC,IAAI,IAAS,GAEP,IAAQ,MAAY,aAAa,KAAK,GACtC,IAAQ,EAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,GAAK,GAAG,OAAQ,IAAM,EAAG,QAAQ,CAAC;CAyBtE,OAvBA,EAAK,MAAM,CAAC,CAAC,CAAC,SAAS,GAAG,EAAE,YAAS,WAAQ,UAAO,gBAAa;EAChE,IAAI,CAAC,GAAQ;EACb,IAAM,IAAO,SAAS,gBAAgB,8BAA8B,MAAM,GACpE,IAAQ,IAAS;EACvB,KAAU;EACV,IAAM,IAAM,KAAK,IAAI,IAAS,GAAO,MAAO,GACtC,IAAW,MAAM,IAAQ,KACzB,IAAK,IAAI,KAAK,MAAM,IAAQ,MAC5B,IAAK,IAAI,KAAK,MAAM,IAAM,MAC1B,IAAK,KAAK,IAAI,CAAE,GAChB,IAAK,KAAK,IAAI,CAAE,GAChB,IAAK,KAAK,IAAI,CAAE,GAChB,IAAK,KAAK,IAAI,CAAE,GAChB,IAAI,KAAK,KAAS,IAAQ,EAAG,GAAG,KAAS,IAAQ,EAAG,KAAK,KAAS,KAAS,EAAG,GAAG,KAAS,KAAS,EAAG,aAA2B,EAAS,KAAK,KAAS,KAAS,EAAG,GAAG,KAAS,KAAS,EAAG,KAAK,KAAS,IAAQ,EAAG,GAAG,KAAS,IAAQ,EAAG,KAAK,EAAM,GAAG,EAAM,KAAK,EAAS,KAAK,KAAS,IAAQ,EAAG,GAAG,KAAS,IAAQ;EAQjU,AANA,EAAK,MAAM,YAAY,WAAW,CAAK,GACvC,EAAK,GAAM,cAAc,CAAO,GAChC,EAAK,GAAM,cAAc,CAAK,GAC9B,EAAK,GAAM,KAAK,CAAC,GACjB,EAAK,GAAM,QAAQ,KAAK,GACxB,EAAK,GAAM,YAAY,GAAG,GAC1B,EAAI,YAAY,CAAI;CACrB,CAAC,GACM;AACR"}
@@ -1,52 +1,6 @@
1
- import { jsx as r, jsxs as c } from "react/jsx-runtime";
2
- import { forwardRef as d } from "react";
3
- import { toCustomElementProps as s } from "../utils.js";
4
- import "./chart-element.js";
5
- import "../alert/alert.js";
6
- import "../app/app.js";
7
- import "../avatar/avatar.js";
8
- import "../badge/badge.js";
9
- import "../breadcrumbs/breadcrumbs.js";
10
- import "../button/button.js";
11
- import "../card/card.js";
12
- import "../chip/chip.js";
13
- import "../details/details.js";
14
- import "../dialog/dialog.js";
15
- import "../divider/divider.js";
16
- import "../errorsummary/errorsummary.js";
17
- import "../field/field.js";
18
- import "../fieldset/fieldset.js";
19
- import "../fileupload/fileupload.js";
20
- import "../helptext/helptext.js";
21
- import "../input/input.js";
22
- import "../law/law.js";
23
- import "../layout/layout.js";
24
- import "../link/link.js";
25
- import "../logo/logo.js";
26
- import "../pagination/pagination.js";
27
- import "../popover/popover.js";
28
- import "../print/print.js";
29
- import "../progress/progress.js";
30
- import "../skeleton/skeleton.js";
31
- import "../spinner/spinner.js";
32
- import "../steps/steps.js";
33
- import { Table as i } from "../table/table.js";
34
- import "../tabs/tabs.js";
35
- import "../tag/tag.js";
36
- import "../toast/toast.js";
37
- import "../togglegroup/togglegroup.js";
38
- import "../typography/typography.js";
39
- import "../validation/validation.js";
40
- let o = 0;
41
- const Z = d(function({ data: m, children: e, ...n }, h) {
42
- return /* @__PURE__ */ r("mtds-chart", { ref: h, ...s(n), children: m ? /* @__PURE__ */ c(i, { children: [
43
- /* @__PURE__ */ r(i.Thead, { children: m.slice(0, 1).map((p) => /* @__PURE__ */ r(i.Tr, { children: p.map((t) => /* @__PURE__ */ r(i.Th, { suppressHydrationWarning: !0, children: t }, `${++o}`)) }, `${++o}`)) }),
44
- /* @__PURE__ */ r(i.Tbody, { children: m.slice(1).map((p) => /* @__PURE__ */ r(i.Tr, { children: p.map(
45
- (t, l) => l ? /* @__PURE__ */ r(i.Td, { children: t }, `${++o}`) : /* @__PURE__ */ r(i.Th, { children: t }, `${++o}`)
46
- ) }, `${++o}`)) })
47
- ] }, `table_${++o}`) : e });
48
- });
49
- export {
50
- Z as Chart
51
- };
52
- //# sourceMappingURL=chart.js.map
1
+ //#region designsystem/chart/chart.css?raw
2
+ var e = "/* NOTE: Using --mtds- not --mtds- since we're inside shadow dom */\n:host(:not([hidden])) { display: grid; gap: var(--mtds-6) }\n[data-event] { cursor: pointer } /* Used to forward clicks from Chart ShaowDOM to relevant cell in child table */\n\n.pie { overflow: visible; aspect-ratio: var(--mtdsc-chart-aspect) }\n.pie > path {\n fill: var(--color);\n outline: none;\n stroke-width: var(--mtdsc-chart-border-width);\n stroke: var(--mtdsc-chart-border-color);\n transform-origin: center;\n transition: scale 0.2s;\n vector-effect: non-scaling-stroke;\n}\n.pie > path:focus-visible,\n.pie > path:hover { scale: 1.05 }\n:host([data-steps=\"false\"]) .axisStep::before,\n:host([data-variant=\"doughnut\"]) .axis,\n:host([data-variant=\"pie\"]) .axis { display: none }\n:host([data-labels=\"false\"]) .axisGroup::before { position: absolute; pointer-events: none; opacity: 0 } /* Keep available for screen readers */\n:host([data-labels=\"false\"]) .lineContainer > div::before,\n:host([data-labels=\"false\"]) .lineContainer > div::after { display: none }\n\n.axis {\n display: grid;\n font-size: var(--mtds-body-sm-font-size);\n gap: var(--mtdsc-chart-axis-gap);\n grid-template-columns: fit-content(7em) 1fr;\n grid-template-rows: 1fr auto;\n grid-template-areas:\n \"y-axis chart\"\n \"y-axis x-axis\";\n}\n\n.axis::before {\n border-bottom-left-radius: var(--mtdsc-chart-axis-edge-radius);\n border-color: var(--mtdsc-chart-axis-edge-color);\n border-style: solid;\n border-width: 0 0 var(--mtdsc-chart-axis-edge-width) var(--mtdsc-chart-axis-edge-width);\n content: \"\";\n grid-area: chart;\n pointer-events: none;\n z-index: 2;\n}\n\n.axisSteps,\n.axisStep,\n.axisGroups,\n.axisGroup { box-sizing: border-box; display: grid; position: relative } /* Help .lineContainer positioning */\n.axisGroups {\n --gap: max(1px, clamp(.5%, calc(10% / var(--bars) * var(--groups)), var(--mtdsc-chart-axis-gap)));\n gap: var(--mtdsc-chart-axis-gap) var(--gap);\n grid-area: chart / chart / x-axis / chart;\n grid-auto-columns: 1fr;\n grid-template-rows: subgrid;\n padding: 0 var(--mtdsc-chart-axis-gap);\n text-align: center;\n}\n.axisGroup { grid-row: inherit; grid-template: inherit }\n.axisGroup::before { order: 1; content: attr(data-label); direction: ltr; min-width: 0 } /* Allow word-wrapping */\n:host(:not([data-variant|=\"bar\"])) { .axisGroup::before { justify-self: center; text-align: start; writing-mode: vertical-rl } }\n\n.axisSteps { align-items: end; aspect-ratio: var(--mtdsc-chart-aspect); grid-area: chart / y-axis / chart / chart; grid-auto-rows: 1fr; grid-template: 1px / subgrid }\n.axisStep { align-items: start; grid-column: inherit; grid-template-columns: inherit; height: 1px; text-align: right }\n.axisStep::after { border-bottom: var(--mtdsc-chart-axis-border); content: \"\" }\n.axisStep::before { content: attr(data-label) / \"\"; translate: 0 -50% } /* Hide form screen readers */\n.axisStep[data-label=\"0\"]::after { opacity: 0 } /* Hide 0 line as it overlapps with .axis::before */\n\n/* Reduce amount of steps if small space */\n:host(:not([data-variant|=\"bar\"])) .axisStepsYHalf .axisStep:nth-last-child(even) { display: none }\n:host(:not([data-variant|=\"bar\"])) .axisStepsYHalf .axisSteps:has(.axisStep:nth-last-child(even):first-child) { grid-template-rows: 0.5fr }\n:host([data-variant|=\"bar\"]) .axisStepsXHalf .axisStep:nth-last-child(even) { display: none }\n:host([data-variant|=\"bar\"]) .axisStepsXHalf .axisSteps:has(.axisStep:nth-last-child(even):first-child) { grid-template-columns: 0.5fr }\n\n:host([data-variant|=\"bar\"]) .axisSteps,\n:host([data-variant|=\"bar\"]) .axisGroup { direction: rtl }\n:host([data-variant|=\"bar\"]) .axisSteps > *,\n:host([data-variant|=\"bar\"]) .axisGroup > * { direction: ltr }\n:host([data-variant|=\"bar\"]) .axisGroups {\n aspect-ratio: var(--mtdsc-chart-aspect);\n gap: 1% var(--mtdsc-chart-axis-gap);\n grid-area: chart / y-axis / chart / chart;\n grid-template: none / subgrid;\n padding: var(--mtdsc-chart-axis-gap) 0;\n row-gap: var(--mtdsc-chart-axis-gap);\n text-align: right;\n}\n:host([data-variant|=\"bar\"]) .axisGroup::before { align-self: center }\n:host([data-variant|=\"bar\"]) .axisGroup { grid-column: inherit; grid-row: auto }\n:host([data-variant|=\"bar\"]) .axisSteps { align-items: stretch; aspect-ratio: auto; grid-area: chart / chart / x-axis / chart; grid-auto-columns: 1fr; grid-template: subgrid / 1px }\n:host([data-variant|=\"bar\"]) .axisStep { align-items: stretch; grid-row: inherit; grid-column: auto; grid-template-rows: inherit; grid-template-columns: none; text-align: center }\n:host([data-variant|=\"bar\"]) .axisStep::after { order: -1; border-left: var(--mtdsc-chart-axis-border); border-bottom: 0 }\n:host([data-variant|=\"bar\"]) .axisStep::before { translate: -50% 0 }\n\n.axisGroupContent { display: flex }\n:host([data-variant=\"column-stacked\"]) .axisGroupContent { flex-direction: column-reverse }\n:host([data-variant=\"bar\"]) .axisGroupContent { flex-direction: column }\n:host([data-variant=\"bar-stacked\"]) .axisGroupContent { flex-direction: row }\n\n.bar {\n --size: calc(var(--value) / var(--total, 1) * 100%);\n align-self: end;\n background: var(--color);\n border: var(--mtdsc-chart-border-color) solid var(--mtdsc-chart-border-width);\n border-radius: var(--mtds-border-radius-sm) var(--mtds-border-radius-sm) 0 0;\n box-sizing: border-box;\n height: var(--size);\n width: 100%;\n}\n.bar:focus-visible,\n.linePoint:focus-visible { box-shadow: var(--mtdsc-focus-boxShadow); outline: var(--mtdsc-focus-outline); outline-offset: var(--mtds-border-width-focus); z-index: 2 }\n:host([data-variant|=\"bar\"]) .bar { border-radius: 0 var(--mtds-border-radius-sm) var(--mtds-border-radius-sm) 0; width: var(--size); height: 100%; align-self: start }\n\n/* Prevent double border - using margin to see border around bars */\n/* Prevent double border - using border to avoid affecting size */\n:host(:not([data-variant])) .bar + .bar,\n:host([data-variant=\"column\"]) .bar + .bar { margin-left: -1px }\n:host([data-variant=\"column-stacked\"]) .bar:not(:last-child) { border-radius: 0 }\n:host([data-variant=\"column-stacked\"]) .bar + .bar { border-bottom: none }\n:host([data-variant=\"bar\"]) .bar + .bar { margin-top: -1px }\n:host([data-variant=\"bar-stacked\"]) .bar:not(:last-child) { border-radius: 0 }\n:host([data-variant=\"bar-stacked\"]) .bar + .bar { border-left: none }\n\n.lineContainer { align-items: flex-start; display: flex; justify-content: space-between; pointer-events: none; grid-row: chart }\n.lineContainer > svg, .lineContainer { position: absolute; width: 100%; height: 100% }\n.lineContainer > svg { overflow: clip visible }\n.lineContainer > div { position: relative; height: 100% }\n.lineContainer > div + div::before {\n border-left: var(--mtdsc-chart-axis-border);\n content: '';\n inset: 0 auto 0 0;\n position: absolute;\n}\n\n.lineContainer > div::after {\n content: attr(data-label) / '';\n position: absolute;\n top: 100%;\n translate: -50%;\n}\n\n:host([data-variant|=\"line\"]) .axisGroups,\n:host([data-variant|=\"area\"]) .axisGroups { padding: 0 }\n.lineShade, .line { fill: none; stroke: var(--color); stroke-linejoin: round; stroke-linecap: round; stroke-width: 1.5; vector-effect: non-scaling-stroke }\n.lineShade { stroke: none; fill: var(--color); opacity: 0.3; mask: linear-gradient(to bottom, black, transparent) }\n\n.linePoint, .line, :host:has(.linePoint) .legend::before { filter: var(--_mtdsc-chart-line-filter) } /* Ensure more contrast for line colors */\n.linePoint {\n --size: var(--mtds-2);\n background: var(--color);\n border-radius: var(--mtds-border-radius-full);\n border: var(--mtdsc-chart-border-width) solid var(--mtdsc-chart-border-color);\n box-sizing: border-box;\n height: var(--size);\n margin: calc(var(--size) / -2);\n padding: 0;\n pointer-events: all;\n position: relative;\n top: calc(100% - var(--value) / var(--total, 1) * 100%);\n transition: scale 0.2s;\n width: var(--size);\n z-index: 2;\n}\n.linePoint:focus-visible,\n.linePoint:hover { scale: 1.3 }\n.linePoint::before { content: \"\"; position: absolute; inset: calc(var(--mtds-3) * -1); /* Increase click surface */ }\n:host([data-dots=\"false\"]) .linePoint { background: none; border: none }\n\n:host([data-legend=\"false\"]) .legends { display: none }\n.legends { align-items: center; display: flex; flex-wrap: wrap; gap: var(--mtds-2) var(--mtds-5); justify-content: center }\n.legend { display: flex; align-items: center; gap: var(--mtds-2) }\n.legend::before {\n background: var(--color);\n border-radius: var(--mtds-border-radius-full);\n border: var(--mtdsc-chart-border-color) solid var(--mtdsc-chart-border-width);\n box-sizing: border-box;\n content: \"\";\n display: inline-block;\n height: var(--mtds-5);\n vertical-align: middle;\n width: var(--mtds-5);\n}\n";
3
+ //#endregion
4
+ export { e as default };
5
+
6
+ //# sourceMappingURL=chart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart.js","sources":["../../designsystem/chart/chart.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { toCustomElementProps } from \"../utils\";\nimport \"./chart-element\";\nimport { Table } from \"../react\";\nimport type { CustomReactElementProps } from \"../react-types\";\nimport type { MTDSChartElement } from \"./chart-element\";\n\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicElements {\n\t\t\t\"mtds-chart\": ChartProps;\n\t\t}\n\t}\n}\n\nexport type ChartProps = CustomReactElementProps<MTDSChartElement> & {\n\tdata?: (number | string)[][];\n\t\"data-legend\"?: \"none\" | \"hidden\" | \"false\" | \"true\" | boolean;\n\t\"data-axis\"?: \"none\" | \"hidden\" | \"false\" | \"true\" | boolean;\n\t\"data-variant\"?:\n\t\t| \"area\"\n\t\t| \"bar\"\n\t\t| \"bar-stacked\"\n\t\t| \"column\"\n\t\t| \"column-stacked\"\n\t\t| \"doughnut\"\n\t\t| \"line\"\n\t\t| \"pie\";\n};\n\nlet RENDER = 0; // Ensure re-render on data change\nexport const Chart = forwardRef<MTDSChartElement, ChartProps>(function Chart(\n\t{ data, children, ...rest },\n\tref,\n) {\n\treturn (\n\t\t<mtds-chart ref={ref} {...toCustomElementProps(rest)}>\n\t\t\t{data ? (\n\t\t\t\t<Table key={`table_${++RENDER}`}>\n\t\t\t\t\t<Table.Thead>\n\t\t\t\t\t\t{data.slice(0, 1).map((tr) => (\n\t\t\t\t\t\t\t<Table.Tr key={`${++RENDER}`}>\n\t\t\t\t\t\t\t\t{tr.map((td) => (\n\t\t\t\t\t\t\t\t\t<Table.Th suppressHydrationWarning key={`${++RENDER}`}>\n\t\t\t\t\t\t\t\t\t\t{td}\n\t\t\t\t\t\t\t\t\t</Table.Th>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</Table.Tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</Table.Thead>\n\t\t\t\t\t<Table.Tbody>\n\t\t\t\t\t\t{data.slice(1).map((tr) => (\n\t\t\t\t\t\t\t<Table.Tr key={`${++RENDER}`}>\n\t\t\t\t\t\t\t\t{tr.map((td, i) =>\n\t\t\t\t\t\t\t\t\ti ? (\n\t\t\t\t\t\t\t\t\t\t<Table.Td key={`${++RENDER}`}>{td}</Table.Td>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<Table.Th key={`${++RENDER}`}>{td}</Table.Th>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</Table.Tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</Table.Tbody>\n\t\t\t\t</Table>\n\t\t\t) : (\n\t\t\t\tchildren\n\t\t\t)}\n\t\t</mtds-chart>\n\t);\n});\n"],"names":["RENDER","Chart","forwardRef","data","children","rest","ref","jsx","toCustomElementProps","jsxs","Table","tr","td","i"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAIA,IAAS;AACN,MAAMC,IAAQC,EAAyC,SAC7D,EAAE,MAAAC,GAAM,UAAAC,GAAU,GAAGC,EAAA,GACrBC,GACC;AACD,SACC,gBAAAC,EAAC,gBAAW,KAAAD,GAAW,GAAGE,EAAqBH,CAAI,GACjD,UAAAF,IACA,gBAAAM,EAACC,GAAA,EACA,UAAA;AAAA,IAAA,gBAAAH,EAACG,EAAM,OAAN,EACC,UAAAP,EAAK,MAAM,GAAG,CAAC,EAAE,IAAI,CAACQ,MACtB,gBAAAJ,EAACG,EAAM,IAAN,EACC,YAAG,IAAI,CAACE,MACR,gBAAAL,EAACG,EAAM,IAAN,EAAS,0BAAwB,IAChC,eADsC,GAAG,EAAEV,CAAM,EAEnD,CACA,KALa,GAAG,EAAEA,CAAM,EAM1B,CACA,GACF;AAAA,IACA,gBAAAO,EAACG,EAAM,OAAN,EACC,YAAK,MAAM,CAAC,EAAE,IAAI,CAACC,MACnB,gBAAAJ,EAACG,EAAM,IAAN,EACC,UAAAC,EAAG;AAAA,MAAI,CAACC,GAAIC,MACZA,sBACEH,EAAM,IAAN,EAA8B,UAAAE,EAAA,GAAhB,GAAG,EAAEZ,CAAM,EAAQ,sBAEjCU,EAAM,IAAN,EAA8B,UAAAE,KAAhB,GAAG,EAAEZ,CAAM,EAAQ;AAAA,IAAA,KALtB,GAAG,EAAEA,CAAM,EAQ1B,CACA,EAAA,CACF;AAAA,EAAA,EAAA,GAxBW,SAAS,EAAEA,CAAM,EAyB7B,IAEAI,GAEF;AAEF,CAAC;"}
1
+ {"version":3,"file":"chart.js","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import { toCustomElementProps as e } from "../utils.js";
2
+ import "./chart-element.js";
3
+ import { Table as t } from "../table/table.js";
4
+ import "../react.js";
5
+ import { forwardRef as n } from "react";
6
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
7
+ //#region designsystem/chart/chart.tsx
8
+ var a = 0, o = n(function({ data: n, children: o, ...s }, c) {
9
+ return /* @__PURE__ */ r("mtds-chart", {
10
+ ref: c,
11
+ ...e(s),
12
+ children: n ? /* @__PURE__ */ i(t, { children: [/* @__PURE__ */ r(t.Thead, { children: n.slice(0, 1).map((e) => /* @__PURE__ */ r(t.Tr, { children: e.map((e) => /* @__PURE__ */ r(t.Th, {
13
+ suppressHydrationWarning: !0,
14
+ children: e
15
+ }, `${++a}`)) }, `${++a}`)) }), /* @__PURE__ */ r(t.Tbody, { children: n.slice(1).map((e) => /* @__PURE__ */ r(t.Tr, { children: e.map((e, n) => r(n ? t.Td : t.Th, { children: e }, `${++a}`)) }, `${++a}`)) })] }, `table_${++a}`) : o
16
+ });
17
+ });
18
+ //#endregion
19
+ export { o as Chart };
20
+
21
+ //# sourceMappingURL=chart2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart2.js","names":[],"sources":["../../designsystem/chart/chart.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport { toCustomElementProps } from \"../utils\";\nimport \"./chart-element\";\nimport { Table } from \"../react\";\nimport type { CustomReactElementProps } from \"../react-types\";\nimport type { MTDSChartElement } from \"./chart-element\";\n\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicElements {\n\t\t\t\"mtds-chart\": ChartProps;\n\t\t}\n\t}\n}\n\nexport type ChartProps = CustomReactElementProps<MTDSChartElement> & {\n\tdata?: (number | string)[][];\n\t\"data-legend\"?: \"none\" | \"hidden\" | \"false\" | \"true\" | boolean;\n\t\"data-axis\"?: \"none\" | \"hidden\" | \"false\" | \"true\" | boolean;\n\t\"data-variant\"?:\n\t\t| \"area\"\n\t\t| \"bar\"\n\t\t| \"bar-stacked\"\n\t\t| \"column\"\n\t\t| \"column-stacked\"\n\t\t| \"doughnut\"\n\t\t| \"line\"\n\t\t| \"pie\";\n};\n\nlet RENDER = 0; // Ensure re-render on data change\nexport const Chart = forwardRef<MTDSChartElement, ChartProps>(function Chart(\n\t{ data, children, ...rest },\n\tref,\n) {\n\treturn (\n\t\t<mtds-chart ref={ref} {...toCustomElementProps(rest)}>\n\t\t\t{data ? (\n\t\t\t\t<Table key={`table_${++RENDER}`}>\n\t\t\t\t\t<Table.Thead>\n\t\t\t\t\t\t{data.slice(0, 1).map((tr) => (\n\t\t\t\t\t\t\t<Table.Tr key={`${++RENDER}`}>\n\t\t\t\t\t\t\t\t{tr.map((td) => (\n\t\t\t\t\t\t\t\t\t<Table.Th suppressHydrationWarning key={`${++RENDER}`}>\n\t\t\t\t\t\t\t\t\t\t{td}\n\t\t\t\t\t\t\t\t\t</Table.Th>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</Table.Tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</Table.Thead>\n\t\t\t\t\t<Table.Tbody>\n\t\t\t\t\t\t{data.slice(1).map((tr) => (\n\t\t\t\t\t\t\t<Table.Tr key={`${++RENDER}`}>\n\t\t\t\t\t\t\t\t{tr.map((td, i) =>\n\t\t\t\t\t\t\t\t\ti ? (\n\t\t\t\t\t\t\t\t\t\t<Table.Td key={`${++RENDER}`}>{td}</Table.Td>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<Table.Th key={`${++RENDER}`}>{td}</Table.Th>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</Table.Tr>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</Table.Tbody>\n\t\t\t\t</Table>\n\t\t\t) : (\n\t\t\t\tchildren\n\t\t\t)}\n\t\t</mtds-chart>\n\t);\n});\n"],"mappings":";;;;;;;AA8BA,IAAI,IAAS,GACA,IAAQ,EAAyC,SAC7D,EAAE,SAAM,aAAU,GAAG,KACrB,GACC;CACD,OACC,kBAAC,cAAD;EAAiB;EAAK,GAAI,EAAqB,CAAI;YACjD,IACA,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,EAAM,OAAP,EAAA,UACE,EAAK,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,MACtB,kBAAC,EAAM,IAAP,EAAA,UACE,EAAG,KAAK,MACR,kBAAC,EAAM,IAAP;GAAU,0BAAA;aACR;EACQ,GAF8B,GAAG,EAAE,GAEnC,CACV,EACQ,GANK,GAAG,EAAE,GAMV,CACV,EACW,CAAA,GACb,kBAAC,EAAM,OAAP,EAAA,UACE,EAAK,MAAM,CAAC,CAAC,CAAC,KAAK,MACnB,kBAAC,EAAM,IAAP,EAAA,UACE,EAAG,KAAK,GAAI,MAEX,EADD,IACE,EAAM,KAEN,EAAM,IAFP,EAAA,UAA+B,EAAa,GAA7B,GAAG,EAAE,GAEwB,CAE9C,EACS,GARK,GAAG,EAAE,GAQV,CACV,EACW,CAAA,CACP,EAAA,GAzBK,SAAS,EAAE,GAyBhB,IAEP;CAEU,CAAA;AAEd,CAAC"}
package/mtds/chip/chip.js CHANGED
@@ -1,12 +1,16 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import p from "clsx";
3
- import { forwardRef as e } from "react";
4
- import f from "../styles.module.css.js";
5
- const h = e(function({ as: r, className: t, ...o }, m) {
6
- const a = r || (o["data-removable"] ? "button" : "label");
7
- return /* @__PURE__ */ i(a, { className: p(f.chip, t), ref: m, ...o });
1
+ import e from "../styles.module.js";
2
+ import t from "clsx";
3
+ import { forwardRef as n } from "react";
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ //#region designsystem/chip/chip.tsx
6
+ var i = n(function({ as: n, className: i, ...a }, o) {
7
+ return /* @__PURE__ */ r(n || (a["data-removable"] ? "button" : "label"), {
8
+ className: t(e.chip, i),
9
+ ref: o,
10
+ ...a
11
+ });
8
12
  });
9
- export {
10
- h as Chip
11
- };
12
- //# sourceMappingURL=chip.js.map
13
+ //#endregion
14
+ export { i as Chip };
15
+
16
+ //# sourceMappingURL=chip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chip.js","sources":["../../designsystem/chip/chip.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\ntype ChipBaseProps<Removable> = {\n\thref?: Removable;\n\t\"data-removable\"?: boolean;\n};\n\nexport type ChipProps<\n\tRemovable,\n\tAs extends React.ElementType = Removable extends true ? \"button\" : \"label\",\n> = PolymorphicComponentPropWithRef<As, ChipBaseProps<Removable>>;\n\ntype ChipComponent = <\n\tRemovable,\n\tAs extends React.ElementType = Removable extends true ? \"button\" : \"label\",\n>(\n\tprops: ChipProps<Removable, As>,\n) => JSX.Element;\n\nexport const Chip: ChipComponent = forwardRef<null>(function Chip<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"div\",\n>({ as, className, ...rest }: ChipProps<Href, As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || (rest[\"data-removable\"] ? \"button\" : \"label\");\n\n\treturn <Tag className={clsx(styles.chip, className)} ref={ref} {...rest} />;\n}) as ChipComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"names":["Chip","forwardRef","as","className","rest","ref","Tag","jsx","clsx","styles"],"mappings":";;;;AAyBO,MAAMA,IAAsBC,EAAiB,SAGlD,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAA,GAA6BC,GAA0B;AAC5E,QAAMC,IAAMJ,MAAOE,EAAK,gBAAgB,IAAI,WAAW;AAEvD,SAAO,gBAAAG,EAACD,GAAA,EAAI,WAAWE,EAAKC,EAAO,MAAMN,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAA,CAAM;AAC1E,CAAC;"}
1
+ {"version":3,"file":"chip.js","names":[],"sources":["../../designsystem/chip/chip.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { forwardRef, type JSX } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\n\ntype ChipBaseProps<Removable> = {\n\thref?: Removable;\n\t\"data-removable\"?: boolean;\n};\n\nexport type ChipProps<\n\tRemovable,\n\tAs extends React.ElementType = Removable extends true ? \"button\" : \"label\",\n> = PolymorphicComponentPropWithRef<As, ChipBaseProps<Removable>>;\n\ntype ChipComponent = <\n\tRemovable,\n\tAs extends React.ElementType = Removable extends true ? \"button\" : \"label\",\n>(\n\tprops: ChipProps<Removable, As>,\n) => JSX.Element;\n\nexport const Chip: ChipComponent = forwardRef<null>(function Chip<\n\tHref,\n\tAs extends React.ElementType = Href extends string ? \"a\" : \"div\",\n>({ as, className, ...rest }: ChipProps<Href, As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || (rest[\"data-removable\"] ? \"button\" : \"label\");\n\n\treturn <Tag className={clsx(styles.chip, className)} ref={ref} {...rest} />;\n}) as ChipComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n"],"mappings":";;;;;AAyBA,IAAa,IAAsB,EAAiB,SAGlD,EAAE,OAAI,cAAW,GAAG,KAA6B,GAA0B;CAG5E,OAAO,kBAFK,MAAO,EAAK,oBAAoB,WAAW,UAEhD;EAAK,WAAW,EAAK,EAAO,MAAM,CAAS;EAAQ;EAAK,GAAI;CAAO,CAAA;AAC3E,CAAC"}