@griddo/core 1.74.37 → 1.75.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.
Files changed (96) hide show
  1. package/README.md +60 -66
  2. package/dist/assets/svg/Delete.d.ts +3 -0
  3. package/dist/assets/svg/Duplicate.d.ts +3 -0
  4. package/dist/components/CloudinaryBackgroundImage/index.d.ts +23 -0
  5. package/dist/components/CloudinaryImage/index.d.ts +30 -0
  6. package/dist/components/Component/ComponentWrapper/index.d.ts +16 -0
  7. package/dist/components/Component/index.d.ts +27 -0
  8. package/dist/components/GriddoBackgroundImage/index.d.ts +7 -0
  9. package/dist/components/GriddoImage/index.d.ts +57 -0
  10. package/dist/components/GriddoLink/index.d.ts +59 -0
  11. package/dist/components/GriddoLink/utils.d.ts +9 -0
  12. package/dist/components/LdJson/index.d.ts +14 -0
  13. package/dist/components/Link/index.d.ts +15 -0
  14. package/dist/components/ModulePreview/index.d.ts +15 -0
  15. package/dist/components/Page/index.d.ts +16 -0
  16. package/dist/components/Preview/index.d.ts +11 -0
  17. package/dist/components/index.d.ts +12 -0
  18. package/dist/constants/cloudinary.d.ts +17 -0
  19. package/dist/contexts/I18n/index.d.ts +24 -0
  20. package/dist/contexts/Navigation/index.d.ts +13 -0
  21. package/dist/contexts/Page/index.d.ts +15 -0
  22. package/dist/contexts/Site/index.d.ts +27 -0
  23. package/dist/contexts/index.d.ts +4 -0
  24. package/dist/functions/create-schemas/index.d.ts +18 -0
  25. package/dist/functions/image-utils.d.ts +43 -0
  26. package/dist/functions/index.d.ts +7 -0
  27. package/dist/functions/utils.d.ts +74 -0
  28. package/dist/hooks/index.d.ts +18 -0
  29. package/dist/hooks/themes/types.d.ts +20 -0
  30. package/dist/hooks/themes/useGlobalTheme.d.ts +6 -0
  31. package/dist/hooks/themes/useTheme.d.ts +8 -0
  32. package/dist/hooks/themes/useThemeColors.d.ts +8 -0
  33. package/dist/hooks/themes/useThemeFont.d.ts +8 -0
  34. package/dist/hooks/themes/useThemePrimitives.d.ts +8 -0
  35. package/dist/hooks/themes/utils.d.ts +61 -0
  36. package/dist/hooks/useContentType.d.ts +11 -0
  37. package/dist/hooks/useDataFilters.d.ts +35 -0
  38. package/dist/hooks/useGriddoImage.d.ts +49 -0
  39. package/dist/hooks/useI18n.d.ts +38 -0
  40. package/dist/hooks/useImage.d.ts +44 -0
  41. package/dist/hooks/useLink.d.ts +8 -0
  42. package/dist/hooks/useList.d.ts +36 -0
  43. package/dist/hooks/useNavigation.d.ts +5 -0
  44. package/dist/hooks/usePage.d.ts +11 -0
  45. package/dist/hooks/useReferenceFieldData.d.ts +11 -0
  46. package/dist/hooks/useSite.d.ts +12 -0
  47. package/dist/hooks/useSitemap.d.ts +7 -0
  48. package/dist/index.d.ts +24 -6
  49. package/dist/index.js +1 -1
  50. package/dist/types/constants/locales.d.ts +2 -0
  51. package/dist/types/constants/timezone.d.ts +2 -0
  52. package/dist/types/constants/utilities.d.ts +1 -0
  53. package/dist/types/core.d.ts +263 -0
  54. package/dist/types/fields.d.ts +191 -0
  55. package/dist/types/global.d.ts +33 -0
  56. package/dist/{src/types → types}/schema-functions/fields/base.d.ts +33 -43
  57. package/dist/{src/types/schema-functions/fields/page-data-fields.d.ts → types/schema-functions/fields/page-content-type-fields.d.ts} +4 -4
  58. package/dist/{src/types → types}/schema-functions/fields/props.d.ts +11 -26
  59. package/dist/{src/types/schema-functions/fields/pure-data-fields.d.ts → types/schema-functions/fields/simple-content-type-fields.d.ts} +4 -4
  60. package/dist/{src/types → types}/schema-functions/fields/ui-fields.d.ts +6 -6
  61. package/dist/types/schema-functions/schemas/Categories.d.ts +10 -0
  62. package/dist/types/schema-functions/schemas/ContentType.d.ts +4 -0
  63. package/dist/types/schema-functions/schemas/DamDefaults.d.ts +13 -0
  64. package/dist/{src/types/schema-functions/schemas/DataPackSchema.d.ts → types/schema-functions/schemas/DataPack.d.ts} +3 -4
  65. package/dist/types/schema-functions/schemas/DataPackCategory.d.ts +4 -0
  66. package/dist/{src/types/schema-functions/schemas/HeaderFooterSchema.d.ts → types/schema-functions/schemas/HeaderFooter.d.ts} +15 -16
  67. package/dist/types/schema-functions/schemas/Languages.d.ts +9 -0
  68. package/dist/{src/types/schema-functions/schemas/MenuSchema.d.ts → types/schema-functions/schemas/Menu.d.ts} +2 -2
  69. package/dist/types/schema-functions/schemas/ModuleCategories.d.ts +9 -0
  70. package/dist/types/schema-functions/schemas/PageContentType.d.ts +19 -0
  71. package/dist/types/schema-functions/schemas/SimpleContentType.d.ts +15 -0
  72. package/dist/types/schema-functions/schemas/Themes.d.ts +9 -0
  73. package/dist/types/schema-functions/schemas/Translations.d.ts +2 -0
  74. package/dist/types/schema-functions/schemas/UI.d.ts +49 -0
  75. package/dist/{src/types → types}/schema-functions/schemas/base.d.ts +15 -27
  76. package/dist/types/schema-functions/schemas/index.d.ts +12 -0
  77. package/dist/{src/types → types}/schema-functions/schemas/props.d.ts +6 -7
  78. package/dist/{src/types → types}/schema.d.ts +0 -0
  79. package/dist/types/theme.d.ts +51 -0
  80. package/package.json +74 -75
  81. package/dist/src/functions/create-schemas/index.d.ts +0 -69
  82. package/dist/src/functions/create-schemas/utils.d.ts +0 -33
  83. package/dist/src/types/core.d.ts +0 -419
  84. package/dist/src/types/fields.d.ts +0 -7
  85. package/dist/src/types/schema-functions/schemas/CategoriesSchema.d.ts +0 -13
  86. package/dist/src/types/schema-functions/schemas/DamDefaultsSchema.d.ts +0 -11
  87. package/dist/src/types/schema-functions/schemas/DataPackCategoriesSchema.d.ts +0 -4
  88. package/dist/src/types/schema-functions/schemas/LanguagesSchema.d.ts +0 -8
  89. package/dist/src/types/schema-functions/schemas/ModuleCategoriesSchema.d.ts +0 -6
  90. package/dist/src/types/schema-functions/schemas/PageDataSchema.d.ts +0 -20
  91. package/dist/src/types/schema-functions/schemas/PureDataSchema.d.ts +0 -14
  92. package/dist/src/types/schema-functions/schemas/ThemesSchema.d.ts +0 -11
  93. package/dist/src/types/schema-functions/schemas/TranslationsSchema.d.ts +0 -3
  94. package/dist/src/types/schema-functions/schemas/UISchema.d.ts +0 -47
  95. package/dist/src/types/schema-functions/schemas/index.d.ts +0 -14
  96. package/dist/src/types/theme.d.ts +0 -57
