@react-x11/components 0.9.0 → 0.11.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 +10 -4
- package/dist/charts/node.d.ts +11 -1
- package/dist/charts/node.d.ts.map +1 -1
- package/dist/charts/node.js +44 -14
- package/dist/charts/node.js.map +1 -1
- package/dist/charts/render.d.ts +12 -3
- package/dist/charts/render.d.ts.map +1 -1
- package/dist/charts/render.js +94 -25
- package/dist/charts/render.js.map +1 -1
- package/dist/code/index.d.ts.map +1 -1
- package/dist/code/index.js +27 -24
- package/dist/code/index.js.map +1 -1
- package/dist/code-editor/completion.d.ts.map +1 -1
- package/dist/code-editor/completion.js +3 -2
- package/dist/code-editor/completion.js.map +1 -1
- package/dist/code-editor/index.d.ts.map +1 -1
- package/dist/code-editor/index.js +19 -0
- package/dist/code-editor/index.js.map +1 -1
- package/dist/code-editor/node.d.ts +177 -7
- package/dist/code-editor/node.d.ts.map +1 -1
- package/dist/code-editor/node.js +1329 -164
- package/dist/code-editor/node.js.map +1 -1
- package/dist/code-language/index.d.ts +1 -1
- package/dist/code-language/index.d.ts.map +1 -1
- package/dist/code-language/index.js +1 -1
- package/dist/code-language/index.js.map +1 -1
- package/dist/code-language/languages/glsl.d.ts.map +1 -1
- package/dist/code-language/languages/glsl.js +10 -2
- package/dist/code-language/languages/glsl.js.map +1 -1
- package/dist/code-language/languages/javascript.d.ts.map +1 -1
- package/dist/code-language/languages/javascript.js +18 -3
- package/dist/code-language/languages/javascript.js.map +1 -1
- package/dist/code-language/languages/json.d.ts.map +1 -1
- package/dist/code-language/languages/json.js +10 -2
- package/dist/code-language/languages/json.js.map +1 -1
- package/dist/code-language/languages/shell.d.ts.map +1 -1
- package/dist/code-language/languages/shell.js +10 -2
- package/dist/code-language/languages/shell.js.map +1 -1
- package/dist/code-language/languages/sql.d.ts.map +1 -1
- package/dist/code-language/languages/sql.js +20 -2
- package/dist/code-language/languages/sql.js.map +1 -1
- package/dist/code-language/runs.d.ts +31 -0
- package/dist/code-language/runs.d.ts.map +1 -1
- package/dist/code-language/runs.js +105 -0
- package/dist/code-language/runs.js.map +1 -1
- package/dist/code-language/stream.d.ts +22 -0
- package/dist/code-language/stream.d.ts.map +1 -1
- package/dist/code-language/stream.js +259 -9
- package/dist/code-language/stream.js.map +1 -1
- package/dist/code-language/types.d.ts +5 -4
- package/dist/code-language/types.d.ts.map +1 -1
- package/dist/codeblock/index.d.ts +26 -2
- package/dist/codeblock/index.d.ts.map +1 -1
- package/dist/codeblock/index.js +57 -4
- package/dist/codeblock/index.js.map +1 -1
- package/dist/flow/draw.d.ts +50 -0
- package/dist/flow/draw.d.ts.map +1 -1
- package/dist/flow/draw.js +132 -33
- package/dist/flow/draw.js.map +1 -1
- package/dist/flow/gl/color.d.ts +13 -0
- package/dist/flow/gl/color.d.ts.map +1 -0
- package/dist/flow/gl/color.js +82 -0
- package/dist/flow/gl/color.js.map +1 -0
- package/dist/flow/gl/index.d.ts +60 -0
- package/dist/flow/gl/index.d.ts.map +1 -0
- package/dist/flow/gl/index.js +283 -0
- package/dist/flow/gl/index.js.map +1 -0
- package/dist/flow/gl/pack.d.ts +133 -0
- package/dist/flow/gl/pack.d.ts.map +1 -0
- package/dist/flow/gl/pack.js +408 -0
- package/dist/flow/gl/pack.js.map +1 -0
- package/dist/flow/gl/renderer.d.ts +95 -0
- package/dist/flow/gl/renderer.d.ts.map +1 -0
- package/dist/flow/gl/renderer.js +459 -0
- package/dist/flow/gl/renderer.js.map +1 -0
- package/dist/flow/gl/shaders.d.ts +79 -0
- package/dist/flow/gl/shaders.d.ts.map +1 -0
- package/dist/flow/gl/shaders.js +346 -0
- package/dist/flow/gl/shaders.js.map +1 -0
- package/dist/flow/gl/text.d.ts +318 -0
- package/dist/flow/gl/text.d.ts.map +1 -0
- package/dist/flow/gl/text.js +1103 -0
- package/dist/flow/gl/text.js.map +1 -0
- package/dist/flow/index.d.ts +1 -1
- package/dist/flow/index.d.ts.map +1 -1
- package/dist/flow/index.js +619 -64
- package/dist/flow/index.js.map +1 -1
- package/dist/flow/node.d.ts +621 -72
- package/dist/flow/node.d.ts.map +1 -1
- package/dist/flow/node.js +2253 -1018
- package/dist/flow/node.js.map +1 -1
- package/dist/flow/paint.d.ts +35 -0
- package/dist/flow/paint.d.ts.map +1 -0
- package/dist/flow/paint.js +393 -0
- package/dist/flow/paint.js.map +1 -0
- package/dist/flow/paths.d.ts +14 -0
- package/dist/flow/paths.d.ts.map +1 -1
- package/dist/flow/paths.js +45 -19
- package/dist/flow/paths.js.map +1 -1
- package/dist/flow/scene.d.ts +584 -0
- package/dist/flow/scene.d.ts.map +1 -0
- package/dist/flow/scene.js +1453 -0
- package/dist/flow/scene.js.map +1 -0
- package/dist/flow/types.d.ts +111 -1
- package/dist/flow/types.d.ts.map +1 -1
- package/dist/html/controls.d.ts +28 -0
- package/dist/html/controls.d.ts.map +1 -1
- package/dist/html/controls.js +52 -2
- package/dist/html/controls.js.map +1 -1
- package/dist/html/css/calc.d.ts +14 -0
- package/dist/html/css/calc.d.ts.map +1 -0
- package/dist/html/css/calc.js +344 -0
- package/dist/html/css/calc.js.map +1 -0
- package/dist/html/css/cascade.d.ts +262 -6
- package/dist/html/css/cascade.d.ts.map +1 -1
- package/dist/html/css/cascade.js +1373 -67
- package/dist/html/css/cascade.js.map +1 -1
- package/dist/html/css/color.d.ts +23 -0
- package/dist/html/css/color.d.ts.map +1 -0
- package/dist/html/css/color.js +740 -0
- package/dist/html/css/color.js.map +1 -0
- package/dist/html/css/content.d.ts +92 -0
- package/dist/html/css/content.d.ts.map +1 -0
- package/dist/html/css/content.js +388 -0
- package/dist/html/css/content.js.map +1 -0
- package/dist/html/css/counter-styles.d.ts +76 -0
- package/dist/html/css/counter-styles.d.ts.map +1 -0
- package/dist/html/css/counter-styles.js +893 -0
- package/dist/html/css/counter-styles.js.map +1 -0
- package/dist/html/css/decode.d.ts +12 -0
- package/dist/html/css/decode.d.ts.map +1 -0
- package/dist/html/css/decode.js +116 -0
- package/dist/html/css/decode.js.map +1 -0
- package/dist/html/css/parse.d.ts +110 -10
- package/dist/html/css/parse.d.ts.map +1 -1
- package/dist/html/css/parse.js +1473 -180
- package/dist/html/css/parse.js.map +1 -1
- package/dist/html/css/style.d.ts +501 -15
- package/dist/html/css/style.d.ts.map +1 -1
- package/dist/html/css/style.js +3729 -206
- package/dist/html/css/style.js.map +1 -1
- package/dist/html/css/ua.d.ts.map +1 -1
- package/dist/html/css/ua.js +65 -16
- package/dist/html/css/ua.js.map +1 -1
- package/dist/html/css/values.d.ts +37 -3
- package/dist/html/css/values.d.ts.map +1 -1
- package/dist/html/css/values.js +122 -48
- package/dist/html/css/values.js.map +1 -1
- package/dist/html/css/vars.d.ts +52 -0
- package/dist/html/css/vars.d.ts.map +1 -0
- package/dist/html/css/vars.js +358 -0
- package/dist/html/css/vars.js.map +1 -0
- package/dist/html/dom.d.ts +30 -4
- package/dist/html/dom.d.ts.map +1 -1
- package/dist/html/dom.js +278 -17
- package/dist/html/dom.js.map +1 -1
- package/dist/html/fonts.d.ts +106 -0
- package/dist/html/fonts.d.ts.map +1 -0
- package/dist/html/fonts.js +565 -0
- package/dist/html/fonts.js.map +1 -0
- package/dist/html/gif.d.ts +15 -0
- package/dist/html/gif.d.ts.map +1 -0
- package/dist/html/gif.js +229 -0
- package/dist/html/gif.js.map +1 -0
- package/dist/html/index.d.ts +50 -11
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +115 -9
- package/dist/html/index.js.map +1 -1
- package/dist/html/layout/block.d.ts +226 -3
- package/dist/html/layout/block.d.ts.map +1 -1
- package/dist/html/layout/block.js +3077 -219
- package/dist/html/layout/block.js.map +1 -1
- package/dist/html/layout/boxes.d.ts +367 -17
- package/dist/html/layout/boxes.d.ts.map +1 -1
- package/dist/html/layout/boxes.js +1742 -182
- package/dist/html/layout/boxes.js.map +1 -1
- package/dist/html/layout/cache.d.ts +58 -0
- package/dist/html/layout/cache.d.ts.map +1 -0
- package/dist/html/layout/cache.js +224 -0
- package/dist/html/layout/cache.js.map +1 -0
- package/dist/html/layout/collapse.d.ts +45 -0
- package/dist/html/layout/collapse.d.ts.map +1 -0
- package/dist/html/layout/collapse.js +246 -0
- package/dist/html/layout/collapse.js.map +1 -0
- package/dist/html/layout/css-grid.d.ts +7 -0
- package/dist/html/layout/css-grid.d.ts.map +1 -0
- package/dist/html/layout/css-grid.js +900 -0
- package/dist/html/layout/css-grid.js.map +1 -0
- package/dist/html/layout/flex.d.ts.map +1 -1
- package/dist/html/layout/flex.js +1025 -89
- package/dist/html/layout/flex.js.map +1 -1
- package/dist/html/layout/floats.d.ts +45 -6
- package/dist/html/layout/floats.d.ts.map +1 -1
- package/dist/html/layout/floats.js +113 -14
- package/dist/html/layout/floats.js.map +1 -1
- package/dist/html/layout/grid-lines.d.ts +39 -0
- package/dist/html/layout/grid-lines.d.ts.map +1 -0
- package/dist/html/layout/grid-lines.js +119 -0
- package/dist/html/layout/grid-lines.js.map +1 -0
- package/dist/html/layout/grid.d.ts +53 -0
- package/dist/html/layout/grid.d.ts.map +1 -0
- package/dist/html/layout/grid.js +153 -0
- package/dist/html/layout/grid.js.map +1 -0
- package/dist/html/layout/inline.d.ts +154 -1
- package/dist/html/layout/inline.d.ts.map +1 -1
- package/dist/html/layout/inline.js +3598 -175
- package/dist/html/layout/inline.js.map +1 -1
- package/dist/html/layout/shaping.d.ts +6 -0
- package/dist/html/layout/shaping.d.ts.map +1 -0
- package/dist/html/layout/shaping.js +100 -0
- package/dist/html/layout/shaping.js.map +1 -0
- package/dist/html/layout/table.d.ts +3 -0
- package/dist/html/layout/table.d.ts.map +1 -1
- package/dist/html/layout/table.js +681 -175
- package/dist/html/layout/table.js.map +1 -1
- package/dist/html/layout/tracks.d.ts +44 -0
- package/dist/html/layout/tracks.d.ts.map +1 -0
- package/dist/html/layout/tracks.js +349 -0
- package/dist/html/layout/tracks.js.map +1 -0
- package/dist/html/node.d.ts +169 -4
- package/dist/html/node.d.ts.map +1 -1
- package/dist/html/node.js +1429 -137
- package/dist/html/node.js.map +1 -1
- package/dist/html/paint.d.ts +92 -3
- package/dist/html/paint.d.ts.map +1 -1
- package/dist/html/paint.js +3635 -107
- package/dist/html/paint.js.map +1 -1
- package/dist/html/resources.d.ts +60 -14
- package/dist/html/resources.d.ts.map +1 -1
- package/dist/html/resources.js +122 -36
- package/dist/html/resources.js.map +1 -1
- package/dist/html/surfaces.d.ts +23 -0
- package/dist/html/surfaces.d.ts.map +1 -0
- package/dist/html/surfaces.js +68 -0
- package/dist/html/surfaces.js.map +1 -0
- package/dist/html/svg.d.ts +80 -0
- package/dist/html/svg.d.ts.map +1 -0
- package/dist/html/svg.js +442 -0
- package/dist/html/svg.js.map +1 -0
- package/dist/html/url.d.ts +23 -0
- package/dist/html/url.d.ts.map +1 -0
- package/dist/html/url.js +80 -0
- package/dist/html/url.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/codelines.d.ts +42 -0
- package/dist/internal/codelines.d.ts.map +1 -0
- package/dist/internal/codelines.js +170 -0
- package/dist/internal/codelines.js.map +1 -0
- package/dist/internal/collate.d.ts +3 -0
- package/dist/internal/collate.d.ts.map +1 -0
- package/dist/internal/collate.js +11 -0
- package/dist/internal/collate.js.map +1 -0
- package/dist/internal/markdown/ast.d.ts +11 -0
- package/dist/internal/markdown/ast.d.ts.map +1 -1
- package/dist/internal/markdown/parse.d.ts.map +1 -1
- package/dist/internal/markdown/parse.js +109 -8
- package/dist/internal/markdown/parse.js.map +1 -1
- package/dist/internal/prewarm.d.ts +18 -0
- package/dist/internal/prewarm.d.ts.map +1 -0
- package/dist/internal/prewarm.js +42 -0
- package/dist/internal/prewarm.js.map +1 -0
- package/dist/internal/sdf.d.ts +20 -0
- package/dist/internal/sdf.d.ts.map +1 -0
- package/dist/internal/sdf.js +216 -0
- package/dist/internal/sdf.js.map +1 -0
- package/dist/internal/splice.d.ts +12 -0
- package/dist/internal/splice.d.ts.map +1 -0
- package/dist/internal/splice.js +23 -0
- package/dist/internal/splice.js.map +1 -0
- package/dist/internal/window.d.ts +12 -0
- package/dist/internal/window.d.ts.map +1 -1
- package/dist/internal/window.js +23 -6
- package/dist/internal/window.js.map +1 -1
- package/dist/maps/anchors.d.ts +6 -1
- package/dist/maps/anchors.d.ts.map +1 -1
- package/dist/maps/anchors.js +260 -1
- package/dist/maps/anchors.js.map +1 -1
- package/dist/maps/controller.d.ts +57 -0
- package/dist/maps/controller.d.ts.map +1 -1
- package/dist/maps/controller.js +97 -18
- package/dist/maps/controller.js.map +1 -1
- package/dist/maps/gl/buckets.d.ts +5 -1
- package/dist/maps/gl/buckets.d.ts.map +1 -1
- package/dist/maps/gl/buckets.js +5 -2
- package/dist/maps/gl/buckets.js.map +1 -1
- package/dist/maps/gl/build-worker.d.ts +2 -0
- package/dist/maps/gl/build-worker.d.ts.map +1 -1
- package/dist/maps/gl/build-worker.js +1 -1
- package/dist/maps/gl/build-worker.js.map +1 -1
- package/dist/maps/gl/cover.d.ts +23 -4
- package/dist/maps/gl/cover.d.ts.map +1 -1
- package/dist/maps/gl/cover.js +61 -48
- package/dist/maps/gl/cover.js.map +1 -1
- package/dist/maps/gl/placement.d.ts +21 -8
- package/dist/maps/gl/placement.d.ts.map +1 -1
- package/dist/maps/gl/placement.js +133 -58
- package/dist/maps/gl/placement.js.map +1 -1
- package/dist/maps/gl/renderer.d.ts +36 -4
- package/dist/maps/gl/renderer.d.ts.map +1 -1
- package/dist/maps/gl/renderer.js +81 -24
- package/dist/maps/gl/renderer.js.map +1 -1
- package/dist/maps/gl/shaders.d.ts +18 -17
- package/dist/maps/gl/shaders.d.ts.map +1 -1
- package/dist/maps/gl/shaders.js +34 -32
- package/dist/maps/gl/shaders.js.map +1 -1
- package/dist/maps/gl/store.d.ts +10 -0
- package/dist/maps/gl/store.d.ts.map +1 -1
- package/dist/maps/gl/store.js +47 -4
- package/dist/maps/gl/store.js.map +1 -1
- package/dist/maps/gl/text.d.ts +153 -24
- package/dist/maps/gl/text.d.ts.map +1 -1
- package/dist/maps/gl/text.js +379 -63
- package/dist/maps/gl/text.js.map +1 -1
- package/dist/maps/gl/view.d.ts +293 -2
- package/dist/maps/gl/view.d.ts.map +1 -1
- package/dist/maps/gl/view.js +317 -82
- package/dist/maps/gl/view.js.map +1 -1
- package/dist/maps/icons.d.ts +32 -0
- package/dist/maps/icons.d.ts.map +1 -0
- package/dist/maps/icons.js +151 -0
- package/dist/maps/icons.js.map +1 -0
- package/dist/maps/index.d.ts +2 -0
- package/dist/maps/index.d.ts.map +1 -1
- package/dist/maps/index.js +2 -0
- package/dist/maps/index.js.map +1 -1
- package/dist/maps/labels.d.ts +56 -4
- package/dist/maps/labels.d.ts.map +1 -1
- package/dist/maps/labels.js +213 -46
- package/dist/maps/labels.js.map +1 -1
- package/dist/maps/node.d.ts +17 -0
- package/dist/maps/node.d.ts.map +1 -1
- package/dist/maps/node.js +64 -30
- package/dist/maps/node.js.map +1 -1
- package/dist/maps/proj.d.ts +48 -0
- package/dist/maps/proj.d.ts.map +1 -1
- package/dist/maps/proj.js +73 -0
- package/dist/maps/proj.js.map +1 -1
- package/dist/maps/sources.d.ts +5 -3
- package/dist/maps/sources.d.ts.map +1 -1
- package/dist/maps/sources.js +5 -3
- package/dist/maps/sources.js.map +1 -1
- package/dist/maps/style.d.ts +35 -0
- package/dist/maps/style.d.ts.map +1 -1
- package/dist/maps/style.js.map +1 -1
- package/dist/maps/styles.d.ts +12 -0
- package/dist/maps/styles.d.ts.map +1 -1
- package/dist/maps/styles.js +120 -6
- package/dist/maps/styles.js.map +1 -1
- package/dist/maps/tiles.d.ts +31 -11
- package/dist/maps/tiles.d.ts.map +1 -1
- package/dist/maps/tiles.js +61 -27
- package/dist/maps/tiles.js.map +1 -1
- package/dist/maps/types.d.ts +28 -4
- package/dist/maps/types.d.ts.map +1 -1
- package/dist/markdown/index.d.ts.map +1 -1
- package/dist/markdown/index.js +209 -68
- package/dist/markdown/index.js.map +1 -1
- package/dist/markdown/spans.d.ts.map +1 -1
- package/dist/markdown/spans.js +6 -0
- package/dist/markdown/spans.js.map +1 -1
- package/dist/qml/containers.d.ts.map +1 -1
- package/dist/qml/containers.js +6 -1
- package/dist/qml/containers.js.map +1 -1
- package/dist/qml/interaction.d.ts.map +1 -1
- package/dist/qml/interaction.js +38 -5
- package/dist/qml/interaction.js.map +1 -1
- package/dist/qml/layouts.d.ts.map +1 -1
- package/dist/qml/layouts.js +21 -6
- package/dist/qml/layouts.js.map +1 -1
- package/dist/qml/qtquick.d.ts.map +1 -1
- package/dist/qml/qtquick.js +9 -2
- package/dist/qml/qtquick.js.map +1 -1
- package/dist/qml/react.d.ts.map +1 -1
- package/dist/qml/react.js +9 -7
- package/dist/qml/react.js.map +1 -1
- package/dist/reorder/clock.d.ts +7 -0
- package/dist/reorder/clock.d.ts.map +1 -0
- package/dist/reorder/clock.js +26 -0
- package/dist/reorder/clock.js.map +1 -0
- package/dist/reorder/index.d.ts +25 -3
- package/dist/reorder/index.d.ts.map +1 -1
- package/dist/reorder/index.js +64 -19
- package/dist/reorder/index.js.map +1 -1
- package/dist/rich-text-editor/index.d.ts +0 -11
- package/dist/rich-text-editor/index.d.ts.map +1 -1
- package/dist/rich-text-editor/index.js +38 -9
- package/dist/rich-text-editor/index.js.map +1 -1
- package/dist/rich-text-editor/keymap.d.ts.map +1 -1
- package/dist/rich-text-editor/keymap.js +2 -1
- package/dist/rich-text-editor/keymap.js.map +1 -1
- package/dist/rich-text-editor/keys.d.ts +17 -6
- package/dist/rich-text-editor/keys.d.ts.map +1 -1
- package/dist/rich-text-editor/keys.js +135 -26
- package/dist/rich-text-editor/keys.js.map +1 -1
- package/dist/rich-text-editor/markdown.d.ts.map +1 -1
- package/dist/rich-text-editor/markdown.js +30 -1
- package/dist/rich-text-editor/markdown.js.map +1 -1
- package/dist/rich-text-editor/marks.d.ts +9 -0
- package/dist/rich-text-editor/marks.d.ts.map +1 -0
- package/dist/rich-text-editor/marks.js +83 -0
- package/dist/rich-text-editor/marks.js.map +1 -0
- package/dist/rich-text-editor/render.d.ts.map +1 -1
- package/dist/rich-text-editor/render.js +28 -10
- package/dist/rich-text-editor/render.js.map +1 -1
- package/dist/rich-text-editor/replace.d.ts +13 -0
- package/dist/rich-text-editor/replace.d.ts.map +1 -0
- package/dist/rich-text-editor/replace.js +64 -0
- package/dist/rich-text-editor/replace.js.map +1 -0
- package/dist/rich-text-editor/toolbar.d.ts.map +1 -1
- package/dist/rich-text-editor/toolbar.js +1 -1
- package/dist/rich-text-editor/toolbar.js.map +1 -1
- package/dist/rich-text-editor/virtual.d.ts.map +1 -1
- package/dist/rich-text-editor/virtual.js +17 -0
- package/dist/rich-text-editor/virtual.js.map +1 -1
- package/dist/richtext/node.d.ts +46 -2
- package/dist/richtext/node.d.ts.map +1 -1
- package/dist/richtext/node.js +187 -4
- package/dist/richtext/node.js.map +1 -1
- package/dist/richtext/runs.d.ts +13 -8
- package/dist/richtext/runs.d.ts.map +1 -1
- package/dist/richtext/runs.js +18 -8
- package/dist/richtext/runs.js.map +1 -1
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/index.js +23 -0
- package/dist/table/index.js.map +1 -1
- package/dist/table/rows.d.ts +3 -2
- package/dist/table/rows.d.ts.map +1 -1
- package/dist/table/rows.js +20 -6
- package/dist/table/rows.js.map +1 -1
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +4 -0
- package/dist/terminal/index.js.map +1 -1
- package/dist/terminal/vt/pty.d.ts +13 -2
- package/dist/terminal/vt/pty.d.ts.map +1 -1
- package/dist/terminal/vt/pty.js +18 -3
- package/dist/terminal/vt/pty.js.map +1 -1
- package/dist/terminal-output/index.d.ts.map +1 -1
- package/dist/terminal-output/index.js +103 -23
- package/dist/terminal-output/index.js.map +1 -1
- package/dist/terminal-output/runs.d.ts +4 -1
- package/dist/terminal-output/runs.d.ts.map +1 -1
- package/dist/terminal-output/runs.js +5 -1
- package/dist/terminal-output/runs.js.map +1 -1
- package/dist/three/canvas.d.ts.map +1 -1
- package/dist/three/canvas.js +85 -7
- package/dist/three/canvas.js.map +1 -1
- package/dist/three/events.d.ts +22 -4
- package/dist/three/events.d.ts.map +1 -1
- package/dist/three/events.js +34 -4
- package/dist/three/events.js.map +1 -1
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/tree/index.js +17 -0
- package/dist/tree/index.js.map +1 -1
- package/package.json +42 -33
- package/src/charts/node.ts +62 -26
- package/src/charts/render.ts +120 -30
- package/src/code/index.ts +36 -32
- package/src/code-editor/completion.ts +3 -2
- package/src/code-editor/index.ts +19 -0
- package/src/code-editor/node.ts +1574 -184
- package/src/code-language/index.ts +1 -1
- package/src/code-language/languages/glsl.ts +12 -2
- package/src/code-language/languages/javascript.ts +21 -4
- package/src/code-language/languages/json.ts +12 -2
- package/src/code-language/languages/shell.ts +12 -2
- package/src/code-language/languages/sql.ts +22 -2
- package/src/code-language/runs.ts +111 -1
- package/src/code-language/stream.ts +257 -17
- package/src/code-language/types.ts +5 -4
- package/src/codeblock/index.ts +68 -4
- package/src/flow/draw.ts +167 -41
- package/src/flow/gl/color.ts +85 -0
- package/src/flow/gl/index.ts +342 -0
- package/src/flow/gl/pack.ts +585 -0
- package/src/flow/gl/renderer.ts +679 -0
- package/src/flow/gl/shaders.ts +371 -0
- package/src/flow/gl/text.ts +1295 -0
- package/src/flow/index.ts +794 -67
- package/src/flow/node.ts +2496 -1256
- package/src/flow/paint.ts +511 -0
- package/src/flow/paths.ts +80 -15
- package/src/flow/scene.ts +2199 -0
- package/src/flow/types.ts +113 -1
- package/src/html/controls.ts +73 -2
- package/src/html/css/calc.ts +385 -0
- package/src/html/css/cascade.ts +1481 -62
- package/src/html/css/color.ts +755 -0
- package/src/html/css/content.ts +417 -0
- package/src/html/css/counter-styles.ts +973 -0
- package/src/html/css/decode.ts +130 -0
- package/src/html/css/parse.ts +1514 -160
- package/src/html/css/style.ts +4131 -223
- package/src/html/css/ua.ts +66 -17
- package/src/html/css/values.ts +150 -50
- package/src/html/css/vars.ts +348 -0
- package/src/html/dom.ts +284 -17
- package/src/html/fonts.ts +641 -0
- package/src/html/gif.ts +233 -0
- package/src/html/index.ts +180 -20
- package/src/html/layout/block.ts +3560 -208
- package/src/html/layout/boxes.ts +2141 -190
- package/src/html/layout/cache.ts +289 -0
- package/src/html/layout/collapse.ts +317 -0
- package/src/html/layout/css-grid.ts +1063 -0
- package/src/html/layout/flex.ts +1115 -106
- package/src/html/layout/floats.ts +128 -14
- package/src/html/layout/grid-lines.ts +141 -0
- package/src/html/layout/grid.ts +181 -0
- package/src/html/layout/inline.ts +4187 -192
- package/src/html/layout/shaping.ts +140 -0
- package/src/html/layout/table.ts +696 -186
- package/src/html/layout/tracks.ts +437 -0
- package/src/html/node.ts +1585 -156
- package/src/html/paint.ts +4582 -267
- package/src/html/resources.ts +161 -50
- package/src/html/surfaces.ts +81 -0
- package/src/html/svg.ts +504 -0
- package/src/html/url.ts +86 -0
- package/src/index.ts +2 -0
- package/src/internal/codelines.ts +200 -0
- package/src/internal/collate.ts +12 -0
- package/src/internal/markdown/ast.ts +11 -0
- package/src/internal/markdown/parse.ts +154 -11
- package/src/internal/prewarm.ts +45 -0
- package/src/internal/sdf.ts +227 -0
- package/src/internal/splice.ts +25 -0
- package/src/internal/window.ts +36 -5
- package/src/maps/anchors.ts +307 -1
- package/src/maps/controller.ts +116 -31
- package/src/maps/gl/buckets.ts +5 -1
- package/src/maps/gl/build-worker.ts +13 -2
- package/src/maps/gl/cover.ts +79 -44
- package/src/maps/gl/placement.ts +221 -69
- package/src/maps/gl/renderer.ts +104 -20
- package/src/maps/gl/shaders.ts +35 -32
- package/src/maps/gl/store.ts +66 -17
- package/src/maps/gl/text.ts +444 -71
- package/src/maps/gl/view.ts +361 -96
- package/src/maps/icons.ts +183 -0
- package/src/maps/index.ts +4 -0
- package/src/maps/labels.ts +269 -49
- package/src/maps/node.ts +82 -49
- package/src/maps/proj.ts +87 -0
- package/src/maps/sources.ts +5 -3
- package/src/maps/style.ts +32 -0
- package/src/maps/styles.ts +215 -4
- package/src/maps/tiles.ts +64 -31
- package/src/maps/types.ts +28 -4
- package/src/markdown/index.ts +293 -92
- package/src/markdown/spans.ts +5 -0
- package/src/qml/containers.tsx +6 -1
- package/src/qml/interaction.tsx +42 -5
- package/src/qml/layouts.tsx +21 -6
- package/src/qml/qtquick.tsx +9 -2
- package/src/qml/react.tsx +7 -5
- package/src/reorder/clock.ts +27 -0
- package/src/reorder/index.ts +100 -27
- package/src/rich-text-editor/index.ts +37 -12
- package/src/rich-text-editor/keymap.ts +1 -1
- package/src/rich-text-editor/keys.ts +135 -26
- package/src/rich-text-editor/markdown.ts +36 -1
- package/src/rich-text-editor/marks.ts +101 -0
- package/src/rich-text-editor/render.ts +49 -12
- package/src/rich-text-editor/replace.ts +85 -0
- package/src/rich-text-editor/toolbar.ts +1 -1
- package/src/rich-text-editor/virtual.ts +25 -0
- package/src/richtext/node.ts +235 -14
- package/src/richtext/runs.ts +23 -12
- package/src/table/index.ts +29 -0
- package/src/table/rows.ts +18 -8
- package/src/terminal/index.ts +4 -0
- package/src/terminal/vt/pty.ts +16 -2
- package/src/terminal-output/index.ts +129 -31
- package/src/terminal-output/runs.ts +16 -2
- package/src/three/canvas.ts +102 -8
- package/src/three/events.ts +49 -9
- package/src/tree/index.ts +19 -0
|
@@ -12,76 +12,151 @@
|
|
|
12
12
|
// beside it because that is the one an author reaches for when the auto
|
|
13
13
|
// algorithm is too slow — which, on a table with a thousand rows, it is.
|
|
14
14
|
import { AUTO, isPct, resolveOrNull } from '../css/values.js';
|
|
15
|
-
import { Box } from './boxes.js';
|
|
16
|
-
import { measureIntrinsicWidth, moveTo, resolveEdges } from './block.js';
|
|
15
|
+
import { Box, CLIPPED_CELLS, COLLAPSED_CELLS, isBlank } from './boxes.js';
|
|
16
|
+
import { CELL_CONTENT, MIN_CONTENT_PROBE, clampHeight, exactMinContent, layoutBlockIn, measureIntrinsicWidth, moveContent, moveTo, resolveEdges, } from './block.js';
|
|
17
|
+
import { firstBaselineIn } from './inline.js';
|
|
18
|
+
import { tableGrid } from './grid.js';
|
|
17
19
|
/** Lay out a table's insides. Returns the content height. */
|
|
18
20
|
export function layoutTable(table, ctx, contentWidth) {
|
|
19
|
-
const rows =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const { rows, captions, cells, columnCount, columnBoxes, columnGroups } = tableGrid(table);
|
|
22
|
+
table.captionTop = 0;
|
|
23
|
+
table.captionBottom = 0;
|
|
24
|
+
if (!columnCount) {
|
|
25
|
+
// With no columns, an auto table is as wide as its widest caption can
|
|
26
|
+
// be and its `min-width` asks, as one with columns is at the least
|
|
27
|
+
// (17.5.2), rather than as the room on offer: a caption over no cells
|
|
28
|
+
// was centred in the width of the page.
|
|
29
|
+
if (table.style.width === AUTO) {
|
|
30
|
+
let inner = captions.length
|
|
31
|
+
? captionMinimum(captions, ctx) - table.horizontalExtra
|
|
32
|
+
: 0;
|
|
33
|
+
const min = resolveOrNull(table.style.minWidth, contentWidth);
|
|
34
|
+
if (min !== null) {
|
|
35
|
+
inner = Math.max(inner, table.style.boxSizing === 'border-box'
|
|
36
|
+
? min - table.horizontalExtra
|
|
37
|
+
: min);
|
|
28
38
|
}
|
|
39
|
+
table.width = Math.max(0, inner) + table.horizontalExtra;
|
|
29
40
|
}
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
layoutCaptions(captions, ctx, table);
|
|
42
|
+
return 0;
|
|
32
43
|
}
|
|
33
|
-
const { cells, columnCount } = gridOf(rows);
|
|
34
|
-
if (!columnCount)
|
|
35
|
-
return layoutCaptionsOnly(captions, ctx, table, contentWidth);
|
|
36
44
|
const style = table.style;
|
|
37
|
-
|
|
45
|
+
// between the columns, and between the rows (CSS 2.1 17.6.1)
|
|
46
|
+
const apart = style.borderCollapse !== 'collapse';
|
|
47
|
+
const spacing = apart ? style.borderSpacing : 0;
|
|
48
|
+
const rowSpacing = apart ? style.borderSpacingY : 0;
|
|
38
49
|
const gaps = spacing * (columnCount + 1);
|
|
39
50
|
const available = Math.max(0, contentWidth - gaps);
|
|
40
51
|
for (const cell of cells)
|
|
41
52
|
resolveEdges(cell.box, contentWidth);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
// a fixed layout needs a width to be fixed to; with `auto` a table is laid
|
|
54
|
+
// out by its contents after all (CSS 2.1 17.5.2.1)
|
|
55
|
+
const fixed = style.tableLayout === 'fixed' && style.width !== AUTO;
|
|
56
|
+
// a percentage of the table's width less its spacing (CSS 2.1 17.5.2.1)
|
|
57
|
+
const set = columnWidths(columnBoxes, columnGroups, available);
|
|
58
|
+
const widths = fixed
|
|
59
|
+
? fixedColumns(cells, set, columnCount, available, spacing)
|
|
60
|
+
: autoColumns(cells, set, columnCount, available, ctx, contentWidth, style.width !== AUTO, spacing);
|
|
45
61
|
// --- place ---------------------------------------------------------------
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
// An auto table is at least as wide as its widest caption can be (CSS 2.1
|
|
63
|
+
// 17.5.2), and as its `min-width` asks; the columns share what that adds.
|
|
64
|
+
if (style.width === AUTO) {
|
|
65
|
+
let room = 0;
|
|
66
|
+
if (captions.length) {
|
|
67
|
+
room = captionMinimum(captions, ctx) - table.horizontalExtra - gaps;
|
|
68
|
+
}
|
|
69
|
+
const min = resolveOrNull(style.minWidth, contentWidth);
|
|
70
|
+
if (min !== null) {
|
|
71
|
+
const inner = style.boxSizing === 'border-box' ? min - table.horizontalExtra : min;
|
|
72
|
+
room = Math.max(room, inner - gaps);
|
|
73
|
+
}
|
|
74
|
+
const sum = widths.reduce((a, b) => a + b, 0);
|
|
75
|
+
if (room > sum) {
|
|
76
|
+
for (let c = 0; c < columnCount; c += 1) {
|
|
77
|
+
widths[c] +=
|
|
78
|
+
sum > 0
|
|
79
|
+
? (widths[c] / sum) * (room - sum)
|
|
80
|
+
: (room - sum) / columnCount;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
52
83
|
}
|
|
84
|
+
// A column that `visibility: collapse` takes out of the table has been
|
|
85
|
+
// sized with the rest, and is no room at all where they are placed (CSS
|
|
86
|
+
// 2.1 17.5.5): no width, and no spacing after it. Its cells are still
|
|
87
|
+
// laid out at the width they would have had, so that taking it out
|
|
88
|
+
// changes no row's height.
|
|
53
89
|
const columnX = new Array(columnCount);
|
|
90
|
+
const gone = new Array(columnCount);
|
|
91
|
+
let anyGone = false;
|
|
54
92
|
let x = table.contentX + spacing;
|
|
55
93
|
for (let c = 0; c < columnCount; c += 1) {
|
|
56
94
|
columnX[c] = x;
|
|
57
|
-
|
|
95
|
+
gone[c] = collapsedColumn(columnBoxes[c], columnGroups[c]);
|
|
96
|
+
if (gone[c])
|
|
97
|
+
anyGone = true;
|
|
98
|
+
else
|
|
99
|
+
x += widths[c] + spacing;
|
|
58
100
|
}
|
|
59
101
|
// A table with `width: auto` is as wide as its columns need, not as wide as
|
|
60
102
|
// its container — it shrinks to fit, which is what makes a two-column table
|
|
61
103
|
// in a wide document a small table rather than a pair of columns stranded
|
|
62
104
|
// at the left of a full-width box. The columns were sized against the space
|
|
63
|
-
// on offer, so this
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
105
|
+
// on offer, so this narrows it — but never past the least its columns can
|
|
106
|
+
// be (CSS 2.1 17.5.2.2): a table whose words do not fit is wider than the
|
|
107
|
+
// room, as a word is, and one beside a float goes below it.
|
|
108
|
+
//
|
|
109
|
+
// A table set to a width is as wide as it or its columns, whichever is the
|
|
110
|
+
// wider: columns set wider than the table widen it. A column taken out
|
|
111
|
+
// gives its room back either way, set width or not.
|
|
112
|
+
const used = x - table.contentX;
|
|
113
|
+
let tableContentWidth = contentWidth;
|
|
114
|
+
if (style.width === AUTO) {
|
|
115
|
+
tableContentWidth = used;
|
|
67
116
|
table.width = tableContentWidth + table.horizontalExtra;
|
|
117
|
+
}
|
|
118
|
+
else if (used > contentWidth || anyGone) {
|
|
119
|
+
tableContentWidth = used;
|
|
120
|
+
table.width = used + table.horizontalExtra;
|
|
121
|
+
}
|
|
122
|
+
layoutCaptions(captions, ctx, table);
|
|
123
|
+
const top = table.contentY + table.captionTop;
|
|
124
|
+
let y = top;
|
|
68
125
|
const rowTop = new Array(rows.length);
|
|
69
126
|
const rowHeight = new Array(rows.length).fill(0);
|
|
70
|
-
y +=
|
|
127
|
+
y += rowSpacing;
|
|
71
128
|
// Size every cell at its column width first, so a row's height is the
|
|
72
|
-
// tallest cell in it rather than the first one that was measured.
|
|
73
|
-
|
|
129
|
+
// tallest cell in it rather than the first one that was measured. What
|
|
130
|
+
// its content came to is kept apart from a height the cell sets: it is
|
|
131
|
+
// that content `vertical-align` moves in the cell.
|
|
132
|
+
const natural = new Array(cells.length);
|
|
133
|
+
for (let i = 0; i < cells.length; i += 1) {
|
|
134
|
+
const cell = cells[i];
|
|
74
135
|
const width = spannedWidth(widths, cell, spacing);
|
|
75
136
|
ctx.layoutSubtree(cell.box, width);
|
|
137
|
+
natural[i] = CELL_CONTENT.get(cell.box) ?? cell.box.height;
|
|
138
|
+
// A height a cell sets is a least one: its content is laid out as a
|
|
139
|
+
// block's, which keeps a height it sets and lets the content run out of
|
|
140
|
+
// it, and a cell does not. `<td height="10">` with a line in it is as
|
|
141
|
+
// tall as the line (CSS 2.1 17.5.3), where it was 10px with the line
|
|
142
|
+
// hanging out of it.
|
|
143
|
+
if (natural[i] > cell.box.height)
|
|
144
|
+
cell.box.height = natural[i];
|
|
76
145
|
const specified = resolveOrNull(cell.box.style.height, NaN);
|
|
77
146
|
if (specified !== null) {
|
|
78
147
|
cell.box.height = Math.max(cell.box.height, specified + cell.box.verticalExtra);
|
|
79
148
|
}
|
|
80
149
|
}
|
|
81
|
-
|
|
150
|
+
// A cell aligned on the baseline — every value but `top`, `middle` and
|
|
151
|
+
// `bottom` — hangs its first line on its first row's baseline, the lowest
|
|
152
|
+
// of theirs from the row's top (CSS 2.1 17.5.3), and the row is as tall as
|
|
153
|
+
// the cells hung from it need.
|
|
154
|
+
const lift = baselineLifts(cells, rows.length);
|
|
155
|
+
for (let i = 0; i < cells.length; i += 1) {
|
|
156
|
+
const cell = cells[i];
|
|
82
157
|
if (cell.rowSpan > 1)
|
|
83
158
|
continue;
|
|
84
|
-
rowHeight[cell.row] = Math.max(rowHeight[cell.row], cell.box.height);
|
|
159
|
+
rowHeight[cell.row] = Math.max(rowHeight[cell.row], lift[i] + cell.box.height);
|
|
85
160
|
}
|
|
86
161
|
for (let r = 0; r < rows.length; r += 1) {
|
|
87
162
|
const specified = resolveOrNull(rows[r].style.height, NaN);
|
|
@@ -91,47 +166,152 @@ export function layoutTable(table, ctx, contentWidth) {
|
|
|
91
166
|
// A row-spanning cell only forces height when the rows it covers do not
|
|
92
167
|
// already provide it — otherwise a `rowspan="3"` cell would make each of
|
|
93
168
|
// its three rows as tall as all of it.
|
|
94
|
-
for (
|
|
169
|
+
for (let i = 0; i < cells.length; i += 1) {
|
|
170
|
+
const cell = cells[i];
|
|
95
171
|
if (cell.rowSpan <= 1)
|
|
96
172
|
continue;
|
|
97
173
|
const last = Math.min(rows.length - 1, cell.row + cell.rowSpan - 1);
|
|
98
174
|
let covered = 0;
|
|
99
175
|
for (let r = cell.row; r <= last; r += 1)
|
|
100
176
|
covered += rowHeight[r];
|
|
101
|
-
covered +=
|
|
102
|
-
const missing = cell.box.height - covered;
|
|
177
|
+
covered += rowSpacing * (last - cell.row);
|
|
178
|
+
const missing = lift[i] + cell.box.height - covered;
|
|
103
179
|
if (missing > 0)
|
|
104
180
|
rowHeight[last] += missing;
|
|
105
181
|
}
|
|
182
|
+
// A table's own height, within its least and greatest, is a least
|
|
183
|
+
// height: what its rows come short of it goes to them (CSS 2.1 17.5.3,
|
|
184
|
+
// which leaves how to its user agents: `growRows`)
|
|
185
|
+
const wanted = resolveOrNull(style.height, table.percentHeightBase);
|
|
186
|
+
if (rows.length) {
|
|
187
|
+
const extraBox = table.verticalExtra;
|
|
188
|
+
const set = wanted === null
|
|
189
|
+
? 0
|
|
190
|
+
: style.boxSizing === 'border-box'
|
|
191
|
+
? wanted
|
|
192
|
+
: wanted + extraBox;
|
|
193
|
+
const inner = clampHeight(table, set) - extraBox;
|
|
194
|
+
let total = 0;
|
|
195
|
+
for (const h of rowHeight)
|
|
196
|
+
total += h;
|
|
197
|
+
const extra = inner - total - rowSpacing * (rows.length + 1);
|
|
198
|
+
if (extra > 0)
|
|
199
|
+
growRows(rowHeight, rowSizing(rows, cells), extra, inner);
|
|
200
|
+
}
|
|
201
|
+
// And a row it takes out has sized the columns with the rest, and is as
|
|
202
|
+
// tall as nothing, with no spacing after it; its cells inherit the value,
|
|
203
|
+
// and are not drawn.
|
|
204
|
+
const rowGone = new Array(rows.length);
|
|
106
205
|
for (let r = 0; r < rows.length; r += 1) {
|
|
107
206
|
rowTop[r] = y;
|
|
108
|
-
|
|
207
|
+
rowGone[r] = rows[r].style.visibility === 'collapse';
|
|
208
|
+
if (rowGone[r])
|
|
209
|
+
rowHeight[r] = 0;
|
|
210
|
+
else
|
|
211
|
+
y += rowHeight[r] + rowSpacing;
|
|
109
212
|
}
|
|
110
|
-
for (
|
|
213
|
+
for (let i = 0; i < cells.length; i += 1) {
|
|
214
|
+
const cell = cells[i];
|
|
111
215
|
const last = Math.min(rows.length - 1, cell.row + cell.rowSpan - 1);
|
|
112
216
|
let height = 0;
|
|
113
|
-
|
|
217
|
+
let clip = false;
|
|
218
|
+
for (let r = cell.row; r <= last; r += 1) {
|
|
114
219
|
height += rowHeight[r];
|
|
115
|
-
|
|
116
|
-
|
|
220
|
+
if (r > cell.row && rowGone[r])
|
|
221
|
+
clip = true;
|
|
222
|
+
}
|
|
223
|
+
height += rowSpacing * (last - cell.row);
|
|
224
|
+
if (clip) {
|
|
225
|
+
// down to the last of its rows left in the table, whose spacing went
|
|
226
|
+
// with the rows taken out
|
|
227
|
+
let bottom = rowTop[cell.row] + rowHeight[cell.row];
|
|
228
|
+
for (let r = cell.row + 1; r <= last; r += 1) {
|
|
229
|
+
if (!rowGone[r])
|
|
230
|
+
bottom = rowTop[r] + rowHeight[r];
|
|
231
|
+
}
|
|
232
|
+
height = bottom - rowTop[cell.row];
|
|
233
|
+
}
|
|
234
|
+
let width = spannedWidth(widths, cell, spacing);
|
|
235
|
+
// Where its columns are: a cell spanning a column taken out is laid out
|
|
236
|
+
// across all of them, moved left by the width of the ones before the
|
|
237
|
+
// first left in, and clipped to the ones left, which cuts out what was
|
|
238
|
+
// in those (CSS 2.1 17.5.5). The spacing after them goes from the end
|
|
239
|
+
// of its content, which does not line up with the columns it spans.
|
|
240
|
+
// One wholly in them is not drawn.
|
|
241
|
+
let placeX = columnX[cell.column];
|
|
242
|
+
let boxX = placeX;
|
|
243
|
+
if (anyGone) {
|
|
244
|
+
const lastColumn = Math.min(columnCount - 1, cell.column + cell.colSpan - 1);
|
|
245
|
+
let first = -1;
|
|
246
|
+
let end = -1;
|
|
247
|
+
let before = 0;
|
|
248
|
+
let some = false;
|
|
249
|
+
for (let c = cell.column; c <= lastColumn; c += 1) {
|
|
250
|
+
if (!gone[c]) {
|
|
251
|
+
if (first < 0)
|
|
252
|
+
first = c;
|
|
253
|
+
end = c;
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
if (first < 0)
|
|
257
|
+
before += (some ? spacing : 0) + widths[c];
|
|
258
|
+
some = true;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (first < 0)
|
|
262
|
+
COLLAPSED_CELLS.add(cell.box);
|
|
263
|
+
else if (some) {
|
|
264
|
+
clip = true;
|
|
265
|
+
boxX = columnX[first];
|
|
266
|
+
placeX = boxX - before;
|
|
267
|
+
width = columnX[end] + widths[end] - boxX;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
117
270
|
const inner = cell.box.height;
|
|
118
271
|
// `vertical-align` inside a cell moves the *content*, not the box: the
|
|
119
|
-
// box fills the row, and the content sits top,
|
|
120
|
-
|
|
272
|
+
// box fills the row, background and all, and the content sits top,
|
|
273
|
+
// middle, bottom or on the row's baseline in it — in the box a height
|
|
274
|
+
// of its own makes too, which is no content to be moved
|
|
275
|
+
let offset = lift[i];
|
|
121
276
|
const va = cell.box.style.verticalAlign;
|
|
277
|
+
const content = natural[i];
|
|
278
|
+
const room = Math.max(height, inner);
|
|
122
279
|
if (va === 'middle')
|
|
123
|
-
offset = Math.max(0, (
|
|
280
|
+
offset = Math.max(0, (room - content) / 2);
|
|
124
281
|
else if (va === 'bottom')
|
|
125
|
-
offset = Math.max(0,
|
|
126
|
-
moveTo(cell.box,
|
|
282
|
+
offset = Math.max(0, room - content);
|
|
283
|
+
moveTo(cell.box, placeX, rowTop[cell.row]);
|
|
284
|
+
moveContent(cell.box, offset);
|
|
285
|
+
cell.box.x = boxX;
|
|
127
286
|
cell.box.width = width;
|
|
128
|
-
|
|
287
|
+
if (clip) {
|
|
288
|
+
cell.box.height = height;
|
|
289
|
+
CLIPPED_CELLS.add(cell.box);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
cell.box.height = Math.max(inner, height);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// where the grid lines fell, for the collapsed borders drawn along them
|
|
296
|
+
const collapsed = table.collapsed;
|
|
297
|
+
if (collapsed && collapsed.columns === columnCount) {
|
|
298
|
+
const last = columnCount - 1;
|
|
299
|
+
collapsed.lineX = columnX.map((cx) => cx - table.x);
|
|
300
|
+
collapsed.lineX.push(columnX[last] + widths[last] - table.x);
|
|
301
|
+
collapsed.lineY = rowTop.map((ry) => ry - table.y);
|
|
302
|
+
const bottom = rows.length - 1;
|
|
303
|
+
collapsed.lineY.push(rowTop[bottom] + rowHeight[bottom] - table.y);
|
|
129
304
|
}
|
|
305
|
+
// A row, and a group of them, spans the columns: from the first one's
|
|
306
|
+
// left edge to the last one's right, the spacing around them outside it
|
|
307
|
+
// (CSS 2.1 17.5.1), as it is above and below.
|
|
308
|
+
const gridX = table.contentX + spacing;
|
|
309
|
+
const gridWidth = Math.max(0, x - spacing - gridX);
|
|
130
310
|
for (let r = 0; r < rows.length; r += 1) {
|
|
131
311
|
const row = rows[r];
|
|
132
|
-
row.x =
|
|
312
|
+
row.x = gridX;
|
|
133
313
|
row.y = rowTop[r];
|
|
134
|
-
row.width =
|
|
314
|
+
row.width = gridWidth;
|
|
135
315
|
row.height = rowHeight[r];
|
|
136
316
|
}
|
|
137
317
|
for (const child of table.children) {
|
|
@@ -140,25 +320,81 @@ export function layoutTable(table, ctx, contentWidth) {
|
|
|
140
320
|
const groupRows = child.children.filter((row) => row.kind === 'table-row');
|
|
141
321
|
if (!groupRows.length)
|
|
142
322
|
continue;
|
|
143
|
-
child.x =
|
|
323
|
+
child.x = gridX;
|
|
144
324
|
child.y = groupRows[0].y;
|
|
145
|
-
child.width =
|
|
325
|
+
child.width = gridWidth;
|
|
146
326
|
child.height =
|
|
147
327
|
groupRows[groupRows.length - 1].y +
|
|
148
328
|
groupRows[groupRows.length - 1].height -
|
|
149
329
|
child.y;
|
|
150
330
|
}
|
|
151
|
-
return y -
|
|
331
|
+
return y - top;
|
|
332
|
+
}
|
|
333
|
+
/** Whether `visibility: collapse` takes a column out: its own, or the
|
|
334
|
+
* column group's that holds it with no column box of its own. */
|
|
335
|
+
function collapsedColumn(column, group) {
|
|
336
|
+
return (column ?? group)?.style.visibility === 'collapse';
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* A table's captions, which are outside the table box (CSS 2.1 17.4): as
|
|
340
|
+
* wide as its border box, the ones on top above its border, and the ones
|
|
341
|
+
* at the bottom laid out here and placed below it by `finishCaptions`,
|
|
342
|
+
* once the table's height is known.
|
|
343
|
+
*/
|
|
344
|
+
function layoutCaptions(captions, ctx, table) {
|
|
345
|
+
let y = table.y;
|
|
346
|
+
for (const caption of captions) {
|
|
347
|
+
// laid out at the offset its margins give it across the table, which
|
|
348
|
+
// is where it stays across
|
|
349
|
+
layoutBlockIn(caption, ctx, table.width);
|
|
350
|
+
const height = caption.marginTop + caption.height + caption.marginBottom;
|
|
351
|
+
if (caption.style.captionSide === 'bottom') {
|
|
352
|
+
table.captionBottom += height;
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
moveTo(caption, table.x + caption.x, y + caption.marginTop);
|
|
356
|
+
y += height;
|
|
357
|
+
table.captionTop += height;
|
|
358
|
+
}
|
|
152
359
|
}
|
|
153
|
-
|
|
154
|
-
|
|
360
|
+
/** The narrowest the widest caption can be, margins in: its own width
|
|
361
|
+
* where it has one, and its longest word where it has not. */
|
|
362
|
+
function captionMinimum(captions, ctx) {
|
|
363
|
+
let widest = 0;
|
|
155
364
|
for (const caption of captions) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
365
|
+
let width = measureIntrinsicWidth(caption, ctx, MIN_CONTENT_PROBE);
|
|
366
|
+
// and as wide as a length its own `width` sets: the probe lays it out
|
|
367
|
+
// at none, so an empty caption set to 100px measured nothing, and the
|
|
368
|
+
// table under it was as narrow as its cells
|
|
369
|
+
const set = caption.style.width;
|
|
370
|
+
if (set !== AUTO && !isPct(set)) {
|
|
371
|
+
const length = resolveOrNull(set, 0);
|
|
372
|
+
if (length !== null) {
|
|
373
|
+
const extra = caption.style.boxSizing === 'border-box'
|
|
374
|
+
? 0
|
|
375
|
+
: caption.horizontalExtra;
|
|
376
|
+
width = Math.max(width, length + extra);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
widest = Math.max(widest, width + caption.marginLeft + caption.marginRight);
|
|
160
380
|
}
|
|
161
|
-
return
|
|
381
|
+
return widest;
|
|
382
|
+
}
|
|
383
|
+
/** The table box has its height: the captions go around it, the bottom
|
|
384
|
+
* ones below it, and the box grows to hold them. */
|
|
385
|
+
export function finishCaptions(table) {
|
|
386
|
+
if (!table.captionTop && !table.captionBottom)
|
|
387
|
+
return;
|
|
388
|
+
let y = table.y + table.captionTop + table.height;
|
|
389
|
+
for (const caption of table.children) {
|
|
390
|
+
if (caption.kind !== 'table-caption')
|
|
391
|
+
continue;
|
|
392
|
+
if (caption.style.captionSide !== 'bottom')
|
|
393
|
+
continue;
|
|
394
|
+
moveTo(caption, table.x + caption.x, y + caption.marginTop);
|
|
395
|
+
y += caption.marginTop + caption.height + caption.marginBottom;
|
|
396
|
+
}
|
|
397
|
+
table.height += table.captionTop + table.captionBottom;
|
|
162
398
|
}
|
|
163
399
|
function spannedWidth(widths, cell, spacing) {
|
|
164
400
|
let width = 0;
|
|
@@ -168,81 +404,73 @@ function spannedWidth(widths, cell, spacing) {
|
|
|
168
404
|
return width + spacing * (last - cell.column);
|
|
169
405
|
}
|
|
170
406
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
407
|
+
* `table-layout: fixed`: the columns and the first row decide, and the rest
|
|
408
|
+
* of the table is not measured at all, which is the whole point of it (CSS
|
|
409
|
+
* 2.1 17.5.2.1). A column with a `width` sets its own; failing that, a cell
|
|
410
|
+
* of the first row with one sets the columns it spans, by its border box and
|
|
411
|
+
* less the spacing between them; the columns left share what remains, and
|
|
412
|
+
* where nothing remains, what is left of a table wider than its columns is
|
|
413
|
+
* shared among all of them.
|
|
175
414
|
*/
|
|
176
|
-
function
|
|
177
|
-
const cells = [];
|
|
178
|
-
const occupied = [];
|
|
179
|
-
let columnCount = 0;
|
|
180
|
-
const mark = (r, c) => {
|
|
181
|
-
(occupied[r] ??= [])[c] = true;
|
|
182
|
-
};
|
|
183
|
-
const taken = (r, c) => occupied[r]?.[c] === true;
|
|
184
|
-
for (let r = 0; r < rows.length; r += 1) {
|
|
185
|
-
let c = 0;
|
|
186
|
-
for (const box of rows[r].children) {
|
|
187
|
-
if (box.kind !== 'table-cell')
|
|
188
|
-
continue;
|
|
189
|
-
while (taken(r, c))
|
|
190
|
-
c += 1;
|
|
191
|
-
const colSpan = Math.max(1, spanAttr(box, 'colspan'));
|
|
192
|
-
const rowSpan = Math.max(1, spanAttr(box, 'rowspan'));
|
|
193
|
-
cells.push({ box, row: r, column: c, colSpan, rowSpan });
|
|
194
|
-
for (let dr = 0; dr < rowSpan; dr += 1) {
|
|
195
|
-
for (let dc = 0; dc < colSpan; dc += 1)
|
|
196
|
-
mark(r + dr, c + dc);
|
|
197
|
-
}
|
|
198
|
-
c += colSpan;
|
|
199
|
-
columnCount = Math.max(columnCount, c);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return { cells, columnCount };
|
|
203
|
-
}
|
|
204
|
-
function spanAttr(box, name) {
|
|
205
|
-
const raw = box.el?.attribs?.[name];
|
|
206
|
-
if (!raw)
|
|
207
|
-
return 1;
|
|
208
|
-
const n = parseInt(raw, 10);
|
|
209
|
-
return Number.isFinite(n) && n > 0 ? Math.min(n, 1000) : 1;
|
|
210
|
-
}
|
|
211
|
-
/** `table-layout: fixed` — the first row and any `width` decide, and the
|
|
212
|
-
* rest of the table is not measured at all. That is the whole point of it. */
|
|
213
|
-
function fixedColumns(table, cells, columnCount, available) {
|
|
415
|
+
function fixedColumns(cells, columnWidths, columnCount, available, spacing) {
|
|
214
416
|
const widths = new Array(columnCount).fill(0);
|
|
215
|
-
const
|
|
417
|
+
const set = new Array(columnCount).fill(false);
|
|
418
|
+
for (let c = 0; c < columnCount; c += 1) {
|
|
419
|
+
const px = columnWidths[c];
|
|
420
|
+
if (px === null)
|
|
421
|
+
continue;
|
|
422
|
+
widths[c] = px;
|
|
423
|
+
set[c] = true;
|
|
424
|
+
}
|
|
216
425
|
for (const cell of cells) {
|
|
217
426
|
if (cell.row > 0)
|
|
218
427
|
break;
|
|
219
|
-
const
|
|
220
|
-
if (len === AUTO)
|
|
221
|
-
continue;
|
|
222
|
-
const px = lengthAgainst(len, available);
|
|
428
|
+
const px = tableWidth(cell.box.style.width, available);
|
|
223
429
|
if (px === null)
|
|
224
430
|
continue;
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
431
|
+
const box = cell.box;
|
|
432
|
+
const outer = box.style.boxSizing === 'border-box'
|
|
433
|
+
? Math.max(px, box.horizontalExtra)
|
|
434
|
+
: px + box.horizontalExtra;
|
|
435
|
+
const last = Math.min(columnCount, cell.column + cell.colSpan);
|
|
436
|
+
let taken = spacing * (last - cell.column - 1);
|
|
437
|
+
let open = 0;
|
|
438
|
+
for (let c = cell.column; c < last; c += 1) {
|
|
439
|
+
if (set[c])
|
|
440
|
+
taken += widths[c];
|
|
441
|
+
else
|
|
442
|
+
open += 1;
|
|
443
|
+
}
|
|
444
|
+
if (!open)
|
|
445
|
+
continue;
|
|
446
|
+
const each = Math.max(0, outer - taken) / open;
|
|
447
|
+
for (let c = cell.column; c < last; c += 1) {
|
|
448
|
+
if (set[c])
|
|
449
|
+
continue;
|
|
450
|
+
widths[c] = each;
|
|
451
|
+
set[c] = true;
|
|
229
452
|
}
|
|
230
453
|
}
|
|
231
|
-
|
|
454
|
+
let used = 0;
|
|
455
|
+
let unset = 0;
|
|
456
|
+
for (let c = 0; c < columnCount; c += 1) {
|
|
457
|
+
if (set[c])
|
|
458
|
+
used += widths[c];
|
|
459
|
+
else
|
|
460
|
+
unset += 1;
|
|
461
|
+
}
|
|
232
462
|
const remaining = Math.max(0, available - used);
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
for (let c = 0; c < columnCount; c += 1)
|
|
245
|
-
widths[c] *= scale;
|
|
463
|
+
if (unset) {
|
|
464
|
+
for (let c = 0; c < columnCount; c += 1) {
|
|
465
|
+
if (!set[c])
|
|
466
|
+
widths[c] = remaining / unset;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
else if (remaining > 0 && columnCount) {
|
|
470
|
+
for (let c = 0; c < columnCount; c += 1) {
|
|
471
|
+
widths[c] +=
|
|
472
|
+
used > 0 ? (widths[c] / used) * remaining : remaining / columnCount;
|
|
473
|
+
}
|
|
246
474
|
}
|
|
247
475
|
return widths;
|
|
248
476
|
}
|
|
@@ -256,15 +484,16 @@ function fixedColumns(table, cells, columnCount, available) {
|
|
|
256
484
|
* proportion, so a column of long prose gives up more than a column of
|
|
257
485
|
* dates. A column with an explicit `width` is honoured before either.
|
|
258
486
|
*/
|
|
259
|
-
function autoColumns(cells, columnCount, available, ctx, containingWidth) {
|
|
487
|
+
function autoColumns(cells, columnWidths, columnCount, available, ctx, containingWidth, fill, spacing) {
|
|
260
488
|
const max = new Array(columnCount).fill(0);
|
|
261
489
|
const min = new Array(columnCount).fill(0);
|
|
262
490
|
const explicit = new Array(columnCount).fill(null);
|
|
491
|
+
const spanning = [];
|
|
263
492
|
for (const cell of cells) {
|
|
264
|
-
// Two probe layouts per cell: unconstrained for max-content, and at
|
|
265
|
-
// width
|
|
266
|
-
// breaking at every opportunity, so the widest line is the
|
|
267
|
-
// unbreakable word.
|
|
493
|
+
// Two probe layouts per cell: unconstrained for max-content, and at no
|
|
494
|
+
// width for min-content (`MIN_CONTENT_PROBE`) — which the line breaker
|
|
495
|
+
// answers by breaking at every opportunity, so the widest line is the
|
|
496
|
+
// longest unbreakable word.
|
|
268
497
|
//
|
|
269
498
|
// Cached on the box, because intrinsic widths are width-independent by
|
|
270
499
|
// definition — measuring them per layout pass made a *resize* of a
|
|
@@ -273,68 +502,345 @@ function autoColumns(cells, columnCount, available, ctx, containingWidth) {
|
|
|
273
502
|
// is the box's lifetime: any DOM or style change rebuilds the tree.
|
|
274
503
|
if (cell.box.intrinsicMaxContent < 0) {
|
|
275
504
|
cell.box.intrinsicMaxContent = measureIntrinsicWidth(cell.box, ctx, Infinity);
|
|
276
|
-
|
|
505
|
+
// where its words say it exactly, read from the layout just made
|
|
506
|
+
cell.box.intrinsicMinContent =
|
|
507
|
+
(ctx.fonts && exactMinContent(cell.box, ctx.fonts)) ??
|
|
508
|
+
measureIntrinsicWidth(cell.box, ctx, MIN_CONTENT_PROBE, true);
|
|
277
509
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const width = len === AUTO ? null : lengthAgainst(len, containingWidth);
|
|
282
|
-
if (cell.colSpan === 1) {
|
|
283
|
-
max[cell.column] = Math.max(max[cell.column], cellMax);
|
|
284
|
-
min[cell.column] = Math.max(min[cell.column], cellMin);
|
|
285
|
-
if (width !== null) {
|
|
286
|
-
explicit[cell.column] = Math.max(explicit[cell.column] ?? 0, width + cell.box.horizontalExtra);
|
|
287
|
-
}
|
|
510
|
+
if (cell.colSpan > 1) {
|
|
511
|
+
spanning.push(cell);
|
|
512
|
+
continue;
|
|
288
513
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
let currentMax = 0;
|
|
295
|
-
let currentMin = 0;
|
|
296
|
-
for (let c = cell.column; c <= last; c += 1) {
|
|
297
|
-
currentMax += max[c];
|
|
298
|
-
currentMin += min[c];
|
|
299
|
-
}
|
|
300
|
-
const spread = last - cell.column + 1;
|
|
301
|
-
if (cellMax > currentMax) {
|
|
302
|
-
const each = (cellMax - currentMax) / spread;
|
|
303
|
-
for (let c = cell.column; c <= last; c += 1)
|
|
304
|
-
max[c] += each;
|
|
305
|
-
}
|
|
306
|
-
if (cellMin > currentMin) {
|
|
307
|
-
const each = (cellMin - currentMin) / spread;
|
|
308
|
-
for (let c = cell.column; c <= last; c += 1)
|
|
309
|
-
min[c] += each;
|
|
310
|
-
}
|
|
514
|
+
max[cell.column] = Math.max(max[cell.column], cell.box.intrinsicMaxContent);
|
|
515
|
+
min[cell.column] = Math.max(min[cell.column], cell.box.intrinsicMinContent);
|
|
516
|
+
const width = cellWidth(cell, containingWidth);
|
|
517
|
+
if (width !== null) {
|
|
518
|
+
explicit[cell.column] = Math.max(explicit[cell.column] ?? 0, width);
|
|
311
519
|
}
|
|
312
520
|
}
|
|
521
|
+
// a column's own width counts as its cells' do: at least that, and its
|
|
522
|
+
// content's max where that is wider (CSS 2.1 17.5.2.2, step 2)
|
|
523
|
+
for (let c = 0; c < columnCount; c += 1) {
|
|
524
|
+
const own = columnWidths[c];
|
|
525
|
+
if (own !== null)
|
|
526
|
+
explicit[c] = Math.max(explicit[c] ?? 0, own);
|
|
527
|
+
}
|
|
528
|
+
// A spanning cell comes after the cells of one column, the narrower
|
|
529
|
+
// spans first, and adds to its columns only what they come short of it
|
|
530
|
+
// (CSS 2.1 17.5.2.2, step 3). It holds the spacing between them too,
|
|
531
|
+
// room the columns need not find. What it adds goes to those of them
|
|
532
|
+
// with no width set, in proportion to their content, and evenly where
|
|
533
|
+
// they have none. Taken in document order and spread evenly, a spanning
|
|
534
|
+
// cell in a first row was shared out before the cells of one column
|
|
535
|
+
// under it were seen, and a column one of them set to 5px took half.
|
|
536
|
+
spanning.sort((a, b) => a.colSpan - b.colSpan);
|
|
537
|
+
const grow = (into, want, cell) => {
|
|
538
|
+
const last = Math.min(columnCount - 1, cell.column + cell.colSpan - 1);
|
|
539
|
+
let have = spacing * (last - cell.column);
|
|
540
|
+
for (let c = cell.column; c <= last; c += 1)
|
|
541
|
+
have += into[c];
|
|
542
|
+
if (!(want > have))
|
|
543
|
+
return;
|
|
544
|
+
let free = false;
|
|
545
|
+
for (let c = cell.column; c <= last && !free; c += 1) {
|
|
546
|
+
free = explicit[c] === null;
|
|
547
|
+
}
|
|
548
|
+
let weight = 0;
|
|
549
|
+
let count = 0;
|
|
550
|
+
for (let c = cell.column; c <= last; c += 1) {
|
|
551
|
+
if (free && explicit[c] !== null)
|
|
552
|
+
continue;
|
|
553
|
+
weight += max[c];
|
|
554
|
+
count += 1;
|
|
555
|
+
}
|
|
556
|
+
for (let c = cell.column; c <= last; c += 1) {
|
|
557
|
+
if (free && explicit[c] !== null)
|
|
558
|
+
continue;
|
|
559
|
+
into[c] +=
|
|
560
|
+
weight > 0 ? ((want - have) * max[c]) / weight : (want - have) / count;
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
// what the columns' content alone asks, before their set widths: the
|
|
564
|
+
// least a column gives way to when the table has less room than its
|
|
565
|
+
// cells' widths want, as beside a float
|
|
566
|
+
const least = min.slice();
|
|
567
|
+
for (const cell of spanning)
|
|
568
|
+
grow(least, cell.box.intrinsicMinContent, cell);
|
|
313
569
|
for (let c = 0; c < columnCount; c += 1) {
|
|
314
570
|
if (explicit[c] !== null) {
|
|
315
|
-
max[c] = Math.max(
|
|
571
|
+
max[c] = Math.max(min[c], explicit[c]);
|
|
316
572
|
min[c] = Math.max(min[c], Math.min(explicit[c], max[c]));
|
|
317
573
|
}
|
|
318
|
-
min[c] = Math.min(min[c], max[c]);
|
|
319
574
|
}
|
|
575
|
+
// and with them: a spanning cell's own width is the least it is, as a
|
|
576
|
+
// single cell's is (step 1), so a cell over three columns set to 100px,
|
|
577
|
+
// with 20px between them, has 60 to share, where it had none
|
|
578
|
+
for (const cell of spanning) {
|
|
579
|
+
const own = cellWidth(cell, containingWidth) ?? 0;
|
|
580
|
+
grow(min, Math.max(cell.box.intrinsicMinContent, own), cell);
|
|
581
|
+
grow(max, Math.max(cell.box.intrinsicMaxContent, own), cell);
|
|
582
|
+
}
|
|
583
|
+
for (let c = 0; c < columnCount; c += 1)
|
|
584
|
+
min[c] = Math.min(min[c], max[c]);
|
|
320
585
|
const totalMax = max.reduce((a, b) => a + b, 0);
|
|
321
586
|
if (totalMax <= available) {
|
|
322
|
-
// Everything fits. A table with
|
|
323
|
-
//
|
|
324
|
-
|
|
587
|
+
// Everything fits. A table with a width of its own still fills it (CSS
|
|
588
|
+
// 2.1 17.5.2.2): the columns not set to a width take the rest in
|
|
589
|
+
// proportion to what they asked for, or every column does where all are
|
|
590
|
+
// set. Returned as asked, `<table width="600">` drew its cells at their
|
|
591
|
+
// content's width and left the rest of its 600 empty.
|
|
592
|
+
if (!fill || available <= totalMax)
|
|
593
|
+
return max;
|
|
594
|
+
const set = explicit.every((w) => w !== null);
|
|
595
|
+
let weight = 0;
|
|
596
|
+
let count = 0;
|
|
597
|
+
for (let c = 0; c < columnCount; c += 1) {
|
|
598
|
+
if (!set && explicit[c] !== null)
|
|
599
|
+
continue;
|
|
600
|
+
weight += max[c];
|
|
601
|
+
count += 1;
|
|
602
|
+
}
|
|
603
|
+
const extra = available - totalMax;
|
|
604
|
+
return max.map((m, c) => !set && explicit[c] !== null
|
|
605
|
+
? m
|
|
606
|
+
: m + (weight > 0 ? (extra * m) / weight : extra / count));
|
|
325
607
|
}
|
|
326
608
|
const totalMin = min.reduce((a, b) => a + b, 0);
|
|
327
|
-
if (totalMin >= available)
|
|
328
|
-
|
|
609
|
+
if (totalMin >= available) {
|
|
610
|
+
// Less room than the cells' widths want: a width a cell was set to
|
|
611
|
+
// gives way first, down to what its content asks, and a table never
|
|
612
|
+
// goes narrower than its words (CSS 2.1 17.5.2.2), which it overflows.
|
|
613
|
+
const totalLeast = least.reduce((a, b) => a + b, 0);
|
|
614
|
+
if (totalLeast >= available)
|
|
615
|
+
return least;
|
|
616
|
+
const give = totalMin - totalLeast;
|
|
617
|
+
return min.map((m, c) => m - ((m - least[c]) / give) * (totalMin - available));
|
|
618
|
+
}
|
|
329
619
|
const slack = available - totalMin;
|
|
330
620
|
const surplus = totalMax - totalMin;
|
|
331
621
|
return max.map((m, c) => min[c] + ((m - min[c]) / surplus) * slack);
|
|
332
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* The width each column is set to, or null: a column's own `width`, or its
|
|
625
|
+
* group's shared among the columns of a group that has none of its own
|
|
626
|
+
* (HTML's `<colgroup span>`); and a group's `width` spread over its columns
|
|
627
|
+
* where theirs come to less (CSS 2.1 17.5.2.2, step 4). Each within its
|
|
628
|
+
* `min-width` and `max-width`, which apply to columns and column groups as
|
|
629
|
+
* to any block (10.4), so `min-width` alone sets one.
|
|
630
|
+
*/
|
|
631
|
+
function columnWidths(columnBoxes, columnGroups, base) {
|
|
632
|
+
const widths = columnBoxes.map((column) => column ? partWidth(column, base) : null);
|
|
633
|
+
let group = null;
|
|
634
|
+
for (let c = 0; c <= columnGroups.length; c += 1) {
|
|
635
|
+
if (c < columnGroups.length && columnGroups[c] === group)
|
|
636
|
+
continue;
|
|
637
|
+
// the group that ends here, over its columns from `start`
|
|
638
|
+
if (group) {
|
|
639
|
+
const width = partWidth(group, base);
|
|
640
|
+
let start = c - 1;
|
|
641
|
+
while (start > 0 && columnGroups[start - 1] === group)
|
|
642
|
+
start -= 1;
|
|
643
|
+
if (width !== null) {
|
|
644
|
+
let have = 0;
|
|
645
|
+
for (let i = start; i < c; i += 1)
|
|
646
|
+
have += widths[i] ?? 0;
|
|
647
|
+
if (have < width) {
|
|
648
|
+
const each = (width - have) / (c - start);
|
|
649
|
+
for (let i = start; i < c; i += 1) {
|
|
650
|
+
widths[i] = (widths[i] ?? 0) + each;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
group = c < columnGroups.length ? columnGroups[c] : null;
|
|
656
|
+
}
|
|
657
|
+
return widths;
|
|
658
|
+
}
|
|
659
|
+
/** A column's or a column group's width, within its limits, or null where
|
|
660
|
+
* it sets none. */
|
|
661
|
+
function partWidth(box, base) {
|
|
662
|
+
const style = box.style;
|
|
663
|
+
const width = tableWidth(style.width, base);
|
|
664
|
+
const min = lengthAgainst(style.minWidth, base) ?? 0;
|
|
665
|
+
if (width === null && !(min > 0))
|
|
666
|
+
return null;
|
|
667
|
+
const max = style.maxWidth === 'none' ? null : lengthAgainst(style.maxWidth, base);
|
|
668
|
+
let out = width ?? 0;
|
|
669
|
+
if (max !== null)
|
|
670
|
+
out = Math.min(out, max);
|
|
671
|
+
return Math.max(0, out, min);
|
|
672
|
+
}
|
|
673
|
+
/** A cell's own `width`, its padding and borders in, or null. A
|
|
674
|
+
* percentage is a share of the table its padding and borders are part
|
|
675
|
+
* of, as browsers read it: added on, a 90% cell and a 10% one came to
|
|
676
|
+
* more than the table, which then took it back from both. Held within its
|
|
677
|
+
* `min-width` and `max-width` as a column's is (`partWidth`), which CSS
|
|
678
|
+
* 2.1 leaves undefined and every browser does: a cell set `width: 3in;
|
|
679
|
+
* max-width: 1in` is an inch wide, and one with `min-width` alone is as
|
|
680
|
+
* wide as that. */
|
|
681
|
+
function cellWidth(cell, base) {
|
|
682
|
+
const style = cell.box.style;
|
|
683
|
+
const len = style.width;
|
|
684
|
+
const width = len === AUTO ? null : tableWidth(len, base);
|
|
685
|
+
const min = lengthAgainst(style.minWidth, base) ?? 0;
|
|
686
|
+
if (width === null && !(min > 0))
|
|
687
|
+
return null;
|
|
688
|
+
const max = style.maxWidth === 'none' ? null : lengthAgainst(style.maxWidth, base);
|
|
689
|
+
let own = width ?? 0;
|
|
690
|
+
if (max !== null)
|
|
691
|
+
own = Math.min(own, max);
|
|
692
|
+
own = Math.max(0, own, min);
|
|
693
|
+
if (isPct(len) && own === width) {
|
|
694
|
+
return Math.max(width, cell.box.horizontalExtra);
|
|
695
|
+
}
|
|
696
|
+
return own + cell.box.horizontalExtra;
|
|
697
|
+
}
|
|
698
|
+
/** A cell's or a column's width. One that adds a percentage to a length,
|
|
699
|
+
* a `calc()`, is `auto` in a table, as browsers read it: a column cannot be
|
|
700
|
+
* both a share of the table and a size of its own. */
|
|
701
|
+
function tableWidth(len, base) {
|
|
702
|
+
if (isPct(len) && (len.px || len.of))
|
|
703
|
+
return null;
|
|
704
|
+
return lengthAgainst(len, base);
|
|
705
|
+
}
|
|
333
706
|
function lengthAgainst(len, base) {
|
|
334
707
|
if (len === AUTO)
|
|
335
708
|
return null;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
709
|
+
return resolveOrNull(len, base);
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* How far each cell's content moves down to put its baseline on its first
|
|
713
|
+
* row's: 0 for a cell aligned `top`, `middle` or `bottom`, which is placed
|
|
714
|
+
* once the row's height is known. A cell's baseline is its first line box's,
|
|
715
|
+
* at any depth, or the bottom of its content where it has none (CSS 2.1
|
|
716
|
+
* 17.5.3); it is taken as laid out, from the cell's top. An empty cell has
|
|
717
|
+
* nothing to align and says nothing about the row's, as in a browser: its
|
|
718
|
+
* content's bottom is its height, which would hang every other cell in the
|
|
719
|
+
* row from the bottom of a cell given a height and nothing in it.
|
|
720
|
+
*/
|
|
721
|
+
function baselineLifts(cells, rowCount) {
|
|
722
|
+
const lift = new Array(cells.length).fill(0);
|
|
723
|
+
let any = false;
|
|
724
|
+
for (const cell of cells) {
|
|
725
|
+
const va = cell.box.style.verticalAlign;
|
|
726
|
+
if (va !== 'top' && va !== 'middle' && va !== 'bottom')
|
|
727
|
+
any = true;
|
|
728
|
+
}
|
|
729
|
+
if (!any)
|
|
730
|
+
return lift;
|
|
731
|
+
const own = new Array(cells.length).fill(NaN);
|
|
732
|
+
const row = new Array(rowCount).fill(-Infinity);
|
|
733
|
+
for (let i = 0; i < cells.length; i += 1) {
|
|
734
|
+
const box = cells[i].box;
|
|
735
|
+
const va = box.style.verticalAlign;
|
|
736
|
+
if (va === 'top' || va === 'middle' || va === 'bottom')
|
|
737
|
+
continue;
|
|
738
|
+
const first = firstBaselineIn(box);
|
|
739
|
+
if (first === null && !holdsFlow(box))
|
|
740
|
+
continue;
|
|
741
|
+
own[i] =
|
|
742
|
+
first !== null
|
|
743
|
+
? first - box.y
|
|
744
|
+
: box.height - box.padBottom - box.borderBottom;
|
|
745
|
+
row[cells[i].row] = Math.max(row[cells[i].row], own[i]);
|
|
746
|
+
}
|
|
747
|
+
for (let i = 0; i < cells.length; i += 1) {
|
|
748
|
+
if (own[i] === own[i])
|
|
749
|
+
lift[i] = row[cells[i].row] - own[i];
|
|
750
|
+
}
|
|
751
|
+
return lift;
|
|
752
|
+
}
|
|
753
|
+
/** Whether a cell has anything in flow in it. */
|
|
754
|
+
function holdsFlow(box) {
|
|
755
|
+
for (const child of box.children) {
|
|
756
|
+
if (child.outOfFlow || child.isFloat)
|
|
757
|
+
continue;
|
|
758
|
+
if (child.kind === 'text' && isBlank(child.text))
|
|
759
|
+
continue;
|
|
760
|
+
return true;
|
|
761
|
+
}
|
|
762
|
+
return false;
|
|
763
|
+
}
|
|
764
|
+
function rowSizing(rows, cells) {
|
|
765
|
+
const sizing = rows.map((row) => {
|
|
766
|
+
const height = row.style.height;
|
|
767
|
+
return {
|
|
768
|
+
constrained: typeof height === 'number',
|
|
769
|
+
percent: height !== AUTO && isPct(height) ? height.pct : null,
|
|
770
|
+
};
|
|
771
|
+
});
|
|
772
|
+
for (const cell of cells) {
|
|
773
|
+
if (cell.rowSpan > 1 || !sizing[cell.row])
|
|
774
|
+
continue;
|
|
775
|
+
const height = cell.box.style.height;
|
|
776
|
+
const row = sizing[cell.row];
|
|
777
|
+
if (typeof height === 'number')
|
|
778
|
+
row.constrained = true;
|
|
779
|
+
else if (height !== AUTO && isPct(height)) {
|
|
780
|
+
row.percent = Math.max(row.percent ?? 0, height.pct);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
return sizing;
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* The height a table has past its rows' given out among them, as browsers
|
|
787
|
+
* give it (the CSS Tables 3 draft leaves it open, csswg-drafts#4418): first
|
|
788
|
+
* to the rows a percentage sets, up to it; then to the rows nothing sets
|
|
789
|
+
* that have content, in proportion to their heights; then, where every row
|
|
790
|
+
* with content is set, to the empty rows, those nothing sets first, evenly;
|
|
791
|
+
* and else to every row with content, in proportion. A row whose cells set
|
|
792
|
+
* its height keeps it while an empty row beside it takes the rest.
|
|
793
|
+
*/
|
|
794
|
+
function growRows(heights, sizing, extra, base) {
|
|
795
|
+
const n = heights.length;
|
|
796
|
+
const deficit = heights.map((h, r) => {
|
|
797
|
+
const pct = sizing[r].percent;
|
|
798
|
+
return pct ? Math.max(0, (pct / 100) * base - h) : 0;
|
|
799
|
+
});
|
|
800
|
+
const empty = [];
|
|
801
|
+
const nothingSetEmpty = [];
|
|
802
|
+
const full = [];
|
|
803
|
+
const nothingSetFull = [];
|
|
804
|
+
let setFull = 0;
|
|
805
|
+
for (let r = 0; r < n; r += 1) {
|
|
806
|
+
const set = sizing[r].constrained || sizing[r].percent !== null;
|
|
807
|
+
if (heights[r] === 0 && deficit[r] === 0) {
|
|
808
|
+
empty.push(r);
|
|
809
|
+
if (!set)
|
|
810
|
+
nothingSetEmpty.push(r);
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
full.push(r);
|
|
814
|
+
if (set)
|
|
815
|
+
setFull += 1;
|
|
816
|
+
else
|
|
817
|
+
nothingSetFull.push(r);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
const owed = deficit.reduce((a, b) => a + b, 0);
|
|
821
|
+
if (owed > 0) {
|
|
822
|
+
const give = Math.min(owed, extra);
|
|
823
|
+
for (let r = 0; r < n; r += 1)
|
|
824
|
+
heights[r] += (give * deficit[r]) / owed;
|
|
825
|
+
extra -= give;
|
|
826
|
+
if (!(extra > 0))
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
const grow = (which, even) => {
|
|
830
|
+
let sum = 0;
|
|
831
|
+
for (const r of which)
|
|
832
|
+
sum += heights[r];
|
|
833
|
+
for (const r of which) {
|
|
834
|
+
heights[r] +=
|
|
835
|
+
even || !(sum > 0) ? extra / which.length : (extra * heights[r]) / sum;
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
if (nothingSetFull.length)
|
|
839
|
+
grow(nothingSetFull, false);
|
|
840
|
+
else if (empty.length && empty.length + setFull === n) {
|
|
841
|
+
grow(nothingSetEmpty.length ? nothingSetEmpty : empty, true);
|
|
842
|
+
}
|
|
843
|
+
else
|
|
844
|
+
grow(full, false);
|
|
339
845
|
}
|
|
340
846
|
//# sourceMappingURL=table.js.map
|