kanto-ds 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +26 -0
- package/README.md +155 -0
- package/dist/assets/fonts/README.md +19 -0
- package/dist/assets/fonts/manrope/OFL.txt +93 -0
- package/dist/assets/fonts/manrope/manrope-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/manrope/manrope-cyrillic-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/manrope/manrope-latin-ext-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/manrope/manrope-latin-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/mulish/OFL.txt +93 -0
- package/dist/assets/fonts/mulish/mulish-cyrillic-ext-wght-italic.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-cyrillic-wght-italic.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-cyrillic-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-latin-ext-wght-italic.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-latin-ext-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-latin-wght-italic.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-latin-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/source_code_pro/OFL.txt +93 -0
- package/dist/assets/fonts/source_code_pro/SourceCodePro-Regular.woff2 +0 -0
- package/dist/chunks/dialog-CPIfFIlF.js +29 -0
- package/dist/chunks/dialog-CPIfFIlF.js.map +1 -0
- package/dist/chunks/events-Bjl5Zmmq.js +18 -0
- package/dist/chunks/events-Bjl5Zmmq.js.map +1 -0
- package/dist/chunks/form-control-CxjBTt1c.js +17 -0
- package/dist/chunks/form-control-CxjBTt1c.js.map +1 -0
- package/dist/chunks/kt-element-CcMLO5e8.js +28 -0
- package/dist/chunks/kt-element-CcMLO5e8.js.map +1 -0
- package/dist/chunks/listbox-CUXYn_3S.js +101 -0
- package/dist/chunks/listbox-CUXYn_3S.js.map +1 -0
- package/dist/chunks/registry-X4LS9J5K.js +30 -0
- package/dist/chunks/registry-X4LS9J5K.js.map +1 -0
- package/dist/chunks/slots-BPbIdxAJ.js +7 -0
- package/dist/chunks/slots-BPbIdxAJ.js.map +1 -0
- package/dist/chunks/toaster-PmdKSV5x.js +40 -0
- package/dist/chunks/toaster-PmdKSV5x.js.map +1 -0
- package/dist/components/core/kt-avatar/kt-avatar.d.ts +49 -0
- package/dist/components/core/kt-avatar/kt-avatar.js +156 -0
- package/dist/components/core/kt-avatar/kt-avatar.js.map +1 -0
- package/dist/components/core/kt-badge/kt-badge.d.ts +77 -0
- package/dist/components/core/kt-badge/kt-badge.js +254 -0
- package/dist/components/core/kt-badge/kt-badge.js.map +1 -0
- package/dist/components/core/kt-button/kt-button.d.ts +71 -0
- package/dist/components/core/kt-button/kt-button.js +271 -0
- package/dist/components/core/kt-button/kt-button.js.map +1 -0
- package/dist/components/core/kt-card/kt-card.d.ts +62 -0
- package/dist/components/core/kt-card/kt-card.js +230 -0
- package/dist/components/core/kt-card/kt-card.js.map +1 -0
- package/dist/components/core/kt-code/kt-code.d.ts +55 -0
- package/dist/components/core/kt-code/kt-code.js +155 -0
- package/dist/components/core/kt-code/kt-code.js.map +1 -0
- package/dist/components/core/kt-icon/kt-icon.d.ts +44 -0
- package/dist/components/core/kt-icon/kt-icon.js +85 -0
- package/dist/components/core/kt-icon/kt-icon.js.map +1 -0
- package/dist/components/core/kt-kbd/kt-kbd.d.ts +38 -0
- package/dist/components/core/kt-kbd/kt-kbd.js +89 -0
- package/dist/components/core/kt-kbd/kt-kbd.js.map +1 -0
- package/dist/components/data/kt-chart/kt-chart.d.ts +99 -0
- package/dist/components/data/kt-chart/kt-chart.js +406 -0
- package/dist/components/data/kt-chart/kt-chart.js.map +1 -0
- package/dist/components/data/kt-meter/kt-meter.d.ts +63 -0
- package/dist/components/data/kt-meter/kt-meter.js +177 -0
- package/dist/components/data/kt-meter/kt-meter.js.map +1 -0
- package/dist/components/data/kt-pagination/kt-pagination.d.ts +35 -0
- package/dist/components/data/kt-pagination/kt-pagination.js +88 -0
- package/dist/components/data/kt-pagination/kt-pagination.js.map +1 -0
- package/dist/components/data/kt-stat/kt-stat.d.ts +60 -0
- package/dist/components/data/kt-stat/kt-stat.js +137 -0
- package/dist/components/data/kt-stat/kt-stat.js.map +1 -0
- package/dist/components/data/kt-table/kt-table.d.ts +99 -0
- package/dist/components/data/kt-table/kt-table.js +340 -0
- package/dist/components/data/kt-table/kt-table.js.map +1 -0
- package/dist/components/data/kt-timeline/kt-timeline.d.ts +78 -0
- package/dist/components/data/kt-timeline/kt-timeline.js +252 -0
- package/dist/components/data/kt-timeline/kt-timeline.js.map +1 -0
- package/dist/components/feedback/kt-alert/kt-alert.d.ts +46 -0
- package/dist/components/feedback/kt-alert/kt-alert.js +180 -0
- package/dist/components/feedback/kt-alert/kt-alert.js.map +1 -0
- package/dist/components/feedback/kt-empty-state/kt-empty-state.d.ts +40 -0
- package/dist/components/feedback/kt-empty-state/kt-empty-state.js +100 -0
- package/dist/components/feedback/kt-empty-state/kt-empty-state.js.map +1 -0
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.d.ts +53 -0
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js +212 -0
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js.map +1 -0
- package/dist/components/feedback/kt-skeleton/kt-skeleton.d.ts +43 -0
- package/dist/components/feedback/kt-skeleton/kt-skeleton.js +117 -0
- package/dist/components/feedback/kt-skeleton/kt-skeleton.js.map +1 -0
- package/dist/components/feedback/kt-toast/kt-toast.d.ts +57 -0
- package/dist/components/feedback/kt-toast/kt-toast.js +231 -0
- package/dist/components/feedback/kt-toast/kt-toast.js.map +1 -0
- package/dist/components/feedback/kt-toast-container/kt-toast-container.d.ts +60 -0
- package/dist/components/feedback/kt-toast-container/kt-toast-container.js +100 -0
- package/dist/components/feedback/kt-toast-container/kt-toast-container.js.map +1 -0
- package/dist/components/feedback/kt-toast-container/toaster.d.ts +37 -0
- package/dist/components/feedback/kt-tooltip/kt-tooltip.d.ts +57 -0
- package/dist/components/feedback/kt-tooltip/kt-tooltip.js +138 -0
- package/dist/components/feedback/kt-tooltip/kt-tooltip.js.map +1 -0
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.d.ts +68 -0
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js +287 -0
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js.map +1 -0
- package/dist/components/forms/kt-form/kt-form.d.ts +75 -0
- package/dist/components/forms/kt-form/kt-form.js +187 -0
- package/dist/components/forms/kt-form/kt-form.js.map +1 -0
- package/dist/components/forms/kt-input/kt-input.d.ts +112 -0
- package/dist/components/forms/kt-input/kt-input.js +556 -0
- package/dist/components/forms/kt-input/kt-input.js.map +1 -0
- package/dist/components/forms/kt-input-menu/kt-input-menu.d.ts +60 -0
- package/dist/components/forms/kt-input-menu/kt-input-menu.js +313 -0
- package/dist/components/forms/kt-input-menu/kt-input-menu.js.map +1 -0
- package/dist/components/forms/kt-label-input/kt-label-input.d.ts +42 -0
- package/dist/components/forms/kt-label-input/kt-label-input.js +69 -0
- package/dist/components/forms/kt-label-input/kt-label-input.js.map +1 -0
- package/dist/components/forms/kt-select/kt-select.d.ts +80 -0
- package/dist/components/forms/kt-select/kt-select.js +334 -0
- package/dist/components/forms/kt-select/kt-select.js.map +1 -0
- package/dist/components/forms/kt-textarea/kt-textarea.d.ts +62 -0
- package/dist/components/forms/kt-textarea/kt-textarea.js +239 -0
- package/dist/components/forms/kt-textarea/kt-textarea.js.map +1 -0
- package/dist/components/forms/kt-toggle/kt-toggle.d.ts +53 -0
- package/dist/components/forms/kt-toggle/kt-toggle.js +170 -0
- package/dist/components/forms/kt-toggle/kt-toggle.js.map +1 -0
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.d.ts +45 -0
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js +93 -0
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js.map +1 -0
- package/dist/components/navigation/kt-header/kt-header.d.ts +67 -0
- package/dist/components/navigation/kt-header/kt-header.js +195 -0
- package/dist/components/navigation/kt-header/kt-header.js.map +1 -0
- package/dist/components/navigation/kt-page-header/kt-page-header.d.ts +48 -0
- package/dist/components/navigation/kt-page-header/kt-page-header.js +111 -0
- package/dist/components/navigation/kt-page-header/kt-page-header.js.map +1 -0
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.d.ts +63 -0
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js +228 -0
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js.map +1 -0
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.d.ts +94 -0
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js +265 -0
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js.map +1 -0
- package/dist/components/navigation/kt-tabs/kt-tabs.d.ts +64 -0
- package/dist/components/navigation/kt-tabs/kt-tabs.js +175 -0
- package/dist/components/navigation/kt-tabs/kt-tabs.js.map +1 -0
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.d.ts +50 -0
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js +191 -0
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js.map +1 -0
- package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.d.ts +55 -0
- package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js +128 -0
- package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js.map +1 -0
- package/dist/components/overlays/kt-collapsible/kt-collapsible.d.ts +42 -0
- package/dist/components/overlays/kt-collapsible/kt-collapsible.js +107 -0
- package/dist/components/overlays/kt-collapsible/kt-collapsible.js.map +1 -0
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.d.ts +56 -0
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +155 -0
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js.map +1 -0
- package/dist/components/overlays/kt-dropdown/kt-dropdown.d.ts +64 -0
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js +212 -0
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js.map +1 -0
- package/dist/components/overlays/kt-modal/kt-modal.d.ts +61 -0
- package/dist/components/overlays/kt-modal/kt-modal.js +207 -0
- package/dist/components/overlays/kt-modal/kt-modal.js.map +1 -0
- package/dist/components/overlays/kt-side-panel/kt-side-panel.d.ts +52 -0
- package/dist/components/overlays/kt-side-panel/kt-side-panel.js +178 -0
- package/dist/components/overlays/kt-side-panel/kt-side-panel.js.map +1 -0
- package/dist/icons/defaults.d.ts +25 -0
- package/dist/icons/index.d.ts +3 -0
- package/dist/icons/index.js +37 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/icons/registry.d.ts +38 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/countries.d.ts +37 -0
- package/dist/internal/dialog.d.ts +22 -0
- package/dist/internal/events.d.ts +14 -0
- package/dist/internal/form-control.d.ts +27 -0
- package/dist/internal/format.d.ts +8 -0
- package/dist/internal/kt-element.d.ts +22 -0
- package/dist/internal/listbox.d.ts +36 -0
- package/dist/internal/slots.d.ts +10 -0
- package/dist/react/index.d.ts +208 -0
- package/dist/react/index.js +314 -0
- package/dist/react/index.js.map +1 -0
- package/dist/styles.css +13 -0
- package/dist/tokens/README.md +63 -0
- package/dist/tokens/base.css +79 -0
- package/dist/tokens/colors.css +125 -0
- package/dist/tokens/fonts.css +136 -0
- package/dist/tokens/index.css +12 -0
- package/dist/tokens/responsive.css +108 -0
- package/dist/tokens/spacing.css +66 -0
- package/dist/tokens/theme-light.css +144 -0
- package/dist/tokens/typography.css +41 -0
- package/dist/vue/index.d.ts +143 -0
- package/dist/vue/index.js +56 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +296 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kt-icon.js","sources":["../../../../src/components/core/kt-icon/kt-icon.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\nimport { getIcon, type IconNode } from 'kanto-ds/icons';\nimport '../../../icons/defaults.js';\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\n/** Names already reported as missing, so the console gets one line per icon. */\nconst warned = new Set<string>();\n\n/** Builds one SVG child from a Lucide `[tag, attrs]` pair. */\nfunction toSvgChild([tag, attrs]: IconNode[number]): SVGElement {\n const element = document.createElementNS(SVG_NS, tag);\n for (const [name, value] of Object.entries(attrs)) {\n if (value !== undefined) element.setAttribute(name, String(value));\n }\n return element;\n}\n\n/**\n * A Lucide icon, resolved from the registry by name.\n *\n * The icon inherits `currentColor`, so it is coloured by setting `color` on\n * the element or on any ancestor — there is no colour attribute to keep in\n * sync with the surrounding text.\n *\n * Unknown names render nothing but still occupy their box, so a typo shifts no\n * layout while you find it in the console.\n *\n * @element kt-icon\n *\n * @csspart svg - The `<svg>` root.\n *\n * @example\n * ```html\n * <kt-icon name=\"search\"></kt-icon>\n * <kt-icon name=\"trash-2\" size=\"16\" label=\"Delete\"></kt-icon>\n * ```\n */\nexport class KtIcon extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: none;\n vertical-align: middle;\n color: inherit;\n }\n\n svg {\n display: block;\n }\n `,\n ];\n\n /** Icon name, kebab-case: `chevron-down`, `circle-alert`. */\n @property({ type: String, reflect: true })\n name = '';\n\n /** Width and height in pixels. */\n @property({ type: Number, reflect: true })\n size = 24;\n\n /** Stroke width passed to the SVG. */\n @property({ type: Number, attribute: 'stroke-width' })\n strokeWidth = 2;\n\n /**\n * Accessible name. Set it when the icon carries meaning on its own; leave it\n * off — the default — when adjacent text already says what this is, and the\n * icon is hidden from assistive technology.\n */\n @property({ type: String })\n label = '';\n\n override render(): TemplateResult | typeof nothing {\n const node = getIcon(this.name);\n\n if (!node) {\n if (this.name && !warned.has(this.name)) {\n warned.add(this.name);\n console.warn(\n `<kt-icon>: no icon registered as \"${this.name}\". ` +\n `Register it with registerIcons({ ... }) from \"kanto-ds/icons\".`,\n );\n }\n return html`<svg\n part=\"svg\"\n width=${this.size}\n height=${this.size}\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n ></svg>`;\n }\n\n return html`<svg\n part=\"svg\"\n xmlns=${SVG_NS}\n width=${this.size}\n height=${this.size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=${this.strokeWidth}\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n role=${this.label ? 'img' : nothing}\n aria-label=${this.label || nothing}\n aria-hidden=${this.label ? nothing : 'true'}\n >\n ${node.map(toSvgChild)}\n </svg>`;\n }\n}\n\ndefineElement('kt-icon', KtIcon);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-icon': KtIcon;\n }\n}\n"],"names":["SVG_NS","warned","toSvgChild","tag","attrs","element","name","value","KtIcon","KtElement","css","node","getIcon","html","nothing","__decorateClass","property","defineElement"],"mappings":";;;;;;;;;AAMA,MAAMA,IAAS,8BAGTC,wBAAa,IAAA;AAGnB,SAASC,EAAW,CAACC,GAAKC,CAAK,GAAiC;AAC9D,QAAMC,IAAU,SAAS,gBAAgBL,GAAQG,CAAG;AACpD,aAAW,CAACG,GAAMC,CAAK,KAAK,OAAO,QAAQH,CAAK;AAC9C,IAAIG,MAAU,UAAWF,EAAQ,aAAaC,GAAM,OAAOC,CAAK,CAAC;AAEnE,SAAOF;AACT;AAsBO,MAAMG,UAAeC,EAAU;AAAA,EAA/B,cAAA;AAAA,UAAA,GAAA,SAAA,GAqBL,KAAA,OAAO,IAIP,KAAA,OAAO,IAIP,KAAA,cAAc,GAQd,KAAA,QAAQ;AAAA,EAAA;AAAA,EApCR,OAAA;AAAA,SAAgB,SAAS;AAAA,MACvBA,EAAU;AAAA,MACVC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,EAcF;AAAA,EAsBS,SAA0C;AACjD,UAAMC,IAAOC,EAAQ,KAAK,IAAI;AAE9B,WAAKD,IAiBEE;AAAA;AAAA,cAEGb,CAAM;AAAA,cACN,KAAK,IAAI;AAAA,eACR,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA,qBAIH,KAAK,WAAW;AAAA;AAAA;AAAA,aAGxB,KAAK,QAAQ,QAAQc,CAAO;AAAA,mBACtB,KAAK,SAASA,CAAO;AAAA,oBACpB,KAAK,QAAQA,IAAU,MAAM;AAAA;AAAA,QAEzCH,EAAK,IAAIT,CAAU,CAAC;AAAA,eA/BlB,KAAK,QAAQ,CAACD,EAAO,IAAI,KAAK,IAAI,MACpCA,EAAO,IAAI,KAAK,IAAI,GACpB,QAAQ;AAAA,MACN,qCAAqC,KAAK,IAAI;AAAA,IAAA,IAI3CY;AAAA;AAAA,gBAEG,KAAK,IAAI;AAAA,iBACR,KAAK,IAAI;AAAA;AAAA;AAAA;AAAA,EAuBxB;AACF;AAxDEE,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GApB9BR,EAqBX,WAAA,MAAA;AAIAO,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GAxB9BR,EAyBX,WAAA,MAAA;AAIAO,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,QAAQ,WAAW,gBAAgB;AAAA,GA5B1CR,EA6BX,WAAA,aAAA;AAQAO,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GApCfR,EAqCX,WAAA,OAAA;AA0CFS,EAAc,WAAWT,CAAM;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { KtElement } from '#internal/kt-element';
|
|
3
|
+
/**
|
|
4
|
+
* A keyboard shortcut.
|
|
5
|
+
*
|
|
6
|
+
* Renders per platform: `⌘ K` on a Mac, `Ctrl K` elsewhere. A shortcut printed
|
|
7
|
+
* with the wrong modifier is worse than none — the reader tries it, it does not
|
|
8
|
+
* work, and they stop trusting the hints.
|
|
9
|
+
*
|
|
10
|
+
* @element kt-kbd
|
|
11
|
+
*
|
|
12
|
+
* @slot - The key, when `keys` is not used.
|
|
13
|
+
*
|
|
14
|
+
* @csspart base - The wrapper.
|
|
15
|
+
* @csspart key - One key.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```html
|
|
19
|
+
* <kt-kbd keys="meta k"></kt-kbd>
|
|
20
|
+
* <kt-kbd>/</kt-kbd>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class KtKbd extends KtElement {
|
|
24
|
+
static styles: import("lit").CSSResultGroup[];
|
|
25
|
+
/** Space-separated keys: `meta k`, `ctrl shift p`. */
|
|
26
|
+
keys: string;
|
|
27
|
+
/** Forces a platform instead of sniffing the current one. */
|
|
28
|
+
platform: 'auto' | 'mac' | 'other';
|
|
29
|
+
private get isMac();
|
|
30
|
+
/** The keys as they will be shown. Exposed so tests and docs can read them. */
|
|
31
|
+
get labels(): string[];
|
|
32
|
+
render(): TemplateResult;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'kt-kbd': KtKbd;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { css as c, html as o } from "lit";
|
|
2
|
+
import { property as p } from "lit/decorators.js";
|
|
3
|
+
import { K as l, d as f } from "../../../chunks/kt-element-CcMLO5e8.js";
|
|
4
|
+
var m = Object.defineProperty, d = (a, t, e, y) => {
|
|
5
|
+
for (var r = void 0, s = a.length - 1, n; s >= 0; s--)
|
|
6
|
+
(n = a[s]) && (r = n(t, e, r) || r);
|
|
7
|
+
return r && m(t, e, r), r;
|
|
8
|
+
};
|
|
9
|
+
const b = {
|
|
10
|
+
mod: "⌘",
|
|
11
|
+
meta: "⌘",
|
|
12
|
+
cmd: "⌘",
|
|
13
|
+
ctrl: "⌃",
|
|
14
|
+
alt: "⌥",
|
|
15
|
+
option: "⌥",
|
|
16
|
+
shift: "⇧",
|
|
17
|
+
enter: "↵",
|
|
18
|
+
escape: "esc",
|
|
19
|
+
backspace: "⌫"
|
|
20
|
+
}, h = {
|
|
21
|
+
mod: "Ctrl",
|
|
22
|
+
meta: "Win",
|
|
23
|
+
cmd: "Ctrl",
|
|
24
|
+
ctrl: "Ctrl",
|
|
25
|
+
alt: "Alt",
|
|
26
|
+
option: "Alt",
|
|
27
|
+
shift: "Shift",
|
|
28
|
+
enter: "Enter",
|
|
29
|
+
escape: "Esc",
|
|
30
|
+
backspace: "Backspace"
|
|
31
|
+
};
|
|
32
|
+
class i extends l {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments), this.keys = "", this.platform = "auto";
|
|
35
|
+
}
|
|
36
|
+
static {
|
|
37
|
+
this.styles = [
|
|
38
|
+
l.styles,
|
|
39
|
+
c`
|
|
40
|
+
:host {
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
gap: 3px;
|
|
44
|
+
vertical-align: middle;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
kbd {
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
min-width: 20px;
|
|
52
|
+
height: 20px;
|
|
53
|
+
padding: 0 5px;
|
|
54
|
+
color: var(--color-text-500);
|
|
55
|
+
font: var(--font-normal-small);
|
|
56
|
+
font-family: var(--font-family-body);
|
|
57
|
+
background: var(--surface-card);
|
|
58
|
+
border: var(--border-width) solid var(--border-subtle);
|
|
59
|
+
border-radius: 5px;
|
|
60
|
+
}
|
|
61
|
+
`
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
get isMac() {
|
|
65
|
+
return this.platform !== "auto" ? this.platform === "mac" : typeof navigator > "u" ? !1 : /mac|iphone|ipad/i.test(navigator.platform || navigator.userAgent);
|
|
66
|
+
}
|
|
67
|
+
/** The keys as they will be shown. Exposed so tests and docs can read them. */
|
|
68
|
+
get labels() {
|
|
69
|
+
const t = this.isMac ? b : h;
|
|
70
|
+
return this.keys.split(/\s+/).filter(Boolean).map((e) => t[e.toLowerCase()] ?? e.toUpperCase());
|
|
71
|
+
}
|
|
72
|
+
render() {
|
|
73
|
+
const t = this.labels;
|
|
74
|
+
return o`<span part="base" style="display:contents">
|
|
75
|
+
${t.length > 0 ? t.map((e) => o`<kbd part="key">${e}</kbd>`) : o`<kbd part="key"><slot></slot></kbd>`}
|
|
76
|
+
</span>`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
d([
|
|
80
|
+
p({ type: String })
|
|
81
|
+
], i.prototype, "keys");
|
|
82
|
+
d([
|
|
83
|
+
p({ type: String })
|
|
84
|
+
], i.prototype, "platform");
|
|
85
|
+
f("kt-kbd", i);
|
|
86
|
+
export {
|
|
87
|
+
i as KtKbd
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=kt-kbd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kt-kbd.js","sources":["../../../../src/components/core/kt-kbd/kt-kbd.ts"],"sourcesContent":["import { css, html, type TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\n\n/**\n * Symbols people actually recognise, per platform.\n *\n * `mod` is the one to reach for: it means \"the primary shortcut modifier\",\n * which is Command on a Mac and Control everywhere else. `meta` stays honest —\n * on Windows the Meta key really is the Windows key, and printing \"Ctrl\" for it\n * would send the reader to the wrong key.\n */\nconst MAC: Record<string, string> = {\n mod: '⌘',\n meta: '⌘',\n cmd: '⌘',\n ctrl: '⌃',\n alt: '⌥',\n option: '⌥',\n shift: '⇧',\n enter: '↵',\n escape: 'esc',\n backspace: '⌫',\n};\n\nconst OTHER: Record<string, string> = {\n mod: 'Ctrl',\n meta: 'Win',\n cmd: 'Ctrl',\n ctrl: 'Ctrl',\n alt: 'Alt',\n option: 'Alt',\n shift: 'Shift',\n enter: 'Enter',\n escape: 'Esc',\n backspace: 'Backspace',\n};\n\n/**\n * A keyboard shortcut.\n *\n * Renders per platform: `⌘ K` on a Mac, `Ctrl K` elsewhere. A shortcut printed\n * with the wrong modifier is worse than none — the reader tries it, it does not\n * work, and they stop trusting the hints.\n *\n * @element kt-kbd\n *\n * @slot - The key, when `keys` is not used.\n *\n * @csspart base - The wrapper.\n * @csspart key - One key.\n *\n * @example\n * ```html\n * <kt-kbd keys=\"meta k\"></kt-kbd>\n * <kt-kbd>/</kt-kbd>\n * ```\n */\nexport class KtKbd extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n vertical-align: middle;\n }\n\n kbd {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 20px;\n height: 20px;\n padding: 0 5px;\n color: var(--color-text-500);\n font: var(--font-normal-small);\n font-family: var(--font-family-body);\n background: var(--surface-card);\n border: var(--border-width) solid var(--border-subtle);\n border-radius: 5px;\n }\n `,\n ];\n\n /** Space-separated keys: `meta k`, `ctrl shift p`. */\n @property({ type: String })\n keys = '';\n\n /** Forces a platform instead of sniffing the current one. */\n @property({ type: String })\n platform: 'auto' | 'mac' | 'other' = 'auto';\n\n private get isMac(): boolean {\n if (this.platform !== 'auto') return this.platform === 'mac';\n if (typeof navigator === 'undefined') return false;\n return /mac|iphone|ipad/i.test(navigator.platform || navigator.userAgent);\n }\n\n /** The keys as they will be shown. Exposed so tests and docs can read them. */\n get labels(): string[] {\n const table = this.isMac ? MAC : OTHER;\n return this.keys\n .split(/\\s+/)\n .filter(Boolean)\n .map((key) => table[key.toLowerCase()] ?? key.toUpperCase());\n }\n\n override render(): TemplateResult {\n const labels = this.labels;\n\n return html`<span part=\"base\" style=\"display:contents\">\n ${\n labels.length > 0\n ? labels.map((label) => html`<kbd part=\"key\">${label}</kbd>`)\n : html`<kbd part=\"key\"><slot></slot></kbd>`\n }\n </span>`;\n }\n}\n\ndefineElement('kt-kbd', KtKbd);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-kbd': KtKbd;\n }\n}\n"],"names":["MAC","OTHER","KtKbd","KtElement","css","table","key","labels","html","label","__decorateClass","property","defineElement"],"mappings":";;;;;;;;AAYA,MAAMA,IAA8B;AAAA,EAClC,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,WAAW;AACb,GAEMC,IAAgC;AAAA,EACpC,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,WAAW;AACb;AAsBO,MAAMC,UAAcC,EAAU;AAAA,EAA9B,cAAA;AAAA,UAAA,GAAA,SAAA,GA8BL,KAAA,OAAO,IAIP,KAAA,WAAqC;AAAA,EAAA;AAAA,EAjCrC,OAAA;AAAA,SAAgB,SAAS;AAAA,MACvBA,EAAU;AAAA,MACVC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,EAuBF;AAAA,EAUA,IAAY,QAAiB;AAC3B,WAAI,KAAK,aAAa,SAAe,KAAK,aAAa,QACnD,OAAO,YAAc,MAAoB,KACtC,mBAAmB,KAAK,UAAU,YAAY,UAAU,SAAS;AAAA,EAC1E;AAAA;AAAA,EAGA,IAAI,SAAmB;AACrB,UAAMC,IAAQ,KAAK,QAAQL,IAAMC;AACjC,WAAO,KAAK,KACT,MAAM,KAAK,EACX,OAAO,OAAO,EACd,IAAI,CAACK,MAAQD,EAAMC,EAAI,YAAA,CAAa,KAAKA,EAAI,aAAa;AAAA,EAC/D;AAAA,EAES,SAAyB;AAChC,UAAMC,IAAS,KAAK;AAEpB,WAAOC;AAAA,QAEHD,EAAO,SAAS,IACZA,EAAO,IAAI,CAACE,MAAUD,oBAAuBC,CAAK,QAAQ,IAC1DD,sCACN;AAAA;AAAA,EAEJ;AACF;AAhCEE,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA7BfT,EA8BX,WAAA,MAAA;AAIAQ,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAjCfT,EAkCX,WAAA,UAAA;AA8BFU,EAAc,UAAUV,CAAK;"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { KtElement } from '#internal/kt-element';
|
|
3
|
+
export type KtChartType = 'area' | 'line' | 'bar';
|
|
4
|
+
export interface KtSeries {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly values: readonly number[];
|
|
7
|
+
/** Overrides the slot this series would take from the categorical order. */
|
|
8
|
+
readonly color?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A small chart, drawn from the token layer.
|
|
12
|
+
*
|
|
13
|
+
* Deliberately narrow: one axis, one to eight series, three marks. It is the
|
|
14
|
+
* shape a product dashboard actually needs, not a charting library — anything
|
|
15
|
+
* past this and you want a real one.
|
|
16
|
+
*
|
|
17
|
+
* **Colour.** One series takes the brand hue: with nothing to tell apart there
|
|
18
|
+
* is no identity to encode, and the title names it. Two or more take the fixed
|
|
19
|
+
* categorical order in `--chart-series-1…8`, assigned by position and never
|
|
20
|
+
* cycled, so a series keeps its colour when a filter removes its neighbours.
|
|
21
|
+
* Those hues are kept clear of the semantic palette, so a line can never be
|
|
22
|
+
* mistaken for a status.
|
|
23
|
+
*
|
|
24
|
+
* **The table is not optional.** Every chart also renders its data as a table,
|
|
25
|
+
* visually hidden by default. It is what a screen reader reads, and it is the
|
|
26
|
+
* relief that four of the light-theme series hues require, sitting as they do
|
|
27
|
+
* below 3:1 on a light surface.
|
|
28
|
+
*
|
|
29
|
+
* @element kt-chart
|
|
30
|
+
*
|
|
31
|
+
* @csspart svg - The plot.
|
|
32
|
+
* @csspart legend - The legend, when there are two or more series.
|
|
33
|
+
* @csspart table - The data table.
|
|
34
|
+
*
|
|
35
|
+
* @fires kt-point-hover - The hovered index changed. `detail: { index }`,
|
|
36
|
+
* with `index` of -1 when the pointer leaves.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```js
|
|
40
|
+
* chart.labels = ['Jan', 'Feb', 'Mar'];
|
|
41
|
+
* chart.series = [{ name: 'Revenue', values: [42, 58, 36] }];
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare class KtChart extends KtElement {
|
|
45
|
+
static styles: import("lit").CSSResultGroup[];
|
|
46
|
+
private plot;
|
|
47
|
+
private observer?;
|
|
48
|
+
private readonly tableId;
|
|
49
|
+
private box;
|
|
50
|
+
private active;
|
|
51
|
+
type: KtChartType;
|
|
52
|
+
series: readonly KtSeries[];
|
|
53
|
+
/** One label per index along the x axis. */
|
|
54
|
+
labels: readonly string[];
|
|
55
|
+
height: number;
|
|
56
|
+
/** Formats a value for the tooltip and the table. */
|
|
57
|
+
format: (value: number) => string;
|
|
58
|
+
/** Horizontal grid lines. */
|
|
59
|
+
noGrid: boolean;
|
|
60
|
+
/** Puts the data table on screen instead of only in the accessibility tree. */
|
|
61
|
+
showTable: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Smooths the line through a monotone spline.
|
|
64
|
+
*
|
|
65
|
+
* Off by default on purpose: a curve between two samples draws values that
|
|
66
|
+
* were never measured. Turn it on when the underlying quantity really is
|
|
67
|
+
* continuous and the reader knows it.
|
|
68
|
+
*/
|
|
69
|
+
smooth: boolean;
|
|
70
|
+
/** Accessible name. Say what the chart shows. */
|
|
71
|
+
label: string;
|
|
72
|
+
connectedCallback(): void;
|
|
73
|
+
firstUpdated(): void;
|
|
74
|
+
disconnectedCallback(): void;
|
|
75
|
+
private colorFor;
|
|
76
|
+
private get pointCount();
|
|
77
|
+
private get bounds();
|
|
78
|
+
private get plotArea();
|
|
79
|
+
private xFor;
|
|
80
|
+
private yFor;
|
|
81
|
+
/**
|
|
82
|
+
* A monotone cubic path — it never overshoots the samples, which a plain
|
|
83
|
+
* cardinal spline happily does, inventing peaks that are not in the data.
|
|
84
|
+
*/
|
|
85
|
+
private pathFor;
|
|
86
|
+
private onPointerMove;
|
|
87
|
+
private onPointerLeave;
|
|
88
|
+
private renderGrid;
|
|
89
|
+
private renderBars;
|
|
90
|
+
private renderLines;
|
|
91
|
+
private renderAxis;
|
|
92
|
+
private renderTooltip;
|
|
93
|
+
render(): TemplateResult;
|
|
94
|
+
}
|
|
95
|
+
declare global {
|
|
96
|
+
interface HTMLElementTagNameMap {
|
|
97
|
+
'kt-chart': KtChart;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { css as F, nothing as h, svg as l, html as c } from "lit";
|
|
2
|
+
import { query as M, state as g, property as p } from "lit/decorators.js";
|
|
3
|
+
import { K as f, d as A } from "../../../chunks/kt-element-CcMLO5e8.js";
|
|
4
|
+
import { u as C, e as y } from "../../../chunks/events-Bjl5Zmmq.js";
|
|
5
|
+
var P = Object.defineProperty, n = (b, e, t, o) => {
|
|
6
|
+
for (var i = void 0, s = b.length - 1, r; s >= 0; s--)
|
|
7
|
+
(r = b[s]) && (i = r(e, t, i) || i);
|
|
8
|
+
return i && P(e, t, i), i;
|
|
9
|
+
};
|
|
10
|
+
const u = { top: 12, right: 4, bottom: 22, left: 4 }, G = 8;
|
|
11
|
+
class a extends f {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.tableId = C("kt-chart-table"), this.box = { width: 0, height: 0 }, this.active = -1, this.type = "area", this.series = [], this.labels = [], this.height = 200, this.format = (e) => String(e), this.noGrid = !1, this.showTable = !1, this.smooth = !1, this.label = "";
|
|
14
|
+
}
|
|
15
|
+
static {
|
|
16
|
+
this.styles = [
|
|
17
|
+
f.styles,
|
|
18
|
+
F`
|
|
19
|
+
:host {
|
|
20
|
+
display: block;
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.plot {
|
|
25
|
+
position: relative;
|
|
26
|
+
width: 100%;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
svg {
|
|
30
|
+
display: block;
|
|
31
|
+
width: 100%;
|
|
32
|
+
overflow: visible;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Recessive: the data is the loud part. */
|
|
36
|
+
.grid {
|
|
37
|
+
stroke: var(--chart-grid);
|
|
38
|
+
stroke-width: 1;
|
|
39
|
+
opacity: 0.6;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.axis-label {
|
|
43
|
+
fill: var(--chart-axis);
|
|
44
|
+
font: var(--font-normal-small);
|
|
45
|
+
font-family: var(--font-family-body);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.line {
|
|
49
|
+
fill: none;
|
|
50
|
+
stroke-width: 2;
|
|
51
|
+
stroke-linecap: round;
|
|
52
|
+
stroke-linejoin: round;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.marker {
|
|
56
|
+
stroke: var(--surface-card);
|
|
57
|
+
stroke-width: 2;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.crosshair {
|
|
61
|
+
stroke: var(--chart-axis);
|
|
62
|
+
stroke-width: 1;
|
|
63
|
+
stroke-dasharray: 3 3;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.tooltip {
|
|
67
|
+
position: absolute;
|
|
68
|
+
z-index: var(--z-tooltip);
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
gap: 4px;
|
|
72
|
+
min-width: 120px;
|
|
73
|
+
padding: 8px 10px;
|
|
74
|
+
color: var(--text-inverted);
|
|
75
|
+
font: var(--font-normal-small);
|
|
76
|
+
background: var(--surface-inverted);
|
|
77
|
+
border-radius: var(--border-radius);
|
|
78
|
+
box-shadow: var(--shadow-toast);
|
|
79
|
+
pointer-events: none;
|
|
80
|
+
transform: translate(-50%, calc(-100% - 12px));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.tooltip-row {
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
gap: 6px;
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.swatch {
|
|
91
|
+
width: 8px;
|
|
92
|
+
height: 8px;
|
|
93
|
+
border-radius: 2px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.tooltip-name {
|
|
97
|
+
flex: 1;
|
|
98
|
+
opacity: 0.75;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.tooltip-value {
|
|
102
|
+
font-variant-numeric: tabular-nums;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.legend {
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-wrap: wrap;
|
|
108
|
+
gap: 14px;
|
|
109
|
+
margin-top: 10px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.legend-item {
|
|
113
|
+
display: inline-flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
gap: 6px;
|
|
116
|
+
color: var(--text-muted);
|
|
117
|
+
font: var(--font-normal-small);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* Present for assistive technology and for anyone who needs the
|
|
121
|
+
numbers; show-table puts it on screen. */
|
|
122
|
+
.table {
|
|
123
|
+
position: absolute;
|
|
124
|
+
width: 1px;
|
|
125
|
+
height: 1px;
|
|
126
|
+
overflow: hidden;
|
|
127
|
+
clip-path: inset(50%);
|
|
128
|
+
white-space: nowrap;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:host([show-table]) .table {
|
|
132
|
+
position: static;
|
|
133
|
+
width: auto;
|
|
134
|
+
height: auto;
|
|
135
|
+
margin-top: 16px;
|
|
136
|
+
overflow: visible;
|
|
137
|
+
clip-path: none;
|
|
138
|
+
white-space: normal;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
:host([show-table]) table {
|
|
142
|
+
width: 100%;
|
|
143
|
+
border-collapse: collapse;
|
|
144
|
+
font: var(--font-normal-small);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
:host([show-table]) th,
|
|
148
|
+
:host([show-table]) td {
|
|
149
|
+
padding: 6px 10px;
|
|
150
|
+
color: var(--text-muted);
|
|
151
|
+
text-align: right;
|
|
152
|
+
border-bottom: var(--border-width) solid var(--border-subtle);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:host([show-table]) th:first-child,
|
|
156
|
+
:host([show-table]) td:first-child {
|
|
157
|
+
color: var(--text-body);
|
|
158
|
+
text-align: left;
|
|
159
|
+
}
|
|
160
|
+
`
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
connectedCallback() {
|
|
164
|
+
super.connectedCallback(), this.observer = new ResizeObserver(([e]) => {
|
|
165
|
+
e && (this.box = { width: e.contentRect.width, height: this.height });
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
firstUpdated() {
|
|
169
|
+
this.plot && this.observer?.observe(this.plot);
|
|
170
|
+
}
|
|
171
|
+
disconnectedCallback() {
|
|
172
|
+
super.disconnectedCallback(), this.observer?.disconnect();
|
|
173
|
+
}
|
|
174
|
+
colorFor(e, t) {
|
|
175
|
+
return t.color ? t.color : this.series.length === 1 ? "var(--color-primary-base)" : `var(--chart-series-${e % G + 1})`;
|
|
176
|
+
}
|
|
177
|
+
get pointCount() {
|
|
178
|
+
return Math.max(0, ...this.series.map((e) => e.values.length));
|
|
179
|
+
}
|
|
180
|
+
get bounds() {
|
|
181
|
+
const e = this.series.flatMap((i) => [...i.values]);
|
|
182
|
+
if (e.length === 0) return { min: 0, max: 1 };
|
|
183
|
+
const t = Math.max(...e, 0), o = Math.min(...e, 0);
|
|
184
|
+
return { min: o, max: t === o ? o + 1 : t };
|
|
185
|
+
}
|
|
186
|
+
get plotArea() {
|
|
187
|
+
return {
|
|
188
|
+
x: u.left,
|
|
189
|
+
y: u.top,
|
|
190
|
+
width: Math.max(0, this.box.width - u.left - u.right),
|
|
191
|
+
height: Math.max(0, this.height - u.top - u.bottom)
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
xFor(e) {
|
|
195
|
+
const t = this.plotArea, o = this.pointCount;
|
|
196
|
+
return o <= 1 ? t.x + t.width / 2 : t.x + e / (o - 1) * t.width;
|
|
197
|
+
}
|
|
198
|
+
yFor(e) {
|
|
199
|
+
const t = this.plotArea, { min: o, max: i } = this.bounds;
|
|
200
|
+
return t.y + t.height - (e - o) / (i - o) * t.height;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* A monotone cubic path — it never overshoots the samples, which a plain
|
|
204
|
+
* cardinal spline happily does, inventing peaks that are not in the data.
|
|
205
|
+
*/
|
|
206
|
+
pathFor(e) {
|
|
207
|
+
const t = e.map((i, s) => [this.xFor(s), this.yFor(i)]);
|
|
208
|
+
if (t.length === 0) return "";
|
|
209
|
+
if (t.length === 1 || !this.smooth)
|
|
210
|
+
return t.map(([i, s], r) => `${r === 0 ? "M" : "L"}${i},${s}`).join(" ");
|
|
211
|
+
let o = `M${t[0][0]},${t[0][1]}`;
|
|
212
|
+
for (let i = 0; i < t.length - 1; i += 1) {
|
|
213
|
+
const [s, r] = t[i], [d, v] = t[i + 1], x = (d - s) / 3;
|
|
214
|
+
o += ` C${s + x},${r} ${d - x},${v} ${d},${v}`;
|
|
215
|
+
}
|
|
216
|
+
return o;
|
|
217
|
+
}
|
|
218
|
+
onPointerMove(e) {
|
|
219
|
+
const t = this.plotArea, o = this.pointCount;
|
|
220
|
+
if (o === 0 || t.width === 0) return;
|
|
221
|
+
const i = e.offsetX - t.x, s = Math.round(i / t.width * (o - 1)), r = Math.min(Math.max(s, 0), o - 1);
|
|
222
|
+
r !== this.active && (this.active = r, y(this, "kt-point-hover", { index: r }));
|
|
223
|
+
}
|
|
224
|
+
onPointerLeave() {
|
|
225
|
+
this.active !== -1 && (this.active = -1, y(this, "kt-point-hover", { index: -1 }));
|
|
226
|
+
}
|
|
227
|
+
renderGrid() {
|
|
228
|
+
if (this.noGrid) return h;
|
|
229
|
+
const e = this.plotArea;
|
|
230
|
+
return l`${[0, 0.25, 0.5, 0.75, 1].map((t) => {
|
|
231
|
+
const o = e.y + e.height * t;
|
|
232
|
+
return l`<line class="grid" x1=${e.x} y1=${o} x2=${e.x + e.width} y2=${o} />`;
|
|
233
|
+
})}`;
|
|
234
|
+
}
|
|
235
|
+
renderBars() {
|
|
236
|
+
const e = this.plotArea, t = this.pointCount, o = this.series.length, i = t > 0 ? e.width / t : 0, s = Math.max(2, i / o - 2), r = this.yFor(Math.max(0, this.bounds.min));
|
|
237
|
+
return l`${this.series.map(
|
|
238
|
+
(d, v) => d.values.map((x, m) => {
|
|
239
|
+
const $ = this.yFor(x), w = e.x + m * i + (i - s * o) / 2 + v * s, k = Math.max(1, r - $);
|
|
240
|
+
return l`<rect
|
|
241
|
+
x=${w} y=${$} width=${s} height=${k}
|
|
242
|
+
rx="4" ry="4"
|
|
243
|
+
fill=${this.colorFor(v, d)}
|
|
244
|
+
opacity=${this.active === -1 || this.active === m ? 1 : 0.45}
|
|
245
|
+
/>`;
|
|
246
|
+
})
|
|
247
|
+
)}`;
|
|
248
|
+
}
|
|
249
|
+
renderLines() {
|
|
250
|
+
const e = this.plotArea;
|
|
251
|
+
return l`${this.series.map((t, o) => {
|
|
252
|
+
const i = this.colorFor(o, t), s = this.pathFor(t.values), r = `${this.tableId}-fill-${o}`;
|
|
253
|
+
return l`
|
|
254
|
+
${this.type === "area" ? l`
|
|
255
|
+
<defs>
|
|
256
|
+
<linearGradient id=${r} x1="0" y1="0" x2="0" y2="1">
|
|
257
|
+
<stop offset="0%" stop-color=${i} stop-opacity="0.28" />
|
|
258
|
+
<stop offset="100%" stop-color=${i} stop-opacity="0.02" />
|
|
259
|
+
</linearGradient>
|
|
260
|
+
</defs>
|
|
261
|
+
<path
|
|
262
|
+
d=${`${s} L${this.xFor(t.values.length - 1)},${e.y + e.height} L${this.xFor(0)},${e.y + e.height} Z`}
|
|
263
|
+
fill=${`url(#${r})`}
|
|
264
|
+
/>` : h}
|
|
265
|
+
<path class="line" d=${s} stroke=${i} />
|
|
266
|
+
${this.active >= 0 && t.values[this.active] !== void 0 ? l`<circle
|
|
267
|
+
class="marker"
|
|
268
|
+
cx=${this.xFor(this.active)}
|
|
269
|
+
cy=${this.yFor(t.values[this.active])}
|
|
270
|
+
r="5"
|
|
271
|
+
fill=${i}
|
|
272
|
+
/>` : h}`;
|
|
273
|
+
})}`;
|
|
274
|
+
}
|
|
275
|
+
renderAxis() {
|
|
276
|
+
const e = this.plotArea, t = this.pointCount, o = Math.max(1, Math.ceil(t / Math.max(1, Math.floor(e.width / 56))));
|
|
277
|
+
return l`${this.labels.map(
|
|
278
|
+
(i, s) => s % o === 0 ? l`<text
|
|
279
|
+
class="axis-label"
|
|
280
|
+
x=${this.xFor(s)}
|
|
281
|
+
y=${e.y + e.height + 16}
|
|
282
|
+
text-anchor="middle"
|
|
283
|
+
>${i}</text>` : h
|
|
284
|
+
)}`;
|
|
285
|
+
}
|
|
286
|
+
renderTooltip() {
|
|
287
|
+
return this.active < 0 || this.box.width === 0 ? h : c`<div
|
|
288
|
+
class="tooltip"
|
|
289
|
+
style=${`left:${this.xFor(this.active)}px;top:${this.plotArea.y + this.plotArea.height}px`}
|
|
290
|
+
role="status"
|
|
291
|
+
>
|
|
292
|
+
<strong>${this.labels[this.active] ?? `#${this.active + 1}`}</strong>
|
|
293
|
+
${this.series.map(
|
|
294
|
+
(e, t) => c`<span class="tooltip-row">
|
|
295
|
+
<span class="swatch" style=${`background:${this.colorFor(t, e)}`}></span>
|
|
296
|
+
<span class="tooltip-name">${e.name}</span>
|
|
297
|
+
<span class="tooltip-value">${this.format(e.values[this.active] ?? 0)}</span>
|
|
298
|
+
</span>`
|
|
299
|
+
)}
|
|
300
|
+
</div>`;
|
|
301
|
+
}
|
|
302
|
+
render() {
|
|
303
|
+
const e = this.plotArea, t = this.box.width > 0 && this.pointCount > 0;
|
|
304
|
+
return c`<div class="plot" style=${`height:${this.height}px`}>
|
|
305
|
+
<svg
|
|
306
|
+
part="svg"
|
|
307
|
+
width=${this.box.width}
|
|
308
|
+
height=${this.height}
|
|
309
|
+
role="img"
|
|
310
|
+
aria-label=${this.label || h}
|
|
311
|
+
aria-describedby=${this.tableId}
|
|
312
|
+
@pointermove=${this.onPointerMove}
|
|
313
|
+
@pointerleave=${this.onPointerLeave}
|
|
314
|
+
>
|
|
315
|
+
${t ? this.renderGrid() : h}
|
|
316
|
+
${t && this.type === "bar" ? this.renderBars() : h}
|
|
317
|
+
${t && this.type !== "bar" ? this.renderLines() : h}
|
|
318
|
+
${t && this.active >= 0 && this.type !== "bar" ? l`<line
|
|
319
|
+
class="crosshair"
|
|
320
|
+
x1=${this.xFor(this.active)} y1=${e.y}
|
|
321
|
+
x2=${this.xFor(this.active)} y2=${e.y + e.height}
|
|
322
|
+
/>` : h}
|
|
323
|
+
${t ? this.renderAxis() : h}
|
|
324
|
+
</svg>
|
|
325
|
+
${this.renderTooltip()}
|
|
326
|
+
</div>
|
|
327
|
+
|
|
328
|
+
${this.series.length > 1 ? c`<div part="legend" class="legend">
|
|
329
|
+
${this.series.map(
|
|
330
|
+
(o, i) => c`<span class="legend-item">
|
|
331
|
+
<span
|
|
332
|
+
class="swatch"
|
|
333
|
+
style=${`background:${this.colorFor(i, o)}`}
|
|
334
|
+
></span>
|
|
335
|
+
${o.name}
|
|
336
|
+
</span>`
|
|
337
|
+
)}
|
|
338
|
+
</div>` : h}
|
|
339
|
+
|
|
340
|
+
<div part="table" class="table" id=${this.tableId}>
|
|
341
|
+
<table>
|
|
342
|
+
<caption>
|
|
343
|
+
${this.label || "Chart data"}
|
|
344
|
+
</caption>
|
|
345
|
+
<thead>
|
|
346
|
+
<tr>
|
|
347
|
+
<th scope="col">Point</th>
|
|
348
|
+
${this.series.map((o) => c`<th scope="col">${o.name}</th>`)}
|
|
349
|
+
</tr>
|
|
350
|
+
</thead>
|
|
351
|
+
<tbody>
|
|
352
|
+
${Array.from(
|
|
353
|
+
{ length: this.pointCount },
|
|
354
|
+
(o, i) => c`<tr>
|
|
355
|
+
<th scope="row">${this.labels[i] ?? `#${i + 1}`}</th>
|
|
356
|
+
${this.series.map(
|
|
357
|
+
(s) => c`<td>${this.format(s.values[i] ?? 0)}</td>`
|
|
358
|
+
)}
|
|
359
|
+
</tr>`
|
|
360
|
+
)}
|
|
361
|
+
</tbody>
|
|
362
|
+
</table>
|
|
363
|
+
</div>`;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
n([
|
|
367
|
+
M(".plot")
|
|
368
|
+
], a.prototype, "plot");
|
|
369
|
+
n([
|
|
370
|
+
g()
|
|
371
|
+
], a.prototype, "box");
|
|
372
|
+
n([
|
|
373
|
+
g()
|
|
374
|
+
], a.prototype, "active");
|
|
375
|
+
n([
|
|
376
|
+
p({ type: String, reflect: !0 })
|
|
377
|
+
], a.prototype, "type");
|
|
378
|
+
n([
|
|
379
|
+
p({ attribute: !1 })
|
|
380
|
+
], a.prototype, "series");
|
|
381
|
+
n([
|
|
382
|
+
p({ attribute: !1 })
|
|
383
|
+
], a.prototype, "labels");
|
|
384
|
+
n([
|
|
385
|
+
p({ type: Number })
|
|
386
|
+
], a.prototype, "height");
|
|
387
|
+
n([
|
|
388
|
+
p({ attribute: !1 })
|
|
389
|
+
], a.prototype, "format");
|
|
390
|
+
n([
|
|
391
|
+
p({ type: Boolean, attribute: "no-grid" })
|
|
392
|
+
], a.prototype, "noGrid");
|
|
393
|
+
n([
|
|
394
|
+
p({ type: Boolean, reflect: !0, attribute: "show-table" })
|
|
395
|
+
], a.prototype, "showTable");
|
|
396
|
+
n([
|
|
397
|
+
p({ type: Boolean })
|
|
398
|
+
], a.prototype, "smooth");
|
|
399
|
+
n([
|
|
400
|
+
p({ type: String })
|
|
401
|
+
], a.prototype, "label");
|
|
402
|
+
A("kt-chart", a);
|
|
403
|
+
export {
|
|
404
|
+
a as KtChart
|
|
405
|
+
};
|
|
406
|
+
//# sourceMappingURL=kt-chart.js.map
|