@styleflow.app/flowpress-astro-core 1.0.0-beta.21 → 1.0.0-beta.23

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/accessibility-panel.d.ts +2 -0
  3. package/dist/accessibility-panel.d.ts.map +1 -0
  4. package/dist/accessibility-panel.js +66 -0
  5. package/dist/accessibility-panel.js.map +1 -0
  6. package/dist/astro/BaseLayout.astro +18 -6
  7. package/dist/astro/ThemeRuntime.astro +3 -1
  8. package/dist/astro/blocks/ThemeToggleBlock.astro +7 -17
  9. package/dist/astro/native/core-transparent.astro +11 -0
  10. package/dist/astro/native/grid.css +12 -12
  11. package/dist/astro/native/registry.d.ts.map +1 -1
  12. package/dist/astro/native/registry.js +7 -0
  13. package/dist/astro/native/registry.js.map +1 -1
  14. package/dist/astro/native/registry.ts +7 -0
  15. package/dist/astro/preferences/AccessibilityPanel.astro +118 -0
  16. package/dist/astro/preferences/ColorModeToggle.astro +26 -0
  17. package/dist/astro/preferences/MotionToggle.astro +27 -0
  18. package/dist/astro/preferences/PreferencesRuntime.astro +9 -0
  19. package/dist/astro/preferences/ThemeToggle.astro +30 -0
  20. package/dist/astro/preferences/Toggle.astro +50 -0
  21. package/dist/astro/preferences/preferences.css +124 -0
  22. package/dist/default-blocks.d.ts +1 -1
  23. package/dist/default-blocks.d.ts.map +1 -1
  24. package/dist/default-blocks.js +11 -1
  25. package/dist/default-blocks.js.map +1 -1
  26. package/dist/index.d.ts +2 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +1 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/motion-preference.d.ts +50 -0
  31. package/dist/motion-preference.d.ts.map +1 -0
  32. package/dist/motion-preference.js +132 -0
  33. package/dist/motion-preference.js.map +1 -0
  34. package/dist/preferences-runtime.d.ts +3 -0
  35. package/dist/preferences-runtime.d.ts.map +1 -0
  36. package/dist/preferences-runtime.js +23 -0
  37. package/dist/preferences-runtime.js.map +1 -0
  38. package/dist/preferences-styleflow.d.ts +3 -0
  39. package/dist/preferences-styleflow.d.ts.map +1 -0
  40. package/dist/preferences-styleflow.js +14 -0
  41. package/dist/preferences-styleflow.js.map +1 -0
  42. package/dist/preferences.d.ts +4 -0
  43. package/dist/preferences.d.ts.map +1 -0
  44. package/dist/preferences.js +4 -0
  45. package/dist/preferences.js.map +1 -0
  46. package/dist/theme-runtime.d.ts.map +1 -1
  47. package/dist/theme-runtime.js +29 -6
  48. package/dist/theme-runtime.js.map +1 -1
  49. package/dist/tsconfig.tsbuildinfo +1 -1
  50. package/dist/vivid-colors-preference.d.ts +31 -0
  51. package/dist/vivid-colors-preference.d.ts.map +1 -0
  52. package/dist/vivid-colors-preference.js +102 -0
  53. package/dist/vivid-colors-preference.js.map +1 -0
  54. package/package.json +15 -3
