@astryxdesign/cli 0.7.18-canary.gfacee17 → 0.7.18
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/CHANGELOG.md +185 -19
- package/README.md +19 -19
- package/api/component/_adapter.d.mts +2 -1
- package/api/component/_adapter.mjs +2 -1
- package/api/docs/_adapter.d.mts +6 -5
- package/api/docs/_adapter.mjs +36 -5
- package/api/doctor/_adapter.d.mts +6 -3
- package/api/doctor/_adapter.mjs +13 -5
- package/api/doctor/doctor.mjs +5 -5
- package/api/doctor/font-packages.d.mts +36 -0
- package/api/doctor/font-packages.mjs +124 -0
- package/api/doctor/theme-checks.mjs +110 -49
- package/api/experimental.d.mts +0 -2
- package/api/experimental.mjs +0 -12
- package/api/icon/_adapter.d.mts +2 -2
- package/api/icon/_adapter.mjs +6 -2
- package/api/icon/_authoring.mjs +22 -13
- package/api/icon/_default-look.mjs +15 -15
- package/api/icon/add/add.mjs +14 -9
- package/api/icon/icon.doc.mjs +7 -7
- package/api/icon/icon.type.d.mts +33 -33
- package/api/icon/icon.type.mjs +45 -45
- package/api/icon/iconAdd.doc.mjs +9 -10
- package/api/icon/iconMap.doc.mjs +11 -12
- package/api/icon/iconNewDefinition.doc.mjs +8 -8
- package/api/icon/iconNewSet.doc.mjs +5 -5
- package/api/icon/map/map.mjs +7 -7
- package/api/icon/use/use.mjs +4 -4
- package/api/init/run/run.mjs +0 -1
- package/api/integration/add-helpers.mjs +1 -1
- package/api/integration/validate-integration.type.d.mts +6 -6
- package/api/integration/validate-integration.type.mjs +6 -6
- package/api/render/_adapter.d.mts +5 -3
- package/api/render/_adapter.mjs +64 -4
- package/api/render/render.doc.mjs +9 -2
- package/api/render/render.mjs +5 -2
- package/api/render/render.type.d.mts +17 -0
- package/api/render/render.type.mjs +10 -0
- package/api/search/ORDERING.md +1 -1
- package/api/search/_candidate-score.mjs +20 -0
- package/api/search/_words.d.mts +8 -0
- package/api/search/_words.mjs +15 -0
- package/api/template/template.type.d.mts +2 -2
- package/api/template/template.type.mjs +2 -2
- package/api/theme/_adapter.mjs +19 -11
- package/api/theme/build/build.d.mts +19 -51
- package/api/theme/build/build.mjs +195 -189
- package/api/theme/build/font-warning.d.mts +19 -2
- package/api/theme/build/font-warning.mjs +46 -5
- package/api/theme/generateTonalPalette.doc.mjs +1 -1
- package/api/theme/palette/generate/derive-look.mjs +108 -37
- package/api/theme/palette/generate/mapping.mjs +2 -0
- package/api/theme/template/template.d.mts +0 -17
- package/api/theme/template/template.mjs +1 -42
- package/api/theme/theme.type.d.mts +5 -4
- package/api/theme/theme.type.mjs +5 -4
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeRemove.doc.mjs +1 -1
- package/assets/codemods/transforms/v0.7.0/preserve-bottom-sheet-content-padding.mjs +3 -1
- package/assets/component-list.generated.json +1 -1
- package/assets/discover/official-packages.json +26 -2
- package/assets/docs/author-a-theme.doc.mjs +6 -5
- package/assets/docs/browser-support.doc.mjs +1 -0
- package/assets/docs/icons.doc.mjs +8 -7
- package/assets/docs/motion.doc.mjs +46 -0
- package/assets/docs/theme.doc.dense.mjs +6 -17
- package/assets/docs/theme.doc.mjs +6 -16
- package/assets/docs/theme.doc.zh.mjs +6 -16
- package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
- package/assets/docs/tree/data-colors-in-renderers.doc.mjs +400 -0
- package/assets/docs/tree/font-setup.doc.mjs +30 -0
- package/assets/docs/tree/icon-sets.doc.mjs +2 -2
- package/assets/docs/tree/share-a-page.doc.mjs +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +3 -3
- package/assets/docs/tree/tokens-color.doc.mjs +5 -0
- package/assets/docs/tree/tokens.doc.mjs +4 -3
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/visualization.doc.mjs +30 -0
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/definitions/drag.doc.mjs +1 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Card/SelectableCardElevated.doc.mjs +1 -1
- package/assets/templates/blocks/components/Card/SelectableCardElevated.tsx +20 -10
- package/assets/templates/blocks/components/Card/SelectableCardShowcase.doc.mjs +1 -1
- package/assets/templates/blocks/components/Card/SelectableCardShowcase.tsx +36 -16
- package/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx +6 -0
- package/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx +6 -0
- package/assets/templates/blocks/components/Hooks/useIndicatorFocusRingHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useIndicatorFocusRingHookUsage.tsx +63 -0
- package/assets/templates/blocks/components/Hooks/useLongPressHookUsage.doc.mjs +29 -0
- package/assets/templates/blocks/components/Hooks/useLongPressHookUsage.tsx +237 -0
- package/assets/templates/blocks/components/SideNav/SideNavShowcase.tsx +10 -72
- package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.doc.mjs +1 -1
- package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.tsx +7 -7
- package/assets/templates/blocks/components/Table/TableCustomRowTable.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/TableCustomRowTable.tsx +96 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat-landing/page.tsx +4 -0
- package/assets/templates/pages/dashboard-scorecard/page.tsx +26 -7
- package/assets/templates/pages/editor/page.tsx +13 -3
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/butter/butterTheme.ts +12 -10
- package/assets/templates/themes/butter/icons.tsx +2 -0
- package/assets/templates/themes/chocolate/chocolateTheme.ts +1 -0
- package/assets/templates/themes/chocolate/icons.tsx +2 -0
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/gothic/gothicTheme.ts +1 -0
- package/assets/templates/themes/gothic/icons.tsx +2 -0
- package/assets/templates/themes/matcha/icons.tsx +2 -0
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/matcha/matchaTheme.ts +1 -0
- package/assets/templates/themes/neutral/icons.tsx +2 -0
- package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/neutral/neutralTheme.ts +1 -0
- package/assets/templates/themes/stone/icons.tsx +2 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/stone/stoneTheme.ts +1 -0
- package/assets/templates/themes/y2k/icons.tsx +2 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +1 -0
- package/assets/theme.template.ts +9 -5
- package/authoring/config/parse.mjs +1 -1
- package/authoring/doctypes/base/type.ts +2 -3
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/icon-set/icon-names.mjs +1 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/doctor.mjs +2 -2
- package/clients/cli/commands/experimental/export.mjs +2 -1
- package/clients/cli/commands/experimental/icon.mjs +17 -17
- package/clients/cli/commands/experimental/index.mjs +0 -5
- package/clients/cli/commands/experimental/render-output.mjs +9 -0
- package/clients/cli/commands/experimental-export.doc.mjs +6 -0
- package/clients/cli/commands/experimental-icon-add.doc.mjs +8 -8
- package/clients/cli/commands/experimental-icon-map.doc.mjs +6 -6
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +6 -6
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +3 -3
- package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +6 -6
- package/clients/cli/commands/experimental.doc.mjs +2 -6
- package/clients/cli/commands/template.mjs +1 -1
- package/clients/cli/commands/theme-build.doc.mjs +8 -1
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -1
- package/clients/cli/commands/theme-remove.doc.mjs +1 -1
- package/clients/cli/commands/theme.doc.mjs +1 -11
- package/clients/cli/commands/theme.mjs +110 -475
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/index.mjs +4 -34
- package/clients/cli/lib/base-gate.mjs +2 -3
- package/clients/cli/lib/cli-error.mjs +8 -72
- package/clients/cli/lib/define-command.mjs +0 -19
- package/clients/cli/lib/json-shim.mjs +11 -633
- package/clients/cli/lib/manifest.mjs +0 -4
- package/clients/cli/lib/stray-option.mjs +1 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/color/css-color.mjs +2 -3
- package/foundation/discovery/app-layout.d.mts +13 -0
- package/foundation/discovery/app-layout.mjs +35 -0
- package/foundation/discovery/cli-self-docs.mjs +4 -4
- package/foundation/discovery/fixture-refs.d.mts +51 -0
- package/foundation/discovery/fixture-refs.mjs +351 -0
- package/foundation/discovery/icon-definition-discovery.mjs +7 -7
- package/foundation/discovery/icon-ranking.mjs +2 -2
- package/foundation/discovery/icon-set-checks.mjs +6 -6
- package/foundation/discovery/icon-set-discovery.mjs +2 -2
- package/foundation/discovery/icon-set-writer.d.mts +24 -7
- package/foundation/discovery/icon-set-writer.mjs +75 -31
- package/foundation/discovery/static-descriptor.d.mts +49 -0
- package/foundation/discovery/static-descriptor.mjs +548 -0
- package/foundation/discovery/template-adapter.d.mts +0 -47
- package/foundation/discovery/template-adapter.mjs +1 -333
- package/foundation/discovery/theme-discovery.d.mts +6 -47
- package/foundation/discovery/theme-discovery.mjs +15 -537
- package/foundation/doc-compiler/bundle.mjs +2 -2
- package/foundation/doc-compiler/import.mjs +1 -1
- package/foundation/env/user-dirs.d.mts +5 -2
- package/foundation/env/user-dirs.mjs +12 -5
- package/foundation/fonts/next-font.d.mts +26 -0
- package/foundation/fonts/next-font.mjs +149 -0
- package/foundation/fs/empty-folder.mjs +2 -2
- package/foundation/fs/read-record.mjs +11 -4
- package/foundation/pictures/pictures.d.mts +152 -0
- package/foundation/pictures/pictures.mjs +565 -0
- package/foundation/release/folder-lock.mjs +3 -2
- package/foundation/render/cut-short.d.mts +2 -2
- package/foundation/render/cut-short.mjs +2 -2
- package/foundation/render/drawn-contrast.d.mts +2 -2
- package/foundation/render/drawn-contrast.mjs +2 -2
- package/foundation/render/font-probe.d.mts +2 -2
- package/foundation/render/font-probe.mjs +2 -2
- package/foundation/render/layers.mjs +1 -2
- package/foundation/render/package-resolve-hooks.d.mts +25 -5
- package/foundation/render/package-resolve-hooks.mjs +77 -14
- package/foundation/render/page-worker.mjs +24 -12
- package/foundation/render/part-boxes.d.mts +2 -3
- package/foundation/render/part-boxes.mjs +2 -3
- package/foundation/render/picture-chrome.mjs +18 -15
- package/foundation/render/picture-playwright.mjs +10 -7
- package/foundation/render/picture-window.d.mts +13 -0
- package/foundation/render/picture-window.mjs +31 -0
- package/foundation/render/render-page.d.mts +1 -1
- package/foundation/render/render-page.mjs +4 -5
- package/foundation/render/single-copy-hooks.d.mts +2 -0
- package/foundation/render/single-copy-hooks.mjs +2 -0
- package/foundation/response/error-codes.doc.mjs +14 -14
- package/foundation/response/error-codes.mjs +13 -13
- package/foundation/response/response-types.doc.mjs +8 -69
- package/foundation/runtime/css-tree.mjs +2 -2
- package/foundation/runtime/word-table.d.mts +1 -1
- package/foundation/runtime/word-table.mjs +1 -1
- package/foundation/suggest/other-command.d.mts +52 -15
- package/foundation/suggest/other-command.mjs +168 -45
- package/foundation/text/suggest-order.d.mts +7 -0
- package/foundation/text/suggest-order.mjs +1 -1
- package/package.json +7 -8
- package/api/theme-edit/_adapter.d.mts +0 -228
- package/api/theme-edit/_adapter.mjs +0 -2025
- package/api/theme-edit/_catalog.d.mts +0 -172
- package/api/theme-edit/_catalog.mjs +0 -806
- package/api/theme-edit/_check.d.mts +0 -391
- package/api/theme-edit/_check.mjs +0 -9370
- package/api/theme-edit/_color.d.mts +0 -135
- package/api/theme-edit/_color.mjs +0 -480
- package/api/theme-edit/_compiler.d.mts +0 -77
- package/api/theme-edit/_compiler.mjs +0 -1053
- package/api/theme-edit/_context.d.mts +0 -399
- package/api/theme-edit/_context.mjs +0 -1778
- package/api/theme-edit/_css.d.mts +0 -169
- package/api/theme-edit/_css.mjs +0 -1167
- package/api/theme-edit/_edit.d.mts +0 -167
- package/api/theme-edit/_edit.mjs +0 -11220
- package/api/theme-edit/_how-commands.d.mts +0 -315
- package/api/theme-edit/_how-commands.mjs +0 -1664
- package/api/theme-edit/_how-question.d.mts +0 -341
- package/api/theme-edit/_how-question.mjs +0 -33291
- package/api/theme-edit/_how-sides.d.mts +0 -22
- package/api/theme-edit/_how-sides.mjs +0 -173
- package/api/theme-edit/_how-steps.d.mts +0 -42
- package/api/theme-edit/_how-steps.mjs +0 -208
- package/api/theme-edit/_how-values.d.mts +0 -29
- package/api/theme-edit/_how-values.mjs +0 -111
- package/api/theme-edit/_how-words.d.mts +0 -15
- package/api/theme-edit/_how-words.mjs +0 -239
- package/api/theme-edit/_how.d.mts +0 -55
- package/api/theme-edit/_how.mjs +0 -2388
- package/api/theme-edit/_importers.d.mts +0 -38
- package/api/theme-edit/_importers.mjs +0 -188
- package/api/theme-edit/_marks.d.mts +0 -39
- package/api/theme-edit/_marks.mjs +0 -67
- package/api/theme-edit/_missed.d.mts +0 -56
- package/api/theme-edit/_missed.mjs +0 -1128
- package/api/theme-edit/_name-rule.d.mts +0 -11
- package/api/theme-edit/_name-rule.mjs +0 -12
- package/api/theme-edit/_normal.d.mts +0 -365
- package/api/theme-edit/_normal.mjs +0 -1978
- package/api/theme-edit/_overview.d.mts +0 -9
- package/api/theme-edit/_overview.mjs +0 -293
- package/api/theme-edit/_palette.d.mts +0 -616
- package/api/theme-edit/_palette.mjs +0 -2776
- package/api/theme-edit/_part-pieces.d.mts +0 -54
- package/api/theme-edit/_part-pieces.mjs +0 -179
- package/api/theme-edit/_part-words.d.mts +0 -39
- package/api/theme-edit/_part-words.mjs +0 -242
- package/api/theme-edit/_parts.d.mts +0 -402
- package/api/theme-edit/_parts.mjs +0 -2294
- package/api/theme-edit/_picture-traits.d.mts +0 -259
- package/api/theme-edit/_picture-traits.mjs +0 -1030
- package/api/theme-edit/_png.d.mts +0 -94
- package/api/theme-edit/_png.mjs +0 -479
- package/api/theme-edit/_preview-app.d.mts +0 -172
- package/api/theme-edit/_preview-app.mjs +0 -6430
- package/api/theme-edit/_preview.d.mts +0 -549
- package/api/theme-edit/_preview.mjs +0 -3264
- package/api/theme-edit/_project.d.mts +0 -207
- package/api/theme-edit/_project.mjs +0 -643
- package/api/theme-edit/_resolved.d.mts +0 -46
- package/api/theme-edit/_resolved.mjs +0 -800
- package/api/theme-edit/_set-line.d.mts +0 -29
- package/api/theme-edit/_set-line.mjs +0 -100
- package/api/theme-edit/_settings.d.mts +0 -2426
- package/api/theme-edit/_settings.mjs +0 -18435
- package/api/theme-edit/_tables.d.mts +0 -227
- package/api/theme-edit/_tables.mjs +0 -1128
- package/api/theme-edit/_text-looks.d.mts +0 -78
- package/api/theme-edit/_text-looks.mjs +0 -376
- package/api/theme-edit/_vet.d.mts +0 -50
- package/api/theme-edit/_vet.mjs +0 -166
- package/api/theme-edit/how/how.d.mts +0 -17
- package/api/theme-edit/how/how.mjs +0 -28
- package/api/theme-edit/new/new.d.mts +0 -11
- package/api/theme-edit/new/new.mjs +0 -22
- package/api/theme-edit/preview-add/preview-add.d.mts +0 -14
- package/api/theme-edit/preview-add/preview-add.mjs +0 -25
- package/api/theme-edit/preview-app/preview-app.d.mts +0 -13
- package/api/theme-edit/preview-app/preview-app.mjs +0 -24
- package/api/theme-edit/preview-list/preview-list.d.mts +0 -10
- package/api/theme-edit/preview-list/preview-list.mjs +0 -21
- package/api/theme-edit/preview-remove/preview-remove.d.mts +0 -12
- package/api/theme-edit/preview-remove/preview-remove.mjs +0 -23
- package/api/theme-edit/set/set.d.mts +0 -13
- package/api/theme-edit/set/set.mjs +0 -24
- package/api/theme-edit/show/show.d.mts +0 -13
- package/api/theme-edit/show/show.mjs +0 -24
- package/api/theme-edit/theme-edit.d.mts +0 -12
- package/api/theme-edit/theme-edit.mjs +0 -36
- package/api/theme-edit/theme-edit.type.d.mts +0 -730
- package/api/theme-edit/theme-edit.type.mjs +0 -342
- package/api/theme-edit/themeEditHow.doc.d.mts +0 -6
- package/api/theme-edit/themeEditHow.doc.mjs +0 -105
- package/api/theme-edit/themeEditNew.doc.d.mts +0 -5
- package/api/theme-edit/themeEditNew.doc.mjs +0 -112
- package/api/theme-edit/themeEditPreviewAdd.doc.d.mts +0 -6
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +0 -121
- package/api/theme-edit/themeEditPreviewApp.doc.d.mts +0 -6
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +0 -87
- package/api/theme-edit/themeEditPreviewList.doc.d.mts +0 -6
- package/api/theme-edit/themeEditPreviewList.doc.mjs +0 -62
- package/api/theme-edit/themeEditPreviewRemove.doc.d.mts +0 -6
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +0 -96
- package/api/theme-edit/themeEditSet.doc.d.mts +0 -6
- package/api/theme-edit/themeEditSet.doc.mjs +0 -175
- package/api/theme-edit/themeEditShow.doc.d.mts +0 -6
- package/api/theme-edit/themeEditShow.doc.mjs +0 -118
- package/api/theme-edit/themeEditUndo.doc.d.mts +0 -6
- package/api/theme-edit/themeEditUndo.doc.mjs +0 -133
- package/api/theme-edit/undo/undo.d.mts +0 -13
- package/api/theme-edit/undo/undo.mjs +0 -24
- package/assets/preview-app/README.md +0 -6
- package/assets/preview-app/css.d.ts +0 -5
- package/assets/preview-app/gitignore +0 -4
- package/assets/preview-app/next.config.mjs +0 -12
- package/assets/preview-app/package.json +0 -24
- package/assets/preview-app/src/app/globals.css +0 -6
- package/assets/preview-app/src/app/layout.tsx +0 -21
- package/assets/preview-app/src/app/page.tsx +0 -94
- package/assets/preview-app/src/app/providers.tsx +0 -16
- package/assets/preview-app/tsconfig.json +0 -27
- package/clients/cli/commands/experimental/theme.mjs +0 -2990
- package/clients/cli/commands/experimental-theme-add.doc.mjs +0 -80
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +0 -98
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +0 -196
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +0 -174
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +0 -139
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +0 -77
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +0 -105
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +0 -49
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +0 -72
- package/clients/cli/commands/experimental-theme-list.doc.mjs +0 -49
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +0 -88
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +0 -61
- package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +0 -48
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +0 -59
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +0 -41
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +0 -57
- package/clients/cli/commands/experimental-theme-targets.doc.mjs +0 -62
- package/clients/cli/commands/experimental-theme-template.doc.mjs +0 -63
- package/clients/cli/commands/experimental-theme-use.doc.mjs +0 -57
- package/clients/cli/commands/experimental-theme.doc.mjs +0 -60
- package/foundation/fonts/fontsource-families.generated.d.mts +0 -5
- package/foundation/fonts/fontsource-families.generated.mjs +0 -2110
|
@@ -1,806 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file The pages `astryx experimental theme` renders: a catalog of every
|
|
5
|
-
* component (to learn what each part reads, and for the contact sheet) and a
|
|
6
|
-
* sample app page (the preview). Each page is written as a page module and
|
|
7
|
-
* rendered by the same machinery as `astryx experimental export`, with the
|
|
8
|
-
* project's own React and Core.
|
|
9
|
-
*
|
|
10
|
-
* Pages are element trees (`{__element, props, children}`), the shape of a
|
|
11
|
-
* component doc's playground defaults, so a component the installed Core
|
|
12
|
-
* does not have renders as nothing instead of breaking the page.
|
|
13
|
-
*
|
|
14
|
-
* @position api/theme-edit — page sources for the part data and previews
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @typedef {{__element: string, props?: Record<string, unknown>, children?: unknown}} Tree
|
|
19
|
-
* @typedef {{name: string, label: string, tree: unknown, group?: string, open?: boolean, mounted?: boolean, openable?: boolean, onlyOpen?: boolean, openTree?: unknown, strip?: boolean, anchored?: boolean, states?: boolean}} CatalogItem
|
|
20
|
-
* `open`: drawn open in a document after the server render (a popover,
|
|
21
|
-
* tooltip or menu, which Core places only once mounted: layers.mjs);
|
|
22
|
-
* `mounted`: drawn as the browser shows it once it runs, nothing opened
|
|
23
|
-
* (a part Core finishes as it mounts: a table's selected row);
|
|
24
|
-
* `openable`: also shown open in the overlays section when it holds an
|
|
25
|
-
* overlay a press opens (a dropdown's menu, a selector's list);
|
|
26
|
-
* `onlyOpen`: in the page for that open look alone; `openTree`: the part
|
|
27
|
-
* as shown open, when a prop its doc names opens it (a dropdown's
|
|
28
|
-
* `isMenuOpen`); `strip`: on the sample page, drawn open in the strip of
|
|
29
|
-
* overlays below it; `anchored`: an overlay placed beside its trigger (it
|
|
30
|
-
* takes a placement), small, shown before the panels over the page;
|
|
31
|
-
* `states`: drawn at rest, hovered, focused from the keyboard and pressed
|
|
32
|
-
* (a control of the sample page), when it holds a control to focus
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
import {LAYER_GLOBAL} from '../../foundation/render/layers.mjs';
|
|
36
|
-
|
|
37
|
-
/** @param {string} name @param {Record<string, unknown>} [props] @param {...unknown} children @returns {Tree} */
|
|
38
|
-
export const h = (name, props = {}, ...children) => ({
|
|
39
|
-
__element: name,
|
|
40
|
-
props,
|
|
41
|
-
...(children.length ? {children} : {}),
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const ROWS = [
|
|
45
|
-
{id: 1, task: 'Review Q4 roadmap', owner: 'Alex', status: 'In progress'},
|
|
46
|
-
{id: 2, task: 'Ship onboarding flow', owner: 'Sam', status: 'Done'},
|
|
47
|
-
{id: 3, task: 'Fix login timeout', owner: 'Riley', status: 'Blocked'},
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* The Core components the in-app preview's top bar draws (its title and
|
|
52
|
-
* its light/dark/system switch). The route imports these, and the contrast
|
|
53
|
-
* check measures each one's text over the header, as the app shows it.
|
|
54
|
-
*/
|
|
55
|
-
export const TOP_BAR_COMPONENTS = Object.freeze([
|
|
56
|
-
'TopNav',
|
|
57
|
-
'TopNavHeading',
|
|
58
|
-
'SegmentedControl',
|
|
59
|
-
'SegmentedControlItem',
|
|
60
|
-
]);
|
|
61
|
-
|
|
62
|
-
/** The sample app page every preview shows. */
|
|
63
|
-
export const SAMPLE_PAGE = h(
|
|
64
|
-
'AppShell',
|
|
65
|
-
{
|
|
66
|
-
height: 'auto',
|
|
67
|
-
contentPadding: 4,
|
|
68
|
-
topNav: h('TopNav', {
|
|
69
|
-
label: 'Main',
|
|
70
|
-
heading: h('Text', {weight: 'bold'}, 'Open Items'),
|
|
71
|
-
startContent: h(
|
|
72
|
-
'HStack',
|
|
73
|
-
{gap: 1},
|
|
74
|
-
h('TopNavItem', {label: 'Inbox', href: '#', isSelected: true}),
|
|
75
|
-
h('TopNavItem', {label: 'Projects', href: '#'}),
|
|
76
|
-
h('TopNavItem', {label: 'Reports', href: '#'}),
|
|
77
|
-
),
|
|
78
|
-
endContent: h('Button', {
|
|
79
|
-
label: 'New item',
|
|
80
|
-
variant: 'primary',
|
|
81
|
-
size: 'sm',
|
|
82
|
-
}),
|
|
83
|
-
}),
|
|
84
|
-
sideNav: h(
|
|
85
|
-
'SideNav',
|
|
86
|
-
{label: 'Sections'},
|
|
87
|
-
h('SideNavItem', {label: 'My tasks', href: '#', isSelected: true}),
|
|
88
|
-
h('SideNavItem', {label: 'Team', href: '#'}),
|
|
89
|
-
h('SideNavItem', {label: 'Archive', href: '#'}),
|
|
90
|
-
),
|
|
91
|
-
},
|
|
92
|
-
h(
|
|
93
|
-
'VStack',
|
|
94
|
-
{gap: 4},
|
|
95
|
-
h(
|
|
96
|
-
'VStack',
|
|
97
|
-
{gap: 1},
|
|
98
|
-
h('Heading', {level: 1, type: 'display-2'}, 'Plan the week ahead'),
|
|
99
|
-
// A link in running text, as an app writes one: its color is read on
|
|
100
|
-
// the page.
|
|
101
|
-
h(
|
|
102
|
-
'Text',
|
|
103
|
-
{type: 'supporting'},
|
|
104
|
-
'Everything your team is working on, in one place. ',
|
|
105
|
-
h('Link', {href: '#'}, 'See the plan'),
|
|
106
|
-
),
|
|
107
|
-
),
|
|
108
|
-
h('Heading', {level: 2}, 'My tasks'),
|
|
109
|
-
h('Banner', {
|
|
110
|
-
status: 'info',
|
|
111
|
-
title: 'Weekly sync moved to Thursday',
|
|
112
|
-
description: 'The agenda doc is updated.',
|
|
113
|
-
collapsible: false,
|
|
114
|
-
}),
|
|
115
|
-
h(
|
|
116
|
-
'TabList',
|
|
117
|
-
{value: 'open'},
|
|
118
|
-
h('Tab', {value: 'open', label: 'Open'}),
|
|
119
|
-
h('Tab', {value: 'done', label: 'Done'}),
|
|
120
|
-
h('Tab', {value: 'all', label: 'All'}),
|
|
121
|
-
),
|
|
122
|
-
h(
|
|
123
|
-
'HStack',
|
|
124
|
-
{gap: 4, align: 'start'},
|
|
125
|
-
h(
|
|
126
|
-
'Card',
|
|
127
|
-
{width: 340},
|
|
128
|
-
h(
|
|
129
|
-
'VStack',
|
|
130
|
-
{gap: 3},
|
|
131
|
-
h(
|
|
132
|
-
'HStack',
|
|
133
|
-
{gap: 2, align: 'center'},
|
|
134
|
-
h('Heading', {level: 3}, 'New task'),
|
|
135
|
-
h('Badge', {variant: 'info', label: 'Draft'}),
|
|
136
|
-
h('Badge', {variant: 'neutral', label: 'Personal'}),
|
|
137
|
-
),
|
|
138
|
-
// A link in a card's text: its color is read on the card.
|
|
139
|
-
h(
|
|
140
|
-
'Text',
|
|
141
|
-
{type: 'body'},
|
|
142
|
-
'Shared with your team. ',
|
|
143
|
-
h('Link', {href: '#'}, 'Change who sees it'),
|
|
144
|
-
),
|
|
145
|
-
h('TextInput', {label: 'Title', value: 'Prepare launch notes'}),
|
|
146
|
-
h('Switch', {label: 'Notify my team', value: true}),
|
|
147
|
-
h('CheckboxInput', {label: 'Add to calendar', value: true}),
|
|
148
|
-
h('ProgressBar', {label: 'Progress', value: 60, hasValueLabel: true}),
|
|
149
|
-
// The buttons wrap to a second row when a theme's buttons are
|
|
150
|
-
// wider than the card (a roomier padding, a larger text): a
|
|
151
|
-
// label is never cut short by the sample's own width.
|
|
152
|
-
h(
|
|
153
|
-
'HStack',
|
|
154
|
-
{gap: 2, wrap: 'wrap'},
|
|
155
|
-
h('Button', {label: 'Save', variant: 'primary'}),
|
|
156
|
-
h('Button', {label: 'Preview', variant: 'secondary'}),
|
|
157
|
-
h('Button', {label: 'Cancel', variant: 'ghost'}),
|
|
158
|
-
h('Button', {label: 'Delete', variant: 'destructive'}),
|
|
159
|
-
),
|
|
160
|
-
),
|
|
161
|
-
),
|
|
162
|
-
h(
|
|
163
|
-
'Card',
|
|
164
|
-
{width: 400},
|
|
165
|
-
h(
|
|
166
|
-
'VStack',
|
|
167
|
-
{gap: 3},
|
|
168
|
-
h('Heading', {level: 3}, 'This week'),
|
|
169
|
-
// Striped, so Core's row stripe, and a theme's stripe color, show on
|
|
170
|
-
// the page.
|
|
171
|
-
h('Table', {
|
|
172
|
-
data: ROWS,
|
|
173
|
-
idKey: 'id',
|
|
174
|
-
isStriped: true,
|
|
175
|
-
columns: [
|
|
176
|
-
{key: 'task', header: 'Task'},
|
|
177
|
-
{key: 'owner', header: 'Owner'},
|
|
178
|
-
{key: 'status', header: 'Status'},
|
|
179
|
-
],
|
|
180
|
-
}),
|
|
181
|
-
h(
|
|
182
|
-
'HStack',
|
|
183
|
-
{gap: 2, align: 'center'},
|
|
184
|
-
h('StatusDot', {variant: 'success', label: 'ok'}),
|
|
185
|
-
h('Badge', {variant: 'success', label: '2 done'}),
|
|
186
|
-
h('StatusDot', {variant: 'warning', label: 'risk'}),
|
|
187
|
-
h('Badge', {variant: 'warning', label: '1 at risk'}),
|
|
188
|
-
h('StatusDot', {variant: 'error', label: 'blocked'}),
|
|
189
|
-
h('Badge', {variant: 'error', label: '1 blocked'}),
|
|
190
|
-
),
|
|
191
|
-
),
|
|
192
|
-
),
|
|
193
|
-
),
|
|
194
|
-
),
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* The few fixed items of the sample search source a page hands a part that
|
|
199
|
-
* requires one (a typeahead): the editor's pages and the catalog the part
|
|
200
|
-
* data is read from use these same items.
|
|
201
|
-
*/
|
|
202
|
-
export const SAMPLE_SEARCH_ITEMS = Object.freeze([
|
|
203
|
-
{id: 'design', label: 'Design'},
|
|
204
|
-
{id: 'engineering', label: 'Engineering'},
|
|
205
|
-
{id: 'research', label: 'Research'},
|
|
206
|
-
{id: 'marketing', label: 'Marketing'},
|
|
207
|
-
]);
|
|
208
|
-
|
|
209
|
-
/** The prop value that stands for the page's sample search source. */
|
|
210
|
-
export const SAMPLE_SOURCE = Object.freeze({__code: 'SAMPLE_SOURCE'});
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Overlays the overlays section draws open in a deeper state than their docs
|
|
214
|
-
* show: a menu with its submenu open, a popover that holds a form, a date and
|
|
215
|
-
* time field with its time list, a table with a row selected and a column
|
|
216
|
-
* sorted, and the navigation drawer of a narrow screen. Each is drawn as the
|
|
217
|
-
* other overlays are: open as it mounts, or opened by the drawing's presses
|
|
218
|
-
* (`openable`). A part a hook configures (a table's plugins) names the hook
|
|
219
|
-
* and its state as data (`{__plugin, ...}`), and the page calls the hook.
|
|
220
|
-
* @type {ReadonlyArray<import('./_catalog.mjs').CatalogItem>}
|
|
221
|
-
*/
|
|
222
|
-
export const OPEN_SCENES = Object.freeze([
|
|
223
|
-
{
|
|
224
|
-
name: 'DropdownMenu',
|
|
225
|
-
label: 'submenu',
|
|
226
|
-
openable: true,
|
|
227
|
-
tree: h('DropdownMenu', {
|
|
228
|
-
button: {label: 'Move'},
|
|
229
|
-
items: [
|
|
230
|
-
{label: 'Rename'},
|
|
231
|
-
{
|
|
232
|
-
label: 'Move to',
|
|
233
|
-
items: [{label: 'Inbox'}, {label: 'Archive'}, {label: 'Trash'}],
|
|
234
|
-
},
|
|
235
|
-
{label: 'Delete'},
|
|
236
|
-
],
|
|
237
|
-
}),
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
name: 'Popover',
|
|
241
|
-
label: 'form',
|
|
242
|
-
open: true,
|
|
243
|
-
anchored: true,
|
|
244
|
-
tree: h('Popover', {
|
|
245
|
-
isOpen: true,
|
|
246
|
-
label: 'Filter tasks',
|
|
247
|
-
hasAutoFocus: false,
|
|
248
|
-
content: h(
|
|
249
|
-
'VStack',
|
|
250
|
-
{gap: 3},
|
|
251
|
-
h('TextInput', {label: 'Owner', value: 'Alex'}),
|
|
252
|
-
h('CheckboxInput', {label: 'Only open items', value: true}),
|
|
253
|
-
h(
|
|
254
|
-
'HStack',
|
|
255
|
-
{gap: 2},
|
|
256
|
-
h('Button', {label: 'Apply', variant: 'primary'}),
|
|
257
|
-
h('Button', {label: 'Reset', variant: 'ghost'}),
|
|
258
|
-
),
|
|
259
|
-
),
|
|
260
|
-
children: h('Button', {label: 'Filter', variant: 'secondary'}),
|
|
261
|
-
}),
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
name: 'DateTimeInput',
|
|
265
|
-
label: 'time list',
|
|
266
|
-
openable: true,
|
|
267
|
-
tree: h('DateTimeInput', {
|
|
268
|
-
label: 'Starts',
|
|
269
|
-
value: '2026-11-16T09:30',
|
|
270
|
-
timeOptionInterval: 30,
|
|
271
|
-
}),
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
// Core marks a selected row and a sorted column as the browser runs
|
|
275
|
-
// (the row's selected state, the column's sort glyph), so the table is
|
|
276
|
-
// drawn as it mounts, with its plugins in that state.
|
|
277
|
-
name: 'Table',
|
|
278
|
-
label: 'selected and sorted',
|
|
279
|
-
mounted: true,
|
|
280
|
-
tree: h('Table', {
|
|
281
|
-
idKey: 'id',
|
|
282
|
-
data: [
|
|
283
|
-
{id: '1', name: 'Alice', role: 'Engineer', status: 'Active'},
|
|
284
|
-
{id: '2', name: 'Bob', role: 'Designer', status: 'Away'},
|
|
285
|
-
{id: '3', name: 'Charlie', role: 'Manager', status: 'Active'},
|
|
286
|
-
],
|
|
287
|
-
columns: [
|
|
288
|
-
{key: 'name', header: 'Name', sortable: true},
|
|
289
|
-
{key: 'role', header: 'Role', sortable: true},
|
|
290
|
-
{key: 'status', header: 'Status'},
|
|
291
|
-
],
|
|
292
|
-
plugins: {
|
|
293
|
-
selection: {__plugin: 'useTableSelection', selected: ['2']},
|
|
294
|
-
sortable: {
|
|
295
|
-
__plugin: 'useTableSortable',
|
|
296
|
-
sort: [{sortKey: 'name', direction: 'ascending'}],
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
}),
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
name: 'CommandPalette',
|
|
303
|
-
label: 'highlighted',
|
|
304
|
-
// Its picker highlights the chosen item once its first results come,
|
|
305
|
-
// so it is drawn as the browser shows it after mounting.
|
|
306
|
-
mounted: true,
|
|
307
|
-
tree: h('CommandPalette', {
|
|
308
|
-
isOpen: true,
|
|
309
|
-
isInline: true,
|
|
310
|
-
searchSource: SAMPLE_SOURCE,
|
|
311
|
-
value: SAMPLE_SEARCH_ITEMS[1].id,
|
|
312
|
-
}),
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
name: 'MobileNav',
|
|
316
|
-
label: 'open',
|
|
317
|
-
open: true,
|
|
318
|
-
tree: h(
|
|
319
|
-
'MobileNav',
|
|
320
|
-
{isOpen: true, header: 'Navigation'},
|
|
321
|
-
h(
|
|
322
|
-
'SideNavSection',
|
|
323
|
-
{title: 'Main'},
|
|
324
|
-
h('SideNavItem', {label: 'Inbox', href: '#', isSelected: true}),
|
|
325
|
-
h('SideNavItem', {label: 'Projects', href: '#'}),
|
|
326
|
-
h('SideNavItem', {label: 'Reports', href: '#'}),
|
|
327
|
-
),
|
|
328
|
-
),
|
|
329
|
-
},
|
|
330
|
-
]);
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Each control of the sample page once (a button of each variant, a field,
|
|
334
|
-
* a switch, a tab, a nav item), for the states section. A part of a parent
|
|
335
|
-
* (a tab) stays inside the parent the page puts it in, alone there.
|
|
336
|
-
* @returns {Array<{tree: Tree, label: string}>}
|
|
337
|
-
*/
|
|
338
|
-
export function sampleControls() {
|
|
339
|
-
/** @type {Map<string, {tree: Tree, label: string}>} */
|
|
340
|
-
const out = new Map();
|
|
341
|
-
/** @param {unknown} v @param {Tree | null} parent */
|
|
342
|
-
const walk = (v, parent) => {
|
|
343
|
-
if (Array.isArray(v)) {
|
|
344
|
-
for (const x of v) walk(x, parent);
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
if (!v || typeof v !== 'object') return;
|
|
348
|
-
const e = /** @type {Tree} */ (v);
|
|
349
|
-
if (typeof e.__element !== 'string') return;
|
|
350
|
-
const inner = [...Object.values(e.props ?? {}), e.children];
|
|
351
|
-
if (elementNames(inner).size) {
|
|
352
|
-
for (const x of inner) walk(x, e);
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
const props = e.props ?? {};
|
|
356
|
-
const siblings = /** @type {unknown[]} */ ([]).concat(
|
|
357
|
-
parent?.children ?? [],
|
|
358
|
-
);
|
|
359
|
-
const inParent = parent != null && siblings.includes(e);
|
|
360
|
-
// A part its parent holds selected by value (a tab), or that says so.
|
|
361
|
-
const selected =
|
|
362
|
-
props.isSelected === true ||
|
|
363
|
-
(inParent && props.value != null && parent?.props?.value === props.value);
|
|
364
|
-
// One of each look: a variant at a size, selected or not.
|
|
365
|
-
const label = [props.variant, props.size, selected ? 'selected' : '']
|
|
366
|
-
.filter(x => typeof x === 'string' && x)
|
|
367
|
-
.join(' ');
|
|
368
|
-
const key = `${e.__element} ${label}`;
|
|
369
|
-
if (out.has(key)) return;
|
|
370
|
-
out.set(key, {
|
|
371
|
-
tree: inParent && parent ? {...parent, children: [e]} : e,
|
|
372
|
-
label,
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
walk(SAMPLE_PAGE, null);
|
|
376
|
-
return [...out.values()];
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/** Components first on the contact sheet, in this order. */
|
|
380
|
-
export const SHEET_ORDER = [
|
|
381
|
-
'Heading',
|
|
382
|
-
'Text',
|
|
383
|
-
'Button',
|
|
384
|
-
'Badge',
|
|
385
|
-
'Banner',
|
|
386
|
-
'Card',
|
|
387
|
-
'TextInput',
|
|
388
|
-
'TextArea',
|
|
389
|
-
'NumberInput',
|
|
390
|
-
'Selector',
|
|
391
|
-
'CheckboxInput',
|
|
392
|
-
'Switch',
|
|
393
|
-
'ProgressBar',
|
|
394
|
-
'TabList',
|
|
395
|
-
'SegmentedControl',
|
|
396
|
-
'TopNav',
|
|
397
|
-
'SideNav',
|
|
398
|
-
'Table',
|
|
399
|
-
'StatusDot',
|
|
400
|
-
];
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Every component name an element tree uses, and every hook its plugins
|
|
404
|
-
* name.
|
|
405
|
-
* @param {unknown} v
|
|
406
|
-
* @param {Set<string>} [out]
|
|
407
|
-
* @returns {Set<string>}
|
|
408
|
-
*/
|
|
409
|
-
export function elementNames(v, out = new Set()) {
|
|
410
|
-
if (Array.isArray(v)) for (const x of v) elementNames(x, out);
|
|
411
|
-
else if (v && typeof v === 'object') {
|
|
412
|
-
const el = /** @type {any} */ (v).__element;
|
|
413
|
-
if (typeof el === 'string') out.add(el);
|
|
414
|
-
// A hook a part's plugin names is imported as a part is.
|
|
415
|
-
const hook = /** @type {any} */ (v).__plugin;
|
|
416
|
-
if (typeof hook === 'string') out.add(hook);
|
|
417
|
-
for (const x of Object.values(v)) elementNames(x, out);
|
|
418
|
-
}
|
|
419
|
-
return out;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Where an element of a page comes from: a module specifier, bound to the
|
|
424
|
-
* export named like the element, or a module and the export it is (a
|
|
425
|
-
* template page is its file's `default`).
|
|
426
|
-
* @typedef {string | {from: string, export: string}} Binding
|
|
427
|
-
*/
|
|
428
|
-
|
|
429
|
-
/** The module a binding imports. @param {Binding} b */
|
|
430
|
-
export const bindingFrom = b => (typeof b === 'string' ? b : b.from);
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* The page module source for a list of items. Each item renders on its own,
|
|
434
|
-
* so one component that throws leaves the rest of the page. With a theme,
|
|
435
|
-
* each item renders inside `<Theme>`; a theme with both modes follows the
|
|
436
|
-
* viewer's scheme, and a bar of three CSS-only switches (auto, light, dark)
|
|
437
|
-
* flips it, since the file runs no script.
|
|
438
|
-
* @param {object} spec
|
|
439
|
-
* @param {CatalogItem[]} spec.items
|
|
440
|
-
* @param {Record<string, Binding>} spec.imports element name -> the module
|
|
441
|
-
* it comes from (bound to the export of the same name), or the module and
|
|
442
|
-
* the export it is
|
|
443
|
-
* @param {{module: string, css: string[], mode: 'system' | 'light' | 'dark'} | null} spec.theme
|
|
444
|
-
* module and css are import specifiers relative to the page
|
|
445
|
-
* @param {'catalog' | 'sheet' | 'page'} spec.layout
|
|
446
|
-
* @param {string} [spec.title]
|
|
447
|
-
* @param {string} [spec.section] the section a sheet shows alone, as a class on its page
|
|
448
|
-
* @returns {string}
|
|
449
|
-
*/
|
|
450
|
-
export function pageSource({
|
|
451
|
-
items,
|
|
452
|
-
imports,
|
|
453
|
-
theme,
|
|
454
|
-
layout,
|
|
455
|
-
title = '',
|
|
456
|
-
section = '',
|
|
457
|
-
}) {
|
|
458
|
-
/** @type {Map<string, Array<[string, string]>>} element and export, per module */
|
|
459
|
-
const byModule = new Map();
|
|
460
|
-
for (const [name, b] of Object.entries(imports)) {
|
|
461
|
-
const spec = bindingFrom(b);
|
|
462
|
-
const list = byModule.get(spec) ?? [];
|
|
463
|
-
list.push([name, typeof b === 'string' ? name : b.export]);
|
|
464
|
-
byModule.set(spec, list);
|
|
465
|
-
}
|
|
466
|
-
const lines = [
|
|
467
|
-
'// Generated by astryx experimental theme. It is rebuilt on every run.',
|
|
468
|
-
"import * as React from 'react';",
|
|
469
|
-
"import {renderToStaticMarkup} from 'react-dom/server';",
|
|
470
|
-
];
|
|
471
|
-
if (theme) {
|
|
472
|
-
lines.push("import {Theme} from '@astryxdesign/core/theme';");
|
|
473
|
-
lines.push(`import * as ThemeModule from ${JSON.stringify(theme.module)};`);
|
|
474
|
-
for (const c of theme.css) lines.push(`import ${JSON.stringify(c)};`);
|
|
475
|
-
}
|
|
476
|
-
const entries = [];
|
|
477
|
-
let i = 0;
|
|
478
|
-
for (const [spec, names] of byModule) {
|
|
479
|
-
lines.push(`import * as M${i} from ${JSON.stringify(spec)};`);
|
|
480
|
-
for (const [n, exp] of names)
|
|
481
|
-
entries.push(`${JSON.stringify(n)}: M${i}[${JSON.stringify(exp)}]`);
|
|
482
|
-
i++;
|
|
483
|
-
}
|
|
484
|
-
lines.push(`const C = {${entries.join(', ')}};`);
|
|
485
|
-
lines.push('const noop = () => {};');
|
|
486
|
-
lines.push(
|
|
487
|
-
'const HANDLERS = ["onChange", "onClick", "onDismiss", "onOpenChange", "onSelect", "onValueChange"];',
|
|
488
|
-
);
|
|
489
|
-
lines.push(
|
|
490
|
-
'const isEl = v => Boolean(v && typeof v === "object" && !Array.isArray(v) && v.__element);',
|
|
491
|
-
);
|
|
492
|
-
lines.push(
|
|
493
|
-
'function el(v) { if (Array.isArray(v)) return v.map(el); if (v && typeof v === "object" && v.__element) { const T = C[v.__element] ?? (/^[a-z][a-z0-9]*$/.test(v.__element) ? v.__element : null); if (!T) return null; const props = fix(v.props ?? {}); if (props.plugins && Object.values(props.plugins).some(isPlugin)) return React.createElement(Plugged, {T, props}); return React.createElement(T, props, ...[].concat(v.children ?? []).map(el)); } return v; }',
|
|
494
|
-
);
|
|
495
|
-
// A plugin named as data ({__plugin: hook, ...state}) is the hook's
|
|
496
|
-
// return, called in a component of the page's own, with the state the data
|
|
497
|
-
// gives it: a table's selected rows, its sorted columns.
|
|
498
|
-
lines.push(
|
|
499
|
-
'const isPlugin = v => Boolean(v && typeof v === "object" && typeof v.__plugin === "string");',
|
|
500
|
-
);
|
|
501
|
-
lines.push(
|
|
502
|
-
'const PLUGIN_CONFIG = {useTableSelection: (spec, props) => ({getIsItemSelected: item => (spec.selected ?? []).includes(String(item[props.idKey ?? "id"])), onSelectItem: noop, onSelectAll: noop, getIsAllSelected: () => false, getIsIndeterminate: () => (spec.selected ?? []).length > 0}), useTableSortable: spec => ({sort: spec.sort ?? [], onSortChange: noop})};',
|
|
503
|
-
);
|
|
504
|
-
lines.push(
|
|
505
|
-
'function Plugged({T, props}) { const plugins = {}; for (const [k, spec] of Object.entries(props.plugins)) plugins[k] = isPlugin(spec) && C[spec.__plugin] && PLUGIN_CONFIG[spec.__plugin] ? C[spec.__plugin](PLUGIN_CONFIG[spec.__plugin](spec, props)) : spec; return React.createElement(T, {...props, plugins}); }',
|
|
506
|
-
);
|
|
507
|
-
// The sample search source a part that requires one gets (a typeahead):
|
|
508
|
-
// the prop names it, the page defines it.
|
|
509
|
-
lines.push(`const SAMPLE_ITEMS = ${JSON.stringify(SAMPLE_SEARCH_ITEMS)};`);
|
|
510
|
-
lines.push(
|
|
511
|
-
'const SAMPLE_SOURCE = {search: q => SAMPLE_ITEMS.filter(i => i.label.toLowerCase().includes(String(q).toLowerCase())), bootstrap: () => SAMPLE_ITEMS, cancel: () => {}};',
|
|
512
|
-
);
|
|
513
|
-
lines.push(
|
|
514
|
-
'function fix(p) { const o = {}; for (const [k, v] of Object.entries(p)) o[k] = v && typeof v === "object" && v.__code === "SAMPLE_SOURCE" ? SAMPLE_SOURCE : isEl(v) || (Array.isArray(v) && v.some(isEl)) ? el(v) : v; for (const k of HANDLERS) if (!(k in o)) o[k] = noop; return o; }',
|
|
515
|
-
);
|
|
516
|
-
lines.push(`const ITEMS = ${JSON.stringify(items)};`);
|
|
517
|
-
lines.push(
|
|
518
|
-
theme
|
|
519
|
-
? 'const theme = Object.values(ThemeModule).find(v => v && typeof v === "object" && typeof v.name === "string");'
|
|
520
|
-
: 'const theme = null;',
|
|
521
|
-
);
|
|
522
|
-
lines.push(`const MODE = ${JSON.stringify(theme?.mode ?? 'light')};`);
|
|
523
|
-
lines.push(
|
|
524
|
-
// A part shown open whose server render leaves only a layer's marker
|
|
525
|
-
// (Core places a popover, tooltip or menu once mounted) goes to the
|
|
526
|
-
// render's drawing of open layers, which puts it in place after the
|
|
527
|
-
// server render. Any other part is its server render. `open` is
|
|
528
|
-
// 'ifOpen' for a part shown only for its open look: drawn as nothing when
|
|
529
|
-
// nothing opens. Content Core keeps inert in its server render waits for
|
|
530
|
-
// what only the browser knows (a calendar's month waits for today's
|
|
531
|
-
// date), so a part that holds it is drawn as the browser mounts it; so
|
|
532
|
-
// is an overlay shown open with no layer, which loads what it lists once
|
|
533
|
-
// mounted (a command palette's items).
|
|
534
|
-
`function html(tree, mode = MODE, open = false) { try { const node = el(tree); const whole = theme ? React.createElement(Theme, {theme, mode}, node) : node; const markup = renderToStaticMarkup(whole); const layered = markup.includes('<template></template>'); if (open === 'ifOpen' && !layered) return null; const mounted = open === 'mounted' || open === true && !layered || !open && markup.includes(' inert=""'); const draw = (open && layered) || mounted ? globalThis[${JSON.stringify(LAYER_GLOBAL)}] : null; return draw ? draw(whole, mounted ? 'mounted' : open === 'ifOpen') : markup; } catch { return null; } }`,
|
|
535
|
-
);
|
|
536
|
-
// A theme with both modes: each part is rendered in light and in dark, as
|
|
537
|
-
// the app renders it in each (a part that picks its look from the mode as
|
|
538
|
-
// it renders, such as a Toast's text on its inverted surface, differs);
|
|
539
|
-
// a part whose two renders are the same is written once.
|
|
540
|
-
lines.push(
|
|
541
|
-
'function modes(tree, open) { if (!theme || MODE !== "system") { const one = html(tree, MODE, open); return one == null ? null : {one}; } const light = html(tree, "light", open); const dark = html(tree, "dark", open); if (light == null && dark == null) return null; return light === dark ? {one: light} : {light: light ?? "", dark: dark ?? ""}; }',
|
|
542
|
-
);
|
|
543
|
-
lines.push(`const LAYOUT = ${JSON.stringify(layout)};`);
|
|
544
|
-
// How the sheet groups the parts drawn into its sections, written into
|
|
545
|
-
// the page from the functions below (what reads the sheet's sections
|
|
546
|
-
// reads the same).
|
|
547
|
-
lines.push(
|
|
548
|
-
String(openGroupOf),
|
|
549
|
-
String(sheetGroups),
|
|
550
|
-
String(sheetSectionClass),
|
|
551
|
-
);
|
|
552
|
-
lines.push(`const SECTION = ${JSON.stringify(section ?? '')};`);
|
|
553
|
-
lines.push(`const TITLE = ${JSON.stringify(title)};`);
|
|
554
|
-
lines.push(`const SHEET_CSS = ${JSON.stringify(SHEET_CSS)};`);
|
|
555
|
-
// The parts as live elements, for drawing the overlays they show or open
|
|
556
|
-
// (render-page's openLayers): the page itself holds only their markup.
|
|
557
|
-
lines.push(`const h = React.createElement;
|
|
558
|
-
export function openLayerElements() {
|
|
559
|
-
return ITEMS.map(it => { const node = el(it.tree); return theme ? h(Theme, {theme, mode: MODE === 'system' ? 'light' : MODE}, node) : node; });
|
|
560
|
-
}
|
|
561
|
-
export default function Page() {
|
|
562
|
-
if (LAYOUT === 'catalog') {
|
|
563
|
-
return h('div', null, ITEMS.map((it, i) => {
|
|
564
|
-
const markup = html(it.tree);
|
|
565
|
-
return markup == null ? null : h('section', {key: i, 'data-cat': it.name, dangerouslySetInnerHTML: {__html: markup}});
|
|
566
|
-
}));
|
|
567
|
-
}
|
|
568
|
-
const rendered = ITEMS.map(it => ({...it, markup: modes(it.tree, it.mounted ? 'mounted' : it.open)})).filter(it => it.markup != null);
|
|
569
|
-
// A part only in this page for its open look (the overlays section alone)
|
|
570
|
-
// is not shown closed.
|
|
571
|
-
const done = rendered.filter(it => !it.onlyOpen);
|
|
572
|
-
// A part with a closed control that opens a popup (a dropdown's menu
|
|
573
|
-
// button, a selector's field: the controls the drawing presses), or with
|
|
574
|
-
// a layer's marker and no such control (a context menu's area, which a
|
|
575
|
-
// right click opens), is shown open too, with the overlays, so a look's
|
|
576
|
-
// menus and lists show in the pictures.
|
|
577
|
-
// On one family's own page its parts drawn open follow the family, named
|
|
578
|
-
// for it; on the whole sheet they join the overlays.
|
|
579
|
-
const OPEN_GROUP = openGroupOf(SECTION);
|
|
580
|
-
const opensPopup = html => html.includes('<template></template>') || (html.match(/<[^>]*\\baria-expanded="false"[^>]*>/g) ?? []).some(tag => /\\baria-haspopup=|\\brole="combobox"/.test(tag));
|
|
581
|
-
for (const it of rendered) {
|
|
582
|
-
const m = it.markup;
|
|
583
|
-
if (!it.openable || !opensPopup(m.one ?? m.light)) continue;
|
|
584
|
-
const open = modes(it.openTree ?? it.tree, 'ifOpen');
|
|
585
|
-
if (open) done.push({...it, group: OPEN_GROUP, label: it.label || 'open', markup: open, opened: true});
|
|
586
|
-
}
|
|
587
|
-
// A control of the sample page drawn in each state a person puts it in:
|
|
588
|
-
// the render's stylesheet applies a state's rules to what is marked with
|
|
589
|
-
// it (render-page.mjs), so a picture shows hover, keyboard focus and a
|
|
590
|
-
// press with no pointer or keyboard. Hover and press reach the control
|
|
591
|
-
// and all it holds, as a pointer over it does; focus reaches the first
|
|
592
|
-
// element that takes it, as a Tab does.
|
|
593
|
-
const FOCUSABLE = /<(?:button|input|select|textarea)\\b|<a\\b(?=[^>]*\\shref=)|<[a-z][\\w-]*\\b(?=[^>]*\\stabindex="0")/;
|
|
594
|
-
const inState = (html, state) => {
|
|
595
|
-
if (state === 'focus') { const m = FOCUSABLE.exec(html); return m ? html.slice(0, m.index) + m[0] + ' data-astryx-state="focus"' + html.slice(m.index + m[0].length) : html; }
|
|
596
|
-
return '<div data-astryx-state="' + state + '">' + html + '</div>';
|
|
597
|
-
};
|
|
598
|
-
const STATES = [['rest', null], ['hover', 'hover'], ['focus-visible', 'focus'], ['pressed', 'hover active']];
|
|
599
|
-
const stated = [];
|
|
600
|
-
for (const it of done.filter(x => x.states)) {
|
|
601
|
-
const m = it.markup;
|
|
602
|
-
if (!FOCUSABLE.test(m.one ?? m.light)) continue;
|
|
603
|
-
const each = f => m.one != null ? {one: f(m.one)} : {light: f(m.light), dark: f(m.dark)};
|
|
604
|
-
stated.push({...it, rows: STATES.map(([label, s]) => ({label, markup: s ? each(html => inState(html, s)) : m}))});
|
|
605
|
-
}
|
|
606
|
-
const drawn = done.filter(x => !x.states);
|
|
607
|
-
const part = (m, key) => m.one != null
|
|
608
|
-
? h('div', {key, dangerouslySetInnerHTML: {__html: m.one}})
|
|
609
|
-
: h(React.Fragment, {key}, h('div', {className: 'cs-light', dangerouslySetInnerHTML: {__html: m.light}}), h('div', {className: 'cs-dark', dangerouslySetInnerHTML: {__html: m.dark}}));
|
|
610
|
-
const bar = MODE === 'system'
|
|
611
|
-
? h('div', {className: 'cs-bar'}, h('strong', null, TITLE),
|
|
612
|
-
['auto', 'light', 'dark'].map(m => h('label', {key: m}, h('input', {type: 'radio', name: 'cs-mode', id: 'cs-' + m, defaultChecked: m === 'auto'}), ' ' + m)))
|
|
613
|
-
: h('div', {className: 'cs-bar'}, h('strong', null, TITLE), h('span', null, MODE + ' only'));
|
|
614
|
-
let body;
|
|
615
|
-
if (LAYOUT === 'page') {
|
|
616
|
-
// The page, then the overlays drawn open in a strip below it.
|
|
617
|
-
const strip = drawn.filter(it => it.strip || it.opened);
|
|
618
|
-
body = [
|
|
619
|
-
...drawn.filter(it => !it.strip && !it.opened).map((it, i) => part(it.markup, i)),
|
|
620
|
-
strip.length
|
|
621
|
-
? h('section', {key: 'strip', className: 'cs-strip'},
|
|
622
|
-
h('div', {className: 'cs-strip-name'}, 'open overlays'),
|
|
623
|
-
h('div', {className: 'cs-strip-row'}, strip.map((it, i) => h('div', {key: i, className: 'cs-strip-item'},
|
|
624
|
-
h('div', {className: 'cs-label'}, it.name),
|
|
625
|
-
part(it.markup)))))
|
|
626
|
-
: null,
|
|
627
|
-
];
|
|
628
|
-
} else {
|
|
629
|
-
const groups = sheetGroups(drawn, OPEN_GROUP);
|
|
630
|
-
body = groups.map(g => h('section', {key: g.name, className: sheetSectionClass(g.name, OPEN_GROUP)},
|
|
631
|
-
g.name ? h('h2', {className: 'cs-group-name'}, g.name) : null,
|
|
632
|
-
h('div', {className: g.name === 'pages' ? 'cs-pages' : 'cs-sheet'}, g.cells.map(c => h('div', {key: c.name, className: 'cs-cell', style: {'--cs-examples': c.list.length}},
|
|
633
|
-
h('div', {className: 'cs-name'}, c.name),
|
|
634
|
-
h('div', {className: 'cs-row'}, c.list.map((x, j) => h('div', {key: j, className: 'cs-item'},
|
|
635
|
-
x.label ? h('div', {className: 'cs-label'}, x.label) : null,
|
|
636
|
-
x.opened ? h('div', {className: 'cs-open'}, part(x.markup)) : part(x.markup)))))))));
|
|
637
|
-
// On the overlays section's own page the states come first, so its
|
|
638
|
-
// picture shows them in its first screen.
|
|
639
|
-
if (stated.length)
|
|
640
|
-
body[SECTION === 'overlays' ? 'unshift' : 'push'](h('section', {key: 'states', className: 'cs-group cs-states cs-family-states'},
|
|
641
|
-
h('h2', {className: 'cs-group-name'}, 'states'),
|
|
642
|
-
h('div', {className: 'cs-states-grid'},
|
|
643
|
-
h('div', {className: 'cs-states-row cs-states-head'}, h('div', null), STATES.map(([label]) => h('div', {key: label, className: 'cs-label'}, label))),
|
|
644
|
-
stated.map((it, i) => h('div', {key: i, className: 'cs-states-row'},
|
|
645
|
-
h('div', {className: 'cs-name'}, it.name + (it.label ? ' ' + it.label : '')),
|
|
646
|
-
it.rows.map((r, j) => h('div', {key: j, className: 'cs-states-cell'}, part(r.markup))))))));
|
|
647
|
-
}
|
|
648
|
-
const page = h('div', {className: SECTION ? 'cs-page cs-section-' + SECTION : 'cs-page', style: {background: 'var(--color-background-body)', color: 'var(--color-text-primary)', minHeight: '100vh'}}, bar, body);
|
|
649
|
-
return h('main', null, h('style', {dangerouslySetInnerHTML: {__html: SHEET_CSS}}), theme ? h(Theme, {theme, mode: MODE}, page) : page);
|
|
650
|
-
}`);
|
|
651
|
-
return `${lines.join('\n')}\n`;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/**
|
|
655
|
-
* The section a sheet puts the parts it draws open in: on one family's own
|
|
656
|
-
* page, that family's open section; on the whole sheet, the overlays.
|
|
657
|
-
* Written into the page as well (pageSource).
|
|
658
|
-
* @param {string} section the family the page is of, or ''
|
|
659
|
-
*/
|
|
660
|
-
export function openGroupOf(section) {
|
|
661
|
-
return section && section !== 'overlays' ? section + ', open' : 'overlays';
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* The sections of a sheet, in order, with their cells, from the parts it
|
|
666
|
-
* draws: by each part's group, in the order of the parts. In the overlays
|
|
667
|
-
* section the small overlays drawn open beside their triggers (a tooltip,
|
|
668
|
-
* a menu, a list) come first, a panel over the whole page (a dialog, a
|
|
669
|
-
* drawer) after them; on a family's page its parts drawn open follow it.
|
|
670
|
-
* Written into the page as well (pageSource).
|
|
671
|
-
* @param {Array<{name: string, group?: string, label?: string, opened?: boolean, open?: unknown, anchored?: boolean}>} drawn
|
|
672
|
-
* @param {string} openGroup the section of the parts drawn open
|
|
673
|
-
* @returns {Array<{name: string, cells: Array<{name: string, list: any[]}>}>}
|
|
674
|
-
*/
|
|
675
|
-
export function sheetGroups(drawn, openGroup) {
|
|
676
|
-
/** @type {Array<{name: string, cells: Array<{name: string, list: any[]}>}>} */
|
|
677
|
-
const groups = [];
|
|
678
|
-
const small = (/** @type {any} */ it) =>
|
|
679
|
-
it.opened || (it.open && it.anchored);
|
|
680
|
-
const ordered =
|
|
681
|
-
openGroup === 'overlays'
|
|
682
|
-
? [...drawn.filter(small), ...drawn.filter(it => !small(it))]
|
|
683
|
-
: [...drawn.filter(it => !it.opened), ...drawn.filter(it => it.opened)];
|
|
684
|
-
for (const it of ordered) {
|
|
685
|
-
let g = groups.find((/** @type {any} */ x) => x.name === (it.group ?? ''));
|
|
686
|
-
if (!g) {
|
|
687
|
-
g = {name: it.group ?? '', cells: []};
|
|
688
|
-
groups.push(g);
|
|
689
|
-
}
|
|
690
|
-
let c = g.cells.find((/** @type {any} */ x) => x.name === it.name);
|
|
691
|
-
if (!c) {
|
|
692
|
-
c = {name: it.name, list: []};
|
|
693
|
-
g.cells.push(c);
|
|
694
|
-
}
|
|
695
|
-
if (!c.list.some((/** @type {any} */ x) => x.label === it.label))
|
|
696
|
-
c.list.push(it);
|
|
697
|
-
}
|
|
698
|
-
return groups;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* A sheet section's class: its family's, by which the full sheet is cut
|
|
703
|
-
* into a page for each family (familyPages). Written into the page as well
|
|
704
|
-
* (pageSource).
|
|
705
|
-
* @param {string} name
|
|
706
|
-
* @param {string} openGroup
|
|
707
|
-
*/
|
|
708
|
-
export function sheetSectionClass(name, openGroup) {
|
|
709
|
-
return (
|
|
710
|
-
(name === openGroup ? 'cs-group cs-open-group' : 'cs-group') +
|
|
711
|
-
' cs-family-' +
|
|
712
|
-
name.replace(/[^a-z0-9]+/g, '-')
|
|
713
|
-
);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
/** The light and dark switches, and the contact sheet grid. */
|
|
717
|
-
export const SHEET_CSS = [
|
|
718
|
-
'body{margin:0}',
|
|
719
|
-
'.cs-bar{position:sticky;top:0;z-index:100;display:flex;gap:14px;align-items:center;padding:8px 14px;font:12px ui-monospace,monospace;background:Canvas;color:CanvasText;border-bottom:1px solid #8884}',
|
|
720
|
-
'body:has(#cs-light:checked),body:has(#cs-light:checked) [data-astryx-theme]{color-scheme:light!important}',
|
|
721
|
-
'body:has(#cs-dark:checked),body:has(#cs-dark:checked) [data-astryx-theme]{color-scheme:dark!important}',
|
|
722
|
-
// A part rendered in each mode: the render of the mode the page shows.
|
|
723
|
-
'.cs-dark{display:none}',
|
|
724
|
-
'@media (prefers-color-scheme:dark){.cs-light{display:none}.cs-dark{display:block}}',
|
|
725
|
-
'body:has(#cs-light:checked) .cs-light,body:has(#cs-dark:checked) .cs-dark{display:block!important}',
|
|
726
|
-
'body:has(#cs-light:checked) .cs-dark,body:has(#cs-dark:checked) .cs-light{display:none!important}',
|
|
727
|
-
'.cs-group-name{font:600 14px ui-monospace,monospace;margin:16px 14px 0;opacity:.75}',
|
|
728
|
-
// Cells wrap, about three to a row; a cell is never narrower than what it
|
|
729
|
-
// holds (a date input's calendar, a date range's two months), so nothing
|
|
730
|
-
// is cut at its edge:
|
|
731
|
-
// a wide part takes a row of its own.
|
|
732
|
-
'.cs-sheet{display:flex;flex-wrap:wrap;align-items:flex-start;gap:14px;padding:14px}',
|
|
733
|
-
'.cs-sheet>.cs-cell{flex:1 1 360px;min-width:min-content;max-width:100%;box-sizing:border-box}',
|
|
734
|
-
'.cs-pages{display:grid;grid-template-columns:minmax(0,1fr);gap:14px;padding:14px}',
|
|
735
|
-
// A cell is as tall as what it holds, so every variant is drawn whole.
|
|
736
|
-
// A focus ring drawn outside a part at the cell's edge shows whole: the
|
|
737
|
-
// cell clips only past a ring's reach.
|
|
738
|
-
'.cs-cell{border:1px dashed #8885;padding:10px;overflow:clip;overflow-clip-margin:8px}',
|
|
739
|
-
'.cs-pages .cs-cell{max-height:none}',
|
|
740
|
-
// A panel that fills the window (a drawer, a bottom sheet, a lightbox)
|
|
741
|
-
// takes an equal share of that height for each of its examples, so every
|
|
742
|
-
// example is drawn, never one panel filling the cell.
|
|
743
|
-
'.cs-open-group .cs-cell dialog{max-height:calc((860px - (var(--cs-examples, 1) - 1) * 34px) / var(--cs-examples, 1))!important}',
|
|
744
|
-
'.cs-name{font:600 12px ui-monospace,monospace;opacity:.6;margin-bottom:8px}',
|
|
745
|
-
'.cs-row{display:flex;flex-wrap:wrap;gap:10px;align-items:flex-start}',
|
|
746
|
-
'.cs-label{font:10px ui-monospace,monospace;opacity:.5}',
|
|
747
|
-
// An item takes a share of its row, so a part as wide as its container
|
|
748
|
-
// (a divider, a form layout) is drawn at a width, never at none.
|
|
749
|
-
'.cs-item{max-width:100%;position:relative;flex:1 1 200px;min-width:min-content}',
|
|
750
|
-
// A part that needs a row's width (a table, code, an app shell) takes the
|
|
751
|
-
// whole row of the grid, so its text is never cut or wrapped mid-word.
|
|
752
|
-
'.cs-sheet>.cs-cell:has(table,pre,.astryx-app-shell){flex-basis:100%}',
|
|
753
|
-
// A part that needs a row's width draws each variant on a row of its own,
|
|
754
|
-
// and an app shell on the sheet at a height that shows its frame, not a
|
|
755
|
-
// window's (the pages section draws the sample app whole).
|
|
756
|
-
'.cs-sheet>.cs-cell:has(table,pre,.astryx-app-shell)>.cs-row>.cs-item{flex-basis:100%}',
|
|
757
|
-
'.cs-sheet .cs-item .astryx-app-shell{height:360px!important;min-height:0!important}',
|
|
758
|
-
// A frame that draws nothing of its own (an aspect ratio) shows its box.
|
|
759
|
-
'.cs-item .astryx-aspect-ratio{outline:1px dashed #8888}',
|
|
760
|
-
// A part as tall as its container (a vertical divider) is drawn at a
|
|
761
|
-
// height, never at none.
|
|
762
|
-
'.cs-item:has([role="separator"][aria-orientation="vertical"]) [data-astryx-theme]{display:flex;height:64px}',
|
|
763
|
-
// Overlays shown open in place: a layer the page would open with script
|
|
764
|
-
// (its root alone: a hidden helper popover inside it stays hidden), and a
|
|
765
|
-
// panel over the page (a drawer, a bottom sheet, a lightbox) at the size
|
|
766
|
-
// of its cell.
|
|
767
|
-
'.cs-strip{padding:16px 14px;border-top:1px dashed #8885}',
|
|
768
|
-
'.cs-strip-name{font:600 12px ui-monospace,monospace;opacity:.6;margin-bottom:8px}',
|
|
769
|
-
'.cs-strip-row{display:flex;flex-wrap:wrap;gap:24px;align-items:flex-start}',
|
|
770
|
-
'.cs-strip-item{max-width:300px;position:relative}',
|
|
771
|
-
'.cs-strip [popover][data-astryx-layer-root]{display:block!important;position:relative!important;inset:auto!important;margin:8px 0 0!important;translate:none!important;transform:none!important}',
|
|
772
|
-
// An overlay shown in place keeps its own width (a popover that holds a
|
|
773
|
-
// form, a date input's calendar): its cell grows to hold it.
|
|
774
|
-
'.cs-cell [popover][data-astryx-layer-root]{display:block!important;position:relative!important;inset:auto!important;margin:8px 0 0!important;translate:none!important;transform:none!important;box-sizing:border-box!important}',
|
|
775
|
-
// A layer opened from inside another (a submenu's flyout) sits beside it.
|
|
776
|
-
'.cs-cell [data-astryx-layer-nest]{display:flex;align-items:flex-start;gap:4px}',
|
|
777
|
-
'.cs-cell [data-astryx-layer-nest] > [data-astryx-layer-root]{margin-top:8px!important}',
|
|
778
|
-
// A part shown for its open look that opened nothing has no cell.
|
|
779
|
-
'.cs-cell:has(.cs-open):not(:has(.cs-open [data-astryx-layer-root])){display:none}',
|
|
780
|
-
// The overlays section's own page (sheet-overlays.png): the small
|
|
781
|
-
// overlays first, about five to a row (a panel over the page, wider,
|
|
782
|
-
// about four), a panel cropped to its top at 260px.
|
|
783
|
-
'.cs-section-overlays .cs-open-group .cs-sheet>.cs-cell{flex-basis:200px}',
|
|
784
|
-
// (A panel over the page is drawn at least a fifth of the page wide, as
|
|
785
|
-
// wide as a column of five.)
|
|
786
|
-
'.cs-section-overlays .cs-open-group .cs-sheet>.cs-cell:has(dialog){flex-basis:240px}',
|
|
787
|
-
// (A part that needs a row's width keeps its row here too.)
|
|
788
|
-
'.cs-section-overlays .cs-open-group .cs-sheet>.cs-cell:has(table,pre,.astryx-app-shell){flex-basis:100%}',
|
|
789
|
-
'.cs-section-overlays .cs-open-group .cs-cell dialog{max-height:260px!important}',
|
|
790
|
-
// The states section: one row per control, one column per state.
|
|
791
|
-
'.cs-states-grid{display:grid;gap:10px;padding:14px}',
|
|
792
|
-
'.cs-states-row{display:grid;grid-template-columns:160px repeat(4,minmax(0,1fr));gap:14px;align-items:center}',
|
|
793
|
-
'.cs-states-cell{min-width:0;overflow:clip;overflow-clip-margin:8px;padding:6px}',
|
|
794
|
-
// A panel wider than its cell (a narrow screen's navigation drawer) is
|
|
795
|
-
// drawn from its start, never cut at the start.
|
|
796
|
-
// A dialog drawn in place holds its panel in place too: a panel placed
|
|
797
|
-
// over the window (a navigation drawer at the window's edge) would leave
|
|
798
|
-
// the dialog with no height, and the cell empty.
|
|
799
|
-
'.cs-cell dialog > *{max-width:100%!important;position:relative!important;inset:auto!important}',
|
|
800
|
-
'.cs-cell dialog{display:block!important;position:relative!important;inset:auto!important;margin:0!important;max-width:100%!important;max-height:300px!important;translate:none!important;transform:none!important}',
|
|
801
|
-
// A panel over the page (a bottom sheet, a lightbox, an open mobile nav)
|
|
802
|
-
// sizes itself from the window, so its cell never grows to it: the cell
|
|
803
|
-
// takes its share of the row and the panel is drawn whole at the cell's
|
|
804
|
-
// width, never past the sheet's edge.
|
|
805
|
-
'.cs-sheet>.cs-cell:has(dialog),.cs-cell:has(dialog) .cs-item{min-width:0}',
|
|
806
|
-
].join('');
|