@@ -0,0 +1,18 @@
1
+ import type { CategoryContentType, Component, DamDefaults, DataPack, DataPackCategory, Footer, Header, Languages, Menu, Module, ModuleCategories, PageContentType, SimpleContentType, Template, Themes, Translations } from "../../types/schema-functions/schemas";
2
+ declare const createComponentSchema: (schema: Component) => Component;
3
+ declare const createSimpleContentTypeSchema: (schema: SimpleContentType) => SimpleContentType;
4
+ declare const createPageContentTypeSchema: (schema: PageContentType) => PageContentType;
5
+ declare const createCategoryContentTypeSchema: (schema: CategoryContentType) => CategoryContentType;
6
+ declare const createDamDefaultsSchema: (schema: DamDefaults) => DamDefaults;
7
+ declare const createDataPackCategorySchema: (schema: DataPackCategory) => DataPackCategory;
8
+ declare const createDataPackSchema: (schema: DataPack) => DataPack;
9
+ declare const createFooterSchema: (schema: Footer) => Footer;
10
+ declare const createHeaderSchema: (schema: Header) => Header;
11
+ declare const createLanguagesSchema: (schema: Languages) => Languages;
12
+ declare const createMenuSchema: (schema: Menu) => Menu;
13
+ declare const createModuleCategoriesSchema: (schema: ModuleCategories) => ModuleCategories;
14
+ declare const createModuleSchema: (schema: Module) => Module;
15
+ declare const createTemplateSchema: (schema: Template) => Template;
16
+ declare const createThemesSchema: (schema: Themes) => Themes;
17
+ declare const createTranslationsSchema: (schema: Translations) => Partial<Record<"br" | "hr" | "li" | "th" | "tr" | "or" | "Cy_az_AZ" | "Cy_sr_SP" | "Cy_uz_UZ" | "Lt_az_AZ" | "Lt_sr_SP" | "Lt_uz_UZ" | "aa" | "ab" | "ae" | "af" | "af_ZA" | "ak" | "am" | "an" | "ar" | "ar_AE" | "ar_BH" | "ar_DZ" | "ar_EG" | "ar_IQ" | "ar_JO" | "ar_KW" | "ar_LB" | "ar_LY" | "ar_MA" | "ar_OM" | "ar_QA" | "ar_SA" | "ar_SY" | "ar_TN" | "ar_YE" | "as" | "av" | "ay" | "az" | "ba" | "be" | "be_BY" | "bg" | "bg_BG" | "bh" | "bi" | "bm" | "bn" | "bo" | "bs" | "ca" | "ca_ES" | "ce" | "ch" | "co" | "cr" | "cs" | "cs_CZ" | "cu" | "cv" | "cy" | "da" | "da_DK" | "de" | "de_AT" | "de_CH" | "de_DE" | "de_LI" | "de_LU" | "div_MV" | "dv" | "dz" | "ee" | "el" | "el_GR" | "en" | "en_AU" | "en_BZ" | "en_CA" | "en_CB" | "en_GB" | "en_IE" | "en_JM" | "en_NZ" | "en_PH" | "en_TT" | "en_US" | "en_ZA" | "en_ZW" | "eo" | "es" | "es_AR" | "es_BO" | "es_CL" | "es_CO" | "es_CR" | "es_DO" | "es_EC" | "es_ES" | "es_GT" | "es_HN" | "es_MX" | "es_NI" | "es_PA" | "es_PE" | "es_PR" | "es_PY" | "es_SV" | "es_UY" | "es_VE" | "et" | "et_EE" | "eu" | "eu_ES" | "fa" | "fa_IR" | "ff" | "fi" | "fi_FI" | "fj" | "fo" | "fo_FO" | "fr" | "fr_BE" | "fr_CA" | "fr_CH" | "fr_FR" | "fr_LU" | "fr_MC" | "fy" | "ga" | "gd" | "gl" | "gl_ES" | "gn" | "gu" | "gu_IN" | "gv" | "ha" | "he" | "he_IL" | "hi" | "hi_IN" | "ho" | "hr_HR" | "ht" | "hu" | "hu_HU" | "hy" | "hy_AM" | "hz" | "ia" | "id" | "id_ID" | "ie" | "ig" | "ii" | "ik" | "io" | "is" | "is_IS" | "it" | "it_CH" | "it_IT" | "iu" | "ja" | "ja_JP" | "jv" | "ka" | "ka_GE" | "kg" | "ki" | "kj" | "kk" | "kk_KZ" | "kl" | "km" | "kn" | "kn_IN" | "ko" | "ko_KR" | "kr" | "ks" | "ku" | "kv" | "kw" | "ky" | "ky_KZ" | "la" | "lb" | "lg" | "ln" | "lo" | "lt" | "lt_LT" | "lu" | "lv" | "lv_LV" | "mg" | "mh" | "mi" | "mk" | "mk_MK" | "ml" | "mn" | "mn_MN" | "mr" | "mr_IN" | "ms" | "ms_BN" | "ms_MY" | "mt" | "my" | "na" | "nb" | "nb_NO" | "nd" | "ne" | "ng" | "nl" | "nl_BE" | "nl_NL" | "nn" | "nn_NO" | "no" | "nr" | "nv" | "ny" | "oc" | "oj" | "om" | "os" | "pa" | "pa_IN" | "pi" | "pl" | "pl_PL" | "ps" | "pt" | "pt_BR" | "pt_PT" | "qu" | "rm" | "rn" | "ro" | "ro_RO" | "ru" | "ru_RU" | "rw" | "sa" | "sa_IN" | "sc" | "sd" | "se" | "sg" | "si" | "sk" | "sk_SK" | "sl" | "sl_SI" | "sm" | "sn" | "so" | "sq" | "sq_AL" | "sr" | "ss" | "st" | "su" | "sv" | "sv_FI" | "sv_SE" | "sw" | "sw_KE" | "ta" | "ta_IN" | "te" | "te_IN" | "tg" | "th_TH" | "ti" | "tk" | "tl" | "tn" | "to" | "tr_TR" | "ts" | "tt" | "tt_RU" | "tw" | "ty" | "ug" | "uk" | "uk_UA" | "ur" | "ur_PK" | "uz" | "ve" | "vi" | "vi_VN" | "vo" | "wa" | "wo" | "xh" | "yi" | "yo" | "za" | "zh" | "zh_CHS" | "zh_CHT" | "zh_CN" | "zh_HK" | "zh_MO" | "zh_SG" | "zh_TW" | "zu", Record<string, unknown>>>;
18
+ export { createCategoryContentTypeSchema, createComponentSchema, createDamDefaultsSchema, createDataPackCategorySchema, createDataPackSchema, createFooterSchema, createHeaderSchema, createLanguagesSchema, createMenuSchema, createModuleCategoriesSchema, createModuleSchema, createPageContentTypeSchema, createSimpleContentTypeSchema, createTemplateSchema, createThemesSchema, createTranslationsSchema, };
@@ -0,0 +1,43 @@
1
+ import { ImageConfig } from "../hooks/useGriddoImage";
2
+ import { CloudinaryResponsiveImageProps } from "../hooks/useImage";
3
+ import { ResponsiveImageProps } from "../types/core";
4
+ declare function rearrangeResponsiveArray(arr: Array<ResponsiveImageProps>): ResponsiveImageProps[];
5
+ declare function cloudinaryRearrangeResponsiveArray(arr?: Array<CloudinaryResponsiveImageProps>): CloudinaryResponsiveImageProps[];
6
+ declare function fillIntArray(n: number, from?: number): number[];
7
+ declare function removeUnit(unit?: string): string | undefined;
8
+ /**
9
+ * mergeObject
10
+ * Sobreescribe el objeto2 al objeto1 siempre que las propiedades sean truthy
11
+ * @param {object} object1 Un objeto
12
+ * @param {object} object2 Un objeto
13
+ * @return {object} un nuevo objeto resultado de sobreescribir object2 a object1
14
+ * @example
15
+ * mergeObject({a: 1, b: 0}, {a: 3, b: null})
16
+ * -> {a: 3, b:0}
17
+ */
18
+ declare function mergeObjects(object1: any, object2: any): {
19
+ [x: string]: unknown;
20
+ };
21
+ declare function getGriddoDamURIWithParams(props: GetGriddoDamURIWithParamsProps): string;
22
+ /**
23
+ * cleanCloudinaryURI
24
+ * Limpia la URI de cloudinary con parámetros sin valor
25
+ * @param {string} URI la parte de la url de cloudinary con los parámetros del
26
+ * query para la imagen.
27
+ * @returns {string} la URI sin valores "nulos"
28
+ * @example
29
+ * Elimina parámetros de la URI sin valores correctos
30
+ * cloeanCloudinaryURI("w_320,q_undefined,f_null,,,g_,h_120")
31
+ * -> "w_320,h_120"
32
+ */
33
+ declare function cleanCloudinaryURI(URI: string): string;
34
+ declare function getDomainFromDamUrl(damUrl: string): string;
35
+ declare function getDamIdFromDamUrl(damUrl: string): string;
36
+ declare const rndHash: () => string;
37
+ export declare type UnknownObject = Record<string, unknown>;
38
+ interface GetGriddoDamURIWithParamsProps {
39
+ damId: string;
40
+ imageConfig: ImageConfig;
41
+ [key: string]: unknown;
42
+ }
43
+ export { rearrangeResponsiveArray, cloudinaryRearrangeResponsiveArray, removeUnit, mergeObjects, cleanCloudinaryURI, getGriddoDamURIWithParams, getDomainFromDamUrl, getDamIdFromDamUrl, fillIntArray, rndHash, };
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import { ComponentProps } from "../components/Component";
3
+ declare const getComponent: (components: Record<string, React.FC<Omit<ComponentProps, "libComponents">>>, props: {
4
+ [key: string]: unknown;
5
+ component: string;
6
+ }) => React.FC<Omit<ComponentProps, "libComponents">> | null;
7
+ export { getComponent };
@@ -0,0 +1,74 @@
1
+ declare function getLinks(url?: GetLinkProps): {
2
+ href: string | null | undefined;
3
+ to: string | null | undefined;
4
+ };
5
+ declare function parseAnchor(pageUrl: string, linkUrl: string): string;
6
+ declare function getToken(): {
7
+ Authorization: string;
8
+ } | null;
9
+ declare function getSiteID(): any;
10
+ declare function getLang(): number | false;
11
+ /**
12
+ * recursiveSearch
13
+ * Devuelve una lista con los valores de una prop dentro de un objeto
14
+ * La búsqueda es recursiva en todo el objeto
15
+ * @param {object} config Un objeto con los parámetros de la función
16
+ * @param {object} config.obj El objeto donde buscar
17
+ * @param {string} config.searchKey El nombre de la propiedad a buscar
18
+ * @param {array} config.results El array de resultados, se van añadiendo recursivamente los resultados.
19
+ * @param {boolean} config.unique Si es true elimina los resultados repetidos
20
+ * @example
21
+ * Obtiene una lista con los valores de la prop "a"
22
+ * recursiveSearch({ obj: {a: 1, b: {a: "foo"}}, "a"})
23
+ * -> [1, "foo"]
24
+ *
25
+ * @return {array} Un array con los valores de la propiedad `searchValue`
26
+ */
27
+ declare function recursiveSearch({ obj, searchKey, resultsBuffer, unique, }?: RecursiveSearchProps): string[];
28
+ /**
29
+ * concatParams
30
+ * @param {object} params
31
+ * @param {string} params.baseUrl base url of the api
32
+ * @param {object} params.params object with the params to be sent
33
+ * @returns {string} a string with the params concatenated
34
+ */
35
+ declare function concatParams({ baseUrl, params }: ConcatParams): string;
36
+ /**
37
+ * slicePageArray
38
+ * Extrae un rango de elementos de un array indicando el número de elementos y
39
+ * usando el concepto "página" como índice.
40
+ * @param {object} props Un objeto con las props
41
+ * @param {array} props.array Array de datos.
42
+ * @param {number} props.page Índice desde el que extraer los elementos.
43
+ * @param {number} props.itemsPerPage Número de elementos que extraerá del array.
44
+ * @return {array} Array con los elementos extraidos
45
+ * @example
46
+ * Extrae la página 2 usando 3 elementos por página
47
+ * slicePageArray({
48
+ * data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
49
+ * page: 2,
50
+ * itemsPerPage: 3
51
+ * })
52
+ * -> [3, 4, 5]
53
+ */
54
+ declare function slicePageArray({ array, page, itemsPerPage }: SlicePageArray): number[];
55
+ interface GetLinkProps {
56
+ href?: string;
57
+ linkToURL?: string;
58
+ }
59
+ interface RecursiveSearchProps {
60
+ obj?: Record<string, string>;
61
+ searchKey?: string;
62
+ resultsBuffer?: Array<string>;
63
+ unique?: boolean;
64
+ }
65
+ interface ConcatParams {
66
+ baseUrl: string;
67
+ params: Record<string, any>;
68
+ }
69
+ interface SlicePageArray {
70
+ array: Array<number>;
71
+ page: number;
72
+ itemsPerPage: number;
73
+ }
74
+ export { getLinks, parseAnchor, getToken, getSiteID, getLang, recursiveSearch, concatParams, slicePageArray, };
@@ -0,0 +1,18 @@
1
+ import { useGlobalTheme } from "./themes/useGlobalTheme";
2
+ import { useTheme } from "./themes/useTheme";
3
+ import { useThemeColors } from "./themes/useThemeColors";
4
+ import { useThemeFont } from "./themes/useThemeFont";
5
+ import { useThemePrimitives } from "./themes/useThemePrimitives";
6
+ import { useContentType } from "./useContentType";
7
+ import { useDataFilters } from "./useDataFilters";
8
+ import { useGriddoImage } from "./useGriddoImage";
9
+ import { useI18n } from "./useI18n";
10
+ import { useImage } from "./useImage";
11
+ import { useLink } from "./useLink";
12
+ import { useList } from "./useList";
13
+ import { useNavigation } from "./useNavigation";
14
+ import { usePage } from "./usePage";
15
+ import { useReferenceFieldData } from "./useReferenceFieldData";
16
+ import { useSite } from "./useSite";
17
+ import { useSitemap } from "./useSitemap";
18
+ export { useContentType, useDataFilters, useGlobalTheme, useGriddoImage, useI18n, useImage, useLink, useList, useNavigation, usePage, useReferenceFieldData as useDistributorData, useReferenceFieldData, useSite, useSitemap, useTheme, useThemeColors, useThemeFont, useThemePrimitives, };
@@ -0,0 +1,20 @@
1
+ export declare type ThemeColorsProps = {
2
+ /** Theme from which to obtain primitives. If not specified, primitives for all themes will be returned. */
3
+ theme: string;
4
+ /** Subtheme from which to obtain primitives. If not specified, primitives for all subthemes will be returned. */
5
+ subtheme?: string;
6
+ /** Whether to include global theme or not. */
7
+ global?: boolean;
8
+ };
9
+ export declare type UseThemeColorsProps = Partial<ThemeColorsProps> | ThemeColorsProps;
10
+ export declare type UseThemeFontProps = UseThemeColorsProps;
11
+ export declare type UseThemePrimitivesProps = UseThemeColorsProps & {
12
+ /** Group of primitives to get, i.e. 'spacing', 'radii'... */
13
+ primitive: string | Array<string>;
14
+ };
15
+ export interface UseThemeProps {
16
+ /** Theme from which to obtain primitives. If not specified, all themes will be returned. */
17
+ theme?: string;
18
+ /** Whether to include global theme or not. */
19
+ global?: boolean;
20
+ }
@@ -0,0 +1,6 @@
1
+ import { Theme } from "../..";
2
+ /**
3
+ * Returns global theme definition and its primitives values.
4
+ */
5
+ declare function useGlobalTheme(themeFile: Theme.GriddoTheme): Theme.GlobalTheme;
6
+ export { useGlobalTheme };
@@ -0,0 +1,8 @@
1
+ import { Theme } from "../..";
2
+ import { UseThemeProps } from "./types";
3
+ /**
4
+ * This hook can be used to get a specific theme, given its id.
5
+ * If theme id is not specified, it will return all themes.
6
+ */
7
+ declare function useTheme(themeFile: Theme.GriddoTheme, props: UseThemeProps): Array<Theme.GlobalTheme | Theme.Theme> | Theme.Theme;
8
+ export { useTheme };
@@ -0,0 +1,8 @@
1
+ import { Theme } from "../..";
2
+ import { UseThemeColorsProps } from "./types";
3
+ /**
4
+ * This hook can be used to get all color primitives from the given theme.
5
+ * If theme is not specified, it will return color primitives for all themes.
6
+ */
7
+ declare function useThemeColors(themeFile: Theme.GriddoTheme, props?: UseThemeColorsProps): Array<Theme.GlobalTheme | Theme.Theme>;
8
+ export { useThemeColors };
@@ -0,0 +1,8 @@
1
+ import { Theme } from "../..";
2
+ import { UseThemeFontProps } from "./types";
3
+ /**
4
+ * This hook can be used to get font related primitives from the given theme and subtheme.
5
+ * If theme or subtheme are not specified, it will return font primitives for all themes and subthemes.
6
+ */
7
+ declare function useThemeFont(themeFile: Theme.GriddoTheme, props?: UseThemeFontProps): Array<Theme.GlobalTheme | Theme.Theme>;
8
+ export { useThemeFont };
@@ -0,0 +1,8 @@
1
+ import { Theme } from "../..";
2
+ import { UseThemePrimitivesProps } from "./types";
3
+ /**
4
+ * This hook can be used to get a specific group of primitives from the given theme and subtheme.
5
+ * If theme or subtheme are not specified, it will return primitives for all themes and subthemes.
6
+ */
7
+ declare function useThemePrimitives(themeFile: Theme.GriddoTheme, props: UseThemePrimitivesProps): Array<Theme.GlobalTheme | Theme.Theme>;
8
+ export { useThemePrimitives };
@@ -0,0 +1,61 @@
1
+ import { Theme } from "../..";
2
+ export declare const filterThemePrimitivesByType: (themes: Array<Theme.GlobalTheme | Theme.Theme>, primitives: string | Array<string>, subtheme?: string | undefined) => ({
3
+ primitives: Theme.Primitives;
4
+ subthemes: {
5
+ primitives: Theme.Primitives;
6
+ id: string;
7
+ name: string;
8
+ selector: string;
9
+ description?: string | undefined;
10
+ }[];
11
+ customMedia?: {
12
+ [key: string]: string;
13
+ } | undefined;
14
+ id: string;
15
+ name: string;
16
+ selector: string;
17
+ description?: string | undefined;
18
+ } | {
19
+ primitives: Theme.Primitives;
20
+ subthemes: {
21
+ primitives: Theme.Primitives;
22
+ id: string;
23
+ name: string;
24
+ selector: string;
25
+ description?: string | undefined;
26
+ }[];
27
+ id: string;
28
+ name: string;
29
+ selector: string;
30
+ description?: string | undefined;
31
+ })[];
32
+ export declare const filterThemePrimitivesByColor: (themes: Array<Theme.GlobalTheme | Theme.Theme>, subtheme?: string | undefined) => ({
33
+ primitives: Theme.Primitives;
34
+ subthemes: {
35
+ primitives: Theme.Primitives;
36
+ id: string;
37
+ name: string;
38
+ selector: string;
39
+ description?: string | undefined;
40
+ }[];
41
+ customMedia?: {
42
+ [key: string]: string;
43
+ } | undefined;
44
+ id: string;
45
+ name: string;
46
+ selector: string;
47
+ description?: string | undefined;
48
+ } | {
49
+ primitives: Theme.Primitives;
50
+ subthemes: {
51
+ primitives: Theme.Primitives;
52
+ id: string;
53
+ name: string;
54
+ selector: string;
55
+ description?: string | undefined;
56
+ }[];
57
+ id: string;
58
+ name: string;
59
+ selector: string;
60
+ description?: string | undefined;
61
+ })[];
@@ -0,0 +1,11 @@
1
+ import { Fields } from "..";
2
+ interface UseContentTypeProps<ContentType> {
3
+ /** The ReferenceField from the module schema */
4
+ data?: Fields.ReferenceField<ContentType>;
5
+ /** The queriedData prop from the building phase */
6
+ queriedData?: Fields.QueriedData<ContentType>;
7
+ /** --to-be-implemented-- ContentType prop to be processed */
8
+ contentType?: never;
9
+ }
10
+ declare function useContentType<ContentType>({ data, queriedData, }: UseContentTypeProps<ContentType>): Fields.QueriedData<ContentType> | undefined;
11
+ export { useContentType };
@@ -0,0 +1,35 @@
1
+ import { SetQueryProps } from "../types/global";
2
+ /**
3
+ * `useDataFilters()`
4
+ *
5
+ * Returns an object with filter information to use with ContentTypes.
6
+ * @example
7
+ * const [{ query }, setQuery] = useDataFilters()
8
+ * setQuery(data) // `data` from a `ReferenceField`
9
+ */
10
+ declare function useDataFilters<ContentType>(): UseDataFiltersReturn<ContentType>;
11
+ export declare type UseDataFiltersSetQueryProps<ContentType> = Pick<SetQueryProps<ContentType>, "data" | "apiUrl" | "lang" | "site" | "cached">;
12
+ export declare type UseDataFiltersItem<Item> = Omit<Item, "contentTypeName"> & {
13
+ id: number;
14
+ };
15
+ export interface UseDataFilterSetUrlAction {
16
+ queryUrl: string;
17
+ }
18
+ export declare type UseDataFiltersReturn<ContentType> = [
19
+ UseDataFiltersState<ContentType>,
20
+ (setQuery: UseDataFiltersSetQueryProps<ContentType>) => void | null
21
+ ];
22
+ export declare type UseDataFiltersState<Item> = {
23
+ isError: boolean;
24
+ isLoading: boolean;
25
+ msg: {
26
+ code: number;
27
+ msg: string;
28
+ };
29
+ query?: {
30
+ page: number;
31
+ totalItems: number;
32
+ items: Array<UseDataFiltersItem<Item>>;
33
+ };
34
+ };
35
+ export { useDataFilters };
@@ -0,0 +1,49 @@
1
+ import { ImageCropType, ImageDecoding, ImageFormats, ImageLoading, ImagePosition, ImageTransform, ResponsiveImageProps } from "../types/core";
2
+ /**
3
+ * `useGriddoImage()`
4
+ */
5
+ declare function useGriddoImage({ url, ...props }: UseGriddoImageProps): UseGriddoImageReturn;
6
+ export interface GenerateImageChunkProps {
7
+ srcSet?: Array<string>;
8
+ srcSetURL?: Array<string>;
9
+ format: ImageFormats;
10
+ }
11
+ export interface UseGriddoImageProps extends Omit<ImageConfig, "formats"> {
12
+ url?: string;
13
+ }
14
+ export interface ImageConfig {
15
+ blurCSSTransition?: string;
16
+ blurSize?: string;
17
+ crop?: ImageCropType;
18
+ decoding?: ImageDecoding;
19
+ domain?: string;
20
+ format?: ImageFormats;
21
+ formats?: Array<ImageFormats>;
22
+ height?: string;
23
+ loading?: ImageLoading;
24
+ position?: ImagePosition;
25
+ quality?: number;
26
+ responsive?: Array<ResponsiveImageProps>;
27
+ transforms?: ImageTransform;
28
+ width?: string;
29
+ sizes?: string;
30
+ }
31
+ export interface ImageChunk {
32
+ srcSet?: Array<string>;
33
+ srcSetURL?: Array<string>;
34
+ }
35
+ export interface UseGriddoImageReturn {
36
+ srcSet?: Array<string>;
37
+ srcSetURL?: Array<string>;
38
+ src?: string;
39
+ sizes?: string;
40
+ webpFallback?: ImageChunk;
41
+ jpg?: ImageChunk;
42
+ jpeg?: ImageChunk;
43
+ webp?: ImageChunk;
44
+ avif?: ImageChunk;
45
+ png?: ImageChunk;
46
+ gif?: ImageChunk;
47
+ svg?: ImageChunk;
48
+ }
49
+ export { useGriddoImage };
@@ -0,0 +1,38 @@
1
+ import { Locale } from "../types/core";
2
+ /**
3
+ * `useI18n()`
4
+ *
5
+ * Hook que devuelve funciones para obtener las traducciones desde el contexto
6
+ * teniendo en cuenta el idioma de la página actual.
7
+ * [Documentación](https://www.notion.so/griddoio/useI18n-021b08689dcf4abd8f666da7b7646611)
8
+ * @example
9
+ * ```typescript
10
+ * const { getTraslation, getNestedTranslation } = useI18n()
11
+ * const foo = getTranslation("submitButtonLabel")
12
+ * const bar = getNestedTranslation("modules.backLabel")
13
+ * ```
14
+ */
15
+ declare function useI18n(props?: UseI18nProps): I18nFunctions;
16
+ export interface UseI18nProps {
17
+ /** Locale code from where get the translation. This locale override the current page language */
18
+ locale?: Locale;
19
+ }
20
+ declare type I18nTranslationFunction = (
21
+ /** Key from the translation object that will be obtained */
22
+ key: string,
23
+ /** Fallback string in case `key` doesn't return nothing (undefined) */
24
+ defaultString?: string) => string | Record<string, unknown>;
25
+ export interface I18nFunctions {
26
+ /**
27
+ * Return a static translation based on the translation object and current page language using a string key as argument.
28
+ * @example: getTranslation("greetings")
29
+ */
30
+ getTranslation: I18nTranslationFunction;
31
+ /**
32
+ * Return a static translation based on the translation object and current page language using a dot notation string key as argument.
33
+ * Translate function helper with "dot object notation"
34
+ * @example: getNestedTranslation("ui.strings.followUs")
35
+ */
36
+ getNestedTranslation: I18nTranslationFunction;
37
+ }
38
+ export { useI18n };
@@ -0,0 +1,44 @@
1
+ import { ImageDecoding, ImageLoading } from "../types/core";
2
+ /**
3
+ * `useImage()`
4
+ *
5
+ * @deprecated This hook will be removed from Griddo in the future.
6
+ */
7
+ declare function useImage({ publicId, ...props }: UseImageProps): {
8
+ src: string;
9
+ srcSet: string[] | undefined;
10
+ sizes: string;
11
+ fallbackSrcImage: string;
12
+ srcSetURL: string[] | undefined;
13
+ };
14
+ export declare type UseImageProps = CloudinaryImageConfig;
15
+ interface CloudinaryImageConfig {
16
+ responsive?: Array<CloudinaryResponsiveImageProps>;
17
+ ar?: number | string;
18
+ backgroundLazy?: boolean;
19
+ crop?: "fill" | "crop" | "thumb" | "fill_pad" | "lfill";
20
+ decoding?: ImageDecoding;
21
+ domain?: string;
22
+ fallback404Image?: string;
23
+ fallback404ImageId?: string;
24
+ format?: "auto" | "jpg" | "webp" | "avif" | "gif" | "png";
25
+ gravity?: string;
26
+ height?: string;
27
+ loading?: ImageLoading;
28
+ publicId?: string;
29
+ quality?: number;
30
+ sizes?: string;
31
+ uploadFolder?: string;
32
+ width?: string;
33
+ }
34
+ export interface CloudinaryResponsiveImageProps {
35
+ breakpoint?: null | string;
36
+ width?: string;
37
+ height?: string;
38
+ quality?: number;
39
+ crop?: CloudinaryImageCrop;
40
+ format?: CloudinaryImageFormat;
41
+ }
42
+ export declare type CloudinaryImageFormat = "auto" | "jpg" | "webp" | "avif" | "gif" | "png";
43
+ export declare type CloudinaryImageCrop = "fill" | "crop" | "thumb" | "fill_pad" | "lfill";
44
+ export { useImage };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * `useLink()`
4
+ *
5
+ * @deprecated This hooks is used by the old `<Link>` component from Griddo which you may want not use anymore. Use `<GriddoLink>` instead.
6
+ */
7
+ declare function useLink(): (props: import("..").GriddoLinkProps) => JSX.Element;
8
+ export { useLink };
@@ -0,0 +1,36 @@
1
+ import { SetQueryProps } from "../types/global";
2
+ /**
3
+ * `useList()`
4
+ *
5
+ * Hook with which to obtain a list of ContentTypes from the public API.
6
+ * @example
7
+ * const [{ query }, setQuery] = useList()
8
+ * setQuery(data) // `data` from a `ReferenceField`
9
+ */
10
+ declare function useList<ContentType>(): UseListReturn<ContentType>;
11
+ export declare type UseListSetQueryProps<ContentType> = SetQueryProps<ContentType>;
12
+ export declare type UseListItem<Item> = Omit<Item, "contentTypeName"> & {
13
+ id: number;
14
+ };
15
+ export interface UseListSetUrlAction {
16
+ queryUrl: string | undefined;
17
+ extra: Record<string, unknown> | undefined;
18
+ }
19
+ export declare type UseListReturn<ContentType> = [
20
+ UseListState<ContentType>,
21
+ (setQuery: UseListSetQueryProps<ContentType>) => void | null
22
+ ];
23
+ export declare type UseListState<Item> = {
24
+ isError: boolean;
25
+ isLoading: boolean;
26
+ msg: {
27
+ code: number;
28
+ msg: string;
29
+ };
30
+ query?: {
31
+ page: number;
32
+ totalItems: number;
33
+ items: Array<UseListItem<Item>>;
34
+ };
35
+ };
36
+ export { useList };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * `useNavigation()`
3
+ */
4
+ declare function useNavigation(): import("../contexts/Navigation").NavigationContextProps | null;
5
+ export { useNavigation };
@@ -0,0 +1,11 @@
1
+ import { PageContextProps } from "../contexts/Page";
2
+ /**
3
+ * `usePage()`
4
+ *
5
+ * Hook to get some page properties.
6
+ * [Documentation](https://www.notion.so/griddoio/usePage-2a781f907cf74b4f8df6a4fbe0d8f399)
7
+ * @example
8
+ * const { title } = usePage()
9
+ */
10
+ declare function usePage(): PageContextProps;
11
+ export { usePage };
@@ -0,0 +1,11 @@
1
+ import { Fields } from "..";
2
+ /**
3
+ * `useReferenceFieldData<ContentType>()`
4
+ *
5
+ * Hook para obtener el contenido de los datos a partir de un `ReferenceField`
6
+ * [Documentación](https://www.notion.so/griddoio/useReferenceFieldData-9eca3bc618464c5c9bee67f3a9607138)
7
+ * @example
8
+ * const dataItems = useReferenceFieldData<NewsContentType>(data)
9
+ */
10
+ declare function useReferenceFieldData<GriddoContentType = unknown>(data?: Fields.ReferenceField<GriddoContentType>): Fields.QueriedData<GriddoContentType> | undefined | null;
11
+ export { useReferenceFieldData };
@@ -0,0 +1,12 @@
1
+ import { Site } from "../types/core";
2
+ /**
3
+ * `useSite()`
4
+ *
5
+ * Hook to get some site properties.
6
+ * [Documentation](https://www.notion.so/griddoio/useSite-6d8065726c03409f9f884515ecab2eca)
7
+ * @example
8
+ * const { renderer } = useSite()
9
+ */
10
+ declare const useSite: UseSite;
11
+ declare type UseSite = () => Site;
12
+ export { useSite };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * `useSitemap()`
3
+ *
4
+ * @deprecated This hook will be removed from Griddo in the future
5
+ */
6
+ declare function useSitemap(): (boolean | undefined)[];
7
+ export { useSitemap };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,24 @@
1
- import { Core } from "./src/types/core";
2
- import { PageContentTypeFields, PageCTFields, PageDataFields, PureDataFields, SimpleContentTypeFields, SimpleCTFields, UIFields } from "./src/types/fields";
3
- import { Schema } from "./src/types/schema";
4
- import { Theme } from "./src/types/theme";
5
- import { createCategoriesSchema, createDamDefaultsSchema, createDataPackCategoriesSchema, createDataPackSchema, createHeaderFooterSchema, createLanguagesSchema, createMenuSchema, createModuleCategoriesSchema, createPageDataField as createPageContentTypeField, createPageDataField, createPageDataSchema as createPageContentTypeSchema, createPageDataSchema, createPureDataField, createPureDataField as createSimpleContentTypeField, createPureDataSchema, createPureDataSchema as createSimpleContentTypeSchema, createThemesSchema, createTranslationsSchema, createUIField, createUISchema } from "./src/functions/create-schemas";
6
- export { Theme, Schema, Core, UIFields, PureDataFields, PageDataFields, SimpleContentTypeFields, PageContentTypeFields, SimpleCTFields, PageCTFields, createCategoriesSchema, createDamDefaultsSchema, createDataPackCategoriesSchema, createDataPackSchema, createLanguagesSchema, createMenuSchema, createModuleCategoriesSchema, createHeaderFooterSchema, createPageDataSchema, createPageContentTypeSchema, createPureDataSchema, createSimpleContentTypeSchema, createThemesSchema, createTranslationsSchema, createUISchema, createPageDataField, createPureDataField, createPageContentTypeField, createSimpleContentTypeField, createUIField, };
1
+ import { CloudinaryBackgroundImage, CloudinaryImage, Component, GriddoBackgroundImage, GriddoImage, GriddoLink, LdJson, Link, Page, Preview } from "./components";
2
+ import { PageContext, PageProvider, SiteContext, SiteProvider } from "./contexts";
3
+ import { SiteProviderProps } from "./contexts/Site";
4
+ import { getComponent } from "./functions";
5
+ import { createComponentSchema, createSimpleContentTypeSchema, createPageContentTypeSchema, createCategoryContentTypeSchema, createDamDefaultsSchema, createDataPackCategorySchema, createDataPackSchema, createFooterSchema, createHeaderSchema, createLanguagesSchema, createMenuSchema, createModuleCategoriesSchema, createModuleSchema, createTemplateSchema, createThemesSchema, createTranslationsSchema } from "./functions/create-schemas";
6
+ import { getLang, getSiteID, getToken } from "./functions/utils";
7
+ import { useContentType, useDataFilters, useGlobalTheme, useGriddoImage, useI18n, useImage, useLink, useList, useNavigation, usePage, useReferenceFieldData, useSite, useSitemap, useTheme, useThemeColors, useThemeFont, useThemePrimitives } from "./hooks";
8
+ import { CloudinaryImageProps } from "./components/CloudinaryImage";
9
+ import { ComponentProps } from "./components/Component";
10
+ import { GriddoImageProps } from "./components/GriddoImage";
11
+ import { GriddoLinkProps, HLocation, LinkGetProps, WindowLocation } from "./components/GriddoLink";
12
+ import { ModulePreviewProps } from "./components/ModulePreview";
13
+ import { PageProps } from "./components/Page";
14
+ import { PreviewProps } from "./components/Preview";
15
+ import { UseDataFilterSetUrlAction, UseDataFiltersItem, UseDataFiltersReturn, UseDataFiltersSetQueryProps, UseDataFiltersState } from "./hooks/useDataFilters";
16
+ import { GenerateImageChunkProps, ImageChunk, ImageConfig, UseGriddoImageProps, UseGriddoImageReturn } from "./hooks/useGriddoImage";
17
+ import { I18nFunctions, UseI18nProps } from "./hooks/useI18n";
18
+ import { CloudinaryImageCrop, CloudinaryImageFormat, CloudinaryResponsiveImageProps, UseImageProps } from "./hooks/useImage";
19
+ import { UseListItem, UseListReturn, UseListSetQueryProps, UseListSetUrlAction, UseListState } from "./hooks/useList";
20
+ import * as Core from "./types/core";
21
+ import * as Fields from "./types/fields";
22
+ import * as Schema from "./types/schema-functions/schemas";
23
+ import * as Theme from "./types/theme";
24
+ export { PageContext, PageProvider, SiteContext, SiteProvider, SiteProviderProps, CloudinaryBackgroundImage, CloudinaryImage, Component, GriddoBackgroundImage, GriddoImage, GriddoLink, LdJson, Link, Page, Preview, UseDataFilterSetUrlAction, UseDataFiltersItem, UseDataFiltersReturn, UseDataFiltersSetQueryProps, UseDataFiltersState, CloudinaryImageCrop, CloudinaryImageFormat, CloudinaryResponsiveImageProps, GenerateImageChunkProps, I18nFunctions, ImageChunk, ImageConfig, UseListItem, UseListReturn, UseListSetQueryProps, UseListSetUrlAction, UseListState, UseGriddoImageProps, UseGriddoImageReturn, UseI18nProps, UseImageProps, useContentType, useDataFilters, useGriddoImage, useI18n, useImage, useLink, useList, useNavigation, usePage, useReferenceFieldData as useDistributorData, useReferenceFieldData, useSite, useSitemap, useGlobalTheme, useTheme, useThemeColors, useThemeFont, useThemePrimitives, getLang, getSiteID, getToken, getComponent, createCategoryContentTypeSchema, createComponentSchema, createDamDefaultsSchema, createDataPackCategorySchema, createDataPackSchema, createFooterSchema, createHeaderSchema, createLanguagesSchema, createMenuSchema, createModuleCategoriesSchema, createModuleSchema, createPageContentTypeSchema, createSimpleContentTypeSchema, createTemplateSchema, createThemesSchema, createTranslationsSchema, Core, Fields, Schema, Theme, CloudinaryImageProps, ComponentProps, GriddoImageProps, GriddoLinkProps, HLocation, LinkGetProps, ModulePreviewProps, PageProps, PreviewProps, WindowLocation, };