@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
package/build-wp/index.js
CHANGED
|
@@ -12946,12 +12946,11 @@ function ButtonTrigger({
|
|
|
12946
12946
|
return /* @__PURE__ */ jsx37(
|
|
12947
12947
|
button_default,
|
|
12948
12948
|
{
|
|
12949
|
-
label,
|
|
12950
|
-
icon: action.icon,
|
|
12951
12949
|
disabled: !!action.disabled,
|
|
12952
12950
|
accessibleWhenDisabled: true,
|
|
12953
12951
|
size: "compact",
|
|
12954
|
-
onClick
|
|
12952
|
+
onClick,
|
|
12953
|
+
children: label
|
|
12955
12954
|
}
|
|
12956
12955
|
);
|
|
12957
12956
|
}
|
|
@@ -12969,10 +12968,11 @@ function ActionModal({
|
|
|
12969
12968
|
closeModal
|
|
12970
12969
|
}) {
|
|
12971
12970
|
const label = typeof action.label === "string" ? action.label : action.label(items);
|
|
12971
|
+
const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
|
|
12972
12972
|
return /* @__PURE__ */ jsx37(
|
|
12973
12973
|
modal_default,
|
|
12974
12974
|
{
|
|
12975
|
-
title:
|
|
12975
|
+
title: modalHeader || label,
|
|
12976
12976
|
__experimentalHideHeader: !!action.hideModalHeader,
|
|
12977
12977
|
onRequestClose: closeModal,
|
|
12978
12978
|
focusOnMount: action.modalFocusOnMount ?? true,
|
|
@@ -13017,7 +13017,7 @@ function ItemActions({
|
|
|
13017
13017
|
(action) => !action.isEligible || action.isEligible(item2)
|
|
13018
13018
|
);
|
|
13019
13019
|
const _primaryActions = _eligibleActions.filter(
|
|
13020
|
-
(action) => action.isPrimary
|
|
13020
|
+
(action) => action.isPrimary
|
|
13021
13021
|
);
|
|
13022
13022
|
return {
|
|
13023
13023
|
primaryActions: _primaryActions,
|
|
@@ -13038,7 +13038,7 @@ function ItemActions({
|
|
|
13038
13038
|
return /* @__PURE__ */ jsxs(
|
|
13039
13039
|
component_default9,
|
|
13040
13040
|
{
|
|
13041
|
-
spacing:
|
|
13041
|
+
spacing: 0,
|
|
13042
13042
|
justify: "flex-end",
|
|
13043
13043
|
className: "dataviews-item-actions",
|
|
13044
13044
|
style: {
|
|
@@ -13244,12 +13244,10 @@ function ActionTrigger({
|
|
|
13244
13244
|
{
|
|
13245
13245
|
disabled: isBusy,
|
|
13246
13246
|
accessibleWhenDisabled: true,
|
|
13247
|
-
label,
|
|
13248
|
-
icon: action.icon,
|
|
13249
13247
|
size: "compact",
|
|
13250
13248
|
onClick,
|
|
13251
13249
|
isBusy,
|
|
13252
|
-
|
|
13250
|
+
children: label
|
|
13253
13251
|
}
|
|
13254
13252
|
);
|
|
13255
13253
|
}
|
|
@@ -13396,7 +13394,7 @@ function FooterContent({
|
|
|
13396
13394
|
}, [selection, data, getItemId, selectableItems]);
|
|
13397
13395
|
const actionsToShow = useMemo(
|
|
13398
13396
|
() => actions.filter((action) => {
|
|
13399
|
-
return action.supportsBulk &&
|
|
13397
|
+
return action.supportsBulk && selectedItems.some(
|
|
13400
13398
|
(item2) => !action.isEligible || action.isEligible(item2)
|
|
13401
13399
|
);
|
|
13402
13400
|
}),
|
|
@@ -13486,7 +13484,7 @@ var _HeaderMenu = forwardRef(function HeaderMenu({
|
|
|
13486
13484
|
isSortable = field.enableSorting !== false;
|
|
13487
13485
|
const header = field.header;
|
|
13488
13486
|
operators = !!field.filterBy && field.filterBy?.operators || [];
|
|
13489
|
-
canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.
|
|
13487
|
+
canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
|
|
13490
13488
|
if (!isSortable && !canMove && !isHidable && !canAddFilter) {
|
|
13491
13489
|
return header;
|
|
13492
13490
|
}
|
|
@@ -14656,12 +14654,12 @@ function PrimaryActionGridCell({
|
|
|
14656
14654
|
render: /* @__PURE__ */ jsx45(
|
|
14657
14655
|
button_default,
|
|
14658
14656
|
{
|
|
14659
|
-
label,
|
|
14660
14657
|
disabled: !!primaryAction.disabled,
|
|
14661
14658
|
accessibleWhenDisabled: true,
|
|
14662
|
-
icon: primaryAction.icon,
|
|
14663
14659
|
size: "small",
|
|
14664
|
-
onClick: () => setIsModalOpen(true)
|
|
14660
|
+
onClick: () => setIsModalOpen(true),
|
|
14661
|
+
variant: "link",
|
|
14662
|
+
children: label
|
|
14665
14663
|
}
|
|
14666
14664
|
),
|
|
14667
14665
|
children: isModalOpen && /* @__PURE__ */ jsx45(
|
|
@@ -14680,14 +14678,14 @@ function PrimaryActionGridCell({
|
|
|
14680
14678
|
render: /* @__PURE__ */ jsx45(
|
|
14681
14679
|
button_default,
|
|
14682
14680
|
{
|
|
14683
|
-
label,
|
|
14684
14681
|
disabled: !!primaryAction.disabled,
|
|
14685
14682
|
accessibleWhenDisabled: true,
|
|
14686
|
-
icon: primaryAction.icon,
|
|
14687
14683
|
size: "small",
|
|
14688
14684
|
onClick: () => {
|
|
14689
14685
|
primaryAction.callback([item2], { registry });
|
|
14690
|
-
}
|
|
14686
|
+
},
|
|
14687
|
+
variant: "link",
|
|
14688
|
+
children: label
|
|
14691
14689
|
}
|
|
14692
14690
|
)
|
|
14693
14691
|
}
|
|
@@ -14740,7 +14738,7 @@ function ListItem({
|
|
|
14740
14738
|
(action) => !action.isEligible || action.isEligible(item2)
|
|
14741
14739
|
);
|
|
14742
14740
|
const _primaryActions = _eligibleActions.filter(
|
|
14743
|
-
(action) => action.isPrimary
|
|
14741
|
+
(action) => action.isPrimary
|
|
14744
14742
|
);
|
|
14745
14743
|
return {
|
|
14746
14744
|
primaryAction: _primaryActions[0],
|
|
@@ -15942,6 +15940,46 @@ var getCurrentValue = (filterDefinition, currentFilter) => {
|
|
|
15942
15940
|
return EMPTY_ARRAY3;
|
|
15943
15941
|
};
|
|
15944
15942
|
|
|
15943
|
+
// src/hooks/use-elements.ts
|
|
15944
|
+
var EMPTY_ARRAY4 = [];
|
|
15945
|
+
function useElements({
|
|
15946
|
+
elements,
|
|
15947
|
+
getElements
|
|
15948
|
+
}) {
|
|
15949
|
+
const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
|
|
15950
|
+
const [records, setRecords] = useState(staticElements);
|
|
15951
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
15952
|
+
useEffect(() => {
|
|
15953
|
+
if (!getElements) {
|
|
15954
|
+
setRecords(staticElements);
|
|
15955
|
+
return;
|
|
15956
|
+
}
|
|
15957
|
+
let cancelled = false;
|
|
15958
|
+
setIsLoading(true);
|
|
15959
|
+
getElements().then((fetchedElements) => {
|
|
15960
|
+
if (!cancelled) {
|
|
15961
|
+
const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
|
|
15962
|
+
setRecords(dynamicElements);
|
|
15963
|
+
}
|
|
15964
|
+
}).catch(() => {
|
|
15965
|
+
if (!cancelled) {
|
|
15966
|
+
setRecords(staticElements);
|
|
15967
|
+
}
|
|
15968
|
+
}).finally(() => {
|
|
15969
|
+
if (!cancelled) {
|
|
15970
|
+
setIsLoading(false);
|
|
15971
|
+
}
|
|
15972
|
+
});
|
|
15973
|
+
return () => {
|
|
15974
|
+
cancelled = true;
|
|
15975
|
+
};
|
|
15976
|
+
}, [getElements, staticElements]);
|
|
15977
|
+
return {
|
|
15978
|
+
elements: records,
|
|
15979
|
+
isLoading
|
|
15980
|
+
};
|
|
15981
|
+
}
|
|
15982
|
+
|
|
15945
15983
|
// src/components/dataviews-filters/search-widget.tsx
|
|
15946
15984
|
import { jsx as jsx51, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
15947
15985
|
function normalizeSearchInput(input = "") {
|
|
@@ -16217,8 +16255,18 @@ function ComboboxList2({ view, filter, onChangeView }) {
|
|
|
16217
16255
|
);
|
|
16218
16256
|
}
|
|
16219
16257
|
function SearchWidget(props) {
|
|
16220
|
-
const
|
|
16221
|
-
|
|
16258
|
+
const { elements, isLoading } = useElements({
|
|
16259
|
+
elements: props.filter.elements,
|
|
16260
|
+
getElements: props.filter.getElements
|
|
16261
|
+
});
|
|
16262
|
+
if (isLoading) {
|
|
16263
|
+
return /* @__PURE__ */ jsx51("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ jsx51(spinner_default, {}) });
|
|
16264
|
+
}
|
|
16265
|
+
if (elements.length === 0) {
|
|
16266
|
+
return /* @__PURE__ */ jsx51("div", { className: "dataviews-filters__search-widget-no-elements", children: __28("No elements found") });
|
|
16267
|
+
}
|
|
16268
|
+
const Widget = elements.length > 10 ? ComboboxList2 : ListBox;
|
|
16269
|
+
return /* @__PURE__ */ jsx51(Widget, { ...props, filter: { ...props.filter, elements } });
|
|
16222
16270
|
}
|
|
16223
16271
|
|
|
16224
16272
|
// src/components/dataviews-filters/input-widget.tsx
|
|
@@ -16672,8 +16720,12 @@ function Filter({
|
|
|
16672
16720
|
(f) => f.field === filter.field
|
|
16673
16721
|
);
|
|
16674
16722
|
let activeElements = [];
|
|
16675
|
-
|
|
16676
|
-
|
|
16723
|
+
const { elements } = useElements({
|
|
16724
|
+
elements: filter.elements,
|
|
16725
|
+
getElements: filter.getElements
|
|
16726
|
+
});
|
|
16727
|
+
if (elements.length > 0) {
|
|
16728
|
+
activeElements = elements.filter((element) => {
|
|
16677
16729
|
if (filter.singleSelection) {
|
|
16678
16730
|
return element.value === filterInView?.value;
|
|
16679
16731
|
}
|
|
@@ -16785,13 +16837,13 @@ function Filter({
|
|
|
16785
16837
|
renderContent: () => {
|
|
16786
16838
|
return /* @__PURE__ */ jsxs13(component_default14, { spacing: 0, justify: "flex-start", children: [
|
|
16787
16839
|
/* @__PURE__ */ jsx53(OperatorSelector, { ...commonProps }),
|
|
16788
|
-
commonProps.filter.
|
|
16840
|
+
commonProps.filter.hasElements ? /* @__PURE__ */ jsx53(
|
|
16789
16841
|
SearchWidget,
|
|
16790
16842
|
{
|
|
16791
16843
|
...commonProps,
|
|
16792
16844
|
filter: {
|
|
16793
16845
|
...commonProps.filter,
|
|
16794
|
-
elements
|
|
16846
|
+
elements
|
|
16795
16847
|
}
|
|
16796
16848
|
}
|
|
16797
16849
|
) : /* @__PURE__ */ jsx53(InputWidget, { ...commonProps, fields })
|
|
@@ -16909,7 +16961,7 @@ function useFilters(fields, view) {
|
|
|
16909
16961
|
return useMemo(() => {
|
|
16910
16962
|
const filters = [];
|
|
16911
16963
|
fields.forEach((field) => {
|
|
16912
|
-
if (field.filterBy === false || !field.
|
|
16964
|
+
if (field.filterBy === false || !field.hasElements && !field.Edit) {
|
|
16913
16965
|
return;
|
|
16914
16966
|
}
|
|
16915
16967
|
const operators = field.filterBy.operators;
|
|
@@ -16920,7 +16972,9 @@ function useFilters(fields, view) {
|
|
|
16920
16972
|
filters.push({
|
|
16921
16973
|
field: field.id,
|
|
16922
16974
|
name: field.label,
|
|
16923
|
-
elements: field.elements
|
|
16975
|
+
elements: field.elements,
|
|
16976
|
+
getElements: field.getElements,
|
|
16977
|
+
hasElements: field.hasElements,
|
|
16924
16978
|
singleSelection: operators.some(
|
|
16925
16979
|
(op) => SINGLE_SELECTION_OPERATORS.includes(op)
|
|
16926
16980
|
),
|
|
@@ -17162,13 +17216,13 @@ function DataViewsLayout({ className }) {
|
|
|
17162
17216
|
|
|
17163
17217
|
// src/components/dataviews-footer/index.tsx
|
|
17164
17218
|
import { jsx as jsx60, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
17165
|
-
var
|
|
17219
|
+
var EMPTY_ARRAY5 = [];
|
|
17166
17220
|
function DataViewsFooter() {
|
|
17167
17221
|
const {
|
|
17168
17222
|
view,
|
|
17169
17223
|
paginationInfo: { totalItems = 0, totalPages },
|
|
17170
17224
|
data,
|
|
17171
|
-
actions =
|
|
17225
|
+
actions = EMPTY_ARRAY5
|
|
17172
17226
|
} = useContext(dataviews_context_default);
|
|
17173
17227
|
const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
|
|
17174
17228
|
if (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions) {
|
|
@@ -17936,16 +17990,27 @@ var dataviews_view_config_default = DataViewsViewConfig;
|
|
|
17936
17990
|
// src/field-types/email.tsx
|
|
17937
17991
|
import { __ as __37 } from "@wordpress/i18n";
|
|
17938
17992
|
|
|
17939
|
-
// src/field-types/utils/render-from-elements.
|
|
17940
|
-
function
|
|
17993
|
+
// src/field-types/utils/render-from-elements.tsx
|
|
17994
|
+
function RenderFromElements({
|
|
17941
17995
|
item: item2,
|
|
17942
17996
|
field
|
|
17943
17997
|
}) {
|
|
17998
|
+
const { elements, isLoading } = useElements({
|
|
17999
|
+
elements: field.elements,
|
|
18000
|
+
getElements: field.getElements
|
|
18001
|
+
});
|
|
17944
18002
|
const value = field.getValue({ item: item2 });
|
|
17945
|
-
|
|
18003
|
+
if (isLoading) {
|
|
18004
|
+
return value;
|
|
18005
|
+
}
|
|
18006
|
+
if (elements.length === 0) {
|
|
18007
|
+
return value;
|
|
18008
|
+
}
|
|
18009
|
+
return elements?.find((element) => element.value === value)?.label || field.getValue({ item: item2 });
|
|
17946
18010
|
}
|
|
17947
18011
|
|
|
17948
18012
|
// src/field-types/email.tsx
|
|
18013
|
+
import { jsx as jsx64 } from "react/jsx-runtime";
|
|
17949
18014
|
function sort(valueA, valueB, direction) {
|
|
17950
18015
|
return direction === "asc" ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
|
|
17951
18016
|
}
|
|
@@ -17964,7 +18029,7 @@ var email_default = {
|
|
|
17964
18029
|
},
|
|
17965
18030
|
Edit: "email",
|
|
17966
18031
|
render: ({ item: item2, field }) => {
|
|
17967
|
-
return field.
|
|
18032
|
+
return field.hasElements ? /* @__PURE__ */ jsx64(RenderFromElements, { item: item2, field }) : field.getValue({ item: item2 });
|
|
17968
18033
|
},
|
|
17969
18034
|
enableSorting: true,
|
|
17970
18035
|
filterBy: {
|
|
@@ -17986,6 +18051,7 @@ var email_default = {
|
|
|
17986
18051
|
|
|
17987
18052
|
// src/field-types/integer.tsx
|
|
17988
18053
|
import { __ as __38 } from "@wordpress/i18n";
|
|
18054
|
+
import { jsx as jsx65 } from "react/jsx-runtime";
|
|
17989
18055
|
function sort2(a, b, direction) {
|
|
17990
18056
|
return direction === "asc" ? a - b : b - a;
|
|
17991
18057
|
}
|
|
@@ -18003,7 +18069,7 @@ var integer_default = {
|
|
|
18003
18069
|
},
|
|
18004
18070
|
Edit: "integer",
|
|
18005
18071
|
render: ({ item: item2, field }) => {
|
|
18006
|
-
return field.
|
|
18072
|
+
return field.hasElements ? /* @__PURE__ */ jsx65(RenderFromElements, { item: item2, field }) : field.getValue({ item: item2 });
|
|
18007
18073
|
},
|
|
18008
18074
|
enableSorting: true,
|
|
18009
18075
|
filterBy: {
|
|
@@ -18036,6 +18102,7 @@ var integer_default = {
|
|
|
18036
18102
|
|
|
18037
18103
|
// src/field-types/number.tsx
|
|
18038
18104
|
import { __ as __39 } from "@wordpress/i18n";
|
|
18105
|
+
import { jsx as jsx66 } from "react/jsx-runtime";
|
|
18039
18106
|
function sort3(a, b, direction) {
|
|
18040
18107
|
return direction === "asc" ? a - b : b - a;
|
|
18041
18108
|
}
|
|
@@ -18056,17 +18123,14 @@ var number_default = {
|
|
|
18056
18123
|
},
|
|
18057
18124
|
Edit: "number",
|
|
18058
18125
|
render: ({ item: item2, field }) => {
|
|
18126
|
+
if (field.hasElements) {
|
|
18127
|
+
/* @__PURE__ */ jsx66(RenderFromElements, { item: item2, field });
|
|
18128
|
+
}
|
|
18059
18129
|
const value = field.getValue({ item: item2 });
|
|
18060
|
-
if (!
|
|
18061
|
-
|
|
18062
|
-
const match = field.elements.find(
|
|
18063
|
-
(element) => Number.isFinite(Number(element.value)) && Number(element.value) === numericValue
|
|
18064
|
-
);
|
|
18065
|
-
if (match) {
|
|
18066
|
-
return match.label;
|
|
18067
|
-
}
|
|
18130
|
+
if (![null, void 0].includes(value)) {
|
|
18131
|
+
return Number(value).toFixed(2);
|
|
18068
18132
|
}
|
|
18069
|
-
return
|
|
18133
|
+
return null;
|
|
18070
18134
|
},
|
|
18071
18135
|
enableSorting: true,
|
|
18072
18136
|
filterBy: {
|
|
@@ -18098,6 +18162,7 @@ var number_default = {
|
|
|
18098
18162
|
};
|
|
18099
18163
|
|
|
18100
18164
|
// src/field-types/text.tsx
|
|
18165
|
+
import { jsx as jsx67 } from "react/jsx-runtime";
|
|
18101
18166
|
function sort4(valueA, valueB, direction) {
|
|
18102
18167
|
return direction === "asc" ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
|
|
18103
18168
|
}
|
|
@@ -18109,7 +18174,7 @@ var text_default = {
|
|
|
18109
18174
|
},
|
|
18110
18175
|
Edit: "text",
|
|
18111
18176
|
render: ({ item: item2, field }) => {
|
|
18112
|
-
return field.
|
|
18177
|
+
return field.hasElements ? /* @__PURE__ */ jsx67(RenderFromElements, { item: item2, field }) : field.getValue({ item: item2 });
|
|
18113
18178
|
},
|
|
18114
18179
|
enableSorting: true,
|
|
18115
18180
|
filterBy: {
|
|
@@ -18131,6 +18196,7 @@ var text_default = {
|
|
|
18131
18196
|
};
|
|
18132
18197
|
|
|
18133
18198
|
// src/field-types/datetime.tsx
|
|
18199
|
+
import { jsx as jsx68 } from "react/jsx-runtime";
|
|
18134
18200
|
function sort5(a, b, direction) {
|
|
18135
18201
|
const timeA = new Date(a).getTime();
|
|
18136
18202
|
const timeB = new Date(b).getTime();
|
|
@@ -18144,7 +18210,7 @@ var datetime_default = {
|
|
|
18144
18210
|
},
|
|
18145
18211
|
Edit: "datetime",
|
|
18146
18212
|
render: ({ item: item2, field }) => {
|
|
18147
|
-
return field.
|
|
18213
|
+
return field.hasElements ? /* @__PURE__ */ jsx68(RenderFromElements, { item: item2, field }) : field.getValue({ item: item2 });
|
|
18148
18214
|
},
|
|
18149
18215
|
enableSorting: true,
|
|
18150
18216
|
filterBy: {
|
|
@@ -18173,6 +18239,7 @@ var datetime_default = {
|
|
|
18173
18239
|
|
|
18174
18240
|
// src/field-types/date.tsx
|
|
18175
18241
|
import { dateI18n, getDate, getSettings } from "@wordpress/date";
|
|
18242
|
+
import { jsx as jsx69 } from "react/jsx-runtime";
|
|
18176
18243
|
var getFormattedDate = (dateToDisplay) => dateI18n(getSettings().formats.date, getDate(dateToDisplay));
|
|
18177
18244
|
function sort6(a, b, direction) {
|
|
18178
18245
|
const timeA = new Date(a).getTime();
|
|
@@ -18187,8 +18254,8 @@ var date_default = {
|
|
|
18187
18254
|
custom: () => null
|
|
18188
18255
|
},
|
|
18189
18256
|
render: ({ item: item2, field }) => {
|
|
18190
|
-
if (field.
|
|
18191
|
-
return
|
|
18257
|
+
if (field.hasElements) {
|
|
18258
|
+
return /* @__PURE__ */ jsx69(RenderFromElements, { item: item2, field });
|
|
18192
18259
|
}
|
|
18193
18260
|
const value = field.getValue({ item: item2 });
|
|
18194
18261
|
if (!value) {
|
|
@@ -18225,6 +18292,7 @@ var date_default = {
|
|
|
18225
18292
|
|
|
18226
18293
|
// src/field-types/boolean.tsx
|
|
18227
18294
|
import { __ as __40 } from "@wordpress/i18n";
|
|
18295
|
+
import { jsx as jsx70 } from "react/jsx-runtime";
|
|
18228
18296
|
function sort7(a, b, direction) {
|
|
18229
18297
|
const boolA = Boolean(a);
|
|
18230
18298
|
const boolB = Boolean(b);
|
|
@@ -18250,8 +18318,8 @@ var boolean_default = {
|
|
|
18250
18318
|
},
|
|
18251
18319
|
Edit: "checkbox",
|
|
18252
18320
|
render: ({ item: item2, field }) => {
|
|
18253
|
-
if (field.
|
|
18254
|
-
return
|
|
18321
|
+
if (field.hasElements) {
|
|
18322
|
+
return /* @__PURE__ */ jsx70(RenderFromElements, { item: item2, field });
|
|
18255
18323
|
}
|
|
18256
18324
|
if (field.getValue({ item: item2 }) === true) {
|
|
18257
18325
|
return __40("True");
|
|
@@ -18332,6 +18400,7 @@ var arrayFieldType = {
|
|
|
18332
18400
|
var array_default = arrayFieldType;
|
|
18333
18401
|
|
|
18334
18402
|
// src/field-types/password.tsx
|
|
18403
|
+
import { jsx as jsx71 } from "react/jsx-runtime";
|
|
18335
18404
|
function sort10(valueA, valueB, direction) {
|
|
18336
18405
|
return 0;
|
|
18337
18406
|
}
|
|
@@ -18343,13 +18412,14 @@ var password_default = {
|
|
|
18343
18412
|
},
|
|
18344
18413
|
Edit: "password",
|
|
18345
18414
|
render: ({ item: item2, field }) => {
|
|
18346
|
-
return field.
|
|
18415
|
+
return field.hasElements ? /* @__PURE__ */ jsx71(RenderFromElements, { item: item2, field }) : "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
|
|
18347
18416
|
},
|
|
18348
18417
|
enableSorting: false,
|
|
18349
18418
|
filterBy: false
|
|
18350
18419
|
};
|
|
18351
18420
|
|
|
18352
18421
|
// src/field-types/telephone.tsx
|
|
18422
|
+
import { jsx as jsx72 } from "react/jsx-runtime";
|
|
18353
18423
|
function sort11(valueA, valueB, direction) {
|
|
18354
18424
|
return direction === "asc" ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
|
|
18355
18425
|
}
|
|
@@ -18361,7 +18431,7 @@ var telephone_default = {
|
|
|
18361
18431
|
},
|
|
18362
18432
|
Edit: "telephone",
|
|
18363
18433
|
render: ({ item: item2, field }) => {
|
|
18364
|
-
return field.
|
|
18434
|
+
return field.hasElements ? /* @__PURE__ */ jsx72(RenderFromElements, { item: item2, field }) : field.getValue({ item: item2 });
|
|
18365
18435
|
},
|
|
18366
18436
|
enableSorting: true,
|
|
18367
18437
|
filterBy: {
|
|
@@ -18384,7 +18454,7 @@ var telephone_default = {
|
|
|
18384
18454
|
// src/field-types/color.tsx
|
|
18385
18455
|
import { colord as colord4 } from "colord";
|
|
18386
18456
|
import { __ as __42 } from "@wordpress/i18n";
|
|
18387
|
-
import { jsx as
|
|
18457
|
+
import { jsx as jsx73, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
18388
18458
|
function sort12(valueA, valueB, direction) {
|
|
18389
18459
|
const colorA = colord4(valueA);
|
|
18390
18460
|
const colorB = colord4(valueB);
|
|
@@ -18421,8 +18491,8 @@ var color_default = {
|
|
|
18421
18491
|
},
|
|
18422
18492
|
Edit: "color",
|
|
18423
18493
|
render: ({ item: item2, field }) => {
|
|
18424
|
-
if (field.
|
|
18425
|
-
return
|
|
18494
|
+
if (field.hasElements) {
|
|
18495
|
+
return /* @__PURE__ */ jsx73(RenderFromElements, { item: item2, field });
|
|
18426
18496
|
}
|
|
18427
18497
|
const value = field.getValue({ item: item2 });
|
|
18428
18498
|
if (!value || !colord4(value).isValid()) {
|
|
@@ -18433,7 +18503,7 @@ var color_default = {
|
|
|
18433
18503
|
{
|
|
18434
18504
|
style: { display: "flex", alignItems: "center", gap: "8px" },
|
|
18435
18505
|
children: [
|
|
18436
|
-
/* @__PURE__ */
|
|
18506
|
+
/* @__PURE__ */ jsx73(
|
|
18437
18507
|
"div",
|
|
18438
18508
|
{
|
|
18439
18509
|
style: {
|
|
@@ -18446,7 +18516,7 @@ var color_default = {
|
|
|
18446
18516
|
}
|
|
18447
18517
|
}
|
|
18448
18518
|
),
|
|
18449
|
-
/* @__PURE__ */
|
|
18519
|
+
/* @__PURE__ */ jsx73("span", { children: value })
|
|
18450
18520
|
]
|
|
18451
18521
|
}
|
|
18452
18522
|
);
|
|
@@ -18459,6 +18529,7 @@ var color_default = {
|
|
|
18459
18529
|
};
|
|
18460
18530
|
|
|
18461
18531
|
// src/field-types/url.tsx
|
|
18532
|
+
import { jsx as jsx74 } from "react/jsx-runtime";
|
|
18462
18533
|
function sort13(valueA, valueB, direction) {
|
|
18463
18534
|
return direction === "asc" ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
|
|
18464
18535
|
}
|
|
@@ -18470,7 +18541,7 @@ var url_default = {
|
|
|
18470
18541
|
},
|
|
18471
18542
|
Edit: "url",
|
|
18472
18543
|
render: ({ item: item2, field }) => {
|
|
18473
|
-
return field.
|
|
18544
|
+
return field.hasElements ? /* @__PURE__ */ jsx74(RenderFromElements, { item: item2, field }) : field.getValue({ item: item2 });
|
|
18474
18545
|
},
|
|
18475
18546
|
enableSorting: true,
|
|
18476
18547
|
filterBy: {
|
|
@@ -18491,6 +18562,7 @@ var url_default = {
|
|
|
18491
18562
|
};
|
|
18492
18563
|
|
|
18493
18564
|
// src/field-types/index.tsx
|
|
18565
|
+
import { jsx as jsx75 } from "react/jsx-runtime";
|
|
18494
18566
|
function getFieldTypeDefinition(type) {
|
|
18495
18567
|
if ("email" === type) {
|
|
18496
18568
|
return email_default;
|
|
@@ -18544,7 +18616,7 @@ function getFieldTypeDefinition(type) {
|
|
|
18544
18616
|
},
|
|
18545
18617
|
Edit: null,
|
|
18546
18618
|
render: ({ item: item2, field }) => {
|
|
18547
|
-
return field.
|
|
18619
|
+
return field.hasElements ? /* @__PURE__ */ jsx75(RenderFromElements, { item: item2, field }) : field.getValue({ item: item2 });
|
|
18548
18620
|
},
|
|
18549
18621
|
enableSorting: true,
|
|
18550
18622
|
filterBy: {
|
|
@@ -18554,52 +18626,40 @@ function getFieldTypeDefinition(type) {
|
|
|
18554
18626
|
};
|
|
18555
18627
|
}
|
|
18556
18628
|
|
|
18629
|
+
// src/dataform-controls/utils/get-custom-validity.ts
|
|
18630
|
+
function getCustomValidity(isValid, validity) {
|
|
18631
|
+
let customValidity;
|
|
18632
|
+
if (isValid?.required && validity?.required) {
|
|
18633
|
+
customValidity = validity?.required?.message ? validity.required : void 0;
|
|
18634
|
+
} else if (isValid?.elements && validity?.elements) {
|
|
18635
|
+
customValidity = validity.elements;
|
|
18636
|
+
} else if (validity?.custom) {
|
|
18637
|
+
customValidity = validity.custom;
|
|
18638
|
+
}
|
|
18639
|
+
return customValidity;
|
|
18640
|
+
}
|
|
18641
|
+
|
|
18557
18642
|
// src/dataform-controls/checkbox.tsx
|
|
18558
|
-
import
|
|
18559
|
-
import { jsx as jsx65 } from "react/jsx-runtime";
|
|
18643
|
+
import { jsx as jsx76 } from "react/jsx-runtime";
|
|
18560
18644
|
var { ValidatedCheckboxControl: ValidatedCheckboxControl2 } = unlock3(privateApis);
|
|
18561
18645
|
function Checkbox({
|
|
18562
18646
|
field,
|
|
18563
18647
|
onChange,
|
|
18564
18648
|
data,
|
|
18565
|
-
hideLabelFromVision
|
|
18649
|
+
hideLabelFromVision,
|
|
18650
|
+
validity
|
|
18566
18651
|
}) {
|
|
18567
|
-
const { getValue, setValue, label, description } = field;
|
|
18568
|
-
const [customValidity, setCustomValidity] = useState(void 0);
|
|
18652
|
+
const { getValue, setValue, label, description, isValid } = field;
|
|
18569
18653
|
const onChangeControl = useCallback(() => {
|
|
18570
18654
|
onChange(
|
|
18571
18655
|
setValue({ item: data, value: !getValue({ item: data }) })
|
|
18572
18656
|
);
|
|
18573
18657
|
}, [data, getValue, onChange, setValue]);
|
|
18574
|
-
|
|
18575
|
-
(newValue) => {
|
|
18576
|
-
const message = field.isValid?.custom?.(
|
|
18577
|
-
deepMerge(
|
|
18578
|
-
data,
|
|
18579
|
-
setValue({
|
|
18580
|
-
item: data,
|
|
18581
|
-
value: newValue
|
|
18582
|
-
})
|
|
18583
|
-
),
|
|
18584
|
-
field
|
|
18585
|
-
);
|
|
18586
|
-
if (message) {
|
|
18587
|
-
setCustomValidity({
|
|
18588
|
-
type: "invalid",
|
|
18589
|
-
message
|
|
18590
|
-
});
|
|
18591
|
-
return;
|
|
18592
|
-
}
|
|
18593
|
-
setCustomValidity(void 0);
|
|
18594
|
-
},
|
|
18595
|
-
[data, field, setValue]
|
|
18596
|
-
);
|
|
18597
|
-
return /* @__PURE__ */ jsx65(
|
|
18658
|
+
return /* @__PURE__ */ jsx76(
|
|
18598
18659
|
ValidatedCheckboxControl2,
|
|
18599
18660
|
{
|
|
18600
18661
|
required: !!field.isValid?.required,
|
|
18601
|
-
|
|
18602
|
-
customValidity,
|
|
18662
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
18603
18663
|
hidden: hideLabelFromVision,
|
|
18604
18664
|
label,
|
|
18605
18665
|
help: description,
|
|
@@ -18610,15 +18670,14 @@ function Checkbox({
|
|
|
18610
18670
|
}
|
|
18611
18671
|
|
|
18612
18672
|
// src/dataform-controls/datetime.tsx
|
|
18613
|
-
import
|
|
18614
|
-
import { format, isValid } from "date-fns";
|
|
18673
|
+
import { format, isValid as isValidDate } from "date-fns";
|
|
18615
18674
|
import { __ as __44 } from "@wordpress/i18n";
|
|
18616
18675
|
import { getDate as getDate2, getSettings as getSettings2 } from "@wordpress/date";
|
|
18617
18676
|
|
|
18618
18677
|
// src/dataform-controls/utils/relative-date-control.tsx
|
|
18619
18678
|
import clsx37 from "clsx";
|
|
18620
18679
|
import { __ as __43 } from "@wordpress/i18n";
|
|
18621
|
-
import { jsx as
|
|
18680
|
+
import { jsx as jsx77, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
18622
18681
|
var TIME_UNITS_OPTIONS = {
|
|
18623
18682
|
[OPERATOR_IN_THE_PAST]: [
|
|
18624
18683
|
{ value: "days", label: __43("Days") },
|
|
@@ -18663,7 +18722,7 @@ function RelativeDateControl({
|
|
|
18663
18722
|
),
|
|
18664
18723
|
[onChange, setValue, data, relValue]
|
|
18665
18724
|
);
|
|
18666
|
-
return /* @__PURE__ */
|
|
18725
|
+
return /* @__PURE__ */ jsx77(
|
|
18667
18726
|
base_control_default,
|
|
18668
18727
|
{
|
|
18669
18728
|
id,
|
|
@@ -18672,7 +18731,7 @@ function RelativeDateControl({
|
|
|
18672
18731
|
label,
|
|
18673
18732
|
hideLabelFromVision,
|
|
18674
18733
|
children: /* @__PURE__ */ jsxs19(component_default9, { spacing: 2.5, children: [
|
|
18675
|
-
/* @__PURE__ */
|
|
18734
|
+
/* @__PURE__ */ jsx77(
|
|
18676
18735
|
number_control_default,
|
|
18677
18736
|
{
|
|
18678
18737
|
__next40pxDefaultSize: true,
|
|
@@ -18684,7 +18743,7 @@ function RelativeDateControl({
|
|
|
18684
18743
|
onChange: onChangeValue
|
|
18685
18744
|
}
|
|
18686
18745
|
),
|
|
18687
|
-
/* @__PURE__ */
|
|
18746
|
+
/* @__PURE__ */ jsx77(
|
|
18688
18747
|
select_control_default,
|
|
18689
18748
|
{
|
|
18690
18749
|
className: "dataviews-controls__relative-date-unit",
|
|
@@ -18703,14 +18762,14 @@ function RelativeDateControl({
|
|
|
18703
18762
|
}
|
|
18704
18763
|
|
|
18705
18764
|
// src/dataform-controls/datetime.tsx
|
|
18706
|
-
import { jsx as
|
|
18765
|
+
import { jsx as jsx78, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
18707
18766
|
var { DateCalendar: DateCalendar2, ValidatedInputControl: ValidatedInputControl2 } = unlock3(privateApis);
|
|
18708
18767
|
var parseDateTime = (dateTimeString) => {
|
|
18709
18768
|
if (!dateTimeString) {
|
|
18710
18769
|
return null;
|
|
18711
18770
|
}
|
|
18712
18771
|
const parsed = getDate2(dateTimeString);
|
|
18713
|
-
return parsed &&
|
|
18772
|
+
return parsed && isValidDate(parsed) ? parsed : null;
|
|
18714
18773
|
};
|
|
18715
18774
|
var formatDateTime = (date) => {
|
|
18716
18775
|
if (!date) {
|
|
@@ -18725,16 +18784,16 @@ function CalendarDateTimeControl({
|
|
|
18725
18784
|
data,
|
|
18726
18785
|
field,
|
|
18727
18786
|
onChange,
|
|
18728
|
-
hideLabelFromVision
|
|
18787
|
+
hideLabelFromVision,
|
|
18788
|
+
validity
|
|
18729
18789
|
}) {
|
|
18730
|
-
const { id, label, description, setValue, getValue } = field;
|
|
18790
|
+
const { id, label, description, setValue, getValue, isValid } = field;
|
|
18731
18791
|
const fieldValue = getValue({ item: data });
|
|
18732
18792
|
const value = typeof fieldValue === "string" ? fieldValue : void 0;
|
|
18733
18793
|
const [calendarMonth, setCalendarMonth] = useState(() => {
|
|
18734
18794
|
const parsedDate = parseDateTime(value);
|
|
18735
18795
|
return parsedDate || /* @__PURE__ */ new Date();
|
|
18736
18796
|
});
|
|
18737
|
-
const [customValidity, setCustomValidity] = useState(void 0);
|
|
18738
18797
|
const inputControlRef = useRef(null);
|
|
18739
18798
|
const validationTimeoutRef = useRef();
|
|
18740
18799
|
const previousFocusRef = useRef(null);
|
|
@@ -18749,29 +18808,6 @@ function CalendarDateTimeControl({
|
|
|
18749
18808
|
}
|
|
18750
18809
|
};
|
|
18751
18810
|
}, []);
|
|
18752
|
-
const onValidateControl = useCallback(
|
|
18753
|
-
(newValue) => {
|
|
18754
|
-
const message = field.isValid?.custom?.(
|
|
18755
|
-
deepMerge2(
|
|
18756
|
-
data,
|
|
18757
|
-
setValue({
|
|
18758
|
-
item: data,
|
|
18759
|
-
value: newValue
|
|
18760
|
-
})
|
|
18761
|
-
),
|
|
18762
|
-
field
|
|
18763
|
-
);
|
|
18764
|
-
if (message) {
|
|
18765
|
-
setCustomValidity({
|
|
18766
|
-
type: "invalid",
|
|
18767
|
-
message
|
|
18768
|
-
});
|
|
18769
|
-
return;
|
|
18770
|
-
}
|
|
18771
|
-
setCustomValidity(void 0);
|
|
18772
|
-
},
|
|
18773
|
-
[data, field, setValue]
|
|
18774
|
-
);
|
|
18775
18811
|
const onSelectDate = useCallback(
|
|
18776
18812
|
(newDate) => {
|
|
18777
18813
|
let dateTimeValue;
|
|
@@ -18789,13 +18825,11 @@ function CalendarDateTimeControl({
|
|
|
18789
18825
|
}
|
|
18790
18826
|
dateTimeValue = finalDateTime.toISOString();
|
|
18791
18827
|
onChangeCallback(dateTimeValue);
|
|
18792
|
-
onValidateControl(dateTimeValue);
|
|
18793
18828
|
if (validationTimeoutRef.current) {
|
|
18794
18829
|
clearTimeout(validationTimeoutRef.current);
|
|
18795
18830
|
}
|
|
18796
18831
|
} else {
|
|
18797
18832
|
onChangeCallback(void 0);
|
|
18798
|
-
onValidateControl(void 0);
|
|
18799
18833
|
}
|
|
18800
18834
|
previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
|
|
18801
18835
|
validationTimeoutRef.current = setTimeout(() => {
|
|
@@ -18803,14 +18837,13 @@ function CalendarDateTimeControl({
|
|
|
18803
18837
|
inputControlRef.current.focus();
|
|
18804
18838
|
inputControlRef.current.blur();
|
|
18805
18839
|
onChangeCallback(dateTimeValue);
|
|
18806
|
-
onValidateControl(dateTimeValue);
|
|
18807
18840
|
if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
|
|
18808
18841
|
previousFocusRef.current.focus();
|
|
18809
18842
|
}
|
|
18810
18843
|
}
|
|
18811
18844
|
}, 0);
|
|
18812
18845
|
},
|
|
18813
|
-
[onChangeCallback, value
|
|
18846
|
+
[onChangeCallback, value]
|
|
18814
18847
|
);
|
|
18815
18848
|
const handleManualDateTimeChange = useCallback(
|
|
18816
18849
|
(newValue) => {
|
|
@@ -18831,8 +18864,8 @@ function CalendarDateTimeControl({
|
|
|
18831
18864
|
timezone: { string: timezoneString },
|
|
18832
18865
|
l10n: { startOfWeek }
|
|
18833
18866
|
} = getSettings2();
|
|
18834
|
-
const displayLabel =
|
|
18835
|
-
return /* @__PURE__ */
|
|
18867
|
+
const displayLabel = isValid?.required && !hideLabelFromVision ? `${label} (${__44("Required")})` : label;
|
|
18868
|
+
return /* @__PURE__ */ jsx78(
|
|
18836
18869
|
base_control_default,
|
|
18837
18870
|
{
|
|
18838
18871
|
__nextHasNoMarginBottom: true,
|
|
@@ -18841,7 +18874,7 @@ function CalendarDateTimeControl({
|
|
|
18841
18874
|
help: description,
|
|
18842
18875
|
hideLabelFromVision,
|
|
18843
18876
|
children: /* @__PURE__ */ jsxs20(component_default14, { spacing: 4, children: [
|
|
18844
|
-
/* @__PURE__ */
|
|
18877
|
+
/* @__PURE__ */ jsx78(
|
|
18845
18878
|
DateCalendar2,
|
|
18846
18879
|
{
|
|
18847
18880
|
style: { width: "100%" },
|
|
@@ -18853,14 +18886,13 @@ function CalendarDateTimeControl({
|
|
|
18853
18886
|
weekStartsOn: startOfWeek
|
|
18854
18887
|
}
|
|
18855
18888
|
),
|
|
18856
|
-
/* @__PURE__ */
|
|
18889
|
+
/* @__PURE__ */ jsx78(
|
|
18857
18890
|
ValidatedInputControl2,
|
|
18858
18891
|
{
|
|
18859
18892
|
ref: inputControlRef,
|
|
18860
18893
|
__next40pxDefaultSize: true,
|
|
18861
|
-
required: !!
|
|
18862
|
-
|
|
18863
|
-
customValidity,
|
|
18894
|
+
required: !!isValid?.required,
|
|
18895
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
18864
18896
|
type: "datetime-local",
|
|
18865
18897
|
label: __44("Date time"),
|
|
18866
18898
|
hideLabelFromVision: true,
|
|
@@ -18879,10 +18911,11 @@ function DateTime({
|
|
|
18879
18911
|
field,
|
|
18880
18912
|
onChange,
|
|
18881
18913
|
hideLabelFromVision,
|
|
18882
|
-
operator
|
|
18914
|
+
operator,
|
|
18915
|
+
validity
|
|
18883
18916
|
}) {
|
|
18884
18917
|
if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
|
|
18885
|
-
return /* @__PURE__ */
|
|
18918
|
+
return /* @__PURE__ */ jsx78(
|
|
18886
18919
|
RelativeDateControl,
|
|
18887
18920
|
{
|
|
18888
18921
|
className: "dataviews-controls__datetime",
|
|
@@ -18894,32 +18927,32 @@ function DateTime({
|
|
|
18894
18927
|
}
|
|
18895
18928
|
);
|
|
18896
18929
|
}
|
|
18897
|
-
return /* @__PURE__ */
|
|
18930
|
+
return /* @__PURE__ */ jsx78(
|
|
18898
18931
|
CalendarDateTimeControl,
|
|
18899
18932
|
{
|
|
18900
18933
|
data,
|
|
18901
18934
|
field,
|
|
18902
18935
|
onChange,
|
|
18903
|
-
hideLabelFromVision
|
|
18936
|
+
hideLabelFromVision,
|
|
18937
|
+
validity
|
|
18904
18938
|
}
|
|
18905
18939
|
);
|
|
18906
18940
|
}
|
|
18907
18941
|
|
|
18908
18942
|
// src/dataform-controls/date.tsx
|
|
18909
|
-
import { __ as __45 } from "@wordpress/i18n";
|
|
18910
|
-
import { getDate as getDate3, getSettings as getSettings3 } from "@wordpress/date";
|
|
18911
18943
|
import clsx38 from "clsx";
|
|
18912
18944
|
import {
|
|
18913
18945
|
format as format2,
|
|
18914
|
-
isValid as
|
|
18946
|
+
isValid as isValidDate2,
|
|
18915
18947
|
subMonths,
|
|
18916
18948
|
subDays,
|
|
18917
18949
|
subYears,
|
|
18918
18950
|
startOfMonth,
|
|
18919
18951
|
startOfYear
|
|
18920
18952
|
} from "date-fns";
|
|
18921
|
-
import
|
|
18922
|
-
import {
|
|
18953
|
+
import { __ as __45 } from "@wordpress/i18n";
|
|
18954
|
+
import { getDate as getDate3, getSettings as getSettings3 } from "@wordpress/date";
|
|
18955
|
+
import { jsx as jsx79, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
18923
18956
|
var { DateCalendar: DateCalendar3, DateRangeCalendar: DateRangeCalendar2 } = unlock3(privateApis);
|
|
18924
18957
|
var DATE_PRESETS = [
|
|
18925
18958
|
{
|
|
@@ -18999,7 +19032,7 @@ var parseDate = (dateString) => {
|
|
|
18999
19032
|
return null;
|
|
19000
19033
|
}
|
|
19001
19034
|
const parsed = getDate3(dateString);
|
|
19002
|
-
return parsed &&
|
|
19035
|
+
return parsed && isValidDate2(parsed) ? parsed : null;
|
|
19003
19036
|
};
|
|
19004
19037
|
var formatDate = (date) => {
|
|
19005
19038
|
if (!date) {
|
|
@@ -19008,61 +19041,42 @@ var formatDate = (date) => {
|
|
|
19008
19041
|
return typeof date === "string" ? date : format2(date, "yyyy-MM-dd");
|
|
19009
19042
|
};
|
|
19010
19043
|
function ValidatedDateControl({
|
|
19011
|
-
value,
|
|
19012
19044
|
field,
|
|
19013
|
-
|
|
19014
|
-
setValue,
|
|
19045
|
+
validity,
|
|
19015
19046
|
inputRefs,
|
|
19016
19047
|
isTouched,
|
|
19017
19048
|
setIsTouched,
|
|
19018
19049
|
children
|
|
19019
19050
|
}) {
|
|
19051
|
+
const { isValid } = field;
|
|
19020
19052
|
const [customValidity, setCustomValidity] = useState(void 0);
|
|
19021
|
-
const
|
|
19022
|
-
(
|
|
19023
|
-
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
|
|
19027
|
-
|
|
19028
|
-
|
|
19029
|
-
|
|
19030
|
-
|
|
19031
|
-
),
|
|
19032
|
-
field
|
|
19033
|
-
);
|
|
19034
|
-
if (customMessage) {
|
|
19035
|
-
setCustomValidity({
|
|
19036
|
-
type: "invalid",
|
|
19037
|
-
message: customMessage
|
|
19038
|
-
});
|
|
19039
|
-
return;
|
|
19040
|
-
}
|
|
19041
|
-
}
|
|
19042
|
-
const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
|
|
19043
|
-
for (const ref of refs) {
|
|
19044
|
-
const input = ref.current;
|
|
19045
|
-
if (input && !input.validity.valid) {
|
|
19046
|
-
setCustomValidity({
|
|
19047
|
-
type: "invalid",
|
|
19048
|
-
message: input.validationMessage
|
|
19049
|
-
});
|
|
19050
|
-
return;
|
|
19051
|
-
}
|
|
19053
|
+
const validateRefs = useCallback(() => {
|
|
19054
|
+
const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
|
|
19055
|
+
for (const ref of refs) {
|
|
19056
|
+
const input = ref.current;
|
|
19057
|
+
if (input && !input.validity.valid) {
|
|
19058
|
+
setCustomValidity({
|
|
19059
|
+
type: "invalid",
|
|
19060
|
+
message: input.validationMessage
|
|
19061
|
+
});
|
|
19062
|
+
return;
|
|
19052
19063
|
}
|
|
19053
|
-
|
|
19054
|
-
|
|
19055
|
-
|
|
19056
|
-
);
|
|
19064
|
+
}
|
|
19065
|
+
setCustomValidity(void 0);
|
|
19066
|
+
}, [inputRefs]);
|
|
19057
19067
|
useEffect(() => {
|
|
19058
19068
|
if (isTouched) {
|
|
19059
19069
|
const timeoutId = setTimeout(() => {
|
|
19060
|
-
|
|
19070
|
+
if (validity) {
|
|
19071
|
+
setCustomValidity(getCustomValidity(isValid, validity));
|
|
19072
|
+
} else {
|
|
19073
|
+
validateRefs();
|
|
19074
|
+
}
|
|
19061
19075
|
}, 0);
|
|
19062
19076
|
return () => clearTimeout(timeoutId);
|
|
19063
19077
|
}
|
|
19064
19078
|
return void 0;
|
|
19065
|
-
}, [isTouched,
|
|
19079
|
+
}, [isTouched, isValid, validity, validateRefs]);
|
|
19066
19080
|
const onBlur = (event) => {
|
|
19067
19081
|
if (isTouched) {
|
|
19068
19082
|
return;
|
|
@@ -19073,15 +19087,16 @@ function ValidatedDateControl({
|
|
|
19073
19087
|
};
|
|
19074
19088
|
return /* @__PURE__ */ jsxs21("div", { onBlur, children: [
|
|
19075
19089
|
children,
|
|
19076
|
-
/* @__PURE__ */
|
|
19090
|
+
/* @__PURE__ */ jsx79("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ jsxs21(
|
|
19077
19091
|
"p",
|
|
19078
19092
|
{
|
|
19079
19093
|
className: clsx38(
|
|
19080
19094
|
"components-validated-control__indicator",
|
|
19081
|
-
"is-invalid"
|
|
19095
|
+
customValidity.type === "invalid" ? "is-invalid" : void 0,
|
|
19096
|
+
customValidity.type === "valid" ? "is-valid" : void 0
|
|
19082
19097
|
),
|
|
19083
19098
|
children: [
|
|
19084
|
-
/* @__PURE__ */
|
|
19099
|
+
/* @__PURE__ */ jsx79(
|
|
19085
19100
|
icon_default2,
|
|
19086
19101
|
{
|
|
19087
19102
|
className: "components-validated-control__indicator-icon",
|
|
@@ -19100,9 +19115,10 @@ function CalendarDateControl({
|
|
|
19100
19115
|
data,
|
|
19101
19116
|
field,
|
|
19102
19117
|
onChange,
|
|
19103
|
-
hideLabelFromVision
|
|
19118
|
+
hideLabelFromVision,
|
|
19119
|
+
validity
|
|
19104
19120
|
}) {
|
|
19105
|
-
const { id, label, setValue, getValue } = field;
|
|
19121
|
+
const { id, label, setValue, getValue, isValid } = field;
|
|
19106
19122
|
const [selectedPresetId, setSelectedPresetId] = useState(
|
|
19107
19123
|
null
|
|
19108
19124
|
);
|
|
@@ -19156,18 +19172,16 @@ function CalendarDateControl({
|
|
|
19156
19172
|
timezone: { string: timezoneString },
|
|
19157
19173
|
l10n: { startOfWeek }
|
|
19158
19174
|
} = getSettings3();
|
|
19159
|
-
const displayLabel =
|
|
19160
|
-
return /* @__PURE__ */
|
|
19175
|
+
const displayLabel = isValid?.required ? `${label} (${__45("Required")})` : label;
|
|
19176
|
+
return /* @__PURE__ */ jsx79(
|
|
19161
19177
|
ValidatedDateControl,
|
|
19162
19178
|
{
|
|
19163
|
-
value,
|
|
19164
19179
|
field,
|
|
19165
|
-
|
|
19166
|
-
setValue,
|
|
19180
|
+
validity,
|
|
19167
19181
|
inputRefs: validityTargetRef,
|
|
19168
19182
|
isTouched,
|
|
19169
19183
|
setIsTouched,
|
|
19170
|
-
children: /* @__PURE__ */
|
|
19184
|
+
children: /* @__PURE__ */ jsx79(
|
|
19171
19185
|
base_control_default,
|
|
19172
19186
|
{
|
|
19173
19187
|
__nextHasNoMarginBottom: true,
|
|
@@ -19179,7 +19193,7 @@ function CalendarDateControl({
|
|
|
19179
19193
|
/* @__PURE__ */ jsxs21(component_default9, { spacing: 2, wrap: true, justify: "flex-start", children: [
|
|
19180
19194
|
DATE_PRESETS.map((preset) => {
|
|
19181
19195
|
const isSelected = selectedPresetId === preset.id;
|
|
19182
|
-
return /* @__PURE__ */
|
|
19196
|
+
return /* @__PURE__ */ jsx79(
|
|
19183
19197
|
button_default,
|
|
19184
19198
|
{
|
|
19185
19199
|
className: "dataviews-controls__date-preset",
|
|
@@ -19192,7 +19206,7 @@ function CalendarDateControl({
|
|
|
19192
19206
|
preset.id
|
|
19193
19207
|
);
|
|
19194
19208
|
}),
|
|
19195
|
-
/* @__PURE__ */
|
|
19209
|
+
/* @__PURE__ */ jsx79(
|
|
19196
19210
|
button_default,
|
|
19197
19211
|
{
|
|
19198
19212
|
className: "dataviews-controls__date-preset",
|
|
@@ -19205,7 +19219,7 @@ function CalendarDateControl({
|
|
|
19205
19219
|
}
|
|
19206
19220
|
)
|
|
19207
19221
|
] }),
|
|
19208
|
-
/* @__PURE__ */
|
|
19222
|
+
/* @__PURE__ */ jsx79(
|
|
19209
19223
|
input_control_default,
|
|
19210
19224
|
{
|
|
19211
19225
|
__next40pxDefaultSize: true,
|
|
@@ -19218,7 +19232,7 @@ function CalendarDateControl({
|
|
|
19218
19232
|
required: !!field.isValid?.required
|
|
19219
19233
|
}
|
|
19220
19234
|
),
|
|
19221
|
-
/* @__PURE__ */
|
|
19235
|
+
/* @__PURE__ */ jsx79(
|
|
19222
19236
|
DateCalendar3,
|
|
19223
19237
|
{
|
|
19224
19238
|
style: { width: "100%" },
|
|
@@ -19240,7 +19254,8 @@ function CalendarDateRangeControl({
|
|
|
19240
19254
|
data,
|
|
19241
19255
|
field,
|
|
19242
19256
|
onChange,
|
|
19243
|
-
hideLabelFromVision
|
|
19257
|
+
hideLabelFromVision,
|
|
19258
|
+
validity
|
|
19244
19259
|
}) {
|
|
19245
19260
|
const { id, label, getValue, setValue } = field;
|
|
19246
19261
|
let value;
|
|
@@ -19331,17 +19346,15 @@ function CalendarDateRangeControl({
|
|
|
19331
19346
|
);
|
|
19332
19347
|
const { timezone, l10n } = getSettings3();
|
|
19333
19348
|
const displayLabel = field.isValid?.required ? `${label} (${__45("Required")})` : label;
|
|
19334
|
-
return /* @__PURE__ */
|
|
19349
|
+
return /* @__PURE__ */ jsx79(
|
|
19335
19350
|
ValidatedDateControl,
|
|
19336
19351
|
{
|
|
19337
|
-
value,
|
|
19338
19352
|
field,
|
|
19339
|
-
|
|
19340
|
-
setValue,
|
|
19353
|
+
validity,
|
|
19341
19354
|
inputRefs: [fromInputRef, toInputRef],
|
|
19342
19355
|
isTouched,
|
|
19343
19356
|
setIsTouched,
|
|
19344
|
-
children: /* @__PURE__ */
|
|
19357
|
+
children: /* @__PURE__ */ jsx79(
|
|
19345
19358
|
base_control_default,
|
|
19346
19359
|
{
|
|
19347
19360
|
__nextHasNoMarginBottom: true,
|
|
@@ -19353,7 +19366,7 @@ function CalendarDateRangeControl({
|
|
|
19353
19366
|
/* @__PURE__ */ jsxs21(component_default9, { spacing: 2, wrap: true, justify: "flex-start", children: [
|
|
19354
19367
|
DATE_RANGE_PRESETS.map((preset) => {
|
|
19355
19368
|
const isSelected = selectedPresetId === preset.id;
|
|
19356
|
-
return /* @__PURE__ */
|
|
19369
|
+
return /* @__PURE__ */ jsx79(
|
|
19357
19370
|
button_default,
|
|
19358
19371
|
{
|
|
19359
19372
|
className: "dataviews-controls__date-preset",
|
|
@@ -19366,7 +19379,7 @@ function CalendarDateRangeControl({
|
|
|
19366
19379
|
preset.id
|
|
19367
19380
|
);
|
|
19368
19381
|
}),
|
|
19369
|
-
/* @__PURE__ */
|
|
19382
|
+
/* @__PURE__ */ jsx79(
|
|
19370
19383
|
button_default,
|
|
19371
19384
|
{
|
|
19372
19385
|
className: "dataviews-controls__date-preset",
|
|
@@ -19380,7 +19393,7 @@ function CalendarDateRangeControl({
|
|
|
19380
19393
|
)
|
|
19381
19394
|
] }),
|
|
19382
19395
|
/* @__PURE__ */ jsxs21(component_default9, { spacing: 2, children: [
|
|
19383
|
-
/* @__PURE__ */
|
|
19396
|
+
/* @__PURE__ */ jsx79(
|
|
19384
19397
|
input_control_default,
|
|
19385
19398
|
{
|
|
19386
19399
|
__next40pxDefaultSize: true,
|
|
@@ -19393,7 +19406,7 @@ function CalendarDateRangeControl({
|
|
|
19393
19406
|
required: !!field.isValid?.required
|
|
19394
19407
|
}
|
|
19395
19408
|
),
|
|
19396
|
-
/* @__PURE__ */
|
|
19409
|
+
/* @__PURE__ */ jsx79(
|
|
19397
19410
|
input_control_default,
|
|
19398
19411
|
{
|
|
19399
19412
|
__next40pxDefaultSize: true,
|
|
@@ -19407,7 +19420,7 @@ function CalendarDateRangeControl({
|
|
|
19407
19420
|
}
|
|
19408
19421
|
)
|
|
19409
19422
|
] }),
|
|
19410
|
-
/* @__PURE__ */
|
|
19423
|
+
/* @__PURE__ */ jsx79(
|
|
19411
19424
|
DateRangeCalendar2,
|
|
19412
19425
|
{
|
|
19413
19426
|
style: { width: "100%" },
|
|
@@ -19430,10 +19443,11 @@ function DateControl({
|
|
|
19430
19443
|
field,
|
|
19431
19444
|
onChange,
|
|
19432
19445
|
hideLabelFromVision,
|
|
19433
|
-
operator
|
|
19446
|
+
operator,
|
|
19447
|
+
validity
|
|
19434
19448
|
}) {
|
|
19435
19449
|
if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
|
|
19436
|
-
return /* @__PURE__ */
|
|
19450
|
+
return /* @__PURE__ */ jsx79(
|
|
19437
19451
|
RelativeDateControl,
|
|
19438
19452
|
{
|
|
19439
19453
|
className: "dataviews-controls__date",
|
|
@@ -19446,30 +19460,31 @@ function DateControl({
|
|
|
19446
19460
|
);
|
|
19447
19461
|
}
|
|
19448
19462
|
if (operator === OPERATOR_BETWEEN) {
|
|
19449
|
-
return /* @__PURE__ */
|
|
19463
|
+
return /* @__PURE__ */ jsx79(
|
|
19450
19464
|
CalendarDateRangeControl,
|
|
19451
19465
|
{
|
|
19452
19466
|
data,
|
|
19453
19467
|
field,
|
|
19454
19468
|
onChange,
|
|
19455
|
-
hideLabelFromVision
|
|
19469
|
+
hideLabelFromVision,
|
|
19470
|
+
validity
|
|
19456
19471
|
}
|
|
19457
19472
|
);
|
|
19458
19473
|
}
|
|
19459
|
-
return /* @__PURE__ */
|
|
19474
|
+
return /* @__PURE__ */ jsx79(
|
|
19460
19475
|
CalendarDateControl,
|
|
19461
19476
|
{
|
|
19462
19477
|
data,
|
|
19463
19478
|
field,
|
|
19464
19479
|
onChange,
|
|
19465
|
-
hideLabelFromVision
|
|
19480
|
+
hideLabelFromVision,
|
|
19481
|
+
validity
|
|
19466
19482
|
}
|
|
19467
19483
|
);
|
|
19468
19484
|
}
|
|
19469
19485
|
|
|
19470
19486
|
// src/dataform-controls/utils/validated-input.tsx
|
|
19471
|
-
import
|
|
19472
|
-
import { jsx as jsx69 } from "react/jsx-runtime";
|
|
19487
|
+
import { jsx as jsx80 } from "react/jsx-runtime";
|
|
19473
19488
|
var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(privateApis);
|
|
19474
19489
|
function ValidatedText({
|
|
19475
19490
|
data,
|
|
@@ -19478,11 +19493,11 @@ function ValidatedText({
|
|
|
19478
19493
|
hideLabelFromVision,
|
|
19479
19494
|
type,
|
|
19480
19495
|
prefix,
|
|
19481
|
-
suffix
|
|
19496
|
+
suffix,
|
|
19497
|
+
validity
|
|
19482
19498
|
}) {
|
|
19483
|
-
const { label, placeholder, description, getValue, setValue, isValid
|
|
19499
|
+
const { label, placeholder, description, getValue, setValue, isValid } = field;
|
|
19484
19500
|
const value = getValue({ item: data });
|
|
19485
|
-
const [customValidity, setCustomValidity] = useState(void 0);
|
|
19486
19501
|
const onChangeControl = useCallback(
|
|
19487
19502
|
(newValue) => onChange(
|
|
19488
19503
|
setValue({
|
|
@@ -19492,35 +19507,11 @@ function ValidatedText({
|
|
|
19492
19507
|
),
|
|
19493
19508
|
[data, setValue, onChange]
|
|
19494
19509
|
);
|
|
19495
|
-
|
|
19496
|
-
(newValue) => {
|
|
19497
|
-
const message = isValid3?.custom?.(
|
|
19498
|
-
deepMerge4(
|
|
19499
|
-
data,
|
|
19500
|
-
setValue({
|
|
19501
|
-
item: data,
|
|
19502
|
-
value: newValue
|
|
19503
|
-
})
|
|
19504
|
-
),
|
|
19505
|
-
field
|
|
19506
|
-
);
|
|
19507
|
-
if (message) {
|
|
19508
|
-
setCustomValidity({
|
|
19509
|
-
type: "invalid",
|
|
19510
|
-
message
|
|
19511
|
-
});
|
|
19512
|
-
return;
|
|
19513
|
-
}
|
|
19514
|
-
setCustomValidity(void 0);
|
|
19515
|
-
},
|
|
19516
|
-
[data, field, isValid3, setValue]
|
|
19517
|
-
);
|
|
19518
|
-
return /* @__PURE__ */ jsx69(
|
|
19510
|
+
return /* @__PURE__ */ jsx80(
|
|
19519
19511
|
ValidatedInputControl3,
|
|
19520
19512
|
{
|
|
19521
|
-
required: !!
|
|
19522
|
-
|
|
19523
|
-
customValidity,
|
|
19513
|
+
required: !!isValid?.required,
|
|
19514
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
19524
19515
|
label,
|
|
19525
19516
|
placeholder,
|
|
19526
19517
|
value: value ?? "",
|
|
@@ -19536,14 +19527,15 @@ function ValidatedText({
|
|
|
19536
19527
|
}
|
|
19537
19528
|
|
|
19538
19529
|
// src/dataform-controls/email.tsx
|
|
19539
|
-
import { jsx as
|
|
19530
|
+
import { jsx as jsx81 } from "react/jsx-runtime";
|
|
19540
19531
|
function Email({
|
|
19541
19532
|
data,
|
|
19542
19533
|
field,
|
|
19543
19534
|
onChange,
|
|
19544
|
-
hideLabelFromVision
|
|
19535
|
+
hideLabelFromVision,
|
|
19536
|
+
validity
|
|
19545
19537
|
}) {
|
|
19546
|
-
return /* @__PURE__ */
|
|
19538
|
+
return /* @__PURE__ */ jsx81(
|
|
19547
19539
|
ValidatedText,
|
|
19548
19540
|
{
|
|
19549
19541
|
...{
|
|
@@ -19551,22 +19543,24 @@ function Email({
|
|
|
19551
19543
|
field,
|
|
19552
19544
|
onChange,
|
|
19553
19545
|
hideLabelFromVision,
|
|
19546
|
+
validity,
|
|
19554
19547
|
type: "email",
|
|
19555
|
-
prefix: /* @__PURE__ */
|
|
19548
|
+
prefix: /* @__PURE__ */ jsx81(input_prefix_wrapper_default, { variant: "icon", children: /* @__PURE__ */ jsx81(icon_default2, { icon: at_symbol_default }) })
|
|
19556
19549
|
}
|
|
19557
19550
|
}
|
|
19558
19551
|
);
|
|
19559
19552
|
}
|
|
19560
19553
|
|
|
19561
19554
|
// src/dataform-controls/telephone.tsx
|
|
19562
|
-
import { jsx as
|
|
19555
|
+
import { jsx as jsx82 } from "react/jsx-runtime";
|
|
19563
19556
|
function Telephone({
|
|
19564
19557
|
data,
|
|
19565
19558
|
field,
|
|
19566
19559
|
onChange,
|
|
19567
|
-
hideLabelFromVision
|
|
19560
|
+
hideLabelFromVision,
|
|
19561
|
+
validity
|
|
19568
19562
|
}) {
|
|
19569
|
-
return /* @__PURE__ */
|
|
19563
|
+
return /* @__PURE__ */ jsx82(
|
|
19570
19564
|
ValidatedText,
|
|
19571
19565
|
{
|
|
19572
19566
|
...{
|
|
@@ -19574,22 +19568,24 @@ function Telephone({
|
|
|
19574
19568
|
field,
|
|
19575
19569
|
onChange,
|
|
19576
19570
|
hideLabelFromVision,
|
|
19571
|
+
validity,
|
|
19577
19572
|
type: "tel",
|
|
19578
|
-
prefix: /* @__PURE__ */
|
|
19573
|
+
prefix: /* @__PURE__ */ jsx82(input_prefix_wrapper_default, { variant: "icon", children: /* @__PURE__ */ jsx82(icon_default2, { icon: mobile_default }) })
|
|
19579
19574
|
}
|
|
19580
19575
|
}
|
|
19581
19576
|
);
|
|
19582
19577
|
}
|
|
19583
19578
|
|
|
19584
19579
|
// src/dataform-controls/url.tsx
|
|
19585
|
-
import { jsx as
|
|
19580
|
+
import { jsx as jsx83 } from "react/jsx-runtime";
|
|
19586
19581
|
function Url({
|
|
19587
19582
|
data,
|
|
19588
19583
|
field,
|
|
19589
19584
|
onChange,
|
|
19590
|
-
hideLabelFromVision
|
|
19585
|
+
hideLabelFromVision,
|
|
19586
|
+
validity
|
|
19591
19587
|
}) {
|
|
19592
|
-
return /* @__PURE__ */
|
|
19588
|
+
return /* @__PURE__ */ jsx83(
|
|
19593
19589
|
ValidatedText,
|
|
19594
19590
|
{
|
|
19595
19591
|
...{
|
|
@@ -19597,17 +19593,17 @@ function Url({
|
|
|
19597
19593
|
field,
|
|
19598
19594
|
onChange,
|
|
19599
19595
|
hideLabelFromVision,
|
|
19596
|
+
validity,
|
|
19600
19597
|
type: "url",
|
|
19601
|
-
prefix: /* @__PURE__ */
|
|
19598
|
+
prefix: /* @__PURE__ */ jsx83(input_prefix_wrapper_default, { variant: "icon", children: /* @__PURE__ */ jsx83(icon_default2, { icon: link_default }) })
|
|
19602
19599
|
}
|
|
19603
19600
|
}
|
|
19604
19601
|
);
|
|
19605
19602
|
}
|
|
19606
19603
|
|
|
19607
19604
|
// src/dataform-controls/utils/validated-number.tsx
|
|
19608
|
-
import deepMerge5 from "deepmerge";
|
|
19609
19605
|
import { __ as __46 } from "@wordpress/i18n";
|
|
19610
|
-
import { jsx as
|
|
19606
|
+
import { jsx as jsx84, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
19611
19607
|
var { ValidatedNumberControl: ValidatedNumberControl2 } = unlock3(privateApis);
|
|
19612
19608
|
function toNumberOrEmpty(value) {
|
|
19613
19609
|
if (value === "" || value === void 0) {
|
|
@@ -19631,13 +19627,13 @@ function BetweenControls({
|
|
|
19631
19627
|
(newValue) => onChange([min, toNumberOrEmpty(newValue)]),
|
|
19632
19628
|
[onChange, min]
|
|
19633
19629
|
);
|
|
19634
|
-
return /* @__PURE__ */
|
|
19630
|
+
return /* @__PURE__ */ jsx84(
|
|
19635
19631
|
base_control_default,
|
|
19636
19632
|
{
|
|
19637
19633
|
__nextHasNoMarginBottom: true,
|
|
19638
19634
|
help: __46("The max. value must be greater than the min. value."),
|
|
19639
19635
|
children: /* @__PURE__ */ jsxs22(component_default3, { direction: "row", gap: 4, children: [
|
|
19640
|
-
/* @__PURE__ */
|
|
19636
|
+
/* @__PURE__ */ jsx84(
|
|
19641
19637
|
number_control_default,
|
|
19642
19638
|
{
|
|
19643
19639
|
label: __46("Min."),
|
|
@@ -19649,7 +19645,7 @@ function BetweenControls({
|
|
|
19649
19645
|
step
|
|
19650
19646
|
}
|
|
19651
19647
|
),
|
|
19652
|
-
/* @__PURE__ */
|
|
19648
|
+
/* @__PURE__ */ jsx84(
|
|
19653
19649
|
number_control_default,
|
|
19654
19650
|
{
|
|
19655
19651
|
label: __46("Max."),
|
|
@@ -19671,12 +19667,12 @@ function ValidatedNumber({
|
|
|
19671
19667
|
onChange,
|
|
19672
19668
|
hideLabelFromVision,
|
|
19673
19669
|
operator,
|
|
19674
|
-
decimals
|
|
19670
|
+
decimals,
|
|
19671
|
+
validity
|
|
19675
19672
|
}) {
|
|
19676
19673
|
const step = Math.pow(10, Math.abs(decimals) * -1);
|
|
19677
|
-
const { label, description, getValue, setValue } = field;
|
|
19674
|
+
const { label, description, getValue, setValue, isValid } = field;
|
|
19678
19675
|
const value = getValue({ item: data }) ?? "";
|
|
19679
|
-
const [customValidity, setCustomValidity] = useState(void 0);
|
|
19680
19676
|
const onChangeControl = useCallback(
|
|
19681
19677
|
(newValue) => {
|
|
19682
19678
|
onChange(
|
|
@@ -19702,29 +19698,6 @@ function ValidatedNumber({
|
|
|
19702
19698
|
},
|
|
19703
19699
|
[data, onChange, setValue]
|
|
19704
19700
|
);
|
|
19705
|
-
const onValidateControl = useCallback(
|
|
19706
|
-
(newValue) => {
|
|
19707
|
-
const message = field.isValid?.custom?.(
|
|
19708
|
-
deepMerge5(
|
|
19709
|
-
data,
|
|
19710
|
-
setValue({
|
|
19711
|
-
item: data,
|
|
19712
|
-
value: [void 0, "", null].includes(newValue) ? void 0 : Number(newValue)
|
|
19713
|
-
})
|
|
19714
|
-
),
|
|
19715
|
-
field
|
|
19716
|
-
);
|
|
19717
|
-
if (message) {
|
|
19718
|
-
setCustomValidity({
|
|
19719
|
-
type: "invalid",
|
|
19720
|
-
message
|
|
19721
|
-
});
|
|
19722
|
-
return;
|
|
19723
|
-
}
|
|
19724
|
-
setCustomValidity(void 0);
|
|
19725
|
-
},
|
|
19726
|
-
[data, field, setValue]
|
|
19727
|
-
);
|
|
19728
19701
|
if (operator === OPERATOR_BETWEEN) {
|
|
19729
19702
|
let valueBetween = ["", ""];
|
|
19730
19703
|
if (Array.isArray(value) && value.length === 2 && value.every(
|
|
@@ -19732,7 +19705,7 @@ function ValidatedNumber({
|
|
|
19732
19705
|
)) {
|
|
19733
19706
|
valueBetween = value;
|
|
19734
19707
|
}
|
|
19735
|
-
return /* @__PURE__ */
|
|
19708
|
+
return /* @__PURE__ */ jsx84(
|
|
19736
19709
|
BetweenControls,
|
|
19737
19710
|
{
|
|
19738
19711
|
value: valueBetween,
|
|
@@ -19742,12 +19715,11 @@ function ValidatedNumber({
|
|
|
19742
19715
|
}
|
|
19743
19716
|
);
|
|
19744
19717
|
}
|
|
19745
|
-
return /* @__PURE__ */
|
|
19718
|
+
return /* @__PURE__ */ jsx84(
|
|
19746
19719
|
ValidatedNumberControl2,
|
|
19747
19720
|
{
|
|
19748
|
-
required: !!
|
|
19749
|
-
|
|
19750
|
-
customValidity,
|
|
19721
|
+
required: !!isValid?.required,
|
|
19722
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
19751
19723
|
label,
|
|
19752
19724
|
help: description,
|
|
19753
19725
|
value,
|
|
@@ -19760,124 +19732,84 @@ function ValidatedNumber({
|
|
|
19760
19732
|
}
|
|
19761
19733
|
|
|
19762
19734
|
// src/dataform-controls/integer.tsx
|
|
19763
|
-
import { jsx as
|
|
19735
|
+
import { jsx as jsx85 } from "react/jsx-runtime";
|
|
19764
19736
|
function Number2(props) {
|
|
19765
|
-
return /* @__PURE__ */
|
|
19737
|
+
return /* @__PURE__ */ jsx85(ValidatedNumber, { ...props, decimals: 0 });
|
|
19766
19738
|
}
|
|
19767
19739
|
|
|
19768
19740
|
// src/dataform-controls/number.tsx
|
|
19769
|
-
import { jsx as
|
|
19741
|
+
import { jsx as jsx86 } from "react/jsx-runtime";
|
|
19770
19742
|
function Number3(props) {
|
|
19771
|
-
return /* @__PURE__ */
|
|
19743
|
+
return /* @__PURE__ */ jsx86(ValidatedNumber, { ...props, decimals: 2 });
|
|
19772
19744
|
}
|
|
19773
19745
|
|
|
19774
19746
|
// src/dataform-controls/radio.tsx
|
|
19775
|
-
import
|
|
19776
|
-
import { jsx as jsx76 } from "react/jsx-runtime";
|
|
19747
|
+
import { jsx as jsx87 } from "react/jsx-runtime";
|
|
19777
19748
|
var { ValidatedRadioControl: ValidatedRadioControl2 } = unlock3(privateApis);
|
|
19778
19749
|
function Radio2({
|
|
19779
19750
|
data,
|
|
19780
19751
|
field,
|
|
19781
19752
|
onChange,
|
|
19782
|
-
hideLabelFromVision
|
|
19753
|
+
hideLabelFromVision,
|
|
19754
|
+
validity
|
|
19783
19755
|
}) {
|
|
19784
|
-
const { label, description,
|
|
19756
|
+
const { label, description, getValue, setValue, isValid } = field;
|
|
19757
|
+
const { elements, isLoading } = useElements({
|
|
19758
|
+
elements: field.elements,
|
|
19759
|
+
getElements: field.getElements
|
|
19760
|
+
});
|
|
19785
19761
|
const value = getValue({ item: data });
|
|
19786
|
-
const [customValidity, setCustomValidity] = useState(void 0);
|
|
19787
19762
|
const onChangeControl = useCallback(
|
|
19788
19763
|
(newValue) => onChange(setValue({ item: data, value: newValue })),
|
|
19789
19764
|
[data, onChange, setValue]
|
|
19790
19765
|
);
|
|
19791
|
-
|
|
19792
|
-
(
|
|
19793
|
-
const message = field.isValid?.custom?.(
|
|
19794
|
-
deepMerge6(
|
|
19795
|
-
data,
|
|
19796
|
-
setValue({
|
|
19797
|
-
item: data,
|
|
19798
|
-
value: newValue
|
|
19799
|
-
})
|
|
19800
|
-
),
|
|
19801
|
-
field
|
|
19802
|
-
);
|
|
19803
|
-
if (message) {
|
|
19804
|
-
setCustomValidity({
|
|
19805
|
-
type: "invalid",
|
|
19806
|
-
message
|
|
19807
|
-
});
|
|
19808
|
-
return;
|
|
19809
|
-
}
|
|
19810
|
-
setCustomValidity(void 0);
|
|
19811
|
-
},
|
|
19812
|
-
[data, field, setValue]
|
|
19813
|
-
);
|
|
19814
|
-
if (elements) {
|
|
19815
|
-
return /* @__PURE__ */ jsx76(
|
|
19816
|
-
ValidatedRadioControl2,
|
|
19817
|
-
{
|
|
19818
|
-
required: !!field.isValid?.required,
|
|
19819
|
-
onValidate: onValidateControl,
|
|
19820
|
-
customValidity,
|
|
19821
|
-
label,
|
|
19822
|
-
help: description,
|
|
19823
|
-
onChange: onChangeControl,
|
|
19824
|
-
options: elements,
|
|
19825
|
-
selected: value,
|
|
19826
|
-
hideLabelFromVision
|
|
19827
|
-
}
|
|
19828
|
-
);
|
|
19766
|
+
if (isLoading) {
|
|
19767
|
+
return /* @__PURE__ */ jsx87(spinner_default, {});
|
|
19829
19768
|
}
|
|
19830
|
-
return
|
|
19769
|
+
return /* @__PURE__ */ jsx87(
|
|
19770
|
+
ValidatedRadioControl2,
|
|
19771
|
+
{
|
|
19772
|
+
required: !!field.isValid?.required,
|
|
19773
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
19774
|
+
label,
|
|
19775
|
+
help: description,
|
|
19776
|
+
onChange: onChangeControl,
|
|
19777
|
+
options: elements,
|
|
19778
|
+
selected: value,
|
|
19779
|
+
hideLabelFromVision
|
|
19780
|
+
}
|
|
19781
|
+
);
|
|
19831
19782
|
}
|
|
19832
19783
|
|
|
19833
19784
|
// src/dataform-controls/select.tsx
|
|
19834
|
-
import
|
|
19835
|
-
import { jsx as jsx77 } from "react/jsx-runtime";
|
|
19785
|
+
import { jsx as jsx88 } from "react/jsx-runtime";
|
|
19836
19786
|
var { ValidatedSelectControl: ValidatedSelectControl2 } = unlock3(privateApis);
|
|
19837
19787
|
function Select2({
|
|
19838
19788
|
data,
|
|
19839
19789
|
field,
|
|
19840
19790
|
onChange,
|
|
19841
|
-
hideLabelFromVision
|
|
19791
|
+
hideLabelFromVision,
|
|
19792
|
+
validity
|
|
19842
19793
|
}) {
|
|
19843
|
-
const { type, label, description, getValue, setValue } = field;
|
|
19844
|
-
const [customValidity, setCustomValidity] = useState(void 0);
|
|
19794
|
+
const { type, label, description, getValue, setValue, isValid } = field;
|
|
19845
19795
|
const isMultiple = type === "array";
|
|
19846
19796
|
const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
|
|
19847
19797
|
const onChangeControl = useCallback(
|
|
19848
19798
|
(newValue) => onChange(setValue({ item: data, value: newValue })),
|
|
19849
19799
|
[data, onChange, setValue]
|
|
19850
19800
|
);
|
|
19851
|
-
const
|
|
19852
|
-
|
|
19853
|
-
|
|
19854
|
-
|
|
19855
|
-
|
|
19856
|
-
|
|
19857
|
-
|
|
19858
|
-
|
|
19859
|
-
})
|
|
19860
|
-
),
|
|
19861
|
-
field
|
|
19862
|
-
);
|
|
19863
|
-
if (message) {
|
|
19864
|
-
setCustomValidity({
|
|
19865
|
-
type: "invalid",
|
|
19866
|
-
message
|
|
19867
|
-
});
|
|
19868
|
-
return;
|
|
19869
|
-
}
|
|
19870
|
-
setCustomValidity(void 0);
|
|
19871
|
-
},
|
|
19872
|
-
[data, field, setValue]
|
|
19873
|
-
);
|
|
19874
|
-
const elements = field?.elements ?? [];
|
|
19875
|
-
return /* @__PURE__ */ jsx77(
|
|
19801
|
+
const { elements, isLoading } = useElements({
|
|
19802
|
+
elements: field.elements,
|
|
19803
|
+
getElements: field.getElements
|
|
19804
|
+
});
|
|
19805
|
+
if (isLoading) {
|
|
19806
|
+
return /* @__PURE__ */ jsx88(spinner_default, {});
|
|
19807
|
+
}
|
|
19808
|
+
return /* @__PURE__ */ jsx88(
|
|
19876
19809
|
ValidatedSelectControl2,
|
|
19877
19810
|
{
|
|
19878
19811
|
required: !!field.isValid?.required,
|
|
19879
|
-
|
|
19880
|
-
customValidity,
|
|
19812
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
19881
19813
|
label,
|
|
19882
19814
|
value,
|
|
19883
19815
|
help: description,
|
|
@@ -19892,16 +19824,17 @@ function Select2({
|
|
|
19892
19824
|
}
|
|
19893
19825
|
|
|
19894
19826
|
// src/dataform-controls/text.tsx
|
|
19895
|
-
import { jsx as
|
|
19827
|
+
import { jsx as jsx89 } from "react/jsx-runtime";
|
|
19896
19828
|
function Text3({
|
|
19897
19829
|
data,
|
|
19898
19830
|
field,
|
|
19899
19831
|
onChange,
|
|
19900
19832
|
hideLabelFromVision,
|
|
19901
|
-
config
|
|
19833
|
+
config,
|
|
19834
|
+
validity
|
|
19902
19835
|
}) {
|
|
19903
19836
|
const { prefix, suffix } = config || {};
|
|
19904
|
-
return /* @__PURE__ */
|
|
19837
|
+
return /* @__PURE__ */ jsx89(
|
|
19905
19838
|
ValidatedText,
|
|
19906
19839
|
{
|
|
19907
19840
|
...{
|
|
@@ -19909,6 +19842,7 @@ function Text3({
|
|
|
19909
19842
|
field,
|
|
19910
19843
|
onChange,
|
|
19911
19844
|
hideLabelFromVision,
|
|
19845
|
+
validity,
|
|
19912
19846
|
prefix: prefix ? createElement(prefix) : void 0,
|
|
19913
19847
|
suffix: suffix ? createElement(suffix) : void 0
|
|
19914
19848
|
}
|
|
@@ -19917,51 +19851,26 @@ function Text3({
|
|
|
19917
19851
|
}
|
|
19918
19852
|
|
|
19919
19853
|
// src/dataform-controls/toggle.tsx
|
|
19920
|
-
import
|
|
19921
|
-
import { jsx as jsx79 } from "react/jsx-runtime";
|
|
19854
|
+
import { jsx as jsx90 } from "react/jsx-runtime";
|
|
19922
19855
|
var { ValidatedToggleControl: ValidatedToggleControl2 } = unlock3(privateApis);
|
|
19923
19856
|
function Toggle({
|
|
19924
19857
|
field,
|
|
19925
19858
|
onChange,
|
|
19926
19859
|
data,
|
|
19927
|
-
hideLabelFromVision
|
|
19860
|
+
hideLabelFromVision,
|
|
19861
|
+
validity
|
|
19928
19862
|
}) {
|
|
19929
|
-
const { label, description, getValue, setValue } = field;
|
|
19930
|
-
const [customValidity, setCustomValidity] = useState(void 0);
|
|
19863
|
+
const { label, description, getValue, setValue, isValid } = field;
|
|
19931
19864
|
const onChangeControl = useCallback(() => {
|
|
19932
19865
|
onChange(
|
|
19933
19866
|
setValue({ item: data, value: !getValue({ item: data }) })
|
|
19934
19867
|
);
|
|
19935
19868
|
}, [onChange, setValue, data, getValue]);
|
|
19936
|
-
|
|
19937
|
-
(newValue) => {
|
|
19938
|
-
const message = field.isValid?.custom?.(
|
|
19939
|
-
deepMerge8(
|
|
19940
|
-
data,
|
|
19941
|
-
setValue({
|
|
19942
|
-
item: data,
|
|
19943
|
-
value: newValue
|
|
19944
|
-
})
|
|
19945
|
-
),
|
|
19946
|
-
field
|
|
19947
|
-
);
|
|
19948
|
-
if (message) {
|
|
19949
|
-
setCustomValidity({
|
|
19950
|
-
type: "invalid",
|
|
19951
|
-
message
|
|
19952
|
-
});
|
|
19953
|
-
return;
|
|
19954
|
-
}
|
|
19955
|
-
setCustomValidity(void 0);
|
|
19956
|
-
},
|
|
19957
|
-
[data, field, setValue]
|
|
19958
|
-
);
|
|
19959
|
-
return /* @__PURE__ */ jsx79(
|
|
19869
|
+
return /* @__PURE__ */ jsx90(
|
|
19960
19870
|
ValidatedToggleControl2,
|
|
19961
19871
|
{
|
|
19962
|
-
required: !!
|
|
19963
|
-
|
|
19964
|
-
customValidity,
|
|
19872
|
+
required: !!isValid.required,
|
|
19873
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
19965
19874
|
hidden: hideLabelFromVision,
|
|
19966
19875
|
__nextHasNoMarginBottom: true,
|
|
19967
19876
|
label,
|
|
@@ -19973,53 +19882,28 @@ function Toggle({
|
|
|
19973
19882
|
}
|
|
19974
19883
|
|
|
19975
19884
|
// src/dataform-controls/textarea.tsx
|
|
19976
|
-
import
|
|
19977
|
-
import { jsx as jsx80 } from "react/jsx-runtime";
|
|
19885
|
+
import { jsx as jsx91 } from "react/jsx-runtime";
|
|
19978
19886
|
var { ValidatedTextareaControl: ValidatedTextareaControl2 } = unlock3(privateApis);
|
|
19979
19887
|
function Textarea({
|
|
19980
19888
|
data,
|
|
19981
19889
|
field,
|
|
19982
19890
|
onChange,
|
|
19983
19891
|
hideLabelFromVision,
|
|
19984
|
-
config
|
|
19892
|
+
config,
|
|
19893
|
+
validity
|
|
19985
19894
|
}) {
|
|
19986
19895
|
const { rows = 4 } = config || {};
|
|
19987
|
-
const { label, placeholder, description, setValue } = field;
|
|
19896
|
+
const { label, placeholder, description, setValue, isValid } = field;
|
|
19988
19897
|
const value = field.getValue({ item: data });
|
|
19989
|
-
const [customValidity, setCustomValidity] = useState(void 0);
|
|
19990
19898
|
const onChangeControl = useCallback(
|
|
19991
19899
|
(newValue) => onChange(setValue({ item: data, value: newValue })),
|
|
19992
19900
|
[data, onChange, setValue]
|
|
19993
19901
|
);
|
|
19994
|
-
|
|
19995
|
-
(newValue) => {
|
|
19996
|
-
const message = field.isValid?.custom?.(
|
|
19997
|
-
deepMerge9(
|
|
19998
|
-
data,
|
|
19999
|
-
setValue({
|
|
20000
|
-
item: data,
|
|
20001
|
-
value: newValue
|
|
20002
|
-
})
|
|
20003
|
-
),
|
|
20004
|
-
field
|
|
20005
|
-
);
|
|
20006
|
-
if (message) {
|
|
20007
|
-
setCustomValidity({
|
|
20008
|
-
type: "invalid",
|
|
20009
|
-
message
|
|
20010
|
-
});
|
|
20011
|
-
return;
|
|
20012
|
-
}
|
|
20013
|
-
setCustomValidity(void 0);
|
|
20014
|
-
},
|
|
20015
|
-
[data, field, setValue]
|
|
20016
|
-
);
|
|
20017
|
-
return /* @__PURE__ */ jsx80(
|
|
19902
|
+
return /* @__PURE__ */ jsx91(
|
|
20018
19903
|
ValidatedTextareaControl2,
|
|
20019
19904
|
{
|
|
20020
|
-
required: !!
|
|
20021
|
-
|
|
20022
|
-
customValidity,
|
|
19905
|
+
required: !!isValid?.required,
|
|
19906
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
20023
19907
|
label,
|
|
20024
19908
|
placeholder,
|
|
20025
19909
|
value: value ?? "",
|
|
@@ -20034,91 +19918,73 @@ function Textarea({
|
|
|
20034
19918
|
}
|
|
20035
19919
|
|
|
20036
19920
|
// src/dataform-controls/toggle-group.tsx
|
|
20037
|
-
import
|
|
20038
|
-
import { jsx as jsx81 } from "react/jsx-runtime";
|
|
19921
|
+
import { jsx as jsx92 } from "react/jsx-runtime";
|
|
20039
19922
|
var { ValidatedToggleGroupControl: ValidatedToggleGroupControl2 } = unlock3(privateApis);
|
|
20040
19923
|
function ToggleGroup({
|
|
20041
19924
|
data,
|
|
20042
19925
|
field,
|
|
20043
19926
|
onChange,
|
|
20044
|
-
hideLabelFromVision
|
|
19927
|
+
hideLabelFromVision,
|
|
19928
|
+
validity
|
|
20045
19929
|
}) {
|
|
20046
|
-
const { getValue, setValue } = field;
|
|
20047
|
-
const [customValidity, setCustomValidity] = useState(void 0);
|
|
19930
|
+
const { getValue, setValue, isValid } = field;
|
|
20048
19931
|
const value = getValue({ item: data });
|
|
20049
19932
|
const onChangeControl = useCallback(
|
|
20050
19933
|
(newValue) => onChange(setValue({ item: data, value: newValue })),
|
|
20051
19934
|
[data, onChange, setValue]
|
|
20052
19935
|
);
|
|
20053
|
-
const
|
|
20054
|
-
|
|
20055
|
-
|
|
20056
|
-
|
|
20057
|
-
|
|
20058
|
-
|
|
20059
|
-
item: data,
|
|
20060
|
-
value: newValue
|
|
20061
|
-
})
|
|
20062
|
-
),
|
|
20063
|
-
field
|
|
20064
|
-
);
|
|
20065
|
-
if (message) {
|
|
20066
|
-
setCustomValidity({
|
|
20067
|
-
type: "invalid",
|
|
20068
|
-
message
|
|
20069
|
-
});
|
|
20070
|
-
return;
|
|
20071
|
-
}
|
|
20072
|
-
setCustomValidity(void 0);
|
|
20073
|
-
},
|
|
20074
|
-
[data, field, setValue]
|
|
20075
|
-
);
|
|
20076
|
-
if (field.elements) {
|
|
20077
|
-
const selectedOption = field.elements.find(
|
|
20078
|
-
(el) => el.value === value
|
|
20079
|
-
);
|
|
20080
|
-
return /* @__PURE__ */ jsx81(
|
|
20081
|
-
ValidatedToggleGroupControl2,
|
|
20082
|
-
{
|
|
20083
|
-
required: !!field.isValid?.required,
|
|
20084
|
-
onValidate: onValidateControl,
|
|
20085
|
-
customValidity,
|
|
20086
|
-
__next40pxDefaultSize: true,
|
|
20087
|
-
__nextHasNoMarginBottom: true,
|
|
20088
|
-
isBlock: true,
|
|
20089
|
-
label: field.label,
|
|
20090
|
-
help: selectedOption?.description || field.description,
|
|
20091
|
-
onChange: onChangeControl,
|
|
20092
|
-
value,
|
|
20093
|
-
hideLabelFromVision,
|
|
20094
|
-
children: field.elements.map((el) => /* @__PURE__ */ jsx81(
|
|
20095
|
-
component_default12,
|
|
20096
|
-
{
|
|
20097
|
-
label: el.label,
|
|
20098
|
-
value: el.value
|
|
20099
|
-
},
|
|
20100
|
-
el.value
|
|
20101
|
-
))
|
|
20102
|
-
}
|
|
20103
|
-
);
|
|
19936
|
+
const { elements, isLoading } = useElements({
|
|
19937
|
+
elements: field.elements,
|
|
19938
|
+
getElements: field.getElements
|
|
19939
|
+
});
|
|
19940
|
+
if (isLoading) {
|
|
19941
|
+
return /* @__PURE__ */ jsx92(spinner_default, {});
|
|
20104
19942
|
}
|
|
20105
|
-
|
|
19943
|
+
if (elements.length === 0) {
|
|
19944
|
+
return null;
|
|
19945
|
+
}
|
|
19946
|
+
const selectedOption = elements.find((el) => el.value === value);
|
|
19947
|
+
return /* @__PURE__ */ jsx92(
|
|
19948
|
+
ValidatedToggleGroupControl2,
|
|
19949
|
+
{
|
|
19950
|
+
required: !!field.isValid?.required,
|
|
19951
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
19952
|
+
__next40pxDefaultSize: true,
|
|
19953
|
+
__nextHasNoMarginBottom: true,
|
|
19954
|
+
isBlock: true,
|
|
19955
|
+
label: field.label,
|
|
19956
|
+
help: selectedOption?.description || field.description,
|
|
19957
|
+
onChange: onChangeControl,
|
|
19958
|
+
value,
|
|
19959
|
+
hideLabelFromVision,
|
|
19960
|
+
children: elements.map((el) => /* @__PURE__ */ jsx92(
|
|
19961
|
+
component_default12,
|
|
19962
|
+
{
|
|
19963
|
+
label: el.label,
|
|
19964
|
+
value: el.value
|
|
19965
|
+
},
|
|
19966
|
+
el.value
|
|
19967
|
+
))
|
|
19968
|
+
}
|
|
19969
|
+
);
|
|
20106
19970
|
}
|
|
20107
19971
|
|
|
20108
19972
|
// src/dataform-controls/array.tsx
|
|
20109
|
-
import
|
|
20110
|
-
import { _n as _n4, sprintf as sprintf15 } from "@wordpress/i18n";
|
|
20111
|
-
import { jsx as jsx82 } from "react/jsx-runtime";
|
|
19973
|
+
import { jsx as jsx93 } from "react/jsx-runtime";
|
|
20112
19974
|
var { ValidatedFormTokenField: ValidatedFormTokenField2 } = unlock3(privateApis);
|
|
20113
19975
|
function ArrayControl({
|
|
20114
19976
|
data,
|
|
20115
19977
|
field,
|
|
20116
19978
|
onChange,
|
|
20117
|
-
hideLabelFromVision
|
|
19979
|
+
hideLabelFromVision,
|
|
19980
|
+
validity
|
|
20118
19981
|
}) {
|
|
20119
|
-
const { label, placeholder,
|
|
19982
|
+
const { label, placeholder, getValue, setValue, isValid } = field;
|
|
20120
19983
|
const value = getValue({ item: data });
|
|
20121
|
-
const
|
|
19984
|
+
const { elements, isLoading } = useElements({
|
|
19985
|
+
elements: field.elements,
|
|
19986
|
+
getElements: field.getElements
|
|
19987
|
+
});
|
|
20122
19988
|
const arrayValueAsElements = useMemo(
|
|
20123
19989
|
() => Array.isArray(value) ? value.map((token) => {
|
|
20124
19990
|
const element = elements?.find(
|
|
@@ -20128,59 +19994,6 @@ function ArrayControl({
|
|
|
20128
19994
|
}) : [],
|
|
20129
19995
|
[value, elements]
|
|
20130
19996
|
);
|
|
20131
|
-
const validateTokens = useCallback(
|
|
20132
|
-
(tokens) => {
|
|
20133
|
-
const tokenValues = tokens.map((token) => {
|
|
20134
|
-
if (typeof token === "object" && "value" in token) {
|
|
20135
|
-
return token.value;
|
|
20136
|
-
}
|
|
20137
|
-
return token;
|
|
20138
|
-
});
|
|
20139
|
-
if (field.isValid?.elements && elements) {
|
|
20140
|
-
const invalidTokens = tokenValues.filter((tokenValue) => {
|
|
20141
|
-
return !elements.some(
|
|
20142
|
-
(element) => element.value === tokenValue
|
|
20143
|
-
);
|
|
20144
|
-
});
|
|
20145
|
-
if (invalidTokens.length > 0) {
|
|
20146
|
-
setCustomValidity({
|
|
20147
|
-
type: "invalid",
|
|
20148
|
-
message: sprintf15(
|
|
20149
|
-
/* translators: %s: list of invalid tokens */
|
|
20150
|
-
_n4(
|
|
20151
|
-
"Please select from the available options: %s is invalid.",
|
|
20152
|
-
"Please select from the available options: %s are invalid.",
|
|
20153
|
-
invalidTokens.length
|
|
20154
|
-
),
|
|
20155
|
-
invalidTokens.join(", ")
|
|
20156
|
-
)
|
|
20157
|
-
});
|
|
20158
|
-
return;
|
|
20159
|
-
}
|
|
20160
|
-
}
|
|
20161
|
-
if (field.isValid?.custom) {
|
|
20162
|
-
const result = field.isValid?.custom?.(
|
|
20163
|
-
deepMerge11(
|
|
20164
|
-
data,
|
|
20165
|
-
setValue({
|
|
20166
|
-
item: data,
|
|
20167
|
-
value: tokenValues
|
|
20168
|
-
})
|
|
20169
|
-
),
|
|
20170
|
-
field
|
|
20171
|
-
);
|
|
20172
|
-
if (result) {
|
|
20173
|
-
setCustomValidity({
|
|
20174
|
-
type: "invalid",
|
|
20175
|
-
message: result
|
|
20176
|
-
});
|
|
20177
|
-
return;
|
|
20178
|
-
}
|
|
20179
|
-
}
|
|
20180
|
-
setCustomValidity(void 0);
|
|
20181
|
-
},
|
|
20182
|
-
[elements, data, field, setValue]
|
|
20183
|
-
);
|
|
20184
19997
|
const onChangeControl = useCallback(
|
|
20185
19998
|
(tokens) => {
|
|
20186
19999
|
const valueTokens = tokens.map((token) => {
|
|
@@ -20193,12 +20006,14 @@ function ArrayControl({
|
|
|
20193
20006
|
},
|
|
20194
20007
|
[onChange, setValue, data]
|
|
20195
20008
|
);
|
|
20196
|
-
|
|
20009
|
+
if (isLoading) {
|
|
20010
|
+
return /* @__PURE__ */ jsx93(spinner_default, {});
|
|
20011
|
+
}
|
|
20012
|
+
return /* @__PURE__ */ jsx93(
|
|
20197
20013
|
ValidatedFormTokenField2,
|
|
20198
20014
|
{
|
|
20199
|
-
required: !!
|
|
20200
|
-
|
|
20201
|
-
customValidity,
|
|
20015
|
+
required: !!isValid?.required,
|
|
20016
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
20202
20017
|
label: hideLabelFromVision ? void 0 : label,
|
|
20203
20018
|
value: arrayValueAsElements,
|
|
20204
20019
|
onChange: onChangeControl,
|
|
@@ -20231,9 +20046,9 @@ function ArrayControl({
|
|
|
20231
20046
|
const element = elements.find(
|
|
20232
20047
|
(el) => el.value === item2
|
|
20233
20048
|
);
|
|
20234
|
-
return /* @__PURE__ */
|
|
20049
|
+
return /* @__PURE__ */ jsx93("span", { children: element?.label || item2 });
|
|
20235
20050
|
}
|
|
20236
|
-
return /* @__PURE__ */
|
|
20051
|
+
return /* @__PURE__ */ jsx93("span", { children: item2 });
|
|
20237
20052
|
}
|
|
20238
20053
|
}
|
|
20239
20054
|
);
|
|
@@ -20241,18 +20056,17 @@ function ArrayControl({
|
|
|
20241
20056
|
|
|
20242
20057
|
// src/dataform-controls/color.tsx
|
|
20243
20058
|
import { colord as colord5 } from "colord";
|
|
20244
|
-
import
|
|
20245
|
-
import { jsx as jsx83 } from "react/jsx-runtime";
|
|
20059
|
+
import { jsx as jsx94 } from "react/jsx-runtime";
|
|
20246
20060
|
var { ValidatedInputControl: ValidatedInputControl4, Picker: Picker2 } = unlock3(privateApis);
|
|
20247
20061
|
var ColorPicker = ({
|
|
20248
20062
|
color,
|
|
20249
20063
|
onColorChange
|
|
20250
20064
|
}) => {
|
|
20251
20065
|
const validColor = color && colord5(color).isValid() ? color : "#ffffff";
|
|
20252
|
-
return /* @__PURE__ */
|
|
20066
|
+
return /* @__PURE__ */ jsx94(
|
|
20253
20067
|
dropdown_default,
|
|
20254
20068
|
{
|
|
20255
|
-
renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */
|
|
20069
|
+
renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */ jsx94(input_prefix_wrapper_default, { variant: "icon", children: /* @__PURE__ */ jsx94(
|
|
20256
20070
|
"button",
|
|
20257
20071
|
{
|
|
20258
20072
|
type: "button",
|
|
@@ -20275,7 +20089,7 @@ var ColorPicker = ({
|
|
|
20275
20089
|
"aria-label": "Open color picker"
|
|
20276
20090
|
}
|
|
20277
20091
|
) }),
|
|
20278
|
-
renderContent: () => /* @__PURE__ */
|
|
20092
|
+
renderContent: () => /* @__PURE__ */ jsx94("div", { style: { padding: "16px" }, children: /* @__PURE__ */ jsx94(
|
|
20279
20093
|
Picker2,
|
|
20280
20094
|
{
|
|
20281
20095
|
color: colord5(validColor),
|
|
@@ -20290,11 +20104,11 @@ function Color({
|
|
|
20290
20104
|
data,
|
|
20291
20105
|
field,
|
|
20292
20106
|
onChange,
|
|
20293
|
-
hideLabelFromVision
|
|
20107
|
+
hideLabelFromVision,
|
|
20108
|
+
validity
|
|
20294
20109
|
}) {
|
|
20295
|
-
const { label, placeholder, description, setValue } = field;
|
|
20110
|
+
const { label, placeholder, description, setValue, isValid } = field;
|
|
20296
20111
|
const value = field.getValue({ item: data }) || "";
|
|
20297
|
-
const [customValidity, setCustomValidity] = useState(void 0);
|
|
20298
20112
|
const handleColorChange = useCallback(
|
|
20299
20113
|
(colorObject) => {
|
|
20300
20114
|
onChange(setValue({ item: data, value: colorObject.toHex() }));
|
|
@@ -20307,35 +20121,11 @@ function Color({
|
|
|
20307
20121
|
},
|
|
20308
20122
|
[data, onChange, setValue]
|
|
20309
20123
|
);
|
|
20310
|
-
|
|
20311
|
-
(newValue) => {
|
|
20312
|
-
const message = field.isValid?.custom?.(
|
|
20313
|
-
deepMerge12(
|
|
20314
|
-
data,
|
|
20315
|
-
setValue({
|
|
20316
|
-
item: data,
|
|
20317
|
-
value: newValue
|
|
20318
|
-
})
|
|
20319
|
-
),
|
|
20320
|
-
field
|
|
20321
|
-
);
|
|
20322
|
-
if (message) {
|
|
20323
|
-
setCustomValidity({
|
|
20324
|
-
type: "invalid",
|
|
20325
|
-
message
|
|
20326
|
-
});
|
|
20327
|
-
return;
|
|
20328
|
-
}
|
|
20329
|
-
setCustomValidity(void 0);
|
|
20330
|
-
},
|
|
20331
|
-
[data, field, setValue]
|
|
20332
|
-
);
|
|
20333
|
-
return /* @__PURE__ */ jsx83(
|
|
20124
|
+
return /* @__PURE__ */ jsx94(
|
|
20334
20125
|
ValidatedInputControl4,
|
|
20335
20126
|
{
|
|
20336
20127
|
required: !!field.isValid?.required,
|
|
20337
|
-
|
|
20338
|
-
customValidity,
|
|
20128
|
+
customValidity: getCustomValidity(isValid, validity),
|
|
20339
20129
|
label,
|
|
20340
20130
|
placeholder,
|
|
20341
20131
|
value,
|
|
@@ -20343,7 +20133,7 @@ function Color({
|
|
|
20343
20133
|
onChange: handleInputChange,
|
|
20344
20134
|
hideLabelFromVision,
|
|
20345
20135
|
type: "text",
|
|
20346
|
-
prefix: /* @__PURE__ */
|
|
20136
|
+
prefix: /* @__PURE__ */ jsx94(
|
|
20347
20137
|
ColorPicker,
|
|
20348
20138
|
{
|
|
20349
20139
|
color: value,
|
|
@@ -20356,18 +20146,19 @@ function Color({
|
|
|
20356
20146
|
|
|
20357
20147
|
// src/dataform-controls/password.tsx
|
|
20358
20148
|
import { __ as __47 } from "@wordpress/i18n";
|
|
20359
|
-
import { jsx as
|
|
20149
|
+
import { jsx as jsx95 } from "react/jsx-runtime";
|
|
20360
20150
|
function Password({
|
|
20361
20151
|
data,
|
|
20362
20152
|
field,
|
|
20363
20153
|
onChange,
|
|
20364
|
-
hideLabelFromVision
|
|
20154
|
+
hideLabelFromVision,
|
|
20155
|
+
validity
|
|
20365
20156
|
}) {
|
|
20366
20157
|
const [isVisible2, setIsVisible] = useState(false);
|
|
20367
20158
|
const toggleVisibility = useCallback(() => {
|
|
20368
20159
|
setIsVisible((prev) => !prev);
|
|
20369
20160
|
}, []);
|
|
20370
|
-
return /* @__PURE__ */
|
|
20161
|
+
return /* @__PURE__ */ jsx95(
|
|
20371
20162
|
ValidatedText,
|
|
20372
20163
|
{
|
|
20373
20164
|
...{
|
|
@@ -20375,8 +20166,9 @@ function Password({
|
|
|
20375
20166
|
field,
|
|
20376
20167
|
onChange,
|
|
20377
20168
|
hideLabelFromVision,
|
|
20169
|
+
validity,
|
|
20378
20170
|
type: isVisible2 ? "text" : "password",
|
|
20379
|
-
suffix: /* @__PURE__ */
|
|
20171
|
+
suffix: /* @__PURE__ */ jsx95(
|
|
20380
20172
|
button_default,
|
|
20381
20173
|
{
|
|
20382
20174
|
icon: isVisible2 ? unseen_default : seen_default,
|
|
@@ -20391,8 +20183,13 @@ function Password({
|
|
|
20391
20183
|
);
|
|
20392
20184
|
}
|
|
20393
20185
|
|
|
20186
|
+
// src/utils/has-elements.ts
|
|
20187
|
+
function hasElements(field) {
|
|
20188
|
+
return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
|
|
20189
|
+
}
|
|
20190
|
+
|
|
20394
20191
|
// src/dataform-controls/index.tsx
|
|
20395
|
-
import { jsx as
|
|
20192
|
+
import { jsx as jsx96 } from "react/jsx-runtime";
|
|
20396
20193
|
var FORM_CONTROLS = {
|
|
20397
20194
|
array: ArrayControl,
|
|
20398
20195
|
checkbox: Checkbox,
|
|
@@ -20419,7 +20216,7 @@ function createConfiguredControl(config) {
|
|
|
20419
20216
|
const { control, ...controlConfig } = config;
|
|
20420
20217
|
const BaseControlType = getControlByType(control);
|
|
20421
20218
|
return function ConfiguredControl(props) {
|
|
20422
|
-
return /* @__PURE__ */
|
|
20219
|
+
return /* @__PURE__ */ jsx96(BaseControlType, { ...props, config: controlConfig });
|
|
20423
20220
|
};
|
|
20424
20221
|
}
|
|
20425
20222
|
function getControl(field, fieldTypeDefinition) {
|
|
@@ -20432,7 +20229,7 @@ function getControl(field, fieldTypeDefinition) {
|
|
|
20432
20229
|
if (isEditConfig(field.Edit)) {
|
|
20433
20230
|
return createConfiguredControl(field.Edit);
|
|
20434
20231
|
}
|
|
20435
|
-
if (field
|
|
20232
|
+
if (hasElements(field) && field.type !== "array") {
|
|
20436
20233
|
return getControlByType("select");
|
|
20437
20234
|
}
|
|
20438
20235
|
if (typeof fieldTypeDefinition.Edit === "string") {
|
|
@@ -20490,7 +20287,7 @@ function getFilterBy(field, fieldTypeDefinition) {
|
|
|
20490
20287
|
operators = operators.filter(
|
|
20491
20288
|
(operator) => validOperators.includes(operator)
|
|
20492
20289
|
);
|
|
20493
|
-
if (field
|
|
20290
|
+
if (hasElements(field) && operators.includes(OPERATOR_BETWEEN)) {
|
|
20494
20291
|
operators = operators.filter(
|
|
20495
20292
|
(operator) => operator !== OPERATOR_BETWEEN
|
|
20496
20293
|
);
|
|
@@ -20520,7 +20317,7 @@ function getFilterBy(field, fieldTypeDefinition) {
|
|
|
20520
20317
|
return false;
|
|
20521
20318
|
}
|
|
20522
20319
|
let defaultOperators = fieldTypeDefinition.filterBy.defaultOperators;
|
|
20523
|
-
if (field
|
|
20320
|
+
if (hasElements(field) && defaultOperators.includes(OPERATOR_BETWEEN)) {
|
|
20524
20321
|
defaultOperators = defaultOperators.filter(
|
|
20525
20322
|
(operator) => operator !== OPERATOR_BETWEEN
|
|
20526
20323
|
);
|
|
@@ -20543,7 +20340,7 @@ function normalizeFields(fields) {
|
|
|
20543
20340
|
direction
|
|
20544
20341
|
);
|
|
20545
20342
|
};
|
|
20546
|
-
const
|
|
20343
|
+
const isValid = {
|
|
20547
20344
|
...fieldTypeDefinition.isValid,
|
|
20548
20345
|
...field.isValid
|
|
20549
20346
|
};
|
|
@@ -20563,8 +20360,9 @@ function normalizeFields(fields) {
|
|
|
20563
20360
|
setValue,
|
|
20564
20361
|
render: render3,
|
|
20565
20362
|
sort: sort14,
|
|
20566
|
-
isValid
|
|
20363
|
+
isValid,
|
|
20567
20364
|
Edit,
|
|
20365
|
+
hasElements: hasElements(field),
|
|
20568
20366
|
enableHiding: field.enableHiding ?? true,
|
|
20569
20367
|
enableSorting: field.enableSorting ?? fieldTypeDefinition.enableSorting ?? true,
|
|
20570
20368
|
filterBy,
|
|
@@ -20574,10 +20372,10 @@ function normalizeFields(fields) {
|
|
|
20574
20372
|
}
|
|
20575
20373
|
|
|
20576
20374
|
// src/components/dataviews/index.tsx
|
|
20577
|
-
import { Fragment as Fragment10, jsx as
|
|
20375
|
+
import { Fragment as Fragment10, jsx as jsx97, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
20578
20376
|
var defaultGetItemId = (item2) => item2.id;
|
|
20579
20377
|
var defaultIsItemClickable = () => true;
|
|
20580
|
-
var
|
|
20378
|
+
var EMPTY_ARRAY6 = [];
|
|
20581
20379
|
var dataViewsLayouts = VIEW_LAYOUTS.filter(
|
|
20582
20380
|
(viewLayout) => !viewLayout.isPicker
|
|
20583
20381
|
);
|
|
@@ -20602,8 +20400,8 @@ function DefaultUI({
|
|
|
20602
20400
|
expanded: false,
|
|
20603
20401
|
className: "dataviews__search",
|
|
20604
20402
|
children: [
|
|
20605
|
-
search && /* @__PURE__ */
|
|
20606
|
-
/* @__PURE__ */
|
|
20403
|
+
search && /* @__PURE__ */ jsx97(dataviews_search_default, { label: searchLabel }),
|
|
20404
|
+
/* @__PURE__ */ jsx97(toggle_default, {})
|
|
20607
20405
|
]
|
|
20608
20406
|
}
|
|
20609
20407
|
),
|
|
@@ -20614,7 +20412,7 @@ function DefaultUI({
|
|
|
20614
20412
|
expanded: false,
|
|
20615
20413
|
style: { flexShrink: 0 },
|
|
20616
20414
|
children: [
|
|
20617
|
-
/* @__PURE__ */
|
|
20415
|
+
/* @__PURE__ */ jsx97(dataviews_view_config_default, {}),
|
|
20618
20416
|
header
|
|
20619
20417
|
]
|
|
20620
20418
|
}
|
|
@@ -20622,9 +20420,9 @@ function DefaultUI({
|
|
|
20622
20420
|
]
|
|
20623
20421
|
}
|
|
20624
20422
|
),
|
|
20625
|
-
/* @__PURE__ */
|
|
20626
|
-
/* @__PURE__ */
|
|
20627
|
-
/* @__PURE__ */
|
|
20423
|
+
/* @__PURE__ */ jsx97(filters_toggled_default, { className: "dataviews-filters__container" }),
|
|
20424
|
+
/* @__PURE__ */ jsx97(DataViewsLayout, {}),
|
|
20425
|
+
/* @__PURE__ */ jsx97(DataViewsFooter, {})
|
|
20628
20426
|
] });
|
|
20629
20427
|
}
|
|
20630
20428
|
function DataViews({
|
|
@@ -20633,7 +20431,7 @@ function DataViews({
|
|
|
20633
20431
|
fields,
|
|
20634
20432
|
search = true,
|
|
20635
20433
|
searchLabel = void 0,
|
|
20636
|
-
actions =
|
|
20434
|
+
actions = EMPTY_ARRAY6,
|
|
20637
20435
|
data,
|
|
20638
20436
|
getItemId = defaultGetItemId,
|
|
20639
20437
|
getItemLevel,
|
|
@@ -20730,7 +20528,7 @@ function DataViews({
|
|
|
20730
20528
|
if (!defaultLayouts[view.type]) {
|
|
20731
20529
|
return null;
|
|
20732
20530
|
}
|
|
20733
|
-
return /* @__PURE__ */
|
|
20531
|
+
return /* @__PURE__ */ jsx97(
|
|
20734
20532
|
dataviews_context_default.Provider,
|
|
20735
20533
|
{
|
|
20736
20534
|
value: {
|
|
@@ -20761,7 +20559,7 @@ function DataViews({
|
|
|
20761
20559
|
empty,
|
|
20762
20560
|
hasInfiniteScrollHandler: !!infiniteScrollHandler
|
|
20763
20561
|
},
|
|
20764
|
-
children: /* @__PURE__ */
|
|
20562
|
+
children: /* @__PURE__ */ jsx97("div", { className: "dataviews-wrapper", ref: containerRef, children: children ?? /* @__PURE__ */ jsx97(
|
|
20765
20563
|
DefaultUI,
|
|
20766
20564
|
{
|
|
20767
20565
|
header,
|
|
@@ -20786,13 +20584,13 @@ DataViewsSubComponents.Footer = DataViewsFooter;
|
|
|
20786
20584
|
var dataviews_default = DataViewsSubComponents;
|
|
20787
20585
|
|
|
20788
20586
|
// src/components/dataviews-picker/index.tsx
|
|
20789
|
-
import { Fragment as Fragment11, jsx as
|
|
20587
|
+
import { Fragment as Fragment11, jsx as jsx98, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
20790
20588
|
var isItemClickable = () => false;
|
|
20791
20589
|
var dataViewsPickerLayouts = VIEW_LAYOUTS.filter(
|
|
20792
20590
|
(viewLayout) => viewLayout.isPicker
|
|
20793
20591
|
);
|
|
20794
20592
|
var defaultGetItemId2 = (item2) => item2.id;
|
|
20795
|
-
var
|
|
20593
|
+
var EMPTY_ARRAY7 = [];
|
|
20796
20594
|
function DefaultUI2({
|
|
20797
20595
|
search = true,
|
|
20798
20596
|
searchLabel = void 0
|
|
@@ -20813,26 +20611,26 @@ function DefaultUI2({
|
|
|
20813
20611
|
expanded: false,
|
|
20814
20612
|
className: "dataviews__search",
|
|
20815
20613
|
children: [
|
|
20816
|
-
search && /* @__PURE__ */
|
|
20817
|
-
/* @__PURE__ */
|
|
20614
|
+
search && /* @__PURE__ */ jsx98(dataviews_search_default, { label: searchLabel }),
|
|
20615
|
+
/* @__PURE__ */ jsx98(toggle_default, {})
|
|
20818
20616
|
]
|
|
20819
20617
|
}
|
|
20820
20618
|
),
|
|
20821
|
-
/* @__PURE__ */
|
|
20619
|
+
/* @__PURE__ */ jsx98(
|
|
20822
20620
|
component_default9,
|
|
20823
20621
|
{
|
|
20824
20622
|
spacing: 1,
|
|
20825
20623
|
expanded: false,
|
|
20826
20624
|
style: { flexShrink: 0 },
|
|
20827
|
-
children: /* @__PURE__ */
|
|
20625
|
+
children: /* @__PURE__ */ jsx98(dataviews_view_config_default, {})
|
|
20828
20626
|
}
|
|
20829
20627
|
)
|
|
20830
20628
|
]
|
|
20831
20629
|
}
|
|
20832
20630
|
),
|
|
20833
|
-
/* @__PURE__ */
|
|
20834
|
-
/* @__PURE__ */
|
|
20835
|
-
/* @__PURE__ */
|
|
20631
|
+
/* @__PURE__ */ jsx98(filters_toggled_default, { className: "dataviews-filters__container" }),
|
|
20632
|
+
/* @__PURE__ */ jsx98(DataViewsLayout, {}),
|
|
20633
|
+
/* @__PURE__ */ jsx98(DataViewsPickerFooter, {})
|
|
20836
20634
|
] });
|
|
20837
20635
|
}
|
|
20838
20636
|
function DataViewsPicker({
|
|
@@ -20841,7 +20639,7 @@ function DataViewsPicker({
|
|
|
20841
20639
|
fields,
|
|
20842
20640
|
search = true,
|
|
20843
20641
|
searchLabel = void 0,
|
|
20844
|
-
actions =
|
|
20642
|
+
actions = EMPTY_ARRAY7,
|
|
20845
20643
|
data,
|
|
20846
20644
|
getItemId = defaultGetItemId2,
|
|
20847
20645
|
isLoading = false,
|
|
@@ -20923,7 +20721,7 @@ function DataViewsPicker({
|
|
|
20923
20721
|
if (!defaultLayouts[view.type]) {
|
|
20924
20722
|
return null;
|
|
20925
20723
|
}
|
|
20926
|
-
return /* @__PURE__ */
|
|
20724
|
+
return /* @__PURE__ */ jsx98(
|
|
20927
20725
|
dataviews_context_default.Provider,
|
|
20928
20726
|
{
|
|
20929
20727
|
value: {
|
|
@@ -20952,7 +20750,7 @@ function DataViewsPicker({
|
|
|
20952
20750
|
empty,
|
|
20953
20751
|
hasInfiniteScrollHandler: !!infiniteScrollHandler
|
|
20954
20752
|
},
|
|
20955
|
-
children: /* @__PURE__ */
|
|
20753
|
+
children: /* @__PURE__ */ jsx98("div", { className: "dataviews-picker-wrapper", ref: containerRef, children: children ?? /* @__PURE__ */ jsx98(DefaultUI2, { search, searchLabel }) })
|
|
20956
20754
|
}
|
|
20957
20755
|
);
|
|
20958
20756
|
}
|
|
@@ -20969,7 +20767,7 @@ DataViewsPickerSubComponents.ViewConfig = DataviewsViewConfigDropdown;
|
|
|
20969
20767
|
var dataviews_picker_default = DataViewsPickerSubComponents;
|
|
20970
20768
|
|
|
20971
20769
|
// src/components/dataform-context/index.tsx
|
|
20972
|
-
import { jsx as
|
|
20770
|
+
import { jsx as jsx99 } from "react/jsx-runtime";
|
|
20973
20771
|
var DataFormContext = createContext({
|
|
20974
20772
|
fields: []
|
|
20975
20773
|
});
|
|
@@ -20978,7 +20776,7 @@ function DataFormProvider({
|
|
|
20978
20776
|
fields,
|
|
20979
20777
|
children
|
|
20980
20778
|
}) {
|
|
20981
|
-
return /* @__PURE__ */
|
|
20779
|
+
return /* @__PURE__ */ jsx99(DataFormContext.Provider, { value: { fields }, children });
|
|
20982
20780
|
}
|
|
20983
20781
|
var dataform_context_default = DataFormContext;
|
|
20984
20782
|
|
|
@@ -21066,18 +20864,19 @@ function normalizeFormFields(form) {
|
|
|
21066
20864
|
}
|
|
21067
20865
|
|
|
21068
20866
|
// src/dataform-layouts/regular/index.tsx
|
|
21069
|
-
import { Fragment as Fragment12, jsx as
|
|
20867
|
+
import { Fragment as Fragment12, jsx as jsx100, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
21070
20868
|
function Header2({ title }) {
|
|
21071
|
-
return /* @__PURE__ */
|
|
21072
|
-
/* @__PURE__ */
|
|
21073
|
-
/* @__PURE__ */
|
|
20869
|
+
return /* @__PURE__ */ jsx100(component_default14, { className: "dataforms-layouts-regular__header", spacing: 4, children: /* @__PURE__ */ jsxs25(component_default9, { alignment: "center", children: [
|
|
20870
|
+
/* @__PURE__ */ jsx100(component_default15, { level: 2, size: 13, children: title }),
|
|
20871
|
+
/* @__PURE__ */ jsx100(component_default6, {})
|
|
21074
20872
|
] }) });
|
|
21075
20873
|
}
|
|
21076
20874
|
function FormRegularField({
|
|
21077
20875
|
data,
|
|
21078
20876
|
field,
|
|
21079
20877
|
onChange,
|
|
21080
|
-
hideLabelFromVision
|
|
20878
|
+
hideLabelFromVision,
|
|
20879
|
+
validity
|
|
21081
20880
|
}) {
|
|
21082
20881
|
const { fields } = useContext(dataform_context_default);
|
|
21083
20882
|
const form = useMemo(
|
|
@@ -21089,13 +20888,14 @@ function FormRegularField({
|
|
|
21089
20888
|
);
|
|
21090
20889
|
if (isCombinedField(field)) {
|
|
21091
20890
|
return /* @__PURE__ */ jsxs25(Fragment12, { children: [
|
|
21092
|
-
!hideLabelFromVision && field.label && /* @__PURE__ */
|
|
21093
|
-
/* @__PURE__ */
|
|
20891
|
+
!hideLabelFromVision && field.label && /* @__PURE__ */ jsx100(Header2, { title: field.label }),
|
|
20892
|
+
/* @__PURE__ */ jsx100(
|
|
21094
20893
|
DataFormLayout,
|
|
21095
20894
|
{
|
|
21096
20895
|
data,
|
|
21097
20896
|
form,
|
|
21098
|
-
onChange
|
|
20897
|
+
onChange,
|
|
20898
|
+
validity: validity?.children
|
|
21099
20899
|
}
|
|
21100
20900
|
)
|
|
21101
20901
|
] });
|
|
@@ -21113,7 +20913,7 @@ function FormRegularField({
|
|
|
21113
20913
|
}
|
|
21114
20914
|
if (labelPosition === "side") {
|
|
21115
20915
|
return /* @__PURE__ */ jsxs25(component_default9, { className: "dataforms-layouts-regular__field", children: [
|
|
21116
|
-
/* @__PURE__ */
|
|
20916
|
+
/* @__PURE__ */ jsx100(
|
|
21117
20917
|
"div",
|
|
21118
20918
|
{
|
|
21119
20919
|
className: clsx39(
|
|
@@ -21123,40 +20923,42 @@ function FormRegularField({
|
|
|
21123
20923
|
children: fieldDefinition.label
|
|
21124
20924
|
}
|
|
21125
20925
|
),
|
|
21126
|
-
/* @__PURE__ */
|
|
20926
|
+
/* @__PURE__ */ jsx100("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ jsx100(
|
|
21127
20927
|
fieldDefinition.render,
|
|
21128
20928
|
{
|
|
21129
20929
|
item: data,
|
|
21130
20930
|
field: fieldDefinition
|
|
21131
20931
|
}
|
|
21132
|
-
) : /* @__PURE__ */
|
|
20932
|
+
) : /* @__PURE__ */ jsx100(
|
|
21133
20933
|
fieldDefinition.Edit,
|
|
21134
20934
|
{
|
|
21135
20935
|
data,
|
|
21136
20936
|
field: fieldDefinition,
|
|
21137
20937
|
onChange,
|
|
21138
|
-
hideLabelFromVision: true
|
|
20938
|
+
hideLabelFromVision: true,
|
|
20939
|
+
validity
|
|
21139
20940
|
},
|
|
21140
20941
|
fieldDefinition.id
|
|
21141
20942
|
) })
|
|
21142
20943
|
] });
|
|
21143
20944
|
}
|
|
21144
|
-
return /* @__PURE__ */
|
|
21145
|
-
!hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */
|
|
21146
|
-
/* @__PURE__ */
|
|
20945
|
+
return /* @__PURE__ */ jsx100("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ jsx100(Fragment12, { children: /* @__PURE__ */ jsxs25(Fragment12, { children: [
|
|
20946
|
+
!hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ jsx100(base_control_default.VisualLabel, { children: fieldDefinition.label }),
|
|
20947
|
+
/* @__PURE__ */ jsx100(
|
|
21147
20948
|
fieldDefinition.render,
|
|
21148
20949
|
{
|
|
21149
20950
|
item: data,
|
|
21150
20951
|
field: fieldDefinition
|
|
21151
20952
|
}
|
|
21152
20953
|
)
|
|
21153
|
-
] }) }) : /* @__PURE__ */
|
|
20954
|
+
] }) }) : /* @__PURE__ */ jsx100(
|
|
21154
20955
|
fieldDefinition.Edit,
|
|
21155
20956
|
{
|
|
21156
20957
|
data,
|
|
21157
20958
|
field: fieldDefinition,
|
|
21158
20959
|
onChange,
|
|
21159
|
-
hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision
|
|
20960
|
+
hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
|
|
20961
|
+
validity
|
|
21160
20962
|
}
|
|
21161
20963
|
) });
|
|
21162
20964
|
}
|
|
@@ -21168,8 +20970,8 @@ import clsx40 from "clsx";
|
|
|
21168
20970
|
import { __ as __48 } from "@wordpress/i18n";
|
|
21169
20971
|
|
|
21170
20972
|
// src/dataform-layouts/panel/summary-button.tsx
|
|
21171
|
-
import { sprintf as
|
|
21172
|
-
import { jsx as
|
|
20973
|
+
import { sprintf as sprintf15, _x as _x5 } from "@wordpress/i18n";
|
|
20974
|
+
import { jsx as jsx101 } from "react/jsx-runtime";
|
|
21173
20975
|
function SummaryButton({
|
|
21174
20976
|
summaryFields,
|
|
21175
20977
|
data,
|
|
@@ -21179,14 +20981,14 @@ function SummaryButton({
|
|
|
21179
20981
|
onClick,
|
|
21180
20982
|
"aria-expanded": ariaExpanded
|
|
21181
20983
|
}) {
|
|
21182
|
-
return /* @__PURE__ */
|
|
20984
|
+
return /* @__PURE__ */ jsx101(
|
|
21183
20985
|
button_default,
|
|
21184
20986
|
{
|
|
21185
20987
|
className: "dataforms-layouts-panel__summary-button",
|
|
21186
20988
|
size: "compact",
|
|
21187
20989
|
variant: ["none", "top"].includes(labelPosition) ? "link" : "tertiary",
|
|
21188
20990
|
"aria-expanded": ariaExpanded,
|
|
21189
|
-
"aria-label":
|
|
20991
|
+
"aria-label": sprintf15(
|
|
21190
20992
|
// translators: %s: Field name.
|
|
21191
20993
|
_x5("Edit %s", "field"),
|
|
21192
20994
|
fieldLabel || ""
|
|
@@ -21199,7 +21001,7 @@ function SummaryButton({
|
|
|
21199
21001
|
height: "auto",
|
|
21200
21002
|
alignItems: "flex-start"
|
|
21201
21003
|
} : void 0,
|
|
21202
|
-
children: summaryFields.length > 1 ? /* @__PURE__ */
|
|
21004
|
+
children: summaryFields.length > 1 ? /* @__PURE__ */ jsx101(
|
|
21203
21005
|
"div",
|
|
21204
21006
|
{
|
|
21205
21007
|
style: {
|
|
@@ -21209,11 +21011,11 @@ function SummaryButton({
|
|
|
21209
21011
|
width: "100%",
|
|
21210
21012
|
gap: "2px"
|
|
21211
21013
|
},
|
|
21212
|
-
children: summaryFields.map((summaryField) => /* @__PURE__ */
|
|
21014
|
+
children: summaryFields.map((summaryField) => /* @__PURE__ */ jsx101(
|
|
21213
21015
|
"div",
|
|
21214
21016
|
{
|
|
21215
21017
|
style: { width: "100%" },
|
|
21216
|
-
children: /* @__PURE__ */
|
|
21018
|
+
children: /* @__PURE__ */ jsx101(
|
|
21217
21019
|
summaryField.render,
|
|
21218
21020
|
{
|
|
21219
21021
|
item: data,
|
|
@@ -21224,7 +21026,7 @@ function SummaryButton({
|
|
|
21224
21026
|
summaryField.id
|
|
21225
21027
|
))
|
|
21226
21028
|
}
|
|
21227
|
-
) : summaryFields.map((summaryField) => /* @__PURE__ */
|
|
21029
|
+
) : summaryFields.map((summaryField) => /* @__PURE__ */ jsx101(
|
|
21228
21030
|
summaryField.render,
|
|
21229
21031
|
{
|
|
21230
21032
|
item: data,
|
|
@@ -21238,20 +21040,20 @@ function SummaryButton({
|
|
|
21238
21040
|
var summary_button_default = SummaryButton;
|
|
21239
21041
|
|
|
21240
21042
|
// src/dataform-layouts/panel/dropdown.tsx
|
|
21241
|
-
import { Fragment as Fragment13, jsx as
|
|
21043
|
+
import { Fragment as Fragment13, jsx as jsx102, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
21242
21044
|
function DropdownHeader({
|
|
21243
21045
|
title,
|
|
21244
21046
|
onClose
|
|
21245
21047
|
}) {
|
|
21246
|
-
return /* @__PURE__ */
|
|
21048
|
+
return /* @__PURE__ */ jsx102(
|
|
21247
21049
|
component_default14,
|
|
21248
21050
|
{
|
|
21249
21051
|
className: "dataforms-layouts-panel__dropdown-header",
|
|
21250
21052
|
spacing: 4,
|
|
21251
21053
|
children: /* @__PURE__ */ jsxs26(component_default9, { alignment: "center", children: [
|
|
21252
|
-
title && /* @__PURE__ */
|
|
21253
|
-
/* @__PURE__ */
|
|
21254
|
-
onClose && /* @__PURE__ */
|
|
21054
|
+
title && /* @__PURE__ */ jsx102(component_default15, { level: 2, size: 13, children: title }),
|
|
21055
|
+
/* @__PURE__ */ jsx102(component_default6, {}),
|
|
21056
|
+
onClose && /* @__PURE__ */ jsx102(
|
|
21255
21057
|
button_default,
|
|
21256
21058
|
{
|
|
21257
21059
|
label: __48("Close"),
|
|
@@ -21265,13 +21067,14 @@ function DropdownHeader({
|
|
|
21265
21067
|
);
|
|
21266
21068
|
}
|
|
21267
21069
|
function PanelDropdown({
|
|
21268
|
-
fieldDefinition,
|
|
21269
|
-
summaryFields,
|
|
21270
|
-
popoverAnchor,
|
|
21271
|
-
labelPosition = "side",
|
|
21272
21070
|
data,
|
|
21071
|
+
field,
|
|
21273
21072
|
onChange,
|
|
21274
|
-
|
|
21073
|
+
validity,
|
|
21074
|
+
labelPosition = "side",
|
|
21075
|
+
summaryFields,
|
|
21076
|
+
fieldDefinition,
|
|
21077
|
+
popoverAnchor
|
|
21275
21078
|
}) {
|
|
21276
21079
|
const fieldLabel = isCombinedField(field) ? field.label : fieldDefinition?.label;
|
|
21277
21080
|
const form = useMemo(
|
|
@@ -21284,6 +21087,15 @@ function PanelDropdown({
|
|
|
21284
21087
|
}),
|
|
21285
21088
|
[field]
|
|
21286
21089
|
);
|
|
21090
|
+
const formValidity = useMemo(() => {
|
|
21091
|
+
if (validity === void 0) {
|
|
21092
|
+
return void 0;
|
|
21093
|
+
}
|
|
21094
|
+
if (isCombinedField(field)) {
|
|
21095
|
+
return validity?.children;
|
|
21096
|
+
}
|
|
21097
|
+
return { [field.id]: validity };
|
|
21098
|
+
}, [validity, field]);
|
|
21287
21099
|
const popoverProps = useMemo(
|
|
21288
21100
|
() => ({
|
|
21289
21101
|
// Anchor the popover to the middle of the entire row so that it doesn't
|
|
@@ -21295,7 +21107,7 @@ function PanelDropdown({
|
|
|
21295
21107
|
}),
|
|
21296
21108
|
[popoverAnchor]
|
|
21297
21109
|
);
|
|
21298
|
-
return /* @__PURE__ */
|
|
21110
|
+
return /* @__PURE__ */ jsx102(
|
|
21299
21111
|
dropdown_default,
|
|
21300
21112
|
{
|
|
21301
21113
|
contentClassName: "dataforms-layouts-panel__field-dropdown",
|
|
@@ -21306,7 +21118,7 @@ function PanelDropdown({
|
|
|
21306
21118
|
variant: "tertiary",
|
|
21307
21119
|
tooltipPosition: "middle left"
|
|
21308
21120
|
},
|
|
21309
|
-
renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */
|
|
21121
|
+
renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ jsx102(
|
|
21310
21122
|
summary_button_default,
|
|
21311
21123
|
{
|
|
21312
21124
|
summaryFields,
|
|
@@ -21319,22 +21131,24 @@ function PanelDropdown({
|
|
|
21319
21131
|
}
|
|
21320
21132
|
),
|
|
21321
21133
|
renderContent: ({ onClose }) => /* @__PURE__ */ jsxs26(Fragment13, { children: [
|
|
21322
|
-
/* @__PURE__ */
|
|
21323
|
-
/* @__PURE__ */
|
|
21134
|
+
/* @__PURE__ */ jsx102(DropdownHeader, { title: fieldLabel, onClose }),
|
|
21135
|
+
/* @__PURE__ */ jsx102(
|
|
21324
21136
|
DataFormLayout,
|
|
21325
21137
|
{
|
|
21326
21138
|
data,
|
|
21327
21139
|
form,
|
|
21328
21140
|
onChange,
|
|
21329
|
-
|
|
21141
|
+
validity: formValidity,
|
|
21142
|
+
children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ jsx102(
|
|
21330
21143
|
FieldLayout,
|
|
21331
21144
|
{
|
|
21332
21145
|
data,
|
|
21333
|
-
field:
|
|
21146
|
+
field: childField,
|
|
21334
21147
|
onChange,
|
|
21335
|
-
hideLabelFromVision: (form?.fields ?? []).length < 2
|
|
21148
|
+
hideLabelFromVision: (form?.fields ?? []).length < 2,
|
|
21149
|
+
validity: childFieldValidity
|
|
21336
21150
|
},
|
|
21337
|
-
|
|
21151
|
+
childField.id
|
|
21338
21152
|
)
|
|
21339
21153
|
}
|
|
21340
21154
|
)
|
|
@@ -21345,26 +21159,430 @@ function PanelDropdown({
|
|
|
21345
21159
|
var dropdown_default2 = PanelDropdown;
|
|
21346
21160
|
|
|
21347
21161
|
// src/dataform-layouts/panel/modal.tsx
|
|
21348
|
-
import
|
|
21162
|
+
import deepMerge2 from "deepmerge";
|
|
21163
|
+
import { __ as __50 } from "@wordpress/i18n";
|
|
21164
|
+
|
|
21165
|
+
// src/hooks/use-form-validity.ts
|
|
21166
|
+
import deepMerge from "deepmerge";
|
|
21349
21167
|
import { __ as __49 } from "@wordpress/i18n";
|
|
21350
|
-
|
|
21168
|
+
var isEmptyNullOrUndefined = (value) => [void 0, "", null].includes(value);
|
|
21169
|
+
var isArrayOrElementsEmptyNullOrUndefined = (value) => {
|
|
21170
|
+
return !Array.isArray(value) || value.length === 0 || value.every((element) => isEmptyNullOrUndefined(element));
|
|
21171
|
+
};
|
|
21172
|
+
function isInvalidForRequired(fieldType, value) {
|
|
21173
|
+
if (fieldType === void 0 && isEmptyNullOrUndefined(value) || fieldType === "text" && isEmptyNullOrUndefined(value) || fieldType === "email" && isEmptyNullOrUndefined(value) || fieldType === "url" && isEmptyNullOrUndefined(value) || fieldType === "telephone" && isEmptyNullOrUndefined(value) || fieldType === "password" && isEmptyNullOrUndefined(value) || fieldType === "integer" && isEmptyNullOrUndefined(value) || fieldType === "number" && isEmptyNullOrUndefined(value) || fieldType === "array" && isArrayOrElementsEmptyNullOrUndefined(value) || fieldType === "boolean" && value !== true) {
|
|
21174
|
+
return true;
|
|
21175
|
+
}
|
|
21176
|
+
return false;
|
|
21177
|
+
}
|
|
21178
|
+
function isFormValid(formValidity) {
|
|
21179
|
+
if (!formValidity) {
|
|
21180
|
+
return true;
|
|
21181
|
+
}
|
|
21182
|
+
return Object.values(formValidity).every((fieldValidation) => {
|
|
21183
|
+
return Object.entries(fieldValidation).every(
|
|
21184
|
+
([key, validation]) => {
|
|
21185
|
+
if (key === "children" && validation && typeof validation === "object") {
|
|
21186
|
+
return isFormValid(validation);
|
|
21187
|
+
}
|
|
21188
|
+
return validation.type === "valid";
|
|
21189
|
+
}
|
|
21190
|
+
);
|
|
21191
|
+
});
|
|
21192
|
+
}
|
|
21193
|
+
function updateFieldValidity(setFormValidity, parentFieldId, fieldId, newValidity) {
|
|
21194
|
+
if (parentFieldId) {
|
|
21195
|
+
setFormValidity((prev) => ({
|
|
21196
|
+
...prev,
|
|
21197
|
+
[parentFieldId]: {
|
|
21198
|
+
...prev?.[parentFieldId],
|
|
21199
|
+
children: {
|
|
21200
|
+
...prev?.[parentFieldId]?.children,
|
|
21201
|
+
[fieldId]: {
|
|
21202
|
+
...newValidity
|
|
21203
|
+
}
|
|
21204
|
+
}
|
|
21205
|
+
}
|
|
21206
|
+
}));
|
|
21207
|
+
} else {
|
|
21208
|
+
setFormValidity((prev) => ({
|
|
21209
|
+
...prev,
|
|
21210
|
+
[fieldId]: {
|
|
21211
|
+
...newValidity
|
|
21212
|
+
}
|
|
21213
|
+
}));
|
|
21214
|
+
}
|
|
21215
|
+
}
|
|
21216
|
+
function getFieldsToValidate(fields, form) {
|
|
21217
|
+
const formFields = normalizeFormFields(form);
|
|
21218
|
+
if (formFields.length === 0) {
|
|
21219
|
+
return { fields: [], fieldToParent: /* @__PURE__ */ new Map() };
|
|
21220
|
+
}
|
|
21221
|
+
const fieldToParent = /* @__PURE__ */ new Map();
|
|
21222
|
+
const fieldIdsToValidate = [];
|
|
21223
|
+
formFields.forEach((formField) => {
|
|
21224
|
+
if (!!formField.children) {
|
|
21225
|
+
formField.children.forEach((child) => {
|
|
21226
|
+
const childId = typeof child === "string" ? child : child.id;
|
|
21227
|
+
fieldIdsToValidate.push(childId);
|
|
21228
|
+
fieldToParent.set(childId, formField.id);
|
|
21229
|
+
});
|
|
21230
|
+
} else {
|
|
21231
|
+
fieldIdsToValidate.push(formField.id);
|
|
21232
|
+
}
|
|
21233
|
+
});
|
|
21234
|
+
return {
|
|
21235
|
+
fields: normalizeFields(
|
|
21236
|
+
fields.filter(
|
|
21237
|
+
(field) => fieldIdsToValidate.includes(field.id)
|
|
21238
|
+
)
|
|
21239
|
+
),
|
|
21240
|
+
fieldToParent
|
|
21241
|
+
};
|
|
21242
|
+
}
|
|
21243
|
+
function useFormValidity(item2, fields, form) {
|
|
21244
|
+
const [formValidity, setFormValidity] = useState();
|
|
21245
|
+
const previousValidatedValuesRef = useRef({});
|
|
21246
|
+
const customValidationCounterRef = useRef({});
|
|
21247
|
+
const elementsValidationCounterRef = useRef(
|
|
21248
|
+
{}
|
|
21249
|
+
);
|
|
21250
|
+
const validate = useCallback(() => {
|
|
21251
|
+
const { fields: fieldsToValidate, fieldToParent } = getFieldsToValidate(
|
|
21252
|
+
fields,
|
|
21253
|
+
form
|
|
21254
|
+
);
|
|
21255
|
+
if (fieldsToValidate.length === 0) {
|
|
21256
|
+
setFormValidity(void 0);
|
|
21257
|
+
return;
|
|
21258
|
+
}
|
|
21259
|
+
fieldsToValidate.forEach((field) => {
|
|
21260
|
+
const value = field.getValue({ item: item2 });
|
|
21261
|
+
if (previousValidatedValuesRef.current.hasOwnProperty(field.id) && value === previousValidatedValuesRef.current[field.id]) {
|
|
21262
|
+
return;
|
|
21263
|
+
}
|
|
21264
|
+
previousValidatedValuesRef.current[field.id] = value;
|
|
21265
|
+
const parentFieldId = fieldToParent.get(field.id);
|
|
21266
|
+
if (field.isValid.required && isInvalidForRequired(field.type, value)) {
|
|
21267
|
+
updateFieldValidity(setFormValidity, parentFieldId, field.id, {
|
|
21268
|
+
required: { type: "invalid" }
|
|
21269
|
+
});
|
|
21270
|
+
return;
|
|
21271
|
+
}
|
|
21272
|
+
if (field.isValid.elements && field.hasElements && !field.getElements && Array.isArray(field.elements)) {
|
|
21273
|
+
const validValues = field.elements.map((el) => el.value);
|
|
21274
|
+
if (field.type !== "array" && !validValues.includes(value)) {
|
|
21275
|
+
updateFieldValidity(
|
|
21276
|
+
setFormValidity,
|
|
21277
|
+
parentFieldId,
|
|
21278
|
+
field.id,
|
|
21279
|
+
{
|
|
21280
|
+
elements: {
|
|
21281
|
+
type: "invalid",
|
|
21282
|
+
message: "Value must be one of the elements."
|
|
21283
|
+
}
|
|
21284
|
+
}
|
|
21285
|
+
);
|
|
21286
|
+
return;
|
|
21287
|
+
}
|
|
21288
|
+
if (field.type === "array" && !Array.isArray(value)) {
|
|
21289
|
+
updateFieldValidity(
|
|
21290
|
+
setFormValidity,
|
|
21291
|
+
parentFieldId,
|
|
21292
|
+
field.id,
|
|
21293
|
+
{
|
|
21294
|
+
elements: {
|
|
21295
|
+
type: "invalid",
|
|
21296
|
+
message: "Value must be an array."
|
|
21297
|
+
}
|
|
21298
|
+
}
|
|
21299
|
+
);
|
|
21300
|
+
return;
|
|
21301
|
+
}
|
|
21302
|
+
if (field.type === "array" && value.some((v) => !validValues.includes(v))) {
|
|
21303
|
+
updateFieldValidity(
|
|
21304
|
+
setFormValidity,
|
|
21305
|
+
parentFieldId,
|
|
21306
|
+
field.id,
|
|
21307
|
+
{
|
|
21308
|
+
elements: {
|
|
21309
|
+
type: "invalid",
|
|
21310
|
+
message: "Value must be one of the elements."
|
|
21311
|
+
}
|
|
21312
|
+
}
|
|
21313
|
+
);
|
|
21314
|
+
return;
|
|
21315
|
+
}
|
|
21316
|
+
}
|
|
21317
|
+
if (field.isValid.elements && field.hasElements && typeof field.getElements === "function") {
|
|
21318
|
+
const currentToken = (elementsValidationCounterRef.current[field.id] || 0) + 1;
|
|
21319
|
+
elementsValidationCounterRef.current[field.id] = currentToken;
|
|
21320
|
+
updateFieldValidity(setFormValidity, parentFieldId, field.id, {
|
|
21321
|
+
elements: {
|
|
21322
|
+
type: "validating",
|
|
21323
|
+
message: "Validating..."
|
|
21324
|
+
}
|
|
21325
|
+
});
|
|
21326
|
+
field.getElements().then((result) => {
|
|
21327
|
+
if (elementsValidationCounterRef.current[field.id] !== currentToken) {
|
|
21328
|
+
return;
|
|
21329
|
+
}
|
|
21330
|
+
if (!Array.isArray(result)) {
|
|
21331
|
+
updateFieldValidity(
|
|
21332
|
+
setFormValidity,
|
|
21333
|
+
parentFieldId,
|
|
21334
|
+
field.id,
|
|
21335
|
+
{
|
|
21336
|
+
elements: {
|
|
21337
|
+
type: "invalid",
|
|
21338
|
+
message: "Could not validate elements."
|
|
21339
|
+
}
|
|
21340
|
+
}
|
|
21341
|
+
);
|
|
21342
|
+
return;
|
|
21343
|
+
}
|
|
21344
|
+
const validValues = result.map((el) => el.value);
|
|
21345
|
+
if (field.type !== "array" && !validValues.includes(value)) {
|
|
21346
|
+
updateFieldValidity(
|
|
21347
|
+
setFormValidity,
|
|
21348
|
+
parentFieldId,
|
|
21349
|
+
field.id,
|
|
21350
|
+
{
|
|
21351
|
+
elements: {
|
|
21352
|
+
type: "invalid",
|
|
21353
|
+
message: "Value must be one of the elements."
|
|
21354
|
+
}
|
|
21355
|
+
}
|
|
21356
|
+
);
|
|
21357
|
+
return;
|
|
21358
|
+
}
|
|
21359
|
+
if (field.type === "array" && !Array.isArray(value)) {
|
|
21360
|
+
updateFieldValidity(
|
|
21361
|
+
setFormValidity,
|
|
21362
|
+
parentFieldId,
|
|
21363
|
+
field.id,
|
|
21364
|
+
{
|
|
21365
|
+
elements: {
|
|
21366
|
+
type: "invalid",
|
|
21367
|
+
message: "Value must be an array."
|
|
21368
|
+
}
|
|
21369
|
+
}
|
|
21370
|
+
);
|
|
21371
|
+
return;
|
|
21372
|
+
}
|
|
21373
|
+
if (field.type === "array" && value.some(
|
|
21374
|
+
(v) => !validValues.includes(v)
|
|
21375
|
+
)) {
|
|
21376
|
+
updateFieldValidity(
|
|
21377
|
+
setFormValidity,
|
|
21378
|
+
parentFieldId,
|
|
21379
|
+
field.id,
|
|
21380
|
+
{
|
|
21381
|
+
elements: {
|
|
21382
|
+
type: "invalid",
|
|
21383
|
+
message: "Value must be one of the elements."
|
|
21384
|
+
}
|
|
21385
|
+
}
|
|
21386
|
+
);
|
|
21387
|
+
}
|
|
21388
|
+
}).catch((error) => {
|
|
21389
|
+
if (elementsValidationCounterRef.current[field.id] !== currentToken) {
|
|
21390
|
+
return;
|
|
21391
|
+
}
|
|
21392
|
+
updateFieldValidity(
|
|
21393
|
+
setFormValidity,
|
|
21394
|
+
parentFieldId,
|
|
21395
|
+
field.id,
|
|
21396
|
+
{
|
|
21397
|
+
elements: {
|
|
21398
|
+
type: "invalid",
|
|
21399
|
+
message: error.message
|
|
21400
|
+
}
|
|
21401
|
+
}
|
|
21402
|
+
);
|
|
21403
|
+
});
|
|
21404
|
+
}
|
|
21405
|
+
let customError;
|
|
21406
|
+
try {
|
|
21407
|
+
customError = field.isValid?.custom?.(
|
|
21408
|
+
deepMerge(
|
|
21409
|
+
item2,
|
|
21410
|
+
field.setValue({
|
|
21411
|
+
item: item2,
|
|
21412
|
+
value
|
|
21413
|
+
})
|
|
21414
|
+
),
|
|
21415
|
+
field
|
|
21416
|
+
);
|
|
21417
|
+
} catch (error) {
|
|
21418
|
+
let errorMessage;
|
|
21419
|
+
if (error instanceof Error) {
|
|
21420
|
+
errorMessage = error.message;
|
|
21421
|
+
} else {
|
|
21422
|
+
errorMessage = String(error) || __49("Unknown error when running custom validation.");
|
|
21423
|
+
}
|
|
21424
|
+
updateFieldValidity(setFormValidity, parentFieldId, field.id, {
|
|
21425
|
+
custom: {
|
|
21426
|
+
type: "invalid",
|
|
21427
|
+
message: errorMessage
|
|
21428
|
+
}
|
|
21429
|
+
});
|
|
21430
|
+
}
|
|
21431
|
+
if (typeof customError === "string") {
|
|
21432
|
+
updateFieldValidity(setFormValidity, parentFieldId, field.id, {
|
|
21433
|
+
custom: {
|
|
21434
|
+
type: "invalid",
|
|
21435
|
+
message: customError
|
|
21436
|
+
}
|
|
21437
|
+
});
|
|
21438
|
+
return;
|
|
21439
|
+
}
|
|
21440
|
+
if (customError instanceof Promise) {
|
|
21441
|
+
const currentToken = (customValidationCounterRef.current[field.id] || 0) + 1;
|
|
21442
|
+
customValidationCounterRef.current[field.id] = currentToken;
|
|
21443
|
+
updateFieldValidity(setFormValidity, parentFieldId, field.id, {
|
|
21444
|
+
custom: {
|
|
21445
|
+
type: "validating",
|
|
21446
|
+
message: "Validating..."
|
|
21447
|
+
}
|
|
21448
|
+
});
|
|
21449
|
+
customError.then((result) => {
|
|
21450
|
+
if (customValidationCounterRef.current[field.id] !== currentToken) {
|
|
21451
|
+
return;
|
|
21452
|
+
}
|
|
21453
|
+
if (result === null) {
|
|
21454
|
+
updateFieldValidity(
|
|
21455
|
+
setFormValidity,
|
|
21456
|
+
parentFieldId,
|
|
21457
|
+
field.id,
|
|
21458
|
+
{
|
|
21459
|
+
custom: {
|
|
21460
|
+
type: "valid",
|
|
21461
|
+
message: "Valid"
|
|
21462
|
+
}
|
|
21463
|
+
}
|
|
21464
|
+
);
|
|
21465
|
+
return;
|
|
21466
|
+
}
|
|
21467
|
+
if (typeof result === "string") {
|
|
21468
|
+
updateFieldValidity(
|
|
21469
|
+
setFormValidity,
|
|
21470
|
+
parentFieldId,
|
|
21471
|
+
field.id,
|
|
21472
|
+
{
|
|
21473
|
+
custom: {
|
|
21474
|
+
type: "invalid",
|
|
21475
|
+
message: result
|
|
21476
|
+
}
|
|
21477
|
+
}
|
|
21478
|
+
);
|
|
21479
|
+
}
|
|
21480
|
+
}).catch((error) => {
|
|
21481
|
+
if (customValidationCounterRef.current[field.id] !== currentToken) {
|
|
21482
|
+
return;
|
|
21483
|
+
}
|
|
21484
|
+
updateFieldValidity(
|
|
21485
|
+
setFormValidity,
|
|
21486
|
+
parentFieldId,
|
|
21487
|
+
field.id,
|
|
21488
|
+
{
|
|
21489
|
+
custom: {
|
|
21490
|
+
type: "invalid",
|
|
21491
|
+
message: error.message
|
|
21492
|
+
}
|
|
21493
|
+
}
|
|
21494
|
+
);
|
|
21495
|
+
});
|
|
21496
|
+
return;
|
|
21497
|
+
}
|
|
21498
|
+
setFormValidity((prev) => {
|
|
21499
|
+
if (!prev) {
|
|
21500
|
+
return prev;
|
|
21501
|
+
}
|
|
21502
|
+
if (parentFieldId) {
|
|
21503
|
+
const parentField = prev[parentFieldId];
|
|
21504
|
+
if (!parentField?.children) {
|
|
21505
|
+
return prev;
|
|
21506
|
+
}
|
|
21507
|
+
const { [field.id]: removed2, ...restChildren } = parentField.children;
|
|
21508
|
+
if (Object.keys(restChildren).length === 0) {
|
|
21509
|
+
const { children, ...restParent } = parentField;
|
|
21510
|
+
if (Object.keys(restParent).length === 0) {
|
|
21511
|
+
const {
|
|
21512
|
+
[parentFieldId]: removedParent,
|
|
21513
|
+
...restFields
|
|
21514
|
+
} = prev;
|
|
21515
|
+
return Object.keys(restFields).length === 0 ? void 0 : restFields;
|
|
21516
|
+
}
|
|
21517
|
+
return {
|
|
21518
|
+
...prev,
|
|
21519
|
+
[parentFieldId]: restParent
|
|
21520
|
+
};
|
|
21521
|
+
}
|
|
21522
|
+
return {
|
|
21523
|
+
...prev,
|
|
21524
|
+
[parentFieldId]: {
|
|
21525
|
+
...parentField,
|
|
21526
|
+
children: restChildren
|
|
21527
|
+
}
|
|
21528
|
+
};
|
|
21529
|
+
}
|
|
21530
|
+
if (!prev[field.id]) {
|
|
21531
|
+
return prev;
|
|
21532
|
+
}
|
|
21533
|
+
const { [field.id]: removed, ...rest } = prev;
|
|
21534
|
+
if (Object.keys(rest).length === 0) {
|
|
21535
|
+
return void 0;
|
|
21536
|
+
}
|
|
21537
|
+
return rest;
|
|
21538
|
+
});
|
|
21539
|
+
});
|
|
21540
|
+
}, [item2, fields, form]);
|
|
21541
|
+
useEffect(() => {
|
|
21542
|
+
validate();
|
|
21543
|
+
}, [validate]);
|
|
21544
|
+
return {
|
|
21545
|
+
validity: formValidity,
|
|
21546
|
+
isValid: isFormValid(formValidity)
|
|
21547
|
+
};
|
|
21548
|
+
}
|
|
21549
|
+
var use_form_validity_default = useFormValidity;
|
|
21550
|
+
|
|
21551
|
+
// src/dataform-layouts/panel/modal.tsx
|
|
21552
|
+
import { Fragment as Fragment14, jsx as jsx103, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
21351
21553
|
function ModalContent({
|
|
21352
21554
|
data,
|
|
21353
|
-
|
|
21354
|
-
fieldLabel,
|
|
21555
|
+
field,
|
|
21355
21556
|
onChange,
|
|
21557
|
+
fieldLabel,
|
|
21356
21558
|
onClose
|
|
21357
21559
|
}) {
|
|
21560
|
+
const { fields } = useContext(dataform_context_default);
|
|
21358
21561
|
const [changes, setChanges] = useState({});
|
|
21359
21562
|
const modalData = useMemo(() => {
|
|
21360
|
-
return
|
|
21563
|
+
return deepMerge2(data, changes);
|
|
21361
21564
|
}, [data, changes]);
|
|
21565
|
+
const form = useMemo(
|
|
21566
|
+
() => ({
|
|
21567
|
+
layout: DEFAULT_LAYOUT,
|
|
21568
|
+
fields: isCombinedField(field) ? field.children : (
|
|
21569
|
+
// If not explicit children return the field id itself.
|
|
21570
|
+
[{ id: field.id }]
|
|
21571
|
+
)
|
|
21572
|
+
}),
|
|
21573
|
+
[field]
|
|
21574
|
+
);
|
|
21575
|
+
const { validity } = use_form_validity_default(
|
|
21576
|
+
modalData,
|
|
21577
|
+
fields,
|
|
21578
|
+
form
|
|
21579
|
+
);
|
|
21362
21580
|
const onApply = () => {
|
|
21363
21581
|
onChange(changes);
|
|
21364
21582
|
onClose();
|
|
21365
21583
|
};
|
|
21366
21584
|
const handleOnChange = (newValue) => {
|
|
21367
|
-
setChanges((prev) =>
|
|
21585
|
+
setChanges((prev) => deepMerge2(prev, newValue));
|
|
21368
21586
|
};
|
|
21369
21587
|
return /* @__PURE__ */ jsxs27(
|
|
21370
21588
|
modal_default,
|
|
@@ -21375,21 +21593,23 @@ function ModalContent({
|
|
|
21375
21593
|
title: fieldLabel,
|
|
21376
21594
|
size: "medium",
|
|
21377
21595
|
children: [
|
|
21378
|
-
/* @__PURE__ */
|
|
21596
|
+
/* @__PURE__ */ jsx103(
|
|
21379
21597
|
DataFormLayout,
|
|
21380
21598
|
{
|
|
21381
21599
|
data: modalData,
|
|
21382
21600
|
form,
|
|
21383
21601
|
onChange: handleOnChange,
|
|
21384
|
-
|
|
21602
|
+
validity,
|
|
21603
|
+
children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ jsx103(
|
|
21385
21604
|
FieldLayout,
|
|
21386
21605
|
{
|
|
21387
21606
|
data: modalData,
|
|
21388
|
-
field:
|
|
21607
|
+
field: childField,
|
|
21389
21608
|
onChange: handleOnChange,
|
|
21390
|
-
hideLabelFromVision: (form?.fields ?? []).length < 2
|
|
21609
|
+
hideLabelFromVision: (form?.fields ?? []).length < 2,
|
|
21610
|
+
validity: childFieldValidity
|
|
21391
21611
|
},
|
|
21392
|
-
|
|
21612
|
+
childField.id
|
|
21393
21613
|
)
|
|
21394
21614
|
}
|
|
21395
21615
|
),
|
|
@@ -21399,23 +21619,23 @@ function ModalContent({
|
|
|
21399
21619
|
className: "dataforms-layouts-panel__modal-footer",
|
|
21400
21620
|
spacing: 3,
|
|
21401
21621
|
children: [
|
|
21402
|
-
/* @__PURE__ */
|
|
21403
|
-
/* @__PURE__ */
|
|
21622
|
+
/* @__PURE__ */ jsx103(component_default6, {}),
|
|
21623
|
+
/* @__PURE__ */ jsx103(
|
|
21404
21624
|
button_default,
|
|
21405
21625
|
{
|
|
21406
21626
|
variant: "tertiary",
|
|
21407
21627
|
onClick: onClose,
|
|
21408
21628
|
__next40pxDefaultSize: true,
|
|
21409
|
-
children:
|
|
21629
|
+
children: __50("Cancel")
|
|
21410
21630
|
}
|
|
21411
21631
|
),
|
|
21412
|
-
/* @__PURE__ */
|
|
21632
|
+
/* @__PURE__ */ jsx103(
|
|
21413
21633
|
button_default,
|
|
21414
21634
|
{
|
|
21415
21635
|
variant: "primary",
|
|
21416
21636
|
onClick: onApply,
|
|
21417
21637
|
__next40pxDefaultSize: true,
|
|
21418
|
-
children:
|
|
21638
|
+
children: __50("Apply")
|
|
21419
21639
|
}
|
|
21420
21640
|
)
|
|
21421
21641
|
]
|
|
@@ -21426,27 +21646,17 @@ function ModalContent({
|
|
|
21426
21646
|
);
|
|
21427
21647
|
}
|
|
21428
21648
|
function PanelModal({
|
|
21429
|
-
fieldDefinition,
|
|
21430
|
-
summaryFields,
|
|
21431
|
-
labelPosition,
|
|
21432
21649
|
data,
|
|
21650
|
+
field,
|
|
21433
21651
|
onChange,
|
|
21434
|
-
|
|
21652
|
+
labelPosition,
|
|
21653
|
+
summaryFields,
|
|
21654
|
+
fieldDefinition
|
|
21435
21655
|
}) {
|
|
21436
21656
|
const [isOpen, setIsOpen] = useState(false);
|
|
21437
21657
|
const fieldLabel = isCombinedField(field) ? field.label : fieldDefinition?.label;
|
|
21438
|
-
const form = useMemo(
|
|
21439
|
-
() => ({
|
|
21440
|
-
layout: DEFAULT_LAYOUT,
|
|
21441
|
-
fields: isCombinedField(field) ? field.children : (
|
|
21442
|
-
// If not explicit children return the field id itself.
|
|
21443
|
-
[{ id: field.id }]
|
|
21444
|
-
)
|
|
21445
|
-
}),
|
|
21446
|
-
[field]
|
|
21447
|
-
);
|
|
21448
21658
|
return /* @__PURE__ */ jsxs27(Fragment14, { children: [
|
|
21449
|
-
/* @__PURE__ */
|
|
21659
|
+
/* @__PURE__ */ jsx103(
|
|
21450
21660
|
summary_button_default,
|
|
21451
21661
|
{
|
|
21452
21662
|
summaryFields,
|
|
@@ -21458,13 +21668,13 @@ function PanelModal({
|
|
|
21458
21668
|
"aria-expanded": isOpen
|
|
21459
21669
|
}
|
|
21460
21670
|
),
|
|
21461
|
-
isOpen && /* @__PURE__ */
|
|
21671
|
+
isOpen && /* @__PURE__ */ jsx103(
|
|
21462
21672
|
ModalContent,
|
|
21463
21673
|
{
|
|
21464
21674
|
data,
|
|
21465
|
-
|
|
21466
|
-
fieldLabel: fieldLabel ?? "",
|
|
21675
|
+
field,
|
|
21467
21676
|
onChange,
|
|
21677
|
+
fieldLabel: fieldLabel ?? "",
|
|
21468
21678
|
onClose: () => setIsOpen(false)
|
|
21469
21679
|
}
|
|
21470
21680
|
)
|
|
@@ -21492,7 +21702,7 @@ var getSummaryFields = (summaryField, fields) => {
|
|
|
21492
21702
|
};
|
|
21493
21703
|
|
|
21494
21704
|
// src/dataform-layouts/panel/index.tsx
|
|
21495
|
-
import { jsx as
|
|
21705
|
+
import { jsx as jsx104, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
21496
21706
|
var getFieldDefinition = (field, fields) => {
|
|
21497
21707
|
const fieldDefinition = fields.find((_field) => _field.id === field.id);
|
|
21498
21708
|
if (!fieldDefinition) {
|
|
@@ -21529,7 +21739,8 @@ var getFieldDefinitionAndSummaryFields = (layout, field, fields) => {
|
|
|
21529
21739
|
function FormPanelField({
|
|
21530
21740
|
data,
|
|
21531
21741
|
field,
|
|
21532
|
-
onChange
|
|
21742
|
+
onChange,
|
|
21743
|
+
validity
|
|
21533
21744
|
}) {
|
|
21534
21745
|
const { fields } = useContext(dataform_context_default);
|
|
21535
21746
|
const layout = normalizeLayout({
|
|
@@ -21549,31 +21760,32 @@ function FormPanelField({
|
|
|
21549
21760
|
`dataforms-layouts-panel__field-label--label-position-${labelPosition}`
|
|
21550
21761
|
);
|
|
21551
21762
|
const fieldLabel = isCombinedField(field) ? field.label : fieldDefinition?.label;
|
|
21552
|
-
const renderedControl = layout.openAs === "modal" ? /* @__PURE__ */
|
|
21763
|
+
const renderedControl = layout.openAs === "modal" ? /* @__PURE__ */ jsx104(
|
|
21553
21764
|
modal_default2,
|
|
21554
21765
|
{
|
|
21555
|
-
field,
|
|
21556
|
-
fieldDefinition,
|
|
21557
|
-
summaryFields,
|
|
21558
21766
|
data,
|
|
21767
|
+
field,
|
|
21559
21768
|
onChange,
|
|
21560
|
-
labelPosition
|
|
21769
|
+
labelPosition,
|
|
21770
|
+
summaryFields,
|
|
21771
|
+
fieldDefinition
|
|
21561
21772
|
}
|
|
21562
|
-
) : /* @__PURE__ */
|
|
21773
|
+
) : /* @__PURE__ */ jsx104(
|
|
21563
21774
|
dropdown_default2,
|
|
21564
21775
|
{
|
|
21565
|
-
field,
|
|
21566
|
-
popoverAnchor,
|
|
21567
|
-
fieldDefinition,
|
|
21568
|
-
summaryFields,
|
|
21569
21776
|
data,
|
|
21777
|
+
field,
|
|
21570
21778
|
onChange,
|
|
21571
|
-
|
|
21779
|
+
validity,
|
|
21780
|
+
labelPosition,
|
|
21781
|
+
summaryFields,
|
|
21782
|
+
fieldDefinition,
|
|
21783
|
+
popoverAnchor
|
|
21572
21784
|
}
|
|
21573
21785
|
);
|
|
21574
21786
|
if (labelPosition === "top") {
|
|
21575
21787
|
return /* @__PURE__ */ jsxs28(component_default14, { className: "dataforms-layouts-panel__field", spacing: 0, children: [
|
|
21576
|
-
/* @__PURE__ */
|
|
21788
|
+
/* @__PURE__ */ jsx104(
|
|
21577
21789
|
"div",
|
|
21578
21790
|
{
|
|
21579
21791
|
className: labelClassName,
|
|
@@ -21581,11 +21793,11 @@ function FormPanelField({
|
|
|
21581
21793
|
children: fieldLabel
|
|
21582
21794
|
}
|
|
21583
21795
|
),
|
|
21584
|
-
/* @__PURE__ */
|
|
21796
|
+
/* @__PURE__ */ jsx104("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl })
|
|
21585
21797
|
] });
|
|
21586
21798
|
}
|
|
21587
21799
|
if (labelPosition === "none") {
|
|
21588
|
-
return /* @__PURE__ */
|
|
21800
|
+
return /* @__PURE__ */ jsx104("div", { className: "dataforms-layouts-panel__field", children: renderedControl });
|
|
21589
21801
|
}
|
|
21590
21802
|
return /* @__PURE__ */ jsxs28(
|
|
21591
21803
|
component_default9,
|
|
@@ -21593,15 +21805,15 @@ function FormPanelField({
|
|
|
21593
21805
|
ref: setPopoverAnchor,
|
|
21594
21806
|
className: "dataforms-layouts-panel__field",
|
|
21595
21807
|
children: [
|
|
21596
|
-
/* @__PURE__ */
|
|
21597
|
-
/* @__PURE__ */
|
|
21808
|
+
/* @__PURE__ */ jsx104("div", { className: labelClassName, children: fieldLabel }),
|
|
21809
|
+
/* @__PURE__ */ jsx104("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl })
|
|
21598
21810
|
]
|
|
21599
21811
|
}
|
|
21600
21812
|
);
|
|
21601
21813
|
}
|
|
21602
21814
|
|
|
21603
21815
|
// src/dataform-layouts/card/index.tsx
|
|
21604
|
-
import { jsx as
|
|
21816
|
+
import { jsx as jsx105, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
21605
21817
|
function useCollapsibleCard(initialIsOpen = true) {
|
|
21606
21818
|
const [isOpen, setIsOpen] = useState(initialIsOpen);
|
|
21607
21819
|
const toggle = useCallback(() => {
|
|
@@ -21621,7 +21833,7 @@ function useCollapsibleCard(initialIsOpen = true) {
|
|
|
21621
21833
|
...props.style
|
|
21622
21834
|
},
|
|
21623
21835
|
children: [
|
|
21624
|
-
/* @__PURE__ */
|
|
21836
|
+
/* @__PURE__ */ jsx105(
|
|
21625
21837
|
"div",
|
|
21626
21838
|
{
|
|
21627
21839
|
style: {
|
|
@@ -21633,7 +21845,7 @@ function useCollapsibleCard(initialIsOpen = true) {
|
|
|
21633
21845
|
children
|
|
21634
21846
|
}
|
|
21635
21847
|
),
|
|
21636
|
-
/* @__PURE__ */
|
|
21848
|
+
/* @__PURE__ */ jsx105(
|
|
21637
21849
|
button_default,
|
|
21638
21850
|
{
|
|
21639
21851
|
__next40pxDefaultSize: true,
|
|
@@ -21679,7 +21891,8 @@ function FormCardField({
|
|
|
21679
21891
|
data,
|
|
21680
21892
|
field,
|
|
21681
21893
|
onChange,
|
|
21682
|
-
hideLabelFromVision
|
|
21894
|
+
hideLabelFromVision,
|
|
21895
|
+
validity
|
|
21683
21896
|
}) {
|
|
21684
21897
|
const { fields } = useContext(dataform_context_default);
|
|
21685
21898
|
const layout = normalizeLayout({
|
|
@@ -21704,9 +21917,9 @@ function FormCardField({
|
|
|
21704
21917
|
const withHeader2 = !!field.label && layout.withHeader;
|
|
21705
21918
|
return /* @__PURE__ */ jsxs29(component_default18, { className: "dataforms-layouts-card__field", children: [
|
|
21706
21919
|
withHeader2 && /* @__PURE__ */ jsxs29(CollapsibleCardHeader, { className: "dataforms-layouts-card__field-header", children: [
|
|
21707
|
-
/* @__PURE__ */
|
|
21708
|
-
visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */
|
|
21709
|
-
(summaryField) => /* @__PURE__ */
|
|
21920
|
+
/* @__PURE__ */ jsx105("span", { className: "dataforms-layouts-card__field-header-label", children: field.label }),
|
|
21921
|
+
visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */ jsx105("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map(
|
|
21922
|
+
(summaryField) => /* @__PURE__ */ jsx105(
|
|
21710
21923
|
summaryField.render,
|
|
21711
21924
|
{
|
|
21712
21925
|
item: data,
|
|
@@ -21719,13 +21932,14 @@ function FormCardField({
|
|
|
21719
21932
|
(isOpen || !withHeader2) && // If it doesn't have a header, keep it open.
|
|
21720
21933
|
// Otherwise, the card will not be visible.
|
|
21721
21934
|
/* @__PURE__ */ jsxs29(component_default20, { className: "dataforms-layouts-card__field-control", children: [
|
|
21722
|
-
field.description && /* @__PURE__ */
|
|
21723
|
-
/* @__PURE__ */
|
|
21935
|
+
field.description && /* @__PURE__ */ jsx105("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
|
|
21936
|
+
/* @__PURE__ */ jsx105(
|
|
21724
21937
|
DataFormLayout,
|
|
21725
21938
|
{
|
|
21726
21939
|
data,
|
|
21727
21940
|
form,
|
|
21728
|
-
onChange
|
|
21941
|
+
onChange,
|
|
21942
|
+
validity: validity?.children
|
|
21729
21943
|
}
|
|
21730
21944
|
)
|
|
21731
21945
|
] })
|
|
@@ -21744,8 +21958,8 @@ function FormCardField({
|
|
|
21744
21958
|
const withHeader = !!fieldDefinition.label && layout.withHeader;
|
|
21745
21959
|
return /* @__PURE__ */ jsxs29(component_default18, { className: "dataforms-layouts-card__field", children: [
|
|
21746
21960
|
withHeader && /* @__PURE__ */ jsxs29(CollapsibleCardHeader, { className: "dataforms-layouts-card__field-header", children: [
|
|
21747
|
-
/* @__PURE__ */
|
|
21748
|
-
visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */
|
|
21961
|
+
/* @__PURE__ */ jsx105("span", { className: "dataforms-layouts-card__field-header-label", children: fieldDefinition.label }),
|
|
21962
|
+
visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */ jsx105("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ jsx105(
|
|
21749
21963
|
summaryField.render,
|
|
21750
21964
|
{
|
|
21751
21965
|
item: data,
|
|
@@ -21756,32 +21970,34 @@ function FormCardField({
|
|
|
21756
21970
|
] }),
|
|
21757
21971
|
(isOpen || !withHeader) && // If it doesn't have a header, keep it open.
|
|
21758
21972
|
// Otherwise, the card will not be visible.
|
|
21759
|
-
/* @__PURE__ */
|
|
21973
|
+
/* @__PURE__ */ jsx105(component_default20, { className: "dataforms-layouts-card__field-control", children: /* @__PURE__ */ jsx105(
|
|
21760
21974
|
RegularLayout,
|
|
21761
21975
|
{
|
|
21762
21976
|
data,
|
|
21763
21977
|
field,
|
|
21764
21978
|
onChange,
|
|
21765
|
-
hideLabelFromVision: hideLabelFromVision || withHeader
|
|
21979
|
+
hideLabelFromVision: hideLabelFromVision || withHeader,
|
|
21980
|
+
validity
|
|
21766
21981
|
}
|
|
21767
21982
|
) })
|
|
21768
21983
|
] });
|
|
21769
21984
|
}
|
|
21770
21985
|
|
|
21771
21986
|
// src/dataform-layouts/row/index.tsx
|
|
21772
|
-
import { Fragment as Fragment15, jsx as
|
|
21987
|
+
import { Fragment as Fragment15, jsx as jsx106, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
21773
21988
|
function Header3({ title }) {
|
|
21774
|
-
return /* @__PURE__ */
|
|
21775
|
-
/* @__PURE__ */
|
|
21776
|
-
/* @__PURE__ */
|
|
21989
|
+
return /* @__PURE__ */ jsx106(component_default14, { className: "dataforms-layouts-row__header", spacing: 4, children: /* @__PURE__ */ jsxs30(component_default9, { alignment: "center", children: [
|
|
21990
|
+
/* @__PURE__ */ jsx106(component_default15, { level: 2, size: 13, children: title }),
|
|
21991
|
+
/* @__PURE__ */ jsx106(component_default6, {})
|
|
21777
21992
|
] }) });
|
|
21778
21993
|
}
|
|
21779
|
-
var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */
|
|
21994
|
+
var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ jsx106(Fragment15, { children });
|
|
21780
21995
|
function FormRowField({
|
|
21781
21996
|
data,
|
|
21782
21997
|
field,
|
|
21783
21998
|
onChange,
|
|
21784
|
-
hideLabelFromVision
|
|
21999
|
+
hideLabelFromVision,
|
|
22000
|
+
validity
|
|
21785
22001
|
}) {
|
|
21786
22002
|
const { fields } = useContext(dataform_context_default);
|
|
21787
22003
|
const layout = normalizeLayout({
|
|
@@ -21798,30 +22014,32 @@ function FormRowField({
|
|
|
21798
22014
|
})
|
|
21799
22015
|
};
|
|
21800
22016
|
return /* @__PURE__ */ jsxs30("div", { className: "dataforms-layouts-row__field", children: [
|
|
21801
|
-
!hideLabelFromVision && field.label && /* @__PURE__ */
|
|
21802
|
-
/* @__PURE__ */
|
|
22017
|
+
!hideLabelFromVision && field.label && /* @__PURE__ */ jsx106(Header3, { title: field.label }),
|
|
22018
|
+
/* @__PURE__ */ jsx106(component_default9, { alignment: layout.alignment, spacing: 4, children: /* @__PURE__ */ jsx106(
|
|
21803
22019
|
DataFormLayout,
|
|
21804
22020
|
{
|
|
21805
22021
|
data,
|
|
21806
22022
|
form,
|
|
21807
22023
|
onChange,
|
|
22024
|
+
validity: validity?.children,
|
|
21808
22025
|
as: EMPTY_WRAPPER,
|
|
21809
|
-
children: (FieldLayout,
|
|
22026
|
+
children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ jsx106(
|
|
21810
22027
|
"div",
|
|
21811
22028
|
{
|
|
21812
22029
|
className: "dataforms-layouts-row__field-control",
|
|
21813
|
-
style: layout.styles[
|
|
21814
|
-
children: /* @__PURE__ */
|
|
22030
|
+
style: layout.styles[childField.id],
|
|
22031
|
+
children: /* @__PURE__ */ jsx106(
|
|
21815
22032
|
FieldLayout,
|
|
21816
22033
|
{
|
|
21817
22034
|
data,
|
|
21818
|
-
field:
|
|
22035
|
+
field: childField,
|
|
21819
22036
|
onChange,
|
|
21820
|
-
hideLabelFromVision
|
|
22037
|
+
hideLabelFromVision,
|
|
22038
|
+
validity: childFieldValidity
|
|
21821
22039
|
}
|
|
21822
22040
|
)
|
|
21823
22041
|
},
|
|
21824
|
-
|
|
22042
|
+
childField.id
|
|
21825
22043
|
)
|
|
21826
22044
|
}
|
|
21827
22045
|
) })
|
|
@@ -21835,18 +22053,19 @@ function FormRowField({
|
|
|
21835
22053
|
if (!RegularLayout) {
|
|
21836
22054
|
return null;
|
|
21837
22055
|
}
|
|
21838
|
-
return /* @__PURE__ */
|
|
22056
|
+
return /* @__PURE__ */ jsx106(Fragment15, { children: /* @__PURE__ */ jsx106("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ jsx106(
|
|
21839
22057
|
RegularLayout,
|
|
21840
22058
|
{
|
|
21841
22059
|
data,
|
|
21842
22060
|
field: fieldDefinition,
|
|
21843
|
-
onChange
|
|
22061
|
+
onChange,
|
|
22062
|
+
validity
|
|
21844
22063
|
}
|
|
21845
22064
|
) }) });
|
|
21846
22065
|
}
|
|
21847
22066
|
|
|
21848
22067
|
// src/dataform-layouts/index.tsx
|
|
21849
|
-
import { jsx as
|
|
22068
|
+
import { jsx as jsx107 } from "react/jsx-runtime";
|
|
21850
22069
|
var FORM_FIELD_LAYOUTS = [
|
|
21851
22070
|
{
|
|
21852
22071
|
type: "regular",
|
|
@@ -21854,7 +22073,7 @@ var FORM_FIELD_LAYOUTS = [
|
|
|
21854
22073
|
wrapper: ({
|
|
21855
22074
|
children,
|
|
21856
22075
|
layout
|
|
21857
|
-
}) => /* @__PURE__ */
|
|
22076
|
+
}) => /* @__PURE__ */ jsx107(
|
|
21858
22077
|
component_default14,
|
|
21859
22078
|
{
|
|
21860
22079
|
className: "dataforms-layouts__wrapper",
|
|
@@ -21866,7 +22085,7 @@ var FORM_FIELD_LAYOUTS = [
|
|
|
21866
22085
|
{
|
|
21867
22086
|
type: "panel",
|
|
21868
22087
|
component: FormPanelField,
|
|
21869
|
-
wrapper: ({ children }) => /* @__PURE__ */
|
|
22088
|
+
wrapper: ({ children }) => /* @__PURE__ */ jsx107(component_default14, { className: "dataforms-layouts__wrapper", spacing: 2, children })
|
|
21870
22089
|
},
|
|
21871
22090
|
{
|
|
21872
22091
|
type: "card",
|
|
@@ -21874,7 +22093,7 @@ var FORM_FIELD_LAYOUTS = [
|
|
|
21874
22093
|
wrapper: ({
|
|
21875
22094
|
children,
|
|
21876
22095
|
layout
|
|
21877
|
-
}) => /* @__PURE__ */
|
|
22096
|
+
}) => /* @__PURE__ */ jsx107(
|
|
21878
22097
|
component_default14,
|
|
21879
22098
|
{
|
|
21880
22099
|
className: "dataforms-layouts__wrapper",
|
|
@@ -21889,7 +22108,7 @@ var FORM_FIELD_LAYOUTS = [
|
|
|
21889
22108
|
wrapper: ({
|
|
21890
22109
|
children,
|
|
21891
22110
|
layout
|
|
21892
|
-
}) => /* @__PURE__ */
|
|
22111
|
+
}) => /* @__PURE__ */ jsx107(component_default14, { className: "dataforms-layouts__wrapper", spacing: 4, children: /* @__PURE__ */ jsx107("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ jsx107(
|
|
21893
22112
|
component_default9,
|
|
21894
22113
|
{
|
|
21895
22114
|
spacing: 4,
|
|
@@ -21904,12 +22123,13 @@ function getFormFieldLayout(type) {
|
|
|
21904
22123
|
}
|
|
21905
22124
|
|
|
21906
22125
|
// src/dataform-layouts/data-form-layout.tsx
|
|
21907
|
-
import { jsx as
|
|
21908
|
-
var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */
|
|
22126
|
+
import { jsx as jsx108 } from "react/jsx-runtime";
|
|
22127
|
+
var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ jsx108(component_default14, { className: "dataforms-layouts__wrapper", spacing: 4, children });
|
|
21909
22128
|
function DataFormLayout({
|
|
21910
22129
|
data,
|
|
21911
22130
|
form,
|
|
21912
22131
|
onChange,
|
|
22132
|
+
validity,
|
|
21913
22133
|
children,
|
|
21914
22134
|
as
|
|
21915
22135
|
}) {
|
|
@@ -21926,7 +22146,7 @@ function DataFormLayout({
|
|
|
21926
22146
|
);
|
|
21927
22147
|
const normalizedFormLayout = normalizeLayout(form.layout);
|
|
21928
22148
|
const Wrapper4 = as ?? getFormFieldLayout(normalizedFormLayout.type)?.wrapper ?? DEFAULT_WRAPPER;
|
|
21929
|
-
return /* @__PURE__ */
|
|
22149
|
+
return /* @__PURE__ */ jsx108(Wrapper4, { layout: normalizedFormLayout, children: normalizedFormFields.map((formField) => {
|
|
21930
22150
|
const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
|
|
21931
22151
|
if (!FieldLayout) {
|
|
21932
22152
|
return null;
|
|
@@ -21936,14 +22156,19 @@ function DataFormLayout({
|
|
|
21936
22156
|
return null;
|
|
21937
22157
|
}
|
|
21938
22158
|
if (children) {
|
|
21939
|
-
return children(
|
|
22159
|
+
return children(
|
|
22160
|
+
FieldLayout,
|
|
22161
|
+
formField,
|
|
22162
|
+
validity?.[formField.id]
|
|
22163
|
+
);
|
|
21940
22164
|
}
|
|
21941
|
-
return /* @__PURE__ */
|
|
22165
|
+
return /* @__PURE__ */ jsx108(
|
|
21942
22166
|
FieldLayout,
|
|
21943
22167
|
{
|
|
21944
22168
|
data,
|
|
21945
22169
|
field: formField,
|
|
21946
|
-
onChange
|
|
22170
|
+
onChange,
|
|
22171
|
+
validity: validity?.[formField.id]
|
|
21947
22172
|
},
|
|
21948
22173
|
formField.id
|
|
21949
22174
|
);
|
|
@@ -21951,12 +22176,13 @@ function DataFormLayout({
|
|
|
21951
22176
|
}
|
|
21952
22177
|
|
|
21953
22178
|
// src/components/dataform/index.tsx
|
|
21954
|
-
import { jsx as
|
|
22179
|
+
import { jsx as jsx109 } from "react/jsx-runtime";
|
|
21955
22180
|
function DataForm({
|
|
21956
22181
|
data,
|
|
21957
22182
|
form,
|
|
21958
22183
|
fields,
|
|
21959
|
-
onChange
|
|
22184
|
+
onChange,
|
|
22185
|
+
validity
|
|
21960
22186
|
}) {
|
|
21961
22187
|
const normalizedFields = useMemo(
|
|
21962
22188
|
() => normalizeFields(fields),
|
|
@@ -21965,7 +22191,15 @@ function DataForm({
|
|
|
21965
22191
|
if (!form.fields) {
|
|
21966
22192
|
return null;
|
|
21967
22193
|
}
|
|
21968
|
-
return /* @__PURE__ */
|
|
22194
|
+
return /* @__PURE__ */ jsx109(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ jsx109(
|
|
22195
|
+
DataFormLayout,
|
|
22196
|
+
{
|
|
22197
|
+
data,
|
|
22198
|
+
form,
|
|
22199
|
+
onChange,
|
|
22200
|
+
validity
|
|
22201
|
+
}
|
|
22202
|
+
) });
|
|
21969
22203
|
}
|
|
21970
22204
|
|
|
21971
22205
|
// src/utils/filter-sort-and-paginate.ts
|
|
@@ -21975,7 +22209,7 @@ import { getDate as getDate4 } from "@wordpress/date";
|
|
|
21975
22209
|
function normalizeSearchInput2(input = "") {
|
|
21976
22210
|
return removeAccents3(input.trim().toLowerCase());
|
|
21977
22211
|
}
|
|
21978
|
-
var
|
|
22212
|
+
var EMPTY_ARRAY8 = [];
|
|
21979
22213
|
function getRelativeDate(value, unit) {
|
|
21980
22214
|
switch (unit) {
|
|
21981
22215
|
case "days":
|
|
@@ -21993,7 +22227,7 @@ function getRelativeDate(value, unit) {
|
|
|
21993
22227
|
function filterSortAndPaginate(data, view, fields) {
|
|
21994
22228
|
if (!data) {
|
|
21995
22229
|
return {
|
|
21996
|
-
data:
|
|
22230
|
+
data: EMPTY_ARRAY8,
|
|
21997
22231
|
paginationInfo: { totalItems: 0, totalPages: 0 }
|
|
21998
22232
|
};
|
|
21999
22233
|
}
|
|
@@ -22218,53 +22452,11 @@ function filterSortAndPaginate(data, view, fields) {
|
|
|
22218
22452
|
}
|
|
22219
22453
|
};
|
|
22220
22454
|
}
|
|
22221
|
-
|
|
22222
|
-
// src/utils/is-item-valid.ts
|
|
22223
|
-
function isItemValid(item2, fields, form) {
|
|
22224
|
-
const _fields = normalizeFields(
|
|
22225
|
-
fields.filter(({ id }) => !!form.fields?.includes(id))
|
|
22226
|
-
);
|
|
22227
|
-
const isEmptyNullOrUndefined = (value) => [void 0, "", null].includes(value);
|
|
22228
|
-
const isArrayOrElementsEmptyNullOrUndefined = (value) => {
|
|
22229
|
-
return !Array.isArray(value) || value.length === 0 || value.every((element) => isEmptyNullOrUndefined(element));
|
|
22230
|
-
};
|
|
22231
|
-
return _fields.every((field) => {
|
|
22232
|
-
const value = field.getValue({ item: item2 });
|
|
22233
|
-
if (field.isValid.required) {
|
|
22234
|
-
if (field.type === "text" && isEmptyNullOrUndefined(value) || field.type === "email" && isEmptyNullOrUndefined(value) || field.type === "url" && isEmptyNullOrUndefined(value) || field.type === "telephone" && isEmptyNullOrUndefined(value) || field.type === "password" && isEmptyNullOrUndefined(value) || field.type === "integer" && isEmptyNullOrUndefined(value) || field.type === "number" && isEmptyNullOrUndefined(value) || field.type === "array" && isArrayOrElementsEmptyNullOrUndefined(value) || field.type === void 0 && isEmptyNullOrUndefined(value)) {
|
|
22235
|
-
return false;
|
|
22236
|
-
}
|
|
22237
|
-
if (field.type === "boolean" && value !== true) {
|
|
22238
|
-
return false;
|
|
22239
|
-
}
|
|
22240
|
-
}
|
|
22241
|
-
if (field.isValid.elements) {
|
|
22242
|
-
if (field.elements) {
|
|
22243
|
-
const validValues = field.elements.map(
|
|
22244
|
-
(element) => element.value
|
|
22245
|
-
);
|
|
22246
|
-
if (field.type === "array") {
|
|
22247
|
-
if (Array.isArray(value)) {
|
|
22248
|
-
return value.every(
|
|
22249
|
-
(arrayItem) => validValues.includes(arrayItem)
|
|
22250
|
-
);
|
|
22251
|
-
}
|
|
22252
|
-
return false;
|
|
22253
|
-
}
|
|
22254
|
-
return validValues.includes(value);
|
|
22255
|
-
}
|
|
22256
|
-
}
|
|
22257
|
-
if (typeof field.isValid.custom === "function" && field.isValid.custom(item2, field) !== null) {
|
|
22258
|
-
return false;
|
|
22259
|
-
}
|
|
22260
|
-
return true;
|
|
22261
|
-
});
|
|
22262
|
-
}
|
|
22263
22455
|
export {
|
|
22264
22456
|
DataForm,
|
|
22265
22457
|
dataviews_default as DataViews,
|
|
22266
22458
|
dataviews_picker_default as DataViewsPicker,
|
|
22267
22459
|
VIEW_LAYOUTS,
|
|
22268
22460
|
filterSortAndPaginate,
|
|
22269
|
-
|
|
22461
|
+
use_form_validity_default as useFormValidity
|
|
22270
22462
|
};
|