@react-x11/components 0.1.0 → 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 +979 -21
- package/dist/ansi/cast.d.ts +48 -0
- package/dist/ansi/cast.d.ts.map +1 -0
- package/dist/ansi/cast.js +135 -0
- package/dist/ansi/cast.js.map +1 -0
- package/dist/ansi/index.d.ts +10 -0
- package/dist/ansi/index.d.ts.map +1 -0
- package/dist/ansi/index.js +27 -0
- package/dist/ansi/index.js.map +1 -0
- package/dist/ansi/palette.d.ts +79 -0
- package/dist/ansi/palette.d.ts.map +1 -0
- package/dist/ansi/palette.js +155 -0
- package/dist/ansi/palette.js.map +1 -0
- package/dist/ansi/parse.d.ts +114 -0
- package/dist/ansi/parse.d.ts.map +1 -0
- package/dist/ansi/parse.js +687 -0
- package/dist/ansi/parse.js.map +1 -0
- package/dist/ansi/sgr.d.ts +87 -0
- package/dist/ansi/sgr.d.ts.map +1 -0
- package/dist/ansi/sgr.js +302 -0
- package/dist/ansi/sgr.js.map +1 -0
- package/dist/ansi/utf8.d.ts +15 -0
- package/dist/ansi/utf8.d.ts.map +1 -0
- package/dist/ansi/utf8.js +82 -0
- package/dist/ansi/utf8.js.map +1 -0
- package/dist/calendar/Calendar.d.ts +136 -0
- package/dist/calendar/Calendar.d.ts.map +1 -0
- package/dist/calendar/Calendar.js +460 -0
- package/dist/calendar/Calendar.js.map +1 -0
- package/dist/calendar/DatePicker.d.ts +52 -0
- package/dist/calendar/DatePicker.d.ts.map +1 -0
- package/dist/calendar/DatePicker.js +257 -0
- package/dist/calendar/DatePicker.js.map +1 -0
- package/dist/calendar/dates.d.ts +90 -0
- package/dist/calendar/dates.d.ts.map +1 -0
- package/dist/calendar/dates.js +236 -0
- package/dist/calendar/dates.js.map +1 -0
- package/dist/calendar/index.d.ts +8 -0
- package/dist/calendar/index.d.ts.map +1 -0
- package/dist/calendar/index.js +15 -0
- package/dist/calendar/index.js.map +1 -0
- package/dist/charts/components.d.ts +141 -0
- package/dist/charts/components.d.ts.map +1 -0
- package/dist/charts/components.js +580 -0
- package/dist/charts/components.js.map +1 -0
- package/dist/charts/data.d.ts +198 -0
- package/dist/charts/data.d.ts.map +1 -0
- package/dist/charts/data.js +616 -0
- package/dist/charts/data.js.map +1 -0
- package/dist/charts/hx.d.ts +21 -0
- package/dist/charts/hx.d.ts.map +1 -0
- package/dist/charts/hx.js +15 -0
- package/dist/charts/hx.js.map +1 -0
- package/dist/charts/index.d.ts +27 -0
- package/dist/charts/index.d.ts.map +1 -0
- package/dist/charts/index.js +38 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/charts/node.d.ts +96 -0
- package/dist/charts/node.d.ts.map +1 -0
- package/dist/charts/node.js +720 -0
- package/dist/charts/node.js.map +1 -0
- package/dist/charts/render.d.ts +153 -0
- package/dist/charts/render.d.ts.map +1 -0
- package/dist/charts/render.js +762 -0
- package/dist/charts/render.js.map +1 -0
- package/dist/charts/scale.d.ts +42 -0
- package/dist/charts/scale.d.ts.map +1 -0
- package/dist/charts/scale.js +173 -0
- package/dist/charts/scale.js.map +1 -0
- package/dist/charts/spec.d.ts +91 -0
- package/dist/charts/spec.d.ts.map +1 -0
- package/dist/charts/spec.js +33 -0
- package/dist/charts/spec.js.map +1 -0
- package/dist/charts/timers.d.ts +6 -0
- package/dist/charts/timers.d.ts.map +1 -0
- package/dist/charts/timers.js +14 -0
- package/dist/charts/timers.js.map +1 -0
- package/dist/code/hx.d.ts +24 -0
- package/dist/code/hx.d.ts.map +1 -0
- package/dist/code/hx.js +25 -0
- package/dist/code/hx.js.map +1 -0
- package/dist/code/index.d.ts +45 -0
- package/dist/code/index.d.ts.map +1 -0
- package/dist/code/index.js +93 -0
- package/dist/code/index.js.map +1 -0
- package/dist/code-editor/completion.d.ts +26 -0
- package/dist/code-editor/completion.d.ts.map +1 -0
- package/dist/code-editor/completion.js +129 -0
- package/dist/code-editor/completion.js.map +1 -0
- package/dist/code-editor/doc.d.ts +35 -0
- package/dist/code-editor/doc.d.ts.map +1 -0
- package/dist/code-editor/doc.js +162 -0
- package/dist/code-editor/doc.js.map +1 -0
- package/dist/code-editor/hx.d.ts +13 -0
- package/dist/code-editor/hx.d.ts.map +1 -0
- package/dist/code-editor/hx.js +10 -0
- package/dist/code-editor/hx.js.map +1 -0
- package/dist/code-editor/index.d.ts +88 -0
- package/dist/code-editor/index.d.ts.map +1 -0
- package/dist/code-editor/index.js +401 -0
- package/dist/code-editor/index.js.map +1 -0
- package/dist/code-editor/node.d.ts +343 -0
- package/dist/code-editor/node.d.ts.map +1 -0
- package/dist/code-editor/node.js +1521 -0
- package/dist/code-editor/node.js.map +1 -0
- package/dist/code-language/hljs.d.ts +47 -0
- package/dist/code-language/hljs.d.ts.map +1 -0
- package/dist/code-language/hljs.js +211 -0
- package/dist/code-language/hljs.js.map +1 -0
- package/dist/code-language/index.d.ts +22 -0
- package/dist/code-language/index.d.ts.map +1 -0
- package/dist/code-language/index.js +20 -0
- package/dist/code-language/index.js.map +1 -0
- package/dist/code-language/languages/glsl.d.ts +4 -0
- package/dist/code-language/languages/glsl.d.ts.map +1 -0
- package/dist/code-language/languages/glsl.js +99 -0
- package/dist/code-language/languages/glsl.js.map +1 -0
- package/dist/code-language/languages/javascript.d.ts +10 -0
- package/dist/code-language/languages/javascript.d.ts.map +1 -0
- package/dist/code-language/languages/javascript.js +360 -0
- package/dist/code-language/languages/javascript.js.map +1 -0
- package/dist/code-language/languages/json.d.ts +4 -0
- package/dist/code-language/languages/json.d.ts.map +1 -0
- package/dist/code-language/languages/json.js +68 -0
- package/dist/code-language/languages/json.js.map +1 -0
- package/dist/code-language/languages/shell.d.ts +4 -0
- package/dist/code-language/languages/shell.d.ts.map +1 -0
- package/dist/code-language/languages/shell.js +189 -0
- package/dist/code-language/languages/shell.js.map +1 -0
- package/dist/code-language/languages/sql.d.ts +11 -0
- package/dist/code-language/languages/sql.d.ts.map +1 -0
- package/dist/code-language/languages/sql.js +133 -0
- package/dist/code-language/languages/sql.js.map +1 -0
- package/dist/code-language/lezer.d.ts +24 -0
- package/dist/code-language/lezer.d.ts.map +1 -0
- package/dist/code-language/lezer.js +148 -0
- package/dist/code-language/lezer.js.map +1 -0
- package/dist/code-language/registry.d.ts +19 -0
- package/dist/code-language/registry.d.ts.map +1 -0
- package/dist/code-language/registry.js +56 -0
- package/dist/code-language/registry.js.map +1 -0
- package/dist/code-language/runs.d.ts +35 -0
- package/dist/code-language/runs.d.ts.map +1 -0
- package/dist/code-language/runs.js +88 -0
- package/dist/code-language/runs.js.map +1 -0
- package/dist/code-language/stream.d.ts +70 -0
- package/dist/code-language/stream.d.ts.map +1 -0
- package/dist/code-language/stream.js +243 -0
- package/dist/code-language/stream.js.map +1 -0
- package/dist/code-language/textmate.d.ts +27 -0
- package/dist/code-language/textmate.d.ts.map +1 -0
- package/dist/code-language/textmate.js +86 -0
- package/dist/code-language/textmate.js.map +1 -0
- package/dist/code-language/theme.d.ts +26 -0
- package/dist/code-language/theme.d.ts.map +1 -0
- package/dist/code-language/theme.js +108 -0
- package/dist/code-language/theme.js.map +1 -0
- package/dist/code-language/timers.d.ts +7 -0
- package/dist/code-language/timers.d.ts.map +1 -0
- package/dist/code-language/timers.js +22 -0
- package/dist/code-language/timers.js.map +1 -0
- package/dist/code-language/types.d.ts +173 -0
- package/dist/code-language/types.d.ts.map +1 -0
- package/dist/code-language/types.js +41 -0
- package/dist/code-language/types.js.map +1 -0
- package/dist/codeblock/index.d.ts +69 -0
- package/dist/codeblock/index.d.ts.map +1 -0
- package/dist/codeblock/index.js +85 -0
- package/dist/codeblock/index.js.map +1 -0
- package/dist/color-picker/ColorField.d.ts +39 -0
- package/dist/color-picker/ColorField.d.ts.map +1 -0
- package/dist/color-picker/ColorField.js +239 -0
- package/dist/color-picker/ColorField.js.map +1 -0
- package/dist/color-picker/ColorPicker.d.ts +109 -0
- package/dist/color-picker/ColorPicker.d.ts.map +1 -0
- package/dist/color-picker/ColorPicker.js +757 -0
- package/dist/color-picker/ColorPicker.js.map +1 -0
- package/dist/color-picker/color.d.ts +105 -0
- package/dist/color-picker/color.d.ts.map +1 -0
- package/dist/color-picker/color.js +313 -0
- package/dist/color-picker/color.js.map +1 -0
- package/dist/color-picker/index.d.ts +8 -0
- package/dist/color-picker/index.d.ts.map +1 -0
- package/dist/color-picker/index.js +19 -0
- package/dist/color-picker/index.js.map +1 -0
- package/dist/desktop-calendar/eds.d.ts +102 -0
- package/dist/desktop-calendar/eds.d.ts.map +1 -0
- package/dist/desktop-calendar/eds.js +356 -0
- package/dist/desktop-calendar/eds.js.map +1 -0
- package/dist/desktop-calendar/ical.d.ts +63 -0
- package/dist/desktop-calendar/ical.d.ts.map +1 -0
- package/dist/desktop-calendar/ical.js +57 -0
- package/dist/desktop-calendar/ical.js.map +1 -0
- package/dist/desktop-calendar/index.d.ts +72 -0
- package/dist/desktop-calendar/index.d.ts.map +1 -0
- package/dist/desktop-calendar/index.js +213 -0
- package/dist/desktop-calendar/index.js.map +1 -0
- package/dist/embed/client.d.ts +121 -0
- package/dist/embed/client.d.ts.map +1 -0
- package/dist/embed/client.js +203 -0
- package/dist/embed/client.js.map +1 -0
- package/dist/embed/host.d.ts +96 -0
- package/dist/embed/host.d.ts.map +1 -0
- package/dist/embed/host.js +266 -0
- package/dist/embed/host.js.map +1 -0
- package/dist/embed/index.d.ts +5 -0
- package/dist/embed/index.d.ts.map +1 -0
- package/dist/embed/index.js +13 -0
- package/dist/embed/index.js.map +1 -0
- package/dist/embed/timers.d.ts +6 -0
- package/dist/embed/timers.d.ts.map +1 -0
- package/dist/embed/timers.js +16 -0
- package/dist/embed/timers.js.map +1 -0
- package/dist/flow/draw.d.ts +45 -0
- package/dist/flow/draw.d.ts.map +1 -0
- package/dist/flow/draw.js +295 -0
- package/dist/flow/draw.js.map +1 -0
- package/dist/flow/index.d.ts +64 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +306 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/model.d.ts +158 -0
- package/dist/flow/model.d.ts.map +1 -0
- package/dist/flow/model.js +566 -0
- package/dist/flow/model.js.map +1 -0
- package/dist/flow/node.d.ts +429 -0
- package/dist/flow/node.d.ts.map +1 -0
- package/dist/flow/node.js +3025 -0
- package/dist/flow/node.js.map +1 -0
- package/dist/flow/paths.d.ts +43 -0
- package/dist/flow/paths.d.ts.map +1 -0
- package/dist/flow/paths.js +327 -0
- package/dist/flow/paths.js.map +1 -0
- package/dist/flow/types.d.ts +561 -0
- package/dist/flow/types.d.ts.map +1 -0
- package/dist/flow/types.js +2 -0
- package/dist/flow/types.js.map +1 -0
- package/dist/formula/hx.d.ts +24 -0
- package/dist/formula/hx.d.ts.map +1 -0
- package/dist/formula/hx.js +25 -0
- package/dist/formula/hx.js.map +1 -0
- package/dist/formula/index.d.ts +74 -0
- package/dist/formula/index.d.ts.map +1 -0
- package/dist/formula/index.js +155 -0
- package/dist/formula/index.js.map +1 -0
- package/dist/formula/katex.d.ts +78 -0
- package/dist/formula/katex.d.ts.map +1 -0
- package/dist/formula/katex.js +130 -0
- package/dist/formula/katex.js.map +1 -0
- package/dist/formula/layout.d.ts +103 -0
- package/dist/formula/layout.d.ts.map +1 -0
- package/dist/formula/layout.js +716 -0
- package/dist/formula/layout.js.map +1 -0
- package/dist/formula/node.d.ts +50 -0
- package/dist/formula/node.d.ts.map +1 -0
- package/dist/formula/node.js +351 -0
- package/dist/formula/node.js.map +1 -0
- package/dist/html/controls.d.ts +48 -0
- package/dist/html/controls.d.ts.map +1 -0
- package/dist/html/controls.js +195 -0
- package/dist/html/controls.js.map +1 -0
- package/dist/html/css/cascade.d.ts +51 -0
- package/dist/html/css/cascade.d.ts.map +1 -0
- package/dist/html/css/cascade.js +552 -0
- package/dist/html/css/cascade.js.map +1 -0
- package/dist/html/css/parse.d.ts +74 -0
- package/dist/html/css/parse.d.ts.map +1 -0
- package/dist/html/css/parse.js +464 -0
- package/dist/html/css/parse.js.map +1 -0
- package/dist/html/css/style.d.ts +142 -0
- package/dist/html/css/style.d.ts.map +1 -0
- package/dist/html/css/style.js +1145 -0
- package/dist/html/css/style.js.map +1 -0
- package/dist/html/css/ua.d.ts +5 -0
- package/dist/html/css/ua.d.ts.map +1 -0
- package/dist/html/css/ua.js +171 -0
- package/dist/html/css/ua.js.map +1 -0
- package/dist/html/css/values.d.ts +78 -0
- package/dist/html/css/values.d.ts.map +1 -0
- package/dist/html/css/values.js +330 -0
- package/dist/html/css/values.js.map +1 -0
- package/dist/html/dom.d.ts +112 -0
- package/dist/html/dom.d.ts.map +1 -0
- package/dist/html/dom.js +374 -0
- package/dist/html/dom.js.map +1 -0
- package/dist/html/hx.d.ts +24 -0
- package/dist/html/hx.d.ts.map +1 -0
- package/dist/html/hx.js +29 -0
- package/dist/html/hx.js.map +1 -0
- package/dist/html/index.d.ts +137 -0
- package/dist/html/index.d.ts.map +1 -0
- package/dist/html/index.js +339 -0
- package/dist/html/index.js.map +1 -0
- package/dist/html/layout/block.d.ts +58 -0
- package/dist/html/layout/block.d.ts.map +1 -0
- package/dist/html/layout/block.js +724 -0
- package/dist/html/layout/block.js.map +1 -0
- package/dist/html/layout/boxes.d.ts +261 -0
- package/dist/html/layout/boxes.d.ts.map +1 -0
- package/dist/html/layout/boxes.js +725 -0
- package/dist/html/layout/boxes.js.map +1 -0
- package/dist/html/layout/flex.d.ts +16 -0
- package/dist/html/layout/flex.d.ts.map +1 -0
- package/dist/html/layout/flex.js +242 -0
- package/dist/html/layout/flex.js.map +1 -0
- package/dist/html/layout/floats.d.ts +50 -0
- package/dist/html/layout/floats.d.ts.map +1 -0
- package/dist/html/layout/floats.js +110 -0
- package/dist/html/layout/floats.js.map +1 -0
- package/dist/html/layout/inline.d.ts +44 -0
- package/dist/html/layout/inline.d.ts.map +1 -0
- package/dist/html/layout/inline.js +700 -0
- package/dist/html/layout/inline.js.map +1 -0
- package/dist/html/layout/table.d.ts +5 -0
- package/dist/html/layout/table.d.ts.map +1 -0
- package/dist/html/layout/table.js +340 -0
- package/dist/html/layout/table.js.map +1 -0
- package/dist/html/node.d.ts +149 -0
- package/dist/html/node.d.ts.map +1 -0
- package/dist/html/node.js +861 -0
- package/dist/html/node.js.map +1 -0
- package/dist/html/paint.d.ts +48 -0
- package/dist/html/paint.d.ts.map +1 -0
- package/dist/html/paint.js +495 -0
- package/dist/html/paint.js.map +1 -0
- package/dist/html/resources.d.ts +48 -0
- package/dist/html/resources.d.ts.map +1 -0
- package/dist/html/resources.js +156 -0
- package/dist/html/resources.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +92 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/heights.d.ts +81 -0
- package/dist/internal/heights.d.ts.map +1 -0
- package/dist/internal/heights.js +193 -0
- package/dist/internal/heights.js.map +1 -0
- package/dist/internal/hx.d.ts +24 -0
- package/dist/internal/hx.d.ts.map +1 -0
- package/dist/internal/hx.js +27 -0
- package/dist/internal/hx.js.map +1 -0
- package/dist/internal/text.d.ts +6 -0
- package/dist/internal/text.d.ts.map +1 -0
- package/dist/internal/text.js +44 -0
- package/dist/internal/text.js.map +1 -0
- package/dist/internal/timers.d.ts +8 -0
- package/dist/internal/timers.d.ts.map +1 -0
- package/dist/internal/timers.js +22 -0
- package/dist/internal/timers.js.map +1 -0
- package/dist/internal/widget.d.ts +40 -0
- package/dist/internal/widget.d.ts.map +1 -0
- package/dist/internal/widget.js +44 -0
- package/dist/internal/widget.js.map +1 -0
- package/dist/markdown/ast.d.ts +126 -0
- package/dist/markdown/ast.d.ts.map +1 -0
- package/dist/markdown/ast.js +8 -0
- package/dist/markdown/ast.js.map +1 -0
- package/dist/markdown/hx.d.ts +24 -0
- package/dist/markdown/hx.d.ts.map +1 -0
- package/dist/markdown/hx.js +25 -0
- package/dist/markdown/hx.js.map +1 -0
- package/dist/markdown/index.d.ts +90 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +413 -0
- package/dist/markdown/index.js.map +1 -0
- package/dist/markdown/parse.d.ts +8 -0
- package/dist/markdown/parse.d.ts.map +1 -0
- package/dist/markdown/parse.js +911 -0
- package/dist/markdown/parse.js.map +1 -0
- package/dist/markdown/spans.d.ts +20 -0
- package/dist/markdown/spans.d.ts.map +1 -0
- package/dist/markdown/spans.js +96 -0
- package/dist/markdown/spans.js.map +1 -0
- package/dist/media-player/backends.d.ts +64 -0
- package/dist/media-player/backends.d.ts.map +1 -0
- package/dist/media-player/backends.js +110 -0
- package/dist/media-player/backends.js.map +1 -0
- package/dist/media-player/control.d.ts +40 -0
- package/dist/media-player/control.d.ts.map +1 -0
- package/dist/media-player/control.js +44 -0
- package/dist/media-player/control.js.map +1 -0
- package/dist/media-player/hx.d.ts +24 -0
- package/dist/media-player/hx.d.ts.map +1 -0
- package/dist/media-player/hx.js +25 -0
- package/dist/media-player/hx.js.map +1 -0
- package/dist/media-player/index.d.ts +107 -0
- package/dist/media-player/index.d.ts.map +1 -0
- package/dist/media-player/index.js +219 -0
- package/dist/media-player/index.js.map +1 -0
- package/dist/media-player/mpv.d.ts +4 -0
- package/dist/media-player/mpv.d.ts.map +1 -0
- package/dist/media-player/mpv.js +120 -0
- package/dist/media-player/mpv.js.map +1 -0
- package/dist/media-player/vlc.d.ts +8 -0
- package/dist/media-player/vlc.d.ts.map +1 -0
- package/dist/media-player/vlc.js +83 -0
- package/dist/media-player/vlc.js.map +1 -0
- package/dist/richtext/index.d.ts +19 -0
- package/dist/richtext/index.d.ts.map +1 -0
- package/dist/richtext/index.js +4 -0
- package/dist/richtext/index.js.map +1 -0
- package/dist/richtext/links.d.ts +12 -0
- package/dist/richtext/links.d.ts.map +1 -0
- package/dist/richtext/links.js +64 -0
- package/dist/richtext/links.js.map +1 -0
- package/dist/richtext/menu.d.ts +11 -0
- package/dist/richtext/menu.d.ts.map +1 -0
- package/dist/richtext/menu.js +43 -0
- package/dist/richtext/menu.js.map +1 -0
- package/dist/richtext/node.d.ts +151 -0
- package/dist/richtext/node.d.ts.map +1 -0
- package/dist/richtext/node.js +255 -0
- package/dist/richtext/node.js.map +1 -0
- package/dist/richtext/runs.d.ts +92 -0
- package/dist/richtext/runs.d.ts.map +1 -0
- package/dist/richtext/runs.js +158 -0
- package/dist/richtext/runs.js.map +1 -0
- package/dist/table/hx.d.ts +24 -0
- package/dist/table/hx.d.ts.map +1 -0
- package/dist/table/hx.js +25 -0
- package/dist/table/hx.js.map +1 -0
- package/dist/table/index.d.ts +169 -0
- package/dist/table/index.d.ts.map +1 -0
- package/dist/table/index.js +844 -0
- package/dist/table/index.js.map +1 -0
- package/dist/table/rows.d.ts +136 -0
- package/dist/table/rows.d.ts.map +1 -0
- package/dist/table/rows.js +146 -0
- package/dist/table/rows.js.map +1 -0
- package/dist/terminal/backends.d.ts +105 -0
- package/dist/terminal/backends.d.ts.map +1 -0
- package/dist/terminal/backends.js +185 -0
- package/dist/terminal/backends.js.map +1 -0
- package/dist/terminal/hx.d.ts +24 -0
- package/dist/terminal/hx.d.ts.map +1 -0
- package/dist/terminal/hx.js +25 -0
- package/dist/terminal/hx.js.map +1 -0
- package/dist/terminal/index.d.ts +160 -0
- package/dist/terminal/index.d.ts.map +1 -0
- package/dist/terminal/index.js +344 -0
- package/dist/terminal/index.js.map +1 -0
- package/dist/terminal/title.d.ts +24 -0
- package/dist/terminal/title.d.ts.map +1 -0
- package/dist/terminal/title.js +129 -0
- package/dist/terminal/title.js.map +1 -0
- package/dist/terminal/vt/colors.d.ts +63 -0
- package/dist/terminal/vt/colors.d.ts.map +1 -0
- package/dist/terminal/vt/colors.js +203 -0
- package/dist/terminal/vt/colors.js.map +1 -0
- package/dist/terminal/vt/diff.d.ts +117 -0
- package/dist/terminal/vt/diff.d.ts.map +1 -0
- package/dist/terminal/vt/diff.js +358 -0
- package/dist/terminal/vt/diff.js.map +1 -0
- package/dist/terminal/vt/fonts.d.ts +92 -0
- package/dist/terminal/vt/fonts.d.ts.map +1 -0
- package/dist/terminal/vt/fonts.js +178 -0
- package/dist/terminal/vt/fonts.js.map +1 -0
- package/dist/terminal/vt/index.d.ts +78 -0
- package/dist/terminal/vt/index.d.ts.map +1 -0
- package/dist/terminal/vt/index.js +312 -0
- package/dist/terminal/vt/index.js.map +1 -0
- package/dist/terminal/vt/keys.d.ts +74 -0
- package/dist/terminal/vt/keys.d.ts.map +1 -0
- package/dist/terminal/vt/keys.js +309 -0
- package/dist/terminal/vt/keys.js.map +1 -0
- package/dist/terminal/vt/mouse.d.ts +44 -0
- package/dist/terminal/vt/mouse.d.ts.map +1 -0
- package/dist/terminal/vt/mouse.js +106 -0
- package/dist/terminal/vt/mouse.js.map +1 -0
- package/dist/terminal/vt/node.d.ts +246 -0
- package/dist/terminal/vt/node.d.ts.map +1 -0
- package/dist/terminal/vt/node.js +1068 -0
- package/dist/terminal/vt/node.js.map +1 -0
- package/dist/terminal/vt/pty.d.ts +81 -0
- package/dist/terminal/vt/pty.d.ts.map +1 -0
- package/dist/terminal/vt/pty.js +201 -0
- package/dist/terminal/vt/pty.js.map +1 -0
- package/dist/terminal/vt/renderer.d.ts +179 -0
- package/dist/terminal/vt/renderer.d.ts.map +1 -0
- package/dist/terminal/vt/renderer.js +357 -0
- package/dist/terminal/vt/renderer.js.map +1 -0
- package/dist/terminal/vt/timers.d.ts +6 -0
- package/dist/terminal/vt/timers.d.ts.map +1 -0
- package/dist/terminal/vt/timers.js +16 -0
- package/dist/terminal/vt/timers.js.map +1 -0
- package/dist/terminal/vt/xterm.d.ts +142 -0
- package/dist/terminal/vt/xterm.d.ts.map +1 -0
- package/dist/terminal/vt/xterm.js +32 -0
- package/dist/terminal/vt/xterm.js.map +1 -0
- package/dist/terminal-output/hx.d.ts +24 -0
- package/dist/terminal-output/hx.d.ts.map +1 -0
- package/dist/terminal-output/hx.js +25 -0
- package/dist/terminal-output/hx.js.map +1 -0
- package/dist/terminal-output/index.d.ts +92 -0
- package/dist/terminal-output/index.d.ts.map +1 -0
- package/dist/terminal-output/index.js +179 -0
- package/dist/terminal-output/index.js.map +1 -0
- package/dist/terminal-output/runs.d.ts +27 -0
- package/dist/terminal-output/runs.d.ts.map +1 -0
- package/dist/terminal-output/runs.js +66 -0
- package/dist/terminal-output/runs.js.map +1 -0
- package/dist/three/canvas.d.ts +46 -0
- package/dist/three/canvas.d.ts.map +1 -0
- package/dist/three/canvas.js +305 -0
- package/dist/three/canvas.js.map +1 -0
- package/dist/three/events.d.ts +64 -0
- package/dist/three/events.d.ts.map +1 -0
- package/dist/three/events.js +146 -0
- package/dist/three/events.js.map +1 -0
- package/dist/three/geometries.d.ts +89 -0
- package/dist/three/geometries.d.ts.map +1 -0
- package/dist/three/geometries.js +345 -0
- package/dist/three/geometries.js.map +1 -0
- package/dist/three/globals.d.ts +7 -0
- package/dist/three/globals.d.ts.map +1 -0
- package/dist/three/globals.js +20 -0
- package/dist/three/globals.js.map +1 -0
- package/dist/three/hx.d.ts +9 -0
- package/dist/three/hx.d.ts.map +1 -0
- package/dist/three/hx.js +10 -0
- package/dist/three/hx.js.map +1 -0
- package/dist/three/index.d.ts +22 -0
- package/dist/three/index.d.ts.map +1 -0
- package/dist/three/index.js +24 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/jsx-dev-runtime.d.ts +19 -0
- package/dist/three/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/three/jsx-dev-runtime.js +2 -0
- package/dist/three/jsx-dev-runtime.js.map +1 -0
- package/dist/three/jsx-runtime.d.ts +19 -0
- package/dist/three/jsx-runtime.d.ts.map +1 -0
- package/dist/three/jsx-runtime.js +2 -0
- package/dist/three/jsx-runtime.js.map +1 -0
- package/dist/three/jsx.d.ts +198 -0
- package/dist/three/jsx.d.ts.map +1 -0
- package/dist/three/jsx.js +2 -0
- package/dist/three/jsx.js.map +1 -0
- package/dist/three/materials.d.ts +125 -0
- package/dist/three/materials.d.ts.map +1 -0
- package/dist/three/materials.js +229 -0
- package/dist/three/materials.js.map +1 -0
- package/dist/three/math.d.ts +146 -0
- package/dist/three/math.d.ts.map +1 -0
- package/dist/three/math.js +464 -0
- package/dist/three/math.js.map +1 -0
- package/dist/three/objects.d.ts +185 -0
- package/dist/three/objects.d.ts.map +1 -0
- package/dist/three/objects.js +309 -0
- package/dist/three/objects.js.map +1 -0
- package/dist/three/passes.d.ts +54 -0
- package/dist/three/passes.d.ts.map +1 -0
- package/dist/three/passes.js +78 -0
- package/dist/three/passes.js.map +1 -0
- package/dist/three/postprocess.d.ts +85 -0
- package/dist/three/postprocess.d.ts.map +1 -0
- package/dist/three/postprocess.js +503 -0
- package/dist/three/postprocess.js.map +1 -0
- package/dist/three/raycast.d.ts +24 -0
- package/dist/three/raycast.d.ts.map +1 -0
- package/dist/three/raycast.js +138 -0
- package/dist/three/raycast.js.map +1 -0
- package/dist/three/reconciler.d.ts +48 -0
- package/dist/three/reconciler.d.ts.map +1 -0
- package/dist/three/reconciler.js +416 -0
- package/dist/three/reconciler.js.map +1 -0
- package/dist/three/renderer-direct.d.ts +102 -0
- package/dist/three/renderer-direct.d.ts.map +1 -0
- package/dist/three/renderer-direct.js +782 -0
- package/dist/three/renderer-direct.js.map +1 -0
- package/dist/three/renderer-indirect.d.ts +68 -0
- package/dist/three/renderer-indirect.d.ts.map +1 -0
- package/dist/three/renderer-indirect.js +438 -0
- package/dist/three/renderer-indirect.js.map +1 -0
- package/dist/three/store.d.ts +81 -0
- package/dist/three/store.d.ts.map +1 -0
- package/dist/three/store.js +110 -0
- package/dist/three/store.js.map +1 -0
- package/dist/timeline/hx.d.ts +18 -0
- package/dist/timeline/hx.d.ts.map +1 -0
- package/dist/timeline/hx.js +10 -0
- package/dist/timeline/hx.js.map +1 -0
- package/dist/timeline/index.d.ts +152 -0
- package/dist/timeline/index.d.ts.map +1 -0
- package/dist/timeline/index.js +383 -0
- package/dist/timeline/index.js.map +1 -0
- package/dist/tray-host/hx.d.ts +24 -0
- package/dist/tray-host/hx.d.ts.map +1 -0
- package/dist/tray-host/hx.js +25 -0
- package/dist/tray-host/hx.js.map +1 -0
- package/dist/tray-host/index.d.ts +110 -0
- package/dist/tray-host/index.d.ts.map +1 -0
- package/dist/tray-host/index.js +191 -0
- package/dist/tray-host/index.js.map +1 -0
- package/dist/tray-host/manager.d.ts +137 -0
- package/dist/tray-host/manager.d.ts.map +1 -0
- package/dist/tray-host/manager.js +462 -0
- package/dist/tray-host/manager.js.map +1 -0
- package/dist/tray-host/notify.d.ts +22 -0
- package/dist/tray-host/notify.d.ts.map +1 -0
- package/dist/tray-host/notify.js +74 -0
- package/dist/tray-host/notify.js.map +1 -0
- package/dist/tray-host/protocol.d.ts +106 -0
- package/dist/tray-host/protocol.d.ts.map +1 -0
- package/dist/tray-host/protocol.js +191 -0
- package/dist/tray-host/protocol.js.map +1 -0
- package/dist/tree/hx.d.ts +24 -0
- package/dist/tree/hx.d.ts.map +1 -0
- package/dist/tree/hx.js +25 -0
- package/dist/tree/hx.js.map +1 -0
- package/dist/tree/index.d.ts +221 -0
- package/dist/tree/index.d.ts.map +1 -0
- package/dist/tree/index.js +716 -0
- package/dist/tree/index.js.map +1 -0
- package/dist/tree/internal.d.ts +18 -0
- package/dist/tree/internal.d.ts.map +1 -0
- package/dist/tree/internal.js +66 -0
- package/dist/tree/internal.js.map +1 -0
- package/dist/tree/rows.d.ts +177 -0
- package/dist/tree/rows.d.ts.map +1 -0
- package/dist/tree/rows.js +179 -0
- package/dist/tree/rows.js.map +1 -0
- package/package.json +166 -12
- package/src/ansi/cast.ts +159 -0
- package/src/ansi/index.ts +53 -0
- package/src/ansi/palette.ts +226 -0
- package/src/ansi/parse.ts +780 -0
- package/src/ansi/sgr.ts +380 -0
- package/src/ansi/utf8.ts +84 -0
- package/src/calendar/Calendar.ts +744 -0
- package/src/calendar/DatePicker.ts +368 -0
- package/src/calendar/dates.ts +307 -0
- package/src/calendar/index.ts +51 -0
- package/src/charts/components.ts +864 -0
- package/src/charts/data.ts +776 -0
- package/src/charts/hx.ts +39 -0
- package/src/charts/index.ts +99 -0
- package/src/charts/node.ts +932 -0
- package/src/charts/render.ts +982 -0
- package/src/charts/scale.ts +214 -0
- package/src/charts/spec.ts +122 -0
- package/src/charts/timers.ts +24 -0
- package/src/code/hx.ts +51 -0
- package/src/code/index.ts +174 -0
- package/src/code-editor/completion.ts +161 -0
- package/src/code-editor/doc.ts +198 -0
- package/src/code-editor/hx.ts +26 -0
- package/src/code-editor/index.ts +615 -0
- package/src/code-editor/node.ts +1926 -0
- package/src/code-language/hljs.ts +302 -0
- package/src/code-language/index.ts +51 -0
- package/src/code-language/languages/glsl.ts +120 -0
- package/src/code-language/languages/javascript.ts +419 -0
- package/src/code-language/languages/json.ts +72 -0
- package/src/code-language/languages/shell.ts +221 -0
- package/src/code-language/languages/sql.ts +165 -0
- package/src/code-language/lezer.ts +190 -0
- package/src/code-language/registry.ts +66 -0
- package/src/code-language/runs.ts +128 -0
- package/src/code-language/stream.ts +306 -0
- package/src/code-language/textmate.ts +134 -0
- package/src/code-language/theme.ts +124 -0
- package/src/code-language/timers.ts +36 -0
- package/src/code-language/types.ts +252 -0
- package/src/codeblock/index.ts +146 -0
- package/src/color-picker/ColorField.ts +333 -0
- package/src/color-picker/ColorPicker.ts +1069 -0
- package/src/color-picker/color.ts +399 -0
- package/src/color-picker/index.ts +50 -0
- package/src/desktop-calendar/eds.ts +484 -0
- package/src/desktop-calendar/ical.ts +119 -0
- package/src/desktop-calendar/index.ts +287 -0
- package/src/embed/client.ts +311 -0
- package/src/embed/host.ts +432 -0
- package/src/embed/index.ts +33 -0
- package/src/embed/timers.ts +32 -0
- package/src/flow/draw.ts +418 -0
- package/src/flow/index.ts +473 -0
- package/src/flow/model.ts +687 -0
- package/src/flow/node.ts +3694 -0
- package/src/flow/paths.ts +403 -0
- package/src/flow/types.ts +634 -0
- package/src/formula/hx.ts +51 -0
- package/src/formula/index.ts +243 -0
- package/src/formula/katex.ts +209 -0
- package/src/formula/layout.ts +876 -0
- package/src/formula/node.ts +467 -0
- package/src/html/controls.ts +244 -0
- package/src/html/css/cascade.ts +606 -0
- package/src/html/css/parse.ts +500 -0
- package/src/html/css/style.ts +1371 -0
- package/src/html/css/ua.ts +174 -0
- package/src/html/css/values.ts +358 -0
- package/src/html/dom.ts +410 -0
- package/src/html/hx.ts +55 -0
- package/src/html/index.ts +545 -0
- package/src/html/layout/block.ts +876 -0
- package/src/html/layout/boxes.ts +981 -0
- package/src/html/layout/flex.ts +297 -0
- package/src/html/layout/floats.ts +125 -0
- package/src/html/layout/inline.ts +870 -0
- package/src/html/layout/table.ts +380 -0
- package/src/html/node.ts +967 -0
- package/src/html/paint.ts +605 -0
- package/src/html/resources.ts +214 -0
- package/src/index.ts +638 -0
- package/src/internal/heights.ts +211 -0
- package/src/internal/hx.ts +53 -0
- package/src/internal/text.ts +44 -0
- package/src/internal/timers.ts +44 -0
- package/src/internal/widget.ts +92 -0
- package/src/markdown/ast.ts +163 -0
- package/src/markdown/hx.ts +51 -0
- package/src/markdown/index.ts +686 -0
- package/src/markdown/parse.ts +1037 -0
- package/src/markdown/spans.ts +143 -0
- package/src/media-player/backends.ts +155 -0
- package/src/media-player/control.ts +70 -0
- package/src/media-player/hx.ts +51 -0
- package/src/media-player/index.ts +378 -0
- package/src/media-player/mpv.ts +146 -0
- package/src/media-player/vlc.ts +97 -0
- package/src/richtext/index.ts +42 -0
- package/src/richtext/links.ts +78 -0
- package/src/richtext/menu.ts +49 -0
- package/src/richtext/node.ts +406 -0
- package/src/richtext/runs.ts +253 -0
- package/src/table/hx.ts +51 -0
- package/src/table/index.ts +1219 -0
- package/src/table/rows.ts +275 -0
- package/src/terminal/backends.ts +242 -0
- package/src/terminal/hx.ts +51 -0
- package/src/terminal/index.ts +574 -0
- package/src/terminal/title.ts +172 -0
- package/src/terminal/vt/colors.ts +247 -0
- package/src/terminal/vt/diff.ts +467 -0
- package/src/terminal/vt/fonts.ts +233 -0
- package/src/terminal/vt/index.ts +443 -0
- package/src/terminal/vt/keys.ts +369 -0
- package/src/terminal/vt/mouse.ts +144 -0
- package/src/terminal/vt/node.ts +1242 -0
- package/src/terminal/vt/pty.ts +334 -0
- package/src/terminal/vt/renderer.ts +555 -0
- package/src/terminal/vt/timers.ts +31 -0
- package/src/terminal/vt/xterm.ts +193 -0
- package/src/terminal-output/hx.ts +51 -0
- package/src/terminal-output/index.ts +340 -0
- package/src/terminal-output/runs.ts +79 -0
- package/src/three/canvas.ts +451 -0
- package/src/three/events.ts +197 -0
- package/src/three/geometries.ts +429 -0
- package/src/three/globals.ts +34 -0
- package/src/three/hx.ts +22 -0
- package/src/three/index.ts +98 -0
- package/src/three/jsx-dev-runtime.ts +27 -0
- package/src/three/jsx-runtime.ts +38 -0
- package/src/three/jsx.ts +275 -0
- package/src/three/materials.ts +270 -0
- package/src/three/math.ts +585 -0
- package/src/three/objects.ts +397 -0
- package/src/three/passes.ts +90 -0
- package/src/three/postprocess.ts +677 -0
- package/src/three/raycast.ts +189 -0
- package/src/three/react-reconciler.d.ts +50 -0
- package/src/three/reconciler.ts +624 -0
- package/src/three/renderer-direct.ts +1055 -0
- package/src/three/renderer-indirect.ts +570 -0
- package/src/three/store.ts +207 -0
- package/src/timeline/hx.ts +31 -0
- package/src/timeline/index.ts +603 -0
- package/src/tray-host/hx.ts +51 -0
- package/src/tray-host/index.ts +331 -0
- package/src/tray-host/manager.ts +639 -0
- package/src/tray-host/notify.ts +102 -0
- package/src/tray-host/protocol.ts +235 -0
- package/src/tree/hx.ts +51 -0
- package/src/tree/index.ts +1087 -0
- package/src/tree/internal.ts +87 -0
- package/src/tree/rows.ts +334 -0
- package/src/index.d.ts +0 -2
- package/src/index.js +0 -9
- package/src/sparkline/index.d.ts +0 -29
- package/src/sparkline/index.js +0 -50
- package/src/sparkline/node.js +0 -72
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
// <Timeline> — a vertical run of events: an indicator per step, a line
|
|
2
|
+
// between them, and content beside them.
|
|
3
|
+
//
|
|
4
|
+
// The API is [Chakra UI's Timeline](https://chakra-ui.com/docs/components/timeline)
|
|
5
|
+
// with its parts spelled flat — `Timeline.Root` is `<Timeline>`,
|
|
6
|
+
// `Timeline.Item` is `<TimelineItem>` — because that is how the rest of this
|
|
7
|
+
// package names a composition (see `/charts`), and because a namespace object
|
|
8
|
+
// is a module-scope mutation the tree-shaking guard would have to reason
|
|
9
|
+
// about. Everything else is Chakra's: the eight parts, `size`, `variant`, and
|
|
10
|
+
// the last item's line being off by default.
|
|
11
|
+
//
|
|
12
|
+
// It is pure composition of `<box>` and `<text>`, so there is no
|
|
13
|
+
// `registerElement` here and nothing for the reconciler to learn. The one
|
|
14
|
+
// piece that looks like it wants a custom drawing element — the line running
|
|
15
|
+
// down the gutter — is a 1px `<box>` positioned absolutely over the item's
|
|
16
|
+
// full height, which is exactly how the web does it and costs a rectangle
|
|
17
|
+
// instead of a paint callback.
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
20
|
+
import { useTheme } from 'react-x11';
|
|
21
|
+
import { interpolate, readableInk } from 'react-x11/style';
|
|
22
|
+
import type { Style } from 'react-x11/style';
|
|
23
|
+
|
|
24
|
+
import { hx } from './hx.js';
|
|
25
|
+
|
|
26
|
+
const h = React.createElement;
|
|
27
|
+
|
|
28
|
+
/** What `style` props here accept, matching the rest of the package. */
|
|
29
|
+
type StyleInput = Style | Style[];
|
|
30
|
+
|
|
31
|
+
// --- geometry ---------------------------------------------------------------
|
|
32
|
+
//
|
|
33
|
+
// Chakra's numbers, tightened for the desktop: a web timeline is read at arm's
|
|
34
|
+
// length down a column that owns the page, and a panel in an application
|
|
35
|
+
// window is not. Everything a caller is likely to want to move — the width of
|
|
36
|
+
// the whole thing, the space around it — is `style` on the root, so these stay
|
|
37
|
+
// constants rather than props.
|
|
38
|
+
|
|
39
|
+
/** The line. One pixel, at every size, the way every timeline draws it. */
|
|
40
|
+
const THICKNESS = 1;
|
|
41
|
+
/** Between the connector column and the content beside it. */
|
|
42
|
+
const ITEM_GAP = 12;
|
|
43
|
+
/** Between the rows inside one item's content. */
|
|
44
|
+
const CONTENT_GAP = 4;
|
|
45
|
+
/** Under one item's content: the run of line between two indicators. */
|
|
46
|
+
const STEP_GAP = 18;
|
|
47
|
+
/** Inside a title, between the label and whatever is set beside it. */
|
|
48
|
+
const TITLE_GAP = 6;
|
|
49
|
+
/**
|
|
50
|
+
* How far an indicator clears the line it sits on.
|
|
51
|
+
*
|
|
52
|
+
* Drawn as an `outline`, which is painted outside the border box and never
|
|
53
|
+
* seen by yoga — so the clearance cannot move the circle it surrounds, and a
|
|
54
|
+
* variant that turns it off cannot change the layout either.
|
|
55
|
+
*/
|
|
56
|
+
const RING = 2;
|
|
57
|
+
|
|
58
|
+
export type TimelineSize = 'sm' | 'md' | 'lg' | 'xl';
|
|
59
|
+
export type TimelineVariant = 'subtle' | 'solid' | 'outline' | 'plain';
|
|
60
|
+
|
|
61
|
+
interface SizeSpec {
|
|
62
|
+
/** The indicator's box, and so the diameter of its circle. */
|
|
63
|
+
indicator: number;
|
|
64
|
+
/** Whatever is written inside the indicator — a step number, a glyph. */
|
|
65
|
+
font: number;
|
|
66
|
+
/** How far the title sits off the theme's body size. */
|
|
67
|
+
titleStep: number;
|
|
68
|
+
/**
|
|
69
|
+
* What the title drops by, so its letters line up with the middle of an
|
|
70
|
+
* indicator taller than they are.
|
|
71
|
+
*
|
|
72
|
+
* A constant rather than a measurement: giving the title a `minHeight` of
|
|
73
|
+
* the indicator would centre it exactly, and would also push the
|
|
74
|
+
* description that far down for a row nothing else fills. These are
|
|
75
|
+
* Chakra's own numbers, and they are what half the difference between a
|
|
76
|
+
* 14px line and each circle comes to.
|
|
77
|
+
*/
|
|
78
|
+
titleTop: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The indicator sizes are Chakra's (16/20/24/32). The type sizes are not:
|
|
82
|
+
// they step off the theme's own `fontSize` rather than a fixed scale, so a
|
|
83
|
+
// theme that sets 16 gets a timeline in 16 instead of one that ignores it.
|
|
84
|
+
const SIZES: Record<TimelineSize, SizeSpec> = {
|
|
85
|
+
sm: { indicator: 16, font: 10, titleStep: -2, titleTop: 0 },
|
|
86
|
+
md: { indicator: 20, font: 12, titleStep: 0, titleTop: 0 },
|
|
87
|
+
lg: { indicator: 24, font: 12, titleStep: 0, titleTop: 2 },
|
|
88
|
+
xl: { indicator: 32, font: 14, titleStep: 0, titleTop: 6 },
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/** What the parts of one timeline share. */
|
|
92
|
+
interface TimelineLook {
|
|
93
|
+
variant: TimelineVariant;
|
|
94
|
+
/** The indicator colour, resolved: `tint` and `readableInk` need a real
|
|
95
|
+
* colour rather than a `$token`. */
|
|
96
|
+
accent: string;
|
|
97
|
+
/** What the line is cleared with around an indicator — the colour behind
|
|
98
|
+
* the timeline, also resolved. */
|
|
99
|
+
ground: string;
|
|
100
|
+
indicator: number;
|
|
101
|
+
indicatorFont: number;
|
|
102
|
+
titleFont: number;
|
|
103
|
+
titleTop: number;
|
|
104
|
+
descriptionFont: number;
|
|
105
|
+
showLastSeparator: boolean;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const LookContext = React.createContext<TimelineLook | null>(null);
|
|
109
|
+
/** Whether the item being rendered is the last one. */
|
|
110
|
+
const LastContext = React.createContext(false);
|
|
111
|
+
|
|
112
|
+
function useLook(part: string): TimelineLook {
|
|
113
|
+
const look = React.useContext(LookContext);
|
|
114
|
+
if (!look) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`@react-x11/components: <${part}> has to be inside a <Timeline>. ` +
|
|
117
|
+
'It reads the size, the variant and the accent from it.',
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
return look;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A colour prop, resolved against the palette.
|
|
125
|
+
*
|
|
126
|
+
* `$token` is normally the renderer's job — it resolves one against the
|
|
127
|
+
* nearest `theme` prop while painting — but `tint()` and `readableInk()` are
|
|
128
|
+
* arithmetic over real colours and run here, before any of that. So the two
|
|
129
|
+
* colours this component computes *from* are looked up eagerly, and every
|
|
130
|
+
* other colour it uses stays a `$token` in the style.
|
|
131
|
+
*/
|
|
132
|
+
function resolveColor(
|
|
133
|
+
value: string | undefined,
|
|
134
|
+
theme: Record<string, unknown>,
|
|
135
|
+
fallback: string,
|
|
136
|
+
): string {
|
|
137
|
+
if (!value) return fallback;
|
|
138
|
+
if (!value.startsWith('$')) return value;
|
|
139
|
+
const named = theme[value.slice(1)];
|
|
140
|
+
return typeof named === 'string' ? named : fallback;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* `accent` laid over `ground`, opaquely — a weak wash of the accent at
|
|
145
|
+
* `amount`, a strong one near 1.
|
|
146
|
+
*
|
|
147
|
+
* The obvious spelling of a `subtle` chip is `tint(accent, 0.22)`, and it is
|
|
148
|
+
* the wrong one here: the line runs *behind* every indicator, so a
|
|
149
|
+
* translucent chip has it showing through the middle of the mark. Mixing
|
|
150
|
+
* against the ground gives the same colour and stops the light — and it is
|
|
151
|
+
* still one expression for both palettes, because the ground is what
|
|
152
|
+
* differs between them.
|
|
153
|
+
*
|
|
154
|
+
* `interpolate` is the renderer's own colour lerp, the one that drives every
|
|
155
|
+
* `transition`; it answers null for anything it cannot parse, which is the
|
|
156
|
+
* same "keep going with what you were given" the rest of the style layer
|
|
157
|
+
* does.
|
|
158
|
+
*/
|
|
159
|
+
function over(ground: string, accent: string, amount: number): string {
|
|
160
|
+
const mixed = interpolate(ground, accent, amount);
|
|
161
|
+
return typeof mixed === 'string' ? mixed : accent;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Strings and numbers are only legal inside `<text>`, and every part here
|
|
166
|
+
* takes prose — `<TimelineTitle>Product shipped</TimelineTitle>` is the
|
|
167
|
+
* shortest thing that works and has to keep working. So a primitive child is
|
|
168
|
+
* wrapped, and an element child is left exactly as it was written.
|
|
169
|
+
*
|
|
170
|
+
* The wrapper carries no style of its own: `color`, `fontSize`, `fontFamily`
|
|
171
|
+
* and `fontWeight` inherit down the tree, so the box above it has already
|
|
172
|
+
* said everything there is to say — and an app's own `<text>` child inherits
|
|
173
|
+
* the same thing, which is what keeps the two forms looking alike.
|
|
174
|
+
*/
|
|
175
|
+
function withText(children: ReactNode): ReactNode {
|
|
176
|
+
let wrapped = false;
|
|
177
|
+
const mapped = React.Children.map(children, (child) => {
|
|
178
|
+
if (typeof child !== 'string' && typeof child !== 'number') return child;
|
|
179
|
+
wrapped = true;
|
|
180
|
+
return hx('text', null, child);
|
|
181
|
+
});
|
|
182
|
+
return wrapped ? mapped : children;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The part's own style, then the caller's — later entries win, which is how
|
|
187
|
+
* every `style` prop in this renderer resolves precedence.
|
|
188
|
+
*/
|
|
189
|
+
function styled(base: Style, extra: StyleInput | undefined): Style[] {
|
|
190
|
+
if (!extra) return [base];
|
|
191
|
+
return Array.isArray(extra) ? [base, ...extra] : [base, extra];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// --- root -------------------------------------------------------------------
|
|
195
|
+
|
|
196
|
+
export interface TimelineProps {
|
|
197
|
+
/** Indicator size, and the type that goes with it. Default `'md'`. */
|
|
198
|
+
size?: TimelineSize;
|
|
199
|
+
/** How an indicator is painted. Default `'solid'`. */
|
|
200
|
+
variant?: TimelineVariant;
|
|
201
|
+
/**
|
|
202
|
+
* The colour the indicators take — Chakra's `colorPalette`, as one colour.
|
|
203
|
+
* A `$token` is resolved against the palette. Default `$accent`.
|
|
204
|
+
*/
|
|
205
|
+
accent?: string;
|
|
206
|
+
/**
|
|
207
|
+
* The colour behind the timeline, which is what the line is cleared with
|
|
208
|
+
* around each indicator. Default `$background`; a timeline on a card wants
|
|
209
|
+
* `'$surface'`.
|
|
210
|
+
*/
|
|
211
|
+
ground?: string;
|
|
212
|
+
/**
|
|
213
|
+
* Keep the line running past the last indicator. Default false, as in
|
|
214
|
+
* Chakra: a line that stops at the last step reads as "this is the end of
|
|
215
|
+
* it", and one that carries on reads as "there is more below".
|
|
216
|
+
*/
|
|
217
|
+
showLastSeparator?: boolean;
|
|
218
|
+
/** The root `<box>`'s style — width, padding, `flexGrow`. */
|
|
219
|
+
style?: StyleInput;
|
|
220
|
+
'data-testname'?: string;
|
|
221
|
+
children?: ReactNode;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* A timeline.
|
|
226
|
+
*
|
|
227
|
+
* ```jsx
|
|
228
|
+
* <Timeline>
|
|
229
|
+
* <TimelineItem>
|
|
230
|
+
* <TimelineConnector>
|
|
231
|
+
* <TimelineSeparator />
|
|
232
|
+
* <TimelineIndicator>1</TimelineIndicator>
|
|
233
|
+
* </TimelineConnector>
|
|
234
|
+
* <TimelineContent>
|
|
235
|
+
* <TimelineTitle>Product shipped</TimelineTitle>
|
|
236
|
+
* <TimelineDescription>13th May 2021</TimelineDescription>
|
|
237
|
+
* </TimelineContent>
|
|
238
|
+
* </TimelineItem>
|
|
239
|
+
* </Timeline>
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
export function Timeline(props: TimelineProps): ReactElement {
|
|
243
|
+
// `Theme` is an interface, so it has no implicit index signature — the same
|
|
244
|
+
// widening `hx.ts` documents for the `theme` prop.
|
|
245
|
+
const theme = useTheme() as unknown as Record<string, unknown>;
|
|
246
|
+
const size = props.size ?? 'md';
|
|
247
|
+
const variant = props.variant ?? 'solid';
|
|
248
|
+
const accent = resolveColor(props.accent, theme, String(theme.accent));
|
|
249
|
+
const ground = resolveColor(props.ground, theme, String(theme.background));
|
|
250
|
+
const showLastSeparator = props.showLastSeparator ?? false;
|
|
251
|
+
const body = typeof theme.fontSize === 'number' ? theme.fontSize : 14;
|
|
252
|
+
|
|
253
|
+
const look = React.useMemo<TimelineLook>(() => {
|
|
254
|
+
const spec = SIZES[size] ?? SIZES.md;
|
|
255
|
+
return {
|
|
256
|
+
variant,
|
|
257
|
+
accent,
|
|
258
|
+
ground,
|
|
259
|
+
indicator: spec.indicator,
|
|
260
|
+
indicatorFont: spec.font,
|
|
261
|
+
titleFont: body + spec.titleStep,
|
|
262
|
+
titleTop: spec.titleTop,
|
|
263
|
+
// One size for every timeline, as in Chakra: a caption is a caption,
|
|
264
|
+
// and a description that grew with the indicator would make the
|
|
265
|
+
// biggest timeline the one whose dates are hardest to skim.
|
|
266
|
+
descriptionFont: body - 2,
|
|
267
|
+
showLastSeparator,
|
|
268
|
+
};
|
|
269
|
+
}, [size, variant, accent, ground, showLastSeparator, body]);
|
|
270
|
+
|
|
271
|
+
// Which item is last is a `:last-of-type` selector on the web and a walk
|
|
272
|
+
// here. `Children.toArray` drops the nulls a `{cond && <TimelineItem/>}`
|
|
273
|
+
// leaves behind, so "last" means the last one actually rendered.
|
|
274
|
+
const items = React.Children.toArray(props.children);
|
|
275
|
+
const end = items.length - 1;
|
|
276
|
+
|
|
277
|
+
return h(
|
|
278
|
+
LookContext.Provider,
|
|
279
|
+
{ value: look },
|
|
280
|
+
hx(
|
|
281
|
+
'box',
|
|
282
|
+
{
|
|
283
|
+
// A run of steps is a list, and saying so is what gets a screen
|
|
284
|
+
// reader to announce "list, 4 items" before reading the first one.
|
|
285
|
+
role: 'list',
|
|
286
|
+
style: styled({ flexDirection: 'column' }, props.style),
|
|
287
|
+
'data-testname': props['data-testname'],
|
|
288
|
+
},
|
|
289
|
+
items.map((child, i) =>
|
|
290
|
+
h(
|
|
291
|
+
LastContext.Provider,
|
|
292
|
+
{
|
|
293
|
+
key: (React.isValidElement(child) && child.key) || i,
|
|
294
|
+
value: i === end,
|
|
295
|
+
},
|
|
296
|
+
child,
|
|
297
|
+
),
|
|
298
|
+
),
|
|
299
|
+
),
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// --- item -------------------------------------------------------------------
|
|
304
|
+
|
|
305
|
+
export interface TimelineItemProps {
|
|
306
|
+
style?: StyleInput;
|
|
307
|
+
'data-testname'?: string;
|
|
308
|
+
children?: ReactNode;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* One step: a connector column and the content beside it, in whichever order
|
|
313
|
+
* they are written. Putting a `<TimelineContent>` *before* the connector is
|
|
314
|
+
* how the two-sided layout is built.
|
|
315
|
+
*/
|
|
316
|
+
export function TimelineItem(props: TimelineItemProps): ReactElement {
|
|
317
|
+
useLook('TimelineItem');
|
|
318
|
+
return hx(
|
|
319
|
+
'box',
|
|
320
|
+
{
|
|
321
|
+
// `listitem` takes its accessible name from its contents, so the title
|
|
322
|
+
// and the date below are what an assistive technology reads out.
|
|
323
|
+
role: 'listitem',
|
|
324
|
+
style: styled(
|
|
325
|
+
{
|
|
326
|
+
flexDirection: 'row',
|
|
327
|
+
alignItems: 'flex-start',
|
|
328
|
+
flexShrink: 0,
|
|
329
|
+
gap: ITEM_GAP,
|
|
330
|
+
},
|
|
331
|
+
props.style,
|
|
332
|
+
),
|
|
333
|
+
'data-testname': props['data-testname'],
|
|
334
|
+
},
|
|
335
|
+
props.children,
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// --- connector, separator, indicator ----------------------------------------
|
|
340
|
+
|
|
341
|
+
export interface TimelineConnectorProps {
|
|
342
|
+
style?: StyleInput;
|
|
343
|
+
'data-testname'?: string;
|
|
344
|
+
children?: ReactNode;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* The gutter: the indicator, and the line running past it.
|
|
349
|
+
*
|
|
350
|
+
* `alignSelf: 'stretch'` is what makes it as tall as the item however tall
|
|
351
|
+
* the content beside it turns out to be, which is what the separator measures
|
|
352
|
+
* itself against.
|
|
353
|
+
*
|
|
354
|
+
* Which *side* it lands on is nobody's decision here: `<TimelineItem>` is a
|
|
355
|
+
* plain flex row, so an RTL subtree mirrors it and the marks end up on the
|
|
356
|
+
* right, where an RTL reader starts. That is the reason there is no `side`
|
|
357
|
+
* prop — `direction` already says this, and a second way to say it is a
|
|
358
|
+
* second thing that can disagree with the first.
|
|
359
|
+
*/
|
|
360
|
+
export function TimelineConnector(props: TimelineConnectorProps): ReactElement {
|
|
361
|
+
useLook('TimelineConnector');
|
|
362
|
+
return hx(
|
|
363
|
+
'box',
|
|
364
|
+
{
|
|
365
|
+
style: styled(
|
|
366
|
+
{ alignSelf: 'stretch', alignItems: 'center', flexShrink: 0 },
|
|
367
|
+
props.style,
|
|
368
|
+
),
|
|
369
|
+
'data-testname': props['data-testname'],
|
|
370
|
+
},
|
|
371
|
+
props.children,
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export interface TimelineSeparatorProps {
|
|
376
|
+
style?: StyleInput;
|
|
377
|
+
'data-testname'?: string;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* The line down the gutter.
|
|
382
|
+
*
|
|
383
|
+
* It spans the item's full height and the indicator is painted over it,
|
|
384
|
+
* rather than being two stubs above and below — that is the arrangement that
|
|
385
|
+
* needs no arithmetic about where the indicator ends, and it is why the
|
|
386
|
+
* indicator carries a `ground`-coloured ring: the ring is what cuts the line.
|
|
387
|
+
*
|
|
388
|
+
* `zIndex: -1` rather than an ordering rule: Chakra's snippets write the
|
|
389
|
+
* separator before the indicator, but a reader who writes it after should get
|
|
390
|
+
* the same picture, and paint order is otherwise document order.
|
|
391
|
+
*/
|
|
392
|
+
export function TimelineSeparator(
|
|
393
|
+
props: TimelineSeparatorProps,
|
|
394
|
+
): ReactElement | null {
|
|
395
|
+
const look = useLook('TimelineSeparator');
|
|
396
|
+
const last = React.useContext(LastContext);
|
|
397
|
+
if (last && !look.showLastSeparator) return null;
|
|
398
|
+
return hx('box', {
|
|
399
|
+
style: styled(
|
|
400
|
+
{
|
|
401
|
+
position: 'absolute',
|
|
402
|
+
top: 0,
|
|
403
|
+
bottom: 0,
|
|
404
|
+
width: THICKNESS,
|
|
405
|
+
// `start` rather than `left`, so an RTL timeline puts its gutter on
|
|
406
|
+
// the other side without anything here knowing which way it reads.
|
|
407
|
+
start: Math.round((look.indicator - THICKNESS) / 2),
|
|
408
|
+
backgroundColor: '$border',
|
|
409
|
+
zIndex: -1,
|
|
410
|
+
},
|
|
411
|
+
props.style,
|
|
412
|
+
),
|
|
413
|
+
'data-testname': props['data-testname'],
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export interface TimelineIndicatorProps {
|
|
418
|
+
/** Overrides the timeline's `variant` for this step alone. */
|
|
419
|
+
variant?: TimelineVariant;
|
|
420
|
+
/** Overrides the timeline's `accent` for this step alone — a green tick
|
|
421
|
+
* for what is done, the danger colour for what failed. `$token` allowed. */
|
|
422
|
+
accent?: string;
|
|
423
|
+
/** The ink inside. Default: the readable one for the fill. */
|
|
424
|
+
color?: string;
|
|
425
|
+
style?: StyleInput;
|
|
426
|
+
'data-testname'?: string;
|
|
427
|
+
children?: ReactNode;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* The mark on the line: a filled circle by default, with a step number, a
|
|
432
|
+
* glyph or nothing inside it.
|
|
433
|
+
*
|
|
434
|
+
* An `<Icon>` in here needs no colour of its own — `color` inherits down the
|
|
435
|
+
* tree and a `mono` canvas resolves its ink the same way `<text>` does — but
|
|
436
|
+
* it does need a `size`, which does not inherit.
|
|
437
|
+
*/
|
|
438
|
+
export function TimelineIndicator(props: TimelineIndicatorProps): ReactElement {
|
|
439
|
+
const look = useLook('TimelineIndicator');
|
|
440
|
+
const theme = useTheme() as unknown as Record<string, unknown>;
|
|
441
|
+
const variant = props.variant ?? look.variant;
|
|
442
|
+
const accent =
|
|
443
|
+
props.accent === undefined
|
|
444
|
+
? look.accent
|
|
445
|
+
: resolveColor(props.accent, theme, look.accent);
|
|
446
|
+
|
|
447
|
+
// The ink on a filled indicator. The palette has already answered this for
|
|
448
|
+
// its own accent (`accentText`, itself derived), so ask it rather than
|
|
449
|
+
// deriving a second answer that could disagree; a colour the app brought is
|
|
450
|
+
// measured the same way core measures one.
|
|
451
|
+
const onAccent =
|
|
452
|
+
accent === theme.accent
|
|
453
|
+
? String(theme.accentText)
|
|
454
|
+
: readableInk(accent, [String(theme.text), String(theme.background)]);
|
|
455
|
+
|
|
456
|
+
const paint: Style =
|
|
457
|
+
variant === 'solid'
|
|
458
|
+
? { backgroundColor: accent, color: props.color ?? onAccent }
|
|
459
|
+
: variant === 'subtle'
|
|
460
|
+
? {
|
|
461
|
+
backgroundColor: over(look.ground, accent, 0.22),
|
|
462
|
+
color: props.color ?? '$text',
|
|
463
|
+
}
|
|
464
|
+
: variant === 'outline'
|
|
465
|
+
? {
|
|
466
|
+
backgroundColor: look.ground,
|
|
467
|
+
borderWidth: 1,
|
|
468
|
+
borderColor: over(look.ground, accent, 0.55),
|
|
469
|
+
color: props.color ?? '$text',
|
|
470
|
+
}
|
|
471
|
+
: // plain: no chip, but still opaque. The line runs *behind* every
|
|
472
|
+
// indicator, and a transparent one would have it struck through
|
|
473
|
+
// whatever is inside — which is the one thing a tick in a
|
|
474
|
+
// timeline must not look like.
|
|
475
|
+
{ backgroundColor: look.ground, color: props.color ?? '$text' };
|
|
476
|
+
|
|
477
|
+
return hx(
|
|
478
|
+
'box',
|
|
479
|
+
{
|
|
480
|
+
style: styled(
|
|
481
|
+
{
|
|
482
|
+
width: look.indicator,
|
|
483
|
+
height: look.indicator,
|
|
484
|
+
borderRadius: look.indicator / 2,
|
|
485
|
+
alignItems: 'center',
|
|
486
|
+
justifyContent: 'center',
|
|
487
|
+
flexShrink: 0,
|
|
488
|
+
fontSize: look.indicatorFont,
|
|
489
|
+
fontWeight: 'bold',
|
|
490
|
+
// The clearance around the mark. An explicit `outlineWidth` draws
|
|
491
|
+
// the ring whether or not anything is focused, which is what makes
|
|
492
|
+
// it usable as something other than a focus ring.
|
|
493
|
+
outlineWidth: RING,
|
|
494
|
+
outlineColor: look.ground,
|
|
495
|
+
outlineOffset: 0,
|
|
496
|
+
...paint,
|
|
497
|
+
},
|
|
498
|
+
props.style,
|
|
499
|
+
),
|
|
500
|
+
'data-testname': props['data-testname'],
|
|
501
|
+
},
|
|
502
|
+
withText(props.children),
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// --- content ----------------------------------------------------------------
|
|
507
|
+
|
|
508
|
+
export interface TimelineContentProps {
|
|
509
|
+
style?: StyleInput;
|
|
510
|
+
'data-testname'?: string;
|
|
511
|
+
children?: ReactNode;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* What the step says. Its bottom padding is the run of line between this
|
|
516
|
+
* indicator and the next, so the gutter's length is decided by the content
|
|
517
|
+
* beside it rather than by a height anyone has to name — and the last item
|
|
518
|
+
* has none, which is what stops a timeline ending in a gap.
|
|
519
|
+
*/
|
|
520
|
+
export function TimelineContent(props: TimelineContentProps): ReactElement {
|
|
521
|
+
useLook('TimelineContent');
|
|
522
|
+
const last = React.useContext(LastContext);
|
|
523
|
+
return hx(
|
|
524
|
+
'box',
|
|
525
|
+
{
|
|
526
|
+
style: styled(
|
|
527
|
+
{
|
|
528
|
+
flexDirection: 'column',
|
|
529
|
+
flexGrow: 1,
|
|
530
|
+
flexShrink: 1,
|
|
531
|
+
gap: CONTENT_GAP,
|
|
532
|
+
paddingBottom: last ? 0 : STEP_GAP,
|
|
533
|
+
},
|
|
534
|
+
props.style,
|
|
535
|
+
),
|
|
536
|
+
'data-testname': props['data-testname'],
|
|
537
|
+
},
|
|
538
|
+
withText(props.children),
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
export interface TimelineTitleProps {
|
|
543
|
+
style?: StyleInput;
|
|
544
|
+
'data-testname'?: string;
|
|
545
|
+
children?: ReactNode;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* The step's heading. A row, so a badge or a timestamp can sit beside the
|
|
550
|
+
* label, dropped by whatever it takes to line its letters up with the middle
|
|
551
|
+
* of the indicator at this size.
|
|
552
|
+
*/
|
|
553
|
+
export function TimelineTitle(props: TimelineTitleProps): ReactElement {
|
|
554
|
+
const look = useLook('TimelineTitle');
|
|
555
|
+
return hx(
|
|
556
|
+
'box',
|
|
557
|
+
{
|
|
558
|
+
style: styled(
|
|
559
|
+
{
|
|
560
|
+
flexDirection: 'row',
|
|
561
|
+
flexWrap: 'wrap',
|
|
562
|
+
alignItems: 'center',
|
|
563
|
+
gap: TITLE_GAP,
|
|
564
|
+
marginTop: look.titleTop,
|
|
565
|
+
fontSize: look.titleFont,
|
|
566
|
+
fontWeight: 'bold',
|
|
567
|
+
color: '$text',
|
|
568
|
+
},
|
|
569
|
+
props.style,
|
|
570
|
+
),
|
|
571
|
+
'data-testname': props['data-testname'],
|
|
572
|
+
},
|
|
573
|
+
withText(props.children),
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export interface TimelineDescriptionProps {
|
|
578
|
+
style?: StyleInput;
|
|
579
|
+
'data-testname'?: string;
|
|
580
|
+
children?: ReactNode;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** The quiet line under the title: a date, a name, a status. */
|
|
584
|
+
export function TimelineDescription(
|
|
585
|
+
props: TimelineDescriptionProps,
|
|
586
|
+
): ReactElement {
|
|
587
|
+
const look = useLook('TimelineDescription');
|
|
588
|
+
return hx(
|
|
589
|
+
'box',
|
|
590
|
+
{
|
|
591
|
+
style: styled(
|
|
592
|
+
{
|
|
593
|
+
flexDirection: 'column',
|
|
594
|
+
fontSize: look.descriptionFont,
|
|
595
|
+
color: '$textMuted',
|
|
596
|
+
},
|
|
597
|
+
props.style,
|
|
598
|
+
),
|
|
599
|
+
'data-testname': props['data-testname'],
|
|
600
|
+
},
|
|
601
|
+
withText(props.children),
|
|
602
|
+
);
|
|
603
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// `React.createElement`, typed against react-x11's host elements.
|
|
2
|
+
//
|
|
3
|
+
// The library writes `h(...)` rather than JSX — a convention inherited from
|
|
4
|
+
// core, and worth keeping so moving code between the two repos stays a
|
|
5
|
+
// rename. But `React.createElement`'s own overloads are `@types/react`'s, and
|
|
6
|
+
// they describe the DOM: a `<box onKeyDown>` handler is checked against
|
|
7
|
+
// React's `KeyboardEvent`, not react-x11's, and the whole props object is
|
|
8
|
+
// measured against `DOMAttributes`. Everything interesting fails.
|
|
9
|
+
//
|
|
10
|
+
// So the element name is looked up in react-x11's own element table instead.
|
|
11
|
+
// `hx('box', …)` gets `<box>`'s real props — `ev.keysym` on a key handler,
|
|
12
|
+
// `onDraw` on a `<canvas>` — and `hx('div', …)` is an error, which is the
|
|
13
|
+
// same guarantee the JSX namespace gives `examples/` and `test/types/`.
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import type { Key, ReactElement, ReactNode } from 'react';
|
|
16
|
+
import type { ReactX11Elements, Theme } from 'react-x11';
|
|
17
|
+
|
|
18
|
+
/** The host elements, by name. */
|
|
19
|
+
export type Host = ReactX11Elements;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* What every element takes on top of its own props.
|
|
23
|
+
*
|
|
24
|
+
* `theme` is honoured by **every** node — `Node.theme` merges `props.theme`
|
|
25
|
+
* over the inherited palette, whatever the kind — but react-x11's element
|
|
26
|
+
* declarations only put it on `<window>`. A widget re-declares the theme it
|
|
27
|
+
* read from context onto its own root so that `$token` values still resolve
|
|
28
|
+
* inside a `<popup>`, which is a separate window and does not inherit the
|
|
29
|
+
* trigger's node tree. So the prop is real; only the declaration is narrow.
|
|
30
|
+
*/
|
|
31
|
+
interface CommonProps {
|
|
32
|
+
key?: Key;
|
|
33
|
+
/** `Theme` is listed alongside the record because it is an interface, and
|
|
34
|
+
* an interface has no implicit index signature — so the palette `useTheme`
|
|
35
|
+
* hands back is not assignable to the record react-x11 declares. */
|
|
36
|
+
theme?: Theme | Record<string, string | number>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function hx<K extends keyof Host>(
|
|
40
|
+
type: K,
|
|
41
|
+
// `theme` is dropped from the element's own props before the merge:
|
|
42
|
+
// `<window>` and `<popup>` already declare it, narrower, and intersecting
|
|
43
|
+
// the two would demand a value satisfying both.
|
|
44
|
+
props?: (Omit<Host[K], 'theme'> & CommonProps) | null,
|
|
45
|
+
...children: ReactNode[]
|
|
46
|
+
): ReactElement {
|
|
47
|
+
// The cast is the whole point of the wrapper: `createElement`'s string
|
|
48
|
+
// overload insists on DOM props, and the signature above has already
|
|
49
|
+
// checked these against the element that will actually receive them.
|
|
50
|
+
return React.createElement(type as string, props as never, ...children);
|
|
51
|
+
}
|