@codeleap/mobile 4.2.9 → 4.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Registry.js +28 -53
- package/dist/Registry.js.map +1 -1
- package/dist/components/ActionIcon/index.js +27 -67
- package/dist/components/ActionIcon/index.js.map +1 -1
- package/dist/components/ActionIcon/styles.js +1 -2
- package/dist/components/ActionIcon/types.js +1 -2
- package/dist/components/ActivityIndicator/index.js +22 -62
- package/dist/components/ActivityIndicator/index.js.map +1 -1
- package/dist/components/ActivityIndicator/styles.js +1 -2
- package/dist/components/ActivityIndicator/types.js +1 -2
- package/dist/components/Autocomplete/index.js +73 -121
- package/dist/components/Autocomplete/index.js.map +1 -1
- package/dist/components/Autocomplete/styles.js +1 -2
- package/dist/components/Autocomplete/types.js +1 -2
- package/dist/components/Avatar/index.js +49 -90
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/Avatar/styles.js +1 -2
- package/dist/components/Avatar/types.js +1 -2
- package/dist/components/AvatarGroup/index.js +30 -75
- package/dist/components/AvatarGroup/index.js.map +1 -1
- package/dist/components/AvatarGroup/styles.js +1 -2
- package/dist/components/AvatarGroup/types.js +1 -2
- package/dist/components/Backdrop/index.js +26 -66
- package/dist/components/Backdrop/index.js.map +1 -1
- package/dist/components/Backdrop/styles.js +1 -2
- package/dist/components/Backdrop/types.js +1 -2
- package/dist/components/Badge/index.js +44 -85
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/styles.js +1 -2
- package/dist/components/Badge/types.js +1 -2
- package/dist/components/Button/index.js +49 -98
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/styles.js +1 -2
- package/dist/components/Button/types.js +1 -2
- package/dist/components/Calendar/index.js +27 -68
- package/dist/components/Calendar/index.js.map +1 -1
- package/dist/components/Calendar/types.d.ts +1 -2
- package/dist/components/Calendar/types.js +1 -2
- package/dist/components/Checkbox/index.js +52 -85
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Checkbox/styles.js +1 -2
- package/dist/components/Checkbox/types.js +1 -2
- package/dist/components/DatePickerModal/index.js +61 -113
- package/dist/components/DatePickerModal/index.js.map +1 -1
- package/dist/components/DatePickerModal/styles.js +1 -2
- package/dist/components/DatePickerModal/types.js +1 -2
- package/dist/components/EmptyPlaceholder/index.js +40 -69
- package/dist/components/EmptyPlaceholder/index.js.map +1 -1
- package/dist/components/EmptyPlaceholder/styles.js +1 -2
- package/dist/components/EmptyPlaceholder/types.js +1 -2
- package/dist/components/FileInput/index.js +112 -178
- package/dist/components/FileInput/index.js.map +1 -1
- package/dist/components/FileInput/types.js +1 -2
- package/dist/components/Grid/index.js +47 -97
- package/dist/components/Grid/index.js.map +1 -1
- package/dist/components/Grid/styles.js +1 -2
- package/dist/components/Grid/types.js +1 -2
- package/dist/components/Icon/index.js +34 -75
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Icon/styles.js +1 -2
- package/dist/components/Icon/types.js +1 -2
- package/dist/components/Image/index.js +53 -96
- package/dist/components/Image/index.js.map +1 -1
- package/dist/components/Image/styles.js +1 -2
- package/dist/components/Image/types.js +1 -2
- package/dist/components/ImageView/Spotlight.js +75 -131
- package/dist/components/ImageView/Spotlight.js.map +1 -1
- package/dist/components/ImageView/component.js +8 -15
- package/dist/components/ImageView/component.js.map +1 -1
- package/dist/components/ImageView/index.js +2 -18
- package/dist/components/ImageView/index.js.map +1 -1
- package/dist/components/InputBase/index.js +35 -75
- package/dist/components/InputBase/index.js.map +1 -1
- package/dist/components/InputBase/styles.d.ts +3 -3
- package/dist/components/InputBase/styles.js +49 -50
- package/dist/components/InputBase/styles.js.map +1 -1
- package/dist/components/InputBase/types.d.ts +1 -0
- package/dist/components/InputBase/types.js +1 -2
- package/dist/components/InputBase/utils.js +4 -19
- package/dist/components/InputBase/utils.js.map +1 -1
- package/dist/components/List/index.js +46 -86
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/List/styles.js +1 -2
- package/dist/components/List/types.js +1 -2
- package/dist/components/LoadingOverlay/index.js +28 -66
- package/dist/components/LoadingOverlay/index.js.map +1 -1
- package/dist/components/LoadingOverlay/styles.js +1 -2
- package/dist/components/LoadingOverlay/types.js +1 -2
- package/dist/components/Modal/index.js +77 -113
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.js +1 -2
- package/dist/components/Modal/types.js +1 -2
- package/dist/components/Navigation/Navigation.js +23 -66
- package/dist/components/Navigation/Navigation.js.map +1 -1
- package/dist/components/Navigation/constants.js +7 -10
- package/dist/components/Navigation/constants.js.map +1 -1
- package/dist/components/Navigation/index.js +3 -19
- package/dist/components/Navigation/index.js.map +1 -1
- package/dist/components/Navigation/types.js +1 -2
- package/dist/components/Navigation/utils.js +24 -59
- package/dist/components/Navigation/utils.js.map +1 -1
- package/dist/components/NumberIncrement/index.js +132 -165
- package/dist/components/NumberIncrement/index.js.map +1 -1
- package/dist/components/NumberIncrement/styles.js +1 -2
- package/dist/components/NumberIncrement/types.d.ts +2 -2
- package/dist/components/NumberIncrement/types.js +1 -2
- package/dist/components/NumberIncrement/utils.js +8 -12
- package/dist/components/NumberIncrement/utils.js.map +1 -1
- package/dist/components/Pager/PagerDots.js +17 -54
- package/dist/components/Pager/PagerDots.js.map +1 -1
- package/dist/components/Pager/index.js +43 -97
- package/dist/components/Pager/index.js.map +1 -1
- package/dist/components/Pager/styles.js +1 -2
- package/dist/components/Pager/types.js +1 -2
- package/dist/components/PaginationIndicator/index.js +23 -38
- package/dist/components/PaginationIndicator/index.js.map +1 -1
- package/dist/components/PaginationIndicator/styles.js +1 -2
- package/dist/components/PaginationIndicator/types.js +1 -2
- package/dist/components/PlacesAutocomplete/index.js +55 -106
- package/dist/components/PlacesAutocomplete/index.js.map +1 -1
- package/dist/components/PlacesAutocomplete/styles.js +1 -2
- package/dist/components/PlacesAutocomplete/types.js +1 -2
- package/dist/components/RadioInput/index.js +46 -84
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/RadioInput/styles.js +1 -2
- package/dist/components/RadioInput/types.js +1 -2
- package/dist/components/RefreshControl/index.js +22 -63
- package/dist/components/RefreshControl/index.js.map +1 -1
- package/dist/components/RefreshControl/styles.js +1 -2
- package/dist/components/RefreshControl/types.js +1 -2
- package/dist/components/Scroll/index.js +33 -81
- package/dist/components/Scroll/index.js.map +1 -1
- package/dist/components/Scroll/styles.js +1 -2
- package/dist/components/Scroll/types.js +1 -2
- package/dist/components/SearchInput/index.js +22 -69
- package/dist/components/SearchInput/index.js.map +1 -1
- package/dist/components/SectionFilters/context.d.ts +6 -0
- package/dist/components/SectionFilters/context.js +4 -8
- package/dist/components/SectionFilters/context.js.map +1 -1
- package/dist/components/SectionFilters/index.js +33 -76
- package/dist/components/SectionFilters/index.js.map +1 -1
- package/dist/components/SectionFilters/types.js +1 -2
- package/dist/components/SectionFilters/useSectionFilters.d.ts +4 -0
- package/dist/components/SectionFilters/useSectionFilters.js +75 -73
- package/dist/components/SectionFilters/useSectionFilters.js.map +1 -1
- package/dist/components/Sections/index.d.ts +8 -8
- package/dist/components/Sections/index.js +61 -106
- package/dist/components/Sections/index.js.map +1 -1
- package/dist/components/Sections/styles.d.ts +1 -1
- package/dist/components/Sections/styles.js +1 -2
- package/dist/components/Sections/types.js +1 -2
- package/dist/components/SegmentedControl/Option.js +13 -31
- package/dist/components/SegmentedControl/Option.js.map +1 -1
- package/dist/components/SegmentedControl/index.js +71 -114
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/SegmentedControl/styles.js +1 -2
- package/dist/components/SegmentedControl/types.js +1 -2
- package/dist/components/Select/index.js +94 -157
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/styles.js +1 -2
- package/dist/components/Select/types.js +1 -2
- package/dist/components/Slider/index.js +89 -129
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/styles.d.ts +0 -6
- package/dist/components/Slider/styles.js +1 -2
- package/dist/components/Slider/types.js +1 -2
- package/dist/components/SortablePhotos/index.js +58 -91
- package/dist/components/SortablePhotos/index.js.map +1 -1
- package/dist/components/SortablePhotos/styles.js +1 -2
- package/dist/components/SortablePhotos/types.js +1 -2
- package/dist/components/SortablePhotos/useSortablePhotos.js +93 -157
- package/dist/components/SortablePhotos/useSortablePhotos.js.map +1 -1
- package/dist/components/Switch/index.js +51 -84
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/styles.js +1 -2
- package/dist/components/Switch/types.js +1 -2
- package/dist/components/Text/index.js +40 -88
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/Text/styles.js +1 -2
- package/dist/components/Text/types.js +1 -2
- package/dist/components/TextInput/index.js +83 -131
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/styles.js +1 -2
- package/dist/components/TextInput/types.js +1 -2
- package/dist/components/Touchable/index.js +69 -122
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/Touchable/styles.js +1 -2
- package/dist/components/Touchable/types.js +1 -2
- package/dist/components/View/index.js +19 -51
- package/dist/components/View/index.js.map +1 -1
- package/dist/components/View/styles.js +1 -2
- package/dist/components/View/types.js +1 -2
- package/dist/components/components.js +43 -59
- package/dist/components/components.js.map +1 -1
- package/dist/hooks/index.js +7 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.js +8 -43
- package/dist/index.js.map +1 -1
- package/dist/modules/PressableRipple/index.js +2 -8
- package/dist/modules/PressableRipple/index.js.map +1 -1
- package/dist/modules/PressableRipple/ripple.js +125 -163
- package/dist/modules/PressableRipple/ripple.js.map +1 -1
- package/dist/modules/PressableRipple/styles.js +9 -20
- package/dist/modules/PressableRipple/styles.js.map +1 -1
- package/dist/modules/PressableRipple/type.js +1 -2
- package/dist/modules/reactNavigation.js +10 -21
- package/dist/modules/reactNavigation.js.map +1 -1
- package/dist/modules/textInputMask.js +3 -20
- package/dist/modules/textInputMask.js.map +1 -1
- package/dist/modules/types/textInputMask.js +1 -2
- package/dist/types/index.js +1 -17
- package/dist/types/index.js.map +1 -1
- package/dist/types/utility.js +1 -2
- package/dist/utils/KeyboardAware/context.js +5 -14
- package/dist/utils/KeyboardAware/context.js.map +1 -1
- package/dist/utils/KeyboardAware/index.js +3 -19
- package/dist/utils/KeyboardAware/index.js.map +1 -1
- package/dist/utils/KeyboardAware/keyboardHooks.js +36 -41
- package/dist/utils/KeyboardAware/keyboardHooks.js.map +1 -1
- package/dist/utils/KeyboardAware/types.js +1 -2
- package/dist/utils/KeyboardAware/types.js.map +1 -1
- package/dist/utils/ModalManager/components.js +24 -54
- package/dist/utils/ModalManager/components.js.map +1 -1
- package/dist/utils/ModalManager/context.js +94 -89
- package/dist/utils/ModalManager/context.js.map +1 -1
- package/dist/utils/ModalManager/index.js +7 -10
- package/dist/utils/ModalManager/index.js.map +1 -1
- package/dist/utils/NotificationManager/index.js +115 -245
- package/dist/utils/NotificationManager/index.js.map +1 -1
- package/dist/utils/NotificationManager/types.js +1 -2
- package/dist/utils/OSAlert.js +32 -48
- package/dist/utils/OSAlert.js.map +1 -1
- package/dist/utils/PermissionManager/context.js +138 -255
- package/dist/utils/PermissionManager/context.js.map +1 -1
- package/dist/utils/PermissionManager/index.js +2 -8
- package/dist/utils/PermissionManager/index.js.map +1 -1
- package/dist/utils/PermissionManager/types.js +1 -2
- package/dist/utils/StorageManager.js +39 -46
- package/dist/utils/StorageManager.js.map +1 -1
- package/dist/utils/Subscription.js +30 -54
- package/dist/utils/Subscription.js.map +1 -1
- package/dist/utils/deprecated/notifications.js +143 -250
- package/dist/utils/deprecated/notifications.js.map +1 -1
- package/dist/utils/hooks.js +101 -120
- package/dist/utils/hooks.js.map +1 -1
- package/dist/utils/index.js +14 -43
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/input.js +15 -19
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/locale.js +5 -9
- package/dist/utils/locale.js.map +1 -1
- package/dist/utils/misc.js +25 -40
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/theme.js +24 -33
- package/dist/utils/theme.js.map +1 -1
- package/dist/utils/useQueryListRefresh.js +16 -26
- package/dist/utils/useQueryListRefresh.js.map +1 -1
- package/package.json +6 -6
- package/package.json.bak +2 -2
- package/src/components/Calendar/types.ts +3 -3
- package/src/components/InputBase/styles.ts +35 -23
- package/src/components/InputBase/types.ts +1 -0
- package/src/components/NumberIncrement/index.tsx +8 -2
- package/src/components/NumberIncrement/types.ts +3 -3
- package/src/components/RadioInput/index.tsx +4 -0
- package/src/components/SectionFilters/useSectionFilters.tsx +39 -1
- package/src/components/Sections/index.tsx +3 -2
- package/src/components/Sections/styles.ts +2 -2
- package/src/components/Slider/index.tsx +9 -1
- package/src/components/Slider/styles.ts +0 -6
- package/src/components/TextInput/index.tsx +5 -0
|
@@ -1,134 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
37
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
38
|
-
};
|
|
39
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
40
|
-
var t = {};
|
|
41
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
42
|
-
t[p] = s[p];
|
|
43
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
44
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
45
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
46
|
-
t[p[i]] = s[p[i]];
|
|
47
|
-
}
|
|
48
|
-
return t;
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { TypeGuards, useCallback } from '@codeleap/common';
|
|
3
|
+
import { SectionList } from 'react-native';
|
|
4
|
+
import { View } from '../View';
|
|
5
|
+
import { RefreshControl } from '../RefreshControl';
|
|
6
|
+
import { useKeyboardPaddingStyle } from '../../utils';
|
|
7
|
+
import { MobileStyleRegistry } from '../../Registry';
|
|
8
|
+
import { useStylesFor } from '../../hooks';
|
|
9
|
+
import { EmptyPlaceholder } from '../EmptyPlaceholder';
|
|
10
|
+
export * from './styles';
|
|
11
|
+
export * from './types';
|
|
12
|
+
const RenderSeparator = (props) => {
|
|
13
|
+
return <View style={props.separatorStyles}/>;
|
|
49
14
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var EmptyPlaceholder_1 = require("../EmptyPlaceholder");
|
|
61
|
-
__exportStar(require("./styles"), exports);
|
|
62
|
-
__exportStar(require("./types"), exports);
|
|
63
|
-
var RenderSeparator = function (props) {
|
|
64
|
-
return <View_1.View style={props.separatorStyles}/>;
|
|
65
|
-
};
|
|
66
|
-
var Sections = function (sectionsProps) {
|
|
67
|
-
var _a = __assign(__assign({}, exports.Sections.defaultProps), sectionsProps), style = _a.style, onRefresh = _a.onRefresh, component = _a.component, refreshing = _a.refreshing, placeholder = _a.placeholder, refreshControlProps = _a.refreshControlProps, loading = _a.loading, keyboardAware = _a.keyboardAware, _b = _a.fakeEmpty, fakeEmpty = _b === void 0 ? loading : _b, contentContainerStyle = _a.contentContainerStyle, refreshControl = _a.refreshControl, RenderItem = _a.renderItem, data = _a.sections, RenderSectionHeader = _a.renderSectionHeader, RenderSectionFooter = _a.renderSectionFooter, props = __rest(_a, ["style", "onRefresh", "component", "refreshing", "placeholder", "refreshControlProps", "loading", "keyboardAware", "fakeEmpty", "contentContainerStyle", "refreshControl", "renderItem", "sections", "renderSectionHeader", "renderSectionFooter"]);
|
|
68
|
-
var sections = (0, react_1.useMemo)(function () {
|
|
69
|
-
return data === null || data === void 0 ? void 0 : data.map(function (section, index) { return (__assign(__assign({}, section), { index: index })); });
|
|
15
|
+
export function Sections(sectionsProps) {
|
|
16
|
+
const { style, onRefresh, component, refreshing, placeholder, refreshControlProps, loading, keyboardAware, fakeEmpty = loading, contentContainerStyle, refreshControl, renderItem: RenderItem, sections: data, renderSectionHeader: RenderSectionHeader, renderSectionFooter: RenderSectionFooter, ...props } = {
|
|
17
|
+
...Sections.defaultProps,
|
|
18
|
+
...sectionsProps,
|
|
19
|
+
};
|
|
20
|
+
const sections = useMemo(() => {
|
|
21
|
+
return data?.map((section, index) => ({
|
|
22
|
+
...section,
|
|
23
|
+
index,
|
|
24
|
+
}));
|
|
70
25
|
}, [JSON.stringify(data)]);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (!
|
|
26
|
+
const styles = useStylesFor(Sections.styleRegistryName, style);
|
|
27
|
+
const separator = useCallback(() => {
|
|
28
|
+
if (!props?.separators)
|
|
74
29
|
return null;
|
|
75
30
|
return <RenderSeparator separatorStyles={styles.separator}/>;
|
|
76
31
|
}, []);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return { isFirst: isFirst, isLast: isLast, isOnly: isOnly, title: title, index: index };
|
|
32
|
+
const getSectionProps = (data) => {
|
|
33
|
+
const listLength = sections?.length || 0;
|
|
34
|
+
const isFirst = data?.section?.index === sections?.[0]?.index;
|
|
35
|
+
const isLast = data?.section?.index === sections?.[listLength - 1]?.index;
|
|
36
|
+
const isOnly = isFirst && isLast;
|
|
37
|
+
const title = data?.section?.title;
|
|
38
|
+
const index = data?.section?.index;
|
|
39
|
+
return { isFirst, isLast, isOnly, title, index };
|
|
86
40
|
};
|
|
87
|
-
|
|
41
|
+
const renderSectionHeader = useCallback((data) => {
|
|
88
42
|
if (!RenderSectionHeader)
|
|
89
43
|
return null;
|
|
90
|
-
|
|
44
|
+
const positionProps = getSectionProps(data);
|
|
91
45
|
return <RenderSectionHeader {...data.section} {...positionProps}/>;
|
|
92
|
-
}, [RenderSectionHeader, sections
|
|
93
|
-
|
|
46
|
+
}, [RenderSectionHeader, sections?.length]);
|
|
47
|
+
const renderSectionFooter = useCallback((data) => {
|
|
94
48
|
if (!RenderSectionFooter)
|
|
95
49
|
return null;
|
|
96
|
-
|
|
50
|
+
const positionProps = getSectionProps(data);
|
|
97
51
|
return <RenderSectionFooter {...data.section} {...positionProps}/>;
|
|
98
|
-
}, [RenderSectionFooter, sections
|
|
99
|
-
|
|
100
|
-
var _a, _b;
|
|
52
|
+
}, [RenderSectionFooter, sections?.length]);
|
|
53
|
+
const renderItem = useCallback((data) => {
|
|
101
54
|
if (!RenderItem)
|
|
102
55
|
return null;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
56
|
+
const listLength = data?.section?.data?.length || 0;
|
|
57
|
+
const isFirst = data?.index === 0;
|
|
58
|
+
const isLast = data?.index === listLength - 1;
|
|
59
|
+
const isOnly = isFirst && isLast;
|
|
107
60
|
return (<RenderItem {...data} isFirst={isFirst} isLast={isLast} isOnly={isOnly}/>);
|
|
108
61
|
}, [RenderItem]);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
62
|
+
const isEmpty = !sections || !sections?.length;
|
|
63
|
+
const _placeholder = {
|
|
64
|
+
...placeholder,
|
|
65
|
+
loading: TypeGuards.isBoolean(placeholder?.loading) ? placeholder.loading : loading,
|
|
66
|
+
};
|
|
67
|
+
const keyboardStyle = useKeyboardPaddingStyle([
|
|
112
68
|
styles.content,
|
|
113
69
|
contentContainerStyle,
|
|
114
70
|
isEmpty && styles['content:empty'],
|
|
115
71
|
loading && styles['content:loading'],
|
|
116
72
|
], keyboardAware && !props.horizontal);
|
|
117
|
-
|
|
118
|
-
return (<
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return exports.Sections;
|
|
73
|
+
const wrapperStyle = [styles.wrapper, isEmpty && styles['wrapper:empty'], loading && styles['wrapper:loading']];
|
|
74
|
+
return (<SectionList ItemSeparatorComponent={separator} refreshControl={!!onRefresh && (<RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps}/>)} ListEmptyComponent={<EmptyPlaceholder {..._placeholder}/>} showsVerticalScrollIndicator={false} showsHorizontalScrollIndicator={false} {...props} ListHeaderComponentStyle={styles.header} ListFooterComponentStyle={styles.footer} style={wrapperStyle} contentContainerStyle={keyboardStyle} sections={sections} renderItem={renderItem} renderSectionHeader={renderSectionHeader} renderSectionFooter={renderSectionFooter}/>);
|
|
75
|
+
}
|
|
76
|
+
Sections.styleRegistryName = 'Sections';
|
|
77
|
+
Sections.elements = ['wrapper', 'content', 'separator', 'header', 'footer', 'refreshControl'];
|
|
78
|
+
Sections.rootElement = 'wrapper';
|
|
79
|
+
Sections.withVariantTypes = (styles) => {
|
|
80
|
+
return Sections;
|
|
126
81
|
};
|
|
127
|
-
|
|
82
|
+
Sections.defaultProps = {
|
|
128
83
|
keyboardShouldPersistTaps: 'handled',
|
|
129
84
|
fakeEmpty: false,
|
|
130
85
|
loading: false,
|
|
131
86
|
keyboardAware: true,
|
|
132
87
|
};
|
|
133
|
-
|
|
88
|
+
MobileStyleRegistry.registerComponent(Sections);
|
|
134
89
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Sections/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Sections/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAsC,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,IAAI,EAAa,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAGrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,eAAe,GAAG,CAAC,KAA8C,EAAE,EAAE;IACzE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,eAA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ading';
|
|
3
|
-
type SectionsParts = ScrollComposition | 'separator' | 'header' | 'refreshControl';
|
|
3
|
+
type SectionsParts = ScrollComposition | 'separator' | 'header' | 'footer' | 'refreshControl';
|
|
4
4
|
export type SectionsComposition = `${SectionsParts}:${SectionsStates}` | SectionsParts;
|
|
5
5
|
export {};
|
|
@@ -1,44 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SegmentedControlOption = void 0;
|
|
18
|
-
var react_1 = __importDefault(require("react"));
|
|
19
|
-
var Text_1 = require("../Text");
|
|
20
|
-
var Touchable_1 = require("../Touchable");
|
|
21
|
-
var Icon_1 = require("../Icon");
|
|
22
|
-
var SegmentedControlOption = function (props) {
|
|
23
|
-
var selected = props.selected, onPress = props.onPress, debugName = props.debugName, style = props.style, variantStyles = props.variantStyles, label = props.label, value = props.value, icon = props.icon, textProps = props.textProps, _a = props.badge, badge = _a === void 0 ? null : _a, touchableProps = __rest(props, ["selected", "onPress", "debugName", "style", "variantStyles", "label", "value", "icon", "textProps", "badge"]);
|
|
24
|
-
return (<Touchable_1.Touchable debugName={"Segmented Control ".concat(debugName, ", option ").concat(label)} noFeedback={selected} style={[
|
|
25
|
-
variantStyles === null || variantStyles === void 0 ? void 0 : variantStyles.button,
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from '../Text';
|
|
3
|
+
import { Touchable } from '../Touchable';
|
|
4
|
+
import { Icon } from '../Icon';
|
|
5
|
+
export const SegmentedControlOption = (props) => {
|
|
6
|
+
const { selected, onPress, debugName, style, variantStyles, label, value, icon, textProps, badge = null, ...touchableProps } = props;
|
|
7
|
+
return (<Touchable debugName={`Segmented Control ${debugName}, option ${label}`} noFeedback={selected} style={[
|
|
8
|
+
variantStyles?.button,
|
|
26
9
|
selected && variantStyles['button:selected'],
|
|
27
10
|
style,
|
|
28
11
|
{
|
|
29
12
|
feedback: variantStyles.buttonFeedback,
|
|
30
13
|
}
|
|
31
14
|
]} onPress={onPress} {...touchableProps}>
|
|
32
|
-
{!!icon ? <
|
|
15
|
+
{!!icon ? <Icon name={icon} style={variantStyles?.icon}/> : null}
|
|
33
16
|
|
|
34
|
-
<
|
|
35
|
-
variantStyles
|
|
17
|
+
<Text text={label} style={[
|
|
18
|
+
variantStyles?.text,
|
|
36
19
|
selected && variantStyles['text:selected'],
|
|
37
|
-
|
|
20
|
+
touchableProps?.disabled && variantStyles['text:disabled'],
|
|
38
21
|
]} {...textProps}/>
|
|
39
22
|
|
|
40
23
|
{badge}
|
|
41
|
-
</
|
|
24
|
+
</Touchable>);
|
|
42
25
|
};
|
|
43
|
-
exports.SegmentedControlOption = SegmentedControlOption;
|
|
44
26
|
//# sourceMappingURL=Option.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Option.js","sourceRoot":"","sources":["../../../src/components/SegmentedControl/Option.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Option.js","sourceRoot":"","sources":["../../../src/components/SegmentedControl/Option.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAkB,MAAM,cAAc,CAAA;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAc9B,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAkC,EAAE,EAAE;IAC3E,MAAM,EACJ,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,EACL,aAAa,EACb,KAAK,EACL,KAAK,EACL,IAAI,EACJ,SAAS,EACT,KAAK,GAAG,IAAI,EACZ,GAAG,cAAc,EAClB,GAAG,KAAK,CAAA;IAET,OAAO,CACL,CAAC,SAAS,CACR,SAAS,CAAC,CAAC,qBAAqB,SAAS,YAAY,KAAK,EAAE,CAAC,CAC7D,UAAU,CAAC,CAAC,QAAQ,CAAC,CACrB,KAAK,CAAC,CAAC;YACL,aAAa,EAAE,MAAM;YACrB,QAAQ,IAAI,aAAa,CAAC,iBAAiB,CAAC;YAC5C,KAAK;YACL;gBACE,QAAQ,EAAE,aAAa,CAAC,cAAc;aACvC;SACF,CAAC,CACF,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,IAAI,cAAc,CAAC,CAEnB;MAAA,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,EAAG,CAAC,CAAC,CAAC,IAAI,CAEjE;;MAAA,CAAC,IAAI,CACH,IAAI,CAAC,CAAC,KAAK,CAAC,CACZ,KAAK,CAAC,CAAC;YACL,aAAa,EAAE,IAAI;YACnB,QAAQ,IAAI,aAAa,CAAC,eAAe,CAAC;YAC1C,cAAc,EAAE,QAAQ,IAAI,aAAa,CAAC,eAAe,CAAC;SAC3D,CAAC,CACF,IAAI,SAAS,CAAC,EAGhB;;MAAA,CAAC,KAAK,CACR;IAAA,EAAE,SAAS,CAAC,CACb,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,116 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import React, { useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Easing, ScrollView } from 'react-native';
|
|
3
|
+
import { Text } from '../Text';
|
|
4
|
+
import { View } from '../View';
|
|
5
|
+
import { useAnimatedVariantStyles } from '../../utils';
|
|
6
|
+
import { SegmentedControlOption } from './Option';
|
|
7
|
+
import { useTheme } from '@codeleap/styles';
|
|
8
|
+
import { MobileStyleRegistry } from '../../Registry';
|
|
9
|
+
import { useStylesFor } from '../../hooks';
|
|
10
|
+
export * from './styles';
|
|
11
|
+
export * from './types';
|
|
12
|
+
const DefaultBubble = (props) => {
|
|
13
|
+
return <View animated {...props}/>;
|
|
12
14
|
};
|
|
13
|
-
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
37
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
38
|
-
};
|
|
39
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
40
|
-
var t = {};
|
|
41
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
42
|
-
t[p] = s[p];
|
|
43
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
44
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
45
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
46
|
-
t[p[i]] = s[p[i]];
|
|
47
|
-
}
|
|
48
|
-
return t;
|
|
49
|
-
};
|
|
50
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.SegmentedControl = void 0;
|
|
52
|
-
var react_1 = __importStar(require("react"));
|
|
53
|
-
var react_native_1 = require("react-native");
|
|
54
|
-
var Text_1 = require("../Text");
|
|
55
|
-
var View_1 = require("../View");
|
|
56
|
-
var utils_1 = require("../../utils");
|
|
57
|
-
var Option_1 = require("./Option");
|
|
58
|
-
var styles_1 = require("@codeleap/styles");
|
|
59
|
-
var Registry_1 = require("../../Registry");
|
|
60
|
-
var hooks_1 = require("../../hooks");
|
|
61
|
-
__exportStar(require("./styles"), exports);
|
|
62
|
-
__exportStar(require("./types"), exports);
|
|
63
|
-
var DefaultBubble = function (props) {
|
|
64
|
-
return <View_1.View animated {...props}/>;
|
|
65
|
-
};
|
|
66
|
-
var defaultAnimation = {
|
|
15
|
+
const defaultAnimation = {
|
|
67
16
|
type: 'timing',
|
|
68
17
|
duration: 200,
|
|
69
|
-
easing:
|
|
18
|
+
easing: Easing.linear,
|
|
70
19
|
};
|
|
71
|
-
|
|
72
|
-
var _a;
|
|
20
|
+
export const SegmentedControl = React.forwardRef((props, ref) => {
|
|
73
21
|
// @ts-expect-error
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
22
|
+
const [themeValues, themeSpacing] = useTheme(store => [store.current?.values, store.current?.spacing]);
|
|
23
|
+
const { options = [], onValueChange, debugName, label, value, animation = {}, scrollProps = {}, getItemWidth = () => (themeValues?.width - themeSpacing?.value?.(4)) / options.length, renderBubble, scrollToCurrentOptionOnMount, renderOption, touchableProps, style, ...viewProps } = {
|
|
24
|
+
...SegmentedControl.defaultProps,
|
|
25
|
+
...props,
|
|
26
|
+
};
|
|
27
|
+
const [bubbleWidth, setBubbleWidth] = useState(0);
|
|
28
|
+
const _animation = {
|
|
29
|
+
...defaultAnimation,
|
|
30
|
+
...animation,
|
|
31
|
+
};
|
|
32
|
+
const styles = useStylesFor(SegmentedControl.styleRegistryName, style);
|
|
33
|
+
const scrollRef = useRef(null);
|
|
80
34
|
function scrollTo(idx) {
|
|
81
35
|
if (!scrollRef.current)
|
|
82
36
|
return;
|
|
83
|
-
setTimeout(
|
|
84
|
-
|
|
85
|
-
(_b = (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollToPosition) === null || _b === void 0 ? void 0 : _b.call(_a, widthStyle.width * idx, 0, true);
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
scrollRef.current?.scrollToPosition?.(widthStyle.width * idx, 0, true);
|
|
86
39
|
});
|
|
87
40
|
}
|
|
88
|
-
|
|
41
|
+
const widthStyle = useMemo(() => {
|
|
89
42
|
if (getItemWidth) {
|
|
90
|
-
|
|
91
|
-
|
|
43
|
+
const sizes = options.map(getItemWidth);
|
|
44
|
+
const maxWidth = sizes.sort((a, b) => b - a)[0];
|
|
92
45
|
return { width: maxWidth };
|
|
93
46
|
}
|
|
94
47
|
return {
|
|
95
48
|
width: bubbleWidth,
|
|
96
49
|
};
|
|
97
50
|
}, [options, bubbleWidth]);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return
|
|
51
|
+
const currentOptionIdx = options.findIndex(o => o.value === value) || 0;
|
|
52
|
+
const onPress = (txt, idx) => {
|
|
53
|
+
return () => {
|
|
101
54
|
onValueChange(txt);
|
|
102
55
|
scrollTo(idx);
|
|
103
56
|
};
|
|
104
57
|
};
|
|
105
|
-
|
|
106
|
-
|
|
58
|
+
const hasScrolledInitially = useRef(false);
|
|
59
|
+
useImperativeHandle(ref, () => {
|
|
107
60
|
if (!scrollRef.current)
|
|
108
61
|
return null;
|
|
109
|
-
return
|
|
62
|
+
return {
|
|
63
|
+
...(scrollRef.current),
|
|
64
|
+
scrollTo,
|
|
65
|
+
scrollToCurrent() {
|
|
110
66
|
if (!scrollRef.current)
|
|
111
67
|
return;
|
|
112
68
|
scrollTo(currentOptionIdx);
|
|
113
|
-
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
114
71
|
}, [
|
|
115
72
|
currentOptionIdx,
|
|
116
73
|
]);
|
|
@@ -118,12 +75,12 @@ exports.SegmentedControl = react_1.default.forwardRef(function (props, ref) {
|
|
|
118
75
|
scrollTo(currentOptionIdx);
|
|
119
76
|
hasScrolledInitially.current = true;
|
|
120
77
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
78
|
+
const BubbleView = renderBubble;
|
|
79
|
+
const Option = renderOption;
|
|
80
|
+
const bubbleAnimation = useAnimatedVariantStyles({
|
|
124
81
|
variantStyles: styles,
|
|
125
82
|
animatedProperties: [],
|
|
126
|
-
updater:
|
|
83
|
+
updater: () => {
|
|
127
84
|
'worklet';
|
|
128
85
|
return {
|
|
129
86
|
translateX: currentOptionIdx * widthStyle.width,
|
|
@@ -132,21 +89,21 @@ exports.SegmentedControl = react_1.default.forwardRef(function (props, ref) {
|
|
|
132
89
|
transition: _animation,
|
|
133
90
|
dependencies: [currentOptionIdx, widthStyle.width],
|
|
134
91
|
});
|
|
135
|
-
|
|
136
|
-
return (<
|
|
137
|
-
<
|
|
138
|
-
<
|
|
139
|
-
</
|
|
92
|
+
const largestWidth = useRef(0);
|
|
93
|
+
return (<View style={styles?.wrapper}>
|
|
94
|
+
<View {...viewProps} style={styles?.labelWrapper}>
|
|
95
|
+
<Text style={styles?.labelText} text={label}/>
|
|
96
|
+
</View>
|
|
140
97
|
|
|
141
|
-
<
|
|
142
|
-
<
|
|
98
|
+
<ScrollView horizontal showsHorizontalScrollIndicator={false} style={styles?.scroll} contentContainerStyle={styles?.scrollContent} {...scrollProps} ref={scrollRef}>
|
|
99
|
+
<View style={styles?.innerWrapper}>
|
|
143
100
|
<BubbleView options={options} animated animatedStyle={bubbleAnimation} style={[
|
|
144
|
-
styles
|
|
145
|
-
|
|
101
|
+
styles?.selectedBubble,
|
|
102
|
+
props?.touchableProps?.disabled && styles?.['selectedBubble:disabled'],
|
|
146
103
|
widthStyle,
|
|
147
104
|
]}/>
|
|
148
|
-
{options.map(
|
|
149
|
-
|
|
105
|
+
{options.map((o, idx) => (<Option debugName={debugName} label={o.label} value={o.value} icon={o.icon} onPress={onPress(o.value, idx)} key={idx} style={widthStyle} selected={value === o.value} variantStyles={styles} onLayout={e => {
|
|
106
|
+
const { width } = e.nativeEvent.layout;
|
|
150
107
|
if (width > largestWidth.current) {
|
|
151
108
|
largestWidth.current = width;
|
|
152
109
|
}
|
|
@@ -154,21 +111,21 @@ exports.SegmentedControl = react_1.default.forwardRef(function (props, ref) {
|
|
|
154
111
|
setBubbleWidth(largestWidth.current);
|
|
155
112
|
largestWidth.current = 0;
|
|
156
113
|
}
|
|
157
|
-
}} {...touchableProps}/>)
|
|
158
|
-
</
|
|
159
|
-
</
|
|
160
|
-
</
|
|
114
|
+
}} {...touchableProps}/>))}
|
|
115
|
+
</View>
|
|
116
|
+
</ScrollView>
|
|
117
|
+
</View>);
|
|
161
118
|
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return
|
|
119
|
+
SegmentedControl.styleRegistryName = 'SegmentedControl';
|
|
120
|
+
SegmentedControl.elements = ['wrapper', 'selectedBubble', 'innerWrapper', 'scroll', 'text', 'icon', 'button', 'label', 'badge'];
|
|
121
|
+
SegmentedControl.rootElement = 'scroll';
|
|
122
|
+
SegmentedControl.withVariantTypes = (styles) => {
|
|
123
|
+
return SegmentedControl;
|
|
167
124
|
};
|
|
168
|
-
|
|
125
|
+
SegmentedControl.defaultProps = {
|
|
169
126
|
renderBubble: DefaultBubble,
|
|
170
|
-
renderOption:
|
|
127
|
+
renderOption: SegmentedControlOption,
|
|
171
128
|
scrollToCurrentOptionOnMount: true,
|
|
172
129
|
};
|
|
173
|
-
|
|
130
|
+
MobileStyleRegistry.registerComponent(SegmentedControl);
|
|
174
131
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SegmentedControl/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SegmentedControl/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAO,MAAM,OAAO,CAAA;AAClF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAEjD,OAAO,EAAmE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,EAAE;IAC9B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAG,CAAA;AACrC,CAAC,CAAA;AAED,MAAM,gBAAgB,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