@contraagent/elements 0.0.0-stage → 0.2.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/README.md +83 -2
- package/custom-elements.json +5022 -0
- package/dist/charts/bar-chart.d.ts +32 -0
- package/dist/charts/bar-chart.d.ts.map +1 -0
- package/dist/charts/bar-chart.js +70 -0
- package/dist/charts/bar-chart.js.map +1 -0
- package/dist/charts/base.d.ts +48 -0
- package/dist/charts/base.d.ts.map +1 -0
- package/dist/charts/base.js +203 -0
- package/dist/charts/base.js.map +1 -0
- package/dist/charts/column-chart.d.ts +42 -0
- package/dist/charts/column-chart.d.ts.map +1 -0
- package/dist/charts/column-chart.js +146 -0
- package/dist/charts/column-chart.js.map +1 -0
- package/dist/charts/heatmap.d.ts +42 -0
- package/dist/charts/heatmap.d.ts.map +1 -0
- package/dist/charts/heatmap.js +124 -0
- package/dist/charts/heatmap.js.map +1 -0
- package/dist/charts/index.d.ts +9 -0
- package/dist/charts/index.d.ts.map +1 -0
- package/dist/charts/index.js +11 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/charts/line-chart.d.ts +36 -0
- package/dist/charts/line-chart.d.ts.map +1 -0
- package/dist/charts/line-chart.js +118 -0
- package/dist/charts/line-chart.js.map +1 -0
- package/dist/charts/scale.d.ts +32 -0
- package/dist/charts/scale.d.ts.map +1 -0
- package/dist/charts/scale.js +50 -0
- package/dist/charts/scale.js.map +1 -0
- package/dist/charts/state-grid.d.ts +64 -0
- package/dist/charts/state-grid.d.ts.map +1 -0
- package/dist/charts/state-grid.js +223 -0
- package/dist/charts/state-grid.js.map +1 -0
- package/dist/charts/types.d.ts +34 -0
- package/dist/charts/types.d.ts.map +1 -0
- package/dist/charts/types.js +11 -0
- package/dist/charts/types.js.map +1 -0
- package/dist/checks/check-table.d.ts +32 -0
- package/dist/checks/check-table.d.ts.map +1 -0
- package/dist/checks/check-table.js +94 -0
- package/dist/checks/check-table.js.map +1 -0
- package/dist/checks/index.d.ts +4 -0
- package/dist/checks/index.d.ts.map +1 -0
- package/dist/checks/index.js +6 -0
- package/dist/checks/index.js.map +1 -0
- package/dist/checks/styles.d.ts +5 -0
- package/dist/checks/styles.d.ts.map +1 -0
- package/dist/checks/styles.js +30 -0
- package/dist/checks/styles.js.map +1 -0
- package/dist/checks/types.d.ts +35 -0
- package/dist/checks/types.d.ts.map +1 -0
- package/dist/checks/types.js +12 -0
- package/dist/checks/types.js.map +1 -0
- package/dist/code/code.d.ts +83 -0
- package/dist/code/code.d.ts.map +1 -0
- package/dist/code/code.js +206 -0
- package/dist/code/code.js.map +1 -0
- package/dist/code/highlight.d.ts +25 -0
- package/dist/code/highlight.d.ts.map +1 -0
- package/dist/code/highlight.js +312 -0
- package/dist/code/highlight.js.map +1 -0
- package/dist/code/index.d.ts +3 -0
- package/dist/code/index.d.ts.map +1 -0
- package/dist/code/index.js +5 -0
- package/dist/code/index.js.map +1 -0
- package/dist/core/clock.d.ts +20 -0
- package/dist/core/clock.d.ts.map +1 -0
- package/dist/core/clock.js +45 -0
- package/dist/core/clock.js.map +1 -0
- package/dist/core/define.d.ts +3 -0
- package/dist/core/define.d.ts.map +1 -0
- package/dist/core/define.js +8 -0
- package/dist/core/define.js.map +1 -0
- package/dist/core/events.d.ts +78 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +8 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/format.d.ts +8 -0
- package/dist/core/format.d.ts.map +1 -0
- package/dist/core/format.js +28 -0
- package/dist/core/format.js.map +1 -0
- package/dist/core/frame.d.ts +4 -0
- package/dist/core/frame.d.ts.map +1 -0
- package/dist/core/frame.js +5 -0
- package/dist/core/frame.js.map +1 -0
- package/dist/core/strings.d.ts +3 -0
- package/dist/core/strings.d.ts.map +1 -0
- package/dist/core/strings.js +14 -0
- package/dist/core/strings.js.map +1 -0
- package/dist/core/tone.d.ts +8 -0
- package/dist/core/tone.d.ts.map +1 -0
- package/dist/core/tone.js +9 -0
- package/dist/core/tone.js.map +1 -0
- package/dist/count/count.d.ts +22 -0
- package/dist/count/count.d.ts.map +1 -0
- package/dist/count/count.js +60 -0
- package/dist/count/count.js.map +1 -0
- package/dist/count/elapsed.d.ts +18 -0
- package/dist/count/elapsed.d.ts.map +1 -0
- package/dist/count/elapsed.js +33 -0
- package/dist/count/elapsed.js.map +1 -0
- package/dist/count/index.d.ts +3 -0
- package/dist/count/index.d.ts.map +1 -0
- package/dist/count/index.js +5 -0
- package/dist/count/index.js.map +1 -0
- package/dist/define/all.d.ts +15 -0
- package/dist/define/all.d.ts.map +1 -0
- package/dist/define/all.js +16 -0
- package/dist/define/all.js.map +1 -0
- package/dist/define/charts.d.ts +8 -0
- package/dist/define/charts.d.ts.map +1 -0
- package/dist/define/charts.js +15 -0
- package/dist/define/charts.js.map +1 -0
- package/dist/define/check-table.d.ts +4 -0
- package/dist/define/check-table.d.ts.map +1 -0
- package/dist/define/check-table.js +7 -0
- package/dist/define/check-table.js.map +1 -0
- package/dist/define/code.d.ts +4 -0
- package/dist/define/code.d.ts.map +1 -0
- package/dist/define/code.js +7 -0
- package/dist/define/code.js.map +1 -0
- package/dist/define/count.d.ts +5 -0
- package/dist/define/count.d.ts.map +1 -0
- package/dist/define/count.js +9 -0
- package/dist/define/count.js.map +1 -0
- package/dist/define/data-table.d.ts +4 -0
- package/dist/define/data-table.d.ts.map +1 -0
- package/dist/define/data-table.js +7 -0
- package/dist/define/data-table.js.map +1 -0
- package/dist/define/graph.d.ts +6 -0
- package/dist/define/graph.d.ts.map +1 -0
- package/dist/define/graph.js +9 -0
- package/dist/define/graph.js.map +1 -0
- package/dist/define/json-tree.d.ts +4 -0
- package/dist/define/json-tree.d.ts.map +1 -0
- package/dist/define/json-tree.js +7 -0
- package/dist/define/json-tree.js.map +1 -0
- package/dist/define/lanes.d.ts +4 -0
- package/dist/define/lanes.d.ts.map +1 -0
- package/dist/define/lanes.js +7 -0
- package/dist/define/lanes.js.map +1 -0
- package/dist/define/markdown.d.ts +4 -0
- package/dist/define/markdown.d.ts.map +1 -0
- package/dist/define/markdown.js +7 -0
- package/dist/define/markdown.js.map +1 -0
- package/dist/define/matrix.d.ts +4 -0
- package/dist/define/matrix.d.ts.map +1 -0
- package/dist/define/matrix.js +7 -0
- package/dist/define/matrix.js.map +1 -0
- package/dist/define/segmented.d.ts +4 -0
- package/dist/define/segmented.d.ts.map +1 -0
- package/dist/define/segmented.js +7 -0
- package/dist/define/segmented.js.map +1 -0
- package/dist/define/tiles.d.ts +5 -0
- package/dist/define/tiles.d.ts.map +1 -0
- package/dist/define/tiles.js +9 -0
- package/dist/define/tiles.js.map +1 -0
- package/dist/define/transcript.d.ts +4 -0
- package/dist/define/transcript.d.ts.map +1 -0
- package/dist/define/transcript.js +7 -0
- package/dist/define/transcript.js.map +1 -0
- package/dist/define/tree.d.ts +4 -0
- package/dist/define/tree.d.ts.map +1 -0
- package/dist/define/tree.js +7 -0
- package/dist/define/tree.js.map +1 -0
- package/dist/graph/arrange.d.ts +43 -0
- package/dist/graph/arrange.d.ts.map +1 -0
- package/dist/graph/arrange.js +390 -0
- package/dist/graph/arrange.js.map +1 -0
- package/dist/graph/card.d.ts +71 -0
- package/dist/graph/card.d.ts.map +1 -0
- package/dist/graph/card.js +185 -0
- package/dist/graph/card.js.map +1 -0
- package/dist/graph/host.d.ts +82 -0
- package/dist/graph/host.d.ts.map +1 -0
- package/dist/graph/host.js +21 -0
- package/dist/graph/host.js.map +1 -0
- package/dist/graph/icons.d.ts +7 -0
- package/dist/graph/icons.d.ts.map +1 -0
- package/dist/graph/icons.js +18 -0
- package/dist/graph/icons.js.map +1 -0
- package/dist/graph/index.d.ts +15 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +17 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/layered-graph.d.ts +226 -0
- package/dist/graph/layered-graph.d.ts.map +1 -0
- package/dist/graph/layered-graph.js +396 -0
- package/dist/graph/layered-graph.js.map +1 -0
- package/dist/graph/layout.d.ts +80 -0
- package/dist/graph/layout.d.ts.map +1 -0
- package/dist/graph/layout.js +264 -0
- package/dist/graph/layout.js.map +1 -0
- package/dist/graph/marks.d.ts +24 -0
- package/dist/graph/marks.d.ts.map +1 -0
- package/dist/graph/marks.js +38 -0
- package/dist/graph/marks.js.map +1 -0
- package/dist/graph/nav.d.ts +14 -0
- package/dist/graph/nav.d.ts.map +1 -0
- package/dist/graph/nav.js +14 -0
- package/dist/graph/nav.js.map +1 -0
- package/dist/graph/pan-zoom.d.ts +80 -0
- package/dist/graph/pan-zoom.d.ts.map +1 -0
- package/dist/graph/pan-zoom.js +191 -0
- package/dist/graph/pan-zoom.js.map +1 -0
- package/dist/graph/paths.d.ts +9 -0
- package/dist/graph/paths.d.ts.map +1 -0
- package/dist/graph/paths.js +44 -0
- package/dist/graph/paths.js.map +1 -0
- package/dist/graph/place-card.d.ts +36 -0
- package/dist/graph/place-card.d.ts.map +1 -0
- package/dist/graph/place-card.js +68 -0
- package/dist/graph/place-card.js.map +1 -0
- package/dist/graph/strings.d.ts +50 -0
- package/dist/graph/strings.d.ts.map +1 -0
- package/dist/graph/strings.js +37 -0
- package/dist/graph/strings.js.map +1 -0
- package/dist/graph/styles.d.ts +2 -0
- package/dist/graph/styles.d.ts.map +1 -0
- package/dist/graph/styles.js +203 -0
- package/dist/graph/styles.js.map +1 -0
- package/dist/graph/types.d.ts +184 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +2 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/graph/view.d.ts +17 -0
- package/dist/graph/view.d.ts.map +1 -0
- package/dist/graph/view.js +21 -0
- package/dist/graph/view.js.map +1 -0
- package/dist/graph/views/dag.d.ts +10 -0
- package/dist/graph/views/dag.d.ts.map +1 -0
- package/dist/graph/views/dag.js +292 -0
- package/dist/graph/views/dag.js.map +1 -0
- package/dist/graph/views/foot.d.ts +8 -0
- package/dist/graph/views/foot.d.ts.map +1 -0
- package/dist/graph/views/foot.js +103 -0
- package/dist/graph/views/foot.js.map +1 -0
- package/dist/graph/views/node-table.d.ts +17 -0
- package/dist/graph/views/node-table.d.ts.map +1 -0
- package/dist/graph/views/node-table.js +80 -0
- package/dist/graph/views/node-table.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/json/index.d.ts +2 -0
- package/dist/json/index.d.ts.map +1 -0
- package/dist/json/index.js +3 -0
- package/dist/json/index.js.map +1 -0
- package/dist/json/json-tree.d.ts +21 -0
- package/dist/json/json-tree.d.ts.map +1 -0
- package/dist/json/json-tree.js +51 -0
- package/dist/json/json-tree.js.map +1 -0
- package/dist/lanes/index.d.ts +5 -0
- package/dist/lanes/index.d.ts.map +1 -0
- package/dist/lanes/index.js +7 -0
- package/dist/lanes/index.js.map +1 -0
- package/dist/lanes/lanes.d.ts +56 -0
- package/dist/lanes/lanes.d.ts.map +1 -0
- package/dist/lanes/lanes.js +160 -0
- package/dist/lanes/lanes.js.map +1 -0
- package/dist/lanes/stack.d.ts +26 -0
- package/dist/lanes/stack.d.ts.map +1 -0
- package/dist/lanes/stack.js +43 -0
- package/dist/lanes/stack.js.map +1 -0
- package/dist/lanes/styles.d.ts +2 -0
- package/dist/lanes/styles.d.ts.map +1 -0
- package/dist/lanes/styles.js +30 -0
- package/dist/lanes/styles.js.map +1 -0
- package/dist/lanes/types.d.ts +41 -0
- package/dist/lanes/types.d.ts.map +1 -0
- package/dist/lanes/types.js +6 -0
- package/dist/lanes/types.js.map +1 -0
- package/dist/markdown/cae-markdown.d.ts +37 -0
- package/dist/markdown/cae-markdown.d.ts.map +1 -0
- package/dist/markdown/cae-markdown.js +68 -0
- package/dist/markdown/cae-markdown.js.map +1 -0
- package/dist/markdown/highlight.d.ts +2 -0
- package/dist/markdown/highlight.d.ts.map +1 -0
- package/dist/markdown/highlight.js +3 -0
- package/dist/markdown/highlight.js.map +1 -0
- package/dist/markdown/index.d.ts +4 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +6 -0
- package/dist/markdown/index.js.map +1 -0
- package/dist/markdown/markdown.d.ts +4 -0
- package/dist/markdown/markdown.d.ts.map +1 -0
- package/dist/markdown/markdown.js +105 -0
- package/dist/markdown/markdown.js.map +1 -0
- package/dist/matrix/grid-step.d.ts +8 -0
- package/dist/matrix/grid-step.d.ts.map +1 -0
- package/dist/matrix/grid-step.js +69 -0
- package/dist/matrix/grid-step.js.map +1 -0
- package/dist/matrix/index.d.ts +5 -0
- package/dist/matrix/index.d.ts.map +1 -0
- package/dist/matrix/index.js +7 -0
- package/dist/matrix/index.js.map +1 -0
- package/dist/matrix/mark-matrix.d.ts +97 -0
- package/dist/matrix/mark-matrix.d.ts.map +1 -0
- package/dist/matrix/mark-matrix.js +272 -0
- package/dist/matrix/mark-matrix.js.map +1 -0
- package/dist/matrix/styles.d.ts +4 -0
- package/dist/matrix/styles.d.ts.map +1 -0
- package/dist/matrix/styles.js +47 -0
- package/dist/matrix/styles.js.map +1 -0
- package/dist/matrix/types.d.ts +79 -0
- package/dist/matrix/types.d.ts.map +1 -0
- package/dist/matrix/types.js +5 -0
- package/dist/matrix/types.js.map +1 -0
- package/dist/primitives/fact-line.d.ts +14 -0
- package/dist/primitives/fact-line.d.ts.map +1 -0
- package/dist/primitives/fact-line.js +18 -0
- package/dist/primitives/fact-line.js.map +1 -0
- package/dist/primitives/icon.d.ts +14 -0
- package/dist/primitives/icon.d.ts.map +1 -0
- package/dist/primitives/icon.js +19 -0
- package/dist/primitives/icon.js.map +1 -0
- package/dist/primitives/index.d.ts +10 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +13 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/legend.d.ts +28 -0
- package/dist/primitives/legend.d.ts.map +1 -0
- package/dist/primitives/legend.js +28 -0
- package/dist/primitives/legend.js.map +1 -0
- package/dist/primitives/pill.d.ts +23 -0
- package/dist/primitives/pill.d.ts.map +1 -0
- package/dist/primitives/pill.js +40 -0
- package/dist/primitives/pill.js.map +1 -0
- package/dist/primitives/roving-focus.d.ts +47 -0
- package/dist/primitives/roving-focus.d.ts.map +1 -0
- package/dist/primitives/roving-focus.js +111 -0
- package/dist/primitives/roving-focus.js.map +1 -0
- package/dist/primitives/segmented.d.ts +41 -0
- package/dist/primitives/segmented.d.ts.map +1 -0
- package/dist/primitives/segmented.js +88 -0
- package/dist/primitives/segmented.js.map +1 -0
- package/dist/primitives/share-bar.d.ts +37 -0
- package/dist/primitives/share-bar.d.ts.map +1 -0
- package/dist/primitives/share-bar.js +69 -0
- package/dist/primitives/share-bar.js.map +1 -0
- package/dist/primitives/states.d.ts +19 -0
- package/dist/primitives/states.d.ts.map +1 -0
- package/dist/primitives/states.js +11 -0
- package/dist/primitives/states.js.map +1 -0
- package/dist/primitives/window.d.ts +24 -0
- package/dist/primitives/window.d.ts.map +1 -0
- package/dist/primitives/window.js +56 -0
- package/dist/primitives/window.js.map +1 -0
- package/dist/styles/chips.d.ts +2 -0
- package/dist/styles/chips.d.ts.map +1 -0
- package/dist/styles/chips.js +18 -0
- package/dist/styles/chips.js.map +1 -0
- package/dist/styles/facts.d.ts +2 -0
- package/dist/styles/facts.d.ts.map +1 -0
- package/dist/styles/facts.js +7 -0
- package/dist/styles/facts.js.map +1 -0
- package/dist/styles/index.d.ts +16 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/styles/index.js +15 -0
- package/dist/styles/index.js.map +1 -0
- package/dist/styles/layout.d.ts +2 -0
- package/dist/styles/layout.d.ts.map +1 -0
- package/dist/styles/layout.js +33 -0
- package/dist/styles/layout.js.map +1 -0
- package/dist/styles/marks.d.ts +2 -0
- package/dist/styles/marks.d.ts.map +1 -0
- package/dist/styles/marks.js +30 -0
- package/dist/styles/marks.js.map +1 -0
- package/dist/styles/meter.d.ts +3 -0
- package/dist/styles/meter.d.ts.map +1 -0
- package/dist/styles/meter.js +9 -0
- package/dist/styles/meter.js.map +1 -0
- package/dist/styles/motion.d.ts +2 -0
- package/dist/styles/motion.d.ts.map +1 -0
- package/dist/styles/motion.js +27 -0
- package/dist/styles/motion.js.map +1 -0
- package/dist/styles/prose.d.ts +3 -0
- package/dist/styles/prose.d.ts.map +1 -0
- package/dist/styles/prose.js +64 -0
- package/dist/styles/prose.js.map +1 -0
- package/dist/styles/reset.d.ts +2 -0
- package/dist/styles/reset.d.ts.map +1 -0
- package/dist/styles/reset.js +13 -0
- package/dist/styles/reset.js.map +1 -0
- package/dist/styles/status.d.ts +2 -0
- package/dist/styles/status.d.ts.map +1 -0
- package/dist/styles/status.js +52 -0
- package/dist/styles/status.js.map +1 -0
- package/dist/styles/text.d.ts +2 -0
- package/dist/styles/text.d.ts.map +1 -0
- package/dist/styles/text.js +21 -0
- package/dist/styles/text.js.map +1 -0
- package/dist/styles/tokens.d.ts +8 -0
- package/dist/styles/tokens.d.ts.map +1 -0
- package/dist/styles/tokens.js +32 -0
- package/dist/styles/tokens.js.map +1 -0
- package/dist/table/data-table.d.ts +106 -0
- package/dist/table/data-table.d.ts.map +1 -0
- package/dist/table/data-table.js +408 -0
- package/dist/table/data-table.js.map +1 -0
- package/dist/table/index.d.ts +4 -0
- package/dist/table/index.d.ts.map +1 -0
- package/dist/table/index.js +6 -0
- package/dist/table/index.js.map +1 -0
- package/dist/table/styles.d.ts +2 -0
- package/dist/table/styles.d.ts.map +1 -0
- package/dist/table/styles.js +32 -0
- package/dist/table/styles.js.map +1 -0
- package/dist/table/types.d.ts +48 -0
- package/dist/table/types.d.ts.map +1 -0
- package/dist/table/types.js +30 -0
- package/dist/table/types.js.map +1 -0
- package/dist/themes/boot.d.ts +7 -0
- package/dist/themes/boot.d.ts.map +1 -0
- package/dist/themes/boot.js +14 -0
- package/dist/themes/boot.js.map +1 -0
- package/dist/themes/choice.d.ts +16 -0
- package/dist/themes/choice.d.ts.map +1 -0
- package/dist/themes/choice.js +45 -0
- package/dist/themes/choice.js.map +1 -0
- package/dist/themes/data.d.ts +43 -0
- package/dist/themes/data.d.ts.map +1 -0
- package/dist/themes/data.js +408 -0
- package/dist/themes/data.js.map +1 -0
- package/dist/themes/index.d.ts +7 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/index.js +11 -0
- package/dist/themes/index.js.map +1 -0
- package/dist/themes/sheet.d.ts +16 -0
- package/dist/themes/sheet.d.ts.map +1 -0
- package/dist/themes/sheet.js +28 -0
- package/dist/themes/sheet.js.map +1 -0
- package/dist/themes/token-meanings.d.ts +3 -0
- package/dist/themes/token-meanings.d.ts.map +1 -0
- package/dist/themes/token-meanings.js +67 -0
- package/dist/themes/token-meanings.js.map +1 -0
- package/dist/themes/tokens-list.d.ts +14 -0
- package/dist/themes/tokens-list.d.ts.map +1 -0
- package/dist/themes/tokens-list.js +69 -0
- package/dist/themes/tokens-list.js.map +1 -0
- package/dist/tiles/index.d.ts +4 -0
- package/dist/tiles/index.d.ts.map +1 -0
- package/dist/tiles/index.js +6 -0
- package/dist/tiles/index.js.map +1 -0
- package/dist/tiles/stat-tiles.d.ts +40 -0
- package/dist/tiles/stat-tiles.d.ts.map +1 -0
- package/dist/tiles/stat-tiles.js +99 -0
- package/dist/tiles/stat-tiles.js.map +1 -0
- package/dist/tiles/styles.d.ts +2 -0
- package/dist/tiles/styles.d.ts.map +1 -0
- package/dist/tiles/styles.js +23 -0
- package/dist/tiles/styles.js.map +1 -0
- package/dist/tiles/types.d.ts +22 -0
- package/dist/tiles/types.d.ts.map +1 -0
- package/dist/tiles/types.js +2 -0
- package/dist/tiles/types.js.map +1 -0
- package/dist/transcript/follow-scroll.d.ts +21 -0
- package/dist/transcript/follow-scroll.d.ts.map +1 -0
- package/dist/transcript/follow-scroll.js +76 -0
- package/dist/transcript/follow-scroll.js.map +1 -0
- package/dist/transcript/index.d.ts +5 -0
- package/dist/transcript/index.d.ts.map +1 -0
- package/dist/transcript/index.js +7 -0
- package/dist/transcript/index.js.map +1 -0
- package/dist/transcript/styles.d.ts +2 -0
- package/dist/transcript/styles.d.ts.map +1 -0
- package/dist/transcript/styles.js +114 -0
- package/dist/transcript/styles.js.map +1 -0
- package/dist/transcript/tags.d.ts +6 -0
- package/dist/transcript/tags.d.ts.map +1 -0
- package/dist/transcript/tags.js +13 -0
- package/dist/transcript/tags.js.map +1 -0
- package/dist/transcript/tool-card.d.ts +16 -0
- package/dist/transcript/tool-card.d.ts.map +1 -0
- package/dist/transcript/tool-card.js +87 -0
- package/dist/transcript/tool-card.js.map +1 -0
- package/dist/transcript/transcript.d.ts +103 -0
- package/dist/transcript/transcript.d.ts.map +1 -0
- package/dist/transcript/transcript.js +397 -0
- package/dist/transcript/transcript.js.map +1 -0
- package/dist/transcript/types.d.ts +161 -0
- package/dist/transcript/types.d.ts.map +1 -0
- package/dist/transcript/types.js +25 -0
- package/dist/transcript/types.js.map +1 -0
- package/dist/tree/index.d.ts +2 -0
- package/dist/tree/index.d.ts.map +1 -0
- package/dist/tree/index.js +4 -0
- package/dist/tree/index.js.map +1 -0
- package/dist/tree/tree.d.ts +83 -0
- package/dist/tree/tree.d.ts.map +1 -0
- package/dist/tree/tree.js +251 -0
- package/dist/tree/tree.js.map +1 -0
- package/docs/charts.md +58 -0
- package/docs/check-table.md +40 -0
- package/docs/code.md +55 -0
- package/docs/data-table.md +57 -0
- package/docs/examples/charts.ts +61 -0
- package/docs/examples/check-table.ts +19 -0
- package/docs/examples/ci-pipeline.ts +271 -0
- package/docs/examples/code.ts +28 -0
- package/docs/examples/data-table.ts +39 -0
- package/docs/examples/graph.ts +57 -0
- package/docs/examples/lanes.ts +40 -0
- package/docs/examples/matrix.ts +56 -0
- package/docs/examples/page.css +34 -0
- package/docs/examples/segmented.ts +18 -0
- package/docs/examples/status.ts +30 -0
- package/docs/examples/theme.css +54 -0
- package/docs/examples/tiles.ts +27 -0
- package/docs/examples/transcript.ts +59 -0
- package/docs/examples/tree.ts +44 -0
- package/docs/graph.md +112 -0
- package/docs/lanes.md +48 -0
- package/docs/matrix.md +34 -0
- package/docs/page.md +87 -0
- package/docs/primitives.md +57 -0
- package/docs/strings.md +16 -0
- package/docs/theming.md +147 -0
- package/docs/tiles.md +40 -0
- package/docs/transcript.md +73 -0
- package/docs/tree.md +44 -0
- package/docs/tsconfig.json +20 -0
- package/package.json +177 -4
- package/src/charts/bar-chart.ts +74 -0
- package/src/charts/base.ts +188 -0
- package/src/charts/column-chart.ts +153 -0
- package/src/charts/heatmap.ts +129 -0
- package/src/charts/index.ts +10 -0
- package/src/charts/line-chart.ts +128 -0
- package/src/charts/scale.ts +61 -0
- package/src/charts/state-grid.ts +245 -0
- package/src/charts/types.ts +48 -0
- package/src/checks/check-table.ts +85 -0
- package/src/checks/index.ts +5 -0
- package/src/checks/styles.ts +31 -0
- package/src/checks/types.ts +48 -0
- package/src/code/code.ts +199 -0
- package/src/code/highlight.ts +378 -0
- package/src/code/index.ts +4 -0
- package/src/core/clock.ts +46 -0
- package/src/core/define.ts +7 -0
- package/src/core/events.ts +89 -0
- package/src/core/format.ts +25 -0
- package/src/core/frame.ts +5 -0
- package/src/core/strings.ts +11 -0
- package/src/core/tone.ts +14 -0
- package/src/count/count.ts +54 -0
- package/src/count/elapsed.ts +33 -0
- package/src/count/index.ts +4 -0
- package/src/define/all.ts +15 -0
- package/src/define/charts.ts +17 -0
- package/src/define/check-table.ts +9 -0
- package/src/define/code.ts +9 -0
- package/src/define/count.ts +11 -0
- package/src/define/data-table.ts +9 -0
- package/src/define/graph.ts +11 -0
- package/src/define/json-tree.ts +9 -0
- package/src/define/lanes.ts +9 -0
- package/src/define/markdown.ts +9 -0
- package/src/define/matrix.ts +9 -0
- package/src/define/segmented.ts +9 -0
- package/src/define/tiles.ts +11 -0
- package/src/define/transcript.ts +9 -0
- package/src/define/tree.ts +9 -0
- package/src/graph/arrange.ts +399 -0
- package/src/graph/card.ts +209 -0
- package/src/graph/host.ts +100 -0
- package/src/graph/icons.ts +23 -0
- package/src/graph/index.ts +16 -0
- package/src/graph/layered-graph.ts +417 -0
- package/src/graph/layout.ts +331 -0
- package/src/graph/marks.ts +42 -0
- package/src/graph/nav.ts +19 -0
- package/src/graph/pan-zoom.ts +219 -0
- package/src/graph/paths.ts +41 -0
- package/src/graph/place-card.ts +93 -0
- package/src/graph/strings.ts +86 -0
- package/src/graph/styles.ts +204 -0
- package/src/graph/types.ts +202 -0
- package/src/graph/view.ts +28 -0
- package/src/graph/views/dag.ts +294 -0
- package/src/graph/views/foot.ts +109 -0
- package/src/graph/views/node-table.ts +90 -0
- package/src/index.ts +27 -0
- package/src/json/index.ts +2 -0
- package/src/json/json-tree.ts +49 -0
- package/src/lanes/index.ts +6 -0
- package/src/lanes/lanes.ts +143 -0
- package/src/lanes/stack.ts +51 -0
- package/src/lanes/styles.ts +30 -0
- package/src/lanes/types.ts +51 -0
- package/src/markdown/cae-markdown.ts +64 -0
- package/src/markdown/highlight.ts +2 -0
- package/src/markdown/index.ts +5 -0
- package/src/markdown/markdown.ts +110 -0
- package/src/matrix/grid-step.ts +58 -0
- package/src/matrix/index.ts +6 -0
- package/src/matrix/mark-matrix.ts +285 -0
- package/src/matrix/styles.ts +48 -0
- package/src/matrix/types.ts +83 -0
- package/src/primitives/fact-line.ts +26 -0
- package/src/primitives/icon.ts +26 -0
- package/src/primitives/index.ts +12 -0
- package/src/primitives/legend.ts +56 -0
- package/src/primitives/pill.ts +58 -0
- package/src/primitives/roving-focus.ts +138 -0
- package/src/primitives/segmented.ts +92 -0
- package/src/primitives/share-bar.ts +94 -0
- package/src/primitives/states.ts +28 -0
- package/src/primitives/window.ts +65 -0
- package/src/styles/chips.ts +18 -0
- package/src/styles/facts.ts +7 -0
- package/src/styles/index.ts +19 -0
- package/src/styles/layout.ts +33 -0
- package/src/styles/marks.ts +30 -0
- package/src/styles/meter.ts +9 -0
- package/src/styles/motion.ts +27 -0
- package/src/styles/prose.ts +64 -0
- package/src/styles/reset.ts +13 -0
- package/src/styles/status.ts +52 -0
- package/src/styles/text.ts +21 -0
- package/src/styles/tokens.ts +35 -0
- package/src/table/data-table.ts +367 -0
- package/src/table/index.ts +5 -0
- package/src/table/styles.ts +32 -0
- package/src/table/types.ts +73 -0
- package/src/themes/boot.ts +14 -0
- package/src/themes/choice.ts +47 -0
- package/src/themes/data.ts +433 -0
- package/src/themes/index.ts +10 -0
- package/src/themes/sheet.ts +29 -0
- package/src/themes/token-meanings.ts +67 -0
- package/src/themes/tokens-list.ts +82 -0
- package/src/tiles/index.ts +5 -0
- package/src/tiles/stat-tiles.ts +92 -0
- package/src/tiles/styles.ts +23 -0
- package/src/tiles/types.ts +20 -0
- package/src/transcript/follow-scroll.ts +72 -0
- package/src/transcript/index.ts +6 -0
- package/src/transcript/styles.ts +114 -0
- package/src/transcript/tags.ts +18 -0
- package/src/transcript/tool-card.ts +103 -0
- package/src/transcript/transcript.ts +358 -0
- package/src/transcript/types.ts +167 -0
- package/src/tree/index.ts +3 -0
- package/src/tree/tree.ts +263 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { css, html, nothing, svg, type TemplateResult } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import type { Tone } from '../core/tone.js';
|
|
4
|
+
import type { LegendItem } from '../primitives/legend.js';
|
|
5
|
+
import { ChartElement } from './base.js';
|
|
6
|
+
import { LABEL_GAP, labelStride } from './scale.js';
|
|
7
|
+
|
|
8
|
+
/** One cell of a state grid: its state in words, the tone that colours it, and a fact of its own for the tooltip. */
|
|
9
|
+
export interface StateCell {
|
|
10
|
+
label: string;
|
|
11
|
+
tone: Tone;
|
|
12
|
+
tip?: string | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const CELL_H = 22;
|
|
16
|
+
const GAP = 2;
|
|
17
|
+
const M = { top: 2, right: 2, bottom: 22 };
|
|
18
|
+
/** The narrowest cell that still holds its mark. */
|
|
19
|
+
const MARK_MIN = 14;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A tone's fill: a failure and what needs attention stand out, a cell that ended well
|
|
23
|
+
* stays quiet, so the exceptions are what the eye finds first.
|
|
24
|
+
*/
|
|
25
|
+
export function stateFill(tone: Tone): string {
|
|
26
|
+
switch (tone) {
|
|
27
|
+
case 'failed':
|
|
28
|
+
return 'color-mix(in srgb, var(--status-failed) 72%, var(--card))';
|
|
29
|
+
case 'attention':
|
|
30
|
+
return 'color-mix(in srgb, var(--status-attention) 68%, var(--card))';
|
|
31
|
+
case 'running':
|
|
32
|
+
return 'color-mix(in srgb, var(--status-running) 60%, var(--card))';
|
|
33
|
+
case 'done':
|
|
34
|
+
return 'color-mix(in srgb, var(--status-done) 30%, var(--card))';
|
|
35
|
+
case 'muted':
|
|
36
|
+
return 'color-mix(in srgb, var(--text-muted) 26%, var(--card))';
|
|
37
|
+
default:
|
|
38
|
+
return 'color-mix(in srgb, var(--text) 12%, var(--card))';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The mark a tone takes in a cell, beside its colour: ✓ done, ✕ failed, ◌ attention; none for the others. */
|
|
43
|
+
export function stateMark(tone: Tone): string {
|
|
44
|
+
return tone === 'done' ? '✓' : tone === 'failed' ? '✕' : tone === 'attention' ? '◌' : '';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The order of the tones in a legend: the exceptions first, what ended well after. */
|
|
48
|
+
const TONE_ORDER: readonly Tone[] = ['failed', 'attention', 'running', 'done', 'muted', 'neutral'];
|
|
49
|
+
|
|
50
|
+
/** The textures that tell the states of one tone apart, after the first (plain): stripes, dots, crosshatch, lines. */
|
|
51
|
+
export const TEXTURES = ['', 'stripes', 'dots', 'cross', 'lines'] as const;
|
|
52
|
+
export type Texture = (typeof TEXTURES)[number];
|
|
53
|
+
|
|
54
|
+
/** Each state's texture, by `tone` and `label`: the first state of a tone plain, the next ones in `TEXTURES` order (again from the start past the fifth). */
|
|
55
|
+
export function texturesOf(states: readonly StateCell[]): Map<string, Texture> {
|
|
56
|
+
const n = new Map<Tone, number>();
|
|
57
|
+
const out = new Map<string, Texture>();
|
|
58
|
+
for (const s of states) {
|
|
59
|
+
const i = n.get(s.tone) ?? 0;
|
|
60
|
+
n.set(s.tone, i + 1);
|
|
61
|
+
out.set(stateKey(s), TEXTURES[i % TEXTURES.length]!);
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const stateKey = (c: StateCell): string => `${c.tone}\u0000${c.label}`;
|
|
67
|
+
|
|
68
|
+
/** A texture as a CSS background over a legend key's fill. */
|
|
69
|
+
function textureCss(t: Texture): string {
|
|
70
|
+
const ink = 'color-mix(in srgb, var(--text) 45%, transparent)';
|
|
71
|
+
switch (t) {
|
|
72
|
+
case 'stripes':
|
|
73
|
+
return `repeating-linear-gradient(45deg, ${ink} 0 1.5px, transparent 1.5px 4px)`;
|
|
74
|
+
case 'dots':
|
|
75
|
+
return `radial-gradient(${ink} 1px, transparent 1.3px) 0 0 / 4px 4px`;
|
|
76
|
+
case 'cross':
|
|
77
|
+
return `repeating-linear-gradient(45deg, ${ink} 0 1px, transparent 1px 4px), repeating-linear-gradient(-45deg, ${ink} 0 1px, transparent 1px 4px)`;
|
|
78
|
+
case 'lines':
|
|
79
|
+
return `repeating-linear-gradient(0deg, ${ink} 0 1.5px, transparent 1.5px 4px)`;
|
|
80
|
+
default:
|
|
81
|
+
return '';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Each state of the cells once: by tone (failed, attention, running, done, muted, neutral), then in the order the cells first give it. */
|
|
86
|
+
export function statesOf(cells: readonly (readonly (StateCell | null | undefined)[])[]): StateCell[] {
|
|
87
|
+
const seen = new Map<string, StateCell>();
|
|
88
|
+
for (const row of cells) for (const c of row) if (c && !seen.has(stateKey(c))) seen.set(stateKey(c), c);
|
|
89
|
+
return [...seen.values()].sort((a, b) => TONE_ORDER.indexOf(a.tone) - TONE_ORDER.indexOf(b.tone));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A state per row (`y`) and column (`x`), each cell coloured by its tone
|
|
94
|
+
* (`cells[row][column]`; a null cell is left empty): the states of hourly runs by day,
|
|
95
|
+
* say. The colour is never alone: a cell wide enough holds its tone's mark (✓ ✕ ◌), the
|
|
96
|
+
* states of one tone differ by a texture (the first plain, then stripes, dots,
|
|
97
|
+
* crosshatch, lines), the legend names every state with its texture, and pointing at a cell, or moving to it with the arrow keys
|
|
98
|
+
* (up and down by a row), shows its row, column, state and fact; the switch shows them
|
|
99
|
+
* all as a table of words.
|
|
100
|
+
*
|
|
101
|
+
* @tagname cae-state-grid
|
|
102
|
+
* @csspart plot - the grid
|
|
103
|
+
* @csspart table - the table of its states
|
|
104
|
+
* @csspart switch - the button between the two
|
|
105
|
+
* @csspart empty - what it shows with no cells
|
|
106
|
+
* @csspart legend - the legend
|
|
107
|
+
*/
|
|
108
|
+
export class CaeStateGrid extends ChartElement {
|
|
109
|
+
static override styles = [
|
|
110
|
+
...ChartElement.styles,
|
|
111
|
+
css`
|
|
112
|
+
.mark { font-size: 11px; font-weight: 700; fill: var(--text); pointer-events: none; }
|
|
113
|
+
/* a cell that ended well keeps its mark, quietly: the exceptions are what the eye finds */
|
|
114
|
+
.mark.quiet { font-weight: 400; fill: var(--text-muted); }
|
|
115
|
+
.legend .key { display: inline-grid; place-items: center; width: 14px; height: 14px; margin-right: 6px; border-radius: 3px;
|
|
116
|
+
font-size: 9.5px; font-weight: 700; color: var(--text); vertical-align: -2px; }
|
|
117
|
+
`,
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
@property({ attribute: false }) x: readonly string[] = [];
|
|
121
|
+
@property({ attribute: false }) y: readonly string[] = [];
|
|
122
|
+
@property({ attribute: false }) cells: readonly (readonly (StateCell | null)[])[] = [];
|
|
123
|
+
|
|
124
|
+
protected hasValues(): boolean {
|
|
125
|
+
return this.x.length > 0 && this.y.length > 0 && this.cells.some((r) => r.some((c) => !!c));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
protected legendItems(): LegendItem[] {
|
|
129
|
+
const states = statesOf(this.cells);
|
|
130
|
+
const textures = texturesOf(states);
|
|
131
|
+
return states.map((s) => {
|
|
132
|
+
const t = textureCss(textures.get(stateKey(s)) ?? '');
|
|
133
|
+
return {
|
|
134
|
+
label: s.label,
|
|
135
|
+
icon: html`<span class="key" aria-hidden="true" data-texture=${textures.get(stateKey(s)) || nothing}
|
|
136
|
+
style="background: ${t ? `${t}, ` : ''}${stateFill(s.tone)}">${stateMark(s.tone)}</span>`,
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
protected itemCount(): number {
|
|
142
|
+
return this.x.length * this.y.length;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
protected override rowLength(): number {
|
|
146
|
+
return this.x.length;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
protected plot(): TemplateResult {
|
|
150
|
+
const nx = this.x.length;
|
|
151
|
+
const ny = this.y.length;
|
|
152
|
+
const left = Math.max(...this.y.map((s) => this.labelWidth(s))) + 2;
|
|
153
|
+
const w = this.plotWidth;
|
|
154
|
+
const pw = w - left - M.right;
|
|
155
|
+
const cw = pw / nx;
|
|
156
|
+
const h = M.top + ny * CELL_H + M.bottom;
|
|
157
|
+
const stride = labelStride(nx, pw, Math.max(...this.x.map((s) => this.labelWidth(s))) + LABEL_GAP);
|
|
158
|
+
const a = this.active;
|
|
159
|
+
const marked = cw - GAP >= MARK_MIN;
|
|
160
|
+
const textures = texturesOf(statesOf(this.cells));
|
|
161
|
+
const cells: TemplateResult[] = [];
|
|
162
|
+
for (let r = 0; r < ny; r++)
|
|
163
|
+
for (let c = 0; c < nx; c++) {
|
|
164
|
+
const cell = this.cells[r]?.[c];
|
|
165
|
+
const x = left + c * cw;
|
|
166
|
+
const y = M.top + r * CELL_H;
|
|
167
|
+
const i = r * nx + c;
|
|
168
|
+
const box = { x: x + GAP / 2, y: y + GAP / 2, w: Math.max(1, cw - GAP), h: CELL_H - GAP };
|
|
169
|
+
if (!cell) {
|
|
170
|
+
cells.push(svg`<rect x=${box.x} y=${box.y} width=${box.w} height=${box.h} rx="2" fill="none" stroke="var(--line)"
|
|
171
|
+
@mouseenter=${() => (this.active = i)}></rect>`);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const mark = marked ? stateMark(cell.tone) : '';
|
|
175
|
+
const texture = textures.get(stateKey(cell)) ?? '';
|
|
176
|
+
cells.push(svg`<g @mouseenter=${() => (this.active = i)}>
|
|
177
|
+
<rect x=${box.x} y=${box.y} width=${box.w} height=${box.h} rx="2" fill=${stateFill(cell.tone)}
|
|
178
|
+
stroke=${a === i ? 'var(--text)' : 'none'} stroke-width="1.5"></rect>
|
|
179
|
+
${texture ? svg`<rect class="texture" data-texture=${texture} x=${box.x} y=${box.y} width=${box.w} height=${box.h} rx="2" fill=${`url(#${this.patternId(texture)})`} pointer-events="none"></rect>` : nothing}
|
|
180
|
+
${mark ? svg`<text class=${cell.tone === 'done' ? 'mark quiet' : 'mark'} x=${box.x + box.w / 2} y=${box.y + box.h / 2} dy="0.35em" text-anchor="middle" aria-hidden="true">${mark}</text>` : nothing}
|
|
181
|
+
</g>`);
|
|
182
|
+
}
|
|
183
|
+
const at = a !== null && a < nx * ny ? { r: Math.floor(a / nx), c: a % nx } : null;
|
|
184
|
+
return html`<svg width=${w} height=${h} role="img" aria-label=${this.label || nothing}>
|
|
185
|
+
${this.patterns(new Set(textures.values()))}
|
|
186
|
+
${this.y.map((label, r) => svg`<text class="axis" x=${left - 6} y=${M.top + r * CELL_H + CELL_H / 2} dy="0.32em" text-anchor="end">${label}</text>`)}
|
|
187
|
+
${cells}
|
|
188
|
+
${this.x.map((label, c) =>
|
|
189
|
+
c % stride === 0 ? svg`<text class="axis" x=${left + c * cw + cw / 2} y=${h - 6} text-anchor="middle">${label}</text>` : nothing,
|
|
190
|
+
)}
|
|
191
|
+
</svg>
|
|
192
|
+
${at ? this.tip(left + at.c * cw + cw / 2, M.top + (at.r + 1) * CELL_H, this.tipBody(at.r, at.c)) : nothing}`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** One id per element and texture: two grids in a page keep their own patterns. */
|
|
196
|
+
private readonly uid = `sg${Math.random().toString(36).slice(2, 8)}`;
|
|
197
|
+
|
|
198
|
+
private patternId(t: Texture): string {
|
|
199
|
+
return `${this.uid}-${t}`;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** The SVG patterns of the textures in use, drawn in the text's colour over a cell's fill. */
|
|
203
|
+
private patterns(used: ReadonlySet<Texture>): TemplateResult {
|
|
204
|
+
const line = (d: string) => svg`<path d=${d} stroke="var(--text)" stroke-opacity="0.45" stroke-width="1.2"></path>`;
|
|
205
|
+
const body = (t: Texture) =>
|
|
206
|
+
t === 'stripes'
|
|
207
|
+
? line('M-1 1 L1 -1 M0 5 L5 0 M4 6 L6 4')
|
|
208
|
+
: t === 'dots'
|
|
209
|
+
? svg`<circle cx="2.5" cy="2.5" r="0.9" fill="var(--text)" fill-opacity="0.5"></circle>`
|
|
210
|
+
: t === 'cross'
|
|
211
|
+
? line('M0 0 L5 5 M5 0 L0 5')
|
|
212
|
+
: line('M0 2.5 L5 2.5');
|
|
213
|
+
return svg`<defs>${[...used].filter((t) => t).map(
|
|
214
|
+
(t) => svg`<pattern id=${this.patternId(t)} width="5" height="5" patternUnits="userSpaceOnUse">${body(t)}</pattern>`,
|
|
215
|
+
)}</defs>`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
private tipBody(r: number, c: number): TemplateResult {
|
|
219
|
+
const cell = this.cells[r]?.[c];
|
|
220
|
+
return html`<b>${this.y[r]} | ${this.x[c]}</b>
|
|
221
|
+
<div class="row">${cell
|
|
222
|
+
? html`<i style="background: ${stateFill(cell.tone)}"></i><span>${cell.label}</span>`
|
|
223
|
+
: html`<span>${this.words.none}</span>`}</div>
|
|
224
|
+
${cell?.tip ? html`<div class="row"><span>${cell.tip}</span></div>` : nothing}`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
protected table(): TemplateResult {
|
|
228
|
+
const none = this.words.none;
|
|
229
|
+
return html`<table aria-label=${this.label || nothing}>
|
|
230
|
+
<thead><tr><th scope="col">${this.words.label}</th>${this.x.map((l) => html`<th scope="col">${l}</th>`)}</tr></thead>
|
|
231
|
+
<tbody>${this.y.map(
|
|
232
|
+
(label, r) => html`<tr><th scope="row">${label}</th>${this.x.map((_, c) => {
|
|
233
|
+
const cell = this.cells[r]?.[c];
|
|
234
|
+
return html`<td title=${cell?.tip || nothing}>${cell ? cell.label : none}</td>`;
|
|
235
|
+
})}</tr>`,
|
|
236
|
+
)}</tbody>
|
|
237
|
+
</table>`;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
declare global {
|
|
242
|
+
interface HTMLElementTagNameMap {
|
|
243
|
+
'cae-state-grid': CaeStateGrid;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// What the charts take: plain series of numbers, and their words.
|
|
2
|
+
import type { Tone } from '../core/tone.js';
|
|
3
|
+
|
|
4
|
+
/** One series: a value per label of the chart's `x`, in that order; null where it has none. */
|
|
5
|
+
export interface ChartSeries {
|
|
6
|
+
name: string;
|
|
7
|
+
values: readonly (number | null)[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** One horizontal bar: its label and value; `tone` gives it a status colour. */
|
|
11
|
+
export interface ChartBar {
|
|
12
|
+
label: string;
|
|
13
|
+
value: number;
|
|
14
|
+
tone?: Tone;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A number in words (`$1.20`, `42%`, `2m 05s`): the host's format for the chart's unit. */
|
|
18
|
+
export type ValueText = (value: number) => string;
|
|
19
|
+
|
|
20
|
+
/** The words of a chart. */
|
|
21
|
+
export interface ChartStrings {
|
|
22
|
+
/** What a chart with nothing to draw says. */
|
|
23
|
+
empty: string;
|
|
24
|
+
/** The button that shows the values as a table, and the one that shows the chart again. */
|
|
25
|
+
showTable: string;
|
|
26
|
+
showChart: string;
|
|
27
|
+
/** The column of a table view that holds the labels of `x` (or of the bars). */
|
|
28
|
+
label: string;
|
|
29
|
+
/** The name of the series past the sixth, folded into one. */
|
|
30
|
+
other: string;
|
|
31
|
+
/** The sum of a label's stacked series. */
|
|
32
|
+
total: string;
|
|
33
|
+
/** A value a series has not (null). */
|
|
34
|
+
none: string;
|
|
35
|
+
/** The heatmap's colour scale: its lowest and highest value. */
|
|
36
|
+
scale: (low: string, high: string) => string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const DEFAULT_CHART_STRINGS: ChartStrings = {
|
|
40
|
+
empty: 'No values',
|
|
41
|
+
showTable: 'Show table',
|
|
42
|
+
showChart: 'Show chart',
|
|
43
|
+
label: 'Label',
|
|
44
|
+
other: 'Other',
|
|
45
|
+
total: 'Total',
|
|
46
|
+
none: '—',
|
|
47
|
+
scale: (low, high) => `${low} to ${high}`,
|
|
48
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { LitElement, html, nothing, type TemplateResult } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { withDefaults } from '../core/strings.js';
|
|
4
|
+
import { base } from '../styles/index.js';
|
|
5
|
+
import { checkTableStyles, verdictStyles } from './styles.js';
|
|
6
|
+
import { DEFAULT_CHECK_TABLE_STRINGS, type CheckRow, type CheckTableStrings, type Verdict } from './types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A verdict in words (`.verdict`, `data-verdict`; `verdictStyles`): ✓ before a
|
|
10
|
+
* pass, ✕ before a failure, hidden from screen readers, which read the word.
|
|
11
|
+
* Nothing for `none` without a word.
|
|
12
|
+
*/
|
|
13
|
+
export function verdict(v: Verdict, label: string, tip = ''): TemplateResult | typeof nothing {
|
|
14
|
+
if (v === 'none' && !label) return nothing;
|
|
15
|
+
const mark = v === 'pass' ? '✓' : v === 'fail' ? '✕' : '';
|
|
16
|
+
return html`<span class="verdict" part="verdict" data-verdict=${v} title=${tip || nothing}>${mark
|
|
17
|
+
? html`<span aria-hidden="true">${mark}</span> `
|
|
18
|
+
: nothing}${label}</span>`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const cut = (s: string, n: number) => (s.length > n ? `${s.slice(0, n)}…` : s);
|
|
22
|
+
|
|
23
|
+
/** A value in a line: a string quoted and cut, a list's length and first items, an object's first keys. */
|
|
24
|
+
function shortValue(v: unknown, s: CheckTableStrings): TemplateResult {
|
|
25
|
+
if (v === undefined) return html`<span class="jdim">—</span>`;
|
|
26
|
+
if (typeof v === 'string') return html`<span class="js" title=${v}>"${cut(v, 90)}"</span>`;
|
|
27
|
+
if (Array.isArray(v)) {
|
|
28
|
+
const head = v
|
|
29
|
+
.slice(0, 3)
|
|
30
|
+
.map((x) => (typeof x === 'string' ? `"${cut(x, 28)}"` : JSON.stringify(x)))
|
|
31
|
+
.join(', ');
|
|
32
|
+
return html`<span class="jn">${s.items(v.length)}</span>
|
|
33
|
+
<span class="jdim">${head}${v.length > 3 ? ', …' : ''}</span>`;
|
|
34
|
+
}
|
|
35
|
+
if (v !== null && typeof v === 'object') return html`<span class="jn">${s.object}</span> <span class="jdim">${Object.keys(v).slice(0, 4).join(', ')}</span>`;
|
|
36
|
+
return html`<span class="jn">${JSON.stringify(v)}</span>`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Named values checked one by one: a row per name, with what it must be, what
|
|
41
|
+
* it is and the verdict. Without `showValues`, only the names and what each
|
|
42
|
+
* must be (nothing to check them against).
|
|
43
|
+
*
|
|
44
|
+
* @tagname cae-check-table
|
|
45
|
+
* @csspart table - the `<table>`
|
|
46
|
+
* @csspart row - each row of a name
|
|
47
|
+
* @csspart verdict - each verdict
|
|
48
|
+
*/
|
|
49
|
+
export class CaeCheckTable extends LitElement {
|
|
50
|
+
static override styles = [base, verdictStyles, checkTableStyles];
|
|
51
|
+
|
|
52
|
+
@property({ attribute: false }) rows: readonly CheckRow[] = [];
|
|
53
|
+
/** Show the values and the verdicts. */
|
|
54
|
+
@property({ type: Boolean }) showValues = true;
|
|
55
|
+
@property({ attribute: false }) strings: Partial<CheckTableStrings> = {};
|
|
56
|
+
|
|
57
|
+
override render() {
|
|
58
|
+
const s = withDefaults(DEFAULT_CHECK_TABLE_STRINGS, this.strings);
|
|
59
|
+
const all = this.showValues;
|
|
60
|
+
return html`<table part="table">
|
|
61
|
+
<thead><tr>
|
|
62
|
+
<th scope="col">${s.name}</th><th scope="col">${s.expected}</th>
|
|
63
|
+
${all ? html`<th scope="col">${s.actual}</th><th scope="col">${s.verdict}</th>` : nothing}
|
|
64
|
+
</tr></thead>
|
|
65
|
+
<tbody>
|
|
66
|
+
${this.rows.map(
|
|
67
|
+
(r) => html`<tr part="row">
|
|
68
|
+
<td class="jmono">${r.name}</td>
|
|
69
|
+
<td class=${r.extra ? 'jdim' : 'jmono jdim'}>${r.expected}${r.optional ? html` <i>${s.optional}</i>` : nothing}</td>
|
|
70
|
+
${all
|
|
71
|
+
? html`<td class="value">${shortValue(r.hasValue ? r.value : undefined, s)}</td>
|
|
72
|
+
<td>${verdict(r.verdict, r.verdictLabel, r.tip)}</td>`
|
|
73
|
+
: nothing}
|
|
74
|
+
</tr>`,
|
|
75
|
+
)}
|
|
76
|
+
</tbody>
|
|
77
|
+
</table>`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare global {
|
|
82
|
+
interface HTMLElementTagNameMap {
|
|
83
|
+
'cae-check-table': CaeCheckTable;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// The look of `<cae-check-table>`, and of a verdict (`verdict()`) wherever a
|
|
2
|
+
// host shows one.
|
|
3
|
+
import { css } from 'lit';
|
|
4
|
+
|
|
5
|
+
/** A verdict: ✓ and its word quiet, ✕ and its word in the failed tone, a warning in the attention tone. */
|
|
6
|
+
export const verdictStyles = css`
|
|
7
|
+
.verdict { font-size: 12px; }
|
|
8
|
+
.verdict[data-verdict='pass'] { color: var(--text-2); }
|
|
9
|
+
.verdict[data-verdict='pass'] > [aria-hidden] { color: var(--status-done); font-weight: 700; }
|
|
10
|
+
.verdict[data-verdict='fail'] { color: var(--status-failed); font-weight: 600; }
|
|
11
|
+
.verdict[data-verdict='warn'] { color: var(--status-attention); }
|
|
12
|
+
.verdict[data-verdict='none'] { color: var(--text-muted); }
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
/** Sized to its content, so a verdict sits next to the value it judges; a long value wraps. */
|
|
16
|
+
export const checkTableStyles = css`
|
|
17
|
+
:host { display: block; max-width: 100%; }
|
|
18
|
+
table { width: auto; max-width: 100%; border-collapse: collapse; }
|
|
19
|
+
th { text-align: left; font-size: 11.5px; color: var(--text-muted);
|
|
20
|
+
font-weight: 600; padding: 4px 20px 4px 0; border-bottom: 1px solid var(--line); }
|
|
21
|
+
td { padding: 5px 20px 5px 0; border: 0; border-bottom: 1px solid var(--line); vertical-align: baseline; font-size: 12.5px; }
|
|
22
|
+
th:last-child, td:last-child { padding-right: 0; }
|
|
23
|
+
td.value { overflow-wrap: anywhere; }
|
|
24
|
+
tbody tr:last-child td { border-bottom: 0; }
|
|
25
|
+
/* a name stays on one line while the table has the room, and breaks where it must */
|
|
26
|
+
td:first-child { font-weight: 600; overflow-wrap: anywhere; }
|
|
27
|
+
td:last-child { white-space: nowrap; }
|
|
28
|
+
i { font-style: normal; color: var(--text-muted); font-size: 11px; margin-left: 4px; }
|
|
29
|
+
.js { color: var(--code-string); }
|
|
30
|
+
.jn { color: var(--code-number); }
|
|
31
|
+
`;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// What `<cae-check-table>` shows: a row per named value, what it must be, what
|
|
2
|
+
// it is, and the verdict.
|
|
3
|
+
|
|
4
|
+
/** A check's result: passed, failed, a warning, or no verdict (a word may still say why). */
|
|
5
|
+
export type Verdict = 'pass' | 'fail' | 'warn' | 'none';
|
|
6
|
+
|
|
7
|
+
export interface CheckRow {
|
|
8
|
+
/** What is checked: a field's name. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** What it must be: a type, in code; with `extra`, a phrase. */
|
|
11
|
+
expected: string;
|
|
12
|
+
/** It may be absent: "optional" follows `expected`. */
|
|
13
|
+
optional?: boolean;
|
|
14
|
+
/** Not one of the expected names: `expected` is a phrase, not code. */
|
|
15
|
+
extra?: boolean;
|
|
16
|
+
/** The value was found (`value`, possibly undefined or null); else "—". */
|
|
17
|
+
hasValue: boolean;
|
|
18
|
+
value?: unknown;
|
|
19
|
+
verdict: Verdict;
|
|
20
|
+
/** The verdict in words; '' with `none` for an empty cell. */
|
|
21
|
+
verdictLabel: string;
|
|
22
|
+
/** The verdict's tooltip. */
|
|
23
|
+
tip?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CheckTableStrings {
|
|
27
|
+
/** The header of the names. */
|
|
28
|
+
name: string;
|
|
29
|
+
expected: string;
|
|
30
|
+
/** The header of the values. */
|
|
31
|
+
actual: string;
|
|
32
|
+
verdict: string;
|
|
33
|
+
optional: string;
|
|
34
|
+
/** A list's length. */
|
|
35
|
+
items: (n: number) => string;
|
|
36
|
+
/** An object's summary, before its first keys. */
|
|
37
|
+
object: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const DEFAULT_CHECK_TABLE_STRINGS: CheckTableStrings = {
|
|
41
|
+
name: 'Name',
|
|
42
|
+
expected: 'Expected',
|
|
43
|
+
actual: 'Value',
|
|
44
|
+
verdict: 'Check',
|
|
45
|
+
optional: 'optional',
|
|
46
|
+
items: (n) => (n === 1 ? '1 item' : `${n} items`),
|
|
47
|
+
object: 'object',
|
|
48
|
+
};
|
package/src/code/code.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { LitElement, css, html, nothing, type PropertyValues } from 'lit';
|
|
2
|
+
import { property, state } from 'lit/decorators.js';
|
|
3
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
4
|
+
import { withDefaults } from '../core/strings.js';
|
|
5
|
+
import { base, prose } from '../styles/index.js';
|
|
6
|
+
import { languageOf, tokenLines, tokenize, tokensHtml } from './highlight.js';
|
|
7
|
+
|
|
8
|
+
/** A line marked in a text: its number, or the first and the last of a range, both included. */
|
|
9
|
+
export type LineMark = number | readonly [number, number];
|
|
10
|
+
|
|
11
|
+
export interface CodeStrings {
|
|
12
|
+
/** The button that copies the whole text. */
|
|
13
|
+
copy: string;
|
|
14
|
+
/** What the copy button says for a moment after the text was copied. */
|
|
15
|
+
copied: string;
|
|
16
|
+
/** The switch between long lines wrapped and scrolled sideways. */
|
|
17
|
+
wrap: string;
|
|
18
|
+
/** What a text with no characters shows. */
|
|
19
|
+
empty: string;
|
|
20
|
+
/** The note under a text cut short: the lines shown of all its lines. */
|
|
21
|
+
cut: (shown: number, total: number) => string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const DEFAULT_CODE_STRINGS: Readonly<CodeStrings> = {
|
|
25
|
+
copy: 'Copy',
|
|
26
|
+
copied: 'Copied',
|
|
27
|
+
wrap: 'Wrap lines',
|
|
28
|
+
empty: 'No text',
|
|
29
|
+
cut: (shown, total) => `First ${shown.toLocaleString('en')} of ${total.toLocaleString('en')} lines`,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** What of a text is shown. */
|
|
33
|
+
export interface ShownText {
|
|
34
|
+
/** The text shown: its first lines. */
|
|
35
|
+
shown: string;
|
|
36
|
+
/** The number of lines shown. */
|
|
37
|
+
lines: number;
|
|
38
|
+
/** The number of lines of the whole text (a last line break ends the last line). */
|
|
39
|
+
total: number;
|
|
40
|
+
/** Less than the whole text is shown. */
|
|
41
|
+
cut: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The first lines of `text`: at most `maxLines` lines and `maxCharacters` characters, cut
|
|
46
|
+
* at the end of a line (a first line longer than that is cut inside it).
|
|
47
|
+
*/
|
|
48
|
+
export function shownText(text: string, maxLines: number, maxCharacters: number): ShownText {
|
|
49
|
+
const all = text.endsWith('\n') ? text.slice(0, -1) : text;
|
|
50
|
+
let total = all || text ? 1 : 0;
|
|
51
|
+
for (let i = all.indexOf('\n'); i >= 0; i = all.indexOf('\n', i + 1)) total++;
|
|
52
|
+
let end = 0;
|
|
53
|
+
let lines = 0;
|
|
54
|
+
while (lines < Math.max(1, maxLines)) {
|
|
55
|
+
const next = all.indexOf('\n', end);
|
|
56
|
+
const stop = next < 0 ? all.length : next;
|
|
57
|
+
if (lines > 0 && stop > maxCharacters) break;
|
|
58
|
+
lines++;
|
|
59
|
+
if (next < 0) {
|
|
60
|
+
end = all.length;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
end = next + 1;
|
|
64
|
+
}
|
|
65
|
+
let shown = lines >= total ? all : all.slice(0, end - 1);
|
|
66
|
+
if (shown.length > maxCharacters) shown = shown.slice(0, maxCharacters);
|
|
67
|
+
return { shown, lines: total ? lines : 0, total, cut: shown.length < all.length };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Whether line `n` is in one of `marks`. */
|
|
71
|
+
export function isMarked(marks: readonly LineMark[], n: number): boolean {
|
|
72
|
+
return marks.some((m) => (typeof m === 'number' ? m === n : n >= m[0] && n <= m[1]));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A text shown as code: highlighted by its `language` (`LANGUAGES`, another name of one
|
|
77
|
+
* or a file name; anything else is plain), each line numbered from `start`, the lines of
|
|
78
|
+
* `highlight` marked (a bar beside the number and a tint). Long lines scroll sideways,
|
|
79
|
+
* or wrap with `wrap` or the reader's switch. A text of more than `maxLines` lines or
|
|
80
|
+
* `maxCharacters` characters shows its first lines and says how many it has; the copy
|
|
81
|
+
* button copies the whole text. The line numbers are not part of a selection.
|
|
82
|
+
*
|
|
83
|
+
* @tagname cae-code
|
|
84
|
+
* @csspart header - the path, the language and the buttons
|
|
85
|
+
* @csspart code - the lines, which scroll
|
|
86
|
+
* @csspart cut - the note under a text cut short
|
|
87
|
+
*/
|
|
88
|
+
export class CaeCode extends LitElement {
|
|
89
|
+
static override styles = [
|
|
90
|
+
base,
|
|
91
|
+
prose,
|
|
92
|
+
css`
|
|
93
|
+
:host { display: block; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--well); overflow: hidden; }
|
|
94
|
+
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 4px 6px 4px 10px; border-bottom: 1px solid var(--line); font-size: var(--font-size-sm); color: var(--text-2); }
|
|
95
|
+
.path { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
|
96
|
+
.lang { color: var(--text-muted); }
|
|
97
|
+
.tools { margin-left: auto; display: flex; gap: 4px; flex: none; }
|
|
98
|
+
.tools button { font-size: var(--font-size-sm); color: var(--text-2); border: 1px solid var(--line2); border-radius: var(--radius-pill); padding: 0 9px; cursor: pointer; background: none; }
|
|
99
|
+
.tools button[aria-pressed='true'] { background: var(--raise); color: var(--text); }
|
|
100
|
+
.scroll { overflow: auto; max-height: var(--cae-code-max-height, 70vh); font-family: var(--mono); font-size: var(--font-size-md); line-height: 1.5; }
|
|
101
|
+
.lines { display: block; min-width: max-content; padding: 4px 0; }
|
|
102
|
+
.wrap .lines { min-width: 0; }
|
|
103
|
+
.ln { display: flex; }
|
|
104
|
+
/* the number is the line's own: drawn by CSS, so a selection of lines copies no numbers */
|
|
105
|
+
.ln::before { content: attr(data-n); position: sticky; left: 0; flex: none; box-sizing: border-box; width: calc(var(--digits) * 1ch + 22px);
|
|
106
|
+
padding: 0 10px 0 8px; text-align: right; color: var(--text-muted); background: var(--well); border-left: 3px solid transparent; }
|
|
107
|
+
.t { flex: 1; white-space: pre; padding-right: 12px; }
|
|
108
|
+
.t:empty::after { content: ' '; }
|
|
109
|
+
.wrap .t { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
110
|
+
.ln[data-mark] { background: color-mix(in srgb, var(--accent) 6%, transparent); }
|
|
111
|
+
.hl-doc { opacity: 1; }
|
|
112
|
+
.ln[data-mark]::before { border-left-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 14%, var(--well)); }
|
|
113
|
+
.cut, .empty { padding: 4px 10px; font-size: var(--font-size-sm); color: var(--text-muted); border-top: 1px solid var(--line); }
|
|
114
|
+
.empty { border-top: 0; }
|
|
115
|
+
`,
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
/** The text. */
|
|
119
|
+
@property() code = '';
|
|
120
|
+
/** Its language: a name of `LANGUAGES`, another name of one, or a file name; anything else is plain text. */
|
|
121
|
+
@property() language = '';
|
|
122
|
+
/** The number of the first line. */
|
|
123
|
+
@property({ type: Number }) start = 1;
|
|
124
|
+
/** The lines marked, in the numbers shown. */
|
|
125
|
+
@property({ attribute: false }) highlight: readonly LineMark[] = [];
|
|
126
|
+
/** The file the text is, named over it. */
|
|
127
|
+
@property() path = '';
|
|
128
|
+
/** What the lines are named to a screen reader (default: the path). */
|
|
129
|
+
@property() label = '';
|
|
130
|
+
/** Long lines wrap at first; the reader's switch changes it. */
|
|
131
|
+
@property({ type: Boolean }) wrap = false;
|
|
132
|
+
/** The most lines shown. */
|
|
133
|
+
@property({ type: Number }) maxLines = 5000;
|
|
134
|
+
/** The most characters shown, at the end of a line. */
|
|
135
|
+
@property({ type: Number }) maxCharacters = 500_000;
|
|
136
|
+
/** The visible words; English by default. */
|
|
137
|
+
@property({ attribute: false }) strings: Partial<CodeStrings> = {};
|
|
138
|
+
|
|
139
|
+
@state() private wrapped = false;
|
|
140
|
+
@state() private copied = false;
|
|
141
|
+
private copiedTimer: ReturnType<typeof setTimeout> | undefined;
|
|
142
|
+
|
|
143
|
+
override willUpdate(changed: PropertyValues<this>): void {
|
|
144
|
+
if (changed.has('wrap')) this.wrapped = this.wrap;
|
|
145
|
+
if (changed.has('code')) this.copied = false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
override disconnectedCallback(): void {
|
|
149
|
+
super.disconnectedCallback();
|
|
150
|
+
clearTimeout(this.copiedTimer);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private async copy(): Promise<void> {
|
|
154
|
+
try {
|
|
155
|
+
await navigator.clipboard.writeText(this.code);
|
|
156
|
+
} catch {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
this.copied = true;
|
|
160
|
+
clearTimeout(this.copiedTimer);
|
|
161
|
+
this.copiedTimer = setTimeout(() => (this.copied = false), 1500);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
override render() {
|
|
165
|
+
const s = withDefaults(DEFAULT_CODE_STRINGS, this.strings);
|
|
166
|
+
const lang = languageOf(this.language);
|
|
167
|
+
const { shown, lines, total, cut } = shownText(this.code, this.maxLines, this.maxCharacters);
|
|
168
|
+
const last = this.start + Math.max(lines, 1) - 1;
|
|
169
|
+
const rows = tokenLines(tokenize(shown, lang))
|
|
170
|
+
.map((line, i) => {
|
|
171
|
+
const n = this.start + i;
|
|
172
|
+
return `<div class="ln" data-n="${n}"${isMarked(this.highlight, n) ? ' data-mark=""' : ''}><span class="t">${tokensHtml(line)}</span></div>`;
|
|
173
|
+
})
|
|
174
|
+
.join('');
|
|
175
|
+
return html`<div class="head" part="header">
|
|
176
|
+
${this.path ? html`<span class="path" title=${this.path}>${this.path}</span>` : nothing}
|
|
177
|
+
${lang ? html`<span class="lang">${lang}</span>` : nothing}
|
|
178
|
+
<span class="tools">
|
|
179
|
+
<button type="button" aria-pressed=${this.wrapped ? 'true' : 'false'} @click=${() => (this.wrapped = !this.wrapped)}>${s.wrap}</button>
|
|
180
|
+
<button type="button" ?disabled=${!this.code} @click=${() => void this.copy()}>${this.copied ? s.copied : s.copy}</button>
|
|
181
|
+
</span>
|
|
182
|
+
<span class="sr" role="status">${this.copied ? s.copied : ''}</span>
|
|
183
|
+
</div>
|
|
184
|
+
${this.code
|
|
185
|
+
? html`<div class="scroll ${this.wrapped ? 'wrap' : ''}" part="code" data-scroll=${this.wrapped ? 'y' : 'x'} tabindex="0" role=${this.label || this.path ? 'region' : nothing}
|
|
186
|
+
aria-label=${this.label || this.path || nothing}
|
|
187
|
+
style="--digits: ${String(last).length}">
|
|
188
|
+
<code class="lines hl">${unsafeHTML(rows)}</code>
|
|
189
|
+
</div>
|
|
190
|
+
${cut ? html`<div class="cut" part="cut">${s.cut(lines, total)}</div>` : nothing}`
|
|
191
|
+
: html`<div class="empty">${s.empty}</div>`}`;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
declare global {
|
|
196
|
+
interface HTMLElementTagNameMap {
|
|
197
|
+
'cae-code': CaeCode;
|
|
198
|
+
}
|
|
199
|
+
}
|