@wordpress/dataviews 10.2.0 → 10.3.1-next.2f1c7c01b.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/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 +6 -4
- package/build/components/dataviews-view-config/index.js.map +1 -1
- 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/constants.js +36 -34
- package/build/constants.js.map +1 -1
- 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 +3 -1
- package/build/dataform-controls/password.js.map +1 -1
- 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 +65 -34
- 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/get-summary-fields.js +3 -1
- package/build/dataform-layouts/get-summary-fields.js.map +1 -1
- package/build/dataform-layouts/index.js +4 -2
- package/build/dataform-layouts/index.js.map +2 -2
- package/build/dataform-layouts/{normalize-form-fields.js → normalize-form.js} +39 -22
- 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 +3 -1
- package/build/dataviews-layouts/index.js.map +1 -1
- package/build/dataviews-layouts/list/index.js +6 -6
- package/build/dataviews-layouts/list/index.js.map +2 -2
- 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/table/column-header-menu.js +6 -4
- package/build/dataviews-layouts/table/column-header-menu.js.map +1 -1
- package/build/dataviews-layouts/table/column-primary.js +3 -1
- package/build/dataviews-layouts/table/column-primary.js.map +1 -1
- 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 +3 -1
- package/build/dataviews-layouts/table/index.js.map +1 -1
- 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 +1 -1
- 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 +5 -4
- package/build-module/components/dataviews-view-config/index.js.map +1 -1
- 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/constants.js +35 -34
- package/build-module/constants.js.map +1 -1
- 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 +2 -1
- package/build-module/dataform-controls/password.js.map +1 -1
- 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 +63 -33
- 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/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 +3 -2
- package/build-module/dataform-layouts/index.js.map +2 -2
- package/build-module/dataform-layouts/{normalize-form-fields.js → normalize-form.js} +34 -17
- 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 +2 -1
- package/build-module/dataviews-layouts/index.js.map +1 -1
- package/build-module/dataviews-layouts/list/index.js +5 -6
- package/build-module/dataviews-layouts/list/index.js.map +2 -2
- 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/table/column-header-menu.js +5 -4
- package/build-module/dataviews-layouts/table/column-header-menu.js.map +1 -1
- package/build-module/dataviews-layouts/table/column-primary.js +2 -1
- package/build-module/dataviews-layouts/table/column-primary.js.map +1 -1
- 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 +2 -1
- package/build-module/dataviews-layouts/table/index.js.map +1 -1
- 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-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-item-actions/index.d.ts.map +1 -1
- package/build-types/dataform-controls/datetime.d.ts.map +1 -1
- package/build-types/dataform-layouts/card/index.d.ts +1 -1
- 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/index.d.ts +2 -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/list/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 +1 -10
- package/build-types/stories/dataform.story.d.ts.map +1 -1
- package/build-types/stories/dataviews-picker.story.d.ts +31 -0
- package/build-types/stories/dataviews-picker.story.d.ts.map +1 -1
- package/build-types/stories/dataviews.fixtures.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 +12 -6
- package/build-types/types/dataform.d.ts.map +1 -1
- package/build-wp/index.js +738 -532
- package/package.json +15 -15
- package/src/components/dataform/index.tsx +3 -1
- package/src/components/dataviews-filters/filter.tsx +16 -1
- package/src/components/dataviews-item-actions/index.tsx +37 -14
- package/src/dataform-controls/datetime.tsx +3 -10
- package/src/dataform-layouts/card/index.tsx +45 -21
- package/src/dataform-layouts/data-form-layout.tsx +12 -23
- package/src/dataform-layouts/index.tsx +5 -3
- package/src/dataform-layouts/{normalize-form-fields.ts → normalize-form.ts} +39 -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/list/index.tsx +2 -5
- 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 +502 -454
- package/src/stories/dataviews-picker.story.tsx +155 -32
- package/src/stories/dataviews.fixtures.tsx +4 -1
- package/src/stories/field-types.story.tsx +7 -7
- package/src/test/normalize-form.ts +568 -0
- package/src/test/use-form-validity.ts +318 -33
- package/src/types/dataform.ts +12 -8
- 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 -324
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dataviews",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.1-next.2f1c7c01b.0",
|
|
4
4
|
"description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -44,19 +44,19 @@
|
|
|
44
44
|
"sideEffects": false,
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@ariakit/react": "^0.4.15",
|
|
47
|
-
"@wordpress/base-styles": "^6.10.0",
|
|
48
|
-
"@wordpress/components": "^30.7.0",
|
|
49
|
-
"@wordpress/compose": "^7.34.0",
|
|
50
|
-
"@wordpress/data": "^10.34.0",
|
|
51
|
-
"@wordpress/date": "^5.34.0",
|
|
52
|
-
"@wordpress/element": "^6.34.0",
|
|
53
|
-
"@wordpress/i18n": "^6.7.0",
|
|
54
|
-
"@wordpress/icons": "^11.1.0",
|
|
55
|
-
"@wordpress/keycodes": "^4.34.0",
|
|
56
|
-
"@wordpress/primitives": "^4.34.0",
|
|
57
|
-
"@wordpress/private-apis": "^1.34.0",
|
|
58
|
-
"@wordpress/url": "^4.34.0",
|
|
59
|
-
"@wordpress/warning": "^3.34.0",
|
|
47
|
+
"@wordpress/base-styles": "^6.10.1-next.2f1c7c01b.0",
|
|
48
|
+
"@wordpress/components": "^30.7.2-next.2f1c7c01b.0",
|
|
49
|
+
"@wordpress/compose": "^7.34.1-next.2f1c7c01b.0",
|
|
50
|
+
"@wordpress/data": "^10.34.1-next.2f1c7c01b.0",
|
|
51
|
+
"@wordpress/date": "^5.34.1-next.2f1c7c01b.0",
|
|
52
|
+
"@wordpress/element": "^6.34.1-next.2f1c7c01b.0",
|
|
53
|
+
"@wordpress/i18n": "^6.7.1-next.2f1c7c01b.0",
|
|
54
|
+
"@wordpress/icons": "^11.1.1-next.2f1c7c01b.0",
|
|
55
|
+
"@wordpress/keycodes": "^4.34.1-next.2f1c7c01b.0",
|
|
56
|
+
"@wordpress/primitives": "^4.34.1-next.2f1c7c01b.0",
|
|
57
|
+
"@wordpress/private-apis": "^1.34.1-next.2f1c7c01b.0",
|
|
58
|
+
"@wordpress/url": "^4.34.1-next.2f1c7c01b.0",
|
|
59
|
+
"@wordpress/warning": "^3.34.1-next.2f1c7c01b.0",
|
|
60
60
|
"clsx": "^2.1.1",
|
|
61
61
|
"colord": "^2.7.0",
|
|
62
62
|
"date-fns": "^4.1.0",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build:wp": "node build"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "c6ddcdf455bc02567a2c9e03de6862a2061b85e8"
|
|
78
78
|
}
|
|
@@ -10,6 +10,7 @@ import type { DataFormProps } from '../../types';
|
|
|
10
10
|
import { DataFormProvider } from '../dataform-context';
|
|
11
11
|
import normalizeFields from '../../utils/normalize-fields';
|
|
12
12
|
import { DataFormLayout } from '../../dataform-layouts/data-form-layout';
|
|
13
|
+
import normalizeForm from '../../dataform-layouts/normalize-form';
|
|
13
14
|
|
|
14
15
|
export default function DataForm< Item >( {
|
|
15
16
|
data,
|
|
@@ -18,6 +19,7 @@ export default function DataForm< Item >( {
|
|
|
18
19
|
onChange,
|
|
19
20
|
validity,
|
|
20
21
|
}: DataFormProps< Item > ) {
|
|
22
|
+
const normalizedForm = useMemo( () => normalizeForm( form ), [ form ] );
|
|
21
23
|
const normalizedFields = useMemo(
|
|
22
24
|
() => normalizeFields( fields ),
|
|
23
25
|
[ fields ]
|
|
@@ -31,7 +33,7 @@ export default function DataForm< Item >( {
|
|
|
31
33
|
<DataFormProvider fields={ normalizedFields }>
|
|
32
34
|
<DataFormLayout
|
|
33
35
|
data={ data }
|
|
34
|
-
form={
|
|
36
|
+
form={ normalizedForm }
|
|
35
37
|
onChange={ onChange }
|
|
36
38
|
validity={ validity }
|
|
37
39
|
/>
|
|
@@ -62,6 +62,7 @@ import type {
|
|
|
62
62
|
View,
|
|
63
63
|
} from '../../types';
|
|
64
64
|
import useElements from '../../hooks/use-elements';
|
|
65
|
+
import parseDateTime from '../../field-types/utils/parse-date-time';
|
|
65
66
|
|
|
66
67
|
interface FilterTextProps {
|
|
67
68
|
activeElements: Option[];
|
|
@@ -494,10 +495,24 @@ export default function Filter( {
|
|
|
494
495
|
return filterInView?.value?.includes( element.value );
|
|
495
496
|
} );
|
|
496
497
|
} else if ( filterInView?.value !== undefined ) {
|
|
498
|
+
const field = fields.find( ( f ) => f.id === filter.field );
|
|
499
|
+
let label = filterInView.value;
|
|
500
|
+
|
|
501
|
+
if ( field?.type === 'datetime' && typeof label === 'string' ) {
|
|
502
|
+
try {
|
|
503
|
+
const dateValue = parseDateTime( label );
|
|
504
|
+
if ( dateValue !== null ) {
|
|
505
|
+
label = dateValue.toLocaleString();
|
|
506
|
+
}
|
|
507
|
+
} catch ( e ) {
|
|
508
|
+
label = filterInView.value;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
497
512
|
activeElements = [
|
|
498
513
|
{
|
|
499
514
|
value: filterInView.value,
|
|
500
|
-
label
|
|
515
|
+
label,
|
|
501
516
|
},
|
|
502
517
|
];
|
|
503
518
|
}
|
|
@@ -132,22 +132,45 @@ export function ActionsMenuGroup< Item >( {
|
|
|
132
132
|
registry,
|
|
133
133
|
setActiveModalAction,
|
|
134
134
|
}: ActionsMenuGroupProps< Item > ) {
|
|
135
|
+
const { primaryActions, regularActions } = useMemo( () => {
|
|
136
|
+
return actions.reduce(
|
|
137
|
+
( acc, action ) => {
|
|
138
|
+
( action.isPrimary
|
|
139
|
+
? acc.primaryActions
|
|
140
|
+
: acc.regularActions
|
|
141
|
+
).push( action );
|
|
142
|
+
return acc;
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
primaryActions: [] as Action< Item >[],
|
|
146
|
+
regularActions: [] as Action< Item >[],
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
}, [ actions ] );
|
|
150
|
+
|
|
151
|
+
const renderActionGroup = ( actionList: Action< Item >[] ) =>
|
|
152
|
+
actionList.map( ( action ) => (
|
|
153
|
+
<MenuItemTrigger
|
|
154
|
+
key={ action.id }
|
|
155
|
+
action={ action }
|
|
156
|
+
onClick={ () => {
|
|
157
|
+
if ( 'RenderModal' in action ) {
|
|
158
|
+
setActiveModalAction( action );
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
action.callback( [ item ], { registry } );
|
|
162
|
+
} }
|
|
163
|
+
items={ [ item ] }
|
|
164
|
+
/>
|
|
165
|
+
) );
|
|
166
|
+
|
|
135
167
|
return (
|
|
136
168
|
<Menu.Group>
|
|
137
|
-
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if ( 'RenderModal' in action ) {
|
|
143
|
-
setActiveModalAction( action );
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
action.callback( [ item ], { registry } );
|
|
147
|
-
} }
|
|
148
|
-
items={ [ item ] }
|
|
149
|
-
/>
|
|
150
|
-
) ) }
|
|
169
|
+
{ renderActionGroup( primaryActions ) }
|
|
170
|
+
{ primaryActions.length > 0 && regularActions.length > 0 && (
|
|
171
|
+
<Menu.Separator />
|
|
172
|
+
) }
|
|
173
|
+
{ renderActionGroup( regularActions ) }
|
|
151
174
|
</Menu.Group>
|
|
152
175
|
);
|
|
153
176
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { format
|
|
4
|
+
import { format } from 'date-fns';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { useCallback, useEffect, useRef, useState } from '@wordpress/element';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
|
-
import {
|
|
16
|
+
import { getSettings } from '@wordpress/date';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Internal dependencies
|
|
@@ -22,18 +22,11 @@ import type { DataFormControlProps } from '../types';
|
|
|
22
22
|
import { OPERATOR_IN_THE_PAST, OPERATOR_OVER } from '../constants';
|
|
23
23
|
import RelativeDateControl from './utils/relative-date-control';
|
|
24
24
|
import getCustomValidity from './utils/get-custom-validity';
|
|
25
|
+
import parseDateTime from '../field-types/utils/parse-date-time';
|
|
25
26
|
import { unlock } from '../lock-unlock';
|
|
26
27
|
|
|
27
28
|
const { DateCalendar, ValidatedInputControl } = unlock( componentsPrivateApis );
|
|
28
29
|
|
|
29
|
-
const parseDateTime = ( dateTimeString?: string ): Date | null => {
|
|
30
|
-
if ( ! dateTimeString ) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const parsed = getDate( dateTimeString );
|
|
34
|
-
return parsed && isValidDate( parsed ) ? parsed : null;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
30
|
const formatDateTime = ( date?: Date | string ): string => {
|
|
38
31
|
if ( ! date ) {
|
|
39
32
|
return '';
|
|
@@ -16,16 +16,14 @@ import { chevronDown, chevronUp } from '@wordpress/icons';
|
|
|
16
16
|
import { getFormFieldLayout } from '..';
|
|
17
17
|
import DataFormContext from '../../components/dataform-context';
|
|
18
18
|
import type {
|
|
19
|
-
NormalizedCardLayout,
|
|
20
|
-
CardLayout,
|
|
21
19
|
FieldLayoutProps,
|
|
22
|
-
|
|
23
|
-
Layout,
|
|
20
|
+
NormalizedCardLayout,
|
|
24
21
|
NormalizedField,
|
|
22
|
+
NormalizedForm,
|
|
23
|
+
NormalizedLayout,
|
|
25
24
|
} from '../../types';
|
|
26
25
|
import { DataFormLayout } from '../data-form-layout';
|
|
27
|
-
import {
|
|
28
|
-
import { DEFAULT_LAYOUT, normalizeLayout } from '../normalize-form-fields';
|
|
26
|
+
import { DEFAULT_LAYOUT } from '../normalize-form';
|
|
29
27
|
import { getSummaryFields } from '../get-summary-fields';
|
|
30
28
|
|
|
31
29
|
const NonCollapsibleCardHeader = ( {
|
|
@@ -34,7 +32,7 @@ const NonCollapsibleCardHeader = ( {
|
|
|
34
32
|
}: {
|
|
35
33
|
children: React.ReactNode;
|
|
36
34
|
} ) => (
|
|
37
|
-
<OriginalCardHeader { ...props }>
|
|
35
|
+
<OriginalCardHeader isBorderless { ...props }>
|
|
38
36
|
<div
|
|
39
37
|
style={ {
|
|
40
38
|
height: '40px', // This is to match the chevron's __next40pxDefaultSize
|
|
@@ -72,6 +70,7 @@ export function useCardHeader( layout: NormalizedCardLayout ) {
|
|
|
72
70
|
cursor: 'pointer',
|
|
73
71
|
...props.style,
|
|
74
72
|
} }
|
|
73
|
+
isBorderless
|
|
75
74
|
>
|
|
76
75
|
<div
|
|
77
76
|
style={ {
|
|
@@ -162,16 +161,12 @@ export default function FormCardField< Item >( {
|
|
|
162
161
|
validity,
|
|
163
162
|
}: FieldLayoutProps< Item > ) {
|
|
164
163
|
const { fields } = useContext( DataFormContext );
|
|
164
|
+
const layout = field.layout as NormalizedCardLayout;
|
|
165
165
|
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const form: Form = useMemo(
|
|
172
|
-
(): Form => ( {
|
|
173
|
-
layout: DEFAULT_LAYOUT as Layout,
|
|
174
|
-
fields: isCombinedField( field ) ? field.children : [],
|
|
166
|
+
const form: NormalizedForm = useMemo(
|
|
167
|
+
() => ( {
|
|
168
|
+
layout: DEFAULT_LAYOUT as NormalizedLayout,
|
|
169
|
+
fields: field.children ?? [],
|
|
175
170
|
} ),
|
|
176
171
|
[ field ]
|
|
177
172
|
);
|
|
@@ -184,11 +179,27 @@ export default function FormCardField< Item >( {
|
|
|
184
179
|
isSummaryFieldVisible( summaryField, layout.summary, isOpen )
|
|
185
180
|
);
|
|
186
181
|
|
|
187
|
-
|
|
182
|
+
const sizeCard = {
|
|
183
|
+
blockStart: 'medium' as const,
|
|
184
|
+
blockEnd: 'medium' as const,
|
|
185
|
+
inlineStart: 'medium' as const,
|
|
186
|
+
inlineEnd: 'medium' as const,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
if ( !! field.children ) {
|
|
188
190
|
const withHeader = !! field.label && layout.withHeader;
|
|
189
191
|
|
|
192
|
+
const sizeCardBody = {
|
|
193
|
+
blockStart: withHeader
|
|
194
|
+
? ( 'none' as const )
|
|
195
|
+
: ( 'medium' as const ),
|
|
196
|
+
blockEnd: 'medium' as const,
|
|
197
|
+
inlineStart: 'medium' as const,
|
|
198
|
+
inlineEnd: 'medium' as const,
|
|
199
|
+
};
|
|
200
|
+
|
|
190
201
|
return (
|
|
191
|
-
<Card className="dataforms-layouts-card__field">
|
|
202
|
+
<Card className="dataforms-layouts-card__field" size={ sizeCard }>
|
|
192
203
|
{ withHeader && (
|
|
193
204
|
<CardHeader className="dataforms-layouts-card__field-header">
|
|
194
205
|
<span className="dataforms-layouts-card__field-header-label">
|
|
@@ -213,7 +224,10 @@ export default function FormCardField< Item >( {
|
|
|
213
224
|
{ ( isOpen || ! withHeader ) && (
|
|
214
225
|
// If it doesn't have a header, keep it open.
|
|
215
226
|
// Otherwise, the card will not be visible.
|
|
216
|
-
<CardBody
|
|
227
|
+
<CardBody
|
|
228
|
+
size={ sizeCardBody }
|
|
229
|
+
className="dataforms-layouts-card__field-control"
|
|
230
|
+
>
|
|
217
231
|
{ field.description && (
|
|
218
232
|
<div className="dataforms-layouts-card__field-description">
|
|
219
233
|
{ field.description }
|
|
@@ -245,8 +259,15 @@ export default function FormCardField< Item >( {
|
|
|
245
259
|
}
|
|
246
260
|
const withHeader = !! fieldDefinition.label && layout.withHeader;
|
|
247
261
|
|
|
262
|
+
const sizeCardBody = {
|
|
263
|
+
blockStart: withHeader ? ( 'none' as const ) : ( 'medium' as const ),
|
|
264
|
+
blockEnd: 'medium' as const,
|
|
265
|
+
inlineStart: 'medium' as const,
|
|
266
|
+
inlineEnd: 'medium' as const,
|
|
267
|
+
};
|
|
268
|
+
|
|
248
269
|
return (
|
|
249
|
-
<Card className="dataforms-layouts-card__field">
|
|
270
|
+
<Card className="dataforms-layouts-card__field" size={ sizeCard }>
|
|
250
271
|
{ withHeader && (
|
|
251
272
|
<CardHeader className="dataforms-layouts-card__field-header">
|
|
252
273
|
<span className="dataforms-layouts-card__field-header-label">
|
|
@@ -268,7 +289,10 @@ export default function FormCardField< Item >( {
|
|
|
268
289
|
{ ( isOpen || ! withHeader ) && (
|
|
269
290
|
// If it doesn't have a header, keep it open.
|
|
270
291
|
// Otherwise, the card will not be visible.
|
|
271
|
-
<CardBody
|
|
292
|
+
<CardBody
|
|
293
|
+
size={ sizeCardBody }
|
|
294
|
+
className="dataforms-layouts-card__field-control"
|
|
295
|
+
>
|
|
272
296
|
<RegularLayout
|
|
273
297
|
data={ data }
|
|
274
298
|
field={ field }
|
|
@@ -2,22 +2,19 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __experimentalVStack as VStack } from '@wordpress/components';
|
|
5
|
-
import { useContext
|
|
5
|
+
import { useContext } from '@wordpress/element';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import type {
|
|
11
11
|
FieldValidity,
|
|
12
|
-
Form,
|
|
13
|
-
FormField,
|
|
14
12
|
FormValidity,
|
|
15
|
-
|
|
13
|
+
NormalizedForm,
|
|
14
|
+
NormalizedFormField,
|
|
16
15
|
} from '../types';
|
|
17
16
|
import { getFormFieldLayout } from './index';
|
|
18
17
|
import DataFormContext from '../components/dataform-context';
|
|
19
|
-
import { isCombinedField } from './is-combined-field';
|
|
20
|
-
import normalizeFormFields, { normalizeLayout } from './normalize-form-fields';
|
|
21
18
|
|
|
22
19
|
const DEFAULT_WRAPPER = ( { children }: { children: React.ReactNode } ) => (
|
|
23
20
|
<VStack className="dataforms-layouts__wrapper" spacing={ 4 }>
|
|
@@ -34,46 +31,38 @@ export function DataFormLayout< Item >( {
|
|
|
34
31
|
as,
|
|
35
32
|
}: {
|
|
36
33
|
data: Item;
|
|
37
|
-
form:
|
|
34
|
+
form: NormalizedForm;
|
|
38
35
|
onChange: ( value: any ) => void;
|
|
39
36
|
validity?: FormValidity;
|
|
40
37
|
children?: (
|
|
41
38
|
FieldLayout: ( props: {
|
|
42
39
|
data: Item;
|
|
43
|
-
field:
|
|
40
|
+
field: NormalizedFormField;
|
|
44
41
|
onChange: ( value: any ) => void;
|
|
45
42
|
hideLabelFromVision?: boolean;
|
|
46
43
|
validity?: FieldValidity;
|
|
47
44
|
} ) => React.JSX.Element | null,
|
|
48
|
-
childField:
|
|
45
|
+
childField: NormalizedFormField,
|
|
49
46
|
childFieldValidity?: FieldValidity
|
|
50
47
|
) => React.JSX.Element;
|
|
51
48
|
as?: React.ComponentType< { children: React.ReactNode } >;
|
|
52
49
|
} ) {
|
|
53
50
|
const { fields: fieldDefinitions } = useContext( DataFormContext );
|
|
54
51
|
|
|
55
|
-
function getFieldDefinition( field:
|
|
56
|
-
const fieldId = typeof field === 'string' ? field : field.id;
|
|
57
|
-
|
|
52
|
+
function getFieldDefinition( field: NormalizedFormField ) {
|
|
58
53
|
return fieldDefinitions.find(
|
|
59
|
-
( fieldDefinition ) => fieldDefinition.id ===
|
|
54
|
+
( fieldDefinition ) => fieldDefinition.id === field.id
|
|
60
55
|
);
|
|
61
56
|
}
|
|
62
57
|
|
|
63
|
-
const normalizedFormFields = useMemo(
|
|
64
|
-
() => normalizeFormFields( form ),
|
|
65
|
-
[ form ]
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const normalizedFormLayout = normalizeLayout( form.layout );
|
|
69
58
|
const Wrapper =
|
|
70
59
|
as ??
|
|
71
|
-
getFormFieldLayout(
|
|
60
|
+
getFormFieldLayout( form.layout.type )?.wrapper ??
|
|
72
61
|
DEFAULT_WRAPPER;
|
|
73
62
|
|
|
74
63
|
return (
|
|
75
|
-
<Wrapper layout={
|
|
76
|
-
{
|
|
64
|
+
<Wrapper layout={ form.layout }>
|
|
65
|
+
{ form.fields.map( ( formField ) => {
|
|
77
66
|
const FieldLayout = getFormFieldLayout( formField.layout.type )
|
|
78
67
|
?.component;
|
|
79
68
|
|
|
@@ -81,7 +70,7 @@ export function DataFormLayout< Item >( {
|
|
|
81
70
|
return null;
|
|
82
71
|
}
|
|
83
72
|
|
|
84
|
-
const fieldDefinition = !
|
|
73
|
+
const fieldDefinition = ! formField.children
|
|
85
74
|
? getFieldDefinition( formField )
|
|
86
75
|
: undefined;
|
|
87
76
|
|
|
@@ -9,7 +9,7 @@ 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';
|
|
@@ -51,13 +51,15 @@ const FORM_FIELD_LAYOUTS = [
|
|
|
51
51
|
layout,
|
|
52
52
|
}: {
|
|
53
53
|
children: React.ReactNode;
|
|
54
|
-
layout:
|
|
54
|
+
layout: NormalizedLayout;
|
|
55
55
|
} ) => (
|
|
56
56
|
<VStack className="dataforms-layouts__wrapper" spacing={ 4 }>
|
|
57
57
|
<div className="dataforms-layouts-row__field">
|
|
58
58
|
<HStack
|
|
59
59
|
spacing={ 4 }
|
|
60
|
-
alignment={
|
|
60
|
+
alignment={
|
|
61
|
+
( layout as NormalizedRowLayout ).alignment
|
|
62
|
+
}
|
|
61
63
|
>
|
|
62
64
|
{ children }
|
|
63
65
|
</HStack>
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import type {
|
|
5
5
|
Form,
|
|
6
6
|
Layout,
|
|
7
|
+
NormalizedForm,
|
|
8
|
+
NormalizedFormField,
|
|
7
9
|
NormalizedLayout,
|
|
8
10
|
NormalizedRegularLayout,
|
|
9
11
|
NormalizedPanelLayout,
|
|
@@ -13,11 +15,6 @@ import type {
|
|
|
13
15
|
CardSummaryField,
|
|
14
16
|
} from '../types';
|
|
15
17
|
|
|
16
|
-
interface NormalizedFormField {
|
|
17
|
-
id: string;
|
|
18
|
-
layout: Layout;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
18
|
export const DEFAULT_LAYOUT: NormalizedLayout = {
|
|
22
19
|
type: 'regular',
|
|
23
20
|
labelPosition: 'top',
|
|
@@ -43,7 +40,7 @@ const normalizeCardSummaryField = (
|
|
|
43
40
|
* @param layout The layout object to normalize.
|
|
44
41
|
* @return The normalized layout object.
|
|
45
42
|
*/
|
|
46
|
-
|
|
43
|
+
function normalizeLayout( layout?: Layout ): NormalizedLayout {
|
|
47
44
|
let normalizedLayout = DEFAULT_LAYOUT;
|
|
48
45
|
|
|
49
46
|
if ( layout?.type === 'regular' ) {
|
|
@@ -102,25 +99,44 @@ export function normalizeLayout( layout?: Layout ): NormalizedLayout {
|
|
|
102
99
|
return normalizedLayout;
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
|
|
106
|
-
form
|
|
107
|
-
|
|
108
|
-
const
|
|
102
|
+
function normalizeForm( form: Form ): NormalizedForm {
|
|
103
|
+
const normalizedFormLayout = normalizeLayout( form?.layout );
|
|
104
|
+
|
|
105
|
+
const normalizedFields: NormalizedFormField[] = ( form.fields ?? [] ).map(
|
|
106
|
+
( field ) => {
|
|
107
|
+
if ( typeof field === 'string' ) {
|
|
108
|
+
return {
|
|
109
|
+
id: field,
|
|
110
|
+
layout: normalizedFormLayout,
|
|
111
|
+
} satisfies NormalizedFormField;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const fieldLayout = field.layout
|
|
115
|
+
? normalizeLayout( field.layout )
|
|
116
|
+
: normalizedFormLayout;
|
|
109
117
|
|
|
110
|
-
return ( form.fields ?? [] ).map( ( field ) => {
|
|
111
|
-
if ( typeof field === 'string' ) {
|
|
112
118
|
return {
|
|
113
|
-
id: field,
|
|
114
|
-
layout:
|
|
115
|
-
|
|
119
|
+
id: field.id,
|
|
120
|
+
layout: fieldLayout,
|
|
121
|
+
...( !! field.label && { label: field.label } ),
|
|
122
|
+
...( !! field.description && {
|
|
123
|
+
description: field.description,
|
|
124
|
+
} ),
|
|
125
|
+
...( 'children' in field &&
|
|
126
|
+
Array.isArray( field.children ) && {
|
|
127
|
+
children: normalizeForm( {
|
|
128
|
+
fields: field.children,
|
|
129
|
+
layout: DEFAULT_LAYOUT,
|
|
130
|
+
} ).fields,
|
|
131
|
+
} ),
|
|
132
|
+
} satisfies NormalizedFormField;
|
|
116
133
|
}
|
|
134
|
+
);
|
|
117
135
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
...field,
|
|
123
|
-
layout: fieldLayout,
|
|
124
|
-
};
|
|
125
|
-
} );
|
|
136
|
+
return {
|
|
137
|
+
layout: normalizedFormLayout,
|
|
138
|
+
fields: normalizedFields,
|
|
139
|
+
};
|
|
126
140
|
}
|
|
141
|
+
|
|
142
|
+
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
|
|