@griddo/ax 10.2.10 → 10.2.12

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 (50) hide show
  1. package/package.json +2 -2
  2. package/src/__tests__/components/Fields/UrlField/UrlField.test.tsx +1 -1
  3. package/src/components/Fields/AsyncSelect/index.tsx +12 -8
  4. package/src/components/Fields/AsyncSelect/style.tsx +58 -1
  5. package/src/components/Fields/CheckField/index.tsx +15 -2
  6. package/src/components/Fields/IntegrationsField/IntegrationItem/CustomPanel/index.tsx +49 -47
  7. package/src/components/Fields/IntegrationsField/IntegrationItem/CustomPanel/style.tsx +6 -1
  8. package/src/components/Fields/IntegrationsField/IntegrationItem/VariablesPanel/index.tsx +13 -11
  9. package/src/components/Fields/IntegrationsField/IntegrationItem/VariablesPanel/style.tsx +6 -3
  10. package/src/components/Fields/MultiCheckSelect/style.tsx +1 -0
  11. package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +274 -38
  12. package/src/components/Fields/ReferenceField/AutoPanel/style.tsx +112 -15
  13. package/src/components/Fields/ReferenceField/Context/index.tsx +18 -10
  14. package/src/components/Fields/ReferenceField/ItemList/Item/index.tsx +9 -30
  15. package/src/components/Fields/ReferenceField/ItemList/Item/style.tsx +9 -51
  16. package/src/components/Fields/ReferenceField/ItemList/index.tsx +10 -6
  17. package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +36 -18
  18. package/src/components/Fields/ReferenceField/ManualPanel/style.tsx +2 -0
  19. package/src/components/Fields/ReferenceField/index.tsx +1 -0
  20. package/src/components/Fields/Select/index.tsx +10 -13
  21. package/src/components/Fields/Select/style.tsx +13 -7
  22. package/src/components/Fields/TimeField/index.tsx +1 -0
  23. package/src/components/Fields/UniqueCheck/index.tsx +3 -1
  24. package/src/components/Fields/UrlField/index.tsx +3 -1
  25. package/src/components/Fields/UrlField/style.tsx +6 -1
  26. package/src/components/FloatingPanel/style.tsx +0 -1
  27. package/src/components/PageFinder/index.tsx +8 -7
  28. package/src/components/SearchField/index.tsx +2 -3
  29. package/src/helpers/arrays.tsx +2 -2
  30. package/src/modules/Analytics/DimensionPanel/index.tsx +44 -42
  31. package/src/modules/Analytics/DimensionPanel/style.tsx +6 -1
  32. package/src/modules/Analytics/GroupPanel/index.tsx +57 -64
  33. package/src/modules/Analytics/GroupPanel/style.tsx +6 -0
  34. package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +15 -13
  35. package/src/modules/Categories/CategoriesList/CategoryPanel/style.tsx +11 -4
  36. package/src/modules/GlobalSettings/Robots/Item/RobotsPanel/index.tsx +20 -18
  37. package/src/modules/GlobalSettings/Robots/Item/RobotsPanel/style.tsx +6 -1
  38. package/src/modules/Navigation/Menus/List/Table/ConfigPanel/index.tsx +8 -6
  39. package/src/modules/Navigation/Menus/List/Table/ConfigPanel/style.tsx +6 -1
  40. package/src/modules/Navigation/Menus/List/Table/SidePanel/index.tsx +15 -13
  41. package/src/modules/Navigation/Menus/List/Table/SidePanel/style.tsx +9 -2
  42. package/src/modules/Redirects/RedirectPanel/index.tsx +33 -31
  43. package/src/modules/Redirects/RedirectPanel/style.tsx +6 -1
  44. package/src/modules/Redirects/index.tsx +0 -1
  45. package/src/modules/Settings/Integrations/IntegrationForm/VariablePanel/index.tsx +63 -61
  46. package/src/modules/Settings/Integrations/IntegrationForm/VariablePanel/style.tsx +6 -1
  47. package/src/modules/Settings/Integrations/IntegrationForm/index.tsx +5 -3
  48. package/src/modules/Settings/Integrations/IntegrationForm/style.tsx +6 -0
  49. package/src/modules/Settings/Languages/LanguagePanel/index.tsx +14 -12
  50. package/src/modules/Settings/Languages/LanguagePanel/style.tsx +8 -1
