@reqvire-org/ads 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -6
- package/dist/ads-errors.mjs +275 -12
- package/dist/ads-views.mjs +4 -4
- package/dist/analysis/design-usage.mjs +20 -4
- package/dist/analysis/mock-check.mjs +5 -4
- package/dist/analysis/owner-analysis-key.mjs +1 -1
- package/dist/analysis/owner-choices.mjs +172 -39
- package/dist/analysis/owner-composition.mjs +37 -13
- package/dist/analysis/owner-controls.mjs +27 -0
- package/dist/analysis/owner-source.mjs +67 -18
- package/dist/analysis/prose-owners.mjs +57 -0
- package/dist/analysis/styling-ownership.mjs +22 -0
- package/dist/check.mjs +7 -1
- package/dist/cli-arguments.mjs +2 -2
- package/dist/cli.mjs +3 -3
- package/dist/composed-contrast.mjs +28 -8
- package/dist/composed-keyline.mjs +107 -0
- package/dist/construction-output.mjs +146 -18
- package/dist/construction-spec.d.mts +212 -9
- package/dist/construction-spec.mjs +297 -56
- package/dist/corner-overpaint.mjs +53 -0
- package/dist/design-foundation.mjs +6 -1
- package/dist/design-usage.mjs +8 -2
- package/dist/emit/emission.mjs +11 -4
- package/dist/emit/font-emission.mjs +21 -1
- package/dist/emit/foundation-sheet.mjs +6 -5
- package/dist/emit/preview-tree.mjs +1 -1
- package/dist/finding-rules.mjs +7 -0
- package/dist/font-checks.mjs +42 -0
- package/dist/font-declaration.d.mts +10 -0
- package/dist/font-declaration.mjs +25 -3
- package/dist/font-fallback.d.mts +37 -0
- package/dist/font-fallback.mjs +25 -0
- package/dist/font-macro.d.mts +10 -0
- package/dist/font-metrics.d.mts +34 -0
- package/dist/font-metrics.mjs +314 -0
- package/dist/font-model.mjs +28 -2
- package/dist/foundation-macro.d.mts +1 -1
- package/dist/frame-regions.mjs +66 -3
- package/dist/grid-facts.mjs +72 -16
- package/dist/grid-lowering.mjs +11 -5
- package/dist/init.mjs +14 -23
- package/dist/lowering-enter.mjs +31 -0
- package/dist/lowering-properties.mjs +22 -1
- package/dist/lowering-region-layout.mjs +42 -8
- package/dist/lowering-sequence.mjs +89 -0
- package/dist/lowering-session.mjs +7 -0
- package/dist/lowering-transitions.mjs +22 -8
- package/dist/mcp/preview-http.bundle.js +2 -2
- package/dist/mcp/preview-widget.bundle.js +5 -5
- package/dist/motion-model.mjs +2 -0
- package/dist/owner-analysis-check.mjs +67 -7
- package/dist/owner-errors.mjs +16 -0
- package/dist/owner-lowering.mjs +36 -16
- package/dist/owner-scenarios.mjs +25 -3
- package/dist/ownership-model.mjs +23 -4
- package/dist/paint-contrast.mjs +5 -0
- package/dist/placeholder-contrast.mjs +1 -0
- package/dist/platform-features.mjs +26 -2
- package/dist/preview-bun.mjs +17 -16
- package/dist/preview-controls.mjs +35 -0
- package/dist/preview-incremental.mjs +1 -1
- package/dist/preview-source.mjs +2 -2
- package/dist/profile-macro.d.mts +15 -0
- package/dist/profile-model.mjs +3 -3
- package/dist/profile-view-facts.mjs +55 -4
- package/dist/prose-model.d.mts +81 -0
- package/dist/prose-model.mjs +101 -0
- package/dist/recipe-macro.d.mts +105 -3
- package/dist/recipe-model.mjs +31 -7
- package/dist/region-lowering.mjs +241 -41
- package/dist/render-audit/corner-overpaint.page.mjs +54 -0
- package/dist/render-audit/worker.mjs +6 -1
- package/dist/render-audit.mjs +25 -0
- package/dist/role-vocabulary.d.mts +38 -2
- package/dist/role-vocabulary.mjs +39 -4
- package/dist/scenario-kit.d.mts +6 -0
- package/dist/scenario-registry.mjs +1 -1
- package/dist/scheme-switch.d.mts +8 -0
- package/dist/scheme-switch.mjs +1 -0
- package/dist/showcase/ads-views.mjs +116 -53
- package/dist/showcase/assets-view.mjs +117 -86
- package/dist/showcase/client.bundle.js +65 -65
- package/dist/showcase/http-client.bundle.js +17 -17
- package/dist/showcase/preview-frame.css +2 -0
- package/dist/showcase/profiles-view.mjs +163 -122
- package/dist/showcase/scenario-page.d.mts +11 -1
- package/dist/showcase/scenario-page.mjs +18 -3
- package/dist/showcase/token-sample.mjs +47 -4
- package/dist/showcase/tokens-view.mjs +82 -34
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +5 -5
- package/dist/skills/README.md +5 -5
- package/dist/skills/ads-designer/README.md +1 -1
- package/dist/skills/ads-designer/SKILL.md +13 -12
- package/dist/skills/ads-designer/references/accessibility.md +2 -2
- package/dist/skills/ads-designer/references/atomic-styles.md +8 -1
- package/dist/skills/ads-designer/references/branding.md +7 -2
- package/dist/skills/ads-designer/references/cli.md +4 -4
- package/dist/skills/ads-designer/references/contracts.md +9 -2
- package/dist/skills/ads-designer/references/design-craft.md +1 -1
- package/dist/skills/ads-designer/references/design-data.md +3 -3
- package/dist/skills/ads-designer/references/forms.md +6 -6
- package/dist/skills/ads-designer/references/layout.md +42 -3
- package/dist/skills/ads-designer/references/motion.md +37 -1
- package/dist/skills/ads-designer/references/performance.md +7 -1
- package/dist/skills/ads-designer/references/recipes.md +67 -6
- package/dist/skills/ads-designer/references/runtimes.md +1 -1
- package/dist/skills/ads-designer/references/scenarios.md +1 -0
- package/dist/skills/ads-import/references/atomic-styles.md +8 -1
- package/dist/skills/ads-import/references/cli.md +4 -4
- package/dist/skills/ads-import/references/contracts.md +9 -2
- package/dist/skills/ads-import/references/design-data.md +3 -3
- package/dist/skills/ads-import/references/forms.md +6 -6
- package/dist/skills/ads-import/references/layout.md +42 -3
- package/dist/skills/ads-import/references/recipes.md +67 -6
- package/dist/skills/ads-import/references/runtimes.md +1 -1
- package/dist/skills/ads-import/references/scenarios.md +1 -0
- package/dist/skills/ads-migrate/SKILL.md +2 -1
- package/dist/skills/ads-migrate/references/0.5.0-to-0.5.1.md +239 -0
- package/dist/skills/ads-port/references/atomic-styles.md +8 -1
- package/dist/skills/ads-port/references/cli.md +4 -4
- package/dist/skills/ads-port/references/contracts.md +9 -2
- package/dist/skills/ads-port/references/design-data.md +3 -3
- package/dist/skills/ads-port/references/forms.md +6 -6
- package/dist/skills/ads-port/references/layout.md +42 -3
- package/dist/skills/ads-port/references/recipes.md +67 -6
- package/dist/skills/ads-port/references/runtimes.md +1 -1
- package/dist/skills/ads-port/references/scenarios.md +1 -0
- package/dist/spatial-model.mjs +20 -4
- package/dist/state-conditions.d.mts +29 -0
- package/dist/state-conditions.mjs +42 -2
- package/dist/surface-contrast.mjs +68 -10
- package/dist/surface-effects.mjs +98 -0
- package/dist/target-size.mjs +1 -1
- package/dist/task-cache.mjs +1 -1
- package/dist/token-dtcg.mjs +1 -0
- package/dist/token-view-facts.mjs +54 -5
- package/dist/unreached-sources.mjs +5 -0
- package/dist/validation.mjs +1 -1
- package/docs/ADS.md +36 -13
- package/docs/ARCHITECTURE.md +160 -16
- package/docs/ASSETS.md +81 -10
- package/docs/CACHING.md +1 -1
- package/docs/CHANGELOG.md +346 -21
- package/docs/DESIGN-REFERENCES.md +5 -5
- package/docs/GUIDE.md +241 -72
- package/docs/LANGUAGE.md +287 -21
- package/docs/LOWERING.md +13 -1
- package/docs/MOTION.md +233 -7
- package/docs/PROFILE-KINDS.md +167 -13
- package/docs/PROFILES.md +2 -2
- package/docs/RULES.md +49 -18
- package/docs/TOKEN-ROLES.md +9 -7
- package/package.json +1 -1
- package/dist/starter-files.mjs +0 -155
- package/dist/starter-overlay.mjs +0 -189
- package/dist/starters/preact/design-system/assets/avatars/avatar.ads.ts +0 -10
- package/dist/starters/preact/design-system/assets/avatars/member.svg +0 -1
- package/dist/starters/preact/design-system/assets/brand/emblem.ads.ts +0 -18
- package/dist/starters/preact/design-system/assets/brand/emblem.svg +0 -4
- package/dist/starters/preact/design-system/assets/brand/iris-emblem.ads.ts +0 -14
- package/dist/starters/preact/design-system/assets/brand/iris-emblem.svg +0 -4
- package/dist/starters/preact/design-system/assets/brand/mark.ads.ts +0 -14
- package/dist/starters/preact/design-system/assets/brand/mark.svg +0 -1
- package/dist/starters/preact/design-system/assets/glyphs/arrow.ads.ts +0 -14
- package/dist/starters/preact/design-system/assets/glyphs/arrow.svg +0 -1
- package/dist/starters/preact/design-system/assets/glyphs/chevron-20.svg +0 -1
- package/dist/starters/preact/design-system/assets/glyphs/chevron-24.svg +0 -1
- package/dist/starters/preact/design-system/assets/glyphs/chevron.ads.ts +0 -20
- package/dist/starters/preact/design-system/assets/glyphs/close.ads.ts +0 -13
- package/dist/starters/preact/design-system/assets/glyphs/close.svg +0 -1
- package/dist/starters/preact/design-system/assets/glyphs/favorite.ads.ts +0 -23
- package/dist/starters/preact/design-system/assets/glyphs/favorite.normal.svg +0 -1
- package/dist/starters/preact/design-system/assets/glyphs/favorite.selected.svg +0 -1
- package/dist/starters/preact/design-system/assets/glyphs/search.ads.ts +0 -10
- package/dist/starters/preact/design-system/assets/glyphs/search.svg +0 -1
- package/dist/starters/preact/design-system/assets/illustrations/journey.ads.ts +0 -32
- package/dist/starters/preact/design-system/assets/illustrations/journey.contrast.svg +0 -6
- package/dist/starters/preact/design-system/assets/illustrations/journey.dark.svg +0 -13
- package/dist/starters/preact/design-system/assets/illustrations/journey.light.svg +0 -13
- package/dist/starters/preact/design-system/assets/logos/harbor-pay.ads.ts +0 -17
- package/dist/starters/preact/design-system/assets/logos/harbor-pay.dark.svg +0 -10
- package/dist/starters/preact/design-system/assets/logos/harbor-pay.light.svg +0 -10
- package/dist/starters/preact/design-system/assets/logos/lumen-cloud.ads.ts +0 -15
- package/dist/starters/preact/design-system/assets/logos/lumen-cloud.dark.svg +0 -9
- package/dist/starters/preact/design-system/assets/logos/lumen-cloud.light.svg +0 -9
- package/dist/starters/preact/design-system/assets/status/error.svg +0 -1
- package/dist/starters/preact/design-system/assets/status/outcomes.ads.ts +0 -31
- package/dist/starters/preact/design-system/assets/status/status.ads.ts +0 -16
- package/dist/starters/preact/design-system/assets/status/success.svg +0 -1
- package/dist/starters/preact/design-system/assets/status/sync-status.ads.ts +0 -14
- package/dist/starters/preact/design-system/assets/status/sync-status.svg +0 -7
- package/dist/starters/preact/design-system/assets/status/warning.svg +0 -1
- package/dist/starters/preact/design-system/components/Actions/Button/Button.ads.scenario.tsx +0 -12
- package/dist/starters/preact/design-system/components/Actions/Button/Button.tsx +0 -198
- package/dist/starters/preact/design-system/components/Actions/IconButton/IconButton.tsx +0 -95
- package/dist/starters/preact/design-system/components/Actions/ToggleTile/ToggleTile.ads.scenario.tsx +0 -22
- package/dist/starters/preact/design-system/components/Actions/ToggleTile/ToggleTile.tsx +0 -60
- package/dist/starters/preact/design-system/components/Containers/Disclosure/Disclosure.ads.scenario.tsx +0 -24
- package/dist/starters/preact/design-system/components/Containers/Disclosure/Disclosure.tsx +0 -50
- package/dist/starters/preact/design-system/components/Content/Artwork/Artwork.ads.scenario.tsx +0 -8
- package/dist/starters/preact/design-system/components/Content/Artwork/Artwork.tsx +0 -110
- package/dist/starters/preact/design-system/components/Content/BarChart/BarChart.ads.scenario.tsx +0 -25
- package/dist/starters/preact/design-system/components/Content/BarChart/BarChart.tsx +0 -72
- package/dist/starters/preact/design-system/components/Content/GuideGrid/GuideGrid.ads.scenario.tsx +0 -8
- package/dist/starters/preact/design-system/components/Content/GuideGrid/GuideGrid.tsx +0 -43
- package/dist/starters/preact/design-system/components/Content/Icon/Icon.ads.scenario.tsx +0 -21
- package/dist/starters/preact/design-system/components/Content/Icon/Icon.tsx +0 -41
- package/dist/starters/preact/design-system/components/Content/Icon/glyphs/arrow.tsx +0 -10
- package/dist/starters/preact/design-system/components/Content/Icon/glyphs/close.tsx +0 -10
- package/dist/starters/preact/design-system/components/Content/Icon/glyphs/search.tsx +0 -10
- package/dist/starters/preact/design-system/components/Content/Image/Image.ads.fixture.ts +0 -9
- package/dist/starters/preact/design-system/components/Content/Image/Image.ads.scenario.tsx +0 -12
- package/dist/starters/preact/design-system/components/Content/Image/Image.tsx +0 -83
- package/dist/starters/preact/design-system/components/Content/InspectedGlyph/InspectedGlyph.ads.scenario.tsx +0 -27
- package/dist/starters/preact/design-system/components/Content/InspectedGlyph/InspectedGlyph.tsx +0 -46
- package/dist/starters/preact/design-system/components/Content/PartnerLogo/PartnerLogo.ads.scenario.tsx +0 -17
- package/dist/starters/preact/design-system/components/Content/PartnerLogo/PartnerLogo.tsx +0 -41
- package/dist/starters/preact/design-system/components/Content/StatusIcon/StatusIcon.ads.scenario.tsx +0 -20
- package/dist/starters/preact/design-system/components/Content/StatusIcon/StatusIcon.tsx +0 -37
- package/dist/starters/preact/design-system/components/Forms/TextField/TextField.ads.scenario.tsx +0 -24
- package/dist/starters/preact/design-system/components/Forms/TextField/TextField.tsx +0 -173
- package/dist/starters/preact/design-system/components/Identity/Identity.ads.scenario.tsx +0 -13
- package/dist/starters/preact/design-system/components/Identity/Identity.tsx +0 -146
- package/dist/starters/preact/design-system/components/Overlays/Menu/Menu.ads.scenario.tsx +0 -27
- package/dist/starters/preact/design-system/components/Overlays/Menu/Menu.tsx +0 -194
- package/dist/starters/preact/design-system/components/Overlays/Popover/Popover.ads.scenario.tsx +0 -19
- package/dist/starters/preact/design-system/components/Overlays/Popover/Popover.tsx +0 -37
- package/dist/starters/preact/design-system/controllers/FormField/FormField.ads.behavior.ts +0 -70
- package/dist/starters/preact/design-system/controllers/FormField/FormField.behavior.spec.ts +0 -237
- package/dist/starters/preact/design-system/controllers/FormField/FormField.ts +0 -343
- package/dist/starters/preact/design-system/controllers/FormField/useFormField.ts +0 -70
- package/dist/starters/preact/design-system/controllers/Palette/Palette.ts +0 -165
- package/dist/starters/preact/design-system/foundation.ads.ts +0 -22
- package/dist/starters/preact/design-system/index.ts +0 -51
- package/dist/starters/preact/design-system/mocks/ConstructionProofs/ConstructionProofs.ads.fixture.ts +0 -5
- package/dist/starters/preact/design-system/mocks/ConstructionProofs/ConstructionProofs.ads.scenario.tsx +0 -22
- package/dist/starters/preact/design-system/mocks/Inspector/Inspector.ads.fixture.ts +0 -12
- package/dist/starters/preact/design-system/mocks/Inspector/Inspector.ads.scenario.tsx +0 -21
- package/dist/starters/preact/design-system/mocks/Workspace/Layouts.ads.scenario.tsx +0 -24
- package/dist/starters/preact/design-system/mocks/Workspace/Media.ads.scenario.tsx +0 -24
- package/dist/starters/preact/design-system/mocks/Workspace/Stress.ads.scenario.tsx +0 -36
- package/dist/starters/preact/design-system/mocks/Workspace/Workspace.ads.fixture.ts +0 -13
- package/dist/starters/preact/design-system/mocks/Workspace/Workspace.ads.scenario.tsx +0 -27
- package/dist/starters/preact/design-system/mocks/Workspace/media/ads.svg +0 -1
- package/dist/starters/preact/design-system/palette.generated.ts +0 -188
- package/dist/starters/preact/design-system/patterns/ArtworkCatalogue/ArtworkCatalogue/ArtworkCatalogue.tsx +0 -73
- package/dist/starters/preact/design-system/patterns/ConstructionWorkbench/ConstructionWorkbench/ConstructionWorkbench.ads.scenario.tsx +0 -23
- package/dist/starters/preact/design-system/patterns/ConstructionWorkbench/ConstructionWorkbench/ConstructionWorkbench.tsx +0 -94
- package/dist/starters/preact/design-system/patterns/Forms/InviteMember/InviteMember.ads.scenario.tsx +0 -21
- package/dist/starters/preact/design-system/patterns/Forms/InviteMember/InviteMember.tsx +0 -137
- package/dist/starters/preact/design-system/patterns/Inspector/Inspector/Inspector.ads.scenario.tsx +0 -22
- package/dist/starters/preact/design-system/patterns/Inspector/Inspector/Inspector.tsx +0 -248
- package/dist/starters/preact/design-system/patterns/Shell/Shell.ads.scenario.tsx +0 -26
- package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +0 -268
- package/dist/starters/preact/design-system/patterns/Workspace/Workspace/Workspace.ads.scenario.tsx +0 -28
- package/dist/starters/preact/design-system/patterns/Workspace/Workspace/Workspace.tsx +0 -105
- package/dist/starters/preact/design-system/patterns/Workspace/Workspace/WorkspacePanels.tsx +0 -179
- package/dist/starters/preact/design-system/profiles/Containers/containers.ads.ts +0 -67
- package/dist/starters/preact/design-system/profiles/Containers/frames.ads.ts +0 -32
- package/dist/starters/preact/design-system/profiles/Containers/geometry.ads.ts +0 -30
- package/dist/starters/preact/design-system/profiles/Containers/spacing.ads.ts +0 -26
- package/dist/starters/preact/design-system/profiles/Controls/controls.ads.ts +0 -157
- package/dist/starters/preact/design-system/profiles/Controls/frames.ads.ts +0 -50
- package/dist/starters/preact/design-system/profiles/Controls/spacing.ads.ts +0 -29
- package/dist/starters/preact/design-system/profiles/Focus/keyboard.ads.ts +0 -13
- package/dist/starters/preact/design-system/profiles/Identity/identity.ads.ts +0 -25
- package/dist/starters/preact/design-system/profiles/Identity/spacing.ads.ts +0 -22
- package/dist/starters/preact/design-system/profiles/Layout/grid.ads.ts +0 -69
- package/dist/starters/preact/design-system/profiles/Layout/inspector.ads.ts +0 -146
- package/dist/starters/preact/design-system/profiles/Layout/overlays.ads.ts +0 -94
- package/dist/starters/preact/design-system/profiles/Layout/regions.ads.ts +0 -296
- package/dist/starters/preact/design-system/profiles/Motion/feedback.ads.ts +0 -92
- package/dist/starters/preact/design-system/profiles/Surfaces/controls.ads.ts +0 -142
- package/dist/starters/preact/design-system/profiles/Surfaces/document.ads.ts +0 -2
- package/dist/starters/preact/design-system/profiles/Surfaces/materials.ads.ts +0 -18
- package/dist/starters/preact/design-system/profiles/Surfaces/surfaces.ads.ts +0 -48
- package/dist/starters/preact/design-system/profiles/Typography/details.ads.ts +0 -19
- package/dist/starters/preact/design-system/profiles/Typography/document.ads.ts +0 -2
- package/dist/starters/preact/design-system/profiles/Typography/headings.ads.ts +0 -15
- package/dist/starters/preact/design-system/profiles/Typography/text.ads.ts +0 -73
- package/dist/starters/preact/design-system/profiles/Visuals/artwork.ads.ts +0 -46
- package/dist/starters/preact/design-system/profiles/Visuals/charts.ads.ts +0 -31
- package/dist/starters/preact/design-system/profiles/Visuals/content.ads.ts +0 -52
- package/dist/starters/preact/design-system/profiles/Visuals/glyphs.ads.ts +0 -35
- package/dist/starters/preact/design-system/profiles/Visuals/identity.ads.ts +0 -24
- package/dist/starters/preact/design-system/tokens/Artwork/paint.ads.css +0 -7
- package/dist/starters/preact/design-system/tokens/Artwork/visual-size.ads.css +0 -12
- package/dist/starters/preact/design-system/tokens/Brand/paint.ads.css +0 -7
- package/dist/starters/preact/design-system/tokens/Charts/paint.ads.css +0 -19
- package/dist/starters/preact/design-system/tokens/Containers/border-width.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Containers/content-gap.ads.css +0 -5
- package/dist/starters/preact/design-system/tokens/Containers/frame-inset.ads.css +0 -6
- package/dist/starters/preact/design-system/tokens/Containers/frame-size.ads.css +0 -11
- package/dist/starters/preact/design-system/tokens/Containers/radius.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Controls/border-width.ads.css +0 -4
- package/dist/starters/preact/design-system/tokens/Controls/content-gap.ads.css +0 -6
- package/dist/starters/preact/design-system/tokens/Controls/control-min-size.ads.css +0 -17
- package/dist/starters/preact/design-system/tokens/Controls/frame-inset.ads.css +0 -21
- package/dist/starters/preact/design-system/tokens/Controls/radius.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Controls/target-min-size.ads.css +0 -2
- package/dist/starters/preact/design-system/tokens/Controls/visual-size.ads.css +0 -2
- package/dist/starters/preact/design-system/tokens/Focus/border-width.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Focus/focus-offset.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Foundation/spacing.ads.css +0 -20
- package/dist/starters/preact/design-system/tokens/Grid/grid-gutter.ads.css +0 -6
- package/dist/starters/preact/design-system/tokens/Grid/layer.ads.css +0 -2
- package/dist/starters/preact/design-system/tokens/Grid/layout-size.ads.css +0 -15
- package/dist/starters/preact/design-system/tokens/Grid/spacing.ads.css +0 -12
- package/dist/starters/preact/design-system/tokens/Grid/track-count.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Identity/content-gap.ads.css +0 -6
- package/dist/starters/preact/design-system/tokens/Identity/visual-size.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Motion/duration.ads.css +0 -6
- package/dist/starters/preact/design-system/tokens/Motion/easing.ads.css +0 -5
- package/dist/starters/preact/design-system/tokens/Motion/motion-angle.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Motion/motion-distance.ads.css +0 -2
- package/dist/starters/preact/design-system/tokens/Motion/motion-scale.ads.css +0 -9
- package/dist/starters/preact/design-system/tokens/Surfaces/blur.ads.css +0 -2
- package/dist/starters/preact/design-system/tokens/Surfaces/gradient.ads.css +0 -2
- package/dist/starters/preact/design-system/tokens/Surfaces/opacity.ads.css +0 -2
- package/dist/starters/preact/design-system/tokens/Surfaces/paint.ads.css +0 -58
- package/dist/starters/preact/design-system/tokens/Surfaces/shadow.ads.css +0 -20
- package/dist/starters/preact/design-system/tokens/Typography/font-family.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Typography/font-features.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Typography/font-size.ads.css +0 -9
- package/dist/starters/preact/design-system/tokens/Typography/font-stretch.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Typography/font-variations.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Typography/font-weight.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Typography/letter-spacing.ads.css +0 -1
- package/dist/starters/preact/design-system/tokens/Typography/line-height.ads.css +0 -11
- package/dist/starters/preact/design-system/tokens/Typography/word-spacing.ads.css +0 -1
- package/dist/starters/preact/starter.json +0 -11
- package/dist/starters/react/design-system/assets/avatars/avatar.ads.ts +0 -10
- package/dist/starters/react/design-system/assets/avatars/member.svg +0 -1
- package/dist/starters/react/design-system/assets/brand/emblem.ads.ts +0 -18
- package/dist/starters/react/design-system/assets/brand/emblem.svg +0 -4
- package/dist/starters/react/design-system/assets/brand/iris-emblem.ads.ts +0 -14
- package/dist/starters/react/design-system/assets/brand/iris-emblem.svg +0 -4
- package/dist/starters/react/design-system/assets/brand/mark.ads.ts +0 -14
- package/dist/starters/react/design-system/assets/brand/mark.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/arrow.ads.ts +0 -14
- package/dist/starters/react/design-system/assets/glyphs/arrow.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/chevron-20.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/chevron-24.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/chevron.ads.ts +0 -20
- package/dist/starters/react/design-system/assets/glyphs/close.ads.ts +0 -13
- package/dist/starters/react/design-system/assets/glyphs/close.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/favorite.ads.ts +0 -23
- package/dist/starters/react/design-system/assets/glyphs/favorite.normal.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/favorite.selected.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/search.ads.ts +0 -10
- package/dist/starters/react/design-system/assets/glyphs/search.svg +0 -1
- package/dist/starters/react/design-system/assets/illustrations/journey.ads.ts +0 -32
- package/dist/starters/react/design-system/assets/illustrations/journey.contrast.svg +0 -6
- package/dist/starters/react/design-system/assets/illustrations/journey.dark.svg +0 -13
- package/dist/starters/react/design-system/assets/illustrations/journey.light.svg +0 -13
- package/dist/starters/react/design-system/assets/logos/harbor-pay.ads.ts +0 -17
- package/dist/starters/react/design-system/assets/logos/harbor-pay.dark.svg +0 -10
- package/dist/starters/react/design-system/assets/logos/harbor-pay.light.svg +0 -10
- package/dist/starters/react/design-system/assets/logos/lumen-cloud.ads.ts +0 -15
- package/dist/starters/react/design-system/assets/logos/lumen-cloud.dark.svg +0 -9
- package/dist/starters/react/design-system/assets/logos/lumen-cloud.light.svg +0 -9
- package/dist/starters/react/design-system/assets/status/error.svg +0 -1
- package/dist/starters/react/design-system/assets/status/outcomes.ads.ts +0 -31
- package/dist/starters/react/design-system/assets/status/status.ads.ts +0 -16
- package/dist/starters/react/design-system/assets/status/success.svg +0 -1
- package/dist/starters/react/design-system/assets/status/sync-status.ads.ts +0 -14
- package/dist/starters/react/design-system/assets/status/sync-status.svg +0 -7
- package/dist/starters/react/design-system/assets/status/warning.svg +0 -1
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.scenario.tsx +0 -12
- package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +0 -198
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +0 -95
- package/dist/starters/react/design-system/components/Actions/ToggleTile/ToggleTile.ads.scenario.tsx +0 -22
- package/dist/starters/react/design-system/components/Actions/ToggleTile/ToggleTile.tsx +0 -60
- package/dist/starters/react/design-system/components/Containers/Disclosure/Disclosure.ads.scenario.tsx +0 -24
- package/dist/starters/react/design-system/components/Containers/Disclosure/Disclosure.tsx +0 -50
- package/dist/starters/react/design-system/components/Content/Artwork/Artwork.ads.scenario.tsx +0 -8
- package/dist/starters/react/design-system/components/Content/Artwork/Artwork.tsx +0 -110
- package/dist/starters/react/design-system/components/Content/BarChart/BarChart.ads.scenario.tsx +0 -25
- package/dist/starters/react/design-system/components/Content/BarChart/BarChart.tsx +0 -72
- package/dist/starters/react/design-system/components/Content/GuideGrid/GuideGrid.ads.scenario.tsx +0 -8
- package/dist/starters/react/design-system/components/Content/GuideGrid/GuideGrid.tsx +0 -43
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +0 -21
- package/dist/starters/react/design-system/components/Content/Icon/Icon.tsx +0 -41
- package/dist/starters/react/design-system/components/Content/Icon/glyphs/arrow.tsx +0 -10
- package/dist/starters/react/design-system/components/Content/Icon/glyphs/close.tsx +0 -10
- package/dist/starters/react/design-system/components/Content/Icon/glyphs/search.tsx +0 -10
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.fixture.ts +0 -9
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.scenario.tsx +0 -12
- package/dist/starters/react/design-system/components/Content/Image/Image.tsx +0 -83
- package/dist/starters/react/design-system/components/Content/InspectedGlyph/InspectedGlyph.ads.scenario.tsx +0 -27
- package/dist/starters/react/design-system/components/Content/InspectedGlyph/InspectedGlyph.tsx +0 -46
- package/dist/starters/react/design-system/components/Content/PartnerLogo/PartnerLogo.ads.scenario.tsx +0 -17
- package/dist/starters/react/design-system/components/Content/PartnerLogo/PartnerLogo.tsx +0 -41
- package/dist/starters/react/design-system/components/Content/StatusIcon/StatusIcon.ads.scenario.tsx +0 -20
- package/dist/starters/react/design-system/components/Content/StatusIcon/StatusIcon.tsx +0 -37
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.scenario.tsx +0 -24
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.tsx +0 -173
- package/dist/starters/react/design-system/components/Identity/Identity.ads.scenario.tsx +0 -13
- package/dist/starters/react/design-system/components/Identity/Identity.tsx +0 -146
- package/dist/starters/react/design-system/components/Overlays/Menu/Menu.ads.scenario.tsx +0 -27
- package/dist/starters/react/design-system/components/Overlays/Menu/Menu.tsx +0 -194
- package/dist/starters/react/design-system/components/Overlays/Popover/Popover.ads.scenario.tsx +0 -19
- package/dist/starters/react/design-system/components/Overlays/Popover/Popover.tsx +0 -37
- package/dist/starters/react/design-system/controllers/FormField/FormField.ads.behavior.ts +0 -70
- package/dist/starters/react/design-system/controllers/FormField/FormField.behavior.spec.ts +0 -237
- package/dist/starters/react/design-system/controllers/FormField/FormField.ts +0 -343
- package/dist/starters/react/design-system/controllers/FormField/useFormField.ts +0 -70
- package/dist/starters/react/design-system/controllers/Palette/Palette.ts +0 -165
- package/dist/starters/react/design-system/foundation.ads.ts +0 -22
- package/dist/starters/react/design-system/index.ts +0 -51
- package/dist/starters/react/design-system/mocks/ConstructionProofs/ConstructionProofs.ads.fixture.ts +0 -5
- package/dist/starters/react/design-system/mocks/ConstructionProofs/ConstructionProofs.ads.scenario.tsx +0 -22
- package/dist/starters/react/design-system/mocks/Inspector/Inspector.ads.fixture.ts +0 -12
- package/dist/starters/react/design-system/mocks/Inspector/Inspector.ads.scenario.tsx +0 -21
- package/dist/starters/react/design-system/mocks/Workspace/Layouts.ads.scenario.tsx +0 -24
- package/dist/starters/react/design-system/mocks/Workspace/Media.ads.scenario.tsx +0 -24
- package/dist/starters/react/design-system/mocks/Workspace/Stress.ads.scenario.tsx +0 -36
- package/dist/starters/react/design-system/mocks/Workspace/Workspace.ads.fixture.ts +0 -13
- package/dist/starters/react/design-system/mocks/Workspace/Workspace.ads.scenario.tsx +0 -27
- package/dist/starters/react/design-system/mocks/Workspace/media/ads.svg +0 -1
- package/dist/starters/react/design-system/palette.generated.ts +0 -188
- package/dist/starters/react/design-system/patterns/ArtworkCatalogue/ArtworkCatalogue/ArtworkCatalogue.tsx +0 -73
- package/dist/starters/react/design-system/patterns/ConstructionWorkbench/ConstructionWorkbench/ConstructionWorkbench.ads.scenario.tsx +0 -23
- package/dist/starters/react/design-system/patterns/ConstructionWorkbench/ConstructionWorkbench/ConstructionWorkbench.tsx +0 -94
- package/dist/starters/react/design-system/patterns/Forms/InviteMember/InviteMember.ads.scenario.tsx +0 -21
- package/dist/starters/react/design-system/patterns/Forms/InviteMember/InviteMember.tsx +0 -137
- package/dist/starters/react/design-system/patterns/Inspector/Inspector/Inspector.ads.scenario.tsx +0 -22
- package/dist/starters/react/design-system/patterns/Inspector/Inspector/Inspector.tsx +0 -248
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +0 -26
- package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +0 -268
- package/dist/starters/react/design-system/patterns/Workspace/Workspace/Workspace.ads.scenario.tsx +0 -28
- package/dist/starters/react/design-system/patterns/Workspace/Workspace/Workspace.tsx +0 -105
- package/dist/starters/react/design-system/patterns/Workspace/Workspace/WorkspacePanels.tsx +0 -179
- package/dist/starters/react/design-system/profiles/Containers/containers.ads.ts +0 -67
- package/dist/starters/react/design-system/profiles/Containers/frames.ads.ts +0 -32
- package/dist/starters/react/design-system/profiles/Containers/geometry.ads.ts +0 -30
- package/dist/starters/react/design-system/profiles/Containers/spacing.ads.ts +0 -26
- package/dist/starters/react/design-system/profiles/Controls/controls.ads.ts +0 -157
- package/dist/starters/react/design-system/profiles/Controls/frames.ads.ts +0 -50
- package/dist/starters/react/design-system/profiles/Controls/spacing.ads.ts +0 -29
- package/dist/starters/react/design-system/profiles/Focus/keyboard.ads.ts +0 -13
- package/dist/starters/react/design-system/profiles/Identity/identity.ads.ts +0 -25
- package/dist/starters/react/design-system/profiles/Identity/spacing.ads.ts +0 -22
- package/dist/starters/react/design-system/profiles/Layout/grid.ads.ts +0 -69
- package/dist/starters/react/design-system/profiles/Layout/inspector.ads.ts +0 -146
- package/dist/starters/react/design-system/profiles/Layout/overlays.ads.ts +0 -94
- package/dist/starters/react/design-system/profiles/Layout/regions.ads.ts +0 -296
- package/dist/starters/react/design-system/profiles/Motion/feedback.ads.ts +0 -92
- package/dist/starters/react/design-system/profiles/Surfaces/controls.ads.ts +0 -142
- package/dist/starters/react/design-system/profiles/Surfaces/document.ads.ts +0 -2
- package/dist/starters/react/design-system/profiles/Surfaces/materials.ads.ts +0 -18
- package/dist/starters/react/design-system/profiles/Surfaces/surfaces.ads.ts +0 -48
- package/dist/starters/react/design-system/profiles/Typography/details.ads.ts +0 -19
- package/dist/starters/react/design-system/profiles/Typography/document.ads.ts +0 -2
- package/dist/starters/react/design-system/profiles/Typography/headings.ads.ts +0 -15
- package/dist/starters/react/design-system/profiles/Typography/text.ads.ts +0 -73
- package/dist/starters/react/design-system/profiles/Visuals/artwork.ads.ts +0 -46
- package/dist/starters/react/design-system/profiles/Visuals/charts.ads.ts +0 -31
- package/dist/starters/react/design-system/profiles/Visuals/content.ads.ts +0 -52
- package/dist/starters/react/design-system/profiles/Visuals/glyphs.ads.ts +0 -35
- package/dist/starters/react/design-system/profiles/Visuals/identity.ads.ts +0 -24
- package/dist/starters/react/design-system/tokens/Artwork/paint.ads.css +0 -7
- package/dist/starters/react/design-system/tokens/Artwork/visual-size.ads.css +0 -12
- package/dist/starters/react/design-system/tokens/Brand/paint.ads.css +0 -7
- package/dist/starters/react/design-system/tokens/Charts/paint.ads.css +0 -19
- package/dist/starters/react/design-system/tokens/Containers/border-width.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Containers/content-gap.ads.css +0 -5
- package/dist/starters/react/design-system/tokens/Containers/frame-inset.ads.css +0 -6
- package/dist/starters/react/design-system/tokens/Containers/frame-size.ads.css +0 -11
- package/dist/starters/react/design-system/tokens/Containers/radius.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Controls/border-width.ads.css +0 -4
- package/dist/starters/react/design-system/tokens/Controls/content-gap.ads.css +0 -6
- package/dist/starters/react/design-system/tokens/Controls/control-min-size.ads.css +0 -17
- package/dist/starters/react/design-system/tokens/Controls/frame-inset.ads.css +0 -21
- package/dist/starters/react/design-system/tokens/Controls/radius.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Controls/target-min-size.ads.css +0 -2
- package/dist/starters/react/design-system/tokens/Controls/visual-size.ads.css +0 -2
- package/dist/starters/react/design-system/tokens/Focus/border-width.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Focus/focus-offset.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Foundation/spacing.ads.css +0 -20
- package/dist/starters/react/design-system/tokens/Grid/grid-gutter.ads.css +0 -6
- package/dist/starters/react/design-system/tokens/Grid/layer.ads.css +0 -2
- package/dist/starters/react/design-system/tokens/Grid/layout-size.ads.css +0 -15
- package/dist/starters/react/design-system/tokens/Grid/spacing.ads.css +0 -12
- package/dist/starters/react/design-system/tokens/Grid/track-count.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Identity/content-gap.ads.css +0 -6
- package/dist/starters/react/design-system/tokens/Identity/visual-size.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Motion/duration.ads.css +0 -6
- package/dist/starters/react/design-system/tokens/Motion/easing.ads.css +0 -5
- package/dist/starters/react/design-system/tokens/Motion/motion-angle.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Motion/motion-distance.ads.css +0 -2
- package/dist/starters/react/design-system/tokens/Motion/motion-scale.ads.css +0 -9
- package/dist/starters/react/design-system/tokens/Surfaces/blur.ads.css +0 -2
- package/dist/starters/react/design-system/tokens/Surfaces/gradient.ads.css +0 -2
- package/dist/starters/react/design-system/tokens/Surfaces/opacity.ads.css +0 -2
- package/dist/starters/react/design-system/tokens/Surfaces/paint.ads.css +0 -58
- package/dist/starters/react/design-system/tokens/Surfaces/shadow.ads.css +0 -20
- package/dist/starters/react/design-system/tokens/Typography/font-family.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Typography/font-features.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Typography/font-size.ads.css +0 -9
- package/dist/starters/react/design-system/tokens/Typography/font-stretch.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Typography/font-variations.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Typography/font-weight.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Typography/letter-spacing.ads.css +0 -1
- package/dist/starters/react/design-system/tokens/Typography/line-height.ads.css +0 -11
- package/dist/starters/react/design-system/tokens/Typography/word-spacing.ads.css +0 -1
- package/dist/starters/react/starter.json +0 -11
- package/docs/STARTER.md +0 -167
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
// Form fields: when a constraint error shows, how it reaches assistive
|
|
2
|
-
// technology, and autofill. Framework-neutral; useFormField.ts binds it from a
|
|
3
|
-
// component. Nothing here renders markup or writes styling: the bridge mirrors
|
|
4
|
-
// state onto the field's owner root as data attributes its recipe selects
|
|
5
|
-
// (`[data-user-invalid]`, `[data-user-valid]`, `[data-autofill]`), and onto the
|
|
6
|
-
// input as ARIA state.
|
|
7
|
-
//
|
|
8
|
-
// Timing. A constraint error (required, type, pattern, length) shows only after
|
|
9
|
-
// the user has interacted: committed an edit (change), left an edited field
|
|
10
|
-
// (blur) or tried to submit the form (the browser's `invalid` event). Before
|
|
11
|
-
// that the field is pristine: `aria-invalid="false"`, no error linked, nothing
|
|
12
|
-
// announced. Where the browser supports `:user-invalid`/`:user-valid`, its own
|
|
13
|
-
// notion of interaction counts too; elsewhere the tracked events alone decide
|
|
14
|
-
// (the fallback). An error the application supplies (a server's verdict) shows
|
|
15
|
-
// at once, whatever the interaction.
|
|
16
|
-
//
|
|
17
|
-
// Accessibility. `aria-invalid` is always explicit ("true" or "false"); the
|
|
18
|
-
// error message's id is in `aria-describedby` only while it is shown; an error
|
|
19
|
-
// that appears on blur or commit is announced once through the form's one polite
|
|
20
|
-
// live region (bindForm's `announce`); after a failed submit, focus moves to the
|
|
21
|
-
// form's error summary when it renders one, else to the first invalid field.
|
|
22
|
-
//
|
|
23
|
-
// Autofill. `:autofill` (`:-webkit-autofill` in older engines) is read with
|
|
24
|
-
// `matches()` when the field is bound and on every input, change, focus and blur:
|
|
25
|
-
// no animation hook and no styling. A browser that fills before any interaction
|
|
26
|
-
// (Chromium's saved credentials) keeps the value from script until the user
|
|
27
|
-
// interacts, so the state appears then; the browser's own autofill styling covers
|
|
28
|
-
// the time before.
|
|
29
|
-
|
|
30
|
-
/** What happened to a field, with its constraint validity at that moment. */
|
|
31
|
-
export type FieldEvent =
|
|
32
|
-
/** An edit (every keystroke). */
|
|
33
|
-
| { readonly kind: "input"; readonly invalid: boolean }
|
|
34
|
-
/** A committed edit (text fields commit on blur, others on each change). */
|
|
35
|
-
| { readonly kind: "change"; readonly invalid: boolean }
|
|
36
|
-
/** Focus left the field. */
|
|
37
|
-
| { readonly kind: "blur"; readonly invalid: boolean }
|
|
38
|
-
/** A submit or `checkValidity()` found the field invalid. */
|
|
39
|
-
| { readonly kind: "invalid" }
|
|
40
|
-
/** The form was reset: the field is pristine again. */
|
|
41
|
-
| { readonly kind: "reset"; readonly invalid: boolean };
|
|
42
|
-
|
|
43
|
-
/** A field's tracked interaction, independent of the browser's `:user-invalid`. */
|
|
44
|
-
export interface FieldState {
|
|
45
|
-
/** Edited since it was bound or last reset. */
|
|
46
|
-
readonly dirty: boolean;
|
|
47
|
-
/** The user has finished an interaction: an error may show. */
|
|
48
|
-
readonly interacted: boolean;
|
|
49
|
-
/** It fails its constraints now. */
|
|
50
|
-
readonly invalid: boolean;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const initialFieldState = (invalid: boolean): FieldState => ({ dirty: false, interacted: false, invalid });
|
|
54
|
-
|
|
55
|
-
/** The tracked state after an event: interaction starts with a commit, a blur after an edit, or a failed submit. */
|
|
56
|
-
export function fieldStep(state: FieldState, event: FieldEvent): FieldState {
|
|
57
|
-
switch (event.kind) {
|
|
58
|
-
case "input":
|
|
59
|
-
return { ...state, dirty: true, invalid: event.invalid };
|
|
60
|
-
case "change":
|
|
61
|
-
return { dirty: true, interacted: true, invalid: event.invalid };
|
|
62
|
-
case "blur":
|
|
63
|
-
return { ...state, interacted: state.interacted || state.dirty, invalid: event.invalid };
|
|
64
|
-
case "invalid":
|
|
65
|
-
return { ...state, interacted: true, invalid: true };
|
|
66
|
-
case "reset":
|
|
67
|
-
return initialFieldState(event.invalid);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** Where an error shown comes from. */
|
|
72
|
-
export type ErrorSource = "application" | "constraint";
|
|
73
|
-
|
|
74
|
-
/** What a field shows and exposes. */
|
|
75
|
-
export type FieldView =
|
|
76
|
-
/** No interaction yet and no application error: no state, `aria-invalid="false"`. */
|
|
77
|
-
| { readonly kind: "pristine"; readonly autofill: boolean }
|
|
78
|
-
/** Interacted and satisfies its constraints. */
|
|
79
|
-
| { readonly kind: "valid"; readonly autofill: boolean }
|
|
80
|
-
/** An error is shown: its message, linked by `aria-describedby`. */
|
|
81
|
-
| { readonly kind: "invalid"; readonly source: ErrorSource; readonly message: string; readonly autofill: boolean };
|
|
82
|
-
|
|
83
|
-
export interface ViewInputs {
|
|
84
|
-
/** The application's error (a server verdict): shown at once. Empty or null: none. */
|
|
85
|
-
readonly error: string | null;
|
|
86
|
-
/** The message for a constraint failure (the application's, else the browser's `validationMessage`). */
|
|
87
|
-
readonly constraintMessage: string;
|
|
88
|
-
/** The browser's own interaction flag (`:user-invalid` or `:user-valid` matches); null where it is unsupported or not consulted. */
|
|
89
|
-
readonly nativeInteracted: boolean | null;
|
|
90
|
-
readonly autofill: boolean;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** The view of the constraints alone: a constraint error after interaction, else valid or pristine. */
|
|
94
|
-
export function constraintView(state: FieldState, inputs: Omit<ViewInputs, "error">): FieldView {
|
|
95
|
-
const { autofill } = inputs;
|
|
96
|
-
const interacted = state.interacted || inputs.nativeInteracted === true;
|
|
97
|
-
if (!interacted) return { kind: "pristine", autofill };
|
|
98
|
-
if (state.invalid) return { kind: "invalid", source: "constraint", message: inputs.constraintMessage, autofill };
|
|
99
|
-
return { kind: "valid", autofill };
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** An application error over a constraint view: shown at once, whatever the interaction. */
|
|
103
|
-
export function withApplicationError(view: FieldView, error: string | null): FieldView {
|
|
104
|
-
return error !== null && error !== "" ? { kind: "invalid", source: "application", message: error, autofill: view.autofill } : view;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** The view of a tracked state: an application error first, then a constraint error after interaction. */
|
|
108
|
-
export function fieldView(state: FieldState, inputs: ViewInputs): FieldView {
|
|
109
|
-
return withApplicationError(constraintView(state, inputs), inputs.error);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** The input's `aria-invalid`: always explicit. */
|
|
113
|
-
export const ariaInvalid = (view: FieldView): "true" | "false" => (view.kind === "invalid" ? "true" : "false");
|
|
114
|
-
|
|
115
|
-
/** The ids the input is described by: the error's only while it is shown (it replaces the help text). Null for none. */
|
|
116
|
-
export function describedBy(view: FieldView, ids: { readonly help: string | null; readonly error: string }): string | null {
|
|
117
|
-
if (view.kind === "invalid") return ids.error;
|
|
118
|
-
return ids.help;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** Whether a change of view is announced: an error that appears (or changes) on blur or commit; never on typing, submit or reset. */
|
|
122
|
-
export function announces(before: FieldView, after: FieldView, event: FieldEvent): boolean {
|
|
123
|
-
if (event.kind !== "blur" && event.kind !== "change") return false;
|
|
124
|
-
if (after.kind !== "invalid") return false;
|
|
125
|
-
return before.kind !== "invalid" || before.message !== after.message;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** The text announced for a field's error. */
|
|
129
|
-
export const announcement = (label: string, message: string): string => `${label}: ${message}`;
|
|
130
|
-
|
|
131
|
-
const sameView = (a: FieldView, b: FieldView): boolean =>
|
|
132
|
-
a.kind === b.kind && a.autofill === b.autofill && (a.kind !== "invalid" || (b.kind === "invalid" && a.source === b.source && a.message === b.message));
|
|
133
|
-
|
|
134
|
-
// --- DOM binding ----------------------------------------------------------
|
|
135
|
-
|
|
136
|
-
export type FieldControl = HTMLInputElement | HTMLTextAreaElement;
|
|
137
|
-
|
|
138
|
-
export interface FieldOptions {
|
|
139
|
-
/** The field's visible label, which an announcement starts with. */
|
|
140
|
-
readonly label: string;
|
|
141
|
-
/** The help text's id while help is shown; null without help. */
|
|
142
|
-
readonly helpId: string | null;
|
|
143
|
-
/** The error message's id: the owner renders the message under it while the view is invalid. */
|
|
144
|
-
readonly errorId: string;
|
|
145
|
-
/** The application's error; shown at once. */
|
|
146
|
-
readonly error: string | null;
|
|
147
|
-
/** The message for a constraint failure; null uses the browser's `validationMessage`. */
|
|
148
|
-
readonly message: string | null;
|
|
149
|
-
/** Keep the browser's own validation bubble on submit; by default the bridge's error replaces it. */
|
|
150
|
-
readonly native: boolean;
|
|
151
|
-
/** Called when the constraint view changes. The application's error is not part of it: the owner overlays it at
|
|
152
|
-
* render (`withApplicationError`), so a changed error shows in the same render as the prop. */
|
|
153
|
-
readonly onView: (constraint: FieldView) => void;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export interface FieldBinding {
|
|
157
|
-
/** The view the binding writes (the application's error included). */
|
|
158
|
-
readonly view: () => FieldView;
|
|
159
|
-
/** The constraint view alone (what `onView` reports). */
|
|
160
|
-
readonly constraint: () => FieldView;
|
|
161
|
-
/** New options from the owner's props; re-derives the view. */
|
|
162
|
-
readonly update: (options: FieldOptions) => void;
|
|
163
|
-
readonly dispose: () => void;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/** Whether this browser matches `:user-invalid`; the tracked events alone decide where it does not. */
|
|
167
|
-
export function supportsUserValidity(): boolean {
|
|
168
|
-
return typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("selector(:user-invalid)");
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const matchesSelector = (element: Element, selector: string): boolean | null => {
|
|
172
|
-
try {
|
|
173
|
-
return element.matches(selector);
|
|
174
|
-
} catch {
|
|
175
|
-
return null; // A selector this engine does not parse.
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
/** Whether the browser has autofilled the control (`:autofill`, else the prefixed form). */
|
|
180
|
-
export function autofilled(control: Element): boolean {
|
|
181
|
-
return matchesSelector(control, ":autofill") ?? matchesSelector(control, ":-webkit-autofill") ?? false;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Binds a field: listens to input, change, blur, invalid on the control and
|
|
186
|
-
* reset on its form; mirrors the view onto `root` (`data-user-invalid`,
|
|
187
|
-
* `data-user-valid`, `data-autofill`) and the control (`aria-invalid`,
|
|
188
|
-
* `aria-describedby`); announces blur-triggered errors through the form's
|
|
189
|
-
* binding. `dispose` removes every listener and timer.
|
|
190
|
-
*/
|
|
191
|
-
export function bindFormField(control: FieldControl, root: HTMLElement, initial: FieldOptions): FieldBinding {
|
|
192
|
-
let options = initial;
|
|
193
|
-
const native = supportsUserValidity();
|
|
194
|
-
let state = initialFieldState(!control.validity.valid);
|
|
195
|
-
/** After a reset the browser's flag is stale until the reset completes. */
|
|
196
|
-
let ignoreNative = false;
|
|
197
|
-
let constraint: FieldView = derive();
|
|
198
|
-
let current: FieldView = withApplicationError(constraint, options.error);
|
|
199
|
-
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
200
|
-
|
|
201
|
-
function derive(): FieldView {
|
|
202
|
-
const nativeInteracted = native && !ignoreNative ? (matchesSelector(control, ":user-invalid") ?? false) || (matchesSelector(control, ":user-valid") ?? false) : null;
|
|
203
|
-
return constraintView(state, { constraintMessage: options.message ?? control.validationMessage, nativeInteracted, autofill: autofilled(control) });
|
|
204
|
-
}
|
|
205
|
-
function write(view: FieldView): void {
|
|
206
|
-
root.toggleAttribute("data-user-invalid", view.kind === "invalid");
|
|
207
|
-
root.toggleAttribute("data-user-valid", view.kind === "valid");
|
|
208
|
-
root.toggleAttribute("data-autofill", view.autofill);
|
|
209
|
-
control.setAttribute("aria-invalid", ariaInvalid(view));
|
|
210
|
-
const ids = describedBy(view, { help: options.helpId, error: options.errorId });
|
|
211
|
-
if (ids === null) control.removeAttribute("aria-describedby");
|
|
212
|
-
else control.setAttribute("aria-describedby", ids);
|
|
213
|
-
}
|
|
214
|
-
function apply(event: FieldEvent | null): void {
|
|
215
|
-
if (event !== null) state = fieldStep(state, event);
|
|
216
|
-
const before = current;
|
|
217
|
-
const previous = constraint;
|
|
218
|
-
constraint = derive();
|
|
219
|
-
current = withApplicationError(constraint, options.error);
|
|
220
|
-
write(current);
|
|
221
|
-
if (event !== null && current.kind === "invalid" && announces(before, current, event)) formBindingOf(control)?.announce(announcement(options.label, current.message));
|
|
222
|
-
if (!sameView(previous, constraint)) options.onView(constraint);
|
|
223
|
-
}
|
|
224
|
-
const invalidNow = (): boolean => !control.validity.valid;
|
|
225
|
-
const onInput = (): void => apply({ kind: "input", invalid: invalidNow() });
|
|
226
|
-
const onChange = (): void => apply({ kind: "change", invalid: invalidNow() });
|
|
227
|
-
const onBlur = (): void => apply({ kind: "blur", invalid: invalidNow() });
|
|
228
|
-
const onFocus = (): void => apply(null);
|
|
229
|
-
const onInvalid = (event: Event): void => {
|
|
230
|
-
// The bridge's message replaces the browser's bubble unless the field keeps native validation.
|
|
231
|
-
if (!options.native) event.preventDefault();
|
|
232
|
-
apply({ kind: "invalid" });
|
|
233
|
-
};
|
|
234
|
-
// `reset` fires before the form resets its controls; read them once it has.
|
|
235
|
-
const onReset = (event: Event): void => {
|
|
236
|
-
if (event.target !== control.form) return;
|
|
237
|
-
ignoreNative = true;
|
|
238
|
-
apply({ kind: "reset", invalid: invalidNow() });
|
|
239
|
-
if (timer !== null) clearTimeout(timer);
|
|
240
|
-
timer = setTimeout(() => {
|
|
241
|
-
timer = null;
|
|
242
|
-
ignoreNative = false;
|
|
243
|
-
state = initialFieldState(invalidNow());
|
|
244
|
-
apply(null);
|
|
245
|
-
}, 0);
|
|
246
|
-
};
|
|
247
|
-
const form = control.form;
|
|
248
|
-
control.addEventListener("input", onInput);
|
|
249
|
-
control.addEventListener("change", onChange);
|
|
250
|
-
control.addEventListener("blur", onBlur);
|
|
251
|
-
control.addEventListener("focus", onFocus);
|
|
252
|
-
control.addEventListener("invalid", onInvalid);
|
|
253
|
-
form?.addEventListener("reset", onReset);
|
|
254
|
-
write(current);
|
|
255
|
-
return {
|
|
256
|
-
view: () => current,
|
|
257
|
-
constraint: () => constraint,
|
|
258
|
-
update(next) {
|
|
259
|
-
options = next;
|
|
260
|
-
apply(null);
|
|
261
|
-
},
|
|
262
|
-
dispose() {
|
|
263
|
-
control.removeEventListener("input", onInput);
|
|
264
|
-
control.removeEventListener("change", onChange);
|
|
265
|
-
control.removeEventListener("blur", onBlur);
|
|
266
|
-
control.removeEventListener("focus", onFocus);
|
|
267
|
-
control.removeEventListener("invalid", onInvalid);
|
|
268
|
-
form?.removeEventListener("reset", onReset);
|
|
269
|
-
if (timer !== null) clearTimeout(timer);
|
|
270
|
-
timer = null;
|
|
271
|
-
},
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// --- Form binding ---------------------------------------------------------
|
|
276
|
-
|
|
277
|
-
export interface FormOptions {
|
|
278
|
-
/** The form's error summary, focused after a failed submit when it is rendered; else the first invalid field is. */
|
|
279
|
-
readonly summary: () => HTMLElement | null;
|
|
280
|
-
/** The text for the form's one polite live region (empty clears it). */
|
|
281
|
-
readonly onAnnounce: (text: string) => void;
|
|
282
|
-
/** The controls a failed submit found invalid, in form order (for a summary to list). */
|
|
283
|
-
readonly onInvalidSubmit: (controls: readonly Element[]) => void;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export interface FormBinding {
|
|
287
|
-
readonly announce: (text: string) => void;
|
|
288
|
-
readonly dispose: () => void;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const forms = new WeakMap<HTMLFormElement, FormBinding>();
|
|
292
|
-
|
|
293
|
-
/** The binding of the control's form, when the form is bound. */
|
|
294
|
-
export function formBindingOf(control: FieldControl): FormBinding | undefined {
|
|
295
|
-
const form = control.form;
|
|
296
|
-
return form === null ? undefined : forms.get(form);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Binds a form: owns its one polite live region's text (fields announce through
|
|
301
|
-
* it; a submit or reset clears it) and moves focus after a failed submit to the
|
|
302
|
-
* summary, else to the first invalid control in form order.
|
|
303
|
-
*/
|
|
304
|
-
export function bindForm(form: HTMLFormElement, options: FormOptions): FormBinding {
|
|
305
|
-
const invalid = new Set<Element>();
|
|
306
|
-
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
307
|
-
// `invalid` does not bubble: listen in the capture phase. Every invalid
|
|
308
|
-
// control of one submit is reported in the same task; focus after them.
|
|
309
|
-
const onInvalid = (event: Event): void => {
|
|
310
|
-
const target = event.target as Element | null;
|
|
311
|
-
if (target === null) return;
|
|
312
|
-
invalid.add(target);
|
|
313
|
-
if (timer !== null) return;
|
|
314
|
-
timer = setTimeout(() => {
|
|
315
|
-
timer = null;
|
|
316
|
-
const controls = [...form.elements].filter((element) => invalid.has(element));
|
|
317
|
-
invalid.clear();
|
|
318
|
-
if (controls.length === 0) return;
|
|
319
|
-
options.onInvalidSubmit(controls);
|
|
320
|
-
const summary = options.summary();
|
|
321
|
-
const target = (summary !== null && summary.isConnected ? summary : controls[0]) as Partial<HTMLElement> | undefined;
|
|
322
|
-
target?.focus?.();
|
|
323
|
-
}, 0);
|
|
324
|
-
};
|
|
325
|
-
const clear = (): void => options.onAnnounce("");
|
|
326
|
-
form.addEventListener("invalid", onInvalid, true);
|
|
327
|
-
form.addEventListener("submit", clear);
|
|
328
|
-
form.addEventListener("reset", clear);
|
|
329
|
-
const binding: FormBinding = {
|
|
330
|
-
announce: (text) => options.onAnnounce(text),
|
|
331
|
-
dispose() {
|
|
332
|
-
form.removeEventListener("invalid", onInvalid, true);
|
|
333
|
-
form.removeEventListener("submit", clear);
|
|
334
|
-
form.removeEventListener("reset", clear);
|
|
335
|
-
if (timer !== null) clearTimeout(timer);
|
|
336
|
-
timer = null;
|
|
337
|
-
invalid.clear();
|
|
338
|
-
if (forms.get(form) === binding) forms.delete(form);
|
|
339
|
-
},
|
|
340
|
-
};
|
|
341
|
-
forms.set(form, binding);
|
|
342
|
-
return binding;
|
|
343
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// The form-field bridge (./FormField.ts) bound from a component: the hooks own
|
|
2
|
-
// the binding's lifetime (bound in an effect, disposed on unmount) and hand the
|
|
3
|
-
// component the view it renders its message from. DOM access happens only in
|
|
4
|
-
// effects and event listeners, so a server render is the pristine view, or the
|
|
5
|
-
// application's error.
|
|
6
|
-
import { useEffect, useRef, useState } from "react";
|
|
7
|
-
import { bindForm, bindFormField, withApplicationError, type FieldBinding, type FieldControl, type FieldOptions, type FieldView } from "./FormField";
|
|
8
|
-
|
|
9
|
-
export interface FormFieldOptions {
|
|
10
|
-
readonly label: string;
|
|
11
|
-
readonly helpId: string | null;
|
|
12
|
-
readonly errorId: string;
|
|
13
|
-
readonly error: string | null;
|
|
14
|
-
readonly message: string | null;
|
|
15
|
-
readonly native: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const PRISTINE: FieldView = { kind: "pristine", autofill: false };
|
|
19
|
-
|
|
20
|
-
/** Binds a field: refs for its control and owner root, and the current view. The application's error is overlaid at
|
|
21
|
-
* render, so it shows (and clears) in the same render as the prop; the constraint view follows the binding. */
|
|
22
|
-
export function useFormField<C extends FieldControl, R extends HTMLElement>(options: FormFieldOptions) {
|
|
23
|
-
const control = useRef<C>(null);
|
|
24
|
-
const root = useRef<R>(null);
|
|
25
|
-
const [constraint, setView] = useState<FieldView>(PRISTINE);
|
|
26
|
-
const binding = useRef<FieldBinding | null>(null);
|
|
27
|
-
const latest = useRef<FieldOptions>({ ...options, onView: setView });
|
|
28
|
-
latest.current = { ...options, onView: setView };
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const input = control.current;
|
|
31
|
-
const owner = root.current;
|
|
32
|
-
if (input === null || owner === null) return;
|
|
33
|
-
const bound = bindFormField(input, owner, latest.current);
|
|
34
|
-
binding.current = bound;
|
|
35
|
-
setView(bound.constraint());
|
|
36
|
-
return () => {
|
|
37
|
-
bound.dispose();
|
|
38
|
-
binding.current = null;
|
|
39
|
-
};
|
|
40
|
-
}, []);
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
binding.current?.update(latest.current);
|
|
43
|
-
}, [options.label, options.helpId, options.errorId, options.error, options.message, options.native]);
|
|
44
|
-
return { control, root, view: withApplicationError(constraint, options.error) };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface FormBridgeOptions {
|
|
48
|
-
/** Called with the controls a failed submit found invalid, in form order. */
|
|
49
|
-
readonly onInvalidSubmit?: (controls: readonly Element[]) => void;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** Binds a form: its ref, the text of its one polite live region, and a ref for an optional error summary focused after a failed submit. */
|
|
53
|
-
export function useFormBridge<S extends HTMLElement>(options: FormBridgeOptions = {}) {
|
|
54
|
-
const form = useRef<HTMLFormElement>(null);
|
|
55
|
-
const summary = useRef<S>(null);
|
|
56
|
-
const [announcement, setAnnouncement] = useState("");
|
|
57
|
-
const onInvalidSubmit = useRef(options.onInvalidSubmit);
|
|
58
|
-
onInvalidSubmit.current = options.onInvalidSubmit;
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
const element = form.current;
|
|
61
|
-
if (element === null) return;
|
|
62
|
-
const bound = bindForm(element, {
|
|
63
|
-
summary: () => summary.current,
|
|
64
|
-
onAnnounce: setAnnouncement,
|
|
65
|
-
onInvalidSubmit: (controls) => onInvalidSubmit.current?.(controls),
|
|
66
|
-
});
|
|
67
|
-
return () => bound.dispose();
|
|
68
|
-
}, []);
|
|
69
|
-
return { form, summary, announcement };
|
|
70
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
// Renderer colors for Canvas, WebGL and SVG drawing. Read a palette once per render or
|
|
2
|
-
// context change with paletteFor(element), look colors up inside per-item loops, and
|
|
3
|
-
// redraw from observePalette(element, callback). Nothing here inserts DOM nodes.
|
|
4
|
-
import {
|
|
5
|
-
brands,
|
|
6
|
-
contexts,
|
|
7
|
-
defaultContext,
|
|
8
|
-
palette,
|
|
9
|
-
systemThemes,
|
|
10
|
-
themes,
|
|
11
|
-
type ColorToken,
|
|
12
|
-
type Palette,
|
|
13
|
-
type PaletteColor,
|
|
14
|
-
type PaletteContext,
|
|
15
|
-
} from "../../palette.generated";
|
|
16
|
-
|
|
17
|
-
export type { ColorToken, Palette, PaletteColor, PaletteContext };
|
|
18
|
-
|
|
19
|
-
const themeSelector = themes.map((name) => `[data-theme="${name}"]`).join(", ");
|
|
20
|
-
const brandSelector = brands.map((name) => `[data-brand="${name}"]`).join(", ");
|
|
21
|
-
const darkScheme = "(prefers-color-scheme: dark)";
|
|
22
|
-
|
|
23
|
-
/** The nearest ancestor (or the element itself) matching a selector, crossing shadow roots. */
|
|
24
|
-
function closest(element: Element, selector: string): Element | null {
|
|
25
|
-
let node: Element | null = element;
|
|
26
|
-
while (node) {
|
|
27
|
-
const found = node.closest(selector);
|
|
28
|
-
if (found) return found;
|
|
29
|
-
const root = node.getRootNode();
|
|
30
|
-
node = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.host : null;
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function systemTheme(): string | null {
|
|
36
|
-
// The OS scheme selects a theme only where the generated systemThemes says the token sheets
|
|
37
|
-
// follow it, and only on a root without data-theme.
|
|
38
|
-
if (!systemThemes || typeof matchMedia !== "function" || document.documentElement.hasAttribute("data-theme")) return null;
|
|
39
|
-
return matchMedia(darkScheme).matches ? systemThemes.dark : systemThemes.light;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** The palette context an element renders in: its nearest declared data-theme and data-brand,
|
|
43
|
-
* else the OS color scheme (when systemThemes follows it) or the default theme and brand. */
|
|
44
|
-
export function paletteContext(element: Element): PaletteContext {
|
|
45
|
-
const theme = closest(element, themeSelector)?.getAttribute("data-theme") ?? systemTheme() ?? themes[0];
|
|
46
|
-
const brand = brandSelector ? closest(element, brandSelector)?.getAttribute("data-brand") : null;
|
|
47
|
-
const key = brand && brand !== (brands as readonly string[])[0] ? `${brand}/${theme}` : theme;
|
|
48
|
-
return (contexts as readonly string[]).includes(key) ? (key as PaletteContext) : defaultContext;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Every color token resolved for the element's context. Read it once per render, outside
|
|
52
|
-
* per-node and per-edge loops; it is a static object, so lookups cost nothing. */
|
|
53
|
-
export function paletteFor(element: Element): Palette {
|
|
54
|
-
return palette[paletteContext(element)];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Colors outside the palette, normalized once by one offscreen 2D context.
|
|
58
|
-
const cacheSize = 256;
|
|
59
|
-
const colors = new Map<string, PaletteColor | null>();
|
|
60
|
-
let context2d: OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D | null | undefined;
|
|
61
|
-
|
|
62
|
-
type Subscriber = { element: Element; callback: (palette: Palette, context: PaletteContext) => void; context: PaletteContext };
|
|
63
|
-
const subscribers = new Set<Subscriber>();
|
|
64
|
-
let observer: MutationObserver | null = null;
|
|
65
|
-
let media: MediaQueryList | null = null;
|
|
66
|
-
|
|
67
|
-
function refresh(records?: MutationRecord[]) {
|
|
68
|
-
let changed = false;
|
|
69
|
-
for (const subscriber of subscribers) {
|
|
70
|
-
if (!subscribers.has(subscriber)) continue; // unsubscribed by an earlier callback
|
|
71
|
-
// Only an attribute change on the element or an ancestor can change its context.
|
|
72
|
-
if (records && subscriber.element.getRootNode() === document && !records.some((record) => record.target === subscriber.element || record.target.contains(subscriber.element))) continue;
|
|
73
|
-
const context = paletteContext(subscriber.element);
|
|
74
|
-
if (context === subscriber.context) continue;
|
|
75
|
-
subscriber.context = context;
|
|
76
|
-
changed = true;
|
|
77
|
-
subscriber.callback(palette[context], context);
|
|
78
|
-
}
|
|
79
|
-
if (changed) colors.clear();
|
|
80
|
-
}
|
|
81
|
-
const onMedia = () => refresh();
|
|
82
|
-
|
|
83
|
-
/** Calls back with the new palette whenever the element's effective context changes: a
|
|
84
|
-
* data-theme or data-brand change on it or an ancestor, or the OS color scheme with
|
|
85
|
-
* systemThemes. Returns the unsubscribe function. One shared observer serves all. */
|
|
86
|
-
export function observePalette(element: Element, callback: (palette: Palette, context: PaletteContext) => void): () => void {
|
|
87
|
-
const subscriber: Subscriber = { element, callback, context: paletteContext(element) };
|
|
88
|
-
subscribers.add(subscriber);
|
|
89
|
-
if (!observer && typeof MutationObserver === "function") {
|
|
90
|
-
observer = new MutationObserver((records) => refresh(records));
|
|
91
|
-
observer.observe(document.documentElement, { subtree: true, attributes: true, attributeFilter: ["data-theme", "data-brand"] });
|
|
92
|
-
}
|
|
93
|
-
if (!media && systemThemes && typeof matchMedia === "function") {
|
|
94
|
-
media = matchMedia(darkScheme);
|
|
95
|
-
media.addEventListener("change", onMedia);
|
|
96
|
-
}
|
|
97
|
-
return () => {
|
|
98
|
-
subscribers.delete(subscriber);
|
|
99
|
-
if (subscribers.size) return;
|
|
100
|
-
observer?.disconnect();
|
|
101
|
-
observer = null;
|
|
102
|
-
media?.removeEventListener("change", onMedia);
|
|
103
|
-
media = null;
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function canvas2d() {
|
|
108
|
-
if (context2d !== undefined) return context2d;
|
|
109
|
-
const canvas = typeof OffscreenCanvas === "function" ? new OffscreenCanvas(1, 1) : typeof document !== "undefined" ? Object.assign(document.createElement("canvas"), { width: 1, height: 1 }) : null;
|
|
110
|
-
context2d = (canvas?.getContext("2d", { willReadFrequently: true }) as OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D | null | undefined) ?? null;
|
|
111
|
-
return context2d;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const hex = (value: number) => value.toString(16).padStart(2, "0");
|
|
115
|
-
function fromChannels(r: number, g: number, b: number, a: number): PaletteColor {
|
|
116
|
-
const alpha = Math.round(a * 10000) / 10000;
|
|
117
|
-
return { css: alpha >= 1 ? `#${hex(r)}${hex(g)}${hex(b)}` : `rgba(${r}, ${g}, ${b}, ${alpha})`, rgba: [r, g, b, alpha] };
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function normalize(value: string): PaletteColor | null {
|
|
121
|
-
const ctx = canvas2d();
|
|
122
|
-
if (!ctx) return null;
|
|
123
|
-
// An invalid color leaves fillStyle unchanged; two sentinels tell it apart from a valid one.
|
|
124
|
-
ctx.fillStyle = "#000000";
|
|
125
|
-
ctx.fillStyle = value;
|
|
126
|
-
const first = String(ctx.fillStyle);
|
|
127
|
-
ctx.fillStyle = "#ffffff";
|
|
128
|
-
ctx.fillStyle = value;
|
|
129
|
-
if (first !== String(ctx.fillStyle)) return null;
|
|
130
|
-
const legacy = first.match(/^#([\da-f]{6})$/i) ?? first.match(/^rgba\((\d+), (\d+), (\d+), ([\d.]+)\)$/);
|
|
131
|
-
if (legacy) return legacy.length === 2 ? fromChannels(parseInt(legacy[1].slice(0, 2), 16), parseInt(legacy[1].slice(2, 4), 16), parseInt(legacy[1].slice(4), 16), 1) : fromChannels(Number(legacy[1]), Number(legacy[2]), Number(legacy[3]), Number(legacy[4]));
|
|
132
|
-
// Wider color syntax: draw one pixel; the canvas clips to sRGB.
|
|
133
|
-
ctx.clearRect(0, 0, 1, 1);
|
|
134
|
-
ctx.fillRect(0, 0, 1, 1);
|
|
135
|
-
const [r, g, b, a] = ctx.getImageData(0, 0, 1, 1).data;
|
|
136
|
-
return fromChannels(r, g, b, a / 255);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/** A color for a value outside the palette: a palette token (--name or var(--name)) from the
|
|
140
|
-
* element's context, currentColor or another token from the element's computed style, or any
|
|
141
|
-
* absolute CSS color. Absolute strings are normalized once by an offscreen canvas and kept in a
|
|
142
|
-
* bounded cache; the cache clears when an observed context changes. Null when not a color. */
|
|
143
|
-
export function resolveColor(element: Element, value: string): PaletteColor | null {
|
|
144
|
-
let text = value.trim();
|
|
145
|
-
const token = text.match(/^var\(\s*(--[\w-]+)\s*\)$/)?.[1] ?? (text.startsWith("--") ? text : null);
|
|
146
|
-
if (token) {
|
|
147
|
-
const own = (paletteFor(element) as Record<string, PaletteColor | undefined>)[token];
|
|
148
|
-
if (own) return own;
|
|
149
|
-
text = getComputedStyle(element).getPropertyValue(token).trim();
|
|
150
|
-
} else if (/^currentcolor$/i.test(text) || text.includes("var(")) {
|
|
151
|
-
const style = getComputedStyle(element);
|
|
152
|
-
text = /^currentcolor$/i.test(text) ? style.color : text.replace(/var\(\s*(--[\w-]+)\s*\)/g, (_match, name: string) => style.getPropertyValue(name).trim());
|
|
153
|
-
}
|
|
154
|
-
if (!text) return null;
|
|
155
|
-
if (colors.has(text)) {
|
|
156
|
-
const cached = colors.get(text) ?? null;
|
|
157
|
-
colors.delete(text);
|
|
158
|
-
colors.set(text, cached);
|
|
159
|
-
return cached;
|
|
160
|
-
}
|
|
161
|
-
const color = normalize(text);
|
|
162
|
-
colors.set(text, color);
|
|
163
|
-
if (colors.size > cacheSize) colors.delete(colors.keys().next().value as string);
|
|
164
|
-
return color;
|
|
165
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { foundation } from "@reqvire-org/ads/foundation" with { type: "macro" };
|
|
2
|
-
|
|
3
|
-
// The compiler emits ordinary document CSS from these shared responsibilities.
|
|
4
|
-
// Themes and brands are declared here, in order: the first of each is the
|
|
5
|
-
// default, whose values are the :root values of the token sheets.
|
|
6
|
-
export default foundation({
|
|
7
|
-
tokens: "./tokens",
|
|
8
|
-
text: "document-text",
|
|
9
|
-
surface: "document-surface",
|
|
10
|
-
focus: "keyboard-focus",
|
|
11
|
-
reset: "document",
|
|
12
|
-
themes: [
|
|
13
|
-
{ name: "light", scheme: "light" },
|
|
14
|
-
{ name: "dark", scheme: "dark" },
|
|
15
|
-
{ name: "high-contrast", scheme: "dark" },
|
|
16
|
-
],
|
|
17
|
-
brands: [{ name: "northstar" }, { name: "iris" }],
|
|
18
|
-
// palette.generated.ts: paint tokens resolved per context for the Palette controller (`ads sync` keeps it current).
|
|
19
|
-
palette: true,
|
|
20
|
-
// A root without data-theme follows the OS colour scheme: light, or dark (the first theme of each scheme).
|
|
21
|
-
followSystemTheme: true,
|
|
22
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// The public barrel: every public owner is re-exported here by name.
|
|
2
|
-
// Review/scenario code is never exported here.
|
|
3
|
-
export { Button } from "./components/Actions/Button/Button";
|
|
4
|
-
export { TextField } from "./components/Forms/TextField/TextField";
|
|
5
|
-
export { Identity } from "./components/Identity/Identity";
|
|
6
|
-
export { Artwork } from "./components/Content/Artwork/Artwork";
|
|
7
|
-
export { PartnerLogo } from "./components/Content/PartnerLogo/PartnerLogo";
|
|
8
|
-
export { Icon } from "./components/Content/Icon/Icon";
|
|
9
|
-
export type { IconGlyph, IconProps, IconSize } from "./components/Content/Icon/Icon";
|
|
10
|
-
// One reference and one ready component per glyph: an app that imports SearchIcon ships no other glyph.
|
|
11
|
-
export { arrowGlyph, ArrowIcon } from "./components/Content/Icon/glyphs/arrow";
|
|
12
|
-
export { closeGlyph, CloseIcon } from "./components/Content/Icon/glyphs/close";
|
|
13
|
-
export { searchGlyph, SearchIcon } from "./components/Content/Icon/glyphs/search";
|
|
14
|
-
export { IconButton } from "./components/Actions/IconButton/IconButton";
|
|
15
|
-
export type { IconButtonProps } from "./components/Actions/IconButton/IconButton";
|
|
16
|
-
export { StatusIcon } from "./components/Content/StatusIcon/StatusIcon";
|
|
17
|
-
export type { StatusIconProps, StatusName } from "./components/Content/StatusIcon/StatusIcon";
|
|
18
|
-
export { BarChart } from "./components/Content/BarChart/BarChart";
|
|
19
|
-
export type { BarChartItem, BarChartProps, SeriesPaint } from "./components/Content/BarChart/BarChart";
|
|
20
|
-
export { Image } from "./components/Content/Image/Image";
|
|
21
|
-
export type { ImageProps, ContentImage } from "./components/Content/Image/Image";
|
|
22
|
-
export { Disclosure } from "./components/Containers/Disclosure/Disclosure";
|
|
23
|
-
export type { DisclosureProps } from "./components/Containers/Disclosure/Disclosure";
|
|
24
|
-
export { Popover } from "./components/Overlays/Popover/Popover";
|
|
25
|
-
export type { PopoverProps } from "./components/Overlays/Popover/Popover";
|
|
26
|
-
export { Menu } from "./components/Overlays/Menu/Menu";
|
|
27
|
-
export type { MenuItem, MenuProps } from "./components/Overlays/Menu/Menu";
|
|
28
|
-
export { Shell } from "./patterns/Shell/Shell";
|
|
29
|
-
export type { ShellProps } from "./patterns/Shell/Shell";
|
|
30
|
-
export { InviteMember } from "./patterns/Forms/InviteMember/InviteMember";
|
|
31
|
-
export { Workspace } from "./patterns/Workspace/Workspace/Workspace";
|
|
32
|
-
export type { WorkspaceProps, WorkspaceView } from "./patterns/Workspace/Workspace/Workspace";
|
|
33
|
-
export { ConstructionWorkbench } from "./patterns/ConstructionWorkbench/ConstructionWorkbench/ConstructionWorkbench";
|
|
34
|
-
export type { ConstructionWorkbenchProps } from "./patterns/ConstructionWorkbench/ConstructionWorkbench/ConstructionWorkbench";
|
|
35
|
-
export { ArtworkCatalogue } from "./patterns/ArtworkCatalogue/ArtworkCatalogue/ArtworkCatalogue";
|
|
36
|
-
export { ToggleTile } from "./components/Actions/ToggleTile/ToggleTile";
|
|
37
|
-
export type { ToggleTileProps } from "./components/Actions/ToggleTile/ToggleTile";
|
|
38
|
-
export { GuideGrid } from "./components/Content/GuideGrid/GuideGrid";
|
|
39
|
-
export type { GuideGridProps } from "./components/Content/GuideGrid/GuideGrid";
|
|
40
|
-
export { InspectedGlyph } from "./components/Content/InspectedGlyph/InspectedGlyph";
|
|
41
|
-
export type { InspectedGlyphProps } from "./components/Content/InspectedGlyph/InspectedGlyph";
|
|
42
|
-
export { Inspector } from "./patterns/Inspector/Inspector/Inspector";
|
|
43
|
-
export type { InspectorEntry, InspectorProps, InspectorSpecimen } from "./patterns/Inspector/Inspector/Inspector";
|
|
44
|
-
// Renderer colours for canvas and WebGL drawing: a controller (a plain module, no recipe or markup).
|
|
45
|
-
export { observePalette, paletteContext, paletteFor, resolveColor } from "./controllers/Palette/Palette";
|
|
46
|
-
export type { ColorToken, Palette, PaletteColor, PaletteContext } from "./controllers/Palette/Palette";
|
|
47
|
-
// Form fields: validation timing, error accessibility and autofill (a controller; TextField and InviteMember bind it).
|
|
48
|
-
export { announcement, announces, ariaInvalid, autofilled, bindForm, bindFormField, constraintView, describedBy, fieldStep, fieldView, formBindingOf, initialFieldState, supportsUserValidity, withApplicationError } from "./controllers/FormField/FormField";
|
|
49
|
-
export type { ErrorSource, FieldBinding, FieldControl, FieldEvent, FieldOptions, FieldState, FieldView, FormBinding, FormOptions, ViewInputs } from "./controllers/FormField/FormField";
|
|
50
|
-
export { useFormBridge, useFormField } from "./controllers/FormField/useFormField";
|
|
51
|
-
export type { FormBridgeOptions, FormFieldOptions } from "./controllers/FormField/useFormField";
|