@ornikar/kitt-universal 23.3.0 → 23.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/definitions/BottomSheet/useStaticBottomSheet.d.ts +3 -3
  3. package/dist/definitions/BottomSheet/useStaticBottomSheet.d.ts.map +1 -1
  4. package/dist/definitions/forms/DocumentPicker/DocumentPicker.d.ts +15 -0
  5. package/dist/definitions/forms/DocumentPicker/DocumentPicker.d.ts.map +1 -0
  6. package/dist/definitions/forms/FilePicker/BottomSheetActions/BottomSheetActions.d.ts +13 -0
  7. package/dist/definitions/forms/FilePicker/BottomSheetActions/BottomSheetActions.d.ts.map +1 -0
  8. package/dist/definitions/forms/FilePicker/BottomSheetActions/BottomSheetActionsItem.d.ts +7 -0
  9. package/dist/definitions/forms/FilePicker/BottomSheetActions/BottomSheetActionsItem.d.ts.map +1 -0
  10. package/dist/definitions/forms/FilePicker/FilePicker.d.ts +17 -0
  11. package/dist/definitions/forms/FilePicker/FilePicker.d.ts.map +1 -0
  12. package/dist/definitions/forms/FilePicker/FilePicker.web.d.ts +4 -0
  13. package/dist/definitions/forms/FilePicker/FilePicker.web.d.ts.map +1 -0
  14. package/dist/definitions/forms/ImagePicker/ImagePicker.d.ts +15 -0
  15. package/dist/definitions/forms/ImagePicker/ImagePicker.d.ts.map +1 -0
  16. package/dist/definitions/index.d.ts +7 -2
  17. package/dist/definitions/index.d.ts.map +1 -1
  18. package/dist/index-metro.es.android.js +311 -164
  19. package/dist/index-metro.es.android.js.map +1 -1
  20. package/dist/index-metro.es.ios.js +311 -164
  21. package/dist/index-metro.es.ios.js.map +1 -1
  22. package/dist/index-node-20.10.cjs.js +231 -83
  23. package/dist/index-node-20.10.cjs.js.map +1 -1
  24. package/dist/index-node-20.10.cjs.web.js +62 -0
  25. package/dist/index-node-20.10.cjs.web.js.map +1 -1
  26. package/dist/index-node-20.10.es.mjs +231 -86
  27. package/dist/index-node-20.10.es.mjs.map +1 -1
  28. package/dist/index-node-20.10.es.web.mjs +60 -1
  29. package/dist/index-node-20.10.es.web.mjs.map +1 -1
  30. package/dist/index.es.js +343 -158
  31. package/dist/index.es.js.map +1 -1
  32. package/dist/index.es.web.js +104 -1
  33. package/dist/index.es.web.js.map +1 -1
  34. package/dist/tsbuildinfo +1 -1
  35. package/package.json +4 -1
  36. package/translations/fr-FR.json +2 -0