@@ -1,19 +1,51 @@
1
1
  import React, { useState } from "react";
2
+ import { connect } from "react-redux";
2
3
 
3
- import { IDataSource, ISite, IStructuredData } from "@ax/types";
4
- import { Button, FloatingMenu, IconAction, RadioGroup, Select, FieldsBehavior, UniqueCheck } from "@ax/components";
4
+ import { IDataSource, ILanguage, IRootState, ISite, IStructuredData } from "@ax/types";
5
+ import {
6
+ Button,
7
+ FloatingMenu,
8
+ IconAction,
9
+ RadioGroup,
10
+ Select,
11
+ FieldsBehavior,
12
+ AsyncSelect,
13
+ ToggleField,
14
+ UniqueCheck,
15
+ } from "@ax/components";
5
16
 
6
17
  import { IReferenceState, useReference } from "../Context";
7
18
  import AutoItem from "./AutoItem";
19
+
8
20
  import * as S from "./style";
9
21
 
10
22
  const AutoPanel = (props: IProps): JSX.Element => {
11
- const { onChange, site, structuredData, validators, categories } = props;
23
+ const { onChange, site, structuredData, validators, categories, globalLangs, lang } = props;
12
24
 
13
25
  const { state, setState } = useReference();
14
26
 
15
27
  const init = state.quantity ? "number" : "all";
16
28
  const [allItems, setAllItems] = useState<string | boolean>(init);
29
+ const initConfig = {
30
+ isConfigOpen: false,
31
+ isLanguageOpen: true,
32
+ isDataOpen: true,
33
+ isAllLangOpen: true,
34
+ isCustomLangOpen: true,
35
+ };
36
+ const [configState, setConfigState] = useState<IConfigState>(initConfig);
37
+ const initToggle = {
38
+ isSiteActive: state.site ? true : false,
39
+ isLangActive: state.lang ? true : false,
40
+ errorSite: false,
41
+ errorLang: false,
42
+ errorMsg: "",
43
+ };
44
+ const [toggleState, setToggleState] = useState<IToggleState>(initToggle);
45
+
46
+ const langOptions = globalLangs
47
+ .filter((language) => lang.id !== language.id)
48
+ .map((language) => ({ label: language.label, value: language.id.toString() }));
17
49
 
18
50
  const structuredDataValues: any[] = [];
19
51
  for (const [, dataType] of Object.entries(structuredData) as any[]) {
@@ -92,20 +124,43 @@ const AutoPanel = (props: IProps): JSX.Element => {
92
124
  minValue: validators && validators.minValue ? validators.minValue : undefined,
93
125
  };
94
126
 
127
+ const checkErrors = (): boolean => {
128
+ let errorSite = false;
129
+ let errorLang = false;
130
+ let errorMsg = "";
131
+ if (toggleState.isSiteActive && !state.site) {
132
+ errorSite = true;
133
+ errorMsg = "You need to select site before apply.";
134
+ }
135
+ if (toggleState.isLangActive && !state.lang) {
136
+ errorLang = true;
137
+ errorMsg = "You need to select language before apply.";
138
+ }
139
+ if (errorLang && errorSite) {
140
+ errorMsg = "You need to define some settings before apply.";
141
+ }
142
+ setToggleState({ ...toggleState, errorLang, errorSite, errorMsg });
143
+ return errorSite || errorLang;
144
+ };
145
+
95
146
  const handleApply = () => {
96
- const order = state.order.concat("-", state.orderDirection);
97
- const newValue = {
98
- mode: "auto",
99
- quantity: state.quantity,
100
- order,
101
- source: state.source,
102
- filter: state.filter,
103
- fullRelations: state.fullRelations,
104
- allLanguages: state.allLanguages,
105
- preferenceLanguage: state.preferenceLanguage,
106
- };
147
+ if (!checkErrors()) {
148
+ const order = state.order.concat("-", state.orderDirection);
149
+ const newValue = {
150
+ mode: "auto",
151
+ quantity: state.quantity,
152
+ order,
153
+ source: state.source,
154
+ filter: state.filter,
155
+ fullRelations: state.fullRelations,
156
+ allLanguages: state.allLanguages,
157
+ preferenceLanguage: state.preferenceLanguage,
158
+ lang: state.lang,
159
+ site: state.site,
160
+ };
107
161
 
108
- onChange(newValue);
162
+ onChange(newValue);
163
+ }
109
164
  };
110
165
 
111
166
  const handleAddSource = (value: string) => {
@@ -172,12 +227,45 @@ const AutoPanel = (props: IProps): JSX.Element => {
172
227
  }
173
228
  };
174
229
 
175
- const handleAllLanguagesChange = (value: any) =>
176
- setState((state: IReferenceState) => ({ ...state, allLanguages: value }));
230
+ const handleAllLanguagesChange = (value: any) => {
231
+ const preferenceLanguage = value ? state.preferenceLanguage : false;
232
+ setState((state: IReferenceState) => ({ ...state, allLanguages: value, preferenceLanguage }));
233
+ };
177
234
 
178
235
  const handlePreferenceLanguageChange = (value: any) =>
179
236
  setState((state: IReferenceState) => ({ ...state, preferenceLanguage: value }));
180
237
 
238
+ const toggleConfig = (value: keyof IConfigState) => setConfigState({ ...configState, [value]: !configState[value] });
239
+
240
+ const handleSiteChange = (value: string | number | null) => {
241
+ setState((state: IReferenceState) => ({ ...state, site: value || undefined }));
242
+ if (value) {
243
+ setToggleState({ ...toggleState, isSiteActive: true, errorSite: false, errorMsg: "" });
244
+ }
245
+ };
246
+
247
+ const handleLangChange = (value: string) => {
248
+ const lang = value.length ? parseInt(value) : undefined;
249
+ setState((state: IReferenceState) => ({ ...state, lang }));
250
+ if (value) {
251
+ setToggleState({ ...toggleState, isLangActive: true, errorLang: false, errorMsg: "" });
252
+ }
253
+ };
254
+
255
+ const handleLangToggleChange = (value: boolean) => {
256
+ setToggleState({ ...toggleState, isLangActive: value });
257
+ if (!value) {
258
+ setState((state: IReferenceState) => ({ ...state, lang: undefined }));
259
+ }
260
+ };
261
+
262
+ const handleSiteToggleChange = (value: boolean) => {
263
+ setToggleState({ ...toggleState, isSiteActive: value });
264
+ if (!value) {
265
+ setState((state: IReferenceState) => ({ ...state, site: undefined }));
266
+ }
267
+ };
268
+
181
269
  return (
182
270
  <S.Wrapper data-testid="auto-panel-wrapper">
183
271
  <S.FormWrapper>
@@ -186,7 +274,8 @@ const AutoPanel = (props: IProps): JSX.Element => {
186
274
  <S.SourceActions>
187
275
  {state.source && `${state.source.length} items`} {addSource}
188
276
  </S.SourceActions>
189
- {state.source && state.source.length > 0 &&
277
+ {state.source &&
278
+ state.source.length > 0 &&
190
279
  state.source.map((singleSource: string) => {
191
280
  const sourceFilters = state.filter.filter((f: any) => f.source === singleSource);
192
281
  const source = state.sourceTitles.find((el: IDataSource) => el.id === singleSource);
@@ -201,27 +290,11 @@ const AutoPanel = (props: IProps): JSX.Element => {
201
290
  site={site}
202
291
  structuredDataSite={[...structuredData.site, ...categories.site]}
203
292
  />
204
- ) : <></>;
293
+ ) : (
294
+ <></>
295
+ );
205
296
  })}
206
297
  </S.SourcesWrapper>
207
- <S.AllLanguagesWrapper>
208
- <S.AllLanguagesText>
209
- The content is displayed in the language of the page, but if the content you want is not available in that
210
- language, you have the option to include content in another language.
211
- </S.AllLanguagesText>
212
- <UniqueCheck
213
- name="allLanguagesCheck"
214
- options={[{ value: false, name: "allLanguages", title: "Include content in another language" }]}
215
- value={state.allLanguages}
216
- onChange={handleAllLanguagesChange}
217
- />
218
- {state.allLanguages && <UniqueCheck
219
- name="preferenceLanguageCheck"
220
- options={[{ value: false, name: "preferenceLanguage", title: "Language page first" }]}
221
- value={state.preferenceLanguage}
222
- onChange={handlePreferenceLanguageChange}
223
- />}
224
- </S.AllLanguagesWrapper>
225
298
  <S.RadioWrapper>
226
299
  <S.FieldLabel>Sort</S.FieldLabel>
227
300
  <RadioGroup {...radioGroupProps} />
@@ -229,8 +302,148 @@ const AutoPanel = (props: IProps): JSX.Element => {
229
302
  <S.FieldLabel>Number of items</S.FieldLabel>
230
303
  <RadioGroup name="quantityGroup" options={quantityOptions} value={allItems} onChange={handleItemsChange} />
231
304
  {allItems !== "all" && <FieldsBehavior {...numberFieldProps} />}
305
+
306
+ <S.AdvancedWrapper>
307
+ <S.ConfigLabel
308
+ onClick={() => toggleConfig("isConfigOpen")}
309
+ isOpen={configState.isConfigOpen}
310
+ data-testid="advanced-config-label"
311
+ >
312
+ Advanced Settings
313
+ </S.ConfigLabel>
314
+ <S.ConfigWrapper isOpen={configState.isConfigOpen}>
315
+ <S.OptionLabel
316
+ onClick={() => toggleConfig("isLanguageOpen")}
317
+ isOpen={configState.isLanguageOpen}
318
+ data-testid="advanced-config-label"
319
+ >
320
+ <S.LabelContent>
321
+ <S.OptionText>Language options</S.OptionText>
322
+ </S.LabelContent>
323
+ </S.OptionLabel>
324
+
325
+ <S.ConfigWrapper isOpen={configState.isLanguageOpen}>
326
+ <S.ConfigContent smallMargin={toggleState.isLangActive}>
327
+ <S.OptionLabel
328
+ onClick={() => toggleConfig("isAllLangOpen")}
329
+ isOpen={configState.isAllLangOpen}
330
+ data-testid="advanced-config-label"
331
+ >
332
+ <S.LabelContent>
333
+ <S.SubOptionText>Include content in any language</S.SubOptionText>
334
+ <ToggleField
335
+ name="allLanguages"
336
+ value={state.allLanguages}
337
+ onChange={handleAllLanguagesChange}
338
+ size="s"
339
+ />
340
+ </S.LabelContent>
341
+ </S.OptionLabel>
342
+
343
+ <S.ConfigWrapper isOpen={configState.isAllLangOpen}>
344
+ <S.SubConfigContent hasMargin={true}>
345
+ <S.OptionDescription>
346
+ By default, data is displayed in the page's language. Enable this option if you want the content
347
+ to <strong>include data in any available language</strong>.
348
+ </S.OptionDescription>
349
+ {state.allLanguages && (
350
+ <S.CheckWrapper>
351
+ <UniqueCheck
352
+ name="preferenceLanguageCheck"
353
+ options={[{ value: false, name: "preferenceLanguage", title: "Language page first" }]}
354
+ value={state.preferenceLanguage}
355
+ onChange={handlePreferenceLanguageChange}
356
+ />
357
+ </S.CheckWrapper>
358
+ )}
359
+ </S.SubConfigContent>
360
+ </S.ConfigWrapper>
361
+
362
+ {langOptions.length > 0 ? (
363
+ <>
364
+ <S.OptionLabel
365
+ onClick={() => toggleConfig("isCustomLangOpen")}
366
+ isOpen={configState.isCustomLangOpen}
367
+ data-testid="advanced-config-label"
368
+ >
369
+ <S.LabelContent>
370
+ <S.SubOptionText>Specify different language</S.SubOptionText>
371
+ <ToggleField
372
+ name="customLang"
373
+ value={toggleState.isLangActive}
374
+ onChange={handleLangToggleChange}
375
+ size="s"
376
+ />
377
+ </S.LabelContent>
378
+ </S.OptionLabel>
379
+
380
+ <S.ConfigWrapper>
381
+ <S.SubConfigContent>
382
+ <S.OptionDescription isOpen={configState.isCustomLangOpen}>
383
+ By default, data is displayed in the page's language. Enable this option if you wish to{" "}
384
+ <strong>specify a different language</strong> for the content of this distributor.
385
+ </S.OptionDescription>
386
+ {toggleState.isLangActive && (
387
+ <Select
388
+ name="select"
389
+ options={langOptions}
390
+ onChange={handleLangChange}
391
+ value={state.lang?.toString() || ""}
392
+ type="inline"
393
+ placeholder="Select language"
394
+ error={toggleState.errorLang}
395
+ />
396
+ )}
397
+ </S.SubConfigContent>
398
+ </S.ConfigWrapper>
399
+ </>
400
+ ) : (
401
+ <></>
402
+ )}
403
+ </S.ConfigContent>
404
+ </S.ConfigWrapper>
405
+
406
+ <S.OptionLabel
407
+ onClick={() => toggleConfig("isDataOpen")}
408
+ isOpen={configState.isDataOpen}
409
+ data-testid="advanced-config-label"
410
+ >
411
+ <S.LabelContent>
412
+ <S.OptionText>Data from specific site</S.OptionText>
413
+ <ToggleField
414
+ name="site-toggle"
415
+ value={toggleState.isSiteActive}
416
+ onChange={handleSiteToggleChange}
417
+ size="s"
418
+ />
419
+ </S.LabelContent>
420
+ </S.OptionLabel>
421
+
422
+ <S.ConfigWrapper>
423
+ <S.ConfigContent smallMargin={toggleState.isSiteActive} isLast={true}>
424
+ <S.OptionDescription isOpen={configState.isDataOpen}>
425
+ The content is displayed in the language of the page, but{" "}
426
+ <strong>if the content you want is not available in that language</strong>, you have the option to
427
+ include content in another language.
428
+ </S.OptionDescription>
429
+ {toggleState.isSiteActive && (
430
+ <AsyncSelect
431
+ name="select"
432
+ entity="sites"
433
+ onChange={handleSiteChange}
434
+ value={state.site || null}
435
+ type="inline"
436
+ placeholder="Select site"
437
+ error={toggleState.errorSite}
438
+ />
439
+ )}
440
+ </S.ConfigContent>
441
+ </S.ConfigWrapper>
442
+ </S.ConfigWrapper>
443
+ </S.AdvancedWrapper>
232
444
  </S.FormWrapper>
233
445
  <S.ActionsWrapper>
446
+ <S.ErrorWrapper>{toggleState.errorMsg.length > 0 && toggleState.errorMsg}</S.ErrorWrapper>
234
447
  <Button type="button" onClick={handleApply}>
235
448
  Apply
236
449
  </Button>
@@ -245,6 +458,29 @@ interface IProps {
245
458
  onChange: (value: any) => void;
246
459
  site: ISite;
247
460
  validators?: Record<string, unknown>;
461
+ globalLangs: ILanguage[];
462
+ lang: { locale: string; id: number };
248
463
  }
249
464
 
250
- export default AutoPanel;
465
+ interface IConfigState {
466
+ isConfigOpen: boolean;
467
+ isLanguageOpen: boolean;
468
+ isDataOpen: boolean;
469
+ isAllLangOpen: boolean;
470
+ isCustomLangOpen: boolean;
471
+ }
472
+
473
+ interface IToggleState {
474
+ isSiteActive: boolean;
475
+ isLangActive: boolean;
476
+ errorSite: boolean;
477
+ errorLang: boolean;
478
+ errorMsg: string;
479
+ }
480
+
481
+ const mapStateToProps = (state: IRootState) => ({
482
+ globalLangs: state.app.globalLangs,
483
+ lang: state.app.lang,
484
+ });
485
+
486
+ export default connect(mapStateToProps)(AutoPanel);
@@ -6,11 +6,15 @@ const Wrapper = styled.div`
6
6
  justify-content: space-between;
7
7
  position: relative;
8
8
  height: 100%;
9
- overflow: auto;
10
9
  padding-bottom: ${(p) => `calc(${p.theme.spacing.l} + ${p.theme.spacing.s})`};
11
10
  `;
12
11
 
13
- const FormWrapper = styled.div``;
12
+ const FormWrapper = styled.div`
13
+ position: relative;
14
+ padding: ${(p) => p.theme.spacing.m};
15
+ height: 100%;
16
+ overflow: auto;
17
+ `;
14
18
 
15
19
  const SourcesWrapper = styled.div`
16
20
  margin-bottom: ${(p) => p.theme.spacing.m};
@@ -45,7 +49,7 @@ const RadioWrapper = styled.div`
45
49
 
46
50
  const SelectWrapper = styled.div`
47
51
  position: absolute;
48
- right: 0;
52
+ right: ${(p) => p.theme.spacing.m};
49
53
  margin-top: ${(p) => `-${p.theme.spacing.xs}`};
50
54
  div {
51
55
  right: 0;
@@ -53,8 +57,11 @@ const SelectWrapper = styled.div`
53
57
  `;
54
58
 
55
59
  const ActionsWrapper = styled.div`
60
+ display: flex;
56
61
  text-align: right;
57
- padding-top: ${(p) => p.theme.spacing.m};
62
+ padding: ${(p) => `${p.theme.spacing.s} ${p.theme.spacing.m} ${p.theme.spacing.m} ${p.theme.spacing.m}`};
63
+ border-top: 1px solid ${(p) => p.theme.color.uiLine};
64
+ align-items: center;
58
65
  `;
59
66
 
60
67
  const IconWrapper = styled.div`
@@ -75,19 +82,99 @@ const SourceItem = styled.li`
75
82
  }
76
83
  `;
77
84
 
78
- const AllLanguagesWrapper = styled.div`
85
+ const AdvancedWrapper = styled.div``;
86
+
87
+ const ConfigLabel = styled.div<{ isOpen: boolean }>`
88
+ position: relative;
89
+ ${(p) => p.theme.textStyle.uiS};
90
+ color: ${(p) => p.theme.colors.interactive01};
91
+ margin-bottom: ${(p) => p.theme.spacing.xs};
92
+ cursor: pointer;
93
+ :after {
94
+ content: "";
95
+ border: solid ${(p) => p.theme.color.interactive01};
96
+ margin-left: ${(p) => p.theme.spacing.xs};
97
+ border-width: 0 2px 2px 0;
98
+ display: inline-block;
99
+ padding: 3px;
100
+ transform: ${(p) => (p.isOpen ? `rotate(-135deg) translate(-2px, 0)` : `rotate(45deg) translate(0, -2px)`)};
101
+ }
102
+ `;
103
+
104
+ const ConfigWrapper = styled.div<{ isOpen?: boolean }>`
105
+ overflow-y: ${(p) => (p.isOpen === false ? "hidden" : "visible")};
106
+ height: ${(p) => (p.isOpen === false ? 0 : "auto")};
107
+ transition: height 0.5s ease-in-out;
108
+ `;
109
+
110
+ const ConfigContent = styled.div<{ smallMargin: boolean; isLast?: boolean }>`
111
+ margin-bottom: ${(p) => p.theme.spacing.m};
112
+ padding: ${(p) =>
113
+ p.smallMargin ? `0 0 ${p.theme.spacing.xs} ${p.theme.spacing.m}` : `0 0 ${p.theme.spacing.m} ${p.theme.spacing.m}`};
114
+ border-bottom: ${(p) => (p.isLast ? "none" : `1px solid ${p.theme.color.uiLine}`)};
115
+ `;
116
+
117
+ const SubConfigContent = styled.div<{ hasMargin?: boolean }>`
118
+ padding-left: ${(p) => p.theme.spacing.m};
119
+ margin-bottom: ${(p) => (p.hasMargin ? p.theme.spacing.s : "0")};
120
+ `;
121
+
122
+ const OptionLabel = styled.div<{ isOpen: boolean }>`
123
+ position: relative;
124
+ margin-bottom: ${(p) => p.theme.spacing.xs};
125
+ padding-left: ${(p) => p.theme.spacing.xxs};
126
+ cursor: pointer;
127
+ :before {
128
+ position: absolute;
129
+ top: 6px;
130
+ content: "";
131
+ border: solid ${(p) => p.theme.color.interactive01};
132
+ margin-right: 12px;
133
+ border-width: 0 2px 2px 0;
134
+ padding: 3px;
135
+ transform: ${(p) => (p.isOpen ? `rotate(45deg) translate(-3px, 0)` : `rotate(-45deg) translate(0, -3px)`)};
136
+ }
137
+ `;
138
+
139
+ const OptionText = styled.div`
79
140
  ${(p) => p.theme.textStyle.fieldContent};
80
- color: ${(p) => p.theme.color.textHighEmphasis};
81
- background-color: ${(p) => p.theme.color.uiBackground03};
82
- padding: ${(p) => p.theme.spacing.s};
83
- border-radius: ${(p) => p.theme.radii.s};
84
- margin-bottom: ${(p) => p.theme.spacing.s};
141
+ color: ${(p) => p.theme.colors.textHighEmphasis};
85
142
  `;
86
143
 
87
- const AllLanguagesText = styled.div`
144
+ const SubOptionText = styled.div`
145
+ ${(p) => p.theme.textStyle.uiM};
146
+ color: ${(p) => p.theme.colors.textHighEmphasis};
147
+ `;
148
+
149
+ const LabelContent = styled.div`
150
+ display: flex;
151
+ align-items: center;
152
+ justify-content: space-between;
153
+ padding-left: 20px;
154
+ `;
155
+
156
+ const OptionDescription = styled.div<{ isOpen?: boolean }>`
88
157
  ${(p) => p.theme.textStyle.uiXS};
89
- color: ${(p) => p.theme.color.textMediumEmphasis};
90
- margin-bottom: ${(p) => p.theme.spacing.xs};
158
+ color: ${(p) => p.theme.colors.textMediumEmphasis};
159
+ padding-right: ${(p) => p.theme.spacing.s};
160
+ overflow-y: ${(p) => (p.isOpen === false ? "hidden" : "visible")};
161
+ height: ${(p) => (p.isOpen === false ? 0 : "auto")};
162
+ transition: height 0.5s ease-in-out;
163
+ `;
164
+
165
+ const CheckWrapper = styled.div`
166
+ margin-top: ${(p) => p.theme.spacing.xs};
167
+ label {
168
+ margin-bottom: 0;
169
+ color: ${(p) => p.theme.colors.textHighEmphasis};
170
+ }
171
+ `;
172
+
173
+ const ErrorWrapper = styled.div`
174
+ ${(p) => p.theme.textStyle.uiXS};
175
+ color: ${(p) => p.theme.colors.error};
176
+ width: 100%;
177
+ padding-right: ${(p) => p.theme.spacing.s};
91
178
  `;
92
179
 
93
180
  export {
@@ -103,6 +190,16 @@ export {
103
190
  SourceMenu,
104
191
  SourceItem,
105
192
  SelectWrapper,
106
- AllLanguagesWrapper,
107
- AllLanguagesText,
193
+ AdvancedWrapper,
194
+ ConfigLabel,
195
+ ConfigWrapper,
196
+ ConfigContent,
197
+ SubConfigContent,
198
+ OptionLabel,
199
+ LabelContent,
200
+ OptionDescription,
201
+ OptionText,
202
+ SubOptionText,
203
+ CheckWrapper,
204
+ ErrorWrapper,
108
205
  };
@@ -1,9 +1,9 @@
1
1
  import React, { createContext, useState, useCallback, useContext, ReactElement } from "react";
2
2
  import { moveElement } from "@ax/forms";
3
3
  import { moveArrayElement } from "@ax/helpers";
4
- import { IStructuredDataContent } from "@ax/types";
4
+ import { IDataSource, IStructuredDataContent } from "@ax/types";
5
5
 
6
- const initState = {
6
+ const initState: IReferenceState = {
7
7
  mode: "auto",
8
8
  order: "recent",
9
9
  orderDirection: "ASC",
@@ -53,8 +53,8 @@ const useReferenceProvider = (modes?: string[]) => {
53
53
  const { selectedItems, fixed, fullRelations = false } = state;
54
54
  const newItems = moveElement(item.id, selectedItems, newIndex, "id");
55
55
  const originalItemId = item.relatedPage?.originalStructuredDataId;
56
- const itemId = state.fixed.includes(originalItemId) ? originalItemId : item.id;
57
- const newFixed = moveArrayElement(itemId, fixed, newIndex);
56
+ const itemId = originalItemId && state.fixed.includes(originalItemId) ? originalItemId : item.id;
57
+ const newFixed: number[] = moveArrayElement(itemId, fixed, newIndex);
58
58
  const newState: IReferenceState = {
59
59
  ...state,
60
60
  selectedItems: newItems,
@@ -77,17 +77,25 @@ export interface IReferenceState {
77
77
  order: string;
78
78
  orderDirection: string;
79
79
  quantity: number;
80
- items: any;
81
- selectedItems: any;
82
- fixed: any;
80
+ items: IStructuredDataContent[];
81
+ selectedItems: IStructuredDataContent[];
82
+ fixed: number[];
83
83
  search: string;
84
84
  showSelected: boolean;
85
- source: any;
86
- filter: any;
87
- sourceTitles: any;
85
+ source: string[];
86
+ filter: IFilter[];
87
+ sourceTitles: IDataSource[];
88
88
  fullRelations: boolean;
89
89
  allLanguages: boolean;
90
90
  preferenceLanguage: boolean;
91
+ lang?: number;
92
+ site?: number;
93
+ }
94
+
95
+ interface IFilter {
96
+ id: number;
97
+ label: string;
98
+ source: string;
91
99
  }
92
100
 
93
101
  export { ReferenceProvider, useReference };
@@ -4,7 +4,7 @@ import { DraggableProvided } from "react-beautiful-dnd";
4
4
  import { IDataSource, IStructuredDataContent } from "@ax/types";
5
5
  import { getFormattedDateWithTimezone } from "@ax/helpers";
6
6
 
7
- import { FloatingMenu, Icon, IconAction } from "@ax/components";
7
+ import { Icon } from "@ax/components";
8
8
 
9
9
  import * as S from "./style";
10
10
 
@@ -15,34 +15,13 @@ const Item = (props: IProps) => {
15
15
  handleDelete(item);
16
16
  };
17
17
 
18
- const MoreInfoButton = () => (
19
- <S.IconActionWrapper>
20
- <IconAction icon="more" />
21
- </S.IconActionWrapper>
22
- );
23
-
24
- const actionMenuItem = (item: any) => (
25
- <S.ActionItem key={item.icon} onClick={item.action} data-testid="action-menu-item">
26
- <Icon name={item.icon} />
27
- <S.ActionText>{item.label}</S.ActionText>
28
- </S.ActionItem>
29
- );
30
-
31
- const editMenu = {
32
- options: [
33
- {
34
- label: "delete",
35
- icon: "delete",
36
- action: removeItem,
37
- },
38
- ],
39
- };
40
-
41
- const ActionMenu = () => (
42
- <FloatingMenu Button={MoreInfoButton}>
43
- <S.ActionMenu>{editMenu.options.map((item: any, i: number) => actionMenuItem(item))}</S.ActionMenu>
44
- </FloatingMenu>
45
- );
18
+ const menuOptions = [
19
+ {
20
+ label: "delete",
21
+ icon: "delete",
22
+ action: removeItem,
23
+ },
24
+ ];
46
25
 
47
26
  return (
48
27
  <S.Item ref={innerRef} data-testid="reference-field-item" {...provided?.draggableProps}>
@@ -58,7 +37,7 @@ const Item = (props: IProps) => {
58
37
  </S.Header>
59
38
  <S.Title>{item.content.title}</S.Title>
60
39
  </S.TextWrapper>
61
- <ActionMenu />
40
+ <S.StyledActionMenu icon="more" options={menuOptions} tooltip="Actions" />
62
41
  </S.Item>
63
42
  );
64
43
  };