@automattic/vip-design-system 0.25.0 → 0.26.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/NewForm/FormAutocomplete.css +166 -0
- package/build/system/NewForm/FormAutocomplete.js +23 -24
- package/build/system/NewForm/FormAutocomplete.stories.js +12 -40
- package/build/system/NewTabs/Tabs.js +61 -0
- package/build/system/NewTabs/Tabs.stories.js +55 -0
- package/build/system/NewTabs/TabsContent.js +50 -0
- package/build/system/NewTabs/TabsList.js +49 -0
- package/build/system/NewTabs/TabsTrigger.js +83 -0
- package/build/system/NewTabs/index.js +19 -0
- package/build/system/ResourceList/ResourceList.js +26 -35
- package/build/system/ResourceList/ResourceList.stories.js +0 -2
- package/build/system/index.js +7 -0
- package/package.json +3 -2
- package/src/system/NewForm/FormAutocomplete.js +16 -12
- package/src/system/NewForm/FormAutocomplete.stories.jsx +13 -39
- package/src/system/NewTabs/Tabs.js +44 -0
- package/src/system/NewTabs/Tabs.stories.jsx +29 -0
- package/src/system/NewTabs/TabsContent.js +33 -0
- package/src/system/NewTabs/TabsList.js +33 -0
- package/src/system/NewTabs/TabsTrigger.js +57 -0
- package/src/system/NewTabs/index.js +9 -0
- package/src/system/index.js +5 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
.autocomplete__wrapper {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.autocomplete__hint,
|
|
6
|
+
.autocomplete__input {
|
|
7
|
+
-webkit-appearance: none;
|
|
8
|
+
border: 2px solid #0b0c0c;
|
|
9
|
+
border-radius: 0; /* Safari 10 on iOS adds implicit border rounding. */
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
-moz-box-sizing: border-box;
|
|
12
|
+
-webkit-box-sizing: border-box;
|
|
13
|
+
margin-bottom: 0; /* BUG: Safari 10 on macOS seems to add an implicit margin. */
|
|
14
|
+
width: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.autocomplete__input {
|
|
18
|
+
background-color: transparent;
|
|
19
|
+
position: relative;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.autocomplete__hint {
|
|
23
|
+
color: #b1b4b6;
|
|
24
|
+
position: absolute;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.autocomplete__input--default {
|
|
28
|
+
padding: 5px;
|
|
29
|
+
}
|
|
30
|
+
.autocomplete__input--focused {
|
|
31
|
+
outline: 3px solid #fd0;
|
|
32
|
+
outline-offset: 0;
|
|
33
|
+
box-shadow: inset 0 0 0 2px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.autocomplete__input--show-all-values {
|
|
37
|
+
padding: 5px 34px 5px 5px; /* Space for arrow. Other padding should match .autocomplete__input--default. */
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.autocomplete__dropdown-arrow-down {
|
|
42
|
+
z-index: -1;
|
|
43
|
+
display: inline-block;
|
|
44
|
+
position: absolute;
|
|
45
|
+
right: 8px;
|
|
46
|
+
width: 24px;
|
|
47
|
+
height: 24px;
|
|
48
|
+
top: 10px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.autocomplete__menu {
|
|
52
|
+
background-color: #fff;
|
|
53
|
+
border: 2px solid #0B0C0C;
|
|
54
|
+
border-top: 0;
|
|
55
|
+
color: #0B0C0C;
|
|
56
|
+
margin: 0;
|
|
57
|
+
max-height: 342px;
|
|
58
|
+
overflow-x: hidden;
|
|
59
|
+
padding: 0;
|
|
60
|
+
width: 100%;
|
|
61
|
+
width: calc(100% - 4px);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.autocomplete__menu--visible {
|
|
65
|
+
display: block;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.autocomplete__menu--hidden {
|
|
69
|
+
display: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.autocomplete__menu--overlay {
|
|
73
|
+
box-shadow: rgba(0, 0, 0, 0.256863) 0px 2px 6px;
|
|
74
|
+
left: 0;
|
|
75
|
+
position: absolute;
|
|
76
|
+
top: 100%;
|
|
77
|
+
z-index: 100;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.autocomplete__menu--inline {
|
|
81
|
+
position: relative;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.autocomplete__option {
|
|
85
|
+
border-bottom: solid #b1b4b6;
|
|
86
|
+
border-width: 1px 0;
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
display: block;
|
|
89
|
+
position: relative;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.autocomplete__option > * {
|
|
93
|
+
pointer-events: none;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.autocomplete__option:first-of-type {
|
|
97
|
+
border-top-width: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.autocomplete__option:last-of-type {
|
|
101
|
+
border-bottom-width: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.autocomplete__option--odd {
|
|
105
|
+
background-color: #FAFAFA;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.autocomplete__option--focused,
|
|
109
|
+
.autocomplete__option:hover {
|
|
110
|
+
background-color: #1d70b8;
|
|
111
|
+
border-color: #1d70b8;
|
|
112
|
+
color: white;
|
|
113
|
+
outline: none;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@media (-ms-high-contrast: active), (forced-colors: active) {
|
|
117
|
+
.autocomplete__menu {
|
|
118
|
+
border-color: FieldText;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.autocomplete__option {
|
|
122
|
+
background-color: Field;
|
|
123
|
+
color: FieldText;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.autocomplete__option--focused,
|
|
127
|
+
.autocomplete__option:hover {
|
|
128
|
+
forced-color-adjust: none; /* prevent backplate from obscuring text */
|
|
129
|
+
background-color: Highlight;
|
|
130
|
+
border-color: Highlight;
|
|
131
|
+
color: HighlightText;
|
|
132
|
+
|
|
133
|
+
/* Prefer SelectedItem / SelectedItemText in browsers that support it */
|
|
134
|
+
background-color: SelectedItem;
|
|
135
|
+
border-color: SelectedItem;
|
|
136
|
+
color: SelectedItemText;
|
|
137
|
+
outline-color: SelectedItemText;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.autocomplete__option--no-results {
|
|
142
|
+
background-color: #FAFAFA;
|
|
143
|
+
color: #646b6f;
|
|
144
|
+
cursor: not-allowed;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.autocomplete__hint,
|
|
148
|
+
.autocomplete__input,
|
|
149
|
+
.autocomplete__option {
|
|
150
|
+
font-size: 16px;
|
|
151
|
+
line-height: 1.25;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.autocomplete__hint,
|
|
155
|
+
.autocomplete__option {
|
|
156
|
+
padding: 5px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@media (min-width: 641px) {
|
|
160
|
+
.autocomplete__hint,
|
|
161
|
+
.autocomplete__input,
|
|
162
|
+
.autocomplete__option {
|
|
163
|
+
font-size: 19px;
|
|
164
|
+
line-height: 1.31579;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -7,6 +7,8 @@ exports.FormAutocomplete = 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 = _interopRequireWildcard(require("react"));
|
|
11
13
|
|
|
12
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -25,19 +27,12 @@ var _FormSelectArrow = require("./FormSelectArrow");
|
|
|
25
27
|
|
|
26
28
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
27
29
|
|
|
30
|
+
var _excluded = ["isInline", "forLabel", "options", "label", "getOptionLabel", "getOptionValue", "onChange", "value", "showAllValues", "displayMenu", "id"];
|
|
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 defaultStyles = {
|
|
42
37
|
width: '100%',
|
|
43
38
|
py: 0,
|
|
@@ -114,15 +109,18 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
114
109
|
forLabel = _ref.forLabel,
|
|
115
110
|
options = _ref.options,
|
|
116
111
|
label = _ref.label,
|
|
112
|
+
getOptionLabel = _ref.getOptionLabel,
|
|
117
113
|
getOptionValue = _ref.getOptionValue,
|
|
118
|
-
onChange = _ref.onChange,
|
|
114
|
+
_ref$onChange = _ref.onChange,
|
|
115
|
+
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
119
116
|
value = _ref.value,
|
|
120
117
|
_ref$showAllValues = _ref.showAllValues,
|
|
121
118
|
showAllValues = _ref$showAllValues === void 0 ? true : _ref$showAllValues,
|
|
122
119
|
_ref$displayMenu = _ref.displayMenu,
|
|
123
120
|
displayMenu = _ref$displayMenu === void 0 ? 'overlay' : _ref$displayMenu,
|
|
124
121
|
_ref$id = _ref.id,
|
|
125
|
-
id = _ref$id === void 0 ? 'vip-autocomplete' : _ref$id
|
|
122
|
+
id = _ref$id === void 0 ? 'vip-autocomplete' : _ref$id,
|
|
123
|
+
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
126
124
|
|
|
127
125
|
var SelectLabel = function SelectLabel() {
|
|
128
126
|
return (0, _jsxRuntime.jsx)(_Label.Label, {
|
|
@@ -132,9 +130,9 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
132
130
|
};
|
|
133
131
|
|
|
134
132
|
var inlineLabel = !!(isInline && label);
|
|
135
|
-
var
|
|
136
|
-
return
|
|
137
|
-
}, [
|
|
133
|
+
var optionLabel = (0, _react.useCallback)(function (option) {
|
|
134
|
+
return getOptionLabel ? getOptionLabel(option) : option.label;
|
|
135
|
+
}, [getOptionLabel]);
|
|
138
136
|
var getAllOptions = (0, _react.useMemo)(function () {
|
|
139
137
|
return [].concat(options.filter(function (option) {
|
|
140
138
|
return !option.options;
|
|
@@ -146,22 +144,22 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
146
144
|
return a.concat(b);
|
|
147
145
|
}, []);
|
|
148
146
|
}, [options]);
|
|
149
|
-
var
|
|
147
|
+
var getOptionByLabel = (0, _react.useCallback)(function (inputValue) {
|
|
150
148
|
return getAllOptions.find(function (option) {
|
|
151
|
-
return "" +
|
|
149
|
+
return "" + optionLabel(option) === "" + inputValue;
|
|
152
150
|
});
|
|
153
|
-
}, [getAllOptions,
|
|
151
|
+
}, [getAllOptions, optionLabel]);
|
|
154
152
|
var onValueChange = (0, _react.useCallback)(function (inputValue) {
|
|
155
|
-
if (
|
|
156
|
-
onChange(
|
|
153
|
+
if (inputValue) {
|
|
154
|
+
onChange(getOptionByLabel(inputValue), inputValue);
|
|
157
155
|
}
|
|
158
|
-
}, [onChange,
|
|
156
|
+
}, [onChange, getOptionByLabel]);
|
|
159
157
|
var suggest = (0, _react.useCallback)(function (query, populateResults) {
|
|
160
158
|
var data = options.filter(function (option) {
|
|
161
|
-
return option.
|
|
159
|
+
return optionLabel(option).toLowerCase().indexOf(query.toLowerCase()) >= 0;
|
|
162
160
|
});
|
|
163
161
|
populateResults(data.map(function (option) {
|
|
164
|
-
return option
|
|
162
|
+
return optionLabel(option);
|
|
165
163
|
}));
|
|
166
164
|
}, [options]);
|
|
167
165
|
(0, _react.useEffect)(function () {
|
|
@@ -176,7 +174,7 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
176
174
|
children: (0, _jsxRuntime.jsxs)(_FormSelectContent.FormSelectContent, {
|
|
177
175
|
isInline: inlineLabel,
|
|
178
176
|
label: inlineLabel ? (0, _jsxRuntime.jsx)(SelectLabel, {}) : null,
|
|
179
|
-
children: [(0, _jsxRuntime.jsx)(_react2["default"], {
|
|
177
|
+
children: [(0, _jsxRuntime.jsx)(_react2["default"], (0, _extends2["default"])({
|
|
180
178
|
id: id,
|
|
181
179
|
showAllValues: showAllValues,
|
|
182
180
|
ref: forwardRef,
|
|
@@ -184,7 +182,7 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
184
182
|
defaultValue: value,
|
|
185
183
|
displayMenu: displayMenu,
|
|
186
184
|
onConfirm: onValueChange
|
|
187
|
-
}), (0, _jsxRuntime.jsx)(_FormSelectArrow.FormSelectArrow, {})]
|
|
185
|
+
}, props)), (0, _jsxRuntime.jsx)(_FormSelectArrow.FormSelectArrow, {})]
|
|
188
186
|
})
|
|
189
187
|
})]
|
|
190
188
|
});
|
|
@@ -200,6 +198,7 @@ FormAutocomplete.propTypes = {
|
|
|
200
198
|
displayMenu: _propTypes["default"].string,
|
|
201
199
|
label: _propTypes["default"].string,
|
|
202
200
|
options: _propTypes["default"].array,
|
|
201
|
+
getOptionLabel: _propTypes["default"].func,
|
|
203
202
|
getOptionValue: _propTypes["default"].func,
|
|
204
203
|
onChange: _propTypes["default"].func
|
|
205
204
|
};
|
|
@@ -9,13 +9,11 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
|
|
10
10
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
11
|
|
|
12
|
-
var _react = require("react");
|
|
13
|
-
|
|
14
12
|
var Form = _interopRequireWildcard(require("."));
|
|
15
13
|
|
|
16
14
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
15
|
|
|
18
|
-
var _excluded = ["label", "width"
|
|
16
|
+
var _excluded = ["label", "width"];
|
|
19
17
|
|
|
20
18
|
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
19
|
|
|
@@ -45,7 +43,7 @@ var _default = {
|
|
|
45
43
|
}
|
|
46
44
|
};
|
|
47
45
|
exports["default"] = _default;
|
|
48
|
-
var
|
|
46
|
+
var options = [{
|
|
49
47
|
value: 'chocolate',
|
|
50
48
|
label: 'Chocolate'
|
|
51
49
|
}, {
|
|
@@ -54,14 +52,17 @@ var defaultOptions = [{
|
|
|
54
52
|
}, {
|
|
55
53
|
value: 'vanilla',
|
|
56
54
|
label: 'Vanilla'
|
|
57
|
-
}];
|
|
55
|
+
}];
|
|
56
|
+
var args = {
|
|
57
|
+
label: 'Label',
|
|
58
|
+
options: options
|
|
59
|
+
}; // eslint-disable-next-line react/prop-types
|
|
58
60
|
|
|
59
61
|
var DefaultComponent = function DefaultComponent(_ref) {
|
|
60
62
|
var _ref$label = _ref.label,
|
|
61
63
|
label = _ref$label === void 0 ? 'Label' : _ref$label,
|
|
62
64
|
_ref$width = _ref.width,
|
|
63
65
|
width = _ref$width === void 0 ? 250 : _ref$width,
|
|
64
|
-
onChange = _ref.onChange,
|
|
65
66
|
rest = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
66
67
|
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
67
68
|
children: (0, _jsxRuntime.jsx)(Form.Root, {
|
|
@@ -71,8 +72,7 @@ var DefaultComponent = function DefaultComponent(_ref) {
|
|
|
71
72
|
},
|
|
72
73
|
children: (0, _jsxRuntime.jsx)(Form.Autocomplete, (0, _extends2["default"])({
|
|
73
74
|
id: "form-autocomplete",
|
|
74
|
-
label: label
|
|
75
|
-
onChange: onChange
|
|
75
|
+
label: label
|
|
76
76
|
}, rest))
|
|
77
77
|
})
|
|
78
78
|
})
|
|
@@ -80,47 +80,19 @@ var DefaultComponent = function DefaultComponent(_ref) {
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
var Default = function Default() {
|
|
83
|
-
var _useState = (0, _react.useState)(defaultOptions),
|
|
84
|
-
options = _useState[0],
|
|
85
|
-
setOptions = _useState[1];
|
|
86
|
-
|
|
87
|
-
var onChange = (0, _react.useCallback)(function (value) {
|
|
88
|
-
setOptions(defaultOptions.filter(function (option) {
|
|
89
|
-
return !value || option.label.toLowerCase().indexOf(value.toLowerCase()) >= 0;
|
|
90
|
-
}));
|
|
91
|
-
});
|
|
92
|
-
var args = {
|
|
93
|
-
label: 'Label',
|
|
94
|
-
options: options
|
|
95
|
-
};
|
|
96
83
|
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
97
|
-
children: (0, _jsxRuntime.jsx)(DefaultComponent, (0, _extends2["default"])({
|
|
98
|
-
onChange: onChange
|
|
99
|
-
}, args))
|
|
84
|
+
children: (0, _jsxRuntime.jsx)(DefaultComponent, (0, _extends2["default"])({}, args))
|
|
100
85
|
});
|
|
101
86
|
};
|
|
102
87
|
|
|
103
88
|
exports.Default = Default;
|
|
104
89
|
|
|
105
90
|
var Inline = function Inline() {
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
setOptions = _useState2[1];
|
|
109
|
-
|
|
110
|
-
var onChange = (0, _react.useCallback)(function (value) {
|
|
111
|
-
setOptions(defaultOptions.filter(function (option) {
|
|
112
|
-
return !value || option.label.toLowerCase().indexOf(value.toLowerCase()) >= 0;
|
|
113
|
-
}));
|
|
91
|
+
var customArgs = (0, _extends2["default"])({}, args, {
|
|
92
|
+
isInline: true
|
|
114
93
|
});
|
|
115
|
-
var args = {
|
|
116
|
-
label: 'Label',
|
|
117
|
-
options: options
|
|
118
|
-
};
|
|
119
94
|
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
120
|
-
children: (0, _jsxRuntime.jsx)(DefaultComponent, (0, _extends2["default"])({
|
|
121
|
-
isInline: true,
|
|
122
|
-
onChange: onChange
|
|
123
|
-
}, args))
|
|
95
|
+
children: (0, _jsxRuntime.jsx)(DefaultComponent, (0, _extends2["default"])({}, customArgs))
|
|
124
96
|
});
|
|
125
97
|
};
|
|
126
98
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.NewTabs = void 0;
|
|
7
|
+
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var TabsPrimitive = _interopRequireWildcard(require("@radix-ui/react-tabs"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
18
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
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
|
+
|
|
24
|
+
/** @jsxImportSource theme-ui */
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* External dependencies
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Internal dependencies
|
|
32
|
+
*/
|
|
33
|
+
var NewTabs = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
34
|
+
var children = _ref.children,
|
|
35
|
+
_ref$onValueChange = _ref.onValueChange,
|
|
36
|
+
onValueChange = _ref$onValueChange === void 0 ? undefined : _ref$onValueChange,
|
|
37
|
+
_ref$defaultValue = _ref.defaultValue,
|
|
38
|
+
defaultValue = _ref$defaultValue === void 0 ? undefined : _ref$defaultValue,
|
|
39
|
+
_ref$className = _ref.className,
|
|
40
|
+
className = _ref$className === void 0 ? null : _ref$className,
|
|
41
|
+
_ref$sx = _ref.sx,
|
|
42
|
+
sx = _ref$sx === void 0 ? {} : _ref$sx;
|
|
43
|
+
return (0, _jsxRuntime.jsx)(TabsPrimitive.Root, {
|
|
44
|
+
ref: ref,
|
|
45
|
+
defaultValue: defaultValue,
|
|
46
|
+
onValueChange: onValueChange,
|
|
47
|
+
className: (0, _classnames["default"])('vip-tabs-component', className),
|
|
48
|
+
sx: (0, _extends2["default"])({}, sx),
|
|
49
|
+
children: children
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
exports.NewTabs = NewTabs;
|
|
54
|
+
NewTabs.propTypes = {
|
|
55
|
+
className: _propTypes["default"].any,
|
|
56
|
+
sx: _propTypes["default"].object,
|
|
57
|
+
defaultValue: _propTypes["default"].node,
|
|
58
|
+
onValueChange: _propTypes["default"].func,
|
|
59
|
+
children: _propTypes["default"].node.isRequired
|
|
60
|
+
};
|
|
61
|
+
NewTabs.displayName = 'NewTabs';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.Default = void 0;
|
|
5
|
+
|
|
6
|
+
var _ = require("..");
|
|
7
|
+
|
|
8
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
var _default = {
|
|
14
|
+
title: 'NewTabs',
|
|
15
|
+
component: _.NewTabs
|
|
16
|
+
};
|
|
17
|
+
exports["default"] = _default;
|
|
18
|
+
|
|
19
|
+
var Default = function Default() {
|
|
20
|
+
return (0, _jsxRuntime.jsxs)(_.NewTabs, {
|
|
21
|
+
defaultValue: "all",
|
|
22
|
+
children: [(0, _jsxRuntime.jsxs)(_.TabsList, {
|
|
23
|
+
title: "See all the content",
|
|
24
|
+
children: [(0, _jsxRuntime.jsx)(_.TabsTrigger, {
|
|
25
|
+
value: "all",
|
|
26
|
+
children: "All (5)"
|
|
27
|
+
}), (0, _jsxRuntime.jsx)(_.TabsTrigger, {
|
|
28
|
+
value: "live",
|
|
29
|
+
children: "Live (2)"
|
|
30
|
+
}), (0, _jsxRuntime.jsx)(_.TabsTrigger, {
|
|
31
|
+
value: "dev",
|
|
32
|
+
children: "In Development (3)"
|
|
33
|
+
}), (0, _jsxRuntime.jsx)(_.TabsTrigger, {
|
|
34
|
+
value: "protect",
|
|
35
|
+
disabled: true,
|
|
36
|
+
children: "Not accessible"
|
|
37
|
+
})]
|
|
38
|
+
}), (0, _jsxRuntime.jsx)(_.TabsContent, {
|
|
39
|
+
value: "all",
|
|
40
|
+
children: (0, _jsxRuntime.jsx)(_.Text, {
|
|
41
|
+
children: "All content"
|
|
42
|
+
})
|
|
43
|
+
}), (0, _jsxRuntime.jsx)(_.TabsContent, {
|
|
44
|
+
value: "live",
|
|
45
|
+
children: "Live content"
|
|
46
|
+
}), (0, _jsxRuntime.jsx)(_.TabsContent, {
|
|
47
|
+
value: "dev",
|
|
48
|
+
children: (0, _jsxRuntime.jsx)(_.Text, {
|
|
49
|
+
children: "In Development content"
|
|
50
|
+
})
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.Default = Default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.TabsContent = void 0;
|
|
7
|
+
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var TabsPrimitive = _interopRequireWildcard(require("@radix-ui/react-tabs"));
|
|
13
|
+
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
|
|
16
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
/** @jsxImportSource theme-ui */
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* External dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
var TabsContent = function TabsContent(_ref) {
|
|
32
|
+
var value = _ref.value,
|
|
33
|
+
sx = _ref.sx,
|
|
34
|
+
children = _ref.children;
|
|
35
|
+
return (0, _jsxRuntime.jsx)(TabsPrimitive.Content, {
|
|
36
|
+
className: (0, _classnames["default"])('vip-tabs-content', "vip-tabs-content-" + value),
|
|
37
|
+
value: value,
|
|
38
|
+
sx: (0, _extends2["default"])({
|
|
39
|
+
mt: 4
|
|
40
|
+
}, sx),
|
|
41
|
+
children: children
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.TabsContent = TabsContent;
|
|
46
|
+
TabsContent.propTypes = {
|
|
47
|
+
sx: _propTypes["default"].object,
|
|
48
|
+
value: _propTypes["default"].string,
|
|
49
|
+
children: _propTypes["default"].node.isRequired
|
|
50
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.TabsList = void 0;
|
|
7
|
+
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var TabsPrimitive = _interopRequireWildcard(require("@radix-ui/react-tabs"));
|
|
13
|
+
|
|
14
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
15
|
+
|
|
16
|
+
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); }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
/** @jsxImportSource theme-ui */
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* External dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
var TabsList = function TabsList(_ref) {
|
|
30
|
+
var children = _ref.children,
|
|
31
|
+
title = _ref.title,
|
|
32
|
+
sx = _ref.sx;
|
|
33
|
+
return (0, _jsxRuntime.jsx)(TabsPrimitive.List, {
|
|
34
|
+
sx: (0, _extends2["default"])({
|
|
35
|
+
borderBottom: '1px solid',
|
|
36
|
+
borderColor: 'border',
|
|
37
|
+
display: 'flex'
|
|
38
|
+
}, sx),
|
|
39
|
+
title: title,
|
|
40
|
+
children: children
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.TabsList = TabsList;
|
|
45
|
+
TabsList.propTypes = {
|
|
46
|
+
sx: _propTypes["default"].object,
|
|
47
|
+
title: _propTypes["default"].string.isRequired,
|
|
48
|
+
children: _propTypes["default"].node.isRequired
|
|
49
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.TabsTrigger = void 0;
|
|
7
|
+
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var TabsPrimitive = _interopRequireWildcard(require("@radix-ui/react-tabs"));
|
|
13
|
+
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
|
|
16
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
/** @jsxImportSource theme-ui */
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* External dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
var styles = {
|
|
32
|
+
cursor: 'pointer',
|
|
33
|
+
background: 'none',
|
|
34
|
+
mr: 3,
|
|
35
|
+
fontSize: 2,
|
|
36
|
+
px: 0,
|
|
37
|
+
pb: 3,
|
|
38
|
+
border: 'none',
|
|
39
|
+
color: 'muted',
|
|
40
|
+
'&[data-state="active"]': {
|
|
41
|
+
color: 'heading',
|
|
42
|
+
fontWeight: 'body',
|
|
43
|
+
boxShadow: function boxShadow(theme) {
|
|
44
|
+
return "inset 0 -1px 0 0 " + theme.colors.link + ", 0 1px 0 0 " + theme.colors.link;
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
'&:disabled': {
|
|
48
|
+
color: 'grey.70'
|
|
49
|
+
},
|
|
50
|
+
':hover': {
|
|
51
|
+
fontWeight: 'body',
|
|
52
|
+
color: 'heading'
|
|
53
|
+
},
|
|
54
|
+
'&:focus': function focus(theme) {
|
|
55
|
+
return theme.outline;
|
|
56
|
+
},
|
|
57
|
+
'&:focus-visible': function focusVisible(theme) {
|
|
58
|
+
return theme.outline;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var TabsTrigger = function TabsTrigger(_ref) {
|
|
63
|
+
var value = _ref.value,
|
|
64
|
+
_ref$disabled = _ref.disabled,
|
|
65
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
66
|
+
sx = _ref.sx,
|
|
67
|
+
children = _ref.children;
|
|
68
|
+
return (0, _jsxRuntime.jsx)(TabsPrimitive.TabsTrigger, {
|
|
69
|
+
className: (0, _classnames["default"])('vip-tabs-trigger', "vip-tabs-trigger-" + value),
|
|
70
|
+
value: value,
|
|
71
|
+
disabled: disabled,
|
|
72
|
+
sx: (0, _extends2["default"])({}, styles, sx),
|
|
73
|
+
children: children
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
exports.TabsTrigger = TabsTrigger;
|
|
78
|
+
TabsTrigger.propTypes = {
|
|
79
|
+
sx: _propTypes["default"].object,
|
|
80
|
+
value: _propTypes["default"].string,
|
|
81
|
+
disabled: _propTypes["default"].bool,
|
|
82
|
+
children: _propTypes["default"].node.isRequired
|
|
83
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
|
|
5
|
+
var _Tabs = require("./Tabs");
|
|
6
|
+
|
|
7
|
+
exports.NewTabs = _Tabs.NewTabs;
|
|
8
|
+
|
|
9
|
+
var _TabsTrigger = require("./TabsTrigger");
|
|
10
|
+
|
|
11
|
+
exports.TabsTrigger = _TabsTrigger.TabsTrigger;
|
|
12
|
+
|
|
13
|
+
var _TabsList = require("./TabsList");
|
|
14
|
+
|
|
15
|
+
exports.TabsList = _TabsList.TabsList;
|
|
16
|
+
|
|
17
|
+
var _TabsContent = require("./TabsContent");
|
|
18
|
+
|
|
19
|
+
exports.TabsContent = _TabsContent.TabsContent;
|
|
@@ -9,8 +9,6 @@ var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
-
var _react = require("react");
|
|
13
|
-
|
|
14
12
|
var _ = require("..");
|
|
15
13
|
|
|
16
14
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
@@ -53,7 +51,7 @@ var StyledListItem = function StyledListItem(props) {
|
|
|
53
51
|
sx: {
|
|
54
52
|
py: 2,
|
|
55
53
|
borderBottom: '1px solid',
|
|
56
|
-
borderColor: '
|
|
54
|
+
borderColor: 'border',
|
|
57
55
|
listStyleType: 'none',
|
|
58
56
|
margin: 0,
|
|
59
57
|
px: 0
|
|
@@ -87,37 +85,6 @@ var ResourceList = function ResourceList(_ref) {
|
|
|
87
85
|
});
|
|
88
86
|
};
|
|
89
87
|
|
|
90
|
-
var renderGoupedItems = function renderGoupedItems() {
|
|
91
|
-
return (0, _react.useMemo)(function () {
|
|
92
|
-
return Object.keys(groupedItems).map(function (groupName, index) {
|
|
93
|
-
return (0, _jsxRuntime.jsxs)(_.Box, {
|
|
94
|
-
sx: {
|
|
95
|
-
mb: 4
|
|
96
|
-
},
|
|
97
|
-
as: "li",
|
|
98
|
-
children: [(0, _jsxRuntime.jsx)(_.Heading, {
|
|
99
|
-
variant: "h4",
|
|
100
|
-
as: "h4",
|
|
101
|
-
sx: {
|
|
102
|
-
mb: 3
|
|
103
|
-
},
|
|
104
|
-
children: groupName
|
|
105
|
-
}), (0, _jsxRuntime.jsx)(_.Box, {
|
|
106
|
-
as: "ul",
|
|
107
|
-
sx: {
|
|
108
|
-
listStyleType: 'none',
|
|
109
|
-
m: 0,
|
|
110
|
-
p: 0,
|
|
111
|
-
borderTop: '1px solid',
|
|
112
|
-
borderColor: 'border'
|
|
113
|
-
},
|
|
114
|
-
children: renderItemList(groupedItems[groupName])
|
|
115
|
-
})]
|
|
116
|
-
}, index);
|
|
117
|
-
});
|
|
118
|
-
}, [groupedItems]);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
88
|
return (0, _jsxRuntime.jsx)(_.Box, {
|
|
122
89
|
as: "ul",
|
|
123
90
|
sx: {
|
|
@@ -126,7 +93,31 @@ var ResourceList = function ResourceList(_ref) {
|
|
|
126
93
|
p: 0
|
|
127
94
|
},
|
|
128
95
|
className: "vip-resource-list-component",
|
|
129
|
-
children: groupedByDay ?
|
|
96
|
+
children: groupedByDay ? Object.keys(groupedItems).map(function (groupName, index) {
|
|
97
|
+
return (0, _jsxRuntime.jsxs)(_.Box, {
|
|
98
|
+
sx: {
|
|
99
|
+
mb: 4
|
|
100
|
+
},
|
|
101
|
+
children: [(0, _jsxRuntime.jsx)(_.Heading, {
|
|
102
|
+
variant: "h4",
|
|
103
|
+
as: "h4",
|
|
104
|
+
sx: {
|
|
105
|
+
mb: 3
|
|
106
|
+
},
|
|
107
|
+
children: groupName
|
|
108
|
+
}), (0, _jsxRuntime.jsx)(_.Box, {
|
|
109
|
+
as: "ul",
|
|
110
|
+
sx: {
|
|
111
|
+
listStyleType: 'none',
|
|
112
|
+
m: 0,
|
|
113
|
+
p: 0,
|
|
114
|
+
borderTop: '1px solid',
|
|
115
|
+
borderColor: 'border'
|
|
116
|
+
},
|
|
117
|
+
children: renderItemList(groupedItems[groupName])
|
|
118
|
+
})]
|
|
119
|
+
}, index);
|
|
120
|
+
}) : renderItemList(items)
|
|
130
121
|
});
|
|
131
122
|
};
|
|
132
123
|
|
|
@@ -129,7 +129,6 @@ var Grouped = function Grouped() {
|
|
|
129
129
|
children: "#443"
|
|
130
130
|
})]
|
|
131
131
|
}), (0, _jsxRuntime.jsxs)(_.Text, {
|
|
132
|
-
as: "div",
|
|
133
132
|
sx: {
|
|
134
133
|
mb: 0,
|
|
135
134
|
fontSize: 1,
|
|
@@ -338,7 +337,6 @@ var Relative = function Relative() {
|
|
|
338
337
|
children: "Running"
|
|
339
338
|
})]
|
|
340
339
|
}), (0, _jsxRuntime.jsxs)(_.Text, {
|
|
341
|
-
as: "div",
|
|
342
340
|
sx: {
|
|
343
341
|
mb: 0,
|
|
344
342
|
color: 'muted',
|
package/build/system/index.js
CHANGED
|
@@ -154,6 +154,13 @@ exports.Wizard = _Wizard.Wizard;
|
|
|
154
154
|
exports.WizardStep = _Wizard.WizardStep;
|
|
155
155
|
exports.WizardStepHorizontal = _Wizard.WizardStepHorizontal;
|
|
156
156
|
|
|
157
|
+
var _NewTabs = require("./NewTabs");
|
|
158
|
+
|
|
159
|
+
exports.NewTabs = _NewTabs.NewTabs;
|
|
160
|
+
exports.TabsList = _NewTabs.TabsList;
|
|
161
|
+
exports.TabsContent = _NewTabs.TabsContent;
|
|
162
|
+
exports.TabsTrigger = _NewTabs.TabsTrigger;
|
|
163
|
+
|
|
157
164
|
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); }
|
|
158
165
|
|
|
159
166
|
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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/vip-design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"main": "build/system/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build-storybook": "build-storybook",
|
|
7
7
|
"prepare": "npm run build",
|
|
8
|
-
"build": "npm run theme-update && cross-env NODE_ENV=production babel src --out-dir build && npm run theme-builder-copy",
|
|
8
|
+
"build": "npm run theme-update && cross-env NODE_ENV=production babel src --out-dir build --copy-files && npm run theme-builder-copy",
|
|
9
9
|
"format": "prettier --write \"src/**/*.{js,ts,tsx,md,mdx,json}\"",
|
|
10
10
|
"format:check": "prettier --list-different -- \"src/system/**/*.{js,ts,tsx,md,mdx,json}\"",
|
|
11
11
|
"jest": "NODE_ENV=test jest --detectOpenHandles --env=jsdom",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@radix-ui/react-switch": "^1.0.0",
|
|
29
29
|
"@radix-ui/react-tooltip": "^1.0.0",
|
|
30
30
|
"@radix-ui/react-visually-hidden": "^1.0.0",
|
|
31
|
+
"@radix-ui/react-tabs": "^1.0.0",
|
|
31
32
|
"@storybook/addon-storysource": "^6.5.10",
|
|
32
33
|
"accessible-autocomplete": "^2.0.4",
|
|
33
34
|
"babel-loader": "^8.2.2",
|
|
@@ -74,12 +74,14 @@ const FormAutocomplete = React.forwardRef(
|
|
|
74
74
|
forLabel,
|
|
75
75
|
options,
|
|
76
76
|
label,
|
|
77
|
+
getOptionLabel,
|
|
77
78
|
getOptionValue,
|
|
78
|
-
onChange,
|
|
79
|
+
onChange = () => {},
|
|
79
80
|
value,
|
|
80
81
|
showAllValues = true,
|
|
81
82
|
displayMenu = 'overlay',
|
|
82
83
|
id = 'vip-autocomplete',
|
|
84
|
+
...props
|
|
83
85
|
},
|
|
84
86
|
forwardRef
|
|
85
87
|
) => {
|
|
@@ -87,9 +89,9 @@ const FormAutocomplete = React.forwardRef(
|
|
|
87
89
|
|
|
88
90
|
const inlineLabel = !! ( isInline && label );
|
|
89
91
|
|
|
90
|
-
const
|
|
91
|
-
option => (
|
|
92
|
-
[
|
|
92
|
+
const optionLabel = useCallback(
|
|
93
|
+
option => ( getOptionLabel ? getOptionLabel( option ) : option.label ),
|
|
94
|
+
[ getOptionLabel ]
|
|
93
95
|
);
|
|
94
96
|
|
|
95
97
|
const getAllOptions = useMemo(
|
|
@@ -101,27 +103,27 @@ const FormAutocomplete = React.forwardRef(
|
|
|
101
103
|
[ options ]
|
|
102
104
|
);
|
|
103
105
|
|
|
104
|
-
const
|
|
106
|
+
const getOptionByLabel = useCallback(
|
|
105
107
|
inputValue =>
|
|
106
|
-
getAllOptions.find( option => `${
|
|
107
|
-
[ getAllOptions,
|
|
108
|
+
getAllOptions.find( option => `${ optionLabel( option ) }` === `${ inputValue }` ),
|
|
109
|
+
[ getAllOptions, optionLabel ]
|
|
108
110
|
);
|
|
109
111
|
|
|
110
112
|
const onValueChange = useCallback(
|
|
111
113
|
inputValue => {
|
|
112
|
-
if (
|
|
113
|
-
onChange(
|
|
114
|
+
if ( inputValue ) {
|
|
115
|
+
onChange( getOptionByLabel( inputValue ), inputValue );
|
|
114
116
|
}
|
|
115
117
|
},
|
|
116
|
-
[ onChange,
|
|
118
|
+
[ onChange, getOptionByLabel ]
|
|
117
119
|
);
|
|
118
120
|
|
|
119
121
|
const suggest = useCallback(
|
|
120
122
|
( query, populateResults ) => {
|
|
121
123
|
const data = options.filter(
|
|
122
|
-
option => option.
|
|
124
|
+
option => optionLabel( option ).toLowerCase().indexOf( query.toLowerCase() ) >= 0
|
|
123
125
|
);
|
|
124
|
-
populateResults( data.map( option => option
|
|
126
|
+
populateResults( data.map( option => optionLabel( option ) ) );
|
|
125
127
|
},
|
|
126
128
|
[ options ]
|
|
127
129
|
);
|
|
@@ -155,6 +157,7 @@ const FormAutocomplete = React.forwardRef(
|
|
|
155
157
|
defaultValue={ value }
|
|
156
158
|
displayMenu={ displayMenu }
|
|
157
159
|
onConfirm={ onValueChange }
|
|
160
|
+
{ ...props }
|
|
158
161
|
/>
|
|
159
162
|
<FormSelectArrow />
|
|
160
163
|
</FormSelectContent>
|
|
@@ -173,6 +176,7 @@ FormAutocomplete.propTypes = {
|
|
|
173
176
|
displayMenu: PropTypes.string,
|
|
174
177
|
label: PropTypes.string,
|
|
175
178
|
options: PropTypes.array,
|
|
179
|
+
getOptionLabel: PropTypes.func,
|
|
176
180
|
getOptionValue: PropTypes.func,
|
|
177
181
|
onChange: PropTypes.func,
|
|
178
182
|
};
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Internal dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { useCallback, useState } from 'react';
|
|
7
6
|
import * as Form from '.';
|
|
8
7
|
|
|
9
8
|
export default {
|
|
@@ -20,70 +19,45 @@ export default {
|
|
|
20
19
|
},
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
const
|
|
22
|
+
const options = [
|
|
24
23
|
{ value: 'chocolate', label: 'Chocolate' },
|
|
25
24
|
{ value: 'strawberry', label: 'Strawberry Chocolate Vanilla Chocolate Vanilla' },
|
|
26
25
|
{ value: 'vanilla', label: 'Vanilla' },
|
|
27
26
|
];
|
|
28
27
|
|
|
28
|
+
const args = {
|
|
29
|
+
label: 'Label',
|
|
30
|
+
options,
|
|
31
|
+
};
|
|
32
|
+
|
|
29
33
|
// eslint-disable-next-line react/prop-types
|
|
30
|
-
const DefaultComponent = ( { label = 'Label', width = 250,
|
|
34
|
+
const DefaultComponent = ( { label = 'Label', width = 250, ...rest } ) => (
|
|
31
35
|
<>
|
|
32
36
|
<Form.Root>
|
|
33
37
|
<div sx={ { width } }>
|
|
34
|
-
<Form.Autocomplete
|
|
35
|
-
id="form-autocomplete"
|
|
36
|
-
label={ label }
|
|
37
|
-
onChange={ onChange }
|
|
38
|
-
{ ...rest }
|
|
39
|
-
/>
|
|
38
|
+
<Form.Autocomplete id="form-autocomplete" label={ label } { ...rest } />
|
|
40
39
|
</div>
|
|
41
40
|
</Form.Root>
|
|
42
41
|
</>
|
|
43
42
|
);
|
|
44
43
|
|
|
45
44
|
export const Default = () => {
|
|
46
|
-
const [ options, setOptions ] = useState( defaultOptions );
|
|
47
|
-
|
|
48
|
-
const onChange = useCallback( value => {
|
|
49
|
-
setOptions(
|
|
50
|
-
defaultOptions.filter(
|
|
51
|
-
option => ! value || option.label.toLowerCase().indexOf( value.toLowerCase() ) >= 0
|
|
52
|
-
)
|
|
53
|
-
);
|
|
54
|
-
} );
|
|
55
|
-
|
|
56
|
-
const args = {
|
|
57
|
-
label: 'Label',
|
|
58
|
-
options,
|
|
59
|
-
};
|
|
60
|
-
|
|
61
45
|
return (
|
|
62
46
|
<>
|
|
63
|
-
<DefaultComponent
|
|
47
|
+
<DefaultComponent { ...args } />
|
|
64
48
|
</>
|
|
65
49
|
);
|
|
66
50
|
};
|
|
67
51
|
|
|
68
52
|
export const Inline = () => {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
setOptions(
|
|
73
|
-
defaultOptions.filter(
|
|
74
|
-
option => ! value || option.label.toLowerCase().indexOf( value.toLowerCase() ) >= 0
|
|
75
|
-
)
|
|
76
|
-
);
|
|
77
|
-
} );
|
|
78
|
-
|
|
79
|
-
const args = {
|
|
80
|
-
label: 'Label',
|
|
81
|
-
options,
|
|
53
|
+
const customArgs = {
|
|
54
|
+
...args,
|
|
55
|
+
isInline: true,
|
|
82
56
|
};
|
|
83
57
|
|
|
84
58
|
return (
|
|
85
59
|
<>
|
|
86
|
-
<DefaultComponent
|
|
60
|
+
<DefaultComponent { ...customArgs } />
|
|
87
61
|
</>
|
|
88
62
|
);
|
|
89
63
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const NewTabs = React.forwardRef(
|
|
16
|
+
(
|
|
17
|
+
{ children, onValueChange = undefined, defaultValue = undefined, className = null, sx = {} },
|
|
18
|
+
ref
|
|
19
|
+
) => {
|
|
20
|
+
return (
|
|
21
|
+
<TabsPrimitive.Root
|
|
22
|
+
ref={ ref }
|
|
23
|
+
defaultValue={ defaultValue }
|
|
24
|
+
onValueChange={ onValueChange }
|
|
25
|
+
className={ classNames( 'vip-tabs-component', className ) }
|
|
26
|
+
sx={ { ...sx } }
|
|
27
|
+
>
|
|
28
|
+
{ children }
|
|
29
|
+
</TabsPrimitive.Root>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
NewTabs.propTypes = {
|
|
35
|
+
className: PropTypes.any,
|
|
36
|
+
sx: PropTypes.object,
|
|
37
|
+
defaultValue: PropTypes.node,
|
|
38
|
+
onValueChange: PropTypes.func,
|
|
39
|
+
children: PropTypes.node.isRequired,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
NewTabs.displayName = 'NewTabs';
|
|
43
|
+
|
|
44
|
+
export { NewTabs };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { NewTabs, TabsTrigger, TabsList, TabsContent, Text } from '..';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'NewTabs',
|
|
8
|
+
component: NewTabs,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const Default = () => (
|
|
12
|
+
<NewTabs defaultValue="all">
|
|
13
|
+
<TabsList title="See all the content">
|
|
14
|
+
<TabsTrigger value="all">All (5)</TabsTrigger>
|
|
15
|
+
<TabsTrigger value="live">Live (2)</TabsTrigger>
|
|
16
|
+
<TabsTrigger value="dev">In Development (3)</TabsTrigger>
|
|
17
|
+
<TabsTrigger value="protect" disabled={ true }>
|
|
18
|
+
Not accessible
|
|
19
|
+
</TabsTrigger>
|
|
20
|
+
</TabsList>
|
|
21
|
+
<TabsContent value="all">
|
|
22
|
+
<Text>All content</Text>
|
|
23
|
+
</TabsContent>
|
|
24
|
+
<TabsContent value="live">Live content</TabsContent>
|
|
25
|
+
<TabsContent value="dev">
|
|
26
|
+
<Text>In Development content</Text>
|
|
27
|
+
</TabsContent>
|
|
28
|
+
</NewTabs>
|
|
29
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const TabsContent = ( { value, sx, children } ) => (
|
|
15
|
+
<TabsPrimitive.Content
|
|
16
|
+
className={ classNames( 'vip-tabs-content', `vip-tabs-content-${ value }` ) }
|
|
17
|
+
value={ value }
|
|
18
|
+
sx={ {
|
|
19
|
+
mt: 4,
|
|
20
|
+
...sx,
|
|
21
|
+
} }
|
|
22
|
+
>
|
|
23
|
+
{ children }
|
|
24
|
+
</TabsPrimitive.Content>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
TabsContent.propTypes = {
|
|
28
|
+
sx: PropTypes.object,
|
|
29
|
+
value: PropTypes.string,
|
|
30
|
+
children: PropTypes.node.isRequired,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { TabsContent };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const TabsList = ( { children, title, sx } ) => (
|
|
14
|
+
<TabsPrimitive.List
|
|
15
|
+
sx={ {
|
|
16
|
+
borderBottom: '1px solid',
|
|
17
|
+
borderColor: 'border',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
...sx,
|
|
20
|
+
} }
|
|
21
|
+
title={ title }
|
|
22
|
+
>
|
|
23
|
+
{ children }
|
|
24
|
+
</TabsPrimitive.List>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
TabsList.propTypes = {
|
|
28
|
+
sx: PropTypes.object,
|
|
29
|
+
title: PropTypes.string.isRequired,
|
|
30
|
+
children: PropTypes.node.isRequired,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { TabsList };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const styles = {
|
|
15
|
+
cursor: 'pointer',
|
|
16
|
+
background: 'none',
|
|
17
|
+
mr: 3,
|
|
18
|
+
fontSize: 2,
|
|
19
|
+
px: 0,
|
|
20
|
+
pb: 3,
|
|
21
|
+
border: 'none',
|
|
22
|
+
color: 'muted',
|
|
23
|
+
'&[data-state="active"]': {
|
|
24
|
+
color: 'heading',
|
|
25
|
+
fontWeight: 'body',
|
|
26
|
+
boxShadow: theme => `inset 0 -1px 0 0 ${ theme.colors.link }, 0 1px 0 0 ${ theme.colors.link }`,
|
|
27
|
+
},
|
|
28
|
+
'&:disabled': {
|
|
29
|
+
color: 'grey.70',
|
|
30
|
+
},
|
|
31
|
+
':hover': { fontWeight: 'body', color: 'heading' },
|
|
32
|
+
'&:focus': theme => theme.outline,
|
|
33
|
+
'&:focus-visible': theme => theme.outline,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const TabsTrigger = ( { value, disabled = false, sx, children } ) => (
|
|
37
|
+
<TabsPrimitive.TabsTrigger
|
|
38
|
+
className={ classNames( 'vip-tabs-trigger', `vip-tabs-trigger-${ value }` ) }
|
|
39
|
+
value={ value }
|
|
40
|
+
disabled={ disabled }
|
|
41
|
+
sx={ {
|
|
42
|
+
...styles,
|
|
43
|
+
...sx,
|
|
44
|
+
} }
|
|
45
|
+
>
|
|
46
|
+
{ children }
|
|
47
|
+
</TabsPrimitive.TabsTrigger>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
TabsTrigger.propTypes = {
|
|
51
|
+
sx: PropTypes.object,
|
|
52
|
+
value: PropTypes.string,
|
|
53
|
+
disabled: PropTypes.bool,
|
|
54
|
+
children: PropTypes.node.isRequired,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { TabsTrigger };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { NewTabs } from './Tabs';
|
|
5
|
+
import { TabsTrigger } from './TabsTrigger';
|
|
6
|
+
import { TabsList } from './TabsList';
|
|
7
|
+
import { TabsContent } from './TabsContent';
|
|
8
|
+
|
|
9
|
+
export { NewTabs, TabsList, TabsTrigger, TabsContent };
|
package/src/system/index.js
CHANGED
|
@@ -55,6 +55,7 @@ import { TabItem, Tabs } from './Tabs';
|
|
|
55
55
|
import { Text } from './Text';
|
|
56
56
|
import theme from './theme';
|
|
57
57
|
import { Wizard, WizardStep, WizardStepHorizontal } from './Wizard';
|
|
58
|
+
import { NewTabs, TabsList, TabsContent, TabsTrigger } from './NewTabs';
|
|
58
59
|
|
|
59
60
|
export {
|
|
60
61
|
Accordion,
|
|
@@ -103,6 +104,10 @@ export {
|
|
|
103
104
|
ToggleRow,
|
|
104
105
|
ToggleGroup,
|
|
105
106
|
TabItem,
|
|
107
|
+
NewTabs,
|
|
108
|
+
TabsTrigger,
|
|
109
|
+
TabsContent,
|
|
110
|
+
TabsList,
|
|
106
111
|
Time,
|
|
107
112
|
Timeline,
|
|
108
113
|
Validation,
|