@se-studio/core-ui 1.0.45 → 1.0.47
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/ANALYTICS.md +136 -0
- package/CHANGELOG.md +466 -0
- package/CMS_INFRASTRUCTURE.md +335 -0
- package/CONSENT.md +121 -0
- package/README.md +13 -8
- package/dist/cmsRegistration.d.ts +152 -0
- package/dist/cmsRegistration.d.ts.map +1 -0
- package/dist/cmsRegistration.js +145 -0
- package/dist/cmsRegistration.js.map +1 -0
- package/dist/components/CmsCollection.d.ts +2 -1
- package/dist/components/CmsCollection.d.ts.map +1 -1
- package/dist/components/CmsCollection.js +1 -1
- package/dist/components/CmsCollection.js.map +1 -1
- package/dist/components/CmsComponent.d.ts +2 -1
- package/dist/components/CmsComponent.d.ts.map +1 -1
- package/dist/components/CmsComponent.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/showcase/components/AllViewPanel.d.ts +7 -0
- package/dist/showcase/components/AllViewPanel.d.ts.map +1 -0
- package/dist/showcase/components/AllViewPanel.js +35 -0
- package/dist/showcase/components/AllViewPanel.js.map +1 -0
- package/dist/showcase/components/Controls.d.ts +15 -0
- package/dist/showcase/components/Controls.d.ts.map +1 -0
- package/dist/showcase/components/Controls.js +74 -0
- package/dist/showcase/components/Controls.js.map +1 -0
- package/dist/showcase/components/ControlsWrapper.d.ts +13 -0
- package/dist/showcase/components/ControlsWrapper.d.ts.map +1 -0
- package/dist/showcase/components/ControlsWrapper.js +9 -0
- package/dist/showcase/components/ControlsWrapper.js.map +1 -0
- package/dist/showcase/components/PreviewPanel.d.ts +10 -0
- package/dist/showcase/components/PreviewPanel.d.ts.map +1 -0
- package/dist/showcase/components/PreviewPanel.js +42 -0
- package/dist/showcase/components/PreviewPanel.js.map +1 -0
- package/dist/showcase/components/ScaledIframe.d.ts +10 -0
- package/dist/showcase/components/ScaledIframe.d.ts.map +1 -0
- package/dist/showcase/components/ScaledIframe.js +16 -0
- package/dist/showcase/components/ScaledIframe.js.map +1 -0
- package/dist/showcase/components/ShowcaseAllRenderPage.d.ts +19 -0
- package/dist/showcase/components/ShowcaseAllRenderPage.d.ts.map +1 -0
- package/dist/showcase/components/ShowcaseAllRenderPage.js +46 -0
- package/dist/showcase/components/ShowcaseAllRenderPage.js.map +1 -0
- package/dist/showcase/components/ShowcasePage.d.ts +15 -0
- package/dist/showcase/components/ShowcasePage.d.ts.map +1 -0
- package/dist/showcase/components/ShowcasePage.js +16 -0
- package/dist/showcase/components/ShowcasePage.js.map +1 -0
- package/dist/showcase/components/ShowcaseRenderPage.d.ts +19 -0
- package/dist/showcase/components/ShowcaseRenderPage.d.ts.map +1 -0
- package/dist/showcase/components/ShowcaseRenderPage.js +51 -0
- package/dist/showcase/components/ShowcaseRenderPage.js.map +1 -0
- package/dist/showcase/components/TopBar.d.ts +11 -0
- package/dist/showcase/components/TopBar.d.ts.map +1 -0
- package/dist/showcase/components/TopBar.js +103 -0
- package/dist/showcase/components/TopBar.js.map +1 -0
- package/dist/showcase/index.d.ts +12 -0
- package/dist/showcase/index.d.ts.map +1 -0
- package/dist/showcase/index.js +12 -0
- package/dist/showcase/index.js.map +1 -0
- package/dist/showcase/mockFactory.d.ts +34 -0
- package/dist/showcase/mockFactory.d.ts.map +1 -0
- package/dist/showcase/mockFactory.js +352 -0
- package/dist/showcase/mockFactory.js.map +1 -0
- package/dist/showcase/types.d.ts +20 -0
- package/dist/showcase/types.d.ts.map +1 -0
- package/dist/showcase/types.js +18 -0
- package/dist/showcase/types.js.map +1 -0
- package/dist/utils/buildPageMetadata.d.ts +20 -1
- package/dist/utils/buildPageMetadata.d.ts.map +1 -1
- package/dist/utils/buildPageMetadata.js +37 -0
- package/dist/utils/buildPageMetadata.js.map +1 -1
- package/dist/utils/componentUtils.d.ts +39 -146
- package/dist/utils/componentUtils.d.ts.map +1 -1
- package/dist/utils/componentUtils.js +142 -101
- package/dist/utils/componentUtils.js.map +1 -1
- package/dist/utils/urlUtils.d.ts +5 -0
- package/dist/utils/urlUtils.d.ts.map +1 -1
- package/dist/utils/urlUtils.js +10 -0
- package/dist/utils/urlUtils.js.map +1 -1
- package/package.json +9 -6
- package/src/showcase/README.md +131 -0
- package/dist/__tests__/setup.d.ts +0 -2
- package/dist/__tests__/setup.d.ts.map +0 -1
- package/dist/__tests__/setup.js +0 -2
- package/dist/__tests__/setup.js.map +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# CMS Showcase Infrastructure
|
|
2
|
+
|
|
3
|
+
The CMS Showcase is a developer tool designed to test and preview CMS components and collections with mock data. This directory contains the shared infrastructure used by multiple projects to implement their own showcase pages.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
The showcase is split into several key parts:
|
|
8
|
+
|
|
9
|
+
- `ShowcasePage.tsx`: The main container component that handles the layout, top bar, and panels.
|
|
10
|
+
- `ShowcaseRenderPage.tsx`: The iframe content component that renders the actual CMS component or collection with mock data.
|
|
11
|
+
- `mockFactory.ts`: Logic for generating mock data based on component/collection types and control state.
|
|
12
|
+
- `components/`: UI components for the showcase interface (Sidebar, Controls, TopBar, etc.).
|
|
13
|
+
- `types.ts`: TypeScript definitions for the showcase state and control options.
|
|
14
|
+
|
|
15
|
+
## Styling Conventions
|
|
16
|
+
|
|
17
|
+
**IMPORTANT:** Because this code is shared across multiple projects, it **must not** rely on project-specific Tailwind configurations.
|
|
18
|
+
|
|
19
|
+
All styling in this directory uses **hardcoded Tailwind arbitrary values** to ensure consistent rendering regardless of the host project's `tailwind.config.ts`.
|
|
20
|
+
|
|
21
|
+
- **Colors:** Use hex codes, e.g., `text-[#374151]`, `bg-[#f9fafb]`, `border-[#e5e7eb]`.
|
|
22
|
+
- **Spacing/Size:** Use pixel values, e.g., `text-[11px]`, `w-[300px]`, `p-[16px]`.
|
|
23
|
+
- **Fonts:** Use standard weights, e.g., `font-[500]`, `font-[600]`.
|
|
24
|
+
|
|
25
|
+
## Registration Pattern & `usedFields`
|
|
26
|
+
|
|
27
|
+
The showcase uses the `usedFields` and `cardUsedFields` from the CMS registration system to determine which controls to show for a given component or collection. It also uses the `mock` and `cardMock` properties to generate realistic initial data.
|
|
28
|
+
|
|
29
|
+
When you register a component using `defineComponent` or a collection using `defineCollection`, you provide a `Set<string>` of fields that the component actually uses. The `mockFactory` uses these sets to:
|
|
30
|
+
1. Filter the generated mock data to only include relevant fields.
|
|
31
|
+
2. Show or hide controls in the sidebar based on whether a field is "used".
|
|
32
|
+
|
|
33
|
+
Example registration:
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
export const HeroRegistration = defineComponent({
|
|
37
|
+
name: 'Hero', // Must match CMS componentType
|
|
38
|
+
renderer: Hero,
|
|
39
|
+
usedFields: new Set(['heading', 'preHeading', 'body', 'visual', 'links']),
|
|
40
|
+
mock: {
|
|
41
|
+
heading: 'Hero Heading',
|
|
42
|
+
body: 'Hero body text description.',
|
|
43
|
+
visual: { width: 1200, height: 600 },
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Integration Guide
|
|
49
|
+
|
|
50
|
+
To add a CMS Showcase to a project:
|
|
51
|
+
|
|
52
|
+
1. Create a `page.tsx` for the main showcase interface:
|
|
53
|
+
```tsx
|
|
54
|
+
import { ShowcasePage } from '@se-studio/core-ui';
|
|
55
|
+
import {
|
|
56
|
+
componentFieldsMap,
|
|
57
|
+
collectionFieldsMap,
|
|
58
|
+
projectRendererConfig,
|
|
59
|
+
// ... other props
|
|
60
|
+
} from '@/lib/cms';
|
|
61
|
+
|
|
62
|
+
export default async function Page({ searchParams }) {
|
|
63
|
+
return (
|
|
64
|
+
<ShowcasePage
|
|
65
|
+
searchParams={await searchParams}
|
|
66
|
+
rendererConfig={projectRendererConfig}
|
|
67
|
+
componentFieldsMap={componentFieldsMap}
|
|
68
|
+
collectionFieldsMap={collectionFieldsMap}
|
|
69
|
+
basePath="/cms-showcase"
|
|
70
|
+
// ... project-specific color options
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
2. Create a separate route for the preview iframe (e.g., `/cms-showcase/render/page.tsx`):
|
|
77
|
+
```tsx
|
|
78
|
+
import { ShowcaseRenderPage } from '@se-studio/core-ui';
|
|
79
|
+
import {
|
|
80
|
+
componentFieldsMap,
|
|
81
|
+
collectionFieldsMap,
|
|
82
|
+
collectionCardFieldsMap,
|
|
83
|
+
componentMockMap,
|
|
84
|
+
collectionMockMap,
|
|
85
|
+
collectionCardMockMap,
|
|
86
|
+
projectRendererConfig
|
|
87
|
+
} from '@/lib/cms';
|
|
88
|
+
|
|
89
|
+
export default async function Page({ searchParams }) {
|
|
90
|
+
return (
|
|
91
|
+
<ShowcaseRenderPage
|
|
92
|
+
searchParams={await searchParams}
|
|
93
|
+
rendererConfig={projectRendererConfig}
|
|
94
|
+
componentFieldsMap={componentFieldsMap}
|
|
95
|
+
collectionFieldsMap={collectionFieldsMap}
|
|
96
|
+
collectionCardFieldsMap={collectionCardFieldsMap}
|
|
97
|
+
componentMockMap={componentMockMap}
|
|
98
|
+
collectionMockMap={collectionMockMap}
|
|
99
|
+
collectionCardMockMap={collectionCardMockMap}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
3. Ensure your `cms.ts` exports all the maps built from registrations:
|
|
106
|
+
```ts
|
|
107
|
+
// Build maps from registrations
|
|
108
|
+
const {
|
|
109
|
+
componentMap,
|
|
110
|
+
componentFieldsMap,
|
|
111
|
+
componentMockMap
|
|
112
|
+
} = buildComponentMaps(componentRegistrations);
|
|
113
|
+
|
|
114
|
+
const {
|
|
115
|
+
collectionMap,
|
|
116
|
+
collectionFieldsMap,
|
|
117
|
+
collectionCardFieldsMap,
|
|
118
|
+
collectionMockMap,
|
|
119
|
+
collectionCardMockMap
|
|
120
|
+
} = buildCollectionMaps(collectionRegistrations);
|
|
121
|
+
|
|
122
|
+
// Export maps for cms-showcase
|
|
123
|
+
export {
|
|
124
|
+
componentFieldsMap,
|
|
125
|
+
collectionFieldsMap,
|
|
126
|
+
collectionCardFieldsMap,
|
|
127
|
+
componentMockMap,
|
|
128
|
+
collectionMockMap,
|
|
129
|
+
collectionCardMockMap,
|
|
130
|
+
};
|
|
131
|
+
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|
package/dist/__tests__/setup.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|