@ornikar/kitt-universal 6.0.0 → 6.1.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 (44) hide show
  1. package/dist/definitions/Button/AnimatedButtonPressable.d.ts +2 -1
  2. package/dist/definitions/Button/AnimatedButtonPressable.d.ts.map +1 -1
  3. package/dist/definitions/Button/AnimatedButtonPressable.web.d.ts +2 -1
  4. package/dist/definitions/Button/AnimatedButtonPressable.web.d.ts.map +1 -1
  5. package/dist/definitions/Button/BaseStyledButtonPressable.d.ts +2 -1
  6. package/dist/definitions/Button/BaseStyledButtonPressable.d.ts.map +1 -1
  7. package/dist/definitions/Button/Button.d.ts +2 -0
  8. package/dist/definitions/Button/Button.d.ts.map +1 -1
  9. package/dist/definitions/Button/ButtonContent.d.ts +3 -2
  10. package/dist/definitions/Button/ButtonContent.d.ts.map +1 -1
  11. package/dist/definitions/Button/getVariantValuesIfExist.d.ts +5 -0
  12. package/dist/definitions/Button/getVariantValuesIfExist.d.ts.map +1 -0
  13. package/dist/definitions/ExternalLink/ExternalLink.d.ts +3 -3
  14. package/dist/definitions/ExternalLink/ExternalLink.d.ts.map +1 -1
  15. package/dist/definitions/themes/late-ocean/button.d.ts +26 -9
  16. package/dist/definitions/themes/late-ocean/button.d.ts.map +1 -1
  17. package/dist/definitions/utils/tests/renderWithProvidersUtils.d.ts +4 -2
  18. package/dist/definitions/utils/tests/renderWithProvidersUtils.d.ts.map +1 -1
  19. package/dist/index-browser-all.es.android.js +103 -49
  20. package/dist/index-browser-all.es.android.js.map +1 -1
  21. package/dist/index-browser-all.es.ios.js +103 -49
  22. package/dist/index-browser-all.es.ios.js.map +1 -1
  23. package/dist/index-browser-all.es.js +103 -49
  24. package/dist/index-browser-all.es.js.map +1 -1
  25. package/dist/index-browser-all.es.web.js +117 -54
  26. package/dist/index-browser-all.es.web.js.map +1 -1
  27. package/dist/index-node-14.17.cjs.js +96 -46
  28. package/dist/index-node-14.17.cjs.js.map +1 -1
  29. package/dist/index-node-14.17.cjs.web.js +113 -52
  30. package/dist/index-node-14.17.cjs.web.js.map +1 -1
  31. package/dist/linaria-themes-browser-all.es.android.js +56 -35
  32. package/dist/linaria-themes-browser-all.es.android.js.map +1 -1
  33. package/dist/linaria-themes-browser-all.es.ios.js +56 -35
  34. package/dist/linaria-themes-browser-all.es.ios.js.map +1 -1
  35. package/dist/linaria-themes-browser-all.es.js +56 -35
  36. package/dist/linaria-themes-browser-all.es.js.map +1 -1
  37. package/dist/linaria-themes-browser-all.es.web.js +56 -35
  38. package/dist/linaria-themes-browser-all.es.web.js.map +1 -1
  39. package/dist/linaria-themes-node-14.17.cjs.js +56 -35
  40. package/dist/linaria-themes-node-14.17.cjs.js.map +1 -1
  41. package/dist/linaria-themes-node-14.17.cjs.web.js +56 -35
  42. package/dist/linaria-themes-node-14.17.cjs.web.js.map +1 -1
  43. package/dist/tsbuildinfo +1 -1
  44. package/package.json +4 -4
@@ -376,6 +376,20 @@ function withTheme(WrappedComponent) {
376
376
  });
377
377
  }
378
378
 
379
+ const hasVariant = (button, variant) => {
380
+ return variant in button;
381
+ };
382
+
383
+ function getVariantValuesIfExist(theme, type, variant) {
384
+ const button = theme.kitt.button[type];
385
+
386
+ if (hasVariant(button, variant)) {
387
+ return button[variant];
388
+ }
389
+
390
+ return theme.kitt.button[type].default;
391
+ }
392
+
379
393
  function isSubtle(type) {
380
394
  return type.startsWith('subtle');
381
395
  }
