@webiny/app-headless-cms 5.21.0 → 5.22.0-beta.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.
Files changed (99) hide show
  1. package/admin/components/ContentEntryForm/useContentEntryForm.js +113 -15
  2. package/admin/components/ContentModelEditor/Context.js +3 -1
  3. package/admin/components/ContentModelEditor/Editor.d.ts +1 -1
  4. package/admin/components/ContentModelEditor/Editor.js +1 -1
  5. package/admin/components/Draggable.d.ts +3 -2
  6. package/admin/components/Draggable.js +5 -3
  7. package/admin/components/Droppable.d.ts +3 -2
  8. package/admin/components/Droppable.js +5 -3
  9. package/admin/components/FieldEditor/EditFieldDialog/PredefinedValues.d.ts +10 -5
  10. package/admin/components/FieldEditor/EditFieldDialog/PredefinedValues.js +9 -5
  11. package/admin/components/FieldEditor/Field.js +4 -4
  12. package/admin/components/FieldEditor/FieldEditor.js +1 -1
  13. package/admin/components/FieldEditor/Styled.d.ts +2 -2
  14. package/admin/elements/ContentGroupMenuElement.js +2 -1
  15. package/admin/elements/ContentModelMenuElement.js +2 -1
  16. package/admin/elements/NothingToShowElement.js +1 -1
  17. package/admin/graphql/contentModels.d.ts +1 -1
  18. package/admin/graphql/contentModels.js +1 -1
  19. package/admin/menus/CmsMenuLoader.js +1 -1
  20. package/admin/plugins/editor/defaultBar/BackButton.js +1 -1
  21. package/admin/plugins/editor/defaultBar/CreateContentButton.js +1 -1
  22. package/admin/plugins/editor/defaultBar/Divider.d.ts +1 -1
  23. package/admin/plugins/editor/defaultBar/FormSettings/FormSettingsButton.js +1 -1
  24. package/admin/plugins/editor/defaultBar/FormSettings/FormSettingsStyled.d.ts +2 -2
  25. package/admin/plugins/editor/defaultBar/Name/NameStyled.d.ts +3 -3
  26. package/admin/plugins/editor/formSettings/index.js +1 -1
  27. package/admin/plugins/fieldRenderers/DynamicSection.js +1 -1
  28. package/admin/plugins/fieldRenderers/checkboxes.js +18 -15
  29. package/admin/plugins/fieldRenderers/dateTime/DateOnly.d.ts +9 -0
  30. package/admin/plugins/fieldRenderers/dateTime/DateOnly.js +39 -0
  31. package/admin/plugins/fieldRenderers/dateTime/DateTimeWithTimezone.d.ts +2 -3
  32. package/admin/plugins/fieldRenderers/dateTime/DateTimeWithTimezone.js +61 -59
  33. package/admin/plugins/fieldRenderers/dateTime/DateTimeWithoutTimezone.d.ts +4 -4
  34. package/admin/plugins/fieldRenderers/dateTime/DateTimeWithoutTimezone.js +52 -51
  35. package/admin/plugins/fieldRenderers/dateTime/Input.d.ts +6 -7
  36. package/admin/plugins/fieldRenderers/dateTime/Input.js +2 -5
  37. package/admin/plugins/fieldRenderers/dateTime/Select.d.ts +10 -3
  38. package/admin/plugins/fieldRenderers/dateTime/Select.js +2 -5
  39. package/admin/plugins/fieldRenderers/dateTime/Time.d.ts +3 -3
  40. package/admin/plugins/fieldRenderers/dateTime/Time.js +33 -9
  41. package/admin/plugins/fieldRenderers/dateTime/dateTimeField.js +8 -13
  42. package/admin/plugins/fieldRenderers/dateTime/dateTimeFields.js +9 -13
  43. package/admin/plugins/fieldRenderers/dateTime/utils.d.ts +7 -6
  44. package/admin/plugins/fieldRenderers/dateTime/utils.js +51 -9
  45. package/admin/plugins/fieldRenderers/file/fileField.js +1 -2
  46. package/admin/plugins/fieldRenderers/file/utils.js +1 -1
  47. package/admin/plugins/fieldRenderers/longText/longTexts.js +1 -1
  48. package/admin/plugins/fieldRenderers/number/numberInputs.js +1 -1
  49. package/admin/plugins/fieldRenderers/object/multipleObjects.js +1 -1
  50. package/admin/plugins/fieldRenderers/radioButtons.js +4 -3
  51. package/admin/plugins/fieldRenderers/ref/components/MissingEntryHelpText.d.ts +5 -0
  52. package/admin/plugins/fieldRenderers/ref/components/MissingEntryHelpText.js +30 -0
  53. package/admin/plugins/fieldRenderers/ref/components/NewRefEntryFormDialog.d.ts +9 -0
  54. package/admin/plugins/fieldRenderers/ref/components/NewRefEntryFormDialog.js +147 -0
  55. package/admin/plugins/fieldRenderers/ref/components/createEntryUrl.d.ts +1 -0
  56. package/admin/plugins/fieldRenderers/ref/components/createEntryUrl.js +3 -0
  57. package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntry.d.ts +11 -0
  58. package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntry.js +30 -0
  59. package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntryDialog.d.ts +10 -0
  60. package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntryDialog.js +28 -0
  61. package/admin/plugins/fieldRenderers/richText/richTextInputs.js +1 -1
  62. package/admin/plugins/fieldRenderers/text/textInputs.js +1 -1
  63. package/admin/plugins/fieldValidators/date/createDateInputField.js +8 -13
  64. package/admin/plugins/fieldValidators/unique.d.ts +3 -0
  65. package/admin/plugins/fieldValidators/unique.js +12 -0
  66. package/admin/plugins/fields/PredefinedValuesDynamicFieldset.d.ts +7 -4
  67. package/admin/plugins/fields/PredefinedValuesDynamicFieldset.js +88 -53
  68. package/admin/plugins/fields/boolean.js +19 -2
  69. package/admin/plugins/fields/dateTime.js +17 -6
  70. package/admin/plugins/fields/file.js +1 -1
  71. package/admin/plugins/fields/longText.js +1 -1
  72. package/admin/plugins/fields/number.js +1 -1
  73. package/admin/plugins/fields/object.js +1 -1
  74. package/admin/plugins/fields/ref.js +1 -1
  75. package/admin/plugins/fields/richText.js +1 -1
  76. package/admin/plugins/fields/text.js +2 -2
  77. package/admin/plugins/index.d.ts +1 -1
  78. package/admin/plugins/permissionRenderer/components/StyledComponents.d.ts +1 -1
  79. package/admin/plugins/permissionRenderer/index.js +1 -1
  80. package/admin/plugins/transformers/dateTransformer.js +5 -7
  81. package/admin/plugins/validators/unique.d.ts +7 -0
  82. package/admin/plugins/validators/unique.js +38 -0
  83. package/admin/views/contentEntries/ContentEntriesContext.d.ts +7 -7
  84. package/admin/views/contentEntries/ContentEntriesContext.js +3 -1
  85. package/admin/views/contentEntries/ContentEntriesList.js +2 -2
  86. package/admin/views/contentEntries/ContentEntry/ContentEntryContext.d.ts +10 -3
  87. package/admin/views/contentEntries/ContentEntry/ContentEntryContext.js +27 -7
  88. package/admin/views/contentEntries/ContentEntry/RevisionListItem.js +9 -9
  89. package/admin/views/contentEntries/ContentEntry/header/contentFormOptionsMenu/ContentFormOptionsMenu.js +2 -2
  90. package/admin/views/contentEntries/ContentEntry/header/requestChanges/RequestChanges.js +1 -1
  91. package/admin/views/contentEntries/ContentEntry/header/requestReview/RequestReview.js +1 -1
  92. package/admin/views/contentEntries/ContentEntry/header/revisionSelector/RevisionSelector.js +1 -1
  93. package/admin/views/contentEntries/ContentEntry.js +1 -1
  94. package/admin/views/contentModelGroups/ContentModelGroupsDataList.js +2 -2
  95. package/admin/views/contentModelGroups/ContentModelGroupsForm.js +1 -1
  96. package/admin/views/contentModels/ContentModelEditor.js +1 -1
  97. package/admin/views/contentModels/ContentModelsDataList.js +4 -4
  98. package/package.json +31 -37
  99. package/types.d.ts +4 -1
