@cleartrip/ct-design-dialog 4.0.0 → 5.0.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/README.md +75 -0
- package/dist/Dialog.d.ts +3 -4
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.native.d.ts +5 -0
- package/dist/Dialog.native.d.ts.map +1 -0
- package/dist/DialogAction/DialogAction.d.ts +5 -6
- package/dist/DialogAction/DialogAction.d.ts.map +1 -1
- package/dist/DialogAction/DialogAction.native.d.ts +7 -0
- package/dist/DialogAction/DialogAction.native.d.ts.map +1 -0
- package/dist/DialogContent/DialogContent.d.ts +5 -6
- package/dist/DialogContent/DialogContent.d.ts.map +1 -1
- package/dist/DialogContent/DialogContent.native.d.ts +7 -0
- package/dist/DialogContent/DialogContent.native.d.ts.map +1 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/ct-design-dialog.browser.cjs.js +1 -1
- package/dist/ct-design-dialog.browser.cjs.js.map +1 -1
- package/dist/ct-design-dialog.browser.esm.js +1 -1
- package/dist/ct-design-dialog.browser.esm.js.map +1 -1
- package/dist/ct-design-dialog.cjs.js +67 -39
- package/dist/ct-design-dialog.cjs.js.map +1 -1
- package/dist/ct-design-dialog.esm.js +69 -41
- package/dist/ct-design-dialog.esm.js.map +1 -1
- package/dist/ct-design-dialog.umd.js +70 -79
- package/dist/ct-design-dialog.umd.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.native.d.ts +6 -0
- package/dist/index.native.d.ts.map +1 -0
- package/dist/type.d.ts +41 -33
- package/dist/type.d.ts.map +1 -1
- package/package.json +23 -14
- package/src/Dialog.native.tsx +83 -0
- package/src/Dialog.tsx +130 -0
- package/src/DialogAction/DialogAction.native.tsx +69 -0
- package/src/DialogAction/DialogAction.tsx +77 -0
- package/src/DialogContent/DialogContent.native.tsx +39 -0
- package/src/DialogContent/DialogContent.tsx +42 -0
- package/src/constants.ts +9 -0
- package/src/index.native.ts +5 -0
- package/src/index.ts +5 -0
- package/src/type.ts +185 -0
- package/dist/style.d.ts +0 -43
- package/dist/style.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,35 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleartrip/ct-design-dialog",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Dialog Component",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
-
"main": "dist/ct-design-dialog.cjs.js",
|
|
6
|
+
"main": "./dist/ct-design-dialog.cjs.js",
|
|
7
|
+
"react-native": "src/index.native.ts",
|
|
7
8
|
"jsnext:main": "dist/ct-design-dialog.esm.js",
|
|
8
9
|
"module": "dist/ct-design-dialog.esm.js",
|
|
9
10
|
"sideEffects": false,
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/ct-design-dialog.esm.js",
|
|
15
|
+
"default": "./dist/ct-design-dialog.cjs.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
10
18
|
"browser": {
|
|
11
19
|
"./dist/ct-design-dialog.esm.js": "./dist/ct-design-dialog.browser.esm.js",
|
|
12
20
|
"./dist/ct-design-dialog.cjs.js": "./dist/ct-design-dialog.browser.cjs.js"
|
|
13
21
|
},
|
|
14
22
|
"files": [
|
|
15
|
-
"dist"
|
|
23
|
+
"dist",
|
|
24
|
+
"src"
|
|
16
25
|
],
|
|
17
26
|
"dependencies": {
|
|
18
|
-
"@cleartrip/ct-design-
|
|
19
|
-
"@cleartrip/ct-design-
|
|
20
|
-
"@cleartrip/ct-design-
|
|
21
|
-
"@cleartrip/ct-design-modal": "
|
|
22
|
-
"@cleartrip/ct-design-
|
|
23
|
-
"@cleartrip/ct-design-
|
|
24
|
-
"@cleartrip/ct-design-container": "4.0.0"
|
|
27
|
+
"@cleartrip/ct-design-container": "5.0.0",
|
|
28
|
+
"@cleartrip/ct-design-style-manager": "5.0.0",
|
|
29
|
+
"@cleartrip/ct-design-theme": "5.0.0",
|
|
30
|
+
"@cleartrip/ct-design-modal": "5.0.0",
|
|
31
|
+
"@cleartrip/ct-design-types": "5.0.0",
|
|
32
|
+
"@cleartrip/ct-design-typography": "5.0.0"
|
|
25
33
|
},
|
|
26
34
|
"devDependencies": {
|
|
27
|
-
"@cleartrip/ct-design-icons": "
|
|
35
|
+
"@cleartrip/ct-design-icons": "5.0.0"
|
|
28
36
|
},
|
|
29
37
|
"peerDependencies": {
|
|
30
38
|
"react": ">=16.8.0",
|
|
31
|
-
"react-dom": ">=16.8.0"
|
|
32
|
-
"styled-components": "^5.3.6"
|
|
39
|
+
"react-dom": ">=16.8.0"
|
|
33
40
|
},
|
|
34
41
|
"publishConfig": {
|
|
35
42
|
"access": "public"
|
|
@@ -40,6 +47,8 @@
|
|
|
40
47
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
41
48
|
"watch-package": "rollup -c -w",
|
|
42
49
|
"build-package": "rollup -c",
|
|
43
|
-
"build-package:clean": "rm -rf dist && rollup -c"
|
|
50
|
+
"build-package:clean": "rm -rf dist && rollup -c",
|
|
51
|
+
"publish-package:local": "yalc publish --no-scripts",
|
|
52
|
+
"publish-package:local:registry": "pnpm publish --registry http://localhost:4873 --no-git-checks --access public"
|
|
44
53
|
}
|
|
45
54
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { ContainerRef } from '@cleartrip/ct-design-container';
|
|
4
|
+
import {
|
|
5
|
+
ActionButtonAlignment,
|
|
6
|
+
ActionButtonVariant,
|
|
7
|
+
Modal,
|
|
8
|
+
type ActionButtonAlignmentType,
|
|
9
|
+
type ActionButtonVariantsType,
|
|
10
|
+
} from '@cleartrip/ct-design-modal';
|
|
11
|
+
|
|
12
|
+
import type { IDialogProps } from './type';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Native implementation of `Dialog`.
|
|
16
|
+
*
|
|
17
|
+
* Migrated 1:1 from aldenui (`core/components/components/Dialog`).
|
|
18
|
+
* The native `Modal` already implements the `actionButtonType` +
|
|
19
|
+
* `actionButtonAlignment` slots, so this wrapper only needs to
|
|
20
|
+
* translate the legacy `overlayCloseIcon` flag set and forward
|
|
21
|
+
* everything else unchanged.
|
|
22
|
+
*/
|
|
23
|
+
const Dialog = forwardRef<ContainerRef, IDialogProps>(
|
|
24
|
+
(
|
|
25
|
+
{
|
|
26
|
+
children,
|
|
27
|
+
open,
|
|
28
|
+
variant,
|
|
29
|
+
placement,
|
|
30
|
+
blur,
|
|
31
|
+
allowBackdropClose,
|
|
32
|
+
overlayCloseIcon,
|
|
33
|
+
onClose,
|
|
34
|
+
styleConfig,
|
|
35
|
+
size,
|
|
36
|
+
actionButtonType: actionButtonTypeFromProps,
|
|
37
|
+
actionButtonAlignment: actionButtonAlignmentFromProps,
|
|
38
|
+
},
|
|
39
|
+
forwardedRef,
|
|
40
|
+
) => {
|
|
41
|
+
const { root: customRootStyles = [], modalWrapperStyles = [] } = styleConfig || {};
|
|
42
|
+
const { show = false, isBack = false, showCloseIcon = false, isCenter = false } = overlayCloseIcon || {};
|
|
43
|
+
|
|
44
|
+
const actionButtonAlignment = useMemo<ActionButtonAlignmentType>(() => {
|
|
45
|
+
if (actionButtonAlignmentFromProps) return actionButtonAlignmentFromProps;
|
|
46
|
+
if (isBack) return ActionButtonAlignment.LEFT;
|
|
47
|
+
if (isCenter) return ActionButtonAlignment.CENTER;
|
|
48
|
+
return ActionButtonAlignment.RIGHT;
|
|
49
|
+
}, [actionButtonAlignmentFromProps, isBack, isCenter]);
|
|
50
|
+
|
|
51
|
+
const actionButtonType = useMemo<ActionButtonVariantsType>(() => {
|
|
52
|
+
if (actionButtonTypeFromProps) return actionButtonTypeFromProps;
|
|
53
|
+
if (isBack) return ActionButtonVariant.BACK;
|
|
54
|
+
if (showCloseIcon || show) return ActionButtonVariant.CLOSE;
|
|
55
|
+
return ActionButtonVariant.NONE;
|
|
56
|
+
}, [actionButtonTypeFromProps, isBack, showCloseIcon, show]);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Modal
|
|
60
|
+
ref={forwardedRef}
|
|
61
|
+
variant={variant}
|
|
62
|
+
placement={placement}
|
|
63
|
+
allowBackdropClose={allowBackdropClose}
|
|
64
|
+
onClose={onClose}
|
|
65
|
+
blur={blur}
|
|
66
|
+
open={open}
|
|
67
|
+
size={size}
|
|
68
|
+
actionButtonType={actionButtonType}
|
|
69
|
+
actionButtonAlignment={actionButtonAlignment}
|
|
70
|
+
styleConfig={{
|
|
71
|
+
root: customRootStyles,
|
|
72
|
+
modalContentStyles: modalWrapperStyles,
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
</Modal>
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
Dialog.displayName = 'Dialog';
|
|
82
|
+
|
|
83
|
+
export default Dialog;
|
package/src/Dialog.tsx
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { ContainerRef } from '@cleartrip/ct-design-container';
|
|
4
|
+
import {
|
|
5
|
+
ActionButtonAlignment,
|
|
6
|
+
ActionButtonVariant,
|
|
7
|
+
Modal,
|
|
8
|
+
ModalWithCloseOverlay,
|
|
9
|
+
type ActionButtonAlignmentType,
|
|
10
|
+
type ActionButtonVariantsType,
|
|
11
|
+
} from '@cleartrip/ct-design-modal';
|
|
12
|
+
|
|
13
|
+
import type { IDialogProps } from './type';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Web implementation of `Dialog`.
|
|
17
|
+
*
|
|
18
|
+
* Migrated from aldenui (`core/components/components/Dialog`) per
|
|
19
|
+
* Migration.MD. The yagami Dialog is a thin wrapper around `Modal`
|
|
20
|
+
* that translates the legacy `overlayCloseIcon` flag set into the
|
|
21
|
+
* Modal-level `actionButtonType` + `actionButtonAlignment` contract:
|
|
22
|
+
*
|
|
23
|
+
* - `isBack` → `actionButtonType=BACK`, alignment `LEFT`
|
|
24
|
+
* - `showCloseIcon`→ `actionButtonType=CLOSE`
|
|
25
|
+
* - `isCenter` → alignment `CENTER`
|
|
26
|
+
* - default → `actionButtonType=NONE`, alignment `RIGHT`
|
|
27
|
+
*
|
|
28
|
+
* The public API surface is preserved 1:1 with aldenui; the only
|
|
29
|
+
* implementation difference on web is that the underlying `Modal`
|
|
30
|
+
* does not yet implement the `actionButton*` slots directly, so we
|
|
31
|
+
* delegate the close-overlay rendering to `ModalWithCloseOverlay`
|
|
32
|
+
* whenever a visible close affordance is requested. The `NONE` case
|
|
33
|
+
* falls through to plain `Modal`.
|
|
34
|
+
*/
|
|
35
|
+
const Dialog = forwardRef<ContainerRef, IDialogProps>(
|
|
36
|
+
(
|
|
37
|
+
{
|
|
38
|
+
children,
|
|
39
|
+
open,
|
|
40
|
+
variant,
|
|
41
|
+
placement,
|
|
42
|
+
blur,
|
|
43
|
+
allowBackdropClose,
|
|
44
|
+
overlayCloseIcon,
|
|
45
|
+
onClose,
|
|
46
|
+
styleConfig,
|
|
47
|
+
size,
|
|
48
|
+
insidePortal = true,
|
|
49
|
+
actionButtonType: actionButtonTypeFromProps,
|
|
50
|
+
actionButtonAlignment: actionButtonAlignmentFromProps,
|
|
51
|
+
},
|
|
52
|
+
forwardedRef,
|
|
53
|
+
) => {
|
|
54
|
+
const { root: customRootStyles = [], modalWrapperStyles = [] } = styleConfig || {};
|
|
55
|
+
const {
|
|
56
|
+
show = false,
|
|
57
|
+
isBack = false,
|
|
58
|
+
showCloseIcon = false,
|
|
59
|
+
isCenter = false,
|
|
60
|
+
isTop = true,
|
|
61
|
+
} = overlayCloseIcon || {};
|
|
62
|
+
|
|
63
|
+
// Translate legacy `overlayCloseIcon` flags to the new
|
|
64
|
+
// Modal-level `actionButton*` contract. Explicit `actionButton*`
|
|
65
|
+
// props take precedence so consumers can opt into the new API
|
|
66
|
+
// directly without touching `overlayCloseIcon`.
|
|
67
|
+
const actionButtonAlignment = useMemo<ActionButtonAlignmentType>(() => {
|
|
68
|
+
if (actionButtonAlignmentFromProps) return actionButtonAlignmentFromProps;
|
|
69
|
+
if (isBack) return ActionButtonAlignment.LEFT;
|
|
70
|
+
if (isCenter) return ActionButtonAlignment.CENTER;
|
|
71
|
+
return ActionButtonAlignment.RIGHT;
|
|
72
|
+
}, [actionButtonAlignmentFromProps, isBack, isCenter]);
|
|
73
|
+
|
|
74
|
+
const actionButtonType = useMemo<ActionButtonVariantsType>(() => {
|
|
75
|
+
if (actionButtonTypeFromProps) return actionButtonTypeFromProps;
|
|
76
|
+
if (isBack) return ActionButtonVariant.BACK;
|
|
77
|
+
if (showCloseIcon || show) return ActionButtonVariant.CLOSE;
|
|
78
|
+
return ActionButtonVariant.NONE;
|
|
79
|
+
}, [actionButtonTypeFromProps, isBack, showCloseIcon, show]);
|
|
80
|
+
|
|
81
|
+
const needsOverlay = actionButtonType !== ActionButtonVariant.NONE;
|
|
82
|
+
|
|
83
|
+
if (needsOverlay) {
|
|
84
|
+
return (
|
|
85
|
+
// `ModalWithCloseOverlay` expects an `HTMLDivElement` ref while
|
|
86
|
+
// the public Dialog ref signature is `ContainerRef` for
|
|
87
|
+
// cross-platform parity with native. The cast keeps the public
|
|
88
|
+
// type stable until web Modal adopts the new ref shape.
|
|
89
|
+
<ModalWithCloseOverlay
|
|
90
|
+
ref={forwardedRef}
|
|
91
|
+
variant={variant}
|
|
92
|
+
placement={placement}
|
|
93
|
+
allowBackdropClose={allowBackdropClose}
|
|
94
|
+
onClose={onClose}
|
|
95
|
+
blur={blur}
|
|
96
|
+
open={open}
|
|
97
|
+
insidePortal={insidePortal}
|
|
98
|
+
size={size ?? 'NONE'}
|
|
99
|
+
isBack={actionButtonType === ActionButtonVariant.BACK}
|
|
100
|
+
isCenter={actionButtonAlignment === ActionButtonAlignment.CENTER}
|
|
101
|
+
isTop={isTop}
|
|
102
|
+
wrapperStyles={modalWrapperStyles}
|
|
103
|
+
styleConfig={{ root: customRootStyles }}
|
|
104
|
+
>
|
|
105
|
+
{children}
|
|
106
|
+
</ModalWithCloseOverlay>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<Modal
|
|
112
|
+
ref={forwardedRef}
|
|
113
|
+
variant={variant}
|
|
114
|
+
placement={placement}
|
|
115
|
+
allowBackdropClose={allowBackdropClose}
|
|
116
|
+
onClose={onClose}
|
|
117
|
+
blur={blur}
|
|
118
|
+
open={open}
|
|
119
|
+
insidePortal={insidePortal}
|
|
120
|
+
size={size ?? 'NONE'}
|
|
121
|
+
>
|
|
122
|
+
{children}
|
|
123
|
+
</Modal>
|
|
124
|
+
);
|
|
125
|
+
},
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
Dialog.displayName = 'Dialog';
|
|
129
|
+
|
|
130
|
+
export default Dialog;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Container } from '@cleartrip/ct-design-container';
|
|
2
|
+
import { makeStyles, useStyles } from '@cleartrip/ct-design-style-manager';
|
|
3
|
+
import { Typography } from '@cleartrip/ct-design-typography';
|
|
4
|
+
|
|
5
|
+
import { type IDialogActionProps } from '../type';
|
|
6
|
+
import { DialogAlignmentTypes } from '../constants';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Static style slots shared across the native DialogAction layout.
|
|
10
|
+
* Kept in lock-step with the web variant so visual output matches
|
|
11
|
+
* across platforms.
|
|
12
|
+
*/
|
|
13
|
+
const staticStyles = makeStyles((theme) => ({
|
|
14
|
+
root: {
|
|
15
|
+
paddingVertical: 0,
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
paddingHorizontal: theme.spacing[6],
|
|
18
|
+
},
|
|
19
|
+
actionContainer: {
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Native implementation of `DialogAction`. Mirrors the web variant
|
|
27
|
+
* exactly — the native `Container` + `Typography` primitives already
|
|
28
|
+
* handle the RN shim so no platform-specific branches are required.
|
|
29
|
+
*/
|
|
30
|
+
const DialogAction = ({
|
|
31
|
+
alignment = DialogAlignmentTypes.COLUMN,
|
|
32
|
+
actionButtons = [],
|
|
33
|
+
styleConfig,
|
|
34
|
+
}: IDialogActionProps) => {
|
|
35
|
+
const { root: customRootStyles = [] } = styleConfig || {};
|
|
36
|
+
|
|
37
|
+
const dynamicStyles = useStyles(
|
|
38
|
+
() => ({
|
|
39
|
+
root: {
|
|
40
|
+
flexDirection: alignment,
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
[alignment],
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Container styleConfig={{ root: [staticStyles.root, dynamicStyles.root, ...customRootStyles] }}>
|
|
48
|
+
{actionButtons.map((btn, index) => {
|
|
49
|
+
const { type, onClick, label, styleConfig: buttonStyleConfig } = btn || {};
|
|
50
|
+
const { root: customActionStyles = [] } = buttonStyleConfig || {};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Container
|
|
54
|
+
key={`actionButton_${index}`}
|
|
55
|
+
styleConfig={{ root: [staticStyles.actionContainer, ...customActionStyles] }}
|
|
56
|
+
>
|
|
57
|
+
<Typography variant='HM4' color={type} isClickable={!!onClick} onClick={onClick}>
|
|
58
|
+
{label}
|
|
59
|
+
</Typography>
|
|
60
|
+
</Container>
|
|
61
|
+
);
|
|
62
|
+
})}
|
|
63
|
+
</Container>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
DialogAction.displayName = 'DialogAction';
|
|
68
|
+
|
|
69
|
+
export default DialogAction;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Container } from '@cleartrip/ct-design-container';
|
|
2
|
+
import { makeStyles, useStyles } from '@cleartrip/ct-design-style-manager';
|
|
3
|
+
import { Typography } from '@cleartrip/ct-design-typography';
|
|
4
|
+
|
|
5
|
+
import { type IDialogActionProps } from '../type';
|
|
6
|
+
import { DialogAlignmentTypes } from '../constants';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Static style slots shared across the DialogAction layout.
|
|
10
|
+
*
|
|
11
|
+
* - `root` is the outer wrapper around the action list. Mirrors
|
|
12
|
+
* aldenui's zero vertical / `theme.spacing[6]` horizontal padding
|
|
13
|
+
* so existing dialogs keep their proportions.
|
|
14
|
+
* - `actionContainer` centers each button row; the per-button
|
|
15
|
+
* Container uses it as a base before composing caller overrides.
|
|
16
|
+
*/
|
|
17
|
+
const staticStyles = makeStyles((theme) => ({
|
|
18
|
+
root: {
|
|
19
|
+
paddingVertical: 0,
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
paddingHorizontal: theme.spacing[6],
|
|
22
|
+
},
|
|
23
|
+
actionContainer: {
|
|
24
|
+
justifyContent: 'center',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Web implementation of `DialogAction`.
|
|
31
|
+
*
|
|
32
|
+
* Migrated from aldenui (`core/components/components/Dialog/DialogAction`)
|
|
33
|
+
* per Migration.MD. Replaces the legacy `css`/`useTheme` mix with
|
|
34
|
+
* `Container` + composed `styleConfig.root` slots and a dynamic
|
|
35
|
+
* `useStyles` slot for `flexDirection`. The default `alignment` is
|
|
36
|
+
* `'column'` for parity with aldenui's vertical stack.
|
|
37
|
+
*/
|
|
38
|
+
const DialogAction = ({
|
|
39
|
+
alignment = DialogAlignmentTypes.COLUMN,
|
|
40
|
+
actionButtons = [],
|
|
41
|
+
styleConfig,
|
|
42
|
+
}: IDialogActionProps) => {
|
|
43
|
+
const { root: customRootStyles = [] } = styleConfig || {};
|
|
44
|
+
|
|
45
|
+
const dynamicStyles = useStyles(
|
|
46
|
+
() => ({
|
|
47
|
+
root: {
|
|
48
|
+
flexDirection: alignment,
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
[alignment],
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Container styleConfig={{ root: [staticStyles.root, dynamicStyles.root, ...customRootStyles] }}>
|
|
56
|
+
{actionButtons.map((btn, index) => {
|
|
57
|
+
const { type, onClick, label, styleConfig: buttonStyleConfig } = btn || {};
|
|
58
|
+
const { root: customActionStyles = [] } = buttonStyleConfig || {};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Container
|
|
62
|
+
key={`actionButton_${index}`}
|
|
63
|
+
styleConfig={{ root: [staticStyles.actionContainer, ...customActionStyles] }}
|
|
64
|
+
>
|
|
65
|
+
<Typography variant='HM4' color={type} isClickable={!!onClick} onClick={onClick}>
|
|
66
|
+
{label}
|
|
67
|
+
</Typography>
|
|
68
|
+
</Container>
|
|
69
|
+
);
|
|
70
|
+
})}
|
|
71
|
+
</Container>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
DialogAction.displayName = 'DialogAction';
|
|
76
|
+
|
|
77
|
+
export default DialogAction;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Container } from '@cleartrip/ct-design-container';
|
|
2
|
+
import { makeStyles } from '@cleartrip/ct-design-style-manager';
|
|
3
|
+
|
|
4
|
+
import type { IDialogContentProps } from '../type';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Static slot applied to the DialogContent root. Mirrors aldenui's
|
|
8
|
+
* `theme.spacing[6]` padding + centered flex alignment so migrated
|
|
9
|
+
* call sites render identically.
|
|
10
|
+
*/
|
|
11
|
+
const staticStyles = makeStyles((theme) => ({
|
|
12
|
+
root: {
|
|
13
|
+
padding: theme.spacing[6],
|
|
14
|
+
justifyContent: 'center',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Native implementation of `DialogContent` — functionally identical
|
|
21
|
+
* to the web variant. Kept as a separate file so platform-specific
|
|
22
|
+
* tweaks (e.g. pressable wiring, measure calls) can diverge later
|
|
23
|
+
* without touching web.
|
|
24
|
+
*/
|
|
25
|
+
const DialogContent = ({ headIcon, title, description, styleConfig }: IDialogContentProps) => {
|
|
26
|
+
const { root: customStyles = [] } = styleConfig || {};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Container styleConfig={{ root: [staticStyles.root, ...customStyles] }}>
|
|
30
|
+
{headIcon}
|
|
31
|
+
{title}
|
|
32
|
+
{description}
|
|
33
|
+
</Container>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
DialogContent.displayName = 'DialogContent';
|
|
38
|
+
|
|
39
|
+
export default DialogContent;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Container } from '@cleartrip/ct-design-container';
|
|
2
|
+
import { makeStyles } from '@cleartrip/ct-design-style-manager';
|
|
3
|
+
|
|
4
|
+
import type { IDialogContentProps } from '../type';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Static slot applied to the DialogContent root. Mirrors aldenui's
|
|
8
|
+
* `theme.spacing[6]` padding + centered flex alignment so migrated
|
|
9
|
+
* call sites render identically.
|
|
10
|
+
*/
|
|
11
|
+
const staticStyles = makeStyles((theme) => ({
|
|
12
|
+
root: {
|
|
13
|
+
padding: theme.spacing[6],
|
|
14
|
+
justifyContent: 'center',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Top content slot rendered inside a Dialog body.
|
|
21
|
+
*
|
|
22
|
+
* Migrated from aldenui (`core/components/components/Dialog/DialogContent`)
|
|
23
|
+
* per Migration.MD — swaps the previous `css`/`useTheme` pattern for
|
|
24
|
+
* `Container` + composed `styleConfig.root` slots so consumers can
|
|
25
|
+
* layer style arrays on top of the default padding/alignment without
|
|
26
|
+
* the styled-components detour.
|
|
27
|
+
*/
|
|
28
|
+
const DialogContent = ({ headIcon, title, description, styleConfig }: IDialogContentProps) => {
|
|
29
|
+
const { root: customStyles = [] } = styleConfig || {};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Container styleConfig={{ root: [staticStyles.root, ...customStyles] }}>
|
|
33
|
+
{headIcon}
|
|
34
|
+
{title}
|
|
35
|
+
{description}
|
|
36
|
+
</Container>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
DialogContent.displayName = 'DialogContent';
|
|
41
|
+
|
|
42
|
+
export default DialogContent;
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Dialog } from './Dialog.native';
|
|
2
|
+
export { default as DialogAction } from './DialogAction/DialogAction.native';
|
|
3
|
+
export { default as DialogContent } from './DialogContent/DialogContent.native';
|
|
4
|
+
export type * from './type';
|
|
5
|
+
export * from './constants';
|
package/src/index.ts
ADDED