@codeleap/web 3.24.2 → 3.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/package.json +2 -1
  2. package/src/components/ActionIcon/index.tsx +51 -52
  3. package/src/components/ActionIcon/styles.ts +1 -5
  4. package/src/components/ActionIcon/types.ts +15 -0
  5. package/src/components/ActivityIndicator/index.tsx +34 -55
  6. package/src/components/ActivityIndicator/styles.ts +0 -6
  7. package/src/components/ActivityIndicator/types.ts +12 -0
  8. package/src/components/Badge/index.tsx +43 -80
  9. package/src/components/Badge/styles.ts +1 -11
  10. package/src/components/Badge/types.ts +28 -0
  11. package/src/components/Button/index.tsx +46 -89
  12. package/src/components/Button/styles.ts +0 -5
  13. package/src/components/Button/types.ts +25 -0
  14. package/src/components/Checkbox/index.tsx +83 -97
  15. package/src/components/Checkbox/styles.ts +1 -5
  16. package/src/components/Checkbox/types.ts +15 -0
  17. package/src/components/Collapse/index.tsx +41 -83
  18. package/src/components/Collapse/styles.ts +3 -6
  19. package/src/components/Collapse/types.ts +11 -0
  20. package/src/components/ColorPicker/index.tsx +95 -48
  21. package/src/components/ColorPicker/styles.ts +11 -11
  22. package/src/components/ColorPicker/types.ts +26 -12
  23. package/src/components/CropPicker/index.tsx +100 -102
  24. package/src/components/CropPicker/styles.ts +0 -7
  25. package/src/components/CropPicker/types.ts +10 -15
  26. package/src/components/DatePicker/{defaultComponents → components}/Header.tsx +9 -17
  27. package/src/components/DatePicker/{defaultComponents → components}/OuterInput.tsx +6 -7
  28. package/src/components/DatePicker/index.tsx +110 -124
  29. package/src/components/DatePicker/styles.ts +1 -12
  30. package/src/components/DatePicker/types.ts +16 -33
  31. package/src/components/Drawer/index.tsx +133 -125
  32. package/src/components/Drawer/styles.ts +0 -5
  33. package/src/components/Drawer/types.ts +23 -0
  34. package/src/components/Dropzone/index.tsx +87 -63
  35. package/src/components/Dropzone/styles.ts +0 -6
  36. package/src/components/Dropzone/types.ts +29 -37
  37. package/src/components/EmptyPlaceholder/index.tsx +63 -83
  38. package/src/components/EmptyPlaceholder/styles.ts +0 -5
  39. package/src/components/EmptyPlaceholder/types.ts +32 -0
  40. package/src/components/FileInput/index.tsx +72 -0
  41. package/src/components/FileInput/types.ts +14 -0
  42. package/src/components/Grid/index.tsx +40 -41
  43. package/src/components/Grid/styles.ts +2 -9
  44. package/src/components/Grid/types.ts +10 -12
  45. package/src/components/Icon/index.tsx +45 -47
  46. package/src/components/Icon/styles.ts +0 -8
  47. package/src/components/Icon/types.ts +15 -0
  48. package/src/components/InputBase/index.tsx +71 -42
  49. package/src/components/InputBase/styles.ts +37 -47
  50. package/src/components/InputBase/types.ts +19 -7
  51. package/src/components/InputBase/utils.ts +3 -23
  52. package/src/components/List/ListLayout.tsx +20 -37
  53. package/src/components/List/index.tsx +36 -41
  54. package/src/components/List/styles.ts +5 -11
  55. package/src/components/List/types.ts +30 -20
  56. package/src/components/LoadingOverlay/index.tsx +31 -33
  57. package/src/components/LoadingOverlay/styles.ts +3 -8
  58. package/src/components/LoadingOverlay/types.ts +16 -0
  59. package/src/components/Modal/index.tsx +98 -160
  60. package/src/components/Modal/styles.ts +0 -5
  61. package/src/components/Modal/types.ts +55 -0
  62. package/src/components/NumberIncrement/index.tsx +67 -98
  63. package/src/components/NumberIncrement/styles.ts +0 -5
  64. package/src/components/NumberIncrement/types.ts +29 -0
  65. package/src/components/Overlay/index.tsx +37 -35
  66. package/src/components/Overlay/styles.ts +3 -5
  67. package/src/components/Overlay/types.ts +13 -0
  68. package/src/components/Pager/index.tsx +65 -81
  69. package/src/components/Pager/styles.ts +3 -9
  70. package/src/components/Pager/types.ts +35 -0
  71. package/src/components/PaginationButtons/index.tsx +173 -0
  72. package/src/components/PaginationButtons/styles.ts +7 -0
  73. package/src/components/PaginationButtons/types.ts +26 -0
  74. package/src/components/PaginationIndicator/index.tsx +69 -0
  75. package/src/components/PaginationIndicator/styles.ts +3 -0
  76. package/src/components/PaginationIndicator/types.ts +18 -0
  77. package/src/components/Progress/Bar/index.tsx +45 -50
  78. package/src/components/Progress/Bar/styles.ts +10 -0
  79. package/src/components/Progress/Bar/types.ts +26 -0
  80. package/src/components/Progress/Circle/index.tsx +45 -48
  81. package/src/components/Progress/Circle/styles.ts +1 -8
  82. package/src/components/Progress/Circle/types.ts +10 -22
  83. package/src/components/RadioInput/index.tsx +78 -124
  84. package/src/components/RadioInput/styles.ts +0 -6
  85. package/src/components/RadioInput/types.ts +29 -0
  86. package/src/components/SearchInput/index.tsx +10 -10
  87. package/src/components/SectionFilters/index.tsx +47 -36
  88. package/src/components/SectionFilters/styles.ts +1 -5
  89. package/src/components/SectionFilters/types.ts +14 -13
  90. package/src/components/SegmentedControl/index.tsx +111 -89
  91. package/src/components/SegmentedControl/styles.ts +7 -21
  92. package/src/components/SegmentedControl/types.ts +44 -0
  93. package/src/components/Select/index.tsx +92 -56
  94. package/src/components/Select/styles.ts +19 -36
  95. package/src/components/Select/types.ts +15 -10
  96. package/src/components/Slider/index.tsx +85 -93
  97. package/src/components/Slider/styles.ts +13 -6
  98. package/src/components/Slider/types.ts +29 -0
  99. package/src/components/Switch/index.tsx +63 -74
  100. package/src/components/Switch/styles.ts +1 -6
  101. package/src/components/Switch/types.ts +13 -0
  102. package/src/components/Tag/index.tsx +39 -44
  103. package/src/components/Tag/styles.ts +1 -9
  104. package/src/components/Tag/types.ts +10 -10
  105. package/src/components/Text/index.tsx +37 -48
  106. package/src/components/Text/styles.ts +0 -8
  107. package/src/components/Text/types.ts +8 -8
  108. package/src/components/TextEditor/index.tsx +49 -28
  109. package/src/components/TextEditor/styles.ts +1 -8
  110. package/src/components/TextEditor/types.ts +11 -6
  111. package/src/components/TextInput/index.tsx +58 -96
  112. package/src/components/TextInput/mask.tsx +2 -50
  113. package/src/components/TextInput/styles.ts +3 -8
  114. package/src/components/TextInput/types.ts +85 -0
  115. package/src/components/Tooltip/index.tsx +61 -84
  116. package/src/components/Tooltip/styles.ts +3 -10
  117. package/src/components/Tooltip/types.ts +46 -0
  118. package/src/components/Touchable/index.tsx +43 -86
  119. package/src/components/Touchable/styles.ts +0 -6
  120. package/src/components/Touchable/types.ts +22 -0
  121. package/src/components/View/index.tsx +36 -50
  122. package/src/components/View/styles.ts +0 -6
  123. package/src/components/View/types.ts +14 -15
  124. package/src/components/components.ts +2 -3
  125. package/src/index.ts +1 -0
  126. package/src/lib/WebStyleRegistry.ts +51 -0
  127. package/src/lib/hooks/index.ts +5 -0
  128. package/src/lib/hooks/useBreakpointMatch.ts +8 -7
  129. package/src/{components/CropPicker/useCropPicker.tsx → lib/hooks/useCropPicker.ts} +66 -13
  130. package/src/lib/hooks/useFileInput.ts +15 -0
  131. package/src/lib/hooks/useInfiniteScroll.ts +77 -0
  132. package/src/lib/hooks/useMediaQuery.ts +4 -3
  133. package/src/lib/hooks/usePagination.ts +79 -63
  134. package/src/lib/hooks/useRefresh.ts +87 -0
  135. package/src/lib/hooks/useStylesFor.ts +13 -0
  136. package/src/lib/index.ts +1 -0
  137. package/src/lib/utils/cache.ts +9 -0
  138. package/src/lib/utils/index.ts +1 -0
  139. package/src/lib/utils/test.ts +2 -2
  140. package/src/components/CropPicker/utils.ts +0 -51
  141. package/src/components/FileInput.tsx +0 -91
  142. package/src/components/List/PaginationIndicator.tsx +0 -102
  143. package/src/components/List/useInfiniteScroll.ts +0 -159
  144. package/src/components/Progress/Bar/styles.tsx +0 -7
  145. package/src/components/Progress/Bar/types.tsx +0 -30
  146. package/src/components/Scroll/index.tsx +0 -32
  147. package/src/components/Scroll/styles.ts +0 -8
  148. package/src/components/SegmentedControl/SegmentedControlOption.tsx +0 -84
  149. package/src/components/defaultStyles.ts +0 -79
  150. /package/src/components/DatePicker/{defaultComponents → components}/index.tsx +0 -0
