@cdx-ui/primitives 0.0.1-alpha.22 → 0.0.1-alpha.24

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.
Files changed (126) hide show
  1. package/lib/commonjs/dialog/context.js +11 -0
  2. package/lib/commonjs/dialog/context.js.map +1 -0
  3. package/lib/commonjs/dialog/createDialogBody.js +21 -0
  4. package/lib/commonjs/dialog/createDialogBody.js.map +1 -0
  5. package/lib/commonjs/dialog/createDialogClose.js +37 -0
  6. package/lib/commonjs/dialog/createDialogClose.js.map +1 -0
  7. package/lib/commonjs/dialog/createDialogContent.js +141 -0
  8. package/lib/commonjs/dialog/createDialogContent.js.map +1 -0
  9. package/lib/commonjs/dialog/createDialogDescription.js +30 -0
  10. package/lib/commonjs/dialog/createDialogDescription.js.map +1 -0
  11. package/lib/commonjs/dialog/createDialogFooter.js +21 -0
  12. package/lib/commonjs/dialog/createDialogFooter.js.map +1 -0
  13. package/lib/commonjs/dialog/createDialogHeader.js +21 -0
  14. package/lib/commonjs/dialog/createDialogHeader.js.map +1 -0
  15. package/lib/commonjs/dialog/createDialogRoot.js +54 -0
  16. package/lib/commonjs/dialog/createDialogRoot.js.map +1 -0
  17. package/lib/commonjs/dialog/createDialogTitle.js +21 -0
  18. package/lib/commonjs/dialog/createDialogTitle.js.map +1 -0
  19. package/lib/commonjs/dialog/createDialogTrigger.js +37 -0
  20. package/lib/commonjs/dialog/createDialogTrigger.js.map +1 -0
  21. package/lib/commonjs/dialog/index.js +60 -0
  22. package/lib/commonjs/dialog/index.js.map +1 -0
  23. package/lib/commonjs/dialog/types.js +6 -0
  24. package/lib/commonjs/dialog/types.js.map +1 -0
  25. package/lib/commonjs/index.js +12 -0
  26. package/lib/commonjs/index.js.map +1 -1
  27. package/lib/commonjs/overlay/OverlayContainer.js +3 -8
  28. package/lib/commonjs/overlay/OverlayContainer.js.map +1 -1
  29. package/lib/commonjs/overlay/index.js +7 -0
  30. package/lib/commonjs/overlay/index.js.map +1 -1
  31. package/lib/commonjs/overlay/useEscapeKey.js +14 -0
  32. package/lib/commonjs/overlay/useEscapeKey.js.map +1 -0
  33. package/lib/commonjs/overlay/useEscapeKey.web.js +30 -0
  34. package/lib/commonjs/overlay/useEscapeKey.web.js.map +1 -0
  35. package/lib/commonjs/utils/createPortal.js +23 -0
  36. package/lib/commonjs/utils/createPortal.js.map +1 -0
  37. package/lib/module/dialog/context.js +5 -0
  38. package/lib/module/dialog/context.js.map +1 -0
  39. package/lib/module/dialog/createDialogBody.js +15 -0
  40. package/lib/module/dialog/createDialogBody.js.map +1 -0
  41. package/lib/module/dialog/createDialogClose.js +31 -0
  42. package/lib/module/dialog/createDialogClose.js.map +1 -0
  43. package/lib/module/dialog/createDialogContent.js +136 -0
  44. package/lib/module/dialog/createDialogContent.js.map +1 -0
  45. package/lib/module/dialog/createDialogDescription.js +24 -0
  46. package/lib/module/dialog/createDialogDescription.js.map +1 -0
  47. package/lib/module/dialog/createDialogFooter.js +15 -0
  48. package/lib/module/dialog/createDialogFooter.js.map +1 -0
  49. package/lib/module/dialog/createDialogHeader.js +15 -0
  50. package/lib/module/dialog/createDialogHeader.js.map +1 -0
  51. package/lib/module/dialog/createDialogRoot.js +49 -0
  52. package/lib/module/dialog/createDialogRoot.js.map +1 -0
  53. package/lib/module/dialog/createDialogTitle.js +15 -0
  54. package/lib/module/dialog/createDialogTitle.js.map +1 -0
  55. package/lib/module/dialog/createDialogTrigger.js +31 -0
  56. package/lib/module/dialog/createDialogTrigger.js.map +1 -0
  57. package/lib/module/dialog/index.js +45 -0
  58. package/lib/module/dialog/index.js.map +1 -0
  59. package/lib/module/dialog/types.js +4 -0
  60. package/lib/module/dialog/types.js.map +1 -0
  61. package/lib/module/index.js +1 -0
  62. package/lib/module/index.js.map +1 -1
  63. package/lib/module/overlay/OverlayContainer.js +1 -6
  64. package/lib/module/overlay/OverlayContainer.js.map +1 -1
  65. package/lib/module/overlay/index.js +1 -0
  66. package/lib/module/overlay/index.js.map +1 -1
  67. package/lib/module/overlay/useEscapeKey.js +10 -0
  68. package/lib/module/overlay/useEscapeKey.js.map +1 -0
  69. package/lib/module/overlay/useEscapeKey.web.js +27 -0
  70. package/lib/module/overlay/useEscapeKey.web.js.map +1 -0
  71. package/lib/module/utils/createPortal.js +19 -0
  72. package/lib/module/utils/createPortal.js.map +1 -0
  73. package/lib/typescript/dialog/context.d.ts +6 -0
  74. package/lib/typescript/dialog/context.d.ts.map +1 -0
  75. package/lib/typescript/dialog/createDialogBody.d.ts +4 -0
  76. package/lib/typescript/dialog/createDialogBody.d.ts.map +1 -0
  77. package/lib/typescript/dialog/createDialogClose.d.ts +4 -0
  78. package/lib/typescript/dialog/createDialogClose.d.ts.map +1 -0
  79. package/lib/typescript/dialog/createDialogContent.d.ts +4 -0
  80. package/lib/typescript/dialog/createDialogContent.d.ts.map +1 -0
  81. package/lib/typescript/dialog/createDialogDescription.d.ts +4 -0
  82. package/lib/typescript/dialog/createDialogDescription.d.ts.map +1 -0
  83. package/lib/typescript/dialog/createDialogFooter.d.ts +4 -0
  84. package/lib/typescript/dialog/createDialogFooter.d.ts.map +1 -0
  85. package/lib/typescript/dialog/createDialogHeader.d.ts +4 -0
  86. package/lib/typescript/dialog/createDialogHeader.d.ts.map +1 -0
  87. package/lib/typescript/dialog/createDialogRoot.d.ts +4 -0
  88. package/lib/typescript/dialog/createDialogRoot.d.ts.map +1 -0
  89. package/lib/typescript/dialog/createDialogTitle.d.ts +4 -0
  90. package/lib/typescript/dialog/createDialogTitle.d.ts.map +1 -0
  91. package/lib/typescript/dialog/createDialogTrigger.d.ts +4 -0
  92. package/lib/typescript/dialog/createDialogTrigger.d.ts.map +1 -0
  93. package/lib/typescript/dialog/index.d.ts +18 -0
  94. package/lib/typescript/dialog/index.d.ts.map +1 -0
  95. package/lib/typescript/dialog/types.d.ts +52 -0
  96. package/lib/typescript/dialog/types.d.ts.map +1 -0
  97. package/lib/typescript/index.d.ts +1 -0
  98. package/lib/typescript/index.d.ts.map +1 -1
  99. package/lib/typescript/overlay/OverlayContainer.d.ts.map +1 -1
  100. package/lib/typescript/overlay/index.d.ts +1 -0
  101. package/lib/typescript/overlay/index.d.ts.map +1 -1
  102. package/lib/typescript/overlay/useEscapeKey.d.ts +6 -0
  103. package/lib/typescript/overlay/useEscapeKey.d.ts.map +1 -0
  104. package/lib/typescript/overlay/useEscapeKey.web.d.ts +6 -0
  105. package/lib/typescript/overlay/useEscapeKey.web.d.ts.map +1 -0
  106. package/lib/typescript/utils/createPortal.d.ts +11 -0
  107. package/lib/typescript/utils/createPortal.d.ts.map +1 -0
  108. package/package.json +2 -2
  109. package/src/dialog/context.tsx +4 -0
  110. package/src/dialog/createDialogBody.tsx +11 -0
  111. package/src/dialog/createDialogClose.tsx +27 -0
  112. package/src/dialog/createDialogContent.tsx +122 -0
  113. package/src/dialog/createDialogDescription.tsx +20 -0
  114. package/src/dialog/createDialogFooter.tsx +11 -0
  115. package/src/dialog/createDialogHeader.tsx +11 -0
  116. package/src/dialog/createDialogRoot.tsx +66 -0
  117. package/src/dialog/createDialogTitle.tsx +11 -0
  118. package/src/dialog/createDialogTrigger.tsx +27 -0
  119. package/src/dialog/index.tsx +93 -0
  120. package/src/dialog/types.ts +88 -0
  121. package/src/index.ts +1 -0
  122. package/src/overlay/OverlayContainer.tsx +2 -10
  123. package/src/overlay/index.ts +1 -0
  124. package/src/overlay/useEscapeKey.ts +7 -0
  125. package/src/overlay/useEscapeKey.web.ts +27 -0
  126. package/src/utils/createPortal.ts +20 -0
