@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
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
6
|
* WordPress dependencies
|
|
4
7
|
*/
|
|
@@ -11,6 +14,9 @@ import { moreVertical } from '@wordpress/icons';
|
|
|
11
14
|
* Internal dependencies
|
|
12
15
|
*/
|
|
13
16
|
import { unlock } from './lock-unlock';
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
20
|
const {
|
|
15
21
|
DropdownMenuV2: DropdownMenu,
|
|
16
22
|
DropdownMenuGroupV2: DropdownMenuGroup,
|
|
@@ -20,10 +26,12 @@ const {
|
|
|
20
26
|
} = unlock(componentsPrivateApis);
|
|
21
27
|
function ButtonTrigger({
|
|
22
28
|
action,
|
|
23
|
-
onClick
|
|
29
|
+
onClick,
|
|
30
|
+
items
|
|
24
31
|
}) {
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
const label = typeof action.label === 'string' ? action.label : action.label(items);
|
|
33
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
34
|
+
label: label,
|
|
27
35
|
icon: action.icon,
|
|
28
36
|
isDestructive: action.isDestructive,
|
|
29
37
|
size: "compact",
|
|
@@ -32,60 +40,82 @@ function ButtonTrigger({
|
|
|
32
40
|
}
|
|
33
41
|
function DropdownMenuItemTrigger({
|
|
34
42
|
action,
|
|
35
|
-
onClick
|
|
43
|
+
onClick,
|
|
44
|
+
items
|
|
36
45
|
}) {
|
|
37
|
-
|
|
46
|
+
const label = typeof action.label === 'string' ? action.label : action.label(items);
|
|
47
|
+
return /*#__PURE__*/_jsx(DropdownMenuItem, {
|
|
38
48
|
onClick: onClick,
|
|
39
|
-
hideOnClick: !action
|
|
40
|
-
|
|
49
|
+
hideOnClick: !('RenderModal' in action),
|
|
50
|
+
children: /*#__PURE__*/_jsx(DropdownMenuItemLabel, {
|
|
51
|
+
children: label
|
|
52
|
+
})
|
|
53
|
+
});
|
|
41
54
|
}
|
|
42
|
-
function
|
|
55
|
+
export function ActionModal({
|
|
43
56
|
action,
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
items,
|
|
58
|
+
closeModal
|
|
59
|
+
}) {
|
|
60
|
+
const label = typeof action.label === 'string' ? action.label : action.label(items);
|
|
61
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
62
|
+
title: action.modalHeader || label,
|
|
63
|
+
__experimentalHideHeader: !!action.hideModalHeader,
|
|
64
|
+
onRequestClose: closeModal !== null && closeModal !== void 0 ? closeModal : () => {},
|
|
65
|
+
overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(action.id)}`,
|
|
66
|
+
children: /*#__PURE__*/_jsx(action.RenderModal, {
|
|
67
|
+
items: items,
|
|
68
|
+
closeModal: closeModal,
|
|
69
|
+
onActionStart: action.onActionStart,
|
|
70
|
+
onActionPerformed: action.onActionPerformed
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function ActionWithModal({
|
|
75
|
+
action,
|
|
76
|
+
items,
|
|
77
|
+
ActionTrigger,
|
|
78
|
+
isBusy
|
|
46
79
|
}) {
|
|
47
80
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
48
81
|
const actionTriggerProps = {
|
|
49
82
|
action,
|
|
50
|
-
onClick: () =>
|
|
51
|
-
|
|
52
|
-
const {
|
|
53
|
-
RenderModal,
|
|
54
|
-
hideModalHeader
|
|
55
|
-
} = action;
|
|
56
|
-
return createElement(Fragment, null, createElement(ActionTrigger, {
|
|
57
|
-
...actionTriggerProps
|
|
58
|
-
}), isModalOpen && createElement(Modal, {
|
|
59
|
-
title: action.modalHeader || action.label,
|
|
60
|
-
__experimentalHideHeader: !!hideModalHeader,
|
|
61
|
-
onRequestClose: () => {
|
|
62
|
-
setIsModalOpen(false);
|
|
83
|
+
onClick: () => {
|
|
84
|
+
setIsModalOpen(true);
|
|
63
85
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
86
|
+
items,
|
|
87
|
+
isBusy
|
|
88
|
+
};
|
|
89
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
90
|
+
children: [/*#__PURE__*/_jsx(ActionTrigger, {
|
|
91
|
+
...actionTriggerProps
|
|
92
|
+
}), isModalOpen && /*#__PURE__*/_jsx(ActionModal, {
|
|
93
|
+
action: action,
|
|
94
|
+
items: items,
|
|
95
|
+
closeModal: () => setIsModalOpen(false)
|
|
96
|
+
})]
|
|
97
|
+
});
|
|
69
98
|
}
|
|
70
|
-
function ActionsDropdownMenuGroup({
|
|
99
|
+
export function ActionsDropdownMenuGroup({
|
|
71
100
|
actions,
|
|
72
101
|
item
|
|
73
102
|
}) {
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
103
|
+
return /*#__PURE__*/_jsx(DropdownMenuGroup, {
|
|
104
|
+
children: actions.map(action => {
|
|
105
|
+
if ('RenderModal' in action) {
|
|
106
|
+
return /*#__PURE__*/_jsx(ActionWithModal, {
|
|
107
|
+
action: action,
|
|
108
|
+
items: [item],
|
|
109
|
+
ActionTrigger: DropdownMenuItemTrigger
|
|
110
|
+
}, action.id);
|
|
111
|
+
}
|
|
112
|
+
return /*#__PURE__*/_jsx(DropdownMenuItemTrigger, {
|
|
78
113
|
action: action,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
key: action.id,
|
|
85
|
-
action: action,
|
|
86
|
-
onClick: () => action.callback([item])
|
|
87
|
-
});
|
|
88
|
-
}));
|
|
114
|
+
onClick: () => action.callback([item]),
|
|
115
|
+
items: [item]
|
|
116
|
+
}, action.id);
|
|
117
|
+
})
|
|
118
|
+
});
|
|
89
119
|
}
|
|
90
120
|
export default function ItemActions({
|
|
91
121
|
item,
|
|
@@ -106,54 +136,55 @@ export default function ItemActions({
|
|
|
106
136
|
};
|
|
107
137
|
}, [actions, item]);
|
|
108
138
|
if (isCompact) {
|
|
109
|
-
return
|
|
139
|
+
return /*#__PURE__*/_jsx(CompactItemActions, {
|
|
110
140
|
item: item,
|
|
111
141
|
actions: eligibleActions
|
|
112
142
|
});
|
|
113
143
|
}
|
|
114
|
-
return
|
|
144
|
+
return /*#__PURE__*/_jsxs(HStack, {
|
|
115
145
|
spacing: 1,
|
|
116
146
|
justify: "flex-end",
|
|
117
147
|
className: "dataviews-item-actions",
|
|
118
148
|
style: {
|
|
119
149
|
flexShrink: '0',
|
|
120
150
|
width: 'auto'
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
151
|
+
},
|
|
152
|
+
children: [!!primaryActions.length && primaryActions.map(action => {
|
|
153
|
+
if ('RenderModal' in action) {
|
|
154
|
+
return /*#__PURE__*/_jsx(ActionWithModal, {
|
|
155
|
+
action: action,
|
|
156
|
+
items: [item],
|
|
157
|
+
ActionTrigger: ButtonTrigger
|
|
158
|
+
}, action.id);
|
|
159
|
+
}
|
|
160
|
+
return /*#__PURE__*/_jsx(ButtonTrigger, {
|
|
126
161
|
action: action,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
});
|
|
136
|
-
}), createElement(CompactItemActions, {
|
|
137
|
-
item: item,
|
|
138
|
-
actions: eligibleActions
|
|
139
|
-
}));
|
|
162
|
+
onClick: () => action.callback([item]),
|
|
163
|
+
items: [item]
|
|
164
|
+
}, action.id);
|
|
165
|
+
}), /*#__PURE__*/_jsx(CompactItemActions, {
|
|
166
|
+
item: item,
|
|
167
|
+
actions: eligibleActions
|
|
168
|
+
})]
|
|
169
|
+
});
|
|
140
170
|
}
|
|
141
171
|
function CompactItemActions({
|
|
142
172
|
item,
|
|
143
173
|
actions
|
|
144
174
|
}) {
|
|
145
|
-
return
|
|
146
|
-
trigger:
|
|
175
|
+
return /*#__PURE__*/_jsx(DropdownMenu, {
|
|
176
|
+
trigger: /*#__PURE__*/_jsx(Button, {
|
|
147
177
|
size: "compact",
|
|
148
178
|
icon: moreVertical,
|
|
149
179
|
label: __('Actions'),
|
|
150
180
|
disabled: !actions.length,
|
|
151
181
|
className: "dataviews-all-actions-button"
|
|
152
182
|
}),
|
|
153
|
-
placement: "bottom-end"
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
183
|
+
placement: "bottom-end",
|
|
184
|
+
children: /*#__PURE__*/_jsx(ActionsDropdownMenuGroup, {
|
|
185
|
+
actions: actions,
|
|
186
|
+
item: item
|
|
187
|
+
})
|
|
188
|
+
});
|
|
158
189
|
}
|
|
159
190
|
//# sourceMappingURL=item-actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","Modal","__experimentalHStack","HStack","privateApis","componentsPrivateApis","__","useMemo","useState","moreVertical","unlock","DropdownMenuV2","DropdownMenu","DropdownMenuGroupV2","DropdownMenuGroup","DropdownMenuItemV2","DropdownMenuItem","DropdownMenuItemLabelV2","DropdownMenuItemLabel","kebabCase","ButtonTrigger","action","onClick","createElement","label","icon","isDestructive","size","DropdownMenuItemTrigger","hideOnClick","RenderModal","ActionWithModal","item","ActionTrigger","isModalOpen","setIsModalOpen","actionTriggerProps","hideModalHeader","Fragment","title","modalHeader","__experimentalHideHeader","onRequestClose","overlayClassName","id","items","closeModal","ActionsDropdownMenuGroup","actions","map","key","callback","ItemActions","isCompact","primaryActions","eligibleActions","_eligibleActions","filter","isEligible","_primaryActions","isPrimary","CompactItemActions","spacing","justify","className","style","flexShrink","width","length","trigger","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 } item={ item } />\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,KAAK,EACLC,oBAAoB,IAAIC,MAAM,EAC9BC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,YAAY,QAAQ,kBAAkB;;AAE/C;AACA;AACA;AACA,SAASC,MAAM,QAAQ,eAAe;AAEtC,MAAM;EACLC,cAAc,EAAEC,YAAY;EAC5BC,mBAAmB,EAAEC,iBAAiB;EACtCC,kBAAkB,EAAEC,gBAAgB;EACpCC,uBAAuB,EAAEC,qBAAqB;EAC9CC;AACD,CAAC,GA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B,MAAM;MACN2B,IAAI,EAAC,SAAS;MACdF,IAAI,EAAGhB,YAAc;MACrBe,KAAK,EAAGlB,EAAE,CAAE,SAAU,CAAG;MACzBgE,QAAQ,EAAG,CAAEtB,OAAO,CAACoB,MAAQ;MAC7BJ,SAAS,EAAC;IAA8B,CACxC,CACD;IACDO,SAAS,EAAC;EAAY,GAEtBhD,aAAA,CAACwB,wBAAwB;IAACC,OAAO,EAAGA,OAAS;IAAChB,IAAI,EAAGA;EAAM,CAAE,CAChD,CAAC;AAEjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Button","Modal","__experimentalHStack","HStack","privateApis","componentsPrivateApis","__","useMemo","useState","moreVertical","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DropdownMenuV2","DropdownMenu","DropdownMenuGroupV2","DropdownMenuGroup","DropdownMenuItemV2","DropdownMenuItem","DropdownMenuItemLabelV2","DropdownMenuItemLabel","kebabCase","ButtonTrigger","action","onClick","items","label","icon","isDestructive","size","DropdownMenuItemTrigger","hideOnClick","children","ActionModal","closeModal","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","overlayClassName","id","RenderModal","onActionStart","onActionPerformed","ActionWithModal","ActionTrigger","isBusy","isModalOpen","setIsModalOpen","actionTriggerProps","ActionsDropdownMenuGroup","actions","item","map","callback","ItemActions","isCompact","primaryActions","eligibleActions","_eligibleActions","filter","isEligible","_primaryActions","isPrimary","CompactItemActions","spacing","justify","className","style","flexShrink","width","length","trigger","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":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SACCA,MAAM,EACNC,KAAK,EACLC,oBAAoB,IAAIC,MAAM,EAC9BC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,YAAY,QAAQ,kBAAkB;;AAE/C;AACA;AACA;AACA,SAASC,MAAM,QAAQ,e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AAQ,EAAG,CAAEtB,OAAO,CAACoB,MAAQ;MAC7BJ,SAAS,EAAC;IAA8B,CACxC,CACD;IACDO,SAAS,EAAC,YAAY;IAAA3C,QAAA,eAEtBxB,IAAA,CAAC2C,wBAAwB;MAACC,OAAO,EAAGA,OAAS;MAACC,IAAI,EAAGA;IAAM,CAAE;EAAC,CACjD,CAAC;AAEjB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","isRTL","blockTable","category","formatListBullets","formatListBulletsRTL","ViewTable","ViewGrid","ViewList","LAYOUT_GRID","LAYOUT_LIST","LAYOUT_TABLE","VIEW_LAYOUTS","type","label","component","icon"],"sources":["@wordpress/dataviews/src/layouts.
|
|
1
|
+
{"version":3,"names":["__","isRTL","blockTable","category","formatListBullets","formatListBulletsRTL","ViewTable","ViewGrid","ViewList","LAYOUT_GRID","LAYOUT_LIST","LAYOUT_TABLE","VIEW_LAYOUTS","type","label","component","icon"],"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":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SACCC,UAAU,EACVC,QAAQ,EACRC,iBAAiB,EACjBC,oBAAoB,QACd,kBAAkB;;AAEzB;AACA;AACA;AACA,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,QAAQ,MAAM,aAAa;AAClC,SAASC,WAAW,EAAEC,WAAW,EAAEC,YAAY,QAAQ,aAAa;AAEpE,OAAO,MAAMC,YAAY,GAAG,CAC3B;EACCC,IAAI,EAAEF,YAAY;EAClBG,KAAK,EAAEd,EAAE,CAAE,OAAQ,CAAC;EACpBe,SAAS,EAAET,SAAS;EACpBU,IAAI,EAAEd;AACP,CAAC,EACD;EACCW,IAAI,EAAEJ,WAAW;EACjBK,KAAK,EAAEd,EAAE,CAAE,MAAO,CAAC;EACnBe,SAAS,EAAER,QAAQ;EACnBS,IAAI,EAAEb;AACP,CAAC,EACD;EACCU,IAAI,EAAEH,WAAW;EACjBI,KAAK,EAAEd,EAAE,CAAE,MAAO,CAAC;EACnBe,SAAS,EAAEP,QAAQ;EACnBQ,IAAI,EAAEf,KAAK,CAAC,CAAC,GAAGI,oBAAoB,GAAGD;AACxC,CAAC,CACD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"sources":["@wordpress/dataviews/src/lock-unlock.
|
|
1
|
+
{"version":3,"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","lock","unlock"],"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":"AAAA;AACA;AACA;AACA,SAASA,gDAAgD,QAAQ,yBAAyB;AAE1F,OAAO,MAAM;EAAEC,IAAI;EAAEC;AAAO,CAAC,GAC5BF,gDAAgD,CAC/C,iHAAiH,EACjH,sBACD,CAAC","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;AACA,OAAO,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":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
1
|
/**
|
|
3
2
|
* WordPress dependencies
|
|
4
3
|
*/
|
|
@@ -6,6 +5,12 @@ import { Button, __experimentalHStack as HStack, SelectControl } from '@wordpres
|
|
|
6
5
|
import { createInterpolateElement, memo } from '@wordpress/element';
|
|
7
6
|
import { sprintf, __, _x } from '@wordpress/i18n';
|
|
8
7
|
import { chevronRight, chevronLeft } from '@wordpress/icons';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
14
|
const Pagination = memo(function Pagination({
|
|
10
15
|
view,
|
|
11
16
|
onChangeView,
|
|
@@ -14,69 +19,74 @@ const Pagination = memo(function Pagination({
|
|
|
14
19
|
totalPages
|
|
15
20
|
}
|
|
16
21
|
}) {
|
|
22
|
+
var _view$page;
|
|
17
23
|
if (!totalItems || !totalPages) {
|
|
18
24
|
return null;
|
|
19
25
|
}
|
|
20
|
-
|
|
26
|
+
const currentPage = (_view$page = view.page) !== null && _view$page !== void 0 ? _view$page : 1;
|
|
27
|
+
return !!totalItems && totalPages !== 1 && /*#__PURE__*/_jsxs(HStack, {
|
|
21
28
|
expanded: false,
|
|
22
29
|
spacing: 6,
|
|
23
30
|
justify: "end",
|
|
24
|
-
className: "dataviews-pagination"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
className: "dataviews-pagination",
|
|
32
|
+
children: [/*#__PURE__*/_jsx(HStack, {
|
|
33
|
+
justify: "flex-start",
|
|
34
|
+
expanded: false,
|
|
35
|
+
spacing: 2,
|
|
36
|
+
className: "dataviews-pagination__page-selection",
|
|
37
|
+
children: createInterpolateElement(sprintf(
|
|
38
|
+
// translators: %s: Total number of pages.
|
|
39
|
+
_x('Page <CurrentPageControl /> of %s', 'paging'), totalPages), {
|
|
40
|
+
CurrentPageControl: /*#__PURE__*/_jsx(SelectControl, {
|
|
41
|
+
"aria-label": __('Current page'),
|
|
42
|
+
value: view.page?.toString(),
|
|
43
|
+
options: Array.from(Array(totalPages)).map((_, i) => {
|
|
44
|
+
const page = i + 1;
|
|
45
|
+
return {
|
|
46
|
+
value: page.toString(),
|
|
47
|
+
label: page.toString()
|
|
48
|
+
};
|
|
49
|
+
}),
|
|
50
|
+
onChange: newValue => {
|
|
51
|
+
onChangeView({
|
|
52
|
+
...view,
|
|
53
|
+
page: +newValue
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
size: "compact",
|
|
57
|
+
__nextHasNoMarginBottom: true
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
}), /*#__PURE__*/_jsxs(HStack, {
|
|
61
|
+
expanded: false,
|
|
62
|
+
spacing: 1,
|
|
63
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
64
|
+
onClick: () => onChangeView({
|
|
45
65
|
...view,
|
|
46
|
-
page:
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
page: view.page + 1
|
|
71
|
-
}),
|
|
72
|
-
disabled: view.page >= totalPages,
|
|
73
|
-
__experimentalIsFocusable: true,
|
|
74
|
-
label: __('Next page'),
|
|
75
|
-
icon: chevronRight,
|
|
76
|
-
showTooltip: true,
|
|
77
|
-
size: "compact",
|
|
78
|
-
tooltipPosition: "top"
|
|
79
|
-
})));
|
|
66
|
+
page: currentPage - 1
|
|
67
|
+
}),
|
|
68
|
+
disabled: currentPage === 1,
|
|
69
|
+
__experimentalIsFocusable: true,
|
|
70
|
+
label: __('Previous page'),
|
|
71
|
+
icon: chevronLeft,
|
|
72
|
+
showTooltip: true,
|
|
73
|
+
size: "compact",
|
|
74
|
+
tooltipPosition: "top"
|
|
75
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
76
|
+
onClick: () => onChangeView({
|
|
77
|
+
...view,
|
|
78
|
+
page: currentPage + 1
|
|
79
|
+
}),
|
|
80
|
+
disabled: currentPage >= totalPages,
|
|
81
|
+
__experimentalIsFocusable: true,
|
|
82
|
+
label: __('Next page'),
|
|
83
|
+
icon: chevronRight,
|
|
84
|
+
showTooltip: true,
|
|
85
|
+
size: "compact",
|
|
86
|
+
tooltipPosition: "top"
|
|
87
|
+
})]
|
|
88
|
+
})]
|
|
89
|
+
});
|
|
80
90
|
});
|
|
81
91
|
export default Pagination;
|
|
82
92
|
//# sourceMappingURL=pagination.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","__experimentalHStack","HStack","SelectControl","createInterpolateElement","memo","sprintf","__","_x","chevronRight","chevronLeft","Pagination","view","onChangeView","paginationInfo","totalItems","totalPages","
|
|
1
|
+
{"version":3,"names":["Button","__experimentalHStack","HStack","SelectControl","createInterpolateElement","memo","sprintf","__","_x","chevronRight","chevronLeft","jsx","_jsx","jsxs","_jsxs","Pagination","view","onChangeView","paginationInfo","totalItems","totalPages","_view$page","currentPage","page","expanded","spacing","justify","className","children","CurrentPageControl","value","toString","options","Array","from","map","_","i","label","onChange","newValue","size","__nextHasNoMarginBottom","onClick","disabled","__experimentalIsFocusable","icon","showTooltip","tooltipPosition"],"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":"AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,aAAa,QACP,uBAAuB;AAC9B,SAASC,wBAAwB,EAAEC,IAAI,QAAQ,oBAAoB;AACnE,SAASC,OAAO,EAAEC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACjD,SAASC,YAAY,EAAEC,WAAW,QAAQ,kBAAkB;;AAE5D;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAcA,MAAMC,UAAU,GAAGV,IAAI,CAAE,SAASU,UAAUA,CAAE;EAC7CC,IAAI;EACJC,YAAY;EACZC,cAAc,EAAE;IAAEC,UAAU,GAAG,CAAC;IAAEC;EAAW;AAC7B,CAAC,EAAG;EAAA,IAAAC,UAAA;EACpB,IAAK,CAAEF,UAAU,IAAI,CAAEC,UAAU,EAAG;IACnC,OAAO,IAAI;EACZ;EACA,MAAME,WAAW,IAAAD,UAAA,GAAGL,IAAI,CAACO,IAAI,cAAAF,UAAA,cAAAA,UAAA,GAAI,CAAC;EAClC,OACC,CAAC,CAAEF,UAAU,IACbC,UAAU,KAAK,CAAC,iBACfN,KAAA,CAACZ,MAAM;IACNsB,QAAQ,EAAG,KAAO;IAClBC,OAAO,EAAG,CAAG;I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KAAK,CAAG;QAC9BuB,yBAAyB;QACzBP,KAAK,EAAG/B,EAAE,CAAE,eAAgB,CAAG;QAC/BuC,IAAI,EAAGpC,WAAa;QACpBqC,WAAW;QACXN,IAAI,EAAC,SAAS;QACdO,eAAe,EAAC;MAAK,CACrB,CAAC,eACFpC,IAAA,CAACZ,MAAM;QACN2C,OAAO,EAAGA,CAAA,KACT1B,YAAY,CAAE;UAAE,GAAGD,IAAI;UAAEO,IAAI,EAAED,WAAW,GAAG;QAAE,CAAE,CACjD;QACDsB,QAAQ,EAAGtB,WAAW,IAAIF,UAAY;QACtCyB,yBAAyB;QACzBP,KAAK,EAAG/B,EAAE,CAAE,WAAY,CAAG;QAC3BuC,IAAI,EAAGrC,YAAc;QACrBsC,WAAW;QACXN,IAAI,EAAC,SAAS;QACdO,eAAe,EAAC;MAAK,CACrB,CAAC;IAAA,CACK,CAAC;EAAA,CACF,CACR;AAEH,CAAE,CAAC;AAEH,eAAejC,UAAU","ignoreList":[]}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
1
|
/**
|
|
3
2
|
* WordPress dependencies
|
|
4
3
|
*/
|
|
5
4
|
import { Button } from '@wordpress/components';
|
|
6
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
11
|
export default function ResetFilter({
|
|
8
12
|
filters,
|
|
9
13
|
view,
|
|
@@ -11,7 +15,7 @@ export default function ResetFilter({
|
|
|
11
15
|
}) {
|
|
12
16
|
const isPrimary = field => filters.some(_filter => _filter.field === field && _filter.isPrimary);
|
|
13
17
|
const isDisabled = !view.search && !view.filters?.some(_filter => _filter.value !== undefined || !isPrimary(_filter.field));
|
|
14
|
-
return
|
|
18
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
15
19
|
disabled: isDisabled,
|
|
16
20
|
__experimentalIsFocusable: true,
|
|
17
21
|
size: "compact",
|
|
@@ -24,7 +28,8 @@ export default function ResetFilter({
|
|
|
24
28
|
search: '',
|
|
25
29
|
filters: []
|
|
26
30
|
});
|
|
27
|
-
}
|
|
28
|
-
|
|
31
|
+
},
|
|
32
|
+
children: __('Reset')
|
|
33
|
+
});
|
|
29
34
|
}
|
|
30
35
|
//# sourceMappingURL=reset-filters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","__","ResetFilter","filters","view","onChangeView","isPrimary","field","some","_filter","isDisabled","search","value","undefined","
|
|
1
|
+
{"version":3,"names":["Button","__","jsx","_jsx","ResetFilter","filters","view","onChangeView","isPrimary","field","some","_filter","isDisabled","search","value","undefined","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":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAWA,eAAe,SAASC,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,oBACCN,IAAA,CAACH,MAAM;IACNgB,QAAQ,EAAGJ,UAAY;IACvBK,yBAAyB;IACzBC,IAAI,EAAC,SAAS;IACdC,OAAO,EAAC,UAAU;IAClBC,SAAS,EAAC,iCAAiC;IAC3CC,OAAO,EAAGA,CAAA,KAAM;MACfd,YAAY,CAAE;QACb,GAAGD,IAAI;QACPgB,IAAI,EAAE,CAAC;QACPT,MAAM,EAAE,EAAE;QACVR,OAAO,EAAE;MACV,CAAE,CAAC;IACJ,CAAG;IAAAkB,QAAA,EAEDtB,EAAE,CAAE,OAAQ;EAAC,CACR,CAAC;AAEX","ignoreList":[]}
|