@wordpress/dataviews 10.0.1-next.ff1cebbba.0 → 10.1.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 +10 -1
- package/README.md +97 -8
- package/build/components/dataform/index.js +11 -2
- package/build/components/dataform/index.js.map +2 -2
- package/build/components/dataform-context/index.js.map +2 -2
- package/build/components/dataviews-bulk-actions/index.js +2 -4
- package/build/components/dataviews-bulk-actions/index.js.map +2 -2
- package/build/components/dataviews-filters/filter.js +9 -4
- package/build/components/dataviews-filters/filter.js.map +3 -3
- package/build/components/dataviews-filters/search-widget.js +13 -2
- package/build/components/dataviews-filters/search-widget.js.map +3 -3
- package/build/components/dataviews-filters/use-filters.js +4 -2
- package/build/components/dataviews-filters/use-filters.js.map +2 -2
- package/build/components/dataviews-item-actions/index.js +6 -6
- package/build/components/dataviews-item-actions/index.js.map +2 -2
- package/build/dataform-controls/array.js +14 -61
- package/build/dataform-controls/array.js.map +3 -3
- package/build/dataform-controls/checkbox.js +5 -29
- package/build/dataform-controls/checkbox.js.map +3 -3
- package/build/dataform-controls/color.js +5 -29
- package/build/dataform-controls/color.js.map +3 -3
- package/build/dataform-controls/date.js +40 -57
- package/build/dataform-controls/date.js.map +3 -3
- package/build/dataform-controls/datetime.js +12 -37
- package/build/dataform-controls/datetime.js.map +3 -3
- package/build/dataform-controls/email.js +3 -1
- package/build/dataform-controls/email.js.map +2 -2
- package/build/dataform-controls/index.js +2 -1
- package/build/dataform-controls/index.js.map +3 -3
- package/build/dataform-controls/password.js +3 -1
- package/build/dataform-controls/password.js.map +2 -2
- package/build/dataform-controls/radio.js +24 -43
- package/build/dataform-controls/radio.js.map +3 -3
- package/build/dataform-controls/select.js +13 -30
- package/build/dataform-controls/select.js.map +3 -3
- package/build/dataform-controls/telephone.js +3 -1
- package/build/dataform-controls/telephone.js.map +2 -2
- package/build/dataform-controls/text.js +3 -1
- package/build/dataform-controls/text.js.map +2 -2
- package/build/dataform-controls/textarea.js +6 -30
- package/build/dataform-controls/textarea.js.map +3 -3
- package/build/dataform-controls/toggle-group.js +38 -56
- package/build/dataform-controls/toggle-group.js.map +3 -3
- package/build/dataform-controls/toggle.js +6 -30
- package/build/dataform-controls/toggle.js.map +3 -3
- package/build/dataform-controls/url.js +3 -1
- package/build/dataform-controls/url.js.map +2 -2
- package/build/dataform-controls/utils/get-custom-validity.js +35 -0
- package/build/dataform-controls/utils/get-custom-validity.js.map +7 -0
- package/build/dataform-controls/utils/validated-input.js +4 -28
- package/build/dataform-controls/utils/validated-input.js.map +3 -3
- package/build/dataform-controls/utils/validated-number.js +6 -30
- package/build/dataform-controls/utils/validated-number.js.map +3 -3
- package/build/dataform-layouts/card/index.js +6 -3
- package/build/dataform-layouts/card/index.js.map +2 -2
- package/build/dataform-layouts/data-form-layout.js +8 -2
- package/build/dataform-layouts/data-form-layout.js.map +2 -2
- package/build/dataform-layouts/panel/dropdown.js +21 -9
- package/build/dataform-layouts/panel/dropdown.js.map +2 -2
- package/build/dataform-layouts/panel/index.js +12 -10
- package/build/dataform-layouts/panel/index.js.map +2 -2
- package/build/dataform-layouts/panel/modal.js +32 -22
- package/build/dataform-layouts/panel/modal.js.map +3 -3
- package/build/dataform-layouts/regular/index.js +8 -4
- package/build/dataform-layouts/regular/index.js.map +2 -2
- package/build/dataform-layouts/row/index.js +11 -7
- package/build/dataform-layouts/row/index.js.map +2 -2
- package/build/dataviews-layouts/list/index.js +7 -7
- package/build/dataviews-layouts/list/index.js.map +2 -2
- package/build/dataviews-layouts/table/column-header-menu.js +1 -1
- package/build/dataviews-layouts/table/column-header-menu.js.map +2 -2
- package/build/field-types/boolean.js +3 -2
- package/build/field-types/boolean.js.map +3 -3
- package/build/field-types/color.js +2 -2
- package/build/field-types/color.js.map +3 -3
- package/build/field-types/date.js +3 -2
- package/build/field-types/date.js.map +3 -3
- package/build/field-types/datetime.js +2 -1
- package/build/field-types/datetime.js.map +3 -3
- package/build/field-types/email.js +2 -1
- package/build/field-types/email.js.map +3 -3
- package/build/field-types/index.js +2 -1
- package/build/field-types/index.js.map +3 -3
- package/build/field-types/integer.js +2 -1
- package/build/field-types/integer.js.map +3 -3
- package/build/field-types/number.js +18 -9
- package/build/field-types/number.js.map +3 -3
- package/build/field-types/password.js +2 -1
- package/build/field-types/password.js.map +3 -3
- package/build/field-types/telephone.js +2 -1
- package/build/field-types/telephone.js.map +3 -3
- package/build/field-types/text.js +2 -1
- package/build/field-types/text.js.map +3 -3
- package/build/field-types/url.js +2 -1
- package/build/field-types/url.js.map +3 -3
- package/build/field-types/utils/render-from-elements.js +24 -3
- package/build/field-types/utils/render-from-elements.js.map +4 -4
- package/build/hooks/index.js +39 -0
- package/build/hooks/index.js.map +7 -0
- package/build/hooks/use-elements.js +63 -0
- package/build/hooks/use-elements.js.map +7 -0
- package/build/hooks/use-form-validity.js +426 -0
- package/build/hooks/use-form-validity.js.map +7 -0
- package/build/index.js +3 -3
- package/build/index.js.map +2 -2
- package/build/types/dataform.js.map +1 -1
- package/build/types/dataviews.js.map +1 -1
- package/build/types/field-api.js.map +1 -1
- package/build/utils/has-elements.js +27 -0
- package/build/utils/has-elements.js.map +7 -0
- package/build/utils/normalize-fields.js +4 -2
- package/build/utils/normalize-fields.js.map +3 -3
- package/build-module/components/dataform/index.js +11 -2
- package/build-module/components/dataform/index.js.map +2 -2
- package/build-module/components/dataform-context/index.js.map +2 -2
- package/build-module/components/dataviews-bulk-actions/index.js +2 -4
- package/build-module/components/dataviews-bulk-actions/index.js.map +2 -2
- package/build-module/components/dataviews-filters/filter.js +9 -4
- package/build-module/components/dataviews-filters/filter.js.map +2 -2
- package/build-module/components/dataviews-filters/search-widget.js +19 -3
- package/build-module/components/dataviews-filters/search-widget.js.map +2 -2
- package/build-module/components/dataviews-filters/use-filters.js +4 -2
- package/build-module/components/dataviews-filters/use-filters.js.map +2 -2
- package/build-module/components/dataviews-item-actions/index.js +6 -6
- package/build-module/components/dataviews-item-actions/index.js.map +2 -2
- package/build-module/dataform-controls/array.js +16 -63
- package/build-module/dataform-controls/array.js.map +2 -2
- package/build-module/dataform-controls/checkbox.js +6 -30
- package/build-module/dataform-controls/checkbox.js.map +2 -2
- package/build-module/dataform-controls/color.js +6 -30
- package/build-module/dataform-controls/color.js.map +2 -2
- package/build-module/dataform-controls/date.js +49 -66
- package/build-module/dataform-controls/date.js.map +2 -2
- package/build-module/dataform-controls/datetime.js +14 -39
- package/build-module/dataform-controls/datetime.js.map +2 -2
- package/build-module/dataform-controls/email.js +3 -1
- package/build-module/dataform-controls/email.js.map +2 -2
- package/build-module/dataform-controls/index.js +2 -1
- package/build-module/dataform-controls/index.js.map +2 -2
- package/build-module/dataform-controls/password.js +3 -1
- package/build-module/dataform-controls/password.js.map +2 -2
- package/build-module/dataform-controls/radio.js +26 -45
- package/build-module/dataform-controls/radio.js.map +2 -2
- package/build-module/dataform-controls/select.js +15 -32
- package/build-module/dataform-controls/select.js.map +2 -2
- package/build-module/dataform-controls/telephone.js +3 -1
- package/build-module/dataform-controls/telephone.js.map +2 -2
- package/build-module/dataform-controls/text.js +3 -1
- package/build-module/dataform-controls/text.js.map +2 -2
- package/build-module/dataform-controls/textarea.js +7 -31
- package/build-module/dataform-controls/textarea.js.map +2 -2
- package/build-module/dataform-controls/toggle-group.js +41 -58
- package/build-module/dataform-controls/toggle-group.js.map +2 -2
- package/build-module/dataform-controls/toggle.js +7 -31
- package/build-module/dataform-controls/toggle.js.map +2 -2
- package/build-module/dataform-controls/url.js +3 -1
- package/build-module/dataform-controls/url.js.map +2 -2
- package/build-module/dataform-controls/utils/get-custom-validity.js +15 -0
- package/build-module/dataform-controls/utils/get-custom-validity.js.map +7 -0
- package/build-module/dataform-controls/utils/validated-input.js +5 -29
- package/build-module/dataform-controls/utils/validated-input.js.map +2 -2
- package/build-module/dataform-controls/utils/validated-number.js +7 -31
- package/build-module/dataform-controls/utils/validated-number.js.map +2 -2
- package/build-module/dataform-layouts/card/index.js +6 -3
- package/build-module/dataform-layouts/card/index.js.map +2 -2
- package/build-module/dataform-layouts/data-form-layout.js +8 -2
- package/build-module/dataform-layouts/data-form-layout.js.map +2 -2
- package/build-module/dataform-layouts/panel/dropdown.js +21 -9
- package/build-module/dataform-layouts/panel/dropdown.js.map +2 -2
- package/build-module/dataform-layouts/panel/index.js +12 -10
- package/build-module/dataform-layouts/panel/index.js.map +2 -2
- package/build-module/dataform-layouts/panel/modal.js +33 -23
- package/build-module/dataform-layouts/panel/modal.js.map +2 -2
- package/build-module/dataform-layouts/regular/index.js +8 -4
- package/build-module/dataform-layouts/regular/index.js.map +2 -2
- package/build-module/dataform-layouts/row/index.js +11 -7
- package/build-module/dataform-layouts/row/index.js.map +2 -2
- package/build-module/dataviews-layouts/list/index.js +7 -7
- package/build-module/dataviews-layouts/list/index.js.map +2 -2
- package/build-module/dataviews-layouts/table/column-header-menu.js +1 -1
- package/build-module/dataviews-layouts/table/column-header-menu.js.map +2 -2
- package/build-module/field-types/boolean.js +4 -3
- package/build-module/field-types/boolean.js.map +2 -2
- package/build-module/field-types/color.js +3 -3
- package/build-module/field-types/color.js.map +2 -2
- package/build-module/field-types/date.js +4 -3
- package/build-module/field-types/date.js.map +2 -2
- package/build-module/field-types/datetime.js +3 -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 +2 -2
- package/build-module/field-types/index.js +3 -2
- package/build-module/field-types/index.js.map +2 -2
- package/build-module/field-types/integer.js +3 -2
- package/build-module/field-types/integer.js.map +2 -2
- package/build-module/field-types/number.js +8 -9
- package/build-module/field-types/number.js.map +2 -2
- package/build-module/field-types/password.js +3 -2
- package/build-module/field-types/password.js.map +2 -2
- package/build-module/field-types/telephone.js +3 -2
- package/build-module/field-types/telephone.js.map +2 -2
- package/build-module/field-types/text.js +3 -2
- package/build-module/field-types/text.js.map +2 -2
- package/build-module/field-types/url.js +3 -2
- package/build-module/field-types/url.js.map +2 -2
- package/build-module/field-types/utils/render-from-elements.js +14 -3
- package/build-module/field-types/utils/render-from-elements.js.map +3 -3
- package/build-module/hooks/index.js +5 -0
- package/build-module/hooks/index.js.map +7 -0
- package/build-module/hooks/use-elements.js +43 -0
- package/build-module/hooks/use-elements.js.map +7 -0
- package/build-module/hooks/use-form-validity.js +392 -0
- package/build-module/hooks/use-form-validity.js.map +7 -0
- package/build-module/index.js +2 -2
- package/build-module/index.js.map +2 -2
- package/build-module/utils/has-elements.js +7 -0
- package/build-module/utils/has-elements.js.map +7 -0
- package/build-module/utils/normalize-fields.js +4 -2
- package/build-module/utils/normalize-fields.js.map +2 -2
- package/build-style/style-rtl.css +10 -4
- package/build-style/style.css +10 -4
- package/build-types/components/dataform/index.d.ts +1 -1
- package/build-types/components/dataform/index.d.ts.map +1 -1
- package/build-types/components/dataform-context/index.d.ts.map +1 -1
- package/build-types/components/dataviews-bulk-actions/index.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/filter.d.ts +1 -1
- package/build-types/components/dataviews-filters/filter.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/search-widget.d.ts.map +1 -1
- package/build-types/components/dataviews-filters/use-filters.d.ts.map +1 -1
- package/build-types/components/dataviews-item-actions/index.d.ts.map +1 -1
- package/build-types/dataform-controls/array.d.ts +1 -1
- package/build-types/dataform-controls/array.d.ts.map +1 -1
- package/build-types/dataform-controls/checkbox.d.ts +1 -1
- package/build-types/dataform-controls/checkbox.d.ts.map +1 -1
- package/build-types/dataform-controls/color.d.ts +1 -1
- package/build-types/dataform-controls/color.d.ts.map +1 -1
- package/build-types/dataform-controls/date.d.ts +1 -1
- package/build-types/dataform-controls/date.d.ts.map +1 -1
- package/build-types/dataform-controls/datetime.d.ts +1 -1
- package/build-types/dataform-controls/datetime.d.ts.map +1 -1
- package/build-types/dataform-controls/email.d.ts +1 -1
- package/build-types/dataform-controls/email.d.ts.map +1 -1
- package/build-types/dataform-controls/index.d.ts.map +1 -1
- package/build-types/dataform-controls/password.d.ts +1 -1
- package/build-types/dataform-controls/password.d.ts.map +1 -1
- package/build-types/dataform-controls/radio.d.ts +1 -1
- package/build-types/dataform-controls/radio.d.ts.map +1 -1
- package/build-types/dataform-controls/select.d.ts +1 -1
- package/build-types/dataform-controls/select.d.ts.map +1 -1
- package/build-types/dataform-controls/telephone.d.ts +1 -1
- package/build-types/dataform-controls/telephone.d.ts.map +1 -1
- package/build-types/dataform-controls/text.d.ts +1 -1
- package/build-types/dataform-controls/text.d.ts.map +1 -1
- package/build-types/dataform-controls/textarea.d.ts +1 -1
- package/build-types/dataform-controls/textarea.d.ts.map +1 -1
- package/build-types/dataform-controls/toggle-group.d.ts +1 -1
- package/build-types/dataform-controls/toggle-group.d.ts.map +1 -1
- package/build-types/dataform-controls/toggle.d.ts +1 -1
- package/build-types/dataform-controls/toggle.d.ts.map +1 -1
- package/build-types/dataform-controls/url.d.ts +1 -1
- package/build-types/dataform-controls/url.d.ts.map +1 -1
- package/build-types/dataform-controls/utils/get-custom-validity.d.ts +9 -0
- package/build-types/dataform-controls/utils/get-custom-validity.d.ts.map +1 -0
- package/build-types/dataform-controls/utils/validated-input.d.ts +1 -1
- package/build-types/dataform-controls/utils/validated-input.d.ts.map +1 -1
- package/build-types/dataform-controls/utils/validated-number.d.ts +1 -1
- package/build-types/dataform-controls/utils/validated-number.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 +5 -3
- package/build-types/dataform-layouts/data-form-layout.d.ts.map +1 -1
- package/build-types/dataform-layouts/panel/dropdown.d.ts +8 -7
- package/build-types/dataform-layouts/panel/dropdown.d.ts.map +1 -1
- package/build-types/dataform-layouts/panel/index.d.ts +1 -1
- package/build-types/dataform-layouts/panel/index.d.ts.map +1 -1
- package/build-types/dataform-layouts/panel/modal.d.ts +5 -5
- package/build-types/dataform-layouts/panel/modal.d.ts.map +1 -1
- package/build-types/dataform-layouts/regular/index.d.ts +1 -1
- package/build-types/dataform-layouts/regular/index.d.ts.map +1 -1
- package/build-types/dataform-layouts/row/index.d.ts +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/boolean.d.ts +1 -1
- package/build-types/field-types/date.d.ts +1 -1
- package/build-types/field-types/datetime.d.ts.map +1 -1
- package/build-types/field-types/email.d.ts.map +1 -1
- package/build-types/field-types/index.d.ts.map +1 -1
- package/build-types/field-types/integer.d.ts.map +1 -1
- package/build-types/field-types/number.d.ts +1 -1
- package/build-types/field-types/number.d.ts.map +1 -1
- package/build-types/field-types/password.d.ts +1 -1
- package/build-types/field-types/password.d.ts.map +1 -1
- package/build-types/field-types/telephone.d.ts.map +1 -1
- package/build-types/field-types/text.d.ts.map +1 -1
- package/build-types/field-types/url.d.ts.map +1 -1
- package/build-types/field-types/utils/render-from-elements.d.ts +1 -1
- package/build-types/field-types/utils/render-from-elements.d.ts.map +1 -1
- package/build-types/hooks/index.d.ts +5 -0
- package/build-types/hooks/index.d.ts.map +1 -0
- package/build-types/hooks/use-elements.d.ts +12 -0
- package/build-types/hooks/use-elements.d.ts.map +1 -0
- package/build-types/hooks/use-form-validity.d.ts +16 -0
- package/build-types/hooks/use-form-validity.d.ts.map +1 -0
- package/build-types/index.d.ts +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/stories/dataform.story.d.ts +14 -4
- package/build-types/stories/dataform.story.d.ts.map +1 -1
- package/build-types/stories/dataviews.fixtures.d.ts.map +1 -1
- package/build-types/stories/field-types.story.d.ts +38 -15
- package/build-types/stories/field-types.story.d.ts.map +1 -1
- package/build-types/test/use-form-validity.d.ts +2 -0
- package/build-types/test/use-form-validity.d.ts.map +1 -0
- package/build-types/types/dataform.d.ts +4 -1
- package/build-types/types/dataform.d.ts.map +1 -1
- package/build-types/types/dataviews.d.ts +10 -2
- package/build-types/types/dataviews.d.ts.map +1 -1
- package/build-types/types/field-api.d.ts +25 -1
- package/build-types/types/field-api.d.ts.map +1 -1
- package/build-types/utils/has-elements.d.ts +6 -0
- package/build-types/utils/has-elements.d.ts.map +1 -0
- package/build-types/utils/normalize-fields.d.ts.map +1 -1
- package/build-wp/index.js +1011 -819
- package/package.json +15 -15
- package/src/components/dataform/index.tsx +7 -1
- package/src/components/dataform-context/index.tsx +3 -1
- package/src/components/dataviews-bulk-actions/index.tsx +3 -5
- package/src/components/dataviews-filters/filter.tsx +11 -5
- package/src/components/dataviews-filters/search-widget.tsx +30 -3
- package/src/components/dataviews-filters/style.scss +8 -0
- package/src/components/dataviews-filters/use-filters.ts +4 -2
- package/src/components/dataviews-item-actions/index.tsx +11 -6
- package/src/components/dataviews-item-actions/style.scss +1 -0
- package/src/dataform-controls/array.tsx +16 -82
- package/src/dataform-controls/checkbox.tsx +5 -41
- package/src/dataform-controls/color.tsx +5 -37
- package/src/dataform-controls/date.tsx +63 -76
- package/src/dataform-controls/datetime.tsx +11 -45
- package/src/dataform-controls/email.tsx +2 -0
- package/src/dataform-controls/index.tsx +2 -1
- package/src/dataform-controls/password.tsx +2 -0
- package/src/dataform-controls/radio.tsx +24 -55
- package/src/dataform-controls/select.tsx +14 -42
- package/src/dataform-controls/telephone.tsx +2 -0
- package/src/dataform-controls/text.tsx +2 -0
- package/src/dataform-controls/textarea.tsx +6 -42
- package/src/dataform-controls/toggle-group.tsx +38 -64
- package/src/dataform-controls/toggle.tsx +6 -42
- package/src/dataform-controls/url.tsx +2 -0
- package/src/dataform-controls/utils/get-custom-validity.ts +24 -0
- package/src/dataform-controls/utils/validated-input.tsx +4 -40
- package/src/dataform-controls/utils/validated-number.tsx +6 -44
- package/src/dataform-layouts/card/index.tsx +3 -0
- package/src/dataform-layouts/data-form-layout.tsx +18 -3
- package/src/dataform-layouts/panel/dropdown.tsx +35 -14
- package/src/dataform-layouts/panel/index.tsx +9 -7
- package/src/dataform-layouts/panel/modal.tsx +41 -30
- package/src/dataform-layouts/regular/index.tsx +4 -0
- package/src/dataform-layouts/row/index.tsx +8 -4
- package/src/dataviews-layouts/list/index.tsx +9 -7
- package/src/dataviews-layouts/table/column-header-menu.tsx +1 -1
- package/src/dataviews-layouts/table/style.scss +2 -3
- package/src/field-types/boolean.tsx +3 -3
- package/src/field-types/color.tsx +3 -3
- package/src/field-types/date.tsx +3 -3
- package/src/field-types/datetime.tsx +6 -4
- package/src/field-types/email.tsx +6 -4
- package/src/field-types/index.tsx +6 -4
- package/src/field-types/integer.tsx +6 -4
- package/src/field-types/number.tsx +8 -12
- package/src/field-types/password.tsx +6 -4
- package/src/field-types/telephone.tsx +6 -4
- package/src/field-types/text.tsx +6 -4
- package/src/field-types/url.tsx +6 -4
- package/src/field-types/utils/render-from-elements.tsx +29 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/use-elements.ts +66 -0
- package/src/hooks/use-form-validity.ts +571 -0
- package/src/index.ts +1 -1
- package/src/stories/dataform.story.tsx +243 -59
- package/src/stories/dataviews.fixtures.tsx +9 -4
- package/src/stories/field-types.story.tsx +159 -29
- package/src/test/use-form-validity.ts +546 -0
- package/src/types/dataform.ts +5 -1
- package/src/types/dataviews.ts +12 -2
- package/src/types/field-api.ts +32 -1
- package/src/utils/has-elements.ts +11 -0
- package/src/utils/normalize-fields.ts +7 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/utils/is-item-valid.js +0 -75
- package/build/utils/is-item-valid.js.map +0 -7
- package/build-module/utils/is-item-valid.js +0 -45
- package/build-module/utils/is-item-valid.js.map +0 -7
- package/build-types/test/validation.d.ts +0 -2
- package/build-types/test/validation.d.ts.map +0 -1
- package/build-types/utils/is-item-valid.d.ts +0 -12
- package/build-types/utils/is-item-valid.d.ts.map +0 -1
- package/src/field-types/utils/render-from-elements.ts +0 -15
- package/src/test/validation.ts +0 -322
- package/src/utils/is-item-valid.ts +0 -93
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types/dataform.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Field } from './field-api';\n\n/**\n * DataForm layouts.\n */\nexport type LayoutType = 'regular' | 'panel' | 'card' | 'row';\nexport type LabelPosition = 'top' | 'side' | 'none';\n\nexport type PanelSummaryField = string | string[];\nexport type NormalizedPanelSummaryField = string[];\n\nexport type RegularLayout = {\n\ttype: 'regular';\n\tlabelPosition?: LabelPosition;\n};\nexport type NormalizedRegularLayout = {\n\ttype: 'regular';\n\tlabelPosition: LabelPosition;\n};\n\nexport type PanelLayout = {\n\ttype: 'panel';\n\tlabelPosition?: LabelPosition;\n\topenAs?: 'dropdown' | 'modal';\n\tsummary?: PanelSummaryField;\n};\nexport type NormalizedPanelLayout = {\n\ttype: 'panel';\n\tlabelPosition: LabelPosition;\n\topenAs: 'dropdown' | 'modal';\n\tsummary: NormalizedPanelSummaryField;\n};\n\nexport type CardSummaryField =\n\t| PanelSummaryField // Basic usage: string or string[]\n\t| Array<\n\t\t\t| string\n\t\t\t| {\n\t\t\t\t\tid: string;\n\t\t\t\t\tvisibility: 'always' | 'when-collapsed';\n\t\t\t }\n\t >;\n\nexport type NormalizedCardSummaryField = Array< {\n\tid: string;\n\tvisibility: 'always' | 'when-collapsed';\n} >;\n\nexport type CardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened?: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader?: true | undefined;\n\t\t\tisOpened?: boolean;\n\t\t\tsummary?: CardSummaryField;\n\t };\nexport type NormalizedCardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened: true;\n\t\t\t// Summary is an empty array\n\t\t\tsummary: [];\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: true;\n\t\t\tisOpened: boolean;\n\t\t\tsummary: NormalizedCardSummaryField;\n\t };\n\nexport type RowLayout = {\n\ttype: 'row';\n\talignment?: 'start' | 'center' | 'end';\n\tstyles?: Record< string, { flex?: React.CSSProperties[ 'flex' ] } >;\n};\nexport type NormalizedRowLayout = {\n\ttype: 'row';\n\talignment: 'start' | 'center' | 'end';\n\tstyles: Record< string, { flex?: React.CSSProperties[ 'flex' ] } >;\n};\n\nexport type Layout = RegularLayout | PanelLayout | CardLayout | RowLayout;\nexport type NormalizedLayout =\n\t| NormalizedRegularLayout\n\t| NormalizedPanelLayout\n\t| NormalizedCardLayout\n\t| NormalizedRowLayout;\n\nexport type NormalizedSummaryField =\n\t| NormalizedPanelSummaryField\n\t| NormalizedCardSummaryField;\n\nexport type SimpleFormField = {\n\tid: string;\n\tlayout?: Layout;\n};\n\nexport type CombinedFormField = {\n\tid: string;\n\tlabel?: string;\n\tdescription?: string;\n\tlayout?: Layout;\n\tchildren: Array< FormField | string >;\n};\n\nexport type FormField = SimpleFormField | CombinedFormField;\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\tlayout?: Layout;\n\tfields?: Array< FormField | string >;\n};\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: ( value: Record< string, any > ) => void;\n}\n\nexport interface FieldLayoutProps< Item > {\n\tdata: Item;\n\tfield: FormField;\n\tonChange: ( value: any ) => void;\n\thideLabelFromVision?: boolean;\n}\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Field, FieldValidity } from './field-api';\n\n/**\n * DataForm layouts.\n */\nexport type LayoutType = 'regular' | 'panel' | 'card' | 'row';\nexport type LabelPosition = 'top' | 'side' | 'none';\n\nexport type PanelSummaryField = string | string[];\nexport type NormalizedPanelSummaryField = string[];\n\nexport type RegularLayout = {\n\ttype: 'regular';\n\tlabelPosition?: LabelPosition;\n};\nexport type NormalizedRegularLayout = {\n\ttype: 'regular';\n\tlabelPosition: LabelPosition;\n};\n\nexport type PanelLayout = {\n\ttype: 'panel';\n\tlabelPosition?: LabelPosition;\n\topenAs?: 'dropdown' | 'modal';\n\tsummary?: PanelSummaryField;\n};\nexport type NormalizedPanelLayout = {\n\ttype: 'panel';\n\tlabelPosition: LabelPosition;\n\topenAs: 'dropdown' | 'modal';\n\tsummary: NormalizedPanelSummaryField;\n};\n\nexport type CardSummaryField =\n\t| PanelSummaryField // Basic usage: string or string[]\n\t| Array<\n\t\t\t| string\n\t\t\t| {\n\t\t\t\t\tid: string;\n\t\t\t\t\tvisibility: 'always' | 'when-collapsed';\n\t\t\t }\n\t >;\n\nexport type NormalizedCardSummaryField = Array< {\n\tid: string;\n\tvisibility: 'always' | 'when-collapsed';\n} >;\n\nexport type CardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened?: true;\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader?: true | undefined;\n\t\t\tisOpened?: boolean;\n\t\t\tsummary?: CardSummaryField;\n\t };\nexport type NormalizedCardLayout =\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: false;\n\t\t\t// isOpened cannot be false if withHeader is false as well.\n\t\t\t// Otherwise, the card would not be visible.\n\t\t\tisOpened: true;\n\t\t\t// Summary is an empty array\n\t\t\tsummary: [];\n\t }\n\t| {\n\t\t\ttype: 'card';\n\t\t\twithHeader: true;\n\t\t\tisOpened: boolean;\n\t\t\tsummary: NormalizedCardSummaryField;\n\t };\n\nexport type RowLayout = {\n\ttype: 'row';\n\talignment?: 'start' | 'center' | 'end';\n\tstyles?: Record< string, { flex?: React.CSSProperties[ 'flex' ] } >;\n};\nexport type NormalizedRowLayout = {\n\ttype: 'row';\n\talignment: 'start' | 'center' | 'end';\n\tstyles: Record< string, { flex?: React.CSSProperties[ 'flex' ] } >;\n};\n\nexport type Layout = RegularLayout | PanelLayout | CardLayout | RowLayout;\nexport type NormalizedLayout =\n\t| NormalizedRegularLayout\n\t| NormalizedPanelLayout\n\t| NormalizedCardLayout\n\t| NormalizedRowLayout;\n\nexport type NormalizedSummaryField =\n\t| NormalizedPanelSummaryField\n\t| NormalizedCardSummaryField;\n\nexport type SimpleFormField = {\n\tid: string;\n\tlayout?: Layout;\n};\n\nexport type CombinedFormField = {\n\tid: string;\n\tlabel?: string;\n\tdescription?: string;\n\tlayout?: Layout;\n\tchildren: Array< FormField | string >;\n};\n\nexport type FormField = SimpleFormField | CombinedFormField;\n\n/**\n * The form configuration.\n */\nexport type Form = {\n\tlayout?: Layout;\n\tfields?: Array< FormField | string >;\n};\n\nexport interface DataFormProps< Item > {\n\tdata: Item;\n\tfields: Field< Item >[];\n\tform: Form;\n\tonChange: ( value: Record< string, any > ) => void;\n\tvalidity?: FormValidity;\n}\n\nexport type FormValidity = Record< string, FieldValidity > | undefined;\n\nexport interface FieldLayoutProps< Item > {\n\tdata: Item;\n\tfield: FormField;\n\tonChange: ( value: any ) => void;\n\thideLabelFromVision?: boolean;\n\tvalidity?: FieldValidity;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types/dataviews.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode, ComponentProps } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport type { useFocusOnMount } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tNormalizedField,\n\tOperator,\n\tOption,\n\tSortDirection,\n} from './field-api';\nimport type { SetSelection } from './private';\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n\n\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked?: boolean;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode, ComponentProps } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport type { useFocusOnMount } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tNormalizedField,\n\tOperator,\n\tOption,\n\tSortDirection,\n} from './field-api';\nimport type { SetSelection } from './private';\n\n/**\n * The filters applied to the dataset.\n */\nexport interface Filter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The operator to use.\n\t */\n\toperator: Operator;\n\n\t/**\n\t * The value to filter by.\n\t */\n\tvalue: any;\n\n\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked?: boolean;\n}\n\nexport interface NormalizedFilter {\n\t/**\n\t * The field to filter by.\n\t */\n\tfield: string;\n\n\t/**\n\t * The field name.\n\t */\n\tname: string;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Retrieval function to get the elements.\n\t */\n\tgetElements?: () => Promise< Option[] >;\n\n\t/**\n\t * Whether the filter has elements.\n\t */\n\thasElements: boolean;\n\n\t/**\n\t * Is a single selection filter.\n\t */\n\tsingleSelection: boolean;\n\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether the filter is visible.\n\t */\n\tisVisible: boolean;\n\n\t/**\n\t * Whether it is a primary filter.\n\t */\n\tisPrimary: boolean;\n\n\t/**\n\t * Whether the filter can be edited by the user.\n\t */\n\tisLocked: boolean;\n}\n\ninterface ViewBase {\n\t/**\n\t * The layout of the view.\n\t */\n\ttype: string;\n\n\t/**\n\t * The global search term.\n\t */\n\tsearch?: string;\n\n\t/**\n\t * The filters to apply.\n\t */\n\tfilters?: Filter[];\n\n\t/**\n\t * The sorting configuration.\n\t */\n\tsort?: {\n\t\t/**\n\t\t * The field to sort by.\n\t\t */\n\t\tfield: string;\n\n\t\t/**\n\t\t * The direction to sort by.\n\t\t */\n\t\tdirection: SortDirection;\n\t};\n\n\t/**\n\t * The active page\n\t */\n\tpage?: number;\n\n\t/**\n\t * The number of items per page\n\t */\n\tperPage?: number;\n\n\t/**\n\t * The fields to render\n\t */\n\tfields?: string[];\n\n\t/**\n\t * Title field\n\t */\n\ttitleField?: string;\n\n\t/**\n\t * Media field\n\t */\n\tmediaField?: string;\n\n\t/**\n\t * Description field\n\t */\n\tdescriptionField?: string;\n\n\t/**\n\t * Whether to show the title\n\t */\n\tshowTitle?: boolean;\n\n\t/**\n\t * Whether to show the media\n\t */\n\tshowMedia?: boolean;\n\n\t/**\n\t * Whether to show the description\n\t */\n\tshowDescription?: boolean;\n\n\t/**\n\t * Whether to show the hierarchical levels.\n\t */\n\tshowLevels?: boolean;\n\n\t/**\n\t * The field to group by.\n\t */\n\tgroupByField?: string;\n\n\t/**\n\t * Whether infinite scroll is enabled.\n\t */\n\tinfiniteScrollEnabled?: boolean;\n}\n\nexport interface ColumnStyle {\n\t/**\n\t * The width of the field column.\n\t */\n\twidth?: string | number;\n\n\t/**\n\t * The minimum width of the field column.\n\t */\n\tmaxWidth?: string | number;\n\n\t/**\n\t * The maximum width of the field column.\n\t */\n\tminWidth?: string | number;\n\n\t/**\n\t * The alignment of the field column, defaults to left.\n\t */\n\talign?: 'start' | 'center' | 'end';\n}\n\nexport type Density = 'compact' | 'balanced' | 'comfortable';\n\nexport interface ViewTable extends ViewBase {\n\ttype: 'table';\n\n\tlayout?: {\n\t\t/**\n\t\t * The styles for the columns.\n\t\t */\n\t\tstyles?: Record< string, ColumnStyle >;\n\n\t\t/**\n\t\t * The density of the view.\n\t\t */\n\t\tdensity?: Density;\n\n\t\t/**\n\t\t * Whether the view allows column moving.\n\t\t */\n\t\tenableMoving?: boolean;\n\t};\n}\n\nexport interface ViewList extends ViewBase {\n\ttype: 'list';\n}\n\nexport interface ViewGrid extends ViewBase {\n\ttype: 'grid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\n\t};\n}\n\nexport interface ViewPickerGrid extends ViewBase {\n\ttype: 'pickerGrid';\n\n\tlayout?: {\n\t\t/**\n\t\t * The fields to use as badge fields.\n\t\t */\n\t\tbadgeFields?: string[];\n\n\t\t/**\n\t\t * The preview size of the grid.\n\t\t */\n\t\tpreviewSize?: number;\n\t};\n}\n\nexport type View = ViewList | ViewGrid | ViewTable | ViewPickerGrid;\n\ninterface ActionBase< Item > {\n\t/**\n\t * The unique identifier of the action.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the action.\n\t * In case we want to adjust the label based on the selected items,\n\t * a function can be provided.\n\t */\n\tlabel: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The icon of the action. (Either a string or an SVG element)\n\t * This should be IconType from the components package\n\t * but that import is breaking typescript build for the moment.\n\t */\n\ticon?: any;\n\n\t/**\n\t * Whether the action is disabled.\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the action is a primary action.\n\t */\n\tisPrimary?: boolean;\n\n\t/**\n\t * Whether the item passed as an argument supports the current action.\n\t */\n\tisEligible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the action can be used as a bulk action.\n\t */\n\tsupportsBulk?: boolean;\n\n\t/**\n\t * The context in which the action is visible.\n\t * This is only a \"meta\" information for now.\n\t */\n\tcontext?: 'list' | 'single';\n}\n\nexport interface RenderModalProps< Item > {\n\titems: Item[];\n\tcloseModal?: () => void;\n\tonActionPerformed?: ( items: Item[] ) => void;\n}\n\nexport interface ActionModal< Item > extends ActionBase< Item > {\n\t/**\n\t * Modal to render when the action is triggered.\n\t */\n\tRenderModal: ( {\n\t\titems,\n\t\tcloseModal,\n\t\tonActionPerformed,\n\t}: RenderModalProps< Item > ) => ReactElement;\n\n\t/**\n\t * Whether to hide the modal header.\n\t */\n\thideModalHeader?: boolean;\n\n\t/**\n\t * The header of the modal.\n\t */\n\tmodalHeader?: string | ( ( items: Item[] ) => string );\n\n\t/**\n\t * The size of the modal.\n\t *\n\t * @default 'medium'\n\t */\n\tmodalSize?: 'small' | 'medium' | 'large' | 'fill';\n\n\t/**\n\t * The focus on mount property of the modal.\n\t */\n\tmodalFocusOnMount?:\n\t\t| Parameters< typeof useFocusOnMount >[ 0 ]\n\t\t| 'firstContentElement';\n}\n\nexport interface ActionButton< Item > extends ActionBase< Item > {\n\t/**\n\t * The callback to execute when the action is triggered.\n\t */\n\tcallback: (\n\t\titems: Item[],\n\t\tcontext: {\n\t\t\tregistry: any;\n\t\t\tonActionPerformed?: ( items: Item[] ) => void;\n\t\t}\n\t) => void;\n}\n\nexport type Action< Item > = ActionModal< Item > | ActionButton< Item >;\n\nexport interface ViewBaseProps< Item > {\n\tclassName?: string;\n\tactions: Action< Item >[];\n\tdata: Item[];\n\tfields: NormalizedField< Item >[];\n\tgetItemId: ( item: Item ) => string;\n\tgetItemLevel?: ( item: Item ) => number;\n\tisLoading?: boolean;\n\tonChangeView: ( view: View ) => void;\n\tonChangeSelection: SetSelection;\n\tselection: string[];\n\tsetOpenedFilter: ( fieldId: string ) => void;\n\tonClickItem?: ( item: Item ) => void;\n\trenderItemLink?: (\n\t\tprops: {\n\t\t\titem: Item;\n\t\t} & ComponentProps< 'a' >\n\t) => ReactElement;\n\tisItemClickable: ( item: Item ) => boolean;\n\tview: View;\n\tempty: ReactNode;\n}\n\nexport type ViewPickerBaseProps< Item > = Omit<\n\tViewBaseProps< Item >,\n\t| 'view'\n\t| 'onChangeView'\n\t// The following props are not supported for pickers.\n\t| 'isItemClickable'\n\t| 'onClickItem'\n\t| 'renderItemLink'\n\t| 'getItemLevel'\n> & {\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n};\n\nexport interface ViewTableProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewTable;\n}\n\nexport interface ViewListProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewList;\n}\n\nexport interface ViewGridProps< Item > extends ViewBaseProps< Item > {\n\tview: ViewGrid;\n}\n\nexport interface ViewPickerGridProps< Item >\n\textends Omit< ViewPickerBaseProps< Item >, 'view' > {\n\tview: ViewPickerGrid;\n}\n\nexport type ViewProps< Item > =\n\t| ViewTableProps< Item >\n\t| ViewGridProps< Item >\n\t| ViewListProps< Item >;\n\nexport type ViewPickerProps< Item > = ViewPickerGridProps< Item >;\n\nexport interface SupportedLayouts {\n\tlist?: Omit< ViewList, 'type' >;\n\tgrid?: Omit< ViewGrid, 'type' >;\n\ttable?: Omit< ViewTable, 'type' >;\n\tpickerGrid?: Omit< ViewPickerGrid, 'type' >;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types/field-api.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement, ComponentType } from 'react';\n\n/**\n * Utility type that makes all properties of T optional recursively.\n * Used by field setValue functions to allow partial item updates.\n */\nexport type DeepPartial< T > = {\n\t[ P in keyof T ]?: T[ P ] extends object ? DeepPartial< T[ P ] > : T[ P ];\n};\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\nexport interface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport interface NormalizedFilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\ninterface FilterConfigForType {\n\t/**\n\t * What operators are used by default.\n\t */\n\tdefaultOperators: Operator[];\n\n\t/**\n\t * What operators are supported by the field.\n\t */\n\tvalidOperators: Operator[];\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll'\n\t| 'lessThan'\n\t| 'greaterThan'\n\t| 'lessThanOrEqual'\n\t| 'greaterThanOrEqual'\n\t| 'before'\n\t| 'after'\n\t| 'beforeInc'\n\t| 'afterInc'\n\t| 'contains'\n\t| 'notContains'\n\t| 'startsWith'\n\t| 'between'\n\t| 'on'\n\t| 'notOn'\n\t| 'inThePast'\n\t| 'over';\n\nexport type FieldType =\n\t| 'text'\n\t| 'integer'\n\t| 'number'\n\t| 'datetime'\n\t| 'date'\n\t| 'media'\n\t| 'boolean'\n\t| 'email'\n\t| 'password'\n\t| 'telephone'\n\t| 'color'\n\t| 'url'\n\t| 'array';\n\n/**\n * An abstract interface for Field based on the field type.\n */\nexport type FieldTypeDefinition< Item > = {\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid: Rules< Item >;\n\n\t/**\n\t * Callback used to render an edit control for the field or control name.\n\t */\n\tEdit:\n\t\t| ComponentType< DataFormControlProps< Item > >\n\t\t| string\n\t\t| EditConfig\n\t\t| null;\n\n\t/**\n\t * Callback used to render the field.\n\t */\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * The filter config for the field.\n\t */\n\tfilterBy: FilterConfigForType | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting: boolean;\n};\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\telements?: boolean;\n\tcustom
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement, ComponentType } from 'react';\n\n/**\n * Utility type that makes all properties of T optional recursively.\n * Used by field setValue functions to allow partial item updates.\n */\nexport type DeepPartial< T > = {\n\t[ P in keyof T ]?: T[ P ] extends object ? DeepPartial< T[ P ] > : T[ P ];\n};\n\nexport type SortDirection = 'asc' | 'desc';\n\n/**\n * Generic option type.\n */\nexport interface Option< Value extends any = any > {\n\tvalue: Value;\n\tlabel: string;\n\tdescription?: string;\n}\n\nexport interface FilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators?: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\nexport interface NormalizedFilterByConfig {\n\t/**\n\t * The list of operators supported by the field.\n\t */\n\toperators: Operator[];\n\n\t/**\n\t * Whether it is a primary filter.\n\t *\n\t * A primary filter is always visible and is not listed in the \"Add filter\" component,\n\t * except for the list layout where it behaves like a secondary filter.\n\t */\n\tisPrimary?: boolean;\n}\n\ninterface FilterConfigForType {\n\t/**\n\t * What operators are used by default.\n\t */\n\tdefaultOperators: Operator[];\n\n\t/**\n\t * What operators are supported by the field.\n\t */\n\tvalidOperators: Operator[];\n}\n\nexport type Operator =\n\t| 'is'\n\t| 'isNot'\n\t| 'isAny'\n\t| 'isNone'\n\t| 'isAll'\n\t| 'isNotAll'\n\t| 'lessThan'\n\t| 'greaterThan'\n\t| 'lessThanOrEqual'\n\t| 'greaterThanOrEqual'\n\t| 'before'\n\t| 'after'\n\t| 'beforeInc'\n\t| 'afterInc'\n\t| 'contains'\n\t| 'notContains'\n\t| 'startsWith'\n\t| 'between'\n\t| 'on'\n\t| 'notOn'\n\t| 'inThePast'\n\t| 'over';\n\nexport type FieldType =\n\t| 'text'\n\t| 'integer'\n\t| 'number'\n\t| 'datetime'\n\t| 'date'\n\t| 'media'\n\t| 'boolean'\n\t| 'email'\n\t| 'password'\n\t| 'telephone'\n\t| 'color'\n\t| 'url'\n\t| 'array';\n\n/**\n * An abstract interface for Field based on the field type.\n */\nexport type FieldTypeDefinition< Item > = {\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid: Rules< Item >;\n\n\t/**\n\t * Callback used to render an edit control for the field or control name.\n\t */\n\tEdit:\n\t\t| ComponentType< DataFormControlProps< Item > >\n\t\t| string\n\t\t| EditConfig\n\t\t| null;\n\n\t/**\n\t * Callback used to render the field.\n\t */\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * The filter config for the field.\n\t */\n\tfilterBy: FilterConfigForType | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting: boolean;\n};\n\nexport type Rules< Item > = {\n\trequired?: boolean;\n\telements?: boolean;\n\tcustom?:\n\t\t| ( ( item: Item, field: NormalizedField< Item > ) => null | string )\n\t\t| ( (\n\t\t\t\titem: Item,\n\t\t\t\tfield: NormalizedField< Item >\n\t\t ) => Promise< null | string > );\n};\n\n/**\n * Edit configuration for textarea controls.\n */\nexport type EditConfigTextarea = {\n\tcontrol: 'textarea';\n\t/**\n\t * Number of rows for the textarea.\n\t */\n\trows?: number;\n};\n\n/**\n * Edit configuration for text controls.\n */\nexport type EditConfigText = {\n\tcontrol: 'text';\n\t/**\n\t * Prefix component to display before the input.\n\t */\n\tprefix?: React.ComponentType;\n\t/**\n\t * Suffix component to display after the input.\n\t */\n\tsuffix?: React.ComponentType;\n};\n\n/**\n * Edit configuration for other control types (excluding 'text' and 'textarea').\n */\nexport type EditConfigGeneric = {\n\tcontrol: Exclude< FieldType, 'text' | 'textarea' >;\n};\n\n/**\n * Edit configuration object with type-safe control options.\n * Each control type has its own specific configuration properties.\n */\nexport type EditConfig =\n\t| EditConfigTextarea\n\t| EditConfigText\n\t| EditConfigGeneric;\n\n/**\n * A dataview field for a specific property of a data type.\n */\nexport type Field< Item > = {\n\t/**\n\t * Type of the fields.\n\t */\n\ttype?: FieldType;\n\n\t/**\n\t * The unique identifier of the field.\n\t */\n\tid: string;\n\n\t/**\n\t * The label of the field. Defaults to the id.\n\t */\n\tlabel?: string;\n\n\t/**\n\t * The header of the field. Defaults to the label.\n\t * It allows the usage of a React Element to render the field labels.\n\t */\n\theader?: string | ReactElement;\n\n\t/**\n\t * A description of the field.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Placeholder for the field.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Callback used to render the field. Defaults to `field.getValue`.\n\t */\n\trender?: ComponentType< DataViewRenderFieldProps< Item > >;\n\n\t/**\n\t * Callback used to render an edit control for the field.\n\t */\n\tEdit?: ComponentType< DataFormControlProps< Item > > | string | EditConfig;\n\n\t/**\n\t * Callback used to sort the field.\n\t */\n\tsort?: ( a: Item, b: Item, direction: SortDirection ) => number;\n\n\t/**\n\t * Callback used to validate the field.\n\t */\n\tisValid?: Rules< Item >;\n\n\t/**\n\t * Callback used to decide if a field should be displayed.\n\t */\n\tisVisible?: ( item: Item ) => boolean;\n\n\t/**\n\t * Whether the field is sortable.\n\t */\n\tenableSorting?: boolean;\n\n\t/**\n\t * Whether the field is searchable.\n\t */\n\tenableGlobalSearch?: boolean;\n\n\t/**\n\t * Whether the field can be hidden in the UI.\n\t */\n\tenableHiding?: boolean;\n\n\t/**\n\t * The list of options to pick from when using the field as a filter.\n\t */\n\telements?: Option[];\n\n\t/**\n\t * Retrieval function for elements.\n\t */\n\tgetElements?: () => Promise< Option[] >;\n\n\t/**\n\t * Filter config for the field.\n\t */\n\tfilterBy?: FilterByConfig | false;\n\n\t/**\n\t * Whether the field is readOnly.\n\t * If `true`, the value will be rendered using the `render` callback.\n\t */\n\treadOnly?: boolean;\n\n\t/**\n\t * Callback used to retrieve the value of the field from the item.\n\t * Defaults to `item[ field.id ]`.\n\t */\n\tgetValue?: ( args: { item: Item } ) => any;\n\n\t/**\n\t * Callback used to set the value of the field on the item.\n\t * Used for editing operations to update field values.\n\t */\n\tsetValue?: ( args: { item: Item; value: any } ) => DeepPartial< Item >;\n};\n\nexport type NormalizedField< Item > = Omit< Field< Item >, 'Edit' > & {\n\tlabel: string;\n\theader: string | ReactElement;\n\tgetValue: ( args: { item: Item } ) => any;\n\tsetValue: ( args: { item: Item; value: any } ) => DeepPartial< Item >;\n\trender: ComponentType< DataViewRenderFieldProps< Item > >;\n\tEdit: ComponentType< DataFormControlProps< Item > > | null;\n\thasElements: boolean;\n\tsort: ( a: Item, b: Item, direction: SortDirection ) => number;\n\tisValid: Rules< Item >;\n\tenableHiding: boolean;\n\tenableSorting: boolean;\n\tfilterBy: NormalizedFilterByConfig | false;\n\treadOnly: boolean;\n};\n\n/**\n * A collection of dataview fields for a data type.\n */\nexport type Fields< Item > = Field< Item >[];\n\nexport type FieldValidity = {\n\trequired?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage?: string;\n\t};\n\telements?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tcustom?: {\n\t\ttype: 'valid' | 'invalid' | 'validating';\n\t\tmessage: string;\n\t};\n\tchildren?: Record< string, FieldValidity >;\n};\n\nexport type DataFormControlProps< Item > = {\n\tdata: Item;\n\tfield: NormalizedField< Item >;\n\tonChange: ( value: DeepPartial< Item > ) => void;\n\thideLabelFromVision?: boolean;\n\t/**\n\t * The currently selected filter operator for this field.\n\t *\n\t * Used by DataViews filters to determine which control to render based on the operator type.\n\t */\n\toperator?: Operator;\n\t/**\n\t * Validity information for the field, if any.\n\t */\n\tvalidity?: FieldValidity;\n\t/**\n\t * Configuration object for the control.\n\t */\n\tconfig?: {\n\t\tprefix?: React.ComponentType;\n\t\tsuffix?: React.ComponentType;\n\t\trows?: number;\n\t};\n};\n\nexport type DataViewRenderFieldProps< Item > = {\n\titem: Item;\n\tfield: NormalizedField< Item >;\n\tconfig?: {\n\t\tsizes: string;\n\t};\n};\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var has_elements_exports = {};
|
|
20
|
+
__export(has_elements_exports, {
|
|
21
|
+
default: () => hasElements
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(has_elements_exports);
|
|
24
|
+
function hasElements(field) {
|
|
25
|
+
return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=has-elements.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/has-elements.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Field } from '../types/field-api';\n\nexport default function hasElements< Item >( field: Field< Item > ): boolean {\n\treturn (\n\t\t( Array.isArray( field.elements ) && field.elements.length > 0 ) ||\n\t\ttypeof field.getElements === 'function'\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKe,SAAR,YAAsC,OAAgC;AAC5E,SACG,MAAM,QAAS,MAAM,QAAS,KAAK,MAAM,SAAS,SAAS,KAC7D,OAAO,MAAM,gBAAgB;AAE/B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(normalize_fields_exports);
|
|
|
34
34
|
var import_field_types = __toESM(require("../field-types"));
|
|
35
35
|
var import_dataform_controls = require("../dataform-controls");
|
|
36
36
|
var import_constants = require("../constants");
|
|
37
|
+
var import_has_elements = __toESM(require("./has-elements"));
|
|
37
38
|
const getValueFromId = (id) => ({ item }) => {
|
|
38
39
|
const path = id.split(".");
|
|
39
40
|
let value = item;
|
|
@@ -73,7 +74,7 @@ function getFilterBy(field, fieldTypeDefinition) {
|
|
|
73
74
|
operators = operators.filter(
|
|
74
75
|
(operator) => validOperators.includes(operator)
|
|
75
76
|
);
|
|
76
|
-
if (field
|
|
77
|
+
if ((0, import_has_elements.default)(field) && operators.includes(import_constants.OPERATOR_BETWEEN)) {
|
|
77
78
|
operators = operators.filter(
|
|
78
79
|
(operator) => operator !== import_constants.OPERATOR_BETWEEN
|
|
79
80
|
);
|
|
@@ -103,7 +104,7 @@ function getFilterBy(field, fieldTypeDefinition) {
|
|
|
103
104
|
return false;
|
|
104
105
|
}
|
|
105
106
|
let defaultOperators = fieldTypeDefinition.filterBy.defaultOperators;
|
|
106
|
-
if (field
|
|
107
|
+
if ((0, import_has_elements.default)(field) && defaultOperators.includes(import_constants.OPERATOR_BETWEEN)) {
|
|
107
108
|
defaultOperators = defaultOperators.filter(
|
|
108
109
|
(operator) => operator !== import_constants.OPERATOR_BETWEEN
|
|
109
110
|
);
|
|
@@ -148,6 +149,7 @@ function normalizeFields(fields) {
|
|
|
148
149
|
sort,
|
|
149
150
|
isValid,
|
|
150
151
|
Edit,
|
|
152
|
+
hasElements: (0, import_has_elements.default)(field),
|
|
151
153
|
enableHiding: field.enableHiding ?? true,
|
|
152
154
|
enableSorting: field.enableSorting ?? fieldTypeDefinition.enableSorting ?? true,
|
|
153
155
|
filterBy,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/normalize-fields.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { FunctionComponent } from 'react';\n\n/**\n * Internal dependencies\n */\nimport getFieldTypeDefinition from '../field-types';\nimport type {\n\tDataViewRenderFieldProps,\n\tField,\n\tFieldTypeDefinition,\n\tNormalizedFilterByConfig,\n\tNormalizedField,\n} from '../types';\nimport { getControl } from '../dataform-controls';\nimport {\n\tALL_OPERATORS,\n\tOPERATOR_BETWEEN,\n\tSINGLE_SELECTION_OPERATORS,\n} from '../constants';\n\nconst getValueFromId =\n\t( id: string ) =>\n\t( { item }: { item: any } ) => {\n\t\tconst path = id.split( '.' );\n\t\tlet value = item;\n\t\tfor ( const segment of path ) {\n\t\t\tif ( value.hasOwnProperty( segment ) ) {\n\t\t\t\tvalue = value[ segment ];\n\t\t\t} else {\n\t\t\t\tvalue = undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t};\n\nconst setValueFromId =\n\t( id: string ) =>\n\t( { value }: { value: any } ) => {\n\t\tconst path = id.split( '.' );\n\t\tconst result: any = {};\n\t\tlet current = result;\n\n\t\tfor ( const segment of path.slice( 0, -1 ) ) {\n\t\t\tcurrent[ segment ] = {};\n\t\t\tcurrent = current[ segment ];\n\t\t}\n\n\t\tcurrent[ path.at( -1 )! ] = value;\n\t\treturn result;\n\t};\n\nfunction getFilterBy< Item >(\n\tfield: Field< Item >,\n\tfieldTypeDefinition: FieldTypeDefinition< Item >\n): NormalizedFilterByConfig | false {\n\tif ( field.filterBy === false ) {\n\t\treturn false;\n\t}\n\n\tif ( typeof field.filterBy === 'object' ) {\n\t\tlet operators = field.filterBy.operators;\n\n\t\t// Assign default values if no operator was provided.\n\t\tif ( ! operators || ! Array.isArray( operators ) ) {\n\t\t\toperators = !! fieldTypeDefinition.filterBy\n\t\t\t\t? fieldTypeDefinition.filterBy.defaultOperators\n\t\t\t\t: [];\n\t\t}\n\n\t\t// Make sure only valid operators are included.\n\t\tlet validOperators = ALL_OPERATORS;\n\t\tif ( typeof fieldTypeDefinition.filterBy === 'object' ) {\n\t\t\tvalidOperators = fieldTypeDefinition.filterBy.validOperators;\n\t\t}\n\t\toperators = operators.filter( ( operator ) =>\n\t\t\tvalidOperators.includes( operator )\n\t\t);\n\n\t\t// The `between` operator is not supported when elements are provided.\n\t\tif ( field
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,yBAAmC;AAQnC,+BAA2B;AAC3B,uBAIO;
|
|
6
|
-
"names": ["getFieldTypeDefinition", "sort", "render"]
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { FunctionComponent } from 'react';\n\n/**\n * Internal dependencies\n */\nimport getFieldTypeDefinition from '../field-types';\nimport type {\n\tDataViewRenderFieldProps,\n\tField,\n\tFieldTypeDefinition,\n\tNormalizedFilterByConfig,\n\tNormalizedField,\n} from '../types';\nimport { getControl } from '../dataform-controls';\nimport {\n\tALL_OPERATORS,\n\tOPERATOR_BETWEEN,\n\tSINGLE_SELECTION_OPERATORS,\n} from '../constants';\nimport hasElements from './has-elements';\n\nconst getValueFromId =\n\t( id: string ) =>\n\t( { item }: { item: any } ) => {\n\t\tconst path = id.split( '.' );\n\t\tlet value = item;\n\t\tfor ( const segment of path ) {\n\t\t\tif ( value.hasOwnProperty( segment ) ) {\n\t\t\t\tvalue = value[ segment ];\n\t\t\t} else {\n\t\t\t\tvalue = undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t};\n\nconst setValueFromId =\n\t( id: string ) =>\n\t( { value }: { value: any } ) => {\n\t\tconst path = id.split( '.' );\n\t\tconst result: any = {};\n\t\tlet current = result;\n\n\t\tfor ( const segment of path.slice( 0, -1 ) ) {\n\t\t\tcurrent[ segment ] = {};\n\t\t\tcurrent = current[ segment ];\n\t\t}\n\n\t\tcurrent[ path.at( -1 )! ] = value;\n\t\treturn result;\n\t};\n\nfunction getFilterBy< Item >(\n\tfield: Field< Item >,\n\tfieldTypeDefinition: FieldTypeDefinition< Item >\n): NormalizedFilterByConfig | false {\n\tif ( field.filterBy === false ) {\n\t\treturn false;\n\t}\n\n\tif ( typeof field.filterBy === 'object' ) {\n\t\tlet operators = field.filterBy.operators;\n\n\t\t// Assign default values if no operator was provided.\n\t\tif ( ! operators || ! Array.isArray( operators ) ) {\n\t\t\toperators = !! fieldTypeDefinition.filterBy\n\t\t\t\t? fieldTypeDefinition.filterBy.defaultOperators\n\t\t\t\t: [];\n\t\t}\n\n\t\t// Make sure only valid operators are included.\n\t\tlet validOperators = ALL_OPERATORS;\n\t\tif ( typeof fieldTypeDefinition.filterBy === 'object' ) {\n\t\t\tvalidOperators = fieldTypeDefinition.filterBy.validOperators;\n\t\t}\n\t\toperators = operators.filter( ( operator ) =>\n\t\t\tvalidOperators.includes( operator )\n\t\t);\n\n\t\t// The `between` operator is not supported when elements are provided.\n\t\tif ( hasElements( field ) && operators.includes( OPERATOR_BETWEEN ) ) {\n\t\t\toperators = operators.filter(\n\t\t\t\t( operator ) => operator !== OPERATOR_BETWEEN\n\t\t\t);\n\t\t}\n\n\t\t// Do not allow mixing single & multiselection operators.\n\t\t// Remove multiselection operators if any of the single selection ones is present.\n\t\tconst hasSingleSelectionOperator = operators.some( ( operator ) =>\n\t\t\tSINGLE_SELECTION_OPERATORS.includes( operator )\n\t\t);\n\t\tif ( hasSingleSelectionOperator ) {\n\t\t\toperators = operators.filter( ( operator ) =>\n\t\t\t\t// The 'Between' operator is unique as it can be combined with single selection operators.\n\t\t\t\t[ ...SINGLE_SELECTION_OPERATORS, OPERATOR_BETWEEN ].includes(\n\t\t\t\t\toperator\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t// If no operators are left at this point,\n\t\t// the filters should be disabled.\n\t\tif ( operators.length === 0 ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn {\n\t\t\tisPrimary: !! field.filterBy.isPrimary,\n\t\t\toperators,\n\t\t};\n\t}\n\n\tif ( fieldTypeDefinition.filterBy === false ) {\n\t\treturn false;\n\t}\n\n\tlet defaultOperators = fieldTypeDefinition.filterBy.defaultOperators;\n\t// The `between` operator is not supported when elements are provided.\n\tif (\n\t\thasElements( field ) &&\n\t\tdefaultOperators.includes( OPERATOR_BETWEEN )\n\t) {\n\t\tdefaultOperators = defaultOperators.filter(\n\t\t\t( operator ) => operator !== OPERATOR_BETWEEN\n\t\t);\n\t}\n\n\treturn {\n\t\toperators: defaultOperators,\n\t};\n}\n\n/**\n * Apply default values and normalize the fields config.\n *\n * @param fields Fields config.\n * @return Normalized fields config.\n */\nexport default function normalizeFields< Item >(\n\tfields: Field< Item >[]\n): NormalizedField< Item >[] {\n\treturn fields.map( ( field ) => {\n\t\tconst fieldTypeDefinition = getFieldTypeDefinition< Item >(\n\t\t\tfield.type\n\t\t);\n\t\tconst getValue = field.getValue || getValueFromId( field.id );\n\t\tconst setValue = field.setValue || setValueFromId( field.id );\n\n\t\tconst sort =\n\t\t\tfield.sort ??\n\t\t\tfunction sort( a, b, direction ) {\n\t\t\t\treturn fieldTypeDefinition.sort(\n\t\t\t\t\tgetValue( { item: a } ),\n\t\t\t\t\tgetValue( { item: b } ),\n\t\t\t\t\tdirection\n\t\t\t\t);\n\t\t\t};\n\n\t\tconst isValid = {\n\t\t\t...fieldTypeDefinition.isValid,\n\t\t\t...field.isValid,\n\t\t};\n\n\t\tconst Edit = getControl( field, fieldTypeDefinition );\n\n\t\tconst render =\n\t\t\tfield.render ??\n\t\t\tfunction render( {\n\t\t\t\titem,\n\t\t\t\tfield: renderedField,\n\t\t\t}: DataViewRenderFieldProps< Item > ) {\n\t\t\t\treturn (\n\t\t\t\t\tfieldTypeDefinition.render as FunctionComponent<\n\t\t\t\t\t\tDataViewRenderFieldProps< Item >\n\t\t\t\t\t>\n\t\t\t\t )( { item, field: renderedField } );\n\t\t\t};\n\n\t\tconst filterBy = getFilterBy( field, fieldTypeDefinition );\n\n\t\treturn {\n\t\t\t...field,\n\t\t\tlabel: field.label || field.id,\n\t\t\theader: field.header || field.label || field.id,\n\t\t\tgetValue,\n\t\t\tsetValue,\n\t\t\trender,\n\t\t\tsort,\n\t\t\tisValid,\n\t\t\tEdit,\n\t\t\thasElements: hasElements( field ),\n\t\t\tenableHiding: field.enableHiding ?? true,\n\t\t\tenableSorting:\n\t\t\t\tfield.enableSorting ??\n\t\t\t\tfieldTypeDefinition.enableSorting ??\n\t\t\t\ttrue,\n\t\t\tfilterBy,\n\t\t\treadOnly: field.readOnly ?? fieldTypeDefinition.readOnly ?? false,\n\t\t};\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA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M,SACL,MAAM,UACN,SAASC,QAAQ;AAAA,MAChB;AAAA,MACA,OAAO;AAAA,IACR,GAAsC;AACrC,aACC,oBAAoB,OAGjB,EAAE,MAAM,OAAO,cAAc,CAAE;AAAA,IACpC;AAED,UAAM,WAAW,YAAa,OAAO,mBAAoB;AAEzD,WAAO;AAAA,MACN,GAAG;AAAA,MACH,OAAO,MAAM,SAAS,MAAM;AAAA,MAC5B,QAAQ,MAAM,UAAU,MAAM,SAAS,MAAM;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAa,oBAAAH,SAAa,KAAM;AAAA,MAChC,cAAc,MAAM,gBAAgB;AAAA,MACpC,eACC,MAAM,iBACN,oBAAoB,iBACpB;AAAA,MACD;AAAA,MACA,UAAU,MAAM,YAAY,oBAAoB,YAAY;AAAA,IAC7D;AAAA,EACD,CAAE;AACH;",
|
|
6
|
+
"names": ["hasElements", "getFieldTypeDefinition", "sort", "render"]
|
|
7
7
|
}
|
|
@@ -7,7 +7,8 @@ function DataForm({
|
|
|
7
7
|
data,
|
|
8
8
|
form,
|
|
9
9
|
fields,
|
|
10
|
-
onChange
|
|
10
|
+
onChange,
|
|
11
|
+
validity
|
|
11
12
|
}) {
|
|
12
13
|
const normalizedFields = useMemo(
|
|
13
14
|
() => normalizeFields(fields),
|
|
@@ -16,7 +17,15 @@ function DataForm({
|
|
|
16
17
|
if (!form.fields) {
|
|
17
18
|
return null;
|
|
18
19
|
}
|
|
19
|
-
return /* @__PURE__ */ jsx(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ jsx(
|
|
20
|
+
return /* @__PURE__ */ jsx(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ jsx(
|
|
21
|
+
DataFormLayout,
|
|
22
|
+
{
|
|
23
|
+
data,
|
|
24
|
+
form,
|
|
25
|
+
onChange,
|
|
26
|
+
validity
|
|
27
|
+
}
|
|
28
|
+
) });
|
|
20
29
|
}
|
|
21
30
|
export {
|
|
22
31
|
DataForm as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataform/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormProps } from '../../types';\nimport { DataFormProvider } from '../dataform-context';\nimport normalizeFields from '../../utils/normalize-fields';\nimport { DataFormLayout } from '../../dataform-layouts/data-form-layout';\n\nexport default function DataForm< Item >( {\n\tdata,\n\tform,\n\tfields,\n\tonChange,\n}: DataFormProps< Item > ) {\n\tconst normalizedFields = useMemo(\n\t\t() => normalizeFields( fields ),\n\t\t[ fields ]\n\t);\n\n\tif ( ! form.fields ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DataFormProvider fields={ normalizedFields }>\n\t\t\t<DataFormLayout
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormProps } from '../../types';\nimport { DataFormProvider } from '../dataform-context';\nimport normalizeFields from '../../utils/normalize-fields';\nimport { DataFormLayout } from '../../dataform-layouts/data-form-layout';\n\nexport default function DataForm< Item >( {\n\tdata,\n\tform,\n\tfields,\n\tonChange,\n\tvalidity,\n}: DataFormProps< Item > ) {\n\tconst normalizedFields = useMemo(\n\t\t() => normalizeFields( fields ),\n\t\t[ fields ]\n\t);\n\n\tif ( ! form.fields ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DataFormProvider fields={ normalizedFields }>\n\t\t\t<DataFormLayout\n\t\t\t\tdata={ data }\n\t\t\t\tform={ form }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalidity={ validity }\n\t\t\t/>\n\t\t</DataFormProvider>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AA+BG;AA5BH,SAAS,eAAe;AAMxB,SAAS,wBAAwB;AACjC,OAAO,qBAAqB;AAC5B,SAAS,sBAAsB;AAEhB,SAAR,SAAmC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA2B;AAC1B,QAAM,mBAAmB;AAAA,IACxB,MAAM,gBAAiB,MAAO;AAAA,IAC9B,CAAE,MAAO;AAAA,EACV;AAEA,MAAK,CAAE,KAAK,QAAS;AACpB,WAAO;AAAA,EACR;AAEA,SACC,oBAAC,oBAAiB,QAAS,kBAC1B;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD,GACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataform-context/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { NormalizedField } from '../../types';\n\ntype DataFormContextType< Item > = {\n\tfields: NormalizedField< Item >[];\n};\n\nconst DataFormContext = createContext< DataFormContextType< any > >( {\n\tfields: [],\n} );\nDataFormContext.displayName = 'DataFormContext';\n\nexport function DataFormProvider< Item >( {\n\tfields,\n\tchildren,\n}: React.PropsWithChildren< {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { NormalizedField } from '../../types';\n\ntype DataFormContextType< Item > = {\n\tfields: NormalizedField< Item >[];\n};\n\nconst DataFormContext = createContext< DataFormContextType< any > >( {\n\tfields: [],\n} );\nDataFormContext.displayName = 'DataFormContext';\n\nexport function DataFormProvider< Item >( {\n\tfields,\n\tchildren,\n}: React.PropsWithChildren< {\n\tfields: NormalizedField< Item >[];\n} > ) {\n\treturn (\n\t\t<DataFormContext.Provider value={ { fields } }>\n\t\t\t{ children }\n\t\t</DataFormContext.Provider>\n\t);\n}\n\nexport default DataFormContext;\n"],
|
|
5
|
+
"mappings": "AA0BE;AAvBF,SAAS,qBAAqB;AAW9B,MAAM,kBAAkB,cAA6C;AAAA,EACpE,QAAQ,CAAC;AACV,CAAE;AACF,gBAAgB,cAAc;AAEvB,SAAS,iBAA0B;AAAA,EACzC;AAAA,EACA;AACD,GAEM;AACL,SACC,oBAAC,gBAAgB,UAAhB,EAAyB,OAAQ,EAAE,OAAO,GACxC,UACH;AAEF;AAEA,IAAO,2BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -101,12 +101,10 @@ function ActionTrigger({
|
|
|
101
101
|
{
|
|
102
102
|
disabled: isBusy,
|
|
103
103
|
accessibleWhenDisabled: true,
|
|
104
|
-
label,
|
|
105
|
-
icon: action.icon,
|
|
106
104
|
size: "compact",
|
|
107
105
|
onClick,
|
|
108
106
|
isBusy,
|
|
109
|
-
|
|
107
|
+
children: label
|
|
110
108
|
}
|
|
111
109
|
);
|
|
112
110
|
}
|
|
@@ -253,7 +251,7 @@ function FooterContent({
|
|
|
253
251
|
}, [selection, data, getItemId, selectableItems]);
|
|
254
252
|
const actionsToShow = useMemo(
|
|
255
253
|
() => actions.filter((action) => {
|
|
256
|
-
return action.supportsBulk &&
|
|
254
|
+
return action.supportsBulk && selectedItems.some(
|
|
257
255
|
(item) => !action.isEligible || action.isEligible(item)
|
|
258
256
|
);
|
|
259
257
|
}),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataviews-bulk-actions/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCheckboxControl,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { useMemo, useState, useRef, useContext } from '@wordpress/element';\nimport { useRegistry } from '@wordpress/data';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport { ActionModal } from '../dataviews-item-actions';\nimport type { Action, ActionModal as ActionModalType } from '../../types';\nimport type { SetSelection } from '../../types/private';\nimport type { ActionTriggerProps } from '../dataviews-item-actions';\n\ninterface ActionWithModalProps< Item > {\n\taction: ActionModalType< Item >;\n\titems: Item[];\n\tActionTriggerComponent: (\n\t\tprops: ActionTriggerProps< Item >\n\t) => ReactElement;\n}\n\nfunction ActionWithModal< Item >( {\n\taction,\n\titems,\n\tActionTriggerComponent,\n}: ActionWithModalProps< Item > ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst actionTriggerProps = {\n\t\taction,\n\t\tonClick: () => {\n\t\t\tsetIsModalOpen( true );\n\t\t},\n\t\titems,\n\t};\n\treturn (\n\t\t<>\n\t\t\t<ActionTriggerComponent { ...actionTriggerProps } />\n\t\t\t{ isModalOpen && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ action }\n\t\t\t\t\titems={ items }\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport function useHasAPossibleBulkAction< Item >(\n\tactions: Action< Item >[],\n\titem: Item\n) {\n\treturn useMemo( () => {\n\t\treturn actions.some( ( action ) => {\n\t\t\treturn (\n\t\t\t\taction.supportsBulk &&\n\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t);\n\t\t} );\n\t}, [ actions, item ] );\n}\n\nexport function useSomeItemHasAPossibleBulkAction< Item >(\n\tactions: Action< Item >[],\n\tdata: Item[]\n) {\n\treturn useMemo( () => {\n\t\treturn data.some( ( item ) => {\n\t\t\treturn actions.some( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\t}, [ actions, data ] );\n}\n\ninterface BulkSelectionCheckboxProps< Item > {\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tdata: Item[];\n\tactions: Action< Item >[];\n\tgetItemId: ( item: Item ) => string;\n}\n\nexport function BulkSelectionCheckbox< Item >( {\n\tselection,\n\tonChangeSelection,\n\tdata,\n\tactions,\n\tgetItemId,\n}: BulkSelectionCheckboxProps< Item > ) {\n\tconst selectableItems = useMemo( () => {\n\t\treturn data.filter( ( item ) => {\n\t\t\treturn actions.some(\n\t\t\t\t( action ) =>\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t);\n\t\t} );\n\t}, [ data, actions ] );\n\tconst selectedItems = data.filter(\n\t\t( item ) =>\n\t\t\tselection.includes( getItemId( item ) ) &&\n\t\t\tselectableItems.includes( item )\n\t);\n\tconst areAllSelected = selectedItems.length === selectableItems.length;\n\treturn (\n\t\t<CheckboxControl\n\t\t\tclassName=\"dataviews-view-table-selection-checkbox\"\n\t\t\t__nextHasNoMarginBottom\n\t\t\tchecked={ areAllSelected }\n\t\t\tindeterminate={ ! areAllSelected && !! selectedItems.length }\n\t\t\tonChange={ () => {\n\t\t\t\tif ( areAllSelected ) {\n\t\t\t\t\tonChangeSelection( [] );\n\t\t\t\t} else {\n\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\tselectableItems.map( ( item ) => getItemId( item ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} }\n\t\t\taria-label={\n\t\t\t\tareAllSelected ? __( 'Deselect all' ) : __( 'Select all' )\n\t\t\t}\n\t\t/>\n\t);\n}\n\ninterface ActionButtonProps< Item > {\n\taction: Action< Item >;\n\tselectedItems: Item[];\n\tactionInProgress: string | null;\n\tsetActionInProgress: ( actionId: string | null ) => void;\n}\n\ninterface ToolbarContentProps< Item > {\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tdata: Item[];\n\tactions: Action< Item >[];\n\tgetItemId: ( item: Item ) => string;\n}\n\nfunction ActionTrigger< Item >( {\n\taction,\n\tonClick,\n\tisBusy,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Button\n\t\t\tdisabled={ isBusy }\n\t\t\taccessibleWhenDisabled\n\t\t\tlabel={ label }\n\t\t\ticon={ action.icon }\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ onClick }\n\t\t\tisBusy={ isBusy }\n\t\t\ttooltipPosition=\"top\"\n\t\t/>\n\t);\n}\n\nconst EMPTY_ARRAY: [] = [];\n\nfunction ActionButton< Item >( {\n\taction,\n\tselectedItems,\n\tactionInProgress,\n\tsetActionInProgress,\n}: ActionButtonProps< Item > ) {\n\tconst registry = useRegistry();\n\tconst selectedEligibleItems = useMemo( () => {\n\t\treturn selectedItems.filter( ( item ) => {\n\t\t\treturn ! action.isEligible || action.isEligible( item );\n\t\t} );\n\t}, [ action, selectedItems ] );\n\tif ( 'RenderModal' in action ) {\n\t\treturn (\n\t\t\t<ActionWithModal\n\t\t\t\tkey={ action.id }\n\t\t\t\taction={ action }\n\t\t\t\titems={ selectedEligibleItems }\n\t\t\t\tActionTriggerComponent={ ActionTrigger }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<ActionTrigger\n\t\t\tkey={ action.id }\n\t\t\taction={ action }\n\t\t\tonClick={ async () => {\n\t\t\t\tsetActionInProgress( action.id );\n\t\t\t\tawait action.callback( selectedItems, {\n\t\t\t\t\tregistry,\n\t\t\t\t} );\n\t\t\t\tsetActionInProgress( null );\n\t\t\t} }\n\t\t\titems={ selectedEligibleItems }\n\t\t\tisBusy={ actionInProgress === action.id }\n\t\t/>\n\t);\n}\n\nfunction renderFooterContent< Item >(\n\tdata: Item[],\n\tactions: Action< Item >[],\n\tgetItemId: ( item: Item ) => string,\n\tselection: string[],\n\tactionsToShow: Action< Item >[],\n\tselectedItems: Item[],\n\tactionInProgress: string | null,\n\tsetActionInProgress: ( actionId: string | null ) => void,\n\tonChangeSelection: SetSelection\n) {\n\tconst message =\n\t\tselectedItems.length > 0\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %d: number of items. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d Item selected',\n\t\t\t\t\t\t'%d Items selected',\n\t\t\t\t\t\tselectedItems.length\n\t\t\t\t\t),\n\t\t\t\t\tselectedItems.length\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: %d: number of items. */\n\t\t\t\t\t_n( '%d Item', '%d Items', data.length ),\n\t\t\t\t\tdata.length\n\t\t\t );\n\treturn (\n\t\t<HStack\n\t\t\texpanded={ false }\n\t\t\tclassName=\"dataviews-bulk-actions-footer__container\"\n\t\t\tspacing={ 3 }\n\t\t>\n\t\t\t<BulkSelectionCheckbox\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tdata={ data }\n\t\t\t\tactions={ actions }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t/>\n\t\t\t<span className=\"dataviews-bulk-actions-footer__item-count\">\n\t\t\t\t{ message }\n\t\t\t</span>\n\t\t\t<HStack\n\t\t\t\tclassName=\"dataviews-bulk-actions-footer__action-buttons\"\n\t\t\t\texpanded={ false }\n\t\t\t\tspacing={ 1 }\n\t\t\t>\n\t\t\t\t{ actionsToShow.map( ( action ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ActionButton\n\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\tselectedItems={ selectedItems }\n\t\t\t\t\t\t\tactionInProgress={ actionInProgress }\n\t\t\t\t\t\t\tsetActionInProgress={ setActionInProgress }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ selectedItems.length > 0 && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tlabel={ __( 'Cancel' ) }\n\t\t\t\t\t\tdisabled={ !! actionInProgress }\n\t\t\t\t\t\taccessibleWhenDisabled={ false }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChangeSelection( EMPTY_ARRAY );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</HStack>\n\t);\n}\n\nfunction FooterContent< Item >( {\n\tselection,\n\tactions,\n\tonChangeSelection,\n\tdata,\n\tgetItemId,\n}: ToolbarContentProps< Item > ) {\n\tconst [ actionInProgress, setActionInProgress ] = useState< string | null >(\n\t\tnull\n\t);\n\tconst footerContentRef = useRef< JSX.Element | null >( null );\n\n\tconst bulkActions = useMemo(\n\t\t() => actions.filter( ( action ) => action.supportsBulk ),\n\t\t[ actions ]\n\t);\n\tconst selectableItems = useMemo( () => {\n\t\treturn data.filter( ( item ) => {\n\t\t\treturn bulkActions.some(\n\t\t\t\t( action ) => ! action.isEligible || action.isEligible( item )\n\t\t\t);\n\t\t} );\n\t}, [ data, bulkActions ] );\n\n\tconst selectedItems = useMemo( () => {\n\t\treturn data.filter(\n\t\t\t( item ) =>\n\t\t\t\tselection.includes( getItemId( item ) ) &&\n\t\t\t\tselectableItems.includes( item )\n\t\t);\n\t}, [ selection, data, getItemId, selectableItems ] );\n\n\tconst actionsToShow = useMemo(\n\t\t() =>\n\t\t\tactions.filter( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\taction.icon &&\n\t\t\t\t\tselectedItems.some(\n\t\t\t\t\t\t( item ) =>\n\t\t\t\t\t\t\t! action.isEligible || action.isEligible( item )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} ),\n\t\t[ actions, selectedItems ]\n\t);\n\tif ( ! actionInProgress ) {\n\t\tif ( footerContentRef.current ) {\n\t\t\tfooterContentRef.current = null;\n\t\t}\n\t\treturn renderFooterContent(\n\t\t\tdata,\n\t\t\tactions,\n\t\t\tgetItemId,\n\t\t\tselection,\n\t\t\tactionsToShow,\n\t\t\tselectedItems,\n\t\t\tactionInProgress,\n\t\t\tsetActionInProgress,\n\t\t\tonChangeSelection\n\t\t);\n\t} else if ( ! footerContentRef.current ) {\n\t\tfooterContentRef.current = renderFooterContent(\n\t\t\tdata,\n\t\t\tactions,\n\t\t\tgetItemId,\n\t\t\tselection,\n\t\t\tactionsToShow,\n\t\t\tselectedItems,\n\t\t\tactionInProgress,\n\t\t\tsetActionInProgress,\n\t\t\tonChangeSelection\n\t\t);\n\t}\n\treturn footerContentRef.current;\n}\n\nexport function BulkActionsFooter() {\n\tconst {\n\t\tdata,\n\t\tselection,\n\t\tactions = EMPTY_ARRAY,\n\t\tonChangeSelection,\n\t\tgetItemId,\n\t} = useContext( DataViewsContext );\n\treturn (\n\t\t<FooterContent\n\t\t\tselection={ selection }\n\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\tdata={ data }\n\t\t\tactions={ actions }\n\t\t\tgetItemId={ getItemId }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "AAiDE,mBACC,KADD;AAzCF;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP,SAAS,IAAI,SAAS,UAAU;AAChC,SAAS,SAAS,UAAU,QAAQ,kBAAkB;AACtD,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAK3B,OAAO,sBAAsB;AAC7B,SAAS,mBAAmB;AAa5B,SAAS,gBAAyB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AACjC,QAAM,CAAE,aAAa,cAAe,IAAI,SAAU,KAAM;AACxD,QAAM,qBAAqB;AAAA,IAC1B;AAAA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C;AAAA;AAAA,MACA,WAAU;AAAA,MACV,yBAAuB;AAAA,MACvB,SAAU;AAAA,MACV,eAAgB,CAAE,kBAAkB,CAAC,CAAE,cAAc;AAAA,MACrD,UAAW,MAAM;AAChB,YAAK,gBAAiB;AACrB,4BAAmB,CAAC,CAAE;AAAA,QACvB,OAAO;AACN;AAAA,YACC,gBAAgB,IAAK,CAAE,SAAU,UAAW,IAAK,CAAE;AAAA,UACpD;AAAA,QACD;AAAA,MACD;AAAA,MACA,cACC,iBAAiB,GAAI,cAAe,IAAI,GAAI,YAAa;AAAA;AAAA,EAE3D;AAEF;AAiBA,SAAS,cAAuB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAgC;AAC/B,QAAM,QACL,OAAO,OAAO,UAAU,WAAW,OAAO,QAAQ,OAAO,MAAO,KAAM;AACvE,SACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAW;AAAA,MACX,wBAAsB;AAAA,MACtB
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactElement } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tCheckboxControl,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { useMemo, useState, useRef, useContext } from '@wordpress/element';\nimport { useRegistry } from '@wordpress/data';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport DataViewsContext from '../dataviews-context';\nimport { ActionModal } from '../dataviews-item-actions';\nimport type { Action, ActionModal as ActionModalType } from '../../types';\nimport type { SetSelection } from '../../types/private';\nimport type { ActionTriggerProps } from '../dataviews-item-actions';\n\ninterface ActionWithModalProps< Item > {\n\taction: ActionModalType< Item >;\n\titems: Item[];\n\tActionTriggerComponent: (\n\t\tprops: ActionTriggerProps< Item >\n\t) => ReactElement;\n}\n\nfunction ActionWithModal< Item >( {\n\taction,\n\titems,\n\tActionTriggerComponent,\n}: ActionWithModalProps< Item > ) {\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst actionTriggerProps = {\n\t\taction,\n\t\tonClick: () => {\n\t\t\tsetIsModalOpen( true );\n\t\t},\n\t\titems,\n\t};\n\treturn (\n\t\t<>\n\t\t\t<ActionTriggerComponent { ...actionTriggerProps } />\n\t\t\t{ isModalOpen && (\n\t\t\t\t<ActionModal\n\t\t\t\t\taction={ action }\n\t\t\t\t\titems={ items }\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport function useHasAPossibleBulkAction< Item >(\n\tactions: Action< Item >[],\n\titem: Item\n) {\n\treturn useMemo( () => {\n\t\treturn actions.some( ( action ) => {\n\t\t\treturn (\n\t\t\t\taction.supportsBulk &&\n\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t);\n\t\t} );\n\t}, [ actions, item ] );\n}\n\nexport function useSomeItemHasAPossibleBulkAction< Item >(\n\tactions: Action< Item >[],\n\tdata: Item[]\n) {\n\treturn useMemo( () => {\n\t\treturn data.some( ( item ) => {\n\t\t\treturn actions.some( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t\t);\n\t\t\t} );\n\t\t} );\n\t}, [ actions, data ] );\n}\n\ninterface BulkSelectionCheckboxProps< Item > {\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tdata: Item[];\n\tactions: Action< Item >[];\n\tgetItemId: ( item: Item ) => string;\n}\n\nexport function BulkSelectionCheckbox< Item >( {\n\tselection,\n\tonChangeSelection,\n\tdata,\n\tactions,\n\tgetItemId,\n}: BulkSelectionCheckboxProps< Item > ) {\n\tconst selectableItems = useMemo( () => {\n\t\treturn data.filter( ( item ) => {\n\t\t\treturn actions.some(\n\t\t\t\t( action ) =>\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\t( ! action.isEligible || action.isEligible( item ) )\n\t\t\t);\n\t\t} );\n\t}, [ data, actions ] );\n\tconst selectedItems = data.filter(\n\t\t( item ) =>\n\t\t\tselection.includes( getItemId( item ) ) &&\n\t\t\tselectableItems.includes( item )\n\t);\n\tconst areAllSelected = selectedItems.length === selectableItems.length;\n\treturn (\n\t\t<CheckboxControl\n\t\t\tclassName=\"dataviews-view-table-selection-checkbox\"\n\t\t\t__nextHasNoMarginBottom\n\t\t\tchecked={ areAllSelected }\n\t\t\tindeterminate={ ! areAllSelected && !! selectedItems.length }\n\t\t\tonChange={ () => {\n\t\t\t\tif ( areAllSelected ) {\n\t\t\t\t\tonChangeSelection( [] );\n\t\t\t\t} else {\n\t\t\t\t\tonChangeSelection(\n\t\t\t\t\t\tselectableItems.map( ( item ) => getItemId( item ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} }\n\t\t\taria-label={\n\t\t\t\tareAllSelected ? __( 'Deselect all' ) : __( 'Select all' )\n\t\t\t}\n\t\t/>\n\t);\n}\n\ninterface ActionButtonProps< Item > {\n\taction: Action< Item >;\n\tselectedItems: Item[];\n\tactionInProgress: string | null;\n\tsetActionInProgress: ( actionId: string | null ) => void;\n}\n\ninterface ToolbarContentProps< Item > {\n\tselection: string[];\n\tonChangeSelection: SetSelection;\n\tdata: Item[];\n\tactions: Action< Item >[];\n\tgetItemId: ( item: Item ) => string;\n}\n\nfunction ActionTrigger< Item >( {\n\taction,\n\tonClick,\n\tisBusy,\n\titems,\n}: ActionTriggerProps< Item > ) {\n\tconst label =\n\t\ttypeof action.label === 'string' ? action.label : action.label( items );\n\treturn (\n\t\t<Button\n\t\t\tdisabled={ isBusy }\n\t\t\taccessibleWhenDisabled\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ onClick }\n\t\t\tisBusy={ isBusy }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n\nconst EMPTY_ARRAY: [] = [];\n\nfunction ActionButton< Item >( {\n\taction,\n\tselectedItems,\n\tactionInProgress,\n\tsetActionInProgress,\n}: ActionButtonProps< Item > ) {\n\tconst registry = useRegistry();\n\tconst selectedEligibleItems = useMemo( () => {\n\t\treturn selectedItems.filter( ( item ) => {\n\t\t\treturn ! action.isEligible || action.isEligible( item );\n\t\t} );\n\t}, [ action, selectedItems ] );\n\tif ( 'RenderModal' in action ) {\n\t\treturn (\n\t\t\t<ActionWithModal\n\t\t\t\tkey={ action.id }\n\t\t\t\taction={ action }\n\t\t\t\titems={ selectedEligibleItems }\n\t\t\t\tActionTriggerComponent={ ActionTrigger }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<ActionTrigger\n\t\t\tkey={ action.id }\n\t\t\taction={ action }\n\t\t\tonClick={ async () => {\n\t\t\t\tsetActionInProgress( action.id );\n\t\t\t\tawait action.callback( selectedItems, {\n\t\t\t\t\tregistry,\n\t\t\t\t} );\n\t\t\t\tsetActionInProgress( null );\n\t\t\t} }\n\t\t\titems={ selectedEligibleItems }\n\t\t\tisBusy={ actionInProgress === action.id }\n\t\t/>\n\t);\n}\n\nfunction renderFooterContent< Item >(\n\tdata: Item[],\n\tactions: Action< Item >[],\n\tgetItemId: ( item: Item ) => string,\n\tselection: string[],\n\tactionsToShow: Action< Item >[],\n\tselectedItems: Item[],\n\tactionInProgress: string | null,\n\tsetActionInProgress: ( actionId: string | null ) => void,\n\tonChangeSelection: SetSelection\n) {\n\tconst message =\n\t\tselectedItems.length > 0\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %d: number of items. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d Item selected',\n\t\t\t\t\t\t'%d Items selected',\n\t\t\t\t\t\tselectedItems.length\n\t\t\t\t\t),\n\t\t\t\t\tselectedItems.length\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: %d: number of items. */\n\t\t\t\t\t_n( '%d Item', '%d Items', data.length ),\n\t\t\t\t\tdata.length\n\t\t\t );\n\treturn (\n\t\t<HStack\n\t\t\texpanded={ false }\n\t\t\tclassName=\"dataviews-bulk-actions-footer__container\"\n\t\t\tspacing={ 3 }\n\t\t>\n\t\t\t<BulkSelectionCheckbox\n\t\t\t\tselection={ selection }\n\t\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\t\tdata={ data }\n\t\t\t\tactions={ actions }\n\t\t\t\tgetItemId={ getItemId }\n\t\t\t/>\n\t\t\t<span className=\"dataviews-bulk-actions-footer__item-count\">\n\t\t\t\t{ message }\n\t\t\t</span>\n\t\t\t<HStack\n\t\t\t\tclassName=\"dataviews-bulk-actions-footer__action-buttons\"\n\t\t\t\texpanded={ false }\n\t\t\t\tspacing={ 1 }\n\t\t\t>\n\t\t\t\t{ actionsToShow.map( ( action ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<ActionButton\n\t\t\t\t\t\t\tkey={ action.id }\n\t\t\t\t\t\t\taction={ action }\n\t\t\t\t\t\t\tselectedItems={ selectedItems }\n\t\t\t\t\t\t\tactionInProgress={ actionInProgress }\n\t\t\t\t\t\t\tsetActionInProgress={ setActionInProgress }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ selectedItems.length > 0 && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\ttooltipPosition=\"top\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tlabel={ __( 'Cancel' ) }\n\t\t\t\t\t\tdisabled={ !! actionInProgress }\n\t\t\t\t\t\taccessibleWhenDisabled={ false }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChangeSelection( EMPTY_ARRAY );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</HStack>\n\t);\n}\n\nfunction FooterContent< Item >( {\n\tselection,\n\tactions,\n\tonChangeSelection,\n\tdata,\n\tgetItemId,\n}: ToolbarContentProps< Item > ) {\n\tconst [ actionInProgress, setActionInProgress ] = useState< string | null >(\n\t\tnull\n\t);\n\tconst footerContentRef = useRef< JSX.Element | null >( null );\n\n\tconst bulkActions = useMemo(\n\t\t() => actions.filter( ( action ) => action.supportsBulk ),\n\t\t[ actions ]\n\t);\n\tconst selectableItems = useMemo( () => {\n\t\treturn data.filter( ( item ) => {\n\t\t\treturn bulkActions.some(\n\t\t\t\t( action ) => ! action.isEligible || action.isEligible( item )\n\t\t\t);\n\t\t} );\n\t}, [ data, bulkActions ] );\n\n\tconst selectedItems = useMemo( () => {\n\t\treturn data.filter(\n\t\t\t( item ) =>\n\t\t\t\tselection.includes( getItemId( item ) ) &&\n\t\t\t\tselectableItems.includes( item )\n\t\t);\n\t}, [ selection, data, getItemId, selectableItems ] );\n\n\tconst actionsToShow = useMemo(\n\t\t() =>\n\t\t\tactions.filter( ( action ) => {\n\t\t\t\treturn (\n\t\t\t\t\taction.supportsBulk &&\n\t\t\t\t\tselectedItems.some(\n\t\t\t\t\t\t( item ) =>\n\t\t\t\t\t\t\t! action.isEligible || action.isEligible( item )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} ),\n\t\t[ actions, selectedItems ]\n\t);\n\tif ( ! actionInProgress ) {\n\t\tif ( footerContentRef.current ) {\n\t\t\tfooterContentRef.current = null;\n\t\t}\n\t\treturn renderFooterContent(\n\t\t\tdata,\n\t\t\tactions,\n\t\t\tgetItemId,\n\t\t\tselection,\n\t\t\tactionsToShow,\n\t\t\tselectedItems,\n\t\t\tactionInProgress,\n\t\t\tsetActionInProgress,\n\t\t\tonChangeSelection\n\t\t);\n\t} else if ( ! footerContentRef.current ) {\n\t\tfooterContentRef.current = renderFooterContent(\n\t\t\tdata,\n\t\t\tactions,\n\t\t\tgetItemId,\n\t\t\tselection,\n\t\t\tactionsToShow,\n\t\t\tselectedItems,\n\t\t\tactionInProgress,\n\t\t\tsetActionInProgress,\n\t\t\tonChangeSelection\n\t\t);\n\t}\n\treturn footerContentRef.current;\n}\n\nexport function BulkActionsFooter() {\n\tconst {\n\t\tdata,\n\t\tselection,\n\t\tactions = EMPTY_ARRAY,\n\t\tonChangeSelection,\n\t\tgetItemId,\n\t} = useContext( DataViewsContext );\n\treturn (\n\t\t<FooterContent\n\t\t\tselection={ selection }\n\t\t\tonChangeSelection={ onChangeSelection }\n\t\t\tdata={ data }\n\t\t\tactions={ actions }\n\t\t\tgetItemId={ getItemId }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAiDE,mBACC,KADD;AAzCF;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP,SAAS,IAAI,SAAS,UAAU;AAChC,SAAS,SAAS,UAAU,QAAQ,kBAAkB;AACtD,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAK3B,OAAO,sBAAsB;AAC7B,SAAS,mBAAmB;AAa5B,SAAS,gBAAyB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AACjC,QAAM,CAAE,aAAa,cAAe,IAAI,SAAU,KAAM;AACxD,QAAM,qBAAqB;AAAA,IAC1B;AAAA,IACA,SAAS,MAAM;AACd,qBAAgB,IAAK;AAAA,IACtB;AAAA,IACA;AAAA,EACD;AACA,SACC,iCACC;AAAA,wBAAC,0BAAyB,GAAG,oBAAqB;AAAA,IAChD,eACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAa,MAAM,eAAgB,KAAM;AAAA;AAAA,IAC1C;AAAA,KAEF;AAEF;AAEO,SAAS,0BACf,SACA,MACC;AACD,SAAO,QAAS,MAAM;AACrB,WAAO,QAAQ,KAAM,CAAE,WAAY;AAClC,aACC,OAAO,iBACL,CAAE,OAAO,cAAc,OAAO,WAAY,IAAK;AAAA,IAEnD,CAAE;AAAA,EACH,GAAG,CAAE,SAAS,IAAK,CAAE;AACtB;AAEO,SAAS,kCACf,SACA,MACC;AACD,SAAO,QAAS,MAAM;AACrB,WAAO,KAAK,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44
|
+
import useElements from "../../hooks/use-elements";
|
|
44
45
|
const FilterText = ({
|
|
45
46
|
activeElements,
|
|
46
47
|
filterInView,
|
|
@@ -399,8 +400,12 @@ function Filter({
|
|
|
399
400
|
(f) => f.field === filter.field
|
|
400
401
|
);
|
|
401
402
|
let activeElements = [];
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
const { elements } = useElements({
|
|
404
|
+
elements: filter.elements,
|
|
405
|
+
getElements: filter.getElements
|
|
406
|
+
});
|
|
407
|
+
if (elements.length > 0) {
|
|
408
|
+
activeElements = elements.filter((element) => {
|
|
404
409
|
if (filter.singleSelection) {
|
|
405
410
|
return element.value === filterInView?.value;
|
|
406
411
|
}
|
|
@@ -512,13 +517,13 @@ function Filter({
|
|
|
512
517
|
renderContent: () => {
|
|
513
518
|
return /* @__PURE__ */ jsxs(VStack, { spacing: 0, justify: "flex-start", children: [
|
|
514
519
|
/* @__PURE__ */ jsx(OperatorSelector, { ...commonProps }),
|
|
515
|
-
commonProps.filter.
|
|
520
|
+
commonProps.filter.hasElements ? /* @__PURE__ */ jsx(
|
|
516
521
|
SearchWidget,
|
|
517
522
|
{
|
|
518
523
|
...commonProps,
|
|
519
524
|
filter: {
|
|
520
525
|
...commonProps.filter,
|
|
521
|
-
elements
|
|
526
|
+
elements
|
|
522
527
|
}
|
|
523
528
|
}
|
|
524
529
|
) : /* @__PURE__ */ jsx(InputWidget, { ...commonProps, fields })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/dataviews-filters/filter.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { RefObject } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\tFlexItem,\n\tSelectControl,\n\tTooltip,\n\tIcon,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef, createInterpolateElement } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\n\nconst ENTER = 'Enter';\nconst SPACE = ' ';\n\n/**\n * Internal dependencies\n */\nimport SearchWidget from './search-widget';\nimport InputWidget from './input-widget';\nimport {\n\tOPERATORS,\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tOPERATOR_IS_ALL,\n\tOPERATOR_IS_NOT_ALL,\n\tOPERATOR_LESS_THAN,\n\tOPERATOR_GREATER_THAN,\n\tOPERATOR_LESS_THAN_OR_EQUAL,\n\tOPERATOR_GREATER_THAN_OR_EQUAL,\n\tOPERATOR_CONTAINS,\n\tOPERATOR_NOT_CONTAINS,\n\tOPERATOR_STARTS_WITH,\n\tOPERATOR_BEFORE,\n\tOPERATOR_AFTER,\n\tOPERATOR_BEFORE_INC,\n\tOPERATOR_AFTER_INC,\n\tOPERATOR_BETWEEN,\n\tOPERATOR_ON,\n\tOPERATOR_NOT_ON,\n\tOPERATOR_IN_THE_PAST,\n\tOPERATOR_OVER,\n} from '../../constants';\nimport type {\n\tFilter,\n\tNormalizedFilter,\n\tOperator,\n\tOption,\n\tView,\n\tNormalizedField,\n} from '../../types';\n\ninterface FilterTextProps {\n\tactiveElements: Option[];\n\tfilterInView?: Filter;\n\tfilter: NormalizedFilter;\n}\n\ninterface OperatorSelectorProps {\n\tfilter: NormalizedFilter;\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n}\n\ninterface FilterProps extends OperatorSelectorProps {\n\taddFilterRef: RefObject< HTMLButtonElement >;\n\topenedFilter: string | null;\n\tfields: NormalizedField< any >[];\n}\n\nconst FilterText = ( {\n\tactiveElements,\n\tfilterInView,\n\tfilter,\n}: FilterTextProps ) => {\n\tif ( activeElements === undefined || activeElements.length === 0 ) {\n\t\treturn filter.name;\n\t}\n\n\tconst filterTextWrappers = {\n\t\tName: <span className=\"dataviews-filters__summary-filter-text-name\" />,\n\t\tValue: (\n\t\t\t<span className=\"dataviews-filters__summary-filter-text-value\" />\n\t\t),\n\t};\n\n\tif ( filterInView?.operator === OPERATOR_IS_ANY ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is any: Admin, Editor\". */\n\t\t\t\t__( '<Name>%1$s is any: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements.map( ( element ) => element.label ).join( ', ' )\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IS_NONE ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is none: Admin, Editor\". */\n\t\t\t\t__( '<Name>%1$s is none: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements.map( ( element ) => element.label ).join( ', ' )\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IS_ALL ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is all: Admin, Editor\". */\n\t\t\t\t__( '<Name>%1$s is all: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements.map( ( element ) => element.label ).join( ', ' )\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IS_NOT_ALL ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is not all: Admin, Editor\". */\n\t\t\t\t__( '<Name>%1$s is not all: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements.map( ( element ) => element.label ).join( ', ' )\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IS ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is: Admin\". */\n\t\t\t\t__( '<Name>%1$s is: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IS_NOT ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is not: Admin\". */\n\t\t\t\t__( '<Name>%1$s is not: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_LESS_THAN ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Price is less than: 10\". */\n\t\t\t\t__( '<Name>%1$s is less than: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_GREATER_THAN ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Price is greater than: 10\". */\n\t\t\t\t__( '<Name>%1$s is greater than: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_LESS_THAN_OR_EQUAL ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Price is less than or equal to: 10\". */\n\t\t\t\t__(\n\t\t\t\t\t'<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>'\n\t\t\t\t),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_GREATER_THAN_OR_EQUAL ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Price is greater than or equal to: 10\". */\n\t\t\t\t__(\n\t\t\t\t\t'<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>'\n\t\t\t\t),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_CONTAINS ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Title contains: Mars\". */\n\t\t\t\t__( '<Name>%1$s contains: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_NOT_CONTAINS ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Description doesn't contain: photo\". */\n\t\t\t\t__( \"<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>\" ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_STARTS_WITH ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Title starts with: Mar\". */\n\t\t\t\t__( '<Name>%1$s starts with: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_BEFORE ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is before: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is before: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_AFTER ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is after: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is after: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_BEFORE_INC ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is on or before: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is on or before: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_AFTER_INC ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is on or after: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is on or after: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_BETWEEN ) {\n\t\tconst { label } = activeElements[ 0 ];\n\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Min value. 3: Max value. e.g.: \"Item count between (inc): 10 and 180\". */\n\t\t\t\t__(\n\t\t\t\t\t'<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>'\n\t\t\t\t),\n\t\t\t\tfilter.name,\n\t\t\t\tlabel[ 0 ],\n\t\t\t\tlabel[ 1 ]\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_ON ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_NOT_ON ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is not: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is not: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IN_THE_PAST ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is in the past: 1 days\". */\n\t\t\t\t__( '<Name>%1$s is in the past: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\t`${ activeElements[ 0 ].value.value } ${ activeElements[ 0 ].value.unit }`\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_OVER ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is over: 1 days ago\". */\n\t\t\t\t__( '<Name>%1$s is over: </Name><Value>%2$s</Value> ago' ),\n\t\t\t\tfilter.name,\n\t\t\t\t`${ activeElements[ 0 ].value.value } ${ activeElements[ 0 ].value.unit }`\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\treturn sprintf(\n\t\t/* translators: 1: Filter name e.g.: \"Unknown status for Author\". */\n\t\t__( 'Unknown status for %1$s' ),\n\t\tfilter.name\n\t);\n};\n\nfunction OperatorSelector( {\n\tfilter,\n\tview,\n\tonChangeView,\n}: OperatorSelectorProps ) {\n\tconst operatorOptions = filter.operators?.map( ( operator ) => ( {\n\t\tvalue: operator,\n\t\tlabel: OPERATORS[ operator ]?.label,\n\t} ) );\n\tconst currentFilter = view.filters?.find(\n\t\t( _filter ) => _filter.field === filter.field\n\t);\n\tconst value = currentFilter?.operator || filter.operators[ 0 ];\n\treturn (\n\t\toperatorOptions.length > 1 && (\n\t\t\t<HStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"dataviews-filters__summary-operators-container\"\n\t\t\t>\n\t\t\t\t<FlexItem className=\"dataviews-filters__summary-operators-filter-name\">\n\t\t\t\t\t{ filter.name }\n\t\t\t\t</FlexItem>\n\n\t\t\t\t<SelectControl\n\t\t\t\t\tclassName=\"dataviews-filters__summary-operators-filter-select\"\n\t\t\t\t\tlabel={ __( 'Conditions' ) }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\toptions={ operatorOptions }\n\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\tconst operator = newValue as Operator;\n\t\t\t\t\t\tconst currentOperator = currentFilter?.operator;\n\t\t\t\t\t\tconst newFilters = currentFilter\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t...( view.filters ?? [] ).map(\n\t\t\t\t\t\t\t\t\t\t( _filter ) => {\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t_filter.field === filter.field\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t// Reset the value only when switching between operators that have different value types.\n\t\t\t\t\t\t\t\t\t\t\t\tconst OPERATORS_SHOULD_RESET_VALUE =\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tOPERATOR_BETWEEN,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tOPERATOR_IN_THE_PAST,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tOPERATOR_OVER,\n\t\t\t\t\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\t\t\t\tconst shouldResetValue =\n\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentOperator &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t( OPERATORS_SHOULD_RESET_VALUE.includes(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentOperator\n\t\t\t\t\t\t\t\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tOPERATORS_SHOULD_RESET_VALUE.includes(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\toperator\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) );\n\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: shouldResetValue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: _filter.value,\n\t\t\t\t\t\t\t\t\t\t\t\t\toperator,\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn _filter;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t...( view.filters ?? [] ),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\t\t\toperator,\n\t\t\t\t\t\t\t\t\t\tvalue: undefined,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t ];\n\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\tfilters: newFilters,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t)\n\t);\n}\n\nexport default function Filter( {\n\taddFilterRef,\n\topenedFilter,\n\tfields,\n\t...commonProps\n}: FilterProps ) {\n\tconst toggleRef = useRef< HTMLDivElement >( null );\n\tconst { filter, view, onChangeView } = commonProps;\n\tconst filterInView = view.filters?.find(\n\t\t( f ) => f.field === filter.field\n\t);\n\n\tlet activeElements: Option[] = [];\n\n\tif ( filter.elements.length > 0 ) {\n\t\tactiveElements = filter.elements.filter( ( element ) => {\n\t\t\tif ( filter.singleSelection ) {\n\t\t\t\treturn element.value === filterInView?.value;\n\t\t\t}\n\t\t\treturn filterInView?.value?.includes( element.value );\n\t\t} );\n\t} else if ( filterInView?.value !== undefined ) {\n\t\tactiveElements = [\n\t\t\t{\n\t\t\t\tvalue: filterInView.value,\n\t\t\t\tlabel: filterInView.value,\n\t\t\t},\n\t\t];\n\t}\n\n\tconst isPrimary = filter.isPrimary;\n\tconst isLocked = filterInView?.isLocked;\n\tconst hasValues = ! isLocked && filterInView?.value !== undefined;\n\tconst canResetOrRemove = ! isLocked && ( ! isPrimary || hasValues );\n\treturn (\n\t\t<Dropdown\n\t\t\tdefaultOpen={ openedFilter === filter.field }\n\t\t\tcontentClassName=\"dataviews-filters__summary-popover\"\n\t\t\tpopoverProps={ { placement: 'bottom-start', role: 'dialog' } }\n\t\t\tonClose={ () => {\n\t\t\t\ttoggleRef.current?.focus();\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<div className=\"dataviews-filters__summary-chip-container\">\n\t\t\t\t\t<Tooltip\n\t\t\t\t\t\ttext={ sprintf(\n\t\t\t\t\t\t\t/* translators: 1: Filter name. */\n\t\t\t\t\t\t\t__( 'Filter by: %1$s' ),\n\t\t\t\t\t\t\tfilter.name.toLowerCase()\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tplacement=\"top\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'dataviews-filters__summary-chip',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-reset': canResetOrRemove,\n\t\t\t\t\t\t\t\t\t'has-values': hasValues,\n\t\t\t\t\t\t\t\t\t'is-not-clickable': isLocked,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\ttabIndex={ isLocked ? -1 : 0 }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tif ( ! isLocked ) {\n\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! isLocked &&\n\t\t\t\t\t\t\t\t\t[ ENTER, SPACE ].includes( event.key )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-disabled={ isLocked }\n\t\t\t\t\t\t\taria-pressed={ isOpen }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\tref={ toggleRef }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FilterText\n\t\t\t\t\t\t\t\tactiveElements={ activeElements }\n\t\t\t\t\t\t\t\tfilterInView={ filterInView }\n\t\t\t\t\t\t\t\tfilter={ filter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t\t{ canResetOrRemove && (\n\t\t\t\t\t\t<Tooltip\n\t\t\t\t\t\t\ttext={ isPrimary ? __( 'Reset' ) : __( 'Remove' ) }\n\t\t\t\t\t\t\tplacement=\"top\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'dataviews-filters__summary-chip-remove',\n\t\t\t\t\t\t\t\t\t{ 'has-values': hasValues }\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\t\t\t\tfilters: view.filters?.filter(\n\t\t\t\t\t\t\t\t\t\t\t( _filter ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t_filter.field !== filter.field\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t// If the filter is not primary and can be removed, it will be added\n\t\t\t\t\t\t\t\t\t// back to the available filters from `Add filter` component.\n\t\t\t\t\t\t\t\t\tif ( ! isPrimary ) {\n\t\t\t\t\t\t\t\t\t\taddFilterRef.current?.focus();\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t// If is primary, focus the toggle button.\n\t\t\t\t\t\t\t\t\t\ttoggleRef.current?.focus();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Icon icon={ closeSmall } />\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\trenderContent={ () => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 0 } justify=\"flex-start\">\n\t\t\t\t\t\t<OperatorSelector { ...commonProps } />\n\t\t\t\t\t\t{ commonProps.filter.elements.length > 0 ? (\n\t\t\t\t\t\t\t<SearchWidget\n\t\t\t\t\t\t\t\t{ ...commonProps }\n\t\t\t\t\t\t\t\tfilter={ {\n\t\t\t\t\t\t\t\t\t...commonProps.filter,\n\t\t\t\t\t\t\t\t\telements: commonProps.filter.elements,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<InputWidget { ...commonProps } fields={ fields } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { RefObject } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n\tFlexItem,\n\tSelectControl,\n\tTooltip,\n\tIcon,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef, createInterpolateElement } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\n\nconst ENTER = 'Enter';\nconst SPACE = ' ';\n\n/**\n * Internal dependencies\n */\nimport SearchWidget from './search-widget';\nimport InputWidget from './input-widget';\nimport {\n\tOPERATORS,\n\tOPERATOR_IS,\n\tOPERATOR_IS_NOT,\n\tOPERATOR_IS_ANY,\n\tOPERATOR_IS_NONE,\n\tOPERATOR_IS_ALL,\n\tOPERATOR_IS_NOT_ALL,\n\tOPERATOR_LESS_THAN,\n\tOPERATOR_GREATER_THAN,\n\tOPERATOR_LESS_THAN_OR_EQUAL,\n\tOPERATOR_GREATER_THAN_OR_EQUAL,\n\tOPERATOR_CONTAINS,\n\tOPERATOR_NOT_CONTAINS,\n\tOPERATOR_STARTS_WITH,\n\tOPERATOR_BEFORE,\n\tOPERATOR_AFTER,\n\tOPERATOR_BEFORE_INC,\n\tOPERATOR_AFTER_INC,\n\tOPERATOR_BETWEEN,\n\tOPERATOR_ON,\n\tOPERATOR_NOT_ON,\n\tOPERATOR_IN_THE_PAST,\n\tOPERATOR_OVER,\n} from '../../constants';\nimport type {\n\tFilter,\n\tNormalizedField,\n\tNormalizedFilter,\n\tOperator,\n\tOption,\n\tView,\n} from '../../types';\nimport useElements from '../../hooks/use-elements';\n\ninterface FilterTextProps {\n\tactiveElements: Option[];\n\tfilterInView?: Filter;\n\tfilter: NormalizedFilter;\n}\n\ninterface OperatorSelectorProps {\n\tfilter: NormalizedFilter;\n\tview: View;\n\tonChangeView: ( view: View ) => void;\n}\n\ninterface FilterProps extends OperatorSelectorProps {\n\taddFilterRef: RefObject< HTMLButtonElement >;\n\topenedFilter: string | null;\n\tfields: NormalizedField< any >[];\n}\n\nconst FilterText = ( {\n\tactiveElements,\n\tfilterInView,\n\tfilter,\n}: FilterTextProps ) => {\n\tif ( activeElements === undefined || activeElements.length === 0 ) {\n\t\treturn filter.name;\n\t}\n\n\tconst filterTextWrappers = {\n\t\tName: <span className=\"dataviews-filters__summary-filter-text-name\" />,\n\t\tValue: (\n\t\t\t<span className=\"dataviews-filters__summary-filter-text-value\" />\n\t\t),\n\t};\n\n\tif ( filterInView?.operator === OPERATOR_IS_ANY ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is any: Admin, Editor\". */\n\t\t\t\t__( '<Name>%1$s is any: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements.map( ( element ) => element.label ).join( ', ' )\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IS_NONE ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is none: Admin, Editor\". */\n\t\t\t\t__( '<Name>%1$s is none: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements.map( ( element ) => element.label ).join( ', ' )\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IS_ALL ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is all: Admin, Editor\". */\n\t\t\t\t__( '<Name>%1$s is all: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements.map( ( element ) => element.label ).join( ', ' )\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IS_NOT_ALL ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is not all: Admin, Editor\". */\n\t\t\t\t__( '<Name>%1$s is not all: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements.map( ( element ) => element.label ).join( ', ' )\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IS ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is: Admin\". */\n\t\t\t\t__( '<Name>%1$s is: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IS_NOT ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Author is not: Admin\". */\n\t\t\t\t__( '<Name>%1$s is not: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_LESS_THAN ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Price is less than: 10\". */\n\t\t\t\t__( '<Name>%1$s is less than: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_GREATER_THAN ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Price is greater than: 10\". */\n\t\t\t\t__( '<Name>%1$s is greater than: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_LESS_THAN_OR_EQUAL ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Price is less than or equal to: 10\". */\n\t\t\t\t__(\n\t\t\t\t\t'<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>'\n\t\t\t\t),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_GREATER_THAN_OR_EQUAL ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Price is greater than or equal to: 10\". */\n\t\t\t\t__(\n\t\t\t\t\t'<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>'\n\t\t\t\t),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_CONTAINS ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Title contains: Mars\". */\n\t\t\t\t__( '<Name>%1$s contains: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_NOT_CONTAINS ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Description doesn't contain: photo\". */\n\t\t\t\t__( \"<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>\" ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_STARTS_WITH ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Title starts with: Mar\". */\n\t\t\t\t__( '<Name>%1$s starts with: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_BEFORE ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is before: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is before: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_AFTER ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is after: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is after: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_BEFORE_INC ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is on or before: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is on or before: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_AFTER_INC ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is on or after: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is on or after: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_BETWEEN ) {\n\t\tconst { label } = activeElements[ 0 ];\n\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Min value. 3: Max value. e.g.: \"Item count between (inc): 10 and 180\". */\n\t\t\t\t__(\n\t\t\t\t\t'<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>'\n\t\t\t\t),\n\t\t\t\tfilter.name,\n\t\t\t\tlabel[ 0 ],\n\t\t\t\tlabel[ 1 ]\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_ON ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_NOT_ON ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is not: 2024-01-01\". */\n\t\t\t\t__( '<Name>%1$s is not: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\tactiveElements[ 0 ].label\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_IN_THE_PAST ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is in the past: 1 days\". */\n\t\t\t\t__( '<Name>%1$s is in the past: </Name><Value>%2$s</Value>' ),\n\t\t\t\tfilter.name,\n\t\t\t\t`${ activeElements[ 0 ].value.value } ${ activeElements[ 0 ].value.unit }`\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\n\tif ( filterInView?.operator === OPERATOR_OVER ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: 1: Filter name. 2: Filter value. e.g.: \"Date is over: 1 days ago\". */\n\t\t\t\t__( '<Name>%1$s is over: </Name><Value>%2$s</Value> ago' ),\n\t\t\t\tfilter.name,\n\t\t\t\t`${ activeElements[ 0 ].value.value } ${ activeElements[ 0 ].value.unit }`\n\t\t\t),\n\t\t\tfilterTextWrappers\n\t\t);\n\t}\n\treturn sprintf(\n\t\t/* translators: 1: Filter name e.g.: \"Unknown status for Author\". */\n\t\t__( 'Unknown status for %1$s' ),\n\t\tfilter.name\n\t);\n};\n\nfunction OperatorSelector( {\n\tfilter,\n\tview,\n\tonChangeView,\n}: OperatorSelectorProps ) {\n\tconst operatorOptions = filter.operators?.map( ( operator ) => ( {\n\t\tvalue: operator,\n\t\tlabel: OPERATORS[ operator ]?.label,\n\t} ) );\n\tconst currentFilter = view.filters?.find(\n\t\t( _filter ) => _filter.field === filter.field\n\t);\n\tconst value = currentFilter?.operator || filter.operators[ 0 ];\n\treturn (\n\t\toperatorOptions.length > 1 && (\n\t\t\t<HStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tclassName=\"dataviews-filters__summary-operators-container\"\n\t\t\t>\n\t\t\t\t<FlexItem className=\"dataviews-filters__summary-operators-filter-name\">\n\t\t\t\t\t{ filter.name }\n\t\t\t\t</FlexItem>\n\n\t\t\t\t<SelectControl\n\t\t\t\t\tclassName=\"dataviews-filters__summary-operators-filter-select\"\n\t\t\t\t\tlabel={ __( 'Conditions' ) }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\toptions={ operatorOptions }\n\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\tconst operator = newValue as Operator;\n\t\t\t\t\t\tconst currentOperator = currentFilter?.operator;\n\t\t\t\t\t\tconst newFilters = currentFilter\n\t\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t\t...( view.filters ?? [] ).map(\n\t\t\t\t\t\t\t\t\t\t( _filter ) => {\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t_filter.field === filter.field\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\t// Reset the value only when switching between operators that have different value types.\n\t\t\t\t\t\t\t\t\t\t\t\tconst OPERATORS_SHOULD_RESET_VALUE =\n\t\t\t\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tOPERATOR_BETWEEN,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tOPERATOR_IN_THE_PAST,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tOPERATOR_OVER,\n\t\t\t\t\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\t\t\t\tconst shouldResetValue =\n\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentOperator &&\n\t\t\t\t\t\t\t\t\t\t\t\t\t( OPERATORS_SHOULD_RESET_VALUE.includes(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentOperator\n\t\t\t\t\t\t\t\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tOPERATORS_SHOULD_RESET_VALUE.includes(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\toperator\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) );\n\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalue: shouldResetValue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: _filter.value,\n\t\t\t\t\t\t\t\t\t\t\t\t\toperator,\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn _filter;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t\t...( view.filters ?? [] ),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tfield: filter.field,\n\t\t\t\t\t\t\t\t\t\toperator,\n\t\t\t\t\t\t\t\t\t\tvalue: undefined,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t ];\n\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\tfilters: newFilters,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t)\n\t);\n}\n\nexport default function Filter( {\n\taddFilterRef,\n\topenedFilter,\n\tfields,\n\t...commonProps\n}: FilterProps ) {\n\tconst toggleRef = useRef< HTMLDivElement >( null );\n\tconst { filter, view, onChangeView } = commonProps;\n\tconst filterInView = view.filters?.find(\n\t\t( f ) => f.field === filter.field\n\t);\n\n\tlet activeElements: Option[] = [];\n\n\tconst { elements } = useElements( {\n\t\telements: filter.elements,\n\t\tgetElements: filter.getElements,\n\t} );\n\n\tif ( elements.length > 0 ) {\n\t\tactiveElements = elements.filter( ( element ) => {\n\t\t\tif ( filter.singleSelection ) {\n\t\t\t\treturn element.value === filterInView?.value;\n\t\t\t}\n\t\t\treturn filterInView?.value?.includes( element.value );\n\t\t} );\n\t} else if ( filterInView?.value !== undefined ) {\n\t\tactiveElements = [\n\t\t\t{\n\t\t\t\tvalue: filterInView.value,\n\t\t\t\tlabel: filterInView.value,\n\t\t\t},\n\t\t];\n\t}\n\n\tconst isPrimary = filter.isPrimary;\n\tconst isLocked = filterInView?.isLocked;\n\tconst hasValues = ! isLocked && filterInView?.value !== undefined;\n\tconst canResetOrRemove = ! isLocked && ( ! isPrimary || hasValues );\n\treturn (\n\t\t<Dropdown\n\t\t\tdefaultOpen={ openedFilter === filter.field }\n\t\t\tcontentClassName=\"dataviews-filters__summary-popover\"\n\t\t\tpopoverProps={ { placement: 'bottom-start', role: 'dialog' } }\n\t\t\tonClose={ () => {\n\t\t\t\ttoggleRef.current?.focus();\n\t\t\t} }\n\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t<div className=\"dataviews-filters__summary-chip-container\">\n\t\t\t\t\t<Tooltip\n\t\t\t\t\t\ttext={ sprintf(\n\t\t\t\t\t\t\t/* translators: 1: Filter name. */\n\t\t\t\t\t\t\t__( 'Filter by: %1$s' ),\n\t\t\t\t\t\t\tfilter.name.toLowerCase()\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tplacement=\"top\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'dataviews-filters__summary-chip',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'has-reset': canResetOrRemove,\n\t\t\t\t\t\t\t\t\t'has-values': hasValues,\n\t\t\t\t\t\t\t\t\t'is-not-clickable': isLocked,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\ttabIndex={ isLocked ? -1 : 0 }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tif ( ! isLocked ) {\n\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! isLocked &&\n\t\t\t\t\t\t\t\t\t[ ENTER, SPACE ].includes( event.key )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taria-disabled={ isLocked }\n\t\t\t\t\t\t\taria-pressed={ isOpen }\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\tref={ toggleRef }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FilterText\n\t\t\t\t\t\t\t\tactiveElements={ activeElements }\n\t\t\t\t\t\t\t\tfilterInView={ filterInView }\n\t\t\t\t\t\t\t\tfilter={ filter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t\t{ canResetOrRemove && (\n\t\t\t\t\t\t<Tooltip\n\t\t\t\t\t\t\ttext={ isPrimary ? __( 'Reset' ) : __( 'Remove' ) }\n\t\t\t\t\t\t\tplacement=\"top\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t\t'dataviews-filters__summary-chip-remove',\n\t\t\t\t\t\t\t\t\t{ 'has-values': hasValues }\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonChangeView( {\n\t\t\t\t\t\t\t\t\t\t...view,\n\t\t\t\t\t\t\t\t\t\tpage: 1,\n\t\t\t\t\t\t\t\t\t\tfilters: view.filters?.filter(\n\t\t\t\t\t\t\t\t\t\t\t( _filter ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t_filter.field !== filter.field\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t// If the filter is not primary and can be removed, it will be added\n\t\t\t\t\t\t\t\t\t// back to the available filters from `Add filter` component.\n\t\t\t\t\t\t\t\t\tif ( ! isPrimary ) {\n\t\t\t\t\t\t\t\t\t\taddFilterRef.current?.focus();\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t// If is primary, focus the toggle button.\n\t\t\t\t\t\t\t\t\t\ttoggleRef.current?.focus();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Icon icon={ closeSmall } />\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\trenderContent={ () => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 0 } justify=\"flex-start\">\n\t\t\t\t\t\t<OperatorSelector { ...commonProps } />\n\t\t\t\t\t\t{ commonProps.filter.hasElements ? (\n\t\t\t\t\t\t\t<SearchWidget\n\t\t\t\t\t\t\t\t{ ...commonProps }\n\t\t\t\t\t\t\t\tfilter={ {\n\t\t\t\t\t\t\t\t\t...commonProps.filter,\n\t\t\t\t\t\t\t\t\telements,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<InputWidget { ...commonProps } fields={ fields } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AA6FQ,cA4SL,YA5SK;AA1FR,OAAO,UAAU;AAMjB;AAAA,EACC;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,IAAI,eAAe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