@sheinx/hooks 3.0.0-rc.1 → 3.0.0-rc.11
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/cjs/common/type.d.ts +15 -15
- package/cjs/common/type.d.ts.map +1 -1
- package/cjs/common/use-click-away/index.d.ts +2 -2
- package/cjs/common/use-click-away/index.d.ts.map +1 -1
- package/cjs/common/use-click-away/index.js +2 -3
- package/cjs/common/use-default-value/index.js +2 -2
- package/cjs/common/use-default-value/use-default-value.js +9 -5
- package/cjs/common/use-drag-mock/index.js +2 -2
- package/cjs/common/use-drag-mock/use-drag-mock.js +11 -8
- package/cjs/common/use-drag-mock/use-drag-move.js +15 -11
- package/cjs/common/use-drag-mock/use-drag-resize.js +9 -5
- package/cjs/common/use-filter/index.js +2 -2
- package/cjs/common/use-filter/use-filter.js +17 -13
- package/cjs/common/use-fork-ref/index.js +5 -10
- package/cjs/common/use-func-change/index.js +2 -2
- package/cjs/common/use-func-change/use-func-change.d.ts +1 -1
- package/cjs/common/use-func-change/use-func-change.js +2 -3
- package/cjs/common/use-input-able/index.js +2 -2
- package/cjs/common/use-input-able/use-Input-able.js +8 -4
- package/cjs/common/use-input-able/use-Input-able.type.d.ts +1 -1
- package/cjs/common/use-input-able/use-Input-able.type.d.ts.map +1 -1
- package/cjs/common/use-key-event/index.js +6 -8
- package/cjs/common/use-latest-obj/index.js +1 -3
- package/cjs/common/use-list-select/index.js +2 -2
- package/cjs/common/use-list-select/use-list-select-multiple.js +26 -39
- package/cjs/common/use-list-select/use-list-select-single.js +9 -11
- package/cjs/common/use-list-select/use-list-select.js +10 -12
- package/cjs/common/use-pagination-list/index.js +17 -15
- package/cjs/common/use-persist-fn/index.js +1 -2
- package/cjs/common/use-position-style/get-position-style.js +10 -7
- package/cjs/common/use-position-style/index.d.ts +3 -3
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +16 -22
- package/cjs/common/use-previous/index.js +1 -2
- package/cjs/common/use-render/index.js +8 -5
- package/cjs/common/use-resize/index.js +11 -9
- package/cjs/common/use-safe-state/index.js +8 -5
- package/cjs/common/use-style/index.js +0 -2
- package/cjs/common/use-toggle/index.d.ts +1 -1
- package/cjs/common/use-toggle/index.d.ts.map +1 -1
- package/cjs/common/use-toggle/index.js +7 -3
- package/cjs/common/use-transform/index.js +2 -2
- package/cjs/common/use-transform/use-transform.js +13 -11
- package/cjs/common/use-unmounted-ref/index.js +1 -2
- package/cjs/components/use-button/index.js +2 -2
- package/cjs/components/use-button/use-button.d.ts +5 -6
- package/cjs/components/use-button/use-button.d.ts.map +1 -1
- package/cjs/components/use-button/use-button.js +15 -32
- package/cjs/components/use-button/use-button.type.d.ts +3 -8
- package/cjs/components/use-button/use-button.type.d.ts.map +1 -1
- package/cjs/components/use-carousel/index.js +2 -2
- package/cjs/components/use-carousel/use-carousel.d.ts +1 -1
- package/cjs/components/use-carousel/use-carousel.d.ts.map +1 -1
- package/cjs/components/use-carousel/use-carousel.js +9 -5
- package/cjs/components/use-cascader/index.js +2 -2
- package/cjs/components/use-cascader/use-cascader.js +2 -3
- package/cjs/components/use-check/index.js +2 -2
- package/cjs/components/use-check/use-check.d.ts +3 -3
- package/cjs/components/use-check/use-check.js +24 -17
- package/cjs/components/use-collapse/index.js +2 -2
- package/cjs/components/use-collapse/use-collapse-item.d.ts +4 -4
- package/cjs/components/use-collapse/use-collapse-item.js +7 -10
- package/cjs/components/use-collapse/use-collapse-item.type.d.ts +1 -1
- package/cjs/components/use-collapse/use-collapse-item.type.d.ts.map +1 -1
- package/cjs/components/use-collapse/use-collapse.js +14 -13
- package/cjs/components/use-datepicker/index.js +2 -2
- package/cjs/components/use-datepicker/use-date.js +13 -11
- package/cjs/components/use-datepicker/use-datepicker-format.js +26 -21
- package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts +4 -4
- package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-range.js +10 -7
- package/cjs/components/use-datepicker/use-datepicker-range.type.d.ts +1 -1
- package/cjs/components/use-datepicker/use-datepicker-range.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-month.js +13 -11
- package/cjs/components/use-datepicker/use-quarter.js +13 -12
- package/cjs/components/use-datepicker/use-time.js +3 -8
- package/cjs/components/use-datepicker/use-year.js +13 -11
- package/cjs/components/use-datepicker/util.d.ts +3 -3
- package/cjs/components/use-datepicker/util.d.ts.map +1 -1
- package/cjs/components/use-datepicker/util.js +13 -20
- package/cjs/components/use-descriptions/index.js +2 -2
- package/cjs/components/use-descriptions/use-descriptions.js +14 -11
- package/cjs/components/use-form/Provider.js +6 -10
- package/cjs/components/use-form/form-bind-context.js +6 -11
- package/cjs/components/use-form/form-config-context.js +6 -11
- package/cjs/components/use-form/form-func-context.js +6 -11
- package/cjs/components/use-form/index.js +2 -3
- package/cjs/components/use-form/use-form-control/index.js +2 -2
- package/cjs/components/use-form/use-form-control/use-form-control.js +23 -23
- package/cjs/components/use-form/use-form-fieldset/fieldset-context.js +10 -19
- package/cjs/components/use-form/use-form-fieldset/index.js +2 -2
- package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.js +3 -5
- package/cjs/components/use-form/use-form-flow/index.js +2 -2
- package/cjs/components/use-form/use-form-flow/use-form-datum.js +1 -2
- package/cjs/components/use-form/use-form-flow/use-form-flow.js +2 -3
- package/cjs/components/use-form/use-form-item/form-item-context.js +5 -9
- package/cjs/components/use-form/use-form-item/index.js +2 -2
- package/cjs/components/use-form/use-form-item/use-form-item.js +12 -13
- package/cjs/components/use-form/use-form.d.ts +2 -2
- package/cjs/components/use-form/use-form.js +28 -37
- package/cjs/components/use-form/use-form.type.d.ts +4 -4
- package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
- package/cjs/components/use-image/index.js +2 -2
- package/cjs/components/use-image/use-image-gallery.d.ts +4 -4
- package/cjs/components/use-image/use-image-gallery.d.ts.map +1 -1
- package/cjs/components/use-image/use-image-gallery.js +18 -15
- package/cjs/components/use-image/use-image-gallery.type.d.ts +1 -1
- package/cjs/components/use-image/use-image-gallery.type.d.ts.map +1 -1
- package/cjs/components/use-image/use-image-group.d.ts +2 -2
- package/cjs/components/use-image/use-image-group.d.ts.map +1 -1
- package/cjs/components/use-image/use-image-group.js +9 -12
- package/cjs/components/use-image/use-image-magnify.js +13 -13
- package/cjs/components/use-image/use-image.d.ts +3 -3
- package/cjs/components/use-image/use-image.d.ts.map +1 -1
- package/cjs/components/use-image/use-image.js +17 -23
- package/cjs/components/use-image/use-image.type.d.ts +4 -4
- package/cjs/components/use-image/use-image.type.d.ts.map +1 -1
- package/cjs/components/use-input/index.js +2 -2
- package/cjs/components/use-input/use-input-format.d.ts +1 -1
- package/cjs/components/use-input/use-input-format.js +13 -15
- package/cjs/components/use-input/use-input-format.type.d.ts +1 -1
- package/cjs/components/use-input/use-input-format.type.d.ts.map +1 -1
- package/cjs/components/use-input/use-input-number.d.ts +1 -1
- package/cjs/components/use-input/use-input-number.js +15 -16
- package/cjs/components/use-input/use-input-number.type.d.ts +1 -1
- package/cjs/components/use-input/use-input-number.type.d.ts.map +1 -1
- package/cjs/components/use-input/use-input-password.js +11 -9
- package/cjs/components/use-input/use-input-password.type.d.ts +1 -1
- package/cjs/components/use-input/use-input-password.type.d.ts.map +1 -1
- package/cjs/components/use-input/use-input.d.ts +3 -3
- package/cjs/components/use-input/use-input.js +30 -29
- package/cjs/components/use-input/use-input.type.d.ts +5 -5
- package/cjs/components/use-input/use-input.type.d.ts.map +1 -1
- package/cjs/components/use-menu/index.js +2 -2
- package/cjs/components/use-menu/use-menu-item.d.ts +1 -1
- package/cjs/components/use-menu/use-menu-item.d.ts.map +1 -1
- package/cjs/components/use-menu/use-menu-item.js +11 -12
- package/cjs/components/use-menu/use-menu.js +2 -8
- package/cjs/components/use-menu/use-menu.type.d.ts +1 -1
- package/cjs/components/use-menu/use-menu.type.d.ts.map +1 -1
- package/cjs/components/use-pagination/index.js +2 -2
- package/cjs/components/use-pagination/use-pagination.d.ts +1 -1
- package/cjs/components/use-pagination/use-pagination.d.ts.map +1 -1
- package/cjs/components/use-pagination/use-pagination.js +19 -13
- package/cjs/components/use-popup/index.js +2 -2
- package/cjs/components/use-popup/popup-context.js +1 -2
- package/cjs/components/use-popup/use-popup.js +14 -11
- package/cjs/components/use-popup/use-popup.type.d.ts +1 -1
- package/cjs/components/use-popup/use-popup.type.d.ts.map +1 -1
- package/cjs/components/use-select/index.js +2 -2
- package/cjs/components/use-select/use-select-group.js +13 -10
- package/cjs/components/use-select/use-select.js +1 -2
- package/cjs/components/use-select/use-select.type.d.ts +1 -1
- package/cjs/components/use-select/use-select.type.d.ts.map +1 -1
- package/cjs/components/use-slider/index.js +2 -2
- package/cjs/components/use-slider/use-slider.js +15 -10
- package/cjs/components/use-table/index.js +2 -2
- package/cjs/components/use-table/use-table-columns.d.ts +1 -1
- package/cjs/components/use-table/use-table-columns.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-columns.js +4 -8
- package/cjs/components/use-table/use-table-expand.js +19 -20
- package/cjs/components/use-table/use-table-group.js +1 -7
- package/cjs/components/use-table/use-table-layout.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-layout.js +36 -34
- package/cjs/components/use-table/use-table-row.js +8 -9
- package/cjs/components/use-table/use-table-sort.d.ts +1 -1
- package/cjs/components/use-table/use-table-sort.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-sort.js +21 -22
- package/cjs/components/use-table/use-table-tree.d.ts +1 -1
- package/cjs/components/use-table/use-table-tree.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-tree.js +48 -57
- package/cjs/components/use-table/use-table-virtual.js +17 -13
- package/cjs/components/use-table/use-table.type.d.ts +4 -4
- package/cjs/components/use-table/use-table.type.d.ts.map +1 -1
- package/cjs/components/use-tabs/context.js +7 -13
- package/cjs/components/use-tabs/index.js +2 -2
- package/cjs/components/use-tabs/use-tabs.js +9 -6
- package/cjs/components/use-tabs/use-tabs.type.d.ts +1 -1
- package/cjs/components/use-tabs/use-tabs.type.d.ts.map +1 -1
- package/cjs/components/use-textarea/index.js +2 -2
- package/cjs/components/use-textarea/use-textarea-format.js +5 -7
- package/cjs/components/use-textarea/use-textarea-format.type.d.ts +1 -1
- package/cjs/components/use-textarea/use-textarea-format.type.d.ts.map +1 -1
- package/cjs/components/use-textarea/use-textarea.d.ts +2 -2
- package/cjs/components/use-textarea/use-textarea.js +23 -18
- package/cjs/components/use-textarea/use-textarea.type.d.ts +3 -3
- package/cjs/components/use-textarea/use-textarea.type.d.ts.map +1 -1
- package/cjs/components/use-transfer/index.js +2 -2
- package/cjs/components/use-transfer/use-transfer.js +20 -19
- package/cjs/components/use-transfer/use-transfer.type.d.ts +1 -1
- package/cjs/components/use-transfer/use-transfer.type.d.ts.map +1 -1
- package/cjs/components/use-tree/index.js +2 -2
- package/cjs/components/use-tree/use-tree-node.js +11 -7
- package/cjs/components/use-tree/use-tree-node.type.d.ts +2 -2
- package/cjs/components/use-tree/use-tree-node.type.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree.js +11 -16
- package/cjs/components/use-tree/use-tree.type.d.ts +3 -3
- package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/cjs/components/use-treeselect/index.js +2 -2
- package/cjs/components/use-treeselect/use-tiled.js +13 -9
- package/cjs/components/use-treeselect/use-tiled.type.d.ts +1 -1
- package/cjs/components/use-treeselect/use-tiled.type.d.ts.map +1 -1
- package/cjs/components/use-treeselect/use-treeselect.js +1 -2
- package/cjs/components/use-upload/index.js +2 -2
- package/cjs/components/use-upload/use-upload.js +36 -34
- package/cjs/components/use-upload/xhr.js +0 -1
- package/cjs/components/use-validate/index.js +2 -2
- package/cjs/components/use-validate/use-validate.js +9 -5
- package/cjs/index.js +4 -9
- package/cjs/utils/accept.d.ts +1 -1
- package/cjs/utils/accept.d.ts.map +1 -1
- package/cjs/utils/accept.js +0 -4
- package/cjs/utils/array.js +2 -4
- package/cjs/utils/attribute.js +3 -5
- package/cjs/utils/clone.js +11 -20
- package/cjs/utils/document.js +2 -4
- package/cjs/utils/dom/element.js +11 -11
- package/cjs/utils/dom/index.js +2 -3
- package/cjs/utils/dom/responsiveObserve.js +10 -15
- package/cjs/utils/dom/responsiveObserve.type.d.ts +4 -4
- package/cjs/utils/dom/responsiveObserve.type.d.ts.map +1 -1
- package/cjs/utils/dom/scroll-behavior.js +2 -3
- package/cjs/utils/extract-event-handlers.js +0 -6
- package/cjs/utils/func.js +3 -5
- package/cjs/utils/immer.d.ts +1 -8
- package/cjs/utils/immer.d.ts.map +1 -1
- package/cjs/utils/immer.js +11 -8
- package/cjs/utils/index.js +2 -3
- package/cjs/utils/is.d.ts +1 -1
- package/cjs/utils/is.d.ts.map +1 -1
- package/cjs/utils/is.js +30 -55
- package/cjs/utils/lazyload.d.ts +1 -1
- package/cjs/utils/lazyload.d.ts.map +1 -1
- package/cjs/utils/lazyload.js +0 -1
- package/cjs/utils/number.js +0 -7
- package/cjs/utils/object.d.ts +4 -4
- package/cjs/utils/object.d.ts.map +1 -1
- package/cjs/utils/object.js +18 -37
- package/cjs/utils/position.js +4 -3
- package/cjs/utils/react-render.d.ts +1 -1
- package/cjs/utils/react-render.d.ts.map +1 -1
- package/cjs/utils/react-render.js +17 -24
- package/cjs/utils/render.d.ts +1 -1
- package/cjs/utils/render.d.ts.map +1 -1
- package/cjs/utils/render.js +3 -5
- package/cjs/utils/rule/index.js +2 -2
- package/cjs/utils/rule/length.d.ts +1 -1
- package/cjs/utils/rule/length.js +9 -11
- package/cjs/utils/rule/regexp.d.ts +1 -1
- package/cjs/utils/rule/regexp.js +4 -9
- package/cjs/utils/rule/required.d.ts +1 -1
- package/cjs/utils/rule/required.js +3 -5
- package/cjs/utils/rule/rule.js +4 -9
- package/cjs/utils/rule/rule.type.d.ts +8 -8
- package/cjs/utils/rule/rule.type.d.ts.map +1 -1
- package/cjs/utils/rule/type.d.ts +1 -1
- package/cjs/utils/rule/type.js +3 -5
- package/cjs/utils/shallow-equal.js +4 -9
- package/cjs/utils/string.js +0 -7
- package/cjs/utils/style-unit.js +0 -2
- package/cjs/utils/tree.d.ts +1 -1
- package/cjs/utils/tree.d.ts.map +1 -1
- package/cjs/utils/tree.js +19 -21
- package/cjs/utils/uid.js +0 -11
- package/cjs/utils/validate/error.js +22 -18
- package/cjs/utils/validate/get-rule.js +1 -4
- package/cjs/utils/validate/index.d.ts +1 -1
- package/cjs/utils/validate/index.d.ts.map +1 -1
- package/cjs/utils/validate/index.js +13 -13
- package/cjs/utils/validate/isJson.js +2 -5
- package/cjs/utils/validate/nullable.js +2 -3
- package/cjs/utils/validate/type.d.ts +1 -1
- package/cjs/utils/validate/type.d.ts.map +1 -1
- package/cjs/utils/validate/type.js +4 -9
- package/esm/common/type.d.ts +15 -15
- package/esm/common/type.d.ts.map +1 -1
- package/esm/common/type.js +1 -5
- package/esm/common/use-click-away/index.d.ts +2 -2
- package/esm/common/use-click-away/index.d.ts.map +1 -1
- package/esm/common/use-click-away/index.js +8 -17
- package/esm/common/use-default-value/index.js +2 -26
- package/esm/common/use-default-value/use-default-value.js +16 -19
- package/esm/common/use-default-value/use-previous.js +4 -10
- package/esm/common/use-drag-mock/index.js +3 -33
- package/esm/common/use-drag-mock/use-drag-mock.js +17 -20
- package/esm/common/use-drag-mock/use-drag-move.js +25 -28
- package/esm/common/use-drag-mock/use-drag-resize.js +19 -22
- package/esm/common/use-filter/index.js +1 -19
- package/esm/common/use-filter/use-filter.js +34 -36
- package/esm/common/use-filter/use-filter.type.js +1 -5
- package/esm/common/use-fork-ref/index.js +5 -20
- package/esm/common/use-fork-ref/setRef.js +1 -7
- package/esm/common/use-func-change/index.js +1 -19
- package/esm/common/use-func-change/use-func-change.d.ts +1 -1
- package/esm/common/use-func-change/use-func-change.js +8 -16
- package/esm/common/use-input-able/index.js +1 -19
- package/esm/common/use-input-able/use-Input-able.js +25 -28
- package/esm/common/use-input-able/use-Input-able.type.d.ts +1 -1
- package/esm/common/use-input-able/use-Input-able.type.d.ts.map +1 -1
- package/esm/common/use-input-able/use-Input-able.type.js +1 -5
- package/esm/common/use-key-event/index.js +7 -15
- package/esm/common/use-latest-obj/index.js +4 -12
- package/esm/common/use-list-select/index.js +3 -33
- package/esm/common/use-list-select/use-list-select-multiple.js +41 -64
- package/esm/common/use-list-select/use-list-select-single.js +17 -26
- package/esm/common/use-list-select/use-list-select.js +16 -25
- package/esm/common/use-list-select/use-list.type.js +1 -5
- package/esm/common/use-pagination-list/index.js +22 -26
- package/esm/common/use-persist-fn/index.js +5 -11
- package/esm/common/use-position-style/get-position-style.js +10 -13
- package/esm/common/use-position-style/index.d.ts +3 -3
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +25 -41
- package/esm/common/use-previous/index.js +5 -13
- package/esm/common/use-render/index.js +15 -19
- package/esm/common/use-resize/index.js +17 -21
- package/esm/common/use-safe-state/index.js +15 -19
- package/esm/common/use-style/index.js +3 -11
- package/esm/common/use-toggle/index.d.ts +1 -1
- package/esm/common/use-toggle/index.d.ts.map +1 -1
- package/esm/common/use-toggle/index.js +12 -14
- package/esm/common/use-transform/index.js +1 -19
- package/esm/common/use-transform/use-transform.js +23 -27
- package/esm/common/use-transform/use-transform.type.js +1 -5
- package/esm/common/use-unmounted-ref/index.js +5 -13
- package/esm/components/use-button/index.js +1 -19
- package/esm/components/use-button/use-button-group.type.js +1 -5
- package/esm/components/use-button/use-button.d.ts +5 -6
- package/esm/components/use-button/use-button.d.ts.map +1 -1
- package/esm/components/use-button/use-button.js +20 -43
- package/esm/components/use-button/use-button.type.d.ts +3 -8
- package/esm/components/use-button/use-button.type.d.ts.map +1 -1
- package/esm/components/use-button/use-button.type.js +1 -5
- package/esm/components/use-carousel/index.js +1 -19
- package/esm/components/use-carousel/use-carousel.d.ts +1 -1
- package/esm/components/use-carousel/use-carousel.d.ts.map +1 -1
- package/esm/components/use-carousel/use-carousel.js +21 -24
- package/esm/components/use-cascader/index.js +1 -19
- package/esm/components/use-cascader/use-cascader.js +5 -13
- package/esm/components/use-cascader/use-cascader.type.js +1 -5
- package/esm/components/use-check/index.js +1 -19
- package/esm/components/use-check/use-check.d.ts +3 -3
- package/esm/components/use-check/use-check.js +32 -31
- package/esm/components/use-check/use-check.type.js +1 -5
- package/esm/components/use-collapse/index.js +2 -26
- package/esm/components/use-collapse/use-collapse-item.d.ts +4 -4
- package/esm/components/use-collapse/use-collapse-item.js +9 -18
- package/esm/components/use-collapse/use-collapse-item.type.d.ts +1 -1
- package/esm/components/use-collapse/use-collapse-item.type.d.ts.map +1 -1
- package/esm/components/use-collapse/use-collapse-item.type.js +1 -5
- package/esm/components/use-collapse/use-collapse.js +17 -22
- package/esm/components/use-collapse/use-collapse.type.js +1 -5
- package/esm/components/use-datepicker/index.js +8 -62
- package/esm/components/use-datepicker/use-date.js +53 -57
- package/esm/components/use-datepicker/use-date.type.js +1 -5
- package/esm/components/use-datepicker/use-datepicker-format.js +54 -56
- package/esm/components/use-datepicker/use-datepicker-format.type.d.ts +4 -4
- package/esm/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.type.js +1 -5
- package/esm/components/use-datepicker/use-datepicker-range.js +43 -47
- package/esm/components/use-datepicker/use-datepicker-range.type.d.ts +1 -1
- package/esm/components/use-datepicker/use-datepicker-range.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-range.type.js +1 -5
- package/esm/components/use-datepicker/use-month.js +37 -41
- package/esm/components/use-datepicker/use-month.type.js +1 -5
- package/esm/components/use-datepicker/use-quarter.js +36 -41
- package/esm/components/use-datepicker/use-quarter.type.js +1 -5
- package/esm/components/use-datepicker/use-time.js +23 -35
- package/esm/components/use-datepicker/use-time.type.js +1 -5
- package/esm/components/use-datepicker/use-year.js +37 -41
- package/esm/components/use-datepicker/use-year.type.js +1 -5
- package/esm/components/use-datepicker/util.d.ts +3 -3
- package/esm/components/use-datepicker/util.d.ts.map +1 -1
- package/esm/components/use-datepicker/util.js +67 -80
- package/esm/components/use-descriptions/index.js +1 -19
- package/esm/components/use-descriptions/use-descriptions.js +24 -27
- package/esm/components/use-descriptions/use-descriptions.type.js +1 -5
- package/esm/components/use-form/Provider.js +12 -26
- package/esm/components/use-form/form-bind-context.js +4 -17
- package/esm/components/use-form/form-config-context.js +4 -17
- package/esm/components/use-form/form-func-context.js +4 -17
- package/esm/components/use-form/index.js +7 -87
- package/esm/components/use-form/use-form-control/index.js +1 -19
- package/esm/components/use-form/use-form-control/use-form-control.js +57 -66
- package/esm/components/use-form/use-form-control/use-form-control.type.js +1 -5
- package/esm/components/use-form/use-form-fieldset/fieldset-context.js +13 -29
- package/esm/components/use-form/use-form-fieldset/index.js +2 -26
- package/esm/components/use-form/use-form-fieldset/use-form-fieldset.js +6 -15
- package/esm/components/use-form/use-form-fieldset/use-form-fieldset.type.js +1 -5
- package/esm/components/use-form/use-form-flow/index.js +2 -26
- package/esm/components/use-form/use-form-flow/use-form-datum.js +4 -11
- package/esm/components/use-form/use-form-flow/use-form-flow.js +9 -17
- package/esm/components/use-form/use-form-flow/use-form-flow.type.js +1 -5
- package/esm/components/use-form/use-form-item/form-item-context.js +3 -15
- package/esm/components/use-form/use-form-item/index.js +1 -19
- package/esm/components/use-form/use-form-item/use-form-item.js +21 -32
- package/esm/components/use-form/use-form.d.ts +2 -2
- package/esm/components/use-form/use-form.js +65 -83
- package/esm/components/use-form/use-form.type.d.ts +4 -4
- package/esm/components/use-form/use-form.type.d.ts.map +1 -1
- package/esm/components/use-form/use-form.type.js +1 -5
- package/esm/components/use-image/index.js +4 -40
- package/esm/components/use-image/use-image-gallery.d.ts +4 -4
- package/esm/components/use-image/use-image-gallery.d.ts.map +1 -1
- package/esm/components/use-image/use-image-gallery.js +34 -37
- package/esm/components/use-image/use-image-gallery.type.d.ts +1 -1
- package/esm/components/use-image/use-image-gallery.type.d.ts.map +1 -1
- package/esm/components/use-image/use-image-gallery.type.js +1 -5
- package/esm/components/use-image/use-image-group.d.ts +2 -2
- package/esm/components/use-image/use-image-group.d.ts.map +1 -1
- package/esm/components/use-image/use-image-group.js +15 -24
- package/esm/components/use-image/use-image-group.type.js +1 -5
- package/esm/components/use-image/use-image-magnify.js +17 -26
- package/esm/components/use-image/use-image-magnify.type.js +1 -5
- package/esm/components/use-image/use-image.d.ts +3 -3
- package/esm/components/use-image/use-image.d.ts.map +1 -1
- package/esm/components/use-image/use-image.js +28 -41
- package/esm/components/use-image/use-image.type.d.ts +4 -4
- package/esm/components/use-image/use-image.type.d.ts.map +1 -1
- package/esm/components/use-image/use-image.type.js +1 -5
- package/esm/components/use-input/index.js +4 -40
- package/esm/components/use-input/use-input-format.d.ts +1 -1
- package/esm/components/use-input/use-input-format.js +18 -27
- package/esm/components/use-input/use-input-format.type.d.ts +1 -1
- package/esm/components/use-input/use-input-format.type.d.ts.map +1 -1
- package/esm/components/use-input/use-input-format.type.js +1 -5
- package/esm/components/use-input/use-input-number.d.ts +1 -1
- package/esm/components/use-input/use-input-number.js +23 -31
- package/esm/components/use-input/use-input-number.type.d.ts +1 -1
- package/esm/components/use-input/use-input-number.type.d.ts.map +1 -1
- package/esm/components/use-input/use-input-number.type.js +1 -5
- package/esm/components/use-input/use-input-password.js +16 -21
- package/esm/components/use-input/use-input-password.type.d.ts +1 -1
- package/esm/components/use-input/use-input-password.type.d.ts.map +1 -1
- package/esm/components/use-input/use-input-password.type.js +1 -5
- package/esm/components/use-input/use-input.d.ts +3 -3
- package/esm/components/use-input/use-input.js +34 -42
- package/esm/components/use-input/use-input.type.d.ts +5 -5
- package/esm/components/use-input/use-input.type.d.ts.map +1 -1
- package/esm/components/use-input/use-input.type.js +1 -5
- package/esm/components/use-menu/index.js +2 -20
- package/esm/components/use-menu/use-menu-item.d.ts +1 -1
- package/esm/components/use-menu/use-menu-item.d.ts.map +1 -1
- package/esm/components/use-menu/use-menu-item.js +23 -31
- package/esm/components/use-menu/use-menu.js +15 -28
- package/esm/components/use-menu/use-menu.type.d.ts +1 -1
- package/esm/components/use-menu/use-menu.type.d.ts.map +1 -1
- package/esm/components/use-menu/use-menu.type.js +1 -5
- package/esm/components/use-pagination/index.js +1 -19
- package/esm/components/use-pagination/use-pagination.d.ts +1 -1
- package/esm/components/use-pagination/use-pagination.d.ts.map +1 -1
- package/esm/components/use-pagination/use-pagination.js +25 -25
- package/esm/components/use-pagination/use-pagination.type.js +1 -5
- package/esm/components/use-popup/index.js +1 -19
- package/esm/components/use-popup/popup-context.js +3 -9
- package/esm/components/use-popup/use-popup.js +35 -39
- package/esm/components/use-popup/use-popup.type.d.ts +1 -1
- package/esm/components/use-popup/use-popup.type.d.ts.map +1 -1
- package/esm/components/use-popup/use-popup.type.js +1 -5
- package/esm/components/use-select/index.js +2 -26
- package/esm/components/use-select/use-select-group.js +19 -22
- package/esm/components/use-select/use-select-group.type.js +1 -5
- package/esm/components/use-select/use-select.js +5 -12
- package/esm/components/use-select/use-select.type.d.ts +1 -1
- package/esm/components/use-select/use-select.type.d.ts.map +1 -1
- package/esm/components/use-select/use-select.type.js +1 -5
- package/esm/components/use-slider/index.js +1 -19
- package/esm/components/use-slider/use-slider.js +30 -32
- package/esm/components/use-slider/use-slider.type.js +1 -5
- package/esm/components/use-table/index.js +8 -68
- package/esm/components/use-table/use-table-columns.d.ts +1 -1
- package/esm/components/use-table/use-table-columns.d.ts.map +1 -1
- package/esm/components/use-table/use-table-columns.js +9 -20
- package/esm/components/use-table/use-table-expand.js +24 -35
- package/esm/components/use-table/use-table-group.js +5 -17
- package/esm/components/use-table/use-table-layout.d.ts.map +1 -1
- package/esm/components/use-table/use-table-layout.js +68 -75
- package/esm/components/use-table/use-table-row.js +18 -25
- package/esm/components/use-table/use-table-sort.d.ts +1 -1
- package/esm/components/use-table/use-table-sort.d.ts.map +1 -1
- package/esm/components/use-table/use-table-sort.js +34 -41
- package/esm/components/use-table/use-table-tree.d.ts +1 -1
- package/esm/components/use-table/use-table-tree.d.ts.map +1 -1
- package/esm/components/use-table/use-table-tree.js +61 -76
- package/esm/components/use-table/use-table-virtual.js +34 -36
- package/esm/components/use-table/use-table.type.d.ts +4 -4
- package/esm/components/use-table/use-table.type.d.ts.map +1 -1
- package/esm/components/use-table/use-table.type.js +1 -5
- package/esm/components/use-tabs/context.js +7 -21
- package/esm/components/use-tabs/context.type.js +1 -5
- package/esm/components/use-tabs/index.js +2 -26
- package/esm/components/use-tabs/use-tabs.js +13 -16
- package/esm/components/use-tabs/use-tabs.type.d.ts +1 -1
- package/esm/components/use-tabs/use-tabs.type.d.ts.map +1 -1
- package/esm/components/use-tabs/use-tabs.type.js +1 -5
- package/esm/components/use-textarea/index.js +2 -26
- package/esm/components/use-textarea/use-textarea-format.js +6 -15
- package/esm/components/use-textarea/use-textarea-format.type.d.ts +1 -1
- package/esm/components/use-textarea/use-textarea-format.type.d.ts.map +1 -1
- package/esm/components/use-textarea/use-textarea-format.type.js +1 -5
- package/esm/components/use-textarea/use-textarea.d.ts +2 -2
- package/esm/components/use-textarea/use-textarea.js +31 -32
- package/esm/components/use-textarea/use-textarea.type.d.ts +3 -3
- package/esm/components/use-textarea/use-textarea.type.d.ts.map +1 -1
- package/esm/components/use-textarea/use-textarea.type.js +1 -5
- package/esm/components/use-transfer/index.js +1 -19
- package/esm/components/use-transfer/use-transfer.js +33 -38
- package/esm/components/use-transfer/use-transfer.type.d.ts +1 -1
- package/esm/components/use-transfer/use-transfer.type.d.ts.map +1 -1
- package/esm/components/use-transfer/use-transfer.type.js +1 -5
- package/esm/components/use-tree/index.js +2 -26
- package/esm/components/use-tree/use-tree-node.js +17 -20
- package/esm/components/use-tree/use-tree-node.type.d.ts +2 -2
- package/esm/components/use-tree/use-tree-node.type.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree-node.type.js +1 -5
- package/esm/components/use-tree/use-tree.js +25 -37
- package/esm/components/use-tree/use-tree.type.d.ts +3 -3
- package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree.type.js +1 -5
- package/esm/components/use-treeselect/index.js +2 -26
- package/esm/components/use-treeselect/use-tiled.js +22 -24
- package/esm/components/use-treeselect/use-tiled.type.d.ts +1 -1
- package/esm/components/use-treeselect/use-tiled.type.d.ts.map +1 -1
- package/esm/components/use-treeselect/use-tiled.type.js +1 -5
- package/esm/components/use-treeselect/use-treeselect.js +3 -10
- package/esm/components/use-treeselect/use-treeselect.type.js +1 -5
- package/esm/components/use-upload/index.js +1 -19
- package/esm/components/use-upload/use-upload.js +57 -62
- package/esm/components/use-upload/use-upload.type.js +1 -5
- package/esm/components/use-upload/xhr.js +1 -8
- package/esm/components/use-validate/index.js +1 -19
- package/esm/components/use-validate/use-validate.js +16 -19
- package/esm/components/use-validate/use-validate.type.js +1 -5
- package/esm/index.js +48 -547
- package/esm/utils/accept.d.ts +1 -1
- package/esm/utils/accept.d.ts.map +1 -1
- package/esm/utils/accept.js +1 -11
- package/esm/utils/array.js +2 -10
- package/esm/utils/attribute.js +3 -11
- package/esm/utils/clone.js +19 -34
- package/esm/utils/document.js +11 -20
- package/esm/utils/dom/element.js +23 -33
- package/esm/utils/dom/index.js +5 -69
- package/esm/utils/dom/normalize-wheel.js +1 -7
- package/esm/utils/dom/normalize-wheel.type.js +1 -5
- package/esm/utils/dom/ready.js +3 -9
- package/esm/utils/dom/responsiveObserve.js +10 -21
- package/esm/utils/dom/responsiveObserve.type.d.ts +4 -4
- package/esm/utils/dom/responsiveObserve.type.d.ts.map +1 -1
- package/esm/utils/dom/responsiveObserve.type.js +1 -5
- package/esm/utils/dom/scroll-behavior.js +2 -9
- package/esm/utils/extract-event-handlers.js +1 -13
- package/esm/utils/func.js +3 -11
- package/esm/utils/immer.d.ts +1 -8
- package/esm/utils/immer.d.ts.map +1 -1
- package/esm/utils/immer.js +12 -20
- package/esm/utils/index.js +22 -269
- package/esm/utils/is.d.ts +1 -1
- package/esm/utils/is.d.ts.map +1 -1
- package/esm/utils/is.js +33 -69
- package/esm/utils/lazyload.d.ts +1 -1
- package/esm/utils/lazyload.d.ts.map +1 -1
- package/esm/utils/lazyload.js +6 -15
- package/esm/utils/number.js +6 -24
- package/esm/utils/object.d.ts +4 -4
- package/esm/utils/object.d.ts.map +1 -1
- package/esm/utils/object.js +30 -59
- package/esm/utils/position.js +8 -13
- package/esm/utils/react-render.d.ts +1 -1
- package/esm/utils/react-render.d.ts.map +1 -1
- package/esm/utils/react-render.js +16 -31
- package/esm/utils/render.d.ts +1 -1
- package/esm/utils/render.d.ts.map +1 -1
- package/esm/utils/render.js +4 -13
- package/esm/utils/rule/index.js +1 -19
- package/esm/utils/rule/length.d.ts +1 -1
- package/esm/utils/rule/length.js +11 -19
- package/esm/utils/rule/regexp.d.ts +1 -1
- package/esm/utils/rule/regexp.js +7 -18
- package/esm/utils/rule/required.d.ts +1 -1
- package/esm/utils/rule/required.js +6 -14
- package/esm/utils/rule/rule.js +20 -33
- package/esm/utils/rule/rule.type.d.ts +8 -8
- package/esm/utils/rule/rule.type.d.ts.map +1 -1
- package/esm/utils/rule/rule.type.js +1 -5
- package/esm/utils/rule/type.d.ts +1 -1
- package/esm/utils/rule/type.js +6 -14
- package/esm/utils/shallow-equal.js +7 -21
- package/esm/utils/string.js +2 -16
- package/esm/utils/style-unit.js +3 -11
- package/esm/utils/tree.d.ts +1 -1
- package/esm/utils/tree.d.ts.map +1 -1
- package/esm/utils/tree.js +24 -32
- package/esm/utils/uid.js +2 -20
- package/esm/utils/validate/error.js +23 -26
- package/esm/utils/validate/get-rule.js +16 -26
- package/esm/utils/validate/index.d.ts +1 -1
- package/esm/utils/validate/index.d.ts.map +1 -1
- package/esm/utils/validate/index.js +20 -40
- package/esm/utils/validate/isJson.js +3 -12
- package/esm/utils/validate/nullable.js +2 -9
- package/esm/utils/validate/type.d.ts +1 -1
- package/esm/utils/validate/type.d.ts.map +1 -1
- package/esm/utils/validate/type.js +8 -19
- package/package.json +3 -2
@@ -1,25 +1,18 @@
|
|
1
|
-
"use strict";
|
2
1
|
"use client";
|
3
|
-
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
6
|
-
value: true
|
7
|
-
});
|
8
|
-
exports.useKeyEvent = exports.default = void 0;
|
9
|
-
var _usePersistFn = _interopRequireDefault(require("../use-persist-fn"));
|
2
|
+
import usePersistFn from "../use-persist-fn";
|
10
3
|
var useKeyEvent = function useKeyEvent(params) {
|
11
|
-
var keyEvent = (
|
4
|
+
var keyEvent = usePersistFn(function (e) {
|
12
5
|
var _params$onEnterPress, _params$onEscPress, _params$onSpacePress;
|
13
6
|
var keyCode = e.keyCode;
|
14
7
|
switch (keyCode) {
|
15
8
|
case 13:
|
16
|
-
(_params$onEnterPress = params.onEnterPress) === null || _params$onEnterPress === void 0
|
9
|
+
(_params$onEnterPress = params.onEnterPress) === null || _params$onEnterPress === void 0 || _params$onEnterPress.call(params, e);
|
17
10
|
break;
|
18
11
|
case 27:
|
19
|
-
(_params$onEscPress = params.onEscPress) === null || _params$onEscPress === void 0
|
12
|
+
(_params$onEscPress = params.onEscPress) === null || _params$onEscPress === void 0 || _params$onEscPress.call(params, e);
|
20
13
|
break;
|
21
14
|
case 32:
|
22
|
-
(_params$onSpacePress = params.onSpacePress) === null || _params$onSpacePress === void 0
|
15
|
+
(_params$onSpacePress = params.onSpacePress) === null || _params$onSpacePress === void 0 || _params$onSpacePress.call(params, e);
|
23
16
|
break;
|
24
17
|
default:
|
25
18
|
break;
|
@@ -27,6 +20,5 @@ var useKeyEvent = function useKeyEvent(params) {
|
|
27
20
|
});
|
28
21
|
return keyEvent;
|
29
22
|
};
|
30
|
-
|
31
|
-
|
32
|
-
exports.default = _default;
|
23
|
+
export { useKeyEvent };
|
24
|
+
export default useKeyEvent;
|
@@ -1,20 +1,12 @@
|
|
1
|
-
"use strict";
|
2
1
|
"use client";
|
3
|
-
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
5
|
-
value: true
|
6
|
-
});
|
7
|
-
exports.default = void 0;
|
8
|
-
exports.useLatestObj = useLatestObj;
|
9
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
10
|
-
var _react = require("react");
|
2
|
+
import { useRef } from 'react';
|
11
3
|
//保持对象引用不变并且每次都是最新的
|
12
4
|
function useLatestObj(value) {
|
13
|
-
var ref =
|
5
|
+
var ref = useRef(value);
|
14
6
|
Object.keys(value).forEach(function (key) {
|
15
7
|
ref.current[key] = value[key];
|
16
8
|
});
|
17
9
|
return ref.current;
|
18
10
|
}
|
19
|
-
|
20
|
-
|
11
|
+
export { useLatestObj };
|
12
|
+
export default useLatestObj;
|
@@ -1,34 +1,4 @@
|
|
1
|
-
"use strict";
|
2
1
|
"use client";
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
value: true
|
7
|
-
});
|
8
|
-
Object.defineProperty(exports, "default", {
|
9
|
-
enumerable: true,
|
10
|
-
get: function get() {
|
11
|
-
return _useListSelectMultiple.default;
|
12
|
-
}
|
13
|
-
});
|
14
|
-
Object.defineProperty(exports, "useListSelect", {
|
15
|
-
enumerable: true,
|
16
|
-
get: function get() {
|
17
|
-
return _useListSelect.default;
|
18
|
-
}
|
19
|
-
});
|
20
|
-
Object.defineProperty(exports, "useListSelectMultiple", {
|
21
|
-
enumerable: true,
|
22
|
-
get: function get() {
|
23
|
-
return _useListSelectMultiple.default;
|
24
|
-
}
|
25
|
-
});
|
26
|
-
Object.defineProperty(exports, "useListSelectSingle", {
|
27
|
-
enumerable: true,
|
28
|
-
get: function get() {
|
29
|
-
return _useListSelectSingle.default;
|
30
|
-
}
|
31
|
-
});
|
32
|
-
var _useListSelectMultiple = _interopRequireDefault(require("./use-list-select-multiple"));
|
33
|
-
var _useListSelectSingle = _interopRequireDefault(require("./use-list-select-single"));
|
34
|
-
var _useListSelect = _interopRequireDefault(require("./use-list-select"));
|
2
|
+
export { default, default as useListSelectMultiple } from "./use-list-select-multiple";
|
3
|
+
export { default as useListSelectSingle } from "./use-list-select-single";
|
4
|
+
export { default as useListSelect } from "./use-list-select";
|
@@ -1,36 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
require("core-js/modules/es.weak-map.js");
|
6
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
7
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
8
|
-
Object.defineProperty(exports, "__esModule", {
|
9
|
-
value: true
|
10
|
-
});
|
11
|
-
exports.default = void 0;
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
13
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
14
|
-
require("core-js/modules/es.regexp.exec.js");
|
15
|
-
require("core-js/modules/es.string.split.js");
|
16
|
-
require("core-js/modules/es.array.iterator.js");
|
17
|
-
require("core-js/modules/es.map.js");
|
18
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
19
|
-
require("core-js/modules/es.array.filter.js");
|
20
|
-
require("core-js/modules/es.array.concat.js");
|
21
|
-
require("core-js/modules/es.set.js");
|
22
|
-
require("core-js/modules/es.array.splice.js");
|
23
|
-
require("core-js/modules/es.array.from.js");
|
24
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
25
|
-
require("core-js/modules/es.object.values.js");
|
26
|
-
var _utils = require("../../utils");
|
27
|
-
var _react = _interopRequireWildcard(require("react"));
|
28
|
-
var _usePersistFn = _interopRequireDefault(require("../use-persist-fn"));
|
29
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
30
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
4
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
31
5
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
6
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
7
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
32
8
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
9
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
10
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
33
11
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
12
|
+
import { isArray, isObject } from "../../utils";
|
13
|
+
import React, { useMemo } from 'react';
|
14
|
+
import usePersistFn from "../use-persist-fn";
|
34
15
|
var isUnMatchedData = function isUnMatchedData(data) {
|
35
16
|
return data && data.IS_NOT_MATCHED_VALUE;
|
36
17
|
};
|
@@ -46,7 +27,7 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
46
27
|
} else {
|
47
28
|
valueArr = props.value || [];
|
48
29
|
}
|
49
|
-
var _React$useRef =
|
30
|
+
var _React$useRef = React.useRef({
|
50
31
|
lastValue: undefined,
|
51
32
|
valueMap: new Map(),
|
52
33
|
lastData: [],
|
@@ -54,23 +35,23 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
54
35
|
flatDataCache: new Map()
|
55
36
|
}),
|
56
37
|
context = _React$useRef.current;
|
57
|
-
var disabledCheck = (
|
38
|
+
var disabledCheck = usePersistFn(function (data) {
|
58
39
|
if (typeof props.disabled === 'boolean') return props.disabled;
|
59
40
|
if (typeof props.disabled === 'function') return props.disabled(data);
|
60
41
|
return false;
|
61
42
|
});
|
62
|
-
var formatData = (
|
63
|
-
if (typeof props.format === 'string' &&
|
43
|
+
var formatData = usePersistFn(function (data) {
|
44
|
+
if (typeof props.format === 'string' && isObject(data)) return data[props.format];
|
64
45
|
if (typeof props.format === 'function') return props.format(data);
|
65
46
|
return data;
|
66
47
|
});
|
67
|
-
var getVaildData = (
|
48
|
+
var getVaildData = usePersistFn(function () {
|
68
49
|
var vaildData = props.data.filter(function (item) {
|
69
50
|
return !disabledCheck(item);
|
70
51
|
});
|
71
52
|
return vaildData;
|
72
53
|
});
|
73
|
-
var getFlatDataValue = (
|
54
|
+
var getFlatDataValue = usePersistFn(function (data, childrenKey) {
|
74
55
|
var values = [];
|
75
56
|
for (var i = 0; i < data.length; i++) {
|
76
57
|
var item = data[i];
|
@@ -83,13 +64,13 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
83
64
|
if (childrenKey && item && item[childrenKey]) {
|
84
65
|
var children = item[childrenKey];
|
85
66
|
if (children.length) {
|
86
|
-
values.push.apply(values, (
|
67
|
+
values.push.apply(values, _toConsumableArray(getFlatDataValue(children, childrenKey)));
|
87
68
|
}
|
88
69
|
}
|
89
70
|
}
|
90
71
|
return values;
|
91
72
|
});
|
92
|
-
var getFlatData = (
|
73
|
+
var getFlatData = usePersistFn(function (data, childrenKey) {
|
93
74
|
var dataArr = [];
|
94
75
|
for (var i = 0; i < data.length; i++) {
|
95
76
|
var item = data[i];
|
@@ -98,13 +79,13 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
98
79
|
if (childrenKey && item && item[childrenKey]) {
|
99
80
|
var children = item[childrenKey];
|
100
81
|
if (children.length) {
|
101
|
-
dataArr.push.apply(dataArr, (
|
82
|
+
dataArr.push.apply(dataArr, _toConsumableArray(getFlatData(children, childrenKey)));
|
102
83
|
}
|
103
84
|
}
|
104
85
|
}
|
105
86
|
return dataArr;
|
106
87
|
});
|
107
|
-
var getDataMap = (
|
88
|
+
var getDataMap = usePersistFn(function (childrenKey) {
|
108
89
|
// data 对应 value
|
109
90
|
if (props.data === context.lastData) return context.dataMap;
|
110
91
|
var map = new Map();
|
@@ -128,11 +109,11 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
128
109
|
context.lastValue = props.value;
|
129
110
|
return map;
|
130
111
|
};
|
131
|
-
var add = (
|
112
|
+
var add = usePersistFn(function (data) {
|
132
113
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
133
114
|
if (data === null || data === undefined) return;
|
134
115
|
var childrenKey = config.childrenKey;
|
135
|
-
var values = getFlatDataValue(
|
116
|
+
var values = getFlatDataValue(isArray(data) ? data : [data], childrenKey);
|
136
117
|
var before = config.overwrite ? [] : valueArr || [];
|
137
118
|
if (values.length) {
|
138
119
|
var newValue = config.unshift ? values.concat(before) : before.concat(values);
|
@@ -140,18 +121,18 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
140
121
|
props.onChange(valueResult, data, true);
|
141
122
|
}
|
142
123
|
});
|
143
|
-
var removeAll = (
|
124
|
+
var removeAll = usePersistFn(function () {
|
144
125
|
props.onChange([], undefined, false);
|
145
126
|
});
|
146
127
|
|
147
128
|
// 删除数据
|
148
129
|
|
149
|
-
var remove = (
|
130
|
+
var remove = usePersistFn(function (data) {
|
150
131
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
151
132
|
if (data === null || data === undefined) return;
|
152
133
|
var childrenKey = config.childrenKey;
|
153
134
|
var values = [];
|
154
|
-
var raws =
|
135
|
+
var raws = isArray(data) ? _toConsumableArray(data) : [data];
|
155
136
|
if (!props.prediction) {
|
156
137
|
var removeValue = getFlatDataValue(raws, childrenKey);
|
157
138
|
var rowValueSet = new Set(removeValue);
|
@@ -188,7 +169,7 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
188
169
|
var valueResult = props.separator ? values.join(props.separator) : values;
|
189
170
|
props.onChange(valueResult, data, false);
|
190
171
|
});
|
191
|
-
var check = (
|
172
|
+
var check = usePersistFn(function (raw) {
|
192
173
|
if (props.prediction) {
|
193
174
|
for (var i = 0, count = valueArr.length; i < count; i++) {
|
194
175
|
if (props.prediction(valueArr[i], raw)) return true;
|
@@ -197,7 +178,7 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
197
178
|
}
|
198
179
|
return !!getValueMap().get(formatData(raw));
|
199
180
|
});
|
200
|
-
var getDataByValues = (
|
181
|
+
var getDataByValues = usePersistFn(function (values) {
|
201
182
|
var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
202
183
|
var map = getDataMap(info.childrenKey);
|
203
184
|
var result = [];
|
@@ -217,10 +198,10 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
217
198
|
} else {
|
218
199
|
// 获取map value 数组
|
219
200
|
var raws = Array.from(map.values());
|
220
|
-
outer: for (var
|
201
|
+
outer: for (var _i = 0; _i < values.length; _i++) {
|
221
202
|
for (var j = 0; j < raws.length; j++) {
|
222
203
|
var _item = raws[j];
|
223
|
-
if (props.prediction(values[
|
204
|
+
if (props.prediction(values[_i], _item)) {
|
224
205
|
result.push(_item);
|
225
206
|
raws.splice(j, 1);
|
226
207
|
continue outer;
|
@@ -228,38 +209,35 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
228
209
|
}
|
229
210
|
result.push({
|
230
211
|
IS_NOT_MATCHED_VALUE: true,
|
231
|
-
value: values[
|
212
|
+
value: values[_i]
|
232
213
|
});
|
233
214
|
}
|
234
215
|
}
|
235
216
|
return result;
|
236
217
|
});
|
237
|
-
var getCheckedStatus = (
|
218
|
+
var getCheckedStatus = usePersistFn(function (childrenKey) {
|
238
219
|
if (valueArr.length === 0) return false;
|
239
220
|
var dataMap = getDataMap(childrenKey);
|
240
|
-
var valueMap = getValueMap();
|
241
221
|
var formatValues = Array.from(dataMap, function (_ref) {
|
242
|
-
var _ref2 = (
|
243
|
-
|
222
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
223
|
+
_value = _ref2[0],
|
244
224
|
data = _ref2[1];
|
245
|
-
return
|
225
|
+
return data;
|
246
226
|
});
|
247
227
|
var checkedNum = 0;
|
248
228
|
var validateNum = 0;
|
249
|
-
formatValues.
|
250
|
-
var
|
251
|
-
value = _ref4[0],
|
252
|
-
data = _ref4[1];
|
229
|
+
for (var i = 0; i < formatValues.length; i++) {
|
230
|
+
var data = formatValues[i];
|
253
231
|
if (!disabledCheck(data)) {
|
254
232
|
validateNum++;
|
255
|
-
if (
|
233
|
+
if (check(data)) checkedNum++;
|
256
234
|
}
|
257
|
-
}
|
235
|
+
}
|
258
236
|
if (checkedNum === 0) return false;
|
259
237
|
if (checkedNum === validateNum) return true;
|
260
238
|
return 'indeterminate';
|
261
239
|
});
|
262
|
-
var func =
|
240
|
+
var func = useMemo(function () {
|
263
241
|
return {
|
264
242
|
add: add,
|
265
243
|
remove: remove,
|
@@ -277,5 +255,4 @@ var useListSelectMultiple = function useListSelectMultiple(props) {
|
|
277
255
|
}, Object.values(props));
|
278
256
|
return func;
|
279
257
|
};
|
280
|
-
|
281
|
-
exports.default = _default;
|
258
|
+
export default useListSelectMultiple;
|
@@ -1,46 +1,37 @@
|
|
1
|
-
"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
var
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
|
11
|
-
require("core-js/modules/es.object.values.js");
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
|
-
var _useListSelectMultiple = _interopRequireDefault(require("./use-list-select-multiple"));
|
14
|
-
var _usePersistFn = _interopRequireDefault(require("../use-persist-fn"));
|
15
|
-
var _utils = require("../../utils");
|
16
|
-
var _react = require("react");
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
7
|
+
import useListSelectMultiple from "./use-list-select-multiple";
|
8
|
+
import usePersistFn from "../use-persist-fn";
|
9
|
+
import { isArray } from "../../utils";
|
10
|
+
import { useMemo } from 'react';
|
19
11
|
var useListSelectSingle = function useListSelectSingle(props) {
|
20
|
-
var onChange = (
|
12
|
+
var onChange = usePersistFn(function (value, data, checked) {
|
21
13
|
var _props$onChange;
|
22
|
-
(_props$onChange = props.onChange) === null || _props$onChange === void 0
|
14
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, value[0], data, checked);
|
23
15
|
});
|
24
16
|
var getValue = function getValue(v) {
|
25
17
|
if (v === undefined || v === null) return v;
|
26
|
-
if (
|
18
|
+
if (isArray(v)) return v;
|
27
19
|
return [v];
|
28
20
|
};
|
29
|
-
var list = (
|
21
|
+
var list = useListSelectMultiple(_objectSpread(_objectSpread({}, props), {}, {
|
30
22
|
value: getValue(props.value),
|
31
23
|
onChange: onChange
|
32
24
|
}));
|
33
|
-
var add = (
|
25
|
+
var add = usePersistFn(function (data) {
|
34
26
|
list.add(data, {
|
35
27
|
overwrite: true
|
36
28
|
});
|
37
29
|
});
|
38
|
-
var result =
|
30
|
+
var result = useMemo(function () {
|
39
31
|
return _objectSpread(_objectSpread({}, list), {}, {
|
40
32
|
add: add
|
41
33
|
});
|
42
34
|
}, Object.values(props));
|
43
35
|
return result;
|
44
36
|
};
|
45
|
-
|
46
|
-
exports.default = _default;
|
37
|
+
export default useListSelectSingle;
|
@@ -1,20 +1,12 @@
|
|
1
|
-
"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
var
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
exports.default = void 0;
|
11
|
-
require("core-js/modules/es.object.values.js");
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
|
-
var _react = require("react");
|
14
|
-
var _usePersistFn = _interopRequireDefault(require("../use-persist-fn"));
|
15
|
-
var _useListSelectMultiple = _interopRequireDefault(require("./use-list-select-multiple"));
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
17
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
7
|
+
import { useMemo } from 'react';
|
8
|
+
import usePersistFn from "../use-persist-fn";
|
9
|
+
import useListSelectMultiple from "./use-list-select-multiple";
|
18
10
|
var useListSelect = function useListSelect(props) {
|
19
11
|
var multiple = props.multiple;
|
20
12
|
var value = props.value;
|
@@ -25,26 +17,26 @@ var useListSelect = function useListSelect(props) {
|
|
25
17
|
value = [props.value];
|
26
18
|
}
|
27
19
|
}
|
28
|
-
var onChange = (
|
20
|
+
var onChange = usePersistFn(function (value, data, checked) {
|
29
21
|
if (multiple) {
|
30
22
|
var _props$onChange;
|
31
|
-
(_props$onChange = props.onChange) === null || _props$onChange === void 0
|
23
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, value, data, checked);
|
32
24
|
} else {
|
33
25
|
var _props$onChange2;
|
34
|
-
(_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0
|
26
|
+
(_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0 || _props$onChange2.call(props, value[0], data, checked);
|
35
27
|
}
|
36
28
|
});
|
37
|
-
var datum = (
|
29
|
+
var datum = useListSelectMultiple(_objectSpread(_objectSpread({}, props), {}, {
|
38
30
|
value: value,
|
39
31
|
onChange: onChange,
|
40
32
|
prediction: props.prediction
|
41
33
|
}));
|
42
|
-
var add = (
|
34
|
+
var add = usePersistFn(function (data) {
|
43
35
|
datum.add(data, {
|
44
36
|
overwrite: true
|
45
37
|
});
|
46
38
|
});
|
47
|
-
var result =
|
39
|
+
var result = useMemo(function () {
|
48
40
|
if (!multiple) {
|
49
41
|
return _objectSpread(_objectSpread({}, datum), {}, {
|
50
42
|
add: add
|
@@ -54,5 +46,4 @@ var useListSelect = function useListSelect(props) {
|
|
54
46
|
}, Object.values(props));
|
55
47
|
return result;
|
56
48
|
};
|
57
|
-
|
58
|
-
exports.default = _default;
|
49
|
+
export default useListSelect;
|
@@ -1,33 +1,30 @@
|
|
1
|
-
"use strict";
|
2
1
|
"use client";
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
var
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
var
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
2
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
9
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
12
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
14
|
+
import { useState, useMemo } from 'react';
|
15
|
+
import usePersistFn from "../use-persist-fn";
|
19
16
|
var usePaginationList = function usePaginationList(props) {
|
20
|
-
var _useState =
|
21
|
-
_useState2 = (
|
17
|
+
var _useState = useState(props.defaultCurrent || 1),
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
22
19
|
current = _useState2[0],
|
23
20
|
setCurrent = _useState2[1];
|
24
|
-
var _useState3 =
|
25
|
-
_useState4 = (
|
21
|
+
var _useState3 = useState(props.pageSize || 10),
|
22
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
26
23
|
pageSize = _useState4[0],
|
27
24
|
setPageSize = _useState4[1];
|
28
25
|
var _props$shouldPage = props.shouldPage,
|
29
26
|
shouldPage = _props$shouldPage === void 0 ? true : _props$shouldPage;
|
30
|
-
var handleChange = (
|
27
|
+
var handleChange = usePersistFn(function (current, pageSize) {
|
31
28
|
setCurrent(current);
|
32
29
|
setPageSize(pageSize);
|
33
30
|
if (props.onChange) props.onChange(current, pageSize);
|
@@ -52,13 +49,12 @@ var usePaginationList = function usePaginationList(props) {
|
|
52
49
|
return data.slice(start, start + pageSize);
|
53
50
|
};
|
54
51
|
var page = getPager(props.data);
|
55
|
-
var data =
|
52
|
+
var data = useMemo(function () {
|
56
53
|
return getData(props.data, page.pageSize, page.current);
|
57
54
|
}, [props.data, page.pageSize, page.current]);
|
58
55
|
return _objectSpread(_objectSpread({}, page), {}, {
|
59
56
|
data: data
|
60
57
|
});
|
61
58
|
};
|
62
|
-
|
63
|
-
|
64
|
-
exports.default = _default;
|
59
|
+
export default usePaginationList;
|
60
|
+
export { usePaginationList };
|
@@ -1,21 +1,15 @@
|
|
1
|
-
"use strict";
|
2
1
|
"use client";
|
2
|
+
import { useRef } from 'react';
|
3
3
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
5
|
-
value: true
|
6
|
-
});
|
7
|
-
exports.default = void 0;
|
8
|
-
exports.usePersistFn = usePersistFn;
|
9
|
-
var _react = require("react");
|
10
4
|
/**
|
11
5
|
* 持久化缓存函数
|
12
6
|
* @param fn 函数 {@link T | T}
|
13
7
|
* @return 被持久化引用地址的函数 {@link T | T}
|
14
8
|
*/
|
15
9
|
function usePersistFn(fn) {
|
16
|
-
var fnRef =
|
10
|
+
var fnRef = useRef(fn);
|
17
11
|
fnRef.current = fn;
|
18
|
-
var persistFn =
|
12
|
+
var persistFn = useRef();
|
19
13
|
if (!persistFn.current) {
|
20
14
|
// @ts-expect-error //TODO 这里可能要单独的去处理一下类型
|
21
15
|
persistFn.current = function () {
|
@@ -24,5 +18,5 @@ function usePersistFn(fn) {
|
|
24
18
|
}
|
25
19
|
return persistFn.current;
|
26
20
|
}
|
27
|
-
|
28
|
-
|
21
|
+
export { usePersistFn };
|
22
|
+
export default usePersistFn;
|