@servicetitan/dte-unlayer 0.122.0 → 0.124.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/dist/display-conditions/ConditionGroup.d.ts +6 -2
- package/dist/display-conditions/ConditionGroup.d.ts.map +1 -1
- package/dist/display-conditions/ConditionGroup.js +8 -3
- package/dist/display-conditions/ConditionGroup.js.map +1 -1
- package/dist/display-conditions/ConditionGroupsSection.d.ts +6 -2
- package/dist/display-conditions/ConditionGroupsSection.d.ts.map +1 -1
- package/dist/display-conditions/ConditionGroupsSection.js +4 -1
- package/dist/display-conditions/ConditionGroupsSection.js.map +1 -1
- package/dist/display-conditions/ConditionRow.d.ts +6 -2
- package/dist/display-conditions/ConditionRow.d.ts.map +1 -1
- package/dist/display-conditions/ConditionRow.js +240 -110
- package/dist/display-conditions/ConditionRow.js.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.d.ts +3 -0
- package/dist/display-conditions/DisplayConditionModal.d.ts.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.js +123 -8
- package/dist/display-conditions/DisplayConditionModal.js.map +1 -1
- package/dist/display-conditions/nunjucks.d.ts.map +1 -1
- package/dist/display-conditions/nunjucks.js +17 -6
- package/dist/display-conditions/nunjucks.js.map +1 -1
- package/dist/display-conditions/types.d.ts +3 -0
- package/dist/display-conditions/types.d.ts.map +1 -1
- package/dist/display-conditions/types.js.map +1 -1
- package/dist/editor-core-source.d.ts +1 -1
- package/dist/editor-core-source.d.ts.map +1 -1
- package/dist/editor-core-source.js +1 -1
- package/dist/editor-core-source.js.map +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +3 -1
- package/dist/editor.js.map +1 -1
- package/dist/shared/forms.d.ts +26 -0
- package/dist/shared/forms.d.ts.map +1 -1
- package/dist/shared/forms.js +75 -1
- package/dist/shared/forms.js.map +1 -1
- package/dist/unlayer-interface.d.ts +2 -0
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer-interface.js.map +1 -1
- package/package.json +1 -1
- package/src/display-conditions/ConditionGroup.tsx +12 -3
- package/src/display-conditions/ConditionGroupsSection.tsx +11 -1
- package/src/display-conditions/ConditionRow.tsx +229 -86
- package/src/display-conditions/DisplayConditionModal.tsx +138 -5
- package/src/display-conditions/nunjucks.ts +18 -9
- package/src/display-conditions/types.ts +4 -0
- package/src/editor-core-source.ts +1 -1
- package/src/editor.tsx +7 -1
- package/src/shared/forms.ts +85 -0
- package/src/unlayer-interface.tsx +9 -0
package/dist/editor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAOhB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAgB,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE3E,MAAM,WAAW,kBAAkB;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,wBAAwB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB,OAAO,CAAC,IAAI,IAAI,CAAC;IAEjB,QAAQ,CAAC,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,CAAC;IAE/C,cAAc,CAAC,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAE/C,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE/C,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI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117,7 +117,9 @@ export const UnlayerEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
117
117
|
ref: containerRef
|
|
118
118
|
}),
|
|
119
119
|
props.opts.displayConditions && /*#__PURE__*/ _jsx(DisplayConditionModal, {
|
|
120
|
-
schema: props.opts.schema
|
|
120
|
+
schema: props.opts.schema,
|
|
121
|
+
onConditionalsOpen: props.opts.onConditionalsOpen,
|
|
122
|
+
onConditionFormSelect: props.opts.onConditionFormSelect
|
|
121
123
|
})
|
|
122
124
|
]
|
|
123
125
|
});
|
package/dist/editor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/editor.tsx"],"sourcesContent":["import {\n CSSProperties,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { DisplayConditionModal } from './display-conditions/DisplayConditionModal';\nimport { UnlayerEditorTwin } from './shared/const';\nimport { UnlayerStore, UnlayerDesignChangeInfo } from './store';\nimport { UnlayerRef, CreateUnlayerEditorProps } from './unlayer-interface';\n\nexport interface UnlayerEditorProps {\n id?: string;\n design?: any;\n opts: CreateUnlayerEditorProps;\n minHeight?: number;\n style?: CSSProperties;\n\n onReady?(): void;\n\n onChange?(info: UnlayerDesignChangeInfo): void;\n\n onSnapshotSave?(tool: UnlayerEditorTwin): void;\n\n onImage?(file: File): Promise<{ url: string }>;\n\n onError?(title: string, description?: string): void;\n\n onMessage?(type: string, data: any): void;\n}\n\nexport const useUnlayerRef = () => useRef<UnlayerRef | null>(null);\n\nexport const UnlayerEditor = forwardRef<UnlayerRef, UnlayerEditorProps>((props, ref) => {\n const [isReady, setIsReady] = useState(false);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const store = useMemo(\n () => new UnlayerStore(props.opts),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useEffect(() => {\n if (containerRef.current) {\n store\n .init(containerRef.current)\n .then(() => setIsReady(true))\n .catch(() => setIsReady(false));\n }\n\n return () => store.destroy();\n }, [store]);\n useImperativeHandle(ref, () => store.unlayerRef, [store]);\n\n useEffect(() => {\n if (isReady) {\n store.setDesign(props.design);\n }\n }, [isReady, props.design, store]);\n\n useEffect(() => {\n store.setOnChange(props.onChange);\n\n return () => store.setOnChange();\n }, [props.onChange, store]);\n\n useEffect(() => {\n store.setOnSnapshotSave(props.onSnapshotSave);\n\n return () => store.setOnSnapshotSave();\n }, [props.onSnapshotSave, store]);\n\n useEffect(() => {\n if (props.opts.newSnapshot) {\n store.addTwin(props.opts.newSnapshot);\n }\n }, [props.opts.newSnapshot, store]);\n\n useEffect(() => {\n store.setOnReady(props.onReady);\n\n return () => store.setOnReady();\n }, [props.onReady, store]);\n\n useEffect(() => {\n store.setOnImage(props.onImage);\n\n return () => store.setOnImage();\n }, [props.onImage, store]);\n\n useEffect(() => {\n store.setOnError(props.onError);\n\n return () => store.setOnError();\n }, [props.onError, store]);\n\n useEffect(() => {\n store.setOnMessage(props.onMessage);\n\n return () => store.setOnMessage();\n }, [props.onMessage, store]);\n\n useEffect(() => {\n store.setOnFormSelect(props.opts.onFormSelect);\n\n return () => store.setOnFormSelect();\n }, [props.opts.onFormSelect, store]);\n\n useEffect(() => {\n store.setOnCalcFieldOpen(props.opts.onCalcFieldOpen);\n\n return () => store.setOnCalcFieldOpen();\n }, [props.opts.onCalcFieldOpen, store]);\n\n useEffect(() => {\n store.setOnCalcFieldSelect(props.opts.onCalcFieldSelect);\n\n return () => store.setOnCalcFieldSelect();\n }, [props.opts.onCalcFieldSelect, store]);\n\n const { minHeight = 800, style = {} } = props;\n\n return (\n <div style={{ minHeight, display: 'flex' }}>\n {!isReady && <p className=\"c-red-500\">error loading editor</p>}\n <div id={props.id ?? 'editor'} style={style} ref={containerRef} />\n {props.opts.displayConditions && <DisplayConditionModal
|
|
1
|
+
{"version":3,"sources":["../src/editor.tsx"],"sourcesContent":["import {\n CSSProperties,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { DisplayConditionModal } from './display-conditions/DisplayConditionModal';\nimport { UnlayerEditorTwin } from './shared/const';\nimport { UnlayerStore, UnlayerDesignChangeInfo } from './store';\nimport { UnlayerRef, CreateUnlayerEditorProps } from './unlayer-interface';\n\nexport interface UnlayerEditorProps {\n id?: string;\n design?: any;\n opts: CreateUnlayerEditorProps;\n minHeight?: number;\n style?: CSSProperties;\n\n onReady?(): void;\n\n onChange?(info: UnlayerDesignChangeInfo): void;\n\n onSnapshotSave?(tool: UnlayerEditorTwin): void;\n\n onImage?(file: File): Promise<{ url: string }>;\n\n onError?(title: string, description?: string): void;\n\n onMessage?(type: string, data: any): void;\n}\n\nexport const useUnlayerRef = () => useRef<UnlayerRef | null>(null);\n\nexport const UnlayerEditor = forwardRef<UnlayerRef, UnlayerEditorProps>((props, ref) => {\n const [isReady, setIsReady] = useState(false);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const store = useMemo(\n () => new UnlayerStore(props.opts),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useEffect(() => {\n if (containerRef.current) {\n store\n .init(containerRef.current)\n .then(() => setIsReady(true))\n .catch(() => setIsReady(false));\n }\n\n return () => store.destroy();\n }, [store]);\n useImperativeHandle(ref, () => store.unlayerRef, [store]);\n\n useEffect(() => {\n if (isReady) {\n store.setDesign(props.design);\n }\n }, [isReady, props.design, store]);\n\n useEffect(() => {\n store.setOnChange(props.onChange);\n\n return () => store.setOnChange();\n }, [props.onChange, store]);\n\n useEffect(() => {\n store.setOnSnapshotSave(props.onSnapshotSave);\n\n return () => store.setOnSnapshotSave();\n }, [props.onSnapshotSave, store]);\n\n useEffect(() => {\n if (props.opts.newSnapshot) {\n store.addTwin(props.opts.newSnapshot);\n }\n }, [props.opts.newSnapshot, store]);\n\n useEffect(() => {\n store.setOnReady(props.onReady);\n\n return () => store.setOnReady();\n }, [props.onReady, store]);\n\n useEffect(() => {\n store.setOnImage(props.onImage);\n\n return () => store.setOnImage();\n }, [props.onImage, store]);\n\n useEffect(() => {\n store.setOnError(props.onError);\n\n return () => store.setOnError();\n }, [props.onError, store]);\n\n useEffect(() => {\n store.setOnMessage(props.onMessage);\n\n return () => store.setOnMessage();\n }, [props.onMessage, store]);\n\n useEffect(() => {\n store.setOnFormSelect(props.opts.onFormSelect);\n\n return () => store.setOnFormSelect();\n }, [props.opts.onFormSelect, store]);\n\n useEffect(() => {\n store.setOnCalcFieldOpen(props.opts.onCalcFieldOpen);\n\n return () => store.setOnCalcFieldOpen();\n }, [props.opts.onCalcFieldOpen, store]);\n\n useEffect(() => {\n store.setOnCalcFieldSelect(props.opts.onCalcFieldSelect);\n\n return () => store.setOnCalcFieldSelect();\n }, [props.opts.onCalcFieldSelect, store]);\n\n const { minHeight = 800, style = {} } = props;\n\n return (\n <div style={{ minHeight, display: 'flex' }}>\n {!isReady && <p className=\"c-red-500\">error loading editor</p>}\n <div id={props.id ?? 'editor'} style={style} ref={containerRef} />\n {props.opts.displayConditions && (\n <DisplayConditionModal\n schema={props.opts.schema}\n onConditionalsOpen={props.opts.onConditionalsOpen}\n onConditionFormSelect={props.opts.onConditionFormSelect}\n />\n )}\n </div>\n );\n});\n"],"names":["forwardRef","useEffect","useImperativeHandle","useMemo","useRef","useState","DisplayConditionModal","UnlayerStore","useUnlayerRef","UnlayerEditor","props","ref","isReady","setIsReady","containerRef","store","opts","current","init","then","catch","destroy","unlayerRef","setDesign","design","setOnChange","onChange","setOnSnapshotSave","onSnapshotSave","newSnapshot","addTwin","setOnReady","onReady","setOnImage","onImage","setOnError","onError","setOnMessage","onMessage","setOnFormSelect","onFormSelect","setOnCalcFieldOpen","onCalcFieldOpen","setOnCalcFieldSelect","onCalcFieldSelect","minHeight","style","div","display","p","className","id","displayConditions","schema","onConditionalsOpen","onConditionFormSelect"],"mappings":";AAAA,SAEIA,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,QAAQ;AACf,SAAS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,IAAIzC,CAAAA,YAAAA,MAAMyC,EAAE,cAARzC,uBAAAA,YAAY;gBAAUoC,OAAOA;gBAAOnC,KAAKG;;YACjDJ,MAAMM,IAAI,CAACoC,iBAAiB,kBACzB,KAAC9C;gBACG+C,QAAQ3C,MAAMM,IAAI,CAACqC,MAAM;gBACzBC,oBAAoB5C,MAAMM,IAAI,CAACsC,kBAAkB;gBACjDC,uBAAuB7C,MAAMM,IAAI,CAACuC,qBAAqB;;;;AAK3E,GAAG"}
|
package/dist/shared/forms.d.ts
CHANGED
|
@@ -7,4 +7,30 @@ export interface FormFieldInfo {
|
|
|
7
7
|
header: string;
|
|
8
8
|
itemType: string;
|
|
9
9
|
}
|
|
10
|
+
export declare const enum FormItemType {
|
|
11
|
+
Text = "Text",
|
|
12
|
+
Number = "Number",
|
|
13
|
+
Picture = "Picture",
|
|
14
|
+
Checkboxes = "Checkboxes",
|
|
15
|
+
RadioButtons = "RadioButtons",
|
|
16
|
+
Date = "Date",
|
|
17
|
+
Signature = "Signature",
|
|
18
|
+
Dropdown = "Dropdown",
|
|
19
|
+
Stoplight = "Stoplight",
|
|
20
|
+
SmartField = "SmartField"
|
|
21
|
+
}
|
|
22
|
+
export type FormCalculatedFieldType = 'number' | 'date';
|
|
23
|
+
export type FormConditionalFieldType = 'number' | 'string';
|
|
24
|
+
export declare const buildFormFieldKey: (formId: number, fieldId: string) => string;
|
|
25
|
+
export declare const parseFormFieldKey: (key: string) => {
|
|
26
|
+
formId: number;
|
|
27
|
+
fieldId: string;
|
|
28
|
+
} | null;
|
|
29
|
+
export declare const isFormFieldKey: (key: string) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Submission keys may start with numeric properties, so dot notation is unsafe.
|
|
32
|
+
*/
|
|
33
|
+
export declare const toNunjucksFieldReference: (fieldKey: string) => string;
|
|
34
|
+
export declare const getCalculatedFieldTypeFromFormItemType: (itemType: string) => FormCalculatedFieldType | null;
|
|
35
|
+
export declare const getConditionalFieldTypeFromFormItemType: (itemType: string) => FormConditionalFieldType | null;
|
|
10
36
|
//# sourceMappingURL=forms.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forms.d.ts","sourceRoot":"","sources":["../../src/shared/forms.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB"}
|
|
1
|
+
{"version":3,"file":"forms.d.ts","sourceRoot":"","sources":["../../src/shared/forms.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,0BAAkB,YAAY;IAC1B,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,UAAU,eAAe;CAC5B;AAED,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,MAAM,CAAC;AACxD,MAAM,MAAM,wBAAwB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAO3D,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,KAAG,MACF,CAAC;AAEnE,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAkBrF,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,OAA0C,CAAC;AAExF;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,UAAU,MAAM,KAAG,MAO3D,CAAC;AAEF,eAAO,MAAM,sCAAsC,GAC/C,UAAU,MAAM,KACjB,uBAAuB,GAAG,IAQ5B,CAAC;AAEF,eAAO,MAAM,uCAAuC,GAChD,UAAU,MAAM,KACjB,wBAAwB,GAAG,IAW7B,CAAC"}
|
package/dist/shared/forms.js
CHANGED
|
@@ -1,3 +1,77 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export var FormItemType = /*#__PURE__*/ function(FormItemType) {
|
|
2
|
+
FormItemType["Text"] = "Text";
|
|
3
|
+
FormItemType["Number"] = "Number";
|
|
4
|
+
FormItemType["Picture"] = "Picture";
|
|
5
|
+
FormItemType["Checkboxes"] = "Checkboxes";
|
|
6
|
+
FormItemType["RadioButtons"] = "RadioButtons";
|
|
7
|
+
FormItemType["Date"] = "Date";
|
|
8
|
+
FormItemType["Signature"] = "Signature";
|
|
9
|
+
FormItemType["Dropdown"] = "Dropdown";
|
|
10
|
+
FormItemType["Stoplight"] = "Stoplight";
|
|
11
|
+
FormItemType["SmartField"] = "SmartField";
|
|
12
|
+
return FormItemType;
|
|
13
|
+
}({});
|
|
14
|
+
const FORM_FIELD_KEY_RE = /^__submission_fields\.(\d+)\.([A-Za-z0-9]+)$/;
|
|
15
|
+
const FORM_FIELD_RUNTIME_PATH_RE = /^__submission_fields\["(\d+)"\]\["([A-Za-z0-9]+)"\]$/;
|
|
16
|
+
const LEGACY_FORM_KEY_RE = /^form_(\d+)_([A-Za-z0-9]+)$/;
|
|
17
|
+
const LEGACY_FORM_KEY_PREFIX_RE = /^__form_(\d+)_([a-f0-9]+)$/;
|
|
18
|
+
export const buildFormFieldKey = (formId, fieldId)=>`__submission_fields.${formId}.${fieldId.replaceAll('-', '')}`;
|
|
19
|
+
export const parseFormFieldKey = (key)=>{
|
|
20
|
+
var _FORM_FIELD_KEY_RE_exec;
|
|
21
|
+
const match = (_FORM_FIELD_KEY_RE_exec = FORM_FIELD_KEY_RE.exec(key)) !== null && _FORM_FIELD_KEY_RE_exec !== void 0 ? _FORM_FIELD_KEY_RE_exec : FORM_FIELD_RUNTIME_PATH_RE.exec(key);
|
|
22
|
+
if (match) {
|
|
23
|
+
return {
|
|
24
|
+
formId: Number(match[1]),
|
|
25
|
+
fieldId: match[2]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Backward compatibility for already saved values.
|
|
29
|
+
const oldMatch = LEGACY_FORM_KEY_RE.exec(key);
|
|
30
|
+
if (oldMatch) {
|
|
31
|
+
return {
|
|
32
|
+
formId: Number(oldMatch[1]),
|
|
33
|
+
fieldId: oldMatch[2]
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const legacyMatch = LEGACY_FORM_KEY_PREFIX_RE.exec(key);
|
|
37
|
+
if (legacyMatch) {
|
|
38
|
+
return {
|
|
39
|
+
formId: Number(legacyMatch[1]),
|
|
40
|
+
fieldId: legacyMatch[2]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
};
|
|
45
|
+
export const isFormFieldKey = (key)=>parseFormFieldKey(key) !== null;
|
|
46
|
+
/**
|
|
47
|
+
* Submission keys may start with numeric properties, so dot notation is unsafe.
|
|
48
|
+
*/ export const toNunjucksFieldReference = (fieldKey)=>{
|
|
49
|
+
const parsed = parseFormFieldKey(fieldKey);
|
|
50
|
+
if (!parsed) {
|
|
51
|
+
return fieldKey;
|
|
52
|
+
}
|
|
53
|
+
return `__submission_fields["${parsed.formId}"]["${parsed.fieldId}"]`;
|
|
54
|
+
};
|
|
55
|
+
export const getCalculatedFieldTypeFromFormItemType = (itemType)=>{
|
|
56
|
+
if (itemType === 'Number') {
|
|
57
|
+
return 'number';
|
|
58
|
+
}
|
|
59
|
+
if (itemType === 'Date') {
|
|
60
|
+
return 'date';
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
};
|
|
64
|
+
export const getConditionalFieldTypeFromFormItemType = (itemType)=>{
|
|
65
|
+
if (!itemType) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
if (itemType === 'Number') {
|
|
69
|
+
return 'number';
|
|
70
|
+
}
|
|
71
|
+
if (itemType === 'Picture' || itemType === 'Signature') {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return 'string';
|
|
75
|
+
};
|
|
2
76
|
|
|
3
77
|
//# sourceMappingURL=forms.js.map
|
package/dist/shared/forms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shared/forms.ts"],"sourcesContent":["export interface FormInfo {\n id: number;\n name: string;\n}\n\nexport interface FormFieldInfo {\n id: string;\n header: string;\n itemType: string;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/shared/forms.ts"],"sourcesContent":["export interface FormInfo {\n id: number;\n name: string;\n}\n\nexport interface FormFieldInfo {\n id: string;\n header: string;\n itemType: string;\n}\n\nexport const enum FormItemType {\n Text = 'Text',\n Number = 'Number',\n Picture = 'Picture',\n Checkboxes = 'Checkboxes',\n RadioButtons = 'RadioButtons',\n Date = 'Date',\n Signature = 'Signature',\n Dropdown = 'Dropdown',\n Stoplight = 'Stoplight',\n SmartField = 'SmartField',\n}\n\nexport type FormCalculatedFieldType = 'number' | 'date';\nexport type FormConditionalFieldType = 'number' | 'string';\n\nconst FORM_FIELD_KEY_RE = /^__submission_fields\\.(\\d+)\\.([A-Za-z0-9]+)$/;\nconst FORM_FIELD_RUNTIME_PATH_RE = /^__submission_fields\\[\"(\\d+)\"\\]\\[\"([A-Za-z0-9]+)\"\\]$/;\nconst LEGACY_FORM_KEY_RE = /^form_(\\d+)_([A-Za-z0-9]+)$/;\nconst LEGACY_FORM_KEY_PREFIX_RE = /^__form_(\\d+)_([a-f0-9]+)$/;\n\nexport const buildFormFieldKey = (formId: number, fieldId: string): string =>\n `__submission_fields.${formId}.${fieldId.replaceAll('-', '')}`;\n\nexport const parseFormFieldKey = (key: string): { formId: number; fieldId: string } | null => {\n const match = FORM_FIELD_KEY_RE.exec(key) ?? FORM_FIELD_RUNTIME_PATH_RE.exec(key);\n if (match) {\n return { formId: Number(match[1]), fieldId: match[2] };\n }\n\n // Backward compatibility for already saved values.\n const oldMatch = LEGACY_FORM_KEY_RE.exec(key);\n if (oldMatch) {\n return { formId: Number(oldMatch[1]), fieldId: oldMatch[2] };\n }\n\n const legacyMatch = LEGACY_FORM_KEY_PREFIX_RE.exec(key);\n if (legacyMatch) {\n return { formId: Number(legacyMatch[1]), fieldId: legacyMatch[2] };\n }\n\n return null;\n};\n\nexport const isFormFieldKey = (key: string): boolean => parseFormFieldKey(key) !== null;\n\n/**\n * Submission keys may start with numeric properties, so dot notation is unsafe.\n */\nexport const toNunjucksFieldReference = (fieldKey: string): string => {\n const parsed = parseFormFieldKey(fieldKey);\n if (!parsed) {\n return fieldKey;\n }\n\n return `__submission_fields[\"${parsed.formId}\"][\"${parsed.fieldId}\"]`;\n};\n\nexport const getCalculatedFieldTypeFromFormItemType = (\n itemType: string,\n): FormCalculatedFieldType | null => {\n if (itemType === 'Number') {\n return 'number';\n }\n if (itemType === 'Date') {\n return 'date';\n }\n return null;\n};\n\nexport const getConditionalFieldTypeFromFormItemType = (\n itemType: string,\n): FormConditionalFieldType | null => {\n if (!itemType) {\n return null;\n }\n if (itemType === 'Number') {\n return 'number';\n }\n if (itemType === 'Picture' || itemType === 'Signature') {\n return null;\n }\n return 'string';\n};\n"],"names":["FormItemType","FORM_FIELD_KEY_RE","FORM_FIELD_RUNTIME_PATH_RE","LEGACY_FORM_KEY_RE","LEGACY_FORM_KEY_PREFIX_RE","buildFormFieldKey","formId","fieldId","replaceAll","parseFormFieldKey","key","match","exec","Number","oldMatch","legacyMatch","isFormFieldKey","toNunjucksFieldReference","fieldKey","parsed","getCalculatedFieldTypeFromFormItemType","itemType","getConditionalFieldTypeFromFormItemType"],"mappings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aAAa,UAAU;QACvB,OAAO;IACX;IACA,IAAIA,aAAa,QAAQ;QACrB,OAAO;IACX;IACA,OAAO;AACX,EAAE;AAEF,OAAO,MAAMC,0CAA0C,CACnDD;IAEA,IAAI,CAACA,UAAU;QACX,OAAO;IACX;IACA,IAAIA,aAAa,UAAU;QACvB,OAAO;IACX;IACA,IAAIA,aAAa,aAAaA,aAAa,aAAa;QACpD,OAAO;IACX;IACA,OAAO;AACX,EAAE"}
|
|
@@ -82,5 +82,7 @@ export interface CreateUnlayerEditorProps {
|
|
|
82
82
|
onFormSelect?: (formId: number) => void;
|
|
83
83
|
onCalcFieldOpen?: (usedFormIds: number[]) => void;
|
|
84
84
|
onCalcFieldSelect?: (fieldKeys: string[]) => void;
|
|
85
|
+
onConditionalsOpen?: (usedFormIds: number[], sendFormList: (forms: FormInfo[]) => void, sendFormFields: (formId: number, fields: FormFieldInfo[]) => void) => void;
|
|
86
|
+
onConditionFormSelect?: (formId: number, sendFormFields: (formId: number, fields: FormFieldInfo[]) => void) => void;
|
|
85
87
|
}
|
|
86
88
|
//# sourceMappingURL=unlayer-interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlayer-interface.d.ts","sourceRoot":"","sources":["../src/unlayer-interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,+BAA+B,EAC/B,iBAAiB,EACjB,iBAAiB,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;CACf;AACD,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAC9D,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;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AE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,IAAI,KAChE,IAAI,CAAC;IACV,qBAAqB,CAAC,EAAE,CACpB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,IAAI,KAChE,IAAI,CAAC;CACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/unlayer-interface.tsx"],"sourcesContent":["import {\n UnlayerEditorESignRecipientInfo,\n UnlayerEditorTwin,\n UnlayerEditorUnit,\n} from './shared/const';\nimport { FormFieldInfo, FormInfo } from './shared/forms';\nimport { SchemaObject } from './shared/schema';\n\nexport interface UnlayerDesignTool {\n type: string;\n slug?: string;\n values: any;\n}\nexport interface UnlayerDesignCustomTool extends UnlayerDesignTool {\n slug: string;\n}\n\nexport interface UnlayerDesignFormat {\n body: {\n rows: {\n cells: number[];\n columns: {\n contents: UnlayerDesignTool[];\n values?: any;\n }[];\n values?: any;\n }[];\n values?: any;\n };\n counters: Record<string, number>;\n schemaVersion: number;\n}\n\nexport interface UnlayerExport {\n html: string;\n chunks: any;\n design: UnlayerDesignFormat;\n}\n\nexport interface UnlayerRef {\n loadDesign(design: any): void;\n saveDesign(cb: (design: any) => void): void;\n exportHtml(cb: (data: UnlayerExport) => void): void;\n sendFormList(forms: FormInfo[]): void;\n sendFormFields(formId: number, fields: FormFieldInfo[]): void;\n sendCalcFieldLabels(labels: Record<string, string>): void;\n}\n\nexport interface UnlayerEditorMergeTagInfo {\n id: string;\n name: string;\n propertyPath: string;\n}\n\nexport interface UnlayerEditorCustomTool {\n key: string;\n title: string;\n description?: string;\n url: string;\n groupUrl?: string;\n}\n\nexport interface CreateUnlayerEditorProps {\n tools: UnlayerEditorCustomTool[];\n newSnapshot?: UnlayerEditorTwin;\n toolTwins?: UnlayerEditorTwin[];\n isSnapshotMode?: boolean;\n dummyData?: any;\n schema?: SchemaObject;\n customCSS?: string | string[] | undefined;\n customJS?: string | string[] | undefined;\n mergeTags?: UnlayerEditorMergeTagInfo[] | undefined;\n eSignRecipients?: UnlayerEditorESignRecipientInfo[] | undefined;\n eSignFieldTypes?: string[] | undefined;\n genericConfigMode?: boolean;\n generics?: true | string[];\n units?: UnlayerEditorUnit[];\n noCoreTools?: boolean;\n latest?: boolean;\n blocks?: boolean;\n hideAllTools?: boolean;\n hideContentControls?: boolean;\n hideBodyMenuItem?: boolean;\n displayConditions?: boolean;\n enableHTMLEditing?: boolean;\n enableHTMLEditingReadonly?: boolean;\n imageValidation?: {\n maxWidth?: number;\n maxHeight?: number;\n maxFileSize?: number;\n };\n holidays?: string[];\n onFormSelect?: (formId: number) => void;\n onCalcFieldOpen?: (usedFormIds: number[]) => void;\n onCalcFieldSelect?: (fieldKeys: string[]) => void;\n}\n"],"names":[],"mappings":"AA8DA,
|
|
1
|
+
{"version":3,"sources":["../src/unlayer-interface.tsx"],"sourcesContent":["import {\n UnlayerEditorESignRecipientInfo,\n UnlayerEditorTwin,\n UnlayerEditorUnit,\n} from './shared/const';\nimport { FormFieldInfo, FormInfo } from './shared/forms';\nimport { SchemaObject } from './shared/schema';\n\nexport interface UnlayerDesignTool {\n type: string;\n slug?: string;\n values: any;\n}\nexport interface UnlayerDesignCustomTool extends UnlayerDesignTool {\n slug: string;\n}\n\nexport interface UnlayerDesignFormat {\n body: {\n rows: {\n cells: number[];\n columns: {\n contents: UnlayerDesignTool[];\n values?: any;\n }[];\n values?: any;\n }[];\n values?: any;\n };\n counters: Record<string, number>;\n schemaVersion: number;\n}\n\nexport interface UnlayerExport {\n html: string;\n chunks: any;\n design: UnlayerDesignFormat;\n}\n\nexport interface UnlayerRef {\n loadDesign(design: any): void;\n saveDesign(cb: (design: any) => void): void;\n exportHtml(cb: (data: UnlayerExport) => void): void;\n sendFormList(forms: FormInfo[]): void;\n sendFormFields(formId: number, fields: FormFieldInfo[]): void;\n sendCalcFieldLabels(labels: Record<string, string>): void;\n}\n\nexport interface UnlayerEditorMergeTagInfo {\n id: string;\n name: string;\n propertyPath: string;\n}\n\nexport interface UnlayerEditorCustomTool {\n key: string;\n title: string;\n description?: string;\n url: string;\n groupUrl?: string;\n}\n\nexport interface CreateUnlayerEditorProps {\n tools: UnlayerEditorCustomTool[];\n newSnapshot?: UnlayerEditorTwin;\n toolTwins?: UnlayerEditorTwin[];\n isSnapshotMode?: boolean;\n dummyData?: any;\n schema?: SchemaObject;\n customCSS?: string | string[] | undefined;\n customJS?: string | string[] | undefined;\n mergeTags?: UnlayerEditorMergeTagInfo[] | undefined;\n eSignRecipients?: UnlayerEditorESignRecipientInfo[] | undefined;\n eSignFieldTypes?: string[] | undefined;\n genericConfigMode?: boolean;\n generics?: true | string[];\n units?: UnlayerEditorUnit[];\n noCoreTools?: boolean;\n latest?: boolean;\n blocks?: boolean;\n hideAllTools?: boolean;\n hideContentControls?: boolean;\n hideBodyMenuItem?: boolean;\n displayConditions?: boolean;\n enableHTMLEditing?: boolean;\n enableHTMLEditingReadonly?: boolean;\n imageValidation?: {\n maxWidth?: number;\n maxHeight?: number;\n maxFileSize?: number;\n };\n holidays?: string[];\n onFormSelect?: (formId: number) => void;\n onCalcFieldOpen?: (usedFormIds: number[]) => void;\n onCalcFieldSelect?: (fieldKeys: string[]) => void;\n onConditionalsOpen?: (\n usedFormIds: number[],\n sendFormList: (forms: FormInfo[]) => void,\n sendFormFields: (formId: number, fields: FormFieldInfo[]) => void,\n ) => void;\n onConditionFormSelect?: (\n formId: number,\n sendFormFields: (formId: number, fields: FormFieldInfo[]) => void,\n ) => void;\n}\n"],"names":[],"mappings":"AA8DA,WA0CC"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { Button, Flex } from '@servicetitan/anvil2';
|
|
2
2
|
import PlusIcon from '@servicetitan/anvil2/assets/icons/material/round/add.svg';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
|
+
import { FormInfo } from '../shared/forms';
|
|
4
5
|
import { ConditionRow } from './ConditionRow';
|
|
5
6
|
import { defaultCondition } from './constants';
|
|
6
|
-
import { ConditionGroup as ConditionGroupType, SingleCondition } from './types';
|
|
7
|
+
import { ConditionGroup as ConditionGroupType, FormFieldOption, SingleCondition } from './types';
|
|
7
8
|
import type { DataPointOption } from './types';
|
|
8
9
|
|
|
9
10
|
export interface ConditionGroupProps {
|
|
10
11
|
dataPointOptions: DataPointOption[];
|
|
12
|
+
formFieldOptions: FormFieldOption[];
|
|
13
|
+
forms: FormInfo[];
|
|
11
14
|
group: ConditionGroupType;
|
|
15
|
+
onFormSelect: (formId: number) => void;
|
|
12
16
|
onUpdate: (g: ConditionGroupType) => void;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
export function ConditionGroup({
|
|
16
20
|
dataPointOptions,
|
|
21
|
+
formFieldOptions,
|
|
22
|
+
forms,
|
|
17
23
|
group,
|
|
24
|
+
onFormSelect,
|
|
18
25
|
onUpdate,
|
|
19
26
|
}: Readonly<ConditionGroupProps>) {
|
|
20
27
|
const addCondition = useCallback(() => {
|
|
@@ -41,8 +48,7 @@ export function ConditionGroup({
|
|
|
41
48
|
(index: number) => {
|
|
42
49
|
let next = group.conditions.filter((_, i) => i !== index);
|
|
43
50
|
if (index === 0 && next.length > 0) {
|
|
44
|
-
|
|
45
|
-
next = [rest as SingleCondition, ...next.slice(1)];
|
|
51
|
+
next = [{ ...next[0], logicalOperator: undefined }, ...next.slice(1)];
|
|
46
52
|
}
|
|
47
53
|
onUpdate({
|
|
48
54
|
...group,
|
|
@@ -61,7 +67,10 @@ export function ConditionGroup({
|
|
|
61
67
|
canRemove
|
|
62
68
|
condition={c}
|
|
63
69
|
dataPointOptions={dataPointOptions}
|
|
70
|
+
forms={forms}
|
|
71
|
+
formFieldOptions={formFieldOptions}
|
|
64
72
|
onChange={next => updateCondition(i, next)}
|
|
73
|
+
onFormSelect={onFormSelect}
|
|
65
74
|
onRemove={() => removeCondition(i)}
|
|
66
75
|
/>
|
|
67
76
|
</Flex>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Chip, Flex, SegmentedControl, Text } from '@servicetitan/anvil2';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
+
import { FormInfo } from '../shared/forms';
|
|
3
4
|
import { ConditionGroup } from './ConditionGroup';
|
|
4
|
-
import { ConditionGroup as ConditionGroupType } from './types';
|
|
5
|
+
import { ConditionGroup as ConditionGroupType, FormFieldOption } from './types';
|
|
5
6
|
import type { DataPointOption } from './types';
|
|
6
7
|
|
|
7
8
|
export type MatchType = 'all' | 'any';
|
|
@@ -9,8 +10,11 @@ export type MatchType = 'all' | 'any';
|
|
|
9
10
|
export interface ConditionGroupsSectionProps {
|
|
10
11
|
behaviorSection?: ReactNode;
|
|
11
12
|
dataPointOptions: DataPointOption[];
|
|
13
|
+
formFieldOptions: FormFieldOption[];
|
|
14
|
+
forms: FormInfo[];
|
|
12
15
|
groups: ConditionGroupType[];
|
|
13
16
|
matchType: MatchType;
|
|
17
|
+
onFormSelect: (formId: number) => void;
|
|
14
18
|
onMatchTypeChange: (matchType: MatchType) => void;
|
|
15
19
|
onUpdateGroup: (index: number, group: ConditionGroupType) => void;
|
|
16
20
|
}
|
|
@@ -18,8 +22,11 @@ export interface ConditionGroupsSectionProps {
|
|
|
18
22
|
export function ConditionGroupsSection({
|
|
19
23
|
behaviorSection,
|
|
20
24
|
dataPointOptions,
|
|
25
|
+
formFieldOptions,
|
|
26
|
+
forms,
|
|
21
27
|
groups,
|
|
22
28
|
matchType,
|
|
29
|
+
onFormSelect,
|
|
23
30
|
onMatchTypeChange,
|
|
24
31
|
onUpdateGroup,
|
|
25
32
|
}: Readonly<ConditionGroupsSectionProps>) {
|
|
@@ -53,7 +60,10 @@ export function ConditionGroupsSection({
|
|
|
53
60
|
{behaviorSection}
|
|
54
61
|
<ConditionGroup
|
|
55
62
|
dataPointOptions={dataPointOptions}
|
|
63
|
+
formFieldOptions={formFieldOptions}
|
|
64
|
+
forms={forms}
|
|
56
65
|
group={firstGroup}
|
|
66
|
+
onFormSelect={onFormSelect}
|
|
57
67
|
onUpdate={g => onUpdateGroup(0, g)}
|
|
58
68
|
/>
|
|
59
69
|
</Flex>
|