@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.
Files changed (86) hide show
  1. package/ANALYTICS.md +136 -0
  2. package/CHANGELOG.md +466 -0
  3. package/CMS_INFRASTRUCTURE.md +335 -0
  4. package/CONSENT.md +121 -0
  5. package/README.md +13 -8
  6. package/dist/cmsRegistration.d.ts +152 -0
  7. package/dist/cmsRegistration.d.ts.map +1 -0
  8. package/dist/cmsRegistration.js +145 -0
  9. package/dist/cmsRegistration.js.map +1 -0
  10. package/dist/components/CmsCollection.d.ts +2 -1
  11. package/dist/components/CmsCollection.d.ts.map +1 -1
  12. package/dist/components/CmsCollection.js +1 -1
  13. package/dist/components/CmsCollection.js.map +1 -1
  14. package/dist/components/CmsComponent.d.ts +2 -1
  15. package/dist/components/CmsComponent.d.ts.map +1 -1
  16. package/dist/components/CmsComponent.js.map +1 -1
  17. package/dist/index.d.ts +6 -4
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +6 -3
  20. package/dist/index.js.map +1 -1
  21. package/dist/showcase/components/AllViewPanel.d.ts +7 -0
  22. package/dist/showcase/components/AllViewPanel.d.ts.map +1 -0
  23. package/dist/showcase/components/AllViewPanel.js +35 -0
  24. package/dist/showcase/components/AllViewPanel.js.map +1 -0
  25. package/dist/showcase/components/Controls.d.ts +15 -0
  26. package/dist/showcase/components/Controls.d.ts.map +1 -0
  27. package/dist/showcase/components/Controls.js +74 -0
  28. package/dist/showcase/components/Controls.js.map +1 -0
  29. package/dist/showcase/components/ControlsWrapper.d.ts +13 -0
  30. package/dist/showcase/components/ControlsWrapper.d.ts.map +1 -0
  31. package/dist/showcase/components/ControlsWrapper.js +9 -0
  32. package/dist/showcase/components/ControlsWrapper.js.map +1 -0
  33. package/dist/showcase/components/PreviewPanel.d.ts +10 -0
  34. package/dist/showcase/components/PreviewPanel.d.ts.map +1 -0
  35. package/dist/showcase/components/PreviewPanel.js +42 -0
  36. package/dist/showcase/components/PreviewPanel.js.map +1 -0
  37. package/dist/showcase/components/ScaledIframe.d.ts +10 -0
  38. package/dist/showcase/components/ScaledIframe.d.ts.map +1 -0
  39. package/dist/showcase/components/ScaledIframe.js +16 -0
  40. package/dist/showcase/components/ScaledIframe.js.map +1 -0
  41. package/dist/showcase/components/ShowcaseAllRenderPage.d.ts +19 -0
  42. package/dist/showcase/components/ShowcaseAllRenderPage.d.ts.map +1 -0
  43. package/dist/showcase/components/ShowcaseAllRenderPage.js +46 -0
  44. package/dist/showcase/components/ShowcaseAllRenderPage.js.map +1 -0
  45. package/dist/showcase/components/ShowcasePage.d.ts +15 -0
  46. package/dist/showcase/components/ShowcasePage.d.ts.map +1 -0
  47. package/dist/showcase/components/ShowcasePage.js +16 -0
  48. package/dist/showcase/components/ShowcasePage.js.map +1 -0
  49. package/dist/showcase/components/ShowcaseRenderPage.d.ts +19 -0
  50. package/dist/showcase/components/ShowcaseRenderPage.d.ts.map +1 -0
  51. package/dist/showcase/components/ShowcaseRenderPage.js +51 -0
  52. package/dist/showcase/components/ShowcaseRenderPage.js.map +1 -0
  53. package/dist/showcase/components/TopBar.d.ts +11 -0
  54. package/dist/showcase/components/TopBar.d.ts.map +1 -0
  55. package/dist/showcase/components/TopBar.js +103 -0
  56. package/dist/showcase/components/TopBar.js.map +1 -0
  57. package/dist/showcase/index.d.ts +12 -0
  58. package/dist/showcase/index.d.ts.map +1 -0
  59. package/dist/showcase/index.js +12 -0
  60. package/dist/showcase/index.js.map +1 -0
  61. package/dist/showcase/mockFactory.d.ts +34 -0
  62. package/dist/showcase/mockFactory.d.ts.map +1 -0
  63. package/dist/showcase/mockFactory.js +352 -0
  64. package/dist/showcase/mockFactory.js.map +1 -0
  65. package/dist/showcase/types.d.ts +20 -0
  66. package/dist/showcase/types.d.ts.map +1 -0
  67. package/dist/showcase/types.js +18 -0
  68. package/dist/showcase/types.js.map +1 -0
  69. package/dist/utils/buildPageMetadata.d.ts +20 -1
  70. package/dist/utils/buildPageMetadata.d.ts.map +1 -1
  71. package/dist/utils/buildPageMetadata.js +37 -0
  72. package/dist/utils/buildPageMetadata.js.map +1 -1
  73. package/dist/utils/componentUtils.d.ts +39 -146
  74. package/dist/utils/componentUtils.d.ts.map +1 -1
  75. package/dist/utils/componentUtils.js +142 -101
  76. package/dist/utils/componentUtils.js.map +1 -1
  77. package/dist/utils/urlUtils.d.ts +5 -0
  78. package/dist/utils/urlUtils.d.ts.map +1 -1
  79. package/dist/utils/urlUtils.js +10 -0
  80. package/dist/utils/urlUtils.js.map +1 -1
  81. package/package.json +9 -6
  82. package/src/showcase/README.md +131 -0
  83. package/dist/__tests__/setup.d.ts +0 -2
  84. package/dist/__tests__/setup.d.ts.map +0 -1
  85. package/dist/__tests__/setup.js +0 -2
  86. 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,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
@@ -1,2 +0,0 @@
1
- import '@testing-library/jest-dom';
2
- //# sourceMappingURL=setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}