@@ -1,90 +1,31 @@
1
- /** @jsx jsx */
2
- import { jsx, CSSObject } from '@emotion/react'
3
- import {
4
- AnyFunction,
5
- ComponentVariants,
6
- IconPlaceholder,
7
- TypeGuards,
8
- onMount,
9
- onUpdate,
10
- useDefaultComponentStyle,
11
- useNestedStylesByKey,
12
- StylesOf,
13
- PropsOf,
14
- useIsomorphicEffect,
15
- } from '@codeleap/common'
16
-
1
+ import { TypeGuards, onMount, onUpdate, useIsomorphicEffect } from '@codeleap/common'
17
2
  import React, { useId, useRef } from 'react'
18
3
  import ReactDOM from 'react-dom'
19
4
  import { v4 } from 'uuid'
20
5
  import { View } from '../View'
21
6
  import { Text } from '../Text'
22
- import { Overlay, OverlayProps } from '../Overlay'
23
- import { ModalComposition, ModalPresets } from './styles'
24
- import { ActionIcon, ActionIconProps } from '../ActionIcon'
25
- import { Scroll } from '../Scroll'
26
- import { ComponentCommonProps } from '../../types'
27
- import { Touchable, TouchableProps } from '../Touchable'
7
+ import { Overlay } from '../Overlay'
8
+ import { ActionIcon } from '../ActionIcon'
9
+ import { Touchable } from '../Touchable'
28
10
  import { modalScrollLock, ModalStore } from '../../lib/tools/modal'
