@webiny/app-headless-cms 5.22.1 → 5.23.1-beta.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/admin/components/ContentEntryForm/functions/createValidators.js +1 -1
- package/admin/components/ContentEntryForm/useContentEntryForm.d.ts +1 -0
- package/admin/components/ContentEntryForm/useContentEntryForm.js +2 -2
- package/admin/components/ContentModelEditor/Editor.d.ts +1 -1
- package/admin/components/FieldEditor/EditFieldDialog/GeneralTab.js +1 -1
- package/admin/components/FieldEditor/FieldEditorContext.js +3 -0
- package/admin/components/FieldEditor/Styled.d.ts +2 -2
- package/admin/components/FieldEditor/utils/deleteField.js +1 -1
- package/admin/plugins/editor/defaultBar/Divider.d.ts +1 -1
- package/admin/plugins/editor/defaultBar/FormSettings/FormSettingsStyled.d.ts +2 -2
- package/admin/plugins/editor/defaultBar/Name/NameStyled.d.ts +3 -3
- package/admin/plugins/fieldRenderers/dateTime/Time.js +37 -8
- package/admin/plugins/fieldRenderers/ref/components/ContentEntriesAutocomplete.js +38 -3
- package/admin/plugins/fieldRenderers/ref/components/ContentEntriesMultiAutoComplete.js +39 -2
- package/admin/plugins/fieldRenderers/ref/components/MissingEntryHelpText.d.ts +1 -0
- package/admin/plugins/fieldRenderers/ref/components/MissingEntryHelpText.js +8 -2
- package/admin/plugins/fieldRenderers/ref/components/NewRefEntryFormDialog.js +12 -3
- package/admin/plugins/fieldRenderers/ref/components/useReference.js +7 -1
- package/admin/plugins/fieldRenderers/ref/components/useReferences.js +7 -1
- package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntry.d.ts +2 -1
- package/admin/plugins/fieldRenderers/ref/hooks/useNewRefEntry.js +30 -4
- package/admin/plugins/fieldRenderers/ref/refInput.js +3 -2
- package/admin/plugins/fieldRenderers/ref/refInputs.js +3 -2
- package/admin/plugins/fields/richText.js +0 -1
- package/admin/plugins/index.d.ts +1 -1
- package/admin/plugins/permissionRenderer/components/StyledComponents.d.ts +1 -1
- package/admin/plugins/transformers/dateTransformer.js +6 -4
- package/admin/plugins/validators/dateGte.js +42 -11
- package/admin/plugins/validators/dateLte.js +42 -11
- package/admin/plugins/validators/gte.js +33 -5
- package/admin/plugins/validators/in.js +33 -5
- package/admin/plugins/validators/lte.js +33 -5
- package/admin/plugins/validators/maxLength.js +33 -5
- package/admin/plugins/validators/minLength.js +33 -5
- package/admin/plugins/validators/pattern.d.ts +1 -1
- package/admin/plugins/validators/pattern.js +49 -20
- package/admin/plugins/validators/timeGte.js +32 -6
- package/admin/plugins/validators/timeLte.js +32 -6
- package/admin/views/contentEntries/ContentEntry/ContentEntryContext.d.ts +3 -3
- package/admin/views/contentEntries/ContentEntry.js +2 -1
- package/package.json +19 -19
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
3
|
|
|
3
4
|
var _templateObject;
|
|
4
5
|
|
|
5
|
-
import React from "react";
|
|
6
|
+
import React, { useCallback } from "react";
|
|
6
7
|
import debounce from "lodash/debounce";
|
|
7
8
|
import { MultiAutoComplete } from "@webiny/ui/AutoComplete";
|
|
8
9
|
import { Link } from "@webiny/react-router";
|
|
9
10
|
import { i18n } from "@webiny/app/i18n";
|
|
10
11
|
import { useReferences } from "./useReferences";
|
|
11
12
|
import { renderItem } from "./renderItem";
|
|
13
|
+
import NewRefEntryFormDialog, { NewEntryButton } from "./NewRefEntryFormDialog";
|
|
14
|
+
import { useNewRefEntry } from "../hooks/useNewRefEntry";
|
|
12
15
|
var t = i18n.ns("app-headless-cms/admin/fields/ref");
|
|
13
16
|
var warn = t(_templateObject || (_templateObject = _taggedTemplateLiteral(["Before publishing the main content entry, make sure you publish the following referenced entries: {entries}"])));
|
|
14
17
|
|
|
@@ -26,6 +29,13 @@ function ContentEntriesMultiAutocomplete(_ref) {
|
|
|
26
29
|
loading = _useReferences.loading,
|
|
27
30
|
onChange = _useReferences.onChange;
|
|
28
31
|
|
|
32
|
+
var _useNewRefEntry = useNewRefEntry({
|
|
33
|
+
field: field
|
|
34
|
+
}),
|
|
35
|
+
renderNewEntryModal = _useNewRefEntry.renderNewEntryModal,
|
|
36
|
+
refModelId = _useNewRefEntry.refModelId,
|
|
37
|
+
helpText = _useNewRefEntry.helpText;
|
|
38
|
+
|
|
29
39
|
var entryWarning = function entryWarning(_ref2, index) {
|
|
30
40
|
var id = _ref2.id,
|
|
31
41
|
modelId = _ref2.modelId,
|
|
@@ -48,6 +58,32 @@ function ContentEntriesMultiAutocomplete(_ref) {
|
|
|
48
58
|
});
|
|
49
59
|
}
|
|
50
60
|
|
|
61
|
+
var refEntryOnChange = useCallback(function (value) {
|
|
62
|
+
/**
|
|
63
|
+
* Append new selected entry at the end of existing entries.
|
|
64
|
+
*/
|
|
65
|
+
onChange([].concat(_toConsumableArray(entries), [value]));
|
|
66
|
+
}, [onChange, entries]);
|
|
67
|
+
|
|
68
|
+
if (renderNewEntryModal) {
|
|
69
|
+
return /*#__PURE__*/React.createElement(NewRefEntryFormDialog, {
|
|
70
|
+
modelId: refModelId,
|
|
71
|
+
onChange: refEntryOnChange
|
|
72
|
+
}, /*#__PURE__*/React.createElement(MultiAutoComplete, Object.assign({}, bind, {
|
|
73
|
+
renderItem: renderItem,
|
|
74
|
+
renderListItemLabel: renderItem,
|
|
75
|
+
useMultipleSelectionList: true,
|
|
76
|
+
onChange: onChange,
|
|
77
|
+
loading: loading,
|
|
78
|
+
value: entries,
|
|
79
|
+
options: options,
|
|
80
|
+
label: field.label,
|
|
81
|
+
onInput: debounce(setSearch, 250),
|
|
82
|
+
description: /*#__PURE__*/React.createElement(React.Fragment, null, field.helpText, warning),
|
|
83
|
+
noResultFound: /*#__PURE__*/React.createElement(NewEntryButton, null)
|
|
84
|
+
})));
|
|
85
|
+
}
|
|
86
|
+
|
|
51
87
|
return /*#__PURE__*/React.createElement(MultiAutoComplete, Object.assign({}, bind, {
|
|
52
88
|
renderItem: renderItem,
|
|
53
89
|
renderListItemLabel: renderItem,
|
|
@@ -58,7 +94,8 @@ function ContentEntriesMultiAutocomplete(_ref) {
|
|
|
58
94
|
options: options,
|
|
59
95
|
label: field.label,
|
|
60
96
|
onInput: debounce(setSearch, 250),
|
|
61
|
-
description: /*#__PURE__*/React.createElement(React.Fragment, null, field.helpText, warning)
|
|
97
|
+
description: /*#__PURE__*/React.createElement(React.Fragment, null, field.helpText, warning),
|
|
98
|
+
noResultFound: helpText
|
|
62
99
|
}));
|
|
63
100
|
}
|
|
64
101
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject, _templateObject2;
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
4
4
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import styled from "@emotion/styled";
|
|
@@ -10,10 +10,16 @@ import { createNewEntryUrl } from "./createEntryUrl";
|
|
|
10
10
|
import { i18n } from "@webiny/app/i18n";
|
|
11
11
|
var t = i18n.ns("app-headless-cms/admin/fields/ref");
|
|
12
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 referenceMultipleModelsLabel = t(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["The creation of reference values from within this view is only supported\n when a single reference model is selected. To reference values from multiple models,\n please make sure the referenced values exist before setting the reference."])));
|
|
13
14
|
var HelpTextTypography = /*#__PURE__*/styled(Typography, {
|
|
14
15
|
label: "HelpTextTypography",
|
|
15
16
|
target: "ex67440"
|
|
16
17
|
})("&{display:inline-block;color:var(--mdc-theme-text-secondary-on-background) !important;}");
|
|
18
|
+
export var ReferenceMultipleModelsHelpText = function ReferenceMultipleModelsHelpText() {
|
|
19
|
+
return /*#__PURE__*/React.createElement(HelpTextTypography, {
|
|
20
|
+
use: "caption"
|
|
21
|
+
}, referenceMultipleModelsLabel);
|
|
22
|
+
};
|
|
17
23
|
|
|
18
24
|
var MissingEntryHelpText = function MissingEntryHelpText(_ref) {
|
|
19
25
|
var refModelId = _ref.refModelId;
|
|
@@ -23,7 +29,7 @@ var MissingEntryHelpText = function MissingEntryHelpText(_ref) {
|
|
|
23
29
|
newEntryLink: /*#__PURE__*/React.createElement(Link, {
|
|
24
30
|
to: createNewEntryUrl(refModelId),
|
|
25
31
|
target: "_blank"
|
|
26
|
-
}, t(
|
|
32
|
+
}, t(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["entry"]))))
|
|
27
33
|
}));
|
|
28
34
|
};
|
|
29
35
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
4
|
|
|
@@ -36,7 +37,8 @@ var EntryForm = function EntryForm(_ref) {
|
|
|
36
37
|
onForm: function onForm(form) {
|
|
37
38
|
return setFormRef(form);
|
|
38
39
|
},
|
|
39
|
-
entry: {}
|
|
40
|
+
entry: {},
|
|
41
|
+
addEntryToListCache: false
|
|
40
42
|
});
|
|
41
43
|
};
|
|
42
44
|
|
|
@@ -108,13 +110,20 @@ var NewRefEntryFormDialog = function NewRefEntryFormDialog(_ref2) {
|
|
|
108
110
|
return setOpen(false);
|
|
109
111
|
}, []);
|
|
110
112
|
var onCreate = useCallback(function (entry) {
|
|
111
|
-
onChange(entry)
|
|
113
|
+
onChange(_objectSpread(_objectSpread({}, entry), {}, {
|
|
114
|
+
/*
|
|
115
|
+
* Format data for AutoComplete.
|
|
116
|
+
*/
|
|
117
|
+
published: get(entry, "meta.status") === "published",
|
|
118
|
+
modelId: contentModel.modelId,
|
|
119
|
+
modelName: contentModel.name
|
|
120
|
+
}));
|
|
112
121
|
/*
|
|
113
122
|
Close the modal
|
|
114
123
|
*/
|
|
115
124
|
|
|
116
125
|
setOpen(false);
|
|
117
|
-
}, [
|
|
126
|
+
}, [onChange, contentModel]);
|
|
118
127
|
|
|
119
128
|
if (!contentModel) {
|
|
120
129
|
return children;
|
|
@@ -143,7 +143,13 @@ export var useReference = function useReference(_ref) {
|
|
|
143
143
|
}),
|
|
144
144
|
query: "__latest__",
|
|
145
145
|
limit: 10
|
|
146
|
-
}
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* We cannot update this query response in cache after a reference entry being created/deleted,
|
|
150
|
+
* which result in cached response being stale, therefore, we're setting the fetchPolicy to "network-only" to by passing cache.
|
|
151
|
+
*/
|
|
152
|
+
fetchPolicy: "network-only"
|
|
147
153
|
}).then(function (_ref3) {
|
|
148
154
|
var data = _ref3.data;
|
|
149
155
|
var latestEntryData = convertQueryDataToEntryList(data.content.data);
|
|
@@ -111,7 +111,13 @@ export var useReferences = function useReferences(_ref) {
|
|
|
111
111
|
}),
|
|
112
112
|
query: "__latest__",
|
|
113
113
|
limit: 10
|
|
114
|
-
}
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* We cannot update this query response in cache after a reference entry being created/deleted,
|
|
118
|
+
* which result in cached response being stale, therefore, we're setting the fetchPolicy to "network-only" to by passing cache.
|
|
119
|
+
*/
|
|
120
|
+
fetchPolicy: "network-only"
|
|
115
121
|
}).then(function (_ref3) {
|
|
116
122
|
var data = _ref3.data;
|
|
117
123
|
setLatestEntries(data.content.data);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { CmsEditorField } from "../../../../../types";
|
|
2
3
|
interface UseNewRefEntryParams {
|
|
3
4
|
field: CmsEditorField;
|
|
4
5
|
}
|
|
5
6
|
interface UseNewRefEntry {
|
|
6
7
|
renderNewEntryModal: boolean;
|
|
7
|
-
renderedInPreviewTab: boolean;
|
|
8
8
|
refModelId: string;
|
|
9
|
+
helpText: React.ReactElement;
|
|
9
10
|
}
|
|
10
11
|
export declare const useNewRefEntry: ({ field }: UseNewRefEntryParams) => UseNewRefEntry;
|
|
11
12
|
export {};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useContext } from "react";
|
|
2
3
|
import { Context as ContentEntriesContext } from "../../../../views/contentEntries/ContentEntriesContext";
|
|
4
|
+
import MissingEntryHelpText, { ReferenceMultipleModelsHelpText } from "../components/MissingEntryHelpText";
|
|
3
5
|
export var useNewRefEntry = function useNewRefEntry(_ref) {
|
|
4
6
|
var field = _ref.field;
|
|
5
|
-
|
|
7
|
+
|
|
8
|
+
var _field$settings$model = _slicedToArray(field.settings.models, 1),
|
|
9
|
+
refModelId = _field$settings$model[0].modelId;
|
|
10
|
+
|
|
11
|
+
var referenceMultipleModels = field.settings.models.length > 1;
|
|
6
12
|
var contentEntriesContextValue = useContext(ContentEntriesContext);
|
|
7
13
|
/**
|
|
8
14
|
* We don't wrap the "ContentEntryForm" with "ContentEntriesContextProvider"
|
|
@@ -13,18 +19,38 @@ export var useNewRefEntry = function useNewRefEntry(_ref) {
|
|
|
13
19
|
*/
|
|
14
20
|
|
|
15
21
|
var renderedInPreviewTab = contentEntriesContextValue === null;
|
|
22
|
+
/**
|
|
23
|
+
* Set "renderNewEntryModal" value.
|
|
24
|
+
*/
|
|
25
|
+
|
|
16
26
|
var renderNewEntryModal;
|
|
17
27
|
|
|
18
28
|
if (renderedInPreviewTab) {
|
|
19
29
|
renderNewEntryModal = false;
|
|
30
|
+
} else if (referenceMultipleModels) {
|
|
31
|
+
renderNewEntryModal = false;
|
|
20
32
|
} else {
|
|
21
33
|
var insideDialog = contentEntriesContextValue.insideDialog;
|
|
22
34
|
renderNewEntryModal = !insideDialog;
|
|
23
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Set "helpText" value.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
var helpText = null;
|
|
42
|
+
|
|
43
|
+
if (referenceMultipleModels) {
|
|
44
|
+
helpText = /*#__PURE__*/React.createElement(ReferenceMultipleModelsHelpText, null);
|
|
45
|
+
} else {
|
|
46
|
+
helpText = /*#__PURE__*/React.createElement(MissingEntryHelpText, {
|
|
47
|
+
refModelId: refModelId
|
|
48
|
+
});
|
|
49
|
+
}
|
|
24
50
|
|
|
25
51
|
return {
|
|
26
52
|
renderNewEntryModal: renderNewEntryModal,
|
|
27
|
-
|
|
28
|
-
|
|
53
|
+
refModelId: refModelId,
|
|
54
|
+
helpText: helpText
|
|
29
55
|
};
|
|
30
56
|
};
|
|
@@ -5,6 +5,7 @@ var _templateObject, _templateObject2;
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { i18n } from "@webiny/app/i18n";
|
|
7
7
|
import ContentEntriesAutocomplete from "./components/ContentEntriesAutocomplete";
|
|
8
|
+
import { NewRefEntryDialogContextProvider } from "./hooks/useNewRefEntryDialog";
|
|
8
9
|
var t = i18n.ns("app-headless-cms/admin/fields/ref");
|
|
9
10
|
var plugin = {
|
|
10
11
|
type: "cms-editor-field-renderer",
|
|
@@ -20,9 +21,9 @@ var plugin = {
|
|
|
20
21
|
render: function render(props) {
|
|
21
22
|
var Bind = props.getBind();
|
|
22
23
|
return /*#__PURE__*/React.createElement(Bind, null, function (bind) {
|
|
23
|
-
return /*#__PURE__*/React.createElement(ContentEntriesAutocomplete, Object.assign({}, props, {
|
|
24
|
+
return /*#__PURE__*/React.createElement(NewRefEntryDialogContextProvider, null, /*#__PURE__*/React.createElement(ContentEntriesAutocomplete, Object.assign({}, props, {
|
|
24
25
|
bind: bind
|
|
25
|
-
}));
|
|
26
|
+
})));
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -4,6 +4,7 @@ var _templateObject, _templateObject2;
|
|
|
4
4
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import ContentEntriesMultiAutocomplete from "./components/ContentEntriesMultiAutoComplete";
|
|
7
|
+
import { NewRefEntryDialogContextProvider } from "./hooks/useNewRefEntryDialog";
|
|
7
8
|
import { i18n } from "@webiny/app/i18n";
|
|
8
9
|
var t = i18n.ns("app-headless-cms/admin/fields/ref");
|
|
9
10
|
|
|
@@ -25,11 +26,11 @@ var plugin = {
|
|
|
25
26
|
render: function render(props) {
|
|
26
27
|
var Bind = props.getBind();
|
|
27
28
|
return /*#__PURE__*/React.createElement(Bind, null, function (bind) {
|
|
28
|
-
return /*#__PURE__*/React.createElement(ContentEntriesMultiAutocomplete, Object.assign({
|
|
29
|
+
return /*#__PURE__*/React.createElement(NewRefEntryDialogContextProvider, null, /*#__PURE__*/React.createElement(ContentEntriesMultiAutocomplete, Object.assign({
|
|
29
30
|
key: getKey(props.field, bind)
|
|
30
31
|
}, props, {
|
|
31
32
|
bind: bind
|
|
32
|
-
}));
|
|
33
|
+
})));
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
}
|
package/admin/plugins/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const _default: () => (import("
|
|
2
|
+
declare const _default: () => (import("../../types").CmsEditorFormSettingsPlugin | import("../../types").CmsIconsPlugin | import("../../types").CmsFieldValueTransformer[] | import("@webiny/app/types").CacheGetObjectIdPlugin | import("@webiny/app/types").RoutePlugin[] | import("@webiny/app-admin/types").AdminInstallationPlugin | import("@webiny/app-admin/types").AdminAppPermissionRendererPlugin | import("../../types").CmsContentDetailsPlugin[] | {
|
|
3
3
|
name: string;
|
|
4
4
|
type: string;
|
|
5
5
|
render(): JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const Note: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "
|
|
2
|
+
export declare const Note: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "children" | "style" | "slot" | "title" | "onError" | "color" | "translate" | "hidden" | "className" | "id" | "lang" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is">, object>;
|
|
@@ -5,7 +5,7 @@ var throwTransformError = function throwTransformError(params) {
|
|
|
5
5
|
var type = params.type,
|
|
6
6
|
value = params.value,
|
|
7
7
|
error = params.ex;
|
|
8
|
-
|
|
8
|
+
return new WebinyError("Could not transform value to a date.", "TRANSFORM_ERROR", {
|
|
9
9
|
error: error,
|
|
10
10
|
type: type,
|
|
11
11
|
value: value
|
|
@@ -14,14 +14,14 @@ var throwTransformError = function throwTransformError(params) {
|
|
|
14
14
|
|
|
15
15
|
var dateOnly = function dateOnly(value) {
|
|
16
16
|
if (!value) {
|
|
17
|
-
return null;
|
|
17
|
+
return null;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
try {
|
|
21
21
|
var date = new Date(value).toISOString();
|
|
22
22
|
return date.substr(0, 10);
|
|
23
23
|
} catch (ex) {
|
|
24
|
-
throwTransformError({
|
|
24
|
+
throw throwTransformError({
|
|
25
25
|
ex: ex,
|
|
26
26
|
value: value,
|
|
27
27
|
type: "date"
|
|
@@ -65,6 +65,8 @@ var extractTime = function extractTime(value) {
|
|
|
65
65
|
} else if (result.length === 2) {
|
|
66
66
|
return "".concat(value, ":00");
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
return null;
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
var dateTimeWithTimezone = function dateTimeWithTimezone(value) {
|
|
@@ -110,7 +112,7 @@ var dateTimeWithoutTimezone = function dateTimeWithoutTimezone(value) {
|
|
|
110
112
|
try {
|
|
111
113
|
return new Date("".concat(value.replace(" ", "T"), ".000Z")).toISOString();
|
|
112
114
|
} catch (ex) {
|
|
113
|
-
throwTransformError({
|
|
115
|
+
throw throwTransformError({
|
|
114
116
|
ex: ex,
|
|
115
117
|
value: value,
|
|
116
118
|
type: "dateTimeWithoutTimezone"
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
1
3
|
import { validation } from "@webiny/validation";
|
|
2
4
|
export default (function () {
|
|
3
5
|
return {
|
|
@@ -5,19 +7,48 @@ export default (function () {
|
|
|
5
7
|
name: "cms-model-field-validator-date-gte",
|
|
6
8
|
validator: {
|
|
7
9
|
name: "dateGte",
|
|
8
|
-
validate: function
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
validate: function () {
|
|
11
|
+
var _validate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value, validator) {
|
|
12
|
+
var _validator$settings, gteValue, type;
|
|
13
|
+
|
|
14
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
|
+
while (1) {
|
|
16
|
+
switch (_context.prev = _context.next) {
|
|
17
|
+
case 0:
|
|
18
|
+
_validator$settings = validator.settings, gteValue = _validator$settings.value, type = _validator$settings.type;
|
|
19
|
+
|
|
20
|
+
if (!(typeof gteValue === "undefined")) {
|
|
21
|
+
_context.next = 5;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return _context.abrupt("return", true);
|
|
26
|
+
|
|
27
|
+
case 5:
|
|
28
|
+
if (!(type === "time")) {
|
|
29
|
+
_context.next = 7;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return _context.abrupt("return", validation.validate(value, "timeGte:".concat(gteValue)));
|
|
34
|
+
|
|
35
|
+
case 7:
|
|
36
|
+
return _context.abrupt("return", validation.validate(value, "dateGte:".concat(gteValue)));
|
|
37
|
+
|
|
38
|
+
case 8:
|
|
39
|
+
case "end":
|
|
40
|
+
return _context.stop();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, _callee);
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
function validate(_x, _x2) {
|
|
47
|
+
return _validate.apply(this, arguments);
|
|
17
48
|
}
|
|
18
49
|
|
|
19
|
-
return
|
|
20
|
-
}
|
|
50
|
+
return validate;
|
|
51
|
+
}()
|
|
21
52
|
}
|
|
22
53
|
};
|
|
23
54
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
1
3
|
import { validation } from "@webiny/validation";
|
|
2
4
|
export default (function () {
|
|
3
5
|
return {
|
|
@@ -5,19 +7,48 @@ export default (function () {
|
|
|
5
7
|
name: "cms-model-field-validator-date-lte",
|
|
6
8
|
validator: {
|
|
7
9
|
name: "dateLte",
|
|
8
|
-
validate: function
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
validate: function () {
|
|
11
|
+
var _validate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value, validator) {
|
|
12
|
+
var _validator$settings, lteValue, type;
|
|
13
|
+
|
|
14
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
|
+
while (1) {
|
|
16
|
+
switch (_context.prev = _context.next) {
|
|
17
|
+
case 0:
|
|
18
|
+
_validator$settings = validator.settings, lteValue = _validator$settings.value, type = _validator$settings.type;
|
|
19
|
+
|
|
20
|
+
if (!(typeof lteValue === "undefined")) {
|
|
21
|
+
_context.next = 5;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return _context.abrupt("return", true);
|
|
26
|
+
|
|
27
|
+
case 5:
|
|
28
|
+
if (!(type === "time")) {
|
|
29
|
+
_context.next = 7;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return _context.abrupt("return", validation.validate(value, "timeLte:".concat(lteValue)));
|
|
34
|
+
|
|
35
|
+
case 7:
|
|
36
|
+
return _context.abrupt("return", validation.validate(value, "dateLte:".concat(lteValue)));
|
|
37
|
+
|
|
38
|
+
case 8:
|
|
39
|
+
case "end":
|
|
40
|
+
return _context.stop();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, _callee);
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
function validate(_x, _x2) {
|
|
47
|
+
return _validate.apply(this, arguments);
|
|
17
48
|
}
|
|
18
49
|
|
|
19
|
-
return
|
|
20
|
-
}
|
|
50
|
+
return validate;
|
|
51
|
+
}()
|
|
21
52
|
}
|
|
22
53
|
};
|
|
23
54
|
});
|
|
@@ -1,15 +1,43 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
1
3
|
import { validation } from "@webiny/validation";
|
|
2
4
|
export default {
|
|
3
5
|
type: "cms-model-field-validator",
|
|
4
6
|
name: "cms-model-field-validator-gte",
|
|
5
7
|
validator: {
|
|
6
8
|
name: "gte",
|
|
7
|
-
validate: function
|
|
8
|
-
var
|
|
9
|
+
validate: function () {
|
|
10
|
+
var _validate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value, validator) {
|
|
11
|
+
var gteValue;
|
|
12
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
13
|
+
while (1) {
|
|
14
|
+
switch (_context.prev = _context.next) {
|
|
15
|
+
case 0:
|
|
16
|
+
gteValue = validator.settings.value;
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
if (!(typeof gteValue === "undefined")) {
|
|
19
|
+
_context.next = 3;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return _context.abrupt("return", true);
|
|
24
|
+
|
|
25
|
+
case 3:
|
|
26
|
+
return _context.abrupt("return", validation.validate(value, "gte:".concat(gteValue)));
|
|
27
|
+
|
|
28
|
+
case 4:
|
|
29
|
+
case "end":
|
|
30
|
+
return _context.stop();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, _callee);
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
function validate(_x, _x2) {
|
|
37
|
+
return _validate.apply(this, arguments);
|
|
12
38
|
}
|
|
13
|
-
|
|
39
|
+
|
|
40
|
+
return validate;
|
|
41
|
+
}()
|
|
14
42
|
}
|
|
15
43
|
};
|
|
@@ -1,15 +1,43 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
1
3
|
import { validation } from "@webiny/validation";
|
|
2
4
|
export default {
|
|
3
5
|
type: "cms-model-field-validator",
|
|
4
6
|
name: "cms-model-field-validator-in",
|
|
5
7
|
validator: {
|
|
6
8
|
name: "in",
|
|
7
|
-
validate: function
|
|
8
|
-
var
|
|
9
|
+
validate: function () {
|
|
10
|
+
var _validate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value, validator) {
|
|
11
|
+
var values;
|
|
12
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
13
|
+
while (1) {
|
|
14
|
+
switch (_context.prev = _context.next) {
|
|
15
|
+
case 0:
|
|
16
|
+
values = validator.settings.values;
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
if (!(Array.isArray(values) === false || values.length === 0)) {
|
|
19
|
+
_context.next = 3;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return _context.abrupt("return", true);
|
|
24
|
+
|
|
25
|
+
case 3:
|
|
26
|
+
return _context.abrupt("return", validation.validate(value, "in:".concat(values.join(":"))));
|
|
27
|
+
|
|
28
|
+
case 4:
|
|
29
|
+
case "end":
|
|
30
|
+
return _context.stop();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, _callee);
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
function validate(_x, _x2) {
|
|
37
|
+
return _validate.apply(this, arguments);
|
|
12
38
|
}
|
|
13
|
-
|
|
39
|
+
|
|
40
|
+
return validate;
|
|
41
|
+
}()
|
|
14
42
|
}
|
|
15
43
|
};
|