@alanizcreative/formation-static 0.0.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/LICENSE +21 -0
- package/README.md +145 -0
- package/cjs/actions/actions.d.ts +8 -0
- package/cjs/actions/actions.js +1 -0
- package/cjs/actions/actionsTypes.d.ts +10 -0
- package/cjs/actions/actionsTypes.js +1 -0
- package/cjs/components/Navigation/Navigation.d.ts +14 -0
- package/cjs/components/Navigation/Navigation.js +1 -0
- package/cjs/components/Navigation/NavigationTypes.d.ts +88 -0
- package/cjs/components/Navigation/NavigationTypes.js +1 -0
- package/cjs/components/Pagination/Pagination.d.ts +3 -0
- package/cjs/components/Pagination/Pagination.js +1 -0
- package/cjs/components/Pagination/PaginationTypes.d.ts +54 -0
- package/cjs/components/Pagination/PaginationTypes.js +1 -0
- package/cjs/config/config.d.ts +5 -0
- package/cjs/config/config.js +1 -0
- package/cjs/config/configTypes.d.ts +66 -0
- package/cjs/config/configTypes.js +1 -0
- package/cjs/contentful/contentfulData.d.ts +5 -0
- package/cjs/contentful/contentfulData.js +1 -0
- package/cjs/contentful/contentfulDataNormal.d.ts +4 -0
- package/cjs/contentful/contentfulDataNormal.js +1 -0
- package/cjs/contentful/contentfulDataTypes.d.ts +78 -0
- package/cjs/contentful/contentfulDataTypes.js +1 -0
- package/cjs/filters/filters.d.ts +8 -0
- package/cjs/filters/filters.js +1 -0
- package/cjs/filters/filtersTypes.d.ts +60 -0
- package/cjs/filters/filtersTypes.js +1 -0
- package/cjs/global/globalTypes.d.ts +34 -0
- package/cjs/global/globalTypes.js +1 -0
- package/cjs/layouts/Column/Column.d.ts +3 -0
- package/cjs/layouts/Column/Column.js +1 -0
- package/cjs/layouts/Column/ColumnTypes.d.ts +16 -0
- package/cjs/layouts/Column/ColumnTypes.js +1 -0
- package/cjs/layouts/Container/Container.d.ts +3 -0
- package/cjs/layouts/Container/Container.js +1 -0
- package/cjs/layouts/Container/ContainerTypes.d.ts +15 -0
- package/cjs/layouts/Container/ContainerTypes.js +1 -0
- package/cjs/local/localData.d.ts +5 -0
- package/cjs/local/localData.js +1 -0
- package/cjs/local/localDataNormal.d.ts +3 -0
- package/cjs/local/localDataNormal.js +1 -0
- package/cjs/local/localDataTypes.d.ts +14 -0
- package/cjs/local/localDataTypes.js +1 -0
- package/cjs/objects/Form/Form.d.ts +3 -0
- package/cjs/objects/Form/Form.js +1 -0
- package/cjs/objects/Form/FormField.d.ts +3 -0
- package/cjs/objects/Form/FormField.js +1 -0
- package/cjs/objects/Form/FormOption.d.ts +3 -0
- package/cjs/objects/Form/FormOption.js +1 -0
- package/cjs/objects/Form/FormTypes.d.ts +76 -0
- package/cjs/objects/Form/FormTypes.js +1 -0
- package/cjs/package.json +1 -0
- package/cjs/redirects/redirects.d.ts +4 -0
- package/cjs/redirects/redirects.js +1 -0
- package/cjs/redirects/redirectsFile.d.ts +2 -0
- package/cjs/redirects/redirectsFile.js +1 -0
- package/cjs/render/render.d.ts +11 -0
- package/cjs/render/render.js +1 -0
- package/cjs/render/renderInline.d.ts +4 -0
- package/cjs/render/renderInline.js +1 -0
- package/cjs/render/renderTypes.d.ts +197 -0
- package/cjs/render/renderTypes.js +1 -0
- package/cjs/scripts/scripts.d.ts +8 -0
- package/cjs/scripts/scripts.js +1 -0
- package/cjs/scripts/scriptsTypes.d.ts +15 -0
- package/cjs/scripts/scriptsTypes.js +1 -0
- package/cjs/serverless/Contact/Contact.d.ts +3 -0
- package/cjs/serverless/Contact/Contact.js +1 -0
- package/cjs/serverless/Contact/ContactTypes.d.ts +13 -0
- package/cjs/serverless/Contact/ContactTypes.js +1 -0
- package/cjs/serverless/serverless.d.ts +12 -0
- package/cjs/serverless/serverless.js +1 -0
- package/cjs/serverless/serverlessTypes.d.ts +41 -0
- package/cjs/serverless/serverlessTypes.js +1 -0
- package/cjs/shortcodes/shortcodes.d.ts +10 -0
- package/cjs/shortcodes/shortcodes.js +1 -0
- package/cjs/shortcodes/shortcodesTypes.d.ts +20 -0
- package/cjs/shortcodes/shortcodesTypes.js +1 -0
- package/cjs/store/store.d.ts +9 -0
- package/cjs/store/store.js +1 -0
- package/cjs/store/storeFiles.d.ts +2 -0
- package/cjs/store/storeFiles.js +1 -0
- package/cjs/store/storeTypes.d.ts +28 -0
- package/cjs/store/storeTypes.js +1 -0
- package/cjs/text/RichText/RichText.d.ts +4 -0
- package/cjs/text/RichText/RichText.js +1 -0
- package/cjs/text/RichText/RichTextTypes.d.ts +54 -0
- package/cjs/text/RichText/RichTextTypes.js +1 -0
- package/cjs/utils/ResponseError/ResponseError.d.ts +5 -0
- package/cjs/utils/ResponseError/ResponseError.js +1 -0
- package/cjs/utils/archive/archive.d.ts +10 -0
- package/cjs/utils/archive/archive.js +1 -0
- package/cjs/utils/archive/archiveTypes.d.ts +29 -0
- package/cjs/utils/archive/archiveTypes.js +1 -0
- package/cjs/utils/array/array.d.ts +3 -0
- package/cjs/utils/array/array.js +1 -0
- package/cjs/utils/boolean/boolean.d.ts +2 -0
- package/cjs/utils/boolean/boolean.js +1 -0
- package/cjs/utils/contentType/contentType.d.ts +2 -0
- package/cjs/utils/contentType/contentType.js +1 -0
- package/cjs/utils/dataSource/dataSource.d.ts +3 -0
- package/cjs/utils/dataSource/dataSource.js +1 -0
- package/cjs/utils/dataSource/dataSourceTypes.d.ts +9 -0
- package/cjs/utils/dataSource/dataSourceTypes.js +1 -0
- package/cjs/utils/escape/escape.d.ts +2 -0
- package/cjs/utils/escape/escape.js +1 -0
- package/cjs/utils/excerpt/excerpt.d.ts +3 -0
- package/cjs/utils/excerpt/excerpt.js +1 -0
- package/cjs/utils/excerpt/excerptTypes.d.ts +14 -0
- package/cjs/utils/excerpt/excerptTypes.js +1 -0
- package/cjs/utils/file/file.d.ts +3 -0
- package/cjs/utils/file/file.js +1 -0
- package/cjs/utils/file/filePath.d.ts +2 -0
- package/cjs/utils/file/filePath.js +1 -0
- package/cjs/utils/function/function.d.ts +3 -0
- package/cjs/utils/function/function.js +1 -0
- package/cjs/utils/heading/heading.d.ts +2 -0
- package/cjs/utils/heading/heading.js +1 -0
- package/cjs/utils/image/image.d.ts +5 -0
- package/cjs/utils/image/image.js +1 -0
- package/cjs/utils/image/imageLocal.d.ts +3 -0
- package/cjs/utils/image/imageLocal.js +1 -0
- package/cjs/utils/image/imageRemote.d.ts +3 -0
- package/cjs/utils/image/imageRemote.js +1 -0
- package/cjs/utils/image/imageTypes.d.ts +69 -0
- package/cjs/utils/image/imageTypes.js +1 -0
- package/cjs/utils/json/json.d.ts +3 -0
- package/cjs/utils/json/json.js +1 -0
- package/cjs/utils/link/link.d.ts +6 -0
- package/cjs/utils/link/link.js +1 -0
- package/cjs/utils/link/linkShare.d.ts +3 -0
- package/cjs/utils/link/linkShare.js +1 -0
- package/cjs/utils/link/linkTypes.d.ts +28 -0
- package/cjs/utils/link/linkTypes.js +1 -0
- package/cjs/utils/map/map.d.ts +2 -0
- package/cjs/utils/map/map.js +1 -0
- package/cjs/utils/minify/minify.d.ts +2 -0
- package/cjs/utils/minify/minify.js +1 -0
- package/cjs/utils/number/number.d.ts +2 -0
- package/cjs/utils/number/number.js +1 -0
- package/cjs/utils/object/object.d.ts +4 -0
- package/cjs/utils/object/object.js +1 -0
- package/cjs/utils/object/objectUtils.d.ts +2 -0
- package/cjs/utils/object/objectUtils.js +1 -0
- package/cjs/utils/path/path.d.ts +3 -0
- package/cjs/utils/path/path.js +1 -0
- package/cjs/utils/print/print.d.ts +2 -0
- package/cjs/utils/print/print.js +1 -0
- package/cjs/utils/set/set.d.ts +3 -0
- package/cjs/utils/set/set.js +1 -0
- package/cjs/utils/string/string.d.ts +3 -0
- package/cjs/utils/string/string.js +1 -0
- package/cjs/utils/tag/tag.d.ts +4 -0
- package/cjs/utils/tag/tag.js +1 -0
- package/cjs/utils/tag/tagTypes.d.ts +6 -0
- package/cjs/utils/tag/tagTypes.js +1 -0
- package/cjs/utils/year/year.d.ts +2 -0
- package/cjs/utils/year/year.js +1 -0
- package/cjs/wordpress/wordpressData.d.ts +6 -0
- package/cjs/wordpress/wordpressData.js +1 -0
- package/cjs/wordpress/wordpressDataNormal.d.ts +9 -0
- package/cjs/wordpress/wordpressDataNormal.js +1 -0
- package/cjs/wordpress/wordpressDataTypes.d.ts +208 -0
- package/cjs/wordpress/wordpressDataTypes.js +1 -0
- package/lib/actions/actions.d.ts +8 -0
- package/lib/actions/actions.js +1 -0
- package/lib/actions/actionsTypes.d.ts +10 -0
- package/lib/actions/actionsTypes.js +1 -0
- package/lib/components/Navigation/Navigation.d.ts +14 -0
- package/lib/components/Navigation/Navigation.js +1 -0
- package/lib/components/Navigation/NavigationTypes.d.ts +88 -0
- package/lib/components/Navigation/NavigationTypes.js +1 -0
- package/lib/components/Pagination/Pagination.d.ts +3 -0
- package/lib/components/Pagination/Pagination.js +1 -0
- package/lib/components/Pagination/PaginationTypes.d.ts +54 -0
- package/lib/components/Pagination/PaginationTypes.js +1 -0
- package/lib/config/config.d.ts +5 -0
- package/lib/config/config.js +1 -0
- package/lib/config/configTypes.d.ts +66 -0
- package/lib/config/configTypes.js +1 -0
- package/lib/contentful/contentfulData.d.ts +5 -0
- package/lib/contentful/contentfulData.js +1 -0
- package/lib/contentful/contentfulDataNormal.d.ts +4 -0
- package/lib/contentful/contentfulDataNormal.js +1 -0
- package/lib/contentful/contentfulDataTypes.d.ts +78 -0
- package/lib/contentful/contentfulDataTypes.js +1 -0
- package/lib/filters/filters.d.ts +8 -0
- package/lib/filters/filters.js +1 -0
- package/lib/filters/filtersTypes.d.ts +60 -0
- package/lib/filters/filtersTypes.js +1 -0
- package/lib/global/globalTypes.d.ts +34 -0
- package/lib/global/globalTypes.js +1 -0
- package/lib/layouts/Column/Column.d.ts +3 -0
- package/lib/layouts/Column/Column.js +1 -0
- package/lib/layouts/Column/ColumnTypes.d.ts +16 -0
- package/lib/layouts/Column/ColumnTypes.js +1 -0
- package/lib/layouts/Container/Container.d.ts +3 -0
- package/lib/layouts/Container/Container.js +1 -0
- package/lib/layouts/Container/ContainerTypes.d.ts +15 -0
- package/lib/layouts/Container/ContainerTypes.js +1 -0
- package/lib/local/localData.d.ts +5 -0
- package/lib/local/localData.js +1 -0
- package/lib/local/localDataNormal.d.ts +3 -0
- package/lib/local/localDataNormal.js +1 -0
- package/lib/local/localDataTypes.d.ts +14 -0
- package/lib/local/localDataTypes.js +1 -0
- package/lib/objects/Form/Form.d.ts +3 -0
- package/lib/objects/Form/Form.js +1 -0
- package/lib/objects/Form/FormField.d.ts +3 -0
- package/lib/objects/Form/FormField.js +1 -0
- package/lib/objects/Form/FormOption.d.ts +3 -0
- package/lib/objects/Form/FormOption.js +1 -0
- package/lib/objects/Form/FormTypes.d.ts +76 -0
- package/lib/objects/Form/FormTypes.js +1 -0
- package/lib/package.json +1 -0
- package/lib/redirects/redirects.d.ts +4 -0
- package/lib/redirects/redirects.js +1 -0
- package/lib/redirects/redirectsFile.d.ts +2 -0
- package/lib/redirects/redirectsFile.js +1 -0
- package/lib/render/render.d.ts +11 -0
- package/lib/render/render.js +1 -0
- package/lib/render/renderInline.d.ts +4 -0
- package/lib/render/renderInline.js +1 -0
- package/lib/render/renderTypes.d.ts +197 -0
- package/lib/render/renderTypes.js +1 -0
- package/lib/scripts/scripts.d.ts +8 -0
- package/lib/scripts/scripts.js +1 -0
- package/lib/scripts/scriptsTypes.d.ts +15 -0
- package/lib/scripts/scriptsTypes.js +1 -0
- package/lib/serverless/Contact/Contact.d.ts +3 -0
- package/lib/serverless/Contact/Contact.js +1 -0
- package/lib/serverless/Contact/ContactTypes.d.ts +13 -0
- package/lib/serverless/Contact/ContactTypes.js +1 -0
- package/lib/serverless/serverless.d.ts +12 -0
- package/lib/serverless/serverless.js +1 -0
- package/lib/serverless/serverlessTypes.d.ts +41 -0
- package/lib/serverless/serverlessTypes.js +1 -0
- package/lib/shortcodes/shortcodes.d.ts +10 -0
- package/lib/shortcodes/shortcodes.js +1 -0
- package/lib/shortcodes/shortcodesTypes.d.ts +20 -0
- package/lib/shortcodes/shortcodesTypes.js +1 -0
- package/lib/store/store.d.ts +9 -0
- package/lib/store/store.js +1 -0
- package/lib/store/storeFiles.d.ts +2 -0
- package/lib/store/storeFiles.js +1 -0
- package/lib/store/storeTypes.d.ts +28 -0
- package/lib/store/storeTypes.js +1 -0
- package/lib/text/RichText/RichText.d.ts +4 -0
- package/lib/text/RichText/RichText.js +1 -0
- package/lib/text/RichText/RichTextTypes.d.ts +54 -0
- package/lib/text/RichText/RichTextTypes.js +1 -0
- package/lib/utils/ResponseError/ResponseError.d.ts +5 -0
- package/lib/utils/ResponseError/ResponseError.js +1 -0
- package/lib/utils/archive/archive.d.ts +10 -0
- package/lib/utils/archive/archive.js +1 -0
- package/lib/utils/archive/archiveTypes.d.ts +29 -0
- package/lib/utils/archive/archiveTypes.js +1 -0
- package/lib/utils/array/array.d.ts +3 -0
- package/lib/utils/array/array.js +1 -0
- package/lib/utils/boolean/boolean.d.ts +2 -0
- package/lib/utils/boolean/boolean.js +1 -0
- package/lib/utils/contentType/contentType.d.ts +2 -0
- package/lib/utils/contentType/contentType.js +1 -0
- package/lib/utils/dataSource/dataSource.d.ts +3 -0
- package/lib/utils/dataSource/dataSource.js +1 -0
- package/lib/utils/dataSource/dataSourceTypes.d.ts +9 -0
- package/lib/utils/dataSource/dataSourceTypes.js +1 -0
- package/lib/utils/escape/escape.d.ts +2 -0
- package/lib/utils/escape/escape.js +1 -0
- package/lib/utils/excerpt/excerpt.d.ts +3 -0
- package/lib/utils/excerpt/excerpt.js +1 -0
- package/lib/utils/excerpt/excerptTypes.d.ts +14 -0
- package/lib/utils/excerpt/excerptTypes.js +1 -0
- package/lib/utils/file/file.d.ts +3 -0
- package/lib/utils/file/file.js +1 -0
- package/lib/utils/file/filePath.d.ts +2 -0
- package/lib/utils/file/filePath.js +1 -0
- package/lib/utils/function/function.d.ts +3 -0
- package/lib/utils/function/function.js +1 -0
- package/lib/utils/heading/heading.d.ts +2 -0
- package/lib/utils/heading/heading.js +1 -0
- package/lib/utils/image/image.d.ts +5 -0
- package/lib/utils/image/image.js +1 -0
- package/lib/utils/image/imageLocal.d.ts +3 -0
- package/lib/utils/image/imageLocal.js +1 -0
- package/lib/utils/image/imageRemote.d.ts +3 -0
- package/lib/utils/image/imageRemote.js +1 -0
- package/lib/utils/image/imageTypes.d.ts +69 -0
- package/lib/utils/image/imageTypes.js +1 -0
- package/lib/utils/json/json.d.ts +3 -0
- package/lib/utils/json/json.js +1 -0
- package/lib/utils/link/link.d.ts +6 -0
- package/lib/utils/link/link.js +1 -0
- package/lib/utils/link/linkShare.d.ts +3 -0
- package/lib/utils/link/linkShare.js +1 -0
- package/lib/utils/link/linkTypes.d.ts +28 -0
- package/lib/utils/link/linkTypes.js +1 -0
- package/lib/utils/map/map.d.ts +2 -0
- package/lib/utils/map/map.js +1 -0
- package/lib/utils/minify/minify.d.ts +2 -0
- package/lib/utils/minify/minify.js +1 -0
- package/lib/utils/number/number.d.ts +2 -0
- package/lib/utils/number/number.js +1 -0
- package/lib/utils/object/object.d.ts +4 -0
- package/lib/utils/object/object.js +1 -0
- package/lib/utils/object/objectUtils.d.ts +2 -0
- package/lib/utils/object/objectUtils.js +1 -0
- package/lib/utils/path/path.d.ts +3 -0
- package/lib/utils/path/path.js +1 -0
- package/lib/utils/print/print.d.ts +2 -0
- package/lib/utils/print/print.js +1 -0
- package/lib/utils/set/set.d.ts +3 -0
- package/lib/utils/set/set.js +1 -0
- package/lib/utils/string/string.d.ts +3 -0
- package/lib/utils/string/string.js +1 -0
- package/lib/utils/tag/tag.d.ts +4 -0
- package/lib/utils/tag/tag.js +1 -0
- package/lib/utils/tag/tagTypes.d.ts +6 -0
- package/lib/utils/tag/tagTypes.js +1 -0
- package/lib/utils/year/year.d.ts +2 -0
- package/lib/utils/year/year.js +1 -0
- package/lib/wordpress/wordpressData.d.ts +6 -0
- package/lib/wordpress/wordpressData.js +1 -0
- package/lib/wordpress/wordpressDataNormal.d.ts +9 -0
- package/lib/wordpress/wordpressDataNormal.js +1 -0
- package/lib/wordpress/wordpressDataTypes.d.ts +208 -0
- package/lib/wordpress/wordpressDataTypes.js +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { InternalLink, Generic, RefString } from '../../global/globalTypes.js';
|
|
2
|
+
export interface NavigationProps {
|
|
3
|
+
navigations: NavigationList[];
|
|
4
|
+
items: NavigationItem[];
|
|
5
|
+
currentLink?: string;
|
|
6
|
+
currentType?: string | string[];
|
|
7
|
+
}
|
|
8
|
+
export interface NavigationList extends Generic {
|
|
9
|
+
title: string;
|
|
10
|
+
location: string | string[];
|
|
11
|
+
items: NavigationItem[];
|
|
12
|
+
}
|
|
13
|
+
export interface NavigationByLocationItem {
|
|
14
|
+
title: string;
|
|
15
|
+
items: NavigationItem[];
|
|
16
|
+
}
|
|
17
|
+
export type NavigationByLocation<L extends string = string> = Map<L, NavigationByLocationItem>;
|
|
18
|
+
export interface NavigationItem extends Generic {
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
link?: string;
|
|
22
|
+
internalLink?: InternalLink;
|
|
23
|
+
externalLink?: string;
|
|
24
|
+
children?: NavigationItem[];
|
|
25
|
+
current?: boolean;
|
|
26
|
+
external?: boolean;
|
|
27
|
+
descendentCurrent?: boolean;
|
|
28
|
+
archiveCurrent?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export type NavigationItemsById = Map<string, NavigationItem>;
|
|
31
|
+
export interface NavigationBreadcrumbItem extends NavigationItem {
|
|
32
|
+
slug: string;
|
|
33
|
+
contentType: string;
|
|
34
|
+
}
|
|
35
|
+
export interface NavigationOutputBaseArgs {
|
|
36
|
+
listClass?: string;
|
|
37
|
+
listAttr?: string;
|
|
38
|
+
itemClass?: string;
|
|
39
|
+
itemAttr?: string;
|
|
40
|
+
linkClass?: string;
|
|
41
|
+
internalLinkClass?: string;
|
|
42
|
+
linkAttr?: string;
|
|
43
|
+
depthAttr?: boolean;
|
|
44
|
+
dataAttr?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface NavigationOutputListFilterArgs {
|
|
47
|
+
args: NavigationOutputArgs;
|
|
48
|
+
output: RefString;
|
|
49
|
+
items: NavigationItem[];
|
|
50
|
+
depth: number;
|
|
51
|
+
}
|
|
52
|
+
export interface NavigationOutputFilterArgs {
|
|
53
|
+
args: NavigationOutputArgs;
|
|
54
|
+
item: NavigationItem;
|
|
55
|
+
output: RefString;
|
|
56
|
+
index: number;
|
|
57
|
+
items: NavigationItem[];
|
|
58
|
+
depth: number;
|
|
59
|
+
}
|
|
60
|
+
export type NavigationOutputListFilter = (args: NavigationOutputListFilterArgs) => void;
|
|
61
|
+
export type NavigationFilter = (args: NavigationOutputFilterArgs) => void;
|
|
62
|
+
export interface NavigationOutputArgs extends NavigationOutputBaseArgs {
|
|
63
|
+
currentLink?: string;
|
|
64
|
+
currentType?: string | string[];
|
|
65
|
+
listTag?: string;
|
|
66
|
+
itemTag?: string;
|
|
67
|
+
filterBeforeList?: NavigationOutputListFilter;
|
|
68
|
+
filterAfterList?: NavigationOutputListFilter;
|
|
69
|
+
filterBeforeItem?: NavigationFilter;
|
|
70
|
+
filterAfterItem?: NavigationFilter;
|
|
71
|
+
filterBeforeLink?: NavigationFilter;
|
|
72
|
+
filterAfterLink?: NavigationFilter;
|
|
73
|
+
filterBeforeLinkText?: NavigationFilter;
|
|
74
|
+
filterAfterLinkText?: NavigationFilter;
|
|
75
|
+
}
|
|
76
|
+
export interface NavigationBreadcrumbOutputFilterArgs {
|
|
77
|
+
output: RefString;
|
|
78
|
+
lastLevel: boolean;
|
|
79
|
+
}
|
|
80
|
+
export type NavigationBreadcrumbOutputFilter = (args: NavigationBreadcrumbOutputFilterArgs) => void;
|
|
81
|
+
export interface NavigationBreadcrumbOutputArgs extends NavigationOutputBaseArgs {
|
|
82
|
+
current?: string;
|
|
83
|
+
currentClass?: string;
|
|
84
|
+
currentLabel?: string;
|
|
85
|
+
a11yClass?: string;
|
|
86
|
+
filterBeforeLink?: NavigationBreadcrumbOutputFilter;
|
|
87
|
+
filterAfterLink?: NavigationBreadcrumbOutputFilter;
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObjectStrict}from"../../utils/object/object.js";import{isStringStrict}from"../../utils/string/string.js";const Pagination=props=>{const fallback={output:"",data:{}};if(!isObjectStrict(props))return fallback;const{total:total=1,display:display=5,current:current=1,filters:filters,url:url,ellipsis:ellipsis,first:first,last:last,prev:prev="",next:next="",firstLabel:firstLabel="First page",lastLabel:lastLabel="Last page",prevLabel:prevLabel="Previous page",nextLabel:nextLabel="Next page",currentLabel:currentLabel="Current page",pageLabel:pageLabel="Page",titleTemplate:titleTemplate="Page %current of %total",args:args}=props,{listClass:listClass,listAttr:listAttr,itemClass:itemClass,itemAttr:itemAttr,linkClass:linkClass,linkAttr:linkAttr,currentClass:currentClass,a11yClass:a11yClass="a-hide-vis",firstClass:firstClass,lastClass:lastClass,prevSpanClass:prevSpanClass,prevLinkClass:prevLinkClass,nextSpanClass:nextSpanClass,nextLinkClass:nextLinkClass}=isObjectStrict(args)?args:{};if(total<=1||!isStringStrict(url))return fallback;let output="";const hasFilters=isObjectStrict(filters);let firstParams={},lastParams={page:total.toString()},prevParams={},nextParams={},currentParams={};const prevPage=current-1,nextPage=current+1<=total?current+1:0;current>1&&(currentParams.page=current.toString()),prevPage>1&&(prevParams.page=prevPage.toString()),nextPage&&(nextParams.page=nextPage.toString()),hasFilters&&(firstParams={...firstParams,...filters},lastParams={...lastParams,...filters},currentParams={...currentParams,...filters},prevParams={...prevParams,...filters},current<total&&(nextParams={...nextParams,...filters}));const lastParamsStr=`?${new URLSearchParams(lastParams).toString()}`;let firstParamsStr=new URLSearchParams(firstParams).toString(),prevParamsStr=new URLSearchParams(prevParams).toString(),nextParamsStr=new URLSearchParams(nextParams).toString(),currentParamsStr=new URLSearchParams(currentParams).toString();firstParamsStr&&(firstParamsStr=`?${firstParamsStr}`),prevParamsStr&&(prevParamsStr=`?${prevParamsStr}`),nextParamsStr&&(nextParamsStr=`?${nextParamsStr}`),currentParamsStr&&(currentParamsStr=`?${currentParamsStr}`);const data={current:current,total:total};nextPage&&(data.next=nextPage),prevPage&&(data.prev=prevPage),currentParamsStr&&(data.currentParams=currentParams),nextParamsStr&&(data.nextParams=nextParams),prevParamsStr&&(data.prevParams=prevParams),firstParamsStr&&(data.firstParams=firstParams),data.lastParams=lastParams,current>1&&(data.title=titleTemplate.replace("%current",current.toString()).replace("%total",total.toString()));const max=display-1,half=Math.ceil(display/2),maxHalf=max/2,center=total>max,limit=center?max:total-1;let start=1;center&&(start=current<max?1:current-maxHalf),start>total-limit&&(start=total-limit);const totalPagesItems=start+limit,listAttrs=[];isStringStrict(listClass)&&listAttrs.push(`class="${listClass}"`),isStringStrict(listAttr)&&listAttrs.push(listAttr);const hasEllipsis=isStringStrict(ellipsis),itemAttrs=`${isStringStrict(itemClass)?` class="${itemClass}"`:""}${isStringStrict(itemAttr)?` ${itemAttr}`:""}`;isStringStrict(first)&&(output+=`\n <li${itemAttrs} data-pag-first>\n <a\n href="${url}${firstParamsStr}"\n aria-label="${firstLabel}"${isStringStrict(firstClass)?` class="${firstClass}"`:""}\n >\n ${first}\n </a>\n </li>\n `);let prevItem=`<span${isStringStrict(prevSpanClass)?` class="${prevSpanClass}"`:""}>${prev}</span>`,isPrevLink=!1;current>1&&(isPrevLink=!0,prevItem=`\n <a\n href="${url}${prevParamsStr}"\n aria-label="${prevLabel}"${isStringStrict(prevLinkClass)?` class="${prevLinkClass}"`:""}\n >\n ${prev}\n </a>\n `),output+=`<li${itemAttrs} data-pag-prev="${isPrevLink?"link":"text"}">${prevItem}</li>`;let ellipsisOutput="";hasEllipsis&&(ellipsisOutput=`<li${itemAttrs} aria-hidden="true" data-pag-ellipsis>${ellipsis}</li>`),center&¤t>=limit&¤t>half&&(output+=ellipsisOutput);for(let i=start;i<=totalPagesItems;i+=1){const isCurrent=i===current;let content="";if(isCurrent)content=`\n <span${isStringStrict(currentClass)?` class="${currentClass}"`:""}>\n <span class="${a11yClass}">${currentLabel} </span>\n ${i}\n </span>\n `;else{let params={};i>1&&(params.page=i.toString()),hasFilters&&(params={...params,...filters});let paramsStr=new URLSearchParams(params).toString();paramsStr&&(paramsStr=`?${paramsStr}`),content=`\n <a href="${url}${paramsStr}"${isStringStrict(linkClass)?` class="${linkClass}"`:""}${isStringStrict(linkAttr)?` ${linkAttr}`:""}>\n <span class="${a11yClass}">${pageLabel} </span>\n ${i}\n </a>\n `}output+=`<li${itemAttrs}${isCurrent?" data-pag-current":""}>${content}</li>`}center&¤t<total-maxHalf&&(output+=ellipsisOutput);let nextItem=`<span${isStringStrict(nextSpanClass)?` class="${nextSpanClass}"`:""}>${next}</span>`,nextLink=!1;return current<total&&(nextLink=!0,nextItem=`\n <a\n href="${url}${nextParamsStr}"\n aria-label="${nextLabel}"${isStringStrict(nextLinkClass)?` class="${nextLinkClass}"`:""}\n >\n ${next}\n </a>\n `),output+=`<li${itemAttrs} data-pag-next="${nextLink?"link":"text"}">${nextItem}</li>`,isStringStrict(last)&&(output+=`\n <li${itemAttrs} data-pag-last>\n <a\n href="${url}${lastParamsStr}"\n aria-label="${lastLabel}"${isStringStrict(lastClass)?` class="${lastClass}"`:""}\n >\n ${last}\n </a>\n </li>\n `),{output:`\n <ol${listAttrs.length?` ${listAttrs.join(" ")}`:""}>\n ${output}\n </ol>\n `,data:data}};export{Pagination};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface PaginationProps {
|
|
2
|
+
total?: number;
|
|
3
|
+
display?: number;
|
|
4
|
+
current?: number;
|
|
5
|
+
filters?: Record<string, string>;
|
|
6
|
+
url?: string;
|
|
7
|
+
ellipsis?: string;
|
|
8
|
+
first?: string;
|
|
9
|
+
last?: string;
|
|
10
|
+
prev?: string;
|
|
11
|
+
next?: string;
|
|
12
|
+
firstLabel?: string;
|
|
13
|
+
lastLabel?: string;
|
|
14
|
+
prevLabel?: string;
|
|
15
|
+
nextLabel?: string;
|
|
16
|
+
currentLabel?: string;
|
|
17
|
+
pageLabel?: string;
|
|
18
|
+
titleTemplate?: string;
|
|
19
|
+
args?: PaginationArgs;
|
|
20
|
+
}
|
|
21
|
+
export interface PaginationArgs {
|
|
22
|
+
listClass?: string;
|
|
23
|
+
listAttr?: string;
|
|
24
|
+
itemClass?: string;
|
|
25
|
+
itemAttr?: string;
|
|
26
|
+
linkClass?: string;
|
|
27
|
+
linkAttr?: string;
|
|
28
|
+
currentClass?: string;
|
|
29
|
+
a11yClass?: string;
|
|
30
|
+
firstClass?: string;
|
|
31
|
+
lastClass?: string;
|
|
32
|
+
prevSpanClass?: string;
|
|
33
|
+
prevLinkClass?: string;
|
|
34
|
+
nextSpanClass?: string;
|
|
35
|
+
nextLinkClass?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface PaginationData {
|
|
38
|
+
current?: number;
|
|
39
|
+
total?: number;
|
|
40
|
+
title?: string;
|
|
41
|
+
first?: number;
|
|
42
|
+
last?: number;
|
|
43
|
+
next?: number;
|
|
44
|
+
prev?: number;
|
|
45
|
+
firstParams?: Record<string, string>;
|
|
46
|
+
lastParams?: Record<string, string>;
|
|
47
|
+
nextParams?: Record<string, string>;
|
|
48
|
+
prevParams?: Record<string, string>;
|
|
49
|
+
currentParams?: Record<string, string>;
|
|
50
|
+
}
|
|
51
|
+
export interface PaginationReturn {
|
|
52
|
+
output: string;
|
|
53
|
+
data: PaginationData;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let config={namespace:"frm",source:"cms",title:"",meta:{description:"",image:""},partialTypes:[],wholeTypes:[],hierarchicalTypes:[],localeInSlug:{},typeInSlug:{},taxonomyInSlug:{},normalTypes:{},renderTypes:{},env:{dev:!0,prod:!1,build:!1,cache:!1,dir:"",devUrl:"",prodUrl:""},cms:{name:"",space:"",prodUser:"",prodCredential:"",prodHost:"",devUser:"",devCredential:"",devHost:""},local:{dir:"json"},scripts:{inputDir:"lib",outputDir:"js"},styles:{inputDir:"src",outputDir:"css"},image:{inputDir:"src/assets/img",outputDir:"site/assets/img",localUrl:"/assets/img",remoteUrl:"",quality:75,sizes:[200,400,600,800,1e3,1200,1600,2e3]},filter:config=>config};const setConfig=args=>(config={...config,...args},config),setConfigFilter=env=>(config=config.filter(config,env),config);export{config,setConfig,setConfigFilter};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Source, GenericStrings, Generic } from '../global/globalTypes.js';
|
|
2
|
+
export interface ConfigMeta {
|
|
3
|
+
description: string;
|
|
4
|
+
image: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ConfigEnv {
|
|
7
|
+
dev: boolean;
|
|
8
|
+
prod: boolean;
|
|
9
|
+
build: boolean;
|
|
10
|
+
cache: boolean;
|
|
11
|
+
dir: string;
|
|
12
|
+
devUrl: string;
|
|
13
|
+
prodUrl: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ConfigCms {
|
|
16
|
+
name: string;
|
|
17
|
+
space: string;
|
|
18
|
+
prodUser: string;
|
|
19
|
+
prodCredential: string;
|
|
20
|
+
prodHost: string;
|
|
21
|
+
devUser: string;
|
|
22
|
+
devCredential: string;
|
|
23
|
+
devHost: string;
|
|
24
|
+
ssl?: boolean;
|
|
25
|
+
env?: string;
|
|
26
|
+
locales?: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface ConfigLocal {
|
|
29
|
+
dir: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ConfigAsset {
|
|
32
|
+
inputDir: string;
|
|
33
|
+
outputDir: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ConfigImage {
|
|
36
|
+
inputDir: string;
|
|
37
|
+
outputDir: string;
|
|
38
|
+
localUrl: string;
|
|
39
|
+
remoteUrl: string;
|
|
40
|
+
sizes: number[];
|
|
41
|
+
quality: number;
|
|
42
|
+
}
|
|
43
|
+
export type ConfigFilter = (config: Config, env: Generic) => Config;
|
|
44
|
+
export interface Config {
|
|
45
|
+
namespace: string;
|
|
46
|
+
source: Source;
|
|
47
|
+
title: string;
|
|
48
|
+
meta: ConfigMeta;
|
|
49
|
+
partialTypes: string[];
|
|
50
|
+
wholeTypes: string[];
|
|
51
|
+
renderTypes: GenericStrings;
|
|
52
|
+
normalTypes: GenericStrings;
|
|
53
|
+
hierarchicalTypes: string[];
|
|
54
|
+
localeInSlug: Record<string, string>;
|
|
55
|
+
typeInSlug: Record<string, string | Record<string, string>>;
|
|
56
|
+
taxonomyInSlug: Record<string, string | Record<string, string>>;
|
|
57
|
+
env: ConfigEnv;
|
|
58
|
+
cms: ConfigCms;
|
|
59
|
+
local: ConfigLocal;
|
|
60
|
+
scripts: ConfigAsset;
|
|
61
|
+
styles: ConfigAsset;
|
|
62
|
+
image: ConfigImage;
|
|
63
|
+
filter: ConfigFilter;
|
|
64
|
+
}
|
|
65
|
+
export type ConfigSet = (args: Partial<Config>) => Config;
|
|
66
|
+
export type ConfigSetFilter = (env: Generic) => Config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ContentfulDataParams, AllContentfulDataArgs } from './contentfulDataTypes.js';
|
|
2
|
+
import type { RenderAllData, RenderData } from '../render/renderTypes.js';
|
|
3
|
+
declare const getContentfulData: (key: string, params?: ContentfulDataParams) => Promise<RenderData>;
|
|
4
|
+
declare const getAllContentfulData: (args?: AllContentfulDataArgs) => Promise<RenderAllData | undefined>;
|
|
5
|
+
export { getContentfulData, getAllContentfulData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import resolveResponse from"contentful-resolve-response";import{applyFilters}from"../filters/filters.js";import{isObject,isObjectStrict}from"../utils/object/object.js";import{isStringStrict}from"../utils/string/string.js";import{config}from"../config/config.js";import{getStoreItem}from"../store/store.js";import{normalizeContentfulData}from"./contentfulDataNormal.js";const getContentfulData=async(key,params)=>{if(!isStringStrict(key))throw new Error("No key");if(config.env.cache){const cacheDataFilterArgs={key:key,type:"get"},cacheData=await applyFilters("cacheData",void 0,cacheDataFilterArgs,!0);if(isObject(cacheData))return structuredClone(cacheData)}const{space:space,devCredential:devCredential,prodCredential:prodCredential,devHost:devHost,prodHost:prodHost,env:env="master"}=config.cms;let accessToken=devCredential,host=devHost;if(config.env.prod&&(accessToken=prodCredential,host=prodHost),!isStringStrict(space)||!isStringStrict(accessToken)||!isStringStrict(host))throw new Error("No credentials");let url=`https://${host}/spaces/${space}/environments/${env}/entries?access_token=${accessToken}`;if(isObjectStrict(params))for(const[key,value]of Object.entries(params))url+=`&${key}=${value.toString()}`;const resp=await fetch(url),data=await resp.json();if(!resp.ok){const message=isStringStrict(data.message)?data.message:"Bad fetch response";throw new Error(message,{cause:data})}const resolvedData=resolveResponse(data),newItems=normalizeContentfulData(resolvedData),{total:total,limit:limit,skip:skip}=data,newData={items:newItems,total:total,limit:limit,skip:skip};if(config.env.cache){const cacheDataFilterArgs={key:key,type:"set",data:data};await applyFilters("cacheData",newData,cacheDataFilterArgs,!0)}return newData},getAllContentfulData=async args=>{const{serverlessData:serverlessData,previewData:previewData}=isObjectStrict(args)?args:{};let allData={navigationItem:[],navigation:[],content:{page:[]}};const isServerless=null!=serverlessData,isPreview=null!=previewData,contentfulDataFilterArgs={serverlessData:serverlessData,previewData:previewData},cmsLocales=config.cms.locales||[],defaultLocale=cmsLocales[0],paramLocales=isPreview?[]:[...cmsLocales];if(0===paramLocales.length&¶mLocales.push(""),isServerless||isPreview){let locale,contentType="",id="";if(isServerless){const item=getStoreItem("slugs")[serverlessData.path];if(item){const[itemId,itemContentType,itemLocale]=item;id=itemId||"",contentType=itemContentType||"",locale=itemLocale||""}}if(isPreview&&(id=previewData.id,contentType=previewData.contentType,locale=previewData.locale),id){const key=`serverless_${id}_${contentType}`,params={content_type:contentType,"sys.id":id,include:10};locale&&locale!==defaultLocale&&(params.locale=locale,paramLocales[0]=locale);const data=await getContentfulData(key,params);let{items:items}=data;items=applyFilters("contentfulData",items,{...contentfulDataFilterArgs,contentType:contentType}),allData.content[contentType]=items}}if(!isServerless){const partial=config.partialTypes;for(const contentType of partial){const key=`all_${contentType}`;let newItems=[];for(const locale of paramLocales){const params={content_type:contentType};locale&&locale!==defaultLocale&&(params.locale=locale);const newData=await getContentfulData(key,params);let{items:items}=newData;items=applyFilters("contentfulData",items,{...contentfulDataFilterArgs,contentType:contentType}),newItems=[...newItems,...items]}allData[contentType]=newItems}}if(!isServerless&&!isPreview){const whole=config.wholeTypes;for(const contentType of whole){const key=`all_${contentType}`;let newItems=[];for(const locale of paramLocales){const params={content_type:contentType,include:10};locale&&locale!==defaultLocale&&(params.locale=locale);const newData=await getContentfulData(key,params);let{items:items}=newData;items=applyFilters("contentfulData",items,{...contentfulDataFilterArgs,contentType:contentType}),newItems=[...newItems,...items]}allData.content[contentType]=newItems}}return allData=applyFilters("allData",allData,{type:"contentful",serverlessData:serverlessData,previewData:previewData}),allData};export{getContentfulData,getAllContentfulData};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ContentfulDataItem } from './contentfulDataTypes.js';
|
|
2
|
+
import type { RenderItem } from '../render/renderTypes.js';
|
|
3
|
+
declare const normalizeContentfulData: (data: ContentfulDataItem[], _newData?: RenderItem[]) => RenderItem[];
|
|
4
|
+
export { normalizeContentfulData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{normalizeContentType}from"../utils/contentType/contentType.js";import{isArrayStrict}from"../utils/array/array.js";import{isObjectStrict}from"../utils/object/object.js";import{isString,isStringStrict}from"../utils/string/string.js";import{getObjectKeys}from"../utils/object/objectUtils.js";import{isNumber}from"../utils/number/number.js";import{config}from"../config/config.js";const getTag=(type="text")=>({br:"br",hr:"hr",paragraph:"p",blockquote:"blockquote",bold:"b",italic:"i",underline:"u",superscript:"sup",subscript:"sub",code:"code",hyperlink:"a","entry-hyperlink":"a","asset-hyperlink":"a","heading-1":"h1","heading-2":"h2","heading-3":"h3","heading-4":"h4","heading-5":"h5","heading-6":"h6","list-item":"li","unordered-list":"ul","ordered-list":"ol",table:"table","table-row":"tr","table-cell":"td","table-header-cell":"th"}[type]||""),normalizeRichText=items=>{const newItems=[];return items.forEach(item=>{if(!isObjectStrict(item))return;const{nodeType:nodeType,data:data,value:value,marks:marks,content:content}=item,tag=getTag(nodeType);let contentValue,link,internalLink;if(isStringStrict(value)&&(contentValue=value,contentValue=contentValue.replace(/\n/g,"<br>"),isArrayStrict(marks))){const markTags=marks.map(m=>getTag(m.type));contentValue=`${markTags.map(m=>`<${m}>`).join("")}${value}${markTags.map(m=>`</${m}>`).join("")}`}if(isStringStrict(content)&&(contentValue=content),isArrayStrict(content)&&(contentValue=normalizeRichText(content)),isObjectStrict(data)&&(link=isString(data.uri)?data.uri:"",isObjectStrict(data.target))){const target=data.target;"entry-hyperlink"!==nodeType&&"embedded-entry-inline"!==nodeType||(internalLink=target);const url=target.fields?.file?.url;"asset-hyperlink"===nodeType&&isString(url)&&(link=`https:${url}`)}if(!contentValue)return;const newItem={content:contentValue};return isStringStrict(tag)&&(newItem.tag=tag),isStringStrict(link)&&(newItem.link=link),isObjectStrict(internalLink)&&(newItem.internalLink=normalizeItem(internalLink,[],!0)),newItems.push(newItem)}),newItems},normalizeFile=(file,fields)=>{const type=isString(file.contentType)?file.contentType:"",format=type?type.split("/")[1]:"";return{url:isString(file.url)?`https:${file.url}`:"",name:isString(file.fileName)?file.fileName:"",alt:isString(fields.description)?fields.description:"",width:isNumber(file.details?.image?.width)?file.details.image.width:0,height:isNumber(file.details?.image?.height)?file.details.image.height:0,size:isNumber(file.details?.size)?file.details.size:0,format:"jpeg"===format?"jpg":format,type:type}},normalizeItem=(item,data,isInternalLink=!1)=>{let newItem={};const itemCopy={...item};isString(itemCopy.sys?.id)&&(newItem.id=itemCopy.sys.id),isStringStrict(itemCopy.sys?.locale)&&(newItem.locale=itemCopy.sys.locale);let type="";if(isString(itemCopy.sys?.type)&&(type=itemCopy.sys.type),isString(itemCopy.sys?.contentType?.sys?.id)&&(type=itemCopy.sys.contentType.sys.id),type&&"Link"!==type&&(newItem.contentType=normalizeContentType(type),isString(config.renderTypes[type])&&(newItem.renderType=config.renderTypes[type])),isArrayStrict(itemCopy.metadata?.tags)&&(newItem.metadata={tags:itemCopy.metadata.tags.map(t=>({id:isString(t.sys?.id)?t.sys.id:""}))}),isObjectStrict(itemCopy.fields)){const fields=itemCopy.fields,file=fields.file;if(isObjectStrict(file))return Object.assign(normalizeFile(file,fields),newItem);getObjectKeys(fields).forEach(prop=>{const field=fields[prop];if("content"!==prop||!isInternalLink)if(isObjectStrict(field))if("document"===field.nodeType){const{content:content}=field;isArrayStrict(content)&&(newItem[prop]=content.map(c=>isObjectStrict(c)?normalizeItem(c,data,isInternalLink):c))}else newItem[prop]=normalizeItem(field,data,"internalLink"===prop);else isArrayStrict(field)?newItem[prop]=field.map(f=>isObjectStrict(f)?normalizeItem(f,data,isInternalLink):f):newItem[prop]=field})}if(isString(itemCopy.nodeType)){const nodeType=itemCopy.nodeType;if("embedded-entry-block"===nodeType||"embedded-asset-block"===nodeType){const content=isObjectStrict(itemCopy.data?.target)?itemCopy.data.target:{};newItem=normalizeItem(content,data,isInternalLink)}else newItem.renderType="richText",newItem.tag=getTag(itemCopy.nodeType),isString(itemCopy.content)&&(newItem.content=itemCopy.content),isArrayStrict(itemCopy.content)&&(newItem.content=normalizeRichText(itemCopy.content))}return newItem},normalizeContentfulData=(data,_newData=[])=>isArrayStrict(data)?(data.forEach(item=>{isObjectStrict(item)&&_newData.push(normalizeItem(item,_newData))}),_newData):[];export{normalizeContentfulData};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Generic } from '../global/globalTypes.js';
|
|
2
|
+
import type { RenderServerlessData, RenderPreviewData } from '../render/renderTypes.js';
|
|
3
|
+
export type ContentfulDataParams = Record<string, string | number | boolean>;
|
|
4
|
+
interface ContentfulDataErrorSys {
|
|
5
|
+
type: string;
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ContentfulDataError {
|
|
9
|
+
message: string;
|
|
10
|
+
sys: ContentfulDataErrorSys;
|
|
11
|
+
}
|
|
12
|
+
export interface ContentfulData {
|
|
13
|
+
items: ContentfulDataItem[];
|
|
14
|
+
total: number;
|
|
15
|
+
limit: number;
|
|
16
|
+
skip: number;
|
|
17
|
+
}
|
|
18
|
+
interface ContentfulDataId {
|
|
19
|
+
id?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ContentfulDataTag {
|
|
22
|
+
sys?: ContentfulDataId;
|
|
23
|
+
}
|
|
24
|
+
interface ContentfulDataMeta {
|
|
25
|
+
tags?: ContentfulDataTag[];
|
|
26
|
+
}
|
|
27
|
+
export interface ContentfulDataMark {
|
|
28
|
+
type: string;
|
|
29
|
+
}
|
|
30
|
+
interface ContentfulDataFileImage {
|
|
31
|
+
width?: number;
|
|
32
|
+
height?: number;
|
|
33
|
+
}
|
|
34
|
+
interface ContentfulDataFileDetails {
|
|
35
|
+
size?: number;
|
|
36
|
+
image?: ContentfulDataFileImage;
|
|
37
|
+
}
|
|
38
|
+
export interface ContentfulDataFile {
|
|
39
|
+
url?: string;
|
|
40
|
+
contentType?: string;
|
|
41
|
+
fileName?: string;
|
|
42
|
+
details?: ContentfulDataFileDetails;
|
|
43
|
+
}
|
|
44
|
+
export interface ContentfulDataFields extends Generic {
|
|
45
|
+
content?: ContentfulDataItem[] | ContentfulDataItem;
|
|
46
|
+
internalLink?: ContentfulDataItem;
|
|
47
|
+
file?: ContentfulDataFile;
|
|
48
|
+
description?: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
}
|
|
51
|
+
interface ContentfulDataSysType {
|
|
52
|
+
sys?: ContentfulDataId;
|
|
53
|
+
}
|
|
54
|
+
export interface ContentfulDataSys {
|
|
55
|
+
id?: string;
|
|
56
|
+
type?: string;
|
|
57
|
+
locale?: string;
|
|
58
|
+
contentType?: ContentfulDataSysType;
|
|
59
|
+
}
|
|
60
|
+
interface ContentfulDataDatum {
|
|
61
|
+
uri?: string;
|
|
62
|
+
target?: ContentfulDataItem;
|
|
63
|
+
}
|
|
64
|
+
export interface ContentfulDataItem {
|
|
65
|
+
value?: string;
|
|
66
|
+
nodeType?: string;
|
|
67
|
+
marks?: ContentfulDataMark[];
|
|
68
|
+
data?: ContentfulDataDatum;
|
|
69
|
+
content?: ContentfulDataItem[] | string;
|
|
70
|
+
metadata?: ContentfulDataMeta;
|
|
71
|
+
sys?: ContentfulDataSys;
|
|
72
|
+
fields?: ContentfulDataFields;
|
|
73
|
+
}
|
|
74
|
+
export interface AllContentfulDataArgs {
|
|
75
|
+
serverlessData?: RenderServerlessData;
|
|
76
|
+
previewData?: RenderPreviewData;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Filters, FilterMap, FilterReturnType } from './filtersTypes.js';
|
|
2
|
+
declare let filters: FilterMap;
|
|
3
|
+
declare const addFilter: <T extends keyof Filters>(name: T, filter: Filters[T]) => boolean;
|
|
4
|
+
declare const removeFilter: <T extends keyof Filters>(name: T, filter: Filters[T]) => boolean;
|
|
5
|
+
declare const applyFilters: <T, V extends boolean = false>(name: string, value: T, args?: unknown, isAsync?: V) => FilterReturnType<T, V>;
|
|
6
|
+
declare const resetFilters: () => void;
|
|
7
|
+
declare const setFilters: (args: Partial<Filters>) => boolean;
|
|
8
|
+
export { filters, addFilter, removeFilter, applyFilters, resetFilters, setFilters };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isSet,isSetStrict}from"../utils/set/set.js";import{isStringStrict}from"../utils/string/string.js";import{isObjectStrict}from"../utils/object/object.js";import{isFunction}from"../utils/function/function.js";let filters=new Map([["columnProps",new Set],["containerProps",new Set],["formOptionProps",new Set],["formFieldProps",new Set],["formProps",new Set],["richTextProps",new Set],["richTextOutput",new Set],["richTextContentItem",new Set],["richTextContent",new Set],["richTextContentOutput",new Set],["renderItem",new Set],["renderItemData",new Set],["renderContent",new Set],["serverlessResult",new Set],["contactResult",new Set],["cacheData",new Set],["storeData",new Set],["contentfulData",new Set],["wordpressData",new Set],["localData",new Set],["allData",new Set],["slugParts",new Set],["slug",new Set]]);const addFilter=(name,filter)=>!(!isStringStrict(name)||!isFunction(filter))&&(isSet(filters.get(name))||filters.set(name,new Set),filters.get(name)?.add(filter),!0),removeFilter=(name,filter)=>{if(!isStringStrict(name)||!isFunction(filter))return!1;const filterSet=filters.get(name);return!!isSet(filterSet)&&filterSet.delete(filter)},applySequentially=async(callbacks,value,args)=>{for(const callback of callbacks)value=await callback(value,args);return value},applyFilters=(name,value,args,isAsync=!1)=>{const filterSet=filters.get(name);if(!isSetStrict(filterSet))return value;const callbacks=[];for(const callback of filterSet.values())isAsync?callbacks.push(callback):value=callback(value,args);return isAsync?applySequentially(callbacks,value,args).then(newValue=>newValue).catch(()=>value):value},resetFilters=()=>{filters=new Map([["columnProps",new Set],["containerProps",new Set],["formOptionProps",new Set],["formFieldProps",new Set],["formProps",new Set],["richTextProps",new Set],["richTextOutput",new Set],["richTextContentItem",new Set],["richTextContent",new Set],["richTextContentOutput",new Set],["renderItem",new Set],["renderItemData",new Set],["renderContent",new Set],["serverlessResult",new Set],["contactResult",new Set],["cacheData",new Set],["storeData",new Set],["contentfulData",new Set],["wordpressData",new Set],["localData",new Set],["allData",new Set],["slugParts",new Set],["slug",new Set]])},setFilters=args=>{if(!isObjectStrict(args))return!1;const newFilters=Object.entries(args);return!!newFilters.length&&(resetFilters(),newFilters.forEach(([name,filter])=>{filter&&addFilter(name,filter)}),!0)};export{filters,addFilter,removeFilter,applyFilters,resetFilters,setFilters};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { GenericFunction } from '../global/globalTypes.js';
|
|
2
|
+
import type { ColumnPropsFilter } from '../layouts/Column/ColumnTypes.js';
|
|
3
|
+
import type { ContainerPropsFilter } from '../layouts/Container/ContainerTypes.js';
|
|
4
|
+
import type { FormPropsFilter, FormFieldPropsFilter, FormOptionPropsFilter } from '../objects/Form/FormTypes.js';
|
|
5
|
+
import type { ServerlessResultFilter } from '../serverless/serverlessTypes.js';
|
|
6
|
+
import type { ContactResultFilter } from '../serverless/Contact/ContactTypes.js';
|
|
7
|
+
import type { LinkSlugPartsFilter, LinkSlugFilter } from '../utils/link/linkTypes.js';
|
|
8
|
+
import type { RichTextPropsFilter, RichTextOutputFilter, RichTextContentItemFilter, RichTextContentFilter, RichTextContentOutputFilter } from '../text/RichText/RichTextTypes.js';
|
|
9
|
+
import type { RenderItem, RenderItemFilter, RenderItemDataFilter, RenderContentFilter, RenderServerlessData, RenderPreviewData, RenderAllData, RenderData } from '../render/renderTypes.js';
|
|
10
|
+
export interface DataFilterArgs {
|
|
11
|
+
serverlessData?: RenderServerlessData;
|
|
12
|
+
previewData?: RenderPreviewData;
|
|
13
|
+
contentType?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AllDataFilterArgs {
|
|
16
|
+
type: 'contentful' | 'wordpress' | 'local';
|
|
17
|
+
serverlessData?: RenderServerlessData;
|
|
18
|
+
previewData?: RenderPreviewData;
|
|
19
|
+
}
|
|
20
|
+
export type ContentfulDataFilter = (data: RenderItem[], args: DataFilterArgs) => RenderItem[];
|
|
21
|
+
export type WordpressDataFilter = (data: RenderItem[], args: DataFilterArgs) => RenderItem[];
|
|
22
|
+
export type LocalDataFilter = (data: RenderItem) => RenderItem;
|
|
23
|
+
export type AllDataFilter = (allData: RenderAllData, args: AllDataFilterArgs) => RenderAllData;
|
|
24
|
+
export interface CacheData extends RenderData {
|
|
25
|
+
data?: Record<string, RenderItem>;
|
|
26
|
+
}
|
|
27
|
+
export interface CacheDataFilterArgs {
|
|
28
|
+
key: string;
|
|
29
|
+
type: string;
|
|
30
|
+
data?: CacheData;
|
|
31
|
+
}
|
|
32
|
+
export type CacheDataFilter = (data: CacheData, args: CacheDataFilterArgs) => Promise<CacheData | undefined>;
|
|
33
|
+
export type StoreDataFilter = (data: object | undefined, type: string) => Promise<object | undefined>;
|
|
34
|
+
export interface Filters extends Record<string, GenericFunction> {
|
|
35
|
+
columnProps: ColumnPropsFilter;
|
|
36
|
+
containerProps: ContainerPropsFilter;
|
|
37
|
+
formOptionProps: FormOptionPropsFilter;
|
|
38
|
+
formFieldProps: FormFieldPropsFilter;
|
|
39
|
+
formProps: FormPropsFilter;
|
|
40
|
+
richTextProps: RichTextPropsFilter;
|
|
41
|
+
richTextOutput: RichTextOutputFilter;
|
|
42
|
+
richTextContentItem: RichTextContentItemFilter;
|
|
43
|
+
richTextContent: RichTextContentFilter;
|
|
44
|
+
richTextContentOutput: RichTextContentOutputFilter;
|
|
45
|
+
renderItem: RenderItemFilter;
|
|
46
|
+
renderItemData: RenderItemDataFilter;
|
|
47
|
+
renderContent: RenderContentFilter;
|
|
48
|
+
serverlessResult: ServerlessResultFilter;
|
|
49
|
+
contactResult: ContactResultFilter;
|
|
50
|
+
cacheData: CacheDataFilter;
|
|
51
|
+
storeData: StoreDataFilter;
|
|
52
|
+
contentfulData: ContentfulDataFilter;
|
|
53
|
+
wordpressData: WordpressDataFilter;
|
|
54
|
+
localData: LocalDataFilter;
|
|
55
|
+
allData: AllDataFilter;
|
|
56
|
+
slugParts: LinkSlugPartsFilter;
|
|
57
|
+
slug: LinkSlugFilter;
|
|
58
|
+
}
|
|
59
|
+
export type FilterMap = Map<string, Set<GenericFunction>> & Map<'columnProps' | 'containerProps' | 'formOptionProps' | 'formFieldProps' | 'formProps' | 'richTextProps' | 'richTextOutput' | 'richTextContentItem' | 'richTextContent' | 'richTextContentOutput' | 'renderItem' | 'renderItemData' | 'renderContent' | 'serverlessResult' | 'contactResult' | 'cacheData' | 'storeData' | 'contentfulData' | 'wordpressData' | 'localData' | 'allData' | 'slugParts' | 'slug', Set<ColumnPropsFilter | ContainerPropsFilter | FormOptionPropsFilter | FormFieldPropsFilter | FormPropsFilter | RichTextPropsFilter | RichTextOutputFilter | RichTextContentItemFilter | RichTextContentFilter | RichTextContentOutputFilter | RenderItemFilter | RenderItemDataFilter | RenderContentFilter | ServerlessResultFilter | ContactResultFilter | CacheDataFilter | StoreDataFilter | ContentfulDataFilter | WordpressDataFilter | LocalDataFilter | AllDataFilter | LinkSlugPartsFilter | LinkSlugFilter>>;
|
|
60
|
+
export type FilterReturnType<T, V extends false | true> = V extends true ? Promise<T> : T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface Taxonomy {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
contentTypes: string[];
|
|
5
|
+
slug?: string;
|
|
6
|
+
link?: string;
|
|
7
|
+
isPage?: boolean;
|
|
8
|
+
usePrimaryContentTypeSlug?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface InternalLink extends Generic {
|
|
11
|
+
id?: string;
|
|
12
|
+
contentType?: string;
|
|
13
|
+
slug?: string;
|
|
14
|
+
link?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
taxonomy?: Taxonomy;
|
|
17
|
+
}
|
|
18
|
+
export interface Parent extends InternalLink {
|
|
19
|
+
id: string;
|
|
20
|
+
slug: string;
|
|
21
|
+
title: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ParentArgs<T = Generic> {
|
|
24
|
+
renderType: string;
|
|
25
|
+
args: T;
|
|
26
|
+
}
|
|
27
|
+
export interface RefString {
|
|
28
|
+
ref: string;
|
|
29
|
+
}
|
|
30
|
+
export type Source = 'cms' | 'local' | (string & Record<never, never>);
|
|
31
|
+
export type Generic = Record<string, unknown>;
|
|
32
|
+
export type GenericFunction<T extends (...args: any[]) => any = (...args: any[]) => any> = T;
|
|
33
|
+
export type GenericStrings = Record<string, string>;
|
|
34
|
+
export type GenericNumbers = Record<string, number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{applyFilters}from"../../filters/filters.js";import{isStringStrict}from"../../utils/string/string.js";import{isObjectStrict}from"../../utils/object/object.js";const Column=props=>{if(!isObjectStrict(props))return[];props=applyFilters("columnProps",props);const{args:args}=props,{tag:tag="div",classes:classes,style:style,attr:attr}=isObjectStrict(args)?args:{};if(!isStringStrict(tag))return[];let styles="";isStringStrict(style)&&(styles=` style="${style}"`);let attrs="";return isStringStrict(classes)&&(attrs+=` class="${classes}"`),isStringStrict(attr)&&(attrs+=` ${attr}`),[`<${tag}${attrs}${styles}>`,`</${tag}>`]};export{Column};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Generic } from '../../global/globalTypes.js';
|
|
2
|
+
import type { RenderFunctionArgs, RenderItem } from '../../render/renderTypes.js';
|
|
3
|
+
export interface ColumnArgs<T = any, W = any> extends Generic {
|
|
4
|
+
tag?: string & T;
|
|
5
|
+
width?: (string | number) & W;
|
|
6
|
+
widthSmall?: (string | number) & W;
|
|
7
|
+
widthMedium?: (string | number) & W;
|
|
8
|
+
widthLarge?: (string | number) & W;
|
|
9
|
+
classes?: string;
|
|
10
|
+
style?: string;
|
|
11
|
+
attr?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ColumnProps<A = ColumnArgs, R = RenderItem> extends RenderFunctionArgs<A, R> {
|
|
14
|
+
args: ColumnArgs & A;
|
|
15
|
+
}
|
|
16
|
+
export type ColumnPropsFilter<A = ColumnArgs, R = RenderItem> = (props: ColumnProps<A, R>) => ColumnProps<A, R>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{applyFilters}from"../../filters/filters.js";import{isObjectStrict}from"../../utils/object/object.js";import{isStringStrict}from"../../utils/string/string.js";const Container=props=>{if(!isObjectStrict(props))return[];props=applyFilters("containerProps",props);const{args:args}=props,{tag:tag="div",layoutClasses:layoutClasses,classes:classes,style:style,attr:attr,nest:nest=!1}=isObjectStrict(args)?args:{};if(!isStringStrict(tag))return[];const isSemanticParent=new Set(["ul","ol","dl","figure"]).has(tag),hasLayoutClasses=isStringStrict(layoutClasses),hasClasses=isStringStrict(classes),attrs=[],innerAttrs=[],isNested=nest&&hasLayoutClasses,isNestedSemanticParent=isSemanticParent&&isNested,innerClassesArr=[];isNested&&hasLayoutClasses&&innerClassesArr.push(layoutClasses);const outerClassesArr=[];isNested&&hasClasses&&outerClassesArr.push(classes),!isNested&&hasClasses&&outerClassesArr.push(classes),!isNested&&hasLayoutClasses&&outerClassesArr.push(layoutClasses),outerClassesArr.length&&attrs.push(`class="${outerClassesArr.join(" ")}"`),innerClassesArr.length&&innerAttrs.push(`class="${innerClassesArr.join(" ")}"`);const att=isNestedSemanticParent?innerAttrs:attrs;isStringStrict(attr)&&att.push(attr),isStringStrict(style)&&att.push(`style="${style}"`);let outerTag=tag,innerTag="";isNested&&(outerTag=isSemanticParent?"div":tag,innerTag=isSemanticParent?tag:"div");let start=`<${outerTag}${attrs.length?` ${attrs.join(" ")}`:""}>`,end=`</${outerTag}>`;return innerTag&&(start=`${start}<${innerTag} ${innerAttrs.join(" ")}>`,end=`</${innerTag}>${end}`),[start,end]};export{Container};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Generic } from '../../global/globalTypes.js';
|
|
2
|
+
import type { RenderFunctionArgs, RenderItem } from '../../render/renderTypes.js';
|
|
3
|
+
export interface ContainerArgs<T = any, M = any> extends Generic {
|
|
4
|
+
tag?: string & T;
|
|
5
|
+
maxWidth?: (string | number) & M;
|
|
6
|
+
layoutClasses?: string;
|
|
7
|
+
classes?: string;
|
|
8
|
+
style?: string;
|
|
9
|
+
attr?: string;
|
|
10
|
+
nest?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ContainerProps<A = ContainerArgs, R = RenderItem> extends RenderFunctionArgs<A, R> {
|
|
13
|
+
args: ContainerArgs & A;
|
|
14
|
+
}
|
|
15
|
+
export type ContainerPropsFilter<A = ContainerArgs, R = RenderItem> = (props: ContainerProps<A, R>) => ContainerProps<A, R>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LocalData, LocalDataArgs, AllLocalDataArgs } from './localDataTypes.js';
|
|
2
|
+
import type { RenderAllData } from '../render/renderTypes.js';
|
|
3
|
+
declare const getLocalData: (args: LocalDataArgs) => Promise<LocalData>;
|
|
4
|
+
declare const getAllLocalData: (args?: AllLocalDataArgs) => Promise<RenderAllData | undefined>;
|
|
5
|
+
export { getLocalData, getAllLocalData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readdir,readFile}from"node:fs/promises";import{extname,basename,resolve}from"node:path";import{isObject,isObjectStrict}from"../utils/object/object.js";import{isStringStrict}from"../utils/string/string.js";import{applyFilters}from"../filters/filters.js";import{getJson}from"../utils/json/json.js";import{config}from"../config/config.js";import{normalizeLocalData}from"./localDataNormal.js";const getLocalData=async args=>{if(!isObjectStrict(args))throw new Error("No args");const{key:key,refProps:refProps,imageProps:imageProps,unsetProps:unsetProps}=args;if(!isStringStrict(key))throw new Error("No key");if(config.env.cache){const cacheDataFilterArgs={key:key,type:"get"},cacheData=await applyFilters("cacheData",void 0,cacheDataFilterArgs,!0),cacheItems=cacheData?.data;if(isObject(cacheItems))return structuredClone(cacheItems)}const dir=config.local.dir,data={};let hasData=!1;const files=await readdir(resolve(dir));for(const file of files){const fileExt=extname(file),fileName=basename(file,fileExt);if(".json"!==fileExt)continue;const fileContents=await readFile(resolve(dir,file),{encoding:"utf8"}),fileJson=getJson(fileContents);fileJson&&(data[fileName]=fileJson,hasData=!0)}if(!hasData)throw new Error("No data");const newData=normalizeLocalData(data,refProps,imageProps,unsetProps);if(config.env.cache){const cacheDataFilterArgs={key:key,type:"set",data:data};await applyFilters("cacheData",{data:newData},cacheDataFilterArgs,!0)}return newData},getAllLocalData=async args=>{const data=await getLocalData({key:"all_file_data",refProps:args?.refProps,imageProps:args?.imageProps,unsetProps:args?.unsetProps});let allData={navigationItem:[],navigation:[],content:{page:[]}};for(const[,value]of Object.entries(data)){const{contentType:contentType}=value;if(!isStringStrict(contentType))continue;const isPartial=config.partialTypes.includes(contentType),isWhole=config.wholeTypes.includes(contentType);if(!isPartial&&!isWhole)continue;const val=applyFilters("localData",value);isPartial&&(null==allData[contentType]&&(allData[contentType]=[]),allData[contentType].push(val)),isWhole&&(null==allData.content[contentType]&&(allData.content[contentType]=[]),allData.content[contentType].push(val))}return allData=applyFilters("allData",allData,{type:"local"}),allData};export{getLocalData,getAllLocalData};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject,isObjectStrict}from"../utils/object/object.js";import{isArray,isArrayStrict}from"../utils/array/array.js";import{isStringStrict}from"../utils/string/string.js";import{getStoreItem}from"../store/store.js";const normalizeLocalRefs=(data,refData,imageData,refProps=["internalLink","term","taxonomy"],imageProps=["image"],unsetProps=["content"],contentType)=>{const newData=isArray(data)?[]:{},isTemplate="contentTemplate"===data.renderType,isNavigation="navigation"===contentType,isNavigationItem="navigationItem"===contentType;for(const[key,value]of Object.entries(data)){const isRef=refProps.includes(key),isImage=imageProps.includes(key),isStr=isStringStrict(value),isArr=isArrayStrict(value);let newValue=value;isTemplate&&"content"===key&&isArr&&(newValue=value.map(item=>isStringStrict(item)?{...refData[item]}:item)),(isNavigation&&"items"===key||isNavigationItem&&"children"===key)&&isArr&&(newValue=value.map(id=>isStringStrict(id)?{id:id,title:refData[id]?.title}:null).filter(Boolean)),isImage&&isStr&&(newValue=imageData[value]?{...imageData[value]}:null),isRef&&isStr&&(newValue={...refData[value]},unsetProps.forEach(prop=>{newValue[prop]&&(newValue[prop]=void 0)})),isRef&&isArrayStrict(value)&&(newValue=value.map(refKey=>{if(!isStringStrict(refKey))return null;const ref=refData[refKey];if(!isObjectStrict(ref))return null;const newRef={...ref};return unsetProps.forEach(prop=>{newRef[prop]&&(newRef[prop]=void 0)}),newRef}).filter(Boolean)),isObject(newValue)&&(newValue=normalizeLocalRefs(newValue,refData,imageData,refProps,imageProps,unsetProps)),newData[key]=newValue}return newData},normalizeLocalData=(data,refProps,imageProps,unsetProps)=>{const newData={},imageMeta=getStoreItem("imageMeta"),refData={};for(const[key,item]of Object.entries(data))isObjectStrict(item)&&(refData[key]={id:key,...item});for(const[key,item]of Object.entries(refData))newData[key]=normalizeLocalRefs(item,refData,imageMeta,refProps,imageProps,unsetProps,item.contentType);return newData};export{normalizeLocalData};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RenderItem } from '../render/renderTypes.js';
|
|
2
|
+
export type LocalData = Record<string, RenderItem>;
|
|
3
|
+
export type LocalDataItem = Record<string | number, unknown>;
|
|
4
|
+
export interface LocalDataArgs {
|
|
5
|
+
key: string;
|
|
6
|
+
refProps?: string[];
|
|
7
|
+
imageProps?: string[];
|
|
8
|
+
unsetProps?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface AllLocalDataArgs {
|
|
11
|
+
refProps?: string[];
|
|
12
|
+
imageProps?: string[];
|
|
13
|
+
unsetProps?: string[];
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{v4 as uuid}from"uuid";import{applyFilters}from"../../filters/filters.js";import{isStringStrict}from"../../utils/string/string.js";import{isObjectStrict}from"../../utils/object/object.js";const Form=props=>{if(!isObjectStrict(props))return[];props=applyFilters("formProps",props);const{args:args}=props,{id:id,formTag:formTag="form",formClasses:formClasses,formAttr:formAttr,fields:fields="",fieldsClasses:fieldsClasses,fieldsAttr:fieldsAttr,submitFieldClasses:submitFieldClasses,submitFieldAttr:submitFieldAttr,submitLabel:submitLabel="Submit",submitClasses:submitClasses,submitAttr:submitAttr,honeypotName:honeypotName,honeypotFieldClasses:honeypotFieldClasses,honeypotFieldAttr:honeypotFieldAttr,honeypotLabelClasses:honeypotLabelClasses,honeypotLabel:honeypotLabel="Website",honeypotClasses:honeypotClasses,honeypotAttr:honeypotAttr}=isObjectStrict(args)?args:{};if(!isStringStrict(id)||!isStringStrict(formTag)||!isStringStrict(submitLabel))return[];const formAttrs=(isStringStrict(formClasses)?` class="${formClasses}"`:"")+(isStringStrict(formAttr)?` ${formAttr}`:""),fieldsTag="form"===formTag?"div":"form",fieldsAttrs=(isStringStrict(fieldsClasses)?` class="${fieldsClasses}"`:"")+(isStringStrict(fieldsAttr)?` ${fieldsAttr}`:"");let honeypotOutput="";if(isStringStrict(honeypotName)){const honeypotId=uuid(),honeypotFieldAttrs=(isStringStrict(honeypotFieldClasses)?` class="${honeypotFieldClasses}"`:"")+(isStringStrict(honeypotFieldAttr)?` ${honeypotFieldAttr}`:""),honeypotAttrs=(isStringStrict(honeypotClasses)?` class="${honeypotClasses}"`:"")+(isStringStrict(honeypotAttr)?` ${honeypotAttr}`:"");honeypotOutput=`\n <div${honeypotFieldAttrs}>\n <label for="${honeypotId}"${isStringStrict(honeypotLabelClasses)?` class="${honeypotLabelClasses}"`:""}>\n ${honeypotLabel}\n </label>\n <input type="url" name="${honeypotName}" id="${honeypotId}" autocomplete="off"${honeypotAttrs}>\n </div>\n `}return[`\n <${formTag} id="${id}"${formAttrs}>\n <${fieldsTag}${fieldsAttrs}>`,`${fields}${honeypotOutput}\n <div${(isStringStrict(submitFieldClasses)?` class="${submitFieldClasses}"`:"")+(isStringStrict(submitFieldAttr)?` ${submitFieldAttr}`:"")}>\n <button type="submit"${(isStringStrict(submitClasses)?` class="${submitClasses}"`:"")+(isStringStrict(submitAttr)?` ${submitAttr}`:"")}>\n ${submitLabel}\n </button>\n </div>\n </${fieldsTag}>\n </${formTag}>\n `]};export{Form};
|