@wordpress/dataviews 4.22.0 → 5.0.1-next.719a03cbe.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 +39 -0
- package/README.md +146 -32
- package/build/components/dataviews/index.js +71 -37
- package/build/components/dataviews/index.js.map +1 -1
- package/build/components/dataviews-context/index.js +15 -1
- package/build/components/dataviews-context/index.js.map +1 -1
- package/build/components/dataviews-filters/{filter-summary.js → filter.js} +108 -17
- package/build/components/dataviews-filters/filter.js.map +1 -0
- package/build/components/dataviews-filters/index.js +21 -20
- package/build/components/dataviews-filters/index.js.map +1 -1
- package/build/components/dataviews-filters/input-widget.js +76 -0
- package/build/components/dataviews-filters/input-widget.js.map +1 -0
- package/build/components/dataviews-filters/search-widget.js +33 -39
- package/build/components/dataviews-filters/search-widget.js.map +1 -1
- package/build/components/dataviews-filters/utils.js +25 -0
- package/build/components/dataviews-filters/utils.js.map +1 -0
- package/build/components/dataviews-item-actions/index.js +1 -1
- package/build/components/dataviews-item-actions/index.js.map +1 -1
- package/build/components/dataviews-layout/index.js +7 -2
- package/build/components/dataviews-layout/index.js.map +1 -1
- package/build/components/dataviews-pagination/index.js +4 -3
- package/build/components/dataviews-pagination/index.js.map +1 -1
- package/build/components/dataviews-selection-checkbox/index.js.map +1 -1
- package/build/components/dataviews-view-config/index.js +10 -19
- package/build/components/dataviews-view-config/index.js.map +1 -1
- package/build/constants.js +83 -2
- package/build/constants.js.map +1 -1
- package/build/dataform-controls/boolean.js +42 -0
- package/build/dataform-controls/boolean.js.map +1 -0
- package/build/dataform-controls/checkbox.js +44 -0
- package/build/dataform-controls/checkbox.js.map +1 -0
- package/build/dataform-controls/datetime.js +96 -2
- package/build/dataform-controls/datetime.js.map +1 -1
- package/build/dataform-controls/email.js +48 -0
- package/build/dataform-controls/email.js.map +1 -0
- package/build/dataform-controls/index.js +9 -1
- package/build/dataform-controls/index.js.map +1 -1
- package/build/dataform-controls/integer.js +49 -1
- package/build/dataform-controls/integer.js.map +1 -1
- package/build/dataform-controls/select.js +1 -0
- package/build/dataform-controls/select.js.map +1 -1
- package/build/dataform-controls/text.js +3 -1
- package/build/dataform-controls/text.js.map +1 -1
- package/build/dataform-controls/toggle-group.js +52 -0
- package/build/dataform-controls/toggle-group.js.map +1 -0
- package/build/dataforms-layouts/data-form-layout.js +1 -1
- package/build/dataforms-layouts/data-form-layout.js.map +1 -1
- package/build/dataforms-layouts/panel/index.js +14 -5
- package/build/dataforms-layouts/panel/index.js.map +1 -1
- package/build/dataforms-layouts/regular/index.js +23 -4
- package/build/dataforms-layouts/regular/index.js.map +1 -1
- package/build/dataviews-layouts/grid/index.js +31 -25
- package/build/dataviews-layouts/grid/index.js.map +1 -1
- package/build/dataviews-layouts/list/index.js +11 -6
- package/build/dataviews-layouts/list/index.js.map +1 -1
- package/build/dataviews-layouts/table/column-header-menu.js +9 -7
- package/build/dataviews-layouts/table/column-header-menu.js.map +1 -1
- package/build/dataviews-layouts/table/column-primary.js +18 -13
- package/build/dataviews-layouts/table/column-primary.js.map +1 -1
- package/build/dataviews-layouts/table/index.js +46 -14
- package/build/dataviews-layouts/table/index.js.map +1 -1
- package/build/dataviews-layouts/table/use-is-horizontal-scroll-end.js +65 -0
- package/build/dataviews-layouts/table/use-is-horizontal-scroll-end.js.map +1 -0
- package/build/dataviews-layouts/utils/item-click-wrapper.js +77 -0
- package/build/dataviews-layouts/utils/item-click-wrapper.js.map +1 -0
- package/build/field-types/array.js +62 -0
- package/build/field-types/array.js.map +1 -0
- package/build/field-types/boolean.js +71 -0
- package/build/field-types/boolean.js.map +1 -0
- package/build/field-types/datetime.js +19 -1
- package/build/field-types/datetime.js.map +1 -1
- package/build/field-types/email.js +60 -0
- package/build/field-types/email.js.map +1 -0
- package/build/field-types/index.js +38 -1
- package/build/field-types/index.js.map +1 -1
- package/build/field-types/integer.js +23 -1
- package/build/field-types/integer.js.map +1 -1
- package/build/field-types/media.js +31 -0
- package/build/field-types/media.js.map +1 -0
- package/build/field-types/text.js +23 -1
- package/build/field-types/text.js.map +1 -1
- package/build/filter-and-sort-data-view.js +152 -1
- package/build/filter-and-sort-data-view.js.map +1 -1
- package/build/normalize-fields.js +72 -11
- package/build/normalize-fields.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils.js +11 -19
- package/build/utils.js.map +1 -1
- package/build-module/components/dataviews/index.js +74 -40
- package/build-module/components/dataviews/index.js.map +1 -1
- package/build-module/components/dataviews-context/index.js +16 -2
- package/build-module/components/dataviews-context/index.js.map +1 -1
- package/build-module/components/dataviews-filters/filter.js +309 -0
- package/build-module/components/dataviews-filters/filter.js.map +1 -0
- package/build-module/components/dataviews-filters/index.js +22 -21
- package/build-module/components/dataviews-filters/index.js.map +1 -1
- package/build-module/components/dataviews-filters/input-widget.js +69 -0
- package/build-module/components/dataviews-filters/input-widget.js.map +1 -0
- package/build-module/components/dataviews-filters/search-widget.js +31 -37
- package/build-module/components/dataviews-filters/search-widget.js.map +1 -1
- package/build-module/components/dataviews-filters/utils.js +18 -0
- package/build-module/components/dataviews-filters/utils.js.map +1 -0
- package/build-module/components/dataviews-item-actions/index.js +1 -1
- package/build-module/components/dataviews-item-actions/index.js.map +1 -1
- package/build-module/components/dataviews-layout/index.js +7 -2
- package/build-module/components/dataviews-layout/index.js.map +1 -1
- package/build-module/components/dataviews-pagination/index.js +4 -4
- package/build-module/components/dataviews-pagination/index.js.map +1 -1
- package/build-module/components/dataviews-selection-checkbox/index.js.map +1 -1
- package/build-module/components/dataviews-view-config/index.js +9 -20
- package/build-module/components/dataviews-view-config/index.js.map +1 -1
- package/build-module/constants.js +82 -1
- package/build-module/constants.js.map +1 -1
- package/build-module/dataform-controls/boolean.js +35 -0
- package/build-module/dataform-controls/boolean.js.map +1 -0
- package/build-module/dataform-controls/checkbox.js +37 -0
- package/build-module/dataform-controls/checkbox.js.map +1 -0
- package/build-module/dataform-controls/datetime.js +98 -3
- package/build-module/dataform-controls/datetime.js.map +1 -1
- package/build-module/dataform-controls/email.js +41 -0
- package/build-module/dataform-controls/email.js.map +1 -0
- package/build-module/dataform-controls/index.js +9 -1
- package/build-module/dataform-controls/index.js.map +1 -1
- package/build-module/dataform-controls/integer.js +51 -3
- package/build-module/dataform-controls/integer.js.map +1 -1
- package/build-module/dataform-controls/select.js +1 -0
- package/build-module/dataform-controls/select.js.map +1 -1
- package/build-module/dataform-controls/text.js +3 -1
- package/build-module/dataform-controls/text.js.map +1 -1
- package/build-module/dataform-controls/toggle-group.js +45 -0
- package/build-module/dataform-controls/toggle-group.js.map +1 -0
- package/build-module/dataforms-layouts/data-form-layout.js +1 -1
- package/build-module/dataforms-layouts/data-form-layout.js.map +1 -1
- package/build-module/dataforms-layouts/panel/index.js +14 -5
- package/build-module/dataforms-layouts/panel/index.js.map +1 -1
- package/build-module/dataforms-layouts/regular/index.js +23 -4
- package/build-module/dataforms-layouts/regular/index.js.map +1 -1
- package/build-module/dataviews-layouts/grid/index.js +31 -26
- package/build-module/dataviews-layouts/grid/index.js.map +1 -1
- package/build-module/dataviews-layouts/list/index.js +11 -6
- package/build-module/dataviews-layouts/list/index.js.map +1 -1
- package/build-module/dataviews-layouts/table/column-header-menu.js +9 -7
- package/build-module/dataviews-layouts/table/column-header-menu.js.map +1 -1
- package/build-module/dataviews-layouts/table/column-primary.js +18 -12
- package/build-module/dataviews-layouts/table/column-primary.js.map +1 -1
- package/build-module/dataviews-layouts/table/index.js +47 -16
- package/build-module/dataviews-layouts/table/index.js.map +1 -1
- package/build-module/dataviews-layouts/table/use-is-horizontal-scroll-end.js +58 -0
- package/build-module/dataviews-layouts/table/use-is-horizontal-scroll-end.js.map +1 -0
- package/build-module/dataviews-layouts/utils/item-click-wrapper.js +71 -0
- package/build-module/dataviews-layouts/utils/item-click-wrapper.js.map +1 -0
- package/build-module/field-types/array.js +57 -0
- package/build-module/field-types/array.js.map +1 -0
- package/build-module/field-types/boolean.js +65 -0
- package/build-module/field-types/boolean.js.map +1 -0
- package/build-module/field-types/datetime.js +19 -1
- package/build-module/field-types/datetime.js.map +1 -1
- package/build-module/field-types/email.js +54 -0
- package/build-module/field-types/email.js.map +1 -0
- package/build-module/field-types/index.js +38 -1
- package/build-module/field-types/index.js.map +1 -1
- package/build-module/field-types/integer.js +23 -1
- package/build-module/field-types/integer.js.map +1 -1
- package/build-module/field-types/media.js +25 -0
- package/build-module/field-types/media.js.map +1 -0
- package/build-module/field-types/text.js +23 -1
- package/build-module/field-types/text.js.map +1 -1
- package/build-module/filter-and-sort-data-view.js +153 -2
- package/build-module/filter-and-sort-data-view.js.map +1 -1
- package/build-module/normalize-fields.js +72 -11
- package/build-module/normalize-fields.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-module/utils.js +10 -17
- package/build-module/utils.js.map +1 -1
- package/build-style/style-rtl.css +307 -13
- package/build-style/style.css +307 -13
- package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews/index.d.ts +24 -3
- package/build-types/components/dataviews/index.d.ts.map +1 -1
- package/build-types/components/dataviews/stories/fixtures.d.ts +9 -1
- package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -1
- package/build-types/components/dataviews/stories/index.story.d.ts +22 -4
- package/build-types/components/dataviews/stories/index.story.d.ts.map +1 -1
- package/build-types/components/dataviews-context/index.d.ts +14 -1
- package/build-types/components/dataviews-context/index.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/filter.d.ts +15 -0
- package/build-types/components/dataviews-filters/filter.d.ts.map +1 -0
- package/build-types/components/dataviews-filters/index.d.ts +3 -8
- package/build-types/components/dataviews-filters/index.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/input-widget.d.ts +13 -0
- package/build-types/components/dataviews-filters/input-widget.d.ts.map +1 -0
- package/build-types/components/dataviews-filters/search-widget.d.ts +4 -5
- package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/utils.d.ts +6 -0
- package/build-types/components/dataviews-filters/utils.d.ts.map +1 -0
- package/build-types/components/dataviews-layout/index.d.ts +5 -1
- package/build-types/components/dataviews-layout/index.d.ts.map +1 -1
- package/build-types/components/dataviews-pagination/index.d.ts +1 -1
- package/build-types/components/dataviews-pagination/index.d.ts.map +1 -1
- package/build-types/components/dataviews-selection-checkbox/index.d.ts +2 -2
- package/build-types/components/dataviews-selection-checkbox/index.d.ts.map +1 -1
- package/build-types/components/dataviews-view-config/index.d.ts +3 -4
- package/build-types/components/dataviews-view-config/index.d.ts.map +1 -1
- package/build-types/components/stories/index.story.d.ts +59 -0
- package/build-types/components/stories/index.story.d.ts.map +1 -0
- package/build-types/constants.d.ts +20 -3
- package/build-types/constants.d.ts.map +1 -1
- package/build-types/dataform-controls/boolean.d.ts +6 -0
- package/build-types/dataform-controls/boolean.d.ts.map +1 -0
- package/build-types/dataform-controls/checkbox.d.ts +6 -0
- package/build-types/dataform-controls/checkbox.d.ts.map +1 -0
- package/build-types/dataform-controls/datetime.d.ts +1 -1
- package/build-types/dataform-controls/datetime.d.ts.map +1 -1
- package/build-types/dataform-controls/email.d.ts +6 -0
- package/build-types/dataform-controls/email.d.ts.map +1 -0
- package/build-types/dataform-controls/index.d.ts +1 -1
- package/build-types/dataform-controls/index.d.ts.map +1 -1
- package/build-types/dataform-controls/integer.d.ts +1 -4
- package/build-types/dataform-controls/integer.d.ts.map +1 -1
- package/build-types/dataform-controls/select.d.ts.map +1 -1
- package/build-types/dataform-controls/text.d.ts.map +1 -1
- package/build-types/dataform-controls/toggle-group.d.ts +6 -0
- package/build-types/dataform-controls/toggle-group.d.ts.map +1 -0
- package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -1
- package/build-types/dataforms-layouts/regular/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/grid/index.d.ts +2 -1
- package/build-types/dataviews-layouts/grid/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/index.d.ts +3 -3
- package/build-types/dataviews-layouts/list/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/table/column-header-menu.d.ts.map +1 -1
- package/build-types/dataviews-layouts/table/column-primary.d.ts +8 -1
- package/build-types/dataviews-layouts/table/column-primary.d.ts.map +1 -1
- package/build-types/dataviews-layouts/table/index.d.ts +1 -1
- package/build-types/dataviews-layouts/table/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/table/use-is-horizontal-scroll-end.d.ts +19 -0
- package/build-types/dataviews-layouts/table/use-is-horizontal-scroll-end.d.ts.map +1 -0
- package/build-types/dataviews-layouts/utils/item-click-wrapper.d.ts +15 -0
- package/build-types/dataviews-layouts/utils/item-click-wrapper.d.ts.map +1 -0
- package/build-types/field-types/array.d.ts +7 -0
- package/build-types/field-types/array.d.ts.map +1 -0
- package/build-types/field-types/boolean.d.ts +19 -0
- package/build-types/field-types/boolean.d.ts.map +1 -0
- package/build-types/field-types/datetime.d.ts +7 -1
- package/build-types/field-types/datetime.d.ts.map +1 -1
- package/build-types/field-types/email.d.ts +19 -0
- package/build-types/field-types/email.d.ts.map +1 -0
- package/build-types/field-types/index.d.ts +2 -10
- package/build-types/field-types/index.d.ts.map +1 -1
- package/build-types/field-types/integer.d.ts +7 -1
- package/build-types/field-types/integer.d.ts.map +1 -1
- package/build-types/field-types/media.d.ts +16 -0
- package/build-types/field-types/media.d.ts.map +1 -0
- package/build-types/field-types/text.d.ts +7 -1
- package/build-types/field-types/text.d.ts.map +1 -1
- package/build-types/filter-and-sort-data-view.d.ts.map +1 -1
- package/build-types/normalize-fields.d.ts.map +1 -1
- package/build-types/types.d.ts +70 -8
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils.d.ts +5 -2
- package/build-types/utils.d.ts.map +1 -1
- package/build-wp/index.js +2545 -994
- package/package.json +18 -12
- package/src/components/dataform/stories/index.story.tsx +41 -20
- package/src/components/dataviews/index.tsx +108 -43
- package/src/components/dataviews/stories/fixtures.tsx +58 -13
- package/src/components/dataviews/stories/index.story.tsx +228 -7
- package/src/components/dataviews/stories/style.css +24 -3
- package/src/components/dataviews/style.scss +27 -0
- package/src/components/dataviews-context/index.ts +30 -2
- package/src/components/dataviews-filters/filter.tsx +603 -0
- package/src/components/dataviews-filters/index.tsx +23 -29
- package/src/components/dataviews-filters/input-widget.tsx +91 -0
- package/src/components/dataviews-filters/search-widget.tsx +51 -48
- package/src/components/dataviews-filters/style.scss +117 -14
- package/src/components/dataviews-filters/utils.ts +25 -0
- package/src/components/dataviews-item-actions/index.tsx +1 -1
- package/src/components/dataviews-layout/index.tsx +8 -1
- package/src/components/dataviews-pagination/index.tsx +4 -4
- package/src/components/dataviews-selection-checkbox/index.tsx +2 -2
- package/src/components/dataviews-view-config/index.tsx +10 -18
- package/src/components/stories/index.story.tsx +351 -0
- package/src/constants.ts +116 -1
- package/src/dataform-controls/boolean.tsx +30 -0
- package/src/dataform-controls/checkbox.tsx +31 -0
- package/src/dataform-controls/datetime.tsx +106 -2
- package/src/dataform-controls/email.tsx +42 -0
- package/src/dataform-controls/index.tsx +8 -0
- package/src/dataform-controls/integer.tsx +75 -1
- package/src/dataform-controls/select.tsx +1 -0
- package/src/dataform-controls/style.scss +5 -0
- package/src/dataform-controls/text.tsx +2 -1
- package/src/dataform-controls/toggle-group.tsx +59 -0
- package/src/dataforms-layouts/data-form-layout.tsx +1 -1
- package/src/dataforms-layouts/panel/index.tsx +19 -7
- package/src/dataforms-layouts/panel/style.scss +8 -1
- package/src/dataforms-layouts/regular/index.tsx +50 -17
- package/src/dataforms-layouts/regular/style.scss +4 -1
- package/src/dataviews-layouts/grid/index.tsx +47 -26
- package/src/dataviews-layouts/list/index.tsx +12 -5
- package/src/dataviews-layouts/table/column-header-menu.tsx +10 -8
- package/src/dataviews-layouts/table/column-primary.tsx +26 -13
- package/src/dataviews-layouts/table/index.tsx +74 -10
- package/src/dataviews-layouts/table/style.scss +37 -1
- package/src/dataviews-layouts/table/use-is-horizontal-scroll-end.ts +82 -0
- package/src/dataviews-layouts/utils/item-click-wrapper.tsx +93 -0
- package/src/field-types/array.tsx +75 -0
- package/src/field-types/boolean.tsx +66 -0
- package/src/field-types/datetime.tsx +46 -2
- package/src/field-types/email.tsx +79 -0
- package/src/field-types/index.tsx +45 -3
- package/src/field-types/integer.tsx +53 -2
- package/src/field-types/media.tsx +28 -0
- package/src/field-types/text.tsx +41 -2
- package/src/filter-and-sort-data-view.ts +243 -1
- package/src/normalize-fields.ts +116 -13
- package/src/test/dataviews.tsx +20 -2
- package/src/test/filter-and-sort-data-view.js +507 -0
- package/src/test/normalize-fields.ts +155 -0
- package/src/types.ts +106 -9
- package/src/utils.ts +10 -33
- package/tsconfig.json +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/dataviews-filters/filter-summary.js.map +0 -1
- package/build/dataviews-layouts/utils/get-clickable-item-props.js +0 -36
- package/build/dataviews-layouts/utils/get-clickable-item-props.js.map +0 -1
- package/build-module/components/dataviews-filters/filter-summary.js +0 -218
- package/build-module/components/dataviews-filters/filter-summary.js.map +0 -1
- package/build-module/dataviews-layouts/utils/get-clickable-item-props.js +0 -30
- package/build-module/dataviews-layouts/utils/get-clickable-item-props.js.map +0 -1
- package/build-types/components/dataviews-filters/filter-summary.d.ts +0 -14
- package/build-types/components/dataviews-filters/filter-summary.d.ts.map +0 -1
- package/build-types/dataviews-layouts/utils/get-clickable-item-props.d.ts +0 -19
- package/build-types/dataviews-layouts/utils/get-clickable-item-props.d.ts.map +0 -1
- package/src/components/dataviews-filters/filter-summary.tsx +0 -338
- package/src/dataviews-layouts/utils/get-clickable-item-props.ts +0 -39
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 5.0.0-next.0 (2025-07-08)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- Fix `filterSortAndPaginate` to handle undefined values for the `is` filter.
|
|
10
|
+
- Fix the background color of the action column if the row is selected
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- Add support for free composition in the `DataViews` component by exporting subcomponents: `<DataViews.ViewConfig />`, `<DataViews.Search />`, `<DataViews.Pagination />`, `<DataViews.LayoutSwitcher />`, `<DataViews.Layout />`, `<DataViews.FiltersToggle />`, `<DataViews.Filters />`, `<DataViews.BulkActionToolbar />`.
|
|
15
|
+
- `select`, `text`, `email` controls: add `help` support from the field `description` prop.
|
|
16
|
+
- `text`, `email` Edit control: add `help` support from the field `description` prop.
|
|
17
|
+
|
|
18
|
+
- Add new Edit controls: `checkbox`, `toggleGroup`. In the `toggleGroup`, if the field elements (options) have a `description`, then the selected option's description will be also rendered.
|
|
19
|
+
- Add new `media`, `boolean`, `email` and `array` field type definitions.
|
|
20
|
+
- Field type definitions are now able to define a default `enableSorting` and `render` function.
|
|
21
|
+
- Pin the actions column on the table view when the width is insufficient.
|
|
22
|
+
- Enhance filter component styles.
|
|
23
|
+
- Add user input filter support based on the `Edit` property of the field type definitions.
|
|
24
|
+
- Add new filter operators: `lessThan`, `greaterThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `contains`, `notContains`, `startsWith`, `between`, `on`, `notOn`, `before`, `after`, `inThePast`, `over`, `beforeInc`, and `afterInc`.
|
|
25
|
+
- Add `align` to the `layout.styles` properties, for use in the DataViews table layout. Options are: `start`, `center`, and `end`.
|
|
26
|
+
- Allow fields to opt-out of filtering via `field.filterBy: false`.
|
|
27
|
+
- Update the field type definitions to declare the default and valid operators they support. Fields with no `type` property can use all operators; if none is provided in the field's config, they'll use `is` and `isNot` by default.
|
|
28
|
+
- Adjust the spacing of the `DataForm` based on the type.
|
|
29
|
+
- Add `label-position-side` classes to labels in the form field layouts. Ensure that labels in the panel view do not align center, and that all side labels are center aligned.
|
|
30
|
+
- Allow readonly fields in DataForm when `readOnly` is set to `true`.
|
|
31
|
+
- Adjust the padding when the component is placed inside a `Card`.
|
|
32
|
+
- Introduce `perPageSizes` to control the available sizes of the items per page
|
|
33
|
+
|
|
34
|
+
### Breaking Changes
|
|
35
|
+
|
|
36
|
+
- Fields with `Edit` defined or `type` will automatically be considered as filters unless `filterBy` is set to `false`.
|
|
37
|
+
- Add `renderItemLink` prop support in the `DataViews` component. It replaces `onClickItem`prop and allows integration with router libraries.
|
|
38
|
+
|
|
39
|
+
### Internal
|
|
40
|
+
|
|
41
|
+
- Adds new story that combines DataViews and DataForm.
|
|
42
|
+
- Add a story for each FieldTypeDefinition.
|
|
43
|
+
|
|
5
44
|
## 4.22.0 (2025-06-25)
|
|
6
45
|
|
|
7
46
|
## 4.21.0 (2025-06-04)
|
package/README.md
CHANGED
|
@@ -212,10 +212,13 @@ Properties:
|
|
|
212
212
|
|
|
213
213
|
##### Properties of `layout`
|
|
214
214
|
|
|
215
|
-
| Properties of `layout`
|
|
216
|
-
|
|
|
217
|
-
| `badgeFields`: a list of field's `id` to render without label and styled as badges.
|
|
218
|
-
| `styles`: additional `width`, `maxWidth`, `minWidth` styles for each field column.
|
|
215
|
+
| Properties of `layout` | Table | Grid | List |
|
|
216
|
+
| ------------------------------------------------------------------------------------------- | ----- | ---- | ---- |
|
|
217
|
+
| `badgeFields`: a list of field's `id` to render without label and styled as badges. | | ✓ | |
|
|
218
|
+
| `styles`: additional `width`, `maxWidth`, `minWidth`, `align` styles for each field column. | ✓ | | |
|
|
219
|
+
|
|
220
|
+
**For column alignment (`align` property), follow these guidelines:**
|
|
221
|
+
Right-align whenever the cell value is fundamentally quantitative—numbers, decimals, currency, percentages—so that digits and decimal points line up, aiding comparison and calculation. Otherwise, default to left-alignment for all other types (text, codes, labels, dates).
|
|
219
222
|
|
|
220
223
|
#### `onChangeView`: `function`
|
|
221
224
|
|
|
@@ -298,7 +301,7 @@ const actions = [
|
|
|
298
301
|
icon: <Icon icon={ view } />,
|
|
299
302
|
isEligible: ( item ) => item.status === 'published',
|
|
300
303
|
callback: ( items ) => {
|
|
301
|
-
console.log( 'Viewing item:', items[0] );
|
|
304
|
+
console.log( 'Viewing item:', items[ 0 ] );
|
|
302
305
|
},
|
|
303
306
|
},
|
|
304
307
|
{
|
|
@@ -308,7 +311,7 @@ const actions = [
|
|
|
308
311
|
supportsBulk: true,
|
|
309
312
|
callback: ( items ) => {
|
|
310
313
|
console.log( 'Editing items:', items );
|
|
311
|
-
}
|
|
314
|
+
},
|
|
312
315
|
},
|
|
313
316
|
{
|
|
314
317
|
id: 'delete',
|
|
@@ -320,17 +323,17 @@ const actions = [
|
|
|
320
323
|
<p>Are you sure you want to delete { items.length } item(s)?</p>
|
|
321
324
|
<Button
|
|
322
325
|
variant="primary"
|
|
323
|
-
onClick={() => {
|
|
326
|
+
onClick={ () => {
|
|
324
327
|
console.log( 'Deleting items:', items );
|
|
325
328
|
onActionPerformed();
|
|
326
329
|
closeModal();
|
|
327
|
-
}}
|
|
330
|
+
} }
|
|
328
331
|
>
|
|
329
332
|
Confirm Delete
|
|
330
333
|
</Button>
|
|
331
334
|
</div>
|
|
332
|
-
)
|
|
333
|
-
}
|
|
335
|
+
),
|
|
336
|
+
},
|
|
334
337
|
];
|
|
335
338
|
```
|
|
336
339
|
|
|
@@ -386,14 +389,109 @@ If `selection` and `onChangeSelection` are provided, the `DataViews` component b
|
|
|
386
389
|
|
|
387
390
|
A function that determines if a media field or a primary field is clickable. It receives an item as an argument and returns a boolean value indicating whether the item can be clicked.
|
|
388
391
|
|
|
389
|
-
#### `
|
|
392
|
+
#### `renderItemLink`: `React.ComponentType`
|
|
393
|
+
|
|
394
|
+
A render function used to render clickable items.
|
|
395
|
+
|
|
396
|
+
It can render regular links, but also allows integration with routing libraries (like TanStack Router or React Router).
|
|
397
|
+
|
|
398
|
+
The component receives the following props:
|
|
390
399
|
|
|
391
|
-
|
|
400
|
+
- `item`: The data item that was clicked
|
|
401
|
+
- Additional standard HTML anchor props (className, style, etc.)
|
|
402
|
+
|
|
403
|
+
```jsx
|
|
404
|
+
// Then use it in DataViews
|
|
405
|
+
<DataViews
|
|
406
|
+
// ...other props
|
|
407
|
+
renderItemLink={ ( { item, ...props } ) => (
|
|
408
|
+
<Link to={ `/sites/${ item.slug }` } preload="intent" { ...props } />
|
|
409
|
+
) }
|
|
410
|
+
/>
|
|
411
|
+
```
|
|
392
412
|
|
|
393
413
|
#### `header`: React component
|
|
394
414
|
|
|
395
415
|
React component to be rendered next to the view config button.
|
|
396
416
|
|
|
417
|
+
#### `perPageSizes`: `[ number, number, number, number ]`
|
|
418
|
+
|
|
419
|
+
A list of numbers used to control the available item counts per page.
|
|
420
|
+
|
|
421
|
+
It's optional. Defaults to `[10, 20, 50, 100]`.
|
|
422
|
+
|
|
423
|
+
### Composition modes
|
|
424
|
+
|
|
425
|
+
The `DataViews` component supports two composition modes:
|
|
426
|
+
|
|
427
|
+
- **Controlled**: This is the default usage mode. `DataViews` renders a full layout out-of-the-box — including search, filters, view switcher, layout grid or table, actions, and pagination. It’s the simplest way to get started and requires minimal setup.
|
|
428
|
+
|
|
429
|
+
- **Free composition**: This mode gives developers full control over the layout. You can compose your own UI using internal components — placing them exactly where they’re needed in your interface. This is useful for more advanced or custom layouts, while still relying on the same shared context for user interactions.
|
|
430
|
+
|
|
431
|
+
The component automatically detects the mode based on the `children` prop. If no `children` are passed, `DataViews` renders its internal layout (controlled mode). If `children` are provided, the component switches to free composition mode, skipping the default layout entirely.
|
|
432
|
+
|
|
433
|
+
In both modes, user interactions update the same `view` object and share the same behavior. Free composition components rely on context state and don’t require additional props to work, making them safe to use without extra boilerplate.
|
|
434
|
+
|
|
435
|
+
### Free composition
|
|
436
|
+
|
|
437
|
+
When you pass the `children` prop to the `DataViews` component, it enters free composition mode. In this mode, `DataViews` no longer renders its built-in layout — instead, it acts as a wrapper that provides access to internal state and shared behavior through context.
|
|
438
|
+
|
|
439
|
+
This allows you to build your own layout from scratch using the subcomponents exposed by `DataViews`. Each subcomponent automatically connects to the shared context, so you don't need to wire props manually. You can arrange these components however you want and combine them with your own custom elements.
|
|
440
|
+
|
|
441
|
+
This pattern enables full layout flexibility while keeping the data logic centralized.
|
|
442
|
+
|
|
443
|
+
The following components are available directly under `DataViews`:
|
|
444
|
+
|
|
445
|
+
- `DataViews.Search`
|
|
446
|
+
- `DataViews.FiltersToggle`
|
|
447
|
+
- `DataViews.Filters`
|
|
448
|
+
- `DataViews.Layout`
|
|
449
|
+
- `DataViews.LayoutSwitcher`
|
|
450
|
+
- `DataViews.Pagination`
|
|
451
|
+
- `DataViews.BulkActionToolbar`
|
|
452
|
+
- `DataViews.ViewConfig`
|
|
453
|
+
|
|
454
|
+
#### example
|
|
455
|
+
|
|
456
|
+
```jsx
|
|
457
|
+
import DataViews from '@wordpress/dataviews';
|
|
458
|
+
import { __ } from '@wordpress/i18n';
|
|
459
|
+
|
|
460
|
+
const CustomLayout = () => {
|
|
461
|
+
// Declare data, fields, etc.
|
|
462
|
+
|
|
463
|
+
return (
|
|
464
|
+
<DataViews
|
|
465
|
+
data={ data }
|
|
466
|
+
fields={ fields }
|
|
467
|
+
view={ view }
|
|
468
|
+
onChangeView={ onChangeView }
|
|
469
|
+
paginationInfo={ paginationInfo }
|
|
470
|
+
defaultLayouts={ { table: {} } }
|
|
471
|
+
>
|
|
472
|
+
<h1>{ __( 'Free composition' ) }</h1>
|
|
473
|
+
<DataViews.Search />
|
|
474
|
+
<DataViews.FiltersToggle />
|
|
475
|
+
<DataViews.Filters />
|
|
476
|
+
<DataViews.Layout />
|
|
477
|
+
<DataViews.Pagination />
|
|
478
|
+
</DataViews>
|
|
479
|
+
);
|
|
480
|
+
};
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
> You can render only the pieces you need, rearrange them freely, or combine them with custom components.
|
|
484
|
+
|
|
485
|
+
### Accessibility considerations
|
|
486
|
+
|
|
487
|
+
All `DataViews` subcomponents are designed with accessibility in mind — including keyboard interactions, focus management, and semantic roles. Components like `Search`, `Pagination`, `FiltersToggle`, and `Filters` already handle these responsibilities internally and can be safely used in custom layouts.
|
|
488
|
+
|
|
489
|
+
When using free composition, developers are responsible for the outer structure of the layout.
|
|
490
|
+
|
|
491
|
+
Developers don't need to worry about the internal accessibility logic for individual features. The core behaviors — like search semantics, filter toggles, or pagination focus — are encapsulated.
|
|
492
|
+
|
|
493
|
+
`FiltersToggle` controls the visibility of the filters panel, and `Filters` renders the actual filters inside it. They work together and should always be used as a pair. While their internal behavior is accessible by default, how they’re positioned and grouped in custom layouts may affect the overall experience — especially for assistive technologies. Extra care is recommended.
|
|
494
|
+
|
|
397
495
|
## `DataForm`
|
|
398
496
|
|
|
399
497
|
<div class="callout callout-info">At <a href="https://wordpress.github.io/gutenberg/">WordPress Gutenberg's Storybook</a> there's and <a href="https://wordpress.github.io/gutenberg/?path=/docs/dataviews-dataform--docs">example implementation of the DataForm component</a>.</div>
|
|
@@ -421,7 +519,7 @@ const Example = () => {
|
|
|
421
519
|
|
|
422
520
|
A single item to be edited.
|
|
423
521
|
|
|
424
|
-
It can be thought of as a single record coming from the `data` property of `DataViews` —
|
|
522
|
+
It can be thought of as a single record coming from the `data` property of `DataViews` — though it doesn't need to be. It can be totally separated or a mix of records if your app supports bulk editing.
|
|
425
523
|
|
|
426
524
|
#### `fields`: `Object[]`
|
|
427
525
|
|
|
@@ -709,10 +807,10 @@ The header text to show in the modal.
|
|
|
709
807
|
|
|
710
808
|
Specifies the size of the modal window when displaying action content using `RenderModal`.
|
|
711
809
|
|
|
712
|
-
-
|
|
713
|
-
-
|
|
714
|
-
-
|
|
715
|
-
-
|
|
810
|
+
- Type: `string`
|
|
811
|
+
- Optional
|
|
812
|
+
- Default: `'medium'`
|
|
813
|
+
- One of: `'small'`, `'medium'`, `'large'`, `'fill'`
|
|
716
814
|
|
|
717
815
|
Example:
|
|
718
816
|
|
|
@@ -726,10 +824,10 @@ Example:
|
|
|
726
824
|
|
|
727
825
|
Specifies the focus on mount property of the modal.
|
|
728
826
|
|
|
729
|
-
-
|
|
730
|
-
-
|
|
731
|
-
-
|
|
732
|
-
-
|
|
827
|
+
- Type: `boolean` | `string`
|
|
828
|
+
- Optional
|
|
829
|
+
- Default: `true`
|
|
830
|
+
- One of: `true` | `false` | `'firstElement'` | `'firstContentElement'`
|
|
733
831
|
|
|
734
832
|
Example:
|
|
735
833
|
|
|
@@ -791,7 +889,7 @@ Example:
|
|
|
791
889
|
|
|
792
890
|
### `header`
|
|
793
891
|
|
|
794
|
-
React component used by the layouts to display the field name —
|
|
892
|
+
React component used by the layouts to display the field name — useful to add icons, etc. It's complementary to the `label` property.
|
|
795
893
|
|
|
796
894
|
- Type: React component.
|
|
797
895
|
- Optional.
|
|
@@ -1099,16 +1197,32 @@ Configuration of the filters.
|
|
|
1099
1197
|
|
|
1100
1198
|
Operators:
|
|
1101
1199
|
|
|
1102
|
-
| Operator
|
|
1103
|
-
|
|
|
1104
|
-
| `is`
|
|
1105
|
-
| `isNot`
|
|
1106
|
-
| `isAny`
|
|
1107
|
-
| `isNone`
|
|
1108
|
-
| `isAll`
|
|
1109
|
-
| `isNotAll`
|
|
1110
|
-
|
|
1111
|
-
|
|
1200
|
+
| Operator | Selection | Description | Example |
|
|
1201
|
+
| -------------------- | -------------- | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
|
|
1202
|
+
| `is` | Single item | `EQUAL TO`. The item's field is equal to a single value. | Author is Admin |
|
|
1203
|
+
| `isNot` | Single item | `NOT EQUAL TO`. The item's field is not equal to a single value. | Author is not Admin |
|
|
1204
|
+
| `isAny` | Multiple items | `OR`. The item's field is present in a list of values. | Author is any: Admin, Editor |
|
|
1205
|
+
| `isNone` | Multiple items | `NOT OR`. The item's field is not present in a list of values. | Author is none: Admin, Editor |
|
|
1206
|
+
| `isAll` | Multiple items | `AND`. The item's field has all of the values in the list. | Category is all: Book, Review, Science Fiction |
|
|
1207
|
+
| `isNotAll` | Multiple items | `NOT AND`. The item's field doesn't have all of the values in the list. | Category is not all: Book, Review, Science Fiction |
|
|
1208
|
+
| `lessThan` | Single item | `LESS THAN`. The item's field is numerically less than a single value. | Age is less than 18 |
|
|
1209
|
+
| `greaterThan` | Single item | `GREATER THAN`. The item's field is numerically greater than a single value. | Age is greater than 65 |
|
|
1210
|
+
| `lessThanOrEqual` | Single item | `LESS THAN OR EQUAL TO`. The item's field is numerically less than or equal to a single value. | Age is less than or equal to 18 |
|
|
1211
|
+
| `greaterThanOrEqual` | Single item | `GREATER THAN OR EQUAL TO`. The item's field is numerically greater than or equal to a single value. | Age is greater than or equal to 65 |
|
|
1212
|
+
| `contains` | Text | `CONTAINS`. The item's field contains the given substring. | Title contains: Mars |
|
|
1213
|
+
| `notContains` | Text | `NOT CONTAINS`. The item's field does not contain the given substring. | Description doesn't contain: photo |
|
|
1214
|
+
| `startsWith` | Text | `STARTS WITH`. The item's field starts with the given substring. | Title starts with: Mar |
|
|
1215
|
+
| `on` | Date | `ON`. The item's field is on a given date (date equality using proper date parsing). | Date is on: 2024-01-01 |
|
|
1216
|
+
| `notOn` | Date | `NOT ON`. The item's field is not on a given date (date inequality using proper date parsing). | Date is not on: 2024-01-01 |
|
|
1217
|
+
| `before` | Date | `BEFORE`. The item's field is before a given date. | Date is before 2024-01-01 |
|
|
1218
|
+
| `after` | Date | `AFTER`. The item's field is after a given date. | Date is after 2024-01-01 |
|
|
1219
|
+
| `beforeInc` | Date | `BEFORE (Inc)`. The item's field is before a given date, including the date. | Date is before 2024-01-01, including 2024-01-01 |
|
|
1220
|
+
| `afterInc` | Date | `AFTER (Inc)`. The item's field is after a given date, including the date. | Date is after 2024-01-01, including 2024-01-01 |
|
|
1221
|
+
| `inThePast` | Date | `IN THE PAST`. The item's field is within the last N units (days, weeks, months, or years) from now. | Orders placed in the past 7 days |
|
|
1222
|
+
| `over` | Date | `OVER`. The item's field is older than N units (days, weeks, months, or years) from now. | Orders placed over 7 days ago |
|
|
1223
|
+
| `between` | Multiple items | `BETWEEN`. The item's field is between two values. | Item count between (inc): 10-180 |
|
|
1224
|
+
|
|
1225
|
+
`is`, `isNot`, `on`, `notOn`, `lessThan`, `greaterThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `before`, `after`, `beforeInc`, `afterInc`, `contains`, `notContains`, and `startsWith` are single-selection operators, while `isAny`, `isNone`, `isAll`, and `isNotAll` are multi-selection. `between` is a special operator that requires two values and it's not supported for preset layout. A filter with no operators declared will support the `isAny` and `isNone` multi-selection operators by default. A filter cannot mix single-selection & multi-selection operators; if a single-selection operator is present in the list of valid operators, the multi-selection ones will be discarded, and the filter won't allow selecting more than one item.
|
|
1112
1226
|
|
|
1113
1227
|
Example:
|
|
1114
1228
|
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _components = require("@wordpress/components");
|
|
9
9
|
var _element = require("@wordpress/element");
|
|
10
10
|
var _compose = require("@wordpress/compose");
|
|
@@ -13,7 +13,9 @@ var _dataviewsFilters = _interopRequireWildcard(require("../dataviews-filters"))
|
|
|
13
13
|
var _dataviewsLayout = _interopRequireDefault(require("../dataviews-layout"));
|
|
14
14
|
var _dataviewsFooter = _interopRequireDefault(require("../dataviews-footer"));
|
|
15
15
|
var _dataviewsSearch = _interopRequireDefault(require("../dataviews-search"));
|
|
16
|
-
var
|
|
16
|
+
var _dataviewsBulkActions = require("../dataviews-bulk-actions");
|
|
17
|
+
var _dataviewsPagination = require("../dataviews-pagination");
|
|
18
|
+
var _dataviewsViewConfig = _interopRequireWildcard(require("../dataviews-view-config"));
|
|
17
19
|
var _normalizeFields = require("../../normalize-fields");
|
|
18
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -33,6 +35,40 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
33
35
|
const defaultGetItemId = item => item.id;
|
|
34
36
|
const defaultIsItemClickable = () => true;
|
|
35
37
|
const EMPTY_ARRAY = [];
|
|
38
|
+
function DefaultUI({
|
|
39
|
+
header,
|
|
40
|
+
search = true,
|
|
41
|
+
searchLabel = undefined
|
|
42
|
+
}) {
|
|
43
|
+
const {
|
|
44
|
+
isShowingFilter
|
|
45
|
+
} = (0, _element.useContext)(_dataviewsContext.default);
|
|
46
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
47
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
48
|
+
alignment: "top",
|
|
49
|
+
justify: "space-between",
|
|
50
|
+
className: "dataviews__view-actions",
|
|
51
|
+
spacing: 1,
|
|
52
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
53
|
+
justify: "start",
|
|
54
|
+
expanded: false,
|
|
55
|
+
className: "dataviews__search",
|
|
56
|
+
children: [search && /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsSearch.default, {
|
|
57
|
+
label: searchLabel
|
|
58
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsFilters.FiltersToggle, {})]
|
|
59
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
60
|
+
spacing: 1,
|
|
61
|
+
expanded: false,
|
|
62
|
+
style: {
|
|
63
|
+
flexShrink: 0
|
|
64
|
+
},
|
|
65
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsViewConfig.default, {}), header]
|
|
66
|
+
})]
|
|
67
|
+
}), isShowingFilter && /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsFilters.default, {
|
|
68
|
+
className: "dataviews-filters__container"
|
|
69
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsLayout.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsFooter.default, {})]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
36
72
|
function DataViews({
|
|
37
73
|
view,
|
|
38
74
|
onChangeView,
|
|
@@ -49,11 +85,15 @@ function DataViews({
|
|
|
49
85
|
selection: selectionProperty,
|
|
50
86
|
onChangeSelection,
|
|
51
87
|
onClickItem,
|
|
88
|
+
renderItemLink,
|
|
52
89
|
isItemClickable = defaultIsItemClickable,
|
|
53
|
-
header
|
|
90
|
+
header,
|
|
91
|
+
children,
|
|
92
|
+
perPageSizes
|
|
54
93
|
}) {
|
|
94
|
+
const containerRef = (0, _element.useRef)(null);
|
|
55
95
|
const [containerWidth, setContainerWidth] = (0, _element.useState)(0);
|
|
56
|
-
const
|
|
96
|
+
const resizeObserverRef = (0, _compose.useResizeObserver)(resizeObserverEntries => {
|
|
57
97
|
setContainerWidth(resizeObserverEntries[0].borderBoxSize[0].inlineSize);
|
|
58
98
|
}, {
|
|
59
99
|
box: 'border-box'
|
|
@@ -94,42 +134,36 @@ function DataViews({
|
|
|
94
134
|
getItemLevel,
|
|
95
135
|
isItemClickable,
|
|
96
136
|
onClickItem,
|
|
97
|
-
|
|
137
|
+
renderItemLink,
|
|
138
|
+
containerWidth,
|
|
139
|
+
containerRef,
|
|
140
|
+
defaultLayouts,
|
|
141
|
+
filters,
|
|
142
|
+
isShowingFilter,
|
|
143
|
+
setIsShowingFilter,
|
|
144
|
+
perPageSizes
|
|
98
145
|
},
|
|
99
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
146
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
100
147
|
className: "dataviews-wrapper",
|
|
101
|
-
ref: containerRef,
|
|
102
|
-
children:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
108
|
-
justify: "start",
|
|
109
|
-
expanded: false,
|
|
110
|
-
className: "dataviews__search",
|
|
111
|
-
children: [search && /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsSearch.default, {
|
|
112
|
-
label: searchLabel
|
|
113
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsFilters.FiltersToggle, {
|
|
114
|
-
filters: filters,
|
|
115
|
-
view: view,
|
|
116
|
-
onChangeView: onChangeView,
|
|
117
|
-
setOpenedFilter: setOpenedFilter,
|
|
118
|
-
setIsShowingFilter: setIsShowingFilter,
|
|
119
|
-
isShowingFilter: isShowingFilter
|
|
120
|
-
})]
|
|
121
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
122
|
-
spacing: 1,
|
|
123
|
-
expanded: false,
|
|
124
|
-
style: {
|
|
125
|
-
flexShrink: 0
|
|
126
|
-
},
|
|
127
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsViewConfig.default, {
|
|
128
|
-
defaultLayouts: defaultLayouts
|
|
129
|
-
}), header]
|
|
130
|
-
})]
|
|
131
|
-
}), isShowingFilter && /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsFilters.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsLayout.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataviewsFooter.default, {})]
|
|
148
|
+
ref: (0, _compose.useMergeRefs)([containerRef, resizeObserverRef]),
|
|
149
|
+
children: children !== null && children !== void 0 ? children : /*#__PURE__*/(0, _jsxRuntime.jsx)(DefaultUI, {
|
|
150
|
+
header: header,
|
|
151
|
+
search: search,
|
|
152
|
+
searchLabel: searchLabel
|
|
153
|
+
})
|
|
132
154
|
})
|
|
133
155
|
});
|
|
134
156
|
}
|
|
157
|
+
|
|
158
|
+
// Populate the DataViews sub components
|
|
159
|
+
const DataViewsSubComponents = DataViews;
|
|
160
|
+
DataViewsSubComponents.BulkActionToolbar = _dataviewsBulkActions.BulkActionsFooter;
|
|
161
|
+
DataViewsSubComponents.Filters = _dataviewsFilters.default;
|
|
162
|
+
DataViewsSubComponents.FiltersToggle = _dataviewsFilters.FiltersToggle;
|
|
163
|
+
DataViewsSubComponents.Layout = _dataviewsLayout.default;
|
|
164
|
+
DataViewsSubComponents.LayoutSwitcher = _dataviewsViewConfig.ViewTypeMenu;
|
|
165
|
+
DataViewsSubComponents.Pagination = _dataviewsPagination.DataViewsPagination;
|
|
166
|
+
DataViewsSubComponents.Search = _dataviewsSearch.default;
|
|
167
|
+
DataViewsSubComponents.ViewConfig = _dataviewsViewConfig.DataviewsViewConfigDropdown;
|
|
168
|
+
var _default = exports.default = DataViewsSubComponents;
|
|
135
169
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_compose","_dataviewsContext","_interopRequireDefault","_dataviewsFilters","_interopRequireWildcard","_dataviewsLayout","_dataviewsFooter","_dataviewsSearch","_dataviewsViewConfig","_normalizeFields","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","defaultGetItemId","item","id","defaultIsItemClickable","EMPTY_ARRAY","DataViews","view","onChangeView","fields","search","searchLabel","undefined","actions","data","getItemId","getItemLevel","isLoading","paginationInfo","defaultLayouts","selection","selectionProperty","onChangeSelection","onClickItem","isItemClickable","header","containerWidth","setContainerWidth","useState","containerRef","useResizeObserver","resizeObserverEntries","borderBoxSize","inlineSize","box","selectionState","setSelectionState","isUncontrolled","openedFilter","setOpenedFilter","setSelectionWithChange","value","newValue","_fields","useMemo","normalizeFields","_selection","filter","some","filters","useFilters","isShowingFilter","setIsShowingFilter","isPrimary","jsx","Provider","children","jsxs","className","ref","__experimentalHStack","alignment","justify","spacing","expanded","label","FiltersToggle","style","flexShrink"],"sources":["@wordpress/dataviews/src/components/dataviews/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack } from '@wordpress/components';\nimport { useMemo, useState } from '@wordpress/element';\nimport { useResizeObserver } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport {\n\tdefault as DataViewsFilters,\n\tuseFilters,\n\tFiltersToggle,\n} from '../dataviews-filters';\nimport DataViewsLayout from '../dataviews-layout';\nimport DataViewsFooter from '../dataviews-footer';\nimport DataViewsSearch from '../dataviews-search';\nimport DataViewsViewConfig from '../dataviews-view-config';\nimport { normalizeFields } from '../../normalize-fields';\nimport type { Action, Field, View, SupportedLayouts } from '../../types';\nimport type { SelectionOrUpdater } from '../../private-types';\n\ntype ItemWithId = { id: string };\n\ntype DataViewsProps< Item > = {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n\tfields: Field< Item >[];\n\tsearch?: boolean;\n\tsearchLabel?: string;\n\tactions?: Action< Item >[];\n\tdata: Item[];\n\tisLoading?: boolean;\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t};\n\tdefaultLayouts: SupportedLayouts;\n\tselection?: string[];\n\tonChangeSelection?: ( items: string[] ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\tisItemClickable?: ( item: Item ) => boolean;\n\theader?: ReactNode;\n\tgetItemLevel?: ( item: Item ) => number;\n} & ( Item extends ItemWithId\n\t? { getItemId?: ( item: Item ) => string }\n\t: { getItemId: ( item: Item ) => string } );\n\nconst defaultGetItemId = ( item: ItemWithId ) => item.id;\nconst defaultIsItemClickable = () => true;\nconst EMPTY_ARRAY: any[] = [];\n\nexport default function DataViews< Item >( {\n\tview,\n\tonChangeView,\n\tfields,\n\tsearch = true,\n\tsearchLabel = undefined,\n\tactions = EMPTY_ARRAY,\n\tdata,\n\tgetItemId = defaultGetItemId,\n\tgetItemLevel,\n\tisLoading = false,\n\tpaginationInfo,\n\tdefaultLayouts,\n\tselection: selectionProperty,\n\tonChangeSelection,\n\tonClickItem,\n\tisItemClickable = defaultIsItemClickable,\n\theader,\n}: DataViewsProps< Item > ) {\n\tconst [ containerWidth, setContainerWidth ] = useState( 0 );\n\tconst containerRef = useResizeObserver(\n\t\t( resizeObserverEntries: any ) => {\n\t\t\tsetContainerWidth(\n\t\t\t\tresizeObserverEntries[ 0 ].borderBoxSize[ 0 ].inlineSize\n\t\t\t);\n\t\t},\n\t\t{ box: 'border-box' }\n\t);\n\tconst [ selectionState, setSelectionState ] = useState< string[] >( [] );\n\tconst isUncontrolled =\n\t\tselectionProperty === undefined || onChangeSelection === undefined;\n\tconst selection = isUncontrolled ? selectionState : selectionProperty;\n\tconst [ openedFilter, setOpenedFilter ] = useState< string | null >( null );\n\tfunction setSelectionWithChange( value: SelectionOrUpdater ) {\n\t\tconst newValue =\n\t\t\ttypeof value === 'function' ? value( selection ) : value;\n\t\tif ( isUncontrolled ) {\n\t\t\tsetSelectionState( newValue );\n\t\t}\n\t\tif ( onChangeSelection ) {\n\t\t\tonChangeSelection( newValue );\n\t\t}\n\t}\n\tconst _fields = useMemo( () => normalizeFields( fields ), [ fields ] );\n\tconst _selection = useMemo( () => {\n\t\treturn selection.filter( ( id ) =>\n\t\t\tdata.some( ( item ) => getItemId( item ) === id )\n\t\t);\n\t}, [ selection, data, getItemId ] );\n\n\tconst filters = useFilters( _fields, view );\n\tconst [ isShowingFilter, setIsShowingFilter ] = useState< boolean >( () =>\n\t\t( filters || [] ).some( ( filter ) => filter.isPrimary )\n\t);\n\n\treturn (\n\t\t<DataViewsContext.Provider\n\t\t\tvalue={ {\n\t\t\t\tview,\n\t\t\t\tonChangeView,\n\t\t\t\tfields: _fields,\n\t\t\t\tactions,\n\t\t\t\tdata,\n\t\t\t\tisLoading,\n\t\t\t\tpaginationInfo,\n\t\t\t\tselection: _selection,\n\t\t\t\tonChangeSelection: setSelectionWithChange,\n\t\t\t\topenedFilter,\n\t\t\t\tsetOpenedFilter,\n\t\t\t\tgetItemId,\n\t\t\t\tgetItemLevel,\n\t\t\t\tisItemClickable,\n\t\t\t\tonClickItem,\n\t\t\t\tcontainerWidth,\n\t\t\t} }\n\t\t>\n\t\t\t<div className=\"dataviews-wrapper\" ref={ containerRef }>\n\t\t\t\t<HStack\n\t\t\t\t\talignment=\"top\"\n\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\tclassName=\"dataviews__view-actions\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tjustify=\"start\"\n\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\tclassName=\"dataviews__search\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ search && <DataViewsSearch label={ searchLabel } /> }\n\t\t\t\t\t\t<FiltersToggle\n\t\t\t\t\t\t\tfilters={ filters }\n\t\t\t\t\t\t\tview={ view }\n\t\t\t\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\t\t\t\tsetOpenedFilter={ setOpenedFilter }\n\t\t\t\t\t\t\tsetIsShowingFilter={ setIsShowingFilter }\n\t\t\t\t\t\t\tisShowingFilter={ isShowingFilter }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\tstyle={ { flexShrink: 0 } }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DataViewsViewConfig\n\t\t\t\t\t\t\tdefaultLayouts={ defaultLayouts }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ header }\n\t\t\t\t\t</HStack>\n\t\t\t\t</HStack>\n\t\t\t\t{ isShowingFilter && <DataViewsFilters /> }\n\t\t\t\t<DataViewsLayout />\n\t\t\t\t<DataViewsFooter />\n\t\t\t</div>\n\t\t</DataViewsContext.Provider>\n\t);\n}\n"],"mappings":";;;;;;;AAQA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,iBAAA,GAAAC,sBAAA,CAAAJ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;YACnBgC,cAAc,EAAGA;UAAgB,CACjC,CAAC,EACAM,MAAM;QAAA,CACD,CAAC;MAAA,CACF,CAAC,EACP0B,eAAe,iBAAI,IAAAvE,WAAA,CAAA0E,GAAA,EAACjF,iBAAA,CAAAc,OAAgB,IAAE,CAAC,eACzC,IAAAP,WAAA,CAAA0E,GAAA,EAAC/E,gBAAA,CAAAY,OAAe,IAAE,CAAC,eACnB,IAAAP,WAAA,CAAA0E,GAAA,EAAC9E,gBAAA,CAAAW,OAAe,IAAE,CAAC;IAAA,CACf;EAAC,CACoB,CAAC;AAE9B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_compose","_dataviewsContext","_interopRequireDefault","_dataviewsFilters","_interopRequireWildcard","_dataviewsLayout","_dataviewsFooter","_dataviewsSearch","_dataviewsBulkActions","_dataviewsPagination","_dataviewsViewConfig","_normalizeFields","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","defaultGetItemId","item","id","defaultIsItemClickable","EMPTY_ARRAY","DefaultUI","header","search","searchLabel","undefined","isShowingFilter","useContext","DataViewsContext","jsxs","Fragment","children","__experimentalHStack","alignment","justify","className","spacing","expanded","jsx","label","FiltersToggle","style","flexShrink","DataViews","view","onChangeView","fields","actions","data","getItemId","getItemLevel","isLoading","paginationInfo","defaultLayouts","selection","selectionProperty","onChangeSelection","onClickItem","renderItemLink","isItemClickable","perPageSizes","containerRef","useRef","containerWidth","setContainerWidth","useState","resizeObserverRef","useResizeObserver","resizeObserverEntries","borderBoxSize","inlineSize","box","selectionState","setSelectionState","isUncontrolled","openedFilter","setOpenedFilter","setSelectionWithChange","value","newValue","_fields","useMemo","normalizeFields","_selection","filter","some","filters","useFilters","setIsShowingFilter","isPrimary","Provider","ref","useMergeRefs","DataViewsSubComponents","BulkActionToolbar","BulkActionsFooter","Filters","DataViewsFilters","Layout","DataViewsLayout","LayoutSwitcher","ViewTypeMenu","Pagination","DataViewsPagination","Search","DataViewsSearch","ViewConfig","DataviewsViewConfigDropdown","_default","exports"],"sources":["@wordpress/dataviews/src/components/dataviews/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode, ComponentProps, ReactElement } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack } from '@wordpress/components';\nimport { useContext, useMemo, useRef, useState } from '@wordpress/element';\nimport { useMergeRefs, useResizeObserver } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport {\n\tdefault as DataViewsFilters,\n\tuseFilters,\n\tFiltersToggle,\n} from '../dataviews-filters';\nimport DataViewsLayout from '../dataviews-layout';\nimport DataViewsFooter from '../dataviews-footer';\nimport DataViewsSearch from '../dataviews-search';\nimport { BulkActionsFooter } from '../dataviews-bulk-actions';\nimport { DataViewsPagination } from '../dataviews-pagination';\nimport DataViewsViewConfig, {\n\tDataviewsViewConfigDropdown,\n\tViewTypeMenu,\n} from '../dataviews-view-config';\nimport { normalizeFields } from '../../normalize-fields';\nimport type { Action, Field, View, SupportedLayouts } from '../../types';\nimport type { SelectionOrUpdater } from '../../private-types';\ntype ItemWithId = { id: string };\n\ntype DataViewsProps< Item > = {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n\tfields: Field< Item >[];\n\tsearch?: boolean;\n\tsearchLabel?: string;\n\tactions?: Action< Item >[];\n\tdata: Item[];\n\tisLoading?: boolean;\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t};\n\tdefaultLayouts: SupportedLayouts;\n\tselection?: string[];\n\tonChangeSelection?: ( items: string[] ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable?: ( item: Item ) => boolean;\n\theader?: ReactNode;\n\tgetItemLevel?: ( item: Item ) => number;\n\tchildren?: ReactNode;\n\tperPageSizes?: [ number, number, number, number ];\n} & ( Item extends ItemWithId\n\t? { getItemId?: ( item: Item ) => string }\n\t: { getItemId: ( item: Item ) => string } );\n\nconst defaultGetItemId = ( item: ItemWithId ) => item.id;\nconst defaultIsItemClickable = () => true;\nconst EMPTY_ARRAY: any[] = [];\n\ntype DefaultUIProps = Pick<\n\tDataViewsProps< any >,\n\t'header' | 'search' | 'searchLabel'\n>;\n\nfunction DefaultUI( {\n\theader,\n\tsearch = true,\n\tsearchLabel = undefined,\n}: DefaultUIProps ) {\n\tconst { isShowingFilter } = useContext( DataViewsContext );\n\treturn (\n\t\t<>\n\t\t\t<HStack\n\t\t\t\talignment=\"top\"\n\t\t\t\tjustify=\"space-between\"\n\t\t\t\tclassName=\"dataviews__view-actions\"\n\t\t\t\tspacing={ 1 }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tjustify=\"start\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t\tclassName=\"dataviews__search\"\n\t\t\t\t>\n\t\t\t\t\t{ search && <DataViewsSearch label={ searchLabel } /> }\n\t\t\t\t\t<FiltersToggle />\n\t\t\t\t</HStack>\n\t\t\t\t<HStack\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\texpanded={ false }\n\t\t\t\t\tstyle={ { flexShrink: 0 } }\n\t\t\t\t>\n\t\t\t\t\t<DataViewsViewConfig />\n\t\t\t\t\t{ header }\n\t\t\t\t</HStack>\n\t\t\t</HStack>\n\t\t\t{ isShowingFilter && (\n\t\t\t\t<DataViewsFilters className=\"dataviews-filters__container\" />\n\t\t\t) }\n\t\t\t<DataViewsLayout />\n\t\t\t<DataViewsFooter />\n\t\t</>\n\t);\n}\n\nfunction DataViews< Item >( {\n\tview,\n\tonChangeView,\n\tfields,\n\tsearch = true,\n\tsearchLabel = undefined,\n\tactions = EMPTY_ARRAY,\n\tdata,\n\tgetItemId = defaultGetItemId,\n\tgetItemLevel,\n\tisLoading = false,\n\tpaginationInfo,\n\tdefaultLayouts,\n\tselection: selectionProperty,\n\tonChangeSelection,\n\tonClickItem,\n\trenderItemLink,\n\tisItemClickable = defaultIsItemClickable,\n\theader,\n\tchildren,\n\tperPageSizes,\n}: DataViewsProps< Item > ) {\n\tconst containerRef = useRef< HTMLDivElement | null >( null );\n\tconst [ containerWidth, setContainerWidth ] = useState( 0 );\n\tconst resizeObserverRef = useResizeObserver(\n\t\t( resizeObserverEntries: any ) => {\n\t\t\tsetContainerWidth(\n\t\t\t\tresizeObserverEntries[ 0 ].borderBoxSize[ 0 ].inlineSize\n\t\t\t);\n\t\t},\n\t\t{ box: 'border-box' }\n\t);\n\tconst [ selectionState, setSelectionState ] = useState< string[] >( [] );\n\tconst isUncontrolled =\n\t\tselectionProperty === undefined || onChangeSelection === undefined;\n\tconst selection = isUncontrolled ? selectionState : selectionProperty;\n\tconst [ openedFilter, setOpenedFilter ] = useState< string | null >( null );\n\tfunction setSelectionWithChange( value: SelectionOrUpdater ) {\n\t\tconst newValue =\n\t\t\ttypeof value === 'function' ? value( selection ) : value;\n\t\tif ( isUncontrolled ) {\n\t\t\tsetSelectionState( newValue );\n\t\t}\n\t\tif ( onChangeSelection ) {\n\t\t\tonChangeSelection( newValue );\n\t\t}\n\t}\n\tconst _fields = useMemo( () => normalizeFields( fields ), [ fields ] );\n\tconst _selection = useMemo( () => {\n\t\treturn selection.filter( ( id ) =>\n\t\t\tdata.some( ( item ) => getItemId( item ) === id )\n\t\t);\n\t}, [ selection, data, getItemId ] );\n\n\tconst filters = useFilters( _fields, view );\n\tconst [ isShowingFilter, setIsShowingFilter ] = useState< boolean >( () =>\n\t\t( filters || [] ).some( ( filter ) => filter.isPrimary )\n\t);\n\n\treturn (\n\t\t<DataViewsContext.Provider\n\t\t\tvalue={ {\n\t\t\t\tview,\n\t\t\t\tonChangeView,\n\t\t\t\tfields: _fields,\n\t\t\t\tactions,\n\t\t\t\tdata,\n\t\t\t\tisLoading,\n\t\t\t\tpaginationInfo,\n\t\t\t\tselection: _selection,\n\t\t\t\tonChangeSelection: setSelectionWithChange,\n\t\t\t\topenedFilter,\n\t\t\t\tsetOpenedFilter,\n\t\t\t\tgetItemId,\n\t\t\t\tgetItemLevel,\n\t\t\t\tisItemClickable,\n\t\t\t\tonClickItem,\n\t\t\t\trenderItemLink,\n\t\t\t\tcontainerWidth,\n\t\t\t\tcontainerRef,\n\t\t\t\tdefaultLayouts,\n\t\t\t\tfilters,\n\t\t\t\tisShowingFilter,\n\t\t\t\tsetIsShowingFilter,\n\t\t\t\tperPageSizes,\n\t\t\t} }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"dataviews-wrapper\"\n\t\t\t\tref={ useMergeRefs( [ containerRef, resizeObserverRef ] ) }\n\t\t\t>\n\t\t\t\t{ children ?? (\n\t\t\t\t\t<DefaultUI\n\t\t\t\t\t\theader={ header }\n\t\t\t\t\t\tsearch={ search }\n\t\t\t\t\t\tsearchLabel={ searchLabel }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</DataViewsContext.Provider>\n\t);\n}\n\n// Populate the DataViews sub components\nconst DataViewsSubComponents = DataViews as typeof DataViews & {\n\tBulkActionToolbar: typeof BulkActionsFooter;\n\tFilters: typeof DataViewsFilters;\n\tFiltersToggle: typeof FiltersToggle;\n\tLayout: typeof DataViewsLayout;\n\tLayoutSwitcher: typeof ViewTypeMenu;\n\tPagination: typeof DataViewsPagination;\n\tSearch: typeof DataViewsSearch;\n\tViewConfig: typeof DataviewsViewConfigDropdown;\n};\n\nDataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;\nDataViewsSubComponents.Filters = DataViewsFilters;\nDataViewsSubComponents.FiltersToggle = FiltersToggle;\nDataViewsSubComponents.Layout = DataViewsLayout;\nDataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;\nDataViewsSubComponents.Pagination = DataViewsPagination;\nDataViewsSubComponents.Search = DataViewsSearch;\nDataViewsSubComponents.ViewConfig = Data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,GAAGC,uCAAiB;AAC5DF,sBAAsB,CAACG,OAAO,GAAGC,yBAAgB;AACjDJ,sBAAsB,CAACrD,aAAa,GAAGA,+BAAa;AACpDqD,sBAAsB,CAACK,MAAM,GAAGC,wBAAe;AAC/CN,sBAAsB,CAACO,cAAc,GAAGC,iCAAY;AACpDR,sBAAsB,CAACS,UAAU,GAAGC,wCAAmB;AACvDV,sBAAsB,CAACW,MAAM,GAAGC,wBAAe;AAC/CZ,sBAAsB,CAACa,UAAU,GAAGC,gDAA2B;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3G,OAAA,GAEjD2F,sBAAsB","ignoreList":[]}
|
|
@@ -6,6 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _element = require("@wordpress/element");
|
|
8
8
|
var _constants = require("../../constants");
|
|
9
|
+
/**
|
|
10
|
+
* External dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
9
13
|
/**
|
|
10
14
|
* WordPress dependencies
|
|
11
15
|
*/
|
|
@@ -31,7 +35,17 @@ const DataViewsContext = (0, _element.createContext)({
|
|
|
31
35
|
openedFilter: null,
|
|
32
36
|
getItemId: item => item.id,
|
|
33
37
|
isItemClickable: () => true,
|
|
34
|
-
|
|
38
|
+
renderItemLink: undefined,
|
|
39
|
+
containerWidth: 0,
|
|
40
|
+
containerRef: (0, _element.createRef)(),
|
|
41
|
+
defaultLayouts: {
|
|
42
|
+
list: {},
|
|
43
|
+
grid: {},
|
|
44
|
+
table: {}
|
|
45
|
+
},
|
|
46
|
+
filters: [],
|
|
47
|
+
isShowingFilter: false,
|
|
48
|
+
setIsShowingFilter: () => {}
|
|
35
49
|
});
|
|
36
50
|
var _default = exports.default = DataViewsContext;
|
|
37
51
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_constants","DataViewsContext","createContext","view","type","LAYOUT_TABLE","onChangeView","fields","data","paginationInfo","totalItems","totalPages","selection","onChangeSelection","setOpenedFilter","openedFilter","getItemId","item","id","isItemClickable","containerWidth","_default","exports","default"],"sources":["@wordpress/dataviews/src/components/dataviews-context/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {
|
|
1
|
+
{"version":3,"names":["_element","require","_constants","DataViewsContext","createContext","view","type","LAYOUT_TABLE","onChangeView","fields","data","paginationInfo","totalItems","totalPages","selection","onChangeSelection","setOpenedFilter","openedFilter","getItemId","item","id","isItemClickable","renderItemLink","undefined","containerWidth","containerRef","createRef","defaultLayouts","list","grid","table","filters","isShowingFilter","setIsShowingFilter","_default","exports","default"],"sources":["@wordpress/dataviews/src/components/dataviews-context/index.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentProps, ReactElement } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { createContext, createRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tView,\n\tAction,\n\tNormalizedField,\n\tSupportedLayouts,\n\tNormalizedFilter,\n} from '../../types';\nimport type { SetSelection } from '../../private-types';\nimport { LAYOUT_TABLE } from '../../constants';\n\ntype DataViewsContextType< Item > = {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n\tfields: NormalizedField< Item >[];\n\tactions?: Action< Item >[];\n\tdata: Item[];\n\tisLoading?: boolean;\n\tpaginationInfo: {\n\t\ttotalItems: number;\n\t\ttotalPages: number;\n\t};\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\topenedFilter: string | null;\n\tsetOpenedFilter: ( openedFilter: string | null ) => void;\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable: ( item: Item ) => boolean;\n\tcontainerWidth: number;\n\tcontainerRef: React.MutableRefObject< HTMLDivElement | null >;\n\tdefaultLayouts: SupportedLayouts;\n\tfilters: NormalizedFilter[];\n\tisShowingFilter: boolean;\n\tsetIsShowingFilter: ( value: boolean ) => void;\n\tperPageSizes?: [ number, number, number, number ];\n};\n\nconst DataViewsContext = createContext< DataViewsContextType< any > >( {\n\tview: { type: LAYOUT_TABLE },\n\tonChangeView: () => {},\n\tfields: [],\n\tdata: [],\n\tpaginationInfo: {\n\t\ttotalItems: 0,\n\t\ttotalPages: 0,\n\t},\n\tselection: [],\n\tonChangeSelection: () => {},\n\tsetOpenedFilter: () => {},\n\topenedFilter: null,\n\tgetItemId: ( item ) => item.id,\n\tisItemClickable: () => true,\n\trenderItemLink: undefined,\n\tcontainerWidth: 0,\n\tcontainerRef: createRef(),\n\tdefaultLayouts: { list: {}, grid: {}, table: {} },\n\tfilters: [],\n\tisShowingFilter: false,\n\tsetIsShowingFilter: () => {},\n} );\n\nexport default DataViewsContext;\n"],"mappings":";;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AAaA,IAAAC,UAAA,GAAAD,OAAA;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AA4CA,MAAME,gBAAgB,GAAG,IAAAC,sBAAa,EAAiC;EACtEC,IAAI,EAAE;IAAEC,IAAI,EAAEC;EAAa,CAAC;EAC5BC,YAAY,EAAEA,CAAA,KAAM,CAAC,CAAC;EACtBC,MAAM,EAAE,EAAE;EACVC,IAAI,EAAE,EAAE;EACRC,cAAc,EAAE;IACfC,UAAU,EAAE,CAAC;IACbC,UAAU,EAAE;EACb,CAAC;EACDC,SAAS,EAAE,EAAE;EACbC,iBAAiB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC3BC,eAAe,EAAEA,CAAA,KAAM,CAAC,CAAC;EACzBC,YAAY,EAAE,IAAI;EAClBC,SAAS,EAAIC,IAAI,IAAMA,IAAI,CAACC,EAAE;EAC9BC,eAAe,EAAEA,CAAA,KAAM,IAAI;EAC3BC,cAAc,EAAEC,SAAS;EACzBC,cAAc,EAAE,CAAC;EACjBC,YAAY,EAAE,IAAAC,kBAAS,EAAC,CAAC;EACzBC,cAAc,EAAE;IAAEC,IAAI,EAAE,CAAC,CAAC;IAAEC,IAAI,EAAE,CAAC,CAAC;IAAEC,KAAK,EAAE,CAAC;EAAE,CAAC;EACjDC,OAAO,EAAE,EAAE;EACXC,eAAe,EAAE,KAAK;EACtBC,kBAAkB,EAAEA,CAAA,KAAM,CAAC;AAC5B,CAAE,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEWjC,gBAAgB","ignoreList":[]}
|