@alanizcreative/formation-static 1.3.0-beta.29
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 +3 -0
- package/cjs/components/Navigation/Navigation.d.ts +16 -0
- package/cjs/components/Navigation/Navigation.js +1 -0
- package/cjs/components/Navigation/NavigationTypes.d.ts +85 -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 +44 -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 +64 -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 +67 -0
- package/cjs/contentful/contentfulDataTypes.js +1 -0
- package/cjs/global/globalTypes.d.ts +32 -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 +74 -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 +198 -0
- package/cjs/render/renderTypes.js +1 -0
- package/cjs/serverless/Ajax/Ajax.d.ts +3 -0
- package/cjs/serverless/Ajax/Ajax.js +1 -0
- package/cjs/serverless/Ajax/AjaxTypes.d.ts +11 -0
- package/cjs/serverless/Ajax/AjaxTypes.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/Preview/Preview.d.ts +5 -0
- package/cjs/serverless/Preview/Preview.js +1 -0
- package/cjs/serverless/Reload/Reload.d.ts +5 -0
- package/cjs/serverless/Reload/Reload.js +1 -0
- package/cjs/serverless/Reload/ReloadTypes.d.ts +5 -0
- package/cjs/serverless/Reload/ReloadTypes.js +1 -0
- package/cjs/serverless/serverless.d.ts +6 -0
- package/cjs/serverless/serverless.js +1 -0
- package/cjs/serverless/serverlessFiles.d.ts +3 -0
- package/cjs/serverless/serverlessFiles.js +1 -0
- package/cjs/serverless/serverlessTypes.d.ts +50 -0
- package/cjs/serverless/serverlessTypes.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 +35 -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/action/action.d.ts +8 -0
- package/cjs/utils/action/action.js +1 -0
- package/cjs/utils/action/actionTypes.d.ts +10 -0
- package/cjs/utils/action/actionTypes.js +1 -0
- package/cjs/utils/archive/archive.d.ts +7 -0
- package/cjs/utils/archive/archive.js +1 -0
- package/cjs/utils/archive/archiveTypes.d.ts +18 -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/filePath.d.ts +2 -0
- package/cjs/utils/file/filePath.js +1 -0
- package/cjs/utils/filter/filter.d.ts +8 -0
- package/cjs/utils/filter/filter.js +1 -0
- package/cjs/utils/filter/filterTypes.d.ts +62 -0
- package/cjs/utils/filter/filterTypes.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 +60 -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 +31 -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/scriptStyle/scriptStyle.d.ts +8 -0
- package/cjs/utils/scriptStyle/scriptStyle.js +1 -0
- package/cjs/utils/scriptStyle/scriptStyleTypes.d.ts +12 -0
- package/cjs/utils/scriptStyle/scriptStyleTypes.js +1 -0
- package/cjs/utils/set/set.d.ts +3 -0
- package/cjs/utils/set/set.js +1 -0
- package/cjs/utils/shortcode/shortcode.d.ts +10 -0
- package/cjs/utils/shortcode/shortcode.js +1 -0
- package/cjs/utils/shortcode/shortcodeTypes.d.ts +20 -0
- package/cjs/utils/shortcode/shortcodeTypes.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 +7 -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 +206 -0
- package/cjs/wordpress/wordpressDataTypes.js +1 -0
- package/lib/components/Navigation/Navigation.d.ts +16 -0
- package/lib/components/Navigation/Navigation.js +1 -0
- package/lib/components/Navigation/NavigationTypes.d.ts +85 -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 +44 -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 +64 -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 +67 -0
- package/lib/contentful/contentfulDataTypes.js +1 -0
- package/lib/global/globalTypes.d.ts +32 -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 +74 -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 +198 -0
- package/lib/render/renderTypes.js +1 -0
- package/lib/serverless/Ajax/Ajax.d.ts +3 -0
- package/lib/serverless/Ajax/Ajax.js +1 -0
- package/lib/serverless/Ajax/AjaxTypes.d.ts +11 -0
- package/lib/serverless/Ajax/AjaxTypes.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/Preview/Preview.d.ts +5 -0
- package/lib/serverless/Preview/Preview.js +1 -0
- package/lib/serverless/Reload/Reload.d.ts +5 -0
- package/lib/serverless/Reload/Reload.js +1 -0
- package/lib/serverless/Reload/ReloadTypes.d.ts +5 -0
- package/lib/serverless/Reload/ReloadTypes.js +1 -0
- package/lib/serverless/serverless.d.ts +6 -0
- package/lib/serverless/serverless.js +1 -0
- package/lib/serverless/serverlessFiles.d.ts +3 -0
- package/lib/serverless/serverlessFiles.js +1 -0
- package/lib/serverless/serverlessTypes.d.ts +50 -0
- package/lib/serverless/serverlessTypes.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 +35 -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/action/action.d.ts +8 -0
- package/lib/utils/action/action.js +1 -0
- package/lib/utils/action/actionTypes.d.ts +10 -0
- package/lib/utils/action/actionTypes.js +1 -0
- package/lib/utils/archive/archive.d.ts +7 -0
- package/lib/utils/archive/archive.js +1 -0
- package/lib/utils/archive/archiveTypes.d.ts +18 -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/filePath.d.ts +2 -0
- package/lib/utils/file/filePath.js +1 -0
- package/lib/utils/filter/filter.d.ts +8 -0
- package/lib/utils/filter/filter.js +1 -0
- package/lib/utils/filter/filterTypes.d.ts +62 -0
- package/lib/utils/filter/filterTypes.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 +60 -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 +31 -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/scriptStyle/scriptStyle.d.ts +8 -0
- package/lib/utils/scriptStyle/scriptStyle.js +1 -0
- package/lib/utils/scriptStyle/scriptStyleTypes.d.ts +12 -0
- package/lib/utils/scriptStyle/scriptStyleTypes.js +1 -0
- package/lib/utils/set/set.d.ts +3 -0
- package/lib/utils/set/set.js +1 -0
- package/lib/utils/shortcode/shortcode.d.ts +10 -0
- package/lib/utils/shortcode/shortcode.js +1 -0
- package/lib/utils/shortcode/shortcodeTypes.d.ts +20 -0
- package/lib/utils/shortcode/shortcodeTypes.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 +7 -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 +206 -0
- package/lib/wordpress/wordpressDataTypes.js +1 -0
- package/package.json +87 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Graciela Alaniz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { NavigationProps, NavigationList, NavigationByLocation, NavigationItem, NavigationItemsById, NavigationBreadcrumbItem, NavigationOutputArgs, NavigationBreadcrumbOutputArgs, NavigationByLocationItem } from './NavigationTypes.js';
|
|
2
|
+
declare class Navigation<L extends string = string> {
|
|
3
|
+
#private;
|
|
4
|
+
navigations: NavigationList[];
|
|
5
|
+
items: NavigationItem[];
|
|
6
|
+
currentLink: string;
|
|
7
|
+
currentType: string[];
|
|
8
|
+
init: boolean;
|
|
9
|
+
constructor(props: NavigationProps);
|
|
10
|
+
getOutput(location: L, args?: NavigationOutputArgs, maxDepth?: number): string;
|
|
11
|
+
getBreadcrumbs(items: NavigationBreadcrumbItem[], current?: string, args?: NavigationBreadcrumbOutputArgs): string;
|
|
12
|
+
getItemsById(): NavigationItemsById;
|
|
13
|
+
getNavigationsByLocation(): NavigationByLocation<L>;
|
|
14
|
+
getNavigationByLocation(location: L): NavigationByLocationItem | undefined;
|
|
15
|
+
}
|
|
16
|
+
export { Navigation };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Navigation=void 0;const link_js_1=require("../../utils/link/link.js"),array_js_1=require("../../utils/array/array.js"),object_js_1=require("../../utils/object/object.js"),string_js_1=require("../../utils/string/string.js"),function_js_1=require("../../utils/function/function.js"),number_js_1=require("../../utils/number/number.js"),contentType_js_1=require("../../utils/contentType/contentType.js"),store_js_1=require("../../store/store.js");class Navigation{navigations=[];items=[];currentLink="";currentType=[];init=!1;#itemsById=new Map;#navigationsByLocation=new Map;constructor(props){this.init=this.#initialize(props)}#initialize(props){if(!(0,object_js_1.isObjectStrict)(props))return!1;const{navigations:navigations,items:items,currentLink:currentLink,currentType:currentType}=props;if(!(0,array_js_1.isArrayStrict)(navigations)||!(0,array_js_1.isArrayStrict)(items))return!1;this.navigations=navigations,this.items=items,this.currentLink=(0,string_js_1.isStringStrict)(currentLink)?currentLink:"";const typesArr=(0,array_js_1.isArrayStrict)(currentType)?currentType:[currentType];return this.currentType=typesArr.map((type=>(0,contentType_js_1.normalizeContentType)(type))),this.items.forEach((item=>{item&&this.#itemsById.set(item.id,item)})),this.items.forEach((item=>{const info=this.#getItemInfo(item);info&&this.#itemsById.set(info.id,info)})),this.navigations.forEach((nav=>{if(!(0,object_js_1.isObjectStrict)(nav))return;const{title:title,location:location,items:items=[]}=nav,locations=(0,array_js_1.isArrayStrict)(location)?location:[location];(0,string_js_1.isStringStrict)(title)&&(0,array_js_1.isArrayStrict)(items)&&locations.forEach((loc=>{this.#navigationsByLocation.set(loc,{title:title,items:items})}))})),!0}#getItemInfo(item){if(!(0,object_js_1.isObjectStrict)(item))return;const{id:id,title:title,link:link,internalLink:internalLink,externalLink:externalLink,children:children}=item;let external=!1;(0,string_js_1.isStringStrict)(externalLink)&&(external=!0);const props={id:id,title:title,link:(0,string_js_1.isStringStrict)(link)?link:(0,link_js_1.getLink)(internalLink,externalLink),external:external};(0,string_js_1.isStringStrict)(props.link)&&!external&&(props.current=props.link===this.currentLink);const internalId=internalLink?.id;if((0,string_js_1.isStringStrict)(internalId)){let isArchiveCurrent=!1;for(const type of this.currentType){if(internalId===(0,store_js_1.getStoreItem)("archiveMeta")[type]?.id){isArchiveCurrent=!0;break}}props.archiveCurrent=isArchiveCurrent}let descendentCurrent=!1;if((0,array_js_1.isArrayStrict)(children)){const storeChildren=[];descendentCurrent=this.#recurseItemChildren(children,storeChildren),props.children=storeChildren}return descendentCurrent&&(props.descendentCurrent=descendentCurrent),{...item,...props}}#recurseItemChildren(children,output){let childCurrent=!1;return children.forEach((child=>{const info=this.#getItemInfo(this.#itemsById.get(child?.id));if(!info)return;const{current:current=!1,archiveCurrent:archiveCurrent=!1}=info;(current||archiveCurrent)&&(childCurrent=!0),output.push(info)})),childCurrent}#getItems(items=[]){const resItems=[];return items.forEach((item=>{if(!(0,object_js_1.isObjectStrict)(item))return;const{id:id}=item,storedItem=this.#itemsById.get(id);storedItem&&resItems.push(storedItem)})),resItems}#recurseOutput=(items,output,args,depth=0,maxDepth)=>{if((0,number_js_1.isNumber)(maxDepth)&&depth>maxDepth)return;const dataAttr=(0,string_js_1.isStringStrict)(args.dataAttr)?args.dataAttr:"data-nav",depthAttr=args.depthAttr?` ${dataAttr}-depth="${depth}"`:"",listFilterArgs={args:args,output:output,items:items,depth:depth};(0,function_js_1.isFunction)(args.filterBeforeList)&&args.filterBeforeList(listFilterArgs);const listClasses=(0,string_js_1.isStringStrict)(args.listClass)?` class="${args.listClass}"`:"",listAttrs=(0,string_js_1.isStringStrict)(args.listAttr)?` ${args.listAttr}`:"",listTag=(0,string_js_1.isStringStrict)(args.listTag)?args.listTag:"ul";output.html+=`<${listTag}${depthAttr}${listClasses}${listAttrs}>`,items.forEach(((item,index)=>{const{title:title,link:link,external:external=!1,children:children,current:current=!1,descendentCurrent:descendentCurrent=!1,archiveCurrent:archiveCurrent=!1}=item,filterArgs={args:args,item:item,output:output,index:index,items:items,depth:depth};(0,function_js_1.isFunction)(args.filterBeforeItem)&&args.filterBeforeItem(filterArgs);const itemClasses=(0,string_js_1.isStringStrict)(args.itemClass)?` class="${args.itemClass}"`:"",itemTag=(0,string_js_1.isStringStrict)(args.itemTag)?args.itemTag:"li";let itemAttrs=(0,string_js_1.isStringStrict)(args.itemAttr)?` ${args.itemAttr}`:"";current&&(itemAttrs+=` ${dataAttr}-current`),descendentCurrent&&(itemAttrs+=` ${dataAttr}-descendent-current`),archiveCurrent&&(itemAttrs+=` ${dataAttr}-archive-current`),output.html+=`<${itemTag}${depthAttr}${itemClasses}${itemAttrs}>`,(0,function_js_1.isFunction)(args.filterBeforeLink)&&args.filterBeforeLink(filterArgs);const linkClassesArr=[];(0,string_js_1.isStringStrict)(args.linkClass)&&linkClassesArr.push(args.linkClass),!external&&(0,string_js_1.isStringStrict)(args.internalLinkClass)&&linkClassesArr.push(args.internalLinkClass);const hasLink=(0,string_js_1.isStringStrict)(link),linkClasses=linkClassesArr.length>0?` class="${linkClassesArr.join(" ")}"`:"",linkAttrsArr=[hasLink?`href="${link}"`:'type="button"'];(0,string_js_1.isStringStrict)(args.linkAttr)&&linkAttrsArr.push(args.linkAttr),current&&(linkAttrsArr.push(`${dataAttr}-current`),hasLink&&linkAttrsArr.push('aria-current="page"')),descendentCurrent&&linkAttrsArr.push(`${dataAttr}-descendent-current`),archiveCurrent&&linkAttrsArr.push(`${dataAttr}-archive-current`);const linkAttrs=` ${linkAttrsArr.join(" ")}`,linkTag=hasLink?"a":"button";output.html+=`<${linkTag}${depthAttr}${linkClasses}${linkAttrs}>`,(0,function_js_1.isFunction)(args.filterBeforeLinkText)&&args.filterBeforeLinkText(filterArgs),output.html+=title,(0,function_js_1.isFunction)(args.filterAfterLinkText)&&args.filterAfterLinkText(filterArgs),output.html+=`</${linkTag}>`,(0,function_js_1.isFunction)(args.filterAfterLink)&&args.filterAfterLink(filterArgs),(0,array_js_1.isArrayStrict)(children)&&this.#recurseOutput(children,output,args,depth+1,maxDepth),output.html+=`</${itemTag}>`,(0,function_js_1.isFunction)(args.filterAfterItem)&&args.filterAfterItem(filterArgs)})),output.html+=`</${listTag}>`,(0,function_js_1.isFunction)(args.filterAfterList)&&args.filterAfterList(listFilterArgs)};getOutput(location,args,maxDepth){const nav=this.#navigationsByLocation.get(location);if(!nav)return"";const items=nav.items,normalizedItems=this.#getItems(items);if(!normalizedItems.length)return"";args=Object.assign({listTag:"",listClass:"",listAttr:"",itemTag:"",itemClass:"",itemAttr:"",linkClass:"",internalLinkClass:"",linkAttr:"",dataAttr:"",depthAttr:!1,filterBeforeList:()=>{},filterAfterList:()=>{},filterBeforeItem:()=>{},filterAfterItem:()=>{},filterBeforeLink:()=>{},filterAfterLink:()=>{},filterBeforeLinkText:()=>{},filterAfterLinkText:()=>{}},(0,object_js_1.isObjectStrict)(args)?args:{});const output={html:""};return this.#recurseOutput(normalizedItems,output,args,0,maxDepth),output.html}getBreadcrumbs(items,current,args){if(!(0,array_js_1.isArrayStrict)(items))return"";args=Object.assign({listClass:"",listAttr:"",itemClass:"",itemAttr:"",linkClass:"",internalLinkClass:"",linkAttr:"",currentClass:"",currentLabel:"",a11yClass:"a-hide-vis",dataAttr:"",filterBeforeLink:()=>{},filterAfterLink:()=>{}},(0,object_js_1.isObjectStrict)(args)?args:{});const dataAttr=(0,string_js_1.isStringStrict)(args.dataAttr)?args.dataAttr:"data-nav",listClasses=(0,string_js_1.isStringStrict)(args.listClass)?` class="${args.listClass}"`:"",listAttrs=(0,string_js_1.isStringStrict)(args.listAttr)?` ${args.listAttr}`:"",filteredItems=items.filter((item=>!!(0,string_js_1.isStringStrict)(item.title)&&(!!(0,string_js_1.isString)(item.slug)&&(item.slug=(0,link_js_1.getSlug)({id:item.id,slug:item.slug,contentType:item.contentType,pageData:item.internalLink}),!0)))),itemClasses=(0,string_js_1.isStringStrict)(args.itemClass)?` class="${args.itemClass}"`:"",itemAttrs=(0,string_js_1.isStringStrict)(args.itemAttr)?` ${args.itemAttr}`:"",lastItemIndex=filteredItems.length-1,itemsArr=filteredItems.map(((item,index)=>{const{title:title,slug:slug}=item,link=(0,link_js_1.getPermalink)(slug),output={html:""},lastLevel=lastItemIndex===index,filterArgs={output:output,lastLevel:lastLevel};output.html+=`<li${itemClasses}${itemAttrs}${lastLevel?` ${dataAttr}-last`:""}>`,(0,function_js_1.isFunction)(args.filterBeforeLink)&&args.filterBeforeLink(filterArgs);const linkClassesArr=[];(0,string_js_1.isStringStrict)(args.linkClass)&&linkClassesArr.push(args.linkClass),(0,string_js_1.isStringStrict)(args.internalLinkClass)&&linkClassesArr.push(args.internalLinkClass);const linkClasses=linkClassesArr.length>0?` class="${linkClassesArr.join(" ")}"`:"",linkAttrs=(0,string_js_1.isStringStrict)(args.linkAttr)?` ${args.linkAttr}`:"";return output.html+=`<a${linkClasses} href="${link}"${linkAttrs}>${title}</a>`,(0,function_js_1.isFunction)(args.filterAfterLink)&&args.filterAfterLink(filterArgs),output.html+="</li>",output.html})),currentLabel=(0,string_js_1.isStringStrict)(args.currentLabel)?args.currentLabel:"(current page)",currentClasses=(0,string_js_1.isStringStrict)(args.currentClass)?` class="${args.currentClass}"`:"",a11yClasses=(0,string_js_1.isStringStrict)(args.a11yClass)?` class="${args.a11yClass}"`:"",currentItem=(0,string_js_1.isStringStrict)(current)?`\n <li${itemClasses}${itemAttrs} ${dataAttr}-current>\n <span${currentClasses}>${current}<span${a11yClasses}> ${currentLabel}</span></span>\n </li>\n `:"";return`\n <ol${listClasses}${listAttrs}>\n ${itemsArr.join("")}\n ${currentItem}\n </ol>\n `}getItemsById(){return this.#itemsById}getNavigationsByLocation(){return this.#navigationsByLocation}getNavigationByLocation(location){return this.#navigationsByLocation.get(location)}}exports.Navigation=Navigation;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { InternalLink, Generic, HtmlString } 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: HtmlString;
|
|
49
|
+
items: NavigationItem[];
|
|
50
|
+
depth: number;
|
|
51
|
+
}
|
|
52
|
+
export interface NavigationOutputFilterArgs {
|
|
53
|
+
args: NavigationOutputArgs;
|
|
54
|
+
item: NavigationItem;
|
|
55
|
+
output: HtmlString;
|
|
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
|
+
listTag?: string;
|
|
64
|
+
itemTag?: string;
|
|
65
|
+
filterBeforeList?: NavigationOutputListFilter;
|
|
66
|
+
filterAfterList?: NavigationOutputListFilter;
|
|
67
|
+
filterBeforeItem?: NavigationFilter;
|
|
68
|
+
filterAfterItem?: NavigationFilter;
|
|
69
|
+
filterBeforeLink?: NavigationFilter;
|
|
70
|
+
filterAfterLink?: NavigationFilter;
|
|
71
|
+
filterBeforeLinkText?: NavigationFilter;
|
|
72
|
+
filterAfterLinkText?: NavigationFilter;
|
|
73
|
+
}
|
|
74
|
+
export interface NavigationBreadcrumbOutputFilterArgs {
|
|
75
|
+
output: HtmlString;
|
|
76
|
+
lastLevel: boolean;
|
|
77
|
+
}
|
|
78
|
+
export type NavigationBreadcrumbOutputFilter = (args: NavigationBreadcrumbOutputFilterArgs) => void;
|
|
79
|
+
export interface NavigationBreadcrumbOutputArgs extends NavigationOutputBaseArgs {
|
|
80
|
+
currentClass?: string;
|
|
81
|
+
currentLabel?: string;
|
|
82
|
+
a11yClass?: string;
|
|
83
|
+
filterBeforeLink?: NavigationBreadcrumbOutputFilter;
|
|
84
|
+
filterAfterLink?: NavigationBreadcrumbOutputFilter;
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Pagination=void 0;const object_js_1=require("../../utils/object/object.js"),string_js_1=require("../../utils/string/string.js"),Pagination=props=>{const fallback={output:"",data:{}};if(!(0,object_js_1.isObjectStrict)(props))return fallback;const{total:total=1,display:display=5,current:current=1,filters:filters,url:url,ellipsis:ellipsis,prev:prev="",next:next="",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",prevSpanClass:prevSpanClass,prevLinkClass:prevLinkClass,nextSpanClass:nextSpanClass,nextLinkClass:nextLinkClass}=(0,object_js_1.isObjectStrict)(args)?args:{};if(total<=1||!(0,string_js_1.isStringStrict)(url))return fallback;let output="";const hasFilters=(0,string_js_1.isStringStrict)(filters);let prevFilters="",nextFilters="",currentFilters="";hasFilters&&(prevFilters=current>2?`&${filters}`:`?${filters}`,currentFilters=1===current?`?${filters}`:`&${filters}`,current<total&&(nextFilters=`&${filters}`));const data={current:current,total:total,nextFilters:nextFilters,currentFilters:currentFilters};1===current?data.next=current+1:(data.title=titleTemplate.replace("%current",current.toString()).replace("%total",total.toString()),data.next=current+1<=total?current+1:0,data.prev=current-1,data.prevFilters=prevFilters);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=[];(0,string_js_1.isStringStrict)(listClass)&&listAttrs.push(`class="${listClass}"`),(0,string_js_1.isStringStrict)(listAttr)&&listAttrs.push(listAttr);const hasEllipsis=(0,string_js_1.isStringStrict)(ellipsis),itemAttrs=`${(0,string_js_1.isStringStrict)(itemClass)?` class="${itemClass}"`:""}${(0,string_js_1.isStringStrict)(itemAttr)?` ${itemAttr}`:""}`;let prevItem=`<span${(0,string_js_1.isStringStrict)(prevSpanClass)?` class="${prevSpanClass}"`:""}>${prev}</span>`,isPrevLink=!1;current>1&&(isPrevLink=!0,prevItem=`\n <a\n href="${url}${current>2?"?page="+(current-1):""}${prevFilters}"\n aria-label="${prevLabel}"${(0,string_js_1.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${(0,string_js_1.isStringStrict)(currentClass)?` class="${currentClass}"`:""}>\n <span class="${a11yClass}">${currentLabel} </span>\n ${i}\n </span>\n `;else{content=`\n <a href="${1===i?url:`${url}?page=${i}`}${hasFilters?1===i?`?${filters}`:`&${filters}`:""}"${(0,string_js_1.isStringStrict)(linkClass)?` class="${linkClass}"`:""}${(0,string_js_1.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${(0,string_js_1.isStringStrict)(nextSpanClass)?` class="${nextSpanClass}"`:""}>${next}</span>`,nextLink=!1;return current<total&&(nextLink=!0,nextItem=`\n <a\n href="${url}?page=${current+1}${nextFilters}"\n aria-label="${nextLabel}"${(0,string_js_1.isStringStrict)(nextLinkClass)?` class="${nextLinkClass}"`:""}\n >\n ${next}\n </a>\n `),output+=`<li${itemAttrs} data-pag-next="${nextLink?"link":"text"}">${nextItem}</li>`,{output:`\n <ol${listAttrs.length>0?` ${listAttrs.join(" ")}`:""}>\n ${output}\n </ol>\n `,data:data}};exports.Pagination=Pagination;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface PaginationProps {
|
|
2
|
+
total?: number;
|
|
3
|
+
display?: number;
|
|
4
|
+
current?: number;
|
|
5
|
+
filters?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
ellipsis?: string;
|
|
8
|
+
prev?: string;
|
|
9
|
+
next?: string;
|
|
10
|
+
prevLabel?: string;
|
|
11
|
+
nextLabel?: string;
|
|
12
|
+
currentLabel?: string;
|
|
13
|
+
pageLabel?: string;
|
|
14
|
+
titleTemplate?: string;
|
|
15
|
+
args?: PaginationArgs;
|
|
16
|
+
}
|
|
17
|
+
export interface PaginationArgs {
|
|
18
|
+
listClass?: string;
|
|
19
|
+
listAttr?: string;
|
|
20
|
+
itemClass?: string;
|
|
21
|
+
itemAttr?: string;
|
|
22
|
+
linkClass?: string;
|
|
23
|
+
linkAttr?: string;
|
|
24
|
+
currentClass?: string;
|
|
25
|
+
a11yClass?: string;
|
|
26
|
+
prevSpanClass?: string;
|
|
27
|
+
prevLinkClass?: string;
|
|
28
|
+
nextSpanClass?: string;
|
|
29
|
+
nextLinkClass?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface PaginationData {
|
|
32
|
+
current?: number;
|
|
33
|
+
total?: number;
|
|
34
|
+
title?: string;
|
|
35
|
+
next?: number;
|
|
36
|
+
prev?: number;
|
|
37
|
+
nextFilters?: string;
|
|
38
|
+
prevFilters?: string;
|
|
39
|
+
currentFilters?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface PaginationReturn {
|
|
42
|
+
output: string;
|
|
43
|
+
data: PaginationData;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setConfigFilter=exports.setConfig=exports.config=void 0;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};exports.config=config;const setConfig=args=>(exports.config=config={...config,...args},config);exports.setConfig=setConfig;const setConfigFilter=env=>(exports.config=config=config.filter(config,env),config);exports.setConfigFilter=setConfigFilter;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Source, GenericStrings } 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
|
+
ssl?: boolean;
|
|
19
|
+
prodUser: string;
|
|
20
|
+
prodCredential: string;
|
|
21
|
+
prodHost: string;
|
|
22
|
+
devUser: string;
|
|
23
|
+
devCredential: string;
|
|
24
|
+
devHost: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ConfigLocal {
|
|
27
|
+
dir: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ConfigAsset {
|
|
30
|
+
inputDir: string;
|
|
31
|
+
outputDir: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ConfigImage {
|
|
34
|
+
inputDir: string;
|
|
35
|
+
outputDir: string;
|
|
36
|
+
localUrl: string;
|
|
37
|
+
remoteUrl: string;
|
|
38
|
+
sizes: number[];
|
|
39
|
+
quality: number;
|
|
40
|
+
}
|
|
41
|
+
export type ConfigFilter = (config: Config, env: GenericStrings | NodeJS.Process['env']) => Config;
|
|
42
|
+
export interface Config {
|
|
43
|
+
namespace: string;
|
|
44
|
+
source: Source;
|
|
45
|
+
title: string;
|
|
46
|
+
meta: ConfigMeta;
|
|
47
|
+
partialTypes: string[];
|
|
48
|
+
wholeTypes: string[];
|
|
49
|
+
renderTypes: GenericStrings;
|
|
50
|
+
normalTypes: GenericStrings;
|
|
51
|
+
hierarchicalTypes: string[];
|
|
52
|
+
localeInSlug: Record<string, string>;
|
|
53
|
+
typeInSlug: Record<string, string | Record<string, string>>;
|
|
54
|
+
taxonomyInSlug: Record<string, string | Record<string, string>>;
|
|
55
|
+
env: ConfigEnv;
|
|
56
|
+
cms: ConfigCms;
|
|
57
|
+
local: ConfigLocal;
|
|
58
|
+
scripts: ConfigAsset;
|
|
59
|
+
styles: ConfigAsset;
|
|
60
|
+
image: ConfigImage;
|
|
61
|
+
filter: ConfigFilter;
|
|
62
|
+
}
|
|
63
|
+
export type ConfigSet = (args: Partial<Config>) => Config;
|
|
64
|
+
export type ConfigSetFilter = (env: GenericStrings | NodeJS.Process['env']) => Config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ContentfulDataParams, AllContentfulDataArgs } from './contentfulDataTypes.js';
|
|
2
|
+
import type { RenderAllData, RenderItem } from '../render/renderTypes.js';
|
|
3
|
+
declare const getContentfulData: (key: string, params?: ContentfulDataParams) => Promise<RenderItem[]>;
|
|
4
|
+
declare const getAllContentfulData: (args?: AllContentfulDataArgs) => Promise<RenderAllData | undefined>;
|
|
5
|
+
export { getContentfulData, getAllContentfulData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(mod){return mod&&mod.__esModule?mod:{default:mod}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAllContentfulData=exports.getContentfulData=void 0;const contentful_resolve_response_1=__importDefault(require("contentful-resolve-response")),ResponseError_js_1=require("../utils/ResponseError/ResponseError.js"),filter_js_1=require("../utils/filter/filter.js"),object_js_1=require("../utils/object/object.js"),string_js_1=require("../utils/string/string.js"),array_js_1=require("../utils/array/array.js"),config_js_1=require("../config/config.js"),store_js_1=require("../store/store.js"),contentfulDataNormal_js_1=require("./contentfulDataNormal.js"),getContentfulData=async(key,params={})=>{if(!(0,string_js_1.isStringStrict)(key))throw new Error("No key");if(config_js_1.config.env.cache){const cacheDataFilterArgs={key:key,type:"get"},cacheData=await(0,filter_js_1.applyFilters)("cacheData",void 0,cacheDataFilterArgs,!0);if((0,object_js_1.isObject)(cacheData))return structuredClone(cacheData)}const{space:space,devCredential:devCredential,prodCredential:prodCredential,devHost:devHost,prodHost:prodHost}=config_js_1.config.cms;let accessToken=devCredential,host=devHost;if(config_js_1.config.env.prod&&(accessToken=prodCredential,host=prodHost),!(0,string_js_1.isStringStrict)(space)||!(0,string_js_1.isStringStrict)(accessToken)||!(0,string_js_1.isStringStrict)(host))throw new Error("No credentials");let url=`https://${host}/spaces/${space}/environments/master/entries?access_token=${accessToken}`;for(const[key,value]of Object.entries(params))url+=`&${key}=${value.toString()}`;const resp=await fetch(url),data=await resp.json();if(!resp.ok)throw new ResponseError_js_1.ResponseError("Bad fetch response",resp);const resolvedData=(0,contentful_resolve_response_1.default)(data),newData=(0,contentfulDataNormal_js_1.normalizeContentfulData)(resolvedData.items);if(config_js_1.config.env.cache){const cacheDataFilterArgs={key:key,type:"set",data:data};await(0,filter_js_1.applyFilters)("cacheData",newData,cacheDataFilterArgs,!0)}return newData};exports.getContentfulData=getContentfulData;const getAllContentfulData=async(args={})=>{const{serverlessData:serverlessData,previewData:previewData}=args;let allData={navigationItem:[],navigation:[],redirect:[],content:{page:[]}};const isServerless=null!=serverlessData,isPreview=null!=previewData,contentfulDataFilterArgs={serverlessData:serverlessData,previewData:previewData};if(isServerless||isPreview){let contentType="",id="";if(isServerless){const item=(0,store_js_1.getStoreItem)("slugs")[serverlessData.path];(0,object_js_1.isObjectStrict)(item)&&(id=(0,string_js_1.isStringStrict)(item.id)?item.id:"",contentType=(0,string_js_1.isStringStrict)(item.contentType)?item.contentType:"")}if(isPreview&&(id=previewData.id,contentType=previewData.contentType),id){const key=`serverless_${id}_${contentType}`,params={"sys.id":id,include:10},data=await getContentfulData(key,params);(0,array_js_1.isArray)(data)&&(allData.content[contentType]=data)}}if(!isServerless){const partial=config_js_1.config.partialTypes;for(const contentType of partial){allData[contentType]=[];const key=`all_${contentType}`,params={content_type:contentType};let data=await getContentfulData(key,params);data=(0,filter_js_1.applyFilters)("contentfulData",data,contentfulDataFilterArgs),(0,array_js_1.isArray)(data)&&(allData[contentType]=data)}}if(!isServerless&&!isPreview){const whole=config_js_1.config.wholeTypes;for(const contentType of whole){allData.content[contentType]=[];const key=`all_${contentType}`,params={content_type:contentType,include:10};let data=await getContentfulData(key,params);data=(0,filter_js_1.applyFilters)("contentfulData",data,contentfulDataFilterArgs),(0,array_js_1.isArray)(data)&&(allData.content[contentType]=data)}}return allData=(0,filter_js_1.applyFilters)("allData",allData,{type:"contentful",serverlessData:serverlessData,previewData:previewData}),allData};exports.getAllContentfulData=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
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeContentfulData=void 0;const contentType_js_1=require("../utils/contentType/contentType.js"),array_js_1=require("../utils/array/array.js"),object_js_1=require("../utils/object/object.js"),string_js_1=require("../utils/string/string.js"),objectUtils_js_1=require("../utils/object/objectUtils.js"),number_js_1=require("../utils/number/number.js"),config_js_1=require("../config/config.js"),getTag=(type="text")=>{const tag={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",text:""}[type];return(0,string_js_1.isString)(tag)?tag:""},normalizeRichText=items=>{const newItems=[];return items.forEach((item=>{if(!(0,object_js_1.isObjectStrict)(item))return;const{nodeType:nodeType,data:data,value:value,marks:marks,content:content}=item,tag=getTag(nodeType);let contentValue,link,internalLink;if((0,string_js_1.isStringStrict)(value)&&(contentValue=value,contentValue=contentValue.replace(/\n/g,"<br>"),(0,array_js_1.isArrayStrict)(marks))){const markTags=marks.map((m=>getTag(m.type)));contentValue=`${markTags.map((m=>`<${m}>`)).join("")}${value}${markTags.map((m=>`</${m}>`)).join("")}`}if((0,string_js_1.isStringStrict)(content)&&(contentValue=content),(0,array_js_1.isArrayStrict)(content)){const contentArr=normalizeRichText(content);contentArr.length>0&&(contentValue=contentArr)}if((0,object_js_1.isObjectStrict)(data)&&(link=(0,string_js_1.isString)(data.uri)?data.uri:"",(0,object_js_1.isObjectStrict)(data.target))){const target=data.target;"entry-hyperlink"===nodeType&&(internalLink=target);const url=target.fields?.file?.url;"asset-hyperlink"===nodeType&&(0,string_js_1.isString)(url)&&(link=url)}if(!contentValue)return;const newItem={content:contentValue};return(0,string_js_1.isStringStrict)(tag)&&(newItem.tag=tag),(0,string_js_1.isStringStrict)(link)&&(newItem.link=link),(0,object_js_1.isObjectStrict)(internalLink)&&(newItem.internalLink=normalizeItem(internalLink,[],!0)),newItems.push(newItem)})),newItems},normalizeFile=(file,fields)=>{const type=(0,string_js_1.isString)(file.contentType)?file.contentType:"",format=type?type.split("/")[1]:"";return{url:(0,string_js_1.isString)(file.url)?`https:${file.url}`:"",name:(0,string_js_1.isString)(file.fileName)?file.fileName:"",alt:(0,string_js_1.isString)(fields.description)?fields.description:"",width:(0,number_js_1.isNumber)(file.details?.image?.width)?file.details.image.width:0,height:(0,number_js_1.isNumber)(file.details?.image?.height)?file.details.image.height:0,size:(0,number_js_1.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};(0,string_js_1.isString)(itemCopy.sys?.id)&&(newItem.id=itemCopy.sys.id);let type="";if((0,string_js_1.isString)(itemCopy.sys?.type)&&(type=itemCopy.sys.type),(0,string_js_1.isString)(itemCopy.sys?.contentType?.sys?.id)&&(type=itemCopy.sys.contentType.sys.id),type&&"Link"!==type&&(newItem.contentType=(0,contentType_js_1.normalizeContentType)(type),(0,string_js_1.isString)(config_js_1.config.renderTypes[type])&&(newItem.renderType=config_js_1.config.renderTypes[type])),(0,array_js_1.isArrayStrict)(itemCopy.metadata?.tags)&&(newItem.metadata={tags:itemCopy.metadata.tags.map((t=>({id:(0,string_js_1.isString)(t.sys?.id)?t.sys.id:"",name:(0,string_js_1.isString)(t.sys?.name)?t.sys.name:""})))}),(0,object_js_1.isObjectStrict)(itemCopy.fields)){const fields=itemCopy.fields,file=fields.file;if((0,object_js_1.isObjectStrict)(file))return Object.assign(normalizeFile(file,fields),newItem);(0,objectUtils_js_1.getObjectKeys)(fields).forEach((prop=>{const field=fields[prop];if("content"!==prop||!isInternalLink)if((0,object_js_1.isObjectStrict)(field))if("document"===field.nodeType){const{content:content}=field;(0,array_js_1.isArrayStrict)(content)&&(newItem[prop]=content.map((c=>(0,object_js_1.isObjectStrict)(c)?normalizeItem(c,data,isInternalLink):c)))}else newItem[prop]=normalizeItem(field,data,"internalLink"===prop);else(0,array_js_1.isArrayStrict)(field)?newItem[prop]=field.map((f=>(0,object_js_1.isObjectStrict)(f)?normalizeItem(f,data,isInternalLink):f)):newItem[prop]=field}))}if((0,string_js_1.isString)(itemCopy.nodeType)){const nodeType=itemCopy.nodeType;if("embedded-entry-block"===nodeType||"embedded-asset-block"===nodeType){const content=(0,object_js_1.isObjectStrict)(itemCopy.data?.target)?itemCopy.data.target:item;newItem=normalizeItem(content,data,isInternalLink)}else newItem.renderType="richText",newItem.tag=getTag(itemCopy.nodeType),(0,string_js_1.isString)(itemCopy.content)&&(newItem.content=itemCopy.content),(0,array_js_1.isArrayStrict)(itemCopy.content)&&(newItem.content=normalizeRichText(itemCopy.content))}return newItem},normalizeContentfulData=(data,_newData=[])=>(0,array_js_1.isArrayStrict)(data)?(data.forEach((item=>{(0,object_js_1.isObjectStrict)(item)&&_newData.push(normalizeItem(item,_newData))})),_newData):[];exports.normalizeContentfulData=normalizeContentfulData;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Generic } from '../global/globalTypes.js';
|
|
2
|
+
import type { RenderServerlessData, RenderPreviewData, RenderItem } from '../render/renderTypes.js';
|
|
3
|
+
export type ContentfulDataParams = Record<string, string | number | boolean>;
|
|
4
|
+
export interface ContentfulDataTag {
|
|
5
|
+
sys?: {
|
|
6
|
+
id?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface ContentfulDataMark {
|
|
11
|
+
type: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ContentfulDataFile {
|
|
14
|
+
url?: string;
|
|
15
|
+
contentType?: string;
|
|
16
|
+
fileName?: string;
|
|
17
|
+
details?: {
|
|
18
|
+
size?: number;
|
|
19
|
+
image?: {
|
|
20
|
+
width?: number;
|
|
21
|
+
height?: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface ContentfulDataFields extends Generic {
|
|
26
|
+
content?: ContentfulDataItem[] | ContentfulDataItem;
|
|
27
|
+
internalLink?: ContentfulDataItem;
|
|
28
|
+
file?: ContentfulDataFile;
|
|
29
|
+
description?: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ContentfulDataSys {
|
|
33
|
+
id?: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
contentType?: {
|
|
36
|
+
sys?: {
|
|
37
|
+
id?: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface ContentfulDataItem {
|
|
42
|
+
value?: string;
|
|
43
|
+
nodeType?: string;
|
|
44
|
+
marks?: ContentfulDataMark[];
|
|
45
|
+
data?: {
|
|
46
|
+
uri?: string;
|
|
47
|
+
target?: ContentfulDataItem;
|
|
48
|
+
};
|
|
49
|
+
content?: ContentfulDataItem[] | string;
|
|
50
|
+
metadata?: {
|
|
51
|
+
tags?: ContentfulDataTag[];
|
|
52
|
+
};
|
|
53
|
+
sys?: ContentfulDataSys;
|
|
54
|
+
fields?: ContentfulDataFields;
|
|
55
|
+
}
|
|
56
|
+
export interface ContentfulData extends Generic {
|
|
57
|
+
items?: ContentfulDataItem[];
|
|
58
|
+
errors?: Generic[];
|
|
59
|
+
}
|
|
60
|
+
export interface ContentfulDataReturn extends Generic {
|
|
61
|
+
items?: RenderItem[];
|
|
62
|
+
errors?: Generic[];
|
|
63
|
+
}
|
|
64
|
+
export interface AllContentfulDataArgs {
|
|
65
|
+
serverlessData?: RenderServerlessData;
|
|
66
|
+
previewData?: RenderPreviewData;
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1,32 @@
|
|
|
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 InternalLinkBase {
|
|
11
|
+
id?: string;
|
|
12
|
+
contentType?: string;
|
|
13
|
+
slug?: string;
|
|
14
|
+
link?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
taxonomy?: Taxonomy;
|
|
17
|
+
}
|
|
18
|
+
export interface InternalLink extends InternalLinkBase, Partial<Taxonomy> {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface ParentArgs<T = Generic> {
|
|
22
|
+
renderType: string;
|
|
23
|
+
args: T;
|
|
24
|
+
}
|
|
25
|
+
export interface HtmlString {
|
|
26
|
+
html: string;
|
|
27
|
+
}
|
|
28
|
+
export type Source = 'cms' | 'local' | (string & Record<never, never>);
|
|
29
|
+
export type Generic = Record<string, unknown>;
|
|
30
|
+
export type GenericFunction<T extends (...args: any[]) => any = (...args: any[]) => any> = T;
|
|
31
|
+
export type GenericStrings = Record<string, string>;
|
|
32
|
+
export type GenericNumbers = Record<string, number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Column=void 0;const filter_js_1=require("../../utils/filter/filter.js"),string_js_1=require("../../utils/string/string.js"),object_js_1=require("../../utils/object/object.js"),Column=props=>{if(!(0,object_js_1.isObjectStrict)(props))return[];if(props=(0,filter_js_1.applyFilters)("columnProps",props),!(0,object_js_1.isObjectStrict)(props))return[];const{args:args}=props,{tag:tag="div",classes:classes,style:style,attr:attr}=(0,object_js_1.isObjectStrict)(args)?args:{};if(!(0,string_js_1.isStringStrict)(tag))return[];let styles="";(0,string_js_1.isStringStrict)(style)&&(styles=` style="${style}"`);let attrs="";return(0,string_js_1.isStringStrict)(classes)&&(attrs+=` class="${classes}"`),(0,string_js_1.isStringStrict)(attr)&&(attrs+=` ${attr}`),[`<${tag}${attrs}${styles}>`,`</${tag}>`]};exports.Column=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 extends Generic {
|
|
4
|
+
tag?: string;
|
|
5
|
+
width?: string | number;
|
|
6
|
+
widthSmall?: string | number;
|
|
7
|
+
widthMedium?: string | number;
|
|
8
|
+
widthLarge?: string | number;
|
|
9
|
+
classes?: string;
|
|
10
|
+
style?: string;
|
|
11
|
+
attr?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ColumnProps<T = ColumnArgs, R = RenderItem> extends RenderFunctionArgs<T, R> {
|
|
14
|
+
args: ColumnArgs & T;
|
|
15
|
+
}
|
|
16
|
+
export type ColumnPropsFilter<T = ColumnArgs, R = RenderItem> = (props: ColumnProps<T, R>) => ColumnProps<T, R>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Container=void 0;const filter_js_1=require("../../utils/filter/filter.js"),object_js_1=require("../../utils/object/object.js"),string_js_1=require("../../utils/string/string.js"),Container=props=>{if(!(0,object_js_1.isObjectStrict)(props))return[];if(props=(0,filter_js_1.applyFilters)("containerProps",props),!(0,object_js_1.isObjectStrict)(props))return[];const{args:args}=props,{tag:tag="div",layoutClasses:layoutClasses,classes:classes,style:style,attr:attr,nest:nest=!1}=(0,object_js_1.isObjectStrict)(args)?args:{};if(!(0,string_js_1.isStringStrict)(tag))return[];const isSemanticParent=["ul","ol","dl","figure"].includes(tag),hasLayoutClasses=(0,string_js_1.isStringStrict)(layoutClasses),hasClasses=(0,string_js_1.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>0&&attrs.push(`class="${outerClassesArr.join(" ")}"`),innerClassesArr.length>0&&innerAttrs.push(`class="${innerClassesArr.join(" ")}"`);const att=isNestedSemanticParent?innerAttrs:attrs;(0,string_js_1.isStringStrict)(attr)&&att.push(attr),(0,string_js_1.isStringStrict)(style)&&att.push(`style="${style}"`);let outerTag=tag,innerTag="";isNested&&(outerTag=isSemanticParent?"div":tag,innerTag=isSemanticParent?tag:"div");let start=`<${outerTag}${attrs.length>0?` ${attrs.join(" ")}`:""}>`,end=`</${outerTag}>`;return innerTag&&(start=`${start}<${innerTag}${innerAttrs.length>0?` ${innerAttrs.join(" ")}`:""}>`,end=`</${innerTag}>${end}`),[start,end]};exports.Container=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 extends Generic {
|
|
4
|
+
tag?: string;
|
|
5
|
+
maxWidth?: string | number;
|
|
6
|
+
layoutClasses?: string;
|
|
7
|
+
classes?: string;
|
|
8
|
+
style?: string;
|
|
9
|
+
attr?: string;
|
|
10
|
+
nest?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ContainerProps<T = ContainerArgs, R = RenderItem> extends RenderFunctionArgs<T, R> {
|
|
13
|
+
args: ContainerArgs & T;
|
|
14
|
+
}
|
|
15
|
+
export type ContainerPropsFilter<T = ContainerArgs, R = RenderItem> = (props: ContainerProps<T, R>) => ContainerProps<T, R>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -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
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAllLocalData=exports.getLocalData=void 0;const promises_1=require("node:fs/promises"),node_path_1=require("node:path"),object_js_1=require("../utils/object/object.js"),string_js_1=require("../utils/string/string.js"),filter_js_1=require("../utils/filter/filter.js"),json_js_1=require("../utils/json/json.js"),config_js_1=require("../config/config.js"),localDataNormal_js_1=require("./localDataNormal.js"),getLocalData=async args=>{if(!(0,object_js_1.isObjectStrict)(args))throw new Error("No args");const{key:key,refProps:refProps,imageProps:imageProps,unsetProps:unsetProps}=args;if(!(0,string_js_1.isStringStrict)(key))throw new Error("No key");if(config_js_1.config.env.cache){const cacheDataFilterArgs={key:key,type:"get"},cacheData=await(0,filter_js_1.applyFilters)("cacheData",void 0,cacheDataFilterArgs,!0),cacheObj=cacheData?.data;if((0,object_js_1.isObject)(cacheObj))return structuredClone(cacheObj)}const dir=config_js_1.config.local.dir,data={};let hasData=!1;const files=await(0,promises_1.readdir)((0,node_path_1.resolve)(dir));for(const file of files){const fileExt=(0,node_path_1.extname)(file),fileName=(0,node_path_1.basename)(file,fileExt);if(".json"!==fileExt)continue;const fileContents=await(0,promises_1.readFile)((0,node_path_1.resolve)(dir,file),{encoding:"utf8"}),fileJson=(0,json_js_1.getJson)(fileContents);fileJson&&(data[fileName]=fileJson,hasData=!0)}if(!hasData)throw new Error("No data");const newData=(0,localDataNormal_js_1.normalizeLocalData)(data,refProps,imageProps,unsetProps);if(config_js_1.config.env.cache){const cacheDataFilterArgs={key:key,type:"set",data:data};await(0,filter_js_1.applyFilters)("cacheData",{data:newData},cacheDataFilterArgs,!0)}return newData};exports.getLocalData=getLocalData;const 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(!(0,string_js_1.isStringStrict)(contentType))continue;const isPartial=config_js_1.config.partialTypes.includes(contentType),isWhole=config_js_1.config.wholeTypes.includes(contentType);if(!isPartial&&!isWhole)continue;const val=(0,filter_js_1.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=(0,filter_js_1.applyFilters)("allData",allData,{type:"local"}),allData};exports.getAllLocalData=getAllLocalData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeLocalData=void 0;const object_js_1=require("../utils/object/object.js"),array_js_1=require("../utils/array/array.js"),string_js_1=require("../utils/string/string.js"),store_js_1=require("../store/store.js"),normalizeLocalRefs=(data,refData,imageData,refProps=["internalLink","term","taxonomy"],imageProps=["image"],unsetProps=["content"],contentType)=>{const newData=(0,array_js_1.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=(0,string_js_1.isStringStrict)(value),isArr=(0,array_js_1.isArrayStrict)(value);let newValue=value;if(isTemplate&&"content"===key&&isArr&&(newValue=value.map((item=>{if(!(0,string_js_1.isStringStrict)(item))return item;const ref=refData[item];return(0,object_js_1.isObjectStrict)(ref)?{...ref}:void 0}))),(isNavigation&&"items"===key||isNavigationItem&&"children"===key)&&isArr&&(newValue=value.map((id=>(0,string_js_1.isStringStrict)(id)?{id:id,title:refData[id]?.title}:null)).filter(Boolean)),isImage&&isStr&&(newValue=imageData[value]?{...imageData[value]}:null),isRef&&isStr){const ref=refData[value];(0,object_js_1.isObjectStrict)(ref)&&(newValue={...ref},unsetProps.forEach((prop=>{newValue[prop]&&(newValue[prop]=void 0)})))}isRef&&(0,array_js_1.isArrayStrict)(value)&&(newValue=value.map((refKey=>{if(!(0,string_js_1.isStringStrict)(refKey))return null;const ref=refData[refKey];if(!(0,object_js_1.isObjectStrict)(ref))return null;const newRef={...ref};return unsetProps.forEach((prop=>{newRef[prop]&&(newRef[prop]=void 0)})),newRef})).filter(Boolean)),(0,object_js_1.isObject)(newValue)&&(newValue=normalizeLocalRefs(newValue,refData,imageData,refProps,imageProps,unsetProps)),newData[key]=newValue}return newData},normalizeLocalData=(data,refProps,imageProps,unsetProps)=>{const newData={},imageMeta=(0,store_js_1.getStoreItem)("imageMeta"),refData={};for(const[key,item]of Object.entries(data))(0,object_js_1.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};exports.normalizeLocalData=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
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Form=void 0;const uuid_1=require("uuid"),filter_js_1=require("../../utils/filter/filter.js"),string_js_1=require("../../utils/string/string.js"),object_js_1=require("../../utils/object/object.js"),config_js_1=require("../../config/config.js"),Form=props=>{if(!(0,object_js_1.isObjectStrict)(props))return[];if(props=(0,filter_js_1.applyFilters)("formProps",props),!(0,object_js_1.isObjectStrict)(props))return[];const{args:args}=props,{id:id,formTag:formTag="form",formClasses:formClasses,formAttr:formAttr,fieldsClasses:fieldsClasses,fieldsAttr:fieldsAttr,submitFieldClasses:submitFieldClasses,submitFieldAttr:submitFieldAttr,submitLabel:submitLabel="Submit",submitClasses:submitClasses,submitAttr:submitAttr,honeypot:honeypot=!1,honeypotFieldClasses:honeypotFieldClasses,honeypotFieldAttr:honeypotFieldAttr,honeypotLabelClasses:honeypotLabelClasses,honeypotLabel:honeypotLabel="Website",honeypotClasses:honeypotClasses,honeypotAttr:honeypotAttr}=(0,object_js_1.isObjectStrict)(args)?args:{};if(!(0,string_js_1.isStringStrict)(id)||!(0,string_js_1.isStringStrict)(formTag)||!(0,string_js_1.isStringStrict)(submitLabel))return[];const formAttrs=((0,string_js_1.isStringStrict)(formClasses)?` class="${formClasses}"`:"")+((0,string_js_1.isStringStrict)(formAttr)?` ${formAttr}`:""),fieldsTag="form"===formTag?"div":"form",fieldsAttrs=((0,string_js_1.isStringStrict)(fieldsClasses)?` class="${fieldsClasses}"`:"")+((0,string_js_1.isStringStrict)(fieldsAttr)?` ${fieldsAttr}`:"");let honeypotOutput="";if(honeypot){const honeypotId=(0,uuid_1.v4)(),honeypotName=`${config_js_1.config.namespace}_asi`,honeypotFieldAttrs=((0,string_js_1.isStringStrict)(honeypotFieldClasses)?` class="${honeypotFieldClasses}"`:"")+((0,string_js_1.isStringStrict)(honeypotFieldAttr)?` ${honeypotFieldAttr}`:""),honeypotAttrs=((0,string_js_1.isStringStrict)(honeypotClasses)?` class="${honeypotClasses}"`:"")+((0,string_js_1.isStringStrict)(honeypotAttr)?` ${honeypotAttr}`:"");honeypotOutput=`\n <div${honeypotFieldAttrs}>\n <label for="${honeypotId}"${(0,string_js_1.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}>`,`${honeypotOutput}\n <div${((0,string_js_1.isStringStrict)(submitFieldClasses)?` class="${submitFieldClasses}"`:"")+((0,string_js_1.isStringStrict)(submitFieldAttr)?` ${submitFieldAttr}`:"")}>\n <button type="submit"${((0,string_js_1.isStringStrict)(submitClasses)?` class="${submitClasses}"`:"")+((0,string_js_1.isStringStrict)(submitAttr)?` ${submitAttr}`:"")}>\n ${submitLabel}\n </button>\n </div>\n </${fieldsTag}>\n </${formTag}>\n `]};exports.Form=Form;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FormField=void 0;const uuid_1=require("uuid"),filter_js_1=require("../../utils/filter/filter.js"),string_js_1=require("../../utils/string/string.js"),object_js_1=require("../../utils/object/object.js"),FormField=props=>{if(!(0,object_js_1.isObjectStrict)(props))return[];if(props=(0,filter_js_1.applyFilters)("formFieldProps",props),!(0,object_js_1.isObjectStrict)(props))return[];const{args:args}=props,{type:type="text",name:name,label:label,hint:hint,value:value,required:required=!1,attributes:attributes,emptyError:emptyError,invalidError:invalidError,fieldClasses:fieldClasses,fieldAttr:fieldAttr,fieldsetClasses:fieldsetClasses,fieldsetAttr:fieldsetAttr,labelClasses:labelClasses,classes:classes,radioIcon:radioIcon,checkboxIcon:checkboxIcon}=(0,object_js_1.isObjectStrict)(args)?args:{},isHidden="hidden"===type;if(!(0,string_js_1.isStringStrict)(label)&&!isHidden)return[];let isFieldset="fieldset"===type;if(!isFieldset&&!(0,string_js_1.isStringStrict)(name))return[];const isOption="checkbox"===type||"radio"===type,isSelect="select"===type;("checkbox-group"===type||"radio-group"===type)&&(isFieldset=!0);const isTextarea="textarea"===type,hasValue=(0,string_js_1.isStringStrict)(value),id=(0,uuid_1.v4)();let optionIcon="",selectIcon="";"radio"===type&&(0,string_js_1.isStringStrict)(radioIcon)&&(optionIcon=radioIcon),"checkbox"===type&&(0,string_js_1.isStringStrict)(checkboxIcon)&&(optionIcon=checkboxIcon),"select"===type&&(0,string_js_1.isStringStrict)(args.selectIcon)&&(selectIcon=args.selectIcon);const requiredIcon=required&&(0,string_js_1.isStringStrict)(args.requiredIcon)?args.requiredIcon:"",fieldAttrs=["data-form-field"],fieldsetAttrs=[],attrs=["data-form-input"];if((0,string_js_1.isStringStrict)(attributes)){const attrsArr=attributes.split("\n");for(const attr of attrsArr){const[attrName,attrValue]=attr.split(" : ");(0,string_js_1.isStringStrict)(attrName)&&(0,string_js_1.isStringStrict)(attrValue)&&attrs.push(`${attrName}="${attrValue}"`)}}isTextarea||isSelect||!hasValue||attrs.push(`value="${value}"`),(0,string_js_1.isStringStrict)(classes)&&attrs.push(`class="${classes}"`),(0,string_js_1.isStringStrict)(fieldClasses)&&fieldAttrs.push(`class="${fieldClasses}"`),(0,string_js_1.isStringStrict)(fieldsetClasses)&&fieldsetAttrs.push(`class="${fieldsetClasses}"`),(0,string_js_1.isStringStrict)(fieldAttr)&&fieldAttrs.push(fieldAttr),(0,string_js_1.isStringStrict)(fieldsetAttr)&&fieldsetAttrs.push(fieldsetAttr),(0,string_js_1.isStringStrict)(emptyError)&&!isHidden&&(isFieldset?fieldsetAttrs:attrs).push(`data-form-empty="${emptyError}"`),(0,string_js_1.isStringStrict)(invalidError)&&!isHidden&&(isFieldset?fieldsetAttrs:attrs).push(`data-form-invalid="${invalidError}"`),required&&!isHidden&&(isFieldset?fieldsetAttrs:attrs).push(isFieldset?"data-form-required":"required");const fieldAtts=` ${fieldAttrs.join(" ")}`,fieldsetAtts=fieldsetAttrs.length>0?` ${fieldsetAttrs.join(" ")}`:"",atts=` ${attrs.join(" ")}`;let hintOutput="";(0,string_js_1.isStringStrict)(hint)&&(hintOutput=`<small data-form-hint>${hint}</small>`);let labelBefore="",labelAfter="";const labelClass=(0,string_js_1.isStringStrict)(labelClasses)?` class="${labelClasses}"`:"";isFieldset?labelBefore=`\n <legend id="${(0,uuid_1.v4)()}"${labelClass}>\n <span data-form-legend>\n <span data-form-legend-text>${label}</span>\n ${requiredIcon}\n </span>\n ${hintOutput}\n </legend>\n `:isOption?labelAfter=`\n <label for="${id}"${labelClass}>\n <span data-form-option>\n ${optionIcon}\n <span data-form-label>\n <span data-form-label-text>${label}</span>\n ${requiredIcon}\n </span>\n </span>\n ${hintOutput}\n </label>\n `:labelBefore=`\n <label for="${id}"${labelClass}>\n <span data-form-label>\n <span data-form-label-text>${label}</span>\n ${requiredIcon}\n </span>\n ${hintOutput}\n </label>\n `;let beforeOutput="",afterOutput="";switch(type){case"text":case"email":case"checkbox":case"radio":case"number":case"password":case"tel":case"url":case"hidden":beforeOutput=`<input type="${type}" name="${name}" id="${id}"${atts}>`;break;case"textarea":beforeOutput=`<textarea name="${name}" id="${id}"${atts}>${hasValue?value:""}</textarea>`;break;case"select":beforeOutput=`\n <div data-form-select>\n <select name="${name}" id="${id}"${atts}>`,afterOutput=`\n </select>\n ${selectIcon}\n </div>`}return isHidden?[beforeOutput]:[`\n <div${fieldAtts}>\n ${isFieldset?`<fieldset${fieldsetAtts}>`:""}\n ${labelBefore}\n ${isFieldset?"<div data-form-group>":""}\n ${beforeOutput}`,`${afterOutput}\n ${labelAfter}\n ${isFieldset?"</div></fieldset>":""}\n </div>\n `]};exports.FormField=FormField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FormOption=void 0;const uuid_1=require("uuid"),filter_js_1=require("../../utils/filter/filter.js"),string_js_1=require("../../utils/string/string.js"),object_js_1=require("../../utils/object/object.js"),array_js_1=require("../../utils/array/array.js"),FormOption=props=>{if(!(0,object_js_1.isObjectStrict)(props))return"";if(props=(0,filter_js_1.applyFilters)("formOptionProps",props),!(0,object_js_1.isObjectStrict)(props))return"";const{args:args,parents:parents}=props,{label:label,value:value="",name:name,hint:hint,selected:selected,radioIcon:radioIcon,checkboxIcon:checkboxIcon,optionClasses:optionClasses,labelClasses:labelClasses,classes:classes}=(0,object_js_1.isObjectStrict)(args)?args:{};if(!(0,string_js_1.isStringStrict)(label))return"";if(!(0,array_js_1.isArrayStrict)(parents))return"";const fieldParent=parents[0];if(!(0,object_js_1.isObjectStrict)(fieldParent))return"";const{renderType:renderType,args:fieldArgs}=fieldParent;if("formField"!==renderType)return"";const{name:fieldName,type:fieldType}=fieldArgs,isRadioGroup="radio-group"===fieldType,isCheckboxGroup="checkbox-group"===fieldType,isSelect="select"===fieldType;if(!isRadioGroup&&!isCheckboxGroup&&!isSelect)return"";if(isSelect)return`<option value="${value}"${selected?" selected":""}>${label}</option>`;const inputName=name||fieldName;if(!(0,string_js_1.isStringStrict)(inputName))return"";const id=(0,uuid_1.v4)();let optionIcon="";isRadioGroup&&(0,string_js_1.isStringStrict)(radioIcon)&&(optionIcon=radioIcon),isCheckboxGroup&&(0,string_js_1.isStringStrict)(checkboxIcon)&&(optionIcon=checkboxIcon);let hintOutput="";return(0,string_js_1.isStringStrict)(hint)&&(hintOutput=`<small data-form-hint>${hint}</small>`),`\n <div${(0,string_js_1.isStringStrict)(optionClasses)?` class="${optionClasses}"`:""}>\n <input\n type="${isRadioGroup?"radio":"checkbox"}"\n value="${value}"\n name="${inputName}"\n id="${id}"\n ${(0,string_js_1.isStringStrict)(classes)?` class="${classes}"`:""}\n data-form-input\n ${selected?" checked":""}\n >\n <label for="${id}"${(0,string_js_1.isStringStrict)(labelClasses)?` class="${labelClasses}"`:""}>\n <span data-form-option>\n ${optionIcon}\n <span data-form-label>\n <span data-form-label-text>${label}</span>\n ${hintOutput}\n </span>\n </span>\n </label>\n </div>\n `};exports.FormOption=FormOption;
|