@asheeui/puck 0.0.0-stage → 2.3.0

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 (154) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +10 -0
  3. package/README.md +126 -3
  4. package/dist/index.d.ts +22 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +23 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/index.native.d.ts +22 -0
  9. package/dist/index.native.d.ts.map +1 -0
  10. package/dist/index.native.js +22 -0
  11. package/dist/index.native.js.map +1 -0
  12. package/dist/native/blocks/content.d.ts +19 -0
  13. package/dist/native/blocks/content.d.ts.map +1 -0
  14. package/dist/native/blocks/content.js +29 -0
  15. package/dist/native/blocks/content.js.map +1 -0
  16. package/dist/native/blocks/layout.d.ts +42 -0
  17. package/dist/native/blocks/layout.d.ts.map +1 -0
  18. package/dist/native/blocks/layout.js +33 -0
  19. package/dist/native/blocks/layout.js.map +1 -0
  20. package/dist/native/blocks/navigation.d.ts +19 -0
  21. package/dist/native/blocks/navigation.d.ts.map +1 -0
  22. package/dist/native/blocks/navigation.js +38 -0
  23. package/dist/native/blocks/navigation.js.map +1 -0
  24. package/dist/native/blocks/sections.d.ts +30 -0
  25. package/dist/native/blocks/sections.d.ts.map +1 -0
  26. package/dist/native/blocks/sections.js +60 -0
  27. package/dist/native/blocks/sections.js.map +1 -0
  28. package/dist/native/blocks/utility.d.ts +13 -0
  29. package/dist/native/blocks/utility.d.ts.map +1 -0
  30. package/dist/native/blocks/utility.js +18 -0
  31. package/dist/native/blocks/utility.js.map +1 -0
  32. package/dist/native/config.d.ts +19 -0
  33. package/dist/native/config.d.ts.map +1 -0
  34. package/dist/native/config.js +45 -0
  35. package/dist/native/config.js.map +1 -0
  36. package/dist/native/index.d.ts +18 -0
  37. package/dist/native/index.d.ts.map +1 -0
  38. package/dist/native/index.js +18 -0
  39. package/dist/native/index.js.map +1 -0
  40. package/dist/native/render.d.ts +39 -0
  41. package/dist/native/render.d.ts.map +1 -0
  42. package/dist/native/render.js +71 -0
  43. package/dist/native/render.js.map +1 -0
  44. package/dist/native/root.d.ts +21 -0
  45. package/dist/native/root.d.ts.map +1 -0
  46. package/dist/native/root.js +28 -0
  47. package/dist/native/root.js.map +1 -0
  48. package/dist/shared/adapters.d.ts +52 -0
  49. package/dist/shared/adapters.d.ts.map +1 -0
  50. package/dist/shared/adapters.js +57 -0
  51. package/dist/shared/adapters.js.map +1 -0
  52. package/dist/shared/blocks/content.d.ts +42 -0
  53. package/dist/shared/blocks/content.d.ts.map +1 -0
  54. package/dist/shared/blocks/content.js +44 -0
  55. package/dist/shared/blocks/content.js.map +1 -0
  56. package/dist/shared/blocks/index.d.ts +42 -0
  57. package/dist/shared/blocks/index.d.ts.map +1 -0
  58. package/dist/shared/blocks/index.js +81 -0
  59. package/dist/shared/blocks/index.js.map +1 -0
  60. package/dist/shared/blocks/layout.d.ts +52 -0
  61. package/dist/shared/blocks/layout.d.ts.map +1 -0
  62. package/dist/shared/blocks/layout.js +51 -0
  63. package/dist/shared/blocks/layout.js.map +1 -0
  64. package/dist/shared/blocks/navigation.d.ts +74 -0
  65. package/dist/shared/blocks/navigation.d.ts.map +1 -0
  66. package/dist/shared/blocks/navigation.js +86 -0
  67. package/dist/shared/blocks/navigation.js.map +1 -0
  68. package/dist/shared/blocks/sections.d.ts +142 -0
  69. package/dist/shared/blocks/sections.d.ts.map +1 -0
  70. package/dist/shared/blocks/sections.js +166 -0
  71. package/dist/shared/blocks/sections.js.map +1 -0
  72. package/dist/shared/blocks/utility.d.ts +31 -0
  73. package/dist/shared/blocks/utility.d.ts.map +1 -0
  74. package/dist/shared/blocks/utility.js +36 -0
  75. package/dist/shared/blocks/utility.js.map +1 -0
  76. package/dist/shared/fields.d.ts +103 -0
  77. package/dist/shared/fields.d.ts.map +1 -0
  78. package/dist/shared/fields.js +162 -0
  79. package/dist/shared/fields.js.map +1 -0
  80. package/dist/shared/index.d.ts +14 -0
  81. package/dist/shared/index.d.ts.map +1 -0
  82. package/dist/shared/index.js +14 -0
  83. package/dist/shared/index.js.map +1 -0
  84. package/dist/shared/types.d.ts +235 -0
  85. package/dist/shared/types.d.ts.map +1 -0
  86. package/dist/shared/types.js +20 -0
  87. package/dist/shared/types.js.map +1 -0
  88. package/dist/web/blocks/content.d.ts +10 -0
  89. package/dist/web/blocks/content.d.ts.map +1 -0
  90. package/dist/web/blocks/content.js +28 -0
  91. package/dist/web/blocks/content.js.map +1 -0
  92. package/dist/web/blocks/layout.d.ts +27 -0
  93. package/dist/web/blocks/layout.d.ts.map +1 -0
  94. package/dist/web/blocks/layout.js +28 -0
  95. package/dist/web/blocks/layout.js.map +1 -0
  96. package/dist/web/blocks/navigation.d.ts +10 -0
  97. package/dist/web/blocks/navigation.d.ts.map +1 -0
  98. package/dist/web/blocks/navigation.js +38 -0
  99. package/dist/web/blocks/navigation.js.map +1 -0
  100. package/dist/web/blocks/sections.d.ts +22 -0
  101. package/dist/web/blocks/sections.d.ts.map +1 -0
  102. package/dist/web/blocks/sections.js +60 -0
  103. package/dist/web/blocks/sections.js.map +1 -0
  104. package/dist/web/blocks/utility.d.ts +6 -0
  105. package/dist/web/blocks/utility.d.ts.map +1 -0
  106. package/dist/web/blocks/utility.js +19 -0
  107. package/dist/web/blocks/utility.js.map +1 -0
  108. package/dist/web/config.d.ts +65 -0
  109. package/dist/web/config.d.ts.map +1 -0
  110. package/dist/web/config.js +35 -0
  111. package/dist/web/config.js.map +1 -0
  112. package/dist/web/index.d.ts +19 -0
  113. package/dist/web/index.d.ts.map +1 -0
  114. package/dist/web/index.js +20 -0
  115. package/dist/web/index.js.map +1 -0
  116. package/dist/web/page.d.ts +24 -0
  117. package/dist/web/page.d.ts.map +1 -0
  118. package/dist/web/page.js +27 -0
  119. package/dist/web/page.js.map +1 -0
  120. package/dist/web/root.d.ts +9 -0
  121. package/dist/web/root.d.ts.map +1 -0
  122. package/dist/web/root.js +26 -0
  123. package/dist/web/root.js.map +1 -0
  124. package/package.json +119 -3
  125. package/src/index.native.ts +22 -0
  126. package/src/index.ts +24 -0
  127. package/src/native/blocks/content.tsx +55 -0
  128. package/src/native/blocks/layout.tsx +72 -0
  129. package/src/native/blocks/navigation.tsx +71 -0
  130. package/src/native/blocks/sections.tsx +174 -0
  131. package/src/native/blocks/utility.tsx +27 -0
  132. package/src/native/config.tsx +66 -0
  133. package/src/native/index.ts +18 -0
  134. package/src/native/render.tsx +113 -0
  135. package/src/native/root.tsx +35 -0
  136. package/src/shared/adapters.ts +82 -0
  137. package/src/shared/blocks/content.ts +80 -0
  138. package/src/shared/blocks/index.ts +100 -0
  139. package/src/shared/blocks/layout.ts +82 -0
  140. package/src/shared/blocks/navigation.ts +168 -0
  141. package/src/shared/blocks/sections.ts +322 -0
  142. package/src/shared/blocks/utility.ts +65 -0
  143. package/src/shared/fields.ts +199 -0
  144. package/src/shared/index.ts +14 -0
  145. package/src/shared/types.ts +278 -0
  146. package/src/web/blocks/content.tsx +55 -0
  147. package/src/web/blocks/layout.tsx +73 -0
  148. package/src/web/blocks/navigation.tsx +72 -0
  149. package/src/web/blocks/sections.tsx +177 -0
  150. package/src/web/blocks/utility.tsx +31 -0
  151. package/src/web/config.tsx +141 -0
  152. package/src/web/index.ts +21 -0
  153. package/src/web/page.tsx +40 -0
  154. package/src/web/root.tsx +34 -0
