@wordpress/dataviews 1.1.0 → 1.2.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 +11 -5
- package/build/bulk-actions-toolbar.js +182 -0
- package/build/bulk-actions-toolbar.js.map +1 -0
- package/build/bulk-actions.js +8 -8
- package/build/bulk-actions.js.map +1 -1
- package/build/dataviews.js +11 -4
- 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 +3 -3
- package/build/filter-summary.js.map +1 -1
- package/build/item-actions.js +41 -22
- package/build/item-actions.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/normalize-fields.js.map +1 -1
- package/build/pagination.js +13 -7
- package/build/pagination.js.map +1 -1
- package/build/single-selection-checkbox.js +4 -0
- package/build/single-selection-checkbox.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/view-grid.js +9 -10
- package/build/view-grid.js.map +1 -1
- package/build/view-list.js +134 -21
- package/build/view-list.js.map +1 -1
- package/build/view-table.js +9 -9
- package/build/view-table.js.map +1 -1
- package/build-module/bulk-actions-toolbar.js +175 -0
- package/build-module/bulk-actions-toolbar.js.map +1 -0
- package/build-module/bulk-actions.js +8 -8
- package/build-module/bulk-actions.js.map +1 -1
- package/build-module/dataviews.js +11 -4
- 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 +3 -3
- package/build-module/filter-summary.js.map +1 -1
- package/build-module/item-actions.js +40 -24
- package/build-module/item-actions.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 +14 -7
- package/build-module/pagination.js.map +1 -1
- package/build-module/single-selection-checkbox.js +5 -0
- package/build-module/single-selection-checkbox.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/view-grid.js +9 -10
- package/build-module/view-grid.js.map +1 -1
- package/build-module/view-list.js +135 -23
- package/build-module/view-list.js.map +1 -1
- package/build-module/view-table.js +9 -9
- package/build-module/view-table.js.map +1 -1
- package/build-style/style-rtl.css +62 -27
- package/build-style/style.css +62 -27
- package/build-types/add-filter.d.ts +8 -0
- package/build-types/add-filter.d.ts.map +1 -0
- package/build-types/bulk-actions-toolbar.d.ts +8 -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/dataviews.d.ts +15 -0
- package/build-types/dataviews.d.ts.map +1 -0
- package/build-types/dropdown-menu-helper.d.ts +6 -0
- package/build-types/dropdown-menu-helper.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 +6 -0
- package/build-types/filter-summary.d.ts.map +1 -0
- package/build-types/filters.d.ts +3 -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 +37 -0
- package/build-types/item-actions.d.ts.map +1 -0
- package/build-types/layouts.d.ts +20 -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 +6 -0
- package/build-types/reset-filters.d.ts.map +1 -0
- package/build-types/search-widget.d.ts +2 -0
- package/build-types/search-widget.d.ts.map +1 -0
- package/build-types/search.d.ts +3 -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 +152 -20
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils.d.ts +2 -0
- package/build-types/utils.d.ts.map +1 -0
- package/build-types/view-actions.d.ts +3 -0
- package/build-types/view-actions.d.ts.map +1 -0
- package/build-types/view-grid.d.ts +15 -0
- package/build-types/view-grid.d.ts.map +1 -0
- package/build-types/view-list.d.ts +16 -0
- package/build-types/view-list.d.ts.map +1 -0
- package/build-types/view-table.d.ts +14 -0
- package/build-types/view-table.d.ts.map +1 -0
- package/package.json +12 -12
- package/src/bulk-actions-toolbar.js +244 -0
- package/src/{bulk-actions.js → bulk-actions.tsx} +73 -17
- package/src/dataviews.js +14 -3
- package/src/filter-and-sort-data-view.ts +13 -8
- package/src/filter-summary.js +3 -3
- package/src/{item-actions.js → item-actions.tsx} +112 -28
- package/src/normalize-fields.ts +4 -2
- package/src/{pagination.js → pagination.tsx} +28 -7
- package/src/{single-selection-checkbox.js → single-selection-checkbox.tsx} +17 -2
- package/src/style.scss +77 -28
- package/src/types.ts +190 -20
- package/src/{view-grid.js → view-grid.tsx} +45 -16
- package/src/view-list.tsx +421 -0
- package/src/view-table.js +8 -8
- package/tsconfig.json +4 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/src/view-list.js +0 -207
- /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
|
|
2
6
|
/**
|
|
3
7
|
* WordPress dependencies
|
|
4
8
|
*/
|
|
@@ -36,47 +40,59 @@ function DropdownMenuItemTrigger({
|
|
|
36
40
|
}) {
|
|
37
41
|
return createElement(DropdownMenuItem, {
|
|
38
42
|
onClick: onClick,
|
|
39
|
-
hideOnClick: !action
|
|
43
|
+
hideOnClick: !('RenderModal' in action)
|
|
40
44
|
}, createElement(DropdownMenuItemLabel, null, action.label));
|
|
41
45
|
}
|
|
42
|
-
function
|
|
46
|
+
export function ActionModal({
|
|
43
47
|
action,
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
items,
|
|
49
|
+
closeModal
|
|
50
|
+
}) {
|
|
51
|
+
return createElement(Modal, {
|
|
52
|
+
title: action.modalHeader || action.label,
|
|
53
|
+
__experimentalHideHeader: !!action.hideModalHeader,
|
|
54
|
+
onRequestClose: closeModal !== null && closeModal !== void 0 ? closeModal : () => {},
|
|
55
|
+
overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(action.id)}`
|
|
56
|
+
}, createElement(action.RenderModal, {
|
|
57
|
+
items: items,
|
|
58
|
+
closeModal: closeModal,
|
|
59
|
+
onActionStart: action.onActionStart,
|
|
60
|
+
onActionPerformed: action.onActionPerformed
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
export function ActionWithModal({
|
|
64
|
+
action,
|
|
65
|
+
items,
|
|
66
|
+
ActionTrigger,
|
|
67
|
+
isBusy
|
|
46
68
|
}) {
|
|
47
69
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
48
70
|
const actionTriggerProps = {
|
|
49
71
|
action,
|
|
50
|
-
onClick: () =>
|
|
72
|
+
onClick: () => {
|
|
73
|
+
setIsModalOpen(true);
|
|
74
|
+
},
|
|
75
|
+
items,
|
|
76
|
+
isBusy
|
|
51
77
|
};
|
|
52
|
-
const {
|
|
53
|
-
RenderModal,
|
|
54
|
-
hideModalHeader
|
|
55
|
-
} = action;
|
|
56
78
|
return createElement(Fragment, null, createElement(ActionTrigger, {
|
|
57
79
|
...actionTriggerProps
|
|
58
|
-
}), isModalOpen && createElement(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
onRequestClose: () => {
|
|
62
|
-
setIsModalOpen(false);
|
|
63
|
-
},
|
|
64
|
-
overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(action.id)}`
|
|
65
|
-
}, createElement(RenderModal, {
|
|
66
|
-
items: [item],
|
|
80
|
+
}), isModalOpen && createElement(ActionModal, {
|
|
81
|
+
action: action,
|
|
82
|
+
items: items,
|
|
67
83
|
closeModal: () => setIsModalOpen(false)
|
|
68
|
-
}))
|
|
84
|
+
}));
|
|
69
85
|
}
|
|
70
|
-
function ActionsDropdownMenuGroup({
|
|
86
|
+
export function ActionsDropdownMenuGroup({
|
|
71
87
|
actions,
|
|
72
88
|
item
|
|
73
89
|
}) {
|
|
74
90
|
return createElement(DropdownMenuGroup, null, actions.map(action => {
|
|
75
|
-
if (
|
|
91
|
+
if ('RenderModal' in action) {
|
|
76
92
|
return createElement(ActionWithModal, {
|
|
77
93
|
key: action.id,
|
|
78
94
|
action: action,
|
|
79
|
-
|
|
95
|
+
items: [item],
|
|
80
96
|
ActionTrigger: DropdownMenuItemTrigger
|
|
81
97
|
});
|
|
82
98
|
}
|
|
@@ -120,11 +136,11 @@ export default function ItemActions({
|
|
|
120
136
|
width: 'auto'
|
|
121
137
|
}
|
|
122
138
|
}, !!primaryActions.length && primaryActions.map(action => {
|
|
123
|
-
if (
|
|
139
|
+
if ('RenderModal' in action) {
|
|
124
140
|
return createElement(ActionWithModal, {
|
|
125
141
|
key: action.id,
|
|
126
142
|
action: action,
|
|
127
|
-
|
|
143
|
+
items: [item],
|
|
128
144
|
ActionTrigger: ButtonTrigger
|
|
129
145
|
});
|
|
130
146
|
}
|
|
@@ -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,GAAGT,MAAM,CAAEL,qBAAsB,CAAC;AAEnC,SAASe,aAAaA,CAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAG;EAC7C,OACCC,aAAA,CAACvB,MAAM;IACNwB,KAAK,EAAGH,MAAM,CAACG,KAAO;IACtBC,IAAI,EAAGJ,MAAM,CAACI,IAAM;IACpBC,aAAa,EAAGL,MAAM,CAACK,aAAe;IACtCC,IAAI,EAAC,SAAS;IACdL,OAAO,EAAGA;EAAS,CACnB,CAAC;AAEJ;AAEA,SAASM,uBAAuBA,CAAE;EAAEP,MAAM;EAAEC;AAAQ,CAAC,EAAG;EACvD,OACCC,aAAA,CAACP,gBAAgB;IAChBM,OAAO,EAAGA,OAAS;IACnBO,WAAW,EAAG,CAAER,MAAM,CAACS;EAAa,GAEpCP,aAAA,CAACL,qBAAqB,QAAGG,MAAM,CAACG,KAA8B,CAC7C,CAAC;AAErB;AAEA,SAASO,eAAeA,CAAE;EAAEV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EAAG;MAC5B,OACCP,aAAA,CAACQ,eAAe;QACfmB,GAAG,EAAG7B,MAAM,CAACuB,EAAI;QACjBvB,MAAM,EAAGA,MAAQ;QACjBW,IAAI,EAAGA,IAAM;QACbC,aAAa,EAAGb;MAAe,CAC/B,CAAC;IAEJ;IACA,OACCG,aAAA,CAACH,aAAa;MACb8B,GAAG,EAAG7B,MAAM,CAACuB,EAAI;MACjBvB,MAAM,EAAGA,MAAQ;MACjBC,OAAO,EAAGA,CAAA,KAAMD,MAAM,CAAC8B,QAAQ,CAAE,CAAEnB,IAAI,CAAG;IAAG,CAC7C,CAAC;EAEJ,CAAE,CAAC,EACJT,aAAA,CAACsC,kBAAkB;IAAC7B,IAAI,EAAGA,IAAM;IAACgB,OAAO,EAAGO;EAAiB,CAAE,CACxD,CAAC;AAEX;AAEA,SAASM,kBAAkBA,CAAE;EAAE7B,IAAI;EAAEgB;AAAQ,CAAC,EAAG;EAChD,OACCzB,aAAA,CAACX,YAAY;IACZyD,OAAO,EACN9C,aAAA,CAACvB,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","DropdownMenuV2","DropdownMenu","DropdownMenuGroupV2","DropdownMenuGroup","DropdownMenuItemV2","DropdownMenuItem","DropdownMenuItemLabelV2","DropdownMenuItemLabel","kebabCase","ButtonTrigger","action","onClick","createElement","label","icon","isDestructive","size","DropdownMenuItemTrigger","hideOnClick","ActionModal","items","closeModal","title","modalHeader","__experimentalHideHeader","hideModalHeader","onRequestClose","overlayClassName","id","RenderModal","onActionStart","onActionPerformed","ActionWithModal","ActionTrigger","isBusy","isModalOpen","setIsModalOpen","actionTriggerProps","Fragment","ActionsDropdownMenuGroup","actions","item","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.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\ninterface ButtonTriggerProps< Item extends AnyItem > {\n\taction: Action< Item >;\n\tonClick: MouseEventHandler;\n}\n\ninterface DropdownMenuItemTriggerProps< Item extends AnyItem > {\n\taction: Action< Item >;\n\tonClick: MouseEventHandler;\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: (\n\t\tprops: ButtonTriggerProps< Item > | DropdownMenuItemTriggerProps< Item >\n\t) => 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}: ButtonTriggerProps< Item > ) {\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< Item extends AnyItem >( {\n\taction,\n\tonClick,\n}: DropdownMenuItemTriggerProps< Item > ) {\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>{ action.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\treturn (\n\t\t<Modal\n\t\t\ttitle={ action.modalHeader || action.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/>\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/>\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,eAAe;AAGtC,MAAM;EACLC,cAAc,EAAEC,YAAY;EAC5BC,mBAAmB,EAAEC,iBAAiB;EACtCC,kBAAkB,EAAEC,gBAAgB;EACpCC,uBAAuB,EAAEC,qBAAqB;EAC9CC;AACD,CAAC,GAAGT,MAAM,CAAEL,qBAAsB,CAAC;AA0CnC,SAASe,aAAaA,CAA0B;EAC/CC,MAAM;EACNC;AAC2B,CAAC,EAAG;EAC/B,OACCC,aAAA,CAACvB,MAAM;IACNwB,KAAK,EAAGH,MAAM,CAACG,KAAO;IACtBC,IAAI,EAAGJ,MAAM,CAACI,IAAM;IACpBC,aAAa,EAAGL,MAAM,CAACK,aAAe;IACtCC,IAAI,EAAC,SAAS;IACdL,OAAO,EAAGA;EAAS,CACnB,CAAC;AAEJ;AAEA,SAASM,uBAAuBA,CAA0B;EACzDP,MAAM;EACNC;AACqC,CAAC,EAAG;EACzC,OACCC,aAAA,CAACP,gBAAgB;IAChBM,OAAO,EAAGA,OAAS;IACnBO,WAAW,EAAG,EAAI,aAAa,IAAIR,MAAM;EAAI,GAE7CE,aAAA,CAACL,qBAAqB,QAAGG,MAAM,CAACG,KAA8B,CAC7C,CAAC;AA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AAwB;IAACC,OAAO,EAAGA,OAAS;IAACC,IAAI,EAAGA;EAAM,CAAE,CAChD,CAAC;AAEjB","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":[]}
|
|
@@ -6,6 +6,11 @@ import { Button, __experimentalHStack as HStack, SelectControl } from '@wordpres
|
|
|
6
6
|
import { createInterpolateElement, memo } from '@wordpress/element';
|
|
7
7
|
import { sprintf, __, _x } from '@wordpress/i18n';
|
|
8
8
|
import { chevronRight, chevronLeft } from '@wordpress/icons';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
9
14
|
const Pagination = memo(function Pagination({
|
|
10
15
|
view,
|
|
11
16
|
onChangeView,
|
|
@@ -14,9 +19,11 @@ 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
|
}
|
|
26
|
+
const currentPage = (_view$page = view.page) !== null && _view$page !== void 0 ? _view$page : 1;
|
|
20
27
|
return !!totalItems && totalPages !== 1 && createElement(HStack, {
|
|
21
28
|
expanded: false,
|
|
22
29
|
spacing: 6,
|
|
@@ -32,12 +39,12 @@ const Pagination = memo(function Pagination({
|
|
|
32
39
|
_x('Page <CurrentPageControl /> of %s', 'paging'), totalPages), {
|
|
33
40
|
CurrentPageControl: createElement(SelectControl, {
|
|
34
41
|
"aria-label": __('Current page'),
|
|
35
|
-
value: view.page,
|
|
42
|
+
value: view.page?.toString(),
|
|
36
43
|
options: Array.from(Array(totalPages)).map((_, i) => {
|
|
37
44
|
const page = i + 1;
|
|
38
45
|
return {
|
|
39
|
-
value: page,
|
|
40
|
-
label: page
|
|
46
|
+
value: page.toString(),
|
|
47
|
+
label: page.toString()
|
|
41
48
|
};
|
|
42
49
|
}),
|
|
43
50
|
onChange: newValue => {
|
|
@@ -55,9 +62,9 @@ const Pagination = memo(function Pagination({
|
|
|
55
62
|
}, createElement(Button, {
|
|
56
63
|
onClick: () => onChangeView({
|
|
57
64
|
...view,
|
|
58
|
-
page:
|
|
65
|
+
page: currentPage - 1
|
|
59
66
|
}),
|
|
60
|
-
disabled:
|
|
67
|
+
disabled: currentPage === 1,
|
|
61
68
|
__experimentalIsFocusable: true,
|
|
62
69
|
label: __('Previous page'),
|
|
63
70
|
icon: chevronLeft,
|
|
@@ -67,9 +74,9 @@ const Pagination = memo(function Pagination({
|
|
|
67
74
|
}), createElement(Button, {
|
|
68
75
|
onClick: () => onChangeView({
|
|
69
76
|
...view,
|
|
70
|
-
page:
|
|
77
|
+
page: currentPage + 1
|
|
71
78
|
}),
|
|
72
|
-
disabled:
|
|
79
|
+
disabled: currentPage >= totalPages,
|
|
73
80
|
__experimentalIsFocusable: true,
|
|
74
81
|
label: __('Next page'),
|
|
75
82
|
icon: chevronRight,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","__experimentalHStack","HStack","SelectControl","createInterpolateElement","memo","sprintf","__","_x","chevronRight","chevronLeft","Pagination","view","onChangeView","paginationInfo","totalItems","totalPages","createElement","expanded","spacing","justify","className","CurrentPageControl","value","
|
|
1
|
+
{"version":3,"names":["Button","__experimentalHStack","HStack","SelectControl","createInterpolateElement","memo","sprintf","__","_x","chevronRight","chevronLeft","Pagination","view","onChangeView","paginationInfo","totalItems","totalPages","_view$page","currentPage","page","createElement","expanded","spacing","justify","className","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;;AAYA,MAAMC,UAAU,GAAGN,IAAI,CAAE,SAASM,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,UA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Y,CAAE;MACb,GAAGD,IAAI;MACPO,IAAI,EAAED,WAAW,GAAG;IACrB,CAAE,CACF;IACDsB,QAAQ,EAAGtB,WAAW,KAAK,CAAG;IAC9BuB,yBAAyB;IACzBP,KAAK,EAAG3B,EAAE,CAAE,eAAgB,CAAG;IAC/BmC,IAAI,EAAGhC,WAAa;IACpBiC,WAAW;IACXN,IAAI,EAAC,SAAS;IACdO,eAAe,EAAC;EAAK,CACrB,CAAC,EACFxB,aAAA,CAACpB,MAAM;IACNuC,OAAO,EAAGA,CAAA,KACT1B,YAAY,CAAE;MAAE,GAAGD,IAAI;MAAEO,IAAI,EAAED,WAAW,GAAG;IAAE,CAAE,CACjD;IACDsB,QAAQ,EAAGtB,WAAW,IAAIF,UAAY;IACtCyB,yBAAyB;IACzBP,KAAK,EAAG3B,EAAE,CAAE,WAAY,CAAG;IAC3BmC,IAAI,EAAGjC,YAAc;IACrBkC,WAAW;IACXN,IAAI,EAAC,SAAS;IACdO,eAAe,EAAC;EAAK,CACrB,CACM,CACD,CACR;AAEH,CAAE,CAAC;AAEH,eAAejC,UAAU","ignoreList":[]}
|
|
@@ -4,6 +4,11 @@ import { createElement } from "react";
|
|
|
4
4
|
*/
|
|
5
5
|
import { __, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { CheckboxControl } from '@wordpress/components';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
7
12
|
export default function SingleSelectionCheckbox({
|
|
8
13
|
selection,
|
|
9
14
|
onSelectionChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","CheckboxControl","SingleSelectionCheckbox","selection","onSelectionChange","item","data","getItemId","primaryField","disabled","id","isSelected","includes","selectionLabel","getValue","createElement","className","__nextHasNoMarginBottom","checked","onChange","filter","_item","itemId"],"sources":["@wordpress/dataviews/src/single-selection-checkbox.
|
|
1
|
+
{"version":3,"names":["__","sprintf","CheckboxControl","SingleSelectionCheckbox","selection","onSelectionChange","item","data","getItemId","primaryField","disabled","id","isSelected","includes","selectionLabel","getValue","createElement","className","__nextHasNoMarginBottom","checked","onChange","filter","_item","itemId"],"sources":["@wordpress/dataviews/src/single-selection-checkbox.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { Field, AnyItem } from './types';\n\ninterface SingleSelectionCheckboxProps< Item extends AnyItem > {\n\tselection: string[];\n\tonSelectionChange: ( selection: Item[] ) => void;\n\titem: Item;\n\tdata: Item[];\n\tgetItemId: ( item: Item ) => string;\n\tprimaryField?: Field< Item >;\n\tdisabled: boolean;\n}\n\nexport default function SingleSelectionCheckbox< Item extends AnyItem >( {\n\tselection,\n\tonSelectionChange,\n\titem,\n\tdata,\n\tgetItemId,\n\tprimaryField,\n\tdisabled,\n}: SingleSelectionCheckboxProps< Item > ) {\n\tconst id = getItemId( item );\n\tconst isSelected = selection.includes( id );\n\tlet selectionLabel;\n\tif ( primaryField?.getValue && item ) {\n\t\t// eslint-disable-next-line @wordpress/valid-sprintf\n\t\tselectionLabel = sprintf(\n\t\t\t/* translators: %s: item title. */\n\t\t\tisSelected ? __( 'Deselect item: %s' ) : __( 'Select item: %s' ),\n\t\t\tprimaryField.getValue( { item } )\n\t\t);\n\t} else {\n\t\tselectionLabel = isSelected\n\t\t\t? __( 'Select a new item' )\n\t\t\t: __( 'Deselect item' );\n\t}\n\treturn (\n\t\t<CheckboxControl\n\t\t\tclassName=\"dataviews-view-table-selection-checkbox\"\n\t\t\t__nextHasNoMarginBottom\n\t\t\taria-label={ selectionLabel }\n\t\t\taria-disabled={ disabled }\n\t\t\tchecked={ isSelected }\n\t\t\tonChange={ () => {\n\t\t\t\tif ( disabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isSelected ) {\n\t\t\t\t\tonSelectionChange(\n\t\t\t\t\t\tdata.filter( ( _item ) => {\n\t\t\t\t\t\t\tconst itemId = getItemId?.( _item );\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\titemId === id || selection.includes( itemId )\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} else {\n\t\t\t\t\tonSelectionChange(\n\t\t\t\t\t\tdata.filter( ( _item ) => {\n\t\t\t\t\t\t\tconst itemId = getItemId?.( _item );\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\titemId !== id && selection.includes( itemId )\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}\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,uBAAuB;;AAEvD;AACA;AACA;;AAaA,eAAe,SAASC,uBAAuBA,CAA0B;EACxEC,SAAS;EACTC,iBAAiB;EACjBC,IAAI;EACJC,IAAI;EACJC,SAAS;EACTC,YAAY;EACZC;AACqC,CAAC,EAAG;EACzC,MAAMC,EAAE,GAAGH,SAAS,CAAEF,IAAK,CAAC;EAC5B,MAAMM,UAAU,GAAGR,SAAS,CAACS,QAAQ,CAAEF,EAAG,CAAC;EAC3C,IAAIG,cAAc;EAClB,IAAKL,YAAY,EAAEM,QAAQ,IAAIT,IAAI,EAAG;IACrC;IACAQ,cAAc,GAAGb,OAAO,EACvB;IACAW,UAAU,GAAGZ,EAAE,CAAE,mBAAoB,CAAC,GAAGA,EAAE,CAAE,iBAAkB,CAAC,EAChES,YAAY,CAACM,QAAQ,CAAE;MAAET;IAAK,CAAE,CACjC,CAAC;EACF,CAAC,MAAM;IACNQ,cAAc,GAAGF,UAAU,GACxBZ,EAAE,CAAE,mBAAoB,CAAC,GACzBA,EAAE,CAAE,eAAgB,CAAC;EACzB;EACA,OACCgB,aAAA,CAACd,eAAe;IACfe,SAAS,EAAC,yCAAyC;IACnDC,uBAAuB;IACvB,cAAaJ,cAAgB;IAC7B,iBAAgBJ,QAAU;IAC1BS,OAAO,EAAGP,UAAY;IACtBQ,QAAQ,EAAGA,CAAA,KAAM;MAChB,IAAKV,QAAQ,EAAG;QACf;MACD;MAEA,IAAK,CAAEE,UAAU,EAAG;QACnBP,iBAAiB,CAChBE,IAAI,CAACc,MAAM,CAAIC,KAAK,IAAM;UACzB,MAAMC,MAAM,GAAGf,SAAS,GAAIc,KAAM,CAAC;UACnC,OACCC,MAAM,KAAKZ,EAAE,IAAIP,SAAS,CAACS,QAAQ,CAAEU,MAAO,CAAC;QAE/C,CAAE,CACH,CAAC;MACF,CAAC,MAAM;QACNlB,iBAAiB,CAChBE,IAAI,CAACc,MAAM,CAAIC,KAAK,IAAM;UACzB,MAAMC,MAAM,GAAGf,SAAS,GAAIc,KAAM,CAAC;UACnC,OACCC,MAAM,KAAKZ,EAAE,IAAIP,SAAS,CAACS,QAAQ,CAAEU,MAAO,CAAC;QAE/C,CAAE,CACH,CAAC;MACF;IACD;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode } from 'react';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\ninterface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\ntype Operator = 'is' | 'isNot' | 'isAny' | 'isNone' | 'isAll' | 'isNotAll';\n\nexport type AnyItem = Record< string, any >;\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport interface Field< Item extends AnyItem > {\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\theader?: string;\n\n\t/**\n\t * Callback used to retrieve the value of the field from the item.\n\t * Defaults to `item[ field.id ]`.\n\t */\n\tgetValue?: ( args: { item: Item } ) => any;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ( args: { item: Item } ) => ReactNode;\n\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n}\n\nexport type NormalizedField< Item extends AnyItem > = Field< Item > &\n\tRequired< Pick< Field< Item >, 'header' | 'getValue' | 'render' > >;\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item extends AnyItem > = Field< Item >[];\n\nexport type Data< Item extends AnyItem > = Item[];\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The hidden fields.\n\t */\n\thiddenFields: string[];\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewBase;\n\ninterface ActionBase< Item extends AnyItem > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t */\n\tlabel: string;\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n}\n\nexport interface ActionModal< Item extends AnyItem >\n\textends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action has finished.\n\t */\n\tonActionPerformed: ( ( items: Item[] ) => void ) | undefined;\n\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tonActionStart: ( ( items: Item[] ) => void ) | undefined;\n\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionStart,\n\t\tonActionPerformed,\n\t}: {\n\t\titems: Item[];\n\t\tcloseModal?: () => void;\n\t\tonActionStart?: ( items: Item[] ) => void;\n\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t} ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n}\n\nexport interface ActionButton< Item extends AnyItem >\n\textends ActionBase< AnyItem > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: ( items: Item[] ) => void;\n}\n\nexport type Action< Item extends AnyItem > =\n\t| ActionModal< Item >\n\t| ActionButton< Item >;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@ import { createElement, Fragment } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import clsx from 'clsx';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -35,7 +35,7 @@ function GridItem({
|
|
|
35
35
|
return createElement(VStack, {
|
|
36
36
|
spacing: 0,
|
|
37
37
|
key: id,
|
|
38
|
-
className:
|
|
38
|
+
className: clsx('dataviews-view-grid__card', {
|
|
39
39
|
'is-selected': hasBulkAction && isSelected
|
|
40
40
|
}),
|
|
41
41
|
onClickCapture: event => {
|
|
@@ -66,7 +66,6 @@ function GridItem({
|
|
|
66
66
|
justify: "space-between",
|
|
67
67
|
className: "dataviews-view-grid__title-actions"
|
|
68
68
|
}, createElement(SingleSelectionCheckbox, {
|
|
69
|
-
id: id,
|
|
70
69
|
item: item,
|
|
71
70
|
selection: selection,
|
|
72
71
|
onSelectionChange: onSelectionChange,
|
|
@@ -86,7 +85,7 @@ function GridItem({
|
|
|
86
85
|
className: "dataviews-view-grid__badge-fields",
|
|
87
86
|
spacing: 2,
|
|
88
87
|
wrap: true,
|
|
89
|
-
|
|
88
|
+
alignment: "top",
|
|
90
89
|
justify: "flex-start"
|
|
91
90
|
}, badgeFields.map(field => {
|
|
92
91
|
const renderedValue = field.render({
|
|
@@ -110,7 +109,7 @@ function GridItem({
|
|
|
110
109
|
return null;
|
|
111
110
|
}
|
|
112
111
|
return createElement(Flex, {
|
|
113
|
-
className:
|
|
112
|
+
className: clsx('dataviews-view-grid__field', columnFields?.includes(field.id) ? 'is-column' : 'is-row'),
|
|
114
113
|
key: field.id,
|
|
115
114
|
gap: 1,
|
|
116
115
|
justify: "flex-start",
|
|
@@ -130,14 +129,14 @@ function GridItem({
|
|
|
130
129
|
})));
|
|
131
130
|
}
|
|
132
131
|
export default function ViewGrid({
|
|
132
|
+
actions,
|
|
133
133
|
data,
|
|
134
134
|
fields,
|
|
135
|
-
view,
|
|
136
|
-
actions,
|
|
137
|
-
isLoading,
|
|
138
135
|
getItemId,
|
|
136
|
+
isLoading,
|
|
137
|
+
onSelectionChange,
|
|
139
138
|
selection,
|
|
140
|
-
|
|
139
|
+
view
|
|
141
140
|
}) {
|
|
142
141
|
const mediaField = fields.find(field => field.id === view.layout.mediaField);
|
|
143
142
|
const primaryField = fields.find(field => field.id === view.layout.primaryField);
|
|
@@ -180,7 +179,7 @@ export default function ViewGrid({
|
|
|
180
179
|
columnFields: view.layout.columnFields
|
|
181
180
|
});
|
|
182
181
|
})), !hasData && createElement("div", {
|
|
183
|
-
className:
|
|
182
|
+
className: clsx({
|
|
184
183
|
'dataviews-loading': isLoading,
|
|
185
184
|
'dataviews-no-results': !isLoading
|
|
186
185
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","__experimentalGrid","Grid","__experimentalHStack","HStack","__experimentalVStack","VStack","Spinner","Flex","FlexItem","__","ItemActions","SingleSelectionCheckbox","useHasAPossibleBulkAction","GridItem","selection","data","onSelectionChange","getItemId","item","actions","mediaField","primaryField","visibleFields","badgeFields","columnFields","hasBulkAction","id","isSelected","includes","createElement","spacing","key","className","onClickCapture","event","ctrlKey","metaKey","stopPropagation","preventDefault","filter","_item","itemId","render","justify","disabled","isCompact","length","wrap","align","map","field","renderedValue","gap","expanded","style","height","direction","Fragment","header","maxHeight","ViewGrid","fields","view","isLoading","find","layout","reduce","accumulator","hiddenFields","push","hasData","columns","alignment"],"sources":["@wordpress/dataviews/src/view-grid.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalGrid as Grid,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tSpinner,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ItemActions from './item-actions';\nimport SingleSelectionCheckbox from './single-selection-checkbox';\n\nimport { useHasAPossibleBulkAction } from './bulk-actions';\n\nfunction GridItem( {\n\tselection,\n\tdata,\n\tonSelectionChange,\n\tgetItemId,\n\titem,\n\tactions,\n\tmediaField,\n\tprimaryField,\n\tvisibleFields,\n\tbadgeFields,\n\tcolumnFields,\n} ) {\n\tconst hasBulkAction = useHasAPossibleBulkAction( actions, item );\n\tconst id = getItemId( item );\n\tconst isSelected = selection.includes( id );\n\treturn (\n\t\t<VStack\n\t\t\tspacing={ 0 }\n\t\t\tkey={ id }\n\t\t\tclassName={ classnames( 'dataviews-view-grid__card', {\n\t\t\t\t'is-selected': hasBulkAction && isSelected,\n\t\t\t} ) }\n\t\t\tonClickCapture={ ( event ) => {\n\t\t\t\tif ( event.ctrlKey || event.metaKey ) {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( ! hasBulkAction ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif ( ! isSelected ) {\n\t\t\t\t\t\tonSelectionChange(\n\t\t\t\t\t\t\tdata.filter( ( _item ) => {\n\t\t\t\t\t\t\t\tconst itemId = getItemId?.( _item );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\titemId === id ||\n\t\t\t\t\t\t\t\t\tselection.includes( itemId )\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} else {\n\t\t\t\t\t\tonSelectionChange(\n\t\t\t\t\t\t\tdata.filter( ( _item ) => {\n\t\t\t\t\t\t\t\tconst itemId = getItemId?.( _item );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\titemId !== id &&\n\t\t\t\t\t\t\t\t\tselection.includes( itemId )\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}\n\t\t\t} }\n\t\t>\n\t\t\t<div className=\"dataviews-view-grid__media\">\n\t\t\t\t{ mediaField?.render( { item } ) }\n\t\t\t</div>\n\t\t\t<HStack\n\t\t\t\tjustify=\"space-between\"\n\t\t\t\tclassName=\"dataviews-view-grid__title-actions\"\n\t\t\t>\n\t\t\t\t<SingleSelectionCheckbox\n\t\t\t\t\tid={ id }\n\t\t\t\t\titem={ item }\n\t\t\t\t\tselection={ selection }\n\t\t\t\t\tonSelectionChange={ onSelectionChange }\n\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tprimaryField={ primaryField }\n\t\t\t\t\tdisabled={ ! hasBulkAction }\n\t\t\t\t/>\n\t\t\t\t<HStack className=\"dataviews-view-grid__primary-field\">\n\t\t\t\t\t{ primaryField?.render( { item } ) }\n\t\t\t\t</HStack>\n\t\t\t\t<ItemActions item={ item } actions={ actions } isCompact />\n\t\t\t</HStack>\n\t\t\t{ !! badgeFields?.length && (\n\t\t\t\t<HStack\n\t\t\t\t\tclassName=\"dataviews-view-grid__badge-fields\"\n\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\twrap\n\t\t\t\t\talign=\"top\"\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t>\n\t\t\t\t\t{ badgeFields.map( ( field ) => {\n\t\t\t\t\t\tconst renderedValue = field.render( {\n\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tif ( ! renderedValue ) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tkey={ field.id }\n\t\t\t\t\t\t\t\tclassName={ 'dataviews-view-grid__field-value' }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ renderedValue }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</HStack>\n\t\t\t) }\n\t\t\t{ !! visibleFields?.length && (\n\t\t\t\t<VStack className=\"dataviews-view-grid__fields\" spacing={ 3 }>\n\t\t\t\t\t{ visibleFields.map( ( field ) => {\n\t\t\t\t\t\tconst renderedValue = field.render( {\n\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tif ( ! renderedValue ) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'dataviews-view-grid__field',\n\t\t\t\t\t\t\t\t\tcolumnFields?.includes( field.id )\n\t\t\t\t\t\t\t\t\t\t? 'is-column'\n\t\t\t\t\t\t\t\t\t\t: 'is-row'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tkey={ field.id }\n\t\t\t\t\t\t\t\tgap={ 1 }\n\t\t\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\t\t\texpanded\n\t\t\t\t\t\t\t\tstyle={ { height: 'auto' } }\n\t\t\t\t\t\t\t\tdirection={\n\t\t\t\t\t\t\t\t\tcolumnFields?.includes( field.id )\n\t\t\t\t\t\t\t\t\t\t? 'column'\n\t\t\t\t\t\t\t\t\t\t: 'row'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<FlexItem className=\"dataviews-view-grid__field-name\">\n\t\t\t\t\t\t\t\t\t\t{ field.header }\n\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\t\t\tclassName=\"dataviews-view-grid__field-value\"\n\t\t\t\t\t\t\t\t\t\tstyle={ { maxHeight: 'none' } }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ renderedValue }\n\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</VStack>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport default function ViewGrid( {\n\tdata,\n\tfields,\n\tview,\n\tactions,\n\tisLoading,\n\tgetItemId,\n\tselection,\n\tonSelectionChange,\n} ) {\n\tconst mediaField = fields.find(\n\t\t( field ) => field.id === view.layout.mediaField\n\t);\n\tconst primaryField = fields.find(\n\t\t( field ) => field.id === view.layout.primaryField\n\t);\n\tconst { visibleFields, badgeFields } = fields.reduce(\n\t\t( accumulator, field ) => {\n\t\t\tif (\n\t\t\t\tview.hiddenFields.includes( field.id ) ||\n\t\t\t\t[ view.layout.mediaField, view.layout.primaryField ].includes(\n\t\t\t\t\tfield.id\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\t\t\t// If the field is a badge field, add it to the badgeFields array\n\t\t\t// otherwise add it to the rest visibleFields array.\n\t\t\tconst key = view.layout.badgeFields?.includes( field.id )\n\t\t\t\t? 'badgeFields'\n\t\t\t\t: 'visibleFields';\n\t\t\taccumulator[ key ].push( field );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ visibleFields: [], badgeFields: [] }\n\t);\n\tconst hasData = !! data?.length;\n\treturn (\n\t\t<>\n\t\t\t{ hasData && (\n\t\t\t\t<Grid\n\t\t\t\t\tgap={ 6 }\n\t\t\t\t\tcolumns={ 2 }\n\t\t\t\t\talignment=\"top\"\n\t\t\t\t\tclassName=\"dataviews-view-grid\"\n\t\t\t\t\taria-busy={ isLoading }\n\t\t\t\t>\n\t\t\t\t\t{ data.map( ( item ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<GridItem\n\t\t\t\t\t\t\t\tkey={ getItemId( item ) }\n\t\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\tonSelectionChange={ onSelectionChange }\n\t\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\t\t\tmediaField={ mediaField }\n\t\t\t\t\t\t\t\tprimaryField={ primaryField }\n\t\t\t\t\t\t\t\tvisibleFields={ visibleFields }\n\t\t\t\t\t\t\t\tbadgeFields={ badgeFields }\n\t\t\t\t\t\t\t\tcolumnFields={ view.layout.columnFields }\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</Grid>\n\t\t\t) }\n\t\t\t{ ! hasData && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t'dataviews-loading': isLoading,\n\t\t\t\t\t\t'dataviews-no-results': ! isLoading,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<p>{ isLoading ? <Spinner /> : __( 'No results' ) }</p>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,OAAO,EACPC,IAAI,EACJC,QAAQ,QACF,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,WAAW,MAAM,gBAAgB;AACxC,OAAOC,uBAAuB,MAAM,6BAA6B;AAEjE,SAASC,yBAAyB,QAAQ,gBAAgB;AAE1D,SAASC,QAAQA,CAAE;EAClBC,SAAS;EACTC,IAAI;EACJC,iBAAiB;EACjBC,SAAS;EACTC,IAAI;EACJC,OAAO;EACPC,UAAU;EACVC,YAAY;EACZC,aAAa;EACbC,WAAW;EACXC;AACD,CAAC,EAAG;EACH,MAAMC,aAAa,GAAGb,yBAAyB,CAAEO,OAAO,EAAED,IAAK,CAAC;EAChE,MAAMQ,EAAE,GAAGT,SAAS,CAAEC,IAAK,CAAC;EAC5B,MAAMS,UAAU,GAAGb,SAAS,CAACc,QAAQ,CAAEF,EAAG,CAAC;EAC3C,OACCG,aAAA,CAACxB,MAAM;IACNyB,OAAO,EAAG,CAAG;IACbC,GAAG,EAAGL,EAAI;IACVM,SAAS,EAAGjC,UAAU,CAAE,2BAA2B,EAAE;MACpD,aAAa,EAAE0B,aAAa,IAAIE;IACjC,CAAE,CAAG;IACLM,cAAc,E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AE,CAAC,GAAGG,EAAE,CAAE,YAAa,CAAM,CAClD,CAEL,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","__experimentalGrid","Grid","__experimentalHStack","HStack","__experimentalVStack","VStack","Spinner","Flex","FlexItem","__","ItemActions","SingleSelectionCheckbox","useHasAPossibleBulkAction","GridItem","selection","data","onSelectionChange","getItemId","item","actions","mediaField","primaryField","visibleFields","badgeFields","columnFields","hasBulkAction","id","isSelected","includes","createElement","spacing","key","className","onClickCapture","event","ctrlKey","metaKey","stopPropagation","preventDefault","filter","_item","itemId","render","justify","disabled","isCompact","length","wrap","alignment","map","field","renderedValue","gap","expanded","style","height","direction","Fragment","header","maxHeight","ViewGrid","fields","isLoading","view","find","layout","reduce","accumulator","hiddenFields","push","hasData","columns"],"sources":["@wordpress/dataviews/src/view-grid.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalGrid as Grid,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tSpinner,\n\tFlex,\n\tFlexItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ItemActions from './item-actions';\nimport SingleSelectionCheckbox from './single-selection-checkbox';\nimport { useHasAPossibleBulkAction } from './bulk-actions';\nimport type {\n\tAction,\n\tAnyItem,\n\tNormalizedField,\n\tViewGrid as ViewGridType,\n} from './types';\n\ninterface GridItemProps< Item extends AnyItem > {\n\tselection: string[];\n\tdata: Item[];\n\tonSelectionChange: ( items: Item[] ) => void;\n\tgetItemId: ( item: Item ) => string;\n\titem: Item;\n\tactions: Action< Item >[];\n\tmediaField?: NormalizedField< Item >;\n\tprimaryField?: NormalizedField< Item >;\n\tvisibleFields: NormalizedField< Item >[];\n\tbadgeFields: NormalizedField< Item >[];\n\tcolumnFields: string[];\n}\n\ninterface ViewGridProps< Item extends AnyItem > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading: boolean;\n\tonSelectionChange: ( items: Item[] ) => void;\n\tselection: string[];\n\tview: ViewGridType;\n}\n\nfunction GridItem< Item extends AnyItem >( {\n\tselection,\n\tdata,\n\tonSelectionChange,\n\tgetItemId,\n\titem,\n\tactions,\n\tmediaField,\n\tprimaryField,\n\tvisibleFields,\n\tbadgeFields,\n\tcolumnFields,\n}: GridItemProps< Item > ) {\n\tconst hasBulkAction = useHasAPossibleBulkAction( actions, item );\n\tconst id = getItemId( item );\n\tconst isSelected = selection.includes( id );\n\treturn (\n\t\t<VStack\n\t\t\tspacing={ 0 }\n\t\t\tkey={ id }\n\t\t\tclassName={ clsx( 'dataviews-view-grid__card', {\n\t\t\t\t'is-selected': hasBulkAction && isSelected,\n\t\t\t} ) }\n\t\t\tonClickCapture={ ( event ) => {\n\t\t\t\tif ( event.ctrlKey || event.metaKey ) {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( ! hasBulkAction ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif ( ! isSelected ) {\n\t\t\t\t\t\tonSelectionChange(\n\t\t\t\t\t\t\tdata.filter( ( _item ) => {\n\t\t\t\t\t\t\t\tconst itemId = getItemId?.( _item );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\titemId === id ||\n\t\t\t\t\t\t\t\t\tselection.includes( itemId )\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} else {\n\t\t\t\t\t\tonSelectionChange(\n\t\t\t\t\t\t\tdata.filter( ( _item ) => {\n\t\t\t\t\t\t\t\tconst itemId = getItemId?.( _item );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\titemId !== id &&\n\t\t\t\t\t\t\t\t\tselection.includes( itemId )\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}\n\t\t\t} }\n\t\t>\n\t\t\t<div className=\"dataviews-view-grid__media\">\n\t\t\t\t{ mediaField?.render( { item } ) }\n\t\t\t</div>\n\t\t\t<HStack\n\t\t\t\tjustify=\"space-between\"\n\t\t\t\tclassName=\"dataviews-view-grid__title-actions\"\n\t\t\t>\n\t\t\t\t<SingleSelectionCheckbox\n\t\t\t\t\titem={ item }\n\t\t\t\t\tselection={ selection }\n\t\t\t\t\tonSelectionChange={ onSelectionChange }\n\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tprimaryField={ primaryField }\n\t\t\t\t\tdisabled={ ! hasBulkAction }\n\t\t\t\t/>\n\t\t\t\t<HStack className=\"dataviews-view-grid__primary-field\">\n\t\t\t\t\t{ primaryField?.render( { item } ) }\n\t\t\t\t</HStack>\n\t\t\t\t<ItemActions item={ item } actions={ actions } isCompact />\n\t\t\t</HStack>\n\t\t\t{ !! badgeFields?.length && (\n\t\t\t\t<HStack\n\t\t\t\t\tclassName=\"dataviews-view-grid__badge-fields\"\n\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\twrap\n\t\t\t\t\talignment=\"top\"\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t>\n\t\t\t\t\t{ badgeFields.map( ( field ) => {\n\t\t\t\t\t\tconst renderedValue = field.render( {\n\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tif ( ! renderedValue ) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\tkey={ field.id }\n\t\t\t\t\t\t\t\tclassName={ 'dataviews-view-grid__field-value' }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ renderedValue }\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</HStack>\n\t\t\t) }\n\t\t\t{ !! visibleFields?.length && (\n\t\t\t\t<VStack className=\"dataviews-view-grid__fields\" spacing={ 3 }>\n\t\t\t\t\t{ visibleFields.map( ( field ) => {\n\t\t\t\t\t\tconst renderedValue = field.render( {\n\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tif ( ! renderedValue ) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'dataviews-view-grid__field',\n\t\t\t\t\t\t\t\t\tcolumnFields?.includes( field.id )\n\t\t\t\t\t\t\t\t\t\t? 'is-column'\n\t\t\t\t\t\t\t\t\t\t: 'is-row'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tkey={ field.id }\n\t\t\t\t\t\t\t\tgap={ 1 }\n\t\t\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\t\t\texpanded\n\t\t\t\t\t\t\t\tstyle={ { height: 'auto' } }\n\t\t\t\t\t\t\t\tdirection={\n\t\t\t\t\t\t\t\t\tcolumnFields?.includes( field.id )\n\t\t\t\t\t\t\t\t\t\t? 'column'\n\t\t\t\t\t\t\t\t\t\t: 'row'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<FlexItem className=\"dataviews-view-grid__field-name\">\n\t\t\t\t\t\t\t\t\t\t{ field.header }\n\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\t\t\tclassName=\"dataviews-view-grid__field-value\"\n\t\t\t\t\t\t\t\t\t\tstyle={ { maxHeight: 'none' } }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ renderedValue }\n\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</VStack>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport default function ViewGrid< Item extends AnyItem >( {\n\tactions,\n\tdata,\n\tfields,\n\tgetItemId,\n\tisLoading,\n\tonSelectionChange,\n\tselection,\n\tview,\n}: ViewGridProps< Item > ) {\n\tconst mediaField = fields.find(\n\t\t( field ) => field.id === view.layout.mediaField\n\t);\n\tconst primaryField = fields.find(\n\t\t( field ) => field.id === view.layout.primaryField\n\t);\n\tconst { visibleFields, badgeFields } = fields.reduce(\n\t\t( accumulator: Record< string, NormalizedField< Item >[] >, field ) => {\n\t\t\tif (\n\t\t\t\tview.hiddenFields.includes( field.id ) ||\n\t\t\t\t[ view.layout.mediaField, view.layout.primaryField ].includes(\n\t\t\t\t\tfield.id\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\t\t\t// If the field is a badge field, add it to the badgeFields array\n\t\t\t// otherwise add it to the rest visibleFields array.\n\t\t\tconst key = view.layout.badgeFields?.includes( field.id )\n\t\t\t\t? 'badgeFields'\n\t\t\t\t: 'visibleFields';\n\t\t\taccumulator[ key ].push( field );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ visibleFields: [], badgeFields: [] }\n\t);\n\tconst hasData = !! data?.length;\n\treturn (\n\t\t<>\n\t\t\t{ hasData && (\n\t\t\t\t<Grid\n\t\t\t\t\tgap={ 6 }\n\t\t\t\t\tcolumns={ 2 }\n\t\t\t\t\talignment=\"top\"\n\t\t\t\t\tclassName=\"dataviews-view-grid\"\n\t\t\t\t\taria-busy={ isLoading }\n\t\t\t\t>\n\t\t\t\t\t{ data.map( ( item ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<GridItem\n\t\t\t\t\t\t\t\tkey={ getItemId( item ) }\n\t\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\tonSelectionChange={ onSelectionChange }\n\t\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\t\t\tmediaField={ mediaField }\n\t\t\t\t\t\t\t\tprimaryField={ primaryField }\n\t\t\t\t\t\t\t\tvisibleFields={ visibleFields }\n\t\t\t\t\t\t\t\tbadgeFields={ badgeFields }\n\t\t\t\t\t\t\t\tcolumnFields={ view.layout.columnFields }\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</Grid>\n\t\t\t) }\n\t\t\t{ ! hasData && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( {\n\t\t\t\t\t\t'dataviews-loading': isLoading,\n\t\t\t\t\t\t'dataviews-no-results': ! isLoading,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<p>{ isLoading ? <Spinner /> : __( 'No results' ) }</p>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,OAAO,EACPC,IAAI,EACJC,QAAQ,QACF,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,WAAW,MAAM,gBAAgB;AACxC,OAAOC,uBAAuB,MAAM,6BAA6B;AACjE,SAASC,yBAAyB,QAAQ,gBAAgB;AAiC1D,SAASC,QAAQA,CAA0B;EAC1CC,SAAS;EACTC,IAAI;EACJC,iBAAiB;EACjBC,SAAS;EACTC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