@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
|
@@ -6,14 +6,16 @@ import {
|
|
|
6
6
|
Button
|
|
7
7
|
} from "@wordpress/components";
|
|
8
8
|
import { __ } from "@wordpress/i18n";
|
|
9
|
-
import { useMemo } from "@wordpress/element";
|
|
9
|
+
import { useMemo, useRef, useState } from "@wordpress/element";
|
|
10
10
|
import { closeSmall } from "@wordpress/icons";
|
|
11
|
-
import {
|
|
11
|
+
import { __experimentalUseDialog as useDialog } from "@wordpress/compose";
|
|
12
12
|
import { Stack } from "@wordpress/ui";
|
|
13
13
|
import { DataFormLayout } from "../data-form-layout.mjs";
|
|
14
14
|
import { DEFAULT_LAYOUT } from "../normalize-form.mjs";
|
|
15
15
|
import SummaryButton from "./summary-button.mjs";
|
|
16
|
-
import
|
|
16
|
+
import useReportValidity from "../../../hooks/use-report-validity.mjs";
|
|
17
|
+
import useFieldFromFormField from "./utils/use-field-from-form-field.mjs";
|
|
18
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
19
|
function DropdownHeader({
|
|
18
20
|
title,
|
|
19
21
|
onClose
|
|
@@ -23,8 +25,8 @@ function DropdownHeader({
|
|
|
23
25
|
{
|
|
24
26
|
direction: "column",
|
|
25
27
|
className: "dataforms-layouts-panel__dropdown-header",
|
|
26
|
-
gap: "
|
|
27
|
-
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", gap: "
|
|
28
|
+
gap: "lg",
|
|
29
|
+
children: /* @__PURE__ */ jsxs(Stack, { direction: "row", gap: "sm", align: "center", children: [
|
|
28
30
|
title && /* @__PURE__ */ jsx(Heading, { level: 2, size: 13, children: title }),
|
|
29
31
|
/* @__PURE__ */ jsx(Spacer, { style: { flex: 1 } }),
|
|
30
32
|
onClose && /* @__PURE__ */ jsx(
|
|
@@ -40,18 +42,38 @@ function DropdownHeader({
|
|
|
40
42
|
}
|
|
41
43
|
);
|
|
42
44
|
}
|
|
45
|
+
function DropdownContentWithValidation({
|
|
46
|
+
touched,
|
|
47
|
+
children
|
|
48
|
+
}) {
|
|
49
|
+
const ref = useRef(null);
|
|
50
|
+
useReportValidity(ref, touched);
|
|
51
|
+
return /* @__PURE__ */ jsx("div", { ref, children });
|
|
52
|
+
}
|
|
43
53
|
function PanelDropdown({
|
|
44
54
|
data,
|
|
45
55
|
field,
|
|
46
56
|
onChange,
|
|
47
|
-
validity
|
|
48
|
-
labelPosition = "side",
|
|
49
|
-
summaryFields,
|
|
50
|
-
fieldDefinition,
|
|
51
|
-
popoverAnchor,
|
|
52
|
-
onOpen
|
|
57
|
+
validity
|
|
53
58
|
}) {
|
|
54
|
-
const
|
|
59
|
+
const [touched, setTouched] = useState(false);
|
|
60
|
+
const [popoverAnchor, setPopoverAnchor] = useState(
|
|
61
|
+
null
|
|
62
|
+
);
|
|
63
|
+
const popoverProps = useMemo(
|
|
64
|
+
() => ({
|
|
65
|
+
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
66
|
+
// move around when the label changes.
|
|
67
|
+
anchor: popoverAnchor,
|
|
68
|
+
placement: "left-start",
|
|
69
|
+
offset: 36,
|
|
70
|
+
shift: true
|
|
71
|
+
}),
|
|
72
|
+
[popoverAnchor]
|
|
73
|
+
);
|
|
74
|
+
const [dialogRef, dialogProps] = useDialog({
|
|
75
|
+
focusOnMount: "firstInputElement"
|
|
76
|
+
});
|
|
55
77
|
const form = useMemo(
|
|
56
78
|
() => ({
|
|
57
79
|
layout: DEFAULT_LAYOUT,
|
|
@@ -71,69 +93,72 @@ function PanelDropdown({
|
|
|
71
93
|
}
|
|
72
94
|
return { [field.id]: validity };
|
|
73
95
|
}, [validity, field]);
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
anchor: popoverAnchor,
|
|
79
|
-
placement: "left-start",
|
|
80
|
-
offset: 36,
|
|
81
|
-
shift: true
|
|
82
|
-
}),
|
|
83
|
-
[popoverAnchor]
|
|
84
|
-
);
|
|
85
|
-
const focusOnMountRef = useFocusOnMount("firstInputElement");
|
|
96
|
+
const { fieldDefinition, fieldLabel, summaryFields } = useFieldFromFormField(field);
|
|
97
|
+
if (!fieldDefinition) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
86
100
|
return /* @__PURE__ */ jsx(
|
|
87
|
-
|
|
101
|
+
"div",
|
|
88
102
|
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
size: "compact",
|
|
94
|
-
variant: "tertiary",
|
|
95
|
-
tooltipPosition: "middle left"
|
|
96
|
-
},
|
|
97
|
-
renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ jsx(
|
|
98
|
-
SummaryButton,
|
|
103
|
+
ref: setPopoverAnchor,
|
|
104
|
+
className: "dataforms-layouts-panel__field-dropdown-anchor",
|
|
105
|
+
children: /* @__PURE__ */ jsx(
|
|
106
|
+
Dropdown,
|
|
99
107
|
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (!isOpen && onOpen) {
|
|
107
|
-
onOpen();
|
|
108
|
+
contentClassName: "dataforms-layouts-panel__field-dropdown",
|
|
109
|
+
popoverProps,
|
|
110
|
+
focusOnMount: false,
|
|
111
|
+
onToggle: (willOpen) => {
|
|
112
|
+
if (!willOpen) {
|
|
113
|
+
setTouched(true);
|
|
108
114
|
}
|
|
109
|
-
onToggle();
|
|
110
115
|
},
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ jsx(
|
|
117
|
+
SummaryButton,
|
|
118
|
+
{
|
|
119
|
+
data,
|
|
120
|
+
field,
|
|
121
|
+
fieldLabel,
|
|
122
|
+
summaryFields,
|
|
123
|
+
validity,
|
|
124
|
+
touched,
|
|
125
|
+
disabled: fieldDefinition.readOnly === true,
|
|
126
|
+
onClick: onToggle,
|
|
127
|
+
"aria-expanded": isOpen
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
renderContent: ({ onClose }) => /* @__PURE__ */ jsx(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ jsxs("div", { ref: dialogRef, ...dialogProps, children: [
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
DropdownHeader,
|
|
133
|
+
{
|
|
134
|
+
title: fieldLabel,
|
|
135
|
+
onClose
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
/* @__PURE__ */ jsx(
|
|
139
|
+
DataFormLayout,
|
|
125
140
|
{
|
|
126
141
|
data,
|
|
127
|
-
|
|
142
|
+
form,
|
|
128
143
|
onChange,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
144
|
+
validity: formValidity,
|
|
145
|
+
children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ jsx(
|
|
146
|
+
FieldLayout,
|
|
147
|
+
{
|
|
148
|
+
data,
|
|
149
|
+
field: childField,
|
|
150
|
+
onChange,
|
|
151
|
+
hideLabelFromVision: (form?.fields ?? []).length < 2,
|
|
152
|
+
markWhenOptional,
|
|
153
|
+
validity: childFieldValidity
|
|
154
|
+
},
|
|
155
|
+
childField.id
|
|
156
|
+
)
|
|
157
|
+
}
|
|
133
158
|
)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
159
|
+
] }) })
|
|
160
|
+
}
|
|
161
|
+
)
|
|
137
162
|
}
|
|
138
163
|
);
|
|
139
164
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/dataform-layouts/panel/dropdown.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tDropdown,\n\tButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\nimport {
|
|
5
|
-
"mappings": ";AAGA;AAAA,EACC,yBAAyB;AAAA,EACzB,wBAAwB;AAAA,EACxB;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AACnB,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tDropdown,\n\tButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useRef, useState } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tFieldLayoutProps,\n\tNormalizedForm,\n\tFormValidity,\n} from '../../../types';\nimport { DataFormLayout } from '../data-form-layout';\nimport { DEFAULT_LAYOUT } from '../normalize-form';\nimport SummaryButton from './summary-button';\nimport useReportValidity from '../../../hooks/use-report-validity';\nimport useFieldFromFormField from './utils/use-field-from-form-field';\n\nfunction DropdownHeader( {\n\ttitle,\n\tonClose,\n}: {\n\ttitle?: string;\n\tonClose: () => void;\n} ) {\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tclassName=\"dataforms-layouts-panel__dropdown-header\"\n\t\t\tgap=\"lg\"\n\t\t>\n\t\t\t<Stack direction=\"row\" gap=\"sm\" align=\"center\">\n\t\t\t\t{ title && (\n\t\t\t\t\t<Heading level={ 2 } size={ 13 }>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Heading>\n\t\t\t\t) }\n\t\t\t\t<Spacer style={ { flex: 1 } } />\n\t\t\t\t{ onClose && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n}\n\nfunction DropdownContentWithValidation( {\n\ttouched,\n\tchildren,\n}: {\n\ttouched: boolean;\n\tchildren: React.ReactNode;\n} ) {\n\tconst ref = useRef< HTMLDivElement >( null );\n\tuseReportValidity( ref, touched );\n\treturn <div ref={ ref }>{ children }</div>;\n}\n\nfunction PanelDropdown< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\tvalidity,\n}: FieldLayoutProps< Item > ) {\n\tconst [ touched, setTouched ] = useState( false );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(\n\t\tnull\n\t);\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\tconst [ dialogRef, dialogProps ] = useDialog( {\n\t\tfocusOnMount: 'firstInputElement',\n\t} );\n\n\tconst form: NormalizedForm = useMemo(\n\t\t() => ( {\n\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\tfields: !! field.children\n\t\t\t\t? field.children\n\t\t\t\t: // If not explicit children return the field id itself.\n\t\t\t\t [ { id: field.id, layout: DEFAULT_LAYOUT } ],\n\t\t} ),\n\t\t[ field ]\n\t);\n\tconst formValidity = useMemo( (): FormValidity => {\n\t\tif ( validity === undefined ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif ( !! field.children ) {\n\t\t\treturn validity?.children;\n\t\t}\n\n\t\treturn { [ field.id ]: validity };\n\t}, [ validity, field ] );\n\n\tconst { fieldDefinition, fieldLabel, summaryFields } =\n\t\tuseFieldFromFormField( field );\n\tif ( ! fieldDefinition ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={ setPopoverAnchor }\n\t\t\tclassName=\"dataforms-layouts-panel__field-dropdown-anchor\"\n\t\t>\n\t\t\t<Dropdown\n\t\t\t\tcontentClassName=\"dataforms-layouts-panel__field-dropdown\"\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount={ false }\n\t\t\t\tonToggle={ ( willOpen ) => {\n\t\t\t\t\tif ( ! willOpen ) {\n\t\t\t\t\t\tsetTouched( true );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<SummaryButton\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\tfieldLabel={ fieldLabel }\n\t\t\t\t\t\tsummaryFields={ summaryFields }\n\t\t\t\t\t\tvalidity={ validity }\n\t\t\t\t\t\ttouched={ touched }\n\t\t\t\t\t\tdisabled={ fieldDefinition.readOnly === true }\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<DropdownContentWithValidation touched={ touched }>\n\t\t\t\t\t\t<div ref={ dialogRef } { ...dialogProps }>\n\t\t\t\t\t\t\t<DropdownHeader\n\t\t\t\t\t\t\t\ttitle={ fieldLabel }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<DataFormLayout\n\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\tform={ form }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tvalidity={ formValidity }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ (\n\t\t\t\t\t\t\t\t\tFieldLayout,\n\t\t\t\t\t\t\t\t\tchildField,\n\t\t\t\t\t\t\t\t\tchildFieldValidity,\n\t\t\t\t\t\t\t\t\tmarkWhenOptional\n\t\t\t\t\t\t\t\t) => (\n\t\t\t\t\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\t\t\t\t\tkey={ childField.id }\n\t\t\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\t\t\tfield={ childField }\n\t\t\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\t\t\thideLabelFromVision={\n\t\t\t\t\t\t\t\t\t\t\t( form?.fields ?? [] ).length < 2\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t\t\t\t\t\t\t\tvalidity={ childFieldValidity }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</DataFormLayout>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</DropdownContentWithValidation>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default PanelDropdown;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,194 +1,32 @@
|
|
|
1
1
|
// packages/dataviews/src/components/dataform-layouts/panel/index.tsx
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import { Icon, Tooltip } from "@wordpress/components";
|
|
4
|
-
import { useState, useContext } from "@wordpress/element";
|
|
5
|
-
import { error as errorIcon } from "@wordpress/icons";
|
|
6
|
-
import { Stack } from "@wordpress/ui";
|
|
7
|
-
import DataFormContext from "../../dataform-context/index.mjs";
|
|
8
|
-
import PanelDropdown from "./dropdown.mjs";
|
|
9
2
|
import PanelModal from "./modal.mjs";
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
function getFirstValidationError(validity) {
|
|
13
|
-
if (!validity) {
|
|
14
|
-
return void 0;
|
|
15
|
-
}
|
|
16
|
-
const validityRules = Object.keys(validity).filter(
|
|
17
|
-
(key) => key !== "children"
|
|
18
|
-
);
|
|
19
|
-
for (const key of validityRules) {
|
|
20
|
-
const rule = validity[key];
|
|
21
|
-
if (rule === void 0) {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (rule.type === "invalid") {
|
|
25
|
-
if (rule.message) {
|
|
26
|
-
return rule.message;
|
|
27
|
-
}
|
|
28
|
-
if (key === "required") {
|
|
29
|
-
return "A required field is empty";
|
|
30
|
-
}
|
|
31
|
-
return "Unidentified validation error";
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (validity.children) {
|
|
35
|
-
for (const childValidity of Object.values(validity.children)) {
|
|
36
|
-
const childError = getFirstValidationError(childValidity);
|
|
37
|
-
if (childError) {
|
|
38
|
-
return childError;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return void 0;
|
|
43
|
-
}
|
|
44
|
-
var getFieldDefinition = (field, fields) => {
|
|
45
|
-
const fieldDefinition = fields.find((_field) => _field.id === field.id);
|
|
46
|
-
if (!fieldDefinition) {
|
|
47
|
-
return fields.find((_field) => {
|
|
48
|
-
if (!!field.children) {
|
|
49
|
-
const simpleChildren = field.children.filter(
|
|
50
|
-
(child) => !child.children
|
|
51
|
-
);
|
|
52
|
-
if (simpleChildren.length === 0) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
return _field.id === simpleChildren[0].id;
|
|
56
|
-
}
|
|
57
|
-
return _field.id === field.id;
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return fieldDefinition;
|
|
61
|
-
};
|
|
62
|
-
var getFieldDefinitionAndSummaryFields = (layout, field, fields) => {
|
|
63
|
-
const summaryFields = getSummaryFields(layout.summary, fields);
|
|
64
|
-
const fieldDefinition = getFieldDefinition(field, fields);
|
|
65
|
-
if (summaryFields.length === 0) {
|
|
66
|
-
return {
|
|
67
|
-
summaryFields: fieldDefinition ? [fieldDefinition] : [],
|
|
68
|
-
fieldDefinition
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
summaryFields,
|
|
73
|
-
fieldDefinition
|
|
74
|
-
};
|
|
75
|
-
};
|
|
3
|
+
import PanelDropdown from "./dropdown.mjs";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
76
5
|
function FormPanelField({
|
|
77
6
|
data,
|
|
78
7
|
field,
|
|
79
8
|
onChange,
|
|
80
9
|
validity
|
|
81
10
|
}) {
|
|
82
|
-
const { fields } = useContext(DataFormContext);
|
|
83
11
|
const layout = field.layout;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
12
|
+
if (layout.openAs === "modal") {
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
PanelModal,
|
|
15
|
+
{
|
|
16
|
+
data,
|
|
17
|
+
field,
|
|
18
|
+
onChange,
|
|
19
|
+
validity
|
|
20
|
+
}
|
|
21
|
+
);
|
|
92
22
|
}
|
|
93
|
-
|
|
94
|
-
const errorMessage = getFirstValidationError(validity);
|
|
95
|
-
const showError = touched && !!errorMessage;
|
|
96
|
-
const labelClassName = clsx(
|
|
97
|
-
"dataforms-layouts-panel__field-label",
|
|
98
|
-
`dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
|
|
99
|
-
{ "has-error": showError }
|
|
100
|
-
);
|
|
101
|
-
const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
|
|
102
|
-
const labelContent = showError ? /* @__PURE__ */ jsx(Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ jsxs(
|
|
103
|
-
Stack,
|
|
104
|
-
{
|
|
105
|
-
direction: "row",
|
|
106
|
-
gap: "xs",
|
|
107
|
-
className: "dataforms-layouts-panel__field-label-error-content",
|
|
108
|
-
justify: "flex-start",
|
|
109
|
-
children: [
|
|
110
|
-
/* @__PURE__ */ jsx(Icon, { icon: errorIcon, size: 16 }),
|
|
111
|
-
/* @__PURE__ */ jsx(Fragment, { children: fieldLabel })
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
) }) : fieldLabel;
|
|
115
|
-
const renderedControl = layout.openAs === "modal" ? /* @__PURE__ */ jsx(
|
|
116
|
-
PanelModal,
|
|
117
|
-
{
|
|
118
|
-
data,
|
|
119
|
-
field,
|
|
120
|
-
onChange,
|
|
121
|
-
labelPosition,
|
|
122
|
-
summaryFields,
|
|
123
|
-
fieldDefinition,
|
|
124
|
-
onOpen: handleOpen
|
|
125
|
-
}
|
|
126
|
-
) : /* @__PURE__ */ jsx(
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
127
24
|
PanelDropdown,
|
|
128
25
|
{
|
|
129
26
|
data,
|
|
130
27
|
field,
|
|
131
28
|
onChange,
|
|
132
|
-
validity
|
|
133
|
-
labelPosition,
|
|
134
|
-
summaryFields,
|
|
135
|
-
fieldDefinition,
|
|
136
|
-
popoverAnchor,
|
|
137
|
-
onOpen: handleOpen
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
if (labelPosition === "top") {
|
|
141
|
-
return /* @__PURE__ */ jsxs(
|
|
142
|
-
Stack,
|
|
143
|
-
{
|
|
144
|
-
direction: "column",
|
|
145
|
-
className: "dataforms-layouts-panel__field",
|
|
146
|
-
children: [
|
|
147
|
-
/* @__PURE__ */ jsx(
|
|
148
|
-
"div",
|
|
149
|
-
{
|
|
150
|
-
className: labelClassName,
|
|
151
|
-
style: { paddingBottom: 0 },
|
|
152
|
-
children: labelContent
|
|
153
|
-
}
|
|
154
|
-
),
|
|
155
|
-
/* @__PURE__ */ jsx("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl })
|
|
156
|
-
]
|
|
157
|
-
}
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
if (labelPosition === "none") {
|
|
161
|
-
return /* @__PURE__ */ jsxs(
|
|
162
|
-
Stack,
|
|
163
|
-
{
|
|
164
|
-
direction: "row",
|
|
165
|
-
gap: "xs",
|
|
166
|
-
className: "dataforms-layouts-panel__field dataforms-layouts-panel__field--label-position-none",
|
|
167
|
-
children: [
|
|
168
|
-
showError && /* @__PURE__ */ jsx(Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ jsx(
|
|
169
|
-
Icon,
|
|
170
|
-
{
|
|
171
|
-
className: "dataforms-layouts-panel__field-label-error-content",
|
|
172
|
-
icon: errorIcon,
|
|
173
|
-
size: 16
|
|
174
|
-
}
|
|
175
|
-
) }),
|
|
176
|
-
/* @__PURE__ */ jsx("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl })
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
return /* @__PURE__ */ jsxs(
|
|
182
|
-
Stack,
|
|
183
|
-
{
|
|
184
|
-
direction: "row",
|
|
185
|
-
gap: "xs",
|
|
186
|
-
ref: setPopoverAnchor,
|
|
187
|
-
className: "dataforms-layouts-panel__field",
|
|
188
|
-
children: [
|
|
189
|
-
/* @__PURE__ */ jsx("div", { className: labelClassName, children: labelContent }),
|
|
190
|
-
/* @__PURE__ */ jsx("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl })
|
|
191
|
-
]
|
|
29
|
+
validity
|
|
192
30
|
}
|
|
193
31
|
);
|
|
194
32
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/dataform-layouts/panel/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n *
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { FieldLayoutProps, NormalizedPanelLayout } from '../../../types';\nimport PanelModal from './modal';\nimport PanelDropdown from './dropdown';\n\nexport default function FormPanelField< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\tvalidity,\n}: FieldLayoutProps< Item > ) {\n\tconst layout = field.layout as NormalizedPanelLayout;\n\n\tif ( layout.openAs === 'modal' ) {\n\t\treturn (\n\t\t\t<PanelModal\n\t\t\t\tdata={ data }\n\t\t\t\tfield={ field }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalidity={ validity }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<PanelDropdown\n\t\t\tdata={ data }\n\t\t\tfield={ field }\n\t\t\tonChange={ onChange }\n\t\t\tvalidity={ validity }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAIA,OAAO,gBAAgB;AACvB,OAAO,mBAAmB;AAYvB;AAVY,SAAR,eAAyC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA8B;AAC7B,QAAM,SAAS,MAAM;AAErB,MAAK,OAAO,WAAW,SAAU;AAChC,WACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,EAEF;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,21 +6,24 @@ import {
|
|
|
6
6
|
Modal
|
|
7
7
|
} from "@wordpress/components";
|
|
8
8
|
import { __ } from "@wordpress/i18n";
|
|
9
|
-
import { useContext,
|
|
10
|
-
import { useFocusOnMount } from "@wordpress/compose";
|
|
9
|
+
import { useContext, useMemo, useRef, useState } from "@wordpress/element";
|
|
10
|
+
import { useFocusOnMount, useMergeRefs } from "@wordpress/compose";
|
|
11
11
|
import { Stack } from "@wordpress/ui";
|
|
12
12
|
import { DataFormLayout } from "../data-form-layout.mjs";
|
|
13
13
|
import { DEFAULT_LAYOUT } from "../normalize-form.mjs";
|
|
14
14
|
import SummaryButton from "./summary-button.mjs";
|
|
15
15
|
import useFormValidity from "../../../hooks/use-form-validity.mjs";
|
|
16
|
+
import useReportValidity from "../../../hooks/use-report-validity.mjs";
|
|
16
17
|
import DataFormContext from "../../dataform-context/index.mjs";
|
|
18
|
+
import useFieldFromFormField from "./utils/use-field-from-form-field.mjs";
|
|
17
19
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
18
20
|
function ModalContent({
|
|
19
21
|
data,
|
|
20
22
|
field,
|
|
21
23
|
onChange,
|
|
22
24
|
fieldLabel,
|
|
23
|
-
onClose
|
|
25
|
+
onClose,
|
|
26
|
+
touched
|
|
24
27
|
}) {
|
|
25
28
|
const { fields } = useContext(DataFormContext);
|
|
26
29
|
const [changes, setChanges] = useState({});
|
|
@@ -65,6 +68,9 @@ function ModalContent({
|
|
|
65
68
|
);
|
|
66
69
|
};
|
|
67
70
|
const focusOnMountRef = useFocusOnMount("firstInputElement");
|
|
71
|
+
const contentRef = useRef(null);
|
|
72
|
+
const mergedRef = useMergeRefs([focusOnMountRef, contentRef]);
|
|
73
|
+
useReportValidity(contentRef, touched);
|
|
68
74
|
return /* @__PURE__ */ jsxs(
|
|
69
75
|
Modal,
|
|
70
76
|
{
|
|
@@ -74,20 +80,21 @@ function ModalContent({
|
|
|
74
80
|
title: fieldLabel,
|
|
75
81
|
size: "medium",
|
|
76
82
|
children: [
|
|
77
|
-
/* @__PURE__ */ jsx("div", { ref:
|
|
83
|
+
/* @__PURE__ */ jsx("div", { ref: mergedRef, children: /* @__PURE__ */ jsx(
|
|
78
84
|
DataFormLayout,
|
|
79
85
|
{
|
|
80
86
|
data: modalData,
|
|
81
87
|
form,
|
|
82
88
|
onChange: handleOnChange,
|
|
83
89
|
validity,
|
|
84
|
-
children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ jsx(
|
|
90
|
+
children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ jsx(
|
|
85
91
|
FieldLayout,
|
|
86
92
|
{
|
|
87
93
|
data: modalData,
|
|
88
94
|
field: childField,
|
|
89
95
|
onChange: handleOnChange,
|
|
90
96
|
hideLabelFromVision: form.fields.length < 2,
|
|
97
|
+
markWhenOptional,
|
|
91
98
|
validity: childFieldValidity
|
|
92
99
|
},
|
|
93
100
|
childField.id
|
|
@@ -99,7 +106,7 @@ function ModalContent({
|
|
|
99
106
|
{
|
|
100
107
|
direction: "row",
|
|
101
108
|
className: "dataforms-layouts-panel__modal-footer",
|
|
102
|
-
gap: "
|
|
109
|
+
gap: "md",
|
|
103
110
|
children: [
|
|
104
111
|
/* @__PURE__ */ jsx(Spacer, { style: { flex: 1 } }),
|
|
105
112
|
/* @__PURE__ */ jsx(
|
|
@@ -131,28 +138,30 @@ function PanelModal({
|
|
|
131
138
|
data,
|
|
132
139
|
field,
|
|
133
140
|
onChange,
|
|
134
|
-
|
|
135
|
-
summaryFields,
|
|
136
|
-
fieldDefinition,
|
|
137
|
-
onOpen
|
|
141
|
+
validity
|
|
138
142
|
}) {
|
|
143
|
+
const [touched, setTouched] = useState(false);
|
|
139
144
|
const [isOpen, setIsOpen] = useState(false);
|
|
140
|
-
const fieldLabel
|
|
145
|
+
const { fieldDefinition, fieldLabel, summaryFields } = useFieldFromFormField(field);
|
|
146
|
+
if (!fieldDefinition) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const handleClose = () => {
|
|
150
|
+
setIsOpen(false);
|
|
151
|
+
setTouched(true);
|
|
152
|
+
};
|
|
141
153
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
142
154
|
/* @__PURE__ */ jsx(
|
|
143
155
|
SummaryButton,
|
|
144
156
|
{
|
|
145
|
-
summaryFields,
|
|
146
157
|
data,
|
|
147
|
-
|
|
158
|
+
field,
|
|
148
159
|
fieldLabel,
|
|
160
|
+
summaryFields,
|
|
161
|
+
validity,
|
|
162
|
+
touched,
|
|
149
163
|
disabled: fieldDefinition.readOnly === true,
|
|
150
|
-
onClick: () =>
|
|
151
|
-
if (onOpen) {
|
|
152
|
-
onOpen();
|
|
153
|
-
}
|
|
154
|
-
setIsOpen(true);
|
|
155
|
-
},
|
|
164
|
+
onClick: () => setIsOpen(true),
|
|
156
165
|
"aria-expanded": isOpen
|
|
157
166
|
}
|
|
158
167
|
),
|
|
@@ -163,7 +172,8 @@ function PanelModal({
|
|
|
163
172
|
field,
|
|
164
173
|
onChange,
|
|
165
174
|
fieldLabel: fieldLabel ?? "",
|
|
166
|
-
onClose:
|
|
175
|
+
onClose: handleClose,
|
|
176
|
+
touched
|
|
167
177
|
}
|
|
168
178
|
)
|
|
169
179
|
] });
|