@se-studio/core-ui 0.1.0 → 0.1.1
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/README.md +218 -20
- package/dist/CmsRendererConfig.d.ts +38 -0
- package/dist/CmsRendererConfig.d.ts.map +1 -0
- package/dist/CmsRendererConfig.js +2 -0
- package/dist/CmsRendererConfig.js.map +1 -0
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/setup.js +2 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/components/AnimationComponent.d.ts +13 -0
- package/dist/components/AnimationComponent.d.ts.map +1 -0
- package/dist/components/AnimationComponent.js +6 -0
- package/dist/components/AnimationComponent.js.map +1 -0
- package/dist/components/ClientMonitor.d.ts +2 -3
- package/dist/components/ClientMonitor.d.ts.map +1 -0
- package/dist/components/ClientMonitor.js +104 -102
- package/dist/components/ClientMonitor.js.map +1 -1
- package/dist/components/CmsCollection.d.ts +14 -0
- package/dist/components/CmsCollection.d.ts.map +1 -0
- package/dist/components/CmsCollection.js +26 -0
- package/dist/components/CmsCollection.js.map +1 -0
- package/dist/components/CmsComponent.d.ts +14 -0
- package/dist/components/CmsComponent.d.ts.map +1 -0
- package/dist/components/CmsComponent.js +26 -0
- package/dist/components/CmsComponent.js.map +1 -0
- package/dist/components/CmsContent.d.ts +22 -0
- package/dist/components/CmsContent.d.ts.map +1 -0
- package/dist/components/CmsContent.js +117 -0
- package/dist/components/CmsContent.js.map +1 -0
- package/dist/components/CmsDataError.d.ts +14 -0
- package/dist/components/CmsDataError.d.ts.map +1 -0
- package/dist/components/CmsDataError.js +7 -0
- package/dist/components/CmsDataError.js.map +1 -0
- package/dist/components/ImageComponent.d.ts +7 -0
- package/dist/components/ImageComponent.d.ts.map +1 -0
- package/dist/components/ImageComponent.js +14 -0
- package/dist/components/ImageComponent.js.map +1 -0
- package/dist/components/ImageKitClientVideo.d.ts +10 -0
- package/dist/components/ImageKitClientVideo.d.ts.map +1 -0
- package/dist/components/ImageKitClientVideo.js +30 -0
- package/dist/components/ImageKitClientVideo.js.map +1 -0
- package/dist/components/LocalVideo.d.ts +9 -0
- package/dist/components/LocalVideo.d.ts.map +1 -0
- package/dist/components/LocalVideo.js +31 -0
- package/dist/components/LocalVideo.js.map +1 -0
- package/dist/components/PictureComponent.d.ts +7 -0
- package/dist/components/PictureComponent.d.ts.map +1 -0
- package/dist/components/PictureComponent.js +28 -0
- package/dist/components/PictureComponent.js.map +1 -0
- package/dist/components/Preview.d.ts +2 -3
- package/dist/components/Preview.d.ts.map +1 -0
- package/dist/components/Preview.js +33 -31
- package/dist/components/Preview.js.map +1 -1
- package/dist/components/SvgComponent.d.ts +7 -0
- package/dist/components/SvgComponent.d.ts.map +1 -0
- package/dist/components/SvgComponent.js +8 -0
- package/dist/components/SvgComponent.js.map +1 -0
- package/dist/components/SvgImageComponent.d.ts +7 -0
- package/dist/components/SvgImageComponent.d.ts.map +1 -0
- package/dist/components/SvgImageComponent.js +10 -0
- package/dist/components/SvgImageComponent.js.map +1 -0
- package/dist/components/Video.d.ts +6 -0
- package/dist/components/Video.d.ts.map +1 -0
- package/dist/components/Video.js +2 -0
- package/dist/components/Video.js.map +1 -0
- package/dist/components/VideoComponent.d.ts +9 -0
- package/dist/components/VideoComponent.d.ts.map +1 -0
- package/dist/components/VideoComponent.js +11 -0
- package/dist/components/VideoComponent.js.map +1 -0
- package/dist/components/Visual.d.ts +30 -0
- package/dist/components/Visual.d.ts.map +1 -0
- package/dist/components/Visual.js +57 -0
- package/dist/components/Visual.js.map +1 -0
- package/dist/components/VisualComponent.d.ts +7 -0
- package/dist/components/VisualComponent.d.ts.map +1 -0
- package/dist/components/VisualComponent.js +19 -0
- package/dist/components/VisualComponent.js.map +1 -0
- package/dist/elements/RtfOrString.d.ts +13 -0
- package/dist/elements/RtfOrString.d.ts.map +1 -0
- package/dist/elements/RtfOrString.js +13 -0
- package/dist/elements/RtfOrString.js.map +1 -0
- package/dist/elements/UtmLink.d.ts +7 -0
- package/dist/elements/UtmLink.d.ts.map +1 -0
- package/dist/elements/UtmLink.js +24 -0
- package/dist/elements/UtmLink.js.map +1 -0
- package/dist/elements/UtmLinkOrDiv.d.ts +5 -0
- package/dist/elements/UtmLinkOrDiv.d.ts.map +1 -0
- package/dist/elements/UtmLinkOrDiv.js +9 -0
- package/dist/elements/UtmLinkOrDiv.js.map +1 -0
- package/dist/embeddable/BuildEmbed.d.ts +6 -0
- package/dist/embeddable/BuildEmbed.d.ts.map +1 -0
- package/dist/embeddable/BuildEmbed.js +15 -0
- package/dist/embeddable/BuildEmbed.js.map +1 -0
- package/dist/embeddable/EmbeddableContext.d.ts +14 -0
- package/dist/embeddable/EmbeddableContext.d.ts.map +1 -0
- package/dist/embeddable/EmbeddableContext.js +2 -0
- package/dist/embeddable/EmbeddableContext.js.map +1 -0
- package/dist/embeddable/EmbeddableMaps.d.ts +7 -0
- package/dist/embeddable/EmbeddableMaps.d.ts.map +1 -0
- package/dist/embeddable/EmbeddableMaps.js +7 -0
- package/dist/embeddable/EmbeddableMaps.js.map +1 -0
- package/dist/framework/BackgroundMedia.d.ts +11 -0
- package/dist/framework/BackgroundMedia.d.ts.map +1 -0
- package/dist/framework/BackgroundMedia.js +19 -0
- package/dist/framework/BackgroundMedia.js.map +1 -0
- package/dist/framework/ColourChange.d.ts +8 -0
- package/dist/framework/ColourChange.d.ts.map +1 -0
- package/dist/framework/ColourChange.js +13 -0
- package/dist/framework/ColourChange.js.map +1 -0
- package/dist/framework/ComponentErrorIndicator.d.ts +12 -0
- package/dist/framework/ComponentErrorIndicator.d.ts.map +1 -0
- package/dist/framework/ComponentErrorIndicator.js +26 -0
- package/dist/framework/ComponentErrorIndicator.js.map +1 -0
- package/dist/framework/componentErrors.d.ts +11 -0
- package/dist/framework/componentErrors.d.ts.map +1 -0
- package/dist/framework/componentErrors.js +21 -0
- package/dist/framework/componentErrors.js.map +1 -0
- package/dist/hooks/useClickTracking.d.ts +19 -0
- package/dist/hooks/useClickTracking.d.ts.map +1 -0
- package/dist/hooks/useClickTracking.js +19 -0
- package/dist/hooks/useClickTracking.js.map +1 -0
- package/dist/hooks/useDocumentVisible.d.ts +2 -3
- package/dist/hooks/useDocumentVisible.d.ts.map +1 -0
- package/dist/hooks/useDocumentVisible.js +15 -18
- package/dist/hooks/useDocumentVisible.js.map +1 -1
- package/dist/hooks/visibility.d.ts +14 -0
- package/dist/hooks/visibility.d.ts.map +1 -0
- package/dist/hooks/visibility.js +122 -0
- package/dist/hooks/visibility.js.map +1 -0
- package/dist/index.d.ts +40 -172
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -1077
- package/dist/index.js.map +1 -1
- package/dist/rtf/rtf.d.ts +11 -0
- package/dist/rtf/rtf.d.ts.map +1 -0
- package/dist/rtf/rtf.js +60 -0
- package/dist/rtf/rtf.js.map +1 -0
- package/dist/utils/UnsupportedWarning.d.ts +7 -0
- package/dist/utils/UnsupportedWarning.d.ts.map +1 -0
- package/dist/utils/UnsupportedWarning.js +20 -0
- package/dist/utils/UnsupportedWarning.js.map +1 -0
- package/dist/utils/UnusedChecker.d.ts +12 -0
- package/dist/utils/UnusedChecker.d.ts.map +1 -0
- package/dist/utils/UnusedChecker.js +53 -0
- package/dist/utils/UnusedChecker.js.map +1 -0
- package/dist/utils/buildPageMetadata.d.ts +11 -0
- package/dist/utils/buildPageMetadata.d.ts.map +1 -0
- package/dist/utils/buildPageMetadata.js +45 -0
- package/dist/utils/buildPageMetadata.js.map +1 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js +6 -0
- package/dist/utils/cn.js.map +1 -0
- package/dist/utils/componentUtils.d.ts +26 -0
- package/dist/utils/componentUtils.d.ts.map +1 -0
- package/dist/utils/componentUtils.js +46 -0
- package/dist/utils/componentUtils.js.map +1 -0
- package/dist/utils/convertText.d.ts +2 -0
- package/dist/utils/convertText.d.ts.map +1 -0
- package/dist/utils/convertText.js +33 -0
- package/dist/utils/convertText.js.map +1 -0
- package/dist/utils/errorHandling.d.ts +10 -0
- package/dist/utils/errorHandling.d.ts.map +1 -0
- package/dist/utils/errorHandling.js +27 -0
- package/dist/utils/errorHandling.js.map +1 -0
- package/dist/utils/previewUtils.d.ts +29 -0
- package/dist/utils/previewUtils.d.ts.map +1 -0
- package/dist/utils/previewUtils.js +24 -0
- package/dist/utils/previewUtils.js.map +1 -0
- package/dist/utils/visualPositions.d.ts +3 -0
- package/dist/utils/visualPositions.d.ts.map +1 -0
- package/dist/utils/visualPositions.js +14 -0
- package/dist/utils/visualPositions.js.map +1 -0
- package/dist/utils/visualSizes.d.ts +5 -0
- package/dist/utils/visualSizes.d.ts.map +1 -0
- package/dist/utils/visualSizes.js +21 -0
- package/dist/utils/visualSizes.js.map +1 -0
- package/package.json +13 -14
- package/dist/client.d.ts +0 -2
- package/dist/client.js +0 -8
- package/dist/client.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
# @se-studio/core-ui
|
|
2
2
|
|
|
3
|
-
Shared React UI component library with Tailwind CSS v4 for SE Studio applications.
|
|
3
|
+
Shared React UI component library with Tailwind CSS v4 and CMS infrastructure for SE Studio applications.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **React 19** - Built with the latest React
|
|
8
8
|
- **TypeScript** - Full type safety
|
|
9
|
-
- **
|
|
9
|
+
- **CMS Infrastructure** - Complete system for mapping Contentful content to React components
|
|
10
|
+
- **Tailwind CSS v4** - Modern utility-first CSS framework with custom breakpoints
|
|
11
|
+
- **Visual Components** - Optimized image, video, and animation components
|
|
12
|
+
- **Rich Text Rendering** - RTF (Rich Text Field) support with embedded content
|
|
10
13
|
- **Tree-shakeable** - Import only what you need
|
|
11
14
|
- **Dual exports** - ESM and CJS support
|
|
12
15
|
- **Fully tested** - Comprehensive test coverage with Vitest
|
|
@@ -17,23 +20,45 @@ Shared React UI component library with Tailwind CSS v4 for SE Studio application
|
|
|
17
20
|
pnpm add @se-studio/core-ui
|
|
18
21
|
```
|
|
19
22
|
|
|
20
|
-
##
|
|
23
|
+
## Quick Start
|
|
21
24
|
|
|
22
|
-
###
|
|
25
|
+
### Basic Component Usage
|
|
23
26
|
|
|
24
27
|
```tsx
|
|
25
|
-
import {
|
|
26
|
-
import type {
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
import { Visual } from '@se-studio/core-ui';
|
|
29
|
+
import type { IAsset } from '@se-studio/core-data-types';
|
|
30
|
+
|
|
31
|
+
const image: IAsset = {
|
|
32
|
+
src: 'https://images.ctfassets.net/...',
|
|
33
|
+
alt: 'Hero image',
|
|
34
|
+
width: 1920,
|
|
35
|
+
height: 1080
|
|
30
36
|
};
|
|
31
37
|
|
|
32
38
|
export default function MyPage() {
|
|
33
|
-
return <
|
|
39
|
+
return <Visual image={image} className="w-full h-auto" />;
|
|
34
40
|
}
|
|
35
41
|
```
|
|
36
42
|
|
|
43
|
+
### CMS Infrastructure Usage
|
|
44
|
+
|
|
45
|
+
For content-driven applications, use the CMS infrastructure:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { CmsContent } from '@se-studio/core-ui';
|
|
49
|
+
import { contentfulPageRest } from '@se-studio/contentful-rest-api';
|
|
50
|
+
|
|
51
|
+
// Fetch page from Contentful
|
|
52
|
+
const page = await contentfulPageRest(config, 'home');
|
|
53
|
+
|
|
54
|
+
// Automatically render the correct components
|
|
55
|
+
export default function Page() {
|
|
56
|
+
return <CmsContent content={page} config={rendererConfig} />;
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
See the [CMS Infrastructure Guide](./CMS_INFRASTRUCTURE.md) for detailed documentation.
|
|
61
|
+
|
|
37
62
|
### Using Tailwind Configuration
|
|
38
63
|
|
|
39
64
|
Import the Tailwind configuration in your `tailwind.config.ts`:
|
|
@@ -64,28 +89,109 @@ import '@se-studio/core-ui/styles';
|
|
|
64
89
|
|
|
65
90
|
## Components
|
|
66
91
|
|
|
67
|
-
###
|
|
92
|
+
### CMS Infrastructure Components
|
|
68
93
|
|
|
69
|
-
|
|
94
|
+
#### CmsContent
|
|
70
95
|
|
|
71
|
-
|
|
96
|
+
Main component for rendering CMS content with automatic component mapping.
|
|
72
97
|
|
|
73
|
-
|
|
74
|
-
- `
|
|
75
|
-
- `
|
|
98
|
+
**Props:**
|
|
99
|
+
- `content` - Page or entry content from Contentful
|
|
100
|
+
- `config` - `CmsRendererConfig` - Component and collection mapping configuration
|
|
101
|
+
- `context?` - Optional context data to pass to components
|
|
76
102
|
|
|
77
103
|
**Example:**
|
|
104
|
+
```tsx
|
|
105
|
+
import { CmsContent } from '@se-studio/core-ui';
|
|
106
|
+
|
|
107
|
+
<CmsContent content={page} config={rendererConfig} />
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### CmsComponent
|
|
111
|
+
|
|
112
|
+
Renders individual CMS components with type-based routing.
|
|
113
|
+
|
|
114
|
+
**Props:**
|
|
115
|
+
- `component` - Component data from Contentful
|
|
116
|
+
- `config` - Component mapping configuration
|
|
117
|
+
- `context?` - Optional context
|
|
118
|
+
|
|
119
|
+
#### CmsCollection
|
|
120
|
+
|
|
121
|
+
Renders CMS collections (arrays of components) with type-based routing.
|
|
78
122
|
|
|
123
|
+
**Props:**
|
|
124
|
+
- `collection` - Array of components from Contentful
|
|
125
|
+
- `config` - Collection mapping configuration
|
|
126
|
+
- `context?` - Optional context
|
|
127
|
+
|
|
128
|
+
### Visual Components
|
|
129
|
+
|
|
130
|
+
#### Visual
|
|
131
|
+
|
|
132
|
+
Optimized image/video component with Next.js Image integration.
|
|
133
|
+
|
|
134
|
+
**Props:**
|
|
135
|
+
- `image` - `IAsset` - Image data with src, alt, width, height
|
|
136
|
+
- `video?` - `IAsset` - Optional video data
|
|
137
|
+
- `animation?` - `IAsset` - Optional animation/Lottie data
|
|
138
|
+
- `className?` - Additional CSS classes
|
|
139
|
+
- `priority?` - Enable priority loading for above-the-fold content
|
|
140
|
+
- `fill?` - Use Next.js Image fill mode
|
|
141
|
+
|
|
142
|
+
**Example:**
|
|
79
143
|
```tsx
|
|
80
|
-
import {
|
|
144
|
+
import { Visual } from '@se-studio/core-ui';
|
|
81
145
|
|
|
82
|
-
<
|
|
83
|
-
|
|
146
|
+
<Visual
|
|
147
|
+
image={imageData}
|
|
84
148
|
className="w-full h-auto"
|
|
85
149
|
priority
|
|
86
150
|
/>
|
|
87
151
|
```
|
|
88
152
|
|
|
153
|
+
### Rich Text Components
|
|
154
|
+
|
|
155
|
+
#### RTF (Rich Text Field)
|
|
156
|
+
|
|
157
|
+
Renders Contentful rich text with support for embedded entries and assets.
|
|
158
|
+
|
|
159
|
+
**Props:**
|
|
160
|
+
- `document` - Contentful rich text document
|
|
161
|
+
- `embeddedComponents?` - Configuration for embedded components
|
|
162
|
+
- `embeddedCollections?` - Configuration for embedded collections
|
|
163
|
+
|
|
164
|
+
**Example:**
|
|
165
|
+
```tsx
|
|
166
|
+
import { RTF } from '@se-studio/core-ui';
|
|
167
|
+
|
|
168
|
+
<RTF
|
|
169
|
+
document={richTextField}
|
|
170
|
+
embeddedComponents={componentConfig}
|
|
171
|
+
/>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Utility Components
|
|
175
|
+
|
|
176
|
+
#### UnusedChecker
|
|
177
|
+
|
|
178
|
+
Development utility to detect unused CMS content types in your configuration.
|
|
179
|
+
|
|
180
|
+
**Props:**
|
|
181
|
+
- `config` - Your CMS renderer configuration
|
|
182
|
+
- `pages` - Array of pages to check against
|
|
183
|
+
- `allowedUnused?` - Array of content types allowed to be unused
|
|
184
|
+
|
|
185
|
+
**Example:**
|
|
186
|
+
```tsx
|
|
187
|
+
import { UnusedChecker } from '@se-studio/core-ui';
|
|
188
|
+
|
|
189
|
+
<UnusedChecker
|
|
190
|
+
config={rendererConfig}
|
|
191
|
+
pages={allPages}
|
|
192
|
+
/>
|
|
193
|
+
```
|
|
194
|
+
|
|
89
195
|
## Development
|
|
90
196
|
|
|
91
197
|
```bash
|
|
@@ -108,7 +214,9 @@ pnpm type-check
|
|
|
108
214
|
pnpm lint
|
|
109
215
|
```
|
|
110
216
|
|
|
111
|
-
##
|
|
217
|
+
## Tailwind Configuration
|
|
218
|
+
|
|
219
|
+
### Custom Breakpoints
|
|
112
220
|
|
|
113
221
|
The library includes custom breakpoints optimized for modern responsive design:
|
|
114
222
|
|
|
@@ -116,6 +224,96 @@ The library includes custom breakpoints optimized for modern responsive design:
|
|
|
116
224
|
- `laptop`: 1024px
|
|
117
225
|
- `desktop`: 1440px
|
|
118
226
|
|
|
227
|
+
Use them in your Tailwind classes:
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
<div className="hidden tablet:block laptop:grid laptop:grid-cols-2 desktop:grid-cols-3">
|
|
231
|
+
{/* Content */}
|
|
232
|
+
</div>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Typography Utilities
|
|
236
|
+
|
|
237
|
+
Custom typography styles are available:
|
|
238
|
+
|
|
239
|
+
- `text-h1` - Heading 1 style
|
|
240
|
+
- `text-h2` - Heading 2 style
|
|
241
|
+
- `text-h3` - Heading 3 style
|
|
242
|
+
- `text-h4` - Heading 4 style
|
|
243
|
+
- `text-body` - Body text style
|
|
244
|
+
- `text-body-sm` - Small body text
|
|
245
|
+
|
|
246
|
+
## Configuration System
|
|
247
|
+
|
|
248
|
+
The package exports several configuration utilities:
|
|
249
|
+
|
|
250
|
+
### createCmsRendererConfig
|
|
251
|
+
|
|
252
|
+
Creates a type-safe CMS renderer configuration:
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
import { createCmsRendererConfig } from '@se-studio/core-ui';
|
|
256
|
+
|
|
257
|
+
const config = createCmsRendererConfig({
|
|
258
|
+
components: {
|
|
259
|
+
heroSection: HeroComponent,
|
|
260
|
+
featureSection: FeatureComponent
|
|
261
|
+
},
|
|
262
|
+
collections: {
|
|
263
|
+
cardGrid: CardGridCollection
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### mergeCmsRendererConfig
|
|
269
|
+
|
|
270
|
+
Merges multiple configurations (useful for environment-specific or preview mode configs):
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
import { mergeCmsRendererConfig } from '@se-studio/core-ui';
|
|
274
|
+
|
|
275
|
+
const previewConfig = mergeCmsRendererConfig(
|
|
276
|
+
baseConfig,
|
|
277
|
+
previewOverrides
|
|
278
|
+
);
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## API Exports
|
|
282
|
+
|
|
283
|
+
### Component Configuration Types
|
|
284
|
+
|
|
285
|
+
- `ComponentConfig<TComponent, TContext>` - Type-safe component configuration
|
|
286
|
+
- `CollectionConfig<TCollection, TContext>` - Type-safe collection configuration
|
|
287
|
+
- `CmsRendererConfig` - Complete renderer configuration type
|
|
288
|
+
|
|
289
|
+
### Utility Functions
|
|
290
|
+
|
|
291
|
+
- `buildPageMetadata(page)` - Generate Next.js metadata from page data
|
|
292
|
+
- `handleCmsError(error)` - Error handling utility for CMS operations
|
|
293
|
+
- `extractComponentInfo(component, config)` - Extract component rendering info
|
|
294
|
+
- `extractCollectionInfo(collection, config)` - Extract collection rendering info
|
|
295
|
+
|
|
296
|
+
## Advanced Usage
|
|
297
|
+
|
|
298
|
+
For advanced CMS infrastructure usage, including:
|
|
299
|
+
- Configuration composition patterns
|
|
300
|
+
- Embeddable components
|
|
301
|
+
- Context passing
|
|
302
|
+
- Type-safe prop extraction
|
|
303
|
+
- Preview mode setup
|
|
304
|
+
|
|
305
|
+
See the [CMS Infrastructure Guide](./CMS_INFRASTRUCTURE.md).
|
|
306
|
+
|
|
307
|
+
## Examples
|
|
308
|
+
|
|
309
|
+
Check out the [example-pointme app](../../apps/example-pointme) for a complete implementation using all core-ui features.
|
|
310
|
+
|
|
311
|
+
## Learn More
|
|
312
|
+
|
|
313
|
+
- [CMS Infrastructure Guide](./CMS_INFRASTRUCTURE.md) - Comprehensive guide to the CMS system
|
|
314
|
+
- [Core Data Types](../core-data-types/README.md) - Shared TypeScript types
|
|
315
|
+
- [Contentful REST API](../contentful-rest-api/README.md) - API client for Contentful
|
|
316
|
+
|
|
119
317
|
## License
|
|
120
318
|
|
|
121
319
|
MIT
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { IContentContext } from '@se-studio/core-data-types';
|
|
2
|
+
import type { React } from 'next/dist/server/route-modules/app-page/vendored/rsc/entrypoints';
|
|
3
|
+
import type { PropsWithChildren } from 'react';
|
|
4
|
+
import type { CollectionMap } from './components/CmsCollection';
|
|
5
|
+
import type { ComponentMap } from './components/CmsComponent';
|
|
6
|
+
import type { ExternalComponentMap, InternalLinkRenderer, VisualComponentRenderer } from './components/CmsContent';
|
|
7
|
+
export interface CmsRendererConfig {
|
|
8
|
+
componentMap: ComponentMap;
|
|
9
|
+
collectionMap: CollectionMap;
|
|
10
|
+
externalComponentMap: ExternalComponentMap;
|
|
11
|
+
visualComponentRenderer: VisualComponentRenderer;
|
|
12
|
+
internalLinkRenderer: InternalLinkRenderer;
|
|
13
|
+
customContentMap?: Partial<Record<string, React.FC<{
|
|
14
|
+
information: any;
|
|
15
|
+
contentContext: IContentContext;
|
|
16
|
+
}>>>;
|
|
17
|
+
showUnknownTypeErrors: boolean;
|
|
18
|
+
showRenderErrors: boolean;
|
|
19
|
+
defaultComponentRenderer: React.FC<{
|
|
20
|
+
information: any;
|
|
21
|
+
contentContext: IContentContext;
|
|
22
|
+
rendererConfig: CmsRendererConfig;
|
|
23
|
+
}>;
|
|
24
|
+
defaultCollectionRenderer: React.FC<{
|
|
25
|
+
information: any;
|
|
26
|
+
contentContext: IContentContext;
|
|
27
|
+
rendererConfig: CmsRendererConfig;
|
|
28
|
+
}>;
|
|
29
|
+
basicLinkRenderer: React.FC<PropsWithChildren<{
|
|
30
|
+
href?: string;
|
|
31
|
+
}>>;
|
|
32
|
+
embeddedContentRenderer: React.FC<{
|
|
33
|
+
information: any;
|
|
34
|
+
contentContext: IContentContext;
|
|
35
|
+
rendererConfig: CmsRendererConfig;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=CmsRendererConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CmsRendererConfig.d.ts","sourceRoot":"","sources":["../src/CmsRendererConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kEAAkE,CAAC;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AAyCjC,MAAM,WAAW,iBAAiB;IAahC,YAAY,EAAE,YAAY,CAAC;IAc3B,aAAa,EAAE,aAAa,CAAC;IAc7B,oBAAoB,EAAE,oBAAoB,CAAC;IAa3C,uBAAuB,EAAE,uBAAuB,CAAC;IAajD,oBAAoB,EAAE,oBAAoB,CAAC;IAc3C,gBAAgB,CAAC,EAAE,OAAO,CACxB,MAAM,CACJ,MAAM,EACN,KAAK,CAAC,EAAE,CAAC;QACP,WAAW,EAAE,GAAG,CAAC;QACjB,cAAc,EAAE,eAAe,CAAC;KACjC,CAAC,CACH,CACF,CAAC;IAQF,qBAAqB,EAAE,OAAO,CAAC;IAQ/B,gBAAgB,EAAE,OAAO,CAAC;IAE1B,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC;QACjC,WAAW,EAAE,GAAG,CAAC;QACjB,cAAc,EAAE,eAAe,CAAC;QAChC,cAAc,EAAE,iBAAiB,CAAC;KACnC,CAAC,CAAC;IACH,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC;QAClC,WAAW,EAAE,GAAG,CAAC;QACjB,cAAc,EAAE,eAAe,CAAC;QAChC,cAAc,EAAE,iBAAiB,CAAC;KACnC,CAAC,CAAC;IACH,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAClE,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC;QAChC,WAAW,EAAE,GAAG,CAAC;QACjB,cAAc,EAAE,eAAe,CAAC;QAChC,cAAc,EAAE,iBAAiB,CAAC;KACnC,CAAC,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CmsRendererConfig.js","sourceRoot":"","sources":["../src/CmsRendererConfig.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IAnimation } from '@se-studio/core-data-types';
|
|
2
|
+
import type { IVisualProps } from './Visual';
|
|
3
|
+
interface IAnimationProps extends IVisualProps {
|
|
4
|
+
direction?: number;
|
|
5
|
+
controls?: boolean;
|
|
6
|
+
count?: number;
|
|
7
|
+
hover?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare function Animation({ className, style, }: {
|
|
10
|
+
animation: IAnimation;
|
|
11
|
+
} & Omit<IAnimationProps, 'analyticsContext' | 'componentLabel'>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default Animation;
|
|
13
|
+
//# sourceMappingURL=AnimationComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationComponent.d.ts","sourceRoot":"","sources":["../../src/components/AnimationComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,UAAU,eAAgB,SAAQ,YAAY;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,iBAAS,SAAS,CAAC,EACjB,SAAS,EACT,KAAK,GACN,EAAE;IACD,SAAS,EAAE,UAAU,CAAC;CACvB,GAAG,IAAI,CAAC,eAAe,EAAE,kBAAkB,GAAG,gBAAgB,CAAC,2CAM/D;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
function Animation({ className, style, }) {
|
|
3
|
+
return (_jsx("div", { className: className, style: style, children: "Animation Component" }));
|
|
4
|
+
}
|
|
5
|
+
export default Animation;
|
|
6
|
+
//# sourceMappingURL=AnimationComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimationComponent.js","sourceRoot":"","sources":["../../src/components/AnimationComponent.tsx"],"names":[],"mappings":";AAUA,SAAS,SAAS,CAAC,EACjB,SAAS,EACT,KAAK,GAGyD;IAC9D,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,oCAEjC,CACP,CAAC;AACJ,CAAC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
declare const ClientMonitor: React.FC;
|
|
2
|
-
|
|
3
|
-
export { ClientMonitor };
|
|
1
|
+
export declare const ClientMonitor: React.FC;
|
|
2
|
+
//# sourceMappingURL=ClientMonitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientMonitor.d.ts","sourceRoot":"","sources":["../../src/components/ClientMonitor.tsx"],"names":[],"mappings":"AA4JA,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAYjC,CAAC"}
|
|
@@ -1,135 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
import { usePathname } from
|
|
3
|
-
import { useEffect } from
|
|
4
|
-
import { useDocumentVisible } from
|
|
1
|
+
'use client';
|
|
2
|
+
import { usePathname } from 'next/navigation';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { useDocumentVisible } from '../hooks/useDocumentVisible';
|
|
5
5
|
let _observer;
|
|
6
6
|
function handleVideo(video, isIntersecting) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (!isIntersecting) {
|
|
8
|
+
if (!video.paused) {
|
|
9
|
+
video.pause();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
else if (video.paused) {
|
|
13
|
+
video
|
|
14
|
+
.play()
|
|
15
|
+
.then(() => {
|
|
16
|
+
video.controls = false;
|
|
17
|
+
})
|
|
18
|
+
.catch(() => {
|
|
19
|
+
});
|
|
10
20
|
}
|
|
11
|
-
} else if (video.paused) {
|
|
12
|
-
video.play().then(() => {
|
|
13
|
-
video.controls = false;
|
|
14
|
-
}).catch(() => {
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
21
|
}
|
|
18
22
|
function handleAnimation(animation, isIntersecting) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} else {
|
|
25
|
-
if (currentState === "paused") {
|
|
26
|
-
animation.play();
|
|
23
|
+
const currentState = animation.currentState;
|
|
24
|
+
if (!isIntersecting) {
|
|
25
|
+
if (currentState === 'playing') {
|
|
26
|
+
animation.pause();
|
|
27
|
+
}
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
else {
|
|
30
|
+
if (currentState === 'paused') {
|
|
31
|
+
animation.play();
|
|
32
|
+
}
|
|
33
|
+
if (!currentState || currentState === 'loading') {
|
|
34
|
+
if (animation.play) {
|
|
35
|
+
animation.play();
|
|
36
|
+
}
|
|
37
|
+
animation.autoplay = true;
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
|
-
}
|
|
35
40
|
}
|
|
36
41
|
function handleAnimatedSection(section, isIntersecting) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
section.dataset.visible = isIntersecting ? 'true' : 'false';
|
|
43
|
+
if (isIntersecting) {
|
|
44
|
+
if (!section.dataset.seen) {
|
|
45
|
+
section.dataset.seen = 'true';
|
|
46
|
+
}
|
|
41
47
|
}
|
|
42
|
-
}
|
|
43
48
|
}
|
|
44
49
|
function intersectionHandler(entries) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
const target = entry.target;
|
|
52
|
+
switch (target.localName) {
|
|
53
|
+
case 'video':
|
|
54
|
+
handleVideo(target, entry.isIntersecting);
|
|
55
|
+
break;
|
|
56
|
+
case 'lottie-player':
|
|
57
|
+
handleAnimation(target, entry.isIntersecting);
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
{
|
|
61
|
+
const element = target;
|
|
62
|
+
handleAnimatedSection(element, entry.isIntersecting);
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
58
65
|
}
|
|
59
|
-
break;
|
|
60
66
|
}
|
|
61
|
-
}
|
|
62
67
|
}
|
|
63
68
|
function getObserver() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
if (!_observer) {
|
|
70
|
+
const observer = new IntersectionObserver(intersectionHandler, {
|
|
71
|
+
threshold: 0.2,
|
|
72
|
+
});
|
|
73
|
+
_observer = observer;
|
|
74
|
+
}
|
|
75
|
+
return _observer;
|
|
71
76
|
}
|
|
72
77
|
function findAllVideos() {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
for (const video of videos) {
|
|
76
|
-
video.controls = false;
|
|
77
|
-
video.muted = true;
|
|
78
|
-
observer.observe(video);
|
|
79
|
-
}
|
|
80
|
-
return () => {
|
|
78
|
+
const videos = document.getElementsByTagName('video');
|
|
79
|
+
const observer = getObserver();
|
|
81
80
|
for (const video of videos) {
|
|
82
|
-
|
|
81
|
+
video.controls = false;
|
|
82
|
+
video.muted = true;
|
|
83
|
+
observer.observe(video);
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
+
return () => {
|
|
86
|
+
for (const video of videos) {
|
|
87
|
+
observer.unobserve(video);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
85
90
|
}
|
|
86
91
|
function findAllAnimations() {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
for (const animation of animations) {
|
|
90
|
-
observer.observe(animation);
|
|
91
|
-
}
|
|
92
|
-
return () => {
|
|
92
|
+
const animations = document.getElementsByTagName('lottie-player');
|
|
93
|
+
const observer = getObserver();
|
|
93
94
|
for (const animation of animations) {
|
|
94
|
-
|
|
95
|
+
observer.observe(animation);
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
+
return () => {
|
|
98
|
+
for (const animation of animations) {
|
|
99
|
+
observer.unobserve(animation);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
97
102
|
}
|
|
98
103
|
function findAllAnimatedSections() {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
for (const section of sections) {
|
|
102
|
-
observer.observe(section);
|
|
103
|
-
}
|
|
104
|
-
return () => {
|
|
104
|
+
const sections = document.querySelectorAll('[data-component]');
|
|
105
|
+
const observer = getObserver();
|
|
105
106
|
for (const section of sections) {
|
|
106
|
-
|
|
107
|
+
observer.observe(section);
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
+
return () => {
|
|
110
|
+
for (const section of sections) {
|
|
111
|
+
observer.unobserve(section);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
109
114
|
}
|
|
110
115
|
function findAll() {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
const videoCleanup = findAllVideos();
|
|
117
|
+
const animationCleanup = findAllAnimations();
|
|
118
|
+
const animatedSectionCleanup = findAllAnimatedSections();
|
|
119
|
+
return () => {
|
|
120
|
+
videoCleanup();
|
|
121
|
+
animationCleanup();
|
|
122
|
+
animatedSectionCleanup();
|
|
123
|
+
};
|
|
119
124
|
}
|
|
120
|
-
const ClientMonitor = () => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
};
|
|
132
|
-
export {
|
|
133
|
-
ClientMonitor
|
|
125
|
+
export const ClientMonitor = () => {
|
|
126
|
+
const isDocumentVisible = useDocumentVisible();
|
|
127
|
+
const pathname = usePathname();
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
pathname;
|
|
130
|
+
if (isDocumentVisible) {
|
|
131
|
+
return findAll();
|
|
132
|
+
}
|
|
133
|
+
return undefined;
|
|
134
|
+
}, [pathname, isDocumentVisible]);
|
|
135
|
+
return null;
|
|
134
136
|
};
|
|
135
137
|
//# sourceMappingURL=ClientMonitor.js.map
|