@lobehub/ui 5.40.2 → 5.41.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/es/base-ui/AutoComplete/AutoComplete.mjs +2 -0
- package/es/base-ui/AutoComplete/AutoComplete.mjs.map +1 -1
- package/es/base-ui/ContextMenu/ContextMenuHost.mjs +2 -0
- package/es/base-ui/ContextMenu/ContextMenuHost.mjs.map +1 -1
- package/es/base-ui/ContextMenu/renderItems.mjs +3 -1
- package/es/base-ui/ContextMenu/renderItems.mjs.map +1 -1
- package/es/base-ui/DraggablePanel/DraggablePanel.d.mts +6 -0
- package/es/base-ui/DraggablePanel/DraggablePanel.mjs +68 -0
- package/es/base-ui/DraggablePanel/DraggablePanel.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/atoms.d.mts +47 -0
- package/es/base-ui/DraggablePanel/atoms.mjs +333 -0
- package/es/base-ui/DraggablePanel/atoms.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/context.d.mts +17 -0
- package/es/base-ui/DraggablePanel/context.mjs +13 -0
- package/es/base-ui/DraggablePanel/context.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/core/axes.d.mts +16 -0
- package/es/base-ui/DraggablePanel/core/axes.mjs +51 -0
- package/es/base-ui/DraggablePanel/core/axes.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/core/controller.d.mts +56 -0
- package/es/base-ui/DraggablePanel/core/controller.mjs +206 -0
- package/es/base-ui/DraggablePanel/core/controller.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/core/dom.mjs +34 -0
- package/es/base-ui/DraggablePanel/core/dom.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/core/env.mjs +28 -0
- package/es/base-ui/DraggablePanel/core/env.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/core/internal.mjs +9 -0
- package/es/base-ui/DraggablePanel/core/internal.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/core/transition.mjs +17 -0
- package/es/base-ui/DraggablePanel/core/transition.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/core/utils.mjs +20 -0
- package/es/base-ui/DraggablePanel/core/utils.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/index.d.mts +5 -0
- package/es/base-ui/DraggablePanel/style.mjs +356 -0
- package/es/base-ui/DraggablePanel/style.mjs.map +1 -0
- package/es/base-ui/DraggablePanel/type.d.mts +53 -0
- package/es/base-ui/DropdownMenu/atoms.d.mts +1 -1
- package/es/base-ui/DropdownMenu/atoms.mjs +3 -1
- package/es/base-ui/DropdownMenu/atoms.mjs.map +1 -1
- package/es/base-ui/Input/style.d.mts +2 -2
- package/es/base-ui/Popover/atoms.d.mts +1 -1
- package/es/base-ui/Popover/atoms.mjs +3 -1
- package/es/base-ui/Popover/atoms.mjs.map +1 -1
- package/es/base-ui/Select/Select.mjs +0 -1
- package/es/base-ui/Select/Select.mjs.map +1 -1
- package/es/base-ui/Select/atoms.d.mts +1 -1
- package/es/base-ui/Select/atoms.mjs +3 -1
- package/es/base-ui/Select/atoms.mjs.map +1 -1
- package/es/base-ui/Select/style.mjs +2 -1
- package/es/base-ui/Select/style.mjs.map +1 -1
- package/es/base-ui/Tooltip/TooltipGroup.mjs +2 -0
- package/es/base-ui/Tooltip/TooltipGroup.mjs.map +1 -1
- package/es/base-ui/Tooltip/TooltipStandalone.mjs +2 -0
- package/es/base-ui/Tooltip/TooltipStandalone.mjs.map +1 -1
- package/es/base-ui/floating/collisionPadding.d.mts +7 -0
- package/es/base-ui/floating/collisionPadding.mjs +17 -0
- package/es/base-ui/floating/collisionPadding.mjs.map +1 -0
- package/es/base-ui/index.d.mts +7 -1
- package/es/base-ui/index.mjs +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { createStaticStyles, cx } from "antd-style";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
//#region src/base-ui/DraggablePanel/style.ts
|
|
4
|
+
const TOGGLE_HIT_SHORT = 26;
|
|
5
|
+
const TOGGLE_HIT_LONG = 34;
|
|
6
|
+
const BOW = {
|
|
7
|
+
bulge: 10,
|
|
8
|
+
curve: .44,
|
|
9
|
+
gap: 45,
|
|
10
|
+
half: 46,
|
|
11
|
+
stroke: 1.25
|
|
12
|
+
};
|
|
13
|
+
const prefix = "base-draggable-panel";
|
|
14
|
+
const styles = createStaticStyles(({ css, cssVar }) => {
|
|
15
|
+
const float = css`
|
|
16
|
+
position: absolute;
|
|
17
|
+
z-index: 200;
|
|
18
|
+
`;
|
|
19
|
+
const toggleRoot = cx(`${prefix}-toggle`, css`
|
|
20
|
+
pointer-events: none;
|
|
21
|
+
|
|
22
|
+
position: absolute;
|
|
23
|
+
z-index: 110;
|
|
24
|
+
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
|
|
29
|
+
> button {
|
|
30
|
+
pointer-events: all;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
|
|
33
|
+
position: relative;
|
|
34
|
+
|
|
35
|
+
width: ${TOGGLE_HIT_SHORT}px;
|
|
36
|
+
height: ${TOGGLE_HIT_LONG}px;
|
|
37
|
+
padding: 0;
|
|
38
|
+
border: none;
|
|
39
|
+
|
|
40
|
+
color: ${cssVar.colorTextTertiary};
|
|
41
|
+
|
|
42
|
+
background: none;
|
|
43
|
+
|
|
44
|
+
&:hover {
|
|
45
|
+
color: ${cssVar.colorText};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&:focus-visible {
|
|
49
|
+
outline: 2px solid ${cssVar.colorPrimary};
|
|
50
|
+
outline-offset: 3px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
svg {
|
|
55
|
+
pointer-events: none;
|
|
56
|
+
|
|
57
|
+
position: absolute;
|
|
58
|
+
inset-block-start: 50%;
|
|
59
|
+
inset-inline-start: 50%;
|
|
60
|
+
transform: translate(-50%, -50%) scaleX(0.45);
|
|
61
|
+
|
|
62
|
+
overflow: visible;
|
|
63
|
+
|
|
64
|
+
opacity: 0;
|
|
65
|
+
|
|
66
|
+
transition:
|
|
67
|
+
opacity 0.18s ${cssVar.motionEaseOut},
|
|
68
|
+
transform 0.24s ${cssVar.motionEaseOut};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
path {
|
|
72
|
+
transition: stroke 0.16s ${cssVar.motionEaseOut};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* The bow is the seam bending, so it carries the seam's color, not the chevron's. */
|
|
76
|
+
path[data-bow] {
|
|
77
|
+
stroke: ${cssVar.colorBorderSecondary};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
button:hover path[data-bow] {
|
|
81
|
+
stroke: ${cssVar.colorBorder};
|
|
82
|
+
}
|
|
83
|
+
`);
|
|
84
|
+
return {
|
|
85
|
+
body: css`
|
|
86
|
+
overflow: hidden auto;
|
|
87
|
+
padding: 16px;
|
|
88
|
+
`,
|
|
89
|
+
bottomFloat: cx(float, css`
|
|
90
|
+
inset-block-end: 0;
|
|
91
|
+
inset-inline: 0;
|
|
92
|
+
width: 100%;
|
|
93
|
+
`),
|
|
94
|
+
container: css`
|
|
95
|
+
position: relative;
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
`,
|
|
100
|
+
content: cx(`${prefix}-content`, css`
|
|
101
|
+
display: flex;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
flex-shrink: 0;
|
|
104
|
+
|
|
105
|
+
min-width: 0;
|
|
106
|
+
min-height: 0;
|
|
107
|
+
|
|
108
|
+
background: var(--draggable-panel-bg, ${cssVar.colorBgLayout});
|
|
109
|
+
`),
|
|
110
|
+
fixed: css`
|
|
111
|
+
position: relative;
|
|
112
|
+
`,
|
|
113
|
+
footer: css`
|
|
114
|
+
display: flex;
|
|
115
|
+
flex: none;
|
|
116
|
+
gap: 8px;
|
|
117
|
+
align-items: center;
|
|
118
|
+
|
|
119
|
+
padding-block: 8px;
|
|
120
|
+
padding-inline: 16px;
|
|
121
|
+
border-block-start: 1px solid ${cssVar.colorBorderSecondary};
|
|
122
|
+
`,
|
|
123
|
+
handle: cx(`${prefix}-handle`, css`
|
|
124
|
+
touch-action: none;
|
|
125
|
+
position: absolute;
|
|
126
|
+
z-index: 100;
|
|
127
|
+
|
|
128
|
+
&::before,
|
|
129
|
+
&::after {
|
|
130
|
+
content: '';
|
|
131
|
+
position: absolute;
|
|
132
|
+
background: ${cssVar.colorBorderSecondary};
|
|
133
|
+
transition:
|
|
134
|
+
width 0.25s ${cssVar.motionEaseOut},
|
|
135
|
+
height 0.25s ${cssVar.motionEaseOut},
|
|
136
|
+
background 0.16s ${cssVar.motionEaseOut};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&:hover::before,
|
|
140
|
+
&:hover::after {
|
|
141
|
+
background: ${cssVar.colorFill};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
&[data-resizing]::before,
|
|
145
|
+
&[data-resizing]::after {
|
|
146
|
+
background: ${cssVar.colorPrimary};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
&[data-border='false']::before,
|
|
150
|
+
&[data-border='false']::after {
|
|
151
|
+
background: transparent;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&:focus-visible {
|
|
155
|
+
outline: 2px solid ${cssVar.colorPrimary};
|
|
156
|
+
outline-offset: -2px;
|
|
157
|
+
}
|
|
158
|
+
`),
|
|
159
|
+
handleHorizontal: css`
|
|
160
|
+
cursor: row-resize;
|
|
161
|
+
inset-inline: 0;
|
|
162
|
+
height: var(--draggable-panel-handle-size);
|
|
163
|
+
|
|
164
|
+
&::before,
|
|
165
|
+
&::after {
|
|
166
|
+
inset-block-start: 50%;
|
|
167
|
+
height: 1px;
|
|
168
|
+
margin-block-start: -0.5px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
&::before {
|
|
172
|
+
inset-inline-start: 0;
|
|
173
|
+
width: calc(50% - var(--draggable-panel-gap, 0px));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&::after {
|
|
177
|
+
inset-inline-end: 0;
|
|
178
|
+
width: calc(50% - var(--draggable-panel-gap, 0px));
|
|
179
|
+
}
|
|
180
|
+
`,
|
|
181
|
+
handleVertical: css`
|
|
182
|
+
cursor: col-resize;
|
|
183
|
+
inset-block: 0;
|
|
184
|
+
width: var(--draggable-panel-handle-size);
|
|
185
|
+
|
|
186
|
+
&::before,
|
|
187
|
+
&::after {
|
|
188
|
+
inset-inline-start: 50%;
|
|
189
|
+
width: 1px;
|
|
190
|
+
margin-inline-start: -0.5px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
&::before {
|
|
194
|
+
inset-block-start: 0;
|
|
195
|
+
height: calc(50% - var(--draggable-panel-gap, 0px));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&::after {
|
|
199
|
+
inset-block-end: 0;
|
|
200
|
+
height: calc(50% - var(--draggable-panel-gap, 0px));
|
|
201
|
+
}
|
|
202
|
+
`,
|
|
203
|
+
header: css`
|
|
204
|
+
display: flex;
|
|
205
|
+
flex: none;
|
|
206
|
+
gap: 8px;
|
|
207
|
+
align-items: center;
|
|
208
|
+
justify-content: space-between;
|
|
209
|
+
|
|
210
|
+
padding-block: 8px;
|
|
211
|
+
padding-inline: 16px;
|
|
212
|
+
border-block-end: 1px solid ${cssVar.colorBorderSecondary};
|
|
213
|
+
|
|
214
|
+
font-weight: 500;
|
|
215
|
+
`,
|
|
216
|
+
leftFloat: cx(float, css`
|
|
217
|
+
inset-block: 0;
|
|
218
|
+
inset-inline-start: 0;
|
|
219
|
+
height: 100%;
|
|
220
|
+
`),
|
|
221
|
+
rightFloat: cx(float, css`
|
|
222
|
+
inset-block: 0;
|
|
223
|
+
inset-inline-end: 0;
|
|
224
|
+
height: 100%;
|
|
225
|
+
`),
|
|
226
|
+
root: cx(prefix, css`
|
|
227
|
+
--draggable-panel-gap: 0px;
|
|
228
|
+
|
|
229
|
+
display: flex;
|
|
230
|
+
flex-shrink: 0;
|
|
231
|
+
min-width: 0;
|
|
232
|
+
min-height: 0;
|
|
233
|
+
|
|
234
|
+
&[data-expandable='true']:hover,
|
|
235
|
+
&[data-expandable='true']:focus-within,
|
|
236
|
+
&[data-expandable='true'][data-expand='false'] {
|
|
237
|
+
--draggable-panel-gap: ${BOW.gap}px;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* The wrapper carries an inline opacity when collapsed, so beat it. */
|
|
241
|
+
&[data-expandable='true']:hover
|
|
242
|
+
.${prefix}-toggle,
|
|
243
|
+
&[data-expandable='true']:focus-within
|
|
244
|
+
.${prefix}-toggle {
|
|
245
|
+
opacity: 1 !important;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
&[data-expandable='true']:hover .${prefix}-toggle svg,
|
|
249
|
+
&[data-expandable='true']:focus-within .${prefix}-toggle svg,
|
|
250
|
+
&[data-expandable='true'][data-expand='false'] .${prefix}-toggle svg {
|
|
251
|
+
transform: translate(-50%, -50%) scaleX(1);
|
|
252
|
+
opacity: 1;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
&[data-expandable='true'][data-resizing='true'] {
|
|
256
|
+
--draggable-panel-gap: 0px;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
&[data-expandable='true'][data-resizing='true'] .${prefix}-toggle svg {
|
|
260
|
+
opacity: 0;
|
|
261
|
+
}
|
|
262
|
+
`),
|
|
263
|
+
toggleBottom: cx(`${prefix}-toggle-bottom`, css`
|
|
264
|
+
inset-block-end: -${TOGGLE_HIT_SHORT / 2}px;
|
|
265
|
+
inset-inline: 0;
|
|
266
|
+
height: ${TOGGLE_HIT_SHORT}px;
|
|
267
|
+
|
|
268
|
+
> button {
|
|
269
|
+
width: ${TOGGLE_HIT_LONG}px;
|
|
270
|
+
height: ${TOGGLE_HIT_SHORT}px;
|
|
271
|
+
}
|
|
272
|
+
`),
|
|
273
|
+
toggleLeft: cx(`${prefix}-toggle-left`, css`
|
|
274
|
+
inset-block: 0;
|
|
275
|
+
inset-inline-start: -${TOGGLE_HIT_SHORT / 2}px;
|
|
276
|
+
width: ${TOGGLE_HIT_SHORT}px;
|
|
277
|
+
`),
|
|
278
|
+
toggleRight: cx(`${prefix}-toggle-right`, css`
|
|
279
|
+
inset-block: 0;
|
|
280
|
+
inset-inline-end: -${TOGGLE_HIT_SHORT / 2}px;
|
|
281
|
+
width: ${TOGGLE_HIT_SHORT}px;
|
|
282
|
+
`),
|
|
283
|
+
toggleRoot,
|
|
284
|
+
toggleTop: cx(`${prefix}-toggle-top`, css`
|
|
285
|
+
inset-block-start: -${TOGGLE_HIT_SHORT / 2}px;
|
|
286
|
+
inset-inline: 0;
|
|
287
|
+
height: ${TOGGLE_HIT_SHORT}px;
|
|
288
|
+
|
|
289
|
+
> button {
|
|
290
|
+
width: ${TOGGLE_HIT_LONG}px;
|
|
291
|
+
height: ${TOGGLE_HIT_SHORT}px;
|
|
292
|
+
}
|
|
293
|
+
`),
|
|
294
|
+
topFloat: cx(float, css`
|
|
295
|
+
inset-block-start: 0;
|
|
296
|
+
inset-inline: 0;
|
|
297
|
+
width: 100%;
|
|
298
|
+
`)
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
const rootVariants = cva(styles.root, {
|
|
302
|
+
compoundVariants: [
|
|
303
|
+
{
|
|
304
|
+
class: styles.leftFloat,
|
|
305
|
+
mode: "float",
|
|
306
|
+
placement: "left"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
class: styles.rightFloat,
|
|
310
|
+
mode: "float",
|
|
311
|
+
placement: "right"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
class: styles.topFloat,
|
|
315
|
+
mode: "float",
|
|
316
|
+
placement: "top"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
class: styles.bottomFloat,
|
|
320
|
+
mode: "float",
|
|
321
|
+
placement: "bottom"
|
|
322
|
+
}
|
|
323
|
+
],
|
|
324
|
+
defaultVariants: {
|
|
325
|
+
mode: "fixed",
|
|
326
|
+
placement: "right"
|
|
327
|
+
},
|
|
328
|
+
variants: {
|
|
329
|
+
mode: {
|
|
330
|
+
fixed: styles.fixed,
|
|
331
|
+
float: null
|
|
332
|
+
},
|
|
333
|
+
placement: {
|
|
334
|
+
bottom: null,
|
|
335
|
+
left: null,
|
|
336
|
+
right: null,
|
|
337
|
+
top: null
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
const handleVariants = cva(styles.handle, { variants: { edge: {
|
|
342
|
+
bottom: styles.handleHorizontal,
|
|
343
|
+
left: styles.handleVertical,
|
|
344
|
+
right: styles.handleVertical,
|
|
345
|
+
top: styles.handleHorizontal
|
|
346
|
+
} } });
|
|
347
|
+
const toggleVariants = cva(styles.toggleRoot, { variants: { placement: {
|
|
348
|
+
bottom: styles.toggleTop,
|
|
349
|
+
left: styles.toggleRight,
|
|
350
|
+
right: styles.toggleLeft,
|
|
351
|
+
top: styles.toggleBottom
|
|
352
|
+
} } });
|
|
353
|
+
//#endregion
|
|
354
|
+
export { BOW, handleVariants, rootVariants, styles, toggleVariants };
|
|
355
|
+
|
|
356
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../../src/base-ui/DraggablePanel/style.ts"],"sourcesContent":["import { createStaticStyles, cx } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nconst TOGGLE_HIT_SHORT = 26;\nconst TOGGLE_HIT_LONG = 34;\n\nexport const BOW = {\n bulge: 10,\n curve: 0.44,\n gap: 45,\n half: 46,\n stroke: 1.25,\n};\n\nconst prefix = 'base-draggable-panel';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => {\n const float = css`\n position: absolute;\n z-index: 200;\n `;\n\n const toggleRoot = cx(\n `${prefix}-toggle`,\n css`\n pointer-events: none;\n\n position: absolute;\n z-index: 110;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n > button {\n pointer-events: all;\n cursor: pointer;\n\n position: relative;\n\n width: ${TOGGLE_HIT_SHORT}px;\n height: ${TOGGLE_HIT_LONG}px;\n padding: 0;\n border: none;\n\n color: ${cssVar.colorTextTertiary};\n\n background: none;\n\n &:hover {\n color: ${cssVar.colorText};\n }\n\n &:focus-visible {\n outline: 2px solid ${cssVar.colorPrimary};\n outline-offset: 3px;\n }\n }\n\n svg {\n pointer-events: none;\n\n position: absolute;\n inset-block-start: 50%;\n inset-inline-start: 50%;\n transform: translate(-50%, -50%) scaleX(0.45);\n\n overflow: visible;\n\n opacity: 0;\n\n transition:\n opacity 0.18s ${cssVar.motionEaseOut},\n transform 0.24s ${cssVar.motionEaseOut};\n }\n\n path {\n transition: stroke 0.16s ${cssVar.motionEaseOut};\n }\n\n /* The bow is the seam bending, so it carries the seam's color, not the chevron's. */\n path[data-bow] {\n stroke: ${cssVar.colorBorderSecondary};\n }\n\n button:hover path[data-bow] {\n stroke: ${cssVar.colorBorder};\n }\n `,\n );\n\n return {\n body: css`\n overflow: hidden auto;\n padding: 16px;\n `,\n bottomFloat: cx(\n float,\n css`\n inset-block-end: 0;\n inset-inline: 0;\n width: 100%;\n `,\n ),\n container: css`\n position: relative;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n `,\n content: cx(\n `${prefix}-content`,\n css`\n display: flex;\n flex-direction: column;\n flex-shrink: 0;\n\n min-width: 0;\n min-height: 0;\n\n background: var(--draggable-panel-bg, ${cssVar.colorBgLayout});\n `,\n ),\n fixed: css`\n position: relative;\n `,\n footer: css`\n display: flex;\n flex: none;\n gap: 8px;\n align-items: center;\n\n padding-block: 8px;\n padding-inline: 16px;\n border-block-start: 1px solid ${cssVar.colorBorderSecondary};\n `,\n handle: cx(\n `${prefix}-handle`,\n css`\n touch-action: none;\n position: absolute;\n z-index: 100;\n\n &::before,\n &::after {\n content: '';\n position: absolute;\n background: ${cssVar.colorBorderSecondary};\n transition:\n width 0.25s ${cssVar.motionEaseOut},\n height 0.25s ${cssVar.motionEaseOut},\n background 0.16s ${cssVar.motionEaseOut};\n }\n\n &:hover::before,\n &:hover::after {\n background: ${cssVar.colorFill};\n }\n\n &[data-resizing]::before,\n &[data-resizing]::after {\n background: ${cssVar.colorPrimary};\n }\n\n &[data-border='false']::before,\n &[data-border='false']::after {\n background: transparent;\n }\n\n &:focus-visible {\n outline: 2px solid ${cssVar.colorPrimary};\n outline-offset: -2px;\n }\n `,\n ),\n handleHorizontal: css`\n cursor: row-resize;\n inset-inline: 0;\n height: var(--draggable-panel-handle-size);\n\n &::before,\n &::after {\n inset-block-start: 50%;\n height: 1px;\n margin-block-start: -0.5px;\n }\n\n &::before {\n inset-inline-start: 0;\n width: calc(50% - var(--draggable-panel-gap, 0px));\n }\n\n &::after {\n inset-inline-end: 0;\n width: calc(50% - var(--draggable-panel-gap, 0px));\n }\n `,\n handleVertical: css`\n cursor: col-resize;\n inset-block: 0;\n width: var(--draggable-panel-handle-size);\n\n &::before,\n &::after {\n inset-inline-start: 50%;\n width: 1px;\n margin-inline-start: -0.5px;\n }\n\n &::before {\n inset-block-start: 0;\n height: calc(50% - var(--draggable-panel-gap, 0px));\n }\n\n &::after {\n inset-block-end: 0;\n height: calc(50% - var(--draggable-panel-gap, 0px));\n }\n `,\n header: css`\n display: flex;\n flex: none;\n gap: 8px;\n align-items: center;\n justify-content: space-between;\n\n padding-block: 8px;\n padding-inline: 16px;\n border-block-end: 1px solid ${cssVar.colorBorderSecondary};\n\n font-weight: 500;\n `,\n leftFloat: cx(\n float,\n css`\n inset-block: 0;\n inset-inline-start: 0;\n height: 100%;\n `,\n ),\n rightFloat: cx(\n float,\n css`\n inset-block: 0;\n inset-inline-end: 0;\n height: 100%;\n `,\n ),\n root: cx(\n prefix,\n css`\n --draggable-panel-gap: 0px;\n\n display: flex;\n flex-shrink: 0;\n min-width: 0;\n min-height: 0;\n\n &[data-expandable='true']:hover,\n &[data-expandable='true']:focus-within,\n &[data-expandable='true'][data-expand='false'] {\n --draggable-panel-gap: ${BOW.gap}px;\n }\n\n /* The wrapper carries an inline opacity when collapsed, so beat it. */\n &[data-expandable='true']:hover\n .${prefix}-toggle,\n &[data-expandable='true']:focus-within\n .${prefix}-toggle {\n opacity: 1 !important;\n }\n\n &[data-expandable='true']:hover .${prefix}-toggle svg,\n &[data-expandable='true']:focus-within .${prefix}-toggle svg,\n &[data-expandable='true'][data-expand='false'] .${prefix}-toggle svg {\n transform: translate(-50%, -50%) scaleX(1);\n opacity: 1;\n }\n\n &[data-expandable='true'][data-resizing='true'] {\n --draggable-panel-gap: 0px;\n }\n\n &[data-expandable='true'][data-resizing='true'] .${prefix}-toggle svg {\n opacity: 0;\n }\n `,\n ),\n toggleBottom: cx(\n `${prefix}-toggle-bottom`,\n css`\n inset-block-end: -${TOGGLE_HIT_SHORT / 2}px;\n inset-inline: 0;\n height: ${TOGGLE_HIT_SHORT}px;\n\n > button {\n width: ${TOGGLE_HIT_LONG}px;\n height: ${TOGGLE_HIT_SHORT}px;\n }\n `,\n ),\n toggleLeft: cx(\n `${prefix}-toggle-left`,\n css`\n inset-block: 0;\n inset-inline-start: -${TOGGLE_HIT_SHORT / 2}px;\n width: ${TOGGLE_HIT_SHORT}px;\n `,\n ),\n toggleRight: cx(\n `${prefix}-toggle-right`,\n css`\n inset-block: 0;\n inset-inline-end: -${TOGGLE_HIT_SHORT / 2}px;\n width: ${TOGGLE_HIT_SHORT}px;\n `,\n ),\n toggleRoot,\n toggleTop: cx(\n `${prefix}-toggle-top`,\n css`\n inset-block-start: -${TOGGLE_HIT_SHORT / 2}px;\n inset-inline: 0;\n height: ${TOGGLE_HIT_SHORT}px;\n\n > button {\n width: ${TOGGLE_HIT_LONG}px;\n height: ${TOGGLE_HIT_SHORT}px;\n }\n `,\n ),\n\n topFloat: cx(\n float,\n css`\n inset-block-start: 0;\n inset-inline: 0;\n width: 100%;\n `,\n ),\n };\n});\n\nexport const rootVariants = cva(styles.root, {\n compoundVariants: [\n { class: styles.leftFloat, mode: 'float', placement: 'left' },\n { class: styles.rightFloat, mode: 'float', placement: 'right' },\n { class: styles.topFloat, mode: 'float', placement: 'top' },\n { class: styles.bottomFloat, mode: 'float', placement: 'bottom' },\n ],\n defaultVariants: { mode: 'fixed', placement: 'right' },\n variants: {\n mode: { fixed: styles.fixed, float: null },\n placement: { bottom: null, left: null, right: null, top: null },\n },\n});\n\nexport const handleVariants = cva(styles.handle, {\n variants: {\n edge: {\n bottom: styles.handleHorizontal,\n left: styles.handleVertical,\n right: styles.handleVertical,\n top: styles.handleHorizontal,\n },\n },\n});\n\nexport const toggleVariants = cva(styles.toggleRoot, {\n variants: {\n placement: {\n bottom: styles.toggleTop,\n left: styles.toggleRight,\n right: styles.toggleLeft,\n top: styles.toggleBottom,\n },\n },\n});\n"],"mappings":";;;AAGA,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AAExB,MAAa,MAAM;CACjB,OAAO;CACP,OAAO;CACP,KAAK;CACL,MAAM;CACN,QAAQ;AACV;AAEA,MAAM,SAAS;AAEf,MAAa,SAAS,oBAAoB,EAAE,KAAK,aAAa;CAC5D,MAAM,QAAQ,GAAG;;;;CAKjB,MAAM,aAAa,GACjB,GAAG,OAAO,UACV,GAAG;;;;;;;;;;;;;;;;iBAgBU,iBAAiB;kBAChB,gBAAgB;;;;iBAIjB,OAAO,kBAAkB;;;;;mBAKvB,OAAO,UAAU;;;;+BAIL,OAAO,aAAa;;;;;;;;;;;;;;;;;;0BAkBzB,OAAO,cAAc;4BACnB,OAAO,cAAc;;;;mCAId,OAAO,cAAc;;;;;kBAKtC,OAAO,qBAAqB;;;;kBAI5B,OAAO,YAAY;;KAGnC;CAEA,OAAO;EACL,MAAM,GAAG;;;;EAIT,aAAa,GACX,OACA,GAAG;;;;OAKL;EACA,WAAW,GAAG;;;;;;EAMd,SAAS,GACP,GAAG,OAAO,WACV,GAAG;;;;;;;;gDAQuC,OAAO,cAAc;OAEjE;EACA,OAAO,G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,WAAW;EAAO;EAC5D;GAAE,OAAO,OAAO;GAAY,MAAM;GAAS,WAAW;EAAQ;EAC9D;GAAE,OAAO,OAAO;GAAU,MAAM;GAAS,WAAW;EAAM;EAC1D;GAAE,OAAO,OAAO;GAAa,MAAM;GAAS,WAAW;EAAS;CAClE;CACA,iBAAiB;EAAE,MAAM;EAAS,WAAW;CAAQ;CACrD,UAAU;EACR,MAAM;GAAE,OAAO,OAAO;GAAO,OAAO;EAAK;EACzC,WAAW;GAAE,QAAQ;GAAM,MAAM;GAAM,OAAO;GAAM,KAAK;EAAK;CAChE;AACF,CAAC;AAED,MAAa,iBAAiB,IAAI,OAAO,QAAQ,EAC/C,UAAU,EACR,MAAM;CACJ,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd,EACF,EACF,CAAC;AAED,MAAa,iBAAiB,IAAI,OAAO,YAAY,EACnD,UAAU,EACR,WAAW;CACT,QAAQ,OAAO;CACf,MAAM,OAAO;CACb,OAAO,OAAO;CACd,KAAK,OAAO;AACd,EACF,EACF,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { DivProps } from "../../types/index.mjs";
|
|
2
|
+
import { Placement } from "./core/axes.mjs";
|
|
3
|
+
import { CSSProperties } from "react";
|
|
4
|
+
//#region src/base-ui/DraggablePanel/type.d.ts
|
|
5
|
+
type DraggablePanelPlacement = Placement;
|
|
6
|
+
interface DraggablePanelSize {
|
|
7
|
+
height?: number | string;
|
|
8
|
+
width?: number | string;
|
|
9
|
+
}
|
|
10
|
+
interface DraggablePanelProps extends Omit<DivProps, 'onDrag'> {
|
|
11
|
+
backgroundColor?: string;
|
|
12
|
+
classNames?: {
|
|
13
|
+
content?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Preview a collapsed panel while resizing at or below this size, then commit
|
|
17
|
+
* the collapsed state on pointer release. Dragging back above the threshold
|
|
18
|
+
* before release restores the panel.
|
|
19
|
+
* Omit to disable drag-to-collapse behavior.
|
|
20
|
+
*/
|
|
21
|
+
collapseThreshold?: number;
|
|
22
|
+
defaultExpand?: boolean;
|
|
23
|
+
defaultSize?: DraggablePanelSize;
|
|
24
|
+
expand?: boolean;
|
|
25
|
+
expandable?: boolean;
|
|
26
|
+
maxHeight?: number;
|
|
27
|
+
maxWidth?: number;
|
|
28
|
+
minHeight?: number;
|
|
29
|
+
minWidth?: number;
|
|
30
|
+
mode?: 'fixed' | 'float';
|
|
31
|
+
onExpandChange?: (expand: boolean) => void;
|
|
32
|
+
onSizeChange?: (delta: DraggablePanelSize, size: DraggablePanelSize) => void;
|
|
33
|
+
onSizeDragging?: (delta: DraggablePanelSize, size: DraggablePanelSize) => void;
|
|
34
|
+
/**
|
|
35
|
+
* `placement` is resolved against the inline axis, so `left` means inline-start
|
|
36
|
+
* and flips with `dir="rtl"`.
|
|
37
|
+
*/
|
|
38
|
+
placement?: DraggablePanelPlacement;
|
|
39
|
+
showBorder?: boolean;
|
|
40
|
+
showHandleWhenCollapsed?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Widen the resize handle's hit area from 8px to 16px. A coarse pointer always
|
|
43
|
+
* gets 20px regardless.
|
|
44
|
+
*/
|
|
45
|
+
showHandleWideArea?: boolean;
|
|
46
|
+
size?: DraggablePanelSize;
|
|
47
|
+
styles?: {
|
|
48
|
+
content?: CSSProperties;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { DraggablePanelPlacement, DraggablePanelProps, DraggablePanelSize };
|
|
53
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -27,7 +27,7 @@ type DropdownMenuPositionerProps = React.ComponentProps<typeof Menu.Positioner>
|
|
|
27
27
|
placement?: DropdownMenuPlacement;
|
|
28
28
|
};
|
|
29
29
|
declare const DropdownMenuPositioner: {
|
|
30
|
-
({ className, placement, hoverTrigger, align, side, sideOffset, children, style, ...rest }: DropdownMenuPositionerProps): React.JSX.Element;
|
|
30
|
+
({ className, collisionPadding, placement, hoverTrigger, align, side, sideOffset, children, style, ...rest }: DropdownMenuPositionerProps): React.JSX.Element;
|
|
31
31
|
displayName: string;
|
|
32
32
|
};
|
|
33
33
|
type DropdownMenuPopupProps = React.ComponentProps<typeof Menu.Popup>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useNativeButton } from "../../hooks/useNativeButton.mjs";
|
|
3
|
+
import { getFloatingCollisionPadding } from "../floating/collisionPadding.mjs";
|
|
3
4
|
import { FloatingLayerProvider } from "../../hooks/useFloatingLayer.mjs";
|
|
4
5
|
import { useAppElement } from "../../ThemeProvider/AppElementContext.mjs";
|
|
5
6
|
import { CLASSNAMES } from "../../styles/classNames.mjs";
|
|
@@ -69,7 +70,7 @@ const DropdownMenuPortal = ({ container, ...rest }) => {
|
|
|
69
70
|
});
|
|
70
71
|
};
|
|
71
72
|
DropdownMenuPortal.displayName = "DropdownMenuPortal";
|
|
72
|
-
const DropdownMenuPositioner = ({ className, placement, hoverTrigger, align, side, sideOffset, children, style, ...rest }) => {
|
|
73
|
+
const DropdownMenuPositioner = ({ className, collisionPadding, placement, hoverTrigger, align, side, sideOffset, children, style, ...rest }) => {
|
|
73
74
|
const placementConfig = placement ? placementMap[placement] : void 0;
|
|
74
75
|
const [positionerNode, setPositionerNode] = useState(null);
|
|
75
76
|
const explicitZIndex = typeof style !== "function" && style?.zIndex != null && typeof style.zIndex === "number" ? style.zIndex : void 0;
|
|
@@ -86,6 +87,7 @@ const DropdownMenuPositioner = ({ className, placement, hoverTrigger, align, sid
|
|
|
86
87
|
...rest,
|
|
87
88
|
align: align ?? placementConfig?.align,
|
|
88
89
|
className: mergeStateClassName(styles.positioner, className),
|
|
90
|
+
collisionPadding: collisionPadding ?? getFloatingCollisionPadding(),
|
|
89
91
|
"data-hover-trigger": hoverTrigger || void 0,
|
|
90
92
|
"data-placement": placement,
|
|
91
93
|
ref: composedRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atoms.mjs","names":[],"sources":["../../../src/base-ui/DropdownMenu/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Menu } from '@base-ui/react/menu';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { cx } from 'antd-style';\nimport clsx from 'clsx';\nimport type React from 'react';\nimport { cloneElement, isValidElement, useCallback, useState } from 'react';\nimport { mergeRefs, useMergeRefs } from 'react-merge-refs';\n\nimport Switch from '@/base-ui/Switch';\nimport { FloatingLayerProvider } from '@/hooks/useFloatingLayer';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { CLASSNAMES } from '@/styles/classNames';\nimport { useAppElement } from '@/ThemeProvider';\nimport { placementMap } from '@/utils/placement';\n\nimport { useLayerZIndex } from '../zIndex';\nimport { styles } from './sharedStyle';\nimport { type DropdownMenuPlacement } from './type';\n\nexport const DropdownMenuRoot: typeof Menu.Root = (props) => <Menu.Root modal={false} {...props} />;\nexport const DropdownMenuSubmenuRoot = Menu.SubmenuRoot;\nexport const DropdownMenuCheckboxItemIndicator = Menu.CheckboxItemIndicator;\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\nexport type DropdownMenuTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Menu.Trigger>,\n 'children' | 'render'\n> & {\n children: React.ReactNode;\n};\n\nexport const DropdownMenuTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: DropdownMenuTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n // Base UI's trigger props include `type=\"button\"` by default.\n // If we render into a non-<button> element, that prop is invalid and can warn.\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 className: clsx(CLASSNAMES.DropdownMenuTrigger, className, mergedProps.className),\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return <Menu.Trigger {...rest} nativeButton={resolvedNativeButton} render={renderer as any} />;\n }\n\n return (\n <Menu.Trigger\n {...rest}\n className={clsx(CLASSNAMES.DropdownMenuTrigger, className)}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Menu.Trigger>\n );\n};\n\nDropdownMenuTrigger.displayName = 'DropdownMenuTrigger';\n\nexport type DropdownMenuPortalProps = React.ComponentProps<typeof Menu.Portal> & {\n /**\n * When `container` is not provided, it uses a shared container created by `usePortalContainer`.\n */\n container?: HTMLElement | null;\n};\n\nexport const DropdownMenuPortal = ({ container, ...rest }: DropdownMenuPortalProps) => {\n const appElement = useAppElement();\n return <Menu.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\nDropdownMenuPortal.displayName = 'DropdownMenuPortal';\n\nexport type DropdownMenuPositionerProps = React.ComponentProps<typeof Menu.Positioner> & {\n hoverTrigger?: boolean;\n placement?: DropdownMenuPlacement;\n};\n\nexport const DropdownMenuPositioner = ({\n className,\n placement,\n hoverTrigger,\n align,\n side,\n sideOffset,\n children,\n style,\n ...rest\n}: DropdownMenuPositionerProps) => {\n const placementConfig = placement ? placementMap[placement] : undefined;\n const [positionerNode, setPositionerNode] = useState<HTMLDivElement | null>(null);\n\n const explicitZIndex =\n typeof style !== 'function' && style?.zIndex != null && typeof style.zIndex === 'number'\n ? style.zIndex\n : undefined;\n const { zIndex, ref: zRef } = useLayerZIndex<HTMLDivElement>('floating', explicitZIndex);\n const composedRef = useMergeRefs([setPositionerNode, zRef]);\n\n const resolvedStyle =\n typeof style === 'function'\n ? (state: any) => ({ zIndex, ...style(state) })\n : { zIndex, ...style };\n\n return (\n <Menu.Positioner\n {...rest}\n align={align ?? placementConfig?.align}\n className={mergeStateClassName(styles.positioner, className as any) as any}\n data-hover-trigger={hoverTrigger || undefined}\n data-placement={placement}\n ref={composedRef as any}\n side={side ?? placementConfig?.side}\n sideOffset={sideOffset ?? (placementConfig ? 6 : undefined)}\n style={resolvedStyle}\n >\n <FloatingLayerProvider value={positionerNode}>{children}</FloatingLayerProvider>\n </Menu.Positioner>\n );\n};\n\nDropdownMenuPositioner.displayName = 'DropdownMenuPositioner';\n\nexport type DropdownMenuPopupProps = React.ComponentProps<typeof Menu.Popup>;\n\nexport const DropdownMenuPopup = ({ className, ...rest }: DropdownMenuPopupProps) => {\n return (\n <Menu.Popup {...rest} className={mergeStateClassName(styles.popup, className as any) as any} />\n );\n};\n\nDropdownMenuPopup.displayName = 'DropdownMenuPopup';\n\nexport type DropdownMenuHeaderProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuHeader = ({ className, ...rest }: DropdownMenuHeaderProps) => {\n return <div {...rest} className={cx(styles.header, className)} />;\n};\n\nDropdownMenuHeader.displayName = 'DropdownMenuHeader';\n\nexport type DropdownMenuFooterProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuFooter = ({ className, ...rest }: DropdownMenuFooterProps) => {\n return <div {...rest} className={cx(styles.footer, className)} />;\n};\n\nDropdownMenuFooter.displayName = 'DropdownMenuFooter';\n\nexport type DropdownMenuScrollViewportProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuScrollViewport = ({\n className,\n ...rest\n}: DropdownMenuScrollViewportProps) => {\n return <div {...rest} className={cx(styles.slotViewport, className)} />;\n};\n\nDropdownMenuScrollViewport.displayName = 'DropdownMenuScrollViewport';\n\nexport type DropdownMenuItemProps = React.ComponentProps<typeof Menu.Item> & { danger?: boolean };\n\nexport const DropdownMenuItem = ({ className, danger, ...rest }: DropdownMenuItemProps) => {\n return (\n <Menu.Item\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\nexport type DropdownMenuCheckboxItemProps = React.ComponentProps<typeof Menu.CheckboxItem> & {\n danger?: boolean;\n};\n\nexport const DropdownMenuCheckboxItemPrimitive = ({\n className,\n danger,\n ...rest\n}: DropdownMenuCheckboxItemProps) => {\n return (\n <Menu.CheckboxItem\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuCheckboxItemPrimitive.displayName = 'DropdownMenuCheckboxItemPrimitive';\n\nexport type DropdownMenuSeparatorProps = React.ComponentProps<typeof Menu.Separator>;\n\nexport const DropdownMenuSeparator = ({ className, ...rest }: DropdownMenuSeparatorProps) => {\n return (\n <Menu.Separator\n {...rest}\n className={(state) =>\n cx(styles.separator, typeof className === 'function' ? className(state) : className)\n }\n />\n );\n};\n\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\nexport const DropdownMenuGroup = Menu.Group;\n\nexport type DropdownMenuGroupLabelProps = React.ComponentProps<typeof Menu.GroupLabel>;\n\nexport const DropdownMenuGroupLabel = ({ className, ...rest }: DropdownMenuGroupLabelProps) => {\n return (\n <Menu.GroupLabel\n {...rest}\n className={(state) =>\n cx(styles.groupLabel, typeof className === 'function' ? className(state) : className)\n }\n />\n );\n};\n\nDropdownMenuGroupLabel.displayName = 'DropdownMenuGroupLabel';\n\nexport type DropdownMenuSubmenuTriggerProps = React.ComponentProps<typeof Menu.SubmenuTrigger> & {\n danger?: boolean;\n};\n\nexport const DropdownMenuSubmenuTrigger = ({\n className,\n danger,\n ...rest\n}: DropdownMenuSubmenuTriggerProps) => {\n return (\n <Menu.SubmenuTrigger\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuSubmenuTrigger.displayName = 'DropdownMenuSubmenuTrigger';\n\nexport type DropdownMenuItemContentProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuItemContent = ({ className, ...rest }: DropdownMenuItemContentProps) => {\n return <div {...rest} className={cx(styles.itemContent, className)} />;\n};\n\nDropdownMenuItemContent.displayName = 'DropdownMenuItemContent';\n\nexport type DropdownMenuItemIconProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemIcon = ({ className, ...rest }: DropdownMenuItemIconProps) => {\n return <span {...rest} className={cx(styles.icon, className)} />;\n};\n\nDropdownMenuItemIcon.displayName = 'DropdownMenuItemIcon';\n\nexport type DropdownMenuItemLabelGroupProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuItemLabelGroup = ({\n className,\n ...rest\n}: DropdownMenuItemLabelGroupProps) => {\n return <div {...rest} className={cx(styles.labelGroup, className)} />;\n};\n\nDropdownMenuItemLabelGroup.displayName = 'DropdownMenuItemLabelGroup';\n\nexport type DropdownMenuItemLabelProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemLabel = ({ className, ...rest }: DropdownMenuItemLabelProps) => {\n return <span {...rest} className={cx(styles.label, className)} />;\n};\n\nDropdownMenuItemLabel.displayName = 'DropdownMenuItemLabel';\n\nexport type DropdownMenuItemDescProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemDesc = ({ className, ...rest }: DropdownMenuItemDescProps) => {\n return <span {...rest} className={cx(styles.desc, className)} />;\n};\n\nDropdownMenuItemDesc.displayName = 'DropdownMenuItemDesc';\n\nexport type DropdownMenuItemExtraProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemExtra = ({ className, ...rest }: DropdownMenuItemExtraProps) => {\n return <span {...rest} className={cx(styles.extra, className)} />;\n};\n\nDropdownMenuItemExtra.displayName = 'DropdownMenuItemExtra';\n\nexport type DropdownMenuSubmenuArrowProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuSubmenuArrow = ({ className, ...rest }: DropdownMenuSubmenuArrowProps) => {\n return <span {...rest} className={cx(styles.submenuArrow, className)} />;\n};\n\nDropdownMenuSubmenuArrow.displayName = 'DropdownMenuSubmenuArrow';\n\nexport type DropdownMenuSwitchItemProps = Omit<\n React.ComponentProps<typeof Menu.Item>,\n 'onClick'\n> & {\n checked?: boolean;\n closeOnClick?: boolean;\n danger?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: (checked: boolean) => void;\n};\n\nexport const DropdownMenuSwitchItem = ({\n checked: checkedProp,\n className,\n closeOnClick = false,\n danger,\n defaultChecked,\n disabled,\n onCheckedChange,\n children,\n ...rest\n}: DropdownMenuSwitchItemProps) => {\n const [internalChecked, setInternalChecked] = useState(defaultChecked ?? false);\n const isControlled = checkedProp !== undefined;\n const checked = isControlled ? checkedProp : internalChecked;\n\n const handleCheckedChange = useCallback(\n (newChecked: boolean) => {\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n onCheckedChange?.(newChecked);\n },\n [isControlled, onCheckedChange],\n );\n\n return (\n <Menu.Item\n {...rest}\n closeOnClick={closeOnClick}\n disabled={disabled}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n onClick={(e) => {\n e.preventDefault();\n if (!disabled) {\n handleCheckedChange(!checked);\n }\n }}\n >\n {children}\n <span\n style={{ display: 'inline-flex', marginInlineStart: 16 }}\n onFocus={(e) => e.stopPropagation()}\n >\n <Switch\n checked={checked}\n disabled={disabled}\n size=\"small\"\n tabIndex={-1}\n onChange={handleCheckedChange}\n onClick={(_, e) => e.stopPropagation()}\n />\n </span>\n </Menu.Item>\n );\n};\n\nDropdownMenuSwitchItem.displayName = 'DropdownMenuSwitchItem';\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,MAAa,oBAAsC,UAAU,oBAAC,KAAK,MAAN;CAAW,OAAO;CAAO,GAAI;AAAQ,CAAA;AAClG,MAAa,0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kBAAkB,KAAK;CAC9E,MAAM,eAAe,gBAAgB,KAAA;CACrC,MAAM,UAAU,eAAe,cAAc;CAE7C,MAAM,sBAAsB,aACzB,eAAwB;EACvB,IAAI,CAAC,cACH,mBAAmB,UAAU;EAE/B,kBAAkB,UAAU;CAC9B,GACA,CAAC,cAAc,eAAe,CAChC;CAEA,OACE,qBAAC,KAAK,MAAN;EACE,GAAI;EACU;EACJ;EACV,YAAY,UACV,GACE,OAAO,MACP,UAAU,OAAO,QACjB,OAAO,cAAc,aAAa,UAAU,KAAK,IAAI,SACvD;EAEF,UAAU,MAAM;GACd,EAAE,eAAe;GACjB,IAAI,CAAC,UACH,oBAAoB,CAAC,OAAO;EAEhC;EAhBF,UAAA,CAkBG,UACD,oBAAC,QAAD;GACE,OAAO;IAAE,SAAS;IAAe,mBAAmB;GAAG;GACvD,UAAU,MAAM,EAAE,gBAAgB;GAElC,UAAA,oBAAC,QAAD;IACW;IACC;IACV,MAAK;IACL,UAAU;IACV,UAAU;IACV,UAAU,GAAG,MAAM,EAAE,gBAAgB;GACtC,CAAA;EACG,CAAA,CACG;;AAEf;AAEA,uBAAuB,cAAc"}
|
|
1
|
+
{"version":3,"file":"atoms.mjs","names":[],"sources":["../../../src/base-ui/DropdownMenu/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { Menu } from '@base-ui/react/menu';\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { cx } from 'antd-style';\nimport clsx from 'clsx';\nimport type React from 'react';\nimport { cloneElement, isValidElement, useCallback, useState } from 'react';\nimport { mergeRefs, useMergeRefs } from 'react-merge-refs';\n\nimport { getFloatingCollisionPadding } from '@/base-ui/floating';\nimport Switch from '@/base-ui/Switch';\nimport { FloatingLayerProvider } from '@/hooks/useFloatingLayer';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { CLASSNAMES } from '@/styles/classNames';\nimport { useAppElement } from '@/ThemeProvider';\nimport { placementMap } from '@/utils/placement';\n\nimport { useLayerZIndex } from '../zIndex';\nimport { styles } from './sharedStyle';\nimport { type DropdownMenuPlacement } from './type';\n\nexport const DropdownMenuRoot: typeof Menu.Root = (props) => <Menu.Root modal={false} {...props} />;\nexport const DropdownMenuSubmenuRoot = Menu.SubmenuRoot;\nexport const DropdownMenuCheckboxItemIndicator = Menu.CheckboxItemIndicator;\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\nexport type DropdownMenuTriggerProps = Omit<\n React.ComponentPropsWithRef<typeof Menu.Trigger>,\n 'children' | 'render'\n> & {\n children: React.ReactNode;\n};\n\nexport const DropdownMenuTrigger = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: DropdownMenuTriggerProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n const renderer = (props: any) => {\n // Base UI's trigger props include `type=\"button\"` by default.\n // If we render into a non-<button> element, that prop is invalid and can warn.\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 className: clsx(CLASSNAMES.DropdownMenuTrigger, className, mergedProps.className),\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n };\n\n if (isValidElement(children)) {\n return <Menu.Trigger {...rest} nativeButton={resolvedNativeButton} render={renderer as any} />;\n }\n\n return (\n <Menu.Trigger\n {...rest}\n className={clsx(CLASSNAMES.DropdownMenuTrigger, className)}\n nativeButton={resolvedNativeButton}\n ref={refProp as any}\n >\n {children}\n </Menu.Trigger>\n );\n};\n\nDropdownMenuTrigger.displayName = 'DropdownMenuTrigger';\n\nexport type DropdownMenuPortalProps = React.ComponentProps<typeof Menu.Portal> & {\n /**\n * When `container` is not provided, it uses a shared container created by `usePortalContainer`.\n */\n container?: HTMLElement | null;\n};\n\nexport const DropdownMenuPortal = ({ container, ...rest }: DropdownMenuPortalProps) => {\n const appElement = useAppElement();\n return <Menu.Portal container={container ?? appElement ?? undefined} {...rest} />;\n};\n\nDropdownMenuPortal.displayName = 'DropdownMenuPortal';\n\nexport type DropdownMenuPositionerProps = React.ComponentProps<typeof Menu.Positioner> & {\n hoverTrigger?: boolean;\n placement?: DropdownMenuPlacement;\n};\n\nexport const DropdownMenuPositioner = ({\n className,\n collisionPadding,\n placement,\n hoverTrigger,\n align,\n side,\n sideOffset,\n children,\n style,\n ...rest\n}: DropdownMenuPositionerProps) => {\n const placementConfig = placement ? placementMap[placement] : undefined;\n const [positionerNode, setPositionerNode] = useState<HTMLDivElement | null>(null);\n\n const explicitZIndex =\n typeof style !== 'function' && style?.zIndex != null && typeof style.zIndex === 'number'\n ? style.zIndex\n : undefined;\n const { zIndex, ref: zRef } = useLayerZIndex<HTMLDivElement>('floating', explicitZIndex);\n const composedRef = useMergeRefs([setPositionerNode, zRef]);\n\n const resolvedStyle =\n typeof style === 'function'\n ? (state: any) => ({ zIndex, ...style(state) })\n : { zIndex, ...style };\n\n return (\n <Menu.Positioner\n {...rest}\n align={align ?? placementConfig?.align}\n className={mergeStateClassName(styles.positioner, className as any) as any}\n collisionPadding={collisionPadding ?? getFloatingCollisionPadding()}\n data-hover-trigger={hoverTrigger || undefined}\n data-placement={placement}\n ref={composedRef as any}\n side={side ?? placementConfig?.side}\n sideOffset={sideOffset ?? (placementConfig ? 6 : undefined)}\n style={resolvedStyle}\n >\n <FloatingLayerProvider value={positionerNode}>{children}</FloatingLayerProvider>\n </Menu.Positioner>\n );\n};\n\nDropdownMenuPositioner.displayName = 'DropdownMenuPositioner';\n\nexport type DropdownMenuPopupProps = React.ComponentProps<typeof Menu.Popup>;\n\nexport const DropdownMenuPopup = ({ className, ...rest }: DropdownMenuPopupProps) => {\n return (\n <Menu.Popup {...rest} className={mergeStateClassName(styles.popup, className as any) as any} />\n );\n};\n\nDropdownMenuPopup.displayName = 'DropdownMenuPopup';\n\nexport type DropdownMenuHeaderProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuHeader = ({ className, ...rest }: DropdownMenuHeaderProps) => {\n return <div {...rest} className={cx(styles.header, className)} />;\n};\n\nDropdownMenuHeader.displayName = 'DropdownMenuHeader';\n\nexport type DropdownMenuFooterProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuFooter = ({ className, ...rest }: DropdownMenuFooterProps) => {\n return <div {...rest} className={cx(styles.footer, className)} />;\n};\n\nDropdownMenuFooter.displayName = 'DropdownMenuFooter';\n\nexport type DropdownMenuScrollViewportProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuScrollViewport = ({\n className,\n ...rest\n}: DropdownMenuScrollViewportProps) => {\n return <div {...rest} className={cx(styles.slotViewport, className)} />;\n};\n\nDropdownMenuScrollViewport.displayName = 'DropdownMenuScrollViewport';\n\nexport type DropdownMenuItemProps = React.ComponentProps<typeof Menu.Item> & { danger?: boolean };\n\nexport const DropdownMenuItem = ({ className, danger, ...rest }: DropdownMenuItemProps) => {\n return (\n <Menu.Item\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\nexport type DropdownMenuCheckboxItemProps = React.ComponentProps<typeof Menu.CheckboxItem> & {\n danger?: boolean;\n};\n\nexport const DropdownMenuCheckboxItemPrimitive = ({\n className,\n danger,\n ...rest\n}: DropdownMenuCheckboxItemProps) => {\n return (\n <Menu.CheckboxItem\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuCheckboxItemPrimitive.displayName = 'DropdownMenuCheckboxItemPrimitive';\n\nexport type DropdownMenuSeparatorProps = React.ComponentProps<typeof Menu.Separator>;\n\nexport const DropdownMenuSeparator = ({ className, ...rest }: DropdownMenuSeparatorProps) => {\n return (\n <Menu.Separator\n {...rest}\n className={(state) =>\n cx(styles.separator, typeof className === 'function' ? className(state) : className)\n }\n />\n );\n};\n\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\nexport const DropdownMenuGroup = Menu.Group;\n\nexport type DropdownMenuGroupLabelProps = React.ComponentProps<typeof Menu.GroupLabel>;\n\nexport const DropdownMenuGroupLabel = ({ className, ...rest }: DropdownMenuGroupLabelProps) => {\n return (\n <Menu.GroupLabel\n {...rest}\n className={(state) =>\n cx(styles.groupLabel, typeof className === 'function' ? className(state) : className)\n }\n />\n );\n};\n\nDropdownMenuGroupLabel.displayName = 'DropdownMenuGroupLabel';\n\nexport type DropdownMenuSubmenuTriggerProps = React.ComponentProps<typeof Menu.SubmenuTrigger> & {\n danger?: boolean;\n};\n\nexport const DropdownMenuSubmenuTrigger = ({\n className,\n danger,\n ...rest\n}: DropdownMenuSubmenuTriggerProps) => {\n return (\n <Menu.SubmenuTrigger\n {...rest}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n );\n};\n\nDropdownMenuSubmenuTrigger.displayName = 'DropdownMenuSubmenuTrigger';\n\nexport type DropdownMenuItemContentProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuItemContent = ({ className, ...rest }: DropdownMenuItemContentProps) => {\n return <div {...rest} className={cx(styles.itemContent, className)} />;\n};\n\nDropdownMenuItemContent.displayName = 'DropdownMenuItemContent';\n\nexport type DropdownMenuItemIconProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemIcon = ({ className, ...rest }: DropdownMenuItemIconProps) => {\n return <span {...rest} className={cx(styles.icon, className)} />;\n};\n\nDropdownMenuItemIcon.displayName = 'DropdownMenuItemIcon';\n\nexport type DropdownMenuItemLabelGroupProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const DropdownMenuItemLabelGroup = ({\n className,\n ...rest\n}: DropdownMenuItemLabelGroupProps) => {\n return <div {...rest} className={cx(styles.labelGroup, className)} />;\n};\n\nDropdownMenuItemLabelGroup.displayName = 'DropdownMenuItemLabelGroup';\n\nexport type DropdownMenuItemLabelProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemLabel = ({ className, ...rest }: DropdownMenuItemLabelProps) => {\n return <span {...rest} className={cx(styles.label, className)} />;\n};\n\nDropdownMenuItemLabel.displayName = 'DropdownMenuItemLabel';\n\nexport type DropdownMenuItemDescProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemDesc = ({ className, ...rest }: DropdownMenuItemDescProps) => {\n return <span {...rest} className={cx(styles.desc, className)} />;\n};\n\nDropdownMenuItemDesc.displayName = 'DropdownMenuItemDesc';\n\nexport type DropdownMenuItemExtraProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuItemExtra = ({ className, ...rest }: DropdownMenuItemExtraProps) => {\n return <span {...rest} className={cx(styles.extra, className)} />;\n};\n\nDropdownMenuItemExtra.displayName = 'DropdownMenuItemExtra';\n\nexport type DropdownMenuSubmenuArrowProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const DropdownMenuSubmenuArrow = ({ className, ...rest }: DropdownMenuSubmenuArrowProps) => {\n return <span {...rest} className={cx(styles.submenuArrow, className)} />;\n};\n\nDropdownMenuSubmenuArrow.displayName = 'DropdownMenuSubmenuArrow';\n\nexport type DropdownMenuSwitchItemProps = Omit<\n React.ComponentProps<typeof Menu.Item>,\n 'onClick'\n> & {\n checked?: boolean;\n closeOnClick?: boolean;\n danger?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: (checked: boolean) => void;\n};\n\nexport const DropdownMenuSwitchItem = ({\n checked: checkedProp,\n className,\n closeOnClick = false,\n danger,\n defaultChecked,\n disabled,\n onCheckedChange,\n children,\n ...rest\n}: DropdownMenuSwitchItemProps) => {\n const [internalChecked, setInternalChecked] = useState(defaultChecked ?? false);\n const isControlled = checkedProp !== undefined;\n const checked = isControlled ? checkedProp : internalChecked;\n\n const handleCheckedChange = useCallback(\n (newChecked: boolean) => {\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n onCheckedChange?.(newChecked);\n },\n [isControlled, onCheckedChange],\n );\n\n return (\n <Menu.Item\n {...rest}\n closeOnClick={closeOnClick}\n disabled={disabled}\n className={(state) =>\n cx(\n styles.item,\n danger && styles.danger,\n typeof className === 'function' ? className(state) : className,\n )\n }\n onClick={(e) => {\n e.preventDefault();\n if (!disabled) {\n handleCheckedChange(!checked);\n }\n }}\n >\n {children}\n <span\n style={{ display: 'inline-flex', marginInlineStart: 16 }}\n onFocus={(e) => e.stopPropagation()}\n >\n <Switch\n checked={checked}\n disabled={disabled}\n size=\"small\"\n tabIndex={-1}\n onChange={handleCheckedChange}\n onClick={(_, e) => e.stopPropagation()}\n />\n </span>\n </Menu.Item>\n );\n};\n\nDropdownMenuSwitchItem.displayName = 'DropdownMenuSwitchItem';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,MAAa,oBAAsC,UAAU,oBAAC,KAAK,MAAN;CAAW,OAAO;CAAO,GAAI;AAAQ,CAAA;AAClG,MAAa,0BAA0B,KAAK;AAC5C,MAAa,oCAAoC,KAAK;AAEtD,MAAM,uBACJ,MACA,cACG;CACH,IAAI,OAAO,cAAc,YAAY,QAAQ,UAAkB,GAAG,MAAM,UAAU,KAAK,CAAC;CACxF,OAAO,GAAG,MAAM,SAAS;AAC3B;AASA,MAAa,uBAAuB,EAClC,UACA,WACA,cACA,KAAK,SACL,GAAG,WAC2B;CAC9B,MAAM,EAAE,8BAA8B,yBAAyB,gBAAgB;EAC7E;EACA;CACF,CAAC;CAED,MAAM,YAAY,UAAe;EAG/B,MAAM,uBAAuB;GAC3B,IAAI,8BAA8B,OAAO;GAEzC,MAAM,EAAE,MAAM,GAAG,cAAc;GAC/B,OAAO;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CAAC,UACH,oBAAoB,CAAC,OAAO;EAEhC;EAhBF,UAAA,CAkBG,UACD,oBAAC,QAAD;GACE,OAAO;IAAE,SAAS;IAAe,mBAAmB;GAAG;GACvD,UAAU,MAAM,EAAE,gBAAgB;GAElC,UAAA,oBAAC,QAAD;IACW;IACC;IACV,MAAK;IACL,UAAU;IACV,UAAU;IACV,UAAU,GAAG,MAAM,EAAE,gBAAgB;GACtC,CAAA;EACG,CAAA,CACG;;AAEf;AAEA,uBAAuB,cAAc"}
|
|
@@ -23,8 +23,8 @@ declare const styles: {
|
|
|
23
23
|
};
|
|
24
24
|
declare const rootVariants: (props?: ({
|
|
25
25
|
shadow?: boolean | null | undefined;
|
|
26
|
-
size?: "
|
|
27
|
-
variant?: "
|
|
26
|
+
size?: "large" | "middle" | "small" | null | undefined;
|
|
27
|
+
variant?: "borderless" | "filled" | "outlined" | null | undefined;
|
|
28
28
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { rootVariants, styles };
|
|
@@ -30,7 +30,7 @@ type PopoverPositionerAtomProps = ComponentProps<typeof Popover.Positioner> & {
|
|
|
30
30
|
placement?: PopoverPlacement;
|
|
31
31
|
};
|
|
32
32
|
declare const PopoverPositioner: {
|
|
33
|
-
({ children, className, hoverTrigger, placement, align, side, sideOffset, style, ...rest }: PopoverPositionerAtomProps): import("react").JSX.Element;
|
|
33
|
+
({ children, className, collisionPadding, hoverTrigger, placement, align, side, sideOffset, style, ...rest }: PopoverPositionerAtomProps): import("react").JSX.Element;
|
|
34
34
|
displayName: string;
|
|
35
35
|
};
|
|
36
36
|
type PopoverPopupAtomProps = ComponentProps<typeof Popover.Popup>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useNativeButton } from "../../hooks/useNativeButton.mjs";
|
|
3
|
+
import { getFloatingCollisionPadding } from "../floating/collisionPadding.mjs";
|
|
3
4
|
import { FloatingLayerProvider } from "../../hooks/useFloatingLayer.mjs";
|
|
4
5
|
import { placementMap } from "../../utils/placement.mjs";
|
|
5
6
|
import { useLayerZIndex } from "../zIndex/useLayerZIndex.mjs";
|
|
@@ -63,7 +64,7 @@ const PopoverPortal = ({ container, root, children, ...rest }) => {
|
|
|
63
64
|
});
|
|
64
65
|
};
|
|
65
66
|
PopoverPortal.displayName = "PopoverPortal";
|
|
66
|
-
const PopoverPositioner = ({ children, className, hoverTrigger, placement, align, side, sideOffset, style, ...rest }) => {
|
|
67
|
+
const PopoverPositioner = ({ children, className, collisionPadding, hoverTrigger, placement, align, side, sideOffset, style, ...rest }) => {
|
|
67
68
|
const placementConfig = placement ? placementMap[placement] : void 0;
|
|
68
69
|
const [positionerNode, setPositionerNode] = useState(null);
|
|
69
70
|
const explicitZIndex = typeof style !== "function" && style?.zIndex != null && typeof style.zIndex === "number" ? style.zIndex : void 0;
|
|
@@ -78,6 +79,7 @@ const PopoverPositioner = ({ children, className, hoverTrigger, placement, align
|
|
|
78
79
|
};
|
|
79
80
|
return /* @__PURE__ */ jsx(Popover.Positioner, {
|
|
80
81
|
align: align ?? placementConfig?.align ?? "center",
|
|
82
|
+
collisionPadding: collisionPadding ?? getFloatingCollisionPadding(),
|
|
81
83
|
"data-hover-trigger": hoverTrigger || void 0,
|
|
82
84
|
"data-placement": placement,
|
|
83
85
|
ref: composedRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atoms.mjs","names":["BasePopover"],"sources":["../../../src/base-ui/Popover/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport { cx } from 'antd-style';\nimport {\n cloneElement,\n type ComponentProps,\n type ComponentPropsWithRef,\n isValidElement,\n useState,\n} from 'react';\nimport { mergeRefs, useMergeRefs } from 'react-merge-refs';\n\nimport { FloatingLayerProvider } from '@/hooks/useFloatingLayer';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { placementMap } from '@/utils/placement';\n\nimport { useLayerZIndex } from '../zIndex';\nimport { PopoverArrowIcon } from './ArrowIcon';\nimport { usePopoverPortalContainer } from './PopoverPortal';\nimport { styles } from './style';\nimport { type PopoverPlacement } from './type';\n\nexport const PopoverRoot = BasePopover.Root;\nexport const PopoverBackdrop = BasePopover.Backdrop;\n\nexport type PopoverTriggerElementProps = Omit<\n ComponentPropsWithRef<typeof BasePopover.Trigger>,\n 'children' | 'render'\n> & {\n children: ComponentProps<typeof BasePopover.Trigger>['children'];\n};\n\nexport const PopoverTriggerElement = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: PopoverTriggerElementProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n if (isValidElement(children)) {\n return (\n <BasePopover.Trigger\n {...rest}\n nativeButton={resolvedNativeButton}\n render={(props, state) => {\n // Base UI's trigger props include `type=\"button\"` by default.\n // If we render into a non-<button> element, that prop is invalid and can warn.\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ref: triggerRef, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n const baseClassName =\n typeof (mergedProps as any).className === 'function'\n ? (mergedProps as any).className(state)\n : (mergedProps as any).className;\n const extraClassName =\n typeof (className as any) === 'function' ? (className as any)(state) : className;\n\n return cloneElement(children as any, {\n ...mergedProps,\n className: cx(baseClassName, extraClassName),\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n }}\n />\n );\n }\n\n return (\n <BasePopover.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n ref={refProp}\n >\n {children}\n </BasePopover.Trigger>\n );\n};\n\nPopoverTriggerElement.displayName = 'PopoverTriggerElement';\n\nexport type PopoverPortalAtomProps = Omit<\n ComponentProps<typeof BasePopover.Portal>,\n 'container'\n> & {\n /**\n * Portal container. When not provided, it uses the shared container created by `usePopoverPortalContainer`.\n */\n container?: HTMLElement | null;\n /**\n * Root element used by `usePopoverPortalContainer` to create the default container.\n */\n root?: HTMLElement | ShadowRoot | null;\n};\n\nexport const PopoverPortal = ({ container, root, children, ...rest }: PopoverPortalAtomProps) => {\n const defaultContainer = usePopoverPortalContainer(root);\n const resolvedContainer = container ?? defaultContainer;\n\n if (!resolvedContainer) return null;\n\n return (\n <BasePopover.Portal container={resolvedContainer} {...rest}>\n {children}\n </BasePopover.Portal>\n );\n};\n\nPopoverPortal.displayName = 'PopoverPortal';\n\nexport type PopoverPositionerAtomProps = ComponentProps<typeof BasePopover.Positioner> & {\n hoverTrigger?: boolean;\n placement?: PopoverPlacement;\n};\n\nexport const PopoverPositioner = ({\n children,\n className,\n hoverTrigger,\n placement,\n align,\n side,\n sideOffset,\n style,\n ...rest\n}: PopoverPositionerAtomProps) => {\n const placementConfig = placement ? placementMap[placement] : undefined;\n const [positionerNode, setPositionerNode] = useState<HTMLDivElement | null>(null);\n const explicitZIndex =\n typeof style !== 'function' && style?.zIndex != null && typeof style.zIndex === 'number'\n ? style.zIndex\n : undefined;\n const { zIndex, ref: zRef } = useLayerZIndex<HTMLDivElement>('floating', explicitZIndex);\n const composedRef = useMergeRefs([setPositionerNode, zRef]);\n\n const resolvedStyle =\n typeof style === 'function'\n ? (state: any) => ({ zIndex, ...style(state) })\n : { zIndex, ...style };\n\n return (\n <BasePopover.Positioner\n align={align ?? placementConfig?.align ?? 'center'}\n data-hover-trigger={hoverTrigger || undefined}\n data-placement={placement}\n ref={composedRef as any}\n side={side ?? placementConfig?.side ?? 'bottom'}\n sideOffset={sideOffset ?? 6}\n style={resolvedStyle}\n className={(state) =>\n cx(styles.positioner, typeof className === 'function' ? className(state) : className)\n }\n {...rest}\n >\n <FloatingLayerProvider value={positionerNode}>{children}</FloatingLayerProvider>\n </BasePopover.Positioner>\n );\n};\n\nPopoverPositioner.displayName = 'PopoverPositioner';\n\nexport type PopoverPopupAtomProps = ComponentProps<typeof BasePopover.Popup>;\n\nexport const PopoverPopup = ({ className, ...rest }: PopoverPopupAtomProps) => {\n return (\n <BasePopover.Popup\n className={(state) =>\n cx(styles.popup, typeof className === 'function' ? className(state) : className)\n }\n {...rest}\n />\n );\n};\n\nPopoverPopup.displayName = 'PopoverPopup';\n\nexport type PopoverArrowAtomProps = ComponentProps<typeof BasePopover.Arrow>;\n\nexport const PopoverArrow = ({ className, children, ...rest }: PopoverArrowAtomProps) => {\n return (\n <BasePopover.Arrow\n className={(state) =>\n cx(styles.arrow, typeof className === 'function' ? className(state) : className)\n }\n {...rest}\n >\n {children ?? PopoverArrowIcon}\n </BasePopover.Arrow>\n );\n};\n\nPopoverArrow.displayName = 'PopoverArrow';\n\nexport type PopoverViewportAtomProps = ComponentProps<typeof BasePopover.Viewport>;\n\nexport const PopoverViewport = ({ className, ...rest }: PopoverViewportAtomProps) => {\n return (\n <BasePopover.Viewport\n className={(state) =>\n cx(styles.viewport, typeof className === 'function' ? className(state) : className)\n }\n {...rest}\n />\n );\n};\n\nPopoverViewport.displayName = 'PopoverViewport';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"atoms.mjs","names":["BasePopover"],"sources":["../../../src/base-ui/Popover/atoms.tsx"],"sourcesContent":["'use client';\n\nimport { mergeProps } from '@base-ui/react/merge-props';\nimport { Popover as BasePopover } from '@base-ui/react/popover';\nimport { cx } from 'antd-style';\nimport {\n cloneElement,\n type ComponentProps,\n type ComponentPropsWithRef,\n isValidElement,\n useState,\n} from 'react';\nimport { mergeRefs, useMergeRefs } from 'react-merge-refs';\n\nimport { getFloatingCollisionPadding } from '@/base-ui/floating';\nimport { FloatingLayerProvider } from '@/hooks/useFloatingLayer';\nimport { useNativeButton } from '@/hooks/useNativeButton';\nimport { placementMap } from '@/utils/placement';\n\nimport { useLayerZIndex } from '../zIndex';\nimport { PopoverArrowIcon } from './ArrowIcon';\nimport { usePopoverPortalContainer } from './PopoverPortal';\nimport { styles } from './style';\nimport { type PopoverPlacement } from './type';\n\nexport const PopoverRoot = BasePopover.Root;\nexport const PopoverBackdrop = BasePopover.Backdrop;\n\nexport type PopoverTriggerElementProps = Omit<\n ComponentPropsWithRef<typeof BasePopover.Trigger>,\n 'children' | 'render'\n> & {\n children: ComponentProps<typeof BasePopover.Trigger>['children'];\n};\n\nexport const PopoverTriggerElement = ({\n children,\n className,\n nativeButton,\n ref: refProp,\n ...rest\n}: PopoverTriggerElementProps) => {\n const { isNativeButtonTriggerElement, resolvedNativeButton } = useNativeButton({\n children,\n nativeButton,\n });\n\n if (isValidElement(children)) {\n return (\n <BasePopover.Trigger\n {...rest}\n nativeButton={resolvedNativeButton}\n render={(props, state) => {\n // Base UI's trigger props include `type=\"button\"` by default.\n // If we render into a non-<button> element, that prop is invalid and can warn.\n const resolvedProps = (() => {\n if (isNativeButtonTriggerElement) return props as any;\n // eslint-disable-next-line unused-imports/no-unused-vars\n const { type, ref: triggerRef, ...restProps } = props as any;\n return restProps;\n })();\n\n const mergedProps = mergeProps((children as any).props, resolvedProps);\n const baseClassName =\n typeof (mergedProps as any).className === 'function'\n ? (mergedProps as any).className(state)\n : (mergedProps as any).className;\n const extraClassName =\n typeof (className as any) === 'function' ? (className as any)(state) : className;\n\n return cloneElement(children as any, {\n ...mergedProps,\n className: cx(baseClassName, extraClassName),\n ref: mergeRefs([(children as any).ref, (props as any).ref, refProp]),\n });\n }}\n />\n );\n }\n\n return (\n <BasePopover.Trigger\n {...rest}\n className={className}\n nativeButton={resolvedNativeButton}\n ref={refProp}\n >\n {children}\n </BasePopover.Trigger>\n );\n};\n\nPopoverTriggerElement.displayName = 'PopoverTriggerElement';\n\nexport type PopoverPortalAtomProps = Omit<\n ComponentProps<typeof BasePopover.Portal>,\n 'container'\n> & {\n /**\n * Portal container. When not provided, it uses the shared container created by `usePopoverPortalContainer`.\n */\n container?: HTMLElement | null;\n /**\n * Root element used by `usePopoverPortalContainer` to create the default container.\n */\n root?: HTMLElement | ShadowRoot | null;\n};\n\nexport const PopoverPortal = ({ container, root, children, ...rest }: PopoverPortalAtomProps) => {\n const defaultContainer = usePopoverPortalContainer(root);\n const resolvedContainer = container ?? defaultContainer;\n\n if (!resolvedContainer) return null;\n\n return (\n <BasePopover.Portal container={resolvedContainer} {...rest}>\n {children}\n </BasePopover.Portal>\n );\n};\n\nPopoverPortal.displayName = 'PopoverPortal';\n\nexport type PopoverPositionerAtomProps = ComponentProps<typeof BasePopover.Positioner> & {\n hoverTrigger?: boolean;\n placement?: PopoverPlacement;\n};\n\nexport const PopoverPositioner = ({\n children,\n className,\n collisionPadding,\n hoverTrigger,\n placement,\n align,\n side,\n sideOffset,\n style,\n ...rest\n}: PopoverPositionerAtomProps) => {\n const placementConfig = placement ? placementMap[placement] : undefined;\n const [positionerNode, setPositionerNode] = useState<HTMLDivElement | null>(null);\n const explicitZIndex =\n typeof style !== 'function' && style?.zIndex != null && typeof style.zIndex === 'number'\n ? style.zIndex\n : undefined;\n const { zIndex, ref: zRef } = useLayerZIndex<HTMLDivElement>('floating', explicitZIndex);\n const composedRef = useMergeRefs([setPositionerNode, zRef]);\n\n const resolvedStyle =\n typeof style === 'function'\n ? (state: any) => ({ zIndex, ...style(state) })\n : { zIndex, ...style };\n\n return (\n <BasePopover.Positioner\n align={align ?? placementConfig?.align ?? 'center'}\n collisionPadding={collisionPadding ?? getFloatingCollisionPadding()}\n data-hover-trigger={hoverTrigger || undefined}\n data-placement={placement}\n ref={composedRef as any}\n side={side ?? placementConfig?.side ?? 'bottom'}\n sideOffset={sideOffset ?? 6}\n style={resolvedStyle}\n className={(state) =>\n cx(styles.positioner, typeof className === 'function' ? className(state) : className)\n }\n {...rest}\n >\n <FloatingLayerProvider value={positionerNode}>{children}</FloatingLayerProvider>\n </BasePopover.Positioner>\n );\n};\n\nPopoverPositioner.displayName = 'PopoverPositioner';\n\nexport type PopoverPopupAtomProps = ComponentProps<typeof BasePopover.Popup>;\n\nexport const PopoverPopup = ({ className, ...rest }: PopoverPopupAtomProps) => {\n return (\n <BasePopover.Popup\n className={(state) =>\n cx(styles.popup, typeof className === 'function' ? className(state) : className)\n }\n {...rest}\n />\n );\n};\n\nPopoverPopup.displayName = 'PopoverPopup';\n\nexport type PopoverArrowAtomProps = ComponentProps<typeof BasePopover.Arrow>;\n\nexport const PopoverArrow = ({ className, children, ...rest }: PopoverArrowAtomProps) => {\n return (\n <BasePopover.Arrow\n className={(state) =>\n cx(styles.arrow, typeof className === 'function' ? className(state) : className)\n }\n {...rest}\n >\n {children ?? PopoverArrowIcon}\n </BasePopover.Arrow>\n );\n};\n\nPopoverArrow.displayName = 'PopoverArrow';\n\nexport type PopoverViewportAtomProps = ComponentProps<typeof BasePopover.Viewport>;\n\nexport const PopoverViewport = ({ className, ...rest }: PopoverViewportAtomProps) => {\n return (\n <BasePopover.Viewport\n className={(state) =>\n cx(styles.viewport, typeof className === 'function' ? className(state) : className)\n }\n {...rest}\n />\n );\n};\n\nPopoverViewport.displayName = 'PopoverViewport';\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,MAAa,cAAcA,QAAY;AACvC,MAAa,kBAAkBA,QAAY;AAS3C,MAAa,yBAAyB,EACpC,UACA,WACA,cACA,KAAK,SACL,GAAG,WAC6B;CAChC,MAAM,EAAE,8BAA8B,yBAAyB,gBAAgB;EAC7E;EACA;CACF,CAAC;CAED,IAAI,eAAe,QAAQ,GACzB,OACE,oBAACA,QAAY,SAAb;EACE,GAAI;EACJ,cAAc;EACd,SAAS,OAAO,UAAU;GAGxB,MAAM,uBAAuB;IAC3B,IAAI,8BAA8B,OAAO;IAEzC,MAAM,EAAE,MAAM,KAAK,YAAY,GAAG,cAAc;IAChD,OAAO;GACT,EAAA,CAAG;GAEH,MAAM,cAAc,WAAY,SAAiB,OAAO,aAAa;GACrE,MAAM,gBACJ,OAAQ,YAAoB,cAAc,aACrC,YAAoB,UAAU,KAAK,IACnC,YAAoB;GAC3B,MAAM,iBACJ,OAAQ,cAAsB,aAAc,UAAkB,KAAK,I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