11
+ import { ModalHeaderProps, ModalProps } from './types'
12
+ import { useStylesFor } from '../../lib/hooks/useStylesFor'
13
+ import { WebStyleRegistry } from '../../lib/WebStyleRegistry'
14
+ import { AnyRecord, AppIcon, IJSX, StyledComponentProps, useNestedStylesByKey } from '@codeleap/styles'
29
15
 
30
16
  export * from './styles'
31
-
32
- export type ModalProps =
33
- {
34
- visible?: boolean
35
- children?: React.ReactNode
36
- title?: React.ReactNode | string
37
- description?: React.ReactNode | string
38
- renderModalBody?: (props: ModalBodyProps) => React.ReactElement
39
- toggle?: AnyFunction
40
- styles?: StylesOf<ModalComposition>
41
- style?: React.CSSProperties
42
- accessible?: boolean
43
- showClose?: boolean
44
- closable?: boolean
45
- dismissOnBackdrop?: boolean
46
- scroll?: boolean
47
- header?: React.ReactElement
48
- footer?: React.ReactNode
49
- withOverlay?: boolean
50
- closeIconName?: IconPlaceholder
51
- keepMounted?: boolean
52
- renderHeader?: (props: ModalHeaderProps) => React.ReactElement
53
- debugName?: string
54
- closeButtonProps?: Partial<ActionIconProps>
55
- closeOnEscape?: boolean
56
- onClose?: () => void
57
- overlayProps?: Partial<OverlayProps>
58
- zIndex?: number
59
- withScrollContainer?: boolean
60
- scrollLock?: boolean
61
- backdropProps?: Partial<TouchableProps>
62
- alterHistory?: boolean
63
- modalId?: string
64
- autoIndex?: boolean
65
- } & ComponentVariants<typeof ModalPresets> & ComponentCommonProps
17
+ export * from './types'
66
18
 
