@wordpress/dataviews 2.2.0 → 4.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 +23 -0
- package/README.md +23 -8
- package/build/components/dataform/index.js +78 -0
- package/build/components/dataform/index.js.map +1 -0
- package/build/components/dataviews/index.js +115 -0
- package/build/components/dataviews/index.js.map +1 -0
- package/build/{bulk-actions.js → components/dataviews-bulk-actions/index.js} +39 -16
- package/build/components/dataviews-bulk-actions/index.js.map +1 -0
- package/build/{bulk-actions-toolbar.js → components/dataviews-bulk-actions-toolbar/index.js} +36 -20
- package/build/components/dataviews-bulk-actions-toolbar/index.js.map +1 -0
- package/build/components/dataviews-context/index.js +36 -0
- package/build/components/dataviews-context/index.js.map +1 -0
- package/build/{add-filter.js → components/dataviews-filters/add-filter.js} +3 -3
- package/build/components/dataviews-filters/add-filter.js.map +1 -0
- package/build/{filter-summary.js → components/dataviews-filters/filter-summary.js} +15 -14
- package/build/components/dataviews-filters/filter-summary.js.map +1 -0
- package/build/{filters.js → components/dataviews-filters/index.js} +15 -16
- package/build/components/dataviews-filters/index.js.map +1 -0
- package/build/{reset-filters.js → components/dataviews-filters/reset-filters.js} +1 -1
- package/build/components/dataviews-filters/reset-filters.js.map +1 -0
- package/build/{search-widget.js → components/dataviews-filters/search-widget.js} +21 -19
- package/build/components/dataviews-filters/search-widget.js.map +1 -0
- package/build/{item-actions.js → components/dataviews-item-actions/index.js} +3 -3
- package/build/components/dataviews-item-actions/index.js.map +1 -0
- package/build/components/dataviews-layout/index.js +53 -0
- package/build/components/dataviews-layout/index.js.map +1 -0
- package/build/{pagination.js → components/dataviews-pagination/index.js} +18 -15
- package/build/components/dataviews-pagination/index.js.map +1 -0
- package/build/{search.js → components/dataviews-search/index.js} +10 -6
- package/build/components/dataviews-search/index.js.map +1 -0
- package/build/components/dataviews-selection-checkbox/index.js +52 -0
- package/build/components/dataviews-selection-checkbox/index.js.map +1 -0
- package/build/{view-actions.js → components/dataviews-view-config/index.js} +94 -80
- package/build/components/dataviews-view-config/index.js.map +1 -0
- package/build/filter-and-sort-data-view.js +4 -1
- package/build/filter-and-sort-data-view.js.map +1 -1
- package/build/index.js +8 -1
- package/build/index.js.map +1 -1
- package/build/layouts/grid/density-picker.js +143 -0
- package/build/layouts/grid/density-picker.js.map +1 -0
- package/build/{view-grid.js → layouts/grid/index.js} +40 -53
- package/build/layouts/grid/index.js.map +1 -0
- package/build/layouts/index.js +52 -0
- package/build/layouts/index.js.map +1 -0
- package/build/{view-list.js → layouts/list/index.js} +31 -27
- package/build/layouts/list/index.js.map +1 -0
- package/build/layouts/table/column-header-menu.js +196 -0
- package/build/layouts/table/column-header-menu.js.map +1 -0
- package/build/layouts/table/index.js +350 -0
- package/build/layouts/table/index.js.map +1 -0
- package/build/normalize-fields.js +1 -1
- package/build/normalize-fields.js.map +1 -1
- package/build/private-types.js +6 -0
- package/build/private-types.js.map +1 -0
- package/build/types.js.map +1 -1
- package/build/utils.js.map +1 -1
- package/build-module/components/dataform/index.js +72 -0
- package/build-module/components/dataform/index.js.map +1 -0
- package/build-module/components/dataviews/index.js +108 -0
- package/build-module/components/dataviews/index.js.map +1 -0
- package/build-module/{bulk-actions.js → components/dataviews-bulk-actions/index.js} +39 -17
- package/build-module/components/dataviews-bulk-actions/index.js.map +1 -0
- package/build-module/{bulk-actions-toolbar.js → components/dataviews-bulk-actions-toolbar/index.js} +35 -20
- package/build-module/components/dataviews-bulk-actions-toolbar/index.js.map +1 -0
- package/build-module/components/dataviews-context/index.js +30 -0
- package/build-module/components/dataviews-context/index.js.map +1 -0
- package/build-module/{add-filter.js → components/dataviews-filters/add-filter.js} +3 -3
- package/build-module/components/dataviews-filters/add-filter.js.map +1 -0
- package/build-module/{filter-summary.js → components/dataviews-filters/filter-summary.js} +15 -14
- package/build-module/components/dataviews-filters/filter-summary.js.map +1 -0
- package/build-module/{filters.js → components/dataviews-filters/index.js} +16 -17
- package/build-module/components/dataviews-filters/index.js.map +1 -0
- package/build-module/{reset-filters.js → components/dataviews-filters/reset-filters.js} +1 -1
- package/build-module/components/dataviews-filters/reset-filters.js.map +1 -0
- package/build-module/{search-widget.js → components/dataviews-filters/search-widget.js} +21 -19
- package/build-module/components/dataviews-filters/search-widget.js.map +1 -0
- package/build-module/{item-actions.js → components/dataviews-item-actions/index.js} +3 -3
- package/build-module/components/dataviews-item-actions/index.js.map +1 -0
- package/build-module/components/dataviews-layout/index.js +45 -0
- package/build-module/components/dataviews-layout/index.js.map +1 -0
- package/build-module/{pagination.js → components/dataviews-pagination/index.js} +19 -17
- package/build-module/components/dataviews-pagination/index.js.map +1 -0
- package/build-module/{search.js → components/dataviews-search/index.js} +10 -7
- package/build-module/components/dataviews-search/index.js.map +1 -0
- package/build-module/components/dataviews-selection-checkbox/index.js +45 -0
- package/build-module/components/dataviews-selection-checkbox/index.js.map +1 -0
- package/build-module/{view-actions.js → components/dataviews-view-config/index.js} +98 -84
- package/build-module/components/dataviews-view-config/index.js.map +1 -0
- 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/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/grid/density-picker.js +138 -0
- package/build-module/layouts/grid/density-picker.js.map +1 -0
- package/build-module/{view-grid.js → layouts/grid/index.js} +37 -50
- package/build-module/layouts/grid/index.js.map +1 -0
- package/build-module/layouts/index.js +43 -0
- package/build-module/layouts/index.js.map +1 -0
- package/build-module/{view-list.js → layouts/list/index.js} +29 -25
- package/build-module/layouts/list/index.js.map +1 -0
- package/build-module/layouts/table/column-header-menu.js +190 -0
- package/build-module/layouts/table/column-header-menu.js.map +1 -0
- package/build-module/layouts/table/index.js +344 -0
- package/build-module/layouts/table/index.js.map +1 -0
- package/build-module/normalize-fields.js +1 -1
- package/build-module/normalize-fields.js.map +1 -1
- package/build-module/private-types.js +2 -0
- package/build-module/private-types.js.map +1 -0
- package/build-module/types.js.map +1 -1
- package/build-module/utils.js.map +1 -1
- package/build-style/style-rtl.css +607 -561
- package/build-style/style.css +607 -561
- package/build-types/components/dataform/index.d.ts +17 -0
- package/build-types/components/dataform/index.d.ts.map +1 -0
- package/build-types/components/dataform/stories/index.story.d.ts +11 -0
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -0
- package/build-types/components/dataviews/index.d.ts +33 -0
- package/build-types/components/dataviews/index.d.ts.map +1 -0
- package/build-types/{stories → components/dataviews/stories}/fixtures.d.ts +18 -17
- package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -0
- package/build-types/components/dataviews/stories/index.story.d.ts +46 -0
- package/build-types/components/dataviews/stories/index.story.d.ts.map +1 -0
- package/build-types/components/dataviews-bulk-actions/index.d.ts +5 -0
- package/build-types/components/dataviews-bulk-actions/index.d.ts.map +1 -0
- package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts +2 -0
- package/build-types/components/dataviews-bulk-actions-toolbar/index.d.ts.map +1 -0
- package/build-types/components/dataviews-context/index.d.ts +26 -0
- package/build-types/components/dataviews-context/index.d.ts.map +1 -0
- package/build-types/{add-filter.d.ts → components/dataviews-filters/add-filter.d.ts} +1 -2
- package/build-types/components/dataviews-filters/add-filter.d.ts.map +1 -0
- package/build-types/{filter-summary.d.ts → components/dataviews-filters/filter-summary.d.ts} +1 -1
- package/build-types/components/dataviews-filters/filter-summary.d.ts.map +1 -0
- package/build-types/components/dataviews-filters/index.d.ts +4 -0
- package/build-types/components/dataviews-filters/index.d.ts.map +1 -0
- package/build-types/{reset-filters.d.ts → components/dataviews-filters/reset-filters.d.ts} +1 -2
- package/build-types/components/dataviews-filters/reset-filters.d.ts.map +1 -0
- package/build-types/{search-widget.d.ts → components/dataviews-filters/search-widget.d.ts} +1 -2
- package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -0
- package/build-types/components/dataviews-item-actions/index.d.ts +35 -0
- package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -0
- package/build-types/components/dataviews-layout/index.d.ts +2 -0
- package/build-types/components/dataviews-layout/index.d.ts.map +1 -0
- package/build-types/components/dataviews-pagination/index.d.ts +4 -0
- package/build-types/components/dataviews-pagination/index.d.ts.map +1 -0
- package/build-types/components/dataviews-search/index.d.ts +6 -0
- package/build-types/components/dataviews-search/index.d.ts.map +1 -0
- package/build-types/components/dataviews-selection-checkbox/index.d.ts +16 -0
- package/build-types/components/dataviews-selection-checkbox/index.d.ts.map +1 -0
- package/build-types/components/dataviews-view-config/index.d.ts +8 -0
- package/build-types/components/dataviews-view-config/index.d.ts.map +1 -0
- 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/index.d.ts +2 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/layouts/grid/density-picker.d.ts +5 -0
- package/build-types/layouts/grid/density-picker.d.ts.map +1 -0
- package/build-types/layouts/grid/index.d.ts +3 -0
- package/build-types/layouts/grid/index.d.ts.map +1 -0
- package/build-types/{layouts.d.ts → layouts/index.d.ts} +6 -5
- package/build-types/layouts/index.d.ts.map +1 -0
- package/build-types/layouts/list/index.d.ts +3 -0
- package/build-types/layouts/list/index.d.ts.map +1 -0
- package/build-types/layouts/table/column-header-menu.d.ts +17 -0
- package/build-types/layouts/table/column-header-menu.d.ts.map +1 -0
- package/build-types/layouts/table/index.d.ts +4 -0
- package/build-types/layouts/table/index.d.ts.map +1 -0
- package/build-types/normalize-fields.d.ts +2 -2
- package/build-types/normalize-fields.d.ts.map +1 -1
- package/build-types/private-types.d.ts +3 -0
- package/build-types/private-types.d.ts.map +1 -0
- package/build-types/types.d.ts +106 -46
- 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/package.json +10 -10
- package/src/components/dataform/index.tsx +106 -0
- package/src/components/dataform/stories/index.story.tsx +42 -0
- package/src/components/dataviews/index.tsx +149 -0
- package/src/{stories → components/dataviews/stories}/fixtures.js +23 -11
- package/src/components/dataviews/stories/index.story.js +65 -0
- package/src/components/dataviews/style.scss +97 -0
- package/src/{bulk-actions.tsx → components/dataviews-bulk-actions/index.tsx} +58 -36
- package/src/components/dataviews-bulk-actions/style.scss +7 -0
- package/src/{bulk-actions-toolbar.tsx → components/dataviews-bulk-actions-toolbar/index.tsx} +48 -36
- package/src/components/dataviews-bulk-actions-toolbar/style.scss +45 -0
- package/src/components/dataviews-context/index.ts +49 -0
- package/src/{add-filter.tsx → components/dataviews-filters/add-filter.tsx} +4 -4
- package/src/{filter-summary.tsx → components/dataviews-filters/filter-summary.tsx} +36 -22
- package/src/{filters.tsx → components/dataviews-filters/index.tsx} +11 -25
- package/src/{reset-filters.tsx → components/dataviews-filters/reset-filters.tsx} +2 -2
- package/src/{search-widget.tsx → components/dataviews-filters/search-widget.tsx} +20 -20
- package/src/components/dataviews-filters/style.scss +252 -0
- package/src/{item-actions.tsx → components/dataviews-item-actions/index.tsx} +16 -17
- package/src/components/dataviews-item-actions/style.scss +3 -0
- package/src/components/dataviews-layout/index.tsx +51 -0
- package/src/{pagination.tsx → components/dataviews-pagination/index.tsx} +15 -23
- package/src/components/dataviews-pagination/style.scss +26 -0
- package/src/{search.tsx → components/dataviews-search/index.tsx} +5 -10
- package/src/components/dataviews-selection-checkbox/index.tsx +65 -0
- package/src/components/dataviews-selection-checkbox/style.scss +14 -0
- package/src/{view-actions.tsx → components/dataviews-view-config/index.tsx} +116 -119
- package/src/filter-and-sort-data-view.ts +13 -3
- package/src/index.ts +2 -1
- package/src/layouts/grid/density-picker.tsx +136 -0
- package/src/{view-grid.tsx → layouts/grid/index.tsx} +45 -63
- package/src/layouts/grid/style.scss +140 -0
- package/src/layouts/index.ts +66 -0
- package/src/{view-list.tsx → layouts/list/index.tsx} +40 -30
- package/src/layouts/list/style.scss +189 -0
- package/src/layouts/table/column-header-menu.tsx +268 -0
- package/src/layouts/table/index.tsx +471 -0
- package/src/layouts/table/style.scss +201 -0
- package/src/normalize-fields.ts +6 -4
- package/src/private-types.tsx +2 -0
- package/src/style.scss +11 -919
- package/src/test/filter-and-sort-data-view.js +17 -2
- package/src/types.ts +113 -55
- package/src/utils.ts +2 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/build/add-filter.js.map +0 -1
- package/build/bulk-actions-toolbar.js.map +0 -1
- package/build/bulk-actions.js.map +0 -1
- package/build/dataviews.js +0 -136
- package/build/dataviews.js.map +0 -1
- package/build/filter-summary.js.map +0 -1
- package/build/filters.js.map +0 -1
- package/build/item-actions.js.map +0 -1
- package/build/layouts.js +0 -38
- package/build/layouts.js.map +0 -1
- package/build/pagination.js.map +0 -1
- package/build/reset-filters.js.map +0 -1
- package/build/search-widget.js.map +0 -1
- package/build/search.js.map +0 -1
- package/build/single-selection-checkbox.js +0 -63
- package/build/single-selection-checkbox.js.map +0 -1
- package/build/view-actions.js.map +0 -1
- package/build/view-grid.js.map +0 -1
- package/build/view-list.js.map +0 -1
- package/build/view-table.js +0 -409
- package/build/view-table.js.map +0 -1
- package/build-module/add-filter.js.map +0 -1
- package/build-module/bulk-actions-toolbar.js.map +0 -1
- package/build-module/bulk-actions.js.map +0 -1
- package/build-module/dataviews.js +0 -129
- package/build-module/dataviews.js.map +0 -1
- package/build-module/filter-summary.js.map +0 -1
- package/build-module/filters.js.map +0 -1
- package/build-module/item-actions.js.map +0 -1
- package/build-module/layouts.js +0 -30
- package/build-module/layouts.js.map +0 -1
- package/build-module/pagination.js.map +0 -1
- package/build-module/reset-filters.js.map +0 -1
- package/build-module/search-widget.js.map +0 -1
- package/build-module/search.js.map +0 -1
- package/build-module/single-selection-checkbox.js +0 -56
- package/build-module/single-selection-checkbox.js.map +0 -1
- package/build-module/view-actions.js.map +0 -1
- package/build-module/view-grid.js.map +0 -1
- package/build-module/view-list.js.map +0 -1
- package/build-module/view-table.js +0 -402
- package/build-module/view-table.js.map +0 -1
- package/build-types/add-filter.d.ts.map +0 -1
- package/build-types/bulk-actions-toolbar.d.ts +0 -12
- package/build-types/bulk-actions-toolbar.d.ts.map +0 -1
- package/build-types/bulk-actions.d.ts +0 -14
- package/build-types/bulk-actions.d.ts.map +0 -1
- package/build-types/dataviews.d.ts +0 -24
- package/build-types/dataviews.d.ts.map +0 -1
- package/build-types/filter-summary.d.ts.map +0 -1
- package/build-types/filters.d.ts +0 -13
- package/build-types/filters.d.ts.map +0 -1
- package/build-types/item-actions.d.ts +0 -35
- package/build-types/item-actions.d.ts.map +0 -1
- package/build-types/layouts.d.ts.map +0 -1
- package/build-types/pagination.d.ts +0 -16
- package/build-types/pagination.d.ts.map +0 -1
- package/build-types/reset-filters.d.ts.map +0 -1
- package/build-types/search-widget.d.ts.map +0 -1
- package/build-types/search.d.ts +0 -13
- package/build-types/search.d.ts.map +0 -1
- package/build-types/single-selection-checkbox.d.ts +0 -17
- package/build-types/single-selection-checkbox.d.ts.map +0 -1
- package/build-types/stories/fixtures.d.ts.map +0 -1
- package/build-types/stories/index.story.d.ts +0 -15
- package/build-types/stories/index.story.d.ts.map +0 -1
- package/build-types/view-actions.d.ts +0 -12
- package/build-types/view-actions.d.ts.map +0 -1
- package/build-types/view-grid.d.ts +0 -4
- package/build-types/view-grid.d.ts.map +0 -1
- package/build-types/view-list.d.ts +0 -4
- package/build-types/view-list.d.ts.map +0 -1
- package/build-types/view-table.d.ts +0 -5
- package/build-types/view-table.d.ts.map +0 -1
- package/src/dataviews.tsx +0 -189
- package/src/layouts.ts +0 -39
- package/src/single-selection-checkbox.tsx +0 -80
- package/src/stories/index.story.js +0 -64
- package/src/view-table.tsx +0 -603
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataviews.d.ts","sourceRoot":"","sources":["../src/dataviews.tsx"],"names":[],"mappings":";AAuBA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAiB,MAAM,SAAS,CAAC;AAE3E,UAAU,cAAc,CAAE,IAAI,SAAS,OAAO;IAC7C,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IACrC,MAAM,EAAE,KAAK,CAAE,IAAI,CAAE,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAE,IAAI,CAAE,EAAE,CAAC;IAC3B,IAAI,EAAE,IAAI,EAAE,CAAC;IACb,SAAS,CAAC,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,MAAM,CAAC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,CAAC,EAAE,CAAE,SAAS,EAAE,MAAM,EAAE,KAAM,IAAI,CAAC;IAC/C,iBAAiB,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,CAAC;CAC9C;AAqBD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,IAAI,SAAS,OAAO,EAAI,EAC1D,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,MAAa,EACb,WAAuB,EACvB,OAAY,EACZ,IAAI,EACJ,SAA4B,EAC5B,SAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,SAAS,EAAE,iBAAiB,EAC5B,YAAY,EAAE,oBAAoB,EAClC,iBAA4C,GAC5C,EAAE,cAAc,CAAE,IAAI,CAAE,+BA6GxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter-summary.d.ts","sourceRoot":"","sources":["../src/filter-summary.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAkCvC,OAAO,KAAK,EAAU,gBAAgB,EAAoB,IAAI,EAAE,MAAM,SAAS,CAAC;AAQhF,UAAU,qBAAqB;IAC9B,MAAM,EAAE,gBAAgB,CAAC;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;CACrC;AAED,UAAU,kBAAmB,SAAQ,qBAAqB;IACzD,YAAY,EAAE,SAAS,CAAE,iBAAiB,CAAE,CAAC;IAC7C,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAgKD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAE,EACtC,YAAY,EACZ,YAAY,EACZ,GAAG,WAAW,EACd,EAAE,kBAAkB,+BAwGpB"}
|
package/build-types/filters.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { AnyItem, NormalizedField, View } from './types';
|
|
3
|
-
interface FiltersProps<Item extends AnyItem> {
|
|
4
|
-
fields: NormalizedField<Item>[];
|
|
5
|
-
view: View;
|
|
6
|
-
onChangeView: (view: View) => void;
|
|
7
|
-
openedFilter: string | null;
|
|
8
|
-
setOpenedFilter: (openedFilter: string | null) => void;
|
|
9
|
-
}
|
|
10
|
-
declare function _Filters<Item extends AnyItem>({ fields, view, onChangeView, openedFilter, setOpenedFilter, }: FiltersProps<Item>): import("react").JSX.Element;
|
|
11
|
-
declare const Filters: typeof _Filters;
|
|
12
|
-
export default Filters;
|
|
13
|
-
//# sourceMappingURL=filters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../src/filters.tsx"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAoB,IAAI,EAAE,MAAM,SAAS,CAAC;AAEhF,UAAU,YAAY,CAAE,IAAI,SAAS,OAAO;IAC3C,MAAM,EAAE,eAAe,CAAE,IAAI,CAAE,EAAE,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IACrC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,EAAE,CAAE,YAAY,EAAE,MAAM,GAAG,IAAI,KAAM,IAAI,CAAC;CACzD;AAED,iBAAS,QAAQ,CAAE,IAAI,SAAS,OAAO,EAAI,EAC1C,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,eAAe,GACf,EAAE,YAAY,CAAE,IAAI,CAAE,+BAyFtB;AAGD,QAAA,MAAM,OAAO,iBAAsC,CAAC;AAEpD,eAAe,OAAO,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import type { MouseEventHandler, ReactElement } from 'react';
|
|
5
|
-
import type { Action, ActionModal as ActionModalType, AnyItem } from './types';
|
|
6
|
-
export interface ActionTriggerProps<Item extends AnyItem> {
|
|
7
|
-
action: Action<Item>;
|
|
8
|
-
onClick: MouseEventHandler;
|
|
9
|
-
isBusy?: boolean;
|
|
10
|
-
items: Item[];
|
|
11
|
-
}
|
|
12
|
-
interface ActionModalProps<Item extends AnyItem> {
|
|
13
|
-
action: ActionModalType<Item>;
|
|
14
|
-
items: Item[];
|
|
15
|
-
closeModal?: () => void;
|
|
16
|
-
}
|
|
17
|
-
interface ActionWithModalProps<Item extends AnyItem> extends ActionModalProps<Item> {
|
|
18
|
-
ActionTrigger: (props: ActionTriggerProps<Item>) => ReactElement;
|
|
19
|
-
isBusy?: boolean;
|
|
20
|
-
}
|
|
21
|
-
interface ActionsDropdownMenuGroupProps<Item extends AnyItem> {
|
|
22
|
-
actions: Action<Item>[];
|
|
23
|
-
item: Item;
|
|
24
|
-
}
|
|
25
|
-
interface ItemActionsProps<Item extends AnyItem> {
|
|
26
|
-
item: Item;
|
|
27
|
-
actions: Action<Item>[];
|
|
28
|
-
isCompact?: boolean;
|
|
29
|
-
}
|
|
30
|
-
export declare function ActionModal<Item extends AnyItem>({ action, items, closeModal, }: ActionModalProps<Item>): import("react").JSX.Element;
|
|
31
|
-
export declare function ActionWithModal<Item extends AnyItem>({ action, items, ActionTrigger, isBusy, }: ActionWithModalProps<Item>): import("react").JSX.Element;
|
|
32
|
-
export declare function ActionsDropdownMenuGroup<Item extends AnyItem>({ actions, item, }: ActionsDropdownMenuGroupProps<Item>): import("react").JSX.Element;
|
|
33
|
-
export default function ItemActions<Item extends AnyItem>({ item, actions, isCompact, }: ItemActionsProps<Item>): import("react").JSX.Element;
|
|
34
|
-
export {};
|
|
35
|
-
//# sourceMappingURL=item-actions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"item-actions.d.ts","sourceRoot":"","sources":["../src/item-actions.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAoB7D,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,IAAI,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAU/E,MAAM,WAAW,kBAAkB,CAAE,IAAI,SAAS,OAAO;IACxD,MAAM,EAAE,MAAM,CAAE,IAAI,CAAE,CAAC;IACvB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;CACd;AAED,UAAU,gBAAgB,CAAE,IAAI,SAAS,OAAO;IAC/C,MAAM,EAAE,eAAe,CAAE,IAAI,CAAE,CAAC;IAChC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,UAAU,oBAAoB,CAAE,IAAI,SAAS,OAAO,CACnD,SAAQ,gBAAgB,CAAE,IAAI,CAAE;IAChC,aAAa,EAAE,CAAE,KAAK,EAAE,kBAAkB,CAAE,IAAI,CAAE,KAAM,YAAY,CAAC;IACrE,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,UAAU,6BAA6B,CAAE,IAAI,SAAS,OAAO;IAC5D,OAAO,EAAE,MAAM,CAAE,IAAI,CAAE,EAAE,CAAC;IAC1B,IAAI,EAAE,IAAI,CAAC;CACX;AAED,UAAU,gBAAgB,CAAE,IAAI,SAAS,OAAO;IAC/C,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,MAAM,CAAE,IAAI,CAAE,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AA0CD,wBAAgB,WAAW,CAAE,IAAI,SAAS,OAAO,EAAI,EACpD,MAAM,EACN,KAAK,EACL,UAAU,GACV,EAAE,gBAAgB,CAAE,IAAI,CAAE,+BAiB1B;AAED,wBAAgB,eAAe,CAAE,IAAI,SAAS,OAAO,EAAI,EACxD,MAAM,EACN,KAAK,EACL,aAAa,EACb,MAAM,GACN,EAAE,oBAAoB,CAAE,IAAI,CAAE,+BAsB9B;AAED,wBAAgB,wBAAwB,CAAE,IAAI,SAAS,OAAO,EAAI,EACjE,OAAO,EACP,IAAI,GACJ,EAAE,6BAA6B,CAAE,IAAI,CAAE,+BA4BvC;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,IAAI,SAAS,OAAO,EAAI,EAC5D,IAAI,EACJ,OAAO,EACP,SAAS,GACT,EAAE,gBAAgB,CAAE,IAAI,CAAE,+BAuD1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../src/layouts.ts"],"names":[],"mappings":";AAWA;;GAEG;AACH,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,QAAQ,MAAM,aAAa,CAAC;AAGnC,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;IAmBxB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
/**
|
|
3
|
-
* Internal dependencies
|
|
4
|
-
*/
|
|
5
|
-
import type { View } from './types';
|
|
6
|
-
interface PaginationProps {
|
|
7
|
-
view: View;
|
|
8
|
-
onChangeView: (view: View) => void;
|
|
9
|
-
paginationInfo: {
|
|
10
|
-
totalItems: number;
|
|
11
|
-
totalPages: number;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
declare const Pagination: import("react").NamedExoticComponent<PaginationProps>;
|
|
15
|
-
export default Pagination;
|
|
16
|
-
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.tsx"],"names":[],"mappings":";AAYA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,UAAU,eAAe;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IACrC,cAAc,EAAE;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;KACnB,CAAC;CACF;AAED,QAAA,MAAM,UAAU,uDAyFb,CAAC;AAEJ,eAAe,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reset-filters.d.ts","sourceRoot":"","sources":["../src/reset-filters.tsx"],"names":[],"mappings":";AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEtD,UAAU,gBAAgB;IACzB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;CACrC;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,EACpC,OAAO,EACP,IAAI,EACJ,YAAY,GACZ,EAAE,gBAAgB,+BA8BlB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search-widget.d.ts","sourceRoot":"","sources":["../src/search-widget.tsx"],"names":[],"mappings":";AAwBA,OAAO,KAAK,EAAU,gBAAgB,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAQ9D,UAAU,iBAAiB;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,gBAAgB,CAAC;IACzB,YAAY,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;CACrC;AAoRD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,KAAK,EAAE,iBAAiB,+BAG7D"}
|
package/build-types/search.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
/**
|
|
3
|
-
* Internal dependencies
|
|
4
|
-
*/
|
|
5
|
-
import type { View } from './types';
|
|
6
|
-
interface SearchProps {
|
|
7
|
-
label?: string;
|
|
8
|
-
view: View;
|
|
9
|
-
onChangeView: (view: View) => void;
|
|
10
|
-
}
|
|
11
|
-
declare const Search: import("react").NamedExoticComponent<SearchProps>;
|
|
12
|
-
export default Search;
|
|
13
|
-
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.tsx"],"names":[],"mappings":";AAQA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,UAAU,WAAW;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;CACrC;AAED,QAAA,MAAM,MAAM,mDAmCT,CAAC;AAEJ,eAAe,MAAM,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
/**
|
|
3
|
-
* Internal dependencies
|
|
4
|
-
*/
|
|
5
|
-
import type { Field, AnyItem } from './types';
|
|
6
|
-
interface SingleSelectionCheckboxProps<Item extends AnyItem> {
|
|
7
|
-
selection: string[];
|
|
8
|
-
onSelectionChange: (selection: Item[]) => void;
|
|
9
|
-
item: Item;
|
|
10
|
-
data: Item[];
|
|
11
|
-
getItemId: (item: Item) => string;
|
|
12
|
-
primaryField?: Field<Item>;
|
|
13
|
-
disabled: boolean;
|
|
14
|
-
}
|
|
15
|
-
export default function SingleSelectionCheckbox<Item extends AnyItem>({ selection, onSelectionChange, item, data, getItemId, primaryField, disabled, }: SingleSelectionCheckboxProps<Item>): import("react").JSX.Element;
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=single-selection-checkbox.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"single-selection-checkbox.d.ts","sourceRoot":"","sources":["../src/single-selection-checkbox.tsx"],"names":[],"mappings":";AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE9C,UAAU,4BAA4B,CAAE,IAAI,SAAS,OAAO;IAC3D,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,iBAAiB,EAAE,CAAE,SAAS,EAAE,IAAI,EAAE,KAAM,IAAI,CAAC;IACjD,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,IAAI,EAAE,CAAC;IACb,SAAS,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,MAAM,CAAC;IACpC,YAAY,CAAC,EAAE,KAAK,CAAE,IAAI,CAAE,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAE,IAAI,SAAS,OAAO,EAAI,EACxE,SAAS,EACT,iBAAiB,EACjB,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,QAAQ,GACR,EAAE,4BAA4B,CAAE,IAAI,CAAE,+BAkDtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/stories/fixtures.js"],"names":[],"mappings":"AAgBA;;;;;;;IAyFE;;;;;;;;;;AAYF;;;;;;;;;;;;;;;;;;;KA8BE;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2DE;6BAlM2B,cAAc"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export default meta;
|
|
2
|
-
export function Default(props: any): import("react").JSX.Element;
|
|
3
|
-
export namespace Default {
|
|
4
|
-
namespace args {
|
|
5
|
-
export { actions };
|
|
6
|
-
export let supportedLayouts: string[];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
declare namespace meta {
|
|
10
|
-
export let title: string;
|
|
11
|
-
export { DataViews as component };
|
|
12
|
-
}
|
|
13
|
-
import { actions } from './fixtures';
|
|
14
|
-
import { DataViews } from '../index';
|
|
15
|
-
//# sourceMappingURL=index.story.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.js"],"names":[],"mappings":";AA6BO,iEA8BN;;;;;;;;;;;wBAlDmD,YAAY;0BADtC,UAAU"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { AnyItem, NormalizedField, View } from './types';
|
|
3
|
-
interface ViewActionsProps<Item extends AnyItem> {
|
|
4
|
-
fields: NormalizedField<Item>[];
|
|
5
|
-
view: View;
|
|
6
|
-
onChangeView: (view: View) => void;
|
|
7
|
-
supportedLayouts?: string[];
|
|
8
|
-
}
|
|
9
|
-
declare function _ViewActions<Item extends AnyItem>({ fields, view, onChangeView, supportedLayouts, }: ViewActionsProps<Item>): import("react").JSX.Element;
|
|
10
|
-
declare const ViewActions: typeof _ViewActions;
|
|
11
|
-
export default ViewActions;
|
|
12
|
-
//# sourceMappingURL=view-actions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-actions.d.ts","sourceRoot":"","sources":["../src/view-actions.tsx"],"names":[],"mappings":";AAsBA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAkC9D,UAAU,gBAAgB,CAAE,IAAI,SAAS,OAAO;IAC/C,MAAM,EAAE,eAAe,CAAE,IAAI,CAAE,EAAE,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IACrC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAoPD,iBAAS,YAAY,CAAE,IAAI,SAAS,OAAO,EAAI,EAC9C,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,gBAAgB,GAChB,EAAE,gBAAgB,CAAE,IAAI,CAAE,+BA+B1B;AAGD,QAAA,MAAM,WAAW,qBAA8C,CAAC;AAEhE,eAAe,WAAW,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { AnyItem, ViewGridProps } from './types';
|
|
3
|
-
export default function ViewGrid<Item extends AnyItem>({ actions, data, fields, getItemId, isLoading, onSelectionChange, selection, view, }: ViewGridProps<Item>): import("react").JSX.Element;
|
|
4
|
-
//# sourceMappingURL=view-grid.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-grid.d.ts","sourceRoot":"","sources":["../src/view-grid.tsx"],"names":[],"mappings":";AAwBA,OAAO,KAAK,EAAU,OAAO,EAAmB,aAAa,EAAE,MAAM,SAAS,CAAC;AAqK/E,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAE,IAAI,SAAS,OAAO,EAAI,EACzD,OAAO,EACP,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,IAAI,GACJ,EAAE,aAAa,CAAE,IAAI,CAAE,+BAsEvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-list.d.ts","sourceRoot":"","sources":["../src/view-list.tsx"],"names":[],"mappings":";AAmCA,OAAO,KAAK,EAAU,OAAO,EAAmB,aAAa,EAAE,MAAM,SAAS,CAAC;AA8Q/E,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAE,IAAI,SAAS,OAAO,EACrD,KAAK,EAAE,aAAa,CAAE,IAAI,CAAE,+BA2G5B"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { AnyItem, ViewTableProps } from './types';
|
|
3
|
-
declare function ViewTable<Item extends AnyItem>({ actions, data, fields, getItemId, isLoading, onChangeView, onSelectionChange, selection, setOpenedFilter, view, }: ViewTableProps<Item>): import("react").JSX.Element | undefined;
|
|
4
|
-
export default ViewTable;
|
|
5
|
-
//# sourceMappingURL=view-table.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-table.d.ts","sourceRoot":"","sources":["../src/view-table.tsx"],"names":[],"mappings":";AA8CA,OAAO,KAAK,EAEX,OAAO,EAIP,cAAc,EACd,MAAM,SAAS,CAAC;AAsXjB,iBAAS,SAAS,CAAE,IAAI,SAAS,OAAO,EAAI,EAC3C,OAAO,EACP,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,IAAI,GACJ,EAAE,cAAc,CAAE,IAAI,CAAE,2CAkKxB;AAED,eAAe,SAAS,CAAC"}
|
package/src/dataviews.tsx
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import type { ComponentType } from 'react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { __experimentalHStack as HStack } from '@wordpress/components';
|
|
10
|
-
import { useMemo, useState, useCallback } from '@wordpress/element';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import Pagination from './pagination';
|
|
16
|
-
import ViewActions from './view-actions';
|
|
17
|
-
import Filters from './filters';
|
|
18
|
-
import Search from './search';
|
|
19
|
-
import { LAYOUT_TABLE, LAYOUT_GRID } from './constants';
|
|
20
|
-
import { VIEW_LAYOUTS } from './layouts';
|
|
21
|
-
import BulkActions from './bulk-actions';
|
|
22
|
-
import { normalizeFields } from './normalize-fields';
|
|
23
|
-
import BulkActionsToolbar from './bulk-actions-toolbar';
|
|
24
|
-
import type { Action, AnyItem, Field, View, ViewBaseProps } from './types';
|
|
25
|
-
|
|
26
|
-
interface DataViewsProps< Item extends AnyItem > {
|
|
27
|
-
view: View;
|
|
28
|
-
onChangeView: ( view: View ) => void;
|
|
29
|
-
fields: Field< Item >[];
|
|
30
|
-
search?: boolean;
|
|
31
|
-
searchLabel?: string;
|
|
32
|
-
actions?: Action< Item >[];
|
|
33
|
-
data: Item[];
|
|
34
|
-
getItemId?: ( item: Item ) => string;
|
|
35
|
-
isLoading?: boolean;
|
|
36
|
-
paginationInfo: {
|
|
37
|
-
totalItems: number;
|
|
38
|
-
totalPages: number;
|
|
39
|
-
};
|
|
40
|
-
supportedLayouts: string[];
|
|
41
|
-
selection?: string[];
|
|
42
|
-
setSelection?: ( selection: string[] ) => void;
|
|
43
|
-
onSelectionChange?: ( items: Item[] ) => void;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const defaultGetItemId = ( item: AnyItem ) => item.id;
|
|
47
|
-
const defaultOnSelectionChange = () => {};
|
|
48
|
-
|
|
49
|
-
function useSomeItemHasAPossibleBulkAction< Item extends AnyItem >(
|
|
50
|
-
actions: Action< Item >[],
|
|
51
|
-
data: Item[]
|
|
52
|
-
) {
|
|
53
|
-
return useMemo( () => {
|
|
54
|
-
return data.some( ( item ) => {
|
|
55
|
-
return actions.some( ( action ) => {
|
|
56
|
-
return (
|
|
57
|
-
action.supportsBulk &&
|
|
58
|
-
( ! action.isEligible || action.isEligible( item ) )
|
|
59
|
-
);
|
|
60
|
-
} );
|
|
61
|
-
} );
|
|
62
|
-
}, [ actions, data ] );
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default function DataViews< Item extends AnyItem >( {
|
|
66
|
-
view,
|
|
67
|
-
onChangeView,
|
|
68
|
-
fields,
|
|
69
|
-
search = true,
|
|
70
|
-
searchLabel = undefined,
|
|
71
|
-
actions = [],
|
|
72
|
-
data,
|
|
73
|
-
getItemId = defaultGetItemId,
|
|
74
|
-
isLoading = false,
|
|
75
|
-
paginationInfo,
|
|
76
|
-
supportedLayouts,
|
|
77
|
-
selection: selectionProperty,
|
|
78
|
-
setSelection: setSelectionProperty,
|
|
79
|
-
onSelectionChange = defaultOnSelectionChange,
|
|
80
|
-
}: DataViewsProps< Item > ) {
|
|
81
|
-
const [ selectionState, setSelectionState ] = useState< string[] >( [] );
|
|
82
|
-
let selection, setSelection;
|
|
83
|
-
if (
|
|
84
|
-
selectionProperty !== undefined &&
|
|
85
|
-
setSelectionProperty !== undefined
|
|
86
|
-
) {
|
|
87
|
-
selection = selectionProperty;
|
|
88
|
-
setSelection = setSelectionProperty;
|
|
89
|
-
} else {
|
|
90
|
-
selection = selectionState;
|
|
91
|
-
setSelection = setSelectionState;
|
|
92
|
-
}
|
|
93
|
-
const [ openedFilter, setOpenedFilter ] = useState< string | null >( null );
|
|
94
|
-
|
|
95
|
-
const onSetSelection = useCallback(
|
|
96
|
-
( items: Item[] ) => {
|
|
97
|
-
setSelection( items.map( ( item ) => getItemId( item ) ) );
|
|
98
|
-
onSelectionChange( items );
|
|
99
|
-
},
|
|
100
|
-
[ setSelection, getItemId, onSelectionChange ]
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
const ViewComponent = VIEW_LAYOUTS.find( ( v ) => v.type === view.type )
|
|
104
|
-
?.component as ComponentType< ViewBaseProps< Item > >;
|
|
105
|
-
const _fields = useMemo( () => normalizeFields( fields ), [ fields ] );
|
|
106
|
-
|
|
107
|
-
const hasPossibleBulkAction = useSomeItemHasAPossibleBulkAction(
|
|
108
|
-
actions,
|
|
109
|
-
data
|
|
110
|
-
);
|
|
111
|
-
const _selection = useMemo( () => {
|
|
112
|
-
return selection.filter( ( id ) =>
|
|
113
|
-
data.some( ( item ) => getItemId( item ) === id )
|
|
114
|
-
);
|
|
115
|
-
}, [ selection, data, getItemId ] );
|
|
116
|
-
return (
|
|
117
|
-
<div className="dataviews-wrapper">
|
|
118
|
-
<HStack
|
|
119
|
-
alignment="top"
|
|
120
|
-
justify="start"
|
|
121
|
-
className="dataviews-filters__view-actions"
|
|
122
|
-
>
|
|
123
|
-
<HStack
|
|
124
|
-
justify="start"
|
|
125
|
-
className="dataviews-filters__container"
|
|
126
|
-
wrap
|
|
127
|
-
>
|
|
128
|
-
{ search && (
|
|
129
|
-
<Search
|
|
130
|
-
label={ searchLabel }
|
|
131
|
-
view={ view }
|
|
132
|
-
onChangeView={ onChangeView }
|
|
133
|
-
/>
|
|
134
|
-
) }
|
|
135
|
-
<Filters
|
|
136
|
-
fields={ _fields }
|
|
137
|
-
view={ view }
|
|
138
|
-
onChangeView={ onChangeView }
|
|
139
|
-
openedFilter={ openedFilter }
|
|
140
|
-
setOpenedFilter={ setOpenedFilter }
|
|
141
|
-
/>
|
|
142
|
-
</HStack>
|
|
143
|
-
{ [ LAYOUT_TABLE, LAYOUT_GRID ].includes( view.type ) &&
|
|
144
|
-
hasPossibleBulkAction && (
|
|
145
|
-
<BulkActions
|
|
146
|
-
actions={ actions }
|
|
147
|
-
data={ data }
|
|
148
|
-
onSelectionChange={ onSetSelection }
|
|
149
|
-
selection={ _selection }
|
|
150
|
-
getItemId={ getItemId }
|
|
151
|
-
/>
|
|
152
|
-
) }
|
|
153
|
-
<ViewActions
|
|
154
|
-
fields={ _fields }
|
|
155
|
-
view={ view }
|
|
156
|
-
onChangeView={ onChangeView }
|
|
157
|
-
supportedLayouts={ supportedLayouts }
|
|
158
|
-
/>
|
|
159
|
-
</HStack>
|
|
160
|
-
<ViewComponent
|
|
161
|
-
actions={ actions }
|
|
162
|
-
data={ data }
|
|
163
|
-
fields={ _fields }
|
|
164
|
-
getItemId={ getItemId }
|
|
165
|
-
isLoading={ isLoading }
|
|
166
|
-
onChangeView={ onChangeView }
|
|
167
|
-
onSelectionChange={ onSetSelection }
|
|
168
|
-
selection={ _selection }
|
|
169
|
-
setOpenedFilter={ setOpenedFilter }
|
|
170
|
-
view={ view }
|
|
171
|
-
/>
|
|
172
|
-
<Pagination
|
|
173
|
-
view={ view }
|
|
174
|
-
onChangeView={ onChangeView }
|
|
175
|
-
paginationInfo={ paginationInfo }
|
|
176
|
-
/>
|
|
177
|
-
{ [ LAYOUT_TABLE, LAYOUT_GRID ].includes( view.type ) &&
|
|
178
|
-
hasPossibleBulkAction && (
|
|
179
|
-
<BulkActionsToolbar
|
|
180
|
-
data={ data }
|
|
181
|
-
actions={ actions }
|
|
182
|
-
selection={ _selection }
|
|
183
|
-
onSelectionChange={ onSetSelection }
|
|
184
|
-
getItemId={ getItemId }
|
|
185
|
-
/>
|
|
186
|
-
) }
|
|
187
|
-
</div>
|
|
188
|
-
);
|
|
189
|
-
}
|
package/src/layouts.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __, isRTL } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
6
|
-
blockTable,
|
|
7
|
-
category,
|
|
8
|
-
formatListBullets,
|
|
9
|
-
formatListBulletsRTL,
|
|
10
|
-
} from '@wordpress/icons';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import ViewTable from './view-table';
|
|
16
|
-
import ViewGrid from './view-grid';
|
|
17
|
-
import ViewList from './view-list';
|
|
18
|
-
import { LAYOUT_GRID, LAYOUT_LIST, LAYOUT_TABLE } from './constants';
|
|
19
|
-
|
|
20
|
-
export const VIEW_LAYOUTS = [
|
|
21
|
-
{
|
|
22
|
-
type: LAYOUT_TABLE,
|
|
23
|
-
label: __( 'Table' ),
|
|
24
|
-
component: ViewTable,
|
|
25
|
-
icon: blockTable,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: LAYOUT_GRID,
|
|
29
|
-
label: __( 'Grid' ),
|
|
30
|
-
component: ViewGrid,
|
|
31
|
-
icon: category,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
type: LAYOUT_LIST,
|
|
35
|
-
label: __( 'List' ),
|
|
36
|
-
component: ViewList,
|
|
37
|
-
icon: isRTL() ? formatListBulletsRTL : formatListBullets,
|
|
38
|
-
},
|
|
39
|
-
];
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
-
import { CheckboxControl } from '@wordpress/components';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import type { Field, AnyItem } from './types';
|
|
11
|
-
|
|
12
|
-
interface SingleSelectionCheckboxProps< Item extends AnyItem > {
|
|
13
|
-
selection: string[];
|
|
14
|
-
onSelectionChange: ( selection: Item[] ) => void;
|
|
15
|
-
item: Item;
|
|
16
|
-
data: Item[];
|
|
17
|
-
getItemId: ( item: Item ) => string;
|
|
18
|
-
primaryField?: Field< Item >;
|
|
19
|
-
disabled: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default function SingleSelectionCheckbox< Item extends AnyItem >( {
|
|
23
|
-
selection,
|
|
24
|
-
onSelectionChange,
|
|
25
|
-
item,
|
|
26
|
-
data,
|
|
27
|
-
getItemId,
|
|
28
|
-
primaryField,
|
|
29
|
-
disabled,
|
|
30
|
-
}: SingleSelectionCheckboxProps< Item > ) {
|
|
31
|
-
const id = getItemId( item );
|
|
32
|
-
const isSelected = ! disabled && selection.includes( id );
|
|
33
|
-
let selectionLabel;
|
|
34
|
-
if ( primaryField?.getValue && item ) {
|
|
35
|
-
// eslint-disable-next-line @wordpress/valid-sprintf
|
|
36
|
-
selectionLabel = sprintf(
|
|
37
|
-
/* translators: %s: item title. */
|
|
38
|
-
isSelected ? __( 'Deselect item: %s' ) : __( 'Select item: %s' ),
|
|
39
|
-
primaryField.getValue( { item } )
|
|
40
|
-
);
|
|
41
|
-
} else {
|
|
42
|
-
selectionLabel = isSelected
|
|
43
|
-
? __( 'Select a new item' )
|
|
44
|
-
: __( 'Deselect item' );
|
|
45
|
-
}
|
|
46
|
-
return (
|
|
47
|
-
<CheckboxControl
|
|
48
|
-
className="dataviews-view-table-selection-checkbox"
|
|
49
|
-
__nextHasNoMarginBottom
|
|
50
|
-
aria-label={ selectionLabel }
|
|
51
|
-
aria-disabled={ disabled }
|
|
52
|
-
checked={ isSelected }
|
|
53
|
-
onChange={ () => {
|
|
54
|
-
if ( disabled ) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if ( ! isSelected ) {
|
|
59
|
-
onSelectionChange(
|
|
60
|
-
data.filter( ( _item ) => {
|
|
61
|
-
const itemId = getItemId?.( _item );
|
|
62
|
-
return (
|
|
63
|
-
itemId === id || selection.includes( itemId )
|
|
64
|
-
);
|
|
65
|
-
} )
|
|
66
|
-
);
|
|
67
|
-
} else {
|
|
68
|
-
onSelectionChange(
|
|
69
|
-
data.filter( ( _item ) => {
|
|
70
|
-
const itemId = getItemId?.( _item );
|
|
71
|
-
return (
|
|
72
|
-
itemId !== id && selection.includes( itemId )
|
|
73
|
-
);
|
|
74
|
-
} )
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
} }
|
|
78
|
-
/>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useState, useMemo, useCallback } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { DataViews } from '../index';
|
|
10
|
-
import { DEFAULT_VIEW, actions, data, fields } from './fixtures';
|
|
11
|
-
import { LAYOUT_GRID, LAYOUT_TABLE } from '../constants';
|
|
12
|
-
import { filterSortAndPaginate } from '../filter-and-sort-data-view';
|
|
13
|
-
|
|
14
|
-
const meta = {
|
|
15
|
-
title: 'DataViews/DataViews',
|
|
16
|
-
component: DataViews,
|
|
17
|
-
};
|
|
18
|
-
export default meta;
|
|
19
|
-
|
|
20
|
-
const defaultConfigPerViewType = {
|
|
21
|
-
[ LAYOUT_TABLE ]: {
|
|
22
|
-
primaryField: 'title',
|
|
23
|
-
},
|
|
24
|
-
[ LAYOUT_GRID ]: {
|
|
25
|
-
mediaField: 'image',
|
|
26
|
-
primaryField: 'title',
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const Default = ( props ) => {
|
|
31
|
-
const [ view, setView ] = useState( DEFAULT_VIEW );
|
|
32
|
-
const { data: shownData, paginationInfo } = useMemo( () => {
|
|
33
|
-
return filterSortAndPaginate( data, view, fields );
|
|
34
|
-
}, [ view ] );
|
|
35
|
-
const onChangeView = useCallback(
|
|
36
|
-
( newView ) => {
|
|
37
|
-
if ( newView.type !== view.type ) {
|
|
38
|
-
newView = {
|
|
39
|
-
...newView,
|
|
40
|
-
layout: {
|
|
41
|
-
...defaultConfigPerViewType[ newView.type ],
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
setView( newView );
|
|
47
|
-
},
|
|
48
|
-
[ view.type, setView ]
|
|
49
|
-
);
|
|
50
|
-
return (
|
|
51
|
-
<DataViews
|
|
52
|
-
{ ...props }
|
|
53
|
-
paginationInfo={ paginationInfo }
|
|
54
|
-
data={ shownData }
|
|
55
|
-
view={ view }
|
|
56
|
-
fields={ fields }
|
|
57
|
-
onChangeView={ onChangeView }
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
Default.args = {
|
|
62
|
-
actions,
|
|
63
|
-
supportedLayouts: [ LAYOUT_TABLE, LAYOUT_GRID ],
|
|
64
|
-
};
|