@skyscanner/backpack-web 36.18.0 → 37.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.
- package/bpk-component-button/src/BpkButtonBase.module.css +1 -1
- package/bpk-component-button/src/BpkButtonV2/BpkButton.module.css +1 -1
- package/bpk-component-carousel/src/BpkCarousel.js +0 -2
- package/bpk-component-checkbox/src/BpkCheckbox.module.css +1 -1
- package/bpk-component-icon/all.d.ts +2 -1
- package/bpk-component-icon/all.js +2 -1
- package/bpk-component-icon/lg/award.js +1 -1
- package/bpk-component-icon/lg/baggage-personal-item.js +14 -0
- package/bpk-component-icon/lg/bus.js +8 -5
- package/bpk-component-icon/sm/award.js +1 -1
- package/bpk-component-icon/sm/baggage-personal-item.js +14 -0
- package/bpk-component-icon/sm/bus.js +3 -2
- package/bpk-component-icon/sm/check.js +18 -0
- package/bpk-component-icon/xl/star-half.js +14 -0
- package/bpk-component-icon/xl/star-outline.js +14 -0
- package/bpk-component-icon/xl/star.js +14 -0
- package/bpk-component-inset-banner/src/BpkInsetBanner.d.ts +3 -0
- package/bpk-component-inset-banner/src/BpkInsetBanner.js +8 -0
- package/bpk-component-inset-banner/src/BpkInsetBanner.module.css +1 -1
- package/bpk-component-link/src/BpkLink.js +11 -5
- package/bpk-component-link/src/BpkLink.module.css +1 -1
- package/bpk-component-overlay/src/BpkOverlay.d.ts +2 -2
- package/bpk-component-overlay/src/BpkOverlay.js +4 -4
- package/bpk-component-overlay/src/BpkOverlay.module.css +1 -1
- package/bpk-component-page-indicator/index.d.ts +6 -0
- package/bpk-component-page-indicator/index.js +3 -1
- package/bpk-component-page-indicator/src/BpkPageIndicator.d.ts +21 -0
- package/bpk-component-page-indicator/src/BpkPageIndicator.js +49 -68
- package/bpk-component-page-indicator/src/NavButton.d.ts +15 -0
- package/bpk-component-page-indicator/src/NavButton.js +22 -35
- package/bpk-component-price/src/BpkPrice.js +6 -2
- package/bpk-component-tooltip/index.d.ts +4 -4
- package/bpk-component-tooltip/index.js +2 -2
- package/bpk-component-tooltip/src/BpkTooltip.d.ts +17 -4
- package/bpk-component-tooltip/src/BpkTooltip.js +100 -23
- package/bpk-component-tooltip/src/BpkTooltip.module.css +1 -1
- package/bpk-mixins/_buttons.scss +5 -1
- package/bpk-mixins/_forms.scss +5 -26
- package/bpk-mixins/_typography.scss +101 -8
- package/package.json +3 -3
- package/unstable__bpk-mixins/_buttons.scss +5 -1
- package/unstable__bpk-mixins/_forms.scss +5 -28
- package/unstable__bpk-mixins/_typography.scss +101 -8
- package/bpk-component-tooltip/src/BpkTooltipPortal.d.ts +0 -54
- package/bpk-component-tooltip/src/BpkTooltipPortal.js +0 -154
|
@@ -782,6 +782,8 @@
|
|
|
782
782
|
/// }
|
|
783
783
|
|
|
784
784
|
@mixin bpk-link {
|
|
785
|
+
position: relative;
|
|
786
|
+
display: inline-block;
|
|
785
787
|
padding: 0;
|
|
786
788
|
border: 0;
|
|
787
789
|
background-color: transparent;
|
|
@@ -789,34 +791,117 @@
|
|
|
789
791
|
cursor: pointer;
|
|
790
792
|
appearance: none;
|
|
791
793
|
|
|
792
|
-
@include bpk-themeable-property(
|
|
794
|
+
@include bpk-themeable-property(
|
|
795
|
+
color,
|
|
796
|
+
--bpk-link-color,
|
|
797
|
+
$bpk-text-primary-day
|
|
798
|
+
);
|
|
793
799
|
|
|
794
800
|
@include bpk-hover {
|
|
795
|
-
text-decoration:
|
|
801
|
+
text-decoration: none;
|
|
796
802
|
|
|
797
803
|
@include bpk-themeable-property(
|
|
798
804
|
color,
|
|
799
805
|
--bpk-link-hover-color,
|
|
800
|
-
$bpk-text-
|
|
806
|
+
$bpk-text-primary-day
|
|
801
807
|
);
|
|
808
|
+
|
|
809
|
+
&::after {
|
|
810
|
+
width: 0%;
|
|
811
|
+
}
|
|
802
812
|
}
|
|
803
813
|
|
|
804
814
|
&:visited {
|
|
805
815
|
@include bpk-themeable-property(
|
|
806
816
|
color,
|
|
807
817
|
--bpk-link-visited-color,
|
|
808
|
-
$bpk-text-
|
|
818
|
+
$bpk-text-primary-day
|
|
809
819
|
);
|
|
810
820
|
}
|
|
811
821
|
|
|
822
|
+
&:active {
|
|
823
|
+
@include bpk-themeable-property(
|
|
824
|
+
color,
|
|
825
|
+
--bpk-link-active-color,
|
|
826
|
+
$bpk-text-primary-day
|
|
827
|
+
);
|
|
828
|
+
|
|
829
|
+
&::after {
|
|
830
|
+
width: 0%;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
&::after {
|
|
835
|
+
position: absolute;
|
|
836
|
+
bottom: 0;
|
|
837
|
+
content: '';
|
|
838
|
+
display: block;
|
|
839
|
+
width: 100%;
|
|
840
|
+
height: tokens.$bpk-border-size-sm;
|
|
841
|
+
transition:
|
|
842
|
+
width 0.2s ease 0s,
|
|
843
|
+
left 0.2s ease 0s;
|
|
844
|
+
|
|
845
|
+
@include bpk-themeable-property(
|
|
846
|
+
background,
|
|
847
|
+
--bpk-link-color,
|
|
848
|
+
$bpk-text-primary-day
|
|
849
|
+
);
|
|
850
|
+
|
|
851
|
+
@media (prefers-reduced-motion) {
|
|
852
|
+
transition:
|
|
853
|
+
width 0s ease 0s,
|
|
854
|
+
left 0s ease 0s;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/// Implicit inline link.
|
|
860
|
+
///
|
|
861
|
+
/// @example scss
|
|
862
|
+
/// .selector {
|
|
863
|
+
/// @include bpk-link();
|
|
864
|
+
/// @include bpk-link--implicit();
|
|
865
|
+
/// }
|
|
866
|
+
|
|
867
|
+
@mixin bpk-link--implicit {
|
|
868
|
+
@include bpk-themeable-property(
|
|
869
|
+
color,
|
|
870
|
+
--bpk-link-color,
|
|
871
|
+
$bpk-text-primary-day
|
|
872
|
+
);
|
|
873
|
+
|
|
874
|
+
@include bpk-hover {
|
|
875
|
+
@include bpk-themeable-property(
|
|
876
|
+
color,
|
|
877
|
+
--bpk-link-hover-color,
|
|
878
|
+
$bpk-text-primary-day
|
|
879
|
+
);
|
|
880
|
+
|
|
881
|
+
&::after {
|
|
882
|
+
width: 100%;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
&::after {
|
|
887
|
+
width: 0;
|
|
888
|
+
transition:
|
|
889
|
+
width 0.2s ease 0s,
|
|
890
|
+
left 0.2s ease 0s;
|
|
891
|
+
}
|
|
892
|
+
|
|
812
893
|
&:active {
|
|
813
894
|
text-decoration: underline;
|
|
814
895
|
|
|
815
896
|
@include bpk-themeable-property(
|
|
816
897
|
color,
|
|
817
898
|
--bpk-link-active-color,
|
|
818
|
-
$bpk-text-
|
|
899
|
+
$bpk-text-primary-day
|
|
819
900
|
);
|
|
901
|
+
|
|
902
|
+
&::after {
|
|
903
|
+
width: 100%;
|
|
904
|
+
}
|
|
820
905
|
}
|
|
821
906
|
}
|
|
822
907
|
|
|
@@ -845,6 +930,14 @@
|
|
|
845
930
|
);
|
|
846
931
|
}
|
|
847
932
|
|
|
933
|
+
&::after {
|
|
934
|
+
@include bpk-themeable-property(
|
|
935
|
+
background,
|
|
936
|
+
--bpk-link-alternate-color,
|
|
937
|
+
$bpk-text-on-dark-day
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
|
|
848
941
|
&:visited {
|
|
849
942
|
@include bpk-themeable-property(
|
|
850
943
|
color,
|
|
@@ -877,14 +970,14 @@
|
|
|
877
970
|
/// }
|
|
878
971
|
|
|
879
972
|
@mixin bpk-link--active {
|
|
880
|
-
color: $bpk-text-
|
|
973
|
+
color: $bpk-text-primary-day;
|
|
881
974
|
|
|
882
975
|
&:visited {
|
|
883
|
-
color: $bpk-text-
|
|
976
|
+
color: $bpk-text-primary-day;
|
|
884
977
|
}
|
|
885
978
|
|
|
886
979
|
&:active {
|
|
887
|
-
color: $bpk-text-
|
|
980
|
+
color: $bpk-text-primary-day;
|
|
888
981
|
}
|
|
889
982
|
}
|
|
890
983
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.1.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"@radix-ui/react-compose-refs": "^1.1.1",
|
|
28
28
|
"@radix-ui/react-slider": "1.1.2",
|
|
29
29
|
"@react-google-maps/api": "^2.19.3",
|
|
30
|
-
"@skyscanner/bpk-foundations-web": "^19.1
|
|
31
|
-
"@skyscanner/bpk-svgs": "^20.
|
|
30
|
+
"@skyscanner/bpk-foundations-web": "^19.4.1",
|
|
31
|
+
"@skyscanner/bpk-svgs": "^20.4.1",
|
|
32
32
|
"a11y-focus-scope": "^1.1.3",
|
|
33
33
|
"a11y-focus-store": "^1.0.0",
|
|
34
34
|
"d3-path": "^2.0.0",
|
|
@@ -395,7 +395,11 @@
|
|
|
395
395
|
background: none; /* stylelint-disable-line order/order, order/properties-order */
|
|
396
396
|
box-shadow: none;
|
|
397
397
|
|
|
398
|
-
@include typography.bpk-link;
|
|
398
|
+
@include typography.bpk-link--implicit;
|
|
399
|
+
|
|
400
|
+
&::after {
|
|
401
|
+
bottom: auto;
|
|
402
|
+
}
|
|
399
403
|
|
|
400
404
|
padding: $vertical-padding 0; /* stylelint-disable-line order/order, order/properties-order */
|
|
401
405
|
color: tokens.$bpk-private-button-link-normal-foreground-day;
|
|
@@ -18,8 +18,6 @@
|
|
|
18
18
|
|
|
19
19
|
/* stylelint-disable at-rule-disallowed-list */
|
|
20
20
|
|
|
21
|
-
@use "sass:math";
|
|
22
|
-
|
|
23
21
|
@use 'tokens.scss';
|
|
24
22
|
@use 'typography.scss';
|
|
25
23
|
@use 'utils.scss';
|
|
@@ -629,34 +627,13 @@
|
|
|
629
627
|
/// @include bpk-checkbox__checkmark();
|
|
630
628
|
/// }
|
|
631
629
|
@mixin bpk-checkbox__checkmark {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
transform: rotate(45deg);
|
|
637
|
-
border-radius: tokens.$bpk-border-size-lg;
|
|
638
|
-
background-color: tokens.$bpk-text-primary-inverse-day;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
&::before {
|
|
642
|
-
top: tokens.bpk-spacing-md() - tokens.$bpk-one-pixel-rem;
|
|
643
|
-
left: 0;
|
|
644
|
-
width: math.div(tokens.bpk-spacing-lg(), 3);
|
|
645
|
-
height: tokens.bpk-spacing-sm() - tokens.$bpk-one-pixel-rem;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
&::after {
|
|
649
|
-
top: tokens.bpk-spacing-sm() * 0.5;
|
|
650
|
-
left: tokens.bpk-spacing-md() - tokens.$bpk-one-pixel-rem;
|
|
651
|
-
width: tokens.bpk-spacing-sm() - tokens.$bpk-one-pixel-rem;
|
|
652
|
-
height: tokens.bpk-spacing-md() + (tokens.$bpk-one-pixel-rem * 3);
|
|
653
|
-
}
|
|
630
|
+
background-image: url('data:image/svg+xml,%3Csvg%20width%3D%2213%22%20height%3D%229%22%20viewBox%3D%220%200%2013%209%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M2.35352%203.64648L5.5%207.5L11.5%201.5%22%20stroke%3D%22white%22%20stroke-width%3D%223%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
|
|
631
|
+
background-repeat: no-repeat;
|
|
632
|
+
background-position: tokens.$bpk-one-pixel-rem center;
|
|
633
|
+
background-size: calc(100% - tokens.$bpk-one-pixel-rem * 2.5) auto;
|
|
654
634
|
|
|
655
635
|
&:disabled {
|
|
656
|
-
|
|
657
|
-
&::after {
|
|
658
|
-
background-color: tokens.$bpk-text-disabled-day;
|
|
659
|
-
}
|
|
636
|
+
background-image: url('data:image/svg+xml,%3Csvg%20width%3D%2213%22%20height%3D%229%22%20viewBox%3D%220%200%2013%209%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M2.35352%203.64648L5.5%207.5L11.5%201.5%22%20stroke%3D%22lightgrey%22%20stroke-width%3D%223%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
|
|
660
637
|
}
|
|
661
638
|
}
|
|
662
639
|
|
|
@@ -782,6 +782,8 @@
|
|
|
782
782
|
/// }
|
|
783
783
|
|
|
784
784
|
@mixin bpk-link {
|
|
785
|
+
position: relative;
|
|
786
|
+
display: inline-block;
|
|
785
787
|
padding: 0;
|
|
786
788
|
border: 0;
|
|
787
789
|
background-color: transparent;
|
|
@@ -789,34 +791,117 @@
|
|
|
789
791
|
cursor: pointer;
|
|
790
792
|
appearance: none;
|
|
791
793
|
|
|
792
|
-
@include utils.bpk-themeable-property(
|
|
794
|
+
@include utils.bpk-themeable-property(
|
|
795
|
+
color,
|
|
796
|
+
--bpk-link-color,
|
|
797
|
+
tokens.$bpk-text-primary-day
|
|
798
|
+
);
|
|
793
799
|
|
|
794
800
|
@include utils.bpk-hover {
|
|
795
|
-
text-decoration:
|
|
801
|
+
text-decoration: none;
|
|
796
802
|
|
|
797
803
|
@include utils.bpk-themeable-property(
|
|
798
804
|
color,
|
|
799
805
|
--bpk-link-hover-color,
|
|
800
|
-
tokens.$bpk-text-
|
|
806
|
+
tokens.$bpk-text-primary-day
|
|
801
807
|
);
|
|
808
|
+
|
|
809
|
+
&::after {
|
|
810
|
+
width: 0%;
|
|
811
|
+
}
|
|
802
812
|
}
|
|
803
813
|
|
|
804
814
|
&:visited {
|
|
805
815
|
@include utils.bpk-themeable-property(
|
|
806
816
|
color,
|
|
807
817
|
--bpk-link-visited-color,
|
|
808
|
-
tokens.$bpk-text-
|
|
818
|
+
tokens.$bpk-text-primary-day
|
|
809
819
|
);
|
|
810
820
|
}
|
|
811
821
|
|
|
822
|
+
&:active {
|
|
823
|
+
@include utils.bpk-themeable-property(
|
|
824
|
+
color,
|
|
825
|
+
--bpk-link-active-color,
|
|
826
|
+
tokens.$bpk-text-primary-day
|
|
827
|
+
);
|
|
828
|
+
|
|
829
|
+
&::after {
|
|
830
|
+
width: 0%;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
&::after {
|
|
835
|
+
position: absolute;
|
|
836
|
+
bottom: 0;
|
|
837
|
+
content: '';
|
|
838
|
+
display: block;
|
|
839
|
+
width: 100%;
|
|
840
|
+
height: tokens.$bpk-border-size-sm;
|
|
841
|
+
transition:
|
|
842
|
+
width 0.2s ease 0s,
|
|
843
|
+
left 0.2s ease 0s;
|
|
844
|
+
|
|
845
|
+
@include utils.bpk-themeable-property(
|
|
846
|
+
background,
|
|
847
|
+
--bpk-link-color,
|
|
848
|
+
tokens.$bpk-text-primary-day
|
|
849
|
+
);
|
|
850
|
+
|
|
851
|
+
@media (prefers-reduced-motion) {
|
|
852
|
+
transition:
|
|
853
|
+
width 0s ease 0s,
|
|
854
|
+
left 0s ease 0s;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/// Implicit inline link.
|
|
860
|
+
///
|
|
861
|
+
/// @example scss
|
|
862
|
+
/// .selector {
|
|
863
|
+
/// @include bpk-link();
|
|
864
|
+
/// @include bpk-link--implicit();
|
|
865
|
+
/// }
|
|
866
|
+
|
|
867
|
+
@mixin bpk-link--implicit {
|
|
868
|
+
@include utils.bpk-themeable-property(
|
|
869
|
+
color,
|
|
870
|
+
--bpk-link-color,
|
|
871
|
+
tokens.$bpk-text-primary-day
|
|
872
|
+
);
|
|
873
|
+
|
|
874
|
+
@include utils.bpk-hover {
|
|
875
|
+
@include utils.bpk-themeable-property(
|
|
876
|
+
color,
|
|
877
|
+
--bpk-link-hover-color,
|
|
878
|
+
tokens.$bpk-text-primary-day
|
|
879
|
+
);
|
|
880
|
+
|
|
881
|
+
&::after {
|
|
882
|
+
width: 100%;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
&::after {
|
|
887
|
+
width: 0;
|
|
888
|
+
transition:
|
|
889
|
+
width 0.2s ease 0s,
|
|
890
|
+
left 0.2s ease 0s;
|
|
891
|
+
}
|
|
892
|
+
|
|
812
893
|
&:active {
|
|
813
894
|
text-decoration: underline;
|
|
814
895
|
|
|
815
896
|
@include utils.bpk-themeable-property(
|
|
816
897
|
color,
|
|
817
898
|
--bpk-link-active-color,
|
|
818
|
-
tokens.$bpk-text-
|
|
899
|
+
tokens.$bpk-text-primary-day
|
|
819
900
|
);
|
|
901
|
+
|
|
902
|
+
&::after {
|
|
903
|
+
width: 100%;
|
|
904
|
+
}
|
|
820
905
|
}
|
|
821
906
|
}
|
|
822
907
|
|
|
@@ -845,6 +930,14 @@
|
|
|
845
930
|
);
|
|
846
931
|
}
|
|
847
932
|
|
|
933
|
+
&::after {
|
|
934
|
+
@include utils.bpk-themeable-property(
|
|
935
|
+
background,
|
|
936
|
+
--bpk-link-alternate-color,
|
|
937
|
+
tokens.$bpk-text-on-dark-day
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
|
|
848
941
|
&:visited {
|
|
849
942
|
@include utils.bpk-themeable-property(
|
|
850
943
|
color,
|
|
@@ -877,14 +970,14 @@
|
|
|
877
970
|
/// }
|
|
878
971
|
|
|
879
972
|
@mixin bpk-link--active {
|
|
880
|
-
color: tokens.$bpk-text-
|
|
973
|
+
color: tokens.$bpk-text-primary-day;
|
|
881
974
|
|
|
882
975
|
&:visited {
|
|
883
|
-
color: tokens.$bpk-text-
|
|
976
|
+
color: tokens.$bpk-text-primary-day;
|
|
884
977
|
}
|
|
885
978
|
|
|
886
979
|
&:active {
|
|
887
|
-
color: tokens.$bpk-text-
|
|
980
|
+
color: tokens.$bpk-text-primary-day;
|
|
888
981
|
}
|
|
889
982
|
}
|
|
890
983
|
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
|
-
import type { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { createPopper } from '@popperjs/core';
|
|
4
|
-
import type { TooltipProps } from './BpkTooltip';
|
|
5
|
-
export type Props = TooltipProps & {
|
|
6
|
-
/**
|
|
7
|
-
* Tooltips are invisible to assistive technologies such as screen readers.
|
|
8
|
-
* To improve accessibility, `ariaLabel` is required to describe the content of the tooltip to assistive technologies.
|
|
9
|
-
* The label will be used on the `target` element, so any existing `aria-label` attached to `target` will be overridden.
|
|
10
|
-
*/
|
|
11
|
-
ariaLabel: string;
|
|
12
|
-
/**
|
|
13
|
-
* "target" should be a DOM element with a "ref" attached to it.
|
|
14
|
-
*/
|
|
15
|
-
target: ReactElement<any>;
|
|
16
|
-
children: ReactNode | string;
|
|
17
|
-
placement?: 'top' | 'right' | 'bottom' | 'left' | 'auto';
|
|
18
|
-
hideOnTouchDevices?: boolean;
|
|
19
|
-
portalStyle?: object;
|
|
20
|
-
portalClassName?: string;
|
|
21
|
-
renderTarget: null | (() => null | HTMLElement);
|
|
22
|
-
/**
|
|
23
|
-
* Please refer to the [documentation](https://popper.js.org/docs/v2/modifiers/) for the underlying positioning library "Popper.js".
|
|
24
|
-
* You can achieve various behaviours such as allowing the tooltip to overflow the viewport etc.
|
|
25
|
-
*/
|
|
26
|
-
popperModifiers?: object[];
|
|
27
|
-
};
|
|
28
|
-
type State = {
|
|
29
|
-
isOpen: boolean;
|
|
30
|
-
};
|
|
31
|
-
declare class BpkTooltipPortal extends Component<Props, State> {
|
|
32
|
-
popper?: ReturnType<typeof createPopper> | null;
|
|
33
|
-
targetRef?: Element | null;
|
|
34
|
-
static defaultProps: {
|
|
35
|
-
className: null;
|
|
36
|
-
padded: boolean;
|
|
37
|
-
type: "light";
|
|
38
|
-
placement: string;
|
|
39
|
-
hideOnTouchDevices: boolean;
|
|
40
|
-
portalStyle: null;
|
|
41
|
-
portalClassName: null;
|
|
42
|
-
renderTarget: null;
|
|
43
|
-
popperModifiers: null;
|
|
44
|
-
};
|
|
45
|
-
constructor(props: Props);
|
|
46
|
-
componentDidMount(): void;
|
|
47
|
-
componentWillUnmount(): void;
|
|
48
|
-
onOpen: (tooltipElement: HTMLElement, targetElement?: HTMLElement | null | undefined) => void;
|
|
49
|
-
beforeClose: (done: () => void | null) => void;
|
|
50
|
-
openTooltip: () => void;
|
|
51
|
-
closeTooltip: () => void;
|
|
52
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
53
|
-
}
|
|
54
|
-
export default BpkTooltipPortal;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Backpack - Skyscanner's Design System
|
|
3
|
-
*
|
|
4
|
-
* Copyright 2016 Skyscanner Ltd
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { cloneElement, Component } from 'react';
|
|
20
|
-
import { createPopper } from '@popperjs/core';
|
|
21
|
-
import { Portal, cssModules } from "../../bpk-react-utils";
|
|
22
|
-
import BpkTooltip from "./BpkTooltip";
|
|
23
|
-
import { TOOLTIP_TYPES } from "./constants";
|
|
24
|
-
import STYLES from "./BpkTooltip.module.css";
|
|
25
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
|
-
const getClassName = cssModules(STYLES);
|
|
27
|
-
const hasTouchSupport = () => !!(typeof window !== 'undefined' && ('ontouchstart' in window || navigator.maxTouchPoints > 0));
|
|
28
|
-
class BpkTooltipPortal extends Component {
|
|
29
|
-
static defaultProps = {
|
|
30
|
-
// Disabling as the rule doesn't work when types are defined in a different file
|
|
31
|
-
/* eslint-disable react/default-props-match-prop-types */
|
|
32
|
-
className: null,
|
|
33
|
-
padded: true,
|
|
34
|
-
type: TOOLTIP_TYPES.light,
|
|
35
|
-
/* eslint-enable */
|
|
36
|
-
placement: 'bottom',
|
|
37
|
-
hideOnTouchDevices: true,
|
|
38
|
-
portalStyle: null,
|
|
39
|
-
portalClassName: null,
|
|
40
|
-
renderTarget: null,
|
|
41
|
-
popperModifiers: null
|
|
42
|
-
};
|
|
43
|
-
constructor(props) {
|
|
44
|
-
super(props);
|
|
45
|
-
this.state = {
|
|
46
|
-
isOpen: false
|
|
47
|
-
};
|
|
48
|
-
this.popper = null;
|
|
49
|
-
this.targetRef = null;
|
|
50
|
-
}
|
|
51
|
-
componentDidMount() {
|
|
52
|
-
if (this.targetRef) {
|
|
53
|
-
const ref = this.targetRef;
|
|
54
|
-
ref.addEventListener('focusin', this.openTooltip);
|
|
55
|
-
ref.addEventListener('focusout', this.closeTooltip);
|
|
56
|
-
ref.addEventListener('mouseenter', this.openTooltip);
|
|
57
|
-
ref.addEventListener('mouseleave', this.closeTooltip);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
componentWillUnmount() {
|
|
61
|
-
if (this.targetRef) {
|
|
62
|
-
const ref = this.targetRef;
|
|
63
|
-
ref.addEventListener('focusin', this.openTooltip);
|
|
64
|
-
ref.addEventListener('focusout', this.closeTooltip);
|
|
65
|
-
ref.removeEventListener('mouseenter', this.openTooltip);
|
|
66
|
-
ref.removeEventListener('mouseleave', this.closeTooltip);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
onOpen = (tooltipElement, targetElement) => {
|
|
70
|
-
// The default modifiers for the popper
|
|
71
|
-
// Note that GPU acceleration should be disabled otherwise Popper will use `translate3d`
|
|
72
|
-
// which can cause blurriness in Safari and Chrome.
|
|
73
|
-
const stdModifiers = [{
|
|
74
|
-
name: 'computeStyles',
|
|
75
|
-
options: {
|
|
76
|
-
gpuAcceleration: false
|
|
77
|
-
}
|
|
78
|
-
}, {
|
|
79
|
-
name: 'offset',
|
|
80
|
-
options: {
|
|
81
|
-
offset: [0, 8]
|
|
82
|
-
}
|
|
83
|
-
}];
|
|
84
|
-
this.popper = createPopper(targetElement, tooltipElement, {
|
|
85
|
-
placement: this.props.placement,
|
|
86
|
-
modifiers: this.props.popperModifiers ? [...this.props.popperModifiers, ...stdModifiers] : stdModifiers
|
|
87
|
-
});
|
|
88
|
-
this.popper.update();
|
|
89
|
-
};
|
|
90
|
-
beforeClose = done => {
|
|
91
|
-
if (this.popper) {
|
|
92
|
-
this.popper.destroy();
|
|
93
|
-
this.popper = null;
|
|
94
|
-
}
|
|
95
|
-
done();
|
|
96
|
-
};
|
|
97
|
-
openTooltip = () => {
|
|
98
|
-
this.setState({
|
|
99
|
-
isOpen: true
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
closeTooltip = () => {
|
|
103
|
-
this.setState({
|
|
104
|
-
isOpen: false
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
render() {
|
|
108
|
-
const {
|
|
109
|
-
ariaLabel,
|
|
110
|
-
children,
|
|
111
|
-
hideOnTouchDevices,
|
|
112
|
-
padded,
|
|
113
|
-
placement,
|
|
114
|
-
popperModifiers,
|
|
115
|
-
portalClassName,
|
|
116
|
-
portalStyle,
|
|
117
|
-
renderTarget,
|
|
118
|
-
target,
|
|
119
|
-
...rest
|
|
120
|
-
} = this.props;
|
|
121
|
-
const classNames = [getClassName('bpk-tooltip-portal')];
|
|
122
|
-
const renderPortal = !hasTouchSupport() || !hideOnTouchDevices;
|
|
123
|
-
const targetWithAccessibilityProps = /*#__PURE__*/cloneElement(target, {
|
|
124
|
-
tabIndex: '0',
|
|
125
|
-
'aria-label': ariaLabel
|
|
126
|
-
});
|
|
127
|
-
if (portalClassName) {
|
|
128
|
-
classNames.push(portalClassName);
|
|
129
|
-
}
|
|
130
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
131
|
-
children: [targetWithAccessibilityProps, renderPortal && /*#__PURE__*/_jsx(Portal, {
|
|
132
|
-
target: targetWithAccessibilityProps,
|
|
133
|
-
targetRef: targetRef => {
|
|
134
|
-
this.targetRef = targetRef;
|
|
135
|
-
},
|
|
136
|
-
isOpen: this.state.isOpen,
|
|
137
|
-
onOpen: this.onOpen,
|
|
138
|
-
onClose: this.closeTooltip,
|
|
139
|
-
style: portalStyle,
|
|
140
|
-
renderTarget: renderTarget
|
|
141
|
-
// TODO: className to be removed
|
|
142
|
-
// eslint-disable-next-line @skyscanner/rules/forbid-component-props
|
|
143
|
-
,
|
|
144
|
-
className: classNames.join(' '),
|
|
145
|
-
children: /*#__PURE__*/_jsx(BpkTooltip, {
|
|
146
|
-
padded: padded,
|
|
147
|
-
...rest,
|
|
148
|
-
children: children
|
|
149
|
-
})
|
|
150
|
-
})]
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
export default BpkTooltipPortal;
|