@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
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useMemo, useState, useRef, useEffect } from '@wordpress/element';
|
|
5
|
+
import { Stack } from '@wordpress/ui';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
11
|
+
import DataForm from '../index';
|
|
12
|
+
import useFormValidity from '../../hooks/use-form-validity';
|
|
13
|
+
import type { Field, Form } from '../../types';
|
|
14
|
+
|
|
15
|
+
const meta: Meta< typeof DataForm > = {
|
|
16
|
+
title: 'DataViews/DataForm/Content',
|
|
17
|
+
component: DataForm,
|
|
18
|
+
parameters: {
|
|
19
|
+
controls: { disable: true },
|
|
20
|
+
},
|
|
21
|
+
tags: [ '!dev' /* Hide individual story pages from sidebar */ ],
|
|
22
|
+
};
|
|
23
|
+
export default meta;
|
|
24
|
+
|
|
25
|
+
type Story = StoryObj< typeof DataForm >;
|
|
26
|
+
|
|
27
|
+
type SampleData = {
|
|
28
|
+
name: string;
|
|
29
|
+
email: string;
|
|
30
|
+
phone: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const Labels: Story = {
|
|
34
|
+
render: () => {
|
|
35
|
+
const [ data, setData ] = useState< SampleData >( {
|
|
36
|
+
name: '',
|
|
37
|
+
email: '',
|
|
38
|
+
phone: '',
|
|
39
|
+
} );
|
|
40
|
+
|
|
41
|
+
const fields: Field< SampleData >[] = useMemo(
|
|
42
|
+
() => [
|
|
43
|
+
{
|
|
44
|
+
id: 'name',
|
|
45
|
+
label: 'Name',
|
|
46
|
+
type: 'text',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 'email',
|
|
50
|
+
label: 'Email',
|
|
51
|
+
type: 'email',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 'phone',
|
|
55
|
+
label: 'Phone number',
|
|
56
|
+
type: 'telephone',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
[]
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const form: Form = useMemo(
|
|
63
|
+
() => ( {
|
|
64
|
+
layout: { type: 'regular' },
|
|
65
|
+
fields: [ 'name', 'email', 'phone' ],
|
|
66
|
+
} ),
|
|
67
|
+
[]
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<Stack direction="column" gap="lg">
|
|
72
|
+
<DataForm< SampleData >
|
|
73
|
+
data={ data }
|
|
74
|
+
fields={ fields }
|
|
75
|
+
form={ form }
|
|
76
|
+
onChange={ ( edits ) =>
|
|
77
|
+
setData( ( prev ) => ( { ...prev, ...edits } ) )
|
|
78
|
+
}
|
|
79
|
+
/>
|
|
80
|
+
</Stack>
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type HelpTextData = {
|
|
86
|
+
name: string;
|
|
87
|
+
email: string;
|
|
88
|
+
phone: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const HelpText: Story = {
|
|
92
|
+
render: () => {
|
|
93
|
+
const [ data, setData ] = useState< HelpTextData >( {
|
|
94
|
+
name: '',
|
|
95
|
+
email: '',
|
|
96
|
+
phone: '',
|
|
97
|
+
} );
|
|
98
|
+
|
|
99
|
+
const fields: Field< HelpTextData >[] = useMemo(
|
|
100
|
+
() => [
|
|
101
|
+
{
|
|
102
|
+
id: 'name',
|
|
103
|
+
label: 'Name',
|
|
104
|
+
type: 'text',
|
|
105
|
+
placeholder: 'Jane Doe',
|
|
106
|
+
description:
|
|
107
|
+
'Enter your full legal name as it appears on official documents.',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: 'email',
|
|
111
|
+
label: 'Email',
|
|
112
|
+
type: 'email',
|
|
113
|
+
placeholder: 'you@example.com',
|
|
114
|
+
description:
|
|
115
|
+
'We will use this to send you important account notifications and updates.',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: 'phone',
|
|
119
|
+
label: 'Phone number',
|
|
120
|
+
type: 'telephone',
|
|
121
|
+
placeholder: '+1 (555) 123-4567',
|
|
122
|
+
description:
|
|
123
|
+
'Include your country code. This number will be used for account verification.',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
[]
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const form: Form = useMemo(
|
|
130
|
+
() => ( {
|
|
131
|
+
layout: { type: 'regular' },
|
|
132
|
+
fields: [ 'name', 'email', 'phone' ],
|
|
133
|
+
} ),
|
|
134
|
+
[]
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<Stack direction="column" gap="lg">
|
|
139
|
+
<DataForm< HelpTextData >
|
|
140
|
+
data={ data }
|
|
141
|
+
fields={ fields }
|
|
142
|
+
form={ form }
|
|
143
|
+
onChange={ ( edits ) =>
|
|
144
|
+
setData( ( prev ) => ( { ...prev, ...edits } ) )
|
|
145
|
+
}
|
|
146
|
+
/>
|
|
147
|
+
</Stack>
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
type ValidationMessagesData = {
|
|
153
|
+
name: string;
|
|
154
|
+
email: string;
|
|
155
|
+
phone: string;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const ValidationMessages: Story = {
|
|
159
|
+
render: () => {
|
|
160
|
+
const [ data, setData ] = useState< ValidationMessagesData >( {
|
|
161
|
+
name: '',
|
|
162
|
+
email: 'invalid-email',
|
|
163
|
+
phone: '123',
|
|
164
|
+
} );
|
|
165
|
+
|
|
166
|
+
const fields: Field< ValidationMessagesData >[] = useMemo(
|
|
167
|
+
() => [
|
|
168
|
+
{
|
|
169
|
+
id: 'name',
|
|
170
|
+
label: 'Name',
|
|
171
|
+
type: 'text',
|
|
172
|
+
placeholder: 'Jane Doe',
|
|
173
|
+
isValid: {
|
|
174
|
+
required: true,
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: 'email',
|
|
179
|
+
label: 'Email',
|
|
180
|
+
type: 'email',
|
|
181
|
+
placeholder: 'you@example.com',
|
|
182
|
+
isValid: {
|
|
183
|
+
required: true,
|
|
184
|
+
custom: ( item ) => {
|
|
185
|
+
if ( ! item.email ) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
if ( ! item.email.includes( '@' ) ) {
|
|
189
|
+
return 'Please enter a valid email address.';
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
id: 'phone',
|
|
197
|
+
label: 'Phone number',
|
|
198
|
+
type: 'telephone',
|
|
199
|
+
placeholder: '+1 (555) 123-4567',
|
|
200
|
+
isValid: {
|
|
201
|
+
required: true,
|
|
202
|
+
custom: ( item ) => {
|
|
203
|
+
if ( ! item.phone ) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
if ( item.phone.length < 10 ) {
|
|
207
|
+
return 'Phone number must be at least 10 digits long.';
|
|
208
|
+
}
|
|
209
|
+
return null;
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
[]
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
const form: Form = useMemo(
|
|
218
|
+
() => ( {
|
|
219
|
+
layout: { type: 'regular' },
|
|
220
|
+
fields: [ 'name', 'email', 'phone' ],
|
|
221
|
+
} ),
|
|
222
|
+
[]
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const { validity } = useFormValidity( data, fields, form );
|
|
226
|
+
const containerRef = useRef< HTMLDivElement >( null );
|
|
227
|
+
|
|
228
|
+
// Show validation messages on load without focusing
|
|
229
|
+
useEffect( () => {
|
|
230
|
+
if ( validity && containerRef.current ) {
|
|
231
|
+
const inputs = containerRef.current.querySelectorAll( 'input' );
|
|
232
|
+
inputs.forEach( ( input ) => {
|
|
233
|
+
// Dispatch 'invalid' event to trigger the validation message display
|
|
234
|
+
input.dispatchEvent(
|
|
235
|
+
new Event( 'invalid', { bubbles: false } )
|
|
236
|
+
);
|
|
237
|
+
} );
|
|
238
|
+
}
|
|
239
|
+
}, [ validity ] );
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<div ref={ containerRef }>
|
|
243
|
+
<Stack direction="column" gap="xl">
|
|
244
|
+
<DataForm< ValidationMessagesData >
|
|
245
|
+
data={ data }
|
|
246
|
+
fields={ fields }
|
|
247
|
+
form={ form }
|
|
248
|
+
validity={ validity }
|
|
249
|
+
onChange={ ( edits ) =>
|
|
250
|
+
setData( ( prev ) => ( { ...prev, ...edits } ) )
|
|
251
|
+
}
|
|
252
|
+
/>
|
|
253
|
+
</Stack>
|
|
254
|
+
</div>
|
|
255
|
+
);
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
type HighLevelHelpTextData = {
|
|
260
|
+
name: string;
|
|
261
|
+
email: string;
|
|
262
|
+
phone: string;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export const HighLevelHelpText: Story = {
|
|
266
|
+
render: () => {
|
|
267
|
+
const [ data, setData ] = useState< HighLevelHelpTextData >( {
|
|
268
|
+
name: '',
|
|
269
|
+
email: '',
|
|
270
|
+
phone: '',
|
|
271
|
+
} );
|
|
272
|
+
|
|
273
|
+
const fields: Field< HighLevelHelpTextData >[] = useMemo(
|
|
274
|
+
() => [
|
|
275
|
+
{
|
|
276
|
+
id: 'name',
|
|
277
|
+
label: 'Name',
|
|
278
|
+
type: 'text',
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
id: 'email',
|
|
282
|
+
label: 'Email',
|
|
283
|
+
type: 'email',
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
id: 'phone',
|
|
287
|
+
label: 'Phone number',
|
|
288
|
+
type: 'telephone',
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
[]
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const form: Form = useMemo(
|
|
295
|
+
() => ( {
|
|
296
|
+
layout: { type: 'regular' },
|
|
297
|
+
fields: [
|
|
298
|
+
{
|
|
299
|
+
id: 'accountForm',
|
|
300
|
+
label: 'Account Information',
|
|
301
|
+
description:
|
|
302
|
+
'We collect this information to create your account and provide personalized services. Your data will be kept secure and used only for account management and service improvements.',
|
|
303
|
+
children: [ 'name', 'email', 'phone' ],
|
|
304
|
+
layout: {
|
|
305
|
+
isCollapsible: false,
|
|
306
|
+
summary: 'account-form',
|
|
307
|
+
type: 'card',
|
|
308
|
+
withHeader: true,
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
],
|
|
312
|
+
} ),
|
|
313
|
+
[]
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<Stack direction="column" gap="lg">
|
|
318
|
+
<DataForm< HighLevelHelpTextData >
|
|
319
|
+
data={ data }
|
|
320
|
+
fields={ fields }
|
|
321
|
+
form={ form }
|
|
322
|
+
onChange={ ( edits ) =>
|
|
323
|
+
setData( ( prev ) => ( { ...prev, ...edits } ) )
|
|
324
|
+
}
|
|
325
|
+
/>
|
|
326
|
+
</Stack>
|
|
327
|
+
);
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
type PlaceholdersData = {
|
|
332
|
+
name: string;
|
|
333
|
+
email: string;
|
|
334
|
+
phone: string;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
export const Placeholders: Story = {
|
|
338
|
+
render: () => {
|
|
339
|
+
const [ data, setData ] = useState< PlaceholdersData >( {
|
|
340
|
+
name: '',
|
|
341
|
+
email: '',
|
|
342
|
+
phone: '',
|
|
343
|
+
} );
|
|
344
|
+
|
|
345
|
+
const fields: Field< PlaceholdersData >[] = useMemo(
|
|
346
|
+
() => [
|
|
347
|
+
{
|
|
348
|
+
id: 'name',
|
|
349
|
+
label: 'Name',
|
|
350
|
+
type: 'text',
|
|
351
|
+
placeholder: 'Jane Doe',
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
id: 'email',
|
|
355
|
+
label: 'Email',
|
|
356
|
+
type: 'email',
|
|
357
|
+
placeholder: 'you@example.com',
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
id: 'phone',
|
|
361
|
+
label: 'Phone number',
|
|
362
|
+
type: 'telephone',
|
|
363
|
+
placeholder: '+1 (555) 123-4567',
|
|
364
|
+
},
|
|
365
|
+
],
|
|
366
|
+
[]
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
const form: Form = useMemo(
|
|
370
|
+
() => ( {
|
|
371
|
+
layout: { type: 'regular' },
|
|
372
|
+
fields: [ 'name', 'email', 'phone' ],
|
|
373
|
+
} ),
|
|
374
|
+
[]
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
return (
|
|
378
|
+
<Stack direction="column" gap="lg">
|
|
379
|
+
<DataForm< PlaceholdersData >
|
|
380
|
+
data={ data }
|
|
381
|
+
fields={ fields }
|
|
382
|
+
form={ form }
|
|
383
|
+
onChange={ ( edits ) =>
|
|
384
|
+
setData( ( prev ) => ( { ...prev, ...edits } ) )
|
|
385
|
+
}
|
|
386
|
+
/>
|
|
387
|
+
</Stack>
|
|
388
|
+
);
|
|
389
|
+
},
|
|
390
|
+
};
|
|
@@ -62,6 +62,11 @@ export const LayoutPanel = {
|
|
|
62
62
|
description: 'Chooses how to open the panel.',
|
|
63
63
|
options: [ 'default', 'dropdown', 'modal' ],
|
|
64
64
|
},
|
|
65
|
+
editVisibility: {
|
|
66
|
+
control: { type: 'select' },
|
|
67
|
+
description: 'Chooses when the edit icon is visible.',
|
|
68
|
+
options: [ 'default', 'always', 'on-hover' ],
|
|
69
|
+
},
|
|
65
70
|
},
|
|
66
71
|
};
|
|
67
72
|
|
|
@@ -100,12 +105,19 @@ export const Validation = {
|
|
|
100
105
|
layout: {
|
|
101
106
|
control: { type: 'select' },
|
|
102
107
|
description: 'Choose the form layout type.',
|
|
103
|
-
options: [
|
|
108
|
+
options: [
|
|
109
|
+
'regular',
|
|
110
|
+
'panel-dropdown',
|
|
111
|
+
'panel-modal',
|
|
112
|
+
'card-collapsible',
|
|
113
|
+
'card-not-collapsible',
|
|
114
|
+
'details',
|
|
115
|
+
],
|
|
104
116
|
},
|
|
105
117
|
required: {
|
|
106
118
|
control: { type: 'boolean' },
|
|
107
119
|
description:
|
|
108
|
-
'Whether or not the required validation rule is active.',
|
|
120
|
+
'Whether or not the required validation rule is active (only applies when fieldDistribution is allSame).',
|
|
109
121
|
},
|
|
110
122
|
elements: {
|
|
111
123
|
control: { type: 'select' },
|
|
@@ -7,7 +7,13 @@ import { useMemo, useState } from '@wordpress/element';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import DataForm from '../index';
|
|
10
|
-
import type {
|
|
10
|
+
import type {
|
|
11
|
+
Field,
|
|
12
|
+
Form,
|
|
13
|
+
Layout,
|
|
14
|
+
PanelLayout,
|
|
15
|
+
EditVisibility,
|
|
16
|
+
} from '../../types';
|
|
11
17
|
|
|
12
18
|
type SamplePost = {
|
|
13
19
|
title: string;
|
|
@@ -261,10 +267,12 @@ const getPanelLayoutFromStoryArgs = ( {
|
|
|
261
267
|
summary,
|
|
262
268
|
labelPosition,
|
|
263
269
|
openAs,
|
|
270
|
+
editVisibility,
|
|
264
271
|
}: {
|
|
265
272
|
summary?: string[];
|
|
266
273
|
labelPosition?: 'default' | 'top' | 'side' | 'none';
|
|
267
274
|
openAs?: 'default' | 'dropdown' | 'modal';
|
|
275
|
+
editVisibility?: 'default' | EditVisibility;
|
|
268
276
|
} ): Layout | undefined => {
|
|
269
277
|
const panelLayout: PanelLayout = {
|
|
270
278
|
type: 'panel',
|
|
@@ -282,16 +290,22 @@ const getPanelLayoutFromStoryArgs = ( {
|
|
|
282
290
|
panelLayout.summary = summary;
|
|
283
291
|
}
|
|
284
292
|
|
|
293
|
+
if ( editVisibility !== 'default' ) {
|
|
294
|
+
panelLayout.editVisibility = editVisibility;
|
|
295
|
+
}
|
|
296
|
+
|
|
285
297
|
return panelLayout;
|
|
286
298
|
};
|
|
287
299
|
|
|
288
300
|
const LayoutPanelComponent = ( {
|
|
289
301
|
labelPosition,
|
|
290
302
|
openAs,
|
|
303
|
+
editVisibility,
|
|
291
304
|
}: {
|
|
292
305
|
type: 'default' | 'regular' | 'panel' | 'card';
|
|
293
306
|
labelPosition: 'default' | 'top' | 'side' | 'none';
|
|
294
307
|
openAs: 'default' | 'dropdown' | 'modal';
|
|
308
|
+
editVisibility: 'default' | EditVisibility;
|
|
295
309
|
} ) => {
|
|
296
310
|
const [ post, setPost ] = useState< SamplePost >( {
|
|
297
311
|
title: 'Hello, World!',
|
|
@@ -321,6 +335,7 @@ const LayoutPanelComponent = ( {
|
|
|
321
335
|
layout: getPanelLayoutFromStoryArgs( {
|
|
322
336
|
labelPosition,
|
|
323
337
|
openAs,
|
|
338
|
+
editVisibility,
|
|
324
339
|
} ),
|
|
325
340
|
fields: [
|
|
326
341
|
'title',
|
|
@@ -357,6 +372,7 @@ const LayoutPanelComponent = ( {
|
|
|
357
372
|
summary: [ 'origin', 'destination', 'flight_status' ],
|
|
358
373
|
labelPosition,
|
|
359
374
|
openAs,
|
|
375
|
+
editVisibility,
|
|
360
376
|
} ),
|
|
361
377
|
},
|
|
362
378
|
{
|
|
@@ -367,11 +383,12 @@ const LayoutPanelComponent = ( {
|
|
|
367
383
|
summary: [ 'author', 'seat' ],
|
|
368
384
|
labelPosition,
|
|
369
385
|
openAs,
|
|
386
|
+
editVisibility,
|
|
370
387
|
} ),
|
|
371
388
|
},
|
|
372
389
|
],
|
|
373
390
|
};
|
|
374
|
-
}, [ labelPosition, openAs ] );
|
|
391
|
+
}, [ labelPosition, openAs, editVisibility ] );
|
|
375
392
|
|
|
376
393
|
return (
|
|
377
394
|
<DataForm< SamplePost >
|
|
@@ -86,7 +86,13 @@ const ValidationComponent = ( {
|
|
|
86
86
|
custom: 'sync' | 'async' | 'none';
|
|
87
87
|
pattern: boolean;
|
|
88
88
|
minMax: boolean;
|
|
89
|
-
layout:
|
|
89
|
+
layout:
|
|
90
|
+
| 'regular'
|
|
91
|
+
| 'panel-dropdown'
|
|
92
|
+
| 'panel-modal'
|
|
93
|
+
| 'card-collapsible'
|
|
94
|
+
| 'card-not-collapsible'
|
|
95
|
+
| 'details';
|
|
90
96
|
} ) => {
|
|
91
97
|
type ValidatedItem = {
|
|
92
98
|
text: string;
|
|
@@ -106,6 +112,7 @@ const ValidationComponent = ( {
|
|
|
106
112
|
password: string;
|
|
107
113
|
toggle?: boolean;
|
|
108
114
|
toggleGroup?: string;
|
|
115
|
+
combobox?: string;
|
|
109
116
|
date?: string;
|
|
110
117
|
dateRange?: string;
|
|
111
118
|
datetime?: string;
|
|
@@ -129,6 +136,7 @@ const ValidationComponent = ( {
|
|
|
129
136
|
password: 'secretpassword123',
|
|
130
137
|
toggle: undefined,
|
|
131
138
|
toggleGroup: undefined,
|
|
139
|
+
combobox: undefined,
|
|
132
140
|
date: undefined,
|
|
133
141
|
dateRange: undefined,
|
|
134
142
|
datetime: undefined,
|
|
@@ -242,6 +250,25 @@ const ValidationComponent = ( {
|
|
|
242
250
|
);
|
|
243
251
|
break;
|
|
244
252
|
|
|
253
|
+
case 'combobox':
|
|
254
|
+
promiseCache[ fieldId ] = new Promise( ( resolve ) =>
|
|
255
|
+
setTimeout(
|
|
256
|
+
() =>
|
|
257
|
+
resolve( [
|
|
258
|
+
{ value: 'apple', label: 'Apple' },
|
|
259
|
+
{ value: 'banana', label: 'Banana' },
|
|
260
|
+
{ value: 'cherry', label: 'Cherry' },
|
|
261
|
+
{ value: 'date', label: 'Date' },
|
|
262
|
+
{
|
|
263
|
+
value: 'elderberry',
|
|
264
|
+
label: 'Elderberry',
|
|
265
|
+
},
|
|
266
|
+
] ),
|
|
267
|
+
3500
|
|
268
|
+
)
|
|
269
|
+
);
|
|
270
|
+
break;
|
|
271
|
+
|
|
245
272
|
default:
|
|
246
273
|
throw new Error( `Unknown field ID: ${ fieldId }` );
|
|
247
274
|
}
|
|
@@ -364,6 +391,14 @@ const ValidationComponent = ( {
|
|
|
364
391
|
return null;
|
|
365
392
|
};
|
|
366
393
|
|
|
394
|
+
const customComboboxRule = ( value: ValidatedItem ) => {
|
|
395
|
+
if ( value.combobox !== 'apple' ) {
|
|
396
|
+
return 'Value must be Apple.';
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return null;
|
|
400
|
+
};
|
|
401
|
+
|
|
367
402
|
const customPasswordRule = ( value: ValidatedItem ) => {
|
|
368
403
|
if ( value.password.length < 8 ) {
|
|
369
404
|
return 'Password must be at least 8 characters long.';
|
|
@@ -768,6 +803,48 @@ const ValidationComponent = ( {
|
|
|
768
803
|
custom: maybeCustomRule( customToggleGroupRule ),
|
|
769
804
|
},
|
|
770
805
|
},
|
|
806
|
+
{
|
|
807
|
+
id: 'combobox',
|
|
808
|
+
type: 'text',
|
|
809
|
+
Edit: 'combobox',
|
|
810
|
+
label: 'Combobox',
|
|
811
|
+
placeholder: 'Search and select a fruit',
|
|
812
|
+
elements:
|
|
813
|
+
elements === 'async'
|
|
814
|
+
? undefined
|
|
815
|
+
: [
|
|
816
|
+
{ value: 'apple', label: 'Apple' },
|
|
817
|
+
{ value: 'banana', label: 'Banana' },
|
|
818
|
+
{ value: 'blueberry', label: 'Blueberry' },
|
|
819
|
+
{ value: 'cherry', label: 'Cherry' },
|
|
820
|
+
{ value: 'date', label: 'Date' },
|
|
821
|
+
{ value: 'elderberry', label: 'Elderberry' },
|
|
822
|
+
{ value: 'fig', label: 'Fig' },
|
|
823
|
+
{ value: 'grape', label: 'Grape' },
|
|
824
|
+
{ value: 'honeydew', label: 'Honeydew' },
|
|
825
|
+
{ value: 'kiwi', label: 'Kiwi' },
|
|
826
|
+
{ value: 'lemon', label: 'Lemon' },
|
|
827
|
+
{ value: 'mango', label: 'Mango' },
|
|
828
|
+
{ value: 'nectarine', label: 'Nectarine' },
|
|
829
|
+
{ value: 'orange', label: 'Orange' },
|
|
830
|
+
{ value: 'papaya', label: 'Papaya' },
|
|
831
|
+
{ value: 'pear', label: 'Pear' },
|
|
832
|
+
{ value: 'quince', label: 'Quince' },
|
|
833
|
+
{ value: 'raspberry', label: 'Raspberry' },
|
|
834
|
+
{ value: 'strawberry', label: 'Strawberry' },
|
|
835
|
+
{ value: 'tangerine', label: 'Tangerine' },
|
|
836
|
+
{ value: 'watermelon', label: 'Watermelon' },
|
|
837
|
+
],
|
|
838
|
+
getElements:
|
|
839
|
+
elements === 'async'
|
|
840
|
+
? getElements( 'combobox' )
|
|
841
|
+
: undefined,
|
|
842
|
+
isValid: {
|
|
843
|
+
required,
|
|
844
|
+
elements: elements !== 'none' ? true : false,
|
|
845
|
+
custom: maybeCustomRule( customComboboxRule ),
|
|
846
|
+
},
|
|
847
|
+
},
|
|
771
848
|
{
|
|
772
849
|
id: 'date',
|
|
773
850
|
type: 'date',
|
|
@@ -800,7 +877,7 @@ const ValidationComponent = ( {
|
|
|
800
877
|
},
|
|
801
878
|
},
|
|
802
879
|
];
|
|
803
|
-
}, [ elements, custom,
|
|
880
|
+
}, [ elements, custom, pattern, minMax, getElements, required ] );
|
|
804
881
|
|
|
805
882
|
const form = useMemo( () => {
|
|
806
883
|
if ( layout === 'regular' ) {
|
|
@@ -853,6 +930,7 @@ const ValidationComponent = ( {
|
|
|
853
930
|
'password',
|
|
854
931
|
'textarea',
|
|
855
932
|
'select',
|
|
933
|
+
'combobox',
|
|
856
934
|
'textWithRadio',
|
|
857
935
|
'boolean',
|
|
858
936
|
'toggle',
|
|
@@ -885,7 +963,7 @@ const ValidationComponent = ( {
|
|
|
885
963
|
{
|
|
886
964
|
id: 'selectFields',
|
|
887
965
|
label: 'Selection Fields',
|
|
888
|
-
children: [ 'select', 'textWithRadio' ],
|
|
966
|
+
children: [ 'select', 'combobox', 'textWithRadio' ],
|
|
889
967
|
},
|
|
890
968
|
{
|
|
891
969
|
id: 'booleanFields',
|
|
@@ -901,9 +979,16 @@ const ValidationComponent = ( {
|
|
|
901
979
|
},
|
|
902
980
|
];
|
|
903
981
|
|
|
904
|
-
if ( layout === 'panel' ) {
|
|
982
|
+
if ( layout === 'panel-dropdown' ) {
|
|
905
983
|
return {
|
|
906
|
-
layout: { type: 'panel' as const },
|
|
984
|
+
layout: { type: 'panel' as const, openAs: 'dropdown' as const },
|
|
985
|
+
fields: groupedFields,
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
if ( layout === 'panel-modal' ) {
|
|
990
|
+
return {
|
|
991
|
+
layout: { type: 'panel' as const, openAs: 'modal' as const },
|
|
907
992
|
fields: groupedFields,
|
|
908
993
|
};
|
|
909
994
|
}
|
|
@@ -915,8 +1000,16 @@ const ValidationComponent = ( {
|
|
|
915
1000
|
};
|
|
916
1001
|
}
|
|
917
1002
|
|
|
1003
|
+
if ( layout === 'card-collapsible' ) {
|
|
1004
|
+
return {
|
|
1005
|
+
layout: { type: 'card' as const },
|
|
1006
|
+
fields: groupedFields,
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// card-not-collapsible
|
|
918
1011
|
return {
|
|
919
|
-
layout: { type: 'card' as const },
|
|
1012
|
+
layout: { type: 'card' as const, isCollapsible: false },
|
|
920
1013
|
fields: groupedFields,
|
|
921
1014
|
};
|
|
922
1015
|
}, [ layout ] );
|
|
@@ -925,7 +1018,7 @@ const ValidationComponent = ( {
|
|
|
925
1018
|
|
|
926
1019
|
return (
|
|
927
1020
|
<form>
|
|
928
|
-
<Stack direction="column" align="start" gap="
|
|
1021
|
+
<Stack direction="column" align="start" gap="3xl">
|
|
929
1022
|
<DataForm< ValidatedItem >
|
|
930
1023
|
data={ post }
|
|
931
1024
|
fields={ _fields }
|
|
@@ -511,9 +511,9 @@ describe( 'DataForm component', () => {
|
|
|
511
511
|
/>
|
|
512
512
|
);
|
|
513
513
|
|
|
514
|
-
const
|
|
514
|
+
const titleButton = fieldsSelector.title.view();
|
|
515
515
|
const user = await userEvent.setup();
|
|
516
|
-
await user.click(
|
|
516
|
+
await user.click( titleButton );
|
|
517
517
|
const titleEditField = screen.getByText(
|
|
518
518
|
'This is the Title Field'
|
|
519
519
|
);
|