@@ -1,74 +1,71 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import React, { useEffect, useState } from "react";
3
+ import React, { useEffect } from "react";
4
4
  import { Grid, Cell } from "@webiny/ui/Grid";
5
- import { DEFAULT_DATE, DEFAULT_TIME, RemoveFieldButton } from "./utils";
6
- import Input from "./Input";
5
+ import { getCurrentDate, getCurrentLocalTime, getDefaultFieldValue, RemoveFieldButton } from "./utils";
6
+ import { Input } from "./Input";
7
7
 
8
8
  var parseDateTime = function parseDateTime(value) {
9
9
  if (!value) {
10
- return {};
10
+ return {
11
+ date: "",
12
+ time: ""
13
+ };
11
14
  }
12
15
 
13
16
  if (value.includes("T")) {
14
17
  var _value$split$0$split = value.split(".")[0].split("T"),
15
18
  _value$split$0$split2 = _slicedToArray(_value$split$0$split, 2),
16
- _formattedDate = _value$split$0$split2[0],
17
- _formattedTime = _value$split$0$split2[1];
19
+ _date = _value$split$0$split2[0],
20
+ _time = _value$split$0$split2[1];
18
21
 
19
22
  return {
20
- formattedDate: _formattedDate,
21
- formattedTime: _formattedTime
23
+ date: _date,
24
+ time: _time
22
25
  };
23
26
  }
24
27
 
25
28
  var _value$split = value.split(" "),
26
29
  _value$split2 = _slicedToArray(_value$split, 2),
27
- formattedDate = _value$split2[0],
28
- formattedTime = _value$split2[1];
30
+ date = _value$split2[0],
31
+ time = _value$split2[1];
29
32
 
30
- if (!formattedDate || !formattedTime) {
31
- throw new Error("Could not extract date and time from \"".concat(value, "\"."));
33
+ if (!date || !time) {
34
+ console.error("Could not extract date and time from \"".concat(value, "\"."));
35
+ return {
36
+ date: "",
37
+ time: ""
38
+ };
32
39
  }
33
40
 
34
41
  return {
35
- formattedDate: formattedDate,
36
- formattedTime: formattedTime
42
+ date: date,
43
+ time: time
37
44
  };
38
45
  };
39
46
 
40
- var DateTimeWithoutTimezone = function DateTimeWithoutTimezone(_ref) {
47
+ export var DateTimeWithoutTimezone = function DateTimeWithoutTimezone(_ref) {
41
48
  var field = _ref.field,
42
49
  bind = _ref.bind,
43
50
  trailingIcon = _ref.trailingIcon;
44
-
45
51
  // "2020-05-18 09:00:00"
46
- var _parseDateTime = parseDateTime(bind.value),
47
- formattedDate = _parseDateTime.formattedDate,
48
- formattedTime = _parseDateTime.formattedTime;
52
+ var initialValue = getDefaultFieldValue(field, bind, function () {
53
+ var date = new Date();
54
+ return "".concat(getCurrentDate(date), " ").concat(getCurrentLocalTime(date));
55
+ });
49
56
 
50
- var _useState = useState({
51
- date: formattedDate || DEFAULT_DATE,
52
- time: formattedTime || DEFAULT_TIME
53
- }),
54
- _useState2 = _slicedToArray(_useState, 2),
55
- state = _useState2[0],
56
- setState = _useState2[1];
57
+ var _parseDateTime = parseDateTime(initialValue),
58
+ date = _parseDateTime.date,
59
+ time = _parseDateTime.time;
57
60
 
58
- var date = state.date,
59
- time = state.time;
61
+ var bindValue = bind.value || "";
60
62
  useEffect(function () {
61
- if (!formattedDate || !formattedTime) {
63
+ if (!date || !time || bindValue === initialValue) {
62
64
  return;
63
65
  }
64
66
 
65
- setState(function () {
66
- return {
67
- date: formattedDate,
68
- time: formattedTime
69
- };
70
- });
71
- }, [formattedDate, formattedTime]);
67
+ bind.onChange(initialValue);
68
+ }, [bindValue]);
72
69
  var cellSize = trailingIcon ? 5 : 6;
73
70
  return /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Cell, {
74
71
  span: 6
@@ -76,12 +73,15 @@ var DateTimeWithoutTimezone = function DateTimeWithoutTimezone(_ref) {
76
73
  bind: _objectSpread(_objectSpread({}, bind), {}, {
77
74
  value: date,
78
75
  onChange: function onChange(value) {
79
- setState(function (prev) {
80
- return _objectSpread(_objectSpread({}, prev), {}, {
81
- date: value
82
- });
83
- });
84
- return bind.onChange("".concat(value, " ").concat(time));
76
+ if (!value) {
77
+ if (!bind.value) {
78
+ return;
79
+ }
80
+
81
+ return bind.onChange("");
82
+ }
83
+
84
+ return bind.onChange("".concat(value, " ").concat(time || getCurrentLocalTime()));
85
85
  }
86
86
  }),
87
87
  field: _objectSpread(_objectSpread({}, field), {}, {
@@ -94,12 +94,15 @@ var DateTimeWithoutTimezone = function DateTimeWithoutTimezone(_ref) {
94
94
  bind: _objectSpread(_objectSpread({}, bind), {}, {
95
95
  value: time,
96
96
  onChange: function onChange(value) {
97
- setState(function (prev) {
98
- return _objectSpread(_objectSpread({}, prev), {}, {
99
- time: value
100
- });
101
- });
102
- return bind.onChange("".concat(date, " ").concat(value));
97
+ if (!value) {
98
+ if (!bind.value) {
99
+ return;
100
+ }
101
+
102
+ return bind.onChange("");
103
+ }
104
+
105
+ return bind.onChange("".concat(date || getCurrentDate(), " ").concat(value));
103
106
  }
104
107
  }),
105
108
  field: _objectSpread(_objectSpread({}, field), {}, {
@@ -110,6 +113,4 @@ var DateTimeWithoutTimezone = function DateTimeWithoutTimezone(_ref) {
110
113
  })), /*#__PURE__*/React.createElement(RemoveFieldButton, {
111
114
  trailingIcon: trailingIcon
112
115
  }));
113
- };
114
-
115
- export default DateTimeWithoutTimezone;
116
+ };
@@ -1,16 +1,15 @@
1
1
  import * as React from "react";
2
2
  import { CmsEditorField } from "../../../../types";
3
3
  import { BindComponentRenderProp } from "@webiny/form";
4
- declare type TrailingIconType = {
4
+ export interface TrailingIcon {
5
5
  icon: React.ReactNode;
6
6
  onClick: any;
7
- };
8
- declare type Props = {
7
+ }
8
+ export interface Props {
9
9
  step?: number;
10
10
  type?: string;
11
11
  bind: BindComponentRenderProp;
12
12
  field: CmsEditorField;
13
- trailingIcon?: TrailingIconType;
14
- };
15
- declare const Input: ({ bind, ...props }: Props) => JSX.Element;
16
- export default Input;
13
+ trailingIcon?: TrailingIcon;
14
+ }
15
+ export declare const Input: React.FC<Props>;
@@ -2,8 +2,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
2
2
  var _excluded = ["bind"];
3
3
  import * as React from "react";
4
4
  import { Input as UiInput } from "@webiny/ui/Input";
5
-
6
- var Input = function Input(_ref) {
5
+ export var Input = function Input(_ref) {
7
6
  var bind = _ref.bind,
8
7
  props = _objectWithoutProperties(_ref, _excluded);
9
8
 
@@ -21,6 +20,4 @@ var Input = function Input(_ref) {
21
20
  type: props.type,
22
21
  trailingIcon: props.trailingIcon
23
22
  }));
24
- };
25
-
26
- export default Input;
23
+ };
@@ -1,3 +1,10 @@
1
- /// <reference types="react" />
2
- declare const Select: (props: any) => JSX.Element;
3
- export default Select;
1
+ import * as React from "react";
2
+ import { SelectProps } from "@webiny/ui/Select";
3
+ export interface Option {
4
+ value: string;
5
+ label: string;
6
+ }
7
+ export interface Props extends SelectProps {
8
+ options: Option[];
9
+ }
10
+ export declare const Select: React.FC<Props>;
@@ -1,13 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { Select as UiSelect } from "@webiny/ui/Select";
3
-
4
- var Select = function Select(props) {
3
+ export var Select = function Select(props) {
5
4
  return /*#__PURE__*/React.createElement(UiSelect, props, props.options.map(function (t) {
6
5
  return /*#__PURE__*/React.createElement("option", {
7
6
  key: t.value,
8
7
  value: t.value
9
8
  }, t.label);
10
9
  }));
11
- };
12
-
13
- export default Select;
10
+ };
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- declare const Time: (props: any) => JSX.Element;
3
- export default Time;
1
+ import React from "react";
2
+ import { Props } from "./Input";
3
+ export declare const Time: React.FC<Props>;
@@ -1,13 +1,37 @@
1
- import React from "react";
2
- import Input from "./Input";
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import React, { useEffect } from "react";
3
+ import { Input } from "./Input";
4
+ import { getCurrentLocalTime, getDefaultFieldValue } from "./utils";
5
+ export var Time = function Time(props) {
6
+ var field = props.field,
7
+ bind = props.bind;
8
+ var time = getDefaultFieldValue(field, bind, function () {
9
+ return getCurrentLocalTime(new Date());
10
+ });
11
+ var bindValue = bind.value || "";
12
+ useEffect(function () {
13
+ if (!time || bindValue === time) {
14
+ return;
15
+ }
3
16
 
4
- var Time = function Time(props) {
5
- // "09:00:00"
17
+ bind.onChange(time);
18
+ }, [bindValue]);
6
19
  return /*#__PURE__*/React.createElement(Input, Object.assign({}, props, {
20
+ bind: _objectSpread(_objectSpread({}, bind), {}, {
21
+ value: time,
22
+ onChange: function onChange(value) {
23
+ if (!value) {
24
+ if (bind.value) {
25
+ return;
26
+ }
27
+
28
+ return bind.onChange("");
29
+ }
30
+
31
+ return bind.onChange(value);
32
+ }
33
+ }),
7
34
  type: "time",
8
- step: 5,
9
- trailingIcon: props.trailingIcon
35
+ step: 5
10
36
  }));
11
- };
12
-
13
- export default Time;
37
+ };
@@ -5,10 +5,10 @@ var _templateObject, _templateObject2;
5
5
  import React from "react";
6
6
  import get from "lodash/get";
7
7
  import { i18n } from "@webiny/app/i18n";
8
- import DateTimeWithoutTimezone from "./DateTimeWithoutTimezone";
9
- import DateTimeWithTimezone from "./DateTimeWithTimezone";
10
- import Time from "./Time";
11
- import Input from "./Input";
8
+ import { DateOnly } from "./DateOnly";
9
+ import { DateTimeWithoutTimezone } from "./DateTimeWithoutTimezone";
10
+ import { DateTimeWithTimezone } from "./DateTimeWithTimezone";
11
+ import { Time } from "./Time";
12
12
  var t = i18n.ns("app-headless-cms/admin/fields/date-time");
13
13
  var plugin = {
14
14
  type: "cms-editor-field-renderer",
@@ -31,26 +31,21 @@ var plugin = {
31
31
  field: field,
32
32
  bind: bind
33
33
  });
34
- }
35
-
36
- if (field.settings.type === "dateTimeWithTimezone") {
34
+ } else if (field.settings.type === "dateTimeWithTimezone") {
37
35
  return /*#__PURE__*/React.createElement(DateTimeWithTimezone, {
38
36
  field: field,
39
37
  bind: bind
40
38
  });
41
- }
42
-
43
- if (field.settings.type === "time") {
39
+ } else if (field.settings.type === "time") {
44
40
  return /*#__PURE__*/React.createElement(Time, {
45
41
  field: field,
46
42
  bind: bind
47
43
  });
48
44
  }
49
45
 
50
- return /*#__PURE__*/React.createElement(Input, {
46
+ return /*#__PURE__*/React.createElement(DateOnly, {
51
47
  bind: bind,
52
- field: field,
53
- type: field.settings.type
48
+ field: field
54
49
  });
55
50
  });
56
51
  }