67
19
  function focusModal(event: FocusEvent, id: string) {
68
- event.preventDefault()
20
+ event?.preventDefault()
69
21
  const modal = document.getElementById(id)
70
22
  if (modal) modal.focus()
71
23
  }
72
24
 
73
- type ModalBodyProps = {
74
- id: string
75
- variantStyles: PropsOf<ModalComposition>
76
- }
77
-
78
- type ModalHeaderProps = Partial<Omit<ModalProps, 'children'>> & {
79
- id: string
80
- variantStyles: PropsOf<ModalComposition>
81
- onPressClose: () => void
82
- }
83
-
84
25
  const ModalDefaultHeader = (props: ModalHeaderProps) => {
85
26
  const {
86
27
  id,
87
- variantStyles,
28
+ styles,
88
29
  title,
89
30
  showClose,
90
31
  closable,
@@ -95,7 +36,7 @@ const ModalDefaultHeader = (props: ModalHeaderProps) => {
95
36
  debugName,
96
37
  } = props
97
38
 
98
- const closeButtonStyles = useNestedStylesByKey('closeButton', variantStyles)
39
+ const closeButtonStyles = useNestedStylesByKey('closeButton', styles)
99
40
 
100
41
  const showCloseButton = showClose && closable
101
42
 
@@ -107,98 +48,67 @@ const ModalDefaultHeader = (props: ModalHeaderProps) => {
107
48
  <View
108
49
  id={`${id}-header`}
109
50
  component='header'
110
- css={variantStyles.header}
51
+ style={styles.header}
111
52
  className='modal-header header'
112
53
  >
113
- <View id={`${id}-title`} css={variantStyles.titleWrapper}>
54
+ <View id={`${id}-title`} style={styles.titleWrapper}>
114
55
  {TypeGuards.isString(title) ? (
115
- <Text debugName={debugName} text={title} css={variantStyles.title} />
116
- ) : (
117
- title
118
- )}
56
+ <Text debugName={debugName} text={title} style={styles.title} />
57
+ ) : title}
119
58
 
120
- {showCloseButton && (
59
+ {showCloseButton ? (
121
60
  <ActionIcon
122
61
  debugName={debugName}
123
- icon={closeIconName as IconPlaceholder}
62
+ icon={closeIconName as AppIcon}
124
63
  onPress={onPressClose}
125
64
  {...closeButtonProps}
126
- styles={closeButtonStyles}
65
+ style={closeButtonStyles}
127
66
  />
128
- )}
67
+ ) : null}
129
68
  </View>
130
69
 
131
70
  {TypeGuards.isString(description) ? (
132
- <Text debugName={debugName} text={description} style={variantStyles.description} />
133
- ) : (
134
- description
135
- )}
71
+ <Text debugName={debugName} text={description} style={styles.description} />
72
+ ) : description}
136
73
  </View>
137
74
  )
138
75
  }
139
76
 
