@zohodesk/library-platform 1.1.6 → 1.1.7-exp.1
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/es/bc/sdk/ResourceNamesEnum.js +1 -0
- package/es/bc/zform/Properties.js +3 -26
- package/es/bc/zform/Symbol.js +2 -0
- package/es/cc/breadcrumb/Constants.js +7 -0
- package/es/cc/breadcrumb/Events.js +14 -0
- package/es/cc/breadcrumb/Properties.js +35 -0
- package/es/cc/breadcrumb/index.js +3 -0
- package/es/cc/fields/field/FormDefaultUIType.js +37 -0
- package/es/cc/fields/index.js +2 -1
- package/es/cc/form/Properties.js +54 -0
- package/es/cc/form-connected/Constants.js +8 -0
- package/es/cc/form-connected/Properties.js +95 -1
- package/es/cc/form-connected/SdkContract.js +159 -0
- package/es/cc/icon-button/Constants.js +7 -0
- package/es/cc/icon-button/Events.js +5 -0
- package/es/cc/icon-button/Properties.js +86 -0
- package/es/cc/icon-button/index.js +3 -0
- package/es/cc/index.js +1 -0
- package/es/cc/section/Properties.js +25 -0
- package/es/index.js +6 -1
- package/es/library/custom-component/adapters/gateways/event-manager/EventManager.js +2 -2
- package/es/library/dot/components/action-location/frameworks/ui/ActionComponentMapping.js +5 -1
- package/es/library/dot/components/form/adapters/presenter/TransformState.js +70 -3
- package/es/library/dot/components/form/frameworks/ui/DefaultComponentRegister.js +28 -0
- package/es/library/dot/components/form/frameworks/ui/Form.js +2 -0
- package/es/library/dot/components/form/frameworks/ui/FormView.js +47 -26
- package/es/library/dot/components/form/frameworks/ui/css/Form.module.css +8 -4
- package/es/library/dot/components/form/frameworks/ui/sub-components/Sections.js +9 -9
- package/es/library/dot/components/section/frameworks/ui/RenderField.js +19 -0
- package/es/library/dot/components/section/frameworks/ui/Section.js +13 -4
- package/es/library/dot/components/section/frameworks/ui/SectionView.js +7 -28
- package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +72 -40
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +7 -13
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +2 -2
- package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/Breadcrumb.js +12 -0
- package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/BreadcrumbView.js +47 -0
- package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/css/Breadcrumb.module.css +19 -0
- package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/sub-components/BreadcrumbItem.js +58 -0
- package/es/library/dot/legacy-to-new-arch/icon-button/frameworks/ui/IconButton.js +12 -0
- package/es/library/dot/legacy-to-new-arch/icon-button/frameworks/ui/IconButtonView.js +43 -0
- package/es/platform/client-actions/cc/action-event-mediator/Properties.js +9 -0
- package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ActionEventMediatorView.js +3 -1
- package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActionsRenderer.module.css +4 -0
- package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActionsRendererView.js +5 -2
- package/es/platform/components/form-connected/adapters/resources/SmartFormResources.js +210 -0
- package/es/platform/components/form-connected/application/interfaces/ISmartFormResources.js +1 -0
- package/es/platform/components/form-connected/frameworks/EventHandlersFactory.js +16 -8
- package/es/platform/components/form-connected/frameworks/FormConnectedFactory.js +27 -3
- package/es/platform/components/form-connected/frameworks/FormConnectedView.js +14 -2
- package/es/platform/components/form-connected/frameworks/FormSdkFactory.js +33 -13
- package/es/platform/components/table-connected/adapters/resources/SmartTableResource.js +0 -52
- package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +4 -1
- package/es/platform/page/index.js +46 -0
- package/es/platform/sdk/adapters/gateways/Service.js +4 -0
- package/es/platform/sdk/application/interfaces/gateways/AbstractResource.js +52 -1
- package/es/platform/sdk/application/usecases/GetResourcesUseCase.js +15 -0
- package/es/platform/sdk/domain/entities/ResourceManager.js +4 -0
- package/es/platform/sdk/frameworks/Sdk.js +7 -0
- package/es/platform/sdk/frameworks/SdkRegistry.js +9 -0
- package/es/platform/zform/adapters/presenter/FormTranslator.js +90 -46
- package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +45 -26
- package/es/platform/zform/adapters/presenter/translators/interfaces/ComponentMapping.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/interfaces/FieldContract.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/interfaces/FormTranslatorState.js +1 -0
- package/es/platform/zform/adapters/presenter/translators/interfaces/SectionContract.js +1 -0
- package/es/platform/zform/adapters/presenter/utils/DefaultClientActions.js +59 -0
- package/es/platform/zform/applications/interfaces/input/DeleteFieldUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/GetFieldValueUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/HideFieldUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/HideSectionUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/InsertFieldUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/SetFieldValueUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/SetFieldsValuesUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/ShowFieldUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/ShowSectionUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/SubmitUseCaseInput.js +1 -0
- package/es/platform/zform/applications/interfaces/input/UpdateFieldUseCaseInput.js +1 -0
- package/es/platform/zform/applications/usecases/DeleteFieldUseCase.js +22 -0
- package/es/platform/zform/applications/usecases/GetFieldValueUseCase.js +23 -0
- package/es/platform/zform/applications/usecases/HideFieldUseCase.js +19 -0
- package/es/platform/zform/applications/usecases/HideSectionUseCase.js +19 -0
- package/es/platform/zform/applications/usecases/InitializeUseCase.js +16 -0
- package/es/platform/zform/applications/usecases/InsertFieldUseCase.js +28 -0
- package/es/platform/zform/applications/usecases/SetFieldValueUseCase.js +44 -0
- package/es/platform/zform/applications/usecases/SetFieldsValuesUseCase.js +51 -0
- package/es/platform/zform/applications/usecases/ShowFieldUseCase.js +19 -0
- package/es/platform/zform/applications/usecases/ShowSectionUseCase.js +19 -0
- package/es/platform/zform/applications/usecases/SubmitUseCase.js +29 -0
- package/es/platform/zform/applications/usecases/UpdateFieldUseCase.js +22 -0
- package/es/platform/zform/domain/ZField.js +14 -0
- package/es/platform/zform/domain/ZForm.js +85 -3
- package/es/platform/zform/domain/ZSection.js +6 -0
- package/es/platform/zform/frameworks/ui/EventHandlerFactory.js +37 -15
- package/es/platform/zrecord/adapters/controllers/CreateRecordController.js +5 -1
- package/es/platform/zrecord/applications/usecases/CreateRecordUseCase.js +5 -3
- package/package.json +7 -6
- package/es/library/dot/components/section/adapters/presenter/TransFormState.js +0 -26
|
@@ -49,7 +49,7 @@ function RowView(_ref, ref) {
|
|
|
49
49
|
key: id,
|
|
50
50
|
ref: ref,
|
|
51
51
|
testId: id,
|
|
52
|
-
$flag_padding:
|
|
52
|
+
$flag_padding: false,
|
|
53
53
|
$flag_active: isSelected,
|
|
54
54
|
$flag_hasHighlighter: isKeyboardControlsEnabled,
|
|
55
55
|
$flag_isHighlighted: isFocussed,
|
|
@@ -60,7 +60,7 @@ function RowView(_ref, ref) {
|
|
|
60
60
|
}
|
|
61
61
|
}),
|
|
62
62
|
customStyle: {
|
|
63
|
-
tableList:
|
|
63
|
+
tableList: style.row,
|
|
64
64
|
$pointer: style[`rowCursor_${cursor}`]
|
|
65
65
|
}
|
|
66
66
|
}, renderReorderer({
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createCustomComponent } from "../../../../../custom-component";
|
|
2
|
+
import BreadcrumbProperties from "../../../../../../cc/breadcrumb/Properties";
|
|
3
|
+
import BreadcrumbEvents from "../../../../../../cc/breadcrumb/Events";
|
|
4
|
+
import BreadcrumbView from "./BreadcrumbView";
|
|
5
|
+
let Breadcrumb = createCustomComponent({
|
|
6
|
+
name: "Breadcrumb",
|
|
7
|
+
View: BreadcrumbView,
|
|
8
|
+
properties: BreadcrumbProperties,
|
|
9
|
+
events: BreadcrumbEvents,
|
|
10
|
+
eventHandlers: {}
|
|
11
|
+
});
|
|
12
|
+
export default Breadcrumb;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Separator from "@zohodesk/dot/es/Separator/Separator";
|
|
3
|
+
import BreadcrumbItem from "./sub-components/BreadcrumbItem"; // @ts-ignore
|
|
4
|
+
|
|
5
|
+
import style from "./css/Breadcrumb.module.css";
|
|
6
|
+
|
|
7
|
+
function BreadcrumbView(_ref, ref) {
|
|
8
|
+
let {
|
|
9
|
+
state,
|
|
10
|
+
helpers
|
|
11
|
+
} = _ref;
|
|
12
|
+
const {
|
|
13
|
+
dispatch
|
|
14
|
+
} = helpers;
|
|
15
|
+
const {
|
|
16
|
+
items
|
|
17
|
+
} = state.properties;
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
ref: ref,
|
|
20
|
+
className: style.wrapper
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Separator, {
|
|
22
|
+
type: "slash",
|
|
23
|
+
shrink: true,
|
|
24
|
+
customClass: {
|
|
25
|
+
customSeparator: style.separator
|
|
26
|
+
}
|
|
27
|
+
}, items.map(_ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
id,
|
|
30
|
+
text,
|
|
31
|
+
isLink,
|
|
32
|
+
iconName,
|
|
33
|
+
isActive
|
|
34
|
+
} = _ref2;
|
|
35
|
+
return /*#__PURE__*/React.createElement(BreadcrumbItem, {
|
|
36
|
+
key: id,
|
|
37
|
+
id: id,
|
|
38
|
+
text: text,
|
|
39
|
+
isLink: isLink,
|
|
40
|
+
iconName: iconName,
|
|
41
|
+
isActive: isActive,
|
|
42
|
+
dispatch: dispatch
|
|
43
|
+
});
|
|
44
|
+
})));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default BreadcrumbView;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.wrapper, .itemContainer {
|
|
2
|
+
max-width: 100%
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.itemContainer {
|
|
6
|
+
column-gap: var(--zd_size4) ;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.separator {
|
|
10
|
+
--separator_fontSize: 14px;
|
|
11
|
+
margin: 0 var(--zd_size10) ;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.buttonStyle {
|
|
15
|
+
--button_font_size: 14px;
|
|
16
|
+
--button_padding: 0px;
|
|
17
|
+
--button_letter_spacing: 0px;
|
|
18
|
+
max-width: 100% ;
|
|
19
|
+
}
|
package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/sub-components/BreadcrumbItem.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Icon from "@zohodesk/icons/es/Icon";
|
|
3
|
+
import Flex from "@zohodesk/layout/es/Flex/Flex";
|
|
4
|
+
import Typography from "@zohodesk/components/es/Typography/Typography";
|
|
5
|
+
import Button from "@zohodesk/components/es/Button/Button";
|
|
6
|
+
import BreadcrumbConstants from "../../../../../../../cc/breadcrumb/Constants"; // @ts-ignore
|
|
7
|
+
|
|
8
|
+
import style from "./../css/Breadcrumb.module.css";
|
|
9
|
+
|
|
10
|
+
function BreadcrumbItem(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
id,
|
|
13
|
+
text,
|
|
14
|
+
isLink,
|
|
15
|
+
iconName,
|
|
16
|
+
iconSize = '14',
|
|
17
|
+
isActive,
|
|
18
|
+
dispatch
|
|
19
|
+
} = _ref;
|
|
20
|
+
|
|
21
|
+
const renderTitle = (text, isLink, isActive) => {
|
|
22
|
+
return isLink ? /*#__PURE__*/React.createElement(Button, {
|
|
23
|
+
text: text,
|
|
24
|
+
title: text,
|
|
25
|
+
palette: 'plainPrimary',
|
|
26
|
+
isBold: false,
|
|
27
|
+
customClass: {
|
|
28
|
+
customButton: style.buttonStyle
|
|
29
|
+
}
|
|
30
|
+
}) : /*#__PURE__*/React.createElement(Typography, {
|
|
31
|
+
$ui_size: isActive ? '16' : '14',
|
|
32
|
+
$ui_weight: isActive ? 'semibold' : 'regular',
|
|
33
|
+
$flag_dotted: true,
|
|
34
|
+
$i18n_dataTitle: text,
|
|
35
|
+
$ui_tagName: 'span'
|
|
36
|
+
}, text);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const renderIcon = (iconName, iconSize) => /*#__PURE__*/React.createElement(Icon, {
|
|
40
|
+
name: iconName,
|
|
41
|
+
size: iconSize
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
45
|
+
key: id,
|
|
46
|
+
$ui_displayMode: "inline",
|
|
47
|
+
$ui_alignItems: "center",
|
|
48
|
+
$ui_className: style.itemContainer,
|
|
49
|
+
$event_onClick: () => dispatch({
|
|
50
|
+
type: BreadcrumbConstants.BREADCRUMB_ITEM_CLICKED,
|
|
51
|
+
payload: {
|
|
52
|
+
id
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
}, !isLink && iconName && renderIcon(iconName, iconSize), renderTitle(text, isLink, isActive));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default BreadcrumbItem;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createCustomComponent } from "../../../../../custom-component";
|
|
2
|
+
import IconButtonProperties from "../../../../../../cc/icon-button/Properties";
|
|
3
|
+
import IconButtonEvents from "../../../../../../cc/icon-button/Events";
|
|
4
|
+
import IconButtonView from "./IconButtonView";
|
|
5
|
+
let IconButton = createCustomComponent({
|
|
6
|
+
name: "IconButton",
|
|
7
|
+
View: IconButtonView,
|
|
8
|
+
properties: IconButtonProperties,
|
|
9
|
+
events: IconButtonEvents,
|
|
10
|
+
eventHandlers: {}
|
|
11
|
+
});
|
|
12
|
+
export default IconButton;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import IconButton from '@zohodesk/dot/es/IconButton/IconButton';
|
|
3
|
+
import IconButtonConstants from "../../../../../../cc/icon-button/Constants";
|
|
4
|
+
|
|
5
|
+
function IconButtonView(_ref, ref) {
|
|
6
|
+
let {
|
|
7
|
+
state,
|
|
8
|
+
helpers
|
|
9
|
+
} = _ref;
|
|
10
|
+
const {
|
|
11
|
+
dispatch
|
|
12
|
+
} = helpers;
|
|
13
|
+
const {
|
|
14
|
+
palette,
|
|
15
|
+
iconSize,
|
|
16
|
+
size,
|
|
17
|
+
iconName,
|
|
18
|
+
isActive,
|
|
19
|
+
isDisabled,
|
|
20
|
+
hoverType,
|
|
21
|
+
title,
|
|
22
|
+
isBold
|
|
23
|
+
} = state.properties;
|
|
24
|
+
return /*#__PURE__*/React.createElement(IconButton, {
|
|
25
|
+
eleRef: ref,
|
|
26
|
+
palette: palette,
|
|
27
|
+
iconSize: iconSize,
|
|
28
|
+
size: size,
|
|
29
|
+
iconName: iconName,
|
|
30
|
+
isActive: isActive,
|
|
31
|
+
isDisabled: isDisabled,
|
|
32
|
+
hoverType: hoverType,
|
|
33
|
+
title: title,
|
|
34
|
+
isBold: isBold,
|
|
35
|
+
onClick: () => {
|
|
36
|
+
dispatch({
|
|
37
|
+
type: IconButtonConstants.ICON_BUTTON_CLICKED
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default IconButtonView;
|
|
@@ -8,10 +8,12 @@ export default function ActionEventMediatorView(_ref, ref) {
|
|
|
8
8
|
const {
|
|
9
9
|
actions,
|
|
10
10
|
renderComponentType,
|
|
11
|
-
gap
|
|
11
|
+
gap,
|
|
12
|
+
testId
|
|
12
13
|
} = state.properties;
|
|
13
14
|
const ActionRenderComponent = ComponentRegistry.get(renderComponentType) || RowActionsRenderer;
|
|
14
15
|
return /*#__PURE__*/React.createElement(ActionRenderComponent, {
|
|
16
|
+
testId: testId,
|
|
15
17
|
actions: actions,
|
|
16
18
|
gap: gap,
|
|
17
19
|
getRef: ref
|
|
@@ -11,13 +11,16 @@ function RowActionsRendererView(_ref, ref) {
|
|
|
11
11
|
} = _ref;
|
|
12
12
|
const {
|
|
13
13
|
actions,
|
|
14
|
-
gap
|
|
14
|
+
gap,
|
|
15
|
+
testId
|
|
15
16
|
} = state.properties;
|
|
16
17
|
return /*#__PURE__*/React.createElement(Flex, {
|
|
17
18
|
ref: ref,
|
|
19
|
+
testId: testId,
|
|
20
|
+
customId: testId,
|
|
18
21
|
$ui_displayMode: "inline",
|
|
19
22
|
$ui_alignItems: "center",
|
|
20
|
-
$ui_className: `${gap !== ActionViewGap.NONE ? style[`gap_${gap}`] : ''}`
|
|
23
|
+
$ui_className: `${style.wrapper} ${gap !== ActionViewGap.NONE ? style[`gap_${gap}`] : ''}`
|
|
21
24
|
}, actions.map((action, index) => {
|
|
22
25
|
return /*#__PURE__*/React.createElement(DynamicActionComponent, {
|
|
23
26
|
action: action,
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import ZFormRepository from "../../../../zform/adapters/gateway/FormRepository";
|
|
2
|
+
import ZFormPresenter from "../../../../zform/adapters/presenter/FormPresenter";
|
|
3
|
+
import ZFormValidator from "../../../../zform/frameworks/validation-rules/Validator";
|
|
4
|
+
import ZFormLayoutRuleApplier from "../../../../zform/frameworks/layout-rules/LayoutRuleApplier";
|
|
5
|
+
import HideSectionUseCase from "../../../../zform/applications/usecases/HideSectionUseCase";
|
|
6
|
+
import ShowSectionUseCase from "../../../../zform/applications/usecases/ShowSectionUseCase";
|
|
7
|
+
import ShowFieldUseCase from "../../../../zform/applications/usecases/ShowFieldUseCase";
|
|
8
|
+
import HideFieldUseCase from "../../../../zform/applications/usecases/HideFieldUseCase";
|
|
9
|
+
import SetFieldValueUseCase from "../../../../zform/applications/usecases/SetFieldValueUseCase";
|
|
10
|
+
import SetFieldsValuesUseCase from "../../../../zform/applications/usecases/SetFieldsValuesUseCase";
|
|
11
|
+
import InsertFieldUseCase from "../../../../zform/applications/usecases/InsertFieldUseCase";
|
|
12
|
+
import DeleteFieldUseCase from "../../../../zform/applications/usecases/DeleteFieldUseCase";
|
|
13
|
+
import UpdateFieldUseCase from "../../../../zform/applications/usecases/UpdateFieldUseCase";
|
|
14
|
+
import GetFieldValueUseCase from "../../../../zform/applications/usecases/GetFieldValueUseCase";
|
|
15
|
+
import SubmitUseCase from "../../../../zform/applications/usecases/SubmitUseCase";
|
|
16
|
+
import { AbstractResource } from "../../../../sdk/application/interfaces/gateways/AbstractResource";
|
|
17
|
+
import { SdkContracts } from "../../../../../cc/form-connected/SdkContract"; // hack
|
|
18
|
+
|
|
19
|
+
import { validations as defaultFieldValidations } from "../../../../../library/behaviours/field-validation/frameworks/utils/FormBasicValidationAdaptor";
|
|
20
|
+
export class SmartFormResources extends AbstractResource {
|
|
21
|
+
initialize() {}
|
|
22
|
+
|
|
23
|
+
destroy() {}
|
|
24
|
+
|
|
25
|
+
createUseCase(dependencies, UseCaseClass) {
|
|
26
|
+
var _usecase$updateDepend, _usecase$updateDepend2;
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
state,
|
|
30
|
+
updateState
|
|
31
|
+
} = this.dependencies;
|
|
32
|
+
const usecase = new UseCaseClass(dependencies);
|
|
33
|
+
(_usecase$updateDepend = usecase.updateDependencies) === null || _usecase$updateDepend === void 0 ? void 0 : _usecase$updateDepend.call(usecase, state, updateState);
|
|
34
|
+
(_usecase$updateDepend2 = usecase.updateDependency) === null || _usecase$updateDepend2 === void 0 ? void 0 : _usecase$updateDepend2.call(usecase, state, updateState);
|
|
35
|
+
return usecase;
|
|
36
|
+
} // private getFormDependencies(): ZFormUseCaseDependencies {
|
|
37
|
+
// const dependencies: ZFormUseCaseDependencies = {
|
|
38
|
+
// repository: new ZFormRepository(),
|
|
39
|
+
// presenter: new ZFormPresenter(),
|
|
40
|
+
// validator: new ZFormValidator(),
|
|
41
|
+
// layoutRuleApplier: new ZFormLayoutRuleApplier()
|
|
42
|
+
// };
|
|
43
|
+
// return dependencies;
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
getFormDependencies() {
|
|
48
|
+
const dependencies = {
|
|
49
|
+
repository: new ZFormRepository(),
|
|
50
|
+
presenter: new ZFormPresenter(),
|
|
51
|
+
validator: new ZFormValidator(defaultFieldValidations),
|
|
52
|
+
// Hack Need to pass customValidators
|
|
53
|
+
layoutRuleApplier: new ZFormLayoutRuleApplier()
|
|
54
|
+
};
|
|
55
|
+
return dependencies;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
hideSection(sectionName) {
|
|
59
|
+
this.validateInput('hideSection', {
|
|
60
|
+
sectionName
|
|
61
|
+
}, SdkContracts.hideSectionInputMeta);
|
|
62
|
+
const dependencies = this.getFormDependencies();
|
|
63
|
+
const usecase = this.createUseCase(dependencies, HideSectionUseCase);
|
|
64
|
+
usecase.execute({
|
|
65
|
+
sectionName
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
showSection(sectionName) {
|
|
70
|
+
this.validateInput('showSection', {
|
|
71
|
+
sectionName
|
|
72
|
+
}, SdkContracts.showSectionInputMeta);
|
|
73
|
+
const dependencies = this.getFormDependencies();
|
|
74
|
+
const usecase = this.createUseCase(dependencies, ShowSectionUseCase);
|
|
75
|
+
usecase.execute({
|
|
76
|
+
sectionName
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
hideField(fieldName) {
|
|
81
|
+
this.validateInput('hideField', {
|
|
82
|
+
fieldName
|
|
83
|
+
}, SdkContracts.hideFieldInputMeta);
|
|
84
|
+
const dependencies = this.getFormDependencies();
|
|
85
|
+
const usecase = this.createUseCase(dependencies, HideFieldUseCase);
|
|
86
|
+
usecase.execute({
|
|
87
|
+
fieldName
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
showField(fieldName) {
|
|
92
|
+
this.validateInput('showField', {
|
|
93
|
+
fieldName
|
|
94
|
+
}, SdkContracts.showFieldInputMeta);
|
|
95
|
+
const dependencies = this.getFormDependencies();
|
|
96
|
+
const usecase = this.createUseCase(dependencies, ShowFieldUseCase);
|
|
97
|
+
usecase.execute({
|
|
98
|
+
fieldName
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
setFieldValue(fieldName, newValue) {
|
|
103
|
+
this.validateInput('setFieldValue', {
|
|
104
|
+
fieldName,
|
|
105
|
+
newValue
|
|
106
|
+
}, SdkContracts.setFieldValueInputMeta);
|
|
107
|
+
const {
|
|
108
|
+
dispatch
|
|
109
|
+
} = this.dependencies;
|
|
110
|
+
const dependencies = this.getFormDependencies();
|
|
111
|
+
const usecase = this.createUseCase(dependencies, SetFieldValueUseCase);
|
|
112
|
+
usecase.execute({
|
|
113
|
+
fieldName,
|
|
114
|
+
newValue,
|
|
115
|
+
dispatch
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
setFieldsValue(fieldsValuesObj) {
|
|
120
|
+
this.validateInput('setFieldsValue', {
|
|
121
|
+
fieldsValuesObj
|
|
122
|
+
}, SdkContracts.setFieldsValueInputMeta);
|
|
123
|
+
const {
|
|
124
|
+
dispatch
|
|
125
|
+
} = this.dependencies;
|
|
126
|
+
const dependencies = this.getFormDependencies();
|
|
127
|
+
const usecase = this.createUseCase(dependencies, SetFieldsValuesUseCase);
|
|
128
|
+
usecase.execute({
|
|
129
|
+
fieldsValuesObj,
|
|
130
|
+
dispatch
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
insertField(input) {
|
|
135
|
+
this.validateInput('insertField', input, SdkContracts.insertFieldInputMeta);
|
|
136
|
+
const {
|
|
137
|
+
dispatch
|
|
138
|
+
} = this.dependencies;
|
|
139
|
+
const dependencies = this.getFormDependencies();
|
|
140
|
+
const usecase = this.createUseCase(dependencies, InsertFieldUseCase);
|
|
141
|
+
usecase.execute({ ...input,
|
|
142
|
+
dispatch
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
deleteField(fieldName) {
|
|
147
|
+
this.validateInput('deleteField', {
|
|
148
|
+
fieldName
|
|
149
|
+
}, SdkContracts.deleteFieldInputMeta);
|
|
150
|
+
const {
|
|
151
|
+
dispatch
|
|
152
|
+
} = this.dependencies;
|
|
153
|
+
const dependencies = this.getFormDependencies();
|
|
154
|
+
const usecase = this.createUseCase(dependencies, DeleteFieldUseCase);
|
|
155
|
+
usecase.execute({
|
|
156
|
+
fieldName,
|
|
157
|
+
dispatch
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
updateField(fieldName, fieldProperties) {
|
|
162
|
+
this.validateInput('updateField', {
|
|
163
|
+
fieldName,
|
|
164
|
+
fieldProperties
|
|
165
|
+
}, SdkContracts.updateFieldInputMeta);
|
|
166
|
+
const {
|
|
167
|
+
dispatch
|
|
168
|
+
} = this.dependencies;
|
|
169
|
+
const dependencies = this.getFormDependencies();
|
|
170
|
+
const usecase = this.createUseCase(dependencies, UpdateFieldUseCase);
|
|
171
|
+
usecase.execute({
|
|
172
|
+
fieldName,
|
|
173
|
+
fieldProperties,
|
|
174
|
+
dispatch
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
getFieldValue(fieldName) {
|
|
179
|
+
const {
|
|
180
|
+
getData,
|
|
181
|
+
setData
|
|
182
|
+
} = this.createCallback();
|
|
183
|
+
this.validateInput('getFieldValue', {
|
|
184
|
+
fieldName
|
|
185
|
+
}, SdkContracts.getFieldValueInputMeta);
|
|
186
|
+
const {
|
|
187
|
+
dispatch
|
|
188
|
+
} = this.dependencies;
|
|
189
|
+
const dependencies = this.getFormDependencies();
|
|
190
|
+
const usecase = this.createUseCase(dependencies, GetFieldValueUseCase);
|
|
191
|
+
usecase.execute({
|
|
192
|
+
fieldName,
|
|
193
|
+
callback: setData,
|
|
194
|
+
dispatch
|
|
195
|
+
});
|
|
196
|
+
return getData();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
submit() {
|
|
200
|
+
const {
|
|
201
|
+
dispatch
|
|
202
|
+
} = this.dependencies;
|
|
203
|
+
const dependencies = this.getFormDependencies();
|
|
204
|
+
const usecase = this.createUseCase(dependencies, SubmitUseCase);
|
|
205
|
+
usecase.execute({
|
|
206
|
+
dispatch
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,21 +2,28 @@ import SmartFormConstants from "../../../../cc/form-connected/Constants";
|
|
|
2
2
|
import FormSdkFactory from "./FormSdkFactory";
|
|
3
3
|
import FormConstants from "../../../../cc/form/Constants";
|
|
4
4
|
import { ZFORM_FIELD_VALUE_CHANGED } from "../../../../bc/zform/Symbol";
|
|
5
|
+
import { platformSDK } from "../../../sdk/frameworks/Sdk";
|
|
5
6
|
const {
|
|
6
7
|
SMART_FORM_FIELD_FOCUSED,
|
|
7
8
|
SMART_FORM_FIELD_BLURRED,
|
|
8
9
|
SMART_FORM_FIELD_VALUE_CHANGED
|
|
9
|
-
} = SmartFormConstants;
|
|
10
|
+
} = SmartFormConstants; // function createHandlerWithSdk(handler) {
|
|
11
|
+
// return input => {
|
|
12
|
+
// const { state, dispatch } = input;
|
|
13
|
+
// handler(input, FormSdkFactory.create({ state, dispatch }));
|
|
14
|
+
// };
|
|
15
|
+
// }
|
|
10
16
|
|
|
11
17
|
function createHandlerWithSdk(handler) {
|
|
12
18
|
return input => {
|
|
13
19
|
const {
|
|
14
|
-
state
|
|
15
|
-
dispatch
|
|
20
|
+
state
|
|
16
21
|
} = input;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
const instanceName = state.properties.instanceName;
|
|
23
|
+
handler({ ...input,
|
|
24
|
+
platformSDK
|
|
25
|
+
}, FormSdkFactory.create({
|
|
26
|
+
instanceName
|
|
20
27
|
}));
|
|
21
28
|
};
|
|
22
29
|
}
|
|
@@ -31,7 +38,7 @@ export default class EventHandlersFactory {
|
|
|
31
38
|
|
|
32
39
|
static create(eventHandlers) {
|
|
33
40
|
const wrapped = EventHandlersFactory.createWrapped(eventHandlers);
|
|
34
|
-
return {
|
|
41
|
+
return {
|
|
35
42
|
[FormConstants.FORM_FIELD_FOCUSED]: _ref => {
|
|
36
43
|
let {
|
|
37
44
|
action,
|
|
@@ -84,7 +91,8 @@ export default class EventHandlersFactory {
|
|
|
84
91
|
value
|
|
85
92
|
}
|
|
86
93
|
});
|
|
87
|
-
}
|
|
94
|
+
},
|
|
95
|
+
...wrapped
|
|
88
96
|
};
|
|
89
97
|
}
|
|
90
98
|
|
|
@@ -3,28 +3,52 @@ import { createCustomComponent } from "../../../../library/custom-component";
|
|
|
3
3
|
import ZHttpBehaviourFactory from "../../../zhttp/frameworks/ZHttpBehaviourFactory";
|
|
4
4
|
import RecordBehaviourFactory from "../../../zrecord/frameworks/RecordBehaviourFactory";
|
|
5
5
|
import FormConnectedView from "./FormConnectedView";
|
|
6
|
-
import
|
|
6
|
+
import defaultDataSource from "../../../data-source";
|
|
7
7
|
import DataBrokerBehaviourFactory from "../../../zdata-source/frameworks/DataBrokerBehaviourFactory";
|
|
8
8
|
import FormTranslator from "../../../zform/adapters/presenter/FormTranslator";
|
|
9
9
|
import ZFormBehaviourFactory from "../../../zform/frameworks/ui/ZFormBehaviourFactory";
|
|
10
10
|
import FieldValidationBehaviourFactory from "../../../../library/behaviours/field-validation/frameworks/ui/FieldValidationBehaviourFactory";
|
|
11
11
|
import EventHandlersfactory from "./EventHandlersFactory";
|
|
12
|
+
import SdkBehaviourFactory from "../../../sdk-behaviour/frameworks/SdkBehaviourFactory";
|
|
13
|
+
import ResourceNamesEnum from "../../../../bc/sdk/ResourceNamesEnum";
|
|
14
|
+
import { sdkRegistry } from "../../../sdk/frameworks/SdkRegistry";
|
|
15
|
+
import { SmartFormResources } from "../adapters/resources/SmartFormResources";
|
|
16
|
+
import ClientActionsBehaviourFactory from "../../../client-actions/behaviour/zclient-actions/frameworks/ClientActionsBehaviourFactory";
|
|
17
|
+
sdkRegistry.registerResource({
|
|
18
|
+
resourceName: ResourceNamesEnum.SMART_FORM,
|
|
19
|
+
resource: SmartFormResources
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
function combineDataSourceWithDefault(dataSource) {
|
|
23
|
+
return { ...defaultDataSource,
|
|
24
|
+
...dataSource,
|
|
25
|
+
httpTemplates: { ...defaultDataSource.httpTemplates,
|
|
26
|
+
...(dataSource === null || dataSource === void 0 ? void 0 : dataSource.httpTemplates)
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
12
31
|
export default class FormConnectedFactory {
|
|
13
32
|
static create(_ref) {
|
|
14
33
|
let {
|
|
15
34
|
name,
|
|
16
35
|
customValidators,
|
|
17
|
-
|
|
36
|
+
dataSource,
|
|
18
37
|
eventHandlers = {},
|
|
19
38
|
View = FormConnectedView
|
|
20
39
|
} = _ref;
|
|
40
|
+
|
|
41
|
+
const _dataSource = combineDataSourceWithDefault(dataSource);
|
|
42
|
+
|
|
21
43
|
return createCustomComponent({
|
|
22
44
|
name: name,
|
|
23
45
|
View: View,
|
|
24
46
|
properties: Properties,
|
|
25
47
|
eventHandlers: EventHandlersfactory.create(eventHandlers),
|
|
26
48
|
transformState: FormTranslator.transformState,
|
|
27
|
-
behaviours: [
|
|
49
|
+
behaviours: [SdkBehaviourFactory.create([ResourceNamesEnum.SMART_FORM]), ClientActionsBehaviourFactory.create({
|
|
50
|
+
getClientActions: _dataSource.httpTemplates.getClientActions
|
|
51
|
+
}), ZHttpBehaviourFactory.create(), DataBrokerBehaviourFactory.create(), RecordBehaviourFactory.create(_dataSource.httpTemplates), FieldValidationBehaviourFactory.create(), ZFormBehaviourFactory.create({
|
|
28
52
|
customValidators
|
|
29
53
|
})]
|
|
30
54
|
});
|
|
@@ -8,12 +8,24 @@ function View(_ref, ref) {
|
|
|
8
8
|
} = _ref;
|
|
9
9
|
const {
|
|
10
10
|
isLoading,
|
|
11
|
-
sections = []
|
|
11
|
+
sections = [],
|
|
12
|
+
isHeaderEnabled,
|
|
13
|
+
isFooterEnabled,
|
|
14
|
+
headerLeftActions,
|
|
15
|
+
headerRightActions,
|
|
16
|
+
footerLeftActions,
|
|
17
|
+
footerRightActions
|
|
12
18
|
} = state.viewModel;
|
|
13
19
|
return /*#__PURE__*/React.createElement(Form, {
|
|
14
20
|
getRef: ref,
|
|
15
21
|
isLoading: isLoading,
|
|
16
|
-
sections: sections
|
|
22
|
+
sections: sections,
|
|
23
|
+
isHeaderEnabled: isHeaderEnabled,
|
|
24
|
+
isFooterEnabled: isFooterEnabled,
|
|
25
|
+
headerLeftActions: headerLeftActions,
|
|
26
|
+
headerRightActions: headerRightActions,
|
|
27
|
+
footerLeftActions: footerLeftActions,
|
|
28
|
+
footerRightActions: footerRightActions
|
|
17
29
|
});
|
|
18
30
|
}
|
|
19
31
|
|