@atlaskit/editor-core 151.3.0 → 152.0.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/CHANGELOG.md +90 -0
- package/dist/cjs/create-editor/ReactEditorView.js +22 -8
- package/dist/cjs/create-editor/create-plugins-list.js +25 -9
- package/dist/cjs/labs/next/presets/cxhtml.js +1 -2
- package/dist/cjs/nodeviews/ReactNodeView.js +2 -2
- package/dist/cjs/nodeviews/SelectionBasedNodeView.js +6 -0
- package/dist/cjs/plugins/analytics/types/enums.js +1 -0
- package/dist/cjs/plugins/annotation/utils.js +19 -8
- package/dist/cjs/plugins/avatar-group/index.js +2 -1
- package/dist/cjs/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +5 -2
- package/dist/cjs/plugins/before-primaryToolbar/index.js +26 -0
- package/dist/cjs/plugins/before-primaryToolbar/ui/BeforePrimaryToolbarWrapper.js +28 -0
- package/dist/cjs/plugins/extension/extension-api.js +10 -2
- package/dist/cjs/plugins/extension/ui/styles.js +1 -1
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +4 -2
- package/dist/cjs/plugins/find-replace/FindReplaceToolbarButtonWithState.js +172 -0
- package/dist/cjs/plugins/find-replace/index.js +14 -137
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +10 -4
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +1 -1
- package/dist/cjs/plugins/fragment/index.js +34 -0
- package/dist/cjs/plugins/fragment/plugin-key.js +11 -0
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -1
- package/dist/cjs/plugins/index.js +16 -0
- package/dist/cjs/plugins/list/actions/conversions.js +39 -71
- package/dist/cjs/plugins/list/transforms.js +7 -1
- package/dist/cjs/plugins/media/index.js +2 -3
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +3 -1
- package/dist/cjs/plugins/media/nodeviews/mediaInline.js +12 -5
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +6 -4
- package/dist/cjs/plugins/media/nodeviews/styles.js +6 -1
- package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +5 -1
- package/dist/cjs/plugins/media/pm-plugins/main.js +49 -15
- package/dist/cjs/plugins/media/toolbar/commands.js +59 -0
- package/dist/cjs/plugins/media/toolbar/filePreviewItem.js +7 -2
- package/dist/cjs/plugins/media/toolbar/index.js +90 -3
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/index.js +9 -1
- package/dist/cjs/plugins/media/utils/media-common.js +1 -1
- package/dist/cjs/plugins/media/utils/media-files.js +5 -1
- package/dist/cjs/plugins/panel/actions.js +2 -2
- package/dist/cjs/plugins/panel/index.js +3 -3
- package/dist/cjs/plugins/panel/nodeviews/panel.js +2 -2
- package/dist/cjs/plugins/panel/toolbar.js +10 -5
- package/dist/cjs/plugins/panel/utils.js +15 -0
- package/dist/cjs/plugins/rank.js +3 -2
- package/dist/cjs/plugins/selection/pm-plugins/selection-main.js +49 -1
- package/dist/cjs/plugins/status/ui/statusPicker.js +4 -2
- package/dist/cjs/plugins/table/commands/insert.js +1 -0
- package/dist/cjs/plugins/table/index.js +3 -2
- package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/cjs/plugins/table/pm-plugins/main.js +26 -3
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +2 -0
- package/dist/cjs/plugins/table/transforms/column-width.js +14 -5
- package/dist/cjs/plugins/table/transforms/fix-tables.js +43 -6
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +3 -2
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -0
- package/dist/cjs/plugins/table/ui/common-styles.css.js +1 -1
- package/dist/cjs/plugins/table/ui/consts.js +1 -1
- package/dist/cjs/plugins/table/ui/messages.js +1 -1
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +2 -1
- package/dist/cjs/plugins/text-formatting/index.js +2 -1
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +1 -0
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +77 -26
- package/dist/cjs/ui/Appearance/FullPage/MainToolbar.js +32 -9
- package/dist/cjs/ui/ColorPalette/Color/index.js +8 -18
- package/dist/cjs/ui/ColorPalette/index.js +7 -4
- package/dist/cjs/ui/ColorPickerButton/index.js +1 -1
- package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +114 -61
- package/dist/cjs/ui/ConfigPanel/FormContent.js +39 -26
- package/dist/cjs/ui/ConfigPanel/transformers.js +490 -248
- package/dist/cjs/ui/ConfigPanel/utils.js +2 -10
- package/dist/cjs/ui/DropdownMenu/index.js +3 -1
- package/dist/cjs/ui/LinkSearch/LinkSearchListItem.js +1 -1
- package/dist/cjs/ui/Resizer/index.js +9 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +19 -8
- package/dist/es2019/create-editor/create-plugins-list.js +26 -10
- package/dist/es2019/labs/next/presets/cxhtml.js +1 -2
- package/dist/es2019/nodeviews/ReactNodeView.js +1 -1
- package/dist/es2019/nodeviews/SelectionBasedNodeView.js +11 -0
- package/dist/es2019/plugins/analytics/types/enums.js +1 -0
- package/dist/es2019/plugins/annotation/utils.js +18 -7
- package/dist/es2019/plugins/avatar-group/index.js +2 -1
- package/dist/es2019/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +3 -2
- package/dist/es2019/plugins/before-primaryToolbar/index.js +15 -0
- package/dist/es2019/plugins/before-primaryToolbar/ui/BeforePrimaryToolbarWrapper.js +12 -0
- package/dist/es2019/plugins/extension/extension-api.js +9 -2
- package/dist/es2019/plugins/extension/ui/styles.js +6 -0
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +4 -2
- package/dist/es2019/plugins/find-replace/FindReplaceToolbarButtonWithState.js +152 -0
- package/dist/es2019/plugins/find-replace/index.js +15 -128
- package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +2 -1
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +10 -2
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +1 -1
- package/dist/es2019/plugins/fragment/index.js +22 -0
- package/dist/es2019/plugins/fragment/plugin-key.js +2 -0
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -2
- package/dist/es2019/plugins/index.js +2 -0
- package/dist/es2019/plugins/list/actions/conversions.js +38 -69
- package/dist/es2019/plugins/list/transforms.js +5 -1
- package/dist/es2019/plugins/media/index.js +2 -2
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +2 -1
- package/dist/es2019/plugins/media/nodeviews/mediaInline.js +8 -4
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +7 -5
- package/dist/es2019/plugins/media/nodeviews/styles.js +2 -0
- package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +5 -1
- package/dist/es2019/plugins/media/pm-plugins/main.js +32 -17
- package/dist/es2019/plugins/media/toolbar/commands.js +47 -0
- package/dist/es2019/plugins/media/toolbar/filePreviewItem.js +6 -2
- package/dist/es2019/plugins/media/toolbar/index.js +90 -3
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/index.js +7 -1
- package/dist/es2019/plugins/media/utils/media-common.js +1 -1
- package/dist/es2019/plugins/media/utils/media-files.js +6 -1
- package/dist/es2019/plugins/panel/actions.js +2 -2
- package/dist/es2019/plugins/panel/index.js +5 -5
- package/dist/es2019/plugins/panel/nodeviews/panel.js +2 -2
- package/dist/es2019/plugins/panel/toolbar.js +10 -5
- package/dist/es2019/plugins/panel/utils.js +8 -1
- package/dist/es2019/plugins/rank.js +3 -2
- package/dist/es2019/plugins/selection/pm-plugins/selection-main.js +48 -1
- package/dist/es2019/plugins/status/ui/statusPicker.js +4 -2
- package/dist/es2019/plugins/table/commands/insert.js +1 -2
- package/dist/es2019/plugins/table/index.js +2 -1
- package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +1 -2
- package/dist/es2019/plugins/table/pm-plugins/main.js +25 -4
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +2 -0
- package/dist/es2019/plugins/table/transforms/column-width.js +13 -3
- package/dist/es2019/plugins/table/transforms/fix-tables.js +43 -5
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +3 -2
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -0
- package/dist/es2019/plugins/table/ui/common-styles.css.js +5 -1
- package/dist/es2019/plugins/table/ui/consts.js +2 -2
- package/dist/es2019/plugins/table/ui/messages.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +3 -3
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +2 -1
- package/dist/es2019/plugins/text-formatting/index.js +3 -2
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +2 -1
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +2 -1
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +60 -27
- package/dist/es2019/ui/Appearance/FullPage/MainToolbar.js +51 -7
- package/dist/es2019/ui/ColorPalette/Color/index.js +9 -18
- package/dist/es2019/ui/ColorPalette/index.js +7 -4
- package/dist/es2019/ui/ColorPickerButton/index.js +1 -1
- package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +101 -49
- package/dist/es2019/ui/ConfigPanel/FormContent.js +35 -26
- package/dist/es2019/ui/ConfigPanel/transformers.js +243 -72
- package/dist/es2019/ui/ConfigPanel/utils.js +1 -2
- package/dist/es2019/ui/Dropdown/index.js +2 -1
- package/dist/es2019/ui/DropdownMenu/index.js +7 -3
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +1 -0
- package/dist/es2019/ui/ElementBrowser/components/ElementList/ElementList.js +1 -0
- package/dist/es2019/ui/LinkSearch/LinkSearchListItem.js +2 -2
- package/dist/es2019/ui/Resizer/index.js +9 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +22 -8
- package/dist/esm/create-editor/create-plugins-list.js +26 -10
- package/dist/esm/labs/next/presets/cxhtml.js +1 -2
- package/dist/esm/nodeviews/ReactNodeView.js +2 -2
- package/dist/esm/nodeviews/SelectionBasedNodeView.js +7 -0
- package/dist/esm/plugins/analytics/types/enums.js +1 -0
- package/dist/esm/plugins/annotation/utils.js +18 -7
- package/dist/esm/plugins/avatar-group/index.js +2 -1
- package/dist/esm/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +5 -2
- package/dist/esm/plugins/before-primaryToolbar/index.js +15 -0
- package/dist/esm/plugins/before-primaryToolbar/ui/BeforePrimaryToolbarWrapper.js +12 -0
- package/dist/esm/plugins/extension/extension-api.js +9 -2
- package/dist/esm/plugins/extension/ui/styles.js +1 -1
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +4 -2
- package/dist/esm/plugins/find-replace/FindReplaceToolbarButtonWithState.js +155 -0
- package/dist/esm/plugins/find-replace/index.js +14 -131
- package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +2 -1
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +9 -4
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +1 -1
- package/dist/esm/plugins/fragment/index.js +22 -0
- package/dist/esm/plugins/fragment/plugin-key.js +2 -0
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -2
- package/dist/esm/plugins/index.js +2 -0
- package/dist/esm/plugins/list/actions/conversions.js +38 -71
- package/dist/esm/plugins/list/transforms.js +7 -1
- package/dist/esm/plugins/media/index.js +2 -3
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +2 -1
- package/dist/esm/plugins/media/nodeviews/mediaInline.js +11 -6
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +7 -5
- package/dist/esm/plugins/media/nodeviews/styles.js +2 -0
- package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +5 -1
- package/dist/esm/plugins/media/pm-plugins/main.js +47 -16
- package/dist/esm/plugins/media/toolbar/commands.js +45 -0
- package/dist/esm/plugins/media/toolbar/filePreviewItem.js +6 -2
- package/dist/esm/plugins/media/toolbar/index.js +88 -3
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/index.js +9 -1
- package/dist/esm/plugins/media/utils/media-common.js +1 -1
- package/dist/esm/plugins/media/utils/media-files.js +6 -1
- package/dist/esm/plugins/panel/actions.js +2 -2
- package/dist/esm/plugins/panel/index.js +5 -5
- package/dist/esm/plugins/panel/nodeviews/panel.js +2 -2
- package/dist/esm/plugins/panel/toolbar.js +9 -4
- package/dist/esm/plugins/panel/utils.js +13 -0
- package/dist/esm/plugins/rank.js +3 -2
- package/dist/esm/plugins/selection/pm-plugins/selection-main.js +50 -1
- package/dist/esm/plugins/status/ui/statusPicker.js +4 -2
- package/dist/esm/plugins/table/commands/insert.js +1 -2
- package/dist/esm/plugins/table/index.js +3 -2
- package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +1 -2
- package/dist/esm/plugins/table/pm-plugins/main.js +27 -4
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/colgroup.js +2 -2
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +2 -0
- package/dist/esm/plugins/table/transforms/column-width.js +13 -3
- package/dist/esm/plugins/table/transforms/fix-tables.js +42 -4
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +3 -2
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -0
- package/dist/esm/plugins/table/ui/common-styles.css.js +1 -1
- package/dist/esm/plugins/table/ui/consts.js +2 -2
- package/dist/esm/plugins/table/ui/messages.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +3 -3
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +2 -1
- package/dist/esm/plugins/text-formatting/index.js +3 -2
- package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +2 -1
- package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +2 -1
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +67 -27
- package/dist/esm/ui/Appearance/FullPage/MainToolbar.js +20 -7
- package/dist/esm/ui/ColorPalette/Color/index.js +9 -16
- package/dist/esm/ui/ColorPalette/index.js +7 -4
- package/dist/esm/ui/ColorPickerButton/index.js +1 -1
- package/dist/esm/ui/ConfigPanel/ConfigPanel.js +113 -62
- package/dist/esm/ui/ConfigPanel/FormContent.js +39 -26
- package/dist/esm/ui/ConfigPanel/transformers.js +488 -248
- package/dist/esm/ui/ConfigPanel/utils.js +1 -6
- package/dist/esm/ui/Dropdown/index.js +2 -1
- package/dist/esm/ui/DropdownMenu/index.js +7 -3
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +1 -0
- package/dist/esm/ui/ElementBrowser/components/ElementList/ElementList.js +1 -0
- package/dist/esm/ui/LinkSearch/LinkSearchListItem.js +2 -2
- package/dist/esm/ui/Resizer/index.js +9 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/full-page.d.ts +1 -1
- package/dist/types/nodeviews/ReactNodeView.d.ts +1 -1
- package/dist/types/nodeviews/SelectionBasedNodeView.d.ts +1 -0
- package/dist/types/plugins/analytics/types/enums.d.ts +1 -0
- package/dist/types/plugins/analytics/types/events.d.ts +7 -1
- package/dist/types/plugins/annotation/utils.d.ts +1 -1
- package/dist/types/plugins/avatar-group/index.d.ts +1 -0
- package/dist/types/plugins/avatar-group/ui/AvatarGroupPluginWrapper.d.ts +1 -0
- package/dist/types/plugins/before-primaryToolbar/index.d.ts +5 -0
- package/dist/types/plugins/before-primaryToolbar/ui/BeforePrimaryToolbarWrapper.d.ts +5 -0
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
- package/dist/types/plugins/find-replace/FindReplaceToolbarButtonWithState.d.ts +15 -0
- package/dist/types/plugins/find-replace/index.d.ts +1 -0
- package/dist/types/plugins/floating-toolbar/ui/EmojiPickerButton.d.ts +1 -1
- package/dist/types/plugins/fragment/index.d.ts +5 -0
- package/dist/types/plugins/fragment/plugin-key.d.ts +2 -0
- package/dist/types/plugins/index.d.ts +2 -0
- package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +3 -2
- package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +1 -1
- package/dist/types/plugins/media/nodeviews/styles.d.ts +2 -0
- package/dist/types/plugins/media/toolbar/commands.d.ts +3 -0
- package/dist/types/plugins/media/toolbar/filePreviewItem.d.ts +2 -0
- package/dist/types/plugins/media/types.d.ts +0 -1
- package/dist/types/plugins/panel/actions.d.ts +1 -1
- package/dist/types/plugins/panel/types.d.ts +8 -2
- package/dist/types/plugins/quick-insert/index.d.ts +2 -1
- package/dist/types/plugins/table/commands/insert.d.ts +3 -0
- package/dist/types/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +1 -0
- package/dist/types/plugins/table/transforms/column-width.d.ts +4 -1
- package/dist/types/plugins/table/transforms/fix-tables.d.ts +3 -2
- package/dist/types/plugins/table/types.d.ts +8 -0
- package/dist/types/plugins/table/ui/consts.d.ts +1 -1
- package/dist/types/types/editor-appearance-component.d.ts +2 -2
- package/dist/types/types/editor-props.d.ts +11 -1
- package/dist/types/types/feature-flags.d.ts +13 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/FullPageToolbar.d.ts +2 -2
- package/dist/types/ui/Appearance/FullPage/MainToolbar.d.ts +10 -1
- package/dist/types/ui/ColorPalette/Color/index.d.ts +8 -5
- package/dist/types/ui/ColorPalette/index.d.ts +1 -0
- package/dist/types/ui/ConfigPanel/transformers.d.ts +7 -1
- package/dist/types/ui/ConfigPanel/utils.d.ts +0 -1
- package/dist/types/ui/Resizer/index.d.ts +1 -0
- package/package.json +32 -29
- package/dist/cjs/plugins/floating-toolbar/ui/EditorRemoveEmojiIcon.js +0 -38
- package/dist/es2019/plugins/floating-toolbar/ui/EditorRemoveEmojiIcon.js +0 -28
- package/dist/esm/plugins/floating-toolbar/ui/EditorRemoveEmojiIcon.js +0 -28
- package/dist/types/plugins/floating-toolbar/ui/EditorRemoveEmojiIcon.d.ts +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
5
5
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
6
6
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
11
11
|
|
|
12
12
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
13
13
|
|
|
14
|
-
import { isFieldset, isDateRange, isTabGroup, isExpand, getFieldSerializer, getFieldDeserializer } from '@atlaskit/editor-common/extensions';
|
|
14
|
+
import { isFieldset, isDateRange, isTabGroup, isTabField, isExpand, getFieldSerializer, getFieldDeserializer } from '@atlaskit/editor-common/extensions';
|
|
15
15
|
import { getNameFromDuplicateField, isDuplicateField } from './utils';
|
|
16
16
|
|
|
17
17
|
var isOption = function isOption(option) {
|
|
@@ -21,10 +21,9 @@ var isOption = function isOption(option) {
|
|
|
21
21
|
var isOptions = function isOptions(options) {
|
|
22
22
|
return Array.isArray(options) && options.every(isOption);
|
|
23
23
|
};
|
|
24
|
-
/** maps the typed-values from the Form values object */
|
|
25
|
-
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
/** maps the typed-values from the Form values object */
|
|
26
|
+
function extract(value, field, options) {
|
|
28
27
|
if (isOptions(value)) {
|
|
29
28
|
return value.map(function (item) {
|
|
30
29
|
return item.value;
|
|
@@ -39,229 +38,463 @@ function extract(value, field) {
|
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
return Number(value);
|
|
41
|
+
} // Workaround for https://product-fabric.atlassian.net/browse/DST-2701
|
|
42
|
+
else if (options !== null && options !== void 0 && options.useDefaultValue && value === undefined && 'defaultValue' in field) {
|
|
43
|
+
return field.defaultValue;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
return value;
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
export var findDuplicateFields = function findDuplicateFields(fields) {
|
|
50
|
+
return findDuplicateFieldsInternal(flattenFields(fields));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var findDuplicateFieldsInternal = function findDuplicateFieldsInternal(fields) {
|
|
54
|
+
var allowDuplicatesMap = {};
|
|
55
|
+
return fields.find(function (field) {
|
|
56
|
+
if (isExpand(field)) {
|
|
57
|
+
return findDuplicateFieldsInternal(field.fields);
|
|
58
|
+
} else if (isTabGroup(field)) {
|
|
59
|
+
return field.fields.find(function (tabField) {
|
|
60
|
+
return findDuplicateFieldsInternal(tabField.fields);
|
|
61
|
+
});
|
|
62
|
+
} else if (allowDuplicatesMap[field.name] === undefined) {
|
|
63
|
+
allowDuplicatesMap[field.name] = !!field.allowDuplicates;
|
|
64
|
+
return;
|
|
65
|
+
} else if (!field.allowDuplicates || !allowDuplicatesMap[field.name]) {
|
|
66
|
+
return field;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return;
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
47
73
|
export var serialize = /*#__PURE__*/function () {
|
|
48
74
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(manifest, data, fields) {
|
|
49
|
-
var
|
|
75
|
+
var options,
|
|
50
76
|
result,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
77
|
+
_options$depth,
|
|
78
|
+
depth,
|
|
79
|
+
parentType,
|
|
80
|
+
flattenedFields,
|
|
81
|
+
fillResults,
|
|
82
|
+
parameters,
|
|
54
83
|
hasDuplicateFields,
|
|
55
|
-
|
|
84
|
+
_args2 = arguments;
|
|
56
85
|
|
|
57
|
-
return _regeneratorRuntime.wrap(function _callee2$(
|
|
86
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
58
87
|
while (1) {
|
|
59
|
-
switch (
|
|
88
|
+
switch (_context2.prev = _context2.next) {
|
|
60
89
|
case 0:
|
|
61
|
-
|
|
90
|
+
options = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : {};
|
|
62
91
|
result = [];
|
|
92
|
+
_options$depth = options.depth, depth = _options$depth === void 0 ? 0 : _options$depth, parentType = options.parentType;
|
|
93
|
+
flattenedFields = flattenFields(fields);
|
|
94
|
+
fillResults = flattenedFields.map( /*#__PURE__*/function () {
|
|
95
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(field) {
|
|
96
|
+
var tabGroupData, tabData, expandData, fieldsetData, value;
|
|
97
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
98
|
+
while (1) {
|
|
99
|
+
switch (_context.prev = _context.next) {
|
|
100
|
+
case 0:
|
|
101
|
+
if (!isTabGroup(field)) {
|
|
102
|
+
_context.next = 7;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
_context.next = 3;
|
|
107
|
+
return serializeTabGroupField(manifest, field, data);
|
|
108
|
+
|
|
109
|
+
case 3:
|
|
110
|
+
tabGroupData = _context.sent;
|
|
111
|
+
result.push.apply(result, _toConsumableArray(tabGroupData));
|
|
112
|
+
_context.next = 30;
|
|
113
|
+
break;
|
|
63
114
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
115
|
+
case 7:
|
|
116
|
+
if (!isTabField(field)) {
|
|
117
|
+
_context.next = 14;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
68
120
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return _regeneratorRuntime.wrap(function _loop$(_context2) {
|
|
72
|
-
while (1) {
|
|
73
|
-
switch (_context2.prev = _context2.next) {
|
|
74
|
-
case 0:
|
|
75
|
-
field = fields.find(function (field) {
|
|
76
|
-
return field.name === getNameFromDuplicateField(name);
|
|
77
|
-
});
|
|
121
|
+
_context.next = 10;
|
|
122
|
+
return serializeTabField(manifest, field, data);
|
|
78
123
|
|
|
79
|
-
|
|
80
|
-
|
|
124
|
+
case 10:
|
|
125
|
+
tabData = _context.sent;
|
|
126
|
+
result.push.apply(result, _toConsumableArray(tabData));
|
|
127
|
+
_context.next = 30;
|
|
81
128
|
break;
|
|
82
|
-
}
|
|
83
129
|
|
|
84
|
-
|
|
130
|
+
case 14:
|
|
131
|
+
if (!isExpand(field)) {
|
|
132
|
+
_context.next = 21;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
85
135
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
value = extract(data[name], field);
|
|
136
|
+
_context.next = 17;
|
|
137
|
+
return serializeExpandField(manifest, field, data);
|
|
89
138
|
|
|
90
|
-
|
|
91
|
-
|
|
139
|
+
case 17:
|
|
140
|
+
expandData = _context.sent;
|
|
141
|
+
result.push.apply(result, _toConsumableArray(expandData));
|
|
142
|
+
_context.next = 30;
|
|
92
143
|
break;
|
|
93
|
-
}
|
|
94
144
|
|
|
95
|
-
|
|
145
|
+
case 21:
|
|
146
|
+
if (!(isFieldset(field) && depth === 0)) {
|
|
147
|
+
_context.next = 28;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
96
150
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
_context2.next = 21;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
151
|
+
_context.next = 24;
|
|
152
|
+
return serializeFieldset(manifest, field, data, depth);
|
|
102
153
|
|
|
103
|
-
|
|
104
|
-
|
|
154
|
+
case 24:
|
|
155
|
+
fieldsetData = _context.sent;
|
|
105
156
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
while (1) {
|
|
110
|
-
switch (_context.prev = _context.next) {
|
|
111
|
-
case 0:
|
|
112
|
-
_context.next = 2;
|
|
113
|
-
return serialize(manifest, groupData[tabField.name] || {}, tabField.fields);
|
|
157
|
+
if (fieldsetData) {
|
|
158
|
+
result.push(fieldsetData);
|
|
159
|
+
}
|
|
114
160
|
|
|
115
|
-
|
|
116
|
-
|
|
161
|
+
_context.next = 30;
|
|
162
|
+
break;
|
|
117
163
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
}, _callee);
|
|
124
|
-
}));
|
|
164
|
+
case 28:
|
|
165
|
+
value = extract(data[field.name], field, {
|
|
166
|
+
useDefaultValue: true
|
|
167
|
+
}); // ignore undefined values
|
|
125
168
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
}();
|
|
169
|
+
if (value !== undefined) {
|
|
170
|
+
result.push(_defineProperty({}, field.name, value));
|
|
171
|
+
}
|
|
130
172
|
|
|
131
|
-
|
|
173
|
+
case 30:
|
|
174
|
+
case "end":
|
|
175
|
+
return _context.stop();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}, _callee);
|
|
179
|
+
}));
|
|
180
|
+
|
|
181
|
+
return function (_x4) {
|
|
182
|
+
return _ref2.apply(this, arguments);
|
|
183
|
+
};
|
|
184
|
+
}());
|
|
185
|
+
_context2.next = 7;
|
|
186
|
+
return Promise.all(fillResults);
|
|
187
|
+
|
|
188
|
+
case 7:
|
|
189
|
+
// Crunch fields down to parameters
|
|
190
|
+
parameters = result.reduce(function (obj, current) {
|
|
191
|
+
for (var _key in current) {
|
|
192
|
+
obj[_key] = current[_key];
|
|
193
|
+
}
|
|
132
194
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
_context2.next = 19;
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
195
|
+
return obj;
|
|
196
|
+
}, {}); // Fix up duplicate values (currently only for fieldsets)
|
|
138
197
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
198
|
+
hasDuplicateFields = parentType === 'fieldset' && !!flattenedFields.find(function (field) {
|
|
199
|
+
return field.allowDuplicates;
|
|
200
|
+
});
|
|
142
201
|
|
|
143
|
-
|
|
144
|
-
|
|
202
|
+
if (!hasDuplicateFields) {
|
|
203
|
+
_context2.next = 11;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
145
206
|
|
|
146
|
-
|
|
147
|
-
i++;
|
|
148
|
-
_context2.next = 11;
|
|
149
|
-
break;
|
|
207
|
+
return _context2.abrupt("return", serializeMergeDuplicateFieldData(parameters, data, flattenedFields));
|
|
150
208
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
break;
|
|
209
|
+
case 11:
|
|
210
|
+
return _context2.abrupt("return", parameters);
|
|
154
211
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
212
|
+
case 12:
|
|
213
|
+
case "end":
|
|
214
|
+
return _context2.stop();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, _callee2);
|
|
218
|
+
}));
|
|
160
219
|
|
|
161
|
-
|
|
162
|
-
|
|
220
|
+
return function serialize(_x, _x2, _x3) {
|
|
221
|
+
return _ref.apply(this, arguments);
|
|
222
|
+
};
|
|
223
|
+
}();
|
|
163
224
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
225
|
+
var serializeFieldset = /*#__PURE__*/function () {
|
|
226
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(manifest, field, data, depth) {
|
|
227
|
+
var fieldSerializer, fieldsetFields, fieldParams, extracted;
|
|
228
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
229
|
+
while (1) {
|
|
230
|
+
switch (_context3.prev = _context3.next) {
|
|
231
|
+
case 0:
|
|
232
|
+
_context3.prev = 0;
|
|
233
|
+
_context3.next = 3;
|
|
234
|
+
return getFieldSerializer(manifest, field.options.transformer);
|
|
168
235
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
236
|
+
case 3:
|
|
237
|
+
fieldSerializer = _context3.sent;
|
|
238
|
+
_context3.next = 10;
|
|
239
|
+
break;
|
|
174
240
|
|
|
175
|
-
|
|
176
|
-
|
|
241
|
+
case 6:
|
|
242
|
+
_context3.prev = 6;
|
|
243
|
+
_context3.t0 = _context3["catch"](0);
|
|
177
244
|
|
|
178
|
-
|
|
179
|
-
|
|
245
|
+
if (!(data[field.name] !== undefined)) {
|
|
246
|
+
_context3.next = 10;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
180
249
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
250
|
+
throw _context3.t0;
|
|
251
|
+
|
|
252
|
+
case 10:
|
|
253
|
+
if (fieldSerializer) {
|
|
254
|
+
_context3.next = 12;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
185
257
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
258
|
+
return _context3.abrupt("return");
|
|
259
|
+
|
|
260
|
+
case 12:
|
|
261
|
+
fieldsetFields = field.fields;
|
|
262
|
+
fieldParams = extract(data[field.name], field, {
|
|
263
|
+
useDefaultValue: true
|
|
264
|
+
}) || {};
|
|
265
|
+
_context3.next = 16;
|
|
266
|
+
return serialize(manifest, fieldParams, fieldsetFields, {
|
|
267
|
+
depth: depth + 1,
|
|
268
|
+
parentType: 'fieldset'
|
|
269
|
+
});
|
|
189
270
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
271
|
+
case 16:
|
|
272
|
+
extracted = _context3.sent;
|
|
273
|
+
return _context3.abrupt("return", _defineProperty({}, field.name, fieldSerializer(extracted)));
|
|
193
274
|
|
|
194
|
-
|
|
195
|
-
|
|
275
|
+
case 18:
|
|
276
|
+
case "end":
|
|
277
|
+
return _context3.stop();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}, _callee3, null, [[0, 6]]);
|
|
281
|
+
}));
|
|
196
282
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
283
|
+
return function serializeFieldset(_x5, _x6, _x7, _x8) {
|
|
284
|
+
return _ref3.apply(this, arguments);
|
|
285
|
+
};
|
|
286
|
+
}();
|
|
287
|
+
|
|
288
|
+
var serializeExpandField = /*#__PURE__*/function () {
|
|
289
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(manifest, field, data) {
|
|
290
|
+
var expandData, value, results, fieldName;
|
|
291
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
292
|
+
while (1) {
|
|
293
|
+
switch (_context4.prev = _context4.next) {
|
|
294
|
+
case 0:
|
|
295
|
+
expandData = field.hasGroupedValues ? data[field.name] || {} : data;
|
|
296
|
+
_context4.next = 3;
|
|
297
|
+
return serialize(manifest, expandData, field.fields, {
|
|
298
|
+
parentType: 'expand'
|
|
203
299
|
});
|
|
204
|
-
_context3.t0 = _regeneratorRuntime.keys(data);
|
|
205
300
|
|
|
206
|
-
case
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
301
|
+
case 3:
|
|
302
|
+
value = _context4.sent;
|
|
303
|
+
results = [];
|
|
304
|
+
|
|
305
|
+
if (!field.hasGroupedValues) {
|
|
306
|
+
for (fieldName in value) {
|
|
307
|
+
results.push(_defineProperty({}, fieldName, value[fieldName]));
|
|
308
|
+
}
|
|
309
|
+
} else {
|
|
310
|
+
results.push(_defineProperty({}, field.name, value));
|
|
210
311
|
}
|
|
211
312
|
|
|
212
|
-
|
|
213
|
-
return _context3.delegateYield(_loop(name), "t2", 8);
|
|
313
|
+
return _context4.abrupt("return", results);
|
|
214
314
|
|
|
215
|
-
case
|
|
216
|
-
|
|
315
|
+
case 7:
|
|
316
|
+
case "end":
|
|
317
|
+
return _context4.stop();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}, _callee4);
|
|
321
|
+
}));
|
|
322
|
+
|
|
323
|
+
return function serializeExpandField(_x9, _x10, _x11) {
|
|
324
|
+
return _ref5.apply(this, arguments);
|
|
325
|
+
};
|
|
326
|
+
}();
|
|
327
|
+
|
|
328
|
+
var resolveTabValues = /*#__PURE__*/function () {
|
|
329
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(manifest, tabField, groupData) {
|
|
330
|
+
var tabFieldParams;
|
|
331
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
332
|
+
while (1) {
|
|
333
|
+
switch (_context5.prev = _context5.next) {
|
|
334
|
+
case 0:
|
|
335
|
+
tabFieldParams = tabField.hasGroupedValues ? groupData[tabField.name] || {} : groupData;
|
|
336
|
+
_context5.next = 3;
|
|
337
|
+
return serialize(manifest, tabFieldParams, tabField.fields, {
|
|
338
|
+
parentType: 'tab'
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
case 3:
|
|
342
|
+
return _context5.abrupt("return", _context5.sent);
|
|
343
|
+
|
|
344
|
+
case 4:
|
|
345
|
+
case "end":
|
|
346
|
+
return _context5.stop();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}, _callee5);
|
|
350
|
+
}));
|
|
351
|
+
|
|
352
|
+
return function resolveTabValues(_x12, _x13, _x14) {
|
|
353
|
+
return _ref6.apply(this, arguments);
|
|
354
|
+
};
|
|
355
|
+
}();
|
|
356
|
+
|
|
357
|
+
var serializeTabGroupField = /*#__PURE__*/function () {
|
|
358
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(manifest, field, data) {
|
|
359
|
+
var tabs, results, value, i, tabField, tabFieldParameters, fieldName, _fieldName;
|
|
217
360
|
|
|
218
|
-
|
|
219
|
-
|
|
361
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
362
|
+
while (1) {
|
|
363
|
+
switch (_context6.prev = _context6.next) {
|
|
364
|
+
case 0:
|
|
365
|
+
tabs = field.fields;
|
|
366
|
+
results = [];
|
|
367
|
+
value = {};
|
|
368
|
+
i = 0;
|
|
369
|
+
|
|
370
|
+
case 4:
|
|
371
|
+
if (!(i < tabs.length)) {
|
|
372
|
+
_context6.next = 13;
|
|
220
373
|
break;
|
|
221
374
|
}
|
|
222
375
|
|
|
223
|
-
|
|
376
|
+
tabField = tabs[i];
|
|
377
|
+
_context6.next = 8;
|
|
378
|
+
return resolveTabValues(manifest, tabField, field.hasGroupedValues ? data[field.name] || {} : data);
|
|
224
379
|
|
|
225
|
-
case
|
|
226
|
-
|
|
380
|
+
case 8:
|
|
381
|
+
tabFieldParameters = _context6.sent;
|
|
382
|
+
|
|
383
|
+
if (tabField.hasGroupedValues) {
|
|
384
|
+
// Keep namespaced by tab
|
|
385
|
+
value[tabField.name] = tabFieldParameters;
|
|
386
|
+
} else {
|
|
387
|
+
// Copy into tabGroup value
|
|
388
|
+
for (fieldName in tabFieldParameters) {
|
|
389
|
+
value[fieldName] = tabFieldParameters[fieldName];
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
case 10:
|
|
394
|
+
i++;
|
|
395
|
+
_context6.next = 4;
|
|
227
396
|
break;
|
|
228
397
|
|
|
229
398
|
case 13:
|
|
230
|
-
//
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
_context3.next = 16;
|
|
238
|
-
break;
|
|
399
|
+
// Now for tabGroup...
|
|
400
|
+
if (field.hasGroupedValues) {
|
|
401
|
+
results.push(_defineProperty({}, field.name, value));
|
|
402
|
+
} else {
|
|
403
|
+
for (_fieldName in value) {
|
|
404
|
+
results.push(_defineProperty({}, _fieldName, value));
|
|
405
|
+
}
|
|
239
406
|
}
|
|
240
407
|
|
|
241
|
-
return
|
|
408
|
+
return _context6.abrupt("return", results);
|
|
242
409
|
|
|
243
|
-
case
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
410
|
+
case 15:
|
|
411
|
+
case "end":
|
|
412
|
+
return _context6.stop();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}, _callee6);
|
|
416
|
+
}));
|
|
417
|
+
|
|
418
|
+
return function serializeTabGroupField(_x15, _x16, _x17) {
|
|
419
|
+
return _ref7.apply(this, arguments);
|
|
420
|
+
};
|
|
421
|
+
}();
|
|
422
|
+
|
|
423
|
+
var serializeTabField = /*#__PURE__*/function () {
|
|
424
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(manifest, field, data) {
|
|
425
|
+
var results, tabField, tabFieldParameters, fieldName;
|
|
426
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
427
|
+
while (1) {
|
|
428
|
+
switch (_context7.prev = _context7.next) {
|
|
429
|
+
case 0:
|
|
430
|
+
results = [];
|
|
431
|
+
tabField = field;
|
|
432
|
+
_context7.next = 4;
|
|
433
|
+
return resolveTabValues(manifest, tabField, data);
|
|
434
|
+
|
|
435
|
+
case 4:
|
|
436
|
+
tabFieldParameters = _context7.sent;
|
|
437
|
+
|
|
438
|
+
if (tabField.hasGroupedValues) {
|
|
439
|
+
// Keep namespaced by tab
|
|
440
|
+
results.push(_defineProperty({}, tabField.name, tabFieldParameters));
|
|
441
|
+
} else {
|
|
442
|
+
// Copy into tabGroup value
|
|
443
|
+
for (fieldName in tabFieldParameters) {
|
|
444
|
+
results.push(_defineProperty({}, fieldName, tabFieldParameters[fieldName]));
|
|
247
445
|
}
|
|
446
|
+
}
|
|
248
447
|
|
|
249
|
-
|
|
250
|
-
}, {}));
|
|
448
|
+
return _context7.abrupt("return", results);
|
|
251
449
|
|
|
252
|
-
case
|
|
450
|
+
case 7:
|
|
253
451
|
case "end":
|
|
254
|
-
return
|
|
452
|
+
return _context7.stop();
|
|
255
453
|
}
|
|
256
454
|
}
|
|
257
|
-
},
|
|
455
|
+
}, _callee7);
|
|
258
456
|
}));
|
|
259
457
|
|
|
260
|
-
return function
|
|
261
|
-
return
|
|
458
|
+
return function serializeTabField(_x18, _x19, _x20) {
|
|
459
|
+
return _ref8.apply(this, arguments);
|
|
262
460
|
};
|
|
263
461
|
}();
|
|
264
462
|
|
|
463
|
+
var serializeMergeDuplicateFieldData = function serializeMergeDuplicateFieldData(parameters, formData, flattenedFields) {
|
|
464
|
+
// Weed out all the non-duplicate field names
|
|
465
|
+
var allDuplicateFieldNames = Object.keys(formData).filter(function (key) {
|
|
466
|
+
return isDuplicateField(key);
|
|
467
|
+
});
|
|
468
|
+
return flattenedFields.reduce(function (newParams, field) {
|
|
469
|
+
var paramValue = parameters[field.name];
|
|
470
|
+
|
|
471
|
+
if (!field.allowDuplicates && paramValue !== undefined) {
|
|
472
|
+
newParams[field.name] = paramValue;
|
|
473
|
+
} else {
|
|
474
|
+
// extract the given duplicate values through the field
|
|
475
|
+
var duplicateValues = allDuplicateFieldNames.filter(function (name) {
|
|
476
|
+
return getNameFromDuplicateField(name) === field.name;
|
|
477
|
+
}).map(function (duplicateFieldName) {
|
|
478
|
+
return extract(formData[duplicateFieldName], field, {
|
|
479
|
+
useDefaultValue: true
|
|
480
|
+
});
|
|
481
|
+
}); // Merge and ensure that all values are worth serializing
|
|
482
|
+
|
|
483
|
+
var mergedValues = [paramValue].concat(_toConsumableArray(duplicateValues)).filter(function (value) {
|
|
484
|
+
return value !== undefined;
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
if (mergedValues.length > 0) {
|
|
488
|
+
// Replace so the duplicate field values are saved under the
|
|
489
|
+
// fieldName as an array
|
|
490
|
+
newParams[field.name] = mergedValues;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
return newParams;
|
|
495
|
+
}, {});
|
|
496
|
+
};
|
|
497
|
+
|
|
265
498
|
function injectDefaultValues(data, fields) {
|
|
266
499
|
var copy = _toConsumableArray(convertToParametersArray(data));
|
|
267
500
|
|
|
@@ -269,7 +502,7 @@ function injectDefaultValues(data, fields) {
|
|
|
269
502
|
_step;
|
|
270
503
|
|
|
271
504
|
try {
|
|
272
|
-
var
|
|
505
|
+
var _loop = function _loop() {
|
|
273
506
|
var field = _step.value;
|
|
274
507
|
var name = field.name;
|
|
275
508
|
var fieldIndex = copy.findIndex(function (item) {
|
|
@@ -297,9 +530,9 @@ function injectDefaultValues(data, fields) {
|
|
|
297
530
|
};
|
|
298
531
|
|
|
299
532
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
300
|
-
var
|
|
533
|
+
var _ret = _loop();
|
|
301
534
|
|
|
302
|
-
if (
|
|
535
|
+
if (_ret === "continue") continue;
|
|
303
536
|
}
|
|
304
537
|
} catch (err) {
|
|
305
538
|
_iterator.e(err);
|
|
@@ -307,198 +540,205 @@ function injectDefaultValues(data, fields) {
|
|
|
307
540
|
_iterator.f();
|
|
308
541
|
}
|
|
309
542
|
|
|
310
|
-
if (doParametersContainDuplicateFields(copy)) {
|
|
311
|
-
return copy;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
543
|
return convertToParametersObject(copy);
|
|
315
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Flattens the given FieldDefinition[] so it resembles the expected data
|
|
547
|
+
* structure in result Parameters.
|
|
548
|
+
*/
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
var flattenFields = function flattenFields(fields) {
|
|
552
|
+
var flattenAccumulator = function flattenAccumulator(accumulator, field) {
|
|
553
|
+
if (isTabGroup(field)) {
|
|
554
|
+
if (field.hasGroupedValues) {
|
|
555
|
+
accumulator.push(field);
|
|
556
|
+
} else {
|
|
557
|
+
var flattenedTabs = field.fields.reduce(function (tabAccumulator, tab) {
|
|
558
|
+
return tabAccumulator.concat(tab.hasGroupedValues ? tab : tab.fields.reduce(flattenAccumulator, []));
|
|
559
|
+
}, []);
|
|
560
|
+
accumulator.push.apply(accumulator, _toConsumableArray(flattenedTabs));
|
|
561
|
+
}
|
|
562
|
+
} else if (isExpand(field)) {
|
|
563
|
+
if (field.hasGroupedValues) {
|
|
564
|
+
accumulator.push(field);
|
|
565
|
+
} else {
|
|
566
|
+
var flattenedExpand = field.fields.reduce(flattenAccumulator, []);
|
|
567
|
+
accumulator.push.apply(accumulator, _toConsumableArray(flattenedExpand));
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
accumulator.push(field);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
return accumulator;
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
return fields.reduce(flattenAccumulator, []);
|
|
577
|
+
};
|
|
316
578
|
|
|
317
579
|
export var deserialize = /*#__PURE__*/function () {
|
|
318
|
-
var
|
|
580
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(manifest, data, fields) {
|
|
319
581
|
var depth,
|
|
320
582
|
dataArray,
|
|
321
583
|
result,
|
|
322
584
|
errors,
|
|
585
|
+
flattenedFields,
|
|
323
586
|
_iterator2,
|
|
324
587
|
_step2,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
588
|
+
_loop2,
|
|
589
|
+
_ret2,
|
|
590
|
+
_args9 = arguments;
|
|
328
591
|
|
|
329
|
-
return _regeneratorRuntime.wrap(function
|
|
592
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context9) {
|
|
330
593
|
while (1) {
|
|
331
|
-
switch (
|
|
594
|
+
switch (_context9.prev = _context9.next) {
|
|
332
595
|
case 0:
|
|
333
|
-
depth =
|
|
596
|
+
depth = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : 0;
|
|
334
597
|
dataArray = convertToParametersArray(data);
|
|
335
598
|
result = [];
|
|
336
599
|
errors = [];
|
|
600
|
+
flattenedFields = flattenFields(fields);
|
|
337
601
|
_iterator2 = _createForOfIteratorHelper(dataArray);
|
|
338
|
-
|
|
339
|
-
|
|
602
|
+
_context9.prev = 6;
|
|
603
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime.mark(function _loop2() {
|
|
340
604
|
var item, _Object$entries$, name, originalValue, field, value, fieldDeserializer;
|
|
341
605
|
|
|
342
|
-
return _regeneratorRuntime.wrap(function
|
|
606
|
+
return _regeneratorRuntime.wrap(function _loop2$(_context8) {
|
|
343
607
|
while (1) {
|
|
344
|
-
switch (
|
|
608
|
+
switch (_context8.prev = _context8.next) {
|
|
345
609
|
case 0:
|
|
346
610
|
item = _step2.value;
|
|
347
611
|
_Object$entries$ = _slicedToArray(Object.entries(item)[0], 2), name = _Object$entries$[0], originalValue = _Object$entries$[1];
|
|
348
|
-
field =
|
|
612
|
+
field = flattenedFields.find(function (field) {
|
|
349
613
|
return field.name === getNameFromDuplicateField(name);
|
|
350
614
|
});
|
|
351
615
|
|
|
352
616
|
if (!(field === undefined)) {
|
|
353
|
-
|
|
617
|
+
_context8.next = 5;
|
|
354
618
|
break;
|
|
355
619
|
}
|
|
356
620
|
|
|
357
|
-
return
|
|
621
|
+
return _context8.abrupt("return", "continue");
|
|
358
622
|
|
|
359
623
|
case 5:
|
|
360
624
|
value = extract(originalValue, field);
|
|
361
625
|
|
|
362
626
|
if (!(value === undefined)) {
|
|
363
|
-
|
|
627
|
+
_context8.next = 8;
|
|
364
628
|
break;
|
|
365
629
|
}
|
|
366
630
|
|
|
367
|
-
return
|
|
631
|
+
return _context8.abrupt("return", "continue");
|
|
368
632
|
|
|
369
633
|
case 8:
|
|
370
634
|
if (!(isFieldset(field) && depth === 0)) {
|
|
371
|
-
|
|
635
|
+
_context8.next = 24;
|
|
372
636
|
break;
|
|
373
637
|
}
|
|
374
638
|
|
|
375
|
-
|
|
639
|
+
_context8.next = 11;
|
|
376
640
|
return getFieldDeserializer(manifest, field.options.transformer);
|
|
377
641
|
|
|
378
642
|
case 11:
|
|
379
|
-
fieldDeserializer =
|
|
643
|
+
fieldDeserializer = _context8.sent;
|
|
380
644
|
|
|
381
645
|
if (!fieldDeserializer) {
|
|
382
|
-
|
|
646
|
+
_context8.next = 24;
|
|
383
647
|
break;
|
|
384
648
|
}
|
|
385
649
|
|
|
386
|
-
|
|
650
|
+
_context8.prev = 13;
|
|
387
651
|
value = fieldDeserializer(value);
|
|
388
|
-
|
|
652
|
+
_context8.next = 21;
|
|
389
653
|
break;
|
|
390
654
|
|
|
391
655
|
case 17:
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
errors.push(_defineProperty({}, name,
|
|
395
|
-
return
|
|
656
|
+
_context8.prev = 17;
|
|
657
|
+
_context8.t0 = _context8["catch"](13);
|
|
658
|
+
errors.push(_defineProperty({}, name, _context8.t0.message));
|
|
659
|
+
return _context8.abrupt("return", "continue");
|
|
396
660
|
|
|
397
661
|
case 21:
|
|
398
|
-
|
|
662
|
+
_context8.next = 23;
|
|
399
663
|
return deserialize(manifest, value, field.fields, depth + 1);
|
|
400
664
|
|
|
401
665
|
case 23:
|
|
402
|
-
value =
|
|
666
|
+
value = _context8.sent;
|
|
403
667
|
|
|
404
668
|
case 24:
|
|
405
669
|
result.push(_defineProperty({}, name, value));
|
|
406
670
|
|
|
407
671
|
case 25:
|
|
408
672
|
case "end":
|
|
409
|
-
return
|
|
673
|
+
return _context8.stop();
|
|
410
674
|
}
|
|
411
675
|
}
|
|
412
|
-
},
|
|
676
|
+
}, _loop2, null, [[13, 17]]);
|
|
413
677
|
});
|
|
414
678
|
|
|
415
679
|
_iterator2.s();
|
|
416
680
|
|
|
417
|
-
case
|
|
681
|
+
case 9:
|
|
418
682
|
if ((_step2 = _iterator2.n()).done) {
|
|
419
|
-
|
|
683
|
+
_context9.next = 16;
|
|
420
684
|
break;
|
|
421
685
|
}
|
|
422
686
|
|
|
423
|
-
return
|
|
687
|
+
return _context9.delegateYield(_loop2(), "t0", 11);
|
|
424
688
|
|
|
425
|
-
case
|
|
426
|
-
|
|
689
|
+
case 11:
|
|
690
|
+
_ret2 = _context9.t0;
|
|
427
691
|
|
|
428
|
-
if (!(
|
|
429
|
-
|
|
692
|
+
if (!(_ret2 === "continue")) {
|
|
693
|
+
_context9.next = 14;
|
|
430
694
|
break;
|
|
431
695
|
}
|
|
432
696
|
|
|
433
|
-
return
|
|
697
|
+
return _context9.abrupt("continue", 14);
|
|
434
698
|
|
|
435
|
-
case
|
|
436
|
-
|
|
699
|
+
case 14:
|
|
700
|
+
_context9.next = 9;
|
|
437
701
|
break;
|
|
438
702
|
|
|
439
|
-
case
|
|
440
|
-
|
|
703
|
+
case 16:
|
|
704
|
+
_context9.next = 21;
|
|
441
705
|
break;
|
|
442
706
|
|
|
443
|
-
case
|
|
444
|
-
|
|
445
|
-
|
|
707
|
+
case 18:
|
|
708
|
+
_context9.prev = 18;
|
|
709
|
+
_context9.t1 = _context9["catch"](6);
|
|
446
710
|
|
|
447
|
-
_iterator2.e(
|
|
711
|
+
_iterator2.e(_context9.t1);
|
|
448
712
|
|
|
449
|
-
case
|
|
450
|
-
|
|
713
|
+
case 21:
|
|
714
|
+
_context9.prev = 21;
|
|
451
715
|
|
|
452
716
|
_iterator2.f();
|
|
453
717
|
|
|
454
|
-
return
|
|
718
|
+
return _context9.finish(21);
|
|
455
719
|
|
|
456
|
-
case
|
|
720
|
+
case 24:
|
|
457
721
|
result = convertToParametersObject(result);
|
|
458
722
|
|
|
459
723
|
if (errors.length > 0) {
|
|
460
724
|
result.errors = convertToParametersObject(errors);
|
|
461
725
|
}
|
|
462
726
|
|
|
463
|
-
return
|
|
727
|
+
return _context9.abrupt("return", injectDefaultValues(result, flattenedFields));
|
|
464
728
|
|
|
465
|
-
case
|
|
729
|
+
case 27:
|
|
466
730
|
case "end":
|
|
467
|
-
return
|
|
731
|
+
return _context9.stop();
|
|
468
732
|
}
|
|
469
733
|
}
|
|
470
|
-
},
|
|
734
|
+
}, _callee8, null, [[6, 18, 21, 24]]);
|
|
471
735
|
}));
|
|
472
736
|
|
|
473
|
-
return function deserialize(
|
|
474
|
-
return
|
|
737
|
+
return function deserialize(_x21, _x22, _x23) {
|
|
738
|
+
return _ref9.apply(this, arguments);
|
|
475
739
|
};
|
|
476
740
|
}();
|
|
477
741
|
|
|
478
|
-
var doParametersContainDuplicateFields = function doParametersContainDuplicateFields(parameters) {
|
|
479
|
-
var keyMap = new Set();
|
|
480
|
-
|
|
481
|
-
var _iterator3 = _createForOfIteratorHelper(parameters),
|
|
482
|
-
_step3;
|
|
483
|
-
|
|
484
|
-
try {
|
|
485
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
486
|
-
var param = _step3.value;
|
|
487
|
-
var key = Object.keys(param)[0];
|
|
488
|
-
|
|
489
|
-
if (keyMap.has(key)) {
|
|
490
|
-
return true;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
keyMap.add(key);
|
|
494
|
-
}
|
|
495
|
-
} catch (err) {
|
|
496
|
-
_iterator3.e(err);
|
|
497
|
-
} finally {
|
|
498
|
-
_iterator3.f();
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
|
|
502
742
|
var convertToParametersObject = function convertToParametersObject() {
|
|
503
743
|
var parameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
504
744
|
|
|
@@ -507,17 +747,17 @@ var convertToParametersObject = function convertToParametersObject() {
|
|
|
507
747
|
}
|
|
508
748
|
|
|
509
749
|
return parameters.reduce(function (obj, current) {
|
|
510
|
-
for (var
|
|
750
|
+
for (var _key2 in current) {
|
|
511
751
|
var keys = Object.keys(obj);
|
|
512
|
-
var resultKey =
|
|
752
|
+
var resultKey = _key2;
|
|
513
753
|
var idx = 1;
|
|
514
754
|
|
|
515
755
|
while (keys.indexOf(resultKey) >= 0) {
|
|
516
|
-
resultKey = "".concat(getNameFromDuplicateField(
|
|
756
|
+
resultKey = "".concat(getNameFromDuplicateField(_key2), ":").concat(idx);
|
|
517
757
|
idx++;
|
|
518
758
|
}
|
|
519
759
|
|
|
520
|
-
obj[resultKey] = current[
|
|
760
|
+
obj[resultKey] = current[_key2];
|
|
521
761
|
}
|
|
522
762
|
|
|
523
763
|
return obj;
|