baseui 10.11.1 → 11.0.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/README.md +3 -3
- package/accordion/accordion.js +60 -13
- package/accordion/accordion.js.flow +49 -12
- package/accordion/index.d.ts +0 -3
- package/accordion/panel.js +7 -6
- package/accordion/panel.js.flow +20 -20
- package/accordion/stateless-accordion.js +2 -4
- package/accordion/stateless-accordion.js.flow +0 -2
- package/accordion/types.js.flow +0 -5
- package/button/constants.js +1 -2
- package/button/constants.js.flow +0 -1
- package/button/index.d.ts +0 -1
- package/button/styled-components.js +2 -29
- package/button/styled-components.js.flow +2 -30
- package/checkbox/checkbox.js +6 -30
- package/checkbox/checkbox.js.flow +7 -38
- package/checkbox/constants.js +2 -1
- package/checkbox/constants.js.flow +2 -1
- package/checkbox/index.d.ts +4 -6
- package/checkbox/index.js +0 -6
- package/checkbox/index.js.flow +0 -1
- package/checkbox/styled-components.js +52 -149
- package/checkbox/styled-components.js.flow +59 -165
- package/checkbox/types.js.flow +0 -5
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +1 -1
- package/data-table/column-datetime.js +1 -1
- package/data-table/column-datetime.js.flow +3 -1
- package/data-table/column.js +6 -2
- package/data-table/column.js.flow +9 -7
- package/data-table/data-table.js +1 -1
- package/data-table/data-table.js.flow +1 -1
- package/data-table/header-cell.js +3 -0
- package/data-table/header-cell.js.flow +1 -1
- package/datepicker/calendar.js +15 -7
- package/datepicker/calendar.js.flow +23 -9
- package/datepicker/constants.js +12 -2
- package/datepicker/constants.js.flow +10 -0
- package/datepicker/datepicker.js +61 -30
- package/datepicker/datepicker.js.flow +77 -37
- package/datepicker/day.js +85 -34
- package/datepicker/day.js.flow +118 -54
- package/datepicker/locale.js.flow +0 -1
- package/datepicker/month.js +3 -1
- package/datepicker/month.js.flow +2 -0
- package/datepicker/stateful-container.js.flow +2 -1
- package/datepicker/styled-components.js +23 -1
- package/datepicker/styled-components.js.flow +12 -2
- package/datepicker/types.js.flow +35 -10
- package/datepicker/utils/date-helpers.js +30 -0
- package/datepicker/utils/date-helpers.js.flow +12 -0
- package/datepicker/week.js +3 -1
- package/datepicker/week.js.flow +2 -0
- package/es/accordion/accordion.js +52 -12
- package/es/accordion/panel.js +7 -5
- package/es/accordion/stateless-accordion.js +2 -4
- package/es/button/constants.js +1 -2
- package/es/button/styled-components.js +2 -29
- package/es/checkbox/checkbox.js +7 -32
- package/es/checkbox/constants.js +2 -1
- package/es/checkbox/index.js +1 -1
- package/es/checkbox/styled-components.js +51 -146
- package/es/data-table/column-categorical.js +1 -1
- package/es/data-table/column-datetime.js +1 -1
- package/es/data-table/column.js +6 -2
- package/es/data-table/data-table.js +1 -1
- package/es/data-table/header-cell.js +3 -0
- package/es/datepicker/calendar.js +15 -7
- package/es/datepicker/constants.js +8 -0
- package/es/datepicker/datepicker.js +56 -29
- package/es/datepicker/day.js +77 -34
- package/es/datepicker/month.js +3 -1
- package/es/datepicker/styled-components.js +8 -2
- package/es/datepicker/types.js +1 -1
- package/es/datepicker/utils/date-helpers.js +16 -0
- package/es/datepicker/week.js +3 -1
- package/es/file-uploader/file-uploader.js +4 -4
- package/es/header-navigation/styled-components.js +3 -3
- package/es/helpers/overrides.js +1 -2
- package/es/input/styled-components.js +4 -4
- package/es/layer/layer.js +4 -4
- package/es/locale/index.js +0 -7
- package/es/menu/stateful-container.js +0 -1
- package/es/menu/styled-components.js +1 -1
- package/es/modal/index.js +1 -1
- package/es/modal/modal.js +19 -65
- package/es/modal/styled-components.js +12 -48
- package/es/phone-input/default-props.js +1 -1
- package/es/phone-input/index.js +0 -4
- package/es/phone-input/phone-input-lite.js +55 -31
- package/es/radio/radio.js +1 -7
- package/es/radio/radiogroup.js +3 -28
- package/es/radio/styled-components.js +4 -5
- package/es/rating/styled-components.js +3 -3
- package/es/select/index.js +1 -2
- package/es/select/select-component.js +32 -20
- package/es/select/styled-components.js +4 -4
- package/es/snackbar/styled-components.js +2 -2
- package/es/spinner/index.js +3 -9
- package/es/spinner/styled-components.js +2 -32
- package/es/table/filter.js +3 -3
- package/es/tag/styled-components.js +1 -1
- package/es/themes/dark-theme/color-component-tokens.js +0 -38
- package/es/themes/dark-theme/color-tokens.js +0 -2
- package/es/themes/dark-theme/create-dark-theme.js +0 -2
- package/es/themes/dark-theme/dark-theme.js +0 -2
- package/es/themes/light-theme/color-component-tokens.js +0 -38
- package/es/themes/light-theme/color-tokens.js +0 -2
- package/es/themes/light-theme/create-light-theme.js +0 -2
- package/es/themes/light-theme/light-theme.js +0 -2
- package/es/timepicker/timepicker.js +1 -8
- package/es/typography/index.js +1 -31
- package/esm/accordion/accordion.js +60 -13
- package/esm/accordion/panel.js +7 -6
- package/esm/accordion/stateless-accordion.js +2 -4
- package/esm/button/constants.js +1 -2
- package/esm/button/styled-components.js +2 -29
- package/esm/checkbox/checkbox.js +7 -30
- package/esm/checkbox/constants.js +2 -1
- package/esm/checkbox/index.js +1 -1
- package/esm/checkbox/styled-components.js +52 -147
- package/esm/data-table/column-categorical.js +1 -1
- package/esm/data-table/column-datetime.js +1 -1
- package/esm/data-table/column.js +6 -2
- package/esm/data-table/data-table.js +1 -1
- package/esm/data-table/header-cell.js +3 -0
- package/esm/datepicker/calendar.js +15 -7
- package/esm/datepicker/constants.js +8 -0
- package/esm/datepicker/datepicker.js +60 -30
- package/esm/datepicker/day.js +84 -34
- package/esm/datepicker/month.js +3 -1
- package/esm/datepicker/styled-components.js +24 -2
- package/esm/datepicker/types.js +1 -1
- package/esm/datepicker/utils/date-helpers.js +30 -0
- package/esm/datepicker/week.js +3 -1
- package/esm/file-uploader/file-uploader.js +4 -4
- package/esm/header-navigation/styled-components.js +3 -3
- package/esm/helpers/overrides.js +1 -2
- package/esm/input/styled-components.js +4 -4
- package/esm/layer/layer.js +4 -4
- package/esm/locale/index.js +0 -7
- package/esm/menu/stateful-container.js +0 -1
- package/esm/menu/styled-components.js +1 -1
- package/esm/modal/index.js +1 -1
- package/esm/modal/modal.js +28 -71
- package/esm/modal/styled-components.js +6 -38
- package/esm/phone-input/default-props.js +1 -1
- package/esm/phone-input/index.js +0 -4
- package/esm/phone-input/phone-input-lite.js +60 -37
- package/esm/radio/radio.js +1 -7
- package/esm/radio/radiogroup.js +3 -28
- package/esm/radio/styled-components.js +4 -5
- package/esm/rating/styled-components.js +3 -3
- package/esm/select/index.js +1 -2
- package/esm/select/select-component.js +34 -19
- package/esm/select/styled-components.js +4 -4
- package/esm/snackbar/styled-components.js +2 -2
- package/esm/spinner/index.js +3 -9
- package/esm/spinner/styled-components.js +2 -40
- package/esm/table/filter.js +3 -3
- package/esm/tag/styled-components.js +1 -1
- package/esm/themes/dark-theme/color-component-tokens.js +0 -38
- package/esm/themes/dark-theme/color-tokens.js +0 -2
- package/esm/themes/dark-theme/create-dark-theme.js +1 -2
- package/esm/themes/dark-theme/dark-theme.js +1 -2
- package/esm/themes/light-theme/color-component-tokens.js +0 -38
- package/esm/themes/light-theme/color-tokens.js +0 -2
- package/esm/themes/light-theme/create-light-theme.js +1 -2
- package/esm/themes/light-theme/light-theme.js +1 -2
- package/esm/timepicker/timepicker.js +1 -8
- package/esm/typography/index.js +1 -35
- package/file-uploader/file-uploader.js +3 -3
- package/file-uploader/file-uploader.js.flow +4 -4
- package/header-navigation/styled-components.js +3 -3
- package/header-navigation/styled-components.js.flow +3 -3
- package/helpers/overrides.js +1 -2
- package/helpers/overrides.js.flow +1 -1
- package/input/index.d.ts +5 -9
- package/input/styled-components.js +4 -4
- package/input/styled-components.js.flow +4 -4
- package/layer/layer.js +4 -4
- package/layer/layer.js.flow +4 -3
- package/locale/index.js +0 -7
- package/locale/index.js.flow +0 -7
- package/locale.ts +0 -1
- package/menu/index.d.ts +1 -3
- package/menu/stateful-container.js +0 -1
- package/menu/stateful-container.js.flow +0 -1
- package/menu/styled-components.js +1 -1
- package/menu/styled-components.js.flow +1 -1
- package/modal/index.d.ts +4 -6
- package/modal/index.js +0 -6
- package/modal/index.js.flow +0 -1
- package/modal/modal.js +27 -70
- package/modal/modal.js.flow +17 -83
- package/modal/styled-components.js +7 -40
- package/modal/styled-components.js.flow +12 -44
- package/modal/types.js.flow +1 -10
- package/package.json +10 -10
- package/phone-input/default-props.js +1 -1
- package/phone-input/default-props.js.flow +1 -1
- package/phone-input/index.d.ts +0 -1
- package/phone-input/index.js +0 -36
- package/phone-input/index.js.flow +0 -4
- package/phone-input/phone-input-lite.js +63 -38
- package/phone-input/phone-input-lite.js.flow +66 -44
- package/progress-bar/index.d.ts +3 -3
- package/radio/index.d.ts +4 -9
- package/radio/radio.js +1 -7
- package/radio/radio.js.flow +1 -8
- package/radio/radiogroup.js +3 -28
- package/radio/radiogroup.js.flow +2 -26
- package/radio/styled-components.js +4 -5
- package/radio/styled-components.js.flow +3 -4
- package/radio/types.js.flow +4 -15
- package/rating/styled-components.js +3 -3
- package/rating/styled-components.js.flow +3 -3
- package/select/index.d.ts +8 -3
- package/select/index.js +0 -6
- package/select/index.js.flow +0 -2
- package/select/select-component.js +34 -19
- package/select/select-component.js.flow +29 -13
- package/select/styled-components.js +4 -4
- package/select/styled-components.js.flow +4 -4
- package/select/types.js.flow +11 -7
- package/snackbar/styled-components.js +1 -1
- package/snackbar/styled-components.js.flow +11 -11
- package/spinner/index.d.ts +5 -18
- package/spinner/index.js +2 -68
- package/spinner/index.js.flow +2 -27
- package/spinner/styled-components.js +9 -45
- package/spinner/styled-components.js.flow +2 -34
- package/spinner/types.js.flow +1 -19
- package/styles/types.js.flow +0 -2
- package/table/filter.js +3 -3
- package/table/filter.js.flow +3 -3
- package/tag/styled-components.js +1 -1
- package/tag/styled-components.js.flow +1 -1
- package/theme.ts +0 -81
- package/themes/dark-theme/color-component-tokens.js +0 -38
- package/themes/dark-theme/color-component-tokens.js.flow +0 -42
- package/themes/dark-theme/color-tokens.js +0 -2
- package/themes/dark-theme/color-tokens.js.flow +0 -2
- package/themes/dark-theme/create-dark-theme.js +1 -3
- package/themes/dark-theme/create-dark-theme.js.flow +0 -2
- package/themes/dark-theme/dark-theme.js +1 -3
- package/themes/dark-theme/dark-theme.js.flow +0 -2
- package/themes/light-theme/color-component-tokens.js +0 -38
- package/themes/light-theme/color-component-tokens.js.flow +0 -43
- package/themes/light-theme/color-tokens.js +0 -2
- package/themes/light-theme/color-tokens.js.flow +0 -2
- package/themes/light-theme/create-light-theme.js +1 -3
- package/themes/light-theme/create-light-theme.js.flow +0 -2
- package/themes/light-theme/light-theme.js +1 -3
- package/themes/light-theme/light-theme.js.flow +0 -2
- package/themes/types.js.flow +0 -68
- package/timepicker/timepicker.js +1 -8
- package/timepicker/timepicker.js.flow +4 -10
- package/typography/index.d.ts +0 -23
- package/typography/index.js +2 -57
- package/typography/index.js.flow +0 -31
- package/es/spinner/spinner.js +0 -68
- package/es/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -35
- package/es/themes/light-theme/color-deprecated-semantic-tokens.js +0 -35
- package/esm/spinner/spinner.js +0 -125
- package/esm/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -38
- package/esm/themes/light-theme/color-deprecated-semantic-tokens.js +0 -38
- package/spinner/spinner.js +0 -136
- package/spinner/spinner.js.flow +0 -75
- package/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/dark-theme/color-deprecated-semantic-tokens.js.flow +0 -42
- package/themes/light-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/light-theme/color-deprecated-semantic-tokens.js.flow +0 -42
package/README.md
CHANGED
|
@@ -24,14 +24,14 @@ Add `baseui` and its peer dependencies to your project:
|
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
26
|
# using yarn
|
|
27
|
-
yarn add baseui styletron-react styletron-engine-
|
|
27
|
+
yarn add baseui styletron-react styletron-engine-monolithic
|
|
28
28
|
|
|
29
29
|
# using npm
|
|
30
|
-
npm install baseui styletron-react styletron-engine-
|
|
30
|
+
npm install baseui styletron-react styletron-engine-monolithic
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
```javascript
|
|
34
|
-
import {Client as Styletron} from 'styletron-engine-
|
|
34
|
+
import {Client as Styletron} from 'styletron-engine-monolithic';
|
|
35
35
|
import {Provider as StyletronProvider} from 'styletron-react';
|
|
36
36
|
import {LightTheme, BaseProvider, styled} from 'baseui';
|
|
37
37
|
import {StatefulInput} from 'baseui/input';
|
package/accordion/accordion.js
CHANGED
|
@@ -87,6 +87,8 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
87
87
|
expanded: []
|
|
88
88
|
}, _this.props.initialState));
|
|
89
89
|
|
|
90
|
+
_defineProperty(_assertThisInitialized(_this), "itemRefs", []);
|
|
91
|
+
|
|
90
92
|
return _this;
|
|
91
93
|
}
|
|
92
94
|
|
|
@@ -133,6 +135,56 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
133
135
|
this.setState(newState);
|
|
134
136
|
typeof onChange === 'function' && onChange(newState);
|
|
135
137
|
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "handleKeyDown",
|
|
140
|
+
value: function handleKeyDown(e) {
|
|
141
|
+
if (this.props.disabled) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
var itemRefs = this.itemRefs;
|
|
146
|
+
var HOME = 36;
|
|
147
|
+
var END = 35;
|
|
148
|
+
var ARROW_UP = 38;
|
|
149
|
+
var ARROW_DOWN = 40;
|
|
150
|
+
|
|
151
|
+
if (e.keyCode === HOME) {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
var firstItem = itemRefs[0];
|
|
154
|
+
firstItem.current && firstItem.current.focus();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (e.keyCode === END) {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
var lastItem = itemRefs[itemRefs.length - 1];
|
|
160
|
+
lastItem.current && lastItem.current.focus();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (e.keyCode === ARROW_UP) {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
var activeItemIdx = itemRefs.findIndex(function (item) {
|
|
166
|
+
return item.current === document.activeElement;
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
if (activeItemIdx > 0) {
|
|
170
|
+
var prevItem = itemRefs[activeItemIdx - 1];
|
|
171
|
+
prevItem.current && prevItem.current.focus();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (e.keyCode === ARROW_DOWN) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
|
|
178
|
+
var _activeItemIdx = itemRefs.findIndex(function (item) {
|
|
179
|
+
return item.current === document.activeElement;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
if (_activeItemIdx < itemRefs.length - 1) {
|
|
183
|
+
var nextItem = itemRefs[_activeItemIdx + 1];
|
|
184
|
+
nextItem.current && nextItem.current.focus();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
136
188
|
}, {
|
|
137
189
|
key: "getItems",
|
|
138
190
|
value: function getItems() {
|
|
@@ -143,12 +195,15 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
143
195
|
accordion = _this$props2.accordion,
|
|
144
196
|
disabled = _this$props2.disabled,
|
|
145
197
|
children = _this$props2.children,
|
|
146
|
-
renderPanelContent = _this$props2.renderPanelContent,
|
|
147
198
|
renderAll = _this$props2.renderAll,
|
|
148
199
|
overrides = _this$props2.overrides; // flowlint-next-line unclear-type:off
|
|
149
200
|
|
|
150
201
|
return React.Children.map(children, function (child, index) {
|
|
151
|
-
if (!child) return;
|
|
202
|
+
if (!child) return;
|
|
203
|
+
var itemRef = /*#__PURE__*/React.createRef();
|
|
204
|
+
|
|
205
|
+
_this2.itemRefs.push(itemRef); // If there is no key provided use the panel order as a default key
|
|
206
|
+
|
|
152
207
|
|
|
153
208
|
var key = child.key || String(index);
|
|
154
209
|
var isExpanded = false;
|
|
@@ -161,9 +216,9 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
161
216
|
|
|
162
217
|
var props = {
|
|
163
218
|
key: key,
|
|
219
|
+
ref: itemRef,
|
|
164
220
|
expanded: isExpanded || child.props.expanded,
|
|
165
221
|
accordion: accordion,
|
|
166
|
-
renderPanelContent: renderPanelContent,
|
|
167
222
|
renderAll: renderAll,
|
|
168
223
|
overrides: child.props.overrides || overrides,
|
|
169
224
|
disabled: child.props.disabled || disabled,
|
|
@@ -178,14 +233,6 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
178
233
|
return /*#__PURE__*/React.cloneElement(child, props);
|
|
179
234
|
});
|
|
180
235
|
}
|
|
181
|
-
}, {
|
|
182
|
-
key: "componentDidMount",
|
|
183
|
-
value: function componentDidMount() {
|
|
184
|
-
// TODO(v11)
|
|
185
|
-
if (process.env.NODE_ENV !== "production" && this.props.renderPanelContent) {
|
|
186
|
-
console.warn('baseui:Accordion The `renderPanelContent` prop is deprecated. Please update your code to use `renderAll`.');
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
236
|
}, {
|
|
190
237
|
key: "render",
|
|
191
238
|
value: function render() {
|
|
@@ -201,7 +248,8 @@ var Accordion = /*#__PURE__*/function (_React$Component) {
|
|
|
201
248
|
return /*#__PURE__*/React.createElement(Root, _extends({
|
|
202
249
|
"data-baseweb": "accordion",
|
|
203
250
|
$disabled: this.props.disabled,
|
|
204
|
-
$isFocusVisible: false
|
|
251
|
+
$isFocusVisible: false,
|
|
252
|
+
onKeyDown: this.handleKeyDown.bind(this)
|
|
205
253
|
}, rootProps), this.getItems());
|
|
206
254
|
}
|
|
207
255
|
}]);
|
|
@@ -220,7 +268,6 @@ _defineProperty(Accordion, "defaultProps", {
|
|
|
220
268
|
onChange: function onChange() {},
|
|
221
269
|
overrides: {},
|
|
222
270
|
renderAll: false,
|
|
223
|
-
renderPanelContent: false,
|
|
224
271
|
stateReducer: function stateReducer(type, newState) {
|
|
225
272
|
return newState;
|
|
226
273
|
}
|
|
@@ -22,7 +22,6 @@ export default class Accordion extends React.Component<AccordionPropsT, Accordio
|
|
|
22
22
|
onChange: () => {},
|
|
23
23
|
overrides: {},
|
|
24
24
|
renderAll: false,
|
|
25
|
-
renderPanelContent: false,
|
|
26
25
|
stateReducer: (type, newState) => newState,
|
|
27
26
|
};
|
|
28
27
|
|
|
@@ -31,6 +30,8 @@ export default class Accordion extends React.Component<AccordionPropsT, Accordio
|
|
|
31
30
|
...this.props.initialState,
|
|
32
31
|
};
|
|
33
32
|
|
|
33
|
+
itemRefs = [];
|
|
34
|
+
|
|
34
35
|
//flowlint-next-line unclear-type:off
|
|
35
36
|
onPanelChange(key: React.Key, onChange: () => {}, ...args: Array<any>) {
|
|
36
37
|
let activeKeys = this.state.expanded;
|
|
@@ -61,12 +62,56 @@ export default class Accordion extends React.Component<AccordionPropsT, Accordio
|
|
|
61
62
|
typeof onChange === 'function' && onChange(newState);
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
handleKeyDown(e: KeyboardEvent) {
|
|
66
|
+
if (this.props.disabled) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const itemRefs = this.itemRefs;
|
|
71
|
+
|
|
72
|
+
const HOME = 36;
|
|
73
|
+
const END = 35;
|
|
74
|
+
const ARROW_UP = 38;
|
|
75
|
+
const ARROW_DOWN = 40;
|
|
76
|
+
|
|
77
|
+
if (e.keyCode === HOME) {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
const firstItem = itemRefs[0];
|
|
80
|
+
firstItem.current && firstItem.current.focus();
|
|
81
|
+
}
|
|
82
|
+
if (e.keyCode === END) {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
const lastItem = itemRefs[itemRefs.length - 1];
|
|
85
|
+
lastItem.current && lastItem.current.focus();
|
|
86
|
+
}
|
|
87
|
+
if (e.keyCode === ARROW_UP) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
const activeItemIdx = itemRefs.findIndex((item) => item.current === document.activeElement);
|
|
90
|
+
if (activeItemIdx > 0) {
|
|
91
|
+
const prevItem = itemRefs[activeItemIdx - 1];
|
|
92
|
+
prevItem.current && prevItem.current.focus();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (e.keyCode === ARROW_DOWN) {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
const activeItemIdx = itemRefs.findIndex((item) => item.current === document.activeElement);
|
|
98
|
+
if (activeItemIdx < itemRefs.length - 1) {
|
|
99
|
+
const nextItem = itemRefs[activeItemIdx + 1];
|
|
100
|
+
nextItem.current && nextItem.current.focus();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
64
105
|
getItems() {
|
|
65
106
|
const { expanded } = this.state;
|
|
66
|
-
const { accordion, disabled, children,
|
|
107
|
+
const { accordion, disabled, children, renderAll, overrides } = this.props;
|
|
67
108
|
// flowlint-next-line unclear-type:off
|
|
68
109
|
return React.Children.map(children, (child: any, index) => {
|
|
69
110
|
if (!child) return;
|
|
111
|
+
|
|
112
|
+
const itemRef = React.createRef<HTMLDivElement>();
|
|
113
|
+
this.itemRefs.push(itemRef);
|
|
114
|
+
|
|
70
115
|
// If there is no key provided use the panel order as a default key
|
|
71
116
|
const key = child.key || String(index);
|
|
72
117
|
let isExpanded = false;
|
|
@@ -78,9 +123,9 @@ export default class Accordion extends React.Component<AccordionPropsT, Accordio
|
|
|
78
123
|
|
|
79
124
|
const props = {
|
|
80
125
|
key,
|
|
126
|
+
ref: itemRef,
|
|
81
127
|
expanded: isExpanded || child.props.expanded,
|
|
82
128
|
accordion,
|
|
83
|
-
renderPanelContent,
|
|
84
129
|
renderAll,
|
|
85
130
|
overrides: child.props.overrides || overrides,
|
|
86
131
|
disabled: child.props.disabled || disabled,
|
|
@@ -90,15 +135,6 @@ export default class Accordion extends React.Component<AccordionPropsT, Accordio
|
|
|
90
135
|
});
|
|
91
136
|
}
|
|
92
137
|
|
|
93
|
-
componentDidMount() {
|
|
94
|
-
// TODO(v11)
|
|
95
|
-
if (__DEV__ && this.props.renderPanelContent) {
|
|
96
|
-
console.warn(
|
|
97
|
-
'baseui:Accordion The `renderPanelContent` prop is deprecated. Please update your code to use `renderAll`.'
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
138
|
render() {
|
|
103
139
|
const { overrides = {} } = this.props;
|
|
104
140
|
const { Root: RootOverride } = overrides;
|
|
@@ -108,6 +144,7 @@ export default class Accordion extends React.Component<AccordionPropsT, Accordio
|
|
|
108
144
|
data-baseweb="accordion"
|
|
109
145
|
$disabled={this.props.disabled}
|
|
110
146
|
$isFocusVisible={false}
|
|
147
|
+
onKeyDown={this.handleKeyDown.bind(this)}
|
|
111
148
|
{...rootProps}
|
|
112
149
|
>
|
|
113
150
|
{this.getItems()}
|
package/accordion/index.d.ts
CHANGED
|
@@ -37,7 +37,6 @@ export interface AccordionProps {
|
|
|
37
37
|
onChange?: (args: {expanded: React.Key[]}) => any;
|
|
38
38
|
overrides?: AccordionOverrides<SharedProps>;
|
|
39
39
|
stateReducer?: StateReducer<AccordionState>;
|
|
40
|
-
renderPanelContent?: boolean;
|
|
41
40
|
renderAll?: boolean;
|
|
42
41
|
}
|
|
43
42
|
|
|
@@ -48,7 +47,6 @@ export type StatelessAccordionProps = {
|
|
|
48
47
|
expanded: React.Key[];
|
|
49
48
|
onChange?: (args: {expanded: React.Key[]; key: React.Key}) => any;
|
|
50
49
|
overrides?: AccordionOverrides<SharedProps> & PanelOverrides<SharedProps>;
|
|
51
|
-
renderPanelContent?: boolean;
|
|
52
50
|
renderAll?: boolean;
|
|
53
51
|
};
|
|
54
52
|
|
|
@@ -85,7 +83,6 @@ export interface SharedPanelProps {
|
|
|
85
83
|
onKeyDown?: (e: KeyboardEvent) => any;
|
|
86
84
|
overrides?: PanelOverrides<SharedProps>;
|
|
87
85
|
title?: React.ReactNode;
|
|
88
|
-
renderPanelContent?: boolean;
|
|
89
86
|
renderAll?: boolean;
|
|
90
87
|
}
|
|
91
88
|
|
package/accordion/panel.js
CHANGED
|
@@ -41,7 +41,7 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
|
|
|
41
41
|
|
|
42
42
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
43
43
|
|
|
44
|
-
var Panel = function Panel(_ref) {
|
|
44
|
+
var Panel = function Panel(_ref, ref) {
|
|
45
45
|
var ariaControls = _ref['aria-controls'],
|
|
46
46
|
children = _ref.children,
|
|
47
47
|
_ref$disabled = _ref.disabled,
|
|
@@ -58,8 +58,6 @@ var Panel = function Panel(_ref) {
|
|
|
58
58
|
overrides = _ref$overrides === void 0 ? {} : _ref$overrides,
|
|
59
59
|
_ref$title = _ref.title,
|
|
60
60
|
title = _ref$title === void 0 ? '' : _ref$title,
|
|
61
|
-
_ref$renderPanelConte = _ref.renderPanelContent,
|
|
62
|
-
renderPanelContent = _ref$renderPanelConte === void 0 ? false : _ref$renderPanelConte,
|
|
63
61
|
_ref$renderAll = _ref.renderAll,
|
|
64
62
|
renderAll = _ref$renderAll === void 0 ? false : _ref$renderAll;
|
|
65
63
|
|
|
@@ -214,7 +212,8 @@ var Panel = function Panel(_ref) {
|
|
|
214
212
|
onClick: handleClick,
|
|
215
213
|
onKeyDown: handleKeyDown,
|
|
216
214
|
onFocus: (0, _focusVisible.forkFocus)(headerProps, handleFocus),
|
|
217
|
-
onBlur: (0, _focusVisible.forkBlur)(headerProps, handleBlur)
|
|
215
|
+
onBlur: (0, _focusVisible.forkBlur)(headerProps, handleBlur),
|
|
216
|
+
ref: ref
|
|
218
217
|
}), title, /*#__PURE__*/React.createElement(ToggleIcon, _extends({
|
|
219
218
|
viewBox: "0 0 24 24",
|
|
220
219
|
title: localState.expanded ? locale.accordion.collapse : locale.accordion.expand,
|
|
@@ -240,9 +239,11 @@ var Panel = function Panel(_ref) {
|
|
|
240
239
|
ref: _animateRef
|
|
241
240
|
}, sharedProps, contentProps, ariaControls ? {
|
|
242
241
|
id: ariaControls
|
|
243
|
-
} : {}), localState.expanded || renderAll ||
|
|
242
|
+
} : {}), localState.expanded || renderAll || localState.animationInProgress ? children : null)));
|
|
244
243
|
});
|
|
245
244
|
};
|
|
246
245
|
|
|
247
|
-
var
|
|
246
|
+
var ForwardedPanel = /*#__PURE__*/React.forwardRef(Panel);
|
|
247
|
+
ForwardedPanel.displayName = 'Panel';
|
|
248
|
+
var _default = ForwardedPanel;
|
|
248
249
|
exports.default = _default;
|
package/accordion/panel.js.flow
CHANGED
|
@@ -20,19 +20,21 @@ import { isFocusVisible, forkFocus, forkBlur } from '../utils/focusVisible.js';
|
|
|
20
20
|
|
|
21
21
|
import type { PanelPropsT } from './types.js';
|
|
22
22
|
|
|
23
|
-
const Panel = (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}: PanelPropsT
|
|
23
|
+
const Panel = (
|
|
24
|
+
{
|
|
25
|
+
'aria-controls': ariaControls,
|
|
26
|
+
children,
|
|
27
|
+
disabled = false,
|
|
28
|
+
expanded = false,
|
|
29
|
+
onChange = () => {},
|
|
30
|
+
onClick = () => {},
|
|
31
|
+
onKeyDown = () => {},
|
|
32
|
+
overrides = {},
|
|
33
|
+
title = '',
|
|
34
|
+
renderAll = false,
|
|
35
|
+
}: PanelPropsT,
|
|
36
|
+
ref
|
|
37
|
+
) => {
|
|
36
38
|
const [localState, setLocalState] = React.useState({
|
|
37
39
|
expanded,
|
|
38
40
|
isFocusVisible: false,
|
|
@@ -176,6 +178,7 @@ const Panel = ({
|
|
|
176
178
|
onKeyDown={handleKeyDown}
|
|
177
179
|
onFocus={forkFocus(headerProps, handleFocus)}
|
|
178
180
|
onBlur={forkBlur(headerProps, handleBlur)}
|
|
181
|
+
ref={ref}
|
|
179
182
|
>
|
|
180
183
|
{title}
|
|
181
184
|
<ToggleIcon
|
|
@@ -215,12 +218,7 @@ const Panel = ({
|
|
|
215
218
|
{...contentProps}
|
|
216
219
|
{...(ariaControls ? { id: ariaControls } : {})}
|
|
217
220
|
>
|
|
218
|
-
{localState.expanded ||
|
|
219
|
-
renderAll ||
|
|
220
|
-
renderPanelContent ||
|
|
221
|
-
localState.animationInProgress
|
|
222
|
-
? children
|
|
223
|
-
: null}
|
|
221
|
+
{localState.expanded || renderAll || localState.animationInProgress ? children : null}
|
|
224
222
|
</Content>
|
|
225
223
|
</ContentAnimationContainer>
|
|
226
224
|
</PanelContainer>
|
|
@@ -229,7 +227,9 @@ const Panel = ({
|
|
|
229
227
|
);
|
|
230
228
|
};
|
|
231
229
|
|
|
232
|
-
|
|
230
|
+
const ForwardedPanel = React.forwardRef<PanelPropsT, HTMLElement>(Panel);
|
|
231
|
+
ForwardedPanel.displayName = 'Panel';
|
|
232
|
+
export default ForwardedPanel;
|
|
233
233
|
|
|
234
234
|
declare var __DEV__: boolean;
|
|
235
235
|
declare var __NODE__: boolean;
|
|
@@ -52,8 +52,7 @@ function StatelessAccordion(_ref) {
|
|
|
52
52
|
onChange = _ref.onChange,
|
|
53
53
|
_ref$overrides = _ref.overrides,
|
|
54
54
|
overrides = _ref$overrides === void 0 ? {} : _ref$overrides,
|
|
55
|
-
renderAll = _ref.renderAll
|
|
56
|
-
renderPanelContent = _ref.renderPanelContent;
|
|
55
|
+
renderAll = _ref.renderAll;
|
|
57
56
|
|
|
58
57
|
var RootOverrides = overrides.Root,
|
|
59
58
|
PanelOverrides = _objectWithoutProperties(overrides, ["Root"]);
|
|
@@ -97,8 +96,7 @@ function StatelessAccordion(_ref) {
|
|
|
97
96
|
});
|
|
98
97
|
} : onChange,
|
|
99
98
|
overrides: child.props.overrides || PanelOverrides,
|
|
100
|
-
renderAll: renderAll
|
|
101
|
-
renderPanelContent: renderPanelContent
|
|
99
|
+
renderAll: renderAll
|
|
102
100
|
});
|
|
103
101
|
}));
|
|
104
102
|
}
|
|
@@ -18,7 +18,6 @@ function StatelessAccordion({
|
|
|
18
18
|
onChange,
|
|
19
19
|
overrides = {},
|
|
20
20
|
renderAll,
|
|
21
|
-
renderPanelContent,
|
|
22
21
|
}: StatelessAccordionPropsT) {
|
|
23
22
|
const { Root: RootOverrides, ...PanelOverrides } = overrides;
|
|
24
23
|
const [Root, rootProps] = getOverrides(RootOverrides, StyledRoot);
|
|
@@ -53,7 +52,6 @@ function StatelessAccordion({
|
|
|
53
52
|
: onChange,
|
|
54
53
|
overrides: child.props.overrides || PanelOverrides,
|
|
55
54
|
renderAll,
|
|
56
|
-
renderPanelContent,
|
|
57
55
|
});
|
|
58
56
|
})}
|
|
59
57
|
</Root>
|
package/accordion/types.js.flow
CHANGED
|
@@ -77,11 +77,6 @@ export type AccordionPropsT = {
|
|
|
77
77
|
/** Handler called each time the component state changes.
|
|
78
78
|
* Used to override default state-change functionality. */
|
|
79
79
|
stateReducer: StateReducerT,
|
|
80
|
-
/**
|
|
81
|
-
* Allows users to render all child content whether a panel is expanded or not
|
|
82
|
-
* for SEO purposed
|
|
83
|
-
*/
|
|
84
|
-
renderPanelContent?: boolean,
|
|
85
80
|
/**
|
|
86
81
|
* Allows users to render all child content whether a panel is expanded or not
|
|
87
82
|
* for SEO purposed
|
package/button/constants.js
CHANGED
package/button/constants.js.flow
CHANGED
package/button/index.d.ts
CHANGED
|
@@ -215,14 +215,6 @@ function getLoadingSpinnerColors(_ref8) {
|
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
case _constants.KIND.minimal:
|
|
219
|
-
{
|
|
220
|
-
return {
|
|
221
|
-
foreground: $theme.colors.buttonMinimalSpinnerForeground,
|
|
222
|
-
background: $theme.colors.buttonMinimalSpinnerBackground
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
|
|
226
218
|
case _constants.KIND.primary:
|
|
227
219
|
default:
|
|
228
220
|
{
|
|
@@ -291,7 +283,7 @@ function getDisabledStyles(_ref11) {
|
|
|
291
283
|
color: $theme.colors.buttonDisabledActiveText,
|
|
292
284
|
backgroundColor: $theme.colors.buttonDisabledActiveFill
|
|
293
285
|
};
|
|
294
|
-
} else if ($kind === _constants.KIND.
|
|
286
|
+
} else if ($kind === _constants.KIND.tertiary) {
|
|
295
287
|
return {
|
|
296
288
|
backgroundColor: $theme.colors.buttonTertiaryDisabledActiveFill,
|
|
297
289
|
color: $theme.colors.buttonTertiaryDisabledActiveText
|
|
@@ -300,7 +292,7 @@ function getDisabledStyles(_ref11) {
|
|
|
300
292
|
}
|
|
301
293
|
|
|
302
294
|
return {
|
|
303
|
-
backgroundColor: $kind === _constants.KIND.
|
|
295
|
+
backgroundColor: $kind === _constants.KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
|
|
304
296
|
color: $theme.colors.buttonDisabledText
|
|
305
297
|
};
|
|
306
298
|
}
|
|
@@ -429,25 +421,6 @@ function getColorStyles(_ref13) {
|
|
|
429
421
|
}
|
|
430
422
|
};
|
|
431
423
|
|
|
432
|
-
case _constants.KIND.minimal:
|
|
433
|
-
if ($isSelected) {
|
|
434
|
-
return {
|
|
435
|
-
color: $theme.colors.buttonMinimalSelectedText,
|
|
436
|
-
backgroundColor: $theme.colors.buttonMinimalSelectedFill
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
return {
|
|
441
|
-
color: $theme.colors.buttonMinimalText,
|
|
442
|
-
backgroundColor: $theme.colors.buttonMinimalFill,
|
|
443
|
-
':hover': {
|
|
444
|
-
backgroundColor: $isLoading ? $theme.colors.buttonMinimalActive : $theme.colors.buttonMinimalHover
|
|
445
|
-
},
|
|
446
|
-
':active': {
|
|
447
|
-
backgroundColor: $theme.colors.buttonMinimalActive
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
|
|
451
424
|
default:
|
|
452
425
|
return Object.freeze({});
|
|
453
426
|
}
|
|
@@ -175,12 +175,6 @@ function getLoadingSpinnerColors({ $theme, $kind, $disabled }) {
|
|
|
175
175
|
background: $theme.colors.buttonTertiarySpinnerBackground,
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
|
-
case KIND.minimal: {
|
|
179
|
-
return {
|
|
180
|
-
foreground: $theme.colors.buttonMinimalSpinnerForeground,
|
|
181
|
-
background: $theme.colors.buttonMinimalSpinnerBackground,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
178
|
case KIND.primary:
|
|
185
179
|
default: {
|
|
186
180
|
return {
|
|
@@ -234,7 +228,7 @@ function getDisabledStyles({ $theme, $kind, $isSelected, $disabled }) {
|
|
|
234
228
|
color: $theme.colors.buttonDisabledActiveText,
|
|
235
229
|
backgroundColor: $theme.colors.buttonDisabledActiveFill,
|
|
236
230
|
};
|
|
237
|
-
} else if ($kind === KIND.
|
|
231
|
+
} else if ($kind === KIND.tertiary) {
|
|
238
232
|
return {
|
|
239
233
|
backgroundColor: $theme.colors.buttonTertiaryDisabledActiveFill,
|
|
240
234
|
color: $theme.colors.buttonTertiaryDisabledActiveText,
|
|
@@ -243,10 +237,7 @@ function getDisabledStyles({ $theme, $kind, $isSelected, $disabled }) {
|
|
|
243
237
|
}
|
|
244
238
|
|
|
245
239
|
return {
|
|
246
|
-
backgroundColor:
|
|
247
|
-
$kind === KIND.minimal || $kind === KIND.tertiary
|
|
248
|
-
? 'transparent'
|
|
249
|
-
: $theme.colors.buttonDisabledFill,
|
|
240
|
+
backgroundColor: $kind === KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
|
|
250
241
|
color: $theme.colors.buttonDisabledText,
|
|
251
242
|
};
|
|
252
243
|
}
|
|
@@ -383,25 +374,6 @@ function getColorStyles({
|
|
|
383
374
|
backgroundColor: $theme.colors.buttonTertiaryActive,
|
|
384
375
|
},
|
|
385
376
|
};
|
|
386
|
-
case KIND.minimal:
|
|
387
|
-
if ($isSelected) {
|
|
388
|
-
return {
|
|
389
|
-
color: $theme.colors.buttonMinimalSelectedText,
|
|
390
|
-
backgroundColor: $theme.colors.buttonMinimalSelectedFill,
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
return {
|
|
394
|
-
color: $theme.colors.buttonMinimalText,
|
|
395
|
-
backgroundColor: $theme.colors.buttonMinimalFill,
|
|
396
|
-
':hover': {
|
|
397
|
-
backgroundColor: $isLoading
|
|
398
|
-
? $theme.colors.buttonMinimalActive
|
|
399
|
-
: $theme.colors.buttonMinimalHover,
|
|
400
|
-
},
|
|
401
|
-
':active': {
|
|
402
|
-
backgroundColor: $theme.colors.buttonMinimalActive,
|
|
403
|
-
},
|
|
404
|
-
};
|
|
405
377
|
default:
|
|
406
378
|
return Object.freeze({});
|
|
407
379
|
}
|