@truedat/core 6.1.5 → 6.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "6.1.5",
3
+ "version": "6.2.0",
4
4
  "description": "Truedat Web Core",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -35,7 +35,7 @@
35
35
  "@testing-library/jest-dom": "^5.16.5",
36
36
  "@testing-library/react": "^12.0.0",
37
37
  "@testing-library/user-event": "^13.2.1",
38
- "@truedat/test": "6.1.5",
38
+ "@truedat/test": "6.2.0",
39
39
  "babel-jest": "^28.1.0",
40
40
  "babel-plugin-dynamic-import-node": "^2.3.3",
41
41
  "babel-plugin-lodash": "^3.3.4",
@@ -117,5 +117,5 @@
117
117
  "react-dom": ">= 16.8.6 < 17",
118
118
  "semantic-ui-react": ">= 2.0.3 < 2.2"
119
119
  },
120
- "gitHead": "3cbadffa2227cac1cce3c21d8442245082324ac1"
120
+ "gitHead": "5c10ee429997ab081477edf0679547eb4bc11f9b"
121
121
  }
@@ -145,7 +145,10 @@ export const RichTextEditor = ({
145
145
  const [editor, setEditor] = useState();
146
146
 
147
147
  useEffect(() => {
148
- if (!_.isEmpty(propValue) && !_.equals(propValue)(jsonValue)) {
148
+ if (
149
+ (!_.isEmpty(propValue) && !_.equals(propValue)(jsonValue)) ||
150
+ (readOnly && !_.equals(value)(Value.fromJSON(propValue)))
151
+ ) {
149
152
  setValue(Value.fromJSON(propValue));
150
153
  }
151
154
  }, [propValue]);
@@ -86,6 +86,11 @@ export const TreeSelector = ({
86
86
  const [open, setOpen] = useState([]);
87
87
  const [displayed, setDisplayed] = useState([]);
88
88
 
89
+ useEffect(() => {
90
+ if (initialValue !== value)
91
+ setValue(_.defaultTo(multiple ? [] : null)(initialValue));
92
+ }, [initialValue]);
93
+
89
94
  useEffect(() => {
90
95
  const ids = childIds(open)(options);
91
96
  setDisplayed((displayed) => _.union(displayed)(ids));
@@ -179,6 +184,7 @@ export const TreeSelector = ({
179
184
  trigger={trigger}
180
185
  upward={false}
181
186
  value={value}
187
+ disabled={disabled}
182
188
  >
183
189
  <Dropdown.Menu>
184
190
  <Input
@@ -6,6 +6,7 @@ exports[`<DomainSelector /> matches latest snapshot 1`] = `
6
6
  class="field fix-dropdown-selector"
7
7
  >
8
8
  <div
9
+ aria-disabled="false"
9
10
  aria-expanded="false"
10
11
  aria-multiselectable="false"
11
12
  class="ui floating dropdown"
@@ -6,6 +6,7 @@ exports[`<HierarchySelector /> matches latest snapshot 1`] = `
6
6
  class="field fix-dropdown-selector"
7
7
  >
8
8
  <div
9
+ aria-disabled="false"
9
10
  aria-expanded="false"
10
11
  aria-multiselectable="true"
11
12
  class="ui floating multiple dropdown"
@@ -6,6 +6,7 @@ exports[`<TreeSelector /> matches latest snapshot 1`] = `
6
6
  class="field fix-dropdown-selector"
7
7
  >
8
8
  <div
9
+ aria-disabled="false"
9
10
  aria-expanded="false"
10
11
  aria-multiselectable="false"
11
12
  class="ui floating dropdown"
@@ -59,18 +59,31 @@ const LanguajeRow = ({
59
59
  </TableCell>
60
60
  {!anyDefault ? (
61
61
  <TableCell textAlign="center">
62
- <Input
63
- id={`radio-${lang}`}
64
- type="radio"
65
- name="is_default"
66
- checked={is_default}
67
- onChange={() => handleChange({ id, locale: { is_default: true } })}
62
+ <ConfirmModal
63
+ trigger={
64
+ <Input
65
+ id={`radio-${lang}`}
66
+ type="radio"
67
+ name="is_default"
68
+ checked={is_default}
69
+ />
70
+ }
71
+ header={formatMessage({
72
+ id: "i18n.messages.locale.setDefault.confirmation.header",
73
+ })}
74
+ content={formatMessage(
75
+ {
76
+ id: "i18n.messages.locale.setDefault.confirmation.content",
77
+ },
78
+ { lang: local_name }
79
+ )}
80
+ onConfirm={() => handleChange({ id, locale: { is_default: true } })}
68
81
  />
69
82
  </TableCell>
70
83
  ) : null}
71
84
 
72
85
  <TableCell>
73
- {!is_default && !["es", "en"].includes(lang) ? (
86
+ {!is_default ? (
74
87
  <ConfirmModal
75
88
  icon="trash"
76
89
  trigger={
@@ -79,7 +79,6 @@ export const SearchContextProvider = (props) => {
79
79
  ? _.without([value])(values)
80
80
  : _.union([value])(values);
81
81
 
82
- console.log("toggleHiddenFilterValue", values, newValue);
83
82
  setHiddenFilters({ ...hiddenFilters, [filter]: newValue });
84
83
  };
85
84
 
@@ -0,0 +1,58 @@
1
+ import _ from "lodash/fp";
2
+
3
+ const translatableFieldTypes = ["enriched_text", "string"];
4
+
5
+ export const splitTranslatableFields = (template) =>
6
+ _.flow(
7
+ _.get("content"),
8
+ _.flatMap((group) =>
9
+ _.reduce(
10
+ (acc, { name, widget }) => {
11
+ const translatableKey = _.includes(widget)(translatableFieldTypes)
12
+ ? "translatable"
13
+ : "noTranslatable";
14
+
15
+ return {
16
+ ...acc,
17
+ [translatableKey]: {
18
+ ...acc[translatableKey],
19
+ [name]: _.cond([
20
+ [(w) => w == "enriched_text", _.constant({})],
21
+ [(w) => w == "string", _.constant("")],
22
+ [_.stubTrue, _.constant(null)],
23
+ ])(widget),
24
+ },
25
+ };
26
+ },
27
+ { translatable: {}, noTranslatable: {} }
28
+ )(group.fields)
29
+ ),
30
+ _.reduce(
31
+ (acc, { translatable, noTranslatable }) => {
32
+ return {
33
+ translatable: { ...acc.translatable, ...translatable },
34
+ noTranslatable: { ...acc.noTranslatable, ...noTranslatable },
35
+ };
36
+ },
37
+ { translatable: {}, noTranslatable: {} }
38
+ )
39
+ )(template);
40
+
41
+ export const formatLocales = (locales) =>
42
+ _.flow(_.orderBy(["lang"], ["asc"]), (localeList) => ({
43
+ default: _.filter({
44
+ is_enabled: true,
45
+ is_required: true,
46
+ is_default: true,
47
+ })(localeList),
48
+ required: _.filter({
49
+ is_enabled: true,
50
+ is_required: true,
51
+ is_default: false,
52
+ })(localeList),
53
+ enabled: _.filter({
54
+ is_enabled: true,
55
+ is_required: false,
56
+ is_default: false,
57
+ })(localeList),
58
+ }))(locales);