@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dataviews",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -52,24 +52,24 @@
|
|
|
52
52
|
"types": "build-types",
|
|
53
53
|
"sideEffects": false,
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@ariakit/react": "^0.4.
|
|
56
|
-
"@wordpress/base-styles": "^6.
|
|
57
|
-
"@wordpress/components": "^32.
|
|
58
|
-
"@wordpress/compose": "^7.
|
|
59
|
-
"@wordpress/data": "^10.
|
|
60
|
-
"@wordpress/date": "^5.
|
|
61
|
-
"@wordpress/deprecated": "^4.
|
|
62
|
-
"@wordpress/dom": "^4.
|
|
63
|
-
"@wordpress/element": "^6.
|
|
64
|
-
"@wordpress/i18n": "^6.
|
|
65
|
-
"@wordpress/icons": "^11.
|
|
66
|
-
"@wordpress/keycodes": "^4.
|
|
67
|
-
"@wordpress/primitives": "^4.
|
|
68
|
-
"@wordpress/private-apis": "^1.
|
|
69
|
-
"@wordpress/theme": "^0.
|
|
70
|
-
"@wordpress/ui": "^0.
|
|
71
|
-
"@wordpress/url": "^4.
|
|
72
|
-
"@wordpress/warning": "^3.
|
|
55
|
+
"@ariakit/react": "^0.4.21",
|
|
56
|
+
"@wordpress/base-styles": "^6.16.0",
|
|
57
|
+
"@wordpress/components": "^32.2.0",
|
|
58
|
+
"@wordpress/compose": "^7.40.0",
|
|
59
|
+
"@wordpress/data": "^10.40.0",
|
|
60
|
+
"@wordpress/date": "^5.40.0",
|
|
61
|
+
"@wordpress/deprecated": "^4.40.0",
|
|
62
|
+
"@wordpress/dom": "^4.40.0",
|
|
63
|
+
"@wordpress/element": "^6.40.0",
|
|
64
|
+
"@wordpress/i18n": "^6.13.0",
|
|
65
|
+
"@wordpress/icons": "^11.7.0",
|
|
66
|
+
"@wordpress/keycodes": "^4.40.0",
|
|
67
|
+
"@wordpress/primitives": "^4.40.0",
|
|
68
|
+
"@wordpress/private-apis": "^1.40.0",
|
|
69
|
+
"@wordpress/theme": "^0.7.0",
|
|
70
|
+
"@wordpress/ui": "^0.7.0",
|
|
71
|
+
"@wordpress/url": "^4.40.0",
|
|
72
|
+
"@wordpress/warning": "^3.40.0",
|
|
73
73
|
"clsx": "^2.1.1",
|
|
74
74
|
"colord": "^2.7.0",
|
|
75
75
|
"date-fns": "^4.1.0",
|
|
@@ -78,8 +78,9 @@
|
|
|
78
78
|
"remove-accents": "^0.5.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
+
"@storybook/addon-docs": "^10.1.11",
|
|
81
82
|
"@storybook/react-vite": "^10.1.11",
|
|
82
|
-
"@testing-library/jest-dom": "^6.
|
|
83
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
83
84
|
"@types/jest": "^29.5.14",
|
|
84
85
|
"esbuild": "^0.27.2",
|
|
85
86
|
"storybook": "^10.1.11"
|
|
@@ -94,5 +95,5 @@
|
|
|
94
95
|
"scripts": {
|
|
95
96
|
"build:wp": "node build.cjs"
|
|
96
97
|
},
|
|
97
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "376124aa10dbc2cc0c81c964ec00b99fcfee5382"
|
|
98
99
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { DataFormControlProps } from '../../types';
|
|
5
|
+
import useElements from '../../hooks/use-elements';
|
|
6
|
+
import Combobox from './combobox';
|
|
7
|
+
import Select from './select';
|
|
8
|
+
|
|
9
|
+
const ELEMENTS_THRESHOLD = 10;
|
|
10
|
+
|
|
11
|
+
export default function AdaptiveSelect< Item >(
|
|
12
|
+
props: DataFormControlProps< Item >
|
|
13
|
+
) {
|
|
14
|
+
const { field } = props;
|
|
15
|
+
const { elements } = useElements( {
|
|
16
|
+
elements: field.elements,
|
|
17
|
+
getElements: field.getElements,
|
|
18
|
+
} );
|
|
19
|
+
if ( elements.length >= ELEMENTS_THRESHOLD ) {
|
|
20
|
+
return <Combobox { ...props } />;
|
|
21
|
+
}
|
|
22
|
+
return <Select { ...props } />;
|
|
23
|
+
}
|
|
@@ -19,6 +19,7 @@ export default function ArrayControl< Item >( {
|
|
|
19
19
|
field,
|
|
20
20
|
onChange,
|
|
21
21
|
hideLabelFromVision,
|
|
22
|
+
markWhenOptional,
|
|
22
23
|
validity,
|
|
23
24
|
}: DataFormControlProps< Item > ) {
|
|
24
25
|
const { label, placeholder, getValue, setValue, isValid } = field;
|
|
@@ -65,6 +66,7 @@ export default function ArrayControl< Item >( {
|
|
|
65
66
|
return (
|
|
66
67
|
<ValidatedFormTokenField
|
|
67
68
|
required={ !! isValid?.required }
|
|
69
|
+
markWhenOptional={ markWhenOptional }
|
|
68
70
|
customValidity={ getCustomValidity( isValid, validity ) }
|
|
69
71
|
label={ hideLabelFromVision ? undefined : label }
|
|
70
72
|
value={ arrayValueAsElements }
|
|
@@ -18,6 +18,7 @@ export default function Checkbox< Item >( {
|
|
|
18
18
|
onChange,
|
|
19
19
|
data,
|
|
20
20
|
hideLabelFromVision,
|
|
21
|
+
markWhenOptional,
|
|
21
22
|
validity,
|
|
22
23
|
}: DataFormControlProps< Item > ) {
|
|
23
24
|
const { getValue, setValue, label, description, isValid } = field;
|
|
@@ -31,6 +32,7 @@ export default function Checkbox< Item >( {
|
|
|
31
32
|
return (
|
|
32
33
|
<ValidatedCheckboxControl
|
|
33
34
|
required={ !! field.isValid?.required }
|
|
35
|
+
markWhenOptional={ markWhenOptional }
|
|
34
36
|
customValidity={ getCustomValidity( isValid, validity ) }
|
|
35
37
|
hidden={ hideLabelFromVision }
|
|
36
38
|
label={ label }
|
|
@@ -7,11 +7,16 @@ import { colord } from 'colord';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
|
+
Button,
|
|
11
|
+
ColorIndicator,
|
|
12
|
+
ColorPicker,
|
|
10
13
|
Dropdown,
|
|
11
14
|
privateApis,
|
|
12
15
|
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
|
|
16
|
+
__experimentalDropdownContentWrapper as DropdownContentWrapper,
|
|
13
17
|
} from '@wordpress/components';
|
|
14
18
|
import { useCallback } from '@wordpress/element';
|
|
19
|
+
import { __ } from '@wordpress/i18n';
|
|
15
20
|
|
|
16
21
|
/**
|
|
17
22
|
* Internal dependencies
|
|
@@ -20,51 +25,37 @@ import type { DataFormControlProps } from '../../types';
|
|
|
20
25
|
import { unlock } from '../../lock-unlock';
|
|
21
26
|
import getCustomValidity from './utils/get-custom-validity';
|
|
22
27
|
|
|
23
|
-
const { ValidatedInputControl
|
|
28
|
+
const { ValidatedInputControl } = unlock( privateApis );
|
|
24
29
|
|
|
25
|
-
const
|
|
30
|
+
const ColorPickerDropdown = ( {
|
|
26
31
|
color,
|
|
27
32
|
onColorChange,
|
|
28
33
|
}: {
|
|
29
34
|
color: string;
|
|
30
|
-
onColorChange: (
|
|
35
|
+
onColorChange: ( newColor: string ) => void;
|
|
31
36
|
} ) => {
|
|
32
37
|
const validColor = color && colord( color ).isValid() ? color : '#ffffff';
|
|
33
38
|
|
|
34
39
|
return (
|
|
35
40
|
<Dropdown
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
backgroundColor: validColor,
|
|
46
|
-
border: '1px solid #ddd',
|
|
47
|
-
cursor: 'pointer',
|
|
48
|
-
outline: isOpen ? '2px solid #007cba' : 'none',
|
|
49
|
-
outlineOffset: '2px',
|
|
50
|
-
display: 'flex',
|
|
51
|
-
alignItems: 'center',
|
|
52
|
-
justifyContent: 'center',
|
|
53
|
-
padding: 0,
|
|
54
|
-
margin: 0,
|
|
55
|
-
} }
|
|
56
|
-
aria-label="Open color picker"
|
|
57
|
-
/>
|
|
58
|
-
</InputControlPrefixWrapper>
|
|
41
|
+
className="dataviews-controls__color-picker-dropdown"
|
|
42
|
+
popoverProps={ { resize: false } }
|
|
43
|
+
renderToggle={ ( { onToggle } ) => (
|
|
44
|
+
<Button
|
|
45
|
+
onClick={ onToggle }
|
|
46
|
+
aria-label={ __( 'Open color picker' ) }
|
|
47
|
+
size="small"
|
|
48
|
+
icon={ () => <ColorIndicator colorValue={ validColor } /> }
|
|
49
|
+
/>
|
|
59
50
|
) }
|
|
60
51
|
renderContent={ () => (
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
color={
|
|
52
|
+
<DropdownContentWrapper paddingSize="none">
|
|
53
|
+
<ColorPicker
|
|
54
|
+
color={ validColor }
|
|
64
55
|
onChange={ onColorChange }
|
|
65
56
|
enableAlpha
|
|
66
57
|
/>
|
|
67
|
-
</
|
|
58
|
+
</DropdownContentWrapper>
|
|
68
59
|
) }
|
|
69
60
|
/>
|
|
70
61
|
);
|
|
@@ -75,14 +66,15 @@ export default function Color< Item >( {
|
|
|
75
66
|
field,
|
|
76
67
|
onChange,
|
|
77
68
|
hideLabelFromVision,
|
|
69
|
+
markWhenOptional,
|
|
78
70
|
validity,
|
|
79
71
|
}: DataFormControlProps< Item > ) {
|
|
80
72
|
const { label, placeholder, description, setValue, isValid } = field;
|
|
81
73
|
const value = field.getValue( { item: data } ) || '';
|
|
82
74
|
|
|
83
75
|
const handleColorChange = useCallback(
|
|
84
|
-
(
|
|
85
|
-
onChange( setValue( { item: data, value:
|
|
76
|
+
( newColor: string ) => {
|
|
77
|
+
onChange( setValue( { item: data, value: newColor } ) );
|
|
86
78
|
},
|
|
87
79
|
[ data, onChange, setValue ]
|
|
88
80
|
);
|
|
@@ -97,6 +89,7 @@ export default function Color< Item >( {
|
|
|
97
89
|
return (
|
|
98
90
|
<ValidatedInputControl
|
|
99
91
|
required={ !! field.isValid?.required }
|
|
92
|
+
markWhenOptional={ markWhenOptional }
|
|
100
93
|
customValidity={ getCustomValidity( isValid, validity ) }
|
|
101
94
|
label={ label }
|
|
102
95
|
placeholder={ placeholder }
|
|
@@ -106,10 +99,12 @@ export default function Color< Item >( {
|
|
|
106
99
|
hideLabelFromVision={ hideLabelFromVision }
|
|
107
100
|
type="text"
|
|
108
101
|
prefix={
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
<InputControlPrefixWrapper variant="control">
|
|
103
|
+
<ColorPickerDropdown
|
|
104
|
+
color={ value }
|
|
105
|
+
onColorChange={ handleColorChange }
|
|
106
|
+
/>
|
|
107
|
+
</InputControlPrefixWrapper>
|
|
113
108
|
}
|
|
114
109
|
/>
|
|
115
110
|
);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { privateApis, Spinner } from '@wordpress/components';
|
|
5
|
+
import { useCallback } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import type { DataFormControlProps } from '../../types';
|
|
11
|
+
import useElements from '../../hooks/use-elements';
|
|
12
|
+
import { unlock } from '../../lock-unlock';
|
|
13
|
+
import getCustomValidity from './utils/get-custom-validity';
|
|
14
|
+
|
|
15
|
+
const { ValidatedComboboxControl } = unlock( privateApis );
|
|
16
|
+
|
|
17
|
+
export default function Combobox< Item >( {
|
|
18
|
+
data,
|
|
19
|
+
field,
|
|
20
|
+
onChange,
|
|
21
|
+
hideLabelFromVision,
|
|
22
|
+
validity,
|
|
23
|
+
}: DataFormControlProps< Item > ) {
|
|
24
|
+
const { label, description, placeholder, getValue, setValue, isValid } =
|
|
25
|
+
field;
|
|
26
|
+
const value = getValue( { item: data } ) ?? '';
|
|
27
|
+
|
|
28
|
+
const onChangeControl = useCallback(
|
|
29
|
+
( newValue: string | null ) =>
|
|
30
|
+
onChange( setValue( { item: data, value: newValue ?? '' } ) ),
|
|
31
|
+
[ data, onChange, setValue ]
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const { elements, isLoading } = useElements( {
|
|
35
|
+
elements: field.elements,
|
|
36
|
+
getElements: field.getElements,
|
|
37
|
+
} );
|
|
38
|
+
|
|
39
|
+
if ( isLoading ) {
|
|
40
|
+
return <Spinner />;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<ValidatedComboboxControl
|
|
45
|
+
required={ !! field.isValid?.required }
|
|
46
|
+
customValidity={ getCustomValidity( isValid, validity ) }
|
|
47
|
+
label={ label }
|
|
48
|
+
value={ value }
|
|
49
|
+
help={ description }
|
|
50
|
+
placeholder={ placeholder }
|
|
51
|
+
options={ elements }
|
|
52
|
+
onChange={ onChangeControl }
|
|
53
|
+
hideLabelFromVision={ hideLabelFromVision }
|
|
54
|
+
allowReset
|
|
55
|
+
expandOnFocus
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -161,8 +161,8 @@ function ValidatedDateControl< Item >( {
|
|
|
161
161
|
field: NormalizedField< Item >;
|
|
162
162
|
validity?: FieldValidity;
|
|
163
163
|
inputRefs:
|
|
164
|
-
| React.RefObject< HTMLInputElement >
|
|
165
|
-
| React.RefObject< HTMLInputElement >[];
|
|
164
|
+
| React.RefObject< HTMLInputElement | null >
|
|
165
|
+
| React.RefObject< HTMLInputElement | null >[];
|
|
166
166
|
isTouched: boolean;
|
|
167
167
|
setIsTouched: ( touched: boolean ) => void;
|
|
168
168
|
children: React.ReactNode;
|
|
@@ -191,18 +191,53 @@ function ValidatedDateControl< Item >( {
|
|
|
191
191
|
setCustomValidity( undefined );
|
|
192
192
|
}, [ inputRefs ] );
|
|
193
193
|
|
|
194
|
+
// Sync React-level validation to native inputs.
|
|
194
195
|
useEffect( () => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
196
|
+
const refs = Array.isArray( inputRefs ) ? inputRefs : [ inputRefs ];
|
|
197
|
+
const result = validity
|
|
198
|
+
? getCustomValidity( isValid, validity )
|
|
199
|
+
: undefined;
|
|
200
|
+
for ( const ref of refs ) {
|
|
201
|
+
const input = ref.current;
|
|
202
|
+
if ( input ) {
|
|
203
|
+
input.setCustomValidity(
|
|
204
|
+
result?.type === 'invalid' && result.message
|
|
205
|
+
? result.message
|
|
206
|
+
: ''
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}, [ inputRefs, isValid, validity ] );
|
|
211
|
+
|
|
212
|
+
// Listen for 'invalid' events (e.g., from reportValidity() on card re-expand).
|
|
213
|
+
useEffect( () => {
|
|
214
|
+
const refs = Array.isArray( inputRefs ) ? inputRefs : [ inputRefs ];
|
|
215
|
+
const handleInvalid = ( event: Event ) => {
|
|
216
|
+
event.preventDefault();
|
|
217
|
+
setIsTouched( true );
|
|
218
|
+
};
|
|
219
|
+
for ( const ref of refs ) {
|
|
220
|
+
ref.current?.addEventListener( 'invalid', handleInvalid );
|
|
221
|
+
}
|
|
222
|
+
return () => {
|
|
223
|
+
for ( const ref of refs ) {
|
|
224
|
+
ref.current?.removeEventListener( 'invalid', handleInvalid );
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}, [ inputRefs, setIsTouched ] );
|
|
228
|
+
|
|
229
|
+
useEffect( () => {
|
|
230
|
+
if ( ! isTouched ) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const result = validity
|
|
234
|
+
? getCustomValidity( isValid, validity )
|
|
235
|
+
: undefined;
|
|
236
|
+
if ( result ) {
|
|
237
|
+
setCustomValidity( result );
|
|
238
|
+
} else {
|
|
239
|
+
validateRefs();
|
|
204
240
|
}
|
|
205
|
-
return undefined;
|
|
206
241
|
}, [ isTouched, isValid, validity, validateRefs ] );
|
|
207
242
|
|
|
208
243
|
const onBlur = ( event: React.FocusEvent< HTMLDivElement > ) => {
|
|
@@ -230,9 +265,6 @@ function ValidatedDateControl< Item >( {
|
|
|
230
265
|
'components-validated-control__indicator',
|
|
231
266
|
customValidity.type === 'invalid'
|
|
232
267
|
? 'is-invalid'
|
|
233
|
-
: undefined,
|
|
234
|
-
customValidity.type === 'valid'
|
|
235
|
-
? 'is-valid'
|
|
236
268
|
: undefined
|
|
237
269
|
) }
|
|
238
270
|
>
|
|
@@ -255,6 +287,7 @@ function CalendarDateControl< Item >( {
|
|
|
255
287
|
field,
|
|
256
288
|
onChange,
|
|
257
289
|
hideLabelFromVision,
|
|
290
|
+
markWhenOptional,
|
|
258
291
|
validity,
|
|
259
292
|
}: DataFormControlProps< Item > ) {
|
|
260
293
|
const {
|
|
@@ -333,9 +366,12 @@ function CalendarDateControl< Item >( {
|
|
|
333
366
|
timezone: { string: timezoneString },
|
|
334
367
|
} = getSettings();
|
|
335
368
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
369
|
+
let displayLabel = label;
|
|
370
|
+
if ( isValid?.required && ! markWhenOptional ) {
|
|
371
|
+
displayLabel = `${ label } (${ __( 'Required' ) })`;
|
|
372
|
+
} else if ( ! isValid?.required && markWhenOptional ) {
|
|
373
|
+
displayLabel = `${ label } (${ __( 'Optional' ) })`;
|
|
374
|
+
}
|
|
339
375
|
|
|
340
376
|
return (
|
|
341
377
|
<ValidatedDateControl
|
|
@@ -351,11 +387,11 @@ function CalendarDateControl< Item >( {
|
|
|
351
387
|
label={ displayLabel }
|
|
352
388
|
hideLabelFromVision={ hideLabelFromVision }
|
|
353
389
|
>
|
|
354
|
-
<Stack direction="column" gap="
|
|
390
|
+
<Stack direction="column" gap="lg">
|
|
355
391
|
{ /* Preset buttons */ }
|
|
356
392
|
<Stack
|
|
357
393
|
direction="row"
|
|
358
|
-
gap="
|
|
394
|
+
gap="sm"
|
|
359
395
|
wrap="wrap"
|
|
360
396
|
justify="flex-start"
|
|
361
397
|
>
|
|
@@ -423,6 +459,7 @@ function CalendarDateRangeControl< Item >( {
|
|
|
423
459
|
field,
|
|
424
460
|
onChange,
|
|
425
461
|
hideLabelFromVision,
|
|
462
|
+
markWhenOptional,
|
|
426
463
|
validity,
|
|
427
464
|
}: DataFormControlProps< Item > ) {
|
|
428
465
|
const { id, label, getValue, setValue, format: fieldFormat } = field;
|
|
@@ -541,9 +578,12 @@ function CalendarDateRangeControl< Item >( {
|
|
|
541
578
|
|
|
542
579
|
const { timezone } = getSettings();
|
|
543
580
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
581
|
+
let displayLabel = label;
|
|
582
|
+
if ( field.isValid?.required && ! markWhenOptional ) {
|
|
583
|
+
displayLabel = `${ label } (${ __( 'Required' ) })`;
|
|
584
|
+
} else if ( ! field.isValid?.required && markWhenOptional ) {
|
|
585
|
+
displayLabel = `${ label } (${ __( 'Optional' ) })`;
|
|
586
|
+
}
|
|
547
587
|
|
|
548
588
|
return (
|
|
549
589
|
<ValidatedDateControl
|
|
@@ -559,11 +599,11 @@ function CalendarDateRangeControl< Item >( {
|
|
|
559
599
|
label={ displayLabel }
|
|
560
600
|
hideLabelFromVision={ hideLabelFromVision }
|
|
561
601
|
>
|
|
562
|
-
<Stack direction="column" gap="
|
|
602
|
+
<Stack direction="column" gap="lg">
|
|
563
603
|
{ /* Preset buttons */ }
|
|
564
604
|
<Stack
|
|
565
605
|
direction="row"
|
|
566
|
-
gap="
|
|
606
|
+
gap="sm"
|
|
567
607
|
wrap="wrap"
|
|
568
608
|
justify="flex-start"
|
|
569
609
|
>
|
|
@@ -599,7 +639,7 @@ function CalendarDateRangeControl< Item >( {
|
|
|
599
639
|
{ /* Manual date range inputs */ }
|
|
600
640
|
<Stack
|
|
601
641
|
direction="row"
|
|
602
|
-
gap="
|
|
642
|
+
gap="sm"
|
|
603
643
|
justify="space-between"
|
|
604
644
|
className="dataviews-controls__date-range-inputs"
|
|
605
645
|
>
|
|
@@ -649,6 +689,7 @@ export default function DateControl< Item >( {
|
|
|
649
689
|
field,
|
|
650
690
|
onChange,
|
|
651
691
|
hideLabelFromVision,
|
|
692
|
+
markWhenOptional,
|
|
652
693
|
operator,
|
|
653
694
|
validity,
|
|
654
695
|
}: DataFormControlProps< Item > ) {
|
|
@@ -672,6 +713,7 @@ export default function DateControl< Item >( {
|
|
|
672
713
|
field={ field }
|
|
673
714
|
onChange={ onChange }
|
|
674
715
|
hideLabelFromVision={ hideLabelFromVision }
|
|
716
|
+
markWhenOptional={ markWhenOptional }
|
|
675
717
|
validity={ validity }
|
|
676
718
|
/>
|
|
677
719
|
);
|
|
@@ -683,6 +725,7 @@ export default function DateControl< Item >( {
|
|
|
683
725
|
field={ field }
|
|
684
726
|
onChange={ onChange }
|
|
685
727
|
hideLabelFromVision={ hideLabelFromVision }
|
|
728
|
+
markWhenOptional={ markWhenOptional }
|
|
686
729
|
validity={ validity }
|
|
687
730
|
/>
|
|
688
731
|
);
|
|
@@ -43,6 +43,7 @@ function CalendarDateTimeControl< Item >( {
|
|
|
43
43
|
field,
|
|
44
44
|
onChange,
|
|
45
45
|
hideLabelFromVision,
|
|
46
|
+
markWhenOptional,
|
|
46
47
|
validity,
|
|
47
48
|
}: DataFormControlProps< Item > ) {
|
|
48
49
|
const { id, label, description, setValue, getValue, isValid } = field;
|
|
@@ -55,7 +56,8 @@ function CalendarDateTimeControl< Item >( {
|
|
|
55
56
|
} );
|
|
56
57
|
|
|
57
58
|
const inputControlRef = useRef< HTMLInputElement >( null );
|
|
58
|
-
const validationTimeoutRef =
|
|
59
|
+
const validationTimeoutRef =
|
|
60
|
+
useRef< ReturnType< typeof setTimeout > >( undefined );
|
|
59
61
|
const previousFocusRef = useRef< Element | null >( null );
|
|
60
62
|
|
|
61
63
|
const onChangeCallback = useCallback(
|
|
@@ -155,10 +157,16 @@ function CalendarDateTimeControl< Item >( {
|
|
|
155
157
|
timezone: { string: timezoneString },
|
|
156
158
|
} = getSettings();
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
let displayLabel = label;
|
|
161
|
+
if ( isValid?.required && ! markWhenOptional && ! hideLabelFromVision ) {
|
|
162
|
+
displayLabel = `${ label } (${ __( 'Required' ) })`;
|
|
163
|
+
} else if (
|
|
164
|
+
! isValid?.required &&
|
|
165
|
+
markWhenOptional &&
|
|
166
|
+
! hideLabelFromVision
|
|
167
|
+
) {
|
|
168
|
+
displayLabel = `${ label } (${ __( 'Optional' ) })`;
|
|
169
|
+
}
|
|
162
170
|
|
|
163
171
|
return (
|
|
164
172
|
<BaseControl
|
|
@@ -167,7 +175,7 @@ function CalendarDateTimeControl< Item >( {
|
|
|
167
175
|
help={ description }
|
|
168
176
|
hideLabelFromVision={ hideLabelFromVision }
|
|
169
177
|
>
|
|
170
|
-
<Stack direction="column" gap="
|
|
178
|
+
<Stack direction="column" gap="lg">
|
|
171
179
|
{ /* Calendar widget */ }
|
|
172
180
|
<DateCalendar
|
|
173
181
|
style={ { width: '100%' } }
|
|
@@ -208,6 +216,7 @@ export default function DateTime< Item >( {
|
|
|
208
216
|
field,
|
|
209
217
|
onChange,
|
|
210
218
|
hideLabelFromVision,
|
|
219
|
+
markWhenOptional,
|
|
211
220
|
operator,
|
|
212
221
|
validity,
|
|
213
222
|
}: DataFormControlProps< Item > ) {
|
|
@@ -230,6 +239,7 @@ export default function DateTime< Item >( {
|
|
|
230
239
|
field={ field }
|
|
231
240
|
onChange={ onChange }
|
|
232
241
|
hideLabelFromVision={ hideLabelFromVision }
|
|
242
|
+
markWhenOptional={ markWhenOptional }
|
|
233
243
|
validity={ validity }
|
|
234
244
|
/>
|
|
235
245
|
);
|
|
@@ -18,6 +18,7 @@ export default function Email< Item >( {
|
|
|
18
18
|
field,
|
|
19
19
|
onChange,
|
|
20
20
|
hideLabelFromVision,
|
|
21
|
+
markWhenOptional,
|
|
21
22
|
validity,
|
|
22
23
|
}: DataFormControlProps< Item > ) {
|
|
23
24
|
return (
|
|
@@ -27,6 +28,7 @@ export default function Email< Item >( {
|
|
|
27
28
|
field,
|
|
28
29
|
onChange,
|
|
29
30
|
hideLabelFromVision,
|
|
31
|
+
markWhenOptional,
|
|
30
32
|
validity,
|
|
31
33
|
type: 'email',
|
|
32
34
|
prefix: (
|
|
@@ -8,8 +8,10 @@ import type { ComponentType } from 'react';
|
|
|
8
8
|
*/
|
|
9
9
|
import type { DataFormControlProps, Field, EditConfig } from '../../types';
|
|
10
10
|
import checkbox from './checkbox';
|
|
11
|
+
import combobox from './combobox';
|
|
11
12
|
import datetime from './datetime';
|
|
12
13
|
import date from './date';
|
|
14
|
+
import adaptiveSelect from './adaptive-select';
|
|
13
15
|
import email from './email';
|
|
14
16
|
import telephone from './telephone';
|
|
15
17
|
import url from './url';
|
|
@@ -31,9 +33,11 @@ interface FormControls {
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
const FORM_CONTROLS: FormControls = {
|
|
36
|
+
adaptiveSelect,
|
|
34
37
|
array,
|
|
35
38
|
checkbox,
|
|
36
39
|
color,
|
|
40
|
+
combobox,
|
|
37
41
|
datetime,
|
|
38
42
|
date,
|
|
39
43
|
email,
|
|
@@ -87,7 +91,7 @@ export function getControl< Item >(
|
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
if ( hasElements( field ) && field.type !== 'array' ) {
|
|
90
|
-
return getControlByType( '
|
|
94
|
+
return getControlByType( 'adaptiveSelect' );
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
if ( fallback === null ) {
|
|
@@ -19,6 +19,7 @@ export default function Password< Item >( {
|
|
|
19
19
|
field,
|
|
20
20
|
onChange,
|
|
21
21
|
hideLabelFromVision,
|
|
22
|
+
markWhenOptional,
|
|
22
23
|
validity,
|
|
23
24
|
}: DataFormControlProps< Item > ) {
|
|
24
25
|
const [ isVisible, setIsVisible ] = useState( false );
|
|
@@ -34,6 +35,7 @@ export default function Password< Item >( {
|
|
|
34
35
|
field,
|
|
35
36
|
onChange,
|
|
36
37
|
hideLabelFromVision,
|
|
38
|
+
markWhenOptional,
|
|
37
39
|
validity,
|
|
38
40
|
type: isVisible ? 'text' : 'password',
|
|
39
41
|
suffix: (
|
|
@@ -19,6 +19,7 @@ export default function Radio< Item >( {
|
|
|
19
19
|
field,
|
|
20
20
|
onChange,
|
|
21
21
|
hideLabelFromVision,
|
|
22
|
+
markWhenOptional,
|
|
22
23
|
validity,
|
|
23
24
|
}: DataFormControlProps< Item > ) {
|
|
24
25
|
const { label, description, getValue, setValue, isValid } = field;
|
|
@@ -41,6 +42,7 @@ export default function Radio< Item >( {
|
|
|
41
42
|
return (
|
|
42
43
|
<ValidatedRadioControl
|
|
43
44
|
required={ !! field.isValid?.required }
|
|
45
|
+
markWhenOptional={ markWhenOptional }
|
|
44
46
|
customValidity={ getCustomValidity( isValid, validity ) }
|
|
45
47
|
label={ label }
|
|
46
48
|
help={ description }
|
|
@@ -19,6 +19,7 @@ export default function Select< Item >( {
|
|
|
19
19
|
field,
|
|
20
20
|
onChange,
|
|
21
21
|
hideLabelFromVision,
|
|
22
|
+
markWhenOptional,
|
|
22
23
|
validity,
|
|
23
24
|
}: DataFormControlProps< Item > ) {
|
|
24
25
|
const { type, label, description, getValue, setValue, isValid } = field;
|
|
@@ -44,6 +45,7 @@ export default function Select< Item >( {
|
|
|
44
45
|
return (
|
|
45
46
|
<ValidatedSelectControl
|
|
46
47
|
required={ !! field.isValid?.required }
|
|
48
|
+
markWhenOptional={ markWhenOptional }
|
|
47
49
|
customValidity={ getCustomValidity( isValid, validity ) }
|
|
48
50
|
label={ label }
|
|
49
51
|
value={ value }
|