@wordpress/dataviews 6.0.0 → 7.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 +25 -1
- package/README.md +42 -14
- package/build/components/dataviews/index.js +38 -6
- package/build/components/dataviews/index.js.map +1 -1
- package/build/components/dataviews-context/index.js +4 -1
- package/build/components/dataviews-context/index.js.map +1 -1
- package/build/components/dataviews-item-actions/index.js +1 -10
- package/build/components/dataviews-item-actions/index.js.map +1 -1
- package/build/components/dataviews-pagination/index.js +1 -1
- package/build/components/dataviews-pagination/index.js.map +1 -1
- package/build/components/dataviews-view-config/index.js +8 -5
- package/build/components/dataviews-view-config/index.js.map +1 -1
- package/build/components/dataviews-view-config/infinite-scroll-toggle.js +47 -0
- package/build/components/dataviews-view-config/infinite-scroll-toggle.js.map +1 -0
- package/build/dataform-controls/array.js +70 -0
- package/build/dataform-controls/array.js.map +1 -0
- package/build/dataform-controls/boolean.js +15 -7
- package/build/dataform-controls/boolean.js.map +1 -1
- package/build/dataform-controls/email.js +14 -7
- package/build/dataform-controls/email.js.map +1 -1
- package/build/dataform-controls/index.js +3 -1
- package/build/dataform-controls/index.js.map +1 -1
- package/build/dataform-controls/integer.js +14 -7
- package/build/dataform-controls/integer.js.map +1 -1
- package/build/dataform-controls/text.js +14 -7
- package/build/dataform-controls/text.js.map +1 -1
- package/build/dataforms-layouts/card/index.js +137 -0
- package/build/dataforms-layouts/card/index.js.map +1 -0
- package/build/dataforms-layouts/data-form-layout.js +2 -2
- package/build/dataforms-layouts/data-form-layout.js.map +1 -1
- package/build/dataforms-layouts/index.js +4 -0
- package/build/dataforms-layouts/index.js.map +1 -1
- package/build/dataforms-layouts/panel/dropdown.js +124 -0
- package/build/dataforms-layouts/panel/dropdown.js.map +1 -0
- package/build/dataforms-layouts/panel/index.js +34 -149
- package/build/dataforms-layouts/panel/index.js.map +1 -1
- package/build/dataforms-layouts/panel/modal.js +125 -0
- package/build/dataforms-layouts/panel/modal.js.map +1 -0
- package/build/dataforms-layouts/regular/index.js +10 -21
- package/build/dataforms-layouts/regular/index.js.map +1 -1
- package/build/dataviews-layouts/grid/index.js +24 -7
- package/build/dataviews-layouts/grid/index.js.map +1 -1
- package/build/dataviews-layouts/grid/preview-size-picker.js +11 -11
- package/build/dataviews-layouts/grid/preview-size-picker.js.map +1 -1
- package/build/dataviews-layouts/list/index.js +45 -27
- package/build/dataviews-layouts/list/index.js.map +1 -1
- package/build/dataviews-layouts/table/column-header-menu.js +3 -0
- package/build/dataviews-layouts/table/column-header-menu.js.map +1 -1
- package/build/dataviews-layouts/table/index.js +23 -8
- package/build/dataviews-layouts/table/index.js.map +1 -1
- package/build/field-types/array.js +2 -2
- package/build/field-types/array.js.map +1 -1
- package/build/normalize-form-fields.js +52 -13
- package/build/normalize-form-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/components/dataviews/index.js +40 -8
- package/build-module/components/dataviews/index.js.map +1 -1
- package/build-module/components/dataviews-context/index.js +4 -1
- package/build-module/components/dataviews-context/index.js.map +1 -1
- package/build-module/components/dataviews-item-actions/index.js +1 -10
- package/build-module/components/dataviews-item-actions/index.js.map +1 -1
- package/build-module/components/dataviews-pagination/index.js +1 -1
- package/build-module/components/dataviews-pagination/index.js.map +1 -1
- package/build-module/components/dataviews-view-config/index.js +8 -5
- package/build-module/components/dataviews-view-config/index.js.map +1 -1
- package/build-module/components/dataviews-view-config/infinite-scroll-toggle.js +39 -0
- package/build-module/components/dataviews-view-config/infinite-scroll-toggle.js.map +1 -0
- package/build-module/dataform-controls/array.js +63 -0
- package/build-module/dataform-controls/array.js.map +1 -0
- package/build-module/dataform-controls/boolean.js +15 -7
- package/build-module/dataform-controls/boolean.js.map +1 -1
- package/build-module/dataform-controls/email.js +15 -8
- package/build-module/dataform-controls/email.js.map +1 -1
- package/build-module/dataform-controls/index.js +3 -1
- package/build-module/dataform-controls/index.js.map +1 -1
- package/build-module/dataform-controls/integer.js +15 -8
- package/build-module/dataform-controls/integer.js.map +1 -1
- package/build-module/dataform-controls/text.js +15 -8
- package/build-module/dataform-controls/text.js.map +1 -1
- package/build-module/dataforms-layouts/card/index.js +128 -0
- package/build-module/dataforms-layouts/card/index.js.map +1 -0
- package/build-module/dataforms-layouts/data-form-layout.js +2 -2
- package/build-module/dataforms-layouts/data-form-layout.js.map +1 -1
- package/build-module/dataforms-layouts/index.js +4 -0
- package/build-module/dataforms-layouts/index.js.map +1 -1
- package/build-module/dataforms-layouts/panel/dropdown.js +118 -0
- package/build-module/dataforms-layouts/panel/dropdown.js.map +1 -0
- package/build-module/dataforms-layouts/panel/index.js +37 -152
- package/build-module/dataforms-layouts/panel/index.js.map +1 -1
- package/build-module/dataforms-layouts/panel/modal.js +119 -0
- package/build-module/dataforms-layouts/panel/modal.js.map +1 -0
- package/build-module/dataforms-layouts/regular/index.js +10 -21
- package/build-module/dataforms-layouts/regular/index.js.map +1 -1
- package/build-module/dataviews-layouts/grid/index.js +25 -8
- package/build-module/dataviews-layouts/grid/index.js.map +1 -1
- package/build-module/dataviews-layouts/grid/preview-size-picker.js +11 -11
- package/build-module/dataviews-layouts/grid/preview-size-picker.js.map +1 -1
- package/build-module/dataviews-layouts/list/index.js +47 -29
- package/build-module/dataviews-layouts/list/index.js.map +1 -1
- package/build-module/dataviews-layouts/table/column-header-menu.js +3 -0
- package/build-module/dataviews-layouts/table/column-header-menu.js.map +1 -1
- package/build-module/dataviews-layouts/table/index.js +23 -8
- package/build-module/dataviews-layouts/table/index.js.map +1 -1
- package/build-module/field-types/array.js +2 -2
- package/build-module/field-types/array.js.map +1 -1
- package/build-module/normalize-form-fields.js +50 -13
- package/build-module/normalize-form-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-style/style-rtl.css +53 -16
- package/build-style/style.css +53 -16
- package/build-types/components/dataform/stories/index.story.d.ts +41 -17
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews/index.d.ts +5 -2
- package/build-types/components/dataviews/index.d.ts.map +1 -1
- package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -1
- package/build-types/components/dataviews/stories/index.story.d.ts +2 -1
- package/build-types/components/dataviews/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews-context/index.d.ts +4 -1
- package/build-types/components/dataviews-context/index.d.ts.map +1 -1
- package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -1
- package/build-types/components/dataviews-view-config/index.d.ts.map +1 -1
- package/build-types/components/dataviews-view-config/infinite-scroll-toggle.d.ts +2 -0
- package/build-types/components/dataviews-view-config/infinite-scroll-toggle.d.ts.map +1 -0
- package/build-types/dataform-controls/array.d.ts +6 -0
- package/build-types/dataform-controls/array.d.ts.map +1 -0
- package/build-types/dataform-controls/boolean.d.ts.map +1 -1
- package/build-types/dataform-controls/email.d.ts.map +1 -1
- package/build-types/dataform-controls/index.d.ts.map +1 -1
- package/build-types/dataform-controls/integer.d.ts.map +1 -1
- package/build-types/dataform-controls/text.d.ts.map +1 -1
- package/build-types/dataforms-layouts/card/index.d.ts +13 -0
- package/build-types/dataforms-layouts/card/index.d.ts.map +1 -0
- package/build-types/dataforms-layouts/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/dropdown.d.ts +14 -0
- package/build-types/dataforms-layouts/panel/dropdown.d.ts.map +1 -0
- package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/panel/modal.d.ts +13 -0
- package/build-types/dataforms-layouts/panel/modal.d.ts.map +1 -0
- package/build-types/dataforms-layouts/regular/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/grid/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/grid/preview-size-picker.d.ts +1 -1
- package/build-types/dataviews-layouts/grid/preview-size-picker.d.ts.map +1 -1
- package/build-types/dataviews-layouts/list/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/table/column-header-menu.d.ts.map +1 -1
- package/build-types/dataviews-layouts/table/index.d.ts.map +1 -1
- package/build-types/field-types/boolean.d.ts +1 -1
- package/build-types/normalize-form-fields.d.ts +10 -3
- package/build-types/normalize-form-fields.d.ts.map +1 -1
- package/build-types/test/normalize-form-fields.d.ts +2 -0
- package/build-types/test/normalize-form-fields.d.ts.map +1 -0
- package/build-types/types.d.ts +54 -6
- package/build-types/types.d.ts.map +1 -1
- package/build-wp/index.js +3062 -1147
- package/package.json +15 -15
- package/src/components/dataform/stories/index.story.tsx +478 -91
- package/src/components/dataviews/index.tsx +50 -14
- package/src/components/dataviews/stories/fixtures.tsx +98 -7
- package/src/components/dataviews/stories/index.story.tsx +137 -4
- package/src/components/dataviews/style.scss +4 -0
- package/src/components/dataviews-context/index.ts +6 -2
- package/src/components/dataviews-item-actions/index.tsx +7 -16
- package/src/components/dataviews-pagination/index.tsx +1 -1
- package/src/components/dataviews-view-config/index.tsx +13 -5
- package/src/components/dataviews-view-config/infinite-scroll-toggle.tsx +39 -0
- package/src/dataform-controls/array.tsx +85 -0
- package/src/dataform-controls/boolean.tsx +24 -10
- package/src/dataform-controls/email.tsx +24 -11
- package/src/dataform-controls/index.tsx +3 -1
- package/src/dataform-controls/integer.tsx +27 -13
- package/src/dataform-controls/text.tsx +24 -11
- package/src/dataforms-layouts/card/index.tsx +154 -0
- package/src/dataforms-layouts/card/style.scss +3 -0
- package/src/dataforms-layouts/data-form-layout.tsx +2 -2
- package/src/dataforms-layouts/index.tsx +5 -0
- package/src/dataforms-layouts/panel/dropdown.tsx +160 -0
- package/src/dataforms-layouts/panel/index.tsx +49 -189
- package/src/dataforms-layouts/panel/modal.tsx +165 -0
- package/src/dataforms-layouts/panel/style.scss +4 -0
- package/src/dataforms-layouts/regular/index.tsx +20 -23
- package/src/dataviews-layouts/grid/index.tsx +32 -5
- package/src/dataviews-layouts/grid/preview-size-picker.tsx +15 -13
- package/src/dataviews-layouts/grid/style.scss +3 -1
- package/src/dataviews-layouts/list/index.tsx +65 -31
- package/src/dataviews-layouts/list/style.scss +7 -3
- package/src/dataviews-layouts/table/column-header-menu.tsx +4 -0
- package/src/dataviews-layouts/table/index.tsx +27 -1
- package/src/field-types/array.tsx +1 -1
- package/src/normalize-form-fields.ts +63 -17
- package/src/test/dataform.tsx +181 -3
- package/src/test/dataviews.tsx +38 -0
- package/src/test/filter-and-sort-data-view.js +123 -64
- package/src/test/normalize-form-fields.ts +247 -0
- package/src/types.ts +72 -6
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -70,16 +70,21 @@ function TableRow({
|
|
|
70
70
|
onClickItem,
|
|
71
71
|
renderItemLink,
|
|
72
72
|
onChangeSelection,
|
|
73
|
-
isActionsColumnSticky
|
|
73
|
+
isActionsColumnSticky,
|
|
74
|
+
posinset
|
|
74
75
|
}) {
|
|
75
76
|
var _view$fields;
|
|
77
|
+
const {
|
|
78
|
+
paginationInfo
|
|
79
|
+
} = (0, _element.useContext)(_dataviewsContext.default);
|
|
76
80
|
const hasPossibleBulkAction = (0, _dataviewsBulkActions.useHasAPossibleBulkAction)(actions, item);
|
|
77
81
|
const isSelected = hasPossibleBulkAction && selection.includes(id);
|
|
78
82
|
const [isHovered, setIsHovered] = (0, _element.useState)(false);
|
|
79
83
|
const {
|
|
80
84
|
showTitle = true,
|
|
81
85
|
showMedia = true,
|
|
82
|
-
showDescription = true
|
|
86
|
+
showDescription = true,
|
|
87
|
+
infiniteScrollEnabled
|
|
83
88
|
} = view;
|
|
84
89
|
const handleMouseEnter = () => {
|
|
85
90
|
setIsHovered(true);
|
|
@@ -105,6 +110,9 @@ function TableRow({
|
|
|
105
110
|
onTouchStart: () => {
|
|
106
111
|
isTouchDeviceRef.current = true;
|
|
107
112
|
},
|
|
113
|
+
"aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : undefined,
|
|
114
|
+
"aria-posinset": posinset,
|
|
115
|
+
role: infiniteScrollEnabled ? 'article' : undefined,
|
|
108
116
|
onClick: event => {
|
|
109
117
|
if (!hasPossibleBulkAction) {
|
|
110
118
|
return;
|
|
@@ -274,6 +282,7 @@ function ViewTable({
|
|
|
274
282
|
headerMenuRefs.current.delete(column);
|
|
275
283
|
}
|
|
276
284
|
};
|
|
285
|
+
const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
|
|
277
286
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
278
287
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("table", {
|
|
279
288
|
className: (0, _clsx.default)('dataviews-view-table', className, {
|
|
@@ -281,6 +290,7 @@ function ViewTable({
|
|
|
281
290
|
}),
|
|
282
291
|
"aria-busy": isLoading,
|
|
283
292
|
"aria-describedby": tableNoticeId,
|
|
293
|
+
role: isInfiniteScroll ? 'feed' : undefined,
|
|
284
294
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("thead", {
|
|
285
295
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("tr", {
|
|
286
296
|
className: "dataviews-view-table__row",
|
|
@@ -307,7 +317,7 @@ function ViewTable({
|
|
|
307
317
|
canMove: false
|
|
308
318
|
})
|
|
309
319
|
}), columns.map((column, index) => {
|
|
310
|
-
var _view$layout$styles$c2;
|
|
320
|
+
var _view$layout$styles$c2, _view$layout$enableMo;
|
|
311
321
|
// Explicit picks the supported styles.
|
|
312
322
|
const {
|
|
313
323
|
width,
|
|
@@ -331,7 +341,8 @@ function ViewTable({
|
|
|
331
341
|
fields: fields,
|
|
332
342
|
onChangeView: onChangeView,
|
|
333
343
|
onHide: onHide,
|
|
334
|
-
setOpenedFilter: setOpenedFilter
|
|
344
|
+
setOpenedFilter: setOpenedFilter,
|
|
345
|
+
canMove: (_view$layout$enableMo = view.layout?.enableMoving) !== null && _view$layout$enableMo !== void 0 ? _view$layout$enableMo : true
|
|
335
346
|
})
|
|
336
347
|
}, column);
|
|
337
348
|
}), !!actions?.length && /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
|
|
@@ -392,18 +403,22 @@ function ViewTable({
|
|
|
392
403
|
onClickItem: onClickItem,
|
|
393
404
|
renderItemLink: renderItemLink,
|
|
394
405
|
isItemClickable: isItemClickable,
|
|
395
|
-
isActionsColumnSticky: !isHorizontalScrollEnd
|
|
406
|
+
isActionsColumnSticky: !isHorizontalScrollEnd,
|
|
407
|
+
posinset: isInfiniteScroll ? index + 1 : undefined
|
|
396
408
|
}, getItemId(item)))
|
|
397
409
|
})]
|
|
398
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
410
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
399
411
|
className: (0, _clsx.default)({
|
|
400
412
|
'dataviews-loading': isLoading,
|
|
401
413
|
'dataviews-no-results': !hasData && !isLoading
|
|
402
414
|
}),
|
|
403
415
|
id: tableNoticeId,
|
|
404
|
-
children: !hasData && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
416
|
+
children: [!hasData && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
405
417
|
children: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {}) : empty
|
|
406
|
-
})
|
|
418
|
+
}), hasData && isLoading && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
419
|
+
className: "dataviews-loading-more",
|
|
420
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})
|
|
421
|
+
})]
|
|
407
422
|
})]
|
|
408
423
|
});
|
|
409
424
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_components","_element","_keycodes","_dataviewsContext","_dataviewsSelectionCheckbox","_dataviewsItemActions","_constants","_dataviewsBulkActions","_columnHeaderMenu","_columnPrimary","_useIsHorizontalScrollEnd","_jsxRuntime","TableColumnField","item","fields","column","align","field","find","f","id","className","clsx","jsx","children","render","TableRow","hasBulkActions","level","actions","view","titleField","mediaField","descriptionField","selection","getItemId","isItemClickable","onClickItem","renderItemLink","onChangeSelection","isActionsColumnSticky","_view$fields","hasPossibleBulkAction","useHasAPossibleBulkAction","isSelected","includes","isHovered","setIsHovered","useState","showTitle","showMedia","showDescription","handleMouseEnter","handleMouseLeave","isTouchDeviceRef","useRef","columns","hasPrimaryColumn","jsxs","onMouseEnter","onMouseLeave","onTouchStart","current","onClick","event","document","getSelection","type","isAppleOS","metaKey","ctrlKey","filter","itemId","default","disabled","undefined","map","_view$layout$styles$c","width","maxWidth","minWidth","layout","styles","style","length","e","stopPropagation","ViewTable","data","getItemLevel","isLoading","onChangeView","setOpenedFilter","empty","_view$fields2","containerRef","useContext","DataViewsContext","headerMenuRefs","Map","headerMenuToFocusRef","nextHeaderMenuToFocus","setNextHeaderMenuToFocus","useSomeItemHasAPossibleBulkAction","useEffect","focus","tableNoticeId","useId","isHorizontalScrollEnd","useIsHorizontalScrollEnd","scrollContainerRef","enabled","onHide","hidden","get","fallback","node","hasData","groupField","groupByField","dataByGroup","reduce","groups","groupName","getValue","has","set","push","headerMenuRef","index","delete","Fragment","density","scope","BulkSelectionCheckbox","ref","fieldId","canMove","_view$layout$styles$c2","textAlign","sort","direction","sortValues","__","Array","from","entries","groupItems","colSpan","sprintf","label","showLevels","toString","Spinner","_default","exports"],"sources":["@wordpress/dataviews/src/dataviews-layouts/table/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ComponentProps, ReactElement } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Spinner } from '@wordpress/components';\nimport {\n\tuseContext,\n\tuseEffect,\n\tuseId,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../../components/dataviews-context';\nimport DataViewsSelectionCheckbox from '../../components/dataviews-selection-checkbox';\nimport ItemActions from '../../components/dataviews-item-actions';\nimport { sortValues } from '../../constants';\nimport {\n\tuseSomeItemHasAPossibleBulkAction,\n\tuseHasAPossibleBulkAction,\n\tBulkSelectionCheckbox,\n} from '../../components/dataviews-bulk-actions';\nimport type {\n\tAction,\n\tNormalizedField,\n\tViewTable as ViewTableType,\n\tViewTableProps,\n} from '../../types';\nimport type { SetSelection } from '../../private-types';\nimport ColumnHeaderMenu from './column-header-menu';\nimport ColumnPrimary from './column-primary';\nimport { useIsHorizontalScrollEnd } from './use-is-horizontal-scroll-end';\n\ninterface TableColumnFieldProps< Item > {\n\tfields: NormalizedField< Item >[];\n\tcolumn: string;\n\titem: Item;\n\talign?: 'start' | 'center' | 'end';\n}\n\ninterface TableRowProps< Item > {\n\thasBulkActions: boolean;\n\titem: Item;\n\tlevel?: number;\n\tactions: Action< Item >[];\n\tfields: NormalizedField< Item >[];\n\tid: string;\n\tview: ViewTableType;\n\ttitleField?: NormalizedField< Item >;\n\tmediaField?: NormalizedField< Item >;\n\tdescriptionField?: NormalizedField< Item >;\n\tselection: string[];\n\tgetItemId: ( item: Item ) => string;\n\tonChangeSelection: SetSelection;\n\tisItemClickable: ( item: Item ) => boolean;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisActionsColumnSticky?: boolean;\n}\n\nfunction TableColumnField< Item >( {\n\titem,\n\tfields,\n\tcolumn,\n\talign,\n}: TableColumnFieldProps< Item > ) {\n\tconst field = fields.find( ( f ) => f.id === column );\n\n\tif ( ! field ) {\n\t\treturn null;\n\t}\n\n\tconst className = clsx( 'dataviews-view-table__cell-content-wrapper', {\n\t\t'dataviews-view-table__cell-align-end': align === 'end',\n\t\t'dataviews-view-table__cell-align-center': align === 'center',\n\t} );\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<field.render item={ item } field={ field } />\n\t\t</div>\n\t);\n}\n\nfunction TableRow< Item >( {\n\thasBulkActions,\n\titem,\n\tlevel,\n\tactions,\n\tfields,\n\tid,\n\tview,\n\ttitleField,\n\tmediaField,\n\tdescriptionField,\n\tselection,\n\tgetItemId,\n\tisItemClickable,\n\tonClickItem,\n\trenderItemLink,\n\tonChangeSelection,\n\tisActionsColumnSticky,\n}: TableRowProps< Item > ) {\n\tconst hasPossibleBulkAction = useHasAPossibleBulkAction( actions, item );\n\tconst isSelected = hasPossibleBulkAction && selection.includes( id );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { showTitle = true, showMedia = true, showDescription = true } = view;\n\tconst handleMouseEnter = () => {\n\t\tsetIsHovered( true );\n\t};\n\tconst handleMouseLeave = () => {\n\t\tsetIsHovered( false );\n\t};\n\n\t// Will be set to true if `onTouchStart` fires. This happens before\n\t// `onClick` and can be used to exclude touchscreen devices from certain\n\t// behaviours.\n\tconst isTouchDeviceRef = useRef( false );\n\tconst columns = view.fields ?? [];\n\tconst hasPrimaryColumn =\n\t\t( titleField && showTitle ) ||\n\t\t( mediaField && showMedia ) ||\n\t\t( descriptionField && showDescription );\n\n\treturn (\n\t\t<tr\n\t\t\tclassName={ clsx( 'dataviews-view-table__row', {\n\t\t\t\t'is-selected': hasPossibleBulkAction && isSelected,\n\t\t\t\t'is-hovered': isHovered,\n\t\t\t\t'has-bulk-actions': hasPossibleBulkAction,\n\t\t\t} ) }\n\t\t\tonMouseEnter={ handleMouseEnter }\n\t\t\tonMouseLeave={ handleMouseLeave }\n\t\t\tonTouchStart={ () => {\n\t\t\t\tisTouchDeviceRef.current = true;\n\t\t\t} }\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tif ( ! hasPossibleBulkAction ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t! isTouchDeviceRef.current &&\n\t\t\t\t\tdocument.getSelection()?.type !== 'Range'\n\t\t\t\t) {\n\t\t\t\t\tif ( isAppleOS() ? event.metaKey : event.ctrlKey ) {\n\t\t\t\t\t\t// Handle non-consecutive selection.\n\t\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\t\tselection.includes( id )\n\t\t\t\t\t\t\t\t? selection.filter(\n\t\t\t\t\t\t\t\t\t\t( itemId ) => id !== itemId\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: [ ...selection, id ]\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Handle single selection\n\t\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\t\tselection.includes( id )\n\t\t\t\t\t\t\t\t? selection.filter(\n\t\t\t\t\t\t\t\t\t\t( itemId ) => id !== itemId\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: [ id ]\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{ hasBulkActions && (\n\t\t\t\t<td className=\"dataviews-view-table__checkbox-column\">\n\t\t\t\t\t<div className=\"dataviews-view-table__cell-content-wrapper\">\n\t\t\t\t\t\t<DataViewsSelectionCheckbox\n\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\ttitleField={ titleField }\n\t\t\t\t\t\t\tdisabled={ ! hasPossibleBulkAction }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</td>\n\t\t\t) }\n\t\t\t{ hasPrimaryColumn && (\n\t\t\t\t<td>\n\t\t\t\t\t<ColumnPrimary\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\ttitleField={ showTitle ? titleField : undefined }\n\t\t\t\t\t\tmediaField={ showMedia ? mediaField : undefined }\n\t\t\t\t\t\tdescriptionField={\n\t\t\t\t\t\t\tshowDescription ? descriptionField : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisItemClickable={ isItemClickable }\n\t\t\t\t\t\tonClickItem={ onClickItem }\n\t\t\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\t\t/>\n\t\t\t\t</td>\n\t\t\t) }\n\t\t\t{ columns.map( ( column: string ) => {\n\t\t\t\t// Explicit picks the supported styles.\n\t\t\t\tconst { width, maxWidth, minWidth, align } =\n\t\t\t\t\tview.layout?.styles?.[ column ] ?? {};\n\n\t\t\t\treturn (\n\t\t\t\t\t<td\n\t\t\t\t\t\tkey={ column }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\tmaxWidth,\n\t\t\t\t\t\t\tminWidth,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TableColumnField\n\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\tcolumn={ column }\n\t\t\t\t\t\t\talign={ align }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</td>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\t{ !! actions?.length && (\n\t\t\t\t// Disable reason: we are not making the element interactive,\n\t\t\t\t// but preventing any click events from bubbling up to the\n\t\t\t\t// table row. This allows us to add a click handler to the row\n\t\t\t\t// itself (to toggle row selection) without erroneously\n\t\t\t\t// intercepting click events from ItemActions.\n\n\t\t\t\t/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t\t\t<td\n\t\t\t\t\tclassName={ clsx( 'dataviews-view-table__actions-column', {\n\t\t\t\t\t\t'dataviews-view-table__actions-column--sticky': true,\n\t\t\t\t\t\t'dataviews-view-table__actions-column--stuck':\n\t\t\t\t\t\t\tisActionsColumnSticky,\n\t\t\t\t\t} ) }\n\t\t\t\t\tonClick={ ( e ) => e.stopPropagation() }\n\t\t\t\t>\n\t\t\t\t\t<ItemActions item={ item } actions={ actions } />\n\t\t\t\t</td>\n\t\t\t\t/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t\t) }\n\t\t</tr>\n\t);\n}\n\nfunction ViewTable< Item >( {\n\tactions,\n\tdata,\n\tfields,\n\tgetItemId,\n\tgetItemLevel,\n\tisLoading = false,\n\tonChangeView,\n\tonChangeSelection,\n\tselection,\n\tsetOpenedFilter,\n\tonClickItem,\n\tisItemClickable,\n\trenderItemLink,\n\tview,\n\tclassName,\n\tempty,\n}: ViewTableProps< Item > ) {\n\tconst { containerRef } = useContext( DataViewsContext );\n\tconst headerMenuRefs = useRef<\n\t\tMap< string, { node: HTMLButtonElement; fallback: string } >\n\t>( new Map() );\n\tconst headerMenuToFocusRef = useRef< HTMLButtonElement >();\n\tconst [ nextHeaderMenuToFocus, setNextHeaderMenuToFocus ] =\n\t\tuseState< HTMLButtonElement >();\n\tconst hasBulkActions = useSomeItemHasAPossibleBulkAction( actions, data );\n\n\tuseEffect( () => {\n\t\tif ( headerMenuToFocusRef.current ) {\n\t\t\theaderMenuToFocusRef.current.focus();\n\t\t\theaderMenuToFocusRef.current = undefined;\n\t\t}\n\t} );\n\n\tconst tableNoticeId = useId();\n\n\tconst isHorizontalScrollEnd = useIsHorizontalScrollEnd( {\n\t\tscrollContainerRef: containerRef,\n\t\tenabled: !! actions?.length,\n\t} );\n\n\tif ( nextHeaderMenuToFocus ) {\n\t\t// If we need to force focus, we short-circuit rendering here\n\t\t// to prevent any additional work while we handle that.\n\t\t// Clearing out the focus directive is necessary to make sure\n\t\t// future renders don't cause unexpected focus jumps.\n\t\theaderMenuToFocusRef.current = nextHeaderMenuToFocus;\n\t\tsetNextHeaderMenuToFocus( undefined );\n\t\treturn;\n\t}\n\n\tconst onHide = ( field: NormalizedField< Item > ) => {\n\t\tconst hidden = headerMenuRefs.current.get( field.id );\n\t\tconst fallback = hidden\n\t\t\t? headerMenuRefs.current.get( hidden.fallback )\n\t\t\t: undefined;\n\t\tsetNextHeaderMenuToFocus( fallback?.node );\n\t};\n\n\tconst hasData = !! data?.length;\n\n\tconst titleField = fields.find( ( field ) => field.id === view.titleField );\n\tconst mediaField = fields.find( ( field ) => field.id === view.mediaField );\n\tconst descriptionField = fields.find(\n\t\t( field ) => field.id === view.descriptionField\n\t);\n\n\t// Get group field if groupByField is specified\n\tconst groupField = view.groupByField\n\t\t? fields.find( ( f ) => f.id === view.groupByField )\n\t\t: null;\n\n\t// Group data by groupByField if specified\n\tconst dataByGroup = groupField\n\t\t? data.reduce( ( groups: Map< string, typeof data >, item ) => {\n\t\t\t\tconst groupName = groupField.getValue( { item } );\n\t\t\t\tif ( ! groups.has( groupName ) ) {\n\t\t\t\t\tgroups.set( groupName, [] );\n\t\t\t\t}\n\t\t\t\tgroups.get( groupName )?.push( item );\n\t\t\t\treturn groups;\n\t\t }, new Map< string, typeof data >() )\n\t\t: null;\n\tconst { showTitle = true, showMedia = true, showDescription = true } = view;\n\tconst hasPrimaryColumn =\n\t\t( titleField && showTitle ) ||\n\t\t( mediaField && showMedia ) ||\n\t\t( descriptionField && showDescription );\n\tconst columns = view.fields ?? [];\n\tconst headerMenuRef =\n\t\t( column: string, index: number ) => ( node: HTMLButtonElement ) => {\n\t\t\tif ( node ) {\n\t\t\t\theaderMenuRefs.current.set( column, {\n\t\t\t\t\tnode,\n\t\t\t\t\tfallback: columns[ index > 0 ? index - 1 : 1 ],\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\theaderMenuRefs.current.delete( column );\n\t\t\t}\n\t\t};\n\n\treturn (\n\t\t<>\n\t\t\t<table\n\t\t\t\tclassName={ clsx( 'dataviews-view-table', className, {\n\t\t\t\t\t[ `has-${ view.layout?.density }-density` ]:\n\t\t\t\t\t\tview.layout?.density &&\n\t\t\t\t\t\t[ 'compact', 'comfortable' ].includes(\n\t\t\t\t\t\t\tview.layout.density\n\t\t\t\t\t\t),\n\t\t\t\t} ) }\n\t\t\t\taria-busy={ isLoading }\n\t\t\t\taria-describedby={ tableNoticeId }\n\t\t\t>\n\t\t\t\t<thead>\n\t\t\t\t\t<tr className=\"dataviews-view-table__row\">\n\t\t\t\t\t\t{ hasBulkActions && (\n\t\t\t\t\t\t\t<th\n\t\t\t\t\t\t\t\tclassName=\"dataviews-view-table__checkbox-column\"\n\t\t\t\t\t\t\t\tscope=\"col\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<BulkSelectionCheckbox\n\t\t\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasPrimaryColumn && (\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t{ titleField && (\n\t\t\t\t\t\t\t\t\t<ColumnHeaderMenu\n\t\t\t\t\t\t\t\t\t\tref={ headerMenuRef(\n\t\t\t\t\t\t\t\t\t\t\ttitleField.id,\n\t\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tfieldId={ titleField.id }\n\t\t\t\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\t\t\t\t\tonHide={ onHide }\n\t\t\t\t\t\t\t\t\t\tsetOpenedFilter={ setOpenedFilter }\n\t\t\t\t\t\t\t\t\t\tcanMove={ false }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ columns.map( ( column, index ) => {\n\t\t\t\t\t\t\t// Explicit picks the supported styles.\n\t\t\t\t\t\t\tconst { width, maxWidth, minWidth, align } =\n\t\t\t\t\t\t\t\tview.layout?.styles?.[ column ] ?? {};\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<th\n\t\t\t\t\t\t\t\t\tkey={ column }\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\t\t\t\tmaxWidth,\n\t\t\t\t\t\t\t\t\t\tminWidth,\n\t\t\t\t\t\t\t\t\t\ttextAlign: align,\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\taria-sort={\n\t\t\t\t\t\t\t\t\t\tview.sort?.direction &&\n\t\t\t\t\t\t\t\t\t\tview.sort?.field === column\n\t\t\t\t\t\t\t\t\t\t\t? sortValues[ view.sort.direction ]\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tscope=\"col\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ColumnHeaderMenu\n\t\t\t\t\t\t\t\t\t\tref={ headerMenuRef( column, index ) }\n\t\t\t\t\t\t\t\t\t\tfieldId={ column }\n\t\t\t\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\t\t\t\t\tonHide={ onHide }\n\t\t\t\t\t\t\t\t\t\tsetOpenedFilter={ setOpenedFilter }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t{ !! actions?.length && (\n\t\t\t\t\t\t\t<th\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'dataviews-view-table__actions-column',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'dataviews-view-table__actions-column--sticky':\n\t\t\t\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\t\t\t'dataviews-view-table__actions-column--stuck':\n\t\t\t\t\t\t\t\t\t\t\t! isHorizontalScrollEnd,\n\t\t\t\t\t\t\t\t\t}\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<span className=\"dataviews-view-table-header\">\n\t\t\t\t\t\t\t\t\t{ __( 'Actions' ) }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t{ /* Render grouped data if groupByField is specified */ }\n\t\t\t\t{ hasData && groupField && dataByGroup ? (\n\t\t\t\t\tArray.from( dataByGroup.entries() ).map(\n\t\t\t\t\t\t( [ groupName, groupItems ] ) => (\n\t\t\t\t\t\t\t<tbody key={ `group-${ groupName }` }>\n\t\t\t\t\t\t\t\t<tr className=\"dataviews-view-table__group-header-row\">\n\t\t\t\t\t\t\t\t\t<td\n\t\t\t\t\t\t\t\t\t\tcolSpan={\n\t\t\t\t\t\t\t\t\t\t\tcolumns.length +\n\t\t\t\t\t\t\t\t\t\t\t( hasPrimaryColumn ? 1 : 0 ) +\n\t\t\t\t\t\t\t\t\t\t\t( hasBulkActions ? 1 : 0 ) +\n\t\t\t\t\t\t\t\t\t\t\t( actions?.length ? 1 : 0 )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tclassName=\"dataviews-view-table__group-header-cell\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// translators: 1: The label of the field e.g. \"Date\". 2: The value of the field, e.g.: \"May 2022\".\n\t\t\t\t\t\t\t\t\t\t\t__( '%1$s: %2$s' ),\n\t\t\t\t\t\t\t\t\t\t\tgroupField.label,\n\t\t\t\t\t\t\t\t\t\t\tgroupName\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t{ groupItems.map( ( item, index ) => (\n\t\t\t\t\t\t\t\t\t<TableRow\n\t\t\t\t\t\t\t\t\t\tkey={ getItemId( item ) }\n\t\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\t\tlevel={\n\t\t\t\t\t\t\t\t\t\t\tview.showLevels &&\n\t\t\t\t\t\t\t\t\t\t\ttypeof getItemLevel === 'function'\n\t\t\t\t\t\t\t\t\t\t\t\t? getItemLevel( item )\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\thasBulkActions={ hasBulkActions }\n\t\t\t\t\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\t\t\t\tid={\n\t\t\t\t\t\t\t\t\t\t\tgetItemId( item ) ||\n\t\t\t\t\t\t\t\t\t\t\tindex.toString()\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\t\t\t\ttitleField={ titleField }\n\t\t\t\t\t\t\t\t\t\tmediaField={ mediaField }\n\t\t\t\t\t\t\t\t\t\tdescriptionField={ descriptionField }\n\t\t\t\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\t\t\t\t\t\t\tonClickItem={ onClickItem }\n\t\t\t\t\t\t\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\t\t\t\t\t\t\tisItemClickable={ isItemClickable }\n\t\t\t\t\t\t\t\t\t\tisActionsColumnSticky={\n\t\t\t\t\t\t\t\t\t\t\t! isHorizontalScrollEnd\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) ) }\n\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t) : (\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t{ hasData &&\n\t\t\t\t\t\t\tdata.map( ( item, index ) => (\n\t\t\t\t\t\t\t\t<TableRow\n\t\t\t\t\t\t\t\t\tkey={ getItemId( item ) }\n\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\tlevel={\n\t\t\t\t\t\t\t\t\t\tview.showLevels &&\n\t\t\t\t\t\t\t\t\t\ttypeof getItemLevel === 'function'\n\t\t\t\t\t\t\t\t\t\t\t? getItemLevel( item )\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\thasBulkActions={ hasBulkActions }\n\t\t\t\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\t\t\tid={ getItemId( item ) || index.toString() }\n\t\t\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\t\t\ttitleField={ titleField }\n\t\t\t\t\t\t\t\t\tmediaField={ mediaField }\n\t\t\t\t\t\t\t\t\tdescriptionField={ descriptionField }\n\t\t\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\t\t\t\t\t\tonClickItem={ onClickItem }\n\t\t\t\t\t\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\t\t\t\t\t\tisItemClickable={ isItemClickable }\n\t\t\t\t\t\t\t\t\tisActionsColumnSticky={\n\t\t\t\t\t\t\t\t\t\t! isHorizontalScrollEnd\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t</tbody>\n\t\t\t\t) }\n\t\t\t</table>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( {\n\t\t\t\t\t'dataviews-loading': isLoading,\n\t\t\t\t\t'dataviews-no-results': ! hasData && ! isLoading,\n\t\t\t\t} ) }\n\t\t\t\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BAAgB,EAAGA,gBAAkB;UACrCC,SAAS,EAAGA,SAAW;UACvBC,SAAS,EAAGA,SAAW;UACvBI,iBAAiB,EAAGA,iBAAmB;UACvCF,WAAW,EAAGA,WAAa;UAC3BC,cAAc,EAAGA,cAAgB;UACjCF,eAAe,EAAGA,eAAiB;UACnCI,qBAAqB,EACpB,CAAEoE;QACF,GAxBKzE,SAAS,CAAEtB,IAAK,CAyBtB,CACA;MAAC,CACE,CACP;IAAA,CACK,CAAC,eACR,IAAAF,WAAA,CAAAY,GAAA;MACCF,SAAS,EAAG,IAAAC,aAAI,EAAE;QACjB,mBAAmB,EAAEoE,SAAS;QAC9B,sBAAsB,EAAE,CAAE2B,OAAO,IAAI,CAAE3B;MACxC,CAAE,CAAG;MACLtE,EAAE,EAAGsF,aAAe;MAAAlF,QAAA,EAElB,CAAE6F,OAAO,iBAAI,IAAA1G,WAAA,CAAAY,GAAA;QAAAC,QAAA,EAAKkE,SAAS,gBAAG,IAAA/E,WAAA,CAAAY,GAAA,EAACvB,WAAA,CAAAyJ,OAAO,IAAE,CAAC,GAAG5D;MAAK,CAAK;IAAC,CACrD,CAAC;EAAA,CACL,CAAC;AAEL;AAAC,IAAA6D,QAAA,GAAAC,OAAA,CAAAlF,OAAA,GAEcc,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_components","_element","_keycodes","_dataviewsContext","_dataviewsSelectionCheckbox","_dataviewsItemActions","_constants","_dataviewsBulkActions","_columnHeaderMenu","_columnPrimary","_useIsHorizontalScrollEnd","_jsxRuntime","TableColumnField","item","fields","column","align","field","find","f","id","className","clsx","jsx","children","render","TableRow","hasBulkActions","level","actions","view","titleField","mediaField","descriptionField","selection","getItemId","isItemClickable","onClickItem","renderItemLink","onChangeSelection","isActionsColumnSticky","posinset","_view$fields","paginationInfo","useContext","DataViewsContext","hasPossibleBulkAction","useHasAPossibleBulkAction","isSelected","includes","isHovered","setIsHovered","useState","showTitle","showMedia","showDescription","infiniteScrollEnabled","handleMouseEnter","handleMouseLeave","isTouchDeviceRef","useRef","columns","hasPrimaryColumn","jsxs","onMouseEnter","onMouseLeave","onTouchStart","current","totalItems","undefined","role","onClick","event","document","getSelection","type","isAppleOS","metaKey","ctrlKey","filter","itemId","default","disabled","map","_view$layout$styles$c","width","maxWidth","minWidth","layout","styles","style","length","e","stopPropagation","ViewTable","data","getItemLevel","isLoading","onChangeView","setOpenedFilter","empty","_view$fields2","containerRef","headerMenuRefs","Map","headerMenuToFocusRef","nextHeaderMenuToFocus","setNextHeaderMenuToFocus","useSomeItemHasAPossibleBulkAction","useEffect","focus","tableNoticeId","useId","isHorizontalScrollEnd","useIsHorizontalScrollEnd","scrollContainerRef","enabled","onHide","hidden","get","fallback","node","hasData","groupField","groupByField","dataByGroup","reduce","groups","groupName","getValue","has","set","push","headerMenuRef","index","delete","isInfiniteScroll","Fragment","density","scope","BulkSelectionCheckbox","ref","fieldId","canMove","_view$layout$styles$c2","_view$layout$enableMo","textAlign","sort","direction","sortValues","enableMoving","__","Array","from","entries","groupItems","colSpan","sprintf","label","showLevels","toString","Spinner","_default","exports"],"sources":["@wordpress/dataviews/src/dataviews-layouts/table/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ComponentProps, ReactElement } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Spinner } from '@wordpress/components';\nimport {\n\tuseContext,\n\tuseEffect,\n\tuseId,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../../components/dataviews-context';\nimport DataViewsSelectionCheckbox from '../../components/dataviews-selection-checkbox';\nimport ItemActions from '../../components/dataviews-item-actions';\nimport { sortValues } from '../../constants';\nimport {\n\tuseSomeItemHasAPossibleBulkAction,\n\tuseHasAPossibleBulkAction,\n\tBulkSelectionCheckbox,\n} from '../../components/dataviews-bulk-actions';\nimport type {\n\tAction,\n\tNormalizedField,\n\tViewTable as ViewTableType,\n\tViewTableProps,\n} from '../../types';\nimport type { SetSelection } from '../../private-types';\nimport ColumnHeaderMenu from './column-header-menu';\nimport ColumnPrimary from './column-primary';\nimport { useIsHorizontalScrollEnd } from './use-is-horizontal-scroll-end';\n\ninterface TableColumnFieldProps< Item > {\n\tfields: NormalizedField< Item >[];\n\tcolumn: string;\n\titem: Item;\n\talign?: 'start' | 'center' | 'end';\n}\n\ninterface TableRowProps< Item > {\n\thasBulkActions: boolean;\n\titem: Item;\n\tlevel?: number;\n\tactions: Action< Item >[];\n\tfields: NormalizedField< Item >[];\n\tid: string;\n\tview: ViewTableType;\n\ttitleField?: NormalizedField< Item >;\n\tmediaField?: NormalizedField< Item >;\n\tdescriptionField?: NormalizedField< Item >;\n\tselection: string[];\n\tgetItemId: ( item: Item ) => string;\n\tonChangeSelection: SetSelection;\n\tisItemClickable: ( item: Item ) => boolean;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisActionsColumnSticky?: boolean;\n\tposinset?: number;\n}\n\nfunction TableColumnField< Item >( {\n\titem,\n\tfields,\n\tcolumn,\n\talign,\n}: TableColumnFieldProps< Item > ) {\n\tconst field = fields.find( ( f ) => f.id === column );\n\n\tif ( ! field ) {\n\t\treturn null;\n\t}\n\n\tconst className = clsx( 'dataviews-view-table__cell-content-wrapper', {\n\t\t'dataviews-view-table__cell-align-end': align === 'end',\n\t\t'dataviews-view-table__cell-align-center': align === 'center',\n\t} );\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<field.render item={ item } field={ field } />\n\t\t</div>\n\t);\n}\n\nfunction TableRow< Item >( {\n\thasBulkActions,\n\titem,\n\tlevel,\n\tactions,\n\tfields,\n\tid,\n\tview,\n\ttitleField,\n\tmediaField,\n\tdescriptionField,\n\tselection,\n\tgetItemId,\n\tisItemClickable,\n\tonClickItem,\n\trenderItemLink,\n\tonChangeSelection,\n\tisActionsColumnSticky,\n\tposinset,\n}: TableRowProps< Item > ) {\n\tconst { paginationInfo } = useContext( DataViewsContext );\n\tconst hasPossibleBulkAction = useHasAPossibleBulkAction( actions, item );\n\tconst isSelected = hasPossibleBulkAction && selection.includes( id );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst {\n\t\tshowTitle = true,\n\t\tshowMedia = true,\n\t\tshowDescription = true,\n\t\tinfiniteScrollEnabled,\n\t} = view;\n\tconst handleMouseEnter = () => {\n\t\tsetIsHovered( true );\n\t};\n\tconst handleMouseLeave = () => {\n\t\tsetIsHovered( false );\n\t};\n\n\t// Will be set to true if `onTouchStart` fires. This happens before\n\t// `onClick` and can be used to exclude touchscreen devices from certain\n\t// behaviours.\n\tconst isTouchDeviceRef = useRef( false );\n\tconst columns = view.fields ?? [];\n\tconst hasPrimaryColumn =\n\t\t( titleField && showTitle ) ||\n\t\t( mediaField && showMedia ) ||\n\t\t( descriptionField && showDescription );\n\n\treturn (\n\t\t<tr\n\t\t\tclassName={ clsx( 'dataviews-view-table__row', {\n\t\t\t\t'is-selected': hasPossibleBulkAction && isSelected,\n\t\t\t\t'is-hovered': isHovered,\n\t\t\t\t'has-bulk-actions': hasPossibleBulkAction,\n\t\t\t} ) }\n\t\t\tonMouseEnter={ handleMouseEnter }\n\t\t\tonMouseLeave={ handleMouseLeave }\n\t\t\tonTouchStart={ () => {\n\t\t\t\tisTouchDeviceRef.current = true;\n\t\t\t} }\n\t\t\taria-setsize={\n\t\t\t\tinfiniteScrollEnabled ? paginationInfo.totalItems : undefined\n\t\t\t}\n\t\t\taria-posinset={ posinset }\n\t\t\trole={ infiniteScrollEnabled ? 'article' : undefined }\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tif ( ! hasPossibleBulkAction ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t! isTouchDeviceRef.current &&\n\t\t\t\t\tdocument.getSelection()?.type !== 'Range'\n\t\t\t\t) {\n\t\t\t\t\tif ( isAppleOS() ? event.metaKey : event.ctrlKey ) {\n\t\t\t\t\t\t// Handle non-consecutive selection.\n\t\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\t\tselection.includes( id )\n\t\t\t\t\t\t\t\t? selection.filter(\n\t\t\t\t\t\t\t\t\t\t( itemId ) => id !== itemId\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: [ ...selection, id ]\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Handle single selection\n\t\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\t\tselection.includes( id )\n\t\t\t\t\t\t\t\t? selection.filter(\n\t\t\t\t\t\t\t\t\t\t( itemId ) => id !== itemId\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: [ id ]\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{ hasBulkActions && (\n\t\t\t\t<td className=\"dataviews-view-table__checkbox-column\">\n\t\t\t\t\t<div className=\"dataviews-view-table__cell-content-wrapper\">\n\t\t\t\t\t\t<DataViewsSelectionCheckbox\n\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\ttitleField={ titleField }\n\t\t\t\t\t\t\tdisabled={ ! hasPossibleBulkAction }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</td>\n\t\t\t) }\n\t\t\t{ hasPrimaryColumn && (\n\t\t\t\t<td>\n\t\t\t\t\t<ColumnPrimary\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\ttitleField={ showTitle ? titleField : undefined }\n\t\t\t\t\t\tmediaField={ showMedia ? mediaField : undefined }\n\t\t\t\t\t\tdescriptionField={\n\t\t\t\t\t\t\tshowDescription ? descriptionField : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisItemClickable={ isItemClickable }\n\t\t\t\t\t\tonClickItem={ onClickItem }\n\t\t\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\t\t/>\n\t\t\t\t</td>\n\t\t\t) }\n\t\t\t{ columns.map( ( column: string ) => {\n\t\t\t\t// Explicit picks the supported styles.\n\t\t\t\tconst { width, maxWidth, minWidth, align } =\n\t\t\t\t\tview.layout?.styles?.[ column ] ?? {};\n\n\t\t\t\treturn (\n\t\t\t\t\t<td\n\t\t\t\t\t\tkey={ column }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\tmaxWidth,\n\t\t\t\t\t\t\tminWidth,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TableColumnField\n\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\tcolumn={ column }\n\t\t\t\t\t\t\talign={ align }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</td>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\t{ !! actions?.length && (\n\t\t\t\t// Disable reason: we are not making the element interactive,\n\t\t\t\t// but preventing any click events from bubbling up to the\n\t\t\t\t// table row. This allows us to add a click handler to the row\n\t\t\t\t// itself (to toggle row selection) without erroneously\n\t\t\t\t// intercepting click events from ItemActions.\n\n\t\t\t\t/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t\t\t<td\n\t\t\t\t\tclassName={ clsx( 'dataviews-view-table__actions-column', {\n\t\t\t\t\t\t'dataviews-view-table__actions-column--sticky': true,\n\t\t\t\t\t\t'dataviews-view-table__actions-column--stuck':\n\t\t\t\t\t\t\tisActionsColumnSticky,\n\t\t\t\t\t} ) }\n\t\t\t\t\tonClick={ ( e ) => e.stopPropagation() }\n\t\t\t\t>\n\t\t\t\t\t<ItemActions item={ item } actions={ actions } />\n\t\t\t\t</td>\n\t\t\t\t/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */\n\t\t\t) }\n\t\t</tr>\n\t);\n}\n\nfunction ViewTable< Item >( {\n\tactions,\n\tdata,\n\tfields,\n\tgetItemId,\n\tgetItemLevel,\n\tisLoading = false,\n\tonChangeView,\n\tonChangeSelection,\n\tselection,\n\tsetOpenedFilter,\n\tonClickItem,\n\tisItemClickable,\n\trenderItemLink,\n\tview,\n\tclassName,\n\tempty,\n}: ViewTableProps< Item > ) {\n\tconst { containerRef } = useContext( DataViewsContext );\n\tconst headerMenuRefs = useRef<\n\t\tMap< string, { node: HTMLButtonElement; fallback: string } >\n\t>( new Map() );\n\tconst headerMenuToFocusRef = useRef< HTMLButtonElement >();\n\tconst [ nextHeaderMenuToFocus, setNextHeaderMenuToFocus ] =\n\t\tuseState< HTMLButtonElement >();\n\tconst hasBulkActions = useSomeItemHasAPossibleBulkAction( actions, data );\n\n\tuseEffect( () => {\n\t\tif ( headerMenuToFocusRef.current ) {\n\t\t\theaderMenuToFocusRef.current.focus();\n\t\t\theaderMenuToFocusRef.current = undefined;\n\t\t}\n\t} );\n\n\tconst tableNoticeId = useId();\n\n\tconst isHorizontalScrollEnd = useIsHorizontalScrollEnd( {\n\t\tscrollContainerRef: containerRef,\n\t\tenabled: !! actions?.length,\n\t} );\n\n\tif ( nextHeaderMenuToFocus ) {\n\t\t// If we need to force focus, we short-circuit rendering here\n\t\t// to prevent any additional work while we handle that.\n\t\t// Clearing out the focus directive is necessary to make sure\n\t\t// future renders don't cause unexpected focus jumps.\n\t\theaderMenuToFocusRef.current = nextHeaderMenuToFocus;\n\t\tsetNextHeaderMenuToFocus( undefined );\n\t\treturn;\n\t}\n\n\tconst onHide = ( field: NormalizedField< Item > ) => {\n\t\tconst hidden = headerMenuRefs.current.get( field.id );\n\t\tconst fallback = hidden\n\t\t\t? headerMenuRefs.current.get( hidden.fallback )\n\t\t\t: undefined;\n\t\tsetNextHeaderMenuToFocus( fallback?.node );\n\t};\n\n\tconst hasData = !! data?.length;\n\n\tconst titleField = fields.find( ( field ) => field.id === view.titleField );\n\tconst mediaField = fields.find( ( field ) => field.id === view.mediaField );\n\tconst descriptionField = fields.find(\n\t\t( field ) => field.id === view.descriptionField\n\t);\n\n\t// Get group field if groupByField is specified\n\tconst groupField = view.groupByField\n\t\t? fields.find( ( f ) => f.id === view.groupByField )\n\t\t: null;\n\n\t// Group data by groupByField if specified\n\tconst dataByGroup = groupField\n\t\t? data.reduce( ( groups: Map< string, typeof data >, item ) => {\n\t\t\t\tconst groupName = groupField.getValue( { item } );\n\t\t\t\tif ( ! groups.has( groupName ) ) {\n\t\t\t\t\tgroups.set( groupName, [] );\n\t\t\t\t}\n\t\t\t\tgroups.get( groupName )?.push( item );\n\t\t\t\treturn groups;\n\t\t }, new Map< string, typeof data >() )\n\t\t: null;\n\tconst { showTitle = true, showMedia = true, showDescription = true } = view;\n\tconst hasPrimaryColumn =\n\t\t( titleField && showTitle ) ||\n\t\t( mediaField && showMedia ) ||\n\t\t( descriptionField && showDescription );\n\tconst columns = view.fields ?? [];\n\tconst headerMenuRef =\n\t\t( column: string, index: number ) => ( node: HTMLButtonElement ) => {\n\t\t\tif ( node ) {\n\t\t\t\theaderMenuRefs.current.set( column, {\n\t\t\t\t\tnode,\n\t\t\t\t\tfallback: columns[ index > 0 ? index - 1 : 1 ],\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\theaderMenuRefs.current.delete( column );\n\t\t\t}\n\t\t};\n\tconst isInfiniteScroll = view.infiniteScrollEnabled && ! dataByGroup;\n\n\treturn (\n\t\t<>\n\t\t\t<table\n\t\t\t\tclassName={ clsx( 'dataviews-view-table', className, {\n\t\t\t\t\t[ `has-${ view.layout?.density }-density` ]:\n\t\t\t\t\t\tview.layout?.density &&\n\t\t\t\t\t\t[ 'compact', 'comfortable' ].includes(\n\t\t\t\t\t\t\tview.layout.density\n\t\t\t\t\t\t),\n\t\t\t\t} ) }\n\t\t\t\taria-busy={ isLoading }\n\t\t\t\taria-describedby={ tableNoticeId }\n\t\t\t\trole={ isInfiniteScroll ? 'feed' : undefined }\n\t\t\t>\n\t\t\t\t<thead>\n\t\t\t\t\t<tr className=\"dataviews-view-table__row\">\n\t\t\t\t\t\t{ hasBulkActions && (\n\t\t\t\t\t\t\t<th\n\t\t\t\t\t\t\t\tclassName=\"dataviews-view-table__checkbox-column\"\n\t\t\t\t\t\t\t\tscope=\"col\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<BulkSelectionCheckbox\n\t\t\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasPrimaryColumn && (\n\t\t\t\t\t\t\t<th scope=\"col\">\n\t\t\t\t\t\t\t\t{ titleField && (\n\t\t\t\t\t\t\t\t\t<ColumnHeaderMenu\n\t\t\t\t\t\t\t\t\t\tref={ headerMenuRef(\n\t\t\t\t\t\t\t\t\t\t\ttitleField.id,\n\t\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tfieldId={ titleField.id }\n\t\t\t\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\t\t\t\t\tonHide={ onHide }\n\t\t\t\t\t\t\t\t\t\tsetOpenedFilter={ setOpenedFilter }\n\t\t\t\t\t\t\t\t\t\tcanMove={ false }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ columns.map( ( column, index ) => {\n\t\t\t\t\t\t\t// Explicit picks the supported styles.\n\t\t\t\t\t\t\tconst { width, maxWidth, minWidth, align } =\n\t\t\t\t\t\t\t\tview.layout?.styles?.[ column ] ?? {};\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<th\n\t\t\t\t\t\t\t\t\tkey={ column }\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\t\t\t\tmaxWidth,\n\t\t\t\t\t\t\t\t\t\tminWidth,\n\t\t\t\t\t\t\t\t\t\ttextAlign: align,\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\taria-sort={\n\t\t\t\t\t\t\t\t\t\tview.sort?.direction &&\n\t\t\t\t\t\t\t\t\t\tview.sort?.field === column\n\t\t\t\t\t\t\t\t\t\t\t? sortValues[ view.sort.direction ]\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tscope=\"col\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ColumnHeaderMenu\n\t\t\t\t\t\t\t\t\t\tref={ headerMenuRef( column, index ) }\n\t\t\t\t\t\t\t\t\t\tfieldId={ column }\n\t\t\t\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\t\t\t\t\tonHide={ onHide }\n\t\t\t\t\t\t\t\t\t\tsetOpenedFilter={ setOpenedFilter }\n\t\t\t\t\t\t\t\t\t\tcanMove={\n\t\t\t\t\t\t\t\t\t\t\tview.layout?.enableMoving ?? true\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</th>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t{ !! actions?.length && (\n\t\t\t\t\t\t\t<th\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'dataviews-view-table__actions-column',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'dataviews-view-table__actions-column--sticky':\n\t\t\t\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\t\t\t'dataviews-view-table__actions-column--stuck':\n\t\t\t\t\t\t\t\t\t\t\t! isHorizontalScrollEnd,\n\t\t\t\t\t\t\t\t\t}\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<span className=\"dataviews-view-table-header\">\n\t\t\t\t\t\t\t\t\t{ __( 'Actions' ) }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</tr>\n\t\t\t\t</thead>\n\t\t\t\t{ /* Render grouped data if groupByField is specified */ }\n\t\t\t\t{ hasData && groupField && dataByGroup ? (\n\t\t\t\t\tArray.from( dataByGroup.entries() ).map(\n\t\t\t\t\t\t( [ groupName, groupItems ] ) => (\n\t\t\t\t\t\t\t<tbody key={ `group-${ groupName }` }>\n\t\t\t\t\t\t\t\t<tr className=\"dataviews-view-table__group-header-row\">\n\t\t\t\t\t\t\t\t\t<td\n\t\t\t\t\t\t\t\t\t\tcolSpan={\n\t\t\t\t\t\t\t\t\t\t\tcolumns.length +\n\t\t\t\t\t\t\t\t\t\t\t( hasPrimaryColumn ? 1 : 0 ) +\n\t\t\t\t\t\t\t\t\t\t\t( hasBulkActions ? 1 : 0 ) +\n\t\t\t\t\t\t\t\t\t\t\t( actions?.length ? 1 : 0 )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tclassName=\"dataviews-view-table__group-header-cell\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// translators: 1: The label of the field e.g. \"Date\". 2: The value of the field, e.g.: \"May 2022\".\n\t\t\t\t\t\t\t\t\t\t\t__( '%1$s: %2$s' ),\n\t\t\t\t\t\t\t\t\t\t\tgroupField.label,\n\t\t\t\t\t\t\t\t\t\t\tgroupName\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t{ groupItems.map( ( item, index ) => (\n\t\t\t\t\t\t\t\t\t<TableRow\n\t\t\t\t\t\t\t\t\t\tkey={ getItemId( item ) }\n\t\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\t\tlevel={\n\t\t\t\t\t\t\t\t\t\t\tview.showLevels &&\n\t\t\t\t\t\t\t\t\t\t\ttypeof getItemLevel === 'function'\n\t\t\t\t\t\t\t\t\t\t\t\t? getItemLevel( item )\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\thasBulkActions={ hasBulkActions }\n\t\t\t\t\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\t\t\t\tid={\n\t\t\t\t\t\t\t\t\t\t\tgetItemId( item ) ||\n\t\t\t\t\t\t\t\t\t\t\tindex.toString()\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\t\t\t\ttitleField={ titleField }\n\t\t\t\t\t\t\t\t\t\tmediaField={ mediaField }\n\t\t\t\t\t\t\t\t\t\tdescriptionField={ descriptionField }\n\t\t\t\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\t\t\t\t\t\t\tonClickItem={ onClickItem }\n\t\t\t\t\t\t\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\t\t\t\t\t\t\tisItemClickable={ isItemClickable }\n\t\t\t\t\t\t\t\t\t\tisActionsColumnSticky={\n\t\t\t\t\t\t\t\t\t\t\t! isHorizontalScrollEnd\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) ) }\n\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t) : (\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t{ hasData &&\n\t\t\t\t\t\t\tdata.map( ( item, index ) => (\n\t\t\t\t\t\t\t\t<TableRow\n\t\t\t\t\t\t\t\t\tkey={ getItemId( item ) }\n\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\tlevel={\n\t\t\t\t\t\t\t\t\t\tview.showLevels &&\n\t\t\t\t\t\t\t\t\t\ttypeof getItemLevel === 'function'\n\t\t\t\t\t\t\t\t\t\t\t? getItemLevel( item )\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\thasBulkActions={ hasBulkActions }\n\t\t\t\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\t\t\t\tid={ getItemId( item ) || index.toString() }\n\t\t\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\t\t\ttitleField={ titleField }\n\t\t\t\t\t\t\t\t\tmediaField={ mediaField }\n\t\t\t\t\t\t\t\t\tdescriptionField={ descriptionField }\n\t\t\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\t\t\t\t\t\tonClickItem={ onClickItem }\n\t\t\t\t\t\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\t\t\t\t\t\tisItemClickable={ isItemClickable }\n\t\t\t\t\t\t\t\t\tisActionsColumnSticky={\n\t\t\t\t\t\t\t\t\t\t! isHorizontalScrollEnd\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tposinset={\n\t\t\t\t\t\t\t\t\t\tisInfiniteScroll ? index + 1 : undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t</tbody>\n\t\t\t\t) }\n\t\t\t</table>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( {\n\t\t\t\t\t'dataviews-loading': isLoading,\n\t\t\t\t\t'dataviews-no-results': ! hasData && ! isLoading,\n\t\t\t\t} ) }\n\t\t\t\tid={ tableNoticeId }\n\t\t\t>\n\t\t\t\t{ ! hasData && <p>{ isLoading ? <Spinner /> : empty }</p> }\n\t\t\t\t{ hasData && isLoading && (\n\t\t\t\t\t<p className=\"dataviews-loading-more\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default ViewTable;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAOA,IAAAI,SAAA,GAAAJ,OAAA;AAKA,IAAAK,iBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,2BAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,qBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,qBAAA,GAAAT,OAAA;AAYA,IAAAU,iBAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,cAAA,GAAAZ,s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BAAmB;UACvCF,WAAW,EAAGA,WAAa;UAC3BC,cAAc,EAAGA,cAAgB;UACjCF,eAAe,EAAGA,eAAiB;UACnCI,qBAAqB,EACpB,CAAEyE,qBACF;UACDxE,QAAQ,EACP+F,gBAAgB,GAAGF,KAAK,GAAG,CAAC,GAAGjE;QAC/B,GA3BKlC,SAAS,CAAEtB,IAAK,CA4BtB,CACA;MAAC,CACE,CACP;IAAA,CACK,CAAC,eACR,IAAAF,WAAA,CAAAoD,IAAA;MACC1C,SAAS,EAAG,IAAAC,aAAI,EAAE;QACjB,mBAAmB,EAAE2E,SAAS;QAC9B,sBAAsB,EAAE,CAAEyB,OAAO,IAAI,CAAEzB;MACxC,CAAE,CAAG;MACL7E,EAAE,EAAG2F,aAAe;MAAAvF,QAAA,GAElB,CAAEkG,OAAO,iBAAI,IAAA/G,WAAA,CAAAY,GAAA;QAAAC,QAAA,EAAKyE,SAAS,gBAAG,IAAAtF,WAAA,CAAAY,GAAA,EAACvB,WAAA,CAAAiK,OAAO,IAAE,CAAC,GAAG7D;MAAK,CAAK,CAAC,EACvDsB,OAAO,IAAIzB,SAAS,iBACrB,IAAAtF,WAAA,CAAAY,GAAA;QAAGF,SAAS,EAAC,wBAAwB;QAAAG,QAAA,eACpC,IAAAb,WAAA,CAAAY,GAAA,EAACvB,WAAA,CAAAiK,OAAO,IAAE;MAAC,CACT,CACH;IAAA,CACG,CAAC;EAAA,CACL,CAAC;AAEL;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAlF,OAAA,GAEca,SAAS","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_constants","sort","valueA","valueB","direction","arrA","Array","isArray","arrB","length","joinedA","join","joinedB","localeCompare","render","item","field","value","getValue","arrayFieldType","isValid","custom","undefined","includes","__","every","v","elements","validValues","map","f","Edit","enableSorting","filterBy","defaultOperators","OPERATOR_IS_ANY","OPERATOR_IS_NONE","validOperators","OPERATOR_IS_ALL","OPERATOR_IS_NOT_ALL","_default","exports","default"],"sources":["@wordpress/dataviews/src/field-types/array.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tDataViewRenderFieldProps,\n\tSortDirection,\n\tFieldTypeDefinition,\n\tNormalizedField,\n} from '../types';\nimport {\n\tOPERATOR_IS_ALL,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tOPERATOR_IS_NOT_ALL,\n} from '../constants';\n\n// Sort arrays by length, then alphabetically by joined string\nfunction sort( valueA: any, valueB: any, direction: SortDirection ) {\n\tconst arrA = Array.isArray( valueA ) ? valueA : [];\n\tconst arrB = Array.isArray( valueB ) ? valueB : [];\n\tif ( arrA.length !== arrB.length ) {\n\t\treturn direction === 'asc'\n\t\t\t? arrA.length - arrB.length\n\t\t\t: arrB.length - arrA.length;\n\t}\n\n\tconst joinedA = arrA.join( ',' );\n\tconst joinedB = arrB.join( ',' );\n\treturn direction === 'asc'\n\t\t? joinedA.localeCompare( joinedB )\n\t\t: joinedB.localeCompare( joinedA );\n}\n\nfunction render( { item, field }: DataViewRenderFieldProps< any > ) {\n\tconst value = field.getValue( { item } ) || [];\n\treturn value.join( ', ' );\n}\n\nconst arrayFieldType: FieldTypeDefinition< any > = {\n\tsort,\n\tisValid: {\n\t\tcustom: ( item: any, field: NormalizedField< any > ) => {\n\t\t\tconst value = field.getValue( { item } );\n\n\t\t\tif (\n\t\t\t\t! [ undefined, '', null ].includes( value ) &&\n\t\t\t\t! Array.isArray( value )\n\t\t\t) {\n\t\t\t\treturn __( 'Value must be an array.' );\n\t\t\t}\n\n\t\t\t// Only allow strings for now. Can be extended to other types in the future.\n\t\t\tif ( ! value.every( ( v: any ) => typeof v === 'string' ) ) {\n\t\t\t\treturn __( 'Every value must be a string.' );\n\t\t\t}\n\n\t\t\tif ( field?.elements ) {\n\t\t\t\tconst validValues = field.elements.map( ( f ) => f.value );\n\t\t\t\tif (\n\t\t\t\t\t! value.every( ( v: any ) => validValues.includes( v ) )\n\t\t\t\t) {\n\t\t\t\t\treturn __( 'Value must be one of the elements.' );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n\tEdit:
|
|
1
|
+
{"version":3,"names":["_i18n","require","_constants","sort","valueA","valueB","direction","arrA","Array","isArray","arrB","length","joinedA","join","joinedB","localeCompare","render","item","field","value","getValue","arrayFieldType","isValid","custom","undefined","includes","__","every","v","elements","validValues","map","f","Edit","enableSorting","filterBy","defaultOperators","OPERATOR_IS_ANY","OPERATOR_IS_NONE","validOperators","OPERATOR_IS_ALL","OPERATOR_IS_NOT_ALL","_default","exports","default"],"sources":["@wordpress/dataviews/src/field-types/array.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tDataViewRenderFieldProps,\n\tSortDirection,\n\tFieldTypeDefinition,\n\tNormalizedField,\n} from '../types';\nimport {\n\tOPERATOR_IS_ALL,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tOPERATOR_IS_NOT_ALL,\n} from '../constants';\n\n// Sort arrays by length, then alphabetically by joined string\nfunction sort( valueA: any, valueB: any, direction: SortDirection ) {\n\tconst arrA = Array.isArray( valueA ) ? valueA : [];\n\tconst arrB = Array.isArray( valueB ) ? valueB : [];\n\tif ( arrA.length !== arrB.length ) {\n\t\treturn direction === 'asc'\n\t\t\t? arrA.length - arrB.length\n\t\t\t: arrB.length - arrA.length;\n\t}\n\n\tconst joinedA = arrA.join( ',' );\n\tconst joinedB = arrB.join( ',' );\n\treturn direction === 'asc'\n\t\t? joinedA.localeCompare( joinedB )\n\t\t: joinedB.localeCompare( joinedA );\n}\n\nfunction render( { item, field }: DataViewRenderFieldProps< any > ) {\n\tconst value = field.getValue( { item } ) || [];\n\treturn value.join( ', ' );\n}\n\nconst arrayFieldType: FieldTypeDefinition< any > = {\n\tsort,\n\tisValid: {\n\t\tcustom: ( item: any, field: NormalizedField< any > ) => {\n\t\t\tconst value = field.getValue( { item } );\n\n\t\t\tif (\n\t\t\t\t! [ undefined, '', null ].includes( value ) &&\n\t\t\t\t! Array.isArray( value )\n\t\t\t) {\n\t\t\t\treturn __( 'Value must be an array.' );\n\t\t\t}\n\n\t\t\t// Only allow strings for now. Can be extended to other types in the future.\n\t\t\tif ( ! value.every( ( v: any ) => typeof v === 'string' ) ) {\n\t\t\t\treturn __( 'Every value must be a string.' );\n\t\t\t}\n\n\t\t\tif ( field?.elements ) {\n\t\t\t\tconst validValues = field.elements.map( ( f ) => f.value );\n\t\t\t\tif (\n\t\t\t\t\t! value.every( ( v: any ) => validValues.includes( v ) )\n\t\t\t\t) {\n\t\t\t\t\treturn __( 'Value must be one of the elements.' );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t},\n\tEdit: 'array', // Use array control\n\trender,\n\tenableSorting: true,\n\tfilterBy: {\n\t\tdefaultOperators: [ OPERATOR_IS_ANY, OPERATOR_IS_NONE ],\n\t\tvalidOperators: [\n\t\t\tOPERATOR_IS_ANY,\n\t\t\tOPERATOR_IS_NONE,\n\t\t\tOPERATOR_IS_ALL,\n\t\t\tOPERATOR_IS_NOT_ALL,\n\t\t],\n\t},\n};\n\nexport default arrayFieldType;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAWA,IAAAC,UAAA,GAAAD,OAAA;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA,SAASE,IAAIA,CAAEC,MAAW,EAAEC,MAAW,EAAEC,SAAwB,EAAG;EACnE,MAAMC,IAAI,GAAGC,KAAK,CAACC,OAAO,CAAEL,MAAO,CAAC,GAAGA,MAAM,GAAG,EAAE;EAClD,MAAMM,IAAI,GAAGF,KAAK,CAACC,OAAO,CAAEJ,MAAO,CAAC,GAAGA,MAAM,GAAG,EAAE;EAClD,IAAKE,IAAI,CAACI,MAAM,K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AMC,WAAW,GAAGZ,KAAK,CAACW,QAAQ,CAACE,GAAG,CAAIC,CAAC,IAAMA,CAAC,CAACb,KAAM,CAAC;QAC1D,IACC,CAAEA,KAAK,CAACQ,KAAK,CAAIC,CAAM,IAAME,WAAW,CAACL,QAAQ,CAAEG,CAAE,CAAE,CAAC,EACvD;UACD,OAAO,IAAAF,QAAE,EAAE,oCAAqC,CAAC;QAClD;MACD;MACA,OAAO,IAAI;IACZ;EACD,CAAC;EACDO,IAAI,EAAE,OAAO;EAAE;EACfjB,MAAM;EACNkB,aAAa,EAAE,IAAI;EACnBC,QAAQ,EAAE;IACTC,gBAAgB,EAAE,CAAEC,0BAAe,EAAEC,2BAAgB,CAAE;IACvDC,cAAc,EAAE,CACfF,0BAAe,EACfC,2BAAgB,EAChBE,0BAAe,EACfC,8BAAmB;EAErB;AACD,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEavB,cAAc","ignoreList":[]}
|
|
@@ -3,33 +3,72 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.DEFAULT_LAYOUT = void 0;
|
|
6
7
|
exports.default = normalizeFormFields;
|
|
8
|
+
exports.normalizeLayout = normalizeLayout;
|
|
7
9
|
/**
|
|
8
10
|
* Internal dependencies
|
|
9
11
|
*/
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const DEFAULT_LAYOUT = exports.DEFAULT_LAYOUT = {
|
|
14
|
+
type: 'regular',
|
|
15
|
+
labelPosition: 'top'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Normalizes a layout configuration based on its type.
|
|
20
|
+
*
|
|
21
|
+
* @param layout The layout object to normalize.
|
|
22
|
+
* @return The normalized layout object.
|
|
23
|
+
*/
|
|
24
|
+
function normalizeLayout(layout) {
|
|
25
|
+
let normalizedLayout = DEFAULT_LAYOUT;
|
|
26
|
+
if (layout?.type === 'regular') {
|
|
27
|
+
var _layout$labelPosition;
|
|
28
|
+
normalizedLayout = {
|
|
29
|
+
type: 'regular',
|
|
30
|
+
labelPosition: (_layout$labelPosition = layout?.labelPosition) !== null && _layout$labelPosition !== void 0 ? _layout$labelPosition : 'top'
|
|
31
|
+
};
|
|
32
|
+
} else if (layout?.type === 'panel') {
|
|
33
|
+
var _layout$labelPosition2, _layout$openAs;
|
|
34
|
+
normalizedLayout = {
|
|
35
|
+
type: 'panel',
|
|
36
|
+
labelPosition: (_layout$labelPosition2 = layout?.labelPosition) !== null && _layout$labelPosition2 !== void 0 ? _layout$labelPosition2 : 'side',
|
|
37
|
+
openAs: (_layout$openAs = layout?.openAs) !== null && _layout$openAs !== void 0 ? _layout$openAs : 'dropdown'
|
|
38
|
+
};
|
|
39
|
+
} else if (layout?.type === 'card') {
|
|
40
|
+
if (layout.withHeader === false) {
|
|
41
|
+
// Don't let isOpened be false if withHeader is false.
|
|
42
|
+
// Otherwise, the card will not be visible.
|
|
43
|
+
normalizedLayout = {
|
|
44
|
+
type: 'card',
|
|
45
|
+
withHeader: false,
|
|
46
|
+
isOpened: true
|
|
47
|
+
};
|
|
48
|
+
} else {
|
|
49
|
+
normalizedLayout = {
|
|
50
|
+
type: 'card',
|
|
51
|
+
withHeader: true,
|
|
52
|
+
isOpened: typeof layout.isOpened === 'boolean' ? layout.isOpened : true
|
|
53
|
+
};
|
|
54
|
+
}
|
|
16
55
|
}
|
|
17
|
-
|
|
56
|
+
return normalizedLayout;
|
|
57
|
+
}
|
|
58
|
+
function normalizeFormFields(form) {
|
|
59
|
+
var _form$fields;
|
|
60
|
+
const formLayout = normalizeLayout(form?.layout);
|
|
18
61
|
return ((_form$fields = form.fields) !== null && _form$fields !== void 0 ? _form$fields : []).map(field => {
|
|
19
|
-
var _field$layout, _field$labelPosition;
|
|
20
62
|
if (typeof field === 'string') {
|
|
21
63
|
return {
|
|
22
64
|
id: field,
|
|
23
|
-
layout
|
|
24
|
-
labelPosition
|
|
65
|
+
layout: formLayout
|
|
25
66
|
};
|
|
26
67
|
}
|
|
27
|
-
const fieldLayout =
|
|
28
|
-
const fieldLabelPosition = (_field$labelPosition = field.labelPosition) !== null && _field$labelPosition !== void 0 ? _field$labelPosition : fieldLayout === 'regular' ? 'top' : 'side';
|
|
68
|
+
const fieldLayout = field.layout ? normalizeLayout(field.layout) : formLayout;
|
|
29
69
|
return {
|
|
30
70
|
...field,
|
|
31
|
-
layout: fieldLayout
|
|
32
|
-
labelPosition: fieldLabelPosition
|
|
71
|
+
layout: fieldLayout
|
|
33
72
|
};
|
|
34
73
|
});
|
|
35
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DEFAULT_LAYOUT","exports","type","labelPosition","normalizeLayout","layout","normalizedLayout","_layout$labelPosition","_layout$labelPosition2","_layout$openAs","openAs","withHeader","isOpened","normalizeFormFields","form","_form$fields","formLayout","fields","map","field","id","fieldLayout"],"sources":["@wordpress/dataviews/src/normalize-form-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tForm,\n\tLayout,\n\tNormalizedLayout,\n\tNormalizedRegularLayout,\n\tNormalizedPanelLayout,\n\tNormalizedCardLayout,\n} from './types';\n\ninterface NormalizedFormField {\n\tid: string;\n\tlayout: Layout;\n}\n\nexport const DEFAULT_LAYOUT: NormalizedLayout = {\n\ttype: 'regular',\n\tlabelPosition: 'top',\n};\n\n/**\n * Normalizes a layout configuration based on its type.\n *\n * @param layout The layout object to normalize.\n * @return The normalized layout object.\n */\nexport function normalizeLayout( layout?: Layout ): NormalizedLayout {\n\tlet normalizedLayout = DEFAULT_LAYOUT;\n\n\tif ( layout?.type === 'regular' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'regular',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'top',\n\t\t} satisfies NormalizedRegularLayout;\n\t} else if ( layout?.type === 'panel' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'panel',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'side',\n\t\t\topenAs: layout?.openAs ?? 'dropdown',\n\t\t} satisfies NormalizedPanelLayout;\n\t} else if ( layout?.type === 'card' ) {\n\t\tif ( layout.withHeader === false ) {\n\t\t\t// Don't let isOpened be false if withHeader is false.\n\t\t\t// Otherwise, the card will not be visible.\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: false,\n\t\t\t\tisOpened: true,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t} else {\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: true,\n\t\t\t\tisOpened:\n\t\t\t\t\ttypeof layout.isOpened === 'boolean'\n\t\t\t\t\t\t? layout.isOpened\n\t\t\t\t\t\t: true,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t}\n\t}\n\n\treturn normalizedLayout;\n}\n\nexport default function normalizeFormFields(\n\tform: Form\n): NormalizedFormField[] {\n\tconst formLayout = normalizeLayout( form?.layout );\n\n\treturn ( form.fields ?? [] ).map( ( field ) => {\n\t\tif ( typeof field === 'string' ) {\n\t\t\treturn {\n\t\t\t\tid: field,\n\t\t\t\tlayout: formLayout,\n\t\t\t};\n\t\t}\n\n\t\tconst fieldLayout = field.layout\n\t\t\t? normalizeLayout( field.layout )\n\t\t\t: formLayout;\n\t\treturn {\n\t\t\t...field,\n\t\t\tlayout: fieldLayout,\n\t\t};\n\t} );\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;;AAeO,MAAMA,cAAgC,GAAAC,OAAA,CAAAD,cAAA,GAAG;EAC/CE,IAAI,EAAE,SAAS;EACfC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAAEC,MAAe,EAAqB;EACpE,IAAIC,gBAAgB,GAAGN,cAAc;EAErC,IAAKK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AIC,KAAK,IAAM;IAC9C,IAAK,OAAOA,KAAK,KAAK,QAAQ,EAAG;MAChC,OAAO;QACNC,EAAE,EAAED,KAAK;QACTd,MAAM,EAAEW;MACT,CAAC;IACF;IAEA,MAAMK,WAAW,GAAGF,KAAK,CAACd,MAAM,GAC7BD,eAAe,CAAEe,KAAK,CAACd,MAAO,CAAC,GAC/BW,UAAU;IACb,OAAO;MACN,GAAGG,KAAK;MACRd,MAAM,EAAEgB;IACT,CAAC;EACF,CAAE,CAAC;AACJ","ignoreList":[]}
|
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tReactElement,\n\tReactNode,\n\tComponentType,\n\tComponentProps,\n} from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\n/**\n * WordPress dependencies\n */\nimport type { useFocusOnMount } from '@wordpress/compose';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\nexport interface 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\nexport interface NormalizedFilterByConfig {\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\ninterface FilterConfigForType {\n\t/**\n\t * What operators are used by default.\n\t */\n\tdefaultOperators: Operator[];\n\n\t/**\n\t * What operators are supported by the field.\n\t */\n\tvalidOperators: Operator[];\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll'\n\t| 'lessThan'\n\t| 'greaterThan'\n\t| 'lessThanOrEqual'\n\t| 'greaterThanOrEqual'\n\t| 'before'\n\t| 'after'\n\t| 'beforeInc'\n\t| 'afterInc'\n\t| 'contains'\n\t| 'notContains'\n\t| 'startsWith'\n\t| 'between'\n\t| 'on'\n\t| 'notOn'\n\t| 'inThePast'\n\t| 'over';\n\nexport type FieldType =\n\t| 'text'\n\t| 'integer'\n\t| 'datetime'\n\t| 'date'\n\t| 'media'\n\t| 'boolean'\n\t| 'email'\n\t| 'array';\n\n/**\n * An abstract interface for Field based on the field type.\n */\nexport type FieldTypeDefinition< Item > = {\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid: Rules< Item >;\n\n\t/**\n\t * Callback used to render an edit control for the field or control name.\n\t */\n\tEdit: ComponentType< DataFormControlProps< Item > > | string | null;\n\n\t/**\n\t * Callback used to render the field.\n\t */\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * The filter config for the field.\n\t */\n\tfilterBy: FilterConfigForType | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting: boolean;\n};\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\tcustom?: ( item: Item, field: NormalizedField< Item > ) => null | string;\n};\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\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\tlabel?: string;\n\n\t/**\n\t * The header of the field. Defaults to the label.\n\t * It allows the usage of a React Element to render the field labels.\n\t */\n\theader?: string | ReactElement;\n\n\t/**\n\t * A description of the field.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string;\n\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort?: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid?: Rules< Item >;\n\n\t/**\n\t * Callback used to decide if a field should be displayed.\n\t */\n\tisVisible?: ( item: Item ) => boolean;\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 | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\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\nexport type NormalizedField< Item > = Omit< Field< Item >, 'Edit' > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\tEdit: ComponentType< DataFormControlProps< Item > > | null;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: Rules< Item >;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n\tfilterBy: NormalizedFilterByConfig | false;\n\treadOnly: boolean;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: Record< string, any > ) => void;\n\thideLabelFromVision?: boolean;\n\t/**\n\t * The currently selected filter operator for this field.\n\t *\n\t * Used by DataViews filters to determine which control to render based on the operator type.\n\t */\n\toperator?: Operator;\n};\n\nexport type DataViewRenderFieldProps< Item > = {\n\titem: Item;\n\tfield: NormalizedField< Item >;\n\tconfig?: {\n\t\tsizes: string;\n\t};\n};\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\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked?: boolean;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\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 * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n\n\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked: boolean;\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 fields to render\n\t */\n\tfields?: string[];\n\n\t/**\n\t * Title field\n\t */\n\ttitleField?: string;\n\n\t/**\n\t * Media field\n\t */\n\tmediaField?: string;\n\n\t/**\n\t * Description field\n\t */\n\tdescriptionField?: string;\n\n\t/**\n\t * Whether to show the title\n\t */\n\tshowTitle?: boolean;\n\n\t/**\n\t * Whether to show the media\n\t */\n\tshowMedia?: boolean;\n\n\t/**\n\t * Whether to show the description\n\t */\n\tshowDescription?: boolean;\n\n\t/**\n\t * Whether to show the hierarchical levels.\n\t */\n\tshowLevels?: boolean;\n\n\t/**\n\t * The field to group by.\n\t */\n\tgroupByField?: string;\n}\n\nexport interface ColumnStyle {\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 * The alignment of the field column, defaults to left.\n\t */\n\talign?: 'start' | 'center' | 'end';\n}\n\nexport type Density = 'compact' | 'balanced' | 'comfortable';\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\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 * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => 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\t/**\n\t * The context in which the action is visible.\n\t * This is only a \"meta\" information for now.\n\t */\n\tcontext?: 'list' | 'single';\n}\n\nexport interface RenderModalProps< Item > {\n\titems: Item[];\n\tcloseModal?: () => void;\n\tonActionPerformed?: ( items: Item[] ) => void;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: RenderModalProps< Item > ) => 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\t/**\n\t * The size of the modal.\n\t *\n\t * @default 'medium'\n\t */\n\tmodalSize?: 'small' | 'medium' | 'large' | 'fill';\n\n\t/**\n\t * The focus on mount property of the modal.\n\t */\n\tmodalFocusOnMount?:\n\t\t| Parameters< typeof useFocusOnMount >[ 0 ]\n\t\t| 'firstContentElement';\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tclassName?: string;\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable: ( item: Item ) => boolean;\n\tview: View;\n\tempty: ReactNode;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n\nexport type SimpleFormField = {\n\tid: string;\n\tlayout?: 'regular' | 'panel';\n\tlabelPosition?: 'side' | 'top' | 'none';\n};\n\nexport type CombinedFormField = {\n\tid: string;\n\tlabel?: string;\n\tlayout?: 'regular' | 'panel';\n\tlabelPosition?: 'side' | 'top' | 'none';\n\tchildren: Array< FormField | string >;\n};\n\nexport type FormField = SimpleFormField | CombinedFormField;\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\ttype?: 'regular' | 'panel';\n\tfields?: Array< FormField | string >;\n\tlabelPosition?: 'side' | 'top' | 'none';\n};\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: ( value: Record< string, any > ) => void;\n}\n\nexport interface FieldLayoutProps< Item > {\n\tdata: Item;\n\tfield: FormField;\n\tonChange: ( value: any ) => void;\n\thideLabelFromVision?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tReactElement,\n\tReactNode,\n\tComponentType,\n\tComponentProps,\n} from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\n/**\n * WordPress dependencies\n */\nimport type { useFocusOnMount } from '@wordpress/compose';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\nexport interface 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\nexport interface NormalizedFilterByConfig {\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\ninterface FilterConfigForType {\n\t/**\n\t * What operators are used by default.\n\t */\n\tdefaultOperators: Operator[];\n\n\t/**\n\t * What operators are supported by the field.\n\t */\n\tvalidOperators: Operator[];\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll'\n\t| 'lessThan'\n\t| 'greaterThan'\n\t| 'lessThanOrEqual'\n\t| 'greaterThanOrEqual'\n\t| 'before'\n\t| 'after'\n\t| 'beforeInc'\n\t| 'afterInc'\n\t| 'contains'\n\t| 'notContains'\n\t| 'startsWith'\n\t| 'between'\n\t| 'on'\n\t| 'notOn'\n\t| 'inThePast'\n\t| 'over';\n\nexport type FieldType =\n\t| 'text'\n\t| 'integer'\n\t| 'datetime'\n\t| 'date'\n\t| 'media'\n\t| 'boolean'\n\t| 'email'\n\t| 'array';\n\n/**\n * An abstract interface for Field based on the field type.\n */\nexport type FieldTypeDefinition< Item > = {\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid: Rules< Item >;\n\n\t/**\n\t * Callback used to render an edit control for the field or control name.\n\t */\n\tEdit: ComponentType< DataFormControlProps< Item > > | string | null;\n\n\t/**\n\t * Callback used to render the field.\n\t */\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * The filter config for the field.\n\t */\n\tfilterBy: FilterConfigForType | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting: boolean;\n};\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\tcustom?: ( item: Item, field: NormalizedField< Item > ) => null | string;\n};\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\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\tlabel?: string;\n\n\t/**\n\t * The header of the field. Defaults to the label.\n\t * It allows the usage of a React Element to render the field labels.\n\t */\n\theader?: string | ReactElement;\n\n\t/**\n\t * A description of the field.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string;\n\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort?: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid?: Rules< Item >;\n\n\t/**\n\t * Callback used to decide if a field should be displayed.\n\t */\n\tisVisible?: ( item: Item ) => boolean;\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 | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\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\nexport type NormalizedField< Item > = Omit< Field< Item >, 'Edit' > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\tEdit: ComponentType< DataFormControlProps< Item > > | null;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: Rules< Item >;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n\tfilterBy: NormalizedFilterByConfig | false;\n\treadOnly: boolean;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: Record< string, any > ) => void;\n\thideLabelFromVision?: boolean;\n\t/**\n\t * The currently selected filter operator for this field.\n\t *\n\t * Used by DataViews filters to determine which control to render based on the operator type.\n\t */\n\toperator?: Operator;\n};\n\nexport type DataViewRenderFieldProps< Item > = {\n\titem: Item;\n\tfield: NormalizedField< Item >;\n\tconfig?: {\n\t\tsizes: string;\n\t};\n};\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\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked?: boolean;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\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 * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n\n\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked: boolean;\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 fields to render\n\t */\n\tfields?: string[];\n\n\t/**\n\t * Title field\n\t */\n\ttitleField?: string;\n\n\t/**\n\t * Media field\n\t */\n\tmediaField?: string;\n\n\t/**\n\t * Description field\n\t */\n\tdescriptionField?: string;\n\n\t/**\n\t * Whether to show the title\n\t */\n\tshowTitle?: boolean;\n\n\t/**\n\t * Whether to show the media\n\t */\n\tshowMedia?: boolean;\n\n\t/**\n\t * Whether to show the description\n\t */\n\tshowDescription?: boolean;\n\n\t/**\n\t * Whether to show the hierarchical levels.\n\t */\n\tshowLevels?: boolean;\n\n\t/**\n\t * The field to group by.\n\t */\n\tgroupByField?: string;\n\n\t/**\n\t * Whether infinite scroll is enabled.\n\t */\n\tinfiniteScrollEnabled?: boolean;\n}\n\nexport interface ColumnStyle {\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 * The alignment of the field column, defaults to left.\n\t */\n\talign?: 'start' | 'center' | 'end';\n}\n\nexport type Density = 'compact' | 'balanced' | 'comfortable';\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\n\t\t/**\n\t\t * Whether the view allows column moving.\n\t\t */\n\t\tenableMoving?: boolean;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\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 * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => 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\t/**\n\t * The context in which the action is visible.\n\t * This is only a \"meta\" information for now.\n\t */\n\tcontext?: 'list' | 'single';\n}\n\nexport interface RenderModalProps< Item > {\n\titems: Item[];\n\tcloseModal?: () => void;\n\tonActionPerformed?: ( items: Item[] ) => void;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: RenderModalProps< Item > ) => 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\t/**\n\t * The size of the modal.\n\t *\n\t * @default 'medium'\n\t */\n\tmodalSize?: 'small' | 'medium' | 'large' | 'fill';\n\n\t/**\n\t * The focus on mount property of the modal.\n\t */\n\tmodalFocusOnMount?:\n\t\t| Parameters< typeof useFocusOnMount >[ 0 ]\n\t\t| 'firstContentElement';\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tclassName?: string;\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable: ( item: Item ) => boolean;\n\tview: View;\n\tempty: ReactNode;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n\n/**\n * DataForm layouts.\n */\nexport type LayoutType = 'regular' | 'panel' | 'card';\nexport type LabelPosition = 'top' | 'side' | 'none';\n\nexport type RegularLayout = {\n\ttype: 'regular';\n\tlabelPosition?: LabelPosition;\n};\nexport type NormalizedRegularLayout = {\n\ttype: 'regular';\n\tlabelPosition: LabelPosition;\n};\n\nexport type PanelLayout = {\n\ttype: 'panel';\n\tlabelPosition?: LabelPosition;\n\topenAs?: 'dropdown' | 'modal';\n};\nexport type NormalizedPanelLayout = {\n\ttype: 'panel';\n\tlabelPosition: LabelPosition;\n\topenAs: 'dropdown' | 'modal';\n};\n\nexport type CardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened?: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader?: true | undefined;\n\t\t\tisOpened?: boolean;\n\t };\nexport type NormalizedCardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: true;\n\t\t\tisOpened: boolean;\n\t };\n\nexport type Layout = RegularLayout | PanelLayout | CardLayout;\nexport type NormalizedLayout =\n\t| NormalizedRegularLayout\n\t| NormalizedPanelLayout\n\t| NormalizedCardLayout;\n\nexport type SimpleFormField = {\n\tid: string;\n\tlayout?: Layout;\n};\n\nexport type CombinedFormField = {\n\tid: string;\n\tlabel?: string;\n\tlayout?: Layout;\n\tchildren: Array< FormField | string >;\n};\n\nexport type FormField = SimpleFormField | CombinedFormField;\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\tlayout?: Layout;\n\tfields?: Array< FormField | string >;\n};\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: ( value: Record< string, any > ) => void;\n}\n\nexport interface FieldLayoutProps< Item > {\n\tdata: Item;\n\tfield: FormField;\n\tonChange: ( value: any ) => void;\n\thideLabelFromVision?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
8
8
|
import { __experimentalHStack as HStack } from '@wordpress/components';
|
|
9
|
-
import { useContext, useMemo, useRef, useState
|
|
10
|
-
import { useResizeObserver } from '@wordpress/compose';
|
|
9
|
+
import { useContext, useEffect, useMemo, useRef, useState } from '@wordpress/element';
|
|
10
|
+
import { useResizeObserver, throttle } from '@wordpress/compose';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
@@ -31,7 +31,8 @@ function DefaultUI({
|
|
|
31
31
|
searchLabel = undefined
|
|
32
32
|
}) {
|
|
33
33
|
const {
|
|
34
|
-
isShowingFilter
|
|
34
|
+
isShowingFilter,
|
|
35
|
+
config
|
|
35
36
|
} = useContext(DataViewsContext);
|
|
36
37
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
37
38
|
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
@@ -46,13 +47,13 @@ function DefaultUI({
|
|
|
46
47
|
children: [search && /*#__PURE__*/_jsx(DataViewsSearch, {
|
|
47
48
|
label: searchLabel
|
|
48
49
|
}), /*#__PURE__*/_jsx(FiltersToggle, {})]
|
|
49
|
-
}), /*#__PURE__*/_jsxs(HStack, {
|
|
50
|
+
}), (config || header) && /*#__PURE__*/_jsxs(HStack, {
|
|
50
51
|
spacing: 1,
|
|
51
52
|
expanded: false,
|
|
52
53
|
style: {
|
|
53
54
|
flexShrink: 0
|
|
54
55
|
},
|
|
55
|
-
children: [/*#__PURE__*/_jsx(DataViewsViewConfig, {}), header]
|
|
56
|
+
children: ["config && ", /*#__PURE__*/_jsx(DataViewsViewConfig, {}), header]
|
|
56
57
|
})]
|
|
57
58
|
}), isShowingFilter && /*#__PURE__*/_jsx(DataViewsFilters, {
|
|
58
59
|
className: "dataviews-filters__container"
|
|
@@ -79,9 +80,14 @@ function DataViews({
|
|
|
79
80
|
isItemClickable = defaultIsItemClickable,
|
|
80
81
|
header,
|
|
81
82
|
children,
|
|
82
|
-
|
|
83
|
+
config = {
|
|
84
|
+
perPageSizes: [10, 20, 50, 100]
|
|
85
|
+
},
|
|
83
86
|
empty
|
|
84
87
|
}) {
|
|
88
|
+
const {
|
|
89
|
+
infiniteScrollHandler
|
|
90
|
+
} = paginationInfo;
|
|
85
91
|
const containerRef = useRef(null);
|
|
86
92
|
const [containerWidth, setContainerWidth] = useState(0);
|
|
87
93
|
const resizeObserverRef = useResizeObserver(resizeObserverEntries => {
|
|
@@ -114,6 +120,31 @@ function DataViews({
|
|
|
114
120
|
setIsShowingFilter(true);
|
|
115
121
|
}
|
|
116
122
|
}, [hasPrimaryOrLockedFilters, isShowingFilter]);
|
|
123
|
+
|
|
124
|
+
// Attach scroll event listener for infinite scroll
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!view.infiniteScrollEnabled || !containerRef.current) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const handleScroll = throttle(event => {
|
|
130
|
+
const target = event.target;
|
|
131
|
+
const scrollTop = target.scrollTop;
|
|
132
|
+
const scrollHeight = target.scrollHeight;
|
|
133
|
+
const clientHeight = target.clientHeight;
|
|
134
|
+
|
|
135
|
+
// Check if user has scrolled near the bottom
|
|
136
|
+
if (scrollTop + clientHeight >= scrollHeight - 100) {
|
|
137
|
+
infiniteScrollHandler?.();
|
|
138
|
+
}
|
|
139
|
+
}, 100); // Throttle to 100ms
|
|
140
|
+
|
|
141
|
+
const container = containerRef.current;
|
|
142
|
+
container.addEventListener('scroll', handleScroll);
|
|
143
|
+
return () => {
|
|
144
|
+
container.removeEventListener('scroll', handleScroll);
|
|
145
|
+
handleScroll.cancel(); // Cancel any pending throttled calls
|
|
146
|
+
};
|
|
147
|
+
}, [infiniteScrollHandler, view.infiniteScrollEnabled]);
|
|
117
148
|
return /*#__PURE__*/_jsx(DataViewsContext.Provider, {
|
|
118
149
|
value: {
|
|
119
150
|
view,
|
|
@@ -139,8 +170,9 @@ function DataViews({
|
|
|
139
170
|
filters,
|
|
140
171
|
isShowingFilter,
|
|
141
172
|
setIsShowingFilter,
|
|
142
|
-
|
|
143
|
-
empty
|
|
173
|
+
config,
|
|
174
|
+
empty,
|
|
175
|
+
hasInfiniteScrollHandler: !!infiniteScrollHandler
|
|
144
176
|
},
|
|
145
177
|
children: /*#__PURE__*/_jsx("div", {
|
|
146
178
|
className: "dataviews-wrapper",
|