@servicetitan/dte-unlayer 0.94.0 → 0.96.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 +12 -0
- package/dist/display-conditions/ConditionGroup.d.ts.map +1 -0
- package/dist/display-conditions/ConditionGroup.js +181 -0
- package/dist/display-conditions/ConditionGroup.js.map +1 -0
- package/dist/display-conditions/ConditionGroupsSection.d.ts +11 -0
- package/dist/display-conditions/ConditionGroupsSection.d.ts.map +1 -0
- package/dist/display-conditions/ConditionGroupsSection.js +71 -0
- package/dist/display-conditions/ConditionGroupsSection.js.map +1 -0
- package/dist/display-conditions/ConditionRow.d.ts +11 -0
- package/dist/display-conditions/ConditionRow.d.ts.map +1 -0
- package/dist/display-conditions/ConditionRow.js +206 -0
- package/dist/display-conditions/ConditionRow.js.map +1 -0
- package/dist/display-conditions/DisplayConditionModal.d.ts +5 -0
- package/dist/display-conditions/DisplayConditionModal.d.ts.map +1 -0
- package/dist/display-conditions/DisplayConditionModal.js +282 -0
- package/dist/display-conditions/DisplayConditionModal.js.map +1 -0
- package/dist/display-conditions/SeparatorWithChip.d.ts +6 -0
- package/dist/display-conditions/SeparatorWithChip.d.ts.map +1 -0
- package/dist/display-conditions/SeparatorWithChip.js +15 -0
- package/dist/display-conditions/SeparatorWithChip.js.map +1 -0
- package/dist/display-conditions/constants.d.ts +7 -0
- package/dist/display-conditions/constants.d.ts.map +1 -0
- package/dist/display-conditions/constants.js +22 -0
- package/dist/display-conditions/constants.js.map +1 -0
- package/dist/display-conditions/displayConditionController.d.ts +9 -0
- package/dist/display-conditions/displayConditionController.d.ts.map +1 -0
- package/dist/display-conditions/displayConditionController.js +29 -0
- package/dist/display-conditions/displayConditionController.js.map +1 -0
- package/dist/display-conditions/nunjucks.d.ts +8 -0
- package/dist/display-conditions/nunjucks.d.ts.map +1 -0
- package/dist/display-conditions/nunjucks.js +448 -0
- package/dist/display-conditions/nunjucks.js.map +1 -0
- package/dist/display-conditions/schemaDataPoints.d.ts +4 -0
- package/dist/display-conditions/schemaDataPoints.d.ts.map +1 -0
- package/dist/display-conditions/schemaDataPoints.js +18 -0
- package/dist/display-conditions/schemaDataPoints.js.map +1 -0
- package/dist/display-conditions/types.d.ts +130 -0
- package/dist/display-conditions/types.d.ts.map +1 -0
- package/dist/display-conditions/types.js +72 -0
- package/dist/display-conditions/types.js.map +1 -0
- 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 +4 -0
- package/dist/editor.js.map +1 -1
- package/dist/shared/schema.d.ts +2 -0
- package/dist/shared/schema.d.ts.map +1 -1
- package/dist/shared/schema.js.map +1 -1
- package/dist/unlayer.d.ts.map +1 -1
- package/dist/unlayer.js +7 -0
- package/dist/unlayer.js.map +1 -1
- package/package.json +4 -2
- package/src/display-conditions/ConditionGroup.tsx +145 -0
- package/src/display-conditions/ConditionGroupsSection.tsx +64 -0
- package/src/display-conditions/ConditionRow.tsx +185 -0
- package/src/display-conditions/DisplayConditionModal.tsx +231 -0
- package/src/display-conditions/SeparatorWithChip.tsx +14 -0
- package/src/display-conditions/constants.ts +22 -0
- package/src/display-conditions/displayConditionController.ts +42 -0
- package/src/display-conditions/nunjucks.ts +503 -0
- package/src/display-conditions/schemaDataPoints.ts +33 -0
- package/src/display-conditions/types.ts +75 -0
- package/src/editor-core-source.ts +1 -1
- package/src/editor.tsx +2 -0
- package/src/shared/schema.ts +2 -0
- package/src/unlayer.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;
|
|
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,CAAC;IAEpD,SAAS,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;CAC7C;AAED,eAAO,MAAM,aAAa,2DAAwC,CAAC;AAEnE,eAAO,MAAM,aAAa,2GA8ExB,CAAC"}
|
package/dist/editor.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { DisplayConditionModal } from './display-conditions/DisplayConditionModal';
|
|
3
4
|
import { UnlayerStore } from './store';
|
|
4
5
|
export const useUnlayerRef = ()=>useRef(null);
|
|
5
6
|
export const UnlayerEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
@@ -93,6 +94,9 @@ export const UnlayerEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
93
94
|
id: (_props_id = props.id) !== null && _props_id !== void 0 ? _props_id : 'editor',
|
|
94
95
|
style: style,
|
|
95
96
|
ref: containerRef
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ _jsx(DisplayConditionModal, {
|
|
99
|
+
schema: props.opts.schema
|
|
96
100
|
})
|
|
97
101
|
]
|
|
98
102
|
});
|
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 { 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 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 </div>\n );\n});\n"],"names":["forwardRef","useEffect","useImperativeHandle","useMemo","useRef","useState","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","minHeight","style","div","display","p","className","id"],"mappings":";AAAA,SAEIA,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,QAAQ;
|
|
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 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 <DisplayConditionModal schema={props.opts.schema} />\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","minHeight","style","div","display","p","className","id","schema"],"mappings":";AAAA,SAEIA,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,QAAQ;AACf,SAASC,qBAAqB,QAAQ,6CAA6C;AAEnF,SAASC,YAAY,QAAiC,UAAU;AAuBhE,OAAO,MAAMC,gBAAgB,IAAMJ,OAA0B,MAAM;AAEnE,OAAO,MAAMK,8BAAgBT,WAA2C,CAACU,OAAOC;IAC5E,MAAM,CAACC,SAASC,WAAW,GAAGR,SAAS;IACvC,MAAMS,eAAeV,OAA8B;IACnD,MAAMW,QAAQZ,QACV,IAAM,IAAII,aAAaG,MAAMM,IAAI,GACjC,uDAAuD;IACvD,EAAE;IAGNf,UAAU;QACN,IAAIa,aAAaG,OAAO,EAAE;YACtBF,MACKG,IAAI,CAACJ,aAAaG,OAAO,EACzBE,IAAI,CAAC,IAAMN,WAAW,OACtB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AAExD,eAAO,MAAM,mBAAmB,GAAI,OAAO,UAAU,KAAG,IAAI,IAAI,kBACR,CAAC;AAEzD,eAAO,MAAM,cAAc,GAAI,QAAQ,UAAU,EAAE,KAAK,MAAM,KAAG,UAAU,GAAG,SAgC7E,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,QAAQ,UAAU,EAAE,KAAK,MAAM,KAAG,UAAU,GAAG,SAUnF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,MAAwC,CAAC;AAE7F,eAAO,MAAM,eAAe,GACxB,MAAM,wBAAwB,EAC9B,gBAAgB,wBAAwB,KACzC,UASF,CAAC;AAEF,MAAM,WAAW,eAAe;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,cAAc,GAAI,QAAQ,YAAY,KAAG;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,GAAG,CAAA;CAgFrF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shared/schema.ts"],"sourcesContent":["export type SchemaNodeAvailableTypes = 'object' | 'array' | 'string' | 'number';\nexport const schemaNodeAvailableTypes = ['object', 'array', 'string', 'number'];\n\nexport type SchemaNodeStringSubTypes = 'string' | 'text' | 'html' | 'image';\nexport const schemaNodeStringSubTypes = ['string', 'text', 'html', 'image'];\n\nexport const schemaIsAvailableType = (type: string): type is SchemaNodeAvailableTypes =>\n schemaNodeAvailableTypes.includes(type);\n\nexport interface SchemaFieldBaseOptions {\n placeholder?: any;\n description?: any;\n sampleData?: any;\n showInEditor?: boolean;\n isHighlighted?: boolean;\n}\n\ninterface SchemaNodeProps {\n title?: string;\n options?: SchemaFieldBaseOptions;\n}\n\nexport interface SchemaObject extends SchemaNodeProps {\n type: 'object';\n properties: Record<string, SchemaNode>;\n}\n\nexport interface SchemaArray extends SchemaNodeProps {\n type: 'array';\n items: SchemaNode;\n}\n\nexport interface SchemaSimpleString extends SchemaNodeProps {\n type: 'string';\n subType?: SchemaNodeStringSubTypes;\n}\n\nexport interface SchemaSimpleNumber extends SchemaNodeProps {\n type: 'number';\n}\n\nexport type SchemaSimple = SchemaSimpleString | SchemaSimpleNumber;\n\nexport const schemaArrayRootKey = '[]';\nexport type SchemaNode = SchemaObject | SchemaArray | SchemaSimple;\n\nexport const schemaIsObject = (node?: SchemaNode): node is SchemaObject => node?.type === 'object';\nexport const schemaIsArrayOfObjects = (node?: SchemaNode): node is SchemaArray =>\n node?.type === 'array' && node?.items.type === 'object';\nexport const schemaIsArray = (node?: SchemaNode): node is SchemaArray => node?.type === 'array';\nexport const schemaIsString = (node?: SchemaNode): node is SchemaSimpleString =>\n node?.type === 'string';\nexport const schemaIsNumber = (node?: SchemaNode): node is SchemaSimpleNumber =>\n node?.type === 'number';\nexport const schemaIsStringHtml = (node?: SchemaNode): node is SchemaSimpleString =>\n node?.type === 'string' && node?.subType === 'html';\n\nexport const schemaIsStringImage = (node?: SchemaNode): node is SchemaSimpleString =>\n node?.type === 'string' && node?.subType === 'image';\n\nexport const schemaFindNode = (schema: SchemaNode, key: string): SchemaNode | undefined => {\n const nodeFinder = (node: SchemaNode, keys: string[]): SchemaNode | undefined => {\n if (!node) {\n return undefined;\n }\n\n if (!keys.length) {\n return node;\n }\n\n const key = keys.shift();\n\n if (!key) {\n return undefined;\n }\n\n if (key === schemaArrayRootKey) {\n return schemaIsArray(node) ? nodeFinder(node.items, keys) : undefined;\n }\n\n if (schemaIsObject(node)) {\n return nodeFinder(node.properties[key], keys);\n }\n\n if (schemaIsArrayOfObjects(node)) {\n return nodeFinder(((node as SchemaArray)?.items as SchemaObject).properties[key], keys);\n }\n\n return undefined;\n };\n\n return nodeFinder(schema, key.split('.'));\n};\n\nexport const schemaFindParentNode = (schema: SchemaNode, key: string): SchemaNode | undefined => {\n const keys = key.split('.');\n\n keys.pop();\n\n return keys.length\n ? schemaFindNode(schema, keys.join('.'))\n : schemaIsObject(schema) && schema.properties[key]\n ? schema\n : undefined;\n};\n\nexport const schemaGetFieldKey = (fullKey: string): string => fullKey.split('.').pop() ?? '';\n\nexport const schemaBuildNode = (\n type: SchemaNodeAvailableTypes,\n arrayItemType?: SchemaNodeAvailableTypes,\n): SchemaNode => {\n if (type === 'object') {\n return { type: 'object', properties: {}, options: {} };\n }\n if (type === 'array') {\n return { type: 'array', items: schemaBuildNode(arrayItemType ?? 'object'), options: {} };\n }\n\n return { type, options: {} };\n};\n\nexport interface SchemaMetaField {\n fieldKey: string;\n fullKey: string;\n node: SchemaNode;\n title: string; // node.title or fullTitle\n fullTitle: string; // joined title of all parents and field\n isArrayed: boolean;\n isValue: boolean;\n}\n\nexport type SchemaMap = Record<string, SchemaMetaField>;\n\nexport const schemaBuildMap = (schema: SchemaObject): { map: SchemaMap; dummyData: any } => {\n const fieldsMap: Record<string, SchemaMetaField> = {};\n const dummyData: any = {};\n\n const processNode = (\n node: SchemaNode,\n nodeKey: string,\n parentNodes: { key: string; title: string }[],\n isArrayed: boolean,\n dummyDataNode: any,\n ) => {\n const nodeLabel = node.title ?? nodeKey;\n const isArrayRoot = nodeKey === schemaArrayRootKey;\n\n if (nodeKey) {\n const fullKey = [...parentNodes.map(n => n.key), nodeKey].join('.');\n const fullTitle = [...parentNodes.map(n => n.title), nodeLabel].join(' - ');\n\n fieldsMap[fullKey] = {\n fieldKey: nodeKey,\n fullKey,\n fullTitle,\n title: (node.title ?? isArrayed) ? nodeLabel : fullTitle,\n node,\n isArrayed,\n isValue: !schemaIsObject(node) && !schemaIsArray(node),\n };\n }\n\n if (schemaIsObject(node)) {\n const properties = node.properties ?? {};\n const keys = Object.keys(properties ?? {}).sort();\n let dummyDataObject = {};\n\n if (isArrayRoot) {\n dummyDataNode.push?.(dummyDataObject);\n } else if (nodeKey) {\n dummyDataNode[nodeKey] = dummyDataObject;\n } else {\n dummyDataObject = dummyDataNode;\n }\n\n for (const key of keys) {\n processNode(\n properties[key],\n key,\n nodeKey ? [...parentNodes, { key: nodeKey, title: nodeLabel }] : [],\n isArrayed,\n dummyDataObject,\n );\n }\n } else if (schemaIsArray(node)) {\n const items = node.items ?? {};\n\n dummyDataNode[nodeKey] = [];\n processNode(\n items,\n schemaArrayRootKey,\n nodeKey ? [...parentNodes, { key: nodeKey, title: nodeLabel }] : [],\n true,\n dummyDataNode[nodeKey],\n );\n } else if (nodeKey) {\n const sampleData = node?.options?.sampleData;\n const placeholder = node?.options?.placeholder;\n const value = sampleData !== undefined ? sampleData : placeholder;\n\n if (value !== undefined) {\n if (isArrayRoot) {\n dummyDataNode.push?.(value);\n } else {\n dummyDataNode[nodeKey] = value;\n }\n }\n }\n };\n\n processNode(schema, '', [], false, dummyData);\n\n return { map: fieldsMap, dummyData };\n};\n"],"names":["schemaNodeAvailableTypes","schemaNodeStringSubTypes","schemaIsAvailableType","type","includes","schemaArrayRootKey","schemaIsObject","node","schemaIsArrayOfObjects","items","schemaIsArray","schemaIsString","schemaIsNumber","schemaIsStringHtml","subType","schemaIsStringImage","schemaFindNode","schema","key","nodeFinder","keys","undefined","length","shift","properties","split","schemaFindParentNode","pop","join","schemaGetFieldKey","fullKey","schemaBuildNode","arrayItemType","options","schemaBuildMap","fieldsMap","dummyData","processNode","nodeKey","parentNodes","isArrayed","dummyDataNode","nodeLabel","title","isArrayRoot","map","n","fullTitle","fieldKey","isValue","Object","sort","dummyDataObject","push","sampleData","placeholder","value"],"mappings":"AACA,OAAO,MAAMA,2BAA2B;IAAC;IAAU;IAAS;IAAU;CAAS,CAAC;AAGhF,OAAO,MAAMC,2BAA2B;IAAC;IAAU;IAAQ;IA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O;gBACdA;YAAd,MAAME,QAAQF,CAAAA,cAAAA,KAAKE,KAAK,cAAVF,yBAAAA,cAAc,CAAC;YAE7BkC,aAAa,CAACH,QAAQ,GAAG,EAAE;YAC3BD,YACI5B,OACAJ,oBACAiC,UAAU;mBAAIC;gBAAa;oBAAErB,KAAKoB;oBAASK,OAAOD;gBAAU;aAAE,GAAG,EAAE,EACnE,MACAD,aAAa,CAACH,QAAQ;QAE9B,OAAO,IAAIA,SAAS;gBACG/B,eACCA;YADpB,MAAM+C,aAAa/C,iBAAAA,4BAAAA,gBAAAA,KAAM0B,OAAO,cAAb1B,oCAAAA,cAAe+C,UAAU;YAC5C,MAAMC,cAAchD,iBAAAA,4BAAAA,iBAAAA,KAAM0B,OAAO,cAAb1B,qCAAAA,eAAegD,WAAW;YAC9C,MAAMC,QAAQF,eAAejC,YAAYiC,aAAaC;YAEtD,IAAIC,UAAUnC,WAAW;gBACrB,IAAIuB,aAAa;wBACbH;qBAAAA,uBAAAA,cAAcY,IAAI,cAAlBZ,2CAAAA,0BAAAA,eAAqBe;gBACzB,OAAO;oBACHf,aAAa,CAACH,QAAQ,GAAGkB;gBAC7B;YACJ;QACJ;IACJ;IAEAnB,YAAYpB,QAAQ,IAAI,EAAE,EAAE,OAAOmB;IAEnC,OAAO;QAAES,KAAKV;QAAWC;IAAU;AACvC,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../src/shared/schema.ts"],"sourcesContent":["export type SchemaNodeAvailableTypes = 'object' | 'array' | 'string' | 'number';\nexport const schemaNodeAvailableTypes = ['object', 'array', 'string', 'number'];\n\nexport type SchemaNodeStringSubTypes = 'string' | 'text' | 'html' | 'image';\nexport const schemaNodeStringSubTypes = ['string', 'text', 'html', 'image'];\n\nexport const schemaIsAvailableType = (type: string): type is SchemaNodeAvailableTypes =>\n schemaNodeAvailableTypes.includes(type);\n\nexport interface SchemaFieldBaseOptions {\n placeholder?: any;\n description?: any;\n sampleData?: any;\n showInEditor?: boolean;\n useInCalculatedFields?: boolean;\n useInConditionals?: boolean;\n isHighlighted?: boolean;\n}\n\ninterface SchemaNodeProps {\n title?: string;\n options?: SchemaFieldBaseOptions;\n}\n\nexport interface SchemaObject extends SchemaNodeProps {\n type: 'object';\n properties: Record<string, SchemaNode>;\n}\n\nexport interface SchemaArray extends SchemaNodeProps {\n type: 'array';\n items: SchemaNode;\n}\n\nexport interface SchemaSimpleString extends SchemaNodeProps {\n type: 'string';\n subType?: SchemaNodeStringSubTypes;\n}\n\nexport interface SchemaSimpleNumber extends SchemaNodeProps {\n type: 'number';\n}\n\nexport type SchemaSimple = SchemaSimpleString | SchemaSimpleNumber;\n\nexport const schemaArrayRootKey = '[]';\nexport type SchemaNode = SchemaObject | SchemaArray | SchemaSimple;\n\nexport const schemaIsObject = (node?: SchemaNode): node is SchemaObject => node?.type === 'object';\nexport const schemaIsArrayOfObjects = (node?: SchemaNode): node is SchemaArray =>\n node?.type === 'array' && node?.items.type === 'object';\nexport const schemaIsArray = (node?: SchemaNode): node is SchemaArray => node?.type === 'array';\nexport const schemaIsString = (node?: SchemaNode): node is SchemaSimpleString =>\n node?.type === 'string';\nexport const schemaIsNumber = (node?: SchemaNode): node is SchemaSimpleNumber =>\n node?.type === 'number';\nexport const schemaIsStringHtml = (node?: SchemaNode): node is SchemaSimpleString =>\n node?.type === 'string' && node?.subType === 'html';\n\nexport const schemaIsStringImage = (node?: SchemaNode): node is SchemaSimpleString =>\n node?.type === 'string' && node?.subType === 'image';\n\nexport const schemaFindNode = (schema: SchemaNode, key: string): SchemaNode | undefined => {\n const nodeFinder = (node: SchemaNode, keys: string[]): SchemaNode | undefined => {\n if (!node) {\n return undefined;\n }\n\n if (!keys.length) {\n return node;\n }\n\n const key = keys.shift();\n\n if (!key) {\n return undefined;\n }\n\n if (key === schemaArrayRootKey) {\n return schemaIsArray(node) ? nodeFinder(node.items, keys) : undefined;\n }\n\n if (schemaIsObject(node)) {\n return nodeFinder(node.properties[key], keys);\n }\n\n if (schemaIsArrayOfObjects(node)) {\n return nodeFinder(((node as SchemaArray)?.items as SchemaObject).properties[key], keys);\n }\n\n return undefined;\n };\n\n return nodeFinder(schema, key.split('.'));\n};\n\nexport const schemaFindParentNode = (schema: SchemaNode, key: string): SchemaNode | undefined => {\n const keys = key.split('.');\n\n keys.pop();\n\n return keys.length\n ? schemaFindNode(schema, keys.join('.'))\n : schemaIsObject(schema) && schema.properties[key]\n ? schema\n : undefined;\n};\n\nexport const schemaGetFieldKey = (fullKey: string): string => fullKey.split('.').pop() ?? '';\n\nexport const schemaBuildNode = (\n type: SchemaNodeAvailableTypes,\n arrayItemType?: SchemaNodeAvailableTypes,\n): SchemaNode => {\n if (type === 'object') {\n return { type: 'object', properties: {}, options: {} };\n }\n if (type === 'array') {\n return { type: 'array', items: schemaBuildNode(arrayItemType ?? 'object'), options: {} };\n }\n\n return { type, options: {} };\n};\n\nexport interface SchemaMetaField {\n fieldKey: string;\n fullKey: string;\n node: SchemaNode;\n title: string; // node.title or fullTitle\n fullTitle: string; // joined title of all parents and field\n isArrayed: boolean;\n isValue: boolean;\n}\n\nexport type SchemaMap = Record<string, SchemaMetaField>;\n\nexport const schemaBuildMap = (schema: SchemaObject): { map: SchemaMap; dummyData: any } => {\n const fieldsMap: Record<string, SchemaMetaField> = {};\n const dummyData: any = {};\n\n const processNode = (\n node: SchemaNode,\n nodeKey: string,\n parentNodes: { key: string; title: string }[],\n isArrayed: boolean,\n dummyDataNode: any,\n ) => {\n const nodeLabel = node.title ?? nodeKey;\n const isArrayRoot = nodeKey === schemaArrayRootKey;\n\n if (nodeKey) {\n const fullKey = [...parentNodes.map(n => n.key), nodeKey].join('.');\n const fullTitle = [...parentNodes.map(n => n.title), nodeLabel].join(' - ');\n\n fieldsMap[fullKey] = {\n fieldKey: nodeKey,\n fullKey,\n fullTitle,\n title: (node.title ?? isArrayed) ? nodeLabel : fullTitle,\n node,\n isArrayed,\n isValue: !schemaIsObject(node) && !schemaIsArray(node),\n };\n }\n\n if (schemaIsObject(node)) {\n const properties = node.properties ?? {};\n const keys = Object.keys(properties ?? {}).sort();\n let dummyDataObject = {};\n\n if (isArrayRoot) {\n dummyDataNode.push?.(dummyDataObject);\n } else if (nodeKey) {\n dummyDataNode[nodeKey] = dummyDataObject;\n } else {\n dummyDataObject = dummyDataNode;\n }\n\n for (const key of keys) {\n processNode(\n properties[key],\n key,\n nodeKey ? [...parentNodes, { key: nodeKey, title: nodeLabel }] : [],\n isArrayed,\n dummyDataObject,\n );\n }\n } else if (schemaIsArray(node)) {\n const items = node.items ?? {};\n\n dummyDataNode[nodeKey] = [];\n processNode(\n items,\n schemaArrayRootKey,\n nodeKey ? [...parentNodes, { key: nodeKey, title: nodeLabel }] : [],\n true,\n dummyDataNode[nodeKey],\n );\n } else if (nodeKey) {\n const sampleData = node?.options?.sampleData;\n const placeholder = node?.options?.placeholder;\n const value = sampleData !== undefined ? sampleData : placeholder;\n\n if (value !== undefined) {\n if (isArrayRoot) {\n dummyDataNode.push?.(value);\n } else {\n dummyDataNode[nodeKey] = value;\n }\n }\n }\n };\n\n processNode(schema, '', [], false, dummyData);\n\n return { map: fieldsMap, dummyData };\n};\n"],"names":["schemaNodeAvailableTypes","schemaNodeStringSubTypes","schemaIsAvailableType","type","includes","schemaArrayRootKey","schemaIsObject","node","schemaIsArrayOfObjects","items","schemaIsArray","schemaIsString","schemaIsNumber","schemaIsStringHtml","subType","schemaIsStringImage","schemaFindNode","schema","key","nodeFinder","keys","undefined","length","shift","properties","split","schemaFindParentNode","pop","join","schemaGetFieldKey","fullKey","schemaBuildNode","arrayItemType","options","schemaBuildMap","fieldsMap","dummyData","processNode","nodeKey","parentNodes","isArrayed","dummyDataNode","nodeLabel","title","isArrayRoot","map","n","fullTitle","fieldKey","isValue","Object","sort","dummyDataObject","push","sampleData","placeholder","value"],"mappings":"AACA,OAAO,MAAMA,2BAA2B;IAAC;IAAU;IAAS;IAAU;CAAS,CAAC;AAGhF,OAAO,MAAMC,2BAA2B;IAAC;IAAU;IAAQ;IA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O;gBACdA;YAAd,MAAME,QAAQF,CAAAA,cAAAA,KAAKE,KAAK,cAAVF,yBAAAA,cAAc,CAAC;YAE7BkC,aAAa,CAACH,QAAQ,GAAG,EAAE;YAC3BD,YACI5B,OACAJ,oBACAiC,UAAU;mBAAIC;gBAAa;oBAAErB,KAAKoB;oBAASK,OAAOD;gBAAU;aAAE,GAAG,EAAE,EACnE,MACAD,aAAa,CAACH,QAAQ;QAE9B,OAAO,IAAIA,SAAS;gBACG/B,eACCA;YADpB,MAAM+C,aAAa/C,iBAAAA,4BAAAA,gBAAAA,KAAM0B,OAAO,cAAb1B,oCAAAA,cAAe+C,UAAU;YAC5C,MAAMC,cAAchD,iBAAAA,4BAAAA,iBAAAA,KAAM0B,OAAO,cAAb1B,qCAAAA,eAAegD,WAAW;YAC9C,MAAMC,QAAQF,eAAejC,YAAYiC,aAAaC;YAEtD,IAAIC,UAAUnC,WAAW;gBACrB,IAAIuB,aAAa;wBACbH;qBAAAA,uBAAAA,cAAcY,IAAI,cAAlBZ,2CAAAA,0BAAAA,eAAqBe;gBACzB,OAAO;oBACHf,aAAa,CAACH,QAAQ,GAAGkB;gBAC7B;YACJ;QACJ;IACJ;IAEAnB,YAAYpB,QAAQ,IAAI,EAAE,EAAE,OAAOmB;IAEnC,OAAO;QAAES,KAAKV;QAAWC;IAAU;AACvC,EAAE"}
|
package/dist/unlayer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlayer.d.ts","sourceRoot":"","sources":["../src/unlayer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unlayer.d.ts","sourceRoot":"","sources":["../src/unlayer.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,GAAG,CAAC;CACf;AAED,MAAM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C;CACpC;AAED,oBAAY,sBAAsB;IAC9B,YAAY,kBAAkB;IAC9B,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,eAAe,qBAAqB;IACpC,QAAQ,cAAc;IACtB,QAAQ,cAAc;IACtB,UAAU,gBAAgB;IAC1B,WAAW,iBAAiB;IAC5B,WAAW,iBAAiB;IAC5B,aAAa,mBAAmB;IAChC,cAAc,oBAAoB;IAClC,YAAY,kBAAkB;CACjC;AAED,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,sBAAsB,CAAC;IAC7B,IAAI,EAAE;QACF,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,GAAG,CAAC;KACf,CAAC;CACL;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;;;CAGpB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,mBAAmB,MAAM,WAO5D,CAAC;AAEF,eAAO,MAAM,2BAA2B,cAUvC,CAAC;AAEF,eAAO,MAAM,uBAAuB,cAMnC,CAAC;AAyBF,eAAO,MAAM,uBAAuB,cAQnC,CAAC;AACF,eAAO,MAAM,gBAAgB,cAiC5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC5B,WAAW,cAAc,EACzB,6MAeG,wBAAwB,KAC5B,OAkLF,CAAC"}
|
package/dist/unlayer.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { emitDisplayCondition } from './display-conditions/displayConditionController';
|
|
1
2
|
import { editorCoreScript, editorCoreStyles, editorCoreTools } from './editor-core';
|
|
2
3
|
import { constGenericsEditor } from './shared/const';
|
|
3
4
|
import { unlayerSupportedFonts } from './shared/fonts';
|
|
@@ -298,6 +299,12 @@ export const createUnlayerEditor = (container, { customCSS, customJS, eSignField
|
|
|
298
299
|
}
|
|
299
300
|
});
|
|
300
301
|
document.getElementById = currentFind;
|
|
302
|
+
result.registerCallback('displayCondition', function(data, done) {
|
|
303
|
+
emitDisplayCondition({
|
|
304
|
+
data,
|
|
305
|
+
done
|
|
306
|
+
});
|
|
307
|
+
});
|
|
301
308
|
return result;
|
|
302
309
|
};
|
|
303
310
|
|
package/dist/unlayer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/unlayer.tsx"],"sourcesContent":["import { editorCoreScript, editorCoreStyles, editorCoreTools } from './editor-core';\nimport { constGenericsEditor } from './shared/const';\nimport { unlayerSupportedFonts } from './shared/fonts';\nimport {\n unlayerCustomEmptyToolState,\n unlayerCustomToolMetaData,\n unlayerCustomToolsGetRegisterUrls,\n} from './tools';\nimport { CreateUnlayerEditorProps } from './unlayer-interface';\n\nexport interface UnlayerExport {\n html: string;\n chunks: any;\n design: any;\n}\n\nexport interface Unlayer {\n addEventListener(event: string, cb: (arg: any) => void): void;\n removeEventListener(event: string, cb: (arg: any) => void): void;\n registerCallback(type: string, cb: (...args: any[]) => void): void;\n unregisterCallback(type: string, cb: (...args: any[]) => void): void;\n registerProvider(type: string, cb: (...args: any[]) => void): void;\n unregisterProvider(type: string, cb: (...args: any[]) => void): void;\n loadDesign(design: any): void;\n saveDesign(callback: (design: any) => void): void;\n exportHtml(callback: (data: UnlayerExport) => void): void;\n setMergeTags(tags: any): void;\n createViewer(opts: { render: (values: any) => string }): any;\n registerTool(tool: any): void;\n setBodyValues(values: any): void;\n}\n\nexport enum DesignUpdatedEventType {\n ContentAdded = 'content:added',\n ContentMoved = 'content:moved',\n ContentRemoved = 'content:removed',\n ContentModified = 'content:modified',\n RowAdded = 'row:added',\n RowMoved = 'row:moved',\n RowRemoved = 'row:removed',\n RowModified = 'row:modified',\n ColumnAdded = 'column:added',\n ColumnRemoved = 'column:removed',\n ColumnModified = 'column:modified',\n BodyModified = 'body:modified',\n}\n\nexport interface EventDesignUpdated {\n type: DesignUpdatedEventType;\n item: {\n type: string;\n slug?: string;\n values: any;\n };\n}\n\n/**\n * !!! IMPORTANT !!!\n * do not forget to update schema version when updating unlayer version\n * it is important for templates export and should be in sync\n * to know correct schema version, open unlayer editor and check output design ('schema' property)\n */\nexport const versions = {\n unlayer: '1.339.0',\n schema: 22,\n};\n\nexport const handlePreselectTool = (preselectToolSlug: string) => {\n return `\n const element = document.querySelector('.u_content_custom_${preselectToolSlug}');\n if (element) {\n element.click();\n }\n `;\n};\n\nexport const hideUnlayerContentsControls = () => {\n return `\n .blockbuilder-layer-controls-contents, .blockbuilder-layer-controls-rows {\n display: none !important;\n }\n\n .blockbuilder-options-header .text-right .icon-delete, .blockbuilder-options-header .text-right .icon-duplicate {\n display: none !important;\n }\n `;\n};\n\nexport const hideUnlayerBodyMenuItem = () => {\n return `\n .nav-item.tab-body {\n display: none !important;\n }\n `;\n};\n\nconst injectEditorCoreStyles = () => {\n const cssText = editorCoreStyles?.trim();\n\n if (!cssText) {\n return '';\n }\n\n return `\n (function () {\n var css = ${JSON.stringify(cssText)};\n var id = 'dte-unlayer-core-styles';\n if (document.getElementById(id)) {\n return;\n }\n var style = document.createElement('style');\n style.id = id;\n style.type = 'text/css';\n style.appendChild(document.createTextNode(css));\n document.head.appendChild(style);\n })();\n `;\n};\n\nexport const hideMobileTabletPreview = () => `\n [data-key=\"preview-tablet\"],\n [data-key=\"resolution\"],\n [data-key=\"dark-mode\"],\n [data-key=\"preview-desktop\"],\n [data-key=\"preview-mobile\"] {\n display: none !important;\n }\n`;\nexport const hideUnlayerTools = () => {\n return `\n .blockbuilder-content-tools {\n display: none !important;\n }\n \n .unlayer-custom-empty-tool-state {\n display: flex;\n margin-top: 150px;\n flex-direction: column;\n justify-content: center;\n }\n \n .unlayer-custom-empty-tool-state-icon {\n text-align: center;\n margin-bottom: 12px;\n }\n \n .unlayer-custom-empty-tool-state-icon svg{\n color: #606162;\n }\n \n .unlayer-custom-empty-tool-state-text {\n text-align: center;\n font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;\n font-size: 16px;\n font-style: normal;\n font-weight: 500;\n line-height: normal;\n color: #606162;\n line-height: 13px;\n }\n `;\n};\n\nexport const createUnlayerEditor = (\n container: HTMLDivElement,\n {\n customCSS,\n customJS,\n eSignFieldTypes,\n eSignRecipients,\n enableHTMLEditing,\n enableHTMLEditingReadonly,\n hideAllTools,\n hideBodyMenuItem,\n hideContentControls,\n latest,\n mergeTags,\n noCoreTools,\n tools,\n units,\n }: CreateUnlayerEditorProps,\n): Unlayer => {\n const customScripts = [\n editorCoreScript,\n editorCoreTools,\n injectEditorCoreStyles(),\n 'window.dteStore.sendData(\"--core-loaded\")',\n ...unlayerCustomToolsGetRegisterUrls(tools),\n unlayerCustomToolMetaData(tools),\n ...(customJS ? (Array.isArray(customJS) ? customJS : [customJS]) : []),\n hideAllTools ? unlayerCustomEmptyToolState() : '',\n 'window.dteStore.sendData(\"--data-loaded\")',\n ].filter(js => !!js?.trim());\n const customStyles = [\n editorCoreStyles,\n ...(customCSS ? (Array.isArray(customCSS) ? customCSS : [customCSS]) : []),\n /*\n * @TODO this is workaround for hiding all tools from unlayer sidebar.\n * Will be better to use unlayer functionality for this but it is not implemented yet\n */\n hideMobileTabletPreview(),\n hideAllTools ? hideUnlayerTools() : '',\n hideContentControls ? hideUnlayerContentsControls() : '',\n hideBodyMenuItem ? hideUnlayerBodyMenuItem() : '',\n ].filter(css => !!css?.trim());\n\n /**\n * Unlayer supports only passing id of container, but when we use shadowDOM (MFE),\n * getElementById can't find element in it\n * so making this dirty hack to let unlayer find container in DOM\n */\n const id = container.id;\n const currentFind = document.getElementById;\n document.getElementById = function (elementId: string) {\n if (id === elementId) {\n return container;\n }\n\n return currentFind.call(document, id);\n };\n\n const acv = constGenericsEditor.adminConfigProperty;\n\n const eSignTypeMapping = (eSignFieldTypes ?? []).map(key => ({\n label: key,\n value: key.charAt(0).toLowerCase() + key.replace(/ /g, '').slice(1),\n }));\n\n const unitsConfig = (units ?? []).reduce(\n (out, unit) => {\n out[`custom#${unit.generic}:unit:${unit.id}`] = {\n data: {\n [acv]: unit.values[acv],\n },\n properties: {\n [constGenericsEditor.userConfigProperty]: {\n editor: {\n data: { [acv]: unit.values[acv] },\n },\n },\n [constGenericsEditor.infoDataProperty]: {\n editor: {\n data: { title: unit.title },\n },\n },\n },\n };\n return out;\n },\n {} as Record<string, any>,\n );\n\n const eSignComponentRecipients = {\n properties: {\n eSignRecipient: {\n editor: {\n data: {\n options: eSignRecipients?.map(item => ({\n label: item.displayName,\n value: item.name,\n })),\n },\n },\n },\n eSignFieldType: {\n editor: {\n data: {\n options: eSignTypeMapping,\n },\n },\n },\n },\n };\n\n const result = (window as any).unlayer.createEditor({\n displayMode: 'web',\n devices: ['desktop'],\n features: {\n preview: true,\n userUploads: false,\n stockImages: false,\n textEditor: {\n tables: true,\n },\n },\n mergeTags: mergeTags?.reduce(\n (out, tag) => {\n out[tag.id] = { name: tag.name, value: tag.propertyPath };\n\n return out;\n },\n {} as Record<string, { name: string; value: string }>,\n ),\n projectId: 5713,\n version: latest ? undefined : versions.unlayer,\n appearance: {\n theme: 'classic_light',\n },\n tools: {\n 'carousel': { enabled: false },\n 'button': { enabled: false },\n 'html': {\n enabled: enableHTMLEditing,\n properties: {\n html: {\n editor: {\n widgetParams: {\n codeMirrorOptions: {\n readOnly: enableHTMLEditingReadonly,\n },\n },\n },\n },\n },\n },\n 'table': {\n enabled: true,\n },\n 'menu': { enabled: false },\n 'form': { enabled: false },\n ...(noCoreTools\n ? {\n columns: { enabled: false },\n text: { enabled: false },\n heading: { enabled: false },\n divider: { enabled: false },\n image: { enabled: false },\n }\n : {}),\n ...unitsConfig,\n 'custom#e-sign': eSignComponentRecipients,\n },\n editor: {\n autoSelectOnDrop: true,\n },\n customJS: customScripts,\n customCSS: customStyles,\n id,\n fonts: {\n showDefaultFonts: false,\n customFonts: unlayerSupportedFonts,\n },\n tabs: {\n content: {},\n body: {},\n blocks: { enabled: false },\n },\n });\n\n document.getElementById = currentFind;\n return result;\n};\n"],"names":["editorCoreScript","editorCoreStyles","editorCoreTools","constGenericsEditor","unlayerSupportedFonts","unlayerCustomEmptyToolState","unlayerCustomToolMetaData","unlayerCustomToolsGetRegisterUrls","DesignUpdatedEventType","versions","unlayer","schema","handlePreselectTool","preselectToolSlug","hideUnlayerContentsControls","hideUnlayerBodyMenuItem","injectEditorCoreStyles","cssText","trim","JSON","stringify","hideMobileTabletPreview","hideUnlayerTools","createUnlayerEditor","container","customCSS","customJS","eSignFieldTypes","eSignRecipients","enableHTMLEditing","enableHTMLEditingReadonly","hideAllTools","hideBodyMenuItem","hideContentControls","latest","mergeTags","noCoreTools","tools","units","customScripts","Array","isArray","filter","js","customStyles","css","id","currentFind","document","getElementById","elementId","call","acv","adminConfigProperty","eSignTypeMapping","map","key","label","value","charAt","toLowerCase","replace","slice","unitsConfig","reduce","out","unit","generic","data","values","properties","userConfigProperty","editor","infoDataProperty","title","eSignComponentRecipients","eSignRecipient","options","item","displayName","name","eSignFieldType","result","window","createEditor","displayMode","devices","features","preview","userUploads","stockImages","textEditor","tables","tag","propertyPath","projectId","version","undefined","appearance","theme","enabled","html","widgetParams","codeMirrorOptions","readOnly","columns","text","heading","divider","image","autoSelectOnDrop","fonts","showDefaultFonts","customFonts","tabs","content","body","blocks"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,gBAAgB;AACpF,SAASC,mBAAmB,QAAQ,iBAAiB;AACrD,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SACIC,2BAA2B,EAC3BC,yBAAyB,EACzBC,iCAAiC,QAC9B,UAAU;AAyBjB,OAAO,IAAA,AAAKC,gDAAAA;;;;;;;;;;;;;WAAAA;MAaX;AAWD;;;;;CAKC,GACD,OAAO,MAAMC,WAAW;IACpBC,SAAS;IACTC,QAAQ;AACZ,EAAE;AAEF,OAAO,MAAMC,sBAAsB,CAACC;IAChC,OAAO,CAAC;kEACsD,EAAEA,kBAAkB;;;;IAIlF,CAAC;AACL,EAAE;AAEF,OAAO,MAAMC,8BAA8B;IACvC,OAAO,CAAC;;;;;;;;IAQR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AS;gBAAM;gBAC1BS,OAAO;oBAAET,SAAS;gBAAM;YAC5B,IACA,CAAC,CAAC;YACR,GAAGrC,WAAW;YACd,iBAAiBY;QACrB;QACAH,QAAQ;YACJsC,kBAAkB;QACtB;QACApF,UAAUa;QACVd,WAAWmB;QACXE;QACAiE,OAAO;YACHC,kBAAkB;YAClBC,aAAa7G;QACjB;QACA8G,MAAM;YACFC,SAAS,CAAC;YACVC,MAAM,CAAC;YACPC,QAAQ;gBAAEjB,SAAS;YAAM;QAC7B;IACJ;IAEApD,SAASC,cAAc,GAAGF;IAC1B,OAAOmC;AACX,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/unlayer.tsx"],"sourcesContent":["import { emitDisplayCondition } from './display-conditions/displayConditionController';\nimport { editorCoreScript, editorCoreStyles, editorCoreTools } from './editor-core';\nimport { constGenericsEditor } from './shared/const';\nimport { unlayerSupportedFonts } from './shared/fonts';\nimport {\n unlayerCustomEmptyToolState,\n unlayerCustomToolMetaData,\n unlayerCustomToolsGetRegisterUrls,\n} from './tools';\nimport { CreateUnlayerEditorProps } from './unlayer-interface';\n\nexport interface UnlayerExport {\n html: string;\n chunks: any;\n design: any;\n}\n\nexport interface Unlayer {\n addEventListener(event: string, cb: (arg: any) => void): void;\n removeEventListener(event: string, cb: (arg: any) => void): void;\n registerCallback(type: string, cb: (...args: any[]) => void): void;\n unregisterCallback(type: string, cb: (...args: any[]) => void): void;\n registerProvider(type: string, cb: (...args: any[]) => void): void;\n unregisterProvider(type: string, cb: (...args: any[]) => void): void;\n loadDesign(design: any): void;\n saveDesign(callback: (design: any) => void): void;\n exportHtml(callback: (data: UnlayerExport) => void): void;\n setMergeTags(tags: any): void;\n createViewer(opts: { render: (values: any) => string }): any;\n registerTool(tool: any): void;\n setBodyValues(values: any): void;\n}\n\nexport enum DesignUpdatedEventType {\n ContentAdded = 'content:added',\n ContentMoved = 'content:moved',\n ContentRemoved = 'content:removed',\n ContentModified = 'content:modified',\n RowAdded = 'row:added',\n RowMoved = 'row:moved',\n RowRemoved = 'row:removed',\n RowModified = 'row:modified',\n ColumnAdded = 'column:added',\n ColumnRemoved = 'column:removed',\n ColumnModified = 'column:modified',\n BodyModified = 'body:modified',\n}\n\nexport interface EventDesignUpdated {\n type: DesignUpdatedEventType;\n item: {\n type: string;\n slug?: string;\n values: any;\n };\n}\n\n/**\n * !!! IMPORTANT !!!\n * do not forget to update schema version when updating unlayer version\n * it is important for templates export and should be in sync\n * to know correct schema version, open unlayer editor and check output design ('schema' property)\n */\nexport const versions = {\n unlayer: '1.339.0',\n schema: 22,\n};\n\nexport const handlePreselectTool = (preselectToolSlug: string) => {\n return `\n const element = document.querySelector('.u_content_custom_${preselectToolSlug}');\n if (element) {\n element.click();\n }\n `;\n};\n\nexport const hideUnlayerContentsControls = () => {\n return `\n .blockbuilder-layer-controls-contents, .blockbuilder-layer-controls-rows {\n display: none !important;\n }\n\n .blockbuilder-options-header .text-right .icon-delete, .blockbuilder-options-header .text-right .icon-duplicate {\n display: none !important;\n }\n `;\n};\n\nexport const hideUnlayerBodyMenuItem = () => {\n return `\n .nav-item.tab-body {\n display: none !important;\n }\n `;\n};\n\nconst injectEditorCoreStyles = () => {\n const cssText = editorCoreStyles?.trim();\n\n if (!cssText) {\n return '';\n }\n\n return `\n (function () {\n var css = ${JSON.stringify(cssText)};\n var id = 'dte-unlayer-core-styles';\n if (document.getElementById(id)) {\n return;\n }\n var style = document.createElement('style');\n style.id = id;\n style.type = 'text/css';\n style.appendChild(document.createTextNode(css));\n document.head.appendChild(style);\n })();\n `;\n};\n\nexport const hideMobileTabletPreview = () => `\n [data-key=\"preview-tablet\"],\n [data-key=\"resolution\"],\n [data-key=\"dark-mode\"],\n [data-key=\"preview-desktop\"],\n [data-key=\"preview-mobile\"] {\n display: none !important;\n }\n`;\nexport const hideUnlayerTools = () => {\n return `\n .blockbuilder-content-tools {\n display: none !important;\n }\n \n .unlayer-custom-empty-tool-state {\n display: flex;\n margin-top: 150px;\n flex-direction: column;\n justify-content: center;\n }\n \n .unlayer-custom-empty-tool-state-icon {\n text-align: center;\n margin-bottom: 12px;\n }\n \n .unlayer-custom-empty-tool-state-icon svg{\n color: #606162;\n }\n \n .unlayer-custom-empty-tool-state-text {\n text-align: center;\n font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;\n font-size: 16px;\n font-style: normal;\n font-weight: 500;\n line-height: normal;\n color: #606162;\n line-height: 13px;\n }\n `;\n};\n\nexport const createUnlayerEditor = (\n container: HTMLDivElement,\n {\n customCSS,\n customJS,\n eSignFieldTypes,\n eSignRecipients,\n enableHTMLEditing,\n enableHTMLEditingReadonly,\n hideAllTools,\n hideBodyMenuItem,\n hideContentControls,\n latest,\n mergeTags,\n noCoreTools,\n tools,\n units,\n }: CreateUnlayerEditorProps,\n): Unlayer => {\n const customScripts = [\n editorCoreScript,\n editorCoreTools,\n injectEditorCoreStyles(),\n 'window.dteStore.sendData(\"--core-loaded\")',\n ...unlayerCustomToolsGetRegisterUrls(tools),\n unlayerCustomToolMetaData(tools),\n ...(customJS ? (Array.isArray(customJS) ? customJS : [customJS]) : []),\n hideAllTools ? unlayerCustomEmptyToolState() : '',\n 'window.dteStore.sendData(\"--data-loaded\")',\n ].filter(js => !!js?.trim());\n const customStyles = [\n editorCoreStyles,\n ...(customCSS ? (Array.isArray(customCSS) ? customCSS : [customCSS]) : []),\n /*\n * @TODO this is workaround for hiding all tools from unlayer sidebar.\n * Will be better to use unlayer functionality for this but it is not implemented yet\n */\n hideMobileTabletPreview(),\n hideAllTools ? hideUnlayerTools() : '',\n hideContentControls ? hideUnlayerContentsControls() : '',\n hideBodyMenuItem ? hideUnlayerBodyMenuItem() : '',\n ].filter(css => !!css?.trim());\n\n /**\n * Unlayer supports only passing id of container, but when we use shadowDOM (MFE),\n * getElementById can't find element in it\n * so making this dirty hack to let unlayer find container in DOM\n */\n const id = container.id;\n const currentFind = document.getElementById;\n document.getElementById = function (elementId: string) {\n if (id === elementId) {\n return container;\n }\n\n return currentFind.call(document, id);\n };\n\n const acv = constGenericsEditor.adminConfigProperty;\n\n const eSignTypeMapping = (eSignFieldTypes ?? []).map(key => ({\n label: key,\n value: key.charAt(0).toLowerCase() + key.replace(/ /g, '').slice(1),\n }));\n\n const unitsConfig = (units ?? []).reduce(\n (out, unit) => {\n out[`custom#${unit.generic}:unit:${unit.id}`] = {\n data: {\n [acv]: unit.values[acv],\n },\n properties: {\n [constGenericsEditor.userConfigProperty]: {\n editor: {\n data: { [acv]: unit.values[acv] },\n },\n },\n [constGenericsEditor.infoDataProperty]: {\n editor: {\n data: { title: unit.title },\n },\n },\n },\n };\n return out;\n },\n {} as Record<string, any>,\n );\n\n const eSignComponentRecipients = {\n properties: {\n eSignRecipient: {\n editor: {\n data: {\n options: eSignRecipients?.map(item => ({\n label: item.displayName,\n value: item.name,\n })),\n },\n },\n },\n eSignFieldType: {\n editor: {\n data: {\n options: eSignTypeMapping,\n },\n },\n },\n },\n };\n\n const result = (window as any).unlayer.createEditor({\n displayMode: 'web',\n devices: ['desktop'],\n features: {\n preview: true,\n userUploads: false,\n stockImages: false,\n textEditor: {\n tables: true,\n },\n },\n mergeTags: mergeTags?.reduce(\n (out, tag) => {\n out[tag.id] = { name: tag.name, value: tag.propertyPath };\n\n return out;\n },\n {} as Record<string, { name: string; value: string }>,\n ),\n projectId: 5713,\n version: latest ? undefined : versions.unlayer,\n appearance: {\n theme: 'classic_light',\n },\n tools: {\n 'carousel': { enabled: false },\n 'button': { enabled: false },\n 'html': {\n enabled: enableHTMLEditing,\n properties: {\n html: {\n editor: {\n widgetParams: {\n codeMirrorOptions: {\n readOnly: enableHTMLEditingReadonly,\n },\n },\n },\n },\n },\n },\n 'table': {\n enabled: true,\n },\n 'menu': { enabled: false },\n 'form': { enabled: false },\n ...(noCoreTools\n ? {\n columns: { enabled: false },\n text: { enabled: false },\n heading: { enabled: false },\n divider: { enabled: false },\n image: { enabled: false },\n }\n : {}),\n ...unitsConfig,\n 'custom#e-sign': eSignComponentRecipients,\n },\n editor: {\n autoSelectOnDrop: true,\n },\n customJS: customScripts,\n customCSS: customStyles,\n id,\n fonts: {\n showDefaultFonts: false,\n customFonts: unlayerSupportedFonts,\n },\n tabs: {\n content: {},\n body: {},\n blocks: { enabled: false },\n },\n });\n\n document.getElementById = currentFind;\n\n result.registerCallback(\n 'displayCondition',\n function (data: any, done: (condition: any) => void) {\n emitDisplayCondition({ data, done });\n },\n );\n\n return result;\n};\n"],"names":["emitDisplayCondition","editorCoreScript","editorCoreStyles","editorCoreTools","constGenericsEditor","unlayerSupportedFonts","unlayerCustomEmptyToolState","unlayerCustomToolMetaData","unlayerCustomToolsGetRegisterUrls","DesignUpdatedEventType","versions","unlayer","schema","handlePreselectTool","preselectToolSlug","hideUnlayerContentsControls","hideUnlayerBodyMenuItem","injectEditorCoreStyles","cssText","trim","JSON","stringify","hideMobileTabletPreview","hideUnlayerTools","createUnlayerEditor","container","customCSS","customJS","eSignFieldTypes","eSignRecipients","enableHTMLEditing","enableHTMLEditingReadonly","hideAllTools","hideBodyMenuItem","hideContentControls","latest","mergeTags","noCoreTools","tools","units","customScripts","Array","isArray","filter","js","customStyles","css","id","currentFind","document","getElementById","elementId","call","acv","adminConfigProperty","eSignTypeMapping","map","key","label","value","charAt","toLowerCase","replace","slice","unitsConfig","reduce","out","unit","generic","data","values","properties","userConfigProperty","editor","infoDataProperty","title","eSignComponentRecipients","eSignRecipient","options","item","displayName","name","eSignFieldType","result","window","createEditor","displayMode","devices","features","preview","userUploads","stockImages","textEditor","tables","tag","propertyPath","projectId","version","undefined","appearance","theme","enabled","html","widgetParams","codeMirrorOptions","readOnly","columns","text","heading","divider","image","autoSelectOnDrop","fonts","showDefaultFonts","customFonts","tabs","content","body","blocks","registerCallback","done"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,kDAAkD;AACvF,SAASC,gBAAgB,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,gBAAgB;AACpF,SAASC,mBAAmB,QAAQ,iBAAiB;AACrD,SAASC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ACJA,SAASvE;gBACTyC,YAAY;oBACR+B,MAAM;wBACF7B,QAAQ;4BACJ8B,cAAc;gCACVC,mBAAmB;oCACfC,UAAU1E;gCACd;4BACJ;wBACJ;oBACJ;gBACJ;YACJ;YACA,SAAS;gBACLsE,SAAS;YACb;YACA,QAAQ;gBAAEA,SAAS;YAAM;YACzB,QAAQ;gBAAEA,SAAS;YAAM;YACzB,GAAIhE,cACE;gBACIqE,SAAS;oBAAEL,SAAS;gBAAM;gBAC1BM,MAAM;oBAAEN,SAAS;gBAAM;gBACvBO,SAAS;oBAAEP,SAAS;gBAAM;gBAC1BQ,SAAS;oBAAER,SAAS;gBAAM;gBAC1BS,OAAO;oBAAET,SAAS;gBAAM;YAC5B,IACA,CAAC,CAAC;YACR,GAAGrC,WAAW;YACd,iBAAiBY;QACrB;QACAH,QAAQ;YACJsC,kBAAkB;QACtB;QACApF,UAAUa;QACVd,WAAWmB;QACXE;QACAiE,OAAO;YACHC,kBAAkB;YAClBC,aAAa7G;QACjB;QACA8G,MAAM;YACFC,SAAS,CAAC;YACVC,MAAM,CAAC;YACPC,QAAQ;gBAAEjB,SAAS;YAAM;QAC7B;IACJ;IAEApD,SAASC,cAAc,GAAGF;IAE1BmC,OAAOoC,gBAAgB,CACnB,oBACA,SAAUlD,IAAS,EAAEmD,IAA8B;QAC/CxH,qBAAqB;YAAEqE;YAAMmD;QAAK;IACtC;IAGJ,OAAOrC;AACX,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/dte-unlayer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -15,5 +15,7 @@
|
|
|
15
15
|
"cli": {
|
|
16
16
|
"webpack": false
|
|
17
17
|
},
|
|
18
|
-
"peerDependencies": {
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@servicetitan/anvil2": "^2.0.2"
|
|
20
|
+
}
|
|
19
21
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Button, Flex, SegmentedControl, Text } from '@servicetitan/anvil2';
|
|
2
|
+
import PlusIcon from '@servicetitan/anvil2/assets/icons/material/round/add.svg';
|
|
3
|
+
import TrashIcon from '@servicetitan/anvil2/assets/icons/material/round/delete.svg';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { ConditionRow } from './ConditionRow';
|
|
6
|
+
import { defaultCondition } from './constants';
|
|
7
|
+
import { ConditionGroup as ConditionGroupType, LogicalOperator, SingleCondition } from './types';
|
|
8
|
+
import type { DataPointOption } from './types';
|
|
9
|
+
|
|
10
|
+
export interface ConditionGroupProps {
|
|
11
|
+
canDelete: boolean;
|
|
12
|
+
dataPointOptions: DataPointOption[];
|
|
13
|
+
group: ConditionGroupType;
|
|
14
|
+
onDelete: () => void;
|
|
15
|
+
onUpdate: (g: ConditionGroupType) => void;
|
|
16
|
+
ruleIndex: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function ConditionGroup({
|
|
20
|
+
canDelete,
|
|
21
|
+
dataPointOptions,
|
|
22
|
+
group,
|
|
23
|
+
onDelete,
|
|
24
|
+
onUpdate,
|
|
25
|
+
ruleIndex,
|
|
26
|
+
}: Readonly<ConditionGroupProps>) {
|
|
27
|
+
const addCondition = useCallback(() => {
|
|
28
|
+
const newCondition: SingleCondition = {
|
|
29
|
+
...defaultCondition(),
|
|
30
|
+
logicalOperator: 'and',
|
|
31
|
+
};
|
|
32
|
+
onUpdate({
|
|
33
|
+
...group,
|
|
34
|
+
conditions: [...group.conditions, newCondition],
|
|
35
|
+
});
|
|
36
|
+
}, [group, onUpdate]);
|
|
37
|
+
|
|
38
|
+
const updateCondition = useCallback(
|
|
39
|
+
(index: number, c: SingleCondition) => {
|
|
40
|
+
const next = [...group.conditions];
|
|
41
|
+
next[index] = c;
|
|
42
|
+
onUpdate({ ...group, conditions: next });
|
|
43
|
+
},
|
|
44
|
+
[group, onUpdate],
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const removeCondition = useCallback(
|
|
48
|
+
(index: number) => {
|
|
49
|
+
let next = group.conditions.filter((_, i) => i !== index);
|
|
50
|
+
// If we removed the first condition, clear logicalOperator on the new first
|
|
51
|
+
if (index === 0 && next.length > 0) {
|
|
52
|
+
const { logicalOperator: unusedOp, ...rest } = next[0];
|
|
53
|
+
next = [rest as SingleCondition, ...next.slice(1)];
|
|
54
|
+
}
|
|
55
|
+
onUpdate({
|
|
56
|
+
...group,
|
|
57
|
+
conditions: next.length ? next : [defaultCondition()],
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
[group, onUpdate],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const handleLogicalOperatorChange = useCallback(
|
|
64
|
+
(conditionIndex: number, value: string) => {
|
|
65
|
+
const next = [...group.conditions];
|
|
66
|
+
next[conditionIndex] = {
|
|
67
|
+
...next[conditionIndex],
|
|
68
|
+
logicalOperator: value as LogicalOperator,
|
|
69
|
+
};
|
|
70
|
+
onUpdate({ ...group, conditions: next });
|
|
71
|
+
},
|
|
72
|
+
[group, onUpdate],
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Flex direction="column" gap="2" style={{ width: '100%' }}>
|
|
77
|
+
<Flex
|
|
78
|
+
direction="row"
|
|
79
|
+
alignItems="center"
|
|
80
|
+
justifyContent="space-between"
|
|
81
|
+
style={{ width: '100%' }}
|
|
82
|
+
>
|
|
83
|
+
<Text size="medium" variant="body" style={{ fontWeight: 'bold' }}>
|
|
84
|
+
Rule {ruleIndex + 1}
|
|
85
|
+
</Text>
|
|
86
|
+
{canDelete && (
|
|
87
|
+
<Button
|
|
88
|
+
appearance="ghost"
|
|
89
|
+
aria-label="Delete rule"
|
|
90
|
+
icon={{ before: TrashIcon }}
|
|
91
|
+
size="large"
|
|
92
|
+
onClick={onDelete}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
</Flex>
|
|
96
|
+
<Flex
|
|
97
|
+
direction="column"
|
|
98
|
+
gap="3"
|
|
99
|
+
style={{
|
|
100
|
+
backgroundColor: '#fff',
|
|
101
|
+
border: '1px solid #e0e0e0',
|
|
102
|
+
borderRadius: 8,
|
|
103
|
+
padding: 12,
|
|
104
|
+
width: '100%',
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
{group.conditions.map((c, i) => (
|
|
108
|
+
<Flex key={c.id} direction="column" gap="3" style={{ padding: '8px 0' }}>
|
|
109
|
+
{i > 0 && (
|
|
110
|
+
<Flex justifyContent="center" alignItems="center" gap="2">
|
|
111
|
+
<SegmentedControl
|
|
112
|
+
selected={c.logicalOperator ?? 'and'}
|
|
113
|
+
onChange={(v: string) => handleLogicalOperatorChange(i, v)}
|
|
114
|
+
>
|
|
115
|
+
<SegmentedControl.Segment value="and">
|
|
116
|
+
And
|
|
117
|
+
</SegmentedControl.Segment>
|
|
118
|
+
<SegmentedControl.Segment value="or">
|
|
119
|
+
Or
|
|
120
|
+
</SegmentedControl.Segment>
|
|
121
|
+
</SegmentedControl>
|
|
122
|
+
</Flex>
|
|
123
|
+
)}
|
|
124
|
+
<ConditionRow
|
|
125
|
+
canRemove
|
|
126
|
+
condition={c}
|
|
127
|
+
dataPointOptions={dataPointOptions}
|
|
128
|
+
onChange={next => updateCondition(i, next)}
|
|
129
|
+
onRemove={() => removeCondition(i)}
|
|
130
|
+
/>
|
|
131
|
+
</Flex>
|
|
132
|
+
))}
|
|
133
|
+
<Flex justifyContent="center" style={{ paddingTop: 8, width: '100%' }}>
|
|
134
|
+
<Button
|
|
135
|
+
appearance="secondary"
|
|
136
|
+
icon={{ before: PlusIcon }}
|
|
137
|
+
onClick={addCondition}
|
|
138
|
+
>
|
|
139
|
+
Add Condition
|
|
140
|
+
</Button>
|
|
141
|
+
</Flex>
|
|
142
|
+
</Flex>
|
|
143
|
+
</Flex>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Button, Flex, SegmentedControl } from '@servicetitan/anvil2';
|
|
2
|
+
import PlusIcon from '@servicetitan/anvil2/assets/icons/material/round/add.svg';
|
|
3
|
+
import { ConditionGroup } from './ConditionGroup';
|
|
4
|
+
import { ConditionGroup as ConditionGroupType, LogicalOperator } from './types';
|
|
5
|
+
import type { DataPointOption } from './types';
|
|
6
|
+
|
|
7
|
+
export interface ConditionGroupsSectionProps {
|
|
8
|
+
dataPointOptions: DataPointOption[];
|
|
9
|
+
groups: ConditionGroupType[];
|
|
10
|
+
onAddGroup: () => void;
|
|
11
|
+
onRemoveGroup: (index: number) => void;
|
|
12
|
+
onUpdateGroup: (index: number, group: ConditionGroupType) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function ConditionGroupsSection({
|
|
16
|
+
dataPointOptions,
|
|
17
|
+
groups,
|
|
18
|
+
onAddGroup,
|
|
19
|
+
onRemoveGroup,
|
|
20
|
+
onUpdateGroup,
|
|
21
|
+
}: Readonly<ConditionGroupsSectionProps>) {
|
|
22
|
+
return (
|
|
23
|
+
<Flex direction="column" gap="4">
|
|
24
|
+
{groups.map((group, index) => (
|
|
25
|
+
<Flex key={group.id} direction="column" gap="3">
|
|
26
|
+
{index > 0 && (
|
|
27
|
+
<Flex
|
|
28
|
+
justifyContent="center"
|
|
29
|
+
alignItems="center"
|
|
30
|
+
gap="2"
|
|
31
|
+
style={{ padding: '12px' }}
|
|
32
|
+
>
|
|
33
|
+
<SegmentedControl
|
|
34
|
+
selected={group.logicalOperator ?? 'and'}
|
|
35
|
+
onChange={(value: string) =>
|
|
36
|
+
onUpdateGroup(index, {
|
|
37
|
+
...group,
|
|
38
|
+
logicalOperator: value as LogicalOperator,
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
>
|
|
42
|
+
<SegmentedControl.Segment value="and">And</SegmentedControl.Segment>
|
|
43
|
+
<SegmentedControl.Segment value="or">Or</SegmentedControl.Segment>
|
|
44
|
+
</SegmentedControl>
|
|
45
|
+
</Flex>
|
|
46
|
+
)}
|
|
47
|
+
<ConditionGroup
|
|
48
|
+
canDelete={groups.length > 1}
|
|
49
|
+
dataPointOptions={dataPointOptions}
|
|
50
|
+
group={group}
|
|
51
|
+
onDelete={() => onRemoveGroup(index)}
|
|
52
|
+
onUpdate={g => onUpdateGroup(index, g)}
|
|
53
|
+
ruleIndex={index}
|
|
54
|
+
/>
|
|
55
|
+
</Flex>
|
|
56
|
+
))}
|
|
57
|
+
<Flex justifyContent="center" style={{ paddingTop: 8, width: '100%' }}>
|
|
58
|
+
<Button appearance="secondary" icon={{ before: PlusIcon }} onClick={onAddGroup}>
|
|
59
|
+
Add Rule
|
|
60
|
+
</Button>
|
|
61
|
+
</Flex>
|
|
62
|
+
</Flex>
|
|
63
|
+
);
|
|
64
|
+
}
|