@pingux/astro 2.218.0 → 2.219.0-alpha.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/lib/cjs/components/NumberField/NumberField.d.ts +4 -0
- package/lib/cjs/components/NumberField/NumberField.js +21 -93
- package/lib/cjs/components/NumberField/NumberField.styles.d.ts +19 -0
- package/lib/cjs/components/NumberField/index.d.ts +1 -0
- package/lib/cjs/components/TableBase/TableBase.js +12 -6
- package/lib/cjs/components/TableBase/TableBase.mdx +14 -20
- package/lib/cjs/components/TableBase/TableBase.stories.js +148 -2
- package/lib/cjs/components/TableBase/TableBase.styles.d.ts +33 -0
- package/lib/cjs/components/TableBase/TableBase.styles.js +31 -5
- package/lib/cjs/components/TableBase/TableBase.test.js +243 -433
- package/lib/cjs/hooks/useField/useField.d.ts +2 -0
- package/lib/cjs/hooks/useSliderField/useSliderField.d.ts +3 -0
- package/lib/cjs/types/box.d.ts +1 -0
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +35 -24
- package/lib/cjs/types/numberField.d.ts +30 -0
- package/lib/cjs/types/numberField.js +6 -0
- package/lib/components/NumberField/NumberField.js +23 -95
- package/lib/components/TableBase/TableBase.js +12 -6
- package/lib/components/TableBase/TableBase.mdx +14 -20
- package/lib/components/TableBase/TableBase.stories.js +147 -1
- package/lib/components/TableBase/TableBase.styles.js +31 -5
- package/lib/components/TableBase/TableBase.test.js +243 -433
- package/lib/types/index.js +1 -0
- package/lib/types/numberField.js +1 -0
- package/package.json +1 -1
|
@@ -22,18 +22,15 @@ var _reactAria = require("react-aria");
|
|
|
22
22
|
var _reactStately = require("react-stately");
|
|
23
23
|
var _i18n = require("@react-aria/i18n");
|
|
24
24
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
25
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
26
25
|
var _uuid = require("uuid");
|
|
27
26
|
var _ = require("../..");
|
|
28
27
|
var _hooks = require("../../hooks");
|
|
29
28
|
var _pendoID = require("../../utils/devUtils/constants/pendoID");
|
|
30
|
-
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
|
31
|
-
var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
|
32
|
-
var _statusProp = require("../../utils/docUtils/statusProp");
|
|
33
29
|
var _react2 = require("@emotion/react");
|
|
34
30
|
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
35
31
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
36
32
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
33
|
+
var displayName = 'NumberField';
|
|
37
34
|
var NumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
38
35
|
var helperText = props.helperText,
|
|
39
36
|
status = props.status;
|
|
@@ -48,9 +45,9 @@ var NumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
48
45
|
var state = (0, _reactStately.useNumberFieldState)(_objectSpread(_objectSpread({}, props), {}, {
|
|
49
46
|
locale: locale
|
|
50
47
|
}));
|
|
51
|
-
var inputRef =
|
|
52
|
-
var incrRef = _react["default"].useRef();
|
|
53
|
-
var decRef = _react["default"].useRef();
|
|
48
|
+
var inputRef = (0, _hooks.useLocalOrForwardRef)(ref);
|
|
49
|
+
var incrRef = _react["default"].useRef(null);
|
|
50
|
+
var decRef = _react["default"].useRef(null);
|
|
54
51
|
var _useNumberField = (0, _reactAria.useNumberField)(props, state, inputRef),
|
|
55
52
|
labelProps = _useNumberField.labelProps,
|
|
56
53
|
groupProps = _useNumberField.groupProps,
|
|
@@ -63,16 +60,12 @@ var NumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
63
60
|
fieldControlWrapperProps = _useField.fieldControlWrapperProps,
|
|
64
61
|
fieldLabelProps = _useField.fieldLabelProps;
|
|
65
62
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
|
66
|
-
/* istanbul ignore next */
|
|
67
|
-
(0, _react.useImperativeHandle)(ref, function () {
|
|
68
|
-
return inputRef.current;
|
|
69
|
-
});
|
|
70
63
|
var ControlArrows = (0, _react2.jsx)(_.Box, {
|
|
71
64
|
variant: "forms.numberField.arrows"
|
|
72
65
|
}, (0, _react2.jsx)(_.IconButton, (0, _extends2["default"])({}, incrementButtonProps, {
|
|
73
|
-
ref:
|
|
74
|
-
tabIndex:
|
|
75
|
-
p: !isOnyx
|
|
66
|
+
ref: incrRef,
|
|
67
|
+
tabIndex: 0,
|
|
68
|
+
p: !isOnyx ? 0 : undefined
|
|
76
69
|
}), (0, _react2.jsx)(_.Icon, {
|
|
77
70
|
icon: MenuUp,
|
|
78
71
|
size: numberFieldArrowSize,
|
|
@@ -81,9 +74,9 @@ var NumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
81
74
|
},
|
|
82
75
|
"aria-hidden": "true"
|
|
83
76
|
})), (0, _react2.jsx)(_.IconButton, (0, _extends2["default"])({}, decrementButtonProps, {
|
|
84
|
-
ref:
|
|
85
|
-
tabIndex:
|
|
86
|
-
p: !isOnyx
|
|
77
|
+
ref: decRef,
|
|
78
|
+
tabIndex: 0,
|
|
79
|
+
p: !isOnyx ? 0 : undefined
|
|
87
80
|
}), (0, _react2.jsx)(_.Icon, {
|
|
88
81
|
icon: MenuDown,
|
|
89
82
|
size: numberFieldArrowSize,
|
|
@@ -92,18 +85,16 @@ var NumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
92
85
|
},
|
|
93
86
|
"aria-hidden": "true"
|
|
94
87
|
})));
|
|
95
|
-
|
|
96
|
-
// this needed to remove console warning in React 16
|
|
97
|
-
// I believe once we update to 17 - we can remove this
|
|
88
|
+
var typedFieldControlInputProps = fieldControlInputProps;
|
|
98
89
|
var onInputFocus = function onInputFocus(e) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
inputProps.onFocus(e);
|
|
90
|
+
var _typedFieldControlInp, _inputProps$onFocus;
|
|
91
|
+
(_typedFieldControlInp = typedFieldControlInputProps.onFocus) === null || _typedFieldControlInp === void 0 || _typedFieldControlInp.call(typedFieldControlInputProps, e);
|
|
92
|
+
(_inputProps$onFocus = inputProps.onFocus) === null || _inputProps$onFocus === void 0 || _inputProps$onFocus.call(inputProps, e);
|
|
102
93
|
};
|
|
103
94
|
var onInputBlur = function onInputBlur(e) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
inputProps.onBlur(e);
|
|
95
|
+
var _typedFieldControlInp2, _inputProps$onBlur;
|
|
96
|
+
(_typedFieldControlInp2 = typedFieldControlInputProps.onBlur) === null || _typedFieldControlInp2 === void 0 || _typedFieldControlInp2.call(typedFieldControlInputProps, e);
|
|
97
|
+
(_inputProps$onBlur = inputProps.onBlur) === null || _inputProps$onBlur === void 0 || _inputProps$onBlur.call(inputProps, e);
|
|
107
98
|
};
|
|
108
99
|
var updatedFieldControlInputProps = _objectSpread(_objectSpread({}, fieldControlInputProps), {}, {
|
|
109
100
|
onFocus: onInputFocus,
|
|
@@ -113,13 +104,13 @@ var NumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
113
104
|
var updatedLabelProps = _objectSpread({}, (0, _reactAria.mergeProps)(fieldLabelProps, labelProps));
|
|
114
105
|
var inputPropsValue = inputProps.value || 0;
|
|
115
106
|
var inputPropsNumericValue = state.numberValue;
|
|
116
|
-
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({}, (0, _pendoID.getPendoID)(
|
|
107
|
+
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({}, (0, _pendoID.getPendoID)(displayName), fieldContainerProps), (0, _react2.jsx)(_.Label, updatedLabelProps), (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
|
117
108
|
variant: "forms.numberField.noDefaultArrows"
|
|
118
109
|
}, groupProps), (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
|
119
110
|
variant: "forms.numberField.arrowsWrapper"
|
|
120
111
|
}, fieldControlWrapperProps, {
|
|
121
112
|
role: "spinbutton",
|
|
122
|
-
"aria-valuetext": inputPropsValue,
|
|
113
|
+
"aria-valuetext": String(inputPropsValue),
|
|
123
114
|
"aria-valuenow": inputPropsNumericValue,
|
|
124
115
|
"aria-labelledby": updatedLabelProps.id
|
|
125
116
|
}), (0, _react2.jsx)(_.Input, (0, _extends2["default"])({
|
|
@@ -134,68 +125,5 @@ var NumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
134
125
|
id: helperTextId
|
|
135
126
|
}, helperText)));
|
|
136
127
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/** A custom aria-label for the decrement button.
|
|
140
|
-
* If not provided, the localized string "Decrement" is used. */
|
|
141
|
-
decrementAriaLabel: _propTypes["default"].string,
|
|
142
|
-
/** A custom aria-label for the increment button.
|
|
143
|
-
* If not provided, the localized string "Increment" is used. */
|
|
144
|
-
incrementAriaLabel: _propTypes["default"].string,
|
|
145
|
-
/** Formatting options for the value displayed in the number field.
|
|
146
|
-
* This also affects what characters are allowed to be typed by the user.
|
|
147
|
-
* See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat)
|
|
148
|
-
* */
|
|
149
|
-
formatOptions: _propTypes["default"].shape({}),
|
|
150
|
-
/** Whether the input is disabled. */
|
|
151
|
-
isDisabled: _propTypes["default"].bool,
|
|
152
|
-
/** Whether the input can be selected but not changed by the user. */
|
|
153
|
-
isReadOnly: _propTypes["default"].bool,
|
|
154
|
-
/** Whether user input is required on the input before form submission. */
|
|
155
|
-
isRequired: _propTypes["default"].bool,
|
|
156
|
-
/** Whether the element should receive focus on render. */
|
|
157
|
-
hasAutoFocus: _propTypes["default"].bool,
|
|
158
|
-
/**
|
|
159
|
-
* Callback fired when focus is lost on the input element.
|
|
160
|
-
*/
|
|
161
|
-
onBlur: _propTypes["default"].func,
|
|
162
|
-
/**
|
|
163
|
-
* Callback fired when focus is lost on the input element.
|
|
164
|
-
*/
|
|
165
|
-
onFocus: _propTypes["default"].func,
|
|
166
|
-
/** Handler that is called when the element's focus status changes. */
|
|
167
|
-
onFocusChange: _propTypes["default"].func,
|
|
168
|
-
/** Handler that is called when a key is pressed. */
|
|
169
|
-
onKeyDown: _propTypes["default"].func,
|
|
170
|
-
/** Handler that is called when a key is released. */
|
|
171
|
-
onKeyUp: _propTypes["default"].func,
|
|
172
|
-
/** Temporary text that occupies the text input when it is empty. */
|
|
173
|
-
placeholder: _propTypes["default"].string,
|
|
174
|
-
/** The amount that the input value changes with each increment or decrement "tick".
|
|
175
|
-
* The step prop can be used to snap the value to certain increments.
|
|
176
|
-
* You can read more about this prop here
|
|
177
|
-
* [Step values](https://react-spectrum.adobe.com/react-aria/useNumberField.html#step-values)
|
|
178
|
-
* */
|
|
179
|
-
step: _propTypes["default"].number,
|
|
180
|
-
/** The smallest value allowed for the input. */
|
|
181
|
-
minValue: _propTypes["default"].number,
|
|
182
|
-
/** The largest value allowed for the input. */
|
|
183
|
-
maxValue: _propTypes["default"].number,
|
|
184
|
-
/** The rendered label for the field. */
|
|
185
|
-
label: _propTypes["default"].node,
|
|
186
|
-
/** Text rendered below the input. */
|
|
187
|
-
helperText: _propTypes["default"].node,
|
|
188
|
-
/** Props object that is spread directly into the helphint element. */
|
|
189
|
-
helpHintProps: _propTypes["default"].shape({}),
|
|
190
|
-
/** If present this prop will cause a help hint to render in the label of the field. */
|
|
191
|
-
hintText: _propTypes["default"].string,
|
|
192
|
-
/**
|
|
193
|
-
* Handler that is called when the value changes.
|
|
194
|
-
* (value: number) => void
|
|
195
|
-
*/
|
|
196
|
-
onChange: _propTypes["default"].func,
|
|
197
|
-
/** The default value (uncontrolled). */
|
|
198
|
-
defaultValue: _propTypes["default"].number,
|
|
199
|
-
/** The current value (controlled). */
|
|
200
|
-
value: _propTypes["default"].number
|
|
201
|
-
}, _statusProp.statusPropTypes), _ariaAttributes.ariaAttributesBasePropTypes), _fieldAttributes.inputFieldAttributesBasePropTypes);
|
|
128
|
+
NumberField.displayName = displayName;
|
|
129
|
+
var _default = exports["default"] = NumberField;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ThemeUICSSObject } from 'theme-ui';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
arrowsWrapper: ThemeUICSSObject;
|
|
4
|
+
arrows: ThemeUICSSObject;
|
|
5
|
+
noDefaultArrows: {
|
|
6
|
+
'input::-webkit-outer-spin-button': {
|
|
7
|
+
WebkitAppearance: string;
|
|
8
|
+
margin: number;
|
|
9
|
+
};
|
|
10
|
+
'input::-webkit-inner-spin-button': {
|
|
11
|
+
WebkitAppearance: string;
|
|
12
|
+
margin: number;
|
|
13
|
+
};
|
|
14
|
+
'input[type=number]': {
|
|
15
|
+
MozAppearance: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './NumberField';
|
|
@@ -380,7 +380,8 @@ function Resizer(props) {
|
|
|
380
380
|
onResizeEnd: onResizeEnd
|
|
381
381
|
}, layoutState, ref),
|
|
382
382
|
resizerProps = _useTableColumnResize.resizerProps,
|
|
383
|
-
inputProps = _useTableColumnResize.inputProps
|
|
383
|
+
inputProps = _useTableColumnResize.inputProps,
|
|
384
|
+
isResizing = _useTableColumnResize.isResizing;
|
|
384
385
|
var _useFocusRing = (0, _focus.useFocusRing)(),
|
|
385
386
|
isFocusVisible = _useFocusRing.isFocusVisible,
|
|
386
387
|
focusProps = _useFocusRing.focusProps;
|
|
@@ -389,8 +390,9 @@ function Resizer(props) {
|
|
|
389
390
|
// keyboard events fired on the input (Enter to start resize, Escape/Tab to
|
|
390
391
|
// end it) bubble up to the element with the keyboard handlers.
|
|
391
392
|
|
|
392
|
-
var _useStatusClasses3 = (0, _hooks.useStatusClasses)('', {
|
|
393
|
-
isFocused: isFocusVisible
|
|
393
|
+
var _useStatusClasses3 = (0, _hooks.useStatusClasses)('resizer', {
|
|
394
|
+
isFocused: isFocusVisible,
|
|
395
|
+
isResizing: isResizing
|
|
394
396
|
}),
|
|
395
397
|
classNames = _useStatusClasses3.classNames;
|
|
396
398
|
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
|
@@ -455,11 +457,15 @@ function TableColumnHeader(props) {
|
|
|
455
457
|
width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(column.key),
|
|
456
458
|
position: 'relative'
|
|
457
459
|
}, column.props.sx)
|
|
458
|
-
}, (0, _utils.mergeProps)(columnHeaderProps,
|
|
460
|
+
}, (0, _utils.mergeProps)(columnHeaderProps, column.props)), (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
|
461
|
+
as: "button",
|
|
462
|
+
type: "button",
|
|
459
463
|
isRow: true,
|
|
460
464
|
gap: "sm",
|
|
461
|
-
alignItems: "center"
|
|
462
|
-
|
|
465
|
+
alignItems: "center",
|
|
466
|
+
variant: "tableBase.sortButton",
|
|
467
|
+
"aria-label": "Sort by ".concat(column.textValue)
|
|
468
|
+
}, (0, _utils.mergeProps)(focusProps)), (0, _react2.jsx)(_.Text, {
|
|
463
469
|
as: "h4",
|
|
464
470
|
variant: "headText"
|
|
465
471
|
}, column.rendered), allowsSorting && sortIcon), allowsResizing && (0, _react2.jsx)(Resizer, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Meta } from '@storybook/addon-docs/blocks';
|
|
2
2
|
import * as TableBaseStories from './TableBase.stories';
|
|
3
|
+
import AccessibilityTable from '../../utils/docUtils/AccessibilityTable';
|
|
3
4
|
|
|
4
5
|
<Meta of={TableBaseStories} isTemplate />
|
|
5
6
|
|
|
@@ -42,23 +43,16 @@ This component requires these additional components:
|
|
|
42
43
|
|
|
43
44
|
### Accessibility
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
#### Screen Readers
|
|
59
|
-
|
|
60
|
-
This component uses the following attributes to assist screen readers:
|
|
61
|
-
- The **`aria-label`** attribute should be provided on the `TableBase` to give the table an accessible name. When a visible `TableCaption` is present, use **`aria-labelledby`** to associate the caption with the table instead.
|
|
62
|
-
- The **`aria-rowcount`** and **`aria-columncount`** attributes are used to indicate the total number of rows and columns in the grid structure.
|
|
63
|
-
- Each `Row` uses the **`aria-rowindex`** attribute to enumerate its position within the table.
|
|
64
|
-
- Each `Column` and `Cell` uses the **`aria-colindex`** attribute to enumerate its position within its row.
|
|
46
|
+
<AccessibilityTable keyboardRows={[
|
|
47
|
+
{ key: 'Tab', description: 'Moves focus into the table (from outside) or out of the table (to the next focusable element after it). The table is a single stop in the page tab sequence — Tab does not move focus between rows or cells within the table.' },
|
|
48
|
+
{ key: 'Shift + Tab', description: 'Moves focus out of the table to the previous focusable element (or into the table from after it).' },
|
|
49
|
+
{ key: 'Space or Enter', description: 'Triggers an action on the focused component, such as toggling row selection or sorting a column.' },
|
|
50
|
+
{ key: 'Arrow keys', description: 'Moves focus between rows and cells within the table.' },
|
|
51
|
+
{ key: 'Home or Page Up', description: 'Shifts the focus to the first row.' },
|
|
52
|
+
{ key: 'End or Page Down', description: 'Shifts the focus to the last visible row.' },
|
|
53
|
+
]} screenReaderRows={[
|
|
54
|
+
'The **`aria-label`** attribute should be provided on the `TableBase` to give the table an accessible name. When a visible `TableCaption` is present, use **`aria-labelledby`** to associate the caption with the table instead.',
|
|
55
|
+
'The **`aria-rowcount`** and **`aria-columncount`** attributes are used to indicate the total number of rows and columns in the grid structure.',
|
|
56
|
+
'Each `Row` uses the **`aria-rowindex`** attribute to enumerate its position within the table.',
|
|
57
|
+
'Each `Column` and `Cell` uses the **`aria-colindex`** attribute to enumerate its position within its row.',
|
|
58
|
+
]} />
|
|
@@ -23,7 +23,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
23
23
|
_Object$defineProperty(exports, "__esModule", {
|
|
24
24
|
value: true
|
|
25
25
|
});
|
|
26
|
-
exports["default"] = exports.WithStickyHeader = exports.WithResizableColumns = exports.WithPagination = exports.WithMinMaxColumnWidth = exports.WithLoadingState = exports.WithLastColumnSticky = exports.WithEmptyState = exports.RowActions = exports.MultiSelection = exports.DynamicWithSorting = exports.DefaultEmptyStateWithButton = exports.DefaultEmptyState = exports.Default = void 0;
|
|
26
|
+
exports["default"] = exports.WithStickyHeader = exports.WithSortingAndResizing = exports.WithResizableColumns = exports.WithPagination = exports.WithMinMaxColumnWidth = exports.WithLoadingState = exports.WithLastColumnSticky = exports.WithEmptyState = exports.RowActions = exports.MultiSelection = exports.DynamicWithSorting = exports.DefaultEmptyStateWithButton = exports.DefaultEmptyState = exports.Default = void 0;
|
|
27
27
|
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
|
28
28
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
29
29
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
@@ -55,7 +55,7 @@ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present,
|
|
|
55
55
|
function _regeneratorDefine2(e, r, n, t) { var i = _Object$defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
56
56
|
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
57
57
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
58
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
58
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
59
59
|
var _default = exports["default"] = {
|
|
60
60
|
title: 'Components/TableBase',
|
|
61
61
|
component: _.TableBase,
|
|
@@ -430,6 +430,152 @@ var WithResizableColumns = exports.WithResizableColumns = function WithResizable
|
|
|
430
430
|
}, (0, _react2.jsx)(_.Cell, null, item.type), (0, _react2.jsx)(_.Cell, null, item.date), (0, _react2.jsx)(_.Cell, null, item.additional_grant), (0, _react2.jsx)(_.Cell, null, item.total_grant));
|
|
431
431
|
})));
|
|
432
432
|
};
|
|
433
|
+
var WithSortingAndResizing = exports.WithSortingAndResizing = function WithSortingAndResizing() {
|
|
434
|
+
var columns = [{
|
|
435
|
+
name: 'Country',
|
|
436
|
+
key: 'country',
|
|
437
|
+
isSortable: true
|
|
438
|
+
}, {
|
|
439
|
+
name: 'Population',
|
|
440
|
+
key: 'population',
|
|
441
|
+
isSortable: true
|
|
442
|
+
}, {
|
|
443
|
+
name: 'Continent',
|
|
444
|
+
key: 'continent',
|
|
445
|
+
isSortable: false
|
|
446
|
+
}];
|
|
447
|
+
var rows = [{
|
|
448
|
+
id: 1,
|
|
449
|
+
country: 'Austria',
|
|
450
|
+
population: '25,000,000',
|
|
451
|
+
continent: 'Oceania'
|
|
452
|
+
}, {
|
|
453
|
+
id: 2,
|
|
454
|
+
country: 'Canada',
|
|
455
|
+
population: '37,000,000',
|
|
456
|
+
continent: 'North America'
|
|
457
|
+
}, {
|
|
458
|
+
id: 3,
|
|
459
|
+
country: 'China',
|
|
460
|
+
population: '1,398,000,000',
|
|
461
|
+
continent: 'Asia'
|
|
462
|
+
}, {
|
|
463
|
+
id: 4,
|
|
464
|
+
country: 'Ethiopia',
|
|
465
|
+
population: '120,000,000',
|
|
466
|
+
continent: 'Africa'
|
|
467
|
+
}, {
|
|
468
|
+
id: 5,
|
|
469
|
+
country: 'France',
|
|
470
|
+
population: '67,000,000',
|
|
471
|
+
continent: 'Europe'
|
|
472
|
+
}, {
|
|
473
|
+
id: 6,
|
|
474
|
+
country: 'Mexico',
|
|
475
|
+
population: '126,000,000',
|
|
476
|
+
continent: 'North America'
|
|
477
|
+
}, {
|
|
478
|
+
id: 7,
|
|
479
|
+
country: 'USA',
|
|
480
|
+
population: '320,000,000',
|
|
481
|
+
continent: 'North America'
|
|
482
|
+
}];
|
|
483
|
+
var collator = (0, _i18n.useCollator)({
|
|
484
|
+
numeric: true
|
|
485
|
+
});
|
|
486
|
+
var list = (0, _data.useAsyncList)({
|
|
487
|
+
load: function load() {
|
|
488
|
+
return (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
489
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context5) {
|
|
490
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
491
|
+
case 0:
|
|
492
|
+
return _context5.abrupt("return", {
|
|
493
|
+
items: rows
|
|
494
|
+
});
|
|
495
|
+
case 1:
|
|
496
|
+
case "end":
|
|
497
|
+
return _context5.stop();
|
|
498
|
+
}
|
|
499
|
+
}, _callee3);
|
|
500
|
+
}))();
|
|
501
|
+
},
|
|
502
|
+
sort: function sort(_ref2) {
|
|
503
|
+
return (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
504
|
+
var items, sortDescriptor, getNumericValue;
|
|
505
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context6) {
|
|
506
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
507
|
+
case 0:
|
|
508
|
+
items = _ref2.items, sortDescriptor = _ref2.sortDescriptor;
|
|
509
|
+
getNumericValue = function getNumericValue(str) {
|
|
510
|
+
return !(0, _isNan["default"])(str) && (0, _parseFloat2["default"])(str.replace(/,/g, ''));
|
|
511
|
+
};
|
|
512
|
+
return _context6.abrupt("return", {
|
|
513
|
+
items: (0, _sort["default"])(items).call(items, function (a, b) {
|
|
514
|
+
if (sortDescriptor.column) {
|
|
515
|
+
var first = a[sortDescriptor.column];
|
|
516
|
+
var second = b[sortDescriptor.column];
|
|
517
|
+
var firstNumericValue = getNumericValue(first);
|
|
518
|
+
var secondNumericValue = getNumericValue(second);
|
|
519
|
+
var cmp = firstNumericValue && secondNumericValue ? firstNumericValue - secondNumericValue : collator.compare(first, second);
|
|
520
|
+
return sortDescriptor.direction === 'descending' ? -cmp : cmp;
|
|
521
|
+
}
|
|
522
|
+
return 1;
|
|
523
|
+
})
|
|
524
|
+
});
|
|
525
|
+
case 3:
|
|
526
|
+
case "end":
|
|
527
|
+
return _context6.stop();
|
|
528
|
+
}
|
|
529
|
+
}, _callee4);
|
|
530
|
+
}))();
|
|
531
|
+
},
|
|
532
|
+
initialSortDescriptor: {
|
|
533
|
+
column: 'country',
|
|
534
|
+
direction: 'ascending'
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
return (0, _react2.jsx)(_.Card, {
|
|
538
|
+
variant: "cards.tableWrapper"
|
|
539
|
+
}, (0, _react2.jsx)(_.TableBase, {
|
|
540
|
+
"aria-label": "Table with sorting and resizing enabled together",
|
|
541
|
+
onSortChange: function onSortChange(descriptor) {
|
|
542
|
+
if (descriptor.column) {
|
|
543
|
+
(0, _sort["default"])(list).call(list, descriptor);
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
sortDescriptor: list.sortDescriptor
|
|
547
|
+
}, (0, _react2.jsx)(_.THead, {
|
|
548
|
+
columns: columns
|
|
549
|
+
}, function (column) {
|
|
550
|
+
return (0, _react2.jsx)(_.Column, {
|
|
551
|
+
minWidth: 155,
|
|
552
|
+
allowsSorting: column.isSortable,
|
|
553
|
+
allowsResizing: column.key !== columns[columns.length - 1].key
|
|
554
|
+
}, column.name);
|
|
555
|
+
}), (0, _react2.jsx)(_.TBody, {
|
|
556
|
+
items: list.items,
|
|
557
|
+
loadingState: list.loadingState,
|
|
558
|
+
onLoadMore: list.loadMore
|
|
559
|
+
}, function (item) {
|
|
560
|
+
return (0, _react2.jsx)(_.Row, {
|
|
561
|
+
key: item.name
|
|
562
|
+
}, function (columnKey) {
|
|
563
|
+
return (0, _react2.jsx)(_.Cell, null, item[columnKey]);
|
|
564
|
+
});
|
|
565
|
+
})));
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
// Added to bypass color contrast issue due to virtualizer
|
|
569
|
+
WithSortingAndResizing.parameters = {
|
|
570
|
+
a11y: {
|
|
571
|
+
config: {
|
|
572
|
+
rules: [{
|
|
573
|
+
id: 'color-contrast',
|
|
574
|
+
enabled: false
|
|
575
|
+
}]
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
};
|
|
433
579
|
var WithMinMaxColumnWidth = exports.WithMinMaxColumnWidth = function WithMinMaxColumnWidth() {
|
|
434
580
|
return (0, _react2.jsx)(_.Card, {
|
|
435
581
|
variant: "cards.tableWrapper"
|
|
@@ -160,6 +160,9 @@ declare const _default: {
|
|
|
160
160
|
outline: string;
|
|
161
161
|
};
|
|
162
162
|
'&.is-focused': {
|
|
163
|
+
'& .resizer': {
|
|
164
|
+
backgroundColor: string;
|
|
165
|
+
};
|
|
163
166
|
outline: string;
|
|
164
167
|
outlineStyle: string;
|
|
165
168
|
outlineColor: string;
|
|
@@ -209,12 +212,42 @@ declare const _default: {
|
|
|
209
212
|
width: string;
|
|
210
213
|
height: string;
|
|
211
214
|
backgroundColor: string;
|
|
215
|
+
boxSizing: string;
|
|
216
|
+
paddingLeft: string;
|
|
217
|
+
paddingRight: string;
|
|
218
|
+
backgroundClip: string;
|
|
212
219
|
position: string;
|
|
213
220
|
right: string;
|
|
214
221
|
top: string;
|
|
215
222
|
'&.is-focused': {
|
|
223
|
+
outline: string;
|
|
224
|
+
outlineStyle: string;
|
|
225
|
+
outlineColor: string;
|
|
226
|
+
outlineOffset: string;
|
|
227
|
+
zIndex: number;
|
|
228
|
+
};
|
|
229
|
+
'&.is-resizing': {
|
|
216
230
|
backgroundColor: string;
|
|
231
|
+
outline: string;
|
|
217
232
|
};
|
|
218
233
|
};
|
|
234
|
+
sortButton: {
|
|
235
|
+
fontWeight: number;
|
|
236
|
+
appearance: string;
|
|
237
|
+
background: string;
|
|
238
|
+
border: string;
|
|
239
|
+
padding: number;
|
|
240
|
+
margin: number;
|
|
241
|
+
cursor: string;
|
|
242
|
+
textAlign: string;
|
|
243
|
+
fontSize: string;
|
|
244
|
+
color: string;
|
|
245
|
+
fontFamily: string;
|
|
246
|
+
display: string;
|
|
247
|
+
overflowWrap: import("../..").overflowWrap;
|
|
248
|
+
maxWidth: string;
|
|
249
|
+
wordWrap: import("../..").wordWrap;
|
|
250
|
+
wordBreak: import("../..").wordBreak;
|
|
251
|
+
};
|
|
219
252
|
};
|
|
220
253
|
export default _default;
|
|
@@ -134,7 +134,11 @@ var head = _objectSpread(_objectSpread({}, _Text.text.label), {}, {
|
|
|
134
134
|
'&:focus-visible': {
|
|
135
135
|
outline: 'none'
|
|
136
136
|
},
|
|
137
|
-
'&.is-focused': _objectSpread({}, defaultFocus)
|
|
137
|
+
'&.is-focused': _objectSpread(_objectSpread({}, defaultFocus), {}, {
|
|
138
|
+
'& .resizer': {
|
|
139
|
+
backgroundColor: 'focus'
|
|
140
|
+
}
|
|
141
|
+
})
|
|
138
142
|
});
|
|
139
143
|
var resizer = {
|
|
140
144
|
cursor: 'col-resize',
|
|
@@ -142,13 +146,34 @@ var resizer = {
|
|
|
142
146
|
width: '2px',
|
|
143
147
|
height: '100%',
|
|
144
148
|
backgroundColor: 'neutral.10',
|
|
149
|
+
boxSizing: 'content-box',
|
|
150
|
+
paddingLeft: '0.25rem',
|
|
151
|
+
paddingRight: '0.25rem',
|
|
152
|
+
backgroundClip: 'content-box',
|
|
145
153
|
position: 'absolute',
|
|
146
|
-
right: '
|
|
154
|
+
right: '-0.25rem',
|
|
147
155
|
top: '0',
|
|
148
|
-
'&.is-focused': {
|
|
149
|
-
|
|
156
|
+
'&.is-focused': _objectSpread({}, defaultFocus),
|
|
157
|
+
'&.is-resizing': {
|
|
158
|
+
backgroundColor: 'focus',
|
|
159
|
+
outline: '0px'
|
|
150
160
|
}
|
|
151
161
|
};
|
|
162
|
+
|
|
163
|
+
// Resets native <button> chrome so the sort trigger reads as plain header
|
|
164
|
+
// text/icon, matching `head`'s typography, while remaining its own
|
|
165
|
+
// focusable, activatable element (a sibling to the resizer, not a
|
|
166
|
+
// descendant of it, or vice versa).
|
|
167
|
+
var sortButton = _objectSpread(_objectSpread({}, _Text.text.label), {}, {
|
|
168
|
+
fontWeight: 500,
|
|
169
|
+
appearance: 'none',
|
|
170
|
+
background: 'none',
|
|
171
|
+
border: 'none',
|
|
172
|
+
padding: 0,
|
|
173
|
+
margin: 0,
|
|
174
|
+
cursor: 'pointer',
|
|
175
|
+
textAlign: 'left'
|
|
176
|
+
});
|
|
152
177
|
var tbody = {
|
|
153
178
|
borderBottom: '1px solid',
|
|
154
179
|
borderBottomColor: 'neutral.80',
|
|
@@ -193,5 +218,6 @@ var _default = exports["default"] = {
|
|
|
193
218
|
data: data,
|
|
194
219
|
head: head,
|
|
195
220
|
row: row,
|
|
196
|
-
resizer: resizer
|
|
221
|
+
resizer: resizer,
|
|
222
|
+
sortButton: sortButton
|
|
197
223
|
};
|