@wordpress/dataviews 10.1.5 → 10.3.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 +19 -0
- package/README.md +109 -1
- package/build/components/dataform/index.js +6 -2
- package/build/components/dataform/index.js.map +3 -3
- package/build/components/dataform-context/index.js +4 -2
- package/build/components/dataform-context/index.js.map +1 -1
- package/build/components/dataviews/index.js +8 -6
- package/build/components/dataviews/index.js.map +1 -1
- package/build/components/dataviews-bulk-actions/index.js +4 -2
- package/build/components/dataviews-bulk-actions/index.js.map +1 -1
- package/build/components/dataviews-context/index.js +3 -1
- package/build/components/dataviews-context/index.js.map +1 -1
- package/build/components/dataviews-filters/add-filter.js +4 -2
- package/build/components/dataviews-filters/add-filter.js.map +1 -1
- package/build/components/dataviews-filters/filter.js +20 -5
- package/build/components/dataviews-filters/filter.js.map +3 -3
- package/build/components/dataviews-filters/filters-toggled.js +3 -1
- package/build/components/dataviews-filters/filters-toggled.js.map +1 -1
- package/build/components/dataviews-filters/filters.js +3 -1
- package/build/components/dataviews-filters/filters.js.map +1 -1
- package/build/components/dataviews-filters/index.js +2 -0
- package/build/components/dataviews-filters/index.js.map +1 -1
- package/build/components/dataviews-filters/input-widget.js +3 -1
- package/build/components/dataviews-filters/input-widget.js.map +1 -1
- package/build/components/dataviews-filters/reset-filters.js +3 -1
- package/build/components/dataviews-filters/reset-filters.js.map +1 -1
- package/build/components/dataviews-filters/search-widget.js +8 -6
- package/build/components/dataviews-filters/search-widget.js.map +2 -2
- package/build/components/dataviews-filters/toggle.js +3 -1
- package/build/components/dataviews-filters/toggle.js.map +1 -1
- package/build/components/dataviews-filters/use-filters.js +2 -0
- package/build/components/dataviews-filters/use-filters.js.map +1 -1
- package/build/components/dataviews-filters/utils.js +4 -2
- package/build/components/dataviews-filters/utils.js.map +1 -1
- package/build/components/dataviews-footer/index.js +4 -2
- package/build/components/dataviews-footer/index.js.map +1 -1
- package/build/components/dataviews-item-actions/index.js +23 -4
- package/build/components/dataviews-item-actions/index.js.map +2 -2
- package/build/components/dataviews-layout/index.js +3 -1
- package/build/components/dataviews-layout/index.js.map +1 -1
- package/build/components/dataviews-pagination/index.js +3 -1
- package/build/components/dataviews-pagination/index.js.map +1 -1
- package/build/components/dataviews-picker/footer.js +4 -2
- package/build/components/dataviews-picker/footer.js.map +1 -1
- package/build/components/dataviews-picker/index.js +8 -6
- package/build/components/dataviews-picker/index.js.map +1 -1
- package/build/components/dataviews-search/index.js +4 -2
- package/build/components/dataviews-search/index.js.map +1 -1
- package/build/components/dataviews-selection-checkbox/index.js +3 -1
- package/build/components/dataviews-selection-checkbox/index.js.map +1 -1
- package/build/components/dataviews-view-config/index.js +17 -400
- package/build/components/dataviews-view-config/index.js.map +3 -3
- package/build/components/dataviews-view-config/infinite-scroll-toggle.js +3 -1
- package/build/components/dataviews-view-config/infinite-scroll-toggle.js.map +1 -1
- package/build/components/dataviews-view-config/properties-section.js +177 -0
- package/build/components/dataviews-view-config/properties-section.js.map +7 -0
- package/build/constants.js +39 -34
- package/build/constants.js.map +2 -2
- package/build/dataform-controls/array.js +4 -2
- package/build/dataform-controls/array.js.map +1 -1
- package/build/dataform-controls/checkbox.js +4 -2
- package/build/dataform-controls/checkbox.js.map +1 -1
- package/build/dataform-controls/color.js +5 -3
- package/build/dataform-controls/color.js.map +1 -1
- package/build/dataform-controls/date.js +8 -6
- package/build/dataform-controls/date.js.map +1 -1
- package/build/dataform-controls/datetime.js +11 -15
- package/build/dataform-controls/datetime.js.map +3 -3
- package/build/dataform-controls/email.js +3 -1
- package/build/dataform-controls/email.js.map +1 -1
- package/build/dataform-controls/index.js +4 -2
- package/build/dataform-controls/index.js.map +1 -1
- package/build/dataform-controls/integer.js +3 -1
- package/build/dataform-controls/integer.js.map +1 -1
- package/build/dataform-controls/number.js +3 -1
- package/build/dataform-controls/number.js.map +1 -1
- package/build/dataform-controls/password.js +6 -5
- package/build/dataform-controls/password.js.map +3 -3
- package/build/dataform-controls/radio.js +4 -2
- package/build/dataform-controls/radio.js.map +1 -1
- package/build/dataform-controls/select.js +4 -2
- package/build/dataform-controls/select.js.map +1 -1
- package/build/dataform-controls/telephone.js +3 -1
- package/build/dataform-controls/telephone.js.map +1 -1
- package/build/dataform-controls/text.js +3 -1
- package/build/dataform-controls/text.js.map +1 -1
- package/build/dataform-controls/textarea.js +4 -2
- package/build/dataform-controls/textarea.js.map +1 -1
- package/build/dataform-controls/toggle-group.js +4 -2
- package/build/dataform-controls/toggle-group.js.map +1 -1
- package/build/dataform-controls/toggle.js +4 -2
- package/build/dataform-controls/toggle.js.map +1 -1
- package/build/dataform-controls/url.js +3 -1
- package/build/dataform-controls/url.js.map +1 -1
- package/build/dataform-controls/utils/get-custom-validity.js +2 -0
- package/build/dataform-controls/utils/get-custom-validity.js.map +1 -1
- package/build/dataform-controls/utils/relative-date-control.js +4 -2
- package/build/dataform-controls/utils/relative-date-control.js.map +1 -1
- package/build/dataform-controls/utils/validated-input.js +4 -2
- package/build/dataform-controls/utils/validated-input.js.map +1 -1
- package/build/dataform-controls/utils/validated-number.js +4 -2
- package/build/dataform-controls/utils/validated-number.js.map +1 -1
- package/build/dataform-layouts/card/index.js +91 -42
- package/build/dataform-layouts/card/index.js.map +3 -3
- package/build/dataform-layouts/data-form-layout.js +8 -14
- package/build/dataform-layouts/data-form-layout.js.map +3 -3
- package/build/dataform-layouts/details/index.js +78 -0
- package/build/dataform-layouts/details/index.js.map +7 -0
- package/build/dataform-layouts/get-summary-fields.js +3 -1
- package/build/dataform-layouts/get-summary-fields.js.map +1 -1
- package/build/dataform-layouts/index.js +9 -2
- package/build/dataform-layouts/index.js.map +3 -3
- package/build/dataform-layouts/{normalize-form-fields.js → normalize-form.js} +48 -24
- package/build/dataform-layouts/normalize-form.js.map +7 -0
- package/build/dataform-layouts/panel/dropdown.js +9 -8
- package/build/dataform-layouts/panel/dropdown.js.map +2 -2
- package/build/dataform-layouts/panel/index.js +10 -14
- package/build/dataform-layouts/panel/index.js.map +2 -2
- package/build/dataform-layouts/panel/modal.js +9 -8
- package/build/dataform-layouts/panel/modal.js.map +2 -2
- package/build/dataform-layouts/panel/summary-button.js +3 -1
- package/build/dataform-layouts/panel/summary-button.js.map +1 -1
- package/build/dataform-layouts/regular/index.js +8 -10
- package/build/dataform-layouts/regular/index.js.map +2 -2
- package/build/dataform-layouts/row/index.js +10 -33
- package/build/dataform-layouts/row/index.js.map +3 -3
- package/build/dataviews-layouts/grid/index.js +4 -2
- package/build/dataviews-layouts/grid/index.js.map +1 -1
- package/build/dataviews-layouts/grid/preview-size-picker.js +4 -2
- package/build/dataviews-layouts/grid/preview-size-picker.js.map +1 -1
- package/build/dataviews-layouts/index.js +12 -1
- package/build/dataviews-layouts/index.js.map +3 -3
- package/build/dataviews-layouts/list/index.js +4 -2
- package/build/dataviews-layouts/list/index.js.map +1 -1
- package/build/dataviews-layouts/picker-grid/index.js +4 -2
- package/build/dataviews-layouts/picker-grid/index.js.map +1 -1
- package/build/dataviews-layouts/picker-table/index.js +422 -0
- package/build/dataviews-layouts/picker-table/index.js.map +7 -0
- package/build/dataviews-layouts/table/column-header-menu.js +6 -4
- package/build/dataviews-layouts/table/column-header-menu.js.map +2 -2
- package/build/dataviews-layouts/table/column-primary.js +4 -7
- package/build/dataviews-layouts/table/column-primary.js.map +2 -2
- package/build/dataviews-layouts/table/density-picker.js +3 -1
- package/build/dataviews-layouts/table/density-picker.js.map +1 -1
- package/build/dataviews-layouts/table/index.js +36 -2
- package/build/dataviews-layouts/table/index.js.map +2 -2
- package/build/dataviews-layouts/table/use-is-horizontal-scroll-end.js +3 -1
- package/build/dataviews-layouts/table/use-is-horizontal-scroll-end.js.map +1 -1
- package/build/dataviews-layouts/utils/get-data-by-group.js +2 -0
- package/build/dataviews-layouts/utils/get-data-by-group.js.map +1 -1
- package/build/dataviews-layouts/utils/grid-items.js +4 -2
- package/build/dataviews-layouts/utils/grid-items.js.map +1 -1
- package/build/dataviews-layouts/utils/item-click-wrapper.js +3 -1
- package/build/dataviews-layouts/utils/item-click-wrapper.js.map +1 -1
- package/build/dataviews-layouts/utils/preview-size-picker.js +4 -2
- package/build/dataviews-layouts/utils/preview-size-picker.js.map +1 -1
- package/build/field-types/array.js +3 -1
- package/build/field-types/array.js.map +1 -1
- package/build/field-types/boolean.js +3 -1
- package/build/field-types/boolean.js.map +1 -1
- package/build/field-types/color.js +3 -1
- package/build/field-types/color.js.map +1 -1
- package/build/field-types/date.js +4 -2
- package/build/field-types/date.js.map +1 -1
- package/build/field-types/datetime.js +17 -2
- package/build/field-types/datetime.js.map +3 -3
- package/build/field-types/email.js +4 -2
- package/build/field-types/email.js.map +1 -1
- package/build/field-types/index.js +3 -1
- package/build/field-types/index.js.map +1 -1
- package/build/field-types/integer.js +3 -1
- package/build/field-types/integer.js.map +1 -1
- package/build/field-types/media.js +2 -0
- package/build/field-types/media.js.map +1 -1
- package/build/field-types/number.js +3 -1
- package/build/field-types/number.js.map +1 -1
- package/build/field-types/password.js +3 -1
- package/build/field-types/password.js.map +1 -1
- package/build/field-types/telephone.js +3 -1
- package/build/field-types/telephone.js.map +1 -1
- package/build/field-types/text.js +3 -1
- package/build/field-types/text.js.map +1 -1
- package/build/field-types/url.js +3 -1
- package/build/field-types/url.js.map +1 -1
- package/build/{dataform-layouts/is-combined-field.js → field-types/utils/parse-date-time.js} +15 -11
- package/build/field-types/utils/parse-date-time.js.map +7 -0
- package/build/field-types/utils/render-from-elements.js +2 -0
- package/build/field-types/utils/render-from-elements.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-elements.js +3 -1
- package/build/hooks/use-elements.js.map +1 -1
- package/build/hooks/use-form-validity.js +425 -321
- package/build/hooks/use-form-validity.js.map +3 -3
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +3 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/types/dataform.js +2 -0
- package/build/types/dataform.js.map +2 -2
- package/build/types/dataviews.js +2 -0
- package/build/types/dataviews.js.map +2 -2
- package/build/types/field-api.js +2 -0
- package/build/types/field-api.js.map +1 -1
- package/build/types/index.js +2 -0
- package/build/types/index.js.map +1 -1
- package/build/types/private.js +2 -0
- package/build/types/private.js.map +1 -1
- package/build/utils/filter-sort-and-paginate.js +3 -1
- package/build/utils/filter-sort-and-paginate.js.map +1 -1
- package/build/utils/has-elements.js +2 -0
- package/build/utils/has-elements.js.map +1 -1
- package/build/utils/normalize-fields.js +4 -2
- package/build/utils/normalize-fields.js.map +1 -1
- package/build-module/components/dataform/index.js +5 -2
- package/build-module/components/dataform/index.js.map +2 -2
- package/build-module/components/dataform-context/index.js +3 -2
- package/build-module/components/dataform-context/index.js.map +1 -1
- package/build-module/components/dataviews/index.js +7 -6
- package/build-module/components/dataviews/index.js.map +1 -1
- package/build-module/components/dataviews-bulk-actions/index.js +3 -2
- package/build-module/components/dataviews-bulk-actions/index.js.map +1 -1
- package/build-module/components/dataviews-context/index.js +2 -1
- package/build-module/components/dataviews-context/index.js.map +1 -1
- package/build-module/components/dataviews-filters/add-filter.js +3 -2
- package/build-module/components/dataviews-filters/add-filter.js.map +1 -1
- package/build-module/components/dataviews-filters/filter.js +19 -5
- package/build-module/components/dataviews-filters/filter.js.map +2 -2
- package/build-module/components/dataviews-filters/filters-toggled.js +2 -1
- package/build-module/components/dataviews-filters/filters-toggled.js.map +1 -1
- package/build-module/components/dataviews-filters/filters.js +2 -1
- package/build-module/components/dataviews-filters/filters.js.map +1 -1
- package/build-module/components/dataviews-filters/index.js +1 -0
- package/build-module/components/dataviews-filters/index.js.map +1 -1
- package/build-module/components/dataviews-filters/input-widget.js +2 -1
- package/build-module/components/dataviews-filters/input-widget.js.map +1 -1
- package/build-module/components/dataviews-filters/reset-filters.js +2 -1
- package/build-module/components/dataviews-filters/reset-filters.js.map +1 -1
- package/build-module/components/dataviews-filters/search-widget.js +7 -6
- package/build-module/components/dataviews-filters/search-widget.js.map +2 -2
- package/build-module/components/dataviews-filters/toggle.js +2 -1
- package/build-module/components/dataviews-filters/toggle.js.map +1 -1
- package/build-module/components/dataviews-filters/use-filters.js +1 -0
- package/build-module/components/dataviews-filters/use-filters.js.map +1 -1
- package/build-module/components/dataviews-filters/utils.js +3 -2
- package/build-module/components/dataviews-filters/utils.js.map +1 -1
- package/build-module/components/dataviews-footer/index.js +3 -2
- package/build-module/components/dataviews-footer/index.js.map +1 -1
- package/build-module/components/dataviews-item-actions/index.js +22 -4
- package/build-module/components/dataviews-item-actions/index.js.map +2 -2
- package/build-module/components/dataviews-layout/index.js +2 -1
- package/build-module/components/dataviews-layout/index.js.map +1 -1
- package/build-module/components/dataviews-pagination/index.js +2 -1
- package/build-module/components/dataviews-pagination/index.js.map +1 -1
- package/build-module/components/dataviews-picker/footer.js +3 -2
- package/build-module/components/dataviews-picker/footer.js.map +1 -1
- package/build-module/components/dataviews-picker/index.js +7 -6
- package/build-module/components/dataviews-picker/index.js.map +1 -1
- package/build-module/components/dataviews-search/index.js +3 -2
- package/build-module/components/dataviews-search/index.js.map +1 -1
- package/build-module/components/dataviews-selection-checkbox/index.js +2 -1
- package/build-module/components/dataviews-selection-checkbox/index.js.map +1 -1
- package/build-module/components/dataviews-view-config/index.js +20 -416
- package/build-module/components/dataviews-view-config/index.js.map +2 -2
- package/build-module/components/dataviews-view-config/infinite-scroll-toggle.js +2 -1
- package/build-module/components/dataviews-view-config/infinite-scroll-toggle.js.map +1 -1
- package/build-module/components/dataviews-view-config/properties-section.js +149 -0
- package/build-module/components/dataviews-view-config/properties-section.js.map +7 -0
- package/build-module/constants.js +37 -34
- package/build-module/constants.js.map +2 -2
- package/build-module/dataform-controls/array.js +3 -2
- package/build-module/dataform-controls/array.js.map +1 -1
- package/build-module/dataform-controls/checkbox.js +3 -2
- package/build-module/dataform-controls/checkbox.js.map +1 -1
- package/build-module/dataform-controls/color.js +4 -3
- package/build-module/dataform-controls/color.js.map +1 -1
- package/build-module/dataform-controls/date.js +7 -6
- package/build-module/dataform-controls/date.js.map +1 -1
- package/build-module/dataform-controls/datetime.js +7 -12
- package/build-module/dataform-controls/datetime.js.map +2 -2
- package/build-module/dataform-controls/email.js +2 -1
- package/build-module/dataform-controls/email.js.map +1 -1
- package/build-module/dataform-controls/index.js +3 -2
- package/build-module/dataform-controls/index.js.map +1 -1
- package/build-module/dataform-controls/integer.js +2 -1
- package/build-module/dataform-controls/integer.js.map +1 -1
- package/build-module/dataform-controls/number.js +2 -1
- package/build-module/dataform-controls/number.js.map +1 -1
- package/build-module/dataform-controls/password.js +9 -6
- package/build-module/dataform-controls/password.js.map +2 -2
- package/build-module/dataform-controls/radio.js +3 -2
- package/build-module/dataform-controls/radio.js.map +1 -1
- package/build-module/dataform-controls/select.js +3 -2
- package/build-module/dataform-controls/select.js.map +1 -1
- package/build-module/dataform-controls/telephone.js +2 -1
- package/build-module/dataform-controls/telephone.js.map +1 -1
- package/build-module/dataform-controls/text.js +2 -1
- package/build-module/dataform-controls/text.js.map +1 -1
- package/build-module/dataform-controls/textarea.js +3 -2
- package/build-module/dataform-controls/textarea.js.map +1 -1
- package/build-module/dataform-controls/toggle-group.js +3 -2
- package/build-module/dataform-controls/toggle-group.js.map +1 -1
- package/build-module/dataform-controls/toggle.js +3 -2
- package/build-module/dataform-controls/toggle.js.map +1 -1
- package/build-module/dataform-controls/url.js +2 -1
- package/build-module/dataform-controls/url.js.map +1 -1
- package/build-module/dataform-controls/utils/get-custom-validity.js +1 -0
- package/build-module/dataform-controls/utils/get-custom-validity.js.map +1 -1
- package/build-module/dataform-controls/utils/relative-date-control.js +3 -2
- package/build-module/dataform-controls/utils/relative-date-control.js.map +1 -1
- package/build-module/dataform-controls/utils/validated-input.js +3 -2
- package/build-module/dataform-controls/utils/validated-input.js.map +1 -1
- package/build-module/dataform-controls/utils/validated-number.js +3 -2
- package/build-module/dataform-controls/utils/validated-number.js.map +1 -1
- package/build-module/dataform-layouts/card/index.js +95 -42
- package/build-module/dataform-layouts/card/index.js.map +3 -3
- package/build-module/dataform-layouts/data-form-layout.js +8 -15
- package/build-module/dataform-layouts/data-form-layout.js.map +2 -2
- package/build-module/dataform-layouts/details/index.js +47 -0
- package/build-module/dataform-layouts/details/index.js.map +7 -0
- package/build-module/dataform-layouts/get-summary-fields.js +2 -1
- package/build-module/dataform-layouts/get-summary-fields.js.map +1 -1
- package/build-module/dataform-layouts/index.js +8 -2
- package/build-module/dataform-layouts/index.js.map +2 -2
- package/build-module/dataform-layouts/{normalize-form-fields.js → normalize-form.js} +43 -19
- package/build-module/dataform-layouts/normalize-form.js.map +7 -0
- package/build-module/dataform-layouts/panel/dropdown.js +7 -7
- package/build-module/dataform-layouts/panel/dropdown.js.map +2 -2
- package/build-module/dataform-layouts/panel/index.js +9 -14
- package/build-module/dataform-layouts/panel/index.js.map +2 -2
- package/build-module/dataform-layouts/panel/modal.js +7 -7
- package/build-module/dataform-layouts/panel/modal.js.map +2 -2
- package/build-module/dataform-layouts/panel/summary-button.js +2 -1
- package/build-module/dataform-layouts/panel/summary-button.js.map +1 -1
- package/build-module/dataform-layouts/regular/index.js +6 -9
- package/build-module/dataform-layouts/regular/index.js.map +2 -2
- package/build-module/dataform-layouts/row/index.js +9 -23
- package/build-module/dataform-layouts/row/index.js.map +2 -2
- package/build-module/dataviews-layouts/grid/index.js +3 -2
- package/build-module/dataviews-layouts/grid/index.js.map +1 -1
- package/build-module/dataviews-layouts/grid/preview-size-picker.js +3 -2
- package/build-module/dataviews-layouts/grid/preview-size-picker.js.map +1 -1
- package/build-module/dataviews-layouts/index.js +13 -2
- package/build-module/dataviews-layouts/index.js.map +2 -2
- package/build-module/dataviews-layouts/list/index.js +3 -2
- package/build-module/dataviews-layouts/list/index.js.map +1 -1
- package/build-module/dataviews-layouts/picker-grid/index.js +3 -2
- package/build-module/dataviews-layouts/picker-grid/index.js.map +1 -1
- package/build-module/dataviews-layouts/picker-table/index.js +397 -0
- package/build-module/dataviews-layouts/picker-table/index.js.map +7 -0
- package/build-module/dataviews-layouts/table/column-header-menu.js +5 -4
- package/build-module/dataviews-layouts/table/column-header-menu.js.map +2 -2
- package/build-module/dataviews-layouts/table/column-primary.js +3 -7
- package/build-module/dataviews-layouts/table/column-primary.js.map +2 -2
- package/build-module/dataviews-layouts/table/density-picker.js +2 -1
- package/build-module/dataviews-layouts/table/density-picker.js.map +1 -1
- package/build-module/dataviews-layouts/table/index.js +36 -3
- package/build-module/dataviews-layouts/table/index.js.map +2 -2
- package/build-module/dataviews-layouts/table/use-is-horizontal-scroll-end.js +2 -1
- package/build-module/dataviews-layouts/table/use-is-horizontal-scroll-end.js.map +1 -1
- package/build-module/dataviews-layouts/utils/get-data-by-group.js +1 -0
- package/build-module/dataviews-layouts/utils/get-data-by-group.js.map +1 -1
- package/build-module/dataviews-layouts/utils/grid-items.js +3 -2
- package/build-module/dataviews-layouts/utils/grid-items.js.map +1 -1
- package/build-module/dataviews-layouts/utils/item-click-wrapper.js +2 -1
- package/build-module/dataviews-layouts/utils/item-click-wrapper.js.map +1 -1
- package/build-module/dataviews-layouts/utils/preview-size-picker.js +3 -2
- package/build-module/dataviews-layouts/utils/preview-size-picker.js.map +1 -1
- package/build-module/field-types/array.js +2 -1
- package/build-module/field-types/array.js.map +1 -1
- package/build-module/field-types/boolean.js +2 -1
- package/build-module/field-types/boolean.js.map +1 -1
- package/build-module/field-types/color.js +2 -1
- package/build-module/field-types/color.js.map +1 -1
- package/build-module/field-types/date.js +3 -2
- package/build-module/field-types/date.js.map +1 -1
- package/build-module/field-types/datetime.js +16 -2
- package/build-module/field-types/datetime.js.map +2 -2
- package/build-module/field-types/email.js +3 -2
- package/build-module/field-types/email.js.map +1 -1
- package/build-module/field-types/index.js +2 -1
- package/build-module/field-types/index.js.map +1 -1
- package/build-module/field-types/integer.js +2 -1
- package/build-module/field-types/integer.js.map +1 -1
- package/build-module/field-types/media.js +1 -0
- package/build-module/field-types/media.js.map +1 -1
- package/build-module/field-types/number.js +2 -1
- package/build-module/field-types/number.js.map +1 -1
- package/build-module/field-types/password.js +2 -1
- package/build-module/field-types/password.js.map +1 -1
- package/build-module/field-types/telephone.js +2 -1
- package/build-module/field-types/telephone.js.map +1 -1
- package/build-module/field-types/text.js +2 -1
- package/build-module/field-types/text.js.map +1 -1
- package/build-module/field-types/url.js +2 -1
- package/build-module/field-types/url.js.map +1 -1
- package/build-module/field-types/utils/parse-date-time.js +14 -0
- package/build-module/field-types/utils/parse-date-time.js.map +7 -0
- package/build-module/field-types/utils/render-from-elements.js +1 -0
- package/build-module/field-types/utils/render-from-elements.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-elements.js +2 -1
- package/build-module/hooks/use-elements.js.map +1 -1
- package/build-module/hooks/use-form-validity.js +424 -321
- package/build-module/hooks/use-form-validity.js.map +3 -3
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +2 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/utils/filter-sort-and-paginate.js +2 -1
- package/build-module/utils/filter-sort-and-paginate.js.map +1 -1
- package/build-module/utils/has-elements.js +1 -0
- package/build-module/utils/has-elements.js.map +1 -1
- package/build-module/utils/normalize-fields.js +3 -2
- package/build-module/utils/normalize-fields.js.map +1 -1
- package/build-style/style-rtl.css +41 -51
- package/build-style/style.css +41 -51
- package/build-types/components/dataform/index.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/filter.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/utils.d.ts.map +1 -1
- package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -1
- package/build-types/components/dataviews-view-config/index.d.ts.map +1 -1
- package/build-types/components/dataviews-view-config/properties-section.d.ts +4 -0
- package/build-types/components/dataviews-view-config/properties-section.d.ts.map +1 -0
- package/build-types/constants.d.ts +1 -0
- package/build-types/constants.d.ts.map +1 -1
- package/build-types/dataform-controls/datetime.d.ts.map +1 -1
- package/build-types/dataform-controls/password.d.ts.map +1 -1
- package/build-types/dataform-layouts/card/index.d.ts +3 -3
- package/build-types/dataform-layouts/card/index.d.ts.map +1 -1
- package/build-types/dataform-layouts/data-form-layout.d.ts +4 -4
- package/build-types/dataform-layouts/data-form-layout.d.ts.map +1 -1
- package/build-types/dataform-layouts/details/index.d.ts +6 -0
- package/build-types/dataform-layouts/details/index.d.ts.map +1 -0
- package/build-types/dataform-layouts/get-summary-fields.d.ts.map +1 -1
- package/build-types/dataform-layouts/index.d.ts +7 -2
- package/build-types/dataform-layouts/index.d.ts.map +1 -1
- package/build-types/dataform-layouts/normalize-form.d.ts +8 -0
- package/build-types/dataform-layouts/normalize-form.d.ts.map +1 -0
- package/build-types/dataform-layouts/panel/dropdown.d.ts +2 -2
- package/build-types/dataform-layouts/panel/dropdown.d.ts.map +1 -1
- package/build-types/dataform-layouts/panel/index.d.ts.map +1 -1
- package/build-types/dataform-layouts/panel/modal.d.ts +2 -2
- package/build-types/dataform-layouts/panel/modal.d.ts.map +1 -1
- package/build-types/dataform-layouts/regular/index.d.ts.map +1 -1
- package/build-types/dataform-layouts/row/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/index.d.ts +8 -0
- package/build-types/dataviews-layouts/index.d.ts.map +1 -1
- package/build-types/dataviews-layouts/picker-table/index.d.ts +4 -0
- package/build-types/dataviews-layouts/picker-table/index.d.ts.map +1 -0
- package/build-types/dataviews-layouts/table/column-header-menu.d.ts +3 -3
- package/build-types/dataviews-layouts/table/column-header-menu.d.ts.map +1 -1
- package/build-types/dataviews-layouts/table/column-primary.d.ts.map +1 -1
- package/build-types/dataviews-layouts/table/index.d.ts.map +1 -1
- package/build-types/field-types/datetime.d.ts +1 -1
- package/build-types/field-types/datetime.d.ts.map +1 -1
- package/build-types/field-types/utils/parse-date-time.d.ts +2 -0
- package/build-types/field-types/utils/parse-date-time.d.ts.map +1 -0
- package/build-types/hooks/use-form-validity.d.ts.map +1 -1
- package/build-types/stories/dataform.story.d.ts +13 -11
- package/build-types/stories/dataform.story.d.ts.map +1 -1
- package/build-types/stories/dataviews-picker.story.d.ts +33 -0
- package/build-types/stories/dataviews-picker.story.d.ts.map +1 -1
- package/build-types/stories/dataviews.story.d.ts +7 -1
- package/build-types/stories/dataviews.story.d.ts.map +1 -1
- package/build-types/test/normalize-form.d.ts +2 -0
- package/build-types/test/normalize-form.d.ts.map +1 -0
- package/build-types/types/dataform.d.ts +27 -9
- package/build-types/types/dataform.d.ts.map +1 -1
- package/build-types/types/dataviews.d.ts +23 -2
- package/build-types/types/dataviews.d.ts.map +1 -1
- package/build-wp/index.js +2258 -1817
- package/package.json +15 -15
- package/src/components/dataform/index.tsx +3 -1
- package/src/components/dataviews/style.scss +1 -1
- package/src/components/dataviews-bulk-actions/style.scss +1 -1
- package/src/components/dataviews-filters/filter.tsx +16 -1
- package/src/components/dataviews-filters/style.scss +1 -1
- package/src/components/dataviews-item-actions/index.tsx +37 -14
- package/src/components/dataviews-pagination/style.scss +2 -2
- package/src/components/dataviews-view-config/index.tsx +8 -504
- package/src/components/dataviews-view-config/properties-section.tsx +201 -0
- package/src/components/dataviews-view-config/style.scss +2 -39
- package/src/constants.ts +1 -0
- package/src/dataform-controls/datetime.tsx +3 -10
- package/src/dataform-controls/password.tsx +16 -12
- package/src/dataform-layouts/card/index.tsx +89 -33
- package/src/dataform-layouts/data-form-layout.tsx +12 -23
- package/src/dataform-layouts/details/index.tsx +71 -0
- package/src/dataform-layouts/details/style.scss +5 -0
- package/src/dataform-layouts/index.tsx +10 -3
- package/src/dataform-layouts/{normalize-form-fields.ts → normalize-form.ts} +50 -23
- package/src/dataform-layouts/panel/dropdown.tsx +10 -13
- package/src/dataform-layouts/panel/index.tsx +9 -24
- package/src/dataform-layouts/panel/modal.tsx +15 -15
- package/src/dataform-layouts/regular/index.tsx +7 -12
- package/src/dataform-layouts/row/index.tsx +13 -26
- package/src/dataviews-layouts/index.ts +10 -0
- package/src/dataviews-layouts/picker-table/index.tsx +487 -0
- package/src/dataviews-layouts/picker-table/style.scss +45 -0
- package/src/dataviews-layouts/table/column-header-menu.tsx +3 -2
- package/src/dataviews-layouts/table/column-primary.tsx +4 -7
- package/src/dataviews-layouts/table/index.tsx +37 -2
- package/src/dataviews-layouts/table/style.scss +2 -2
- package/src/field-types/datetime.tsx +16 -5
- package/src/field-types/utils/parse-date-time.ts +17 -0
- package/src/hooks/use-form-validity.ts +572 -422
- package/src/stories/dataform.story.tsx +604 -456
- package/src/stories/dataviews-picker.story.tsx +166 -38
- package/src/stories/dataviews.story.tsx +10 -2
- package/src/stories/field-types.story.tsx +7 -7
- package/src/style.scss +2 -0
- package/src/test/normalize-form.ts +568 -0
- package/src/test/use-form-validity.ts +318 -33
- package/src/types/dataform.ts +36 -11
- package/src/types/dataviews.ts +36 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dataform-layouts/is-combined-field.js.map +0 -7
- package/build/dataform-layouts/normalize-form-fields.js.map +0 -7
- package/build-module/dataform-layouts/is-combined-field.js +0 -7
- package/build-module/dataform-layouts/is-combined-field.js.map +0 -7
- package/build-module/dataform-layouts/normalize-form-fields.js.map +0 -7
- package/build-types/dataform-layouts/is-combined-field.d.ts +0 -6
- package/build-types/dataform-layouts/is-combined-field.d.ts.map +0 -1
- package/build-types/dataform-layouts/normalize-form-fields.d.ts +0 -19
- package/build-types/dataform-layouts/normalize-form-fields.d.ts.map +0 -1
- package/build-types/test/normalize-form-fields.d.ts +0 -2
- package/build-types/test/normalize-form-fields.d.ts.map +0 -1
- package/src/dataform-layouts/is-combined-field.ts +0 -10
- package/src/test/normalize-form-fields.ts +0 -317
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useContext, useMemo } from '@wordpress/element';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import type {
|
|
11
|
+
NormalizedForm,
|
|
12
|
+
NormalizedDetailsLayout,
|
|
13
|
+
FieldLayoutProps,
|
|
14
|
+
} from '../../types';
|
|
15
|
+
import DataFormContext from '../../components/dataform-context';
|
|
16
|
+
import { DataFormLayout } from '../data-form-layout';
|
|
17
|
+
import { DEFAULT_LAYOUT } from '../normalize-form';
|
|
18
|
+
|
|
19
|
+
export default function FormDetailsField< Item >( {
|
|
20
|
+
data,
|
|
21
|
+
field,
|
|
22
|
+
onChange,
|
|
23
|
+
}: FieldLayoutProps< Item > ) {
|
|
24
|
+
const { fields } = useContext( DataFormContext );
|
|
25
|
+
|
|
26
|
+
const form: NormalizedForm = useMemo(
|
|
27
|
+
() => ( {
|
|
28
|
+
layout: DEFAULT_LAYOUT,
|
|
29
|
+
fields: field.children ?? [],
|
|
30
|
+
} ),
|
|
31
|
+
[ field ]
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
if ( ! field.children ) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Find the summary field definition if specified
|
|
39
|
+
const summaryFieldId =
|
|
40
|
+
( field.layout as NormalizedDetailsLayout ).summary ?? '';
|
|
41
|
+
const summaryField = summaryFieldId
|
|
42
|
+
? fields.find( ( fieldDef ) => fieldDef.id === summaryFieldId )
|
|
43
|
+
: undefined;
|
|
44
|
+
|
|
45
|
+
// Render the summary content
|
|
46
|
+
let summaryContent;
|
|
47
|
+
if ( summaryField && summaryField.render ) {
|
|
48
|
+
// Use the field's render function to display the current value
|
|
49
|
+
summaryContent = (
|
|
50
|
+
<summaryField.render item={ data } field={ summaryField } />
|
|
51
|
+
);
|
|
52
|
+
} else {
|
|
53
|
+
// Fall back to the label
|
|
54
|
+
summaryContent = field.label || __( 'More details' );
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<details className="dataforms-layouts-details__details">
|
|
59
|
+
<summary className="dataforms-layouts-details__summary">
|
|
60
|
+
{ summaryContent }
|
|
61
|
+
</summary>
|
|
62
|
+
<div className="dataforms-layouts-details__content">
|
|
63
|
+
<DataFormLayout
|
|
64
|
+
data={ data }
|
|
65
|
+
form={ form }
|
|
66
|
+
onChange={ onChange }
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
</details>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
|
-
import type {
|
|
12
|
+
import type { NormalizedLayout, NormalizedRowLayout } from '../types';
|
|
13
13
|
import FormRegularField from './regular';
|
|
14
14
|
import FormPanelField from './panel';
|
|
15
15
|
import FormCardField from './card';
|
|
16
16
|
import FormRowField from './row';
|
|
17
|
+
import FormDetailsField from './details';
|
|
17
18
|
|
|
18
19
|
const FORM_FIELD_LAYOUTS = [
|
|
19
20
|
{
|
|
@@ -51,13 +52,15 @@ const FORM_FIELD_LAYOUTS = [
|
|
|
51
52
|
layout,
|
|
52
53
|
}: {
|
|
53
54
|
children: React.ReactNode;
|
|
54
|
-
layout:
|
|
55
|
+
layout: NormalizedLayout;
|
|
55
56
|
} ) => (
|
|
56
57
|
<VStack className="dataforms-layouts__wrapper" spacing={ 4 }>
|
|
57
58
|
<div className="dataforms-layouts-row__field">
|
|
58
59
|
<HStack
|
|
59
60
|
spacing={ 4 }
|
|
60
|
-
alignment={
|
|
61
|
+
alignment={
|
|
62
|
+
( layout as NormalizedRowLayout ).alignment
|
|
63
|
+
}
|
|
61
64
|
>
|
|
62
65
|
{ children }
|
|
63
66
|
</HStack>
|
|
@@ -65,6 +68,10 @@ const FORM_FIELD_LAYOUTS = [
|
|
|
65
68
|
</VStack>
|
|
66
69
|
),
|
|
67
70
|
},
|
|
71
|
+
{
|
|
72
|
+
type: 'details',
|
|
73
|
+
component: FormDetailsField,
|
|
74
|
+
},
|
|
68
75
|
];
|
|
69
76
|
|
|
70
77
|
export function getFormFieldLayout( type: string ) {
|
|
@@ -4,20 +4,18 @@
|
|
|
4
4
|
import type {
|
|
5
5
|
Form,
|
|
6
6
|
Layout,
|
|
7
|
+
NormalizedForm,
|
|
8
|
+
NormalizedFormField,
|
|
7
9
|
NormalizedLayout,
|
|
8
10
|
NormalizedRegularLayout,
|
|
9
11
|
NormalizedPanelLayout,
|
|
10
12
|
NormalizedCardLayout,
|
|
11
13
|
NormalizedRowLayout,
|
|
14
|
+
NormalizedDetailsLayout,
|
|
12
15
|
NormalizedCardSummaryField,
|
|
13
16
|
CardSummaryField,
|
|
14
17
|
} from '../types';
|
|
15
18
|
|
|
16
|
-
interface NormalizedFormField {
|
|
17
|
-
id: string;
|
|
18
|
-
layout: Layout;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
19
|
export const DEFAULT_LAYOUT: NormalizedLayout = {
|
|
22
20
|
type: 'regular',
|
|
23
21
|
labelPosition: 'top',
|
|
@@ -43,7 +41,7 @@ const normalizeCardSummaryField = (
|
|
|
43
41
|
* @param layout The layout object to normalize.
|
|
44
42
|
* @return The normalized layout object.
|
|
45
43
|
*/
|
|
46
|
-
|
|
44
|
+
function normalizeLayout( layout?: Layout ): NormalizedLayout {
|
|
47
45
|
let normalizedLayout = DEFAULT_LAYOUT;
|
|
48
46
|
|
|
49
47
|
if ( layout?.type === 'regular' ) {
|
|
@@ -72,6 +70,7 @@ export function normalizeLayout( layout?: Layout ): NormalizedLayout {
|
|
|
72
70
|
withHeader: false,
|
|
73
71
|
isOpened: true,
|
|
74
72
|
summary: [],
|
|
73
|
+
isCollapsible: false,
|
|
75
74
|
} satisfies NormalizedCardLayout;
|
|
76
75
|
} else {
|
|
77
76
|
const summary = layout.summary ?? [];
|
|
@@ -84,6 +83,10 @@ export function normalizeLayout( layout?: Layout ): NormalizedLayout {
|
|
|
84
83
|
? layout.isOpened
|
|
85
84
|
: true,
|
|
86
85
|
summary: normalizeCardSummaryField( summary ),
|
|
86
|
+
isCollapsible:
|
|
87
|
+
layout.isCollapsible === undefined
|
|
88
|
+
? true
|
|
89
|
+
: layout.isCollapsible,
|
|
87
90
|
} satisfies NormalizedCardLayout;
|
|
88
91
|
}
|
|
89
92
|
} else if ( layout?.type === 'row' ) {
|
|
@@ -92,30 +95,54 @@ export function normalizeLayout( layout?: Layout ): NormalizedLayout {
|
|
|
92
95
|
alignment: layout?.alignment ?? 'center',
|
|
93
96
|
styles: layout?.styles ?? {},
|
|
94
97
|
} satisfies NormalizedRowLayout;
|
|
98
|
+
} else if ( layout?.type === 'details' ) {
|
|
99
|
+
normalizedLayout = {
|
|
100
|
+
type: 'details',
|
|
101
|
+
summary: layout?.summary ?? '',
|
|
102
|
+
} satisfies NormalizedDetailsLayout;
|
|
95
103
|
}
|
|
96
104
|
|
|
97
105
|
return normalizedLayout;
|
|
98
106
|
}
|
|
99
107
|
|
|
100
|
-
|
|
101
|
-
form
|
|
102
|
-
|
|
103
|
-
const
|
|
108
|
+
function normalizeForm( form: Form ): NormalizedForm {
|
|
109
|
+
const normalizedFormLayout = normalizeLayout( form?.layout );
|
|
110
|
+
|
|
111
|
+
const normalizedFields: NormalizedFormField[] = ( form.fields ?? [] ).map(
|
|
112
|
+
( field ) => {
|
|
113
|
+
if ( typeof field === 'string' ) {
|
|
114
|
+
return {
|
|
115
|
+
id: field,
|
|
116
|
+
layout: normalizedFormLayout,
|
|
117
|
+
} satisfies NormalizedFormField;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const fieldLayout = field.layout
|
|
121
|
+
? normalizeLayout( field.layout )
|
|
122
|
+
: normalizedFormLayout;
|
|
104
123
|
|
|
105
|
-
return ( form.fields ?? [] ).map( ( field ) => {
|
|
106
|
-
if ( typeof field === 'string' ) {
|
|
107
124
|
return {
|
|
108
|
-
id: field,
|
|
109
|
-
layout:
|
|
110
|
-
|
|
125
|
+
id: field.id,
|
|
126
|
+
layout: fieldLayout,
|
|
127
|
+
...( !! field.label && { label: field.label } ),
|
|
128
|
+
...( !! field.description && {
|
|
129
|
+
description: field.description,
|
|
130
|
+
} ),
|
|
131
|
+
...( 'children' in field &&
|
|
132
|
+
Array.isArray( field.children ) && {
|
|
133
|
+
children: normalizeForm( {
|
|
134
|
+
fields: field.children,
|
|
135
|
+
layout: DEFAULT_LAYOUT,
|
|
136
|
+
} ).fields,
|
|
137
|
+
} ),
|
|
138
|
+
} satisfies NormalizedFormField;
|
|
111
139
|
}
|
|
140
|
+
);
|
|
112
141
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
...field,
|
|
118
|
-
layout: fieldLayout,
|
|
119
|
-
};
|
|
120
|
-
} );
|
|
142
|
+
return {
|
|
143
|
+
layout: normalizedFormLayout,
|
|
144
|
+
fields: normalizedFields,
|
|
145
|
+
};
|
|
121
146
|
}
|
|
147
|
+
|
|
148
|
+
export default normalizeForm;
|
|
@@ -18,14 +18,13 @@ import { closeSmall } from '@wordpress/icons';
|
|
|
18
18
|
*/
|
|
19
19
|
import type {
|
|
20
20
|
FieldValidity,
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
NormalizedForm,
|
|
22
|
+
NormalizedFormField,
|
|
23
23
|
FormValidity,
|
|
24
24
|
NormalizedField,
|
|
25
25
|
} from '../../types';
|
|
26
26
|
import { DataFormLayout } from '../data-form-layout';
|
|
27
|
-
import {
|
|
28
|
-
import { DEFAULT_LAYOUT } from '../normalize-form-fields';
|
|
27
|
+
import { DEFAULT_LAYOUT } from '../normalize-form';
|
|
29
28
|
import SummaryButton from './summary-button';
|
|
30
29
|
|
|
31
30
|
function DropdownHeader( {
|
|
@@ -71,7 +70,7 @@ function PanelDropdown< Item >( {
|
|
|
71
70
|
popoverAnchor,
|
|
72
71
|
}: {
|
|
73
72
|
data: Item;
|
|
74
|
-
field:
|
|
73
|
+
field: NormalizedFormField;
|
|
75
74
|
onChange: ( value: any ) => void;
|
|
76
75
|
validity?: FieldValidity;
|
|
77
76
|
labelPosition: 'side' | 'top' | 'none';
|
|
@@ -79,17 +78,15 @@ function PanelDropdown< Item >( {
|
|
|
79
78
|
fieldDefinition: NormalizedField< Item >;
|
|
80
79
|
popoverAnchor: HTMLElement | null;
|
|
81
80
|
} ) {
|
|
82
|
-
const fieldLabel =
|
|
83
|
-
? field.label
|
|
84
|
-
: fieldDefinition?.label;
|
|
81
|
+
const fieldLabel = !! field.children ? field.label : fieldDefinition?.label;
|
|
85
82
|
|
|
86
|
-
const form:
|
|
87
|
-
()
|
|
83
|
+
const form: NormalizedForm = useMemo(
|
|
84
|
+
() => ( {
|
|
88
85
|
layout: DEFAULT_LAYOUT,
|
|
89
|
-
fields:
|
|
86
|
+
fields: !! field.children
|
|
90
87
|
? field.children
|
|
91
88
|
: // If not explicit children return the field id itself.
|
|
92
|
-
[ { id: field.id } ],
|
|
89
|
+
[ { id: field.id, layout: DEFAULT_LAYOUT } ],
|
|
93
90
|
} ),
|
|
94
91
|
[ field ]
|
|
95
92
|
);
|
|
@@ -98,7 +95,7 @@ function PanelDropdown< Item >( {
|
|
|
98
95
|
return undefined;
|
|
99
96
|
}
|
|
100
97
|
|
|
101
|
-
if (
|
|
98
|
+
if ( !! field.children ) {
|
|
102
99
|
return validity?.children;
|
|
103
100
|
}
|
|
104
101
|
|
|
@@ -17,48 +17,39 @@ import { useState, useContext } from '@wordpress/element';
|
|
|
17
17
|
*/
|
|
18
18
|
import type {
|
|
19
19
|
FieldLayoutProps,
|
|
20
|
-
FormField,
|
|
21
20
|
NormalizedField,
|
|
21
|
+
NormalizedFormField,
|
|
22
22
|
NormalizedPanelLayout,
|
|
23
|
-
PanelLayout,
|
|
24
|
-
SimpleFormField,
|
|
25
23
|
} from '../../types';
|
|
26
24
|
import DataFormContext from '../../components/dataform-context';
|
|
27
|
-
import { isCombinedField } from '../is-combined-field';
|
|
28
|
-
import { normalizeLayout } from '../normalize-form-fields';
|
|
29
25
|
import PanelDropdown from './dropdown';
|
|
30
26
|
import PanelModal from './modal';
|
|
31
27
|
import { getSummaryFields } from '../get-summary-fields';
|
|
32
28
|
|
|
33
29
|
const getFieldDefinition = < Item, >(
|
|
34
|
-
field:
|
|
30
|
+
field: NormalizedFormField,
|
|
35
31
|
fields: NormalizedField< Item >[]
|
|
36
32
|
) => {
|
|
37
33
|
const fieldDefinition = fields.find( ( _field ) => _field.id === field.id );
|
|
38
34
|
|
|
39
35
|
if ( ! fieldDefinition ) {
|
|
40
36
|
return fields.find( ( _field ) => {
|
|
41
|
-
if (
|
|
37
|
+
if ( !! field.children ) {
|
|
42
38
|
const simpleChildren = field.children.filter(
|
|
43
|
-
( child )
|
|
44
|
-
typeof child === 'string' || ! isCombinedField( child )
|
|
39
|
+
( child ) => ! child.children
|
|
45
40
|
);
|
|
46
41
|
|
|
47
42
|
if ( simpleChildren.length === 0 ) {
|
|
48
43
|
return false;
|
|
49
44
|
}
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
typeof simpleChildren[ 0 ] === 'string'
|
|
53
|
-
? simpleChildren[ 0 ]
|
|
54
|
-
: simpleChildren[ 0 ].id;
|
|
55
|
-
|
|
56
|
-
return _field.id === firstChildFieldId;
|
|
46
|
+
return _field.id === simpleChildren[ 0 ].id;
|
|
57
47
|
}
|
|
58
48
|
|
|
59
49
|
return _field.id === field.id;
|
|
60
50
|
} );
|
|
61
51
|
}
|
|
52
|
+
|
|
62
53
|
return fieldDefinition;
|
|
63
54
|
};
|
|
64
55
|
|
|
@@ -78,7 +69,7 @@ const getFieldDefinition = < Item, >(
|
|
|
78
69
|
*/
|
|
79
70
|
const getFieldDefinitionAndSummaryFields = < Item, >(
|
|
80
71
|
layout: NormalizedPanelLayout,
|
|
81
|
-
field:
|
|
72
|
+
field: NormalizedFormField,
|
|
82
73
|
fields: NormalizedField< Item >[]
|
|
83
74
|
) => {
|
|
84
75
|
const summaryFields = getSummaryFields( layout.summary, fields );
|
|
@@ -104,11 +95,7 @@ export default function FormPanelField< Item >( {
|
|
|
104
95
|
validity,
|
|
105
96
|
}: FieldLayoutProps< Item > ) {
|
|
106
97
|
const { fields } = useContext( DataFormContext );
|
|
107
|
-
|
|
108
|
-
const layout: NormalizedPanelLayout = normalizeLayout( {
|
|
109
|
-
...field.layout,
|
|
110
|
-
type: 'panel',
|
|
111
|
-
} as PanelLayout ) as NormalizedPanelLayout;
|
|
98
|
+
const layout = field.layout as NormalizedPanelLayout;
|
|
112
99
|
|
|
113
100
|
// Use internal state instead of a ref to make sure that the component
|
|
114
101
|
// re-renders when the popover's anchor updates.
|
|
@@ -128,9 +115,7 @@ export default function FormPanelField< Item >( {
|
|
|
128
115
|
'dataforms-layouts-panel__field-label',
|
|
129
116
|
`dataforms-layouts-panel__field-label--label-position-${ labelPosition }`
|
|
130
117
|
);
|
|
131
|
-
const fieldLabel =
|
|
132
|
-
? field.label
|
|
133
|
-
: fieldDefinition?.label;
|
|
118
|
+
const fieldLabel = !! field.children ? field.label : fieldDefinition?.label;
|
|
134
119
|
|
|
135
120
|
const renderedControl =
|
|
136
121
|
layout.openAs === 'modal' ? (
|
|
@@ -18,10 +18,14 @@ import { useContext, useState, useMemo } from '@wordpress/element';
|
|
|
18
18
|
/**
|
|
19
19
|
* Internal dependencies
|
|
20
20
|
*/
|
|
21
|
-
import type {
|
|
21
|
+
import type {
|
|
22
|
+
Field,
|
|
23
|
+
NormalizedForm,
|
|
24
|
+
NormalizedFormField,
|
|
25
|
+
NormalizedField,
|
|
26
|
+
} from '../../types';
|
|
22
27
|
import { DataFormLayout } from '../data-form-layout';
|
|
23
|
-
import {
|
|
24
|
-
import { DEFAULT_LAYOUT } from '../normalize-form-fields';
|
|
28
|
+
import { DEFAULT_LAYOUT } from '../normalize-form';
|
|
25
29
|
import SummaryButton from './summary-button';
|
|
26
30
|
import useFormValidity from '../../hooks/use-form-validity';
|
|
27
31
|
import DataFormContext from '../../components/dataform-context';
|
|
@@ -34,7 +38,7 @@ function ModalContent< Item >( {
|
|
|
34
38
|
onClose,
|
|
35
39
|
}: {
|
|
36
40
|
data: Item;
|
|
37
|
-
field:
|
|
41
|
+
field: NormalizedFormField;
|
|
38
42
|
onChange: ( data: Partial< Item > ) => void;
|
|
39
43
|
onClose: () => void;
|
|
40
44
|
fieldLabel: string;
|
|
@@ -45,13 +49,13 @@ function ModalContent< Item >( {
|
|
|
45
49
|
return deepMerge( data, changes );
|
|
46
50
|
}, [ data, changes ] );
|
|
47
51
|
|
|
48
|
-
const form:
|
|
49
|
-
()
|
|
52
|
+
const form: NormalizedForm = useMemo(
|
|
53
|
+
() => ( {
|
|
50
54
|
layout: DEFAULT_LAYOUT,
|
|
51
|
-
fields:
|
|
55
|
+
fields: !! field.children
|
|
52
56
|
? field.children
|
|
53
57
|
: // If not explicit children return the field id itself.
|
|
54
|
-
[ { id: field.id } ],
|
|
58
|
+
[ { id: field.id, layout: DEFAULT_LAYOUT } ],
|
|
55
59
|
} ),
|
|
56
60
|
[ field ]
|
|
57
61
|
);
|
|
@@ -91,9 +95,7 @@ function ModalContent< Item >( {
|
|
|
91
95
|
data={ modalData }
|
|
92
96
|
field={ childField }
|
|
93
97
|
onChange={ handleOnChange }
|
|
94
|
-
hideLabelFromVision={
|
|
95
|
-
( form?.fields ?? [] ).length < 2
|
|
96
|
-
}
|
|
98
|
+
hideLabelFromVision={ form.fields.length < 2 }
|
|
97
99
|
validity={ childFieldValidity }
|
|
98
100
|
/>
|
|
99
101
|
) }
|
|
@@ -131,7 +133,7 @@ function PanelModal< Item >( {
|
|
|
131
133
|
fieldDefinition,
|
|
132
134
|
}: {
|
|
133
135
|
data: Item;
|
|
134
|
-
field:
|
|
136
|
+
field: NormalizedFormField;
|
|
135
137
|
onChange: ( value: any ) => void;
|
|
136
138
|
labelPosition: 'side' | 'top' | 'none';
|
|
137
139
|
summaryFields: NormalizedField< Item >[];
|
|
@@ -139,9 +141,7 @@ function PanelModal< Item >( {
|
|
|
139
141
|
} ) {
|
|
140
142
|
const [ isOpen, setIsOpen ] = useState( false );
|
|
141
143
|
|
|
142
|
-
const fieldLabel =
|
|
143
|
-
? field.label
|
|
144
|
-
: fieldDefinition?.label;
|
|
144
|
+
const fieldLabel = !! field.children ? field.label : fieldDefinition?.label;
|
|
145
145
|
|
|
146
146
|
return (
|
|
147
147
|
<>
|
|
@@ -19,14 +19,13 @@ import {
|
|
|
19
19
|
* Internal dependencies
|
|
20
20
|
*/
|
|
21
21
|
import type {
|
|
22
|
-
Form,
|
|
23
22
|
FieldLayoutProps,
|
|
23
|
+
NormalizedForm,
|
|
24
24
|
NormalizedRegularLayout,
|
|
25
25
|
} from '../../types';
|
|
26
26
|
import DataFormContext from '../../components/dataform-context';
|
|
27
27
|
import { DataFormLayout } from '../data-form-layout';
|
|
28
|
-
import {
|
|
29
|
-
import { DEFAULT_LAYOUT, normalizeLayout } from '../normalize-form-fields';
|
|
28
|
+
import { DEFAULT_LAYOUT } from '../normalize-form';
|
|
30
29
|
|
|
31
30
|
function Header( { title }: { title: string } ) {
|
|
32
31
|
return (
|
|
@@ -49,16 +48,17 @@ export default function FormRegularField< Item >( {
|
|
|
49
48
|
validity,
|
|
50
49
|
}: FieldLayoutProps< Item > ) {
|
|
51
50
|
const { fields } = useContext( DataFormContext );
|
|
51
|
+
const layout = field.layout as NormalizedRegularLayout;
|
|
52
52
|
|
|
53
|
-
const form:
|
|
54
|
-
()
|
|
53
|
+
const form: NormalizedForm = useMemo(
|
|
54
|
+
() => ( {
|
|
55
55
|
layout: DEFAULT_LAYOUT,
|
|
56
|
-
fields:
|
|
56
|
+
fields: !! field.children ? field.children : [],
|
|
57
57
|
} ),
|
|
58
58
|
[ field ]
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
if (
|
|
61
|
+
if ( !! field.children ) {
|
|
62
62
|
return (
|
|
63
63
|
<>
|
|
64
64
|
{ ! hideLabelFromVision && field.label && (
|
|
@@ -74,11 +74,6 @@ export default function FormRegularField< Item >( {
|
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const layout: NormalizedRegularLayout = normalizeLayout( {
|
|
78
|
-
...field.layout,
|
|
79
|
-
type: 'regular',
|
|
80
|
-
} ) as NormalizedRegularLayout;
|
|
81
|
-
|
|
82
77
|
const labelPosition = layout.labelPosition;
|
|
83
78
|
const fieldDefinition = fields.find(
|
|
84
79
|
( fieldDef ) => fieldDef.id === field.id
|
|
@@ -7,16 +7,18 @@ import {
|
|
|
7
7
|
__experimentalVStack as VStack,
|
|
8
8
|
__experimentalHeading as Heading,
|
|
9
9
|
} from '@wordpress/components';
|
|
10
|
-
import { useContext } from '@wordpress/element';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies
|
|
14
13
|
*/
|
|
15
|
-
import type {
|
|
16
|
-
|
|
14
|
+
import type {
|
|
15
|
+
FieldLayoutProps,
|
|
16
|
+
NormalizedForm,
|
|
17
|
+
NormalizedLayout,
|
|
18
|
+
NormalizedRowLayout,
|
|
19
|
+
} from '../../types';
|
|
17
20
|
import { DataFormLayout } from '../data-form-layout';
|
|
18
|
-
import {
|
|
19
|
-
import { normalizeLayout } from '../normalize-form-fields';
|
|
21
|
+
import { DEFAULT_LAYOUT } from '../normalize-form';
|
|
20
22
|
import { getFormFieldLayout } from '..';
|
|
21
23
|
|
|
22
24
|
function Header( { title }: { title: string } ) {
|
|
@@ -43,21 +45,12 @@ export default function FormRowField< Item >( {
|
|
|
43
45
|
hideLabelFromVision,
|
|
44
46
|
validity,
|
|
45
47
|
}: FieldLayoutProps< Item > ) {
|
|
46
|
-
const
|
|
48
|
+
const layout = field.layout as NormalizedRowLayout;
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if ( isCombinedField( field ) ) {
|
|
54
|
-
const form: Form = {
|
|
55
|
-
fields: field.children.map( ( child ) => {
|
|
56
|
-
if ( typeof child === 'string' ) {
|
|
57
|
-
return { id: child };
|
|
58
|
-
}
|
|
59
|
-
return child;
|
|
60
|
-
} ),
|
|
50
|
+
if ( !! field.children ) {
|
|
51
|
+
const form: NormalizedForm = {
|
|
52
|
+
layout: DEFAULT_LAYOUT as NormalizedLayout,
|
|
53
|
+
fields: field.children,
|
|
61
54
|
};
|
|
62
55
|
|
|
63
56
|
return (
|
|
@@ -94,12 +87,6 @@ export default function FormRowField< Item >( {
|
|
|
94
87
|
);
|
|
95
88
|
}
|
|
96
89
|
|
|
97
|
-
const fieldDefinition = fields.find( ( f ) => f.id === field.id );
|
|
98
|
-
|
|
99
|
-
if ( ! fieldDefinition || ! fieldDefinition.Edit ) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
90
|
const RegularLayout = getFormFieldLayout( 'regular' )?.component;
|
|
104
91
|
if ( ! RegularLayout ) {
|
|
105
92
|
return null;
|
|
@@ -110,7 +97,7 @@ export default function FormRowField< Item >( {
|
|
|
110
97
|
<div className="dataforms-layouts-row__field-control">
|
|
111
98
|
<RegularLayout
|
|
112
99
|
data={ data }
|
|
113
|
-
field={
|
|
100
|
+
field={ field }
|
|
114
101
|
onChange={ onChange }
|
|
115
102
|
validity={ validity }
|
|
116
103
|
/>
|
|
@@ -16,11 +16,13 @@ import ViewTable from './table';
|
|
|
16
16
|
import ViewGrid from './grid';
|
|
17
17
|
import ViewList from './list';
|
|
18
18
|
import ViewPickerGrid from './picker-grid';
|
|
19
|
+
import ViewPickerTable from './picker-table';
|
|
19
20
|
import {
|
|
20
21
|
LAYOUT_GRID,
|
|
21
22
|
LAYOUT_LIST,
|
|
22
23
|
LAYOUT_TABLE,
|
|
23
24
|
LAYOUT_PICKER_GRID,
|
|
25
|
+
LAYOUT_PICKER_TABLE,
|
|
24
26
|
} from '../constants';
|
|
25
27
|
import PreviewSizePicker from './utils/preview-size-picker';
|
|
26
28
|
import DensityPicker from './table/density-picker';
|
|
@@ -54,4 +56,12 @@ export const VIEW_LAYOUTS = [
|
|
|
54
56
|
viewConfigOptions: PreviewSizePicker,
|
|
55
57
|
isPicker: true,
|
|
56
58
|
},
|
|
59
|
+
{
|
|
60
|
+
type: LAYOUT_PICKER_TABLE,
|
|
61
|
+
label: __( 'Table' ),
|
|
62
|
+
component: ViewPickerTable,
|
|
63
|
+
icon: blockTable,
|
|
64
|
+
viewConfigOptions: DensityPicker,
|
|
65
|
+
isPicker: true,
|
|
66
|
+
},
|
|
57
67
|
];
|