@wordpress/dataviews 13.1.1-next.v.202603102151.0 → 14.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 +18 -1
- package/README.md +19 -3
- package/build/components/dataform-controls/datetime.cjs +8 -4
- package/build/components/dataform-controls/datetime.cjs.map +2 -2
- package/build/components/dataform-layouts/card/index.cjs +132 -128
- package/build/components/dataform-layouts/card/index.cjs.map +3 -3
- package/build/components/dataviews-bulk-actions/index.cjs +28 -5
- package/build/components/dataviews-bulk-actions/index.cjs.map +2 -2
- package/build/components/dataviews-context/index.cjs +2 -2
- package/build/components/dataviews-context/index.cjs.map +2 -2
- package/build/components/dataviews-footer/index.cjs +2 -3
- package/build/components/dataviews-footer/index.cjs.map +2 -2
- package/build/components/dataviews-layout/index.cjs +12 -3
- package/build/components/dataviews-layout/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/grid/composite-grid.cjs +378 -245
- package/build/components/dataviews-layouts/grid/composite-grid.cjs.map +2 -2
- package/build/components/dataviews-layouts/index.cjs +3 -3
- package/build/components/dataviews-layouts/index.cjs.map +3 -3
- package/build/components/dataviews-layouts/picker-grid/index.cjs +76 -32
- package/build/components/dataviews-layouts/picker-grid/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/picker-table/index.cjs +34 -22
- package/build/components/dataviews-layouts/picker-table/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/table/index.cjs +97 -88
- package/build/components/dataviews-layouts/table/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/table/{use-is-horizontal-scroll-end.cjs → use-scroll-state.cjs} +29 -33
- package/build/components/dataviews-layouts/table/use-scroll-state.cjs.map +7 -0
- package/build/components/dataviews-layouts/utils/density-picker.cjs.map +2 -2
- package/build/components/dataviews-layouts/utils/grid-config-options.cjs +45 -0
- package/build/components/dataviews-layouts/utils/grid-config-options.cjs.map +7 -0
- package/build/components/dataviews-layouts/utils/use-infinite-scroll.cjs +62 -0
- package/build/components/dataviews-layouts/utils/use-infinite-scroll.cjs.map +7 -0
- package/build/components/dataviews-picker-footer/index.cjs +23 -4
- package/build/components/dataviews-picker-footer/index.cjs.map +2 -2
- package/build/components/dataviews-search/index.cjs +2 -1
- package/build/components/dataviews-search/index.cjs.map +2 -2
- package/build/components/dataviews-selection-checkbox/index.cjs +3 -2
- package/build/components/dataviews-selection-checkbox/index.cjs.map +2 -2
- package/build/components/dataviews-view-config/index.cjs +0 -2
- package/build/components/dataviews-view-config/index.cjs.map +3 -3
- package/build/components/dataviews-view-config/infinite-scroll-toggle.cjs +0 -3
- package/build/components/dataviews-view-config/infinite-scroll-toggle.cjs.map +2 -2
- package/build/dataviews/index.cjs +38 -34
- package/build/dataviews/index.cjs.map +3 -3
- package/build/dataviews-picker/index.cjs +26 -25
- package/build/dataviews-picker/index.cjs.map +3 -3
- package/build/hooks/index.cjs +11 -2
- package/build/hooks/index.cjs.map +2 -2
- package/build/hooks/use-data.cjs +146 -9
- package/build/hooks/use-data.cjs.map +2 -2
- package/build/hooks/use-infinite-scroll.cjs +208 -0
- package/build/hooks/use-infinite-scroll.cjs.map +7 -0
- package/build/hooks/use-selected-items.cjs +57 -0
- package/build/hooks/use-selected-items.cjs.map +7 -0
- package/build/types/dataviews.cjs.map +1 -1
- package/build/types/field-api.cjs.map +1 -1
- package/build/utils/filter-sort-and-paginate.cjs +5 -1
- package/build/utils/filter-sort-and-paginate.cjs.map +2 -2
- package/build/utils/get-footer-message.cjs +8 -8
- package/build/utils/get-footer-message.cjs.map +2 -2
- package/build-module/components/dataform-controls/datetime.mjs +8 -4
- package/build-module/components/dataform-controls/datetime.mjs.map +2 -2
- package/build-module/components/dataform-layouts/card/index.mjs +132 -133
- package/build-module/components/dataform-layouts/card/index.mjs.map +2 -2
- package/build-module/components/dataviews-bulk-actions/index.mjs +28 -5
- package/build-module/components/dataviews-bulk-actions/index.mjs.map +2 -2
- package/build-module/components/dataviews-context/index.mjs +2 -2
- package/build-module/components/dataviews-context/index.mjs.map +2 -2
- package/build-module/components/dataviews-footer/index.mjs +2 -3
- package/build-module/components/dataviews-footer/index.mjs.map +2 -2
- package/build-module/components/dataviews-layout/index.mjs +12 -3
- package/build-module/components/dataviews-layout/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/grid/composite-grid.mjs +387 -246
- package/build-module/components/dataviews-layouts/grid/composite-grid.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/index.mjs +3 -3
- package/build-module/components/dataviews-layouts/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/picker-grid/index.mjs +80 -33
- package/build-module/components/dataviews-layouts/picker-grid/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/picker-table/index.mjs +34 -22
- package/build-module/components/dataviews-layouts/picker-table/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/table/index.mjs +97 -88
- package/build-module/components/dataviews-layouts/table/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/table/use-scroll-state.mjs +46 -0
- package/build-module/components/dataviews-layouts/table/use-scroll-state.mjs.map +7 -0
- package/build-module/components/dataviews-layouts/utils/density-picker.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/utils/grid-config-options.mjs +14 -0
- package/build-module/components/dataviews-layouts/utils/grid-config-options.mjs.map +7 -0
- package/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs +26 -0
- package/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs.map +7 -0
- package/build-module/components/dataviews-picker-footer/index.mjs +23 -4
- package/build-module/components/dataviews-picker-footer/index.mjs.map +2 -2
- package/build-module/components/dataviews-search/index.mjs +2 -1
- package/build-module/components/dataviews-search/index.mjs.map +2 -2
- package/build-module/components/dataviews-selection-checkbox/index.mjs +3 -2
- package/build-module/components/dataviews-selection-checkbox/index.mjs.map +2 -2
- package/build-module/components/dataviews-view-config/index.mjs +0 -2
- package/build-module/components/dataviews-view-config/index.mjs.map +2 -2
- package/build-module/components/dataviews-view-config/infinite-scroll-toggle.mjs +0 -3
- package/build-module/components/dataviews-view-config/infinite-scroll-toggle.mjs.map +2 -2
- package/build-module/dataviews/index.mjs +46 -36
- package/build-module/dataviews/index.mjs.map +2 -2
- package/build-module/dataviews-picker/index.mjs +34 -27
- package/build-module/dataviews-picker/index.mjs.map +2 -2
- package/build-module/hooks/index.mjs +7 -1
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/use-data.mjs +147 -10
- package/build-module/hooks/use-data.mjs.map +2 -2
- package/build-module/hooks/use-infinite-scroll.mjs +188 -0
- package/build-module/hooks/use-infinite-scroll.mjs.map +7 -0
- package/build-module/hooks/use-selected-items.mjs +36 -0
- package/build-module/hooks/use-selected-items.mjs.map +7 -0
- package/build-module/utils/filter-sort-and-paginate.mjs +5 -1
- package/build-module/utils/filter-sort-and-paginate.mjs.map +2 -2
- package/build-module/utils/get-footer-message.mjs +8 -8
- package/build-module/utils/get-footer-message.mjs.map +2 -2
- package/build-style/style-rtl.css +107 -41
- package/build-style/style.css +107 -41
- package/build-types/components/dataform-controls/datetime.d.ts +1 -1
- package/build-types/components/dataform-controls/datetime.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/card/index.d.ts.map +1 -1
- package/build-types/components/dataviews-bulk-actions/index.d.ts +2 -1
- package/build-types/components/dataviews-bulk-actions/index.d.ts.map +1 -1
- package/build-types/components/dataviews-context/index.d.ts +1 -1
- package/build-types/components/dataviews-context/index.d.ts.map +1 -1
- package/build-types/components/dataviews-footer/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layout/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/grid/composite-grid.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/index.d.ts +3 -3
- package/build-types/components/dataviews-layouts/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/picker-grid/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/picker-table/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/table/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/table/use-scroll-state.d.ts +25 -0
- package/build-types/components/dataviews-layouts/table/use-scroll-state.d.ts.map +1 -0
- package/build-types/components/dataviews-layouts/utils/density-picker.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/utils/grid-config-options.d.ts +2 -0
- package/build-types/components/dataviews-layouts/utils/grid-config-options.d.ts.map +1 -0
- package/build-types/components/dataviews-layouts/utils/use-infinite-scroll.d.ts +22 -0
- package/build-types/components/dataviews-layouts/utils/use-infinite-scroll.d.ts.map +1 -0
- package/build-types/components/dataviews-picker-footer/index.d.ts.map +1 -1
- package/build-types/components/dataviews-search/index.d.ts.map +1 -1
- package/build-types/components/dataviews-selection-checkbox/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 +1 -1
- package/build-types/components/dataviews-view-config/infinite-scroll-toggle.d.ts.map +1 -1
- package/build-types/dataviews/index.d.ts +0 -1
- package/build-types/dataviews/index.d.ts.map +1 -1
- package/build-types/dataviews/stories/empty.d.ts +1 -2
- package/build-types/dataviews/stories/empty.d.ts.map +1 -1
- package/build-types/dataviews/stories/fixtures.d.ts.map +1 -1
- package/build-types/dataviews/stories/free-composition.d.ts.map +1 -1
- package/build-types/dataviews/stories/index.story.d.ts +18 -10
- package/build-types/dataviews/stories/index.story.d.ts.map +1 -1
- package/build-types/dataviews/stories/infinite-scroll.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-activity.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-custom.d.ts +3 -1
- package/build-types/dataviews/stories/layout-custom.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-grid.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-list.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-table.d.ts.map +1 -1
- package/build-types/dataviews/stories/with-card.d.ts +3 -1
- package/build-types/dataviews/stories/with-card.d.ts.map +1 -1
- package/build-types/dataviews-picker/index.d.ts +0 -1
- package/build-types/dataviews-picker/index.d.ts.map +1 -1
- package/build-types/dataviews-picker/stories/fixtures.d.ts.map +1 -1
- package/build-types/dataviews-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/field-types/stories/index.story.d.ts.map +1 -1
- package/build-types/hooks/index.d.ts +3 -0
- package/build-types/hooks/index.d.ts.map +1 -1
- package/build-types/hooks/test/use-data.d.ts +2 -0
- package/build-types/hooks/test/use-data.d.ts.map +1 -0
- package/build-types/hooks/use-data.d.ts +41 -3
- package/build-types/hooks/use-data.d.ts.map +1 -1
- package/build-types/hooks/use-infinite-scroll.d.ts +21 -0
- package/build-types/hooks/use-infinite-scroll.d.ts.map +1 -0
- package/build-types/hooks/use-selected-items.d.ts +19 -0
- package/build-types/hooks/use-selected-items.d.ts.map +1 -0
- package/build-types/types/dataviews.d.ts +15 -1
- package/build-types/types/dataviews.d.ts.map +1 -1
- package/build-types/types/field-api.d.ts +15 -4
- package/build-types/types/field-api.d.ts.map +1 -1
- package/build-types/utils/filter-sort-and-paginate.d.ts.map +1 -1
- package/build-types/utils/get-footer-message.d.ts +3 -2
- package/build-types/utils/get-footer-message.d.ts.map +1 -1
- package/build-wp/index.js +3202 -2761
- package/package.json +19 -19
- package/src/components/dataform-controls/datetime.tsx +19 -11
- package/src/components/dataform-layouts/card/index.tsx +171 -146
- package/src/components/dataform-layouts/card/style.scss +8 -5
- package/src/components/dataviews-bulk-actions/index.tsx +28 -1
- package/src/components/dataviews-context/index.ts +2 -2
- package/src/components/dataviews-footer/index.tsx +1 -6
- package/src/components/dataviews-layout/index.tsx +41 -19
- package/src/components/dataviews-layout/style.scss +8 -0
- package/src/components/dataviews-layouts/grid/composite-grid.tsx +433 -278
- package/src/components/dataviews-layouts/grid/style.scss +22 -2
- package/src/components/dataviews-layouts/index.ts +3 -3
- package/src/components/dataviews-layouts/picker-grid/index.tsx +70 -17
- package/src/components/dataviews-layouts/picker-grid/style.scss +10 -0
- package/src/components/dataviews-layouts/picker-table/index.tsx +42 -22
- package/src/components/dataviews-layouts/table/index.tsx +10 -4
- package/src/components/dataviews-layouts/table/style.scss +13 -0
- package/src/components/dataviews-layouts/table/use-scroll-state.ts +79 -0
- package/src/components/dataviews-layouts/utils/density-picker.tsx +12 -2
- package/src/components/dataviews-layouts/utils/grid-config-options.tsx +14 -0
- package/src/components/dataviews-layouts/utils/grid-items.scss +9 -1
- package/src/components/dataviews-layouts/utils/use-infinite-scroll.ts +64 -0
- package/src/components/dataviews-picker-footer/index.tsx +21 -1
- package/src/components/dataviews-search/index.tsx +2 -1
- package/src/components/dataviews-selection-checkbox/index.tsx +4 -2
- package/src/components/dataviews-view-config/index.tsx +0 -2
- package/src/components/dataviews-view-config/infinite-scroll-toggle.tsx +0 -5
- package/src/dataviews/index.tsx +58 -45
- package/src/dataviews/stories/empty.tsx +1 -3
- package/src/dataviews/stories/fixtures.tsx +288 -0
- package/src/dataviews/stories/free-composition.tsx +44 -45
- package/src/dataviews/stories/index.story.tsx +31 -8
- package/src/dataviews/stories/infinite-scroll.tsx +7 -93
- package/src/dataviews/stories/layout-activity.tsx +1 -0
- package/src/dataviews/stories/layout-custom.tsx +7 -3
- package/src/dataviews/stories/layout-grid.tsx +1 -0
- package/src/dataviews/stories/layout-list.tsx +1 -0
- package/src/dataviews/stories/layout-table.tsx +1 -0
- package/src/dataviews/stories/style.css +0 -5
- package/src/dataviews/stories/with-card.tsx +35 -24
- package/src/dataviews/style.scss +5 -8
- package/src/dataviews/test/dataviews.tsx +54 -1
- package/src/dataviews-picker/index.tsx +41 -35
- package/src/dataviews-picker/stories/fixtures.tsx +270 -0
- package/src/dataviews-picker/stories/index.story.tsx +62 -129
- package/src/field-types/stories/index.story.tsx +12 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/test/use-data.ts +791 -0
- package/src/hooks/use-data.ts +288 -21
- package/src/hooks/use-infinite-scroll.ts +304 -0
- package/src/hooks/use-selected-items.ts +72 -0
- package/src/style.scss +1 -0
- package/src/types/dataviews.ts +18 -1
- package/src/types/field-api.ts +16 -3
- package/src/utils/filter-sort-and-paginate.ts +13 -1
- package/src/utils/get-footer-message.ts +12 -9
- package/src/utils/test/filter-sort-and-paginate.js +78 -54
- package/build/components/dataviews-layouts/table/use-is-horizontal-scroll-end.cjs.map +0 -7
- package/build-module/components/dataviews-layouts/table/use-is-horizontal-scroll-end.mjs +0 -50
- package/build-module/components/dataviews-layouts/table/use-is-horizontal-scroll-end.mjs.map +0 -7
- package/build-types/components/dataviews-layouts/table/use-is-horizontal-scroll-end.d.ts +0 -19
- package/build-types/components/dataviews-layouts/table/use-is-horizontal-scroll-end.d.ts.map +0 -1
- package/src/components/dataviews-layouts/table/use-is-horizontal-scroll-end.ts +0 -82
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataviews-bulk-actions/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Button, CheckboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState, useRef, useContext } from '@wordpress/element';\nimport { useRegistry } from '@wordpress/data';\nimport { closeSmall } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport { ActionModal } from '../dataviews-item-actions';\nimport type { Action, ActionModal as ActionModalType } from '../../types';\nimport type { SetSelection } from '../../types/private';\nimport type { ActionTriggerProps } from '../dataviews-item-actions';\nimport getFooterMessage from '../../utils/get-footer-message';\n\ninterface ActionWithModalProps< Item > {\n\taction: ActionModalType< Item >;\n\titems: Item[];\n\tActionTriggerComponent: (\n\t\tprops: ActionTriggerProps< Item >\n\t) => ReactElement;\n}\n\nfunction ActionWithModal< Item >( {\n\taction,\n\titems,\n\tActionTriggerComponent,\n}: ActionWithModalProps< Item > ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst actionTriggerProps = {\n\t\taction,\n\t\tonClick: () => {\n\t\t\tsetIsModalOpen( true );\n\t\t},\n\t\titems,\n\t};\n\treturn (\n\t\t<>\n\t\t\t<ActionTriggerComponent { ...actionTriggerProps } />\n\t\t\t{ isModalOpen && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ action }\n\t\t\t\t\titems={ items }\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport function useHasAPossibleBulkAction< Item >(\n\tactions: Action< Item >[],\n\titem: Item\n) {\n\treturn useMemo( () => {\n\t\treturn actions.some( ( action ) => {\n\t\t\treturn (\n\t\t\t\taction.supportsBulk &&\n\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t);\n\t\t} );\n\t}, [ actions, item ] );\n}\n\nexport function useSomeItemHasAPossibleBulkAction< Item >(\n\tactions: Action< Item >[],\n\tdata: Item[]\n) {\n\treturn useMemo( () => {\n\t\treturn data.some( ( item ) => {\n\t\t\treturn actions.some( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\t}, [ actions, data ] );\n}\n\ninterface BulkSelectionCheckboxProps< Item > {\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tdata: Item[];\n\tactions: Action< Item >[];\n\tgetItemId: ( item: Item ) => string;\n}\n\nexport function BulkSelectionCheckbox< Item >( {\n\tselection,\n\tonChangeSelection,\n\tdata,\n\tactions,\n\tgetItemId,\n}: BulkSelectionCheckboxProps< Item > ) {\n\tconst selectableItems = useMemo( () => {\n\t\treturn data.filter( ( item ) => {\n\t\t\treturn actions.some(\n\t\t\t\t( action ) =>\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t);\n\t\t} );\n\t}, [ data, actions ] );\n\tconst selectedItems = data.filter(\n\t\t( item ) =>\n\t\t\tselection.includes( getItemId( item ) ) &&\n\t\t\tselectableItems.includes( item )\n\t);\n\tconst areAllSelected = selectedItems.length === selectableItems.length;\n\treturn (\n\t\t<CheckboxControl\n\t\t\tclassName=\"dataviews-view-table-selection-checkbox\"\n\t\t\tchecked={ areAllSelected }\n\t\t\tindeterminate={ ! areAllSelected && !! selectedItems.length }\n\t\t\tonChange={ () => {\n\t\t\t\tif ( areAllSelected ) {\n\t\t\t\t\tonChangeSelection( [] );\n\t\t\t\t} else {\n\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\tselectableItems.map( ( item ) => getItemId( item ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} }\n\t\t\taria-label={\n\t\t\t\tareAllSelected ? __( 'Deselect all' ) : __( 'Select all' )\n\t\t\t}\n\t\t/>\n\t);\n}\n\ninterface ActionButtonProps< Item > {\n\taction: Action< Item >;\n\tselectedItems: Item[];\n\tactionInProgress: string | null;\n\tsetActionInProgress: ( actionId: string | null ) => void;\n}\n\ninterface ToolbarContentProps< Item > {\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tdata: Item[];\n\tactions: Action< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t};\n}\n\nfunction ActionTrigger< Item >( {\n\taction,\n\tonClick,\n\tisBusy,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\tif ( isMobile ) {\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tdisabled={ isBusy }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tlabel={ label }\n\t\t\t\ticon={ action.icon }\n\t\t\t\tsize=\"compact\"\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisBusy={ isBusy }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\tdisabled={ isBusy }\n\t\t\taccessibleWhenDisabled\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ onClick }\n\t\t\tisBusy={ isBusy }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n\nconst EMPTY_ARRAY: [] = [];\n\nfunction ActionButton< Item >( {\n\taction,\n\tselectedItems,\n\tactionInProgress,\n\tsetActionInProgress,\n}: ActionButtonProps< Item > ) {\n\tconst registry = useRegistry();\n\tconst selectedEligibleItems = useMemo( () => {\n\t\treturn selectedItems.filter( ( item ) => {\n\t\t\treturn ! action.isEligible || action.isEligible( item );\n\t\t} );\n\t}, [ action, selectedItems ] );\n\tif ( 'RenderModal' in action ) {\n\t\treturn (\n\t\t\t<ActionWithModal\n\t\t\t\tkey={ action.id }\n\t\t\t\taction={ action }\n\t\t\t\titems={ selectedEligibleItems }\n\t\t\t\tActionTriggerComponent={ ActionTrigger }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<ActionTrigger\n\t\t\tkey={ action.id }\n\t\t\taction={ action }\n\t\t\tonClick={ async () => {\n\t\t\t\tsetActionInProgress( action.id );\n\t\t\t\tawait action.callback( selectedItems, {\n\t\t\t\t\tregistry,\n\t\t\t\t} );\n\t\t\t\tsetActionInProgress( null );\n\t\t\t} }\n\t\t\titems={ selectedEligibleItems }\n\t\t\tisBusy={ actionInProgress === action.id }\n\t\t/>\n\t);\n}\n\nfunction renderFooterContent< Item >(\n\tdata: Item[],\n\tactions: Action< Item >[],\n\tgetItemId: ( item: Item ) => string,\n\tselection: string[],\n\tactionsToShow: Action< Item >[],\n\tselectedItems: Item[],\n\tactionInProgress: string | null,\n\tsetActionInProgress: ( actionId: string | null ) => void,\n\tonChangeSelection: SetSelection,\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t}\n) {\n\tconst message = getFooterMessage(\n\t\tselection.length,\n\t\tdata.length,\n\t\tpaginationInfo.totalItems\n\t);\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"row\"\n\t\t\tclassName=\"dataviews-bulk-actions-footer__container\"\n\t\t\tgap=\"md\"\n\t\t\talign=\"center\"\n\t\t>\n\t\t\t<BulkSelectionCheckbox\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tdata={ data }\n\t\t\t\tactions={ actions }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t/>\n\t\t\t<span className=\"dataviews-bulk-actions-footer__item-count\">\n\t\t\t\t{ message }\n\t\t\t</span>\n\t\t\t<Stack\n\t\t\t\tdirection=\"row\"\n\t\t\t\tclassName=\"dataviews-bulk-actions-footer__action-buttons\"\n\t\t\t\tgap=\"xs\"\n\t\t\t>\n\t\t\t\t{ actionsToShow.map( ( action ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ActionButton\n\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\tselectedItems={ selectedItems }\n\t\t\t\t\t\t\tactionInProgress={ actionInProgress }\n\t\t\t\t\t\t\tsetActionInProgress={ setActionInProgress }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ selectedItems.length > 0 && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tlabel={ __( 'Cancel' ) }\n\t\t\t\t\t\tdisabled={ !! actionInProgress }\n\t\t\t\t\t\taccessibleWhenDisabled={ false }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChangeSelection( EMPTY_ARRAY );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n}\n\nfunction FooterContent< Item >( {\n\tselection,\n\tactions,\n\tonChangeSelection,\n\tdata,\n\tgetItemId,\n\tpaginationInfo,\n}: ToolbarContentProps< Item > ) {\n\tconst [ actionInProgress, setActionInProgress ] = useState< string | null >(\n\t\tnull\n\t);\n\tconst footerContentRef = useRef< React.JSX.Element >( undefined );\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\tconst bulkActions = useMemo(\n\t\t() => actions.filter( ( action ) => action.supportsBulk ),\n\t\t[ actions ]\n\t);\n\tconst selectableItems = useMemo( () => {\n\t\treturn data.filter( ( item ) => {\n\t\t\treturn bulkActions.some(\n\t\t\t\t( action ) => ! action.isEligible || action.isEligible( item )\n\t\t\t);\n\t\t} );\n\t}, [ data, bulkActions ] );\n\n\tconst selectedItems = useMemo( () => {\n\t\treturn data.filter(\n\t\t\t( item ) =>\n\t\t\t\tselection.includes( getItemId( item ) ) &&\n\t\t\t\tselectableItems.includes( item )\n\t\t);\n\t}, [ selection, data, getItemId, selectableItems ] );\n\n\tconst actionsToShow = useMemo(\n\t\t() =>\n\t\t\tactions.filter( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! isMobile || action.icon ) &&\n\t\t\t\t\tselectedItems.some(\n\t\t\t\t\t\t( item ) =>\n\t\t\t\t\t\t\t! action.isEligible || action.isEligible( item )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} ),\n\t\t[ actions, selectedItems, isMobile ]\n\t);\n\tif ( ! actionInProgress ) {\n\t\tif ( footerContentRef.current ) {\n\t\t\tfooterContentRef.current = undefined;\n\t\t}\n\t\treturn renderFooterContent(\n\t\t\tdata,\n\t\t\tactions,\n\t\t\tgetItemId,\n\t\t\tselection,\n\t\t\tactionsToShow,\n\t\t\tselectedItems,\n\t\t\tactionInProgress,\n\t\t\tsetActionInProgress,\n\t\t\tonChangeSelection,\n\t\t\tpaginationInfo\n\t\t);\n\t} else if ( ! footerContentRef.current ) {\n\t\tfooterContentRef.current = renderFooterContent(\n\t\t\tdata,\n\t\t\tactions,\n\t\t\tgetItemId,\n\t\t\tselection,\n\t\t\tactionsToShow,\n\t\t\tselectedItems,\n\t\t\tactionInProgress,\n\t\t\tsetActionInProgress,\n\t\t\tonChangeSelection,\n\t\t\tpaginationInfo\n\t\t);\n\t}\n\treturn footerContentRef.current;\n}\n\nexport function BulkActionsFooter() {\n\tconst {\n\t\tdata,\n\t\tselection,\n\t\tactions = EMPTY_ARRAY,\n\t\tonChangeSelection,\n\t\tgetItemId,\n\t\tpaginationInfo,\n\t} = useContext( DataViewsContext );\n\treturn (\n\t\t<FooterContent\n\t\t\tselection={ selection }\n\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\tdata={ data }\n\t\t\tactions={ actions }\n\t\t\tgetItemId={ getItemId }\n\t\t\tpaginationInfo={ paginationInfo }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAQA,SAAS,QAAQ,uBAAuB;AACxC,SAAS,UAAU;AACnB,SAAS,SAAS,UAAU,QAAQ,kBAAkB;AACtD,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AACjC,SAAS,aAAa;AAKtB,OAAO,sBAAsB;AAC7B,SAAS,mBAAmB;AAI5B,OAAO,sBAAsB;AAwB3B,mBACC,KADD;AAdF,SAAS,gBAAyB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AACjC,QAAM,CAAE,aAAa,cAAe,IAAI,SAAU,KAAM;AACxD,QAAM,qBAAqB;AAAA,IAC1B;AAAA,IACA,SAAS,MAAM;AACd,qBAAgB,IAAK;AAAA,IACtB;AAAA,IACA;AAAA,EACD;AACA,SACC,iCACC;AAAA,wBAAC,0BAAyB,GAAG,oBAAqB;AAAA,IAChD,eACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAa,MAAM,eAAgB,KAAM;AAAA;AAAA,IAC1C;AAAA,KAEF;AAEF;AAEO,SAAS,0BACf,SACA,MACC;AACD,SAAO,QAAS,MAAM;AACrB,WAAO,QAAQ,KAAM,CAAE,WAAY;AAClC,aACC,OAAO,iBACL,CAAE,OAAO,cAAc,OAAO,WAAY,IAAK;AAAA,IAEnD,CAAE;AAAA,EACH,GAAG,CAAE,SAAS,IAAK,CAAE;AACtB;AAEO,SAAS,kCACf,SACA,MACC;AACD,SAAO,QAAS,MAAM;AACrB,WAAO,KAAK,KAAM,CAAE,SAAU;AAC7B,aAAO,QAAQ,KAAM,CAAE,WAAY;AAClC,eACC,OAAO,iBACL,CAAE,OAAO,cAAc,OAAO,WAAY,IAAK;AAAA,MAEnD,CAAE;AAAA,IACH,CAAE;AAAA,EACH,GAAG,CAAE,SAAS,IAAK,CAAE;AACtB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Button, CheckboxControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState, useRef, useContext } from '@wordpress/element';\nimport { useRegistry } from '@wordpress/data';\nimport { closeSmall } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport { ActionModal } from '../dataviews-item-actions';\nimport type { Action, ActionModal as ActionModalType } from '../../types';\nimport type { SetSelection } from '../../types/private';\nimport type { ActionTriggerProps } from '../dataviews-item-actions';\nimport getFooterMessage from '../../utils/get-footer-message';\n\ninterface ActionWithModalProps< Item > {\n\taction: ActionModalType< Item >;\n\titems: Item[];\n\tActionTriggerComponent: (\n\t\tprops: ActionTriggerProps< Item >\n\t) => ReactElement;\n}\n\nfunction ActionWithModal< Item >( {\n\taction,\n\titems,\n\tActionTriggerComponent,\n}: ActionWithModalProps< Item > ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst actionTriggerProps = {\n\t\taction,\n\t\tonClick: () => {\n\t\t\tsetIsModalOpen( true );\n\t\t},\n\t\titems,\n\t};\n\treturn (\n\t\t<>\n\t\t\t<ActionTriggerComponent { ...actionTriggerProps } />\n\t\t\t{ isModalOpen && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ action }\n\t\t\t\t\titems={ items }\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport function useHasAPossibleBulkAction< Item >(\n\tactions: Action< Item >[],\n\titem: Item\n) {\n\treturn useMemo( () => {\n\t\treturn actions.some( ( action ) => {\n\t\t\treturn (\n\t\t\t\taction.supportsBulk &&\n\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t);\n\t\t} );\n\t}, [ actions, item ] );\n}\n\nexport function useSomeItemHasAPossibleBulkAction< Item >(\n\tactions: Action< Item >[],\n\tdata: Item[]\n) {\n\treturn useMemo( () => {\n\t\treturn data.some( ( item ) => {\n\t\t\treturn actions.some( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\t}, [ actions, data ] );\n}\n\ninterface BulkSelectionCheckboxProps< Item > {\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tdata: Item[];\n\tactions: Action< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tdisableSelectAll?: boolean;\n}\n\nexport function BulkSelectionCheckbox< Item >( {\n\tselection,\n\tonChangeSelection,\n\tdata,\n\tactions,\n\tgetItemId,\n\tdisableSelectAll = false,\n}: BulkSelectionCheckboxProps< Item > ) {\n\tconst selectableItems = useMemo( () => {\n\t\treturn data.filter( ( item ) => {\n\t\t\treturn actions.some(\n\t\t\t\t( action ) =>\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t);\n\t\t} );\n\t}, [ data, actions ] );\n\tconst selectedItems = data.filter(\n\t\t( item ) =>\n\t\t\tselection.includes( getItemId( item ) ) &&\n\t\t\tselectableItems.includes( item )\n\t);\n\tconst hasSelection = selection.length > 0;\n\tconst areAllSelected = selectedItems.length === selectableItems.length;\n\n\tif ( disableSelectAll ) {\n\t\treturn (\n\t\t\t<CheckboxControl\n\t\t\t\tclassName=\"dataviews-view-table-selection-checkbox\"\n\t\t\t\tchecked={ hasSelection }\n\t\t\t\tdisabled={ ! hasSelection }\n\t\t\t\tonChange={ () => {\n\t\t\t\t\tonChangeSelection( [] );\n\t\t\t\t} }\n\t\t\t\taria-label={ __( 'Deselect all' ) }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<CheckboxControl\n\t\t\tclassName=\"dataviews-view-table-selection-checkbox\"\n\t\t\tchecked={ areAllSelected }\n\t\t\tindeterminate={ ! areAllSelected && !! selectedItems.length }\n\t\t\tonChange={ () => {\n\t\t\t\tif ( areAllSelected ) {\n\t\t\t\t\tonChangeSelection( [] );\n\t\t\t\t} else {\n\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\tselectableItems.map( ( item ) => getItemId( item ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} }\n\t\t\taria-label={\n\t\t\t\tareAllSelected ? __( 'Deselect all' ) : __( 'Select all' )\n\t\t\t}\n\t\t/>\n\t);\n}\n\ninterface ActionButtonProps< Item > {\n\taction: Action< Item >;\n\tselectedItems: Item[];\n\tactionInProgress: string | null;\n\tsetActionInProgress: ( actionId: string | null ) => void;\n}\n\ninterface ToolbarContentProps< Item > {\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tdata: Item[];\n\tactions: Action< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisInfiniteScroll: boolean;\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t};\n}\n\nfunction ActionTrigger< Item >( {\n\taction,\n\tonClick,\n\tisBusy,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\tif ( isMobile ) {\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tdisabled={ isBusy }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tlabel={ label }\n\t\t\t\ticon={ action.icon }\n\t\t\t\tsize=\"compact\"\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisBusy={ isBusy }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\tdisabled={ isBusy }\n\t\t\taccessibleWhenDisabled\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ onClick }\n\t\t\tisBusy={ isBusy }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n\nconst EMPTY_ARRAY: [] = [];\n\nfunction ActionButton< Item >( {\n\taction,\n\tselectedItems,\n\tactionInProgress,\n\tsetActionInProgress,\n}: ActionButtonProps< Item > ) {\n\tconst registry = useRegistry();\n\tconst selectedEligibleItems = useMemo( () => {\n\t\treturn selectedItems.filter( ( item ) => {\n\t\t\treturn ! action.isEligible || action.isEligible( item );\n\t\t} );\n\t}, [ action, selectedItems ] );\n\tif ( 'RenderModal' in action ) {\n\t\treturn (\n\t\t\t<ActionWithModal\n\t\t\t\tkey={ action.id }\n\t\t\t\taction={ action }\n\t\t\t\titems={ selectedEligibleItems }\n\t\t\t\tActionTriggerComponent={ ActionTrigger }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<ActionTrigger\n\t\t\tkey={ action.id }\n\t\t\taction={ action }\n\t\t\tonClick={ async () => {\n\t\t\t\tsetActionInProgress( action.id );\n\t\t\t\tawait action.callback( selectedItems, {\n\t\t\t\t\tregistry,\n\t\t\t\t} );\n\t\t\t\tsetActionInProgress( null );\n\t\t\t} }\n\t\t\titems={ selectedEligibleItems }\n\t\t\tisBusy={ actionInProgress === action.id }\n\t\t/>\n\t);\n}\n\nfunction renderFooterContent< Item >(\n\tdata: Item[],\n\tactions: Action< Item >[],\n\tgetItemId: ( item: Item ) => string,\n\tisInfiniteScroll: boolean,\n\tselection: string[],\n\tactionsToShow: Action< Item >[],\n\tselectedItems: Item[],\n\tactionInProgress: string | null,\n\tsetActionInProgress: ( actionId: string | null ) => void,\n\tonChangeSelection: SetSelection,\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t}\n) {\n\tconst message = getFooterMessage(\n\t\tselection.length,\n\t\tdata.length,\n\t\tpaginationInfo.totalItems,\n\t\tisInfiniteScroll\n\t);\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"row\"\n\t\t\tclassName=\"dataviews-bulk-actions-footer__container\"\n\t\t\tgap=\"md\"\n\t\t\talign=\"center\"\n\t\t>\n\t\t\t<BulkSelectionCheckbox\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tdata={ data }\n\t\t\t\tactions={ actions }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t\tdisableSelectAll={ isInfiniteScroll }\n\t\t\t/>\n\t\t\t<span className=\"dataviews-bulk-actions-footer__item-count\">\n\t\t\t\t{ message }\n\t\t\t</span>\n\t\t\t<Stack\n\t\t\t\tdirection=\"row\"\n\t\t\t\tclassName=\"dataviews-bulk-actions-footer__action-buttons\"\n\t\t\t\tgap=\"xs\"\n\t\t\t>\n\t\t\t\t{ actionsToShow.map( ( action ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ActionButton\n\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\tselectedItems={ selectedItems }\n\t\t\t\t\t\t\tactionInProgress={ actionInProgress }\n\t\t\t\t\t\t\tsetActionInProgress={ setActionInProgress }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ selectedItems.length > 0 && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tlabel={ __( 'Cancel' ) }\n\t\t\t\t\t\tdisabled={ !! actionInProgress }\n\t\t\t\t\t\taccessibleWhenDisabled={ false }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChangeSelection( EMPTY_ARRAY );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n}\n\nfunction FooterContent< Item >( {\n\tselection,\n\tactions,\n\tonChangeSelection,\n\tdata,\n\tgetItemId,\n\tisInfiniteScroll,\n\tpaginationInfo,\n}: ToolbarContentProps< Item > ) {\n\tconst [ actionInProgress, setActionInProgress ] = useState< string | null >(\n\t\tnull\n\t);\n\tconst footerContentRef = useRef< React.JSX.Element >( undefined );\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\tconst bulkActions = useMemo(\n\t\t() => actions.filter( ( action ) => action.supportsBulk ),\n\t\t[ actions ]\n\t);\n\tconst selectableItems = useMemo( () => {\n\t\treturn data.filter( ( item ) => {\n\t\t\treturn bulkActions.some(\n\t\t\t\t( action ) => ! action.isEligible || action.isEligible( item )\n\t\t\t);\n\t\t} );\n\t}, [ data, bulkActions ] );\n\n\tconst selectedItems = useMemo( () => {\n\t\treturn data.filter(\n\t\t\t( item ) =>\n\t\t\t\tselection.includes( getItemId( item ) ) &&\n\t\t\t\tselectableItems.includes( item )\n\t\t);\n\t}, [ selection, data, getItemId, selectableItems ] );\n\n\tconst actionsToShow = useMemo(\n\t\t() =>\n\t\t\tactions.filter( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! isMobile || action.icon ) &&\n\t\t\t\t\tselectedItems.some(\n\t\t\t\t\t\t( item ) =>\n\t\t\t\t\t\t\t! action.isEligible || action.isEligible( item )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} ),\n\t\t[ actions, selectedItems, isMobile ]\n\t);\n\tif ( ! actionInProgress ) {\n\t\tif ( footerContentRef.current ) {\n\t\t\tfooterContentRef.current = undefined;\n\t\t}\n\t\treturn renderFooterContent(\n\t\t\tdata,\n\t\t\tactions,\n\t\t\tgetItemId,\n\t\t\tisInfiniteScroll,\n\t\t\tselection,\n\t\t\tactionsToShow,\n\t\t\tselectedItems,\n\t\t\tactionInProgress,\n\t\t\tsetActionInProgress,\n\t\t\tonChangeSelection,\n\t\t\tpaginationInfo\n\t\t);\n\t} else if ( ! footerContentRef.current ) {\n\t\tfooterContentRef.current = renderFooterContent(\n\t\t\tdata,\n\t\t\tactions,\n\t\t\tgetItemId,\n\t\t\tisInfiniteScroll,\n\t\t\tselection,\n\t\t\tactionsToShow,\n\t\t\tselectedItems,\n\t\t\tactionInProgress,\n\t\t\tsetActionInProgress,\n\t\t\tonChangeSelection,\n\t\t\tpaginationInfo\n\t\t);\n\t}\n\treturn footerContentRef.current;\n}\n\nexport function BulkActionsFooter() {\n\tconst {\n\t\tdata,\n\t\tselection,\n\t\tactions = EMPTY_ARRAY,\n\t\tonChangeSelection,\n\t\tgetItemId,\n\t\tpaginationInfo,\n\t\tview,\n\t} = useContext( DataViewsContext );\n\treturn (\n\t\t<FooterContent\n\t\t\tselection={ selection }\n\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\tdata={ data }\n\t\t\tactions={ actions }\n\t\t\tgetItemId={ getItemId }\n\t\t\tisInfiniteScroll={ !! view.infiniteScrollEnabled }\n\t\t\tpaginationInfo={ paginationInfo }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAQA,SAAS,QAAQ,uBAAuB;AACxC,SAAS,UAAU;AACnB,SAAS,SAAS,UAAU,QAAQ,kBAAkB;AACtD,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SA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AA,MAC3B;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -30,10 +30,10 @@ var DataViewsContext = createContext({
|
|
|
30
30
|
setIsShowingFilter: () => {
|
|
31
31
|
},
|
|
32
32
|
hasInitiallyLoaded: false,
|
|
33
|
-
hasInfiniteScrollHandler: false,
|
|
34
33
|
config: {
|
|
35
34
|
perPageSizes: []
|
|
36
|
-
}
|
|
35
|
+
},
|
|
36
|
+
intersectionObserver: null
|
|
37
37
|
});
|
|
38
38
|
DataViewsContext.displayName = "DataViewsContext";
|
|
39
39
|
var dataviews_context_default = DataViewsContext;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataviews-context/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ComponentProps, ReactElement, ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { createContext, createRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tView,\n\tAction,\n\tNormalizedField,\n\tSupportedLayouts,\n\tNormalizedFilter,\n} from '../../types';\nimport type { SetSelection } from '../../types/private';\nimport { LAYOUT_TABLE } from '../../constants';\n\ntype DataViewsContextType< Item > = {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n\tfields: NormalizedField< Item >[];\n\tactions?: Action< Item >[];\n\tdata: Item[];\n\tisLoading?: boolean;\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t};\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\topenedFilter: string | null;\n\tsetOpenedFilter: ( openedFilter: string | null ) => void;\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\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\tcontainerWidth: number;\n\tcontainerRef: React.MutableRefObject< HTMLDivElement | null >;\n\tresizeObserverRef:\n\t\t| ( ( element?: HTMLDivElement | null ) => void )\n\t\t| React.RefObject< HTMLDivElement >;\n\tdefaultLayouts: SupportedLayouts;\n\tfilters: NormalizedFilter[];\n\tisShowingFilter: boolean;\n\tsetIsShowingFilter: ( value: boolean ) => void;\n\tconfig: { perPageSizes: number[] };\n\tempty?: ReactNode;\n\thasInitiallyLoaded?: boolean;\n\
|
|
5
|
-
"mappings": ";AAQA,SAAS,eAAe,iBAAiB;AAazC,SAAS,oBAAoB;AA2C7B,IAAM,mBAAmB,cAA8C;AAAA,EACtE,MAAM,EAAE,MAAM,aAAa;AAAA,EAC3B,cAAc,MAAM;AAAA,EAAC;AAAA,EACrB,QAAQ,CAAC;AAAA,EACT,MAAM,CAAC;AAAA,EACP,gBAAgB;AAAA,IACf,YAAY;AAAA,IACZ,YAAY;AAAA,EACb;AAAA,EACA,WAAW,CAAC;AAAA,EACZ,mBAAmB,MAAM;AAAA,EAAC;AAAA,EAC1B,iBAAiB,MAAM;AAAA,EAAC;AAAA,EACxB,cAAc;AAAA,EACd,WAAW,CAAE,SAAU,KAAK;AAAA,EAC5B,iBAAiB,MAAM;AAAA,EACvB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAc,UAAU;AAAA,EACxB,mBAAmB,MAAM;AAAA,EAAC;AAAA,EAC1B,gBAAgB,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,OAAO,CAAC,EAAE;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,iBAAiB;AAAA,EACjB,oBAAoB,MAAM;AAAA,EAAC;AAAA,EAC3B,oBAAoB;AAAA,EACpB,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ComponentProps, ReactElement, ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { createContext, createRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tView,\n\tAction,\n\tNormalizedField,\n\tSupportedLayouts,\n\tNormalizedFilter,\n} from '../../types';\nimport type { SetSelection } from '../../types/private';\nimport { LAYOUT_TABLE } from '../../constants';\n\ntype DataViewsContextType< Item > = {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n\tfields: NormalizedField< Item >[];\n\tactions?: Action< Item >[];\n\tdata: Item[];\n\tisLoading?: boolean;\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t};\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\topenedFilter: string | null;\n\tsetOpenedFilter: ( openedFilter: string | null ) => void;\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\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\tcontainerWidth: number;\n\tcontainerRef: React.MutableRefObject< HTMLDivElement | null >;\n\tresizeObserverRef:\n\t\t| ( ( element?: HTMLDivElement | null ) => void )\n\t\t| React.RefObject< HTMLDivElement >;\n\tdefaultLayouts: SupportedLayouts;\n\tfilters: NormalizedFilter[];\n\tisShowingFilter: boolean;\n\tsetIsShowingFilter: ( value: boolean ) => void;\n\tconfig: { perPageSizes: number[] };\n\tempty?: ReactNode;\n\thasInitiallyLoaded?: boolean;\n\titemListLabel?: string;\n\tonReset?: ( () => void ) | false;\n\tintersectionObserver?: IntersectionObserver | null;\n};\n\nconst DataViewsContext = createContext< DataViewsContextType< any > >( {\n\tview: { type: LAYOUT_TABLE },\n\tonChangeView: () => {},\n\tfields: [],\n\tdata: [],\n\tpaginationInfo: {\n\t\ttotalItems: 0,\n\t\ttotalPages: 0,\n\t},\n\tselection: [],\n\tonChangeSelection: () => {},\n\tsetOpenedFilter: () => {},\n\topenedFilter: null,\n\tgetItemId: ( item ) => item.id,\n\tisItemClickable: () => true,\n\trenderItemLink: undefined,\n\tcontainerWidth: 0,\n\tcontainerRef: createRef(),\n\tresizeObserverRef: () => {},\n\tdefaultLayouts: { list: {}, grid: {}, table: {} },\n\tfilters: [],\n\tisShowingFilter: false,\n\tsetIsShowingFilter: () => {},\n\thasInitiallyLoaded: false,\n\tconfig: {\n\t\tperPageSizes: [],\n\t},\n\tintersectionObserver: null,\n} );\n\nDataViewsContext.displayName = 'DataViewsContext';\n\nexport default DataViewsContext;\n"],
|
|
5
|
+
"mappings": ";AAQA,SAAS,eAAe,iBAAiB;AAazC,SAAS,oBAAoB;AA2C7B,IAAM,mBAAmB,cAA8C;AAAA,EACtE,MAAM,EAAE,MAAM,aAAa;AAAA,EAC3B,cAAc,MAAM;AAAA,EAAC;AAAA,EACrB,QAAQ,CAAC;AAAA,EACT,MAAM,CAAC;AAAA,EACP,gBAAgB;AAAA,IACf,YAAY;AAAA,IACZ,YAAY;AAAA,EACb;AAAA,EACA,WAAW,CAAC;AAAA,EACZ,mBAAmB,MAAM;AAAA,EAAC;AAAA,EAC1B,iBAAiB,MAAM;AAAA,EAAC;AAAA,EACxB,cAAc;AAAA,EACd,WAAW,CAAE,SAAU,KAAK;AAAA,EAC5B,iBAAiB,MAAM;AAAA,EACvB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAc,UAAU;AAAA,EACxB,mBAAmB,MAAM;AAAA,EAAC;AAAA,EAC1B,gBAAgB,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,OAAO,CAAC,EAAE;AAAA,EAChD,SAAS,CAAC;AAAA,EACV,iBAAiB;AAAA,EACjB,oBAAoB,MAAM;AAAA,EAAC;AAAA,EAC3B,oBAAoB;AAAA,EACpB,QAAQ;AAAA,IACP,cAAc,CAAC;AAAA,EAChB;AAAA,EACA,sBAAsB;AACvB,CAAE;AAEF,iBAAiB,cAAc;AAE/B,IAAO,4BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -19,10 +19,9 @@ function DataViewsFooter() {
|
|
|
19
19
|
data,
|
|
20
20
|
actions = EMPTY_ARRAY,
|
|
21
21
|
isLoading,
|
|
22
|
-
hasInitiallyLoaded
|
|
23
|
-
hasInfiniteScrollHandler
|
|
22
|
+
hasInitiallyLoaded
|
|
24
23
|
} = useContext(DataViewsContext);
|
|
25
|
-
const isRefreshing = !!isLoading && hasInitiallyLoaded &&
|
|
24
|
+
const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
|
|
26
25
|
const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
|
|
27
26
|
const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
|
|
28
27
|
if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataviews-footer/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport DataViewsPagination from '../dataviews-pagination';\nimport {\n\tBulkActionsFooter,\n\tuseSomeItemHasAPossibleBulkAction,\n} from '../dataviews-bulk-actions';\nimport { LAYOUT_GRID, LAYOUT_TABLE } from '../../constants';\nimport { useDelayedLoading } from '../../hooks/use-delayed-loading';\n\nconst EMPTY_ARRAY: [] = [];\n\nexport default function DataViewsFooter() {\n\tconst {\n\t\tview,\n\t\tpaginationInfo: { totalItems = 0, totalPages },\n\t\tdata,\n\t\tactions = EMPTY_ARRAY,\n\t\tisLoading,\n\t\thasInitiallyLoaded,\n\t
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AAKtB,OAAO,sBAAsB;AAC7B,OAAO,yBAAyB;AAChC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,oBAAoB;AAC1C,SAAS,yBAAyB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport DataViewsPagination from '../dataviews-pagination';\nimport {\n\tBulkActionsFooter,\n\tuseSomeItemHasAPossibleBulkAction,\n} from '../dataviews-bulk-actions';\nimport { LAYOUT_GRID, LAYOUT_TABLE } from '../../constants';\nimport { useDelayedLoading } from '../../hooks/use-delayed-loading';\n\nconst EMPTY_ARRAY: [] = [];\n\nexport default function DataViewsFooter() {\n\tconst {\n\t\tview,\n\t\tpaginationInfo: { totalItems = 0, totalPages },\n\t\tdata,\n\t\tactions = EMPTY_ARRAY,\n\t\tisLoading,\n\t\thasInitiallyLoaded,\n\t} = useContext( DataViewsContext );\n\n\tconst isRefreshing = !! isLoading && hasInitiallyLoaded && !! data?.length;\n\n\tconst isDelayedRefreshing = useDelayedLoading( !! isRefreshing );\n\n\tconst hasBulkActions =\n\t\tuseSomeItemHasAPossibleBulkAction( actions, data ) &&\n\t\t[ LAYOUT_TABLE, LAYOUT_GRID ].includes( view.type );\n\n\tif (\n\t\t! isRefreshing &&\n\t\t( ! totalItems ||\n\t\t\t! totalPages ||\n\t\t\t( totalPages <= 1 && ! hasBulkActions ) )\n\t) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t( !! totalItems || isRefreshing ) && (\n\t\t\t<div\n\t\t\t\tclassName=\"dataviews-footer\"\n\t\t\t\t// @ts-ignore\n\t\t\t\tinert={ isRefreshing ? 'true' : undefined }\n\t\t\t>\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\tjustify=\"end\"\n\t\t\t\t\talign=\"center\"\n\t\t\t\t\tclassName={ clsx( 'dataviews-footer__content', {\n\t\t\t\t\t\t'is-refreshing': isDelayedRefreshing,\n\t\t\t\t\t} ) }\n\t\t\t\t\tgap=\"sm\"\n\t\t\t\t>\n\t\t\t\t\t{ hasBulkActions && <BulkActionsFooter /> }\n\t\t\t\t\t<DataViewsPagination />\n\t\t\t\t</Stack>\n\t\t\t</div>\n\t\t)\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AAKtB,OAAO,sBAAsB;AAC7B,OAAO,yBAAyB;AAChC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,oBAAoB;AAC1C,SAAS,yBAAyB;AAqC9B,SASqB,KATrB;AAnCJ,IAAM,cAAkB,CAAC;AAEV,SAAR,kBAAmC;AACzC,QAAM;AAAA,IACL;AAAA,IACA,gBAAgB,EAAE,aAAa,GAAG,WAAW;AAAA,IAC7C;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,EACD,IAAI,WAAY,gBAAiB;AAEjC,QAAM,eAAe,CAAC,CAAE,aAAa,sBAAsB,CAAC,CAAE,MAAM;AAEpE,QAAM,sBAAsB,kBAAmB,CAAC,CAAE,YAAa;AAE/D,QAAM,iBACL,kCAAmC,SAAS,IAAK,KACjD,CAAE,cAAc,WAAY,EAAE,SAAU,KAAK,IAAK;AAEnD,MACC,CAAE,iBACA,CAAE,cACH,CAAE,cACA,cAAc,KAAK,CAAE,iBACvB;AACD,WAAO;AAAA,EACR;AACA,UACG,CAAC,CAAE,cAAc,iBAClB;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MAEV,OAAQ,eAAe,SAAS;AAAA,MAEhC;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,SAAQ;AAAA,UACR,OAAM;AAAA,UACN,WAAY,KAAM,6BAA6B;AAAA,YAC9C,iBAAiB;AAAA,UAClB,CAAE;AAAA,UACF,KAAI;AAAA,UAEF;AAAA,8BAAkB,oBAAC,qBAAkB;AAAA,YACvC,oBAAC,uBAAoB;AAAA;AAAA;AAAA,MACtB;AAAA;AAAA,EACD;AAGH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// packages/dataviews/src/components/dataviews-layout/index.tsx
|
|
2
2
|
import { useContext } from "@wordpress/element";
|
|
3
|
+
import { Spinner } from "@wordpress/components";
|
|
3
4
|
import { __ } from "@wordpress/i18n";
|
|
4
5
|
import DataViewsContext from "../dataviews-context/index.mjs";
|
|
5
6
|
import { VIEW_LAYOUTS } from "../dataviews-layouts/index.mjs";
|
|
7
|
+
import { useDelayedLoading } from "../../hooks/use-delayed-loading.mjs";
|
|
6
8
|
import { jsx } from "react/jsx-runtime";
|
|
7
9
|
function DataViewsLayout({ className }) {
|
|
8
10
|
const {
|
|
@@ -22,15 +24,22 @@ function DataViewsLayout({ className }) {
|
|
|
22
24
|
isItemClickable,
|
|
23
25
|
renderItemLink,
|
|
24
26
|
defaultLayouts,
|
|
27
|
+
containerRef,
|
|
25
28
|
empty = /* @__PURE__ */ jsx("p", { children: __("No results") })
|
|
26
29
|
} = useContext(DataViewsContext);
|
|
30
|
+
const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
|
|
31
|
+
delay: 200
|
|
32
|
+
});
|
|
27
33
|
if (!hasInitiallyLoaded) {
|
|
28
|
-
|
|
34
|
+
if (!isDelayedInitialLoading) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return /* @__PURE__ */ jsx("div", { className: "dataviews-loading", children: /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(Spinner, {}) }) });
|
|
29
38
|
}
|
|
30
39
|
const ViewComponent = VIEW_LAYOUTS.find(
|
|
31
40
|
(v) => v.type === view.type && defaultLayouts[v.type]
|
|
32
41
|
)?.component;
|
|
33
|
-
return /* @__PURE__ */ jsx(
|
|
42
|
+
return /* @__PURE__ */ jsx("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ jsx(
|
|
34
43
|
ViewComponent,
|
|
35
44
|
{
|
|
36
45
|
className,
|
|
@@ -50,7 +59,7 @@ function DataViewsLayout({ className }) {
|
|
|
50
59
|
view,
|
|
51
60
|
empty
|
|
52
61
|
}
|
|
53
|
-
);
|
|
62
|
+
) });
|
|
54
63
|
}
|
|
55
64
|
export {
|
|
56
65
|
DataViewsLayout as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataviews-layout/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport { VIEW_LAYOUTS } from '../dataviews-layouts';\nimport type { ViewBaseProps } from '../../types';\n\ntype DataViewsLayoutProps = {\n\tclassName?: string;\n};\n\nexport default function DataViewsLayout( { className }: DataViewsLayoutProps ) {\n\tconst {\n\t\tactions = [],\n\t\tdata,\n\t\tfields,\n\t\tgetItemId,\n\t\tgetItemLevel,\n\t\thasInitiallyLoaded,\n\t\tisLoading,\n\t\tview,\n\t\tonChangeView,\n\t\tselection,\n\t\tonChangeSelection,\n\t\tsetOpenedFilter,\n\t\tonClickItem,\n\t\tisItemClickable,\n\t\trenderItemLink,\n\t\tdefaultLayouts,\n\t\tempty = <p>{ __( 'No results' ) }</p>,\n\t} = useContext( DataViewsContext );\n\n\tif ( ! hasInitiallyLoaded ) {\n\t\treturn null;\n\t}\n\n\tconst ViewComponent = VIEW_LAYOUTS.find(\n\t\t( v ) => v.type === view.type && defaultLayouts[ v.type ]\n\t)?.component as ComponentType< ViewBaseProps< any > >;\n\n\treturn (\n\t\t<ViewComponent\n\t\t\tclassName={ className }\n\t\t\tactions={ actions }\n\t\t\tdata={ data }\n\t\t\tfields={ fields }\n\t\t\tgetItemId={ getItemId }\n\t\t\tgetItemLevel={ getItemLevel }\n\t\t\tisLoading={ isLoading }\n\t\t\tonChangeView={ onChangeView }\n\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\tselection={ selection }\n\t\t\tsetOpenedFilter={ setOpenedFilter }\n\t\t\tonClickItem={ onClickItem }\n\t\t\trenderItemLink={ renderItemLink }\n\t\t\tisItemClickable={ isItemClickable }\n\t\t\tview={ view }\n\t\t\tempty={ empty }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAQA,SAAS,kBAAkB;AAC3B,SAAS,UAAU;AAKnB,OAAO,sBAAsB;AAC7B,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { Spinner } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport { VIEW_LAYOUTS } from '../dataviews-layouts';\nimport { useDelayedLoading } from '../../hooks/use-delayed-loading';\nimport type { ViewBaseProps } from '../../types';\n\ntype DataViewsLayoutProps = {\n\tclassName?: string;\n};\n\nexport default function DataViewsLayout( { className }: DataViewsLayoutProps ) {\n\tconst {\n\t\tactions = [],\n\t\tdata,\n\t\tfields,\n\t\tgetItemId,\n\t\tgetItemLevel,\n\t\thasInitiallyLoaded,\n\t\tisLoading,\n\t\tview,\n\t\tonChangeView,\n\t\tselection,\n\t\tonChangeSelection,\n\t\tsetOpenedFilter,\n\t\tonClickItem,\n\t\tisItemClickable,\n\t\trenderItemLink,\n\t\tdefaultLayouts,\n\t\tcontainerRef,\n\t\tempty = <p>{ __( 'No results' ) }</p>,\n\t} = useContext( DataViewsContext );\n\n\tconst isDelayedInitialLoading = useDelayedLoading( ! hasInitiallyLoaded, {\n\t\tdelay: 200,\n\t} );\n\t// Until the initial data load completes, show a spinner (or nothing if fast).\n\t// After that, render the layout component which preserves previous data\n\t// while loading subsequent requests.\n\tif ( ! hasInitiallyLoaded ) {\n\t\t// If the initial data load is fast, don't show the loading state at all.\n\t\tif ( ! isDelayedInitialLoading ) {\n\t\t\treturn null;\n\t\t}\n\t\t// If the initial data load takes more than 200ms, show the loading state.\n\t\treturn (\n\t\t\t<div className=\"dataviews-loading\">\n\t\t\t\t<p>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst ViewComponent = VIEW_LAYOUTS.find(\n\t\t( v ) => v.type === view.type && defaultLayouts[ v.type ]\n\t)?.component as ComponentType< ViewBaseProps< any > >;\n\n\treturn (\n\t\t<div className=\"dataviews-layout__container\" ref={ containerRef }>\n\t\t\t<ViewComponent\n\t\t\t\tclassName={ className }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ data }\n\t\t\t\tfields={ fields }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t\tgetItemLevel={ getItemLevel }\n\t\t\t\tisLoading={ isLoading }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tselection={ selection }\n\t\t\t\tsetOpenedFilter={ setOpenedFilter }\n\t\t\t\tonClickItem={ onClickItem }\n\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\tisItemClickable={ isItemClickable }\n\t\t\t\tview={ view }\n\t\t\t\tempty={ empty }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAQA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,UAAU;AAKnB,OAAO,sBAAsB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AA0BxB;AAnBK,SAAR,gBAAkC,EAAE,UAAU,GAA0B;AAC9E,QAAM;AA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