@@ -1,17 +1,17 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
3
 
4
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
4
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
5
5
 
6
6
  import React from "react";
7
7
  import get from "lodash/get";
8
- import { i18n } from "@webiny/app/i18n";
9
- import { ReactComponent as DeleteIcon } from "@svgr/webpack!../../../icons/close.svg";
10
8
  import DynamicSection from "../DynamicSection";
11
- import DateTimeWithoutTimezone from "./DateTimeWithoutTimezone";
12
- import DateTimeWithTimezone from "./DateTimeWithTimezone";
13
- import Time from "./Time";
14
- import Input from "./Input";
9
+ import { i18n } from "@webiny/app/i18n";
10
+ import { ReactComponent as DeleteIcon } from "../../../icons/close.svg";
11
+ import { DateTimeWithoutTimezone } from "./DateTimeWithoutTimezone";
12
+ import { DateTimeWithTimezone } from "./DateTimeWithTimezone";
13
+ import { DateOnly } from "./DateOnly";
14
+ import { Time } from "./Time";
15
15
  var t = i18n.ns("app-headless-cms/admin/fields/date-time");
16
16
  var plugin = {
17
17
  type: "cms-editor-field-renderer",
@@ -60,21 +60,17 @@ var plugin = {
60
60
  })
61
61
  }),
