@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataform-layouts/data-form-layout.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tFieldValidity,\n\tFormValidity,\n\tNormalizedForm,\n\tNormalizedFormField,\n} from '../../types';\nimport { getFormFieldLayout } from './index';\nimport DataFormContext from '../dataform-context';\n\nconst DEFAULT_WRAPPER = ( { children }: { children: React.ReactNode } ) => (\n\t<Stack direction=\"column\" className=\"dataforms-layouts__wrapper\" gap=\"
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext, useMemo } from '@wordpress/element';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tFieldValidity,\n\tFormValidity,\n\tNormalizedForm,\n\tNormalizedFormField,\n} from '../../types';\nimport { getFormFieldLayout } from './index';\nimport DataFormContext from '../dataform-context';\n\nconst DEFAULT_WRAPPER = ( { children }: { children: React.ReactNode } ) => (\n\t<Stack direction=\"column\" className=\"dataforms-layouts__wrapper\" gap=\"lg\">\n\t\t{ children }\n\t</Stack>\n);\n\nexport function DataFormLayout< Item >( {\n\tdata,\n\tform,\n\tonChange,\n\tvalidity,\n\tchildren,\n\tas,\n}: {\n\tdata: Item;\n\tform: NormalizedForm;\n\tonChange: ( value: any ) => void;\n\tvalidity?: FormValidity;\n\tchildren?: (\n\t\tFieldLayout: ( props: {\n\t\t\tdata: Item;\n\t\t\tfield: NormalizedFormField;\n\t\t\tonChange: ( value: any ) => void;\n\t\t\thideLabelFromVision?: boolean;\n\t\t\tmarkWhenOptional?: boolean;\n\t\t\tvalidity?: FieldValidity;\n\t\t} ) => React.JSX.Element | null,\n\t\tchildField: NormalizedFormField,\n\t\tchildFieldValidity?: FieldValidity,\n\t\tmarkWhenOptional?: boolean\n\t) => React.JSX.Element;\n\tas?: React.ComponentType< { children: React.ReactNode } >;\n} ) {\n\tconst { fields: fieldDefinitions } = useContext( DataFormContext );\n\n\t// Auto-compute: mark the minority of fields\n\t// When counts are equal, mark required fields\n\tconst markWhenOptional = useMemo( () => {\n\t\tconst requiredCount = fieldDefinitions.filter(\n\t\t\t( f ) => !! f.isValid?.required\n\t\t).length;\n\t\tconst optionalCount = fieldDefinitions.length - requiredCount;\n\t\treturn requiredCount > optionalCount;\n\t}, [ fieldDefinitions ] );\n\n\tfunction getFieldDefinition( field: NormalizedFormField ) {\n\t\treturn fieldDefinitions.find(\n\t\t\t( fieldDefinition ) => fieldDefinition.id === field.id\n\t\t);\n\t}\n\n\tconst Wrapper =\n\t\tas ??\n\t\tgetFormFieldLayout( form.layout.type )?.wrapper ??\n\t\tDEFAULT_WRAPPER;\n\n\treturn (\n\t\t<Wrapper layout={ form.layout }>\n\t\t\t{ form.fields.map( ( formField ) => {\n\t\t\t\tconst FieldLayout = getFormFieldLayout( formField.layout.type )\n\t\t\t\t\t?.component;\n\n\t\t\t\tif ( ! FieldLayout ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tconst fieldDefinition = ! formField.children\n\t\t\t\t\t? getFieldDefinition( formField )\n\t\t\t\t\t: undefined;\n\n\t\t\t\tif (\n\t\t\t\t\tfieldDefinition &&\n\t\t\t\t\tfieldDefinition.isVisible &&\n\t\t\t\t\t! fieldDefinition.isVisible( data )\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif ( children ) {\n\t\t\t\t\treturn children(\n\t\t\t\t\t\tFieldLayout,\n\t\t\t\t\t\tformField,\n\t\t\t\t\t\tvalidity?.[ formField.id ],\n\t\t\t\t\t\tmarkWhenOptional\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<FieldLayout\n\t\t\t\t\t\tkey={ formField.id }\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tfield={ formField }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t\t\t\tvalidity={ validity?.[ formField.id ] }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Wrapper>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAoC;AACpC,gBAAsB;AAWtB,mBAAmC;AACnC,8BAA4B;AAG3B;AADD,IAAM,kBAAkB,CAAE,EAAE,SAAS,MACpC,4CAAC,mBAAM,WAAU,UAAS,WAAU,8BAA6B,KAAI,MAClE,UACH;AAGM,SAAS,eAAwB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAmBI;AACH,QAAM,EAAE,QAAQ,iBAAiB,QAAI,2BAAY,wBAAAA,OAAgB;AAIjE,QAAM,uBAAmB,wBAAS,MAAM;AACvC,UAAM,gBAAgB,iBAAiB;AAAA,MACtC,CAAE,MAAO,CAAC,CAAE,EAAE,SAAS;AAAA,IACxB,EAAE;AACF,UAAM,gBAAgB,iBAAiB,SAAS;AAChD,WAAO,gBAAgB;AAAA,EACxB,GAAG,CAAE,gBAAiB,CAAE;AAExB,WAAS,mBAAoB,OAA6B;AACzD,WAAO,iBAAiB;AAAA,MACvB,CAAE,oBAAqB,gBAAgB,OAAO,MAAM;AAAA,IACrD;AAAA,EACD;AAEA,QAAM,UACL,UACA,iCAAoB,KAAK,OAAO,IAAK,GAAG,WACxC;AAED,SACC,4CAAC,WAAQ,QAAS,KAAK,QACpB,eAAK,OAAO,IAAK,CAAE,cAAe;AACnC,UAAM,kBAAc,iCAAoB,UAAU,OAAO,IAAK,GAC3D;AAEH,QAAK,CAAE,aAAc;AACpB,aAAO;AAAA,IACR;AAEA,UAAM,kBAAkB,CAAE,UAAU,WACjC,mBAAoB,SAAU,IAC9B;AAEH,QACC,mBACA,gBAAgB,aAChB,CAAE,gBAAgB,UAAW,IAAK,GACjC;AACD,aAAO;AAAA,IACR;AAEA,QAAK,UAAW;AACf,aAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA,WAAY,UAAU,EAAG;AAAA,QACzB;AAAA,MACD;AAAA,IACD;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QAEA;AAAA,QACA,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,UAAW,WAAY,UAAU,EAAG;AAAA;AAAA,MAL9B,UAAU;AAAA,IAMjB;AAAA,EAEF,CAAE,GACH;AAEF;",
|
|
6
6
|
"names": ["DataFormContext"]
|
|
7
7
|
}
|
|
@@ -35,16 +35,24 @@ __export(details_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(details_exports);
|
|
36
36
|
var import_element = require("@wordpress/element");
|
|
37
37
|
var import_i18n = require("@wordpress/i18n");
|
|
38
|
+
var import_ui = require("@wordpress/ui");
|
|
38
39
|
var import_dataform_context = __toESM(require("../../dataform-context/index.cjs"));
|
|
39
40
|
var import_data_form_layout = require("../data-form-layout.cjs");
|
|
40
41
|
var import_normalize_form = require("../normalize-form.cjs");
|
|
42
|
+
var import_use_report_validity = __toESM(require("../../../hooks/use-report-validity.cjs"));
|
|
43
|
+
var import_validation_badge = __toESM(require("../validation-badge.cjs"));
|
|
41
44
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
45
|
function FormDetailsField({
|
|
43
46
|
data,
|
|
44
47
|
field,
|
|
45
|
-
onChange
|
|
48
|
+
onChange,
|
|
49
|
+
validity
|
|
46
50
|
}) {
|
|
47
51
|
const { fields } = (0, import_element.useContext)(import_dataform_context.default);
|
|
52
|
+
const detailsRef = (0, import_element.useRef)(null);
|
|
53
|
+
const contentRef = (0, import_element.useRef)(null);
|
|
54
|
+
const [touched, setTouched] = (0, import_element.useState)(false);
|
|
55
|
+
const [isOpen, setIsOpen] = (0, import_element.useState)(false);
|
|
48
56
|
const form = (0, import_element.useMemo)(
|
|
49
57
|
() => ({
|
|
50
58
|
layout: import_normalize_form.DEFAULT_LAYOUT,
|
|
@@ -52,6 +60,27 @@ function FormDetailsField({
|
|
|
52
60
|
}),
|
|
53
61
|
[field]
|
|
54
62
|
);
|
|
63
|
+
(0, import_element.useEffect)(() => {
|
|
64
|
+
const details = detailsRef.current;
|
|
65
|
+
if (!details) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const handleToggle = () => {
|
|
69
|
+
const nowOpen = details.open;
|
|
70
|
+
if (!nowOpen) {
|
|
71
|
+
setTouched(true);
|
|
72
|
+
}
|
|
73
|
+
setIsOpen(nowOpen);
|
|
74
|
+
};
|
|
75
|
+
details.addEventListener("toggle", handleToggle);
|
|
76
|
+
return () => {
|
|
77
|
+
details.removeEventListener("toggle", handleToggle);
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
(0, import_use_report_validity.default)(contentRef, isOpen && touched);
|
|
81
|
+
const handleBlur = (0, import_element.useCallback)(() => {
|
|
82
|
+
setTouched(true);
|
|
83
|
+
}, []);
|
|
55
84
|
if (!field.children) {
|
|
56
85
|
return null;
|
|
57
86
|
}
|
|
@@ -63,16 +92,44 @@ function FormDetailsField({
|
|
|
63
92
|
} else {
|
|
64
93
|
summaryContent = field.label || (0, import_i18n.__)("More details");
|
|
65
94
|
}
|
|
66
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
96
|
+
"details",
|
|
97
|
+
{
|
|
98
|
+
ref: detailsRef,
|
|
99
|
+
className: "dataforms-layouts-details__details",
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
102
|
+
import_ui.Stack,
|
|
103
|
+
{
|
|
104
|
+
direction: "row",
|
|
105
|
+
align: "center",
|
|
106
|
+
gap: "md",
|
|
107
|
+
className: "dataforms-layouts-details__summary-content",
|
|
108
|
+
children: [
|
|
109
|
+
summaryContent,
|
|
110
|
+
touched && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_validation_badge.default, { validity })
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
) }),
|
|
114
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
ref: contentRef,
|
|
118
|
+
className: "dataforms-layouts-details__content",
|
|
119
|
+
onBlur: handleBlur,
|
|
120
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
|
+
import_data_form_layout.DataFormLayout,
|
|
122
|
+
{
|
|
123
|
+
data,
|
|
124
|
+
form,
|
|
125
|
+
onChange,
|
|
126
|
+
validity: validity?.children
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
);
|
|
77
134
|
}
|
|
78
135
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/dataform-layouts/details/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": ["DataFormContext"]
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tNormalizedForm,\n\tNormalizedDetailsLayout,\n\tFieldLayoutProps,\n} from '../../../types';\nimport DataFormContext from '../../dataform-context';\nimport { DataFormLayout } from '../data-form-layout';\nimport { DEFAULT_LAYOUT } from '../normalize-form';\nimport useReportValidity from '../../../hooks/use-report-validity';\nimport ValidationBadge from '../validation-badge';\n\nexport default function FormDetailsField< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\tvalidity,\n}: FieldLayoutProps< Item > ) {\n\tconst { fields } = useContext( DataFormContext );\n\tconst detailsRef = useRef< HTMLDetailsElement >( null );\n\tconst contentRef = useRef< HTMLDivElement >( null );\n\tconst [ touched, setTouched ] = useState( false );\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\n\tconst form: NormalizedForm = useMemo(\n\t\t() => ( {\n\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\tfields: field.children ?? [],\n\t\t} ),\n\t\t[ field ]\n\t);\n\n\t// Track the open/close state of the native details element.\n\tuseEffect( () => {\n\t\tconst details = detailsRef.current;\n\t\tif ( ! details ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst handleToggle = () => {\n\t\t\tconst nowOpen = details.open;\n\t\t\t// Mark as touched when collapsing (going from open to closed).\n\t\t\tif ( ! nowOpen ) {\n\t\t\t\tsetTouched( true );\n\t\t\t}\n\t\t\tsetIsOpen( nowOpen );\n\t\t};\n\n\t\tdetails.addEventListener( 'toggle', handleToggle );\n\t\treturn () => {\n\t\t\tdetails.removeEventListener( 'toggle', handleToggle );\n\t\t};\n\t}, [] );\n\n\t// When expanded after being touched, trigger reportValidity to show\n\t// field-level errors.\n\tuseReportValidity( contentRef, isOpen && touched );\n\n\t// Mark as touched when any field inside is blurred.\n\tconst handleBlur = useCallback( () => {\n\t\tsetTouched( true );\n\t}, [] );\n\n\tif ( ! field.children ) {\n\t\treturn null;\n\t}\n\n\t// Find the summary field definition if specified\n\tconst summaryFieldId =\n\t\t( field.layout as NormalizedDetailsLayout ).summary ?? '';\n\tconst summaryField = summaryFieldId\n\t\t? fields.find( ( fieldDef ) => fieldDef.id === summaryFieldId )\n\t\t: undefined;\n\n\t// Render the summary content\n\tlet summaryContent;\n\tif ( summaryField && summaryField.render ) {\n\t\t// Use the field's render function to display the current value\n\t\tsummaryContent = (\n\t\t\t<summaryField.render item={ data } field={ summaryField } />\n\t\t);\n\t} else {\n\t\t// Fall back to the label\n\t\tsummaryContent = field.label || __( 'More details' );\n\t}\n\n\treturn (\n\t\t<details\n\t\t\tref={ detailsRef }\n\t\t\tclassName=\"dataforms-layouts-details__details\"\n\t\t>\n\t\t\t<summary className=\"dataforms-layouts-details__summary\">\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\talign=\"center\"\n\t\t\t\t\tgap=\"md\"\n\t\t\t\t\tclassName=\"dataforms-layouts-details__summary-content\"\n\t\t\t\t>\n\t\t\t\t\t{ summaryContent }\n\t\t\t\t\t{ touched && <ValidationBadge validity={ validity } /> }\n\t\t\t\t</Stack>\n\t\t\t</summary>\n\t\t\t<div\n\t\t\t\tref={ contentRef }\n\t\t\t\tclassName=\"dataforms-layouts-details__content\"\n\t\t\t\tonBlur={ handleBlur }\n\t\t\t>\n\t\t\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AAa,MAAM;AACrC,eAAY,IAAK;AAAA,EAClB,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,MAAM,UAAW;AACvB,WAAO;AAAA,EACR;AAGA,QAAM,iBACH,MAAM,OAAoC,WAAW;AACxD,QAAM,eAAe,iBAClB,OAAO,KAAM,CAAE,aAAc,SAAS,OAAO,cAAe,IAC5D;AAGH,MAAI;AACJ,MAAK,gBAAgB,aAAa,QAAS;AAE1C,qBACC,4CAAC,aAAa,QAAb,EAAoB,MAAO,MAAO,OAAQ,cAAe;AAAA,EAE5D,OAAO;AAEN,qBAAiB,MAAM,aAAS,gBAAI,cAAe;AAAA,EACpD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,KAAM;AAAA,MACN,WAAU;AAAA,MAEV;AAAA,oDAAC,aAAQ,WAAU,sCAClB;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,OAAM;AAAA,YACN,KAAI;AAAA,YACJ,WAAU;AAAA,YAER;AAAA;AAAA,cACA,WAAW,4CAAC,wBAAAC,SAAA,EAAgB,UAAsB;AAAA;AAAA;AAAA,QACrD,GACD;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN,WAAU;AAAA,YACV,QAAS;AAAA,YAET;AAAA,cAAC;AAAA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,UAAW,UAAU;AAAA;AAAA,YACtB;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["DataFormContext", "useReportValidity", "ValidationBadge"]
|
|
7
7
|
}
|
|
@@ -49,7 +49,7 @@ var FORM_FIELD_LAYOUTS = [
|
|
|
49
49
|
{
|
|
50
50
|
direction: "column",
|
|
51
51
|
className: "dataforms-layouts__wrapper",
|
|
52
|
-
gap: "
|
|
52
|
+
gap: "lg",
|
|
53
53
|
children
|
|
54
54
|
}
|
|
55
55
|
)
|
|
@@ -62,7 +62,7 @@ var FORM_FIELD_LAYOUTS = [
|
|
|
62
62
|
{
|
|
63
63
|
direction: "column",
|
|
64
64
|
className: "dataforms-layouts__wrapper",
|
|
65
|
-
gap: "
|
|
65
|
+
gap: "md",
|
|
66
66
|
children
|
|
67
67
|
}
|
|
68
68
|
)
|
|
@@ -75,7 +75,7 @@ var FORM_FIELD_LAYOUTS = [
|
|
|
75
75
|
{
|
|
76
76
|
direction: "column",
|
|
77
77
|
className: "dataforms-layouts__wrapper",
|
|
78
|
-
gap: "
|
|
78
|
+
gap: "xl",
|
|
79
79
|
children
|
|
80
80
|
}
|
|
81
81
|
)
|
|
@@ -91,12 +91,12 @@ var FORM_FIELD_LAYOUTS = [
|
|
|
91
91
|
{
|
|
92
92
|
direction: "column",
|
|
93
93
|
className: "dataforms-layouts__wrapper",
|
|
94
|
-
gap: "
|
|
94
|
+
gap: "lg",
|
|
95
95
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
96
|
import_ui.Stack,
|
|
97
97
|
{
|
|
98
98
|
direction: "row",
|
|
99
|
-
gap: "
|
|
99
|
+
gap: "lg",
|
|
100
100
|
align: layout.alignment,
|
|
101
101
|
children
|
|
102
102
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataform-layouts/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type { NormalizedLayout, NormalizedRowLayout } from '../../types';\nimport FormRegularField from './regular';\nimport FormPanelField from './panel';\nimport FormCardField from './card';\nimport FormRowField from './row';\nimport FormDetailsField from './details';\n\nconst FORM_FIELD_LAYOUTS = [\n\t{\n\t\ttype: 'regular',\n\t\tcomponent: FormRegularField,\n\t\twrapper: ( { children }: { children: React.ReactNode } ) => (\n\t\t\t<Stack\n\t\t\t\tdirection=\"column\"\n\t\t\t\tclassName=\"dataforms-layouts__wrapper\"\n\t\t\t\tgap=\"
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport type { NormalizedLayout, NormalizedRowLayout } from '../../types';\nimport FormRegularField from './regular';\nimport FormPanelField from './panel';\nimport FormCardField from './card';\nimport FormRowField from './row';\nimport FormDetailsField from './details';\n\nconst FORM_FIELD_LAYOUTS = [\n\t{\n\t\ttype: 'regular',\n\t\tcomponent: FormRegularField,\n\t\twrapper: ( { children }: { children: React.ReactNode } ) => (\n\t\t\t<Stack\n\t\t\t\tdirection=\"column\"\n\t\t\t\tclassName=\"dataforms-layouts__wrapper\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</Stack>\n\t\t),\n\t},\n\t{\n\t\ttype: 'panel',\n\t\tcomponent: FormPanelField,\n\t\twrapper: ( { children }: { children: React.ReactNode } ) => (\n\t\t\t<Stack\n\t\t\t\tdirection=\"column\"\n\t\t\t\tclassName=\"dataforms-layouts__wrapper\"\n\t\t\t\tgap=\"md\"\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</Stack>\n\t\t),\n\t},\n\t{\n\t\ttype: 'card',\n\t\tcomponent: FormCardField,\n\t\twrapper: ( { children }: { children: React.ReactNode } ) => (\n\t\t\t<Stack\n\t\t\t\tdirection=\"column\"\n\t\t\t\tclassName=\"dataforms-layouts__wrapper\"\n\t\t\t\tgap=\"xl\"\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</Stack>\n\t\t),\n\t},\n\t{\n\t\ttype: 'row',\n\t\tcomponent: FormRowField,\n\t\twrapper: ( {\n\t\t\tchildren,\n\t\t\tlayout,\n\t\t}: {\n\t\t\tchildren: React.ReactNode;\n\t\t\tlayout: NormalizedLayout;\n\t\t} ) => (\n\t\t\t<Stack\n\t\t\t\tdirection=\"column\"\n\t\t\t\tclassName=\"dataforms-layouts__wrapper\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<div className=\"dataforms-layouts-row__field\">\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\t\tgap=\"lg\"\n\t\t\t\t\t\talign={ ( layout as NormalizedRowLayout ).alignment }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</Stack>\n\t\t\t\t</div>\n\t\t\t</Stack>\n\t\t),\n\t},\n\t{\n\t\ttype: 'details',\n\t\tcomponent: FormDetailsField,\n\t},\n];\n\nexport function getFormFieldLayout( type: string ) {\n\treturn FORM_FIELD_LAYOUTS.find( ( layout ) => layout.type === type );\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gBAAsB;AAMtB,qBAA6B;AAC7B,mBAA2B;AAC3B,kBAA0B;AAC1B,iBAAyB;AACzB,qBAA6B;AAO1B;AALH,IAAM,qBAAqB;AAAA,EAC1B;AAAA,IACC,MAAM;AAAA,IACN,WAAW,eAAAA;AAAA,IACX,SAAS,CAAE,EAAE,SAAS,MACrB;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,WAAU;AAAA,QACV,KAAI;AAAA,QAEF;AAAA;AAAA,IACH;AAAA,EAEF;AAAA,EACA;AAAA,IACC,MAAM;AAAA,IACN,WAAW,aAAAC;AAAA,IACX,SAAS,CAAE,EAAE,SAAS,MACrB;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,WAAU;AAAA,QACV,KAAI;AAAA,QAEF;AAAA;AAAA,IACH;AAAA,EAEF;AAAA,EACA;AAAA,IACC,MAAM;AAAA,IACN,WAAW,YAAAC;AAAA,IACX,SAAS,CAAE,EAAE,SAAS,MACrB;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,WAAU;AAAA,QACV,KAAI;AAAA,QAEF;AAAA;AAAA,IACH;AAAA,EAEF;AAAA,EACA;AAAA,IACC,MAAM;AAAA,IACN,WAAW,WAAAC;AAAA,IACX,SAAS,CAAE;AAAA,MACV;AAAA,MACA;AAAA,IACD,MAIC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,WAAU;AAAA,QACV,KAAI;AAAA,QAEJ,sDAAC,SAAI,WAAU,gCACd;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,KAAI;AAAA,YACJ,OAAU,OAAgC;AAAA,YAExC;AAAA;AAAA,QACH,GACD;AAAA;AAAA,IACD;AAAA,EAEF;AAAA,EACA;AAAA,IACC,MAAM;AAAA,IACN,WAAW,eAAAC;AAAA,EACZ;AACD;AAEO,SAAS,mBAAoB,MAAe;AAClD,SAAO,mBAAmB,KAAM,CAAE,WAAY,OAAO,SAAS,IAAK;AACpE;",
|
|
6
6
|
"names": ["FormRegularField", "FormPanelField", "FormCardField", "FormRowField", "FormDetailsField"]
|
|
7
7
|
}
|
|
@@ -53,7 +53,8 @@ function normalizeLayout(layout) {
|
|
|
53
53
|
type: "panel",
|
|
54
54
|
labelPosition: layout?.labelPosition ?? "side",
|
|
55
55
|
openAs: layout?.openAs ?? "dropdown",
|
|
56
|
-
summary: normalizedSummary
|
|
56
|
+
summary: normalizedSummary,
|
|
57
|
+
editVisibility: layout?.editVisibility ?? "on-hover"
|
|
57
58
|
};
|
|
58
59
|
} else if (layout?.type === "card") {
|
|
59
60
|
if (layout.withHeader === false) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataform-layouts/normalize-form.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type {\n\tForm,\n\tLayout,\n\tNormalizedForm,\n\tNormalizedFormField,\n\tNormalizedLayout,\n\tNormalizedRegularLayout,\n\tNormalizedPanelLayout,\n\tNormalizedCardLayout,\n\tNormalizedRowLayout,\n\tNormalizedDetailsLayout,\n\tNormalizedCardSummaryField,\n\tCardSummaryField,\n} from '../../types';\n\nexport const DEFAULT_LAYOUT: NormalizedLayout = {\n\ttype: 'regular',\n\tlabelPosition: 'top',\n} as NormalizedRegularLayout;\n\nconst normalizeCardSummaryField = (\n\tsum: CardSummaryField\n): NormalizedCardSummaryField => {\n\tif ( typeof sum === 'string' ) {\n\t\treturn [ { id: sum, visibility: 'when-collapsed' } ];\n\t}\n\treturn sum.map( ( item ) => {\n\t\tif ( typeof item === 'string' ) {\n\t\t\treturn { id: item, visibility: 'when-collapsed' };\n\t\t}\n\t\treturn { id: item.id, visibility: item.visibility };\n\t} );\n};\n\n/**\n * Normalizes a layout configuration based on its type.\n *\n * @param layout The layout object to normalize.\n * @return The normalized layout object.\n */\nfunction normalizeLayout( layout?: Layout ): NormalizedLayout {\n\tlet normalizedLayout = DEFAULT_LAYOUT;\n\n\tif ( layout?.type === 'regular' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'regular',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'top',\n\t\t} satisfies NormalizedRegularLayout;\n\t} else if ( layout?.type === 'panel' ) {\n\t\tconst summary = layout.summary ?? [];\n\t\tconst normalizedSummary = Array.isArray( summary )\n\t\t\t? summary\n\t\t\t: [ summary ];\n\n\t\tnormalizedLayout = {\n\t\t\ttype: 'panel',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'side',\n\t\t\topenAs: layout?.openAs ?? 'dropdown',\n\t\t\tsummary: normalizedSummary,\n\t\t} satisfies NormalizedPanelLayout;\n\t} else if ( layout?.type === 'card' ) {\n\t\tif ( layout.withHeader === false ) {\n\t\t\t// Don't let isOpened be false if withHeader is false.\n\t\t\t// Otherwise, the card will not be visible.\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: false,\n\t\t\t\tisOpened: true,\n\t\t\t\tsummary: [],\n\t\t\t\tisCollapsible: false,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t} else {\n\t\t\tconst summary = layout.summary ?? [];\n\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: true,\n\t\t\t\tisOpened:\n\t\t\t\t\ttypeof layout.isOpened === 'boolean'\n\t\t\t\t\t\t? layout.isOpened\n\t\t\t\t\t\t: true,\n\t\t\t\tsummary: normalizeCardSummaryField( summary ),\n\t\t\t\tisCollapsible:\n\t\t\t\t\tlayout.isCollapsible === undefined\n\t\t\t\t\t\t? true\n\t\t\t\t\t\t: layout.isCollapsible,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t}\n\t} else if ( layout?.type === 'row' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'row',\n\t\t\talignment: layout?.alignment ?? 'center',\n\t\t\tstyles: layout?.styles ?? {},\n\t\t} satisfies NormalizedRowLayout;\n\t} else if ( layout?.type === 'details' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'details',\n\t\t\tsummary: layout?.summary ?? '',\n\t\t} satisfies NormalizedDetailsLayout;\n\t}\n\n\treturn normalizedLayout;\n}\n\nfunction normalizeForm( form: Form ): NormalizedForm {\n\tconst normalizedFormLayout = normalizeLayout( form?.layout );\n\n\tconst normalizedFields: NormalizedFormField[] = ( form.fields ?? [] ).map(\n\t\t( field ) => {\n\t\t\tif ( typeof field === 'string' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: field,\n\t\t\t\t\tlayout: normalizedFormLayout,\n\t\t\t\t} satisfies NormalizedFormField;\n\t\t\t}\n\n\t\t\tconst fieldLayout = field.layout\n\t\t\t\t? normalizeLayout( field.layout )\n\t\t\t\t: normalizedFormLayout;\n\n\t\t\treturn {\n\t\t\t\tid: field.id,\n\t\t\t\tlayout: fieldLayout,\n\t\t\t\t...( !! field.label && { label: field.label } ),\n\t\t\t\t...( !! field.description && {\n\t\t\t\t\tdescription: field.description,\n\t\t\t\t} ),\n\t\t\t\t...( 'children' in field &&\n\t\t\t\t\tArray.isArray( field.children ) && {\n\t\t\t\t\t\tchildren: normalizeForm( {\n\t\t\t\t\t\t\tfields: field.children,\n\t\t\t\t\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\t\t\t\t} ).fields,\n\t\t\t\t\t} ),\n\t\t\t} satisfies NormalizedFormField;\n\t\t}\n\t);\n\n\treturn {\n\t\tlayout: normalizedFormLayout,\n\t\tfields: normalizedFields,\n\t};\n}\n\nexport default normalizeForm;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,IAAM,iBAAmC;AAAA,EAC/C,MAAM;AAAA,EACN,eAAe;AAChB;AAEA,IAAM,4BAA4B,CACjC,QACgC;AAChC,MAAK,OAAO,QAAQ,UAAW;AAC9B,WAAO,CAAE,EAAE,IAAI,KAAK,YAAY,iBAAiB,CAAE;AAAA,EACpD;AACA,SAAO,IAAI,IAAK,CAAE,SAAU;AAC3B,QAAK,OAAO,SAAS,UAAW;AAC/B,aAAO,EAAE,IAAI,MAAM,YAAY,iBAAiB;AAAA,IACjD;AACA,WAAO,EAAE,IAAI,KAAK,IAAI,YAAY,KAAK,WAAW;AAAA,EACnD,CAAE;AACH;AAQA,SAAS,gBAAiB,QAAoC;AAC7D,MAAI,mBAAmB;AAEvB,MAAK,QAAQ,SAAS,WAAY;AACjC,uBAAmB;AAAA,MAClB,MAAM;AAAA,MACN,eAAe,QAAQ,iBAAiB;AAAA,IACzC;AAAA,EACD,WAAY,QAAQ,SAAS,SAAU;AACtC,UAAM,UAAU,OAAO,WAAW,CAAC;AACnC,UAAM,oBAAoB,MAAM,QAAS,OAAQ,IAC9C,UACA,CAAE,OAAQ;AAEb,uBAAmB;AAAA,MAClB,MAAM;AAAA,MACN,eAAe,QAAQ,iBAAiB;AAAA,MACxC,QAAQ,QAAQ,UAAU;AAAA,MAC1B,SAAS;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type {\n\tForm,\n\tLayout,\n\tNormalizedForm,\n\tNormalizedFormField,\n\tNormalizedLayout,\n\tNormalizedRegularLayout,\n\tNormalizedPanelLayout,\n\tNormalizedCardLayout,\n\tNormalizedRowLayout,\n\tNormalizedDetailsLayout,\n\tNormalizedCardSummaryField,\n\tCardSummaryField,\n} from '../../types';\n\nexport const DEFAULT_LAYOUT: NormalizedLayout = {\n\ttype: 'regular',\n\tlabelPosition: 'top',\n} as NormalizedRegularLayout;\n\nconst normalizeCardSummaryField = (\n\tsum: CardSummaryField\n): NormalizedCardSummaryField => {\n\tif ( typeof sum === 'string' ) {\n\t\treturn [ { id: sum, visibility: 'when-collapsed' } ];\n\t}\n\treturn sum.map( ( item ) => {\n\t\tif ( typeof item === 'string' ) {\n\t\t\treturn { id: item, visibility: 'when-collapsed' };\n\t\t}\n\t\treturn { id: item.id, visibility: item.visibility };\n\t} );\n};\n\n/**\n * Normalizes a layout configuration based on its type.\n *\n * @param layout The layout object to normalize.\n * @return The normalized layout object.\n */\nfunction normalizeLayout( layout?: Layout ): NormalizedLayout {\n\tlet normalizedLayout = DEFAULT_LAYOUT;\n\n\tif ( layout?.type === 'regular' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'regular',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'top',\n\t\t} satisfies NormalizedRegularLayout;\n\t} else if ( layout?.type === 'panel' ) {\n\t\tconst summary = layout.summary ?? [];\n\t\tconst normalizedSummary = Array.isArray( summary )\n\t\t\t? summary\n\t\t\t: [ summary ];\n\n\t\tnormalizedLayout = {\n\t\t\ttype: 'panel',\n\t\t\tlabelPosition: layout?.labelPosition ?? 'side',\n\t\t\topenAs: layout?.openAs ?? 'dropdown',\n\t\t\tsummary: normalizedSummary,\n\t\t\teditVisibility: layout?.editVisibility ?? 'on-hover',\n\t\t} satisfies NormalizedPanelLayout;\n\t} else if ( layout?.type === 'card' ) {\n\t\tif ( layout.withHeader === false ) {\n\t\t\t// Don't let isOpened be false if withHeader is false.\n\t\t\t// Otherwise, the card will not be visible.\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: false,\n\t\t\t\tisOpened: true,\n\t\t\t\tsummary: [],\n\t\t\t\tisCollapsible: false,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t} else {\n\t\t\tconst summary = layout.summary ?? [];\n\n\t\t\tnormalizedLayout = {\n\t\t\t\ttype: 'card',\n\t\t\t\twithHeader: true,\n\t\t\t\tisOpened:\n\t\t\t\t\ttypeof layout.isOpened === 'boolean'\n\t\t\t\t\t\t? layout.isOpened\n\t\t\t\t\t\t: true,\n\t\t\t\tsummary: normalizeCardSummaryField( summary ),\n\t\t\t\tisCollapsible:\n\t\t\t\t\tlayout.isCollapsible === undefined\n\t\t\t\t\t\t? true\n\t\t\t\t\t\t: layout.isCollapsible,\n\t\t\t} satisfies NormalizedCardLayout;\n\t\t}\n\t} else if ( layout?.type === 'row' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'row',\n\t\t\talignment: layout?.alignment ?? 'center',\n\t\t\tstyles: layout?.styles ?? {},\n\t\t} satisfies NormalizedRowLayout;\n\t} else if ( layout?.type === 'details' ) {\n\t\tnormalizedLayout = {\n\t\t\ttype: 'details',\n\t\t\tsummary: layout?.summary ?? '',\n\t\t} satisfies NormalizedDetailsLayout;\n\t}\n\n\treturn normalizedLayout;\n}\n\nfunction normalizeForm( form: Form ): NormalizedForm {\n\tconst normalizedFormLayout = normalizeLayout( form?.layout );\n\n\tconst normalizedFields: NormalizedFormField[] = ( form.fields ?? [] ).map(\n\t\t( field ) => {\n\t\t\tif ( typeof field === 'string' ) {\n\t\t\t\treturn {\n\t\t\t\t\tid: field,\n\t\t\t\t\tlayout: normalizedFormLayout,\n\t\t\t\t} satisfies NormalizedFormField;\n\t\t\t}\n\n\t\t\tconst fieldLayout = field.layout\n\t\t\t\t? normalizeLayout( field.layout )\n\t\t\t\t: normalizedFormLayout;\n\n\t\t\treturn {\n\t\t\t\tid: field.id,\n\t\t\t\tlayout: fieldLayout,\n\t\t\t\t...( !! field.label && { label: field.label } ),\n\t\t\t\t...( !! field.description && {\n\t\t\t\t\tdescription: field.description,\n\t\t\t\t} ),\n\t\t\t\t...( 'children' in field &&\n\t\t\t\t\tArray.isArray( field.children ) && {\n\t\t\t\t\t\tchildren: normalizeForm( {\n\t\t\t\t\t\t\tfields: field.children,\n\t\t\t\t\t\t\tlayout: DEFAULT_LAYOUT,\n\t\t\t\t\t\t} ).fields,\n\t\t\t\t\t} ),\n\t\t\t} satisfies NormalizedFormField;\n\t\t}\n\t);\n\n\treturn {\n\t\tlayout: normalizedFormLayout,\n\t\tfields: normalizedFields,\n\t};\n}\n\nexport default normalizeForm;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,IAAM,iBAAmC;AAAA,EAC/C,MAAM;AAAA,EACN,eAAe;AAChB;AAEA,IAAM,4BAA4B,CACjC,QACgC;AAChC,MAAK,OAAO,QAAQ,UAAW;AAC9B,WAAO,CAAE,EAAE,IAAI,KAAK,YAAY,iBAAiB,CAAE;AAAA,EACpD;AACA,SAAO,IAAI,IAAK,CAAE,SAAU;AAC3B,QAAK,OAAO,SAAS,UAAW;AAC/B,aAAO,EAAE,IAAI,MAAM,YAAY,iBAAiB;AAAA,IACjD;AACA,WAAO,EAAE,IAAI,KAAK,IAAI,YAAY,KAAK,WAAW;AAAA,EACnD,CAAE;AACH;AAQA,SAAS,gBAAiB,QAAoC;AAC7D,MAAI,mBAAmB;AAEvB,MAAK,QAAQ,SAAS,WAAY;AACjC,uBAAmB;AAAA,MAClB,MAAM;AAAA,MACN,eAAe,QAAQ,iBAAiB;AAAA,IACzC;AAAA,EACD,WAAY,QAAQ,SAAS,SAAU;AACtC,UAAM,UAAU,OAAO,WAAW,CAAC;AACnC,UAAM,oBAAoB,MAAM,QAAS,OAAQ,IAC9C,UACA,CA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AAI,MAAM;AAAA,QACV,QAAQ;AAAA,QACR,GAAK,CAAC,CAAE,MAAM,SAAS,EAAE,OAAO,MAAM,MAAM;AAAA,QAC5C,GAAK,CAAC,CAAE,MAAM,eAAe;AAAA,UAC5B,aAAa,MAAM;AAAA,QACpB;AAAA,QACA,GAAK,cAAc,SAClB,MAAM,QAAS,MAAM,QAAS,KAAK;AAAA,UAClC,UAAU,cAAe;AAAA,YACxB,QAAQ,MAAM;AAAA,YACd,QAAQ;AAAA,UACT,CAAE,EAAE;AAAA,QACL;AAAA,MACF;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,EACT;AACD;AAEA,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -42,6 +42,8 @@ var import_ui = require("@wordpress/ui");
|
|
|
42
42
|
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
|
+
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"));
|
|
45
47
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
48
|
function DropdownHeader({
|
|
47
49
|
title,
|
|
@@ -52,8 +54,8 @@ function DropdownHeader({
|
|
|
52
54
|
{
|
|
53
55
|
direction: "column",
|
|
54
56
|
className: "dataforms-layouts-panel__dropdown-header",
|
|
55
|
-
gap: "
|
|
56
|
-
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: [
|
|
57
59
|
title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalHeading, { level: 2, size: 13, children: title }),
|
|
58
60
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.__experimentalSpacer, { style: { flex: 1 } }),
|
|
59
61
|
onClose && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -69,18 +71,38 @@ function DropdownHeader({
|
|
|
69
71
|
}
|
|
70
72
|
);
|
|
71
73
|
}
|
|
74
|
+
function DropdownContentWithValidation({
|
|
75
|
+
touched,
|
|
76
|
+
children
|
|
77
|
+
}) {
|
|
78
|
+
const ref = (0, import_element.useRef)(null);
|
|
79
|
+
(0, import_use_report_validity.default)(ref, touched);
|
|
80
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref, children });
|
|
81
|
+
}
|
|
72
82
|
function PanelDropdown({
|
|
73
83
|
data,
|
|
74
84
|
field,
|
|
75
85
|
onChange,
|
|
76
|
-
validity
|
|
77
|
-
labelPosition = "side",
|
|
78
|
-
summaryFields,
|
|
79
|
-
fieldDefinition,
|
|
80
|
-
popoverAnchor,
|
|
81
|
-
onOpen
|
|
86
|
+
validity
|
|
82
87
|
}) {
|
|
83
|
-
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
|
+
});
|
|
84
106
|
const form = (0, import_element.useMemo)(
|
|
85
107
|
() => ({
|
|
86
108
|
layout: import_normalize_form.DEFAULT_LAYOUT,
|
|
@@ -100,69 +122,72 @@ function PanelDropdown({
|
|
|
100
122
|
}
|
|
101
123
|
return { [field.id]: validity };
|
|
102
124
|
}, [validity, field]);
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
anchor: popoverAnchor,
|
|
108
|
-
placement: "left-start",
|
|
109
|
-
offset: 36,
|
|
110
|
-
shift: true
|
|
111
|
-
}),
|
|
112
|
-
[popoverAnchor]
|
|
113
|
-
);
|
|
114
|
-
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
|
+
}
|
|
115
129
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
116
|
-
|
|
130
|
+
"div",
|
|
117
131
|
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
size: "compact",
|
|
123
|
-
variant: "tertiary",
|
|
124
|
-
tooltipPosition: "middle left"
|
|
125
|
-
},
|
|
126
|
-
renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
|
-
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,
|
|
128
136
|
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (!isOpen && onOpen) {
|
|
136
|
-
onOpen();
|
|
137
|
+
contentClassName: "dataforms-layouts-panel__field-dropdown",
|
|
138
|
+
popoverProps,
|
|
139
|
+
focusOnMount: false,
|
|
140
|
+
onToggle: (willOpen) => {
|
|
141
|
+
if (!willOpen) {
|
|
142
|
+
setTouched(true);
|
|
137
143
|
}
|
|
138
|
-
onToggle();
|
|
139
144
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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,
|
|
154
169
|
{
|
|
155
170
|
data,
|
|
156
|
-
|
|
171
|
+
form,
|
|
157
172
|
onChange,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
+
}
|
|
162
187
|
)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
188
|
+
] }) })
|
|
189
|
+
}
|
|
190
|
+
)
|
|
166
191
|
}
|
|
167
192
|
);
|
|
168
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 } 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", "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\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