@astryxdesign/cli 0.6.6 → 0.6.7-canary.7ec9564
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 +129 -0
- package/README.md +84 -82
- package/api/build/_adapter.d.mts +20 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.test.mjs +1 -1
- package/api/build/build.type.d.mts +12 -0
- package/api/build/build.type.mjs +3 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +13 -1
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +615 -0
- package/api/component/component.doc.mjs +5 -2
- package/api/component/component.mjs +49 -15
- package/api/component/component.test.mjs +32 -0
- package/api/component/component.type.d.mts +33 -3
- package/api/component/component.type.mjs +10 -3
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +5 -2
- package/api/component/detail/detail.mjs +5 -1
- package/api/component/detail/props/props.d.mts +2 -1
- package/api/component/detail/props/props.mjs +3 -2
- package/api/component/detail/showcase/showcase.d.mts +3 -1
- package/api/component/detail/showcase/showcase.mjs +3 -1
- package/api/component/detail/source/source.d.mts +3 -2
- package/api/component/detail/source/source.mjs +7 -3
- package/api/component/list/list.mjs +128 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +73 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +171 -14
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +38 -23
- package/api/docs/docs.depth.test.mjs +2 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +13 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/docs.type.d.mts +43 -3
- package/api/docs/docs.type.mjs +23 -3
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +8 -7
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/node/node.mjs +3 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/_adapter.d.mts +50 -0
- package/api/doctor/_adapter.mjs +190 -0
- package/api/doctor/doctor.d.mts +6 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +144 -150
- package/api/doctor/doctor.test.mjs +104 -0
- package/api/doctor/theme-checks.d.mts +24 -0
- package/api/doctor/theme-checks.mjs +1231 -0
- package/api/doctor/theme-checks.test.mjs +667 -0
- package/api/gap-report/gap-report.doc.mjs +2 -1
- package/api/gap-report/gap-report.mjs +15 -1
- package/api/hook/_adapter.d.mts +1 -0
- package/api/hook/_adapter.mjs +3 -0
- package/api/hook/detail/detail.mjs +2 -2
- package/api/hook/detail/params/params.mjs +2 -2
- package/api/hook/hook.type.d.mts +12 -0
- package/api/hook/hook.type.mjs +3 -0
- package/api/hook/list/list.mjs +8 -8
- package/api/index.d.mts +1 -1
- package/api/index.mjs +4 -0
- package/api/init/run/run.d.mts +3 -5
- package/api/init/run/run.mjs +11 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +16 -2
- package/api/integration/add-theme.test.mjs +66 -15
- package/api/integration/authoring-checks.mjs +21 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/pack-check.component-replaces.test.mjs +126 -0
- package/api/integration/pack-check.d.mts +10 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
- package/api/integration/pack-check.mjs +483 -1
- package/api/integration/pack-check.test.mjs +568 -8
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +47 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +247 -43
- package/api/search/search.test.mjs +5 -1
- package/api/search/search.type.d.mts +3 -3
- package/api/search/search.type.mjs +2 -2
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +23 -0
- package/api/swizzle/copy/copy.d.mts +5 -6
- package/api/swizzle/copy/copy.mjs +29 -10
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +5 -2
- package/api/swizzle/swizzle.test.mjs +55 -5
- package/api/swizzle/swizzle.type.d.mts +8 -0
- package/api/swizzle/swizzle.type.mjs +2 -0
- package/api/template/copy/copy.mjs +14 -1
- package/api/template/show/show.mjs +2 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +1 -0
- package/api/template/template.type.d.mts +15 -0
- package/api/template/template.type.mjs +6 -0
- package/api/theme/_adapter.d.mts +106 -6
- package/api/theme/_adapter.mjs +687 -18
- package/api/theme/add/add.binary.test.mjs +76 -3
- package/api/theme/add/add.d.mts +5 -9
- package/api/theme/add/add.mjs +87 -64
- package/api/theme/add/add.rollback.test.mjs +9 -9
- package/api/theme/add/add.staging.test.mjs +9 -9
- package/api/theme/add/add.test.mjs +461 -55
- package/api/theme/add/add.types.test.mjs +151 -0
- package/api/theme/build/build.d.mts +96 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.mjs +286 -118
- package/api/theme/build/build.test.mjs +30 -0
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/api/theme/eject/eject.binary.test.mjs +90 -0
- package/api/theme/eject/eject.d.mts +17 -0
- package/api/theme/eject/eject.mjs +65 -0
- package/api/theme/eject/eject.rollback.test.mjs +158 -0
- package/api/theme/eject/eject.staging.test.mjs +83 -0
- package/api/theme/eject/eject.test.mjs +160 -0
- package/api/theme/integration-themes.test.mjs +30 -6
- package/api/theme/list/list.d.mts +10 -0
- package/api/theme/list/list.mjs +75 -7
- package/api/theme/list/list.test.mjs +155 -4
- package/api/theme/remove/remove.d.mts +12 -0
- package/api/theme/remove/remove.mjs +15 -0
- package/api/theme/remove/remove.test.mjs +94 -0
- package/api/theme/template/template.mjs +3 -4
- package/api/theme/theme.d.mts +5 -2
- package/api/theme/theme.mjs +13 -8
- package/api/theme/theme.type.d.mts +106 -2
- package/api/theme/theme.type.mjs +54 -5
- package/api/theme/themeAdd.doc.d.mts +1 -3
- package/api/theme/themeAdd.doc.mjs +35 -22
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeEject.doc.d.mts +8 -0
- package/api/theme/themeEject.doc.mjs +89 -0
- package/api/theme/themeListAvailable.doc.mjs +4 -4
- package/api/theme/themeListCopySources.doc.d.mts +8 -0
- package/api/theme/themeListCopySources.doc.mjs +60 -0
- package/api/theme/themeRemove.doc.d.mts +6 -0
- package/api/theme/themeRemove.doc.mjs +50 -0
- package/api/theme/themeTemplate.doc.mjs +4 -3
- package/api/theme/themeUse.doc.d.mts +6 -0
- package/api/theme/themeUse.doc.mjs +47 -0
- package/api/theme/use/use.d.mts +12 -0
- package/api/theme/use/use.mjs +15 -0
- package/api/theme/use/use.test.mjs +98 -0
- package/api/upgrade/_adapter.d.mts +1 -0
- package/api/upgrade/_adapter.mjs +3 -0
- package/api/upgrade/list/list.mjs +9 -3
- package/api/upgrade/upgrade.type.d.mts +4 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/codemods/__tests__/registry.test.mjs +1 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/v0.6.7/index.mjs +23 -0
- package/assets/codemods/transforms/v0.6.7/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +166 -0
- package/assets/docs/getting-started.doc.mjs +61 -17
- package/assets/docs/principles.doc.dense.mjs +4 -4
- package/assets/docs/principles.doc.mjs +6 -6
- package/assets/docs/principles.doc.zh.mjs +4 -4
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -771
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +5 -4
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +67 -0
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +55 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/responsive.doc.mjs +98 -0
- package/assets/docs/tree/scaffold.doc.mjs +140 -0
- package/assets/docs/tree/side-panels.doc.mjs +81 -0
- package/assets/docs/tree/structure.doc.mjs +140 -0
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +4 -0
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +4 -1
- package/assets/docs/use-a-theme.doc.mjs +212 -0
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
- package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
- package/assets/templates/pages/table-comparison/page.tsx +1449 -0
- package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
- package/assets/theme.template.ts +4 -3
- package/authoring/doctypes/command/command.doc.mjs +5 -0
- package/authoring/doctypes/command/type.ts +2 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -4
- package/authoring/doctypes/template/type.ts +1 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +338 -45
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +8 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +91 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +316 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.mjs +63 -23
- package/clients/cli/commands/docs.test.mjs +17 -15
- package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +59 -52
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +28 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/layout-check.doc.mjs +2 -0
- package/clients/cli/commands/layout-expand.doc.mjs +2 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +2 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +2 -0
- package/clients/cli/commands/layout.mjs +40 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.test.mjs +10 -4
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +56 -5
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +135 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +5 -2
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
- package/clients/cli/commands/theme-remove.doc.mjs +22 -0
- package/clients/cli/commands/theme-template.doc.mjs +4 -3
- package/clients/cli/commands/theme-use.doc.mjs +22 -0
- package/clients/cli/commands/theme.doc.mjs +21 -16
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/index.mjs +5 -2
- package/clients/cli/lib/component-format.mjs +29 -2
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/clients/cli/lib/resolve-theme.mjs +80 -78
- package/clients/cli/lib/resolve-theme.test.mjs +523 -27
- package/foundation/agent-docs/agent-docs.mjs +48 -30
- package/foundation/agent-docs/agent-docs.test.mjs +47 -34
- package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
- package/foundation/config/project.d.mts +20 -5
- package/foundation/config/project.mjs +43 -6
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/config/theme-private-vars.d.mts +12 -0
- package/foundation/config/theme-private-vars.mjs +107 -0
- package/foundation/config/theme-private-vars.test.mjs +55 -0
- package/foundation/config/theme-state.d.mts +145 -0
- package/foundation/config/theme-state.mjs +417 -0
- package/foundation/config/theme-state.test.mjs +182 -0
- package/foundation/discovery/component-discovery.d.mts +5 -2
- package/foundation/discovery/component-discovery.mjs +12 -6
- package/foundation/discovery/component-replacement.d.mts +91 -0
- package/foundation/discovery/component-replacement.mjs +417 -0
- package/foundation/discovery/component-replacement.test.mjs +480 -0
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- package/foundation/discovery/docs-output-budget.d.mts +6 -2
- package/foundation/discovery/docs-output-budget.mjs +2 -1
- package/foundation/discovery/docs-section-key.d.mts +4 -2
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/module-exports.d.mts +10 -0
- package/foundation/discovery/module-exports.mjs +146 -0
- package/foundation/discovery/package-exports.d.mts +29 -0
- package/foundation/discovery/package-exports.mjs +200 -0
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/discovery/theme-discovery.d.mts +72 -5
- package/foundation/discovery/theme-discovery.mjs +134 -18
- package/foundation/discovery/theme-discovery.test.mjs +9 -3
- package/foundation/discovery/theme-imports.d.mts +15 -0
- package/foundation/discovery/theme-imports.mjs +217 -0
- package/foundation/discovery/theme-imports.test.mjs +173 -0
- package/foundation/doc-compiler/bundle.mjs +52 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +15 -5
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +22 -0
- package/foundation/integrations/cli-requirement.mjs +31 -0
- package/foundation/integrations/cli-requirement.test.mjs +70 -0
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- package/foundation/response/base.d.ts +9 -3
- package/foundation/response/json.d.mts +7 -4
- package/foundation/response/json.mjs +10 -6
- package/foundation/response/response-types.doc.mjs +41 -26
- package/foundation/response/response.doc.mjs +18 -4
- package/foundation/text/copyright-header.mjs +1 -1
- package/foundation/text/copyright-header.test.mjs +1 -1
- package/package.json +9 -9
- package/assets/docs/layout.doc.dense.mjs +0 -388
- package/assets/docs/layout.doc.mjs +0 -550
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
|
@@ -0,0 +1,1474 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Four kinds of financial account on one page, each in a collapsible Card with
|
|
7
|
+
* a table of its own — because a credit card and a checking account do not
|
|
8
|
+
* share a column grid.
|
|
9
|
+
*
|
|
10
|
+
* This is the grouping shape for heterogeneous records. `useTableGroupedRows`
|
|
11
|
+
* is the right tool when every group is the same kind of thing and grouping is
|
|
12
|
+
* just a sort you can collapse: issues by status, orders by month, rows by
|
|
13
|
+
* owner. One table, one header, section rows in between. It is the wrong tool
|
|
14
|
+
* the moment the groups stop agreeing on what the columns mean. Utilization is
|
|
15
|
+
* a credit-card idea, pending payout is a processor idea, and cost basis is an
|
|
16
|
+
* investment idea; forcing all three into one grid produces a table that is
|
|
17
|
+
* mostly em-dashes, with a header row that is true of no row beneath it.
|
|
18
|
+
*
|
|
19
|
+
* So each group owns a table. The Card supplies the boundary the shared header
|
|
20
|
+
* row used to supply, and the Collapsible trigger carries the group's name,
|
|
21
|
+
* count, and running total, so a collapsed group still answers the question
|
|
22
|
+
* most people came for.
|
|
23
|
+
*
|
|
24
|
+
* The `table-grouped` template is the other half of this pair: one collection
|
|
25
|
+
* of like rows, split into collapsible sections that all share a column set.
|
|
26
|
+
* Reach for that one when the rows agree and this one when they do not.
|
|
27
|
+
*
|
|
28
|
+
* ## Extending this template
|
|
29
|
+
*
|
|
30
|
+
* **The test for splitting is column divergence, not group count.** Two groups
|
|
31
|
+
* with different columns belong in separate tables; twelve groups with
|
|
32
|
+
* identical columns belong in one table with the plugin. If you find yourself
|
|
33
|
+
* adding a column that only applies to some groups and writing a fallback dash
|
|
34
|
+
* for the rest, that is the signal to split. Conversely, if these four tables
|
|
35
|
+
* ever converge on the same columns, collapse them back — this layout costs a
|
|
36
|
+
* Card and a header per group, and that is only worth paying for real
|
|
37
|
+
* structural difference.
|
|
38
|
+
*
|
|
39
|
+
* **Each table is data-driven, and that is the payoff.** Because the groups are
|
|
40
|
+
* separate tables, every one of them can use `data` + `columns` with
|
|
41
|
+
* `renderCell`, which is the RSC-friendly path and the one that gets headers,
|
|
42
|
+
* widths, and plugins for free. The single-table version of this page has to
|
|
43
|
+
* drop to children mode to emit section rows, and loses all of that.
|
|
44
|
+
*
|
|
45
|
+
* **What the four tables do share, they share by position.** Every table runs
|
|
46
|
+
* name → qualifier → figures → change, on the same column widths, so the eye
|
|
47
|
+
* can travel straight down the page across four different schemas. That is the
|
|
48
|
+
* whole reason Utilization sits ahead of Balance rather than after it.
|
|
49
|
+
*
|
|
50
|
+
* **The trigger is a button, so it holds no buttons.** Group name, count, and
|
|
51
|
+
* total are text and icons only. Per-account actions live in the rows, and
|
|
52
|
+
* anything that acts on a whole group belongs in the page header rather than
|
|
53
|
+
* inside the trigger — nesting a control inside the trigger makes the click
|
|
54
|
+
* target ambiguous and is invalid HTML besides.
|
|
55
|
+
*
|
|
56
|
+
* **Open state is controlled, not `defaultIsOpen`.** The page owns a Set of
|
|
57
|
+
* open group ids, which is what lets Expand all / Collapse all work and what
|
|
58
|
+
* you would persist per user. Uncontrolled Collapsibles are fine for a static
|
|
59
|
+
* FAQ; they cannot participate in a page-level control.
|
|
60
|
+
*
|
|
61
|
+
* **Money is stored in cents.** Every amount is an integer and only the display
|
|
62
|
+
* step formats, so group totals and the header's net position stay exact. Net
|
|
63
|
+
* position deliberately subtracts card balances — it is a derived figure, never
|
|
64
|
+
* a stored one, so adding an account updates it with no other edit.
|
|
65
|
+
*
|
|
66
|
+
* **One time range drives the whole page.** The selector under the chart is
|
|
67
|
+
* page state, not chart state: the Change column, every detail chart, and the
|
|
68
|
+
* header's delta all read it from context. A page where the chart says "3M"
|
|
69
|
+
* and the table says something else is a page with two different answers to
|
|
70
|
+
* the same question.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
import {
|
|
74
|
+
createContext,
|
|
75
|
+
useContext,
|
|
76
|
+
useEffect,
|
|
77
|
+
useLayoutEffect,
|
|
78
|
+
useMemo,
|
|
79
|
+
useRef,
|
|
80
|
+
useState,
|
|
81
|
+
} from 'react';
|
|
82
|
+
import * as stylex from '@stylexjs/stylex';
|
|
83
|
+
import {
|
|
84
|
+
Area,
|
|
85
|
+
AreaChart,
|
|
86
|
+
ReferenceLine,
|
|
87
|
+
ResponsiveContainer,
|
|
88
|
+
Tooltip,
|
|
89
|
+
XAxis,
|
|
90
|
+
YAxis,
|
|
91
|
+
} from 'recharts';
|
|
92
|
+
|
|
93
|
+
import {
|
|
94
|
+
HStack,
|
|
95
|
+
Layout,
|
|
96
|
+
LayoutContent,
|
|
97
|
+
LayoutHeader,
|
|
98
|
+
StackItem,
|
|
99
|
+
VStack,
|
|
100
|
+
} from '@astryxdesign/core/Layout';
|
|
101
|
+
import {colorVars, radiusVars} from '@astryxdesign/core/theme/tokens.stylex';
|
|
102
|
+
import {Heading, Text} from '@astryxdesign/core/Text';
|
|
103
|
+
import {Badge} from '@astryxdesign/core/Badge';
|
|
104
|
+
import {Button} from '@astryxdesign/core/Button';
|
|
105
|
+
import {Card} from '@astryxdesign/core/Card';
|
|
106
|
+
import {Collapsible} from '@astryxdesign/core/Collapsible';
|
|
107
|
+
import {Icon} from '@astryxdesign/core/Icon';
|
|
108
|
+
import {ProgressBar} from '@astryxdesign/core/ProgressBar';
|
|
109
|
+
import {Skeleton} from '@astryxdesign/core/Skeleton';
|
|
110
|
+
import {
|
|
111
|
+
SegmentedControl,
|
|
112
|
+
SegmentedControlItem,
|
|
113
|
+
} from '@astryxdesign/core/SegmentedControl';
|
|
114
|
+
import {Token} from '@astryxdesign/core/Token';
|
|
115
|
+
import {
|
|
116
|
+
Table,
|
|
117
|
+
pixel,
|
|
118
|
+
proportional,
|
|
119
|
+
useTableRowExpansion,
|
|
120
|
+
useTableSortable,
|
|
121
|
+
useTableSortableState,
|
|
122
|
+
} from '@astryxdesign/core/Table';
|
|
123
|
+
import type {TableColumn, TableSortComparator} from '@astryxdesign/core/Table';
|
|
124
|
+
import {
|
|
125
|
+
ArrowsRightLeftIcon,
|
|
126
|
+
BuildingLibraryIcon,
|
|
127
|
+
CreditCardIcon,
|
|
128
|
+
PresentationChartLineIcon,
|
|
129
|
+
} from '@heroicons/react/24/outline';
|
|
130
|
+
|
|
131
|
+
// ============= SHARED VOCABULARY =============
|
|
132
|
+
|
|
133
|
+
/** Everything the page-level machinery needs from a row, whatever group it is
|
|
134
|
+
* in: an id to key its history by, and the drift that history follows. */
|
|
135
|
+
interface AccountRecord extends Record<string, unknown> {
|
|
136
|
+
id: string;
|
|
137
|
+
/** Direction and strength of the account's drift, as a daily fraction. Feeds
|
|
138
|
+
* the generated history, so an account's chart and its Change agree. */
|
|
139
|
+
trend: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Pinned locale keeps the rendered output identical in every environment.
|
|
143
|
+
const currency = new Intl.NumberFormat('en-US', {
|
|
144
|
+
style: 'currency',
|
|
145
|
+
currency: 'USD',
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
function money(cents: number): string {
|
|
149
|
+
return currency.format(cents / 100);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function sum<T>(rows: T[], pick: (row: T) => number): number {
|
|
153
|
+
return rows.reduce((total, row) => total + pick(row), 0);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Every numeric cell on the page. Alignment is deliberately not its job: the
|
|
158
|
+
* column's `align: 'end'` puts a `text-align` on the `<th>` as well as the
|
|
159
|
+
* `<td>`, so the header travels with its figures instead of hugging the far
|
|
160
|
+
* side of them. Doing it in the cell would right-align the numbers and leave
|
|
161
|
+
* the header behind. All this adds is tabular digits, so a column of money
|
|
162
|
+
* lines up digit for digit.
|
|
163
|
+
*
|
|
164
|
+
* There is no muted variant. A figure in a table is a value, and values are
|
|
165
|
+
* primary text — the de-emphasis that used to sit on the comparison columns
|
|
166
|
+
* made them read as annotations on the column beside them rather than as
|
|
167
|
+
* numbers in their own right.
|
|
168
|
+
*/
|
|
169
|
+
function Figure({children}: {children: string}) {
|
|
170
|
+
return <Text hasTabularNumbers>{children}</Text>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ============= TIME RANGE =============
|
|
174
|
+
|
|
175
|
+
const RANGE_IDS = ['1W', '1M', '3M', 'YTD', '1Y'] as const;
|
|
176
|
+
type RangeId = (typeof RANGE_IDS)[number];
|
|
177
|
+
|
|
178
|
+
/** Pinned so the generated series, the axis labels and the "as of" dates are
|
|
179
|
+
* the same on every render and in every environment. */
|
|
180
|
+
const TODAY = Date.UTC(2025, 8, 30);
|
|
181
|
+
|
|
182
|
+
const RANGE_DAYS: Record<RangeId, number> = {
|
|
183
|
+
'1W': 7,
|
|
184
|
+
'1M': 30,
|
|
185
|
+
'3M': 90,
|
|
186
|
+
// Days elapsed in the pinned year, so YTD means what it says on this date.
|
|
187
|
+
YTD: 273,
|
|
188
|
+
'1Y': 365,
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The selected window, read by the Change column and by every detail chart.
|
|
193
|
+
* Context rather than prop-drilling because the readers are cells — four
|
|
194
|
+
* column definitions deep, in four separate tables, none of which the page
|
|
195
|
+
* renders directly.
|
|
196
|
+
*/
|
|
197
|
+
const RangeContext = createContext<RangeId>('YTD');
|
|
198
|
+
const useRange = () => useContext(RangeContext);
|
|
199
|
+
|
|
200
|
+
const SERIES_DAYS = RANGE_DAYS['1Y'];
|
|
201
|
+
|
|
202
|
+
const dayFormat = new Intl.DateTimeFormat('en-US', {
|
|
203
|
+
month: 'short',
|
|
204
|
+
day: 'numeric',
|
|
205
|
+
timeZone: 'UTC',
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
function dayLabel(daysAgo: number): string {
|
|
209
|
+
const date = new Date(TODAY);
|
|
210
|
+
date.setUTCDate(date.getUTCDate() - daysAgo);
|
|
211
|
+
return dayFormat.format(date);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** FNV-1a over the account id, so each account's walk is its own but stable. */
|
|
215
|
+
function seedFrom(id: string): number {
|
|
216
|
+
let hash = 2166136261;
|
|
217
|
+
for (let index = 0; index < id.length; index++) {
|
|
218
|
+
hash ^= id.charCodeAt(index);
|
|
219
|
+
hash = Math.imul(hash, 16777619);
|
|
220
|
+
}
|
|
221
|
+
return hash >>> 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* A year of daily values ending at the account's current figure.
|
|
226
|
+
*
|
|
227
|
+
* Built backwards from today so the last point is always the real number on
|
|
228
|
+
* the row — the alternative is a series that drifts to something close to it
|
|
229
|
+
* and a table that disagrees with its own chart. xorshift rather than
|
|
230
|
+
* `Math.random` because a template that renders differently on the server and
|
|
231
|
+
* the client is a hydration error waiting to happen.
|
|
232
|
+
*/
|
|
233
|
+
function historyFor<T extends AccountRecord>(
|
|
234
|
+
rows: T[],
|
|
235
|
+
pick: (row: T) => number,
|
|
236
|
+
volatility: number,
|
|
237
|
+
): Array<[string, number[]]> {
|
|
238
|
+
return rows.map(row => {
|
|
239
|
+
let state = seedFrom(row.id) || 1;
|
|
240
|
+
const random = () => {
|
|
241
|
+
state ^= state << 13;
|
|
242
|
+
state ^= state >>> 17;
|
|
243
|
+
state ^= state << 5;
|
|
244
|
+
return ((state >>> 0) % 10000) / 10000 - 0.5;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
const series = new Array<number>(SERIES_DAYS);
|
|
248
|
+
let value = pick(row);
|
|
249
|
+
series[SERIES_DAYS - 1] = value;
|
|
250
|
+
for (let day = SERIES_DAYS - 2; day >= 0; day--) {
|
|
251
|
+
value /= 1 + row.trend + random() * volatility;
|
|
252
|
+
series[day] = Math.max(1, Math.round(value));
|
|
253
|
+
}
|
|
254
|
+
return [row.id, series];
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function windowOf(id: string, range: RangeId): number[] {
|
|
259
|
+
return HISTORY[id].slice(-RANGE_DAYS[range]);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The Change column is a percentage, not an amount. Four groups whose headline
|
|
264
|
+
* figures span two orders of magnitude cannot be compared in dollars — a
|
|
265
|
+
* $5,000 move is most of a vendor card and a rounding error on the treasury
|
|
266
|
+
* sweep. A percentage is the one form of "how much did this move" that means
|
|
267
|
+
* the same thing in every one of these tables, which is what makes it worth a
|
|
268
|
+
* column in all four.
|
|
269
|
+
*/
|
|
270
|
+
function changePercentOf(id: string, range: RangeId): number {
|
|
271
|
+
const points = windowOf(id, range);
|
|
272
|
+
const start = points[0];
|
|
273
|
+
if (start === 0) {
|
|
274
|
+
return 0;
|
|
275
|
+
}
|
|
276
|
+
return ((points[points.length - 1] - start) / Math.abs(start)) * 100;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const percentFormat = new Intl.NumberFormat('en-US', {
|
|
280
|
+
minimumFractionDigits: 1,
|
|
281
|
+
maximumFractionDigits: 1,
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// ============= CHART VOCABULARY =============
|
|
285
|
+
|
|
286
|
+
const UP_COLOR = 'var(--color-data-categorical-green, #0B991F)';
|
|
287
|
+
const DOWN_COLOR = 'var(--color-data-categorical-red, #F5394F)';
|
|
288
|
+
const GRID_COLOR = 'var(--color-border, rgba(5, 54, 89, 0.1))';
|
|
289
|
+
// Text tokens rather than the categorical pair the charts stroke with: these
|
|
290
|
+
// carry text contrast, which a 12px label needs and a 1.5px line does not.
|
|
291
|
+
const TEXT_UP_COLOR = 'var(--color-text-green, #0B991F)';
|
|
292
|
+
const TEXT_DOWN_COLOR = 'var(--color-text-red, #F5394F)';
|
|
293
|
+
const AXIS_TICK = {
|
|
294
|
+
fontSize: 'var(--font-size-sm, 12px)',
|
|
295
|
+
fill: 'var(--color-text-secondary, #4E606F)',
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
/** Tooltips and readouts have no room for cents. */
|
|
299
|
+
const wholeCurrency = new Intl.NumberFormat('en-US', {
|
|
300
|
+
style: 'currency',
|
|
301
|
+
currency: 'USD',
|
|
302
|
+
maximumFractionDigits: 0,
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
/** Five evenly spaced dates, whether the window is a week or a year. */
|
|
306
|
+
function axisTicks(count: number): number[] {
|
|
307
|
+
const stops = Math.min(5, count);
|
|
308
|
+
if (stops < 2) {
|
|
309
|
+
return [0];
|
|
310
|
+
}
|
|
311
|
+
return Array.from({length: stops}, (_, stop) =>
|
|
312
|
+
Math.round((stop * (count - 1)) / (stops - 1)),
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* The width of the box the cards are laid out in, tracked as it changes.
|
|
318
|
+
*
|
|
319
|
+
* A media query answers a question about the window, and this template is not
|
|
320
|
+
* always the window: the docsite preview puts it in a dialog and the catalog
|
|
321
|
+
* draws it through `scale(0.5)`. Both leave `matchMedia` describing a viewport
|
|
322
|
+
* the cards cannot see. `@container` asks the right question, but its answer
|
|
323
|
+
* never leaves CSS and what changes here is the column *list*, which only
|
|
324
|
+
* React can do — so the box is measured.
|
|
325
|
+
*
|
|
326
|
+
* `offsetWidth` for the first read rather than `getBoundingClientRect`: the
|
|
327
|
+
* observer reports the box as laid out and ignores an ancestor transform,
|
|
328
|
+
* while the rect bakes it in, so mixing the two under the catalog's scale
|
|
329
|
+
* opens at half the real width and corrects an instant later.
|
|
330
|
+
*/
|
|
331
|
+
function useSurfaceWidth() {
|
|
332
|
+
const ref = useRef<HTMLElement>(null);
|
|
333
|
+
const [width, setWidth] = useState(0);
|
|
334
|
+
|
|
335
|
+
useLayoutEffect(() => {
|
|
336
|
+
const node = ref.current;
|
|
337
|
+
if (!node) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
setWidth(node.offsetWidth);
|
|
341
|
+
|
|
342
|
+
const observer = new ResizeObserver(entries => {
|
|
343
|
+
const entry = entries[0];
|
|
344
|
+
if (entry) {
|
|
345
|
+
setWidth(entry.contentRect.width);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
observer.observe(node);
|
|
349
|
+
return () => observer.disconnect();
|
|
350
|
+
}, []);
|
|
351
|
+
|
|
352
|
+
return [ref, width] as const;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Below this the widest table — credit cards, carrying three money columns
|
|
357
|
+
* and a change — has less room than its fixed widths ask for, and every table
|
|
358
|
+
* switches together so the four cards stay legible as one page rather than
|
|
359
|
+
* four differently-shaped ones.
|
|
360
|
+
*/
|
|
361
|
+
const COMPACT_BELOW_PX = 720;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Every column the compact layout drops, folded into the one that survives:
|
|
365
|
+
* the figure the group is headlined by, and beneath it the direction and size
|
|
366
|
+
* of its move. The arrow states the sign that the colour also states, so the
|
|
367
|
+
* cell still reads where the colour does not.
|
|
368
|
+
*/
|
|
369
|
+
function CompactValueCell({
|
|
370
|
+
id,
|
|
371
|
+
amountCents,
|
|
372
|
+
isLiability,
|
|
373
|
+
}: {
|
|
374
|
+
id: string;
|
|
375
|
+
amountCents: number;
|
|
376
|
+
isLiability?: boolean;
|
|
377
|
+
}) {
|
|
378
|
+
const range = useRange();
|
|
379
|
+
const percent = changePercentOf(id, range);
|
|
380
|
+
const isUp = percent >= 0;
|
|
381
|
+
const isGood = isLiability ? !isUp : isUp;
|
|
382
|
+
return (
|
|
383
|
+
<VStack gap={0} hAlign="end">
|
|
384
|
+
<Figure>{money(amountCents)}</Figure>
|
|
385
|
+
{/* Colour on the row so the icon and the figure inherit one value,
|
|
386
|
+
rather than being told the same thing twice — Text has no success
|
|
387
|
+
or error of its own to be told with. */}
|
|
388
|
+
<HStack
|
|
389
|
+
gap={0.5}
|
|
390
|
+
vAlign="center"
|
|
391
|
+
xstyle={styles.delta(isGood ? TEXT_UP_COLOR : TEXT_DOWN_COLOR)}>
|
|
392
|
+
<Icon
|
|
393
|
+
icon={isUp ? 'arrowUp' : 'arrowDown'}
|
|
394
|
+
size="xsm"
|
|
395
|
+
color="inherit"
|
|
396
|
+
/>
|
|
397
|
+
<Text type="supporting" color="inherit">
|
|
398
|
+
{percentFormat.format(Math.abs(percent))}%
|
|
399
|
+
</Text>
|
|
400
|
+
</HStack>
|
|
401
|
+
</VStack>
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function ChangeCell({id, isLiability}: {id: string; isLiability?: boolean}) {
|
|
406
|
+
const range = useRange();
|
|
407
|
+
const percent = changePercentOf(id, range);
|
|
408
|
+
const isUp = percent >= 0;
|
|
409
|
+
const isGood = isLiability ? !isUp : isUp;
|
|
410
|
+
return (
|
|
411
|
+
// A Token is a flex box and fills the cell, so `text-align` from the
|
|
412
|
+
// column's align cannot place it — the row does that here instead.
|
|
413
|
+
<HStack hAlign="end">
|
|
414
|
+
<Token
|
|
415
|
+
size="sm"
|
|
416
|
+
color={isGood ? 'green' : 'red'}
|
|
417
|
+
label={`${isUp ? '+' : '−'}${percentFormat.format(Math.abs(percent))}%`}
|
|
418
|
+
/>
|
|
419
|
+
</HStack>
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// ============= GROUP 1 — BANK ACCOUNTS =============
|
|
424
|
+
|
|
425
|
+
interface BankAccount extends AccountRecord {
|
|
426
|
+
name: string;
|
|
427
|
+
institution: string;
|
|
428
|
+
mask: string;
|
|
429
|
+
kind: 'Checking' | 'Savings' | 'Money market';
|
|
430
|
+
availableCents: number;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const BANK_ACCOUNTS: BankAccount[] = [
|
|
434
|
+
{
|
|
435
|
+
id: 'bank-1',
|
|
436
|
+
name: 'Operating',
|
|
437
|
+
institution: 'First Meridian Bank',
|
|
438
|
+
mask: '••4417',
|
|
439
|
+
kind: 'Checking',
|
|
440
|
+
availableCents: 84_215_600,
|
|
441
|
+
trend: 0.00022,
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
id: 'bank-2',
|
|
445
|
+
name: 'Payroll',
|
|
446
|
+
institution: 'First Meridian Bank',
|
|
447
|
+
mask: '••8830',
|
|
448
|
+
kind: 'Checking',
|
|
449
|
+
availableCents: 21_940_800,
|
|
450
|
+
trend: 0.00004,
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
id: 'bank-3',
|
|
454
|
+
name: 'Tax reserve',
|
|
455
|
+
institution: 'Harborline Credit Union',
|
|
456
|
+
mask: '••1265',
|
|
457
|
+
kind: 'Savings',
|
|
458
|
+
availableCents: 47_500_000,
|
|
459
|
+
trend: 0.00009,
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
id: 'bank-4',
|
|
463
|
+
name: 'Treasury sweep',
|
|
464
|
+
institution: 'Northgate Financial',
|
|
465
|
+
mask: '••7702',
|
|
466
|
+
kind: 'Money market',
|
|
467
|
+
availableCents: 132_800_000,
|
|
468
|
+
trend: 0.00033,
|
|
469
|
+
},
|
|
470
|
+
];
|
|
471
|
+
|
|
472
|
+
const bankColumns: TableColumn<BankAccount>[] = [
|
|
473
|
+
{
|
|
474
|
+
key: 'name',
|
|
475
|
+
sortable: true,
|
|
476
|
+
header: 'Account',
|
|
477
|
+
width: proportional(2),
|
|
478
|
+
renderCell: account => (
|
|
479
|
+
<VStack gap={0}>
|
|
480
|
+
<Text>{account.name}</Text>
|
|
481
|
+
<Text type="supporting">
|
|
482
|
+
{account.institution} · {account.mask}
|
|
483
|
+
</Text>
|
|
484
|
+
</VStack>
|
|
485
|
+
),
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
key: 'kind',
|
|
489
|
+
sortable: true,
|
|
490
|
+
header: 'Type',
|
|
491
|
+
width: pixel(150),
|
|
492
|
+
renderCell: account => <Text>{account.kind}</Text>,
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
key: 'available',
|
|
496
|
+
sortable: true,
|
|
497
|
+
header: 'Available',
|
|
498
|
+
width: pixel(150),
|
|
499
|
+
align: 'end',
|
|
500
|
+
renderCell: account => <Figure>{money(account.availableCents)}</Figure>,
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
key: 'change',
|
|
504
|
+
sortable: true,
|
|
505
|
+
header: 'Change',
|
|
506
|
+
width: pixel(110),
|
|
507
|
+
align: 'end',
|
|
508
|
+
renderCell: account => <ChangeCell id={account.id} />,
|
|
509
|
+
},
|
|
510
|
+
];
|
|
511
|
+
|
|
512
|
+
// The name cell is reused rather than restated, so the two layouts cannot
|
|
513
|
+
// drift apart in the one column they share.
|
|
514
|
+
const bankCompactColumns: TableColumn<BankAccount>[] = [
|
|
515
|
+
bankColumns[0],
|
|
516
|
+
{
|
|
517
|
+
key: 'available',
|
|
518
|
+
sortable: true,
|
|
519
|
+
header: 'Available',
|
|
520
|
+
width: pixel(150),
|
|
521
|
+
align: 'end',
|
|
522
|
+
renderCell: account => (
|
|
523
|
+
<CompactValueCell id={account.id} amountCents={account.availableCents} />
|
|
524
|
+
),
|
|
525
|
+
},
|
|
526
|
+
];
|
|
527
|
+
|
|
528
|
+
const bankComparators: Partial<
|
|
529
|
+
Record<string, TableSortComparator<BankAccount>>
|
|
530
|
+
> = {
|
|
531
|
+
name: (a, b) => a.name.localeCompare(b.name),
|
|
532
|
+
kind: (a, b) => a.kind.localeCompare(b.kind),
|
|
533
|
+
available: (a, b) => a.availableCents - b.availableCents,
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
// ============= GROUP 2 — CREDIT CARDS =============
|
|
537
|
+
|
|
538
|
+
interface CreditCardAccount extends AccountRecord {
|
|
539
|
+
name: string;
|
|
540
|
+
issuer: string;
|
|
541
|
+
mask: string;
|
|
542
|
+
balanceCents: number;
|
|
543
|
+
limitCents: number;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
const CREDIT_CARDS: CreditCardAccount[] = [
|
|
547
|
+
{
|
|
548
|
+
id: 'card-1',
|
|
549
|
+
name: 'Corporate — Engineering',
|
|
550
|
+
issuer: 'Meridian Business Card',
|
|
551
|
+
mask: '••2041',
|
|
552
|
+
balanceCents: 4_182_300,
|
|
553
|
+
limitCents: 15_000_000,
|
|
554
|
+
trend: 0.00042,
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
id: 'card-2',
|
|
558
|
+
name: 'Corporate — Travel',
|
|
559
|
+
issuer: 'Meridian Business Card',
|
|
560
|
+
mask: '••6688',
|
|
561
|
+
balanceCents: 9_640_500,
|
|
562
|
+
limitCents: 12_000_000,
|
|
563
|
+
trend: 0.00071,
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
id: 'card-3',
|
|
567
|
+
name: 'Vendor payments',
|
|
568
|
+
issuer: 'Northgate Commercial',
|
|
569
|
+
mask: '••3319',
|
|
570
|
+
balanceCents: 1_205_000,
|
|
571
|
+
limitCents: 25_000_000,
|
|
572
|
+
trend: -0.00018,
|
|
573
|
+
},
|
|
574
|
+
];
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Bar and reading on one line, because they are one fact. ProgressBar's own
|
|
578
|
+
* `hasValueLabel` stacks the number above the track, which costs a second row
|
|
579
|
+
* in every card row and leaves the widest column on the page mostly empty; the
|
|
580
|
+
* component's guidance is to compose the reading alongside instead.
|
|
581
|
+
*
|
|
582
|
+
* Neutral, and neutral for all three. Colour-coding utilization turns a
|
|
583
|
+
* measurement into a verdict, and the thresholds that verdict needs are a
|
|
584
|
+
* policy this page does not have — 80% on a card kept deliberately near its
|
|
585
|
+
* limit is not the same event as 80% on one that is usually idle. Neutral over
|
|
586
|
+
* accent for the same reason one step further on: the accent is the page's
|
|
587
|
+
* emphasis colour, and there is nothing here to emphasise. The number is right
|
|
588
|
+
* beside the bar.
|
|
589
|
+
*/
|
|
590
|
+
function UtilizationCell({card}: {card: CreditCardAccount}) {
|
|
591
|
+
const percent = Math.round((card.balanceCents / card.limitCents) * 100);
|
|
592
|
+
return (
|
|
593
|
+
<HStack gap={2} vAlign="center">
|
|
594
|
+
<StackItem size="fill">
|
|
595
|
+
<ProgressBar
|
|
596
|
+
label={`${card.name} utilization`}
|
|
597
|
+
isLabelHidden
|
|
598
|
+
value={percent}
|
|
599
|
+
variant="neutral"
|
|
600
|
+
/>
|
|
601
|
+
</StackItem>
|
|
602
|
+
<Text hasTabularNumbers>{percent}%</Text>
|
|
603
|
+
</HStack>
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
const creditCardColumns: TableColumn<CreditCardAccount>[] = [
|
|
608
|
+
{
|
|
609
|
+
key: 'name',
|
|
610
|
+
sortable: true,
|
|
611
|
+
header: 'Card',
|
|
612
|
+
width: proportional(2),
|
|
613
|
+
renderCell: card => (
|
|
614
|
+
<VStack gap={0}>
|
|
615
|
+
<Text>{card.name}</Text>
|
|
616
|
+
<Text type="supporting">
|
|
617
|
+
{card.issuer} · {card.mask}
|
|
618
|
+
</Text>
|
|
619
|
+
</VStack>
|
|
620
|
+
),
|
|
621
|
+
},
|
|
622
|
+
// Utilization sits where every other group puts its qualifier — bank's type,
|
|
623
|
+
// the processor's merchant id — so the money columns start at the same place
|
|
624
|
+
// in all four tables and the eye can run straight down the page.
|
|
625
|
+
{
|
|
626
|
+
key: 'utilization',
|
|
627
|
+
sortable: true,
|
|
628
|
+
header: 'Utilization',
|
|
629
|
+
width: pixel(150),
|
|
630
|
+
renderCell: card => <UtilizationCell card={card} />,
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
key: 'balance',
|
|
634
|
+
sortable: true,
|
|
635
|
+
header: 'Balance',
|
|
636
|
+
width: pixel(150),
|
|
637
|
+
align: 'end',
|
|
638
|
+
renderCell: card => <Figure>{money(card.balanceCents)}</Figure>,
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
key: 'limit',
|
|
642
|
+
sortable: true,
|
|
643
|
+
header: 'Limit',
|
|
644
|
+
width: pixel(150),
|
|
645
|
+
align: 'end',
|
|
646
|
+
renderCell: card => <Figure>{money(card.limitCents)}</Figure>,
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
key: 'change',
|
|
650
|
+
sortable: true,
|
|
651
|
+
header: 'Change',
|
|
652
|
+
width: pixel(110),
|
|
653
|
+
align: 'end',
|
|
654
|
+
// The only group whose Change column is read inversely: a balance that
|
|
655
|
+
// grew is a debt that grew.
|
|
656
|
+
renderCell: card => <ChangeCell id={card.id} isLiability />,
|
|
657
|
+
},
|
|
658
|
+
];
|
|
659
|
+
|
|
660
|
+
const creditCardCompactColumns: TableColumn<CreditCardAccount>[] = [
|
|
661
|
+
creditCardColumns[0],
|
|
662
|
+
{
|
|
663
|
+
key: 'balance',
|
|
664
|
+
sortable: true,
|
|
665
|
+
header: 'Balance',
|
|
666
|
+
width: pixel(150),
|
|
667
|
+
align: 'end',
|
|
668
|
+
renderCell: card => (
|
|
669
|
+
<CompactValueCell
|
|
670
|
+
id={card.id}
|
|
671
|
+
amountCents={card.balanceCents}
|
|
672
|
+
isLiability
|
|
673
|
+
/>
|
|
674
|
+
),
|
|
675
|
+
},
|
|
676
|
+
];
|
|
677
|
+
|
|
678
|
+
const creditCardComparators: Partial<
|
|
679
|
+
Record<string, TableSortComparator<CreditCardAccount>>
|
|
680
|
+
> = {
|
|
681
|
+
name: (a, b) => a.name.localeCompare(b.name),
|
|
682
|
+
// Utilization is a ratio, not a balance — sorting it by balance would put a
|
|
683
|
+
// maxed-out small card below a barely-touched large one.
|
|
684
|
+
utilization: (a, b) =>
|
|
685
|
+
a.balanceCents / a.limitCents - b.balanceCents / b.limitCents,
|
|
686
|
+
balance: (a, b) => a.balanceCents - b.balanceCents,
|
|
687
|
+
limit: (a, b) => a.limitCents - b.limitCents,
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
// ============= GROUP 3 — PAYMENT PROCESSORS =============
|
|
691
|
+
|
|
692
|
+
interface ProcessorAccount extends AccountRecord {
|
|
693
|
+
name: string;
|
|
694
|
+
merchantId: string;
|
|
695
|
+
pendingPayoutCents: number;
|
|
696
|
+
feesMtdCents: number;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
const PROCESSORS: ProcessorAccount[] = [
|
|
700
|
+
{
|
|
701
|
+
id: 'proc-1',
|
|
702
|
+
name: 'Stripe',
|
|
703
|
+
merchantId: 'acct_1Qf82LmR',
|
|
704
|
+
pendingPayoutCents: 18_442_900,
|
|
705
|
+
feesMtdCents: 612_400,
|
|
706
|
+
trend: 0.00058,
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
id: 'proc-2',
|
|
710
|
+
name: 'PayPal Commerce',
|
|
711
|
+
merchantId: 'MRC-88214-XT',
|
|
712
|
+
pendingPayoutCents: 3_218_650,
|
|
713
|
+
feesMtdCents: 148_900,
|
|
714
|
+
trend: -0.00024,
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
id: 'proc-3',
|
|
718
|
+
name: 'Adyen',
|
|
719
|
+
merchantId: 'AD-NORTHWIND-01',
|
|
720
|
+
pendingPayoutCents: 7_905_100,
|
|
721
|
+
feesMtdCents: 233_050,
|
|
722
|
+
trend: 0.00031,
|
|
723
|
+
},
|
|
724
|
+
];
|
|
725
|
+
|
|
726
|
+
const processorColumns: TableColumn<ProcessorAccount>[] = [
|
|
727
|
+
{
|
|
728
|
+
key: 'name',
|
|
729
|
+
sortable: true,
|
|
730
|
+
header: 'Processor',
|
|
731
|
+
width: proportional(2),
|
|
732
|
+
renderCell: processor => (
|
|
733
|
+
<VStack gap={0}>
|
|
734
|
+
<Text>{processor.name}</Text>
|
|
735
|
+
<Text type="supporting">{processor.merchantId}</Text>
|
|
736
|
+
</VStack>
|
|
737
|
+
),
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
key: 'pendingPayout',
|
|
741
|
+
sortable: true,
|
|
742
|
+
header: 'Pending payout',
|
|
743
|
+
width: pixel(150),
|
|
744
|
+
align: 'end',
|
|
745
|
+
renderCell: processor => (
|
|
746
|
+
<Figure>{money(processor.pendingPayoutCents)}</Figure>
|
|
747
|
+
),
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
key: 'feesMtd',
|
|
751
|
+
sortable: true,
|
|
752
|
+
header: 'Fees (MTD)',
|
|
753
|
+
width: pixel(150),
|
|
754
|
+
align: 'end',
|
|
755
|
+
renderCell: processor => <Figure>{money(processor.feesMtdCents)}</Figure>,
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
key: 'change',
|
|
759
|
+
sortable: true,
|
|
760
|
+
header: 'Change',
|
|
761
|
+
width: pixel(110),
|
|
762
|
+
align: 'end',
|
|
763
|
+
renderCell: processor => <ChangeCell id={processor.id} />,
|
|
764
|
+
},
|
|
765
|
+
];
|
|
766
|
+
|
|
767
|
+
const processorCompactColumns: TableColumn<ProcessorAccount>[] = [
|
|
768
|
+
processorColumns[0],
|
|
769
|
+
{
|
|
770
|
+
key: 'pendingPayout',
|
|
771
|
+
sortable: true,
|
|
772
|
+
header: 'Pending payout',
|
|
773
|
+
width: pixel(150),
|
|
774
|
+
align: 'end',
|
|
775
|
+
renderCell: processor => (
|
|
776
|
+
<CompactValueCell
|
|
777
|
+
id={processor.id}
|
|
778
|
+
amountCents={processor.pendingPayoutCents}
|
|
779
|
+
/>
|
|
780
|
+
),
|
|
781
|
+
},
|
|
782
|
+
];
|
|
783
|
+
|
|
784
|
+
const processorComparators: Partial<
|
|
785
|
+
Record<string, TableSortComparator<ProcessorAccount>>
|
|
786
|
+
> = {
|
|
787
|
+
name: (a, b) => a.name.localeCompare(b.name),
|
|
788
|
+
pendingPayout: (a, b) => a.pendingPayoutCents - b.pendingPayoutCents,
|
|
789
|
+
feesMtd: (a, b) => a.feesMtdCents - b.feesMtdCents,
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
// ============= GROUP 4 — INVESTMENT ACCOUNTS =============
|
|
793
|
+
|
|
794
|
+
interface InvestmentAccount extends AccountRecord {
|
|
795
|
+
name: string;
|
|
796
|
+
custodian: string;
|
|
797
|
+
marketValueCents: number;
|
|
798
|
+
costBasisCents: number;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
const INVESTMENTS: InvestmentAccount[] = [
|
|
802
|
+
{
|
|
803
|
+
id: 'inv-1',
|
|
804
|
+
name: 'Short-duration treasuries',
|
|
805
|
+
custodian: 'Northgate Asset Management',
|
|
806
|
+
marketValueCents: 245_180_000,
|
|
807
|
+
costBasisCents: 240_000_000,
|
|
808
|
+
trend: 0.00012,
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
id: 'inv-2',
|
|
812
|
+
name: 'Corporate bond ladder',
|
|
813
|
+
custodian: 'Northgate Asset Management',
|
|
814
|
+
marketValueCents: 98_420_000,
|
|
815
|
+
costBasisCents: 100_000_000,
|
|
816
|
+
trend: -0.00006,
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
id: 'inv-3',
|
|
820
|
+
name: 'Money market fund',
|
|
821
|
+
custodian: 'Harborline Capital',
|
|
822
|
+
marketValueCents: 61_050_000,
|
|
823
|
+
costBasisCents: 61_000_000,
|
|
824
|
+
trend: 0.00003,
|
|
825
|
+
},
|
|
826
|
+
];
|
|
827
|
+
|
|
828
|
+
const investmentColumns: TableColumn<InvestmentAccount>[] = [
|
|
829
|
+
{
|
|
830
|
+
key: 'name',
|
|
831
|
+
sortable: true,
|
|
832
|
+
header: 'Account',
|
|
833
|
+
width: proportional(2),
|
|
834
|
+
renderCell: account => (
|
|
835
|
+
<VStack gap={0}>
|
|
836
|
+
<Text>{account.name}</Text>
|
|
837
|
+
<Text type="supporting">{account.custodian}</Text>
|
|
838
|
+
</VStack>
|
|
839
|
+
),
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
key: 'marketValue',
|
|
843
|
+
sortable: true,
|
|
844
|
+
header: 'Market value',
|
|
845
|
+
width: pixel(150),
|
|
846
|
+
align: 'end',
|
|
847
|
+
renderCell: account => <Figure>{money(account.marketValueCents)}</Figure>,
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
key: 'costBasis',
|
|
851
|
+
sortable: true,
|
|
852
|
+
header: 'Cost basis',
|
|
853
|
+
width: pixel(150),
|
|
854
|
+
align: 'end',
|
|
855
|
+
renderCell: account => <Figure>{money(account.costBasisCents)}</Figure>,
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
key: 'change',
|
|
859
|
+
sortable: true,
|
|
860
|
+
header: 'Change',
|
|
861
|
+
width: pixel(110),
|
|
862
|
+
align: 'end',
|
|
863
|
+
renderCell: account => <ChangeCell id={account.id} />,
|
|
864
|
+
},
|
|
865
|
+
];
|
|
866
|
+
|
|
867
|
+
const investmentCompactColumns: TableColumn<InvestmentAccount>[] = [
|
|
868
|
+
investmentColumns[0],
|
|
869
|
+
{
|
|
870
|
+
key: 'marketValue',
|
|
871
|
+
sortable: true,
|
|
872
|
+
header: 'Market value',
|
|
873
|
+
width: pixel(150),
|
|
874
|
+
align: 'end',
|
|
875
|
+
renderCell: account => (
|
|
876
|
+
<CompactValueCell
|
|
877
|
+
id={account.id}
|
|
878
|
+
amountCents={account.marketValueCents}
|
|
879
|
+
/>
|
|
880
|
+
),
|
|
881
|
+
},
|
|
882
|
+
];
|
|
883
|
+
|
|
884
|
+
const investmentComparators: Partial<
|
|
885
|
+
Record<string, TableSortComparator<InvestmentAccount>>
|
|
886
|
+
> = {
|
|
887
|
+
name: (a, b) => a.name.localeCompare(b.name),
|
|
888
|
+
marketValue: (a, b) => a.marketValueCents - b.marketValueCents,
|
|
889
|
+
costBasis: (a, b) => a.costBasisCents - b.costBasisCents,
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
/** Every row id on the page, so a page-level control can address the details
|
|
893
|
+
* and not just the cards holding them. */
|
|
894
|
+
const ALL_ROW_IDS = [
|
|
895
|
+
...BANK_ACCOUNTS,
|
|
896
|
+
...CREDIT_CARDS,
|
|
897
|
+
...PROCESSORS,
|
|
898
|
+
...INVESTMENTS,
|
|
899
|
+
].map(record => record.id);
|
|
900
|
+
|
|
901
|
+
// ============= DERIVED HISTORY =============
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* A year of daily values per account. Built once at module scope: the numbers
|
|
905
|
+
* are a pure function of the pinned data, so recomputing them per render would
|
|
906
|
+
* be work with no possible different answer.
|
|
907
|
+
*
|
|
908
|
+
* The volatilities differ by group because the accounts do. A payout balance
|
|
909
|
+
* that empties on a schedule is genuinely choppier than a bond ladder, and
|
|
910
|
+
* giving them the same noise makes every chart on the page the same chart.
|
|
911
|
+
*/
|
|
912
|
+
const HISTORY: Record<string, number[]> = Object.fromEntries([
|
|
913
|
+
...historyFor(BANK_ACCOUNTS, account => account.availableCents, 0.014),
|
|
914
|
+
...historyFor(CREDIT_CARDS, card => card.balanceCents, 0.016),
|
|
915
|
+
...historyFor(PROCESSORS, processor => processor.pendingPayoutCents, 0.04),
|
|
916
|
+
...historyFor(INVESTMENTS, account => account.marketValueCents, 0.008),
|
|
917
|
+
]);
|
|
918
|
+
|
|
919
|
+
// ============= DETAIL PANEL =============
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* The account's shape over the selected window, given the width the metadata
|
|
923
|
+
* beside it does not need. At sparkline size the line was a gesture; at this
|
|
924
|
+
* size the dates underneath mean something and a reading of the value is worth
|
|
925
|
+
* following, so it carries an axis and a tooltip.
|
|
926
|
+
*
|
|
927
|
+
* `syncId` is what links it to its siblings: every chart in a group shares
|
|
928
|
+
* one, so pointing at a date in one open row draws the cursor at that date in
|
|
929
|
+
* every other open row of the same category. Recharts syncs on index, which is
|
|
930
|
+
* sound here only because every account in a group is sampled over the same
|
|
931
|
+
* window — same length, same days, same order.
|
|
932
|
+
*/
|
|
933
|
+
const CHART_HEIGHT = 132;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* How long the row this content sits in takes to open.
|
|
937
|
+
*
|
|
938
|
+
* The animating element is an ancestor, so its `transitionend` never reaches
|
|
939
|
+
* us — bubbling runs child to parent. Walking up to read the duration off
|
|
940
|
+
* whichever ancestor actually carries the transition costs one pass and keeps
|
|
941
|
+
* this honest: reduced motion zeroes the token and a theme override changes
|
|
942
|
+
* it, and both are picked up without knowing a class name.
|
|
943
|
+
*/
|
|
944
|
+
function openDurationMs(from: HTMLElement | null): number {
|
|
945
|
+
for (let el = from; el; el = el.parentElement) {
|
|
946
|
+
const style = getComputedStyle(el);
|
|
947
|
+
if (style.transitionProperty.includes('grid-template-rows')) {
|
|
948
|
+
return parseFloat(style.transitionDuration) * 1000;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return 0;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Recharts costs around 400ms of main thread to mount, and spending it while
|
|
956
|
+
* the row is still growing starves the open: measured 9-12 frames across a
|
|
957
|
+
* transition with budget for roughly 40. So hold a skeleton of the chart's
|
|
958
|
+
* exact height until the row has finished opening, then swap. The row animates
|
|
959
|
+
* over a cheap box, and the chart mounts into a panel that is already still.
|
|
960
|
+
* The chart arrives at the same moment either way — only the jank moves off
|
|
961
|
+
* the animation.
|
|
962
|
+
*/
|
|
963
|
+
function useSettledAfterOpen(): [
|
|
964
|
+
React.RefObject<HTMLDivElement | null>,
|
|
965
|
+
boolean,
|
|
966
|
+
] {
|
|
967
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
968
|
+
const [isSettled, setIsSettled] = useState(false);
|
|
969
|
+
|
|
970
|
+
useEffect(() => {
|
|
971
|
+
const duration = openDurationMs(ref.current);
|
|
972
|
+
// Nothing to protect when there is no animation.
|
|
973
|
+
if (duration === 0) {
|
|
974
|
+
setIsSettled(true);
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
const timer = setTimeout(() => setIsSettled(true), duration);
|
|
978
|
+
return () => clearTimeout(timer);
|
|
979
|
+
}, []);
|
|
980
|
+
|
|
981
|
+
return [ref, isSettled];
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
function DetailChart({
|
|
985
|
+
id,
|
|
986
|
+
group,
|
|
987
|
+
isLiability,
|
|
988
|
+
}: {
|
|
989
|
+
id: string;
|
|
990
|
+
group: GroupId;
|
|
991
|
+
isLiability?: boolean;
|
|
992
|
+
}) {
|
|
993
|
+
const [hostRef, isSettled] = useSettledAfterOpen();
|
|
994
|
+
const range = useRange();
|
|
995
|
+
const points = windowOf(id, range);
|
|
996
|
+
const delta = points[points.length - 1] - points[0];
|
|
997
|
+
const isGood = isLiability ? delta <= 0 : delta >= 0;
|
|
998
|
+
const color = isGood ? UP_COLOR : DOWN_COLOR;
|
|
999
|
+
const data = points.map((value, day) => ({
|
|
1000
|
+
day,
|
|
1001
|
+
label: dayLabel(points.length - 1 - day),
|
|
1002
|
+
value: value / 100,
|
|
1003
|
+
}));
|
|
1004
|
+
const ticks = axisTicks(data.length);
|
|
1005
|
+
// One gradient per account, because two charts sharing a fill id take
|
|
1006
|
+
// whichever definition the DOM happens to hold — and open two rows of
|
|
1007
|
+
// opposite sign and that is a green area under a red line.
|
|
1008
|
+
const fillId = `detail-fill-${id}`;
|
|
1009
|
+
|
|
1010
|
+
return (
|
|
1011
|
+
<VStack gap={0} ref={hostRef}>
|
|
1012
|
+
{!isSettled ? (
|
|
1013
|
+
<Skeleton width="100%" height={CHART_HEIGHT} radius={2} />
|
|
1014
|
+
) : (
|
|
1015
|
+
<ResponsiveContainer width="100%" height={CHART_HEIGHT}>
|
|
1016
|
+
<AreaChart data={data} syncId={group} margin={{top: 4, right: 4}}>
|
|
1017
|
+
<defs>
|
|
1018
|
+
<linearGradient id={fillId} x1="0" y1="0" x2="0" y2="1">
|
|
1019
|
+
<stop offset="0%" stopColor={color} stopOpacity={0.2} />
|
|
1020
|
+
<stop offset="100%" stopColor={color} stopOpacity={0} />
|
|
1021
|
+
</linearGradient>
|
|
1022
|
+
</defs>
|
|
1023
|
+
{/* No CartesianGrid and no axis line. A rule at every Y tick reads
|
|
1024
|
+
as a table ruled behind a table, and an axis line at the bottom
|
|
1025
|
+
marks the frame rather than anything in the data. The one rule
|
|
1026
|
+
worth drawing is where the window opened: everything above it is
|
|
1027
|
+
the gain the Change column reports, everything below the loss. */}
|
|
1028
|
+
<XAxis
|
|
1029
|
+
dataKey="day"
|
|
1030
|
+
type="number"
|
|
1031
|
+
domain={[0, data.length - 1]}
|
|
1032
|
+
ticks={ticks}
|
|
1033
|
+
tickFormatter={(day: number) => data[day]?.label ?? ''}
|
|
1034
|
+
tick={AXIS_TICK}
|
|
1035
|
+
axisLine={false}
|
|
1036
|
+
tickLine={false}
|
|
1037
|
+
interval="preserveStartEnd"
|
|
1038
|
+
/>
|
|
1039
|
+
<ReferenceLine
|
|
1040
|
+
y={data[0].value}
|
|
1041
|
+
stroke={GRID_COLOR}
|
|
1042
|
+
strokeDasharray="3 3"
|
|
1043
|
+
/>
|
|
1044
|
+
<YAxis hide domain={['dataMin', 'dataMax']} />
|
|
1045
|
+
<Tooltip content={<DetailTooltip color={color} />} />
|
|
1046
|
+
<Area
|
|
1047
|
+
type="linear"
|
|
1048
|
+
dataKey="value"
|
|
1049
|
+
stroke={color}
|
|
1050
|
+
strokeWidth={1.5}
|
|
1051
|
+
fill={`url(#${fillId})`}
|
|
1052
|
+
dot={false}
|
|
1053
|
+
activeDot={{r: 3, strokeWidth: 0}}
|
|
1054
|
+
isAnimationActive={false}
|
|
1055
|
+
/>
|
|
1056
|
+
</AreaChart>
|
|
1057
|
+
</ResponsiveContainer>
|
|
1058
|
+
)}
|
|
1059
|
+
</VStack>
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
function DetailTooltip({
|
|
1064
|
+
active,
|
|
1065
|
+
payload,
|
|
1066
|
+
color,
|
|
1067
|
+
}: {
|
|
1068
|
+
active?: boolean;
|
|
1069
|
+
payload?: Array<{payload: {label: string; value: number}}>;
|
|
1070
|
+
color?: string;
|
|
1071
|
+
}) {
|
|
1072
|
+
if (!active || !payload?.length) {
|
|
1073
|
+
return null;
|
|
1074
|
+
}
|
|
1075
|
+
const point = payload[0].payload;
|
|
1076
|
+
return (
|
|
1077
|
+
<Card padding={3}>
|
|
1078
|
+
<VStack gap={1}>
|
|
1079
|
+
<Text type="supporting" color="secondary">
|
|
1080
|
+
{point.label}
|
|
1081
|
+
</Text>
|
|
1082
|
+
<HStack gap={2} vAlign="center">
|
|
1083
|
+
<HStack xstyle={styles.swatch(color ?? UP_COLOR)} />
|
|
1084
|
+
<Text weight="semibold" hasTabularNumbers>
|
|
1085
|
+
{wholeCurrency.format(point.value)}
|
|
1086
|
+
</Text>
|
|
1087
|
+
</HStack>
|
|
1088
|
+
</VStack>
|
|
1089
|
+
</Card>
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// ============= GROUP SHELL =============
|
|
1094
|
+
|
|
1095
|
+
const GROUP_IDS = ['bank', 'cards', 'processors', 'investments'] as const;
|
|
1096
|
+
type GroupId = (typeof GROUP_IDS)[number];
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* Square side of the category tile in the group header. 24px is not a look, it
|
|
1100
|
+
* is an alignment: the tile plus the 8px gap after it is exactly the inset the
|
|
1101
|
+
* cells below give their own text, so the group name starts on the same x as
|
|
1102
|
+
* the first column's header and rows. It is also the size of the row-expansion
|
|
1103
|
+
* chevron buttons, and it sits at their x — so the group's disclosure and its
|
|
1104
|
+
* rows' disclosures form one column down the left edge of the card.
|
|
1105
|
+
*/
|
|
1106
|
+
const TILE_SIZE = 24;
|
|
1107
|
+
|
|
1108
|
+
const styles = stylex.create({
|
|
1109
|
+
// The page is a wash so the group cards read as surfaces sitting on it
|
|
1110
|
+
// rather than as outlines drawn on the same sheet. Body is the right token
|
|
1111
|
+
// for that: a theme that wants its cards to contrast sets it away from
|
|
1112
|
+
// --color-background-card, and one that wants them flush sets it equal and
|
|
1113
|
+
// separates them by border instead. Either way the page follows the theme.
|
|
1114
|
+
wash: {
|
|
1115
|
+
backgroundColor: colorVars['--color-background-body'],
|
|
1116
|
+
},
|
|
1117
|
+
delta: (color: string) => ({color}),
|
|
1118
|
+
swatch: (color: string) => ({
|
|
1119
|
+
width: 8,
|
|
1120
|
+
height: 8,
|
|
1121
|
+
borderRadius: '50%',
|
|
1122
|
+
backgroundColor: color,
|
|
1123
|
+
flexShrink: 0,
|
|
1124
|
+
}),
|
|
1125
|
+
categoryTile: {
|
|
1126
|
+
display: 'grid',
|
|
1127
|
+
placeItems: 'center',
|
|
1128
|
+
width: TILE_SIZE,
|
|
1129
|
+
height: TILE_SIZE,
|
|
1130
|
+
flexShrink: 0,
|
|
1131
|
+
borderRadius: radiusVars['--radius-inner'],
|
|
1132
|
+
backgroundColor: colorVars['--color-background-muted'],
|
|
1133
|
+
},
|
|
1134
|
+
});
|
|
1135
|
+
|
|
1136
|
+
function AccountGroup({
|
|
1137
|
+
icon,
|
|
1138
|
+
title,
|
|
1139
|
+
count,
|
|
1140
|
+
summaryLabel,
|
|
1141
|
+
summaryValue,
|
|
1142
|
+
isOpen,
|
|
1143
|
+
onOpenChange,
|
|
1144
|
+
children,
|
|
1145
|
+
}: {
|
|
1146
|
+
icon: React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
1147
|
+
title: string;
|
|
1148
|
+
count: number;
|
|
1149
|
+
summaryLabel: string;
|
|
1150
|
+
summaryValue: string;
|
|
1151
|
+
isOpen: boolean;
|
|
1152
|
+
onOpenChange: (open: boolean) => void;
|
|
1153
|
+
children: React.ReactNode;
|
|
1154
|
+
}) {
|
|
1155
|
+
return (
|
|
1156
|
+
// 8px on the Card and nothing on the Collapsible: one content line for the
|
|
1157
|
+
// header and the table both, and the table's rows then inset themselves by
|
|
1158
|
+
// their own cell padding on top of it.
|
|
1159
|
+
<Card padding={2}>
|
|
1160
|
+
<Collapsible
|
|
1161
|
+
isOpen={isOpen}
|
|
1162
|
+
onOpenChange={onOpenChange}
|
|
1163
|
+
trigger={
|
|
1164
|
+
// paddingBlock, because the trigger has none of its own: its height
|
|
1165
|
+
// is exactly the 24px tile, so the only space above the group name
|
|
1166
|
+
// was the Card's 8px. The column header below it is a table cell and
|
|
1167
|
+
// brings its own inset, which is what made the row read as pinned to
|
|
1168
|
+
// the top edge even though the two gaps measured the same.
|
|
1169
|
+
<HStack
|
|
1170
|
+
gap={2}
|
|
1171
|
+
vAlign="center"
|
|
1172
|
+
hAlign="between"
|
|
1173
|
+
paddingBlock={2}
|
|
1174
|
+
paddingInline={2}>
|
|
1175
|
+
<HStack gap={2} vAlign="center">
|
|
1176
|
+
<HStack xstyle={styles.categoryTile}>
|
|
1177
|
+
<Icon icon={icon} size="sm" />
|
|
1178
|
+
</HStack>
|
|
1179
|
+
<Text weight="semibold">{title}</Text>
|
|
1180
|
+
<Badge variant="neutral" label={String(count)} />
|
|
1181
|
+
</HStack>
|
|
1182
|
+
<HStack gap={2} vAlign="center">
|
|
1183
|
+
{/* Body rather than supporting: it is the label on the one
|
|
1184
|
+
figure a collapsed group still shows, so it has to survive
|
|
1185
|
+
being read at a glance from across the page. */}
|
|
1186
|
+
<Text color="secondary">{summaryLabel}</Text>
|
|
1187
|
+
<Text weight="semibold" hasTabularNumbers>
|
|
1188
|
+
{summaryValue}
|
|
1189
|
+
</Text>
|
|
1190
|
+
</HStack>
|
|
1191
|
+
</HStack>
|
|
1192
|
+
}>
|
|
1193
|
+
{/* The trigger is a row of text and the table opens with a row of
|
|
1194
|
+
text, so without this they read as one block with a hairline in
|
|
1195
|
+
it. 12px is enough to say the header is a header. */}
|
|
1196
|
+
<VStack paddingBlockStart={3}>{children}</VStack>
|
|
1197
|
+
</Collapsible>
|
|
1198
|
+
</Card>
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* The four tables differ in their columns and in nothing else, so the plugin
|
|
1204
|
+
* wiring lives here once rather than four times.
|
|
1205
|
+
*
|
|
1206
|
+
* The built-in expansion plugin owns the disclosure chevron and its muted
|
|
1207
|
+
* detail surface, so every table exposes the same interaction and panel
|
|
1208
|
+
* treatment without custom row event handling.
|
|
1209
|
+
*/
|
|
1210
|
+
function GroupTable<T extends AccountRecord>({
|
|
1211
|
+
data,
|
|
1212
|
+
columns,
|
|
1213
|
+
comparators,
|
|
1214
|
+
expandedRows,
|
|
1215
|
+
onToggleRow,
|
|
1216
|
+
renderExpanded,
|
|
1217
|
+
}: {
|
|
1218
|
+
data: T[];
|
|
1219
|
+
columns: TableColumn<T>[];
|
|
1220
|
+
comparators: Partial<Record<string, TableSortComparator<T>>>;
|
|
1221
|
+
expandedRows: Set<string>;
|
|
1222
|
+
onToggleRow: (key: string) => void;
|
|
1223
|
+
renderExpanded: (item: T) => React.ReactNode;
|
|
1224
|
+
}) {
|
|
1225
|
+
const range = useRange();
|
|
1226
|
+
|
|
1227
|
+
// Change is the one column whose value is not in the row — it is derived
|
|
1228
|
+
// from the page's range. The sort memo keys on data identity, so a range
|
|
1229
|
+
// switch has to hand it a different array or the rows would keep the order
|
|
1230
|
+
// computed from the old window while showing figures from the new one.
|
|
1231
|
+
const rows = useMemo(() => data.slice(), [data, range]);
|
|
1232
|
+
|
|
1233
|
+
const sortComparators = useMemo(
|
|
1234
|
+
() => ({
|
|
1235
|
+
...comparators,
|
|
1236
|
+
change: (a: T, b: T) =>
|
|
1237
|
+
changePercentOf(a.id, range) - changePercentOf(b.id, range),
|
|
1238
|
+
}),
|
|
1239
|
+
[comparators, range],
|
|
1240
|
+
);
|
|
1241
|
+
|
|
1242
|
+
const {sortedData, sortConfig} = useTableSortableState<T>({
|
|
1243
|
+
data: rows,
|
|
1244
|
+
comparators: sortComparators,
|
|
1245
|
+
});
|
|
1246
|
+
const sort = useTableSortable<T>(sortConfig);
|
|
1247
|
+
|
|
1248
|
+
const expansion = useTableRowExpansion<T>({
|
|
1249
|
+
expandedKeys: expandedRows,
|
|
1250
|
+
onToggle: onToggleRow,
|
|
1251
|
+
getRowKey: item => item.id,
|
|
1252
|
+
renderExpanded,
|
|
1253
|
+
});
|
|
1254
|
+
|
|
1255
|
+
return (
|
|
1256
|
+
<Table
|
|
1257
|
+
data={sortedData}
|
|
1258
|
+
columns={columns}
|
|
1259
|
+
idKey="id"
|
|
1260
|
+
density="compact"
|
|
1261
|
+
dividers="rows"
|
|
1262
|
+
plugins={{sort, expansion}}
|
|
1263
|
+
/>
|
|
1264
|
+
);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
// ============= PAGE =============
|
|
1268
|
+
|
|
1269
|
+
export default function ConnectedAccountsTemplate() {
|
|
1270
|
+
const [openGroups, setOpenGroups] = useState<Set<GroupId>>(
|
|
1271
|
+
() => new Set(GROUP_IDS),
|
|
1272
|
+
);
|
|
1273
|
+
|
|
1274
|
+
// Lifted out of the chart because it is not the chart's setting — it is the
|
|
1275
|
+
// page's. Year to date is the default because it is the window accounts are
|
|
1276
|
+
// actually reasoned about in, and it is long enough that a monthly cycle
|
|
1277
|
+
// shows up several times rather than once or twice.
|
|
1278
|
+
const [range, setRange] = useState<RangeId>('YTD');
|
|
1279
|
+
|
|
1280
|
+
// One Set for all four tables, not one per group. Row ids are unique across
|
|
1281
|
+
// the page, so a single Set is unambiguous, and it is what a "collapse every
|
|
1282
|
+
// open detail" control or a persisted view would need to read.
|
|
1283
|
+
const [expandedRows, setExpandedRows] = useState<Set<string>>(
|
|
1284
|
+
() => new Set(),
|
|
1285
|
+
);
|
|
1286
|
+
|
|
1287
|
+
const toggleRow = (key: string) => {
|
|
1288
|
+
setExpandedRows(previous => {
|
|
1289
|
+
const next = new Set(previous);
|
|
1290
|
+
if (next.has(key)) {
|
|
1291
|
+
next.delete(key);
|
|
1292
|
+
} else {
|
|
1293
|
+
next.add(key);
|
|
1294
|
+
}
|
|
1295
|
+
return next;
|
|
1296
|
+
});
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
const toggleGroup = (id: GroupId) => (open: boolean) => {
|
|
1300
|
+
setOpenGroups(previous => {
|
|
1301
|
+
const next = new Set(previous);
|
|
1302
|
+
if (open) {
|
|
1303
|
+
next.add(id);
|
|
1304
|
+
} else {
|
|
1305
|
+
next.delete(id);
|
|
1306
|
+
}
|
|
1307
|
+
return next;
|
|
1308
|
+
});
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1311
|
+
const totals = useMemo(() => {
|
|
1312
|
+
const banks = sum(BANK_ACCOUNTS, account => account.availableCents);
|
|
1313
|
+
const cards = sum(CREDIT_CARDS, card => card.balanceCents);
|
|
1314
|
+
const pending = sum(PROCESSORS, p => p.pendingPayoutCents);
|
|
1315
|
+
const investments = sum(INVESTMENTS, i => i.marketValueCents);
|
|
1316
|
+
return {
|
|
1317
|
+
banks,
|
|
1318
|
+
cards,
|
|
1319
|
+
pending,
|
|
1320
|
+
investments,
|
|
1321
|
+
// Outstanding card balances are a liability, so they come off the top.
|
|
1322
|
+
net: banks + pending + investments - cards,
|
|
1323
|
+
};
|
|
1324
|
+
}, []);
|
|
1325
|
+
|
|
1326
|
+
const [contentRef, contentWidth] = useSurfaceWidth();
|
|
1327
|
+
// Zero is the width before the first measurement, not a narrow box, and
|
|
1328
|
+
// treating it as narrow would flash the compact tables on every mount.
|
|
1329
|
+
const isCompact = contentWidth > 0 && contentWidth < COMPACT_BELOW_PX;
|
|
1330
|
+
|
|
1331
|
+
// "All open" has to mean the details too. A control labelled Expand all that
|
|
1332
|
+
// opens four cards and leaves thirteen collapsed rows inside them has not
|
|
1333
|
+
// expanded all, and its next click would read as Collapse all while most of
|
|
1334
|
+
// the page is still shut.
|
|
1335
|
+
const isEverythingOpen =
|
|
1336
|
+
openGroups.size === GROUP_IDS.length &&
|
|
1337
|
+
expandedRows.size === ALL_ROW_IDS.length;
|
|
1338
|
+
|
|
1339
|
+
const toggleEverything = () => {
|
|
1340
|
+
const open = !isEverythingOpen;
|
|
1341
|
+
setOpenGroups(open ? new Set(GROUP_IDS) : new Set());
|
|
1342
|
+
setExpandedRows(open ? new Set(ALL_ROW_IDS) : new Set());
|
|
1343
|
+
};
|
|
1344
|
+
|
|
1345
|
+
return (
|
|
1346
|
+
<RangeContext.Provider value={range}>
|
|
1347
|
+
<Layout
|
|
1348
|
+
height="auto"
|
|
1349
|
+
contentWidth={1200}
|
|
1350
|
+
xstyle={styles.wash}
|
|
1351
|
+
header={
|
|
1352
|
+
<LayoutHeader padding={4}>
|
|
1353
|
+
<HStack gap={3} vAlign="center" wrap="wrap">
|
|
1354
|
+
<StackItem size="fill">
|
|
1355
|
+
<VStack gap={0.5}>
|
|
1356
|
+
<Heading level={1}>Connected accounts</Heading>
|
|
1357
|
+
<Text type="supporting">
|
|
1358
|
+
Net position {money(totals.net)} across 13 accounts
|
|
1359
|
+
</Text>
|
|
1360
|
+
</VStack>
|
|
1361
|
+
</StackItem>
|
|
1362
|
+
<Button
|
|
1363
|
+
label={isEverythingOpen ? 'Collapse all' : 'Expand all'}
|
|
1364
|
+
variant="ghost"
|
|
1365
|
+
onClick={toggleEverything}
|
|
1366
|
+
/>
|
|
1367
|
+
{/* The range belongs to the page, not to any one table, so it
|
|
1368
|
+
sits with the page title rather than inside a card. */}
|
|
1369
|
+
<SegmentedControl
|
|
1370
|
+
value={range}
|
|
1371
|
+
onChange={value => setRange(value as RangeId)}
|
|
1372
|
+
label="Time range">
|
|
1373
|
+
{RANGE_IDS.map(id => (
|
|
1374
|
+
<SegmentedControlItem key={id} value={id} label={id} />
|
|
1375
|
+
))}
|
|
1376
|
+
</SegmentedControl>
|
|
1377
|
+
</HStack>
|
|
1378
|
+
</LayoutHeader>
|
|
1379
|
+
}
|
|
1380
|
+
content={
|
|
1381
|
+
<LayoutContent padding={4}>
|
|
1382
|
+
<VStack gap={4} ref={contentRef}>
|
|
1383
|
+
<AccountGroup
|
|
1384
|
+
icon={BuildingLibraryIcon}
|
|
1385
|
+
title="Bank accounts"
|
|
1386
|
+
count={BANK_ACCOUNTS.length}
|
|
1387
|
+
summaryLabel="Available"
|
|
1388
|
+
summaryValue={money(totals.banks)}
|
|
1389
|
+
isOpen={openGroups.has('bank')}
|
|
1390
|
+
onOpenChange={toggleGroup('bank')}>
|
|
1391
|
+
<GroupTable<BankAccount>
|
|
1392
|
+
data={BANK_ACCOUNTS}
|
|
1393
|
+
columns={isCompact ? bankCompactColumns : bankColumns}
|
|
1394
|
+
comparators={bankComparators}
|
|
1395
|
+
expandedRows={expandedRows}
|
|
1396
|
+
onToggleRow={toggleRow}
|
|
1397
|
+
renderExpanded={account => (
|
|
1398
|
+
<DetailChart id={account.id} group="bank" />
|
|
1399
|
+
)}
|
|
1400
|
+
/>
|
|
1401
|
+
</AccountGroup>
|
|
1402
|
+
|
|
1403
|
+
<AccountGroup
|
|
1404
|
+
icon={CreditCardIcon}
|
|
1405
|
+
title="Credit cards"
|
|
1406
|
+
count={CREDIT_CARDS.length}
|
|
1407
|
+
summaryLabel="Outstanding"
|
|
1408
|
+
summaryValue={money(totals.cards)}
|
|
1409
|
+
isOpen={openGroups.has('cards')}
|
|
1410
|
+
onOpenChange={toggleGroup('cards')}>
|
|
1411
|
+
<GroupTable<CreditCardAccount>
|
|
1412
|
+
data={CREDIT_CARDS}
|
|
1413
|
+
columns={
|
|
1414
|
+
isCompact ? creditCardCompactColumns : creditCardColumns
|
|
1415
|
+
}
|
|
1416
|
+
comparators={creditCardComparators}
|
|
1417
|
+
expandedRows={expandedRows}
|
|
1418
|
+
onToggleRow={toggleRow}
|
|
1419
|
+
renderExpanded={card => (
|
|
1420
|
+
<DetailChart id={card.id} group="cards" isLiability />
|
|
1421
|
+
)}
|
|
1422
|
+
/>
|
|
1423
|
+
</AccountGroup>
|
|
1424
|
+
|
|
1425
|
+
<AccountGroup
|
|
1426
|
+
icon={ArrowsRightLeftIcon}
|
|
1427
|
+
title="Payment processors"
|
|
1428
|
+
count={PROCESSORS.length}
|
|
1429
|
+
summaryLabel="Pending payout"
|
|
1430
|
+
summaryValue={money(totals.pending)}
|
|
1431
|
+
isOpen={openGroups.has('processors')}
|
|
1432
|
+
onOpenChange={toggleGroup('processors')}>
|
|
1433
|
+
<GroupTable<ProcessorAccount>
|
|
1434
|
+
data={PROCESSORS}
|
|
1435
|
+
columns={
|
|
1436
|
+
isCompact ? processorCompactColumns : processorColumns
|
|
1437
|
+
}
|
|
1438
|
+
comparators={processorComparators}
|
|
1439
|
+
expandedRows={expandedRows}
|
|
1440
|
+
onToggleRow={toggleRow}
|
|
1441
|
+
renderExpanded={processor => (
|
|
1442
|
+
<DetailChart id={processor.id} group="processors" />
|
|
1443
|
+
)}
|
|
1444
|
+
/>
|
|
1445
|
+
</AccountGroup>
|
|
1446
|
+
|
|
1447
|
+
<AccountGroup
|
|
1448
|
+
icon={PresentationChartLineIcon}
|
|
1449
|
+
title="Investment accounts"
|
|
1450
|
+
count={INVESTMENTS.length}
|
|
1451
|
+
summaryLabel="Market value"
|
|
1452
|
+
summaryValue={money(totals.investments)}
|
|
1453
|
+
isOpen={openGroups.has('investments')}
|
|
1454
|
+
onOpenChange={toggleGroup('investments')}>
|
|
1455
|
+
<GroupTable<InvestmentAccount>
|
|
1456
|
+
data={INVESTMENTS}
|
|
1457
|
+
columns={
|
|
1458
|
+
isCompact ? investmentCompactColumns : investmentColumns
|
|
1459
|
+
}
|
|
1460
|
+
comparators={investmentComparators}
|
|
1461
|
+
expandedRows={expandedRows}
|
|
1462
|
+
onToggleRow={toggleRow}
|
|
1463
|
+
renderExpanded={account => (
|
|
1464
|
+
<DetailChart id={account.id} group="investments" />
|
|
1465
|
+
)}
|
|
1466
|
+
/>
|
|
1467
|
+
</AccountGroup>
|
|
1468
|
+
</VStack>
|
|
1469
|
+
</LayoutContent>
|
|
1470
|
+
}
|
|
1471
|
+
/>
|
|
1472
|
+
</RangeContext.Provider>
|
|
1473
|
+
);
|
|
1474
|
+
}
|