@arquimedes.co/eureka-forms 2.0.86 → 2.0.90-test
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/dist/@Types/Draft/DraftEntityData.d.ts +5 -1
- package/dist/@Types/FormStep.d.ts +3 -6
- package/dist/@Types/GenericFormSteps.d.ts +2 -0
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +2 -1
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +1 -0
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValueDialog/MaterialEntityValueDialog.js +4 -6
- package/dist/FormSteps/TextInputStep/MaterialTextInputStep/MaterialTextInputStep.js +4 -4
- package/dist/Icons/@IconTypes.d.ts +7 -0
- package/dist/Icons/@IconTypes.js +1 -0
- package/dist/Icons/CalendarIcon.d.ts +4 -0
- package/dist/Icons/CalendarIcon.js +17 -0
- package/dist/Icons/LocationIcon.d.ts +4 -0
- package/dist/Icons/LocationIcon.js +17 -0
- package/dist/Icons/PersonIcon.d.ts +4 -0
- package/dist/Icons/PersonIcon.js +17 -0
- package/dist/Shared/InputIcon/InputIcon.js +24 -2
- package/dist/Utils/DraftFunctions.d.ts +34 -2
- package/dist/Utils/DraftFunctions.js +198 -12
- package/dist/constants/Draft/DraftEntityDataTypes.d.ts +2 -1
- package/dist/constants/Draft/DraftEntityDataTypes.js +1 -0
- package/dist/constants/IconTypes.d.ts +4 -1
- package/dist/constants/IconTypes.js +3 -0
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { DraftEntityDataTypes, DraftEntityDataMappingTypes } from '../../constan
|
|
|
3
3
|
import { DraftEntityMap } from './Draft';
|
|
4
4
|
import { Condition } from '../Condition';
|
|
5
5
|
import { TicketPropertyTypes } from '../../constants/TicketPropertyTypes';
|
|
6
|
-
export type DraftEntityData = CompanyDraftEntityData | ConditionMetDraftEntityData | DateDraftEntityData | TicketDraftEntityData | MappableDraftEntityData;
|
|
6
|
+
export type DraftEntityData = CompanyDraftEntityData | ConditionMetDraftEntityData | DateDraftEntityData | TicketDraftEntityData | MappableDraftEntityData | FormStepDraftEntityData;
|
|
7
7
|
export interface BaseDraftEntityData {
|
|
8
8
|
type: DraftEntityDataTypes | DraftEntityDataMappingTypes;
|
|
9
9
|
prefix?: string;
|
|
@@ -47,4 +47,8 @@ export interface EntityValueMappingDraftEntityData extends BaseDraftEntityData {
|
|
|
47
47
|
idEntity: string;
|
|
48
48
|
idProperty: string;
|
|
49
49
|
}
|
|
50
|
+
export interface FormStepDraftEntityData extends BaseDraftEntityData {
|
|
51
|
+
type: DraftEntityDataTypes.FORM_STEP;
|
|
52
|
+
idStep: string;
|
|
53
|
+
}
|
|
50
54
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import FormStepTypes, { ClassifierOptionTypes, OptionTypes, RatingTypes, MapperStyleTypes, EntityValueOptionTypes, EntityValueDataTypes, ApiSelectorOptionTypes, ApiSelectorParamTypes } from '../constants/FormStepTypes';
|
|
2
|
+
import IconTypes from '../constants/IconTypes';
|
|
2
3
|
import { Condition } from './Condition';
|
|
3
4
|
import { EurekaDraft } from './Draft/Draft';
|
|
4
5
|
import * as GSteps from './GenericFormSteps';
|
|
@@ -123,18 +124,15 @@ export interface EntityValuePickerDialog {
|
|
|
123
124
|
}
|
|
124
125
|
interface DefaultEntityValuePickerOption {
|
|
125
126
|
type: EntityValueOptionTypes.DEFAULT;
|
|
126
|
-
idEntityValue: string;
|
|
127
127
|
condition?: Condition;
|
|
128
128
|
}
|
|
129
129
|
interface NestedEntityValuePickerOption {
|
|
130
130
|
type: EntityValueOptionTypes.NESTED;
|
|
131
|
-
idEntityValue: string;
|
|
132
131
|
steps: string[];
|
|
133
132
|
condition?: Condition;
|
|
134
133
|
}
|
|
135
134
|
interface HideFormEntityValuePickerOption {
|
|
136
135
|
type: EntityValueOptionTypes.HIDE;
|
|
137
|
-
idEntityValue: string;
|
|
138
136
|
}
|
|
139
137
|
export type EntityValuePickerPath = StepEntityValuePickerPath | ValueEntityValuePickerPath;
|
|
140
138
|
export interface StepEntityValuePickerPath {
|
|
@@ -163,7 +161,7 @@ export interface ValueEntityValuePickerFilter {
|
|
|
163
161
|
}
|
|
164
162
|
export interface ApiSelector extends GSteps.GSmartSelect {
|
|
165
163
|
type: FormStepTypes.API_SELECTOR;
|
|
166
|
-
icon
|
|
164
|
+
icon?: IconTypes;
|
|
167
165
|
url: string;
|
|
168
166
|
pathParams: ApiSelectorParam[];
|
|
169
167
|
queryParams: ApiSelectorParam[];
|
|
@@ -173,16 +171,15 @@ export interface ApiSelector extends GSteps.GSmartSelect {
|
|
|
173
171
|
/** Only has maxSize if level === 0 */
|
|
174
172
|
maxSize?: number;
|
|
175
173
|
options: Record<string, ApiSelectorOption>;
|
|
174
|
+
defaultValue?: any;
|
|
176
175
|
}
|
|
177
176
|
export type ApiSelectorOption = DefaultApiSelectorOption | NestedApiSelectorOption | HideApiSelectorOption;
|
|
178
177
|
interface DefaultApiSelectorOption {
|
|
179
178
|
type: ApiSelectorOptionTypes.DEFAULT;
|
|
180
|
-
idOption: string;
|
|
181
179
|
condition?: Condition;
|
|
182
180
|
}
|
|
183
181
|
interface NestedApiSelectorOption {
|
|
184
182
|
type: ApiSelectorOptionTypes.NESTED;
|
|
185
|
-
idOption: string;
|
|
186
183
|
steps: string[];
|
|
187
184
|
condition?: Condition;
|
|
188
185
|
}
|
|
@@ -39,9 +39,10 @@ function ConfirmationDialog(_a) {
|
|
|
39
39
|
var widthStats = useAppSelector(function (state) { return state.widthStats; });
|
|
40
40
|
var editorState = useMemo(function () {
|
|
41
41
|
return EditorState.createWithContent(convertFromRaw(mapDraftEntities({
|
|
42
|
+
form: form,
|
|
42
43
|
dependencies: dependencies,
|
|
43
44
|
ticket: { caseNumber: confirmation.case },
|
|
44
|
-
},
|
|
45
|
+
}, global.confirmation.confirmationMessage)));
|
|
45
46
|
}, [global.confirmation, dependencies, form]);
|
|
46
47
|
var hasText = editorState.getCurrentContent().hasText();
|
|
47
48
|
var renderIcon = function () {
|
|
@@ -18,19 +18,17 @@ import styles from './MaterialEntityValueDialog.module.css';
|
|
|
18
18
|
import RoundedButton from '../../../../Shared/RoundedButton/RoundedButton';
|
|
19
19
|
import { useAppSelector } from '../../../../hooks';
|
|
20
20
|
import { EditorState, convertFromRaw } from 'draft-js';
|
|
21
|
-
import { useMemo } from 'react';
|
|
21
|
+
import { useContext, useMemo } from 'react';
|
|
22
22
|
import { mapDraftEntities } from '../../../../Utils/DraftFunctions';
|
|
23
23
|
import { Editor } from 'react-draft-wysiwyg';
|
|
24
|
+
import FormContext from '../../../../Contexts/FormContext';
|
|
24
25
|
function MaterialEntityValueDialog(_a) {
|
|
25
26
|
var type = _a.type, entity = _a.entity, message = _a.message, entityValue = _a.entityValue, handleClose = _a.handleClose;
|
|
26
27
|
var formStyle = useAppSelector(function (state) { return state.global.formStyle; });
|
|
28
|
+
var form = useContext(FormContext);
|
|
27
29
|
var dependencies = useAppSelector(function (state) { return state.site.dependencies; });
|
|
28
30
|
var editorState = useMemo(function () {
|
|
29
|
-
return EditorState.createWithContent(convertFromRaw(mapDraftEntities({
|
|
30
|
-
dependencies: dependencies,
|
|
31
|
-
entity: entity,
|
|
32
|
-
entityValue: entityValue,
|
|
33
|
-
}, JSON.parse(JSON.stringify(message)))));
|
|
31
|
+
return EditorState.createWithContent(convertFromRaw(mapDraftEntities({ form: form, dependencies: dependencies, entity: entity, entityValue: entityValue }, message)));
|
|
34
32
|
}, [message, dependencies]);
|
|
35
33
|
return (_jsx(Dialog, __assign({ PaperProps: {
|
|
36
34
|
style: {
|
|
@@ -19,11 +19,11 @@ import { selectBreakPoint, useAppSelector } from '../../../hooks';
|
|
|
19
19
|
import { useFormStep } from '../../StepHooks';
|
|
20
20
|
function TextInputStep(_a) {
|
|
21
21
|
var _b;
|
|
22
|
-
var icon = _a.icon, step = _a.step, editable = _a.editable, maxLength = _a.maxLength,
|
|
22
|
+
var icon = _a.icon, step = _a.step, editable = _a.editable, maxLength = _a.maxLength, _c = _a.defaultValue, defaultValue = _c === void 0 ? step.defaultValue : _c, _d = _a.validation, validation = _d === void 0 ? step.validation : _d;
|
|
23
23
|
var currentBreakPoint = useAppSelector(selectBreakPoint);
|
|
24
|
-
var
|
|
24
|
+
var _e = useAppSelector(function (state) { return state.global; }), formStyle = _e.formStyle, postview = _e.postview;
|
|
25
25
|
var form = useContext(FormContext);
|
|
26
|
-
var
|
|
26
|
+
var _f = useFormStep(step, {
|
|
27
27
|
defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : '',
|
|
28
28
|
debounce: true,
|
|
29
29
|
rules: {
|
|
@@ -38,7 +38,7 @@ function TextInputStep(_a) {
|
|
|
38
38
|
}
|
|
39
39
|
: undefined,
|
|
40
40
|
},
|
|
41
|
-
}), ref =
|
|
41
|
+
}), ref = _f.ref, value = _f.value, onChange = _f.onChange, error = _f.error, field = _f.field;
|
|
42
42
|
return (_jsx("div", __assign({ className: styles.container, style: {
|
|
43
43
|
width: currentBreakPoint <= step.size
|
|
44
44
|
? '100%'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
function CalendarIcon(_a) {
|
|
14
|
+
var className = _a.className, style = _a.style, fill = _a.fill;
|
|
15
|
+
return (_jsx("svg", __assign({ fill: fill, style: style, className: className, xmlns: "http://www.w3.org/2000/svg", height: "24", viewBox: "-1 -1 26 26", width: "24" }, { children: _jsx("path", { d: "M20 3h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1H7V2c0-.55-.45-1-1-1s-1 .45-1 1v1H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-1 18H5c-.55 0-1-.45-1-1V8h16v12c0 .55-.45 1-1 1z" }) })));
|
|
16
|
+
}
|
|
17
|
+
export default CalendarIcon;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
function LocationIcon(_a) {
|
|
14
|
+
var className = _a.className, style = _a.style, fill = _a.fill;
|
|
15
|
+
return (_jsx("svg", __assign({ fill: fill, style: style, className: className, version: "1.1", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, { children: _jsx("path", { d: "M12 2C8.13 2 5 5.13 5 9c0 4.17 4.42 9.92 6.24 12.11.4.48 1.13.48 1.53 0C14.58 18.92 19 13.17 19 9c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z" }) })));
|
|
16
|
+
}
|
|
17
|
+
export default LocationIcon;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
var PersonIcon = function (_a) {
|
|
14
|
+
var className = _a.className, style = _a.style, fill = _a.fill;
|
|
15
|
+
return (_jsxs("svg", __assign({ fill: fill, style: style, className: className, version: "1.1", viewBox: "-42 0 512 512", xmlns: "http://www.w3.org/2000/svg" }, { children: [_jsx("path", { d: "m210.351562 246.632812c33.882813 0 63.222657-12.152343 87.195313-36.128906 23.972656-23.972656 36.125-53.304687 36.125-87.191406 0-33.875-12.152344-63.210938-36.128906-87.191406-23.976563-23.96875-53.3125-36.121094-87.191407-36.121094-33.886718 0-63.21875 12.152344-87.191406 36.125s-36.128906 53.308594-36.128906 87.1875c0 33.886719 12.15625 63.222656 36.132812 87.195312 23.976563 23.96875 53.3125 36.125 87.1875 36.125zm0 0" }), _jsx("path", { d: "m426.128906 393.703125c-.691406-9.976563-2.089844-20.859375-4.148437-32.351563-2.078125-11.578124-4.753907-22.523437-7.957031-32.527343-3.308594-10.339844-7.808594-20.550781-13.371094-30.335938-5.773438-10.15625-12.554688-19-20.164063-26.277343-7.957031-7.613282-17.699219-13.734376-28.964843-18.199219-11.226563-4.441407-23.667969-6.691407-36.976563-6.691407-5.226563 0-10.28125 2.144532-20.042969 8.5-6.007812 3.917969-13.035156 8.449219-20.878906 13.460938-6.707031 4.273438-15.792969 8.277344-27.015625 11.902344-10.949219 3.542968-22.066406 5.339844-33.039063 5.339844-10.972656 0-22.085937-1.796876-33.046874-5.339844-11.210938-3.621094-20.296876-7.625-26.996094-11.898438-7.769532-4.964844-14.800782-9.496094-20.898438-13.46875-9.75-6.355468-14.808594-8.5-20.035156-8.5-13.3125 0-25.75 2.253906-36.972656 6.699219-11.257813 4.457031-21.003906 10.578125-28.96875 18.199219-7.605469 7.28125-14.390625 16.121094-20.15625 26.273437-5.558594 9.785157-10.058594 19.992188-13.371094 30.339844-3.199219 10.003906-5.875 20.945313-7.953125 32.523437-2.058594 11.476563-3.457031 22.363282-4.148437 32.363282-.679688 9.796875-1.023438 19.964844-1.023438 30.234375 0 26.726562 8.496094 48.363281 25.25 64.320312 16.546875 15.746094 38.441406 23.734375 65.066406 23.734375h246.53125c26.625 0 48.511719-7.984375 65.0625-23.734375 16.757813-15.945312 25.253906-37.585937 25.253906-64.324219-.003906-10.316406-.351562-20.492187-1.035156-30.242187zm0 0" })] })));
|
|
16
|
+
};
|
|
17
|
+
export default PersonIcon;
|
|
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import CalendarIcon from '../../Icons/CalendarIcon';
|
|
24
25
|
import LeakIcon from '../../Icons/Construction/LeakIcon';
|
|
25
26
|
import ProjectIcon from '../../Icons/Construction/ProjectIcon';
|
|
26
27
|
import PropertyIcon from '../../Icons/Construction/PropertyIcon';
|
|
@@ -29,6 +30,9 @@ import DocumentIcon from '../../Icons/DocumentIcon';
|
|
|
29
30
|
import CheckListIcon from '../../Icons/Entities/CheckListIcon';
|
|
30
31
|
import GenericEntityIcon from '../../Icons/Entities/GenericEntityIcon';
|
|
31
32
|
import HandShakeIcon from '../../Icons/Entities/HandshakeIcon';
|
|
33
|
+
import SupplierIcon from '../../Icons/Entities/SupplierIcon';
|
|
34
|
+
import LocationIcon from '../../Icons/LocationIcon';
|
|
35
|
+
import PersonIcon from '../../Icons/PersonIcon';
|
|
32
36
|
import IconTypes from '../../constants/IconTypes';
|
|
33
37
|
function InputIcon(_a) {
|
|
34
38
|
var icon = _a.icon, _b = _a.fill, fill = _b === void 0 ? '#757575' : _b, others = __rest(_a, ["icon", "fill"]);
|
|
@@ -51,6 +55,12 @@ function InputIcon(_a) {
|
|
|
51
55
|
height: 23,
|
|
52
56
|
width: 23,
|
|
53
57
|
}, fill: fill }, others)));
|
|
58
|
+
case IconTypes.PERSON:
|
|
59
|
+
return (_jsx(PersonIcon, __assign({ style: {
|
|
60
|
+
display: 'flex',
|
|
61
|
+
height: 23,
|
|
62
|
+
width: 23,
|
|
63
|
+
}, fill: fill }, others)));
|
|
54
64
|
case IconTypes.LEAK:
|
|
55
65
|
return (_jsx(LeakIcon, __assign({ style: {
|
|
56
66
|
display: 'flex',
|
|
@@ -72,12 +82,24 @@ function InputIcon(_a) {
|
|
|
72
82
|
}, fill: fill }, others)));
|
|
73
83
|
case IconTypes.CHECKLIST:
|
|
74
84
|
return (_jsx(CheckListIcon, __assign({ style: {
|
|
85
|
+
display: 'flex',
|
|
86
|
+
height: 23,
|
|
87
|
+
width: 23,
|
|
88
|
+
}, fill: fill }, others)));
|
|
89
|
+
case IconTypes.SUPPLIER:
|
|
90
|
+
return (_jsx(SupplierIcon, __assign({ style: {
|
|
75
91
|
display: 'flex',
|
|
76
92
|
height: 24,
|
|
77
93
|
width: 24,
|
|
78
94
|
}, fill: fill }, others)));
|
|
79
|
-
case IconTypes.
|
|
80
|
-
return (_jsx(
|
|
95
|
+
case IconTypes.CALENDAR:
|
|
96
|
+
return (_jsx(CalendarIcon, __assign({ style: {
|
|
97
|
+
display: 'flex',
|
|
98
|
+
height: 23,
|
|
99
|
+
width: 23,
|
|
100
|
+
}, fill: fill }, others)));
|
|
101
|
+
case IconTypes.LOCATION:
|
|
102
|
+
return (_jsx(LocationIcon, __assign({ style: {
|
|
81
103
|
display: 'flex',
|
|
82
104
|
height: 23,
|
|
83
105
|
width: 23,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { RawDraftContentState } from 'draft-js';
|
|
1
|
+
import { RawDraftContentBlock, RawDraftContentState } from 'draft-js';
|
|
2
2
|
import { EurekaDraft } from '../@Types/Draft/Draft';
|
|
3
|
+
import { DraftEntityData } from '../@Types/Draft/DraftEntityData';
|
|
3
4
|
import { DependencyStore } from '../Form/Form';
|
|
5
|
+
import { FormStep } from '../@Types/FormStep';
|
|
6
|
+
import { Form } from '../@Types';
|
|
4
7
|
interface FormCache {
|
|
8
|
+
form: Form;
|
|
5
9
|
dependencies: DependencyStore;
|
|
6
10
|
ticket?: {
|
|
7
11
|
caseNumber: string;
|
|
@@ -20,5 +24,33 @@ interface FormCache {
|
|
|
20
24
|
}
|
|
21
25
|
export declare function stringToDraft(text: string): RawDraftContentState;
|
|
22
26
|
export declare const getRawText: (draft?: RawDraftContentState, text?: string) => RawDraftContentState;
|
|
23
|
-
export declare function mapDraftEntities(cache: FormCache, draft: EurekaDraft): RawDraftContentState;
|
|
27
|
+
export declare function mapDraftEntities(cache: FormCache, draft: EurekaDraft, mapToId?: boolean): RawDraftContentState;
|
|
28
|
+
type MappedBlock = {
|
|
29
|
+
text: string;
|
|
30
|
+
inlineStyleRanges?: RawDraftContentBlock['inlineStyleRanges'];
|
|
31
|
+
};
|
|
32
|
+
export declare const draftEntityMapper: (cache: FormCache, entityData: DraftEntityData, mapToId?: boolean) => MappedBlock;
|
|
33
|
+
type DraftBlock = EurekaDraft['blocks'][0];
|
|
34
|
+
/**
|
|
35
|
+
* The function will generate text for given draftjs editorContent.
|
|
36
|
+
*/
|
|
37
|
+
export declare function draftToString(cache: FormCache, draft: EurekaDraft, mapToId?: boolean): string;
|
|
38
|
+
/**
|
|
39
|
+
* Function to check if a block is of type list.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isList(blockType: DraftBlock['type']): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Function will return text for Entity.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getEntityText(entityMap: EurekaDraft['entityMap'], entityKey: number, blockText: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Function to check if the block is an atomic entity block.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isAtomicBlock(block: DraftBlock): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The function returns true if the string passed to it has no content.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isEmptyString(str: string): boolean;
|
|
54
|
+
export declare function getDepthPadding(depth: number): string;
|
|
55
|
+
export declare function formStepToString(step: FormStep, value: any | undefined, mapToId?: boolean): string | null;
|
|
24
56
|
export {};
|
|
@@ -6,6 +6,7 @@ import { getLocale } from '../Form/Form';
|
|
|
6
6
|
import { TicketPropertyTypes } from '../constants/TicketPropertyTypes';
|
|
7
7
|
import { format } from 'date-fns';
|
|
8
8
|
import EntityPropertyTypes from '../constants/EntityPropertyTypes';
|
|
9
|
+
import FormStepTypes, { RatingTypes } from '../constants/FormStepTypes';
|
|
9
10
|
export function stringToDraft(text) {
|
|
10
11
|
var draftStructure = {
|
|
11
12
|
blocks: [],
|
|
@@ -48,16 +49,18 @@ export var getRawText = function (draft, text) {
|
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
|
-
export function mapDraftEntities(cache, draft) {
|
|
52
|
+
export function mapDraftEntities(cache, draft, mapToId) {
|
|
53
|
+
if (mapToId === void 0) { mapToId = false; }
|
|
52
54
|
var newBlocks = [];
|
|
53
|
-
var blocks =
|
|
55
|
+
var _a = JSON.parse(JSON.stringify(draft)), blocks = _a.blocks, entityMap = _a.entityMap;
|
|
54
56
|
for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {
|
|
55
57
|
var block = blocks_1[_i];
|
|
56
|
-
newBlocks.push.apply(newBlocks, setBlockEntities(cache, block, entityMap));
|
|
58
|
+
newBlocks.push.apply(newBlocks, setBlockEntities(cache, block, entityMap, mapToId));
|
|
57
59
|
}
|
|
58
60
|
return { blocks: blocks, entityMap: entityMap };
|
|
59
61
|
}
|
|
60
|
-
function setBlockEntities(cache, block, entityMap) {
|
|
62
|
+
function setBlockEntities(cache, block, entityMap, mapToId) {
|
|
63
|
+
if (mapToId === void 0) { mapToId = false; }
|
|
61
64
|
//Con esta funcion saca el texto remplazado de la entidad
|
|
62
65
|
var entities = block.entityRanges.sort(function (s1, s2) { return s2.offset - s1.offset; });
|
|
63
66
|
var newEntities = [];
|
|
@@ -67,7 +70,7 @@ function setBlockEntities(cache, block, entityMap) {
|
|
|
67
70
|
var entityEnd = entity.offset + entity.length - 1;
|
|
68
71
|
var entityData = entityMap[entity.key];
|
|
69
72
|
if (entityData.type === DraftEntityTypes.EUREKA) {
|
|
70
|
-
var mappedBlock =
|
|
73
|
+
var mappedBlock = draftEntityMapper(cache, entityData.data, mapToId);
|
|
71
74
|
var entityText = mappedBlock.text;
|
|
72
75
|
var entitySizeDelta = entityText.length - entity.length;
|
|
73
76
|
for (var _a = 0, styles_1 = styles; _a < styles_1.length; _a++) {
|
|
@@ -159,14 +162,15 @@ function setBlockEntities(cache, block, entityMap) {
|
|
|
159
162
|
block.entityRanges = newEntities;
|
|
160
163
|
return [block];
|
|
161
164
|
}
|
|
162
|
-
var
|
|
165
|
+
export var draftEntityMapper = function (cache, entityData, mapToId) {
|
|
163
166
|
var _a;
|
|
167
|
+
if (mapToId === void 0) { mapToId = false; }
|
|
164
168
|
if (entityData.condition &&
|
|
165
169
|
entityData.type !== DraftEntityDataTypes.CONDITION_MET) {
|
|
166
170
|
if (!evaluateCondition(entityData.condition, cache.dependencies))
|
|
167
171
|
return { text: '' };
|
|
168
172
|
}
|
|
169
|
-
var value = entityMapper(cache, entityData);
|
|
173
|
+
var value = entityMapper(cache, entityData, mapToId);
|
|
170
174
|
if (!(value === null || value === void 0 ? void 0 : value.text) && entityData.fallback) {
|
|
171
175
|
value = { text: entityData.fallback };
|
|
172
176
|
}
|
|
@@ -181,8 +185,9 @@ var handleEntityMapper = function (cache, entityData) {
|
|
|
181
185
|
inlineStyleRanges: value === null || value === void 0 ? void 0 : value.inlineStyleRanges,
|
|
182
186
|
};
|
|
183
187
|
};
|
|
184
|
-
var entityMapper = function (cache, entityData) {
|
|
185
|
-
var _a, _b, _c, _d, _e, _f;
|
|
188
|
+
var entityMapper = function (cache, entityData, mapToId) {
|
|
189
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
190
|
+
if (mapToId === void 0) { mapToId = false; }
|
|
186
191
|
switch (entityData.type) {
|
|
187
192
|
case DraftEntityDataTypes.CONDITION_MET: {
|
|
188
193
|
if (evaluateCondition(entityData.condition, cache.dependencies)) {
|
|
@@ -223,14 +228,23 @@ var entityMapper = function (cache, entityData) {
|
|
|
223
228
|
block.text += ' ';
|
|
224
229
|
var offset = block.text.length;
|
|
225
230
|
block.text += nested.text;
|
|
226
|
-
for (var _i = 0,
|
|
227
|
-
var style =
|
|
231
|
+
for (var _i = 0, _h = nested.inlineStyleRanges; _i < _h.length; _i++) {
|
|
232
|
+
var style = _h[_i];
|
|
228
233
|
style.offset += offset;
|
|
229
234
|
(_e = block.inlineStyleRanges) === null || _e === void 0 ? void 0 : _e.push(style);
|
|
230
235
|
}
|
|
231
236
|
}
|
|
232
237
|
return block;
|
|
233
238
|
}
|
|
239
|
+
case DraftEntityDataTypes.FORM_STEP: {
|
|
240
|
+
var step = cache.form.steps[entityData.idStep];
|
|
241
|
+
if (!step)
|
|
242
|
+
return null;
|
|
243
|
+
var text = formStepToString(step, (_f = cache.dependencies[step.id]) === null || _f === void 0 ? void 0 : _f.value, mapToId);
|
|
244
|
+
if (text === null)
|
|
245
|
+
return null;
|
|
246
|
+
return { text: text, inlineStyleRanges: [] };
|
|
247
|
+
}
|
|
234
248
|
case DraftEntityDataTypes.DATE: {
|
|
235
249
|
var millis = entityData.days * 86400000 +
|
|
236
250
|
entityData.hours * 3600000 +
|
|
@@ -238,7 +252,7 @@ var entityMapper = function (cache, entityData) {
|
|
|
238
252
|
var subtract = false;
|
|
239
253
|
var date = new Date(new Date().getTime() + (subtract ? -millis : millis));
|
|
240
254
|
return {
|
|
241
|
-
text: format(date, (
|
|
255
|
+
text: format(date, (_g = entityData.format) !== null && _g !== void 0 ? _g : 'Pp', {
|
|
242
256
|
locale: getLocale(),
|
|
243
257
|
}),
|
|
244
258
|
};
|
|
@@ -280,3 +294,175 @@ function calcEntityProperty(property, value) {
|
|
|
280
294
|
}
|
|
281
295
|
return null;
|
|
282
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* The function will generate text for given draftjs editorContent.
|
|
299
|
+
*/
|
|
300
|
+
export function draftToString(cache, draft, mapToId) {
|
|
301
|
+
if (mapToId === void 0) { mapToId = false; }
|
|
302
|
+
var text = [];
|
|
303
|
+
if (draft) {
|
|
304
|
+
var _a = JSON.parse(JSON.stringify(draft)), blocks_2 = _a.blocks, entityMap_1 = _a.entityMap;
|
|
305
|
+
if (blocks_2 && blocks_2.length > 0) {
|
|
306
|
+
blocks_2.forEach(function (block) {
|
|
307
|
+
var content = getBlockText(cache, block, entityMap_1, blocks_2.length === 1, mapToId);
|
|
308
|
+
if (isList(block.type)) {
|
|
309
|
+
content = getDepthPadding(block.depth) + content;
|
|
310
|
+
}
|
|
311
|
+
text.push(content);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
var response = text.join('');
|
|
316
|
+
if (response === '\n') {
|
|
317
|
+
return '';
|
|
318
|
+
}
|
|
319
|
+
return response;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Function will return text for the block.
|
|
323
|
+
*/
|
|
324
|
+
function getBlockText(cache, block, entityMap, skipNextLine, mapToId) {
|
|
325
|
+
if (skipNextLine === void 0) { skipNextLine = false; }
|
|
326
|
+
if (mapToId === void 0) { mapToId = false; }
|
|
327
|
+
var blockMarkdown = [];
|
|
328
|
+
blockMarkdown.push(getBlockContentText(cache, block, entityMap, mapToId));
|
|
329
|
+
if (!isAtomicBlock(block) && !skipNextLine)
|
|
330
|
+
blockMarkdown.push('\n');
|
|
331
|
+
return blockMarkdown.join('');
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Function will return the text for block content.
|
|
335
|
+
*/
|
|
336
|
+
function getBlockContentText(cache, block, entityMap, mapToId) {
|
|
337
|
+
if (mapToId === void 0) { mapToId = false; }
|
|
338
|
+
if (isAtomicBlock(block)) {
|
|
339
|
+
return getEntityText(entityMap, block.entityRanges[0].key, block.text);
|
|
340
|
+
}
|
|
341
|
+
setBlockEntities(cache, block, entityMap, mapToId);
|
|
342
|
+
return block.text.replace('\n', '\\s\\s\n');
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Function to check if a block is of type list.
|
|
346
|
+
*/
|
|
347
|
+
export function isList(blockType) {
|
|
348
|
+
return (blockType === 'unordered-list-item' || blockType === 'ordered-list-item');
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Function will return text for Entity.
|
|
352
|
+
*/
|
|
353
|
+
export function getEntityText(entityMap, entityKey, blockText) {
|
|
354
|
+
var entity = entityMap[entityKey];
|
|
355
|
+
if (entity && entity.type === 'EUREKA') {
|
|
356
|
+
return blockText;
|
|
357
|
+
}
|
|
358
|
+
return '';
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Function to check if the block is an atomic entity block.
|
|
362
|
+
*/
|
|
363
|
+
export function isAtomicBlock(block) {
|
|
364
|
+
if (block.entityRanges.length > 0 && isEmptyString(block.text)) {
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* The function returns true if the string passed to it has no content.
|
|
371
|
+
*/
|
|
372
|
+
export function isEmptyString(str) {
|
|
373
|
+
if (str === undefined ||
|
|
374
|
+
str === null ||
|
|
375
|
+
str.length === 0 ||
|
|
376
|
+
str.trim().length === 0) {
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
export function getDepthPadding(depth) {
|
|
382
|
+
var padding = '';
|
|
383
|
+
for (var i = 0; i < depth * 4; i += 1) {
|
|
384
|
+
padding += ' ';
|
|
385
|
+
}
|
|
386
|
+
return padding;
|
|
387
|
+
}
|
|
388
|
+
export function formStepToString(step, value, mapToId) {
|
|
389
|
+
if (mapToId === void 0) { mapToId = false; }
|
|
390
|
+
if (value === undefined || value === null)
|
|
391
|
+
return null;
|
|
392
|
+
switch (step.type) {
|
|
393
|
+
case FormStepTypes.TIMEPICKER: {
|
|
394
|
+
var time = value;
|
|
395
|
+
var parts = [];
|
|
396
|
+
if (time.days) {
|
|
397
|
+
parts.push("".concat(time.days, " d\u00EDa").concat(time.days > 1 ? 's' : ''));
|
|
398
|
+
}
|
|
399
|
+
if (time.hours) {
|
|
400
|
+
parts.push("".concat(time.hours, " hora").concat(time.hours > 1 ? 's' : ''));
|
|
401
|
+
}
|
|
402
|
+
if (time.minutes) {
|
|
403
|
+
parts.push("".concat(time.minutes, " minuto").concat(time.minutes > 1 ? 's' : ''));
|
|
404
|
+
}
|
|
405
|
+
if (parts.length === 0)
|
|
406
|
+
return time.working
|
|
407
|
+
? 'horario hábil más cercano'
|
|
408
|
+
: 'inmediatamente';
|
|
409
|
+
if (time.working) {
|
|
410
|
+
var isMultiple = parts.length > 1 || parts[0].includes('s');
|
|
411
|
+
return parts.join(', ') + (isMultiple ? ' hábiles' : 'hábil');
|
|
412
|
+
}
|
|
413
|
+
return parts.join(', ');
|
|
414
|
+
}
|
|
415
|
+
case FormStepTypes.TEXTAREA:
|
|
416
|
+
return value.value;
|
|
417
|
+
case FormStepTypes.TEXTINPUT:
|
|
418
|
+
case FormStepTypes.SELECTOR:
|
|
419
|
+
return value;
|
|
420
|
+
case FormStepTypes.DATEPICKER:
|
|
421
|
+
return new Date(value).toUTCString();
|
|
422
|
+
case FormStepTypes.CHECKBOX:
|
|
423
|
+
return value ? 'Sí' : 'No';
|
|
424
|
+
case FormStepTypes.ENTITYVALUEPICKER:
|
|
425
|
+
if (mapToId && value._id)
|
|
426
|
+
return value._id;
|
|
427
|
+
if (value.label)
|
|
428
|
+
return value.label;
|
|
429
|
+
return null;
|
|
430
|
+
case FormStepTypes.CLASSIFIER_SELECTOR:
|
|
431
|
+
return value;
|
|
432
|
+
case FormStepTypes.API_SELECTOR:
|
|
433
|
+
if (mapToId && value[step.idAttribute])
|
|
434
|
+
return value[step.idAttribute];
|
|
435
|
+
if (value[step.labelAttribute])
|
|
436
|
+
return value[step.labelAttribute];
|
|
437
|
+
return null;
|
|
438
|
+
case FormStepTypes.FILEUPLOAD: {
|
|
439
|
+
return value
|
|
440
|
+
.map(function (file) { var _a; return (_a = file.fileName) !== null && _a !== void 0 ? _a : 'Archivo'; })
|
|
441
|
+
.join(', ');
|
|
442
|
+
}
|
|
443
|
+
case FormStepTypes.RATING:
|
|
444
|
+
switch (step.ratingType) {
|
|
445
|
+
case RatingTypes.LIKE:
|
|
446
|
+
return value ? 'Si' : 'No';
|
|
447
|
+
case RatingTypes.SATISFACTION:
|
|
448
|
+
switch (value) {
|
|
449
|
+
case 1:
|
|
450
|
+
return 'Muy Insatisfecho';
|
|
451
|
+
case 2:
|
|
452
|
+
return 'Insatisfecho';
|
|
453
|
+
case 3:
|
|
454
|
+
return 'Satisfecho';
|
|
455
|
+
case 4:
|
|
456
|
+
return 'Muy Satisfecho';
|
|
457
|
+
default:
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
default:
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
return value;
|
|
464
|
+
default:
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
@@ -3,7 +3,8 @@ export declare enum DraftEntityDataTypes {
|
|
|
3
3
|
NESTED = "NESTED",
|
|
4
4
|
TICKET = "TICKET",
|
|
5
5
|
COMPANY = "COMPANY",
|
|
6
|
-
CONDITION_MET = "CONDITION_MET"
|
|
6
|
+
CONDITION_MET = "CONDITION_MET",
|
|
7
|
+
FORM_STEP = "FORM_STEP"
|
|
7
8
|
}
|
|
8
9
|
export declare enum DraftEntityDataMappingTypes {
|
|
9
10
|
ENTITYVALUE_MAPPING = "ENTITYVALUE_MAPPING"
|
|
@@ -5,6 +5,7 @@ export var DraftEntityDataTypes;
|
|
|
5
5
|
DraftEntityDataTypes["TICKET"] = "TICKET";
|
|
6
6
|
DraftEntityDataTypes["COMPANY"] = "COMPANY";
|
|
7
7
|
DraftEntityDataTypes["CONDITION_MET"] = "CONDITION_MET";
|
|
8
|
+
DraftEntityDataTypes["FORM_STEP"] = "FORM_STEP";
|
|
8
9
|
})(DraftEntityDataTypes || (DraftEntityDataTypes = {}));
|
|
9
10
|
export var DraftEntityDataMappingTypes;
|
|
10
11
|
(function (DraftEntityDataMappingTypes) {
|
|
@@ -3,10 +3,13 @@ export declare enum IconTypes {
|
|
|
3
3
|
PROPERTY = "PROPERTY",
|
|
4
4
|
SPACE = "SPACE",
|
|
5
5
|
LEAK = "LEAK",
|
|
6
|
+
PERSON = "PERSON",
|
|
6
7
|
DOCUMENT = "DOCUMENT",
|
|
7
8
|
HANDSHAKE = "HANDSHAKE",
|
|
8
9
|
CHECKLIST = "CHECKLIST",
|
|
9
10
|
SUPPLIER = "SUPPLIER",
|
|
10
|
-
GENERIC = "GENERIC"
|
|
11
|
+
GENERIC = "GENERIC",
|
|
12
|
+
LOCATION = "LOCATION",
|
|
13
|
+
CALENDAR = "CALENDAR"
|
|
11
14
|
}
|
|
12
15
|
export default IconTypes;
|
|
@@ -4,10 +4,13 @@ export var IconTypes;
|
|
|
4
4
|
IconTypes["PROPERTY"] = "PROPERTY";
|
|
5
5
|
IconTypes["SPACE"] = "SPACE";
|
|
6
6
|
IconTypes["LEAK"] = "LEAK";
|
|
7
|
+
IconTypes["PERSON"] = "PERSON";
|
|
7
8
|
IconTypes["DOCUMENT"] = "DOCUMENT";
|
|
8
9
|
IconTypes["HANDSHAKE"] = "HANDSHAKE";
|
|
9
10
|
IconTypes["CHECKLIST"] = "CHECKLIST";
|
|
10
11
|
IconTypes["SUPPLIER"] = "SUPPLIER";
|
|
11
12
|
IconTypes["GENERIC"] = "GENERIC";
|
|
13
|
+
IconTypes["LOCATION"] = "LOCATION";
|
|
14
|
+
IconTypes["CALENDAR"] = "CALENDAR";
|
|
12
15
|
})(IconTypes || (IconTypes = {}));
|
|
13
16
|
export default IconTypes;
|
package/package.json
CHANGED