fimo-react 0.21.0-experimental.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 +21 -0
- package/dist/runtime/content/DataSourcesProvider.d.ts +4 -0
- package/dist/runtime/content/DataSourcesProvider.js +63 -0
- package/dist/runtime/content/RefreshContentProvider.d.ts +19 -0
- package/dist/runtime/content/RefreshContentProvider.js +71 -0
- package/dist/runtime/content/createContentClient.d.ts +7 -0
- package/dist/runtime/content/createContentClient.js +7 -0
- package/dist/runtime/content/createSingletonClient.d.ts +5 -0
- package/dist/runtime/content/createSingletonClient.js +6 -0
- package/dist/runtime/content/fixtures/Author.d.ts +48 -0
- package/dist/runtime/content/fixtures/Author.js +22 -0
- package/dist/runtime/content/fixtures/Author.types.d.ts +38 -0
- package/dist/runtime/content/fixtures/Author.types.js +1 -0
- package/dist/runtime/content/fixtures/Post.d.ts +48 -0
- package/dist/runtime/content/fixtures/Post.js +37 -0
- package/dist/runtime/content/fixtures/Post.types.d.ts +50 -0
- package/dist/runtime/content/fixtures/Post.types.js +1 -0
- package/dist/runtime/content/fixtures/SiteSettings.d.ts +42 -0
- package/dist/runtime/content/fixtures/SiteSettings.js +15 -0
- package/dist/runtime/content/fixtures/usage-contract.d.ts +3 -0
- package/dist/runtime/content/fixtures/usage-contract.js +57 -0
- package/dist/runtime/content/fixtures/virtual-fimo-config.d.ts +3 -0
- package/dist/runtime/content/fixtures/virtual-fimo-config.js +3 -0
- package/dist/runtime/content/index.d.ts +5 -0
- package/dist/runtime/content/index.js +2 -0
- package/dist/runtime/content/react-content-client.d.ts +10 -0
- package/dist/runtime/content/react-content-client.js +164 -0
- package/dist/runtime/content/react-singleton-client.d.ts +7 -0
- package/dist/runtime/content/react-singleton-client.js +37 -0
- package/dist/runtime/content/retrieve-data-sources.d.ts +29 -0
- package/dist/runtime/content/retrieve-data-sources.js +107 -0
- package/dist/runtime/content/types.d.ts +42 -0
- package/dist/runtime/content/types.js +1 -0
- package/dist/runtime/content/useQueryLocale.d.ts +2 -0
- package/dist/runtime/content/useQueryLocale.js +5 -0
- package/dist/runtime/content/vite-runtime.d.ts +3 -0
- package/dist/runtime/content/vite-runtime.js +23 -0
- package/dist/runtime/core/AppErrorBoundary.d.ts +10 -0
- package/dist/runtime/core/AppErrorBoundary.js +27 -0
- package/dist/runtime/core/ViteLifecycles.d.ts +5 -0
- package/dist/runtime/core/ViteLifecycles.js +35 -0
- package/dist/runtime/i18n-context.d.ts +9 -0
- package/dist/runtime/i18n-context.js +17 -0
- package/dist/runtime/iframe/ConsoleErrorProvider.d.ts +3 -0
- package/dist/runtime/iframe/ConsoleErrorProvider.js +103 -0
- package/dist/runtime/iframe/ScreenshotProvider.d.ts +3 -0
- package/dist/runtime/iframe/ScreenshotProvider.js +60 -0
- package/dist/runtime/index.d.ts +24 -0
- package/dist/runtime/index.js +24 -0
- package/dist/runtime/internal.d.ts +3 -0
- package/dist/runtime/internal.js +6 -0
- package/dist/runtime/primitives-server.d.ts +7 -0
- package/dist/runtime/primitives-server.js +5 -0
- package/dist/runtime/primitives.d.ts +17 -0
- package/dist/runtime/primitives.js +18 -0
- package/dist/runtime/react/primitives/contracts.d.ts +100 -0
- package/dist/runtime/react/primitives/contracts.js +1 -0
- package/dist/runtime/react/primitives/editable/Boolean.d.ts +5 -0
- package/dist/runtime/react/primitives/editable/Boolean.js +11 -0
- package/dist/runtime/react/primitives/editable/Date.d.ts +4 -0
- package/dist/runtime/react/primitives/editable/Date.js +12 -0
- package/dist/runtime/react/primitives/editable/DateTime.d.ts +4 -0
- package/dist/runtime/react/primitives/editable/DateTime.js +13 -0
- package/dist/runtime/react/primitives/editable/Image.d.ts +4 -0
- package/dist/runtime/react/primitives/editable/Image.js +10 -0
- package/dist/runtime/react/primitives/editable/Json.d.ts +5 -0
- package/dist/runtime/react/primitives/editable/Json.js +11 -0
- package/dist/runtime/react/primitives/editable/RichText.d.ts +4 -0
- package/dist/runtime/react/primitives/editable/RichText.js +11 -0
- package/dist/runtime/react/primitives/editable/Text.d.ts +20 -0
- package/dist/runtime/react/primitives/editable/Text.js +36 -0
- package/dist/runtime/react/primitives/editable/Video.d.ts +4 -0
- package/dist/runtime/react/primitives/editable/Video.js +10 -0
- package/dist/runtime/react/primitives/renderers/DateRenderer.d.ts +17 -0
- package/dist/runtime/react/primitives/renderers/DateRenderer.js +17 -0
- package/dist/runtime/react/primitives/renderers/ImageRenderer.d.ts +8 -0
- package/dist/runtime/react/primitives/renderers/ImageRenderer.js +30 -0
- package/dist/runtime/react/primitives/renderers/RichTextRenderer.d.ts +12 -0
- package/dist/runtime/react/primitives/renderers/RichTextRenderer.js +135 -0
- package/dist/runtime/react/primitives/renderers/StaticImage.d.ts +35 -0
- package/dist/runtime/react/primitives/renderers/StaticImage.js +58 -0
- package/dist/runtime/react/primitives/renderers/VideoRenderer.d.ts +8 -0
- package/dist/runtime/react/primitives/renderers/VideoRenderer.js +10 -0
- package/dist/runtime/react/useFimoLiveValue.d.ts +20 -0
- package/dist/runtime/react/useFimoLiveValue.js +43 -0
- package/dist/runtime/vite/Label.d.ts +13 -0
- package/dist/runtime/vite/Label.js +16 -0
- package/dist/runtime/vite/__fixtures__/virtual-translations.d.ts +5 -0
- package/dist/runtime/vite/__fixtures__/virtual-translations.js +6 -0
- package/dist/runtime/vite/primitives/Images.d.ts +4 -0
- package/dist/runtime/vite/primitives/Images.js +12 -0
- package/dist/runtime/vite/translations.d.ts +28 -0
- package/dist/runtime/vite/translations.js +103 -0
- package/package.json +72 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useIsFetching } from '@tanstack/react-query';
|
|
3
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
// Wait for all running CSS/JS animations to complete
|
|
5
|
+
const waitForAnimations = async () => {
|
|
6
|
+
const animations = document.getAnimations();
|
|
7
|
+
if (animations.length === 0) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
await Promise.all(animations.map((a) => a.finished.catch(() => { })));
|
|
11
|
+
// Small buffer for final paint after animations
|
|
12
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
13
|
+
};
|
|
14
|
+
// This internal component tracks query status and signals when it's safe to screenshot.
|
|
15
|
+
const ScreenshotReadySignaler = () => {
|
|
16
|
+
const isFetching = useIsFetching();
|
|
17
|
+
const hasSeenFetching = useRef(false);
|
|
18
|
+
const hasSignaledReady = useRef(false);
|
|
19
|
+
const fallbackTimerRef = useRef(null);
|
|
20
|
+
const signalReady = useCallback(async () => {
|
|
21
|
+
if (hasSignaledReady.current) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
hasSignaledReady.current = true;
|
|
25
|
+
await waitForAnimations();
|
|
26
|
+
document.body.setAttribute('data-screenshot-ready', 'true');
|
|
27
|
+
}, []);
|
|
28
|
+
// This effect handles the primary logic for pages with data fetching.
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (hasSignaledReady.current) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (isFetching > 0) {
|
|
34
|
+
hasSeenFetching.current = true;
|
|
35
|
+
// A query is active, so we can clear the fallback timer.
|
|
36
|
+
if (fallbackTimerRef.current) {
|
|
37
|
+
clearTimeout(fallbackTimerRef.current);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (hasSeenFetching.current && isFetching === 0) {
|
|
41
|
+
signalReady();
|
|
42
|
+
}
|
|
43
|
+
}, [isFetching, signalReady]);
|
|
44
|
+
// This effect sets up a fallback for static pages without queries.
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
fallbackTimerRef.current = setTimeout(() => {
|
|
47
|
+
signalReady();
|
|
48
|
+
}, 1500); // Wait 1.5 seconds for static pages.
|
|
49
|
+
// Cleanup the timer on unmount.
|
|
50
|
+
return () => {
|
|
51
|
+
if (fallbackTimerRef.current) {
|
|
52
|
+
clearTimeout(fallbackTimerRef.current);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, [signalReady]); // Run only once on mount.
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
58
|
+
export const ScreenshotProvider = ({ children }) => {
|
|
59
|
+
return (_jsxs(_Fragment, { children: [_jsx(ScreenshotReadySignaler, {}), children] }));
|
|
60
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { useLocale } from './i18n-context.js';
|
|
2
|
+
export { localizeFimoPath, resolveFimoLocale } from 'fimo/config';
|
|
3
|
+
export type { FimoLocaleContextValue } from './i18n-context.js';
|
|
4
|
+
export type { FimoLocaleResolution } from 'fimo/config';
|
|
5
|
+
export { DataSourcesProvider } from './content/DataSourcesProvider.js';
|
|
6
|
+
export { RefreshContentProvider } from './content/RefreshContentProvider.js';
|
|
7
|
+
export { parseCollectionResponse } from 'fimo/content';
|
|
8
|
+
export type { CollectionResponse } from 'fimo/content';
|
|
9
|
+
export { createContentClient } from './content/createContentClient.js';
|
|
10
|
+
export { createSingletonClient } from './content/createSingletonClient.js';
|
|
11
|
+
export { createReactContentClient } from './content/react-content-client.js';
|
|
12
|
+
export { createReactSingletonClient } from './content/react-singleton-client.js';
|
|
13
|
+
export { createFormClient, type FormClient, type FormSubmissionResult } from 'fimo/forms';
|
|
14
|
+
export { Label } from './vite/Label.js';
|
|
15
|
+
export type { LabelProps } from './vite/Label.js';
|
|
16
|
+
export { useLabels, useTranslations } from './vite/translations.js';
|
|
17
|
+
export declare const formClient: import("fimo/forms").FormClient;
|
|
18
|
+
export type { CollectionContentClient, CollectionPage, CollectionPageInfo, ContentClientConfig, ContentClientHandle, ContentModuleMeta, ContentModuleRef, ContentReadOptions, ContentResult, ContentSchema, ContentSchemaField, InfiniteListResult, SingletonContentClient, } from './content/types.js';
|
|
19
|
+
export { AppErrorBoundary } from './core/AppErrorBoundary.js';
|
|
20
|
+
export { ViteLifecycles } from './core/ViteLifecycles.js';
|
|
21
|
+
export { ConsoleErrorProvider } from './iframe/ConsoleErrorProvider.js';
|
|
22
|
+
export { ScreenshotProvider } from './iframe/ScreenshotProvider.js';
|
|
23
|
+
export * from './primitives.js';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createFormClient } from 'fimo/forms';
|
|
2
|
+
import { viteContentRuntime } from './content/vite-runtime.js';
|
|
3
|
+
// Locale
|
|
4
|
+
export { useLocale } from './i18n-context.js';
|
|
5
|
+
export { localizeFimoPath, resolveFimoLocale } from 'fimo/config';
|
|
6
|
+
// Content
|
|
7
|
+
export { DataSourcesProvider } from './content/DataSourcesProvider.js';
|
|
8
|
+
export { RefreshContentProvider } from './content/RefreshContentProvider.js';
|
|
9
|
+
export { parseCollectionResponse } from 'fimo/content';
|
|
10
|
+
export { createContentClient } from './content/createContentClient.js';
|
|
11
|
+
export { createSingletonClient } from './content/createSingletonClient.js';
|
|
12
|
+
export { createReactContentClient } from './content/react-content-client.js';
|
|
13
|
+
export { createReactSingletonClient } from './content/react-singleton-client.js';
|
|
14
|
+
export { createFormClient } from 'fimo/forms';
|
|
15
|
+
export { Label } from './vite/Label.js';
|
|
16
|
+
export { useLabels, useTranslations } from './vite/translations.js';
|
|
17
|
+
export const formClient = createFormClient(viteContentRuntime);
|
|
18
|
+
// Core
|
|
19
|
+
export { AppErrorBoundary } from './core/AppErrorBoundary.js';
|
|
20
|
+
export { ViteLifecycles } from './core/ViteLifecycles.js';
|
|
21
|
+
// Iframe
|
|
22
|
+
export { ConsoleErrorProvider } from './iframe/ConsoleErrorProvider.js';
|
|
23
|
+
export { ScreenshotProvider } from './iframe/ScreenshotProvider.js';
|
|
24
|
+
export * from './primitives.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// `fimo-react/internal` — pieces the Fimo framework adapters compose but that
|
|
2
|
+
// applications never import directly. Not covered by semver expectations for
|
|
3
|
+
// application code; it exists so `fimo-react-router` (and any future React
|
|
4
|
+
// framework adapter) does not have to reach into `dist/` paths.
|
|
5
|
+
export { FimoLocaleProvider, useLocale } from './i18n-context.js';
|
|
6
|
+
export { onError } from './core/AppErrorBoundary.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DateRenderer } from './react/primitives/renderers/DateRenderer.js';
|
|
2
|
+
export { ImageRenderer } from './react/primitives/renderers/ImageRenderer.js';
|
|
3
|
+
export { RichTextRenderer } from './react/primitives/renderers/RichTextRenderer.js';
|
|
4
|
+
export { StaticImage } from './react/primitives/renderers/StaticImage.js';
|
|
5
|
+
export { VideoRenderer } from './react/primitives/renderers/VideoRenderer.js';
|
|
6
|
+
export type { BaseImageProps, BaseVideoProps, BooleanProps, DateProps, FimoRichTextComponents, FimoRichTextMarkProps, FimoRichTextNodeProps, ImageProps, JsonProps, RichTextProps, StaticImageProps, TextProps, VideoProps, } from './react/primitives/contracts.js';
|
|
7
|
+
//# sourceMappingURL=primitives-server.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DateRenderer } from './react/primitives/renderers/DateRenderer.js';
|
|
2
|
+
export { ImageRenderer } from './react/primitives/renderers/ImageRenderer.js';
|
|
3
|
+
export { RichTextRenderer } from './react/primitives/renderers/RichTextRenderer.js';
|
|
4
|
+
export { StaticImage } from './react/primitives/renderers/StaticImage.js';
|
|
5
|
+
export { VideoRenderer } from './react/primitives/renderers/VideoRenderer.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { Text } from './react/primitives/editable/Text.js';
|
|
2
|
+
export { Image, StaticImage } from './vite/primitives/Images.js';
|
|
3
|
+
export { Video } from './react/primitives/editable/Video.js';
|
|
4
|
+
export { Date } from './react/primitives/editable/Date.js';
|
|
5
|
+
export { DateTime } from './react/primitives/editable/DateTime.js';
|
|
6
|
+
export { Boolean } from './react/primitives/editable/Boolean.js';
|
|
7
|
+
export { Json } from './react/primitives/editable/Json.js';
|
|
8
|
+
export { RichText } from './react/primitives/editable/RichText.js';
|
|
9
|
+
export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, type FimoPolymorphicReference, type FimoReference, type FimoSource, type FimoPart, type FimoRichTextContent, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, fimo, } from 'fimo/primitives';
|
|
10
|
+
export type { BaseImageProps, BaseVideoProps, BooleanProps, DateProps, FimoRichTextComponents, FimoRichTextMarkProps, FimoRichTextNodeProps, ImageProps, JsonProps, RichTextProps, StaticImageProps, TextProps, VideoProps, } from './react/primitives/contracts.js';
|
|
11
|
+
export { useFimoLiveValue } from './react/useFimoLiveValue.js';
|
|
12
|
+
export { DateRenderer } from './react/primitives/renderers/DateRenderer.js';
|
|
13
|
+
export { ImageRenderer } from './react/primitives/renderers/ImageRenderer.js';
|
|
14
|
+
export { RichTextRenderer } from './react/primitives/renderers/RichTextRenderer.js';
|
|
15
|
+
export { VideoRenderer } from './react/primitives/renderers/VideoRenderer.js';
|
|
16
|
+
export type { BoolOps, DateOps, Field, Fields, FilterFor, NullOnlyOps, NumberOps, Populate, Populated, PopulatedResult, Projected, ProjectedWithPopulate, Query, ReferenceField, ReferenceMap, ScalarOps, Sort, SortField, StringOps, WithReferences, Where, } from 'fimo/primitives';
|
|
17
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Fimo UI — components and primitives for source-tracked inline editing
|
|
2
|
+
// This module is auto-synced and should not be modified by agents or users.
|
|
3
|
+
// Components
|
|
4
|
+
export { Text } from './react/primitives/editable/Text.js';
|
|
5
|
+
export { Image, StaticImage } from './vite/primitives/Images.js';
|
|
6
|
+
export { Video } from './react/primitives/editable/Video.js';
|
|
7
|
+
export { Date } from './react/primitives/editable/Date.js';
|
|
8
|
+
export { DateTime } from './react/primitives/editable/DateTime.js';
|
|
9
|
+
export { Boolean } from './react/primitives/editable/Boolean.js';
|
|
10
|
+
export { Json } from './react/primitives/editable/Json.js';
|
|
11
|
+
export { RichText } from './react/primitives/editable/RichText.js';
|
|
12
|
+
// Primitives & utilities
|
|
13
|
+
export { FimoString, FimoDate, FimoMedia, FimoBoolean, FimoRichText, FIMO_SOURCE, FIMO_PARTS, isFimoString, isFimoDate, hasFimoSource, getFimoSource, getFimoParts, fimo, } from 'fimo/primitives';
|
|
14
|
+
export { useFimoLiveValue } from './react/useFimoLiveValue.js';
|
|
15
|
+
export { DateRenderer } from './react/primitives/renderers/DateRenderer.js';
|
|
16
|
+
export { ImageRenderer } from './react/primitives/renderers/ImageRenderer.js';
|
|
17
|
+
export { RichTextRenderer } from './react/primitives/renderers/RichTextRenderer.js';
|
|
18
|
+
export { VideoRenderer } from './react/primitives/renderers/VideoRenderer.js';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { ImageFit } from 'fimo/primitives';
|
|
2
|
+
import type { FimoBoolean, FimoDate, FimoMedia, FimoRichText, FimoRichTextContent, FimoString } from 'fimo/primitives';
|
|
3
|
+
import type { ComponentPropsWithoutRef, ComponentType, ElementType, ReactNode } from 'react';
|
|
4
|
+
export interface FimoRichTextNodeProps {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
node: FimoRichTextContent;
|
|
7
|
+
}
|
|
8
|
+
export interface FimoRichTextMarkProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
mark: {
|
|
11
|
+
type: string;
|
|
12
|
+
attrs?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface FimoRichTextComponents {
|
|
16
|
+
paragraph?: ComponentType<FimoRichTextNodeProps>;
|
|
17
|
+
heading?: ComponentType<FimoRichTextNodeProps>;
|
|
18
|
+
bulletList?: ComponentType<FimoRichTextNodeProps>;
|
|
19
|
+
orderedList?: ComponentType<FimoRichTextNodeProps>;
|
|
20
|
+
listItem?: ComponentType<FimoRichTextNodeProps>;
|
|
21
|
+
blockquote?: ComponentType<FimoRichTextNodeProps>;
|
|
22
|
+
codeBlock?: ComponentType<FimoRichTextNodeProps>;
|
|
23
|
+
horizontalRule?: ComponentType<FimoRichTextNodeProps>;
|
|
24
|
+
hardBreak?: ComponentType<FimoRichTextNodeProps>;
|
|
25
|
+
image?: ComponentType<FimoRichTextNodeProps>;
|
|
26
|
+
table?: ComponentType<FimoRichTextNodeProps>;
|
|
27
|
+
tableRow?: ComponentType<FimoRichTextNodeProps>;
|
|
28
|
+
tableCell?: ComponentType<FimoRichTextNodeProps>;
|
|
29
|
+
tableHeader?: ComponentType<FimoRichTextNodeProps>;
|
|
30
|
+
iframe?: ComponentType<FimoRichTextNodeProps>;
|
|
31
|
+
bold?: ComponentType<FimoRichTextMarkProps>;
|
|
32
|
+
italic?: ComponentType<FimoRichTextMarkProps>;
|
|
33
|
+
underline?: ComponentType<FimoRichTextMarkProps>;
|
|
34
|
+
strike?: ComponentType<FimoRichTextMarkProps>;
|
|
35
|
+
code?: ComponentType<FimoRichTextMarkProps>;
|
|
36
|
+
link?: ComponentType<FimoRichTextMarkProps>;
|
|
37
|
+
}
|
|
38
|
+
export type BooleanProps<T extends ElementType = 'span'> = {
|
|
39
|
+
value: FimoBoolean;
|
|
40
|
+
as?: T;
|
|
41
|
+
children?: (value: boolean) => ReactNode;
|
|
42
|
+
} & Omit<ComponentPropsWithoutRef<T>, 'value' | 'as' | 'children'>;
|
|
43
|
+
export interface DateProps {
|
|
44
|
+
value: FimoDate | FimoString | Date | string;
|
|
45
|
+
children?: (date: Date) => ReactNode;
|
|
46
|
+
className?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface BaseImageProps extends Omit<ComponentPropsWithoutRef<'img'>, 'src' | 'alt' | 'children'> {
|
|
49
|
+
quality?: number;
|
|
50
|
+
fit?: ImageFit;
|
|
51
|
+
unoptimized?: boolean;
|
|
52
|
+
overrideSrc?: string;
|
|
53
|
+
hostSuffixes?: readonly string[];
|
|
54
|
+
}
|
|
55
|
+
export interface ImageProps extends BaseImageProps {
|
|
56
|
+
value: FimoMedia;
|
|
57
|
+
alt?: string;
|
|
58
|
+
children?: (media: FimoMedia) => ReactNode;
|
|
59
|
+
}
|
|
60
|
+
export type JsonProps<T extends ElementType = 'span'> = {
|
|
61
|
+
value: unknown;
|
|
62
|
+
as?: T;
|
|
63
|
+
children?: (value: unknown) => ReactNode;
|
|
64
|
+
} & Omit<ComponentPropsWithoutRef<T>, 'value' | 'as' | 'children'>;
|
|
65
|
+
export interface RichTextProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
66
|
+
value: FimoRichText | null | undefined;
|
|
67
|
+
components?: FimoRichTextComponents;
|
|
68
|
+
}
|
|
69
|
+
export type StaticImageProps = Omit<ComponentPropsWithoutRef<'img'>, 'children' | 'src'> & {
|
|
70
|
+
/**
|
|
71
|
+
* Direct URL to the image. React's own `img` typings widened `src` to accept
|
|
72
|
+
* a Blob; this renderer resolves a URL through the optimizer, so it stays a
|
|
73
|
+
* string. Same reason `BaseVideoProps` omits `src`.
|
|
74
|
+
*/
|
|
75
|
+
src?: string;
|
|
76
|
+
/** Image quality (1-100). Defaults to 85. */
|
|
77
|
+
quality?: number;
|
|
78
|
+
/** Resize fit mode. Also maps to CSS object-fit. Defaults to 'scale-down'. */
|
|
79
|
+
fit?: ImageFit;
|
|
80
|
+
/** Skip optimization and use the original URL. */
|
|
81
|
+
unoptimized?: boolean;
|
|
82
|
+
hostSuffixes?: readonly string[];
|
|
83
|
+
};
|
|
84
|
+
export type TextProps<T extends ElementType = 'span'> = {
|
|
85
|
+
value: unknown;
|
|
86
|
+
as?: T;
|
|
87
|
+
children?: (value: string) => ReactNode;
|
|
88
|
+
} & Omit<ComponentPropsWithoutRef<T>, 'value' | 'as' | 'children'>;
|
|
89
|
+
export type LabelProps<T extends ElementType = 'span'> = Omit<TextProps<T>, 'value'> & {
|
|
90
|
+
/** Literal label key, e.g. `hero.title`. Dynamic keys cannot be validated. */
|
|
91
|
+
value: string;
|
|
92
|
+
};
|
|
93
|
+
export interface BaseVideoProps extends Omit<ComponentPropsWithoutRef<'video'>, 'src' | 'children'> {
|
|
94
|
+
overrideSrc?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface VideoProps extends BaseVideoProps {
|
|
97
|
+
value: FimoMedia;
|
|
98
|
+
children?: (media: FimoMedia) => ReactNode;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ElementType } from 'react';
|
|
2
|
+
import type { BooleanProps } from '../contracts.js';
|
|
3
|
+
export type { BooleanProps } from '../contracts.js';
|
|
4
|
+
export declare function Boolean<T extends ElementType = 'span'>({ value, as, children, ...props }: BooleanProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
+
//# sourceMappingURL=Boolean.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FIMO_SOURCE } from 'fimo/primitives';
|
|
3
|
+
import { useFimoLiveValue } from '../../useFimoLiveValue.js';
|
|
4
|
+
export function Boolean({ value, as, children, ...props }) {
|
|
5
|
+
const Component = as || 'span';
|
|
6
|
+
const { value: liveValue, ref } = useFimoLiveValue(value ? value.valueOf() : false);
|
|
7
|
+
if (!value) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return (_jsx(Component, { ref: ref, ...props, "data-fimo-source": value[FIMO_SOURCE], children: children ? children(liveValue) : String(liveValue) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FIMO_SOURCE } from 'fimo/primitives';
|
|
3
|
+
import { useFimoLiveValue } from '../../useFimoLiveValue.js';
|
|
4
|
+
import { DateRenderer } from '../renderers/DateRenderer.js';
|
|
5
|
+
export function Date({ value, ...props }) {
|
|
6
|
+
const { value: liveValue, ref } = useFimoLiveValue(value ?? null);
|
|
7
|
+
if (!liveValue) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const source = typeof value === 'object' && FIMO_SOURCE in value ? (value[FIMO_SOURCE] ?? undefined) : undefined;
|
|
11
|
+
return _jsx(DateRenderer, { ...props, value: liveValue, source: source, elementRef: ref });
|
|
12
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DateProps } from '../contracts.js';
|
|
2
|
+
/** Renders a `datetime` field: the `dateTime` attribute keeps the whole instant. */
|
|
3
|
+
export declare function DateTime({ value, ...props }: DateProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
|
+
//# sourceMappingURL=DateTime.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FIMO_SOURCE } from 'fimo/primitives';
|
|
3
|
+
import { useFimoLiveValue } from '../../useFimoLiveValue.js';
|
|
4
|
+
import { DateRenderer } from '../renderers/DateRenderer.js';
|
|
5
|
+
/** Renders a `datetime` field: the `dateTime` attribute keeps the whole instant. */
|
|
6
|
+
export function DateTime({ value, ...props }) {
|
|
7
|
+
const { value: liveValue, ref } = useFimoLiveValue(value ?? null);
|
|
8
|
+
if (!liveValue) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const source = typeof value === 'object' && FIMO_SOURCE in value ? (value[FIMO_SOURCE] ?? undefined) : undefined;
|
|
12
|
+
return _jsx(DateRenderer, { ...props, value: liveValue, source: source, precision: "instant", elementRef: ref });
|
|
13
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ImageProps } from '../contracts.js';
|
|
2
|
+
export type { BaseImageProps, ImageProps } from '../contracts.js';
|
|
3
|
+
export declare function Image({ value: media, ...props }: ImageProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
|
+
//# sourceMappingURL=Image.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useFimoLiveValue } from '../../useFimoLiveValue.js';
|
|
3
|
+
import { ImageRenderer } from '../renderers/ImageRenderer.js';
|
|
4
|
+
export function Image({ value: media, ...props }) {
|
|
5
|
+
const { value: liveMedia, ref } = useFimoLiveValue(media ?? null);
|
|
6
|
+
if (!liveMedia) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return _jsx(ImageRenderer, { ...props, value: liveMedia, elementRef: ref });
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ElementType } from 'react';
|
|
2
|
+
import type { JsonProps } from '../contracts.js';
|
|
3
|
+
export type { JsonProps } from '../contracts.js';
|
|
4
|
+
export declare function Json<T extends ElementType = 'span'>({ value, as, children, ...props }: JsonProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
+
//# sourceMappingURL=Json.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getFimoSource } from 'fimo/primitives';
|
|
3
|
+
import { useFimoLiveValue } from '../../useFimoLiveValue.js';
|
|
4
|
+
export function Json({ value, as, children, ...props }) {
|
|
5
|
+
const Component = as || 'span';
|
|
6
|
+
const { value: liveValue, ref } = useFimoLiveValue(value);
|
|
7
|
+
if (value === null || value === undefined) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return (_jsx(Component, { ref: ref, ...props, "data-fimo-source": getFimoSource(value), children: children ? children(liveValue) : JSON.stringify(liveValue) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RichTextProps } from '../contracts.js';
|
|
2
|
+
export type { RichTextProps } from '../contracts.js';
|
|
3
|
+
export declare function RichText({ value, components, ...props }: RichTextProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
|
+
//# sourceMappingURL=RichText.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FIMO_SOURCE } from 'fimo/primitives';
|
|
3
|
+
import { useFimoLiveValue } from '../../useFimoLiveValue.js';
|
|
4
|
+
import { RichTextRenderer } from '../renderers/RichTextRenderer.js';
|
|
5
|
+
export function RichText({ value, components, ...props }) {
|
|
6
|
+
const { value: liveContent, ref } = useFimoLiveValue(value?.content ?? null);
|
|
7
|
+
if (!value) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return (_jsx(RichTextRenderer, { ...props, document: liveContent, source: value[FIMO_SOURCE], components: components, elementRef: ref }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ElementType } from 'react';
|
|
2
|
+
import type { TextProps } from '../contracts.js';
|
|
3
|
+
export type { TextProps } from '../contracts.js';
|
|
4
|
+
/**
|
|
5
|
+
* Text component for rendering text with source tracking
|
|
6
|
+
*
|
|
7
|
+
* Works with both schema data (FimoString) and translations.
|
|
8
|
+
* The `as` prop changes the rendered element (polymorphic).
|
|
9
|
+
* Use children render function for custom formatting.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <Text value={post.title} />
|
|
13
|
+
* <Text value={post.title} as="h1" className="text-4xl" />
|
|
14
|
+
* <Text value={t('welcome')} as="p" />
|
|
15
|
+
*
|
|
16
|
+
* // With render function for formatting
|
|
17
|
+
* <Text value={product.price}>{(p) => `$${Number(p).toLocaleString()}`}</Text>
|
|
18
|
+
*/
|
|
19
|
+
export declare function Text<T extends ElementType = 'span'>({ value, as, children, ...props }: TextProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=Text.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getFimoParts, getFimoSource } from 'fimo/primitives';
|
|
3
|
+
import { Fragment } from 'react';
|
|
4
|
+
import { useFimoLiveValue } from '../../useFimoLiveValue.js';
|
|
5
|
+
/**
|
|
6
|
+
* Text component for rendering text with source tracking
|
|
7
|
+
*
|
|
8
|
+
* Works with both schema data (FimoString) and translations.
|
|
9
|
+
* The `as` prop changes the rendered element (polymorphic).
|
|
10
|
+
* Use children render function for custom formatting.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <Text value={post.title} />
|
|
14
|
+
* <Text value={post.title} as="h1" className="text-4xl" />
|
|
15
|
+
* <Text value={t('welcome')} as="p" />
|
|
16
|
+
*
|
|
17
|
+
* // With render function for formatting
|
|
18
|
+
* <Text value={product.price}>{(p) => `$${Number(p).toLocaleString()}`}</Text>
|
|
19
|
+
*/
|
|
20
|
+
export function Text({ value, as, children, ...props }) {
|
|
21
|
+
const Component = as || 'span';
|
|
22
|
+
const parts = getFimoParts(value);
|
|
23
|
+
const source = getFimoSource(value);
|
|
24
|
+
const { value: liveValue, ref } = useFimoLiveValue(String(value));
|
|
25
|
+
// Composed fimo value with parts — decompose into individually tracked spans
|
|
26
|
+
if (parts && parts.length > 1 && !children) {
|
|
27
|
+
return (_jsx(Component, { ...props, children: parts.map((part, i) => part.source ? (_jsx(TextPart, { part: part }, i)) : (_jsx(Fragment, { children: part.text }, i))) }));
|
|
28
|
+
}
|
|
29
|
+
// Use render function if provided, otherwise display raw value
|
|
30
|
+
const content = children ? children(liveValue) : liveValue;
|
|
31
|
+
return (_jsx(Component, { ref: ref, ...props, "data-fimo-source": source, children: content }));
|
|
32
|
+
}
|
|
33
|
+
function TextPart({ part }) {
|
|
34
|
+
const { value: liveText, ref } = useFimoLiveValue(part.text);
|
|
35
|
+
return (_jsx("span", { ref: ref, "data-fimo-source": part.source, children: liveText }));
|
|
36
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VideoProps } from '../contracts.js';
|
|
2
|
+
export type { BaseVideoProps, VideoProps } from '../contracts.js';
|
|
3
|
+
export declare function Video({ value: media, ...props }: VideoProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
|
+
//# sourceMappingURL=Video.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useFimoLiveValue } from '../../useFimoLiveValue.js';
|
|
3
|
+
import { VideoRenderer } from '../renderers/VideoRenderer.js';
|
|
4
|
+
export function Video({ value: media, ...props }) {
|
|
5
|
+
const { value: liveMedia, ref } = useFimoLiveValue(media ?? null);
|
|
6
|
+
if (!liveMedia) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return _jsx(VideoRenderer, { ...props, value: liveMedia, elementRef: ref });
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FimoDate, FimoString } from 'fimo/primitives';
|
|
2
|
+
import { type ReactNode, type Ref } from 'react';
|
|
3
|
+
export interface DateRendererProps {
|
|
4
|
+
value: FimoDate | FimoString | Date | string | number;
|
|
5
|
+
source: string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* `day` emits the calendar day in `dateTime`; `instant` keeps the full ISO
|
|
8
|
+
* instant, which is the whole point of a `datetime` field. Defaults to `day`
|
|
9
|
+
* so `<Date>` renders exactly what it always has.
|
|
10
|
+
*/
|
|
11
|
+
precision?: 'day' | 'instant';
|
|
12
|
+
children?: (date: Date) => ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
elementRef?: Ref<HTMLTimeElement>;
|
|
15
|
+
}
|
|
16
|
+
export declare function DateRenderer({ value, source, precision, children, className, elementRef }: DateRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=DateRenderer.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function DateRenderer({ value, source, precision = 'day', children, className, elementRef }) {
|
|
3
|
+
const rawValue = value instanceof String ? value.toString() : value;
|
|
4
|
+
const dateValue = new globalThis.Date(rawValue);
|
|
5
|
+
const iso = dateValue.toISOString();
|
|
6
|
+
const dateTime = precision === 'instant' ? iso : iso.split('T')[0];
|
|
7
|
+
const content = children
|
|
8
|
+
? children(dateValue)
|
|
9
|
+
: precision === 'instant'
|
|
10
|
+
? dateValue.toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' })
|
|
11
|
+
: dateValue.toLocaleDateString(undefined, {
|
|
12
|
+
year: 'numeric',
|
|
13
|
+
month: 'short',
|
|
14
|
+
day: 'numeric',
|
|
15
|
+
});
|
|
16
|
+
return (_jsx("time", { ref: elementRef, dateTime: dateTime, className: className, "data-fimo-source": source, children: content }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { ImageProps } from '../contracts.js';
|
|
3
|
+
interface ImageRendererProps extends ImageProps {
|
|
4
|
+
elementRef?: RefObject<HTMLElement | null>;
|
|
5
|
+
}
|
|
6
|
+
export declare function ImageRenderer({ value: media, children, quality, unoptimized, fit, width, height, alt: altOverride, overrideSrc, srcSet: srcSetOverride, sizes, style, hostSuffixes, elementRef, ...imgProps }: ImageRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=ImageRenderer.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FIMO_SOURCE, resolveImagePresentation } from 'fimo/primitives';
|
|
3
|
+
export function ImageRenderer({ value: media, children, quality, unoptimized = false, fit, width, height, alt: altOverride, overrideSrc, srcSet: srcSetOverride, sizes, style, hostSuffixes, elementRef, ...imgProps }) {
|
|
4
|
+
const mediaSource = media[FIMO_SOURCE];
|
|
5
|
+
if (children) {
|
|
6
|
+
return (_jsx("span", { ref: elementRef, "data-fimo-source": mediaSource, children: children(media) }));
|
|
7
|
+
}
|
|
8
|
+
const image = resolveImagePresentation({
|
|
9
|
+
src: media.url,
|
|
10
|
+
alt: altOverride ?? media.alt,
|
|
11
|
+
mediaWidth: media.width,
|
|
12
|
+
mediaHeight: media.height,
|
|
13
|
+
quality,
|
|
14
|
+
fit,
|
|
15
|
+
unoptimized,
|
|
16
|
+
overrideSrc,
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
sizes,
|
|
20
|
+
srcSet: srcSetOverride,
|
|
21
|
+
hostSuffixes,
|
|
22
|
+
});
|
|
23
|
+
const finalStyle = style?.objectFit
|
|
24
|
+
? style
|
|
25
|
+
: {
|
|
26
|
+
...style,
|
|
27
|
+
objectFit: image.objectFit,
|
|
28
|
+
};
|
|
29
|
+
return (_jsx("img", { ref: elementRef, src: image.src, alt: image.alt, width: image.width, height: image.height, style: finalStyle, sizes: image.sizes, srcSet: image.srcSet, ...imgProps, "data-fimo-source": mediaSource }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FimoRichTextContent } from 'fimo/primitives';
|
|
2
|
+
import { type ComponentPropsWithoutRef, type Ref } from 'react';
|
|
3
|
+
import type { FimoRichTextComponents } from '../contracts.js';
|
|
4
|
+
interface RichTextRendererProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
5
|
+
document: FimoRichTextContent | null | undefined;
|
|
6
|
+
source: string | undefined;
|
|
7
|
+
components?: FimoRichTextComponents;
|
|
8
|
+
elementRef?: Ref<HTMLDivElement>;
|
|
9
|
+
}
|
|
10
|
+
export declare function RichTextRenderer({ document, source, components, elementRef, ...props }: RichTextRendererProps): import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=RichTextRenderer.d.ts.map
|