@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.
@@ -856,6 +856,78 @@ function Emoji({
856
856
  });
857
857
  }
858
858
 
859
+ function ExternalAppLink({
860
+ as: Component,
861
+ appScheme,
862
+ appValue,
863
+ onPress,
864
+ onOpenAppError,
865
+ ...rest
866
+ }) {
867
+ const href = `${appScheme}:${appValue}`;
868
+ return /*#__PURE__*/jsxRuntime.jsx(Component, {
869
+ href: href,
870
+ ...rest,
871
+ onPress: async e => {
872
+ try {
873
+ const canOpen = await BabelPluginStyledComponentsReactNative.Linking.canOpenURL(href);
874
+
875
+ if (canOpen) {
876
+ BabelPluginStyledComponentsReactNative.Linking.openURL(href).catch(err => {
877
+ console.error(`An error occurred while opening ${href}`, err);
878
+ onOpenAppError?.(`An error occurred while opening ${href}`);
879
+ });
880
+
881
+ if (onPress) {
882
+ onPress(e);
883
+ if (e?.defaultPrevented) return;
884
+ }
885
+ } else {
886
+ onOpenAppError?.(`Cannot open url: ${href}`);
887
+ }
888
+ } catch {
889
+ onOpenAppError?.('An error occured with Linkinf.canOpenURL');
890
+ }
891
+ }
892
+ });
893
+ }
894
+
895
+ ExternalAppLink.Sms = function ({
896
+ phoneNumber,
897
+ children,
898
+ ...rest
899
+ }) {
900
+ return /*#__PURE__*/jsxRuntime.jsx(ExternalAppLink, { ...rest,
901
+ appScheme: "sms",
902
+ appValue: phoneNumber,
903
+ children: children
904
+ });
905
+ };
906
+
907
+ ExternalAppLink.Tel = function ({
908
+ phoneNumber,
909
+ children,
910
+ ...rest
911
+ }) {
912
+ return /*#__PURE__*/jsxRuntime.jsx(ExternalAppLink, { ...rest,
913
+ appScheme: "tel",
914
+ appValue: phoneNumber,
915
+ children: children
916
+ });
917
+ };
918
+
919
+ ExternalAppLink.Mail = function ({
920
+ emailAddress,
921
+ children,
922
+ ...rest
923
+ }) {
924
+ return /*#__PURE__*/jsxRuntime.jsx(ExternalAppLink, { ...rest,
925
+ appScheme: "mailto",
926
+ appValue: emailAddress,
927
+ children: children
928
+ });
929
+ };
930
+
859
931
  const defaultOpenLinkBehavior = {
860
932
  native: 'openInModal',
861
933
  web: 'targetBlank'
@@ -3865,6 +3937,7 @@ exports.Card = Card;
3865
3937
  exports.Checkbox = Checkbox;
3866
3938
  exports.DatePicker = DatePicker;
3867
3939
  exports.Emoji = Emoji;
3940
+ exports.ExternalAppLink = ExternalAppLink;
3868
3941
  exports.ExternalLink = ExternalLink;
3869
3942
  exports.Flex = Flex;
3870
3943
  exports.FullScreenModal = FullScreenModal;