rn-custom-ui 1.0.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/LICENSE +20 -0
- package/README.md +477 -0
- package/lib/module/assets/images/close.png +0 -0
- package/lib/module/components/CustomCheckbox/index.js +99 -0
- package/lib/module/components/CustomCheckbox/index.js.map +1 -0
- package/lib/module/components/CustomCheckbox/styles.js +213 -0
- package/lib/module/components/CustomCheckbox/styles.js.map +1 -0
- package/lib/module/components/CustomCheckbox/types.js +4 -0
- package/lib/module/components/CustomCheckbox/types.js.map +1 -0
- package/lib/module/components/closeButton/index.js +45 -0
- package/lib/module/components/closeButton/index.js.map +1 -0
- package/lib/module/components/closeButton/types.js +4 -0
- package/lib/module/components/closeButton/types.js.map +1 -0
- package/lib/module/components/customButton/index.js +176 -0
- package/lib/module/components/customButton/index.js.map +1 -0
- package/lib/module/components/customButton/styles.js +282 -0
- package/lib/module/components/customButton/styles.js.map +1 -0
- package/lib/module/components/customButton/types.js +4 -0
- package/lib/module/components/customButton/types.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownBottomSheet.js +57 -0
- package/lib/module/components/customDropDown/DropDownBottomSheet.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownList.js +51 -0
- package/lib/module/components/customDropDown/DropDownList.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownListItem.js +38 -0
- package/lib/module/components/customDropDown/DropDownListItem.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownListModal.js +63 -0
- package/lib/module/components/customDropDown/DropDownListModal.js.map +1 -0
- package/lib/module/components/customDropDown/index.js +143 -0
- package/lib/module/components/customDropDown/index.js.map +1 -0
- package/lib/module/components/customDropDown/styles.js +189 -0
- package/lib/module/components/customDropDown/styles.js.map +1 -0
- package/lib/module/components/customDropDown/types.js +4 -0
- package/lib/module/components/customDropDown/types.js.map +1 -0
- package/lib/module/components/customDropDown/utils.js +17 -0
- package/lib/module/components/customDropDown/utils.js.map +1 -0
- package/lib/module/components/customList/ListEmpty.js +33 -0
- package/lib/module/components/customList/ListEmpty.js.map +1 -0
- package/lib/module/components/customList/ListFooterLoader.js +14 -0
- package/lib/module/components/customList/ListFooterLoader.js.map +1 -0
- package/lib/module/components/customList/defaultKeyExtractor.js +9 -0
- package/lib/module/components/customList/defaultKeyExtractor.js.map +1 -0
- package/lib/module/components/customList/getFlashList.js +19 -0
- package/lib/module/components/customList/getFlashList.js.map +1 -0
- package/lib/module/components/customList/index.js +117 -0
- package/lib/module/components/customList/index.js.map +1 -0
- package/lib/module/components/customList/styles.js +45 -0
- package/lib/module/components/customList/styles.js.map +1 -0
- package/lib/module/components/customList/types.js +4 -0
- package/lib/module/components/customList/types.js.map +1 -0
- package/lib/module/components/customModal/ModalFooter.js +44 -0
- package/lib/module/components/customModal/ModalFooter.js.map +1 -0
- package/lib/module/components/customModal/index.js +132 -0
- package/lib/module/components/customModal/index.js.map +1 -0
- package/lib/module/components/customModal/styles.js +123 -0
- package/lib/module/components/customModal/styles.js.map +1 -0
- package/lib/module/components/customModal/types.js +4 -0
- package/lib/module/components/customModal/types.js.map +1 -0
- package/lib/module/components/customModal/useCustomModal.js +23 -0
- package/lib/module/components/customModal/useCustomModal.js.map +1 -0
- package/lib/module/components/customNumberPad/NumberPadKey.js +39 -0
- package/lib/module/components/customNumberPad/NumberPadKey.js.map +1 -0
- package/lib/module/components/customNumberPad/index.js +156 -0
- package/lib/module/components/customNumberPad/index.js.map +1 -0
- package/lib/module/components/customNumberPad/styles.js +131 -0
- package/lib/module/components/customNumberPad/styles.js.map +1 -0
- package/lib/module/components/customNumberPad/types.js +4 -0
- package/lib/module/components/customNumberPad/types.js.map +1 -0
- package/lib/module/components/customNumberPad/useNumberPadInput.js +44 -0
- package/lib/module/components/customNumberPad/useNumberPadInput.js.map +1 -0
- package/lib/module/components/customNumberPad/utils.js +38 -0
- package/lib/module/components/customNumberPad/utils.js.map +1 -0
- package/lib/module/components/customSlideTabs/AnimatedTabIndicator.js +66 -0
- package/lib/module/components/customSlideTabs/AnimatedTabIndicator.js.map +1 -0
- package/lib/module/components/customSlideTabs/TabBarItem.js +61 -0
- package/lib/module/components/customSlideTabs/TabBarItem.js.map +1 -0
- package/lib/module/components/customSlideTabs/TabScene.js +88 -0
- package/lib/module/components/customSlideTabs/TabScene.js.map +1 -0
- package/lib/module/components/customSlideTabs/index.js +277 -0
- package/lib/module/components/customSlideTabs/index.js.map +1 -0
- package/lib/module/components/customSlideTabs/styles.js +132 -0
- package/lib/module/components/customSlideTabs/styles.js.map +1 -0
- package/lib/module/components/customSlideTabs/tabBarScroll.js +65 -0
- package/lib/module/components/customSlideTabs/tabBarScroll.js.map +1 -0
- package/lib/module/components/customSlideTabs/types.js +4 -0
- package/lib/module/components/customSlideTabs/types.js.map +1 -0
- package/lib/module/components/loading/index.js +34 -0
- package/lib/module/components/loading/index.js.map +1 -0
- package/lib/module/customFunctions/array.js +61 -0
- package/lib/module/customFunctions/array.js.map +1 -0
- package/lib/module/customFunctions/async.js +62 -0
- package/lib/module/customFunctions/async.js.map +1 -0
- package/lib/module/customFunctions/date.js +109 -0
- package/lib/module/customFunctions/date.js.map +1 -0
- package/lib/module/customFunctions/general.js +29 -0
- package/lib/module/customFunctions/general.js.map +1 -0
- package/lib/module/customFunctions/id.js +20 -0
- package/lib/module/customFunctions/id.js.map +1 -0
- package/lib/module/customFunctions/index.js +29 -0
- package/lib/module/customFunctions/index.js.map +1 -0
- package/lib/module/customFunctions/number.js +94 -0
- package/lib/module/customFunctions/number.js.map +1 -0
- package/lib/module/customFunctions/object.js +39 -0
- package/lib/module/customFunctions/object.js.map +1 -0
- package/lib/module/customFunctions/string.js +63 -0
- package/lib/module/customFunctions/string.js.map +1 -0
- package/lib/module/customFunctions/types.js +2 -0
- package/lib/module/customFunctions/types.js.map +1 -0
- package/lib/module/customFunctions/validation.js +34 -0
- package/lib/module/customFunctions/validation.js.map +1 -0
- package/lib/module/customHooks/errors.js +61 -0
- package/lib/module/customHooks/errors.js.map +1 -0
- package/lib/module/customHooks/fetchJson.js +36 -0
- package/lib/module/customHooks/fetchJson.js.map +1 -0
- package/lib/module/customHooks/index.js +10 -0
- package/lib/module/customHooks/index.js.map +1 -0
- package/lib/module/customHooks/internal.js +49 -0
- package/lib/module/customHooks/internal.js.map +1 -0
- package/lib/module/customHooks/types.js +2 -0
- package/lib/module/customHooks/types.js.map +1 -0
- package/lib/module/customHooks/useApi.js +91 -0
- package/lib/module/customHooks/useApi.js.map +1 -0
- package/lib/module/customHooks/useLazyApi.js +80 -0
- package/lib/module/customHooks/useLazyApi.js.map +1 -0
- package/lib/module/customHooks/useMutation.js +69 -0
- package/lib/module/customHooks/useMutation.js.map +1 -0
- package/lib/module/customHooks/usePaginatedApi.js +127 -0
- package/lib/module/customHooks/usePaginatedApi.js.map +1 -0
- package/lib/module/customHooks/usePollingApi.js +37 -0
- package/lib/module/customHooks/usePollingApi.js.map +1 -0
- package/lib/module/index.js +13 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/multiply.js +6 -0
- package/lib/module/multiply.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/components/CustomCheckbox/index.d.ts +5 -0
- package/lib/typescript/src/components/CustomCheckbox/index.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomCheckbox/styles.d.ts +67 -0
- package/lib/typescript/src/components/CustomCheckbox/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomCheckbox/types.d.ts +28 -0
- package/lib/typescript/src/components/CustomCheckbox/types.d.ts.map +1 -0
- package/lib/typescript/src/components/closeButton/index.d.ts +4 -0
- package/lib/typescript/src/components/closeButton/index.d.ts.map +1 -0
- package/lib/typescript/src/components/closeButton/types.d.ts +8 -0
- package/lib/typescript/src/components/closeButton/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customButton/index.d.ts +5 -0
- package/lib/typescript/src/components/customButton/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customButton/styles.d.ts +231 -0
- package/lib/typescript/src/components/customButton/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customButton/types.d.ts +46 -0
- package/lib/typescript/src/components/customButton/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownBottomSheet.d.ts +18 -0
- package/lib/typescript/src/components/customDropDown/DropDownBottomSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownList.d.ts +17 -0
- package/lib/typescript/src/components/customDropDown/DropDownList.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownListItem.d.ts +15 -0
- package/lib/typescript/src/components/customDropDown/DropDownListItem.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownListModal.d.ts +19 -0
- package/lib/typescript/src/components/customDropDown/DropDownListModal.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/index.d.ts +5 -0
- package/lib/typescript/src/components/customDropDown/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/styles.d.ts +190 -0
- package/lib/typescript/src/components/customDropDown/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/types.d.ts +37 -0
- package/lib/typescript/src/components/customDropDown/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/utils.d.ts +4 -0
- package/lib/typescript/src/components/customDropDown/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/ListEmpty.d.ts +10 -0
- package/lib/typescript/src/components/customList/ListEmpty.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/ListFooterLoader.d.ts +3 -0
- package/lib/typescript/src/components/customList/ListFooterLoader.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/defaultKeyExtractor.d.ts +2 -0
- package/lib/typescript/src/components/customList/defaultKeyExtractor.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/getFlashList.d.ts +6 -0
- package/lib/typescript/src/components/customList/getFlashList.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/index.d.ts +11 -0
- package/lib/typescript/src/components/customList/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/styles.d.ts +42 -0
- package/lib/typescript/src/components/customList/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/types.d.ts +33 -0
- package/lib/typescript/src/components/customList/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/ModalFooter.d.ts +12 -0
- package/lib/typescript/src/components/customModal/ModalFooter.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/index.d.ts +6 -0
- package/lib/typescript/src/components/customModal/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/styles.d.ts +83 -0
- package/lib/typescript/src/components/customModal/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/types.d.ts +36 -0
- package/lib/typescript/src/components/customModal/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/useCustomModal.d.ts +8 -0
- package/lib/typescript/src/components/customModal/useCustomModal.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/NumberPadKey.d.ts +23 -0
- package/lib/typescript/src/components/customNumberPad/NumberPadKey.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/index.d.ts +7 -0
- package/lib/typescript/src/components/customNumberPad/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/styles.d.ts +37 -0
- package/lib/typescript/src/components/customNumberPad/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/types.d.ts +47 -0
- package/lib/typescript/src/components/customNumberPad/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/useNumberPadInput.d.ts +16 -0
- package/lib/typescript/src/components/customNumberPad/useNumberPadInput.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/utils.d.ts +4 -0
- package/lib/typescript/src/components/customNumberPad/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/AnimatedTabIndicator.d.ts +16 -0
- package/lib/typescript/src/components/customSlideTabs/AnimatedTabIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/TabBarItem.d.ts +23 -0
- package/lib/typescript/src/components/customSlideTabs/TabBarItem.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/TabScene.d.ts +21 -0
- package/lib/typescript/src/components/customSlideTabs/TabScene.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/index.d.ts +5 -0
- package/lib/typescript/src/components/customSlideTabs/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/styles.d.ts +130 -0
- package/lib/typescript/src/components/customSlideTabs/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/tabBarScroll.d.ts +15 -0
- package/lib/typescript/src/components/customSlideTabs/tabBarScroll.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/types.d.ts +68 -0
- package/lib/typescript/src/components/customSlideTabs/types.d.ts.map +1 -0
- package/lib/typescript/src/components/loading/index.d.ts +7 -0
- package/lib/typescript/src/components/loading/index.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/array.d.ts +7 -0
- package/lib/typescript/src/customFunctions/array.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/async.d.ts +9 -0
- package/lib/typescript/src/customFunctions/async.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/date.d.ts +18 -0
- package/lib/typescript/src/customFunctions/date.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/general.d.ts +7 -0
- package/lib/typescript/src/customFunctions/general.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/id.d.ts +4 -0
- package/lib/typescript/src/customFunctions/id.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/index.d.ts +26 -0
- package/lib/typescript/src/customFunctions/index.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/number.d.ts +15 -0
- package/lib/typescript/src/customFunctions/number.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/object.d.ts +6 -0
- package/lib/typescript/src/customFunctions/object.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/string.d.ts +20 -0
- package/lib/typescript/src/customFunctions/string.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/types.d.ts +22 -0
- package/lib/typescript/src/customFunctions/types.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/validation.d.ts +11 -0
- package/lib/typescript/src/customFunctions/validation.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/errors.d.ts +16 -0
- package/lib/typescript/src/customHooks/errors.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/fetchJson.d.ts +5 -0
- package/lib/typescript/src/customHooks/fetchJson.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/index.d.ts +9 -0
- package/lib/typescript/src/customHooks/index.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/internal.d.ts +12 -0
- package/lib/typescript/src/customHooks/internal.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/types.d.ts +49 -0
- package/lib/typescript/src/customHooks/types.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/useApi.d.ts +13 -0
- package/lib/typescript/src/customHooks/useApi.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/useLazyApi.d.ts +14 -0
- package/lib/typescript/src/customHooks/useLazyApi.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/useMutation.d.ts +15 -0
- package/lib/typescript/src/customHooks/useMutation.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/usePaginatedApi.d.ts +19 -0
- package/lib/typescript/src/customHooks/usePaginatedApi.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/usePollingApi.d.ts +13 -0
- package/lib/typescript/src/customHooks/usePollingApi.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +11 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/multiply.d.ts +2 -0
- package/lib/typescript/src/multiply.d.ts.map +1 -0
- package/package.json +181 -0
- package/src/assets/images/close.png +0 -0
- package/src/components/CustomCheckbox/index.tsx +143 -0
- package/src/components/CustomCheckbox/styles.ts +146 -0
- package/src/components/CustomCheckbox/types.ts +33 -0
- package/src/components/closeButton/index.tsx +40 -0
- package/src/components/closeButton/types.ts +13 -0
- package/src/components/customButton/index.tsx +288 -0
- package/src/components/customButton/styles.ts +247 -0
- package/src/components/customButton/types.ts +71 -0
- package/src/components/customDropDown/DropDownBottomSheet.tsx +70 -0
- package/src/components/customDropDown/DropDownList.tsx +88 -0
- package/src/components/customDropDown/DropDownListItem.tsx +74 -0
- package/src/components/customDropDown/DropDownListModal.tsx +86 -0
- package/src/components/customDropDown/index.tsx +213 -0
- package/src/components/customDropDown/styles.ts +184 -0
- package/src/components/customDropDown/types.ts +48 -0
- package/src/components/customDropDown/utils.ts +24 -0
- package/src/components/customList/ListEmpty.tsx +36 -0
- package/src/components/customList/ListFooterLoader.tsx +11 -0
- package/src/components/customList/defaultKeyExtractor.ts +7 -0
- package/src/components/customList/getFlashList.ts +26 -0
- package/src/components/customList/index.tsx +142 -0
- package/src/components/customList/styles.ts +43 -0
- package/src/components/customList/types.ts +60 -0
- package/src/components/customModal/ModalFooter.tsx +57 -0
- package/src/components/customModal/index.tsx +166 -0
- package/src/components/customModal/styles.ts +131 -0
- package/src/components/customModal/types.ts +48 -0
- package/src/components/customModal/useCustomModal.ts +25 -0
- package/src/components/customNumberPad/NumberPadKey.tsx +81 -0
- package/src/components/customNumberPad/index.tsx +204 -0
- package/src/components/customNumberPad/styles.ts +146 -0
- package/src/components/customNumberPad/types.ts +53 -0
- package/src/components/customNumberPad/useNumberPadInput.ts +56 -0
- package/src/components/customNumberPad/utils.ts +54 -0
- package/src/components/customSlideTabs/AnimatedTabIndicator.tsx +103 -0
- package/src/components/customSlideTabs/TabBarItem.tsx +118 -0
- package/src/components/customSlideTabs/TabScene.tsx +136 -0
- package/src/components/customSlideTabs/index.tsx +385 -0
- package/src/components/customSlideTabs/styles.ts +136 -0
- package/src/components/customSlideTabs/tabBarScroll.ts +92 -0
- package/src/components/customSlideTabs/types.ts +87 -0
- package/src/components/loading/index.tsx +34 -0
- package/src/customFunctions/array.ts +83 -0
- package/src/customFunctions/async.ts +85 -0
- package/src/customFunctions/date.ts +158 -0
- package/src/customFunctions/general.ts +35 -0
- package/src/customFunctions/id.ts +25 -0
- package/src/customFunctions/index.ts +91 -0
- package/src/customFunctions/number.ts +139 -0
- package/src/customFunctions/object.ts +59 -0
- package/src/customFunctions/string.ts +119 -0
- package/src/customFunctions/types.ts +25 -0
- package/src/customFunctions/validation.ts +49 -0
- package/src/customHooks/errors.ts +87 -0
- package/src/customHooks/fetchJson.ts +49 -0
- package/src/customHooks/index.ts +20 -0
- package/src/customHooks/internal.ts +67 -0
- package/src/customHooks/types.ts +71 -0
- package/src/customHooks/useApi.ts +107 -0
- package/src/customHooks/useLazyApi.ts +92 -0
- package/src/customHooks/useMutation.ts +97 -0
- package/src/customHooks/usePaginatedApi.ts +168 -0
- package/src/customHooks/usePollingApi.ts +48 -0
- package/src/index.tsx +63 -0
- package/src/multiply.tsx +3 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const toSafeNumber = value => {
|
|
4
|
+
const parsed = Number(value);
|
|
5
|
+
return Number.isNaN(parsed) ? 0 : parsed;
|
|
6
|
+
};
|
|
7
|
+
export const parseNumberSafe = toSafeNumber;
|
|
8
|
+
export const formatNumberWithCommas = (value, options = {}) => {
|
|
9
|
+
const {
|
|
10
|
+
locale = 'en-US',
|
|
11
|
+
minimumFractionDigits = 0,
|
|
12
|
+
maximumFractionDigits = 2
|
|
13
|
+
} = options;
|
|
14
|
+
return toSafeNumber(value).toLocaleString(locale, {
|
|
15
|
+
minimumFractionDigits,
|
|
16
|
+
maximumFractionDigits
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export const formatCurrency = (amount, options = {}) => {
|
|
20
|
+
const {
|
|
21
|
+
locale = 'en-US',
|
|
22
|
+
currency = 'USD',
|
|
23
|
+
isDiscount = false,
|
|
24
|
+
minimumFractionDigits = 2,
|
|
25
|
+
maximumFractionDigits = 2
|
|
26
|
+
} = options;
|
|
27
|
+
const safeAmount = toSafeNumber(amount);
|
|
28
|
+
if (locale.startsWith('fr')) {
|
|
29
|
+
const formatted = `${safeAmount.toFixed(maximumFractionDigits).replace('.', ',')} $`;
|
|
30
|
+
return isDiscount ? `-${formatted}` : formatted;
|
|
31
|
+
}
|
|
32
|
+
const formatted = new Intl.NumberFormat(locale, {
|
|
33
|
+
style: 'currency',
|
|
34
|
+
currency,
|
|
35
|
+
minimumFractionDigits,
|
|
36
|
+
maximumFractionDigits
|
|
37
|
+
}).format(safeAmount);
|
|
38
|
+
return isDiscount ? `-${formatted}` : formatted;
|
|
39
|
+
};
|
|
40
|
+
export const formatDiscountAmount = (discount, options = {}) => {
|
|
41
|
+
if (discount === undefined || discount === null || discount === '') {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
const raw = discount.toString().replace('-', '');
|
|
45
|
+
return formatCurrency(raw, {
|
|
46
|
+
...options,
|
|
47
|
+
isDiscount: true
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export const generateRandomNumberString = length => {
|
|
51
|
+
let result = '';
|
|
52
|
+
const digits = '0123456789';
|
|
53
|
+
for (let i = 0; i < length; i += 1) {
|
|
54
|
+
result += digits.charAt(Math.floor(Math.random() * digits.length));
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
export const roundToDecimals = (value, decimals = 2) => {
|
|
59
|
+
const factor = 10 ** decimals;
|
|
60
|
+
return Math.round(toSafeNumber(value) * factor) / factor;
|
|
61
|
+
};
|
|
62
|
+
export const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
63
|
+
export const formatPercentage = (value, decimals = 0, locale = 'en-US') => `${toSafeNumber(value).toLocaleString(locale, {
|
|
64
|
+
minimumFractionDigits: decimals,
|
|
65
|
+
maximumFractionDigits: decimals
|
|
66
|
+
})}%`;
|
|
67
|
+
export const percentage = (part, total) => {
|
|
68
|
+
if (!total) {
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
return roundToDecimals(part / total * 100, 2);
|
|
72
|
+
};
|
|
73
|
+
export const formatBytes = (bytes, decimals = 2) => {
|
|
74
|
+
if (bytes === 0) {
|
|
75
|
+
return '0 B';
|
|
76
|
+
}
|
|
77
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
78
|
+
const index = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
|
|
79
|
+
const value = bytes / 1024 ** index;
|
|
80
|
+
return `${roundToDecimals(value, decimals)} ${units[index]}`;
|
|
81
|
+
};
|
|
82
|
+
export const randomInt = (min, max) => {
|
|
83
|
+
const lower = Math.ceil(min);
|
|
84
|
+
const upper = Math.floor(max);
|
|
85
|
+
return Math.floor(Math.random() * (upper - lower + 1)) + lower;
|
|
86
|
+
};
|
|
87
|
+
export const sum = values => values.reduce((total, value) => total + toSafeNumber(value), 0);
|
|
88
|
+
export const average = values => {
|
|
89
|
+
if (!values.length) {
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
return roundToDecimals(sum(values) / values.length, 2);
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["toSafeNumber","value","parsed","Number","isNaN","parseNumberSafe","formatNumberWithCommas","options","locale","minimumFractionDigits","maximumFractionDigits","toLocaleString","formatCurrency","amount","currency","isDiscount","safeAmount","startsWith","formatted","toFixed","replace","Intl","NumberFormat","style","format","formatDiscountAmount","discount","undefined","raw","toString","generateRandomNumberString","length","result","digits","i","charAt","Math","floor","random","roundToDecimals","decimals","factor","round","clamp","min","max","formatPercentage","percentage","part","total","formatBytes","bytes","units","index","log","randomInt","lower","ceil","upper","sum","values","reduce","average"],"sourceRoot":"../../../src","sources":["customFunctions/number.ts"],"mappings":";;AAEA,MAAMA,YAAY,GAAIC,KAAyC,IAAa;EAC1E,MAAMC,MAAM,GAAGC,MAAM,CAACF,KAAK,CAAC;EAC5B,OAAOE,MAAM,CAACC,K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CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,CAAC,CAAC,IAAIoB,KAAK,GAAGF,KAAK,GAAG,CAAC,CAAC,CAAC,GAAGA,KAAK;AAChE,CAAC;AAED,OAAO,MAAMG,GAAG,GAAIC,MAA8B,IAChDA,MAAM,CAACC,MAAM,CAAS,CAACZ,KAAK,EAAEhD,KAAK,KAAKgD,KAAK,GAAGjD,YAAY,CAACC,KAAK,CAAC,EAAE,CAAC,CAAC;AAEzE,OAAO,MAAM6D,OAAO,GAAIF,MAA8B,IAAa;EACjE,IAAI,CAACA,MAAM,CAAC7B,MAAM,EAAE;IAClB,OAAO,CAAC;EACV;EAEA,OAAOQ,eAAe,CAACoB,GAAG,CAACC,MAAM,CAAC,GAAGA,MAAM,CAAC7B,MAAM,EAAE,CAAC,CAAC;AACxD,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const pick = (object, keys) => {
|
|
4
|
+
const result = {};
|
|
5
|
+
for (const key of keys) {
|
|
6
|
+
if (key in object) {
|
|
7
|
+
result[key] = object[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
export const omit = (object, keys) => {
|
|
13
|
+
const result = {
|
|
14
|
+
...object
|
|
15
|
+
};
|
|
16
|
+
for (const key of keys) {
|
|
17
|
+
delete result[key];
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
export const deepClone = value => {
|
|
22
|
+
if (value === null || typeof value !== 'object') {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
return JSON.parse(JSON.stringify(value));
|
|
26
|
+
};
|
|
27
|
+
export const isPlainObject = value => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
28
|
+
export const getNestedValue = (object, path, fallback) => {
|
|
29
|
+
const keys = path.split('.');
|
|
30
|
+
let current = object;
|
|
31
|
+
for (const key of keys) {
|
|
32
|
+
if (!isPlainObject(current) || !(key in current)) {
|
|
33
|
+
return fallback;
|
|
34
|
+
}
|
|
35
|
+
current = current[key];
|
|
36
|
+
}
|
|
37
|
+
return current;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["pick","object","keys","result","key","omit","deepClone","value","JSON","parse","stringify","isPlainObject","Array","isArray","getNestedValue","path","fallback","split","current"],"sourceRoot":"../../../src","sources":["customFunctions/object.ts"],"mappings":";;AAAA,OAAO,MAAMA,IAAI,GAAGA,CAClBC,MAAS,EACTC,IAAS,KACM;EACf,MAAMC,MAAM,GAAG,CAAC,CAAe;EAE/B,KAAK,MAAMC,GAAG,IAAIF,IAAI,EAAE;IACtB,IAAIE,GAAG,IAAIH,MAAM,EAAE;MACjBE,MAAM,CAACC,GAAG,CAAC,GAAGH,MAAM,CAACG,GAAG,CAAC;IAC3B;EACF;EAEA,OAAOD,MAAM;AACf,CAAC;AAED,OAAO,MAAME,IAAI,GAAGA,CAClBJ,MAAS,EACTC,IAAS,KACM;EACf,MAAMC,MAAM,GAAG;IAAE,GAAGF;EAAO,CAAC;EAE5B,KAAK,MAAMG,GAAG,IAAIF,IAAI,EAAE;IACtB,OAAOC,MAAM,CAACC,GAAG,CAAC;EACpB;EAEA,OAAOD,MAAM;AACf,CAAC;AAED,OAAO,MAAMG,SAAS,GAAOC,KAAQ,IAAQ;EAC3C,IAAIA,KAAK,KAAK,IAAI,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC/C,OAAOA,KAAK;EACd;EAEA,OAAOC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACH,KAAK,CAAC,CAAC;AAC1C,CAAC;AAED,OAAO,MAAMI,aAAa,GACxBJ,KAAc,IAEd,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAI,CAACK,KAAK,CAACC,OAAO,CAACN,KAAK,CAAC;AAEtE,OAAO,MAAMO,cAAc,GAAGA,CAC5Bb,MAA+B,EAC/Bc,IAAY,EACZC,QAAY,KACM;EAClB,MAAMd,IAAI,GAAGa,IAAI,CAACE,KAAK,CAAC,GAAG,CAAC;EAC5B,IAAIC,OAAgB,GAAGjB,MAAM;EAE7B,KAAK,MAAMG,GAAG,IAAIF,IAAI,EAAE;IACtB,IAAI,CAACS,aAAa,CAACO,OAAO,CAAC,IAAI,EAAEd,GAAG,IAAIc,OAAO,CAAC,EAAE;MAChD,OAAOF,QAAQ;IACjB;IAEAE,OAAO,GAAGA,OAAO,CAACd,GAAG,CAAC;EACxB;EAEA,OAAOc,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const capitalizeFirst = value => {
|
|
4
|
+
if (!value) {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
8
|
+
};
|
|
9
|
+
export const getLocalizedSplitText = (text, language, options) => {
|
|
10
|
+
if (typeof text !== 'string' || !text) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
const delimiter = options?.delimiter ?? '||';
|
|
14
|
+
const englishCode = options?.englishCode ?? 'en';
|
|
15
|
+
const parts = text.split(delimiter);
|
|
16
|
+
if (language.startsWith('fr')) {
|
|
17
|
+
return parts[1]?.trim() ?? parts[0]?.trim() ?? '';
|
|
18
|
+
}
|
|
19
|
+
if (language.startsWith(englishCode)) {
|
|
20
|
+
return parts[0]?.trim() ?? '';
|
|
21
|
+
}
|
|
22
|
+
return parts[0]?.trim() ?? '';
|
|
23
|
+
};
|
|
24
|
+
export const removeDuplicates = items => Array.from(new Set(items));
|
|
25
|
+
export const removeDuplicateStrings = items => removeDuplicates(items);
|
|
26
|
+
export const findItemByProperty = (items, property, value) => {
|
|
27
|
+
if (!items?.length) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return items.find(item => item[property] === value);
|
|
31
|
+
};
|
|
32
|
+
export const truncate = (value, maxLength, suffix = '...') => {
|
|
33
|
+
if (!value || value.length <= maxLength) {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
return `${value.slice(0, Math.max(0, maxLength - suffix.length))}${suffix}`;
|
|
37
|
+
};
|
|
38
|
+
export const capitalizeWords = value => value.trim().split(/\s+/).filter(Boolean).map(word => capitalizeFirst(word.toLowerCase())).join(' ');
|
|
39
|
+
export const slugify = value => value.trim().toLowerCase().replace(/[^a-z0-9\s-]/g, '').replace(/\s+/g, '-').replace(/-+/g, '-');
|
|
40
|
+
export const maskString = (value, options = {}) => {
|
|
41
|
+
const {
|
|
42
|
+
visibleStart = 0,
|
|
43
|
+
visibleEnd = 4,
|
|
44
|
+
maskChar = '*'
|
|
45
|
+
} = options;
|
|
46
|
+
if (!value) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
if (value.length <= visibleStart + visibleEnd) {
|
|
50
|
+
return maskChar.repeat(value.length);
|
|
51
|
+
}
|
|
52
|
+
const start = value.slice(0, visibleStart);
|
|
53
|
+
const end = value.slice(-visibleEnd);
|
|
54
|
+
const masked = maskChar.repeat(value.length - visibleStart - visibleEnd);
|
|
55
|
+
return `${start}${masked}${end}`;
|
|
56
|
+
};
|
|
57
|
+
export const normalizeWhitespace = value => value.trim().replace(/\s+/g, ' ');
|
|
58
|
+
export const initialsFromName = (fullName, maxInitials = 2) => {
|
|
59
|
+
const parts = normalizeWhitespace(fullName).split(' ').filter(Boolean);
|
|
60
|
+
return parts.slice(0, maxInitials).map(part => part.charAt(0).toUpperCase()).join('');
|
|
61
|
+
};
|
|
62
|
+
export const camelToTitle = value => capitalizeWords(value.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/[-_]/g, ' '));
|
|
63
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["capitalizeFirst","value","charAt","toUpperCase","slice","getLocalizedSplitText","text","language","options","delimiter","englishCode","parts","split","startsWith","trim","removeDuplicates","items","Array","from","Set","removeDuplicateStrings","findItemByProperty","property","length","undefined","find","item","truncate","maxLength","suffix","Math","max","capitalizeWords","filter","Boolean","map","word","toLowerCase","join","slugify","replace","maskString","visibleStart","visibleEnd","maskChar","repeat","start","end","masked","normalizeWhitespace","initialsFromName","fullName","maxInitials","part","camelToTitle"],"sourceRoot":"../../../src","sources":["customFunctions/string.ts"],"mappings":";;AAAA,OAAO,MAAMA,eAAe,GAAIC,KAAa,IAAa;EACxD,IAAI,CAACA,KAAK,EAAE;IACV,OAAO,EAAE;EACX;EAEA,OAAOA,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGF,KAAK,CAACG,KAAK,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,OAAO,MAAMC,qBAAqB,GAAGA,CACnCC,IAAwB,EACxBC,QAAgB,EAChBC,OAAsD,KAC3C;EACX,IAAI,OAAOF,IAAI,KAAK,QAAQ,IAAI,CAACA,IAAI,EAAE;IACrC,OAAO,EAAE;EACX;EAEA,MAAMG,SAAS,GAAGD,OAAO,EAAEC,SAAS,IAAI,IAAI;EAC5C,MAAMC,WAAW,GAAGF,OAAO,EAAEE,WAAW,IAAI,IAAI;EAChD,MAAMC,KAAK,GAAGL,IAAI,CAACM,KAAK,CAACH,SAAS,CAAC;EAEnC,IAAIF,QAAQ,CAACM,UAAU,CAAC,IAAI,CAAC,EAAE;IAC7B,OAAOF,KAAK,CAAC,CAAC,CAAC,EAAEG,IAAI,CAAC,CAAC,IAAIH,KAAK,CAAC,CAAC,CAAC,EAAEG,IAAI,CAAC,CAAC,IAAI,EAAE;EACnD;EAEA,IAAIP,QAAQ,CAACM,UAAU,CAACH,WAAW,CAAC,EAAE;IACpC,OAAOC,KAAK,CAAC,CAAC,CAAC,EAAEG,IAAI,CAAC,CAAC,IAAI,EAAE;EAC/B;E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AAC,EAAEgD,WAAW,CAAC,CACrBjB,GAAG,CAAEkB,IAAI,IAAKA,IAAI,CAACnD,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAAC,CAC3CmC,IAAI,CAAC,EAAE,CAAC;AACb,CAAC;AAED,OAAO,MAAMgB,YAAY,GAAIrD,KAAa,IACxC+B,eAAe,CACb/B,KAAK,CAACuC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAACA,OAAO,CAAC,OAAO,EAAE,GAAG,CAChE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["customFunctions/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
|
|
4
|
+
const URL_REGEX = /^(https?:\/\/)?([\w-]+\.)+[\w-]{2,}(\/[\w\-._~:/?#[\]@!$&'()*+,;=]*)?$/i;
|
|
5
|
+
const PHONE_REGEX = /^\+?[\d\s().-]{7,20}$/;
|
|
6
|
+
const NUMERIC_REGEX = /^-?\d+(\.\d+)?$/;
|
|
7
|
+
export const isValidEmail = email => EMAIL_REGEX.test(email);
|
|
8
|
+
export const isValidUrl = value => URL_REGEX.test(value.trim());
|
|
9
|
+
export const isValidPhone = value => PHONE_REGEX.test(value.trim());
|
|
10
|
+
export const isNumeric = value => NUMERIC_REGEX.test(String(value).trim());
|
|
11
|
+
export const isStrongPassword = (password, options = {}) => {
|
|
12
|
+
const {
|
|
13
|
+
minLength = 8,
|
|
14
|
+
requireNumber = true,
|
|
15
|
+
requireLetter = true
|
|
16
|
+
} = options;
|
|
17
|
+
if (password.length < minLength) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (requireNumber && !/\d/.test(password)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (requireLetter && !/[a-zA-Z]/.test(password)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
export const encodePlusInEmail = email => {
|
|
29
|
+
if (!email.includes('+')) {
|
|
30
|
+
return email;
|
|
31
|
+
}
|
|
32
|
+
return email.replace(/\+/g, '%2B');
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EMAIL_REGEX","URL_REGEX","PHONE_REGEX","NUMERIC_REGEX","isValidEmail","email","test","isValidUrl","value","trim","isValidPhone","isNumeric","String","isStrongPassword","password","options","minLength","requireNumber","requireLetter","length","encodePlusInEmail","includes","replace"],"sourceRoot":"../../../src","sources":["customFunctions/validation.ts"],"mappings":";;AAAA,MAAMA,WAAW,GAAG,+BAA+B;AACnD,MAAMC,SAAS,GACb,yEAAyE;AAC3E,MAAMC,WAAW,GAAG,uBAAuB;AAC3C,MAAMC,aAAa,GAAG,iBAAiB;AAEvC,OAAO,MAAMC,YAAY,GAAIC,KAAa,IAAcL,WAAW,CAACM,IAAI,CAACD,KAAK,CAAC;AAE/E,OAAO,MAAME,UAAU,GAAIC,KAAa,IACtCP,SAAS,CAACK,IAAI,CAACE,KAAK,CAACC,IAAI,CAAC,CAAC,CAAC;AAE9B,OAAO,MAAMC,YAAY,GAAIF,KAAa,IACxCN,WAAW,CAACI,IAAI,CAACE,KAAK,CAACC,IAAI,CAAC,CAAC,CAAC;AAEhC,OAAO,MAAME,SAAS,GAAIH,KAAsB,IAC9CL,aAAa,CAACG,IAAI,CAACM,MAAM,CAACJ,KAAK,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC;AAE1C,OAAO,MAAMI,gBAAgB,GAAGA,CAC9BC,QAAgB,EAChBC,OAIC,GAAG,CAAC,CAAC,KACM;EACZ,MAAM;IAAEC,SAAS,GAAG,CAAC;IAAEC,aAAa,GAAG,IAAI;IAAEC,aAAa,GAAG;EAAK,CAAC,GAAGH,OAAO;EAE7E,IAAID,QAAQ,CAACK,MAAM,GAAGH,SAAS,EAAE;IAC/B,OAAO,KAAK;EACd;EAEA,IAAIC,aAAa,IAAI,CAAC,IAAI,CAACX,IAAI,CAACQ,QAAQ,CAAC,EAAE;IACzC,OAAO,KAAK;EACd;EAEA,IAAII,aAAa,IAAI,CAAC,UAAU,CAACZ,IAAI,CAACQ,QAAQ,CAAC,EAAE;IAC/C,OAAO,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC;AAED,OAAO,MAAMM,iBAAiB,GAAIf,KAAa,IAAa;EAC1D,IAAI,CAACA,KAAK,CAACgB,QAAQ,CAAC,GAAG,CAAC,EAAE;IACxB,OAAOhB,KAAK;EACd;EAEA,OAAOA,KAAK,CAACiB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;AACpC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export class ApiError extends Error {
|
|
4
|
+
constructor(message, options = {}) {
|
|
5
|
+
super(message, options.cause ? {
|
|
6
|
+
cause: options.cause
|
|
7
|
+
} : undefined);
|
|
8
|
+
this.name = 'ApiError';
|
|
9
|
+
this.status = options.status;
|
|
10
|
+
this.code = options.code;
|
|
11
|
+
this.details = options.details;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export const isApiError = error => error instanceof ApiError;
|
|
15
|
+
export const toApiError = error => {
|
|
16
|
+
if (isApiError(error)) {
|
|
17
|
+
return error;
|
|
18
|
+
}
|
|
19
|
+
if (error instanceof Error) {
|
|
20
|
+
const maybeStatus = error.status;
|
|
21
|
+
const maybeCode = error.code;
|
|
22
|
+
const maybeDetails = error.details;
|
|
23
|
+
return new ApiError(error.message, {
|
|
24
|
+
status: maybeStatus,
|
|
25
|
+
code: maybeCode,
|
|
26
|
+
details: maybeDetails ?? error,
|
|
27
|
+
cause: error
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (typeof error === 'string') {
|
|
31
|
+
return new ApiError(error);
|
|
32
|
+
}
|
|
33
|
+
if (error && typeof error === 'object') {
|
|
34
|
+
const record = error;
|
|
35
|
+
const message = String(record.message ?? record.error ?? record.statusText ?? 'Unknown error');
|
|
36
|
+
return new ApiError(message, {
|
|
37
|
+
status: typeof record.status === 'number' ? record.status : undefined,
|
|
38
|
+
code: typeof record.code === 'string' ? record.code : undefined,
|
|
39
|
+
details: error
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return new ApiError('Unknown error', {
|
|
43
|
+
details: error
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export const getApiErrorMessage = (error, fallback = 'Something went wrong') => {
|
|
47
|
+
if (!error) {
|
|
48
|
+
return fallback;
|
|
49
|
+
}
|
|
50
|
+
if (typeof error === 'string') {
|
|
51
|
+
return error;
|
|
52
|
+
}
|
|
53
|
+
if (error instanceof Error) {
|
|
54
|
+
return error.message || fallback;
|
|
55
|
+
}
|
|
56
|
+
if (typeof error === 'object' && error !== null && 'message' in error) {
|
|
57
|
+
return String(error.message ?? fallback);
|
|
58
|
+
}
|
|
59
|
+
return fallback;
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ApiError","Error","constructor","message","options","cause","undefined","name","status","code","details","isApiError","error","toApiError","maybeStatus","maybeCode","maybeDetails","record","String","statusText","getApiErrorMessage","fallback"],"sourceRoot":"../../../src","sources":["customHooks/errors.ts"],"mappings":";;AAEA,OAAO,MAAMA,QAAQ,SAASC,KAAK,CAAyB;EAK1DC,WAAWA,CACTC,OAAe,EACfC,OAKC,GAAG,CAAC,CAAC,EACN;IACA,KAAK,CAACD,OAAO,EAAEC,OAAO,CAACC,KAAK,GAAG;MAAEA,KAAK,EAAED,OAAO,CAACC;IAAM,CAAC,GAAGC,SAAS,CAAC;IACpE,IA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AAM,CAACR,IAAI,KAAK,QAAQ,GAAGQ,MAAM,CAACR,IAAI,GAAGH,SAAS;MAC/DI,OAAO,EAAEE;IACX,CAAC,CAAC;EACJ;EAEA,OAAO,IAAIZ,QAAQ,CAAC,eAAe,EAAE;IAAEU,OAAO,EAAEE;EAAM,CAAC,CAAC;AAC1D,CAAC;AAED,OAAO,MAAMQ,kBAAkB,GAAGA,CAChCR,KAAc,EACdS,QAAQ,GAAG,sBAAsB,KACtB;EACX,IAAI,CAACT,KAAK,EAAE;IACV,OAAOS,QAAQ;EACjB;EAEA,IAAI,OAAOT,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOA,KAAK;EACd;EAEA,IAAIA,KAAK,YAAYX,KAAK,EAAE;IAC1B,OAAOW,KAAK,CAACT,OAAO,IAAIkB,QAAQ;EAClC;EAEA,IAAI,OAAOT,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAI,SAAS,IAAIA,KAAK,EAAE;IACrE,OAAOM,MAAM,CAAEN,KAAK,CAA2BT,OAAO,IAAIkB,QAAQ,CAAC;EACrE;EAEA,OAAOA,QAAQ;AACjB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { ApiError } from "./errors.js";
|
|
4
|
+
export const fetchJson = async (input, options = {}) => {
|
|
5
|
+
const {
|
|
6
|
+
parseJson = true,
|
|
7
|
+
headers,
|
|
8
|
+
...init
|
|
9
|
+
} = options;
|
|
10
|
+
const response = await fetch(input, {
|
|
11
|
+
...init,
|
|
12
|
+
headers: {
|
|
13
|
+
'Accept': 'application/json',
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
...headers
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const rawText = await response.text();
|
|
19
|
+
let payload = rawText;
|
|
20
|
+
if (parseJson && rawText) {
|
|
21
|
+
try {
|
|
22
|
+
payload = JSON.parse(rawText);
|
|
23
|
+
} catch {
|
|
24
|
+
payload = rawText;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
const message = typeof payload === 'object' && payload !== null && 'message' in payload && typeof payload.message === 'string' ? payload.message : response.statusText || 'Request failed';
|
|
29
|
+
throw new ApiError(message, {
|
|
30
|
+
status: response.status,
|
|
31
|
+
details: payload
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return payload;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=fetchJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ApiError","fetchJson","input","options","parseJson","headers","init","response","fetch","rawText","text","payload","JSON","parse","ok","message","statusText","status","details"],"sourceRoot":"../../../src","sources":["customHooks/fetchJson.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,aAAU;AAMnC,OAAO,MAAMC,SAAS,GAAG,MAAAA,CACvBC,KAAwB,EACxBC,OAAyB,GAAG,CAAC,CAAC,KACP;EACvB,MAAM;IAAEC,SAAS,GAAG,IAAI;IAAEC,OAAO;IAAE,GAAGC;EAAK,CAAC,GAAGH,OAAO;EAEtD,MAAMI,QAAQ,GAAG,MAAMC,KAAK,CAACN,KAAK,EAAE;IAClC,GAAGI,IAAI;IACPD,OAAO,EAAE;MACP,QAAQ,EAAE,kBAAkB;MAC5B,cAAc,EAAE,kBAAkB;MAClC,GAAGA;IACL;EACF,CAAC,CAAC;EAEF,MAAMI,OAAO,GAAG,MAAMF,QAAQ,CAACG,IAAI,CAAC,CAAC;EACrC,IAAIC,OAAgB,GAAGF,OAAO;EAE9B,IAAIL,SAAS,IAAIK,OAAO,EAAE;IACxB,IAAI;MACFE,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACJ,OAAO,CAAC;IAC/B,CAAC,CAAC,MAAM;MACNE,OAAO,GAAGF,OAAO;IACnB;EACF;EAEA,IAAI,CAACF,QAAQ,CAACO,EAAE,EAAE;IAChB,MAAMC,OAAO,GACX,OAAOJ,OAAO,KAAK,QAAQ,IAC3BA,OAAO,KAAK,IAAI,IAChB,SAAS,IAAIA,OAAO,IACpB,OAAQA,OAAO,CAA2BI,OAAO,KAAK,QAAQ,GACzDJ,OAAO,CAAyBI,OAAO,GACxCR,QAAQ,CAACS,UAAU,IAAI,gBAAgB;IAE7C,MAAM,IAAIhB,QAAQ,CAACe,OAAO,EAAE;MAC1BE,MAAM,EAAEV,QAAQ,CAACU,MAAM;MACvBC,OAAO,EAAEP;IACX,CAAC,CAAC;EACJ;EAEA,OAAOA,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { ApiError, getApiErrorMessage, isApiError, toApiError } from "./errors.js";
|
|
4
|
+
export { fetchJson } from "./fetchJson.js";
|
|
5
|
+
export { useApi } from "./useApi.js";
|
|
6
|
+
export { useLazyApi } from "./useLazyApi.js";
|
|
7
|
+
export { useMutation } from "./useMutation.js";
|
|
8
|
+
export { usePaginatedApi } from "./usePaginatedApi.js";
|
|
9
|
+
export { usePollingApi } from "./usePollingApi.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ApiError","getApiErrorMessage","isApiError","toApiError","fetchJson","useApi","useLazyApi","useMutation","usePaginatedApi","usePollingApi"],"sourceRoot":"../../../src","sources":["customHooks/index.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,UAAU,QAAQ,aAAU;AAC/E,SAASC,SAAS,QAA+B,gBAAa;AAC9D,SAASC,MAAM,QAAQ,aAAU;AACjC,SAASC,UAAU,QAAQ,iBAAc;AACzC,SAASC,WAAW,QAAQ,kBAAe;AAC3C,SAASC,eAAe,QAAQ,sBAAmB;AACnD,SAASC,aAAa,QAAQ,oBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { toApiError } from "./errors.js";
|
|
5
|
+
export const useDependencyKey = deps => JSON.stringify(deps);
|
|
6
|
+
export const getStatusFlags = status => ({
|
|
7
|
+
status,
|
|
8
|
+
isIdle: status === 'idle',
|
|
9
|
+
isLoading: status === 'loading',
|
|
10
|
+
isSuccess: status === 'success',
|
|
11
|
+
isError: status === 'error'
|
|
12
|
+
});
|
|
13
|
+
export const useIsMounted = () => {
|
|
14
|
+
const isMountedRef = useRef(true);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
isMountedRef.current = true;
|
|
17
|
+
return () => {
|
|
18
|
+
isMountedRef.current = false;
|
|
19
|
+
};
|
|
20
|
+
}, []);
|
|
21
|
+
return isMountedRef;
|
|
22
|
+
};
|
|
23
|
+
export const useAbortControllerRef = () => {
|
|
24
|
+
const abortRef = useRef(null);
|
|
25
|
+
const abort = () => {
|
|
26
|
+
abortRef.current?.abort();
|
|
27
|
+
abortRef.current = null;
|
|
28
|
+
};
|
|
29
|
+
const create = () => {
|
|
30
|
+
abort();
|
|
31
|
+
const controller = new AbortController();
|
|
32
|
+
abortRef.current = controller;
|
|
33
|
+
return controller;
|
|
34
|
+
};
|
|
35
|
+
useEffect(() => abort, []);
|
|
36
|
+
return {
|
|
37
|
+
abortRef,
|
|
38
|
+
abort,
|
|
39
|
+
create
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export const normalizeApiError = error => toApiError(error);
|
|
43
|
+
export const isAbortError = error => {
|
|
44
|
+
if (typeof DOMException !== 'undefined' && error instanceof DOMException && error.name === 'AbortError') {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return error instanceof Error && (error.name === 'AbortError' || error.message === 'Aborted');
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","toApiError","useDependencyKey","deps","JSON","stringify","getStatusFlags","status","isIdle","isLoading","isSuccess","isError","useIsMounted","isMountedRef","current","useAbortControllerRef","abortRef","abort","create","controller","AbortController","normalizeApiError","error","isAbortError","DOMException","name","Error","message"],"sourceRoot":"../../../src","sources":["customHooks/internal.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,SAASC,UAAU,QAAQ,aAAU;AAGrC,OAAO,MAAMC,gBAAgB,GAAIC,IAA4B,IAC3DC,IAAI,CAACC,SAAS,CAACF,IAAI,CAAC;AAEtB,OAAO,MAAMG,cAAc,GAAIC,MAAiB,KAAsB;EACpEA,MAAM;EACNC,MAAM,EAAED,MAAM,KAAK,MAAM;EACzBE,SAAS,EAAEF,MAAM,KAAK,SAAS;EAC/BG,SAAS,EAAEH,MAAM,KAAK,SAAS;EAC/BI,OAAO,EAAEJ,MAAM,KAAK;AACtB,CAAC,CAAC;AAEF,OAAO,MAAMK,YAAY,GAAGA,CAAA,KAAM;EAChC,MAAMC,YAAY,GAAGb,MAAM,CAAC,IAAI,CAAC;EAEjCD,SAAS,CAAC,MAAM;IACdc,YAAY,CAACC,OAAO,GAAG,IAAI;IAE3B,OAAO,MAAM;MACXD,YAAY,CAACC,OAAO,GAAG,KAAK;IAC9B,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOD,YAAY;AACrB,CAAC;AAED,OAAO,MAAME,qBAAqB,GAAGA,CAAA,KAAM;EACzC,MAAMC,QAAQ,GAAGhB,MAAM,CAAyB,IAAI,CAAC;EAErD,MAAMiB,KAAK,GAAGA,CAAA,KAAM;IAClBD,QAAQ,CAACF,OAAO,EAAEG,KAAK,CAAC,CAAC;IACzBD,QAAQ,CAACF,OAAO,GAAG,IAAI;EACzB,CAAC;EAED,MAAMI,MAAM,GAAGA,CAAA,KAAM;IACnBD,KAAK,CAAC,CAAC;IACP,MAAME,UAAU,GAAG,IAAIC,eAAe,CAAC,CAAC;IACxCJ,QAAQ,CAACF,OAAO,GAAGK,UAAU;IAC7B,OAAOA,UAAU;EACnB,CAAC;EAEDpB,SAAS,CAAC,MAAMkB,KAAK,EAAE,EAAE,CAAC;EAE1B,OAAO;IAAED,QAAQ;IAAEC,KAAK;IAAEC;EAAO,CAAC;AACpC,CAAC;AAED,OAAO,MAAMG,iBAAiB,GAAYC,KAAc,IACtDrB,UAAU,CAACqB,KAAK,CAAW;AAE7B,OAAO,MAAMC,YAAY,GAAID,KAAc,IAAK;EAC9C,IACE,OAAOE,YAAY,KAAK,WAAW,IACnCF,KAAK,YAAYE,YAAY,IAC7BF,KAAK,CAACG,IAAI,KAAK,YAAY,EAC3B;IACA,OAAO,IAAI;EACb;EAEA,OACEH,KAAK,YAAYI,KAAK,KACrBJ,KAAK,CAACG,IAAI,KAAK,YAAY,IAAIH,KAAK,CAACK,OAAO,KAAK,SAAS,CAAC;AAEhE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["customHooks/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { getStatusFlags, isAbortError, normalizeApiError, useAbortControllerRef, useDependencyKey, useIsMounted } from "./internal.js";
|
|
5
|
+
export const useApi = (fetcher, options = {}) => {
|
|
6
|
+
const {
|
|
7
|
+
enabled = true,
|
|
8
|
+
initialData = null,
|
|
9
|
+
deps = [],
|
|
10
|
+
keepPreviousData = false,
|
|
11
|
+
onSuccess,
|
|
12
|
+
onError,
|
|
13
|
+
onSettled
|
|
14
|
+
} = options;
|
|
15
|
+
const [data, setData] = useState(initialData);
|
|
16
|
+
const [error, setError] = useState(null);
|
|
17
|
+
const [status, setStatus] = useState(enabled ? 'loading' : 'idle');
|
|
18
|
+
const fetcherRef = useRef(fetcher);
|
|
19
|
+
const callbacksRef = useRef({
|
|
20
|
+
onSuccess,
|
|
21
|
+
onError,
|
|
22
|
+
onSettled
|
|
23
|
+
});
|
|
24
|
+
const isMountedRef = useIsMounted();
|
|
25
|
+
const {
|
|
26
|
+
abort,
|
|
27
|
+
create
|
|
28
|
+
} = useAbortControllerRef();
|
|
29
|
+
const depsKey = useDependencyKey(deps);
|
|
30
|
+
fetcherRef.current = fetcher;
|
|
31
|
+
callbacksRef.current = {
|
|
32
|
+
onSuccess,
|
|
33
|
+
onError,
|
|
34
|
+
onSettled
|
|
35
|
+
};
|
|
36
|
+
const execute = useCallback(async () => {
|
|
37
|
+
const controller = create();
|
|
38
|
+
setStatus('loading');
|
|
39
|
+
setError(null);
|
|
40
|
+
if (!keepPreviousData) {
|
|
41
|
+
setData(initialData);
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const result = await fetcherRef.current(controller.signal);
|
|
45
|
+
if (controller.signal.aborted || !isMountedRef.current) {
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
setData(result);
|
|
49
|
+
setStatus('success');
|
|
50
|
+
callbacksRef.current.onSuccess?.(result);
|
|
51
|
+
callbacksRef.current.onSettled?.(result, null);
|
|
52
|
+
return result;
|
|
53
|
+
} catch (unknownError) {
|
|
54
|
+
if (isAbortError(unknownError)) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const parsedError = normalizeApiError(unknownError);
|
|
58
|
+
if (!isMountedRef.current) {
|
|
59
|
+
throw parsedError;
|
|
60
|
+
}
|
|
61
|
+
setError(parsedError);
|
|
62
|
+
setStatus('error');
|
|
63
|
+
callbacksRef.current.onError?.(parsedError);
|
|
64
|
+
callbacksRef.current.onSettled?.(null, parsedError);
|
|
65
|
+
throw parsedError;
|
|
66
|
+
}
|
|
67
|
+
}, [create, initialData, isMountedRef, keepPreviousData]);
|
|
68
|
+
const refetch = useCallback(async () => execute(), [execute]);
|
|
69
|
+
const reset = useCallback(() => {
|
|
70
|
+
abort();
|
|
71
|
+
setData(initialData);
|
|
72
|
+
setError(null);
|
|
73
|
+
setStatus('idle');
|
|
74
|
+
}, [abort, initialData]);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (!enabled) {
|
|
77
|
+
abort();
|
|
78
|
+
setStatus('idle');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
execute().catch(() => undefined);
|
|
82
|
+
}, [abort, depsKey, enabled, execute]);
|
|
83
|
+
return {
|
|
84
|
+
data,
|
|
85
|
+
error,
|
|
86
|
+
...getStatusFlags(status),
|
|
87
|
+
refetch,
|
|
88
|
+
reset
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=useApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useState","getStatusFlags","isAbortError","normalizeApiError","useAbortControllerRef","useDependencyKey","useIsMounted","useApi","fetcher","options","enabled","initialData","deps","keepPreviousData","onSuccess","onError","onSettled","data","setData","error","setError","status","setStatus","fetcherRef","callbacksRef","isMountedRef","abort","create","depsKey","current","execute","controller","result","signal","aborted","unknownError","parsedError","refetch","reset","catch","undefined"],"sourceRoot":"../../../src","sources":["customHooks/useApi.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEhE,SACEC,cAAc,EACdC,YAAY,EACZC,iBAAiB,EACjBC,qBAAqB,EACrBC,gBAAgB,EAChBC,YAAY,QACP,eAAY;AAGnB,OAAO,MAAMC,MAAM,GAAGA,CACpBC,OAA0B,EAC1BC,OAAqC,GAAG,CAAC,CAAC,KACvC;EACH,MAAM;IACJC,OAAO,GAAG,IAAI;IACdC,WAAW,GAAG,IAAI;IAClBC,IAAI,GAAG,EAAE;IACTC,gBAAgB,GAAG,KAAK;IACxBC,SAAS;IACTC,OAAO;IACPC;EACF,CAAC,GAAGP,OAAO;EAEX,MAAM,CAACQ,IAAI,EAAEC,OAAO,CAAC,G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,GAAGlB,cAAc,CAACoB,MAAM,CAAC;IACzBgB,OAAO;IACPC;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useRef, useState } from 'react';
|
|
4
|
+
import { getStatusFlags, isAbortError, normalizeApiError, useAbortControllerRef, useIsMounted } from "./internal.js";
|
|
5
|
+
export const useLazyApi = (fetcher, options = {}) => {
|
|
6
|
+
const {
|
|
7
|
+
initialData = null,
|
|
8
|
+
keepPreviousData = false,
|
|
9
|
+
onSuccess,
|
|
10
|
+
onError,
|
|
11
|
+
onSettled
|
|
12
|
+
} = options;
|
|
13
|
+
const [data, setData] = useState(initialData);
|
|
14
|
+
const [error, setError] = useState(null);
|
|
15
|
+
const [status, setStatus] = useState('idle');
|
|
16
|
+
const fetcherRef = useRef(fetcher);
|
|
17
|
+
const callbacksRef = useRef({
|
|
18
|
+
onSuccess,
|
|
19
|
+
onError,
|
|
20
|
+
onSettled
|
|
21
|
+
});
|
|
22
|
+
const isMountedRef = useIsMounted();
|
|
23
|
+
const {
|
|
24
|
+
abort,
|
|
25
|
+
create
|
|
26
|
+
} = useAbortControllerRef();
|
|
27
|
+
fetcherRef.current = fetcher;
|
|
28
|
+
callbacksRef.current = {
|
|
29
|
+
onSuccess,
|
|
30
|
+
onError,
|
|
31
|
+
onSettled
|
|
32
|
+
};
|
|
33
|
+
const execute = useCallback(async () => {
|
|
34
|
+
const controller = create();
|
|
35
|
+
setStatus('loading');
|
|
36
|
+
setError(null);
|
|
37
|
+
if (!keepPreviousData) {
|
|
38
|
+
setData(initialData);
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const result = await fetcherRef.current(controller.signal);
|
|
42
|
+
if (controller.signal.aborted || !isMountedRef.current) {
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
setData(result);
|
|
46
|
+
setStatus('success');
|
|
47
|
+
callbacksRef.current.onSuccess?.(result);
|
|
48
|
+
callbacksRef.current.onSettled?.(result, null);
|
|
49
|
+
return result;
|
|
50
|
+
} catch (unknownError) {
|
|
51
|
+
if (isAbortError(unknownError)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const parsedError = normalizeApiError(unknownError);
|
|
55
|
+
if (!isMountedRef.current) {
|
|
56
|
+
throw parsedError;
|
|
57
|
+
}
|
|
58
|
+
setError(parsedError);
|
|
59
|
+
setStatus('error');
|
|
60
|
+
callbacksRef.current.onError?.(parsedError);
|
|
61
|
+
callbacksRef.current.onSettled?.(null, parsedError);
|
|
62
|
+
throw parsedError;
|
|
63
|
+
}
|
|
64
|
+
}, [create, initialData, isMountedRef, keepPreviousData]);
|
|
65
|
+
const reset = useCallback(() => {
|
|
66
|
+
abort();
|
|
67
|
+
setData(initialData);
|
|
68
|
+
setError(null);
|
|
69
|
+
setStatus('idle');
|
|
70
|
+
}, [abort, initialData]);
|
|
71
|
+
return {
|
|
72
|
+
data,
|
|
73
|
+
error,
|
|
74
|
+
...getStatusFlags(status),
|
|
75
|
+
execute,
|
|
76
|
+
refetch: execute,
|
|
77
|
+
reset
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=useLazyApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","useState","getStatusFlags","isAbortError","normalizeApiError","useAbortControllerRef","useIsMounted","useLazyApi","fetcher","options","initialData","keepPreviousData","onSuccess","onError","onSettled","data","setData","error","setError","status","setStatus","fetcherRef","callbacksRef","isMountedRef","abort","create","current","execute","controller","result","signal","aborted","unknownError","parsedError","reset","refetch"],"sourceRoot":"../../../src","sources":["customHooks/useLazyApi.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAErD,SACEC,cAAc,EACdC,YAAY,EACZC,iBAAiB,EACjBC,qBAAqB,EACrBC,YAAY,QACP,eAAY;AAGnB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