@@ -1 +1 @@
1
- {"version":3,"names":["OverlayContainer","useAnchorPosition","useDismissOverlay","useOverlayPosition","OverlayInsetsProvider"],"sourceRoot":"../../../src","sources":["overlay/index.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,iBAAiB,QAA2B,qBAAqB;AAC1E,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SACEC,kBAAkB,EAElBC,qBAAqB,QAEhB,sBAAsB","ignoreList":[]}
1
+ {"version":3,"names":["OverlayContainer","useAnchorPosition","useDismissOverlay","useEscapeKey","useOverlayPosition","OverlayInsetsProvider"],"sourceRoot":"../../../src","sources":["overlay/index.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,iBAAiB,QAA2B,qBAAqB;AAC1E,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SACEC,kBAAkB,EAElBC,qBAAqB,QAEhB,sBAAsB","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ /* eslint-disable @typescript-eslint/no-unused-vars */
4
+
5
+ /**
6
+ * No-op on native — Escape key dismissal is not applicable.
7
+ * Native uses the system back gesture / hardware button via Modal.
8
+ */
9
+ export function useEscapeKey(_open, _onEscape) {}
10
+ //# sourceMappingURL=useEscapeKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEscapeKey","_open","_onEscape"],"sourceRoot":"../../../src","sources":["overlay/useEscapeKey.ts"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAYA,CAACC,KAAc,EAAEC,SAAqB,EAAE,CAAC","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ import { useEffect, useRef } from 'react';
4
+
5
+ /**
6
+ * Closes an overlay when the user presses the Escape key.
7
+ * Web-only — native platforms use Modal's `onRequestClose` for back/dismiss.
8
+ */
9
+ export function useEscapeKey(open, onEscape) {
10
+ const onEscapeRef = useRef(onEscape);
11
+ onEscapeRef.current = onEscape;
12
+ useEffect(() => {
13
+ if (!open) {
14
+ return;
15
+ }
16
+ const handleKeyDown = e => {
17
+ if (e.key === 'Escape') {
18
+ onEscapeRef.current();
19
+ }
20
+ };
21
+ document.addEventListener('keydown', handleKeyDown);
22
+ return () => {
23
+ document.removeEventListener('keydown', handleKeyDown);
24
+ };
25
+ }, [open]);
26
+ }
27
+ //# sourceMappingURL=useEscapeKey.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useRef","useEscapeKey","open","onEscape","onEscapeRef","current","handleKeyDown","e","key","document","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["overlay/useEscapeKey.web.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;;AAEzC;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,IAAa,EAAEC,QAAoB,EAAE;EAChE,MAAMC,WAAW,GAAGJ,MAAM,CAACG,QAAQ,CAAC;EACpCC,WAAW,CAACC,OAAO,GAAGF,QAAQ;EAE9BJ,SAAS,CAAC,MAAM;IACd,IAAI,CAACG,IAAI,EAAE;MACT;IACF;IAEA,MAAMI,aAAa,GAAIC,CAAgB,IAAK;MAC1C,IAAIA,CAAC,CAACC,GAAG,KAAK,QAAQ,EAAE;QACtBJ,WAAW,CAACC,OAAO,CAAC,CAAC;MACvB;IACF,CAAC;IAEDI,QAAQ,CAACC,gBAAgB,CAAC,SAAS,EAAEJ,aAAa,CAAC;IACnD,OAAO,MAAM;MACXG,QAAQ,CAACE,mBAAmB,CAAC,SAAS,EAAEL,aAAa,CAAC;IACxD,CAAC;EACH,CAAC,EAAE,CAACJ,IAAI,CAAC,CAAC;AACZ","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ import { Platform } from 'react-native';
4
+ /**
5
+ * A reference to `ReactDOM.createPortal` on web, `undefined` on native.
6
+ *
7
+ * Loaded lazily via `require` so that native bundles never reference
8
+ * `react-dom`, which would cause a build error on native platforms.
9
+ */
10
+ export const createPortalFn = (() => {
11
+ if (Platform.OS !== 'web') return undefined;
12
+ try {
13
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
14
+ return require('react-dom').createPortal;
15
+ } catch {
16
+ return undefined;
17
+ }
18
+ })();
19
+ //# sourceMappingURL=createPortal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","createPortalFn","OS","undefined","require","createPortal"],"sourceRoot":"../../../src","sources":["utils/createPortal.ts"],"mappings":";;AACA,SAASA,QAAQ,QAAQ,cAAc;AAIvC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAA0C,GAAG,CAAC,MAAM;EAC/D,IAAID,QAAQ,CAACE,EAAE,KAAK,KAAK,EAAE,OAAOC,SAAS;EAC3C,IAAI;IACF;IACA,OAAQC,OAAO,CAAC,WAAW,CAAC,CAAsCC,YAAY;EAChF,CAAC,CAAC,MAAM;IACN,OAAOF,SAAS;EAClB;AACF,CAAC,EAAE,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { IDialogContextType } from './types';
2
+ export declare const DialogProvider: import("react").FunctionComponent<{
3
+ children: import("react").ReactNode;
4
+ value: IDialogContextType;
5
+ }>, useDialog: () => IDialogContextType;
6
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/dialog/context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,eAAO,MAAO,cAAc;;;IAAE,SAAS,0BAAsD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { IDialogBodyProps } from './types';
3
+ export declare const createDialogBody: <T>(BaseBody: React.ComponentType<T>) => React.ForwardRefExoticComponent<IDialogBodyProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createDialogBody.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDialogBody.d.ts","sourceRoot":"","sources":["../../../src/dialog/createDialogBody.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAG,UAAU,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,qFAOjE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { IDialogCloseProps } from './types';
3
+ export declare const createDialogClose: <T>(BaseClose: React.ComponentType<T>) => React.ForwardRefExoticComponent<IDialogCloseProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createDialogClose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDialogClose.d.ts","sourceRoot":"","sources":["../../../src/dialog/createDialogClose.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGjD,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAG,WAAW,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,sFAsBpE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type React from 'react';
2
+ import type { IDialogContentProps } from './types';
3
+ export declare const createDialogContent: <ContentProps, OverlayProps>(BaseContent: React.ComponentType<ContentProps>, BaseOverlay: React.ComponentType<OverlayProps>) => React.ForwardRefExoticComponent<IDialogContentProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createDialogContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDialogContent.d.ts","sourceRoot":"","sources":["../../../src/dialog/createDialogContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,eAAO,MAAM,mBAAmB,GAAI,YAAY,EAAE,YAAY,EAC5D,aAAa,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,EAC9C,aAAa,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,wFAiG5C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { IDialogDescriptionProps } from './types';
3
+ export declare const createDialogDescription: <T>(BaseDescription: React.ComponentType<T>) => React.ForwardRefExoticComponent<IDialogDescriptionProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createDialogDescription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDialogDescription.d.ts","sourceRoot":"","sources":["../../../src/dialog/createDialogDescription.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,eAAO,MAAM,uBAAuB,GAAI,CAAC,EAAG,iBAAiB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,4FAc/E,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { IDialogFooterProps } from './types';
3
+ export declare const createDialogFooter: <T>(BaseFooter: React.ComponentType<T>) => React.ForwardRefExoticComponent<IDialogFooterProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createDialogFooter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDialogFooter.d.ts","sourceRoot":"","sources":["../../../src/dialog/createDialogFooter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAG,YAAY,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,uFAOrE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { IDialogHeaderProps } from './types';
3
+ export declare const createDialogHeader: <T>(BaseHeader: React.ComponentType<T>) => React.ForwardRefExoticComponent<IDialogHeaderProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createDialogHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDialogHeader.d.ts","sourceRoot":"","sources":["../../../src/dialog/createDialogHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAG,YAAY,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,uFAOrE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type React from 'react';
2
+ import type { IDialogRootProps } from './types';
3
+ export declare const createDialogRoot: <T>(BaseRoot: React.ComponentType<T>) => React.ForwardRefExoticComponent<IDialogRootProps & React.RefAttributes<T>>;
4
+ //# sourceMappingURL=createDialogRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDialogRoot.d.ts","sourceRoot":"","sources":["../../../src/dialog/createDialogRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAG,UAAU,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,+EA0DlE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { IDialogTitleProps } from './types';
3
+ export declare const createDialogTitle: <T>(BaseTitle: React.ComponentType<T>) => React.ForwardRefExoticComponent<IDialogTitleProps & React.RefAttributes<unknown>>;
4
+ //# sourceMappingURL=createDialogTitle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDialogTitle.d.ts","sourceRoot":"","sources":["../../../src/dialog/createDialogTitle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAG,WAAW,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,sFAOnE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { IDialogTriggerProps } from './types';
3
+ export declare const createDialogTrigger: <T>(BaseTrigger: React.ComponentType<T>) => React.ForwardRefExoticComponent<IDialogTriggerProps & React.RefAttributes<T>>;
4
+ //# sourceMappingURL=createDialogTrigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createDialogTrigger.d.ts","sourceRoot":"","sources":["../../../src/dialog/createDialogTrigger.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGnD,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAG,aAAa,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,kFAsBxE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type React from 'react';
2
+ import { DialogProvider, useDialog } from './context';
3
+ import type { IDialogComponentType } from './types';
4
+ export { DialogProvider, useDialog };
5
+ export type { IDialogContextType, IDialogRootProps, IDialogTriggerProps, IDialogContentProps, IDialogOverlayProps, IDialogHeaderProps, IDialogTitleProps, IDialogDescriptionProps, IDialogBodyProps, IDialogFooterProps, IDialogCloseProps, } from './types';
6
+ export declare function createDialog<RootProps, TriggerProps, ContentProps, OverlayProps, HeaderProps, TitleProps, DescriptionProps, BodyProps, FooterProps, CloseProps>(BaseComponents: {
7
+ Root: React.ComponentType<RootProps>;
8
+ Trigger: React.ComponentType<TriggerProps>;
9
+ Content: React.ComponentType<ContentProps>;
10
+ Overlay: React.ComponentType<OverlayProps>;
11
+ Header: React.ComponentType<HeaderProps>;
12
+ Title: React.ComponentType<TitleProps>;
13
+ Description: React.ComponentType<DescriptionProps>;
14
+ Body: React.ComponentType<BodyProps>;
15
+ Footer: React.ComponentType<FooterProps>;
16
+ Close: React.ComponentType<CloseProps>;
17
+ }): IDialogComponentType<RootProps, TriggerProps, ContentProps, HeaderProps, TitleProps, DescriptionProps, BodyProps, FooterProps, CloseProps>;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3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xC,GA+BO,oBAAoB,CACxB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,UAAU,CACX,CACF"}
@@ -0,0 +1,52 @@
1
+ import type { PropsWithoutRef, RefAttributes } from 'react';
2
+ import type { PressableProps, TextProps, ViewProps } from 'react-native';
3
+ export interface IDialogContextType {
4
+ readonly open: boolean;
5
+ readonly onOpenChange: (open: boolean) => void;
6
+ readonly closeOnBackdropPress: boolean;
7
+ readonly closeOnEscKey: boolean;
8
+ readonly nativeID: string;
9
+ readonly role: 'dialog' | 'alertdialog';
10
+ }
11
+ export interface IDialogRootProps {
12
+ readonly open?: boolean;
13
+ readonly onOpenChange?: (open: boolean) => void;
14
+ readonly defaultOpen?: boolean;
15
+ readonly closeOnBackdropPress?: boolean;
16
+ readonly closeOnEscKey?: boolean;
17
+ readonly role?: 'dialog' | 'alertdialog';
18
+ readonly children: React.ReactNode;
19
+ }
20
+ export interface IDialogTriggerProps extends PressableProps {
21
+ readonly asChild?: boolean;
22
+ }
23
+ export interface IDialogContentProps extends ViewProps {
24
+ readonly forceMount?: boolean;
25
+ }
26
+ export interface IDialogOverlayProps extends PressableProps {
27
+ }
28
+ export interface IDialogHeaderProps extends ViewProps {
29
+ }
30
+ export interface IDialogTitleProps extends TextProps {
31
+ }
32
+ export interface IDialogDescriptionProps extends TextProps {
33
+ }
34
+ export interface IDialogBodyProps extends ViewProps {
35
+ }
36
+ export interface IDialogFooterProps extends ViewProps {
37
+ }
38
+ export interface IDialogCloseProps extends PressableProps {
39
+ readonly asChild?: boolean;
40
+ readonly accessibilityLabel?: string;
41
+ }
42
+ export type IDialogComponentType<RootProps, TriggerProps, ContentProps, HeaderProps, TitleProps, DescriptionProps, BodyProps, FooterProps, CloseProps, ContentRef = unknown, TriggerRef = unknown, CloseRef = unknown> = React.ForwardRefExoticComponent<PropsWithoutRef<RootProps & IDialogRootProps> & RefAttributes<unknown>> & {
43
+ Trigger: React.ForwardRefExoticComponent<PropsWithoutRef<TriggerProps & IDialogTriggerProps> & RefAttributes<TriggerRef>>;
44
+ Content: React.ForwardRefExoticComponent<PropsWithoutRef<ContentProps & IDialogContentProps> & RefAttributes<ContentRef>>;
45
+ Header: React.ForwardRefExoticComponent<PropsWithoutRef<HeaderProps & IDialogHeaderProps> & RefAttributes<unknown>>;
46
+ Title: React.ForwardRefExoticComponent<PropsWithoutRef<TitleProps & IDialogTitleProps> & RefAttributes<unknown>>;
47
+ Description: React.ForwardRefExoticComponent<PropsWithoutRef<DescriptionProps & IDialogDescriptionProps> & RefAttributes<unknown>>;
48
+ Body: React.ForwardRefExoticComponent<PropsWithoutRef<BodyProps & IDialogBodyProps> & RefAttributes<unknown>>;
49
+ Footer: React.ForwardRefExoticComponent<PropsWithoutRef<FooterProps & IDialogFooterProps> & RefAttributes<unknown>>;
50
+ Close: React.ForwardRefExoticComponent<PropsWithoutRef<CloseProps & IDialogCloseProps> & RefAttributes<CloseRef>>;
51
+ };
52
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dialog/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;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og';
4
5
  export * from './input';
5
6
  export * from './link';
6
7
  export { type EdgeInsets, OverlayInsetsProvider } from './overlay';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,KAAK,UAAU,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACnE,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,KAAK,UAAU,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACnE,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"OverlayContainer.d.ts","sourceRoot":"","sources":["../../../src/overlay/OverlayContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAIL,KAAK,SAAS,EAGd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAW/E,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,QAAQ,EACR,OAAO,EACP,KAAK,EACL,QAAQ,GACT,EAAE,QAAQ,CAAC,qBAAqB,CAAC,2CAyBjC"}
1
+ {"version":3,"file":"OverlayContainer.d.ts","sourceRoot":"","sources":["../../../src/overlay/OverlayContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAML,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAG/E,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,QAAQ,EACR,OAAO,EACP,KAAK,EACL,QAAQ,GACT,EAAE,QAAQ,CAAC,qBAAqB,CAAC,2CAyBjC"}
@@ -2,5 +2,6 @@ export { OverlayContainer } from './OverlayContainer';
2
2
  export type { OverlayContainerProps } from './OverlayContainer';
3
3
  export { useAnchorPosition, type AnchorLayout } from './useAnchorPosition';
4
4
  export { useDismissOverlay } from './useDismissOverlay';
5
+ export { useEscapeKey } from './useEscapeKey';
5
6
  export { useOverlayPosition, type OverlayPosition, OverlayInsetsProvider, type EdgeInsets, } from './useOverlayPosition';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/overlay/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,UAAU,GAChB,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/overlay/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,UAAU,GAChB,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * No-op on native — Escape key dismissal is not applicable.
3
+ * Native uses the system back gesture / hardware button via Modal.
4
+ */
5
+ export declare function useEscapeKey(_open: boolean, _onEscape: () => void): void;
6
+ //# sourceMappingURL=useEscapeKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEscapeKey.d.ts","sourceRoot":"","sources":["../../../src/overlay/useEscapeKey.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,QAAI"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Closes an overlay when the user presses the Escape key.
3
+ * Web-only — native platforms use Modal's `onRequestClose` for back/dismiss.
4
+ */
5
+ export declare function useEscapeKey(open: boolean, onEscape: () => void): void;
6
+ //# sourceMappingURL=useEscapeKey.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEscapeKey.web.d.ts","sourceRoot":"","sources":["../../../src/overlay/useEscapeKey.web.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,QAoB/D"}
@@ -0,0 +1,11 @@
1
+ import type React from 'react';
2
+ type CreatePortalFn = (children: React.ReactNode, container: Element) => React.ReactPortal;
3
+ /**
4
+ * A reference to `ReactDOM.createPortal` on web, `undefined` on native.
5
+ *
6
+ * Loaded lazily via `require` so that native bundles never reference
7
+ * `react-dom`, which would cause a build error on native platforms.
8
+ */
9
+ export declare const createPortalFn: CreatePortalFn | undefined;
10
+ export {};
11
+ //# sourceMappingURL=createPortal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createPortal.d.ts","sourceRoot":"","sources":["../../../src/utils/createPortal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,KAAK,KAAK,CAAC,WAAW,CAAC;AAE3F;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,cAAc,GAAG,SAQ1C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdx-ui/primitives",
3
- "version": "0.0.1-alpha.22",
3
+ "version": "0.0.1-alpha.24",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "module": "lib/module/index.js",
6
6
  "react-native": "src/index.ts",
@@ -52,7 +52,7 @@
52
52
  "@react-native-aria/interactions": "^0.2.16",
53
53
  "@react-stately/checkbox": "3.7.4",
54
54
  "@react-stately/toggle": "3.9.4",
55
- "@cdx-ui/utils": "0.0.1-alpha.22"
55
+ "@cdx-ui/utils": "0.0.1-alpha.24"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/react": "*",
@@ -0,0 +1,4 @@
1
+ import { createContext } from '@cdx-ui/utils';
2
+ import type { IDialogContextType } from './types';
3
+
4
+ export const [DialogProvider, useDialog] = createContext<IDialogContextType>('DialogContext');
@@ -0,0 +1,11 @@
1
+ import React, { forwardRef } from 'react';
2
+ import type { IDialogBodyProps } from './types';
3
+
4
+ export const createDialogBody = <T,>(BaseBody: React.ComponentType<T>) =>
5
+ forwardRef<unknown, IDialogBodyProps>(({ children, ...props }, ref) => {
6
+ return (
7
+ <BaseBody ref={ref} {...(props as T)}>
8
+ {children}
9
+ </BaseBody>
10
+ );
11
+ });
@@ -0,0 +1,27 @@
1
+ import React, { forwardRef } from 'react';
2
+ import type { IDialogCloseProps } from './types';
3
+ import { useDialog } from './context';
4
+
5
+ export const createDialogClose = <T,>(BaseClose: React.ComponentType<T>) =>
6
+ forwardRef<unknown, IDialogCloseProps>(
7
+ ({ asChild = false, children, onPress, ...props }, ref) => {
8
+ const { onOpenChange } = useDialog();
9
+
10
+ const handlePress = (e?: any) => {
11
+ onPress?.(e);
12
+ onOpenChange(false);
13
+ };
14
+
15
+ if (asChild && React.isValidElement(children)) {
16
+ return React.cloneElement(children as React.ReactElement<any>, {
17
+ onPress: handlePress,
18
+ });
19
+ }
20
+
21
+ return (
22
+ <BaseClose ref={ref} {...(props as T)} onPress={handlePress}>
23
+ {children}
24
+ </BaseClose>
25
+ );
26
+ },
27
+ );
@@ -0,0 +1,122 @@
1
+ import type React from 'react';
2
+ import { forwardRef, useCallback } from 'react';
3
+ import { Modal, Platform, StyleSheet, View } from 'react-native';
4
+ import { FocusScope } from '@react-native-aria/focus';
5
+ import { useEscapeKey } from '../overlay';
6
+ import { createPortalFn } from '../utils/createPortal';
7
+ import { dataAttributes } from '../utils/dataAttributes';
8
+ import { useDialog } from './context';
9
+ import type { IDialogContentProps } from './types';
10
+
11
+ export const createDialogContent = <ContentProps, OverlayProps>(
12
+ BaseContent: React.ComponentType<ContentProps>,
13
+ BaseOverlay: React.ComponentType<OverlayProps>,
14
+ ) =>
15
+ forwardRef(({ children, forceMount = false, ...props }: IDialogContentProps, ref?: any) => {
16
+ const { open, onOpenChange, closeOnBackdropPress, closeOnEscKey, nativeID, role } = useDialog();
17
+
18
+ const handleClose = useCallback(() => {
19
+ onOpenChange(false);
20
+ }, [onOpenChange]);
21
+
22
+ useEscapeKey(open && closeOnEscKey, handleClose);
23
+
24
+ if (!(open || forceMount)) {
25
+ return null;
26
+ }
27
+
28
+ const overlayProps = {
29
+ ...(closeOnBackdropPress ? { onPress: handleClose } : {}),
30
+ accessible: false,
31
+ importantForAccessibility: 'no-hide-descendants' as const,
32
+ ...dataAttributes({ slot: 'dialog-overlay' }),
33
+ };
34
+
35
+ const contentSlotAttrs = dataAttributes({
36
+ slot: 'dialog-content',
37
+ state: open ? 'open' : 'closed',
38
+ });
39
+
40
+ const ariaProps = {
41
+ role,
42
+ 'aria-modal': true,
43
+ 'aria-labelledby': `${nativeID}-title`,
44
+ 'aria-describedby': `${nativeID}-description`,
45
+ };
46
+
47
+ if (Platform.OS === 'web' && createPortalFn) {
48
+ return createPortalFn(
49
+ <FocusScope contain={open} restoreFocus autoFocus={open}>
50
+ <View
51
+ style={{
52
+ position: 'fixed' as any,
53
+ inset: 0 as any,
54
+ zIndex: 50,
55
+ display: 'flex' as any,
56
+ alignItems: 'center',
57
+ justifyContent: 'center',
58
+ }}
59
+ >
60
+ <BaseOverlay {...(overlayProps as any)} />
61
+ <BaseContent
62
+ ref={ref}
63
+ {...contentSlotAttrs}
64
+ {...(props as ContentProps)}
65
+ {...ariaProps}
66
+ >
67
+ {children}
68
+ </BaseContent>
69
+ </View>
70
+ </FocusScope>,
71
+ document.body,
72
+ );
73
+ }
74
+
75
+ // Native layout uses two layers to support both backdrop dismiss and
76
+ // scrollable body content. The overlay Pressable fills the Modal via
77
+ // absolute positioning and handles backdrop taps. A second absolute-fill
78
+ // View with pointerEvents="box-none" centers the content panel — "box-none"
79
+ // lets taps outside the panel pass through to the overlay while allowing
80
+ // the panel and its children to receive touches normally.
81
+ //
82
+ // Critically, the content panel must NOT claim the JS touch responder
83
+ // (e.g. via onStartShouldSetResponder). Doing so triggers React Native's
84
+ // blockNativeResponder, which suppresses the native UIScrollView /
85
+ // ScrollView pan gesture recognizer and breaks any ScrollView inside
86
+ // Dialog.Body.
87
+ //
88
+ // Static StyleSheet used here because these are structural layout concerns
89
+ // of the primitive's modal chrome — not themeable styles. They must remain
90
+ // stable regardless of the styled layer's className.
91
+ return (
92
+ <Modal visible={open} transparent statusBarTranslucent onRequestClose={handleClose}>
93
+ <FocusScope contain={open} restoreFocus autoFocus={open}>
94
+ <View style={styles.fill}>
95
+ <BaseOverlay {...(overlayProps as any)} />
96
+ <View style={styles.center} pointerEvents="box-none">
97
+ <BaseContent
98
+ ref={ref}
99
+ {...contentSlotAttrs}
100
+ {...(props as ContentProps)}
101
+ {...ariaProps}
102
+ >
103
+ {children}
104
+ </BaseContent>
105
+ </View>
106
+ </View>
107
+ </FocusScope>
108
+ </Modal>
109
+ );
110
+ });
111
+
112
+ // Structural layout for the native Modal chrome. These are not themeable —
113
+ // they position the overlay and centering layers that the primitive manages
114
+ // internally. Matches the pattern in OverlayContainer.tsx.
115
+ const styles = StyleSheet.create({
116
+ fill: { flex: 1 },
117
+ center: {
118
+ ...StyleSheet.absoluteFillObject,
119
+ alignItems: 'center',
120
+ justifyContent: 'center',
121
+ },
122
+ });
@@ -0,0 +1,20 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { dataAttributes } from '../utils/dataAttributes';
3
+ import { useDialog } from './context';
4
+ import type { IDialogDescriptionProps } from './types';
5
+
6
+ export const createDialogDescription = <T,>(BaseDescription: React.ComponentType<T>) =>
7
+ forwardRef<unknown, IDialogDescriptionProps>(({ children, ...props }, ref) => {
8
+ const { nativeID } = useDialog();
9
+
10
+ return (
11
+ <BaseDescription
12
+ ref={ref}
13
+ nativeID={`${nativeID}-description`}
14
+ {...(props as T)}
15
+ {...dataAttributes({ slot: 'dialog-description' })}
16
+ >
17
+ {children}
18
+ </BaseDescription>
19
+ );
20
+ });
@@ -0,0 +1,11 @@
1
+ import React, { forwardRef } from 'react';
2
+ import type { IDialogFooterProps } from './types';
3
+
4
+ export const createDialogFooter = <T,>(BaseFooter: React.ComponentType<T>) =>
5
+ forwardRef<unknown, IDialogFooterProps>(({ children, ...props }, ref) => {
6
+ return (
7
+ <BaseFooter ref={ref} {...(props as T)}>
8
+ {children}
9
+ </BaseFooter>
10
+ );
11
+ });
@@ -0,0 +1,11 @@
1
+ import React, { forwardRef } from 'react';
2
+ import type { IDialogHeaderProps } from './types';
3
+
4
+ export const createDialogHeader = <T,>(BaseHeader: React.ComponentType<T>) =>
5
+ forwardRef<unknown, IDialogHeaderProps>(({ children, ...props }, ref) => {
6
+ return (
7
+ <BaseHeader ref={ref} {...(props as T)}>
8
+ {children}
9
+ </BaseHeader>
10
+ );
11
+ });