@griddo/ax 1.69.8 → 1.72.0
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/config/jest/componentsMock.js +0 -26
- package/package.json +4 -3
- package/src/Style/index.tsx +1 -1
- package/src/__tests__/components/ElementsTooltip/ElementsTooltip.test.tsx +97 -0
- package/src/__tests__/components/EmptyState/EmptyState.test.tsx +78 -0
- package/src/__tests__/components/FieldContainer/FieldContainer.test.tsx +82 -0
- package/src/__tests__/components/Fields/AnalyticsField/AnalyticsField.test.tsx +1 -1
- package/src/__tests__/components/Fields/AnalyticsField/PageAnalytics/PageAnalytics.test.tsx +1 -15
- package/src/__tests__/components/Fields/AnalyticsField/StructuredDataAnalytics/StructuredDataAnalytics.test.tsx +1 -16
- package/src/__tests__/components/Fields/ArrayFieldGroup/ArrayFieldGroup.test.tsx +8 -17
- package/src/__tests__/components/Fields/AsyncCheckGroup/AsyncCheckGroup.test.tsx +4 -16
- package/src/__tests__/components/Fields/AsyncSelect/AsyncSelect.test.tsx +2 -20
- package/src/__tests__/components/Fields/CheckField/CheckField.test.tsx +6 -6
- package/src/__tests__/components/Fields/CheckGroup/CheckGroup.test.tsx +15 -15
- package/src/__tests__/components/Fields/ColorPicker/ColorPicker.test.tsx +7 -16
- package/src/__tests__/components/Fields/ComponentArray/ComponentArray.test.tsx +2 -23
- package/src/__tests__/components/Fields/ComponentArray/MixableComponentArray/MixableComponentArray.test.tsx +11 -31
- package/src/__tests__/components/Fields/ComponentArray/MixableComponentArray/PasteModuleButton/PasteModuleButton.test.tsx +15 -21
- package/src/__tests__/components/Fields/ComponentArray/SameComponentArray/SameComponentArray.test.tsx +6 -25
- package/src/__tests__/components/Fields/ComponentContainer/ComponentContainer.test.tsx +559 -0
- package/src/__tests__/components/Fields/ConditionalField/ConditionalField.test.tsx +1 -1
- package/src/__tests__/components/Fields/DateField/DateField.test.tsx +1 -1
- package/src/__tests__/components/Fields/FieldGroup/FieldGroup.test.tsx +1 -1
- package/src/__tests__/components/Fields/FieldsDivider/FieldsDivider.test.tsx +1 -1
- package/src/__tests__/components/Fields/FileField/FileField.test.tsx +3 -3
- package/src/__tests__/components/Fields/HeadingField/HeadingField.test.tsx +6 -6
- package/src/__tests__/components/Fields/HiddenField/HiddenField.test.tsx +2 -8
- package/src/__tests__/components/Fields/ImageField/ImageField.test.tsx +471 -0
- package/src/__tests__/components/Fields/MultiCheckSelect/MultiCheckSelect.test.tsx +2 -16
- package/src/__tests__/components/Fields/MultiCheckSelectGroup/MultiCheckSelectGroup.test.tsx +2 -2
- package/src/__tests__/components/Fields/NoteField/NoteField.test.tsx +2 -7
- package/src/__tests__/components/Fields/NumberField/NumberField.test.tsx +2 -15
- package/src/__tests__/components/Fields/RadioField/RadioField.test.tsx +2 -12
- package/src/__tests__/components/Fields/ReferenceField/ReferenceField.test.tsx +171 -19
- package/src/__tests__/components/Fields/RichText/RichText.test.tsx +2 -13
- package/src/__tests__/components/Fields/Select/Select.test.tsx +3 -23
- package/src/__tests__/components/Fields/SliderField/SliderField.test.tsx +2 -15
- package/src/__tests__/components/Fields/TagField/TagField.test.tsx +4 -4
- package/src/__tests__/components/Fields/TextArea/TextArea.test.tsx +1 -1
- package/src/__tests__/components/Fields/TextField/TextField.test.tsx +6 -6
- package/src/__tests__/components/Fields/TimeField/HourInput/HourInput.test.tsx +142 -0
- package/src/__tests__/components/Fields/TimeField/TimeField.test.tsx +100 -0
- package/src/__tests__/components/Fields/ToggleField/ToggleField.test.tsx +2 -10
- package/src/__tests__/components/Fields/Tooltip/Tooltip.test.tsx +152 -0
- package/src/__tests__/components/Fields/UniqueCheck/UniqueCheck.test.tsx +3 -3
- package/src/__tests__/components/Fields/UrlField/UrlField.test.tsx +4 -4
- package/src/__tests__/components/Fields/VisualUniqueSelection/ImageSelection/ImageSelection.test.tsx +2 -14
- package/src/__tests__/components/Fields/VisualUniqueSelection/ScrollableSelection/ScrollableSelection.test.tsx +6 -20
- package/src/__tests__/components/Fields/VisualUniqueSelection/VisualUniqueSelection.test.tsx +3 -29
- package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.test.tsx +1 -1
- package/src/__tests__/components/FieldsBehavior/FieldsBehavior.test.tsx +149 -0
- package/src/__tests__/components/TableFilters/CategoryFilter/CategoryFilter.test.tsx +241 -0
- package/src/__tests__/components/TableFilters/CustomizeFilters/CustomizeFilters.test.tsx +131 -0
- package/src/__tests__/components/TableFilters/DateFilter/DateFilter.test.tsx +148 -0
- package/src/__tests__/components/TableFilters/LiveFilter/LiveFilter.test.tsx +265 -0
- package/src/__tests__/components/TableFilters/NameFilter/NameFilter.test.tsx +197 -0
- package/src/__tests__/components/TableFilters/SiteFilter/SiteFilter.test.tsx +317 -0
- package/src/__tests__/components/TableFilters/StatusFilter/StatusFilter.test.tsx +197 -0
- package/src/__tests__/components/TableFilters/TranslationsFilter/TranslationsFilter.test.tsx +157 -0
- package/src/__tests__/components/TableFilters/TypeFilter/TypeFilter.test.tsx +164 -0
- package/src/__tests__/components/TableList/TableList.test.tsx +119 -0
- package/src/__tests__/components/Tabs/Tabs.test.tsx +205 -0
- package/src/__tests__/components/Tag/Tag.test.tsx +140 -0
- package/src/__tests__/components/Toast/Toast.test.tsx +102 -0
- package/src/api/navigation.tsx +1 -1
- package/src/components/Browser/index.tsx +1 -1
- package/src/components/Button/index.tsx +3 -3
- package/src/components/ConfigPanel/NavigationForm/Field/index.tsx +14 -3
- package/src/components/ElementsTooltip/index.tsx +10 -9
- package/src/components/EmptyState/index.tsx +2 -2
- package/src/components/FieldContainer/index.tsx +3 -3
- package/src/components/Fields/ArrayFieldGroup/index.tsx +1 -1
- package/src/components/Fields/AsyncCheckGroup/index.tsx +1 -1
- package/src/components/Fields/AsyncSelect/index.tsx +1 -1
- package/src/components/Fields/CheckField/index.tsx +3 -3
- package/src/components/Fields/CheckGroup/index.tsx +2 -2
- package/src/components/Fields/ComponentContainer/index.tsx +7 -6
- package/src/components/Fields/ComponentContainer/style.tsx +2 -2
- package/src/components/Fields/HeadingField/index.tsx +1 -1
- package/src/components/Fields/HiddenField/index.tsx +1 -1
- package/src/components/Fields/ImageField/index.tsx +10 -5
- package/src/components/Fields/MultiCheckSelect/index.tsx +3 -3
- package/src/components/Fields/NumberField/index.tsx +2 -1
- package/src/components/Fields/ReferenceField/ItemList/Item/index.tsx +5 -7
- package/src/components/Fields/ReferenceField/ItemList/Item/style.tsx +2 -2
- package/src/components/Fields/ReferenceField/ItemList/index.tsx +1 -1
- package/src/components/Fields/RichText/index.tsx +10 -6
- package/src/components/Fields/Select/index.tsx +2 -2
- package/src/components/Fields/SliderField/index.tsx +1 -1
- package/src/components/Fields/TextField/index.tsx +2 -7
- package/src/components/Fields/TimeField/HourInput/index.tsx +103 -0
- package/src/components/Fields/TimeField/HourInput/style.tsx +19 -0
- package/src/components/Fields/TimeField/HourInput/utils.tsx +35 -0
- package/src/components/Fields/TimeField/index.tsx +57 -0
- package/src/components/Fields/TimeField/style.tsx +37 -0
- package/src/components/Fields/index.tsx +2 -0
- package/src/components/FieldsBehavior/index.tsx +1 -1
- package/src/components/FloatingMenu/index.tsx +2 -2
- package/src/components/Gallery/GalleryFilters/Type/index.tsx +50 -0
- package/src/components/Gallery/GalleryFilters/Type/style.tsx +39 -0
- package/src/components/Gallery/GalleryPanel/DetailPanel/index.tsx +2 -1
- package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/style.tsx +3 -3
- package/src/components/Gallery/hooks.tsx +10 -4
- package/src/components/Gallery/index.tsx +2 -0
- package/src/components/Icon/index.tsx +1 -1
- package/src/components/IconAction/index.tsx +1 -1
- package/src/components/Lists/index.tsx +1 -1
- package/src/components/Loading/index.tsx +1 -1
- package/src/components/Pagination/index.tsx +1 -1
- package/src/components/SideModal/SideModalOption/index.tsx +4 -2
- package/src/components/SideModal/index.tsx +1 -1
- package/src/components/TableFilters/CategoryFilter/index.tsx +2 -2
- package/src/components/TableFilters/CategoryFilter/style.tsx +1 -10
- package/src/components/TableFilters/CustomizeFilters/index.tsx +2 -3
- package/src/components/TableFilters/DateFilter/index.tsx +4 -4
- package/src/components/TableFilters/LiveFilter/index.tsx +1 -1
- package/src/components/TableFilters/LiveFilter/style.tsx +2 -10
- package/src/components/TableFilters/NameFilter/index.tsx +4 -4
- package/src/components/TableFilters/SiteFilter/index.tsx +16 -13
- package/src/components/TableFilters/SiteFilter/style.tsx +1 -10
- package/src/components/TableFilters/StatusFilter/index.tsx +3 -3
- package/src/components/TableFilters/TranslationsFilter/index.tsx +4 -7
- package/src/components/TableFilters/TranslationsFilter/style.tsx +1 -10
- package/src/components/TableFilters/TypeFilter/index.tsx +2 -2
- package/src/components/TableFilters/TypeFilter/style.tsx +1 -10
- package/src/components/TableList/index.tsx +6 -6
- package/src/components/TableList/style.tsx +1 -1
- package/src/components/Tabs/index.tsx +19 -7
- package/src/components/Tag/index.tsx +6 -6
- package/src/components/Toast/index.tsx +4 -4
- package/src/components/Tooltip/index.tsx +5 -3
- package/src/components/index.tsx +2 -0
- package/src/containers/Navigation/Defaults/actions.tsx +10 -5
- package/src/containers/Navigation/Defaults/utils.tsx +13 -4
- package/src/containers/Sites/actions.tsx +7 -0
- package/src/containers/Sites/constants.tsx +1 -0
- package/src/containers/Sites/interfaces.tsx +6 -0
- package/src/containers/Sites/reducer.tsx +4 -0
- package/src/containers/StructuredData/actions.tsx +21 -8
- package/src/containers/StructuredData/constants.tsx +2 -0
- package/src/containers/StructuredData/interfaces.tsx +7 -1
- package/src/containers/StructuredData/reducer.tsx +5 -1
- package/src/helpers/fields.tsx +2 -2
- package/src/helpers/index.tsx +3 -0
- package/src/helpers/parseTheme.js +456 -0
- package/src/helpers/schemas.tsx +2 -2
- package/src/hooks/forms.tsx +2 -1
- package/src/modules/App/Routing/NavMenu/index.tsx +9 -1
- package/src/modules/Content/BulkHeader/TableHeader/index.tsx +1 -1
- package/src/modules/Content/hooks.tsx +19 -12
- package/src/modules/Content/index.tsx +23 -14
- package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/DefaultsBrowser/index.tsx +3 -0
- package/src/modules/Navigation/Defaults/DefaultsEditor/Editor/index.tsx +3 -1
- package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +16 -18
- package/src/modules/Navigation/Defaults/DefaultsEditor/utils.tsx +37 -0
- package/src/modules/StructuredData/Form/ConnectedField/index.tsx +3 -2
- package/src/modules/StructuredData/Form/index.tsx +22 -17
- package/src/modules/StructuredData/StructuredDataList/hooks.tsx +30 -20
- package/src/modules/StructuredData/StructuredDataList/index.tsx +24 -14
- package/src/types/index.tsx +8 -7
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
SET_INITIAL_VALUES,
|
|
10
10
|
SET_SAVED_SITE_INFO,
|
|
11
11
|
SET_CURRENT_SITE_ERROR_PAGES,
|
|
12
|
+
SET_CONTENT_FILTERS,
|
|
12
13
|
} from "./constants";
|
|
13
14
|
import { ISite } from "@ax/types";
|
|
14
15
|
|
|
@@ -62,4 +63,9 @@ export interface ISetCurrentSiteErrorPages {
|
|
|
62
63
|
payload: { currentSiteErrorPages: number[] };
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
export interface ISetContentFilters {
|
|
67
|
+
type: typeof SET_CONTENT_FILTERS;
|
|
68
|
+
payload: { contentFilters: Record<string,string> | null };
|
|
69
|
+
}
|
|
70
|
+
|
|
65
71
|
export type SitesActionsCreators = ISetSitesAction & ISetCurrentSiteInfoAction;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
SET_INITIAL_VALUES,
|
|
10
10
|
SET_SAVED_SITE_INFO,
|
|
11
11
|
SET_CURRENT_SITE_ERROR_PAGES,
|
|
12
|
+
SET_CONTENT_FILTERS,
|
|
12
13
|
} from "./constants";
|
|
13
14
|
|
|
14
15
|
import { ISite, IPage, ILanguage } from "@ax/types";
|
|
@@ -26,6 +27,7 @@ export interface ISitesState {
|
|
|
26
27
|
currentSiteLanguages: ILanguage[];
|
|
27
28
|
savedSiteInfo: any;
|
|
28
29
|
currentSiteErrorPages: number[];
|
|
30
|
+
contentFilters: Record<string, string> | null;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
export const initialState = {
|
|
@@ -39,6 +41,7 @@ export const initialState = {
|
|
|
39
41
|
currentSiteLanguages: [],
|
|
40
42
|
savedSiteInfo: null,
|
|
41
43
|
currentSiteErrorPages: [],
|
|
44
|
+
contentFilters: null,
|
|
42
45
|
};
|
|
43
46
|
|
|
44
47
|
export function reducer(state = initialState, action: SitesActionsCreators): ISitesState {
|
|
@@ -53,6 +56,7 @@ export function reducer(state = initialState, action: SitesActionsCreators): ISi
|
|
|
53
56
|
case SET_INITIAL_VALUES:
|
|
54
57
|
case SET_SAVED_SITE_INFO:
|
|
55
58
|
case SET_CURRENT_SITE_ERROR_PAGES:
|
|
59
|
+
case SET_CONTENT_FILTERS:
|
|
56
60
|
return { ...state, ...action.payload };
|
|
57
61
|
default:
|
|
58
62
|
return state;
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
SET_SCHEMA_VERSION,
|
|
17
17
|
SET_ERRORS,
|
|
18
18
|
SET_VALIDATED,
|
|
19
|
+
SET_CONTENT_FILTERS,
|
|
19
20
|
} from "./constants";
|
|
20
21
|
|
|
21
22
|
import {
|
|
@@ -30,9 +31,17 @@ import {
|
|
|
30
31
|
ISetSchemaVersion,
|
|
31
32
|
ISetErrors,
|
|
32
33
|
ISetValidated,
|
|
34
|
+
ISetContentFilters,
|
|
33
35
|
} from "./interfaces";
|
|
34
36
|
import { prepareStructuredDataContent, getTaxonomies, filterStructuredDataByID, getTypes } from "./utils";
|
|
35
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
IStructuredData,
|
|
39
|
+
IStructuredDataContent,
|
|
40
|
+
ICategory,
|
|
41
|
+
IGetStructuredDataParams,
|
|
42
|
+
IErrorItem,
|
|
43
|
+
IStructuredDataQueryValues,
|
|
44
|
+
} from "@ax/types";
|
|
36
45
|
import { structuredData } from "@ax/api";
|
|
37
46
|
import { setTotalItems } from "@ax/containers/Sites/actions";
|
|
38
47
|
import { appActions } from "@ax/containers/App";
|
|
@@ -102,30 +111,33 @@ function setValidated(validated: boolean): ISetValidated {
|
|
|
102
111
|
return { type: SET_VALIDATED, payload: { validated } };
|
|
103
112
|
}
|
|
104
113
|
|
|
114
|
+
function setContentFilters(contentFilters: Record<string, IStructuredDataQueryValues> | null): ISetContentFilters {
|
|
115
|
+
return { type: SET_CONTENT_FILTERS, payload: { contentFilters } };
|
|
116
|
+
}
|
|
117
|
+
|
|
105
118
|
function updateFormValue(valueObj: any): (dispatch: Dispatch, getState: any) => void {
|
|
106
119
|
return (dispatch, getState) => {
|
|
107
120
|
const {
|
|
108
121
|
structuredData: { form },
|
|
109
122
|
} = getState();
|
|
110
|
-
const updatedForm = { ...form, content: { ...form
|
|
123
|
+
const updatedForm = { ...form, content: { ...form?.content, ...valueObj } };
|
|
111
124
|
dispatch(updateForm(updatedForm));
|
|
112
125
|
};
|
|
113
126
|
}
|
|
114
127
|
|
|
115
|
-
function resetForm(): (dispatch: Dispatch, getState: any) => void {
|
|
128
|
+
function resetForm(setDefault?: boolean): (dispatch: Dispatch, getState: any) => void {
|
|
116
129
|
return (dispatch, getState) => {
|
|
117
130
|
const {
|
|
118
|
-
structuredData: {
|
|
119
|
-
currentStructuredData: { defaultValues },
|
|
120
|
-
},
|
|
131
|
+
structuredData: { currentStructuredData },
|
|
121
132
|
} = getState();
|
|
122
133
|
|
|
123
|
-
const
|
|
134
|
+
const formContent = setDefault && currentStructuredData ? { content: currentStructuredData.defaultValues } : null;
|
|
124
135
|
|
|
125
136
|
dispatch(setEntity(null));
|
|
126
|
-
dispatch(updateForm(
|
|
137
|
+
dispatch(updateForm(formContent));
|
|
127
138
|
dispatch(setErrors([]));
|
|
128
139
|
dispatch(setValidated(false));
|
|
140
|
+
dispatch(setCurrentDataID(null));
|
|
129
141
|
};
|
|
130
142
|
}
|
|
131
143
|
|
|
@@ -559,4 +571,5 @@ export {
|
|
|
559
571
|
setFilter,
|
|
560
572
|
validateForm,
|
|
561
573
|
deleteError,
|
|
574
|
+
setContentFilters,
|
|
562
575
|
};
|
|
@@ -15,6 +15,7 @@ const SET_FILTER: string | null = `${NAME}/SET_FILTER`;
|
|
|
15
15
|
const SET_SCHEMA_VERSION: string | null = `${NAME}/SET_SCHEMA_VERSION`;
|
|
16
16
|
const SET_ERRORS = `${NAME}/SET_ERRORS`;
|
|
17
17
|
const SET_VALIDATED = `${NAME}/SET_VALIDATED`;
|
|
18
|
+
const SET_CONTENT_FILTERS = `${NAME}/SET_CONTENT_FILTERS`;
|
|
18
19
|
|
|
19
20
|
const ITEMS_PER_PAGE = 50;
|
|
20
21
|
|
|
@@ -45,4 +46,5 @@ export {
|
|
|
45
46
|
SET_SCHEMA_VERSION,
|
|
46
47
|
SET_ERRORS,
|
|
47
48
|
SET_VALIDATED,
|
|
49
|
+
SET_CONTENT_FILTERS,
|
|
48
50
|
};
|
|
@@ -12,9 +12,10 @@ import {
|
|
|
12
12
|
SET_SCHEMA_VERSION,
|
|
13
13
|
SET_ERRORS,
|
|
14
14
|
SET_VALIDATED,
|
|
15
|
+
SET_CONTENT_FILTERS,
|
|
15
16
|
} from "./constants";
|
|
16
17
|
|
|
17
|
-
import { IStructuredData, IStructuredDataContent, ICategory, IErrorItem } from "@ax/types";
|
|
18
|
+
import { IStructuredData, IStructuredDataContent, ICategory, IErrorItem, IStructuredDataQueryValues } from "@ax/types";
|
|
18
19
|
|
|
19
20
|
export interface ISetCategories {
|
|
20
21
|
type: typeof SET_CATEGORIES;
|
|
@@ -80,6 +81,11 @@ export interface ISetValidated {
|
|
|
80
81
|
payload: { validated: boolean };
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
export interface ISetContentFilters {
|
|
85
|
+
type: typeof SET_CONTENT_FILTERS;
|
|
86
|
+
payload: { contentFilters: Record<string, IStructuredDataQueryValues> | null };
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
export type CategoryActionsCreators = ISetCategories & ISetCurrentData;
|
|
84
90
|
|
|
85
91
|
export type StructuredDataActionsCreators = CategoryActionsCreators &
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IStructuredData, IStructuredDataContent, ICategory, IErrorItem } from "@ax/types";
|
|
1
|
+
import { IStructuredData, IStructuredDataContent, ICategory, IErrorItem, IStructuredDataQueryValues } from "@ax/types";
|
|
2
2
|
import {
|
|
3
3
|
SET_CATEGORIES,
|
|
4
4
|
SET_STRUCTURED_DATA,
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
SET_SCHEMA_VERSION,
|
|
16
16
|
SET_ERRORS,
|
|
17
17
|
SET_VALIDATED,
|
|
18
|
+
SET_CONTENT_FILTERS,
|
|
18
19
|
} from "./constants";
|
|
19
20
|
|
|
20
21
|
import { StructuredDataActionsCreators } from "./interfaces";
|
|
@@ -34,6 +35,7 @@ export interface IStructuredDataState {
|
|
|
34
35
|
schemaVersion: string;
|
|
35
36
|
errors: IErrorItem[];
|
|
36
37
|
validated: boolean;
|
|
38
|
+
contentFilters: Record<string, IStructuredDataQueryValues> | null;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
export const initialState = {
|
|
@@ -51,6 +53,7 @@ export const initialState = {
|
|
|
51
53
|
schemaVersion: "",
|
|
52
54
|
errors: [],
|
|
53
55
|
validated: false,
|
|
56
|
+
contentFilters: null,
|
|
54
57
|
};
|
|
55
58
|
|
|
56
59
|
export function reducer(state = initialState, action: StructuredDataActionsCreators): IStructuredDataState {
|
|
@@ -70,6 +73,7 @@ export function reducer(state = initialState, action: StructuredDataActionsCreat
|
|
|
70
73
|
case SET_SCHEMA_VERSION:
|
|
71
74
|
case SET_ERRORS:
|
|
72
75
|
case SET_VALIDATED:
|
|
76
|
+
case SET_CONTENT_FILTERS:
|
|
73
77
|
return { ...state, ...action.payload };
|
|
74
78
|
default:
|
|
75
79
|
return state;
|
package/src/helpers/fields.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import * as components from "@ax/components/Fields";
|
|
2
2
|
|
|
3
|
-
const getFieldByPath = (name: string) =>
|
|
3
|
+
const getFieldByPath = (name: string): (() => JSX.Element) => (components as Record<string, any>)[name];
|
|
4
4
|
|
|
5
5
|
export { getFieldByPath };
|
package/src/helpers/index.tsx
CHANGED
|
@@ -99,6 +99,8 @@ import { isDevelopment } from "./environment";
|
|
|
99
99
|
|
|
100
100
|
import { getDefaultTheme } from "./themes";
|
|
101
101
|
|
|
102
|
+
import { parseTheme } from "./parseTheme";
|
|
103
|
+
|
|
102
104
|
export {
|
|
103
105
|
isComponentEmpty,
|
|
104
106
|
setAsContainedComponent,
|
|
@@ -180,4 +182,5 @@ export {
|
|
|
180
182
|
getDefaultNavigationModules,
|
|
181
183
|
isMultipleNavigationModules,
|
|
182
184
|
areEqual,
|
|
185
|
+
parseTheme,
|
|
183
186
|
};
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
const procUnit = (u, fn) => {
|
|
2
|
+
const unitLess = parseFloat(u.match(/\d*\.?\d*/)[0]);
|
|
3
|
+
const unit = u.split(unitLess.toString())[1];
|
|
4
|
+
const unitLessProccesed = fn(unitLess);
|
|
5
|
+
return `${unitLessProccesed}${unit}`;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const halfUnit = (u) => {
|
|
9
|
+
return procUnit(u, (n) => n / 2);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* hexToRGBA
|
|
14
|
+
* Convierte un color en formato Hexadecimal a formato RGBA
|
|
15
|
+
* @param {string} hex El color en formato hexadecimal
|
|
16
|
+
* @param {number} opacity La valor de opacidad del color, de 0 a 1
|
|
17
|
+
* @example
|
|
18
|
+
* Convierte el color #FFFFFF a RGBA()
|
|
19
|
+
* hexToRGBA("#FFFFFF", 0.5)
|
|
20
|
+
* -> "rgba(255, 255, 255, 0.5)"
|
|
21
|
+
*
|
|
22
|
+
* @return {string} Una cadena con el valor rgba dentro de rgba()
|
|
23
|
+
*/
|
|
24
|
+
const hexToRGBA = (hex, opacity = 1.0) => {
|
|
25
|
+
const clearHex = hex[0] === "#" ? hex.substring(1, 7) : hex;
|
|
26
|
+
const hexToR = parseInt(clearHex.substring(0, 2), 16);
|
|
27
|
+
const hexToG = parseInt(clearHex.substring(2, 4), 16);
|
|
28
|
+
const hexToB = parseInt(clearHex.substring(4, 6), 16);
|
|
29
|
+
return `rgba(${hexToR}, ${hexToG}, ${hexToB}, ${opacity})`;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* isDifferent
|
|
34
|
+
* Comprueba si value1 y value2 son iguales, en caso negativo devuelve una cadena
|
|
35
|
+
* con el valor `value2` asociado a la `prop` (css).
|
|
36
|
+
* Si son iguales devuelve una cadena vacía.
|
|
37
|
+
*
|
|
38
|
+
* Esta función se usa para construir una especia de cascada (a lo css) al
|
|
39
|
+
* construir los estilos de textos responsive. Así si hay una nueva proiedad
|
|
40
|
+
* con un valor diferente
|
|
41
|
+
*
|
|
42
|
+
* @param {string} prop La propiedad css que compara
|
|
43
|
+
* @param {string} value1 El primera valor de la prop
|
|
44
|
+
* @param {string} value2 El segundo valor de la prop
|
|
45
|
+
* @example
|
|
46
|
+
* Compara el font-size
|
|
47
|
+
* isDifferent("font-size", "24px", "24px")
|
|
48
|
+
* -> ""
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* Compara el font-size
|
|
52
|
+
* isDifferent("font-size", "10px", "32px")
|
|
53
|
+
* -> "font-size: 32px"
|
|
54
|
+
*
|
|
55
|
+
* @return {string} Una cadena con la propiedad y el valor nuevo, o una cadena
|
|
56
|
+
* vacía, si los valores son iguales.
|
|
57
|
+
*/
|
|
58
|
+
const isDifferent = (prop, value1, value2) => {
|
|
59
|
+
if (value2) {
|
|
60
|
+
if (value1 === value2) {
|
|
61
|
+
return "";
|
|
62
|
+
} else {
|
|
63
|
+
return `${prop}: ${value2};`;
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* has
|
|
72
|
+
* Determina si existe en el archivo .json una propiedad.
|
|
73
|
+
* Si existe devuelve el par "prop: value", si no busca la proiedad en el
|
|
74
|
+
* apartado defaultStyles y la devuelve. Si tampoco existe ahí, devuelve ""
|
|
75
|
+
*
|
|
76
|
+
* @param {string} prop La propiedad css
|
|
77
|
+
* @param {string} value El valor de la propiedad css
|
|
78
|
+
* @param {string} fallBackValue El valor de la propiedad css en caso de no
|
|
79
|
+
* existir la propiedad value
|
|
80
|
+
*/
|
|
81
|
+
const has = (prop, value, fallBackValue) => {
|
|
82
|
+
if (value) {
|
|
83
|
+
return `${prop}: ${value};`;
|
|
84
|
+
}
|
|
85
|
+
if (fallBackValue) {
|
|
86
|
+
return `${prop}: ${fallBackValue};`;
|
|
87
|
+
}
|
|
88
|
+
return "";
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* parseColors
|
|
93
|
+
* Parsea un objeto de colors con la siguiente estructura
|
|
94
|
+
* {
|
|
95
|
+
* color: {
|
|
96
|
+
* colors: {
|
|
97
|
+
* colorName1: {
|
|
98
|
+
* value: "#ffffff",
|
|
99
|
+
* opacity: "1"
|
|
100
|
+
* },
|
|
101
|
+
* colorName2: {
|
|
102
|
+
* value: "#ffffff",
|
|
103
|
+
* opacity: "1"
|
|
104
|
+
* },
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
* }
|
|
108
|
+
* @param {object} theme El tema
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
const parseColors = (theme) => {
|
|
112
|
+
try {
|
|
113
|
+
const colors = theme.color.colors;
|
|
114
|
+
const color = Object.keys(colors).reduce((acc, label) => {
|
|
115
|
+
const isOpaque = (entry) => entry.opacity === 1 || entry.opacity === undefined || entry.opacity === null;
|
|
116
|
+
const _isHEX = (entry) => {
|
|
117
|
+
try {
|
|
118
|
+
return entry.value[0] === "#";
|
|
119
|
+
} catch (e) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const _isHSL = (entry) => {
|
|
124
|
+
try {
|
|
125
|
+
return entry.type.toLowerCase() === "hsl";
|
|
126
|
+
} catch (e) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const _isRGB = (entry) => {
|
|
131
|
+
try {
|
|
132
|
+
return entry.type.toLowerCase() === "rgb";
|
|
133
|
+
} catch (e) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const isHSL = (entry) => _isHSL(entry) && isOpaque(entry);
|
|
138
|
+
const isHSLA = (entry) => _isHSL(entry) && !isOpaque(entry);
|
|
139
|
+
const isHEX = (entry) => _isHEX(entry) && isOpaque(entry);
|
|
140
|
+
const isHEXA = (entry) => _isHEX(entry) && !isOpaque(entry);
|
|
141
|
+
const isRGB = (entry) => _isRGB(entry) && isOpaque(entry);
|
|
142
|
+
const isRGBA = (entry) => _isRGB(entry) && !isOpaque(entry);
|
|
143
|
+
|
|
144
|
+
if (isHSLA(colors[label])) {
|
|
145
|
+
acc[label] = `hsla(${colors[label].value
|
|
146
|
+
.map((v, idx) => `${idx === 0 ? v : typeof v === "string" ? (v.indexOf("%") === -1 ? v + "%" : v) : v + "%"}`)
|
|
147
|
+
.join(", ")}, ${colors[label].opacity})`;
|
|
148
|
+
}
|
|
149
|
+
if (isHSL(colors[label])) {
|
|
150
|
+
acc[label] = `hsl(${colors[label].value
|
|
151
|
+
.map((v, idx) => `${idx === 0 ? v : typeof v === "string" ? (v.indexOf("%") === -1 ? v + "%" : v) : v + "%"}`)
|
|
152
|
+
.join(", ")})`;
|
|
153
|
+
}
|
|
154
|
+
if (isHEX(colors[label])) {
|
|
155
|
+
acc[label] = `${colors[label].value}`;
|
|
156
|
+
}
|
|
157
|
+
if (isHEXA(colors[label])) {
|
|
158
|
+
acc[label] = `${hexToRGBA(colors[label].value, colors[label].opacity)}`;
|
|
159
|
+
}
|
|
160
|
+
if (isRGB(colors[label])) {
|
|
161
|
+
acc[label] = `rgb(${colors[label].value.join(", ")})`;
|
|
162
|
+
}
|
|
163
|
+
if (isRGBA(colors[label])) {
|
|
164
|
+
acc[label] = `rgba(${colors[label].value.join(", ")}, ${colors[label].opacity})`;
|
|
165
|
+
}
|
|
166
|
+
return acc;
|
|
167
|
+
}, {});
|
|
168
|
+
|
|
169
|
+
// Autogenerador
|
|
170
|
+
// color.interactiveMain = color.interactiveMain ? "#fff" : "#000"
|
|
171
|
+
|
|
172
|
+
return color;
|
|
173
|
+
} catch (e) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const parseGradients = (theme) => {
|
|
179
|
+
try {
|
|
180
|
+
const gradients = theme.gradient.gradients;
|
|
181
|
+
const gradient = Object.keys(gradients).reduce((acc, label) => {
|
|
182
|
+
acc[label] = `linear-gradient(${gradients[label].direction}, ${gradients[label].stops
|
|
183
|
+
.map((stop) => `${hexToRGBA(stop.color, stop.opacity)} ${stop.position}`)
|
|
184
|
+
.join(",")})`;
|
|
185
|
+
return acc;
|
|
186
|
+
}, {});
|
|
187
|
+
return gradient;
|
|
188
|
+
} catch (e) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const parseShadows = (theme) => {
|
|
194
|
+
try {
|
|
195
|
+
const shadows = theme.shadow.shadows;
|
|
196
|
+
const shadow = Object.keys(shadows).reduce((acc, label) => {
|
|
197
|
+
acc[label] = `${shadows[label].x}px ${shadows[label].y}px ${shadows[label].blur}px ${hexToRGBA(
|
|
198
|
+
shadows[label].color,
|
|
199
|
+
shadows[label].opacity
|
|
200
|
+
)}`;
|
|
201
|
+
return acc;
|
|
202
|
+
}, {});
|
|
203
|
+
return shadow;
|
|
204
|
+
} catch (e) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const parseMediaqueries = (theme) => {
|
|
210
|
+
try {
|
|
211
|
+
const mediaqueries = theme.mediaquery.mediaqueries;
|
|
212
|
+
let mqObject = {};
|
|
213
|
+
mediaqueries.forEach((mq) => {
|
|
214
|
+
if (mq.label !== "default") {
|
|
215
|
+
const minWidth = mq.minWidth ? `and (min-width: ${mq.minWidth})` : "";
|
|
216
|
+
const maxWidth = mq.maxWidth ? `and (max-width: ${mq.maxWidth})` : "";
|
|
217
|
+
mqObject[mq.label] = `@media only screen ${minWidth} ${maxWidth}`;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
return mqObject;
|
|
222
|
+
} catch (e) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const parseFontFamilies = (theme) => {
|
|
228
|
+
try {
|
|
229
|
+
return theme.fontFamily.fontFamilies;
|
|
230
|
+
} catch (e) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const getUnitValue = (x) => {
|
|
236
|
+
if (typeof x === "string") {
|
|
237
|
+
return x.match(/\d*\.?\d+?/)[0];
|
|
238
|
+
}
|
|
239
|
+
if (typeof x === "number") {
|
|
240
|
+
return x;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const cropText = (top, bottom) => {
|
|
245
|
+
return `
|
|
246
|
+
&::before, &::after {
|
|
247
|
+
content: "";
|
|
248
|
+
display: block;
|
|
249
|
+
}
|
|
250
|
+
&::before {
|
|
251
|
+
margin-bottom: ${bottom}em;
|
|
252
|
+
}
|
|
253
|
+
&::after {
|
|
254
|
+
margin-top: ${top}em;
|
|
255
|
+
}
|
|
256
|
+
`;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export const parseTextStyles = (theme) => {
|
|
260
|
+
try {
|
|
261
|
+
// Space object for rebass grid.
|
|
262
|
+
const mq = parseMediaqueries(theme);
|
|
263
|
+
const fontFamily = parseFontFamilies(theme);
|
|
264
|
+
|
|
265
|
+
// With process
|
|
266
|
+
const defaultStyles = theme.textStyle.defaultStyles;
|
|
267
|
+
const textStyles = theme.textStyle.textStyles;
|
|
268
|
+
|
|
269
|
+
// fontRes
|
|
270
|
+
let textStyleObject = {};
|
|
271
|
+
textStyles.forEach((style) => {
|
|
272
|
+
let FONTSIZE = getUnitValue(style.fontSize);
|
|
273
|
+
let CROPTOP = style.croptop !== undefined ? style.croptop : 0;
|
|
274
|
+
let CROPBOTTOM = style.cropbottom !== undefined ? style.cropbottom : 0;
|
|
275
|
+
let dynCropTop = (Math.max(CROPTOP + (1 - 1) * (FONTSIZE / 2), 0) / FONTSIZE) * -1;
|
|
276
|
+
let dynCropBottom = (Math.max(CROPBOTTOM + (1 - 1) * (FONTSIZE / 2), 0) / FONTSIZE) * -1;
|
|
277
|
+
textStyleObject[style.name] = `
|
|
278
|
+
|
|
279
|
+
${has("font-family", fontFamily[style.fontFamily], fontFamily[defaultStyles.fontFamily])}
|
|
280
|
+
${has("font-size", style.fontSize, defaultStyles.fontSize)}
|
|
281
|
+
${has("font-weight", style.fontWeight, defaultStyles.fontWeight)}
|
|
282
|
+
${has("letter-spacing", style.letterSpacing, defaultStyles.letterSpacing)}
|
|
283
|
+
${has("line-height", style.lineHeight, defaultStyles.lineHeight)}
|
|
284
|
+
${has("font-style", style.fontStyle, defaultStyles.fontStyle)}
|
|
285
|
+
${has("text-transform", style.textTransform, defaultStyles.textTransform)}
|
|
286
|
+
${CROPTOP && CROPBOTTOM ? cropText(dynCropTop, dynCropBottom) : ""}
|
|
287
|
+
|
|
288
|
+
${
|
|
289
|
+
style.responsive
|
|
290
|
+
? style.responsive
|
|
291
|
+
.map((bp, idx) => {
|
|
292
|
+
FONTSIZE = getUnitValue(bp.fontSize);
|
|
293
|
+
CROPTOP = bp.croptop !== undefined ? bp.croptop : 0;
|
|
294
|
+
CROPBOTTOM = bp.cropbottom !== undefined ? bp.cropbottom : 0;
|
|
295
|
+
dynCropTop = (Math.max(CROPTOP + (1 - 1) * (FONTSIZE / 2), 0) / FONTSIZE) * -1;
|
|
296
|
+
dynCropBottom = (Math.max(CROPBOTTOM + (1 - 1) * (FONTSIZE / 2), 0) / FONTSIZE) * -1;
|
|
297
|
+
if (idx < 1) {
|
|
298
|
+
// En el primer ciclo se compara con el breakpoint base: style
|
|
299
|
+
return `
|
|
300
|
+
${mq[bp.breakpoint]} {
|
|
301
|
+
${isDifferent("font-family", fontFamily[style.fontFamily], fontFamily[bp.fontFamily])}
|
|
302
|
+
${isDifferent("font-size", style.fontSize, bp.fontSize)}
|
|
303
|
+
${isDifferent("font-weight", style.fontWeight, bp.fontWeight)}
|
|
304
|
+
${isDifferent("line-height", style.lineHeight, bp.lineHeight)}
|
|
305
|
+
${isDifferent("letter-spacing", style.letterSpacing, bp.letterSpacing)}
|
|
306
|
+
${isDifferent("font-style", style.fontStyle, bp.fontStyle)}
|
|
307
|
+
${isDifferent("text-transform", style.textTransform, bp.textTransform)}
|
|
308
|
+
${CROPTOP && CROPBOTTOM ? cropText(dynCropTop, dynCropBottom) : ""}
|
|
309
|
+
}
|
|
310
|
+
`;
|
|
311
|
+
} else {
|
|
312
|
+
// A partir del segundo ciclo se compara con el breakpoint anterior
|
|
313
|
+
FONTSIZE = getUnitValue(bp.fontSize);
|
|
314
|
+
CROPTOP = bp.croptop !== undefined ? bp.croptop : 0;
|
|
315
|
+
CROPBOTTOM = bp.cropbottom !== undefined ? bp.cropbottom : 0;
|
|
316
|
+
dynCropTop = (Math.max(CROPTOP + (1 - 1) * (FONTSIZE / 2), 0) / FONTSIZE) * -1;
|
|
317
|
+
dynCropBottom = (Math.max(CROPBOTTOM + (1 - 1) * (FONTSIZE / 2), 0) / FONTSIZE) * -1;
|
|
318
|
+
return `
|
|
319
|
+
${mq[bp.breakpoint]} {
|
|
320
|
+
${isDifferent("font-family", fontFamily[style.responsive[idx - 1].fontFamily], fontFamily[bp.fontFamily])}
|
|
321
|
+
${isDifferent("font-size", style.responsive[idx - 1].fontSize, bp.fontSize)}
|
|
322
|
+
${isDifferent("font-weight", style.responsive[idx - 1].fontWeight, bp.fontWeight)}
|
|
323
|
+
${isDifferent("line-height", style.responsive[idx - 1].lineHeight, bp.lineHeight)}
|
|
324
|
+
${isDifferent("letter-spacing", style.responsive[idx - 1].letterSpacing, bp.letterSpacing)}
|
|
325
|
+
${isDifferent("font-style", style.responsive[idx - 1].fontStyle, bp.fontStyle)}
|
|
326
|
+
${isDifferent("text-transform", style.responsive[idx - 1].textTransform, bp.textTransform)}
|
|
327
|
+
${CROPTOP && CROPBOTTOM ? cropText(dynCropTop, dynCropBottom) : ""}
|
|
328
|
+
}
|
|
329
|
+
`;
|
|
330
|
+
}
|
|
331
|
+
})
|
|
332
|
+
.join("")
|
|
333
|
+
: ""
|
|
334
|
+
}
|
|
335
|
+
`;
|
|
336
|
+
// End
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
return textStyleObject;
|
|
340
|
+
} catch (e) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
const parseBreakpoints = (theme) => {
|
|
346
|
+
try {
|
|
347
|
+
// return Object.fromEntries(Object.entries(theme.mediaquery.mediaqueries.map(bp => bp.minWidth).filter(Boolean)))
|
|
348
|
+
return theme.mediaquery.mediaqueries.map((bp) => bp.minWidth).filter(Boolean);
|
|
349
|
+
} catch (e) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const parseFontSizes = (theme) => {
|
|
355
|
+
try {
|
|
356
|
+
return [
|
|
357
|
+
...new Set(
|
|
358
|
+
theme.textStyle.textStyles
|
|
359
|
+
.map((entry) => entry.fontSize)
|
|
360
|
+
.filter(Boolean)
|
|
361
|
+
.reverse()
|
|
362
|
+
.map((entry) => Number(entry.split("px")[0]))
|
|
363
|
+
.sort((a, b) => a - b)
|
|
364
|
+
),
|
|
365
|
+
];
|
|
366
|
+
} catch (e) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
const parseNegativeSpacing = (theme) => {
|
|
372
|
+
const getNegative = (v) => `-${v}`;
|
|
373
|
+
if (theme.spacing) {
|
|
374
|
+
if (Object.keys(theme.spacing).length) {
|
|
375
|
+
return Object.entries(theme.spacing).reduce(
|
|
376
|
+
(prev, [key, value]) => ({
|
|
377
|
+
...prev,
|
|
378
|
+
[key]: typeof value === "string" ? getNegative(value) : undefined,
|
|
379
|
+
}),
|
|
380
|
+
{}
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
const parseHalfSpacing = (theme) => {
|
|
387
|
+
if (theme.spacing) {
|
|
388
|
+
if (Object.keys(theme.spacing).length) {
|
|
389
|
+
return Object.entries(theme.spacing).reduce(
|
|
390
|
+
(prev, [key, value]) => ({
|
|
391
|
+
...prev,
|
|
392
|
+
[key]: typeof value === "string" ? halfUnit(value) : undefined,
|
|
393
|
+
}),
|
|
394
|
+
{}
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
const parseNegativeHalfSpacing = (theme) => {
|
|
401
|
+
const getNegative = (v) => `-${v}`;
|
|
402
|
+
if (theme.spacing) {
|
|
403
|
+
if (Object.keys(theme.spacing).length) {
|
|
404
|
+
return Object.entries(theme.spacing).reduce(
|
|
405
|
+
(prev, [key, value]) => ({
|
|
406
|
+
...prev,
|
|
407
|
+
[key]: typeof value === "string" ? getNegative(halfUnit(value)) : undefined,
|
|
408
|
+
}),
|
|
409
|
+
{}
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
const parseTheme = (theme) => {
|
|
416
|
+
// Añadir también al parseo de temas todos los elementos que no necesiten ser
|
|
417
|
+
// paseados.
|
|
418
|
+
|
|
419
|
+
const color = parseColors(theme);
|
|
420
|
+
const gradient = parseGradients(theme);
|
|
421
|
+
const shadow = parseShadows(theme);
|
|
422
|
+
const mq = parseMediaqueries(theme);
|
|
423
|
+
const textStyle = parseTextStyles(theme);
|
|
424
|
+
const breakpoints = parseBreakpoints(theme);
|
|
425
|
+
const fontFamily = parseFontFamilies(theme);
|
|
426
|
+
|
|
427
|
+
// Breakpoints alias.
|
|
428
|
+
// De esta manera se pueden utilizar las props responsive así:
|
|
429
|
+
// <Text display={{small:"none", xlarge:"block"}} >...</Text>
|
|
430
|
+
try {
|
|
431
|
+
theme.mediaquery.mediaqueries.forEach((mq) => {
|
|
432
|
+
breakpoints[mq.label] = mq.minWidth;
|
|
433
|
+
});
|
|
434
|
+
} catch (e) {
|
|
435
|
+
//
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const returnObject = {
|
|
439
|
+
...theme,
|
|
440
|
+
fontFamily,
|
|
441
|
+
color,
|
|
442
|
+
colors: color,
|
|
443
|
+
gradient,
|
|
444
|
+
shadow,
|
|
445
|
+
mq,
|
|
446
|
+
textStyle,
|
|
447
|
+
breakpoints,
|
|
448
|
+
fontSizes: parseFontSizes(theme),
|
|
449
|
+
negateSpacing: parseNegativeSpacing(theme),
|
|
450
|
+
halfSpacing: parseHalfSpacing(theme),
|
|
451
|
+
negateHalfSpacing: parseNegativeHalfSpacing(theme),
|
|
452
|
+
};
|
|
453
|
+
return returnObject;
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
export { parseTheme };
|
package/src/helpers/schemas.tsx
CHANGED
|
@@ -6,10 +6,10 @@ import { pageSchemas } from "@ax/schemas";
|
|
|
6
6
|
const allSchemas = { ...schemas.all, ...pageSchemas };
|
|
7
7
|
|
|
8
8
|
const getSchema = (name: string) => allSchemas[name];
|
|
9
|
-
const getDefaultSchema = (name: string) => allSchemas[name].default;
|
|
9
|
+
const getDefaultSchema = (name: string) => (allSchemas[name] ? allSchemas[name].default : {});
|
|
10
10
|
|
|
11
11
|
const getSchemaThumbnails = (name: string, theme?: string) => {
|
|
12
|
-
if (!allSchemas[name]
|
|
12
|
+
if (!allSchemas[name]?.thumbnails) return null;
|
|
13
13
|
|
|
14
14
|
return theme && allSchemas[name].thumbnails[theme] ? allSchemas[name].thumbnails[theme] : allSchemas[name].thumbnails;
|
|
15
15
|
};
|