@ornikar/kitt-universal 16.3.1 → 16.4.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/dist/definitions/GoogleMapsApiKeyProvider/GoogleMapsApiKeyProvider.d.ts +8 -0
- package/dist/definitions/GoogleMapsApiKeyProvider/GoogleMapsApiKeyProvider.d.ts.map +1 -0
- package/dist/definitions/GoogleMapsApiKeyProvider/hooks/useGoogleMapApiKey.d.ts +2 -0
- package/dist/definitions/GoogleMapsApiKeyProvider/hooks/useGoogleMapApiKey.d.ts.map +1 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/GoogleMapsAutocompleteProvider.d.ts +17 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/GoogleMapsAutocompleteProvider.d.ts.map +1 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/hooks/useGoogleMapsApi.d.ts +20 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/hooks/useGoogleMapsApi.d.ts.map +1 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/hooks/useGoogleMapsApi.web.d.ts +3 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/hooks/useGoogleMapsApi.web.d.ts.map +1 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/hooks/useGoogleMapsAutocomplete.d.ts +3 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/hooks/useGoogleMapsAutocomplete.d.ts.map +1 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/reducer/googleMapsAutocompleteReducer.d.ts +40 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/reducer/googleMapsAutocompleteReducer.d.ts.map +1 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/types.d.ts +5 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/types.d.ts.map +1 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/utils/formatAddressFromGoogle.d.ts +20 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/utils/formatAddressFromGoogle.d.ts.map +1 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/utils/makeMapsApiUrl.d.ts +2 -0
- package/dist/definitions/GoogleMapsAutocompleteProvider/utils/makeMapsApiUrl.d.ts.map +1 -0
- package/dist/definitions/forms/Autocomplete/Autocomplete.d.ts +40 -0
- package/dist/definitions/forms/Autocomplete/Autocomplete.d.ts.map +1 -0
- package/dist/definitions/forms/Autocomplete/AutocompleteItem.d.ts +13 -0
- package/dist/definitions/forms/Autocomplete/AutocompleteItem.d.ts.map +1 -0
- package/dist/definitions/forms/Autocomplete/AutocompleteItemsListContainer.d.ts +10 -0
- package/dist/definitions/forms/Autocomplete/AutocompleteItemsListContainer.d.ts.map +1 -0
- package/dist/definitions/forms/Autocomplete/AutocompleteOption.d.ts +8 -0
- package/dist/definitions/forms/Autocomplete/AutocompleteOption.d.ts.map +1 -0
- package/dist/definitions/forms/InputAddress/InputAddress.d.ts +15 -0
- package/dist/definitions/forms/InputAddress/InputAddress.d.ts.map +1 -0
- package/dist/definitions/forms/InputAddress/InputAddressOption.d.ts +7 -0
- package/dist/definitions/forms/InputAddress/InputAddressOption.d.ts.map +1 -0
- package/dist/definitions/forms/InputAddress/utils/defaultItemToString.d.ts +3 -0
- package/dist/definitions/forms/InputAddress/utils/defaultItemToString.d.ts.map +1 -0
- package/dist/definitions/forms/InputAddress/utils/formatInitialValueToAutocompletePrediction.d.ts +4 -0
- package/dist/definitions/forms/InputAddress/utils/formatInitialValueToAutocompletePrediction.d.ts.map +1 -0
- package/dist/definitions/index.d.ts +10 -0
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/definitions/native-base/KittNativeBaseProvider.d.ts +46 -13
- package/dist/definitions/native-base/KittNativeBaseProvider.d.ts.map +1 -1
- package/dist/definitions/story-components/StorySection.d.ts +3 -3
- package/dist/definitions/story-components/StorySection.d.ts.map +1 -1
- package/dist/definitions/themes/default.d.ts +1 -0
- package/dist/definitions/themes/default.d.ts.map +1 -1
- package/dist/definitions/themes/late-ocean/autocomplete.d.ts +37 -0
- package/dist/definitions/themes/late-ocean/autocomplete.d.ts.map +1 -0
- package/dist/definitions/themes/late-ocean/forms.d.ts +1 -0
- package/dist/definitions/themes/late-ocean/forms.d.ts.map +1 -1
- package/dist/index-browser-all.es.android.js +1073 -185
- package/dist/index-browser-all.es.android.js.map +1 -1
- package/dist/index-browser-all.es.ios.js +1073 -185
- package/dist/index-browser-all.es.ios.js.map +1 -1
- package/dist/index-browser-all.es.js +1073 -185
- package/dist/index-browser-all.es.js.map +1 -1
- package/dist/index-browser-all.es.web.js +1040 -190
- package/dist/index-browser-all.es.web.js.map +1 -1
- package/dist/index-node-14.17.cjs.js +931 -142
- package/dist/index-node-14.17.cjs.js.map +1 -1
- package/dist/index-node-14.17.cjs.web.js +892 -111
- package/dist/index-node-14.17.cjs.web.js.map +1 -1
- package/dist/linaria-themes-browser-all.es.android.js +37 -0
- package/dist/linaria-themes-browser-all.es.android.js.map +1 -1
- package/dist/linaria-themes-browser-all.es.ios.js +37 -0
- package/dist/linaria-themes-browser-all.es.ios.js.map +1 -1
- package/dist/linaria-themes-browser-all.es.js +37 -0
- package/dist/linaria-themes-browser-all.es.js.map +1 -1
- package/dist/linaria-themes-browser-all.es.web.js +37 -0
- package/dist/linaria-themes-browser-all.es.web.js.map +1 -1
- package/dist/linaria-themes-node-14.17.cjs.js +37 -0
- package/dist/linaria-themes-node-14.17.cjs.js.map +1 -1
- package/dist/linaria-themes-node-14.17.cjs.web.js +37 -0
- package/dist/linaria-themes-node-14.17.cjs.web.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +6 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext, createContext, forwardRef, cloneElement, useRef, useEffect, useState, useMemo, Children, useReducer, Fragment as Fragment$1,
|
|
1
|
+
import React, { useContext, createContext, forwardRef, cloneElement, useRef, useEffect, useState, useMemo, Children, useReducer, useCallback, Fragment as Fragment$1, createElement } from 'react';
|
|
2
2
|
import { View as View$1, ScrollView as ScrollView$1, Pressable as Pressable$1, Image as Image$1, FlatList as FlatList$1, SectionList as SectionList$1, Stack as Stack$1, VStack as VStack$1, HStack as HStack$1, Center as Center$1, useSx, Text, Input, useBreakpointValue as useBreakpointValue$1, NativeBaseProvider, extendTheme, useMediaQuery } from 'native-base';
|
|
3
3
|
export { useClipboard, useMediaQuery, useSx, useToken } from 'native-base';
|
|
4
4
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
@@ -8,18 +8,21 @@ import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructurin
|
|
|
8
8
|
import _extends from '@babel/runtime/helpers/extends';
|
|
9
9
|
import Animated, { useSharedValue, useAnimatedStyle, interpolateColor, withSpring, withTiming, Easing as Easing$1, runOnJS, useDerivedValue, useAnimatedProps, withDelay, withRepeat, interpolate } from 'react-native-reanimated';
|
|
10
10
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
11
|
-
import { Platform, Animated as Animated$1, Easing, StyleSheet, Modal, ScrollView as ScrollView$2, View as View$2, Linking,
|
|
11
|
+
import { Platform, Animated as Animated$1, Easing, StyleSheet, Modal, ScrollView as ScrollView$2, View as View$2, Linking, Pressable as Pressable$2, Text as Text$1, useWindowDimensions, PixelRatio } from 'react-native';
|
|
12
12
|
export { useWindowDimensions as useWindowSize } from 'react-native';
|
|
13
13
|
import _regeneratorRuntime from '@babel/runtime/helpers/regeneratorRuntime';
|
|
14
14
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
15
|
-
import { ArcIcon, UserIcon, CheckboxMark, EyeOffIcon, EyeIcon, InfoIcon, AlertTriangleIcon, CheckIcon, AlertCircleIcon, XIcon, RotateCCWIcon, TooltipArrowIcon } from '@ornikar/kitt-icons';
|
|
15
|
+
import { ArcIcon, UserIcon, ArrowUpIcon, ArrowDownIcon, CheckboxMark, MapPinIcon, EyeOffIcon, EyeIcon, InfoIcon, AlertTriangleIcon, CheckIcon, AlertCircleIcon, XIcon, RotateCCWIcon, TooltipArrowIcon } from '@ornikar/kitt-icons';
|
|
16
16
|
export * from '@ornikar/kitt-icons';
|
|
17
17
|
import { BottomSheetScrollView, BottomSheetView, useBottomSheetDynamicSnapPoints, BottomSheetModal, BottomSheetHandle, BottomSheetBackdrop } from '@gorhom/bottom-sheet';
|
|
18
18
|
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
19
19
|
import { parse } from 'twemoji-parser';
|
|
20
20
|
import * as WebBrowser from 'expo-web-browser';
|
|
21
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
22
|
+
import Downshift from 'downshift';
|
|
21
23
|
import DateTimePicker, { DateTimePickerAndroid } from '@react-native-community/datetimepicker';
|
|
22
24
|
import { FormattedMessage } from 'react-intl';
|
|
25
|
+
import { useDebouncedCallback } from 'use-debounce';
|
|
23
26
|
import { parseNumber, getCountryCallingCode, isValidNumber } from 'libphonenumber-js';
|
|
24
27
|
import Svg, { Circle as Circle$1 } from 'react-native-svg';
|
|
25
28
|
import { Picker as Picker$1 } from '@react-native-picker/picker';
|
|
@@ -748,6 +751,42 @@ var feedbackMessage = {
|
|
|
748
751
|
}
|
|
749
752
|
};
|
|
750
753
|
|
|
754
|
+
var autocomplete = {
|
|
755
|
+
option: {
|
|
756
|
+
verticalPadding: 2,
|
|
757
|
+
minHeight: 40,
|
|
758
|
+
"default": {
|
|
759
|
+
backgroundColor: colors.white
|
|
760
|
+
},
|
|
761
|
+
hovered: {
|
|
762
|
+
backgroundColor: lateOceanColorPalette.black50
|
|
763
|
+
},
|
|
764
|
+
focused: {
|
|
765
|
+
backgroundColor: lateOceanColorPalette.black50
|
|
766
|
+
},
|
|
767
|
+
selected: {
|
|
768
|
+
backgroundColor: lateOceanColorPalette.black50
|
|
769
|
+
},
|
|
770
|
+
highlighted: {
|
|
771
|
+
backgroundColor: lateOceanColorPalette.black50
|
|
772
|
+
},
|
|
773
|
+
pressed: {
|
|
774
|
+
backgroundColor: lateOceanColorPalette.black100
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
optionsContainer: {
|
|
778
|
+
borderRadius: 10,
|
|
779
|
+
backgroundColor: colors.white,
|
|
780
|
+
shadow: {
|
|
781
|
+
color: colors.black,
|
|
782
|
+
offsetX: 0,
|
|
783
|
+
offsetY: 10,
|
|
784
|
+
opacity: 0.15,
|
|
785
|
+
radius: 20
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
|
|
751
790
|
var checkbox = {
|
|
752
791
|
borderWidth: 2,
|
|
753
792
|
borderRadius: 5,
|
|
@@ -1051,6 +1090,7 @@ var timePicker = {
|
|
|
1051
1090
|
};
|
|
1052
1091
|
|
|
1053
1092
|
var forms = {
|
|
1093
|
+
autocomplete: autocomplete,
|
|
1054
1094
|
datePicker: datePicker,
|
|
1055
1095
|
input: input,
|
|
1056
1096
|
radio: radio,
|
|
@@ -1796,7 +1836,7 @@ var isTypographyHeader = function (type, isHeaderTypographyInContext) {
|
|
|
1796
1836
|
throw new Error('You must set a "base" prop or wrap this Typography in one that does.');
|
|
1797
1837
|
};
|
|
1798
1838
|
|
|
1799
|
-
var _excluded$
|
|
1839
|
+
var _excluded$L = ["accessibilityRole", "base", "small", "medium", "large", "wide", "type", "variant", "color"];
|
|
1800
1840
|
var IsHeaderTypographyContext = /*#__PURE__*/createContext(undefined);
|
|
1801
1841
|
var TypographyColorContext = /*#__PURE__*/createContext('black');
|
|
1802
1842
|
function useTypographyColor() {
|
|
@@ -1846,7 +1886,7 @@ function Typography(_ref) {
|
|
|
1846
1886
|
} : _ref$type,
|
|
1847
1887
|
variant = _ref.variant,
|
|
1848
1888
|
color = _ref.color,
|
|
1849
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
|
1889
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$L);
|
|
1850
1890
|
var sx = useSx();
|
|
1851
1891
|
var isHeaderTypographyInContext = useContext(IsHeaderTypographyContext);
|
|
1852
1892
|
var defaultColor = useTypographyDefaultColor();
|
|
@@ -1951,11 +1991,11 @@ function Icon(_ref) {
|
|
|
1951
1991
|
});
|
|
1952
1992
|
}
|
|
1953
1993
|
|
|
1954
|
-
var _excluded$
|
|
1955
|
-
_excluded2$
|
|
1994
|
+
var _excluded$K = ["color"],
|
|
1995
|
+
_excluded2$6 = ["color"];
|
|
1956
1996
|
function TypographyIconSpecifiedColor(_ref) {
|
|
1957
1997
|
var color = _ref.color,
|
|
1958
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
1998
|
+
props = _objectWithoutProperties(_ref, _excluded$K);
|
|
1959
1999
|
var sx = useSx();
|
|
1960
2000
|
var colorStyle = sx({
|
|
1961
2001
|
color: getTypographyColorValue(color)
|
|
@@ -1970,7 +2010,7 @@ function TypographyIconInheritColor(props) {
|
|
|
1970
2010
|
}
|
|
1971
2011
|
function TypographyIcon(_ref2) {
|
|
1972
2012
|
var color = _ref2.color,
|
|
1973
|
-
props = _objectWithoutProperties(_ref2, _excluded2$
|
|
2013
|
+
props = _objectWithoutProperties(_ref2, _excluded2$6);
|
|
1974
2014
|
if (color) {
|
|
1975
2015
|
return /*#__PURE__*/jsx(TypographyIconSpecifiedColor, _objectSpread({
|
|
1976
2016
|
color: color
|
|
@@ -1999,7 +2039,7 @@ var getTextColorByType = function (type, variant, isHovered, isPressed) {
|
|
|
1999
2039
|
}
|
|
2000
2040
|
};
|
|
2001
2041
|
|
|
2002
|
-
var _excluded$
|
|
2042
|
+
var _excluded$J = ["type", "variant", "isDisabled", "icon", "children", "isHovered", "isPressed", "isFocused"];
|
|
2003
2043
|
function ButtonIcon(_ref) {
|
|
2004
2044
|
var icon = _ref.icon,
|
|
2005
2045
|
color = _ref.color,
|
|
@@ -2074,7 +2114,7 @@ function ButtonContent(_ref3) {
|
|
|
2074
2114
|
isHovered = _ref3.isHovered,
|
|
2075
2115
|
isPressed = _ref3.isPressed;
|
|
2076
2116
|
_ref3.isFocused;
|
|
2077
|
-
var props = _objectWithoutProperties(_ref3, _excluded$
|
|
2117
|
+
var props = _objectWithoutProperties(_ref3, _excluded$J);
|
|
2078
2118
|
var color = isDisabled ? 'black-light' : getTextColorByType(type, variant, isHovered, isPressed);
|
|
2079
2119
|
return /*#__PURE__*/jsx(View, {
|
|
2080
2120
|
_web: {
|
|
@@ -2380,7 +2420,7 @@ function LoaderIcon(_ref) {
|
|
|
2380
2420
|
});
|
|
2381
2421
|
}
|
|
2382
2422
|
|
|
2383
|
-
var _excluded$
|
|
2423
|
+
var _excluded$I = ["as", "onPress", "disabled", "icon", "stretch"];
|
|
2384
2424
|
function ActionsItem(_ref) {
|
|
2385
2425
|
var as = _ref.as,
|
|
2386
2426
|
onPress = _ref.onPress,
|
|
@@ -2391,7 +2431,7 @@ function ActionsItem(_ref) {
|
|
|
2391
2431
|
base: true,
|
|
2392
2432
|
medium: false
|
|
2393
2433
|
} : _ref$stretch,
|
|
2394
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
2434
|
+
props = _objectWithoutProperties(_ref, _excluded$I);
|
|
2395
2435
|
var _useState = useState(false),
|
|
2396
2436
|
_useState2 = _slicedToArray(_useState, 2),
|
|
2397
2437
|
isLoading = _useState2[0],
|
|
@@ -2462,7 +2502,7 @@ function ActionsButton(_ref) {
|
|
|
2462
2502
|
}, props));
|
|
2463
2503
|
}
|
|
2464
2504
|
|
|
2465
|
-
var _excluded$
|
|
2505
|
+
var _excluded$H = ["children", "layout", "reversed"];
|
|
2466
2506
|
function getCurrentLayout(layout) {
|
|
2467
2507
|
if (!layout) return {
|
|
2468
2508
|
base: 'stretch',
|
|
@@ -2491,7 +2531,7 @@ function Actions(_ref) {
|
|
|
2491
2531
|
var children = _ref.children,
|
|
2492
2532
|
layout = _ref.layout,
|
|
2493
2533
|
reversed = _ref.reversed,
|
|
2494
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
2534
|
+
props = _objectWithoutProperties(_ref, _excluded$H);
|
|
2495
2535
|
var currentAlignItems = getCurrentLayout(layout);
|
|
2496
2536
|
var currentDirection = getCurrentDirection(layout);
|
|
2497
2537
|
var currentAlignSelf = getCurrentAlignSelf(layout);
|
|
@@ -2540,7 +2580,7 @@ function getInitials(firstname, lastname) {
|
|
|
2540
2580
|
return "".concat(firstname[0]).concat(lastname[0]).toUpperCase();
|
|
2541
2581
|
}
|
|
2542
2582
|
|
|
2543
|
-
var _excluded$
|
|
2583
|
+
var _excluded$G = ["size", "round", "light", "sizeVariant"];
|
|
2544
2584
|
function AvatarContent(_ref) {
|
|
2545
2585
|
var size = _ref.size,
|
|
2546
2586
|
src = _ref.src,
|
|
@@ -2579,7 +2619,7 @@ function Avatar(_ref2) {
|
|
|
2579
2619
|
round = _ref2.round,
|
|
2580
2620
|
light = _ref2.light,
|
|
2581
2621
|
sizeVariant = _ref2.sizeVariant,
|
|
2582
|
-
props = _objectWithoutProperties(_ref2, _excluded$
|
|
2622
|
+
props = _objectWithoutProperties(_ref2, _excluded$G);
|
|
2583
2623
|
var currentSize = getCurrentSize({
|
|
2584
2624
|
size: size,
|
|
2585
2625
|
sizeVariant: sizeVariant
|
|
@@ -2990,11 +3030,11 @@ function CardModalAnimation(_ref) {
|
|
|
2990
3030
|
});
|
|
2991
3031
|
}
|
|
2992
3032
|
|
|
2993
|
-
var _excluded$
|
|
2994
|
-
_excluded2$
|
|
3033
|
+
var _excluded$F = ["children"],
|
|
3034
|
+
_excluded2$5 = ["children", "visible", "onClose", "onExited"];
|
|
2995
3035
|
function CardModalScrollContainer(_ref) {
|
|
2996
3036
|
var children = _ref.children,
|
|
2997
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
3037
|
+
props = _objectWithoutProperties(_ref, _excluded$F);
|
|
2998
3038
|
if (Platform.OS !== 'web') {
|
|
2999
3039
|
return /*#__PURE__*/jsx(View, {
|
|
3000
3040
|
children: children
|
|
@@ -3009,7 +3049,7 @@ function CardModalBehaviour(_ref2) {
|
|
|
3009
3049
|
visible = _ref2.visible,
|
|
3010
3050
|
onClose = _ref2.onClose,
|
|
3011
3051
|
onExited = _ref2.onExited,
|
|
3012
|
-
props = _objectWithoutProperties(_ref2, _excluded2$
|
|
3052
|
+
props = _objectWithoutProperties(_ref2, _excluded2$5);
|
|
3013
3053
|
var _useState = useState(visible),
|
|
3014
3054
|
_useState2 = _slicedToArray(_useState, 2),
|
|
3015
3055
|
isModalBehaviourVisible = _useState2[0],
|
|
@@ -3040,7 +3080,7 @@ function CardModalBehaviour(_ref2) {
|
|
|
3040
3080
|
});
|
|
3041
3081
|
}
|
|
3042
3082
|
|
|
3043
|
-
var _excluded$
|
|
3083
|
+
var _excluded$E = ["children", "paddingX", "paddingY"];
|
|
3044
3084
|
function CardModalBody(_ref) {
|
|
3045
3085
|
var children = _ref.children,
|
|
3046
3086
|
_ref$paddingX = _ref.paddingX,
|
|
@@ -3050,7 +3090,7 @@ function CardModalBody(_ref) {
|
|
|
3050
3090
|
} : _ref$paddingX,
|
|
3051
3091
|
_ref$paddingY = _ref.paddingY,
|
|
3052
3092
|
paddingY = _ref$paddingY === void 0 ? 'kitt.4' : _ref$paddingY,
|
|
3053
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
3093
|
+
props = _objectWithoutProperties(_ref, _excluded$E);
|
|
3054
3094
|
return /*#__PURE__*/jsx(View, _objectSpread(_objectSpread({
|
|
3055
3095
|
paddingX: paddingX,
|
|
3056
3096
|
paddingY: paddingY
|
|
@@ -3059,7 +3099,7 @@ function CardModalBody(_ref) {
|
|
|
3059
3099
|
}));
|
|
3060
3100
|
}
|
|
3061
3101
|
|
|
3062
|
-
var _excluded$
|
|
3102
|
+
var _excluded$D = ["children", "padding", "hasSeparator"];
|
|
3063
3103
|
function CardModalFooter(_ref) {
|
|
3064
3104
|
var children = _ref.children,
|
|
3065
3105
|
_ref$padding = _ref.padding,
|
|
@@ -3069,7 +3109,7 @@ function CardModalFooter(_ref) {
|
|
|
3069
3109
|
} : _ref$padding,
|
|
3070
3110
|
_ref$hasSeparator = _ref.hasSeparator,
|
|
3071
3111
|
hasSeparator = _ref$hasSeparator === void 0 ? true : _ref$hasSeparator,
|
|
3072
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
3112
|
+
props = _objectWithoutProperties(_ref, _excluded$D);
|
|
3073
3113
|
return /*#__PURE__*/jsx(View, _objectSpread(_objectSpread({}, props), {}, {
|
|
3074
3114
|
marginTop: "kitt.2",
|
|
3075
3115
|
padding: padding,
|
|
@@ -3083,7 +3123,7 @@ function CardModalFooter(_ref) {
|
|
|
3083
3123
|
}));
|
|
3084
3124
|
}
|
|
3085
3125
|
|
|
3086
|
-
var _excluded$
|
|
3126
|
+
var _excluded$C = ["children", "title", "paddingBottom", "hasSeparator", "right", "left"];
|
|
3087
3127
|
function CardModalHeader(_ref) {
|
|
3088
3128
|
var children = _ref.children,
|
|
3089
3129
|
title = _ref.title,
|
|
@@ -3096,7 +3136,7 @@ function CardModalHeader(_ref) {
|
|
|
3096
3136
|
hasSeparator = _ref$hasSeparator === void 0 ? true : _ref$hasSeparator,
|
|
3097
3137
|
right = _ref.right,
|
|
3098
3138
|
left = _ref.left,
|
|
3099
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
3139
|
+
props = _objectWithoutProperties(_ref, _excluded$C);
|
|
3100
3140
|
var defaultContainerPadding = {
|
|
3101
3141
|
base: 'kitt.4',
|
|
3102
3142
|
medium: 'kitt.6'
|
|
@@ -3134,7 +3174,7 @@ function CardModalHeader(_ref) {
|
|
|
3134
3174
|
}));
|
|
3135
3175
|
}
|
|
3136
3176
|
|
|
3137
|
-
var _excluded$
|
|
3177
|
+
var _excluded$B = ["backgroundColor", "maxWidth", "withoutShadow", "children", "header", "body", "footer"];
|
|
3138
3178
|
function CardModal(_ref) {
|
|
3139
3179
|
var _ref$backgroundColor = _ref.backgroundColor,
|
|
3140
3180
|
backgroundColor = _ref$backgroundColor === void 0 ? 'kitt.uiBackgroundLight' : _ref$backgroundColor,
|
|
@@ -3145,7 +3185,7 @@ function CardModal(_ref) {
|
|
|
3145
3185
|
header = _ref.header,
|
|
3146
3186
|
body = _ref.body,
|
|
3147
3187
|
footer = _ref.footer,
|
|
3148
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
3188
|
+
props = _objectWithoutProperties(_ref, _excluded$B);
|
|
3149
3189
|
return /*#__PURE__*/jsx(View, _objectSpread(_objectSpread({}, props), {}, {
|
|
3150
3190
|
overflow: "hidden",
|
|
3151
3191
|
backgroundColor: backgroundColor,
|
|
@@ -3164,7 +3204,7 @@ CardModal.Header = CardModalHeader;
|
|
|
3164
3204
|
CardModal.Footer = CardModalFooter;
|
|
3165
3205
|
CardModal.ModalBehaviour = CardModalBehaviour;
|
|
3166
3206
|
|
|
3167
|
-
function getBackgroundColor$
|
|
3207
|
+
function getBackgroundColor$4(_ref) {
|
|
3168
3208
|
var isDisabled = _ref.isDisabled,
|
|
3169
3209
|
isSelected = _ref.isSelected,
|
|
3170
3210
|
isHovered = _ref.isHovered,
|
|
@@ -3196,7 +3236,7 @@ function AnimatedChoiceItemView(_ref) {
|
|
|
3196
3236
|
var style = sx({
|
|
3197
3237
|
position: 'relative',
|
|
3198
3238
|
borderRadius: getBorderRadius(variant),
|
|
3199
|
-
backgroundColor: getBackgroundColor$
|
|
3239
|
+
backgroundColor: getBackgroundColor$4({
|
|
3200
3240
|
isDisabled: isDisabled,
|
|
3201
3241
|
isSelected: isSelected,
|
|
3202
3242
|
isHovered: isHovered,
|
|
@@ -3403,10 +3443,10 @@ function ChoiceItemContainer(_ref) {
|
|
|
3403
3443
|
});
|
|
3404
3444
|
}
|
|
3405
3445
|
|
|
3406
|
-
var _excluded$
|
|
3446
|
+
var _excluded$A = ["direction"];
|
|
3407
3447
|
function ChoicesContainer(_ref) {
|
|
3408
3448
|
var direction = _ref.direction,
|
|
3409
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
3449
|
+
props = _objectWithoutProperties(_ref, _excluded$A);
|
|
3410
3450
|
if (direction === 'row') {
|
|
3411
3451
|
return /*#__PURE__*/jsx(ScrollView$2, _objectSpread({
|
|
3412
3452
|
horizontal: true
|
|
@@ -3700,13 +3740,13 @@ function DialogModalAnimation(_ref) {
|
|
|
3700
3740
|
});
|
|
3701
3741
|
}
|
|
3702
3742
|
|
|
3703
|
-
var _excluded$
|
|
3743
|
+
var _excluded$z = ["children", "visible", "onClose", "onExited"];
|
|
3704
3744
|
function DialogModalBehaviour(_ref) {
|
|
3705
3745
|
var children = _ref.children,
|
|
3706
3746
|
visible = _ref.visible,
|
|
3707
3747
|
onClose = _ref.onClose,
|
|
3708
3748
|
onExited = _ref.onExited,
|
|
3709
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
3749
|
+
props = _objectWithoutProperties(_ref, _excluded$z);
|
|
3710
3750
|
var _useState = useState(visible),
|
|
3711
3751
|
_useState2 = _slicedToArray(_useState, 2),
|
|
3712
3752
|
isModalBehaviourVisible = _useState2[0],
|
|
@@ -3737,7 +3777,7 @@ function DialogModalBehaviour(_ref) {
|
|
|
3737
3777
|
});
|
|
3738
3778
|
}
|
|
3739
3779
|
|
|
3740
|
-
var _excluded$
|
|
3780
|
+
var _excluded$y = ["stretch"];
|
|
3741
3781
|
function DialogModal(_ref) {
|
|
3742
3782
|
var illustration = _ref.illustration,
|
|
3743
3783
|
title = _ref.title,
|
|
@@ -3778,7 +3818,7 @@ DialogModal.ModalBehaviour = DialogModalBehaviour;
|
|
|
3778
3818
|
function DialogModalButton(_ref2) {
|
|
3779
3819
|
var _ref2$stretch = _ref2.stretch,
|
|
3780
3820
|
stretch = _ref2$stretch === void 0 ? true : _ref2$stretch,
|
|
3781
|
-
props = _objectWithoutProperties(_ref2, _excluded$
|
|
3821
|
+
props = _objectWithoutProperties(_ref2, _excluded$y);
|
|
3782
3822
|
return /*#__PURE__*/jsx(Actions.Button, _objectSpread({
|
|
3783
3823
|
stretch: stretch
|
|
3784
3824
|
}, props));
|
|
@@ -3815,17 +3855,17 @@ function Emoji(_ref) {
|
|
|
3815
3855
|
});
|
|
3816
3856
|
}
|
|
3817
3857
|
|
|
3818
|
-
var _excluded$
|
|
3819
|
-
_excluded2$
|
|
3820
|
-
_excluded3$
|
|
3821
|
-
_excluded4$
|
|
3858
|
+
var _excluded$x = ["as", "appScheme", "appValue", "onPress", "onOpenAppError"],
|
|
3859
|
+
_excluded2$4 = ["phoneNumber", "children"],
|
|
3860
|
+
_excluded3$3 = ["phoneNumber", "children"],
|
|
3861
|
+
_excluded4$3 = ["emailAddress", "children"];
|
|
3822
3862
|
function ExternalAppLink(_ref) {
|
|
3823
3863
|
var Component = _ref.as,
|
|
3824
3864
|
appScheme = _ref.appScheme,
|
|
3825
3865
|
appValue = _ref.appValue,
|
|
3826
3866
|
onPress = _ref.onPress,
|
|
3827
3867
|
onOpenAppError = _ref.onOpenAppError,
|
|
3828
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
3868
|
+
rest = _objectWithoutProperties(_ref, _excluded$x);
|
|
3829
3869
|
var href = "".concat(appScheme, ":").concat(appValue);
|
|
3830
3870
|
var handleOnPress = /*#__PURE__*/function () {
|
|
3831
3871
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
|
|
@@ -3887,7 +3927,7 @@ function ExternalAppLink(_ref) {
|
|
|
3887
3927
|
ExternalAppLink.Sms = function (_ref3) {
|
|
3888
3928
|
var phoneNumber = _ref3.phoneNumber,
|
|
3889
3929
|
children = _ref3.children,
|
|
3890
|
-
rest = _objectWithoutProperties(_ref3, _excluded2$
|
|
3930
|
+
rest = _objectWithoutProperties(_ref3, _excluded2$4);
|
|
3891
3931
|
return /*#__PURE__*/jsx(ExternalAppLink, _objectSpread(_objectSpread({}, rest), {}, {
|
|
3892
3932
|
appScheme: "sms",
|
|
3893
3933
|
appValue: phoneNumber,
|
|
@@ -3897,7 +3937,7 @@ ExternalAppLink.Sms = function (_ref3) {
|
|
|
3897
3937
|
ExternalAppLink.Tel = function (_ref4) {
|
|
3898
3938
|
var phoneNumber = _ref4.phoneNumber,
|
|
3899
3939
|
children = _ref4.children,
|
|
3900
|
-
rest = _objectWithoutProperties(_ref4, _excluded3$
|
|
3940
|
+
rest = _objectWithoutProperties(_ref4, _excluded3$3);
|
|
3901
3941
|
return /*#__PURE__*/jsx(ExternalAppLink, _objectSpread(_objectSpread({}, rest), {}, {
|
|
3902
3942
|
appScheme: "tel",
|
|
3903
3943
|
appValue: phoneNumber,
|
|
@@ -3907,7 +3947,7 @@ ExternalAppLink.Tel = function (_ref4) {
|
|
|
3907
3947
|
ExternalAppLink.Mail = function (_ref5) {
|
|
3908
3948
|
var emailAddress = _ref5.emailAddress,
|
|
3909
3949
|
children = _ref5.children,
|
|
3910
|
-
rest = _objectWithoutProperties(_ref5, _excluded4$
|
|
3950
|
+
rest = _objectWithoutProperties(_ref5, _excluded4$3);
|
|
3911
3951
|
return /*#__PURE__*/jsx(ExternalAppLink, _objectSpread(_objectSpread({}, rest), {}, {
|
|
3912
3952
|
appScheme: "mailto",
|
|
3913
3953
|
appValue: emailAddress,
|
|
@@ -3920,7 +3960,7 @@ var defaultOpenLinkBehavior = {
|
|
|
3920
3960
|
web: 'targetBlank'
|
|
3921
3961
|
};
|
|
3922
3962
|
|
|
3923
|
-
var _excluded$
|
|
3963
|
+
var _excluded$w = ["as", "href", "openLinkBehavior", "onPress", "onOpenLinkError"];
|
|
3924
3964
|
function ExternalLink(_ref) {
|
|
3925
3965
|
var Component = _ref.as,
|
|
3926
3966
|
href = _ref.href,
|
|
@@ -3929,7 +3969,7 @@ function ExternalLink(_ref) {
|
|
|
3929
3969
|
onPress = _ref.onPress,
|
|
3930
3970
|
_ref$onOpenLinkError = _ref.onOpenLinkError,
|
|
3931
3971
|
onOpenLinkError = _ref$onOpenLinkError === void 0 ? console.error : _ref$onOpenLinkError,
|
|
3932
|
-
rest = _objectWithoutProperties(_ref, _excluded$
|
|
3972
|
+
rest = _objectWithoutProperties(_ref, _excluded$w);
|
|
3933
3973
|
return /*#__PURE__*/jsx(Component, _objectSpread(_objectSpread({}, rest), {}, {
|
|
3934
3974
|
onPress: function handleOnPress(e) {
|
|
3935
3975
|
if (onPress) {
|
|
@@ -3958,6 +3998,404 @@ function ExternalLink(_ref) {
|
|
|
3958
3998
|
}));
|
|
3959
3999
|
}
|
|
3960
4000
|
|
|
4001
|
+
function getIconColor(state, disabled) {
|
|
4002
|
+
if (disabled) return 'black-light';
|
|
4003
|
+
switch (state) {
|
|
4004
|
+
case 'invalid':
|
|
4005
|
+
return 'danger';
|
|
4006
|
+
case 'valid':
|
|
4007
|
+
return 'success';
|
|
4008
|
+
default:
|
|
4009
|
+
return undefined;
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
function InputIcon(_ref) {
|
|
4013
|
+
var icon = _ref.icon,
|
|
4014
|
+
state = _ref.state,
|
|
4015
|
+
disabled = _ref.disabled;
|
|
4016
|
+
var theme = useTheme();
|
|
4017
|
+
var color = getIconColor(state, disabled);
|
|
4018
|
+
return /*#__PURE__*/jsx(TypographyIcon, {
|
|
4019
|
+
color: color,
|
|
4020
|
+
icon: icon,
|
|
4021
|
+
size: theme.kitt.forms.input.icon.size
|
|
4022
|
+
});
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
function InputPressable(_ref) {
|
|
4026
|
+
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
4027
|
+
return /*#__PURE__*/jsx(Pressable$2, _objectSpread({}, props));
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
function InputTextContainer(_ref) {
|
|
4031
|
+
var children = _ref.children;
|
|
4032
|
+
return /*#__PURE__*/jsx(View, {
|
|
4033
|
+
position: "relative",
|
|
4034
|
+
children: children
|
|
4035
|
+
});
|
|
4036
|
+
}
|
|
4037
|
+
|
|
4038
|
+
var _excluded$v = ["id", "right", "state", "variant", "internalForceState", "disabled", "autoCorrect", "textContentType", "autoComplete", "keyboardType", "multiline", "onSubmitEditing"];
|
|
4039
|
+
var InputText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
4040
|
+
var id = _ref.id,
|
|
4041
|
+
right = _ref.right;
|
|
4042
|
+
_ref.state;
|
|
4043
|
+
var _ref$variant = _ref.variant,
|
|
4044
|
+
variant = _ref$variant === void 0 ? 'outline' : _ref$variant,
|
|
4045
|
+
internalForceState = _ref.internalForceState,
|
|
4046
|
+
_ref$disabled = _ref.disabled,
|
|
4047
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
4048
|
+
_ref$autoCorrect = _ref.autoCorrect,
|
|
4049
|
+
autoCorrect = _ref$autoCorrect === void 0 ? true : _ref$autoCorrect,
|
|
4050
|
+
_ref$textContentType = _ref.textContentType,
|
|
4051
|
+
textContentType = _ref$textContentType === void 0 ? 'none' : _ref$textContentType,
|
|
4052
|
+
_ref$autoComplete = _ref.autoComplete,
|
|
4053
|
+
autoComplete = _ref$autoComplete === void 0 ? 'off' : _ref$autoComplete,
|
|
4054
|
+
_ref$keyboardType = _ref.keyboardType,
|
|
4055
|
+
keyboardType = _ref$keyboardType === void 0 ? 'default' : _ref$keyboardType,
|
|
4056
|
+
multiline = _ref.multiline,
|
|
4057
|
+
onSubmitEditing = _ref.onSubmitEditing,
|
|
4058
|
+
props = _objectWithoutProperties(_ref, _excluded$v);
|
|
4059
|
+
var theme = useTheme();
|
|
4060
|
+
var fontSizeForNativeBase = createNativeBaseFontSize({
|
|
4061
|
+
base: 'body'
|
|
4062
|
+
});
|
|
4063
|
+
var shouldHandleSingleLineOnIOS = Platform.OS === 'ios' && !multiline;
|
|
4064
|
+
return /*#__PURE__*/jsxs(InputTextContainer, {
|
|
4065
|
+
children: [/*#__PURE__*/jsx(Input, _objectSpread(_objectSpread({
|
|
4066
|
+
ref: ref,
|
|
4067
|
+
multiline: multiline,
|
|
4068
|
+
nativeID: id,
|
|
4069
|
+
isDisabled: internalForceState ? internalForceState === 'disabled' : disabled,
|
|
4070
|
+
isHovered: internalForceState ? internalForceState === 'hover' : undefined,
|
|
4071
|
+
isFocused: internalForceState ? internalForceState === 'focus' : undefined,
|
|
4072
|
+
keyboardType: keyboardType,
|
|
4073
|
+
autoComplete: autoComplete,
|
|
4074
|
+
autoCorrect: autoCorrect,
|
|
4075
|
+
textContentType: textContentType,
|
|
4076
|
+
fontSize: fontSizeForNativeBase,
|
|
4077
|
+
lineHeight:
|
|
4078
|
+
// On basic text input, we set the line-height to zero for iOS to fix vertical text alignment
|
|
4079
|
+
// This is a iOS only fix since having 0 as a line-height value breaks text inputs on Android
|
|
4080
|
+
shouldHandleSingleLineOnIOS ? 0 : fontSizeForNativeBase,
|
|
4081
|
+
fontWeight: "bodies.regular",
|
|
4082
|
+
fontFamily: "bodies.regular",
|
|
4083
|
+
py: !multiline && Platform.OS !== 'web' ? 0 : undefined,
|
|
4084
|
+
variant: variant
|
|
4085
|
+
}, props), {}, {
|
|
4086
|
+
onSubmitEditing: multiline ? function () {
|
|
4087
|
+
return null;
|
|
4088
|
+
} : onSubmitEditing
|
|
4089
|
+
})), right ? /*#__PURE__*/jsx(View, {
|
|
4090
|
+
position: "absolute",
|
|
4091
|
+
right: 0,
|
|
4092
|
+
top: 0,
|
|
4093
|
+
bottom: 0,
|
|
4094
|
+
justifyContent: "center",
|
|
4095
|
+
padding: theme.kitt.forms.input.rightContainer.padding,
|
|
4096
|
+
children: right
|
|
4097
|
+
}) : null]
|
|
4098
|
+
});
|
|
4099
|
+
});
|
|
4100
|
+
|
|
4101
|
+
function getBackgroundColor$3(_ref) {
|
|
4102
|
+
var isSelected = _ref.isSelected,
|
|
4103
|
+
isHighlighted = _ref.isHighlighted,
|
|
4104
|
+
isPressed = _ref.isPressed,
|
|
4105
|
+
isHovered = _ref.isHovered,
|
|
4106
|
+
isFocused = _ref.isFocused;
|
|
4107
|
+
var baseKey = 'kitt.forms.autocomplete.option';
|
|
4108
|
+
if (isHighlighted) {
|
|
4109
|
+
return "".concat(baseKey, ".highlighted.backgroundColor");
|
|
4110
|
+
}
|
|
4111
|
+
if (isPressed) {
|
|
4112
|
+
return "".concat(baseKey, ".pressed.backgroundColor");
|
|
4113
|
+
}
|
|
4114
|
+
if (isHovered) {
|
|
4115
|
+
return "".concat(baseKey, ".hovered.backgroundColor");
|
|
4116
|
+
}
|
|
4117
|
+
if (isFocused) {
|
|
4118
|
+
return "".concat(baseKey, ".focused.backgroundColor");
|
|
4119
|
+
}
|
|
4120
|
+
if (isSelected) {
|
|
4121
|
+
return "".concat(baseKey, ".selected.backgroundColor");
|
|
4122
|
+
}
|
|
4123
|
+
return "".concat(baseKey, ".default.backgroundColor");
|
|
4124
|
+
}
|
|
4125
|
+
function AutocompleteItem(_ref2) {
|
|
4126
|
+
var children = _ref2.children,
|
|
4127
|
+
isSelected = _ref2.isSelected,
|
|
4128
|
+
isHighlighted = _ref2.isHighlighted,
|
|
4129
|
+
isHovered = _ref2.isHovered,
|
|
4130
|
+
isFocused = _ref2.isFocused,
|
|
4131
|
+
isPressed = _ref2.isPressed;
|
|
4132
|
+
return /*#__PURE__*/jsx(View, {
|
|
4133
|
+
justifyContent: "center",
|
|
4134
|
+
width: "100%",
|
|
4135
|
+
minHeight: "kitt.forms.autocomplete.option.minHeight",
|
|
4136
|
+
borderRadius: "kitt.1",
|
|
4137
|
+
padding: "kitt.1",
|
|
4138
|
+
backgroundColor: getBackgroundColor$3({
|
|
4139
|
+
isSelected: isSelected,
|
|
4140
|
+
isHighlighted: isHighlighted,
|
|
4141
|
+
isPressed: isPressed,
|
|
4142
|
+
isHovered: isHovered,
|
|
4143
|
+
isFocused: isFocused
|
|
4144
|
+
}),
|
|
4145
|
+
children: children
|
|
4146
|
+
});
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
function AutocompleteItemsListContainer(_ref) {
|
|
4150
|
+
var testID = _ref.testID,
|
|
4151
|
+
children = _ref.children,
|
|
4152
|
+
_ref$zIndex = _ref.zIndex,
|
|
4153
|
+
zIndex = _ref$zIndex === void 0 ? 1000 : _ref$zIndex;
|
|
4154
|
+
return /*#__PURE__*/jsx(View, {
|
|
4155
|
+
testID: testID,
|
|
4156
|
+
zIndex: zIndex,
|
|
4157
|
+
top: "kitt.2",
|
|
4158
|
+
left: 0,
|
|
4159
|
+
position: "absolute",
|
|
4160
|
+
flexGrow: 1,
|
|
4161
|
+
width: "100%",
|
|
4162
|
+
paddingY: "kitt.2",
|
|
4163
|
+
borderRadius: "kitt.forms.autocomplete.optionsContainer.borderRadius",
|
|
4164
|
+
backgroundColor: "kitt.forms.autocomplete.optionsContainer.backgroundColor",
|
|
4165
|
+
shadow: "kitt.forms.autocomplete.optionsContainer.shadow",
|
|
4166
|
+
_android: {
|
|
4167
|
+
style: {
|
|
4168
|
+
elevation: 2
|
|
4169
|
+
}
|
|
4170
|
+
},
|
|
4171
|
+
children: children
|
|
4172
|
+
});
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
var _excluded$u = ["children"];
|
|
4176
|
+
function AutocompleteOption(_ref) {
|
|
4177
|
+
var children = _ref.children,
|
|
4178
|
+
props = _objectWithoutProperties(_ref, _excluded$u);
|
|
4179
|
+
return /*#__PURE__*/jsx(View, _objectSpread(_objectSpread({
|
|
4180
|
+
paddingX: {
|
|
4181
|
+
base: 'kitt.2',
|
|
4182
|
+
small: 'kitt.4'
|
|
4183
|
+
},
|
|
4184
|
+
paddingY: "kitt.forms.autocomplete.option.verticalPadding"
|
|
4185
|
+
}, props), {}, {
|
|
4186
|
+
children: children
|
|
4187
|
+
}));
|
|
4188
|
+
}
|
|
4189
|
+
|
|
4190
|
+
var _excluded$t = ["children", "name", "disabled", "placeholder", "isInitialOpen", "initialValue", "containerProps", "filterItemBasedOnCurrentInputValue", "checkSelectedItem", "itemToString", "right", "onChange", "onFocus", "onBlur", "onInputChange", "onSelectItem", "onOuterPress", "errorElement", "emptyResultsElement", "inputTestID", "listContainerTestID", "zIndex"],
|
|
4191
|
+
_excluded2$3 = ["onClick", "onPress"],
|
|
4192
|
+
_excluded3$2 = ["onKeyDown", "onFocus", "onBlur", "onChange"],
|
|
4193
|
+
_excluded4$2 = ["onClick", "onPress", "role", "aria-selected"];
|
|
4194
|
+
function patchNativeEvent(event) {
|
|
4195
|
+
return event || {
|
|
4196
|
+
preventDownshiftDefault: false,
|
|
4197
|
+
preventDefault: function preventDefault() {}
|
|
4198
|
+
};
|
|
4199
|
+
}
|
|
4200
|
+
function isReactElement(element) {
|
|
4201
|
+
return _typeof(element) === 'object' && element !== null && 'type' in element && 'props' in element;
|
|
4202
|
+
}
|
|
4203
|
+
function Autocomplete(_ref) {
|
|
4204
|
+
var _children = _ref.children,
|
|
4205
|
+
name = _ref.name,
|
|
4206
|
+
disabled = _ref.disabled,
|
|
4207
|
+
placeholder = _ref.placeholder,
|
|
4208
|
+
isInitialOpen = _ref.isInitialOpen,
|
|
4209
|
+
initialValue = _ref.initialValue,
|
|
4210
|
+
containerProps = _ref.containerProps,
|
|
4211
|
+
filterItemBasedOnCurrentInputValue = _ref.filterItemBasedOnCurrentInputValue,
|
|
4212
|
+
checkSelectedItem = _ref.checkSelectedItem,
|
|
4213
|
+
itemToString = _ref.itemToString,
|
|
4214
|
+
right = _ref.right,
|
|
4215
|
+
_onChange = _ref.onChange,
|
|
4216
|
+
_onFocus = _ref.onFocus,
|
|
4217
|
+
_onBlur = _ref.onBlur,
|
|
4218
|
+
onInputChange = _ref.onInputChange,
|
|
4219
|
+
onSelectItem = _ref.onSelectItem,
|
|
4220
|
+
onOuterPress = _ref.onOuterPress,
|
|
4221
|
+
errorElement = _ref.errorElement,
|
|
4222
|
+
emptyResultsElement = _ref.emptyResultsElement,
|
|
4223
|
+
_ref$inputTestID = _ref.inputTestID,
|
|
4224
|
+
inputTestID = _ref$inputTestID === void 0 ? 'kitt.Autocomplete.inputText' : _ref$inputTestID,
|
|
4225
|
+
_ref$listContainerTes = _ref.listContainerTestID,
|
|
4226
|
+
listContainerTestID = _ref$listContainerTes === void 0 ? 'kitt.Autocomplete.listContainer' : _ref$listContainerTes,
|
|
4227
|
+
_ref$zIndex = _ref.zIndex,
|
|
4228
|
+
zIndex = _ref$zIndex === void 0 ? 1000 : _ref$zIndex,
|
|
4229
|
+
props = _objectWithoutProperties(_ref, _excluded$t);
|
|
4230
|
+
var childrenArray = Children.toArray(_children);
|
|
4231
|
+
var items = childrenArray.filter(isReactElement).map(function (child) {
|
|
4232
|
+
return {
|
|
4233
|
+
child: child,
|
|
4234
|
+
item: child.props.item
|
|
4235
|
+
};
|
|
4236
|
+
});
|
|
4237
|
+
return /*#__PURE__*/jsx(Downshift, {
|
|
4238
|
+
defaultIsOpen: isInitialOpen,
|
|
4239
|
+
initialSelectedItem: initialValue,
|
|
4240
|
+
initialInputValue: initialValue ? itemToString(initialValue) : undefined,
|
|
4241
|
+
itemToString: function handleItemToString(item) {
|
|
4242
|
+
// Prevents returning null values
|
|
4243
|
+
if (!itemToString) return '';
|
|
4244
|
+
return itemToString(item || undefined);
|
|
4245
|
+
},
|
|
4246
|
+
stateReducer: function stateReducer(state, changes) {
|
|
4247
|
+
switch (changes.type) {
|
|
4248
|
+
case Downshift.stateChangeTypes.changeInput:
|
|
4249
|
+
return _objectSpread(_objectSpread({}, changes), {}, {
|
|
4250
|
+
selectedItem: null
|
|
4251
|
+
});
|
|
4252
|
+
default:
|
|
4253
|
+
return changes;
|
|
4254
|
+
}
|
|
4255
|
+
},
|
|
4256
|
+
onChange: function onChange(selectedItem, stateAndHelpers) {
|
|
4257
|
+
if (_onChange) {
|
|
4258
|
+
_onChange(selectedItem, stateAndHelpers);
|
|
4259
|
+
}
|
|
4260
|
+
},
|
|
4261
|
+
onSelect: onSelectItem,
|
|
4262
|
+
onOuterClick: onOuterPress,
|
|
4263
|
+
onInputValueChange: onInputChange,
|
|
4264
|
+
children: function children(_ref2) {
|
|
4265
|
+
var getRootProps = _ref2.getRootProps,
|
|
4266
|
+
getInputProps = _ref2.getInputProps,
|
|
4267
|
+
getMenuProps = _ref2.getMenuProps,
|
|
4268
|
+
getItemProps = _ref2.getItemProps,
|
|
4269
|
+
getToggleButtonProps = _ref2.getToggleButtonProps,
|
|
4270
|
+
isOpen = _ref2.isOpen,
|
|
4271
|
+
inputValue = _ref2.inputValue,
|
|
4272
|
+
highlightedIndex = _ref2.highlightedIndex,
|
|
4273
|
+
selectedItem = _ref2.selectedItem,
|
|
4274
|
+
openMenu = _ref2.openMenu;
|
|
4275
|
+
var shouldSuppressRefError = Platform.OS !== 'web';
|
|
4276
|
+
var rootProps = getRootProps(undefined, {
|
|
4277
|
+
suppressRefError: shouldSuppressRefError
|
|
4278
|
+
});
|
|
4279
|
+
var menuProps = getMenuProps(undefined, {
|
|
4280
|
+
suppressRefError: shouldSuppressRefError
|
|
4281
|
+
});
|
|
4282
|
+
var _getToggleButtonProps = getToggleButtonProps({
|
|
4283
|
+
disabled: disabled
|
|
4284
|
+
}),
|
|
4285
|
+
onClickToggle = _getToggleButtonProps.onClick,
|
|
4286
|
+
onPressToggle = _getToggleButtonProps.onPress,
|
|
4287
|
+
toggleProps = _objectWithoutProperties(_getToggleButtonProps, _excluded2$3);
|
|
4288
|
+
var _getInputProps = getInputProps({
|
|
4289
|
+
placeholder: placeholder,
|
|
4290
|
+
disabled: disabled
|
|
4291
|
+
}),
|
|
4292
|
+
onKeyDown = _getInputProps.onKeyDown,
|
|
4293
|
+
onSearchInputFocus = _getInputProps.onFocus,
|
|
4294
|
+
onSearchInputBlur = _getInputProps.onBlur,
|
|
4295
|
+
onSearchInputChange = _getInputProps.onChange,
|
|
4296
|
+
inputProps = _objectWithoutProperties(_getInputProps, _excluded3$2);
|
|
4297
|
+
var hasCurrentSearch = inputValue && inputValue.length > 0;
|
|
4298
|
+
var currentItems = hasCurrentSearch && filterItemBasedOnCurrentInputValue ? items.filter(function (_ref3) {
|
|
4299
|
+
var item = _ref3.item;
|
|
4300
|
+
if (!filterItemBasedOnCurrentInputValue) return true;
|
|
4301
|
+
return filterItemBasedOnCurrentInputValue(item, inputValue || '');
|
|
4302
|
+
}) : items;
|
|
4303
|
+
|
|
4304
|
+
// We need to check if the menu is open and if there is at least one item or an error element to prevent displaying an empty container
|
|
4305
|
+
var isCurrentlyOpen = isOpen ? currentItems.length > 0 || !!errorElement || !!emptyResultsElement : false;
|
|
4306
|
+
var canDisplayCollapseButton = currentItems.length > 0 || !!errorElement || !!emptyResultsElement;
|
|
4307
|
+
return /*#__PURE__*/jsxs(View, _objectSpread(_objectSpread(_objectSpread({}, rootProps), containerProps), {}, {
|
|
4308
|
+
zIndex: zIndex,
|
|
4309
|
+
position: "relative",
|
|
4310
|
+
children: [/*#__PURE__*/jsx(InputText, _objectSpread(_objectSpread(_objectSpread({}, inputProps), props), {}, {
|
|
4311
|
+
name: name,
|
|
4312
|
+
testID: inputTestID,
|
|
4313
|
+
right: right || (canDisplayCollapseButton ? /*#__PURE__*/jsx(InputPressable, _objectSpread(_objectSpread({}, toggleProps), {}, {
|
|
4314
|
+
testID: "kitt.Autocomplete.listToggle",
|
|
4315
|
+
hitSlop: 40,
|
|
4316
|
+
onPress: function handleTogglePress(e) {
|
|
4317
|
+
if (Platform.OS === 'web') {
|
|
4318
|
+
onClickToggle(e);
|
|
4319
|
+
return;
|
|
4320
|
+
}
|
|
4321
|
+
onPressToggle(patchNativeEvent(e));
|
|
4322
|
+
},
|
|
4323
|
+
children: /*#__PURE__*/jsx(InputIcon, {
|
|
4324
|
+
icon: isCurrentlyOpen ? /*#__PURE__*/jsx(ArrowUpIcon, {}) : /*#__PURE__*/jsx(ArrowDownIcon, {})
|
|
4325
|
+
})
|
|
4326
|
+
})) : null),
|
|
4327
|
+
onFocus: function onFocus(e) {
|
|
4328
|
+
openMenu();
|
|
4329
|
+
/** @ts-expect-error onFocus wants web events */
|
|
4330
|
+
if (Platform.OS !== 'android' && onSearchInputFocus) onSearchInputFocus(e);
|
|
4331
|
+
if (_onFocus) _onFocus(e);
|
|
4332
|
+
},
|
|
4333
|
+
onBlur: function onBlur(e) {
|
|
4334
|
+
/** @ts-expect-error onBlur wants web events */
|
|
4335
|
+
if (Platform.OS !== 'android' && onSearchInputBlur) onSearchInputBlur(e);
|
|
4336
|
+
if (_onBlur) _onBlur(e);
|
|
4337
|
+
}
|
|
4338
|
+
/** @ts-expect-error onSearchInputChange wants web events */,
|
|
4339
|
+
onChange: onSearchInputChange
|
|
4340
|
+
/** @ts-expect-error onKeyDown wants web events */,
|
|
4341
|
+
onKeyPress: onKeyDown
|
|
4342
|
+
})), /*#__PURE__*/jsx(View, _objectSpread(_objectSpread({}, menuProps), {}, {
|
|
4343
|
+
position: "relative",
|
|
4344
|
+
children: isCurrentlyOpen ? /*#__PURE__*/jsxs(AutocompleteItemsListContainer, {
|
|
4345
|
+
testID: listContainerTestID,
|
|
4346
|
+
children: [currentItems.map(function (_ref4, index) {
|
|
4347
|
+
var child = _ref4.child,
|
|
4348
|
+
item = _ref4.item;
|
|
4349
|
+
var _getItemProps = getItemProps({
|
|
4350
|
+
item: item,
|
|
4351
|
+
index: index
|
|
4352
|
+
}),
|
|
4353
|
+
onClick = _getItemProps.onClick,
|
|
4354
|
+
_onPress = _getItemProps.onPress,
|
|
4355
|
+
role = _getItemProps.role,
|
|
4356
|
+
ariaSelected = _getItemProps['aria-selected'],
|
|
4357
|
+
itemProps = _objectWithoutProperties(_getItemProps, _excluded4$2);
|
|
4358
|
+
return /*#__PURE__*/jsx(Pressable, _objectSpread(_objectSpread({}, itemProps), {}, {
|
|
4359
|
+
accessibilityRole: Platform.OS === 'android' ? undefined : role,
|
|
4360
|
+
accessibilityState: {
|
|
4361
|
+
selected: ariaSelected
|
|
4362
|
+
},
|
|
4363
|
+
disabled: disabled,
|
|
4364
|
+
onPress: function onPress(e) {
|
|
4365
|
+
if (Platform.OS === 'web') {
|
|
4366
|
+
if (onClick) onClick(e);
|
|
4367
|
+
return;
|
|
4368
|
+
}
|
|
4369
|
+
if (_onPress) _onPress(patchNativeEvent(e));
|
|
4370
|
+
},
|
|
4371
|
+
children: function children(_ref5) {
|
|
4372
|
+
var isHovered = _ref5.isHovered,
|
|
4373
|
+
isFocused = _ref5.isFocused,
|
|
4374
|
+
isPressed = _ref5.isPressed;
|
|
4375
|
+
return /*#__PURE__*/jsx(AutocompleteItem, {
|
|
4376
|
+
item: item,
|
|
4377
|
+
isHighlighted: highlightedIndex === index,
|
|
4378
|
+
isHovered: isHovered,
|
|
4379
|
+
isFocused: isFocused,
|
|
4380
|
+
isPressed: isPressed,
|
|
4381
|
+
isSelected: checkSelectedItem(selectedItem || undefined, item),
|
|
4382
|
+
children: child
|
|
4383
|
+
});
|
|
4384
|
+
}
|
|
4385
|
+
}), itemProps.id);
|
|
4386
|
+
}), errorElement, emptyResultsElement]
|
|
4387
|
+
}) : null
|
|
4388
|
+
}))]
|
|
4389
|
+
}));
|
|
4390
|
+
}
|
|
4391
|
+
});
|
|
4392
|
+
}
|
|
4393
|
+
Autocomplete.Option = AutocompleteOption;
|
|
4394
|
+
/**
|
|
4395
|
+
* @description: This is exported for testing purposes only
|
|
4396
|
+
*/
|
|
4397
|
+
Autocomplete.UnsafeInternalItem = AutocompleteItem;
|
|
4398
|
+
|
|
3961
4399
|
function getBackgroundColor$2(_ref) {
|
|
3962
4400
|
var isDisabled = _ref.isDisabled,
|
|
3963
4401
|
isPressed = _ref.isPressed,
|
|
@@ -4247,85 +4685,14 @@ function onDatePartChange(_ref) {
|
|
|
4247
4685
|
}
|
|
4248
4686
|
}
|
|
4249
4687
|
if (onFocus) onFocus();
|
|
4250
|
-
onChange(nextValue);
|
|
4251
|
-
if (onBlur) onBlur();
|
|
4252
|
-
}
|
|
4253
|
-
|
|
4254
|
-
function stringToNumber(text) {
|
|
4255
|
-
if (text.length === 0) return undefined;
|
|
4256
|
-
return parseInt(text, 10);
|
|
4257
|
-
}
|
|
4258
|
-
|
|
4259
|
-
function InputTextContainer(_ref) {
|
|
4260
|
-
var children = _ref.children;
|
|
4261
|
-
return /*#__PURE__*/jsx(View, {
|
|
4262
|
-
position: "relative",
|
|
4263
|
-
children: children
|
|
4264
|
-
});
|
|
4265
|
-
}
|
|
4266
|
-
|
|
4267
|
-
var _excluded$s = ["id", "right", "state", "variant", "internalForceState", "disabled", "autoCorrect", "textContentType", "autoComplete", "keyboardType", "multiline", "onSubmitEditing"];
|
|
4268
|
-
var InputText = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
4269
|
-
var id = _ref.id,
|
|
4270
|
-
right = _ref.right;
|
|
4271
|
-
_ref.state;
|
|
4272
|
-
var _ref$variant = _ref.variant,
|
|
4273
|
-
variant = _ref$variant === void 0 ? 'outline' : _ref$variant,
|
|
4274
|
-
internalForceState = _ref.internalForceState,
|
|
4275
|
-
_ref$disabled = _ref.disabled,
|
|
4276
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
4277
|
-
_ref$autoCorrect = _ref.autoCorrect,
|
|
4278
|
-
autoCorrect = _ref$autoCorrect === void 0 ? true : _ref$autoCorrect,
|
|
4279
|
-
_ref$textContentType = _ref.textContentType,
|
|
4280
|
-
textContentType = _ref$textContentType === void 0 ? 'none' : _ref$textContentType,
|
|
4281
|
-
_ref$autoComplete = _ref.autoComplete,
|
|
4282
|
-
autoComplete = _ref$autoComplete === void 0 ? 'off' : _ref$autoComplete,
|
|
4283
|
-
_ref$keyboardType = _ref.keyboardType,
|
|
4284
|
-
keyboardType = _ref$keyboardType === void 0 ? 'default' : _ref$keyboardType,
|
|
4285
|
-
multiline = _ref.multiline,
|
|
4286
|
-
onSubmitEditing = _ref.onSubmitEditing,
|
|
4287
|
-
props = _objectWithoutProperties(_ref, _excluded$s);
|
|
4288
|
-
var theme = useTheme();
|
|
4289
|
-
var fontSizeForNativeBase = createNativeBaseFontSize({
|
|
4290
|
-
base: 'body'
|
|
4291
|
-
});
|
|
4292
|
-
var shouldHandleSingleLineOnIOS = Platform.OS === 'ios' && !multiline;
|
|
4293
|
-
return /*#__PURE__*/jsxs(InputTextContainer, {
|
|
4294
|
-
children: [/*#__PURE__*/jsx(Input, _objectSpread(_objectSpread({
|
|
4295
|
-
ref: ref,
|
|
4296
|
-
multiline: multiline,
|
|
4297
|
-
nativeID: id,
|
|
4298
|
-
isDisabled: internalForceState ? internalForceState === 'disabled' : disabled,
|
|
4299
|
-
isHovered: internalForceState ? internalForceState === 'hover' : undefined,
|
|
4300
|
-
isFocused: internalForceState ? internalForceState === 'focus' : undefined,
|
|
4301
|
-
keyboardType: keyboardType,
|
|
4302
|
-
autoComplete: autoComplete,
|
|
4303
|
-
autoCorrect: autoCorrect,
|
|
4304
|
-
textContentType: textContentType,
|
|
4305
|
-
fontSize: fontSizeForNativeBase,
|
|
4306
|
-
lineHeight:
|
|
4307
|
-
// On basic text input, we set the line-height to zero for iOS to fix vertical text alignment
|
|
4308
|
-
// This is a iOS only fix since having 0 as a line-height value breaks text inputs on Android
|
|
4309
|
-
shouldHandleSingleLineOnIOS ? 0 : fontSizeForNativeBase,
|
|
4310
|
-
fontWeight: "bodies.regular",
|
|
4311
|
-
fontFamily: "bodies.regular",
|
|
4312
|
-
py: !multiline && Platform.OS !== 'web' ? 0 : undefined,
|
|
4313
|
-
variant: variant
|
|
4314
|
-
}, props), {}, {
|
|
4315
|
-
onSubmitEditing: multiline ? function () {
|
|
4316
|
-
return null;
|
|
4317
|
-
} : onSubmitEditing
|
|
4318
|
-
})), right ? /*#__PURE__*/jsx(View, {
|
|
4319
|
-
position: "absolute",
|
|
4320
|
-
right: 0,
|
|
4321
|
-
top: 0,
|
|
4322
|
-
bottom: 0,
|
|
4323
|
-
justifyContent: "center",
|
|
4324
|
-
padding: theme.kitt.forms.input.rightContainer.padding,
|
|
4325
|
-
children: right
|
|
4326
|
-
}) : null]
|
|
4327
|
-
});
|
|
4328
|
-
});
|
|
4688
|
+
onChange(nextValue);
|
|
4689
|
+
if (onBlur) onBlur();
|
|
4690
|
+
}
|
|
4691
|
+
|
|
4692
|
+
function stringToNumber(text) {
|
|
4693
|
+
if (text.length === 0) return undefined;
|
|
4694
|
+
return parseInt(text, 10);
|
|
4695
|
+
}
|
|
4329
4696
|
|
|
4330
4697
|
function getCurrentInternalForcedState$1(_ref) {
|
|
4331
4698
|
var isDisabled = _ref.isDisabled,
|
|
@@ -4383,7 +4750,7 @@ function PartContainer(_ref) {
|
|
|
4383
4750
|
});
|
|
4384
4751
|
}
|
|
4385
4752
|
|
|
4386
|
-
var _excluded$
|
|
4753
|
+
var _excluded$s = ["id", "value", "testID", "stretch", "placeholder", "minDate", "maxDate", "disabled", "isFocusedInternal", "isHoveredInternal", "isPressedInternal", "returnKeyType", "onChange", "onBlur", "onFocus", "onSubmitEditing"];
|
|
4387
4754
|
var KeyboardDatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
4388
4755
|
var id = _ref.id,
|
|
4389
4756
|
value = _ref.value,
|
|
@@ -4401,7 +4768,7 @@ var KeyboardDatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
4401
4768
|
onBlur = _ref.onBlur,
|
|
4402
4769
|
onFocus = _ref.onFocus,
|
|
4403
4770
|
onSubmitEditing = _ref.onSubmitEditing;
|
|
4404
|
-
_objectWithoutProperties(_ref, _excluded$
|
|
4771
|
+
_objectWithoutProperties(_ref, _excluded$s);
|
|
4405
4772
|
var monthRef = useRef(null);
|
|
4406
4773
|
var yearRef = useRef(null);
|
|
4407
4774
|
var defaultValue = value;
|
|
@@ -4611,7 +4978,7 @@ var PressableDateInputs = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
4611
4978
|
});
|
|
4612
4979
|
});
|
|
4613
4980
|
|
|
4614
|
-
var _excluded$
|
|
4981
|
+
var _excluded$r = ["onBlur", "onFocus", "pickerDefaultDate", "pickerUITestID", "isDefaultVisible", "value", "onChange"];
|
|
4615
4982
|
var DatePickerAndroid = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
4616
4983
|
var onBlur = _ref.onBlur,
|
|
4617
4984
|
onFocus = _ref.onFocus,
|
|
@@ -4620,7 +4987,7 @@ var DatePickerAndroid = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
4620
4987
|
isDefaultVisible = _ref.isDefaultVisible,
|
|
4621
4988
|
value = _ref.value,
|
|
4622
4989
|
_onChange = _ref.onChange,
|
|
4623
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
4990
|
+
props = _objectWithoutProperties(_ref, _excluded$r);
|
|
4624
4991
|
var _useState = useState(false),
|
|
4625
4992
|
_useState2 = _slicedToArray(_useState, 2),
|
|
4626
4993
|
isFocused = _useState2[0],
|
|
@@ -4696,7 +5063,7 @@ function PlatformDateTimePicker(_ref) {
|
|
|
4696
5063
|
}));
|
|
4697
5064
|
}
|
|
4698
5065
|
|
|
4699
|
-
var _excluded$
|
|
5066
|
+
var _excluded$q = ["title", "isVisible", "value", "validateButtonLabel", "onClose", "onChange"];
|
|
4700
5067
|
function ModalTitle(_ref) {
|
|
4701
5068
|
var children = _ref.children;
|
|
4702
5069
|
return /*#__PURE__*/jsx(CardModal.Header, {
|
|
@@ -4714,7 +5081,7 @@ function ModalPlatformDateTimePicker(_ref2) {
|
|
|
4714
5081
|
validateButtonLabel = _ref2.validateButtonLabel,
|
|
4715
5082
|
onClose = _ref2.onClose,
|
|
4716
5083
|
onChange = _ref2.onChange,
|
|
4717
|
-
props = _objectWithoutProperties(_ref2, _excluded$
|
|
5084
|
+
props = _objectWithoutProperties(_ref2, _excluded$q);
|
|
4718
5085
|
var _useState = useState(value),
|
|
4719
5086
|
_useState2 = _slicedToArray(_useState, 2),
|
|
4720
5087
|
currentValue = _useState2[0],
|
|
@@ -4760,7 +5127,7 @@ function ModalPlatformDateTimePicker(_ref2) {
|
|
|
4760
5127
|
});
|
|
4761
5128
|
}
|
|
4762
5129
|
|
|
4763
|
-
var _excluded$
|
|
5130
|
+
var _excluded$p = ["value", "pickerUITestID", "pickerUITitle", "pickerUIValidateButtonLabel", "isDefaultVisible", "pickerDefaultDate", "isFocusedInternal", "isHoveredInternal", "isPressedInternal", "onChange", "onFocus", "onBlur"];
|
|
4764
5131
|
var DefaultNativeUIDatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
4765
5132
|
var value = _ref.value,
|
|
4766
5133
|
pickerUITestID = _ref.pickerUITestID,
|
|
@@ -4774,7 +5141,7 @@ var DefaultNativeUIDatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
4774
5141
|
onChange = _ref.onChange,
|
|
4775
5142
|
onFocus = _ref.onFocus,
|
|
4776
5143
|
onBlur = _ref.onBlur,
|
|
4777
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
5144
|
+
props = _objectWithoutProperties(_ref, _excluded$p);
|
|
4778
5145
|
var _useState = useState(isDefaultVisible),
|
|
4779
5146
|
_useState2 = _slicedToArray(_useState, 2),
|
|
4780
5147
|
isPickerUIVisible = _useState2[0],
|
|
@@ -4821,7 +5188,7 @@ var DefaultNativeUIDatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
4821
5188
|
});
|
|
4822
5189
|
});
|
|
4823
5190
|
|
|
4824
|
-
var _excluded$
|
|
5191
|
+
var _excluded$o = ["value", "pickerUITestID", "isDefaultVisible", "pickerDefaultDate", "onChange", "onBlur"];
|
|
4825
5192
|
var NativeUIDatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
4826
5193
|
var value = _ref.value,
|
|
4827
5194
|
pickerUITestID = _ref.pickerUITestID,
|
|
@@ -4829,7 +5196,7 @@ var NativeUIDatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
4829
5196
|
pickerDefaultDate = _ref.pickerDefaultDate,
|
|
4830
5197
|
onChange = _ref.onChange,
|
|
4831
5198
|
onBlur = _ref.onBlur,
|
|
4832
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
5199
|
+
props = _objectWithoutProperties(_ref, _excluded$o);
|
|
4833
5200
|
if (Platform.OS === 'android') {
|
|
4834
5201
|
return /*#__PURE__*/jsx(DatePickerAndroid, _objectSpread({
|
|
4835
5202
|
ref: ref,
|
|
@@ -4851,14 +5218,14 @@ var NativeUIDatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
4851
5218
|
}, props));
|
|
4852
5219
|
});
|
|
4853
5220
|
|
|
4854
|
-
var _excluded$
|
|
5221
|
+
var _excluded$n = ["fillMode", "returnKeyType", "value", "onSubmitEditing"];
|
|
4855
5222
|
var DatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
4856
5223
|
var _ref$fillMode = _ref.fillMode,
|
|
4857
5224
|
fillMode = _ref$fillMode === void 0 ? 'native' : _ref$fillMode,
|
|
4858
5225
|
returnKeyType = _ref.returnKeyType,
|
|
4859
5226
|
value = _ref.value,
|
|
4860
5227
|
onSubmitEditing = _ref.onSubmitEditing,
|
|
4861
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
5228
|
+
props = _objectWithoutProperties(_ref, _excluded$n);
|
|
4862
5229
|
// in apps, final-form can give a string value that will break the component
|
|
4863
5230
|
var currentValue = value || undefined;
|
|
4864
5231
|
if (fillMode === 'keyboard') {
|
|
@@ -4877,6 +5244,511 @@ var DatePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
4877
5244
|
}));
|
|
4878
5245
|
});
|
|
4879
5246
|
|
|
5247
|
+
var GoogleMapsApiKeyContext = /*#__PURE__*/createContext(undefined);
|
|
5248
|
+
function GoogleMapsApiKeyProvider(_ref) {
|
|
5249
|
+
var children = _ref.children,
|
|
5250
|
+
apiKey = _ref.apiKey;
|
|
5251
|
+
return /*#__PURE__*/jsx(GoogleMapsApiKeyContext.Provider, {
|
|
5252
|
+
value: apiKey,
|
|
5253
|
+
children: children
|
|
5254
|
+
});
|
|
5255
|
+
}
|
|
5256
|
+
|
|
5257
|
+
function useGoogleMapApiKey() {
|
|
5258
|
+
var context = useContext(GoogleMapsApiKeyContext);
|
|
5259
|
+
if (!context) {
|
|
5260
|
+
throw new Error('<GoogleMapsApiKeyContext> missing in the react tree');
|
|
5261
|
+
}
|
|
5262
|
+
return context;
|
|
5263
|
+
}
|
|
5264
|
+
|
|
5265
|
+
function makeMapsApiUrl(resource, paramName, value, apiKey) {
|
|
5266
|
+
return "https://maps.googleapis.com/maps/api/".concat(resource, "/json?").concat(paramName, "=").concat(encodeURIComponent(value), "&key=").concat(apiKey);
|
|
5267
|
+
}
|
|
5268
|
+
|
|
5269
|
+
function useGoogleMapsApi() {
|
|
5270
|
+
var apiKey = useGoogleMapApiKey();
|
|
5271
|
+
var makeApiUrl = function (resource, paramName, value) {
|
|
5272
|
+
return makeMapsApiUrl(resource, paramName, value, apiKey);
|
|
5273
|
+
};
|
|
5274
|
+
var sharedFetchOptions = {
|
|
5275
|
+
method: 'GET',
|
|
5276
|
+
headers: {
|
|
5277
|
+
'Content-Type': 'application/json'
|
|
5278
|
+
}
|
|
5279
|
+
};
|
|
5280
|
+
var googlePlacesServices = {
|
|
5281
|
+
autoComplete: {
|
|
5282
|
+
getPlacePredictions: function () {
|
|
5283
|
+
var _getPlacePredictions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
|
|
5284
|
+
var response, data;
|
|
5285
|
+
return _regeneratorRuntime().wrap(function (_context) {
|
|
5286
|
+
while (1) switch (_context.prev = _context.next) {
|
|
5287
|
+
case 0:
|
|
5288
|
+
_context.prev = 0;
|
|
5289
|
+
_context.next = 3;
|
|
5290
|
+
return fetch(makeApiUrl('place/autocomplete', 'input', input), sharedFetchOptions);
|
|
5291
|
+
case 3:
|
|
5292
|
+
response = _context.sent;
|
|
5293
|
+
_context.next = 6;
|
|
5294
|
+
return response.json();
|
|
5295
|
+
case 6:
|
|
5296
|
+
data = _context.sent;
|
|
5297
|
+
if (!((data === null || data === void 0 ? void 0 : data.status) !== 'OK')) {
|
|
5298
|
+
_context.next = 9;
|
|
5299
|
+
break;
|
|
5300
|
+
}
|
|
5301
|
+
return _context.abrupt("return", {
|
|
5302
|
+
status: data === null || data === void 0 ? void 0 : data.status,
|
|
5303
|
+
results: []
|
|
5304
|
+
});
|
|
5305
|
+
case 9:
|
|
5306
|
+
return _context.abrupt("return", {
|
|
5307
|
+
results: data === null || data === void 0 ? void 0 : data.predictions,
|
|
5308
|
+
status: data === null || data === void 0 ? void 0 : data.status
|
|
5309
|
+
});
|
|
5310
|
+
case 12:
|
|
5311
|
+
_context.prev = 12;
|
|
5312
|
+
_context.t0 = _context["catch"](0);
|
|
5313
|
+
return _context.abrupt("return", {
|
|
5314
|
+
status: google.maps.places.PlacesServiceStatus.UNKNOWN_ERROR,
|
|
5315
|
+
results: []
|
|
5316
|
+
});
|
|
5317
|
+
case 15:
|
|
5318
|
+
case "end":
|
|
5319
|
+
return _context.stop();
|
|
5320
|
+
}
|
|
5321
|
+
}, _callee, null, [[0, 12]]);
|
|
5322
|
+
}));
|
|
5323
|
+
function getPlacePredictions() {
|
|
5324
|
+
return _getPlacePredictions.apply(this, arguments);
|
|
5325
|
+
}
|
|
5326
|
+
return getPlacePredictions;
|
|
5327
|
+
}()
|
|
5328
|
+
},
|
|
5329
|
+
placesService: {
|
|
5330
|
+
getDetails: function () {
|
|
5331
|
+
var _getDetails = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(placeId) {
|
|
5332
|
+
var response, data;
|
|
5333
|
+
return _regeneratorRuntime().wrap(function (_context2) {
|
|
5334
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
5335
|
+
case 0:
|
|
5336
|
+
_context2.prev = 0;
|
|
5337
|
+
_context2.next = 3;
|
|
5338
|
+
return fetch(makeApiUrl('place/details', 'place_id', placeId), sharedFetchOptions);
|
|
5339
|
+
case 3:
|
|
5340
|
+
response = _context2.sent;
|
|
5341
|
+
_context2.next = 6;
|
|
5342
|
+
return response.json();
|
|
5343
|
+
case 6:
|
|
5344
|
+
data = _context2.sent;
|
|
5345
|
+
if (!((data === null || data === void 0 ? void 0 : data.status) !== 'OK')) {
|
|
5346
|
+
_context2.next = 9;
|
|
5347
|
+
break;
|
|
5348
|
+
}
|
|
5349
|
+
return _context2.abrupt("return", {
|
|
5350
|
+
status: data === null || data === void 0 ? void 0 : data.status,
|
|
5351
|
+
result: undefined
|
|
5352
|
+
});
|
|
5353
|
+
case 9:
|
|
5354
|
+
return _context2.abrupt("return", {
|
|
5355
|
+
result: data === null || data === void 0 ? void 0 : data.result,
|
|
5356
|
+
status: data === null || data === void 0 ? void 0 : data.status
|
|
5357
|
+
});
|
|
5358
|
+
case 12:
|
|
5359
|
+
_context2.prev = 12;
|
|
5360
|
+
_context2.t0 = _context2["catch"](0);
|
|
5361
|
+
return _context2.abrupt("return", {
|
|
5362
|
+
status: google.maps.places.PlacesServiceStatus.UNKNOWN_ERROR,
|
|
5363
|
+
result: undefined
|
|
5364
|
+
});
|
|
5365
|
+
case 15:
|
|
5366
|
+
case "end":
|
|
5367
|
+
return _context2.stop();
|
|
5368
|
+
}
|
|
5369
|
+
}, _callee2, null, [[0, 12]]);
|
|
5370
|
+
}));
|
|
5371
|
+
function getDetails() {
|
|
5372
|
+
return _getDetails.apply(this, arguments);
|
|
5373
|
+
}
|
|
5374
|
+
return getDetails;
|
|
5375
|
+
}()
|
|
5376
|
+
}
|
|
5377
|
+
};
|
|
5378
|
+
return googlePlacesServices;
|
|
5379
|
+
}
|
|
5380
|
+
|
|
5381
|
+
var googleMapsAutocompleteReducer = function (state, action) {
|
|
5382
|
+
switch (action.type) {
|
|
5383
|
+
case 'search-change':
|
|
5384
|
+
{
|
|
5385
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
5386
|
+
hasSearchError: false,
|
|
5387
|
+
isLoadingSearch: true
|
|
5388
|
+
});
|
|
5389
|
+
}
|
|
5390
|
+
case 'search-success':
|
|
5391
|
+
{
|
|
5392
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
5393
|
+
hasSearchError: false,
|
|
5394
|
+
isLoadingSearch: false,
|
|
5395
|
+
items: action.payload.results
|
|
5396
|
+
});
|
|
5397
|
+
}
|
|
5398
|
+
case 'search-error':
|
|
5399
|
+
{
|
|
5400
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
5401
|
+
hasSearchError: true,
|
|
5402
|
+
isLoadingSearch: false,
|
|
5403
|
+
items: []
|
|
5404
|
+
});
|
|
5405
|
+
}
|
|
5406
|
+
case 'select-result':
|
|
5407
|
+
{
|
|
5408
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
5409
|
+
hasSelectResultError: false,
|
|
5410
|
+
isLoadingResultDetails: true
|
|
5411
|
+
});
|
|
5412
|
+
}
|
|
5413
|
+
case 'select-result-success':
|
|
5414
|
+
{
|
|
5415
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
5416
|
+
hasSelectResultError: false,
|
|
5417
|
+
isLoadingResultDetails: false,
|
|
5418
|
+
currentSelectedValue: action.payload.result
|
|
5419
|
+
});
|
|
5420
|
+
}
|
|
5421
|
+
case 'select-result-error':
|
|
5422
|
+
{
|
|
5423
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
5424
|
+
hasSelectResultError: true,
|
|
5425
|
+
isLoadingResultDetails: false,
|
|
5426
|
+
currentSelectedValue: undefined
|
|
5427
|
+
});
|
|
5428
|
+
}
|
|
5429
|
+
default:
|
|
5430
|
+
return state;
|
|
5431
|
+
}
|
|
5432
|
+
};
|
|
5433
|
+
|
|
5434
|
+
function findComponentByType(typeName, components) {
|
|
5435
|
+
return components.find(function (component) {
|
|
5436
|
+
return component.types.includes(typeName);
|
|
5437
|
+
});
|
|
5438
|
+
}
|
|
5439
|
+
var matchStreetNumberWithOriginalAddress = function () {
|
|
5440
|
+
var streetNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
5441
|
+
var address = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
5442
|
+
var _ref = / *(\d*[-/_]{0,1}\d*) *(bis|ter|quater|quinquies|sexies|septies|octies|novies|decies|[a-z])? /i.exec(address) || [],
|
|
5443
|
+
_ref2 = _slicedToArray(_ref, 3),
|
|
5444
|
+
_ref2$ = _ref2[1],
|
|
5445
|
+
number = _ref2$ === void 0 ? '' : _ref2$,
|
|
5446
|
+
_ref2$2 = _ref2[2],
|
|
5447
|
+
extension = _ref2$2 === void 0 ? '' : _ref2$2;
|
|
5448
|
+
if (number) return "".concat(number).concat(extension);
|
|
5449
|
+
return streetNumber;
|
|
5450
|
+
};
|
|
5451
|
+
var formatAddressFromGoogle = function (placeResult, originalAddress) {
|
|
5452
|
+
var _placeResult$geometry, _placeResult$geometry2, _findComponentByType, _findComponentByType2, _findComponentByType3, _findComponentByType4, _findComponentByType5, _findComponentByType6, _findComponentByType7, _findComponentByType8;
|
|
5453
|
+
var _placeResult$address_ = placeResult.address_components,
|
|
5454
|
+
addressComponents = _placeResult$address_ === void 0 ? [] : _placeResult$address_;
|
|
5455
|
+
return {
|
|
5456
|
+
source: 'google',
|
|
5457
|
+
lat: (_placeResult$geometry = placeResult.geometry) === null || _placeResult$geometry === void 0 ? void 0 : _placeResult$geometry.location.lat(),
|
|
5458
|
+
lng: (_placeResult$geometry2 = placeResult.geometry) === null || _placeResult$geometry2 === void 0 ? void 0 : _placeResult$geometry2.location.lng(),
|
|
5459
|
+
locality: (_findComponentByType = findComponentByType('locality', addressComponents)) === null || _findComponentByType === void 0 ? void 0 : _findComponentByType.long_name,
|
|
5460
|
+
subLocality: (_findComponentByType2 = findComponentByType('sublocality', addressComponents)) === null || _findComponentByType2 === void 0 ? void 0 : _findComponentByType2.long_name,
|
|
5461
|
+
zipcode: (_findComponentByType3 = findComponentByType('postal_code', addressComponents)) === null || _findComponentByType3 === void 0 ? void 0 : _findComponentByType3.long_name,
|
|
5462
|
+
streetName: (_findComponentByType4 = findComponentByType('route', addressComponents)) === null || _findComponentByType4 === void 0 ? void 0 : _findComponentByType4.long_name,
|
|
5463
|
+
streetNumber: matchStreetNumberWithOriginalAddress((_findComponentByType5 = findComponentByType('street_number', addressComponents)) === null || _findComponentByType5 === void 0 ? void 0 : _findComponentByType5.long_name, originalAddress),
|
|
5464
|
+
country: (_findComponentByType6 = findComponentByType('country', addressComponents)) === null || _findComponentByType6 === void 0 ? void 0 : _findComponentByType6.long_name,
|
|
5465
|
+
administrativeAreaLevel1: (_findComponentByType7 = findComponentByType('administrative_area_level_1', addressComponents)) === null || _findComponentByType7 === void 0 ? void 0 : _findComponentByType7.long_name,
|
|
5466
|
+
administrativeAreaLevel2: (_findComponentByType8 = findComponentByType('administrative_area_level_1', addressComponents)) === null || _findComponentByType8 === void 0 ? void 0 : _findComponentByType8.long_name
|
|
5467
|
+
};
|
|
5468
|
+
};
|
|
5469
|
+
|
|
5470
|
+
var GoogleMapsAutocompleteContext = /*#__PURE__*/createContext({
|
|
5471
|
+
state: {
|
|
5472
|
+
items: [],
|
|
5473
|
+
currentSelectedValue: undefined,
|
|
5474
|
+
isLoadingSearch: false,
|
|
5475
|
+
hasSearchError: false,
|
|
5476
|
+
hasSelectResultError: false,
|
|
5477
|
+
isLoadingResultDetails: false,
|
|
5478
|
+
shouldDisplayEmptyStateWhenNoResults: false
|
|
5479
|
+
},
|
|
5480
|
+
onInputChange: function onInputChange() {
|
|
5481
|
+
return Promise.resolve();
|
|
5482
|
+
},
|
|
5483
|
+
onSelectItem: function onSelectItem() {}
|
|
5484
|
+
});
|
|
5485
|
+
function GoogleMapsAutocompleteProvider(_ref) {
|
|
5486
|
+
var children = _ref.children,
|
|
5487
|
+
_ref$minCharsToSearch = _ref.minCharsToSearch,
|
|
5488
|
+
minCharsToSearch = _ref$minCharsToSearch === void 0 ? 3 : _ref$minCharsToSearch,
|
|
5489
|
+
_ref$debounceTimeout = _ref.debounceTimeout,
|
|
5490
|
+
debounceTimeout = _ref$debounceTimeout === void 0 ? 950 : _ref$debounceTimeout;
|
|
5491
|
+
var mapsApi = useGoogleMapsApi();
|
|
5492
|
+
var searchResultsCache = useRef({});
|
|
5493
|
+
var resultDetailsCache = useRef({});
|
|
5494
|
+
var _useReducer = useReducer(googleMapsAutocompleteReducer, {
|
|
5495
|
+
items: [],
|
|
5496
|
+
shouldDisplayEmptyStateWhenNoResults: false
|
|
5497
|
+
}),
|
|
5498
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
5499
|
+
state = _useReducer2[0],
|
|
5500
|
+
dispatch = _useReducer2[1];
|
|
5501
|
+
var handleInputChange = useDebouncedCallback(useCallback( /*#__PURE__*/function () {
|
|
5502
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value) {
|
|
5503
|
+
var predictionsPromise, _yield$predictionsPro, results, status;
|
|
5504
|
+
return _regeneratorRuntime().wrap(function (_context) {
|
|
5505
|
+
while (1) switch (_context.prev = _context.next) {
|
|
5506
|
+
case 0:
|
|
5507
|
+
if (!(value.length < minCharsToSearch)) {
|
|
5508
|
+
_context.next = 2;
|
|
5509
|
+
break;
|
|
5510
|
+
}
|
|
5511
|
+
return _context.abrupt("return");
|
|
5512
|
+
case 2:
|
|
5513
|
+
dispatch({
|
|
5514
|
+
type: 'search-change'
|
|
5515
|
+
});
|
|
5516
|
+
|
|
5517
|
+
// If the user types the same value as the previous search, we don't need to call the API again
|
|
5518
|
+
predictionsPromise = searchResultsCache.current[value] ? Promise.resolve({
|
|
5519
|
+
results: searchResultsCache.current[value],
|
|
5520
|
+
status: 'OK'
|
|
5521
|
+
}) : mapsApi.autoComplete.getPlacePredictions(value);
|
|
5522
|
+
_context.prev = 4;
|
|
5523
|
+
_context.next = 7;
|
|
5524
|
+
return predictionsPromise;
|
|
5525
|
+
case 7:
|
|
5526
|
+
_yield$predictionsPro = _context.sent;
|
|
5527
|
+
results = _yield$predictionsPro.results;
|
|
5528
|
+
status = _yield$predictionsPro.status;
|
|
5529
|
+
if (!(status !== 'OK')) {
|
|
5530
|
+
_context.next = 13;
|
|
5531
|
+
break;
|
|
5532
|
+
}
|
|
5533
|
+
dispatch({
|
|
5534
|
+
type: 'search-error'
|
|
5535
|
+
});
|
|
5536
|
+
return _context.abrupt("return");
|
|
5537
|
+
case 13:
|
|
5538
|
+
// We cache the results to avoid calling the API again if the user types the same value
|
|
5539
|
+
searchResultsCache.current[value] = results;
|
|
5540
|
+
dispatch({
|
|
5541
|
+
type: 'search-success',
|
|
5542
|
+
payload: {
|
|
5543
|
+
results: results
|
|
5544
|
+
}
|
|
5545
|
+
});
|
|
5546
|
+
_context.next = 20;
|
|
5547
|
+
break;
|
|
5548
|
+
case 17:
|
|
5549
|
+
_context.prev = 17;
|
|
5550
|
+
_context.t0 = _context["catch"](4);
|
|
5551
|
+
dispatch({
|
|
5552
|
+
type: 'search-error'
|
|
5553
|
+
});
|
|
5554
|
+
case 20:
|
|
5555
|
+
case "end":
|
|
5556
|
+
return _context.stop();
|
|
5557
|
+
}
|
|
5558
|
+
}, _callee, null, [[4, 17]]);
|
|
5559
|
+
}));
|
|
5560
|
+
return function () {
|
|
5561
|
+
return _ref2.apply(this, arguments);
|
|
5562
|
+
};
|
|
5563
|
+
}(), [mapsApi.autoComplete, minCharsToSearch]), debounceTimeout);
|
|
5564
|
+
var handleSelectItem = useCallback( /*#__PURE__*/function () {
|
|
5565
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(item, onChange) {
|
|
5566
|
+
var placePromise, place, formattedAddress;
|
|
5567
|
+
return _regeneratorRuntime().wrap(function (_context2) {
|
|
5568
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
5569
|
+
case 0:
|
|
5570
|
+
if (item !== null && item !== void 0 && item.place_id) {
|
|
5571
|
+
_context2.next = 3;
|
|
5572
|
+
break;
|
|
5573
|
+
}
|
|
5574
|
+
if (onChange) onChange(undefined);
|
|
5575
|
+
return _context2.abrupt("return");
|
|
5576
|
+
case 3:
|
|
5577
|
+
dispatch({
|
|
5578
|
+
type: 'select-result'
|
|
5579
|
+
});
|
|
5580
|
+
_context2.prev = 4;
|
|
5581
|
+
// If we already have the details in cache, we don't need to fetch them again
|
|
5582
|
+
placePromise = resultDetailsCache.current[item.place_id] ? Promise.resolve(resultDetailsCache.current[item.place_id]) : mapsApi.placesService.getDetails(item.place_id).then(function (_ref4) {
|
|
5583
|
+
var result = _ref4.result;
|
|
5584
|
+
return result;
|
|
5585
|
+
});
|
|
5586
|
+
_context2.next = 8;
|
|
5587
|
+
return placePromise;
|
|
5588
|
+
case 8:
|
|
5589
|
+
place = _context2.sent;
|
|
5590
|
+
if (place) {
|
|
5591
|
+
_context2.next = 13;
|
|
5592
|
+
break;
|
|
5593
|
+
}
|
|
5594
|
+
dispatch({
|
|
5595
|
+
type: 'select-result-error'
|
|
5596
|
+
});
|
|
5597
|
+
if (onChange) onChange(undefined);
|
|
5598
|
+
return _context2.abrupt("return");
|
|
5599
|
+
case 13:
|
|
5600
|
+
dispatch({
|
|
5601
|
+
type: 'select-result-success',
|
|
5602
|
+
payload: {
|
|
5603
|
+
result: place
|
|
5604
|
+
}
|
|
5605
|
+
});
|
|
5606
|
+
formattedAddress = formatAddressFromGoogle(place, item.description); // We cache the result details to avoid fetching them again if the user selects the same item
|
|
5607
|
+
resultDetailsCache.current[item.place_id] = place;
|
|
5608
|
+
if (onChange) onChange(formattedAddress);
|
|
5609
|
+
_context2.next = 23;
|
|
5610
|
+
break;
|
|
5611
|
+
case 19:
|
|
5612
|
+
_context2.prev = 19;
|
|
5613
|
+
_context2.t0 = _context2["catch"](4);
|
|
5614
|
+
dispatch({
|
|
5615
|
+
type: 'select-result-error'
|
|
5616
|
+
});
|
|
5617
|
+
if (onChange) onChange(undefined);
|
|
5618
|
+
case 23:
|
|
5619
|
+
case "end":
|
|
5620
|
+
return _context2.stop();
|
|
5621
|
+
}
|
|
5622
|
+
}, _callee2, null, [[4, 19]]);
|
|
5623
|
+
}));
|
|
5624
|
+
return function () {
|
|
5625
|
+
return _ref3.apply(this, arguments);
|
|
5626
|
+
};
|
|
5627
|
+
}(), [mapsApi.placesService]);
|
|
5628
|
+
var api = useMemo(function () {
|
|
5629
|
+
return {
|
|
5630
|
+
state: state,
|
|
5631
|
+
onSelectItem: handleSelectItem,
|
|
5632
|
+
onInputChange: handleInputChange
|
|
5633
|
+
};
|
|
5634
|
+
}, [handleInputChange, handleSelectItem, state]);
|
|
5635
|
+
return /*#__PURE__*/jsx(GoogleMapsAutocompleteContext.Provider, {
|
|
5636
|
+
value: api,
|
|
5637
|
+
children: children
|
|
5638
|
+
});
|
|
5639
|
+
}
|
|
5640
|
+
|
|
5641
|
+
function useGoogleMapsAutocomplete() {
|
|
5642
|
+
var context = useContext(GoogleMapsAutocompleteContext);
|
|
5643
|
+
if (!context) {
|
|
5644
|
+
throw new Error('<GoogleMapsAutocompleteProvider> missing in the react tree');
|
|
5645
|
+
}
|
|
5646
|
+
return context;
|
|
5647
|
+
}
|
|
5648
|
+
|
|
5649
|
+
function InputAddressOption(_ref) {
|
|
5650
|
+
var item = _ref.item;
|
|
5651
|
+
var sharedTransform = {
|
|
5652
|
+
style: {
|
|
5653
|
+
transform: [{
|
|
5654
|
+
translateY: 4
|
|
5655
|
+
}]
|
|
5656
|
+
}
|
|
5657
|
+
};
|
|
5658
|
+
return /*#__PURE__*/jsx(Autocomplete.Option, {
|
|
5659
|
+
item: item,
|
|
5660
|
+
children: /*#__PURE__*/jsxs(HStack, {
|
|
5661
|
+
space: "kitt.2",
|
|
5662
|
+
children: [/*#__PURE__*/jsx(View, {
|
|
5663
|
+
_web: sharedTransform,
|
|
5664
|
+
_ios: sharedTransform,
|
|
5665
|
+
_android: sharedTransform,
|
|
5666
|
+
children: /*#__PURE__*/jsx(TypographyIcon, {
|
|
5667
|
+
icon: /*#__PURE__*/jsx(MapPinIcon, {}),
|
|
5668
|
+
color: "black"
|
|
5669
|
+
})
|
|
5670
|
+
}), /*#__PURE__*/jsx(View, {
|
|
5671
|
+
flexShrink: 1,
|
|
5672
|
+
children: /*#__PURE__*/jsxs(Typography.Text, {
|
|
5673
|
+
children: [/*#__PURE__*/jsx(Typography.Text, {
|
|
5674
|
+
variant: "bold",
|
|
5675
|
+
children: item.structured_formatting.main_text
|
|
5676
|
+
}), item.structured_formatting.secondary_text ? /*#__PURE__*/jsxs(Typography.Text, {
|
|
5677
|
+
color: "black-light",
|
|
5678
|
+
variant: "bold",
|
|
5679
|
+
children: [' ', item.structured_formatting.secondary_text]
|
|
5680
|
+
}) : null]
|
|
5681
|
+
})
|
|
5682
|
+
})]
|
|
5683
|
+
})
|
|
5684
|
+
});
|
|
5685
|
+
}
|
|
5686
|
+
|
|
5687
|
+
function defaultItemToString(item) {
|
|
5688
|
+
if (!item) return '';
|
|
5689
|
+
return item.structured_formatting.main_text;
|
|
5690
|
+
}
|
|
5691
|
+
|
|
5692
|
+
// This function takes AutocompleteAddress and return a valid google AutocompletePrediction
|
|
5693
|
+
function formatInitialValueToAutocompletePrediction(address, placeId) {
|
|
5694
|
+
return {
|
|
5695
|
+
place_id: placeId,
|
|
5696
|
+
description: '',
|
|
5697
|
+
reference: '',
|
|
5698
|
+
types: [],
|
|
5699
|
+
terms: [],
|
|
5700
|
+
matched_substrings: [],
|
|
5701
|
+
structured_formatting: {
|
|
5702
|
+
main_text: [address.streetName, address.streetNumber].filter(Boolean).join(' '),
|
|
5703
|
+
main_text_matched_substrings: [],
|
|
5704
|
+
secondary_text: [address.zipcode, address.locality, address.subLocality].filter(Boolean).join(' ')
|
|
5705
|
+
}
|
|
5706
|
+
};
|
|
5707
|
+
}
|
|
5708
|
+
|
|
5709
|
+
var _excluded$m = ["initialValue", "itemToString", "errorElement", "emptyResultsElement", "onChange"];
|
|
5710
|
+
function InputAddress(_ref) {
|
|
5711
|
+
var initialValue = _ref.initialValue,
|
|
5712
|
+
_ref$itemToString = _ref.itemToString,
|
|
5713
|
+
itemToString = _ref$itemToString === void 0 ? defaultItemToString : _ref$itemToString,
|
|
5714
|
+
errorElement = _ref.errorElement,
|
|
5715
|
+
emptyResultsElement = _ref.emptyResultsElement,
|
|
5716
|
+
_onChange = _ref.onChange;
|
|
5717
|
+
_objectWithoutProperties(_ref, _excluded$m);
|
|
5718
|
+
var _useGoogleMapsAutocom = useGoogleMapsAutocomplete(),
|
|
5719
|
+
state = _useGoogleMapsAutocom.state,
|
|
5720
|
+
_onInputChange = _useGoogleMapsAutocom.onInputChange,
|
|
5721
|
+
onSelectItem = _useGoogleMapsAutocom.onSelectItem;
|
|
5722
|
+
|
|
5723
|
+
// place_id is a google field that is not available within an AutoCompleteAddress, so we need to add a fake one when handling initial values
|
|
5724
|
+
var formattedInitialValue = initialValue ? formatInitialValueToAutocompletePrediction(initialValue, 'initial-value-placeId') : undefined;
|
|
5725
|
+
return /*#__PURE__*/jsx(Autocomplete, {
|
|
5726
|
+
itemToString: itemToString,
|
|
5727
|
+
initialValue: formattedInitialValue,
|
|
5728
|
+
checkSelectedItem: function checkSelectedItem(selectedItem, item) {
|
|
5729
|
+
return (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.place_id) === item.place_id;
|
|
5730
|
+
},
|
|
5731
|
+
right: state.isLoadingSearch || state.isLoadingResultDetails ? /*#__PURE__*/jsx(Icon, {
|
|
5732
|
+
icon: /*#__PURE__*/jsx(LoaderIcon, {}),
|
|
5733
|
+
color: "kitt.black"
|
|
5734
|
+
}) : undefined,
|
|
5735
|
+
errorElement: state.hasSearchError || state.hasSelectResultError ? errorElement : null,
|
|
5736
|
+
emptyResultsElement: state.items.length === 0 ? emptyResultsElement : null,
|
|
5737
|
+
onInputChange: function onInputChange(v) {
|
|
5738
|
+
_onInputChange(v);
|
|
5739
|
+
},
|
|
5740
|
+
onChange: function onChange(v) {
|
|
5741
|
+
onSelectItem(v, _onChange);
|
|
5742
|
+
},
|
|
5743
|
+
children: state.items.map(function (item) {
|
|
5744
|
+
return /*#__PURE__*/jsx(InputAddressOption, {
|
|
5745
|
+
item: item
|
|
5746
|
+
}, item.place_id);
|
|
5747
|
+
})
|
|
5748
|
+
});
|
|
5749
|
+
}
|
|
5750
|
+
InputAddress.Option = InputAddressOption;
|
|
5751
|
+
|
|
4880
5752
|
var InputEmail = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
4881
5753
|
return /*#__PURE__*/jsx(InputText, _objectSpread({
|
|
4882
5754
|
ref: ref,
|
|
@@ -4932,35 +5804,6 @@ function InputField(_ref) {
|
|
|
4932
5804
|
});
|
|
4933
5805
|
}
|
|
4934
5806
|
|
|
4935
|
-
function getIconColor(state, disabled) {
|
|
4936
|
-
if (disabled) return 'black-light';
|
|
4937
|
-
switch (state) {
|
|
4938
|
-
case 'invalid':
|
|
4939
|
-
return 'danger';
|
|
4940
|
-
case 'valid':
|
|
4941
|
-
return 'success';
|
|
4942
|
-
default:
|
|
4943
|
-
return undefined;
|
|
4944
|
-
}
|
|
4945
|
-
}
|
|
4946
|
-
function InputIcon(_ref) {
|
|
4947
|
-
var icon = _ref.icon,
|
|
4948
|
-
state = _ref.state,
|
|
4949
|
-
disabled = _ref.disabled;
|
|
4950
|
-
var theme = useTheme();
|
|
4951
|
-
var color = getIconColor(state, disabled);
|
|
4952
|
-
return /*#__PURE__*/jsx(TypographyIcon, {
|
|
4953
|
-
color: color,
|
|
4954
|
-
icon: icon,
|
|
4955
|
-
size: theme.kitt.forms.input.icon.size
|
|
4956
|
-
});
|
|
4957
|
-
}
|
|
4958
|
-
|
|
4959
|
-
function InputPressable(_ref) {
|
|
4960
|
-
var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
4961
|
-
return /*#__PURE__*/jsx(Pressable$2, _objectSpread({}, props));
|
|
4962
|
-
}
|
|
4963
|
-
|
|
4964
5807
|
var _excluded$l = ["isPasswordDefaultVisible", "right"];
|
|
4965
5808
|
var InputPassword = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
4966
5809
|
var isPasswordDefaultVisible = _ref.isPasswordDefaultVisible,
|
|
@@ -6842,6 +7685,31 @@ function createKittNativeBaseCustomTheme(theme, appTheme) {
|
|
|
6842
7685
|
}
|
|
6843
7686
|
},
|
|
6844
7687
|
forms: {
|
|
7688
|
+
autocomplete: {
|
|
7689
|
+
option: {
|
|
7690
|
+
"default": {
|
|
7691
|
+
backgroundColor: theme.forms.autocomplete.option["default"].backgroundColor
|
|
7692
|
+
},
|
|
7693
|
+
hovered: {
|
|
7694
|
+
backgroundColor: theme.forms.autocomplete.option.hovered.backgroundColor
|
|
7695
|
+
},
|
|
7696
|
+
focused: {
|
|
7697
|
+
backgroundColor: theme.forms.autocomplete.option.focused.backgroundColor
|
|
7698
|
+
},
|
|
7699
|
+
selected: {
|
|
7700
|
+
backgroundColor: theme.forms.autocomplete.option.selected.backgroundColor
|
|
7701
|
+
},
|
|
7702
|
+
highlighted: {
|
|
7703
|
+
backgroundColor: theme.forms.autocomplete.option.highlighted.backgroundColor
|
|
7704
|
+
},
|
|
7705
|
+
pressed: {
|
|
7706
|
+
backgroundColor: theme.forms.autocomplete.option.pressed.backgroundColor
|
|
7707
|
+
}
|
|
7708
|
+
},
|
|
7709
|
+
optionsContainer: {
|
|
7710
|
+
backgroundColor: theme.forms.autocomplete.optionsContainer.backgroundColor
|
|
7711
|
+
}
|
|
7712
|
+
},
|
|
6845
7713
|
input: {
|
|
6846
7714
|
states: theme.forms.input.states
|
|
6847
7715
|
},
|
|
@@ -7065,6 +7933,11 @@ function createKittNativeBaseCustomTheme(theme, appTheme) {
|
|
|
7065
7933
|
borderRadius: theme.dialogModal.borderRadius
|
|
7066
7934
|
},
|
|
7067
7935
|
forms: {
|
|
7936
|
+
autocomplete: {
|
|
7937
|
+
optionsContainer: {
|
|
7938
|
+
borderRadius: theme.forms.autocomplete.optionsContainer.borderRadius
|
|
7939
|
+
}
|
|
7940
|
+
},
|
|
7068
7941
|
input: {
|
|
7069
7942
|
borderRadius: theme.forms.input.borderRadius
|
|
7070
7943
|
},
|
|
@@ -7320,6 +8193,11 @@ function createKittNativeBaseCustomTheme(theme, appTheme) {
|
|
|
7320
8193
|
minHeight: theme.feedbackMessage.minHeight
|
|
7321
8194
|
},
|
|
7322
8195
|
forms: {
|
|
8196
|
+
autocomplete: {
|
|
8197
|
+
option: {
|
|
8198
|
+
minHeight: theme.forms.autocomplete.option.minHeight
|
|
8199
|
+
}
|
|
8200
|
+
},
|
|
7323
8201
|
datePicker: {
|
|
7324
8202
|
minHeight: theme.forms.input.minHeight,
|
|
7325
8203
|
day: {
|
|
@@ -7422,6 +8300,11 @@ function createKittNativeBaseCustomTheme(theme, appTheme) {
|
|
|
7422
8300
|
overlayPadding: theme.dialogModal.overlayPadding
|
|
7423
8301
|
},
|
|
7424
8302
|
forms: {
|
|
8303
|
+
autocomplete: {
|
|
8304
|
+
option: {
|
|
8305
|
+
verticalPadding: theme.forms.autocomplete.option.verticalPadding
|
|
8306
|
+
}
|
|
8307
|
+
},
|
|
7425
8308
|
datePicker: {
|
|
7426
8309
|
padding: theme.forms.input.padding
|
|
7427
8310
|
},
|
|
@@ -7891,16 +8774,18 @@ function createKittNativeBaseCustomTheme(theme, appTheme) {
|
|
|
7891
8774
|
shadowRadius: theme.dialogModal.shadow.radius
|
|
7892
8775
|
}
|
|
7893
8776
|
},
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
8777
|
+
forms: {
|
|
8778
|
+
autocomplete: {
|
|
8779
|
+
optionsContainer: {
|
|
8780
|
+
shadow: {
|
|
8781
|
+
shadowColor: theme.forms.autocomplete.optionsContainer.shadow.color,
|
|
8782
|
+
shadowOffset: {
|
|
8783
|
+
width: theme.forms.autocomplete.optionsContainer.shadow.offsetX,
|
|
8784
|
+
height: theme.forms.autocomplete.optionsContainer.shadow.offsetY
|
|
8785
|
+
},
|
|
8786
|
+
shadowOpacity: theme.forms.autocomplete.optionsContainer.shadow.opacity,
|
|
8787
|
+
shadowRadius: theme.forms.autocomplete.optionsContainer.shadow.radius
|
|
8788
|
+
}
|
|
7904
8789
|
}
|
|
7905
8790
|
}
|
|
7906
8791
|
}
|
|
@@ -8679,7 +9564,7 @@ function SkeletonContent(_ref) {
|
|
|
8679
9564
|
var _excluded$8 = ["isLoading", "style"],
|
|
8680
9565
|
_excluded2$1 = ["size"],
|
|
8681
9566
|
_excluded3$1 = ["size"],
|
|
8682
|
-
_excluded4 = ["size"];
|
|
9567
|
+
_excluded4$1 = ["size"];
|
|
8683
9568
|
function Skeleton(_ref) {
|
|
8684
9569
|
var _ref$isLoading = _ref.isLoading,
|
|
8685
9570
|
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
@@ -8725,7 +9610,7 @@ function Circle(_ref4) {
|
|
|
8725
9610
|
}
|
|
8726
9611
|
function Square(_ref5) {
|
|
8727
9612
|
var size = _ref5.size,
|
|
8728
|
-
props = _objectWithoutProperties(_ref5, _excluded4);
|
|
9613
|
+
props = _objectWithoutProperties(_ref5, _excluded4$1);
|
|
8729
9614
|
var currentSize = size || 'kitt.skeleton.shape.square.size';
|
|
8730
9615
|
var currentBorderRadius = size ? size * 0.5 : 'kitt.skeleton.shape.square.borderRadius';
|
|
8731
9616
|
return /*#__PURE__*/jsx(Skeleton, _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -9134,7 +10019,8 @@ function Story(_ref) {
|
|
|
9134
10019
|
|
|
9135
10020
|
var _excluded$5 = ["title", "children", "internalIsDemoSection"],
|
|
9136
10021
|
_excluded2 = ["title", "children"],
|
|
9137
|
-
_excluded3 = ["title", "children"]
|
|
10022
|
+
_excluded3 = ["title", "children"],
|
|
10023
|
+
_excluded4 = ["children"];
|
|
9138
10024
|
function StorySection(_ref) {
|
|
9139
10025
|
var title = _ref.title,
|
|
9140
10026
|
children = _ref.children,
|
|
@@ -9174,15 +10060,17 @@ function BlockSection(_ref3) {
|
|
|
9174
10060
|
}));
|
|
9175
10061
|
}
|
|
9176
10062
|
function DemoSection(_ref4) {
|
|
9177
|
-
var children = _ref4.children
|
|
9178
|
-
|
|
9179
|
-
|
|
10063
|
+
var children = _ref4.children,
|
|
10064
|
+
props = _objectWithoutProperties(_ref4, _excluded4);
|
|
10065
|
+
return /*#__PURE__*/jsx(View, _objectSpread(_objectSpread({
|
|
10066
|
+
marginBottom: "kitt.16"
|
|
10067
|
+
}, props), {}, {
|
|
9180
10068
|
children: /*#__PURE__*/jsx(StorySection, {
|
|
9181
10069
|
internalIsDemoSection: true,
|
|
9182
10070
|
title: "Demo",
|
|
9183
10071
|
children: children
|
|
9184
10072
|
})
|
|
9185
|
-
});
|
|
10073
|
+
}));
|
|
9186
10074
|
}
|
|
9187
10075
|
StorySection.SubSection = SubSection;
|
|
9188
10076
|
StorySection.BlockSection = BlockSection;
|
|
@@ -10120,5 +11008,5 @@ function VerticalSteps(_ref) {
|
|
|
10120
11008
|
}
|
|
10121
11009
|
VerticalSteps.Step = ExternalStep;
|
|
10122
11010
|
|
|
10123
|
-
export { ActionCard, Actions, Avatar, BottomSheet, Button, CardModal, Center, Checkbox, ChoicesElements, DatePicker, DialogModal, Emoji, ExternalAppLink, ExternalLink, FlatList, Flex, FullscreenModal, HStack, Highlight, Icon, IconButton, Image, InputEmail, InputFeedback, InputField, InputIcon, InputPassword, InputPhone, InputPressable, InputTag, InputText, KittBreakpointNameEnum, KittBreakpoints, KittBreakpointsMax, KittMapConfigProvider, KittNativeBaseProvider, KittThemeDecorator, KittThemeProvider, Label, ListItem, LoaderIcon, MapMarkerLarge, MapMarkerPosition, MapMarkerSimple, MatchWindowSize, Message, ModalBehaviour, NavigationModal, Notification, Overlay, PageLoader, Picker, Pressable, Radio, RadioButtonGroup, ScrollView, DeprecatedSection as Section, SectionList, SegmentedProgressBar, Skeleton, SpinningIcon, Stack, StaticMap, Story, StoryBlock, StoryContainer, StoryDecorator, StoryGrid, StorySection, StoryTitle, StyleWebWrapper, SwitchBreakpoints, Tag, TextArea, TimePicker, Tooltip, Typography, TypographyEmoji, TypographyIcon, TypographyLink, VStack, VerticalSteps, View, createChoicesComponent, createResponsiveStyleFromProp, getStaticMapImageUrl, hex2rgba, matchWindowSize, theme, useBottomSheet, useBreakpointValue, useCurrentBreakpointName, useGetStaticMapImageUrl, useKittMapConfig, useKittTheme, useMatchWindowSize, useStaticBottomSheet, useStoryBlockColor, useTheme };
|
|
11011
|
+
export { ActionCard, Actions, Autocomplete, Avatar, BottomSheet, Button, CardModal, Center, Checkbox, ChoicesElements, DatePicker, DialogModal, Emoji, ExternalAppLink, ExternalLink, FlatList, Flex, FullscreenModal, GoogleMapsApiKeyProvider, GoogleMapsAutocompleteProvider, HStack, Highlight, Icon, IconButton, Image, InputAddress, InputEmail, InputFeedback, InputField, InputIcon, InputPassword, InputPhone, InputPressable, InputTag, InputText, KittBreakpointNameEnum, KittBreakpoints, KittBreakpointsMax, KittMapConfigProvider, KittNativeBaseProvider, KittThemeDecorator, KittThemeProvider, Label, ListItem, LoaderIcon, MapMarkerLarge, MapMarkerPosition, MapMarkerSimple, MatchWindowSize, Message, ModalBehaviour, NavigationModal, Notification, Overlay, PageLoader, Picker, Pressable, Radio, RadioButtonGroup, ScrollView, DeprecatedSection as Section, SectionList, SegmentedProgressBar, Skeleton, SpinningIcon, Stack, StaticMap, Story, StoryBlock, StoryContainer, StoryDecorator, StoryGrid, StorySection, StoryTitle, StyleWebWrapper, SwitchBreakpoints, Tag, TextArea, TimePicker, Tooltip, Typography, TypographyEmoji, TypographyIcon, TypographyLink, VStack, VerticalSteps, View, createChoicesComponent, createResponsiveStyleFromProp, getStaticMapImageUrl, hex2rgba, matchWindowSize, theme, useBottomSheet, useBreakpointValue, useCurrentBreakpointName, useGetStaticMapImageUrl, useKittMapConfig, useKittTheme, useMatchWindowSize, useStaticBottomSheet, useStoryBlockColor, useTheme };
|
|
10124
11012
|
//# sourceMappingURL=index-browser-all.es.js.map
|