@driveflux/ui 1.0.13 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bottom-sheet/BottomSheetProvider.d.ts +4 -0
- package/dist/bottom-sheet/BottomSheetProvider.d.ts.map +1 -0
- package/dist/bottom-sheet/BottomSheetProvider.js +190 -0
- package/dist/bottom-sheet/context.d.ts +15 -0
- package/dist/bottom-sheet/context.d.ts.map +1 -0
- package/dist/bottom-sheet/context.js +6 -0
- package/dist/bottom-sheet/index.d.ts +4 -0
- package/dist/bottom-sheet/index.d.ts.map +1 -0
- package/dist/bottom-sheet/index.js +3 -0
- package/dist/bottom-sheet/use-bottom-sheet.d.ts +6 -0
- package/dist/bottom-sheet/use-bottom-sheet.d.ts.map +1 -0
- package/dist/bottom-sheet/use-bottom-sheet.js +5 -0
- package/dist/bottom-sheet/utils.d.ts +2 -0
- package/dist/bottom-sheet/utils.d.ts.map +1 -0
- package/dist/bottom-sheet/utils.js +15 -0
- package/dist/chakra.d.ts.map +1 -1
- package/dist/chakra.js +1 -0
- package/dist/modal/ModalProvider.d.ts.map +1 -1
- package/dist/modal/ModalProvider.js +1 -4
- package/dist/modal/use-enhanced-modal.d.ts.map +1 -1
- package/dist/theme/colors.d.ts.map +1 -1
- package/dist/theme/colors.js +36 -36
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/translations.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/accessors.d.ts.map +1 -1
- package/dist/utils/react.d.ts.map +1 -1
- package/package.json +30 -29
- package/.eslintrc.json +0 -3
- package/.swcrc +0 -14
- package/.turbo/turbo-build.log +0 -11
- package/CHANGELOG.md +0 -150
- package/dist/cjs/chakra.js +0 -18
- package/dist/cjs/index.js +0 -20
- package/dist/cjs/modal/ModalProvider.js +0 -255
- package/dist/cjs/modal/components/EnhancedModalCustomWrapper.js +0 -139
- package/dist/cjs/modal/components/EnhancedModalFooter.js +0 -163
- package/dist/cjs/modal/components/MinimalModalContent.js +0 -94
- package/dist/cjs/modal/components/StandardModalContent.js +0 -359
- package/dist/cjs/modal/context.js +0 -20
- package/dist/cjs/modal/index.js +0 -48
- package/dist/cjs/modal/use-enhanced-modal.js +0 -15
- package/dist/cjs/theme/colors.js +0 -147
- package/dist/cjs/theme/index.js +0 -18
- package/dist/cjs/toast/index.js +0 -19
- package/dist/cjs/toast/use-toast-result.js +0 -210
- package/dist/cjs/translations.js +0 -42
- package/dist/cjs/types.js +0 -4
- package/dist/cjs/utils/accessors.js +0 -65
- package/dist/cjs/utils/index.js +0 -19
- package/dist/cjs/utils/react.js +0 -56
- package/dist/index.js +0 -3
- package/index.cjs +0 -1
- package/index.d.ts +0 -1
- package/modal.cjs +0 -1
- package/modal.d.ts +0 -1
- package/src/chakra.ts +0 -2
- package/src/index.ts +0 -4
- package/src/modal/ModalProvider.tsx +0 -143
- package/src/modal/components/EnhancedModalCustomWrapper.tsx +0 -39
- package/src/modal/components/EnhancedModalFooter.tsx +0 -51
- package/src/modal/components/MinimalModalContent.tsx +0 -24
- package/src/modal/components/StandardModalContent.tsx +0 -65
- package/src/modal/context.tsx +0 -81
- package/src/modal/index.ts +0 -7
- package/src/modal/use-enhanced-modal.ts +0 -7
- package/src/theme/colors.ts +0 -179
- package/src/theme/index.ts +0 -1
- package/src/toast/index.ts +0 -3
- package/src/toast/use-toast-result.tsx +0 -168
- package/src/translations.ts +0 -25
- package/src/types.ts +0 -22
- package/src/utils/accessors.ts +0 -64
- package/src/utils/index.ts +0 -2
- package/src/utils/react.ts +0 -35
- package/theme.cjs +0 -1
- package/theme.d.ts +0 -1
- package/toast.cjs +0 -1
- package/toast.d.ts +0 -1
- package/translations.cjs +0 -1
- package/translations.d.ts +0 -1
- package/tsconfig.json +0 -14
- package/tsconfig.tsbuildinfo +0 -1
- package/utils.cjs +0 -1
- package/utils.d.ts +0 -1
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import isEmpty from 'lodash/isEmpty.js'
|
|
2
|
-
import { useCallback, useMemo, useState, type FC, type PropsWithChildren } from 'react'
|
|
3
|
-
import {
|
|
4
|
-
Modal,
|
|
5
|
-
ModalContent,
|
|
6
|
-
ModalOverlay,
|
|
7
|
-
useDisclosure
|
|
8
|
-
} from '../chakra.js'
|
|
9
|
-
import { isReactNode } from '../utils/react.js'
|
|
10
|
-
import MinimalModalContent from './components/MinimalModalContent.js'
|
|
11
|
-
import StandardModalContent from './components/StandardModalContent.js'
|
|
12
|
-
import { ModalContext, type ModalCloseOptions, type ModalContentConfig, type ModalContextState, type ModalControlProps, type ModalOpenOptions, type ModalOptions, type ModalUpdateOptions } from './context.js'
|
|
13
|
-
|
|
14
|
-
const getModalComponent = (modalContentConfig: ModalContentConfig, controls: ModalControlProps) => {
|
|
15
|
-
const otherProps = modalContentConfig.contentProps || {}
|
|
16
|
-
switch (modalContentConfig.type) {
|
|
17
|
-
case 'standard': {
|
|
18
|
-
return <StandardModalContent controls={controls} modalContentConfig={modalContentConfig} {...otherProps} />
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
case 'minimal': {
|
|
22
|
-
return <MinimalModalContent controls={controls} modalContentConfig={modalContentConfig} {...otherProps} />
|
|
23
|
-
}
|
|
24
|
-
case 'custom':
|
|
25
|
-
return isReactNode(modalContentConfig.content) ? modalContentConfig.content : <modalContentConfig.content open={open} close={close} {...otherProps} />
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const isModalOpenOptions = (options?: ModalOpenOptions | ModalContentConfig): options is ModalOpenOptions => {
|
|
30
|
-
return (options as ModalOpenOptions)?.modalContentConfig !== undefined
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const ModalProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
34
|
-
const { isOpen, onClose: onCloseRaw, onOpen: onOpenRaw } = useDisclosure()
|
|
35
|
-
const [modalContentConfig, setModalContentConfig] = useState<ModalContentConfig | undefined>()
|
|
36
|
-
const [modalOptions, setModalOptions] = useState<ModalOptions | undefined>()
|
|
37
|
-
const [modalState, setModalState] = useState<any>()
|
|
38
|
-
|
|
39
|
-
const onClose = useCallback((options?: ModalCloseOptions) => {
|
|
40
|
-
onCloseRaw()
|
|
41
|
-
|
|
42
|
-
if (modalOptions?.onClose) {
|
|
43
|
-
modalOptions.onClose()
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (!options?.keepModalContentConfig) {
|
|
47
|
-
setModalContentConfig(undefined)
|
|
48
|
-
setModalOptions(undefined)
|
|
49
|
-
setModalState(undefined)
|
|
50
|
-
}
|
|
51
|
-
}, [modalOptions])
|
|
52
|
-
|
|
53
|
-
const onOpen = useCallback((modalContentConfigOrOptions?: ModalOpenOptions | ModalContentConfig) => {
|
|
54
|
-
let newModalContentConfig: ModalContentConfig | undefined
|
|
55
|
-
let newModalSate: any
|
|
56
|
-
let newModalOptions: ModalOptions | undefined
|
|
57
|
-
// Here, we know we're passing the global options object
|
|
58
|
-
if (isModalOpenOptions(modalContentConfigOrOptions)) {
|
|
59
|
-
newModalContentConfig = modalContentConfigOrOptions.modalContentConfig
|
|
60
|
-
newModalSate = modalContentConfigOrOptions.modalContentConfig.initialModalState
|
|
61
|
-
newModalOptions = modalContentConfigOrOptions
|
|
62
|
-
}
|
|
63
|
-
// we will set the state only when we're passing the modal content config. Maybe the modal
|
|
64
|
-
// was closed with keepModalContentConfig set to true, so we don't want to override the state
|
|
65
|
-
else if (modalContentConfigOrOptions) {
|
|
66
|
-
newModalContentConfig = modalContentConfigOrOptions
|
|
67
|
-
newModalSate = undefined
|
|
68
|
-
newModalOptions = undefined
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
setModalContentConfig((oldModalContentConfig) => {
|
|
72
|
-
const modalContentConfig = newModalContentConfig || oldModalContentConfig
|
|
73
|
-
|
|
74
|
-
if (modalContentConfig) {
|
|
75
|
-
onOpenRaw()
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return modalContentConfig
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
setModalState(newModalSate)
|
|
82
|
-
setModalOptions(newModalOptions)
|
|
83
|
-
}, [])
|
|
84
|
-
|
|
85
|
-
const update = useCallback((updateOptions: ModalUpdateOptions) => {
|
|
86
|
-
if (!updateOptions || isEmpty(updateOptions)) {
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
setModalContentConfig((oldModalContentConfig) => {
|
|
91
|
-
if (!oldModalContentConfig) {
|
|
92
|
-
return oldModalContentConfig
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
...oldModalContentConfig,
|
|
97
|
-
...updateOptions.modalContentConfig,
|
|
98
|
-
contentProps: {
|
|
99
|
-
...updateOptions.contentProps,
|
|
100
|
-
...oldModalContentConfig.contentProps,
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
}, [])
|
|
105
|
-
|
|
106
|
-
const state = useMemo((): ModalContextState => {
|
|
107
|
-
return {
|
|
108
|
-
isOpen,
|
|
109
|
-
// TODO
|
|
110
|
-
// @ts-expect-error
|
|
111
|
-
open: onOpen,
|
|
112
|
-
close: onClose,
|
|
113
|
-
update,
|
|
114
|
-
modalState,
|
|
115
|
-
setModalState,
|
|
116
|
-
}
|
|
117
|
-
}, [onOpen, onClose, update, modalState, setModalState, isOpen])
|
|
118
|
-
|
|
119
|
-
const content = useMemo(() => modalContentConfig && getModalComponent(modalContentConfig, state), [modalContentConfig])
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<ModalContext.Provider value={state}>
|
|
123
|
-
{children}
|
|
124
|
-
{/* The modal is already rendered in a portal */}
|
|
125
|
-
<Modal
|
|
126
|
-
scrollBehavior={'inside'}
|
|
127
|
-
isCentered
|
|
128
|
-
blockScrollOnMount
|
|
129
|
-
closeOnOverlayClick
|
|
130
|
-
size={modalContentConfig?.size || { base: 'full', md: '3xl' }}
|
|
131
|
-
isOpen={isOpen}
|
|
132
|
-
onClose={onClose}
|
|
133
|
-
>
|
|
134
|
-
<ModalOverlay />
|
|
135
|
-
<ModalContent borderRadius={0}>
|
|
136
|
-
{content}
|
|
137
|
-
</ModalContent>
|
|
138
|
-
</Modal>
|
|
139
|
-
</ModalContext.Provider>
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export default ModalProvider
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import IconClose from '@driveflux/icons/icons/IconClose'
|
|
2
|
-
import type { FC, PropsWithChildren, ReactNode } from 'react'
|
|
3
|
-
import { Button, HStack, Heading, Stack, type StackProps } from '../../chakra.js'
|
|
4
|
-
import { useEnhancedModal } from '../use-enhanced-modal.js'
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
title?: ReactNode
|
|
8
|
-
isCloseHidden?: boolean
|
|
9
|
-
} & StackProps
|
|
10
|
-
|
|
11
|
-
const EnhancedModalCustomWrapper: FC<PropsWithChildren<Props>> = ({ title, children, isCloseHidden, ...props }) => {
|
|
12
|
-
const { close } = useEnhancedModal()
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<Stack overflowY={'scroll'} px={'32px'} py={'24px'} spacing={'18px'} {...props}>
|
|
16
|
-
<HStack justifyContent={'space-between'}>
|
|
17
|
-
<Heading fontSize={'18px'} textTransform={'uppercase'}>
|
|
18
|
-
{title}
|
|
19
|
-
</Heading>
|
|
20
|
-
{!isCloseHidden && (
|
|
21
|
-
<Button
|
|
22
|
-
p={0}
|
|
23
|
-
variant={'unstyled'}
|
|
24
|
-
border={0}
|
|
25
|
-
w={'fit-content'}
|
|
26
|
-
onClick={() => {
|
|
27
|
-
close()
|
|
28
|
-
}}
|
|
29
|
-
>
|
|
30
|
-
<IconClose size={'28px'} />
|
|
31
|
-
</Button>
|
|
32
|
-
)}
|
|
33
|
-
</HStack>
|
|
34
|
-
{children}
|
|
35
|
-
</Stack>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default EnhancedModalCustomWrapper
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react'
|
|
2
|
-
import { Button, ButtonProps, Stack, StackProps } from '../../chakra.js'
|
|
3
|
-
import { colors } from '../../theme/colors.js'
|
|
4
|
-
import { translations } from '../../translations.js'
|
|
5
|
-
import { useEnhancedModal } from '../use-enhanced-modal.js'
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
sticky?: boolean
|
|
9
|
-
cancelProps?: ButtonProps
|
|
10
|
-
okProps?: ButtonProps
|
|
11
|
-
children?: ReactNode
|
|
12
|
-
suffix?: ReactNode
|
|
13
|
-
} & StackProps
|
|
14
|
-
|
|
15
|
-
const EnhancedModalFooter: FC<Props> = ({ sticky, cancelProps, okProps, children, suffix, ...props }) => {
|
|
16
|
-
const { close } = useEnhancedModal()
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<Stack
|
|
20
|
-
pos={{ base: 'absolute', md: sticky ? 'absolute' : 'static' }}
|
|
21
|
-
bottom={0}
|
|
22
|
-
left={0}
|
|
23
|
-
right={0}
|
|
24
|
-
py={'32px'}
|
|
25
|
-
px={{ base: '32px', md: sticky ? '32px' : '0' }}
|
|
26
|
-
borderTop={sticky ? `1px solid ${colors.primary2}` : ''}
|
|
27
|
-
background={colors.white}
|
|
28
|
-
spacing={'24px'}
|
|
29
|
-
zIndex={'sticky'}
|
|
30
|
-
{...props}
|
|
31
|
-
>
|
|
32
|
-
{children ? (
|
|
33
|
-
<Stack direction={{ base: 'column-reverse', md: 'row' }} spacing={'24px'}>
|
|
34
|
-
{children}
|
|
35
|
-
</Stack>
|
|
36
|
-
) : (
|
|
37
|
-
<Stack direction={{ base: 'column-reverse', md: 'row' }} spacing={'24px'}>
|
|
38
|
-
<Button w={'full'} variant={'outline'} onClick={() => close()} {...cancelProps} fontSize={'10px'} fontWeight={'700'} letterSpacing={'3px'}>
|
|
39
|
-
{cancelProps?.children ? cancelProps.children : translations.cancel}
|
|
40
|
-
</Button>
|
|
41
|
-
<Button w={'full'} {...okProps} fontSize={'10px'} fontWeight={'700'} letterSpacing={'3px'}>
|
|
42
|
-
{okProps?.children ? okProps.children : translations.confirm}
|
|
43
|
-
</Button>
|
|
44
|
-
</Stack>
|
|
45
|
-
)}
|
|
46
|
-
{suffix}
|
|
47
|
-
</Stack>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default EnhancedModalFooter
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Fragment, type FC } from 'react'
|
|
2
|
-
import { Box, ModalBody, ModalCloseButton, ModalHeader } from '../../chakra.js'
|
|
3
|
-
import { isReactNode } from '../../utils/react.js'
|
|
4
|
-
import type { ModalContentConfig, ModalControlProps } from '../context.js'
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
controls: ModalControlProps
|
|
8
|
-
modalContentConfig: Extract<ModalContentConfig, { type: 'minimal' }>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const MinimalModalContent: FC<Props> = ({ controls: { open, close }, modalContentConfig, ...props }) => {
|
|
12
|
-
const Content = modalContentConfig.content
|
|
13
|
-
|
|
14
|
-
const Wrapper = modalContentConfig.noModalBody ? Fragment : ModalBody
|
|
15
|
-
return (
|
|
16
|
-
<>
|
|
17
|
-
{modalContentConfig.title ? <ModalHeader>{modalContentConfig.title}</ModalHeader> : <Box h={'32px'} />}
|
|
18
|
-
<ModalCloseButton />
|
|
19
|
-
<Wrapper>{isReactNode(Content) ? Content : <Content close={close} open={open} {...props} />}</Wrapper>
|
|
20
|
-
</>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default MinimalModalContent
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState, type FC } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Button,
|
|
4
|
-
HStack,
|
|
5
|
-
ModalBody,
|
|
6
|
-
ModalCloseButton,
|
|
7
|
-
ModalFooter,
|
|
8
|
-
ModalHeader
|
|
9
|
-
} from '../../chakra.js'
|
|
10
|
-
import { translations } from '../../translations.js'
|
|
11
|
-
import { isReactNode } from '../../utils/react.js'
|
|
12
|
-
import type { ModalContentConfig, ModalControlProps } from '../context.js'
|
|
13
|
-
import { useEnhancedModal } from '../use-enhanced-modal.js'
|
|
14
|
-
|
|
15
|
-
type Props = {
|
|
16
|
-
controls: ModalControlProps
|
|
17
|
-
modalContentConfig: Extract<ModalContentConfig, { type: 'standard' }>
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const StandardModalContent: FC<Props> = ({ controls: { open, close }, modalContentConfig, ...props }) => {
|
|
21
|
-
const Content = modalContentConfig.content
|
|
22
|
-
const [isSaving, setIsSaving] = useState(false)
|
|
23
|
-
const { modalState } = useEnhancedModal()
|
|
24
|
-
|
|
25
|
-
const handleOK = useCallback(async () => {
|
|
26
|
-
setIsSaving(true)
|
|
27
|
-
|
|
28
|
-
if (modalContentConfig.onOk) {
|
|
29
|
-
try {
|
|
30
|
-
await modalContentConfig.onOk(modalState)
|
|
31
|
-
} finally {
|
|
32
|
-
setIsSaving(false)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
close()
|
|
36
|
-
}, [modalContentConfig.onOk, close, modalState])
|
|
37
|
-
|
|
38
|
-
const handleCancel = useCallback(async () => {
|
|
39
|
-
if (modalContentConfig.onCancel) {
|
|
40
|
-
await modalContentConfig.onCancel()
|
|
41
|
-
}
|
|
42
|
-
close()
|
|
43
|
-
}, [modalContentConfig.onCancel, close])
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<ModalHeader>{modalContentConfig.title}</ModalHeader>
|
|
48
|
-
<ModalCloseButton />
|
|
49
|
-
<ModalBody>
|
|
50
|
-
{isReactNode(Content) ? Content : <Content open={open} close={close} {...props} />}
|
|
51
|
-
</ModalBody>
|
|
52
|
-
<ModalFooter>
|
|
53
|
-
<HStack w={'full'} spacing={'6'}>
|
|
54
|
-
<Button isDisabled={isSaving} w={'full'} variant={'outline'} onClick={handleCancel}>{modalContentConfig.cancelText || translations.close}</Button>
|
|
55
|
-
<Button isDisabled={modalContentConfig.isOkDisabled} isLoading={isSaving || modalContentConfig.isOkLoading} w={'full'} variant={'solid'} onClick={handleOK} colorScheme={modalContentConfig.okColorScheme}>
|
|
56
|
-
{modalContentConfig.okText || translations.ok}
|
|
57
|
-
</Button>
|
|
58
|
-
</HStack>
|
|
59
|
-
</ModalFooter>
|
|
60
|
-
</>
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default StandardModalContent
|
package/src/modal/context.tsx
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { createContext, type Dispatch, type FC, type ReactNode, type SetStateAction } from 'react'
|
|
2
|
-
import type { UnionToIntersection } from 'type-fest'
|
|
3
|
-
import type { ModalProps } from '../chakra.js'
|
|
4
|
-
|
|
5
|
-
export type ModalControlProps = {
|
|
6
|
-
open: () => void
|
|
7
|
-
close: () => void
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type StandardModaContentConfig<MS = any> = {
|
|
11
|
-
type: 'standard'
|
|
12
|
-
title?: string
|
|
13
|
-
okText?: string
|
|
14
|
-
okColorScheme?: string
|
|
15
|
-
onOk?: (modalState: MS) => void | Promise<void>
|
|
16
|
-
isOkDisabled?: boolean
|
|
17
|
-
isOkLoading?: boolean
|
|
18
|
-
cancelText?: string
|
|
19
|
-
onCancel?: () => void | Promise<void>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type CustomModalContentConfig = {
|
|
23
|
-
type: 'custom'
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type MinimalModalContentConfig = {
|
|
27
|
-
type: 'minimal'
|
|
28
|
-
title?: string
|
|
29
|
-
noModalBody?: boolean
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type CleanupModalContentConfig<T> = {
|
|
33
|
-
[K in keyof T as Exclude<K, 'type'>]: T[K]
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
type ModalContentConfigUnion<MS = any> = StandardModaContentConfig<MS> | CustomModalContentConfig | MinimalModalContentConfig
|
|
37
|
-
type ModalContentConfigIntersection<MS = any> = UnionToIntersection<CleanupModalContentConfig<ModalContentConfigUnion<MS>>>
|
|
38
|
-
|
|
39
|
-
export type ModalContentConfig<P extends object = {}, MS = any> = {
|
|
40
|
-
contentProps?: P
|
|
41
|
-
initialModalState?: MS
|
|
42
|
-
content: FC<Partial<ModalControlProps> & Omit<P, keyof ModalControlProps>> | ReactNode
|
|
43
|
-
size?: ModalProps['size']
|
|
44
|
-
} & ModalContentConfigUnion<MS>
|
|
45
|
-
|
|
46
|
-
export type ModalOptions = {
|
|
47
|
-
onClose?: () => void
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface ModalOpenOptions<ExtraProps extends object = {}, MS = any> extends ModalOptions {
|
|
51
|
-
modalContentConfig: ModalContentConfig<ExtraProps, MS>
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface ModalUpdateOptions<ExtraProps extends object = Record<string, any>, MS = any> {
|
|
55
|
-
contentProps?: ExtraProps
|
|
56
|
-
state?: MS
|
|
57
|
-
modalContentConfig?: ModalContentConfigIntersection<MS>
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface ModalCloseOptions {
|
|
61
|
-
keepModalContentConfig?: boolean
|
|
62
|
-
}
|
|
63
|
-
export interface ModalContextState<ExtraProps extends object = any, MS = any> {
|
|
64
|
-
isOpen: boolean
|
|
65
|
-
open: <P extends ExtraProps, IMS extends MS = any>(options?: ModalOpenOptions<P, IMS> | ModalContentConfig<P, IMS>) => void
|
|
66
|
-
close: (options?: ModalCloseOptions) => void
|
|
67
|
-
update: (options: ModalUpdateOptions<ExtraProps>) => void
|
|
68
|
-
modalState?: MS
|
|
69
|
-
setModalState: Dispatch<SetStateAction<MS>>
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const initialState: ModalContextState = {
|
|
73
|
-
isOpen: true,
|
|
74
|
-
open: () => {},
|
|
75
|
-
close: () => {},
|
|
76
|
-
update: () => {},
|
|
77
|
-
modalState: undefined,
|
|
78
|
-
setModalState: () => {},
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const ModalContext = createContext<ModalContextState>(initialState)
|
package/src/modal/index.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { default as ModalProvider } from './ModalProvider.js'
|
|
2
|
-
export { default as EnhancedModalCustomWrapper } from './components/EnhancedModalCustomWrapper.js'
|
|
3
|
-
export { default as EnhancedModalFooter } from './components/EnhancedModalFooter.js'
|
|
4
|
-
export { default as MinimalModalContent } from './components/MinimalModalContent.js'
|
|
5
|
-
export * from './context.js'
|
|
6
|
-
export * from './use-enhanced-modal.js'
|
|
7
|
-
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { useContext, type Context } from 'react'
|
|
2
|
-
import type { ModalContextState } from './context.js'
|
|
3
|
-
import { ModalContext } from './context.js'
|
|
4
|
-
|
|
5
|
-
export const useEnhancedModal = <P extends object = any, MS = any>(): ModalContextState<P, MS> => {
|
|
6
|
-
return useContext<ModalContextState<P, MS>>(ModalContext as unknown as Context<ModalContextState<P, MS>>)
|
|
7
|
-
}
|
package/src/theme/colors.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
// TODO sync this with the one in dump
|
|
2
|
-
// remove dump file version
|
|
3
|
-
// update all instances using colors
|
|
4
|
-
|
|
5
|
-
export const colors = {
|
|
6
|
-
/**
|
|
7
|
-
* #EFEFF0 Light Gray
|
|
8
|
-
*/
|
|
9
|
-
primary1: '#EFEFF0',
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* #CACACA Gray
|
|
13
|
-
*/
|
|
14
|
-
primary2: '#CACACA',
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* #585858 Dark Gray
|
|
18
|
-
*/
|
|
19
|
-
primary3: '#585858',
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* #191919 Soft Black
|
|
23
|
-
*/
|
|
24
|
-
primary4: '#191919',
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* #E55867 Red
|
|
28
|
-
*/
|
|
29
|
-
accent4: '#E55867',
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* #ADE0EE Light Blue
|
|
33
|
-
*/
|
|
34
|
-
links2: '#ADE0EE',
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* #50C8E8 Blue
|
|
38
|
-
*/
|
|
39
|
-
links: '#50C8E8',
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* #E24657 Red
|
|
43
|
-
*/
|
|
44
|
-
alert4: '#E24657',
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* #E24657 Red
|
|
48
|
-
*/
|
|
49
|
-
danger: '#E24657',
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* #F4B25C Yellow
|
|
53
|
-
*/
|
|
54
|
-
warning4: '#F4B25C',
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* #4FD9C2 Green
|
|
58
|
-
*/
|
|
59
|
-
success4: '#4FD9C2',
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* #4FD9C2 Green
|
|
63
|
-
*/
|
|
64
|
-
green: '#4FD9C2',
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* #3BD5BC Green
|
|
68
|
-
*/
|
|
69
|
-
// green: '#3BD5BC',
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* #000000 Black
|
|
73
|
-
*/
|
|
74
|
-
black: '#000000',
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* #ffffff White
|
|
78
|
-
*/
|
|
79
|
-
white: '#ffffff',
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* #E6E6E6 Light Gray
|
|
83
|
-
*/
|
|
84
|
-
whiteHover: '#E6E6E6',
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* #F4F4F4 Light Gray
|
|
88
|
-
*/
|
|
89
|
-
placeholder: '#F4F4F4',
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* #F9F7D7 Light Yellow
|
|
93
|
-
*/
|
|
94
|
-
highlight: '#F9F7D7',
|
|
95
|
-
|
|
96
|
-
primary: {
|
|
97
|
-
25: '#fafafa',
|
|
98
|
-
50: '#d6f5f0',
|
|
99
|
-
100: '#98e6d6',
|
|
100
|
-
200: '#191919',
|
|
101
|
-
300: '#191919',
|
|
102
|
-
400: '#3bd5bb',
|
|
103
|
-
500: '#000000',
|
|
104
|
-
600: '#000000',
|
|
105
|
-
700: '#000000',
|
|
106
|
-
800: '#000000',
|
|
107
|
-
900: '#000000'
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
// TODO add 25
|
|
111
|
-
success: {
|
|
112
|
-
50: '#d8f7f2',
|
|
113
|
-
100: '#98e6d6',
|
|
114
|
-
200: '#3bd5bc',
|
|
115
|
-
300: '#4FD9C2',
|
|
116
|
-
400: '#3bd5bb',
|
|
117
|
-
500: '#3bd5bb',
|
|
118
|
-
600: '#2EA692',
|
|
119
|
-
700: '#00825c',
|
|
120
|
-
800: '#00724d',
|
|
121
|
-
900: '#005530'
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
// TODO add 25
|
|
125
|
-
accent: {
|
|
126
|
-
50: '#fceaee',
|
|
127
|
-
100: '#f8cad3',
|
|
128
|
-
200: '#E55867',
|
|
129
|
-
300: '#E55867',
|
|
130
|
-
400: '#E24657',
|
|
131
|
-
500: '#E24657',
|
|
132
|
-
600: '#d8253f',
|
|
133
|
-
700: '#c61a38',
|
|
134
|
-
800: '#b91231',
|
|
135
|
-
900: '#aa0026'
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
// TODO add 25
|
|
139
|
-
warning: {
|
|
140
|
-
50: '#FDF0DE',
|
|
141
|
-
100: '#F4B25C',
|
|
142
|
-
200: '#F4B25C',
|
|
143
|
-
300: '#F4B25C',
|
|
144
|
-
400: '#F4B25C',
|
|
145
|
-
500: '#F4B25C',
|
|
146
|
-
600: '#BF7F2C',
|
|
147
|
-
700: '#F4B25C',
|
|
148
|
-
800: '#F4B25C',
|
|
149
|
-
900: '#F4B25C'
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
info: {
|
|
153
|
-
25: '#50C8E81A',
|
|
154
|
-
50: '#CDF1FA',
|
|
155
|
-
100: '#50C8E8',
|
|
156
|
-
200: '#50C8E8',
|
|
157
|
-
300: '#50C8E8',
|
|
158
|
-
400: '#50C8E8',
|
|
159
|
-
500: '#50C8E8',
|
|
160
|
-
600: '#3EA5C0',
|
|
161
|
-
700: '#50C8E8',
|
|
162
|
-
800: '#50C8E8',
|
|
163
|
-
900: '#50C8E8'
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
// TODO add 25
|
|
167
|
-
alert: {
|
|
168
|
-
50: '#E24657',
|
|
169
|
-
100: '#E24657',
|
|
170
|
-
200: '#E24657',
|
|
171
|
-
300: '#E24657',
|
|
172
|
-
400: '#E24657',
|
|
173
|
-
500: '#E24657',
|
|
174
|
-
600: '#E24657',
|
|
175
|
-
700: '#E24657',
|
|
176
|
-
800: '#E24657',
|
|
177
|
-
900: '#E24657',
|
|
178
|
-
}
|
|
179
|
-
}
|
package/src/theme/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './colors.js'
|
package/src/toast/index.ts
DELETED