@elastic/isomer-studio 0.0.0 → 0.4.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/LICENSE.txt +93 -0
- package/NOTICE.txt +17329 -0
- package/README.md +64 -0
- package/THIRD_PARTY_LICENSES.md +404 -0
- package/bin/isomer-studio.js +10 -0
- package/dist/app/assets/codicon-5T574S7B.ttf +0 -0
- package/dist/app/assets/editor.worker.js +11 -0
- package/dist/app/assets/esbuild.wasm +0 -0
- package/dist/app/assets/json.worker.js +47 -0
- package/dist/app/assets/slack.css +1 -0
- package/dist/app/assets/studio.css +11 -0
- package/dist/app/assets/ts.worker.js +37029 -0
- package/dist/app/index.html +16 -0
- package/dist/apps/app_host.d.ts +8 -0
- package/dist/apps/app_host.d.ts.map +1 -0
- package/dist/apps/app_host.js +73 -0
- package/dist/apps/app_host.js.map +1 -0
- package/dist/browser/dev_host.d.ts +5 -0
- package/dist/browser/dev_host.d.ts.map +1 -0
- package/dist/browser/dev_host.js +46 -0
- package/dist/browser/dev_host.js.map +1 -0
- package/dist/browser/mount.d.ts +16 -0
- package/dist/browser/mount.d.ts.map +1 -0
- package/dist/browser/mount.js +37 -0
- package/dist/browser/mount.js.map +1 -0
- package/dist/browser/static_host.d.ts +5 -0
- package/dist/browser/static_host.d.ts.map +1 -0
- package/dist/browser/static_host.js +55 -0
- package/dist/browser/static_host.js.map +1 -0
- package/dist/chrome/accent.d.ts +14 -0
- package/dist/chrome/accent.d.ts.map +1 -0
- package/dist/chrome/accent.js +31 -0
- package/dist/chrome/accent.js.map +1 -0
- package/dist/chrome/app_pages.d.ts +13 -0
- package/dist/chrome/app_pages.d.ts.map +1 -0
- package/dist/chrome/app_pages.js +33 -0
- package/dist/chrome/app_pages.js.map +1 -0
- package/dist/chrome/color_mode.d.ts +10 -0
- package/dist/chrome/color_mode.d.ts.map +1 -0
- package/dist/chrome/color_mode.js +45 -0
- package/dist/chrome/color_mode.js.map +1 -0
- package/dist/chrome/dev_tint.d.ts +7 -0
- package/dist/chrome/dev_tint.d.ts.map +1 -0
- package/dist/chrome/dev_tint.js +31 -0
- package/dist/chrome/dev_tint.js.map +1 -0
- package/dist/chrome/header.d.ts +20 -0
- package/dist/chrome/header.d.ts.map +1 -0
- package/dist/chrome/header.js +124 -0
- package/dist/chrome/header.js.map +1 -0
- package/dist/chrome/icon_data_uri.d.ts +12 -0
- package/dist/chrome/icon_data_uri.d.ts.map +1 -0
- package/dist/chrome/icon_data_uri.js +21 -0
- package/dist/chrome/icon_data_uri.js.map +1 -0
- package/dist/chrome/isomer_mark.d.ts +17 -0
- package/dist/chrome/isomer_mark.d.ts.map +1 -0
- package/dist/chrome/isomer_mark.js +46 -0
- package/dist/chrome/isomer_mark.js.map +1 -0
- package/dist/chrome/nav.d.ts +22 -0
- package/dist/chrome/nav.d.ts.map +1 -0
- package/dist/chrome/nav.js +306 -0
- package/dist/chrome/nav.js.map +1 -0
- package/dist/chrome/nav_groups.d.ts +6 -0
- package/dist/chrome/nav_groups.d.ts.map +1 -0
- package/dist/chrome/nav_groups.js +48 -0
- package/dist/chrome/nav_groups.js.map +1 -0
- package/dist/chrome/nav_sections.d.ts +29 -0
- package/dist/chrome/nav_sections.d.ts.map +1 -0
- package/dist/chrome/nav_sections.js +55 -0
- package/dist/chrome/nav_sections.js.map +1 -0
- package/dist/chrome/oklch.d.ts +10 -0
- package/dist/chrome/oklch.d.ts.map +1 -0
- package/dist/chrome/oklch.js +61 -0
- package/dist/chrome/oklch.js.map +1 -0
- package/dist/chrome/primitive_glyph.d.ts +14 -0
- package/dist/chrome/primitive_glyph.d.ts.map +1 -0
- package/dist/chrome/primitive_glyph.js +48 -0
- package/dist/chrome/primitive_glyph.js.map +1 -0
- package/dist/chrome/primitive_heading.d.ts +14 -0
- package/dist/chrome/primitive_heading.d.ts.map +1 -0
- package/dist/chrome/primitive_heading.js +32 -0
- package/dist/chrome/primitive_heading.js.map +1 -0
- package/dist/chrome/primitive_peek.d.ts +8 -0
- package/dist/chrome/primitive_peek.d.ts.map +1 -0
- package/dist/chrome/primitive_peek.js +51 -0
- package/dist/chrome/primitive_peek.js.map +1 -0
- package/dist/chrome/primitive_search.d.ts +9 -0
- package/dist/chrome/primitive_search.d.ts.map +1 -0
- package/dist/chrome/primitive_search.js +93 -0
- package/dist/chrome/primitive_search.js.map +1 -0
- package/dist/chrome/route.d.ts +48 -0
- package/dist/chrome/route.d.ts.map +1 -0
- package/dist/chrome/route.js +136 -0
- package/dist/chrome/route.js.map +1 -0
- package/dist/cli/args.d.ts +39 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +171 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/run.d.ts +15 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +113 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +22 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +118 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +11 -0
- package/dist/config.js.map +1 -0
- package/dist/dev/code_editor.d.ts +10 -0
- package/dist/dev/code_editor.d.ts.map +1 -0
- package/dist/dev/code_editor.js +22 -0
- package/dist/dev/code_editor.js.map +1 -0
- package/dist/dev/dev_view.d.ts +9 -0
- package/dist/dev/dev_view.d.ts.map +1 -0
- package/dist/dev/dev_view.js +65 -0
- package/dist/dev/dev_view.js.map +1 -0
- package/dist/dev/editor_panel.d.ts +17 -0
- package/dist/dev/editor_panel.d.ts.map +1 -0
- package/dist/dev/editor_panel.js +51 -0
- package/dist/dev/editor_panel.js.map +1 -0
- package/dist/dev/monaco_editor.d.ts +15 -0
- package/dist/dev/monaco_editor.d.ts.map +1 -0
- package/dist/dev/monaco_editor.js +159 -0
- package/dist/dev/monaco_editor.js.map +1 -0
- package/dist/dev/preview_panel.d.ts +10 -0
- package/dist/dev/preview_panel.d.ts.map +1 -0
- package/dist/dev/preview_panel.js +45 -0
- package/dist/dev/preview_panel.js.map +1 -0
- package/dist/dev/prop_reference.d.ts +9 -0
- package/dist/dev/prop_reference.d.ts.map +1 -0
- package/dist/dev/prop_reference.js +134 -0
- package/dist/dev/prop_reference.js.map +1 -0
- package/dist/dev/tsx_language.d.ts +10 -0
- package/dist/dev/tsx_language.d.ts.map +1 -0
- package/dist/dev/tsx_language.js +283 -0
- package/dist/dev/tsx_language.js.map +1 -0
- package/dist/dev/use_editor.d.ts +23 -0
- package/dist/dev/use_editor.d.ts.map +1 -0
- package/dist/dev/use_editor.js +124 -0
- package/dist/dev/use_editor.js.map +1 -0
- package/dist/docs/docs_view.d.ts +10 -0
- package/dist/docs/docs_view.d.ts.map +1 -0
- package/dist/docs/docs_view.js +80 -0
- package/dist/docs/docs_view.js.map +1 -0
- package/dist/docs/example_source.d.ts +7 -0
- package/dist/docs/example_source.d.ts.map +1 -0
- package/dist/docs/example_source.js +56 -0
- package/dist/docs/example_source.js.map +1 -0
- package/dist/docs/examples_panel.d.ts +10 -0
- package/dist/docs/examples_panel.d.ts.map +1 -0
- package/dist/docs/examples_panel.js +51 -0
- package/dist/docs/examples_panel.js.map +1 -0
- package/dist/docs/gallery_view.d.ts +9 -0
- package/dist/docs/gallery_view.d.ts.map +1 -0
- package/dist/docs/gallery_view.js +98 -0
- package/dist/docs/gallery_view.js.map +1 -0
- package/dist/docs/inline_code.d.ts +11 -0
- package/dist/docs/inline_code.d.ts.map +1 -0
- package/dist/docs/inline_code.js +24 -0
- package/dist/docs/inline_code.js.map +1 -0
- package/dist/docs/on_this_page.d.ts +17 -0
- package/dist/docs/on_this_page.d.ts.map +1 -0
- package/dist/docs/on_this_page.js +77 -0
- package/dist/docs/on_this_page.js.map +1 -0
- package/dist/docs/props_table.d.ts +14 -0
- package/dist/docs/props_table.d.ts.map +1 -0
- package/dist/docs/props_table.js +34 -0
- package/dist/docs/props_table.js.map +1 -0
- package/dist/home/apps_section.d.ts +6 -0
- package/dist/home/apps_section.d.ts.map +1 -0
- package/dist/home/apps_section.js +44 -0
- package/dist/home/apps_section.js.map +1 -0
- package/dist/home/featured_strip.d.ts +12 -0
- package/dist/home/featured_strip.d.ts.map +1 -0
- package/dist/home/featured_strip.js +176 -0
- package/dist/home/featured_strip.js.map +1 -0
- package/dist/home/home_view.d.ts +11 -0
- package/dist/home/home_view.d.ts.map +1 -0
- package/dist/home/home_view.js +261 -0
- package/dist/home/home_view.js.map +1 -0
- package/dist/home/links.d.ts +8 -0
- package/dist/home/links.d.ts.map +1 -0
- package/dist/home/links.js +14 -0
- package/dist/home/links.js.map +1 -0
- package/dist/home/loaded_panel.d.ts +6 -0
- package/dist/home/loaded_panel.d.ts.map +1 -0
- package/dist/home/loaded_panel.js +116 -0
- package/dist/home/loaded_panel.js.map +1 -0
- package/dist/home/surface_chart.d.ts +6 -0
- package/dist/home/surface_chart.d.ts.map +1 -0
- package/dist/home/surface_chart.js +263 -0
- package/dist/home/surface_chart.js.map +1 -0
- package/dist/home/tokens.d.ts +49 -0
- package/dist/home/tokens.d.ts.map +1 -0
- package/dist/home/tokens.js +171 -0
- package/dist/home/tokens.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/model/app_problems.d.ts +4 -0
- package/dist/model/app_problems.d.ts.map +1 -0
- package/dist/model/app_problems.js +90 -0
- package/dist/model/app_problems.js.map +1 -0
- package/dist/model/authoring_types.d.ts +23 -0
- package/dist/model/authoring_types.d.ts.map +1 -0
- package/dist/model/authoring_types.js +35 -0
- package/dist/model/authoring_types.js.map +1 -0
- package/dist/model/compile_jsx.d.ts +19 -0
- package/dist/model/compile_jsx.d.ts.map +1 -0
- package/dist/model/compile_jsx.js +55 -0
- package/dist/model/compile_jsx.js.map +1 -0
- package/dist/model/compose_example.d.ts +9 -0
- package/dist/model/compose_example.d.ts.map +1 -0
- package/dist/model/compose_example.js +24 -0
- package/dist/model/compose_example.js.map +1 -0
- package/dist/model/composition_key.d.ts +6 -0
- package/dist/model/composition_key.d.ts.map +1 -0
- package/dist/model/composition_key.js +26 -0
- package/dist/model/composition_key.js.map +1 -0
- package/dist/model/describe_runtime.d.ts +33 -0
- package/dist/model/describe_runtime.d.ts.map +1 -0
- package/dist/model/describe_runtime.js +77 -0
- package/dist/model/describe_runtime.js.map +1 -0
- package/dist/model/featured.d.ts +11 -0
- package/dist/model/featured.d.ts.map +1 -0
- package/dist/model/featured.js +70 -0
- package/dist/model/featured.js.map +1 -0
- package/dist/model/jsx_transform.d.ts +10 -0
- package/dist/model/jsx_transform.d.ts.map +1 -0
- package/dist/model/jsx_transform.js +31 -0
- package/dist/model/jsx_transform.js.map +1 -0
- package/dist/model/png_manifest.d.ts +23 -0
- package/dist/model/png_manifest.d.ts.map +1 -0
- package/dist/model/png_manifest.js +26 -0
- package/dist/model/png_manifest.js.map +1 -0
- package/dist/model/read_examples.d.ts +12 -0
- package/dist/model/read_examples.d.ts.map +1 -0
- package/dist/model/read_examples.js +43 -0
- package/dist/model/read_examples.js.map +1 -0
- package/dist/model/search.d.ts +4 -0
- package/dist/model/search.d.ts.map +1 -0
- package/dist/model/search.js +29 -0
- package/dist/model/search.js.map +1 -0
- package/dist/model/sha256.d.ts +3 -0
- package/dist/model/sha256.d.ts.map +1 -0
- package/dist/model/sha256.js +72 -0
- package/dist/model/sha256.js.map +1 -0
- package/dist/model/slack_limits.d.ts +9 -0
- package/dist/model/slack_limits.d.ts.map +1 -0
- package/dist/model/slack_limits.js +213 -0
- package/dist/model/slack_limits.js.map +1 -0
- package/dist/node/app_bundle.d.ts +45 -0
- package/dist/node/app_bundle.d.ts.map +1 -0
- package/dist/node/app_bundle.js +212 -0
- package/dist/node/app_bundle.js.map +1 -0
- package/dist/node/build_site.d.ts +28 -0
- package/dist/node/build_site.d.ts.map +1 -0
- package/dist/node/build_site.js +90 -0
- package/dist/node/build_site.js.map +1 -0
- package/dist/node/check.d.ts +40 -0
- package/dist/node/check.d.ts.map +1 -0
- package/dist/node/check.js +162 -0
- package/dist/node/check.js.map +1 -0
- package/dist/node/dev_bundle.d.ts +21 -0
- package/dist/node/dev_bundle.d.ts.map +1 -0
- package/dist/node/dev_bundle.js +121 -0
- package/dist/node/dev_bundle.js.map +1 -0
- package/dist/node/dev_server.d.ts +16 -0
- package/dist/node/dev_server.d.ts.map +1 -0
- package/dist/node/dev_server.js +291 -0
- package/dist/node/dev_server.js.map +1 -0
- package/dist/node/init_config.d.ts +30 -0
- package/dist/node/init_config.d.ts.map +1 -0
- package/dist/node/init_config.js +158 -0
- package/dist/node/init_config.js.map +1 -0
- package/dist/node/load_config.d.ts +34 -0
- package/dist/node/load_config.d.ts.map +1 -0
- package/dist/node/load_config.js +246 -0
- package/dist/node/load_config.js.map +1 -0
- package/dist/node/project_resolution.d.ts +17 -0
- package/dist/node/project_resolution.d.ts.map +1 -0
- package/dist/node/project_resolution.js +66 -0
- package/dist/node/project_resolution.js.map +1 -0
- package/dist/node/rasterize.d.ts +23 -0
- package/dist/node/rasterize.d.ts.map +1 -0
- package/dist/node/rasterize.js +79 -0
- package/dist/node/rasterize.js.map +1 -0
- package/dist/node/report.d.ts +8 -0
- package/dist/node/report.d.ts.map +1 -0
- package/dist/node/report.js +57 -0
- package/dist/node/report.js.map +1 -0
- package/dist/node/resolve_hooks.d.ts +16 -0
- package/dist/node/resolve_hooks.d.ts.map +1 -0
- package/dist/node/resolve_hooks.js +104 -0
- package/dist/node/resolve_hooks.js.map +1 -0
- package/dist/studio.d.ts +4 -0
- package/dist/studio.d.ts.map +1 -0
- package/dist/studio.js +188 -0
- package/dist/studio.js.map +1 -0
- package/dist/studio_context.d.ts +27 -0
- package/dist/studio_context.d.ts.map +1 -0
- package/dist/studio_context.js +17 -0
- package/dist/studio_context.js.map +1 -0
- package/dist/surfaces/adopt_stylesheet.d.ts +7 -0
- package/dist/surfaces/adopt_stylesheet.d.ts.map +1 -0
- package/dist/surfaces/adopt_stylesheet.js +64 -0
- package/dist/surfaces/adopt_stylesheet.js.map +1 -0
- package/dist/surfaces/app_preview.d.ts +4 -0
- package/dist/surfaces/app_preview.d.ts.map +1 -0
- package/dist/surfaces/app_preview.js +28 -0
- package/dist/surfaces/app_preview.js.map +1 -0
- package/dist/surfaces/app_surface.d.ts +9 -0
- package/dist/surfaces/app_surface.d.ts.map +1 -0
- package/dist/surfaces/app_surface.js +27 -0
- package/dist/surfaces/app_surface.js.map +1 -0
- package/dist/surfaces/applicable_enhancements.d.ts +4 -0
- package/dist/surfaces/applicable_enhancements.d.ts.map +1 -0
- package/dist/surfaces/applicable_enhancements.js +16 -0
- package/dist/surfaces/applicable_enhancements.js.map +1 -0
- package/dist/surfaces/enhancement_select.d.ts +10 -0
- package/dist/surfaces/enhancement_select.d.ts.map +1 -0
- package/dist/surfaces/enhancement_select.js +28 -0
- package/dist/surfaces/enhancement_select.js.map +1 -0
- package/dist/surfaces/example_picker.d.ts +11 -0
- package/dist/surfaces/example_picker.d.ts.map +1 -0
- package/dist/surfaces/example_picker.js +44 -0
- package/dist/surfaces/example_picker.js.map +1 -0
- package/dist/surfaces/format_source.d.ts +4 -0
- package/dist/surfaces/format_source.d.ts.map +1 -0
- package/dist/surfaces/format_source.js +30 -0
- package/dist/surfaces/format_source.js.map +1 -0
- package/dist/surfaces/html_surface.d.ts +14 -0
- package/dist/surfaces/html_surface.d.ts.map +1 -0
- package/dist/surfaces/html_surface.js +122 -0
- package/dist/surfaces/html_surface.js.map +1 -0
- package/dist/surfaces/png_surface.d.ts +13 -0
- package/dist/surfaces/png_surface.d.ts.map +1 -0
- package/dist/surfaces/png_surface.js +68 -0
- package/dist/surfaces/png_surface.js.map +1 -0
- package/dist/surfaces/react_surface.d.ts +11 -0
- package/dist/surfaces/react_surface.d.ts.map +1 -0
- package/dist/surfaces/react_surface.js +55 -0
- package/dist/surfaces/react_surface.js.map +1 -0
- package/dist/surfaces/render_output.d.ts +31 -0
- package/dist/surfaces/render_output.d.ts.map +1 -0
- package/dist/surfaces/render_output.js +119 -0
- package/dist/surfaces/render_output.js.map +1 -0
- package/dist/surfaces/scaled_preview.d.ts +17 -0
- package/dist/surfaces/scaled_preview.d.ts.map +1 -0
- package/dist/surfaces/scaled_preview.js +74 -0
- package/dist/surfaces/scaled_preview.js.map +1 -0
- package/dist/surfaces/shadow_root.d.ts +8 -0
- package/dist/surfaces/shadow_root.d.ts.map +1 -0
- package/dist/surfaces/shadow_root.js +41 -0
- package/dist/surfaces/shadow_root.js.map +1 -0
- package/dist/surfaces/slack_surface.d.ts +12 -0
- package/dist/surfaces/slack_surface.d.ts.map +1 -0
- package/dist/surfaces/slack_surface.js +27 -0
- package/dist/surfaces/slack_surface.js.map +1 -0
- package/dist/surfaces/snapshot_surface.d.ts +6 -0
- package/dist/surfaces/snapshot_surface.d.ts.map +1 -0
- package/dist/surfaces/snapshot_surface.js +5 -0
- package/dist/surfaces/snapshot_surface.js.map +1 -0
- package/dist/surfaces/surface_board.d.ts +19 -0
- package/dist/surfaces/surface_board.d.ts.map +1 -0
- package/dist/surfaces/surface_board.js +128 -0
- package/dist/surfaces/surface_board.js.map +1 -0
- package/dist/surfaces/surface_frame.d.ts +8 -0
- package/dist/surfaces/surface_frame.d.ts.map +1 -0
- package/dist/surfaces/surface_frame.js +4 -0
- package/dist/surfaces/surface_frame.js.map +1 -0
- package/dist/surfaces/surface_logos.d.ts +9 -0
- package/dist/surfaces/surface_logos.d.ts.map +1 -0
- package/dist/surfaces/surface_logos.js +21 -0
- package/dist/surfaces/surface_logos.js.map +1 -0
- package/dist/surfaces/surface_preview.d.ts +32 -0
- package/dist/surfaces/surface_preview.d.ts.map +1 -0
- package/dist/surfaces/surface_preview.js +66 -0
- package/dist/surfaces/surface_preview.js.map +1 -0
- package/dist/surfaces/surface_select.d.ts +34 -0
- package/dist/surfaces/surface_select.d.ts.map +1 -0
- package/dist/surfaces/surface_select.js +119 -0
- package/dist/surfaces/surface_select.js.map +1 -0
- package/dist/surfaces/text_surfaces.d.ts +14 -0
- package/dist/surfaces/text_surfaces.d.ts.map +1 -0
- package/dist/surfaces/text_surfaces.js +31 -0
- package/dist/surfaces/text_surfaces.js.map +1 -0
- package/dist/surfaces/zoom_select.d.ts +9 -0
- package/dist/surfaces/zoom_select.d.ts.map +1 -0
- package/dist/surfaces/zoom_select.js +32 -0
- package/dist/surfaces/zoom_select.js.map +1 -0
- package/dist/types.d.ts +32 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/docs/ci.md +55 -0
- package/docs/commands.md +167 -0
- package/docs/config.md +192 -0
- package/docs/images/home.png +0 -0
- package/docs/images/reference.png +0 -0
- package/docs/images/workbench.png +0 -0
- package/docs/index.md +96 -0
- package/docs/toc.yml +10 -0
- package/package.json +89 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface_frame.js","sourceRoot":"","sources":["../../src/surfaces/surface_frame.tsx"],"names":[],"mappings":";AAWA,kGAAkG;AAClG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,QAAQ,EACR,QAAQ,GAIT,EAAE,EAAE,CACH,QAAQ,CAAC,CAAC,CAAC,CACT,cAAK,GAAG,EAAE,QAAQ,oBAAiB,cAAc,YAC9C,QAAQ,GACL,CACP,CAAC,CAAC,CAAC,CACF,4BAAG,QAAQ,GAAI,CAChB,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport type { ReactNode } from 'react';\nimport React from 'react';\nimport type { SerializedStyles } from '@emotion/react';\n\n/** Holds a surface's render, apart from its diagnostics, so a clipping frame never hides them. */\nexport const SurfaceFrame = ({\n frameCss,\n children,\n}: {\n frameCss?: SerializedStyles | undefined;\n children: ReactNode;\n}) =>\n frameCss ? (\n <div css={frameCss} data-test-subj=\"surfaceFrame\">\n {children}\n </div>\n ) : (\n <>{children}</>\n );\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentType, SVGProps } from 'react';
|
|
2
|
+
type LogoProps = SVGProps<SVGSVGElement>;
|
|
3
|
+
export declare const ReactLogo: ComponentType<LogoProps>;
|
|
4
|
+
export declare const MarkdownLogo: ComponentType<LogoProps>;
|
|
5
|
+
/** PNG and the snapshot have no brand mark, so each is a badge with its label knocked out of a solid field. */
|
|
6
|
+
export declare const PngLogo: ComponentType<LogoProps>;
|
|
7
|
+
export declare const SnapshotLogo: ComponentType<LogoProps>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=surface_logos.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface_logos.d.ts","sourceRoot":"","sources":["../../src/surfaces/surface_logos.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGrD,KAAK,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAYzC,eAAO,MAAM,SAAS,0BAGrB,CAAC;AAEF,eAAO,MAAM,YAAY,0BAGxB,CAAC;AAoCF,+GAA+G;AAC/G,eAAO,MAAM,OAAO,0BAAmB,CAAC;AACxC,eAAO,MAAM,YAAY,0BAAoB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
/** Glyph paths for 24px viewBoxes from [Simple Icons](https://simpleicons.org) (CC0), filled with each brand's color. */
|
|
4
|
+
const simpleIcon = (d, fill) => {
|
|
5
|
+
const Logo = (props) => (_jsx("svg", { viewBox: "0 0 24 24", ...props, children: _jsx("path", { d, fill }) }));
|
|
6
|
+
return Logo;
|
|
7
|
+
};
|
|
8
|
+
export const ReactLogo = simpleIcon('M14.23 12.004a2.236 2.236 0 0 1-2.235 2.236 2.236 2.236 0 0 1-2.236-2.236 2.236 2.236 0 0 1 2.235-2.236 2.236 2.236 0 0 1 2.236 2.236zm2.648-10.69c-1.346 0-3.107.96-4.888 2.622-1.78-1.653-3.542-2.602-4.887-2.602-.41 0-.783.093-1.106.278-1.375.793-1.683 3.264-.973 6.365C1.98 8.917 0 10.42 0 12.004c0 1.59 1.99 3.097 5.043 4.03-.704 3.113-.39 5.588.988 6.38.32.187.69.275 1.102.275 1.345 0 3.107-.96 4.888-2.624 1.78 1.654 3.542 2.603 4.887 2.603.41 0 .783-.09 1.106-.275 1.374-.792 1.683-3.263.973-6.365C22.02 15.096 24 13.59 24 12.004c0-1.59-1.99-3.097-5.043-4.032.704-3.11.39-5.587-.988-6.38-.318-.184-.688-.277-1.092-.278zm-.005 1.09v.006c.225 0 .406.044.558.127.666.382.955 1.835.73 3.704-.054.46-.142.945-.25 1.44-.96-.236-2.006-.417-3.107-.534-.66-.905-1.345-1.727-2.035-2.447 1.592-1.48 3.087-2.292 4.105-2.295zm-9.77.02c1.012 0 2.514.808 4.11 2.28-.686.72-1.37 1.537-2.02 2.442-1.107.117-2.154.298-3.113.538-.112-.49-.195-.964-.254-1.42-.23-1.868.054-3.32.714-3.707.19-.09.4-.127.563-.132zm4.882 3.05c.455.468.91.992 1.36 1.564-.44-.02-.89-.034-1.345-.034-.46 0-.915.01-1.36.034.44-.572.895-1.096 1.345-1.565zM12 8.1c.74 0 1.477.034 2.202.093.406.582.802 1.203 1.183 1.86.372.64.71 1.29 1.018 1.946-.308.655-.646 1.31-1.013 1.95-.38.66-.773 1.288-1.18 1.87-.728.063-1.466.098-2.21.098-.74 0-1.477-.035-2.202-.093-.406-.582-.802-1.204-1.183-1.86-.372-.64-.71-1.29-1.018-1.946.303-.657.646-1.313 1.013-1.954.38-.66.773-1.286 1.18-1.868.728-.064 1.466-.098 2.21-.098zm-3.635.254c-.24.377-.48.763-.704 1.16-.225.39-.435.782-.635 1.174-.265-.656-.49-1.31-.676-1.947.64-.15 1.315-.283 2.015-.386zm7.26 0c.695.103 1.365.23 2.006.387-.18.632-.405 1.282-.66 1.933-.2-.39-.41-.783-.64-1.174-.225-.392-.465-.774-.705-1.146zm3.063.675c.484.15.944.317 1.375.498 1.732.74 2.852 1.708 2.852 2.476-.005.768-1.125 1.74-2.857 2.475-.42.18-.88.342-1.355.493-.28-.958-.646-1.956-1.1-2.98.45-1.017.81-2.01 1.085-2.964zm-13.395.004c.278.96.645 1.957 1.1 2.98-.45 1.017-.812 2.01-1.086 2.964-.484-.15-.944-.318-1.37-.5-1.732-.737-2.852-1.706-2.852-2.474 0-.768 1.12-1.742 2.852-2.476.42-.18.88-.342 1.356-.494zm11.678 4.28c.265.657.49 1.312.676 1.948-.64.157-1.316.29-2.016.39.24-.375.48-.762.705-1.158.225-.39.435-.788.636-1.18zm-9.945.02c.2.392.41.783.64 1.175.23.39.465.772.705 1.143-.695-.102-1.365-.23-2.006-.386.18-.63.406-1.282.66-1.933zM17.92 16.32c.112.493.2.968.254 1.423.23 1.868-.054 3.32-.714 3.708-.147.09-.338.128-.563.128-1.012 0-2.514-.807-4.11-2.28.686-.72 1.37-1.536 2.02-2.44 1.107-.118 2.154-.3 3.113-.54zm-11.83.01c.96.234 2.006.415 3.107.532.66.905 1.345 1.727 2.035 2.446-1.595 1.483-3.092 2.295-4.11 2.295-.22-.005-.406-.05-.553-.132-.666-.38-.955-1.834-.73-3.703.054-.46.142-.944.25-1.438zm4.56.64c.44.02.89.034 1.345.034.46 0 .915-.01 1.36-.034-.44.572-.895 1.095-1.345 1.565-.455-.47-.91-.993-1.36-1.565z', '#087EA4');
|
|
9
|
+
export const MarkdownLogo = simpleIcon('M22.27 19.385H1.73A1.73 1.73 0 010 17.655V6.345a1.73 1.73 0 011.73-1.73h20.54A1.73 1.73 0 0124 6.345v11.308a1.73 1.73 0 01-1.73 1.731zM5.769 15.923v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.46v7.847zM21.232 12h-2.309V8.077h-2.307V12h-2.308l3.461 4.039z', 'currentColor');
|
|
10
|
+
const fileBadge = (label) => {
|
|
11
|
+
const fontSize = label.length > 3 ? 6.5 : 8;
|
|
12
|
+
const Logo = (props) => {
|
|
13
|
+
const maskId = useId();
|
|
14
|
+
return (_jsxs("svg", { viewBox: "0 0 24 24", ...props, children: [_jsxs("mask", { id: maskId, children: [_jsx("rect", { width: "24", height: "24", fill: "white" }), _jsx("text", { x: "12", y: 12 + fontSize * 0.4, textAnchor: "middle", fontSize: fontSize, fontWeight: "700", fontFamily: "Inter, Helvetica, Arial, sans-serif", fill: "black", children: label })] }), _jsx("rect", { x: "1", y: "5", width: "22", height: "14", rx: "3", fill: "currentColor", mask: `url(#${maskId})` })] }));
|
|
15
|
+
};
|
|
16
|
+
return Logo;
|
|
17
|
+
};
|
|
18
|
+
/** PNG and the snapshot have no brand mark, so each is a badge with its label knocked out of a solid field. */
|
|
19
|
+
export const PngLogo = fileBadge('PNG');
|
|
20
|
+
export const SnapshotLogo = fileBadge('SNAP');
|
|
21
|
+
//# sourceMappingURL=surface_logos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface_logos.js","sourceRoot":"","sources":["../../src/surfaces/surface_logos.tsx"],"names":[],"mappings":";AAQA,OAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAIrC,yHAAyH;AACzH,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,IAAY,EAA4B,EAAE;IACvE,MAAM,IAAI,GAAG,CAAC,KAAgB,EAAE,EAAE,CAAC,CACjC,cAAK,OAAO,EAAC,WAAW,KAAK,KAAK,YAChC,eAAY,CAAC,EAAE,IAAI,GAAM,GACrB,CACP,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CACjC,mwFAAmwF,EACnwF,SAAS,CACV,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,mSAAmS,EACnS,cAAc,CACf,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,KAAa,EAA4B,EAAE;IAC5D,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,CAAC,KAAgB,EAAE,EAAE;QAChC,MAAM,MAAM,GAAG,KAAK,EAAE,CAAC;QACvB,OAAO,CACL,eAAK,OAAO,EAAC,WAAW,KAAK,KAAK,aAChC,gBAAM,EAAE,EAAE,MAAM,aACd,eAAM,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,GAAG,EAC5C,eACE,CAAC,EAAC,IAAI,EACN,CAAC,EAAE,EAAE,GAAG,QAAQ,GAAG,GAAG,EACtB,UAAU,EAAC,QAAQ,EACnB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAC,KAAK,EAChB,UAAU,EAAC,qCAAqC,EAChD,IAAI,EAAC,OAAO,YACX,KAAK,GACD,IACF,EACP,eACE,CAAC,EAAC,GAAG,EACL,CAAC,EAAC,GAAG,EACL,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,EAAE,EAAC,GAAG,EACN,IAAI,EAAC,cAAc,EACnB,IAAI,EAAE,QAAQ,MAAM,GAAG,GACvB,IACE,CACP,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,+GAA+G;AAC/G,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport type { ComponentType, SVGProps } from 'react';\nimport React, { useId } from 'react';\n\ntype LogoProps = SVGProps<SVGSVGElement>;\n\n/** Glyph paths for 24px viewBoxes from [Simple Icons](https://simpleicons.org) (CC0), filled with each brand's color. */\nconst simpleIcon = (d: string, fill: string): ComponentType<LogoProps> => {\n const Logo = (props: LogoProps) => (\n <svg viewBox=\"0 0 24 24\" {...props}>\n <path {...{ d, fill }} />\n </svg>\n );\n return Logo;\n};\n\nexport const ReactLogo = simpleIcon(\n 'M14.23 12.004a2.236 2.236 0 0 1-2.235 2.236 2.236 2.236 0 0 1-2.236-2.236 2.236 2.236 0 0 1 2.235-2.236 2.236 2.236 0 0 1 2.236 2.236zm2.648-10.69c-1.346 0-3.107.96-4.888 2.622-1.78-1.653-3.542-2.602-4.887-2.602-.41 0-.783.093-1.106.278-1.375.793-1.683 3.264-.973 6.365C1.98 8.917 0 10.42 0 12.004c0 1.59 1.99 3.097 5.043 4.03-.704 3.113-.39 5.588.988 6.38.32.187.69.275 1.102.275 1.345 0 3.107-.96 4.888-2.624 1.78 1.654 3.542 2.603 4.887 2.603.41 0 .783-.09 1.106-.275 1.374-.792 1.683-3.263.973-6.365C22.02 15.096 24 13.59 24 12.004c0-1.59-1.99-3.097-5.043-4.032.704-3.11.39-5.587-.988-6.38-.318-.184-.688-.277-1.092-.278zm-.005 1.09v.006c.225 0 .406.044.558.127.666.382.955 1.835.73 3.704-.054.46-.142.945-.25 1.44-.96-.236-2.006-.417-3.107-.534-.66-.905-1.345-1.727-2.035-2.447 1.592-1.48 3.087-2.292 4.105-2.295zm-9.77.02c1.012 0 2.514.808 4.11 2.28-.686.72-1.37 1.537-2.02 2.442-1.107.117-2.154.298-3.113.538-.112-.49-.195-.964-.254-1.42-.23-1.868.054-3.32.714-3.707.19-.09.4-.127.563-.132zm4.882 3.05c.455.468.91.992 1.36 1.564-.44-.02-.89-.034-1.345-.034-.46 0-.915.01-1.36.034.44-.572.895-1.096 1.345-1.565zM12 8.1c.74 0 1.477.034 2.202.093.406.582.802 1.203 1.183 1.86.372.64.71 1.29 1.018 1.946-.308.655-.646 1.31-1.013 1.95-.38.66-.773 1.288-1.18 1.87-.728.063-1.466.098-2.21.098-.74 0-1.477-.035-2.202-.093-.406-.582-.802-1.204-1.183-1.86-.372-.64-.71-1.29-1.018-1.946.303-.657.646-1.313 1.013-1.954.38-.66.773-1.286 1.18-1.868.728-.064 1.466-.098 2.21-.098zm-3.635.254c-.24.377-.48.763-.704 1.16-.225.39-.435.782-.635 1.174-.265-.656-.49-1.31-.676-1.947.64-.15 1.315-.283 2.015-.386zm7.26 0c.695.103 1.365.23 2.006.387-.18.632-.405 1.282-.66 1.933-.2-.39-.41-.783-.64-1.174-.225-.392-.465-.774-.705-1.146zm3.063.675c.484.15.944.317 1.375.498 1.732.74 2.852 1.708 2.852 2.476-.005.768-1.125 1.74-2.857 2.475-.42.18-.88.342-1.355.493-.28-.958-.646-1.956-1.1-2.98.45-1.017.81-2.01 1.085-2.964zm-13.395.004c.278.96.645 1.957 1.1 2.98-.45 1.017-.812 2.01-1.086 2.964-.484-.15-.944-.318-1.37-.5-1.732-.737-2.852-1.706-2.852-2.474 0-.768 1.12-1.742 2.852-2.476.42-.18.88-.342 1.356-.494zm11.678 4.28c.265.657.49 1.312.676 1.948-.64.157-1.316.29-2.016.39.24-.375.48-.762.705-1.158.225-.39.435-.788.636-1.18zm-9.945.02c.2.392.41.783.64 1.175.23.39.465.772.705 1.143-.695-.102-1.365-.23-2.006-.386.18-.63.406-1.282.66-1.933zM17.92 16.32c.112.493.2.968.254 1.423.23 1.868-.054 3.32-.714 3.708-.147.09-.338.128-.563.128-1.012 0-2.514-.807-4.11-2.28.686-.72 1.37-1.536 2.02-2.44 1.107-.118 2.154-.3 3.113-.54zm-11.83.01c.96.234 2.006.415 3.107.532.66.905 1.345 1.727 2.035 2.446-1.595 1.483-3.092 2.295-4.11 2.295-.22-.005-.406-.05-.553-.132-.666-.38-.955-1.834-.73-3.703.054-.46.142-.944.25-1.438zm4.56.64c.44.02.89.034 1.345.034.46 0 .915-.01 1.36-.034-.44.572-.895 1.095-1.345 1.565-.455-.47-.91-.993-1.36-1.565z',\n '#087EA4'\n);\n\nexport const MarkdownLogo = simpleIcon(\n 'M22.27 19.385H1.73A1.73 1.73 0 010 17.655V6.345a1.73 1.73 0 011.73-1.73h20.54A1.73 1.73 0 0124 6.345v11.308a1.73 1.73 0 01-1.73 1.731zM5.769 15.923v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.46v7.847zM21.232 12h-2.309V8.077h-2.307V12h-2.308l3.461 4.039z',\n 'currentColor'\n);\n\nconst fileBadge = (label: string): ComponentType<LogoProps> => {\n const fontSize = label.length > 3 ? 6.5 : 8;\n const Logo = (props: LogoProps) => {\n const maskId = useId();\n return (\n <svg viewBox=\"0 0 24 24\" {...props}>\n <mask id={maskId}>\n <rect width=\"24\" height=\"24\" fill=\"white\" />\n <text\n x=\"12\"\n y={12 + fontSize * 0.4}\n textAnchor=\"middle\"\n fontSize={fontSize}\n fontWeight=\"700\"\n fontFamily=\"Inter, Helvetica, Arial, sans-serif\"\n fill=\"black\">\n {label}\n </text>\n </mask>\n <rect\n x=\"1\"\n y=\"5\"\n width=\"22\"\n height=\"14\"\n rx=\"3\"\n fill=\"currentColor\"\n mask={`url(#${maskId})`}\n />\n </svg>\n );\n };\n return Logo;\n};\n\n/** PNG and the snapshot have no brand mark, so each is a badge with its label knocked out of a solid field. */\nexport const PngLogo = fileBadge('PNG');\nexport const SnapshotLogo = fileBadge('SNAP');\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IconType } from '@elastic/eui';
|
|
2
|
+
import type { Composition, ValidationResult } from '@elastic/isomer-sdk';
|
|
3
|
+
import type { SerializedStyles } from '@emotion/react';
|
|
4
|
+
import type { StudioSurface } from '../model/describe_runtime.js';
|
|
5
|
+
import type { PreviewZoom } from './scaled_preview.js';
|
|
6
|
+
export type SurfaceView = 'render' | 'source';
|
|
7
|
+
export declare const SURFACE_ICONS: Readonly<Record<StudioSurface, IconType>>;
|
|
8
|
+
/** Switches a surface between its rendered form and its source. */
|
|
9
|
+
export declare const SurfaceViewToggle: ({ view, onChange, legend, }: {
|
|
10
|
+
view: SurfaceView;
|
|
11
|
+
onChange: (view: SurfaceView) => void;
|
|
12
|
+
legend: string;
|
|
13
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
14
|
+
export interface SurfacePreviewProps {
|
|
15
|
+
surface: StudioSurface;
|
|
16
|
+
composition: Composition;
|
|
17
|
+
validation: ValidationResult;
|
|
18
|
+
view: SurfaceView;
|
|
19
|
+
/** Scales the `react`, `html` and `snapshot` renders. Defaults to `fit`. */
|
|
20
|
+
zoom?: PreviewZoom;
|
|
21
|
+
/** Styles a frame around the render or source alone; diagnostics sit below it. */
|
|
22
|
+
frameCss?: SerializedStyles | undefined;
|
|
23
|
+
/** A relevant recovery destination when rendering fails. */
|
|
24
|
+
errorHref?: string | undefined;
|
|
25
|
+
/** `false` leaves out the composition's leading title. Defaults to `true`. */
|
|
26
|
+
heading?: boolean | undefined;
|
|
27
|
+
/** Runs the requested enhancements on React or shadow-DOM HTML previews. */
|
|
28
|
+
enhancements?: readonly string[] | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** One surface's render or source, with what it reported. */
|
|
31
|
+
export declare const SurfacePreview: ({ surface, composition, validation, view, zoom, frameCss, errorHref, heading, enhancements, }: SurfacePreviewProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
32
|
+
//# sourceMappingURL=surface_preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface_preview.d.ts","sourceRoot":"","sources":["../../src/surfaces/surface_preview.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAU7C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EA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'react';
|
|
3
|
+
import { EuiButton, EuiButtonGroup, EuiCallOut, EuiLink, EuiSpacer, EuiText, useEuiTheme, } from '@elastic/eui';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
5
|
+
import { SURFACE_LABELS } from '../model/describe_runtime.js';
|
|
6
|
+
import { useStudio } from '../studio_context.js';
|
|
7
|
+
import { ShadowHtmlSurface } from './html_surface.js';
|
|
8
|
+
import { ReactSurface } from './react_surface.js';
|
|
9
|
+
import { renderSurfaceOutput } from './render_output.js';
|
|
10
|
+
import { ScaledPreview } from './scaled_preview.js';
|
|
11
|
+
import { blockKitBuilderUrl, SlackSurface } from './slack_surface.js';
|
|
12
|
+
import { SnapshotSurface } from './snapshot_surface.js';
|
|
13
|
+
import { SurfaceFrame } from './surface_frame.js';
|
|
14
|
+
import { MarkdownLogo, ReactLogo, SnapshotLogo } from './surface_logos.js';
|
|
15
|
+
import { MarkdownSurface, SourceView, TextSurface } from './text_surfaces.js';
|
|
16
|
+
export const SURFACE_ICONS = {
|
|
17
|
+
react: ReactLogo,
|
|
18
|
+
html: 'code',
|
|
19
|
+
snapshot: SnapshotLogo,
|
|
20
|
+
markdown: MarkdownLogo,
|
|
21
|
+
text: 'text',
|
|
22
|
+
slack: 'logoSlack',
|
|
23
|
+
};
|
|
24
|
+
const VIEW_OPTIONS = [
|
|
25
|
+
{ id: 'render', label: 'Rendered' },
|
|
26
|
+
{ id: 'source', label: 'Output source' },
|
|
27
|
+
];
|
|
28
|
+
const isSurfaceView = (id) => id === 'render' || id === 'source';
|
|
29
|
+
/** Switches a surface between its rendered form and its source. */
|
|
30
|
+
export const SurfaceViewToggle = ({ view, onChange, legend, }) => (_jsx(EuiButtonGroup, { legend, buttonSize: "s", variant: "selection", idSelected: view, display: "highlighted", onChange: (id) => isSurfaceView(id) && onChange(id), children: VIEW_OPTIONS.map(({ id, label }) => (_jsx(EuiButton, { id: id, children: label }, id))) }));
|
|
31
|
+
/** Pads surfaces that draw bare text to the inset a pack's boxed content (a callout) has. */
|
|
32
|
+
const Inset = ({ children, isBottomFlush, }) => {
|
|
33
|
+
const { euiTheme } = useEuiTheme();
|
|
34
|
+
const { m } = euiTheme.size;
|
|
35
|
+
return (_jsx("div", { css: css `
|
|
36
|
+
padding: ${m} ${m} ${isBottomFlush ? 0 : m};
|
|
37
|
+
`, children: children }));
|
|
38
|
+
};
|
|
39
|
+
const Rendered = ({ surface, composition, output, zoom, heading, enhancements, }) => {
|
|
40
|
+
const { source, slack, snapshot } = output;
|
|
41
|
+
switch (surface) {
|
|
42
|
+
case 'react':
|
|
43
|
+
return (_jsx(ScaledPreview, { zoom, children: _jsx(ReactSurface, { composition, heading, enhancements }) }));
|
|
44
|
+
case 'html':
|
|
45
|
+
return (_jsx(ScaledPreview, { zoom, children: _jsx(ShadowHtmlSurface, { html: source, title: `${SURFACE_LABELS.html} preview`, enhancementScript: output.enhancementScript }) }));
|
|
46
|
+
case 'markdown':
|
|
47
|
+
return (_jsx(Inset, { isBottomFlush: true, children: _jsx(MarkdownSurface, { markdown: source }) }));
|
|
48
|
+
case 'text':
|
|
49
|
+
return (_jsx(Inset, { children: _jsx(TextSurface, { text: source }) }));
|
|
50
|
+
case 'slack':
|
|
51
|
+
return slack ? _jsx(SlackSurface, { blocks: slack.blocks }) : null;
|
|
52
|
+
case 'snapshot':
|
|
53
|
+
return snapshot ? (_jsx(ScaledPreview, { zoom, children: _jsx(SnapshotSurface, { html: snapshot.html, stylesheet: snapshot.css }) })) : null;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/** One surface's render or source, with what it reported. */
|
|
57
|
+
export const SurfacePreview = ({ surface, composition, validation, view, zoom = 'fit', frameCss, errorHref, heading, enhancements, }) => {
|
|
58
|
+
const { runtime } = useStudio();
|
|
59
|
+
const output = useMemo(() => renderSurfaceOutput(runtime, surface, composition, validation, {
|
|
60
|
+
heading,
|
|
61
|
+
enhancements,
|
|
62
|
+
}), [runtime, surface, composition, validation, heading, enhancements]);
|
|
63
|
+
const { error, warnings, slack } = output;
|
|
64
|
+
return (_jsxs(_Fragment, { children: [error ? (_jsx(EuiCallOut, { announceOnMount: true, size: "s", color: "danger", iconType: "error", title: "This surface could not render", text: _jsxs(_Fragment, { children: [_jsx("p", { children: error }), errorHref ? (_jsx(EuiLink, { href: errorHref, children: "Open this example in Workbench" })) : null] }) })) : (_jsx(SurfaceFrame, { frameCss, children: view === 'source' ? (_jsxs(_Fragment, { children: [_jsx(SourceView, { output }), slack ? (_jsxs(EuiText, { size: "xs", children: [_jsx(EuiSpacer, { size: "xs" }), _jsx(EuiLink, { href: blockKitBuilderUrl(slack.blocks), target: "_blank", external: true, children: "Open in Block Kit Builder" })] })) : null] })) : (_jsx(Rendered, { surface, composition, output, zoom, heading, enhancements })) })), warnings.length ? (_jsxs(_Fragment, { children: [_jsx(EuiSpacer, { size: "s" }), _jsx(EuiCallOut, { announceOnMount: true, size: "s", color: "warning", iconType: "warning", title: `${SURFACE_LABELS[surface]} warnings`, children: _jsx("ul", { children: warnings.map(({ path, message }) => (_jsx("li", { children: path ? `${path}: ${message}` : message }, `${path}:${message}`))) }) })] })) : null] }));
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=surface_preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface_preview.js","sourceRoot":"","sources":["../../src/surfaces/surface_preview.tsx"],"names":[],"mappings":";AAQA,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EACL,SAAS,EACT,cAAc,EACd,UAAU,EACV,OAAO,EACP,SAAS,EACT,OAAO,EACP,WAAW,GACZ,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGrC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;A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OAAO,IADhC,GAAG,IAAI,IAAI,OAAO,EAAE,CAExB,CACN,CAAC,GACC,GACM,IACZ,CACJ,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport type { ReactNode } from 'react';\nimport React, { useMemo } from 'react';\nimport type { IconType } from '@elastic/eui';\nimport {\n EuiButton,\n EuiButtonGroup,\n EuiCallOut,\n EuiLink,\n EuiSpacer,\n EuiText,\n useEuiTheme,\n} from '@elastic/eui';\nimport type { Composition, ValidationResult } from '@elastic/isomer-sdk';\nimport type { SerializedStyles } from '@emotion/react';\nimport { css } from '@emotion/react';\n\nimport type { StudioSurface } from '../model/describe_runtime';\nimport { SURFACE_LABELS } from '../model/describe_runtime';\nimport { useStudio } from '../studio_context';\n\nimport { ShadowHtmlSurface } from './html_surface';\nimport { ReactSurface } from './react_surface';\nimport type { SurfaceOutput } from './render_output';\nimport { renderSurfaceOutput } from './render_output';\nimport type { PreviewZoom } from './scaled_preview';\nimport { ScaledPreview } from './scaled_preview';\nimport { blockKitBuilderUrl, SlackSurface } from './slack_surface';\nimport { SnapshotSurface } from './snapshot_surface';\nimport { SurfaceFrame } from './surface_frame';\nimport { MarkdownLogo, ReactLogo, SnapshotLogo } from './surface_logos';\nimport { MarkdownSurface, SourceView, TextSurface } from './text_surfaces';\n\nexport type SurfaceView = 'render' | 'source';\n\nexport const SURFACE_ICONS: Readonly<Record<StudioSurface, IconType>> = {\n react: ReactLogo,\n html: 'code',\n snapshot: SnapshotLogo,\n markdown: MarkdownLogo,\n text: 'text',\n slack: 'logoSlack',\n};\n\nconst VIEW_OPTIONS: { id: SurfaceView; label: string }[] = [\n { id: 'render', label: 'Rendered' },\n { id: 'source', label: 'Output source' },\n];\n\nconst isSurfaceView = (id: string): id is SurfaceView =>\n id === 'render' || id === 'source';\n\n/** Switches a surface between its rendered form and its source. */\nexport const SurfaceViewToggle = ({\n view,\n onChange,\n legend,\n}: {\n view: SurfaceView;\n onChange: (view: SurfaceView) => void;\n legend: string;\n}) => (\n <EuiButtonGroup\n {...{ legend }}\n buttonSize=\"s\"\n variant=\"selection\"\n idSelected={view}\n display=\"highlighted\"\n onChange={(id) => isSurfaceView(id) && onChange(id)}>\n {VIEW_OPTIONS.map(({ id, label }) => (\n <EuiButton key={id} id={id}>\n {label}\n </EuiButton>\n ))}\n </EuiButtonGroup>\n);\n\n/** Pads surfaces that draw bare text to the inset a pack's boxed content (a callout) has. */\nconst Inset = ({\n children,\n isBottomFlush,\n}: {\n children: ReactNode;\n isBottomFlush?: boolean;\n}) => {\n const { euiTheme } = useEuiTheme();\n const { m } = euiTheme.size;\n\n return (\n <div\n css={css`\n padding: ${m} ${m} ${isBottomFlush ? 0 : m};\n `}>\n {children}\n </div>\n );\n};\n\nconst Rendered = ({\n surface,\n composition,\n output,\n zoom,\n heading,\n enhancements,\n}: {\n surface: StudioSurface;\n composition: Composition;\n output: SurfaceOutput;\n zoom: PreviewZoom;\n heading: boolean | undefined;\n enhancements?: readonly string[] | undefined;\n}) => {\n const { source, slack, snapshot } = output;\n switch (surface) {\n case 'react':\n return (\n <ScaledPreview {...{ zoom }}>\n <ReactSurface {...{ composition, heading, enhancements }} />\n </ScaledPreview>\n );\n case 'html':\n return (\n <ScaledPreview {...{ zoom }}>\n <ShadowHtmlSurface\n html={source}\n title={`${SURFACE_LABELS.html} preview`}\n enhancementScript={output.enhancementScript}\n />\n </ScaledPreview>\n );\n case 'markdown':\n return (\n <Inset isBottomFlush>\n <MarkdownSurface markdown={source} />\n </Inset>\n );\n case 'text':\n return (\n <Inset>\n <TextSurface text={source} />\n </Inset>\n );\n case 'slack':\n return slack ? <SlackSurface blocks={slack.blocks} /> : null;\n case 'snapshot':\n return snapshot ? (\n <ScaledPreview {...{ zoom }}>\n <SnapshotSurface html={snapshot.html} stylesheet={snapshot.css} />\n </ScaledPreview>\n ) : null;\n }\n};\n\nexport interface SurfacePreviewProps {\n surface: StudioSurface;\n composition: Composition;\n validation: ValidationResult;\n view: SurfaceView;\n /** Scales the `react`, `html` and `snapshot` renders. Defaults to `fit`. */\n zoom?: PreviewZoom;\n /** Styles a frame around the render or source alone; diagnostics sit below it. */\n frameCss?: SerializedStyles | undefined;\n /** A relevant recovery destination when rendering fails. */\n errorHref?: string | undefined;\n /** `false` leaves out the composition's leading title. Defaults to `true`. */\n heading?: boolean | undefined;\n /** Runs the requested enhancements on React or shadow-DOM HTML previews. */\n enhancements?: readonly string[] | undefined;\n}\n\n/** One surface's render or source, with what it reported. */\nexport const SurfacePreview = ({\n surface,\n composition,\n validation,\n view,\n zoom = 'fit',\n frameCss,\n errorHref,\n heading,\n enhancements,\n}: SurfacePreviewProps) => {\n const { runtime } = useStudio();\n const output = useMemo(\n () =>\n renderSurfaceOutput(runtime, surface, composition, validation, {\n heading,\n enhancements,\n }),\n [runtime, surface, composition, validation, heading, enhancements]\n );\n const { error, warnings, slack } = output;\n\n return (\n <>\n {error ? (\n <EuiCallOut\n announceOnMount\n size=\"s\"\n color=\"danger\"\n iconType=\"error\"\n title=\"This surface could not render\"\n text={\n <>\n <p>{error}</p>\n {errorHref ? (\n <EuiLink href={errorHref}>\n Open this example in Workbench\n </EuiLink>\n ) : null}\n </>\n }\n />\n ) : (\n <SurfaceFrame {...{ frameCss }}>\n {view === 'source' ? (\n <>\n <SourceView {...{ output }} />\n {slack ? (\n <EuiText size=\"xs\">\n <EuiSpacer size=\"xs\" />\n <EuiLink\n href={blockKitBuilderUrl(slack.blocks)}\n target=\"_blank\"\n external>\n Open in Block Kit Builder\n </EuiLink>\n </EuiText>\n ) : null}\n </>\n ) : (\n <Rendered\n {...{ surface, composition, output, zoom, heading, enhancements }}\n />\n )}\n </SurfaceFrame>\n )}\n {warnings.length ? (\n <>\n <EuiSpacer size=\"s\" />\n <EuiCallOut\n announceOnMount\n size=\"s\"\n color=\"warning\"\n iconType=\"warning\"\n title={`${SURFACE_LABELS[surface]} warnings`}>\n <ul>\n {warnings.map(({ path, message }) => (\n <li key={`${path}:${message}`}>\n {path ? `${path}: ${message}` : message}\n </li>\n ))}\n </ul>\n </EuiCallOut>\n </>\n ) : null}\n </>\n );\n};\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IconType } from '@elastic/eui';
|
|
2
|
+
import type { StudioSurface } from '../model/describe_runtime.js';
|
|
3
|
+
/** A runtime surface, or the host's PNG of the snapshot surface. */
|
|
4
|
+
export type PreviewSurface = StudioSurface | 'png';
|
|
5
|
+
/** Every surface, or an explicit subset in display order. */
|
|
6
|
+
export type SurfaceSelection = 'all' | readonly PreviewSurface[];
|
|
7
|
+
export declare const PREVIEW_LABELS: Readonly<Record<PreviewSurface, string>>;
|
|
8
|
+
/** The picker consolidates HTML, React, and Snapshot into one Web output. */
|
|
9
|
+
export declare const outputLabel: (surface: PreviewSurface) => string;
|
|
10
|
+
export declare const PREVIEW_ICONS: Readonly<Record<PreviewSurface, IconType>>;
|
|
11
|
+
export declare const SURFACE_NOTES: Readonly<Record<PreviewSurface, string>>;
|
|
12
|
+
/** Surfaces drawn at a fixed layout width, which a card shows as a scaled 16:9 frame. */
|
|
13
|
+
export declare const isVisualSurface: (surface: PreviewSurface) => boolean;
|
|
14
|
+
/** `selection` in `surfaces` order. An empty or stale subset shows every surface. */
|
|
15
|
+
export declare const resolveSurfaces: (surfaces: readonly PreviewSurface[], selection: SurfaceSelection) => PreviewSurface[];
|
|
16
|
+
/** From every surface, choosing one shows only it; otherwise the choice toggles, and removing the last shows every surface. */
|
|
17
|
+
export declare const toggleSurface: (surfaces: readonly PreviewSurface[], selected: readonly PreviewSurface[], surface: PreviewSurface) => PreviewSurface[];
|
|
18
|
+
export declare const surfaceSummary: (selected: readonly PreviewSurface[], surfaces: readonly PreviewSurface[]) => string;
|
|
19
|
+
export declare const surfaceNote: (showing: readonly PreviewSurface[], available: number) => string;
|
|
20
|
+
/** Adds host PNG output, optionally consolidating browser renders as HTML. */
|
|
21
|
+
export declare const previewSurfaces: (supported: readonly StudioSurface[], canRasterize: boolean, consolidateBrowser?: boolean) => PreviewSurface[];
|
|
22
|
+
/** The surfaces to show, and a setter that stores a full selection as `'all'`. */
|
|
23
|
+
export declare const useSurfaceSelection: (surfaces: readonly PreviewSurface[], initial: SurfaceSelection) => {
|
|
24
|
+
showing: PreviewSurface[];
|
|
25
|
+
select: (next: readonly PreviewSurface[]) => void;
|
|
26
|
+
};
|
|
27
|
+
/** Checks the surfaces to compare. One shows at full size; several share the grid. */
|
|
28
|
+
export declare const SurfaceSelect: ({ surfaces, selected, onChange, anchorPosition, }: {
|
|
29
|
+
surfaces: readonly PreviewSurface[];
|
|
30
|
+
selected: readonly PreviewSurface[];
|
|
31
|
+
onChange: (selected: readonly PreviewSurface[]) => void;
|
|
32
|
+
anchorPosition?: "downLeft" | "downRight";
|
|
33
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
34
|
+
//# sourceMappingURL=surface_select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface_select.d.ts","sourceRoot":"","sources":["../../src/surfaces/surface_select.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAuB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAYlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM/D,oEAAoE;AACpE,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,KAAK,CAAC;AAEnD,6DAA6D;AAC7D,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,SAAS,cAAc,EAAE,CAAC;AAQjE,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAGnE,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,WAAW,GAAI,SAAS,cAAc,KAAG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AAG,WAAW,CAAC;CAC3C,qDAgEA,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiIcon, EuiPopover, EuiSelectable, useEuiTheme, } from '@elastic/eui';
|
|
10
|
+
import { css } from '@emotion/react';
|
|
11
|
+
import { SURFACE_LABELS } from '../model/describe_runtime.js';
|
|
12
|
+
import { PngLogo } from './surface_logos.js';
|
|
13
|
+
import { SURFACE_ICONS } from './surface_preview.js';
|
|
14
|
+
export const PREVIEW_LABELS = {
|
|
15
|
+
...SURFACE_LABELS,
|
|
16
|
+
png: 'PNG',
|
|
17
|
+
};
|
|
18
|
+
/** The picker consolidates HTML, React, and Snapshot into one Web output. */
|
|
19
|
+
export const outputLabel = (surface) => surface === 'html' ? 'Web' : PREVIEW_LABELS[surface];
|
|
20
|
+
export const PREVIEW_ICONS = {
|
|
21
|
+
...SURFACE_ICONS,
|
|
22
|
+
png: PngLogo,
|
|
23
|
+
};
|
|
24
|
+
export const SURFACE_NOTES = {
|
|
25
|
+
react: 'Live React, styled by the host.',
|
|
26
|
+
html: 'HTML and its stylesheet in shadow DOM.',
|
|
27
|
+
slack: 'Block Kit, drawn as Slack would.',
|
|
28
|
+
markdown: 'Markdown for chat and docs.',
|
|
29
|
+
text: 'Plain text with no markup.',
|
|
30
|
+
snapshot: 'The React render with the pack stylesheet, laid out for an image.',
|
|
31
|
+
png: 'The snapshot, rasterized by the host.',
|
|
32
|
+
};
|
|
33
|
+
/** Surfaces drawn at a fixed layout width, which a card shows as a scaled 16:9 frame. */
|
|
34
|
+
export const isVisualSurface = (surface) => surface === 'react' ||
|
|
35
|
+
surface === 'html' ||
|
|
36
|
+
surface === 'snapshot' ||
|
|
37
|
+
surface === 'png';
|
|
38
|
+
/** `selection` in `surfaces` order. An empty or stale subset shows every surface. */
|
|
39
|
+
export const resolveSurfaces = (surfaces, selection) => {
|
|
40
|
+
if (selection === 'all') {
|
|
41
|
+
return [...surfaces];
|
|
42
|
+
}
|
|
43
|
+
const picked = surfaces.filter((surface) => selection.includes(surface));
|
|
44
|
+
return picked.length ? picked : [...surfaces];
|
|
45
|
+
};
|
|
46
|
+
/** From every surface, choosing one shows only it; otherwise the choice toggles, and removing the last shows every surface. */
|
|
47
|
+
export const toggleSurface = (surfaces, selected, surface) => {
|
|
48
|
+
if (selected.length === surfaces.length) {
|
|
49
|
+
return [surface];
|
|
50
|
+
}
|
|
51
|
+
const next = selected.includes(surface)
|
|
52
|
+
? selected.filter((item) => item !== surface)
|
|
53
|
+
: [...selected, surface];
|
|
54
|
+
const ordered = surfaces.filter((item) => next.includes(item));
|
|
55
|
+
return ordered.length ? ordered : [...surfaces];
|
|
56
|
+
};
|
|
57
|
+
export const surfaceSummary = (selected, surfaces) => {
|
|
58
|
+
if (selected.length === surfaces.length) {
|
|
59
|
+
return `${surfaces.length} outputs`;
|
|
60
|
+
}
|
|
61
|
+
const [only] = selected;
|
|
62
|
+
return selected.length === 1 && only
|
|
63
|
+
? outputLabel(only)
|
|
64
|
+
: selected.map(outputLabel).join(', ');
|
|
65
|
+
};
|
|
66
|
+
export const surfaceNote = (showing, available) => {
|
|
67
|
+
const [only] = showing;
|
|
68
|
+
if (showing.length === 1 && only) {
|
|
69
|
+
return SURFACE_NOTES[only];
|
|
70
|
+
}
|
|
71
|
+
return showing.length === available
|
|
72
|
+
? `All ${available} outputs from the same props. Pick an output above to inspect one at full size, or several to compare.`
|
|
73
|
+
: `Comparing ${showing.length} outputs from the same props.`;
|
|
74
|
+
};
|
|
75
|
+
/** Adds host PNG output, optionally consolidating browser renders as HTML. */
|
|
76
|
+
export const previewSurfaces = (supported, canRasterize, consolidateBrowser = false) => supported.flatMap((surface) => {
|
|
77
|
+
if (consolidateBrowser &&
|
|
78
|
+
supported.includes('html') &&
|
|
79
|
+
(surface === 'react' || surface === 'snapshot')) {
|
|
80
|
+
return surface === 'snapshot' && canRasterize ? ['png'] : [];
|
|
81
|
+
}
|
|
82
|
+
return surface === 'snapshot' && canRasterize
|
|
83
|
+
? [surface, 'png']
|
|
84
|
+
: [surface];
|
|
85
|
+
});
|
|
86
|
+
const Option = ({ icon, label }) => (_jsxs(EuiFlexGroup, { gutterSize: "s", alignItems: "center", responsive: false, children: [_jsx(EuiFlexItem, { grow: false, children: _jsx(EuiIcon, { type: icon, size: "m", "aria-hidden": true }) }), _jsx(EuiFlexItem, { children: label })] }));
|
|
87
|
+
/** The surfaces to show, and a setter that stores a full selection as `'all'`. */
|
|
88
|
+
export const useSurfaceSelection = (surfaces, initial) => {
|
|
89
|
+
const [selection, setSelection] = useState(initial);
|
|
90
|
+
const select = (next) => setSelection(next.length === surfaces.length ? 'all' : next);
|
|
91
|
+
return { showing: resolveSurfaces(surfaces, selection), select };
|
|
92
|
+
};
|
|
93
|
+
const MENU_WIDTH = 220;
|
|
94
|
+
/** Checks the surfaces to compare. One shows at full size; several share the grid. */
|
|
95
|
+
export const SurfaceSelect = ({ surfaces, selected, onChange, anchorPosition = 'downLeft', }) => {
|
|
96
|
+
const { euiTheme } = useEuiTheme();
|
|
97
|
+
const [isOpen, setOpen] = useState(false);
|
|
98
|
+
const summary = surfaceSummary(selected, surfaces);
|
|
99
|
+
const options = surfaces.map((surface) => ({
|
|
100
|
+
label: outputLabel(surface),
|
|
101
|
+
key: surface,
|
|
102
|
+
surface,
|
|
103
|
+
checked: selected.includes(surface) ? 'on' : undefined,
|
|
104
|
+
}));
|
|
105
|
+
return (_jsx(EuiPopover, { isOpen: isOpen, closePopover: () => setOpen(false), anchorPosition, panelPaddingSize: "none", button: _jsxs(EuiButton, { size: "s", color: "text", iconType: "chevronSingleDown", iconSide: "right", "aria-label": `Outputs: ${summary}`, onClick: () => setOpen((open) => !open), children: [_jsx("span", { css: css `
|
|
106
|
+
margin-inline-end: ${euiTheme.size.s};
|
|
107
|
+
color: ${euiTheme.colors.textSubdued};
|
|
108
|
+
font-weight: ${euiTheme.font.weight.regular};
|
|
109
|
+
`, children: "Outputs" }), _jsx("span", { css: css `
|
|
110
|
+
display: inline-block;
|
|
111
|
+
max-width: ${MENU_WIDTH}px;
|
|
112
|
+
overflow: hidden;
|
|
113
|
+
text-overflow: ellipsis;
|
|
114
|
+
vertical-align: bottom;
|
|
115
|
+
`, children: summary })] }), children: _jsx("div", { css: css `
|
|
116
|
+
min-width: ${MENU_WIDTH}px;
|
|
117
|
+
`, children: _jsx(EuiSelectable, { "aria-label": "Outputs", options, onChange: (_next, _event, { surface }) => onChange(toggleSurface(surfaces, selected, surface)), listProps: { bordered: false }, renderOption: ({ surface, label }) => (_jsx(Option, { icon: PREVIEW_ICONS[surface], label })), children: (list) => list }) }) }));
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=surface_select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface_select.js","sourceRoot":"","sources":["../../src/surfaces/surface_select.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,OAAO,EACP,UAAU,EACV,aAAa,EACb,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGrC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAclD,MAA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K,CAAC,EAC5B,cAAc,EACpB,gBAAgB,EAAC,MAAM,EACvB,MAAM,EACJ,MAAC,SAAS,IACR,IAAI,EAAC,GAAG,EACR,KAAK,EAAC,MAAM,EACZ,QAAQ,EAAC,mBAAmB,EAC5B,QAAQ,EAAC,OAAO,gBACJ,YAAY,OAAO,EAAE,EACjC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,aACvC,eACE,GAAG,EAAE,GAAG,CAAA;mCACe,QAAQ,CAAC,IAAI,CAAC,CAAC;uBAC3B,QAAQ,CAAC,MAAM,CAAC,WAAW;6BACrB,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO;aAC5C,wBAEI,EACP,eACE,GAAG,EAAE,GAAG,CAAA;;2BAEO,UAAU;;;;aAIxB,YACA,OAAO,GACH,IACG,YAEd,cACE,GAAG,EAAE,GAAG,CAAA;uBACO,UAAU;SACxB,YACD,KAAC,aAAa,kBACD,SAAS,EACd,OAAO,EACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CACvC,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,EAEtD,SAAS,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAC9B,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CACpC,KAAC,MAAM,IAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAAQ,KAAK,GAAM,CACxD,YACA,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GACD,GACZ,GACK,CACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport React, { useState } from 'react';\nimport type { EuiSelectableOption, IconType } from '@elastic/eui';\nimport {\n EuiButton,\n EuiFlexGroup,\n EuiFlexItem,\n EuiIcon,\n EuiPopover,\n EuiSelectable,\n useEuiTheme,\n} from '@elastic/eui';\nimport { css } from '@emotion/react';\n\nimport type { StudioSurface } from '../model/describe_runtime';\nimport { SURFACE_LABELS } from '../model/describe_runtime';\n\nimport { PngLogo } from './surface_logos';\nimport { SURFACE_ICONS } from './surface_preview';\n\n/** A runtime surface, or the host's PNG of the snapshot surface. */\nexport type PreviewSurface = StudioSurface | 'png';\n\n/** Every surface, or an explicit subset in display order. */\nexport type SurfaceSelection = 'all' | readonly PreviewSurface[];\n\ninterface SurfaceOptionData {\n surface: PreviewSurface;\n}\n\ntype SurfaceOption = EuiSelectableOption<SurfaceOptionData>;\n\nexport const PREVIEW_LABELS: Readonly<Record<PreviewSurface, string>> = {\n ...SURFACE_LABELS,\n png: 'PNG',\n};\n\n/** The picker consolidates HTML, React, and Snapshot into one Web output. */\nexport const outputLabel = (surface: PreviewSurface): string =>\n surface === 'html' ? 'Web' : PREVIEW_LABELS[surface];\n\nexport const PREVIEW_ICONS: Readonly<Record<PreviewSurface, IconType>> = {\n ...SURFACE_ICONS,\n png: PngLogo,\n};\n\nexport const SURFACE_NOTES: Readonly<Record<PreviewSurface, string>> = {\n react: 'Live React, styled by the host.',\n html: 'HTML and its stylesheet in shadow DOM.',\n slack: 'Block Kit, drawn as Slack would.',\n markdown: 'Markdown for chat and docs.',\n text: 'Plain text with no markup.',\n snapshot: 'The React render with the pack stylesheet, laid out for an image.',\n png: 'The snapshot, rasterized by the host.',\n};\n\n/** Surfaces drawn at a fixed layout width, which a card shows as a scaled 16:9 frame. */\nexport const isVisualSurface = (surface: PreviewSurface): boolean =>\n surface === 'react' ||\n surface === 'html' ||\n surface === 'snapshot' ||\n surface === 'png';\n\n/** `selection` in `surfaces` order. An empty or stale subset shows every surface. */\nexport const resolveSurfaces = (\n surfaces: readonly PreviewSurface[],\n selection: SurfaceSelection\n): PreviewSurface[] => {\n if (selection === 'all') {\n return [...surfaces];\n }\n const picked = surfaces.filter((surface) => selection.includes(surface));\n return picked.length ? picked : [...surfaces];\n};\n\n/** From every surface, choosing one shows only it; otherwise the choice toggles, and removing the last shows every surface. */\nexport const toggleSurface = (\n surfaces: readonly PreviewSurface[],\n selected: readonly PreviewSurface[],\n surface: PreviewSurface\n): PreviewSurface[] => {\n if (selected.length === surfaces.length) {\n return [surface];\n }\n const next = selected.includes(surface)\n ? selected.filter((item) => item !== surface)\n : [...selected, surface];\n const ordered = surfaces.filter((item) => next.includes(item));\n return ordered.length ? ordered : [...surfaces];\n};\n\nexport const surfaceSummary = (\n selected: readonly PreviewSurface[],\n surfaces: readonly PreviewSurface[]\n): string => {\n if (selected.length === surfaces.length) {\n return `${surfaces.length} outputs`;\n }\n const [only] = selected;\n return selected.length === 1 && only\n ? outputLabel(only)\n : selected.map(outputLabel).join(', ');\n};\n\nexport const surfaceNote = (\n showing: readonly PreviewSurface[],\n available: number\n): string => {\n const [only] = showing;\n if (showing.length === 1 && only) {\n return SURFACE_NOTES[only];\n }\n return showing.length === available\n ? `All ${available} outputs from the same props. Pick an output above to inspect one at full size, or several to compare.`\n : `Comparing ${showing.length} outputs from the same props.`;\n};\n\n/** Adds host PNG output, optionally consolidating browser renders as HTML. */\nexport const previewSurfaces = (\n supported: readonly StudioSurface[],\n canRasterize: boolean,\n consolidateBrowser = false\n): PreviewSurface[] =>\n supported.flatMap((surface): PreviewSurface[] => {\n if (\n consolidateBrowser &&\n supported.includes('html') &&\n (surface === 'react' || surface === 'snapshot')\n ) {\n return surface === 'snapshot' && canRasterize ? ['png'] : [];\n }\n return surface === 'snapshot' && canRasterize\n ? [surface, 'png']\n : [surface];\n });\n\nconst Option = ({ icon, label }: { icon: IconType; label: string }) => (\n <EuiFlexGroup gutterSize=\"s\" alignItems=\"center\" responsive={false}>\n <EuiFlexItem grow={false}>\n <EuiIcon type={icon} size=\"m\" aria-hidden={true} />\n </EuiFlexItem>\n <EuiFlexItem>{label}</EuiFlexItem>\n </EuiFlexGroup>\n);\n\n/** The surfaces to show, and a setter that stores a full selection as `'all'`. */\nexport const useSurfaceSelection = (\n surfaces: readonly PreviewSurface[],\n initial: SurfaceSelection\n) => {\n const [selection, setSelection] = useState<SurfaceSelection>(initial);\n const select = (next: readonly PreviewSurface[]) =>\n setSelection(next.length === surfaces.length ? 'all' : next);\n return { showing: resolveSurfaces(surfaces, selection), select };\n};\n\nconst MENU_WIDTH = 220;\n\n/** Checks the surfaces to compare. One shows at full size; several share the grid. */\nexport const SurfaceSelect = ({\n surfaces,\n selected,\n onChange,\n anchorPosition = 'downLeft',\n}: {\n surfaces: readonly PreviewSurface[];\n selected: readonly PreviewSurface[];\n onChange: (selected: readonly PreviewSurface[]) => void;\n anchorPosition?: 'downLeft' | 'downRight';\n}) => {\n const { euiTheme } = useEuiTheme();\n const [isOpen, setOpen] = useState(false);\n const summary = surfaceSummary(selected, surfaces);\n const options: SurfaceOption[] = surfaces.map((surface): SurfaceOption => ({\n label: outputLabel(surface),\n key: surface,\n surface,\n checked: selected.includes(surface) ? 'on' : undefined,\n }));\n\n return (\n <EuiPopover\n isOpen={isOpen}\n closePopover={() => setOpen(false)}\n {...{ anchorPosition }}\n panelPaddingSize=\"none\"\n button={\n <EuiButton\n size=\"s\"\n color=\"text\"\n iconType=\"chevronSingleDown\"\n iconSide=\"right\"\n aria-label={`Outputs: ${summary}`}\n onClick={() => setOpen((open) => !open)}>\n <span\n css={css`\n margin-inline-end: ${euiTheme.size.s};\n color: ${euiTheme.colors.textSubdued};\n font-weight: ${euiTheme.font.weight.regular};\n `}>\n Outputs\n </span>\n <span\n css={css`\n display: inline-block;\n max-width: ${MENU_WIDTH}px;\n overflow: hidden;\n text-overflow: ellipsis;\n vertical-align: bottom;\n `}>\n {summary}\n </span>\n </EuiButton>\n }>\n <div\n css={css`\n min-width: ${MENU_WIDTH}px;\n `}>\n <EuiSelectable<SurfaceOptionData>\n aria-label=\"Outputs\"\n {...{ options }}\n onChange={(_next, _event, { surface }) =>\n onChange(toggleSurface(surfaces, selected, surface))\n }\n listProps={{ bordered: false }}\n renderOption={({ surface, label }) => (\n <Option icon={PREVIEW_ICONS[surface]} {...{ label }} />\n )}>\n {(list) => list}\n </EuiSelectable>\n </div>\n </EuiPopover>\n );\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SurfaceOutput } from './render_output.js';
|
|
2
|
+
/** Markdown as a reader sees it. */
|
|
3
|
+
export declare const MarkdownSurface: ({ markdown }: {
|
|
4
|
+
markdown: string;
|
|
5
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
6
|
+
/** Plain text, which looks the same rendered as it does as source. */
|
|
7
|
+
export declare const TextSurface: ({ text }: {
|
|
8
|
+
text: string;
|
|
9
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
10
|
+
/** A surface's output as source, formatted once the formatter has loaded. */
|
|
11
|
+
export declare const SourceView: ({ output: { source, language }, }: {
|
|
12
|
+
output: SurfaceOutput;
|
|
13
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=text_surfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text_surfaces.d.ts","sourceRoot":"","sources":["../../src/surfaces/text_surfaces.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,oCAAoC;AACpC,eAAO,MAAM,eAAe,GAAI,cAAc;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,qDAEjE,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,WAAW,GAAI,UAAU;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,qDAQrD,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,UAAU,GAAI,mCAExB;IACD,MAAM,EAAE,aAAa,CAAC;CACvB,qDA4BA,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
import { useEffect, useState } from 'react';
|
|
9
|
+
import { EuiCodeBlock, EuiMarkdownFormat } from '@elastic/eui';
|
|
10
|
+
import { formatSource } from './format_source.js';
|
|
11
|
+
/** Markdown as a reader sees it. */
|
|
12
|
+
export const MarkdownSurface = ({ markdown }) => (_jsx(EuiMarkdownFormat, { textSize: "m", children: markdown }));
|
|
13
|
+
/** Plain text, which looks the same rendered as it does as source. */
|
|
14
|
+
export const TextSurface = ({ text }) => (_jsx(EuiCodeBlock, { language: "text", fontSize: "l", paddingSize: "none", transparentBackground: true, children: text }));
|
|
15
|
+
/** A surface's output as source, formatted once the formatter has loaded. */
|
|
16
|
+
export const SourceView = ({ output: { source, language }, }) => {
|
|
17
|
+
const [formatted, setFormatted] = useState();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
let isCurrent = true;
|
|
20
|
+
void formatSource(source, language).then((text) => {
|
|
21
|
+
if (isCurrent) {
|
|
22
|
+
setFormatted({ source, text });
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
isCurrent = false;
|
|
27
|
+
};
|
|
28
|
+
}, [source, language]);
|
|
29
|
+
return (_jsx(EuiCodeBlock, { language: language, fontSize: "s", paddingSize: "s", isCopyable: true, overflowHeight: 480, children: formatted?.source === source ? formatted.text : source }));
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=text_surfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text_surfaces.js","sourceRoot":"","sources":["../../src/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CAAC;IAEvB,OAAO,CACL,KAAC,YAAY,IACX,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAC,GAAG,EACZ,WAAW,EAAC,GAAG,EACf,UAAU,QACV,cAAc,EAAE,GAAG,YAClB,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,GAC1C,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport React, { useEffect, useState } from 'react';\nimport { EuiCodeBlock, EuiMarkdownFormat } from '@elastic/eui';\n\nimport { formatSource } from './format_source';\nimport type { SurfaceOutput } from './render_output';\n\n/** Markdown as a reader sees it. */\nexport const MarkdownSurface = ({ markdown }: { markdown: string }) => (\n <EuiMarkdownFormat textSize=\"m\">{markdown}</EuiMarkdownFormat>\n);\n\n/** Plain text, which looks the same rendered as it does as source. */\nexport const TextSurface = ({ text }: { text: string }) => (\n <EuiCodeBlock\n language=\"text\"\n fontSize=\"l\"\n paddingSize=\"none\"\n transparentBackground>\n {text}\n </EuiCodeBlock>\n);\n\n/** A surface's output as source, formatted once the formatter has loaded. */\nexport const SourceView = ({\n output: { source, language },\n}: {\n output: SurfaceOutput;\n}) => {\n const [formatted, setFormatted] = useState<{\n source: string;\n text: string;\n }>();\n\n useEffect(() => {\n let isCurrent = true;\n void formatSource(source, language).then((text) => {\n if (isCurrent) {\n setFormatted({ source, text });\n }\n });\n return () => {\n isCurrent = false;\n };\n }, [source, language]);\n\n return (\n <EuiCodeBlock\n language={language}\n fontSize=\"s\"\n paddingSize=\"s\"\n isCopyable\n overflowHeight={480}>\n {formatted?.source === source ? formatted.text : source}\n </EuiCodeBlock>\n );\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PreviewZoom } from './scaled_preview.js';
|
|
2
|
+
export declare const zoomLabel: (zoom: PreviewZoom) => string;
|
|
3
|
+
/** Chooses how the visual surfaces scale: fit to the panel, or a fixed zoom. */
|
|
4
|
+
export declare const ZoomSelect: ({ zoom, onChange, isDisabled, }: {
|
|
5
|
+
zoom: PreviewZoom;
|
|
6
|
+
onChange: (zoom: PreviewZoom) => void;
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=zoom_select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zoom_select.d.ts","sourceRoot":"","sources":["../../src/surfaces/zoom_select.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,eAAO,MAAM,SAAS,GAAI,MAAM,WAAW,KAAG,MACe,CAAC;AAE9D,gFAAgF;AAChF,eAAO,MAAM,UAAU,GAAI,iCAIxB;IACD,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,qDAgDA,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { EuiButtonEmpty, EuiPopover, EuiSelectable } from '@elastic/eui';
|
|
10
|
+
import { css } from '@emotion/react';
|
|
11
|
+
const ZOOMS = ['fit', 0.5, 0.75, 1, 1.5, 2];
|
|
12
|
+
export const zoomLabel = (zoom) => zoom === 'fit' ? 'Fit width' : `${Math.round(zoom * 100)}%`;
|
|
13
|
+
/** Chooses how the visual surfaces scale: fit to the panel, or a fixed zoom. */
|
|
14
|
+
export const ZoomSelect = ({ zoom, onChange, isDisabled = false, }) => {
|
|
15
|
+
const [isOpen, setOpen] = useState(false);
|
|
16
|
+
const options = ZOOMS.map((candidate) => ({
|
|
17
|
+
key: String(candidate),
|
|
18
|
+
label: zoomLabel(candidate),
|
|
19
|
+
checked: candidate === zoom ? 'on' : undefined,
|
|
20
|
+
}));
|
|
21
|
+
return (_jsx(EuiPopover, { "aria-label": "Zoom", isOpen: isOpen, closePopover: () => setOpen(false), panelPaddingSize: "none", anchorPosition: "downRight", button: _jsx(EuiButtonEmpty, { size: "xs", color: "text", iconType: "chevronSingleDown", iconSide: "right", isDisabled, onClick: () => setOpen((open) => !open), "aria-label": `Zoom: ${zoomLabel(zoom)}`, children: zoomLabel(zoom) }), children: _jsx(EuiSelectable, { "aria-label": "Zoom", singleSelection: "always", options: options, onChange: (next) => {
|
|
22
|
+
const index = next.findIndex(({ checked }) => checked === 'on');
|
|
23
|
+
const selected = ZOOMS[index];
|
|
24
|
+
if (selected !== undefined) {
|
|
25
|
+
onChange(selected);
|
|
26
|
+
setOpen(false);
|
|
27
|
+
}
|
|
28
|
+
}, listProps: { bordered: false }, css: css `
|
|
29
|
+
min-width: 180px;
|
|
30
|
+
`, children: (list) => list }) }));
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=zoom_select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zoom_select.js","sourceRoot":"","sources":["../../src/surfaces/zoom_select.tsx"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,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CAAC,IAAI,CAAC,EAAE,YACrC,SAAS,CAAC,IAAI,CAAC,GACD,YAEnB,KAAC,aAAa,kBACD,MAAM,EACjB,eAAe,EAAC,QAAQ,EACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;gBACjB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;gBAChE,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC9B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;oBAC3B,QAAQ,CAAC,QAAQ,CAAC,CAAC;oBACnB,OAAO,CAAC,KAAK,CAAC,CAAC;gBACjB,CAAC;YACH,CAAC,EACD,SAAS,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAC9B,GAAG,EAAE,GAAG,CAAA;;SAEP,YACA,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GACD,GACL,CACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport React, { useState } from 'react';\nimport type { EuiSelectableOption } from '@elastic/eui';\nimport { EuiButtonEmpty, EuiPopover, EuiSelectable } from '@elastic/eui';\nimport { css } from '@emotion/react';\n\nimport type { PreviewZoom } from './scaled_preview';\n\nconst ZOOMS: readonly PreviewZoom[] = ['fit', 0.5, 0.75, 1, 1.5, 2];\n\nexport const zoomLabel = (zoom: PreviewZoom): string =>\n zoom === 'fit' ? 'Fit width' : `${Math.round(zoom * 100)}%`;\n\n/** Chooses how the visual surfaces scale: fit to the panel, or a fixed zoom. */\nexport const ZoomSelect = ({\n zoom,\n onChange,\n isDisabled = false,\n}: {\n zoom: PreviewZoom;\n onChange: (zoom: PreviewZoom) => void;\n isDisabled?: boolean;\n}) => {\n const [isOpen, setOpen] = useState(false);\n\n const options = ZOOMS.map((candidate): EuiSelectableOption => ({\n key: String(candidate),\n label: zoomLabel(candidate),\n checked: candidate === zoom ? 'on' : undefined,\n }));\n\n return (\n <EuiPopover\n aria-label=\"Zoom\"\n isOpen={isOpen}\n closePopover={() => setOpen(false)}\n panelPaddingSize=\"none\"\n anchorPosition=\"downRight\"\n button={\n <EuiButtonEmpty\n size=\"xs\"\n color=\"text\"\n iconType=\"chevronSingleDown\"\n iconSide=\"right\"\n {...{ isDisabled }}\n onClick={() => setOpen((open) => !open)}\n aria-label={`Zoom: ${zoomLabel(zoom)}`}>\n {zoomLabel(zoom)}\n </EuiButtonEmpty>\n }>\n <EuiSelectable\n aria-label=\"Zoom\"\n singleSelection=\"always\"\n options={options}\n onChange={(next) => {\n const index = next.findIndex(({ checked }) => checked === 'on');\n const selected = ZOOMS[index];\n if (selected !== undefined) {\n onChange(selected);\n setOpen(false);\n }\n }}\n listProps={{ bordered: false }}\n css={css`\n min-width: 180px;\n `}>\n {(list) => list}\n </EuiSelectable>\n </EuiPopover>\n );\n};\n"]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Composition } from '@elastic/isomer-sdk';
|
|
2
|
+
import type { StudioConfig } from './config.js';
|
|
3
|
+
/**
|
|
4
|
+
* Compiles JSX source to JavaScript using the classic runtime: elements become `h(...)` calls and
|
|
5
|
+
* fragments `Fragment`.
|
|
6
|
+
*/
|
|
7
|
+
export type JsxTransform = (source: string) => Promise<string>;
|
|
8
|
+
/** Raster pixels per CSS pixel in a {@link RasterizePng} image. */
|
|
9
|
+
export declare const PNG_SCALE = 2;
|
|
10
|
+
/**
|
|
11
|
+
* Rasterizes a composition to PNG on the host, which can run `@elastic/isomer-image-takumi` where the browser can't.
|
|
12
|
+
* The image is drawn at {@link PNG_SCALE}, and the preview shows it at its size in CSS pixels.
|
|
13
|
+
*/
|
|
14
|
+
export type RasterizePng = (composition: Composition, options: {
|
|
15
|
+
signal: AbortSignal;
|
|
16
|
+
}) => Promise<Blob>;
|
|
17
|
+
/** Writes compositions as one PDF on the host, a page each, drawn like {@link RasterizePng}'s images. */
|
|
18
|
+
export type RenderPdf = (compositions: readonly Composition[], options?: {
|
|
19
|
+
title?: string | undefined;
|
|
20
|
+
signal?: AbortSignal | undefined;
|
|
21
|
+
}) => Promise<Blob>;
|
|
22
|
+
export interface IsomerStudioProps extends StudioConfig {
|
|
23
|
+
/** Compiles edited JSX; without it the editor offers JSON only. */
|
|
24
|
+
transformJsx?: JsxTransform | undefined;
|
|
25
|
+
/** Adds a PNG preview beneath the `snapshot` surface; without it there is none. */
|
|
26
|
+
rasterizePng?: RasterizePng | undefined;
|
|
27
|
+
/** Lets apps download PDFs; without it they can't. */
|
|
28
|
+
renderPdf?: RenderPdf | undefined;
|
|
29
|
+
/** Why the config's latest apps were rejected, shown above the page. */
|
|
30
|
+
configProblems?: readonly string[] | undefined;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAE/D,mEAAmE;AACnE,eAAO,MAAM,SAAS,IAAI,CAAC;AAE3B;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,KAC7B,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,yGAAyG;AACzG,MAAM,MAAM,SAAS,GAAG,CACtB,YAAY,EAAE,SAAS,WAAW,EAAE,EACpC,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;CAAE,KACvE,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,mEAAmE;IACnE,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,mFAAmF;IACnF,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,sDAAsD;IACtD,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAClC,wEAAwE;IACxE,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAChD"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
|
+
* 2.0.
|
|
6
|
+
*/
|
|
7
|
+
/** Raster pixels per CSS pixel in a {@link RasterizePng} image. */
|
|
8
|
+
export const PNG_SCALE = 2;
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,mEAAmE;AACnE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport type { Composition } from '@elastic/isomer-sdk';\n\nimport type { StudioConfig } from './config';\n\n/**\n * Compiles JSX source to JavaScript using the classic runtime: elements become `h(...)` calls and\n * fragments `Fragment`.\n */\nexport type JsxTransform = (source: string) => Promise<string>;\n\n/** Raster pixels per CSS pixel in a {@link RasterizePng} image. */\nexport const PNG_SCALE = 2;\n\n/**\n * Rasterizes a composition to PNG on the host, which can run `@elastic/isomer-image-takumi` where the browser can't.\n * The image is drawn at {@link PNG_SCALE}, and the preview shows it at its size in CSS pixels.\n */\nexport type RasterizePng = (\n composition: Composition,\n options: { signal: AbortSignal }\n) => Promise<Blob>;\n\n/** Writes compositions as one PDF on the host, a page each, drawn like {@link RasterizePng}'s images. */\nexport type RenderPdf = (\n compositions: readonly Composition[],\n options?: { title?: string | undefined; signal?: AbortSignal | undefined }\n) => Promise<Blob>;\n\nexport interface IsomerStudioProps extends StudioConfig {\n /** Compiles edited JSX; without it the editor offers JSON only. */\n transformJsx?: JsxTransform | undefined;\n /** Adds a PNG preview beneath the `snapshot` surface; without it there is none. */\n rasterizePng?: RasterizePng | undefined;\n /** Lets apps download PDFs; without it they can't. */\n renderPdf?: RenderPdf | undefined;\n /** Why the config's latest apps were rejected, shown above the page. */\n configProblems?: readonly string[] | undefined;\n}\n"]}
|