@automattic/vip-design-system 0.18.3-0 → 0.19.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/build/system/Dropdown/Dropdown.stories.js +3 -6
- package/build/system/NewConfirmationDialog/NewConfirmationDialog.js +19 -26
- package/build/system/NewDialog/NewDialog.js +17 -51
- package/build/system/NewDialog/NewDialog.stories.js +1 -1
- package/build/system/Tooltip/Tooltip.js +15 -4
- package/build/system/Tooltip/Tooltip.stories.js +2 -1
- package/package.json +1 -1
- package/src/system/Dropdown/Dropdown.stories.jsx +2 -6
- package/src/system/NewConfirmationDialog/NewConfirmationDialog.js +5 -6
- package/src/system/NewDialog/NewDialog.js +7 -37
- package/src/system/NewDialog/NewDialog.stories.jsx +1 -1
- package/src/system/Tooltip/Tooltip.js +5 -4
- package/src/system/Tooltip/Tooltip.stories.jsx +1 -1
|
@@ -153,17 +153,13 @@ var WithDialog = function WithDialog() {
|
|
|
153
153
|
|
|
154
154
|
var _React$useState5 = _react["default"].useState(false),
|
|
155
155
|
menuOpen = _React$useState5[0],
|
|
156
|
-
setMenuOpen = _React$useState5[1];
|
|
156
|
+
setMenuOpen = _React$useState5[1]; // eslint-disable-next-line react/prop-types
|
|
157
|
+
|
|
157
158
|
|
|
158
159
|
var AreYouSureDialog = function AreYouSureDialog(_ref) {
|
|
159
160
|
var onConfirm = _ref.onConfirm,
|
|
160
161
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
161
162
|
return (0, _jsxRuntime.jsx)(NewDialog.Root, (0, _extends2["default"])({}, props, {
|
|
162
|
-
contentProps: {
|
|
163
|
-
onCloseAutoFocus: function onCloseAutoFocus() {
|
|
164
|
-
onConfirm();
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
163
|
content: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
168
164
|
children: [(0, _jsxRuntime.jsx)(_Button.Button, {
|
|
169
165
|
variant: "secondary",
|
|
@@ -182,6 +178,7 @@ var WithDialog = function WithDialog() {
|
|
|
182
178
|
children: [(0, _jsxRuntime.jsx)("p", {
|
|
183
179
|
children: "This is an important example when combining the Dropdown component with the NewDialog component. In order to have the correct accessibility, there are some events you need to use. Use this example if you want to copy and paste the code."
|
|
184
180
|
}), (0, _jsxRuntime.jsxs)(Dropdown.Root, {
|
|
181
|
+
modal: !alertOpen,
|
|
185
182
|
open: menuOpen,
|
|
186
183
|
onOpenChange: setMenuOpen,
|
|
187
184
|
contentProps: {
|
|
@@ -5,6 +5,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
6
|
exports.NewConfirmationDialog = void 0;
|
|
7
7
|
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
+
|
|
8
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
13
|
|
|
10
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -15,15 +19,8 @@ var _ = require("..");
|
|
|
15
19
|
|
|
16
20
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
var _excluded = ["trigger", "onConfirm", "needsConfirm", "label", "buttonVariant", "title", "body"];
|
|
19
23
|
|
|
20
|
-
/**
|
|
21
|
-
* External dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Internal dependencies
|
|
26
|
-
*/
|
|
27
24
|
var NewConfirmationDialogContent = function NewConfirmationDialogContent(_ref) {
|
|
28
25
|
var _ref$label = _ref.label,
|
|
29
26
|
label = _ref$label === void 0 ? 'Confirm' : _ref$label,
|
|
@@ -79,11 +76,8 @@ var NewConfirmationDialog = function NewConfirmationDialog(_ref2) {
|
|
|
79
76
|
buttonVariant = _ref2.buttonVariant,
|
|
80
77
|
title = _ref2.title,
|
|
81
78
|
_ref2$body = _ref2.body,
|
|
82
|
-
body = _ref2$body === void 0 ? '' : _ref2$body
|
|
83
|
-
|
|
84
|
-
var _React$useState = _react["default"].useState(false),
|
|
85
|
-
open = _React$useState[0],
|
|
86
|
-
setOpen = _React$useState[1];
|
|
79
|
+
body = _ref2$body === void 0 ? '' : _ref2$body,
|
|
80
|
+
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, _excluded);
|
|
87
81
|
|
|
88
82
|
var directTrigger = /*#__PURE__*/_react["default"].cloneElement(trigger, {
|
|
89
83
|
onClick: onConfirm
|
|
@@ -93,25 +87,24 @@ var NewConfirmationDialog = function NewConfirmationDialog(_ref2) {
|
|
|
93
87
|
return directTrigger;
|
|
94
88
|
}
|
|
95
89
|
|
|
96
|
-
return (0, _jsxRuntime.jsx)(_.NewDialog.Root, {
|
|
97
|
-
open: open,
|
|
98
|
-
onOpenChange: setOpen,
|
|
90
|
+
return (0, _jsxRuntime.jsx)(_.NewDialog.Root, (0, _extends2["default"])({
|
|
99
91
|
sx: {
|
|
100
92
|
maxWidth: 680
|
|
101
93
|
},
|
|
102
94
|
title: title,
|
|
103
95
|
description: body,
|
|
104
|
-
content: (
|
|
105
|
-
onClose
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
96
|
+
content: function content(_ref3) {
|
|
97
|
+
var onClose = _ref3.onClose;
|
|
98
|
+
return (0, _jsxRuntime.jsx)(NewConfirmationDialogContent, {
|
|
99
|
+
onClose: onClose,
|
|
100
|
+
onConfirm: onConfirm,
|
|
101
|
+
body: body,
|
|
102
|
+
label: label,
|
|
103
|
+
buttonVariant: buttonVariant
|
|
104
|
+
});
|
|
105
|
+
},
|
|
113
106
|
trigger: trigger
|
|
114
|
-
});
|
|
107
|
+
}, props));
|
|
115
108
|
};
|
|
116
109
|
|
|
117
110
|
exports.NewConfirmationDialog = NewConfirmationDialog;
|
|
@@ -7,6 +7,8 @@ exports.NewDialog = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
|
|
10
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
+
|
|
10
12
|
var _react = _interopRequireDefault(require("react"));
|
|
11
13
|
|
|
12
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -25,19 +27,12 @@ var _DialogContent = require("./DialogContent");
|
|
|
25
27
|
|
|
26
28
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
27
29
|
|
|
30
|
+
var _excluded = ["trigger", "description", "title", "content", "showHeading", "disabled", "style", "contentProps", "portalProps"];
|
|
31
|
+
|
|
28
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
33
|
|
|
30
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
35
|
|
|
32
|
-
/** @jsxImportSource theme-ui */
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* External dependencies
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Internal dependencies
|
|
40
|
-
*/
|
|
41
36
|
var NewDialog = function NewDialog(_ref) {
|
|
42
37
|
var _ref$trigger = _ref.trigger,
|
|
43
38
|
trigger = _ref$trigger === void 0 ? null : _ref$trigger,
|
|
@@ -54,20 +49,9 @@ var NewDialog = function NewDialog(_ref) {
|
|
|
54
49
|
contentProps = _ref$contentProps === void 0 ? {} : _ref$contentProps,
|
|
55
50
|
_ref$portalProps = _ref.portalProps,
|
|
56
51
|
portalProps = _ref$portalProps === void 0 ? {} : _ref$portalProps,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
allowPinchZoom = _ref$allowPinchZoom === void 0 ? false : _ref$allowPinchZoom,
|
|
61
|
-
_ref$onOpenChange = _ref.onOpenChange,
|
|
62
|
-
onOpenChange = _ref$onOpenChange === void 0 ? undefined : _ref$onOpenChange,
|
|
63
|
-
_ref$open = _ref.open,
|
|
64
|
-
open = _ref$open === void 0 ? undefined : _ref$open,
|
|
65
|
-
_ref$id = _ref.id,
|
|
66
|
-
id = _ref$id === void 0 ? undefined : _ref$id;
|
|
67
|
-
|
|
68
|
-
var _React$useState = _react["default"].useState(open || defaultOpen),
|
|
69
|
-
isOpen = _React$useState[0],
|
|
70
|
-
setIsOpen = _React$useState[1];
|
|
52
|
+
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
53
|
+
|
|
54
|
+
var closeRef = _react["default"].useRef(null);
|
|
71
55
|
|
|
72
56
|
if (disabled) {
|
|
73
57
|
return;
|
|
@@ -76,24 +60,13 @@ var NewDialog = function NewDialog(_ref) {
|
|
|
76
60
|
|
|
77
61
|
var isContentFunction = typeof content === 'function';
|
|
78
62
|
|
|
79
|
-
var
|
|
80
|
-
|
|
63
|
+
var onClose = function onClose() {
|
|
64
|
+
var _closeRef$current;
|
|
81
65
|
|
|
82
|
-
|
|
83
|
-
onOpenChange(status);
|
|
84
|
-
}
|
|
66
|
+
closeRef == null ? void 0 : (_closeRef$current = closeRef.current) == null ? void 0 : _closeRef$current.click();
|
|
85
67
|
};
|
|
86
68
|
|
|
87
|
-
|
|
88
|
-
handleOnOpenChange(open);
|
|
89
|
-
}, [open]);
|
|
90
|
-
|
|
91
|
-
return (0, _jsxRuntime.jsxs)(DialogPrimitive.Root, {
|
|
92
|
-
id: id,
|
|
93
|
-
open: isOpen,
|
|
94
|
-
onOpenChange: handleOnOpenChange,
|
|
95
|
-
defaultOpen: defaultOpen,
|
|
96
|
-
allowPinchZoom: allowPinchZoom,
|
|
69
|
+
return (0, _jsxRuntime.jsxs)(DialogPrimitive.Root, (0, _extends2["default"])({}, props, {
|
|
97
70
|
children: [trigger && (0, _jsxRuntime.jsx)(DialogPrimitive.Trigger, {
|
|
98
71
|
asChild: true,
|
|
99
72
|
children: trigger
|
|
@@ -102,7 +75,9 @@ var NewDialog = function NewDialog(_ref) {
|
|
|
102
75
|
className: "vip-dialog-component",
|
|
103
76
|
sx: (0, _extends2["default"])({}, _DialogContent.contentStyles, extraStyles)
|
|
104
77
|
}, contentProps, {
|
|
105
|
-
children: [(0, _jsxRuntime.jsx)(_DialogClose.DialogCloseDefault, {
|
|
78
|
+
children: [(0, _jsxRuntime.jsx)(_DialogClose.DialogCloseDefault, {
|
|
79
|
+
ref: closeRef
|
|
80
|
+
}), (0, _jsxRuntime.jsx)(_DialogTitle.DialogTitle, {
|
|
106
81
|
title: title,
|
|
107
82
|
hidden: !showHeading
|
|
108
83
|
}), (0, _jsxRuntime.jsx)(_DialogDescription.DialogDescription, {
|
|
@@ -111,14 +86,12 @@ var NewDialog = function NewDialog(_ref) {
|
|
|
111
86
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
112
87
|
role: "document",
|
|
113
88
|
children: isContentFunction ? content({
|
|
114
|
-
onClose:
|
|
115
|
-
return setIsOpen(false);
|
|
116
|
-
}
|
|
89
|
+
onClose: onClose
|
|
117
90
|
}) : content
|
|
118
91
|
})]
|
|
119
92
|
}))]
|
|
120
93
|
}))]
|
|
121
|
-
});
|
|
94
|
+
}));
|
|
122
95
|
};
|
|
123
96
|
|
|
124
97
|
exports.NewDialog = NewDialog;
|
|
@@ -133,12 +106,5 @@ NewDialog.propTypes = {
|
|
|
133
106
|
// Content props in: https://www.radix-ui.com/docs/primitives/components/dialog#content
|
|
134
107
|
contentProps: _propTypes["default"].any,
|
|
135
108
|
// Portal props in: https://www.radix-ui.com/docs/primitives/components/dialog#portal
|
|
136
|
-
portalProps: _propTypes["default"].any
|
|
137
|
-
// Radix DialogPrimitive.Root properties
|
|
138
|
-
// https://www.radix-ui.com/docs/primitives/components/dialog#root
|
|
139
|
-
id: _propTypes["default"].string,
|
|
140
|
-
open: _propTypes["default"].bool,
|
|
141
|
-
defaultOpen: _propTypes["default"].bool,
|
|
142
|
-
allowPinchZoom: _propTypes["default"].bool,
|
|
143
|
-
onOpenChange: _propTypes["default"].func
|
|
109
|
+
portalProps: _propTypes["default"].any
|
|
144
110
|
};
|
|
@@ -225,7 +225,7 @@ var CustomStateManagement = function CustomStateManagement() {
|
|
|
225
225
|
onOpenChange: function onOpenChange(status) {
|
|
226
226
|
// eslint-disable-next-line no-console
|
|
227
227
|
console.log('New status changed', status);
|
|
228
|
-
setOpen(
|
|
228
|
+
setOpen(!open);
|
|
229
229
|
},
|
|
230
230
|
trigger: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
231
231
|
children: "Trigger Dialog"
|
|
@@ -35,7 +35,11 @@ var StyledArrow = function StyledArrow(props) {
|
|
|
35
35
|
|
|
36
36
|
var Tooltip = function Tooltip(_ref) {
|
|
37
37
|
var _ref$trigger = _ref.trigger,
|
|
38
|
-
trigger = _ref$trigger === void 0 ? (0, _jsxRuntime.jsx)(_md.MdHelp, {
|
|
38
|
+
trigger = _ref$trigger === void 0 ? (0, _jsxRuntime.jsx)(_md.MdHelp, {
|
|
39
|
+
sx: {
|
|
40
|
+
fill: 'text'
|
|
41
|
+
}
|
|
42
|
+
}) : _ref$trigger,
|
|
39
43
|
_ref$text = _ref.text,
|
|
40
44
|
text = _ref$text === void 0 ? '' : _ref$text,
|
|
41
45
|
_ref$width = _ref.width,
|
|
@@ -67,7 +71,12 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
67
71
|
background: 'transparent',
|
|
68
72
|
border: 'none',
|
|
69
73
|
display: 'inline-flex',
|
|
70
|
-
|
|
74
|
+
'&:focus': function focus(theme) {
|
|
75
|
+
return theme.outline;
|
|
76
|
+
},
|
|
77
|
+
'&:focus-visible': function focusVisible(theme) {
|
|
78
|
+
return theme.outline;
|
|
79
|
+
},
|
|
71
80
|
p: 0,
|
|
72
81
|
m: 0
|
|
73
82
|
},
|
|
@@ -75,12 +84,14 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
75
84
|
children: [(0, _jsxRuntime.jsx)(_.Card, (0, _extends2["default"])({
|
|
76
85
|
className: "tooltip-content",
|
|
77
86
|
sx: {
|
|
78
|
-
width: width
|
|
87
|
+
width: width,
|
|
88
|
+
background: 'dialog'
|
|
79
89
|
}
|
|
80
90
|
}, props, {
|
|
81
91
|
children: children ? children : (0, _jsxRuntime.jsx)(_.Text, {
|
|
82
92
|
sx: {
|
|
83
|
-
fontSize:
|
|
93
|
+
fontSize: 2,
|
|
94
|
+
color: 'text'
|
|
84
95
|
},
|
|
85
96
|
children: text
|
|
86
97
|
})
|
|
@@ -30,7 +30,8 @@ var Default = function Default() {
|
|
|
30
30
|
}), (0, _jsxRuntime.jsx)(_.Tooltip, {
|
|
31
31
|
children: (0, _jsxRuntime.jsxs)(_.Text, {
|
|
32
32
|
sx: {
|
|
33
|
-
fontSize: 1
|
|
33
|
+
fontSize: 1,
|
|
34
|
+
color: 'text'
|
|
34
35
|
},
|
|
35
36
|
children: ["This is a tooltip that can be used to describe various pieces of functionality.", (0, _jsxRuntime.jsx)("br", {}), (0, _jsxRuntime.jsx)(_.Link, {
|
|
36
37
|
children: "Find out more \u2192"
|
package/package.json
CHANGED
|
@@ -117,20 +117,15 @@ export const WithDialog = () => {
|
|
|
117
117
|
const [ alertOpen, setAlertOpen ] = React.useState( false );
|
|
118
118
|
const [ menuOpen, setMenuOpen ] = React.useState( false );
|
|
119
119
|
|
|
120
|
+
// eslint-disable-next-line react/prop-types
|
|
120
121
|
const AreYouSureDialog = ( { onConfirm, ...props } ) => (
|
|
121
122
|
<NewDialog.Root
|
|
122
123
|
{ ...props }
|
|
123
|
-
contentProps={ {
|
|
124
|
-
onCloseAutoFocus: () => {
|
|
125
|
-
onConfirm();
|
|
126
|
-
},
|
|
127
|
-
} }
|
|
128
124
|
content={
|
|
129
125
|
<>
|
|
130
126
|
<Button variant="secondary" onClick={ () => onConfirm() }>
|
|
131
127
|
Custom Close.
|
|
132
128
|
</Button>
|
|
133
|
-
|
|
134
129
|
<p>Teste abc.</p>
|
|
135
130
|
</>
|
|
136
131
|
}
|
|
@@ -146,6 +141,7 @@ export const WithDialog = () => {
|
|
|
146
141
|
</p>
|
|
147
142
|
|
|
148
143
|
<Dropdown.Root
|
|
144
|
+
modal={ ! alertOpen }
|
|
149
145
|
open={ menuOpen }
|
|
150
146
|
onOpenChange={ setMenuOpen }
|
|
151
147
|
contentProps={ { sideOffset: 5 } }
|
|
@@ -56,8 +56,8 @@ const NewConfirmationDialog = ( {
|
|
|
56
56
|
buttonVariant,
|
|
57
57
|
title,
|
|
58
58
|
body = '',
|
|
59
|
+
...props
|
|
59
60
|
} ) => {
|
|
60
|
-
const [ open, setOpen ] = React.useState( false );
|
|
61
61
|
const directTrigger = React.cloneElement( trigger, { onClick: onConfirm } );
|
|
62
62
|
|
|
63
63
|
if ( ! needsConfirm ) {
|
|
@@ -66,21 +66,20 @@ const NewConfirmationDialog = ( {
|
|
|
66
66
|
|
|
67
67
|
return (
|
|
68
68
|
<NewDialog.Root
|
|
69
|
-
open={ open }
|
|
70
|
-
onOpenChange={ setOpen }
|
|
71
69
|
sx={ { maxWidth: 680 } }
|
|
72
70
|
title={ title }
|
|
73
71
|
description={ body }
|
|
74
|
-
content={
|
|
72
|
+
content={ ( { onClose } ) => (
|
|
75
73
|
<NewConfirmationDialogContent
|
|
76
|
-
onClose={
|
|
74
|
+
onClose={ onClose }
|
|
77
75
|
onConfirm={ onConfirm }
|
|
78
76
|
body={ body }
|
|
79
77
|
label={ label }
|
|
80
78
|
buttonVariant={ buttonVariant }
|
|
81
79
|
/>
|
|
82
|
-
}
|
|
80
|
+
) }
|
|
83
81
|
trigger={ trigger }
|
|
82
|
+
{ ...props }
|
|
84
83
|
/>
|
|
85
84
|
);
|
|
86
85
|
};
|
|
@@ -25,15 +25,9 @@ export const NewDialog = ( {
|
|
|
25
25
|
style: extraStyles,
|
|
26
26
|
contentProps = {},
|
|
27
27
|
portalProps = {},
|
|
28
|
-
|
|
29
|
-
// Radix Specific Properties
|
|
30
|
-
defaultOpen = false,
|
|
31
|
-
allowPinchZoom = false,
|
|
32
|
-
onOpenChange = undefined,
|
|
33
|
-
open = undefined,
|
|
34
|
-
id = undefined,
|
|
28
|
+
...props
|
|
35
29
|
} ) => {
|
|
36
|
-
const
|
|
30
|
+
const closeRef = React.useRef( null );
|
|
37
31
|
|
|
38
32
|
if ( disabled ) {
|
|
39
33
|
return;
|
|
@@ -42,26 +36,12 @@ export const NewDialog = ( {
|
|
|
42
36
|
// if content is a function, pass in onClose
|
|
43
37
|
const isContentFunction = typeof content === 'function';
|
|
44
38
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if ( onOpenChange ) {
|
|
49
|
-
onOpenChange( status );
|
|
50
|
-
}
|
|
39
|
+
const onClose = () => {
|
|
40
|
+
closeRef?.current?.click();
|
|
51
41
|
};
|
|
52
42
|
|
|
53
|
-
React.useEffect( () => {
|
|
54
|
-
handleOnOpenChange( open );
|
|
55
|
-
}, [ open ] );
|
|
56
|
-
|
|
57
43
|
return (
|
|
58
|
-
<DialogPrimitive.Root
|
|
59
|
-
id={ id }
|
|
60
|
-
open={ isOpen }
|
|
61
|
-
onOpenChange={ handleOnOpenChange }
|
|
62
|
-
defaultOpen={ defaultOpen }
|
|
63
|
-
allowPinchZoom={ allowPinchZoom }
|
|
64
|
-
>
|
|
44
|
+
<DialogPrimitive.Root { ...props }>
|
|
65
45
|
{ trigger && <DialogPrimitive.Trigger asChild>{ trigger }</DialogPrimitive.Trigger> }
|
|
66
46
|
|
|
67
47
|
<DialogPrimitive.Portal { ...portalProps }>
|
|
@@ -72,13 +52,11 @@ export const NewDialog = ( {
|
|
|
72
52
|
sx={ { ...contentStyles, ...extraStyles } }
|
|
73
53
|
{ ...contentProps }
|
|
74
54
|
>
|
|
75
|
-
<DialogClose />
|
|
55
|
+
<DialogClose ref={ closeRef } />
|
|
76
56
|
<DialogTitle title={ title } hidden={ ! showHeading } />
|
|
77
57
|
<DialogDescription description={ description } hidden={ ! showHeading } />
|
|
78
58
|
|
|
79
|
-
<div role="document">
|
|
80
|
-
{ isContentFunction ? content( { onClose: () => setIsOpen( false ) } ) : content }
|
|
81
|
-
</div>
|
|
59
|
+
<div role="document">{ isContentFunction ? content( { onClose } ) : content }</div>
|
|
82
60
|
</DialogPrimitive.Content>
|
|
83
61
|
</DialogPrimitive.Portal>
|
|
84
62
|
</DialogPrimitive.Root>
|
|
@@ -99,12 +77,4 @@ NewDialog.propTypes = {
|
|
|
99
77
|
|
|
100
78
|
// Portal props in: https://www.radix-ui.com/docs/primitives/components/dialog#portal
|
|
101
79
|
portalProps: PropTypes.any,
|
|
102
|
-
|
|
103
|
-
// Radix DialogPrimitive.Root properties
|
|
104
|
-
// https://www.radix-ui.com/docs/primitives/components/dialog#root
|
|
105
|
-
id: PropTypes.string,
|
|
106
|
-
open: PropTypes.bool,
|
|
107
|
-
defaultOpen: PropTypes.bool,
|
|
108
|
-
allowPinchZoom: PropTypes.bool,
|
|
109
|
-
onOpenChange: PropTypes.func,
|
|
110
80
|
};
|
|
@@ -155,7 +155,7 @@ export const CustomStateManagement = () => {
|
|
|
155
155
|
// eslint-disable-next-line no-console
|
|
156
156
|
console.log( 'New status changed', status );
|
|
157
157
|
|
|
158
|
-
setOpen(
|
|
158
|
+
setOpen( ! open );
|
|
159
159
|
} }
|
|
160
160
|
trigger={ <Button>Trigger Dialog</Button> }
|
|
161
161
|
content={
|
|
@@ -15,7 +15,7 @@ import { Card, Text } from '..';
|
|
|
15
15
|
const StyledArrow = props => <TooltipPrimitive.Arrow sx={ { fill: 'white' } } { ...props } />;
|
|
16
16
|
|
|
17
17
|
const Tooltip = ( {
|
|
18
|
-
trigger = <MdHelp />,
|
|
18
|
+
trigger = <MdHelp sx={ { fill: 'text' } } />,
|
|
19
19
|
text = '',
|
|
20
20
|
width = 200,
|
|
21
21
|
children,
|
|
@@ -48,7 +48,8 @@ const Tooltip = ( {
|
|
|
48
48
|
background: 'transparent',
|
|
49
49
|
border: 'none',
|
|
50
50
|
display: 'inline-flex',
|
|
51
|
-
|
|
51
|
+
'&:focus': theme => theme.outline,
|
|
52
|
+
'&:focus-visible': theme => theme.outline,
|
|
52
53
|
p: 0,
|
|
53
54
|
m: 0,
|
|
54
55
|
} }
|
|
@@ -56,8 +57,8 @@ const Tooltip = ( {
|
|
|
56
57
|
{ trigger }
|
|
57
58
|
|
|
58
59
|
<TooltipPrimitive.Content>
|
|
59
|
-
<Card className="tooltip-content" sx={ { width:
|
|
60
|
-
{ children ? children : <Text sx={ { fontSize:
|
|
60
|
+
<Card className="tooltip-content" sx={ { width, background: 'dialog' } } { ...props }>
|
|
61
|
+
{ children ? children : <Text sx={ { fontSize: 2, color: 'text' } }>{ text }</Text> }
|
|
61
62
|
</Card>
|
|
62
63
|
<StyledArrow />
|
|
63
64
|
</TooltipPrimitive.Content>
|
|
@@ -12,7 +12,7 @@ export const Default = () => (
|
|
|
12
12
|
<Flex sx={ { alignItems: 'center' } }>
|
|
13
13
|
<Heading sx={ { mb: 0, mr: 2 } }>My Section Heading</Heading>
|
|
14
14
|
<Tooltip>
|
|
15
|
-
<Text sx={ { fontSize: 1 } }>
|
|
15
|
+
<Text sx={ { fontSize: 1, color: 'text' } }>
|
|
16
16
|
This is a tooltip that can be used to describe various pieces of functionality.
|
|
17
17
|
<br />
|
|
18
18
|
<Link>Find out more →</Link>
|