@wordpress/dataviews 11.0.0 → 11.1.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 +20 -0
- package/README.md +140 -93
- package/build/components/dataviews-filters/filter.js +25 -267
- package/build/components/dataviews-filters/filter.js.map +2 -2
- package/build/components/dataviews-filters/input-widget.js +1 -4
- package/build/components/dataviews-filters/input-widget.js.map +2 -2
- package/build/components/dataviews-filters/use-filters.js +3 -3
- package/build/components/dataviews-filters/use-filters.js.map +2 -2
- package/build/constants.js +5 -142
- package/build/constants.js.map +2 -2
- package/build/dataform-controls/number.js +2 -1
- package/build/dataform-controls/number.js.map +2 -2
- package/build/dataform-controls/textarea.js +3 -1
- package/build/dataform-controls/textarea.js.map +2 -2
- package/build/dataform-controls/utils/get-custom-validity.js +8 -0
- package/build/dataform-controls/utils/get-custom-validity.js.map +2 -2
- package/build/dataform-controls/utils/validated-input.js +4 -2
- package/build/dataform-controls/utils/validated-input.js.map +2 -2
- package/build/dataform-controls/utils/validated-number.js +4 -2
- package/build/dataform-controls/utils/validated-number.js.map +2 -2
- package/build/dataform-layouts/panel/modal.js +14 -5
- package/build/dataform-layouts/panel/modal.js.map +2 -2
- package/build/dataviews-layouts/grid/composite-grid.js +39 -37
- package/build/dataviews-layouts/grid/composite-grid.js.map +3 -3
- package/build/dataviews-layouts/table/index.js +8 -3
- package/build/dataviews-layouts/table/index.js.map +2 -2
- package/build/field-types/array.js +27 -14
- package/build/field-types/array.js.map +3 -3
- package/build/field-types/boolean.js +13 -10
- package/build/field-types/boolean.js.map +3 -3
- package/build/field-types/color.js +14 -11
- package/build/field-types/color.js.map +3 -3
- package/build/field-types/date.js +11 -8
- package/build/field-types/date.js.map +3 -3
- package/build/field-types/datetime.js +7 -5
- package/build/field-types/datetime.js.map +3 -3
- package/build/field-types/email.js +20 -11
- package/build/field-types/email.js.map +3 -3
- package/build/field-types/index.js +12 -14
- package/build/field-types/index.js.map +3 -3
- package/build/field-types/integer.js +63 -14
- package/build/field-types/integer.js.map +3 -3
- package/build/field-types/media.js +5 -5
- package/build/field-types/media.js.map +2 -2
- package/build/field-types/no-type.js +9 -6
- package/build/field-types/no-type.js.map +3 -3
- package/build/field-types/number.js +51 -15
- package/build/field-types/number.js.map +3 -3
- package/build/field-types/password.js +13 -5
- package/build/field-types/password.js.map +3 -3
- package/build/field-types/telephone.js +13 -5
- package/build/field-types/telephone.js.map +3 -3
- package/build/field-types/text.js +13 -5
- package/build/field-types/text.js.map +3 -3
- package/build/field-types/url.js +13 -5
- package/build/field-types/url.js.map +3 -3
- package/build/field-types/utils/get-is-valid.js +89 -0
- package/build/field-types/utils/get-is-valid.js.map +7 -0
- package/build/field-types/utils/is-valid-elements.js +35 -0
- package/build/field-types/utils/is-valid-elements.js.map +7 -0
- package/build/field-types/utils/is-valid-max-length.js +36 -0
- package/build/field-types/utils/is-valid-max-length.js.map +7 -0
- package/build/field-types/utils/is-valid-max.js +36 -0
- package/build/field-types/utils/is-valid-max.js.map +7 -0
- package/build/field-types/utils/is-valid-min-length.js +36 -0
- package/build/field-types/utils/is-valid-min-length.js.map +7 -0
- package/build/field-types/utils/is-valid-min.js +36 -0
- package/build/field-types/utils/is-valid-min.js.map +7 -0
- package/build/field-types/utils/is-valid-pattern.js +41 -0
- package/build/field-types/utils/is-valid-pattern.js.map +7 -0
- package/build/field-types/utils/is-valid-required-for-array.js +32 -0
- package/build/field-types/utils/is-valid-required-for-array.js.map +7 -0
- package/build/field-types/utils/is-valid-required-for-bool.js +30 -0
- package/build/field-types/utils/is-valid-required-for-bool.js.map +7 -0
- package/build/field-types/utils/is-valid-required.js +30 -0
- package/build/field-types/utils/is-valid-required.js.map +7 -0
- package/build/hooks/use-form-validity.js +52 -102
- package/build/hooks/use-form-validity.js.map +2 -2
- package/build/types/field-api.js.map +1 -1
- package/build/types/private.js.map +1 -1
- package/build/utils/filter-sort-and-paginate.js +5 -0
- package/build/utils/filter-sort-and-paginate.js.map +3 -3
- package/build/utils/operators.js +399 -0
- package/build/utils/operators.js.map +7 -0
- package/build-module/components/dataviews-filters/filter.js +26 -292
- package/build-module/components/dataviews-filters/filter.js.map +2 -2
- package/build-module/components/dataviews-filters/input-widget.js +1 -4
- package/build-module/components/dataviews-filters/input-widget.js.map +2 -2
- package/build-module/components/dataviews-filters/use-filters.js +6 -3
- package/build-module/components/dataviews-filters/use-filters.js.map +2 -2
- package/build-module/constants.js +5 -139
- package/build-module/constants.js.map +2 -2
- package/build-module/dataform-controls/number.js +2 -1
- package/build-module/dataform-controls/number.js.map +2 -2
- package/build-module/dataform-controls/textarea.js +3 -1
- package/build-module/dataform-controls/textarea.js.map +2 -2
- package/build-module/dataform-controls/utils/get-custom-validity.js +8 -0
- package/build-module/dataform-controls/utils/get-custom-validity.js.map +2 -2
- package/build-module/dataform-controls/utils/validated-input.js +4 -2
- package/build-module/dataform-controls/utils/validated-input.js.map +2 -2
- package/build-module/dataform-controls/utils/validated-number.js +4 -2
- package/build-module/dataform-controls/utils/validated-number.js.map +2 -2
- package/build-module/dataform-layouts/panel/modal.js +14 -5
- package/build-module/dataform-layouts/panel/modal.js.map +2 -2
- package/build-module/dataviews-layouts/grid/composite-grid.js +40 -38
- package/build-module/dataviews-layouts/grid/composite-grid.js.map +3 -3
- package/build-module/dataviews-layouts/table/index.js +8 -3
- package/build-module/dataviews-layouts/table/index.js.map +2 -2
- package/build-module/field-types/array.js +17 -14
- package/build-module/field-types/array.js.map +2 -2
- package/build-module/field-types/boolean.js +13 -10
- package/build-module/field-types/boolean.js.map +2 -2
- package/build-module/field-types/color.js +14 -11
- package/build-module/field-types/color.js.map +2 -2
- package/build-module/field-types/date.js +11 -8
- package/build-module/field-types/date.js.map +2 -2
- package/build-module/field-types/datetime.js +7 -5
- package/build-module/field-types/datetime.js.map +2 -2
- package/build-module/field-types/email.js +20 -11
- package/build-module/field-types/email.js.map +2 -2
- package/build-module/field-types/index.js +12 -14
- package/build-module/field-types/index.js.map +2 -2
- package/build-module/field-types/integer.js +58 -13
- package/build-module/field-types/integer.js.map +2 -2
- package/build-module/field-types/media.js +5 -5
- package/build-module/field-types/media.js.map +2 -2
- package/build-module/field-types/no-type.js +10 -7
- package/build-module/field-types/no-type.js.map +2 -2
- package/build-module/field-types/number.js +47 -15
- package/build-module/field-types/number.js.map +2 -2
- package/build-module/field-types/password.js +13 -5
- package/build-module/field-types/password.js.map +2 -2
- package/build-module/field-types/telephone.js +13 -5
- package/build-module/field-types/telephone.js.map +2 -2
- package/build-module/field-types/text.js +13 -5
- package/build-module/field-types/text.js.map +2 -2
- package/build-module/field-types/url.js +13 -5
- package/build-module/field-types/url.js.map +2 -2
- package/build-module/field-types/utils/get-is-valid.js +68 -0
- package/build-module/field-types/utils/get-is-valid.js.map +7 -0
- package/build-module/field-types/utils/is-valid-elements.js +14 -0
- package/build-module/field-types/utils/is-valid-elements.js.map +7 -0
- package/build-module/field-types/utils/is-valid-max-length.js +15 -0
- package/build-module/field-types/utils/is-valid-max-length.js.map +7 -0
- package/build-module/field-types/utils/is-valid-max.js +15 -0
- package/build-module/field-types/utils/is-valid-max.js.map +7 -0
- package/build-module/field-types/utils/is-valid-min-length.js +15 -0
- package/build-module/field-types/utils/is-valid-min-length.js.map +7 -0
- package/build-module/field-types/utils/is-valid-min.js +15 -0
- package/build-module/field-types/utils/is-valid-min.js.map +7 -0
- package/build-module/field-types/utils/is-valid-pattern.js +20 -0
- package/build-module/field-types/utils/is-valid-pattern.js.map +7 -0
- package/build-module/field-types/utils/is-valid-required-for-array.js +11 -0
- package/build-module/field-types/utils/is-valid-required-for-array.js.map +7 -0
- package/build-module/field-types/utils/is-valid-required-for-bool.js +9 -0
- package/build-module/field-types/utils/is-valid-required-for-bool.js.map +7 -0
- package/build-module/field-types/utils/is-valid-required.js +9 -0
- package/build-module/field-types/utils/is-valid-required.js.map +7 -0
- package/build-module/hooks/use-form-validity.js +52 -102
- package/build-module/hooks/use-form-validity.js.map +2 -2
- package/build-module/utils/filter-sort-and-paginate.js +5 -0
- package/build-module/utils/filter-sort-and-paginate.js.map +2 -2
- package/build-module/utils/operators.js +394 -0
- package/build-module/utils/operators.js.map +7 -0
- package/build-style/style-rtl.css +13 -80
- package/build-style/style.css +13 -80
- package/build-types/components/dataviews-filters/filter.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/input-widget.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/use-filters.d.ts.map +1 -1
- package/build-types/constants.d.ts +6 -12
- package/build-types/constants.d.ts.map +1 -1
- package/build-types/dataform-controls/number.d.ts.map +1 -1
- package/build-types/dataform-controls/textarea.d.ts.map +1 -1
- package/build-types/dataform-controls/utils/get-custom-validity.d.ts +2 -2
- package/build-types/dataform-controls/utils/get-custom-validity.d.ts.map +1 -1
- package/build-types/dataform-controls/utils/validated-input.d.ts.map +1 -1
- package/build-types/dataform-controls/utils/validated-number.d.ts.map +1 -1
- package/build-types/dataform-layouts/panel/modal.d.ts.map +1 -1
- package/build-types/dataviews-layouts/grid/composite-grid.d.ts.map +1 -1
- package/build-types/dataviews-layouts/table/index.d.ts.map +1 -1
- package/build-types/field-types/array.d.ts +9 -2
- package/build-types/field-types/array.d.ts.map +1 -1
- package/build-types/field-types/boolean.d.ts +9 -2
- package/build-types/field-types/boolean.d.ts.map +1 -1
- package/build-types/field-types/color.d.ts +9 -2
- package/build-types/field-types/color.d.ts.map +1 -1
- package/build-types/field-types/date.d.ts +6 -4
- package/build-types/field-types/date.d.ts.map +1 -1
- package/build-types/field-types/datetime.d.ts +6 -4
- package/build-types/field-types/datetime.d.ts.map +1 -1
- package/build-types/field-types/email.d.ts +15 -2
- package/build-types/field-types/email.d.ts.map +1 -1
- package/build-types/field-types/index.d.ts.map +1 -1
- package/build-types/field-types/integer.d.ts +17 -4
- package/build-types/field-types/integer.d.ts.map +1 -1
- package/build-types/field-types/media.d.ts +1 -4
- package/build-types/field-types/media.d.ts.map +1 -1
- package/build-types/field-types/no-type.d.ts +6 -4
- package/build-types/field-types/no-type.d.ts.map +1 -1
- package/build-types/field-types/number.d.ts +17 -4
- package/build-types/field-types/number.d.ts.map +1 -1
- package/build-types/field-types/password.d.ts +12 -4
- package/build-types/field-types/password.d.ts.map +1 -1
- package/build-types/field-types/telephone.d.ts +12 -4
- package/build-types/field-types/telephone.d.ts.map +1 -1
- package/build-types/field-types/text.d.ts +12 -4
- package/build-types/field-types/text.d.ts.map +1 -1
- package/build-types/field-types/url.d.ts +12 -4
- package/build-types/field-types/url.d.ts.map +1 -1
- package/build-types/field-types/utils/get-is-valid.d.ts +7 -0
- package/build-types/field-types/utils/get-is-valid.d.ts.map +1 -0
- package/build-types/field-types/utils/is-valid-elements.d.ts +6 -0
- package/build-types/field-types/utils/is-valid-elements.d.ts.map +1 -0
- package/build-types/field-types/utils/is-valid-max-length.d.ts +6 -0
- package/build-types/field-types/utils/is-valid-max-length.d.ts.map +1 -0
- package/build-types/field-types/utils/is-valid-max.d.ts +6 -0
- package/build-types/field-types/utils/is-valid-max.d.ts.map +1 -0
- package/build-types/field-types/utils/is-valid-min-length.d.ts +6 -0
- package/build-types/field-types/utils/is-valid-min-length.d.ts.map +1 -0
- package/build-types/field-types/utils/is-valid-min.d.ts +6 -0
- package/build-types/field-types/utils/is-valid-min.d.ts.map +1 -0
- package/build-types/field-types/utils/is-valid-pattern.d.ts +6 -0
- package/build-types/field-types/utils/is-valid-pattern.d.ts.map +1 -0
- package/build-types/field-types/utils/is-valid-required-for-array.d.ts +6 -0
- package/build-types/field-types/utils/is-valid-required-for-array.d.ts.map +1 -0
- package/build-types/field-types/utils/is-valid-required-for-bool.d.ts +6 -0
- package/build-types/field-types/utils/is-valid-required-for-bool.d.ts.map +1 -0
- package/build-types/field-types/utils/is-valid-required.d.ts +6 -0
- package/build-types/field-types/utils/is-valid-required.d.ts.map +1 -0
- package/build-types/hooks/use-form-validity.d.ts.map +1 -1
- package/build-types/stories/dataform.story.d.ts +9 -1
- package/build-types/stories/dataform.story.d.ts.map +1 -1
- package/build-types/stories/dataviews-picker.story.d.ts.map +1 -1
- package/build-types/stories/dataviews.story.d.ts +27 -2
- package/build-types/stories/dataviews.story.d.ts.map +1 -1
- package/build-types/stories/field-types.story.d.ts +39 -2
- package/build-types/stories/field-types.story.d.ts.map +1 -1
- package/build-types/types/field-api.d.ts +72 -4
- package/build-types/types/field-api.d.ts.map +1 -1
- package/build-types/types/private.d.ts +13 -3
- package/build-types/types/private.d.ts.map +1 -1
- package/build-types/utils/filter-sort-and-paginate.d.ts.map +1 -1
- package/build-types/utils/operators.d.ts +16 -0
- package/build-types/utils/operators.d.ts.map +1 -0
- package/build-wp/index.js +1548 -1452
- package/package.json +17 -16
- package/src/components/dataviews/style.scss +3 -28
- package/src/components/dataviews-filters/filter.tsx +34 -321
- package/src/components/dataviews-filters/input-widget.tsx +7 -5
- package/src/components/dataviews-filters/use-filters.ts +6 -3
- package/src/components/dataviews-footer/style.scss +1 -7
- package/src/constants.ts +6 -140
- package/src/dataform-controls/number.tsx +3 -3
- package/src/dataform-controls/textarea.tsx +7 -1
- package/src/dataform-controls/utils/get-custom-validity.ts +10 -2
- package/src/dataform-controls/utils/validated-input.tsx +8 -2
- package/src/dataform-controls/utils/validated-number.tsx +3 -1
- package/src/dataform-layouts/panel/modal.tsx +14 -5
- package/src/dataviews-layouts/activity/style.scss +1 -1
- package/src/dataviews-layouts/grid/composite-grid.tsx +64 -57
- package/src/dataviews-layouts/grid/style.scss +3 -12
- package/src/dataviews-layouts/table/index.tsx +9 -3
- package/src/dataviews-layouts/table/style.scss +4 -15
- package/src/dataviews-layouts/utils/grid-items.scss +1 -9
- package/src/field-types/array.tsx +26 -19
- package/src/field-types/boolean.tsx +22 -15
- package/src/field-types/color.tsx +22 -15
- package/src/field-types/date.tsx +14 -11
- package/src/field-types/datetime.tsx +6 -4
- package/src/field-types/email.tsx +24 -15
- package/src/field-types/index.tsx +12 -14
- package/src/field-types/integer.tsx +83 -17
- package/src/field-types/media.tsx +4 -4
- package/src/field-types/no-type.tsx +9 -6
- package/src/field-types/number.tsx +82 -16
- package/src/field-types/password.tsx +12 -4
- package/src/field-types/telephone.tsx +12 -4
- package/src/field-types/text.tsx +12 -4
- package/src/field-types/url.tsx +12 -4
- package/src/field-types/utils/get-is-valid.ts +103 -0
- package/src/field-types/utils/is-valid-elements.ts +20 -0
- package/src/field-types/utils/is-valid-max-length.ts +23 -0
- package/src/field-types/utils/is-valid-max.ts +23 -0
- package/src/field-types/utils/is-valid-min-length.ts +23 -0
- package/src/field-types/utils/is-valid-min.ts +23 -0
- package/src/field-types/utils/is-valid-pattern.ts +29 -0
- package/src/field-types/utils/is-valid-required-for-array.ts +18 -0
- package/src/field-types/utils/is-valid-required-for-bool.ts +13 -0
- package/src/field-types/utils/is-valid-required.ts +13 -0
- package/src/hooks/use-form-validity.ts +78 -156
- package/src/stories/dataform.story.tsx +126 -30
- package/src/stories/dataviews-picker.story.tsx +27 -17
- package/src/stories/dataviews.story.tsx +79 -30
- package/src/stories/field-types.story.tsx +86 -4
- package/src/test/filter-sort-and-paginate.js +2 -1
- package/src/test/normalize-fields.ts +87 -11
- package/src/test/use-form-validity.ts +796 -31
- package/src/types/field-api.ts +90 -4
- package/src/types/private.ts +26 -8
- package/src/utils/filter-sort-and-paginate.ts +5 -0
- package/src/utils/operators.tsx +448 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 11.1.0 (2025-12-23)
|
|
6
|
+
|
|
7
|
+
### Code Quality
|
|
8
|
+
|
|
9
|
+
- DataViews: Remove extra wrapper for GridItem. [#73665](https://github.com/WordPress/gutenberg/pull/73665)
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- Fix sticky footer in DataViews grid view. [#73661](https://github.com/WordPress/gutenberg/pull/73661)
|
|
14
|
+
- DataViews: Apply primary style to first column if there is no title field. [#73729](https://github.com/WordPress/gutenberg/pull/73729)
|
|
15
|
+
|
|
16
|
+
### Enhancements
|
|
17
|
+
|
|
18
|
+
- Better labels for operators and deprecate the `isNotAll` operator. [#73671](https://github.com/WordPress/gutenberg/pull/73671)
|
|
19
|
+
- Field API: move validation to the field type. [#73642](https://github.com/WordPress/gutenberg/pull/73642)
|
|
20
|
+
- DataForm: add support for `min`/`max` and `minLength`/`maxLength` validation for relevant controls. [#73465](https://github.com/WordPress/gutenberg/pull/73465)
|
|
21
|
+
- Field API: display formats for `number` and `integer` types. [#73644](https://github.com/WordPress/gutenberg/pull/73644)
|
|
22
|
+
- DataViews: Update padding to 24px for consistency. [#73334](https://github.com/WordPress/gutenberg/pull/73334)
|
|
23
|
+
|
|
5
24
|
## 11.0.0 (2025-11-26)
|
|
6
25
|
|
|
7
26
|
### Enhancements
|
|
@@ -20,6 +39,7 @@
|
|
|
20
39
|
- Documentation: surface better the `type` property in the documentation. [#73349](https://github.com/WordPress/gutenberg/pull/73349)
|
|
21
40
|
- Documentation: improve DataView's `layout` prop. [#73470](https://github.com/WordPress/gutenberg/pull/73470)
|
|
22
41
|
- Documentation: document `readOnly`, `description`, and `placeholder` properties. [#73515](https://github.com/WordPress/gutenberg/pull/73515)
|
|
42
|
+
- Documentation: add missing props in DataViews. [#73611](https://github.com/WordPress/gutenberg/pull/73611)
|
|
23
43
|
- DataForm Panel Layout: Focus the first input element when the panel opens. [#72322](https://github.com/WordPress/gutenberg/pull/72322)
|
|
24
44
|
- DataForm: Pattern validation is now supported on all fields that browsers support it in. [#73156](https://github.com/WordPress/gutenberg/pull/73156)
|
|
25
45
|
- Documentation: improve operators docs. [#73523](https://github.com/WordPress/gutenberg/pull/73523)
|
package/README.md
CHANGED
|
@@ -225,34 +225,33 @@ Properties:
|
|
|
225
225
|
|
|
226
226
|
| Props / Layout | `table` | `pickerTable` | `grid` | `pickerGrid` | `list` | `activity` |
|
|
227
227
|
| -------------- | ------- | ------------- | ------ | ------------ | ------ | ---------- |
|
|
228
|
-
| `density` | ✓ | ✓ | |
|
|
229
|
-
| `enableMoving` | ✓ | ✓ | |
|
|
230
|
-
| `styles` | ✓ | ✓ | |
|
|
228
|
+
| `density` | ✓ | ✓ | | | | ✓ |
|
|
229
|
+
| `enableMoving` | ✓ | ✓ | | | | |
|
|
230
|
+
| `styles` | ✓ | ✓ | | | | |
|
|
231
231
|
| `badgeFields` | | | ✓ | ✓ | | |
|
|
232
232
|
| `previewSize` | | | ✓ | ✓ | | |
|
|
233
233
|
|
|
234
234
|
`table` and `pickerTable` layouts:
|
|
235
235
|
|
|
236
|
-
-
|
|
237
|
-
-
|
|
238
|
-
-
|
|
236
|
+
- `density`: one of `comfortable`, `balanced`, or `compact`. Configures the size and spacing of the layout.
|
|
237
|
+
- `enableMoving`: whether the table columns should display moving controls.
|
|
238
|
+
- `styles`: additional `width`, `maxWidth`, `minWidth`, `align` styles for each field column.
|
|
239
239
|
|
|
240
240
|
**For column alignment (`align` property), follow these guidelines:**
|
|
241
241
|
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).
|
|
242
242
|
|
|
243
243
|
`grid` and `pickerGrid` layout:
|
|
244
244
|
|
|
245
|
-
-
|
|
246
|
-
-
|
|
245
|
+
- `badgeFields`: a list of field's `id` to render without label and styled as badges.
|
|
246
|
+
- `previewSize`: a `number` representing the size of the preview.
|
|
247
247
|
|
|
248
248
|
`list` layout:
|
|
249
249
|
|
|
250
|
-
-
|
|
250
|
+
- None
|
|
251
251
|
|
|
252
252
|
`activity` layout:
|
|
253
253
|
|
|
254
|
-
-
|
|
255
|
-
|
|
254
|
+
- `density`: one of `comfortable`, `balanced`, or `compact`. Configures the size and spacing of the layout.
|
|
256
255
|
|
|
257
256
|
#### `onChangeView`: `function`
|
|
258
257
|
|
|
@@ -374,6 +373,7 @@ const actions = [
|
|
|
374
373
|
|
|
375
374
|
- `totalItems`: the total number of items in the datasets.
|
|
376
375
|
- `totalPages`: the total number of pages, taking into account the total items in the dataset and the number of items per page provided by the user.
|
|
376
|
+
- `infiniteScrollHandler`: a function that handles infinite scrolling. This function should be called when the user scrolls to the bottom of the page. See [example in storybook](https://wordpress.github.io/gutenberg/?path=/story/dataviews-dataviews--infinite-scroll).
|
|
377
377
|
|
|
378
378
|
#### `search`: `boolean`
|
|
379
379
|
|
|
@@ -404,7 +404,7 @@ const defaultLayouts = {
|
|
|
404
404
|
};
|
|
405
405
|
```
|
|
406
406
|
|
|
407
|
-
The `defaultLayouts` property should be an object that includes properties named `table`, `grid`, and
|
|
407
|
+
The `defaultLayouts` property should be an object that includes properties named `table`, `grid`, `list`, and `activity`. These properties are applied to the view object each time the user switches to the corresponding layout.
|
|
408
408
|
|
|
409
409
|
#### `selection`: `string[]`
|
|
410
410
|
|
|
@@ -426,6 +426,12 @@ Note: `DataViews` still requires at least one bulk action to make items selectab
|
|
|
426
426
|
|
|
427
427
|
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.
|
|
428
428
|
|
|
429
|
+
Note that layouts may still decide not to render clickable primary and media fields. For example, the `list` layout has a different interaction model and doesn't enable this feature.
|
|
430
|
+
|
|
431
|
+
#### `onClickItem`: `function`
|
|
432
|
+
|
|
433
|
+
A function that is called when an item is clicked. It receives the item as a parameter.
|
|
434
|
+
|
|
429
435
|
#### `renderItemLink`: `React.ComponentType`
|
|
430
436
|
|
|
431
437
|
A render function used to render clickable items.
|
|
@@ -853,29 +859,29 @@ For example:
|
|
|
853
859
|
|
|
854
860
|
```json
|
|
855
861
|
{
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
862
|
+
"title": {
|
|
863
|
+
"required": {
|
|
864
|
+
"type": "invalid"
|
|
865
|
+
}
|
|
866
|
+
},
|
|
867
|
+
"author": {
|
|
868
|
+
"elements": {
|
|
869
|
+
"type": "invalid",
|
|
870
|
+
"message": "Value must be one of the elements."
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
"publisher": {
|
|
874
|
+
"custom": {
|
|
875
|
+
"type": "validating",
|
|
876
|
+
"message": "Validating..."
|
|
877
|
+
}
|
|
878
|
+
},
|
|
879
|
+
"isbn": {
|
|
880
|
+
"custom": {
|
|
881
|
+
"type": "valid",
|
|
882
|
+
"message": "Valid."
|
|
883
|
+
}
|
|
884
|
+
}
|
|
879
885
|
}
|
|
880
886
|
```
|
|
881
887
|
|
|
@@ -885,11 +891,11 @@ The `message` is the text to be displayed in the UI controls. The message for th
|
|
|
885
891
|
|
|
886
892
|
The `type` can be:
|
|
887
893
|
|
|
888
|
-
-
|
|
889
|
-
-
|
|
890
|
-
-
|
|
894
|
+
- `validating`: when the value is being validated (e.g., custom async rule)
|
|
895
|
+
- `invalid`: when the value is invalid according to the rule
|
|
896
|
+
- `valid`: when the value _became_ valid after having been invalid (e.g., custom async rule)
|
|
891
897
|
|
|
892
|
-
Note the `valid` status. This is useful for displaying a "Valid." message when the field transitions from invalid to valid.
|
|
898
|
+
Note the `valid` status. This is useful for displaying a "Valid." message when the field transitions from invalid to valid. The `useFormValidity` hook implements this only for the custom async validation.
|
|
893
899
|
|
|
894
900
|
## Utilities
|
|
895
901
|
|
|
@@ -964,7 +970,7 @@ The user facing description of the action.
|
|
|
964
970
|
|
|
965
971
|
```js
|
|
966
972
|
{
|
|
967
|
-
label: Trash
|
|
973
|
+
label: 'Trash'
|
|
968
974
|
}
|
|
969
975
|
```
|
|
970
976
|
|
|
@@ -1395,7 +1401,7 @@ Field authors can override the default Edit control by providing a string that m
|
|
|
1395
1401
|
|
|
1396
1402
|
Additionally, some of the bundled Edit controls are configurable via a config object:
|
|
1397
1403
|
|
|
1398
|
-
-
|
|
1404
|
+
- `textarea` configuration:
|
|
1399
1405
|
|
|
1400
1406
|
```js
|
|
1401
1407
|
{
|
|
@@ -1409,7 +1415,7 @@ Additionally, some of the bundled Edit controls are configurable via a config ob
|
|
|
1409
1415
|
}
|
|
1410
1416
|
```
|
|
1411
1417
|
|
|
1412
|
-
-
|
|
1418
|
+
- `text` configuration:
|
|
1413
1419
|
|
|
1414
1420
|
```js
|
|
1415
1421
|
{
|
|
@@ -1489,9 +1495,9 @@ When the field declares a type, it gets a default sort function:
|
|
|
1489
1495
|
|
|
1490
1496
|
The default sorting can be overriden by providing a custom sort function. It takes the following arguments:
|
|
1491
1497
|
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1498
|
+
- `a`: the first item to compare
|
|
1499
|
+
- `b`: the second item to compare
|
|
1500
|
+
- `direction`: either `asc` (ascending) or `desc` (descending)
|
|
1495
1501
|
|
|
1496
1502
|
It should return a number where:
|
|
1497
1503
|
|
|
@@ -1705,7 +1711,7 @@ Note this function may be called many times in the lifetime of the DataViews/Dat
|
|
|
1705
1711
|
|
|
1706
1712
|
### `filterBy`
|
|
1707
1713
|
|
|
1708
|
-
Configuration of the filters.
|
|
1714
|
+
Configuration of the filters. Set to `false` to opt the field out of filtering entirely.
|
|
1709
1715
|
|
|
1710
1716
|
- Type: `object` | `boolean`.
|
|
1711
1717
|
- Optional.
|
|
@@ -1797,63 +1803,64 @@ Or multi-selection operators:
|
|
|
1797
1803
|
{ value: 'd', label: 'Product D' },
|
|
1798
1804
|
],
|
|
1799
1805
|
filterBy: {
|
|
1800
|
-
operators: [ `isAny`, `isNone`, `isAll
|
|
1806
|
+
operators: [ `isAny`, `isNone`, `isAll` ];
|
|
1801
1807
|
}
|
|
1802
1808
|
}
|
|
1803
1809
|
```
|
|
1804
1810
|
|
|
1805
1811
|
The next table lists all available operators:
|
|
1806
1812
|
|
|
1807
|
-
| Operator | Description
|
|
1808
|
-
| -------------------- |
|
|
1809
|
-
| `after` |
|
|
1810
|
-
| `afterInc` |
|
|
1811
|
-
| `before` |
|
|
1812
|
-
| `beforeInc` |
|
|
1813
|
-
| `between` |
|
|
1814
|
-
| `contains` |
|
|
1815
|
-
| `greaterThan` |
|
|
1816
|
-
| `greaterThanOrEqual` |
|
|
1817
|
-
| `inThePast` |
|
|
1818
|
-
| `isAll` |
|
|
1819
|
-
| `isAny` |
|
|
1820
|
-
| `isNone` |
|
|
1821
|
-
| `
|
|
1822
|
-
| `
|
|
1823
|
-
| `
|
|
1824
|
-
| `
|
|
1825
|
-
| `
|
|
1826
|
-
| `
|
|
1827
|
-
| `
|
|
1828
|
-
| `
|
|
1829
|
-
| `
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
Some operators are single-selection: `is`, `isNot`, `on`, `notOn`, `lessThan`, `greaterThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `before`, `after`, `beforeInc`, `afterInc`, `contains`, `notContains`, and `startsWith`. Others are multi-selection: `isAny`, `isNone`, `isAll`, and `isNotAll`. 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.
|
|
1813
|
+
| Operator | Description | Example |
|
|
1814
|
+
| -------------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------- |
|
|
1815
|
+
| `after` | The result is after a given date. | Date is after: 2024-01-01 |
|
|
1816
|
+
| `afterInc` | The result is after a given date, including the date. | Date is on or after: 2024-01-01 |
|
|
1817
|
+
| `before` | The result is before a given date. | Date is before: 2024-01-01 |
|
|
1818
|
+
| `beforeInc` | The result is before a given date, including the date. | Date is on or before: 2024-01-01 |
|
|
1819
|
+
| `between` | The result is between two values. | Count between (inc): 10 and 180 |
|
|
1820
|
+
| `contains` | The result contains the given substring. | Title contains: Mars |
|
|
1821
|
+
| `greaterThan` | The result is numerically greater than a single value. | Age is greater than: 65 |
|
|
1822
|
+
| `greaterThanOrEqual` | The result is numerically greater than or equal to a single value. | Age is greater than or equal to: 65 |
|
|
1823
|
+
| `inThePast` | The result is within the last N units (days, weeks, months, or years) from now. | Orders in the past: 7 days |
|
|
1824
|
+
| `isAll` | The result includes all values in the list. | Category includes all: Book, Review, Science Fiction |
|
|
1825
|
+
| `isAny` | The result includes some values in the list. | Author includes: Admin, Editor |
|
|
1826
|
+
| `isNone` | The result does not include some values in the list. | Author excludes: Admin, Editor |
|
|
1827
|
+
| `is` | The result is equal to a single value. | Author is: Admin |
|
|
1828
|
+
| `isNot` | The result is not equal to a single value. | Author is not: Admin |
|
|
1829
|
+
| `lessThan` | The result is numerically less than a single value. | Age is less than: 18 |
|
|
1830
|
+
| `lessThanOrEqual` | The result is numerically less than or equal to a single value. | Age is less than or equal to: 18 |
|
|
1831
|
+
| `notContains` | The result does not contain the given substring. | Description doesn't contain: photo |
|
|
1832
|
+
| `notOn` | The result is not on a given date (date inequality using proper date parsing). | Date is not: 2024-01-01 |
|
|
1833
|
+
| `on` | The result is on a given date (date equality using proper date parsing). | Date is: 2024-01-01 |
|
|
1834
|
+
| `over` | The result is older than N units (days, weeks, months, or years) from now. | Orders over: 7 days ago |
|
|
1835
|
+
| `startsWith` | The result starts with the given substring. | Title starts with: Mar |
|
|
1836
|
+
|
|
1837
|
+
Some operators are single-selection: `is`, `isNot`, `on`, `notOn`, `lessThan`, `greaterThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `before`, `after`, `beforeInc`, `afterInc`, `contains`, `notContains`, and `startsWith`. Others are multi-selection: `isAny`, `isNone`, `isAll`. 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.
|
|
1833
1838
|
|
|
1834
1839
|
Valid operators per field type:
|
|
1835
1840
|
|
|
1836
|
-
-
|
|
1837
|
-
-
|
|
1838
|
-
-
|
|
1839
|
-
-
|
|
1840
|
-
-
|
|
1841
|
-
-
|
|
1842
|
-
-
|
|
1843
|
-
-
|
|
1844
|
-
-
|
|
1845
|
-
-
|
|
1846
|
-
-
|
|
1847
|
-
-
|
|
1848
|
-
-
|
|
1849
|
-
-
|
|
1841
|
+
- array: `isAny`, `isNone`, `isAll`.
|
|
1842
|
+
- boolean: `is`, `isNot`.
|
|
1843
|
+
- color: `is`, `isNot`, `isAny`, `isNone`.
|
|
1844
|
+
- date: `on`, `notOn`, `before`, `beforeInc`, `after`, `afterInc`, `inThePast`, `over`, `between`.
|
|
1845
|
+
- datetime: `on`, `notOn`, `before`, `beforeInc`, `after`, `afterInc`, `inThePast`, `over`.
|
|
1846
|
+
- email: `is`, `isNot`, `contains`, `notContains`, `startsWith`, `isAny`, `isNone`, `isAll`.
|
|
1847
|
+
- integer: `is`, `isNot`, `lessThan`, `greaterThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `between`, `isAny`, `isNone`, `isAll`.
|
|
1848
|
+
- media: none.
|
|
1849
|
+
- number: `is`, `isNot`, `lessThan`, `greaterThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `between`, `isAny`, `isNone`, `isAll`.
|
|
1850
|
+
- password: none.
|
|
1851
|
+
- email: `is`, `isNot`, `contains`, `notContains`, `startsWith`, `isAny`, `isNone`, `isAll`.
|
|
1852
|
+
- text: `is`, `isNot`, `contains`, `notContains`, `startsWith`, `isAny`, `isNone`, `isAll`.
|
|
1853
|
+
- url: `is`, `isNot`, `contains`, `notContains`, `startsWith`, `isAny`, `isNone`, `isAll`.
|
|
1854
|
+
- fields with no type: any operator.
|
|
1850
1855
|
|
|
1851
1856
|
### `format`
|
|
1852
1857
|
|
|
1853
|
-
Display format configuration for fields.
|
|
1858
|
+
Display format configuration for fields. Supported for date, number, and integer fields. This configuration affects how the field is displayed in the `render` method, the `Edit` control, and filter controls.
|
|
1854
1859
|
|
|
1855
1860
|
- Type: `object`.
|
|
1856
1861
|
- Optional.
|
|
1862
|
+
|
|
1863
|
+
For `date` fields:
|
|
1857
1864
|
- Properties:
|
|
1858
1865
|
- `date`: The format string using PHP date format (e.g., 'F j, Y' for 'March 10, 2023'). Optional, defaults to WordPress "Date Format" setting.
|
|
1859
1866
|
- `weekStartsOn`: Specifies the first day of the week for calendar controls. One of 0, 1, 2, 3, 4, 5, 6. Optional, defaults to WordPress "Week Starts On" setting, whose value is 0 (Sunday).
|
|
@@ -1872,6 +1879,46 @@ Example:
|
|
|
1872
1879
|
}
|
|
1873
1880
|
```
|
|
1874
1881
|
|
|
1882
|
+
For `number` fields:
|
|
1883
|
+
|
|
1884
|
+
- Properties:
|
|
1885
|
+
- `separatorThousand`: The character used as thousand separator (e.g., ',' for '1,234'). Optional, defaults to ','.
|
|
1886
|
+
- `separatorDecimal`: The character used as decimal separator (e.g., '.' for '1.23'). Optional, defaults to '.'.
|
|
1887
|
+
- `decimals`: Number of decimal places to display (0-100). Optional, defaults to 2.
|
|
1888
|
+
|
|
1889
|
+
Example:
|
|
1890
|
+
|
|
1891
|
+
```js
|
|
1892
|
+
{
|
|
1893
|
+
id: 'price',
|
|
1894
|
+
type: 'number',
|
|
1895
|
+
label: 'Price',
|
|
1896
|
+
format: {
|
|
1897
|
+
separatorThousand: ',',
|
|
1898
|
+
separatorDecimal: '.',
|
|
1899
|
+
decimals: 2,
|
|
1900
|
+
},
|
|
1901
|
+
}
|
|
1902
|
+
```
|
|
1903
|
+
|
|
1904
|
+
For `integer` fields:
|
|
1905
|
+
|
|
1906
|
+
- Properties:
|
|
1907
|
+
- `separatorThousand`: The character used as thousand separator (e.g., ',' for '1,234'). Optional, defaults to ','.
|
|
1908
|
+
|
|
1909
|
+
Example:
|
|
1910
|
+
|
|
1911
|
+
```js
|
|
1912
|
+
{
|
|
1913
|
+
id: 'quantity',
|
|
1914
|
+
type: 'integer',
|
|
1915
|
+
label: 'Quantity',
|
|
1916
|
+
format: {
|
|
1917
|
+
separatorThousand: ',',
|
|
1918
|
+
},
|
|
1919
|
+
}
|
|
1920
|
+
```
|
|
1921
|
+
|
|
1875
1922
|
## Form Field API
|
|
1876
1923
|
|
|
1877
1924
|
### `id`
|
|
@@ -1912,11 +1959,11 @@ For example:
|
|
|
1912
1959
|
|
|
1913
1960
|
#### Panel
|
|
1914
1961
|
|
|
1915
|
-
-
|
|
1916
|
-
-
|
|
1917
|
-
-
|
|
1918
|
-
|
|
1919
|
-
-
|
|
1962
|
+
- `type`: `panel`. Required.
|
|
1963
|
+
- `labelPosition`: one of `side`, `top`, or `none`. Optional. `top` by default.
|
|
1964
|
+
- `summary`: Summary field configuration. Optional. Specifies which field(s) to display in the panel header. Can be:
|
|
1965
|
+
- A string (single field ID)
|
|
1966
|
+
- An array of strings (multiple field IDs)
|
|
1920
1967
|
|
|
1921
1968
|
When no summary fields are explicitly configured, the panel automatically determines which fields to display using this priority:
|
|
1922
1969
|
|