@servicetitan/dte-unlayer 0.110.0 → 0.112.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 +1 -4
- package/dist/display-conditions/ConditionGroup.d.ts.map +1 -1
- package/dist/display-conditions/ConditionGroup.js +38 -115
- package/dist/display-conditions/ConditionGroup.js.map +1 -1
- package/dist/display-conditions/ConditionGroupsSection.d.ts +6 -3
- package/dist/display-conditions/ConditionGroupsSection.d.ts.map +1 -1
- package/dist/display-conditions/ConditionGroupsSection.js +62 -57
- package/dist/display-conditions/ConditionGroupsSection.js.map +1 -1
- package/dist/display-conditions/ConditionRow.d.ts.map +1 -1
- package/dist/display-conditions/ConditionRow.js +15 -11
- package/dist/display-conditions/ConditionRow.js.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.d.ts.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.js +86 -115
- 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 +11 -3
- package/dist/display-conditions/nunjucks.js.map +1 -1
- package/dist/editor.js +1 -1
- package/dist/editor.js.map +1 -1
- package/dist/unlayer-interface.d.ts +1 -0
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer-interface.js.map +1 -1
- package/dist/unlayer.d.ts +1 -1
- package/dist/unlayer.d.ts.map +1 -1
- package/dist/unlayer.js +8 -6
- package/dist/unlayer.js.map +1 -1
- package/package.json +1 -1
- package/src/display-conditions/ConditionGroup.tsx +5 -68
- package/src/display-conditions/ConditionGroupsSection.tsx +41 -44
- package/src/display-conditions/ConditionRow.tsx +18 -8
- package/src/display-conditions/DisplayConditionModal.tsx +101 -92
- package/src/display-conditions/nunjucks.ts +13 -2
- package/src/editor.tsx +1 -1
- package/src/unlayer-interface.tsx +1 -0
- package/src/unlayer.tsx +9 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/unlayer-interface.tsx"],"sourcesContent":["import {\n UnlayerEditorESignRecipientInfo,\n UnlayerEditorTwin,\n UnlayerEditorUnit,\n} from './shared/const';\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}\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 enableHTMLEditing?: boolean;\n enableHTMLEditingReadonly?: boolean;\n imageValidation?: {\n maxWidth?: number;\n maxHeight?: number;\n maxFileSize?: number;\n };\n holidays?: string[];\n}\n"],"names":[],"mappings":"AA0DA,
|
|
1
|
+
{"version":3,"sources":["../src/unlayer-interface.tsx"],"sourcesContent":["import {\n UnlayerEditorESignRecipientInfo,\n UnlayerEditorTwin,\n UnlayerEditorUnit,\n} from './shared/const';\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}\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}\n"],"names":[],"mappings":"AA0DA,WA8BC"}
|
package/dist/unlayer.d.ts
CHANGED
|
@@ -58,5 +58,5 @@ export declare const hideUnlayerContentsControls: () => string;
|
|
|
58
58
|
export declare const hideUnlayerBodyMenuItem: () => string;
|
|
59
59
|
export declare const hideMobileTabletPreview: () => string;
|
|
60
60
|
export declare const hideUnlayerTools: () => string;
|
|
61
|
-
export declare const createUnlayerEditor: (container: HTMLDivElement, { customCSS, customJS, eSignFieldTypes, eSignRecipients, enableHTMLEditing, enableHTMLEditingReadonly, hideAllTools, hideBodyMenuItem, hideContentControls, latest, mergeTags, noCoreTools, tools, units, }: CreateUnlayerEditorProps) => Unlayer;
|
|
61
|
+
export declare const createUnlayerEditor: (container: HTMLDivElement, { customCSS, customJS, displayConditions, eSignFieldTypes, eSignRecipients, enableHTMLEditing, enableHTMLEditingReadonly, hideAllTools, hideBodyMenuItem, hideContentControls, latest, mergeTags, noCoreTools, tools, units, }: CreateUnlayerEditorProps) => Unlayer;
|
|
62
62
|
//# sourceMappingURL=unlayer.d.ts.map
|
package/dist/unlayer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,WAAW,OAAO;IACpB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC;IAC9D,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE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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,gOAgBG,wBAAwB,KAC5B,OAoLF,CAAC"}
|
package/dist/unlayer.js
CHANGED
|
@@ -116,7 +116,7 @@ export const hideUnlayerTools = ()=>{
|
|
|
116
116
|
}
|
|
117
117
|
`;
|
|
118
118
|
};
|
|
119
|
-
export const createUnlayerEditor = (container, { customCSS, customJS, eSignFieldTypes, eSignRecipients, enableHTMLEditing, enableHTMLEditingReadonly, hideAllTools, hideBodyMenuItem, hideContentControls, latest, mergeTags, noCoreTools, tools, units })=>{
|
|
119
|
+
export const createUnlayerEditor = (container, { customCSS, customJS, displayConditions, eSignFieldTypes, eSignRecipients, enableHTMLEditing, enableHTMLEditingReadonly, hideAllTools, hideBodyMenuItem, hideContentControls, latest, mergeTags, noCoreTools, tools, units })=>{
|
|
120
120
|
const customScripts = [
|
|
121
121
|
editorCoreScript,
|
|
122
122
|
editorCoreTools,
|
|
@@ -299,12 +299,14 @@ export const createUnlayerEditor = (container, { customCSS, customJS, eSignField
|
|
|
299
299
|
}
|
|
300
300
|
});
|
|
301
301
|
document.getElementById = currentFind;
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
302
|
+
if (displayConditions) {
|
|
303
|
+
result.registerCallback('displayCondition', function(data, done) {
|
|
304
|
+
emitDisplayCondition({
|
|
305
|
+
data,
|
|
306
|
+
done
|
|
307
|
+
});
|
|
306
308
|
});
|
|
307
|
-
}
|
|
309
|
+
}
|
|
308
310
|
return result;
|
|
309
311
|
};
|
|
310
312
|
|
package/dist/unlayer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,qBAAqB,QAAQ,iBAAiB;AACvD,SACIC,2BAA2B,EAC3BC,yBAAyB,EACzBC,iCAAiC,QAC9B,UAAU;AAyBjB,OAAO,IAAA,AAAKC,gDAAAA;;;;;;;;;;;;;WAAAA;MAaX;AAWD;;;;;CAKC,GACD,OAAO,MAAMC,WA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A,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"}
|
|
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 displayConditions,\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 if (displayConditions) {\n result.registerCallback(\n 'displayCondition',\n function (data: any, done: (condition: any) => void) {\n emitDisplayCondition({ data, done });\n },\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","displayConditions","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,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,CAAC;AACL,EAAE;AAEF,OAAO,MAAMC,0BAA0B;IACnC,OAAO,CAAC;;;;IAIR,CAAC;AACL,EAAE;AAEF,MAAMC,yBAAyB;IAC3B,MAAMC,UAAUhB,6BAAAA,uCAAAA,iBAAkBiB,IAAI;IAEtC,IAAI,CAACD,SAAS;QACV,OAAO;IACX;IAEA,OAAO,CAAC;;sBAEU,EAAEE,KAAKC,SAAS,CAACH,SAAS;;;;;;;;;;;IAW5C,CAAC;AACL;AAEA,OAAO,MAAMI,0BAA0B,IAAM,CAAC;;;;;;;;AAQ9C,CAAC,CAAC;AACF,OAAO,MAAMC,mBAAmB;IAC5B,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+BR,CAAC;AACL,EAAE;AAEF,OAAO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AAEsE;gBAAMmD;YAAK;QACtC;IAER;IAEA,OAAOrC;AACX,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
import { Button, Flex
|
|
1
|
+
import { Button, Flex } from '@servicetitan/anvil2';
|
|
2
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
3
|
import { useCallback } from 'react';
|
|
5
4
|
import { ConditionRow } from './ConditionRow';
|
|
6
5
|
import { defaultCondition } from './constants';
|
|
7
|
-
import { ConditionGroup as ConditionGroupType,
|
|
6
|
+
import { ConditionGroup as ConditionGroupType, SingleCondition } from './types';
|
|
8
7
|
import type { DataPointOption } from './types';
|
|
9
8
|
|
|
10
9
|
export interface ConditionGroupProps {
|
|
11
|
-
canDelete: boolean;
|
|
12
10
|
dataPointOptions: DataPointOption[];
|
|
13
11
|
group: ConditionGroupType;
|
|
14
|
-
onDelete: () => void;
|
|
15
12
|
onUpdate: (g: ConditionGroupType) => void;
|
|
16
|
-
ruleIndex: number;
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
export function ConditionGroup({
|
|
20
|
-
canDelete,
|
|
21
16
|
dataPointOptions,
|
|
22
17
|
group,
|
|
23
|
-
onDelete,
|
|
24
18
|
onUpdate,
|
|
25
|
-
ruleIndex,
|
|
26
19
|
}: Readonly<ConditionGroupProps>) {
|
|
27
20
|
const addCondition = useCallback(() => {
|
|
28
21
|
const newCondition: SingleCondition = {
|
|
@@ -47,9 +40,8 @@ export function ConditionGroup({
|
|
|
47
40
|
const removeCondition = useCallback(
|
|
48
41
|
(index: number) => {
|
|
49
42
|
let next = group.conditions.filter((_, i) => i !== index);
|
|
50
|
-
// If we removed the first condition, clear logicalOperator on the new first
|
|
51
43
|
if (index === 0 && next.length > 0) {
|
|
52
|
-
const { logicalOperator:
|
|
44
|
+
const { logicalOperator: _unusedOp, ...rest } = next[0];
|
|
53
45
|
next = [rest as SingleCondition, ...next.slice(1)];
|
|
54
46
|
}
|
|
55
47
|
onUpdate({
|
|
@@ -60,67 +52,11 @@ export function ConditionGroup({
|
|
|
60
52
|
[group, onUpdate],
|
|
61
53
|
);
|
|
62
54
|
|
|
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
55
|
return (
|
|
76
56
|
<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
|
-
>
|
|
57
|
+
<Flex direction="column" gap="3" style={{ width: '100%' }}>
|
|
107
58
|
{group.conditions.map((c, i) => (
|
|
108
59
|
<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
60
|
<ConditionRow
|
|
125
61
|
canRemove
|
|
126
62
|
condition={c}
|
|
@@ -134,6 +70,7 @@ export function ConditionGroup({
|
|
|
134
70
|
<Button
|
|
135
71
|
appearance="secondary"
|
|
136
72
|
icon={{ before: PlusIcon }}
|
|
73
|
+
size="small"
|
|
137
74
|
onClick={addCondition}
|
|
138
75
|
>
|
|
139
76
|
Add Condition
|
|
@@ -1,64 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Chip, Flex, SegmentedControl, Text } from '@servicetitan/anvil2';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
3
|
import { ConditionGroup } from './ConditionGroup';
|
|
4
|
-
import { ConditionGroup as ConditionGroupType
|
|
4
|
+
import { ConditionGroup as ConditionGroupType } from './types';
|
|
5
5
|
import type { DataPointOption } from './types';
|
|
6
6
|
|
|
7
|
+
export type MatchType = 'all' | 'any';
|
|
8
|
+
|
|
7
9
|
export interface ConditionGroupsSectionProps {
|
|
10
|
+
behaviorSection?: ReactNode;
|
|
8
11
|
dataPointOptions: DataPointOption[];
|
|
9
12
|
groups: ConditionGroupType[];
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
matchType: MatchType;
|
|
14
|
+
onMatchTypeChange: (matchType: MatchType) => void;
|
|
12
15
|
onUpdateGroup: (index: number, group: ConditionGroupType) => void;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export function ConditionGroupsSection({
|
|
19
|
+
behaviorSection,
|
|
16
20
|
dataPointOptions,
|
|
17
21
|
groups,
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
matchType,
|
|
23
|
+
onMatchTypeChange,
|
|
20
24
|
onUpdateGroup,
|
|
21
25
|
}: Readonly<ConditionGroupsSectionProps>) {
|
|
26
|
+
const firstGroup = groups[0];
|
|
27
|
+
if (!firstGroup) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
return (
|
|
23
32
|
<Flex direction="column" gap="4">
|
|
24
|
-
{
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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>
|
|
33
|
+
<Flex direction="row" alignItems="center" gap="1" style={{ flexWrap: 'wrap' }}>
|
|
34
|
+
<Text size="small" variant="body" style={{ fontWeight: 'bold' }}>
|
|
35
|
+
When
|
|
36
|
+
</Text>
|
|
37
|
+
<SegmentedControl
|
|
38
|
+
selected={matchType}
|
|
39
|
+
size="small"
|
|
40
|
+
onChange={(value: string) => onMatchTypeChange(value as MatchType)}
|
|
41
|
+
>
|
|
42
|
+
<SegmentedControl.Segment value="all">All</SegmentedControl.Segment>
|
|
43
|
+
<SegmentedControl.Segment value="any">Any</SegmentedControl.Segment>
|
|
44
|
+
</SegmentedControl>
|
|
45
|
+
<Text size="small" variant="body" style={{ fontWeight: 'bold' }}>
|
|
46
|
+
of the
|
|
47
|
+
</Text>
|
|
48
|
+
<Chip label="IF" size="small" />
|
|
49
|
+
<Text size="small" variant="body" style={{ fontWeight: 'bold' }}>
|
|
50
|
+
conditions are met
|
|
51
|
+
</Text>
|
|
61
52
|
</Flex>
|
|
53
|
+
{behaviorSection}
|
|
54
|
+
<ConditionGroup
|
|
55
|
+
dataPointOptions={dataPointOptions}
|
|
56
|
+
group={firstGroup}
|
|
57
|
+
onUpdate={g => onUpdateGroup(0, g)}
|
|
58
|
+
/>
|
|
62
59
|
</Flex>
|
|
63
60
|
);
|
|
64
61
|
}
|
|
@@ -94,12 +94,12 @@ export function ConditionRow({
|
|
|
94
94
|
display: 'flex',
|
|
95
95
|
alignItems: 'flex-end',
|
|
96
96
|
flexShrink: 0,
|
|
97
|
-
padding: '
|
|
97
|
+
padding: '4px 8px',
|
|
98
98
|
}}
|
|
99
99
|
>
|
|
100
|
-
<Chip label="IF" size="
|
|
100
|
+
<Chip label="IF" size="small" />
|
|
101
101
|
</div>
|
|
102
|
-
<div style={{ flex: '2 1
|
|
102
|
+
<div style={{ flex: '2 1 240px', minWidth: 200 }}>
|
|
103
103
|
<Combobox
|
|
104
104
|
{...({ disableClearSelection: true } as object)}
|
|
105
105
|
groupBy="group"
|
|
@@ -109,7 +109,11 @@ export function ConditionRow({
|
|
|
109
109
|
selectedItem={selectedDataPoint}
|
|
110
110
|
onChange={handleDataPointChange}
|
|
111
111
|
>
|
|
112
|
-
<Combobox.SelectTrigger
|
|
112
|
+
<Combobox.SelectTrigger
|
|
113
|
+
label="Data point"
|
|
114
|
+
placeholder="Select data point..."
|
|
115
|
+
size="small"
|
|
116
|
+
/>
|
|
113
117
|
<Combobox.Content>
|
|
114
118
|
{({ items }: { items: DataPointOption[] }) => (
|
|
115
119
|
<Combobox.List>
|
|
@@ -123,7 +127,7 @@ export function ConditionRow({
|
|
|
123
127
|
</Combobox.Content>
|
|
124
128
|
</Combobox>
|
|
125
129
|
</div>
|
|
126
|
-
<div style={{ flex: '1 1
|
|
130
|
+
<div style={{ flex: '1 1 180px', minWidth: 150 }}>
|
|
127
131
|
<Combobox
|
|
128
132
|
{...({ disableClearSelection: true } as object)}
|
|
129
133
|
itemToKey={(item: OperatorOption | null) => item?.value ?? ''}
|
|
@@ -137,7 +141,11 @@ export function ConditionRow({
|
|
|
137
141
|
})
|
|
138
142
|
}
|
|
139
143
|
>
|
|
140
|
-
<Combobox.SelectTrigger
|
|
144
|
+
<Combobox.SelectTrigger
|
|
145
|
+
label="Condition"
|
|
146
|
+
placeholder="Select..."
|
|
147
|
+
size="small"
|
|
148
|
+
/>
|
|
141
149
|
<Combobox.Content>
|
|
142
150
|
{({ items }: { items: OperatorOption[] }) => (
|
|
143
151
|
<Combobox.List>
|
|
@@ -152,9 +160,10 @@ export function ConditionRow({
|
|
|
152
160
|
</Combobox>
|
|
153
161
|
</div>
|
|
154
162
|
{!isValueLess && (
|
|
155
|
-
<div style={{ flex: '1 1
|
|
163
|
+
<div style={{ flex: '1 1 180px', minWidth: 150 }}>
|
|
156
164
|
<TextField
|
|
157
165
|
label="Value"
|
|
166
|
+
size="small"
|
|
158
167
|
value={condition.value}
|
|
159
168
|
onChange={e => handleValueChange(e.target.value)}
|
|
160
169
|
placeholder={fieldType === 'number' ? 'e.g. 1.5' : 'Enter value...'}
|
|
@@ -170,13 +179,14 @@ export function ConditionRow({
|
|
|
170
179
|
display: 'flex',
|
|
171
180
|
alignItems: 'flex-end',
|
|
172
181
|
flexShrink: 0,
|
|
173
|
-
padding: '
|
|
182
|
+
padding: '4px 8px',
|
|
174
183
|
}}
|
|
175
184
|
>
|
|
176
185
|
<Button
|
|
177
186
|
appearance="secondary"
|
|
178
187
|
aria-label="Remove condition"
|
|
179
188
|
icon={{ before: TrashIcon }}
|
|
189
|
+
size="small"
|
|
180
190
|
onClick={onRemove}
|
|
181
191
|
/>
|
|
182
192
|
</div>
|