@wordpress/dataviews 12.1.1-next.v.202602241322.0 → 13.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 +22 -1
- package/README.md +132 -14
- package/build/components/dataform-layouts/card/index.cjs +12 -7
- package/build/components/dataform-layouts/card/index.cjs.map +2 -2
- package/build/components/dataform-layouts/panel/utils/get-label-content.cjs +2 -2
- package/build/components/dataform-layouts/panel/utils/get-label-content.cjs.map +2 -2
- package/build/components/dataviews-context/index.cjs +1 -0
- package/build/components/dataviews-context/index.cjs.map +2 -2
- package/build/components/dataviews-filters/toggle.cjs +6 -2
- package/build/components/dataviews-filters/toggle.cjs.map +2 -2
- package/build/components/dataviews-footer/index.cjs +28 -12
- package/build/components/dataviews-footer/index.cjs.map +3 -3
- package/build/components/dataviews-item-actions/index.cjs +0 -1
- package/build/components/dataviews-item-actions/index.cjs.map +2 -2
- package/build/components/dataviews-layout/index.cjs +4 -0
- package/build/components/dataviews-layout/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/activity/index.cjs +41 -26
- package/build/components/dataviews-layouts/activity/index.cjs.map +3 -3
- package/build/components/dataviews-layouts/grid/composite-grid.cjs +2 -0
- package/build/components/dataviews-layouts/grid/composite-grid.cjs.map +2 -2
- package/build/components/dataviews-layouts/grid/index.cjs +19 -14
- package/build/components/dataviews-layouts/grid/index.cjs.map +3 -3
- package/build/components/dataviews-layouts/list/index.cjs +25 -12
- package/build/components/dataviews-layouts/list/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/table/index.cjs +40 -19
- package/build/components/dataviews-layouts/table/index.cjs.map +2 -2
- package/build/dataviews/index.cjs +9 -2
- package/build/dataviews/index.cjs.map +3 -3
- package/build/dataviews-picker/index.cjs +1 -0
- package/build/dataviews-picker/index.cjs.map +2 -2
- package/build/hooks/use-data.cjs +46 -0
- package/build/hooks/use-data.cjs.map +7 -0
- package/build/hooks/use-delayed-loading.cjs +47 -0
- package/build/hooks/use-delayed-loading.cjs.map +7 -0
- package/build-module/components/dataform-layouts/card/index.mjs +12 -7
- package/build-module/components/dataform-layouts/card/index.mjs.map +2 -2
- package/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs +3 -3
- package/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs.map +2 -2
- package/build-module/components/dataviews-context/index.mjs +1 -0
- package/build-module/components/dataviews-context/index.mjs.map +2 -2
- package/build-module/components/dataviews-filters/toggle.mjs +6 -2
- package/build-module/components/dataviews-filters/toggle.mjs.map +2 -2
- package/build-module/components/dataviews-footer/index.mjs +28 -12
- package/build-module/components/dataviews-footer/index.mjs.map +2 -2
- package/build-module/components/dataviews-item-actions/index.mjs +0 -1
- package/build-module/components/dataviews-item-actions/index.mjs.map +2 -2
- package/build-module/components/dataviews-layout/index.mjs +4 -0
- package/build-module/components/dataviews-layout/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/activity/index.mjs +41 -26
- package/build-module/components/dataviews-layouts/activity/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/grid/composite-grid.mjs +2 -0
- package/build-module/components/dataviews-layouts/grid/composite-grid.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/grid/index.mjs +19 -14
- package/build-module/components/dataviews-layouts/grid/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/list/index.mjs +25 -12
- package/build-module/components/dataviews-layouts/list/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/table/index.mjs +40 -19
- package/build-module/components/dataviews-layouts/table/index.mjs.map +2 -2
- package/build-module/dataviews/index.mjs +9 -2
- package/build-module/dataviews/index.mjs.map +2 -2
- package/build-module/dataviews-picker/index.mjs +1 -0
- package/build-module/dataviews-picker/index.mjs.map +2 -2
- package/build-module/hooks/use-data.mjs +25 -0
- package/build-module/hooks/use-data.mjs.map +7 -0
- package/build-module/hooks/use-delayed-loading.mjs +22 -0
- package/build-module/hooks/use-delayed-loading.mjs.map +7 -0
- package/build-style/style-rtl.css +91 -19
- package/build-style/style.css +91 -19
- package/build-types/components/dataform-layouts/card/index.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/panel/utils/get-label-content.d.ts +1 -1
- package/build-types/components/dataform-layouts/panel/utils/get-label-content.d.ts.map +1 -1
- package/build-types/components/dataviews-context/index.d.ts +1 -0
- package/build-types/components/dataviews-context/index.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/toggle.d.ts.map +1 -1
- package/build-types/components/dataviews-footer/index.d.ts +1 -1
- package/build-types/components/dataviews-footer/index.d.ts.map +1 -1
- package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layout/index.d.ts +1 -1
- package/build-types/components/dataviews-layout/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/activity/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/grid/composite-grid.d.ts +2 -1
- package/build-types/components/dataviews-layouts/grid/composite-grid.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/grid/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/list/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/table/index.d.ts.map +1 -1
- package/build-types/dataform/stories/layout-panel.d.ts.map +1 -1
- package/build-types/dataviews/index.d.ts.map +1 -1
- package/build-types/dataviews/stories/empty.d.ts.map +1 -1
- package/build-types/dataviews/stories/free-composition.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-table.d.ts.map +1 -1
- package/build-types/dataviews/stories/minimal-ui.d.ts.map +1 -1
- package/build-types/dataviews/stories/with-card.d.ts.map +1 -1
- package/build-types/dataviews-picker/index.d.ts.map +1 -1
- package/build-types/hooks/use-data.d.ts +12 -0
- package/build-types/hooks/use-data.d.ts.map +1 -0
- package/build-types/hooks/use-delayed-loading.d.ts +4 -0
- package/build-types/hooks/use-delayed-loading.d.ts.map +1 -0
- package/build-wp/index.js +263 -135
- package/package.json +16 -19
- package/src/components/dataform-layouts/card/index.tsx +8 -9
- package/src/components/dataform-layouts/card/style.scss +1 -0
- package/src/components/dataform-layouts/panel/style.scss +2 -0
- package/src/components/dataform-layouts/panel/utils/get-label-content.tsx +3 -5
- package/src/components/dataform-layouts/regular/style.scss +3 -2
- package/src/components/dataviews-context/index.ts +2 -0
- package/src/components/dataviews-filters/toggle.tsx +9 -2
- package/src/components/dataviews-footer/index.tsx +39 -12
- package/src/components/dataviews-footer/style.scss +6 -1
- package/src/components/dataviews-item-actions/index.tsx +0 -3
- package/src/components/dataviews-item-actions/style.scss +7 -0
- package/src/components/dataviews-layout/index.tsx +5 -0
- package/src/components/dataviews-layouts/activity/index.tsx +29 -22
- package/src/components/dataviews-layouts/activity/style.scss +5 -0
- package/src/components/dataviews-layouts/grid/composite-grid.tsx +4 -0
- package/src/components/dataviews-layouts/grid/index.tsx +19 -22
- package/src/components/dataviews-layouts/grid/style.scss +5 -0
- package/src/components/dataviews-layouts/list/index.tsx +39 -21
- package/src/components/dataviews-layouts/list/style.scss +5 -9
- package/src/components/dataviews-layouts/table/index.tsx +48 -22
- package/src/components/dataviews-layouts/table/style.scss +6 -0
- package/src/dataform/stories/layout-card.tsx +2 -2
- package/src/dataform/stories/layout-panel.tsx +5 -1
- package/src/dataviews/index.tsx +10 -2
- package/src/dataviews/stories/empty.tsx +1 -7
- package/src/dataviews/stories/free-composition.tsx +0 -5
- package/src/dataviews/stories/layout-table.tsx +1 -7
- package/src/dataviews/stories/minimal-ui.tsx +0 -5
- package/src/dataviews/stories/with-card.tsx +1 -7
- package/src/dataviews/style.scss +25 -0
- package/src/dataviews-picker/index.tsx +1 -0
- package/src/hooks/use-data.ts +45 -0
- package/src/hooks/use-delayed-loading.ts +21 -0
|
@@ -97,7 +97,6 @@ function ActionsMenuGroup({
|
|
|
97
97
|
));
|
|
98
98
|
return /* @__PURE__ */ jsxs(Menu.Group, { children: [
|
|
99
99
|
renderActionGroup(primaryActions),
|
|
100
|
-
primaryActions.length > 0 && regularActions.length > 0 && /* @__PURE__ */ jsx(Menu.Separator, {}),
|
|
101
100
|
renderActionGroup(regularActions)
|
|
102
101
|
] });
|
|
103
102
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataviews-item-actions/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { MouseEventHandler } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { moreVertical } from '@wordpress/icons';\nimport { useRegistry } from '@wordpress/data';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport type { Action, ActionModal as ActionModalType } from '../../types';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nexport interface ActionTriggerProps< Item > {\n\taction: Action< Item >;\n\tonClick: MouseEventHandler;\n\tisBusy?: boolean;\n\titems: Item[];\n\tvariant?: 'primary' | 'secondary' | 'tertiary' | 'link';\n}\n\nexport interface ActionModalProps< Item > {\n\taction: ActionModalType< Item >;\n\titems: Item[];\n\tcloseModal: () => void;\n}\n\ninterface ActionsMenuGroupProps< Item > {\n\tactions: Action< Item >[];\n\titem: Item;\n\tregistry: ReturnType< typeof useRegistry >;\n\tsetActiveModalAction: ( action: ActionModalType< Item > | null ) => void;\n}\n\ninterface ItemActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tisCompact?: boolean;\n}\n\ninterface CompactItemActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tisSmall?: boolean;\n\tregistry: ReturnType< typeof useRegistry >;\n}\n\ninterface PrimaryActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tregistry: ReturnType< typeof useRegistry >;\n\tbuttonVariant?: 'primary' | 'secondary' | 'tertiary' | 'link';\n}\n\nfunction ButtonTrigger< Item >( {\n\taction,\n\tonClick,\n\titems,\n\tvariant,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Button\n\t\t\tdisabled={ !! action.disabled }\n\t\t\taccessibleWhenDisabled\n\t\t\tsize=\"compact\"\n\t\t\tvariant={ variant }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n\nfunction MenuItemTrigger< Item >( {\n\taction,\n\tonClick,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item disabled={ action.disabled } onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal< Item >( {\n\taction,\n\titems,\n\tcloseModal,\n}: ActionModalProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\n\tconst modalHeader =\n\t\ttypeof action.modalHeader === 'function'\n\t\t\t? action.modalHeader( items )\n\t\t\t: action.modalHeader;\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal }\n\t\t\tfocusOnMount={ action.modalFocusOnMount ?? true }\n\t\t\tsize={ action.modalSize || 'medium' }\n\t\t\toverlayClassName={ `dataviews-action-modal dataviews-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nexport function ActionsMenuGroup< Item >( {\n\tactions,\n\titem,\n\tregistry,\n\tsetActiveModalAction,\n}: ActionsMenuGroupProps< Item > ) {\n\tconst { primaryActions, regularActions } = useMemo( () => {\n\t\treturn actions.reduce(\n\t\t\t( acc, action ) => {\n\t\t\t\t( action.isPrimary\n\t\t\t\t\t? acc.primaryActions\n\t\t\t\t\t: acc.regularActions\n\t\t\t\t).push( action );\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{\n\t\t\t\tprimaryActions: [] as Action< Item >[],\n\t\t\t\tregularActions: [] as Action< Item >[],\n\t\t\t}\n\t\t);\n\t}, [ actions ] );\n\n\tconst renderActionGroup = ( actionList: Action< Item >[] ) =>\n\t\tactionList.map( ( action ) => (\n\t\t\t<MenuItemTrigger\n\t\t\t\tkey={ action.id }\n\t\t\t\taction={ action }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\taction.callback( [ item ], { registry } );\n\t\t\t\t} }\n\t\t\t\titems={ [ item ] }\n\t\t\t/>\n\t\t) );\n\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ renderActionGroup( primaryActions ) }\n\t\t\t{
|
|
5
|
-
"mappings": ";AAQA;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,UAAU;AACnB,SAAS,SAAS,gBAAgB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,aAAa;AAKtB,SAAS,cAAc;AAuDrB,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { MouseEventHandler } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tModal,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { moreVertical } from '@wordpress/icons';\nimport { useRegistry } from '@wordpress/data';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport type { Action, ActionModal as ActionModalType } from '../../types';\n\nconst { Menu, kebabCase } = unlock( componentsPrivateApis );\n\nexport interface ActionTriggerProps< Item > {\n\taction: Action< Item >;\n\tonClick: MouseEventHandler;\n\tisBusy?: boolean;\n\titems: Item[];\n\tvariant?: 'primary' | 'secondary' | 'tertiary' | 'link';\n}\n\nexport interface ActionModalProps< Item > {\n\taction: ActionModalType< Item >;\n\titems: Item[];\n\tcloseModal: () => void;\n}\n\ninterface ActionsMenuGroupProps< Item > {\n\tactions: Action< Item >[];\n\titem: Item;\n\tregistry: ReturnType< typeof useRegistry >;\n\tsetActiveModalAction: ( action: ActionModalType< Item > | null ) => void;\n}\n\ninterface ItemActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tisCompact?: boolean;\n}\n\ninterface CompactItemActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tisSmall?: boolean;\n\tregistry: ReturnType< typeof useRegistry >;\n}\n\ninterface PrimaryActionsProps< Item > {\n\titem: Item;\n\tactions: Action< Item >[];\n\tregistry: ReturnType< typeof useRegistry >;\n\tbuttonVariant?: 'primary' | 'secondary' | 'tertiary' | 'link';\n}\n\nfunction ButtonTrigger< Item >( {\n\taction,\n\tonClick,\n\titems,\n\tvariant,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Button\n\t\t\tdisabled={ !! action.disabled }\n\t\t\taccessibleWhenDisabled\n\t\t\tsize=\"compact\"\n\t\t\tvariant={ variant }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n\nfunction MenuItemTrigger< Item >( {\n\taction,\n\tonClick,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Menu.Item disabled={ action.disabled } onClick={ onClick }>\n\t\t\t<Menu.ItemLabel>{ label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n}\n\nexport function ActionModal< Item >( {\n\taction,\n\titems,\n\tcloseModal,\n}: ActionModalProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\n\tconst modalHeader =\n\t\ttypeof action.modalHeader === 'function'\n\t\t\t? action.modalHeader( items )\n\t\t\t: action.modalHeader;\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalHeader || label }\n\t\t\t__experimentalHideHeader={ !! action.hideModalHeader }\n\t\t\tonRequestClose={ closeModal }\n\t\t\tfocusOnMount={ action.modalFocusOnMount ?? true }\n\t\t\tsize={ action.modalSize || 'medium' }\n\t\t\toverlayClassName={ `dataviews-action-modal dataviews-action-modal__${ kebabCase(\n\t\t\t\taction.id\n\t\t\t) }` }\n\t\t>\n\t\t\t<action.RenderModal items={ items } closeModal={ closeModal } />\n\t\t</Modal>\n\t);\n}\n\nexport function ActionsMenuGroup< Item >( {\n\tactions,\n\titem,\n\tregistry,\n\tsetActiveModalAction,\n}: ActionsMenuGroupProps< Item > ) {\n\tconst { primaryActions, regularActions } = useMemo( () => {\n\t\treturn actions.reduce(\n\t\t\t( acc, action ) => {\n\t\t\t\t( action.isPrimary\n\t\t\t\t\t? acc.primaryActions\n\t\t\t\t\t: acc.regularActions\n\t\t\t\t).push( action );\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{\n\t\t\t\tprimaryActions: [] as Action< Item >[],\n\t\t\t\tregularActions: [] as Action< Item >[],\n\t\t\t}\n\t\t);\n\t}, [ actions ] );\n\n\tconst renderActionGroup = ( actionList: Action< Item >[] ) =>\n\t\tactionList.map( ( action ) => (\n\t\t\t<MenuItemTrigger\n\t\t\t\tkey={ action.id }\n\t\t\t\taction={ action }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\taction.callback( [ item ], { registry } );\n\t\t\t\t} }\n\t\t\t\titems={ [ item ] }\n\t\t\t/>\n\t\t) );\n\n\treturn (\n\t\t<Menu.Group>\n\t\t\t{ renderActionGroup( primaryActions ) }\n\t\t\t{ renderActionGroup( regularActions ) }\n\t\t</Menu.Group>\n\t);\n}\n\nexport default function ItemActions< Item >( {\n\titem,\n\tactions,\n\tisCompact,\n}: ItemActionsProps< Item > ) {\n\tconst registry = useRegistry();\n\tconst { primaryActions, eligibleActions } = useMemo( () => {\n\t\t// If an action is eligible for all items, doesn't need\n\t\t// to provide the `isEligible` function.\n\t\tconst _eligibleActions = actions.filter(\n\t\t\t( action ) => ! action.isEligible || action.isEligible( item )\n\t\t);\n\t\tconst _primaryActions = _eligibleActions.filter(\n\t\t\t( action ) => action.isPrimary\n\t\t);\n\t\treturn {\n\t\t\tprimaryActions: _primaryActions,\n\t\t\teligibleActions: _eligibleActions,\n\t\t};\n\t}, [ actions, item ] );\n\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tif ( isCompact ) {\n\t\treturn (\n\t\t\t<CompactItemActions\n\t\t\t\titem={ item }\n\t\t\t\tactions={ eligibleActions }\n\t\t\t\tisSmall\n\t\t\t\tregistry={ registry }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"row\"\n\t\t\tjustify=\"flex-end\"\n\t\t\tclassName=\"dataviews-item-actions\"\n\t\t\tstyle={ {\n\t\t\t\tflexShrink: 0,\n\t\t\t\twidth: 'auto',\n\t\t\t} }\n\t\t>\n\t\t\t<PrimaryActions\n\t\t\t\titem={ item }\n\t\t\t\tactions={ primaryActions }\n\t\t\t\tregistry={ registry }\n\t\t\t/>\n\t\t\t{ ( primaryActions.length < eligibleActions.length ||\n\t\t\t\t// Since we hide primary actions on mobile, we need to show the menu\n\t\t\t\t// there if there are any actions at all.\n\t\t\t\tisMobileViewport ) && (\n\t\t\t\t<CompactItemActions\n\t\t\t\t\titem={ item }\n\t\t\t\t\tactions={ eligibleActions }\n\t\t\t\t\tregistry={ registry }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction CompactItemActions< Item >( {\n\titem,\n\tactions,\n\tisSmall,\n\tregistry,\n}: CompactItemActionsProps< Item > ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState(\n\t\tnull as ActionModalType< Item > | null\n\t);\n\treturn (\n\t\t<>\n\t\t\t<Menu placement=\"bottom-end\">\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tsize={ isSmall ? 'small' : 'compact' }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\tdisabled={ ! actions.length }\n\t\t\t\t\t\t\tclassName=\"dataviews-all-actions-button\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Menu.Popover>\n\t\t\t\t\t<ActionsMenuGroup\n\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\tregistry={ registry }\n\t\t\t\t\t\tsetActiveModalAction={ setActiveModalAction }\n\t\t\t\t\t/>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport function PrimaryActions< Item >( {\n\titem,\n\tactions,\n\tregistry,\n\tbuttonVariant,\n}: PrimaryActionsProps< Item > ) {\n\tconst [ activeModalAction, setActiveModalAction ] = useState( null as any );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tif ( isMobileViewport ) {\n\t\treturn null;\n\t}\n\n\tif ( ! Array.isArray( actions ) || actions.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t{ actions.map( ( action ) => (\n\t\t\t\t<ButtonTrigger\n\t\t\t\t\tkey={ action.id }\n\t\t\t\t\taction={ action }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( 'RenderModal' in action ) {\n\t\t\t\t\t\t\tsetActiveModalAction( action );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\taction.callback( [ item ], { registry } );\n\t\t\t\t\t} }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\tvariant={ buttonVariant }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ !! activeModalAction && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ activeModalAction }\n\t\t\t\t\titems={ [ item ] }\n\t\t\t\t\tcloseModal={ () => setActiveModalAction( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAQA;AAAA,EACC;AAAA,EACA;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,UAAU;AACnB,SAAS,SAAS,gBAAgB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,aAAa;AAKtB,SAAS,cAAc;AAuDrB,SA6KA,UA7KA,KA6FA,YA7FA;AApDF,IAAM,EAAE,MAAM,UAAU,IAAI,OAAQ,qBAAsB;AA2C1D,SAAS,cAAuB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAgC;AAC/B,QAAM,QACL,OAAO,OAAO,UAAU,WAAW,OAAO,QAAQ,OAAO,MAAO,KAAM;AACvE,SACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAW,CAAC,CAAE,OAAO;AAAA,MACrB,wBAAsB;AAAA,MACtB,MAAK;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AChB;AAAA,MAAC;AAAA;AAAA,QAEA;AAAA,QACA,SAAU,MAAM;AACf,cAAK,iBAAiB,QAAS;AAC9B,iCAAsB,MAAO;AAC7B;AAAA,UACD;AACA,iBAAO,SAAU,CAAE,IAAK,GAAG,EAAE,SAAS,CAAE;AAAA,QACzC;AAAA,QACA,OAAQ,CAAE,IAAK;AAAA,QACf,SAAU;AAAA;AAAA,MAVJ,OAAO;AAAA,IAWd,CACC;AAAA,IACA,CAAC,CAAE,qBACJ;AAAA,MAAC;AAAA;AAAA,QACA,QAAS;AAAA,QACT,OAAQ,CAAE,IAAK;AAAA,QACf,YAAa,MAAM,qBAAsB,IAAK;AAAA;AAAA,IAC/C;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -11,6 +11,7 @@ function DataViewsLayout({ className }) {
|
|
|
11
11
|
fields,
|
|
12
12
|
getItemId,
|
|
13
13
|
getItemLevel,
|
|
14
|
+
hasInitiallyLoaded,
|
|
14
15
|
isLoading,
|
|
15
16
|
view,
|
|
16
17
|
onChangeView,
|
|
@@ -23,6 +24,9 @@ function DataViewsLayout({ className }) {
|
|
|
23
24
|
defaultLayouts,
|
|
24
25
|
empty = /* @__PURE__ */ jsx("p", { children: __("No results") })
|
|
25
26
|
} = useContext(DataViewsContext);
|
|
27
|
+
if (!hasInitiallyLoaded) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
26
30
|
const ViewComponent = VIEW_LAYOUTS.find(
|
|
27
31
|
(v) => v.type === view.type && defaultLayouts[v.type]
|
|
28
32
|
)?.component;
|
|
@@ -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\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\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 { __ } 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;AAyBnB;AAlBK,SAAR,gBAAkC,EAAE,UAAU,GAA0B;AAC9E,QAAM;AAAA,IACL,UAAU,CAAC;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,oBAAC,OAAI,aAAI,YAAa,GAAG;AAAA,EAClC,IAAI,WAAY,gBAAiB;AAEjC,MAAK,CAAE,oBAAqB;AAC3B,WAAO;AAAA,EACR;AAEA,QAAM,gBAAgB,aAAa;AAAA,IAClC,CAAE,MAAO,EAAE,SAAS,KAAK,QAAQ,eAAgB,EAAE,IAAK;AAAA,EACzD,GAAG;AAEH,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,46 +5,60 @@ import { Stack } from "@wordpress/ui";
|
|
|
5
5
|
import getDataByGroup from "../utils/get-data-by-group.mjs";
|
|
6
6
|
import ActivityGroup from "./activity-group.mjs";
|
|
7
7
|
import ActivityItems from "./activity-items.mjs";
|
|
8
|
+
import { useDelayedLoading } from "../../../hooks/use-delayed-loading.mjs";
|
|
8
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
function ViewActivity(props) {
|
|
10
11
|
const { empty, data, fields, isLoading, view, className } = props;
|
|
11
|
-
const
|
|
12
|
+
const isDelayedLoading = useDelayedLoading(!!isLoading);
|
|
13
|
+
const hasData = !!data?.length;
|
|
14
|
+
const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
|
|
15
|
+
const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
|
|
16
|
+
const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
|
|
12
17
|
if (!hasData) {
|
|
13
18
|
return /* @__PURE__ */ jsx(
|
|
14
19
|
"div",
|
|
15
20
|
{
|
|
16
|
-
className: clsx({
|
|
17
|
-
"
|
|
18
|
-
"dataviews-no-results": !hasData && !isLoading
|
|
21
|
+
className: clsx("dataviews-no-results", {
|
|
22
|
+
"is-refreshing": isDelayedLoading
|
|
19
23
|
}),
|
|
20
|
-
children:
|
|
24
|
+
children: empty
|
|
21
25
|
}
|
|
22
26
|
);
|
|
23
27
|
}
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
28
|
+
const isInert = !isInfiniteScroll && !!isLoading;
|
|
29
|
+
const wrapperClassName = clsx("dataviews-view-activity", className, {
|
|
30
|
+
"is-refreshing": !isInfiniteScroll && isDelayedLoading
|
|
31
|
+
});
|
|
27
32
|
const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
|
|
28
33
|
if (hasData && groupField && dataByGroup) {
|
|
29
|
-
return /* @__PURE__ */ jsx(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
return /* @__PURE__ */ jsx(
|
|
35
|
+
Stack,
|
|
36
|
+
{
|
|
37
|
+
direction: "column",
|
|
38
|
+
gap: "sm",
|
|
39
|
+
className: wrapperClassName,
|
|
40
|
+
inert: isInert ? "true" : void 0,
|
|
41
|
+
children: groupedEntries.map(
|
|
42
|
+
([groupName, groupData]) => /* @__PURE__ */ jsx(
|
|
43
|
+
ActivityGroup,
|
|
39
44
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
groupName,
|
|
46
|
+
groupData,
|
|
47
|
+
groupField,
|
|
48
|
+
showLabel: view.groupBy?.showLabel !== false,
|
|
49
|
+
children: /* @__PURE__ */ jsx(
|
|
50
|
+
ActivityItems,
|
|
51
|
+
{
|
|
52
|
+
...props,
|
|
53
|
+
data: groupData
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
},
|
|
57
|
+
groupName
|
|
43
58
|
)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
) });
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
);
|
|
48
62
|
}
|
|
49
63
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
50
64
|
/* @__PURE__ */ jsx(
|
|
@@ -52,10 +66,11 @@ function ViewActivity(props) {
|
|
|
52
66
|
{
|
|
53
67
|
className: wrapperClassName,
|
|
54
68
|
role: view.infiniteScrollEnabled ? "feed" : void 0,
|
|
69
|
+
inert: isInert ? "true" : void 0,
|
|
55
70
|
children: /* @__PURE__ */ jsx(ActivityItems, { ...props })
|
|
56
71
|
}
|
|
57
72
|
),
|
|
58
|
-
|
|
73
|
+
isInfiniteScroll && isLoading && /* @__PURE__ */ jsx("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ jsx(Spinner, {}) })
|
|
59
74
|
] });
|
|
60
75
|
}
|
|
61
76
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/dataviews-layouts/activity/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Spinner } from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type { ViewActivityProps } from '../../../types';\nimport getDataByGroup from '../utils/get-data-by-group';\nimport ActivityGroup from './activity-group';\nimport ActivityItems from './activity-items';\n\nexport default function ViewActivity< Item >(\n\tprops: ViewActivityProps< Item >\n) {\n\tconst { empty, data, fields, isLoading, view, className } = props;\n\n\
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,eAAe;AACxB,SAAS,aAAa;AAMtB,OAAO,oBAAoB;AAC3B,OAAO,mBAAmB;AAC1B,OAAO,mBAAmB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Spinner } from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type { ViewActivityProps } from '../../../types';\nimport getDataByGroup from '../utils/get-data-by-group';\nimport ActivityGroup from './activity-group';\nimport ActivityItems from './activity-items';\nimport { useDelayedLoading } from '../../../hooks/use-delayed-loading';\n\nexport default function ViewActivity< Item >(\n\tprops: ViewActivityProps< Item >\n) {\n\tconst { empty, data, fields, isLoading, view, className } = props;\n\n\tconst isDelayedLoading = useDelayedLoading( !! isLoading );\n\tconst hasData = !! data?.length;\n\n\t// Check if data should be grouped\n\tconst groupField = view.groupBy?.field\n\t\t? fields.find( ( field ) => field.id === view.groupBy?.field )\n\t\t: null;\n\tconst dataByGroup =\n\t\thasData && groupField ? getDataByGroup( data, groupField ) : null;\n\n\tconst isInfiniteScroll = view.infiniteScrollEnabled && ! dataByGroup;\n\tif ( ! hasData ) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'dataviews-no-results', {\n\t\t\t\t\t'is-refreshing': isDelayedLoading,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ empty }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst isInert = ! isInfiniteScroll && !! isLoading;\n\tconst wrapperClassName = clsx( 'dataviews-view-activity', className, {\n\t\t'is-refreshing': ! isInfiniteScroll && isDelayedLoading,\n\t} );\n\n\t// Convert dataByGroup entries into array.\n\tconst groupedEntries = dataByGroup\n\t\t? Array.from( dataByGroup.entries() )\n\t\t: [];\n\n\t// Render grouped activity\n\tif ( hasData && groupField && dataByGroup ) {\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"sm\"\n\t\t\t\tclassName={ wrapperClassName }\n\t\t\t\t// @ts-ignore\n\t\t\t\tinert={ isInert ? 'true' : undefined }\n\t\t\t>\n\t\t\t\t{ groupedEntries.map(\n\t\t\t\t\t( [ groupName, groupData ]: [ string, Item[] ] ) => (\n\t\t\t\t\t\t<ActivityGroup< Item >\n\t\t\t\t\t\t\tkey={ groupName }\n\t\t\t\t\t\t\tgroupName={ groupName }\n\t\t\t\t\t\t\tgroupData={ groupData }\n\t\t\t\t\t\t\tgroupField={ groupField }\n\t\t\t\t\t\t\tshowLabel={ view.groupBy?.showLabel !== false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ActivityItems< Item >\n\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\tdata={ groupData }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ActivityGroup>\n\t\t\t\t\t)\n\t\t\t\t) }\n\t\t\t</Stack>\n\t\t);\n\t}\n\n\t// Render flat activity (no grouping)\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tclassName={ wrapperClassName }\n\t\t\t\trole={ view.infiniteScrollEnabled ? 'feed' : undefined }\n\t\t\t\t// @ts-ignore\n\t\t\t\tinert={ isInert ? 'true' : undefined }\n\t\t\t>\n\t\t\t\t<ActivityItems< Item > { ...props } />\n\t\t\t</div>\n\t\t\t{ isInfiniteScroll && isLoading && (\n\t\t\t\t<p className=\"dataviews-loading-more\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,eAAe;AACxB,SAAS,aAAa;AAMtB,OAAO,oBAAoB;AAC3B,OAAO,mBAAmB;AAC1B,OAAO,mBAAmB;AAC1B,SAAS,yBAAyB;AAoB/B,SAoDD,UApDC,KAoDD,YApDC;AAlBY,SAAR,aACN,OACC;AACD,QAAM,EAAE,OAAO,MAAM,QAAQ,WAAW,MAAM,UAAU,IAAI;AAE5D,QA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8BAAC,iBAAwB,GAAG,OAAQ;AAAA;AAAA,IACrC;AAAA,IACE,oBAAoB,aACrB,oBAAC,OAAE,WAAU,0BACZ,8BAAC,WAAQ,GACV;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -235,6 +235,7 @@ function CompositeGrid({
|
|
|
235
235
|
data,
|
|
236
236
|
isInfiniteScroll,
|
|
237
237
|
className,
|
|
238
|
+
inert,
|
|
238
239
|
isLoading,
|
|
239
240
|
view,
|
|
240
241
|
fields,
|
|
@@ -282,6 +283,7 @@ function CompositeGrid({
|
|
|
282
283
|
"aria-busy": isLoading,
|
|
283
284
|
"aria-rowcount": isInfiniteScroll ? void 0 : totalRows,
|
|
284
285
|
ref: resizeObserverRef,
|
|
286
|
+
inert,
|
|
285
287
|
children: chunk(data, gridColumns).map((row, i) => /* @__PURE__ */ jsx(
|
|
286
288
|
Composite.Row,
|
|
287
289
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/dataviews-layouts/grid/composite-grid.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ComponentProps, ReactElement, HTMLAttributes } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tFlex,\n\tFlexItem,\n\tTooltip,\n\tComposite,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { isAppleOS } from '@wordpress/keycodes';\nimport { useContext, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\nimport ItemActions from '../../dataviews-item-actions';\nimport DataViewsSelectionCheckbox from '../../dataviews-selection-checkbox';\nimport DataViewsContext from '../../dataviews-context';\nimport {\n\tuseHasAPossibleBulkAction,\n\tuseSomeItemHasAPossibleBulkAction,\n} from '../../dataviews-bulk-actions';\nimport type {\n\tAction,\n\tNormalizedField,\n\tViewGrid as ViewGridType,\n} from '../../../types';\nimport type { SetSelection } from '../../../types/private';\nimport { ItemClickWrapper } from '../utils/item-click-wrapper';\nconst { Badge } = unlock( componentsPrivateApis );\nimport { useGridColumns } from './preview-size-picker';\n\nfunction chunk< T >( array: T[], size: number ): T[][] {\n\tconst chunks: T[][] = [];\n\tfor ( let i = 0, j = array.length; i < j; i += size ) {\n\t\tchunks.push( array.slice( i, i + size ) );\n\t}\n\treturn chunks;\n}\n\ninterface GridItemProps< Item > extends HTMLAttributes< HTMLDivElement > {\n\tview: ViewGridType;\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tgetItemId: ( item: Item ) => string;\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\titem: Item;\n\tactions: Action< Item >[];\n\ttitleField?: NormalizedField< Item >;\n\tmediaField?: NormalizedField< Item >;\n\tdescriptionField?: NormalizedField< Item >;\n\tregularFields: NormalizedField< Item >[];\n\tbadgeFields: NormalizedField< Item >[];\n\thasBulkActions: boolean;\n\tconfig: {\n\t\tsizes: string;\n\t};\n}\n\nconst GridItem = forwardRef( function GridItem< Item >(\n\t{\n\t\tview,\n\t\tselection,\n\t\tonChangeSelection,\n\t\tonClickItem,\n\t\tisItemClickable,\n\t\trenderItemLink,\n\t\tgetItemId,\n\t\titem,\n\t\tactions,\n\t\tmediaField,\n\t\ttitleField,\n\t\tdescriptionField,\n\t\tregularFields,\n\t\tbadgeFields,\n\t\thasBulkActions,\n\t\tconfig,\n\t\t...props\n\t}: GridItemProps< Item >,\n\tref: React.ForwardedRef< HTMLDivElement >\n) {\n\tconst { showTitle = true, showMedia = true, showDescription = true } = view;\n\tconst hasBulkAction = useHasAPossibleBulkAction( actions, item );\n\tconst id = getItemId( item );\n\tconst instanceId = useInstanceId( GridItem );\n\tconst isSelected = selection.includes( id );\n\tconst mediaPlaceholder = (\n\t\t<span className=\"dataviews-view-grid__media-placeholder\" />\n\t);\n\tconst rendersMediaField = showMedia && mediaField?.render;\n\tconst renderedMediaField = rendersMediaField ? (\n\t\t<mediaField.render\n\t\t\titem={ item }\n\t\t\tfield={ mediaField }\n\t\t\tconfig={ config }\n\t\t/>\n\t) : (\n\t\tmediaPlaceholder\n\t);\n\tconst renderedTitleField =\n\t\tshowTitle && titleField?.render ? (\n\t\t\t<titleField.render item={ item } field={ titleField } />\n\t\t) : null;\n\tlet mediaA11yProps;\n\tlet titleA11yProps;\n\tif ( isItemClickable( item ) && onClickItem ) {\n\t\tif ( renderedTitleField ) {\n\t\t\tmediaA11yProps = {\n\t\t\t\t'aria-labelledby': `dataviews-view-grid__title-field-${ instanceId }`,\n\t\t\t};\n\t\t\ttitleA11yProps = {\n\t\t\t\tid: `dataviews-view-grid__title-field-${ instanceId }`,\n\t\t\t};\n\t\t} else {\n\t\t\tmediaA11yProps = {\n\t\t\t\t'aria-label': __( 'Navigate to item' ),\n\t\t\t};\n\t\t}\n\t}\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\t{ ...props }\n\t\t\tref={ ref }\n\t\t\tclassName={ clsx(\n\t\t\t\tprops.className,\n\t\t\t\t'dataviews-view-grid__row__gridcell',\n\t\t\t\t'dataviews-view-grid__card',\n\t\t\t\t{\n\t\t\t\t\t'is-selected': hasBulkAction && isSelected,\n\t\t\t\t}\n\t\t\t) }\n\t\t\tonClickCapture={ ( event ) => {\n\t\t\t\tprops.onClickCapture?.( event );\n\t\t\t\tif ( isAppleOS() ? event.metaKey : event.ctrlKey ) {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( ! hasBulkAction ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\tselection.includes( id )\n\t\t\t\t\t\t\t? selection.filter( ( itemId ) => id !== itemId )\n\t\t\t\t\t\t\t: [ ...selection, id ]\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} }\n\t\t>\n\t\t\t<ItemClickWrapper\n\t\t\t\titem={ item }\n\t\t\t\tisItemClickable={ isItemClickable }\n\t\t\t\tonClickItem={ onClickItem }\n\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\tclassName={ clsx( 'dataviews-view-grid__media', {\n\t\t\t\t\t'dataviews-view-grid__media--placeholder':\n\t\t\t\t\t\t! rendersMediaField,\n\t\t\t\t} ) }\n\t\t\t\t{ ...mediaA11yProps }\n\t\t\t>\n\t\t\t\t{ renderedMediaField }\n\t\t\t</ItemClickWrapper>\n\t\t\t{ hasBulkActions && (\n\t\t\t\t<DataViewsSelectionCheckbox\n\t\t\t\t\titem={ item }\n\t\t\t\t\tselection={ selection }\n\t\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\ttitleField={ titleField }\n\t\t\t\t\tdisabled={ ! hasBulkAction }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! actions?.length && (\n\t\t\t\t<div className=\"dataviews-view-grid__media-actions\">\n\t\t\t\t\t<ItemActions item={ item } actions={ actions } isCompact />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ showTitle && (\n\t\t\t\t<div className=\"dataviews-view-grid__title\">\n\t\t\t\t\t<ItemClickWrapper\n\t\t\t\t\t\titem={ item }\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\tclassName=\"dataviews-view-grid__title-field dataviews-title-field\"\n\t\t\t\t\t\t{ ...titleA11yProps }\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\ttitleField?.getValueFormatted( {\n\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\tfield: titleField,\n\t\t\t\t\t\t\t} ) || undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ renderedTitleField }\n\t\t\t\t\t</ItemClickWrapper>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<Stack direction=\"column\" gap=\"xs\">\n\t\t\t\t{ showDescription && descriptionField?.render && (\n\t\t\t\t\t<descriptionField.render\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\tfield={ descriptionField }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ !! badgeFields?.length && (\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\tclassName=\"dataviews-view-grid__badge-fields\"\n\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\twrap=\"wrap\"\n\t\t\t\t\t\talign=\"top\"\n\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ badgeFields.map( ( field ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Badge\n\t\t\t\t\t\t\t\t\tkey={ field.id }\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-view-grid__field-value\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<field.render\n\t\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Badge>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</Stack>\n\t\t\t\t) }\n\t\t\t\t{ !! regularFields?.length && (\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\tclassName=\"dataviews-view-grid__fields\"\n\t\t\t\t\t\tgap=\"xs\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ regularFields.map( ( field ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-view-grid__field\"\n\t\t\t\t\t\t\t\t\tkey={ field.id }\n\t\t\t\t\t\t\t\t\tgap={ 1 }\n\t\t\t\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\t\t\t\texpanded\n\t\t\t\t\t\t\t\t\tstyle={ { height: 'auto' } }\n\t\t\t\t\t\t\t\t\tdirection=\"row\"\n\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\t\t<Tooltip text={ field.label }>\n\t\t\t\t\t\t\t\t\t\t\t<FlexItem className=\"dataviews-view-grid__field-name\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ field.header }\n\t\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"dataviews-view-grid__field-value\"\n\t\t\t\t\t\t\t\t\t\t\tstyle={ { maxHeight: 'none' } }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<field.render\n\t\t\t\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</Stack>\n\t\t\t\t) }\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n} ) as < Item >(\n\tprops: GridItemProps< Item > & {\n\t\tref?: React.ForwardedRef< HTMLDivElement >;\n\t}\n) => React.ReactNode;\n\ninterface CompositeGridProps< Item > {\n\tdata: Item[];\n\tisInfiniteScroll: boolean;\n\tclassName?: string;\n\tisLoading?: boolean;\n\tview: ViewGridType;\n\tfields: NormalizedField< Item >[];\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tonClickItem?: ( item: Item ) => void;\n\tisItemClickable: ( item: Item ) => boolean;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tgetItemId: ( item: Item ) => string;\n\tactions: Action< Item >[];\n}\n\nexport default function CompositeGrid< Item >( {\n\tdata,\n\tisInfiniteScroll,\n\tclassName,\n\tisLoading,\n\tview,\n\tfields,\n\tselection,\n\tonChangeSelection,\n\tonClickItem,\n\tisItemClickable,\n\trenderItemLink,\n\tgetItemId,\n\tactions,\n}: CompositeGridProps< Item > ) {\n\tconst { paginationInfo, resizeObserverRef } =\n\t\tuseContext( DataViewsContext );\n\tconst gridColumns = useGridColumns();\n\tconst hasBulkActions = useSomeItemHasAPossibleBulkAction( actions, data );\n\tconst titleField = fields.find(\n\t\t( field ) => field.id === view?.titleField\n\t);\n\tconst mediaField = fields.find(\n\t\t( field ) => field.id === view?.mediaField\n\t);\n\tconst descriptionField = fields.find(\n\t\t( field ) => field.id === view?.descriptionField\n\t);\n\tconst otherFields = view.fields ?? [];\n\tconst { regularFields, badgeFields } = otherFields.reduce(\n\t\t(\n\t\t\taccumulator: Record< string, NormalizedField< Item >[] >,\n\t\t\tfieldId\n\t\t) => {\n\t\t\tconst field = fields.find( ( f ) => f.id === fieldId );\n\t\t\tif ( ! field ) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\t\t\t// If the field is a badge field, add it to the badgeFields array\n\t\t\t// otherwise add it to the rest visibleFields array.\n\t\t\tconst key = view.layout?.badgeFields?.includes( fieldId )\n\t\t\t\t? 'badgeFields'\n\t\t\t\t: 'regularFields';\n\t\t\taccumulator[ key ].push( field );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ regularFields: [], badgeFields: [] }\n\t);\n\n\t/*\n\t * This is the maximum width that an image can achieve in the grid. The reasoning is:\n\t * The biggest min image width available is 430px (see /dataviews-layouts/grid/preview-size-picker.tsx).\n\t * Because the grid is responsive, once there is room for another column, the images shrink to accommodate it.\n\t * So each image will never grow past 2*430px plus a little more to account for the gaps.\n\t */\n\tconst size = '900px';\n\tconst totalRows = Math.ceil( data.length / gridColumns );\n\n\treturn (\n\t\t<Composite\n\t\t\trole={ isInfiniteScroll ? 'feed' : 'grid' }\n\t\t\tclassName={ clsx( 'dataviews-view-grid', className ) }\n\t\t\tfocusWrap\n\t\t\taria-busy={ isLoading }\n\t\t\taria-rowcount={ isInfiniteScroll ? undefined : totalRows }\n\t\t\tref={ resizeObserverRef }\n\t\t>\n\t\t\t{ chunk( data, gridColumns ).map( ( row, i ) => (\n\t\t\t\t<Composite.Row\n\t\t\t\t\tkey={ i }\n\t\t\t\t\trender={\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\trole=\"row\"\n\t\t\t\t\t\t\taria-rowindex={ i + 1 }\n\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %d: The row number in the grid */\n\t\t\t\t\t\t\t\t__( 'Row %d' ),\n\t\t\t\t\t\t\t\ti + 1\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tclassName=\"dataviews-view-grid__row\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tgridTemplateColumns: `repeat( ${ gridColumns }, minmax(0, 1fr) )`,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ row.map( ( item, indexInRow ) => {\n\t\t\t\t\t\tconst index = i * gridColumns + indexInRow;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\t\t\tkey={ getItemId( item ) }\n\t\t\t\t\t\t\t\trender={ ( props ) => (\n\t\t\t\t\t\t\t\t\t<GridItem\n\t\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\t\trole={\n\t\t\t\t\t\t\t\t\t\t\tisInfiniteScroll\n\t\t\t\t\t\t\t\t\t\t\t\t? 'article'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'gridcell'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-setsize={\n\t\t\t\t\t\t\t\t\t\t\tisInfiniteScroll\n\t\t\t\t\t\t\t\t\t\t\t\t? paginationInfo.totalItems\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\taria-posinset={\n\t\t\t\t\t\t\t\t\t\t\tisInfiniteScroll\n\t\t\t\t\t\t\t\t\t\t\t\t? index + 1\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\tview={ view }\n\t\t\t\t\t\t\t\t\t\tselection={ selection }\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\tisItemClickable={ isItemClickable }\n\t\t\t\t\t\t\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\t\t\t\t\tmediaField={ mediaField }\n\t\t\t\t\t\t\t\t\t\ttitleField={ titleField }\n\t\t\t\t\t\t\t\t\t\tdescriptionField={ descriptionField }\n\t\t\t\t\t\t\t\t\t\tregularFields={ regularFields }\n\t\t\t\t\t\t\t\t\t\tbadgeFields={ badgeFields }\n\t\t\t\t\t\t\t\t\t\thasBulkActions={ hasBulkActions }\n\t\t\t\t\t\t\t\t\t\tconfig={ {\n\t\t\t\t\t\t\t\t\t\t\tsizes: size,\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\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YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,WAAU;AAAA,cACV,KAAI;AAAA,cAEF,wBAAc,IAAK,CAAE,UAAW;AACjC,uBACC;AAAA,kBAAC;AAAA;AAAA,oBACA,WAAU;AAAA,oBAEV,KAAM;AAAA,oBACN,SAAQ;AAAA,oBACR,UAAQ;AAAA,oBACR,OAAQ,EAAE,QAAQ,OAAO;AAAA,oBACzB,WAAU;AAAA,oBAEV,2CACC;AAAA,0CAAC,WAAQ,MAAO,MAAM,OACrB,8BAAC,YAAS,WAAU,mCACjB,gBAAM,QACT,GACD;AAAA,sBACA;AAAA,wBAAC;AAAA;AAAA,0BACA,WAAU;AAAA,0BACV,OAAQ,EAAE,WAAW,OAAO;AAAA,0BAE5B;AAAA,4BAAC,MAAM;AAAA,4BAAN;AAAA,8BACA;AAAA,8BACA;AAAA;AAAA,0BACD;AAAA;AAAA,sBACD;AAAA,uBACD;AAAA;AAAA,kBAtBM,MAAM;AAAA,gBAuBb;AAAA,cAEF,CAAE;AAAA;AAAA,UACH;AAAA,WAEF;AAAA;AAAA;AAAA,EACD;AAEF,CAAE;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ComponentProps, ReactElement, HTMLAttributes } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tFlex,\n\tFlexItem,\n\tTooltip,\n\tComposite,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { isAppleOS } from '@wordpress/keycodes';\nimport { useContext, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\nimport ItemActions from '../../dataviews-item-actions';\nimport DataViewsSelectionCheckbox from '../../dataviews-selection-checkbox';\nimport DataViewsContext from '../../dataviews-context';\nimport {\n\tuseHasAPossibleBulkAction,\n\tuseSomeItemHasAPossibleBulkAction,\n} from '../../dataviews-bulk-actions';\nimport type {\n\tAction,\n\tNormalizedField,\n\tViewGrid as ViewGridType,\n} from '../../../types';\nimport type { SetSelection } from '../../../types/private';\nimport { ItemClickWrapper } from '../utils/item-click-wrapper';\nconst { Badge } = unlock( componentsPrivateApis );\nimport { useGridColumns } from './preview-size-picker';\n\nfunction chunk< T >( array: T[], size: number ): T[][] {\n\tconst chunks: T[][] = [];\n\tfor ( let i = 0, j = array.length; i < j; i += size ) {\n\t\tchunks.push( array.slice( i, i + size ) );\n\t}\n\treturn chunks;\n}\n\ninterface GridItemProps< Item > extends HTMLAttributes< HTMLDivElement > {\n\tview: ViewGridType;\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tgetItemId: ( item: Item ) => string;\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\titem: Item;\n\tactions: Action< Item >[];\n\ttitleField?: NormalizedField< Item >;\n\tmediaField?: NormalizedField< Item >;\n\tdescriptionField?: NormalizedField< Item >;\n\tregularFields: NormalizedField< Item >[];\n\tbadgeFields: NormalizedField< Item >[];\n\thasBulkActions: boolean;\n\tconfig: {\n\t\tsizes: string;\n\t};\n}\n\nconst GridItem = forwardRef( function GridItem< Item >(\n\t{\n\t\tview,\n\t\tselection,\n\t\tonChangeSelection,\n\t\tonClickItem,\n\t\tisItemClickable,\n\t\trenderItemLink,\n\t\tgetItemId,\n\t\titem,\n\t\tactions,\n\t\tmediaField,\n\t\ttitleField,\n\t\tdescriptionField,\n\t\tregularFields,\n\t\tbadgeFields,\n\t\thasBulkActions,\n\t\tconfig,\n\t\t...props\n\t}: GridItemProps< Item >,\n\tref: React.ForwardedRef< HTMLDivElement >\n) {\n\tconst { showTitle = true, showMedia = true, showDescription = true } = view;\n\tconst hasBulkAction = useHasAPossibleBulkAction( actions, item );\n\tconst id = getItemId( item );\n\tconst instanceId = useInstanceId( GridItem );\n\tconst isSelected = selection.includes( id );\n\tconst mediaPlaceholder = (\n\t\t<span className=\"dataviews-view-grid__media-placeholder\" />\n\t);\n\tconst rendersMediaField = showMedia && mediaField?.render;\n\tconst renderedMediaField = rendersMediaField ? (\n\t\t<mediaField.render\n\t\t\titem={ item }\n\t\t\tfield={ mediaField }\n\t\t\tconfig={ config }\n\t\t/>\n\t) : (\n\t\tmediaPlaceholder\n\t);\n\tconst renderedTitleField =\n\t\tshowTitle && titleField?.render ? (\n\t\t\t<titleField.render item={ item } field={ titleField } />\n\t\t) : null;\n\tlet mediaA11yProps;\n\tlet titleA11yProps;\n\tif ( isItemClickable( item ) && onClickItem ) {\n\t\tif ( renderedTitleField ) {\n\t\t\tmediaA11yProps = {\n\t\t\t\t'aria-labelledby': `dataviews-view-grid__title-field-${ instanceId }`,\n\t\t\t};\n\t\t\ttitleA11yProps = {\n\t\t\t\tid: `dataviews-view-grid__title-field-${ instanceId }`,\n\t\t\t};\n\t\t} else {\n\t\t\tmediaA11yProps = {\n\t\t\t\t'aria-label': __( 'Navigate to item' ),\n\t\t\t};\n\t\t}\n\t}\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\t{ ...props }\n\t\t\tref={ ref }\n\t\t\tclassName={ clsx(\n\t\t\t\tprops.className,\n\t\t\t\t'dataviews-view-grid__row__gridcell',\n\t\t\t\t'dataviews-view-grid__card',\n\t\t\t\t{\n\t\t\t\t\t'is-selected': hasBulkAction && isSelected,\n\t\t\t\t}\n\t\t\t) }\n\t\t\tonClickCapture={ ( event ) => {\n\t\t\t\tprops.onClickCapture?.( event );\n\t\t\t\tif ( isAppleOS() ? event.metaKey : event.ctrlKey ) {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( ! hasBulkAction ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\tselection.includes( id )\n\t\t\t\t\t\t\t? selection.filter( ( itemId ) => id !== itemId )\n\t\t\t\t\t\t\t: [ ...selection, id ]\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} }\n\t\t>\n\t\t\t<ItemClickWrapper\n\t\t\t\titem={ item }\n\t\t\t\tisItemClickable={ isItemClickable }\n\t\t\t\tonClickItem={ onClickItem }\n\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\tclassName={ clsx( 'dataviews-view-grid__media', {\n\t\t\t\t\t'dataviews-view-grid__media--placeholder':\n\t\t\t\t\t\t! rendersMediaField,\n\t\t\t\t} ) }\n\t\t\t\t{ ...mediaA11yProps }\n\t\t\t>\n\t\t\t\t{ renderedMediaField }\n\t\t\t</ItemClickWrapper>\n\t\t\t{ hasBulkActions && (\n\t\t\t\t<DataViewsSelectionCheckbox\n\t\t\t\t\titem={ item }\n\t\t\t\t\tselection={ selection }\n\t\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\ttitleField={ titleField }\n\t\t\t\t\tdisabled={ ! hasBulkAction }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! actions?.length && (\n\t\t\t\t<div className=\"dataviews-view-grid__media-actions\">\n\t\t\t\t\t<ItemActions item={ item } actions={ actions } isCompact />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ showTitle && (\n\t\t\t\t<div className=\"dataviews-view-grid__title\">\n\t\t\t\t\t<ItemClickWrapper\n\t\t\t\t\t\titem={ item }\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\tclassName=\"dataviews-view-grid__title-field dataviews-title-field\"\n\t\t\t\t\t\t{ ...titleA11yProps }\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\ttitleField?.getValueFormatted( {\n\t\t\t\t\t\t\t\titem,\n\t\t\t\t\t\t\t\tfield: titleField,\n\t\t\t\t\t\t\t} ) || undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ renderedTitleField }\n\t\t\t\t\t</ItemClickWrapper>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<Stack direction=\"column\" gap=\"xs\">\n\t\t\t\t{ showDescription && descriptionField?.render && (\n\t\t\t\t\t<descriptionField.render\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\tfield={ descriptionField }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ !! badgeFields?.length && (\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\tclassName=\"dataviews-view-grid__badge-fields\"\n\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\twrap=\"wrap\"\n\t\t\t\t\t\talign=\"top\"\n\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ badgeFields.map( ( field ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Badge\n\t\t\t\t\t\t\t\t\tkey={ field.id }\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-view-grid__field-value\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<field.render\n\t\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Badge>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</Stack>\n\t\t\t\t) }\n\t\t\t\t{ !! regularFields?.length && (\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\tclassName=\"dataviews-view-grid__fields\"\n\t\t\t\t\t\tgap=\"xs\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ regularFields.map( ( field ) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-view-grid__field\"\n\t\t\t\t\t\t\t\t\tkey={ field.id }\n\t\t\t\t\t\t\t\t\tgap={ 1 }\n\t\t\t\t\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\t\t\t\t\texpanded\n\t\t\t\t\t\t\t\t\tstyle={ { height: 'auto' } }\n\t\t\t\t\t\t\t\t\tdirection=\"row\"\n\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\t\t<Tooltip text={ field.label }>\n\t\t\t\t\t\t\t\t\t\t\t<FlexItem className=\"dataviews-view-grid__field-name\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ field.header }\n\t\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t\t\t\t\t<FlexItem\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"dataviews-view-grid__field-value\"\n\t\t\t\t\t\t\t\t\t\t\tstyle={ { maxHeight: 'none' } }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<field.render\n\t\t\t\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</Stack>\n\t\t\t\t) }\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n} ) as < Item >(\n\tprops: GridItemProps< Item > & {\n\t\tref?: React.ForwardedRef< HTMLDivElement >;\n\t}\n) => React.ReactNode;\n\ninterface CompositeGridProps< Item > {\n\tdata: Item[];\n\tisInfiniteScroll: boolean;\n\tclassName?: string;\n\tinert?: string;\n\tisLoading?: boolean;\n\tview: ViewGridType;\n\tfields: NormalizedField< Item >[];\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tonClickItem?: ( item: Item ) => void;\n\tisItemClickable: ( item: Item ) => boolean;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tgetItemId: ( item: Item ) => string;\n\tactions: Action< Item >[];\n}\n\nexport default function CompositeGrid< Item >( {\n\tdata,\n\tisInfiniteScroll,\n\tclassName,\n\tinert,\n\tisLoading,\n\tview,\n\tfields,\n\tselection,\n\tonChangeSelection,\n\tonClickItem,\n\tisItemClickable,\n\trenderItemLink,\n\tgetItemId,\n\tactions,\n}: CompositeGridProps< Item > ) {\n\tconst { paginationInfo, resizeObserverRef } =\n\t\tuseContext( DataViewsContext );\n\tconst gridColumns = useGridColumns();\n\tconst hasBulkActions = useSomeItemHasAPossibleBulkAction( actions, data );\n\tconst titleField = fields.find(\n\t\t( field ) => field.id === view?.titleField\n\t);\n\tconst mediaField = fields.find(\n\t\t( field ) => field.id === view?.mediaField\n\t);\n\tconst descriptionField = fields.find(\n\t\t( field ) => field.id === view?.descriptionField\n\t);\n\tconst otherFields = view.fields ?? [];\n\tconst { regularFields, badgeFields } = otherFields.reduce(\n\t\t(\n\t\t\taccumulator: Record< string, NormalizedField< Item >[] >,\n\t\t\tfieldId\n\t\t) => {\n\t\t\tconst field = fields.find( ( f ) => f.id === fieldId );\n\t\t\tif ( ! field ) {\n\t\t\t\treturn accumulator;\n\t\t\t}\n\t\t\t// If the field is a badge field, add it to the badgeFields array\n\t\t\t// otherwise add it to the rest visibleFields array.\n\t\t\tconst key = view.layout?.badgeFields?.includes( fieldId )\n\t\t\t\t? 'badgeFields'\n\t\t\t\t: 'regularFields';\n\t\t\taccumulator[ key ].push( field );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ regularFields: [], badgeFields: [] }\n\t);\n\n\t/*\n\t * This is the maximum width that an image can achieve in the grid. The reasoning is:\n\t * The biggest min image width available is 430px (see /dataviews-layouts/grid/preview-size-picker.tsx).\n\t * Because the grid is responsive, once there is room for another column, the images shrink to accommodate it.\n\t * So each image will never grow past 2*430px plus a little more to account for the gaps.\n\t */\n\tconst size = '900px';\n\tconst totalRows = Math.ceil( data.length / gridColumns );\n\n\treturn (\n\t\t<Composite\n\t\t\trole={ isInfiniteScroll ? 'feed' : 'grid' }\n\t\t\tclassName={ clsx( 'dataviews-view-grid', className ) }\n\t\t\tfocusWrap\n\t\t\taria-busy={ isLoading }\n\t\t\taria-rowcount={ isInfiniteScroll ? undefined : totalRows }\n\t\t\tref={ resizeObserverRef }\n\t\t\t// @ts-ignore\n\t\t\tinert={ inert }\n\t\t>\n\t\t\t{ chunk( data, gridColumns ).map( ( row, i ) => (\n\t\t\t\t<Composite.Row\n\t\t\t\t\tkey={ i }\n\t\t\t\t\trender={\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\trole=\"row\"\n\t\t\t\t\t\t\taria-rowindex={ i + 1 }\n\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %d: The row number in the grid */\n\t\t\t\t\t\t\t\t__( 'Row %d' ),\n\t\t\t\t\t\t\t\ti + 1\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tclassName=\"dataviews-view-grid__row\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tgridTemplateColumns: `repeat( ${ gridColumns }, minmax(0, 1fr) )`,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ row.map( ( item, indexInRow ) => {\n\t\t\t\t\t\tconst index = i * gridColumns + indexInRow;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Composite.Item\n\t\t\t\t\t\t\t\tkey={ getItemId( item ) }\n\t\t\t\t\t\t\t\trender={ ( props ) => (\n\t\t\t\t\t\t\t\t\t<GridItem\n\t\t\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\t\t\trole={\n\t\t\t\t\t\t\t\t\t\t\tisInfiniteScroll\n\t\t\t\t\t\t\t\t\t\t\t\t? 'article'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'gridcell'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-setsize={\n\t\t\t\t\t\t\t\t\t\t\tisInfiniteScroll\n\t\t\t\t\t\t\t\t\t\t\t\t? paginationInfo.totalItems\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\taria-posinset={\n\t\t\t\t\t\t\t\t\t\t\tisInfiniteScroll\n\t\t\t\t\t\t\t\t\t\t\t\t? index + 1\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\tview={ view }\n\t\t\t\t\t\t\t\t\t\tselection={ selection }\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\tisItemClickable={ isItemClickable }\n\t\t\t\t\t\t\t\t\t\trenderItemLink={ renderItemLink }\n\t\t\t\t\t\t\t\t\t\tgetItemId={ getItemId }\n\t\t\t\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t\t\t\t\t\tmediaField={ mediaField }\n\t\t\t\t\t\t\t\t\t\ttitleField={ titleField }\n\t\t\t\t\t\t\t\t\t\tdescriptionField={ descriptionField }\n\t\t\t\t\t\t\t\t\t\tregularFields={ regularFields }\n\t\t\t\t\t\t\t\t\t\tbadgeFields={ badgeFields }\n\t\t\t\t\t\t\t\t\t\thasBulkActions={ hasBulkActions }\n\t\t\t\t\t\t\t\t\t\tconfig={ {\n\t\t\t\t\t\t\t\t\t\t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A;AAAA,oBACE,GAAG;AAAA,oBACL,MACC,mBACG,YACA;AAAA,oBAEJ,gBACC,mBACG,eAAe,aACf;AAAA,oBAEJ,iBACC,mBACG,QAAQ,IACR;AAAA,oBAEJ;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA,QAAS;AAAA,sBACR,OAAO;AAAA,oBACR;AAAA;AAAA,gBACD;AAAA;AAAA,cArCK,UAAW,IAAK;AAAA,YAuCvB;AAAA,UAEF,CAAE;AAAA;AAAA,QA9DI;AAAA,MA+DP,CACC;AAAA;AAAA,EACH;AAEF;",
|
|
6
6
|
"names": ["GridItem"]
|
|
7
7
|
}
|
|
@@ -5,6 +5,7 @@ import { __, sprintf } from "@wordpress/i18n";
|
|
|
5
5
|
import { Stack } from "@wordpress/ui";
|
|
6
6
|
import getDataByGroup from "../utils/get-data-by-group.mjs";
|
|
7
7
|
import CompositeGrid from "./composite-grid.mjs";
|
|
8
|
+
import { useDelayedLoading } from "../../../hooks/use-delayed-loading.mjs";
|
|
8
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
function ViewGrid({
|
|
10
11
|
actions,
|
|
@@ -21,12 +22,27 @@ function ViewGrid({
|
|
|
21
22
|
className,
|
|
22
23
|
empty
|
|
23
24
|
}) {
|
|
25
|
+
const isDelayedLoading = useDelayedLoading(!!isLoading);
|
|
24
26
|
const hasData = !!data?.length;
|
|
25
27
|
const groupField = view.groupBy?.field ? fields.find((f) => f.id === view.groupBy?.field) : null;
|
|
26
28
|
const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
|
|
27
29
|
const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
|
|
30
|
+
if (!hasData) {
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
className: clsx("dataviews-no-results", {
|
|
35
|
+
"is-refreshing": isDelayedLoading
|
|
36
|
+
}),
|
|
37
|
+
children: empty
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
28
41
|
const gridProps = {
|
|
29
|
-
className,
|
|
42
|
+
className: clsx(className, {
|
|
43
|
+
"is-refreshing": !isInfiniteScroll && isDelayedLoading
|
|
44
|
+
}),
|
|
45
|
+
inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
|
|
30
46
|
isLoading,
|
|
31
47
|
view,
|
|
32
48
|
fields,
|
|
@@ -68,7 +84,7 @@ function ViewGrid({
|
|
|
68
84
|
)
|
|
69
85
|
) }),
|
|
70
86
|
// Render a single grid with all data.
|
|
71
|
-
|
|
87
|
+
!dataByGroup && /* @__PURE__ */ jsx(
|
|
72
88
|
CompositeGrid,
|
|
73
89
|
{
|
|
74
90
|
...gridProps,
|
|
@@ -76,18 +92,7 @@ function ViewGrid({
|
|
|
76
92
|
isInfiniteScroll: !!isInfiniteScroll
|
|
77
93
|
}
|
|
78
94
|
),
|
|
79
|
-
|
|
80
|
-
!hasData && /* @__PURE__ */ jsx(
|
|
81
|
-
"div",
|
|
82
|
-
{
|
|
83
|
-
className: clsx({
|
|
84
|
-
"dataviews-loading": isLoading,
|
|
85
|
-
"dataviews-no-results": !isLoading
|
|
86
|
-
}),
|
|
87
|
-
children: isLoading ? /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(Spinner, {}) }) : empty
|
|
88
|
-
}
|
|
89
|
-
),
|
|
90
|
-
hasData && isLoading && /* @__PURE__ */ jsx("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ jsx(Spinner, {}) })
|
|
95
|
+
isInfiniteScroll && isLoading && /* @__PURE__ */ jsx("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ jsx(Spinner, {}) })
|
|
91
96
|
]
|
|
92
97
|
});
|
|
93
98
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/dataviews-layouts/grid/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Spinner } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type { ViewGridProps } from '../../../types';\nimport getDataByGroup from '../utils/get-data-by-group';\nimport CompositeGrid from './composite-grid';\n\nfunction ViewGrid< Item >( {\n\tactions,\n\tdata,\n\tfields,\n\tgetItemId,\n\tisLoading,\n\tonChangeSelection,\n\tonClickItem,\n\tisItemClickable,\n\trenderItemLink,\n\tselection,\n\tview,\n\tclassName,\n\tempty,\n}: ViewGridProps< Item > ) {\n\tconst hasData = !! data?.length;\n\tconst groupField = view.groupBy?.field\n\t\t? fields.find( ( f ) => f.id === view.groupBy?.field )\n\t\t: null;\n\tconst dataByGroup = groupField ? getDataByGroup( data, groupField ) : null;\n\tconst isInfiniteScroll = view.infiniteScrollEnabled && ! dataByGroup;\n\tconst gridProps = {\n\t\tclassName,\n\t\tisLoading,\n\t\tview,\n\t\tfields,\n\t\tselection,\n\t\tonChangeSelection,\n\t\tonClickItem,\n\t\tisItemClickable,\n\t\trenderItemLink,\n\t\tgetItemId,\n\t\tactions,\n\t};\n\treturn (\n\t\t<>\n\t\t\t{\n\t\t\t\t// Render multiple groups.\n\t\t\t\thasData && groupField && dataByGroup && (\n\t\t\t\t\t<Stack direction=\"column\" gap=\"lg\">\n\t\t\t\t\t\t{ Array.from( dataByGroup.entries() ).map(\n\t\t\t\t\t\t\t( [ groupName, groupItems ] ) => (\n\t\t\t\t\t\t\t\t<Stack\n\t\t\t\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\t\t\t\tkey={ groupName }\n\t\t\t\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<h3 className=\"dataviews-view-grid__group-header\">\n\t\t\t\t\t\t\t\t\t\t{ view.groupBy?.showLabel === false\n\t\t\t\t\t\t\t\t\t\t\t? groupName\n\t\t\t\t\t\t\t\t\t\t\t: sprintf(\n\t\t\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\t\t__( '%1$s: %2$s' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\tgroupField.label,\n\t\t\t\t\t\t\t\t\t\t\t\t\tgroupName\n\t\t\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t\t\t\t<CompositeGrid\n\t\t\t\t\t\t\t\t\t\t{ ...gridProps }\n\t\t\t\t\t\t\t\t\t\tdata={ groupItems }\n\t\t\t\t\t\t\t\t\t\tisInfiniteScroll={ false }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t}\n\t\t\t{\n\t\t\t\t// Render a single grid with all data.\n\t\t\t\
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,eAAe;AACxB,SAAS,IAAI,eAAe;AAC5B,SAAS,aAAa;AAMtB,OAAO,oBAAoB;AAC3B,OAAO,mBAAmB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Spinner } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type { ViewGridProps } from '../../../types';\nimport getDataByGroup from '../utils/get-data-by-group';\nimport CompositeGrid from './composite-grid';\nimport { useDelayedLoading } from '../../../hooks/use-delayed-loading';\n\nfunction ViewGrid< Item >( {\n\tactions,\n\tdata,\n\tfields,\n\tgetItemId,\n\tisLoading,\n\tonChangeSelection,\n\tonClickItem,\n\tisItemClickable,\n\trenderItemLink,\n\tselection,\n\tview,\n\tclassName,\n\tempty,\n}: ViewGridProps< Item > ) {\n\tconst isDelayedLoading = useDelayedLoading( !! isLoading );\n\tconst hasData = !! data?.length;\n\tconst groupField = view.groupBy?.field\n\t\t? fields.find( ( f ) => f.id === view.groupBy?.field )\n\t\t: null;\n\tconst dataByGroup = groupField ? getDataByGroup( data, groupField ) : null;\n\tconst isInfiniteScroll = view.infiniteScrollEnabled && ! dataByGroup;\n\tif ( ! hasData ) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'dataviews-no-results', {\n\t\t\t\t\t'is-refreshing': isDelayedLoading,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ empty }\n\t\t\t</div>\n\t\t);\n\t}\n\tconst gridProps = {\n\t\tclassName: clsx( className, {\n\t\t\t'is-refreshing': ! isInfiniteScroll && isDelayedLoading,\n\t\t} ),\n\t\tinert: ! isInfiniteScroll && !! isLoading ? 'true' : undefined,\n\t\tisLoading,\n\t\tview,\n\t\tfields,\n\t\tselection,\n\t\tonChangeSelection,\n\t\tonClickItem,\n\t\tisItemClickable,\n\t\trenderItemLink,\n\t\tgetItemId,\n\t\tactions,\n\t};\n\treturn (\n\t\t<>\n\t\t\t{\n\t\t\t\t// Render multiple groups.\n\t\t\t\thasData && groupField && dataByGroup && (\n\t\t\t\t\t<Stack direction=\"column\" gap=\"lg\">\n\t\t\t\t\t\t{ Array.from( dataByGroup.entries() ).map(\n\t\t\t\t\t\t\t( [ groupName, groupItems ] ) => (\n\t\t\t\t\t\t\t\t<Stack\n\t\t\t\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\t\t\t\tkey={ groupName }\n\t\t\t\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<h3 className=\"dataviews-view-grid__group-header\">\n\t\t\t\t\t\t\t\t\t\t{ view.groupBy?.showLabel === false\n\t\t\t\t\t\t\t\t\t\t\t? groupName\n\t\t\t\t\t\t\t\t\t\t\t: sprintf(\n\t\t\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\t\t__( '%1$s: %2$s' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\tgroupField.label,\n\t\t\t\t\t\t\t\t\t\t\t\t\tgroupName\n\t\t\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t\t\t\t<CompositeGrid\n\t\t\t\t\t\t\t\t\t\t{ ...gridProps }\n\t\t\t\t\t\t\t\t\t\tdata={ groupItems }\n\t\t\t\t\t\t\t\t\t\tisInfiniteScroll={ false }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t}\n\t\t\t{\n\t\t\t\t// Render a single grid with all data.\n\t\t\t\t! dataByGroup && (\n\t\t\t\t\t<CompositeGrid\n\t\t\t\t\t\t{ ...gridProps }\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tisInfiniteScroll={ !! isInfiniteScroll }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t\t{ isInfiniteScroll && isLoading && (\n\t\t\t\t<p className=\"dataviews-loading-more\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ViewGrid;\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,eAAe;AACxB,SAAS,IAAI,eAAe;AAC5B,SAAS,aAAa;AAMtB,OAAO,oBAAoB;A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ACX,eAAK,SAAS,cAAc,QAC3B,YACA;AAAA;AAAA,gBAEA,GAAI,YAAa;AAAA,gBACjB,WAAW;AAAA,gBACX;AAAA,cACA,GACJ;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACE,GAAG;AAAA,kBACL,MAAO;AAAA,kBACP,kBAAmB;AAAA;AAAA,cACpB;AAAA;AAAA;AAAA,UAjBM;AAAA,QAkBP;AAAA,MAEF,GACD;AAAA;AAAA,MAKD,CAAE,eACD;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACL;AAAA,UACA,kBAAmB,CAAC,CAAE;AAAA;AAAA,MACvB;AAAA,MAGA,oBAAoB,aACrB,oBAAC,OAAE,WAAU,0BACZ,8BAAC,WAAQ,GACV;AAAA;AAAA,GAEF;AAEF;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,6 +23,7 @@ import { Stack } from "@wordpress/ui";
|
|
|
23
23
|
import { unlock } from "../../../lock-unlock.mjs";
|
|
24
24
|
import { ActionsMenuGroup, ActionModal } from "../../dataviews-item-actions/index.mjs";
|
|
25
25
|
import DataViewsContext from "../../dataviews-context/index.mjs";
|
|
26
|
+
import { useDelayedLoading } from "../../../hooks/use-delayed-loading.mjs";
|
|
26
27
|
import getDataByGroup from "../utils/get-data-by-group.mjs";
|
|
27
28
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
28
29
|
var { Menu } = unlock(componentsPrivateApis);
|
|
@@ -153,6 +154,8 @@ function ListItem({
|
|
|
153
154
|
}
|
|
154
155
|
) }) : null;
|
|
155
156
|
const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ jsx(titleField.render, { item, field: titleField }) : null;
|
|
157
|
+
const renderDescription = showDescription && descriptionField?.render;
|
|
158
|
+
const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
|
|
156
159
|
const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ jsxs(
|
|
157
160
|
Stack,
|
|
158
161
|
{
|
|
@@ -260,7 +263,7 @@ function ListItem({
|
|
|
260
263
|
direction: "row",
|
|
261
264
|
gap: "md",
|
|
262
265
|
justify: "start",
|
|
263
|
-
align: "flex-start",
|
|
266
|
+
align: hasOnlyMediaAndTitle ? "center" : "flex-start",
|
|
264
267
|
style: { flex: 1, minWidth: 0 },
|
|
265
268
|
children: [
|
|
266
269
|
renderedMediaField,
|
|
@@ -282,7 +285,7 @@ function ListItem({
|
|
|
282
285
|
),
|
|
283
286
|
usedActions
|
|
284
287
|
] }),
|
|
285
|
-
|
|
288
|
+
renderDescription && /* @__PURE__ */ jsx("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ jsx(
|
|
286
289
|
descriptionField.render,
|
|
287
290
|
{
|
|
288
291
|
item,
|
|
@@ -349,6 +352,7 @@ function ViewList(props) {
|
|
|
349
352
|
empty
|
|
350
353
|
} = props;
|
|
351
354
|
const baseId = useInstanceId(ViewList, "view-list");
|
|
355
|
+
const isDelayedLoading = useDelayedLoading(!!isLoading);
|
|
352
356
|
const selectedItem = data?.findLast(
|
|
353
357
|
(item) => selection.includes(getItemId(item))
|
|
354
358
|
);
|
|
@@ -372,6 +376,7 @@ function ViewList(props) {
|
|
|
372
376
|
[generateCompositeItemIdPrefix]
|
|
373
377
|
);
|
|
374
378
|
const [activeCompositeId, setActiveCompositeId] = useState(void 0);
|
|
379
|
+
const compositeRef = useRef(null);
|
|
375
380
|
useEffect(() => {
|
|
376
381
|
if (selectedItem) {
|
|
377
382
|
setActiveCompositeId(
|
|
@@ -400,7 +405,11 @@ function ViewList(props) {
|
|
|
400
405
|
);
|
|
401
406
|
const targetCompositeItemId = generateCompositeId(itemIdPrefix);
|
|
402
407
|
setActiveCompositeId(targetCompositeItemId);
|
|
403
|
-
|
|
408
|
+
if (compositeRef.current?.contains(
|
|
409
|
+
compositeRef.current.ownerDocument.activeElement
|
|
410
|
+
)) {
|
|
411
|
+
document.getElementById(targetCompositeItemId)?.focus();
|
|
412
|
+
}
|
|
404
413
|
},
|
|
405
414
|
[data, generateCompositeItemIdPrefix]
|
|
406
415
|
);
|
|
@@ -432,25 +441,26 @@ function ViewList(props) {
|
|
|
432
441
|
},
|
|
433
442
|
[selectCompositeItem, activeItemIndex]
|
|
434
443
|
);
|
|
435
|
-
const hasData = data?.length;
|
|
444
|
+
const hasData = !!data?.length;
|
|
445
|
+
const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
|
|
446
|
+
const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
|
|
447
|
+
const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
|
|
436
448
|
if (!hasData) {
|
|
437
449
|
return /* @__PURE__ */ jsx(
|
|
438
450
|
"div",
|
|
439
451
|
{
|
|
440
|
-
className: clsx({
|
|
441
|
-
"
|
|
442
|
-
"dataviews-no-results": !hasData && !isLoading
|
|
452
|
+
className: clsx("dataviews-no-results", {
|
|
453
|
+
"is-refreshing": isDelayedLoading
|
|
443
454
|
}),
|
|
444
|
-
children:
|
|
455
|
+
children: empty
|
|
445
456
|
}
|
|
446
457
|
);
|
|
447
458
|
}
|
|
448
|
-
const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
|
|
449
|
-
const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
|
|
450
459
|
if (hasData && groupField && dataByGroup) {
|
|
451
460
|
return /* @__PURE__ */ jsx(
|
|
452
461
|
Composite,
|
|
453
462
|
{
|
|
463
|
+
ref: compositeRef,
|
|
454
464
|
id: `${baseId}`,
|
|
455
465
|
render: /* @__PURE__ */ jsx("div", {}),
|
|
456
466
|
className: "dataviews-view-list__group",
|
|
@@ -510,16 +520,19 @@ function ViewList(props) {
|
|
|
510
520
|
/* @__PURE__ */ jsx(
|
|
511
521
|
Composite,
|
|
512
522
|
{
|
|
523
|
+
ref: compositeRef,
|
|
513
524
|
id: baseId,
|
|
514
525
|
render: /* @__PURE__ */ jsx("div", {}),
|
|
515
526
|
className: clsx("dataviews-view-list", className, {
|
|
516
527
|
[`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
|
|
517
528
|
view.layout.density
|
|
518
|
-
)
|
|
529
|
+
),
|
|
530
|
+
"is-refreshing": !isInfiniteScroll && isDelayedLoading
|
|
519
531
|
}),
|
|
520
532
|
role: view.infiniteScrollEnabled ? "feed" : "grid",
|
|
521
533
|
activeId: activeCompositeId,
|
|
522
534
|
setActiveId: setActiveCompositeId,
|
|
535
|
+
inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
|
|
523
536
|
children: data.map((item, index) => {
|
|
524
537
|
const id = generateCompositeItemIdPrefix(item);
|
|
525
538
|
return /* @__PURE__ */ jsx(
|
|
@@ -543,7 +556,7 @@ function ViewList(props) {
|
|
|
543
556
|
})
|
|
544
557
|
}
|
|
545
558
|
),
|
|
546
|
-
|
|
559
|
+
isInfiniteScroll && isLoading && /* @__PURE__ */ jsx("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ jsx(Spinner, {}) })
|
|
547
560
|
] });
|
|
548
561
|
}
|
|
549
562
|
export {
|