62
62
  bind: bind.index,
63
- label: t(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Value {number}"])))({
64
- number: index + 1
65
- }),
66
63
  trailingIcon: trailingIcon
67
64
  });
68
65
  }
69
66
 
70
- return /*#__PURE__*/React.createElement(Input, {
67
+ return /*#__PURE__*/React.createElement(DateOnly, {
71
68
  bind: bind.index,
72
69
  field: _objectSpread(_objectSpread({}, props.field), {}, {
73
- label: props.field.label + t(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral([" Value {number}"])))({
70
+ label: props.field.label + t(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral([" Value {number}"])))({
74
71
  number: index + 1
75
72
  })
76
73
  }),
77
- type: field.settings.type,
78
74
  trailingIcon: trailingIcon
79
75
  });
80
76
  });
@@ -1,15 +1,16 @@
1
1
  /// <reference types="react" />
2
+ import { CmsEditorField } from "../../../../types";
2
3
  export declare const UTC_TIMEZONES: {
3
4
  value: string;
4
5
  label: string;
5
6
  }[];
6
- /**
7
- * @returns Current date string in format `YYYY-MM-DD`
8
- */
9
- export declare const getCurrentDateString: () => string;
10
- export declare const DEFAULT_TIME = "00:00:00";
11
- export declare const DEFAULT_DATE: string;
12
7
  export declare const DEFAULT_TIMEZONE = "+01:00";
