@wordpress/dataviews 1.1.0 → 2.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/CHANGELOG.md +27 -5
- package/README.md +33 -30
- package/build/add-filter.js +30 -22
- package/build/add-filter.js.map +1 -1
- package/build/bulk-actions-toolbar.js +187 -0
- package/build/bulk-actions-toolbar.js.map +1 -0
- package/build/bulk-actions.js +75 -62
- package/build/bulk-actions.js.map +1 -1
- package/build/constants.js +17 -10
- package/build/constants.js.map +1 -1
- package/build/dataviews.js +64 -50
- package/build/dataviews.js.map +1 -1
- package/build/filter-and-sort-data-view.js +2 -2
- package/build/filter-and-sort-data-view.js.map +1 -1
- package/build/filter-summary.js +106 -96
- package/build/filter-summary.js.map +1 -1
- package/build/filters.js +18 -17
- package/build/filters.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/item-actions.js +101 -69
- package/build/item-actions.js.map +1 -1
- package/build/layouts.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/normalize-fields.js.map +1 -1
- package/build/pagination.js +66 -57
- package/build/pagination.js.map +1 -1
- package/build/reset-filters.js +9 -4
- package/build/reset-filters.js.map +1 -1
- package/build/search-widget.js +108 -89
- package/build/search-widget.js.map +1 -1
- package/build/search.js +13 -6
- package/build/search.js.map +1 -1
- package/build/single-selection-checkbox.js +6 -2
- package/build/single-selection-checkbox.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils.js +3 -15
- package/build/utils.js.map +1 -1
- package/build/view-actions.js +168 -120
- package/build/view-actions.js.map +1 -1
- package/build/view-grid.js +119 -106
- package/build/view-grid.js.map +1 -1
- package/build/view-list.js +217 -83
- package/build/view-list.js.map +1 -1
- package/build/view-table.js +227 -199
- package/build/view-table.js.map +1 -1
- package/build-module/add-filter.js +30 -22
- package/build-module/add-filter.js.map +1 -1
- package/build-module/bulk-actions-toolbar.js +182 -0
- package/build-module/bulk-actions-toolbar.js.map +1 -0
- package/build-module/bulk-actions.js +77 -62
- package/build-module/bulk-actions.js.map +1 -1
- package/build-module/constants.js +16 -9
- package/build-module/constants.js.map +1 -1
- package/build-module/dataviews.js +65 -50
- package/build-module/dataviews.js.map +1 -1
- package/build-module/filter-and-sort-data-view.js +2 -2
- package/build-module/filter-and-sort-data-view.js.map +1 -1
- package/build-module/filter-summary.js +107 -97
- package/build-module/filter-summary.js.map +1 -1
- package/build-module/filters.js +18 -17
- package/build-module/filters.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/item-actions.js +102 -71
- package/build-module/item-actions.js.map +1 -1
- package/build-module/layouts.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/normalize-fields.js.map +1 -1
- package/build-module/pagination.js +67 -57
- package/build-module/pagination.js.map +1 -1
- package/build-module/reset-filters.js +9 -4
- package/build-module/reset-filters.js.map +1 -1
- package/build-module/search-widget.js +109 -89
- package/build-module/search-widget.js.map +1 -1
- package/build-module/search.js +13 -6
- package/build-module/search.js.map +1 -1
- package/build-module/single-selection-checkbox.js +6 -2
- package/build-module/single-selection-checkbox.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/utils.js +2 -13
- package/build-module/utils.js.map +1 -1
- package/build-module/view-actions.js +170 -121
- package/build-module/view-actions.js.map +1 -1
- package/build-module/view-grid.js +121 -106
- package/build-module/view-grid.js.map +1 -1
- package/build-module/view-list.js +219 -85
- package/build-module/view-list.js.map +1 -1
- package/build-module/view-table.js +230 -201
- package/build-module/view-table.js.map +1 -1
- package/build-style/style-rtl.css +168 -44
- package/build-style/style.css +168 -44
- package/build-types/add-filter.d.ts +11 -0
- package/build-types/add-filter.d.ts.map +1 -0
- package/build-types/bulk-actions-toolbar.d.ts +12 -0
- package/build-types/bulk-actions-toolbar.d.ts.map +1 -0
- package/build-types/bulk-actions.d.ts +14 -0
- package/build-types/bulk-actions.d.ts.map +1 -0
- package/build-types/constants.d.ts +19 -32
- package/build-types/constants.d.ts.map +1 -1
- package/build-types/dataviews.d.ts +22 -0
- package/build-types/dataviews.d.ts.map +1 -0
- package/build-types/filter-and-sort-data-view.d.ts +3 -3
- package/build-types/filter-and-sort-data-view.d.ts.map +1 -1
- package/build-types/filter-summary.d.ts +14 -0
- package/build-types/filter-summary.d.ts.map +1 -0
- package/build-types/filters.d.ts +13 -0
- package/build-types/filters.d.ts.map +1 -0
- package/build-types/index.d.ts +4 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/item-actions.d.ts +35 -0
- package/build-types/item-actions.d.ts.map +1 -0
- package/build-types/layouts.d.ts +24 -0
- package/build-types/layouts.d.ts.map +1 -0
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/normalize-fields.d.ts +2 -2
- package/build-types/normalize-fields.d.ts.map +1 -1
- package/build-types/pagination.d.ts +16 -0
- package/build-types/pagination.d.ts.map +1 -0
- package/build-types/reset-filters.d.ts +13 -0
- package/build-types/reset-filters.d.ts.map +1 -0
- package/build-types/search-widget.d.ts +10 -0
- package/build-types/search-widget.d.ts.map +1 -0
- package/build-types/search.d.ts +13 -0
- package/build-types/search.d.ts.map +1 -0
- package/build-types/single-selection-checkbox.d.ts +17 -0
- package/build-types/single-selection-checkbox.d.ts.map +1 -0
- package/build-types/stories/fixtures.d.ts +114 -0
- package/build-types/stories/fixtures.d.ts.map +1 -0
- package/build-types/stories/index.story.d.ts +15 -0
- package/build-types/stories/index.story.d.ts.map +1 -0
- package/build-types/types.d.ts +221 -21
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils.d.ts +3 -0
- package/build-types/utils.d.ts.map +1 -0
- package/build-types/view-actions.d.ts +12 -0
- package/build-types/view-actions.d.ts.map +1 -0
- package/build-types/view-grid.d.ts +4 -0
- package/build-types/view-grid.d.ts.map +1 -0
- package/build-types/view-list.d.ts +4 -0
- package/build-types/view-list.d.ts.map +1 -0
- package/build-types/view-table.d.ts +5 -0
- package/build-types/view-table.d.ts.map +1 -0
- package/package.json +12 -13
- package/src/{add-filter.js → add-filter.tsx} +17 -1
- package/src/bulk-actions-toolbar.tsx +272 -0
- package/src/{bulk-actions.js → bulk-actions.tsx} +77 -17
- package/src/constants.ts +12 -5
- package/src/{dataviews.js → dataviews.tsx} +54 -14
- package/src/filter-and-sort-data-view.ts +13 -8
- package/src/{filter-summary.js → filter-summary.tsx} +38 -9
- package/src/{filters.js → filters.tsx} +18 -6
- package/src/{item-actions.js → item-actions.tsx} +119 -30
- package/src/normalize-fields.ts +4 -2
- package/src/{pagination.js → pagination.tsx} +29 -8
- package/src/{reset-filters.js → reset-filters.tsx} +17 -2
- package/src/{search-widget.js → search-widget.tsx} +27 -7
- package/src/{search.js → search.tsx} +22 -5
- package/src/{single-selection-checkbox.js → single-selection-checkbox.tsx} +17 -2
- package/src/style.scss +166 -43
- package/src/types.ts +286 -21
- package/src/{utils.js → utils.ts} +5 -13
- package/src/{view-actions.js → view-actions.tsx} +105 -49
- package/src/{view-grid.js → view-grid.tsx} +31 -18
- package/src/view-list.tsx +410 -0
- package/src/{view-table.js → view-table.tsx} +99 -40
- package/tsconfig.json +3 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dropdown-menu-helper.js +0 -71
- package/build/dropdown-menu-helper.js.map +0 -1
- package/build-module/dropdown-menu-helper.js +0 -64
- package/build-module/dropdown-menu-helper.js.map +0 -1
- package/src/dropdown-menu-helper.js +0 -61
- package/src/view-list.js +0 -207
- /package/src/{index.js → index.ts} +0 -0
- /package/src/{layouts.js → layouts.ts} +0 -0
- /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
package/build/item-actions.js
CHANGED
|
@@ -3,13 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.ActionModal = ActionModal;
|
|
7
|
+
exports.ActionWithModal = ActionWithModal;
|
|
8
|
+
exports.ActionsDropdownMenuGroup = ActionsDropdownMenuGroup;
|
|
6
9
|
exports.default = ItemActions;
|
|
7
|
-
var _react = require("react");
|
|
8
10
|
var _components = require("@wordpress/components");
|
|
9
11
|
var _i18n = require("@wordpress/i18n");
|
|
10
12
|
var _element = require("@wordpress/element");
|
|
11
13
|
var _icons = require("@wordpress/icons");
|
|
12
14
|
var _lockUnlock = require("./lock-unlock");
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
/**
|
|
17
|
+
* External dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
13
20
|
/**
|
|
14
21
|
* WordPress dependencies
|
|
15
22
|
*/
|
|
@@ -27,10 +34,12 @@ const {
|
|
|
27
34
|
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
28
35
|
function ButtonTrigger({
|
|
29
36
|
action,
|
|
30
|
-
onClick
|
|
37
|
+
onClick,
|
|
38
|
+
items
|
|
31
39
|
}) {
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
const label = typeof action.label === 'string' ? action.label : action.label(items);
|
|
41
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
42
|
+
label: label,
|
|
34
43
|
icon: action.icon,
|
|
35
44
|
isDestructive: action.isDestructive,
|
|
36
45
|
size: "compact",
|
|
@@ -39,60 +48,82 @@ function ButtonTrigger({
|
|
|
39
48
|
}
|
|
40
49
|
function DropdownMenuItemTrigger({
|
|
41
50
|
action,
|
|
42
|
-
onClick
|
|
51
|
+
onClick,
|
|
52
|
+
items
|
|
43
53
|
}) {
|
|
44
|
-
|
|
54
|
+
const label = typeof action.label === 'string' ? action.label : action.label(items);
|
|
55
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuItem, {
|
|
45
56
|
onClick: onClick,
|
|
46
|
-
hideOnClick: !action
|
|
47
|
-
|
|
57
|
+
hideOnClick: !('RenderModal' in action),
|
|
58
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuItemLabel, {
|
|
59
|
+
children: label
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function ActionModal({
|
|
64
|
+
action,
|
|
65
|
+
items,
|
|
66
|
+
closeModal
|
|
67
|
+
}) {
|
|
68
|
+
const label = typeof action.label === 'string' ? action.label : action.label(items);
|
|
69
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
|
|
70
|
+
title: action.modalHeader || label,
|
|
71
|
+
__experimentalHideHeader: !!action.hideModalHeader,
|
|
72
|
+
onRequestClose: closeModal !== null && closeModal !== void 0 ? closeModal : () => {},
|
|
73
|
+
overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(action.id)}`,
|
|
74
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(action.RenderModal, {
|
|
75
|
+
items: items,
|
|
76
|
+
closeModal: closeModal,
|
|
77
|
+
onActionStart: action.onActionStart,
|
|
78
|
+
onActionPerformed: action.onActionPerformed
|
|
79
|
+
})
|
|
80
|
+
});
|
|
48
81
|
}
|
|
49
82
|
function ActionWithModal({
|
|
50
83
|
action,
|
|
51
|
-
|
|
52
|
-
ActionTrigger
|
|
84
|
+
items,
|
|
85
|
+
ActionTrigger,
|
|
86
|
+
isBusy
|
|
53
87
|
}) {
|
|
54
88
|
const [isModalOpen, setIsModalOpen] = (0, _element.useState)(false);
|
|
55
89
|
const actionTriggerProps = {
|
|
56
90
|
action,
|
|
57
|
-
onClick: () =>
|
|
58
|
-
|
|
59
|
-
const {
|
|
60
|
-
RenderModal,
|
|
61
|
-
hideModalHeader
|
|
62
|
-
} = action;
|
|
63
|
-
return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(ActionTrigger, {
|
|
64
|
-
...actionTriggerProps
|
|
65
|
-
}), isModalOpen && (0, _react.createElement)(_components.Modal, {
|
|
66
|
-
title: action.modalHeader || action.label,
|
|
67
|
-
__experimentalHideHeader: !!hideModalHeader,
|
|
68
|
-
onRequestClose: () => {
|
|
69
|
-
setIsModalOpen(false);
|
|
91
|
+
onClick: () => {
|
|
92
|
+
setIsModalOpen(true);
|
|
70
93
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
94
|
+
items,
|
|
95
|
+
isBusy
|
|
96
|
+
};
|
|
97
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
98
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ActionTrigger, {
|
|
99
|
+
...actionTriggerProps
|
|
100
|
+
}), isModalOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionModal, {
|
|
101
|
+
action: action,
|
|
102
|
+
items: items,
|
|
103
|
+
closeModal: () => setIsModalOpen(false)
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
76
106
|
}
|
|
77
107
|
function ActionsDropdownMenuGroup({
|
|
78
108
|
actions,
|
|
79
109
|
item
|
|
80
110
|
}) {
|
|
81
|
-
return (0,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
111
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuGroup, {
|
|
112
|
+
children: actions.map(action => {
|
|
113
|
+
if ('RenderModal' in action) {
|
|
114
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionWithModal, {
|
|
115
|
+
action: action,
|
|
116
|
+
items: [item],
|
|
117
|
+
ActionTrigger: DropdownMenuItemTrigger
|
|
118
|
+
}, action.id);
|
|
119
|
+
}
|
|
120
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenuItemTrigger, {
|
|
85
121
|
action: action,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
key: action.id,
|
|
92
|
-
action: action,
|
|
93
|
-
onClick: () => action.callback([item])
|
|
94
|
-
});
|
|
95
|
-
}));
|
|
122
|
+
onClick: () => action.callback([item]),
|
|
123
|
+
items: [item]
|
|
124
|
+
}, action.id);
|
|
125
|
+
})
|
|
126
|
+
});
|
|
96
127
|
}
|
|
97
128
|
function ItemActions({
|
|
98
129
|
item,
|
|
@@ -113,54 +144,55 @@ function ItemActions({
|
|
|
113
144
|
};
|
|
114
145
|
}, [actions, item]);
|
|
115
146
|
if (isCompact) {
|
|
116
|
-
return (0,
|
|
147
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CompactItemActions, {
|
|
117
148
|
item: item,
|
|
118
149
|
actions: eligibleActions
|
|
119
150
|
});
|
|
120
151
|
}
|
|
121
|
-
return (0,
|
|
152
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
122
153
|
spacing: 1,
|
|
123
154
|
justify: "flex-end",
|
|
124
155
|
className: "dataviews-item-actions",
|
|
125
156
|
style: {
|
|
126
157
|
flexShrink: '0',
|
|
127
158
|
width: 'auto'
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
159
|
+
},
|
|
160
|
+
children: [!!primaryActions.length && primaryActions.map(action => {
|
|
161
|
+
if ('RenderModal' in action) {
|
|
162
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionWithModal, {
|
|
163
|
+
action: action,
|
|
164
|
+
items: [item],
|
|
165
|
+
ActionTrigger: ButtonTrigger
|
|
166
|
+
}, action.id);
|
|
167
|
+
}
|
|
168
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonTrigger, {
|
|
133
169
|
action: action,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
});
|
|
143
|
-
}), (0, _react.createElement)(CompactItemActions, {
|
|
144
|
-
item: item,
|
|
145
|
-
actions: eligibleActions
|
|
146
|
-
}));
|
|
170
|
+
onClick: () => action.callback([item]),
|
|
171
|
+
items: [item]
|
|
172
|
+
}, action.id);
|
|
173
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(CompactItemActions, {
|
|
174
|
+
item: item,
|
|
175
|
+
actions: eligibleActions
|
|
176
|
+
})]
|
|
177
|
+
});
|
|
147
178
|
}
|
|
148
179
|
function CompactItemActions({
|
|
149
180
|
item,
|
|
150
181
|
actions
|
|
151
182
|
}) {
|
|
152
|
-
return (0,
|
|
153
|
-
trigger: (0,
|
|
183
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DropdownMenu, {
|
|
184
|
+
trigger: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
154
185
|
size: "compact",
|
|
155
186
|
icon: _icons.moreVertical,
|
|
156
187
|
label: (0, _i18n.__)('Actions'),
|
|
157
188
|
disabled: !actions.length,
|
|
158
189
|
className: "dataviews-all-actions-button"
|
|
159
190
|
}),
|
|
160
|
-
placement: "bottom-end"
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
191
|
+
placement: "bottom-end",
|
|
192
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionsDropdownMenuGroup, {
|
|
193
|
+
actions: actions,
|
|
194
|
+
item: item
|
|
195
|
+
})
|
|
196
|
+
});
|
|
165
197
|
}
|
|
166
198
|
//# sourceMappingURL=item-actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_element","_icons","_lockUnlock","DropdownMenuV2","DropdownMenu","DropdownMenuGroupV2","DropdownMenuGroup","DropdownMenuItemV2","DropdownMenuItem","DropdownMenuItemLabelV2","DropdownMenuItemLabel","kebabCase","unlock","componentsPrivateApis","ButtonTrigger","action","onClick","_react","createElement","Button","label","icon","isDestructive","size","DropdownMenuItemTrigger","hideOnClick","RenderModal","ActionWithModal","item","ActionTrigger","isModalOpen","setIsModalOpen","useState","actionTriggerProps","hideModalHeader","Fragment","Modal","title","modalHeader","__experimentalHideHeader","onRequestClose","overlayClassName","id","items","closeModal","ActionsDropdownMenuGroup","actions","map","key","callback","ItemActions","isCompact","primaryActions","eligibleActions","useMemo","_eligibleActions","filter","isEligible","_primaryActions","isPrimary","CompactItemActions","__experimentalHStack","spacing","justify","className","style","flexShrink","width","length","trigger","moreVertical","__","disabled","placement"],"sources":["@wordpress/dataviews/src/item-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { moreVertical } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst {\n\tDropdownMenuV2: DropdownMenu,\n\tDropdownMenuGroupV2: DropdownMenuGroup,\n\tDropdownMenuItemV2: DropdownMenuItem,\n\tDropdownMenuItemLabelV2: DropdownMenuItemLabel,\n\tkebabCase,\n} = unlock( componentsPrivateApis );\n\nfunction ButtonTrigger( { action, onClick } ) {\n\treturn (\n\t\t<Button\n\t\t\tlabel={ action.label }\n\t\t\ticon={ action.icon }\n\t\t\tisDestructive={ action.isDestructive }\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ onClick }\n\t\t/>\n\t);\n}\n\nfunction DropdownMenuItemTrigger( { action, onClick } ) {\n\treturn (\n\t\t<DropdownMenuItem\n\t\t\tonClick={ onClick }\n\t\t\thideOnClick={ ! action.RenderModal }\n\t\t>\n\t\t\t<DropdownMenuItemLabel>{ action.label }</DropdownMenuItemLabel>\n\t\t</DropdownMenuItem>\n\t);\n}\n\nfunction ActionWithModal( { action, item, ActionTrigger } ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst actionTriggerProps = {\n\t\taction,\n\t\tonClick: () => setIsModalOpen( true ),\n\t};\n\tconst { RenderModal, hideModalHeader } = action;\n\treturn (\n\t\t<>\n\t\t\t<ActionTrigger { ...actionTriggerProps } />\n\t\t\t{ isModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ action.modalHeader || action.label }\n\t\t\t\t\t__experimentalHideHeader={ !! hideModalHeader }\n\t\t\t\t\tonRequestClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\toverlayClassName={ `dataviews-action-modal dataviews-action-modal__${ kebabCase(\n\t\t\t\t\t\taction.id\n\t\t\t\t\t) }` }\n\t\t\t\t>\n\t\t\t\t\t<RenderModal\n\t\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction ActionsDropdownMenuGroup( { actions, item } ) {\n\treturn (\n\t\t<DropdownMenuGroup>\n\t\t\t{ actions.map( ( action ) => {\n\t\t\t\tif ( !! action.RenderModal ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ActionWithModal\n\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\tActionTrigger={ DropdownMenuItemTrigger }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuItemTrigger\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tonClick={ () => action.callback( [ item ] ) }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</DropdownMenuGroup>\n\t);\n}\n\nexport default function ItemActions( { item, actions, isCompact } ) {\n\tconst { primaryActions, eligibleActions } = useMemo( () => {\n\t\t// If an action is eligible for all items, doesn't need\n\t\t// to provide the `isEligible` function.\n\t\tconst _eligibleActions = actions.filter(\n\t\t\t( action ) => ! action.isEligible || action.isEligible( item )\n\t\t);\n\t\tconst _primaryActions = _eligibleActions.filter(\n\t\t\t( action ) => action.isPrimary && !! action.icon\n\t\t);\n\t\treturn {\n\t\t\tprimaryActions: _primaryActions,\n\t\t\teligibleActions: _eligibleActions,\n\t\t};\n\t}, [ actions, item ] );\n\tif ( isCompact ) {\n\t\treturn <CompactItemActions item={ item } actions={ eligibleActions } />;\n\t}\n\treturn (\n\t\t<HStack\n\t\t\tspacing={ 1 }\n\t\t\tjustify=\"flex-end\"\n\t\t\tclassName=\"dataviews-item-actions\"\n\t\t\tstyle={ {\n\t\t\t\tflexShrink: '0',\n\t\t\t\twidth: 'auto',\n\t\t\t} }\n\t\t>\n\t\t\t{ !! primaryActions.length &&\n\t\t\t\tprimaryActions.map( ( action ) => {\n\t\t\t\t\tif ( !! action.RenderModal ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<ActionWithModal\n\t\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\tActionTrigger={ ButtonTrigger }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ButtonTrigger\n\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\tonClick={ () => action.callback( [ item ] ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t<CompactItemActions item={ item } actions={ eligibleActions } />\n\t\t</HStack>\n\t);\n}\n\nfunction CompactItemActions( { item, actions } ) {\n\treturn (\n\t\t<DropdownMenu\n\t\t\ttrigger={\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\tclassName=\"dataviews-all-actions-button\"\n\t\t\t\t/>\n\t\t\t}\n\t\t\tplacement=\"bottom-end\"\n\t\t>\n\t\t\t<ActionsDropdownMenuGroup actions={ actions }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_icons","_lockUnlock","_jsxRuntime","DropdownMenuV2","DropdownMenu","DropdownMenuGroupV2","DropdownMenuGroup","DropdownMenuItemV2","DropdownMenuItem","DropdownMenuItemLabelV2","DropdownMenuItemLabel","kebabCase","unlock","componentsPrivateApis","ButtonTrigger","action","onClick","items","label","jsx","Button","icon","isDestructive","size","DropdownMenuItemTrigger","hideOnClick","children","ActionModal","closeModal","Modal","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","overlayClassName","id","RenderModal","onActionStart","onActionPerformed","ActionWithModal","ActionTrigger","isBusy","isModalOpen","setIsModalOpen","useState","actionTriggerProps","jsxs","Fragment","ActionsDropdownMenuGroup","actions","item","map","callback","ItemActions","isCompact","primaryActions","eligibleActions","useMemo","_eligibleActions","filter","isEligible","_primaryActions","isPrimary","CompactItemActions","__experimentalHStack","spacing","justify","className","style","flexShrink","width","length","trigger","moreVertical","__","disabled","placement"],"sources":["@wordpress/dataviews/src/item-actions.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { MouseEventHandler, ReactElement } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { moreVertical } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport type { Action, ActionModal as ActionModalType, AnyItem } from './types';\n\nconst {\n\tDropdownMenuV2: DropdownMenu,\n\tDropdownMenuGroupV2: DropdownMenuGroup,\n\tDropdownMenuItemV2: DropdownMenuItem,\n\tDropdownMenuItemLabelV2: DropdownMenuItemLabel,\n\tkebabCase,\n} = unlock( componentsPrivateApis );\n\nexport interface ActionTriggerProps< Item extends AnyItem > {\n\taction: Action< Item >;\n\tonClick: MouseEventHandler;\n\tisBusy?: boolean;\n\titems: Item[];\n}\n\ninterface ActionModalProps< Item extends AnyItem > {\n\taction: ActionModalType< Item >;\n\titems: Item[];\n\tcloseModal?: () => void;\n}\n\ninterface ActionWithModalProps< Item extends AnyItem >\n\textends ActionModalProps< Item > {\n\tActionTrigger: ( props: ActionTriggerProps< Item > ) => ReactElement;\n\tisBusy?: boolean;\n}\n\ninterface ActionsDropdownMenuGroupProps< Item extends AnyItem > {\n\tactions: Action< Item >[];\n\titem: Item;\n}\n\ninterface ItemActionsProps< Item extends AnyItem > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tisCompact?: boolean;\n}\n\ninterface CompactItemActionsProps< Item extends AnyItem > {\n\titem: Item;\n\tactions: Action< Item >[];\n}\n\nfunction ButtonTrigger< Item extends AnyItem >( {\n\taction,\n\tonClick,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Button\n\t\t\tlabel={ label }\n\t\t\ticon={ action.icon }\n\t\t\tisDestructive={ action.isDestructive }\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ onClick }\n\t\t/>\n\t);\n}\n\nfunction DropdownMenuItemTrigger< Item extends AnyItem >( {\n\taction,\n\tonClick,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<DropdownMenuItem\n\t\t\tonClick={ onClick }\n\t\t\thideOnClick={ ! ( 'RenderModal' in action ) }\n\t\t>\n\t\t\t<DropdownMenuItemLabel>{ label }</DropdownMenuItemLabel>\n\t\t</DropdownMenuItem>\n\t);\n}\n\nexport function ActionModal< Item extends AnyItem >( {\n\taction,\n\titems,\n\tcloseModal,\n}: ActionModalProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal ?? ( () => {} ) }\n\t\t\toverlayClassName={ `dataviews-action-modal dataviews-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal\n\t\t\t\titems={ items }\n\t\t\t\tcloseModal={ closeModal }\n\t\t\t\tonActionStart={ action.onActionStart }\n\t\t\t\tonActionPerformed={ action.onActionPerformed }\n\t\t\t/>\n\t\t</Modal>\n\t);\n}\n\nexport function ActionWithModal< Item extends AnyItem >( {\n\taction,\n\titems,\n\tActionTrigger,\n\tisBusy,\n}: ActionWithModalProps< Item > ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst actionTriggerProps = {\n\t\taction,\n\t\tonClick: () => {\n\t\t\tsetIsModalOpen( true );\n\t\t},\n\t\titems,\n\t\tisBusy,\n\t};\n\treturn (\n\t\t<>\n\t\t\t<ActionTrigger { ...actionTriggerProps } />\n\t\t\t{ isModalOpen && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ action }\n\t\t\t\t\titems={ items }\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport function ActionsDropdownMenuGroup< Item extends AnyItem >( {\n\tactions,\n\titem,\n}: ActionsDropdownMenuGroupProps< Item > ) {\n\treturn (\n\t\t<DropdownMenuGroup>\n\t\t\t{ actions.map( ( action ) => {\n\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ActionWithModal\n\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\t\t\tActionTrigger={ DropdownMenuItemTrigger }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t<DropdownMenuItemTrigger\n\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\tonClick={ () => action.callback( [ item ] ) }\n\t\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</DropdownMenuGroup>\n\t);\n}\n\nexport default function ItemActions< Item extends AnyItem >( {\n\titem,\n\tactions,\n\tisCompact,\n}: ItemActionsProps< Item > ) {\n\tconst { primaryActions, eligibleActions } = useMemo( () => {\n\t\t// If an action is eligible for all items, doesn't need\n\t\t// to provide the `isEligible` function.\n\t\tconst _eligibleActions = actions.filter(\n\t\t\t( action ) => ! action.isEligible || action.isEligible( item )\n\t\t);\n\t\tconst _primaryActions = _eligibleActions.filter(\n\t\t\t( action ) => action.isPrimary && !! action.icon\n\t\t);\n\t\treturn {\n\t\t\tprimaryActions: _primaryActions,\n\t\t\teligibleActions: _eligibleActions,\n\t\t};\n\t}, [ actions, item ] );\n\tif ( isCompact ) {\n\t\treturn <CompactItemActions item={ item } actions={ eligibleActions } />;\n\t}\n\treturn (\n\t\t<HStack\n\t\t\tspacing={ 1 }\n\t\t\tjustify=\"flex-end\"\n\t\t\tclassName=\"dataviews-item-actions\"\n\t\t\tstyle={ {\n\t\t\t\tflexShrink: '0',\n\t\t\t\twidth: 'auto',\n\t\t\t} }\n\t\t>\n\t\t\t{ !! primaryActions.length &&\n\t\t\t\tprimaryActions.map( ( action ) => {\n\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<ActionWithModal\n\t\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\t\t\t\tActionTrigger={ ButtonTrigger }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ButtonTrigger\n\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\tonClick={ () => action.callback( [ item ] ) }\n\t\t\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t<CompactItemActions item={ item } actions={ eligibleActions } />\n\t\t</HStack>\n\t);\n}\n\nfunction CompactItemActions< Item extends AnyItem >( {\n\titem,\n\tactions,\n}: CompactItemActionsProps< Item > ) {\n\treturn (\n\t\t<DropdownMenu\n\t\t\ttrigger={\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\tclassName=\"dataviews-all-actions-button\"\n\t\t\t\t/>\n\t\t\t}\n\t\t\tplacement=\"bottom-end\"\n\t\t>\n\t\t\t<ActionsDropdownMenuGroup actions={ actions } item={ item } />\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";;;;;;;;;AAQA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAKA,IAAAI,WAAA,GAAAJ,OAAA;AAAuC,IAAAK,WAAA,GAAAL,OAAA;AArBvC;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAIA,MAAM;EACLM,cAAc,EAAEC,YAAY;EAC5BC,mBAAmB,EAAEC,iBAAiB;EACtCC,kBAAkB,EAAEC,gBAAgB;EACpCC,uBAAuB,EAAEC,qBAAqB;EAC9CC;AACD,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAqCnC,SAASC,aAAaA,CAA0B;EAC/CC,MAAM;EACNC,OAAO;EACPC;AAC2B,CAAC,EAAG;EAC/B,MAAMC,KAAK,GACV,OAAOH,MAAM,CAACG,KAAK,KAAK,QAAQ,GAAGH,MAAM,CAACG,KAAK,GAAGH,MAAM,CAACG,KAAK,CAAED,KAAM,CAAC;EAC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A8B,CACxC,CACD;IACDS,SAAS,EAAC,YAAY;IAAAnD,QAAA,eAEtB,IAAAxB,WAAA,CAAAiB,GAAA,EAAC8B,wBAAwB;MAACC,OAAO,EAAGA,OAAS;MAACC,IAAI,EAAGA;IAAM,CAAE;EAAC,CACjD,CAAC;AAEjB","ignoreList":[]}
|
package/build/layouts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_icons","_viewTable","_interopRequireDefault","_viewGrid","_viewList","_constants","VIEW_LAYOUTS","exports","type","LAYOUT_TABLE","label","__","component","ViewTable","icon","blockTable","LAYOUT_GRID","ViewGrid","category","LAYOUT_LIST","ViewList","isRTL","formatListBulletsRTL","formatListBullets"],"sources":["@wordpress/dataviews/src/layouts.
|
|
1
|
+
{"version":3,"names":["_i18n","require","_icons","_viewTable","_interopRequireDefault","_viewGrid","_viewList","_constants","VIEW_LAYOUTS","exports","type","LAYOUT_TABLE","label","__","component","ViewTable","icon","blockTable","LAYOUT_GRID","ViewGrid","category","LAYOUT_LIST","ViewList","isRTL","formatListBulletsRTL","formatListBullets"],"sources":["@wordpress/dataviews/src/layouts.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tblockTable,\n\tcategory,\n\tformatListBullets,\n\tformatListBulletsRTL,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport ViewTable from './view-table';\nimport ViewGrid from './view-grid';\nimport ViewList from './view-list';\nimport { LAYOUT_GRID, LAYOUT_LIST, LAYOUT_TABLE } from './constants';\n\nexport const VIEW_LAYOUTS = [\n\t{\n\t\ttype: LAYOUT_TABLE,\n\t\tlabel: __( 'Table' ),\n\t\tcomponent: ViewTable,\n\t\ticon: blockTable,\n\t},\n\t{\n\t\ttype: LAYOUT_GRID,\n\t\tlabel: __( 'Grid' ),\n\t\tcomponent: ViewGrid,\n\t\ticon: category,\n\t},\n\t{\n\t\ttype: LAYOUT_LIST,\n\t\tlabel: __( 'List' ),\n\t\tcomponent: ViewList,\n\t\ticon: isRTL() ? formatListBulletsRTL : formatListBullets,\n\t},\n];\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,SAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,SAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAjBA;AACA;AACA;;AASA;AACA;AACA;;AAMO,MAAMO,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,CAC3B;EACCE,IAAI,EAAEC,uBAAY;EAClBC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBC,SAAS,EAAEC,kBAAS;EACpBC,IAAI,EAAEC;AACP,CAAC,EACD;EACCP,IAAI,EAAEQ,sBAAW;EACjBN,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO,CAAC;EACnBC,SAAS,EAAEK,iBAAQ;EACnBH,IAAI,EAAEI;AACP,CAAC,EACD;EACCV,IAAI,EAAEW,sBAAW;EACjBT,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAO,CAAC;EACnBC,SAAS,EAAEQ,iBAAQ;EACnBN,IAAI,EAAE,IAAAO,WAAK,EAAC,CAAC,GAAGC,2BAAoB,GAAGC;AACxC,CAAC,CACD","ignoreList":[]}
|
package/build/lock-unlock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_privateApis","require","lock","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/dataviews/src/lock-unlock.
|
|
1
|
+
{"version":3,"names":["_privateApis","require","lock","unlock","__dangerousOptInToUnstableAPIsOnlyForCoreModules","exports"],"sources":["@wordpress/dataviews/src/lock-unlock.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',\n\t\t'@wordpress/dataviews'\n\t);\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5B,IAAAC,6DAAgD,EAC/C,iHAAiH,EACjH,sBACD,CAAC;AAACC,OAAA,CAAAF,MAAA,GAAAA,MAAA;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["normalizeFields","fields","map","field","getValue","item","id","header","render"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Field, NormalizedField } from './types';\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport function normalizeFields(
|
|
1
|
+
{"version":3,"names":["normalizeFields","fields","map","field","getValue","item","id","header","render"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Field, AnyItem, NormalizedField } from './types';\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport function normalizeFields< Item extends AnyItem >(\n\tfields: Field< Item >[]\n): NormalizedField< Item >[] {\n\treturn fields.map( ( field ) => {\n\t\tconst getValue = field.getValue || ( ( { item } ) => item[ field.id ] );\n\n\t\treturn {\n\t\t\t...field,\n\t\t\theader: field.header || field.id,\n\t\t\tgetValue,\n\t\t\trender: field.render || getValue,\n\t\t};\n\t} );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAeA,CAC9BC,MAAuB,EACK;EAC5B,OAAOA,MAAM,CAACC,GAAG,CAAIC,KAAK,IAAM;IAC/B,MAAMC,QAAQ,GAAGD,KAAK,CAACC,QAAQ,KAAM,CAAE;MAAEC;IAAK,CAAC,KAAMA,IAAI,CAAEF,KAAK,CAACG,EAAE,CAAE,CAAE;IAEvE,OAAO;MACN,GAAGH,KAAK;MACRI,MAAM,EAAEJ,KAAK,CAACI,MAAM,IAAIJ,KAAK,CAACG,EAAE;MAChCF,QAAQ;MACRI,MAAM,EAAEL,KAAK,CAACK,MAAM,IAAIJ;IACzB,CAAC;EACF,CAAE,CAAC;AACJ","ignoreList":[]}
|
package/build/pagination.js
CHANGED
|
@@ -4,15 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _components = require("@wordpress/components");
|
|
9
8
|
var _element = require("@wordpress/element");
|
|
10
9
|
var _i18n = require("@wordpress/i18n");
|
|
11
10
|
var _icons = require("@wordpress/icons");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
/**
|
|
13
13
|
* WordPress dependencies
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
16
20
|
const Pagination = (0, _element.memo)(function Pagination({
|
|
17
21
|
view,
|
|
18
22
|
onChangeView,
|
|
@@ -21,69 +25,74 @@ const Pagination = (0, _element.memo)(function Pagination({
|
|
|
21
25
|
totalPages
|
|
22
26
|
}
|
|
23
27
|
}) {
|
|
28
|
+
var _view$page;
|
|
24
29
|
if (!totalItems || !totalPages) {
|
|
25
30
|
return null;
|
|
26
31
|
}
|
|
27
|
-
|
|
32
|
+
const currentPage = (_view$page = view.page) !== null && _view$page !== void 0 ? _view$page : 1;
|
|
33
|
+
return !!totalItems && totalPages !== 1 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
28
34
|
expanded: false,
|
|
29
35
|
spacing: 6,
|
|
30
36
|
justify: "end",
|
|
31
|
-
className: "dataviews-pagination"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
className: "dataviews-pagination",
|
|
38
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalHStack, {
|
|
39
|
+
justify: "flex-start",
|
|
40
|
+
expanded: false,
|
|
41
|
+
spacing: 2,
|
|
42
|
+
className: "dataviews-pagination__page-selection",
|
|
43
|
+
children: (0, _element.createInterpolateElement)((0, _i18n.sprintf)(
|
|
44
|
+
// translators: %s: Total number of pages.
|
|
45
|
+
(0, _i18n._x)('Page <CurrentPageControl /> of %s', 'paging'), totalPages), {
|
|
46
|
+
CurrentPageControl: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SelectControl, {
|
|
47
|
+
"aria-label": (0, _i18n.__)('Current page'),
|
|
48
|
+
value: view.page?.toString(),
|
|
49
|
+
options: Array.from(Array(totalPages)).map((_, i) => {
|
|
50
|
+
const page = i + 1;
|
|
51
|
+
return {
|
|
52
|
+
value: page.toString(),
|
|
53
|
+
label: page.toString()
|
|
54
|
+
};
|
|
55
|
+
}),
|
|
56
|
+
onChange: newValue => {
|
|
57
|
+
onChangeView({
|
|
58
|
+
...view,
|
|
59
|
+
page: +newValue
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
size: "compact",
|
|
63
|
+
__nextHasNoMarginBottom: true
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
67
|
+
expanded: false,
|
|
68
|
+
spacing: 1,
|
|
69
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
70
|
+
onClick: () => onChangeView({
|
|
52
71
|
...view,
|
|
53
|
-
page:
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
page: view.page + 1
|
|
78
|
-
}),
|
|
79
|
-
disabled: view.page >= totalPages,
|
|
80
|
-
__experimentalIsFocusable: true,
|
|
81
|
-
label: (0, _i18n.__)('Next page'),
|
|
82
|
-
icon: _icons.chevronRight,
|
|
83
|
-
showTooltip: true,
|
|
84
|
-
size: "compact",
|
|
85
|
-
tooltipPosition: "top"
|
|
86
|
-
})));
|
|
72
|
+
page: currentPage - 1
|
|
73
|
+
}),
|
|
74
|
+
disabled: currentPage === 1,
|
|
75
|
+
__experimentalIsFocusable: true,
|
|
76
|
+
label: (0, _i18n.__)('Previous page'),
|
|
77
|
+
icon: _icons.chevronLeft,
|
|
78
|
+
showTooltip: true,
|
|
79
|
+
size: "compact",
|
|
80
|
+
tooltipPosition: "top"
|
|
81
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
82
|
+
onClick: () => onChangeView({
|
|
83
|
+
...view,
|
|
84
|
+
page: currentPage + 1
|
|
85
|
+
}),
|
|
86
|
+
disabled: currentPage >= totalPages,
|
|
87
|
+
__experimentalIsFocusable: true,
|
|
88
|
+
label: (0, _i18n.__)('Next page'),
|
|
89
|
+
icon: _icons.chevronRight,
|
|
90
|
+
showTooltip: true,
|
|
91
|
+
size: "compact",
|
|
92
|
+
tooltipPosition: "top"
|
|
93
|
+
})]
|
|
94
|
+
})]
|
|
95
|
+
});
|
|
87
96
|
});
|
|
88
97
|
var _default = exports.default = Pagination;
|
|
89
98
|
//# sourceMappingURL=pagination.js.map
|
package/build/pagination.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_i18n","_icons","Pagination","memo","view","onChangeView","paginationInfo","totalItems","totalPages","
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_i18n","_icons","_jsxRuntime","Pagination","memo","view","onChangeView","paginationInfo","totalItems","totalPages","_view$page","currentPage","page","jsxs","__experimentalHStack","expanded","spacing","justify","className","children","jsx","createInterpolateElement","sprintf","_x","CurrentPageControl","SelectControl","__","value","toString","options","Array","from","map","_","i","label","onChange","newValue","size","__nextHasNoMarginBottom","Button","onClick","disabled","__experimentalIsFocusable","icon","chevronLeft","showTooltip","tooltipPosition","chevronRight","_default","exports","default"],"sources":["@wordpress/dataviews/src/pagination.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\tSelectControl,\n} from '@wordpress/components';\nimport { createInterpolateElement, memo } from '@wordpress/element';\nimport { sprintf, __, _x } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type { View } from './types';\n\ninterface PaginationProps {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t};\n}\n\nconst Pagination = memo( function Pagination( {\n\tview,\n\tonChangeView,\n\tpaginationInfo: { totalItems = 0, totalPages },\n}: PaginationProps ) {\n\tif ( ! totalItems || ! totalPages ) {\n\t\treturn null;\n\t}\n\tconst currentPage = view.page ?? 1;\n\treturn (\n\t\t!! totalItems &&\n\t\ttotalPages !== 1 && (\n\t\t\t<HStack\n\t\t\t\texpanded={ false }\n\t\t\t\tspacing={ 6 }\n\t\t\t\tjustify=\"end\"\n\t\t\t\tclassName=\"dataviews-pagination\"\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\tclassName=\"dataviews-pagination__page-selection\"\n\t\t\t\t>\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t// translators: %s: Total number of pages.\n\t\t\t\t\t\t\t_x( 'Page <CurrentPageControl /> of %s', 'paging' ),\n\t\t\t\t\t\t\ttotalPages\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tCurrentPageControl: (\n\t\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Current page' ) }\n\t\t\t\t\t\t\t\t\tvalue={ view.page?.toString() }\n\t\t\t\t\t\t\t\t\toptions={ Array.from(\n\t\t\t\t\t\t\t\t\t\tArray( totalPages )\n\t\t\t\t\t\t\t\t\t).map( ( _, i ) => {\n\t\t\t\t\t\t\t\t\t\tconst page = i + 1;\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\tvalue: page.toString(),\n\t\t\t\t\t\t\t\t\t\t\tlabel: page.toString(),\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\t\t\t\t\tpage: +newValue,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t\t<HStack expanded={ false } spacing={ 1 }>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\t\tpage: currentPage - 1,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdisabled={ currentPage === 1 }\n\t\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t\t\tlabel={ __( 'Previous page' ) }\n\t\t\t\t\t\ticon={ chevronLeft }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tonChangeView( { ...view, page: currentPage + 1 } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdisabled={ currentPage >= totalPages }\n\t\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t\t\tlabel={ __( 'Next page' ) }\n\t\t\t\t\t\ticon={ chevronRight }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</HStack>\n\t\t)\n\t);\n} );\n\nexport default Pagination;\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAA6D,IAAAI,WAAA,GAAAJ,OAAA;AAV7D;AACA;AACA;;AAUA;AACA;AACA;;AAYA,MAAMK,UAAU,GAAG,IAAAC,aAAI,EAAE,SAASD,UAAUA,CAAE;EAC7CE,IAAI;EACJC,YAAY;EACZC,cAAc,EAAE;IAAEC,UAAU,GAAG,CAA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hD,UAAU","ignoreList":[]}
|
package/build/reset-filters.js
CHANGED
|
@@ -4,13 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = ResetFilter;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _components = require("@wordpress/components");
|
|
9
8
|
var _i18n = require("@wordpress/i18n");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
/**
|
|
11
11
|
* WordPress dependencies
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
14
18
|
function ResetFilter({
|
|
15
19
|
filters,
|
|
16
20
|
view,
|
|
@@ -18,7 +22,7 @@ function ResetFilter({
|
|
|
18
22
|
}) {
|
|
19
23
|
const isPrimary = field => filters.some(_filter => _filter.field === field && _filter.isPrimary);
|
|
20
24
|
const isDisabled = !view.search && !view.filters?.some(_filter => _filter.value !== undefined || !isPrimary(_filter.field));
|
|
21
|
-
return (0,
|
|
25
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
22
26
|
disabled: isDisabled,
|
|
23
27
|
__experimentalIsFocusable: true,
|
|
24
28
|
size: "compact",
|
|
@@ -31,7 +35,8 @@ function ResetFilter({
|
|
|
31
35
|
search: '',
|
|
32
36
|
filters: []
|
|
33
37
|
});
|
|
34
|
-
}
|
|
35
|
-
|
|
38
|
+
},
|
|
39
|
+
children: (0, _i18n.__)('Reset')
|
|
40
|
+
});
|
|
36
41
|
}
|
|
37
42
|
//# sourceMappingURL=reset-filters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","ResetFilter","filters","view","onChangeView","isPrimary","field","some","_filter","isDisabled","search","value","undefined","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_jsxRuntime","ResetFilter","filters","view","onChangeView","isPrimary","field","some","_filter","isDisabled","search","value","undefined","jsx","Button","disabled","__experimentalIsFocusable","size","variant","className","onClick","page","children","__"],"sources":["@wordpress/dataviews/src/reset-filters.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { NormalizedFilter, View } from './types';\n\ninterface ResetFilterProps {\n\tfilters: NormalizedFilter[];\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n}\n\nexport default function ResetFilter( {\n\tfilters,\n\tview,\n\tonChangeView,\n}: ResetFilterProps ) {\n\tconst isPrimary = ( field: string ) =>\n\t\tfilters.some(\n\t\t\t( _filter ) => _filter.field === field && _filter.isPrimary\n\t\t);\n\tconst isDisabled =\n\t\t! view.search &&\n\t\t! view.filters?.some(\n\t\t\t( _filter ) =>\n\t\t\t\t_filter.value !== undefined || ! isPrimary( _filter.field )\n\t\t);\n\treturn (\n\t\t<Button\n\t\t\tdisabled={ isDisabled }\n\t\t\t__experimentalIsFocusable\n\t\t\tsize=\"compact\"\n\t\t\tvariant=\"tertiary\"\n\t\t\tclassName=\"dataviews-filters__reset-button\"\n\t\t\tonClick={ () => {\n\t\t\t\tonChangeView( {\n\t\t\t\t\t...view,\n\t\t\t\t\tpage: 1,\n\t\t\t\t\tsearch: '',\n\t\t\t\t\tfilters: [],\n\t\t\t\t} );\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Reset' ) }\n\t\t</Button>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAAqC,IAAAE,WAAA,GAAAF,OAAA;AAJrC;AACA;AACA;;AAIA;AACA;AACA;;AASe,SAASG,WAAWA,CAAE;EACpCC,OAAO;EACPC,IAAI;EACJC;AACiB,CAAC,EAAG;EACrB,MAAMC,SAAS,GAAKC,KAAa,IAChCJ,OAAO,CAACK,IAAI,CACTC,OAAO,IAAMA,OAAO,CAACF,KAAK,KAAKA,KAAK,IAAIE,OAAO,CAACH,SACnD,CAAC;EACF,MAAMI,UAAU,GACf,CAAEN,IAAI,CAACO,MAAM,IACb,CAAEP,IAAI,CAACD,OAAO,EAAEK,IAAI,CACjBC,OAAO,IACRA,OAAO,CAACG,KAAK,KAAKC,SAAS,IAAI,CAAEP,SAAS,CAAEG,OAAO,CAACF,KAAM,CAC5D,CAAC;EACF,oBACC,IAAAN,WAAA,CAAAa,GAAA,EAAChB,WAAA,CAAAiB,MAAM;IACNC,QAAQ,EAAGN,UAAY;IACvBO,yBAAyB;IACzBC,IAAI,EAAC,SAAS;IACdC,OAAO,EAAC,UAAU;IAClBC,SAAS,EAAC,iCAAiC;IAC3CC,OAAO,EAAGA,CAAA,KAAM;MACfhB,YAAY,CAAE;QACb,GAAGD,IAAI;QACPkB,IAAI,EAAE,CAAC;QACPX,MAAM,EAAE,EAAE;QACVR,OAAO,EAAE;MACV,CAAE,CAAC;IACJ,CAAG;IAAAoB,QAAA,EAED,IAAAC,QAAE,EAAE,OAAQ;EAAC,CACR,CAAC;AAEX","ignoreList":[]}
|