@k2b/ui 0.50.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.css +32 -1
- package/dist/browser/actions/Button.js.map +1 -1
- package/dist/browser/actions/CommandList.js +861 -0
- package/dist/browser/actions/CommandList.js.map +1 -0
- package/dist/browser/actions/CommandMenu.js +237 -0
- package/dist/browser/actions/CommandMenu.js.map +1 -0
- package/dist/browser/actions/Dropdown.js +43 -10
- package/dist/browser/actions/Dropdown.js.map +1 -1
- package/dist/browser/actions/command-dock.js +47 -0
- package/dist/browser/actions/command-dock.js.map +1 -0
- package/dist/browser/actions/command-items.js +84 -0
- package/dist/browser/actions/command-items.js.map +1 -0
- package/dist/browser/actions/command-messages.js +42 -0
- package/dist/browser/actions/command-messages.js.map +1 -0
- package/dist/browser/actions/index.js +1 -0
- package/dist/browser/actions/index.js.map +1 -1
- package/dist/browser/charts/core/area.js +3 -5
- package/dist/browser/charts/core/area.js.map +1 -1
- package/dist/browser/charts/core/calendar.js +1 -1
- package/dist/browser/charts/core/calendar.js.map +1 -1
- package/dist/browser/charts/core/chart-messages.js +17 -0
- package/dist/browser/charts/core/chart-messages.js.map +1 -0
- package/dist/browser/charts/core/hbar-layout.js +118 -0
- package/dist/browser/charts/core/hbar-layout.js.map +1 -0
- package/dist/browser/charts/core/hbar.js +39 -0
- package/dist/browser/charts/core/hbar.js.map +1 -0
- package/dist/browser/charts/core/index.js +7 -2
- package/dist/browser/charts/core/index.js.map +1 -1
- package/dist/browser/charts/core/map.js +116 -0
- package/dist/browser/charts/core/map.js.map +1 -0
- package/dist/browser/charts/core/registry.js +22 -15
- package/dist/browser/charts/core/registry.js.map +1 -1
- package/dist/browser/charts/core/render-size.js +13 -0
- package/dist/browser/charts/core/render-size.js.map +1 -0
- package/dist/browser/charts/core/render.js +20 -10
- package/dist/browser/charts/core/render.js.map +1 -1
- package/dist/browser/charts/core/snapshot.js +3 -3
- package/dist/browser/charts/core/snapshot.js.map +1 -1
- package/dist/browser/charts/core/svg-renderers.js +2406 -0
- package/dist/browser/charts/core/svg-renderers.js.map +1 -0
- package/dist/browser/charts/core/svg.js +4 -2525
- package/dist/browser/charts/core/svg.js.map +1 -1
- package/dist/browser/charts/core/types.js +0 -2
- package/dist/browser/charts/core/types.js.map +1 -1
- package/dist/browser/charts/core/waterfall.js +162 -0
- package/dist/browser/charts/core/waterfall.js.map +1 -0
- package/dist/browser/charts/description.js +2 -0
- package/dist/browser/charts/description.js.map +1 -0
- package/dist/browser/charts.js.map +1 -1
- package/dist/browser/content/Chart.js +14 -628
- package/dist/browser/content/Chart.js.map +1 -1
- package/dist/browser/content/ChartRoot.js +632 -0
- package/dist/browser/content/ChartRoot.js.map +1 -0
- package/dist/browser/content/ChartSparkline.js +24 -0
- package/dist/browser/content/ChartSparkline.js.map +1 -0
- package/dist/browser/content/FileView.js +111 -61
- package/dist/browser/content/FileView.js.map +1 -1
- package/dist/browser/content/Lightbox.js +8 -8
- package/dist/browser/content/Lightbox.js.map +1 -1
- package/dist/browser/content/MapView.js +30 -28
- package/dist/browser/content/MapView.js.map +1 -1
- package/dist/browser/content/PdfPreview.js +84 -52
- package/dist/browser/content/PdfPreview.js.map +1 -1
- package/dist/browser/content/PdfViewer.js +588 -0
- package/dist/browser/content/PdfViewer.js.map +1 -0
- package/dist/browser/content/chart-bar.js +246 -16
- package/dist/browser/content/chart-bar.js.map +1 -1
- package/dist/browser/content/chart-inspection-core.js +22 -21
- package/dist/browser/content/chart-inspection-core.js.map +1 -1
- package/dist/browser/content/chart-line-gaps.js +1 -1
- package/dist/browser/content/chart-line-gaps.js.map +1 -1
- package/dist/browser/content/chart-message-catalog.js +10 -0
- package/dist/browser/content/chart-message-catalog.js.map +1 -1
- package/dist/browser/content/chart-state-timeline.js +1 -1
- package/dist/browser/content/chart-state-timeline.js.map +1 -1
- package/dist/browser/content/chart-svg.js +2 -1
- package/dist/browser/content/chart-svg.js.map +1 -1
- package/dist/browser/content/index.js +1 -0
- package/dist/browser/content/index.js.map +1 -1
- package/dist/browser/content/pdf-document.js +29 -0
- package/dist/browser/content/pdf-document.js.map +1 -0
- package/dist/browser/content/pdf-limits.js +31 -0
- package/dist/browser/content/pdf-limits.js.map +1 -0
- package/dist/browser/content/pdf-messages.js +34 -2
- package/dist/browser/content/pdf-messages.js.map +1 -1
- package/dist/browser/content/pdf-viewer-engine.js +57 -0
- package/dist/browser/content/pdf-viewer-worker.js +28 -0
- package/dist/browser/inputs/ChoiceInputs.js +94 -51
- package/dist/browser/inputs/ChoiceInputs.js.map +1 -1
- package/dist/browser/inputs/ChoiceSlider.js +75 -58
- package/dist/browser/inputs/ChoiceSlider.js.map +1 -1
- package/dist/browser/inputs/DatePicker.js +113 -98
- package/dist/browser/inputs/DatePicker.js.map +1 -1
- package/dist/browser/inputs/PeriodPicker.js +874 -0
- package/dist/browser/inputs/PeriodPicker.js.map +1 -0
- package/dist/browser/inputs/index.js +4 -1
- package/dist/browser/inputs/index.js.map +1 -1
- package/dist/browser/inputs/input-messages.js +8 -2
- package/dist/browser/inputs/input-messages.js.map +1 -1
- package/dist/browser/inputs/markdown/MarkdownEditor.js +14 -10
- package/dist/browser/inputs/markdown/MarkdownEditor.js.map +1 -1
- package/dist/browser/inputs/markdown/SlashCommands.js +402 -0
- package/dist/browser/inputs/markdown/SlashCommands.js.map +1 -0
- package/dist/browser/inputs/period-picker-messages.js +71 -0
- package/dist/browser/inputs/period-picker-messages.js.map +1 -0
- package/dist/browser/inputs/period.js +263 -0
- package/dist/browser/inputs/period.js.map +1 -0
- package/dist/browser/layout/DetailPanel.js +147 -120
- package/dist/browser/layout/DetailPanel.js.map +1 -1
- package/dist/browser/layout/Discussion.js +101 -108
- package/dist/browser/layout/Discussion.js.map +1 -1
- package/dist/browser/layout/index.js.map +1 -1
- package/dist/browser/surfaces/DescriptionList.js +5 -2
- package/dist/browser/surfaces/DescriptionList.js.map +1 -1
- package/dist/browser/surfaces/StatCell.js +19 -14
- package/dist/browser/surfaces/StatCell.js.map +1 -1
- package/dist/browser/surfaces/delta-badge.js +16 -2
- package/dist/browser/surfaces/delta-badge.js.map +1 -1
- package/dist/browser/widgets/DashboardFrame.js +310 -0
- package/dist/browser/widgets/DashboardFrame.js.map +1 -0
- package/dist/browser/widgets/index.js +1 -0
- package/dist/browser/widgets/index.js.map +1 -1
- package/dist/licenses/pdfjs-dist.txt +177 -0
- package/dist/ssr/actions/Button.js.map +1 -1
- package/dist/ssr/actions/CommandList.js +638 -0
- package/dist/ssr/actions/CommandList.js.map +1 -0
- package/dist/ssr/actions/CommandMenu.js +197 -0
- package/dist/ssr/actions/CommandMenu.js.map +1 -0
- package/dist/ssr/actions/Dropdown.js +43 -10
- package/dist/ssr/actions/Dropdown.js.map +1 -1
- package/dist/ssr/actions/command-dock.js +47 -0
- package/dist/ssr/actions/command-dock.js.map +1 -0
- package/dist/ssr/actions/command-items.js +84 -0
- package/dist/ssr/actions/command-items.js.map +1 -0
- package/dist/ssr/actions/command-messages.js +42 -0
- package/dist/ssr/actions/command-messages.js.map +1 -0
- package/dist/ssr/actions/index.js +1 -0
- package/dist/ssr/actions/index.js.map +1 -1
- package/dist/ssr/charts/core/area.js +3 -5
- package/dist/ssr/charts/core/area.js.map +1 -1
- package/dist/ssr/charts/core/calendar.js +1 -1
- package/dist/ssr/charts/core/calendar.js.map +1 -1
- package/dist/ssr/charts/core/chart-messages.js +17 -0
- package/dist/ssr/charts/core/chart-messages.js.map +1 -0
- package/dist/ssr/charts/core/hbar-layout.js +118 -0
- package/dist/ssr/charts/core/hbar-layout.js.map +1 -0
- package/dist/ssr/charts/core/hbar.js +39 -0
- package/dist/ssr/charts/core/hbar.js.map +1 -0
- package/dist/ssr/charts/core/index.js +7 -2
- package/dist/ssr/charts/core/index.js.map +1 -1
- package/dist/ssr/charts/core/map.js +116 -0
- package/dist/ssr/charts/core/map.js.map +1 -0
- package/dist/ssr/charts/core/registry.js +22 -15
- package/dist/ssr/charts/core/registry.js.map +1 -1
- package/dist/ssr/charts/core/render-size.js +13 -0
- package/dist/ssr/charts/core/render-size.js.map +1 -0
- package/dist/ssr/charts/core/render.js +20 -10
- package/dist/ssr/charts/core/render.js.map +1 -1
- package/dist/ssr/charts/core/snapshot.js +3 -3
- package/dist/ssr/charts/core/snapshot.js.map +1 -1
- package/dist/ssr/charts/core/svg-renderers.js +2406 -0
- package/dist/ssr/charts/core/svg-renderers.js.map +1 -0
- package/dist/ssr/charts/core/svg.js +4 -2525
- package/dist/ssr/charts/core/svg.js.map +1 -1
- package/dist/ssr/charts/core/types.js +0 -2
- package/dist/ssr/charts/core/types.js.map +1 -1
- package/dist/ssr/charts/core/waterfall.js +162 -0
- package/dist/ssr/charts/core/waterfall.js.map +1 -0
- package/dist/ssr/charts/description.js +2 -0
- package/dist/ssr/charts/description.js.map +1 -0
- package/dist/ssr/charts.js.map +1 -1
- package/dist/ssr/content/Chart.js +14 -471
- package/dist/ssr/content/Chart.js.map +1 -1
- package/dist/ssr/content/ChartRoot.js +475 -0
- package/dist/ssr/content/ChartRoot.js.map +1 -0
- package/dist/ssr/content/ChartSparkline.js +24 -0
- package/dist/ssr/content/ChartSparkline.js.map +1 -0
- package/dist/ssr/content/FileView.js +56 -7
- package/dist/ssr/content/FileView.js.map +1 -1
- package/dist/ssr/content/Lightbox.js +8 -8
- package/dist/ssr/content/Lightbox.js.map +1 -1
- package/dist/ssr/content/MapView.js +9 -9
- package/dist/ssr/content/MapView.js.map +1 -1
- package/dist/ssr/content/PdfPreview.js +49 -20
- package/dist/ssr/content/PdfPreview.js.map +1 -1
- package/dist/ssr/content/PdfViewer.js +484 -0
- package/dist/ssr/content/PdfViewer.js.map +1 -0
- package/dist/ssr/content/chart-bar.js +246 -16
- package/dist/ssr/content/chart-bar.js.map +1 -1
- package/dist/ssr/content/chart-inspection-core.js +22 -21
- package/dist/ssr/content/chart-inspection-core.js.map +1 -1
- package/dist/ssr/content/chart-line-gaps.js +1 -1
- package/dist/ssr/content/chart-line-gaps.js.map +1 -1
- package/dist/ssr/content/chart-message-catalog.js +10 -0
- package/dist/ssr/content/chart-message-catalog.js.map +1 -1
- package/dist/ssr/content/chart-state-timeline.js +1 -1
- package/dist/ssr/content/chart-state-timeline.js.map +1 -1
- package/dist/ssr/content/chart-svg.js +2 -1
- package/dist/ssr/content/chart-svg.js.map +1 -1
- package/dist/ssr/content/index.js +1 -0
- package/dist/ssr/content/index.js.map +1 -1
- package/dist/ssr/content/pdf-document.js +29 -0
- package/dist/ssr/content/pdf-document.js.map +1 -0
- package/dist/ssr/content/pdf-limits.js +31 -0
- package/dist/ssr/content/pdf-limits.js.map +1 -0
- package/dist/ssr/content/pdf-messages.js +34 -2
- package/dist/ssr/content/pdf-messages.js.map +1 -1
- package/dist/ssr/inputs/ChoiceInputs.js +49 -12
- package/dist/ssr/inputs/ChoiceInputs.js.map +1 -1
- package/dist/ssr/inputs/ChoiceSlider.js +17 -12
- package/dist/ssr/inputs/ChoiceSlider.js.map +1 -1
- package/dist/ssr/inputs/DatePicker.js +14 -9
- package/dist/ssr/inputs/DatePicker.js.map +1 -1
- package/dist/ssr/inputs/PeriodPicker.js +598 -0
- package/dist/ssr/inputs/PeriodPicker.js.map +1 -0
- package/dist/ssr/inputs/index.js +4 -1
- package/dist/ssr/inputs/index.js.map +1 -1
- package/dist/ssr/inputs/input-messages.js +8 -2
- package/dist/ssr/inputs/input-messages.js.map +1 -1
- package/dist/ssr/inputs/markdown/MarkdownEditor.js +3 -2
- package/dist/ssr/inputs/markdown/MarkdownEditor.js.map +1 -1
- package/dist/ssr/inputs/markdown/SlashCommands.js +339 -0
- package/dist/ssr/inputs/markdown/SlashCommands.js.map +1 -0
- package/dist/ssr/inputs/period-picker-messages.js +71 -0
- package/dist/ssr/inputs/period-picker-messages.js.map +1 -0
- package/dist/ssr/inputs/period.js +263 -0
- package/dist/ssr/inputs/period.js.map +1 -0
- package/dist/ssr/layout/DetailPanel.js +27 -4
- package/dist/ssr/layout/DetailPanel.js.map +1 -1
- package/dist/ssr/layout/Discussion.js +16 -2
- package/dist/ssr/layout/Discussion.js.map +1 -1
- package/dist/ssr/layout/index.js.map +1 -1
- package/dist/ssr/surfaces/DescriptionList.js +1 -1
- package/dist/ssr/surfaces/DescriptionList.js.map +1 -1
- package/dist/ssr/surfaces/StatCell.js +4 -5
- package/dist/ssr/surfaces/StatCell.js.map +1 -1
- package/dist/ssr/surfaces/delta-badge.js +16 -2
- package/dist/ssr/surfaces/delta-badge.js.map +1 -1
- package/dist/ssr/widgets/DashboardFrame.js +200 -0
- package/dist/ssr/widgets/DashboardFrame.js.map +1 -0
- package/dist/ssr/widgets/index.js +1 -0
- package/dist/ssr/widgets/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/actions/Button.d.ts +1 -1
- package/dist/types/actions/CommandList.d.ts +120 -0
- package/dist/types/actions/CommandMenu.d.ts +39 -0
- package/dist/types/actions/Dropdown.d.ts +17 -0
- package/dist/types/actions/command-dock.d.ts +8 -0
- package/dist/types/actions/command-items.d.ts +134 -0
- package/dist/types/actions/command-messages.d.ts +19 -0
- package/dist/types/actions/index.d.ts +3 -0
- package/dist/types/charts/core/calendar.d.ts +1 -1
- package/dist/types/charts/core/chart-messages.d.ts +5 -0
- package/dist/types/charts/core/hbar-layout.d.ts +74 -0
- package/dist/types/charts/core/hbar.d.ts +13 -0
- package/dist/types/charts/core/index.d.ts +7 -2
- package/dist/types/charts/core/map.d.ts +3 -0
- package/dist/types/charts/core/registry.d.ts +17 -11
- package/dist/types/charts/core/render-size.d.ts +7 -0
- package/dist/types/charts/core/render.d.ts +1 -4
- package/dist/types/charts/core/snapshot.d.ts +2 -2
- package/dist/types/charts/core/svg-renderers.d.ts +722 -0
- package/dist/types/charts/core/svg.d.ts +4 -698
- package/dist/types/charts/core/types.d.ts +1 -12
- package/dist/types/charts/core/waterfall.d.ts +68 -0
- package/dist/types/charts/description.d.ts +226 -0
- package/dist/types/charts.d.ts +1 -0
- package/dist/types/content/Chart.d.ts +3 -91
- package/dist/types/content/ChartRoot.d.ts +92 -0
- package/dist/types/content/ChartSparkline.d.ts +5 -0
- package/dist/types/content/PdfViewer.d.ts +32 -0
- package/dist/types/content/chart-bar.d.ts +95 -2
- package/dist/types/content/index.d.ts +2 -0
- package/dist/types/content/pdf-document.d.ts +5 -0
- package/dist/types/content/pdf-engine.d.ts +9 -0
- package/dist/types/content/pdf-limits.d.ts +43 -0
- package/dist/types/content/pdf-messages.d.ts +16 -0
- package/dist/types/inputs/ChoiceInputs.d.ts +4 -0
- package/dist/types/inputs/ChoiceSlider.d.ts +12 -0
- package/dist/types/inputs/DatePicker.d.ts +22 -0
- package/dist/types/inputs/PeriodPicker.d.ts +24 -0
- package/dist/types/inputs/index.d.ts +8 -2
- package/dist/types/inputs/input-messages.d.ts +3 -0
- package/dist/types/inputs/markdown/MarkdownEditor.d.ts +5 -0
- package/dist/types/inputs/markdown/SlashCommands.d.ts +20 -0
- package/dist/types/inputs/period-picker-messages.d.ts +34 -0
- package/dist/types/inputs/period.d.ts +134 -0
- package/dist/types/layout/DetailPanel.d.ts +12 -0
- package/dist/types/layout/index.d.ts +1 -1
- package/dist/types/surfaces/DescriptionList.d.ts +5 -0
- package/dist/types/surfaces/StatCell.d.ts +6 -1
- package/dist/types/widgets/DashboardFrame.d.ts +58 -0
- package/dist/types/widgets/index.d.ts +1 -0
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["content/chart-svg.ts"],"sourcesContent":["import type { MapViewport } from \"../charts/core/svg\";\n\n/** Give maps a CSS-sized viewport while retaining the renderer's projection.\n * The outer SVG uses pixels for headers/legend; the nested geographic viewport\n * keeps one fitted scale across zoom levels and clips only at the plot edges.\n */\nexport function responsiveMapSvg(svg: string, width: number, height: number, viewport: MapViewport): string {\n if (!svg.includes('class=\"stdlib-chart-map-viewport\"')) return svg;\n const zoomScale = 2 ** viewport.zoom;\n return svg\n .replace(/<text class=\"stdlib-chart-(title|subtitle|map-empty)\"[^>]*>/g, (tag) => {\n const centered = tag.replace(/x=\"[^\"]*\"/, 'x=\"50%\"');\n return tag.includes(\"map-empty\") ? centered.replace(/y=\"[^\"]*\"/, 'y=\"50%\"') : centered;\n })\n .replace(/^(<svg\\b[^>]*?) viewBox=\"[^\"]*\"/, \"$1\")\n .replace(/<svg class=\"stdlib-chart-map-viewport\"[^>]*>/, (tag) => {\n const mapWidth = Number(tag.match(/\\bwidth=\"([^\"]+)\"/)?.[1]);\n const mapHeight = Number(tag.match(/\\bheight=\"([^\"]+)\"/)?.[1]);\n const inverse = `calc(max(tan(atan2(${mapWidth}px, ${(mapWidth / width) * 100}cqw)), tan(atan2(${mapHeight}px, ${(mapHeight / height) * 100}cqh))) / ${zoomScale})`;\n const translateX = mapWidth / 2 - ((viewport.longitude + 180) / 360) * mapWidth * zoomScale;\n const translateY = mapHeight / 2 - ((90 - viewport.latitude) / 180) * mapHeight * zoomScale;\n return tag\n .replace(\n /\\b(x|y|width|height)=\"([\\d.]+)\"/g,\n (_match, name: string, value: string) =>\n `${name}=\"${(Number(value) / (name === \"x\" || name === \"width\" ? width : height)) * 100}%\"`,\n )\n .replace(\n \">\",\n ` preserveAspectRatio=\"xMidYMid meet\" style=\"--k2b-map-inverse-scale:${inverse}\"><g class=\"k2b-chart-map-camera\" transform=\"translate(${translateX} ${translateY}) scale(${zoomScale})\">`,\n );\n })\n .replace(\"</svg>\", \"</g></svg>\");\n}\n\n/** Adapt our generated SVGs to a CSS-sized box without rebuilding their geometry.\n * Only stdlib and the local timeline renderer supply this markup; this is not a\n * parser for arbitrary SVG. The viewBox remains the interaction coordinate space.\n */\nexport function responsiveChartSvg(svg: string): string {\n return svg.replace(\"<svg \", '<svg preserveAspectRatio=\"none\" ').replace(/<text\\b[^>]*>/g, (tag) => {\n const x = tag.match(/\\bx=\"(-?[\\d.]+)\"/)?.[1];\n const y = tag.match(/\\by=\"(-?[\\d.]+)\"/)?.[1];\n if (x === undefined || y === undefined) return tag;\n const rotation = tag.match(/\\btransform=\"rotate\\((-?[\\d.]+) [^\\\"]+\\)\"/)?.[1];\n // Individual CSS scale precedes rotation. Use the same text anchor as\n // transform-origin, and avoid applying the SVG rotation pivot twice.\n const origin = `transform-origin:${x}px ${y}px${rotation ? `;transform:rotate(${rotation}deg)` : \"\"}`;\n return tag.includes('style=\"')\n ? tag.replace(/style=\"([^\"]*)\"/, (_match, style: string) => `style=\"${style};${origin}\"`)\n : tag.replace(/>$/, ` style=\"${origin}\">`);\n });\n}\n\n/** Add initial controlled selection to our own renderer metadata during SSR. */\nexport function selectedChartSvg(\n svg: string,\n selected:\n | { role: string; index: number; seriesIndex?: number }\n | readonly { role: string; index: number; seriesIndex?: number }[]\n | null\n | undefined,\n): string {\n if (!selected) return svg;\n const targets = \"role\" in selected ? [selected] : selected;\n return svg.replace(/<g\\b[^>]*\\bdata-chart-datum=\"([^\"]*)\"[^>]*>/g, (attribute, encoded: string, offset: number) => {\n const raw = encoded\n .replace(/"/g, '\"')\n .replace(/'|'/g, \"'\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/&/g, \"&\");\n const value: unknown = JSON.parse(raw);\n if (typeof value !== \"object\" || value === null || !(\"role\" in value) || !(\"index\" in value)) return attribute;\n const matches = targets.find(\n (target) =>\n value.role === target.role &&\n value.index === target.index &&\n (\"seriesIndex\" in value ? value.seriesIndex : undefined) === target.seriesIndex,\n );\n if (!matches) return attribute;\n const children = svg.slice(offset, svg.indexOf(\"</g>\", offset));\n const palette = (Number(children.match(/stdlib-chart-series-(\\d+)/)?.[1] ?? matches.seriesIndex ?? 0) % 8) + 1;\n const paint = `--k2b-chart-selection-color:color-mix(in srgb
|
|
1
|
+
{"version":3,"names":[],"sources":["content/chart-svg.ts"],"sourcesContent":["import type { MapViewport } from \"../charts/core/svg\";\n\n/** Give maps a CSS-sized viewport while retaining the renderer's projection.\n * The outer SVG uses pixels for headers/legend; the nested geographic viewport\n * keeps one fitted scale across zoom levels and clips only at the plot edges.\n */\nexport function responsiveMapSvg(svg: string, width: number, height: number, viewport: MapViewport): string {\n if (!svg.includes('class=\"stdlib-chart-map-viewport\"')) return svg;\n const zoomScale = 2 ** viewport.zoom;\n return svg\n .replace(/<text class=\"stdlib-chart-(title|subtitle|map-empty)\"[^>]*>/g, (tag) => {\n const centered = tag.replace(/x=\"[^\"]*\"/, 'x=\"50%\"');\n return tag.includes(\"map-empty\") ? centered.replace(/y=\"[^\"]*\"/, 'y=\"50%\"') : centered;\n })\n .replace(/^(<svg\\b[^>]*?) viewBox=\"[^\"]*\"/, \"$1\")\n .replace(/<svg class=\"stdlib-chart-map-viewport\"[^>]*>/, (tag) => {\n const mapWidth = Number(tag.match(/\\bwidth=\"([^\"]+)\"/)?.[1]);\n const mapHeight = Number(tag.match(/\\bheight=\"([^\"]+)\"/)?.[1]);\n const inverse = `calc(max(tan(atan2(${mapWidth}px, ${(mapWidth / width) * 100}cqw)), tan(atan2(${mapHeight}px, ${(mapHeight / height) * 100}cqh))) / ${zoomScale})`;\n const translateX = mapWidth / 2 - ((viewport.longitude + 180) / 360) * mapWidth * zoomScale;\n const translateY = mapHeight / 2 - ((90 - viewport.latitude) / 180) * mapHeight * zoomScale;\n return tag\n .replace(\n /\\b(x|y|width|height)=\"([\\d.]+)\"/g,\n (_match, name: string, value: string) =>\n `${name}=\"${(Number(value) / (name === \"x\" || name === \"width\" ? width : height)) * 100}%\"`,\n )\n .replace(\n \">\",\n ` preserveAspectRatio=\"xMidYMid meet\" style=\"--k2b-map-inverse-scale:${inverse}\"><g class=\"k2b-chart-map-camera\" transform=\"translate(${translateX} ${translateY}) scale(${zoomScale})\">`,\n );\n })\n .replace(\"</svg>\", \"</g></svg>\");\n}\n\n/** Adapt our generated SVGs to a CSS-sized box without rebuilding their geometry.\n * Only stdlib and the local timeline renderer supply this markup; this is not a\n * parser for arbitrary SVG. The viewBox remains the interaction coordinate space.\n */\nexport function responsiveChartSvg(svg: string): string {\n return svg.replace(\"<svg \", '<svg preserveAspectRatio=\"none\" ').replace(/<text\\b[^>]*>/g, (tag) => {\n const x = tag.match(/\\bx=\"(-?[\\d.]+)\"/)?.[1];\n const y = tag.match(/\\by=\"(-?[\\d.]+)\"/)?.[1];\n if (x === undefined || y === undefined) return tag;\n const rotation = tag.match(/\\btransform=\"rotate\\((-?[\\d.]+) [^\\\"]+\\)\"/)?.[1];\n // Individual CSS scale precedes rotation. Use the same text anchor as\n // transform-origin, and avoid applying the SVG rotation pivot twice.\n const origin = `transform-origin:${x}px ${y}px${rotation ? `;transform:rotate(${rotation}deg)` : \"\"}`;\n return tag.includes('style=\"')\n ? tag.replace(/style=\"([^\"]*)\"/, (_match, style: string) => `style=\"${style};${origin}\"`)\n : tag.replace(/>$/, ` style=\"${origin}\">`);\n });\n}\n\n/** Add initial controlled selection to our own renderer metadata during SSR. */\nexport function selectedChartSvg(\n svg: string,\n selected:\n | { role: string; index: number; seriesIndex?: number }\n | readonly { role: string; index: number; seriesIndex?: number }[]\n | null\n | undefined,\n): string {\n if (!selected) return svg;\n const targets = \"role\" in selected ? [selected] : selected;\n return svg.replace(/<g\\b[^>]*\\bdata-chart-datum=\"([^\"]*)\"[^>]*>/g, (attribute, encoded: string, offset: number) => {\n const raw = encoded\n .replace(/"/g, '\"')\n .replace(/'|'/g, \"'\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/&/g, \"&\");\n const value: unknown = JSON.parse(raw);\n if (typeof value !== \"object\" || value === null || !(\"role\" in value) || !(\"index\" in value)) return attribute;\n const matches = targets.find(\n (target) =>\n value.role === target.role &&\n value.index === target.index &&\n (\"seriesIndex\" in value ? value.seriesIndex : undefined) === target.seriesIndex,\n );\n if (!matches) return attribute;\n const children = svg.slice(offset, svg.indexOf(\"</g>\", offset));\n const palette = (Number(children.match(/stdlib-chart-series-(\\d+)/)?.[1] ?? matches.seriesIndex ?? 0) % 8) + 1;\n const markPaint = children.match(/class=\"k2b-waterfall-bar\"[^>]* fill=\"([^\"]+)\"/)?.[1] ?? `var(--stdlib-chart-c${palette})`;\n const paint = `--k2b-chart-selection-color:color-mix(in srgb,${markPaint} 72%,var(--k2b-chart-highlight-mix))`;\n const opening = attribute.includes('style=\"')\n ? attribute.replace(/style=\"([^\"]*)\"/, (_match: string, style: string) => `style=\"${style};${paint}\"`)\n : attribute.replace(\">\", ` style=\"${paint}\">`);\n return opening.replace(\">\", \" data-selected>\");\n });\n}\n"],"mappings":"AAEA;AACA;AACA;AACA;AACA,OAAO,SAAS,gBAAgB,CAAC,GAAW,EAAE,KAAa,EAAE,MAAc,EAAE,QAAqB,EAAU;EAC1G,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,mCAAmC,CAAC,EAAE,OAAO,GAAG;EAClE,MAAM,SAAS,GAAG,CAAC,IAAI,QAAQ,CAAC,IAAI;EACpC,OAAO,GAAG,CACP,OAAO,CAAC,8DAA8D,EAAG,GAAG,IAAK;IAChF,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC;IACpD,OAAO,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,QAAQ;EACxF,CAAC,CAAC,CACD,OAAO,CAAC,iCAAiC,EAAE,IAAI,CAAC,CAChD,OAAO,CAAC,8CAA8C,EAAG,GAAG,IAAK;IAChE,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,MAAM,OAAO,GAAG,sBAAsB,QAAQ,OAAQ,QAAQ,GAAG,KAAK,GAAI,GAAG,oBAAoB,SAAS,OAAQ,SAAS,GAAG,MAAM,GAAI,GAAG,YAAY,SAAS,GAAG;IACnK,MAAM,UAAU,GAAG,QAAQ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AI,CAAC,OAAO,EAAE,OAAO,SAAS;IAC9B,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,2BAA2B,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC,GAAG,CAAC,GAAI,CAAC;IAC9G,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,+CAA+C,CAAC,GAAG,CAAC,CAAC,IAAI,uBAAuB,OAAO,GAAG;IAC3H,MAAM,KAAK,GAAG,iDAAiD,SAAS,sCAAsC;IAC9G,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,GACzC,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,MAAc,EAAE,KAAa,KAAK,UAAU,KAAK,IAAI,KAAK,GAAG,CAAC,GACpG,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;IAChD,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,iBAAiB,CAAC;EAChD,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -38,6 +38,7 @@ export { MARKDOWN_CALLOUT_CLASSES, MARKDOWN_CALLOUT_ICON_ATTRIBUTES, markdownInf
|
|
|
38
38
|
export { markdownLinkReference, markdownReferenceIcon, markdownReferenceType, markdownReferenceTypeLabel, markStandaloneLinks, renderMarkdownLink } from "./markdown-links";
|
|
39
39
|
export { Pagination } from "./Pagination";
|
|
40
40
|
export { default as PdfPreview } from "./PdfPreview";
|
|
41
|
+
export { default as PdfViewer } from "./PdfViewer";
|
|
41
42
|
export { default as RangePicker } from "./RangePicker";
|
|
42
43
|
export { ReactionBar } from "./ReactionBar";
|
|
43
44
|
export { REFERENCE_CHIP_MAX_CHARACTERS, ReferenceChip, truncateMiddle } from "./ReferenceChip";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["content/index.ts"],"sourcesContent":["export type { ChartDateFormat, ChartDatum, ChartDatumRole, ChartFormat, ChartNumberFormat } from \"../charts/core\";\nexport { BalanceSummary, type BalanceSummaryProps } from \"./BalanceSummary\";\nexport type {\n CalendarAttendee,\n CalendarCommand,\n CalendarController,\n CalendarCustomView,\n CalendarDayBadge,\n CalendarEvent,\n CalendarEventColor,\n CalendarEventLink,\n CalendarEventRenderContext,\n CalendarEventTimeChange,\n CalendarExternalDrag,\n CalendarLabels,\n CalendarProps,\n CalendarQuickCreateControls,\n CalendarRange,\n CalendarRecurrence,\n CalendarResource,\n CalendarSelectionControls,\n CalendarView,\n} from \"./Calendar\";\nexport { default as Calendar } from \"./Calendar\";\n\nexport type { ChartKind, ChartKindProps, ChartLabels, ChartProps, ChartRenderOptions } from \"./Chart\";\nexport { default as Chart } from \"./Chart\";\nexport type { ChartExplorerColumn, ChartExplorerProps, ChartFrameRequest, ChartLegendEntry } from \"./ChartExplorer\";\nexport { ChartExplorer } from \"./ChartExplorer\";\nexport type { ChartExplorerControlsProps } from \"./ChartExplorerControls\";\nexport { ChartExplorerControls } from \"./ChartExplorerControls\";\nexport { ChartFilterControls, type ChartFilterControlsProps } from \"./ChartFilterControls\";\nexport { ChartSnapshotView } from \"./ChartSnapshotView\";\nexport type { CodeDisplayLanguage, CodeDisplayProps } from \"./CodeDisplay\";\nexport { default as CodeDisplay } from \"./CodeDisplay\";\nexport { type ChartCursor, createChartCursor } from \"./chart-cursor\";\nexport type {\n ChartExplorerCharts,\n ChartExplorerController,\n ChartExplorerData,\n ChartExplorerOptions,\n ChartExplorerRequest,\n ChartExplorerRow,\n ChartExplorerSnapshot,\n} from \"./chart-explorer\";\nexport { createChartExplorer } from \"./chart-explorer\";\nexport type { ChartDatumRef, ChartSelection, ChartTooltip, ChartTooltipFormatter } from \"./chart-inspection-core\";\nexport type { ChartSnapshot } from \"./chart-snapshot\";\nexport { prepareChartSnapshot } from \"./chart-snapshot\";\nexport type {\n StateTimelineChartOptions,\n StateTimelineDomain,\n StateTimelineInterval,\n StateTimelineRow,\n StateTimelineState,\n} from \"./chart-state-timeline\";\nexport type { ChartTimeAxis } from \"./chart-time-axis\";\nexport { highlightSql } from \"./code-highlight\";\nexport { type CollectionSelection, createCollectionSelection, type SelectionModifiers } from \"./collection-selection\";\nexport type {\n DataTableColumn,\n DataTableControlsProps,\n DataTableFooter,\n DataTableHeaderProps,\n DataTablePanelFooterProps,\n DataTablePanelProps,\n DataTableProps,\n DataTableRenderCell,\n DataTableRenderHeader,\n DataTableSort,\n} from \"./DataTable\";\nexport { default as DataTable } from \"./DataTable\";\nexport type { DataTableToolsProps, DataTableView, DataTableViewOptions } from \"./DataTableTools\";\nexport { createDataTableView, DataTableTools } from \"./DataTableTools\";\nexport type { DocCodeHighlighter, DocCodeProps, DocConcept, DocNoteVariant, DocRow } from \"./Docs\";\nexport { DocCode, DocConceptGrid, DocInlineCode, DocLead, DocNote, DocPage, DocRows, DocSection } from \"./Docs\";\nexport type {\n DataTableColumnType,\n DataTableNumberFormat,\n DataTableStatusState,\n DataTableTypedColumn,\n} from \"./data-table-columns\";\nexport { filterRows, sortRows } from \"./data-table-columns\";\nexport { FileBrowserPanel, type FileBrowserPanelProps, type FileSource, openFileBrowser } from \"./FileBrowser\";\nexport { FileGrid, type FileGridGroup, type FileGridOpenProps, type FileGridProps, type FileGridSelectableProps } from \"./FileGrid\";\nexport { default as FileTree, type FileTreeActions, type FileTreeEntry, type FileTreeProps } from \"./FileTree\";\nexport { type FileType, FileTypeIcon, type FileTypeIconProps, fileKindLabel, fileTypeOf } from \"./FileTypeIcon\";\nexport {\n canPreviewFile,\n default as FileView,\n type FileViewContent,\n type FileViewFile,\n type FileViewPreviewKind,\n type FileViewProps,\n type FileViewRenderer,\n type FileViewRendererProps,\n formatFileViewSize,\n getFileViewPreviewKind,\n} from \"./FileView\";\nexport { FlowAmount, type FlowAmountDirection, type FlowAmountProps, flowDirection } from \"./FlowAmount\";\nexport type { KbdProps } from \"./Kbd\";\nexport { Kbd } from \"./Kbd\";\nexport type { LabelChipProps } from \"./LabelChip\";\nexport { LabelChip } from \"./LabelChip\";\nexport type { LightboxAction, LightboxImage } from \"./Lightbox\";\nexport { default as Lightbox } from \"./Lightbox\";\nexport type { LogTableEntry } from \"./LogEntriesTable\";\nexport { default as LogEntriesTable } from \"./LogEntriesTable\";\nexport { MapAttribution } from \"./MapAttribution\";\nexport { MapView } from \"./MapView\";\nexport { MapViewFrame } from \"./MapViewFrame\";\nexport { default as MarkdownView, type MarkdownRenderOptions, type MarkdownViewProps, renderSafeMarkdown } from \"./MarkdownView\";\nexport { type MatchRange, MatchText, type MatchTextProps, matchParts } from \"./MatchText\";\nexport type {\n MessageEventGroupProps,\n MessageEventRowProps,\n MessageGroupEntry,\n MessageRowAction,\n MessageRowAttachment,\n MessageRowAuthor,\n MessageRowFile,\n MessageRowMedia,\n MessageRowOrigin,\n MessageRowProgress,\n MessageRowProps,\n MessageRowQuote,\n MessageRowReaction,\n MessageRowStatus,\n MessageRowThread,\n MessageSystemRowProps,\n} from \"./MessageRow\";\nexport { MessageEventGroup, MessageEventRow, MessageRow, MessageSystemRow, startsMessageGroup } from \"./MessageRow\";\nexport { type MapPaletteColors, type MapTheme, mapPalette } from \"./map-palette\";\nexport { type MapStyleOptions, mapAttribution, mapStyle } from \"./map-style\";\nexport { MAP_SNAPSHOT_MAX_PIXELS, MapSnapshotError, type MapSnapshotErrorCode } from \"./map-view-snapshot\";\nexport type {\n MapViewArea,\n MapViewFit,\n MapViewFrameProps,\n MapViewHandle,\n MapViewLine,\n MapViewLineTone,\n MapViewMarker,\n MapViewOwnLocation,\n MapViewPoint,\n MapViewProps,\n MapViewSnapshot,\n MapViewSnapshotOptions,\n MapViewStyle,\n MapViewStyleSource,\n MapViewTone,\n} from \"./map-view-types\";\nexport {\n MARKDOWN_CALLOUT_CLASSES,\n MARKDOWN_CALLOUT_ICON_ATTRIBUTES,\n type MarkdownInfoBlock,\n type MarkdownInfoBlockRenderInput,\n type MarkdownInfoBlockType,\n markdownInfoBlocks,\n renderMarkdownInfoBlock,\n scanMarkdownInfoBlock,\n} from \"./markdown-info-blocks\";\nexport {\n type MarkdownLinkInput,\n type MarkdownReference,\n type MarkdownReferenceKind,\n type MarkdownReferenceType,\n markdownLinkReference,\n markdownReferenceIcon,\n markdownReferenceType,\n markdownReferenceTypeLabel,\n markStandaloneLinks,\n renderMarkdownLink,\n} from \"./markdown-links\";\nexport { Pagination, type PaginationProps } from \"./Pagination\";\nexport type { PdfPreviewProps, PdfPreviewRequest } from \"./PdfPreview\";\nexport { default as PdfPreview } from \"./PdfPreview\";\nexport type { RangeOption, RangePickerProps } from \"./RangePicker\";\nexport { default as RangePicker } from \"./RangePicker\";\nexport { ReactionBar, type ReactionBarItem, type ReactionBarProps } from \"./ReactionBar\";\nexport type {\n ReferenceChipObjectProps,\n ReferenceChipPersonProps,\n ReferenceChipProps,\n ReferenceChipTimeProps,\n} from \"./ReferenceChip\";\nexport { REFERENCE_CHIP_MAX_CHARACTERS, ReferenceChip, truncateMiddle } from \"./ReferenceChip\";\nexport type { StepsProps } from \"./Steps\";\nexport { Steps } from \"./Steps\";\nexport type { StructuredDataPreviewMode, StructuredDataPreviewProps, StructuredDataValue } from \"./StructuredDataPreview\";\nexport { default as StructuredDataPreview, isStructuredDataValue } from \"./StructuredDataPreview\";\nexport type { TimelineColor, TimelineController, TimelineItem, TimelineProps } from \"./Timeline\";\nexport { default as Timeline } from \"./Timeline\";\nexport { VideoPlayer, type VideoPlayerProps } from \"./VideoPlayer\";\nexport type { VirtualFeedController, VirtualFeedProps, VirtualFeedScrollOptions } from \"./VirtualFeed\";\nexport { VirtualFeed } from \"./VirtualFeed\";\nexport type { ZoomPanAction, ZoomPanFullscreen, ZoomPanViewportProps } from \"./ZoomPanViewport\";\nexport { ZoomPanViewport } from \"./ZoomPanVi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AAQ,mBAAmB;AAC9D,SAAS,cAAc,QAAQ,kBAAkB;AACjD,SAAS,OAAO,QAAQ,WAAW;AACnC,SAAS,YAAY,QAAQ,gBAAgB;AAC7C,SAAS,OAAO,IAAI,YAAY,EAAsD,kBAAkB,QAAQ,gBAAgB;AAChI,SAA0B,SAAS,EAAuB,UAAU,QAAQ,aAAa;AAmBzF,SAAS,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,QAAQ,cAAc;AACnH,SAA+C,UAAU,QAAQ,eAAe;AAChF,SAA+B,cAAc,EAAE,QAAQ,QAAQ,aAAa;AAC5E,SAAS,uBAAuB,EAAE,gBAAgB,QAAmC,qBAAqB;AAkB1G,SACE,wBAAwB,EACxB,gCAAgC,EAIhC,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,QAChB,wBAAwB;AAC/B,SAKE,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,QACb,kBAAkB;AACzB,SAAS,UAAU,QAA8B,cAAc;AAE/D,SAAS,OAAO,IAAI,UAAU,QAAQ,cAAc;AAEpD,SAAS,OAAO,IAAI,WAAW,QAAQ,eAAe;AACtD,SAAS,WAAW,QAAqD,eAAe;AAOxF,SAAS,6BAA6B,EAAE,aAAa,EAAE,cAAc,QAAQ,iBAAiB;AAE9F,SAAS,KAAK,QAAQ,SAAS;AAE/B,SAAS,OAAO,IAAI,qBAAqB,EAAE,qBAAqB,QAAQ,yBAAyB;AAEjG,SAAS,OAAO,IAAI,QAAQ,QAAQ,YAAY;AAChD,SAAS,WAAW,QAA+B,eAAe;AAElE,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,eAAe,QAAQ,mBAAmB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["content/index.ts"],"sourcesContent":["export type { ChartDateFormat, ChartDatum, ChartDatumRole, ChartFormat, ChartNumberFormat } from \"../charts/core\";\nexport { BalanceSummary, type BalanceSummaryProps } from \"./BalanceSummary\";\nexport type {\n CalendarAttendee,\n CalendarCommand,\n CalendarController,\n CalendarCustomView,\n CalendarDayBadge,\n CalendarEvent,\n CalendarEventColor,\n CalendarEventLink,\n CalendarEventRenderContext,\n CalendarEventTimeChange,\n CalendarExternalDrag,\n CalendarLabels,\n CalendarProps,\n CalendarQuickCreateControls,\n CalendarRange,\n CalendarRecurrence,\n CalendarResource,\n CalendarSelectionControls,\n CalendarView,\n} from \"./Calendar\";\nexport { default as Calendar } from \"./Calendar\";\n\nexport type { ChartKind, ChartKindProps, ChartLabels, ChartProps, ChartRenderOptions } from \"./Chart\";\nexport { default as Chart } from \"./Chart\";\nexport type { ChartExplorerColumn, ChartExplorerProps, ChartFrameRequest, ChartLegendEntry } from \"./ChartExplorer\";\nexport { ChartExplorer } from \"./ChartExplorer\";\nexport type { ChartExplorerControlsProps } from \"./ChartExplorerControls\";\nexport { ChartExplorerControls } from \"./ChartExplorerControls\";\nexport { ChartFilterControls, type ChartFilterControlsProps } from \"./ChartFilterControls\";\nexport { ChartSnapshotView } from \"./ChartSnapshotView\";\nexport type { CodeDisplayLanguage, CodeDisplayProps } from \"./CodeDisplay\";\nexport { default as CodeDisplay } from \"./CodeDisplay\";\nexport { type ChartCursor, createChartCursor } from \"./chart-cursor\";\nexport type {\n ChartExplorerCharts,\n ChartExplorerController,\n ChartExplorerData,\n ChartExplorerOptions,\n ChartExplorerRequest,\n ChartExplorerRow,\n ChartExplorerSnapshot,\n} from \"./chart-explorer\";\nexport { createChartExplorer } from \"./chart-explorer\";\nexport type { ChartDatumRef, ChartSelection, ChartTooltip, ChartTooltipFormatter } from \"./chart-inspection-core\";\nexport type { ChartSnapshot } from \"./chart-snapshot\";\nexport { prepareChartSnapshot } from \"./chart-snapshot\";\nexport type {\n StateTimelineChartOptions,\n StateTimelineDomain,\n StateTimelineInterval,\n StateTimelineRow,\n StateTimelineState,\n} from \"./chart-state-timeline\";\nexport type { ChartTimeAxis } from \"./chart-time-axis\";\nexport { highlightSql } from \"./code-highlight\";\nexport { type CollectionSelection, createCollectionSelection, type SelectionModifiers } from \"./collection-selection\";\nexport type {\n DataTableColumn,\n DataTableControlsProps,\n DataTableFooter,\n DataTableHeaderProps,\n DataTablePanelFooterProps,\n DataTablePanelProps,\n DataTableProps,\n DataTableRenderCell,\n DataTableRenderHeader,\n DataTableSort,\n} from \"./DataTable\";\nexport { default as DataTable } from \"./DataTable\";\nexport type { DataTableToolsProps, DataTableView, DataTableViewOptions } from \"./DataTableTools\";\nexport { createDataTableView, DataTableTools } from \"./DataTableTools\";\nexport type { DocCodeHighlighter, DocCodeProps, DocConcept, DocNoteVariant, DocRow } from \"./Docs\";\nexport { DocCode, DocConceptGrid, DocInlineCode, DocLead, DocNote, DocPage, DocRows, DocSection } from \"./Docs\";\nexport type {\n DataTableColumnType,\n DataTableNumberFormat,\n DataTableStatusState,\n DataTableTypedColumn,\n} from \"./data-table-columns\";\nexport { filterRows, sortRows } from \"./data-table-columns\";\nexport { FileBrowserPanel, type FileBrowserPanelProps, type FileSource, openFileBrowser } from \"./FileBrowser\";\nexport { FileGrid, type FileGridGroup, type FileGridOpenProps, type FileGridProps, type FileGridSelectableProps } from \"./FileGrid\";\nexport { default as FileTree, type FileTreeActions, type FileTreeEntry, type FileTreeProps } from \"./FileTree\";\nexport { type FileType, FileTypeIcon, type FileTypeIconProps, fileKindLabel, fileTypeOf } from \"./FileTypeIcon\";\nexport {\n canPreviewFile,\n default as FileView,\n type FileViewContent,\n type FileViewFile,\n type FileViewPreviewKind,\n type FileViewProps,\n type FileViewRenderer,\n type FileViewRendererProps,\n formatFileViewSize,\n getFileViewPreviewKind,\n} from \"./FileView\";\nexport { FlowAmount, type FlowAmountDirection, type FlowAmountProps, flowDirection } from \"./FlowAmount\";\nexport type { KbdProps } from \"./Kbd\";\nexport { Kbd } from \"./Kbd\";\nexport type { LabelChipProps } from \"./LabelChip\";\nexport { LabelChip } from \"./LabelChip\";\nexport type { LightboxAction, LightboxImage } from \"./Lightbox\";\nexport { default as Lightbox } from \"./Lightbox\";\nexport type { LogTableEntry } from \"./LogEntriesTable\";\nexport { default as LogEntriesTable } from \"./LogEntriesTable\";\nexport { MapAttribution } from \"./MapAttribution\";\nexport { MapView } from \"./MapView\";\nexport { MapViewFrame } from \"./MapViewFrame\";\nexport { default as MarkdownView, type MarkdownRenderOptions, type MarkdownViewProps, renderSafeMarkdown } from \"./MarkdownView\";\nexport { type MatchRange, MatchText, type MatchTextProps, matchParts } from \"./MatchText\";\nexport type {\n MessageEventGroupProps,\n MessageEventRowProps,\n MessageGroupEntry,\n MessageRowAction,\n MessageRowAttachment,\n MessageRowAuthor,\n MessageRowFile,\n MessageRowMedia,\n MessageRowOrigin,\n MessageRowProgress,\n MessageRowProps,\n MessageRowQuote,\n MessageRowReaction,\n MessageRowStatus,\n MessageRowThread,\n MessageSystemRowProps,\n} from \"./MessageRow\";\nexport { MessageEventGroup, MessageEventRow, MessageRow, MessageSystemRow, startsMessageGroup } from \"./MessageRow\";\nexport { type MapPaletteColors, type MapTheme, mapPalette } from \"./map-palette\";\nexport { type MapStyleOptions, mapAttribution, mapStyle } from \"./map-style\";\nexport { MAP_SNAPSHOT_MAX_PIXELS, MapSnapshotError, type MapSnapshotErrorCode } from \"./map-view-snapshot\";\nexport type {\n MapViewArea,\n MapViewFit,\n MapViewFrameProps,\n MapViewHandle,\n MapViewLine,\n MapViewLineTone,\n MapViewMarker,\n MapViewOwnLocation,\n MapViewPoint,\n MapViewProps,\n MapViewSnapshot,\n MapViewSnapshotOptions,\n MapViewStyle,\n MapViewStyleSource,\n MapViewTone,\n} from \"./map-view-types\";\nexport {\n MARKDOWN_CALLOUT_CLASSES,\n MARKDOWN_CALLOUT_ICON_ATTRIBUTES,\n type MarkdownInfoBlock,\n type MarkdownInfoBlockRenderInput,\n type MarkdownInfoBlockType,\n markdownInfoBlocks,\n renderMarkdownInfoBlock,\n scanMarkdownInfoBlock,\n} from \"./markdown-info-blocks\";\nexport {\n type MarkdownLinkInput,\n type MarkdownReference,\n type MarkdownReferenceKind,\n type MarkdownReferenceType,\n markdownLinkReference,\n markdownReferenceIcon,\n markdownReferenceType,\n markdownReferenceTypeLabel,\n markStandaloneLinks,\n renderMarkdownLink,\n} from \"./markdown-links\";\nexport { Pagination, type PaginationProps } from \"./Pagination\";\nexport type { PdfPreviewProps, PdfPreviewRequest } from \"./PdfPreview\";\nexport { default as PdfPreview } from \"./PdfPreview\";\nexport type { PdfViewerProps } from \"./PdfViewer\";\nexport { default as PdfViewer } from \"./PdfViewer\";\nexport type { RangeOption, RangePickerProps } from \"./RangePicker\";\nexport { default as RangePicker } from \"./RangePicker\";\nexport { ReactionBar, type ReactionBarItem, type ReactionBarProps } from \"./ReactionBar\";\nexport type {\n ReferenceChipObjectProps,\n ReferenceChipPersonProps,\n ReferenceChipProps,\n ReferenceChipTimeProps,\n} from \"./ReferenceChip\";\nexport { REFERENCE_CHIP_MAX_CHARACTERS, ReferenceChip, truncateMiddle } from \"./ReferenceChip\";\nexport type { StepsProps } from \"./Steps\";\nexport { Steps } from \"./Steps\";\nexport type { StructuredDataPreviewMode, StructuredDataPreviewProps, StructuredDataValue } from \"./StructuredDataPreview\";\nexport { default as StructuredDataPreview, isStructuredDataValue } from \"./StructuredDataPreview\";\nexport type { TimelineColor, TimelineController, TimelineItem, TimelineProps } from \"./Timeline\";\nexport { default as Timeline } from \"./Timeline\";\nexport { VideoPlayer, type VideoPlayerProps } from \"./VideoPlayer\";\nexport type { VirtualFeedController, VirtualFeedProps, VirtualFeedScrollOptions } from \"./VirtualFeed\";\nexport { VirtualFeed } from \"./VirtualFeed\";\nexport type { ZoomPanAction, ZoomPanFullscreen, ZoomPanViewportProps } from \"./ZoomPanViewport\";\nexport { ZoomPanViewport } from \"./ZoomPanViewport\";\n"],"mappings":"AACA,SAAS,cAAc,QAAkC,kBAAkB;AAsB3E,SAAS,OAAO,IAAI,QAAQ,QAAQ,YAAY;AAGhD,SAAS,OA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B;AAC7C,SAAS,OAAO,IAAI,YAAY,EAAsD,kBAAkB,QAAQ,gBAAgB;AAChI,SAA0B,SAAS,EAAuB,UAAU,QAAQ,aAAa;AAmBzF,SAAS,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,QAAQ,cAAc;AACnH,SAA+C,UAAU,QAAQ,eAAe;AAChF,SAA+B,cAAc,EAAE,QAAQ,QAAQ,aAAa;AAC5E,SAAS,uBAAuB,EAAE,gBAAgB,QAAmC,qBAAqB;AAkB1G,SACE,wBAAwB,EACxB,gCAAgC,EAIhC,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,QAChB,wBAAwB;AAC/B,SAKE,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,QACb,kBAAkB;AACzB,SAAS,UAAU,QAA8B,cAAc;AAE/D,SAAS,OAAO,IAAI,UAAU,QAAQ,cAAc;AAEpD,SAAS,OAAO,IAAI,SAAS,QAAQ,aAAa;AAElD,SAAS,OAAO,IAAI,WAAW,QAAQ,eAAe;AACtD,SAAS,WAAW,QAAqD,eAAe;AAOxF,SAAS,6BAA6B,EAAE,aAAa,EAAE,cAAc,QAAQ,iBAAiB;AAE9F,SAAS,KAAK,QAAQ,SAAS;AAE/B,SAAS,OAAO,IAAI,qBAAqB,EAAE,qBAAqB,QAAQ,yBAAyB;AAEjG,SAAS,OAAO,IAAI,QAAQ,QAAQ,YAAY;AAChD,SAAS,WAAW,QAA+B,eAAe;AAElE,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,eAAe,QAAQ,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the PDF engine behind `PdfViewer`. The engine is pdf.js with a little glue, bundled once by the @k2b/ui build
|
|
3
|
+
* into its own module next to the pdf.js worker. A host's bundler copies both as files and never bundles pdf.js
|
|
4
|
+
* itself, so no page or script carries it until a document opens.
|
|
5
|
+
*/
|
|
6
|
+
/// <reference path="./pdf-worker.d.ts" />
|
|
7
|
+
// The build points these at its prebuilt `pdf-viewer-engine.js` and the worker copy `pdf-viewer-worker.js`.
|
|
8
|
+
const workerUrl = "";
|
|
9
|
+
// @ts-expect-error TypeScript reads a `type: "file"` import as a module import; the engine module has no default export.
|
|
10
|
+
const engineUrl = "";
|
|
11
|
+
import { PDF_LIMITS, pdfTooLarge } from "./pdf-limits";
|
|
12
|
+
export { PDF_LIMITS, PDF_TOO_LARGE, pageImageWidth } from "./pdf-limits";
|
|
13
|
+
const isEngine = value => typeof value === "object" && value !== null && typeof Reflect.get(value, "openPdf") === "function";
|
|
14
|
+
|
|
15
|
+
/** Opens a PDF; `null` after an abort. Throws `PDF_TOO_LARGE` past `PDF_LIMITS`, or pdf.js's error for a broken file. */
|
|
16
|
+
export const openPdfDocument = async (data, signal) => {
|
|
17
|
+
const size = data instanceof Blob ? data.size : data.byteLength;
|
|
18
|
+
if (size > PDF_LIMITS.maxBytes) throw pdfTooLarge(`PDF is larger than ${PDF_LIMITS.maxBytes} bytes`);
|
|
19
|
+
// pdf.js hands its bytes to the worker, which detaches them: a caller's ArrayBuffer stays theirs as a copy.
|
|
20
|
+
const bytes = data instanceof Blob ? await data.arrayBuffer() : data.slice(0);
|
|
21
|
+
if (signal.aborted) return null;
|
|
22
|
+
// A relative address resolves against this module, where the bundler put the engine file.
|
|
23
|
+
const engine = await import(/* @vite-ignore */engineUrl);
|
|
24
|
+
if (!isEngine(engine)) throw new Error("The PDF engine could not be loaded");
|
|
25
|
+
// Closed while the engine loaded: parse nothing.
|
|
26
|
+
if (signal.aborted) return null;
|
|
27
|
+
return engine.openPdf(bytes, signal, workerUrl);
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=pdf-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["content/pdf-document.ts"],"sourcesContent":["/**\n * Loads the PDF engine behind `PdfViewer`. The engine is pdf.js with a little glue, bundled once by the @k2b/ui build\n * into its own module next to the pdf.js worker. A host's bundler copies both as files and never bundles pdf.js\n * itself, so no page or script carries it until a document opens.\n */\n/// <reference path=\"./pdf-worker.d.ts\" />\n// The build points these at its prebuilt `pdf-viewer-engine.js` and the worker copy `pdf-viewer-worker.js`.\nimport workerUrl from \"pdfjs-dist/legacy/build/pdf.worker.min.mjs\" with { type: \"file\" };\n// @ts-expect-error TypeScript reads a `type: \"file\"` import as a module import; the engine module has no default export.\nimport engineUrl from \"./pdf-engine.ts\" with { type: \"file\" };\nimport { PDF_LIMITS, type PdfDocumentHandle, pdfTooLarge } from \"./pdf-limits\";\n\nexport type { PdfDocumentHandle, PdfPageImage, PdfPageSize } from \"./pdf-limits\";\nexport { PDF_LIMITS, PDF_TOO_LARGE, pageImageWidth } from \"./pdf-limits\";\n\ntype PdfEngine = {\n openPdf: (data: ArrayBuffer, signal: AbortSignal, workerUrl: string) => Promise<PdfDocumentHandle | null>;\n};\n\nconst isEngine = (value: unknown): value is PdfEngine =>\n typeof value === \"object\" && value !== null && typeof Reflect.get(value, \"openPdf\") === \"function\";\n\n/** Opens a PDF; `null` after an abort. Throws `PDF_TOO_LARGE` past `PDF_LIMITS`, or pdf.js's error for a broken file. */\nexport const openPdfDocument = async (data: Blob | ArrayBuffer, signal: AbortSignal): Promise<PdfDocumentHandle | null> => {\n const size = data instanceof Blob ? data.size : data.byteLength;\n if (size > PDF_LIMITS.maxBytes) throw pdfTooLarge(`PDF is larger than ${PDF_LIMITS.maxBytes} bytes`);\n // pdf.js hands its bytes to the worker, which detaches them: a caller's ArrayBuffer stays theirs as a copy.\n const bytes = data instanceof Blob ? await data.arrayBuffer() : data.slice(0);\n if (signal.aborted) return null;\n // A relative address resolves against this module, where the bundler put the engine file.\n const engine: unknown = await import(/* @vite-ignore */ engineUrl);\n if (!isEngine(engine)) throw new Error(\"The PDF engine could not be loaded\");\n // Closed while the engine loaded: parse nothing.\n if (signal.a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0,0 +1,31 @@
|
|
|
1
|
+
/** Shapes and bounds shared by `PdfViewer`, its loader, and the pdf.js engine. */
|
|
2
|
+
|
|
3
|
+
/** A page's size in PDF points at scale 1. */
|
|
4
|
+
|
|
5
|
+
/** One drawn page: an object URL the caller revokes, and its size in pixels. */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Bounds for one document. Bytes and pages bound parsing work and memory; a larger document falls back to the
|
|
9
|
+
* browser's own viewer. Canvas pixels stay below the size Safari still draws (larger canvases come out blank).
|
|
10
|
+
*/
|
|
11
|
+
export const PDF_LIMITS = {
|
|
12
|
+
maxBytes: 100 * 1024 * 1024,
|
|
13
|
+
maxPages: 2000,
|
|
14
|
+
maxCanvasPixels: 16_000_000,
|
|
15
|
+
maxImageWidth: 4096
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** The name of the error a document past `PDF_LIMITS` raises; the host shows the browser's viewer instead. */
|
|
19
|
+
export const PDF_TOO_LARGE = "PdfTooLargeError";
|
|
20
|
+
export const pdfTooLarge = message => Object.assign(new Error(message), {
|
|
21
|
+
name: PDF_TOO_LARGE
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Pixel width for a page image shown `displayWidth` CSS pixels wide: display width times the device pixel ratio
|
|
26
|
+
* (at most 2), at least 400 px where the page allows it, at most `PDF_LIMITS.maxImageWidth`, and always small enough
|
|
27
|
+
* that the canvas stays under `PDF_LIMITS.maxCanvasPixels` for the page's height-to-width `ratio`, also for a very
|
|
28
|
+
* tall page. Very deep zoom turns slightly soft, never blank.
|
|
29
|
+
*/
|
|
30
|
+
export const pageImageWidth = (displayWidth, pixelRatio, ratio) => Math.max(1, Math.floor(Math.min(Math.max(400, displayWidth * Math.min(Math.max(pixelRatio, 1), 2)), PDF_LIMITS.maxImageWidth, Math.sqrt(PDF_LIMITS.maxCanvasPixels / Math.max(ratio, 0.1)))));
|
|
31
|
+
//# sourceMappingURL=pdf-limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["content/pdf-limits.ts"],"sourcesContent":["/** Shapes and bounds shared by `PdfViewer`, its loader, and the pdf.js engine. */\n\n/** A page's size in PDF points at scale 1. */\nexport type PdfPageSize = { width: number; height: number };\n\n/** One drawn page: an object URL the caller revokes, and its size in pixels. */\nexport type PdfPageImage = { url: string; width: number; height: number };\n\nexport type PdfDocumentHandle = {\n pages: readonly PdfPageSize[];\n /** Draws one page `widthPx` wide; `null` after an abort. The caller revokes the returned URL. */\n draw: (index: number, widthPx: number, signal: AbortSignal) => Promise<PdfPageImage | null>;\n /**\n * Lays the selectable, searchable text of one page into `container`. Positions are relative to the page; the font\n * follows `--total-scale-factor` (CSS pixels per point) on the container or above, so zoom changes only that value.\n */\n textLayer: (index: number, container: HTMLElement, signal: AbortSignal) => Promise<void>;\n close: () => Promise<void>;\n};\n\n/**\n * Bounds for one document. Bytes and pages bound parsing work and memory; a larger document falls back to the\n * browser's own viewer. Canvas pixels stay below the size Safari still draws (larger canvases come out blank).\n */\nexport const PDF_LIMITS = {\n maxBytes: 100 * 1024 * 1024,\n maxPages: 2000,\n maxCanvasPixels: 16_000_000,\n maxImageWidth: 4096,\n} as const;\n\n/** The name of the error a document past `PDF_LIMITS` raises; the host shows the browser's viewer instead. */\nexport const PDF_TOO_LARGE = \"PdfTooLargeError\";\n\nexport const pdfTooLarge = (message: string): Error => Object.assign(new Error(message), { name: PDF_TOO_LARGE });\n\n/**\n * Pixel width for a page image shown `displayWidth` CSS pixels wide: display width times the device pixel ratio\n * (at most 2), at least 400 px where the page allows it, at most `PDF_LIMITS.maxImageWidth`, and always small enough\n * that the canvas stays under `PDF_LIMITS.maxCanvasPixels` for the page's height-to-width `ratio`, also for a very\n * tall page. Very deep zoom turns slightly soft, never blank.\n */\nexport const pageImageWidth = (displayWidth: number, pixelRatio: number, ratio: number): number =>\n Math.max(\n 1,\n Math.floor(\n Math.min(\n Math.max(400, displayWidth * Math.min(Math.max(pixelRatio, 1), 2)),\n PDF_LIMITS.maxImageWidth,\n Math.sqrt(PDF_LIMITS.maxCanvasPixels / Math.max(ratio, 0.1)),\n ),\n ),\n );\n"],"mappings":"AAAA;;AAEA;;AAGA;;AAeA;AACA;AACA;AACA;AACA,OAAO,MAAM,UAAU,GAAG;EACxB,QAAQ,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;EAC3B,QAAQ,EAAE,IAAI;EACd,eAAe,EAAE,UAAU;EAC3B,aAAa,EAAE;AACjB,CAAU;;AAEV;AACA,OAAO,MAAM,aAAa,GAAG,kBAAkB;AAE/C,OAAO,MAAM,WAAW,GAAI,OAAe,IAAY,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE;EAAE,IAAI,EAAE;AAAc,CAAC,CAAC;;AAEjH;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM,cAAc,GAAG,CAAC,YAAoB,EAAE,UAAkB,EAAE,KAAa,KACpF,IAAI,CAAC,GAAG,CACN,CAAC,EACD,IAAI,CAAC,KAAK,CACR,IAAI,CAAC,GAAG,CACN,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAClE,UAAU,CAAC,aAAa,EACxB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAC7D,CACF,CACF,CAAC","ignoreList":[]}
|
|
@@ -14,7 +14,23 @@ const pdfMessages = i18n.define({
|
|
|
14
14
|
pdfPreviewNoViewerDescription: "Your browser cannot show PDFs inside a page. Open the document to view it.",
|
|
15
15
|
pdfPreviewRendering: "Rendering PDF preview…",
|
|
16
16
|
previewPdf: "Preview PDF",
|
|
17
|
-
renderPdfPreview: "Render a PDF preview to see the final output."
|
|
17
|
+
renderPdfPreview: "Render a PDF preview to see the final output.",
|
|
18
|
+
pdfPage: ({
|
|
19
|
+
number,
|
|
20
|
+
total
|
|
21
|
+
}) => `Page ${number} of ${total}`,
|
|
22
|
+
pdfPageShort: ({
|
|
23
|
+
number,
|
|
24
|
+
total
|
|
25
|
+
}) => `${number} / ${total}`,
|
|
26
|
+
pdfZoom: "Zoom",
|
|
27
|
+
pdfZoomOut: "Zoom out",
|
|
28
|
+
pdfZoomIn: "Zoom in",
|
|
29
|
+
pdfZoomPercent: ({
|
|
30
|
+
value
|
|
31
|
+
}) => `${value}%`,
|
|
32
|
+
pdfFitWidth: "Width",
|
|
33
|
+
pdfFitWidthLabel: "Fit to width"
|
|
18
34
|
},
|
|
19
35
|
de: {
|
|
20
36
|
openPreview: "Vorschau öffnen",
|
|
@@ -27,7 +43,23 @@ const pdfMessages = i18n.define({
|
|
|
27
43
|
pdfPreviewNoViewerDescription: "Dein Browser kann PDFs nicht innerhalb einer Seite anzeigen. Öffne das Dokument, um es anzusehen.",
|
|
28
44
|
pdfPreviewRendering: "PDF-Vorschau wird erstellt…",
|
|
29
45
|
previewPdf: "PDF anzeigen",
|
|
30
|
-
renderPdfPreview: "Erzeuge eine PDF-Vorschau, um das Endergebnis zu sehen."
|
|
46
|
+
renderPdfPreview: "Erzeuge eine PDF-Vorschau, um das Endergebnis zu sehen.",
|
|
47
|
+
pdfPage: ({
|
|
48
|
+
number,
|
|
49
|
+
total
|
|
50
|
+
}) => `Seite ${number} von ${total}`,
|
|
51
|
+
pdfPageShort: ({
|
|
52
|
+
number,
|
|
53
|
+
total
|
|
54
|
+
}) => `${number} / ${total}`,
|
|
55
|
+
pdfZoom: "Zoom",
|
|
56
|
+
pdfZoomOut: "Verkleinern",
|
|
57
|
+
pdfZoomIn: "Vergrößern",
|
|
58
|
+
pdfZoomPercent: ({
|
|
59
|
+
value
|
|
60
|
+
}) => `${value} %`,
|
|
61
|
+
pdfFitWidth: "Breite",
|
|
62
|
+
pdfFitWidthLabel: "An die Breite anpassen"
|
|
31
63
|
}
|
|
32
64
|
}
|
|
33
65
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["content/pdf-messages.ts"],"sourcesContent":["import { i18n } from \"@k2b/stdlib\";\nimport { useLocale } from \"../intl/locale\";\n\nconst pdfMessages = i18n.define({\n baseLocale: \"en\",\n messages: {\n en: {\n openPreview: \"Open preview\",\n pdfPreview: \"PDF preview\",\n pdfPreviewHttpError: ({ status }: { status: number }) => `PDF preview failed with HTTP ${status}`,\n pdfPreviewTabBlocked: \"The browser blocked the new tab. Allow pop-ups and try again.\",\n pdfPreviewNoViewer: \"This PDF cannot be shown here\",\n pdfPreviewNoViewerDescription: \"Your browser cannot show PDFs inside a page. Open the document to view it.\",\n pdfPreviewRendering: \"Rendering PDF preview…\",\n previewPdf: \"Preview PDF\",\n renderPdfPreview: \"Render a PDF preview to see the final output.\",\n },\n de: {\n openPreview: \"Vorschau öffnen\",\n pdfPreview: \"PDF-Vorschau\",\n pdfPreviewHttpError: ({ status }) => `PDF-Vorschau ist mit HTTP ${status} fehlgeschlagen`,\n pdfPreviewTabBlocked: \"Der Browser hat den neuen Tab blockiert. Erlaube Pop-ups und versuche es erneut.\",\n pdfPreviewNoViewer: \"Dieses PDF kann hier nicht angezeigt werden\",\n pdfPreviewNoViewerDescription: \"Dein Browser kann PDFs nicht innerhalb einer Seite anzeigen. Öffne das Dokument, um es anzusehen.\",\n pdfPreviewRendering: \"PDF-Vorschau wird erstellt…\",\n previewPdf: \"PDF anzeigen\",\n renderPdfPreview: \"Erzeuge eine PDF-Vorschau, um das Endergebnis zu sehen.\",\n },\n },\n});\n\nexport type PdfMessages = ReturnType<(typeof pdfMessages)[\"resolve\"]>[\"t\"];\n\n/** Resolved from the inherited render locale. */\nexport const usePdfMessages = (): (() => PdfMessages) => {\n const locale = useLocale();\n return () => pdfMessages.resolve([locale()]).t;\n};\n\n/** Imperative UI inherits the document locale when no locale is supplied. */\nexport const resolvePdfMessages = (locale?: string): PdfMessages =>\n pdfMessages.resolve([locale ?? (typeof document === \"undefined\" ? pdfMessages.baseLocale : document.documentElement.lang)]).t;\n\nexport const checkPdfMessages = () => pdfMessages.check();\n"],"mappings":"AAAA,SAAS,IAAI,QAAQ,aAAa;AAClC,SAAS,SAAS,QAAQ,gBAAgB;AAE1C,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;EAC9B,UAAU,EAAE,IAAI;EAChB,QAAQ,EAAE;IACR,EAAE,EAAE;MACF,WAAW,EAAE,cAAc;MAC3B,UAAU,EAAE,aAAa;MACzB,mBAAmB,EAAE,CAAC;QAAE;MAA2B,CAAC,KAAK,gCAAgC,MAAM,EAAE;MACjG,oBAAoB,EAAE,+DAA+D;MACrF,kBAAkB,EAAE,+BAA+B;MACnD,6BAA6B,EAAE,4EAA4E;MAC3G,mBAAmB,EAAE,wBAAwB;MAC7C,UAAU,EAAE,aAAa;MACzB,gBAAgB,EAAE;IACpB,CAAC;IACD,EAAE,EAAE;MACF,WAAW,EAAE,iBAAiB;MAC9B,UAAU,EAAE,cAAc;MAC1B,mBAAmB,EAAE,CAAC;QAAE;MAAO,CAAC,KAAK,6BAA6B,MAAM,iBAAiB;MACzF,oBAAoB,EAAE,kFAAkF;MACxG,kBAAkB,EAAE,6CAA6C;MACjE,6BAA6B,EAAE,mGAAmG;MAClI,mBAAmB,EAAE,6BAA6B;MAClD,UAAU,EAAE,cAAc;MAC1B,gBAAgB,EAAE;IACpB;EACF;AACF,CAAC,CAAC;AAIF;AACA,OAAO,MAAM,cAAc,GAAG,MAA2B;EACvD,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;EAC1B,OAAO,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC;;AAED;AACA,OAAO,MAAM,kBAAkB,GAAI,MAAe,IAChD,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,OAAO,QAAQ,KAAK,WAAW,GAAG,WAAW,CAAC,UAAU,GAAG,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/H,OAAO,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["content/pdf-messages.ts"],"sourcesContent":["import { i18n } from \"@k2b/stdlib\";\nimport { useLocale } from \"../intl/locale\";\n\nconst pdfMessages = i18n.define({\n baseLocale: \"en\",\n messages: {\n en: {\n openPreview: \"Open preview\",\n pdfPreview: \"PDF preview\",\n pdfPreviewHttpError: ({ status }: { status: number }) => `PDF preview failed with HTTP ${status}`,\n pdfPreviewTabBlocked: \"The browser blocked the new tab. Allow pop-ups and try again.\",\n pdfPreviewNoViewer: \"This PDF cannot be shown here\",\n pdfPreviewNoViewerDescription: \"Your browser cannot show PDFs inside a page. Open the document to view it.\",\n pdfPreviewRendering: \"Rendering PDF preview…\",\n previewPdf: \"Preview PDF\",\n renderPdfPreview: \"Render a PDF preview to see the final output.\",\n pdfPage: ({ number, total }: { number: number; total: number }) => `Page ${number} of ${total}`,\n pdfPageShort: ({ number, total }: { number: number; total: number }) => `${number} / ${total}`,\n pdfZoom: \"Zoom\",\n pdfZoomOut: \"Zoom out\",\n pdfZoomIn: \"Zoom in\",\n pdfZoomPercent: ({ value }: { value: number }) => `${value}%`,\n pdfFitWidth: \"Width\",\n pdfFitWidthLabel: \"Fit to width\",\n },\n de: {\n openPreview: \"Vorschau öffnen\",\n pdfPreview: \"PDF-Vorschau\",\n pdfPreviewHttpError: ({ status }) => `PDF-Vorschau ist mit HTTP ${status} fehlgeschlagen`,\n pdfPreviewTabBlocked: \"Der Browser hat den neuen Tab blockiert. Erlaube Pop-ups und versuche es erneut.\",\n pdfPreviewNoViewer: \"Dieses PDF kann hier nicht angezeigt werden\",\n pdfPreviewNoViewerDescription: \"Dein Browser kann PDFs nicht innerhalb einer Seite anzeigen. Öffne das Dokument, um es anzusehen.\",\n pdfPreviewRendering: \"PDF-Vorschau wird erstellt…\",\n previewPdf: \"PDF anzeigen\",\n renderPdfPreview: \"Erzeuge eine PDF-Vorschau, um das Endergebnis zu sehen.\",\n pdfPage: ({ number, total }) => `Seite ${number} von ${total}`,\n pdfPageShort: ({ number, total }) => `${number} / ${total}`,\n pdfZoom: \"Zoom\",\n pdfZoomOut: \"Verkleinern\",\n pdfZoomIn: \"Vergrößern\",\n pdfZoomPercent: ({ value }) => `${value} %`,\n pdfFitWidth: \"Breite\",\n pdfFitWidthLabel: \"An die Breite anpassen\",\n },\n },\n});\n\nexport type PdfMessages = ReturnType<(typeof pdfMessages)[\"resolve\"]>[\"t\"];\n\n/** Resolved from the inherited render locale. */\nexport const usePdfMessages = (): (() => PdfMessages) => {\n const locale = useLocale();\n return () => pdfMessages.resolve([locale()]).t;\n};\n\n/** Imperative UI inherits the document locale when no locale is supplied. */\nexport const resolvePdfMessages = (locale?: string): PdfMessages =>\n pdfMessages.resolve([locale ?? (typeof document === \"undefined\" ? pdfMessages.baseLocale : document.documentElement.lang)]).t;\n\nexport const checkPdfMessages = () => pdfMessages.check();\n"],"mappings":"AAAA,SAAS,IAAI,QAAQ,aAAa;AAClC,SAAS,SAAS,QAAQ,gBAAgB;AAE1C,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;EAC9B,UAAU,EAAE,IAAI;EAChB,QAAQ,EAAE;IACR,EAAE,EAAE;MACF,WAAW,EAAE,cAAc;MAC3B,UAAU,EAAE,aAAa;MACzB,mBAAmB,EAAE,CAAC;QAAE;MAA2B,CAAC,KAAK,gCAAgC,MAAM,EAAE;MACjG,oBAAoB,EAAE,+DAA+D;MACrF,kBAAkB,EAAE,+BAA+B;MACnD,6BAA6B,EAAE,4EAA4E;MAC3G,mBAAmB,EAAE,wBAAwB;MAC7C,UAAU,EAAE,aAAa;MACzB,gBAAgB,EAAE,+CAA+C;MACjE,OAAO,EAAE,CAAC;QAAE,M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AC;AAChD,CAAC;;AAED;AACA,OAAO,MAAM,kBAAkB,GAAI,MAAe,IAChD,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,OAAO,QAAQ,KAAK,WAAW,GAAG,WAAW,CAAC,UAAU,GAAG,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/H,OAAO,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,CAAC","ignoreList":[]}
|
|
@@ -9,13 +9,15 @@ import { createComponent as _$createComponent } from "solid-js/web";
|
|
|
9
9
|
var _tmpl$ = ["<input class=\"k2b-control k2b-pin-input__digit\"", " inputmode=\"numeric\" autocomplete=\"off\" pattern=\"[0-9]\" maxlength=\"1\"", "", "", ">"],
|
|
10
10
|
_tmpl$2 = ["<input type=\"hidden\"", ">"],
|
|
11
11
|
_tmpl$3 = ["<output", ">", "</output>"],
|
|
12
|
-
_tmpl$4 =
|
|
13
|
-
_tmpl$5 = ["<
|
|
14
|
-
_tmpl$6 = ["<span class=\"k2b-color-
|
|
15
|
-
_tmpl$7 = ["<
|
|
16
|
-
_tmpl$8 = ["<
|
|
17
|
-
_tmpl$9 = ["<
|
|
12
|
+
_tmpl$4 = "<i class=\"ti ti-arrow-back-up\" aria-hidden=\"true\"></i>",
|
|
13
|
+
_tmpl$5 = ["<div class=\"k2b-slider\"", ">", "", "", "</div>"],
|
|
14
|
+
_tmpl$6 = ["<span class=\"k2b-color-input k2b-color-input--compact\">", "<input", " class=\"k2b-color-input__native\" type=\"color\"", "", "></span>"],
|
|
15
|
+
_tmpl$7 = ["<span class=\"k2b-color-input__swatch\"", " style=\"", "\"></span>"],
|
|
16
|
+
_tmpl$8 = ["<code>", "</code>"],
|
|
17
|
+
_tmpl$9 = ["<button type=\"button\" class=\"k2b-color-input__transparent\"", "", "><i class=\"ti ti-grid-dots\" aria-hidden=\"true\"></i></button>"],
|
|
18
|
+
_tmpl$0 = ["<div class=\"k2b-color-input\"", ">", "", "<input", " class=\"k2b-color-input__native\" type=\"color\"", "", "></div>"];
|
|
18
19
|
import { For, Show, splitProps } from "solid-js";
|
|
20
|
+
import { IconButton } from "../actions/Button";
|
|
19
21
|
import { createFieldMeta, Field, fieldControlAria } from "../internal/field";
|
|
20
22
|
import { commitFieldValue, resolveMaybeAccessor } from "./field-contract";
|
|
21
23
|
import { useInputMessages } from "./input-messages";
|
|
@@ -146,6 +148,18 @@ export function Slider(props) {
|
|
|
146
148
|
return `linear-gradient(to right, var(--k2b-action) 0 ${position}%, var(--k2b-surface-muted) ${position}% 100%)`;
|
|
147
149
|
};
|
|
148
150
|
const resetValue = () => local.defaultValue ?? (local.center ? (min() + max()) / 2 : min());
|
|
151
|
+
const changed = () => local.defaultValue !== undefined && value() !== local.defaultValue;
|
|
152
|
+
const inputMessages = useInputMessages();
|
|
153
|
+
// Names the value it returns to, formatted as the slider shows it: "Reset to 100%".
|
|
154
|
+
const resetLabel = () => inputMessages().resetTo({
|
|
155
|
+
value: local.formatValue?.(resetValue()) ?? String(resetValue())
|
|
156
|
+
});
|
|
157
|
+
let input;
|
|
158
|
+
const reset = () => {
|
|
159
|
+
commitFieldValue(local, resetValue());
|
|
160
|
+
// The button hides once the value is back, so focus returns to the slider it belongs to.
|
|
161
|
+
input?.focus();
|
|
162
|
+
};
|
|
149
163
|
return _$createComponent(Field, {
|
|
150
164
|
get ["class"]() {
|
|
151
165
|
return local.class;
|
|
@@ -167,7 +181,7 @@ export function Slider(props) {
|
|
|
167
181
|
return rest.disabled;
|
|
168
182
|
},
|
|
169
183
|
get children() {
|
|
170
|
-
return _$ssr(_tmpl$
|
|
184
|
+
return _$ssr(_tmpl$5, _$ssrAttribute("data-changed", changed() ? "true" : _$escape(undefined, true), false), _$ssrElement("input", _$mergeProps(rest, {
|
|
171
185
|
get id() {
|
|
172
186
|
return meta.controlId;
|
|
173
187
|
},
|
|
@@ -187,6 +201,29 @@ export function Slider(props) {
|
|
|
187
201
|
get children() {
|
|
188
202
|
return _$ssr(_tmpl$3, _$ssrAttribute("for", _$escape(meta.controlId, true), false), _$escape(local.formatValue?.(value()) ?? value()));
|
|
189
203
|
}
|
|
204
|
+
})), _$escape(_$createComponent(Show, {
|
|
205
|
+
get when() {
|
|
206
|
+
return local.defaultValue !== undefined;
|
|
207
|
+
},
|
|
208
|
+
get children() {
|
|
209
|
+
return _$createComponent(IconButton, {
|
|
210
|
+
"class": "k2b-slider__reset",
|
|
211
|
+
size: "xs",
|
|
212
|
+
get label() {
|
|
213
|
+
return resetLabel();
|
|
214
|
+
},
|
|
215
|
+
get ["aria-describedby"]() {
|
|
216
|
+
return _$memo(() => !!local.label)() ? meta.labelId : undefined;
|
|
217
|
+
},
|
|
218
|
+
get disabled() {
|
|
219
|
+
return rest.disabled || !changed();
|
|
220
|
+
},
|
|
221
|
+
onClick: reset,
|
|
222
|
+
get children() {
|
|
223
|
+
return _$ssr(_tmpl$4);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
190
227
|
})));
|
|
191
228
|
}
|
|
192
229
|
});
|
|
@@ -199,7 +236,7 @@ export function ColorInput(props) {
|
|
|
199
236
|
const error = () => resolveMaybeAccessor(props.error);
|
|
200
237
|
const compact = () => props.compact ?? !props.label;
|
|
201
238
|
let picker;
|
|
202
|
-
const control = () => compact() ? _$ssr(_tmpl$
|
|
239
|
+
const control = () => compact() ? _$ssr(_tmpl$6, _$ssrElement("button", _$mergeProps({
|
|
203
240
|
type: "button",
|
|
204
241
|
"class": "k2b-color-input__swatch",
|
|
205
242
|
get style() {
|
|
@@ -210,20 +247,20 @@ export function ColorInput(props) {
|
|
|
210
247
|
get disabled() {
|
|
211
248
|
return props.disabled;
|
|
212
249
|
}
|
|
213
|
-
}, () => fieldControlAria(meta, props)), undefined, false), _$ssrAttribute("id", _$escape(meta.controlId, true), false), _$ssrAttribute("name", _$escape(props.name, true), false) + _$ssrAttribute("value", _$escape(currentColor(), true), false), _$ssrAttribute("disabled", props.disabled, true)) : _$ssr(_tmpl$
|
|
250
|
+
}, () => fieldControlAria(meta, props)), undefined, false), _$ssrAttribute("id", _$escape(meta.controlId, true), false), _$ssrAttribute("name", _$escape(props.name, true), false) + _$ssrAttribute("value", _$escape(currentColor(), true), false), _$ssrAttribute("disabled", props.disabled, true)) : _$ssr(_tmpl$0, _$ssrAttribute("data-disabled", props.disabled || isTransparent() ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-invalid", error() ? "true" : _$escape(undefined, true), false), _$ssrElement("button", _$mergeProps({
|
|
214
251
|
type: "button",
|
|
215
252
|
"class": "k2b-color-input__value",
|
|
216
253
|
get disabled() {
|
|
217
254
|
return props.disabled || isTransparent();
|
|
218
255
|
}
|
|
219
|
-
}, () => fieldControlAria(meta, props)), [_$ssr(_tmpl$
|
|
256
|
+
}, () => fieldControlAria(meta, props)), [_$ssr(_tmpl$7, _$ssrAttribute("data-transparent", isTransparent() ? "true" : _$escape(undefined, true), false), _$ssrStyle(isTransparent() ? undefined : {
|
|
220
257
|
"background-color": currentColor()
|
|
221
|
-
})), _$ssr(_tmpl$
|
|
258
|
+
})), _$ssr(_tmpl$8, isTransparent() ? "transparent" : _$escape(currentColor().toUpperCase()))], false), _$escape(_$createComponent(Show, {
|
|
222
259
|
get when() {
|
|
223
260
|
return props.transparent;
|
|
224
261
|
},
|
|
225
262
|
get children() {
|
|
226
|
-
return _$ssr(_tmpl$
|
|
263
|
+
return _$ssr(_tmpl$9, _$ssrAttribute("aria-label", isTransparent() ? _$escape(inputMessages().useColor, true) : _$escape(inputMessages().useTransparent, true), false) + _$ssrAttribute("aria-pressed", _$escape(isTransparent(), true), false), _$ssrAttribute("disabled", props.disabled, true));
|
|
227
264
|
}
|
|
228
265
|
})), _$ssrAttribute("id", _$escape(meta.controlId, true), false), _$ssrAttribute("name", _$escape(props.name, true), false) + _$ssrAttribute("value", _$escape(currentColor(), true), false), _$ssrAttribute("disabled", props.disabled || isTransparent(), true));
|
|
229
266
|
return _$createComponent(Field, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["inputs/ChoiceInputs.tsx"],"sourcesContent":["import { For, type JSX, Show, splitProps } from \"solid-js\";\nimport { createFieldMeta, Field, fieldControlAria } from \"../internal/field\";\nimport type { FieldProps, MaybeAccessor, ValueFieldProps } from \"./field-contract\";\nimport { commitFieldValue, resolveMaybeAccessor } from \"./field-contract\";\nimport { useInputMessages } from \"./input-messages\";\n\nexport type PinInputProps = ValueFieldProps<string> & {\n length?: number;\n name?: string;\n stretch?: boolean;\n password?: boolean;\n readOnly?: boolean;\n onSubmit?: () => void;\n};\n\nexport function PinInput(props: PinInputProps): JSX.Element {\n const inputMessages = useInputMessages();\n const meta = createFieldMeta(props.id);\n const length = () => Math.max(1, props.length ?? 6);\n let inputs: HTMLInputElement[] = [];\n const digits = () => (resolveMaybeAccessor(props.value) ?? \"\").replace(/\\D/g, \"\").slice(0, length());\n const error = () => resolveMaybeAccessor(props.error);\n const emit = (value: string) => {\n props.onValueChange?.(value);\n if (value.length === length()) props.onValueCommit?.(value);\n };\n\n const updateDigit = (index: number, input: string) => {\n if (props.disabled || props.readOnly) return;\n const digit = input.replace(/\\D/g, \"\").slice(-1);\n const current = digits();\n emit(`${current.slice(0, index)}${digit}${current.slice(index + 1)}`);\n if (digit && index < length() - 1) {\n inputs[index + 1]?.focus();\n inputs[index + 1]?.select();\n }\n };\n\n const handleKeyDown = (index: number, event: KeyboardEvent) => {\n if (props.disabled || props.readOnly) return;\n if (event.key === \"Enter\" && props.onSubmit && !event.shiftKey && !event.metaKey) {\n event.preventDefault();\n props.onSubmit();\n } else if (event.key === \"ArrowLeft\" && index > 0) {\n event.preventDefault();\n inputs[index - 1]?.focus();\n inputs[index - 1]?.select();\n } else if (event.key === \"ArrowRight\" && index < length() - 1) {\n event.preventDefault();\n inputs[index + 1]?.focus();\n inputs[index + 1]?.select();\n } else if (event.key === \"Backspace\" && !digits()[index] && index > 0) {\n event.preventDefault();\n const current = digits();\n emit(`${current.slice(0, index - 1)}${current.slice(index)}`);\n inputs[index - 1]?.focus();\n inputs[index - 1]?.select();\n }\n };\n\n const handlePaste = (event: ClipboardEvent) => {\n if (props.disabled || props.readOnly) return;\n const pasted = event.clipboardData?.getData(\"text\").replace(/\\D/g, \"\");\n if (!pasted) return;\n event.preventDefault();\n const focused = inputs.indexOf(document.activeElement as HTMLInputElement);\n const start = focused >= 0 ? focused : 0;\n const insert = pasted.slice(0, length() - start);\n const current = digits();\n emit(`${current.slice(0, start)}${insert}${current.slice(start + insert.length)}`.slice(0, length()));\n const next = Math.min(start + insert.length, length() - 1);\n inputs[next]?.focus();\n inputs[next]?.select();\n };\n\n return (\n <Field\n class={props.class}\n label={props.label}\n description={props.description}\n error={error()}\n meta={meta}\n labelFor={false}\n required={props.required}\n disabled={props.disabled}\n >\n <div\n class=\"k2b-pin-input\"\n id={meta.controlId}\n data-stretch={props.stretch ? \"true\" : undefined}\n role=\"group\"\n {...fieldControlAria(meta, props)}\n onPaste={handlePaste}\n >\n <For each={Array.from({ length: length() })}>\n {(_, index) => (\n <input\n ref={(element) => {\n inputs[index()] = element;\n }}\n class=\"k2b-control k2b-pin-input__digit\"\n data-filled={digits()[index()] ? \"true\" : undefined}\n type={props.password ? \"password\" : \"text\"}\n inputmode=\"numeric\"\n autocomplete=\"off\"\n pattern=\"[0-9]\"\n maxlength={1}\n value={digits()[index()] ?? \"\"}\n required={props.required}\n disabled={props.disabled}\n readOnly={props.readOnly}\n aria-label={inputMessages().pinDigit({ index: index() + 1, total: length() })}\n onInput={(event) => updateDigit(index(), event.currentTarget.value)}\n onKeyDown={(event) => handleKeyDown(index(), event)}\n onFocus={(event) => event.currentTarget.select()}\n />\n )}\n </For>\n </div>\n <Show when={props.name}>{(name) => <input type=\"hidden\" name={name()} value={digits()} />}</Show>\n </Field>\n );\n}\n\nexport type SliderProps = FieldProps &\n Omit<JSX.InputHTMLAttributes<HTMLInputElement>, \"type\" | \"value\" | \"onInput\" | \"onChange\" | keyof FieldProps> &\n ValueFieldProps<number> & {\n value: MaybeAccessor<number>;\n formatValue?: (value: number) => string;\n showValue?: boolean;\n center?: boolean;\n defaultValue?: number;\n };\n\nexport function Slider(props: SliderProps): JSX.Element {\n const [local, rest] = splitProps(props, [\n \"aria-describedby\",\n \"aria-label\",\n \"center\",\n \"class\",\n \"defaultValue\",\n \"description\",\n \"error\",\n \"id\",\n \"label\",\n \"onValueChange\",\n \"onValueCommit\",\n \"required\",\n \"showValue\",\n \"value\",\n \"formatValue\",\n ]);\n const meta = createFieldMeta(local.id);\n const min = () => Number(rest.min ?? 0);\n const max = () => Number(rest.max ?? 100);\n const value = () => resolveMaybeAccessor(local.value) ?? min();\n const error = () => resolveMaybeAccessor(local.error);\n const percentage = () => {\n const span = max() - min();\n return span <= 0 ? 0 : Math.min(100, Math.max(0, ((value() - min()) / span) * 100));\n };\n const track = () => {\n const position = percentage();\n if (local.center) {\n const low = Math.min(50, position);\n const high = Math.max(50, position);\n return `linear-gradient(to right, var(--k2b-surface-muted) 0 ${low}%, var(--k2b-action) ${low}% ${high}%, var(--k2b-surface-muted) ${high}% 100%)`;\n }\n return `linear-gradient(to right, var(--k2b-action) 0 ${position}%, var(--k2b-surface-muted) ${position}% 100%)`;\n };\n const resetValue = () => local.defaultValue ?? (local.center ? (min() + max()) / 2 : min());\n\n return (\n <Field\n class={local.class}\n label={local.label}\n description={local.description}\n error={error()}\n meta={meta}\n required={local.required}\n disabled={rest.disabled}\n >\n <div class=\"k2b-slider\">\n <input\n {...rest}\n id={meta.controlId}\n type=\"range\"\n value={value()}\n style={{ background: track() }}\n {...fieldControlAria(meta, local)}\n onInput={(event) => local.onValueChange?.(event.currentTarget.valueAsNumber)}\n onChange={(event) => local.onValueCommit?.(event.currentTarget.valueAsNumber)}\n onDblClick={() => {\n const next = resetValue();\n commitFieldValue(local, next);\n }}\n />\n <Show when={local.showValue ?? true}>\n <output for={meta.controlId}>{local.formatValue?.(value()) ?? value()}</output>\n </Show>\n </div>\n </Field>\n );\n}\n\nexport type ColorInputProps = ValueFieldProps<string> & {\n name?: string;\n compact?: boolean;\n transparent?: boolean;\n transparentValue?: MaybeAccessor<boolean>;\n onTransparentValueChange?: (value: boolean) => void;\n};\n\nexport function ColorInput(props: ColorInputProps): JSX.Element {\n const inputMessages = useInputMessages();\n const meta = createFieldMeta(props.id);\n const currentColor = () => resolveMaybeAccessor(props.value) || \"#3b82f6\";\n const isTransparent = () => resolveMaybeAccessor(props.transparentValue) ?? false;\n const error = () => resolveMaybeAccessor(props.error);\n const compact = () => props.compact ?? !props.label;\n let picker: HTMLInputElement | undefined;\n\n const control = () =>\n compact() ? (\n <span class=\"k2b-color-input k2b-color-input--compact\">\n <button\n type=\"button\"\n class=\"k2b-color-input__swatch\"\n style={{ \"background-color\": currentColor() }}\n disabled={props.disabled}\n {...fieldControlAria(meta, props)}\n onClick={() => picker?.click()}\n />\n <input\n ref={picker}\n id={meta.controlId}\n class=\"k2b-color-input__native\"\n type=\"color\"\n name={props.name}\n value={currentColor()}\n disabled={props.disabled}\n onInput={(event) => props.onValueChange?.(event.currentTarget.value)}\n onChange={(event) => props.onValueCommit?.(event.currentTarget.value)}\n />\n </span>\n ) : (\n <div\n class=\"k2b-color-input\"\n data-disabled={props.disabled || isTransparent() ? \"true\" : undefined}\n data-invalid={error() ? \"true\" : undefined}\n >\n <button\n type=\"button\"\n class=\"k2b-color-input__value\"\n disabled={props.disabled || isTransparent()}\n {...fieldControlAria(meta, props)}\n onClick={() => picker?.click()}\n >\n <span\n class=\"k2b-color-input__swatch\"\n data-transparent={isTransparent() ? \"true\" : undefined}\n style={isTransparent() ? undefined : { \"background-color\": currentColor() }}\n />\n <code>{isTransparent() ? \"transparent\" : currentColor().toUpperCase()}</code>\n </button>\n <Show when={props.transparent}>\n <button\n type=\"button\"\n class=\"k2b-color-input__transparent\"\n aria-label={isTransparent() ? inputMessages().useColor : inputMessages().useTransparent}\n aria-pressed={isTransparent()}\n disabled={props.disabled}\n onClick={() => props.onTransparentValueChange?.(!isTransparent())}\n >\n <i class=\"ti ti-grid-dots\" aria-hidden=\"true\" />\n </button>\n </Show>\n <input\n ref={picker}\n id={meta.controlId}\n class=\"k2b-color-input__native\"\n type=\"color\"\n name={props.name}\n value={currentColor()}\n disabled={props.disabled || isTransparent()}\n onInput={(event) => props.onValueChange?.(event.currentTarget.value)}\n onChange={(event) => props.onValueCommit?.(event.currentTarget.value)}\n />\n </div>\n );\n\n return (\n <Field\n class={props.class}\n label={props.label}\n description={props.description}\n error={error()}\n meta={meta}\n required={props.required}\n disabled={props.disabled}\n >\n {control()}\n </Field>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,GAAG,EAAY,IAAI,EAAE,UAAU,QAAQ,UAAU;AAC1D,SAAS,eAAe,EAAE,KAAK,EAAE,gBAAgB,QAAQ,mBAAmB;AAE5E,SAAS,gBAAgB,EAAE,oBAAoB,QAAQ,kBAAkB;AACzE,SAAS,gBAAgB,QAAQ,kBAAkB;AAWnD,OAAO,SAAS,QAAQ,CAAC,KAAoB,EAAe;EAC1D,MAAM,aAAa,GAAG,gBAAgB,CAAC,CAAC;EACxC,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;EACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;EACnD,IAAI,MAA0B,GAAG,EAAE;EACnC,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;EACpG,MAAM,KAAK,GAAG,MAAM,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC;EACrD,MAAM,IAAI,GAAI,KAAa,IAAK;IAC9B,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC;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K,CAAC,QAAQ,IAAI,aAAa,CAAC,CAAC,QAKhD;EAEH,yBACG,KAAK;IAAA;MAAA,OACG,KAAK,CAAC,KAAK;IAAA;IAAA,IAClB,KAAK;MAAA,OAAE,KAAK,CAAC,KAAK;IAAA;IAAA,IAClB,WAAW;MAAA,OAAE,KAAK,CAAC,WAAW;IAAA;IAAA,IAC9B,KAAK;MAAA,OAAE,KAAK,CAAC,CAAC;IAAA;IACd,IAAI,EAAE,IAAI;IAAA,IACV,QAAQ;MAAA,OAAE,KAAK,CAAC,QAAQ;IAAA;IAAA,IACxB,QAAQ;MAAA,OAAE,KAAK,CAAC,QAAQ;IAAA;IAAA;MAAA,OAEvB,OAAO,CAAC,CAAC;IAAA;EAAA;AAGhB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["inputs/ChoiceInputs.tsx"],"sourcesContent":["import { For, type JSX, Show, splitProps } from \"solid-js\";\nimport { IconButton } from \"../actions/Button\";\nimport { createFieldMeta, Field, fieldControlAria } from \"../internal/field\";\nimport type { FieldProps, MaybeAccessor, ValueFieldProps } from \"./field-contract\";\nimport { commitFieldValue, resolveMaybeAccessor } from \"./field-contract\";\nimport { useInputMessages } from \"./input-messages\";\n\nexport type PinInputProps = ValueFieldProps<string> & {\n length?: number;\n name?: string;\n stretch?: boolean;\n password?: boolean;\n readOnly?: boolean;\n onSubmit?: () => void;\n};\n\nexport function PinInput(props: PinInputProps): JSX.Element {\n const inputMessages = useInputMessages();\n const meta = createFieldMeta(props.id);\n const length = () => Math.max(1, props.length ?? 6);\n let inputs: HTMLInputElement[] = [];\n const digits = () => (resolveMaybeAccessor(props.value) ?? \"\").replace(/\\D/g, \"\").slice(0, length());\n const error = () => resolveMaybeAccessor(props.error);\n const emit = (value: string) => {\n props.onValueChange?.(value);\n if (value.length === length()) props.onValueCommit?.(value);\n };\n\n const updateDigit = (index: number, input: string) => {\n if (props.disabled || props.readOnly) return;\n const digit = input.replace(/\\D/g, \"\").slice(-1);\n const current = digits();\n emit(`${current.slice(0, index)}${digit}${current.slice(index + 1)}`);\n if (digit && index < length() - 1) {\n inputs[index + 1]?.focus();\n inputs[index + 1]?.select();\n }\n };\n\n const handleKeyDown = (index: number, event: KeyboardEvent) => {\n if (props.disabled || props.readOnly) return;\n if (event.key === \"Enter\" && props.onSubmit && !event.shiftKey && !event.metaKey) {\n event.preventDefault();\n props.onSubmit();\n } else if (event.key === \"ArrowLeft\" && index > 0) {\n event.preventDefault();\n inputs[index - 1]?.focus();\n inputs[index - 1]?.select();\n } else if (event.key === \"ArrowRight\" && index < length() - 1) {\n event.preventDefault();\n inputs[index + 1]?.focus();\n inputs[index + 1]?.select();\n } else if (event.key === \"Backspace\" && !digits()[index] && index > 0) {\n event.preventDefault();\n const current = digits();\n emit(`${current.slice(0, index - 1)}${current.slice(index)}`);\n inputs[index - 1]?.focus();\n inputs[index - 1]?.select();\n }\n };\n\n const handlePaste = (event: ClipboardEvent) => {\n if (props.disabled || props.readOnly) return;\n const pasted = event.clipboardData?.getData(\"text\").replace(/\\D/g, \"\");\n if (!pasted) return;\n event.preventDefault();\n const focused = inputs.indexOf(document.activeElement as HTMLInputElement);\n const start = focused >= 0 ? focused : 0;\n const insert = pasted.slice(0, length() - start);\n const current = digits();\n emit(`${current.slice(0, start)}${insert}${current.slice(start + insert.length)}`.slice(0, length()));\n const next = Math.min(start + insert.length, length() - 1);\n inputs[next]?.focus();\n inputs[next]?.select();\n };\n\n return (\n <Field\n class={props.class}\n label={props.label}\n description={props.description}\n error={error()}\n meta={meta}\n labelFor={false}\n required={props.required}\n disabled={props.disabled}\n >\n <div\n class=\"k2b-pin-input\"\n id={meta.controlId}\n data-stretch={props.stretch ? \"true\" : undefined}\n role=\"group\"\n {...fieldControlAria(meta, props)}\n onPaste={handlePaste}\n >\n <For each={Array.from({ length: length() })}>\n {(_, index) => (\n <input\n ref={(element) => {\n inputs[index()] = element;\n }}\n class=\"k2b-control k2b-pin-input__digit\"\n data-filled={digits()[index()] ? \"true\" : undefined}\n type={props.password ? \"password\" : \"text\"}\n inputmode=\"numeric\"\n autocomplete=\"off\"\n pattern=\"[0-9]\"\n maxlength={1}\n value={digits()[index()] ?? \"\"}\n required={props.required}\n disabled={props.disabled}\n readOnly={props.readOnly}\n aria-label={inputMessages().pinDigit({ index: index() + 1, total: length() })}\n onInput={(event) => updateDigit(index(), event.currentTarget.value)}\n onKeyDown={(event) => handleKeyDown(index(), event)}\n onFocus={(event) => event.currentTarget.select()}\n />\n )}\n </For>\n </div>\n <Show when={props.name}>{(name) => <input type=\"hidden\" name={name()} value={digits()} />}</Show>\n </Field>\n );\n}\n\nexport type SliderProps = FieldProps &\n Omit<JSX.InputHTMLAttributes<HTMLInputElement>, \"type\" | \"value\" | \"onInput\" | \"onChange\" | keyof FieldProps> &\n ValueFieldProps<number> & {\n value: MaybeAccessor<number>;\n formatValue?: (value: number) => string;\n showValue?: boolean;\n center?: boolean;\n /**\n * The value the setting starts from. With it, a changed value shows in the accent color and a reset button\n * appears in a slot the slider always keeps, so nothing moves. Double-click resets too.\n */\n defaultValue?: number;\n };\n\nexport function Slider(props: SliderProps): JSX.Element {\n const [local, rest] = splitProps(props, [\n \"aria-describedby\",\n \"aria-label\",\n \"center\",\n \"class\",\n \"defaultValue\",\n \"description\",\n \"error\",\n \"id\",\n \"label\",\n \"onValueChange\",\n \"onValueCommit\",\n \"required\",\n \"showValue\",\n \"value\",\n \"formatValue\",\n ]);\n const meta = createFieldMeta(local.id);\n const min = () => Number(rest.min ?? 0);\n const max = () => Number(rest.max ?? 100);\n const value = () => resolveMaybeAccessor(local.value) ?? min();\n const error = () => resolveMaybeAccessor(local.error);\n const percentage = () => {\n const span = max() - min();\n return span <= 0 ? 0 : Math.min(100, Math.max(0, ((value() - min()) / span) * 100));\n };\n const track = () => {\n const position = percentage();\n if (local.center) {\n const low = Math.min(50, position);\n const high = Math.max(50, position);\n return `linear-gradient(to right, var(--k2b-surface-muted) 0 ${low}%, var(--k2b-action) ${low}% ${high}%, var(--k2b-surface-muted) ${high}% 100%)`;\n }\n return `linear-gradient(to right, var(--k2b-action) 0 ${position}%, var(--k2b-surface-muted) ${position}% 100%)`;\n };\n const resetValue = () => local.defaultValue ?? (local.center ? (min() + max()) / 2 : min());\n const changed = () => local.defaultValue !== undefined && value() !== local.defaultValue;\n const inputMessages = useInputMessages();\n // Names the value it returns to, formatted as the slider shows it: \"Reset to 100%\".\n const resetLabel = () => inputMessages().resetTo({ value: local.formatValue?.(resetValue()) ?? String(resetValue()) });\n let input: HTMLInputElement | undefined;\n const reset = () => {\n commitFieldValue(local, resetValue());\n // The button hides once the value is back, so focus returns to the slider it belongs to.\n input?.focus();\n };\n\n return (\n <Field\n class={local.class}\n label={local.label}\n description={local.description}\n error={error()}\n meta={meta}\n required={local.required}\n disabled={rest.disabled}\n >\n <div class=\"k2b-slider\" data-changed={changed() ? \"true\" : undefined}>\n <input\n {...rest}\n ref={input}\n id={meta.controlId}\n type=\"range\"\n value={value()}\n style={{ background: track() }}\n {...fieldControlAria(meta, local)}\n onInput={(event) => local.onValueChange?.(event.currentTarget.valueAsNumber)}\n onChange={(event) => local.onValueCommit?.(event.currentTarget.valueAsNumber)}\n onDblClick={() => {\n const next = resetValue();\n commitFieldValue(local, next);\n }}\n />\n <Show when={local.showValue ?? true}>\n <output for={meta.controlId}>{local.formatValue?.(value()) ?? value()}</output>\n </Show>\n <Show when={local.defaultValue !== undefined}>\n <IconButton\n class=\"k2b-slider__reset\"\n size=\"xs\"\n label={resetLabel()}\n aria-describedby={local.label ? meta.labelId : undefined}\n disabled={rest.disabled || !changed()}\n onClick={reset}\n >\n <i class=\"ti ti-arrow-back-up\" aria-hidden=\"true\" />\n </IconButton>\n </Show>\n </div>\n </Field>\n );\n}\n\nexport type ColorInputProps = ValueFieldProps<string> & {\n name?: string;\n compact?: boolean;\n transparent?: boolean;\n transparentValue?: MaybeAccessor<boolean>;\n onTransparentValueChange?: (value: boolean) => void;\n};\n\nexport function ColorInput(props: ColorInputProps): JSX.Element {\n const inputMessages = useInputMessages();\n const meta = createFieldMeta(props.id);\n const currentColor = () => resolveMaybeAccessor(props.value) || \"#3b82f6\";\n const isTransparent = () => resolveMaybeAccessor(props.transparentValue) ?? false;\n const error = () => resolveMaybeAccessor(props.error);\n const compact = () => props.compact ?? !props.label;\n let picker: HTMLInputElement | undefined;\n\n const control = () =>\n compact() ? (\n <span class=\"k2b-color-input k2b-color-input--compact\">\n <button\n type=\"button\"\n class=\"k2b-color-input__swatch\"\n style={{ \"background-color\": currentColor() }}\n disabled={props.disabled}\n {...fieldControlAria(meta, props)}\n onClick={() => picker?.click()}\n />\n <input\n ref={picker}\n id={meta.controlId}\n class=\"k2b-color-input__native\"\n type=\"color\"\n name={props.name}\n value={currentColor()}\n disabled={props.disabled}\n onInput={(event) => props.onValueChange?.(event.currentTarget.value)}\n onChange={(event) => props.onValueCommit?.(event.currentTarget.value)}\n />\n </span>\n ) : (\n <div\n class=\"k2b-color-input\"\n data-disabled={props.disabled || isTransparent() ? \"true\" : undefined}\n data-invalid={error() ? \"true\" : undefined}\n >\n <button\n type=\"button\"\n class=\"k2b-color-input__value\"\n disabled={props.disabled || isTransparent()}\n {...fieldControlAria(meta, props)}\n onClick={() => picker?.click()}\n >\n <span\n class=\"k2b-color-input__swatch\"\n data-transparent={isTransparent() ? \"true\" : undefined}\n style={isTransparent() ? undefined : { \"background-color\": currentColor() }}\n />\n <code>{isTransparent() ? \"transparent\" : currentColor().toUpperCase()}</code>\n </button>\n <Show when={props.transparent}>\n <button\n type=\"button\"\n class=\"k2b-color-input__transparent\"\n aria-label={isTransparent() ? inputMessages().useColor : inputMessages().useTransparent}\n aria-pressed={isTransparent()}\n disabled={props.disabled}\n onClick={() => props.onTransparentValueChange?.(!isTransparent())}\n >\n <i class=\"ti ti-grid-dots\" aria-hidden=\"true\" />\n </button>\n </Show>\n <input\n ref={picker}\n id={meta.controlId}\n class=\"k2b-color-input__native\"\n type=\"color\"\n name={props.name}\n value={currentColor()}\n disabled={props.disabled || isTransparent()}\n onInput={(event) => props.onValueChange?.(event.currentTarget.value)}\n onChange={(event) => props.onValueCommit?.(event.currentTarget.value)}\n />\n </div>\n );\n\n return (\n <Field\n class={props.class}\n label={props.label}\n description={props.description}\n error={error()}\n meta={meta}\n required={props.required}\n disabled={props.disabled}\n >\n {control()}\n </Field>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,GAAG,EAAY,IAAI,EAAE,UAAU,QAAQ,UAAU;AAC1D,SAAS,UAAU,QAAQ,mBAAmB;AAC9C,SAAS,eAAe,EAAE,KAAK,EAAE,gBAAgB,QAAQ,mBAAmB;AAE5E,SAAS,gBAAgB,EAAE,oBAAoB,QAAQ,kBAAkB;AACzE,SAAS,gBAAgB,QAAQ,kBAAkB;AAWnD,OAAO,SAAS,QAAQ,CAAC,KAAoB,EAAe;EAC1D,MAAM,aAAa,GAAG,gBAAgB,CAAC,CAAC;EACxC,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;EACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;EACnD,IAAI,MAA0B,GAAG,EAAE;EACnC,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;EACpG,MAAM,KAAK,GAAG,MAAM,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC;EACrD,MAAM,IAAI,GAAI,KAAa,IAAK;IAC9B,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC;IAC5B,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC;EAC7D,CAAC;EAED,MAAM,WAAW,GAAG,C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MAAA,OAEvB,OAAO,CAAC,CAAC;IAAA;EAAA;AAGhB","ignoreList":[]}
|
|
@@ -4,10 +4,10 @@ import { ssr as _$ssr } from "solid-js/web";
|
|
|
4
4
|
import { ssrAttribute as _$ssrAttribute } from "solid-js/web";
|
|
5
5
|
import { escape as _$escape } from "solid-js/web";
|
|
6
6
|
var _tmpl$ = "<i class=\"ti ti-alert-triangle\" aria-hidden=\"true\"></i>",
|
|
7
|
-
_tmpl$2 = ["<div", " class=\"k2b-choice-slider__track\" role=\"slider\"", " aria-valuemin=\"1\"", "
|
|
7
|
+
_tmpl$2 = ["<div", " class=\"k2b-choice-slider__track\" role=\"slider\"", " aria-valuemin=\"1\"", " style=\"", "\"><span class=\"k2b-choice-slider__rail\"></span><span class=\"k2b-choice-slider__fill\"", "></span>", "<span class=\"k2b-choice-slider__thumb\"", "", "></span></div>"],
|
|
8
8
|
_tmpl$3 = ["<div", "><p class=\"k2b-choice-slider__line\"", " aria-live=\"polite\">", "<span>", "</span></p>", "</div>"],
|
|
9
|
-
_tmpl$4 = ["<span class=\"k2b-choice-
|
|
10
|
-
_tmpl$5 = ["<span class=\"k2b-choice-
|
|
9
|
+
_tmpl$4 = ["<span class=\"k2b-choice-slider__stop\"", " style=\"", "\"></span>"],
|
|
10
|
+
_tmpl$5 = ["<span", " data-size=\"indicator\" aria-hidden=\"true\"><span class=\"k2b-choice-slider__track\" style=\"", "\"><span class=\"k2b-choice-slider__rail\"></span><span class=\"k2b-choice-slider__fill\"", "></span><span class=\"k2b-choice-slider__thumb\"", "></span></span></span>"];
|
|
11
11
|
import { createEffect, createMemo, createSignal, For, on, Show } from "solid-js";
|
|
12
12
|
import { resolveMaybeAccessor } from "./field-contract";
|
|
13
13
|
const position = (index, count) => count < 2 ? 0 : index / (count - 1) * 100;
|
|
@@ -117,8 +117,10 @@ export function ChoiceSlider(props) {
|
|
|
117
117
|
// One pointer owns a drag; a second finger waits until it ends.
|
|
118
118
|
if (props.disabled || count() < 2 || event.button !== 0 || drag) return;
|
|
119
119
|
event.preventDefault();
|
|
120
|
+
// A pointer press focuses the track without the keyboard focus ring.
|
|
120
121
|
track?.focus({
|
|
121
|
-
preventScroll: true
|
|
122
|
+
preventScroll: true,
|
|
123
|
+
focusVisible: false
|
|
122
124
|
});
|
|
123
125
|
track?.setPointerCapture?.(event.pointerId);
|
|
124
126
|
const near = Math.round(at(event.clientX));
|
|
@@ -174,18 +176,21 @@ export function ChoiceSlider(props) {
|
|
|
174
176
|
return count() >= 2;
|
|
175
177
|
},
|
|
176
178
|
get children() {
|
|
177
|
-
return _$ssr(_tmpl$2, _$ssrAttribute("id", _$escape(props.id, true), false), _$ssrAttribute("tabindex", props.disabled ? -1 : 0, false) + _$ssrAttribute("aria-label", _$escape(props["aria-label"], true), false) + _$ssrAttribute("aria-labelledby", _$escape(props["aria-labelledby"], true), false), _$ssrAttribute("aria-valuemax", _$escape(count(), true), false) + _$ssrAttribute("aria-valuenow", _$escape(Math.max(0, shown()), true) + 1, false) + _$ssrAttribute("aria-valuetext", _$escape(valueText(), true), false) + _$ssrAttribute("aria-disabled", props.disabled ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(For, {
|
|
178
|
-
get each() {
|
|
179
|
-
return props.options.slice(1);
|
|
180
|
-
},
|
|
181
|
-
children: (_, index) => _$ssr(_tmpl$4, _$ssrAttribute("data-on", shown() > index() ? "" : _$escape(undefined, true), false), _$ssrStyleProperty("left:", `calc(${_$escape(position(index(), count()), true)}% + 8px)`) + _$ssrStyleProperty(";width:", `calc(${_$escape(position(index() + 1, count()), true) - _$escape(position(index(), count()), true)}% - 16px)`))
|
|
182
|
-
})), _$escape(_$createComponent(For, {
|
|
179
|
+
return _$ssr(_tmpl$2, _$ssrAttribute("id", _$escape(props.id, true), false), _$ssrAttribute("tabindex", props.disabled ? -1 : 0, false) + _$ssrAttribute("aria-label", _$escape(props["aria-label"], true), false) + _$ssrAttribute("aria-labelledby", _$escape(props["aria-labelledby"], true), false), _$ssrAttribute("aria-valuemax", _$escape(count(), true), false) + _$ssrAttribute("aria-valuenow", _$escape(Math.max(0, shown()), true) + 1, false) + _$ssrAttribute("aria-valuetext", _$escape(valueText(), true), false) + _$ssrAttribute("aria-disabled", props.disabled ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-dragging", preview() !== null ? "" : _$escape(undefined, true), false), _$ssrStyleProperty("--k2b-choice-slider-at:", `${_$escape(position(Math.max(0, shown()), count()), true)}%`), _$ssrAttribute("hidden", shown() < 0, true), _$escape(_$createComponent(For, {
|
|
183
180
|
get each() {
|
|
184
181
|
return props.options;
|
|
185
182
|
},
|
|
186
|
-
children: (stop, index) => _$ssr(_tmpl$
|
|
187
|
-
})), _$ssrAttribute("data-tone", warning() && preview() === null && option()?.disabledReason ? "warning" : _$escape(undefined, true), false), _$ssrAttribute("hidden", shown() < 0, true)
|
|
183
|
+
children: (stop, index) => _$ssr(_tmpl$4, _$ssrAttribute("data-on", shown() > index() ? "" : _$escape(undefined, true), false) + _$ssrAttribute("data-unavailable", stop.disabledReason ? "" : _$escape(undefined, true), false) + _$ssrAttribute("data-current", index() === shown() ? "" : _$escape(undefined, true), false), _$ssrStyleProperty("left:", `${_$escape(position(index(), count()), true)}%`))
|
|
184
|
+
})), _$ssrAttribute("data-tone", warning() && preview() === null && option()?.disabledReason ? "warning" : _$escape(undefined, true), false), _$ssrAttribute("hidden", shown() < 0, true));
|
|
188
185
|
}
|
|
189
186
|
})));
|
|
190
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* The slider in small and without interaction, 24 px wide: rail, fill and thumb in the same look, for a trigger that
|
|
190
|
+
* opens the real slider. It is decoration; the trigger's own label says the value.
|
|
191
|
+
*/
|
|
192
|
+
export function ChoiceSliderIndicator(props) {
|
|
193
|
+
const at = () => props.index === null || props.index < 0 ? null : position(Math.min(props.index, props.count - 1), props.count);
|
|
194
|
+
return _$ssr(_tmpl$5, _$ssrAttribute("class", _$escape(["k2b-choice-slider", props.class].filter(Boolean).join(" "), true), false), _$ssrStyleProperty("--k2b-choice-slider-at:", `${_$escape(at() ?? 0, true)}%`), _$ssrAttribute("hidden", at() === null, true), _$ssrAttribute("hidden", at() === null, true));
|
|
195
|
+
}
|
|
191
196
|
//# sourceMappingURL=ChoiceSlider.js.map
|