@1money/react-ui 1.15.3 → 1.17.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/AGENTS.md +393 -0
- package/es/components/CheckboxGroup/CheckboxGroup.d.ts +3 -3
- package/es/components/CheckboxGroup/CheckboxGroup.js +94 -91
- package/es/components/CheckboxGroup/interface.d.ts +21 -15
- package/es/components/CheckboxGroup/style/CheckboxGroup.scss +0 -7
- package/es/components/Flex/Flex.d.ts +5 -0
- package/es/components/Flex/Flex.js +50 -0
- package/es/components/Flex/constants.d.ts +41 -0
- package/es/components/Flex/constants.js +45 -0
- package/es/components/Flex/index.d.ts +5 -0
- package/es/components/Flex/index.js +6 -0
- package/es/components/Flex/interface.d.ts +13 -0
- package/es/components/Flex/interface.js +2 -0
- package/es/components/Flex/style/Flex.css +1 -0
- package/es/components/Flex/style/Flex.scss +70 -0
- package/es/components/Flex/style/css.js +2 -0
- package/es/components/Flex/style/index.d.ts +1 -0
- package/es/components/Flex/style/index.js +2 -0
- package/es/components/Form/Form.d.ts +29 -0
- package/es/components/Form/Form.js +188 -0
- package/es/components/Form/FormItem.d.ts +4 -0
- package/es/components/Form/FormItem.js +165 -0
- package/es/components/Form/FormItemContent.d.ts +18 -0
- package/es/components/Form/FormItemContent.js +146 -0
- package/es/components/Form/constants.d.ts +46 -0
- package/es/components/Form/constants.js +65 -0
- package/es/components/Form/helper.d.ts +120 -0
- package/es/components/Form/helper.js +284 -0
- package/es/components/Form/index.d.ts +20 -0
- package/es/components/Form/index.js +21 -0
- package/es/components/Form/interface.d.ts +238 -0
- package/es/components/Form/interface.js +2 -0
- package/es/components/Form/style/Form.css +1 -0
- package/es/components/Form/style/Form.scss +167 -0
- package/es/components/Form/style/css.js +2 -0
- package/es/components/Form/style/index.d.ts +1 -0
- package/es/components/Form/style/index.js +2 -0
- package/es/components/Form/useFormItemContext.d.ts +32 -0
- package/es/components/Form/useFormItemContext.js +55 -0
- package/es/components/Form/useFormItemWatch.d.ts +51 -0
- package/es/components/Form/useFormItemWatch.js +69 -0
- package/es/components/Form/useValidationTrigger.d.ts +40 -0
- package/es/components/Form/useValidationTrigger.js +74 -0
- package/es/components/Grid/Col.d.ts +5 -0
- package/es/components/Grid/Col.js +97 -0
- package/es/components/Grid/Grid.d.ts +12 -0
- package/es/components/Grid/Grid.js +12 -0
- package/es/components/Grid/Row.d.ts +5 -0
- package/es/components/Grid/Row.js +48 -0
- package/es/components/Grid/constants.d.ts +55 -0
- package/es/components/Grid/constants.js +66 -0
- package/es/components/Grid/helper.d.ts +10 -0
- package/es/components/Grid/helper.js +44 -0
- package/es/components/Grid/index.d.ts +7 -0
- package/es/components/Grid/index.js +8 -0
- package/es/components/Grid/interface.d.ts +38 -0
- package/es/components/Grid/interface.js +2 -0
- package/es/components/Grid/style/Grid.css +1 -0
- package/es/components/Grid/style/Grid.scss +196 -0
- package/es/components/Grid/style/css.js +2 -0
- package/es/components/Grid/style/index.d.ts +1 -0
- package/es/components/Grid/style/index.js +2 -0
- package/es/components/Input/Input.js +72 -74
- package/es/components/Input/interface.d.ts +9 -9
- package/es/components/InputAmount/InputAmount.js +228 -276
- package/es/components/InputAmount/helper.d.ts +46 -0
- package/es/components/InputAmount/helper.js +115 -0
- package/es/components/InputAmount/style/normal.css +1 -1
- package/es/components/InputAmount/style/normal.scss +2 -2
- package/es/components/InputAmount/style/primary.css +1 -1
- package/es/components/InputAmount/style/primary.scss +2 -2
- package/es/components/Message/style/Message.css +1 -1
- package/es/components/Message/style/Message.scss +3 -3
- package/es/components/ProForm/ProForm.d.ts +33 -0
- package/es/components/ProForm/ProForm.js +208 -0
- package/es/components/ProForm/ProFormDependency.d.ts +12 -0
- package/es/components/ProForm/ProFormDependency.js +61 -0
- package/es/components/ProForm/ProFormList.d.ts +19 -0
- package/es/components/ProForm/ProFormList.js +348 -0
- package/es/components/ProForm/Submitter.d.ts +21 -0
- package/es/components/ProForm/Submitter.js +76 -0
- package/es/components/ProForm/constants.d.ts +34 -0
- package/es/components/ProForm/constants.js +40 -0
- package/es/components/ProForm/fields/ProFormCheckbox.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormCheckbox.js +11 -0
- package/es/components/ProForm/fields/ProFormCheckboxGroup.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormCheckboxGroup.js +46 -0
- package/es/components/ProForm/fields/ProFormDigit.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormDigit.js +15 -0
- package/es/components/ProForm/fields/ProFormMoney.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormMoney.js +10 -0
- package/es/components/ProForm/fields/ProFormMultiSelect.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormMultiSelect.js +27 -0
- package/es/components/ProForm/fields/ProFormPassword.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormPassword.js +16 -0
- package/es/components/ProForm/fields/ProFormRadio.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormRadio.js +13 -0
- package/es/components/ProForm/fields/ProFormSelect.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormSelect.js +13 -0
- package/es/components/ProForm/fields/ProFormSwitch.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormSwitch.js +11 -0
- package/es/components/ProForm/fields/ProFormText.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormText.js +15 -0
- package/es/components/ProForm/fields/ProFormTextArea.d.ts +6 -0
- package/es/components/ProForm/fields/ProFormTextArea.js +16 -0
- package/es/components/ProForm/fields/createProFormField.d.ts +43 -0
- package/es/components/ProForm/fields/createProFormField.js +200 -0
- package/es/components/ProForm/fields/index.d.ts +12 -0
- package/es/components/ProForm/fields/index.js +13 -0
- package/es/components/ProForm/index.d.ts +7 -0
- package/es/components/ProForm/index.js +7 -0
- package/es/components/ProForm/interface.d.ts +306 -0
- package/es/components/ProForm/interface.js +2 -0
- package/es/components/ProForm/layouts/DrawerForm.d.ts +16 -0
- package/es/components/ProForm/layouts/DrawerForm.js +79 -0
- package/es/components/ProForm/layouts/ModalForm.d.ts +16 -0
- package/es/components/ProForm/layouts/ModalForm.js +89 -0
- package/es/components/ProForm/layouts/QueryFilter.d.ts +21 -0
- package/es/components/ProForm/layouts/QueryFilter.js +132 -0
- package/es/components/ProForm/layouts/StepsForm.d.ts +13 -0
- package/es/components/ProForm/layouts/StepsForm.js +295 -0
- package/es/components/ProForm/layouts/index.d.ts +4 -0
- package/es/components/ProForm/layouts/index.js +5 -0
- package/es/components/ProForm/layouts/useOverlayForm.d.ts +53 -0
- package/es/components/ProForm/layouts/useOverlayForm.js +143 -0
- package/es/components/ProForm/style/ProForm.module.css +1 -0
- package/es/components/ProForm/style/ProForm.module.scss +59 -0
- package/es/components/ProForm/style/css.js +3 -0
- package/es/components/ProForm/style/index.d.ts +1 -0
- package/es/components/ProForm/style/index.js +3 -0
- package/es/components/ProForm/utils.d.ts +72 -0
- package/es/components/ProForm/utils.js +206 -0
- package/es/components/RadioGroup/RadioGroup.js +46 -23
- package/es/components/RadioGroup/interface.d.ts +3 -1
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/Select/Select.js +113 -106
- package/es/components/Select/constants.d.ts +18 -0
- package/es/components/Select/constants.js +19 -0
- package/es/components/Sidebar/Sidebar.js +21 -23
- package/es/components/Sidebar/SidebarLogo.d.ts +7 -0
- package/es/components/Sidebar/SidebarLogo.js +33 -0
- package/es/components/Sidebar/SimplySidebar.d.ts +2 -2
- package/es/components/Sidebar/SimplySidebar.js +18 -22
- package/es/components/Sidebar/Stepper.js +14 -14
- package/es/components/Sidebar/constants.d.ts +16 -0
- package/es/components/Sidebar/constants.js +17 -0
- package/es/components/Sidebar/style/Sidebar.css +1 -1
- package/es/components/Sidebar/style/Sidebar.scss +1 -1
- package/es/components/Sidebar/style/SimplySidebar.css +1 -1
- package/es/components/Sidebar/style/SimplySidebar.scss +1 -1
- package/es/components/Sidebar/style/Stepper.css +1 -1
- package/es/components/Sidebar/style/Stepper.scss +11 -1
- package/es/components/Space/Space.d.ts +5 -0
- package/es/components/Space/Space.js +71 -0
- package/es/components/Space/constants.d.ts +33 -0
- package/es/components/Space/constants.js +37 -0
- package/es/components/Space/index.d.ts +5 -0
- package/es/components/Space/index.js +6 -0
- package/es/components/Space/interface.d.ts +12 -0
- package/es/components/Space/interface.js +2 -0
- package/es/components/Space/style/Space.css +1 -0
- package/es/components/Space/style/Space.scss +40 -0
- package/es/components/Space/style/css.js +2 -0
- package/es/components/Space/style/index.d.ts +1 -0
- package/es/components/Space/style/index.js +2 -0
- package/es/components/Switch/Switch.js +28 -25
- package/es/components/Switch/interface.d.ts +9 -4
- package/es/components/useControlledState/index.d.ts +14 -0
- package/es/components/useControlledState/index.js +32 -0
- package/es/components/useEventCallback/index.d.ts +11 -0
- package/es/components/useEventCallback/index.js +17 -0
- package/es/components/useLayoutEffect/index.d.ts +11 -0
- package/es/components/useLayoutEffect/index.js +17 -0
- package/es/components/useLayoutState/index.d.ts +13 -0
- package/es/components/useLayoutState/index.js +71 -0
- package/es/components/useMemoizedFn/index.d.ts +12 -0
- package/es/components/useMemoizedFn/index.js +27 -0
- package/es/components/usePrevious/index.d.ts +11 -0
- package/es/components/usePrevious/index.js +19 -0
- package/es/components/useSafeState/index.d.ts +12 -0
- package/es/components/useSafeState/index.js +24 -0
- package/es/components/useSyncState/index.d.ts +14 -0
- package/es/components/useSyncState/index.js +37 -0
- package/es/components/useUpdateEffect/index.d.ts +9 -0
- package/es/components/useUpdateEffect/index.js +19 -0
- package/es/index.css +1 -1
- package/es/index.d.ts +32 -2
- package/es/index.js +30 -1
- package/jest.setup.d.ts +1 -0
- package/jest.setup.ts +1 -0
- package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +3 -3
- package/lib/components/CheckboxGroup/CheckboxGroup.js +92 -89
- package/lib/components/CheckboxGroup/interface.d.ts +21 -15
- package/lib/components/CheckboxGroup/style/CheckboxGroup.scss +0 -7
- package/lib/components/Flex/Flex.d.ts +5 -0
- package/lib/components/Flex/Flex.js +60 -0
- package/lib/components/Flex/constants.d.ts +41 -0
- package/lib/components/Flex/constants.js +51 -0
- package/lib/components/Flex/index.d.ts +5 -0
- package/lib/components/Flex/index.js +60 -0
- package/lib/components/Flex/interface.d.ts +13 -0
- package/lib/components/Flex/interface.js +6 -0
- package/lib/components/Flex/style/Flex.css +1 -0
- package/lib/components/Flex/style/Flex.scss +70 -0
- package/lib/components/Flex/style/css.js +4 -0
- package/lib/components/Flex/style/index.d.ts +1 -0
- package/lib/components/Flex/style/index.js +4 -0
- package/lib/components/Form/Form.d.ts +29 -0
- package/lib/components/Form/Form.js +199 -0
- package/lib/components/Form/FormItem.d.ts +4 -0
- package/lib/components/Form/FormItem.js +176 -0
- package/lib/components/Form/FormItemContent.d.ts +18 -0
- package/lib/components/Form/FormItemContent.js +156 -0
- package/lib/components/Form/constants.d.ts +46 -0
- package/lib/components/Form/constants.js +71 -0
- package/lib/components/Form/helper.d.ts +120 -0
- package/lib/components/Form/helper.js +290 -0
- package/lib/components/Form/index.d.ts +20 -0
- package/lib/components/Form/index.js +45 -0
- package/lib/components/Form/interface.d.ts +238 -0
- package/lib/components/Form/interface.js +6 -0
- package/lib/components/Form/style/Form.css +1 -0
- package/lib/components/Form/style/Form.scss +167 -0
- package/lib/components/Form/style/css.js +4 -0
- package/lib/components/Form/style/index.d.ts +1 -0
- package/lib/components/Form/style/index.js +4 -0
- package/lib/components/Form/useFormItemContext.d.ts +32 -0
- package/lib/components/Form/useFormItemContext.js +62 -0
- package/lib/components/Form/useFormItemWatch.d.ts +51 -0
- package/lib/components/Form/useFormItemWatch.js +76 -0
- package/lib/components/Form/useValidationTrigger.d.ts +40 -0
- package/lib/components/Form/useValidationTrigger.js +81 -0
- package/lib/components/Grid/Col.d.ts +5 -0
- package/lib/components/Grid/Col.js +107 -0
- package/lib/components/Grid/Grid.d.ts +12 -0
- package/lib/components/Grid/Grid.js +18 -0
- package/lib/components/Grid/Row.d.ts +5 -0
- package/lib/components/Grid/Row.js +58 -0
- package/lib/components/Grid/constants.d.ts +55 -0
- package/lib/components/Grid/constants.js +72 -0
- package/lib/components/Grid/helper.d.ts +10 -0
- package/lib/components/Grid/helper.js +51 -0
- package/lib/components/Grid/index.d.ts +7 -0
- package/lib/components/Grid/index.js +62 -0
- package/lib/components/Grid/interface.d.ts +38 -0
- package/lib/components/Grid/interface.js +6 -0
- package/lib/components/Grid/style/Grid.css +1 -0
- package/lib/components/Grid/style/Grid.scss +196 -0
- package/lib/components/Grid/style/css.js +4 -0
- package/lib/components/Grid/style/index.d.ts +1 -0
- package/lib/components/Grid/style/index.js +4 -0
- package/lib/components/Input/Input.js +71 -73
- package/lib/components/Input/interface.d.ts +9 -9
- package/lib/components/InputAmount/InputAmount.js +230 -278
- package/lib/components/InputAmount/helper.d.ts +46 -0
- package/lib/components/InputAmount/helper.js +122 -0
- package/lib/components/InputAmount/style/normal.css +1 -1
- package/lib/components/InputAmount/style/normal.scss +2 -2
- package/lib/components/InputAmount/style/primary.css +1 -1
- package/lib/components/InputAmount/style/primary.scss +2 -2
- package/lib/components/Message/style/Message.css +1 -1
- package/lib/components/Message/style/Message.scss +3 -3
- package/lib/components/ProForm/ProForm.d.ts +33 -0
- package/lib/components/ProForm/ProForm.js +216 -0
- package/lib/components/ProForm/ProFormDependency.d.ts +12 -0
- package/lib/components/ProForm/ProFormDependency.js +67 -0
- package/lib/components/ProForm/ProFormList.d.ts +19 -0
- package/lib/components/ProForm/ProFormList.js +355 -0
- package/lib/components/ProForm/Submitter.d.ts +21 -0
- package/lib/components/ProForm/Submitter.js +83 -0
- package/lib/components/ProForm/constants.d.ts +34 -0
- package/lib/components/ProForm/constants.js +46 -0
- package/lib/components/ProForm/fields/ProFormCheckbox.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormCheckbox.js +18 -0
- package/lib/components/ProForm/fields/ProFormCheckboxGroup.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormCheckboxGroup.js +53 -0
- package/lib/components/ProForm/fields/ProFormDigit.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormDigit.js +22 -0
- package/lib/components/ProForm/fields/ProFormMoney.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormMoney.js +17 -0
- package/lib/components/ProForm/fields/ProFormMultiSelect.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormMultiSelect.js +34 -0
- package/lib/components/ProForm/fields/ProFormPassword.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormPassword.js +23 -0
- package/lib/components/ProForm/fields/ProFormRadio.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormRadio.js +20 -0
- package/lib/components/ProForm/fields/ProFormSelect.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormSelect.js +20 -0
- package/lib/components/ProForm/fields/ProFormSwitch.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormSwitch.js +18 -0
- package/lib/components/ProForm/fields/ProFormText.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormText.js +22 -0
- package/lib/components/ProForm/fields/ProFormTextArea.d.ts +6 -0
- package/lib/components/ProForm/fields/ProFormTextArea.js +23 -0
- package/lib/components/ProForm/fields/createProFormField.d.ts +43 -0
- package/lib/components/ProForm/fields/createProFormField.js +208 -0
- package/lib/components/ProForm/fields/index.d.ts +12 -0
- package/lib/components/ProForm/fields/index.js +90 -0
- package/lib/components/ProForm/index.d.ts +7 -0
- package/lib/components/ProForm/index.js +73 -0
- package/lib/components/ProForm/interface.d.ts +306 -0
- package/lib/components/ProForm/interface.js +6 -0
- package/lib/components/ProForm/layouts/DrawerForm.d.ts +16 -0
- package/lib/components/ProForm/layouts/DrawerForm.js +86 -0
- package/lib/components/ProForm/layouts/ModalForm.d.ts +16 -0
- package/lib/components/ProForm/layouts/ModalForm.js +96 -0
- package/lib/components/ProForm/layouts/QueryFilter.d.ts +21 -0
- package/lib/components/ProForm/layouts/QueryFilter.js +139 -0
- package/lib/components/ProForm/layouts/StepsForm.d.ts +13 -0
- package/lib/components/ProForm/layouts/StepsForm.js +302 -0
- package/lib/components/ProForm/layouts/index.d.ts +4 -0
- package/lib/components/ProForm/layouts/index.js +40 -0
- package/lib/components/ProForm/layouts/useOverlayForm.d.ts +53 -0
- package/lib/components/ProForm/layouts/useOverlayForm.js +150 -0
- package/lib/components/ProForm/style/ProForm.module.css +1 -0
- package/lib/components/ProForm/style/ProForm.module.scss +59 -0
- package/lib/components/ProForm/style/css.js +4 -0
- package/lib/components/ProForm/style/index.d.ts +1 -0
- package/lib/components/ProForm/style/index.js +4 -0
- package/lib/components/ProForm/utils.d.ts +72 -0
- package/lib/components/ProForm/utils.js +213 -0
- package/lib/components/RadioGroup/RadioGroup.js +45 -22
- package/lib/components/RadioGroup/interface.d.ts +3 -1
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Select/Select.js +114 -107
- package/lib/components/Select/constants.d.ts +18 -0
- package/lib/components/Select/constants.js +25 -0
- package/lib/components/Sidebar/Sidebar.js +21 -23
- package/lib/components/Sidebar/SidebarLogo.d.ts +7 -0
- package/lib/components/Sidebar/SidebarLogo.js +39 -0
- package/lib/components/Sidebar/SimplySidebar.d.ts +2 -2
- package/lib/components/Sidebar/SimplySidebar.js +17 -21
- package/lib/components/Sidebar/Stepper.js +14 -14
- package/lib/components/Sidebar/constants.d.ts +16 -0
- package/lib/components/Sidebar/constants.js +23 -0
- package/lib/components/Sidebar/style/Sidebar.css +1 -1
- package/lib/components/Sidebar/style/Sidebar.scss +1 -1
- package/lib/components/Sidebar/style/SimplySidebar.css +1 -1
- package/lib/components/Sidebar/style/SimplySidebar.scss +1 -1
- package/lib/components/Sidebar/style/Stepper.css +1 -1
- package/lib/components/Sidebar/style/Stepper.scss +11 -1
- package/lib/components/Space/Space.d.ts +5 -0
- package/lib/components/Space/Space.js +81 -0
- package/lib/components/Space/constants.d.ts +33 -0
- package/lib/components/Space/constants.js +43 -0
- package/lib/components/Space/index.d.ts +5 -0
- package/lib/components/Space/index.js +53 -0
- package/lib/components/Space/interface.d.ts +12 -0
- package/lib/components/Space/interface.js +6 -0
- package/lib/components/Space/style/Space.css +1 -0
- package/lib/components/Space/style/Space.scss +40 -0
- package/lib/components/Space/style/css.js +4 -0
- package/lib/components/Space/style/index.d.ts +1 -0
- package/lib/components/Space/style/index.js +4 -0
- package/lib/components/Switch/Switch.js +27 -24
- package/lib/components/Switch/interface.d.ts +9 -4
- package/lib/components/useControlledState/index.d.ts +14 -0
- package/lib/components/useControlledState/index.js +39 -0
- package/lib/components/useEventCallback/index.d.ts +11 -0
- package/lib/components/useEventCallback/index.js +24 -0
- package/lib/components/useLayoutEffect/index.d.ts +11 -0
- package/lib/components/useLayoutEffect/index.js +23 -0
- package/lib/components/useLayoutState/index.d.ts +13 -0
- package/lib/components/useLayoutState/index.js +79 -0
- package/lib/components/useMemoizedFn/index.d.ts +12 -0
- package/lib/components/useMemoizedFn/index.js +33 -0
- package/lib/components/usePrevious/index.d.ts +11 -0
- package/lib/components/usePrevious/index.js +25 -0
- package/lib/components/useSafeState/index.d.ts +12 -0
- package/lib/components/useSafeState/index.js +31 -0
- package/lib/components/useSyncState/index.d.ts +14 -0
- package/lib/components/useSyncState/index.js +44 -0
- package/lib/components/useUpdateEffect/index.d.ts +9 -0
- package/lib/components/useUpdateEffect/index.js +25 -0
- package/lib/index.css +1 -1
- package/lib/index.d.ts +32 -2
- package/lib/index.js +251 -1
- package/package.json +31 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useMemo, useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A hook that returns a memoized version of a callback function.
|
|
4
|
+
* Unlike `useCallback`, it maintains referential equality across renders
|
|
5
|
+
* without requiring a dependency array, while always calling the latest
|
|
6
|
+
* version of the function.
|
|
7
|
+
*
|
|
8
|
+
* @param fn The function to memoize
|
|
9
|
+
* @returns A memoized function with stable reference
|
|
10
|
+
*/
|
|
11
|
+
export default function useMemoizedFn(fn) {
|
|
12
|
+
var fnRef = useRef(fn);
|
|
13
|
+
fnRef.current = useMemo(function () {
|
|
14
|
+
return fn;
|
|
15
|
+
}, [fn]);
|
|
16
|
+
var memoizedFn = useRef(undefined);
|
|
17
|
+
if (!memoizedFn.current) {
|
|
18
|
+
memoizedFn.current = function () {
|
|
19
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
+
args[_key] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
return fnRef.current.apply(this, args);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return memoizedFn.current;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvc3JjL2NvbXBvbmVudHMvdXNlTWVtb2l6ZWRGbi9pbmRleC50cyIsImNvbXBvbmVudHMvdXNlTWVtb2l6ZWRGbi9pbmRleC5qcyJdLCJuYW1lcyI6WyJ1c2VNZW1vIiwidXNlUmVmIiwidXNlTWVtb2l6ZWRGbiIsImZuIiwiZm5SZWYiLCJjdXJyZW50IiwibWVtb2l6ZWRGbiIsInVuZGVmaW5lZCIsIl9sZW4iLCJhcmd1bWVudHMiLCJsZW5ndGgiLCJhcmdzIiwiQXJyYXkiLCJfa2V5IiwiYXBwbHkiXSwibWFwcGluZ3MiOiJBQUFBLFNBQVNBLE9BQU8sRUFBRUMsTUFBTSxRQUFRLE9BQU87QUFJdkM7QUNGQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FESUEsZUFBYyxTQUFVQyxhQUFhQSxDQUF5QkMsRUFBWSxFQUFBO0VBQ3hFLElBQU1DLEtBQUssR0FBR0gsTUFBTSxDQUFDRSxFQUFFLENBQUM7RUFDeEJDLEtBQUssQ0FBQ0MsT0FBTyxHQUFHTCxPQUFPLENBQUM7SUFBQSxPQUFNRyxFQUFFO0VBQUEsR0FBRSxDQUFDQSxFQUFFLENBQUMsQ0FBQztFQUV2QyxJQUFNRyxVQUFVLEdBQUdMLE1BQU0sQ0FBdUJNL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dGggc3RhYmxlIHJlZmVyZW5jZVxuICovXG5leHBvcnQgZGVmYXVsdCBmdW5jdGlvbiB1c2VNZW1vaXplZEZuKGZuKSB7XG4gICAgY29uc3QgZm5SZWYgPSB1c2VSZWYoZm4pO1xuICAgIGZuUmVmLmN1cnJlbnQgPSB1c2VNZW1vKCgpID0+IGZuLCBbZm5dKTtcbiAgICBjb25zdCBtZW1vaXplZEZuID0gdXNlUmVmKHVuZGVmaW5lZCk7XG4gICAgaWYgKCFtZW1vaXplZEZuLmN1cnJlbnQpIHtcbiAgICAgICAgbWVtb2l6ZWRGbi5jdXJyZW50ID0gZnVuY3Rpb24gKC4uLmFyZ3MpIHtcbiAgICAgICAgICAgIHJldHVybiBmblJlZi5jdXJyZW50LmFwcGx5KHRoaXMsIGFyZ3MpO1xuICAgICAgICB9O1xuICAgIH1cbiAgICByZXR1cm4gbWVtb2l6ZWRGbi5jdXJyZW50O1xufSJdLCJzb3VyY2VSb290IjoiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjIn0=
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the last distinct value observed before the current `value`.
|
|
3
|
+
*
|
|
4
|
+
* Because the internal effect depends on `[value]`, the ref is only updated
|
|
5
|
+
* when `value` changes. That means this hook tracks the previous value on
|
|
6
|
+
* value-change boundaries (not every render).
|
|
7
|
+
*
|
|
8
|
+
* @param value The value to track
|
|
9
|
+
* @returns The previous distinct value, or `undefined` until one exists
|
|
10
|
+
*/
|
|
11
|
+
export default function usePrevious<T>(value: T): T | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the last distinct value observed before the current `value`.
|
|
4
|
+
*
|
|
5
|
+
* Because the internal effect depends on `[value]`, the ref is only updated
|
|
6
|
+
* when `value` changes. That means this hook tracks the previous value on
|
|
7
|
+
* value-change boundaries (not every render).
|
|
8
|
+
*
|
|
9
|
+
* @param value The value to track
|
|
10
|
+
* @returns The previous distinct value, or `undefined` until one exists
|
|
11
|
+
*/
|
|
12
|
+
export default function usePrevious(value) {
|
|
13
|
+
var ref = useRef(undefined);
|
|
14
|
+
useEffect(function () {
|
|
15
|
+
ref.current = value;
|
|
16
|
+
}, [value]);
|
|
17
|
+
return ref.current;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvc3JjL2NvbXBvbmVudHMvdXNlUHJldmlvdXMvaW5kZXgudHMiLCJjb21wb25lbnRzL3VzZVByZXZpb3VzL2luZGV4LmpzIl0sIm5hbWVzIjpbInVzZUVmZmVjdCIsInVzZVJlZiIsInVzZVByZXZpb3VzIiwidmFsdWUiLCJyZWYiLCJ1bmRlZmluZWQiLCJjdXJyZW50Il0sIm1hcHBpbmdzIjoiQUFBQSxTQUFTQSxTQUFTLEVBQUVDLE1BQU0sUUFBUSxPQUFPO0FBRXpDO0FDQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FERUEsZUFBYyxTQUFVQyxXQUFXQSxDQUFJQyxLQUFRLEVBQUE7RUFDN0MsSUFBTUMsR0FBRyxHQUFHSCxNQUFNLENBQWdCSSxTQUFTLENBQUM7RUFFNUNMLFNBQVMsQ0FBQyxZQUFLO0lBQ2JJLEdBQUcsQ0FBQ0UsT0FBTyxHQUFHSCxLQUFLO0VBQ3JCLENBQUMsRUFBRSxDQUFDQSxLQUFLLENBQUMsQ0FBQztFQUVYLE9BQU9DLEdBQUcsQ0FBQ0UsT0FBTztBQUNwQiIsImZpbGUiOiJjb21wb25lbnRzL3VzZVByZXZpb3VzL2luZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOltudWxsLCJpbXBvcnQgeyB1c2VFZmZlY3QsIHVzZVJlZiB9IGZyb20gJ3JlYWN0Jztcbi8qKlxuICogUmV0dXJucyB0aGUgbGFzdCBkaXN0aW5jdCB2YWx1ZSBvYnNlcnZlZCBiZWZvcmUgdGhlIGN1cnJlbnQgYHZhbHVlYC5cbiAqXG4gKiBCZWNhdXNlIHRoZSBpbnRlcm5hbCBlZmZlY3QgZGVwZW5kcyBvbiBgW3ZhbHVlXWAsIHRoZSByZWYgaXMgb25seSB1cGRhdGVkXG4gKiB3aGVuIGB2YWx1ZWAgY2hhbmdlcy4gVGhhdCBtZWFucyB0aGlzIGhvb2sgdHJhY2tzIHRoZSBwcmV2aW91cyB2YWx1ZSBvblxuICogdmFsdWUtY2hhbmdlIGJvdW5kYXJpZXMgKG5vdCBldmVyeSByZW5kZXIpLlxuICpcbiAqIEBwYXJhbSB2YWx1ZSBUaGUgdmFsdWUgdG8gdHJhY2tcbiAqIEByZXR1cm5zIFRoZSBwcmV2aW91cyBkaXN0aW5jdCB2YWx1ZSwgb3IgYHVuZGVmaW5lZGAgdW50aWwgb25lIGV4aXN0c1xuICovXG5leHBvcnQgZGVmYXVsdCBmdW5jdGlvbiB1c2VQcmV2aW91cyh2YWx1ZSkge1xuICAgIGNvbnN0IHJlZiA9IHVzZVJlZih1bmRlZmluZWQpO1xuICAgIHVzZUVmZmVjdCgoKSA9PiB7XG4gICAgICAgIHJlZi5jdXJyZW50ID0gdmFsdWU7XG4gICAgfSwgW3ZhbHVlXSk7XG4gICAgcmV0dXJuIHJlZi5jdXJyZW50O1xufSJdLCJzb3VyY2VSb290IjoiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjIn0=
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* It is exactly the same as `React.useState`, but after the component is unmounted,
|
|
4
|
+
* the setState in the asynchronous callback will no longer be executed to avoid
|
|
5
|
+
* memory leakage caused by updating the state after the component is unmounted.
|
|
6
|
+
*
|
|
7
|
+
* @param initialState The initial state value or initializer function
|
|
8
|
+
* @returns A tuple of [state, setSafeState] similar to useState
|
|
9
|
+
*/
|
|
10
|
+
declare function useSafeState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
|
|
11
|
+
declare function useSafeState<S = undefined>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>];
|
|
12
|
+
export default useSafeState;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useState, useCallback, useRef, useEffect } from 'react';
|
|
3
|
+
// eslint-disable-next-line no-redeclare
|
|
4
|
+
function useSafeState(initialState) {
|
|
5
|
+
var isMountedRef = useRef(true);
|
|
6
|
+
var _useState = useState(initialState),
|
|
7
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
8
|
+
state = _useState2[0],
|
|
9
|
+
setState = _useState2[1];
|
|
10
|
+
useEffect(function () {
|
|
11
|
+
isMountedRef.current = true;
|
|
12
|
+
return function () {
|
|
13
|
+
isMountedRef.current = false;
|
|
14
|
+
};
|
|
15
|
+
}, []);
|
|
16
|
+
var setSafeState = useCallback(function (value) {
|
|
17
|
+
if (isMountedRef.current) {
|
|
18
|
+
setState(value);
|
|
19
|
+
}
|
|
20
|
+
}, []);
|
|
21
|
+
return [state, setSafeState];
|
|
22
|
+
}
|
|
23
|
+
export default useSafeState;
|
|
24
|
+
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvc3JjL2NvbXBvbmVudHMvdXNlU2FmZVN0YXRlL2luZGV4LnRzIl0sIm5hbWVzIjpbInVzZVN0YXRlIiwidXNlQ2FsbGJhY2siLCJ1c2VSZWYiLCJ1c2VFZmZlY3QiLCJ1c2VTYWZlU3RhdGUiLCJpbml0aWFsU3RhdGUiLCJpc01vdW50ZWRSZWYiLCJfdXNlU3RhdGUiLCJfdXNlU3RhdGUyIiwiX3NsaWNlZFRvQXJyYXkiL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Q==
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type SetStateAction } from 'react';
|
|
2
|
+
type GetState<T> = () => T;
|
|
3
|
+
type SetState<T> = (value: SetStateAction<T>) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Same as `React.useState` but will always get the latest state.
|
|
6
|
+
* This is useful when React merges multiple state updates into one.
|
|
7
|
+
* e.g. `onTransitionEnd` triggers multiple events at once that will be merged
|
|
8
|
+
* into a single state update in React.
|
|
9
|
+
*
|
|
10
|
+
* @param initialState The initial state value or initializer function
|
|
11
|
+
* @returns A tuple of [getState, setState] where getState always returns the latest value
|
|
12
|
+
*/
|
|
13
|
+
export default function useSyncState<T>(initialState: T | (() => T)): [GetState<T>, SetState<T>];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useState, useRef } from 'react';
|
|
3
|
+
import useEventCallback from '../useEventCallback';
|
|
4
|
+
/** Sentinel value distinguishing "not yet initialized" from any valid state, including `null`. */
|
|
5
|
+
var UNINITIALIZED = Symbol('useSyncState.uninitialized');
|
|
6
|
+
/**
|
|
7
|
+
* Same as `React.useState` but will always get the latest state.
|
|
8
|
+
* This is useful when React merges multiple state updates into one.
|
|
9
|
+
* e.g. `onTransitionEnd` triggers multiple events at once that will be merged
|
|
10
|
+
* into a single state update in React.
|
|
11
|
+
*
|
|
12
|
+
* @param initialState The initial state value or initializer function
|
|
13
|
+
* @returns A tuple of [getState, setState] where getState always returns the latest value
|
|
14
|
+
*/
|
|
15
|
+
export default function useSyncState(initialState) {
|
|
16
|
+
var stateRef = useRef(UNINITIALIZED);
|
|
17
|
+
// Initialize ref on first render
|
|
18
|
+
if (stateRef.current === UNINITIALIZED) {
|
|
19
|
+
stateRef.current = typeof initialState === 'function' ? initialState() : initialState;
|
|
20
|
+
}
|
|
21
|
+
var _useState = useState({}),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
forceUpdate = _useState2[1];
|
|
24
|
+
var getState = useEventCallback(function () {
|
|
25
|
+
return stateRef.current;
|
|
26
|
+
});
|
|
27
|
+
var setState = useEventCallback(function (value) {
|
|
28
|
+
var prevState = stateRef.current;
|
|
29
|
+
var nextState = typeof value === 'function' ? value(prevState) : value;
|
|
30
|
+
if (!Object.is(prevState, nextState)) {
|
|
31
|
+
stateRef.current = nextState;
|
|
32
|
+
forceUpdate({});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return [getState, setState];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvc3JjL2NvbXBvbmVudHMvdXNlU3luY1N0YXRlL2luZGV4LnRzIiwiY29tcG9uZW50cy91c2VTeW5jU3RhdGUvaW5kZXguanMiXSwibmFtZXMiOlsidXNlU3RhdGUiLCJ1c2VSZWYiLCJ1c2VFdmVudENhbGxiYWNrIiwiVU5JTklUSUFMSVpFRCIsIlN5bWJvbCIsInVzZVN5bmNTdGF0ZSIsImluaXRpYWxTdGF0ZSIsInN0YXRlUmVmIiwiY3VycmVudCIsIl91c2VTdGF0ZSIsIl91c2VTdGF0ZTIiLCJfc2xpY2VkVG9BcnJheSIsImZvcmNlVXBkYXRlIiwiZ2V0U3RhdGUiLCJzZXRTdGF0ZSIsInZhbHVlIiwicHJldlN0YXRlIiwibmV4dFN0YXRlIiwiT2JqZWN0IiwiaXMiXSwibWFwcGluZ3MiOiI7QUFBQSxTQUFTQSxRQUFRLEVBQUVDLE1BQU0sUUFBNkIsT0FBTztBQUM3RCxPQUFPQyxnQkFBZ0IsTUFBTSxxQkFBcUI7QUFLbEQ7QUFDQSxJQUFNQyxhQUFhLEdBQUdDLE1BQU0sQ0FBQyw0QkFBNEIsQ0FBQztBQUUxRDtBQ0pBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQ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type DependencyList, type EffectCallback } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A hook identical to `useEffect`, but it skips the effect on the initial mount
|
|
4
|
+
* and only runs on subsequent updates.
|
|
5
|
+
*
|
|
6
|
+
* @param effect The effect callback to run on updates
|
|
7
|
+
* @param deps The dependency array
|
|
8
|
+
*/
|
|
9
|
+
export default function useUpdateEffect(effect: EffectCallback, deps?: DependencyList): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A hook identical to `useEffect`, but it skips the effect on the initial mount
|
|
4
|
+
* and only runs on subsequent updates.
|
|
5
|
+
*
|
|
6
|
+
* @param effect The effect callback to run on updates
|
|
7
|
+
* @param deps The dependency array
|
|
8
|
+
*/
|
|
9
|
+
export default function useUpdateEffect(effect, deps) {
|
|
10
|
+
var isMounted = useRef(false);
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
if (!isMounted.current) {
|
|
13
|
+
isMounted.current = true;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return effect();
|
|
17
|
+
}, deps);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvc3JjL2NvbXBvbmVudHMvdXNlVXBkYXRlRWZmZWN0L2luZGV4LnRzIiwiY29tcG9uZW50cy91c2VVcGRhdGVFZmZlY3QvaW5kZXguanMiXSwibmFtZXMiOlsidXNlRWZmZWN0IiwidXNlUmVmIiwidXNlVXBkYXRlRWZmZWN0IiwiZWZmZWN0IiwiZGVwcyIsImlzTW91bnRlZCIsImN1cnJlbnQiXSwibWFwcGluZ3MiOiJBQUFBLFNBQVNBLFNBQVMsRUFBRUMsTUFBTSxRQUFrRCxPQUFPO0FBRW5GO0FDQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FERUEsZUFBYyxTQUFVQyxlQUFl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