@@ -0,0 +1,177 @@
1
+ "use client";
2
+
3
+ /**
4
+ * The web marketing section blocks.
5
+ *
6
+ * Each one is a thin adapter over the framework component of the same name, so the
7
+ * builder edits the component's own props rather than a parallel model of them. The
8
+ * label, the fields and the defaults come from `src/shared`; only the drawing is here.
9
+ */
10
+
11
+ import {
12
+ CTA,
13
+ FeatureGrid,
14
+ Hero,
15
+ PricingCard,
16
+ Testimonials,
17
+ } from "@asheeui/web";
18
+ import type {
19
+ AsheeBlock,
20
+ CtaBlockProps,
21
+ FeatureGridBlockProps,
22
+ HeroBlockProps,
23
+ PricingCardBlockProps,
24
+ TestimonialsBlockProps,
25
+ } from "../../shared";
26
+ import {
27
+ CTA_SPEC,
28
+ FEATURE_GRID_SPEC,
29
+ HERO_SPEC,
30
+ PRICING_CARD_SPEC,
31
+ TESTIMONIALS_SPEC,
32
+ toAction,
33
+ toColumns,
34
+ } from "../../shared";
35
+
36
+ /**
37
+ * The leading statement of a page.
38
+ */
39
+ export const heroBlock: AsheeBlock<HeroBlockProps> = {
40
+ ...HERO_SPEC,
41
+ render: ({
42
+ eyebrow,
43
+ title,
44
+ description,
45
+ primaryAction,
46
+ secondaryAction,
47
+ align,
48
+ background,
49
+ contentWidth,
50
+ }) => (
51
+ <Hero
52
+ eyebrow={eyebrow || undefined}
53
+ title={title ?? ""}
54
+ description={description || undefined}
55
+ primaryAction={toAction(primaryAction)}
56
+ secondaryAction={toAction(secondaryAction)}
57
+ align={align ?? "start"}
58
+ background={background ?? "none"}
59
+ containerSize={contentWidth ?? "lg"}
60
+ />
61
+ ),
62
+ };
63
+
64
+ /**
65
+ * The closing call to action of a page.
66
+ */
67
+ export const ctaBlock: AsheeBlock<CtaBlockProps> = {
68
+ ...CTA_SPEC,
69
+ render: ({
70
+ eyebrow,
71
+ title,
72
+ description,
73
+ primaryAction,
74
+ secondaryAction,
75
+ align,
76
+ background,
77
+ panel,
78
+ }) => (
79
+ <CTA
80
+ eyebrow={eyebrow || undefined}
81
+ title={title ?? ""}
82
+ description={description || undefined}
83
+ primaryAction={toAction(primaryAction)}
84
+ secondaryAction={toAction(secondaryAction)}
85
+ align={align ?? "center"}
86
+ background={background ?? "none"}
87
+ panel={panel ?? "bordered"}
88
+ />
89
+ ),
90
+ };
91
+
92
+ /**
93
+ * A band of features laid out in a responsive grid.
94
+ */
95
+ export const featureGridBlock: AsheeBlock<FeatureGridBlockProps> = {
96
+ ...FEATURE_GRID_SPEC,
97
+ render: ({
98
+ eyebrow,
99
+ title,
100
+ description,
101
+ items,
102
+ columnsMd,
103
+ columnsLg,
104
+ align,
105
+ background,
106
+ }) => (
107
+ <FeatureGrid
108
+ eyebrow={eyebrow || undefined}
109
+ title={title || undefined}
110
+ description={description || undefined}
111
+ align={align ?? "center"}
112
+ background={background ?? "none"}
113
+ columnsMd={toColumns(columnsMd)}
114
+ columnsLg={toColumns(columnsLg)}
115
+ items={(items ?? []).map((item, index) => ({
116
+ id: index,
117
+ title: item.title ?? "",
118
+ description: item.description || undefined,
119
+ }))}
120
+ />
121
+ ),
122
+ };
123
+
124
+ /**
125
+ * A band of attributed customer quotes.
126
+ */
127
+ export const testimonialsBlock: AsheeBlock<TestimonialsBlockProps> = {
128
+ ...TESTIMONIALS_SPEC,
129
+ render: ({ eyebrow, title, description, items, align }) => (
130
+ <Testimonials
131
+ eyebrow={eyebrow || undefined}
132
+ title={title || undefined}
133
+ description={description || undefined}
134
+ align={align ?? "center"}
135
+ items={(items ?? []).map((item, index) => ({
136
+ id: index,
137
+ quote: item.quote ?? "",
138
+ name: item.name ?? "",
139
+ role: item.role || undefined,
140
+ }))}
141
+ />
142
+ ),
143
+ };
144
+
145
+ /**
146
+ * One plan in a pricing table.
147
+ */
148
+ export const pricingCardBlock: AsheeBlock<PricingCardBlockProps> = {
149
+ ...PRICING_CARD_SPEC,
150
+ render: ({
151
+ badge,
152
+ name,
153
+ price,
154
+ period,
155
+ description,
156
+ features,
157
+ highlighted,
158
+ primaryAction,
159
+ }) => (
160
+ <div className="p-6">
161
+ <PricingCard
162
+ badge={badge || undefined}
163
+ name={name ?? ""}
164
+ price={price ?? ""}
165
+ period={period || undefined}
166
+ description={description || undefined}
167
+ highlighted={highlighted ?? false}
168
+ features={(features ?? []).map((feature, index) => ({
169
+ id: index,
170
+ label: feature.label ?? "",
171
+ included: feature.included !== false,
172
+ }))}
173
+ primaryAction={toAction(primaryAction)}
174
+ />
175
+ </div>
176
+ ),
177
+ };
@@ -0,0 +1,31 @@
1
+ "use client";
2
+
3
+ /**
4
+ * The web utility blocks.
5
+ *
6
+ * The empty state is the one utility block a marketing or application page needs from a
7
+ * builder: a region that has nothing in it yet, which a non-developer can word and
8
+ * justify without touching code. The fields and the defaults come from `src/shared`.
9
+ */
10
+
11
+ import { EmptyState } from "@asheeui/web";
12
+ import type { AsheeBlock, EmptyStateBlockProps } from "../../shared";
13
+ import { EMPTY_STATE_SPEC, toAction } from "../../shared";
14
+
15
+ /**
16
+ * A region with nothing in it.
17
+ */
18
+ export const emptyStateBlock: AsheeBlock<EmptyStateBlockProps> = {
19
+ ...EMPTY_STATE_SPEC,
20
+ render: ({ title, description, type, panel, primaryAction }) => (
21
+ <div className="p-6">
22
+ <EmptyState
23
+ title={title ?? ""}
24
+ description={description || undefined}
25
+ type={type ?? "info"}
26
+ panel={panel ?? false}
27
+ primaryAction={toAction(primaryAction)}
28
+ />
29
+ </div>
30
+ ),
31
+ };
@@ -0,0 +1,141 @@
1
+ "use client";
2
+
3
+ /**
4
+ * The AsheeUI configuration for Puck, on the web.
5
+ *
6
+ * This file is the registry the visual builder reads: every block, the category it
7
+ * belongs to, and the page shell a published page renders into. It contains no second
8
+ * implementation of any component. Each entry is the framework component plus the
9
+ * serializable configuration a builder can own, and the configuration half comes from
10
+ * `src/shared`, so the web editor and the native renderer offer one editor for one
11
+ * block.
12
+ *
13
+ * One assertion is made here and nowhere else: the components map and the category map
14
+ * are asserted to be the shape the editor's own `Config` describes. It is the single
15
+ * point where this package's platform-free field vocabulary meets the editor's, and a
16
+ * cast is what keeps the two descriptions from having to be one type in both halves —
17
+ * the native entry could not load if they were.
18
+ */
19
+
20
+ import type { Config } from "@puckeditor/core";
21
+ import type {
22
+ AsheePuckRootProps,
23
+ CtaBlockProps,
24
+ EmptyStateBlockProps,
25
+ FeatureGridBlockProps,
26
+ FooterBlockProps,
27
+ HeadingBlockProps,
28
+ HeroBlockProps,
29
+ NavbarBlockProps,
30
+ PricingCardBlockProps,
31
+ TestimonialsBlockProps,
32
+ TextBlockProps,
33
+ } from "../shared";
34
+ import { PUCK_CATEGORIES } from "../shared";
35
+ import { headingBlock, textBlock } from "./blocks/content";
36
+ import {
37
+ type ColumnsBlockProps,
38
+ columnsBlock,
39
+ type SectionBlockProps,
40
+ sectionBlock,
41
+ } from "./blocks/layout";
42
+ import { footerBlock, navbarBlock } from "./blocks/navigation";
43
+ import {
44
+ ctaBlock,
45
+ featureGridBlock,
46
+ heroBlock,
47
+ pricingCardBlock,
48
+ testimonialsBlock,
49
+ } from "./blocks/sections";
50
+ import { emptyStateBlock } from "./blocks/utility";
51
+ import { PuckRoot } from "./root";
52
+
53
+ /**
54
+ * Every block the AsheeUI configuration offers, with its props.
55
+ */
56
+ export type AsheePuckComponents = {
57
+ /** A band with vertical rhythm and a background. */
58
+ Section: SectionBlockProps;
59
+
60
+ /** A two-column arrangement that stacks on a narrow screen. */
61
+ Columns: ColumnsBlockProps;
62
+
63
+ /** A section heading. */
64
+ Heading: HeadingBlockProps;
65
+
66
+ /** A paragraph of body text. */
67
+ Text: TextBlockProps;
68
+
69
+ /** The navigation bar of a page. */
70
+ Navbar: NavbarBlockProps;
71
+
72
+ /** The footer of a page. */
73
+ Footer: FooterBlockProps;
74
+
75
+ /** The leading statement of a page. */
76
+ Hero: HeroBlockProps;
77
+
78
+ /** The closing call to action of a page. */
79
+ CTA: CtaBlockProps;
80
+
81
+ /** A band of features in a responsive grid. */
82
+ FeatureGrid: FeatureGridBlockProps;
83
+
84
+ /** A band of attributed customer quotes. */
85
+ Testimonials: TestimonialsBlockProps;
86
+
87
+ /** One plan in a pricing table. */
88
+ PricingCard: PricingCardBlockProps;
89
+
90
+ /** A region with nothing in it. */
91
+ EmptyState: EmptyStateBlockProps;
92
+ };
93
+
94
+ /**
95
+ * The categories a block can be filed under.
96
+ */
97
+ export type AsheePuckCategory =
98
+ | "Layout"
99
+ | "Navigation"
100
+ | "Hero"
101
+ | "Content"
102
+ | "Features"
103
+ | "CTA"
104
+ | "Pricing"
105
+ | "Testimonials"
106
+ | "Utility";
107
+
108
+ /**
109
+ * The type of the AsheeUI Puck configuration.
110
+ */
111
+ export type AsheePuckConfig = Config<{
112
+ components: AsheePuckComponents;
113
+ root: AsheePuckRootProps;
114
+ categories: AsheePuckCategory[];
115
+ }>;
116
+
117
+ /**
118
+ * The AsheeUI blocks, filed under the categories the builder shows.
119
+ */
120
+ export const asheePuckConfig: AsheePuckConfig = {
121
+ components: {
122
+ Section: sectionBlock,
123
+ Columns: columnsBlock,
124
+ Heading: headingBlock,
125
+ Text: textBlock,
126
+ Navbar: navbarBlock,
127
+ Footer: footerBlock,
128
+ Hero: heroBlock,
129
+ CTA: ctaBlock,
130
+ FeatureGrid: featureGridBlock,
131
+ Testimonials: testimonialsBlock,
132
+ PricingCard: pricingCardBlock,
133
+ EmptyState: emptyStateBlock,
134
+ } as unknown as AsheePuckConfig["components"],
135
+ categories: PUCK_CATEGORIES as unknown as AsheePuckConfig["categories"],
136
+ root: {
137
+ fields: {},
138
+ defaultProps: {},
139
+ render: ({ children }) => <PuckRoot>{children}</PuckRoot>,
140
+ },
141
+ };
@@ -0,0 +1,21 @@
1
+ "use client";
2
+
3
+ /**
4
+ * The web half of the Puck integration.
5
+ *
6
+ * It is the shared layer plus this platform's drawings: the block specs, the field
7
+ * builders and the adapters are re-exported unchanged, and the block registrations and
8
+ * the page renderer are the web's own. Nothing here imports React Native, and nothing
9
+ * here imports the native half of the package, so a browser bundle reaches only the DOM
10
+ * renderer.
11
+ */
12
+
13
+ export * from "../shared";
14
+ export * from "./blocks/content";
15
+ export * from "./blocks/layout";
16
+ export * from "./blocks/navigation";
17
+ export * from "./blocks/sections";
18
+ export * from "./blocks/utility";
19
+ export * from "./config";
20
+ export * from "./page";
21
+ export * from "./root";
@@ -0,0 +1,40 @@
1
+ "use client";
2
+
3
+ /**
4
+ * Rendering a stored page, on the web.
5
+ *
6
+ * A published page renders through the editor's own renderer, which needs no editor:
7
+ * the same block registry the builder reads is what a live site renders, so the two
8
+ * cannot drift. The native entry offers a component of the same name, so an application
9
+ * writes one import and one call and gets each platform's own renderer.
10
+ */
11
+
12
+ import { type Data, Render } from "@puckeditor/core";
13
+ import type { AsheePuckData } from "../shared";
14
+ import { type AsheePuckConfig, asheePuckConfig } from "./config";
15
+
16
+ /**
17
+ * Props of {@link PuckPage}.
18
+ */
19
+ export interface PuckPageProps {
20
+ /** The page the builder published. */
21
+ data: AsheePuckData;
22
+
23
+ /** The block registry to render with. Defaults to the AsheeUI configuration. */
24
+ config?: AsheePuckConfig;
25
+ }
26
+
27
+ /**
28
+ * Render a stored page.
29
+ *
30
+ * @param props - The stored page, and optionally the registry to render it with.
31
+ * @returns The rendered page.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * <PuckPage data={page} />
36
+ * ```
37
+ */
38
+ export function PuckPage({ data, config = asheePuckConfig }: PuckPageProps) {
39
+ return <Render config={config} data={data as unknown as Data} />;
40
+ }
@@ -0,0 +1,34 @@
1
+ "use client";
2
+
3
+ /**
4
+ * The page shell a published page renders into, on the web.
5
+ *
6
+ * A block resolves its theme through the framework provider, so the shell supplies one
7
+ * when the consumer has not. An existing provider is respected rather than nested, so a
8
+ * consumer's own configuration — a default theme, a component override — keeps applying
9
+ * to a built page. That is the whole reason this reads the context instead of always
10
+ * rendering a provider: a second provider would replace the resolved configuration with
11
+ * the framework's own defaults.
12
+ */
13
+
14
+ import { AsheeConfigContext, AsheeUIProvider } from "@asheeui/web";
15
+ import { useContext } from "react";
16
+ import type { AsheePuckRootProps } from "../shared";
17
+
18
+ /**
19
+ * The published page's root.
20
+ *
21
+ * @param props - The page the builder composed.
22
+ * @returns The page, inside the framework's provider when the application has none.
23
+ */
24
+ export function PuckRoot({ children }: AsheePuckRootProps) {
25
+ const existingConfig = useContext(AsheeConfigContext);
26
+
27
+ const page = (
28
+ <div className="flex min-h-dvh w-full flex-col bg-background text-foreground">
29
+ {children}
30
+ </div>
31
+ );
32
+
33
+ return existingConfig ? page : <AsheeUIProvider>{page}</AsheeUIProvider>;
34
+ }