@servicetitan/dte-unlayer 0.149.0 → 0.151.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 -1
- package/dist/display-conditions/ConditionGroup.d.ts.map +1 -1
- package/dist/display-conditions/ConditionGroupsSection.d.ts +1 -1
- package/dist/display-conditions/ConditionGroupsSection.d.ts.map +1 -1
- package/dist/display-conditions/ConditionRow.d.ts +1 -1
- package/dist/display-conditions/ConditionRow.d.ts.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.d.ts +4 -3
- package/dist/display-conditions/DisplayConditionModal.d.ts.map +1 -1
- package/dist/display-conditions/DisplayConditionModal.js +112 -137
- package/dist/display-conditions/DisplayConditionModal.js.map +1 -1
- package/dist/display-conditions/LookupValueControl.d.ts +1 -1
- package/dist/display-conditions/LookupValueControl.d.ts.map +1 -1
- package/dist/display-conditions/SeparatorWithChip.d.ts +1 -1
- package/dist/display-conditions/SeparatorWithChip.d.ts.map +1 -1
- package/dist/editor-core-source.d.ts +3 -3
- package/dist/editor-core-source.d.ts.map +1 -1
- package/dist/editor-core-source.js +3 -3
- package/dist/editor-core-source.js.map +1 -1
- package/dist/unlayer-interface.d.ts +5 -1
- package/dist/unlayer-interface.d.ts.map +1 -1
- package/dist/unlayer-interface.js.map +1 -1
- package/package.json +1 -1
- package/src/display-conditions/DisplayConditionModal.tsx +110 -156
- package/src/editor-core-source.ts +3 -3
- package/src/unlayer-interface.tsx +5 -1
|
@@ -72,7 +72,11 @@ export interface CreateUnlayerEditorProps {
|
|
|
72
72
|
hideContentControls?: boolean;
|
|
73
73
|
hideBodyMenuItem?: boolean;
|
|
74
74
|
displayConditions?: boolean;
|
|
75
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Optional portal target for the display-conditions dialog. Prefer unset so the dialog
|
|
77
|
+
* stays under the host `AnvilProvider` (`.anvil2` CSS scope). When set, content is wrapped
|
|
78
|
+
* in `ThemeProvider` so Anvil2 styles still apply after portaling.
|
|
79
|
+
*/
|
|
76
80
|
displayConditionModalPortalContainer?: Element | DocumentFragment | null;
|
|
77
81
|
enableHTMLEditing?: boolean;
|
|
78
82
|
enableHTMLEditingReadonly?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlayer-interface.d.ts","sourceRoot":"","sources":["../src/unlayer-interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,+BAA+B,EAC/B,iBAAiB,EACjB,iBAAiB,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;CACf;AACD,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAC9D,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE;QACF,IAAI,EAAE;YACF,KAAK,EAAE,MAAM,EAAE,CAAC;YAChB,OAAO,EAAE;gBACL,QAAQ,EAAE,iBAAiB,EAAE,CAAC;gBAC9B,MAAM,CAAC,EAAE,GAAG,CAAC;aAChB,EAAE,CAAC;YACJ,MAAM,CAAC,EAAE,GAAG,CAAC;SAChB,EAAE,CAAC;QACJ,MAAM,CAAC,EAAE,GAAG,CAAC;KAChB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,mBAAmB,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,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,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAClD,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAClD,kBAAkB,CAAC,EAAE,CACjB,WAAW,EAAE,MAAM,EAAE,EACrB,YAAY,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,EACzC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,IAAI,KAChE,IAAI,CAAC;IACV,qBAAqB,CAAC,EAAE,CACpB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,IAAI,KAChE,IAAI,CAAC;CACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/unlayer-interface.tsx"],"sourcesContent":["import {\n UnlayerEditorESignRecipientInfo,\n UnlayerEditorTwin,\n UnlayerEditorUnit,\n} from './shared/const';\nimport { FormFieldInfo, FormInfo } from './shared/forms';\nimport { SchemaObject } from './shared/schema';\n\nexport interface UnlayerDesignTool {\n type: string;\n slug?: string;\n values: any;\n}\nexport interface UnlayerDesignCustomTool extends UnlayerDesignTool {\n slug: string;\n}\n\nexport interface UnlayerDesignFormat {\n body: {\n rows: {\n cells: number[];\n columns: {\n contents: UnlayerDesignTool[];\n values?: any;\n }[];\n values?: any;\n }[];\n values?: any;\n };\n counters: Record<string, number>;\n schemaVersion: number;\n}\n\nexport interface UnlayerExport {\n html: string;\n chunks: any;\n design: UnlayerDesignFormat;\n demoData?: Record<string, unknown>;\n}\n\nexport interface UnlayerRef {\n loadDesign(design: any): void;\n saveDesign(cb: (design: any) => void): void;\n exportHtml(cb: (data: UnlayerExport) => void): void;\n sendFormList(forms: FormInfo[]): void;\n sendFormFields(formId: number, fields: FormFieldInfo[]): void;\n sendCalcFieldLabels(labels: Record<string, string>): void;\n}\n\nexport interface UnlayerEditorMergeTagInfo {\n id: string;\n name: string;\n propertyPath: string;\n}\n\nexport interface UnlayerEditorCustomTool {\n key: string;\n title: string;\n description?: string;\n url: string;\n groupUrl?: string;\n}\n\nexport interface CreateUnlayerEditorProps {\n tools: UnlayerEditorCustomTool[];\n newSnapshot?: UnlayerEditorTwin;\n toolTwins?: UnlayerEditorTwin[];\n isSnapshotMode?: boolean;\n dummyData?: any;\n schema?: SchemaObject;\n customCSS?: string | string[] | undefined;\n customJS?: string | string[] | undefined;\n mergeTags?: UnlayerEditorMergeTagInfo[] | undefined;\n eSignRecipients?: UnlayerEditorESignRecipientInfo[] | undefined;\n eSignFieldTypes?: string[] | undefined;\n genericConfigMode?: boolean;\n generics?: true | string[];\n units?: UnlayerEditorUnit[];\n noCoreTools?: boolean;\n latest?: boolean;\n blocks?: boolean;\n hideAllTools?: boolean;\n hideContentControls?: boolean;\n hideBodyMenuItem?: boolean;\n displayConditions?: boolean;\n
|
|
1
|
+
{"version":3,"sources":["../src/unlayer-interface.tsx"],"sourcesContent":["import {\n UnlayerEditorESignRecipientInfo,\n UnlayerEditorTwin,\n UnlayerEditorUnit,\n} from './shared/const';\nimport { FormFieldInfo, FormInfo } from './shared/forms';\nimport { SchemaObject } from './shared/schema';\n\nexport interface UnlayerDesignTool {\n type: string;\n slug?: string;\n values: any;\n}\nexport interface UnlayerDesignCustomTool extends UnlayerDesignTool {\n slug: string;\n}\n\nexport interface UnlayerDesignFormat {\n body: {\n rows: {\n cells: number[];\n columns: {\n contents: UnlayerDesignTool[];\n values?: any;\n }[];\n values?: any;\n }[];\n values?: any;\n };\n counters: Record<string, number>;\n schemaVersion: number;\n}\n\nexport interface UnlayerExport {\n html: string;\n chunks: any;\n design: UnlayerDesignFormat;\n demoData?: Record<string, unknown>;\n}\n\nexport interface UnlayerRef {\n loadDesign(design: any): void;\n saveDesign(cb: (design: any) => void): void;\n exportHtml(cb: (data: UnlayerExport) => void): void;\n sendFormList(forms: FormInfo[]): void;\n sendFormFields(formId: number, fields: FormFieldInfo[]): void;\n sendCalcFieldLabels(labels: Record<string, string>): void;\n}\n\nexport interface UnlayerEditorMergeTagInfo {\n id: string;\n name: string;\n propertyPath: string;\n}\n\nexport interface UnlayerEditorCustomTool {\n key: string;\n title: string;\n description?: string;\n url: string;\n groupUrl?: string;\n}\n\nexport interface CreateUnlayerEditorProps {\n tools: UnlayerEditorCustomTool[];\n newSnapshot?: UnlayerEditorTwin;\n toolTwins?: UnlayerEditorTwin[];\n isSnapshotMode?: boolean;\n dummyData?: any;\n schema?: SchemaObject;\n customCSS?: string | string[] | undefined;\n customJS?: string | string[] | undefined;\n mergeTags?: UnlayerEditorMergeTagInfo[] | undefined;\n eSignRecipients?: UnlayerEditorESignRecipientInfo[] | undefined;\n eSignFieldTypes?: string[] | undefined;\n genericConfigMode?: boolean;\n generics?: true | string[];\n units?: UnlayerEditorUnit[];\n noCoreTools?: boolean;\n latest?: boolean;\n blocks?: boolean;\n hideAllTools?: boolean;\n hideContentControls?: boolean;\n hideBodyMenuItem?: boolean;\n displayConditions?: boolean;\n /**\n * Optional portal target for the display-conditions dialog. Prefer unset so the dialog\n * stays under the host `AnvilProvider` (`.anvil2` CSS scope). When set, content is wrapped\n * in `ThemeProvider` so Anvil2 styles still apply after portaling.\n */\n displayConditionModalPortalContainer?: Element | DocumentFragment | null;\n enableHTMLEditing?: boolean;\n enableHTMLEditingReadonly?: boolean;\n imageValidation?: {\n maxWidth?: number;\n maxHeight?: number;\n maxFileSize?: number;\n };\n holidays?: string[];\n onFormSelect?: (formId: number) => void;\n onCalcFieldOpen?: (usedFormIds: number[]) => void;\n onCalcFieldSelect?: (fieldKeys: string[]) => void;\n onConditionalsOpen?: (\n usedFormIds: number[],\n sendFormList: (forms: FormInfo[]) => void,\n sendFormFields: (formId: number, fields: FormFieldInfo[]) => void,\n ) => void;\n onConditionFormSelect?: (\n formId: number,\n sendFormFields: (formId: number, fields: FormFieldInfo[]) => void,\n ) => void;\n}\n"],"names":[],"mappings":"AA+DA,WAgDC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import { Button, Combobox, Dialog, Flex, Text } from '@servicetitan/anvil2';
|
|
2
|
-
import {
|
|
3
|
-
Fragment,
|
|
4
|
-
useCallback,
|
|
5
|
-
useEffect,
|
|
6
|
-
useLayoutEffect,
|
|
7
|
-
useMemo,
|
|
8
|
-
useRef,
|
|
9
|
-
useState,
|
|
10
|
-
} from 'react';
|
|
1
|
+
import { Button, Combobox, Dialog, Flex, Text, ThemeProvider } from '@servicetitan/anvil2';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
11
3
|
import { createPortal } from 'react-dom';
|
|
12
4
|
import {
|
|
13
5
|
buildFormFieldKey,
|
|
@@ -36,15 +28,6 @@ const BEHAVIOR_OPTIONS = [
|
|
|
36
28
|
const NUMERIC_VALUE_RE = /^-?(?:\d+\.?\d*|\.\d+)$/;
|
|
37
29
|
type BehaviorOption = (typeof BEHAVIOR_OPTIONS)[number];
|
|
38
30
|
|
|
39
|
-
/** When the editor runs inside a shadow root (e.g. monolith MFE), portaling to `document.body` escapes the shadow tree and loses bundled styles. */
|
|
40
|
-
function resolveDisplayConditionPortalContainer(anchor: HTMLElement): Element | DocumentFragment {
|
|
41
|
-
const rootNode = anchor.getRootNode();
|
|
42
|
-
if (rootNode instanceof ShadowRoot) {
|
|
43
|
-
return rootNode;
|
|
44
|
-
}
|
|
45
|
-
return document.body;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
31
|
function deriveMatchType(conditionState: DisplayConditionState): MatchType {
|
|
49
32
|
const firstGroup = conditionState.groups[0];
|
|
50
33
|
if (!firstGroup || firstGroup.conditions.length <= 1) {
|
|
@@ -77,8 +60,9 @@ function applyMatchTypeToState(
|
|
|
77
60
|
|
|
78
61
|
export interface DisplayConditionModalProps {
|
|
79
62
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
63
|
+
* Optional portal target. Prefer leaving unset so the dialog stays under the host
|
|
64
|
+
* `AnvilProvider` (`.anvil2` CSS scope). When set (e.g. a host-controlled container),
|
|
65
|
+
* content is wrapped in `ThemeProvider` so Anvil2 styles still apply after portaling.
|
|
82
66
|
*/
|
|
83
67
|
portalContainer?: Element | DocumentFragment | null;
|
|
84
68
|
onConditionFormSelect?: (
|
|
@@ -171,22 +155,6 @@ export const DisplayConditionModal = (props: DisplayConditionModalProps) => {
|
|
|
171
155
|
[onConditionFormSelect],
|
|
172
156
|
);
|
|
173
157
|
|
|
174
|
-
const portalAnchorRef = useRef<HTMLSpanElement>(null);
|
|
175
|
-
const [resolvedPortalContainer, setResolvedPortalContainer] = useState<
|
|
176
|
-
Element | DocumentFragment | null
|
|
177
|
-
>(null);
|
|
178
|
-
|
|
179
|
-
useLayoutEffect(() => {
|
|
180
|
-
if (typeof document === 'undefined' || portalContainerProp !== undefined) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
const anchor = portalAnchorRef.current;
|
|
184
|
-
if (!anchor) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
setResolvedPortalContainer(resolveDisplayConditionPortalContainer(anchor));
|
|
188
|
-
}, [portalContainerProp]);
|
|
189
|
-
|
|
190
158
|
useEffect(() => {
|
|
191
159
|
return onDisplayCondition(nextRequest => {
|
|
192
160
|
setRequest(nextRequest);
|
|
@@ -310,127 +278,113 @@ export const DisplayConditionModal = (props: DisplayConditionModalProps) => {
|
|
|
310
278
|
return state.groups.length > 0;
|
|
311
279
|
}, [allFieldOptions, isFieldDataLoading, state.groups]);
|
|
312
280
|
|
|
313
|
-
|
|
314
|
-
|
|
281
|
+
if (!isOpen) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
315
284
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
285
|
+
/*
|
|
286
|
+
* Render in-place by default (same as pdf-editor). Anvil2 3.x CSS is nested under
|
|
287
|
+
* `.anvil2`; portaling to `document.body` / bare shadow root drops that ancestor and
|
|
288
|
+
* styles disappear in MFE prod. Native `<dialog>` top-layer still stacks correctly.
|
|
289
|
+
*/
|
|
290
|
+
const dialog = (
|
|
291
|
+
<Dialog open={isOpen} onClose={handleClose} size="xlarge">
|
|
292
|
+
<Dialog.Header>Conditions</Dialog.Header>
|
|
293
|
+
<Dialog.Content>
|
|
294
|
+
<Flex
|
|
295
|
+
direction="column"
|
|
296
|
+
gap="4"
|
|
322
297
|
style={{
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
overflow: 'hidden',
|
|
328
|
-
whiteSpace: 'nowrap',
|
|
298
|
+
maxHeight: MODAL_CONTENT_MAX_HEIGHT,
|
|
299
|
+
overflowY: 'auto',
|
|
300
|
+
paddingRight: 8,
|
|
301
|
+
width: '100%',
|
|
329
302
|
}}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
</Dialog.Content>
|
|
411
|
-
<Dialog.Footer sticky>
|
|
412
|
-
<Flex
|
|
413
|
-
justifyContent="flex-end"
|
|
414
|
-
alignItems="center"
|
|
415
|
-
gap="3"
|
|
416
|
-
style={{ width: '100%' }}
|
|
417
|
-
>
|
|
418
|
-
<Button appearance="secondary" onClick={handleClose}>
|
|
419
|
-
Cancel
|
|
420
|
-
</Button>
|
|
421
|
-
<Button
|
|
422
|
-
appearance="primary"
|
|
423
|
-
disabled={!canSave}
|
|
424
|
-
onClick={handleSave}
|
|
425
|
-
>
|
|
426
|
-
Save Changes
|
|
427
|
-
</Button>
|
|
428
|
-
</Flex>
|
|
429
|
-
</Dialog.Footer>
|
|
430
|
-
</Dialog>,
|
|
431
|
-
portalTarget,
|
|
432
|
-
)
|
|
433
|
-
: null}
|
|
434
|
-
</Fragment>
|
|
303
|
+
>
|
|
304
|
+
<ConditionGroupsSection
|
|
305
|
+
behaviorSection={
|
|
306
|
+
<Flex
|
|
307
|
+
direction="row"
|
|
308
|
+
alignItems="center"
|
|
309
|
+
gap="2"
|
|
310
|
+
style={{ flexWrap: 'wrap' }}
|
|
311
|
+
>
|
|
312
|
+
<Text size="small" subdued variant="body">
|
|
313
|
+
Select to include or exclude selected template/file.
|
|
314
|
+
</Text>
|
|
315
|
+
<div style={{ width: 90 }}>
|
|
316
|
+
<Combobox.Select
|
|
317
|
+
disableClearSelection
|
|
318
|
+
itemToKey={(item: BehaviorOption | null) =>
|
|
319
|
+
item?.value ?? ''
|
|
320
|
+
}
|
|
321
|
+
itemToString={(item: BehaviorOption | null) =>
|
|
322
|
+
item?.label ?? ''
|
|
323
|
+
}
|
|
324
|
+
items={[...BEHAVIOR_OPTIONS]}
|
|
325
|
+
selectedItem={selectedBehavior}
|
|
326
|
+
onChange={handleBehaviorChange}
|
|
327
|
+
>
|
|
328
|
+
<Combobox.SelectTrigger
|
|
329
|
+
label=""
|
|
330
|
+
placeholder="Select..."
|
|
331
|
+
size="small"
|
|
332
|
+
/>
|
|
333
|
+
<Combobox.Content>
|
|
334
|
+
{({
|
|
335
|
+
items,
|
|
336
|
+
}: {
|
|
337
|
+
items: BehaviorOption[];
|
|
338
|
+
}) => (
|
|
339
|
+
<Combobox.List>
|
|
340
|
+
{items.map((item, i) => (
|
|
341
|
+
<Combobox.Item
|
|
342
|
+
index={i}
|
|
343
|
+
item={item}
|
|
344
|
+
key={item.value}
|
|
345
|
+
>
|
|
346
|
+
{item.label}
|
|
347
|
+
</Combobox.Item>
|
|
348
|
+
))}
|
|
349
|
+
</Combobox.List>
|
|
350
|
+
)}
|
|
351
|
+
</Combobox.Content>
|
|
352
|
+
</Combobox.Select>
|
|
353
|
+
</div>
|
|
354
|
+
</Flex>
|
|
355
|
+
}
|
|
356
|
+
dataPointOptions={dataPointOptions}
|
|
357
|
+
formFieldOptions={formFieldOptions}
|
|
358
|
+
forms={forms}
|
|
359
|
+
groups={state.groups}
|
|
360
|
+
matchType={matchType}
|
|
361
|
+
onFormSelect={handleFormSelect}
|
|
362
|
+
onMatchTypeChange={setMatchType}
|
|
363
|
+
onUpdateGroup={updateGroup}
|
|
364
|
+
/>
|
|
365
|
+
</Flex>
|
|
366
|
+
</Dialog.Content>
|
|
367
|
+
<Dialog.Footer sticky>
|
|
368
|
+
<Flex
|
|
369
|
+
justifyContent="flex-end"
|
|
370
|
+
alignItems="center"
|
|
371
|
+
gap="3"
|
|
372
|
+
style={{ width: '100%' }}
|
|
373
|
+
>
|
|
374
|
+
<Button appearance="secondary" onClick={handleClose}>
|
|
375
|
+
Cancel
|
|
376
|
+
</Button>
|
|
377
|
+
<Button appearance="primary" disabled={!canSave} onClick={handleSave}>
|
|
378
|
+
Save Changes
|
|
379
|
+
</Button>
|
|
380
|
+
</Flex>
|
|
381
|
+
</Dialog.Footer>
|
|
382
|
+
</Dialog>
|
|
435
383
|
);
|
|
384
|
+
|
|
385
|
+
if (portalContainerProp) {
|
|
386
|
+
return createPortal(<ThemeProvider>{dialog}</ThemeProvider>, portalContainerProp);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
return dialog;
|
|
436
390
|
};
|