@@ -0,0 +1,124 @@
1
+ /*
2
+ * Toggle: the on/off state machine. Geometry lives in the markup (Tailwind),
3
+ * colours in Styleflow props; here only what changes with the state.
4
+ *
5
+ * `--sf-toggle-on` is 1 when the switch reads "on". Besides `aria-checked`, the
6
+ * theme and motion switches mirror the document (`<html>` attributes set by the
7
+ * head bootstrap scripts), so they are right from first paint and never slide
8
+ * into place after the page loads.
9
+ */
10
+ .sf-toggle {
11
+ --sf-toggle-on: 0;
12
+ --sf-toggle-travel: 1.25rem;
13
+ --sf-toggle-direction: 1;
14
+ }
15
+
16
+ .sf-toggle:dir(rtl) {
17
+ --sf-toggle-direction: -1;
18
+ }
19
+
20
+ .sf-toggle[aria-checked="true"],
21
+ html[data-styleflow-theme="dark"] .sf-toggle[data-styleflow-theme-toggle],
22
+ html[data-sf-motion-preference="full"] .sf-toggle[data-sf-motion-toggle],
23
+ html[data-sf-vivid-colors="true"] .sf-toggle[data-sf-vivid-colors-toggle] {
24
+ --sf-toggle-on: 1;
25
+ }
26
+
27
+ .sf-toggle__track--on {
28
+ opacity: var(--sf-toggle-on);
29
+ transition: opacity var(--sf-motion-duration-default, 180ms) var(--sf-motion-ease-standard, ease);
30
+ }
31
+
32
+ /* A ring keeps the "off" track readable against the panel in both themes. */
33
+ .sf-toggle__track:not(.sf-toggle__track--on) {
34
+ box-shadow: inset 0 0 0 0.0625rem var(--sf-border);
35
+ }
36
+
37
+ .sf-toggle__thumb {
38
+ box-shadow: 0 0.0625rem 0.25rem color-mix(in srgb, var(--sf-foreground-primary) 45%, transparent);
39
+ transform: translateX(calc(var(--sf-toggle-on) * var(--sf-toggle-travel) * var(--sf-toggle-direction)));
40
+ transition:
41
+ transform var(--sf-motion-duration-default, 180ms) var(--sf-motion-ease-out, ease-out),
42
+ scale var(--sf-motion-duration-fast, 120ms) var(--sf-motion-ease-out, ease-out);
43
+ }
44
+
45
+ .sf-toggle:active .sf-toggle__thumb {
46
+ scale: 1.08 1;
47
+ }
48
+
49
+ /* Optional thumb glyphs: one per state, cross-fading with the thumb. */
50
+ .sf-toggle__glyph {
51
+ position: absolute;
52
+ inline-size: 1rem;
53
+ block-size: 1rem;
54
+ transition: opacity var(--sf-motion-duration-default, 180ms) var(--sf-motion-ease-standard, ease);
55
+ }
56
+
57
+ .sf-toggle__glyph--off {
58
+ opacity: calc(1 - var(--sf-toggle-on));
59
+ }
60
+
61
+ .sf-toggle__glyph--on {
62
+ opacity: var(--sf-toggle-on);
63
+ }
64
+
65
+ /*
66
+ * Accessibility panel: the closed/open states and the lift under the round
67
+ * button. Colours are Styleflow tokens (set by the S props in the markup); the
68
+ * shadow is derived from the foreground token so it follows the theme.
69
+ * Transitions stop on their own when animations are off (motion.css).
70
+ */
71
+ html[data-sf-vivid-colors="false"] {
72
+ filter: saturate(30%);
73
+ }
74
+
75
+ .sf-a11y__trigger {
76
+ box-shadow: 0 0.375rem 1.25rem color-mix(in srgb, var(--sf-surface-default-foreground-primary) 28%, transparent);
77
+ transition: transform var(--sf-motion-duration-default, 180ms) var(--sf-motion-ease-out, ease-out);
78
+ }
79
+
80
+ .sf-a11y__trigger:active {
81
+ transform: scale(0.94);
82
+ }
83
+
84
+ .sf-a11y__panel {
85
+ box-shadow: 0 0.75rem 2rem color-mix(in srgb, var(--sf-surface-default-foreground-primary) 22%, transparent);
86
+ transform-origin: bottom right;
87
+ transition:
88
+ opacity var(--sf-motion-duration-fast, 120ms) var(--sf-motion-ease-soft, ease),
89
+ transform var(--sf-motion-duration-default, 180ms) var(--sf-motion-ease-out, ease-out),
90
+ visibility 0s linear var(--sf-motion-duration-default, 180ms);
91
+ }
92
+
93
+ .sf-a11y__panel[data-state="closed"] {
94
+ opacity: 0;
95
+ transform: translateY(0.5rem) scale(0.96);
96
+ visibility: hidden;
97
+ }
98
+
99
+ .sf-a11y__panel[data-state="open"] {
100
+ opacity: 1;
101
+ transform: none;
102
+ transition-delay: 0s;
103
+ visibility: visible;
104
+ }
105
+
106
+ .sf-a11y__panel[data-state="open"]:dir(rtl) {
107
+ transform-origin: bottom left;
108
+ }
109
+
110
+ /* Geometry formerly supplied by the pilot Tailwind classes. */
111
+ .sf-toggle { position: relative; display: inline-block; block-size: 2rem; inline-size: 3.25rem; flex-shrink: 0; cursor: pointer; border-radius: 9999px !important; }
112
+ .sf-toggle__track { position: absolute; inset: 0; border-radius: 9999px !important; }
113
+ .sf-toggle__thumb { position: absolute; inset-inline-start: .125rem; inset-block-start: .125rem; display: grid; inline-size: 1.75rem; block-size: 1.75rem; place-items: center; border-radius: 9999px !important; }
114
+ .sf-a11y { position: fixed; inset-inline-end: var(--fp-preferences-inset, 1rem); inset-block-end: var(--fp-preferences-inset, 1rem); z-index: var(--fp-preferences-z-index, var(--z-floating, 50)); display: flex; flex-direction: column-reverse; align-items: flex-end; gap: .75rem; }
115
+ .sf-a11y[hidden] { display: none !important; }
116
+ .sf-a11y__trigger { display: grid; inline-size: 3.5rem; block-size: 3.5rem; flex-shrink: 0; place-items: center; cursor: pointer; border-radius: 9999px !important; }
117
+ .sf-a11y__icon { inline-size: 1.75rem; block-size: 1.75rem; }
118
+ .sf-a11y__panel { display: flex; flex-direction: column; inline-size: var(--fp-preferences-width, 18rem); max-inline-size: calc(100vw - 2rem); gap: 1rem; }
119
+ .sf-a11y__row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
120
+ .sf-toggle:focus-visible, .sf-a11y__trigger:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
121
+ html[data-sf-motion-preference="reduce"] :is(.sf-toggle, .sf-toggle *, .sf-a11y__trigger, .sf-a11y__panel) { transition: none !important; }
122
+ @media print { .sf-a11y { display: none !important; } }
123
+
124
+ .flowpress-theme-control { display: inline-flex; align-items: center; gap: .5rem; }
@@ -1,4 +1,4 @@
1
- export declare const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION: "3";
1
+ export declare const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION: "4";
2
2
  export interface FlowpressDefaultBlockCatalogEntry {
3
3
  blockName: string;
4
4
  template: "DefaultBlockAdapter.astro";
@@ -1 +1 @@
1
- {"version":3,"file":"default-blocks.d.ts","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uCAAuC,EAAG,GAAY,CAAC;AAEpE,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,2BAA2B,CAAC;CACvC;AAuED,eAAO,MAAM,4BAA4B,EAAE,SAAS,iCAAiC,EACc,CAAC;AAIpG,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE1E;AAED,wBAAgB,wCAAwC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA+BlF"}
1
+ {"version":3,"file":"default-blocks.d.ts","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uCAAuC,EAAG,GAAY,CAAC;AAEpE,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,2BAA2B,CAAC;CACvC;AAkFD,eAAO,MAAM,4BAA4B,EAAE,SAAS,iCAAiC,EACc,CAAC;AAIpG,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE1E;AAED,wBAAgB,wCAAwC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA+BlF"}
@@ -1,5 +1,15 @@
1
- export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = "3";
1
+ export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = "4";
2
2
  const blockNames = [
3
+ "core/post-content",
4
+ "core/site-logo",
5
+ "core/template-part",
6
+ "sf/accordion",
7
+ "sf/collection",
8
+ "sf/flex",
9
+ "sf/group",
10
+ "sf/marquee",
11
+ "sf/media-text",
12
+ "sf/theme-toggle",
3
13
  "core/term-name",
4
14
  "core/post-terms",
5
15
  "core/button",
@@ -1 +1 @@
1
- {"version":3,"file":"default-blocks.js","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAY,CAAC;AAOpE,MAAM,UAAU,GAAG;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,gBAAgB;IAChB,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,oBAAoB;IACpB,WAAW;IACX,YAAY;IACZ,iBAAiB;IACjB,0BAA0B;IAC1B,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,YAAY;IACZ,uBAAuB;IACvB,oBAAoB;IACpB,iBAAiB;IACjB,yBAAyB;IACzB,YAAY;IACZ,gBAAgB;IAChB,qBAAqB;IACrB,sBAAsB;IACtB,iBAAiB;IACjB,eAAe;IACf,oBAAoB;IACpB,kBAAkB;IAClB,uBAAuB;IACvB,eAAe;IACf,oBAAoB;IACpB,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,WAAW;IACX,gBAAgB;IAChB,gBAAgB;IAChB,YAAY;IACZ,mBAAmB;IACnB,WAAW;IACX,SAAS;IACT,aAAa;IACb,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,WAAW;IACX,iBAAiB;IACjB,SAAS;IACT,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,SAAS;IACT,SAAS;IACT,UAAU;IACV,SAAS;IACT,kBAAkB;IAClB,QAAQ;IACR,mBAAmB;IACnB,UAAU;IACV,cAAc;IACd,YAAY;IACZ,aAAa;IACb,cAAc;IACd,UAAU;IACV,kBAAkB;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,4BAA4B,GACvC,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,2BAA2B,EAAE,CAAC,CAAC,CAAC;AAEpG,MAAM,SAAS,GAAG,IAAI,GAAG,CAAS,UAAU,CAAC,CAAC;AAE9C,MAAM,UAAU,+BAA+B,CAAC,SAAiB;IAC/D,OAAO,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,wCAAwC,CAAC,SAAiB;IACxE,IAAI,CAAC,+BAA+B,CAAC,SAAS,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,iDAAiD,SAAS,GAAG,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,SAAS,KAAK,YAAY,EAAE,CAAC;QAC/B,OAAO;;;;;;;;;;;;;;;CAeV,CAAC;IACA,CAAC;IACD,OAAO;;;;;;;;CAQR,CAAC;AACF,CAAC","sourcesContent":["export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = \"3\" as const;\n\nexport interface FlowpressDefaultBlockCatalogEntry {\n blockName: string;\n template: \"DefaultBlockAdapter.astro\";\n}\n\nconst blockNames = [\n \"core/term-name\",\n \"core/post-terms\",\n \"core/button\",\n \"core/post-date\",\n \"core/icon\",\n \"core/post-excerpt\",\n \"core/term-description\",\n \"core/post-template\",\n \"core/html\",\n \"core/block\",\n \"core/site-title\",\n \"core/post-featured-image\",\n \"core/page-list\",\n \"core/terms-query\",\n \"core/buttons\",\n \"core/image\",\n \"core/query-no-results\",\n \"core/term-template\",\n \"core/navigation\",\n \"core/navigation-submenu\",\n \"core/query\",\n \"core/home-link\",\n \"core/page-list-item\",\n \"core/navigation-link\",\n \"core/post-title\",\n \"sf/post-field\",\n \"project/post-field\",\n \"sf/block-binding\",\n \"project/block-binding\",\n \"sf/term-field\",\n \"project/term-field\",\n \"sf/timeline\",\n \"core/cover\",\n \"core/group\",\n \"core/heading\",\n \"core/list\",\n \"core/list-item\",\n \"core/paragraph\",\n \"core/quote\",\n \"sf/accordion-item\",\n \"sf/button\",\n \"sf/card\",\n \"sf/carousel\",\n \"sf/carousel-item\",\n \"sf/chip\",\n \"sf/code\",\n \"sf/column\",\n \"sf/content-list\",\n \"sf/form\",\n \"sf/gallery\",\n \"sf/grid\",\n \"sf/heading\",\n \"sf/hero\",\n \"sf/icon\",\n \"sf/image\",\n \"sf/blob\",\n \"sf/timeline-card\",\n \"sf/map\",\n \"sf/number-spinner\",\n \"sf/quote\",\n \"sf/rich-text\",\n \"sf/section\",\n \"sf/template\",\n \"sf/term-list\",\n \"sf/video\",\n \"sf/video-youtube\"\n] as const;\n\nexport const flowpressDefaultBlockCatalog: readonly FlowpressDefaultBlockCatalogEntry[] =\n [...blockNames].sort().map((blockName) => ({ blockName, template: \"DefaultBlockAdapter.astro\" }));\n\nconst supported = new Set<string>(blockNames);\n\nexport function hasFlowpressDefaultBlockAdapter(blockName: string): boolean {\n return supported.has(blockName);\n}\n\nexport function createFlowpressDefaultBlockAdapterSource(blockName: string): string {\n if (!hasFlowpressDefaultBlockAdapter(blockName)) {\n throw new Error(`FlowPress has no official default adapter for ${blockName}.`);\n }\n if (blockName === \"core/cover\") {\n return `---\nimport CoverBlock from \"@styleflow.app/flowpress-astro-core/blocks/CoverBlock.astro\";\nimport type { FlowpressBlockRendererProps } from \"@styleflow.app/flowpress-astro-core\";\n\nconst { block, contract, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;\n---\n\n<CoverBlock\n block={block}\n contract={contract}\n htmlProps={htmlProps}\n styleflowProps={styleflowProps}\n>\n <slot />\n</CoverBlock>\n`;\n }\n return `---\nimport DefaultBlockAdapter from \"@styleflow.app/flowpress-astro-core/DefaultBlockAdapter.astro\";\nimport type { FlowpressBlockRendererProps } from \"@styleflow.app/flowpress-astro-core\";\n\nconst props = Astro.props as FlowpressBlockRendererProps;\n---\n\n<DefaultBlockAdapter {...props} />\n`;\n}\n"]}
1
+ {"version":3,"file":"default-blocks.js","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAY,CAAC;AAOpE,MAAM,UAAU,GAAG;IACjB,mBAAmB;IACnB,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,eAAe;IACf,SAAS;IACT,UAAU;IACV,YAAY;IACZ,eAAe;IACf,iBAAiB;IAEjB,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,gBAAgB;IAChB,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,oBAAoB;IACpB,WAAW;IACX,YAAY;IACZ,iBAAiB;IACjB,0BAA0B;IAC1B,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,YAAY;IACZ,uBAAuB;IACvB,oBAAoB;IACpB,iBAAiB;IACjB,yBAAyB;IACzB,YAAY;IACZ,gBAAgB;IAChB,qBAAqB;IACrB,sBAAsB;IACtB,iBAAiB;IACjB,eAAe;IACf,oBAAoB;IACpB,kBAAkB;IAClB,uBAAuB;IACvB,eAAe;IACf,oBAAoB;IACpB,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,WAAW;IACX,gBAAgB;IAChB,gBAAgB;IAChB,YAAY;IACZ,mBAAmB;IACnB,WAAW;IACX,SAAS;IACT,aAAa;IACb,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,WAAW;IACX,iBAAiB;IACjB,SAAS;IACT,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,SAAS;IACT,SAAS;IACT,UAAU;IACV,SAAS;IACT,kBAAkB;IAClB,QAAQ;IACR,mBAAmB;IACnB,UAAU;IACV,cAAc;IACd,YAAY;IACZ,aAAa;IACb,cAAc;IACd,UAAU;IACV,kBAAkB;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,4BAA4B,GACvC,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,2BAA2B,EAAE,CAAC,CAAC,CAAC;AAEpG,MAAM,SAAS,GAAG,IAAI,GAAG,CAAS,UAAU,CAAC,CAAC;AAE9C,MAAM,UAAU,+BAA+B,CAAC,SAAiB;IAC/D,OAAO,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,wCAAwC,CAAC,SAAiB;IACxE,IAAI,CAAC,+BAA+B,CAAC,SAAS,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,iDAAiD,SAAS,GAAG,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,SAAS,KAAK,YAAY,EAAE,CAAC;QAC/B,OAAO;;;;;;;;;;;;;;;CAeV,CAAC;IACA,CAAC;IACD,OAAO;;;;;;;;CAQR,CAAC;AACF,CAAC","sourcesContent":["export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = \"4\" as const;\n\nexport interface FlowpressDefaultBlockCatalogEntry {\n blockName: string;\n template: \"DefaultBlockAdapter.astro\";\n}\n\nconst blockNames = [\n \"core/post-content\",\n \"core/site-logo\",\n \"core/template-part\",\n \"sf/accordion\",\n \"sf/collection\",\n \"sf/flex\",\n \"sf/group\",\n \"sf/marquee\",\n \"sf/media-text\",\n \"sf/theme-toggle\",\n\n \"core/term-name\",\n \"core/post-terms\",\n \"core/button\",\n \"core/post-date\",\n \"core/icon\",\n \"core/post-excerpt\",\n \"core/term-description\",\n \"core/post-template\",\n \"core/html\",\n \"core/block\",\n \"core/site-title\",\n \"core/post-featured-image\",\n \"core/page-list\",\n \"core/terms-query\",\n \"core/buttons\",\n \"core/image\",\n \"core/query-no-results\",\n \"core/term-template\",\n \"core/navigation\",\n \"core/navigation-submenu\",\n \"core/query\",\n \"core/home-link\",\n \"core/page-list-item\",\n \"core/navigation-link\",\n \"core/post-title\",\n \"sf/post-field\",\n \"project/post-field\",\n \"sf/block-binding\",\n \"project/block-binding\",\n \"sf/term-field\",\n \"project/term-field\",\n \"sf/timeline\",\n \"core/cover\",\n \"core/group\",\n \"core/heading\",\n \"core/list\",\n \"core/list-item\",\n \"core/paragraph\",\n \"core/quote\",\n \"sf/accordion-item\",\n \"sf/button\",\n \"sf/card\",\n \"sf/carousel\",\n \"sf/carousel-item\",\n \"sf/chip\",\n \"sf/code\",\n \"sf/column\",\n \"sf/content-list\",\n \"sf/form\",\n \"sf/gallery\",\n \"sf/grid\",\n \"sf/heading\",\n \"sf/hero\",\n \"sf/icon\",\n \"sf/image\",\n \"sf/blob\",\n \"sf/timeline-card\",\n \"sf/map\",\n \"sf/number-spinner\",\n \"sf/quote\",\n \"sf/rich-text\",\n \"sf/section\",\n \"sf/template\",\n \"sf/term-list\",\n \"sf/video\",\n \"sf/video-youtube\"\n] as const;\n\nexport const flowpressDefaultBlockCatalog: readonly FlowpressDefaultBlockCatalogEntry[] =\n [...blockNames].sort().map((blockName) => ({ blockName, template: \"DefaultBlockAdapter.astro\" }));\n\nconst supported = new Set<string>(blockNames);\n\nexport function hasFlowpressDefaultBlockAdapter(blockName: string): boolean {\n return supported.has(blockName);\n}\n\nexport function createFlowpressDefaultBlockAdapterSource(blockName: string): string {\n if (!hasFlowpressDefaultBlockAdapter(blockName)) {\n throw new Error(`FlowPress has no official default adapter for ${blockName}.`);\n }\n if (blockName === \"core/cover\") {\n return `---\nimport CoverBlock from \"@styleflow.app/flowpress-astro-core/blocks/CoverBlock.astro\";\nimport type { FlowpressBlockRendererProps } from \"@styleflow.app/flowpress-astro-core\";\n\nconst { block, contract, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;\n---\n\n<CoverBlock\n block={block}\n contract={contract}\n htmlProps={htmlProps}\n styleflowProps={styleflowProps}\n>\n <slot />\n</CoverBlock>\n`;\n }\n return `---\nimport DefaultBlockAdapter from \"@styleflow.app/flowpress-astro-core/DefaultBlockAdapter.astro\";\nimport type { FlowpressBlockRendererProps } from \"@styleflow.app/flowpress-astro-core\";\n\nconst props = Astro.props as FlowpressBlockRendererProps;\n---\n\n<DefaultBlockAdapter {...props} />\n`;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -11,5 +11,7 @@ export * from "./styleflow.js";
11
11
  export * from "./style-classes.js";
12
12
  export * from "./template-hierarchy.js";
13
13
  export * from "./theme-runtime.js";
14
+ export { resolveFlowpressSiteDesign, flowpressSiteDesignAttributes } from "@styleflow.app/flowpress-components/site-design";
15
+ export type { FlowpressSiteDesign, FlowpressSiteDesignDefaults } from "@styleflow.app/flowpress-components/site-design";
14
16
  export * from "./types.js";
15
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,MAAM,iDAAiD,CAAC;AAC5H,YAAY,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AACxH,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -11,5 +11,6 @@ export * from "./styleflow.js";
11
11
  export * from "./style-classes.js";
12
12
  export * from "./template-hierarchy.js";
13
13
  export * from "./theme-runtime.js";
14
+ export { resolveFlowpressSiteDesign, flowpressSiteDesignAttributes } from "@styleflow.app/flowpress-components/site-design";
14
15
  export * from "./types.js";
15
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./client.js\";\nexport * from \"./carousel.js\";\nexport * from \"./block-renderers.js\";\nexport * from \"./composition.js\";\nexport * from \"./default-blocks.js\";\nexport * from \"./env.js\";\nexport * from \"./links.js\";\nexport * from \"./media.js\";\nexport * from \"./number-spinner.js\";\nexport * from \"./styleflow.js\";\nexport * from \"./style-classes.js\";\nexport * from \"./template-hierarchy.js\";\nexport * from \"./theme-runtime.js\";\nexport * from \"./types.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,MAAM,iDAAiD,CAAC;AAE5H,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./client.js\";\nexport * from \"./carousel.js\";\nexport * from \"./block-renderers.js\";\nexport * from \"./composition.js\";\nexport * from \"./default-blocks.js\";\nexport * from \"./env.js\";\nexport * from \"./links.js\";\nexport * from \"./media.js\";\nexport * from \"./number-spinner.js\";\nexport * from \"./styleflow.js\";\nexport * from \"./style-classes.js\";\nexport * from \"./template-hierarchy.js\";\nexport * from \"./theme-runtime.js\";\nexport { resolveFlowpressSiteDesign, flowpressSiteDesignAttributes } from \"@styleflow.app/flowpress-components/site-design\";\nexport type { FlowpressSiteDesign, FlowpressSiteDesignDefaults } from \"@styleflow.app/flowpress-components/site-design\";\nexport * from \"./types.js\";\n"]}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Single source of truth for "may this page animate?".
3
+ *
4
+ * The default follows the OS (`prefers-reduced-motion`). A visitor's explicit
5
+ * choice from the accessibility panel wins in both directions and is stored in
6
+ * localStorage. The resolved value is mirrored on
7
+ * `<html data-sf-motion-preference="full|reduce">`, so CSS and scripts read the
8
+ * same state, and every change is announced with `sf:motion-change`.
9
+ *
10
+ * Do not read `matchMedia("(prefers-reduced-motion)")` or write a bare
11
+ * `@media (prefers-reduced-motion)` rule elsewhere: neither can be overridden
12
+ * by the visitor.
13
+ */
14
+ export declare const MOTION_STORAGE_KEY = "sf:motion";
15
+ export declare const MOTION_ATTRIBUTE = "data-sf-motion-preference";
16
+ export declare const MOTION_CHANGE_EVENT = "sf:motion-change";
17
+ export declare const MOTION_TOGGLE_SELECTOR = "[data-sf-motion-toggle]";
18
+ export declare const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
19
+ /** `full` animates, `reduce` keeps everything still. */
20
+ export type MotionPreference = "full" | "reduce";
21
+ export declare function isMotionPreference(value: unknown): value is MotionPreference;
22
+ /** An explicit choice beats the OS; without one the OS decides. */
23
+ export declare function resolveMotionPreference(stored: unknown, systemReduces: boolean): MotionPreference;
24
+ /**
25
+ * Inline script for `<head>`: mirrors the resolved preference on `<html>`
26
+ * before first paint, so nothing starts animating and then snaps to a stop.
27
+ */
28
+ export declare function motionPreferenceBootstrapScript(): string;
29
+ /** The browser surface this module needs, injectable for tests. */
30
+ export interface MotionEnvironment {
31
+ document: Pick<Document, "documentElement" | "dispatchEvent" | "addEventListener" | "removeEventListener">;
32
+ storage: Pick<Storage, "getItem" | "setItem"> | null;
33
+ media: Pick<MediaQueryList, "matches" | "addEventListener" | "removeEventListener"> | null;
34
+ }
35
+ export declare function browserMotionEnvironment(): MotionEnvironment;
36
+ /** The mirrored value when the bootstrap ran, otherwise resolved from storage and OS. */
37
+ export declare function getMotionPreference(env?: MotionEnvironment): MotionPreference;
38
+ /** Store an explicit choice and announce it. */
39
+ export declare function setMotionPreference(preference: MotionPreference, env?: MotionEnvironment): void;
40
+ /**
41
+ * Call `listener` whenever the effective preference changes: an explicit
42
+ * choice, or the OS setting while the visitor has not made one.
43
+ */
44
+ export declare function subscribeMotionPreference(listener: (preference: MotionPreference) => void, env?: MotionEnvironment): () => void;
45
+ /**
46
+ * Wire every server-rendered `[data-sf-motion-toggle]` switch: a click flips
47
+ * the preference, `aria-checked` mirrors it (checked means animations on).
48
+ */
49
+ export declare function initializeMotionToggles(scope?: ParentNode, env?: MotionEnvironment): () => void;
50
+ //# sourceMappingURL=motion-preference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion-preference.d.ts","sourceRoot":"","sources":["../src/motion-preference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAC9C,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAC5D,eAAO,MAAM,mBAAmB,qBAAqB,CAAC;AACtD,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAChE,eAAO,MAAM,oBAAoB,qCAAqC,CAAC;AAEvE,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEjD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAED,mEAAmE;AACnE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,gBAAgB,CAGjG;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CAKxD;AAED,mEAAmE;AACnE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,iBAAiB,GAAG,eAAe,GAAG,kBAAkB,GAAG,qBAAqB,CAAC,CAAC;IAC3G,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;IACrD,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,kBAAkB,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC;CAC5F;AAED,wBAAgB,wBAAwB,IAAI,iBAAiB,CAY5D;AAeD,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,iBAA8C,GAAG,gBAAgB,CAEzG;AAQD,gDAAgD;AAChD,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,gBAAgB,EAC5B,GAAG,GAAE,iBAA8C,GAClD,IAAI,CAON;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,CAAC,UAAU,EAAE,gBAAgB,KAAK,IAAI,EAChD,GAAG,GAAE,iBAA8C,GAClD,MAAM,IAAI,CAeZ;AAID;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,GAAE,UAAqB,EAC5B,GAAG,GAAE,iBAA8C,GAClD,MAAM,IAAI,CAsBZ"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Single source of truth for "may this page animate?".
3
+ *
4
+ * The default follows the OS (`prefers-reduced-motion`). A visitor's explicit
5
+ * choice from the accessibility panel wins in both directions and is stored in
6
+ * localStorage. The resolved value is mirrored on
7
+ * `<html data-sf-motion-preference="full|reduce">`, so CSS and scripts read the
8
+ * same state, and every change is announced with `sf:motion-change`.
9
+ *
10
+ * Do not read `matchMedia("(prefers-reduced-motion)")` or write a bare
11
+ * `@media (prefers-reduced-motion)` rule elsewhere: neither can be overridden
12
+ * by the visitor.
13
+ */
14
+ export const MOTION_STORAGE_KEY = "sf:motion";
15
+ export const MOTION_ATTRIBUTE = "data-sf-motion-preference";
16
+ export const MOTION_CHANGE_EVENT = "sf:motion-change";
17
+ export const MOTION_TOGGLE_SELECTOR = "[data-sf-motion-toggle]";
18
+ export const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
19
+ export function isMotionPreference(value) {
20
+ return value === "full" || value === "reduce";
21
+ }
22
+ /** An explicit choice beats the OS; without one the OS decides. */
23
+ export function resolveMotionPreference(stored, systemReduces) {
24
+ if (isMotionPreference(stored))
25
+ return stored;
26
+ return systemReduces ? "reduce" : "full";
27
+ }
28
+ /**
29
+ * Inline script for `<head>`: mirrors the resolved preference on `<html>`
30
+ * before first paint, so nothing starts animating and then snaps to a stop.
31
+ */
32
+ export function motionPreferenceBootstrapScript() {
33
+ const key = JSON.stringify(MOTION_STORAGE_KEY);
34
+ const query = JSON.stringify(REDUCED_MOTION_QUERY);
35
+ const attribute = JSON.stringify(MOTION_ATTRIBUTE);
36
+ return `(()=>{let s=null,r=false;try{s=localStorage.getItem(${key})}catch{}try{r=matchMedia(${query}).matches}catch{}document.documentElement.setAttribute(${attribute},s==="full"||s==="reduce"?s:r?"reduce":"full")})()`;
37
+ }
38
+ export function browserMotionEnvironment() {
39
+ let storage = null;
40
+ try {
41
+ storage = localStorage;
42
+ }
43
+ catch {
44
+ // Blocked storage keeps the preference in memory for the page only.
45
+ }
46
+ return {
47
+ document,
48
+ storage,
49
+ media: typeof matchMedia === "function" ? matchMedia(REDUCED_MOTION_QUERY) : null,
50
+ };
51
+ }
52
+ function readStored(env) {
53
+ try {
54
+ return env.storage?.getItem(MOTION_STORAGE_KEY) ?? null;
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ }
60
+ function mirrored(env) {
61
+ const value = env.document.documentElement.getAttribute(MOTION_ATTRIBUTE);
62
+ return isMotionPreference(value) ? value : null;
63
+ }
64
+ /** The mirrored value when the bootstrap ran, otherwise resolved from storage and OS. */
65
+ export function getMotionPreference(env = browserMotionEnvironment()) {
66
+ return mirrored(env) ?? resolveMotionPreference(readStored(env), env.media?.matches ?? false);
67
+ }
68
+ function apply(preference, env) {
69
+ if (mirrored(env) === preference)
70
+ return;
71
+ env.document.documentElement.setAttribute(MOTION_ATTRIBUTE, preference);
72
+ env.document.dispatchEvent(new CustomEvent(MOTION_CHANGE_EVENT, { detail: { preference } }));
73
+ }
74
+ /** Store an explicit choice and announce it. */
75
+ export function setMotionPreference(preference, env = browserMotionEnvironment()) {
76
+ try {
77
+ env.storage?.setItem(MOTION_STORAGE_KEY, preference);
78
+ }
79
+ catch {
80
+ // The choice still applies to this page.
81
+ }
82
+ apply(preference, env);
83
+ }
84
+ /**
85
+ * Call `listener` whenever the effective preference changes: an explicit
86
+ * choice, or the OS setting while the visitor has not made one.
87
+ */
88
+ export function subscribeMotionPreference(listener, env = browserMotionEnvironment()) {
89
+ const onChange = (event) => {
90
+ const preference = event.detail?.preference;
91
+ if (isMotionPreference(preference))
92
+ listener(preference);
93
+ };
94
+ // Every subscriber may see the OS change; `apply` announces it only once.
95
+ const onSystemChange = () => {
96
+ if (!isMotionPreference(readStored(env)))
97
+ apply(resolveMotionPreference(null, env.media?.matches ?? false), env);
98
+ };
99
+ env.document.addEventListener(MOTION_CHANGE_EVENT, onChange);
100
+ env.media?.addEventListener("change", onSystemChange);
101
+ return () => {
102
+ env.document.removeEventListener(MOTION_CHANGE_EVENT, onChange);
103
+ env.media?.removeEventListener("change", onSystemChange);
104
+ };
105
+ }
106
+ const TOGGLE_BOUND = "sfMotionToggleBound";
107
+ /**
108
+ * Wire every server-rendered `[data-sf-motion-toggle]` switch: a click flips
109
+ * the preference, `aria-checked` mirrors it (checked means animations on).
110
+ */
111
+ export function initializeMotionToggles(scope = document, env = browserMotionEnvironment()) {
112
+ const toggles = [...scope.querySelectorAll(MOTION_TOGGLE_SELECTOR)]
113
+ .filter((toggle) => toggle.dataset[TOGGLE_BOUND] !== "true");
114
+ const sync = (preference) => {
115
+ toggles.forEach((toggle) => toggle.setAttribute("aria-checked", String(preference === "full")));
116
+ };
117
+ const flip = () => setMotionPreference(getMotionPreference(env) === "full" ? "reduce" : "full", env);
118
+ toggles.forEach((toggle) => {
119
+ toggle.dataset[TOGGLE_BOUND] = "true";
120
+ toggle.addEventListener("click", flip);
121
+ });
122
+ sync(getMotionPreference(env));
123
+ const unsubscribe = subscribeMotionPreference(sync, env);
124
+ return () => {
125
+ unsubscribe();
126
+ toggles.forEach((toggle) => {
127
+ toggle.removeEventListener("click", flip);
128
+ delete toggle.dataset[TOGGLE_BOUND];
129
+ });
130
+ };
131
+ }
132
+ //# sourceMappingURL=motion-preference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion-preference.js","sourceRoot":"","sources":["../src/motion-preference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,kCAAkC,CAAC;AAKvE,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ,CAAC;AAChD,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,uBAAuB,CAAC,MAAe,EAAE,aAAsB;IAC7E,IAAI,kBAAkB,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAC9C,OAAO,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,+BAA+B;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACnD,OAAO,uDAAuD,GAAG,6BAA6B,KAAK,0DAA0D,SAAS,oDAAoD,CAAC;AAC7N,CAAC;AASD,MAAM,UAAU,wBAAwB;IACtC,I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O,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Single source of truth for \"may this page animate?\".\n *\n * The default follows the OS (`prefers-reduced-motion`). A visitor's explicit\n * choice from the accessibility panel wins in both directions and is stored in\n * localStorage. The resolved value is mirrored on\n * `<html data-sf-motion-preference=\"full|reduce\">`, so CSS and scripts read the\n * same state, and every change is announced with `sf:motion-change`.\n *\n * Do not read `matchMedia(\"(prefers-reduced-motion)\")` or write a bare\n * `@media (prefers-reduced-motion)` rule elsewhere: neither can be overridden\n * by the visitor.\n */\n\nexport const MOTION_STORAGE_KEY = \"sf:motion\";\nexport const MOTION_ATTRIBUTE = \"data-sf-motion-preference\";\nexport const MOTION_CHANGE_EVENT = \"sf:motion-change\";\nexport const MOTION_TOGGLE_SELECTOR = \"[data-sf-motion-toggle]\";\nexport const REDUCED_MOTION_QUERY = \"(prefers-reduced-motion: reduce)\";\n\n/** `full` animates, `reduce` keeps everything still. */\nexport type MotionPreference = \"full\" | \"reduce\";\n\nexport function isMotionPreference(value: unknown): value is MotionPreference {\n return value === \"full\" || value === \"reduce\";\n}\n\n/** An explicit choice beats the OS; without one the OS decides. */\nexport function resolveMotionPreference(stored: unknown, systemReduces: boolean): MotionPreference {\n if (isMotionPreference(stored)) return stored;\n return systemReduces ? \"reduce\" : \"full\";\n}\n\n/**\n * Inline script for `<head>`: mirrors the resolved preference on `<html>`\n * before first paint, so nothing starts animating and then snaps to a stop.\n */\nexport function motionPreferenceBootstrapScript(): string {\n const key = JSON.stringify(MOTION_STORAGE_KEY);\n const query = JSON.stringify(REDUCED_MOTION_QUERY);\n const attribute = JSON.stringify(MOTION_ATTRIBUTE);\n return `(()=>{let s=null,r=false;try{s=localStorage.getItem(${key})}catch{}try{r=matchMedia(${query}).matches}catch{}document.documentElement.setAttribute(${attribute},s===\"full\"||s===\"reduce\"?s:r?\"reduce\":\"full\")})()`;\n}\n\n/** The browser surface this module needs, injectable for tests. */\nexport interface MotionEnvironment {\n document: Pick<Document, \"documentElement\" | \"dispatchEvent\" | \"addEventListener\" | \"removeEventListener\">;\n storage: Pick<Storage, \"getItem\" | \"setItem\"> | null;\n media: Pick<MediaQueryList, \"matches\" | \"addEventListener\" | \"removeEventListener\"> | null;\n}\n\nexport function browserMotionEnvironment(): MotionEnvironment {\n let storage: MotionEnvironment[\"storage\"] = null;\n try {\n storage = localStorage;\n } catch {\n // Blocked storage keeps the preference in memory for the page only.\n }\n return {\n document,\n storage,\n media: typeof matchMedia === \"function\" ? matchMedia(REDUCED_MOTION_QUERY) : null,\n };\n}\n\nfunction readStored(env: MotionEnvironment): string | null {\n try {\n return env.storage?.getItem(MOTION_STORAGE_KEY) ?? null;\n } catch {\n return null;\n }\n}\n\nfunction mirrored(env: MotionEnvironment): MotionPreference | null {\n const value = env.document.documentElement.getAttribute(MOTION_ATTRIBUTE);\n return isMotionPreference(value) ? value : null;\n}\n\n/** The mirrored value when the bootstrap ran, otherwise resolved from storage and OS. */\nexport function getMotionPreference(env: MotionEnvironment = browserMotionEnvironment()): MotionPreference {\n return mirrored(env) ?? resolveMotionPreference(readStored(env), env.media?.matches ?? false);\n}\n\nfunction apply(preference: MotionPreference, env: MotionEnvironment): void {\n if (mirrored(env) === preference) return;\n env.document.documentElement.setAttribute(MOTION_ATTRIBUTE, preference);\n env.document.dispatchEvent(new CustomEvent(MOTION_CHANGE_EVENT, { detail: { preference } }));\n}\n\n/** Store an explicit choice and announce it. */\nexport function setMotionPreference(\n preference: MotionPreference,\n env: MotionEnvironment = browserMotionEnvironment(),\n): void {\n try {\n env.storage?.setItem(MOTION_STORAGE_KEY, preference);\n } catch {\n // The choice still applies to this page.\n }\n apply(preference, env);\n}\n\n/**\n * Call `listener` whenever the effective preference changes: an explicit\n * choice, or the OS setting while the visitor has not made one.\n */\nexport function subscribeMotionPreference(\n listener: (preference: MotionPreference) => void,\n env: MotionEnvironment = browserMotionEnvironment(),\n): () => void {\n const onChange = (event: Event) => {\n const preference = (event as CustomEvent<{ preference?: unknown }>).detail?.preference;\n if (isMotionPreference(preference)) listener(preference);\n };\n // Every subscriber may see the OS change; `apply` announces it only once.\n const onSystemChange = () => {\n if (!isMotionPreference(readStored(env))) apply(resolveMotionPreference(null, env.media?.matches ?? false), env);\n };\n env.document.addEventListener(MOTION_CHANGE_EVENT, onChange);\n env.media?.addEventListener(\"change\", onSystemChange);\n return () => {\n env.document.removeEventListener(MOTION_CHANGE_EVENT, onChange);\n env.media?.removeEventListener(\"change\", onSystemChange);\n };\n}\n\nconst TOGGLE_BOUND = \"sfMotionToggleBound\";\n\n/**\n * Wire every server-rendered `[data-sf-motion-toggle]` switch: a click flips\n * the preference, `aria-checked` mirrors it (checked means animations on).\n */\nexport function initializeMotionToggles(\n scope: ParentNode = document,\n env: MotionEnvironment = browserMotionEnvironment(),\n): () => void {\n const toggles = [...scope.querySelectorAll<HTMLElement>(MOTION_TOGGLE_SELECTOR)]\n .filter((toggle) => toggle.dataset[TOGGLE_BOUND] !== \"true\");\n const sync = (preference: MotionPreference) => {\n toggles.forEach((toggle) => toggle.setAttribute(\"aria-checked\", String(preference === \"full\")));\n };\n const flip = () => setMotionPreference(getMotionPreference(env) === \"full\" ? \"reduce\" : \"full\", env);\n\n toggles.forEach((toggle) => {\n toggle.dataset[TOGGLE_BOUND] = \"true\";\n toggle.addEventListener(\"click\", flip);\n });\n sync(getMotionPreference(env));\n const unsubscribe = subscribeMotionPreference(sync, env);\n\n return () => {\n unsubscribe();\n toggles.forEach((toggle) => {\n toggle.removeEventListener(\"click\", flip);\n delete toggle.dataset[TOGGLE_BOUND];\n });\n };\n}\n"]}
@@ -0,0 +1,3 @@
1
+ /** One owner for all preference controls, including Astro navigation. */
2
+ export declare function startFlowpressPreferencesRuntime(): void;
3
+ //# sourceMappingURL=preferences-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences-runtime.d.ts","sourceRoot":"","sources":["../src/preferences-runtime.ts"],"names":[],"mappings":"AAKA,yEAAyE;AACzE,wBAAgB,gCAAgC,IAAI,IAAI,CAYvD"}
@@ -0,0 +1,23 @@
1
+ import { initializeAccessibilityPanel } from "./accessibility-panel.js";
2
+ import { initializeMotionToggles } from "./motion-preference.js";
3
+ import { initializeVividColorsToggles } from "./vivid-colors-preference.js";
4
+ let started = false;
5
+ let cleanup = () => { };
6
+ /** One owner for all preference controls, including Astro navigation. */
7
+ export function startFlowpressPreferencesRuntime() {
8
+ if (started)
9
+ return;
10
+ started = true;
11
+ const initialize = () => {
12
+ cleanup();
13
+ const disposers = [initializeAccessibilityPanel(), initializeMotionToggles(), initializeVividColorsToggles()];
14
+ cleanup = () => disposers.forEach((dispose) => dispose());
15
+ };
16
+ if (document.readyState === "loading")
17
+ document.addEventListener("DOMContentLoaded", initialize, { once: true });
18
+ else
19
+ initialize();
20
+ document.addEventListener("astro:page-load", initialize);
21
+ document.addEventListener("astro:before-swap", () => cleanup());
22
+ }
23
+ //# sourceMappingURL=preferences-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences-runtime.js","sourceRoot":"","sources":["../src/preferences-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,IAAI,OAAO,GAAG,KAAK,CAAC;AACpB,IAAI,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AACvB,yEAAyE;AACzE,MAAM,UAAU,gCAAgC;IAC9C,IAAI,OAAO;QAAE,OAAO;IACpB,OAAO,GAAG,IAAI,CAAC;IACf,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,OAAO,EAAE,CAAC;QACV,MAAM,SAAS,GAAG,CAAC,4BAA4B,EAAE,EAAE,uBAAuB,EAAE,EAAE,4BAA4B,EAAE,CAAC,CAAC;QAC9G,OAAO,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC;IACF,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS;QAAE,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;;QAC5G,UAAU,EAAE,CAAC;IAClB,QAAQ,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;IACzD,QAAQ,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { initializeAccessibilityPanel } from \"./accessibility-panel.js\";\nimport { initializeMotionToggles } from \"./motion-preference.js\";\nimport { initializeVividColorsToggles } from \"./vivid-colors-preference.js\";\nlet started = false;\nlet cleanup = () => {};\n/** One owner for all preference controls, including Astro navigation. */\nexport function startFlowpressPreferencesRuntime(): void {\n if (started) return;\n started = true;\n const initialize = () => {\n cleanup();\n const disposers = [initializeAccessibilityPanel(), initializeMotionToggles(), initializeVividColorsToggles()];\n cleanup = () => disposers.forEach((dispose) => dispose());\n };\n if (document.readyState === \"loading\") document.addEventListener(\"DOMContentLoaded\", initialize, { once: true });\n else initialize();\n document.addEventListener(\"astro:page-load\", initialize);\n document.addEventListener(\"astro:before-swap\", () => cleanup());\n}\n"]}
@@ -0,0 +1,3 @@
1
+ /** Keep the pilot appearance where available, using only public contract validation. */
2
+ export declare function preferencesStyleflow(...candidates: Record<string, unknown>[]): Record<string, unknown>;
3
+ //# sourceMappingURL=preferences-styleflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences-styleflow.d.ts","sourceRoot":"","sources":["../src/preferences-styleflow.ts"],"names":[],"mappings":"AACA,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,GAAG,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOtG"}
@@ -0,0 +1,14 @@
1
+ import { resolveStyleFlowAstroPrimitive } from "@styleflow.app/astro";
2
+ /** Keep the pilot appearance where available, using only public contract validation. */
3
+ export function preferencesStyleflow(...candidates) {
4
+ for (const candidate of candidates) {
5
+ try {
6
+ resolveStyleFlowAstroPrimitive({ as: "div", ...candidate });
7
+ return candidate;
8
+ }
9
+ catch { /* The next preset uses fewer optional project coordinates. */ }
10
+ }
11
+ resolveStyleFlowAstroPrimitive({ as: "div" });
12
+ return {};
13
+ }
14
+ //# sourceMappingURL=preferences-styleflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences-styleflow.js","sourceRoot":"","sources":["../src/preferences-styleflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,wFAAwF;AACxF,MAAM,UAAU,oBAAoB,CAAC,GAAG,UAAqC;IAC3E,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC;YAAC,8BAA8B,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;YAAC,OAAO,SAAS,CAAC;QAAC,CAAC;QACtF,MAAM,CAAC,CAAC,8DAA8D,CAAC,CAAC;IAC1E,CAAC;IACD,8BAA8B,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9C,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import { resolveStyleFlowAstroPrimitive } from \"@styleflow.app/astro\";\n/** Keep the pilot appearance where available, using only public contract validation. */\nexport function preferencesStyleflow(...candidates: Record<string, unknown>[]): Record<string, unknown> {\n for (const candidate of candidates) {\n try { resolveStyleFlowAstroPrimitive({ as: \"div\", ...candidate }); return candidate; }\n catch { /* The next preset uses fewer optional project coordinates. */ }\n }\n resolveStyleFlowAstroPrimitive({ as: \"div\" });\n return {};\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export * from "./motion-preference.js";
2
+ export * from "./vivid-colors-preference.js";
3
+ export * from "./accessibility-panel.js";
4
+ //# sourceMappingURL=preferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.d.ts","sourceRoot":"","sources":["../src/preferences.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./motion-preference.js";
2
+ export * from "./vivid-colors-preference.js";
3
+ export * from "./accessibility-panel.js";
4
+ //# sourceMappingURL=preferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.js","sourceRoot":"","sources":["../src/preferences.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC","sourcesContent":["export * from \"./motion-preference.js\";\nexport * from \"./vivid-colors-preference.js\";\nexport * from \"./accessibility-panel.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"theme-runtime.d.ts","sourceRoot":"","sources":["../src/theme-runtime.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAE7D,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,qCAAqC,CAAC,EAAE,2BAA2B,CAAC;KACrE;CACF;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,YAAY,EAAE,MAAM,GACnB,2BAA2B,CAQ7B;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,MAAM,EAAE,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R;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,GAAE,2BAC6B,EACrC,cAAc,GAAE,QAAmB,EACnC,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG,IAAI,GACpD,MAAM,IAAI,CAkEZ"}
@@ -24,10 +24,19 @@ export function styleflowThemeBootstrapScript(themes, defaultTheme) {
24
24
  return `(()=>{const c=${json};window.__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__=c;if(!c.themes.length)return;let s=null;try{s=localStorage.getItem(${JSON.stringify(STYLEFLOW_THEME_STORAGE_KEY)})}catch{}const t=c.themes.includes(s)?s:c.defaultTheme;document.documentElement.setAttribute("data-styleflow-theme",t)})()`;
25
25
  }
26
26
  export function initializeStyleflowThemeRuntime(config = window.__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__
27
- ?? { themes: [], defaultTheme: "" }, documentObject = document, storage = globalThis.localStorage) {
27
+ ?? { themes: [], defaultTheme: "" }, documentObject = document, storage) {
28
28
  const normalized = normalizeStyleflowThemes(config.themes, config.defaultTheme);
29
29
  if (normalized.themes.length === 0)
30
30
  return () => undefined;
31
+ let storageObject = storage;
32
+ if (storageObject === undefined) {
33
+ try {
34
+ storageObject = globalThis.localStorage;
35
+ }
36
+ catch {
37
+ storageObject = null;
38
+ }
39
+ }
31
40
  const root = documentObject.documentElement;
32
41
  let current = initialStyleflowTheme(normalized.themes, normalized.defaultTheme, root.getAttribute("data-styleflow-theme"));
33
42
  const buttons = [...documentObject.querySelectorAll("[data-styleflow-theme-toggle]")];
@@ -37,8 +46,14 @@ export function initializeStyleflowThemeRuntime(config = window.__FLOWPRESS_STYL
37
46
  || button.getAttribute("aria-label")
38
47
  || "Change color theme";
39
48
  button.dataset.styleflowThemeToggleLabel = baseLabel.replace(/: .+$/, "");
40
- button.setAttribute("aria-label", `${button.dataset.styleflowThemeToggleLabel}: ${current}`);
41
- const label = button.querySelector("[data-styleflow-theme-label]");
49
+ if (button.getAttribute("role") === "switch") {
50
+ button.setAttribute("aria-checked", String(current === (button.dataset.styleflowThemeToggleTarget || "dark")));
51
+ }
52
+ else {
53
+ button.setAttribute("aria-label", `${button.dataset.styleflowThemeToggleLabel}: ${current}`);
54
+ }
55
+ const label = button.querySelector("[data-styleflow-theme-label]")
56
+ ?? button.closest(".flowpress-theme-control")?.querySelector("[data-styleflow-theme-label]");
42
57
  if (label)
43
58
  label.textContent = current;
44
59
  }
@@ -46,9 +61,9 @@ export function initializeStyleflowThemeRuntime(config = window.__FLOWPRESS_STYL
46
61
  const apply = (theme, persist) => {
47
62
  current = theme;
48
63
  root.setAttribute("data-styleflow-theme", theme);
49
- if (persist && storage) {
64
+ if (persist && storageObject) {
50
65
  try {
51
- storage.setItem(STYLEFLOW_THEME_STORAGE_KEY, theme);
66
+ storageObject.setItem(STYLEFLOW_THEME_STORAGE_KEY, theme);
52
67
  }
53
68
  catch { /* noop */ }
54
69
  }
@@ -61,7 +76,15 @@ export function initializeStyleflowThemeRuntime(config = window.__FLOWPRESS_STYL
61
76
  for (const button of buttons) {
62
77
  if (button.dataset.styleflowThemeToggleBound === "true")
63
78
  continue;
64
- const listener = () => apply(nextStyleflowTheme(normalized.themes, current), true);
79
+ const listener = () => {
80
+ const target = button.dataset.styleflowThemeToggleTarget;
81
+ const alternative = normalized.defaultTheme !== target
82
+ ? normalized.defaultTheme : normalized.themes.find((theme) => theme !== target);
83
+ const theme = target && alternative && normalized.themes.includes(target)
84
+ ? (current === target ? alternative : target)
85
+ : nextStyleflowTheme(normalized.themes, current);
86
+ apply(theme, true);
87
+ };
65
88
  button.dataset.styleflowThemeToggleBound = "true";
66
89
  button.addEventListener("click", listener);
67
90
  listeners.set(button, listener);