8
+ export declare const getDefaultFieldValue: (field: CmsEditorField, bind: {
9
+ value: string | null | undefined;
10
+ }, getCurrent: () => string) => string;
11
+ export declare const getCurrentTimeZone: (date?: Date) => string;
12
+ export declare const getCurrentLocalTime: (date?: Date) => string;
13
+ export declare const getCurrentDate: (date?: Date) => string;
13
14
  export declare const RemoveFieldButton: ({ trailingIcon }: {
14
15
  trailingIcon: any;
15
16
  }) => JSX.Element;
@@ -1,3 +1,4 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  import React from "react";
2
3
  import { css } from "emotion";
3
4
  import { Cell } from "@webiny/ui/Grid";
@@ -120,17 +121,58 @@ export var UTC_TIMEZONES = [{
120
121
  value: "+14:00",
121
122
  label: "UTC+14:00"
122
123
  }];
123
- /**
124
- * @returns Current date string in format `YYYY-MM-DD`
125
- */
124
+ export var DEFAULT_TIMEZONE = "+01:00";
125
+ export var getDefaultFieldValue = function getDefaultFieldValue(field, bind, getCurrent) {
126
+ var def = field.settings ? field.settings.defaultSetValue || "null" : "null";
127
+
128
+ if (bind.value || def !== "current") {
129
+ return bind.value || "";
130
+ }
126
131
 
127
- export var getCurrentDateString = function getCurrentDateString() {
128
- var today = new Date().toISOString();
129
- return today.substr(0, 10);
132
+ return getCurrent();
133
+ };
134
+ export var getCurrentTimeZone = function getCurrentTimeZone(date) {
135
+ if (!date) {
136
+ date = new Date();
137
+ }
138
+
139
+ var value = date.toTimeString();
140
+ var matches = value.match(/GMT([+-][0-9]{4})/);
141
+
142
+ if (!matches) {
143
+ return null;
144
+ }
145
+
146
+ var timezone = matches[1];
147
+ return "".concat(timezone.substr(0, 3), ":").concat(timezone.substr(3));
148
+ };
149
+ export var getCurrentLocalTime = function getCurrentLocalTime(date) {
150
+ if (!date) {
151
+ date = new Date();
152
+ }
153
+
154
+ var value = date.toTimeString();
155
+
156
+ var _value$split = value.split(" "),
157
+ _value$split2 = _slicedToArray(_value$split, 1),
158
+ time = _value$split2[0];
159
+
160
+ if (!time || time.match(/^([0-9]{2}):([0-9]{2}):([0-9]{2})$/) === null) {
161
+ return "00:00:00";
162
+ }
163
+
164
+ return time;
165
+ };
166
+ export var getCurrentDate = function getCurrentDate(date) {
167
+ if (!date) {
168
+ date = new Date();
169
+ }
170
+
171
+ var year = String(date.getFullYear()).padStart(4, "0");
172
+ var month = String(date.getMonth() + 1).padStart(2, "0");
173
+ var day = String(date.getDate()).padStart(2, "0");
174
+ return "".concat(year, "-").concat(month, "-").concat(day);
130
175
  };
131
- export var DEFAULT_TIME = "00:00:00";
132
- export var DEFAULT_DATE = getCurrentDateString();
133
- export var DEFAULT_TIMEZONE = "+01:00";
134
176
  var deleteIconStyles = /*#__PURE__*/css({
135
177
  width: "100% !important",
136
178
  height: "100% !important",
@@ -7,7 +7,6 @@ import { i18n } from "@webiny/app/i18n";
7
7
  import { Cell, Grid } from "@webiny/ui/Grid";
8
8
  import { FileManager } from "@webiny/app-admin/components";
9
9
  import File from "./File";
10
- import { FormElementMessage } from "@webiny/ui/FormElementMessage";
11
10
  var t = i18n.ns("app-headless-cms/admin/fields/file");
12
11
  var plugin = {
13
12
  type: "cms-editor-field-renderer",
@@ -57,7 +56,7 @@ var plugin = {
57
56
  description: field.helpText
58
57
  }));
59
58
  });
