@pingux/astro 2.139.0 → 2.140.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/GridList/GridList.d.ts +16 -2
- package/lib/cjs/components/GridList/GridList.js +11 -3
- package/lib/cjs/components/GridList/GridList.stories.d.ts +12 -1
- package/lib/cjs/components/GridList/GridList.stories.js +15 -3
- package/lib/cjs/components/GridList/GridList.test.js +35 -2
- package/lib/cjs/components/GridList/GridListRow.js +7 -5
- package/lib/cjs/types/dnd.d.ts +2 -0
- package/lib/components/GridList/GridList.js +11 -3
- package/lib/components/GridList/GridList.stories.js +15 -3
- package/lib/components/GridList/GridList.test.js +35 -2
- package/lib/components/GridList/GridListRow.js +7 -5
- package/package.json +1 -1
@@ -1,3 +1,17 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
|
1
|
+
import React, { Key } from 'react';
|
2
|
+
import { Collection } from 'react-stately';
|
3
|
+
import type { Node } from '@react-types/shared';
|
4
|
+
type GridListProps = {
|
5
|
+
containerProps: object;
|
6
|
+
rowProps: object;
|
7
|
+
cellProps: object;
|
8
|
+
children?: React.ReactNode;
|
9
|
+
isReorderable?: boolean;
|
10
|
+
items: Iterable<object>;
|
11
|
+
keyboardNavigationBehavior?: 'arrow' | 'tab';
|
12
|
+
onAction?: (key: Key) => void;
|
13
|
+
onSelectionChange?: (keys: Selection) => void;
|
14
|
+
collection: Collection<Node<object>>;
|
15
|
+
};
|
16
|
+
declare const GridList: (props: GridListProps) => React.JSX.Element;
|
3
17
|
export default GridList;
|
@@ -20,12 +20,14 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
20
20
|
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
21
21
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
22
22
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
23
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
23
24
|
var _react = _interopRequireWildcard(require("react"));
|
24
25
|
var _reactAria = require("react-aria");
|
25
26
|
var _useGridList2 = _interopRequireDefault(require("../../hooks/useGridList"));
|
26
27
|
var _index = require("../../index");
|
27
28
|
var _GridListRow = _interopRequireDefault(require("./GridListRow"));
|
28
29
|
var _react2 = require("@emotion/react");
|
30
|
+
var _excluded = ["containerProps", "rowProps", "cellProps"];
|
29
31
|
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); }
|
30
32
|
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
33
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
@@ -33,14 +35,18 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
33
35
|
var GridList = function GridList(props) {
|
34
36
|
var _context, _context2;
|
35
37
|
var ref = (0, _react.useRef)(null);
|
36
|
-
var
|
38
|
+
var containerProps = props.containerProps,
|
39
|
+
rowProps = props.rowProps,
|
40
|
+
cellProps = props.cellProps,
|
41
|
+
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
42
|
+
var _useGridList = (0, _useGridList2["default"])(_objectSpread(_objectSpread({}, others), {}, {
|
37
43
|
ref: ref
|
38
44
|
})),
|
39
45
|
collectionProps = _useGridList.collectionProps,
|
40
46
|
gridListItemProps = _useGridList.gridListItemProps,
|
41
47
|
gridProps = _useGridList.gridProps,
|
42
48
|
state = _useGridList.state;
|
43
|
-
return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({}, (0, _reactAria.mergeProps)(gridProps, collectionProps), {
|
49
|
+
return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({}, (0, _reactAria.mergeProps)(gridProps, collectionProps, containerProps), {
|
44
50
|
ref: ref,
|
45
51
|
className: "list",
|
46
52
|
variant: "gridList.container",
|
@@ -48,7 +54,9 @@ var GridList = function GridList(props) {
|
|
48
54
|
}), (0, _map["default"])(_context = (0, _concat["default"])(_context2 = []).call(_context2, (0, _from["default"])(state.collection))).call(_context, function (item) {
|
49
55
|
return (0, _react2.jsx)(_GridListRow["default"], (0, _extends2["default"])({
|
50
56
|
key: item.key,
|
51
|
-
item: item
|
57
|
+
item: item,
|
58
|
+
rowProps: rowProps,
|
59
|
+
cellProps: cellProps
|
52
60
|
}, gridListItemProps));
|
53
61
|
}));
|
54
62
|
};
|
@@ -1,7 +1,18 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
declare const _default: {
|
3
3
|
title: string;
|
4
|
-
component: (props:
|
4
|
+
component: (props: {
|
5
|
+
containerProps: object;
|
6
|
+
rowProps: object;
|
7
|
+
cellProps: object;
|
8
|
+
children?: React.ReactNode;
|
9
|
+
isReorderable?: boolean | undefined;
|
10
|
+
items: Iterable<object>;
|
11
|
+
keyboardNavigationBehavior?: "tab" | "arrow" | undefined;
|
12
|
+
onAction?: ((key: React.Key) => void) | undefined;
|
13
|
+
onSelectionChange?: ((keys: Selection) => void) | undefined;
|
14
|
+
collection: import("react-stately").Collection<import("@react-types/shared").Node<object>>;
|
15
|
+
}) => React.JSX.Element;
|
5
16
|
argTypes: {
|
6
17
|
isReorderable: {
|
7
18
|
description: string;
|
@@ -69,12 +69,14 @@ var ExampleComponent = function ExampleComponent(_ref) {
|
|
69
69
|
sx: {
|
70
70
|
alignItems: 'center'
|
71
71
|
},
|
72
|
-
gap: "sm"
|
72
|
+
gap: "sm",
|
73
|
+
flexGrow: "1"
|
73
74
|
}, (0, _react2.jsx)(_index.TextField, {
|
74
75
|
"aria-label": label,
|
75
76
|
ref: ref,
|
76
77
|
defaultValue: label,
|
77
|
-
"data-testid": "".concat(label, "-text-field")
|
78
|
+
"data-testid": "".concat(label, "-text-field"),
|
79
|
+
flexGrow: "1"
|
78
80
|
}), (0, _react2.jsx)(_index.Box, {
|
79
81
|
isRow: true,
|
80
82
|
sx: {
|
@@ -122,7 +124,17 @@ var Default = function Default(args) {
|
|
122
124
|
return (0, _react2.jsx)(_index.GridList, (0, _extends2["default"])({
|
123
125
|
items: items,
|
124
126
|
isReorderable: true,
|
125
|
-
keyboardNavigationBehavior: "tab"
|
127
|
+
keyboardNavigationBehavior: "tab",
|
128
|
+
rowProps: {
|
129
|
+
sx: {
|
130
|
+
flexGrow: 1
|
131
|
+
}
|
132
|
+
},
|
133
|
+
cellProps: {
|
134
|
+
sx: {
|
135
|
+
flexGrow: 1
|
136
|
+
}
|
137
|
+
}
|
126
138
|
}, args), function (item) {
|
127
139
|
return (0, _react2.jsx)(_reactStately.Item, {
|
128
140
|
textValue: item.name,
|
@@ -53,12 +53,12 @@ describe('GridList Component', function () {
|
|
53
53
|
});
|
54
54
|
});
|
55
55
|
test('renders GridListRow for each item', function () {
|
56
|
-
getDefaultComponent();
|
56
|
+
getDefaultComponent({});
|
57
57
|
var rows = _testWrapper.screen.getAllByRole('row');
|
58
58
|
expect(rows).toHaveLength(items.length);
|
59
59
|
});
|
60
60
|
test('handles keyboard navigation', function () {
|
61
|
-
getDefaultComponent();
|
61
|
+
getDefaultComponent({});
|
62
62
|
var rows = _testWrapper.screen.getAllByRole('row');
|
63
63
|
_userEvent["default"].tab();
|
64
64
|
expect(rows[0]).toHaveClass('is-focused');
|
@@ -150,4 +150,37 @@ describe('GridList Component', function () {
|
|
150
150
|
}
|
151
151
|
}, _callee2);
|
152
152
|
})));
|
153
|
+
test('renders GridList with containerProps', function () {
|
154
|
+
getDefaultComponent({
|
155
|
+
containerProps: {
|
156
|
+
sx: {
|
157
|
+
background: 'red'
|
158
|
+
}
|
159
|
+
}
|
160
|
+
});
|
161
|
+
var list = _testWrapper.screen.getByRole('grid');
|
162
|
+
expect(list).toHaveStyle('background: red');
|
163
|
+
});
|
164
|
+
test('renders GridList with rowProps', function () {
|
165
|
+
getDefaultComponent({
|
166
|
+
rowProps: {
|
167
|
+
sx: {
|
168
|
+
background: 'red'
|
169
|
+
}
|
170
|
+
}
|
171
|
+
});
|
172
|
+
var rows = _testWrapper.screen.getAllByRole('row');
|
173
|
+
expect(rows[0]).toHaveStyle('background: red');
|
174
|
+
});
|
175
|
+
test('renders GridList with cellProps', function () {
|
176
|
+
getDefaultComponent({
|
177
|
+
cellProps: {
|
178
|
+
sx: {
|
179
|
+
background: 'red'
|
180
|
+
}
|
181
|
+
}
|
182
|
+
});
|
183
|
+
var gridCells = _testWrapper.screen.getAllByRole('gridcell');
|
184
|
+
expect(gridCells[0]).toHaveStyle('background: red');
|
185
|
+
});
|
153
186
|
});
|
@@ -24,7 +24,9 @@ var GridListRow = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
24
24
|
var rowRef = (0, _hooks.useLocalOrForwardRef)(ref);
|
25
25
|
var buttonRef = _react["default"].useRef(null);
|
26
26
|
var cellRef = _react["default"].useRef(null);
|
27
|
-
var
|
27
|
+
var customRowProps = props.rowProps,
|
28
|
+
cellProps = props.cellProps,
|
29
|
+
dragState = props.dragState,
|
28
30
|
dropState = props.dropState,
|
29
31
|
isReorderable = props.isReorderable,
|
30
32
|
item = props.item,
|
@@ -54,6 +56,8 @@ var GridListRow = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
54
56
|
variant: "gridList.rowContainer",
|
55
57
|
isRow: true,
|
56
58
|
ref: rowRef
|
59
|
+
}, customRowProps, {
|
60
|
+
flexGrow: "1"
|
57
61
|
}), isReorderable && (0, _react2.jsx)(_index.Box, {
|
58
62
|
isRow: true,
|
59
63
|
sx: {
|
@@ -70,10 +74,8 @@ var GridListRow = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
70
74
|
icon: _DragVerticalIcon["default"]
|
71
75
|
}))), (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({}, gridCellProps, {
|
72
76
|
isRow: true,
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
}), item.rendered)), state.collection.getKeyAfter(item.key) == null && (0, _react2.jsx)(_TreeView.InsertionIndicator, {
|
77
|
+
alignItems: "center"
|
78
|
+
}, cellProps), item.rendered)), state.collection.getKeyAfter(item.key) == null && (0, _react2.jsx)(_TreeView.InsertionIndicator, {
|
77
79
|
key: "".concat(item.key, "-after"),
|
78
80
|
target: {
|
79
81
|
type: 'item',
|
package/lib/cjs/types/dnd.d.ts
CHANGED
@@ -54,6 +54,8 @@ export interface GridListRowProps {
|
|
54
54
|
isReorderable?: boolean;
|
55
55
|
item: Node<object>;
|
56
56
|
state: ListState<object>;
|
57
|
+
rowProps?: object;
|
58
|
+
cellProps?: object;
|
57
59
|
}
|
58
60
|
export interface UseReorderableCollectionProps {
|
59
61
|
draggableCollectionStateOptions: DraggableCollectionStateOptions;
|
@@ -8,6 +8,8 @@ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/obje
|
|
8
8
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
9
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
10
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
+
var _excluded = ["containerProps", "rowProps", "cellProps"];
|
11
13
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
12
14
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
13
15
|
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
@@ -22,14 +24,18 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
22
24
|
var GridList = function GridList(props) {
|
23
25
|
var _context, _context2;
|
24
26
|
var ref = useRef(null);
|
25
|
-
var
|
27
|
+
var containerProps = props.containerProps,
|
28
|
+
rowProps = props.rowProps,
|
29
|
+
cellProps = props.cellProps,
|
30
|
+
others = _objectWithoutProperties(props, _excluded);
|
31
|
+
var _useGridList = useGridList(_objectSpread(_objectSpread({}, others), {}, {
|
26
32
|
ref: ref
|
27
33
|
})),
|
28
34
|
collectionProps = _useGridList.collectionProps,
|
29
35
|
gridListItemProps = _useGridList.gridListItemProps,
|
30
36
|
gridProps = _useGridList.gridProps,
|
31
37
|
state = _useGridList.state;
|
32
|
-
return ___EmotionJSX(Box, _extends({}, mergeProps(gridProps, collectionProps), {
|
38
|
+
return ___EmotionJSX(Box, _extends({}, mergeProps(gridProps, collectionProps, containerProps), {
|
33
39
|
ref: ref,
|
34
40
|
className: "list",
|
35
41
|
variant: "gridList.container",
|
@@ -37,7 +43,9 @@ var GridList = function GridList(props) {
|
|
37
43
|
}), _mapInstanceProperty(_context = _concatInstanceProperty(_context2 = []).call(_context2, _Array$from(state.collection))).call(_context, function (item) {
|
38
44
|
return ___EmotionJSX(GridListRow, _extends({
|
39
45
|
key: item.key,
|
40
|
-
item: item
|
46
|
+
item: item,
|
47
|
+
rowProps: rowProps,
|
48
|
+
cellProps: cellProps
|
41
49
|
}, gridListItemProps));
|
42
50
|
}));
|
43
51
|
};
|
@@ -57,12 +57,14 @@ var ExampleComponent = function ExampleComponent(_ref) {
|
|
57
57
|
sx: {
|
58
58
|
alignItems: 'center'
|
59
59
|
},
|
60
|
-
gap: "sm"
|
60
|
+
gap: "sm",
|
61
|
+
flexGrow: "1"
|
61
62
|
}, ___EmotionJSX(TextField, {
|
62
63
|
"aria-label": label,
|
63
64
|
ref: ref,
|
64
65
|
defaultValue: label,
|
65
|
-
"data-testid": "".concat(label, "-text-field")
|
66
|
+
"data-testid": "".concat(label, "-text-field"),
|
67
|
+
flexGrow: "1"
|
66
68
|
}), ___EmotionJSX(Box, {
|
67
69
|
isRow: true,
|
68
70
|
sx: {
|
@@ -110,7 +112,17 @@ export var Default = function Default(args) {
|
|
110
112
|
return ___EmotionJSX(GridList, _extends({
|
111
113
|
items: items,
|
112
114
|
isReorderable: true,
|
113
|
-
keyboardNavigationBehavior: "tab"
|
115
|
+
keyboardNavigationBehavior: "tab",
|
116
|
+
rowProps: {
|
117
|
+
sx: {
|
118
|
+
flexGrow: 1
|
119
|
+
}
|
120
|
+
},
|
121
|
+
cellProps: {
|
122
|
+
sx: {
|
123
|
+
flexGrow: 1
|
124
|
+
}
|
125
|
+
}
|
114
126
|
}, args), function (item) {
|
115
127
|
return ___EmotionJSX(Item, {
|
116
128
|
textValue: item.name,
|
@@ -49,12 +49,12 @@ describe('GridList Component', function () {
|
|
49
49
|
});
|
50
50
|
});
|
51
51
|
test('renders GridListRow for each item', function () {
|
52
|
-
getDefaultComponent();
|
52
|
+
getDefaultComponent({});
|
53
53
|
var rows = screen.getAllByRole('row');
|
54
54
|
expect(rows).toHaveLength(items.length);
|
55
55
|
});
|
56
56
|
test('handles keyboard navigation', function () {
|
57
|
-
getDefaultComponent();
|
57
|
+
getDefaultComponent({});
|
58
58
|
var rows = screen.getAllByRole('row');
|
59
59
|
userEvent.tab();
|
60
60
|
expect(rows[0]).toHaveClass('is-focused');
|
@@ -146,4 +146,37 @@ describe('GridList Component', function () {
|
|
146
146
|
}
|
147
147
|
}, _callee2);
|
148
148
|
})));
|
149
|
+
test('renders GridList with containerProps', function () {
|
150
|
+
getDefaultComponent({
|
151
|
+
containerProps: {
|
152
|
+
sx: {
|
153
|
+
background: 'red'
|
154
|
+
}
|
155
|
+
}
|
156
|
+
});
|
157
|
+
var list = screen.getByRole('grid');
|
158
|
+
expect(list).toHaveStyle('background: red');
|
159
|
+
});
|
160
|
+
test('renders GridList with rowProps', function () {
|
161
|
+
getDefaultComponent({
|
162
|
+
rowProps: {
|
163
|
+
sx: {
|
164
|
+
background: 'red'
|
165
|
+
}
|
166
|
+
}
|
167
|
+
});
|
168
|
+
var rows = screen.getAllByRole('row');
|
169
|
+
expect(rows[0]).toHaveStyle('background: red');
|
170
|
+
});
|
171
|
+
test('renders GridList with cellProps', function () {
|
172
|
+
getDefaultComponent({
|
173
|
+
cellProps: {
|
174
|
+
sx: {
|
175
|
+
background: 'red'
|
176
|
+
}
|
177
|
+
}
|
178
|
+
});
|
179
|
+
var gridCells = screen.getAllByRole('gridcell');
|
180
|
+
expect(gridCells[0]).toHaveStyle('background: red');
|
181
|
+
});
|
149
182
|
});
|
@@ -11,7 +11,9 @@ var GridListRow = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
11
11
|
var rowRef = useLocalOrForwardRef(ref);
|
12
12
|
var buttonRef = React.useRef(null);
|
13
13
|
var cellRef = React.useRef(null);
|
14
|
-
var
|
14
|
+
var customRowProps = props.rowProps,
|
15
|
+
cellProps = props.cellProps,
|
16
|
+
dragState = props.dragState,
|
15
17
|
dropState = props.dropState,
|
16
18
|
isReorderable = props.isReorderable,
|
17
19
|
item = props.item,
|
@@ -41,6 +43,8 @@ var GridListRow = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
41
43
|
variant: "gridList.rowContainer",
|
42
44
|
isRow: true,
|
43
45
|
ref: rowRef
|
46
|
+
}, customRowProps, {
|
47
|
+
flexGrow: "1"
|
44
48
|
}), isReorderable && ___EmotionJSX(Box, {
|
45
49
|
isRow: true,
|
46
50
|
sx: {
|
@@ -57,10 +61,8 @@ var GridListRow = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
57
61
|
icon: DragIcon
|
58
62
|
}))), ___EmotionJSX(Box, _extends({}, gridCellProps, {
|
59
63
|
isRow: true,
|
60
|
-
|
61
|
-
|
62
|
-
}
|
63
|
-
}), item.rendered)), state.collection.getKeyAfter(item.key) == null && ___EmotionJSX(InsertionIndicator, {
|
64
|
+
alignItems: "center"
|
65
|
+
}, cellProps), item.rendered)), state.collection.getKeyAfter(item.key) == null && ___EmotionJSX(InsertionIndicator, {
|
64
66
|
key: "".concat(item.key, "-after"),
|
65
67
|
target: {
|
66
68
|
type: 'item',
|