@ornikar/kitt-universal 7.7.1 → 7.8.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.
@@ -848,6 +848,78 @@ function Emoji({
848
848
  });
849
849
  }
850
850
 
851
+ function ExternalAppLink({
852
+ as: Component,
853
+ appScheme,
854
+ appValue,
855
+ onPress,
856
+ onOpenAppError,
857
+ ...rest
858
+ }) {
859
+ const href = `${appScheme}:${appValue}`;
860
+ return /*#__PURE__*/jsxRuntime.jsx(Component, {
861
+ href: href,
862
+ ...rest,
863
+ onPress: async e => {
864
+ try {
865
+ const canOpen = await reactNative.Linking.canOpenURL(href);
866
+
867
+ if (canOpen) {
868
+ reactNative.Linking.openURL(href).catch(err => {
869
+ console.error(`An error occurred while opening ${href}`, err);
870
+ onOpenAppError?.(`An error occurred while opening ${href}`);
871
+ });
872
+
873
+ if (onPress) {
874
+ onPress(e);
875
+ if (e?.defaultPrevented) return;
876
+ }
877
+ } else {
878
+ onOpenAppError?.(`Cannot open url: ${href}`);
879
+ }
880
+ } catch {
881
+ onOpenAppError?.('An error occured with Linkinf.canOpenURL');
882
+ }
883
+ }
884
+ });
885
+ }
886
+
887
+ ExternalAppLink.Sms = function ({
888
+ phoneNumber,
889
+ children,
890
+ ...rest
891
+ }) {
892
+ return /*#__PURE__*/jsxRuntime.jsx(ExternalAppLink, { ...rest,
893
+ appScheme: "sms",
894
+ appValue: phoneNumber,
895
+ children: children
896
+ });
897
+ };
898
+
899
+ ExternalAppLink.Tel = function ({
900
+ phoneNumber,
901
+ children,
902
+ ...rest
903
+ }) {
904
+ return /*#__PURE__*/jsxRuntime.jsx(ExternalAppLink, { ...rest,
905
+ appScheme: "tel",
906
+ appValue: phoneNumber,
907
+ children: children
908
+ });
909
+ };
910
+
911
+ ExternalAppLink.Mail = function ({
912
+ emailAddress,
913
+ children,
914
+ ...rest
915
+ }) {
916
+ return /*#__PURE__*/jsxRuntime.jsx(ExternalAppLink, { ...rest,
917
+ appScheme: "mailto",
918
+ appValue: emailAddress,
919
+ children: children
920
+ });
921
+ };
922
+
851
923
  const defaultOpenLinkBehavior = {
852
924
  native: 'openInModal',
853
925
  web: 'targetBlank'
@@ -3533,28 +3605,26 @@ function Picker({
3533
3605
  variant: "bold",
3534
3606
  children: title
3535
3607
  })
3536
- }), /*#__PURE__*/jsxRuntime.jsx(reactNative.View, {
3537
- children: reactNative.Platform.OS === 'ios' ? /*#__PURE__*/jsxRuntime.jsx(picker$1.Picker, {
3538
- testID: testID,
3539
- selectedValue: value,
3540
- itemStyle: theme.picker.ios.default,
3541
- onValueChange: itemValue => setValue(itemValue),
3542
- children: React__default.Children.map(children, child => {
3543
- const item = child; // iOS Picker doesn't support a custom Item component, we need to override its props manually for the selected one
3544
-
3545
- return /*#__PURE__*/React.cloneElement(item, {
3546
- color: item.props.value === value ? theme.picker.ios.selected.color : undefined
3547
- });
3548
- })
3549
- }) : /*#__PURE__*/jsxRuntime.jsx(reactNative.ScrollView, {
3550
- testID: testID,
3551
- children: React__default.Children.map(children, child => {
3552
- const item = child;
3553
- return /*#__PURE__*/React.cloneElement(item, {
3554
- onPress: newValue => setValue(newValue),
3555
- isSelected: item.props.value === value
3556
- });
3557
- })
3608
+ }), reactNative.Platform.OS === 'ios' ? /*#__PURE__*/jsxRuntime.jsx(picker$1.Picker, {
3609
+ testID: testID,
3610
+ selectedValue: value,
3611
+ itemStyle: theme.picker.ios.default,
3612
+ onValueChange: itemValue => setValue(itemValue),
3613
+ children: React__default.Children.map(children, child => {
3614
+ const item = child; // iOS Picker doesn't support a custom Item component, we need to override its props manually for the selected one
3615
+
3616
+ return /*#__PURE__*/React.cloneElement(item, {
3617
+ color: item.props.value === value ? theme.picker.ios.selected.color : undefined
3618
+ });
3619
+ })
3620
+ }) : /*#__PURE__*/jsxRuntime.jsx(reactNative.ScrollView, {
3621
+ testID: testID,
3622
+ children: React__default.Children.map(children, child => {
3623
+ const item = child;
3624
+ return /*#__PURE__*/React.cloneElement(item, {
3625
+ onPress: newValue => setValue(newValue),
3626
+ isSelected: item.props.value === value
3627
+ });
3558
3628
  })
3559
3629
  }), /*#__PURE__*/jsxRuntime.jsx(Modal.Footer, {
3560
3630
  children: /*#__PURE__*/jsxRuntime.jsx(Button, {
@@ -4531,6 +4601,7 @@ exports.Card = Card;
4531
4601
  exports.Checkbox = Checkbox;
4532
4602
  exports.DatePicker = DatePicker;
4533
4603
  exports.Emoji = Emoji;
4604
+ exports.ExternalAppLink = ExternalAppLink;
4534
4605
  exports.ExternalLink = ExternalLink;
4535
4606
  exports.Flex = Flex;
4536
4607
  exports.FullScreenModal = FullScreenModal;