@@ -400,10 +414,11 @@ const AnimatedButtonPressableContainer = withTheme( /*#__PURE__*/react$1.styled(
400
414
  "a1vkj3mh-5": [({
401
415
  theme,
402
416
  $type,
417
+ $variant,
403
418
  $isDisabled
404
419
  }) => {
405
- if ($isDisabled) return theme.kitt.button.disabled.hoverBackgroundColor;
406
- return theme.kitt.button[$type].hoverBackgroundColor;
420
+ if ($isDisabled) return theme.kitt.button.disabled.default.hoverBackgroundColor;
421
+ return getVariantValuesIfExist(theme, $type, $variant).hoverBackgroundColor;
407
422
  }],
408
423
  "a1vkj3mh-6": [({
409
424
  theme
@@ -431,11 +446,12 @@ const AnimatedButtonPressableContainer = withTheme( /*#__PURE__*/react$1.styled(
431
446
  }) => `calc(100% - ${theme.kitt.button.borderWidth.disabled * 0.5}px)`],
432
447
  "a1vkj3mh-14": [({
433
448
  theme
434
- }) => `${theme.kitt.button.borderWidth.disabled}px solid ${theme.kitt.button.disabled.borderColor}`],
449
+ }) => `${theme.kitt.button.borderWidth.disabled}px solid ${theme.kitt.button.disabled.default.borderColor}`],
435
450
  "a1vkj3mh-15": [({
436
451
  theme,
437
- $type
438
- }) => `${theme.kitt.button.borderWidth.focus}px solid ${theme.kitt.button[$type].focusBorderColor}`],
452
+ $type,
453
+ $variant
454
+ }) => `${theme.kitt.button.borderWidth.focus}px solid ${getVariantValuesIfExist(theme, $type, $variant).focusBorderColor}`],
439
455
  "a1vkj3mh-16": [({
440
456
  theme
441
457
  }) => `-${theme.kitt.button.borderWidth.focus}px`],
@@ -445,8 +461,12 @@ const AnimatedButtonPressableContainer = withTheme( /*#__PURE__*/react$1.styled(
445
461
  $isDisabled
446
462
  }) => {
447
463
  if ($isDisabled) return theme.kitt.typography.colors['black-light'];
448
- if (!isSubtle($type)) return 'inherit';
449
- return theme.kitt.button[$type].color;
464
+
465
+ if (isSubtle($type)) {
466
+ return theme.kitt.button[$type].default.color;
467
+ }
468
+
469
+ return 'inherit';
450
470
  }],
451
471
  "a1vkj3mh-19": [({
452
472
  theme,
@@ -454,8 +474,12 @@ const AnimatedButtonPressableContainer = withTheme( /*#__PURE__*/react$1.styled(
454
474
  $isDisabled
455
475
  }) => {
456
476
  if ($isDisabled) return theme.kitt.typography.colors['black-light'];
457
- if (!isSubtle($type)) return 'inherit';
458
- return theme.kitt.button[$type].hoverColor;
477
+
478
+ if (isSubtle($type)) {
479
+ return theme.kitt.button[$type].default.hoverColor;
480
+ }
481
+
482
+ return 'inherit';
459
483
  }],
460
484
  "a1vkj3mh-20": [({
461
485
  theme,
@@ -463,13 +487,18 @@ const AnimatedButtonPressableContainer = withTheme( /*#__PURE__*/react$1.styled(
463
487
  $isDisabled
464
488
  }) => {
465
489
  if ($isDisabled) return theme.kitt.typography.colors['black-light'];
466
- if (!isSubtle($type)) return 'inherit';
467
- return theme.kitt.button[$type].activeColor;
490
+
491
+ if (isSubtle($type)) {
492
+ return theme.kitt.button[$type].default.activeColor;
493
+ }
494
+
495
+ return 'inherit';
468
496
  }]
469
497
  }
470
498
  }));
