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,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useRef, useState } from 'react';
|
|
4
|
+
import { getStatusFlags, isAbortError, normalizeApiError, useAbortControllerRef, useIsMounted } from "./internal.js";
|
|
5
|
+
export const useMutation = (mutationFn, options = {}) => {
|
|
6
|
+
const [data, setData] = useState(null);
|
|
7
|
+
const [error, setError] = useState(null);
|
|
8
|
+
const [status, setStatus] = useState('idle');
|
|
9
|
+
const [variables, setVariables] = useState(null);
|
|
10
|
+
const mutationRef = useRef(mutationFn);
|
|
11
|
+
const callbacksRef = useRef(options);
|
|
12
|
+
const isMountedRef = useIsMounted();
|
|
13
|
+
const {
|
|
14
|
+
abort,
|
|
15
|
+
create
|
|
16
|
+
} = useAbortControllerRef();
|
|
17
|
+
mutationRef.current = mutationFn;
|
|
18
|
+
callbacksRef.current = options;
|
|
19
|
+
const mutateAsync = useCallback(async nextVariables => {
|
|
20
|
+
const controller = create();
|
|
21
|
+
setStatus('loading');
|
|
22
|
+
setError(null);
|
|
23
|
+
setVariables(nextVariables);
|
|
24
|
+
try {
|
|
25
|
+
const result = await mutationRef.current(nextVariables, controller.signal);
|
|
26
|
+
if (controller.signal.aborted || !isMountedRef.current) {
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
setData(result);
|
|
30
|
+
setStatus('success');
|
|
31
|
+
callbacksRef.current.onSuccess?.(result, nextVariables);
|
|
32
|
+
callbacksRef.current.onSettled?.(result, null, nextVariables);
|
|
33
|
+
return result;
|
|
34
|
+
} catch (unknownError) {
|
|
35
|
+
if (isAbortError(unknownError)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const parsedError = normalizeApiError(unknownError);
|
|
39
|
+
if (!isMountedRef.current) {
|
|
40
|
+
throw parsedError;
|
|
41
|
+
}
|
|
42
|
+
setError(parsedError);
|
|
43
|
+
setStatus('error');
|
|
44
|
+
callbacksRef.current.onError?.(parsedError, nextVariables);
|
|
45
|
+
callbacksRef.current.onSettled?.(null, parsedError, nextVariables);
|
|
46
|
+
throw parsedError;
|
|
47
|
+
}
|
|
48
|
+
}, [create, isMountedRef]);
|
|
49
|
+
const mutate = useCallback(nextVariables => {
|
|
50
|
+
mutateAsync(nextVariables).catch(() => {});
|
|
51
|
+
}, [mutateAsync]);
|
|
52
|
+
const reset = useCallback(() => {
|
|
53
|
+
abort();
|
|
54
|
+
setData(null);
|
|
55
|
+
setError(null);
|
|
56
|
+
setVariables(null);
|
|
57
|
+
setStatus('idle');
|
|
58
|
+
}, [abort]);
|
|
59
|
+
return {
|
|
60
|
+
data,
|
|
61
|
+
error,
|
|
62
|
+
variables,
|
|
63
|
+
...getStatusFlags(status),
|
|
64
|
+
mutate,
|
|
65
|
+
mutateAsync,
|
|
66
|
+
reset
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=useMutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","useState","getStatusFlags","isAbortError","normalizeApiError","useAbortControllerRef","useIsMounted","useMutation","mutationFn","options","data","setData","error","setError","status","setStatus","variables","setVariables","mutationRef","callbacksRef","isMountedRef","abort","create","current","mutateAsync","nextVariables","controller","result","signal","aborted","onSuccess","onSettled","unknownError","parsedError","onError","mutate","catch","reset"],"sourceRoot":"../../../src","sources":["customHooks/useMutation.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,OAAO,MAAMC,WAAW,GAAGA,CACzBC,UAA2E,EAC3EC,OAAsD,GAAG,CAAC,CAAC,KACxD;EACH,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,QAAQ,CAAe,IAAI,CAAC;EACpD,MAAM,CAACW,KAAK,EAAEC,QAAQ,CAAC,GAAGZ,QAAQ,CAAgB,IAAI,CAAC;EACvD,MAAM,CAACa,MAAM,EAAEC,SAAS,CAAC,GAAGd,QAAQ,CAAY,MAAM,CAAC;EACvD,MAAM,CAACe,SAAS,EAAEC,YAAY,CAAC,GAAGhB,QAAQ,CAAoB,IAAI,CAAC;EAEnE,MAAMiB,WAAW,GAAGlB,MAAM,CAACQ,UAAU,CAAC;EACtC,MAAMW,YAAY,GAAGnB,MAAM,CAACS,OAAO,CAAC;EACpC,MAAMW,YAAY,GAAGd,YAAY,CAAC,CAAC;EACnC,MAAM;IAAEe,KAAK;IAAEC;EAAO,CAAC,GAAGjB,qBAAqB,CAAC,CAAC;EAEjDa,WAAW,CAACK,OAAO,GAAGf,UAAU;EAChCW,YAAY,CAACI,OAAO,GAAGd,OAAO;EAE9B,MAAMe,WAAW,GAAGzB,WAAW,CAC7B,MAAO0B,aAAyB,IAAK;IACnC,MAAMC,UAAU,GAAGJ,MAAM,CAAC,CAAC;IAE3BP,SAAS,CAAC,SAAS,CAAC;IACpBF,QAAQ,CAAC,IAAI,CAAC;IACdI,YAAY,CAACQ,aAAa,CAAC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CAAC,IAAI,CAAC;IACbE,QAAQ,CAAC,IAAI,CAAC;IACdI,YAAY,CAAC,IAAI,CAAC;IAClBF,SAAS,CAAC,MAAM,CAAC;EACnB,CAAC,EAAE,CAACM,KAAK,CAAC,CAAC;EAEX,OAAO;IACLX,IAAI;IACJE,KAAK;IACLI,SAAS;IACT,GAAGd,cAAc,CAACY,MAAM,CAAC;IACzBqB,MAAM;IACNX,WAAW;IACXa;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,127 @@
|
|
|
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 usePaginatedApi = (fetcher, options = {}) => {
|
|
6
|
+
const {
|
|
7
|
+
enabled = true,
|
|
8
|
+
initialPage = 1,
|
|
9
|
+
deps = [],
|
|
10
|
+
onSuccess,
|
|
11
|
+
onError
|
|
12
|
+
} = options;
|
|
13
|
+
const [items, setItems] = useState([]);
|
|
14
|
+
const [page, setPage] = useState(initialPage);
|
|
15
|
+
const [hasMore, setHasMore] = useState(true);
|
|
16
|
+
const [total, setTotal] = useState(undefined);
|
|
17
|
+
const [error, setError] = useState(null);
|
|
18
|
+
const [status, setStatus] = useState(enabled ? 'loading' : 'idle');
|
|
19
|
+
const [isRefreshing, setIsRefreshing] = useState(false);
|
|
20
|
+
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
21
|
+
const fetcherRef = useRef(fetcher);
|
|
22
|
+
const callbacksRef = useRef({
|
|
23
|
+
onSuccess,
|
|
24
|
+
onError
|
|
25
|
+
});
|
|
26
|
+
const isMountedRef = useIsMounted();
|
|
27
|
+
const {
|
|
28
|
+
abort,
|
|
29
|
+
create
|
|
30
|
+
} = useAbortControllerRef();
|
|
31
|
+
const depsKey = useDependencyKey(deps);
|
|
32
|
+
fetcherRef.current = fetcher;
|
|
33
|
+
callbacksRef.current = {
|
|
34
|
+
onSuccess,
|
|
35
|
+
onError
|
|
36
|
+
};
|
|
37
|
+
const applyResponse = useCallback((response, targetPage, replace) => {
|
|
38
|
+
setItems(current => replace ? response.items : [...current, ...response.items]);
|
|
39
|
+
setHasMore(response.hasMore);
|
|
40
|
+
setTotal(response.total);
|
|
41
|
+
setPage(targetPage);
|
|
42
|
+
setStatus('success');
|
|
43
|
+
callbacksRef.current.onSuccess?.(response, targetPage);
|
|
44
|
+
}, []);
|
|
45
|
+
const fetchPage = useCallback(async (targetPage, replace) => {
|
|
46
|
+
const controller = create();
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetcherRef.current(targetPage, controller.signal);
|
|
49
|
+
if (controller.signal.aborted || !isMountedRef.current) {
|
|
50
|
+
return response;
|
|
51
|
+
}
|
|
52
|
+
applyResponse(response, targetPage, replace);
|
|
53
|
+
setError(null);
|
|
54
|
+
return response;
|
|
55
|
+
} catch (unknownError) {
|
|
56
|
+
if (isAbortError(unknownError)) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const parsedError = normalizeApiError(unknownError);
|
|
60
|
+
if (!isMountedRef.current) {
|
|
61
|
+
throw parsedError;
|
|
62
|
+
}
|
|
63
|
+
setError(parsedError);
|
|
64
|
+
setStatus('error');
|
|
65
|
+
callbacksRef.current.onError?.(parsedError, targetPage);
|
|
66
|
+
throw parsedError;
|
|
67
|
+
}
|
|
68
|
+
}, [applyResponse, create, isMountedRef]);
|
|
69
|
+
const refresh = useCallback(async () => {
|
|
70
|
+
setIsRefreshing(true);
|
|
71
|
+
setStatus('loading');
|
|
72
|
+
try {
|
|
73
|
+
await fetchPage(initialPage, true);
|
|
74
|
+
} finally {
|
|
75
|
+
if (isMountedRef.current) {
|
|
76
|
+
setIsRefreshing(false);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, [fetchPage, initialPage, isMountedRef]);
|
|
80
|
+
const loadMore = useCallback(async () => {
|
|
81
|
+
if (!hasMore || isLoadingMore || status === 'loading') {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
setIsLoadingMore(true);
|
|
85
|
+
try {
|
|
86
|
+
return await fetchPage(page + 1, false);
|
|
87
|
+
} finally {
|
|
88
|
+
if (isMountedRef.current) {
|
|
89
|
+
setIsLoadingMore(false);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, [fetchPage, hasMore, isLoadingMore, isMountedRef, page, status]);
|
|
93
|
+
const reset = useCallback(() => {
|
|
94
|
+
abort();
|
|
95
|
+
setItems([]);
|
|
96
|
+
setPage(initialPage);
|
|
97
|
+
setHasMore(true);
|
|
98
|
+
setTotal(undefined);
|
|
99
|
+
setError(null);
|
|
100
|
+
setStatus('idle');
|
|
101
|
+
setIsRefreshing(false);
|
|
102
|
+
setIsLoadingMore(false);
|
|
103
|
+
}, [abort, initialPage]);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!enabled) {
|
|
106
|
+
abort();
|
|
107
|
+
setStatus('idle');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
setStatus('loading');
|
|
111
|
+
fetchPage(initialPage, true).catch(() => undefined);
|
|
112
|
+
}, [abort, depsKey, enabled, fetchPage, initialPage]);
|
|
113
|
+
return {
|
|
114
|
+
items,
|
|
115
|
+
page,
|
|
116
|
+
hasMore,
|
|
117
|
+
total,
|
|
118
|
+
error,
|
|
119
|
+
isRefreshing,
|
|
120
|
+
isLoadingMore,
|
|
121
|
+
...getStatusFlags(status),
|
|
122
|
+
refresh,
|
|
123
|
+
loadMore,
|
|
124
|
+
reset
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=usePaginatedApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useState","getStatusFlags","isAbortError","normalizeApiError","useAbortControllerRef","useDependencyKey","useIsMounted","usePaginatedApi","fetcher","options","enabled","initialPage","deps","onSuccess","onError","items","setItems","page","setPage","hasMore","setHasMore","total","setTotal","undefined","error","setError","status","setStatus","isRefreshing","setIsRefreshing","isLoadingMore","setIsLoadingMore","fetcherRef","callbacksRef","isMountedRef","abort","create","depsKey","current","applyResponse","response","targetPage","replace","fetchPage","controller","signal","aborted","unknownError","parsedError","refresh","loadMore","reset","catch"],"sourceRoot":"../../../src","sources":["customHooks/usePaginatedApi.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;AAQnB,OAAO,MAAMC,eAAe,GAAGA,CAC7BC,OAAgC,EAChCC,OAA8C,GAAG,CAAC,CAAC,KAChD;EACH,MAAM;IACJC,OAAO,GAAG,IAAI;IACdC,WAAW,GAAG,CAAC;IACfC,IAAI,GAAG,EAAE;IACTC,SAAS;IACTC;EACF,CAAC,GAAGL,OAAO;EAEX,MAAM,CAACM,KAAK,EAAEC,QAAQ,CAAC,GAAGhB,QAAQ,CAAU,EAAE,CAAC;EAC/C,MAAM,CAACiB,IAAI,EAAEC,OAAO,CAAC,GAAGlB,QAAQ,CAACW,WAAW,CAAC;EAC7C,MAAM,CAACQ,OAAO,EAAEC,UAAU,CAAC,GAAGpB,QAAQ,CAAC,IAAI,CAAC;EAC5C,MAAM,CAACqB,KAAK,EAAEC,QAAQ,CAAC,GAAGtB,QAAQ,CAAqBuB,SAAS,CAAC;EACjE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGzB,QAAQ,CAAgB,IAAI,CAAC;EACvD,MAAM,CAAC0B,MAAM,EAAEC,SAAS,CAAC,GAAG3B,QAAQ,CAAYU,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;EAC7E,MAAM,CAACkB,YAAY,EAAEC,eAAe,CAAC,GAAG7B,QAAQ,CAAC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2
|
+
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { AppState } from 'react-native';
|
|
5
|
+
import { useApi } from "./useApi.js";
|
|
6
|
+
export const usePollingApi = (fetcher, options) => {
|
|
7
|
+
const {
|
|
8
|
+
intervalMs,
|
|
9
|
+
pollWhenHidden = false,
|
|
10
|
+
pauseOnError = true,
|
|
11
|
+
enabled = true,
|
|
12
|
+
...apiOptions
|
|
13
|
+
} = options;
|
|
14
|
+
const api = useApi(fetcher, {
|
|
15
|
+
...apiOptions,
|
|
16
|
+
enabled
|
|
17
|
+
});
|
|
18
|
+
const apiRef = useRef(api);
|
|
19
|
+
apiRef.current = api;
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!enabled || intervalMs <= 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (pauseOnError && api.isError) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const intervalId = setInterval(() => {
|
|
28
|
+
if (!pollWhenHidden && AppState.currentState !== 'active') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
apiRef.current.refetch().catch(() => {});
|
|
32
|
+
}, intervalMs);
|
|
33
|
+
return () => clearInterval(intervalId);
|
|
34
|
+
}, [api.isError, enabled, intervalMs, pauseOnError, pollWhenHidden]);
|
|
35
|
+
return api;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=usePollingApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","AppState","useApi","usePollingApi","fetcher","options","intervalMs","pollWhenHidden","pauseOnError","enabled","apiOptions","api","apiRef","current","isError","intervalId","setInterval","currentState","refetch","catch","clearInterval"],"sourceRoot":"../../../src","sources":["customHooks/usePollingApi.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,MAAM,QAAQ,aAAU;AAGjC,OAAO,MAAMC,aAAa,GAAGA,CAC3BC,OAA0B,EAC1BC,OAA4C,KACzC;EACH,MAAM;IACJC,UAAU;IACVC,cAAc,GAAG,KAAK;IACtBC,YAAY,GAAG,IAAI;IACnBC,OAAO,GAAG,IAAI;IACd,GAAGC;EACL,CAAC,GAAGL,OAAO;EAEX,MAAMM,GAAG,GAAGT,MAAM,CAAgBE,OAAO,EAAE;IACzC,GAAGM,UAAU;IACbD;EACF,CAAC,CAAC;EAEF,MAAMG,MAAM,GAAGZ,MAAM,CAACW,GAAG,CAAC;EAC1BC,MAAM,CAACC,OAAO,GAAGF,GAAG;EAEpBZ,SAAS,CAAC,MAAM;IACd,IAAI,CAACU,OAAO,IAAIH,UAAU,IAAI,CAAC,EAAE;MAC/B;IACF;IAEA,IAAIE,YAAY,IAAIG,GAAG,CAACG,OAAO,EAAE;MAC/B;IACF;IAEA,MAAMC,UAAU,GAAGC,WAAW,CAAC,MAAM;MACnC,IAAI,CAACT,cAAc,IAAIN,QAAQ,CAACgB,YAAY,KAAK,QAAQ,EAAE;QACzD;MACF;MAEAL,MAAM,CAACC,OAAO,CAACK,OAAO,CAAC,CAAC,CAACC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1C,CAAC,EAAEb,UAAU,CAAC;IAEd,OAAO,MAAMc,aAAa,CAACL,UAAU,CAAC;EACxC,CAAC,EAAE,CAACJ,GAAG,CAACG,OAAO,EAAEL,OAAO,EAAEH,UAAU,EAAEE,YAAY,EAAED,cAAc,CAAC,CAAC;EAEpE,OAAOI,GAAG;AACZ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { multiply } from "./multiply.js";
|
|
4
|
+
export * from "./customFunctions/index.js";
|
|
5
|
+
export * from "./customHooks/index.js";
|
|
6
|
+
export { default as CustomButton } from "./components/customButton/index.js";
|
|
7
|
+
export { default as CustomDropDown } from "./components/customDropDown/index.js";
|
|
8
|
+
export { default as CustomCheckbox } from "./components/CustomCheckbox/index.js";
|
|
9
|
+
export { default as CustomList, defaultKeyExtractor, getFlashList, isFlashListAvailable } from "./components/customList/index.js";
|
|
10
|
+
export { default as CustomNumberPad, applyNumberPadKey, useNumberPadInput, NUMBER_PAD_ROWS } from "./components/customNumberPad/index.js";
|
|
11
|
+
export { default as CustomModal, useCustomModal } from "./components/customModal/index.js";
|
|
12
|
+
export { default as CustomSlideTabs } from "./components/customSlideTabs/index.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["multiply","default","CustomButton","CustomDropDown","CustomCheckbox","CustomList","defaultKeyExtractor","getFlashList","isFlashListAvailable","CustomNumberPad","applyNumberPadKey","useNumberPadInput","NUMBER_PAD_ROWS","CustomModal","useCustomModal","CustomSlideTabs"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,eAAY;AACrC,cAAc,4BAAmB;AACjC,cAAc,wBAAe;AAC7B,SACEC,OAAO,IAAIC,YAAY,QAMlB,oCAA2B;AAClC,SACED,OAAO,IAAIE,cAAc,QAMpB,sCAA6B;AACpC,SACEF,OAAO,IAAIG,cAAc,QAMpB,sCAA6B;AACpC,SACEH,OAAO,IAAII,UAAU,EACrBC,mBAAmB,EACnBC,YAAY,EACZC,oBAAoB,QAGf,kCAAyB;AAChC,SACEP,OAAO,IAAIQ,eAAe,EAC1BC,iBAAiB,EACjBC,iBAAiB,EACjBC,eAAe,QAQV,uCAA8B;AACrC,SACEX,OAAO,IAAIY,WAAW,EACtBC,cAAc,QAIT,mCAA0B;AACjC,SACEb,OAAO,IAAIc,eAAe,QAMrB,uCAA8B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["multiply","a","b"],"sourceRoot":"../../src","sources":["multiply.tsx"],"mappings":";;AAAA,OAAO,SAASA,QAAQA,CAACC,CAAS,EAAEC,CAAS,EAAU;EACrD,OAAOD,CAAC,GAAGC,CAAC;AACd","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CustomCheckboxProps } from './types';
|
|
2
|
+
declare const CustomCheckbox: ({ checked, onChange, indeterminate, disabled, error, errorMessage, label, description, children, variant, size, shape, labelPosition, containerStyle, boxStyle, labelStyle, descriptionStyle, errorStyle, accessibilityLabel, }: CustomCheckboxProps) => import("react").JSX.Element;
|
|
3
|
+
export default CustomCheckbox;
|
|
4
|
+
export type { CheckboxLabelPosition, CheckboxShape, CheckboxSize, CheckboxVariant, CustomCheckboxProps, } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/CustomCheckbox/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,QAAA,MAAM,cAAc,GAAI,iOAoBrB,mBAAmB,gCA2GrB,CAAC;AAEF,eAAe,cAAc,CAAC;AAC9B,YAAY,EACV,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type TextStyle, type ViewStyle } from 'react-native';
|
|
2
|
+
import type { CheckboxShape, CheckboxSize, CheckboxVariant } from './types';
|
|
3
|
+
export declare const sizeStyles: Record<CheckboxSize, {
|
|
4
|
+
box: ViewStyle;
|
|
5
|
+
check: TextStyle;
|
|
6
|
+
indeterminate: ViewStyle;
|
|
7
|
+
label: TextStyle;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const shapeStyles: Record<CheckboxShape, ViewStyle>;
|
|
10
|
+
export declare const variantTheme: Record<CheckboxVariant, {
|
|
11
|
+
box: ViewStyle;
|
|
12
|
+
boxChecked: ViewStyle;
|
|
13
|
+
checkColor: string;
|
|
14
|
+
indeterminateColor: string;
|
|
15
|
+
label: TextStyle;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const styles: Readonly<{
|
|
18
|
+
wrapper: {
|
|
19
|
+
width: string;
|
|
20
|
+
};
|
|
21
|
+
container: {
|
|
22
|
+
flexDirection: "row";
|
|
23
|
+
alignItems: "flex-start";
|
|
24
|
+
width: string;
|
|
25
|
+
};
|
|
26
|
+
containerLabelLeft: {
|
|
27
|
+
flexDirection: "row-reverse";
|
|
28
|
+
justifyContent: "flex-end";
|
|
29
|
+
};
|
|
30
|
+
containerDisabled: {
|
|
31
|
+
opacity: number;
|
|
32
|
+
};
|
|
33
|
+
box: {
|
|
34
|
+
justifyContent: "center";
|
|
35
|
+
alignItems: "center";
|
|
36
|
+
};
|
|
37
|
+
labelBlock: {
|
|
38
|
+
flex: number;
|
|
39
|
+
marginHorizontal: number;
|
|
40
|
+
};
|
|
41
|
+
labelBlockRight: {
|
|
42
|
+
marginLeft: number;
|
|
43
|
+
marginRight: number;
|
|
44
|
+
};
|
|
45
|
+
labelBlockLeft: {
|
|
46
|
+
marginRight: number;
|
|
47
|
+
marginLeft: number;
|
|
48
|
+
};
|
|
49
|
+
label: {
|
|
50
|
+
fontWeight: "500";
|
|
51
|
+
};
|
|
52
|
+
description: {
|
|
53
|
+
marginTop: number;
|
|
54
|
+
fontSize: number;
|
|
55
|
+
lineHeight: number;
|
|
56
|
+
color: string;
|
|
57
|
+
};
|
|
58
|
+
errorMessage: {
|
|
59
|
+
marginTop: number;
|
|
60
|
+
fontSize: number;
|
|
61
|
+
color: string;
|
|
62
|
+
};
|
|
63
|
+
boxError: {
|
|
64
|
+
borderColor: string;
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/components/CustomCheckbox/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5E,eAAO,MAAM,UAAU,EAAE,MAAM,CAC7B,YAAY,EACZ;IACE,GAAG,EAAE,SAAS,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,SAAS,CAAC;IACzB,KAAK,EAAE,SAAS,CAAC;CAClB,CAoBF,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,aAAa,EAAE,SAAS,CAIxD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAC/B,eAAe,EACf;IACE,GAAG,EAAE,SAAS,CAAC;IACf,UAAU,EAAE,SAAS,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,SAAS,CAAC;CAClB,CA+CF,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiDjB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
export type CheckboxVariant = 'default' | 'primary' | 'success' | 'danger' | 'warning' | 'outline';
|
|
4
|
+
export type CheckboxSize = 'sm' | 'md' | 'lg';
|
|
5
|
+
export type CheckboxShape = 'square' | 'rounded' | 'circle';
|
|
6
|
+
export type CheckboxLabelPosition = 'left' | 'right';
|
|
7
|
+
export interface CustomCheckboxProps {
|
|
8
|
+
checked: boolean;
|
|
9
|
+
onChange?: (checked: boolean) => void;
|
|
10
|
+
indeterminate?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
error?: boolean;
|
|
13
|
+
errorMessage?: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
variant?: CheckboxVariant;
|
|
18
|
+
size?: CheckboxSize;
|
|
19
|
+
shape?: CheckboxShape;
|
|
20
|
+
labelPosition?: CheckboxLabelPosition;
|
|
21
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
22
|
+
boxStyle?: StyleProp<ViewStyle>;
|
|
23
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
24
|
+
descriptionStyle?: StyleProp<TextStyle>;
|
|
25
|
+
errorStyle?: StyleProp<TextStyle>;
|
|
26
|
+
accessibilityLabel?: string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/CustomCheckbox/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,MAAM,eAAe,GACzB,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAEvE,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5D,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,OAAO,CAAC;AAErD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,gBAAgB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/closeButton/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,QAAA,MAAM,WAAW,GAAI,sDAKlB,gBAAgB,gCAiBlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ImageSourcePropType, ImageStyle, StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
export interface CloseButtonProps {
|
|
3
|
+
onPress?: () => void;
|
|
4
|
+
imageStyle?: StyleProp<ImageStyle>;
|
|
5
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
6
|
+
closeImage?: ImageSourcePropType;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/closeButton/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IACnC,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,mBAAmB,CAAC;CAClC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CustomButtonProps } from './types';
|
|
2
|
+
declare const CustomButton: ({ text, children, variant, size, contentAlign, iconOnly, iconOnlyShape, rightImage, leftImage, style, buttonStyles, textStyles, opacity, onPress, imageStyles, imageOuterStyle, rotateRight, rotateLeft, disabled, isLoading, itemCount, showCount, isCapital, borderRadius, RightIcon, LeftIcon, rightIconColor, leftIconColor, rightIconSize, leftIconSize, rightIconProps, leftIconProps, accessibilityRole, accessibilityLabel, accessibilityState, ...touchableProps }: CustomButtonProps) => import("react").JSX.Element;
|
|
3
|
+
export default CustomButton;
|
|
4
|
+
export type { ButtonContentAlign, ButtonSize, ButtonVariant, CustomButtonProps, IconOnlyShape, } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/customButton/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAajD,QAAA,MAAM,YAAY,GAAI,6cAqCnB,iBAAiB,gCA2NnB,CAAC;AAEF,eAAe,YAAY,CAAC;AAC5B,YAAY,EACV,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,aAAa,GACd,MAAM,SAAS,CAAC"}
|