@rescui/dropdown-menu 0.11.19-RUI-297-Add-react-compiler-to-the-packages-build-dbbefd7b8.10 → 0.12.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/lib/dropdown-menu.js +5 -1
- package/lib/dropdown-menu.p.module.css.js +5 -5
- package/lib/index.css +8 -8
- package/llm/components/dropdown-menu.md +133 -22
- package/package.json +11 -11
package/lib/dropdown-menu.js
CHANGED
|
@@ -36,6 +36,7 @@ const DropdownMenu = _ref => {
|
|
|
36
36
|
const [menuWrapperEl, setMenuWrapperEl] = useState(null);
|
|
37
37
|
const [height, setHeight] = useState(0);
|
|
38
38
|
let itemHeightFromCss = null;
|
|
39
|
+
let contrastPrimaryFromCss = null;
|
|
39
40
|
|
|
40
41
|
if (menuWrapperEl) {
|
|
41
42
|
// In theory this part of the code might cause issues with SSR.
|
|
@@ -46,6 +47,7 @@ const DropdownMenu = _ref => {
|
|
|
46
47
|
// it's a dropdown-content and in most cases it opens only on-demand
|
|
47
48
|
const menuWrapperStyles = getComputedStyle(menuWrapperEl);
|
|
48
49
|
itemHeightFromCss = parseInt(menuWrapperStyles.getPropertyValue('--_rs-dropdown-menu-item-height'), 10) || null;
|
|
50
|
+
contrastPrimaryFromCss = parseInt(menuWrapperStyles.getPropertyValue('--rs-dropdown-menu-contrast-primary'), 10) || null;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
const itemHeight = itemHeightFromCss || ITEM_HEIGHT_BY_SIZE[size]; // a little buffer of 10% here
|
|
@@ -81,8 +83,10 @@ const DropdownMenu = _ref => {
|
|
|
81
83
|
"data-test": "dropdown-menu",
|
|
82
84
|
"data-rs-internal": 'dropdown-menu__menu',
|
|
83
85
|
className: styles.menu,
|
|
86
|
+
style: {
|
|
87
|
+
'--rs-menu-contrast-primary': contrastPrimaryFromCss
|
|
88
|
+
},
|
|
84
89
|
enableKeyboardNavigation: true,
|
|
85
|
-
returnFocusOnUnmount: true,
|
|
86
90
|
activateFirstItem: activateFirstItemOnOpen,
|
|
87
91
|
wrapItemsWithLi: wrapItemsWithLi,
|
|
88
92
|
resizeIcons: resizeIcons
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"sizeS": "
|
|
3
|
-
"sizeM": "
|
|
4
|
-
"sizeL": "
|
|
5
|
-
"dropdownMenu": "
|
|
6
|
-
"menu": "
|
|
2
|
+
"sizeS": "_sizeS_1yw9uw9_8",
|
|
3
|
+
"sizeM": "_sizeM_1yw9uw9_11",
|
|
4
|
+
"sizeL": "_sizeL_1yw9uw9_14",
|
|
5
|
+
"dropdownMenu": "_dropdownMenu_1yw9uw9_18",
|
|
6
|
+
"menu": "_menu_1yw9uw9_23"
|
|
7
7
|
};
|
|
8
8
|
export { styles as default };
|
package/lib/index.css
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
.
|
|
1
|
+
._sizeS_1yw9uw9_8{
|
|
2
2
|
--_rs-dropdown-menu-min-width:316px;
|
|
3
3
|
--_rs-dropdown-menu-max-width:389px;
|
|
4
4
|
}
|
|
5
|
-
.
|
|
5
|
+
._sizeS_1yw9uw9_8 [data-rs-internal='dropdown-menu__menu-wrapper']{
|
|
6
6
|
--_rs-dropdown-menu-item-height:32px;
|
|
7
7
|
}
|
|
8
|
-
.
|
|
8
|
+
._sizeM_1yw9uw9_11{
|
|
9
9
|
--_rs-dropdown-menu-min-width:316px;
|
|
10
10
|
--_rs-dropdown-menu-max-width:494px;
|
|
11
11
|
}
|
|
12
|
-
.
|
|
12
|
+
._sizeM_1yw9uw9_11 [data-rs-internal='dropdown-menu__menu-wrapper']{
|
|
13
13
|
--_rs-dropdown-menu-item-height:40px;
|
|
14
14
|
}
|
|
15
|
-
.
|
|
15
|
+
._sizeL_1yw9uw9_14{
|
|
16
16
|
--_rs-dropdown-menu-min-width:316px;
|
|
17
17
|
--_rs-dropdown-menu-max-width:494px;
|
|
18
18
|
}
|
|
19
|
-
.
|
|
19
|
+
._sizeL_1yw9uw9_14 [data-rs-internal='dropdown-menu__menu-wrapper']{
|
|
20
20
|
--_rs-dropdown-menu-item-height:52px;
|
|
21
21
|
}
|
|
22
|
-
.
|
|
22
|
+
._dropdownMenu_1yw9uw9_18{
|
|
23
23
|
min-width:var(--_rs-dropdown-menu-min-width);
|
|
24
24
|
max-width:var(--_rs-dropdown-menu-max-width);
|
|
25
25
|
}
|
|
26
|
-
.
|
|
26
|
+
._menu_1yw9uw9_23{
|
|
27
27
|
margin:0;
|
|
28
28
|
padding:0;
|
|
29
29
|
|
|
@@ -6,6 +6,8 @@ DropdownMenu is a special type of Dropdown component with predefined dimensions
|
|
|
6
6
|
|
|
7
7
|
### Features showcase
|
|
8
8
|
|
|
9
|
+
Do not combine `iconPlacement="right"` with `selected` prop.
|
|
10
|
+
|
|
9
11
|
#### Basic example
|
|
10
12
|
|
|
11
13
|
```tsx
|
|
@@ -139,7 +141,8 @@ const GlowMenuItem = ({ theme, ...restProps }) => {
|
|
|
139
141
|
lightSizeEnterAnimationTime: 0,
|
|
140
142
|
lightSizeLeaveAnimationTime: 0,
|
|
141
143
|
preset: 'bright-pink',
|
|
142
|
-
enableBurst: true
|
|
144
|
+
enableBurst: true,
|
|
145
|
+
forceTheme: 'light'
|
|
143
146
|
});
|
|
144
147
|
return <MenuItem {...restProps} ref={ref} />;
|
|
145
148
|
};
|
|
@@ -171,45 +174,45 @@ const Demo = () => {
|
|
|
171
174
|
render(<Demo />);
|
|
172
175
|
```
|
|
173
176
|
|
|
174
|
-
#### With
|
|
177
|
+
#### With selected support
|
|
175
178
|
|
|
176
179
|
```tsx
|
|
177
180
|
import { useState } from 'react';
|
|
178
181
|
import { DropdownMenu, MenuItem } from '@rescui/dropdown-menu';
|
|
179
182
|
import { Button } from '@rescui/button';
|
|
180
|
-
import { useGlowHover } from '@rescui/use-glow-hover';
|
|
181
183
|
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
184
|
+
const OPTIONS = [
|
|
185
|
+
'Some text 1',
|
|
186
|
+
'Some text 2',
|
|
187
|
+
'Some text 3',
|
|
188
|
+
'Some text 4',
|
|
189
|
+
'Some text 5',
|
|
190
|
+
'Some text 6',
|
|
191
|
+
'Some text 7',
|
|
192
|
+
'Some text 8'
|
|
193
|
+
];
|
|
192
194
|
|
|
193
195
|
const Demo = () => {
|
|
194
196
|
const [isOpen, setIsOpen] = useState(false);
|
|
197
|
+
const [selected, setSelected] = useState(OPTIONS[2]);
|
|
195
198
|
|
|
196
199
|
const toggleIsOpen = () => setIsOpen(s => !s);
|
|
197
200
|
|
|
198
201
|
return (
|
|
199
202
|
<DropdownMenu
|
|
200
|
-
mode={'rock'}
|
|
201
203
|
isOpen={isOpen}
|
|
202
204
|
onRequestClose={() => setIsOpen(false)}
|
|
203
205
|
trigger={<Button onClick={toggleIsOpen}>Open Menu</Button>}
|
|
204
206
|
>
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
{OPTIONS.map(option => (
|
|
208
|
+
<MenuItem
|
|
209
|
+
key={option}
|
|
210
|
+
selected={selected === option}
|
|
211
|
+
onClick={() => setSelected(option)}
|
|
212
|
+
>
|
|
213
|
+
{option}
|
|
214
|
+
</MenuItem>
|
|
215
|
+
))}
|
|
213
216
|
</DropdownMenu>
|
|
214
217
|
);
|
|
215
218
|
};
|
|
@@ -283,6 +286,106 @@ const Demo = () => {
|
|
|
283
286
|
render(<Demo />);
|
|
284
287
|
```
|
|
285
288
|
|
|
289
|
+
#### With hover icon
|
|
290
|
+
|
|
291
|
+
```tsx
|
|
292
|
+
import { useState } from 'react';
|
|
293
|
+
import { DropdownMenu, MenuItem } from '@rescui/dropdown-menu';
|
|
294
|
+
import { Button } from '@rescui/button';
|
|
295
|
+
import {
|
|
296
|
+
LeftOutlineIcon,
|
|
297
|
+
DownloadOutlineIcon,
|
|
298
|
+
CloseOutlineIcon
|
|
299
|
+
} from '@rescui/icons';
|
|
300
|
+
|
|
301
|
+
const Demo = () => {
|
|
302
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
303
|
+
|
|
304
|
+
const toggleIsOpen = () => setIsOpen(s => !s);
|
|
305
|
+
|
|
306
|
+
return (
|
|
307
|
+
<DropdownMenu
|
|
308
|
+
isOpen={isOpen}
|
|
309
|
+
onRequestClose={() => setIsOpen(false)}
|
|
310
|
+
trigger={<Button onClick={toggleIsOpen}>With hover icons</Button>}
|
|
311
|
+
size="l"
|
|
312
|
+
>
|
|
313
|
+
<MenuItem hoverIcon={<DownloadOutlineIcon />}>Some text 1</MenuItem>
|
|
314
|
+
<MenuItem hoverIcon={<CloseOutlineIcon />} selected>
|
|
315
|
+
Some text 2
|
|
316
|
+
</MenuItem>
|
|
317
|
+
<MenuItem hoverIcon={<DownloadOutlineIcon />}>Some text 3</MenuItem>
|
|
318
|
+
<MenuItem
|
|
319
|
+
icon={<LeftOutlineIcon />}
|
|
320
|
+
iconPlacement="right"
|
|
321
|
+
hoverIcon={<CloseOutlineIcon />}
|
|
322
|
+
>
|
|
323
|
+
Some text 4
|
|
324
|
+
</MenuItem>
|
|
325
|
+
<MenuItem hoverIcon={<DownloadOutlineIcon />}>Some text 5</MenuItem>
|
|
326
|
+
</DropdownMenu>
|
|
327
|
+
);
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
render(<Demo />);
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### Contrast primary color
|
|
334
|
+
|
|
335
|
+
If your primary color background requires dark text color, use `--rs-dropdown-menu-contrast-primary` CSS variable.
|
|
336
|
+
|
|
337
|
+
```tsx
|
|
338
|
+
import { useState } from 'react';
|
|
339
|
+
import { DropdownMenu, MenuItem } from '@rescui/dropdown-menu';
|
|
340
|
+
import { Button } from '@rescui/button';
|
|
341
|
+
|
|
342
|
+
const Demo = () => {
|
|
343
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
344
|
+
|
|
345
|
+
const toggleIsOpen = () => setIsOpen(s => !s);
|
|
346
|
+
|
|
347
|
+
return (
|
|
348
|
+
<div className="light-green-primary">
|
|
349
|
+
<DropdownMenu
|
|
350
|
+
isOpen={isOpen}
|
|
351
|
+
onRequestClose={() => setIsOpen(false)}
|
|
352
|
+
trigger={
|
|
353
|
+
<Button onClick={toggleIsOpen} mode="rock">
|
|
354
|
+
Open Menu
|
|
355
|
+
</Button>
|
|
356
|
+
}
|
|
357
|
+
size="l"
|
|
358
|
+
className="dropdown-menu-with-contrast-primary"
|
|
359
|
+
>
|
|
360
|
+
<MenuItem>Some text 1</MenuItem>
|
|
361
|
+
<MenuItem>Some text 2</MenuItem>
|
|
362
|
+
<MenuItem>Some text 3</MenuItem>
|
|
363
|
+
<MenuItem>Some text 4</MenuItem>
|
|
364
|
+
<MenuItem>Some text 5</MenuItem>
|
|
365
|
+
</DropdownMenu>
|
|
366
|
+
</div>
|
|
367
|
+
);
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
render(<Demo />);
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
```postcss
|
|
374
|
+
.dropdown-menu-with-contrast-primary {
|
|
375
|
+
--rs-dropdown-menu-contrast-primary: 1;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.light-green-primary {
|
|
379
|
+
--rs-color-primary-light-theme: rgb(71, 224, 84);
|
|
380
|
+
--rs-color-primary-t-dim-light-theme: rgba(71, 224, 84, 0.8);
|
|
381
|
+
--rs-color-primary-t-fog-light-theme: rgba(71, 224, 84, 0.2);
|
|
382
|
+
|
|
383
|
+
--rs-color-primary-dark-theme: rgb(71, 224, 84);
|
|
384
|
+
--rs-color-primary-t-dim-dark-theme: rgba(71, 224, 84, 0.8);
|
|
385
|
+
--rs-color-primary-t-fog-dark-theme: rgba(71, 224, 84, 0.2);
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
286
389
|
## CSS Mixins API
|
|
287
390
|
|
|
288
391
|
#### `DropdownMenu` mixins
|
|
@@ -342,3 +445,11 @@ render(<MyDropdownMenu />);
|
|
|
342
445
|
}
|
|
343
446
|
}
|
|
344
447
|
```
|
|
448
|
+
|
|
449
|
+
#### `Menu` CSS Vars
|
|
450
|
+
|
|
451
|
+
| Variable | Syntax | Description |
|
|
452
|
+
| --- | --- | --- |
|
|
453
|
+
| `--rs-dropdown-menu-contrast-primary` | `0 \| 1` | The flag whenever the current primary is contrast enough and highlighted text color should be inverted |
|
|
454
|
+
|
|
455
|
+
Check out [this example](/components/dropdown-menu/#contrast-primary-color) for contrast primary.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/dropdown-menu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -17,27 +17,27 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@babel/runtime-corejs3": "^7.26.0",
|
|
20
|
-
"@rescui/dropdown": "0.11.1
|
|
21
|
-
"@rescui/menu": "0.
|
|
22
|
-
"@rescui/use-resize-observer": "0.3.
|
|
20
|
+
"@rescui/dropdown": "^0.11.1",
|
|
21
|
+
"@rescui/menu": "^0.14.0",
|
|
22
|
+
"@rescui/use-resize-observer": "^0.3.3",
|
|
23
23
|
"classnames": "^2.2.6"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@rescui/ui-contexts": "^0.6.0",
|
|
27
27
|
"prop-types": "^15",
|
|
28
|
-
"react": ">=
|
|
28
|
+
"react": ">=16.8.0 <20"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@rescui/colors": "0.3.
|
|
32
|
-
"@rescui/icons": "1.8.3
|
|
33
|
-
"@rescui/scripts": "0.5.2",
|
|
34
|
-
"@rescui/typography": "0.27.3
|
|
35
|
-
"@rescui/visual-regression": "0.1.4"
|
|
31
|
+
"@rescui/colors": "^0.3.2",
|
|
32
|
+
"@rescui/icons": "^1.8.3",
|
|
33
|
+
"@rescui/scripts": "^0.5.2",
|
|
34
|
+
"@rescui/typography": "^0.27.3",
|
|
35
|
+
"@rescui/visual-regression": "^0.1.4"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "rescui-scripts build && yarn run build-pcss-api",
|
|
39
39
|
"build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
|
|
40
40
|
},
|
|
41
41
|
"nx": {},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "7614b4519a4716fbf1151d94c97fda48eab60800"
|
|
43
43
|
}
|