471
499
  const AnimatedButtonPressable = /*#__PURE__*/react.forwardRef(({
472
500
  $type,
501
+ $variant,
473
502
  $isStretch,
474
503
  disabled,
475
504
  ...props
@@ -477,6 +506,7 @@ const AnimatedButtonPressable = /*#__PURE__*/react.forwardRef(({
477
506
  return /*#__PURE__*/jsxRuntime.jsx(AnimatedButtonPressableContainer, {
478
507
  ref: ref,
479
508
  $type: $type,
509
+ $variant: $variant,
480
510
  $isDisabled: !!disabled,
481
511
  $isStretch: $isStretch,
482
512
  children: /*#__PURE__*/jsxRuntime.jsx(BabelPluginStyledComponentsReactNative.Pressable, {
@@ -503,10 +533,11 @@ const BaseStyledButtonPressable = /*#__PURE__*/styled__default(BabelPluginStyled
503
533
  }) => theme.kitt.button.borderRadius, ({
504
534
  theme,
505
535
  $isDisabled,
506
- $type
536
+ $type,
537
+ $variant
507
538
  }) => {
508
- if ($isDisabled) return theme.kitt.button.disabled.backgroundColor;
509
- return theme.kitt.button[$type].backgroundColor;
539
+ if ($isDisabled) return theme.kitt.button.disabled.default.backgroundColor;
540
+ return getVariantValuesIfExist(theme, $type, $variant).backgroundColor;
510
541
  }, ({
511
542
  theme,
512
543
  $isLarge,
@@ -555,10 +586,10 @@ function TypographyIcon({
555
586
  });
556
587
  }
557
588
 
558
- const getTextColorByType = type => {
589
+ const getTextColorByType = (type, variant) => {
559
590
  switch (type) {
560
591
  case 'primary':
561
- return 'white';
592
+ return variant === 'ghost' ? 'primary' : 'white';
562
593
 
563
594
  case 'white':
564
595
  return 'white';
@@ -693,13 +724,14 @@ const ButtonContentContainer = /*#__PURE__*/styled__default(BabelPluginStyledCom
693
724
  });
694
725
  function ButtonContent({
695
726
  type,
727
+ variant,
696
728
  isDisabled,
697
729
  $isStretch,
698
730
  icon,
699
731
  children,
700
732
  ...props
701
733
  }) {
702
- const color = isDisabled ? 'black-light' : getTextColorByType(type);
734
+ const color = isDisabled ? 'black-light' : getTextColorByType(type, variant);
703
735
  return /*#__PURE__*/jsxRuntime.jsx(ButtonContentContainer, {
704
736
  $isSubtle: isSubtle(type),
705
737
  $isStretch: $isStretch,
@@ -718,6 +750,7 @@ function ButtonContent({
718
750
  const Button = /*#__PURE__*/react.forwardRef(({
719
751
  children,
720
752
  type = 'default',
753
+ variant = 'default',
721
754
  disabled,
722
755
  stretch,
723
756
  large,
@@ -729,6 +762,10 @@ const Button = /*#__PURE__*/react.forwardRef(({
729
762
  accessibilityRole = 'button',
730
763
  onPress
731
764
  }, ref) => {
765
+ if ((process.env.NODE_ENV !== "production") && variant === 'ghost' && type !== 'primary') {
766
+ throw new Error('variant=ghost is only allowed with type=primary');
767
+ }
768
+
732
769
  return /*#__PURE__*/jsxRuntime.jsx(AnimatedButtonPressable, {
733
770
  ref: ref,
734
771
  accessibilityRole: accessibilityRole,
@@ -738,14 +775,17 @@ const Button = /*#__PURE__*/react.forwardRef(({
738
775
  disabled: disabled,
739
776
  $isStretch: stretch,
740
777
  $type: type,
778
+ $variant: variant,
741
779
  onPress: onPress,
742
780
  children: /*#__PURE__*/jsxRuntime.jsxs(BaseStyledButtonPressable, {
743
781
  $type: type,
782
+ $variant: variant,
744
783
  $isStretch: stretch,
745
784
  $isLarge: large,
746
785
  $isDisabled: disabled,
747
786
  children: [/*#__PURE__*/jsxRuntime.jsx(ButtonContent, {
748
787
  type: type,
788
+ variant: variant,
749
789
  $isStretch: stretch,
750
790
  isDisabled: disabled,
751
791
  icon: icon,
@@ -919,47 +959,68 @@ const button = {
919
959
  timingFunction: 'cubic-bezier(0.645, 0.045, 0.355, 1)'
920
960
  },
921
961
  default: {
922
- backgroundColor: 'rgba(0, 0, 0, 0.05)',
923
- pressedBackgroundColor: 'rgba(0, 0, 0, 0.1)',
924
- hoverBackgroundColor: 'rgba(0, 0, 0, 0.1)',
925
- focusBorderColor: 'rgba(0, 0, 0, 0.1)'
962
+ default: {
963
+ backgroundColor: 'rgba(0, 0, 0, 0.05)',
964
+ pressedBackgroundColor: 'rgba(0, 0, 0, 0.1)',
965
+ hoverBackgroundColor: 'rgba(0, 0, 0, 0.1)',
966
+ focusBorderColor: 'rgba(0, 0, 0, 0.1)'
967
+ }
926
968
  },
927
969
  primary: {
928
- backgroundColor: colors.primary,
929
- pressedBackgroundColor: colors.primaryLight,
930
- hoverBackgroundColor: colors.primaryLight,
931
- focusBorderColor: 'rgba(76, 52, 224, 0.2)'
970
+ default: {
971
+ backgroundColor: colors.primary,
972
+ pressedBackgroundColor: colors.primaryLight,
973
+ hoverBackgroundColor: colors.primaryLight,
974
+ focusBorderColor: 'rgba(76, 52, 224, 0.2)'
975
+ },
976
+ ghost: {
977
+ backgroundColor: colors.uiBackgroundLight,
978
+ pressedBackgroundColor: colors.uiBackground,
979
+ hoverBackgroundColor: colors.hover,
980
+ focusBorderColor: 'rgba(255,255,255, 0.4)',
981
+ color: colors.primary,
982
+ hoverColor: colors.hover,
983
+ activeColor: colors.hover
984
+ }
932
985
  },
933
986
  white: {
934
- backgroundColor: 'rgba(255, 255, 255, 0.05)',
935
- pressedBackgroundColor: 'rgba(255, 255, 255, 0.1)',
936
- hoverBackgroundColor: 'rgba(255, 255, 255, 0.1)',
937
- focusBorderColor: 'rgba(255, 255, 255, 0.1)'
987
+ default: {
988
+ backgroundColor: 'rgba(255, 255, 255, 0.05)',
989
+ pressedBackgroundColor: 'rgba(255, 255, 255, 0.1)',
990
+ hoverBackgroundColor: 'rgba(255, 255, 255, 0.1)',
991
+ focusBorderColor: 'rgba(255, 255, 255, 0.1)'
992
+ }
938
993
  },
939
994
  subtle: {
940
- backgroundColor: colors.transparent,
941
- pressedBackgroundColor: colors.transparent,
942
- hoverBackgroundColor: colors.transparent,
943
- focusBorderColor: 'rgba(76, 52, 224, 0.2)',
944
- color: colors.primary,
945
- hoverColor: 'rgba(76, 52, 224, 0.8)',
946
- activeColor: 'rgba(76, 52, 224, 0.8)'
995
+ default: {
996
+ backgroundColor: colors.transparent,
997
+ pressedBackgroundColor: colors.transparent,
998
+ hoverBackgroundColor: colors.transparent,
999
+ focusBorderColor: 'rgba(76, 52, 224, 0.2)',
1000
+ color: colors.primary,
1001
+ hoverColor: 'rgba(76, 52, 224, 0.8)',
1002
+ activeColor: 'rgba(76, 52, 224, 0.8)'
1003
+ }
947
1004
  },
948
1005
  'subtle-dark': {
949
- backgroundColor: colors.transparent,
950
- pressedBackgroundColor: colors.transparent,
951
- hoverBackgroundColor: colors.transparent,
952
- focusBorderColor: 'rgba(0, 0, 0, 0.1)',
953
- color: colors.black,
954
- hoverColor: 'rgba(0, 0, 0, 0.8)',
955
- activeColor: 'rgba(0, 0, 0, 0.8)'
1006
+ default: {
1007
+ backgroundColor: colors.transparent,
1008
+ pressedBackgroundColor: colors.transparent,
1009
+ hoverBackgroundColor: colors.transparent,
1010
+ focusBorderColor: 'rgba(0, 0, 0, 0.1)',
1011
+ color: colors.black,
1012
+ hoverColor: 'rgba(0, 0, 0, 0.8)',
1013
+ activeColor: 'rgba(0, 0, 0, 0.8)'
1014
+ }
956
1015
  },
957
1016
  disabled: {
958
- backgroundColor: colors.disabled,
959
- pressedBackgroundColor: colors.disabled,
960
- hoverBackgroundColor: colors.disabled,
961
- focusBorderColor: lateOceanColorPalette.black100,
962
- borderColor: lateOceanColorPalette.black100
1017
+ default: {
1018
+ backgroundColor: colors.disabled,
1019
+ pressedBackgroundColor: colors.disabled,
1020
+ hoverBackgroundColor: colors.disabled,
1021
+ focusBorderColor: lateOceanColorPalette.black100,
1022
+ borderColor: lateOceanColorPalette.black100
1023
+ }
963
1024
  }
964
1025
  };
965
1026
 
@@ -1235,14 +1296,14 @@ const iconButton = {
1235
1296
  },
1236
1297
  disabled: {
1237
1298
  scale: 1,
1238
- backgroundColor: button.disabled.backgroundColor,
1239
- borderColor: button.disabled.borderColor
1299
+ backgroundColor: button.disabled.default.backgroundColor,
1300
+ borderColor: button.disabled.default.borderColor
1240
1301
  },
1241
1302
  default: {
1242
- pressedBackgroundColor: button.default.pressedBackgroundColor
1303
+ pressedBackgroundColor: button.default.default.pressedBackgroundColor
1243
1304
  },
1244
1305
  white: {
1245
- pressedBackgroundColor: button.white.hoverBackgroundColor
1306
+ pressedBackgroundColor: button.white.default.hoverBackgroundColor
1246
1307
  }
1247
1308
  };
1248
1309