@ultraviolet/ui 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +47 -8
- package/dist/src/components/Badge/index.js +26 -33
- package/dist/src/components/Link/index.js +1 -1
- package/dist/src/components/Menu/index.js +1 -0
- package/dist/src/components/MenuV2/Item.js +122 -0
- package/dist/src/components/MenuV2/index.js +126 -0
- package/dist/src/components/Modal/Disclosure.js +21 -19
- package/dist/src/components/Modal/index.js +1 -1
- package/dist/src/components/Notice/index.js +19 -15
- package/dist/src/components/PasswordStrengthMeter/index.js +1 -1
- package/dist/src/components/Text/index.js +1 -1
- package/dist/src/components/TextInput/index.js +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/internalComponents/Popup/index.js +3 -2
- package/package.json +4 -5
package/dist/index.d.ts
CHANGED
|
@@ -1414,7 +1414,7 @@ type LoaderProps = {
|
|
|
1414
1414
|
*/
|
|
1415
1415
|
declare const Loader: ({ percentage, text, size, strokeWidth, color, trailColor, active, label, }: LoaderProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
1416
1416
|
|
|
1417
|
-
type DisclosureElement = ((popover: Partial<PopoverStateReturn>) => ReactElement<ButtonHTMLAttributes<HTMLButtonElement>>) | (ReactElement<ButtonHTMLAttributes<HTMLButtonElement>> & {
|
|
1417
|
+
type DisclosureElement$1 = ((popover: Partial<PopoverStateReturn>) => ReactElement<ButtonHTMLAttributes<HTMLButtonElement>>) | (ReactElement<ButtonHTMLAttributes<HTMLButtonElement>> & {
|
|
1418
1418
|
ref?: Ref<HTMLButtonElement>;
|
|
1419
1419
|
});
|
|
1420
1420
|
declare const arrowPlacementStyles: {
|
|
@@ -1426,13 +1426,13 @@ declare const arrowPlacementStyles: {
|
|
|
1426
1426
|
readonly 'top-start': (theme: Theme) => _emotion_react.SerializedStyles;
|
|
1427
1427
|
};
|
|
1428
1428
|
type ArrowPlacement = keyof typeof arrowPlacementStyles;
|
|
1429
|
-
type MenuProps = {
|
|
1429
|
+
type MenuProps$1 = {
|
|
1430
1430
|
ariaLabel?: string;
|
|
1431
1431
|
id?: string;
|
|
1432
1432
|
placement?: ArrowPlacement;
|
|
1433
1433
|
children?: ((props: PopoverStateReturn) => ReactNode) | ReactNode;
|
|
1434
1434
|
className?: string;
|
|
1435
|
-
disclosure: DisclosureElement;
|
|
1435
|
+
disclosure: DisclosureElement$1;
|
|
1436
1436
|
hasArrow?: boolean;
|
|
1437
1437
|
visible?: boolean;
|
|
1438
1438
|
'data-testid'?: string;
|
|
@@ -1442,8 +1442,9 @@ type MenuProps = {
|
|
|
1442
1442
|
* A menu is usually opened, or made visible, by activating a menu button, choosing an item in a menu that opens a
|
|
1443
1443
|
* sub menu, or by invoking a command, such as `Shift + F10` on Windows, that opens a context specific menu.
|
|
1444
1444
|
* When a user activates a choice in a menu, the menu usually closes unless the choice opened a submenu.
|
|
1445
|
+
* @deprecated use MenuV2 component instead
|
|
1445
1446
|
*/
|
|
1446
|
-
declare const Menu: react.ForwardRefExoticComponent<MenuProps & react.RefAttributes<HTMLButtonElement>> & {
|
|
1447
|
+
declare const Menu: react.ForwardRefExoticComponent<MenuProps$1 & react.RefAttributes<HTMLButtonElement>> & {
|
|
1447
1448
|
Item: react.ForwardRefExoticComponent<{
|
|
1448
1449
|
href?: string | undefined;
|
|
1449
1450
|
disabled?: boolean | undefined;
|
|
@@ -1503,7 +1504,7 @@ type ModalProps = {
|
|
|
1503
1504
|
hideOnClickOutside?: boolean;
|
|
1504
1505
|
preventBodyScroll?: boolean;
|
|
1505
1506
|
ariaLabel?: string;
|
|
1506
|
-
disclosure?:
|
|
1507
|
+
disclosure?: ReactElement | ((state: ModalState) => ReactElement);
|
|
1507
1508
|
isClosable?: boolean;
|
|
1508
1509
|
onClose?: () => void;
|
|
1509
1510
|
onBeforeClose?: () => Promise<void> | void;
|
|
@@ -1722,7 +1723,7 @@ declare const PieChart: ({ height, width, data, emptyLegend, content, withLegend
|
|
|
1722
1723
|
|
|
1723
1724
|
type PopupPlacement = 'top' | 'right' | 'bottom' | 'left' | 'auto';
|
|
1724
1725
|
|
|
1725
|
-
type
|
|
1726
|
+
type PopupProps = {
|
|
1726
1727
|
/**
|
|
1727
1728
|
* Id is automatically generated if not set. It is used for associating tooltip wrapper with tooltip portal.
|
|
1728
1729
|
*/
|
|
@@ -1758,10 +1759,11 @@ type TooltipProps$1 = {
|
|
|
1758
1759
|
'data-testid'?: string;
|
|
1759
1760
|
hasArrow?: boolean;
|
|
1760
1761
|
onClose?: () => void;
|
|
1762
|
+
tabIndex?: number;
|
|
1761
1763
|
onKeyDown?: KeyboardEventHandler;
|
|
1762
1764
|
'aria-haspopup'?: HTMLAttributes<HTMLDivElement>['aria-haspopup'];
|
|
1763
1765
|
};
|
|
1764
|
-
declare const Popup: react.ForwardRefExoticComponent<
|
|
1766
|
+
declare const Popup: react.ForwardRefExoticComponent<PopupProps & react.RefAttributes<HTMLDivElement>>;
|
|
1765
1767
|
|
|
1766
1768
|
type SentimentType = 'neutral' | 'primary';
|
|
1767
1769
|
declare const SIZES_WIDTH: {
|
|
@@ -2592,6 +2594,43 @@ declare const RadioGroup: {
|
|
|
2592
2594
|
Radio: ({ onFocus, onBlur, disabled, error, name, value, label, helper, className, autoFocus, onKeyDown, "data-testid": dataTestId, }: RadioGroupRadioProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
2593
2595
|
};
|
|
2594
2596
|
|
|
2597
|
+
type DisclosureProps = {
|
|
2598
|
+
visible: boolean;
|
|
2599
|
+
};
|
|
2600
|
+
type DisclosureElement = ((disclosure: DisclosureProps) => ReactElement<ButtonHTMLAttributes<HTMLButtonElement>>) | (ReactElement<ButtonHTMLAttributes<HTMLButtonElement>> & {
|
|
2601
|
+
ref?: Ref<HTMLButtonElement>;
|
|
2602
|
+
});
|
|
2603
|
+
type MenuProps = {
|
|
2604
|
+
id?: string;
|
|
2605
|
+
ariaLabel?: string;
|
|
2606
|
+
placement?: ComponentProps<typeof Popup>['placement'];
|
|
2607
|
+
children?: ReactNode;
|
|
2608
|
+
className?: string;
|
|
2609
|
+
disclosure: DisclosureElement;
|
|
2610
|
+
hasArrow?: boolean;
|
|
2611
|
+
visible?: boolean;
|
|
2612
|
+
'data-testid'?: string;
|
|
2613
|
+
};
|
|
2614
|
+
/**
|
|
2615
|
+
* A menu is a widget that offers a list of choices to the user, such as a set of actions or functions.
|
|
2616
|
+
* A menu is usually opened, or made visible, by activating a menu button, choosing an item in a menu that opens a
|
|
2617
|
+
* sub menu, or by invoking a command, such as `Shift + F10` on Windows, that opens a context specific menu.
|
|
2618
|
+
* When a user activates a choice in a menu, the menu usually closes unless the choice opened a submenu.
|
|
2619
|
+
*/
|
|
2620
|
+
declare const MenuV2: react.ForwardRefExoticComponent<MenuProps & react.RefAttributes<HTMLButtonElement>> & {
|
|
2621
|
+
Item: react.ForwardRefExoticComponent<{
|
|
2622
|
+
href?: string | undefined;
|
|
2623
|
+
disabled?: boolean | undefined;
|
|
2624
|
+
tooltip?: string | undefined;
|
|
2625
|
+
className?: string | undefined;
|
|
2626
|
+
children: ReactNode;
|
|
2627
|
+
onClick?: react.MouseEventHandler<HTMLElement> | undefined;
|
|
2628
|
+
borderless?: boolean | undefined;
|
|
2629
|
+
sentiment?: ("neutral" | "danger") | undefined;
|
|
2630
|
+
'data-testid'?: string | undefined;
|
|
2631
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
2632
|
+
};
|
|
2633
|
+
|
|
2595
2634
|
declare const getUUID: (prefix?: string) => string;
|
|
2596
2635
|
|
|
2597
2636
|
declare const bounce: _emotion_react.Keyframes;
|
|
@@ -2635,4 +2674,4 @@ declare const down: (size: ScreenSize, rules: string) => string;
|
|
|
2635
2674
|
|
|
2636
2675
|
declare const normalize: () => string;
|
|
2637
2676
|
|
|
2638
|
-
export { ActionBar, Alert, Avatar, Badge, Banner, BarChart, BarStack, Breadcrumbs, Breakpoint, Bullet, Button, Card, Carousel, Checkbox, CheckboxGroup, CheckboxGroupCheckbox, CopyButton, DateInput, EmptyState, Expandable, LineChart, Link, List, Loader, Menu, Meter, Modal, Notice, NumberInput, Pagination, PasswordCheck, PasswordStrengthMeter, PieChart, Popover, ProgressBar, Radio, RadioGroup, Row, type SCWUITheme, SelectInput, SelectableCard, Separator, Skeleton, Snippet, Stack, Status, StepList, Stepper, SwitchButton, Table, Tabs, Tag, TagInput, TagList, Text, TextInput, TimeInput, ToastContainer, Toggle, ToggleGroup, Tooltip, VerificationCode, bounce, down, extendTheme, fadeIn, fadeOut, flash, getUUID, normalize, ping, pulse, quickScaleDown, scaleBack, scaleDown, scaleForward, scaleUp, sketchIn, sketchOut, slideDownLarge, slideFromBottom, slideFromLeft, slideFromRight, slideFromTop, slideToBottom, slideToLeft, slideToRight, slideToTop, slideUpLarge, toast, unfoldIn, unfoldOut, up, zoomIn, zoomOut };
|
|
2677
|
+
export { ActionBar, Alert, Avatar, Badge, Banner, BarChart, BarStack, Breadcrumbs, Breakpoint, Bullet, Button, Card, Carousel, Checkbox, CheckboxGroup, CheckboxGroupCheckbox, CopyButton, DateInput, EmptyState, Expandable, LineChart, Link, List, Loader, Menu, MenuV2, Meter, Modal, Notice, NumberInput, Pagination, PasswordCheck, PasswordStrengthMeter, PieChart, Popover, ProgressBar, Radio, RadioGroup, Row, type SCWUITheme, SelectInput, SelectableCard, Separator, Skeleton, Snippet, Stack, Status, StepList, Stepper, SwitchButton, Table, Tabs, Tag, TagInput, TagList, Text, TextInput, TimeInput, ToastContainer, Toggle, ToggleGroup, Tooltip, VerificationCode, bounce, down, extendTheme, fadeIn, fadeOut, flash, getUUID, normalize, ping, pulse, quickScaleDown, scaleBack, scaleDown, scaleForward, scaleUp, sketchIn, sketchOut, slideDownLarge, slideFromBottom, slideFromLeft, slideFromRight, slideFromTop, slideToBottom, slideToLeft, slideToRight, slideToTop, slideUpLarge, toast, unfoldIn, unfoldOut, up, zoomIn, zoomOut };
|
|
@@ -7,15 +7,6 @@ import capitalize from '../../utils/capitalize.js';
|
|
|
7
7
|
import { Text } from '../Text/index.js';
|
|
8
8
|
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
9
9
|
|
|
10
|
-
const StyledText = /*#__PURE__*/_styled(Text, {
|
|
11
|
-
target: "ej33bna1"
|
|
12
|
-
})("text-transform:uppercase;font-size:", _ref => {
|
|
13
|
-
let {
|
|
14
|
-
fontSize
|
|
15
|
-
} = _ref;
|
|
16
|
-
return fontSize;
|
|
17
|
-
}, "px;color:inherit;");
|
|
18
|
-
|
|
19
10
|
// TODO: remove when typography has been created
|
|
20
11
|
const TEXT_SIZES = {
|
|
21
12
|
large: 14,
|
|
@@ -35,11 +26,11 @@ const PROMINENCES = {
|
|
|
35
26
|
/**
|
|
36
27
|
* Generate all styles available for badge based on prominence and sentiments
|
|
37
28
|
*/
|
|
38
|
-
const generateStyles =
|
|
29
|
+
const generateStyles = _ref => {
|
|
39
30
|
let {
|
|
40
31
|
prominence,
|
|
41
32
|
theme
|
|
42
|
-
} =
|
|
33
|
+
} = _ref;
|
|
43
34
|
const definedProminence = prominence === PROMINENCES.strong ? capitalize(PROMINENCES.strong) : '';
|
|
44
35
|
const text = `text${definedProminence}`;
|
|
45
36
|
const background = `background${definedProminence}`;
|
|
@@ -64,36 +55,41 @@ const generateStyles = _ref2 => {
|
|
|
64
55
|
`
|
|
65
56
|
};
|
|
66
57
|
};
|
|
67
|
-
const StyledSpan = /*#__PURE__*/_styled(
|
|
68
|
-
shouldForwardProp: prop => !['
|
|
58
|
+
const StyledSpan = /*#__PURE__*/_styled(Text, {
|
|
59
|
+
shouldForwardProp: prop => !['sentimentStyles', 'size', 'fontSize'].includes(prop),
|
|
69
60
|
target: "ej33bna0"
|
|
70
|
-
})("display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;border-radius:",
|
|
61
|
+
})("display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;border-radius:", _ref2 => {
|
|
71
62
|
let {
|
|
72
63
|
theme
|
|
73
|
-
} =
|
|
64
|
+
} = _ref2;
|
|
74
65
|
return theme.radii.xlarge;
|
|
75
|
-
}, ";padding:0 ",
|
|
66
|
+
}, ";padding:0 ", _ref3 => {
|
|
76
67
|
let {
|
|
77
68
|
theme,
|
|
78
69
|
size
|
|
79
|
-
} =
|
|
70
|
+
} = _ref3;
|
|
80
71
|
return size === SIZES.small ? theme.space['1'] : theme.space['2'];
|
|
81
|
-
}, ";gap:",
|
|
72
|
+
}, ";gap:", _ref4 => {
|
|
82
73
|
let {
|
|
83
74
|
theme,
|
|
84
75
|
size
|
|
85
|
-
} =
|
|
76
|
+
} = _ref4;
|
|
86
77
|
return size === SIZES.small ? theme.space['0.5'] : theme.space['1'];
|
|
87
|
-
}, ";width:fit-content;height:",
|
|
78
|
+
}, ";width:fit-content;height:", _ref5 => {
|
|
88
79
|
let {
|
|
89
80
|
size
|
|
90
|
-
} =
|
|
81
|
+
} = _ref5;
|
|
91
82
|
return size;
|
|
92
|
-
}, "px;",
|
|
83
|
+
}, "px;text-transform:uppercase;font-size:", _ref6 => {
|
|
84
|
+
let {
|
|
85
|
+
fontSize
|
|
86
|
+
} = _ref6;
|
|
87
|
+
return fontSize;
|
|
88
|
+
}, "px;color:inherit;", _ref7 => {
|
|
93
89
|
let {
|
|
94
|
-
|
|
90
|
+
sentimentStyles
|
|
95
91
|
} = _ref7;
|
|
96
|
-
return
|
|
92
|
+
return sentimentStyles;
|
|
97
93
|
}, ";");
|
|
98
94
|
/**
|
|
99
95
|
* Badge component is used to display a status or a label in a small container.
|
|
@@ -121,22 +117,19 @@ const Badge = _ref8 => {
|
|
|
121
117
|
}), [prominence, theme]);
|
|
122
118
|
const sizeValue = SIZES[size];
|
|
123
119
|
return jsxs(StyledSpan, {
|
|
124
|
-
role: "status",
|
|
125
120
|
"aria-label": ariaLabel,
|
|
126
|
-
|
|
121
|
+
sentimentStyles: disabled ? generatedStyles['disabled'] : generatedStyles[sentiment],
|
|
127
122
|
size: sizeValue,
|
|
123
|
+
variant: "bodyStrong",
|
|
124
|
+
as: "span",
|
|
125
|
+
fontSize: TEXT_SIZES[size],
|
|
126
|
+
prominence: disabled ? 'weak' : 'default',
|
|
128
127
|
className: className,
|
|
129
128
|
"data-testid": dataTestId,
|
|
130
129
|
children: [icon && sizeValue !== SIZES.small ? jsx(Icon, {
|
|
131
130
|
name: icon,
|
|
132
131
|
size: 16
|
|
133
|
-
}) : null,
|
|
134
|
-
variant: "bodyStrong",
|
|
135
|
-
as: "p",
|
|
136
|
-
fontSize: TEXT_SIZES[size],
|
|
137
|
-
prominence: disabled ? 'weak' : 'default',
|
|
138
|
-
children: children
|
|
139
|
-
})]
|
|
132
|
+
}) : null, children]
|
|
140
133
|
});
|
|
141
134
|
};
|
|
142
135
|
|
|
@@ -119,7 +119,7 @@ const Link = /*#__PURE__*/forwardRef((_ref9, ref) => {
|
|
|
119
119
|
const usedRef = ref ?? elementRef;
|
|
120
120
|
const finalStringChildren = recursivelyGetChildrenString(children);
|
|
121
121
|
useEffect(() => {
|
|
122
|
-
if (oneLine && usedRef
|
|
122
|
+
if (oneLine && usedRef?.current) {
|
|
123
123
|
const {
|
|
124
124
|
offsetWidth,
|
|
125
125
|
scrollWidth
|
|
@@ -145,6 +145,7 @@ const FwdMenu = /*#__PURE__*/forwardRef((_ref9, ref) => {
|
|
|
145
145
|
* A menu is usually opened, or made visible, by activating a menu button, choosing an item in a menu that opens a
|
|
146
146
|
* sub menu, or by invoking a command, such as `Shift + F10` on Windows, that opens a context specific menu.
|
|
147
147
|
* When a user activates a choice in a menu, the menu usually closes unless the choice opened a submenu.
|
|
148
|
+
* @deprecated use MenuV2 component instead
|
|
148
149
|
*/
|
|
149
150
|
const Menu = /*#__PURE__*/Object.assign(FwdMenu, {
|
|
150
151
|
Item
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { Tooltip } from '../Tooltip/index.js';
|
|
4
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
const itemCoreStyle = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
theme,
|
|
9
|
+
borderless,
|
|
10
|
+
sentiment,
|
|
11
|
+
disabled
|
|
12
|
+
} = _ref;
|
|
13
|
+
return `
|
|
14
|
+
display: inline-block;
|
|
15
|
+
font-size: ${theme.typography.bodySmall.fontSize};
|
|
16
|
+
line-height: ${theme.typography.bodySmall.lineHeight};
|
|
17
|
+
font-weight: inherit;
|
|
18
|
+
padding: ${`${theme.space['0.5']} ${theme.space['1']}`};
|
|
19
|
+
border: none;
|
|
20
|
+
${borderless ? '' : `border-bottom: 1px solid ${theme.colors.neutral.border};`}
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
min-width: 110px;
|
|
23
|
+
|
|
24
|
+
color: ${theme.colors[sentiment][disabled ? 'textDisabled' : 'text']};
|
|
25
|
+
svg {
|
|
26
|
+
fill: ${theme.colors[sentiment][disabled ? 'textDisabled' : 'text']};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
${disabled ? `
|
|
30
|
+
cursor: not-allowed;
|
|
31
|
+
` : `
|
|
32
|
+
&:hover,
|
|
33
|
+
&:focus {
|
|
34
|
+
color: ${theme.colors[sentiment].textHover};
|
|
35
|
+
svg {
|
|
36
|
+
fill: ${theme.colors[sentiment].textHover};
|
|
37
|
+
}
|
|
38
|
+
}`}
|
|
39
|
+
`;
|
|
40
|
+
};
|
|
41
|
+
const StyledItem = /*#__PURE__*/_styled('button', {
|
|
42
|
+
shouldForwardProp: prop => !['borderless', 'sentiment'].includes(prop),
|
|
43
|
+
target: "ei26g5y1"
|
|
44
|
+
})(_ref2 => {
|
|
45
|
+
let {
|
|
46
|
+
theme,
|
|
47
|
+
borderless,
|
|
48
|
+
sentiment,
|
|
49
|
+
disabled
|
|
50
|
+
} = _ref2;
|
|
51
|
+
return itemCoreStyle({
|
|
52
|
+
theme,
|
|
53
|
+
borderless,
|
|
54
|
+
sentiment,
|
|
55
|
+
disabled
|
|
56
|
+
});
|
|
57
|
+
}, " background:none;");
|
|
58
|
+
const StyledLinkItem = /*#__PURE__*/_styled('a', {
|
|
59
|
+
shouldForwardProp: prop => !['borderless', 'sentiment'].includes(prop),
|
|
60
|
+
target: "ei26g5y0"
|
|
61
|
+
})(_ref3 => {
|
|
62
|
+
let {
|
|
63
|
+
theme,
|
|
64
|
+
borderless,
|
|
65
|
+
sentiment,
|
|
66
|
+
disabled
|
|
67
|
+
} = _ref3;
|
|
68
|
+
return itemCoreStyle({
|
|
69
|
+
theme,
|
|
70
|
+
borderless,
|
|
71
|
+
sentiment,
|
|
72
|
+
disabled
|
|
73
|
+
});
|
|
74
|
+
}, " text-decoration:none;&:focus{text-decoration:none;}");
|
|
75
|
+
const Item = /*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
76
|
+
let {
|
|
77
|
+
borderless = false,
|
|
78
|
+
disabled = false,
|
|
79
|
+
onClick,
|
|
80
|
+
sentiment = 'neutral',
|
|
81
|
+
href,
|
|
82
|
+
children,
|
|
83
|
+
tooltip,
|
|
84
|
+
className,
|
|
85
|
+
'data-testid': dataTestId
|
|
86
|
+
} = _ref4;
|
|
87
|
+
if (href && !disabled) {
|
|
88
|
+
return jsx(Tooltip, {
|
|
89
|
+
text: tooltip,
|
|
90
|
+
children: jsx(StyledLinkItem, {
|
|
91
|
+
borderless: true,
|
|
92
|
+
href: href,
|
|
93
|
+
ref: ref,
|
|
94
|
+
onClick: disabled ? undefined : onClick,
|
|
95
|
+
role: "menuitem",
|
|
96
|
+
disabled: disabled,
|
|
97
|
+
sentiment: sentiment,
|
|
98
|
+
className: className,
|
|
99
|
+
"data-testid": dataTestId,
|
|
100
|
+
children: children
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return jsx(Tooltip, {
|
|
105
|
+
text: tooltip,
|
|
106
|
+
children: jsx(StyledItem, {
|
|
107
|
+
type: "button",
|
|
108
|
+
ref: ref,
|
|
109
|
+
role: "menuitem",
|
|
110
|
+
disabled: disabled,
|
|
111
|
+
onClick: onClick,
|
|
112
|
+
borderless: borderless,
|
|
113
|
+
sentiment: sentiment,
|
|
114
|
+
className: className,
|
|
115
|
+
"data-testid": dataTestId,
|
|
116
|
+
children: children
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
var Item$1 = Item;
|
|
121
|
+
|
|
122
|
+
export { Item$1 as default };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
2
|
+
import { forwardRef, useState, useRef, useId, isValidElement, useImperativeHandle, cloneElement } from 'react';
|
|
3
|
+
import { Stack } from '../Stack/index.js';
|
|
4
|
+
import Item from './Item.js';
|
|
5
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
6
|
+
import { Popup } from '../../internalComponents/Popup/index.js';
|
|
7
|
+
|
|
8
|
+
const StyledPopup = /*#__PURE__*/_styled(Popup, {
|
|
9
|
+
target: "e1jn11gg1"
|
|
10
|
+
})("background-color:", _ref => {
|
|
11
|
+
let {
|
|
12
|
+
theme
|
|
13
|
+
} = _ref;
|
|
14
|
+
return theme.colors.neutral.background;
|
|
15
|
+
}, ";box-shadow:", _ref2 => {
|
|
16
|
+
let {
|
|
17
|
+
theme
|
|
18
|
+
} = _ref2;
|
|
19
|
+
return theme.shadows.menu;
|
|
20
|
+
}, ";padding:0;&[data-has-arrow='true']{&::after{border-color:", _ref3 => {
|
|
21
|
+
let {
|
|
22
|
+
theme
|
|
23
|
+
} = _ref3;
|
|
24
|
+
return theme.colors.neutral.background;
|
|
25
|
+
}, " transparent transparent transparent;}}");
|
|
26
|
+
const MenuList = /*#__PURE__*/_styled(Stack, {
|
|
27
|
+
target: "e1jn11gg0"
|
|
28
|
+
})("&:after,&:before{border:solid transparent;border-width:9px;content:' ';height:0;width:0;position:absolute;pointer-events:none;}&:after{border-color:transparent;}&:before{border-color:transparent;}background-color:", _ref4 => {
|
|
29
|
+
let {
|
|
30
|
+
theme
|
|
31
|
+
} = _ref4;
|
|
32
|
+
return theme.colors.neutral.backgroundWeakElevated;
|
|
33
|
+
}, ";color:", _ref5 => {
|
|
34
|
+
let {
|
|
35
|
+
theme
|
|
36
|
+
} = _ref5;
|
|
37
|
+
return theme.colors.neutral.text;
|
|
38
|
+
}, ";border-radius:", _ref6 => {
|
|
39
|
+
let {
|
|
40
|
+
theme
|
|
41
|
+
} = _ref6;
|
|
42
|
+
return theme.radii.default;
|
|
43
|
+
}, ";position:relative;");
|
|
44
|
+
const FwdMenu = /*#__PURE__*/forwardRef((_ref7, ref) => {
|
|
45
|
+
let {
|
|
46
|
+
id,
|
|
47
|
+
ariaLabel = 'Menu',
|
|
48
|
+
children,
|
|
49
|
+
disclosure,
|
|
50
|
+
hasArrow = true,
|
|
51
|
+
placement = 'bottom',
|
|
52
|
+
visible = false,
|
|
53
|
+
className,
|
|
54
|
+
'data-testid': dataTestId
|
|
55
|
+
} = _ref7;
|
|
56
|
+
const [isVisible, setIsVisible] = useState(visible);
|
|
57
|
+
const popupRef = useRef(null);
|
|
58
|
+
const disclosureRef = useRef(null);
|
|
59
|
+
const tempId = useId();
|
|
60
|
+
const finalId = `menu-${id ?? tempId}`;
|
|
61
|
+
|
|
62
|
+
// if you need dialog inside your component, use function, otherwise component is fine
|
|
63
|
+
const target = /*#__PURE__*/isValidElement(disclosure) ? disclosure : disclosure({
|
|
64
|
+
visible: isVisible
|
|
65
|
+
});
|
|
66
|
+
const innerRef = useRef(target);
|
|
67
|
+
useImperativeHandle(ref, () => innerRef.current);
|
|
68
|
+
const toggleVisible = () => {
|
|
69
|
+
setIsVisible(!isVisible);
|
|
70
|
+
|
|
71
|
+
// Focus the first item when the menu is opened
|
|
72
|
+
if (!isVisible) {
|
|
73
|
+
requestIdleCallback(() => {
|
|
74
|
+
// We have to wait for the popup to be inserted in the DOM
|
|
75
|
+
if (popupRef.current?.firstChild?.firstChild instanceof HTMLElement) {
|
|
76
|
+
popupRef.current.firstChild.firstChild.focus();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const onClose = () => {
|
|
82
|
+
setIsVisible(false);
|
|
83
|
+
|
|
84
|
+
// Focus the disclosure when the menu is closed
|
|
85
|
+
disclosureRef.current?.focus();
|
|
86
|
+
};
|
|
87
|
+
const finalDisclosure = /*#__PURE__*/cloneElement(target, {
|
|
88
|
+
onClick: toggleVisible,
|
|
89
|
+
'aria-haspopup': 'dialog',
|
|
90
|
+
'aria-expanded': isVisible,
|
|
91
|
+
// @ts-expect-error not sure how to fix this
|
|
92
|
+
ref: disclosureRef
|
|
93
|
+
});
|
|
94
|
+
return jsx(StyledPopup, {
|
|
95
|
+
"aria-label": ariaLabel,
|
|
96
|
+
className: className,
|
|
97
|
+
visible: isVisible,
|
|
98
|
+
placement: placement,
|
|
99
|
+
hasArrow: hasArrow,
|
|
100
|
+
"data-has-arrow": hasArrow,
|
|
101
|
+
role: "dialog",
|
|
102
|
+
id: finalId,
|
|
103
|
+
ref: popupRef,
|
|
104
|
+
onClose: onClose,
|
|
105
|
+
tabIndex: -1,
|
|
106
|
+
text: jsx(MenuList, {
|
|
107
|
+
"data-testid": dataTestId,
|
|
108
|
+
className: className,
|
|
109
|
+
role: "menu",
|
|
110
|
+
children: children
|
|
111
|
+
}),
|
|
112
|
+
children: finalDisclosure
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A menu is a widget that offers a list of choices to the user, such as a set of actions or functions.
|
|
118
|
+
* A menu is usually opened, or made visible, by activating a menu button, choosing an item in a menu that opens a
|
|
119
|
+
* sub menu, or by invoking a command, such as `Shift + F10` on Windows, that opens a context specific menu.
|
|
120
|
+
* When a user activates a choice in a menu, the menu usually closes unless the choice opened a submenu.
|
|
121
|
+
*/
|
|
122
|
+
const MenuV2 = /*#__PURE__*/Object.assign(FwdMenu, {
|
|
123
|
+
Item
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export { MenuV2 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, isValidElement, cloneElement, createRef } from 'react';
|
|
1
|
+
import { useEffect, useMemo, isValidElement, cloneElement, createRef } from 'react';
|
|
2
2
|
|
|
3
3
|
const Disclosure = _ref => {
|
|
4
4
|
let {
|
|
@@ -17,25 +17,27 @@ const Disclosure = _ref => {
|
|
|
17
17
|
element?.removeEventListener('click', handleOpen);
|
|
18
18
|
};
|
|
19
19
|
}, [handleOpen, disclosureRef]);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const finalDisclosure = useMemo(() => {
|
|
21
|
+
if (typeof disclosure === 'function') {
|
|
22
|
+
return disclosure({
|
|
23
|
+
visible,
|
|
24
|
+
onClose: handleClose,
|
|
25
|
+
toggle,
|
|
26
|
+
onOpen: handleOpen,
|
|
27
|
+
modalId: id,
|
|
28
|
+
hide: handleClose
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return disclosure;
|
|
32
|
+
}, [disclosure, handleOpen, handleClose, id, toggle, visible]);
|
|
33
|
+
if (! /*#__PURE__*/isValidElement(finalDisclosure)) {
|
|
34
|
+
return null;
|
|
29
35
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'aria-haspopup': 'dialog'
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
36
|
+
return /*#__PURE__*/cloneElement(finalDisclosure, {
|
|
37
|
+
ref: disclosureRef,
|
|
38
|
+
'aria-controls': id,
|
|
39
|
+
'aria-haspopup': 'dialog'
|
|
40
|
+
});
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export { Disclosure };
|
|
@@ -1,35 +1,39 @@
|
|
|
1
|
+
import _styled from '@emotion/styled/base';
|
|
1
2
|
import { Icon } from '@ultraviolet/icons';
|
|
2
|
-
import { Stack } from '../Stack/index.js';
|
|
3
3
|
import { Text } from '../Text/index.js';
|
|
4
4
|
import { jsxs, jsx } from '@emotion/react/jsx-runtime';
|
|
5
5
|
|
|
6
|
+
const StyledSpan = /*#__PURE__*/_styled(Text, {
|
|
7
|
+
target: "e19pqvs30"
|
|
8
|
+
})("display:flex;align-items:center;gap:", _ref => {
|
|
9
|
+
let {
|
|
10
|
+
theme
|
|
11
|
+
} = _ref;
|
|
12
|
+
return theme.space['1'];
|
|
13
|
+
}, ";");
|
|
14
|
+
|
|
6
15
|
/**
|
|
7
16
|
* A Notice is used to display a short message to the user.
|
|
8
17
|
*/
|
|
9
|
-
const Notice =
|
|
18
|
+
const Notice = _ref2 => {
|
|
10
19
|
let {
|
|
11
20
|
children,
|
|
12
21
|
className,
|
|
13
22
|
'data-testid': dataTestId
|
|
14
|
-
} =
|
|
15
|
-
return jsxs(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
} = _ref2;
|
|
24
|
+
return jsxs(StyledSpan, {
|
|
25
|
+
as: "span",
|
|
26
|
+
variant: "caption",
|
|
27
|
+
sentiment: "neutral",
|
|
28
|
+
prominence: "weak",
|
|
19
29
|
"data-testid": dataTestId,
|
|
20
30
|
className: className,
|
|
21
31
|
children: [jsx(Icon, {
|
|
22
32
|
name: "information-outline",
|
|
23
|
-
size:
|
|
33
|
+
size: 16,
|
|
24
34
|
color: "neutral",
|
|
25
35
|
prominence: "weak"
|
|
26
|
-
}),
|
|
27
|
-
as: "p",
|
|
28
|
-
variant: "caption",
|
|
29
|
-
color: "neutral",
|
|
30
|
-
prominence: "weak",
|
|
31
|
-
children: children
|
|
32
|
-
}) : children]
|
|
36
|
+
}), children]
|
|
33
37
|
});
|
|
34
38
|
};
|
|
35
39
|
|
|
@@ -88,7 +88,7 @@ const PasswordStrengthMeter = _ref7 => {
|
|
|
88
88
|
useEffect(() => {
|
|
89
89
|
setBackgroundColor(strength[score].color);
|
|
90
90
|
handleChange(score);
|
|
91
|
-
getScore(password).then(s => setScore(s)).catch(null);
|
|
91
|
+
getScore(password).then(s => setScore(s)).catch(() => null);
|
|
92
92
|
const toValue = (score + 1) / strength.length * 100;
|
|
93
93
|
setWidth(`${toValue}%`);
|
|
94
94
|
}, [getScore, handleChange, password, score, strength]);
|
|
@@ -82,7 +82,7 @@ const Text = _ref2 => {
|
|
|
82
82
|
const elementRef = useRef(null);
|
|
83
83
|
const finalStringChildren = recursivelyGetChildrenString(children);
|
|
84
84
|
useEffect(() => {
|
|
85
|
-
if (oneLine && elementRef
|
|
85
|
+
if (oneLine && elementRef?.current) {
|
|
86
86
|
const {
|
|
87
87
|
offsetWidth,
|
|
88
88
|
scrollWidth
|
|
@@ -149,7 +149,7 @@ const StyledNotice = /*#__PURE__*/_styled(Notice, {
|
|
|
149
149
|
let {
|
|
150
150
|
theme
|
|
151
151
|
} = _ref13;
|
|
152
|
-
return theme.space['
|
|
152
|
+
return theme.space['0.5'];
|
|
153
153
|
}, ";");
|
|
154
154
|
const StyledInput = /*#__PURE__*/_styled('input', {
|
|
155
155
|
shouldForwardProp: prop => !['as', 'error', 'fillAvailable', 'hasLabel', 'isPlaceholderVisible', 'multiline', 'resizable', 'inputSize', 'paddingRightFactor'].includes(prop),
|
package/dist/src/index.js
CHANGED
|
@@ -65,3 +65,4 @@ export { Tooltip } from './components/Tooltip/index.js';
|
|
|
65
65
|
export { VerificationCode } from './components/VerificationCode/index.js';
|
|
66
66
|
export { RadioGroup } from './components/RadioGroup/index.js';
|
|
67
67
|
export { Icon } from '@ultraviolet/icons';
|
|
68
|
+
export { MenuV2 } from './components/MenuV2/index.js';
|
|
@@ -119,6 +119,7 @@ const Popup = /*#__PURE__*/forwardRef((_ref13, tooltipRef) => {
|
|
|
119
119
|
'data-testid': dataTestId,
|
|
120
120
|
hasArrow = true,
|
|
121
121
|
onClose,
|
|
122
|
+
tabIndex = 0,
|
|
122
123
|
onKeyDown,
|
|
123
124
|
'aria-haspopup': ariaHasPopup
|
|
124
125
|
} = _ref13;
|
|
@@ -291,7 +292,7 @@ const Popup = /*#__PURE__*/forwardRef((_ref13, tooltipRef) => {
|
|
|
291
292
|
onPointerEnter: !isControlled ? onPointerEvent(true) : noop,
|
|
292
293
|
onPointerLeave: !isControlled ? onPointerEvent(false) : noop,
|
|
293
294
|
ref: childrenRef,
|
|
294
|
-
tabIndex:
|
|
295
|
+
tabIndex: tabIndex,
|
|
295
296
|
onKeyDown: event => {
|
|
296
297
|
onKeyDown?.(event);
|
|
297
298
|
onLocalKeyDown(event);
|
|
@@ -300,7 +301,7 @@ const Popup = /*#__PURE__*/forwardRef((_ref13, tooltipRef) => {
|
|
|
300
301
|
"aria-haspopup": ariaHasPopup,
|
|
301
302
|
children: children
|
|
302
303
|
});
|
|
303
|
-
}, [ariaHasPopup, children, containerFullWidth, generatedId, isControlled, onKeyDown, onLocalKeyDown, onPointerEvent]);
|
|
304
|
+
}, [ariaHasPopup, children, containerFullWidth, generatedId, isControlled, onKeyDown, onLocalKeyDown, onPointerEvent, tabIndex]);
|
|
304
305
|
if (!text) {
|
|
305
306
|
if (typeof children === 'function') return null;
|
|
306
307
|
return jsx(Fragment, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Ultraviolet UI",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"react-dom": "18.2.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@babel/core": "7.22.
|
|
42
|
+
"@babel/core": "7.22.19",
|
|
43
43
|
"@emotion/babel-plugin": "11.11.0",
|
|
44
44
|
"@emotion/react": "11.11.1",
|
|
45
45
|
"@emotion/styled": "11.11.0",
|
|
@@ -60,14 +60,13 @@
|
|
|
60
60
|
"@scaleway/random-name": "4.0.2",
|
|
61
61
|
"@scaleway/use-media": "2.0.1",
|
|
62
62
|
"deepmerge": "4.3.1",
|
|
63
|
-
"
|
|
64
|
-
"react-datepicker": "4.17.0",
|
|
63
|
+
"react-datepicker": "4.18.0",
|
|
65
64
|
"react-flatten-children": "1.1.2",
|
|
66
65
|
"react-select": "5.7.4",
|
|
67
66
|
"react-toastify": "9.1.3",
|
|
68
67
|
"react-use-clipboard": "1.0.9",
|
|
69
68
|
"reakit": "1.3.11",
|
|
70
69
|
"@ultraviolet/themes": "1.2.1",
|
|
71
|
-
"@ultraviolet/icons": "2.0.
|
|
70
|
+
"@ultraviolet/icons": "2.0.3"
|
|
72
71
|
}
|
|
73
72
|
}
|