60
- }), field.helpText && /*#__PURE__*/React.createElement(FormElementMessage, null, field.helpText)));
59
+ })));
61
60
  }
62
61
  }
63
62
  };
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { css } from "emotion";
3
- import { ReactComponent as FileIcon } from "@svgr/webpack!../../fields/icons/round_insert_drive_file-24px.svg";
3
+ import { ReactComponent as FileIcon } from "../../fields/icons/round_insert_drive_file-24px.svg";
4
4
  export var imagePlugins = [".jpg", ".jpeg", ".gif", ".png", ".svg"];
5
5
  export var imageWrapperStyles = /*#__PURE__*/css({
6
6
  height: "auto"
@@ -6,7 +6,7 @@ import React from "react";
6
6
  import get from "lodash/get";
7
7
  import { Input } from "@webiny/ui/Input";
8
8
  import { i18n } from "@webiny/app/i18n";
9
- import { ReactComponent as DeleteIcon } from "@svgr/webpack!../../../icons/close.svg";
9
+ import { ReactComponent as DeleteIcon } from "../../../icons/close.svg";
10
10
  import DynamicSection from "../DynamicSection";
11
11
  var t = i18n.ns("app-headless-cms/admin/fields/text");
12
12
  var plugin = {
@@ -6,7 +6,7 @@ import React from "react";
6
6
  import get from "lodash/get";
7
7
  import { Input } from "@webiny/ui/Input";
8
8
  import { i18n } from "@webiny/app/i18n";
9
- import { ReactComponent as DeleteIcon } from "@svgr/webpack!../../../icons/close.svg";
9
+ import { ReactComponent as DeleteIcon } from "../../../icons/close.svg";
10
10
  import DynamicSection from "../DynamicSection";
11
11
  var t = i18n.ns("app-headless-cms/admin/fields/text");
12
12
  var plugin = {
@@ -6,7 +6,7 @@ import React from "react";
6
6
  import { i18n } from "@webiny/app/i18n";
7
7
  import DynamicSection from "../DynamicSection";
8
8
  import { Fields } from "../../../components/ContentEntryForm/Fields";
9
- import { ReactComponent as DeleteIcon } from "@svgr/webpack!../../../icons/close.svg";
9
+ import { ReactComponent as DeleteIcon } from "../../../icons/close.svg";
10
10
  import { IconButton } from "@webiny/ui/Button";
11
11
  import { Cell } from "@webiny/ui/Grid";
12
12
  import { FormElementMessage } from "@webiny/ui/FormElementMessage";
@@ -30,12 +30,13 @@ var plugin = {
30
30
  var onChange = _ref3.onChange,
31
31
  getValue = _ref3.getValue;
32
32
  return /*#__PURE__*/React.createElement(React.Fragment, null, options.map(function (option, index) {
33
+ var value = field.type === "number" ? Number(option.value) : option.value;
33
34
  return /*#__PURE__*/React.createElement("div", {
34
- key: option.value + index
35
+ key: String(option.value) + index
35
36
  }, /*#__PURE__*/React.createElement(Radio, {
36
37
  label: option.label,
37
- value: getValue(option.value),
38
- onChange: onChange(option.value)
38
+ value: getValue(value),
39
+ onChange: onChange(value)
39
40
  }));
40
41
  }));
41
42
  }));
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ declare const MissingEntryHelpText: React.FC<{
3
+ refModelId: string;
4
+ }>;
5
+ export default MissingEntryHelpText;
@@ -0,0 +1,30 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject, _templateObject2;
4
+
5
+ import React from "react";
6
+ import styled from "@emotion/styled";
7
+ import { Typography } from "@webiny/ui/Typography";
8
+ import { Link } from "@webiny/react-router";
9
+ import { createNewEntryUrl } from "./createEntryUrl";
10
+ import { i18n } from "@webiny/app/i18n";
11
+ var t = i18n.ns("app-headless-cms/admin/fields/ref");
12
+ var missingEntryLabel = t(_templateObject || (_templateObject = _taggedTemplateLiteral(["If you can't find the intended reference value in the target model,\n please close this dialog and populate the {newEntryLink} in the target model first."])));
13
+ var HelpTextTypography = /*#__PURE__*/styled(Typography, {
14
+ label: "HelpTextTypography",
15
+ target: "ex67440"
16
+ })("&{display:inline-block;color:var(--mdc-theme-text-secondary-on-background) !important;}");
17
+
18
+ var MissingEntryHelpText = function MissingEntryHelpText(_ref) {
19
+ var refModelId = _ref.refModelId;
20
+ return /*#__PURE__*/React.createElement(HelpTextTypography, {
21
+ use: "caption"
22
+ }, missingEntryLabel({
23
+ newEntryLink: /*#__PURE__*/React.createElement(Link, {
24
+ to: createNewEntryUrl(refModelId),
25
+ target: "_blank"
26
+ }, t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["entry"]))))
27
+ }));
28
+ };
29
+
30
+ export default MissingEntryHelpText;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ export declare const NewEntryButton: () => JSX.Element;
3
+ interface NewRefEntryProps {
4
+ modelId: string;
5
+ children: React.ReactElement;
6
+ onChange: Function;
7
+ }
8
+ declare const NewRefEntryFormDialog: React.FC<NewRefEntryProps>;
9
+ export default NewRefEntryFormDialog;