@wordpress/dataviews 2.1.0 → 3.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 +24 -5
- package/README.md +5 -5
- package/build/add-filter.js +1 -1
- package/build/add-filter.js.map +1 -1
- package/build/bulk-actions-toolbar.js +5 -2
- package/build/bulk-actions-toolbar.js.map +1 -1
- package/build/bulk-actions.js +11 -21
- package/build/bulk-actions.js.map +1 -1
- package/build/dataform.js +78 -0
- package/build/dataform.js.map +1 -0
- package/build/dataviews.js +26 -31
- package/build/dataviews.js.map +1 -1
- package/build/filter-and-sort-data-view.js +4 -1
- package/build/filter-and-sort-data-view.js.map +1 -1
- package/build/filter-summary.js +6 -5
- package/build/filter-summary.js.map +1 -1
- package/build/filters.js +1 -1
- package/build/filters.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/item-actions.js +17 -6
- package/build/item-actions.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/normalize-fields.js.map +1 -1
- package/build/pagination.js +2 -2
- package/build/pagination.js.map +1 -1
- package/build/private-types.js +6 -0
- package/build/private-types.js.map +1 -0
- package/build/reset-filters.js +1 -1
- package/build/reset-filters.js.map +1 -1
- package/build/search-widget.js +8 -6
- package/build/search-widget.js.map +1 -1
- package/build/single-selection-checkbox.js +5 -16
- package/build/single-selection-checkbox.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils.js.map +1 -1
- package/build/view-actions.js +76 -65
- package/build/view-actions.js.map +1 -1
- package/build/view-grid.js +7 -19
- package/build/view-grid.js.map +1 -1
- package/build/view-list.js +15 -8
- package/build/view-list.js.map +1 -1
- package/build/view-table.js +22 -25
- package/build/view-table.js.map +1 -1
- package/build-module/add-filter.js +1 -1
- package/build-module/add-filter.js.map +1 -1
- package/build-module/bulk-actions-toolbar.js +5 -2
- package/build-module/bulk-actions-toolbar.js.map +1 -1
- package/build-module/bulk-actions.js +12 -22
- package/build-module/bulk-actions.js.map +1 -1
- package/build-module/dataform.js +72 -0
- package/build-module/dataform.js.map +1 -0
- package/build-module/dataviews.js +24 -31
- package/build-module/dataviews.js.map +1 -1
- package/build-module/filter-and-sort-data-view.js +4 -1
- package/build-module/filter-and-sort-data-view.js.map +1 -1
- package/build-module/filter-summary.js +6 -5
- package/build-module/filter-summary.js.map +1 -1
- package/build-module/filters.js +1 -1
- package/build-module/filters.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/item-actions.js +17 -6
- package/build-module/item-actions.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/normalize-fields.js.map +1 -1
- package/build-module/pagination.js +2 -2
- package/build-module/pagination.js.map +1 -1
- package/build-module/private-types.js +2 -0
- package/build-module/private-types.js.map +1 -0
- package/build-module/reset-filters.js +1 -1
- package/build-module/reset-filters.js.map +1 -1
- package/build-module/search-widget.js +8 -6
- package/build-module/search-widget.js.map +1 -1
- package/build-module/single-selection-checkbox.js +5 -16
- package/build-module/single-selection-checkbox.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/utils.js.map +1 -1
- package/build-module/view-actions.js +80 -68
- package/build-module/view-actions.js.map +1 -1
- package/build-module/view-grid.js +7 -19
- package/build-module/view-grid.js.map +1 -1
- package/build-module/view-list.js +15 -8
- package/build-module/view-list.js.map +1 -1
- package/build-module/view-table.js +22 -25
- package/build-module/view-table.js.map +1 -1
- package/build-style/style-rtl.css +8 -24
- package/build-style/style.css +8 -24
- package/build-types/bulk-actions-toolbar.d.ts +5 -4
- package/build-types/bulk-actions-toolbar.d.ts.map +1 -1
- package/build-types/bulk-actions.d.ts +7 -6
- package/build-types/bulk-actions.d.ts.map +1 -1
- package/build-types/dataform.d.ts +17 -0
- package/build-types/dataform.d.ts.map +1 -0
- package/build-types/dataviews.d.ts +15 -6
- package/build-types/dataviews.d.ts.map +1 -1
- package/build-types/filter-and-sort-data-view.d.ts +2 -2
- package/build-types/filter-and-sort-data-view.d.ts.map +1 -1
- package/build-types/filter-summary.d.ts.map +1 -1
- package/build-types/filters.d.ts +3 -3
- package/build-types/filters.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/item-actions.d.ts +10 -10
- package/build-types/item-actions.d.ts.map +1 -1
- package/build-types/normalize-fields.d.ts +2 -2
- package/build-types/normalize-fields.d.ts.map +1 -1
- package/build-types/private-types.d.ts +3 -0
- package/build-types/private-types.d.ts.map +1 -0
- package/build-types/single-selection-checkbox.d.ts +5 -5
- package/build-types/single-selection-checkbox.d.ts.map +1 -1
- package/build-types/stories/fixtures.d.ts +14 -1
- package/build-types/stories/fixtures.d.ts.map +1 -1
- package/build-types/stories/index.story.d.ts +15 -1
- package/build-types/stories/index.story.d.ts.map +1 -1
- package/build-types/types.d.ts +73 -38
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils.d.ts +2 -2
- package/build-types/utils.d.ts.map +1 -1
- package/build-types/view-actions.d.ts +4 -4
- package/build-types/view-actions.d.ts.map +1 -1
- package/build-types/view-grid.d.ts +2 -2
- package/build-types/view-grid.d.ts.map +1 -1
- package/build-types/view-list.d.ts +2 -2
- package/build-types/view-list.d.ts.map +1 -1
- package/build-types/view-table.d.ts +2 -2
- package/build-types/view-table.d.ts.map +1 -1
- package/package.json +10 -9
- package/src/add-filter.tsx +1 -1
- package/src/bulk-actions-toolbar.tsx +18 -14
- package/src/bulk-actions.tsx +31 -45
- package/src/dataform.tsx +106 -0
- package/src/dataviews.tsx +55 -60
- package/src/filter-and-sort-data-view.ts +13 -3
- package/src/filter-summary.tsx +18 -12
- package/src/filters.tsx +4 -4
- package/src/index.ts +1 -0
- package/src/item-actions.tsx +27 -24
- package/src/lock-unlock.ts +1 -1
- package/src/normalize-fields.ts +5 -3
- package/src/pagination.tsx +2 -2
- package/src/private-types.tsx +2 -0
- package/src/reset-filters.tsx +1 -1
- package/src/search-widget.tsx +6 -6
- package/src/single-selection-checkbox.tsx +14 -29
- package/src/stories/fixtures.js +17 -1
- package/src/stories/index.story.js +15 -28
- package/src/style.scss +10 -22
- package/src/test/filter-and-sort-data-view.js +16 -1
- package/src/types.ts +75 -47
- package/src/utils.ts +2 -4
- package/src/view-actions.tsx +105 -102
- package/src/view-grid.tsx +21 -38
- package/src/view-list.tsx +22 -22
- package/src/view-table.tsx +45 -45
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["normalizeFields","fields","map","field","getValue","item","id","header","render"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Field,
|
|
1
|
+
{"version":3,"names":["normalizeFields","fields","map","field","getValue","item","id","header","render"],"sources":["@wordpress/dataviews/src/normalize-fields.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Field, NormalizedField, ItemRecord } from './types';\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport function normalizeFields< Item >(\n\tfields: Field< Item >[]\n): NormalizedField< Item >[] {\n\treturn fields.map( ( field ) => {\n\t\tconst getValue =\n\t\t\tfield.getValue ||\n\t\t\t( ( { item }: { item: ItemRecord } ) => item[ field.id ] );\n\n\t\treturn {\n\t\t\t...field,\n\t\t\theader: field.header || field.id,\n\t\t\tgetValue,\n\t\t\trender: field.render || getValue,\n\t\t};\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAC9BC,MAAuB,EACK;EAC5B,OAAOA,MAAM,CAACC,GAAG,CAAIC,KAAK,IAAM;IAC/B,MAAMC,QAAQ,GACbD,KAAK,CAACC,QAAQ,KACZ,CAAE;MAAEC;IAA2B,CAAC,KAAMA,IAAI,CAAEF,KAAK,CAACG,EAAE,CAAE,CAAE;IAE3D,OAAO;MACN,GAAGH,KAAK;MACRI,MAAM,EAAEJ,KAAK,CAACI,MAAM,IAAIJ,KAAK,CAACG,EAAE;MAChCF,QAAQ;MACRI,MAAM,EAAEL,KAAK,CAACK,MAAM,IAAIJ;IACzB,CAAC;EACF,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -66,7 +66,7 @@ const Pagination = memo(function Pagination({
|
|
|
66
66
|
page: currentPage - 1
|
|
67
67
|
}),
|
|
68
68
|
disabled: currentPage === 1,
|
|
69
|
-
|
|
69
|
+
accessibleWhenDisabled: true,
|
|
70
70
|
label: __('Previous page'),
|
|
71
71
|
icon: chevronLeft,
|
|
72
72
|
showTooltip: true,
|
|
@@ -78,7 +78,7 @@ const Pagination = memo(function Pagination({
|
|
|
78
78
|
page: currentPage + 1
|
|
79
79
|
}),
|
|
80
80
|
disabled: currentPage >= totalPages,
|
|
81
|
-
|
|
81
|
+
accessibleWhenDisabled: true,
|
|
82
82
|
label: __('Next page'),
|
|
83
83
|
icon: chevronRight,
|
|
84
84
|
showTooltip: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","__experimentalHStack","HStack","SelectControl","createInterpolateElement","memo","sprintf","__","_x","chevronRight","chevronLeft","jsx","_jsx","jsxs","_jsxs","Pagination","view","onChangeView","paginationInfo","totalItems","totalPages","_view$page","currentPage","page","expanded","spacing","justify","className","children","CurrentPageControl","value","toString","options","Array","from","map","_","i","label","onChange","newValue","size","__nextHasNoMarginBottom","onClick","disabled","
|
|
1
|
+
{"version":3,"names":["Button","__experimentalHStack","HStack","SelectControl","createInterpolateElement","memo","sprintf","__","_x","chevronRight","chevronLeft","jsx","_jsx","jsxs","_jsxs","Pagination","view","onChangeView","paginationInfo","totalItems","totalPages","_view$page","currentPage","page","expanded","spacing","justify","className","children","CurrentPageControl","value","toString","options","Array","from","map","_","i","label","onChange","newValue","size","__nextHasNoMarginBottom","onClick","disabled","accessibleWhenDisabled","icon","showTooltip","tooltipPosition"],"sources":["@wordpress/dataviews/src/pagination.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\tSelectControl,\n} from '@wordpress/components';\nimport { createInterpolateElement, memo } from '@wordpress/element';\nimport { sprintf, __, _x } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport type { View } from './types';\n\ninterface PaginationProps {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t};\n}\n\nconst Pagination = memo( function Pagination( {\n\tview,\n\tonChangeView,\n\tpaginationInfo: { totalItems = 0, totalPages },\n}: PaginationProps ) {\n\tif ( ! totalItems || ! totalPages ) {\n\t\treturn null;\n\t}\n\tconst currentPage = view.page ?? 1;\n\treturn (\n\t\t!! totalItems &&\n\t\ttotalPages !== 1 && (\n\t\t\t<HStack\n\t\t\t\texpanded={ false }\n\t\t\t\tspacing={ 6 }\n\t\t\t\tjustify=\"end\"\n\t\t\t\tclassName=\"dataviews-pagination\"\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\tclassName=\"dataviews-pagination__page-selection\"\n\t\t\t\t>\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t// translators: %s: Total number of pages.\n\t\t\t\t\t\t\t_x( 'Page <CurrentPageControl /> of %s', 'paging' ),\n\t\t\t\t\t\t\ttotalPages\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tCurrentPageControl: (\n\t\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Current page' ) }\n\t\t\t\t\t\t\t\t\tvalue={ view.page?.toString() }\n\t\t\t\t\t\t\t\t\toptions={ Array.from(\n\t\t\t\t\t\t\t\t\t\tArray( totalPages )\n\t\t\t\t\t\t\t\t\t).map( ( _, i ) => {\n\t\t\t\t\t\t\t\t\t\tconst page = i + 1;\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\tvalue: page.toString(),\n\t\t\t\t\t\t\t\t\t\t\tlabel: page.toString(),\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\t\t\t\t\tpage: +newValue,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t\t<HStack expanded={ false } spacing={ 1 }>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\t\tpage: currentPage - 1,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdisabled={ currentPage === 1 }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tlabel={ __( 'Previous page' ) }\n\t\t\t\t\t\ticon={ chevronLeft }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tonChangeView( { ...view, page: currentPage + 1 } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdisabled={ currentPage >= totalPages }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\tlabel={ __( 'Next page' ) }\n\t\t\t\t\t\ticon={ chevronRight }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t</HStack>\n\t\t)\n\t);\n} );\n\nexport default Pagination;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,aAAa,QACP,uBAAuB;AAC9B,SAASC,wBAAwB,EAAEC,IAAI,QAAQ,oBAAoB;AACnE,SAASC,OAAO,EAAEC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACjD,SAASC,YAAY,EAAEC,WAAW,QAAQ,kBAAkB;;AAE5D;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAcA,MAAMC,UAAU,GAAGV,IAAI,CAAE,SAASU,UAAUA,CAAE;EAC7CC,IAAI;EACJC,YAAY;EACZC,cAAc,EAAE;IAAEC,UAAU,GAAG,CAAC;IAAEC;EAAW;AAC7B,CAAC,EAAG;EAAA,IAAAC,UAAA;EACpB,IAAK,CAAEF,UAAU,IAAI,CAAEC,UAAU,EAAG;IACnC,OAAO,IAAI;EACZ;EACA,MAAME,WAAW,IAAAD,UAAA,GAAGL,IAAI,CAACO,IAAI,cAAAF,UAAA,cAAAA,UAAA,GAAI,CAAC;EAClC,OACC,CAAC,CAAEF,UAAU,IACbC,UAAU,KAAK,CAAC,iBACfN,KAAA,CAACZ,MAAM;IACNsB,QAAQ,EAAG,KAAO;IAClBC,OAAO,EAAG,CAAG;IACbC,OAAO,EAAC,KAAK;IACbC,SAAS,EAAC,sBAAsB;IAAAC,QAAA,gBAEhChB,IAAA,CAACV,MAAM;MACNwB,OAAO,EA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;QACpBqC,WAAW;QACXN,IAAI,EAAC,SAAS;QACdO,eAAe,EAAC;MAAK,CACrB,CAAC,eACFpC,IAAA,CAACZ,MAAM;QACN2C,OAAO,EAAGA,CAAA,KACT1B,YAAY,CAAE;UAAE,GAAGD,IAAI;UAAEO,IAAI,EAAED,WAAW,GAAG;QAAE,CAAE,CACjD;QACDsB,QAAQ,EAAGtB,WAAW,IAAIF,UAAY;QACtCyB,sBAAsB;QACtBP,KAAK,EAAG/B,EAAE,CAAE,WAAY,CAAG;QAC3BuC,IAAI,EAAGrC,YAAc;QACrBsC,WAAW;QACXN,IAAI,EAAC,SAAS;QACdO,eAAe,EAAC;MAAK,CACrB,CAAC;IAAA,CACK,CAAC;EAAA,CACF,CACR;AAEH,CAAE,CAAC;AAEH,eAAejC,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/private-types.tsx"],"sourcesContent":["export type SelectionOrUpdater = string[] | ( ( prev: string[] ) => string[] );\nexport type SetSelection = ( selection: SelectionOrUpdater ) => void;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -17,7 +17,7 @@ export default function ResetFilter({
|
|
|
17
17
|
const isDisabled = !view.search && !view.filters?.some(_filter => _filter.value !== undefined || !isPrimary(_filter.field));
|
|
18
18
|
return /*#__PURE__*/_jsx(Button, {
|
|
19
19
|
disabled: isDisabled,
|
|
20
|
-
|
|
20
|
+
accessibleWhenDisabled: true,
|
|
21
21
|
size: "compact",
|
|
22
22
|
variant: "tertiary",
|
|
23
23
|
className: "dataviews-filters__reset-button",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Button","__","jsx","_jsx","ResetFilter","filters","view","onChangeView","isPrimary","field","some","_filter","isDisabled","search","value","undefined","disabled","
|
|
1
|
+
{"version":3,"names":["Button","__","jsx","_jsx","ResetFilter","filters","view","onChangeView","isPrimary","field","some","_filter","isDisabled","search","value","undefined","disabled","accessibleWhenDisabled","size","variant","className","onClick","page","children"],"sources":["@wordpress/dataviews/src/reset-filters.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { NormalizedFilter, View } from './types';\n\ninterface ResetFilterProps {\n\tfilters: NormalizedFilter[];\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n}\n\nexport default function ResetFilter( {\n\tfilters,\n\tview,\n\tonChangeView,\n}: ResetFilterProps ) {\n\tconst isPrimary = ( field: string ) =>\n\t\tfilters.some(\n\t\t\t( _filter ) => _filter.field === field && _filter.isPrimary\n\t\t);\n\tconst isDisabled =\n\t\t! view.search &&\n\t\t! view.filters?.some(\n\t\t\t( _filter ) =>\n\t\t\t\t_filter.value !== undefined || ! isPrimary( _filter.field )\n\t\t);\n\treturn (\n\t\t<Button\n\t\t\tdisabled={ isDisabled }\n\t\t\taccessibleWhenDisabled\n\t\t\tsize=\"compact\"\n\t\t\tvariant=\"tertiary\"\n\t\t\tclassName=\"dataviews-filters__reset-button\"\n\t\t\tonClick={ () => {\n\t\t\t\tonChangeView( {\n\t\t\t\t\t...view,\n\t\t\t\t\tpage: 1,\n\t\t\t\t\tsearch: '',\n\t\t\t\t\tfilters: [],\n\t\t\t\t} );\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Reset' ) }\n\t\t</Button>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAWA,eAAe,SAASC,WAAWA,CAAE;EACpCC,OAAO;EACPC,IAAI;EACJC;AACiB,CAAC,EAAG;EACrB,MAAMC,SAAS,GAAKC,KAAa,IAChCJ,OAAO,CAACK,IAAI,CACTC,OAAO,IAAMA,OAAO,CAACF,KAAK,KAAKA,KAAK,IAAIE,OAAO,CAACH,SACnD,CAAC;EACF,MAAMI,UAAU,GACf,CAAEN,IAAI,CAACO,MAAM,IACb,CAAEP,IAAI,CAACD,OAAO,EAAEK,IAAI,CACjBC,OAAO,IACRA,OAAO,CAACG,KAAK,KAAKC,SAAS,IAAI,CAAEP,SAAS,CAAEG,OAAO,CAACF,KAAM,CAC5D,CAAC;EACF,oBACCN,IAAA,CAACH,MAAM;IACNgB,QAAQ,EAAGJ,UAAY;IACvBK,sBAAsB;IACtBC,IAAI,EAAC,SAAS;IACdC,OAAO,EAAC,UAAU;IAClBC,SAAS,EAAC,iCAAiC;IAC3CC,OAAO,EAAGA,CAAA,KAAM;MACfd,YAAY,CAAE;QACb,GAAGD,IAAI;QACPgB,IAAI,EAAE,CAAC;QACPT,MAAM,EAAE,EAAE;QACVR,OAAO,EAAE;MACV,CAAE,CAAC;IACJ,CAAG;IAAAkB,QAAA,EAEDtB,EAAE,CAAE,OAAQ;EAAC,CACR,CAAC;AAEX","ignoreList":[]}
|
|
@@ -72,7 +72,7 @@ function ListBox({
|
|
|
72
72
|
// so the first item is not selected, since the focus is on the operators control.
|
|
73
73
|
defaultActiveId: filter.operators?.length === 1 ? undefined : null
|
|
74
74
|
});
|
|
75
|
-
const currentFilter = view.filters
|
|
75
|
+
const currentFilter = view.filters?.find(f => f.field === filter.field);
|
|
76
76
|
const currentValue = getCurrentValue(filter, currentFilter);
|
|
77
77
|
return /*#__PURE__*/_jsx(Composite, {
|
|
78
78
|
store: compositeStore,
|
|
@@ -97,7 +97,8 @@ function ListBox({
|
|
|
97
97
|
className: "dataviews-search-widget-listitem"
|
|
98
98
|
}),
|
|
99
99
|
onClick: () => {
|
|
100
|
-
|
|
100
|
+
var _view$filters, _view$filters2;
|
|
101
|
+
const newFilters = currentFilter ? [...((_view$filters = view.filters) !== null && _view$filters !== void 0 ? _view$filters : []).map(_filter => {
|
|
101
102
|
if (_filter.field === filter.field) {
|
|
102
103
|
return {
|
|
103
104
|
..._filter,
|
|
@@ -106,7 +107,7 @@ function ListBox({
|
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
109
|
return _filter;
|
|
109
|
-
})] : [...view.filters, {
|
|
110
|
+
})] : [...((_view$filters2 = view.filters) !== null && _view$filters2 !== void 0 ? _view$filters2 : []), {
|
|
110
111
|
field: filter.field,
|
|
111
112
|
operator: filter.operators[0],
|
|
112
113
|
value: getNewValue(filter, currentFilter, element.value)
|
|
@@ -141,7 +142,7 @@ function ComboboxList({
|
|
|
141
142
|
}) {
|
|
142
143
|
const [searchValue, setSearchValue] = useState('');
|
|
143
144
|
const deferredSearchValue = useDeferredValue(searchValue);
|
|
144
|
-
const currentFilter = view.filters
|
|
145
|
+
const currentFilter = view.filters?.find(_filter => _filter.field === filter.field);
|
|
145
146
|
const currentValue = getCurrentValue(filter, currentFilter);
|
|
146
147
|
const matches = useMemo(() => {
|
|
147
148
|
const normalizedSearch = normalizeSearchInput(deferredSearchValue);
|
|
@@ -151,7 +152,8 @@ function ComboboxList({
|
|
|
151
152
|
resetValueOnSelect: false,
|
|
152
153
|
selectedValue: currentValue,
|
|
153
154
|
setSelectedValue: value => {
|
|
154
|
-
|
|
155
|
+
var _view$filters3, _view$filters4;
|
|
156
|
+
const newFilters = currentFilter ? [...((_view$filters3 = view.filters) !== null && _view$filters3 !== void 0 ? _view$filters3 : []).map(_filter => {
|
|
155
157
|
if (_filter.field === filter.field) {
|
|
156
158
|
return {
|
|
157
159
|
..._filter,
|
|
@@ -160,7 +162,7 @@ function ComboboxList({
|
|
|
160
162
|
};
|
|
161
163
|
}
|
|
162
164
|
return _filter;
|
|
163
|
-
})] : [...view.filters, {
|
|
165
|
+
})] : [...((_view$filters4 = view.filters) !== null && _view$filters4 !== void 0 ? _view$filters4 : []), {
|
|
164
166
|
field: filter.field,
|
|
165
167
|
operator: filter.operators[0],
|
|
166
168
|
value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Ariakit","removeAccents","__","sprintf","useState","useMemo","useDeferredValue","VisuallyHidden","Icon","privateApis","componentsPrivateApis","search","check","SVG","Circle","unlock","jsx","_jsx","jsxs","_jsxs","CompositeV2","Composite","CompositeItemV2","CompositeItem","useCompositeStoreV2","useCompositeStore","radioCheck","xmlns","viewBox","children","cx","cy","r","normalizeSearchInput","input","trim","toLowerCase","EMPTY_ARRAY","getCurrentValue","filterDefinition","currentFilter","singleSelection","value","Array","isArray","getNewValue","includes","filter","v","ListBox","view","onChangeView","compositeStore","virtualFocus","focusLoop","defaultActiveId","operators","length","undefined","filters","find","f","field","currentValue","store","role","className","name","onFocusVisible","getState","activeId","move","first","render","CompositeTypeahead","elements","map","element","CompositeHover","label","onClick","newFilters","_filter","operator","page","icon","description","ComboboxList","searchValue","setSearchValue","deferredSearchValue","matches","normalizedSearch","item","ComboboxProvider","resetValueOnSelect","selectedValue","setSelectedValue","setValue","ComboboxLabel","Combobox","autoSelect","placeholder","alwaysVisible","ComboboxItem","hideOnClick","setValueOnClick","focusOnHover","ComboboxItemValue","SearchWidget","props","Widget"],"sources":["@wordpress/dataviews/src/search-widget.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState, useMemo, useDeferredValue } from '@wordpress/element';\nimport {\n\tVisuallyHidden,\n\tIcon,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { search, check } from '@wordpress/icons';\nimport { SVG, Circle } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport type { Filter, NormalizedFilter, View } from './types';\n\nconst {\n\tCompositeV2: Composite,\n\tCompositeItemV2: CompositeItem,\n\tuseCompositeStoreV2: useCompositeStore,\n} = unlock( componentsPrivateApis );\n\ninterface SearchWidgetProps {\n\tview: View;\n\tfilter: NormalizedFilter;\n\tonChangeView: ( view: View ) => void;\n}\n\nconst radioCheck = (\n\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">\n\t\t<Circle cx={ 12 } cy={ 12 } r={ 3 }></Circle>\n\t</SVG>\n);\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\nconst EMPTY_ARRAY: [] = [];\nconst getCurrentValue = (\n\tfilterDefinition: NormalizedFilter,\n\tcurrentFilter?: Filter\n) => {\n\tif ( filterDefinition.singleSelection ) {\n\t\treturn currentFilter?.value;\n\t}\n\n\tif ( Array.isArray( currentFilter?.value ) ) {\n\t\treturn currentFilter.value;\n\t}\n\n\tif ( ! Array.isArray( currentFilter?.value ) && !! currentFilter?.value ) {\n\t\treturn [ currentFilter.value ];\n\t}\n\n\treturn EMPTY_ARRAY;\n};\n\nconst getNewValue = (\n\tfilterDefinition: NormalizedFilter,\n\tcurrentFilter: Filter | undefined,\n\tvalue: any\n) => {\n\tif ( filterDefinition.singleSelection ) {\n\t\treturn value;\n\t}\n\n\tif ( Array.isArray( currentFilter?.value ) ) {\n\t\treturn currentFilter.value.includes( value )\n\t\t\t? currentFilter.value.filter( ( v ) => v !== value )\n\t\t\t: [ ...currentFilter.value, value ];\n\t}\n\n\treturn [ value ];\n};\n\nfunction ListBox( { view, filter, onChangeView }: SearchWidgetProps ) {\n\tconst compositeStore = useCompositeStore( {\n\t\tvirtualFocus: true,\n\t\tfocusLoop: true,\n\t\t// When we have no or just one operator, we can set the first item as active.\n\t\t// We do that by passing `undefined` to `defaultActiveId`. Otherwise, we set it to `null`,\n\t\t// so the first item is not selected, since the focus is on the operators control.\n\t\tdefaultActiveId: filter.operators?.length === 1 ? undefined : null,\n\t} );\n\tconst currentFilter = view.filters.find(\n\t\t( f ) => f.field === filter.field\n\t);\n\tconst currentValue = getCurrentValue( filter, currentFilter );\n\treturn (\n\t\t<Composite\n\t\t\tstore={ compositeStore }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"dataviews-search-widget-listbox\"\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: List of items for a filter. 1: Filter name. e.g.: \"List of: Author\". */\n\t\t\t\t__( 'List of: %1$s' ),\n\t\t\t\tfilter.name\n\t\t\t) }\n\t\t\tonFocusVisible={ () => {\n\t\t\t\tif ( ! compositeStore.getState().activeId ) {\n\t\t\t\t\tcompositeStore.move( compositeStore.first() );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trender={ <Ariakit.CompositeTypeahead store={ compositeStore } /> }\n\t\t>\n\t\t\t{ filter.elements.map( ( element ) => (\n\t\t\t\t<Ariakit.CompositeHover\n\t\t\t\t\tstore={ compositeStore }\n\t\t\t\t\tkey={ element.value }\n\t\t\t\t\trender={\n\t\t\t\t\t\t<CompositeItem\n\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\taria-label={ element.label }\n\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-listitem\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst newFilters = currentFilter\n\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t...view.filters.map(\n\t\t\t\t\t\t\t\t\t\t\t\t( _filter ) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t_filter.field ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter.field\n\t\t\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\toperator:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter.operator ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: getNewValue(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telement.value\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn _filter;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t\t\t...view.filters,\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\t\t\t\t\toperator: filter.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: getNewValue(\n\t\t\t\t\t\t\t\t\t\t\t\t\tfilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\telement.value\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t ];\n\t\t\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\t\t\tfilters: newFilters,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-check\">\n\t\t\t\t\t\t{ filter.singleSelection &&\n\t\t\t\t\t\t\tcurrentValue === element.value && (\n\t\t\t\t\t\t\t\t<Icon icon={ radioCheck } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! filter.singleSelection &&\n\t\t\t\t\t\t\tcurrentValue.includes( element.value ) && (\n\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t{ element.label }\n\t\t\t\t\t\t{ !! element.description && (\n\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-description\">\n\t\t\t\t\t\t\t\t{ element.description }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</Ariakit.CompositeHover>\n\t\t\t) ) }\n\t\t</Composite>\n\t);\n}\n\nfunction ComboboxList( { view, filter, onChangeView }: SearchWidgetProps ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst deferredSearchValue = useDeferredValue( searchValue );\n\tconst currentFilter = view.filters.find(\n\t\t( _filter ) => _filter.field === filter.field\n\t);\n\tconst currentValue = getCurrentValue( filter, currentFilter );\n\tconst matches = useMemo( () => {\n\t\tconst normalizedSearch = normalizeSearchInput( deferredSearchValue );\n\t\treturn filter.elements.filter( ( item ) =>\n\t\t\tnormalizeSearchInput( item.label ).includes( normalizedSearch )\n\t\t);\n\t}, [ filter.elements, deferredSearchValue ] );\n\treturn (\n\t\t<Ariakit.ComboboxProvider\n\t\t\tresetValueOnSelect={ false }\n\t\t\tselectedValue={ currentValue }\n\t\t\tsetSelectedValue={ ( value ) => {\n\t\t\t\tconst newFilters = currentFilter\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t...view.filters.map( ( _filter ) => {\n\t\t\t\t\t\t\t\tif ( _filter.field === filter.field ) {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\t\t\t\toperator:\n\t\t\t\t\t\t\t\t\t\t\tcurrentFilter.operator ||\n\t\t\t\t\t\t\t\t\t\t\tfilter.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn _filter;\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t ]\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t...view.filters,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\toperator: filter.operators[ 0 ],\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ];\n\t\t\t\tonChangeView( {\n\t\t\t\t\t...view,\n\t\t\t\t\tpage: 1,\n\t\t\t\t\tfilters: newFilters,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tsetValue={ setSearchValue }\n\t\t>\n\t\t\t<div className=\"dataviews-search-widget-filter-combobox__wrapper\">\n\t\t\t\t<Ariakit.ComboboxLabel\n\t\t\t\t\trender={\n\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t{ __( 'Search items' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Search items' ) }\n\t\t\t\t</Ariakit.ComboboxLabel>\n\t\t\t\t<Ariakit.Combobox\n\t\t\t\t\tautoSelect=\"always\"\n\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox__input\"\n\t\t\t\t/>\n\t\t\t\t<div className=\"dataviews-search-widget-filter-combobox__icon\">\n\t\t\t\t\t<Icon icon={ search } />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<Ariakit.ComboboxList\n\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox-list\"\n\t\t\t\talwaysVisible\n\t\t\t>\n\t\t\t\t{ matches.map( ( element ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Ariakit.ComboboxItem\n\t\t\t\t\t\t\tkey={ element.value }\n\t\t\t\t\t\t\tvalue={ element.value }\n\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-listitem\"\n\t\t\t\t\t\t\thideOnClick={ false }\n\t\t\t\t\t\t\tsetValueOnClick={ false }\n\t\t\t\t\t\t\tfocusOnHover\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-check\">\n\t\t\t\t\t\t\t\t{ filter.singleSelection &&\n\t\t\t\t\t\t\t\t\tcurrentValue === element.value && (\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ radioCheck } />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ ! filter.singleSelection &&\n\t\t\t\t\t\t\t\t\tcurrentValue.includes( element.value ) && (\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<Ariakit.ComboboxItemValue\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox-item-value\"\n\t\t\t\t\t\t\t\t\tvalue={ element.label }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ !! element.description && (\n\t\t\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-description\">\n\t\t\t\t\t\t\t\t\t\t{ element.description }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Ariakit.ComboboxItem>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ ! matches.length && <p>{ __( 'No results found' ) }</p> }\n\t\t\t</Ariakit.ComboboxList>\n\t\t</Ariakit.ComboboxProvider>\n\t);\n}\n\nexport default function SearchWidget( props: SearchWidgetProps ) {\n\tconst Widget = props.filter.elements.length > 10 ? ComboboxList : ListBox;\n\treturn <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;YAAY,CAAE,CAC3B,EACA,CAAEqB,MAAM,CAACN,eAAe,IACzBsB,YAAY,CAACjB,QAAQ,CAAE+B,OAAO,CAACnC,KAAM,CAAC,iBACrCzB,IAAA,CAACT,IAAI;cAAC6E,IAAI,EAAGzE;YAAO,CAAE,CACtB;UAAA,CACG,CAAC,eACPO,KAAA;YAAAU,QAAA,gBACCZ,IAAA,CAACjB,OAAO,CAAC4G,iBAAiB;cACzB1C,SAAS,EAAC,oDAAoD;cAC9DxB,KAAK,EAAGmC,OAAO,CAACE;YAAO,CACvB,CAAC,EACA,CAAC,CAAEF,OAAO,CAACS,WAAW,iBACvBrE,IAAA;cAAMiD,SAAS,EAAC,8CAA8C;cAAArC,QAAA,EAC3DgD,OAAO,CAACS;YAAW,CAChB,CACN;UAAA,CACI,CAAC;QAAA,GA3BDT,OAAO,CAACnC,KA4BO,CAAC;MAEzB,CAAE,CAAC,EACD,CAAEiD,OAAO,CAAClC,MAAM,iBAAIxC,IAAA;QAAAY,QAAA,EAAK3B,EAAE,CAAE,kBAAmB;MAAC,CAAK,CAAC;IAAA,CACpC,CAAC;EAAA,CACE,CAAC;AAE7B;AAEA,eAAe,SAAS2G,YAAYA,CAAEC,KAAwB,EAAG;EAChE,MAAMC,MAAM,GAAGD,KAAK,CAAC/D,MAAM,CAAC4B,QAAQ,CAAClB,MAAM,GAAG,EAAE,GAAG8B,YAAY,GAAGtC,OAAO;EACzE,oBAAOhC,IAAA,CAAC8F,MAAM;IAAA,GAAMD;EAAK,CAAI,CAAC;AAC/B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Ariakit","removeAccents","__","sprintf","useState","useMemo","useDeferredValue","VisuallyHidden","Icon","privateApis","componentsPrivateApis","search","check","SVG","Circle","unlock","jsx","_jsx","jsxs","_jsxs","CompositeV2","Composite","CompositeItemV2","CompositeItem","useCompositeStoreV2","useCompositeStore","radioCheck","xmlns","viewBox","children","cx","cy","r","normalizeSearchInput","input","trim","toLowerCase","EMPTY_ARRAY","getCurrentValue","filterDefinition","currentFilter","singleSelection","value","Array","isArray","getNewValue","includes","filter","v","ListBox","view","onChangeView","compositeStore","virtualFocus","focusLoop","defaultActiveId","operators","length","undefined","filters","find","f","field","currentValue","store","role","className","name","onFocusVisible","getState","activeId","move","first","render","CompositeTypeahead","elements","map","element","CompositeHover","label","onClick","_view$filters","_view$filters2","newFilters","_filter","operator","page","icon","description","ComboboxList","searchValue","setSearchValue","deferredSearchValue","matches","normalizedSearch","item","ComboboxProvider","resetValueOnSelect","selectedValue","setSelectedValue","_view$filters3","_view$filters4","setValue","ComboboxLabel","Combobox","autoSelect","placeholder","alwaysVisible","ComboboxItem","hideOnClick","setValueOnClick","focusOnHover","ComboboxItemValue","SearchWidget","props","Widget"],"sources":["@wordpress/dataviews/src/search-widget.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState, useMemo, useDeferredValue } from '@wordpress/element';\nimport {\n\tVisuallyHidden,\n\tIcon,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { search, check } from '@wordpress/icons';\nimport { SVG, Circle } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nimport type { Filter, NormalizedFilter, View } from './types';\n\nconst {\n\tCompositeV2: Composite,\n\tCompositeItemV2: CompositeItem,\n\tuseCompositeStoreV2: useCompositeStore,\n} = unlock( componentsPrivateApis );\n\ninterface SearchWidgetProps {\n\tview: View;\n\tfilter: NormalizedFilter;\n\tonChangeView: ( view: View ) => void;\n}\n\nconst radioCheck = (\n\t<SVG xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">\n\t\t<Circle cx={ 12 } cy={ 12 } r={ 3 }></Circle>\n\t</SVG>\n);\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\nconst EMPTY_ARRAY: [] = [];\nconst getCurrentValue = (\n\tfilterDefinition: NormalizedFilter,\n\tcurrentFilter?: Filter\n) => {\n\tif ( filterDefinition.singleSelection ) {\n\t\treturn currentFilter?.value;\n\t}\n\n\tif ( Array.isArray( currentFilter?.value ) ) {\n\t\treturn currentFilter.value;\n\t}\n\n\tif ( ! Array.isArray( currentFilter?.value ) && !! currentFilter?.value ) {\n\t\treturn [ currentFilter.value ];\n\t}\n\n\treturn EMPTY_ARRAY;\n};\n\nconst getNewValue = (\n\tfilterDefinition: NormalizedFilter,\n\tcurrentFilter: Filter | undefined,\n\tvalue: any\n) => {\n\tif ( filterDefinition.singleSelection ) {\n\t\treturn value;\n\t}\n\n\tif ( Array.isArray( currentFilter?.value ) ) {\n\t\treturn currentFilter.value.includes( value )\n\t\t\t? currentFilter.value.filter( ( v ) => v !== value )\n\t\t\t: [ ...currentFilter.value, value ];\n\t}\n\n\treturn [ value ];\n};\n\nfunction ListBox( { view, filter, onChangeView }: SearchWidgetProps ) {\n\tconst compositeStore = useCompositeStore( {\n\t\tvirtualFocus: true,\n\t\tfocusLoop: true,\n\t\t// When we have no or just one operator, we can set the first item as active.\n\t\t// We do that by passing `undefined` to `defaultActiveId`. Otherwise, we set it to `null`,\n\t\t// so the first item is not selected, since the focus is on the operators control.\n\t\tdefaultActiveId: filter.operators?.length === 1 ? undefined : null,\n\t} );\n\tconst currentFilter = view.filters?.find(\n\t\t( f ) => f.field === filter.field\n\t);\n\tconst currentValue = getCurrentValue( filter, currentFilter );\n\treturn (\n\t\t<Composite\n\t\t\tstore={ compositeStore }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"dataviews-search-widget-listbox\"\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: List of items for a filter. 1: Filter name. e.g.: \"List of: Author\". */\n\t\t\t\t__( 'List of: %1$s' ),\n\t\t\t\tfilter.name\n\t\t\t) }\n\t\t\tonFocusVisible={ () => {\n\t\t\t\tif ( ! compositeStore.getState().activeId ) {\n\t\t\t\t\tcompositeStore.move( compositeStore.first() );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trender={ <Ariakit.CompositeTypeahead store={ compositeStore } /> }\n\t\t>\n\t\t\t{ filter.elements.map( ( element ) => (\n\t\t\t\t<Ariakit.CompositeHover\n\t\t\t\t\tstore={ compositeStore }\n\t\t\t\t\tkey={ element.value }\n\t\t\t\t\trender={\n\t\t\t\t\t\t<CompositeItem\n\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\taria-label={ element.label }\n\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-listitem\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst newFilters = currentFilter\n\t\t\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t\t\t...( view.filters ?? [] ).map(\n\t\t\t\t\t\t\t\t\t\t\t\t( _filter ) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t_filter.field ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter.field\n\t\t\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\toperator:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter.operator ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: getNewValue(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telement.value\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn _filter;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t\t\t...( view.filters ?? [] ),\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\t\t\t\t\toperator: filter.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: getNewValue(\n\t\t\t\t\t\t\t\t\t\t\t\t\tfilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentFilter,\n\t\t\t\t\t\t\t\t\t\t\t\t\telement.value\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t ];\n\t\t\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\t\t\tfilters: newFilters,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-check\">\n\t\t\t\t\t\t{ filter.singleSelection &&\n\t\t\t\t\t\t\tcurrentValue === element.value && (\n\t\t\t\t\t\t\t\t<Icon icon={ radioCheck } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! filter.singleSelection &&\n\t\t\t\t\t\t\tcurrentValue.includes( element.value ) && (\n\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t{ element.label }\n\t\t\t\t\t\t{ !! element.description && (\n\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-description\">\n\t\t\t\t\t\t\t\t{ element.description }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t</Ariakit.CompositeHover>\n\t\t\t) ) }\n\t\t</Composite>\n\t);\n}\n\nfunction ComboboxList( { view, filter, onChangeView }: SearchWidgetProps ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst deferredSearchValue = useDeferredValue( searchValue );\n\tconst currentFilter = view.filters?.find(\n\t\t( _filter ) => _filter.field === filter.field\n\t);\n\tconst currentValue = getCurrentValue( filter, currentFilter );\n\tconst matches = useMemo( () => {\n\t\tconst normalizedSearch = normalizeSearchInput( deferredSearchValue );\n\t\treturn filter.elements.filter( ( item ) =>\n\t\t\tnormalizeSearchInput( item.label ).includes( normalizedSearch )\n\t\t);\n\t}, [ filter.elements, deferredSearchValue ] );\n\treturn (\n\t\t<Ariakit.ComboboxProvider\n\t\t\tresetValueOnSelect={ false }\n\t\t\tselectedValue={ currentValue }\n\t\t\tsetSelectedValue={ ( value ) => {\n\t\t\t\tconst newFilters = currentFilter\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t...( view.filters ?? [] ).map( ( _filter ) => {\n\t\t\t\t\t\t\t\tif ( _filter.field === filter.field ) {\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\t\t\t\toperator:\n\t\t\t\t\t\t\t\t\t\t\tcurrentFilter.operator ||\n\t\t\t\t\t\t\t\t\t\t\tfilter.operators[ 0 ],\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn _filter;\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t ]\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t...( view.filters ?? [] ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\toperator: filter.operators[ 0 ],\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ];\n\t\t\t\tonChangeView( {\n\t\t\t\t\t...view,\n\t\t\t\t\tpage: 1,\n\t\t\t\t\tfilters: newFilters,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tsetValue={ setSearchValue }\n\t\t>\n\t\t\t<div className=\"dataviews-search-widget-filter-combobox__wrapper\">\n\t\t\t\t<Ariakit.ComboboxLabel\n\t\t\t\t\trender={\n\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t{ __( 'Search items' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Search items' ) }\n\t\t\t\t</Ariakit.ComboboxLabel>\n\t\t\t\t<Ariakit.Combobox\n\t\t\t\t\tautoSelect=\"always\"\n\t\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox__input\"\n\t\t\t\t/>\n\t\t\t\t<div className=\"dataviews-search-widget-filter-combobox__icon\">\n\t\t\t\t\t<Icon icon={ search } />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<Ariakit.ComboboxList\n\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox-list\"\n\t\t\t\talwaysVisible\n\t\t\t>\n\t\t\t\t{ matches.map( ( element ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Ariakit.ComboboxItem\n\t\t\t\t\t\t\tkey={ element.value }\n\t\t\t\t\t\t\tvalue={ element.value }\n\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-listitem\"\n\t\t\t\t\t\t\thideOnClick={ false }\n\t\t\t\t\t\t\tsetValueOnClick={ false }\n\t\t\t\t\t\t\tfocusOnHover\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-check\">\n\t\t\t\t\t\t\t\t{ filter.singleSelection &&\n\t\t\t\t\t\t\t\t\tcurrentValue === element.value && (\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ radioCheck } />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ ! filter.singleSelection &&\n\t\t\t\t\t\t\t\t\tcurrentValue.includes( element.value ) && (\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t\t<Ariakit.ComboboxItemValue\n\t\t\t\t\t\t\t\t\tclassName=\"dataviews-search-widget-filter-combobox-item-value\"\n\t\t\t\t\t\t\t\t\tvalue={ element.label }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ !! element.description && (\n\t\t\t\t\t\t\t\t\t<span className=\"dataviews-search-widget-listitem-description\">\n\t\t\t\t\t\t\t\t\t\t{ element.description }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Ariakit.ComboboxItem>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ ! matches.length && <p>{ __( 'No results found' ) }</p> }\n\t\t\t</Ariakit.ComboboxList>\n\t\t</Ariakit.ComboboxProvider>\n\t);\n}\n\nexport default function SearchWidget( props: SearchWidgetProps ) {\n\tconst Widget = props.filter.elements.length > 10 ? ComboboxList : ListBox;\n\treturn <Widget { ...props } />;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,OAAO,MAAM,gBAAgB;AACzC,OAAOC,aAAa,MAAM,gBAAgB;;AAE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13
|
onSelectionChange,
|
|
14
14
|
item,
|
|
15
|
-
data,
|
|
16
15
|
getItemId,
|
|
17
16
|
primaryField,
|
|
18
17
|
disabled
|
|
19
18
|
}) {
|
|
20
19
|
const id = getItemId(item);
|
|
21
|
-
const
|
|
20
|
+
const checked = !disabled && selection.includes(id);
|
|
22
21
|
let selectionLabel;
|
|
23
22
|
if (primaryField?.getValue && item) {
|
|
24
23
|
// eslint-disable-next-line @wordpress/valid-sprintf
|
|
25
24
|
selectionLabel = sprintf( /* translators: %s: item title. */
|
|
26
|
-
|
|
25
|
+
checked ? __('Deselect item: %s') : __('Select item: %s'), primaryField.getValue({
|
|
27
26
|
item
|
|
28
27
|
}));
|
|
29
28
|
} else {
|
|
30
|
-
selectionLabel =
|
|
29
|
+
selectionLabel = checked ? __('Select a new item') : __('Deselect item');
|
|
31
30
|
}
|
|
32
31
|
return /*#__PURE__*/_jsx(CheckboxControl, {
|
|
33
32
|
className: "dataviews-view-table-selection-checkbox",
|
|
34
33
|
__nextHasNoMarginBottom: true,
|
|
35
34
|
"aria-label": selectionLabel,
|
|
36
35
|
"aria-disabled": disabled,
|
|
37
|
-
checked:
|
|
36
|
+
checked: checked,
|
|
38
37
|
onChange: () => {
|
|
39
38
|
if (disabled) {
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
onSelectionChange(data.filter(_item => {
|
|
44
|
-
const itemId = getItemId?.(_item);
|
|
45
|
-
return itemId === id || selection.includes(itemId);
|
|
46
|
-
}));
|
|
47
|
-
} else {
|
|
48
|
-
onSelectionChange(data.filter(_item => {
|
|
49
|
-
const itemId = getItemId?.(_item);
|
|
50
|
-
return itemId !== id && selection.includes(itemId);
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
41
|
+
onSelectionChange(selection.includes(id) ? selection.filter(itemId => id !== itemId) : [...selection, id]);
|
|
53
42
|
}
|
|
54
43
|
});
|
|
55
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","CheckboxControl","jsx","_jsx","SingleSelectionCheckbox","selection","onSelectionChange","item","
|
|
1
|
+
{"version":3,"names":["__","sprintf","CheckboxControl","jsx","_jsx","SingleSelectionCheckbox","selection","onSelectionChange","item","getItemId","primaryField","disabled","id","checked","includes","selectionLabel","getValue","className","__nextHasNoMarginBottom","onChange","filter","itemId"],"sources":["@wordpress/dataviews/src/single-selection-checkbox.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { CheckboxControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { Field } from './types';\nimport type { SetSelection } from './private-types';\n\ninterface SingleSelectionCheckboxProps< Item > {\n\tselection: string[];\n\tonSelectionChange: SetSelection;\n\titem: Item;\n\tgetItemId: ( item: Item ) => string;\n\tprimaryField?: Field< Item >;\n\tdisabled: boolean;\n}\n\nexport default function SingleSelectionCheckbox< Item >( {\n\tselection,\n\tonSelectionChange,\n\titem,\n\tgetItemId,\n\tprimaryField,\n\tdisabled,\n}: SingleSelectionCheckboxProps< Item > ) {\n\tconst id = getItemId( item );\n\tconst checked = ! disabled && selection.includes( id );\n\tlet selectionLabel;\n\tif ( primaryField?.getValue && item ) {\n\t\t// eslint-disable-next-line @wordpress/valid-sprintf\n\t\tselectionLabel = sprintf(\n\t\t\t/* translators: %s: item title. */\n\t\t\tchecked ? __( 'Deselect item: %s' ) : __( 'Select item: %s' ),\n\t\t\tprimaryField.getValue( { item } )\n\t\t);\n\t} else {\n\t\tselectionLabel = checked\n\t\t\t? __( 'Select a new item' )\n\t\t\t: __( 'Deselect item' );\n\t}\n\treturn (\n\t\t<CheckboxControl\n\t\t\tclassName=\"dataviews-view-table-selection-checkbox\"\n\t\t\t__nextHasNoMarginBottom\n\t\t\taria-label={ selectionLabel }\n\t\t\taria-disabled={ disabled }\n\t\t\tchecked={ checked }\n\t\t\tonChange={ () => {\n\t\t\t\tif ( disabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tonSelectionChange(\n\t\t\t\t\tselection.includes( id )\n\t\t\t\t\t\t? selection.filter( ( itemId ) => id !== itemId )\n\t\t\t\t\t\t: [ ...selection, id ]\n\t\t\t\t);\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,uBAAuB;;AAEvD;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAeA,eAAe,SAASC,uBAAuBA,CAAU;EACxDC,SAAS;EACTC,iBAAiB;EACjBC,IAAI;EACJC,SAAS;EACTC,YAAY;EACZC;AACqC,CAAC,EAAG;EACzC,MAAMC,EAAE,GAAGH,SAAS,CAAED,IAAK,CAAC;EAC5B,MAAMK,OAAO,GAAG,CAAEF,QAAQ,IAAIL,SAAS,CAACQ,QAAQ,CAAEF,EAAG,CAAC;EACtD,IAAIG,cAAc;EAClB,IAAKL,YAAY,EAAEM,QAAQ,IAAIR,IAAI,EAAG;IACrC;IACAO,cAAc,GAAGd,OAAO,EACvB;IACAY,OAAO,GAAGb,EAAE,CAAE,mBAAoB,CAAC,GAAGA,EAAE,CAAE,iBAAkB,CAAC,EAC7DU,YAAY,CAACM,QAAQ,CAAE;MAAER;IAAK,CAAE,CACjC,CAAC;EACF,CAAC,MAAM;IACNO,cAAc,GAAGF,OAAO,GACrBb,EAAE,CAAE,mBAAoB,CAAC,GACzBA,EAAE,CAAE,eAAgB,CAAC;EACzB;EACA,oBACCI,IAAA,CAACF,eAAe;IACfe,SAAS,EAAC,yCAAyC;IACnDC,uBAAuB;IACvB,cAAaH,cAAgB;IAC7B,iBAAgBJ,QAAU;IAC1BE,OAAO,EAAGA,OAAS;IACnBM,QAAQ,EAAGA,CAAA,KAAM;MAChB,IAAKR,QAAQ,EAAG;QACf;MACD;MAEAJ,iBAAiB,CAChBD,SAAS,CAACQ,QAAQ,CAAEF,EAAG,CAAC,GACrBN,SAAS,CAACc,MAAM,CAAIC,MAAM,IAAMT,EAAE,KAAKS,MAAO,CAAC,GAC/C,CAAE,GAAGf,SAAS,EAAEM,EAAE,CACtB,CAAC;IACF;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode } from 'react';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/dataviews/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { SetSelection } from './private-types';\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\ninterface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll';\n\nexport type ItemRecord = Record< string, unknown >;\n\nexport type FieldType = 'text';\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\theader?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ( args: { item: Item } ) => ReactNode;\n\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field is filterable.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | undefined;\n} & ( Item extends ItemRecord\n\t? {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue?: ( args: { item: Item } ) => any;\n\t }\n\t: {\n\t\t\t/**\n\t\t\t * Callback used to retrieve the value of the field from the item.\n\t\t\t * Defaults to `item[ field.id ]`.\n\t\t\t */\n\t\t\tgetValue: ( args: { item: Item } ) => any;\n\t } );\n\nexport type NormalizedField< Item > = Field< Item > & {\n\theader: string;\n\tgetValue: ( args: { item: Item } ) => any;\n\trender: ( args: { item: Item } ) => ReactNode;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type Data< Item > = Item[];\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\tvisibleFields?: string[];\n};\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements: Option[];\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The hidden fields.\n\t */\n\tfields?: string[];\n}\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\t};\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The field to use as the primary field.\n\t\t */\n\t\tprimaryField?: string;\n\n\t\t/**\n\t\t * The field to use as the media field.\n\t\t */\n\t\tmediaField?: string;\n\n\t\t/**\n\t\t * The fields to use as columns.\n\t\t */\n\t\tcolumnFields?: string[];\n\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is destructive.\n\t */\n\tisDestructive?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: {\n\t\titems: Item[];\n\t\tcloseModal?: () => void;\n\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t} ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string;\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonSelectionChange: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tview: View;\n}\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ALL_OPERATORS","OPERATOR_IS","OPERATOR_IS_NOT","OPERATOR_IS_ANY","OPERATOR_IS_NONE","sanitizeOperators","field","operators","filterBy","Array","isArray","filter","operator","includes"],"sources":["@wordpress/dataviews/src/utils.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tALL_OPERATORS,\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n} from './constants';\nimport type {
|
|
1
|
+
{"version":3,"names":["ALL_OPERATORS","OPERATOR_IS","OPERATOR_IS_NOT","OPERATOR_IS_ANY","OPERATOR_IS_NONE","sanitizeOperators","field","operators","filterBy","Array","isArray","filter","operator","includes"],"sources":["@wordpress/dataviews/src/utils.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tALL_OPERATORS,\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n} from './constants';\nimport type { NormalizedField } from './types';\n\nexport function sanitizeOperators< Item >( field: NormalizedField< Item > ) {\n\tlet operators = field.filterBy?.operators;\n\n\t// Assign default values.\n\tif ( ! operators || ! Array.isArray( operators ) ) {\n\t\toperators = [ OPERATOR_IS_ANY, OPERATOR_IS_NONE ];\n\t}\n\n\t// Make sure only valid operators are used.\n\toperators = operators.filter( ( operator ) =>\n\t\tALL_OPERATORS.includes( operator )\n\t);\n\n\t// Do not allow mixing single & multiselection operators.\n\t// Remove multiselection operators if any of the single selection ones is present.\n\tif (\n\t\toperators.includes( OPERATOR_IS ) ||\n\t\toperators.includes( OPERATOR_IS_NOT )\n\t) {\n\t\toperators = operators.filter( ( operator ) =>\n\t\t\t[ OPERATOR_IS, OPERATOR_IS_NOT ].includes( operator )\n\t\t);\n\t}\n\n\treturn operators;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,WAAW,EACXC,eAAe,EACfC,eAAe,EACfC,gBAAgB,QACV,aAAa;AAGpB,OAAO,SAASC,iBAAiBA,CAAUC,KAA8B,EAAG;EAC3E,IAAIC,SAAS,GAAGD,KAAK,CAACE,QAAQ,EAAED,SAAS;;EAEzC;EACA,IAAK,CAAEA,SAAS,IAAI,CAAEE,KAAK,CAACC,OAAO,CAAEH,SAAU,CAAC,EAAG;IAClDA,SAAS,GAAG,CAAEJ,eAAe,EAAEC,gBAAgB,CAAE;EAClD;;EAEA;EACAG,SAAS,GAAGA,SAAS,CAACI,MAAM,CAAIC,QAAQ,IACvCZ,aAAa,CAACa,QAAQ,CAAED,QAAS,CAClC,CAAC;;EAED;EACA;EACA,IACCL,SAAS,CAACM,QAAQ,CAAEZ,WAAY,CAAC,IACjCM,SAAS,CAACM,QAAQ,CAAEX,eAAgB,CAAC,EACpC;IACDK,SAAS,GAAGA,SAAS,CAACI,MAAM,CAAIC,QAAQ,IACvC,CAAEX,WAAW,EAAEC,eAAe,CAAE,CAACW,QAAQ,CAAED,QAAS,CACrD,CAAC;EACF;EAEA,OAAOL,SAAS;AACjB","ignoreList":[]}
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
8
|
-
import { Button, privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { Button, privateApis as componentsPrivateApis, __experimentalHStack as HStack } from '@wordpress/components';
|
|
9
|
+
import { __, _x } from '@wordpress/i18n';
|
|
10
10
|
import { memo } from '@wordpress/element';
|
|
11
|
-
import {
|
|
11
|
+
import { cog } from '@wordpress/icons';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
@@ -18,6 +18,7 @@ import { SORTING_DIRECTIONS, sortLabels } from './constants';
|
|
|
18
18
|
import { VIEW_LAYOUTS } from './layouts';
|
|
19
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
22
|
const {
|
|
22
23
|
DropdownMenuV2: DropdownMenu,
|
|
23
24
|
DropdownMenuGroupV2: DropdownMenuGroup,
|
|
@@ -29,50 +30,43 @@ const {
|
|
|
29
30
|
function ViewTypeMenu({
|
|
30
31
|
view,
|
|
31
32
|
onChangeView,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_availableViews = _availableViews.filter(_view => supportedLayouts.includes(_view.type));
|
|
33
|
+
defaultLayouts = {
|
|
34
|
+
list: {},
|
|
35
|
+
grid: {},
|
|
36
|
+
table: {}
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
}) {
|
|
39
|
+
const availableLayouts = Object.keys(defaultLayouts);
|
|
40
|
+
if (availableLayouts.length <= 1) {
|
|
39
41
|
return null;
|
|
40
42
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
return availableLayouts.map(layout => {
|
|
44
|
+
const config = VIEW_LAYOUTS.find(v => v.type === layout);
|
|
45
|
+
if (!config) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return /*#__PURE__*/_jsx(DropdownMenuRadioItem, {
|
|
49
|
+
value: layout,
|
|
50
|
+
name: "view-actions-available-view",
|
|
51
|
+
checked: layout === view.type,
|
|
52
|
+
hideOnClick: true,
|
|
53
|
+
onChange: e => {
|
|
54
|
+
switch (e.target.value) {
|
|
55
|
+
case 'list':
|
|
56
|
+
case 'grid':
|
|
57
|
+
case 'table':
|
|
58
|
+
return onChangeView({
|
|
59
|
+
...view,
|
|
60
|
+
type: e.target.value,
|
|
61
|
+
...defaultLayouts[e.target.value]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
throw new Error('Invalid dataview');
|
|
65
|
+
},
|
|
48
66
|
children: /*#__PURE__*/_jsx(DropdownMenuItemLabel, {
|
|
49
|
-
children:
|
|
67
|
+
children: config.label
|
|
50
68
|
})
|
|
51
|
-
})
|
|
52
|
-
children: _availableViews.map(availableView => {
|
|
53
|
-
return /*#__PURE__*/_jsx(DropdownMenuRadioItem, {
|
|
54
|
-
value: availableView.type,
|
|
55
|
-
name: "view-actions-available-view",
|
|
56
|
-
checked: availableView.type === view.type,
|
|
57
|
-
hideOnClick: true,
|
|
58
|
-
onChange: e => {
|
|
59
|
-
switch (e.target.value) {
|
|
60
|
-
case 'list':
|
|
61
|
-
case 'grid':
|
|
62
|
-
case 'table':
|
|
63
|
-
return onChangeView({
|
|
64
|
-
...view,
|
|
65
|
-
type: e.target.value,
|
|
66
|
-
layout: {}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
throw new Error('Invalid dataview');
|
|
70
|
-
},
|
|
71
|
-
children: /*#__PURE__*/_jsx(DropdownMenuItemLabel, {
|
|
72
|
-
children: availableView.label
|
|
73
|
-
})
|
|
74
|
-
}, availableView.type);
|
|
75
|
-
})
|
|
69
|
+
}, layout);
|
|
76
70
|
});
|
|
77
71
|
}
|
|
78
72
|
const PAGE_SIZE_VALUES = [10, 20, 50, 100];
|
|
@@ -116,7 +110,8 @@ function FieldsVisibilityMenu({
|
|
|
116
110
|
onChangeView,
|
|
117
111
|
fields
|
|
118
112
|
}) {
|
|
119
|
-
const hidableFields = fields.filter(field => field.enableHiding !== false && field.id !== view
|
|
113
|
+
const hidableFields = fields.filter(field => field.enableHiding !== false && field.id !== view?.layout?.mediaField);
|
|
114
|
+
const viewFields = view.fields || fields.map(field => field.id);
|
|
120
115
|
if (!hidableFields?.length) {
|
|
121
116
|
return null;
|
|
122
117
|
}
|
|
@@ -129,11 +124,11 @@ function FieldsVisibilityMenu({
|
|
|
129
124
|
children: hidableFields?.map(field => {
|
|
130
125
|
return /*#__PURE__*/_jsx(DropdownMenuCheckboxItem, {
|
|
131
126
|
value: field.id,
|
|
132
|
-
checked:
|
|
127
|
+
checked: viewFields.includes(field.id),
|
|
133
128
|
onChange: () => {
|
|
134
129
|
onChangeView({
|
|
135
130
|
...view,
|
|
136
|
-
|
|
131
|
+
fields: viewFields.includes(field.id) ? viewFields.filter(id => id !== field.id) : [...viewFields, field.id]
|
|
137
132
|
});
|
|
138
133
|
},
|
|
139
134
|
children: /*#__PURE__*/_jsx(DropdownMenuItemLabel, {
|
|
@@ -208,30 +203,47 @@ function _ViewActions({
|
|
|
208
203
|
fields,
|
|
209
204
|
view,
|
|
210
205
|
onChangeView,
|
|
211
|
-
|
|
206
|
+
defaultLayouts
|
|
212
207
|
}) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}), /*#__PURE__*/_jsx(
|
|
233
|
-
|
|
234
|
-
|
|
208
|
+
const activeView = VIEW_LAYOUTS.find(v => view.type === v.type);
|
|
209
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
210
|
+
children: /*#__PURE__*/_jsxs(HStack, {
|
|
211
|
+
spacing: 1,
|
|
212
|
+
expanded: false,
|
|
213
|
+
style: {
|
|
214
|
+
flexShrink: 0
|
|
215
|
+
},
|
|
216
|
+
children: [/*#__PURE__*/_jsx(DropdownMenu, {
|
|
217
|
+
trigger: /*#__PURE__*/_jsx(Button, {
|
|
218
|
+
size: "compact",
|
|
219
|
+
icon: activeView?.icon,
|
|
220
|
+
label: __('Layout')
|
|
221
|
+
}),
|
|
222
|
+
children: /*#__PURE__*/_jsx(ViewTypeMenu, {
|
|
223
|
+
view: view,
|
|
224
|
+
onChangeView: onChangeView,
|
|
225
|
+
defaultLayouts: defaultLayouts
|
|
226
|
+
})
|
|
227
|
+
}), /*#__PURE__*/_jsx(DropdownMenu, {
|
|
228
|
+
trigger: /*#__PURE__*/_jsx(Button, {
|
|
229
|
+
size: "compact",
|
|
230
|
+
icon: cog,
|
|
231
|
+
label: _x('View options', 'View is used as a noun')
|
|
232
|
+
}),
|
|
233
|
+
children: /*#__PURE__*/_jsxs(DropdownMenuGroup, {
|
|
234
|
+
children: [/*#__PURE__*/_jsx(SortMenu, {
|
|
235
|
+
fields: fields,
|
|
236
|
+
view: view,
|
|
237
|
+
onChangeView: onChangeView
|
|
238
|
+
}), /*#__PURE__*/_jsx(FieldsVisibilityMenu, {
|
|
239
|
+
fields: fields,
|
|
240
|
+
view: view,
|
|
241
|
+
onChangeView: onChangeView
|
|
242
|
+
}), /*#__PURE__*/_jsx(PageSizeMenu, {
|
|
243
|
+
view: view,
|
|
244
|
+
onChangeView: onChangeView
|
|
245
|
+
})]
|
|
246
|
+
})
|
|
235
247
|
})]
|
|
236
248
|
})
|
|
237
249
|
});
|