@automattic/vip-design-system 0.15.0 → 0.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/build/system/NewDialog/NewDialog.js +14 -2
- package/build/system/NewDialog/NewDialog.stories.js +56 -10
- package/build/system/index.js +8 -3
- package/package.json +1 -1
- package/src/system/NewDialog/NewDialog.js +13 -1
- package/src/system/NewDialog/NewDialog.stories.jsx +38 -9
- package/src/system/index.js +1 -1
|
@@ -51,13 +51,22 @@ var NewDialog = function NewDialog(_ref) {
|
|
|
51
51
|
_ref$defaultOpen = _ref.defaultOpen,
|
|
52
52
|
defaultOpen = _ref$defaultOpen === void 0 ? false : _ref$defaultOpen,
|
|
53
53
|
_ref$allowPinchZoom = _ref.allowPinchZoom,
|
|
54
|
-
allowPinchZoom = _ref$allowPinchZoom === void 0 ? false : _ref$allowPinchZoom
|
|
54
|
+
allowPinchZoom = _ref$allowPinchZoom === void 0 ? false : _ref$allowPinchZoom,
|
|
55
|
+
_ref$onOpenChange = _ref.onOpenChange,
|
|
56
|
+
onOpenChange = _ref$onOpenChange === void 0 ? undefined : _ref$onOpenChange,
|
|
57
|
+
_ref$open = _ref.open,
|
|
58
|
+
open = _ref$open === void 0 ? undefined : _ref$open,
|
|
59
|
+
_ref$id = _ref.id,
|
|
60
|
+
id = _ref$id === void 0 ? undefined : _ref$id;
|
|
55
61
|
|
|
56
62
|
if (disabled) {
|
|
57
63
|
return;
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
return (0, _jsxRuntime.jsxs)(DialogPrimitive.Root, {
|
|
67
|
+
id: id,
|
|
68
|
+
open: open,
|
|
69
|
+
onOpenChange: onOpenChange,
|
|
61
70
|
defaultOpen: defaultOpen,
|
|
62
71
|
allowPinchZoom: allowPinchZoom,
|
|
63
72
|
children: [trigger && (0, _jsxRuntime.jsx)(DialogPrimitive.Trigger, {
|
|
@@ -93,6 +102,9 @@ NewDialog.propTypes = {
|
|
|
93
102
|
style: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].func]),
|
|
94
103
|
// Radix DialogPrimitive.Root properties
|
|
95
104
|
// https://www.radix-ui.com/docs/primitives/components/dialog#root
|
|
105
|
+
id: _propTypes["default"].string,
|
|
106
|
+
open: _propTypes["default"].bool,
|
|
96
107
|
defaultOpen: _propTypes["default"].bool,
|
|
97
|
-
allowPinchZoom: _propTypes["default"].bool
|
|
108
|
+
allowPinchZoom: _propTypes["default"].bool,
|
|
109
|
+
onOpenChange: _propTypes["default"].func
|
|
98
110
|
};
|
|
@@ -3,27 +3,37 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports["default"] = exports.HiddenHeadings = exports.Default = exports.CustomStyling = exports.CustomClose = exports.AutoOpen = void 0;
|
|
6
|
+
exports["default"] = exports.HiddenHeadings = exports.Default = exports.CustomStyling = exports.CustomStateManagement = exports.CustomClose = exports.AutoOpen = void 0;
|
|
7
7
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
|
|
10
12
|
var _system = require("../../system");
|
|
11
13
|
|
|
12
14
|
var _ScreenReaderText = _interopRequireDefault(require("../ScreenReaderText"));
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var NewDialog = _interopRequireWildcard(require("."));
|
|
15
17
|
|
|
16
18
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
19
|
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
18
24
|
/** @jsxImportSource theme-ui */
|
|
19
25
|
|
|
26
|
+
/**
|
|
27
|
+
* External dependencies
|
|
28
|
+
*/
|
|
29
|
+
|
|
20
30
|
/**
|
|
21
31
|
/**
|
|
22
32
|
* Internal dependencies
|
|
23
33
|
*/
|
|
24
34
|
var _default = {
|
|
25
35
|
title: 'NewDialog',
|
|
26
|
-
component:
|
|
36
|
+
component: NewDialog.Root
|
|
27
37
|
};
|
|
28
38
|
exports["default"] = _default;
|
|
29
39
|
var defaultProps = {
|
|
@@ -39,7 +49,7 @@ var Default = function Default() {
|
|
|
39
49
|
mb: 3
|
|
40
50
|
},
|
|
41
51
|
children: "Regular Dialog where the title and description are built-in and the content is provided by the user."
|
|
42
|
-
}), (0, _jsxRuntime.jsx)(
|
|
52
|
+
}), (0, _jsxRuntime.jsx)(NewDialog.Root, (0, _extends2["default"])({}, defaultProps, {
|
|
43
53
|
trigger: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
44
54
|
children: "Trigger Dialog"
|
|
45
55
|
})
|
|
@@ -57,7 +67,7 @@ var AutoOpen = function AutoOpen() {
|
|
|
57
67
|
mb: 3
|
|
58
68
|
},
|
|
59
69
|
children: "Auto Opens when rendered. Press escape to close it."
|
|
60
|
-
}), (0, _jsxRuntime.jsx)(
|
|
70
|
+
}), (0, _jsxRuntime.jsx)(NewDialog.Root, (0, _extends2["default"])({}, defaultProps, {
|
|
61
71
|
defaultOpen: true,
|
|
62
72
|
content: (0, _jsxRuntime.jsxs)("div", {
|
|
63
73
|
children: [(0, _jsxRuntime.jsx)("h3", {
|
|
@@ -83,7 +93,7 @@ var HiddenHeadings = function HiddenHeadings() {
|
|
|
83
93
|
mb: 3
|
|
84
94
|
},
|
|
85
95
|
children: "Title and description are hidden, but still announced using a screen reader. Activate VoiceOver or any similar screen reader to listen to: Custom dialog title, Description of the dialog content."
|
|
86
|
-
}), (0, _jsxRuntime.jsx)(
|
|
96
|
+
}), (0, _jsxRuntime.jsx)(NewDialog.Root, (0, _extends2["default"])({}, defaultProps, {
|
|
87
97
|
trigger: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
88
98
|
children: "Trigger Dialog"
|
|
89
99
|
}),
|
|
@@ -124,7 +134,7 @@ var CustomStyling = function CustomStyling() {
|
|
|
124
134
|
mb: 3
|
|
125
135
|
},
|
|
126
136
|
children: "Custom Styling on Dialog Content"
|
|
127
|
-
}), (0, _jsxRuntime.jsx)(
|
|
137
|
+
}), (0, _jsxRuntime.jsx)(NewDialog.Root, (0, _extends2["default"])({}, defaultProps, {
|
|
128
138
|
defaultOpen: true,
|
|
129
139
|
trigger: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
130
140
|
children: "Trigger Dialog"
|
|
@@ -177,12 +187,12 @@ var CustomClose = function CustomClose() {
|
|
|
177
187
|
mb: 3
|
|
178
188
|
},
|
|
179
189
|
children: "This example shows how you can create a custom Close trigger to your dialog"
|
|
180
|
-
}), (0, _jsxRuntime.jsx)(
|
|
190
|
+
}), (0, _jsxRuntime.jsx)(NewDialog.Root, (0, _extends2["default"])({}, defaultProps, {
|
|
181
191
|
trigger: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
182
192
|
children: "Trigger Dialog"
|
|
183
193
|
}),
|
|
184
194
|
content: (0, _jsxRuntime.jsx)("div", {
|
|
185
|
-
children: (0, _jsxRuntime.jsx)(
|
|
195
|
+
children: (0, _jsxRuntime.jsx)(NewDialog.Close, {
|
|
186
196
|
children: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
187
197
|
children: "Close here instead"
|
|
188
198
|
})
|
|
@@ -192,4 +202,40 @@ var CustomClose = function CustomClose() {
|
|
|
192
202
|
});
|
|
193
203
|
};
|
|
194
204
|
|
|
195
|
-
exports.CustomClose = CustomClose;
|
|
205
|
+
exports.CustomClose = CustomClose;
|
|
206
|
+
|
|
207
|
+
var CustomStateManagement = function CustomStateManagement() {
|
|
208
|
+
var _useState = (0, _react.useState)(false),
|
|
209
|
+
open = _useState[0],
|
|
210
|
+
setOpen = _useState[1];
|
|
211
|
+
|
|
212
|
+
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
213
|
+
children: [(0, _jsxRuntime.jsxs)(_system.Text, {
|
|
214
|
+
sx: {
|
|
215
|
+
fontSize: 3,
|
|
216
|
+
mb: 3
|
|
217
|
+
},
|
|
218
|
+
children: ["This example shows how you can create a custom state management. To achieve accessibility, you need to control the ", (0, _jsxRuntime.jsx)("strong", {
|
|
219
|
+
children: "open"
|
|
220
|
+
}), " state, but also keep consistency using the", ' ', (0, _jsxRuntime.jsx)("strong", {
|
|
221
|
+
children: "onOpenChange"
|
|
222
|
+
}), " attribute."]
|
|
223
|
+
}), (0, _jsxRuntime.jsx)(NewDialog.Root, (0, _extends2["default"])({}, defaultProps, {
|
|
224
|
+
open: open,
|
|
225
|
+
onOpenChange: setOpen,
|
|
226
|
+
trigger: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
227
|
+
children: "Trigger Dialog"
|
|
228
|
+
}),
|
|
229
|
+
content: (0, _jsxRuntime.jsx)("div", {
|
|
230
|
+
children: (0, _jsxRuntime.jsx)(_system.Button, {
|
|
231
|
+
onClick: function onClick() {
|
|
232
|
+
return setOpen(false);
|
|
233
|
+
},
|
|
234
|
+
children: "Close here instead"
|
|
235
|
+
})
|
|
236
|
+
})
|
|
237
|
+
}))]
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
exports.CustomStateManagement = CustomStateManagement;
|
package/build/system/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
+
exports.NewDialog = void 0;
|
|
6
7
|
|
|
7
8
|
var _Avatar = require("./Avatar");
|
|
8
9
|
|
|
@@ -42,9 +43,9 @@ exports.DialogMenuItem = _Dialog.DialogMenuItem;
|
|
|
42
43
|
exports.DialogTrigger = _Dialog.DialogTrigger;
|
|
43
44
|
exports.DialogContent = _Dialog.DialogContent;
|
|
44
45
|
|
|
45
|
-
var
|
|
46
|
+
var NewDialog = _interopRequireWildcard(require("./NewDialog"));
|
|
46
47
|
|
|
47
|
-
exports.NewDialog =
|
|
48
|
+
exports.NewDialog = NewDialog;
|
|
48
49
|
|
|
49
50
|
var _ConfirmationDialog = require("./ConfirmationDialog");
|
|
50
51
|
|
|
@@ -140,4 +141,8 @@ var _Wizard = require("./Wizard");
|
|
|
140
141
|
|
|
141
142
|
exports.Wizard = _Wizard.Wizard;
|
|
142
143
|
exports.WizardStep = _Wizard.WizardStep;
|
|
143
|
-
exports.WizardStepHorizontal = _Wizard.WizardStepHorizontal;
|
|
144
|
+
exports.WizardStepHorizontal = _Wizard.WizardStepHorizontal;
|
|
145
|
+
|
|
146
|
+
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); }
|
|
147
|
+
|
|
148
|
+
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; }
|
package/package.json
CHANGED
|
@@ -26,13 +26,22 @@ export const NewDialog = ( {
|
|
|
26
26
|
// Radix Specific Properties
|
|
27
27
|
defaultOpen = false,
|
|
28
28
|
allowPinchZoom = false,
|
|
29
|
+
onOpenChange = undefined,
|
|
30
|
+
open = undefined,
|
|
31
|
+
id = undefined,
|
|
29
32
|
} ) => {
|
|
30
33
|
if ( disabled ) {
|
|
31
34
|
return;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
return (
|
|
35
|
-
<DialogPrimitive.Root
|
|
38
|
+
<DialogPrimitive.Root
|
|
39
|
+
id={ id }
|
|
40
|
+
open={ open }
|
|
41
|
+
onOpenChange={ onOpenChange }
|
|
42
|
+
defaultOpen={ defaultOpen }
|
|
43
|
+
allowPinchZoom={ allowPinchZoom }
|
|
44
|
+
>
|
|
36
45
|
{ trigger && <DialogPrimitive.Trigger asChild>{ trigger }</DialogPrimitive.Trigger> }
|
|
37
46
|
|
|
38
47
|
<DialogPrimitive.Portal>
|
|
@@ -64,6 +73,9 @@ NewDialog.propTypes = {
|
|
|
64
73
|
|
|
65
74
|
// Radix DialogPrimitive.Root properties
|
|
66
75
|
// https://www.radix-ui.com/docs/primitives/components/dialog#root
|
|
76
|
+
id: PropTypes.string,
|
|
77
|
+
open: PropTypes.bool,
|
|
67
78
|
defaultOpen: PropTypes.bool,
|
|
68
79
|
allowPinchZoom: PropTypes.bool,
|
|
80
|
+
onOpenChange: PropTypes.func,
|
|
69
81
|
};
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
/** @jsxImportSource theme-ui */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
|
|
3
8
|
/**
|
|
4
9
|
/**
|
|
5
10
|
* Internal dependencies
|
|
6
11
|
*/
|
|
7
12
|
import { Button, Text, Input, Label } from '../../system';
|
|
8
13
|
import ScreenReaderText from '../ScreenReaderText';
|
|
9
|
-
import
|
|
14
|
+
import * as NewDialog from '.';
|
|
10
15
|
|
|
11
16
|
export default {
|
|
12
17
|
title: 'NewDialog',
|
|
13
|
-
component: NewDialog,
|
|
18
|
+
component: NewDialog.Root,
|
|
14
19
|
};
|
|
15
20
|
|
|
16
21
|
const defaultProps = {
|
|
@@ -24,14 +29,14 @@ export const Default = () => (
|
|
|
24
29
|
Regular Dialog where the title and description are built-in and the content is provided by the
|
|
25
30
|
user.
|
|
26
31
|
</Text>
|
|
27
|
-
<NewDialog { ...defaultProps } trigger={ <Button>Trigger Dialog</Button> } />
|
|
32
|
+
<NewDialog.Root { ...defaultProps } trigger={ <Button>Trigger Dialog</Button> } />
|
|
28
33
|
</>
|
|
29
34
|
);
|
|
30
35
|
|
|
31
36
|
export const AutoOpen = () => (
|
|
32
37
|
<>
|
|
33
38
|
<Text sx={ { fontSize: 3, mb: 3 } }>Auto Opens when rendered. Press escape to close it.</Text>
|
|
34
|
-
<NewDialog
|
|
39
|
+
<NewDialog.Root
|
|
35
40
|
{ ...defaultProps }
|
|
36
41
|
defaultOpen={ true }
|
|
37
42
|
content={
|
|
@@ -61,7 +66,7 @@ export const HiddenHeadings = () => (
|
|
|
61
66
|
dialog content.
|
|
62
67
|
</Text>
|
|
63
68
|
|
|
64
|
-
<NewDialog
|
|
69
|
+
<NewDialog.Root
|
|
65
70
|
{ ...defaultProps }
|
|
66
71
|
trigger={ <Button>Trigger Dialog</Button> }
|
|
67
72
|
title="Custom dialog title"
|
|
@@ -88,7 +93,7 @@ export const CustomStyling = () => (
|
|
|
88
93
|
<>
|
|
89
94
|
<Text sx={ { fontSize: 3, mb: 3 } }>Custom Styling on Dialog Content</Text>
|
|
90
95
|
|
|
91
|
-
<NewDialog
|
|
96
|
+
<NewDialog.Root
|
|
92
97
|
{ ...defaultProps }
|
|
93
98
|
defaultOpen
|
|
94
99
|
trigger={ <Button>Trigger Dialog</Button> }
|
|
@@ -118,16 +123,40 @@ export const CustomClose = () => (
|
|
|
118
123
|
<Text sx={ { fontSize: 3, mb: 3 } }>
|
|
119
124
|
This example shows how you can create a custom Close trigger to your dialog
|
|
120
125
|
</Text>
|
|
121
|
-
<NewDialog
|
|
126
|
+
<NewDialog.Root
|
|
122
127
|
{ ...defaultProps }
|
|
123
128
|
trigger={ <Button>Trigger Dialog</Button> }
|
|
124
129
|
content={
|
|
125
130
|
<div>
|
|
126
|
-
<Close>
|
|
131
|
+
<NewDialog.Close>
|
|
127
132
|
<Button>Close here instead</Button>
|
|
128
|
-
</Close>
|
|
133
|
+
</NewDialog.Close>
|
|
129
134
|
</div>
|
|
130
135
|
}
|
|
131
136
|
/>
|
|
132
137
|
</>
|
|
133
138
|
);
|
|
139
|
+
export const CustomStateManagement = () => {
|
|
140
|
+
const [ open, setOpen ] = useState( false );
|
|
141
|
+
return (
|
|
142
|
+
<>
|
|
143
|
+
<Text sx={ { fontSize: 3, mb: 3 } }>
|
|
144
|
+
This example shows how you can create a custom state management. To achieve accessibility,
|
|
145
|
+
you need to control the <strong>open</strong> state, but also keep consistency using the{ ' ' }
|
|
146
|
+
<strong>onOpenChange</strong> attribute.
|
|
147
|
+
</Text>
|
|
148
|
+
|
|
149
|
+
<NewDialog.Root
|
|
150
|
+
{ ...defaultProps }
|
|
151
|
+
open={ open }
|
|
152
|
+
onOpenChange={ setOpen }
|
|
153
|
+
trigger={ <Button>Trigger Dialog</Button> }
|
|
154
|
+
content={
|
|
155
|
+
<div>
|
|
156
|
+
<Button onClick={ () => setOpen( false ) }>Close here instead</Button>
|
|
157
|
+
</div>
|
|
158
|
+
}
|
|
159
|
+
/>
|
|
160
|
+
</>
|
|
161
|
+
);
|
|
162
|
+
};
|
package/src/system/index.js
CHANGED