@cerberus-design/react 0.16.0-next-22894bb → 0.16.0-next-1e5283a
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/build/legacy/_tsup-dts-rollup.d.cts +108 -90
- package/build/legacy/components/cta-dialog/index.cjs +91 -65
- package/build/legacy/components/cta-dialog/index.cjs.map +1 -1
- package/build/legacy/components/cta-dialog/provider.cjs +91 -65
- package/build/legacy/components/cta-dialog/provider.cjs.map +1 -1
- package/build/legacy/components/{Dialog.client.cjs → dialog/close-icon-trigger.cjs} +36 -28
- package/build/legacy/components/dialog/close-icon-trigger.cjs.map +1 -0
- package/build/legacy/components/dialog/dialog.cjs +80 -0
- package/build/legacy/components/dialog/dialog.cjs.map +1 -0
- package/build/legacy/components/dialog/index.cjs +208 -0
- package/build/legacy/components/dialog/index.cjs.map +1 -0
- package/build/legacy/components/dialog/parts.cjs +109 -0
- package/build/legacy/components/dialog/parts.cjs.map +1 -0
- package/build/legacy/components/dialog/primitives.cjs +112 -0
- package/build/legacy/components/dialog/primitives.cjs.map +1 -0
- package/build/legacy/context/confirm-modal.cjs +78 -49
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/notification-center.cjs +3 -9
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +84 -58
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/index.cjs +489 -437
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +108 -90
- package/build/modern/{chunk-QEM3M4N3.js → chunk-4WKM2MJC.js} +9 -7
- package/build/modern/chunk-4WKM2MJC.js.map +1 -0
- package/build/modern/{chunk-H5WNUPGH.js → chunk-6DAOKE6Z.js} +1 -1
- package/build/modern/{chunk-H5WNUPGH.js.map → chunk-6DAOKE6Z.js.map} +1 -1
- package/build/modern/chunk-C45HS2C4.js +22 -0
- package/build/modern/chunk-C45HS2C4.js.map +1 -0
- package/build/modern/{chunk-ZFFW5ELD.js → chunk-CF3EHG42.js} +4 -4
- package/build/modern/chunk-D7UIWAFO.js +84 -0
- package/build/modern/chunk-D7UIWAFO.js.map +1 -0
- package/build/modern/chunk-DJOYRUNT.js +1 -0
- package/build/modern/chunk-FCSO6N2Y.js +27 -0
- package/build/modern/chunk-FCSO6N2Y.js.map +1 -0
- package/build/modern/{chunk-H54FR7IP.js → chunk-MTZDZXZM.js} +8 -6
- package/build/modern/{chunk-H54FR7IP.js.map → chunk-MTZDZXZM.js.map} +1 -1
- package/build/modern/{chunk-6BN3XKQF.js → chunk-NZKE7C53.js} +8 -8
- package/build/modern/chunk-NZKE7C53.js.map +1 -0
- package/build/modern/{chunk-O542MPR7.js → chunk-OOUNB643.js} +8 -6
- package/build/modern/{chunk-O542MPR7.js.map → chunk-OOUNB643.js.map} +1 -1
- package/build/modern/components/FileStatus.js +2 -2
- package/build/modern/components/cta-dialog/index.js +8 -5
- package/build/modern/components/cta-dialog/provider.js +7 -4
- package/build/modern/components/dialog/close-icon-trigger.js +11 -0
- package/build/modern/components/dialog/dialog.js +9 -0
- package/build/modern/components/dialog/dialog.js.map +1 -0
- package/build/modern/components/dialog/index.js +39 -0
- package/build/modern/components/dialog/index.js.map +1 -0
- package/build/modern/components/dialog/parts.js +8 -0
- package/build/modern/components/dialog/parts.js.map +1 -0
- package/build/modern/components/{Dialog.js → dialog/primitives.js} +4 -5
- package/build/modern/components/dialog/primitives.js.map +1 -0
- package/build/modern/components/select/index.js +4 -4
- package/build/modern/context/confirm-modal.js +7 -2
- package/build/modern/context/notification-center.js +1 -1
- package/build/modern/context/prompt-modal.js +7 -2
- package/build/modern/index.js +56 -47
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/cta-dialog/provider.tsx +2 -2
- package/src/components/{Dialog.client.tsx → dialog/close-icon-trigger.tsx} +11 -13
- package/src/components/dialog/dialog.tsx +41 -0
- package/src/components/dialog/index.ts +4 -0
- package/src/components/dialog/parts.ts +71 -0
- package/src/components/dialog/primitives.tsx +116 -0
- package/src/context/confirm-modal.tsx +1 -1
- package/src/context/notification-center.tsx +3 -3
- package/src/context/prompt-modal.tsx +1 -1
- package/src/index.ts +1 -2
- package/build/legacy/components/Dialog.cjs +0 -86
- package/build/legacy/components/Dialog.cjs.map +0 -1
- package/build/legacy/components/Dialog.client.cjs.map +0 -1
- package/build/modern/chunk-6BN3XKQF.js.map +0 -1
- package/build/modern/chunk-QEM3M4N3.js.map +0 -1
- package/build/modern/chunk-TFL56AYR.js +0 -56
- package/build/modern/chunk-TFL56AYR.js.map +0 -1
- package/build/modern/components/Dialog.client.js +0 -10
- package/src/components/Dialog.tsx +0 -165
- /package/build/modern/{chunk-ZFFW5ELD.js.map → chunk-CF3EHG42.js.map} +0 -0
- /package/build/modern/{components/Dialog.client.js.map → chunk-DJOYRUNT.js.map} +0 -0
- /package/build/modern/components/{Dialog.js.map → dialog/close-icon-trigger.js.map} +0 -0
|
@@ -46,12 +46,15 @@ import { defaultCoordinates } from '@dnd-kit/core';
|
|
|
46
46
|
import { defaultDropAnimation } from '@dnd-kit/core';
|
|
47
47
|
import { defaultDropAnimationSideEffects } from '@dnd-kit/core';
|
|
48
48
|
import { defaultScreenReaderInstructions } from '@dnd-kit/core';
|
|
49
|
-
import {
|
|
50
|
-
import { DialogCloseTriggerProps } from '@ark-ui/react';
|
|
51
|
-
import { DialogContentProps } from '@ark-ui/react';
|
|
49
|
+
import { DialogBackdropProps } from '@ark-ui/react/dialog';
|
|
50
|
+
import { DialogCloseTriggerProps } from '@ark-ui/react/dialog';
|
|
51
|
+
import { DialogContentProps } from '@ark-ui/react/dialog';
|
|
52
|
+
import { DialogDescriptionProps } from '@ark-ui/react/dialog';
|
|
52
53
|
import { DialogHTMLAttributes } from 'react';
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
54
|
+
import { DialogPositionerProps } from '@ark-ui/react/dialog';
|
|
55
|
+
import { DialogRootProps } from '@ark-ui/react/dialog';
|
|
56
|
+
import { DialogTitleProps } from '@ark-ui/react/dialog';
|
|
57
|
+
import { DialogTriggerProps } from '@ark-ui/react/dialog';
|
|
55
58
|
import { DialogVariantProps } from '@cerberus/styled-system/recipes';
|
|
56
59
|
import type { Dispatch } from 'react';
|
|
57
60
|
import { DistanceMeasurement } from '@dnd-kit/core';
|
|
@@ -1431,8 +1434,10 @@ export { DestructiveConfirmOptions }
|
|
|
1431
1434
|
export { DestructiveConfirmOptions as DestructiveConfirmOptions_alias_1 }
|
|
1432
1435
|
|
|
1433
1436
|
/**
|
|
1434
|
-
*
|
|
1437
|
+
* An abstraction of the Dialog primitives that controls the content of the
|
|
1438
|
+
* dialog. Must be used within the `DialogProvider` component.
|
|
1435
1439
|
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
1440
|
+
* @definition [Ark Dialog docs](https://ark-ui.com/react/docs/components/dialog)
|
|
1436
1441
|
* @example
|
|
1437
1442
|
* ```tsx
|
|
1438
1443
|
* <DialogProvider>
|
|
@@ -1448,143 +1453,156 @@ export { DestructiveConfirmOptions as DestructiveConfirmOptions_alias_1 }
|
|
|
1448
1453
|
declare function Dialog(props: DialogProps): JSX_2.Element;
|
|
1449
1454
|
export { Dialog }
|
|
1450
1455
|
export { Dialog as Dialog_alias_1 }
|
|
1456
|
+
export { Dialog as Dialog_alias_2 }
|
|
1451
1457
|
|
|
1452
1458
|
/**
|
|
1453
|
-
* The
|
|
1454
|
-
* component.
|
|
1459
|
+
* The overlay of the dialog.
|
|
1455
1460
|
*/
|
|
1456
|
-
declare
|
|
1461
|
+
declare function DialogBackdrop(props: DialogBackdropProps): JSX_2.Element;
|
|
1457
1462
|
export { DialogBackdrop }
|
|
1458
1463
|
export { DialogBackdrop as DialogBackdrop_alias_1 }
|
|
1464
|
+
export { DialogBackdrop as DialogBackdrop_alias_2 }
|
|
1459
1465
|
|
|
1460
1466
|
/**
|
|
1461
|
-
* This module contains
|
|
1462
|
-
* @module
|
|
1467
|
+
* This module contains the close trigger for the dialog.
|
|
1468
|
+
* @module react/dialog
|
|
1463
1469
|
*/
|
|
1464
1470
|
declare function DialogCloseIconTrigger(props: DialogCloseTriggerProps): JSX_2.Element;
|
|
1465
1471
|
export { DialogCloseIconTrigger }
|
|
1466
1472
|
export { DialogCloseIconTrigger as DialogCloseIconTrigger_alias_1 }
|
|
1473
|
+
export { DialogCloseIconTrigger as DialogCloseIconTrigger_alias_2 }
|
|
1467
1474
|
|
|
1468
1475
|
/**
|
|
1469
|
-
* The trigger that closes the dialog.
|
|
1470
|
-
* component.
|
|
1471
|
-
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
1472
|
-
* @example
|
|
1473
|
-
* ```tsx
|
|
1474
|
-
* <DialogProvider>
|
|
1475
|
-
* <DialogTrigger asChild>
|
|
1476
|
-
* <Button>Open Dialog</Button>
|
|
1477
|
-
* </DialogTrigger>
|
|
1478
|
-
* <Dialog>
|
|
1479
|
-
* <Text>Dialog Content</Text>
|
|
1480
|
-
* <DialogCloseTrigger>Close</DialogCloseTrigger>
|
|
1481
|
-
* </Dialog>
|
|
1482
|
-
* </DialogProvider>
|
|
1483
|
-
* ```
|
|
1476
|
+
* The trigger that closes the dialog.
|
|
1484
1477
|
*/
|
|
1485
|
-
declare
|
|
1478
|
+
declare function DialogCloseTrigger(props: DialogTriggerProps): JSX_2.Element;
|
|
1486
1479
|
export { DialogCloseTrigger }
|
|
1487
1480
|
export { DialogCloseTrigger as DialogCloseTrigger_alias_1 }
|
|
1481
|
+
export { DialogCloseTrigger as DialogCloseTrigger_alias_2 }
|
|
1488
1482
|
|
|
1489
1483
|
/**
|
|
1490
|
-
* The content of the dialog.
|
|
1491
|
-
* component.
|
|
1484
|
+
* The visible content of the dialog.
|
|
1492
1485
|
*/
|
|
1493
|
-
declare
|
|
1486
|
+
declare function DialogContent(props: DialogContentProps & DialogVariantProps): JSX_2.Element;
|
|
1494
1487
|
export { DialogContent }
|
|
1495
1488
|
export { DialogContent as DialogContent_alias_1 }
|
|
1489
|
+
export { DialogContent as DialogContent_alias_2 }
|
|
1496
1490
|
|
|
1497
1491
|
/**
|
|
1498
|
-
* The description of the dialog.
|
|
1499
|
-
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
1500
|
-
* @example
|
|
1501
|
-
* ```tsx
|
|
1502
|
-
* <DialogProvider>
|
|
1503
|
-
* <DialogTrigger asChild>
|
|
1504
|
-
* <Button>Open Dialog</Button>
|
|
1505
|
-
* </DialogTrigger>
|
|
1506
|
-
* <Dialog>
|
|
1507
|
-
* <DialogHeading>Dialog Title</DialogHeading>
|
|
1508
|
-
* <DialogDescription>Dialog Description</DialogDescription>
|
|
1509
|
-
* </Dialog>
|
|
1510
|
-
* </DialogProvider>
|
|
1511
|
-
* ```
|
|
1492
|
+
* The description of the dialog.
|
|
1512
1493
|
*/
|
|
1513
|
-
declare function DialogDescription(props:
|
|
1494
|
+
declare function DialogDescription(props: DialogDescriptionProps): JSX_2.Element;
|
|
1514
1495
|
export { DialogDescription }
|
|
1515
1496
|
export { DialogDescription as DialogDescription_alias_1 }
|
|
1497
|
+
export { DialogDescription as DialogDescription_alias_2 }
|
|
1516
1498
|
|
|
1517
1499
|
/**
|
|
1518
|
-
* The heading of the dialog.
|
|
1519
|
-
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
1520
|
-
* @example
|
|
1521
|
-
* ```tsx
|
|
1522
|
-
* <DialogProvider>
|
|
1523
|
-
* <DialogTrigger asChild>
|
|
1524
|
-
* <Button>Open Dialog</Button>
|
|
1525
|
-
* </DialogTrigger>
|
|
1526
|
-
* <Dialog>
|
|
1527
|
-
* <DialogHeading>Dialog Title</DialogHeading>
|
|
1528
|
-
* <Text>Dialog Content</Text>
|
|
1529
|
-
* </Dialog>
|
|
1530
|
-
* </DialogProvider>
|
|
1531
|
-
* ```
|
|
1500
|
+
* The heading of the dialog.
|
|
1532
1501
|
*/
|
|
1533
1502
|
declare function DialogHeading(props: DialogTitleProps): JSX_2.Element;
|
|
1534
1503
|
export { DialogHeading }
|
|
1535
1504
|
export { DialogHeading as DialogHeading_alias_1 }
|
|
1505
|
+
export { DialogHeading as DialogHeading_alias_2 }
|
|
1506
|
+
|
|
1507
|
+
/**
|
|
1508
|
+
* An Object containing the parts of the dialog component. For users that
|
|
1509
|
+
* prefer Object component syntax.
|
|
1510
|
+
*
|
|
1511
|
+
* @remarks
|
|
1512
|
+
*
|
|
1513
|
+
* When using object component syntax, you import the DialogParts object and
|
|
1514
|
+
* the entire family of components vs. only what you use.
|
|
1515
|
+
*/
|
|
1516
|
+
declare const DialogParts: DialogPartsValue;
|
|
1517
|
+
export { DialogParts }
|
|
1518
|
+
export { DialogParts as DialogParts_alias_1 }
|
|
1519
|
+
export { DialogParts as DialogParts_alias_2 }
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* This module contains the parts of the Dialog component.
|
|
1523
|
+
* @module 'dialog/parts'
|
|
1524
|
+
*/
|
|
1525
|
+
declare interface DialogPartsValue {
|
|
1526
|
+
/**
|
|
1527
|
+
* The context provider of the dialog.
|
|
1528
|
+
*/
|
|
1529
|
+
Root: ElementType;
|
|
1530
|
+
/**
|
|
1531
|
+
* The trigger that opens the dialog.
|
|
1532
|
+
*/
|
|
1533
|
+
Trigger: ElementType;
|
|
1534
|
+
/**
|
|
1535
|
+
* The overlay of the dialog.
|
|
1536
|
+
*/
|
|
1537
|
+
Backdrop: ElementType;
|
|
1538
|
+
/**
|
|
1539
|
+
* The container that positions the dialog.
|
|
1540
|
+
*/
|
|
1541
|
+
Positioner: ElementType;
|
|
1542
|
+
/**
|
|
1543
|
+
* The visible content of the dialog.
|
|
1544
|
+
*/
|
|
1545
|
+
Content: ElementType;
|
|
1546
|
+
/**
|
|
1547
|
+
* The heading of the dialog.
|
|
1548
|
+
*/
|
|
1549
|
+
Heading: ElementType;
|
|
1550
|
+
/**
|
|
1551
|
+
* The description of the dialog.
|
|
1552
|
+
*/
|
|
1553
|
+
Description: ElementType;
|
|
1554
|
+
/**
|
|
1555
|
+
* The trigger that closes the dialog.
|
|
1556
|
+
*/
|
|
1557
|
+
CloseTrigger: ElementType;
|
|
1558
|
+
}
|
|
1536
1559
|
|
|
1537
1560
|
/**
|
|
1538
|
-
* The
|
|
1539
|
-
* component.
|
|
1561
|
+
* The container that positions the dialog.
|
|
1540
1562
|
*/
|
|
1541
|
-
declare
|
|
1563
|
+
declare function DialogPositioner(props: DialogPositionerProps): JSX_2.Element;
|
|
1542
1564
|
export { DialogPositioner }
|
|
1543
1565
|
export { DialogPositioner as DialogPositioner_alias_1 }
|
|
1566
|
+
export { DialogPositioner as DialogPositioner_alias_2 }
|
|
1544
1567
|
|
|
1568
|
+
/**
|
|
1569
|
+
* This module contains and abstraction of the Dialog primitives.
|
|
1570
|
+
* @module 'dialog'
|
|
1571
|
+
*/
|
|
1545
1572
|
declare interface DialogProps extends Omit<DialogContentProps, 'size'>, DialogVariantProps {
|
|
1546
1573
|
}
|
|
1547
1574
|
export { DialogProps }
|
|
1548
1575
|
export { DialogProps as DialogProps_alias_1 }
|
|
1576
|
+
export { DialogProps as DialogProps_alias_2 }
|
|
1549
1577
|
|
|
1550
1578
|
/**
|
|
1551
|
-
* The provider that controls the dialog components.
|
|
1552
|
-
*
|
|
1553
|
-
* @example
|
|
1554
|
-
* ```tsx
|
|
1555
|
-
* <DialogProvider>
|
|
1556
|
-
* <DialogTrigger asChild>
|
|
1557
|
-
* <Button>Open Dialog</Button>
|
|
1558
|
-
* </DialogTrigger>
|
|
1559
|
-
* <Dialog>
|
|
1560
|
-
* <Text>Dialog Content</Text>
|
|
1561
|
-
* <DialogCloseTrigger>Close</DialogCloseTrigger>
|
|
1562
|
-
* </Dialog>
|
|
1563
|
-
* </DialogProvider>
|
|
1564
|
-
* ```
|
|
1579
|
+
* The provider that controls the dialog components. This is a named export of
|
|
1580
|
+
* the DialogRoot primitive.
|
|
1565
1581
|
*/
|
|
1566
|
-
declare
|
|
1582
|
+
declare const DialogProvider: typeof DialogRoot;
|
|
1567
1583
|
export { DialogProvider }
|
|
1568
1584
|
export { DialogProvider as DialogProvider_alias_1 }
|
|
1585
|
+
export { DialogProvider as DialogProvider_alias_2 }
|
|
1569
1586
|
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1587
|
+
/**
|
|
1588
|
+
* This module contains the primitives of the Dialog component.
|
|
1589
|
+
* @module 'dialog/primitives'
|
|
1590
|
+
*/
|
|
1591
|
+
/**
|
|
1592
|
+
* The provider that controls the dialog components.
|
|
1593
|
+
*/
|
|
1594
|
+
declare function DialogRoot(props: DialogRootProps): JSX_2.Element;
|
|
1595
|
+
export { DialogRoot }
|
|
1596
|
+
export { DialogRoot as DialogRoot_alias_1 }
|
|
1597
|
+
export { DialogRoot as DialogRoot_alias_2 }
|
|
1573
1598
|
|
|
1574
1599
|
/**
|
|
1575
|
-
* The trigger that opens the dialog.
|
|
1576
|
-
* component.
|
|
1577
|
-
* @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)
|
|
1578
|
-
* @example
|
|
1579
|
-
* ```tsx
|
|
1580
|
-
* <DialogTrigger asChild>
|
|
1581
|
-
* <Button>Open Dialog</Button>
|
|
1582
|
-
* </DialogTrigger>
|
|
1583
|
-
* ```
|
|
1600
|
+
* The trigger that opens the dialog.
|
|
1584
1601
|
*/
|
|
1585
|
-
declare
|
|
1602
|
+
declare function DialogTrigger(props: DialogTriggerProps): JSX_2.Element;
|
|
1586
1603
|
export { DialogTrigger }
|
|
1587
1604
|
export { DialogTrigger as DialogTrigger_alias_1 }
|
|
1605
|
+
export { DialogTrigger as DialogTrigger_alias_2 }
|
|
1588
1606
|
|
|
1589
1607
|
export { DistanceMeasurement }
|
|
1590
1608
|
|
|
@@ -7,18 +7,20 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
For
|
|
9
9
|
} from "./chunk-DXOKSZVQ.js";
|
|
10
|
+
import {
|
|
11
|
+
Avatar
|
|
12
|
+
} from "./chunk-SXLPDPOZ.js";
|
|
10
13
|
import {
|
|
11
14
|
DialogCloseIconTrigger
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NZKE7C53.js";
|
|
16
|
+
import {
|
|
17
|
+
Dialog
|
|
18
|
+
} from "./chunk-C45HS2C4.js";
|
|
13
19
|
import {
|
|
14
|
-
Dialog,
|
|
15
20
|
DialogDescription,
|
|
16
21
|
DialogHeading,
|
|
17
22
|
DialogProvider
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import {
|
|
20
|
-
Avatar
|
|
21
|
-
} from "./chunk-SXLPDPOZ.js";
|
|
23
|
+
} from "./chunk-D7UIWAFO.js";
|
|
22
24
|
import {
|
|
23
25
|
useCerberusContext
|
|
24
26
|
} from "./chunk-GITT5645.js";
|
|
@@ -114,4 +116,4 @@ export {
|
|
|
114
116
|
CTAModal,
|
|
115
117
|
useCTAModal
|
|
116
118
|
};
|
|
117
|
-
//# sourceMappingURL=chunk-
|
|
119
|
+
//# sourceMappingURL=chunk-4WKM2MJC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/cta-dialog/provider.tsx"],"sourcesContent":["'use client'\n\nimport {\n useCallback,\n useContext,\n useMemo,\n useState,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { HStack, VStack } from '@cerberus/styled-system/jsx'\nimport { useCerberusContext } from '../../context/cerberus'\nimport { Show } from '../Show'\nimport { For } from '../for'\nimport { Avatar } from '../Avatar'\nimport {\n Dialog,\n DialogDescription,\n DialogHeading,\n DialogProvider,\n} from '../dialog'\nimport { DialogCloseIconTrigger } from '../dialog/close-icon-trigger'\nimport type { CTAButtonAction, CTAModalActionReturn } from './utils'\nimport {\n CTAModalContext,\n type CTAModalValue,\n type ShowCTAModalOptions,\n} from './context'\nimport { TriggerItem } from './trigger-item'\n\n/**\n * This module provides the provider and hook for the cta modal.\n * @module 'react/cta-modal/provider'\n */\n\n/**\n * Provides a CTA modal to the app.\n * @see https://cerberus.digitalu.design/react/cta-modal\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <CTAModal>\n * <SomeFeatureSection />\n * </CTAModal>\n *\n * // Use the hook to show the cta modal.\n * const cta = useCTAModal()\n *\n * const handleClick = useCallback(async () => {\n * const userConsent = await cta.show({\n * heading: 'Create or copy a Cohort',\n * description:\n * 'Create a new cohort or copy and existing one.',\n * icon: <Copy size={24} />,\n * actions: [\n * {\n * text: 'Create Cohort',\n * onClick: () => {},\n * {\n * text: 'Copy Cohort',\n * onClick: () => {}\n * }\n * })\n * setConsent(userConsent)\n * }, [cta])\n * ```\n */\nexport function CTAModal(props: PropsWithChildren<object>) {\n const [open, setOpen] = useState<boolean>(false)\n const [content, setContent] = useState<ShowCTAModalOptions | null>(null)\n const confirmIcon = content?.icon\n\n const { icons } = useCerberusContext()\n const { confirmModal: FallbackIcon } = icons\n\n const handleShow = useCallback(\n (options: ShowCTAModalOptions) => {\n setContent({ ...options })\n setOpen(true)\n },\n [setOpen],\n )\n\n const handleActionClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const index = Number(event.currentTarget.getAttribute('data-index'))\n const contentActions = content?.actions as CTAModalActionReturn\n const action = contentActions._actions[index] as CTAButtonAction\n action?.handleClick?.(event)\n setOpen(false)\n },\n [content, setOpen],\n )\n\n const value = useMemo(\n () => ({\n show: handleShow,\n }),\n [handleShow],\n )\n\n return (\n <CTAModalContext.Provider value={value}>\n {props.children}\n\n <DialogProvider open={open} onOpenChange={(e) => setOpen(e.open)}>\n <Dialog size=\"sm\">\n <DialogCloseIconTrigger />\n\n <VStack gap=\"xl\" w=\"full\">\n <VStack alignItems=\"flex-start\" gap=\"md\" w=\"full\">\n <VStack gap=\"lg\" w=\"full\">\n <Avatar\n ariaLabel=\"\"\n gradient=\"charon-light\"\n icon={\n <Show\n when={Boolean(confirmIcon)}\n fallback={<FallbackIcon size={24} />}\n >\n {confirmIcon}\n </Show>\n }\n src=\"\"\n />\n <DialogHeading>{content?.heading}</DialogHeading>\n <DialogDescription>{content?.description}</DialogDescription>\n </VStack>\n </VStack>\n\n <HStack gap=\"md\" w=\"full\">\n <For each={content?.actions._actions}>\n {(action, index) => (\n <Show\n key={index}\n when={content?.actions?.type === 'btnAction'}\n fallback={\n <TriggerItem asChild>{action as ReactNode}</TriggerItem>\n }\n >\n <TriggerItem data-index={index} onClick={handleActionClick}>\n {(action as CTAButtonAction)?.text}\n </TriggerItem>\n </Show>\n )}\n </For>\n </HStack>\n </VStack>\n </Dialog>\n </DialogProvider>\n </CTAModalContext.Provider>\n )\n}\n\nexport function useCTAModal(): CTAModalValue {\n const context = useContext(CTAModalContext)\n if (context === null) {\n throw new Error('useCTAModal must be used within a CTAModal Provider')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,QAAQ,cAAc;AAiGrB,cAII,YAJJ;AAxCH,SAAS,SAAS,OAAkC;AACzD,QAAM,CAAC,MAAM,OAAO,IAAI,SAAkB,KAAK;AAC/C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAqC,IAAI;AACvE,QAAM,cAAc,SAAS;AAE7B,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,EAAE,cAAc,aAAa,IAAI;AAEvC,QAAM,aAAa;AAAA,IACjB,CAAC,YAAiC;AAChC,iBAAW,EAAE,GAAG,QAAQ,CAAC;AACzB,cAAQ,IAAI;AAAA,IACd;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,QAAM,oBAAoB;AAAA,IACxB,CAAC,UAAyC;AACxC,YAAM,QAAQ,OAAO,MAAM,cAAc,aAAa,YAAY,CAAC;AACnE,YAAM,iBAAiB,SAAS;AAChC,YAAM,SAAS,eAAe,SAAS,KAAK;AAC5C,cAAQ,cAAc,KAAK;AAC3B,cAAQ,KAAK;AAAA,IACf;AAA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ACpB,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/notification-center.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useReducer,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { Show } from '../components/Show'\nimport { NotificationHeading } from '../components/NotificationHeading'\nimport { NotificationDescription } from '../components/NotificationDescription'\nimport { Notification } from '../components/Notification'\nimport { animateIn, vstack } from '@cerberus/styled-system/patterns'\nimport { Portal, type PortalProps } from '../components/Portal'\nimport { notification } from '@cerberus/styled-system/recipes'\nimport { Button } from '../components/button/button'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n addNotification,\n clearNotificationState,\n notificationCenterReducer,\n removeNotification,\n updateNotificationState,\n} from './notification-center/store'\n\n/**\n * This module provides a context and hook for notifications.\n * @module\n */\n\nexport interface NotifyOptions {\n /**\n * The palette of the notification.\n * @default 'info'\n */\n palette: 'info' | 'success' | 'warning' | 'danger'\n /**\n * The heading of the notification.\n */\n heading: string\n /**\n * The unique id of the notification.\n */\n id?: string\n /**\n * The description of the notification.\n */\n description?: ReactNode\n /**\n * The action to take when the notification is closed\n */\n onClose?: () => void\n}\n\nexport interface NotificationsValue {\n notify: (options: NotifyOptions) => void\n}\n\nconst NotificationsContext = createContext<NotificationsValue | null>(null)\n\nexport type NotificationsProviderProps = PortalProps & {\n /**\n * The duration in milliseconds to show the notification.\n * @default 6000\n */\n duration?: number\n}\n\n/**\n * Provides a notification center to the app.\n * @see https://cerberus.digitalu.design/react/notification\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <Notifications>\n * <SomeFeatureSection />\n * </Notifications>\n *\n * // Use the hook to show a notification.\n * const notify = useNotifications()\n *\n * const handleClick = useCallback(() => {\n * notify({\n * palette: 'info',\n * heading: 'New feature!',\n * description: 'We have added a new feature to the app.',\n * })\n * }, [notify])\n * ```\n */\nexport function NotificationCenter(\n props: PropsWithChildren<NotificationsProviderProps>,\n) {\n const [state, dispatch] = useReducer(notificationCenterReducer, [])\n const styles = notification()\n\n const timeout = useMemo<number>(\n () => props.duration || 6000,\n [props.duration],\n )\n\n const closeNotification = useCallback(\n (id: string) => {\n updateNotificationState(dispatch, {\n id,\n state: 'closed',\n })\n window.setTimeout(() => {\n removeNotification(dispatch, id)\n }, 150)\n },\n [dispatch],\n )\n\n const handleNotify = useCallback(\n (options: NotifyOptions) => {\n const id = `${options.palette}:${state.length + 1}`\n addNotification(dispatch, {\n ...options,\n id,\n state: 'open',\n })\n\n window.setTimeout(() => {\n closeNotification(id)\n }, timeout)\n },\n [dispatch, state, timeout, closeNotification],\n )\n\n const handleClose = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n const target = e.currentTarget as HTMLButtonElement\n closeNotification(target.value)\n },\n [closeNotification],\n )\n\n const handleCloseAll = useCallback(() => {\n state.forEach((item) => {\n if (item.onClose) item.onClose()\n })\n // we don't want to animate out for this one\n clearNotificationState(dispatch)\n }, [state, dispatch])\n\n const value = useMemo(\n () => ({\n notify: handleNotify,\n }),\n [handleNotify],\n )\n\n // For some reason, the vstack pattern alignItems is not registering here.\n // So we are forcing it with the style prop.\n\n return (\n <NotificationsContext.Provider value={value}>\n {props.children}\n\n <Show when={state.length > 0}>\n <Portal container={props.container}>\n <div className={styles.center}>\n <Show when={state.length >= 4}>\n <Button\n className={cx(styles.closeAll, animateIn())}\n onClick={handleCloseAll}\n palette=\"action\"\n shape=\"rounded\"\n size=\"sm\"\n usage=\"ghost\"\n >\n Close all\n </Button>\n </Show>\n\n <div\n className={vstack({\n alignItems: 'flex-end',\n gap: '4',\n })}\n style={{\n alignItems: 'flex-end',\n }}\n >\n {state.map((option) => (\n <MatchNotification\n key={option.id}\n {...option}\n onClose={handleClose}\n open={option.state}\n />\n ))}\n </div>\n </div>\n </Portal>\n </Show>\n </NotificationsContext.Provider>\n )\n}\n\ninterface MatchNotificationProps extends Omit<NotifyOptions, 'onClose'> {\n open: 'open' | 'closed'\n onClose: (e: MouseEvent<HTMLButtonElement>) => void\n key: string | undefined\n}\n\nfunction MatchNotification(props: MatchNotificationProps) {\n const { palette, id, onClose, heading, description, open } = props\n const sharedProps = useMemo(\n () => ({\n id: id!,\n open: true,\n onClose,\n 'data-state': open,\n }),\n [id, open, onClose],\n )\n\n switch (palette) {\n case 'success':\n return (\n <Notification {...sharedProps} palette=\"success\">\n <NotificationHeading palette=\"success\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"success\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'warning':\n return (\n <Notification {...sharedProps} palette=\"warning\">\n <NotificationHeading palette=\"warning\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"warning\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'danger':\n return (\n <Notification {...sharedProps} palette=\"danger\">\n <NotificationHeading palette=\"danger\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"danger\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'info':\n default:\n return (\n <Notification {...sharedProps} palette=\"info\">\n <NotificationHeading palette=\"info\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"info\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n }\n}\n\n/**\n * The hook to use the NotificationCenter.\n * @returns The notify method to trigger a notification.\n * @example\n * ```tsx\n * const {notify} = useNotificationCenter()\n * notify({\n * palette: 'info',\n * heading: 'New feature',\n * description: 'We have added a new feature to the app.',\n * })\n * ```\n */\nexport function useNotificationCenter(): NotificationsValue {\n const context = useContext(NotificationsContext)\n if (!context) {\n throw new Error(\n 'useNotificationCenter must be used within a NotificationsProvider',\n )\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAKP,SAAS,WAAW,cAA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ACF;AAAA,IAGJ,KAAK;AACH,aACE,qBAAC,gBAAc,GAAG,aAAa,SAAQ,WACrC;AAAA,4BAAC,uBAAoB,SAAQ,WAAW,mBAAQ;AAAA,QAChD,oBAAC,2BAAwB,SAAQ,WAC9B,uBACH;AAAA,SACF;AAAA,IAGJ,KAAK;AACH,aACE,qBAAC,gBAAc,GAAG,aAAa,SAAQ,UACrC;AAAA,4BAAC,uBAAoB,SAAQ,UAAU,mBAAQ;AAAA,QAC/C,oBAAC,2BAAwB,SAAQ,UAC9B,uBACH;AAAA,SACF;AAAA,IAGJ,KAAK;AAAA,IACL;AACE,aACE,qBAAC,gBAAc,GAAG,aAAa,SAAQ,QACrC;AAAA,4BAAC,uBAAoB,SAAQ,QAAQ,mBAAQ;AAAA,QAC7C,oBAAC,2BAAwB,SAAQ,QAC9B,uBACH;AAAA,SACF;AAAA,EAEN;AACF;AAeO,SAAS,wBAA4C;AAC1D,QAAM,UAAU,WAAW,oBAAoB;AAC/C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/context/notification-center.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useReducer,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { animateIn, vstack } from '@cerberus/styled-system/patterns'\nimport { notification } from '@cerberus/styled-system/recipes'\nimport { cx } from '@cerberus/styled-system/css'\nimport { Show } from '../components/Show'\nimport { NotificationHeading } from '../components/NotificationHeading'\nimport { NotificationDescription } from '../components/NotificationDescription'\nimport { Notification } from '../components/Notification'\nimport { Portal, type PortalProps } from '../components/Portal'\nimport { Button } from '../components/button/button'\nimport {\n addNotification,\n clearNotificationState,\n notificationCenterReducer,\n removeNotification,\n updateNotificationState,\n} from './notification-center/store'\n\n/**\n * This module provides a context and hook for notifications.\n * @module\n */\n\nexport interface NotifyOptions {\n /**\n * The palette of the notification.\n * @default 'info'\n */\n palette: 'info' | 'success' | 'warning' | 'danger'\n /**\n * The heading of the notification.\n */\n heading: string\n /**\n * The unique id of the notification.\n */\n id?: string\n /**\n * The description of the notification.\n */\n description?: ReactNode\n /**\n * The action to take when the notification is closed\n */\n onClose?: () => void\n}\n\nexport interface NotificationsValue {\n notify: (options: NotifyOptions) => void\n}\n\nconst NotificationsContext = createContext<NotificationsValue | null>(null)\n\nexport type NotificationsProviderProps = PortalProps & {\n /**\n * The duration in milliseconds to show the notification.\n * @default 6000\n */\n duration?: number\n}\n\n/**\n * Provides a notification center to the app.\n * @see https://cerberus.digitalu.design/react/notification\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <Notifications>\n * <SomeFeatureSection />\n * </Notifications>\n *\n * // Use the hook to show a notification.\n * const notify = useNotifications()\n *\n * const handleClick = useCallback(() => {\n * notify({\n * palette: 'info',\n * heading: 'New feature!',\n * description: 'We have added a new feature to the app.',\n * })\n * }, [notify])\n * ```\n */\nexport function NotificationCenter(\n props: PropsWithChildren<NotificationsProviderProps>,\n) {\n const [state, dispatch] = useReducer(notificationCenterReducer, [])\n const styles = notification()\n\n const timeout = useMemo<number>(\n () => props.duration || 6000,\n [props.duration],\n )\n\n const closeNotification = useCallback(\n (id: string) => {\n updateNotificationState(dispatch, {\n id,\n state: 'closed',\n })\n window.setTimeout(() => {\n removeNotification(dispatch, id)\n }, 150)\n },\n [dispatch],\n )\n\n const handleNotify = useCallback(\n (options: NotifyOptions) => {\n const id = `${options.palette}:${state.length + 1}`\n addNotification(dispatch, {\n ...options,\n id,\n state: 'open',\n })\n\n window.setTimeout(() => {\n closeNotification(id)\n }, timeout)\n },\n [dispatch, state, timeout, closeNotification],\n )\n\n const handleClose = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n const target = e.currentTarget as HTMLButtonElement\n closeNotification(target.value)\n },\n [closeNotification],\n )\n\n const handleCloseAll = useCallback(() => {\n state.forEach((item) => {\n if (item.onClose) item.onClose()\n })\n // we don't want to animate out for this one\n clearNotificationState(dispatch)\n }, [state, dispatch])\n\n const value = useMemo(\n () => ({\n notify: handleNotify,\n }),\n [handleNotify],\n )\n\n // For some reason, the vstack pattern alignItems is not registering here.\n // So we are forcing it with the style prop.\n\n return (\n <NotificationsContext.Provider value={value}>\n {props.children}\n\n <Show when={state.length > 0}>\n <Portal container={props.container}>\n <div className={styles.center}>\n <Show when={state.length >= 4}>\n <Button\n className={cx(styles.closeAll, animateIn())}\n onClick={handleCloseAll}\n palette=\"action\"\n shape=\"rounded\"\n size=\"sm\"\n usage=\"ghost\"\n >\n Close all\n </Button>\n </Show>\n\n <div\n className={vstack({\n alignItems: 'flex-end',\n gap: '4',\n })}\n style={{\n alignItems: 'flex-end',\n }}\n >\n {state.map((option) => (\n <MatchNotification\n key={option.id}\n {...option}\n onClose={handleClose}\n open={option.state}\n />\n ))}\n </div>\n </div>\n </Portal>\n </Show>\n </NotificationsContext.Provider>\n )\n}\n\ninterface MatchNotificationProps extends Omit<NotifyOptions, 'onClose'> {\n open: 'open' | 'closed'\n onClose: (e: MouseEvent<HTMLButtonElement>) => void\n key: string | undefined\n}\n\nfunction MatchNotification(props: MatchNotificationProps) {\n const { palette, id, onClose, heading, description, open } = props\n const sharedProps = useMemo(\n () => ({\n id: id!,\n open: true,\n onClose,\n 'data-state': open,\n }),\n [id, open, onClose],\n )\n\n switch (palette) {\n case 'success':\n return (\n <Notification {...sharedProps} palette=\"success\">\n <NotificationHeading palette=\"success\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"success\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'warning':\n return (\n <Notification {...sharedProps} palette=\"warning\">\n <NotificationHeading palette=\"warning\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"warning\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'danger':\n return (\n <Notification {...sharedProps} palette=\"danger\">\n <NotificationHeading palette=\"danger\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"danger\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n\n case 'info':\n default:\n return (\n <Notification {...sharedProps} palette=\"info\">\n <NotificationHeading palette=\"info\">{heading}</NotificationHeading>\n <NotificationDescription palette=\"info\">\n {description}\n </NotificationDescription>\n </Notification>\n )\n }\n}\n\n/**\n * The hook to use the NotificationCenter.\n * @returns The notify method to trigger a notification.\n * @example\n * ```tsx\n * const {notify} = useNotificationCenter()\n * notify({\n * palette: 'info',\n * heading: 'New feature',\n * description: 'We have added a new feature to the app.',\n * })\n * ```\n */\nexport function useNotificationCenter(): NotificationsValue {\n const context = useContext(NotificationsContext)\n if (!context) {\n throw new Error(\n 'useNotificationCenter must be used within a NotificationsProvider',\n )\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,WAAW,cAAc;AAClC,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AAwJT,SAEI,KAFJ;AAxGV,IAAM,uBAAuB,cAAyC,IAAI;AAgCnE,SAAS,mBACd,OACA;AACA,QAAM,CAAC,OAAO,QAAQ,IAAI,WAAW,2BAA2B,CAAC,CAAC;AAClE,QAAM,SAAS,aAAa;AAE5B,QAAM,UAAU;AAAA,IACd,MAAM,MAAM,YAAY;AAAA,IACxB,CAAC,MAAM,QAAQ;AAAA,EACjB;AAEA,QAAM,oBAAoB;AAAA,IACxB,CAAC,OAAe;AACd,8BAAwB,UAAU;AAAA,QAChC;AAAA,QACA,OAAO;AAAA,MACT,CAAC;AACD,aAAO,WAAW,MAAM;AACtB,2BAAmB,UAAU,EAAE;AAAA,MACjC,GAAG,GAAG;AAAA,IACR;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,eAAe;AAAA,IACnB,CAAC,YAA2B;AAC1B,YAAM,KAAK,GAAG,QAAQ,OAAO,IAAI,MAA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SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Portal
|
|
3
|
+
} from "./chunk-IQJDVFPP.js";
|
|
4
|
+
import {
|
|
5
|
+
DialogBackdrop,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogPositioner
|
|
8
|
+
} from "./chunk-D7UIWAFO.js";
|
|
9
|
+
|
|
10
|
+
// src/components/dialog/dialog.tsx
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
function Dialog(props) {
|
|
13
|
+
return /* @__PURE__ */ jsxs(Portal, { children: [
|
|
14
|
+
/* @__PURE__ */ jsx(DialogBackdrop, {}),
|
|
15
|
+
/* @__PURE__ */ jsx(DialogPositioner, { children: /* @__PURE__ */ jsx(DialogContent, { ...props }) })
|
|
16
|
+
] });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
Dialog
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=chunk-C45HS2C4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/dialog/dialog.tsx"],"sourcesContent":["import type { DialogContentProps } from '@ark-ui/react/dialog'\nimport type { DialogVariantProps } from '@cerberus/styled-system/recipes'\nimport { Portal } from '../Portal'\nimport { DialogBackdrop, DialogContent, DialogPositioner } from './primitives'\n\n/**\n * This module contains and abstraction of the Dialog primitives.\n * @module 'dialog'\n */\n\nexport interface DialogProps\n extends Omit<DialogContentProps, 'size'>,\n DialogVariantProps {}\n\n/**\n * An abstraction of the Dialog primitives that controls the content of the\n * dialog. Must be used within the `DialogProvider` component.\n * @definition [Dialog docs](https://cerberus.digitalu.design/react/dialog)\n * @definition [Ark Dialog docs](https://ark-ui.com/react/docs/components/dialog)\n * @example\n * ```tsx\n * <DialogProvider>\n * <DialogTrigger asChild>\n * <Button>Open Dialog</Button>\n * </DialogTrigger>\n * <Dialog>\n * <Text>Dialog Content</Text>\n * </Dialog>\n * </DialogProvider>\n * ```\n */\nexport function Dialog(props: DialogProps) {\n return (\n <Portal>\n <DialogBackdrop />\n <DialogPositioner>\n <DialogContent {...props} />\n </DialogPositioner>\n </Portal>\n )\n}\n"],"mappings":";;;;;;;;;;AAiCI,SACE,KADF;AAFG,SAAS,OAAO,OAAoB;AACzC,SACE,qBAAC,UACC;AAAA,wBAAC,kBAAe;AAAA,IAChB,oBAAC,oBACC,8BAAC,iBAAe,GAAG,OAAO,GAC5B;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProgressBar
|
|
3
3
|
} from "./chunk-WZJ5UQNM.js";
|
|
4
|
-
import {
|
|
5
|
-
IconButton
|
|
6
|
-
} from "./chunk-APD6IX5R.js";
|
|
7
4
|
import {
|
|
8
5
|
Avatar
|
|
9
6
|
} from "./chunk-SXLPDPOZ.js";
|
|
7
|
+
import {
|
|
8
|
+
IconButton
|
|
9
|
+
} from "./chunk-APD6IX5R.js";
|
|
10
10
|
import {
|
|
11
11
|
Field
|
|
12
12
|
} from "./chunk-FBS7AX76.js";
|
|
@@ -227,4 +227,4 @@ export {
|
|
|
227
227
|
processStatus,
|
|
228
228
|
FileStatus
|
|
229
229
|
};
|
|
230
|
-
//# sourceMappingURL=chunk-
|
|
230
|
+
//# sourceMappingURL=chunk-CF3EHG42.js.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// src/components/dialog/primitives.tsx
|
|
2
|
+
import {
|
|
3
|
+
Dialog
|
|
4
|
+
} from "@ark-ui/react/dialog";
|
|
5
|
+
import { cx } from "@cerberus/styled-system/css";
|
|
6
|
+
import {
|
|
7
|
+
dialog
|
|
8
|
+
} from "@cerberus/styled-system/recipes";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
function DialogRoot(props) {
|
|
11
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { ...props });
|
|
12
|
+
}
|
|
13
|
+
function DialogTrigger(props) {
|
|
14
|
+
const styles = dialog();
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
Dialog.Trigger,
|
|
17
|
+
{
|
|
18
|
+
...props,
|
|
19
|
+
className: cx(styles.trigger, props.className)
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
function DialogBackdrop(props) {
|
|
24
|
+
const styles = dialog();
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
Dialog.Backdrop,
|
|
27
|
+
{
|
|
28
|
+
...props,
|
|
29
|
+
className: cx(styles.backdrop, props.className)
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
function DialogPositioner(props) {
|
|
34
|
+
const styles = dialog();
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
Dialog.Positioner,
|
|
37
|
+
{
|
|
38
|
+
...props,
|
|
39
|
+
className: cx(styles.positioner, props.className)
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function DialogContent(props) {
|
|
44
|
+
const { size, ...contentProps } = props;
|
|
45
|
+
const styles = dialog({ size });
|
|
46
|
+
return /* @__PURE__ */ jsx(
|
|
47
|
+
Dialog.Content,
|
|
48
|
+
{
|
|
49
|
+
...contentProps,
|
|
50
|
+
className: cx(styles.content, contentProps.className)
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
function DialogHeading(props) {
|
|
55
|
+
const styles = dialog();
|
|
56
|
+
return /* @__PURE__ */ jsx(Dialog.Title, { ...props, className: cx(styles.title, props.className) });
|
|
57
|
+
}
|
|
58
|
+
function DialogDescription(props) {
|
|
59
|
+
const styles = dialog();
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
Dialog.Description,
|
|
62
|
+
{
|
|
63
|
+
...props,
|
|
64
|
+
className: cx(styles.description, props.className)
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function DialogCloseTrigger(props) {
|
|
69
|
+
return /* @__PURE__ */ jsx(Dialog.CloseTrigger, { ...props });
|
|
70
|
+
}
|
|
71
|
+
var DialogProvider = DialogRoot;
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
DialogRoot,
|
|
75
|
+
DialogTrigger,
|
|
76
|
+
DialogBackdrop,
|
|
77
|
+
DialogPositioner,
|
|
78
|
+
DialogContent,
|
|
79
|
+
DialogHeading,
|
|
80
|
+
DialogDescription,
|
|
81
|
+
DialogCloseTrigger,
|
|
82
|
+
DialogProvider
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=chunk-D7UIWAFO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/dialog/primitives.tsx"],"sourcesContent":["import {\n Dialog,\n type DialogBackdropProps,\n type DialogContentProps,\n type DialogDescriptionProps,\n type DialogPositionerProps,\n type DialogRootProps,\n type DialogTitleProps,\n type DialogTriggerProps,\n} from '@ark-ui/react/dialog'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n dialog,\n type DialogVariantProps,\n} from '@cerberus/styled-system/recipes'\n\n/**\n * This module contains the primitives of the Dialog component.\n * @module 'dialog/primitives'\n */\n\n/**\n * The provider that controls the dialog components.\n */\nexport function DialogRoot(props: DialogRootProps) {\n return <Dialog.Root {...props} />\n}\n\n/**\n * The trigger that opens the dialog.\n */\nexport function DialogTrigger(props: DialogTriggerProps) {\n const styles = dialog()\n return (\n <Dialog.Trigger\n {...props}\n className={cx(styles.trigger, props.className)}\n />\n )\n}\n\n/**\n * The overlay of the dialog.\n */\nexport function DialogBackdrop(props: DialogBackdropProps) {\n const styles = dialog()\n return (\n <Dialog.Backdrop\n {...props}\n className={cx(styles.backdrop, props.className)}\n />\n )\n}\n\n/**\n * The container that positions the dialog.\n */\nexport function DialogPositioner(props: DialogPositionerProps) {\n const styles = dialog()\n return (\n <Dialog.Positioner\n {...props}\n className={cx(styles.positioner, props.className)}\n />\n )\n}\n\n/**\n * The visible content of the dialog.\n */\nexport function DialogContent(props: DialogContentProps & DialogVariantProps) {\n const { size, ...contentProps } = props\n const styles = dialog({ size })\n return (\n <Dialog.Content\n {...contentProps}\n className={cx(styles.content, contentProps.className)}\n />\n )\n}\n\n/**\n * The heading of the dialog.\n */\nexport function DialogHeading(props: DialogTitleProps) {\n const styles = dialog()\n return (\n <Dialog.Title {...props} className={cx(styles.title, props.className)} />\n )\n}\n\n/**\n * The description of the dialog.\n */\nexport function DialogDescription(props: DialogDescriptionProps) {\n const styles = dialog()\n return (\n <Dialog.Description\n {...props}\n className={cx(styles.description, props.className)}\n />\n )\n}\n\n/**\n * The trigger that closes the dialog.\n */\nexport function DialogCloseTrigger(props: DialogTriggerProps) {\n return <Dialog.CloseTrigger {...props} />\n}\n\n/**\n * The provider that controls the dialog components. This is a named export of\n * the DialogRoot primitive.\n */\nexport const DialogProvider = DialogRoot\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAQK;AACP,SAAS,UAAU;AACnB;AAAA,EACE;AAAA,OAEK;AAWE;AADF,SAAS,WAAW,OAAwB;AACjD,SAAO,oBAAC,OAAO,MAAP,EAAa,GAAG,OAAO;AACjC;AAKO,SAAS,cAAc,OAA2B;AACvD,QAAM,SAAS,OAAO;AACtB,SACE;AAAA,IAAC,OAAO;AAAA,IAAP;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,OAAO,SAAS,MAAM,SAAS;AAAA;AAAA,EAC/C;AAEJ;AAKO,SAAS,eAAe,OAA4B;AACzD,QAAM,SAAS,OAAO;AACtB,SACE;AAAA,IAAC,OAAO;AAAA,IAAP;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,OAAO,UAAU,MAAM,SAAS;AAAA;AAAA,EAChD;AAEJ;AAKO,SAAS,iBAAiB,OAA8B;AAC7D,QAAM,SAAS,OAAO;AACtB,SACE;AAAA,IAAC,OAAO;AAAA,IAAP;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,OAAO,YAAY,MAAM,SAAS;AAAA;AAAA,EAClD;AAEJ;AAKO,SAAS,cAAc,OAAgD;AAC5E,QAAM,EAAE,MAAM,GAAG,aAAa,IAAI;AAClC,QAAM,SAAS,OAAO,EAAE,KAAK,CAAC;AAC9B,SACE;AAAA,IAAC,OAAO;AAAA,IAAP;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,OAAO,SAAS,aAAa,SAAS;AAAA;AAAA,EACtD;AAEJ;AAKO,SAAS,cAAc,OAAyB;AACrD,QAAM,SAAS,OAAO;AACtB,SACE,oBAAC,OAAO,OAAP,EAAc,GAAG,OAAO,WAAW,GAAG,OAAO,OAAO,MAAM,SAAS,GAAG;AAE3E;AAKO,SAAS,kBAAkB,OAA+B;AAC/D,QAAM,SAAS,OAAO;AACtB,SACE;AAAA,IAAC,OAAO;AAAA,IAAP;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,OAAO,aAAa,MAAM,SAAS;AAAA;AAAA,EACnD;AAEJ;AAKO,SAAS,mBAAmB,OAA2B;AAC5D,SAAO,oBAAC,OAAO,cAAP,EAAqB,GAAG,OAAO;AACzC;AAMO,IAAM,iBAAiB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-DJOYRUNT.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DialogBackdrop,
|
|
3
|
+
DialogCloseTrigger,
|
|
4
|
+
DialogContent,
|
|
5
|
+
DialogDescription,
|
|
6
|
+
DialogHeading,
|
|
7
|
+
DialogPositioner,
|
|
8
|
+
DialogRoot,
|
|
9
|
+
DialogTrigger
|
|
10
|
+
} from "./chunk-D7UIWAFO.js";
|
|
11
|
+
|
|
12
|
+
// src/components/dialog/parts.ts
|
|
13
|
+
var DialogParts = {
|
|
14
|
+
Root: DialogRoot,
|
|
15
|
+
Trigger: DialogTrigger,
|
|
16
|
+
Backdrop: DialogBackdrop,
|
|
17
|
+
Positioner: DialogPositioner,
|
|
18
|
+
Content: DialogContent,
|
|
19
|
+
Heading: DialogHeading,
|
|
20
|
+
Description: DialogDescription,
|
|
21
|
+
CloseTrigger: DialogCloseTrigger
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
DialogParts
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-FCSO6N2Y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/dialog/parts.ts"],"sourcesContent":["import type { ElementType } from 'react'\nimport {\n DialogBackdrop,\n DialogCloseTrigger,\n DialogContent,\n DialogDescription,\n DialogHeading,\n DialogPositioner,\n DialogRoot,\n DialogTrigger,\n} from './primitives'\n\n/**\n * This module contains the parts of the Dialog component.\n * @module 'dialog/parts'\n */\n\ninterface DialogPartsValue {\n /**\n * The context provider of the dialog.\n */\n Root: ElementType\n /**\n * The trigger that opens the dialog.\n */\n Trigger: ElementType\n /**\n * The overlay of the dialog.\n */\n Backdrop: ElementType\n /**\n * The container that positions the dialog.\n */\n Positioner: ElementType\n /**\n * The visible content of the dialog.\n */\n Content: ElementType\n /**\n * The heading of the dialog.\n */\n Heading: ElementType\n /**\n * The description of the dialog.\n */\n Description: ElementType\n /**\n * The trigger that closes the dialog.\n */\n CloseTrigger: ElementType\n}\n\n/**\n * An Object containing the parts of the dialog component. For users that\n * prefer Object component syntax.\n *\n * @remarks\n *\n * When using object component syntax, you import the DialogParts object and\n * the entire family of components vs. only what you use.\n */\nexport const DialogParts: DialogPartsValue = {\n Root: DialogRoot,\n Trigger: DialogTrigger,\n Backdrop: DialogBackdrop,\n Positioner: DialogPositioner,\n Content: DialogContent,\n Heading: DialogHeading,\n Description: DialogDescription,\n CloseTrigger: DialogCloseTrigger,\n}\n"],"mappings":";;;;;;;;;;;;AA6DO,IAAM,cAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,aAAa;AAAA,EACb,cAAc;AAChB;","names":[]}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
Avatar
|
|
3
|
+
} from "./chunk-SXLPDPOZ.js";
|
|
4
|
+
import {
|
|
5
|
+
Dialog
|
|
6
|
+
} from "./chunk-C45HS2C4.js";
|
|
7
|
+
import {
|
|
3
8
|
DialogCloseTrigger,
|
|
4
9
|
DialogDescription,
|
|
5
10
|
DialogHeading,
|
|
6
11
|
DialogProvider
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
Avatar
|
|
10
|
-
} from "./chunk-SXLPDPOZ.js";
|
|
12
|
+
} from "./chunk-D7UIWAFO.js";
|
|
11
13
|
import {
|
|
12
14
|
useCerberusContext
|
|
13
15
|
} from "./chunk-GITT5645.js";
|
|
@@ -155,4 +157,4 @@ export {
|
|
|
155
157
|
ConfirmModal,
|
|
156
158
|
useConfirmModal
|
|
157
159
|
};
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
160
|
+
//# sourceMappingURL=chunk-MTZDZXZM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/confirm-modal.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { Button } from '../components/button/button'\nimport { css } from '@cerberus/styled-system/css'\nimport { Show } from '../components/Show'\nimport { Avatar } from '../components/Avatar'\nimport { HStack, VStack } from '@cerberus/styled-system/jsx'\nimport { useCerberusContext } from './cerberus'\nimport {\n Dialog,\n DialogCloseTrigger,\n DialogDescription,\n DialogHeading,\n DialogProvider,\n} from '../components/
|
|
1
|
+
{"version":3,"sources":["../../src/context/confirm-modal.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { Button } from '../components/button/button'\nimport { css } from '@cerberus/styled-system/css'\nimport { Show } from '../components/Show'\nimport { Avatar } from '../components/Avatar'\nimport { HStack, VStack } from '@cerberus/styled-system/jsx'\nimport { useCerberusContext } from './cerberus'\nimport {\n Dialog,\n DialogCloseTrigger,\n DialogDescription,\n DialogHeading,\n DialogProvider,\n} from '../components/dialog'\n\n/**\n * This module provides a context and hook for the confirm modal.\n * @module\n */\n\nexport interface BaseConfirmOptions {\n /**\n * The heading of the confirm modal.\n */\n heading: string\n /**\n * The text for the action button.\n */\n actionText: string\n /**\n * The text for the cancel button.\n */\n cancelText: string\n}\n\nexport interface DestructiveConfirmOptions extends BaseConfirmOptions {\n /**\n * The kind of confirm modal to show.\n */\n kind?: 'destructive'\n /**\n * The description of the confirm modal. Can only be a string for destructive confirm modals.\n */\n description?: string\n}\n\nexport interface NonDestructiveConfirmModalOptions extends BaseConfirmOptions {\n /**\n * The kind of confirm modal to show.\n * @default 'non-destructive'\n */\n kind?: 'non-destructive'\n /**\n * The description of the confirm modal. Can be a ReactNode for non-destructive kind if you need to display text links.\n * @example\n * ```tsx\n * description: <>Use a Fragment because we put the content within a Paragraph tag.</>\n */\n description?: ReactNode\n}\n\nexport type ShowConfirmModalOptions =\n | NonDestructiveConfirmModalOptions\n | DestructiveConfirmOptions\n\nexport type ShowResult =\n | ((value: boolean | PromiseLike<boolean>) => void)\n | null\n\nexport interface ConfirmModalValue {\n show: (options: ShowConfirmModalOptions) => Promise<boolean>\n}\n\nconst ConfirmModalContext = createContext<ConfirmModalValue | null>(null)\n\nexport type ConfirmModalProviderProps = PropsWithChildren<unknown>\n\n/**\n * Provides a confirm modal to the app.\n * @see https://cerberus.digitalu.design/react/confirm-modal\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <ConfirmModal>\n * <SomeFeatureSection />\n * </ConfirmModal>\n *\n * // Use the hook to show the confirm modal.\n * const confirm = useConfirmModal()\n *\n * const handleClick = useCallback(async () => {\n * const userConsent = await confirm.show({\n * heading: 'Add new payment method?',\n * description:\n * 'This will add a new payment method to your account to be billed for future purchases.',\n * actionText: 'Yes, add payment method',\n * cancelText: 'No, cancel',\n * })\n * setConsent(userConsent)\n * }, [confirm])\n * ```\n */\nexport function ConfirmModal(\n props: PropsWithChildren<ConfirmModalProviderProps>,\n) {\n const [open, setOpen] = useState<boolean>(false)\n const [content, setContent] = useState<ShowConfirmModalOptions | null>(null)\n const resolveRef = useRef<ShowResult>(null)\n const kind = content?.kind ?? 'non-destructive'\n\n const { icons } = useCerberusContext()\n const { confirmModal: ConfirmIcon } = icons\n\n const palette = useMemo(\n () => (kind === 'destructive' ? 'danger' : 'action'),\n [kind],\n )\n\n const handleChoice = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n const target = e.currentTarget as HTMLButtonElement\n if (target.value === 'true') {\n resolveRef.current?.(true)\n }\n resolveRef.current?.(false)\n setOpen(false)\n },\n [setOpen],\n )\n\n const handleShow = useCallback(\n (options: ShowConfirmModalOptions) => {\n return new Promise<boolean>((resolve) => {\n setContent({ ...options })\n setOpen(true)\n resolveRef.current = resolve\n })\n },\n [setOpen, setContent],\n )\n\n const value = useMemo(\n () => ({\n show: handleShow,\n }),\n [handleShow],\n )\n\n return (\n <ConfirmModalContext.Provider value={value}>\n {props.children}\n\n <DialogProvider open={open} onOpenChange={(e) => setOpen(e.open)}>\n <Dialog size=\"sm\">\n <VStack gap=\"xl\" w=\"full\">\n <VStack alignItems=\"flex-start\" gap=\"md\" w=\"full\">\n <HStack\n alignSelf=\"center\"\n justify=\"center\"\n paddingBlockEnd=\"md\"\n w=\"full\"\n >\n <Show\n when={palette === 'danger'}\n fallback={\n <Avatar\n ariaLabel=\"\"\n gradient=\"charon-light\"\n icon={<ConfirmIcon size={24} />}\n src=\"\"\n />\n }\n >\n <Avatar\n ariaLabel=\"\"\n gradient=\"hades-dark\"\n icon={<ConfirmIcon size={24} />}\n src=\"\"\n />\n </Show>\n </HStack>\n <DialogHeading>{content?.heading}</DialogHeading>\n <DialogDescription>{content?.description}</DialogDescription>\n </VStack>\n\n <HStack gap=\"4\" w=\"full\">\n <Button\n autoFocus\n className={css({\n w: '1/2',\n })}\n name=\"confirm\"\n onClick={handleChoice}\n palette={palette}\n value=\"true\"\n >\n {content?.actionText}\n </Button>\n <DialogCloseTrigger asChild>\n <Button\n className={css({\n w: '1/2',\n })}\n name=\"cancel\"\n onClick={handleChoice}\n usage=\"outlined\"\n value=\"false\"\n >\n {content?.cancelText}\n </Button>\n </DialogCloseTrigger>\n </HStack>\n </VStack>\n </Dialog>\n </DialogProvider>\n </ConfirmModalContext.Provider>\n )\n}\n\nexport function useConfirmModal(): ConfirmModalValue {\n const context = useContext(ConfirmModalContext)\n if (context === null) {\n throw new Error(\n 'useConfirmModal must be used within a ConfirmModal Provider',\n )\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP,SAAS,WAAW;AAGpB,SAAS,QAAQ,cAAc;AAsJnB,SAagB,KAbhB;AAlFZ,IAAM,sBAAsB,cAAwC,IAAI;AA6BjE,SAAS,aACd,OACA;AACA,QAAM,CAAC,MAAM,OAAO,IAAI,SAAkB,KAAK;AAC/C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAyC,IAAI;AAC3E,QAAM,aAAa,OAAmB,IAAI;AAC1C,QAAM,OAAO,SAAS,QAAQ;AAE9B,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,EAAE,cAAc,YAAY,IAAI;AAEtC,QAAM,UAAU;AAAA,IACd,MAAO,SAAS,gBAAgB,WAAW;AAAA,IAC3C,CAAC,IAAI;AAAA,EACP;AAEA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