@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
|
@@ -2,28 +2,101 @@
|
|
|
2
2
|
@use "@wordpress/base-styles/colors" as *;
|
|
3
3
|
@use "@wordpress/base-styles/z-index" as *;
|
|
4
4
|
|
|
5
|
-
.dataforms-layouts-panel__field {
|
|
5
|
+
.dataforms-layouts-panel__field-trigger {
|
|
6
|
+
position: relative;
|
|
7
|
+
color: inherit;
|
|
8
|
+
display: flex;
|
|
6
9
|
width: 100%;
|
|
7
|
-
min-height: $grid-unit-
|
|
8
|
-
|
|
9
|
-
align-items: flex-start
|
|
10
|
+
min-height: $grid-unit-30;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
align-items: flex-start;
|
|
13
|
+
border-radius: $radius-small;
|
|
14
|
+
isolation: isolate;
|
|
15
|
+
|
|
16
|
+
&--label-side {
|
|
17
|
+
flex-direction: row;
|
|
18
|
+
gap: var(--wpds-dimension-gap-md);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&--label-top {
|
|
22
|
+
display: grid;
|
|
23
|
+
grid-template-columns: 1fr auto;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&--label-none {
|
|
27
|
+
align-items: center;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:not(.is-disabled):hover {
|
|
31
|
+
color: var(--wp-admin-theme-color);
|
|
32
|
+
|
|
33
|
+
.dataforms-layouts-panel__field-trigger-icon {
|
|
34
|
+
opacity: 1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.dataforms-layouts-panel__field-label {
|
|
38
|
+
color: var(--wp-admin-theme-color);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&.is-disabled {
|
|
43
|
+
cursor: default;
|
|
44
|
+
|
|
45
|
+
.dataforms-layouts-panel__field-control {
|
|
46
|
+
color: $gray-700;
|
|
47
|
+
font-weight: var(--wpds-font-weight-regular);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.dataforms-layouts-panel__field-trigger--edit-always
|
|
53
|
+
.dataforms-layouts-panel__field-trigger-icon {
|
|
54
|
+
opacity: 1;
|
|
55
|
+
fill: currentColor;
|
|
56
|
+
|
|
57
|
+
&:hover,
|
|
58
|
+
&:focus-visible {
|
|
59
|
+
fill: var(--wp-admin-theme-color);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.dataforms-layouts-panel__field-trigger-icon {
|
|
64
|
+
padding: 0;
|
|
65
|
+
color: var(--wp-admin-theme-color);
|
|
66
|
+
flex: 0 0 auto;
|
|
67
|
+
opacity: 0;
|
|
68
|
+
border-radius: var(--wpds-border-radius-xs);
|
|
10
69
|
|
|
11
|
-
|
|
12
|
-
|
|
70
|
+
&:focus-visible {
|
|
71
|
+
opacity: 1;
|
|
72
|
+
outline:
|
|
73
|
+
var(--wpds-border-width-focus) solid
|
|
74
|
+
var(--wp-admin-theme-color);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.dataforms-layouts-panel__field-dropdown-anchor {
|
|
79
|
+
width: 100%;
|
|
80
|
+
|
|
81
|
+
.components-dropdown {
|
|
82
|
+
width: 100%;
|
|
13
83
|
}
|
|
14
84
|
}
|
|
15
85
|
|
|
16
86
|
.dataforms-layouts-panel__field-label {
|
|
17
87
|
width: 38%;
|
|
18
88
|
flex-shrink: 0;
|
|
19
|
-
min-height: $grid-unit-
|
|
89
|
+
min-height: $grid-unit-30;
|
|
20
90
|
display: flex;
|
|
21
91
|
align-items: center;
|
|
22
92
|
line-height: $grid-unit-05 * 5;
|
|
23
93
|
hyphens: auto;
|
|
94
|
+
color: $gray-700;
|
|
24
95
|
|
|
25
|
-
|
|
26
|
-
|
|
96
|
+
.components-base-control__label {
|
|
97
|
+
display: inline;
|
|
98
|
+
margin-bottom: 0;
|
|
99
|
+
line-height: inherit;
|
|
27
100
|
}
|
|
28
101
|
|
|
29
102
|
&.has-error {
|
|
@@ -32,8 +105,14 @@
|
|
|
32
105
|
}
|
|
33
106
|
|
|
34
107
|
.dataforms-layouts-panel__field-label-error-content {
|
|
108
|
+
position: relative;
|
|
109
|
+
z-index: 1;
|
|
35
110
|
cursor: help;
|
|
36
111
|
fill: $alert-red;
|
|
112
|
+
display: inline-flex;
|
|
113
|
+
flex-direction: row;
|
|
114
|
+
align-items: center;
|
|
115
|
+
gap: $grid-unit-05;
|
|
37
116
|
svg {
|
|
38
117
|
fill: currentColor;
|
|
39
118
|
}
|
|
@@ -41,26 +120,33 @@
|
|
|
41
120
|
|
|
42
121
|
.dataforms-layouts-panel__field-control {
|
|
43
122
|
flex-grow: 1;
|
|
44
|
-
min-
|
|
123
|
+
min-width: 0;
|
|
124
|
+
min-height: $grid-unit-30;
|
|
125
|
+
line-height: var(--wpds-font-line-height-md);
|
|
45
126
|
display: flex;
|
|
46
127
|
align-items: center;
|
|
128
|
+
overflow: hidden;
|
|
129
|
+
font-weight: var(--wpds-font-weight-medium);
|
|
47
130
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
text-align: left;
|
|
51
|
-
white-space: normal;
|
|
52
|
-
text-wrap: balance; // Fallback for Safari.
|
|
53
|
-
text-wrap: pretty;
|
|
54
|
-
min-height: $button-size-compact;
|
|
131
|
+
> * {
|
|
132
|
+
min-width: 0;
|
|
55
133
|
}
|
|
134
|
+
}
|
|
56
135
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
136
|
+
.dataforms-layouts-panel__field-trigger--label-top
|
|
137
|
+
.dataforms-layouts-panel__field-label {
|
|
138
|
+
width: 100%;
|
|
139
|
+
}
|
|
60
140
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
141
|
+
.dataforms-layouts-panel__field-trigger--label-top
|
|
142
|
+
.dataforms-layouts-panel__field-control {
|
|
143
|
+
grid-column: 1 / -1;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.dataforms-layouts-panel__field-trigger--label-top
|
|
147
|
+
.dataforms-layouts-panel__field-trigger-icon {
|
|
148
|
+
grid-row: 1;
|
|
149
|
+
grid-column: 2;
|
|
64
150
|
}
|
|
65
151
|
|
|
66
152
|
.dataforms-layouts-panel__field-dropdown .components-popover__content {
|
|
@@ -79,7 +165,3 @@
|
|
|
79
165
|
.components-popover.components-dropdown__content.dataforms-layouts-panel__field-dropdown {
|
|
80
166
|
z-index: z-index(".components-popover.components-dropdown__content.dataforms-layouts-panel__field-dropdown");
|
|
81
167
|
}
|
|
82
|
-
|
|
83
|
-
.dataforms-layouts-panel__summary-button:empty {
|
|
84
|
-
min-width: $admin-sidebar-width;
|
|
85
|
-
}
|
|
@@ -1,92 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
|
-
import { Button } from '@wordpress/components';
|
|
9
|
+
import { Button, Icon, Tooltip } from '@wordpress/components';
|
|
5
10
|
import { sprintf, _x } from '@wordpress/i18n';
|
|
11
|
+
import { error as errorIcon, pencil } from '@wordpress/icons';
|
|
12
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
13
|
+
import { useRef } from '@wordpress/element';
|
|
6
14
|
|
|
7
15
|
/**
|
|
8
16
|
* Internal dependencies
|
|
9
17
|
*/
|
|
10
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
FieldValidity,
|
|
20
|
+
NormalizedField,
|
|
21
|
+
NormalizedFormField,
|
|
22
|
+
NormalizedPanelLayout,
|
|
23
|
+
} from '../../../types';
|
|
24
|
+
import getLabelClassName from './utils/get-label-classname';
|
|
25
|
+
import getLabelContent from './utils/get-label-content';
|
|
26
|
+
import getFirstValidationError from './utils/get-first-validation-error';
|
|
11
27
|
|
|
12
|
-
function SummaryButton< Item >( {
|
|
13
|
-
summaryFields,
|
|
28
|
+
export default function SummaryButton< Item >( {
|
|
14
29
|
data,
|
|
15
|
-
|
|
30
|
+
field,
|
|
16
31
|
fieldLabel,
|
|
32
|
+
summaryFields,
|
|
33
|
+
validity,
|
|
34
|
+
touched,
|
|
17
35
|
disabled,
|
|
18
36
|
onClick,
|
|
19
37
|
'aria-expanded': ariaExpanded,
|
|
20
38
|
}: {
|
|
21
|
-
summaryFields: NormalizedField< Item >[];
|
|
22
39
|
data: Item;
|
|
23
|
-
|
|
40
|
+
field: NormalizedFormField;
|
|
24
41
|
fieldLabel?: string;
|
|
42
|
+
summaryFields: NormalizedField< Item >[];
|
|
43
|
+
validity?: FieldValidity;
|
|
44
|
+
touched: boolean;
|
|
25
45
|
disabled?: boolean;
|
|
26
46
|
onClick: () => void;
|
|
27
47
|
'aria-expanded'?: boolean;
|
|
28
48
|
} ) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
49
|
+
const { labelPosition, editVisibility } =
|
|
50
|
+
field.layout as NormalizedPanelLayout;
|
|
51
|
+
const errorMessage = getFirstValidationError( validity );
|
|
52
|
+
const showError = touched && !! errorMessage;
|
|
53
|
+
const labelClassName = getLabelClassName( labelPosition, showError );
|
|
54
|
+
const labelContent = getLabelContent( showError, errorMessage, fieldLabel );
|
|
55
|
+
const className = clsx(
|
|
56
|
+
'dataforms-layouts-panel__field-trigger',
|
|
57
|
+
`dataforms-layouts-panel__field-trigger--label-${ labelPosition }`,
|
|
58
|
+
{
|
|
59
|
+
'is-disabled': disabled,
|
|
60
|
+
'dataforms-layouts-panel__field-trigger--edit-always':
|
|
61
|
+
editVisibility === 'always',
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const controlId = useInstanceId(
|
|
66
|
+
SummaryButton,
|
|
67
|
+
'dataforms-layouts-panel__field-control'
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const ariaLabel = showError
|
|
71
|
+
? sprintf(
|
|
72
|
+
// translators: %s: Field name.
|
|
73
|
+
_x( 'Edit %s (has errors)', 'field' ),
|
|
74
|
+
fieldLabel || ''
|
|
75
|
+
)
|
|
76
|
+
: sprintf(
|
|
40
77
|
// translators: %s: Field name.
|
|
41
78
|
_x( 'Edit %s', 'field' ),
|
|
42
79
|
fieldLabel || ''
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const rowRef = useRef< HTMLDivElement >( null );
|
|
83
|
+
|
|
84
|
+
const handleRowClick = () => {
|
|
85
|
+
const selection =
|
|
86
|
+
rowRef.current?.ownerDocument.defaultView?.getSelection();
|
|
87
|
+
if ( selection && selection.toString().length > 0 ) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
onClick();
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const handleKeyDown = ( event: React.KeyboardEvent ) => {
|
|
94
|
+
if (
|
|
95
|
+
event.target === event.currentTarget &&
|
|
96
|
+
( event.key === 'Enter' || event.key === ' ' )
|
|
97
|
+
) {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
onClick();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div
|
|
105
|
+
ref={ rowRef }
|
|
106
|
+
className={ className }
|
|
107
|
+
onClick={ ! disabled ? handleRowClick : undefined }
|
|
108
|
+
onKeyDown={ ! disabled ? handleKeyDown : undefined }
|
|
109
|
+
>
|
|
110
|
+
{ labelPosition !== 'none' && (
|
|
111
|
+
<span className={ labelClassName }>{ labelContent }</span>
|
|
112
|
+
) }
|
|
113
|
+
{ labelPosition === 'none' && showError && (
|
|
114
|
+
<Tooltip text={ errorMessage } placement="top">
|
|
115
|
+
<span className="dataforms-layouts-panel__field-label-error-content">
|
|
116
|
+
<Icon icon={ errorIcon } size={ 16 } />
|
|
117
|
+
</span>
|
|
118
|
+
</Tooltip>
|
|
43
119
|
) }
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
summaryFields.length > 1
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
120
|
+
<span
|
|
121
|
+
id={ `${ controlId }` }
|
|
122
|
+
className="dataforms-layouts-panel__field-control"
|
|
123
|
+
>
|
|
124
|
+
{ summaryFields.length > 1 ? (
|
|
125
|
+
<span
|
|
126
|
+
style={ {
|
|
127
|
+
display: 'flex',
|
|
128
|
+
flexDirection: 'column',
|
|
52
129
|
alignItems: 'flex-start',
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
130
|
+
width: '100%',
|
|
131
|
+
gap: '2px',
|
|
132
|
+
} }
|
|
133
|
+
>
|
|
134
|
+
{ summaryFields.map( ( summaryField ) => (
|
|
135
|
+
<span
|
|
136
|
+
key={ summaryField.id }
|
|
137
|
+
style={ { width: '100%' } }
|
|
138
|
+
>
|
|
139
|
+
<summaryField.render
|
|
140
|
+
item={ data }
|
|
141
|
+
field={ summaryField }
|
|
142
|
+
/>
|
|
143
|
+
</span>
|
|
144
|
+
) ) }
|
|
145
|
+
</span>
|
|
146
|
+
) : (
|
|
147
|
+
summaryFields.map( ( summaryField ) => (
|
|
148
|
+
<summaryField.render
|
|
69
149
|
key={ summaryField.id }
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
150
|
+
item={ data }
|
|
151
|
+
field={ summaryField }
|
|
152
|
+
/>
|
|
153
|
+
) )
|
|
154
|
+
) }
|
|
155
|
+
</span>
|
|
156
|
+
{ ! disabled && (
|
|
157
|
+
<Button
|
|
158
|
+
className="dataforms-layouts-panel__field-trigger-icon"
|
|
159
|
+
label={ ariaLabel }
|
|
160
|
+
showTooltip={ false }
|
|
161
|
+
icon={ pencil }
|
|
162
|
+
size="small"
|
|
163
|
+
aria-expanded={ ariaExpanded }
|
|
164
|
+
aria-haspopup="dialog"
|
|
165
|
+
aria-describedby={ `${ controlId }` }
|
|
166
|
+
/>
|
|
87
167
|
) }
|
|
88
|
-
</
|
|
168
|
+
</div>
|
|
89
169
|
);
|
|
90
170
|
}
|
|
91
|
-
|
|
92
|
-
export default SummaryButton;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { FieldValidity } from '../../../../types';
|
|
2
|
+
|
|
3
|
+
function getFirstValidationError(
|
|
4
|
+
validity: FieldValidity | undefined
|
|
5
|
+
): string | undefined {
|
|
6
|
+
if ( ! validity ) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const validityRules = Object.keys( validity ).filter(
|
|
11
|
+
( key ) => key !== 'children'
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
for ( const key of validityRules ) {
|
|
15
|
+
const rule = validity[ key as keyof Omit< FieldValidity, 'children' > ];
|
|
16
|
+
if ( rule === undefined ) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if ( rule.type === 'invalid' ) {
|
|
21
|
+
if ( rule.message ) {
|
|
22
|
+
return rule.message;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Provide default message for required validation (message is optional)
|
|
26
|
+
if ( key === 'required' ) {
|
|
27
|
+
return 'A required field is empty';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return 'Unidentified validation error';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Check children recursively
|
|
35
|
+
if ( validity.children ) {
|
|
36
|
+
for ( const childValidity of Object.values( validity.children ) ) {
|
|
37
|
+
const childError = getFirstValidationError( childValidity );
|
|
38
|
+
if ( childError ) {
|
|
39
|
+
return childError;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default getFirstValidationError;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import type { LabelPosition } from '../../../../types';
|
|
6
|
+
|
|
7
|
+
function getLabelClassName(
|
|
8
|
+
labelPosition: LabelPosition,
|
|
9
|
+
showError?: boolean
|
|
10
|
+
) {
|
|
11
|
+
return clsx(
|
|
12
|
+
'dataforms-layouts-panel__field-label',
|
|
13
|
+
`dataforms-layouts-panel__field-label--label-position-${ labelPosition }`,
|
|
14
|
+
{ 'has-error': showError }
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default getLabelClassName;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { BaseControl, Icon, Tooltip } from '@wordpress/components';
|
|
5
|
+
import { error as errorIcon } from '@wordpress/icons';
|
|
6
|
+
|
|
7
|
+
function getLabelContent(
|
|
8
|
+
showError?: boolean,
|
|
9
|
+
errorMessage?: string,
|
|
10
|
+
fieldLabel?: string
|
|
11
|
+
) {
|
|
12
|
+
return showError ? (
|
|
13
|
+
<Tooltip text={ errorMessage } placement="top">
|
|
14
|
+
<span className="dataforms-layouts-panel__field-label-error-content">
|
|
15
|
+
<Icon icon={ errorIcon } size={ 16 } />
|
|
16
|
+
<BaseControl.VisualLabel>
|
|
17
|
+
{ fieldLabel }
|
|
18
|
+
</BaseControl.VisualLabel>
|
|
19
|
+
</span>
|
|
20
|
+
</Tooltip>
|
|
21
|
+
) : (
|
|
22
|
+
<BaseControl.VisualLabel>{ fieldLabel }</BaseControl.VisualLabel>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default getLabelContent;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useContext } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type {
|
|
10
|
+
NormalizedFormField,
|
|
11
|
+
NormalizedField,
|
|
12
|
+
NormalizedPanelLayout,
|
|
13
|
+
} from '../../../../types';
|
|
14
|
+
import { getSummaryFields } from '../../get-summary-fields';
|
|
15
|
+
import DataFormContext from '../../../dataform-context';
|
|
16
|
+
|
|
17
|
+
const getFieldDefinition = < Item >(
|
|
18
|
+
field: NormalizedFormField,
|
|
19
|
+
fields: NormalizedField< Item >[]
|
|
20
|
+
) => {
|
|
21
|
+
const fieldDefinition = fields.find( ( _field ) => _field.id === field.id );
|
|
22
|
+
|
|
23
|
+
if ( ! fieldDefinition ) {
|
|
24
|
+
return fields.find( ( _field ) => {
|
|
25
|
+
if ( !! field.children ) {
|
|
26
|
+
const simpleChildren = field.children.filter(
|
|
27
|
+
( child ) => ! child.children
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if ( simpleChildren.length === 0 ) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return _field.id === simpleChildren[ 0 ].id;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return _field.id === field.id;
|
|
38
|
+
} );
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return fieldDefinition;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Determines the field definition and summary fields for a panel layout.
|
|
46
|
+
*
|
|
47
|
+
* Summary fields are determined with the following priority:
|
|
48
|
+
* 1. Use layout.summary fields if they exist
|
|
49
|
+
* 2. Fall back to the field definition that matches the form field's id
|
|
50
|
+
* 3. If the form field id doesn't exist, pick the first child field
|
|
51
|
+
* 4. If no field definition is found, return empty summary fields
|
|
52
|
+
*
|
|
53
|
+
* @param field The form field to get definition for
|
|
54
|
+
* @return Object containing fieldDefinition, fieldLabel, and summaryFields
|
|
55
|
+
*/
|
|
56
|
+
function useFieldFromFormField( field: NormalizedFormField ) {
|
|
57
|
+
const { fields } = useContext( DataFormContext );
|
|
58
|
+
const layout = field.layout as NormalizedPanelLayout;
|
|
59
|
+
const summaryFields = getSummaryFields( layout.summary, fields );
|
|
60
|
+
const fieldDefinition = getFieldDefinition( field, fields );
|
|
61
|
+
const fieldLabel = !! field.children ? field.label : fieldDefinition?.label;
|
|
62
|
+
|
|
63
|
+
if ( summaryFields.length === 0 ) {
|
|
64
|
+
return {
|
|
65
|
+
summaryFields: fieldDefinition ? [ fieldDefinition ] : [],
|
|
66
|
+
fieldDefinition,
|
|
67
|
+
fieldLabel,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
summaryFields,
|
|
73
|
+
fieldDefinition,
|
|
74
|
+
fieldLabel,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default useFieldFromFormField;
|
|
@@ -30,7 +30,7 @@ function Header( { title }: { title: string } ) {
|
|
|
30
30
|
<Stack
|
|
31
31
|
direction="column"
|
|
32
32
|
className="dataforms-layouts-regular__header"
|
|
33
|
-
gap="
|
|
33
|
+
gap="lg"
|
|
34
34
|
>
|
|
35
35
|
<Stack direction="row" align="center">
|
|
36
36
|
<Heading level={ 2 } size={ 13 }>
|
|
@@ -46,6 +46,7 @@ export default function FormRegularField< Item >( {
|
|
|
46
46
|
field,
|
|
47
47
|
onChange,
|
|
48
48
|
hideLabelFromVision,
|
|
49
|
+
markWhenOptional,
|
|
49
50
|
validity,
|
|
50
51
|
}: FieldLayoutProps< Item > ) {
|
|
51
52
|
const { fields } = useContext( DataFormContext );
|
|
@@ -89,7 +90,7 @@ export default function FormRegularField< Item >( {
|
|
|
89
90
|
<Stack
|
|
90
91
|
direction="row"
|
|
91
92
|
className="dataforms-layouts-regular__field"
|
|
92
|
-
gap="
|
|
93
|
+
gap="sm"
|
|
93
94
|
>
|
|
94
95
|
<div
|
|
95
96
|
className={ clsx(
|
|
@@ -97,7 +98,9 @@ export default function FormRegularField< Item >( {
|
|
|
97
98
|
`dataforms-layouts-regular__field-label--label-position-${ labelPosition }`
|
|
98
99
|
) }
|
|
99
100
|
>
|
|
100
|
-
|
|
101
|
+
<BaseControl.VisualLabel>
|
|
102
|
+
{ fieldDefinition.label }
|
|
103
|
+
</BaseControl.VisualLabel>
|
|
101
104
|
</div>
|
|
102
105
|
<div className="dataforms-layouts-regular__field-control">
|
|
103
106
|
{ fieldDefinition.readOnly === true ? (
|
|
@@ -112,6 +115,7 @@ export default function FormRegularField< Item >( {
|
|
|
112
115
|
field={ fieldDefinition }
|
|
113
116
|
onChange={ onChange }
|
|
114
117
|
hideLabelFromVision
|
|
118
|
+
markWhenOptional={ markWhenOptional }
|
|
115
119
|
validity={ validity }
|
|
116
120
|
/>
|
|
117
121
|
) }
|
|
@@ -144,6 +148,7 @@ export default function FormRegularField< Item >( {
|
|
|
144
148
|
hideLabelFromVision={
|
|
145
149
|
labelPosition === 'none' ? true : hideLabelFromVision
|
|
146
150
|
}
|
|
151
|
+
markWhenOptional={ markWhenOptional }
|
|
147
152
|
validity={ validity }
|
|
148
153
|
/>
|
|
149
154
|
) }
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/colors" as *;
|
|
1
2
|
@use "@wordpress/base-styles/variables" as *;
|
|
2
3
|
|
|
3
4
|
.dataforms-layouts-regular__field {
|
|
@@ -5,6 +6,11 @@
|
|
|
5
6
|
min-height: $grid-unit-40;
|
|
6
7
|
justify-content: flex-start !important;
|
|
7
8
|
align-items: flex-start !important;
|
|
9
|
+
|
|
10
|
+
.components-base-control__label,
|
|
11
|
+
.components-input-control__label {
|
|
12
|
+
color: $gray-700;
|
|
13
|
+
}
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
.dataforms-layouts-regular__field-label {
|
|
@@ -19,6 +25,10 @@
|
|
|
19
25
|
&--label-position-side {
|
|
20
26
|
align-self: center;
|
|
21
27
|
}
|
|
28
|
+
|
|
29
|
+
.components-base-control__label {
|
|
30
|
+
margin-bottom: 0;
|
|
31
|
+
}
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
.dataforms-layouts-regular__field-control {
|