@wordpress/dataviews 11.4.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 +34 -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/date.cjs +23 -9
- 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 +3 -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 +2 -0
- package/build/components/dataform-layouts/card/index.cjs.map +2 -2
- 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 +1 -1
- package/build/components/dataform-layouts/details/index.cjs.map +1 -1
- 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 +81 -66
- package/build/components/dataform-layouts/panel/dropdown.cjs.map +3 -3
- package/build/components/dataform-layouts/panel/index.cjs +13 -177
- package/build/components/dataform-layouts/panel/index.cjs.map +3 -3
- package/build/components/dataform-layouts/panel/modal.cjs +15 -11
- 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/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/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/date.mjs +23 -9
- 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 +3 -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 +2 -0
- 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 +1 -1
- package/build-module/components/dataform-layouts/details/index.mjs.map +1 -1
- 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 +83 -68
- package/build-module/components/dataform-layouts/panel/dropdown.mjs.map +2 -2
- package/build-module/components/dataform-layouts/panel/index.mjs +14 -178
- package/build-module/components/dataform-layouts/panel/index.mjs.map +2 -2
- package/build-module/components/dataform-layouts/panel/modal.mjs +15 -11
- 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/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-style/style-rtl.css +144 -217
- package/build-style/style.css +144 -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/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 +1 -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/normalize-form.d.ts.map +1 -1
- package/build-types/components/dataform-layouts/panel/dropdown.d.ts +2 -13
- 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 -11
- 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/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/index.story.d.ts +9 -1
- 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/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/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 +2689 -2167
- package/package.json +21 -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/date.tsx +24 -16
- 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 +3 -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 +2 -0
- package/src/components/dataform-layouts/data-form-layout.tsx +18 -4
- package/src/components/dataform-layouts/details/index.tsx +1 -1
- 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 +97 -96
- package/src/components/dataform-layouts/panel/index.tsx +10 -245
- package/src/components/dataform-layouts/panel/modal.tsx +24 -22
- 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/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.tsx +5 -5
- package/src/dataform/stories/index.story.tsx +6 -1
- package/src/dataform/stories/layout-panel.tsx +19 -2
- package/src/dataform/stories/validation.tsx +2 -2
- 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 +99 -5
- package/src/hooks/test/use-form-validity.ts +303 -178
- package/src/hooks/use-form-validity.ts +85 -36
- package/src/style.scss +0 -2
- package/src/types/dataform.ts +5 -0
- package/src/types/field-api.ts +4 -0
|
@@ -43,6 +43,7 @@ var import_data_form_layout = require("../data-form-layout.cjs");
|
|
|
43
43
|
var import_normalize_form = require("../normalize-form.cjs");
|
|
44
44
|
var import_summary_button = __toESM(require("./summary-button.cjs"));
|
|
45
45
|
var import_use_report_validity = __toESM(require("../../../hooks/use-report-validity.cjs"));
|
|
46
|
+
var import_use_field_from_form_field = __toESM(require("./utils/use-field-from-form-field.cjs"));
|
|
46
47
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
48
|
function DropdownHeader({
|
|
48
49
|
title,
|
|
@@ -53,8 +54,8 @@ function DropdownHeader({
|
|
|
53
54
|
{
|
|
54
55
|
direction: "column",
|
|
55
56
|
className: "dataforms-layouts-panel__dropdown-header",
|
|
56
|
-
gap: "
|
|
57
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "row", gap: "
|
|
57
|
+
gap: "lg",
|
|
58
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "row", gap: "sm", align: "center", children: [
|
|
58
59
|
title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalHeading, { level: 2, size: 13, children: title }),
|
|
59
60
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalSpacer, { style: { flex: 1 } }),
|
|
60
61
|
onClose && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -82,15 +83,26 @@ function PanelDropdown({
|
|
|
82
83
|
data,
|
|
83
84
|
field,
|
|
84
85
|
onChange,
|
|
85
|
-
validity
|
|
86
|
-
labelPosition = "side",
|
|
87
|
-
summaryFields,
|
|
88
|
-
fieldDefinition,
|
|
89
|
-
popoverAnchor,
|
|
90
|
-
onClose: onCloseCallback,
|
|
91
|
-
touched
|
|
86
|
+
validity
|
|
92
87
|
}) {
|
|
93
|
-
const
|
|
88
|
+
const [touched, setTouched] = (0, import_element.useState)(false);
|
|
89
|
+
const [popoverAnchor, setPopoverAnchor] = (0, import_element.useState)(
|
|
90
|
+
null
|
|
91
|
+
);
|
|
92
|
+
const popoverProps = (0, import_element.useMemo)(
|
|
93
|
+
() => ({
|
|
94
|
+
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
95
|
+
// move around when the label changes.
|
|
96
|
+
anchor: popoverAnchor,
|
|
97
|
+
placement: "left-start",
|
|
98
|
+
offset: 36,
|
|
99
|
+
shift: true
|
|
100
|
+
}),
|
|
101
|
+
[popoverAnchor]
|
|
102
|
+
);
|
|
103
|
+
const [dialogRef, dialogProps] = (0, import_compose.__experimentalUseDialog)({
|
|
104
|
+
focusOnMount: "firstInputElement"
|
|
105
|
+
});
|
|
94
106
|
const form = (0, import_element.useMemo)(
|
|
95
107
|
() => ({
|
|
96
108
|
layout: import_normalize_form.DEFAULT_LAYOUT,
|
|
@@ -110,69 +122,72 @@ function PanelDropdown({
|
|
|
110
122
|
}
|
|
111
123
|
return { [field.id]: validity };
|
|
112
124
|
}, [validity, field]);
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
anchor: popoverAnchor,
|
|
118
|
-
placement: "left-start",
|
|
119
|
-
offset: 36,
|
|
120
|
-
shift: true
|
|
121
|
-
}),
|
|
122
|
-
[popoverAnchor]
|
|
123
|
-
);
|
|
124
|
-
const focusOnMountRef = (0, import_compose.useFocusOnMount)("firstInputElement");
|
|
125
|
+
const { fieldDefinition, fieldLabel, summaryFields } = (0, import_use_field_from_form_field.default)(field);
|
|
126
|
+
if (!fieldDefinition) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
125
129
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
126
|
-
|
|
130
|
+
"div",
|
|
127
131
|
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (!willOpen) {
|
|
133
|
-
onCloseCallback?.();
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
toggleProps: {
|
|
137
|
-
size: "compact",
|
|
138
|
-
variant: "tertiary",
|
|
139
|
-
tooltipPosition: "middle left"
|
|
140
|
-
},
|
|
141
|
-
renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
142
|
-
import_summary_button.default,
|
|
132
|
+
ref: setPopoverAnchor,
|
|
133
|
+
className: "dataforms-layouts-panel__field-dropdown-anchor",
|
|
134
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
135
|
+
import_components.Dropdown,
|
|
143
136
|
{
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
137
|
+
contentClassName: "dataforms-layouts-panel__field-dropdown",
|
|
138
|
+
popoverProps,
|
|
139
|
+
focusOnMount: false,
|
|
140
|
+
onToggle: (willOpen) => {
|
|
141
|
+
if (!willOpen) {
|
|
142
|
+
setTouched(true);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
146
|
+
import_summary_button.default,
|
|
147
|
+
{
|
|
148
|
+
data,
|
|
149
|
+
field,
|
|
150
|
+
fieldLabel,
|
|
151
|
+
summaryFields,
|
|
152
|
+
validity,
|
|
153
|
+
touched,
|
|
154
|
+
disabled: fieldDefinition.readOnly === true,
|
|
155
|
+
onClick: onToggle,
|
|
156
|
+
"aria-expanded": isOpen
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
161
|
+
DropdownHeader,
|
|
162
|
+
{
|
|
163
|
+
title: fieldLabel,
|
|
164
|
+
onClose
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
|
+
import_data_form_layout.DataFormLayout,
|
|
164
169
|
{
|
|
165
170
|
data,
|
|
166
|
-
|
|
171
|
+
form,
|
|
167
172
|
onChange,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
validity: formValidity,
|
|
174
|
+
children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
175
|
+
FieldLayout,
|
|
176
|
+
{
|
|
177
|
+
data,
|
|
178
|
+
field: childField,
|
|
179
|
+
onChange,
|
|
180
|
+
hideLabelFromVision: (form?.fields ?? []).length < 2,
|
|
181
|
+
markWhenOptional,
|
|
182
|
+
validity: childFieldValidity
|
|
183
|
+
},
|
|
184
|
+
childField.id
|
|
185
|
+
)
|
|
186
|
+
}
|
|
172
187
|
)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
188
|
+
] }) })
|
|
189
|
+
}
|
|
190
|
+
)
|
|
176
191
|
}
|
|
177
192
|
);
|
|
178
193
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/dataform-layouts/panel/dropdown.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tDropdown,\n\tButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useRef } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAKO;AACP,kBAAmB;AACnB,
|
|
6
|
-
"names": ["Heading", "Spacer", "useReportValidity", "SummaryButton"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHeading as Heading,\n\t__experimentalSpacer as Spacer,\n\tDropdown,\n\tButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo, useRef, useState } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tFieldLayoutProps,\n\tNormalizedForm,\n\tFormValidity,\n} from '../../../types';\nimport { DataFormLayout } from '../data-form-layout';\nimport { DEFAULT_LAYOUT } from '../normalize-form';\nimport SummaryButton from './summary-button';\nimport useReportValidity from '../../../hooks/use-report-validity';\nimport useFieldFromFormField from './utils/use-field-from-form-field';\n\nfunction DropdownHeader( {\n\ttitle,\n\tonClose,\n}: {\n\ttitle?: string;\n\tonClose: () => void;\n} ) {\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tclassName=\"dataforms-layouts-panel__dropdown-header\"\n\t\t\tgap=\"lg\"\n\t\t>\n\t\t\t<Stack direction=\"row\" gap=\"sm\" align=\"center\">\n\t\t\t\t{ title && (\n\t\t\t\t\t<Heading level={ 2 } size={ 13 }>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</Heading>\n\t\t\t\t) }\n\t\t\t\t<Spacer style={ { flex: 1 } } />\n\t\t\t\t{ onClose && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</Stack>\n\t\t</Stack>\n\t);\n}\n\nfunction DropdownContentWithValidation( {\n\ttouched,\n\tchildren,\n}: {\n\ttouched: boolean;\n\tchildren: React.ReactNode;\n} ) {\n\tconst ref = useRef< HTMLDivElement >( null );\n\tuseReportValidity( ref, touched );\n\treturn <div ref={ ref }>{ children }</div>;\n}\n\nfunction PanelDropdown< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\tvalidity,\n}: FieldLayoutProps< Item > ) {\n\tconst [ touched, setTouched ] = useState( false );\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(\n\t\tnull\n\t);\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t// Anchor the popover to the middle of the entire row so that it doesn't\n\t\t\t// move around when the label changes.\n\t\t\tanchor: popoverAnchor,\n\t\t\tplacement: 'left-start',\n\t\t\toffset: 36,\n\t\t\tshift: true,\n\t\t} ),\n\t\t[ popoverAnchor ]\n\t);\n\tconst [ dialogRef, dialogProps ] = useDialog( {\n\t\tfocusOnMount: 'firstInputElement',\n\t} );\n\n\tconst form: NormalizedForm = useMemo(\n\t\t() => ( {\n\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\tfields: !! field.children\n\t\t\t\t? field.children\n\t\t\t\t: // If not explicit children return the field id itself.\n\t\t\t\t [ { id: field.id, layout: DEFAULT_LAYOUT } ],\n\t\t} ),\n\t\t[ field ]\n\t);\n\tconst formValidity = useMemo( (): FormValidity => {\n\t\tif ( validity === undefined ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif ( !! field.children ) {\n\t\t\treturn validity?.children;\n\t\t}\n\n\t\treturn { [ field.id ]: validity };\n\t}, [ validity, field ] );\n\n\tconst { fieldDefinition, fieldLabel, summaryFields } =\n\t\tuseFieldFromFormField( field );\n\tif ( ! fieldDefinition ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={ setPopoverAnchor }\n\t\t\tclassName=\"dataforms-layouts-panel__field-dropdown-anchor\"\n\t\t>\n\t\t\t<Dropdown\n\t\t\t\tcontentClassName=\"dataforms-layouts-panel__field-dropdown\"\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tfocusOnMount={ false }\n\t\t\t\tonToggle={ ( willOpen ) => {\n\t\t\t\t\tif ( ! willOpen ) {\n\t\t\t\t\t\tsetTouched( true );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<SummaryButton\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\tfieldLabel={ fieldLabel }\n\t\t\t\t\t\tsummaryFields={ summaryFields }\n\t\t\t\t\t\tvalidity={ validity }\n\t\t\t\t\t\ttouched={ touched }\n\t\t\t\t\t\tdisabled={ fieldDefinition.readOnly === true }\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<DropdownContentWithValidation touched={ touched }>\n\t\t\t\t\t\t<div ref={ dialogRef } { ...dialogProps }>\n\t\t\t\t\t\t\t<DropdownHeader\n\t\t\t\t\t\t\t\ttitle={ fieldLabel }\n\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<DataFormLayout\n\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\tform={ form }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tvalidity={ formValidity }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ (\n\t\t\t\t\t\t\t\t\tFieldLayout,\n\t\t\t\t\t\t\t\t\tchildField,\n\t\t\t\t\t\t\t\t\tchildFieldValidity,\n\t\t\t\t\t\t\t\t\tmarkWhenOptional\n\t\t\t\t\t\t\t\t) => (\n\t\t\t\t\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\t\t\t\t\tkey={ childField.id }\n\t\t\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\t\t\tfield={ childField }\n\t\t\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\t\t\thideLabelFromVision={\n\t\t\t\t\t\t\t\t\t\t\t( form?.fields ?? [] ).length < 2\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t\t\t\t\t\t\t\tvalidity={ childFieldValidity }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</DataFormLayout>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</DropdownContentWithValidation>\n\t\t\t\t) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport default PanelDropdown;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAKO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AA,gBACA,OAAQ;AAAA,gBACR;AAAA;AAAA,YACD;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,UAAW;AAAA,gBAET,WACD,aACA,YACA,oBACA,qBAEA;AAAA,kBAAC;AAAA;AAAA,oBAEA;AAAA,oBACA,OAAQ;AAAA,oBACR;AAAA,oBACA,sBACG,MAAM,UAAU,CAAC,GAAI,SAAS;AAAA,oBAEjC;AAAA,oBACA,UAAW;AAAA;AAAA,kBARL,WAAW;AAAA,gBASlB;AAAA;AAAA,YAEF;AAAA,aACD,GACD;AAAA;AAAA,MAEF;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,mBAAQ;",
|
|
6
|
+
"names": ["Heading", "Spacer", "useReportValidity", "useDialog", "useFieldFromFormField", "SummaryButton"]
|
|
7
7
|
}
|
|
@@ -33,198 +33,34 @@ __export(panel_exports, {
|
|
|
33
33
|
default: () => FormPanelField
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(panel_exports);
|
|
36
|
-
var import_clsx = __toESM(require("clsx"));
|
|
37
|
-
var import_components = require("@wordpress/components");
|
|
38
|
-
var import_element = require("@wordpress/element");
|
|
39
|
-
var import_icons = require("@wordpress/icons");
|
|
40
|
-
var import_ui = require("@wordpress/ui");
|
|
41
|
-
var import_dataform_context = __toESM(require("../../dataform-context/index.cjs"));
|
|
42
|
-
var import_dropdown = __toESM(require("./dropdown.cjs"));
|
|
43
36
|
var import_modal = __toESM(require("./modal.cjs"));
|
|
44
|
-
var
|
|
37
|
+
var import_dropdown = __toESM(require("./dropdown.cjs"));
|
|
45
38
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
|
-
function getFirstValidationError(validity) {
|
|
47
|
-
if (!validity) {
|
|
48
|
-
return void 0;
|
|
49
|
-
}
|
|
50
|
-
const validityRules = Object.keys(validity).filter(
|
|
51
|
-
(key) => key !== "children"
|
|
52
|
-
);
|
|
53
|
-
for (const key of validityRules) {
|
|
54
|
-
const rule = validity[key];
|
|
55
|
-
if (rule === void 0) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (rule.type === "invalid") {
|
|
59
|
-
if (rule.message) {
|
|
60
|
-
return rule.message;
|
|
61
|
-
}
|
|
62
|
-
if (key === "required") {
|
|
63
|
-
return "A required field is empty";
|
|
64
|
-
}
|
|
65
|
-
return "Unidentified validation error";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (validity.children) {
|
|
69
|
-
for (const childValidity of Object.values(validity.children)) {
|
|
70
|
-
const childError = getFirstValidationError(childValidity);
|
|
71
|
-
if (childError) {
|
|
72
|
-
return childError;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return void 0;
|
|
77
|
-
}
|
|
78
|
-
var getFieldDefinition = (field, fields) => {
|
|
79
|
-
const fieldDefinition = fields.find((_field) => _field.id === field.id);
|
|
80
|
-
if (!fieldDefinition) {
|
|
81
|
-
return fields.find((_field) => {
|
|
82
|
-
if (!!field.children) {
|
|
83
|
-
const simpleChildren = field.children.filter(
|
|
84
|
-
(child) => !child.children
|
|
85
|
-
);
|
|
86
|
-
if (simpleChildren.length === 0) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
return _field.id === simpleChildren[0].id;
|
|
90
|
-
}
|
|
91
|
-
return _field.id === field.id;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
return fieldDefinition;
|
|
95
|
-
};
|
|
96
|
-
var getFieldDefinitionAndSummaryFields = (layout, field, fields) => {
|
|
97
|
-
const summaryFields = (0, import_get_summary_fields.getSummaryFields)(layout.summary, fields);
|
|
98
|
-
const fieldDefinition = getFieldDefinition(field, fields);
|
|
99
|
-
if (summaryFields.length === 0) {
|
|
100
|
-
return {
|
|
101
|
-
summaryFields: fieldDefinition ? [fieldDefinition] : [],
|
|
102
|
-
fieldDefinition
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
summaryFields,
|
|
107
|
-
fieldDefinition
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
39
|
function FormPanelField({
|
|
111
40
|
data,
|
|
112
41
|
field,
|
|
113
42
|
onChange,
|
|
114
43
|
validity
|
|
115
44
|
}) {
|
|
116
|
-
const { fields } = (0, import_element.useContext)(import_dataform_context.default);
|
|
117
45
|
const layout = field.layout;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
46
|
+
if (layout.openAs === "modal") {
|
|
47
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
48
|
+
import_modal.default,
|
|
49
|
+
{
|
|
50
|
+
data,
|
|
51
|
+
field,
|
|
52
|
+
onChange,
|
|
53
|
+
validity
|
|
54
|
+
}
|
|
55
|
+
);
|
|
126
56
|
}
|
|
127
|
-
|
|
128
|
-
const errorMessage = getFirstValidationError(validity);
|
|
129
|
-
const showError = touched && !!errorMessage;
|
|
130
|
-
const labelClassName = (0, import_clsx.default)(
|
|
131
|
-
"dataforms-layouts-panel__field-label",
|
|
132
|
-
`dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
|
|
133
|
-
{ "has-error": showError }
|
|
134
|
-
);
|
|
135
|
-
const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
|
|
136
|
-
const labelContent = showError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
137
|
-
import_ui.Stack,
|
|
138
|
-
{
|
|
139
|
-
direction: "row",
|
|
140
|
-
gap: "xs",
|
|
141
|
-
className: "dataforms-layouts-panel__field-label-error-content",
|
|
142
|
-
justify: "flex-start",
|
|
143
|
-
children: [
|
|
144
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Icon, { icon: import_icons.error, size: 16 }),
|
|
145
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: fieldLabel })
|
|
146
|
-
]
|
|
147
|
-
}
|
|
148
|
-
) }) : fieldLabel;
|
|
149
|
-
const renderedControl = layout.openAs === "modal" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
150
|
-
import_modal.default,
|
|
151
|
-
{
|
|
152
|
-
data,
|
|
153
|
-
field,
|
|
154
|
-
onChange,
|
|
155
|
-
labelPosition,
|
|
156
|
-
summaryFields,
|
|
157
|
-
fieldDefinition,
|
|
158
|
-
onClose: handleClose,
|
|
159
|
-
touched
|
|
160
|
-
}
|
|
161
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
162
58
|
import_dropdown.default,
|
|
163
59
|
{
|
|
164
60
|
data,
|
|
165
61
|
field,
|
|
166
62
|
onChange,
|
|
167
|
-
validity
|
|
168
|
-
labelPosition,
|
|
169
|
-
summaryFields,
|
|
170
|
-
fieldDefinition,
|
|
171
|
-
popoverAnchor,
|
|
172
|
-
onClose: handleClose,
|
|
173
|
-
touched
|
|
174
|
-
}
|
|
175
|
-
);
|
|
176
|
-
if (labelPosition === "top") {
|
|
177
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
178
|
-
import_ui.Stack,
|
|
179
|
-
{
|
|
180
|
-
direction: "column",
|
|
181
|
-
className: "dataforms-layouts-panel__field",
|
|
182
|
-
children: [
|
|
183
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
184
|
-
"div",
|
|
185
|
-
{
|
|
186
|
-
className: labelClassName,
|
|
187
|
-
style: { paddingBottom: 0 },
|
|
188
|
-
children: labelContent
|
|
189
|
-
}
|
|
190
|
-
),
|
|
191
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl })
|
|
192
|
-
]
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
if (labelPosition === "none") {
|
|
197
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
198
|
-
import_ui.Stack,
|
|
199
|
-
{
|
|
200
|
-
direction: "row",
|
|
201
|
-
gap: "xs",
|
|
202
|
-
className: "dataforms-layouts-panel__field dataforms-layouts-panel__field--label-position-none",
|
|
203
|
-
children: [
|
|
204
|
-
showError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
205
|
-
import_components.Icon,
|
|
206
|
-
{
|
|
207
|
-
className: "dataforms-layouts-panel__field-label-error-content",
|
|
208
|
-
icon: import_icons.error,
|
|
209
|
-
size: 16
|
|
210
|
-
}
|
|
211
|
-
) }),
|
|
212
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl })
|
|
213
|
-
]
|
|
214
|
-
}
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
218
|
-
import_ui.Stack,
|
|
219
|
-
{
|
|
220
|
-
direction: "row",
|
|
221
|
-
gap: "xs",
|
|
222
|
-
ref: setPopoverAnchor,
|
|
223
|
-
className: "dataforms-layouts-panel__field",
|
|
224
|
-
children: [
|
|
225
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: labelClassName, children: labelContent }),
|
|
226
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl })
|
|
227
|
-
]
|
|
63
|
+
validity
|
|
228
64
|
}
|
|
229
65
|
);
|
|
230
66
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/dataform-layouts/panel/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n *
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { FieldLayoutProps, NormalizedPanelLayout } from '../../../types';\nimport PanelModal from './modal';\nimport PanelDropdown from './dropdown';\n\nexport default function FormPanelField< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\tvalidity,\n}: FieldLayoutProps< Item > ) {\n\tconst layout = field.layout as NormalizedPanelLayout;\n\n\tif ( layout.openAs === 'modal' ) {\n\t\treturn (\n\t\t\t<PanelModal\n\t\t\t\tdata={ data }\n\t\t\t\tfield={ field }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalidity={ validity }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<PanelDropdown\n\t\t\tdata={ data }\n\t\t\tfield={ field }\n\t\t\tonChange={ onChange }\n\t\t\tvalidity={ validity }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAAuB;AACvB,sBAA0B;AAYvB;AAVY,SAAR,eAAyC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA8B;AAC7B,QAAM,SAAS,MAAM;AAErB,MAAK,OAAO,WAAW,SAAU;AAChC,WACC;AAAA,MAAC,aAAAA;AAAA,MAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,EAEF;AAEA,SACC;AAAA,IAAC,gBAAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["PanelModal", "PanelDropdown"]
|
|
7
7
|
}
|
|
@@ -45,6 +45,7 @@ var import_summary_button = __toESM(require("./summary-button.cjs"));
|
|
|
45
45
|
var import_use_form_validity = __toESM(require("../../../hooks/use-form-validity.cjs"));
|
|
46
46
|
var import_use_report_validity = __toESM(require("../../../hooks/use-report-validity.cjs"));
|
|
47
47
|
var import_dataform_context = __toESM(require("../../dataform-context/index.cjs"));
|
|
48
|
+
var import_use_field_from_form_field = __toESM(require("./utils/use-field-from-form-field.cjs"));
|
|
48
49
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
50
|
function ModalContent({
|
|
50
51
|
data,
|
|
@@ -116,13 +117,14 @@ function ModalContent({
|
|
|
116
117
|
form,
|
|
117
118
|
onChange: handleOnChange,
|
|
118
119
|
validity,
|
|
119
|
-
children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
120
|
+
children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
120
121
|
FieldLayout,
|
|
121
122
|
{
|
|
122
123
|
data: modalData,
|
|
123
124
|
field: childField,
|
|
124
125
|
onChange: handleOnChange,
|
|
125
126
|
hideLabelFromVision: form.fields.length < 2,
|
|
127
|
+
markWhenOptional,
|
|
126
128
|
validity: childFieldValidity
|
|
127
129
|
},
|
|
128
130
|
childField.id
|
|
@@ -134,7 +136,7 @@ function ModalContent({
|
|
|
134
136
|
{
|
|
135
137
|
direction: "row",
|
|
136
138
|
className: "dataforms-layouts-panel__modal-footer",
|
|
137
|
-
gap: "
|
|
139
|
+
gap: "md",
|
|
138
140
|
children: [
|
|
139
141
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalSpacer, { style: { flex: 1 } }),
|
|
140
142
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -166,26 +168,28 @@ function PanelModal({
|
|
|
166
168
|
data,
|
|
167
169
|
field,
|
|
168
170
|
onChange,
|
|
169
|
-
|
|
170
|
-
summaryFields,
|
|
171
|
-
fieldDefinition,
|
|
172
|
-
onClose: onCloseCallback,
|
|
173
|
-
touched
|
|
171
|
+
validity
|
|
174
172
|
}) {
|
|
173
|
+
const [touched, setTouched] = (0, import_element.useState)(false);
|
|
175
174
|
const [isOpen, setIsOpen] = (0, import_element.useState)(false);
|
|
176
|
-
const fieldLabel =
|
|
175
|
+
const { fieldDefinition, fieldLabel, summaryFields } = (0, import_use_field_from_form_field.default)(field);
|
|
176
|
+
if (!fieldDefinition) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
177
179
|
const handleClose = () => {
|
|
178
180
|
setIsOpen(false);
|
|
179
|
-
|
|
181
|
+
setTouched(true);
|
|
180
182
|
};
|
|
181
183
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
182
184
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
183
185
|
import_summary_button.default,
|
|
184
186
|
{
|
|
185
|
-
summaryFields,
|
|
186
187
|
data,
|
|
187
|
-
|
|
188
|
+
field,
|
|
188
189
|
fieldLabel,
|
|
190
|
+
summaryFields,
|
|
191
|
+
validity,
|
|
192
|
+
touched,
|
|
189
193
|
disabled: fieldDefinition.readOnly === true,
|
|
190
194
|
onClick: () => setIsOpen(true),
|
|
191
195
|
"aria-expanded": isOpen
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/dataform-layouts/panel/modal.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport deepMerge from 'deepmerge';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalSpacer as Spacer,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useContext, useMemo, useRef, useState } from '@wordpress/element';\nimport { useFocusOnMount, useMergeRefs } from '@wordpress/compose';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tField,\n\tNormalizedForm,\n\tNormalizedFormField,\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAsB;AAKtB,wBAIO;AACP,kBAAmB;AACnB,qBAAsD;AACtD,qBAA8C;AAC9C,gBAAsB;AAWtB,8BAA+B;AAC/B,4BAA+B;AAC/B,4BAA0B;AAC1B,+BAA4B;AAC5B,iCAA8B;AAC9B,8BAA4B;
|
|
6
|
-
"names": ["DataFormContext", "deepMerge", "useFormValidity", "useReportValidity", "Spacer", "SummaryButton"]
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport deepMerge from 'deepmerge';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalSpacer as Spacer,\n\tButton,\n\tModal,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useContext, useMemo, useRef, useState } from '@wordpress/element';\nimport { useFocusOnMount, useMergeRefs } from '@wordpress/compose';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tField,\n\tNormalizedForm,\n\tNormalizedFormField,\n\tFieldLayoutProps,\n} from '../../../types';\nimport { DataFormLayout } from '../data-form-layout';\nimport { DEFAULT_LAYOUT } from '../normalize-form';\nimport SummaryButton from './summary-button';\nimport useFormValidity from '../../../hooks/use-form-validity';\nimport useReportValidity from '../../../hooks/use-report-validity';\nimport DataFormContext from '../../dataform-context';\nimport useFieldFromFormField from './utils/use-field-from-form-field';\n\nfunction ModalContent< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\tfieldLabel,\n\tonClose,\n\ttouched,\n}: {\n\tdata: Item;\n\tfield: NormalizedFormField;\n\tonChange: ( data: Partial< Item > ) => void;\n\tonClose: () => void;\n\tfieldLabel: string;\n\ttouched: boolean;\n} ) {\n\tconst { fields } = useContext( DataFormContext );\n\tconst [ changes, setChanges ] = useState< Partial< Item > >( {} );\n\tconst modalData = useMemo( () => {\n\t\treturn deepMerge( data, changes, {\n\t\t\tarrayMerge: ( target, source ) => source,\n\t\t} );\n\t}, [ data, changes ] );\n\n\tconst form: NormalizedForm = useMemo(\n\t\t() => ( {\n\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\tfields: !! field.children\n\t\t\t\t? field.children\n\t\t\t\t: // If not explicit children return the field id itself.\n\t\t\t\t [ { id: field.id, layout: DEFAULT_LAYOUT } ],\n\t\t} ),\n\t\t[ field ]\n\t);\n\n\tconst fieldsAsFieldType: Field< Item >[] = fields.map( ( f ) => ( {\n\t\t...f,\n\t\tEdit: f.Edit === null ? undefined : f.Edit,\n\t\tisValid: {\n\t\t\trequired: f.isValid.required?.constraint,\n\t\t\telements: f.isValid.elements?.constraint,\n\t\t\tmin: f.isValid.min?.constraint,\n\t\t\tmax: f.isValid.max?.constraint,\n\t\t\tpattern: f.isValid.pattern?.constraint,\n\t\t\tminLength: f.isValid.minLength?.constraint,\n\t\t\tmaxLength: f.isValid.maxLength?.constraint,\n\t\t},\n\t} ) );\n\tconst { validity } = useFormValidity( modalData, fieldsAsFieldType, form );\n\n\tconst onApply = () => {\n\t\tonChange( changes );\n\t\tonClose();\n\t};\n\n\tconst handleOnChange = ( newValue: Partial< Item > ) => {\n\t\tsetChanges( ( prev ) =>\n\t\t\tdeepMerge( prev, newValue, {\n\t\t\t\tarrayMerge: ( target, source ) => source,\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst focusOnMountRef = useFocusOnMount( 'firstInputElement' );\n\tconst contentRef = useRef< HTMLDivElement >( null );\n\tconst mergedRef = useMergeRefs( [ focusOnMountRef, contentRef ] );\n\n\t// When the modal is opened after being previously closed (touched),\n\t// trigger reportValidity to show field-level errors.\n\tuseReportValidity( contentRef, touched );\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"dataforms-layouts-panel__modal\"\n\t\t\tonRequestClose={ onClose }\n\t\t\tisFullScreen={ false }\n\t\t\ttitle={ fieldLabel }\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<div ref={ mergedRef }>\n\t\t\t\t<DataFormLayout\n\t\t\t\t\tdata={ modalData }\n\t\t\t\t\tform={ form }\n\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\tvalidity={ validity }\n\t\t\t\t>\n\t\t\t\t\t{ (\n\t\t\t\t\t\tFieldLayout,\n\t\t\t\t\t\tchildField,\n\t\t\t\t\t\tchildFieldValidity,\n\t\t\t\t\t\tmarkWhenOptional\n\t\t\t\t\t) => (\n\t\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\t\tkey={ childField.id }\n\t\t\t\t\t\t\tdata={ modalData }\n\t\t\t\t\t\t\tfield={ childField }\n\t\t\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\t\t\thideLabelFromVision={ form.fields.length < 2 }\n\t\t\t\t\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t\t\t\t\tvalidity={ childFieldValidity }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</DataFormLayout>\n\t\t\t</div>\n\t\t\t<Stack\n\t\t\t\tdirection=\"row\"\n\t\t\t\tclassName=\"dataforms-layouts-panel__modal-footer\"\n\t\t\t\tgap=\"md\"\n\t\t\t>\n\t\t\t\t<Spacer style={ { flex: 1 } } />\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tonClick={ onApply }\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t</Button>\n\t\t\t</Stack>\n\t\t</Modal>\n\t);\n}\n\nfunction PanelModal< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\tvalidity,\n}: FieldLayoutProps< Item > ) {\n\tconst [ touched, setTouched ] = useState( false );\n\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\n\tconst { fieldDefinition, fieldLabel, summaryFields } =\n\t\tuseFieldFromFormField( field );\n\tif ( ! fieldDefinition ) {\n\t\treturn null;\n\t}\n\n\tconst handleClose = () => {\n\t\tsetIsOpen( false );\n\t\tsetTouched( true );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SummaryButton\n\t\t\t\tdata={ data }\n\t\t\t\tfield={ field }\n\t\t\t\tfieldLabel={ fieldLabel }\n\t\t\t\tsummaryFields={ summaryFields }\n\t\t\t\tvalidity={ validity }\n\t\t\t\ttouched={ touched }\n\t\t\t\tdisabled={ fieldDefinition.readOnly === true }\n\t\t\t\tonClick={ () => setIsOpen( true ) }\n\t\t\t\taria-expanded={ isOpen }\n\t\t\t/>\n\t\t\t{ isOpen && (\n\t\t\t\t<ModalContent\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tfield={ field }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tfieldLabel={ fieldLabel ?? '' }\n\t\t\t\t\tonClose={ handleClose }\n\t\t\t\t\ttouched={ touched }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default PanelModal;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAsB;AAKtB,wBAIO;AACP,kBAAmB;AACnB,qBAAsD;AACtD,qBAA8C;AAC9C,gBAAsB;AAWtB,8BAA+B;AAC/B,4BAA+B;AAC/B,4BAA0B;AAC1B,+BAA4B;AAC5B,iCAA8B;AAC9B,8BAA4B;AAC5B,uCAAkC;AA6F5B;AA3FN,SAAS,aAAsB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAOI;AACH,QAAM,EAAE,OAAO,QAAI,2BAAY,wBAAAA,OAAgB;AA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,KAAM;AAE9C,QAAM,EAAE,iBAAiB,YAAY,cAAc,QAClD,iCAAAC,SAAuB,KAAM;AAC9B,MAAK,CAAE,iBAAkB;AACxB,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,MAAM;AACzB,cAAW,KAAM;AACjB,eAAY,IAAK;AAAA,EAClB;AAEA,SACC,4EACC;AAAA;AAAA,MAAC,sBAAAC;AAAA,MAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAW,gBAAgB,aAAa;AAAA,QACxC,SAAU,MAAM,UAAW,IAAK;AAAA,QAChC,iBAAgB;AAAA;AAAA,IACjB;AAAA,IACE,UACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAa,cAAc;AAAA,QAC3B,SAAU;AAAA,QACV;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;AAEA,IAAO,gBAAQ;",
|
|
6
|
+
"names": ["DataFormContext", "deepMerge", "useFormValidity", "useReportValidity", "Spacer", "useFieldFromFormField", "SummaryButton"]
|
|
7
7
|
}
|