140
- const defaultProps: Partial<ModalProps> = {
141
- title: '',
142
- closeIconName: 'x' as IconPlaceholder,
143
- closable: true,
144
- withOverlay: true,
145
- showClose: true,
146
- scroll: false,
147
- closeOnEscape: true,
148
- renderHeader: ModalDefaultHeader,
149
- keepMounted: true,
150
- dismissOnBackdrop: true,
151
- zIndex: null,
152
- description: null,
153
- withScrollContainer: false,
154
- scrollLock: false,
155
- autoIndex: false,
156
- alterHistory: false,
157
- }
158
-
159
- export const ModalContent = (
160
- modalProps: ModalProps & { id: string },
161
- ) => {
77
+ export const ModalContent = (modalProps: ModalProps & { id: string }) => {
162
78
  const {
163
79
  children,
164
80
  visible,
165
81
  title,
166
82
  toggle,
167
- variants = [],
168
- styles,
169
83
  footer,
170
- style = {},
84
+ style,
171
85
  renderHeader: ModalHeader,
172
86
  closable,
173
87
  withOverlay,
174
88
  showClose,
175
- responsiveVariants = {},
176
89
  closeIconName,
177
90
  scroll,
178
91
  renderModalBody,
179
92
  closeOnEscape,
180
93
  onClose,
181
- overlayProps = {},
94
+ overlayProps,
182
95
  dismissOnBackdrop,
183
96
  zIndex,
184
97
  withScrollContainer,
185
98
  debugName,
186
- backdropProps = {},
99
+ backdropProps,
187
100
  alterHistory,
188
101
  id: modalId,
189
102
  autoIndex,
190
103
  ...props
191
104
  } = modalProps
192
105
 
106
+ const styles = useStylesFor(Modal.styleRegistryName, style)
107
+
193
108
  const index = ModalStore(store => (store.indexes?.[modalId] ?? 0))
194
109
 
195
110
  const id = useId()
196
111
  const modalRef = useRef(null)
197
- const variantStyles = useDefaultComponentStyle<'u:Modal', typeof ModalPresets>('u:Modal', {
198
- responsiveVariants,
199
- variants,
200
- styles,
201
- })
202
112
 
203
113
  const toggleAndReturn = () => {
204
114
  toggle?.()
@@ -218,7 +128,7 @@ export const ModalContent = (
218
128
  }
219
129
  }
220
130
 
221
- const handleTabKeyPress = (e: React.KeyboardEvent<HTMLDivElement>, { firstElement, lastElement }: Record<'firstElement' |'lastElement', HTMLDivElement>) => {
131
+ const handleTabKeyPress = (e: React.KeyboardEvent<HTMLDivElement>, { firstElement, lastElement }: Record<'firstElement' | 'lastElement', HTMLDivElement>) => {
222
132
  if (e.key === 'Tab' || e?.keyCode === 9) {
223
133
  if (e.shiftKey && document.activeElement === firstElement) {
224
134
  e.preventDefault()
@@ -256,11 +166,9 @@ export const ModalContent = (
256
166
  if (modal) modal.focus()
257
167
  }, [id])
258
168
 
259
- const close = (closable && dismissOnBackdrop) ? toggleAndReturn : () => { }
169
+ const close = (closable && dismissOnBackdrop) ? toggleAndReturn : () => null
260
170
 
261
- const ModalBody = renderModalBody || (scroll ? Scroll : View)
262
-
263
- const ModalArea = withScrollContainer ? Scroll : View
171
+ const ModalBody = renderModalBody || View
264
172
 
265
173
  const _zIndex = React.useMemo(() => {
266
174
  return TypeGuards.isNumber(zIndex) ? { zIndex } : {}
@@ -270,43 +178,34 @@ export const ModalContent = (
270
178
  <View
271
179
  ref={modalRef}
272
180
  aria-hidden={!visible}
273
- css={[
274
- variantStyles.wrapper,
275
- visible
276
- ? variantStyles['wrapper:visible']
277
- : variantStyles['wrapper:hidden'],
278
- autoIndex ? { zIndex: index } : {},
181
+ style={[
182
+ styles.wrapper,
183
+ visible ? styles['wrapper:visible'] : styles['wrapper:hidden'],
184
+ autoIndex ? { zIndex: index } : null,
279
185
  _zIndex,
280
186
  ]}
281
187
  >
282
188
  <Overlay
283
189
  debugName={debugName}
284
190
  visible={withOverlay ? visible : false}
285
- css={[
286
- variantStyles.backdrop,
287
- visible
288
- ? variantStyles['backdrop:visible']
289
- : variantStyles['backdrop:hidden'],
290
- ]}
291
191
  {...overlayProps}
192
+ style={[
193
+ styles.backdrop,
194
+ visible ? styles['backdrop:visible'] : styles['backdrop:hidden'],
195
+ ]}
292
196
  />
293
197
 
294
- <ModalArea css={variantStyles.innerWrapper}>
198
+ <View style={styles.innerWrapper}>
295
199
  <Touchable
296
- css={variantStyles.backdropPressable}
297
200
  onPress={close}
298
201
  debounce={1000}
202
+ debugName='modal backdrop'
299
203
  {...backdropProps}
204
+ style={styles.backdropPressable}
300
205
  />
206
+
301
207
  <View
302
208
  component='section'
303
- css={[
304
- variantStyles.box,
305
- visible
306
- ? variantStyles['box:visible']
307
- : variantStyles['box:hidden'],
308
- style,
309
- ]}
310
209
  className='content'
311
210
  tabIndex={0}
312
211
  id={id}
@@ -315,35 +214,35 @@ export const ModalContent = (
315
214
  aria-describedby={`${id}-title`}
316
215
  aria-label='Close the modal by pressing Escape key'
317
216
  {...props}
217
+ style={[
218
+ styles.box,
219
+ visible ? styles['box:visible'] : styles['box:hidden'],
220
+ ]}
318
221
  >
319
222
  <ModalHeader
320
223
  {...modalProps}
321
- variantStyles={variantStyles}
224
+ styles={styles}
322
225
  id={id}
323
226
  onPressClose={toggleAndReturn}
324
227
  debugName={debugName}
325
228
  />
326
229
 
327
- <ModalBody
328
- css={variantStyles.body}
329
- variantStyles={variantStyles}
330
- id={id}
331
- >
230
+ <ModalBody style={styles.body} id={id}>
332
231
  {children}
333
232
  </ModalBody>
334
233
 
335
- {footer && (
336
- <View component='footer' css={variantStyles.footer}>
234
+ {footer ? (
235
+ <View component='footer' style={styles.footer}>
337
236
  {footer}
338
237
  </View>
339
- )}
238
+ ) : null}
340
239
  </View>
341
- </ModalArea>
240
+ </View>
342
241
  </View>
343
242
  )
344
243
  }
345
244
 
346
- export const Modal = (props) => {
245
+ export const Modal = (props: ModalProps) => {
347
246
  const allProps = {
348
247
  ...Modal.defaultProps,
349
248
  ...props,
@@ -380,7 +279,7 @@ export const Modal = (props) => {
380
279
  }
381
280
 
382
281
  if (scrollLock) modalScrollLock(visible, modalId.current)
383
-
282
+
384
283
  if (autoIndex) {
385
284
  setTimeout(() => {
386
285
  setIndex(visible, modalId.current)
@@ -392,9 +291,7 @@ export const Modal = (props) => {
392
291
  }
393
292
  }, [visible])
394
293
 
395
- const content = <ModalContent {...props} visible={visible} toggle={toggle} id={modalId.current} />
396
-
397
- // if (renderStatus === 'unmounted') return null
294
+ const content = <ModalContent {...allProps} visible={visible} toggle={toggle} id={modalId.current} />
398
295
 
399
296
  if (typeof window === 'undefined') return content
400
297
 
@@ -402,7 +299,48 @@ export const Modal = (props) => {
402
299
  content,
403
300
  document.body,
404
301
  )
302
+ }
405
303
 
304
+ Modal.styleRegistryName = 'Modal'
305
+
306
+ Modal.elements = [
307
+ 'wrapper',
308
+ 'box',
309
+ 'backdrop',
310
+ 'body',
311
+ 'footer',
312
+ 'header',
313
+ 'title',
314
+ 'innerWrapper',
315
+ 'backdropPressable',
316
+ 'description',
317
+ 'titleWrapper',
318
+ `closeButton`,
319
+ ]
320
+
321
+ Modal.rootElement = 'wrapper'
322
+
323
+ Modal.withVariantTypes = <S extends AnyRecord>(styles: S) => {
324
+ return Modal as (props: StyledComponentProps<ModalProps, typeof styles>) => IJSX
406
325
  }
407
326
 
408
- Modal.defaultProps = defaultProps
327
+ Modal.defaultProps = {
328
+ title: '',
329
+ closeIconName: 'x' as AppIcon,
330
+ closable: true,
331
+ withOverlay: true,
332
+ showClose: true,
333
+ scroll: false,
334
+ closeOnEscape: true,
335
+ renderHeader: ModalDefaultHeader,
336
+ keepMounted: true,
337
+ dismissOnBackdrop: true,
338
+ zIndex: null,
339
+ description: null,
340
+ withScrollContainer: false,
341
+ scrollLock: false,
342
+ autoIndex: false,
343
+ alterHistory: false,
344
+ } as Partial<ModalProps>
345
+
346
+ WebStyleRegistry.registerComponent(Modal)
@@ -1,4 +1,3 @@
1
- import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
1
  import { ActionIconComposition } from '../ActionIcon'
3
2
 
4
3
  export type AnimatableParts = 'box' | 'backdrop' | 'wrapper'
@@ -19,7 +18,3 @@ export type ModalComposition =
19
18
  | ModalParts
20
19
  | `${AnimatableParts}:visible`
21
20
  | `${AnimatableParts}:hidden`
22
-
23
- const createModalStyle = createDefaultVariantFactory<ModalComposition>()
24
-
25
- export const ModalPresets = includePresets((style) => createModalStyle(() => ({ body: style })))
@@ -0,0 +1,55 @@
1
+ import { AnyFunction, PropsOf } from '@codeleap/common'
2
+ import React from 'react'
3
+ import { OverlayProps } from '../Overlay'
4
+ import { ModalComposition } from './styles'
5
+ import { ActionIconProps } from '../ActionIcon'
6
+ import { TouchableProps } from '../Touchable'
7
+ import { AppIcon, ICSS, StyledProp } from '@codeleap/styles'
8
+
9
+ export type ModalProps =
10
+ {
11
+ visible?: boolean
12
+ children?: React.ReactNode
13
+ title?: React.ReactNode | string
14
+ description?: React.ReactNode | string
15
+ renderModalBody?: (props: ModalBodyProps) => React.ReactElement
16
+ toggle?: AnyFunction
17
+ style?: StyledProp<ModalComposition>
18
+ accessible?: boolean
19
+ showClose?: boolean
20
+ closable?: boolean
21
+ dismissOnBackdrop?: boolean
22
+ scroll?: boolean
23
+ header?: React.ReactElement
24
+ footer?: React.ReactNode
25
+ withOverlay?: boolean
26
+ closeIconName?: AppIcon
27
+ keepMounted?: boolean
28
+ renderHeader?: (props: ModalHeaderProps) => React.ReactElement
29
+ debugName?: string
30
+ closeButtonProps?: Partial<ActionIconProps>
31
+ closeOnEscape?: boolean
32
+ onClose?: () => void
33
+ overlayProps?: Partial<OverlayProps>
34
+ zIndex?: number
35
+ withScrollContainer?: boolean
36
+ scrollLock?: boolean
37
+ backdropProps?: Partial<TouchableProps>
38
+ alterHistory?: boolean
39
+ modalId?: string
40
+ autoIndex?: boolean
41
+ }
42
+
43
+ export type ModalBodyProps = {
44
+ id: string
45
+ style: ICSS
46
+ children?: React.ReactNode
47
+ }
48
+
49
+ export type ModalHeaderProps =
50
+ Partial<Omit<ModalProps, 'children'>> &
51
+ {
52
+ id: string
53
+ styles: PropsOf<ModalComposition>
54
+ onPressClose: () => void
55
+ }