@sudajs/cli 0.13.2 → 0.13.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudajs/cli",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "suda": "./bin/suda.js"
@@ -34,7 +34,7 @@
34
34
  "react": "^19.2.7",
35
35
  "react-dom": "^19.2.7",
36
36
  "zod": "^3.24.1",
37
- "@sudajs/theme-engine": "5.1.2"
37
+ "@sudajs/theme-engine": "5.1.3"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@tailwindcss/postcss": "^4.3.0",
@@ -644,6 +644,238 @@ export const Hero: SudaComponentConfig<HeroProps> = {
644
644
  - If a page section needs controlled nested content, use Suda `blockSlots`, not a hand-written Puck slot field. `blockSlots` lets the theme define exactly which local block kinds are allowed inside that section.
645
645
  - Do not use legacy DropZone or `zones` patterns.
646
646
 
647
+ ## Puck Editor Compatibility Contract
648
+
649
+ Every public page and layout component must render consistently in the public
650
+ site, the Puck Editor iframe, and editor preview mode. Build this compatibility
651
+ in when creating the theme; do not wait for an editor-only positioning bug.
652
+
653
+ ### Puck mutates the real component root
654
+
655
+ In edit mode Puck may attach selection and drag attributes and an inline
656
+ position directly to the first real DOM element returned by a component:
657
+
658
+ ```ts
659
+ el.setAttribute("data-puck-component", id);
660
+ el.setAttribute("data-puck-dnd", id);
661
+ el.style.position = "relative";
662
+ ```
663
+
664
+ - Never assume `[data-puck-component]` is an external wrapper. It may be the
665
+ component's own `<nav>`, `<header>`, `<section>`, or `<footer>`.
666
+ - `:has(.component-root)` does not match an element that is itself
667
+ `.component-root`. When both DOM shapes are possible, cover both explicitly:
668
+
669
+ ```css
670
+ .component-root[data-puck-component],
671
+ [data-puck-component]:has(.component-root) {
672
+ /* compatibility override */
673
+ }
674
+ ```
675
+
676
+ - Puck's inline `position: relative` beats ordinary theme CSS. A component
677
+ whose real root must remain `sticky`, `fixed`, or `absolute` in the editor
678
+ needs a specific editor-scoped rule with `!important`.
679
+ - Never apply `position: relative !important` to every editor component. That
680
+ destroys navigation, overlays, and floating controls.
681
+
682
+ ### Stable component roots
683
+
684
+ - Every public page and layout component should return one stable, semantic,
685
+ real DOM root. Prefer `<header>` or `<nav>` for navigation, `<footer>` for the
686
+ footer, and `<section>` or an explicit container for ordinary sections.
687
+ - Do not use a Fragment as the root of a component that controls positioning,
688
+ margin, size, stacking, background, or editor selection. Do not depend on
689
+ Puck to wrap a Fragment.
690
+ - Do not use `display: contents` on a root that needs margin, padding,
691
+ positioning, sticky/fixed behavior, `z-index`, background, or a selection
692
+ outline.
693
+ - `PageOutlet` must render a real DOM element when it needs negative margin,
694
+ overlap, positioning, or sizing.
695
+
696
+ ### Explicit editor scope
697
+
698
+ The layout root must derive editor state from
699
+ `puck?.metadata?.isEditor === true` and expose a stable marker:
700
+
701
+ ```tsx
702
+ <div className="theme-root" data-suda-editor={isEditor ? "true" : undefined}>
703
+ {children}
704
+ </div>
705
+ ```
706
+
707
+ Keep every editor-only compatibility rule below
708
+ `.theme-root[data-suda-editor="true"]`. Do not globally override `.navbar`,
709
+ `.section`, or `[data-puck-component]`, change the public-site layout to repair
710
+ the editor, use vague selectors that affect unrelated components, or edit
711
+ third-party minified CSS. Put compatibility overrides in the theme's scoped
712
+ `src/styles.css`.
713
+
714
+ When the component itself may be the Puck root or may sit inside one, write and
715
+ test both selectors. Keep later rules from overriding the correction:
716
+
717
+ ```css
718
+ .theme-root[data-suda-editor="true"] .theme-navigation[data-puck-component],
719
+ .theme-root[data-suda-editor="true"]
720
+ [data-puck-component]:has(.theme-navigation)
721
+ .theme-navigation {
722
+ position: sticky !important;
723
+ top: 0;
724
+ z-index: 30;
725
+ }
726
+ ```
727
+
728
+ ### Sticky and fixed positioning
729
+
730
+ Before implementing Header, announcement bar, floating CTA, or any
731
+ sticky/fixed component, verify all of the following:
732
+
733
+ - whether Puck writes `position: relative` on the actual positioned root;
734
+ - which element really scrolls in the site and in the editor iframe;
735
+ - that the sticky element is inside the intended scroll container;
736
+ - whether any ancestor has `overflow: hidden`, `auto`, `scroll`, or `clip`, or
737
+ has `transform`, `filter`, `perspective`, or `contain`;
738
+ - that the sticky parent is taller than the sticky element where required;
739
+ - that `top` and `z-index` are explicit; and
740
+ - that iframe scrolling and the outer editor canvas do not use incompatible
741
+ coordinate systems.
742
+
743
+ For a layout Header, prefer putting sticky behavior on the Header's real root.
744
+ If that root receives `data-puck-component`, override Puck's inline position on
745
+ that same node. Do not force the Header root to `relative !important` and then
746
+ expect a parent sticky rule to work. Site and editor may use different
747
+ positioning strategies only when their visual result remains equivalent.
748
+
749
+ ### Transparent navigation is state plus layout
750
+
751
+ Transparent navigation must coordinate all of these concerns, not merely set
752
+ `background: transparent`:
753
+
754
+ - transparent background and removed shadow;
755
+ - logo, menu text, and button color changes;
756
+ - Hero or `PageOutlet` overlap beneath the Header;
757
+ - restoration of the solid state after the scroll threshold;
758
+ - Puck's root-node positioning mutation in the editor; and
759
+ - identical SSR-first-frame and hydrated state.
760
+
761
+ Never render a white logo/text state above an accidentally white navigation
762
+ background. Prefer React Context for a page's transparent-navigation request,
763
+ an SSR-readable DOM marker for the first-frame fallback, and a real
764
+ `PageOutlet` element with negative margin in the editor. The public site may use
765
+ a spacer or equivalent layout strategy. Keep shared measurements in CSS
766
+ variables, for example `--theme-navigation-height: 4.6rem`.
767
+
768
+ ### Editor scroll detection
769
+
770
+ Do not rely only on `window.scrollY` or a `window` scroll listener. The active
771
+ scroll source may be `document.scrollingElement`, the iframe document, or an
772
+ inner `overflow: auto/scroll` container, and `scroll` does not bubble.
773
+
774
+ - Find the nearest scrollable ancestor for each navigation instance and read
775
+ that element's own `scrollTop`.
776
+ - Listen on the document with
777
+ `document.addEventListener("scroll", handler, { capture: true, passive: true })`
778
+ and keep a window listener for public-site compatibility.
779
+ - Do not assume editor and site share the same scrolling element.
780
+
781
+ ### React and editor runtime lifecycle
782
+
783
+ Runtime code must tolerate editor remounts, live prop changes, HMR, frequent
784
+ `MutationObserver` callbacks, React Strict Mode effect replay, and loading after
785
+ `DOMContentLoaded` has already fired.
786
+
787
+ - Make event binding and initialization idempotent.
788
+ - Observe components inserted later and relevant attribute changes.
789
+ - Do not use a permanent `window.__xxxBound` flag that prevents required HMR
790
+ reinitialization.
791
+ - Clean up component effects, observers, and listeners.
792
+ - Keep SSR markers and client state synchronized instead of letting them fight.
793
+
794
+ ### Puck interaction styles
795
+
796
+ Assume edit mode may apply rules equivalent to:
797
+
798
+ ```css
799
+ [data-puck-component] * {
800
+ pointer-events: none;
801
+ user-select: none;
802
+ }
803
+
804
+ [data-puck-component] {
805
+ pointer-events: auto !important;
806
+ }
807
+ ```
808
+
809
+ An unclickable link, dropdown, carousel, or button in edit mode is not by
810
+ itself a theme interaction bug. Distinguish edit mode from preview mode. Never
811
+ globally restore descendant pointer events because that breaks selection and
812
+ dragging; test visitor interactions in editor preview and the public site.
813
+
814
+ ### Layout ownership
815
+
816
+ - Keep only `Header`, `PageOutlet`, `Footer`, and necessary global chrome such
817
+ as an announcement bar in `layoutConfig`.
818
+ - Render Header and Footer exactly once per page from the layout. Do not repeat
819
+ them in starter pages.
820
+ - If Footer or Header moves from page sections into the layout, remove duplicate
821
+ entries from `starterPages`, `cmsTemplates`, `pageConfig.categories`, and AI
822
+ examples.
823
+ - Give Header, `PageOutlet`, and Footer stable `props.id` values, with
824
+ `PageOutlet` between Header and Footer.
825
+ - Read platform white-label, ICP, and other footer metadata from runtime
826
+ metadata; do not persist it as duplicated static component data.
827
+
828
+ ### Vendor CSS
829
+
830
+ Do not modify original third-party minified CSS unless the task explicitly
831
+ requires a maintained vendor patch. Use precise selectors in the theme's own
832
+ scoped `src/styles.css`. If a vendor file truly must change, document the
833
+ reproducible problem and why an override cannot solve it.
834
+
835
+ ### New-theme completion checklist
836
+
837
+ When creating a theme, complete all of these in the initial implementation:
838
+
839
+ - editor root marker and stable real roots;
840
+ - layout-owned Header / `PageOutlet` / Footer with stable ids;
841
+ - Header sticky compatibility in the editor;
842
+ - transparent navigation in editor and site modes;
843
+ - scrollable-ancestor detection and an SSR state marker;
844
+ - idempotent runtime setup and cleanup;
845
+ - real-element `PageOutlet` overlap behavior;
846
+ - responsive viewport behavior; and
847
+ - editor preview versus public-site comparison.
848
+
849
+ ### Required regression matrix
850
+
851
+ Whenever Header, transparent navigation, sticky/fixed positioning,
852
+ `PageOutlet`, Footer, carousel, dropdown/mobile menu, or a `100vh` Hero changes,
853
+ verify:
854
+
855
+ - public-site SSR first frame and post-hydration state;
856
+ - editor desktop, tablet, and mobile viewports;
857
+ - editor edit mode and preview mode;
858
+ - initial top state and state after crossing the scroll threshold;
859
+ - state after HMR and live prop updates;
860
+ - exactly one Header and one Footer; and
861
+ - intact Puck selection and drag behavior.
862
+
863
+ ### Debugging order
864
+
865
+ When editor and site differ, inspect in this order before changing CSS:
866
+
867
+ 1. The component's actual root node.
868
+ 2. The element that received `data-puck-component`.
869
+ 3. Inline styles written on that element.
870
+ 4. Computed `position`, `background`, `z-index`, and ancestor `overflow`.
871
+ 5. The real scrolling element and its `scrollTop`.
872
+ 6. Iframe versus outer-canvas coordinate systems.
873
+ 7. Whether the theme runtime initialized.
874
+ 8. Transparent-state Context and DOM markers.
875
+ 9. Stylesheet load and cascade order.
876
+
877
+ Do not guess selectors repeatedly before confirming the DOM and computed style.
878
+
647
879
  ## Design system rules
648
880
 
649
881
  Build every theme from one theme-level design system. Do not let each section,