@wordpress/dataviews 11.3.1-next.v.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -1
- package/README.md +44 -2
- package/build/components/dataform-controls/adaptive-select.cjs +52 -0
- package/build/components/dataform-controls/adaptive-select.cjs.map +7 -0
- package/build/components/dataform-controls/array.cjs +2 -0
- package/build/components/dataform-controls/array.cjs.map +2 -2
- package/build/components/dataform-controls/checkbox.cjs +2 -0
- package/build/components/dataform-controls/checkbox.cjs.map +2 -2
- package/build/components/dataform-controls/color.cjs +21 -30
- package/build/components/dataform-controls/color.cjs.map +3 -3
- package/build/components/dataform-controls/combobox.cjs +80 -0
- package/build/components/dataform-controls/combobox.cjs.map +7 -0
- package/build/components/dataform-controls/date.cjs +58 -19
- package/build/components/dataform-controls/date.cjs.map +2 -2
- package/build/components/dataform-controls/datetime.cjs +11 -3
- package/build/components/dataform-controls/datetime.cjs.map +2 -2
- package/build/components/dataform-controls/email.cjs +2 -0
- package/build/components/dataform-controls/email.cjs.map +2 -2
- package/build/components/dataform-controls/index.cjs +5 -1
- package/build/components/dataform-controls/index.cjs.map +3 -3
- package/build/components/dataform-controls/password.cjs +2 -0
- package/build/components/dataform-controls/password.cjs.map +2 -2
- package/build/components/dataform-controls/radio.cjs +2 -0
- package/build/components/dataform-controls/radio.cjs.map +2 -2
- package/build/components/dataform-controls/select.cjs +2 -0
- package/build/components/dataform-controls/select.cjs.map +2 -2
- package/build/components/dataform-controls/telephone.cjs +2 -0
- package/build/components/dataform-controls/telephone.cjs.map +2 -2
- package/build/components/dataform-controls/text.cjs +2 -0
- package/build/components/dataform-controls/text.cjs.map +2 -2
- package/build/components/dataform-controls/textarea.cjs +2 -0
- package/build/components/dataform-controls/textarea.cjs.map +2 -2
- package/build/components/dataform-controls/toggle-group.cjs +2 -0
- package/build/components/dataform-controls/toggle-group.cjs.map +2 -2
- package/build/components/dataform-controls/toggle.cjs +2 -0
- package/build/components/dataform-controls/toggle.cjs.map +2 -2
- package/build/components/dataform-controls/url.cjs +2 -0
- package/build/components/dataform-controls/url.cjs.map +2 -2
- package/build/components/dataform-controls/utils/relative-date-control.cjs +1 -1
- package/build/components/dataform-controls/utils/relative-date-control.cjs.map +1 -1
- package/build/components/dataform-controls/utils/validated-input.cjs +2 -0
- package/build/components/dataform-controls/utils/validated-input.cjs.map +2 -2
- package/build/components/dataform-controls/utils/validated-number.cjs +2 -0
- package/build/components/dataform-controls/utils/validated-number.cjs.map +2 -2
- package/build/components/dataform-layouts/card/index.cjs +28 -3
- package/build/components/dataform-layouts/card/index.cjs.map +3 -3
- package/build/components/dataform-layouts/data-form-layout.cjs +11 -2
- package/build/components/dataform-layouts/data-form-layout.cjs.map +2 -2
- package/build/components/dataform-layouts/details/index.cjs +69 -12
- package/build/components/dataform-layouts/details/index.cjs.map +3 -3
- package/build/components/dataform-layouts/index.cjs +5 -5
- package/build/components/dataform-layouts/index.cjs.map +1 -1
- package/build/components/dataform-layouts/normalize-form.cjs +2 -1
- package/build/components/dataform-layouts/normalize-form.cjs.map +2 -2
- package/build/components/dataform-layouts/panel/dropdown.cjs +88 -63
- package/build/components/dataform-layouts/panel/dropdown.cjs.map +3 -3
- package/build/components/dataform-layouts/panel/index.cjs +13 -175
- package/build/components/dataform-layouts/panel/index.cjs.map +3 -3
- package/build/components/dataform-layouts/panel/modal.cjs +28 -18
- package/build/components/dataform-layouts/panel/modal.cjs.map +3 -3
- package/build/components/dataform-layouts/panel/summary-button.cjs +125 -56
- package/build/components/dataform-layouts/panel/summary-button.cjs.map +3 -3
- package/build/components/dataform-layouts/panel/utils/get-first-validation-error.cjs +59 -0
- package/build/components/dataform-layouts/panel/utils/get-first-validation-error.cjs.map +7 -0
- package/build/components/dataform-layouts/panel/utils/get-label-classname.cjs +45 -0
- package/build/components/dataform-layouts/panel/utils/get-label-classname.cjs.map +7 -0
- package/build/components/dataform-layouts/panel/utils/get-label-content.cjs +36 -0
- package/build/components/dataform-layouts/panel/utils/get-label-content.cjs.map +7 -0
- package/build/components/dataform-layouts/panel/utils/use-field-from-form-field.cjs +77 -0
- package/build/components/dataform-layouts/panel/utils/use-field-from-form-field.cjs.map +7 -0
- package/build/components/dataform-layouts/regular/index.cjs +6 -3
- package/build/components/dataform-layouts/regular/index.cjs.map +2 -2
- package/build/components/dataform-layouts/row/index.cjs +5 -2
- package/build/components/dataform-layouts/row/index.cjs.map +2 -2
- package/build/components/dataform-layouts/validation-badge.cjs +67 -0
- package/build/components/dataform-layouts/validation-badge.cjs.map +7 -0
- package/build/components/dataviews-bulk-actions/index.cjs +4 -4
- package/build/components/dataviews-bulk-actions/index.cjs.map +2 -2
- package/build/components/dataviews-context/index.cjs.map +2 -2
- package/build/components/dataviews-filters/filter.cjs +1 -1
- package/build/components/dataviews-filters/filter.cjs.map +1 -1
- package/build/components/dataviews-filters/filters.cjs +1 -1
- package/build/components/dataviews-filters/filters.cjs.map +1 -1
- package/build/components/dataviews-filters/search-widget.cjs +25 -11
- package/build/components/dataviews-filters/search-widget.cjs.map +2 -2
- package/build/components/dataviews-filters/toggle.cjs.map +1 -1
- package/build/components/dataviews-footer/index.cjs +1 -1
- package/build/components/dataviews-footer/index.cjs.map +1 -1
- package/build/components/dataviews-layouts/activity/activity-item.cjs +4 -4
- package/build/components/dataviews-layouts/activity/activity-item.cjs.map +1 -1
- package/build/components/dataviews-layouts/activity/index.cjs +1 -1
- package/build/components/dataviews-layouts/activity/index.cjs.map +1 -1
- package/build/components/dataviews-layouts/grid/composite-grid.cjs +27 -38
- package/build/components/dataviews-layouts/grid/composite-grid.cjs.map +2 -2
- package/build/components/dataviews-layouts/grid/index.cjs +2 -2
- package/build/components/dataviews-layouts/grid/index.cjs.map +1 -1
- package/build/components/dataviews-layouts/list/index.cjs +7 -8
- package/build/components/dataviews-layouts/list/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/picker-grid/index.cjs +5 -5
- package/build/components/dataviews-layouts/picker-grid/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/picker-table/index.cjs +1 -1
- package/build/components/dataviews-layouts/picker-table/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/table/column-primary.cjs +1 -1
- package/build/components/dataviews-layouts/table/column-primary.cjs.map +1 -1
- package/build/components/dataviews-layouts/table/index.cjs +1 -1
- package/build/components/dataviews-layouts/table/index.cjs.map +2 -2
- package/build/components/dataviews-layouts/utils/item-click-wrapper.cjs.map +2 -2
- package/build/components/dataviews-pagination/index.cjs +3 -3
- package/build/components/dataviews-pagination/index.cjs.map +2 -2
- package/build/components/dataviews-picker-footer/index.cjs +3 -3
- package/build/components/dataviews-picker-footer/index.cjs.map +2 -2
- package/build/components/dataviews-view-config/index.cjs +74 -57
- package/build/components/dataviews-view-config/index.cjs.map +3 -3
- package/build/components/dataviews-view-config/properties-section.cjs +1 -1
- package/build/components/dataviews-view-config/properties-section.cjs.map +1 -1
- package/build/dataviews/index.cjs +7 -5
- package/build/dataviews/index.cjs.map +2 -2
- package/build/dataviews-picker/index.cjs +3 -3
- package/build/dataviews-picker/index.cjs.map +2 -2
- package/build/hooks/use-form-validity.cjs +61 -28
- package/build/hooks/use-form-validity.cjs.map +2 -2
- package/build/hooks/use-report-validity.cjs +39 -0
- package/build/hooks/use-report-validity.cjs.map +7 -0
- package/build/types/dataform.cjs.map +1 -1
- package/build/types/field-api.cjs.map +1 -1
- package/build-module/components/dataform-controls/adaptive-select.mjs +21 -0
- package/build-module/components/dataform-controls/adaptive-select.mjs.map +7 -0
- package/build-module/components/dataform-controls/array.mjs +2 -0
- package/build-module/components/dataform-controls/array.mjs.map +2 -2
- package/build-module/components/dataform-controls/checkbox.mjs +2 -0
- package/build-module/components/dataform-controls/checkbox.mjs.map +2 -2
- package/build-module/components/dataform-controls/color.mjs +26 -31
- package/build-module/components/dataform-controls/color.mjs.map +2 -2
- package/build-module/components/dataform-controls/combobox.mjs +49 -0
- package/build-module/components/dataform-controls/combobox.mjs.map +7 -0
- package/build-module/components/dataform-controls/date.mjs +58 -19
- package/build-module/components/dataform-controls/date.mjs.map +2 -2
- package/build-module/components/dataform-controls/datetime.mjs +11 -3
- package/build-module/components/dataform-controls/datetime.mjs.map +2 -2
- package/build-module/components/dataform-controls/email.mjs +2 -0
- package/build-module/components/dataform-controls/email.mjs.map +2 -2
- package/build-module/components/dataform-controls/index.mjs +5 -1
- package/build-module/components/dataform-controls/index.mjs.map +2 -2
- package/build-module/components/dataform-controls/password.mjs +2 -0
- package/build-module/components/dataform-controls/password.mjs.map +2 -2
- package/build-module/components/dataform-controls/radio.mjs +2 -0
- package/build-module/components/dataform-controls/radio.mjs.map +2 -2
- package/build-module/components/dataform-controls/select.mjs +2 -0
- package/build-module/components/dataform-controls/select.mjs.map +2 -2
- package/build-module/components/dataform-controls/telephone.mjs +2 -0
- package/build-module/components/dataform-controls/telephone.mjs.map +2 -2
- package/build-module/components/dataform-controls/text.mjs +2 -0
- package/build-module/components/dataform-controls/text.mjs.map +2 -2
- package/build-module/components/dataform-controls/textarea.mjs +2 -0
- package/build-module/components/dataform-controls/textarea.mjs.map +2 -2
- package/build-module/components/dataform-controls/toggle-group.mjs +2 -0
- package/build-module/components/dataform-controls/toggle-group.mjs.map +2 -2
- package/build-module/components/dataform-controls/toggle.mjs +2 -0
- package/build-module/components/dataform-controls/toggle.mjs.map +2 -2
- package/build-module/components/dataform-controls/url.mjs +2 -0
- package/build-module/components/dataform-controls/url.mjs.map +2 -2
- package/build-module/components/dataform-controls/utils/relative-date-control.mjs +1 -1
- package/build-module/components/dataform-controls/utils/relative-date-control.mjs.map +1 -1
- package/build-module/components/dataform-controls/utils/validated-input.mjs +2 -0
- package/build-module/components/dataform-controls/utils/validated-input.mjs.map +2 -2
- package/build-module/components/dataform-controls/utils/validated-number.mjs +2 -0
- package/build-module/components/dataform-controls/utils/validated-number.mjs.map +2 -2
- package/build-module/components/dataform-layouts/card/index.mjs +29 -3
- package/build-module/components/dataform-layouts/card/index.mjs.map +2 -2
- package/build-module/components/dataform-layouts/data-form-layout.mjs +12 -3
- package/build-module/components/dataform-layouts/data-form-layout.mjs.map +2 -2
- package/build-module/components/dataform-layouts/details/index.mjs +77 -13
- package/build-module/components/dataform-layouts/details/index.mjs.map +2 -2
- package/build-module/components/dataform-layouts/index.mjs +5 -5
- package/build-module/components/dataform-layouts/index.mjs.map +1 -1
- package/build-module/components/dataform-layouts/normalize-form.mjs +2 -1
- package/build-module/components/dataform-layouts/normalize-form.mjs.map +2 -2
- package/build-module/components/dataform-layouts/panel/dropdown.mjs +91 -66
- package/build-module/components/dataform-layouts/panel/dropdown.mjs.map +2 -2
- package/build-module/components/dataform-layouts/panel/index.mjs +14 -176
- package/build-module/components/dataform-layouts/panel/index.mjs.map +2 -2
- package/build-module/components/dataform-layouts/panel/modal.mjs +30 -20
- package/build-module/components/dataform-layouts/panel/modal.mjs.map +2 -2
- package/build-module/components/dataform-layouts/panel/summary-button.mjs +117 -58
- package/build-module/components/dataform-layouts/panel/summary-button.mjs.map +2 -2
- package/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs +38 -0
- package/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs.map +7 -0
- package/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs +14 -0
- package/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs.map +7 -0
- package/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs +15 -0
- package/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs.map +7 -0
- package/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs +46 -0
- package/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs.map +7 -0
- package/build-module/components/dataform-layouts/regular/index.mjs +6 -3
- package/build-module/components/dataform-layouts/regular/index.mjs.map +2 -2
- package/build-module/components/dataform-layouts/row/index.mjs +5 -2
- package/build-module/components/dataform-layouts/row/index.mjs.map +2 -2
- package/build-module/components/dataform-layouts/validation-badge.mjs +46 -0
- package/build-module/components/dataform-layouts/validation-badge.mjs.map +7 -0
- package/build-module/components/dataviews-bulk-actions/index.mjs +4 -4
- package/build-module/components/dataviews-bulk-actions/index.mjs.map +2 -2
- package/build-module/components/dataviews-context/index.mjs.map +2 -2
- package/build-module/components/dataviews-filters/filter.mjs +1 -1
- package/build-module/components/dataviews-filters/filter.mjs.map +1 -1
- package/build-module/components/dataviews-filters/filters.mjs +1 -1
- package/build-module/components/dataviews-filters/filters.mjs.map +1 -1
- package/build-module/components/dataviews-filters/search-widget.mjs +25 -11
- package/build-module/components/dataviews-filters/search-widget.mjs.map +2 -2
- package/build-module/components/dataviews-filters/toggle.mjs.map +1 -1
- package/build-module/components/dataviews-footer/index.mjs +1 -1
- package/build-module/components/dataviews-footer/index.mjs.map +1 -1
- package/build-module/components/dataviews-layouts/activity/activity-item.mjs +4 -4
- package/build-module/components/dataviews-layouts/activity/activity-item.mjs.map +1 -1
- package/build-module/components/dataviews-layouts/activity/index.mjs +1 -1
- package/build-module/components/dataviews-layouts/activity/index.mjs.map +1 -1
- package/build-module/components/dataviews-layouts/grid/composite-grid.mjs +27 -38
- package/build-module/components/dataviews-layouts/grid/composite-grid.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/grid/index.mjs +2 -2
- package/build-module/components/dataviews-layouts/grid/index.mjs.map +1 -1
- package/build-module/components/dataviews-layouts/list/index.mjs +7 -8
- package/build-module/components/dataviews-layouts/list/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/picker-grid/index.mjs +5 -5
- package/build-module/components/dataviews-layouts/picker-grid/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/picker-table/index.mjs +1 -1
- package/build-module/components/dataviews-layouts/picker-table/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/table/column-primary.mjs +1 -1
- package/build-module/components/dataviews-layouts/table/column-primary.mjs.map +1 -1
- package/build-module/components/dataviews-layouts/table/index.mjs +1 -1
- package/build-module/components/dataviews-layouts/table/index.mjs.map +2 -2
- package/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs.map +2 -2
- package/build-module/components/dataviews-pagination/index.mjs +3 -3
- package/build-module/components/dataviews-pagination/index.mjs.map +2 -2
- package/build-module/components/dataviews-picker-footer/index.mjs +3 -3
- package/build-module/components/dataviews-picker-footer/index.mjs.map +2 -2
- package/build-module/components/dataviews-view-config/index.mjs +74 -59
- package/build-module/components/dataviews-view-config/index.mjs.map +2 -2
- package/build-module/components/dataviews-view-config/properties-section.mjs +1 -1
- package/build-module/components/dataviews-view-config/properties-section.mjs.map +1 -1
- package/build-module/dataviews/index.mjs +7 -5
- package/build-module/dataviews/index.mjs.map +2 -2
- package/build-module/dataviews-picker/index.mjs +3 -3
- package/build-module/dataviews-picker/index.mjs.map +2 -2
- package/build-module/hooks/use-form-validity.mjs +61 -28
- package/build-module/hooks/use-form-validity.mjs.map +2 -2
- package/build-module/hooks/use-report-validity.mjs +18 -0
- package/build-module/hooks/use-report-validity.mjs.map +7 -0
- package/build-style/style-rtl.css +149 -217
- package/build-style/style.css +149 -217
- package/build-types/components/dataform-controls/adaptive-select.d.ts +6 -0
- package/build-types/components/dataform-controls/adaptive-select.d.ts.map +1 -0
- package/build-types/components/dataform-controls/array.d.ts +1 -1
- package/build-types/components/dataform-controls/array.d.ts.map +1 -1
- package/build-types/components/dataform-controls/checkbox.d.ts +1 -1
- package/build-types/components/dataform-controls/checkbox.d.ts.map +1 -1
- package/build-types/components/dataform-controls/color.d.ts +1 -1
- package/build-types/components/dataform-controls/color.d.ts.map +1 -1
- package/build-types/components/dataform-controls/combobox.d.ts +6 -0
- package/build-types/components/dataform-controls/combobox.d.ts.map +1 -0
- package/build-types/components/dataform-controls/date.d.ts +1 -1
- package/build-types/components/dataform-controls/date.d.ts.map +1 -1
- package/build-types/components/dataform-controls/datetime.d.ts +1 -1
- package/build-types/components/dataform-controls/datetime.d.ts.map +1 -1
- package/build-types/components/dataform-controls/email.d.ts +1 -1
- package/build-types/components/dataform-controls/email.d.ts.map +1 -1
- package/build-types/components/dataform-controls/index.d.ts.map +1 -1
- package/build-types/components/dataform-controls/password.d.ts +1 -1
- package/build-types/components/dataform-controls/password.d.ts.map +1 -1
- package/build-types/components/dataform-controls/radio.d.ts +1 -1
- package/build-types/components/dataform-controls/radio.d.ts.map +1 -1
- package/build-types/components/dataform-controls/select.d.ts +1 -1
- package/build-types/components/dataform-controls/select.d.ts.map +1 -1
- package/build-types/components/dataform-controls/telephone.d.ts +1 -1
- package/build-types/components/dataform-controls/telephone.d.ts.map +1 -1
- package/build-types/components/dataform-controls/text.d.ts +1 -1
- package/build-types/components/dataform-controls/text.d.ts.map +1 -1
- package/build-types/components/dataform-controls/textarea.d.ts +1 -1
- package/build-types/components/dataform-controls/textarea.d.ts.map +1 -1
- package/build-types/components/dataform-controls/toggle-group.d.ts +1 -1
- package/build-types/components/dataform-controls/toggle-group.d.ts.map +1 -1
- package/build-types/components/dataform-controls/toggle.d.ts +1 -1
- package/build-types/components/dataform-controls/toggle.d.ts.map +1 -1
- package/build-types/components/dataform-controls/url.d.ts +1 -1
- package/build-types/components/dataform-controls/url.d.ts.map +1 -1
- package/build-types/components/dataform-controls/utils/validated-input.d.ts +1 -1
- package/build-types/components/dataform-controls/utils/validated-input.d.ts.map +1 -1
- package/build-types/components/dataform-controls/utils/validated-number.d.ts +1 -1
- package/build-types/components/dataform-controls/utils/validated-number.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/card/index.d.ts +3 -1
- package/build-types/components/dataform-layouts/card/index.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/data-form-layout.d.ts +2 -1
- package/build-types/components/dataform-layouts/data-form-layout.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/details/index.d.ts +1 -1
- package/build-types/components/dataform-layouts/details/index.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/normalize-form.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/panel/dropdown.d.ts +2 -12
- package/build-types/components/dataform-layouts/panel/dropdown.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/panel/index.d.ts +1 -1
- package/build-types/components/dataform-layouts/panel/index.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/panel/modal.d.ts +2 -10
- package/build-types/components/dataform-layouts/panel/modal.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/panel/summary-button.d.ts +6 -5
- package/build-types/components/dataform-layouts/panel/summary-button.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/panel/utils/get-first-validation-error.d.ts +4 -0
- package/build-types/components/dataform-layouts/panel/utils/get-first-validation-error.d.ts.map +1 -0
- package/build-types/components/dataform-layouts/panel/utils/get-label-classname.d.ts +4 -0
- package/build-types/components/dataform-layouts/panel/utils/get-label-classname.d.ts.map +1 -0
- package/build-types/components/dataform-layouts/panel/utils/get-label-content.d.ts +3 -0
- package/build-types/components/dataform-layouts/panel/utils/get-label-content.d.ts.map +1 -0
- package/build-types/components/dataform-layouts/panel/utils/use-field-from-form-field.d.ts +23 -0
- package/build-types/components/dataform-layouts/panel/utils/use-field-from-form-field.d.ts.map +1 -0
- package/build-types/components/dataform-layouts/regular/index.d.ts +1 -1
- package/build-types/components/dataform-layouts/regular/index.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/row/index.d.ts +1 -1
- package/build-types/components/dataform-layouts/row/index.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/validation-badge.d.ts +8 -0
- package/build-types/components/dataform-layouts/validation-badge.d.ts.map +1 -0
- package/build-types/components/dataviews-context/index.d.ts +1 -0
- package/build-types/components/dataviews-context/index.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/filter.d.ts +1 -1
- package/build-types/components/dataviews-filters/filter.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/list/index.d.ts.map +1 -1
- package/build-types/components/dataviews-layouts/utils/item-click-wrapper.d.ts +1 -0
- package/build-types/components/dataviews-layouts/utils/item-click-wrapper.d.ts.map +1 -1
- package/build-types/components/dataviews-view-config/index.d.ts.map +1 -1
- package/build-types/dataform/stories/content.story.d.ts +14 -0
- package/build-types/dataform/stories/content.story.d.ts.map +1 -0
- package/build-types/dataform/stories/index.story.d.ts +10 -2
- package/build-types/dataform/stories/index.story.d.ts.map +1 -1
- package/build-types/dataform/stories/layout-panel.d.ts +3 -1
- package/build-types/dataform/stories/layout-panel.d.ts.map +1 -1
- package/build-types/dataform/stories/validation.d.ts +1 -1
- package/build-types/dataform/stories/validation.d.ts.map +1 -1
- package/build-types/dataviews/index.d.ts +2 -1
- package/build-types/dataviews/index.d.ts.map +1 -1
- package/build-types/dataviews/stories/fixtures.d.ts +1 -0
- package/build-types/dataviews/stories/fixtures.d.ts.map +1 -1
- package/build-types/dataviews/stories/index.story.d.ts +14 -2
- package/build-types/dataviews/stories/index.story.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-activity.d.ts +2 -1
- package/build-types/dataviews/stories/layout-activity.d.ts.map +1 -1
- package/build-types/dataviews/stories/layout-list.d.ts +2 -1
- package/build-types/dataviews/stories/layout-list.d.ts.map +1 -1
- package/build-types/field-types/stories/index.story.d.ts +42 -16
- package/build-types/field-types/stories/index.story.d.ts.map +1 -1
- package/build-types/hooks/use-form-validity.d.ts.map +1 -1
- package/build-types/hooks/use-report-validity.d.ts +14 -0
- package/build-types/hooks/use-report-validity.d.ts.map +1 -0
- package/build-types/types/dataform.d.ts +4 -0
- package/build-types/types/dataform.d.ts.map +1 -1
- package/build-types/types/field-api.d.ts +4 -0
- package/build-types/types/field-api.d.ts.map +1 -1
- package/build-wp/index.js +3749 -2632
- package/package.json +22 -21
- package/src/components/dataform-controls/adaptive-select.tsx +23 -0
- package/src/components/dataform-controls/array.tsx +2 -0
- package/src/components/dataform-controls/checkbox.tsx +2 -0
- package/src/components/dataform-controls/color.tsx +31 -36
- package/src/components/dataform-controls/combobox.tsx +58 -0
- package/src/components/dataform-controls/date.tsx +69 -26
- package/src/components/dataform-controls/datetime.tsx +16 -6
- package/src/components/dataform-controls/email.tsx +2 -0
- package/src/components/dataform-controls/index.tsx +5 -1
- package/src/components/dataform-controls/password.tsx +2 -0
- package/src/components/dataform-controls/radio.tsx +2 -0
- package/src/components/dataform-controls/select.tsx +2 -0
- package/src/components/dataform-controls/style.scss +4 -0
- package/src/components/dataform-controls/telephone.tsx +2 -0
- package/src/components/dataform-controls/text.tsx +2 -0
- package/src/components/dataform-controls/textarea.tsx +2 -0
- package/src/components/dataform-controls/toggle-group.tsx +2 -0
- package/src/components/dataform-controls/toggle.tsx +2 -0
- package/src/components/dataform-controls/url.tsx +2 -0
- package/src/components/dataform-controls/utils/relative-date-control.tsx +1 -1
- package/src/components/dataform-controls/utils/validated-input.tsx +2 -0
- package/src/components/dataform-controls/utils/validated-number.tsx +2 -0
- package/src/components/dataform-layouts/card/index.tsx +40 -3
- package/src/components/dataform-layouts/data-form-layout.tsx +18 -4
- package/src/components/dataform-layouts/details/index.tsx +66 -4
- package/src/components/dataform-layouts/details/style.scss +5 -0
- package/src/components/dataform-layouts/index.tsx +5 -5
- package/src/components/dataform-layouts/normalize-form.ts +1 -0
- package/src/components/dataform-layouts/panel/dropdown.tsx +110 -94
- package/src/components/dataform-layouts/panel/index.tsx +10 -243
- package/src/components/dataform-layouts/panel/modal.tsx +43 -29
- package/src/components/dataform-layouts/panel/style.scss +109 -27
- package/src/components/dataform-layouts/panel/summary-button.tsx +140 -62
- package/src/components/dataform-layouts/panel/utils/get-first-validation-error.ts +47 -0
- package/src/components/dataform-layouts/panel/utils/get-label-classname.ts +18 -0
- package/src/components/dataform-layouts/panel/utils/get-label-content.tsx +26 -0
- package/src/components/dataform-layouts/panel/utils/use-field-from-form-field.ts +78 -0
- package/src/components/dataform-layouts/regular/index.tsx +8 -3
- package/src/components/dataform-layouts/regular/style.scss +10 -0
- package/src/components/dataform-layouts/row/index.tsx +5 -2
- package/src/components/dataform-layouts/test/normalize-form.ts +5 -0
- package/src/components/dataform-layouts/validation-badge.tsx +63 -0
- package/src/components/dataviews-bulk-actions/index.tsx +4 -4
- package/src/components/dataviews-context/index.ts +1 -0
- package/src/components/dataviews-filters/filter.tsx +2 -2
- package/src/components/dataviews-filters/filters.tsx +1 -1
- package/src/components/dataviews-filters/search-widget.tsx +10 -2
- package/src/components/dataviews-filters/style.scss +8 -0
- package/src/components/dataviews-filters/toggle.tsx +1 -1
- package/src/components/dataviews-footer/index.tsx +1 -1
- package/src/components/dataviews-layouts/activity/activity-item.tsx +4 -4
- package/src/components/dataviews-layouts/activity/index.tsx +1 -1
- package/src/components/dataviews-layouts/grid/composite-grid.tsx +35 -35
- package/src/components/dataviews-layouts/grid/index.tsx +2 -2
- package/src/components/dataviews-layouts/grid/style.scss +15 -1
- package/src/components/dataviews-layouts/list/index.tsx +7 -8
- package/src/components/dataviews-layouts/list/style.scss +1 -0
- package/src/components/dataviews-layouts/picker-grid/index.tsx +5 -5
- package/src/components/dataviews-layouts/picker-table/index.tsx +1 -1
- package/src/components/dataviews-layouts/table/column-primary.tsx +1 -1
- package/src/components/dataviews-layouts/table/index.tsx +1 -1
- package/src/components/dataviews-layouts/utils/item-click-wrapper.tsx +1 -0
- package/src/components/dataviews-pagination/index.tsx +3 -3
- package/src/components/dataviews-picker-footer/index.tsx +3 -3
- package/src/components/dataviews-view-config/index.tsx +61 -50
- package/src/components/dataviews-view-config/properties-section.tsx +1 -1
- package/src/components/dataviews-view-config/style.scss +21 -0
- package/src/dataform/stories/content.story.mdx +159 -0
- package/src/dataform/stories/content.story.tsx +390 -0
- package/src/dataform/stories/index.story.tsx +14 -2
- package/src/dataform/stories/layout-panel.tsx +19 -2
- package/src/dataform/stories/validation.tsx +100 -7
- package/src/dataform/test/dataform.tsx +2 -2
- package/src/dataviews/index.tsx +7 -4
- package/src/dataviews/stories/empty.tsx +1 -1
- package/src/dataviews/stories/fixtures.tsx +93 -4
- package/src/dataviews/stories/free-composition.tsx +6 -6
- package/src/dataviews/stories/index.story.tsx +12 -0
- package/src/dataviews/stories/layout-activity.tsx +6 -3
- package/src/dataviews/stories/layout-list.tsx +3 -0
- package/src/dataviews-picker/index.tsx +4 -4
- package/src/dataviews-picker/stories/fixtures.tsx +2 -2
- package/src/dataviews-picker/stories/index.story.tsx +1 -1
- package/src/field-types/stories/index.story.tsx +101 -5
- package/src/hooks/test/use-form-validity.ts +303 -178
- package/src/hooks/use-form-validity.ts +85 -36
- package/src/hooks/use-report-validity.ts +32 -0
- package/src/style.scss +0 -2
- package/src/types/dataform.ts +5 -0
- package/src/types/field-api.ts +4 -0
|
@@ -1647,214 +1647,339 @@ describe( 'useFormValidity', () => {
|
|
|
1647
1647
|
expect( isValid ).toBe( false );
|
|
1648
1648
|
} );
|
|
1649
1649
|
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1650
|
+
it( 'should return early on custom sync validation failure', async () => {
|
|
1651
|
+
const item = { status: 'draft' };
|
|
1652
|
+
const fields: Field< any >[] = [
|
|
1653
|
+
{
|
|
1654
|
+
id: 'status',
|
|
1655
|
+
type: 'text',
|
|
1656
|
+
getElements: async () =>
|
|
1657
|
+
await new Promise( ( resolve ) => {
|
|
1658
|
+
setTimeout( resolve, 5 );
|
|
1659
|
+
} ).then( () => [
|
|
1660
|
+
{ value: 'draft', label: 'Draft' },
|
|
1661
|
+
{ value: 'published', label: 'Published' },
|
|
1662
|
+
] ),
|
|
1663
|
+
isValid: {
|
|
1664
|
+
elements: true,
|
|
1665
|
+
custom: ( value ) => {
|
|
1666
|
+
if ( value.status !== 'published' ) {
|
|
1667
|
+
return 'Status must be published.';
|
|
1668
|
+
}
|
|
1669
|
+
return null;
|
|
1666
1670
|
},
|
|
1667
1671
|
},
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1672
|
+
},
|
|
1673
|
+
];
|
|
1674
|
+
const form = { fields: [ 'status' ] };
|
|
1675
|
+
const { result } = renderHook( () =>
|
|
1676
|
+
useFormValidity( item, fields, form )
|
|
1677
|
+
);
|
|
1678
|
+
expect( result.current ).toEqual( {
|
|
1679
|
+
validity: {
|
|
1680
|
+
status: {
|
|
1681
|
+
custom: {
|
|
1682
|
+
type: 'invalid',
|
|
1683
|
+
message: 'Status must be published.',
|
|
1676
1684
|
},
|
|
1677
1685
|
},
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1686
|
+
},
|
|
1687
|
+
isValid: false,
|
|
1688
|
+
} );
|
|
1689
|
+
} );
|
|
1690
|
+
} );
|
|
1691
|
+
describe( 'async', () => {
|
|
1692
|
+
it( 'is valid when async custom validations pass (return null)', async () => {
|
|
1693
|
+
const item = {
|
|
1694
|
+
id: 1,
|
|
1695
|
+
title: 'Valid Title',
|
|
1696
|
+
status: 'published',
|
|
1697
|
+
};
|
|
1698
|
+
const fields: Field< {} >[] = [
|
|
1699
|
+
{
|
|
1700
|
+
id: 'title',
|
|
1701
|
+
type: 'text',
|
|
1702
|
+
isValid: {
|
|
1703
|
+
custom: async () =>
|
|
1704
|
+
await new Promise( ( resolve ) =>
|
|
1705
|
+
setTimeout( resolve, 5 )
|
|
1706
|
+
).then( () => null ),
|
|
1707
|
+
},
|
|
1708
|
+
},
|
|
1709
|
+
{
|
|
1710
|
+
id: 'status',
|
|
1711
|
+
type: 'text',
|
|
1712
|
+
isValid: {
|
|
1713
|
+
custom: async () =>
|
|
1714
|
+
await new Promise( ( resolve ) =>
|
|
1715
|
+
setTimeout( resolve, 5 )
|
|
1716
|
+
).then( () => null ),
|
|
1717
|
+
},
|
|
1718
|
+
},
|
|
1719
|
+
];
|
|
1720
|
+
const form = { fields: [ 'title', 'status' ] };
|
|
1721
|
+
const { result } = renderHook( () =>
|
|
1722
|
+
useFormValidity( item, fields, form )
|
|
1723
|
+
);
|
|
1724
|
+
|
|
1725
|
+
await waitFor( () => {
|
|
1726
|
+
expect( result.current ).toEqual( {
|
|
1727
|
+
validity: undefined,
|
|
1728
|
+
isValid: true,
|
|
1729
|
+
} );
|
|
1730
|
+
} );
|
|
1731
|
+
} );
|
|
1732
|
+
|
|
1733
|
+
it( 'is invalid and message is "Validating…" when promise is in flight', async () => {
|
|
1734
|
+
const item = {
|
|
1735
|
+
id: 1,
|
|
1736
|
+
title: 'Invalid Title',
|
|
1737
|
+
status: 'published',
|
|
1738
|
+
};
|
|
1739
|
+
const fields: Field< {} >[] = [
|
|
1740
|
+
{
|
|
1741
|
+
id: 'title',
|
|
1742
|
+
type: 'text',
|
|
1743
|
+
isValid: {
|
|
1744
|
+
// This promise is never resolved.
|
|
1745
|
+
// Serves to test in flight behavior of validation.
|
|
1746
|
+
custom: async () => await new Promise( () => {} ),
|
|
1747
|
+
},
|
|
1748
|
+
},
|
|
1749
|
+
];
|
|
1750
|
+
const form = { fields: [ 'title' ] };
|
|
1751
|
+
const { result } = renderHook( () =>
|
|
1752
|
+
useFormValidity( item, fields, form )
|
|
1753
|
+
);
|
|
1754
|
+
|
|
1755
|
+
await waitFor( () => {
|
|
1756
|
+
expect( result.current ).toEqual( {
|
|
1757
|
+
validity: {
|
|
1758
|
+
title: {
|
|
1759
|
+
custom: {
|
|
1760
|
+
type: 'validating',
|
|
1761
|
+
message: 'Validating…',
|
|
1692
1762
|
},
|
|
1693
1763
|
},
|
|
1694
|
-
|
|
1695
|
-
|
|
1764
|
+
},
|
|
1765
|
+
isValid: false,
|
|
1696
1766
|
} );
|
|
1697
1767
|
} );
|
|
1768
|
+
} );
|
|
1698
1769
|
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1770
|
+
it( 'is invalid when validity object contains at least one type:invalid message', async () => {
|
|
1771
|
+
const item = {
|
|
1772
|
+
id: 1,
|
|
1773
|
+
title: 'Invalid Title',
|
|
1774
|
+
status: 'published',
|
|
1775
|
+
};
|
|
1776
|
+
const fields: Field< {} >[] = [
|
|
1777
|
+
{
|
|
1778
|
+
id: 'title',
|
|
1779
|
+
type: 'text',
|
|
1780
|
+
isValid: {
|
|
1781
|
+
custom: async () =>
|
|
1782
|
+
await new Promise( ( resolve ) =>
|
|
1783
|
+
setTimeout( resolve, 5 )
|
|
1784
|
+
).then( () => 'Title is invalid.' ),
|
|
1714
1785
|
},
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
)
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1786
|
+
},
|
|
1787
|
+
];
|
|
1788
|
+
const form = { fields: [ 'title' ] };
|
|
1789
|
+
const { result } = renderHook( () =>
|
|
1790
|
+
useFormValidity( item, fields, form )
|
|
1791
|
+
);
|
|
1792
|
+
|
|
1793
|
+
await waitFor( () => {
|
|
1794
|
+
expect( result.current ).toEqual( {
|
|
1795
|
+
validity: {
|
|
1796
|
+
title: {
|
|
1797
|
+
custom: {
|
|
1798
|
+
type: 'invalid',
|
|
1799
|
+
message: 'Title is invalid.',
|
|
1729
1800
|
},
|
|
1730
1801
|
},
|
|
1731
|
-
|
|
1732
|
-
|
|
1802
|
+
},
|
|
1803
|
+
isValid: false,
|
|
1733
1804
|
} );
|
|
1734
1805
|
} );
|
|
1806
|
+
} );
|
|
1735
1807
|
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1808
|
+
it( 'is invalid when custom returns anything other than null or a string', async () => {
|
|
1809
|
+
const item = {
|
|
1810
|
+
id: 1,
|
|
1811
|
+
title: 'Invalid Title',
|
|
1812
|
+
status: 'published',
|
|
1813
|
+
};
|
|
1814
|
+
const fields: Field< {} >[] = [
|
|
1815
|
+
{
|
|
1816
|
+
id: 'title',
|
|
1817
|
+
type: 'text',
|
|
1818
|
+
isValid: {
|
|
1819
|
+
// @ts-ignore returns wrong type for testing purposes
|
|
1820
|
+
custom: async () =>
|
|
1821
|
+
await new Promise( ( resolve ) =>
|
|
1822
|
+
setTimeout( resolve, 5 )
|
|
1823
|
+
).then( () => 3 ),
|
|
1752
1824
|
},
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
)
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1825
|
+
},
|
|
1826
|
+
];
|
|
1827
|
+
const form = { fields: [ 'title' ] };
|
|
1828
|
+
const { result } = renderHook( () =>
|
|
1829
|
+
useFormValidity( item, fields, form )
|
|
1830
|
+
);
|
|
1831
|
+
|
|
1832
|
+
await waitFor( () => {
|
|
1833
|
+
expect( result.current ).toEqual( {
|
|
1834
|
+
validity: {
|
|
1835
|
+
title: {
|
|
1836
|
+
custom: {
|
|
1837
|
+
type: 'invalid',
|
|
1838
|
+
message: 'Validation could not be processed.',
|
|
1767
1839
|
},
|
|
1768
1840
|
},
|
|
1769
|
-
|
|
1770
|
-
|
|
1841
|
+
},
|
|
1842
|
+
isValid: false,
|
|
1771
1843
|
} );
|
|
1772
1844
|
} );
|
|
1845
|
+
} );
|
|
1773
1846
|
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1847
|
+
it( 'is invalid when promise was rejected', async () => {
|
|
1848
|
+
const item = {
|
|
1849
|
+
id: 1,
|
|
1850
|
+
title: 'Invalid Title',
|
|
1851
|
+
status: 'published',
|
|
1852
|
+
};
|
|
1853
|
+
const fields: Field< {} >[] = [
|
|
1854
|
+
{
|
|
1855
|
+
id: 'title',
|
|
1856
|
+
type: 'text',
|
|
1857
|
+
isValid: {
|
|
1858
|
+
custom: async () =>
|
|
1859
|
+
await new Promise( ( resolve, reject ) =>
|
|
1860
|
+
setTimeout(
|
|
1861
|
+
() =>
|
|
1862
|
+
reject(
|
|
1863
|
+
new Error(
|
|
1864
|
+
'Validation did not complete successfully.'
|
|
1865
|
+
)
|
|
1866
|
+
),
|
|
1867
|
+
5
|
|
1868
|
+
)
|
|
1869
|
+
),
|
|
1791
1870
|
},
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
)
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1871
|
+
},
|
|
1872
|
+
];
|
|
1873
|
+
const form = { fields: [ 'title' ] };
|
|
1874
|
+
const { result } = renderHook( () =>
|
|
1875
|
+
useFormValidity( item, fields, form )
|
|
1876
|
+
);
|
|
1877
|
+
|
|
1878
|
+
await waitFor( () => {
|
|
1879
|
+
expect( result.current ).toEqual( {
|
|
1880
|
+
validity: {
|
|
1881
|
+
title: {
|
|
1882
|
+
custom: {
|
|
1883
|
+
type: 'invalid',
|
|
1884
|
+
message:
|
|
1885
|
+
'Validation did not complete successfully.',
|
|
1807
1886
|
},
|
|
1808
1887
|
},
|
|
1809
|
-
|
|
1810
|
-
|
|
1888
|
+
},
|
|
1889
|
+
isValid: false,
|
|
1811
1890
|
} );
|
|
1812
1891
|
} );
|
|
1892
|
+
} );
|
|
1813
1893
|
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
reject(
|
|
1830
|
-
new Error(
|
|
1831
|
-
'Validation did not complete successfully.'
|
|
1832
|
-
)
|
|
1833
|
-
),
|
|
1834
|
-
5
|
|
1835
|
-
)
|
|
1836
|
-
),
|
|
1837
|
-
},
|
|
1894
|
+
it( 'should remove field from validity when async elements validation passes', async () => {
|
|
1895
|
+
const item = { status: 'draft' };
|
|
1896
|
+
const fields: Field< any >[] = [
|
|
1897
|
+
{
|
|
1898
|
+
id: 'status',
|
|
1899
|
+
type: 'text',
|
|
1900
|
+
getElements: async () =>
|
|
1901
|
+
await new Promise( ( resolve ) => {
|
|
1902
|
+
setTimeout( resolve, 5 );
|
|
1903
|
+
} ).then( () => [
|
|
1904
|
+
{ value: 'draft', label: 'Draft' },
|
|
1905
|
+
{ value: 'published', label: 'Published' },
|
|
1906
|
+
] ),
|
|
1907
|
+
isValid: {
|
|
1908
|
+
elements: true,
|
|
1838
1909
|
},
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
)
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1910
|
+
},
|
|
1911
|
+
];
|
|
1912
|
+
const form = { fields: [ 'status' ] };
|
|
1913
|
+
const { result } = renderHook( () =>
|
|
1914
|
+
useFormValidity( item, fields, form )
|
|
1915
|
+
);
|
|
1916
|
+
|
|
1917
|
+
// Initially should be validating.
|
|
1918
|
+
expect( result.current.validity?.status?.elements?.type ).toBe(
|
|
1919
|
+
'validating'
|
|
1920
|
+
);
|
|
1921
|
+
|
|
1922
|
+
// After resolution, field should be removed (validation passed)
|
|
1923
|
+
await waitFor( () => {
|
|
1924
|
+
expect( result.current ).toEqual( {
|
|
1925
|
+
validity: undefined, // No validation errors
|
|
1926
|
+
isValid: true,
|
|
1927
|
+
} );
|
|
1928
|
+
} );
|
|
1929
|
+
} );
|
|
1930
|
+
|
|
1931
|
+
it( 'should run both async elements and async custom validation', async () => {
|
|
1932
|
+
const item = { status: 'draft' };
|
|
1933
|
+
const fields: Field< any >[] = [
|
|
1934
|
+
{
|
|
1935
|
+
id: 'status',
|
|
1936
|
+
type: 'text',
|
|
1937
|
+
getElements: async () =>
|
|
1938
|
+
await new Promise( ( resolve ) => {
|
|
1939
|
+
setTimeout( resolve, 5 );
|
|
1940
|
+
} ).then( () => [
|
|
1941
|
+
{ value: 'draft', label: 'Draft' },
|
|
1942
|
+
{ value: 'published', label: 'Published' },
|
|
1943
|
+
] ),
|
|
1944
|
+
isValid: {
|
|
1945
|
+
elements: true,
|
|
1946
|
+
custom: async ( value ) =>
|
|
1947
|
+
await new Promise( ( resolve ) =>
|
|
1948
|
+
setTimeout( resolve, 5 )
|
|
1949
|
+
).then( () => {
|
|
1950
|
+
if ( value.status !== 'published' ) {
|
|
1951
|
+
return 'Status must be published.';
|
|
1952
|
+
}
|
|
1953
|
+
return null;
|
|
1954
|
+
} ),
|
|
1955
|
+
},
|
|
1956
|
+
},
|
|
1957
|
+
];
|
|
1958
|
+
const form = { fields: [ 'status' ] };
|
|
1959
|
+
const { result } = renderHook( () =>
|
|
1960
|
+
useFormValidity( item, fields, form )
|
|
1961
|
+
);
|
|
1962
|
+
|
|
1963
|
+
// Initially should have both validating
|
|
1964
|
+
expect( result.current.validity?.status?.elements?.type ).toBe(
|
|
1965
|
+
'validating'
|
|
1966
|
+
);
|
|
1967
|
+
expect( result.current.validity?.status?.custom?.type ).toBe(
|
|
1968
|
+
'validating'
|
|
1969
|
+
);
|
|
1970
|
+
|
|
1971
|
+
// After both async resolve, elements passes but custom fails
|
|
1972
|
+
await waitFor( () => {
|
|
1973
|
+
expect( result.current ).toEqual( {
|
|
1974
|
+
validity: {
|
|
1975
|
+
status: {
|
|
1976
|
+
custom: {
|
|
1977
|
+
type: 'invalid',
|
|
1978
|
+
message: 'Status must be published.',
|
|
1854
1979
|
},
|
|
1855
1980
|
},
|
|
1856
|
-
|
|
1857
|
-
|
|
1981
|
+
},
|
|
1982
|
+
isValid: false,
|
|
1858
1983
|
} );
|
|
1859
1984
|
} );
|
|
1860
1985
|
} );
|