@estuary-solutions/rn-core-ui 0.0.3
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 +743 -0
- package/dist/Accordion/Accordion.d.ts +5 -0
- package/dist/Accordion/Accordion.d.ts.map +1 -0
- package/dist/Accordion/Accordion.js +19 -0
- package/dist/Accordion/AccordionContext.d.ts +7 -0
- package/dist/Accordion/AccordionContext.d.ts.map +1 -0
- package/dist/Accordion/AccordionContext.js +3 -0
- package/dist/Accordion/AccordionGroup.d.ts +7 -0
- package/dist/Accordion/AccordionGroup.d.ts.map +1 -0
- package/dist/Accordion/AccordionGroup.js +32 -0
- package/dist/Accordion/AccordionItem.d.ts +5 -0
- package/dist/Accordion/AccordionItem.d.ts.map +1 -0
- package/dist/Accordion/AccordionItem.js +12 -0
- package/dist/Accordion/AccordionTree.d.ts +6 -0
- package/dist/Accordion/AccordionTree.d.ts.map +1 -0
- package/dist/Accordion/AccordionTree.js +4 -0
- package/dist/Accordion/AccordionTreeInternal.d.ts +5 -0
- package/dist/Accordion/AccordionTreeInternal.d.ts.map +1 -0
- package/dist/Accordion/AccordionTreeInternal.js +36 -0
- package/dist/Accordion/AccordionTreeWithGroup.d.ts +8 -0
- package/dist/Accordion/AccordionTreeWithGroup.d.ts.map +1 -0
- package/dist/Accordion/AccordionTreeWithGroup.js +11 -0
- package/dist/Accordion/index.d.ts +5 -0
- package/dist/Accordion/index.d.ts.map +1 -0
- package/dist/Accordion/index.js +4 -0
- package/dist/Accordion/types/AccordionTypes.d.ts +65 -0
- package/dist/Accordion/types/AccordionTypes.d.ts.map +1 -0
- package/dist/Accordion/types/AccordionTypes.js +1 -0
- package/dist/Avatars/Avatar.d.ts +20 -0
- package/dist/Avatars/Avatar.d.ts.map +1 -0
- package/dist/Avatars/Avatar.js +63 -0
- package/dist/Badges/Badge.d.ts +25 -0
- package/dist/Badges/Badge.d.ts.map +1 -0
- package/dist/Badges/Badge.js +75 -0
- package/dist/Breadcrumbs/Breadcrumb.d.ts +13 -0
- package/dist/Breadcrumbs/Breadcrumb.d.ts.map +1 -0
- package/dist/Breadcrumbs/Breadcrumb.js +63 -0
- package/dist/Button/Button.d.ts +7 -0
- package/dist/Button/Button.d.ts.map +1 -0
- package/dist/Button/Button.js +62 -0
- package/dist/Button/ButtonGradient.d.ts +5 -0
- package/dist/Button/ButtonGradient.d.ts.map +1 -0
- package/dist/Button/ButtonGradient.js +61 -0
- package/dist/Button/index.d.ts +4 -0
- package/dist/Button/index.d.ts.map +1 -0
- package/dist/Button/index.js +3 -0
- package/dist/Button/types/ButtonGradientTypes.d.ts +80 -0
- package/dist/Button/types/ButtonGradientTypes.d.ts.map +1 -0
- package/dist/Button/types/ButtonGradientTypes.js +1 -0
- package/dist/Button/types/ButtonTypes.d.ts +65 -0
- package/dist/Button/types/ButtonTypes.d.ts.map +1 -0
- package/dist/Button/types/ButtonTypes.js +1 -0
- package/dist/Buttons/Button.d.ts +23 -0
- package/dist/Buttons/Button.d.ts.map +1 -0
- package/dist/Buttons/Button.js +66 -0
- package/dist/Cards/Card.d.ts +22 -0
- package/dist/Cards/Card.d.ts.map +1 -0
- package/dist/Cards/Card.js +26 -0
- package/dist/Cards/CardActionArea.d.ts +13 -0
- package/dist/Cards/CardActionArea.d.ts.map +1 -0
- package/dist/Cards/CardActionArea.js +30 -0
- package/dist/Cards/CardActions.d.ts +14 -0
- package/dist/Cards/CardActions.d.ts.map +1 -0
- package/dist/Cards/CardActions.js +41 -0
- package/dist/Cards/CardContent.d.ts +13 -0
- package/dist/Cards/CardContent.d.ts.map +1 -0
- package/dist/Cards/CardContent.js +19 -0
- package/dist/Cards/CardHeader.d.ts +16 -0
- package/dist/Cards/CardHeader.d.ts.map +1 -0
- package/dist/Cards/CardHeader.js +61 -0
- package/dist/Cards/CardMedia.d.ts +23 -0
- package/dist/Cards/CardMedia.d.ts.map +1 -0
- package/dist/Cards/CardMedia.js +16 -0
- package/dist/Cards/Paper.d.ts +13 -0
- package/dist/Cards/Paper.d.ts.map +1 -0
- package/dist/Cards/Paper.js +42 -0
- package/dist/DraggableFlatList/CellDecorators.d.ts +21 -0
- package/dist/DraggableFlatList/CellDecorators.d.ts.map +1 -0
- package/dist/DraggableFlatList/CellDecorators.js +66 -0
- package/dist/DraggableFlatList/CellRendererComponent.d.ts +20 -0
- package/dist/DraggableFlatList/CellRendererComponent.d.ts.map +1 -0
- package/dist/DraggableFlatList/CellRendererComponent.js +146 -0
- package/dist/DraggableFlatList/DraggableFlatList.d.ts +9 -0
- package/dist/DraggableFlatList/DraggableFlatList.d.ts.map +1 -0
- package/dist/DraggableFlatList/DraggableFlatList.js +282 -0
- package/dist/DraggableFlatList/DraggableFlatList.web.d.ts +4 -0
- package/dist/DraggableFlatList/DraggableFlatList.web.d.ts.map +1 -0
- package/dist/DraggableFlatList/DraggableFlatList.web.js +248 -0
- package/dist/DraggableFlatList/NestableDraggableFlatList.d.ts +9 -0
- package/dist/DraggableFlatList/NestableDraggableFlatList.d.ts.map +1 -0
- package/dist/DraggableFlatList/NestableDraggableFlatList.js +66 -0
- package/dist/DraggableFlatList/NestableScrollContainer.d.ts +5 -0
- package/dist/DraggableFlatList/NestableScrollContainer.d.ts.map +1 -0
- package/dist/DraggableFlatList/NestableScrollContainer.js +28 -0
- package/dist/DraggableFlatList/PlaceholderItem.d.ts +8 -0
- package/dist/DraggableFlatList/PlaceholderItem.d.ts.map +1 -0
- package/dist/DraggableFlatList/PlaceholderItem.js +44 -0
- package/dist/DraggableFlatList/RowItem.d.ts +13 -0
- package/dist/DraggableFlatList/RowItem.d.ts.map +1 -0
- package/dist/DraggableFlatList/RowItem.js +45 -0
- package/dist/DraggableFlatList/ScrollOffsetListener.d.ts +8 -0
- package/dist/DraggableFlatList/ScrollOffsetListener.d.ts.map +1 -0
- package/dist/DraggableFlatList/ScrollOffsetListener.js +13 -0
- package/dist/Flex/Flex.d.ts +12 -0
- package/dist/Flex/Flex.d.ts.map +1 -0
- package/dist/Flex/Flex.js +28 -0
- package/dist/Flex/Flex.types.d.ts +10 -0
- package/dist/Flex/Flex.types.d.ts.map +1 -0
- package/dist/Flex/Flex.types.js +1 -0
- package/dist/Flex/index.d.ts +4 -0
- package/dist/Flex/index.d.ts.map +1 -0
- package/dist/Flex/index.js +3 -0
- package/dist/LICENSE +20 -0
- package/dist/README.md +743 -0
- package/dist/SvgIcon/SvgIcon.d.ts +9 -0
- package/dist/SvgIcon/SvgIcon.d.ts.map +1 -0
- package/dist/SvgIcon/SvgIcon.js +39 -0
- package/dist/SvgIcon/components/IconAlertCircle.d.ts +4 -0
- package/dist/SvgIcon/components/IconAlertCircle.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconAlertCircle.js +6 -0
- package/dist/SvgIcon/components/IconAngleLeft.d.ts +4 -0
- package/dist/SvgIcon/components/IconAngleLeft.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconAngleLeft.js +6 -0
- package/dist/SvgIcon/components/IconAngleRight.d.ts +4 -0
- package/dist/SvgIcon/components/IconAngleRight.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconAngleRight.js +6 -0
- package/dist/SvgIcon/components/IconCheckBox.d.ts +4 -0
- package/dist/SvgIcon/components/IconCheckBox.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconCheckBox.js +6 -0
- package/dist/SvgIcon/components/IconCheckBoxOutlineBlank.d.ts +4 -0
- package/dist/SvgIcon/components/IconCheckBoxOutlineBlank.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconCheckBoxOutlineBlank.js +6 -0
- package/dist/SvgIcon/components/IconCheckBoxWithBg.d.ts +4 -0
- package/dist/SvgIcon/components/IconCheckBoxWithBg.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconCheckBoxWithBg.js +6 -0
- package/dist/SvgIcon/components/IconChevronDown.d.ts +4 -0
- package/dist/SvgIcon/components/IconChevronDown.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconChevronDown.js +6 -0
- package/dist/SvgIcon/components/IconChevronUp.d.ts +4 -0
- package/dist/SvgIcon/components/IconChevronUp.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconChevronUp.js +6 -0
- package/dist/SvgIcon/components/IconHome.d.ts +4 -0
- package/dist/SvgIcon/components/IconHome.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconHome.js +6 -0
- package/dist/SvgIcon/components/IconPerson.d.ts +4 -0
- package/dist/SvgIcon/components/IconPerson.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconPerson.js +6 -0
- package/dist/SvgIcon/components/IconPlayCircle.d.ts +4 -0
- package/dist/SvgIcon/components/IconPlayCircle.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconPlayCircle.js +9 -0
- package/dist/SvgIcon/components/IconPlus.d.ts +4 -0
- package/dist/SvgIcon/components/IconPlus.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconPlus.js +6 -0
- package/dist/SvgIcon/components/index.d.ts +13 -0
- package/dist/SvgIcon/components/index.d.ts.map +1 -0
- package/dist/SvgIcon/components/index.js +12 -0
- package/dist/SvgIcon/types/SvgIconTypes.d.ts +46 -0
- package/dist/SvgIcon/types/SvgIconTypes.d.ts.map +1 -0
- package/dist/SvgIcon/types/SvgIconTypes.js +1 -0
- package/dist/TextFields/TextField.d.ts +34 -0
- package/dist/TextFields/TextField.d.ts.map +1 -0
- package/dist/TextFields/TextField.js +400 -0
- package/dist/TextFields/index.d.ts +2 -0
- package/dist/TextFields/index.d.ts.map +1 -0
- package/dist/TextFields/index.js +1 -0
- package/dist/Texts/Text.d.ts +21 -0
- package/dist/Texts/Text.d.ts.map +1 -0
- package/dist/Texts/Text.js +49 -0
- package/dist/constants/DraggableFlatList/constants.d.ts +28 -0
- package/dist/constants/DraggableFlatList/constants.d.ts.map +1 -0
- package/dist/constants/DraggableFlatList/constants.js +25 -0
- package/dist/constants/DraggableFlatList/types.d.ts +65 -0
- package/dist/constants/DraggableFlatList/types.d.ts.map +1 -0
- package/dist/constants/DraggableFlatList/types.js +1 -0
- package/dist/constants/DraggableFlatList/types.web.d.ts +7 -0
- package/dist/constants/DraggableFlatList/types.web.d.ts.map +1 -0
- package/dist/constants/DraggableFlatList/types.web.js +1 -0
- package/dist/constants/consts.d.ts +16 -0
- package/dist/constants/consts.d.ts.map +1 -0
- package/dist/constants/consts.js +15 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +2 -0
- package/dist/constants/types.d.ts +22 -0
- package/dist/constants/types.d.ts.map +1 -0
- package/dist/constants/types.js +21 -0
- package/dist/context/DraggableFlatList/animatedValueContext.d.ts +29 -0
- package/dist/context/DraggableFlatList/animatedValueContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/animatedValueContext.js +154 -0
- package/dist/context/DraggableFlatList/cellContext.d.ts +10 -0
- package/dist/context/DraggableFlatList/cellContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/cellContext.js +18 -0
- package/dist/context/DraggableFlatList/draggableFlatListContext.d.ts +13 -0
- package/dist/context/DraggableFlatList/draggableFlatListContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/draggableFlatListContext.js +19 -0
- package/dist/context/DraggableFlatList/nestableScrollContainerContext.d.ts +23 -0
- package/dist/context/DraggableFlatList/nestableScrollContainerContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/nestableScrollContainerContext.js +36 -0
- package/dist/context/DraggableFlatList/propsContext.d.ts +9 -0
- package/dist/context/DraggableFlatList/propsContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/propsContext.js +25 -0
- package/dist/context/DraggableFlatList/refContext.d.ts +20 -0
- package/dist/context/DraggableFlatList/refContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/refContext.js +55 -0
- package/dist/hooks/DraggableFlatList/useAutoScroll.d.ts +2 -0
- package/dist/hooks/DraggableFlatList/useAutoScroll.d.ts.map +1 -0
- package/dist/hooks/DraggableFlatList/useAutoScroll.js +77 -0
- package/dist/hooks/DraggableFlatList/useCellTranslate.d.ts +9 -0
- package/dist/hooks/DraggableFlatList/useCellTranslate.d.ts.map +1 -0
- package/dist/hooks/DraggableFlatList/useCellTranslate.js +72 -0
- package/dist/hooks/DraggableFlatList/useNestedAutoScroll.d.ts +12 -0
- package/dist/hooks/DraggableFlatList/useNestedAutoScroll.d.ts.map +1 -0
- package/dist/hooks/DraggableFlatList/useNestedAutoScroll.js +77 -0
- package/dist/hooks/DraggableFlatList/useOnCellActiveAnimation.d.ts +15 -0
- package/dist/hooks/DraggableFlatList/useOnCellActiveAnimation.d.ts.map +1 -0
- package/dist/hooks/DraggableFlatList/useOnCellActiveAnimation.js +29 -0
- package/dist/hooks/DraggableFlatList/useStableCallback.d.ts +2 -0
- package/dist/hooks/DraggableFlatList/useStableCallback.d.ts.map +1 -0
- package/dist/hooks/DraggableFlatList/useStableCallback.js +11 -0
- package/dist/hooks/useTheme.d.ts +17 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/hooks/useTheme.js +12 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/themes/colors.d.ts +9 -0
- package/dist/themes/colors.d.ts.map +1 -0
- package/dist/themes/colors.js +201 -0
- package/dist/themes/elevationOverlay.d.ts +2 -0
- package/dist/themes/elevationOverlay.d.ts.map +1 -0
- package/dist/themes/elevationOverlay.js +12 -0
- package/dist/themes/fontSize.d.ts +23 -0
- package/dist/themes/fontSize.d.ts.map +1 -0
- package/dist/themes/fontSize.js +22 -0
- package/dist/themes/index.d.ts +5 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/index.js +4 -0
- package/dist/themes/types/colorTypes.d.ts +665 -0
- package/dist/themes/types/colorTypes.d.ts.map +1 -0
- package/dist/themes/types/colorTypes.js +1 -0
- package/dist/utils/DraggableFlatList/typedMemo.d.ts +2 -0
- package/dist/utils/DraggableFlatList/typedMemo.d.ts.map +1 -0
- package/dist/utils/DraggableFlatList/typedMemo.js +2 -0
- package/dist/utils/cleanTagHTML.d.ts +22 -0
- package/dist/utils/cleanTagHTML.d.ts.map +1 -0
- package/dist/utils/cleanTagHTML.js +36 -0
- package/dist/utils/colors/color.d.ts +2 -0
- package/dist/utils/colors/color.d.ts.map +1 -0
- package/dist/utils/colors/color.js +6 -0
- package/dist/utils/colors/elevation.d.ts +7 -0
- package/dist/utils/colors/elevation.d.ts.map +1 -0
- package/dist/utils/colors/elevation.js +29 -0
- package/dist/utils/colors/index.d.ts +9 -0
- package/dist/utils/colors/index.d.ts.map +1 -0
- package/dist/utils/colors/index.js +7 -0
- package/dist/utils/converter.d.ts +47 -0
- package/dist/utils/converter.d.ts.map +1 -0
- package/dist/utils/converter.js +54 -0
- package/dist/utils/debounce.d.ts +36 -0
- package/dist/utils/debounce.d.ts.map +1 -0
- package/dist/utils/debounce.js +54 -0
- package/dist/utils/filters.d.ts +3 -0
- package/dist/utils/filters.d.ts.map +1 -0
- package/dist/utils/filters.js +10 -0
- package/dist/utils/fixedDistance.d.ts +16 -0
- package/dist/utils/fixedDistance.d.ts.map +1 -0
- package/dist/utils/fixedDistance.js +17 -0
- package/dist/utils/formatMoney.d.ts +30 -0
- package/dist/utils/formatMoney.d.ts.map +1 -0
- package/dist/utils/formatMoney.js +33 -0
- package/dist/utils/getOS.d.ts +6 -0
- package/dist/utils/getOS.d.ts.map +1 -0
- package/dist/utils/getOS.js +6 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/limitedString.d.ts +15 -0
- package/dist/utils/limitedString.d.ts.map +1 -0
- package/dist/utils/limitedString.js +19 -0
- package/dist/utils/resolutions.d.ts +65 -0
- package/dist/utils/resolutions.d.ts.map +1 -0
- package/dist/utils/resolutions.js +79 -0
- package/dist/utils/scale.d.ts +141 -0
- package/dist/utils/scale.d.ts.map +1 -0
- package/dist/utils/scale.js +141 -0
- package/documents/build.js +102 -0
- package/documents/buildFromRoot.js +49 -0
- package/documents/buildFromSample.js +40 -0
- package/documents/buildV2.js +98 -0
- package/documents/copyPackageToExample.js +31 -0
- package/example/RNCoreUISample/.eslintrc.js +10 -0
- package/example/RNCoreUISample/.prettierrc.js +7 -0
- package/example/RNCoreUISample/App.js +26 -0
- package/example/RNCoreUISample/README.md +104 -0
- package/example/RNCoreUISample/android/app/debug.keystore +0 -0
- package/example/RNCoreUISample/babel.config.js +29 -0
- package/example/RNCoreUISample/documents/storybook/manager.js +5 -0
- package/example/RNCoreUISample/fix_node_modules.js +12 -0
- package/example/RNCoreUISample/index.js +20 -0
- package/example/RNCoreUISample/jest.config.js +3 -0
- package/example/RNCoreUISample/metro.config.js +30 -0
- package/package.json +101 -0
- package/src/constants/DraggableFlatList/draggable.d.ts +12 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { View, TextInput, StyleSheet, Animated, Easing, } from 'react-native';
|
|
15
|
+
import { colors, fontSize } from '../themes';
|
|
16
|
+
import { WEB } from '../utils';
|
|
17
|
+
import Text from '../Texts/Text';
|
|
18
|
+
const DEFAULT_ROWS = 3;
|
|
19
|
+
const DEFAULT_MARGIN_TOP = 6;
|
|
20
|
+
const DEFAULT_PADDING = 12;
|
|
21
|
+
const DISABLED_COLOR = colors.disabled;
|
|
22
|
+
const FOCUSED_COLOR = colors.primary;
|
|
23
|
+
const ERROR_COLOR = colors.error;
|
|
24
|
+
const DEFAULT_COLOR = colors.gray_D1D2D4;
|
|
25
|
+
const MIN_HEIGHT = 48;
|
|
26
|
+
const TextField = (_a) => {
|
|
27
|
+
var { label, labelMinSize = fontSize._12, labelSize = fontSize._14, applyTopLabel = true, labelBackground, value, defaultValue, onChangeText, error, errorColor, focusedColor, helperText, helperTextColor, helperTextStyle, renderStartIcon, renderEndIcon, multiline = false, rows = DEFAULT_ROWS, maxRows, editable = true, containerStyle, inputContainerStyle, style, onFocus, onBlur } = _a, rest = __rest(_a, ["label", "labelMinSize", "labelSize", "applyTopLabel", "labelBackground", "value", "defaultValue", "onChangeText", "error", "errorColor", "focusedColor", "helperText", "helperTextColor", "helperTextStyle", "renderStartIcon", "renderEndIcon", "multiline", "rows", "maxRows", "editable", "containerStyle", "inputContainerStyle", "style", "onFocus", "onBlur"]);
|
|
28
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
|
|
29
|
+
const [focused, setFocused] = React.useState(false);
|
|
30
|
+
const [containerWidth, setContainerWidth] = React.useState(0);
|
|
31
|
+
const [containerHeight, setContainerHeight] = React.useState(0);
|
|
32
|
+
const [labelHeight, setLabelHeight] = React.useState(0);
|
|
33
|
+
const [helperHeight, setHelperHeight] = React.useState(0);
|
|
34
|
+
const [contentHeight, setContentHeight] = React.useState(null);
|
|
35
|
+
const [startIconWidth, setStartIconWidth] = React.useState(0);
|
|
36
|
+
const [endIconWidth, setEndIconWidth] = React.useState(0);
|
|
37
|
+
const [webInputHeight, setWebInputHeight] = React.useState();
|
|
38
|
+
const inputRef = React.useRef(null); //Handling dragging on Web
|
|
39
|
+
const isApplyStartIcon = typeof renderStartIcon === 'function';
|
|
40
|
+
const isApplyEndIcon = typeof renderEndIcon === 'function';
|
|
41
|
+
const labelMaxWidth = containerWidth -
|
|
42
|
+
(isApplyStartIcon ? startIconWidth : 0) -
|
|
43
|
+
(isApplyEndIcon ? endIconWidth : 0) -
|
|
44
|
+
DEFAULT_PADDING * 2;
|
|
45
|
+
const isControlled = value !== undefined;
|
|
46
|
+
const textValue = isControlled ? value : internalValue;
|
|
47
|
+
const hasError = Boolean(error);
|
|
48
|
+
const errorMessage = typeof error === 'string' ? error : undefined;
|
|
49
|
+
const floatAnim = React.useRef(new Animated.Value(textValue ? 1 : 0)).current;
|
|
50
|
+
const handleChange = React.useCallback((text) => {
|
|
51
|
+
if (!isControlled) {
|
|
52
|
+
setInternalValue(text);
|
|
53
|
+
}
|
|
54
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(text);
|
|
55
|
+
}, [isControlled, onChangeText]);
|
|
56
|
+
const handleHideTopLabel = () => {
|
|
57
|
+
if (applyTopLabel) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return floatAnim.interpolate({
|
|
61
|
+
inputRange: [0, 1],
|
|
62
|
+
outputRange: [1, 0],
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const resolvePaddingSide = (rawStyle, isTop) => {
|
|
66
|
+
const style = StyleSheet.flatten(rawStyle);
|
|
67
|
+
const side = isTop ? 'paddingTop' : 'paddingBottom';
|
|
68
|
+
if (typeof (style === null || style === void 0 ? void 0 : style.paddingVertical) === 'number') {
|
|
69
|
+
return style.paddingVertical;
|
|
70
|
+
}
|
|
71
|
+
if (typeof (style === null || style === void 0 ? void 0 : style.padding) === 'number') {
|
|
72
|
+
return style.padding;
|
|
73
|
+
}
|
|
74
|
+
if (typeof (style === null || style === void 0 ? void 0 : style[side]) === 'number') {
|
|
75
|
+
return style[side];
|
|
76
|
+
}
|
|
77
|
+
return 0;
|
|
78
|
+
};
|
|
79
|
+
const resolvePadding = (userStyle, fallbackStyle, isTop) => {
|
|
80
|
+
const userPadding = resolvePaddingSide(userStyle, isTop);
|
|
81
|
+
if (userPadding !== 0)
|
|
82
|
+
return userPadding;
|
|
83
|
+
return resolvePaddingSide(fallbackStyle, isTop);
|
|
84
|
+
};
|
|
85
|
+
const calculatePadding = (isTop) => {
|
|
86
|
+
const containerPadding = resolvePadding(containerStyle, styles.container, isTop);
|
|
87
|
+
const inputPadding = resolvePadding(inputContainerStyle, styles.inputContainer, isTop);
|
|
88
|
+
const textInputPadding = resolvePadding(style, styles.input, isTop);
|
|
89
|
+
return containerPadding + inputPadding + textInputPadding;
|
|
90
|
+
};
|
|
91
|
+
const getInsetY = (alignVertical) => {
|
|
92
|
+
switch (alignVertical) {
|
|
93
|
+
case 'center':
|
|
94
|
+
return containerHeight / 2 - labelHeight;
|
|
95
|
+
case 'bottom':
|
|
96
|
+
return containerHeight - helperHeight - DEFAULT_MARGIN_TOP - labelHeight - calculatePadding(false);
|
|
97
|
+
case 'top':
|
|
98
|
+
default:
|
|
99
|
+
return calculatePadding(true);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const resolveTextAlignVertical = () => {
|
|
103
|
+
var _a;
|
|
104
|
+
const textInputStyle = StyleSheet.flatten(style);
|
|
105
|
+
if (WEB) { //Web only support textAlignVertical top
|
|
106
|
+
return 'top';
|
|
107
|
+
}
|
|
108
|
+
return (_a = textInputStyle === null || textInputStyle === void 0 ? void 0 : textInputStyle.textAlignVertical) !== null && _a !== void 0 ? _a : 'top';
|
|
109
|
+
};
|
|
110
|
+
const textAlignVertical = resolveTextAlignVertical();
|
|
111
|
+
const multilineStyle = React.useMemo(() => {
|
|
112
|
+
if (!multiline || !contentHeight) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const padding = resolvePadding(style, styles.input, true) +
|
|
116
|
+
resolvePadding(style, styles.input, false);
|
|
117
|
+
return {
|
|
118
|
+
minHeight: rows ? rows * (contentHeight - (WEB ? padding * 1.9 : padding / 1.3)) : undefined,
|
|
119
|
+
maxHeight: maxRows ? maxRows * (contentHeight - padding / 1.1) : undefined, // maxHeight not work for auto add new line with maxRows on Web. Use height instead.
|
|
120
|
+
};
|
|
121
|
+
}, [multiline, rows, maxRows, contentHeight]);
|
|
122
|
+
const multilineWebStyle = React.useMemo(() => {
|
|
123
|
+
if (!multiline || !WEB || !contentHeight || !webInputHeight) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
const padding = resolvePadding(style, styles.input, true) +
|
|
127
|
+
resolvePadding(style, styles.input, false);
|
|
128
|
+
const minHeight = rows ? rows * (contentHeight - padding * 1.9) : 0;
|
|
129
|
+
const maxHeight = maxRows ? maxRows * (contentHeight - padding * 1.9) : 0;
|
|
130
|
+
if (webInputHeight > maxHeight) {
|
|
131
|
+
return {
|
|
132
|
+
height: maxHeight
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (webInputHeight > minHeight && webInputHeight <= maxHeight) {
|
|
136
|
+
return {
|
|
137
|
+
height: webInputHeight
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}, [multiline, rows, maxRows, contentHeight, webInputHeight]);
|
|
142
|
+
const labelInsetY = React.useMemo(() => getInsetY(textAlignVertical), [
|
|
143
|
+
textAlignVertical,
|
|
144
|
+
style,
|
|
145
|
+
inputContainerStyle,
|
|
146
|
+
containerStyle,
|
|
147
|
+
containerHeight,
|
|
148
|
+
helperHeight,
|
|
149
|
+
labelHeight
|
|
150
|
+
]);
|
|
151
|
+
const renderBackgroundLabel = () => {
|
|
152
|
+
if (labelBackground) {
|
|
153
|
+
return labelBackground;
|
|
154
|
+
}
|
|
155
|
+
if (!editable) {
|
|
156
|
+
return DISABLED_COLOR;
|
|
157
|
+
}
|
|
158
|
+
return colors.white;
|
|
159
|
+
};
|
|
160
|
+
const renderLabelColor = () => {
|
|
161
|
+
if (hasError) {
|
|
162
|
+
if (errorColor) {
|
|
163
|
+
return errorColor;
|
|
164
|
+
}
|
|
165
|
+
return ERROR_COLOR;
|
|
166
|
+
}
|
|
167
|
+
if (focused) {
|
|
168
|
+
if (focusedColor) {
|
|
169
|
+
return focusedColor;
|
|
170
|
+
}
|
|
171
|
+
return FOCUSED_COLOR;
|
|
172
|
+
}
|
|
173
|
+
return DEFAULT_COLOR;
|
|
174
|
+
};
|
|
175
|
+
const renderInputBorderColor = () => {
|
|
176
|
+
if (hasError) {
|
|
177
|
+
if (errorColor) {
|
|
178
|
+
return errorColor;
|
|
179
|
+
}
|
|
180
|
+
return ERROR_COLOR;
|
|
181
|
+
}
|
|
182
|
+
if (focused) {
|
|
183
|
+
if (focusedColor) {
|
|
184
|
+
return focusedColor;
|
|
185
|
+
}
|
|
186
|
+
return FOCUSED_COLOR;
|
|
187
|
+
}
|
|
188
|
+
return DEFAULT_COLOR;
|
|
189
|
+
};
|
|
190
|
+
const renderHelperTextColor = () => {
|
|
191
|
+
if (helperTextColor) {
|
|
192
|
+
return helperTextColor;
|
|
193
|
+
}
|
|
194
|
+
if (hasError) {
|
|
195
|
+
if (errorColor) {
|
|
196
|
+
return errorColor;
|
|
197
|
+
}
|
|
198
|
+
return ERROR_COLOR;
|
|
199
|
+
}
|
|
200
|
+
if (!editable) {
|
|
201
|
+
return DEFAULT_COLOR;
|
|
202
|
+
}
|
|
203
|
+
return colors.black;
|
|
204
|
+
};
|
|
205
|
+
const labelViewStyle = {
|
|
206
|
+
position: 'absolute',
|
|
207
|
+
left: isApplyStartIcon ? startIconWidth + DEFAULT_PADDING : DEFAULT_PADDING,
|
|
208
|
+
top: applyTopLabel ? floatAnim.interpolate({
|
|
209
|
+
inputRange: [0, 1],
|
|
210
|
+
outputRange: [labelInsetY, -labelMinSize / 1.5],
|
|
211
|
+
}) : labelInsetY,
|
|
212
|
+
maxWidth: labelMaxWidth,
|
|
213
|
+
overflow: 'hidden',
|
|
214
|
+
backgroundColor: renderBackgroundLabel(),
|
|
215
|
+
paddingHorizontal: DEFAULT_PADDING,
|
|
216
|
+
opacity: handleHideTopLabel(),
|
|
217
|
+
borderRadius: 5
|
|
218
|
+
};
|
|
219
|
+
const labelStyle = {
|
|
220
|
+
fontSize: applyTopLabel ? floatAnim.interpolate({
|
|
221
|
+
inputRange: [0, 1],
|
|
222
|
+
outputRange: [labelSize, labelMinSize],
|
|
223
|
+
}) : labelSize,
|
|
224
|
+
color: renderLabelColor(),
|
|
225
|
+
};
|
|
226
|
+
React.useEffect(() => {
|
|
227
|
+
Animated.timing(floatAnim, {
|
|
228
|
+
toValue: focused || textValue ? 1 : 0,
|
|
229
|
+
duration: 180,
|
|
230
|
+
easing: Easing.out(Easing.ease),
|
|
231
|
+
useNativeDriver: false,
|
|
232
|
+
}).start();
|
|
233
|
+
}, [focused, textValue, floatAnim]);
|
|
234
|
+
React.useEffect(() => {
|
|
235
|
+
if (!WEB || !multiline) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
const el = inputRef.current;
|
|
239
|
+
if (!el) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
let isDragging = false;
|
|
243
|
+
let startY = 0;
|
|
244
|
+
let startScrollTop = 0;
|
|
245
|
+
const onMouseDown = (e) => {
|
|
246
|
+
isDragging = true;
|
|
247
|
+
startY = e.clientY;
|
|
248
|
+
startScrollTop = el.scrollTop;
|
|
249
|
+
};
|
|
250
|
+
const onMouseMove = (e) => {
|
|
251
|
+
if (!isDragging) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
el.scrollTop = startScrollTop - (e.clientY - startY);
|
|
255
|
+
};
|
|
256
|
+
const onMouseUp = () => {
|
|
257
|
+
isDragging = false;
|
|
258
|
+
};
|
|
259
|
+
el.addEventListener('mousedown', onMouseDown);
|
|
260
|
+
window.addEventListener('mousemove', onMouseMove);
|
|
261
|
+
window.addEventListener('mouseup', onMouseUp);
|
|
262
|
+
return () => {
|
|
263
|
+
el.removeEventListener('mousedown', onMouseDown);
|
|
264
|
+
window.removeEventListener('mousemove', onMouseMove);
|
|
265
|
+
window.removeEventListener('mouseup', onMouseUp);
|
|
266
|
+
};
|
|
267
|
+
}, [multiline]);
|
|
268
|
+
const multilineStyleSignature = React.useMemo(() => {
|
|
269
|
+
if (!style)
|
|
270
|
+
return '';
|
|
271
|
+
const s = Array.isArray(style)
|
|
272
|
+
? Object.assign({}, ...style)
|
|
273
|
+
: style;
|
|
274
|
+
return [
|
|
275
|
+
s.minHeight,
|
|
276
|
+
s.maxHeight,
|
|
277
|
+
s.paddingTop,
|
|
278
|
+
s.paddingBottom,
|
|
279
|
+
s.lineHeight,
|
|
280
|
+
s.fontSize,
|
|
281
|
+
].join('|');
|
|
282
|
+
}, [style]);
|
|
283
|
+
React.useEffect(() => {
|
|
284
|
+
let timeoutID;
|
|
285
|
+
if (contentHeight) {
|
|
286
|
+
handleChange('');
|
|
287
|
+
timeoutID = setTimeout(() => setContentHeight(null), 1000); //Wait until the text change for onContentSizeChange get the init height before reset multilineStyle
|
|
288
|
+
}
|
|
289
|
+
return () => {
|
|
290
|
+
if (timeoutID) {
|
|
291
|
+
clearTimeout(timeoutID);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}, [multilineStyleSignature]);
|
|
295
|
+
return (_jsxs(View, { onLayout: e => {
|
|
296
|
+
var _a, _b, _c, _d;
|
|
297
|
+
setContainerWidth((_b = (_a = e === null || e === void 0 ? void 0 : e.nativeEvent) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.width);
|
|
298
|
+
setContainerHeight((_d = (_c = e === null || e === void 0 ? void 0 : e.nativeEvent) === null || _c === void 0 ? void 0 : _c.layout) === null || _d === void 0 ? void 0 : _d.height);
|
|
299
|
+
}, style: [styles.container, containerStyle], children: [_jsxs(View, { style: [
|
|
300
|
+
styles.inputContainer,
|
|
301
|
+
{ borderColor: renderInputBorderColor() },
|
|
302
|
+
!editable && styles.disabled,
|
|
303
|
+
inputContainerStyle,
|
|
304
|
+
], children: [label && (_jsx(Animated.View, { pointerEvents: 'none', onLayout: e => {
|
|
305
|
+
var _a, _b;
|
|
306
|
+
setLabelHeight((_b = (_a = e === null || e === void 0 ? void 0 : e.nativeEvent) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.height);
|
|
307
|
+
}, style: labelViewStyle, children: _jsx(Animated.Text, { numberOfLines: 1, ellipsizeMode: "tail", style: labelStyle, children: label }) })), isApplyStartIcon && (_jsx(View, { style: styles.iconStart, onLayout: e => {
|
|
308
|
+
setStartIconWidth(e.nativeEvent.layout.width);
|
|
309
|
+
}, children: renderStartIcon({
|
|
310
|
+
focused: focused,
|
|
311
|
+
hasError: hasError,
|
|
312
|
+
editable: editable,
|
|
313
|
+
}) })), _jsx(TextInput, Object.assign({}, rest, { ref: inputRef, style: [
|
|
314
|
+
styles.input,
|
|
315
|
+
multiline && styles.multiline,
|
|
316
|
+
multilineStyle,
|
|
317
|
+
multilineWebStyle,
|
|
318
|
+
WEB && !editable && styles.webDisabled,
|
|
319
|
+
!editable && styles.inputDisabled,
|
|
320
|
+
style,
|
|
321
|
+
], value: textValue, onChangeText: handleChange, editable: editable, multiline: multiline, onFocus: e => {
|
|
322
|
+
if (!editable) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
setFocused(true);
|
|
326
|
+
onFocus && onFocus(e);
|
|
327
|
+
}, onBlur: e => {
|
|
328
|
+
setFocused(false);
|
|
329
|
+
onBlur && onBlur(e);
|
|
330
|
+
}, onContentSizeChange: e => {
|
|
331
|
+
if (multiline && WEB) {
|
|
332
|
+
setWebInputHeight(e.nativeEvent.contentSize.height);
|
|
333
|
+
}
|
|
334
|
+
if (!multiline || contentHeight) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
setContentHeight(e.nativeEvent.contentSize.height);
|
|
338
|
+
} })), isApplyEndIcon && (_jsx(View, { style: styles.iconEnd, onLayout: e => {
|
|
339
|
+
var _a, _b;
|
|
340
|
+
setEndIconWidth((_b = (_a = e.nativeEvent) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.width);
|
|
341
|
+
}, children: renderEndIcon({
|
|
342
|
+
focused: focused,
|
|
343
|
+
hasError: hasError,
|
|
344
|
+
editable: editable,
|
|
345
|
+
}) }))] }), (errorMessage || helperText) && (_jsx(Text, { color: renderHelperTextColor(), onLayout: e => {
|
|
346
|
+
var _a, _b;
|
|
347
|
+
setHelperHeight((_b = (_a = e === null || e === void 0 ? void 0 : e.nativeEvent) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.height);
|
|
348
|
+
}, style: [styles.helperText, helperTextStyle], children: errorMessage !== null && errorMessage !== void 0 ? errorMessage : helperText }))] }));
|
|
349
|
+
};
|
|
350
|
+
const styles = StyleSheet.create({
|
|
351
|
+
container: {
|
|
352
|
+
width: '100%',
|
|
353
|
+
},
|
|
354
|
+
inputContainer: {
|
|
355
|
+
minHeight: MIN_HEIGHT,
|
|
356
|
+
borderWidth: 1,
|
|
357
|
+
borderColor: DEFAULT_COLOR,
|
|
358
|
+
borderRadius: 8,
|
|
359
|
+
flexDirection: 'row',
|
|
360
|
+
alignItems: 'center',
|
|
361
|
+
paddingHorizontal: DEFAULT_PADDING,
|
|
362
|
+
backgroundColor: colors.white,
|
|
363
|
+
},
|
|
364
|
+
focusedBorder: {
|
|
365
|
+
borderColor: FOCUSED_COLOR,
|
|
366
|
+
},
|
|
367
|
+
input: Object.assign({ flex: 1, fontSize: fontSize._14, color: colors.black, paddingVertical: DEFAULT_PADDING }, (WEB
|
|
368
|
+
? {
|
|
369
|
+
outlineStyle: 'none',
|
|
370
|
+
overflow: 'hidden',
|
|
371
|
+
}
|
|
372
|
+
: {})),
|
|
373
|
+
multiline: {
|
|
374
|
+
textAlignVertical: 'top',
|
|
375
|
+
alignItems: 'flex-start'
|
|
376
|
+
},
|
|
377
|
+
iconStart: {
|
|
378
|
+
marginRight: DEFAULT_PADDING,
|
|
379
|
+
},
|
|
380
|
+
iconEnd: {
|
|
381
|
+
marginLeft: DEFAULT_PADDING,
|
|
382
|
+
},
|
|
383
|
+
helperText: {
|
|
384
|
+
marginTop: DEFAULT_MARGIN_TOP,
|
|
385
|
+
fontSize: WEB ? fontSize._10 : fontSize._12,
|
|
386
|
+
paddingHorizontal: DEFAULT_PADDING
|
|
387
|
+
},
|
|
388
|
+
disabled: {
|
|
389
|
+
backgroundColor: DISABLED_COLOR,
|
|
390
|
+
},
|
|
391
|
+
webDisabled: Object.assign({}, (WEB
|
|
392
|
+
? {
|
|
393
|
+
cursor: 'not-allowed',
|
|
394
|
+
}
|
|
395
|
+
: {})),
|
|
396
|
+
inputDisabled: {
|
|
397
|
+
color: DEFAULT_COLOR
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
export default TextField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TextFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TextField } from './TextField';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextProps as RNTextProps, TextStyle, StyleProp } from 'react-native';
|
|
3
|
+
export interface TextProps extends RNTextProps {
|
|
4
|
+
style?: StyleProp<TextStyle>;
|
|
5
|
+
color?: string;
|
|
6
|
+
bold?: boolean;
|
|
7
|
+
italic?: boolean;
|
|
8
|
+
light?: boolean;
|
|
9
|
+
medium?: boolean;
|
|
10
|
+
semiBold?: boolean;
|
|
11
|
+
size?: number;
|
|
12
|
+
thin?: boolean;
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Text component for displaying text with custom styles and loading state.
|
|
17
|
+
* This component also have its own view and can easily be customized.
|
|
18
|
+
*/
|
|
19
|
+
declare const Text: React.FC<TextProps>;
|
|
20
|
+
export default Text;
|
|
21
|
+
//# sourceMappingURL=Text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../src/Texts/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAGL,SAAS,IAAI,WAAW,EACxB,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,SAAU,SAAQ,WAAW;IAC5C,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAyC7B,CAAC;AAQF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { StyleSheet, Text as RNText, } from 'react-native';
|
|
14
|
+
import { colors, fontSize } from '../themes';
|
|
15
|
+
/**
|
|
16
|
+
* Text component for displaying text with custom styles and loading state.
|
|
17
|
+
* This component also have its own view and can easily be customized.
|
|
18
|
+
*/
|
|
19
|
+
const Text = (_a) => {
|
|
20
|
+
var { bold = false, color = colors.black, italic = false, light = false, medium = false, semiBold = false, size = fontSize._16, style = {}, thin = false } = _a, rest = __rest(_a, ["bold", "color", "italic", "light", "medium", "semiBold", "size", "style", "thin"]);
|
|
21
|
+
let textStyle = {
|
|
22
|
+
color,
|
|
23
|
+
fontSize: size,
|
|
24
|
+
fontStyle: italic ? 'italic' : 'normal',
|
|
25
|
+
fontWeight: '400'
|
|
26
|
+
};
|
|
27
|
+
if (bold) {
|
|
28
|
+
textStyle.fontWeight = '700';
|
|
29
|
+
}
|
|
30
|
+
if (semiBold) {
|
|
31
|
+
textStyle.fontWeight = '600';
|
|
32
|
+
}
|
|
33
|
+
if (medium) {
|
|
34
|
+
textStyle.fontWeight = '500';
|
|
35
|
+
}
|
|
36
|
+
if (light) {
|
|
37
|
+
textStyle.fontWeight = '300';
|
|
38
|
+
}
|
|
39
|
+
if (thin) {
|
|
40
|
+
textStyle.fontWeight = '100';
|
|
41
|
+
}
|
|
42
|
+
return _jsx(RNText, Object.assign({}, rest, { style: [styles.textDefault, textStyle, style] }));
|
|
43
|
+
};
|
|
44
|
+
const styles = StyleSheet.create({
|
|
45
|
+
textDefault: {
|
|
46
|
+
color: colors.black,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
export default Text;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PanGestureHandlerProperties } from "react-native-gesture-handler";
|
|
2
|
+
import { WithSpringConfig } from "react-native-reanimated";
|
|
3
|
+
export declare const SCROLL_POSITION_TOLERANCE = 2;
|
|
4
|
+
export declare const DEFAULT_ANIMATION_CONFIG: WithSpringConfig;
|
|
5
|
+
export declare const DEFAULT_PROPS: {
|
|
6
|
+
autoscrollThreshold: number;
|
|
7
|
+
autoscrollSpeed: number;
|
|
8
|
+
animationConfig: {
|
|
9
|
+
stiffness?: number;
|
|
10
|
+
overshootClamping?: boolean;
|
|
11
|
+
restDisplacementThreshold?: number;
|
|
12
|
+
restSpeedThreshold?: number;
|
|
13
|
+
velocity?: number;
|
|
14
|
+
reduceMotion?: import("react-native-reanimated").ReduceMotion;
|
|
15
|
+
} & {
|
|
16
|
+
mass?: number;
|
|
17
|
+
damping?: number;
|
|
18
|
+
duration?: never;
|
|
19
|
+
dampingRatio?: never;
|
|
20
|
+
clamp?: never;
|
|
21
|
+
};
|
|
22
|
+
scrollEnabled: boolean;
|
|
23
|
+
dragHitSlop: PanGestureHandlerProperties["hitSlop"];
|
|
24
|
+
activationDistance: number;
|
|
25
|
+
dragItemOverflow: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare const isReanimatedV2 = true;
|
|
28
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/constants/DraggableFlatList/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAEL,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAGjC,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,wBAAwB,EAAE,gBAOtC,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;iBAKN,2BAA2B,CAAC,SAAS,CAAC;;;CAGzD,CAAC;AAGF,eAAO,MAAM,cAAc,OAAmB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useSharedValue, } from "react-native-reanimated";
|
|
2
|
+
// Fire onScrollComplete when within this many px of target offset
|
|
3
|
+
export const SCROLL_POSITION_TOLERANCE = 2;
|
|
4
|
+
export const DEFAULT_ANIMATION_CONFIG = {
|
|
5
|
+
damping: 20,
|
|
6
|
+
mass: 0.2,
|
|
7
|
+
stiffness: 100,
|
|
8
|
+
overshootClamping: false,
|
|
9
|
+
restSpeedThreshold: 0.2,
|
|
10
|
+
restDisplacementThreshold: 0.2,
|
|
11
|
+
};
|
|
12
|
+
export const DEFAULT_PROPS = {
|
|
13
|
+
autoscrollThreshold: 30,
|
|
14
|
+
autoscrollSpeed: 100,
|
|
15
|
+
animationConfig: DEFAULT_ANIMATION_CONFIG,
|
|
16
|
+
scrollEnabled: true,
|
|
17
|
+
dragHitSlop: 0,
|
|
18
|
+
activationDistance: 0,
|
|
19
|
+
dragItemOverflow: false,
|
|
20
|
+
};
|
|
21
|
+
// Is there a better way to check for v2?
|
|
22
|
+
export const isReanimatedV2 = !!useSharedValue;
|
|
23
|
+
if (!isReanimatedV2) {
|
|
24
|
+
throw new Error("Your version of react-native-reanimated is too old for react-native-draggable-flatlist!");
|
|
25
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FlatListProps, LayoutChangeEvent, StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
import { FlatList } from "react-native-gesture-handler";
|
|
4
|
+
import Animated, { AnimateProps, WithSpringConfig } from "react-native-reanimated";
|
|
5
|
+
import { useAnimatedValues } from "../../context/DraggableFlatList/animatedValueContext";
|
|
6
|
+
import { DEFAULT_PROPS } from "./constants";
|
|
7
|
+
export type DragEndParams<T> = {
|
|
8
|
+
data: T[];
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
11
|
+
};
|
|
12
|
+
type Modify<T, R> = Omit<T, keyof R> & R;
|
|
13
|
+
type DefaultProps = Readonly<typeof DEFAULT_PROPS>;
|
|
14
|
+
export type DraggableFlatListProps<T> = Modify<FlatListProps<T>, {
|
|
15
|
+
data: T[];
|
|
16
|
+
activationDistance?: number;
|
|
17
|
+
animationConfig?: Partial<WithSpringConfig>;
|
|
18
|
+
autoscrollSpeed?: number;
|
|
19
|
+
autoscrollThreshold?: number;
|
|
20
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
21
|
+
debug?: boolean;
|
|
22
|
+
dragItemOverflow?: boolean;
|
|
23
|
+
keyExtractor: (item: T, index: number) => string;
|
|
24
|
+
onDragBegin?: (index: number) => void;
|
|
25
|
+
onDragEnd?: (params: DragEndParams<T>) => void;
|
|
26
|
+
onPlaceholderIndexChange?: (placeholderIndex: number) => void;
|
|
27
|
+
onRelease?: (index: number) => void;
|
|
28
|
+
onScrollOffsetChange?: (scrollOffset: number) => void;
|
|
29
|
+
renderItem: RenderItem<T>;
|
|
30
|
+
renderPlaceholder?: RenderPlaceholder<T>;
|
|
31
|
+
simultaneousHandlers?: React.Ref<any> | React.Ref<any>[];
|
|
32
|
+
outerScrollOffset?: Animated.SharedValue<number>;
|
|
33
|
+
onAnimValInit?: (animVals: ReturnType<typeof useAnimatedValues>) => void;
|
|
34
|
+
itemEnteringAnimation?: AnimateProps<Animated.View>["entering"];
|
|
35
|
+
itemExitingAnimation?: AnimateProps<Animated.View>["exiting"];
|
|
36
|
+
itemLayoutAnimation?: AnimateProps<Animated.View>["layout"];
|
|
37
|
+
enableLayoutAnimationExperimental?: boolean;
|
|
38
|
+
onContainerLayout?: (params: {
|
|
39
|
+
layout: LayoutChangeEvent["nativeEvent"]["layout"];
|
|
40
|
+
containerRef: React.RefObject<Animated.View>;
|
|
41
|
+
}) => void;
|
|
42
|
+
} & Partial<DefaultProps>>;
|
|
43
|
+
export type RenderPlaceholder<T> = (params: {
|
|
44
|
+
item: T;
|
|
45
|
+
index: number;
|
|
46
|
+
}) => JSX.Element;
|
|
47
|
+
export type RenderItemParams<T> = {
|
|
48
|
+
item: T;
|
|
49
|
+
getIndex: () => number | undefined;
|
|
50
|
+
drag: () => void;
|
|
51
|
+
isActive: boolean;
|
|
52
|
+
};
|
|
53
|
+
export type RenderItem<T> = (params: RenderItemParams<T>) => React.ReactNode;
|
|
54
|
+
export type AnimatedFlatListType = <T>(props: Animated.AnimateProps<FlatListProps<T> & {
|
|
55
|
+
ref: React.Ref<FlatList<T>>;
|
|
56
|
+
simultaneousHandlers?: React.Ref<any> | React.Ref<any>[];
|
|
57
|
+
}>) => React.ReactElement;
|
|
58
|
+
export type CellData = {
|
|
59
|
+
measurements: {
|
|
60
|
+
size: number;
|
|
61
|
+
offset: number;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/constants/DraggableFlatList/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DraggableFlatListProps, RenderItemParams } from "../DraggableFlatList/types";
|
|
3
|
+
export interface WebDraggableFlatListProps<T> extends Omit<DraggableFlatListProps<T>, "renderItem" | "containerStyle"> {
|
|
4
|
+
renderItem: (params: RenderItemParams<T>) => React.ReactNode;
|
|
5
|
+
containerStyle?: React.CSSProperties;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=types.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.web.d.ts","sourceRoot":"","sources":["../../../src/constants/DraggableFlatList/types.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,mCAAmC,CAAC;AAE3C,MAAM,WAAW,yBAAyB,CAAC,CAAC,CAAE,SAAQ,IAAI,CACxD,sBAAsB,CAAC,CAAC,CAAC,EACzB,YAAY,GAAG,gBAAgB,CAChC;IACC,UAAU,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC7D,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const FORMAT_TIME_DMY_ = "DD/MM/YYYY";
|
|
2
|
+
export declare const FORMAT_TIME_DMY = "DD-MM-YYYY";
|
|
3
|
+
export declare const FORMAT_TIME = "YYYY-MM-DD HH:mm";
|
|
4
|
+
export declare const FORMAT_TIME_DMYHMS = "DD/MM/YYYY HH:mm:ss";
|
|
5
|
+
export declare const FORMAT_TIME_DMYHM = "DD/MM/YYYY HH:mm";
|
|
6
|
+
export declare const FORMAT_TIME_VH = "MMMM DD, YYYY HH:mm";
|
|
7
|
+
export declare const FORMAT_TIME_DDMMM = "DD MMM";
|
|
8
|
+
export declare const FORMAT_TIME_YMD = "YYYY-MM-DD";
|
|
9
|
+
export declare const FORMAT_TIME_FILTER = "DD/MM/YY";
|
|
10
|
+
export declare const FORMAT_TIME_L = "L";
|
|
11
|
+
export declare const FORMAT_TIME_LL = "LL";
|
|
12
|
+
export declare const FORMAT_TIME_LLL = "LLL";
|
|
13
|
+
export declare const FORMAT_TIME_LLLL = "LLLL";
|
|
14
|
+
export declare const FORMAT_TIME_LT = "LT";
|
|
15
|
+
export declare const FORMAT_TIME_LTS = "LTS";
|
|
16
|
+
//# sourceMappingURL=consts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../src/constants/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAE7C,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAE9C,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AAExD,eAAO,MAAM,iBAAiB,qBAAqB,CAAC;AAEpD,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAE7C,eAAO,MAAM,aAAa,MAAM,CAAC;AACjC,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,eAAe,QAAQ,CAAC;AACrC,eAAO,MAAM,gBAAgB,SAAS,CAAC;AACvC,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,eAAe,QAAQ,CAAC"}
|