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