@wordpress/dataviews 10.1.2 → 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 +18 -0
- package/README.md +1 -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 +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/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} +43 -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 +3 -1
- package/build/dataviews-layouts/index.js.map +1 -1
- package/build/dataviews-layouts/list/index.js +5 -5
- 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 +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/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} +38 -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 +2 -1
- package/build-module/dataviews-layouts/index.js.map +1 -1
- package/build-module/dataviews-layouts/list/index.js +4 -5
- 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-style/style-rtl.css +12 -12
- package/build-style/style.css +12 -12
- 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-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/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 +10 -11
- 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/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 +16 -6
- package/build-types/types/dataform.d.ts.map +1 -1
- package/build-wp/index.js +830 -601
- 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/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/index.tsx +5 -3
- package/src/dataform-layouts/{normalize-form-fields.ts → normalize-form.ts} +44 -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 +0 -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 +520 -456
- package/src/stories/dataviews-picker.story.tsx +155 -32
- 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 +18 -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 -317
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dataviews",
|
|
3
|
-
"version": "10.1.
|
|
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.
|
|
48
|
-
"@wordpress/components": "^30.
|
|
49
|
-
"@wordpress/compose": "^7.
|
|
50
|
-
"@wordpress/data": "^10.
|
|
51
|
-
"@wordpress/date": "^5.
|
|
52
|
-
"@wordpress/element": "^6.
|
|
53
|
-
"@wordpress/i18n": "^6.
|
|
54
|
-
"@wordpress/icons": "^11.
|
|
55
|
-
"@wordpress/keycodes": "^4.
|
|
56
|
-
"@wordpress/primitives": "^4.
|
|
57
|
-
"@wordpress/private-apis": "^1.
|
|
58
|
-
"@wordpress/url": "^4.
|
|
59
|
-
"@wordpress/warning": "^3.
|
|
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
|
}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
.dataviews-pagination__page-select {
|
|
5
5
|
font-size: 11px;
|
|
6
|
-
font-weight:
|
|
6
|
+
font-weight: $font-weight-medium;
|
|
7
7
|
text-transform: uppercase;
|
|
8
8
|
|
|
9
9
|
@include break-small() {
|
|
10
10
|
.components-select-control__input {
|
|
11
11
|
font-size: 11px !important;
|
|
12
|
-
font-weight:
|
|
12
|
+
font-weight: $font-weight-medium;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -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 '';
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
|
|
6
|
+
Button,
|
|
7
|
+
} from '@wordpress/components';
|
|
5
8
|
import { useCallback, useState } from '@wordpress/element';
|
|
6
9
|
import { __ } from '@wordpress/i18n';
|
|
7
10
|
import { seen, unseen } from '@wordpress/icons';
|
|
@@ -34,17 +37,18 @@ export default function Password< Item >( {
|
|
|
34
37
|
validity,
|
|
35
38
|
type: isVisible ? 'text' : 'password',
|
|
36
39
|
suffix: (
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
<InputControlSuffixWrapper variant="control">
|
|
41
|
+
<Button
|
|
42
|
+
icon={ isVisible ? unseen : seen }
|
|
43
|
+
onClick={ toggleVisibility }
|
|
44
|
+
size="small"
|
|
45
|
+
label={
|
|
46
|
+
isVisible
|
|
47
|
+
? __( 'Hide password' )
|
|
48
|
+
: __( 'Show password' )
|
|
49
|
+
}
|
|
50
|
+
/>
|
|
51
|
+
</InputControlSuffixWrapper>
|
|
48
52
|
),
|
|
49
53
|
} }
|
|
50
54
|
/>
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
Card,
|
|
7
|
+
CardBody,
|
|
8
|
+
CardHeader as OriginalCardHeader,
|
|
9
|
+
} from '@wordpress/components';
|
|
5
10
|
import { useCallback, useContext, useMemo, useState } from '@wordpress/element';
|
|
6
11
|
import { chevronDown, chevronUp } from '@wordpress/icons';
|
|
7
12
|
|
|
@@ -11,20 +16,40 @@ import { chevronDown, chevronUp } from '@wordpress/icons';
|
|
|
11
16
|
import { getFormFieldLayout } from '..';
|
|
12
17
|
import DataFormContext from '../../components/dataform-context';
|
|
13
18
|
import type {
|
|
14
|
-
NormalizedCardLayout,
|
|
15
|
-
CardLayout,
|
|
16
19
|
FieldLayoutProps,
|
|
17
|
-
|
|
18
|
-
Layout,
|
|
20
|
+
NormalizedCardLayout,
|
|
19
21
|
NormalizedField,
|
|
22
|
+
NormalizedForm,
|
|
23
|
+
NormalizedLayout,
|
|
20
24
|
} from '../../types';
|
|
21
25
|
import { DataFormLayout } from '../data-form-layout';
|
|
22
|
-
import {
|
|
23
|
-
import { DEFAULT_LAYOUT, normalizeLayout } from '../normalize-form-fields';
|
|
26
|
+
import { DEFAULT_LAYOUT } from '../normalize-form';
|
|
24
27
|
import { getSummaryFields } from '../get-summary-fields';
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
const NonCollapsibleCardHeader = ( {
|
|
30
|
+
children,
|
|
31
|
+
...props
|
|
32
|
+
}: {
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
} ) => (
|
|
35
|
+
<OriginalCardHeader isBorderless { ...props }>
|
|
36
|
+
<div
|
|
37
|
+
style={ {
|
|
38
|
+
height: '40px', // This is to match the chevron's __next40pxDefaultSize
|
|
39
|
+
width: '100%',
|
|
40
|
+
display: 'flex',
|
|
41
|
+
justifyContent: 'space-between',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
} }
|
|
44
|
+
>
|
|
45
|
+
{ children }
|
|
46
|
+
</div>
|
|
47
|
+
</OriginalCardHeader>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export function useCardHeader( layout: NormalizedCardLayout ) {
|
|
51
|
+
const { isOpened, isCollapsible } = layout;
|
|
52
|
+
const [ isOpen, setIsOpen ] = useState( isOpened );
|
|
28
53
|
|
|
29
54
|
const toggle = useCallback( () => {
|
|
30
55
|
setIsOpen( ( prev ) => ! prev );
|
|
@@ -38,13 +63,14 @@ export function useCollapsibleCard( initialIsOpen: boolean = true ) {
|
|
|
38
63
|
children: React.ReactNode;
|
|
39
64
|
[ key: string ]: any;
|
|
40
65
|
} ) => (
|
|
41
|
-
<
|
|
66
|
+
<OriginalCardHeader
|
|
42
67
|
{ ...props }
|
|
43
68
|
onClick={ toggle }
|
|
44
69
|
style={ {
|
|
45
70
|
cursor: 'pointer',
|
|
46
71
|
...props.style,
|
|
47
72
|
} }
|
|
73
|
+
isBorderless
|
|
48
74
|
>
|
|
49
75
|
<div
|
|
50
76
|
style={ {
|
|
@@ -63,12 +89,17 @@ export function useCollapsibleCard( initialIsOpen: boolean = true ) {
|
|
|
63
89
|
aria-expanded={ isOpen }
|
|
64
90
|
aria-label={ isOpen ? 'Collapse' : 'Expand' }
|
|
65
91
|
/>
|
|
66
|
-
</
|
|
92
|
+
</OriginalCardHeader>
|
|
67
93
|
),
|
|
68
94
|
[ toggle, isOpen ]
|
|
69
95
|
);
|
|
70
96
|
|
|
71
|
-
|
|
97
|
+
const effectiveIsOpen = isCollapsible ? isOpen : true;
|
|
98
|
+
const CardHeaderComponent = isCollapsible
|
|
99
|
+
? CollapsibleCardHeader
|
|
100
|
+
: NonCollapsibleCardHeader;
|
|
101
|
+
|
|
102
|
+
return { isOpen: effectiveIsOpen, CardHeader: CardHeaderComponent };
|
|
72
103
|
}
|
|
73
104
|
|
|
74
105
|
function isSummaryFieldVisible< Item >(
|
|
@@ -130,23 +161,17 @@ export default function FormCardField< Item >( {
|
|
|
130
161
|
validity,
|
|
131
162
|
}: FieldLayoutProps< Item > ) {
|
|
132
163
|
const { fields } = useContext( DataFormContext );
|
|
164
|
+
const layout = field.layout as NormalizedCardLayout;
|
|
133
165
|
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const form: Form = useMemo(
|
|
140
|
-
(): Form => ( {
|
|
141
|
-
layout: DEFAULT_LAYOUT as Layout,
|
|
142
|
-
fields: isCombinedField( field ) ? field.children : [],
|
|
166
|
+
const form: NormalizedForm = useMemo(
|
|
167
|
+
() => ( {
|
|
168
|
+
layout: DEFAULT_LAYOUT as NormalizedLayout,
|
|
169
|
+
fields: field.children ?? [],
|
|
143
170
|
} ),
|
|
144
171
|
[ field ]
|
|
145
172
|
);
|
|
146
173
|
|
|
147
|
-
const { isOpen,
|
|
148
|
-
layout.isOpened
|
|
149
|
-
);
|
|
174
|
+
const { isOpen, CardHeader } = useCardHeader( layout );
|
|
150
175
|
|
|
151
176
|
const summaryFields = getSummaryFields< Item >( layout.summary, fields );
|
|
152
177
|
|
|
@@ -154,12 +179,29 @@ export default function FormCardField< Item >( {
|
|
|
154
179
|
isSummaryFieldVisible( summaryField, layout.summary, isOpen )
|
|
155
180
|
);
|
|
156
181
|
|
|
157
|
-
|
|
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 ) {
|
|
158
190
|
const withHeader = !! field.label && layout.withHeader;
|
|
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
|
+
|
|
159
201
|
return (
|
|
160
|
-
<Card className="dataforms-layouts-card__field">
|
|
202
|
+
<Card className="dataforms-layouts-card__field" size={ sizeCard }>
|
|
161
203
|
{ withHeader && (
|
|
162
|
-
<
|
|
204
|
+
<CardHeader className="dataforms-layouts-card__field-header">
|
|
163
205
|
<span className="dataforms-layouts-card__field-header-label">
|
|
164
206
|
{ field.label }
|
|
165
207
|
</span>
|
|
@@ -177,12 +219,15 @@ export default function FormCardField< Item >( {
|
|
|
177
219
|
) }
|
|
178
220
|
</div>
|
|
179
221
|
) }
|
|
180
|
-
</
|
|
222
|
+
</CardHeader>
|
|
181
223
|
) }
|
|
182
224
|
{ ( isOpen || ! withHeader ) && (
|
|
183
225
|
// If it doesn't have a header, keep it open.
|
|
184
226
|
// Otherwise, the card will not be visible.
|
|
185
|
-
<CardBody
|
|
227
|
+
<CardBody
|
|
228
|
+
size={ sizeCardBody }
|
|
229
|
+
className="dataforms-layouts-card__field-control"
|
|
230
|
+
>
|
|
186
231
|
{ field.description && (
|
|
187
232
|
<div className="dataforms-layouts-card__field-description">
|
|
188
233
|
{ field.description }
|
|
@@ -213,10 +258,18 @@ export default function FormCardField< Item >( {
|
|
|
213
258
|
return null;
|
|
214
259
|
}
|
|
215
260
|
const withHeader = !! fieldDefinition.label && layout.withHeader;
|
|
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
|
+
|
|
216
269
|
return (
|
|
217
|
-
<Card className="dataforms-layouts-card__field">
|
|
270
|
+
<Card className="dataforms-layouts-card__field" size={ sizeCard }>
|
|
218
271
|
{ withHeader && (
|
|
219
|
-
<
|
|
272
|
+
<CardHeader className="dataforms-layouts-card__field-header">
|
|
220
273
|
<span className="dataforms-layouts-card__field-header-label">
|
|
221
274
|
{ fieldDefinition.label }
|
|
222
275
|
</span>
|
|
@@ -231,12 +284,15 @@ export default function FormCardField< Item >( {
|
|
|
231
284
|
) ) }
|
|
232
285
|
</div>
|
|
233
286
|
) }
|
|
234
|
-
</
|
|
287
|
+
</CardHeader>
|
|
235
288
|
) }
|
|
236
289
|
{ ( isOpen || ! withHeader ) && (
|
|
237
290
|
// If it doesn't have a header, keep it open.
|
|
238
291
|
// Otherwise, the card will not be visible.
|
|
239
|
-
<CardBody
|
|
292
|
+
<CardBody
|
|
293
|
+
size={ sizeCardBody }
|
|
294
|
+
className="dataforms-layouts-card__field-control"
|
|
295
|
+
>
|
|
240
296
|
<RegularLayout
|
|
241
297
|
data={ data }
|
|
242
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>
|