@f-ewald/components 1.39.0 → 1.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/custom-elements.json +1179 -100
- package/dist/address-autocomplete.js +2 -2
- package/dist/address-autocomplete.js.map +1 -1
- package/dist/app-shell.js +4 -4
- package/dist/app-shell.js.map +1 -1
- package/dist/app-sidebar.js +2 -2
- package/dist/app-sidebar.js.map +1 -1
- package/dist/audio-player.js +1 -1
- package/dist/audio-player.js.map +1 -1
- package/dist/autocomplete-input.js +2 -2
- package/dist/autocomplete-input.js.map +1 -1
- package/dist/breadcrumb-nav.d.ts +87 -0
- package/dist/breadcrumb-nav.d.ts.map +1 -0
- package/dist/breadcrumb-nav.js +281 -0
- package/dist/breadcrumb-nav.js.map +1 -0
- package/dist/button-group.js +2 -2
- package/dist/button-group.js.map +1 -1
- package/dist/calendar-day.js +3 -3
- package/dist/calendar-day.js.map +1 -1
- package/dist/calendar-month.d.ts.map +1 -1
- package/dist/calendar-month.js +4 -1
- package/dist/calendar-month.js.map +1 -1
- package/dist/calendar-week.js +4 -4
- package/dist/calendar-week.js.map +1 -1
- package/dist/chat-message.js +1 -1
- package/dist/chat-message.js.map +1 -1
- package/dist/comment-composer.js +1 -1
- package/dist/comment-composer.js.map +1 -1
- package/dist/confirm-dialog.d.ts.map +1 -1
- package/dist/confirm-dialog.js +5 -2
- package/dist/confirm-dialog.js.map +1 -1
- package/dist/content-divider.js +1 -1
- package/dist/content-divider.js.map +1 -1
- package/dist/cron-schedule.d.ts.map +1 -1
- package/dist/cron-schedule.js +6 -5
- package/dist/cron-schedule.js.map +1 -1
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +3 -2
- package/dist/data-table.js.map +1 -1
- package/dist/dropdown-button.d.ts.map +1 -1
- package/dist/dropdown-button.js +4 -2
- package/dist/dropdown-button.js.map +1 -1
- package/dist/editable-text.js +1 -1
- package/dist/editable-text.js.map +1 -1
- package/dist/empty-state.d.ts +58 -0
- package/dist/empty-state.d.ts.map +1 -0
- package/dist/empty-state.js +203 -0
- package/dist/empty-state.js.map +1 -0
- package/dist/form-field.js +1 -1
- package/dist/form-field.js.map +1 -1
- package/dist/form-select.js +3 -3
- package/dist/form-select.js.map +1 -1
- package/dist/frame-box.js +1 -1
- package/dist/frame-box.js.map +1 -1
- package/dist/fullscreen-button.js +1 -1
- package/dist/fullscreen-button.js.map +1 -1
- package/dist/icons.d.ts +2 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +2 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/kanban-card.js +1 -1
- package/dist/kanban-card.js.map +1 -1
- package/dist/kanban-column.js +3 -3
- package/dist/kanban-column.js.map +1 -1
- package/dist/kbd-hint.d.ts.map +1 -1
- package/dist/kbd-hint.js +2 -1
- package/dist/kbd-hint.js.map +1 -1
- package/dist/link-card.js +1 -1
- package/dist/link-card.js.map +1 -1
- package/dist/markdown-view.js +3 -3
- package/dist/markdown-view.js.map +1 -1
- package/dist/modal-dialog.js +1 -1
- package/dist/modal-dialog.js.map +1 -1
- package/dist/multi-select.js +5 -5
- package/dist/multi-select.js.map +1 -1
- package/dist/pagination-nav.d.ts.map +1 -1
- package/dist/pagination-nav.js +5 -1
- package/dist/pagination-nav.js.map +1 -1
- package/dist/photo-gallery.js +1 -1
- package/dist/photo-gallery.js.map +1 -1
- package/dist/popover-panel.d.ts.map +1 -1
- package/dist/popover-panel.js +4 -2
- package/dist/popover-panel.js.map +1 -1
- package/dist/progress-bar.d.ts.map +1 -1
- package/dist/progress-bar.js +1 -0
- package/dist/progress-bar.js.map +1 -1
- package/dist/radio-cards.js +1 -1
- package/dist/radio-cards.js.map +1 -1
- package/dist/radio-pills.js +1 -1
- package/dist/radio-pills.js.map +1 -1
- package/dist/reveal-button.js +1 -1
- package/dist/reveal-button.js.map +1 -1
- package/dist/scroll-to-bottom.js +1 -1
- package/dist/scroll-to-bottom.js.map +1 -1
- package/dist/scroll-to-top.js +1 -1
- package/dist/scroll-to-top.js.map +1 -1
- package/dist/skip-link.d.ts +38 -0
- package/dist/skip-link.d.ts.map +1 -0
- package/dist/skip-link.js +184 -0
- package/dist/skip-link.js.map +1 -0
- package/dist/slide-panel.js +1 -1
- package/dist/slide-panel.js.map +1 -1
- package/dist/spec-list.d.ts +58 -0
- package/dist/spec-list.d.ts.map +1 -0
- package/dist/spec-list.js +226 -0
- package/dist/spec-list.js.map +1 -0
- package/dist/stat-meter.d.ts.map +1 -1
- package/dist/stat-meter.js +1 -0
- package/dist/stat-meter.js.map +1 -1
- package/dist/tab-bar.js +1 -1
- package/dist/tab-bar.js.map +1 -1
- package/dist/text-area.js +1 -1
- package/dist/text-area.js.map +1 -1
- package/dist/tile-grid.js +1 -1
- package/dist/tile-grid.js.map +1 -1
- package/dist/tokens.css +42 -1
- package/dist/tokens.d.ts +50 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +136 -0
- package/dist/tokens.js.map +1 -1
- package/dist/tree-view.js +2 -2
- package/dist/tree-view.js.map +1 -1
- package/dist/ui-admonition.js +1 -1
- package/dist/ui-admonition.js.map +1 -1
- package/dist/ui-button.js +1 -1
- package/dist/ui-button.js.map +1 -1
- package/dist/video-player.js +1 -1
- package/dist/video-player.js.map +1 -1
- package/dist/vote-control.d.ts +40 -0
- package/dist/vote-control.d.ts.map +1 -0
- package/dist/vote-control.js +318 -0
- package/dist/vote-control.js.map +1 -0
- package/docs/address-autocomplete.md +1 -0
- package/docs/app-shell.md +1 -0
- package/docs/app-sidebar.md +1 -0
- package/docs/audio-player.md +1 -0
- package/docs/autocomplete-input.md +1 -0
- package/docs/breadcrumb-nav.md +70 -0
- package/docs/button-group.md +1 -0
- package/docs/calendar-day.md +1 -0
- package/docs/calendar-month.md +1 -0
- package/docs/calendar-week.md +1 -0
- package/docs/chat-message.md +1 -0
- package/docs/comment-composer.md +1 -0
- package/docs/confirm-dialog.md +1 -0
- package/docs/content-divider.md +1 -0
- package/docs/cron-schedule.md +2 -0
- package/docs/data-table.md +2 -0
- package/docs/design-language.md +57 -5
- package/docs/dropdown-button.md +1 -0
- package/docs/editable-text.md +1 -0
- package/docs/empty-state.md +60 -0
- package/docs/form-field.md +1 -0
- package/docs/form-select.md +1 -0
- package/docs/frame-box.md +1 -0
- package/docs/fullscreen-button.md +1 -0
- package/docs/icons.md +1 -0
- package/docs/kanban-card.md +1 -0
- package/docs/kanban-column.md +1 -0
- package/docs/kbd-hint.md +1 -0
- package/docs/link-card.md +1 -0
- package/docs/markdown-view.md +1 -0
- package/docs/modal-dialog.md +1 -0
- package/docs/multi-select.md +1 -0
- package/docs/pagination-nav.md +2 -0
- package/docs/photo-gallery.md +1 -0
- package/docs/popover-panel.md +1 -0
- package/docs/progress-bar.md +1 -0
- package/docs/radio-cards.md +1 -0
- package/docs/radio-pills.md +1 -0
- package/docs/reveal-button.md +1 -0
- package/docs/scroll-to-bottom.md +1 -0
- package/docs/scroll-to-top.md +1 -0
- package/docs/skip-link.md +61 -0
- package/docs/slide-panel.md +1 -0
- package/docs/spec-list.md +79 -0
- package/docs/stat-meter.md +1 -0
- package/docs/tab-bar.md +1 -0
- package/docs/text-area.md +1 -0
- package/docs/tile-grid.md +1 -0
- package/docs/tree-view.md +1 -0
- package/docs/ui-admonition.md +1 -0
- package/docs/ui-button.md +1 -0
- package/docs/video-player.md +1 -0
- package/docs/vote-control.md +73 -0
- package/llms.txt +212 -49
- package/package.json +1 -1
package/dist/kbd-hint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kbd-hint.js","sourceRoot":"","sources":["../src/kbd-hint.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,Q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G,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAA,2BAA2B,GAAG,CAAC,KAAK,QAAQ,CAAC;;KAE9E,CAAC;IACJ,CAAC;CACF,CAAA;AAxEa;IAAX,QAAQ,EAAE;qCAAW;AAGV;IAAX,QAAQ,EAAE;yCAAgC;AALhC,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CA0EnB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** Platform mode used to render modifier keys. */\nexport type KbdPlatform = \"auto\" | \"mac\" | \"other\";\n\n/** Visual and spoken representations of one shortcut key. */\ninterface KeyRender {\n label: string;\n name: string;\n}\n\n/**\n * Detects macOS via User-Agent Client Hints when available, with legacy\n * navigator fields as fallbacks.\n */\nfunction detectMac(): boolean {\n if (\n typeof window === \"undefined\" ||\n typeof document === \"undefined\" ||\n typeof navigator === \"undefined\"\n ) {\n return false;\n }\n const nav = navigator as Navigator & { userAgentData?: { platform?: string } };\n const source = nav.userAgentData?.platform || nav.platform || nav.userAgent || \"\";\n return /mac/i.test(source);\n}\n\n/**\n * Maps one case-insensitive shortcut token to its visual keycap and spoken\n * name. Unknown tokens remain literal; single letters are uppercased.\n */\nfunction keyLabel(raw: string, mac: boolean): KeyRender {\n switch (raw.trim().toLowerCase()) {\n case \"mod\":\n return mac ? { label: \"⌘\", name: \"Command\" } : { label: \"Ctrl\", name: \"Control\" };\n case \"cmd\":\n case \"command\":\n return mac ? { label: \"⌘\", name: \"Command\" } : { label: \"Cmd\", name: \"Command\" };\n case \"meta\":\n return mac ? { label: \"⌘\", name: \"Command\" } : { label: \"Meta\", name: \"Meta\" };\n case \"super\":\n return mac ? { label: \"⌘\", name: \"Command\" } : { label: \"Super\", name: \"Super\" };\n case \"win\":\n case \"windows\":\n return { label: \"Win\", name: \"Windows\" };\n case \"ctrl\":\n case \"control\":\n return mac ? { label: \"⌃\", name: \"Control\" } : { label: \"Ctrl\", name: \"Control\" };\n case \"alt\":\n case \"opt\":\n case \"option\":\n return mac ? { label: \"⌥\", name: \"Option\" } : { label: \"Alt\", name: \"Alt\" };\n case \"shift\":\n return mac ? { label: \"⇧\", name: \"Shift\" } : { label: \"Shift\", name: \"Shift\" };\n case \"enter\":\n case \"return\":\n return { label: \"⏎\", name: \"Enter\" };\n case \"tab\":\n return { label: \"⇥\", name: \"Tab\" };\n case \"backspace\":\n return { label: \"⌫\", name: \"Backspace\" };\n case \"delete\":\n case \"del\":\n return { label: \"⌦\", name: \"Delete\" };\n case \"esc\":\n case \"escape\":\n return { label: \"Esc\", name: \"Escape\" };\n case \"space\":\n case \"spacebar\":\n return { label: \"Space\", name: \"Space\" };\n case \"up\":\n case \"arrowup\":\n return { label: \"↑\", name: \"Up arrow\" };\n case \"down\":\n case \"arrowdown\":\n return { label: \"↓\", name: \"Down arrow\" };\n case \"left\":\n case \"arrowleft\":\n return { label: \"←\", name: \"Left arrow\" };\n case \"right\":\n case \"arrowright\":\n return { label: \"→\", name: \"Right arrow\" };\n case \"pageup\":\n return { label: \"PgUp\", name: \"Page Up\" };\n case \"pagedown\":\n return { label: \"PgDn\", name: \"Page Down\" };\n default: {\n const token = raw.trim();\n const label = token.length === 1 ? token.toUpperCase() : token;\n return { label, name: label };\n }\n }\n}\n\n/**\n * Renders a keyboard shortcut as one boxed keycap per `+`-separated token.\n * Modifier keys are platform-aware: `Mod` becomes Command on macOS and\n * Control elsewhere. Keycaps derive their presentation from `currentColor`,\n * so the hint works inside neutral and accent-colored controls.\n *\n * @element kbd-hint\n */\n@customElement(\"kbd-hint\")\nexport class KbdHint extends LitElement {\n /** Shortcut as case-insensitive, `+`-separated tokens, e.g. `\"Mod+Enter\"`. */\n @property() keys = \"\";\n\n /** Platform override; `auto` detects macOS from the browser. */\n @property() platform: KbdPlatform = \"auto\";\n\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-flex;\n vertical-align: middle;\n }\n .wrap {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n }\n kbd {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n min-width: 1.25em;\n height: 1.5em;\n padding: 0 0.25rem;\n color: currentColor;\n background: color-mix(in srgb, currentColor 14%, transparent);\n border: 1px solid color-mix(in srgb, currentColor 38%, transparent);\n border-radius: var(--ui-radius-sm, 0.25rem);\n font-family: var(\n --ui-font-mono,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n monospace\n );\n font-size: var(--ui-font-size-xs, 0.6875rem);\n line-height: var(--ui-line-height-glyph, 1);\n }\n `,\n ];\n\n /** Whether modifier aliases should use macOS glyphs. */\n private get isMac(): boolean {\n if (this.platform === \"mac\") return true;\n if (this.platform === \"other\") return false;\n return detectMac();\n }\n\n /** Parses the shortcut into visual/spoken key descriptors. */\n private get parsedKeys(): KeyRender[] {\n const mac = this.isMac;\n return (this.keys ?? \"\")\n .split(\"+\")\n .map((token) => token.trim())\n .filter(Boolean)\n .map((token) => keyLabel(token, mac));\n }\n\n /** Renders nothing for an empty shortcut, otherwise an accessible keycap group. */\n override render() {\n const parsedKeys = this.parsedKeys;\n if (parsedKeys.length === 0) return html``;\n const label = parsedKeys.map((key) => key.name).join(\" \");\n return html`\n <span class=\"wrap\" role=\"img\" aria-label=${label}>\n ${parsedKeys.map((key) => html`<kbd aria-hidden=\"true\">${key.label}</kbd>`)}\n </span>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kbd-hint\": KbdHint;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"kbd-hint.js","sourceRoot":"","sources":["../src/kbd-hint.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM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AC,KAAK,QAAQ,CAAC;;KAE9E,CAAC;IACJ,CAAC;CACF,CAAA;AAzEa;IAAX,QAAQ,EAAE;qCAAW;AAGV;IAAX,QAAQ,EAAE;yCAAgC;AALhC,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CA2EnB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** Platform mode used to render modifier keys. */\nexport type KbdPlatform = \"auto\" | \"mac\" | \"other\";\n\n/** Visual and spoken representations of one shortcut key. */\ninterface KeyRender {\n label: string;\n name: string;\n}\n\n/**\n * Detects macOS via User-Agent Client Hints when available, with legacy\n * navigator fields as fallbacks.\n */\nfunction detectMac(): boolean {\n if (\n typeof window === \"undefined\" ||\n typeof document === \"undefined\" ||\n typeof navigator === \"undefined\"\n ) {\n return false;\n }\n const nav = navigator as Navigator & { userAgentData?: { platform?: string } };\n const source = nav.userAgentData?.platform || nav.platform || nav.userAgent || \"\";\n return /mac/i.test(source);\n}\n\n/**\n * Maps one case-insensitive shortcut token to its visual keycap and spoken\n * name. Unknown tokens remain literal; single letters are uppercased.\n */\nfunction keyLabel(raw: string, mac: boolean): KeyRender {\n switch (raw.trim().toLowerCase()) {\n case \"mod\":\n return mac ? { label: \"⌘\", name: \"Command\" } : { label: \"Ctrl\", name: \"Control\" };\n case \"cmd\":\n case \"command\":\n return mac ? { label: \"⌘\", name: \"Command\" } : { label: \"Cmd\", name: \"Command\" };\n case \"meta\":\n return mac ? { label: \"⌘\", name: \"Command\" } : { label: \"Meta\", name: \"Meta\" };\n case \"super\":\n return mac ? { label: \"⌘\", name: \"Command\" } : { label: \"Super\", name: \"Super\" };\n case \"win\":\n case \"windows\":\n return { label: \"Win\", name: \"Windows\" };\n case \"ctrl\":\n case \"control\":\n return mac ? { label: \"⌃\", name: \"Control\" } : { label: \"Ctrl\", name: \"Control\" };\n case \"alt\":\n case \"opt\":\n case \"option\":\n return mac ? { label: \"⌥\", name: \"Option\" } : { label: \"Alt\", name: \"Alt\" };\n case \"shift\":\n return mac ? { label: \"⇧\", name: \"Shift\" } : { label: \"Shift\", name: \"Shift\" };\n case \"enter\":\n case \"return\":\n return { label: \"⏎\", name: \"Enter\" };\n case \"tab\":\n return { label: \"⇥\", name: \"Tab\" };\n case \"backspace\":\n return { label: \"⌫\", name: \"Backspace\" };\n case \"delete\":\n case \"del\":\n return { label: \"⌦\", name: \"Delete\" };\n case \"esc\":\n case \"escape\":\n return { label: \"Esc\", name: \"Escape\" };\n case \"space\":\n case \"spacebar\":\n return { label: \"Space\", name: \"Space\" };\n case \"up\":\n case \"arrowup\":\n return { label: \"↑\", name: \"Up arrow\" };\n case \"down\":\n case \"arrowdown\":\n return { label: \"↓\", name: \"Down arrow\" };\n case \"left\":\n case \"arrowleft\":\n return { label: \"←\", name: \"Left arrow\" };\n case \"right\":\n case \"arrowright\":\n return { label: \"→\", name: \"Right arrow\" };\n case \"pageup\":\n return { label: \"PgUp\", name: \"Page Up\" };\n case \"pagedown\":\n return { label: \"PgDn\", name: \"Page Down\" };\n default: {\n const token = raw.trim();\n const label = token.length === 1 ? token.toUpperCase() : token;\n return { label, name: label };\n }\n }\n}\n\n/**\n * Renders a keyboard shortcut as one boxed keycap per `+`-separated token.\n * Modifier keys are platform-aware: `Mod` becomes Command on macOS and\n * Control elsewhere. Keycaps derive their presentation from `currentColor`,\n * so the hint works inside neutral and accent-colored controls.\n *\n * @element kbd-hint\n */\n@customElement(\"kbd-hint\")\nexport class KbdHint extends LitElement {\n /** Shortcut as case-insensitive, `+`-separated tokens, e.g. `\"Mod+Enter\"`. */\n @property() keys = \"\";\n\n /** Platform override; `auto` detects macOS from the browser. */\n @property() platform: KbdPlatform = \"auto\";\n\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-flex;\n vertical-align: middle;\n }\n .wrap {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n }\n kbd {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n min-width: 1.25em;\n height: 1.5em;\n padding: 0 0.25rem;\n color: currentColor;\n background: color-mix(in srgb, currentColor 14%, transparent);\n border: var(--ui-border-width, 1px) solid\n color-mix(in srgb, currentColor 38%, transparent);\n border-radius: var(--ui-radius-sm, 0.25rem);\n font-family: var(\n --ui-font-mono,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n monospace\n );\n font-size: var(--ui-font-size-xs, 0.6875rem);\n line-height: var(--ui-line-height-glyph, 1);\n }\n `,\n ];\n\n /** Whether modifier aliases should use macOS glyphs. */\n private get isMac(): boolean {\n if (this.platform === \"mac\") return true;\n if (this.platform === \"other\") return false;\n return detectMac();\n }\n\n /** Parses the shortcut into visual/spoken key descriptors. */\n private get parsedKeys(): KeyRender[] {\n const mac = this.isMac;\n return (this.keys ?? \"\")\n .split(\"+\")\n .map((token) => token.trim())\n .filter(Boolean)\n .map((token) => keyLabel(token, mac));\n }\n\n /** Renders nothing for an empty shortcut, otherwise an accessible keycap group. */\n override render() {\n const parsedKeys = this.parsedKeys;\n if (parsedKeys.length === 0) return html``;\n const label = parsedKeys.map((key) => key.name).join(\" \");\n return html`\n <span class=\"wrap\" role=\"img\" aria-label=${label}>\n ${parsedKeys.map((key) => html`<kbd aria-hidden=\"true\">${key.label}</kbd>`)}\n </span>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"kbd-hint\": KbdHint;\n }\n}\n"]}
|
package/dist/link-card.js
CHANGED
|
@@ -60,7 +60,7 @@ let LinkCard = class LinkCard extends LitElement {
|
|
|
60
60
|
height: 100%;
|
|
61
61
|
box-sizing: border-box;
|
|
62
62
|
padding: 1.5rem;
|
|
63
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
63
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
64
64
|
border-radius: var(--ui-radius, 0.5rem);
|
|
65
65
|
background: var(--ui-surface, #ffffff);
|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nimport { tokens } from \"./tokens.js\";\n\n/** Reachability state for the optional corner status dot. `\"\"` renders no dot. */\nexport type LinkCardStatus = \"up\" | \"down\" | \"checking\" | \"\";\n\nconst STATUS_LABEL: Record<Exclude<LinkCardStatus, \"\">, string> = {\n up: \"Reachable\",\n down: \"Unreachable\",\n checking: \"Checking…\",\n};\n\n/**\n * A single linked-resource tile — logo (or an initial-letter fallback),\n * heading, optional description, and an optional reachability status dot.\n * Renders as a real `<a>` (opening in a new tab) when `href` is set, or a\n * non-interactive `<div>` otherwise. Meant to be laid out inside\n * `card-grid`, mirroring how `gallery-item` pairs with `photo-gallery`.\n *\n * @element link-card\n */\n@customElement(\"link-card\")\nexport class LinkCard extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n }\n .card {\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 0.75rem;\n height: 100%;\n box-sizing: border-box;\n padding: 1.5rem;\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius, 0.5rem);\n background: var(--ui-surface, #ffffff);\n color: inherit;\n text-decoration: none;\n transition:\n border-color 150ms ease,\n box-shadow 150ms ease,\n transform 150ms ease;\n }\n a.card {\n cursor: pointer;\n }\n .card:hover {\n border-color: var(--ui-text-muted, #64748b);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n transform: translateY(-0.0625rem);\n }\n .card:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .status {\n position: absolute;\n top: 1.25rem;\n right: 1.25rem;\n width: 0.5rem;\n height: 0.5rem;\n border-radius: var(--ui-radius-pill, 9999px);\n background: var(--ui-text-muted, #64748b);\n }\n .status--up {\n background: var(--ui-success, #16a34a);\n }\n .status--down {\n background: var(--ui-danger, #dc2626);\n }\n .logo {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n justify-content: center;\n width: 2.5rem;\n height: 2.5rem;\n border-radius: var(--ui-radius, 0.5rem);\n background: var(--ui-surface-muted, #f8fafc);\n overflow: hidden;\n }\n .logo img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n }\n .initial {\n font-size: var(--ui-font-size-lg, 1rem);\n font-weight: var(--ui-font-weight-semibold, 600);\n color: var(--ui-text-muted, #64748b);\n }\n .heading {\n font-size: var(--ui-font-size-lg, 1rem);\n font-weight: var(--ui-font-weight-semibold, 600);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n }\n .description {\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text-muted, #64748b);\n }\n @media (forced-colors: active) {\n .card:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .card {\n transition: none;\n }\n }\n `,\n ];\n\n /** Card title. */\n @property() heading = \"\";\n /** Optional supporting text shown below the heading. */\n @property() description = \"\";\n /** Destination URL. When set, the card renders as a link (opened in a new tab); when unset, a non-interactive tile. */\n @property() href = \"\";\n /** Logo image URL. Falls back to the first letter of `heading` if unset or it fails to load. */\n @property() logo = \"\";\n /** Reachability state for the corner status dot. `\"\"` (default) renders no dot. */\n @property() status: LinkCardStatus = \"\";\n\n @state() private _imgError = false;\n\n protected override willUpdate(changed: Map<string, unknown>) {\n if (changed.has(\"logo\")) this._imgError = false;\n }\n\n override render() {\n const showImage = !!this.logo && !this._imgError;\n const initial = this.heading.trim().charAt(0).toUpperCase();\n const body = html`\n ${this.status\n ? html`<span\n class=\"status status--${this.status}\"\n role=\"img\"\n title=${STATUS_LABEL[this.status]}\n aria-label=${STATUS_LABEL[this.status]}\n ></span>`\n : nothing}\n <span class=\"logo\">\n ${showImage\n ? html`<img src=${this.logo} alt=\"\" @error=${() => (this._imgError = true)} />`\n : html`<span class=\"initial\" aria-hidden=\"true\">${initial}</span>`}\n </span>\n <span class=\"heading\">${this.heading}</span>\n ${this.description ? html`<span class=\"description\">${this.description}</span>` : nothing}\n `;\n return this.href\n ? html`<a class=\"card\" href=${this.href} target=\"_blank\" rel=\"noopener noreferrer\">${body}</a>`\n : html`<div class=\"card\">${body}</div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"link-card\": LinkCard;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"link-card.js","sourceRoot":"","sources":["../src/link-card.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrC,MAAM,YAAY,GAAgD;IAChE,EAAE,EAAE,WAAW;IACf,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE,WAAW;CACtB,CAAC;AAEF;;;;;;;;GAQG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QA6GL,kBAAkB;QACN,YAAO,GAAG,EAAE,CAAC;QACzB,wDAAwD;QAC5C,gBAAW,GAAG,EAAE,CAAC;QAC7B,uHAAuH;QAC3G,SAAI,GAAG,EAAE,CAAC;QACtB,gGAAgG;QACpF,SAAI,GAAG,EAAE,CAAC;QACtB,mFAAmF;QACvE,WAAM,GAAmB,EAAE,CAAC;QAEvB,cAAS,GAAG,KAAK,CAAC;IA8BrC,CAAC;aArJiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,QAAQ,EAAE;6CAAkB;AAEjB;IAAX,QAAQ,EAAE;sCAAW;AAEV;IAAX,QAAQ,EAAE;sCAAW;AAEV;IAAX,QAAQ,EAAE;wCAA6B;AAEvB;IAAhB,KAAK,EAAE;2CAA2B;AAxHxB,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAsJpB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** Reachability state for the optional corner status dot. `\"\"` renders no dot. */\nexport type LinkCardStatus = \"up\" | \"down\" | \"checking\" | \"\";\n\nconst STATUS_LABEL: Record<Exclude<LinkCardStatus, \"\">, string> = {\n up: \"Reachable\",\n down: \"Unreachable\",\n checking: \"Checking…\",\n};\n\n/**\n * A single linked-resource tile — logo (or an initial-letter fallback),\n * heading, optional description, and an optional reachability status dot.\n * Renders as a real `<a>` (opening in a new tab) when `href` is set, or a\n * non-interactive `<div>` otherwise. Meant to be laid out inside\n * `card-grid`, mirroring how `gallery-item` pairs with `photo-gallery`.\n *\n * @element link-card\n */\n@customElement(\"link-card\")\nexport class LinkCard extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n }\n .card {\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 0.75rem;\n height: 100%;\n box-sizing: border-box;\n padding: 1.5rem;\n border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius, 0.5rem);\n background: var(--ui-surface, #ffffff);\n color: inherit;\n text-decoration: none;\n transition:\n border-color 150ms ease,\n box-shadow 150ms ease,\n transform 150ms ease;\n }\n a.card {\n cursor: pointer;\n }\n .card:hover {\n border-color: var(--ui-text-muted, #64748b);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n transform: translateY(-0.0625rem);\n }\n .card:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .status {\n position: absolute;\n top: 1.25rem;\n right: 1.25rem;\n width: 0.5rem;\n height: 0.5rem;\n border-radius: var(--ui-radius-pill, 9999px);\n background: var(--ui-text-muted, #64748b);\n }\n .status--up {\n background: var(--ui-success, #16a34a);\n }\n .status--down {\n background: var(--ui-danger, #dc2626);\n }\n .logo {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n justify-content: center;\n width: 2.5rem;\n height: 2.5rem;\n border-radius: var(--ui-radius, 0.5rem);\n background: var(--ui-surface-muted, #f8fafc);\n overflow: hidden;\n }\n .logo img {\n width: 100%;\n height: 100%;\n object-fit: contain;\n }\n .initial {\n font-size: var(--ui-font-size-lg, 1rem);\n font-weight: var(--ui-font-weight-semibold, 600);\n color: var(--ui-text-muted, #64748b);\n }\n .heading {\n font-size: var(--ui-font-size-lg, 1rem);\n font-weight: var(--ui-font-weight-semibold, 600);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n }\n .description {\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text-muted, #64748b);\n }\n @media (forced-colors: active) {\n .card:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .card {\n transition: none;\n }\n }\n `,\n ];\n\n /** Card title. */\n @property() heading = \"\";\n /** Optional supporting text shown below the heading. */\n @property() description = \"\";\n /** Destination URL. When set, the card renders as a link (opened in a new tab); when unset, a non-interactive tile. */\n @property() href = \"\";\n /** Logo image URL. Falls back to the first letter of `heading` if unset or it fails to load. */\n @property() logo = \"\";\n /** Reachability state for the corner status dot. `\"\"` (default) renders no dot. */\n @property() status: LinkCardStatus = \"\";\n\n @state() private _imgError = false;\n\n protected override willUpdate(changed: Map<string, unknown>) {\n if (changed.has(\"logo\")) this._imgError = false;\n }\n\n override render() {\n const showImage = !!this.logo && !this._imgError;\n const initial = this.heading.trim().charAt(0).toUpperCase();\n const body = html`\n ${this.status\n ? html`<span\n class=\"status status--${this.status}\"\n role=\"img\"\n title=${STATUS_LABEL[this.status]}\n aria-label=${STATUS_LABEL[this.status]}\n ></span>`\n : nothing}\n <span class=\"logo\">\n ${showImage\n ? html`<img src=${this.logo} alt=\"\" @error=${() => (this._imgError = true)} />`\n : html`<span class=\"initial\" aria-hidden=\"true\">${initial}</span>`}\n </span>\n <span class=\"heading\">${this.heading}</span>\n ${this.description ? html`<span class=\"description\">${this.description}</span>` : nothing}\n `;\n return this.href\n ? html`<a class=\"card\" href=${this.href} target=\"_blank\" rel=\"noopener noreferrer\">${body}</a>`\n : html`<div class=\"card\">${body}</div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"link-card\": LinkCard;\n }\n}\n"]}
|
package/dist/markdown-view.js
CHANGED
|
@@ -112,7 +112,7 @@ let MarkdownView = class MarkdownView extends LitElement {
|
|
|
112
112
|
margin: 0.75rem 0;
|
|
113
113
|
padding: 0.75rem;
|
|
114
114
|
background: var(--ui-surface-muted, #f8fafc);
|
|
115
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
115
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
116
116
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
117
117
|
overflow-x: auto;
|
|
118
118
|
}
|
|
@@ -139,7 +139,7 @@ let MarkdownView = class MarkdownView extends LitElement {
|
|
|
139
139
|
.body td {
|
|
140
140
|
text-align: left;
|
|
141
141
|
padding: 0.5rem 0.75rem;
|
|
142
|
-
border-bottom: 1px solid var(--ui-border, #e2e8f0);
|
|
142
|
+
border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
143
143
|
}
|
|
144
144
|
.body th {
|
|
145
145
|
font-weight: var(--ui-font-weight-semibold, 600);
|
|
@@ -148,7 +148,7 @@ let MarkdownView = class MarkdownView extends LitElement {
|
|
|
148
148
|
.body hr {
|
|
149
149
|
margin: 1.5rem 0;
|
|
150
150
|
border: 0;
|
|
151
|
-
border-top: 1px solid var(--ui-border, #e2e8f0);
|
|
151
|
+
border-top: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
152
152
|
}
|
|
153
153
|
`,
|
|
154
154
|
]; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-view.js","sourceRoot":"","sources":["../src/markdown-view.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;GAWG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QA8HL,qCAAqC;QACzB,aAAQ,GAAG,EAAE,CAAC;IAiB5B,CAAC;aA/IiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwHF;KACF,AA3HqB,CA2HpB;IAKM,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAW,CAAC;QACnF,8EAA8E;QAC9E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,iCAAiC,CAAC,CAAC,OAAO,CACpF,YAAY,EACZ,gBAAgB,CACjB,CAAC;QACF,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAEQ,MAAM;QACb,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO,OAAO,CAAC;QACnC,OAAO,IAAI,CAAA,qBAAqB,UAAU,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC;IAC3E,CAAC;CACF,CAAA;AAjBa;IAAX,QAAQ,EAAE;8CAAe;AA/Hf,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAgJxB","sourcesContent":["import DOMPurify from \"dompurify\";\nimport { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { unsafeHTML } from \"lit/directives/unsafe-html.js\";\nimport { marked } from \"marked\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Renders a markdown string as sanitized, styled HTML — headings, lists,\n * code, tables, blockquotes, and links all get token-driven styling, with\n * wide content (code blocks, tables) scrolling in its own container instead\n * of widening the page.\n *\n * The markdown source is treated as untrusted: it is always parsed with\n * `marked` and sanitized with `DOMPurify` before being injected, never\n * rendered as-is.\n *\n * @element markdown-view\n */\n@customElement(\"markdown-view\")\nexport class MarkdownView extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text, #0f172a);\n }\n .body :first-child {\n margin-top: 0;\n }\n .body :last-child {\n margin-bottom: 0;\n }\n .body h1,\n .body h2,\n .body h3,\n .body h4,\n .body h5,\n .body h6 {\n font-weight: var(--ui-font-weight-semibold, 600);\n line-height: var(--ui-line-height-tight, 1.25);\n margin: 1.5rem 0 0.5rem;\n }\n .body h1 {\n font-size: var(--ui-font-size-lg, 1rem);\n }\n .body h2 {\n font-size: var(--ui-font-size-lg, 1rem);\n }\n .body h3,\n .body h4,\n .body h5,\n .body h6 {\n font-size: var(--ui-font-size, 0.875rem);\n }\n .body p {\n margin: 0.75rem 0;\n }\n .body ul,\n .body ol {\n margin: 0.75rem 0;\n padding-left: 1.5rem;\n }\n .body li + li {\n margin-top: 0.25rem;\n }\n .body a {\n color: var(--ui-primary, #4f46e5);\n text-decoration: underline;\n text-underline-offset: 0.125rem;\n }\n .body a:hover {\n color: var(--ui-primary-hover, #4338ca);\n }\n .body code {\n font-family: var(\n --ui-font-mono,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Consolas,\n monospace\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n background: var(--ui-surface-muted, #f8fafc);\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.125rem 0.25rem;\n }\n .body pre {\n margin: 0.75rem 0;\n padding: 0.75rem;\n background: var(--ui-surface-muted, #f8fafc);\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n overflow-x: auto;\n }\n .body pre code {\n background: none;\n padding: 0;\n }\n .body blockquote {\n margin: 0.75rem 0;\n padding: 0.25rem 0.75rem;\n border-left: 0.25rem solid var(--ui-border, #e2e8f0);\n color: var(--ui-text-muted, #64748b);\n }\n .body .table-wrap {\n margin: 0.75rem 0;\n overflow-x: auto;\n }\n .body table {\n border-collapse: collapse;\n width: 100%;\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n .body th,\n .body td {\n text-align: left;\n padding: 0.5rem 0.75rem;\n border-bottom: 1px solid var(--ui-border, #e2e8f0);\n }\n .body th {\n font-weight: var(--ui-font-weight-semibold, 600);\n color: var(--ui-text-muted, #64748b);\n }\n .body hr {\n margin: 1.5rem 0;\n border: 0;\n border-top: 1px solid var(--ui-border, #e2e8f0);\n }\n `,\n ];\n\n /** Raw markdown source to render. */\n @property() markdown = \"\";\n\n private _renderedHtml(): string {\n if (!this.markdown) return \"\";\n const rawHtml = marked.parse(this.markdown, { async: false, gfm: true }) as string;\n // Wrap every table in a scroll container so wide tables don't widen the page.\n const wrapped = rawHtml.replace(/<table>/g, '<div class=\"table-wrap\"><table>').replace(\n /<\\/table>/g,\n \"</table></div>\",\n );\n return DOMPurify.sanitize(wrapped);\n }\n\n override render() {\n if (!this.markdown) return nothing;\n return html`<div class=\"body\">${unsafeHTML(this._renderedHtml())}</div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"markdown-view\": MarkdownView;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"markdown-view.js","sourceRoot":"","sources":["../src/markdown-view.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;GAWG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QA8HL,qCAAqC;QACzB,aAAQ,GAAG,EAAE,CAAC;IAiB5B,CAAC;aA/IiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwHF;KACF,AA3HqB,CA2HpB;IAKM,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAW,CAAC;QACnF,8EAA8E;QAC9E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,iCAAiC,CAAC,CAAC,OAAO,CACpF,YAAY,EACZ,gBAAgB,CACjB,CAAC;QACF,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAEQ,MAAM;QACb,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO,OAAO,CAAC;QACnC,OAAO,IAAI,CAAA,qBAAqB,UAAU,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC;IAC3E,CAAC;CACF,CAAA;AAjBa;IAAX,QAAQ,EAAE;8CAAe;AA/Hf,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAgJxB","sourcesContent":["import DOMPurify from \"dompurify\";\nimport { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { unsafeHTML } from \"lit/directives/unsafe-html.js\";\nimport { marked } from \"marked\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Renders a markdown string as sanitized, styled HTML — headings, lists,\n * code, tables, blockquotes, and links all get token-driven styling, with\n * wide content (code blocks, tables) scrolling in its own container instead\n * of widening the page.\n *\n * The markdown source is treated as untrusted: it is always parsed with\n * `marked` and sanitized with `DOMPurify` before being injected, never\n * rendered as-is.\n *\n * @element markdown-view\n */\n@customElement(\"markdown-view\")\nexport class MarkdownView extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text, #0f172a);\n }\n .body :first-child {\n margin-top: 0;\n }\n .body :last-child {\n margin-bottom: 0;\n }\n .body h1,\n .body h2,\n .body h3,\n .body h4,\n .body h5,\n .body h6 {\n font-weight: var(--ui-font-weight-semibold, 600);\n line-height: var(--ui-line-height-tight, 1.25);\n margin: 1.5rem 0 0.5rem;\n }\n .body h1 {\n font-size: var(--ui-font-size-lg, 1rem);\n }\n .body h2 {\n font-size: var(--ui-font-size-lg, 1rem);\n }\n .body h3,\n .body h4,\n .body h5,\n .body h6 {\n font-size: var(--ui-font-size, 0.875rem);\n }\n .body p {\n margin: 0.75rem 0;\n }\n .body ul,\n .body ol {\n margin: 0.75rem 0;\n padding-left: 1.5rem;\n }\n .body li + li {\n margin-top: 0.25rem;\n }\n .body a {\n color: var(--ui-primary, #4f46e5);\n text-decoration: underline;\n text-underline-offset: 0.125rem;\n }\n .body a:hover {\n color: var(--ui-primary-hover, #4338ca);\n }\n .body code {\n font-family: var(\n --ui-font-mono,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Consolas,\n monospace\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n background: var(--ui-surface-muted, #f8fafc);\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.125rem 0.25rem;\n }\n .body pre {\n margin: 0.75rem 0;\n padding: 0.75rem;\n background: var(--ui-surface-muted, #f8fafc);\n border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n overflow-x: auto;\n }\n .body pre code {\n background: none;\n padding: 0;\n }\n .body blockquote {\n margin: 0.75rem 0;\n padding: 0.25rem 0.75rem;\n border-left: 0.25rem solid var(--ui-border, #e2e8f0);\n color: var(--ui-text-muted, #64748b);\n }\n .body .table-wrap {\n margin: 0.75rem 0;\n overflow-x: auto;\n }\n .body table {\n border-collapse: collapse;\n width: 100%;\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n .body th,\n .body td {\n text-align: left;\n padding: 0.5rem 0.75rem;\n border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n }\n .body th {\n font-weight: var(--ui-font-weight-semibold, 600);\n color: var(--ui-text-muted, #64748b);\n }\n .body hr {\n margin: 1.5rem 0;\n border: 0;\n border-top: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n }\n `,\n ];\n\n /** Raw markdown source to render. */\n @property() markdown = \"\";\n\n private _renderedHtml(): string {\n if (!this.markdown) return \"\";\n const rawHtml = marked.parse(this.markdown, { async: false, gfm: true }) as string;\n // Wrap every table in a scroll container so wide tables don't widen the page.\n const wrapped = rawHtml.replace(/<table>/g, '<div class=\"table-wrap\"><table>').replace(\n /<\\/table>/g,\n \"</table></div>\",\n );\n return DOMPurify.sanitize(wrapped);\n }\n\n override render() {\n if (!this.markdown) return nothing;\n return html`<div class=\"body\">${unsafeHTML(this._renderedHtml())}</div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"markdown-view\": MarkdownView;\n }\n}\n"]}
|
package/dist/modal-dialog.js
CHANGED
|
@@ -130,7 +130,7 @@ let ModalDialog = class ModalDialog extends LitElement {
|
|
|
130
130
|
align-items: center;
|
|
131
131
|
justify-content: space-between;
|
|
132
132
|
padding: 0.75rem;
|
|
133
|
-
border-bottom: 1px solid var(--ui-border, #e2e8f0);
|
|
133
|
+
border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
134
134
|
flex: 0 0 auto;
|
|
135
135
|
}
|
|
136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;QACb,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACtD,OAAO,IAAI,CAAA;;yBAEU,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;iBACjF,IAAI,CAAC,eAAe;;;0BAGX,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;;;uBAG7E,aAAa,IAAI,OAAO;4BACnB,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc;;;;;mCAKjC,IAAI,CAAC,OAAO;;kEAEmB,IAAI,CAAC,MAAM;yCACpC,KAAK,CAAC,EAAE,CAAC;;;;;;;;KAQ7C,CAAC;IACJ,CAAC;CACF,CAAA;AA9H8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAc;AAE9B;IAAX,QAAQ,EAAE;4CAAc;AAMb;IAAX,QAAQ,EAAE;yCAAmC;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAqB;AAlItC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAsPvB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconX } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport { activateLayer, claimEscape, deactivateLayer, isTopLayer } from \"./utils/layer-stack.js\";\n\nexport type ModalDialogSize = \"default\" | \"lg\" | \"fullscreen\";\n\n/**\n * Generic centered modal-dialog shell: overlay + card with header chrome, a\n * close button, and an arbitrary slotted body — the modal sibling to\n * `slide-panel` (fixed-edge) and `popover-panel` (anchored). Unlike\n * `confirm-dialog`, it has no baked-in actions; the consumer supplies the\n * body content (a form, a read-only viewer, a table) and any footer buttons\n * itself. Instant `display:none` → `display:flex` toggle, no transition.\n * Traps focus, closes on Escape, and restores focus to the trigger on\n * close, stacking correctly against other open `confirm-dialog`/\n * `slide-panel`/`popover-panel`/`modal-dialog` layers.\n *\n * @element modal-dialog\n * @fires panel-close - User clicked the close (✕) button, pressed Escape, or (when `dismissible`) clicked the backdrop.\n * @slot - Dialog body content.\n * @slot title - Overrides the header title text (falls back to the `heading` property).\n */\n@customElement(\"modal-dialog\")\nexport class ModalDialog extends LitElement {\n static override styles = [\n tokens,\n css`\n .overlay {\n position: fixed;\n inset: 0;\n background: var(--ui-overlay, rgb(15 23 42 / 0.45));\n z-index: var(--component-layer-z, 50);\n display: none;\n align-items: flex-start;\n justify-content: center;\n padding: 10vh 1.25rem 1.25rem;\n box-sizing: border-box;\n }\n .overlay.open {\n display: flex;\n }\n .overlay.fullscreen {\n padding: 0;\n align-items: stretch;\n }\n .dialog {\n background: var(--ui-surface, #ffffff);\n border-radius: var(--ui-radius, 0.5rem);\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n );\n width: 100%;\n max-width: min(25rem, calc(100vw - 2rem));\n max-height: calc(100vh - 10vh - 1.25rem);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n box-sizing: border-box;\n outline: none;\n }\n .dialog.lg {\n max-width: min(60rem, calc(100vw - 2rem));\n }\n .dialog.fullscreen {\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n border-radius: 0;\n }\n .dialog-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0.75rem;\n border-bottom: 1px solid var(--ui-border, #e2e8f0);\n flex: 0 0 auto;\n }\n .dialog-title {\n font-weight: var(--ui-font-weight-semibold, 600);\n font-size: var(--ui-font-size-lg, 1rem);\n line-height: var(--ui-line-height-tight, 1.25);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n color: var(--ui-text, #0f172a);\n flex: 1 1 auto;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n padding-right: 0.5rem;\n }\n .close-btn {\n background: none;\n border: none;\n cursor: pointer;\n width: 2rem;\n height: 2rem;\n padding: 0;\n color: var(--ui-text-muted, #64748b);\n border-radius: var(--ui-radius-sm, 0.25rem);\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n .close-btn:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .close-btn:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .body {\n overflow-y: auto;\n flex: 1 1 auto;\n }\n @media (forced-colors: active) {\n .close-btn:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n .overlay {\n padding: 0.75rem;\n overflow-y: auto;\n }\n }\n `,\n ];\n\n /** Whether the dialog is visible. */\n @property({ type: Boolean }) open = false;\n /** Title text shown in the dialog header (overridable via slot=\"title\"). */\n @property() heading = \"\";\n /**\n * `\"lg\"` widens the dialog to 60rem for content like tables; `\"default\"`\n * is 25rem; `\"fullscreen\"` covers the entire viewport edge-to-edge with\n * no border-radius or overlay padding.\n */\n @property() size: ModalDialogSize = \"default\";\n /** When true, clicking the backdrop also closes the dialog (off by default — safe for forms with unsaved input). */\n @property({ type: Boolean }) dismissible = false;\n\n private _previousFocus: HTMLElement | null = null;\n\n private _close() {\n this.dispatchEvent(new CustomEvent(\"panel-close\", { bubbles: true, composed: true }));\n }\n\n private _getFocusableElements(): HTMLElement[] {\n const selector =\n \"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])\";\n const slotted = Array.from(this.querySelectorAll<HTMLElement>(selector));\n const internal = Array.from(\n this.shadowRoot?.querySelectorAll<HTMLElement>(selector) ?? [],\n ).filter((element) => element.closest(\".dialog\") !== null);\n return [...slotted, ...internal].filter((element) => !element.hasAttribute(\"hidden\"));\n }\n\n private _focusInitial(): void {\n const autofocus = this.querySelector<HTMLElement>(\"[autofocus]\");\n const close = this.shadowRoot?.querySelector<HTMLElement>(\".close-btn\");\n const dialog = this.shadowRoot?.querySelector<HTMLElement>(\".dialog\");\n (autofocus ?? close ?? this._getFocusableElements()[0] ?? dialog)?.focus();\n }\n\n private _onDocumentFocusIn = (event: FocusEvent): void => {\n if (!this.open || !isTopLayer(this) || event.composedPath().includes(this)) return;\n this._focusInitial();\n };\n\n private _onWindowKeydown = (event: KeyboardEvent): void => {\n if (!this.open || !isTopLayer(this)) return;\n if (claimEscape(this, event)) {\n this._close();\n return;\n }\n if (event.key !== \"Tab\") return;\n\n const focusable = this._getFocusableElements();\n if (focusable.length === 0) {\n event.preventDefault();\n this._focusInitial();\n return;\n }\n const active = (this.shadowRoot?.activeElement ?? document.activeElement) as HTMLElement | null;\n const index = focusable.indexOf(active as HTMLElement);\n if (event.shiftKey && index <= 0) {\n event.preventDefault();\n focusable.at(-1)?.focus();\n } else if (!event.shiftKey && index === focusable.length - 1) {\n event.preventDefault();\n focusable[0]?.focus();\n }\n };\n\n private _onOverlayClick = (event: MouseEvent): void => {\n if (this.dismissible && event.target === event.currentTarget) this._close();\n };\n\n protected override updated(changed: PropertyValues): void {\n if (!changed.has(\"open\")) return;\n if (this.open) {\n activateLayer(this);\n this._previousFocus = document.activeElement as HTMLElement | null;\n document.addEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.addEventListener(\"keydown\", this._onWindowKeydown, true);\n this._focusInitial();\n return;\n }\n deactivateLayer(this);\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n deactivateLayer(this);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n this.open = false;\n }\n\n override render() {\n const explicitLabel = this.getAttribute(\"aria-label\");\n return html`\n <div\n class=\"overlay ${this.open ? \"open\" : \"\"} ${this.size === \"fullscreen\" ? \"fullscreen\" : \"\"}\"\n @click=${this._onOverlayClick}\n >\n <div\n class=\"dialog ${this.size === \"lg\" ? \"lg\" : this.size === \"fullscreen\" ? \"fullscreen\" : \"\"}\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${explicitLabel ?? nothing}\n aria-labelledby=${explicitLabel ? nothing : \"dialog-title\"}\n tabindex=\"-1\"\n >\n <div class=\"dialog-header\">\n <span id=\"dialog-title\" class=\"dialog-title\">\n <slot name=\"title\">${this.heading}</slot>\n </span>\n <button class=\"close-btn\" aria-label=\"Close\" @click=${this._close}>\n <span aria-hidden=\"true\">${iconX(18)}</span>\n </button>\n </div>\n <div class=\"body\">\n <slot></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"modal-dialog\": ModalDialog;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"modal-dialog.js","sourceRoot":"","sources":["../src/modal-dialog.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE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,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;;;uBAG7E,aAAa,IAAI,OAAO;4BACnB,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc;;;;;mCAKjC,IAAI,CAAC,OAAO;;kEAEmB,IAAI,CAAC,MAAM;yCACpC,KAAK,CAAC,EAAE,CAAC;;;;;;;;KAQ7C,CAAC;IACJ,CAAC;CACF,CAAA;AA9H8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAc;AAE9B;IAAX,QAAQ,EAAE;4CAAc;AAMb;IAAX,QAAQ,EAAE;yCAAmC;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAqB;AAlItC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAsPvB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconX } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport { activateLayer, claimEscape, deactivateLayer, isTopLayer } from \"./utils/layer-stack.js\";\n\nexport type ModalDialogSize = \"default\" | \"lg\" | \"fullscreen\";\n\n/**\n * Generic centered modal-dialog shell: overlay + card with header chrome, a\n * close button, and an arbitrary slotted body — the modal sibling to\n * `slide-panel` (fixed-edge) and `popover-panel` (anchored). Unlike\n * `confirm-dialog`, it has no baked-in actions; the consumer supplies the\n * body content (a form, a read-only viewer, a table) and any footer buttons\n * itself. Instant `display:none` → `display:flex` toggle, no transition.\n * Traps focus, closes on Escape, and restores focus to the trigger on\n * close, stacking correctly against other open `confirm-dialog`/\n * `slide-panel`/`popover-panel`/`modal-dialog` layers.\n *\n * @element modal-dialog\n * @fires panel-close - User clicked the close (✕) button, pressed Escape, or (when `dismissible`) clicked the backdrop.\n * @slot - Dialog body content.\n * @slot title - Overrides the header title text (falls back to the `heading` property).\n */\n@customElement(\"modal-dialog\")\nexport class ModalDialog extends LitElement {\n static override styles = [\n tokens,\n css`\n .overlay {\n position: fixed;\n inset: 0;\n background: var(--ui-overlay, rgb(15 23 42 / 0.45));\n z-index: var(--component-layer-z, 50);\n display: none;\n align-items: flex-start;\n justify-content: center;\n padding: 10vh 1.25rem 1.25rem;\n box-sizing: border-box;\n }\n .overlay.open {\n display: flex;\n }\n .overlay.fullscreen {\n padding: 0;\n align-items: stretch;\n }\n .dialog {\n background: var(--ui-surface, #ffffff);\n border-radius: var(--ui-radius, 0.5rem);\n box-shadow: var(\n --ui-shadow-lg,\n 0 20px 25px -5px rgb(0 0 0 / 0.1),\n 0 8px 10px -6px rgb(0 0 0 / 0.1)\n );\n width: 100%;\n max-width: min(25rem, calc(100vw - 2rem));\n max-height: calc(100vh - 10vh - 1.25rem);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n box-sizing: border-box;\n outline: none;\n }\n .dialog.lg {\n max-width: min(60rem, calc(100vw - 2rem));\n }\n .dialog.fullscreen {\n width: 100vw;\n height: 100vh;\n max-width: 100vw;\n max-height: 100vh;\n border-radius: 0;\n }\n .dialog-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0.75rem;\n border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n flex: 0 0 auto;\n }\n .dialog-title {\n font-weight: var(--ui-font-weight-semibold, 600);\n font-size: var(--ui-font-size-lg, 1rem);\n line-height: var(--ui-line-height-tight, 1.25);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n color: var(--ui-text, #0f172a);\n flex: 1 1 auto;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n padding-right: 0.5rem;\n }\n .close-btn {\n background: none;\n border: none;\n cursor: pointer;\n width: 2rem;\n height: 2rem;\n padding: 0;\n color: var(--ui-text-muted, #64748b);\n border-radius: var(--ui-radius-sm, 0.25rem);\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n .close-btn:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .close-btn:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .body {\n overflow-y: auto;\n flex: 1 1 auto;\n }\n @media (forced-colors: active) {\n .close-btn:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n @media (max-width: 48rem) {\n .overlay {\n padding: 0.75rem;\n overflow-y: auto;\n }\n }\n `,\n ];\n\n /** Whether the dialog is visible. */\n @property({ type: Boolean }) open = false;\n /** Title text shown in the dialog header (overridable via slot=\"title\"). */\n @property() heading = \"\";\n /**\n * `\"lg\"` widens the dialog to 60rem for content like tables; `\"default\"`\n * is 25rem; `\"fullscreen\"` covers the entire viewport edge-to-edge with\n * no border-radius or overlay padding.\n */\n @property() size: ModalDialogSize = \"default\";\n /** When true, clicking the backdrop also closes the dialog (off by default — safe for forms with unsaved input). */\n @property({ type: Boolean }) dismissible = false;\n\n private _previousFocus: HTMLElement | null = null;\n\n private _close() {\n this.dispatchEvent(new CustomEvent(\"panel-close\", { bubbles: true, composed: true }));\n }\n\n private _getFocusableElements(): HTMLElement[] {\n const selector =\n \"a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex='-1'])\";\n const slotted = Array.from(this.querySelectorAll<HTMLElement>(selector));\n const internal = Array.from(\n this.shadowRoot?.querySelectorAll<HTMLElement>(selector) ?? [],\n ).filter((element) => element.closest(\".dialog\") !== null);\n return [...slotted, ...internal].filter((element) => !element.hasAttribute(\"hidden\"));\n }\n\n private _focusInitial(): void {\n const autofocus = this.querySelector<HTMLElement>(\"[autofocus]\");\n const close = this.shadowRoot?.querySelector<HTMLElement>(\".close-btn\");\n const dialog = this.shadowRoot?.querySelector<HTMLElement>(\".dialog\");\n (autofocus ?? close ?? this._getFocusableElements()[0] ?? dialog)?.focus();\n }\n\n private _onDocumentFocusIn = (event: FocusEvent): void => {\n if (!this.open || !isTopLayer(this) || event.composedPath().includes(this)) return;\n this._focusInitial();\n };\n\n private _onWindowKeydown = (event: KeyboardEvent): void => {\n if (!this.open || !isTopLayer(this)) return;\n if (claimEscape(this, event)) {\n this._close();\n return;\n }\n if (event.key !== \"Tab\") return;\n\n const focusable = this._getFocusableElements();\n if (focusable.length === 0) {\n event.preventDefault();\n this._focusInitial();\n return;\n }\n const active = (this.shadowRoot?.activeElement ?? document.activeElement) as HTMLElement | null;\n const index = focusable.indexOf(active as HTMLElement);\n if (event.shiftKey && index <= 0) {\n event.preventDefault();\n focusable.at(-1)?.focus();\n } else if (!event.shiftKey && index === focusable.length - 1) {\n event.preventDefault();\n focusable[0]?.focus();\n }\n };\n\n private _onOverlayClick = (event: MouseEvent): void => {\n if (this.dismissible && event.target === event.currentTarget) this._close();\n };\n\n protected override updated(changed: PropertyValues): void {\n if (!changed.has(\"open\")) return;\n if (this.open) {\n activateLayer(this);\n this._previousFocus = document.activeElement as HTMLElement | null;\n document.addEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.addEventListener(\"keydown\", this._onWindowKeydown, true);\n this._focusInitial();\n return;\n }\n deactivateLayer(this);\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener(\"focusin\", this._onDocumentFocusIn, true);\n window.removeEventListener(\"keydown\", this._onWindowKeydown, true);\n deactivateLayer(this);\n if (this._previousFocus?.isConnected) this._previousFocus.focus();\n this._previousFocus = null;\n this.open = false;\n }\n\n override render() {\n const explicitLabel = this.getAttribute(\"aria-label\");\n return html`\n <div\n class=\"overlay ${this.open ? \"open\" : \"\"} ${this.size === \"fullscreen\" ? \"fullscreen\" : \"\"}\"\n @click=${this._onOverlayClick}\n >\n <div\n class=\"dialog ${this.size === \"lg\" ? \"lg\" : this.size === \"fullscreen\" ? \"fullscreen\" : \"\"}\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${explicitLabel ?? nothing}\n aria-labelledby=${explicitLabel ? nothing : \"dialog-title\"}\n tabindex=\"-1\"\n >\n <div class=\"dialog-header\">\n <span id=\"dialog-title\" class=\"dialog-title\">\n <slot name=\"title\">${this.heading}</slot>\n </span>\n <button class=\"close-btn\" aria-label=\"Close\" @click=${this._close}>\n <span aria-hidden=\"true\">${iconX(18)}</span>\n </button>\n </div>\n <div class=\"body\">\n <slot></slot>\n </div>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"modal-dialog\": ModalDialog;\n }\n}\n"]}
|
package/dist/multi-select.js
CHANGED
|
@@ -179,7 +179,7 @@ let MultiSelect = class MultiSelect extends LitElement {
|
|
|
179
179
|
line-height: var(--ui-line-height-tight, 1.25);
|
|
180
180
|
color: var(--ui-text, #0f172a);
|
|
181
181
|
background: var(--ui-surface, #ffffff);
|
|
182
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
182
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
183
183
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
184
184
|
padding: 0.5rem 0.75rem;
|
|
185
185
|
cursor: pointer;
|
|
@@ -215,7 +215,7 @@ let MultiSelect = class MultiSelect extends LitElement {
|
|
|
215
215
|
box-sizing: border-box;
|
|
216
216
|
color: var(--ui-text, #0f172a);
|
|
217
217
|
background: var(--ui-surface, #ffffff);
|
|
218
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
218
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
219
219
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
220
220
|
cursor: text;
|
|
221
221
|
}
|
|
@@ -288,7 +288,7 @@ let MultiSelect = class MultiSelect extends LitElement {
|
|
|
288
288
|
white-space: nowrap;
|
|
289
289
|
color: var(--ui-text, #0f172a);
|
|
290
290
|
background: var(--ui-surface, #ffffff);
|
|
291
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
291
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
292
292
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
293
293
|
box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
|
|
294
294
|
}
|
|
@@ -314,7 +314,7 @@ let MultiSelect = class MultiSelect extends LitElement {
|
|
|
314
314
|
margin-bottom: 0.25rem;
|
|
315
315
|
color: var(--ui-text, #0f172a);
|
|
316
316
|
background: var(--ui-surface, #ffffff);
|
|
317
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
317
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
318
318
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
319
319
|
cursor: text;
|
|
320
320
|
}
|
|
@@ -438,7 +438,7 @@ let MultiSelect = class MultiSelect extends LitElement {
|
|
|
438
438
|
padding-left: 0.5rem;
|
|
439
439
|
color: var(--ui-text, #0f172a);
|
|
440
440
|
background: var(--ui-surface-muted, #f8fafc);
|
|
441
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
441
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
442
442
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
443
443
|
}
|
|
444
444
|
.chip-label {
|