@lobehub/ui 5.15.8 → 5.15.10
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/es/CodeDiff/CodeDiff.mjs +43 -67
- package/es/CodeDiff/CodeDiff.mjs.map +1 -1
- package/es/CodeDiff/DiffPanel.mjs +118 -0
- package/es/CodeDiff/DiffPanel.mjs.map +1 -0
- package/es/CodeDiff/PatchDiff.mjs +39 -63
- package/es/CodeDiff/PatchDiff.mjs.map +1 -1
- package/es/CodeDiff/style.mjs +80 -29
- package/es/CodeDiff/style.mjs.map +1 -1
- package/es/CodeDiff/theme.mjs +45 -0
- package/es/CodeDiff/theme.mjs.map +1 -0
- package/es/CodeDiff/type.d.mts +20 -0
- package/es/EmojiPicker/AvatarUploader.mjs +1 -1
- package/es/Highlighter/Highlighter.mjs +1 -1
- package/es/Highlighter/theme/lobe-theme.d.mts +3 -0
- package/es/Highlighter/theme/lobe-theme.mjs +1 -0
- package/es/Highlighter/theme/lobe-theme.mjs.map +1 -1
- package/es/Mermaid/Mermaid.mjs +1 -1
- package/es/Tag/Tag.mjs +23 -10
- package/es/Tag/Tag.mjs.map +1 -1
- package/es/Tag/styles.mjs +44 -1
- package/es/Tag/styles.mjs.map +1 -1
- package/es/Tag/type.d.mts +2 -1
- package/es/base-ui/Button/Button.d.mts +32 -0
- package/es/base-ui/Button/Button.mjs +100 -0
- package/es/base-ui/Button/Button.mjs.map +1 -0
- package/es/base-ui/Button/index.d.mts +3 -0
- package/es/base-ui/Button/style.d.mts +30 -0
- package/es/base-ui/Button/style.mjs +227 -0
- package/es/base-ui/Button/style.mjs.map +1 -0
- package/es/base-ui/Button/type.d.mts +36 -0
- package/es/base-ui/Modal/Modal.mjs +10 -13
- package/es/base-ui/Modal/Modal.mjs.map +1 -1
- package/es/base-ui/Modal/atoms.mjs +1 -1
- package/es/base-ui/Modal/atoms.mjs.map +1 -1
- package/es/base-ui/Modal/constants.d.mts +2 -0
- package/es/base-ui/Modal/constants.mjs +31 -16
- package/es/base-ui/Modal/constants.mjs.map +1 -1
- package/es/base-ui/Modal/imperative.mjs +7 -13
- package/es/base-ui/Modal/imperative.mjs.map +1 -1
- package/es/base-ui/Modal/style.mjs +47 -98
- package/es/base-ui/Modal/style.mjs.map +1 -1
- package/es/base-ui/Modal/type.d.mts +5 -8
- package/es/base-ui/index.d.mts +5 -2
- package/es/base-ui/index.mjs +4 -2
- package/es/color/colors/blue.d.mts +2 -2
- package/es/color/colors/blue.mjs +50 -50
- package/es/color/colors/blue.mjs.map +1 -1
- package/es/color/colors/index.d.mts +1 -1
- package/es/color/colors/index.mjs +2 -2
- package/es/color/colors/index.mjs.map +1 -1
- package/es/color/index.d.mts +2 -2
- package/es/color/index.mjs +2 -2
- package/es/hooks/useHighlight.mjs +1 -1
- package/es/hooks/useStreamHighlight.mjs +1 -1
- package/es/index.mjs +2 -2
- package/es/styles/customTheme.mjs +2 -2
- package/es/styles/customTheme.mjs.map +1 -1
- package/es/styles/theme/token/dark.mjs +2 -2
- package/es/styles/theme/token/dark.mjs.map +1 -1
- package/es/utils/safeReadableColor.mjs +1 -0
- package/es/utils/safeReadableColor.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/base-ui/Button/style.d.ts
|
|
2
|
+
declare const styles: {
|
|
3
|
+
base: string;
|
|
4
|
+
sizeSmall: string;
|
|
5
|
+
sizeMiddle: string;
|
|
6
|
+
sizeLarge: string;
|
|
7
|
+
shapeCircle: string;
|
|
8
|
+
shapeRound: string;
|
|
9
|
+
block: string;
|
|
10
|
+
iconEnd: string;
|
|
11
|
+
iconOnlySmall: string;
|
|
12
|
+
iconOnlyMiddle: string;
|
|
13
|
+
iconOnlyLarge: string;
|
|
14
|
+
iconBox: string;
|
|
15
|
+
variantDefault: string;
|
|
16
|
+
variantPrimary: string;
|
|
17
|
+
variantDashed: string;
|
|
18
|
+
variantText: string;
|
|
19
|
+
variantLink: string;
|
|
20
|
+
dangerOutlined: string;
|
|
21
|
+
dangerSolid: string;
|
|
22
|
+
dangerInline: string;
|
|
23
|
+
ghostDefault: string;
|
|
24
|
+
ghostPrimary: string;
|
|
25
|
+
ghostDanger: string;
|
|
26
|
+
spinner: string;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { styles };
|
|
30
|
+
//# sourceMappingURL=style.d.mts.map
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { createStaticStyles } from "antd-style";
|
|
2
|
+
//#region src/base-ui/Button/style.ts
|
|
3
|
+
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
4
|
+
base: css`
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
gap: 6px;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
border: 1px solid ${cssVar.colorBorder};
|
|
14
|
+
|
|
15
|
+
font-weight: 500;
|
|
16
|
+
line-height: 1;
|
|
17
|
+
text-decoration: none;
|
|
18
|
+
white-space: nowrap;
|
|
19
|
+
|
|
20
|
+
transition:
|
|
21
|
+
color 160ms cubic-bezier(0.32, 0.72, 0, 1),
|
|
22
|
+
background 160ms cubic-bezier(0.32, 0.72, 0, 1),
|
|
23
|
+
border-color 160ms cubic-bezier(0.32, 0.72, 0, 1),
|
|
24
|
+
box-shadow 160ms cubic-bezier(0.32, 0.72, 0, 1);
|
|
25
|
+
|
|
26
|
+
&:focus-visible {
|
|
27
|
+
outline: none;
|
|
28
|
+
box-shadow: 0 0 0 2px ${cssVar.colorPrimaryBorder};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:disabled,
|
|
32
|
+
&[aria-disabled='true'] {
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
opacity: 0.5;
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
sizeSmall: css`
|
|
39
|
+
height: 24px;
|
|
40
|
+
padding-inline: 8px;
|
|
41
|
+
border-radius: ${cssVar.borderRadiusSM};
|
|
42
|
+
font-size: 12px;
|
|
43
|
+
`,
|
|
44
|
+
sizeMiddle: css`
|
|
45
|
+
height: 32px;
|
|
46
|
+
padding-inline: 14px;
|
|
47
|
+
border-radius: ${cssVar.borderRadiusSM};
|
|
48
|
+
font-size: 13px;
|
|
49
|
+
`,
|
|
50
|
+
sizeLarge: css`
|
|
51
|
+
height: 40px;
|
|
52
|
+
padding-inline: 16px;
|
|
53
|
+
border-radius: ${cssVar.borderRadius};
|
|
54
|
+
font-size: 14px;
|
|
55
|
+
`,
|
|
56
|
+
shapeCircle: css`
|
|
57
|
+
padding-inline: 0;
|
|
58
|
+
border-radius: 50%;
|
|
59
|
+
`,
|
|
60
|
+
shapeRound: css`
|
|
61
|
+
border-radius: 999px;
|
|
62
|
+
`,
|
|
63
|
+
block: css`
|
|
64
|
+
width: 100%;
|
|
65
|
+
`,
|
|
66
|
+
iconEnd: css`
|
|
67
|
+
flex-direction: row-reverse;
|
|
68
|
+
`,
|
|
69
|
+
iconOnlySmall: css`
|
|
70
|
+
width: 24px;
|
|
71
|
+
padding-inline: 0;
|
|
72
|
+
`,
|
|
73
|
+
iconOnlyMiddle: css`
|
|
74
|
+
width: 32px;
|
|
75
|
+
padding-inline: 0;
|
|
76
|
+
`,
|
|
77
|
+
iconOnlyLarge: css`
|
|
78
|
+
width: 40px;
|
|
79
|
+
padding-inline: 0;
|
|
80
|
+
`,
|
|
81
|
+
iconBox: css`
|
|
82
|
+
display: inline-flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
`,
|
|
86
|
+
variantDefault: css`
|
|
87
|
+
color: ${cssVar.colorText};
|
|
88
|
+
background: ${cssVar.colorBgContainer};
|
|
89
|
+
|
|
90
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
91
|
+
border-color: ${cssVar.colorPrimaryBorder};
|
|
92
|
+
color: ${cssVar.colorPrimaryText};
|
|
93
|
+
}
|
|
94
|
+
`,
|
|
95
|
+
variantPrimary: css`
|
|
96
|
+
border-color: ${cssVar.colorPrimary};
|
|
97
|
+
color: ${cssVar.colorTextLightSolid};
|
|
98
|
+
background: ${cssVar.colorPrimary};
|
|
99
|
+
|
|
100
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
101
|
+
border-color: ${cssVar.colorPrimaryHover};
|
|
102
|
+
background: ${cssVar.colorPrimaryHover};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&:active:not(:disabled, [aria-disabled='true']) {
|
|
106
|
+
border-color: ${cssVar.colorPrimaryActive};
|
|
107
|
+
background: ${cssVar.colorPrimaryActive};
|
|
108
|
+
}
|
|
109
|
+
`,
|
|
110
|
+
variantDashed: css`
|
|
111
|
+
border-style: dashed;
|
|
112
|
+
color: ${cssVar.colorText};
|
|
113
|
+
background: ${cssVar.colorBgContainer};
|
|
114
|
+
|
|
115
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
116
|
+
border-color: ${cssVar.colorPrimaryBorder};
|
|
117
|
+
color: ${cssVar.colorPrimaryText};
|
|
118
|
+
}
|
|
119
|
+
`,
|
|
120
|
+
variantText: css`
|
|
121
|
+
border-color: transparent;
|
|
122
|
+
color: ${cssVar.colorText};
|
|
123
|
+
background: transparent;
|
|
124
|
+
|
|
125
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
126
|
+
background: ${cssVar.colorFillSecondary};
|
|
127
|
+
}
|
|
128
|
+
`,
|
|
129
|
+
variantLink: css`
|
|
130
|
+
padding-inline: 0;
|
|
131
|
+
border-color: transparent;
|
|
132
|
+
color: ${cssVar.colorPrimary};
|
|
133
|
+
background: transparent;
|
|
134
|
+
|
|
135
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
136
|
+
color: ${cssVar.colorPrimaryHover};
|
|
137
|
+
background: transparent;
|
|
138
|
+
}
|
|
139
|
+
`,
|
|
140
|
+
dangerOutlined: css`
|
|
141
|
+
border-color: ${cssVar.colorError};
|
|
142
|
+
color: ${cssVar.colorError};
|
|
143
|
+
background: ${cssVar.colorBgContainer};
|
|
144
|
+
|
|
145
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
146
|
+
border-color: ${cssVar.colorErrorHover};
|
|
147
|
+
color: ${cssVar.colorErrorHover};
|
|
148
|
+
background: ${cssVar.colorBgContainer};
|
|
149
|
+
}
|
|
150
|
+
`,
|
|
151
|
+
dangerSolid: css`
|
|
152
|
+
border-color: ${cssVar.colorError};
|
|
153
|
+
color: ${cssVar.colorTextLightSolid};
|
|
154
|
+
background: ${cssVar.colorError};
|
|
155
|
+
|
|
156
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
157
|
+
border-color: ${cssVar.colorErrorHover};
|
|
158
|
+
background: ${cssVar.colorErrorHover};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&:active:not(:disabled, [aria-disabled='true']) {
|
|
162
|
+
border-color: ${cssVar.colorErrorActive};
|
|
163
|
+
background: ${cssVar.colorErrorActive};
|
|
164
|
+
}
|
|
165
|
+
`,
|
|
166
|
+
dangerInline: css`
|
|
167
|
+
color: ${cssVar.colorError};
|
|
168
|
+
|
|
169
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
170
|
+
color: ${cssVar.colorErrorHover};
|
|
171
|
+
}
|
|
172
|
+
`,
|
|
173
|
+
ghostDefault: css`
|
|
174
|
+
border-color: ${cssVar.colorBorder};
|
|
175
|
+
color: ${cssVar.colorText};
|
|
176
|
+
background: transparent;
|
|
177
|
+
|
|
178
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
179
|
+
border-color: ${cssVar.colorPrimaryBorder};
|
|
180
|
+
color: ${cssVar.colorPrimaryText};
|
|
181
|
+
background: transparent;
|
|
182
|
+
}
|
|
183
|
+
`,
|
|
184
|
+
ghostPrimary: css`
|
|
185
|
+
border-color: ${cssVar.colorPrimary};
|
|
186
|
+
color: ${cssVar.colorPrimary};
|
|
187
|
+
background: transparent;
|
|
188
|
+
|
|
189
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
190
|
+
border-color: ${cssVar.colorPrimaryHover};
|
|
191
|
+
color: ${cssVar.colorPrimaryHover};
|
|
192
|
+
background: transparent;
|
|
193
|
+
}
|
|
194
|
+
`,
|
|
195
|
+
ghostDanger: css`
|
|
196
|
+
border-color: ${cssVar.colorError};
|
|
197
|
+
color: ${cssVar.colorError};
|
|
198
|
+
background: transparent;
|
|
199
|
+
|
|
200
|
+
&:hover:not(:disabled, [aria-disabled='true']) {
|
|
201
|
+
border-color: ${cssVar.colorErrorHover};
|
|
202
|
+
color: ${cssVar.colorErrorHover};
|
|
203
|
+
background: transparent;
|
|
204
|
+
}
|
|
205
|
+
`,
|
|
206
|
+
spinner: css`
|
|
207
|
+
@keyframes base-button-spin {
|
|
208
|
+
to {
|
|
209
|
+
transform: rotate(360deg);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
display: inline-block;
|
|
214
|
+
|
|
215
|
+
width: 12px;
|
|
216
|
+
height: 12px;
|
|
217
|
+
border: 1.5px solid currentcolor;
|
|
218
|
+
border-block-start-color: transparent;
|
|
219
|
+
border-radius: 50%;
|
|
220
|
+
|
|
221
|
+
animation: base-button-spin 0.6s linear infinite;
|
|
222
|
+
`
|
|
223
|
+
}));
|
|
224
|
+
//#endregion
|
|
225
|
+
export { styles };
|
|
226
|
+
|
|
227
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../../src/base-ui/Button/style.ts"],"sourcesContent":["import { createStaticStyles } from 'antd-style';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n base: css`\n cursor: pointer;\n\n display: inline-flex;\n gap: 6px;\n align-items: center;\n justify-content: center;\n\n box-sizing: border-box;\n border: 1px solid ${cssVar.colorBorder};\n\n font-weight: 500;\n line-height: 1;\n text-decoration: none;\n white-space: nowrap;\n\n transition:\n color 160ms cubic-bezier(0.32, 0.72, 0, 1),\n background 160ms cubic-bezier(0.32, 0.72, 0, 1),\n border-color 160ms cubic-bezier(0.32, 0.72, 0, 1),\n box-shadow 160ms cubic-bezier(0.32, 0.72, 0, 1);\n\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ${cssVar.colorPrimaryBorder};\n }\n\n &:disabled,\n &[aria-disabled='true'] {\n pointer-events: none;\n cursor: not-allowed;\n opacity: 0.5;\n }\n `,\n\n sizeSmall: css`\n height: 24px;\n padding-inline: 8px;\n border-radius: ${cssVar.borderRadiusSM};\n font-size: 12px;\n `,\n\n sizeMiddle: css`\n height: 32px;\n padding-inline: 14px;\n border-radius: ${cssVar.borderRadiusSM};\n font-size: 13px;\n `,\n\n sizeLarge: css`\n height: 40px;\n padding-inline: 16px;\n border-radius: ${cssVar.borderRadius};\n font-size: 14px;\n `,\n\n shapeCircle: css`\n padding-inline: 0;\n border-radius: 50%;\n `,\n\n shapeRound: css`\n border-radius: 999px;\n `,\n\n block: css`\n width: 100%;\n `,\n\n iconEnd: css`\n flex-direction: row-reverse;\n `,\n\n iconOnlySmall: css`\n width: 24px;\n padding-inline: 0;\n `,\n\n iconOnlyMiddle: css`\n width: 32px;\n padding-inline: 0;\n `,\n\n iconOnlyLarge: css`\n width: 40px;\n padding-inline: 0;\n `,\n\n iconBox: css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n `,\n\n variantDefault: css`\n color: ${cssVar.colorText};\n background: ${cssVar.colorBgContainer};\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n border-color: ${cssVar.colorPrimaryBorder};\n color: ${cssVar.colorPrimaryText};\n }\n `,\n\n variantPrimary: css`\n border-color: ${cssVar.colorPrimary};\n color: ${cssVar.colorTextLightSolid};\n background: ${cssVar.colorPrimary};\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n border-color: ${cssVar.colorPrimaryHover};\n background: ${cssVar.colorPrimaryHover};\n }\n\n &:active:not(:disabled, [aria-disabled='true']) {\n border-color: ${cssVar.colorPrimaryActive};\n background: ${cssVar.colorPrimaryActive};\n }\n `,\n\n variantDashed: css`\n border-style: dashed;\n color: ${cssVar.colorText};\n background: ${cssVar.colorBgContainer};\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n border-color: ${cssVar.colorPrimaryBorder};\n color: ${cssVar.colorPrimaryText};\n }\n `,\n\n variantText: css`\n border-color: transparent;\n color: ${cssVar.colorText};\n background: transparent;\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n background: ${cssVar.colorFillSecondary};\n }\n `,\n\n variantLink: css`\n padding-inline: 0;\n border-color: transparent;\n color: ${cssVar.colorPrimary};\n background: transparent;\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n color: ${cssVar.colorPrimaryHover};\n background: transparent;\n }\n `,\n\n dangerOutlined: css`\n border-color: ${cssVar.colorError};\n color: ${cssVar.colorError};\n background: ${cssVar.colorBgContainer};\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n border-color: ${cssVar.colorErrorHover};\n color: ${cssVar.colorErrorHover};\n background: ${cssVar.colorBgContainer};\n }\n `,\n\n dangerSolid: css`\n border-color: ${cssVar.colorError};\n color: ${cssVar.colorTextLightSolid};\n background: ${cssVar.colorError};\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n border-color: ${cssVar.colorErrorHover};\n background: ${cssVar.colorErrorHover};\n }\n\n &:active:not(:disabled, [aria-disabled='true']) {\n border-color: ${cssVar.colorErrorActive};\n background: ${cssVar.colorErrorActive};\n }\n `,\n\n dangerInline: css`\n color: ${cssVar.colorError};\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n color: ${cssVar.colorErrorHover};\n }\n `,\n\n ghostDefault: css`\n border-color: ${cssVar.colorBorder};\n color: ${cssVar.colorText};\n background: transparent;\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n border-color: ${cssVar.colorPrimaryBorder};\n color: ${cssVar.colorPrimaryText};\n background: transparent;\n }\n `,\n\n ghostPrimary: css`\n border-color: ${cssVar.colorPrimary};\n color: ${cssVar.colorPrimary};\n background: transparent;\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n border-color: ${cssVar.colorPrimaryHover};\n color: ${cssVar.colorPrimaryHover};\n background: transparent;\n }\n `,\n\n ghostDanger: css`\n border-color: ${cssVar.colorError};\n color: ${cssVar.colorError};\n background: transparent;\n\n &:hover:not(:disabled, [aria-disabled='true']) {\n border-color: ${cssVar.colorErrorHover};\n color: ${cssVar.colorErrorHover};\n background: transparent;\n }\n `,\n\n spinner: css`\n @keyframes base-button-spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n display: inline-block;\n\n width: 12px;\n height: 12px;\n border: 1.5px solid currentcolor;\n border-block-start-color: transparent;\n border-radius: 50%;\n\n animation: base-button-spin 0.6s linear infinite;\n `,\n}));\n"],"mappings":";;AAEA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,MAAM,GAAG;;;;;;;;;wBASa,OAAO,YAAY;;;;;;;;;;;;;;;8BAeb,OAAO,mBAAmB;;;;;;;;;;CAWtD,WAAW,GAAG;;;qBAGK,OAAO,eAAe;;;CAIzC,YAAY,GAAG;;;qBAGI,OAAO,eAAe;;;CAIzC,WAAW,GAAG;;;qBAGK,OAAO,aAAa;;;CAIvC,aAAa,GAAG;;;;CAKhB,YAAY,GAAG;;;CAIf,OAAO,GAAG;;;CAIV,SAAS,GAAG;;;CAIZ,eAAe,GAAG;;;;CAKlB,gBAAgB,GAAG;;;;CAKnB,eAAe,GAAG;;;;CAKlB,SAAS,GAAG;;;;;CAMZ,gBAAgB,GAAG;aACR,OAAO,UAAU;kBACZ,OAAO,iBAAiB;;;sBAGpB,OAAO,mBAAmB;eACjC,OAAO,iBAAiB;;;CAIrC,gBAAgB,GAAG;oBACD,OAAO,aAAa;aAC3B,OAAO,oBAAoB;kBACtB,OAAO,aAAa;;;sBAGhB,O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ts
|
|
4
|
+
type ButtonType = 'default' | 'primary' | 'dashed' | 'link' | 'text';
|
|
5
|
+
type ButtonShape = 'default' | 'circle' | 'round';
|
|
6
|
+
type ButtonSize = 'small' | 'middle' | 'large';
|
|
7
|
+
type ButtonIconPosition = 'start' | 'end';
|
|
8
|
+
interface BaseButtonOwnProps {
|
|
9
|
+
block?: boolean;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
classNames?: {
|
|
12
|
+
icon?: string;
|
|
13
|
+
};
|
|
14
|
+
danger?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
ghost?: boolean;
|
|
17
|
+
href?: string;
|
|
18
|
+
htmlType?: ButtonHTMLAttributes<HTMLButtonElement>['type'];
|
|
19
|
+
icon?: ReactNode;
|
|
20
|
+
iconPosition?: ButtonIconPosition;
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
ref?: Ref<HTMLButtonElement | HTMLAnchorElement>;
|
|
23
|
+
shape?: ButtonShape;
|
|
24
|
+
size?: ButtonSize;
|
|
25
|
+
styles?: {
|
|
26
|
+
icon?: CSSProperties;
|
|
27
|
+
};
|
|
28
|
+
target?: string;
|
|
29
|
+
type?: ButtonType;
|
|
30
|
+
}
|
|
31
|
+
type NativeButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof BaseButtonOwnProps | 'type'>;
|
|
32
|
+
type NativeAnchorProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof BaseButtonOwnProps | 'type'>;
|
|
33
|
+
type ButtonProps = BaseButtonOwnProps & NativeButtonProps & Partial<NativeAnchorProps>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { ButtonIconPosition, ButtonProps, ButtonShape, ButtonSize, ButtonType };
|
|
36
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { stopPropagation } from "../../utils/dom.mjs";
|
|
3
|
+
import Button from "../Button/Button.mjs";
|
|
3
4
|
import { styles } from "./style.mjs";
|
|
4
5
|
import { ModalBackdrop, ModalContent, ModalFooter, ModalHeader, ModalPopup, ModalPortal, ModalRoot, ModalTitle } from "./atoms.mjs";
|
|
5
6
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
@@ -9,26 +10,22 @@ import { useDragControls } from "motion/react";
|
|
|
9
10
|
import { Maximize2, Minimize2, X } from "lucide-react";
|
|
10
11
|
//#region src/base-ui/Modal/Modal.tsx
|
|
11
12
|
const OkBtn = ({ confirmLoading, okButtonProps, okText, onOk }) => {
|
|
12
|
-
const {
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
|
|
13
|
+
const { onClick: userOnClick, ...restOk } = okButtonProps ?? {};
|
|
14
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
15
|
+
loading: confirmLoading,
|
|
16
|
+
type: "primary",
|
|
15
17
|
...restOk,
|
|
16
|
-
className: cx(styles.buttonBase, danger ? styles.dangerOkButton : styles.okButton, userCls),
|
|
17
|
-
disabled: confirmLoading || userDisabled,
|
|
18
|
-
style: userStyle,
|
|
19
18
|
onClick: (e) => {
|
|
20
19
|
onOk(e);
|
|
21
20
|
userOnClick?.(e);
|
|
22
21
|
},
|
|
23
|
-
children:
|
|
22
|
+
children: okText
|
|
24
23
|
});
|
|
25
24
|
};
|
|
26
25
|
const CancelBtn = ({ cancelButtonProps, cancelText, onCancel }) => {
|
|
27
|
-
const {
|
|
28
|
-
return /* @__PURE__ */ jsx(
|
|
29
|
-
type: "button",
|
|
26
|
+
const { onClick: userOnClick, ...restCancel } = cancelButtonProps ?? {};
|
|
27
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
30
28
|
...restCancel,
|
|
31
|
-
className: cx(styles.buttonBase, styles.cancelButton, userCls),
|
|
32
29
|
onClick: (e) => {
|
|
33
30
|
onCancel(e);
|
|
34
31
|
userOnClick?.(e);
|
|
@@ -47,7 +44,7 @@ const Modal = memo(({ open, title, children, onOk, onCancel, okText = "OK", canc
|
|
|
47
44
|
const triggerDeny = useCallback(() => {
|
|
48
45
|
clearTimeout(denyTimerRef.current);
|
|
49
46
|
setIsDenying(true);
|
|
50
|
-
denyTimerRef.current = setTimeout(() => setIsDenying(false),
|
|
47
|
+
denyTimerRef.current = setTimeout(() => setIsDenying(false), 300);
|
|
51
48
|
}, []);
|
|
52
49
|
const handleOpenChange = useCallback((nextOpen, eventDetails) => {
|
|
53
50
|
if (!open) return;
|
|
@@ -191,7 +188,7 @@ const Modal = memo(({ open, title, children, onOk, onCancel, okText = "OK", canc
|
|
|
191
188
|
className: styles.closeInline,
|
|
192
189
|
type: "button",
|
|
193
190
|
onClick: handleCancel,
|
|
194
|
-
children: closeIcon ?? /* @__PURE__ */ jsx(X, { size:
|
|
191
|
+
children: closeIcon ?? /* @__PURE__ */ jsx(X, { size: 16 })
|
|
195
192
|
})]
|
|
196
193
|
})]
|
|
197
194
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.mjs","names":[],"sources":["../../../src/base-ui/Modal/Modal.tsx"],"sourcesContent":["'use client';\n\nimport { cx } from 'antd-style';\nimport { Maximize2, Minimize2, X } from 'lucide-react';\nimport { useDragControls } from 'motion/react';\nimport type { MouseEvent, PointerEvent } from 'react';\nimport type React from 'react';\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { stopPropagation } from '@/utils/dom';\n\nimport {\n ModalBackdrop,\n ModalContent,\n ModalFooter,\n ModalHeader,\n ModalPopup,\n ModalPortal,\n ModalRoot,\n ModalTitle,\n} from './atoms';\nimport { styles } from './style';\nimport type { ModalComponentProps } from './type';\n\ninterface OkBtnProps {\n confirmLoading?: boolean;\n okButtonProps?: ModalComponentProps['okButtonProps'];\n okText?: React.ReactNode;\n onOk: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nconst OkBtn: React.FC<OkBtnProps> = ({ confirmLoading, okButtonProps, okText, onOk }) => {\n const {\n className: userCls,\n danger,\n disabled: userDisabled,\n onClick: userOnClick,\n style: userStyle,\n ...restOk\n } = okButtonProps ?? {};\n return (\n <button\n type=\"button\"\n {...restOk}\n className={cx(styles.buttonBase, danger ? styles.dangerOkButton : styles.okButton, userCls)}\n disabled={confirmLoading || userDisabled}\n style={userStyle}\n onClick={(e) => {\n onOk(e);\n userOnClick?.(e);\n }}\n >\n {confirmLoading && <span className={styles.loadingSpinner} />}\n {okText}\n </button>\n );\n};\ninterface CancelBtnProps {\n cancelButtonProps?: ModalComponentProps['cancelButtonProps'];\n cancelText?: React.ReactNode;\n onCancel: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nconst CancelBtn: React.FC<CancelBtnProps> = ({ cancelButtonProps, cancelText, onCancel }) => {\n const { className: userCls, onClick: userOnClick, ...restCancel } = cancelButtonProps ?? {};\n return (\n <button\n type=\"button\"\n {...restCancel}\n className={cx(styles.buttonBase, styles.cancelButton, userCls)}\n onClick={(e) => {\n onCancel(e);\n userOnClick?.(e);\n }}\n >\n {cancelText}\n </button>\n );\n};\n\nconst Modal = memo<ModalComponentProps>(\n ({\n open,\n title,\n children,\n onOk,\n onCancel,\n okText = 'OK',\n cancelText = 'Cancel',\n okButtonProps,\n cancelButtonProps,\n confirmLoading,\n footer,\n width,\n height,\n maskClosable = true,\n closable = true,\n closeIcon,\n className,\n style,\n classNames,\n styles: semanticStyles,\n zIndex,\n afterClose,\n afterOpenChange,\n loading,\n getContainer,\n mask = true,\n keyboard,\n draggable = true,\n allowFullscreen = false,\n }) => {\n const dragControls = useDragControls();\n const constraintsRef = useRef<HTMLDivElement>(null);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [isDragging, setIsDragging] = useState(false);\n const [isDenying, setIsDenying] = useState(false);\n const denyTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n useEffect(() => () => clearTimeout(denyTimerRef.current), []);\n\n const triggerDeny = useCallback(() => {\n clearTimeout(denyTimerRef.current);\n setIsDenying(true);\n denyTimerRef.current = setTimeout(() => setIsDenying(false), 400);\n }, []);\n\n const handleOpenChange = useCallback(\n (nextOpen: boolean, eventDetails: { reason: string }) => {\n if (!open) return;\n if (!nextOpen && keyboard === false && eventDetails.reason === 'escape-key') return;\n if (!nextOpen && !maskClosable && eventDetails.reason === 'outside-press') {\n triggerDeny();\n return;\n }\n if (!nextOpen) {\n onCancel?.(new MouseEvent('click') as unknown as MouseEvent<HTMLButtonElement>);\n }\n },\n [onCancel, keyboard, maskClosable, open, triggerDeny],\n );\n\n const handleExitComplete = useCallback(() => {\n setIsFullscreen(false);\n afterClose?.();\n afterOpenChange?.(false);\n }, [afterClose, afterOpenChange]);\n\n const handleAnimationComplete = useCallback(() => {\n if (open) afterOpenChange?.(true);\n }, [open, afterOpenChange]);\n\n const handleDragStart = useCallback(\n (e: PointerEvent) => {\n if (draggable && !isFullscreen) {\n dragControls.start(e);\n setIsDragging(true);\n }\n },\n [draggable, dragControls, isFullscreen],\n );\n\n const handleDragEnd = useCallback(() => {\n setIsDragging(false);\n }, []);\n\n const handleOk = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n onOk?.(e);\n },\n [onOk],\n );\n\n const handleCancel = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n onCancel?.(e);\n },\n [onCancel],\n );\n\n const footerNode = useMemo(() => {\n if (footer === false || footer === null) return null;\n const cancelBtnNode = (\n <CancelBtn\n cancelButtonProps={cancelButtonProps}\n cancelText={cancelText}\n onCancel={handleCancel}\n />\n );\n const okBtnNode = (\n <OkBtn\n confirmLoading={confirmLoading}\n okButtonProps={okButtonProps}\n okText={okText}\n onOk={handleOk}\n />\n );\n const defaultFooter = (\n <>\n {cancelBtnNode}\n {okBtnNode}\n </>\n );\n\n if (typeof footer === 'function') {\n const BoundCancelBtn: React.FC = () => cancelBtnNode;\n const BoundOkBtn: React.FC = () => okBtnNode;\n return footer(defaultFooter, { CancelBtn: BoundCancelBtn, OkBtn: BoundOkBtn });\n }\n\n return footer ?? defaultFooter;\n }, [\n footer,\n cancelButtonProps,\n cancelText,\n handleCancel,\n confirmLoading,\n okButtonProps,\n okText,\n handleOk,\n ]);\n\n const container = getContainer === false ? undefined : (getContainer ?? undefined);\n\n const shouldDrag = draggable && !isFullscreen;\n const dragProps = shouldDrag\n ? {\n drag: true as const,\n dragConstraints: constraintsRef,\n dragControls,\n dragElastic: 0,\n dragListener: false,\n dragMomentum: false,\n whileDrag: { cursor: 'grabbing' as const },\n }\n : {};\n\n const showTitle = title !== undefined && title !== false && title !== null;\n const showHeader = showTitle || closable || allowFullscreen;\n\n const hasHeight = height !== undefined;\n const panelStyle: React.CSSProperties = {\n ...(hasHeight && !isFullscreen ? { height } : {}),\n ...style,\n };\n\n return (\n <ModalRoot\n open={open ?? false}\n zIndex={zIndex}\n onExitComplete={handleExitComplete}\n onOpenChange={handleOpenChange}\n >\n <ModalPortal container={container}>\n {mask && <ModalBackdrop className={classNames?.mask} style={semanticStyles?.mask} />}\n <ModalPopup\n className={classNames?.wrapper}\n popupStyle={semanticStyles?.wrapper}\n ref={constraintsRef}\n style={panelStyle}\n width={isFullscreen ? undefined : width}\n motionProps={{\n ...dragProps,\n onAnimationComplete: handleAnimationComplete,\n }}\n panelClassName={cx(\n className,\n isFullscreen && styles.fullscreenPopupInner,\n isDenying && styles.denyAnimation,\n )}\n >\n {showHeader && (\n <ModalHeader\n className={cx(classNames?.header, shouldDrag && styles.headerDraggable)}\n style={{\n ...(isDragging ? { cursor: 'grabbing' } : {}),\n ...semanticStyles?.header,\n }}\n onPointerCancel={handleDragEnd}\n onPointerDown={handleDragStart}\n onPointerUp={handleDragEnd}\n >\n {showTitle ? (\n <ModalTitle className={classNames?.title} style={semanticStyles?.title}>\n {title}\n </ModalTitle>\n ) : (\n <span />\n )}\n <div className={styles.headerActions} onPointerDown={stopPropagation}>\n {allowFullscreen && (\n <button\n aria-label={isFullscreen ? 'Exit fullscreen' : 'Fullscreen'}\n className={styles.fullscreenToggle}\n type=\"button\"\n onClick={() => setIsFullscreen((prev) => !prev)}\n >\n {isFullscreen ? <Minimize2 size={14} /> : <Maximize2 size={14} />}\n </button>\n )}\n {closable && (\n <button\n aria-label=\"Close\"\n className={styles.closeInline}\n type=\"button\"\n onClick={handleCancel}\n >\n {closeIcon ?? <X size={18} />}\n </button>\n )}\n </div>\n </ModalHeader>\n )}\n <ModalContent\n className={classNames?.body}\n style={{\n ...(hasHeight || isFullscreen ? { flex: 1 } : {}),\n ...semanticStyles?.body,\n }}\n >\n {loading ? (\n <div\n style={{\n display: 'flex',\n justifyContent: 'center',\n padding: '32px 0',\n }}\n >\n <span className={styles.loadingSpinner} style={{ height: 24, width: 24 }} />\n </div>\n ) : (\n children\n )}\n </ModalContent>\n {footerNode !== null && (\n <ModalFooter className={classNames?.footer} style={semanticStyles?.footer}>\n {footerNode}\n </ModalFooter>\n )}\n </ModalPopup>\n </ModalPortal>\n </ModalRoot>\n );\n },\n);\n\nModal.displayName = 'Modal';\n\nexport default Modal;\n"],"mappings":";;;;;;;;;;AA+BA,MAAM,SAA+B,EAAE,gBAAgB,eAAe,QAAQ,WAAW;CACvF,MAAM,EACJ,WAAW,SACX,QACA,UAAU,cACV,SAAS,aACT,OAAO,WACP,GAAG,WACD,iBAAiB,EAAE;AACvB,QACE,qBAAC,UAAD;EACE,MAAK;EACL,GAAI;EACJ,WAAW,GAAG,OAAO,YAAY,SAAS,OAAO,iBAAiB,OAAO,UAAU,QAAQ;EAC3F,UAAU,kBAAkB;EAC5B,OAAO;EACP,UAAU,MAAM;AACd,QAAK,EAAE;AACP,iBAAc,EAAE;;YARpB,CAWG,kBAAkB,oBAAC,QAAD,EAAM,WAAW,OAAO,gBAAkB,CAAA,EAC5D,OACM;;;AASb,MAAM,aAAuC,EAAE,mBAAmB,YAAY,eAAe;CAC3F,MAAM,EAAE,WAAW,SAAS,SAAS,aAAa,GAAG,eAAe,qBAAqB,EAAE;AAC3F,QACE,oBAAC,UAAD;EACE,MAAK;EACL,GAAI;EACJ,WAAW,GAAG,OAAO,YAAY,OAA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D;MACE,WAAW,YAAY;MACvB,OAAO;OACL,GAAI,aAAa,eAAe,EAAE,MAAM,GAAG,GAAG,EAAE;OAChD,GAAG,gBAAgB;OACpB;gBAEA,UACC,oBAAC,OAAD;OACE,OAAO;QACL,SAAS;QACT,gBAAgB;QAChB,SAAS;QACV;iBAED,oBAAC,QAAD;QAAM,WAAW,OAAO;QAAgB,OAAO;SAAE,QAAQ;SAAI,OAAO;SAAI;QAAI,CAAA;OACxE,CAAA,GAEN;MAEW,CAAA;KACd,eAAe,QACd,oBAAC,aAAD;MAAa,WAAW,YAAY;MAAQ,OAAO,gBAAgB;gBAChE;MACW,CAAA;KAEL;MACD;;EACJ,CAAA;EAGjB;AAED,MAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"Modal.mjs","names":[],"sources":["../../../src/base-ui/Modal/Modal.tsx"],"sourcesContent":["'use client';\n\nimport { cx } from 'antd-style';\nimport { Maximize2, Minimize2, X } from 'lucide-react';\nimport { useDragControls } from 'motion/react';\nimport type { MouseEvent, PointerEvent } from 'react';\nimport type React from 'react';\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { stopPropagation } from '@/utils/dom';\n\nimport { Button } from '../Button';\nimport {\n ModalBackdrop,\n ModalContent,\n ModalFooter,\n ModalHeader,\n ModalPopup,\n ModalPortal,\n ModalRoot,\n ModalTitle,\n} from './atoms';\nimport { styles } from './style';\nimport type { ModalComponentProps } from './type';\n\ninterface OkBtnProps {\n confirmLoading?: boolean;\n okButtonProps?: ModalComponentProps['okButtonProps'];\n okText?: React.ReactNode;\n onOk: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nconst OkBtn: React.FC<OkBtnProps> = ({ confirmLoading, okButtonProps, okText, onOk }) => {\n const { onClick: userOnClick, ...restOk } = okButtonProps ?? {};\n return (\n <Button\n loading={confirmLoading}\n type=\"primary\"\n {...restOk}\n onClick={(e) => {\n onOk(e as MouseEvent<HTMLButtonElement>);\n userOnClick?.(e as never);\n }}\n >\n {okText}\n </Button>\n );\n};\ninterface CancelBtnProps {\n cancelButtonProps?: ModalComponentProps['cancelButtonProps'];\n cancelText?: React.ReactNode;\n onCancel: (e: MouseEvent<HTMLButtonElement>) => void;\n}\n\nconst CancelBtn: React.FC<CancelBtnProps> = ({ cancelButtonProps, cancelText, onCancel }) => {\n const { onClick: userOnClick, ...restCancel } = cancelButtonProps ?? {};\n return (\n <Button\n {...restCancel}\n onClick={(e) => {\n onCancel(e as MouseEvent<HTMLButtonElement>);\n userOnClick?.(e as never);\n }}\n >\n {cancelText}\n </Button>\n );\n};\n\nconst Modal = memo<ModalComponentProps>(\n ({\n open,\n title,\n children,\n onOk,\n onCancel,\n okText = 'OK',\n cancelText = 'Cancel',\n okButtonProps,\n cancelButtonProps,\n confirmLoading,\n footer,\n width,\n height,\n maskClosable = true,\n closable = true,\n closeIcon,\n className,\n style,\n classNames,\n styles: semanticStyles,\n zIndex,\n afterClose,\n afterOpenChange,\n loading,\n getContainer,\n mask = true,\n keyboard,\n draggable = true,\n allowFullscreen = false,\n }) => {\n const dragControls = useDragControls();\n const constraintsRef = useRef<HTMLDivElement>(null);\n const [isFullscreen, setIsFullscreen] = useState(false);\n const [isDragging, setIsDragging] = useState(false);\n const [isDenying, setIsDenying] = useState(false);\n const denyTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n\n useEffect(() => () => clearTimeout(denyTimerRef.current), []);\n\n const triggerDeny = useCallback(() => {\n clearTimeout(denyTimerRef.current);\n setIsDenying(true);\n denyTimerRef.current = setTimeout(() => setIsDenying(false), 300);\n }, []);\n\n const handleOpenChange = useCallback(\n (nextOpen: boolean, eventDetails: { reason: string }) => {\n if (!open) return;\n if (!nextOpen && keyboard === false && eventDetails.reason === 'escape-key') return;\n if (!nextOpen && !maskClosable && eventDetails.reason === 'outside-press') {\n triggerDeny();\n return;\n }\n if (!nextOpen) {\n onCancel?.(new MouseEvent('click') as unknown as MouseEvent<HTMLButtonElement>);\n }\n },\n [onCancel, keyboard, maskClosable, open, triggerDeny],\n );\n\n const handleExitComplete = useCallback(() => {\n setIsFullscreen(false);\n afterClose?.();\n afterOpenChange?.(false);\n }, [afterClose, afterOpenChange]);\n\n const handleAnimationComplete = useCallback(() => {\n if (open) afterOpenChange?.(true);\n }, [open, afterOpenChange]);\n\n const handleDragStart = useCallback(\n (e: PointerEvent) => {\n if (draggable && !isFullscreen) {\n dragControls.start(e);\n setIsDragging(true);\n }\n },\n [draggable, dragControls, isFullscreen],\n );\n\n const handleDragEnd = useCallback(() => {\n setIsDragging(false);\n }, []);\n\n const handleOk = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n onOk?.(e);\n },\n [onOk],\n );\n\n const handleCancel = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n onCancel?.(e);\n },\n [onCancel],\n );\n\n const footerNode = useMemo(() => {\n if (footer === false || footer === null) return null;\n const cancelBtnNode = (\n <CancelBtn\n cancelButtonProps={cancelButtonProps}\n cancelText={cancelText}\n onCancel={handleCancel}\n />\n );\n const okBtnNode = (\n <OkBtn\n confirmLoading={confirmLoading}\n okButtonProps={okButtonProps}\n okText={okText}\n onOk={handleOk}\n />\n );\n const defaultFooter = (\n <>\n {cancelBtnNode}\n {okBtnNode}\n </>\n );\n\n if (typeof footer === 'function') {\n const BoundCancelBtn: React.FC = () => cancelBtnNode;\n const BoundOkBtn: React.FC = () => okBtnNode;\n return footer(defaultFooter, { CancelBtn: BoundCancelBtn, OkBtn: BoundOkBtn });\n }\n\n return footer ?? defaultFooter;\n }, [\n footer,\n cancelButtonProps,\n cancelText,\n handleCancel,\n confirmLoading,\n okButtonProps,\n okText,\n handleOk,\n ]);\n\n const container = getContainer === false ? undefined : (getContainer ?? undefined);\n\n const shouldDrag = draggable && !isFullscreen;\n const dragProps = shouldDrag\n ? {\n drag: true as const,\n dragConstraints: constraintsRef,\n dragControls,\n dragElastic: 0,\n dragListener: false,\n dragMomentum: false,\n whileDrag: { cursor: 'grabbing' as const },\n }\n : {};\n\n const showTitle = title !== undefined && title !== false && title !== null;\n const showHeader = showTitle || closable || allowFullscreen;\n\n const hasHeight = height !== undefined;\n const panelStyle: React.CSSProperties = {\n ...(hasHeight && !isFullscreen ? { height } : {}),\n ...style,\n };\n\n return (\n <ModalRoot\n open={open ?? false}\n zIndex={zIndex}\n onExitComplete={handleExitComplete}\n onOpenChange={handleOpenChange}\n >\n <ModalPortal container={container}>\n {mask && <ModalBackdrop className={classNames?.mask} style={semanticStyles?.mask} />}\n <ModalPopup\n className={classNames?.wrapper}\n popupStyle={semanticStyles?.wrapper}\n ref={constraintsRef}\n style={panelStyle}\n width={isFullscreen ? undefined : width}\n motionProps={{\n ...dragProps,\n onAnimationComplete: handleAnimationComplete,\n }}\n panelClassName={cx(\n className,\n isFullscreen && styles.fullscreenPopupInner,\n isDenying && styles.denyAnimation,\n )}\n >\n {showHeader && (\n <ModalHeader\n className={cx(classNames?.header, shouldDrag && styles.headerDraggable)}\n style={{\n ...(isDragging ? { cursor: 'grabbing' } : {}),\n ...semanticStyles?.header,\n }}\n onPointerCancel={handleDragEnd}\n onPointerDown={handleDragStart}\n onPointerUp={handleDragEnd}\n >\n {showTitle ? (\n <ModalTitle className={classNames?.title} style={semanticStyles?.title}>\n {title}\n </ModalTitle>\n ) : (\n <span />\n )}\n <div className={styles.headerActions} onPointerDown={stopPropagation}>\n {allowFullscreen && (\n <button\n aria-label={isFullscreen ? 'Exit fullscreen' : 'Fullscreen'}\n className={styles.fullscreenToggle}\n type=\"button\"\n onClick={() => setIsFullscreen((prev) => !prev)}\n >\n {isFullscreen ? <Minimize2 size={14} /> : <Maximize2 size={14} />}\n </button>\n )}\n {closable && (\n <button\n aria-label=\"Close\"\n className={styles.closeInline}\n type=\"button\"\n onClick={handleCancel}\n >\n {closeIcon ?? <X size={16} />}\n </button>\n )}\n </div>\n </ModalHeader>\n )}\n <ModalContent\n className={classNames?.body}\n style={{\n ...(hasHeight || isFullscreen ? { flex: 1 } : {}),\n ...semanticStyles?.body,\n }}\n >\n {loading ? (\n <div\n style={{\n display: 'flex',\n justifyContent: 'center',\n padding: '32px 0',\n }}\n >\n <span className={styles.loadingSpinner} style={{ height: 24, width: 24 }} />\n </div>\n ) : (\n children\n )}\n </ModalContent>\n {footerNode !== null && (\n <ModalFooter className={classNames?.footer} style={semanticStyles?.footer}>\n {footerNode}\n </ModalFooter>\n )}\n </ModalPopup>\n </ModalPortal>\n </ModalRoot>\n );\n },\n);\n\nModal.displayName = 'Modal';\n\nexport default Modal;\n"],"mappings":";;;;;;;;;;;AAgCA,MAAM,SAA+B,EAAE,gBAAgB,eAAe,QAAQ,WAAW;CACvF,MAAM,EAAE,SAAS,aAAa,GAAG,WAAW,iBAAiB,EAAE;AAC/D,QACE,oBAAC,QAAD;EACE,SAAS;EACT,MAAK;EACL,GAAI;EACJ,UAAU,MAAM;AACd,QAAK,EAAmC;AACxC,iBAAc,EAAW;;YAG1B;EACM,CAAA;;AASb,MAAM,aAAuC,EAAE,mBAAmB,YAAY,eAAe;CAC3F,MAAM,EAAE,SAAS,aAAa,GAAG,eAAe,qBAAqB,EAAE;AACvE,QACE,oBAAC,QAAD;EACE,GAAI;EACJ,UAAU,MAAM;AACd,YAAS,EAAmC;AAC5C,iBAAc,EAAW;;YAG1B;EACM,CAAA;;AAIb,MAAM,QAAQ,MACX,EACC,MACA,OACA,UACA,MACA,UACA,SAAS,MACT,aAAa,UACb,eACA,mBACA,gBACA,QACA,OACA,QACA,eAAe,MACf,WAAW,MACX,WACA,WACA,OACA,YACA,QAAQ,gBACR,QACA,YACA,iBACA,SACA,cACA,OAAO,MACP,UACA,YAAY,MACZ,kBAAkB,YACd;CACJ,MAAM,eAAe,iBAAiB;CACtC,MAAM,iBAAiB,OAAuB,KAAK;CACnD,MAAM,CAAC,cAAc,mBAAmB,SAAS,MAAM;CACvD,MAAM,CAAC,YAAY,iBAAiB,SAAS,MAAM;CACnD,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,eAA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
184
184
|
const ModalClose = ({ className, children, ...rest }) => /* @__PURE__ */ jsx(Dialog.Close, {
|
|
185
185
|
...rest,
|
|
186
186
|
className: mergeStateClassName(styles.close, className),
|
|
187
|
-
children: children ?? /* @__PURE__ */ jsx(X, { size:
|
|
187
|
+
children: children ?? /* @__PURE__ */ jsx(X, { size: 16 })
|
|
188
188
|
});
|
|
189
189
|
const ModalTrigger = ({ children, className, nativeButton, ref: refProp, ...rest }) => {
|
|
190
190
|
const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atoms.mjs","names":[],"sources":["../../../src/base-ui/Modal/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Dialog } from '@base-ui/react/dialog';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { cx } from 'antd-style';\nimport { X } from 'lucide-react';\nimport { AnimatePresence } from 'motion/react';\nimport type React from 'react';\nimport {\n cloneElement,\n createContext,\n isValidElement,\n use,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { mergeRefs, useMergeRefs } from 'react-merge-refs';\n\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { useMotionComponent } from '@/MotionProvider';\nimport { useAppElement } from '@/ThemeProvider';\n\nimport { useLayerZIndex } from '../zIndex';\nimport { backdropTransition, modalMotionConfig } from './constants';\nimport { ModalLayerProvider, useModalLayer } from './ModalLayerContext';\nimport { styles } from './style';\n\nconst mergeStateClassName = <TState,>(\n base: string,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n if (typeof className === 'function') return (state: TState) => cx(base, className(state));\n return cx(base, className);\n};\n\n// --- Animation Contexts (granular to minimize re-renders) ---\n\n// State: open boolean, null = non-animated mode\nconst ModalOpenContext = createContext<boolean | null>(null);\n\n// Actions: stable callbacks, null = non-animated mode\ninterface ModalAnimationActions {\n onExitComplete: () => void;\n}\nconst ModalActionsContext = createContext<ModalAnimationActions | null>(null);\n\nexport const useModalOpen = () => use(ModalOpenContext);\nexport const useModalActions = () => use(ModalActionsContext);\n\n// --- Root ---\nexport type ModalRootProps = Dialog.Root.Props & {\n onExitComplete?: () => void;\n zIndex?: number;\n};\n\nconst AnimatedModalRoot = ({\n open,\n children,\n onExitComplete: onExitCompleteProp,\n zIndex: explicitZIndex,\n ...rest\n}: Omit<ModalRootProps, 'open'> & { open: boolean }) => {\n const [isPresent, setIsPresent] = useState(!!open);\n\n useEffect(() => {\n if (open) setIsPresent(true);\n }, [open]);\n\n const handleExitComplete = useCallback(() => {\n setIsPresent(false);\n onExitCompleteProp?.();\n }, [onExitCompleteProp]);\n\n const actions = useMemo(() => ({ onExitComplete: handleExitComplete }), [handleExitComplete]);\n\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n\n if (!isPresent) return null;\n\n return (\n <ModalOpenContext value={open}>\n <ModalActionsContext value={actions}>\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal open {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n </ModalActionsContext>\n </ModalOpenContext>\n );\n};\n\nconst NonAnimatedModalRoot = ({ zIndex: explicitZIndex, children, ...rest }: ModalRootProps) => {\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n return (\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n );\n};\n\nexport const ModalRoot = ({ open, onExitComplete, ...rest }: ModalRootProps) => {\n if (open !== undefined) {\n return <AnimatedModalRoot open={open} onExitComplete={onExitComplete} {...rest} />;\n }\n return <NonAnimatedModalRoot {...rest} />;\n};\n\n// --- Portal ---\nexport type ModalPortalProps = React.ComponentProps<typeof Dialog.Portal> & {\n container?: HTMLElement | null;\n};\nexport const ModalPortal = ({ container, ...rest }: ModalPortalProps) => {\n const appElement = useAppElement();\n return <Dialog.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\n// --- Viewport ---\nexport type ModalViewportProps = React.ComponentProps<typeof Dialog.Viewport>;\nexport const ModalViewport = ({ className, ...rest }: ModalViewportProps) => (\n <Dialog.Viewport\n {...rest}\n className={mergeStateClassName(styles.viewport, className as any) as any}\n />\n);\n\n// --- Backdrop ---\nexport type ModalBackdropProps = React.ComponentProps<typeof Dialog.Backdrop>;\nexport const ModalBackdrop = ({ className, style, ...rest }: ModalBackdropProps) => {\n const open = useModalOpen();\n const layer = useModalLayer();\n const Motion = useMotionComponent();\n const layerStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex } : undefined;\n\n if (open !== null) {\n return (\n <Dialog.Backdrop\n {...rest}\n className={cx(styles.backdrop, className as string)}\n style={{ ...layerStyle, ...style, transition: 'none' }}\n render={\n <Motion.div\n animate={{ opacity: open ? 1 : 0 }}\n initial={{ opacity: 0 }}\n transition={backdropTransition}\n />\n }\n />\n );\n }\n\n return (\n <Dialog.Backdrop\n {...rest}\n className={mergeStateClassName(styles.backdrop, className as any) as any}\n style={{ ...layerStyle, ...style }}\n />\n );\n};\n\n// --- Popup ---\nexport type ModalPopupProps = React.ComponentProps<typeof Dialog.Popup> & {\n motionProps?: Record<string, any>;\n panelClassName?: string;\n popupStyle?: React.CSSProperties;\n width?: number | string;\n};\nexport const ModalPopup = ({\n className,\n children,\n width,\n style,\n motionProps,\n panelClassName,\n popupStyle,\n ref: forwardedRef,\n ...rest\n}: ModalPopupProps) => {\n const open = useModalOpen();\n const actions = useModalActions();\n const layer = useModalLayer();\n const Motion = useMotionComponent();\n const popupZIndexStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex + 1 } : undefined;\n const composedRef = useMergeRefs([forwardedRef, layer?.popupRef]);\n\n if (open !== null && actions) {\n return (\n <Dialog.Popup\n {...rest}\n className={cx(styles.popup, className as string)}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n >\n <AnimatePresence onExitComplete={actions.onExitComplete}>\n {open ? (\n <Motion.div\n {...modalMotionConfig}\n {...motionProps}\n className={cx(styles.popupInner, panelClassName)}\n key=\"modal-popup-panel\"\n style={{ maxWidth: width ?? undefined, transition: 'none', ...style }}\n >\n {children}\n </Motion.div>\n ) : null}\n </AnimatePresence>\n </Dialog.Popup>\n );\n }\n\n return (\n <Dialog.Popup\n {...rest}\n className={mergeStateClassName(styles.popup, className as any) as any}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n >\n <div\n className={cx(styles.popupInner, panelClassName)}\n style={{ maxWidth: width ?? undefined, ...style }}\n >\n {children}\n </div>\n </Dialog.Popup>\n );\n};\n\n// --- Header ---\nexport type ModalHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalHeader = ({ className, ...rest }: ModalHeaderProps) => (\n <div {...rest} className={cx(styles.header, className)} />\n);\n\n// --- Title ---\nexport type ModalTitleProps = React.ComponentProps<typeof Dialog.Title>;\nexport const ModalTitle = ({ className, ...rest }: ModalTitleProps) => (\n <Dialog.Title {...rest} className={mergeStateClassName(styles.title, className as any) as any} />\n);\n\n// --- Description ---\nexport type ModalDescriptionProps = React.ComponentProps<typeof Dialog.Description>;\nexport const ModalDescription: React.FC<ModalDescriptionProps> = Dialog.Description;\n\n// --- Content ---\nexport type ModalContentProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalContent = ({ className, ...rest }: ModalContentProps) => (\n <div {...rest} className={cx(styles.content, className)} />\n);\n\n// --- Footer ---\nexport type ModalFooterProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalFooter = ({ className, ...rest }: ModalFooterProps) => (\n <div {...rest} className={cx(styles.footer, className)} />\n);\n\n// --- Close ---\nexport type ModalCloseProps = React.ComponentProps<typeof Dialog.Close>;\nexport const ModalClose = ({ className, children, ...rest }: ModalCloseProps) => (\n <Dialog.Close {...rest} className={mergeStateClassName(styles.close, className as any) as any}>\n {children ?? <X size={18} />}\n </Dialog.Close>\n);\n\n// --- Trigger ---\nexport type ModalTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Dialog.Trigger>,\n 'children' | 'render'\n> & {\n children?: React.ReactNode;\n nativeButton?: boolean;\n};\n\nexport const ModalTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: ModalTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return (\n <Dialog.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n render={renderer as any}\n />\n );\n }\n\n return (\n <Dialog.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Dialog.Trigger>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BA,MAAM,uBACJ,MACA,cACG;AACH,KAAI,OAAO,cAAc,WAAY,SAAQ,UAAkB,GAAG,MAAM,UAAU,MAAM,CAAC;AACzF,QAAO,GAAG,MAAM,UAAU;;AAM5B,MAAM,mBAAmB,cAA8B,KAAK;AAM5D,MAAM,sBAAsB,cAA4C,KAAK;AAE7E,MAAa,qBAAqB,IAAI,iBAAiB;AACvD,MAAa,wBAAwB,IAAI,oBAAoB;AAQ7D,M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D,MAAa,cAAc,EAAE,WAAW,UAAU,GAAG,WACnD,oBAAC,OAAO,OAAR;CAAc,GAAI;CAAM,WAAW,oBAAoB,OAAO,OAAO,UAAiB;WACnF,YAAY,oBAAC,GAAD,EAAG,MAAM,IAAM,CAAA;CACf,CAAA;AAYjB,MAAa,gBAAgB,EAC3B,UACA,WACA,cACA,KAAK,SACL,GAAG,WACoB;CACvB,MAAM,EAAE,8BAA8B,yBAAyB,gBAAgB;EAC7E;EACA;EACD,CAAC;CAEF,MAAM,YAAY,UAAe;EAC/B,MAAM,uBAAuB;AAC3B,OAAI,6BAA8B,QAAO;GAEzC,MAAM,EAAE,MAAM,GAAG,cAAc;AAC/B,UAAO;MACL;AAGJ,SAAO,aAAa,UAAiB;GACnC,GAFkB,WAAY,SAAiB,OAAO,cAExC;GACd,KAAK,UAAU;IAAE,SAAiB;IAAM,MAAc;IAAK;IAAQ,CAAC;GACrE,CAAC;;AAGJ,KAAI,eAAe,SAAS,CAC1B,QACE,oBAAC,OAAO,SAAR;EACE,GAAI;EACO;EACX,cAAc;EACd,QAAQ;EACR,CAAA;AAIN,QACE,oBAAC,OAAO,SAAR;EACE,GAAI;EACO;EACX,cAAc;EACd,KAAK;EAEJ;EACc,CAAA"}
|
|
1
|
+
{"version":3,"file":"atoms.mjs","names":[],"sources":["../../../src/base-ui/Modal/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Dialog } from '@base-ui/react/dialog';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { cx } from 'antd-style';\nimport { X } from 'lucide-react';\nimport { AnimatePresence } from 'motion/react';\nimport type React from 'react';\nimport {\n cloneElement,\n createContext,\n isValidElement,\n use,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { mergeRefs, useMergeRefs } from 'react-merge-refs';\n\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { useMotionComponent } from '@/MotionProvider';\nimport { useAppElement } from '@/ThemeProvider';\n\nimport { useLayerZIndex } from '../zIndex';\nimport { backdropTransition, modalMotionConfig } from './constants';\nimport { ModalLayerProvider, useModalLayer } from './ModalLayerContext';\nimport { styles } from './style';\n\nconst mergeStateClassName = <TState,>(\n base: string,\n className: string | ((state: TState) => string | undefined) | undefined,\n) => {\n if (typeof className === 'function') return (state: TState) => cx(base, className(state));\n return cx(base, className);\n};\n\n// --- Animation Contexts (granular to minimize re-renders) ---\n\n// State: open boolean, null = non-animated mode\nconst ModalOpenContext = createContext<boolean | null>(null);\n\n// Actions: stable callbacks, null = non-animated mode\ninterface ModalAnimationActions {\n onExitComplete: () => void;\n}\nconst ModalActionsContext = createContext<ModalAnimationActions | null>(null);\n\nexport const useModalOpen = () => use(ModalOpenContext);\nexport const useModalActions = () => use(ModalActionsContext);\n\n// --- Root ---\nexport type ModalRootProps = Dialog.Root.Props & {\n onExitComplete?: () => void;\n zIndex?: number;\n};\n\nconst AnimatedModalRoot = ({\n open,\n children,\n onExitComplete: onExitCompleteProp,\n zIndex: explicitZIndex,\n ...rest\n}: Omit<ModalRootProps, 'open'> & { open: boolean }) => {\n const [isPresent, setIsPresent] = useState(!!open);\n\n useEffect(() => {\n if (open) setIsPresent(true);\n }, [open]);\n\n const handleExitComplete = useCallback(() => {\n setIsPresent(false);\n onExitCompleteProp?.();\n }, [onExitCompleteProp]);\n\n const actions = useMemo(() => ({ onExitComplete: handleExitComplete }), [handleExitComplete]);\n\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n\n if (!isPresent) return null;\n\n return (\n <ModalOpenContext value={open}>\n <ModalActionsContext value={actions}>\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal open {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n </ModalActionsContext>\n </ModalOpenContext>\n );\n};\n\nconst NonAnimatedModalRoot = ({ zIndex: explicitZIndex, children, ...rest }: ModalRootProps) => {\n const { zIndex, ref: popupRef } = useLayerZIndex<HTMLDivElement>('modal', explicitZIndex);\n const layer = useMemo(\n () => ({ popupRef: popupRef as (node: HTMLElement | null) => void, zIndex }),\n [zIndex, popupRef],\n );\n return (\n <ModalLayerProvider value={layer}>\n <Dialog.Root modal {...rest}>\n {children}\n </Dialog.Root>\n </ModalLayerProvider>\n );\n};\n\nexport const ModalRoot = ({ open, onExitComplete, ...rest }: ModalRootProps) => {\n if (open !== undefined) {\n return <AnimatedModalRoot open={open} onExitComplete={onExitComplete} {...rest} />;\n }\n return <NonAnimatedModalRoot {...rest} />;\n};\n\n// --- Portal ---\nexport type ModalPortalProps = React.ComponentProps<typeof Dialog.Portal> & {\n container?: HTMLElement | null;\n};\nexport const ModalPortal = ({ container, ...rest }: ModalPortalProps) => {\n const appElement = useAppElement();\n return <Dialog.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\n// --- Viewport ---\nexport type ModalViewportProps = React.ComponentProps<typeof Dialog.Viewport>;\nexport const ModalViewport = ({ className, ...rest }: ModalViewportProps) => (\n <Dialog.Viewport\n {...rest}\n className={mergeStateClassName(styles.viewport, className as any) as any}\n />\n);\n\n// --- Backdrop ---\nexport type ModalBackdropProps = React.ComponentProps<typeof Dialog.Backdrop>;\nexport const ModalBackdrop = ({ className, style, ...rest }: ModalBackdropProps) => {\n const open = useModalOpen();\n const layer = useModalLayer();\n const Motion = useMotionComponent();\n const layerStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex } : undefined;\n\n if (open !== null) {\n return (\n <Dialog.Backdrop\n {...rest}\n className={cx(styles.backdrop, className as string)}\n style={{ ...layerStyle, ...style, transition: 'none' }}\n render={\n <Motion.div\n animate={{ opacity: open ? 1 : 0 }}\n initial={{ opacity: 0 }}\n transition={backdropTransition}\n />\n }\n />\n );\n }\n\n return (\n <Dialog.Backdrop\n {...rest}\n className={mergeStateClassName(styles.backdrop, className as any) as any}\n style={{ ...layerStyle, ...style }}\n />\n );\n};\n\n// --- Popup ---\nexport type ModalPopupProps = React.ComponentProps<typeof Dialog.Popup> & {\n motionProps?: Record<string, any>;\n panelClassName?: string;\n popupStyle?: React.CSSProperties;\n width?: number | string;\n};\nexport const ModalPopup = ({\n className,\n children,\n width,\n style,\n motionProps,\n panelClassName,\n popupStyle,\n ref: forwardedRef,\n ...rest\n}: ModalPopupProps) => {\n const open = useModalOpen();\n const actions = useModalActions();\n const layer = useModalLayer();\n const Motion = useMotionComponent();\n const popupZIndexStyle = layer?.zIndex !== undefined ? { zIndex: layer.zIndex + 1 } : undefined;\n const composedRef = useMergeRefs([forwardedRef, layer?.popupRef]);\n\n if (open !== null && actions) {\n return (\n <Dialog.Popup\n {...rest}\n className={cx(styles.popup, className as string)}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n >\n <AnimatePresence onExitComplete={actions.onExitComplete}>\n {open ? (\n <Motion.div\n {...modalMotionConfig}\n {...motionProps}\n className={cx(styles.popupInner, panelClassName)}\n key=\"modal-popup-panel\"\n style={{ maxWidth: width ?? undefined, transition: 'none', ...style }}\n >\n {children}\n </Motion.div>\n ) : null}\n </AnimatePresence>\n </Dialog.Popup>\n );\n }\n\n return (\n <Dialog.Popup\n {...rest}\n className={mergeStateClassName(styles.popup, className as any) as any}\n ref={composedRef as any}\n style={{ ...popupZIndexStyle, ...popupStyle }}\n >\n <div\n className={cx(styles.popupInner, panelClassName)}\n style={{ maxWidth: width ?? undefined, ...style }}\n >\n {children}\n </div>\n </Dialog.Popup>\n );\n};\n\n// --- Header ---\nexport type ModalHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalHeader = ({ className, ...rest }: ModalHeaderProps) => (\n <div {...rest} className={cx(styles.header, className)} />\n);\n\n// --- Title ---\nexport type ModalTitleProps = React.ComponentProps<typeof Dialog.Title>;\nexport const ModalTitle = ({ className, ...rest }: ModalTitleProps) => (\n <Dialog.Title {...rest} className={mergeStateClassName(styles.title, className as any) as any} />\n);\n\n// --- Description ---\nexport type ModalDescriptionProps = React.ComponentProps<typeof Dialog.Description>;\nexport const ModalDescription: React.FC<ModalDescriptionProps> = Dialog.Description;\n\n// --- Content ---\nexport type ModalContentProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalContent = ({ className, ...rest }: ModalContentProps) => (\n <div {...rest} className={cx(styles.content, className)} />\n);\n\n// --- Footer ---\nexport type ModalFooterProps = React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>;\n};\nexport const ModalFooter = ({ className, ...rest }: ModalFooterProps) => (\n <div {...rest} className={cx(styles.footer, className)} />\n);\n\n// --- Close ---\nexport type ModalCloseProps = React.ComponentProps<typeof Dialog.Close>;\nexport const ModalClose = ({ className, children, ...rest }: ModalCloseProps) => (\n <Dialog.Close {...rest} className={mergeStateClassName(styles.close, className as any) as any}>\n {children ?? <X size={16} />}\n </Dialog.Close>\n);\n\n// --- Trigger ---\nexport type ModalTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Dialog.Trigger>,\n 'children' | 'render'\n> & {\n children?: React.ReactNode;\n nativeButton?: boolean;\n};\n\nexport const ModalTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: ModalTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n return cloneElement(children as any, {\n ...mergedProps,\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return (\n <Dialog.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n render={renderer as any}\n />\n );\n }\n\n return (\n <Dialog.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Dialog.Trigger>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BA,MAAM,uBACJ,MACA,cACG;AACH,KAAI,OAAO,cAAc,WAAY,SAAQ,UAAkB,GAAG,MAAM,UAAU,MAAM,CAAC;AACzF,QAAO,GAAG,MAAM,UAAU;;AAM5B,MAAM,mBAAmB,cAA8B,KAAK;AAM5D,MAAM,sBAAsB,cAA4C,KAAK;AAE7E,MAAa,qBAAqB,IAAI,iBAAiB;AACvD,MAAa,wBAAwB,IAAI,oBAAoB;AAQ7D,MAAM,qBAAqB,EACzB,MACA,UACA,gBAAgB,oBAChB,QAAQ,gBACR,GAAG,WACmD;CACtD,MAAM,CAAC,WAAW,gBAAgB,SAAS,CAAC,CAAC,KAAK;AAElD,iBAAgB;AACd,MAAI,KAAM,cAAa,KAAK;IAC3B,CAAC,KAAK,CAAC;CAEV,MAAM,qBAAqB,kBAAkB;AAC3C,eAAa,MAAM;AACnB,wBAAsB;IACrB,CAAC,mBAAmB,CAAC;CAExB,MAAM,UAAU,eAAe,EAAE,gBAAgB,oBAAoB,GAAG,CAAC,mBAAmB,CAAC;CAE7F,MAAM,EAAE,QAAQ,KAAK,aAAa,eAA+B,SAAS,eAAe;CACzF,MAAM,QAAQ,eACL;EAAY;EAAgD;EAAQ,GAC3E,CAAC,QAAQ,SAAS,CACnB;AAED,KAAI,CAAC,UAAW,QAAO;AAEvB,QACE,oBAAC,kBAAD;EAAkB,OAAO;YACvB,oBAAC,qBAAD;GAAqB,OAAO;aAC1B,oBAAC,oBAAD;IAAoB,OAAO;cACzB,oBAAC,OAAO,MAAR;KAAa,OAAA;KAAM,MAAA;KAAK,GAAI;KACzB;KACW,CAAA;IACK,CAAA;GACD,CAAA;EACL,CAAA;;AAIvB,MAAM,wBAAwB,EAAE,QAAQ,gBAAgB,UAAU,GAAG,WAA2B;CAC9F,MAAM,EAA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motion/react";
|
|
2
2
|
|
|
3
3
|
//#region src/base-ui/Modal/constants.d.ts
|
|
4
|
+
type CubicBezier = [number, number, number, number];
|
|
4
5
|
declare const modalMotionConfig: MotionProps;
|
|
5
6
|
declare const backdropTransition: {
|
|
6
7
|
duration: number;
|
|
8
|
+
ease: CubicBezier;
|
|
7
9
|
};
|
|
8
10
|
//#endregion
|
|
9
11
|
export { backdropTransition, modalMotionConfig };
|
|
@@ -1,26 +1,41 @@
|
|
|
1
1
|
//#region src/base-ui/Modal/constants.ts
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
scale: .96
|
|
9
|
-
};
|
|
2
|
+
const softEase = [
|
|
3
|
+
.32,
|
|
4
|
+
.72,
|
|
5
|
+
0,
|
|
6
|
+
1
|
|
7
|
+
];
|
|
10
8
|
const modalMotionConfig = {
|
|
11
|
-
animate:
|
|
9
|
+
animate: {
|
|
10
|
+
opacity: 1,
|
|
11
|
+
scale: 1
|
|
12
|
+
},
|
|
12
13
|
exit: {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
opacity: 0,
|
|
15
|
+
scale: .98,
|
|
16
|
+
transition: {
|
|
17
|
+
duration: .12,
|
|
18
|
+
ease: [
|
|
19
|
+
.4,
|
|
20
|
+
0,
|
|
21
|
+
1,
|
|
22
|
+
1
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
initial: {
|
|
27
|
+
opacity: 0,
|
|
28
|
+
scale: .97
|
|
15
29
|
},
|
|
16
|
-
initial: initialStyle,
|
|
17
30
|
transition: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
type: "spring"
|
|
31
|
+
duration: .22,
|
|
32
|
+
ease: softEase
|
|
21
33
|
}
|
|
22
34
|
};
|
|
23
|
-
const backdropTransition = {
|
|
35
|
+
const backdropTransition = {
|
|
36
|
+
duration: .18,
|
|
37
|
+
ease: softEase
|
|
38
|
+
};
|
|
24
39
|
//#endregion
|
|
25
40
|
export { backdropTransition, modalMotionConfig };
|
|
26
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../src/base-ui/Modal/constants.ts"],"sourcesContent":["import type { MotionProps } from 'motion/react';\n\nconst enterStyle = { opacity: 1, scale: 1 };\nconst
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../src/base-ui/Modal/constants.ts"],"sourcesContent":["import type { MotionProps } from 'motion/react';\n\ntype CubicBezier = [number, number, number, number];\n\nconst softEase: CubicBezier = [0.32, 0.72, 0, 1];\nconst exitEase: CubicBezier = [0.4, 0, 1, 1];\n\nconst initialStyle = { opacity: 0, scale: 0.97 };\nconst enterStyle = { opacity: 1, scale: 1 };\nconst exitStyle = { opacity: 0, scale: 0.98 };\n\nexport const modalMotionConfig: MotionProps = {\n animate: enterStyle,\n exit: {\n ...exitStyle,\n transition: { duration: 0.12, ease: exitEase },\n },\n initial: initialStyle,\n transition: {\n duration: 0.22,\n ease: softEase,\n },\n};\n\nexport const backdropTransition = {\n duration: 0.18,\n ease: softEase,\n};\n"],"mappings":";AAIA,MAAM,WAAwB;CAAC;CAAM;CAAM;CAAG;CAAE;AAOhD,MAAa,oBAAiC;CAC5C,SAAS;EAJU,SAAS;EAAG,OAAO;EAI7B;CACT,MAAM;EAJY,SAAS;EAAG,OAAO;EAMnC,YAAY;GAAE,UAAU;GAAM,MAAM;IAVT;IAAK;IAAG;IAAG;IAUF;GAAU;EAC/C;CACD,SAAS;EAVY,SAAS;EAAG,OAAO;EAU/B;CACT,YAAY;EACV,UAAU;EACV,MAAM;EACP;CACF;AAED,MAAa,qBAAqB;CAChC,UAAU;CACV,MAAM;CACP"}
|