@@ -1,4 +1,4 @@
1
- import React, { useContext, createContext, forwardRef, cloneElement, useRef, useEffect, useState, useMemo, Children, useReducer, useCallback, Fragment as Fragment$1, createElement } from 'react';
1
+ import React, { useContext, createContext, forwardRef, cloneElement, useRef, useEffect, useState, useMemo, Children, useReducer, Fragment as Fragment$1, useCallback, 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 { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -7,7 +7,7 @@ import { Platform, Animated as Animated$1, Easing, StyleSheet, Modal, ScrollView
7
7
  export { useWindowDimensions as useWindowSize } from 'react-native';
8
8
  import { ArcIcon, UserIcon, MapPinIcon, InfoIcon, AlertTriangleIcon, CheckIcon, AlertCircleIcon, XIcon, RotateCCWIcon } from '@ornikar/kitt-icons';
9
9
  export * from '@ornikar/kitt-icons';
10
- import { BottomSheetScrollView, BottomSheetView, useBottomSheetDynamicSnapPoints, BottomSheetModal, BottomSheetHandle, BottomSheetBackdrop } from '@gorhom/bottom-sheet';
10
+ import { BottomSheetScrollView, BottomSheetView, useBottomSheetDynamicSnapPoints, BottomSheetModal, BottomSheetHandle, BottomSheetBackdrop, useBottomSheetModal } from '@gorhom/bottom-sheet';
11
11
  import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
12
12
  import { parse } from 'twemoji-parser';
13
13
  import * as WebBrowser from 'expo-web-browser';
@@ -15,6 +15,8 @@ import { CaretUpFillIcon, CaretDownFillIcon, EyeClosedRegularIcon, EyeRegularIco
15
15
  import Downshift from 'downshift';
16
16
  import DateTimePicker, { DateTimePickerAndroid } from '@react-native-community/datetimepicker';
17
17
  import { FormattedMessage } from 'react-intl';
18
+ import { getDocumentAsync } from 'expo-document-picker';
19
+ import { launchImageLibraryAsync } from 'expo-image-picker';
18
20
  import { useDebouncedCallback } from 'use-debounce';
19
21
  import { parseNumber, getCountryCallingCode, isValidNumber } from 'libphonenumber-js';
20
22
  import Svg, { Circle as Circle$1 } from 'react-native-svg';
@@ -5308,6 +5310,232 @@ const DatePicker = /*#__PURE__*/forwardRef(({
5308
5310
  });
5309
5311
  });
5310
5312
 
5313
+ function DocumentPicker({
5314
+ onDocumentUpload,
5315
+ children,
5316
+ disabled,
5317
+ documentPickerOptions
5318
+ }) {
5319
+ const childElement = Children.only(children);
5320
+ return /*#__PURE__*/cloneElement(childElement, {
5321
+ // ensure that the press event is not prevented by Button component
5322
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
5323
+ onPress: async () => {
5324
+ if (disabled) return;
5325
+ childElement.props.onPress?.();
5326
+ const result = await getDocumentAsync({
5327
+ ...documentPickerOptions,
5328
+ multiple: false
5329
+ });
5330
+ if (!result.canceled && result.assets[0].file) {
5331
+ onDocumentUpload(result.assets[0].file);
5332
+ }
5333
+ },
5334
+ disabled
5335
+ });
5336
+ }
5337
+
5338
+ function ImagePicker({
5339
+ onImageSelected,
5340
+ children,
5341
+ disabled,
5342
+ imagePickerOptions
5343
+ }) {
5344
+ const childElement = Children.only(children);
5345
+ return /*#__PURE__*/jsx(View, {
5346
+ children: /*#__PURE__*/cloneElement(childElement, {
5347
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
5348
+ onPress: async () => {
5349
+ if (disabled) return;
5350
+ childElement.props.onPress?.();
5351
+
5352
+ // No permissions request is necessary for launching the image library
5353
+ const result = await launchImageLibraryAsync({
5354
+ ...imagePickerOptions,
5355
+ allowsMultipleSelection: false
5356
+ });
5357
+ if (!result.canceled) {
5358
+ onImageSelected(result.assets[0]);
5359
+ }
5360
+ },
5361
+ disabled
5362
+ })
5363
+ });
5364
+ }
5365
+
5366
+ function ListItemContent({
5367
+ children,
5368
+ ...rest
5369
+ }) {
5370
+ return /*#__PURE__*/jsx(View, {
5371
+ alignSelf: "center",
5372
+ flexBasis: "0%",
5373
+ flexGrow: 1,
5374
+ flexShrink: 0,
5375
+ ...rest,
5376
+ children: children
5377
+ });
5378
+ }
5379
+
5380
+ // Handles the vertical alignment of the side elements of the list item
5381
+ function ListItemSideContainer({
5382
+ children,
5383
+ side = 'left',
5384
+ ...rest
5385
+ }) {
5386
+ return /*#__PURE__*/jsx(View, {
5387
+ flexDirection: "row",
5388
+ marginLeft: side === 'right' ? 'kitt.2' : undefined,
5389
+ marginRight: side === 'left' ? 'kitt.2' : undefined,
5390
+ ...rest,
5391
+ children: children
5392
+ });
5393
+ }
5394
+ function ListItemSideContent({
5395
+ children,
5396
+ align = 'auto',
5397
+ ...rest
5398
+ }) {
5399
+ return /*#__PURE__*/jsx(View, {
5400
+ alignSelf: align,
5401
+ ...rest,
5402
+ children: children
5403
+ });
5404
+ }
5405
+
5406
+ function ListItem({
5407
+ children,
5408
+ withPadding,
5409
+ borders,
5410
+ left,
5411
+ right,
5412
+ onPress,
5413
+ ...rest
5414
+ }) {
5415
+ const Wrapper = onPress ? Pressable$2 : Fragment$1;
5416
+ const wrapperProps = onPress ? {
5417
+ accessibilityRole: 'button',
5418
+ onPress,
5419
+ ...rest
5420
+ } : undefined;
5421
+ const containerProps = onPress ? undefined : rest;
5422
+ return /*#__PURE__*/jsx(Wrapper, {
5423
+ ...wrapperProps,
5424
+ children: /*#__PURE__*/jsxs(View, {
5425
+ flexDirection: "row",
5426
+ paddingX: withPadding ? 'kitt.listItem.horizontalPadding' : undefined,
5427
+ paddingY: withPadding ? 'kitt.listItem.verticalPadding' : undefined,
5428
+ borderColor: "kitt.listItem.borderColor",
5429
+ backgroundColor: "kitt.uiBackgroundLight",
5430
+ borderTopWidth: borders === 'top' || borders === 'both' ? 'kitt.listItem.borderWidth' : undefined,
5431
+ borderBottomWidth: borders === 'bottom' || borders === 'both' ? 'kitt.listItem.borderWidth' : undefined,
5432
+ ...containerProps,
5433
+ children: [left ? /*#__PURE__*/jsx(ListItemSideContainer, {
5434
+ side: "left",
5435
+ children: left
5436
+ }) : null, /*#__PURE__*/jsx(ListItemContent, {
5437
+ children: children
5438
+ }), right ? /*#__PURE__*/jsx(ListItemSideContainer, {
5439
+ side: "right",
5440
+ children: right
5441
+ }) : null]
5442
+ })
5443
+ });
5444
+ }
5445
+ ListItem.Content = ListItemContent;
5446
+ ListItem.SideContent = ListItemSideContent;
5447
+ ListItem.SideContainer = ListItemSideContainer;
5448
+
5449
+ function BottomSheetActionsItem({
5450
+ title,
5451
+ ...props
5452
+ }) {
5453
+ return /*#__PURE__*/jsx(Pressable$2, {
5454
+ ...props,
5455
+ children: /*#__PURE__*/jsx(ListItem, {
5456
+ withPadding: true,
5457
+ children: /*#__PURE__*/jsx(Typography.Text, {
5458
+ variant: "bold",
5459
+ base: "body",
5460
+ children: title
5461
+ })
5462
+ })
5463
+ });
5464
+ }
5465
+
5466
+ function BottomSheetActions({
5467
+ onBottomSheetActionsChange,
5468
+ imagePickerOptions,
5469
+ documentPickerOptions,
5470
+ disabled
5471
+ }) {
5472
+ const isPlatformIOS = Platform.OS === 'ios';
5473
+ return /*#__PURE__*/jsxs(VStack, {
5474
+ marginBottom: "kitt.8",
5475
+ children: [/*#__PURE__*/jsx(ImagePicker, {
5476
+ imagePickerOptions: imagePickerOptions,
5477
+ disabled: disabled,
5478
+ onImageSelected: onBottomSheetActionsChange,
5479
+ children: /*#__PURE__*/jsx(BottomSheetActionsItem, {
5480
+ title: /*#__PURE__*/jsx(FormattedMessage, {
5481
+ id: "account.BottomSheetActions.openLibrary",
5482
+ values: {
5483
+ isPlatformIOS
5484
+ }
5485
+ })
5486
+ })
5487
+ }), /*#__PURE__*/jsx(DocumentPicker, {
5488
+ disabled: disabled,
5489
+ documentPickerOptions: documentPickerOptions,
5490
+ onDocumentUpload: onBottomSheetActionsChange,
5491
+ children: /*#__PURE__*/jsx(BottomSheetActionsItem, {
5492
+ title: /*#__PURE__*/jsx(FormattedMessage, {
5493
+ id: "account.BottomSheetActions.openFileExplorer",
5494
+ values: {
5495
+ isPlatformIOS
5496
+ }
5497
+ })
5498
+ })
5499
+ })]
5500
+ });
5501
+ }
5502
+
5503
+ function FilePicker({
5504
+ onFileSelected,
5505
+ children,
5506
+ disabled,
5507
+ imagePickerOptions,
5508
+ documentPickerOptions
5509
+ }) {
5510
+ const childElement = Children.only(children);
5511
+ const {
5512
+ bottomSheetRef,
5513
+ BottomSheet
5514
+ } = useStaticBottomSheet(BottomSheetActions);
5515
+ const {
5516
+ dismissAll
5517
+ } = useBottomSheetModal();
5518
+ const handleBottomSheetActionsChange = file => {
5519
+ dismissAll();
5520
+ onFileSelected(file);
5521
+ };
5522
+ return /*#__PURE__*/jsxs(Fragment, {
5523
+ children: [/*#__PURE__*/cloneElement(childElement, {
5524
+ // ensure that the press event is not prevented by Button component
5525
+ onPress: () => {
5526
+ if (disabled) return;
5527
+ childElement.props.onPress?.();
5528
+ bottomSheetRef.current?.present({
5529
+ onBottomSheetActionsChange: handleBottomSheetActionsChange,
5530
+ imagePickerOptions,
5531
+ documentPickerOptions
5532
+ });
5533
+ },
5534
+ disabled
5535
+ }), /*#__PURE__*/jsx(BottomSheet, {})]
5536
+ });
5537
+ }
5538
+
5311
5539
  const GoogleMapsApiKeyContext = /*#__PURE__*/createContext(undefined);
5312
5540
  function GoogleMapsApiKeyProvider({
5313
5541
  children,
@@ -7100,89 +7328,6 @@ function useKittMapConfig() {
7100
7328
  return context;
7101
7329
  }
7102
7330
 
7103
- function ListItemContent({
7104
- children,
7105
- ...rest
7106
- }) {
7107
- return /*#__PURE__*/jsx(View, {
7108
- alignSelf: "center",
7109
- flexBasis: "0%",
7110
- flexGrow: 1,
7111
- flexShrink: 0,
7112
- ...rest,
7113
- children: children
7114
- });
7115
- }
7116
-
7117
- // Handles the vertical alignment of the side elements of the list item
7118
- function ListItemSideContainer({
7119
- children,
7120
- side = 'left',
7121
- ...rest
7122
- }) {
7123
- return /*#__PURE__*/jsx(View, {
7124
- flexDirection: "row",
7125
- marginLeft: side === 'right' ? 'kitt.2' : undefined,
7126
- marginRight: side === 'left' ? 'kitt.2' : undefined,
7127
- ...rest,
7128
- children: children
7129
- });
7130
- }
7131
- function ListItemSideContent({
7132
- children,
7133
- align = 'auto',
7134
- ...rest
7135
- }) {
7136
- return /*#__PURE__*/jsx(View, {
7137
- alignSelf: align,
7138
- ...rest,
7139
- children: children
7140
- });
7141
- }
7142
-
7143
- function ListItem({
7144
- children,
7145
- withPadding,
7146
- borders,
7147
- left,
7148
- right,
7149
- onPress,
7150
- ...rest
7151
- }) {
7152
- const Wrapper = onPress ? Pressable$2 : Fragment$1;
7153
- const wrapperProps = onPress ? {
7154
- accessibilityRole: 'button',
7155
- onPress,
7156
- ...rest
7157
- } : undefined;
7158
- const containerProps = onPress ? undefined : rest;
7159
- return /*#__PURE__*/jsx(Wrapper, {
7160
- ...wrapperProps,
7161
- children: /*#__PURE__*/jsxs(View, {
7162
- flexDirection: "row",
7163
- paddingX: withPadding ? 'kitt.listItem.horizontalPadding' : undefined,
7164
- paddingY: withPadding ? 'kitt.listItem.verticalPadding' : undefined,
7165
- borderColor: "kitt.listItem.borderColor",
7166
- backgroundColor: "kitt.uiBackgroundLight",
7167
- borderTopWidth: borders === 'top' || borders === 'both' ? 'kitt.listItem.borderWidth' : undefined,
7168
- borderBottomWidth: borders === 'bottom' || borders === 'both' ? 'kitt.listItem.borderWidth' : undefined,
7169
- ...containerProps,
7170
- children: [left ? /*#__PURE__*/jsx(ListItemSideContainer, {
7171
- side: "left",
7172
- children: left
7173
- }) : null, /*#__PURE__*/jsx(ListItemContent, {
7174
- children: children
7175
- }), right ? /*#__PURE__*/jsx(ListItemSideContainer, {
7176
- side: "right",
7177
- children: right
7178
- }) : null]
7179
- })
7180
- });
7181
- }
7182
- ListItem.Content = ListItemContent;
7183
- ListItem.SideContent = ListItemSideContent;
7184
- ListItem.SideContainer = ListItemSideContainer;
7185
-
7186
7331
  const SvgMarkerLargeinline = props => /*#__PURE__*/jsxs("svg", {
7187
7332
  fill: "currentColor",
7188
7333
  viewBox: "0 0 54 56",
@@ -11281,5 +11426,5 @@ function VerticalSteps({
11281
11426
  }
11282
11427
  VerticalSteps.Step = ExternalStep;
11283
11428
 
11284
- export { ActionCard, Actions, Autocomplete, Avatar, BottomSheet, Button, CardModal, Center, Checkbox, ChoicesElements, CloseIconButton, DatePicker, DialogModal, Emoji, ExternalAppLink, ExternalLink, FlatList, Flex, FullscreenModal, GoogleMapsApiKeyProvider, GoogleMapsAutocompleteProvider, HStack, Highlight, Icon, IconButton, Image, InputAddress, InputEmail, InputFeedback, InputField, InputIcon, InputNumber, InputPassword, InputPhone, InputPressable, InputTag, InputText, KittBreakpointNameEnum, KittBreakpoints, KittBreakpointsMax, KittMapConfigProvider, KittNativeBaseProvider, KittThemeDecorator, KittThemeProvider, Label, ListItem, LoaderIcon, MapMarkerLarge, MapMarkerPosition, MapMarkerSimple, MatchWindowSize, Message, ModalBehaviour, FlatList as NativeOnlyFlatList, 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, storyPadding, theme, useBottomSheet, useBreakpointValue, useCurrentBreakpointName, useGetStaticMapImageUrl, useKittMapConfig, useKittTheme, useMatchWindowSize, useOpenExternalLink, useStaticBottomSheet, useStoryBlockColor, useTheme };
11429
+ export { ActionCard, Actions, Autocomplete, Avatar, BottomSheet, Button, CardModal, Center, Checkbox, ChoicesElements, CloseIconButton, DatePicker, DialogModal, DocumentPicker, Emoji, ExternalAppLink, ExternalLink, FilePicker, FlatList, Flex, FullscreenModal, GoogleMapsApiKeyProvider, GoogleMapsAutocompleteProvider, HStack, Highlight, Icon, IconButton, Image, ImagePicker, InputAddress, InputEmail, InputFeedback, InputField, InputIcon, InputNumber, InputPassword, InputPhone, InputPressable, InputTag, InputText, KittBreakpointNameEnum, KittBreakpoints, KittBreakpointsMax, KittMapConfigProvider, KittNativeBaseProvider, KittThemeDecorator, KittThemeProvider, Label, ListItem, LoaderIcon, MapMarkerLarge, MapMarkerPosition, MapMarkerSimple, MatchWindowSize, Message, ModalBehaviour, FlatList as NativeOnlyFlatList, 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, storyPadding, theme, useBottomSheet, useBreakpointValue, useCurrentBreakpointName, useGetStaticMapImageUrl, useKittMapConfig, useKittTheme, useMatchWindowSize, useOpenExternalLink, useStaticBottomSheet, useStoryBlockColor, useTheme };
11285
11430
  //# sourceMappingURL=index-node-20.10.es.mjs.map