@griddo/ax 1.57.22 → 1.58.3
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/package.json +3 -3
- package/public/fonts/fonts.css +276 -1134
- package/src/Style/fonts.tsx +28 -1522
- package/src/Style/index.tsx +1 -2
- package/src/api/sites.tsx +7 -4
- package/src/api/structuredData.tsx +19 -0
- package/src/components/Browser/index.tsx +2 -2
- package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +11 -12
- package/src/components/Fields/ReferenceField/Context/index.tsx +46 -27
- package/src/components/Fields/ReferenceField/ItemList/Item/index.tsx +1 -1
- package/src/components/Fields/ReferenceField/ItemList/index.tsx +6 -6
- package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +9 -9
- package/src/components/Fields/ReferenceField/index.tsx +33 -36
- package/src/components/Fields/Select/style.tsx +0 -1
- package/src/components/Fields/UrlField/PageFinder/SelectionListItem/index.tsx +3 -1
- package/src/components/Fields/UrlField/PageFinder/index.tsx +73 -13
- package/src/components/Fields/UrlField/PageFinder/style.tsx +33 -1
- package/src/components/Fields/UrlField/index.tsx +6 -1
- package/src/components/MainWrapper/AppBar/style.tsx +1 -0
- package/src/components/SubNav/style.tsx +1 -1
- package/src/containers/StructuredData/actions.tsx +5 -2
- package/src/forms/validators.tsx +9 -10
- package/src/global.d.ts +2 -0
- package/src/hooks/forms.tsx +7 -0
- package/src/modules/App/Routing/NavMenu/style.tsx +0 -1
- package/src/modules/Content/ContentFilters/style.tsx +2 -2
- package/src/modules/Navigation/Defaults/Nav/style.tsx +2 -2
- package/src/modules/PageEditor/index.tsx +2 -5
- package/src/modules/Settings/ContentTypes/DataPacks/Nav/style.tsx +2 -2
- package/src/modules/StructuredData/StructuredDataList/ContentFilters/style.tsx +2 -2
- package/src/types/index.tsx +24 -0
- package/public/fonts/Montserrat-100-cyrillic-ext1.woff2 +0 -0
- package/public/fonts/Montserrat-100-cyrillic-ext46.woff2 +0 -0
- package/public/fonts/Montserrat-100-cyrillic2.woff2 +0 -0
- package/public/fonts/Montserrat-100-cyrillic47.woff2 +0 -0
- package/public/fonts/Montserrat-100-latin-ext4.woff2 +0 -0
- package/public/fonts/Montserrat-100-latin-ext49.woff2 +0 -0
- package/public/fonts/Montserrat-100-latin5.woff2 +0 -0
- package/public/fonts/Montserrat-100-latin50.woff2 +0 -0
- package/public/fonts/Montserrat-100-vietnamese3.woff2 +0 -0
- package/public/fonts/Montserrat-100-vietnamese48.woff2 +0 -0
- package/public/fonts/Montserrat-200-cyrillic-ext51.woff2 +0 -0
- package/public/fonts/Montserrat-200-cyrillic-ext6.woff2 +0 -0
- package/public/fonts/Montserrat-200-cyrillic52.woff2 +0 -0
- package/public/fonts/Montserrat-200-cyrillic7.woff2 +0 -0
- package/public/fonts/Montserrat-200-latin-ext54.woff2 +0 -0
- package/public/fonts/Montserrat-200-latin-ext9.woff2 +0 -0
- package/public/fonts/Montserrat-200-latin10.woff2 +0 -0
- package/public/fonts/Montserrat-200-latin55.woff2 +0 -0
- package/public/fonts/Montserrat-200-vietnamese53.woff2 +0 -0
- package/public/fonts/Montserrat-200-vietnamese8.woff2 +0 -0
- package/public/fonts/Montserrat-300-cyrillic-ext11.woff2 +0 -0
- package/public/fonts/Montserrat-300-cyrillic-ext56.woff2 +0 -0
- package/public/fonts/Montserrat-300-cyrillic12.woff2 +0 -0
- package/public/fonts/Montserrat-300-cyrillic57.woff2 +0 -0
- package/public/fonts/Montserrat-300-latin-ext14.woff2 +0 -0
- package/public/fonts/Montserrat-300-latin-ext59.woff2 +0 -0
- package/public/fonts/Montserrat-300-latin15.woff2 +0 -0
- package/public/fonts/Montserrat-300-latin60.woff2 +0 -0
- package/public/fonts/Montserrat-300-vietnamese13.woff2 +0 -0
- package/public/fonts/Montserrat-300-vietnamese58.woff2 +0 -0
- package/public/fonts/Montserrat-400-cyrillic-ext16.woff2 +0 -0
- package/public/fonts/Montserrat-400-cyrillic-ext61.woff2 +0 -0
- package/public/fonts/Montserrat-400-cyrillic17.woff2 +0 -0
- package/public/fonts/Montserrat-400-cyrillic62.woff2 +0 -0
- package/public/fonts/Montserrat-400-latin-ext19.woff2 +0 -0
- package/public/fonts/Montserrat-400-latin-ext64.woff2 +0 -0
- package/public/fonts/Montserrat-400-latin20.woff2 +0 -0
- package/public/fonts/Montserrat-400-latin65.woff2 +0 -0
- package/public/fonts/Montserrat-400-vietnamese18.woff2 +0 -0
- package/public/fonts/Montserrat-400-vietnamese63.woff2 +0 -0
- package/public/fonts/Montserrat-500-cyrillic-ext21.woff2 +0 -0
- package/public/fonts/Montserrat-500-cyrillic-ext66.woff2 +0 -0
- package/public/fonts/Montserrat-500-cyrillic22.woff2 +0 -0
- package/public/fonts/Montserrat-500-cyrillic67.woff2 +0 -0
- package/public/fonts/Montserrat-500-latin-ext24.woff2 +0 -0
- package/public/fonts/Montserrat-500-latin-ext69.woff2 +0 -0
- package/public/fonts/Montserrat-500-latin25.woff2 +0 -0
- package/public/fonts/Montserrat-500-latin70.woff2 +0 -0
- package/public/fonts/Montserrat-500-vietnamese23.woff2 +0 -0
- package/public/fonts/Montserrat-500-vietnamese68.woff2 +0 -0
- package/public/fonts/Montserrat-600-cyrillic-ext26.woff2 +0 -0
- package/public/fonts/Montserrat-600-cyrillic-ext71.woff2 +0 -0
- package/public/fonts/Montserrat-600-cyrillic27.woff2 +0 -0
- package/public/fonts/Montserrat-600-cyrillic72.woff2 +0 -0
- package/public/fonts/Montserrat-600-latin-ext29.woff2 +0 -0
- package/public/fonts/Montserrat-600-latin-ext74.woff2 +0 -0
- package/public/fonts/Montserrat-600-latin30.woff2 +0 -0
- package/public/fonts/Montserrat-600-latin75.woff2 +0 -0
- package/public/fonts/Montserrat-600-vietnamese28.woff2 +0 -0
- package/public/fonts/Montserrat-600-vietnamese73.woff2 +0 -0
- package/public/fonts/Montserrat-700-cyrillic-ext31.woff2 +0 -0
- package/public/fonts/Montserrat-700-cyrillic-ext76.woff2 +0 -0
- package/public/fonts/Montserrat-700-cyrillic32.woff2 +0 -0
- package/public/fonts/Montserrat-700-cyrillic77.woff2 +0 -0
- package/public/fonts/Montserrat-700-latin-ext34.woff2 +0 -0
- package/public/fonts/Montserrat-700-latin-ext79.woff2 +0 -0
- package/public/fonts/Montserrat-700-latin35.woff2 +0 -0
- package/public/fonts/Montserrat-700-latin80.woff2 +0 -0
- package/public/fonts/Montserrat-700-vietnamese33.woff2 +0 -0
- package/public/fonts/Montserrat-700-vietnamese78.woff2 +0 -0
- package/public/fonts/Montserrat-800-cyrillic-ext36.woff2 +0 -0
- package/public/fonts/Montserrat-800-cyrillic-ext81.woff2 +0 -0
- package/public/fonts/Montserrat-800-cyrillic37.woff2 +0 -0
- package/public/fonts/Montserrat-800-cyrillic82.woff2 +0 -0
- package/public/fonts/Montserrat-800-latin-ext39.woff2 +0 -0
- package/public/fonts/Montserrat-800-latin-ext84.woff2 +0 -0
- package/public/fonts/Montserrat-800-latin40.woff2 +0 -0
- package/public/fonts/Montserrat-800-latin85.woff2 +0 -0
- package/public/fonts/Montserrat-800-vietnamese38.woff2 +0 -0
- package/public/fonts/Montserrat-800-vietnamese83.woff2 +0 -0
- package/public/fonts/Montserrat-900-cyrillic-ext41.woff2 +0 -0
- package/public/fonts/Montserrat-900-cyrillic-ext86.woff2 +0 -0
- package/public/fonts/Montserrat-900-cyrillic42.woff2 +0 -0
- package/public/fonts/Montserrat-900-cyrillic87.woff2 +0 -0
- package/public/fonts/Montserrat-900-latin-ext44.woff2 +0 -0
- package/public/fonts/Montserrat-900-latin-ext89.woff2 +0 -0
- package/public/fonts/Montserrat-900-latin45.woff2 +0 -0
- package/public/fonts/Montserrat-900-latin90.woff2 +0 -0
- package/public/fonts/Montserrat-900-vietnamese43.woff2 +0 -0
- package/public/fonts/Montserrat-900-vietnamese88.woff2 +0 -0
- package/public/fonts/PT_Serif-400-cyrillic-ext91.woff2 +0 -0
- package/public/fonts/PT_Serif-400-cyrillic-ext99.woff2 +0 -0
- package/public/fonts/PT_Serif-400-cyrillic100.woff2 +0 -0
- package/public/fonts/PT_Serif-400-cyrillic92.woff2 +0 -0
- package/public/fonts/PT_Serif-400-latin-ext101.woff2 +0 -0
- package/public/fonts/PT_Serif-400-latin-ext93.woff2 +0 -0
- package/public/fonts/PT_Serif-400-latin102.woff2 +0 -0
- package/public/fonts/PT_Serif-400-latin94.woff2 +0 -0
- package/public/fonts/PT_Serif-700-cyrillic-ext103.woff2 +0 -0
- package/public/fonts/PT_Serif-700-cyrillic-ext95.woff2 +0 -0
- package/public/fonts/PT_Serif-700-cyrillic104.woff2 +0 -0
- package/public/fonts/PT_Serif-700-cyrillic96.woff2 +0 -0
- package/public/fonts/PT_Serif-700-latin-ext105.woff2 +0 -0
- package/public/fonts/PT_Serif-700-latin-ext97.woff2 +0 -0
- package/public/fonts/PT_Serif-700-latin106.woff2 +0 -0
- package/public/fonts/PT_Serif-700-latin98.woff2 +0 -0
package/src/Style/index.tsx
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
import { ThemeProvider, createGlobalStyle } from "styled-components";
|
|
4
|
-
import {
|
|
4
|
+
import { parseTheme } from "@griddo/core";
|
|
5
5
|
import reset from "styled-reset";
|
|
6
6
|
import { normalize } from "polished";
|
|
7
7
|
import fonts from "./fonts";
|
|
8
8
|
import globalTheme from "../themes/theme.json";
|
|
9
9
|
|
|
10
|
-
const { parseTheme } = core;
|
|
11
10
|
const GlobalStyle = createGlobalStyle`
|
|
12
11
|
${reset}
|
|
13
12
|
${normalize()}
|
package/src/api/sites.tsx
CHANGED
|
@@ -226,20 +226,23 @@ const removePageBulk = async (siteID: number, ids: number[]): Promise<AxiosRespo
|
|
|
226
226
|
return sendRequest(SERVICES.REMOVE_PAGE_BULK, { ids });
|
|
227
227
|
};
|
|
228
228
|
|
|
229
|
-
const getSitePagesLight = async (params: IGetSitePagesParams) => {
|
|
229
|
+
const getSitePagesLight = async (params: IGetSitePagesParams): Promise<AxiosResponse> => {
|
|
230
230
|
const {
|
|
231
231
|
host,
|
|
232
232
|
endpoint: [prefix, suffix],
|
|
233
233
|
} = SERVICES.GET_SITE_PAGES_LIGHT;
|
|
234
234
|
|
|
235
|
-
const { siteID, deleted, page, itemsPerPage, query } = params;
|
|
235
|
+
const { siteID, deleted, page, itemsPerPage, query, lang, filterStructuredData } = params;
|
|
236
236
|
|
|
237
|
-
SERVICES.GET_SITE_PAGES_LIGHT.dynamicUrl = `${host}${prefix}${siteID}${suffix}?deleted=${deleted}&page=${page}&itemsPerPage=${itemsPerPage}`;
|
|
237
|
+
SERVICES.GET_SITE_PAGES_LIGHT.dynamicUrl = `${host}${prefix}${siteID}${suffix}?deleted=${deleted}&page=${page}&itemsPerPage=${itemsPerPage}&filterStructuredData=${filterStructuredData}`;
|
|
238
238
|
if (query) {
|
|
239
239
|
SERVICES.GET_SITE_PAGES_LIGHT.dynamicUrl = `${host}${prefix}${siteID}${suffix}?deleted=${deleted}&page=${page}&itemsPerPage=${itemsPerPage}&query=${query}`;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
const dataHeader = {} as { lang: number };
|
|
243
|
+
if (lang) dataHeader.lang = lang;
|
|
244
|
+
|
|
245
|
+
return sendRequest(SERVICES.GET_SITE_PAGES_LIGHT, null, dataHeader);
|
|
243
246
|
};
|
|
244
247
|
|
|
245
248
|
const getSiteImages = async (site: number | string, page: number, itemsPerPage: number | null, thumbWidth?: number, thumbHeight?: number, query?: string, search?: string): Promise<AxiosResponse> => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { template } from "./config";
|
|
2
2
|
import { IServiceConfig, sendRequest, sendInitialRequest } from "./utils";
|
|
3
3
|
import { IGetStructuredDataParams } from "@ax/types";
|
|
4
|
+
import { AxiosResponse } from "axios";
|
|
4
5
|
|
|
5
6
|
const SERVICES: { [key: string]: IServiceConfig } = {
|
|
6
7
|
GET_DATA: {
|
|
@@ -68,6 +69,11 @@ const SERVICES: { [key: string]: IServiceConfig } = {
|
|
|
68
69
|
endpoint: ["/structured_data_content/", "/bulk"],
|
|
69
70
|
method: "PUT",
|
|
70
71
|
},
|
|
72
|
+
GET_CONTENT_TYPES: {
|
|
73
|
+
...template,
|
|
74
|
+
endpoint: ["/site/", "/structured_data"],
|
|
75
|
+
method: "GET",
|
|
76
|
+
}
|
|
71
77
|
};
|
|
72
78
|
|
|
73
79
|
const getData = (token: string | null, siteID?: number | null) => {
|
|
@@ -182,6 +188,18 @@ const setDataStatusBulk = (dataContentID: number[], status: string) => {
|
|
|
182
188
|
return sendRequest(SERVICES.SET_DATA_STATUS_BULK, { ids: dataContentID });
|
|
183
189
|
};
|
|
184
190
|
|
|
191
|
+
const getContentTypes = (siteID: number | null, lang?: number): Promise<AxiosResponse> => {
|
|
192
|
+
const { host, endpoint } = SERVICES.GET_CONTENT_TYPES;
|
|
193
|
+
const [prefix, suffix] = endpoint;
|
|
194
|
+
|
|
195
|
+
SERVICES.GET_CONTENT_TYPES.dynamicUrl = `${host}${prefix}${siteID}${suffix}`;
|
|
196
|
+
|
|
197
|
+
const dataHeader = {} as { lang: number };
|
|
198
|
+
if (lang) dataHeader.lang = lang;
|
|
199
|
+
|
|
200
|
+
return sendRequest(SERVICES.GET_CONTENT_TYPES, null, dataHeader);
|
|
201
|
+
};
|
|
202
|
+
|
|
185
203
|
export default {
|
|
186
204
|
getData,
|
|
187
205
|
getDataContent,
|
|
@@ -196,4 +214,5 @@ export default {
|
|
|
196
214
|
restoreDataContentBulk,
|
|
197
215
|
setDataStatus,
|
|
198
216
|
setDataStatusBulk,
|
|
217
|
+
getContentTypes,
|
|
199
218
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
|
|
3
3
|
import * as components from "components";
|
|
4
|
-
import { providers,
|
|
4
|
+
import { providers, translations, cloudinaryDefaults } from "components";
|
|
5
|
+
import { Preview } from "@griddo/core";
|
|
5
6
|
|
|
6
7
|
import * as S from "./style";
|
|
7
8
|
|
|
@@ -11,7 +12,6 @@ const Browser = (props: IBrowserProps): JSX.Element => {
|
|
|
11
12
|
const API_URL = process.env.REACT_APP_API_ENDPOINT;
|
|
12
13
|
const PUBLIC_API_URL = process.env.REACT_APP_PUBLIC_API_ENDPOINT;
|
|
13
14
|
const { SiteProvider, AnimationProvider } = providers;
|
|
14
|
-
const { Preview } = core;
|
|
15
15
|
|
|
16
16
|
useEffect(() => {
|
|
17
17
|
localStorage.setItem("selectedID", "0");
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { IDataSource, ISite, IStructuredData } from "@ax/types";
|
|
4
|
-
|
|
5
4
|
import { Button, FloatingMenu, IconAction, RadioGroup, Select, FieldsBehavior } from "@ax/components";
|
|
6
|
-
import AutoItem from "./AutoItem";
|
|
7
5
|
|
|
6
|
+
import { IReferenceState, useReference } from "../Context";
|
|
7
|
+
import AutoItem from "./AutoItem";
|
|
8
8
|
import * as S from "./style";
|
|
9
9
|
|
|
10
10
|
const AutoPanel = (props: IProps): JSX.Element => {
|
|
11
|
-
const { onChange,
|
|
11
|
+
const { onChange, site, structuredData, validators } = props;
|
|
12
12
|
|
|
13
|
-
const { state, setState } =
|
|
13
|
+
const { state, setState } = useReference();
|
|
14
14
|
|
|
15
15
|
const init = state.quantity ? "number" : "all";
|
|
16
16
|
const [allItems, setAllItems] = useState<string | boolean>(init);
|
|
@@ -59,7 +59,7 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
59
59
|
];
|
|
60
60
|
|
|
61
61
|
const handleOrderDirection = (orderDirection: string) =>
|
|
62
|
-
setState(
|
|
62
|
+
setState((state: IReferenceState) => ({ ...state, orderDirection }));
|
|
63
63
|
|
|
64
64
|
const optionsOnSelect = (
|
|
65
65
|
<S.SelectWrapper>
|
|
@@ -79,7 +79,7 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
79
79
|
name: "Sort",
|
|
80
80
|
options,
|
|
81
81
|
value: state.order,
|
|
82
|
-
onChange: (order: string | boolean) => setState(
|
|
82
|
+
onChange: (order: string | boolean) => setState((state: IReferenceState) => ({ ...state, order })),
|
|
83
83
|
optionsOnSelect,
|
|
84
84
|
};
|
|
85
85
|
|
|
@@ -87,7 +87,7 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
87
87
|
fieldType: "NumberField",
|
|
88
88
|
title: "",
|
|
89
89
|
value: state.quantity,
|
|
90
|
-
onChange: (quantity: number) => setState(
|
|
90
|
+
onChange: (quantity: number) => setState((state: IReferenceState) => ({ ...state, quantity })),
|
|
91
91
|
maxValue: validators && validators.maxValue ? validators.maxValue : undefined,
|
|
92
92
|
minValue: validators && validators.minValue ? validators.minValue : undefined,
|
|
93
93
|
};
|
|
@@ -109,7 +109,7 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
109
109
|
if (!state.source.includes(value)) {
|
|
110
110
|
const newSources = state.source;
|
|
111
111
|
newSources.push(value);
|
|
112
|
-
setState(
|
|
112
|
+
setState((state: IReferenceState) => ({ ...state, source: newSources }));
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
|
|
@@ -142,12 +142,12 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
142
142
|
const removeItem = (item: string) => {
|
|
143
143
|
if (state.source.includes(item)) {
|
|
144
144
|
const newSources = state.source.filter((e: string) => e !== item);
|
|
145
|
-
setState(
|
|
145
|
+
setState((state: IReferenceState) => ({ ...state, source: newSources }));
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
const handleAddFilter = (newFilters: any[]) => {
|
|
150
|
-
setState(
|
|
150
|
+
setState((state: IReferenceState) => ({ ...state, filter: newFilters }));
|
|
151
151
|
};
|
|
152
152
|
|
|
153
153
|
const quantityOptions = [
|
|
@@ -166,7 +166,7 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
166
166
|
const handleItemsChange = (value: string | boolean) => {
|
|
167
167
|
setAllItems(value);
|
|
168
168
|
if (value === "all") {
|
|
169
|
-
setState(
|
|
169
|
+
setState((state: IReferenceState) => ({ ...state, quantity: 0 }));
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
|
|
@@ -214,7 +214,6 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
214
214
|
};
|
|
215
215
|
|
|
216
216
|
interface IProps {
|
|
217
|
-
context: any;
|
|
218
217
|
structuredData: { global: IStructuredData[]; site: IStructuredData[] };
|
|
219
218
|
onChange: (value: any) => void;
|
|
220
219
|
site: ISite;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, useState, useCallback } from "react";
|
|
1
|
+
import React, { createContext, useState, useCallback, useContext, ReactElement } from "react";
|
|
2
2
|
import { moveElement } from "@ax/forms";
|
|
3
3
|
|
|
4
4
|
const initState = {
|
|
@@ -16,52 +16,71 @@ const initState = {
|
|
|
16
16
|
sourceTitles: [],
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
const mode = modes && modes.length ? modes[0] : "auto";
|
|
21
|
-
const [state, setState] = useState({ state: { ...initState, mode } });
|
|
19
|
+
const ReferenceContext = createContext({ state: { ...initState } });
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const ReferenceProvider = ({ modes, children }: { modes?: string[], children: ReactElement }): JSX.Element => {
|
|
22
|
+
const reference = useReferenceProvider(modes);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ReferenceContext.Provider value={reference}>
|
|
26
|
+
{children}
|
|
27
|
+
</ReferenceContext.Provider>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const useReference = (): any => {
|
|
32
|
+
return useContext(ReferenceContext);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const useReferenceProvider = (modes?: string[]) => {
|
|
36
|
+
const mode = modes && modes.length ? modes[0] : "auto";
|
|
37
|
+
const [state, setState] = useState<IReferenceState>({ ...initState, mode });
|
|
26
38
|
|
|
27
39
|
const setModeAndSource = useCallback(
|
|
28
|
-
(mode: string, source:
|
|
40
|
+
(mode: string, source: never[]) => {
|
|
29
41
|
const defaultState = {
|
|
30
42
|
...state,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
mode,
|
|
34
|
-
source,
|
|
35
|
-
},
|
|
43
|
+
mode,
|
|
44
|
+
source,
|
|
36
45
|
};
|
|
37
|
-
|
|
46
|
+
setState(defaultState);
|
|
38
47
|
},
|
|
39
|
-
[
|
|
48
|
+
[setState, state]
|
|
40
49
|
);
|
|
41
50
|
|
|
42
51
|
const setReorderElements = (elementID: number, isPush: boolean) => {
|
|
43
|
-
const { selectedItems } = state
|
|
52
|
+
const { selectedItems } = state;
|
|
44
53
|
const newItems = moveElement(elementID, selectedItems, isPush, "id");
|
|
45
54
|
const fixed = newItems.map((item: any) => item.id);
|
|
46
|
-
const newState = {
|
|
55
|
+
const newState: IReferenceState = {
|
|
47
56
|
...state,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
selectedItems: newItems,
|
|
51
|
-
fixed,
|
|
52
|
-
},
|
|
57
|
+
selectedItems: newItems,
|
|
58
|
+
fixed,
|
|
53
59
|
};
|
|
54
|
-
|
|
60
|
+
setState(newState);
|
|
55
61
|
};
|
|
56
62
|
|
|
57
63
|
return {
|
|
58
|
-
...state,
|
|
59
|
-
setState
|
|
64
|
+
state: { ...state },
|
|
65
|
+
setState,
|
|
60
66
|
setModeAndSource,
|
|
61
67
|
setReorderElements,
|
|
62
68
|
};
|
|
63
69
|
};
|
|
64
70
|
|
|
65
|
-
|
|
71
|
+
export interface IReferenceState {
|
|
72
|
+
mode: string,
|
|
73
|
+
order: string,
|
|
74
|
+
orderDirection: string,
|
|
75
|
+
quantity: number,
|
|
76
|
+
items: any,
|
|
77
|
+
selectedItems: any,
|
|
78
|
+
fixed: any,
|
|
79
|
+
search: string,
|
|
80
|
+
showSelected: boolean,
|
|
81
|
+
source: any,
|
|
82
|
+
filter: any,
|
|
83
|
+
sourceTitles: any,
|
|
84
|
+
}
|
|
66
85
|
|
|
67
|
-
export {
|
|
86
|
+
export { ReferenceProvider, useReference };
|
|
@@ -56,7 +56,7 @@ const Item = (props: IProps) => {
|
|
|
56
56
|
<S.Item>
|
|
57
57
|
<S.TextWrapper>
|
|
58
58
|
<S.Header>
|
|
59
|
-
<S.Type>{source
|
|
59
|
+
<S.Type>{source?.title.toUpperCase()}</S.Type>
|
|
60
60
|
{item.modified && <S.Date>{getFormattedDateWithTimezone(item.modified, "d MMM Y")}</S.Date>}
|
|
61
61
|
<S.ReorderArrowsWrapper>
|
|
62
62
|
<ReorderArrows
|
|
@@ -6,12 +6,13 @@ import { IDataSource, IRootState, IStructuredDataContent } from "@ax/types";
|
|
|
6
6
|
import { isReqOk } from "@ax/helpers";
|
|
7
7
|
import Item from "./Item";
|
|
8
8
|
|
|
9
|
+
import { IReferenceState, useReference } from "../Context";
|
|
9
10
|
import * as S from "./style";
|
|
10
11
|
|
|
11
12
|
const ItemList = (props: IProps) => {
|
|
12
|
-
const { items, currentSite,
|
|
13
|
+
const { items, currentSite, handleListDelete, handleChange } = props;
|
|
13
14
|
|
|
14
|
-
const { state, setState, setReorderElements } =
|
|
15
|
+
const { state, setState, setReorderElements } = useReference();
|
|
15
16
|
|
|
16
17
|
useEffect(() => {
|
|
17
18
|
const params = {
|
|
@@ -23,14 +24,14 @@ const ItemList = (props: IProps) => {
|
|
|
23
24
|
const siteID = currentSite ? currentSite : "global";
|
|
24
25
|
const response = await structuredData.getDistributorContent(siteID, params);
|
|
25
26
|
if (isReqOk(response.status)) {
|
|
26
|
-
setState(
|
|
27
|
+
setState((state: IReferenceState) => ({ ...state, selectedItems: response.data }));
|
|
27
28
|
} else {
|
|
28
29
|
console.log("Error en getItems");
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
getItems();
|
|
32
33
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
}, []);
|
|
34
|
+
}, [items]);
|
|
34
35
|
|
|
35
36
|
useEffect(() => {
|
|
36
37
|
const { mode, fixed } = state;
|
|
@@ -46,7 +47,7 @@ const ItemList = (props: IProps) => {
|
|
|
46
47
|
if (state.fixed.includes(item.id)) {
|
|
47
48
|
const newSelIds = state.fixed.filter((a: any) => a !== item.id);
|
|
48
49
|
const selItems = state.selectedItems.filter((b: any) => b.id !== item.id);
|
|
49
|
-
setState(
|
|
50
|
+
setState((state: IReferenceState) => ({ ...state, fixed: newSelIds, selectedItems: selItems }));
|
|
50
51
|
handleListDelete(newSelIds);
|
|
51
52
|
}
|
|
52
53
|
};
|
|
@@ -75,7 +76,6 @@ const ItemList = (props: IProps) => {
|
|
|
75
76
|
interface IProps {
|
|
76
77
|
items: number[];
|
|
77
78
|
currentSite: number;
|
|
78
|
-
context: any;
|
|
79
79
|
handleListDelete(value: string[]): void;
|
|
80
80
|
handleChange(newValue: any): void;
|
|
81
81
|
}
|
|
@@ -8,13 +8,14 @@ import { Button, Loader, Select, TextField } from "@ax/components";
|
|
|
8
8
|
|
|
9
9
|
import { useDebounce } from "@ax/hooks";
|
|
10
10
|
|
|
11
|
+
import { IReferenceState, useReference } from "../Context";
|
|
11
12
|
import Item from "./Item";
|
|
12
13
|
import * as S from "./style";
|
|
13
14
|
|
|
14
15
|
const ManualPanel = (props: IProps) => {
|
|
15
|
-
const { onChange, currentSite
|
|
16
|
+
const { onChange, currentSite } = props;
|
|
16
17
|
|
|
17
|
-
const { state, setState } =
|
|
18
|
+
const { state, setState } = useReference();
|
|
18
19
|
|
|
19
20
|
const [isLoading, setIsLoading] = useState(false);
|
|
20
21
|
const [selectedSource, setSelectedSource] = useState(state.sourceTitles[0].id);
|
|
@@ -40,7 +41,7 @@ const ManualPanel = (props: IProps) => {
|
|
|
40
41
|
await structuredData.getDataContents(params, currentSite);
|
|
41
42
|
if (isReqOk(response.status)) {
|
|
42
43
|
const { items } = response.data;
|
|
43
|
-
setState(
|
|
44
|
+
setState((state: IReferenceState) => ({ ...state, items }));
|
|
44
45
|
} else {
|
|
45
46
|
console.log("Error en getAndSetItems");
|
|
46
47
|
}
|
|
@@ -55,8 +56,8 @@ const ManualPanel = (props: IProps) => {
|
|
|
55
56
|
}, [currentSite, selectedSource, debouncedSearch, state.mode]);
|
|
56
57
|
|
|
57
58
|
const handleOnClick = (item: IStructuredDataContent) => {
|
|
58
|
-
let newSelIds;
|
|
59
|
-
let selItems;
|
|
59
|
+
let newSelIds: number[];
|
|
60
|
+
let selItems: number[];
|
|
60
61
|
if (state.fixed.includes(item.id)) {
|
|
61
62
|
newSelIds = state.fixed.filter((a: any) => a !== item.id);
|
|
62
63
|
selItems = state.selectedItems.filter((b: any) => b.id !== item.id);
|
|
@@ -65,11 +66,11 @@ const ManualPanel = (props: IProps) => {
|
|
|
65
66
|
selItems = [...state.selectedItems, item];
|
|
66
67
|
}
|
|
67
68
|
const showSelected = state.showSelected && newSelIds.length === 0 ? false : state.showSelected;
|
|
68
|
-
setState(
|
|
69
|
+
setState((state: IReferenceState) => ({ ...state, fixed: newSelIds, selectedItems: selItems, showSelected }));
|
|
69
70
|
};
|
|
70
71
|
|
|
71
72
|
const handleSelectedClick = () => {
|
|
72
|
-
setState(
|
|
73
|
+
setState((state: IReferenceState) => ({ ...state, showSelected: !state.showSelected }));
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
const handleAdd = () => {
|
|
@@ -83,7 +84,7 @@ const ManualPanel = (props: IProps) => {
|
|
|
83
84
|
|
|
84
85
|
const textFieldProps = {
|
|
85
86
|
value: state.search,
|
|
86
|
-
onChange: (search: string) => setState(
|
|
87
|
+
onChange: (search: string) => setState((state: IReferenceState) => ({ ...state, search })),
|
|
87
88
|
placeholder: "Search",
|
|
88
89
|
icon: "search",
|
|
89
90
|
iconPosition: "in",
|
|
@@ -152,7 +153,6 @@ const ManualPanel = (props: IProps) => {
|
|
|
152
153
|
interface IProps {
|
|
153
154
|
currentSite: number;
|
|
154
155
|
onChange: (value: any) => void;
|
|
155
|
-
context: any;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
const mapStateToProps = (state: IRootState) => ({
|
|
@@ -9,19 +9,26 @@ import { IconAction, FloatingPanel, Select, Tag } from "@ax/components";
|
|
|
9
9
|
import AutoPanel from "./AutoPanel";
|
|
10
10
|
import ItemList from "./ItemList";
|
|
11
11
|
import ManualPanel from "./ManualPanel";
|
|
12
|
-
import {
|
|
12
|
+
import { useReference, ReferenceProvider } from "./Context";
|
|
13
13
|
|
|
14
14
|
import * as S from "./style";
|
|
15
15
|
|
|
16
|
+
const ReferenceFieldWithProvider = (props: IProps) => (
|
|
17
|
+
<ReferenceProvider modes={props.selectionType}>
|
|
18
|
+
<ReferenceField {...props} />
|
|
19
|
+
</ReferenceProvider>
|
|
20
|
+
)
|
|
21
|
+
|
|
16
22
|
const ReferenceField = (props: IProps) => {
|
|
17
|
-
const { source, value, onChange, disabled, site, selectionType, structuredDataValues, validators } = props;
|
|
23
|
+
const { source, value, onChange, disabled, site, selectionType, structuredDataValues, validators, maxItems } = props;
|
|
18
24
|
|
|
19
25
|
const { isOpen, toggleModal } = useModal();
|
|
20
26
|
|
|
21
|
-
const
|
|
22
|
-
const { state, setState, setModeAndSource } = contextValue;
|
|
27
|
+
const { state, setState, setModeAndSource } = useReference();
|
|
23
28
|
const { mode } = state;
|
|
24
29
|
const singleMode = selectionType && selectionType.length === 1;
|
|
30
|
+
const isAuto = mode === "auto";
|
|
31
|
+
const hasMaxItems = value && value.fixed && maxItems && !isAuto && value.fixed.length >= maxItems;
|
|
25
32
|
|
|
26
33
|
const handleMode = (mode: string) => {
|
|
27
34
|
const { fixed, order, quantity, filter } = state;
|
|
@@ -31,6 +38,7 @@ const ReferenceField = (props: IProps) => {
|
|
|
31
38
|
unique.includes(selItem.structuredData) ? unique : [...unique, selItem.structuredData],
|
|
32
39
|
[]
|
|
33
40
|
);
|
|
41
|
+
|
|
34
42
|
const resetSource = mode === "manual" || source.length === 1 ? source : manualSources;
|
|
35
43
|
|
|
36
44
|
const newValue =
|
|
@@ -51,8 +59,6 @@ const ReferenceField = (props: IProps) => {
|
|
|
51
59
|
setModeAndSource(mode, resetSource);
|
|
52
60
|
};
|
|
53
61
|
|
|
54
|
-
const isAuto = mode === "auto";
|
|
55
|
-
|
|
56
62
|
useEffect(() => {
|
|
57
63
|
const getSourcesTitles = async () => {
|
|
58
64
|
const response = await structuredData.getDataTitles(source);
|
|
@@ -72,7 +78,7 @@ const ReferenceField = (props: IProps) => {
|
|
|
72
78
|
const [order, orderDirection = "ASC"] = value.order.split("-");
|
|
73
79
|
newState = { ...newState, order, orderDirection };
|
|
74
80
|
}
|
|
75
|
-
setState({
|
|
81
|
+
setState({ ...newState });
|
|
76
82
|
});
|
|
77
83
|
}
|
|
78
84
|
|
|
@@ -142,19 +148,20 @@ const ReferenceField = (props: IProps) => {
|
|
|
142
148
|
</S.DataWrapper>
|
|
143
149
|
);
|
|
144
150
|
|
|
145
|
-
const getPanel = (
|
|
151
|
+
const getPanel = () =>
|
|
146
152
|
isAuto ? (
|
|
147
153
|
<AutoPanel
|
|
148
|
-
context={context}
|
|
149
154
|
structuredData={structuredDataValues}
|
|
150
155
|
onChange={handleOnChange}
|
|
151
156
|
site={site}
|
|
152
157
|
validators={validators}
|
|
153
158
|
/>
|
|
154
159
|
) : (
|
|
155
|
-
|
|
160
|
+
<ManualPanel onChange={handleOnChange} />
|
|
156
161
|
);
|
|
157
162
|
|
|
163
|
+
const manualItems = !isAuto && value && Array.isArray(value.fixed) ? value.fixed.length : 0;
|
|
164
|
+
|
|
158
165
|
return (
|
|
159
166
|
<S.Wrapper>
|
|
160
167
|
<S.Label>Elements</S.Label>
|
|
@@ -169,37 +176,26 @@ const ReferenceField = (props: IProps) => {
|
|
|
169
176
|
disabled={disabled}
|
|
170
177
|
/>
|
|
171
178
|
)}
|
|
172
|
-
{singleMode && !isAuto && value && <S.SingleModeText>{
|
|
179
|
+
{singleMode && !isAuto && value && <S.SingleModeText>{manualItems} items</S.SingleModeText>}
|
|
173
180
|
{singleMode && isAuto && <S.SingleModeText>Configure automatic selection</S.SingleModeText>}
|
|
174
|
-
{!disabled && (
|
|
181
|
+
{!disabled && !hasMaxItems && (
|
|
175
182
|
<S.ActionWrapper>
|
|
176
183
|
<IconAction icon={icon} onClick={handleAddItems} />
|
|
177
184
|
</S.ActionWrapper>
|
|
178
185
|
)}
|
|
179
186
|
</S.ModeWrapper>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
handleChange={onChange}
|
|
193
|
-
/>
|
|
194
|
-
)}
|
|
195
|
-
<FloatingPanel title="Configure elements" toggleModal={toggleModal} isOpen={isOpen}>
|
|
196
|
-
{isOpen && getPanel(context)}
|
|
197
|
-
</FloatingPanel>
|
|
198
|
-
</>
|
|
199
|
-
);
|
|
200
|
-
}}
|
|
201
|
-
</Consumer>
|
|
202
|
-
</Provider>
|
|
187
|
+
{isAuto ? (
|
|
188
|
+
autoData
|
|
189
|
+
) : (
|
|
190
|
+
<ItemList
|
|
191
|
+
items={value ? value.fixed : []}
|
|
192
|
+
handleListDelete={handleListDelete}
|
|
193
|
+
handleChange={onChange}
|
|
194
|
+
/>
|
|
195
|
+
)}
|
|
196
|
+
<FloatingPanel title="Configure elements" toggleModal={toggleModal} isOpen={isOpen}>
|
|
197
|
+
{isOpen && getPanel()}
|
|
198
|
+
</FloatingPanel>
|
|
203
199
|
</S.Wrapper>
|
|
204
200
|
);
|
|
205
201
|
};
|
|
@@ -213,10 +209,11 @@ interface IProps {
|
|
|
213
209
|
selectionType?: string[];
|
|
214
210
|
structuredDataValues: { global: IStructuredData[]; site: IStructuredData[] };
|
|
215
211
|
validators?: Record<string, unknown>;
|
|
212
|
+
maxItems?: number;
|
|
216
213
|
}
|
|
217
214
|
|
|
218
215
|
const mapStateToProps = (state: IRootState) => ({
|
|
219
216
|
structuredDataValues: state.structuredData.structuredData,
|
|
220
217
|
});
|
|
221
218
|
|
|
222
|
-
export default connect(mapStateToProps, null)(
|
|
219
|
+
export default connect(mapStateToProps, null)(ReferenceFieldWithProvider);
|
|
@@ -13,7 +13,6 @@ export const StyledSelect = styled(Select)<{ isDisabled: boolean | undefined; er
|
|
|
13
13
|
border-color: ${(p) => (p.error ? p.theme.color.error : p.theme.color.uiLine)};
|
|
14
14
|
box-shadow: none;
|
|
15
15
|
height: ${(p) => p.theme.spacing.l};
|
|
16
|
-
min-width: calc(${(p) => p.theme.spacing.xl} * 2);
|
|
17
16
|
max-width: calc(${(p) => p.theme.spacing.xl} * 6);
|
|
18
17
|
:hover {
|
|
19
18
|
border-color: ${(p) => (p.error ? p.theme.color.error : p.theme.color.uiLine)};
|
|
@@ -10,10 +10,12 @@ const SelectionListItem = (props: ISelectionListItemProps): JSX.Element => {
|
|
|
10
10
|
onClick(option);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
const pageType = type || "Page";
|
|
14
|
+
|
|
13
15
|
return (
|
|
14
16
|
<S.ListItem onClick={handleOnClick}>
|
|
15
17
|
<S.Header>
|
|
16
|
-
<S.Type>{
|
|
18
|
+
<S.Type>{pageType}</S.Type>
|
|
17
19
|
<S.Date>{getFormattedDateWithTimezone(date, "d MMM Y")}</S.Date>
|
|
18
20
|
</S.Header>
|
|
19
21
|
<S.Content>{title}</S.Content>
|