@skyscanner/backpack-web 34.15.1 → 34.16.0-preminor.2

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 (157) hide show
  1. package/bpk-component-aria-live/src/BpkAriaLive.d.ts +1 -1
  2. package/bpk-component-badge/src/BpkBadge.d.ts +1 -1
  3. package/bpk-component-banner-alert/src/AnimateAndFade.d.ts +1 -1
  4. package/bpk-component-banner-alert/src/BpkBannerAlert.d.ts +1 -2
  5. package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.d.ts +1 -2
  6. package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.d.ts +1 -1
  7. package/bpk-component-banner-alert/src/BpkBannerAlertInner.d.ts +1 -1
  8. package/bpk-component-banner-alert/src/withBannerAlertState.d.ts +36 -44
  9. package/bpk-component-boilerplate/src/BpkBoilerplate.d.ts +1 -2
  10. package/bpk-component-bottom-sheet/src/BpkBottomSheet.d.ts +1 -1
  11. package/bpk-component-button/BpkButtonDestructive.d.ts +1 -2
  12. package/bpk-component-button/BpkButtonFeatured.d.ts +1 -2
  13. package/bpk-component-button/BpkButtonLink.d.ts +1 -2
  14. package/bpk-component-button/BpkButtonLinkOnDark.d.ts +1 -2
  15. package/bpk-component-button/BpkButtonPrimary.d.ts +1 -2
  16. package/bpk-component-button/BpkButtonPrimaryOnDark.d.ts +1 -2
  17. package/bpk-component-button/BpkButtonPrimaryOnLight.d.ts +1 -2
  18. package/bpk-component-button/BpkButtonSecondary.d.ts +1 -2
  19. package/bpk-component-button/BpkButtonSecondaryOnDark.d.ts +1 -2
  20. package/bpk-component-button/src/BpkButton.d.ts +1 -2
  21. package/bpk-component-button/src/BpkButtonBase.d.ts +2 -13
  22. package/bpk-component-button/src/BpkButtonDestructive.module.css +18 -0
  23. package/bpk-component-button/src/BpkButtonFeatured.module.css +18 -0
  24. package/bpk-component-button/src/BpkButtonLink.module.css +18 -0
  25. package/bpk-component-button/src/BpkButtonLinkOnDark.module.css +18 -0
  26. package/bpk-component-button/src/BpkButtonPrimaryOnDark.module.css +18 -0
  27. package/bpk-component-button/src/BpkButtonPrimaryOnLight.module.css +18 -0
  28. package/bpk-component-button/src/BpkButtonSecondary.module.css +18 -0
  29. package/bpk-component-button/src/BpkButtonSecondaryOnDark.module.css +18 -0
  30. package/bpk-component-button/src/BpkButtonV2/BpkButton.d.ts +1 -2
  31. package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +10 -14
  32. package/bpk-component-calendar/src/BpkCalendarDate.d.ts +1 -1
  33. package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +5 -5
  34. package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +1 -1
  35. package/bpk-component-calendar/src/BpkCalendarGridTransition.d.ts +2 -2
  36. package/bpk-component-calendar/src/BpkCalendarNav.d.ts +1 -1
  37. package/bpk-component-calendar/src/BpkCalendarWeek.d.ts +1 -1
  38. package/bpk-component-calendar/src/composeCalendar.d.ts +1 -1
  39. package/bpk-component-card/src/BpkCard.d.ts +1 -1
  40. package/bpk-component-card/src/BpkCardWrapper.d.ts +1 -1
  41. package/bpk-component-card/src/BpkDividedCard.d.ts +1 -1
  42. package/bpk-component-card/src/CardContext.d.ts +0 -1
  43. package/bpk-component-card-button/src/BpkSaveButton.d.ts +1 -1
  44. package/bpk-component-carousel/src/BpkCarousel.d.ts +1 -2
  45. package/bpk-component-carousel/src/BpkCarouselContainer.d.ts +1 -1
  46. package/bpk-component-carousel/src/utils.test.js +30 -0
  47. package/bpk-component-chip/src/BpkDismissibleChip.d.ts +1 -2
  48. package/bpk-component-chip/src/BpkDropdownChip.d.ts +1 -2
  49. package/bpk-component-chip/src/BpkIconChip.d.ts +1 -1
  50. package/bpk-component-chip/src/BpkSelectableChip.d.ts +1 -1
  51. package/bpk-component-chip-group/src/BpkMultiSelectChipGroup.d.ts +1 -1
  52. package/bpk-component-chip-group/src/BpkSingleSelectChipGroup.d.ts +1 -2
  53. package/bpk-component-chip-group/src/Nudger.d.ts +1 -1
  54. package/bpk-component-close-button/src/BpkCloseButton.d.ts +10 -0
  55. package/bpk-component-close-button/src/BpkCloseButton.js +21 -37
  56. package/bpk-component-datatable/src/BpkDataTable.d.ts +1 -2
  57. package/bpk-component-datatable/src/BpkDataTableHeader.d.ts +1 -2
  58. package/bpk-component-datepicker/src/BpkDatepicker.d.ts +7 -9
  59. package/bpk-component-datepicker/src/BpkDatepicker.module.css +18 -0
  60. package/bpk-component-description-list/src/BpkDescriptionDetails.d.ts +1 -1
  61. package/bpk-component-description-list/src/BpkDescriptionList.d.ts +1 -1
  62. package/bpk-component-description-list/src/BpkDescriptionTerm.d.ts +1 -1
  63. package/bpk-component-dialog/src/BpkDialog.d.ts +1 -2
  64. package/bpk-component-dialog/src/BpkDialogInner.d.ts +11 -16
  65. package/bpk-component-flare/src/__generated__/js/corner-radius.d.ts +5 -0
  66. package/bpk-component-flare/src/__generated__/js/pointer.d.ts +5 -0
  67. package/bpk-component-floating-notification/src/BpkFloatingNotification.d.ts +1 -1
  68. package/bpk-component-graphic-promotion/src/BpkGraphicPromo.d.ts +1 -2
  69. package/bpk-component-icon/index.d.ts +2 -2
  70. package/bpk-component-icon/src/classNameModifierHOCFactory.d.ts +2 -2
  71. package/bpk-component-icon/src/withAlignment.d.ts +1 -1
  72. package/bpk-component-icon/src/withRtlSupport.d.ts +3 -4
  73. package/bpk-component-image/src/BpkBackgroundImage.d.ts +1 -1
  74. package/bpk-component-image/src/BpkImage.d.ts +1 -1
  75. package/bpk-component-image/src/withLazyLoading.d.ts +8 -11
  76. package/bpk-component-image/src/withLoadingBehavior.d.ts +5 -7
  77. package/bpk-component-info-banner/src/AnimateAndFade.d.ts +1 -1
  78. package/bpk-component-info-banner/src/BpkInfoBanner.d.ts +1 -2
  79. package/bpk-component-info-banner/src/BpkInfoBannerDismissable.d.ts +1 -2
  80. package/bpk-component-info-banner/src/BpkInfoBannerExpandable.d.ts +1 -1
  81. package/bpk-component-info-banner/src/BpkInfoBannerInner.d.ts +1 -1
  82. package/bpk-component-info-banner/src/withBannerAlertState.d.ts +36 -45
  83. package/bpk-component-input/src/BpkClearButton.module.css +18 -0
  84. package/bpk-component-input/src/BpkInput.d.ts +1 -1
  85. package/bpk-component-input/src/BpkInput.js +1 -1
  86. package/bpk-component-input/src/common-types.d.ts +1 -1
  87. package/bpk-component-input/src/withOpenEvents.d.ts +4 -6
  88. package/bpk-component-inset-banner/src/BpkInsetBanner.d.ts +1 -2
  89. package/bpk-component-journey-arrow/src/BpkJourneyArrow.d.ts +1 -2
  90. package/bpk-component-loading-button/src/BpkLoadingButton.d.ts +6 -38
  91. package/bpk-component-loading-button/src/BpkLoadingButton.js +13 -44
  92. package/bpk-component-map/src/BpkBasicMapMarker.d.ts +1 -1
  93. package/bpk-component-map/src/BpkPriceMarkerV2/BpkPriceMarker.d.ts +1 -1
  94. package/bpk-component-modal/src/BpkModal.d.ts +1 -1
  95. package/bpk-component-modal/src/BpkModalInner.d.ts +1 -1
  96. package/bpk-component-modal/src/BpkModalV2/BpkModal.d.ts +1 -1
  97. package/bpk-component-navigation-bar/src/BpkNavigationBar.d.ts +1 -1
  98. package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.d.ts +1 -1
  99. package/bpk-component-navigation-bar/src/BpkNavigationBarButtonLink.module.css +18 -0
  100. package/bpk-component-navigation-bar/src/BpkNavigationBarIconButton.d.ts +1 -1
  101. package/bpk-component-nudger/index.d.ts +1 -2
  102. package/bpk-component-nudger/index.js +1 -2
  103. package/bpk-component-nudger/src/BpkNudger.d.ts +1 -2
  104. package/bpk-component-nudger/src/BpkNudger.js +102 -20
  105. package/bpk-component-nudger/src/BpkNudger.module.css +1 -1
  106. package/bpk-component-nudger/src/common-types.d.ts +7 -5
  107. package/bpk-component-overlay/src/BpkOverlay.d.ts +1 -1
  108. package/bpk-component-popover/src/BpkPopover.d.ts +1 -1
  109. package/bpk-component-rating/src/BpkRating.d.ts +1 -1
  110. package/bpk-component-rtl-toggle/src/BpkRtlToggle.d.ts +1 -1
  111. package/bpk-component-rtl-toggle/src/updateOnDirectionChange.d.ts +11 -15
  112. package/bpk-component-scrollable-calendar/src/BpkScrollableCalendar.d.ts +6 -9
  113. package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarDate.d.ts +1 -2
  114. package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGrid.d.ts +3 -3
  115. package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.d.ts +3 -3
  116. package/bpk-component-section-header/src/BpkSectionHeader.d.ts +1 -1
  117. package/bpk-component-segmented-control/src/BpkSegmentedControl.d.ts +1 -1
  118. package/bpk-component-skeleton/src/BpkBaseSkeleton.d.d.ts +0 -1
  119. package/bpk-component-skeleton/src/BpkBaseSkeleton.d.ts +1 -2
  120. package/bpk-component-skeleton/src/BpkSkeleton.d.d.ts +0 -1
  121. package/bpk-component-skeleton/src/BpkSkeleton.d.ts +1 -2
  122. package/bpk-component-slider/src/BpkSlider.d.ts +4 -2
  123. package/bpk-component-slider/src/BpkSlider.js +51 -3
  124. package/bpk-component-snippet/index.d.ts +3 -0
  125. package/bpk-component-snippet/index.js +21 -0
  126. package/bpk-component-snippet/src/BpkSnippet.d.ts +48 -0
  127. package/bpk-component-snippet/src/BpkSnippet.js +131 -0
  128. package/bpk-component-snippet/src/BpkSnippet.module.css +18 -0
  129. package/bpk-component-spinner/src/BpkExtraLargeSpinner.d.ts +4 -15
  130. package/bpk-component-spinner/src/BpkExtraLargeSpinner.js +5 -16
  131. package/bpk-component-spinner/src/BpkLargeSpinner.d.ts +5 -18
  132. package/bpk-component-spinner/src/BpkLargeSpinner.js +6 -19
  133. package/bpk-component-spinner/src/BpkSpinner.d.ts +5 -18
  134. package/bpk-component-spinner/src/BpkSpinner.js +6 -19
  135. package/bpk-component-split-input/src/BpkInputField.d.ts +21 -0
  136. package/bpk-component-split-input/src/BpkInputField.js +13 -15
  137. package/bpk-component-split-input/src/BpkSplitInput.d.ts +44 -0
  138. package/bpk-component-split-input/src/BpkSplitInput.js +23 -34
  139. package/bpk-component-swap-button/src/BpkSwapButton.d.ts +1 -2
  140. package/bpk-component-text/src/BpkText.d.ts +1 -1
  141. package/bpk-component-tooltip/src/BpkTooltip.d.ts +1 -1
  142. package/bpk-component-tooltip/src/BpkTooltipPortal.d.ts +1 -1
  143. package/bpk-react-utils/index.d.ts +9 -10
  144. package/bpk-react-utils/src/BpkDialogWrapper/BpkDialogWrapper.d.ts +1 -1
  145. package/bpk-react-utils/src/TransitionInitialMount.d.ts +1 -1
  146. package/bpk-react-utils/src/nativeEventHandler.d.ts +1 -1
  147. package/bpk-react-utils/src/nativeEventHandler.js +7 -5
  148. package/bpk-react-utils/src/withDefaultProps.d.ts +1 -1
  149. package/bpk-scrim-utils/index.d.ts +12 -17
  150. package/bpk-scrim-utils/src/BpkScrim.d.ts +1 -1
  151. package/bpk-scrim-utils/src/withScrim.d.ts +11 -15
  152. package/bpk-scrim-utils/src/withScrimmedPortal.d.ts +1 -1
  153. package/bpk-stylesheets/test.css +164 -0
  154. package/bpk-theming/src/BpkThemeProvider.js +19 -30
  155. package/package.json +5 -3
  156. package/bpk-component-nudger/src/BpkConfigurableNudger.d.ts +0 -27
  157. package/bpk-component-nudger/src/BpkConfigurableNudger.js +0 -96
@@ -16,30 +16,63 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
+ import { useRef } from 'react';
20
+ import { BpkButtonV2, BUTTON_TYPES } from "../../bpk-component-button";
21
+ import { withButtonAlignment } from "../../bpk-component-icon";
22
+ import MinusIcon from "../../bpk-component-icon/sm/minus";
23
+ import PlusIcon from "../../bpk-component-icon/sm/plus";
19
24
  // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
20
25
  import BpkLabel from "../../bpk-component-label";
21
26
  import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
22
- import { cssModules } from "../../bpk-react-utils";
23
- import BpkConfigurableNudger from "./BpkConfigurableNudger";
27
+ import { cssModules, setNativeValue } from "../../bpk-react-utils";
24
28
  import STYLES from "./BpkNudger.module.css";
25
29
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
26
30
  const getClassName = cssModules(STYLES);
27
31
  const compareValues = (a, b) => a - b;
28
- const incrementValue = currentValue => currentValue + 1;
29
- const decrementValue = currentValue => currentValue - 1;
30
- const formatValue = currentValue => currentValue.toString();
31
32
  const BpkNudger = ({
32
33
  buttonType = 'secondary',
33
34
  className = null,
35
+ decreaseButtonLabel,
34
36
  icon,
35
37
  id,
38
+ increaseButtonLabel,
39
+ inputClassName,
40
+ max,
41
+ min,
42
+ name,
43
+ onValueChange,
44
+ step = 1,
36
45
  subtitle,
37
46
  title,
47
+ value,
38
48
  ...rest
39
49
  }) => {
40
- const classNames = getClassName(title && 'bpk-nudger__container');
50
+ // Ensure that the minimum value is 0 or greater it's not designed to handle negative values.
51
+ const minimum = min < 0 ? 0 : min;
52
+ const containerClassNames = getClassName(title && 'bpk-nudger__container');
53
+ const inputClassNames = getClassName('bpk-nudger__input', 'bpk-nudger__input--numeric', inputClassName && inputClassName, buttonType === 'secondaryOnDark' && 'bpk-nudger__input--secondary-on-dark');
54
+ const nudgerClassNames = getClassName('bpk-nudger', className);
55
+ const maxButtonDisabled = compareValues(value, max) >= 0;
56
+ const minButtonDisabled = compareValues(value, minimum) <= 0;
57
+ const AlignedMinusIcon = withButtonAlignment(MinusIcon);
58
+ const AlignedPlusIcon = withButtonAlignment(PlusIcon);
59
+ const inputRef = useRef(null);
60
+ const incrementValue = currentValue => currentValue + step;
61
+ const decrementValue = currentValue => currentValue - step;
62
+ const valueLimitter = element => {
63
+ if (element.valueAsNumber < minimum) {
64
+ onValueChange(minimum);
65
+ setNativeValue(element, minimum, false);
66
+ } else if (element.valueAsNumber > max) {
67
+ onValueChange(max);
68
+ setNativeValue(element, max, false);
69
+ }
70
+ if (element.valueAsNumber >= minimum && element.valueAsNumber <= max) {
71
+ onValueChange(element.valueAsNumber);
72
+ }
73
+ };
41
74
  return /*#__PURE__*/_jsxs("div", {
42
- className: classNames,
75
+ className: containerClassNames,
43
76
  children: [title && /*#__PURE__*/_jsxs("div", {
44
77
  className: getClassName('bpk-nudger__label'),
45
78
  children: [/*#__PURE__*/_jsx(BpkLabel, {
@@ -60,19 +93,68 @@ const BpkNudger = ({
60
93
  })
61
94
  })]
62
95
  })]
63
- }), /*#__PURE__*/_jsx(BpkConfigurableNudger, {
64
- inputClassName: getClassName('bpk-nudger__input--numeric'),
65
- compareValues: compareValues,
66
- incrementValue: incrementValue,
67
- decrementValue: decrementValue,
68
- formatValue: formatValue
69
- // TODO: className to be removed
70
- // eslint-disable-next-line @skyscanner/rules/forbid-component-props
71
- ,
72
- className: className,
73
- buttonType: buttonType,
74
- id: id,
75
- ...rest
96
+ }), /*#__PURE__*/_jsxs("div", {
97
+ className: nudgerClassNames,
98
+ children: [/*#__PURE__*/_jsx(BpkButtonV2, {
99
+ type: BUTTON_TYPES[buttonType],
100
+ iconOnly: true,
101
+ onClick: () => {
102
+ if (Number.isNaN(value)) {
103
+ onValueChange(minimum);
104
+ inputRef.current && setNativeValue(inputRef.current, minimum);
105
+ return;
106
+ }
107
+ const newValue = decrementValue(value);
108
+ onValueChange(newValue);
109
+ // We want to maintain native input events across our form components. Along with react updating
110
+ // the value attribute we can set it via native handlers and emit a "change" event.
111
+ inputRef.current && setNativeValue(inputRef.current, newValue);
112
+ },
113
+ disabled: minButtonDisabled,
114
+ title: decreaseButtonLabel,
115
+ "aria-controls": id,
116
+ children: /*#__PURE__*/_jsx(AlignedMinusIcon, {})
117
+ }), /*#__PURE__*/_jsx("input", {
118
+ type: "number",
119
+ "aria-live": "polite",
120
+ defaultValue: value,
121
+ id: id,
122
+ ref: inputRef,
123
+ name: name || id,
124
+ step: step,
125
+ onInput: event => {
126
+ const inputElement = event.target;
127
+ if (!inputElement.validity.valid &&
128
+ // allow the removal of a value
129
+ Number.isNaN(inputElement.valueAsNumber)) {
130
+ // set prev value if entry invalid
131
+ onValueChange(value);
132
+ setNativeValue(inputElement, value, false);
133
+ }
134
+ valueLimitter(inputElement);
135
+ },
136
+ className: inputClassNames,
137
+ ...rest
138
+ }), /*#__PURE__*/_jsx(BpkButtonV2, {
139
+ type: BUTTON_TYPES[buttonType],
140
+ iconOnly: true,
141
+ onClick: () => {
142
+ if (Number.isNaN(value)) {
143
+ onValueChange(max);
144
+ inputRef.current && setNativeValue(inputRef.current, max);
145
+ return;
146
+ }
147
+ const newValue = incrementValue(value);
148
+ onValueChange(newValue);
149
+ // We want to maintain native input events across our form components. Along with react updating
150
+ // the value attribute we can set it via native handlers and emit a "change" event.
151
+ inputRef.current && setNativeValue(inputRef.current, newValue);
152
+ },
153
+ disabled: maxButtonDisabled,
154
+ title: increaseButtonLabel,
155
+ "aria-controls": id,
156
+ children: /*#__PURE__*/_jsx(AlignedPlusIcon, {})
157
+ })]
76
158
  })]
77
159
  });
78
160
  };
@@ -15,4 +15,4 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- html[dir=rtl] .bpk-nudger{display:flex;flex-direction:row-reverse}.bpk-nudger__input{display:inline-block;padding:.5rem 0;border:none;color:#161616;text-align:center;vertical-align:middle;margin:0;font-size:1rem;line-height:1.25rem;font-weight:700}.bpk-nudger__input--secondary-on-dark{background-color:rgba(0,0,0,0);color:#fff}.bpk-nudger__input--numeric{width:2.5rem}.bpk-nudger__container{display:flex;justify-content:space-between;align-items:center}.bpk-nudger__label{display:flex;gap:.5rem}.bpk-nudger__label--title-subtitle{display:inline-flex;flex-direction:column;justify-content:space-between}.bpk-nudger__label--subtitle{color:#626971}
18
+ html[dir=rtl] .bpk-nudger{display:flex}.bpk-nudger__input{display:inline-block;padding:.5rem 0;border:none;color:#161616;text-align:center;vertical-align:middle;margin:0;font-size:1rem;line-height:1.25rem;font-weight:700}.bpk-nudger__input::-webkit-outer-spin-button,.bpk-nudger__input::-webkit-inner-spin-button{margin:0;appearance:none}.bpk-nudger__input[type=number]{appearance:textfield}.bpk-nudger__input--secondary-on-dark{background-color:rgba(0,0,0,0);color:#fff}.bpk-nudger__input--numeric{width:2.5rem}.bpk-nudger__container{display:flex;justify-content:space-between;align-items:center}.bpk-nudger__label{display:flex;gap:.5rem}.bpk-nudger__label--title-subtitle{display:inline-flex;flex-direction:column;justify-content:space-between}.bpk-nudger__label--subtitle{color:#626971}
@@ -5,11 +5,12 @@ export declare const BUTTON_TYPES: {
5
5
  };
6
6
  export type CommonProps = {
7
7
  id: string;
8
- min: string | number;
9
- max: string | number;
10
- value: string | number;
11
- onChange: (arg0: any) => void | null;
12
- name?: string | null;
8
+ min: number;
9
+ max: number;
10
+ value: number;
11
+ onValueChange: (arg0: number) => void;
12
+ name?: string | undefined;
13
+ step?: number;
13
14
  className?: string | null;
14
15
  /**
15
16
  * This is the label that will be read out when screen reader users tab to the increase button. Make sure you use a descriptive label.
@@ -18,6 +19,7 @@ export type CommonProps = {
18
19
  * Function that handle the incrementing of the current selected value.
19
20
  */
20
21
  increaseButtonLabel: string;
22
+ inputClassName?: string | undefined;
21
23
  /**
22
24
  * This is the label that will be read out when screen reader users tab to the decrease button. Make sure you use a descriptive label
23
25
  */
@@ -30,5 +30,5 @@ export type Props = BpkOverlayProps & ComponentProps<'div'> & {
30
30
  overlayType?: OverlayType;
31
31
  foregroundContent?: ReactNode;
32
32
  };
33
- declare const BpkOverlay: (props: Props) => JSX.Element;
33
+ declare const BpkOverlay: (props: Props) => import("react/jsx-runtime").JSX.Element;
34
34
  export default BpkOverlay;
@@ -33,5 +33,5 @@ export type Props = CloseButtonProps & {
33
33
  onAction?: () => void;
34
34
  renderTarget?: () => HTMLElement | HTMLElement | null;
35
35
  };
36
- declare const BpkPopover: ({ actionText, children, className, closeButtonIcon, closeButtonLabel, closeButtonProps, closeButtonText, id, isOpen, label, labelAsTitle, onAction, onClose, padded, placement, renderTarget, showArrow, target, ...rest }: Props) => JSX.Element;
36
+ declare const BpkPopover: ({ actionText, children, className, closeButtonIcon, closeButtonLabel, closeButtonProps, closeButtonText, id, isOpen, label, labelAsTitle, onAction, onClose, padded, placement, renderTarget, showArrow, target, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
37
37
  export default BpkPopover;
@@ -13,7 +13,7 @@ type Props = {
13
13
  value: string | number;
14
14
  };
15
15
  declare const BpkRating: {
16
- (props: Props): JSX.Element;
16
+ (props: Props): import("react/jsx-runtime").JSX.Element;
17
17
  propTypes: {
18
18
  ariaLabel: PropTypes.Validator<string>;
19
19
  value: PropTypes.Validator<NonNullable<NonNullable<string | number | null | undefined>>>;
@@ -10,6 +10,6 @@ declare class BpkRtlToggle extends Component<Props, State> {
10
10
  componentWillUnmount(): void;
11
11
  handleKeyDown: (e: KeyboardEvent) => void;
12
12
  toggleRtl: (e: InteractionEvents) => void;
13
- render(): JSX.Element;
13
+ render(): import("react/jsx-runtime").JSX.Element;
14
14
  }
15
15
  export default BpkRtlToggle;
@@ -1,23 +1,21 @@
1
1
  import type { ComponentType } from 'react';
2
2
  declare const updateOnDirectionChange: (EnhancedComponent: ComponentType<any> | string) => {
3
- new (props: {} | Readonly<{}>): {
3
+ new (props: {}): {
4
4
  componentDidMount(): void;
5
5
  componentWillUnmount(): void;
6
6
  onDirectionChange: () => void;
7
- render(): JSX.Element;
8
- context: any;
9
- setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
7
+ render(): import("react/jsx-runtime").JSX.Element;
8
+ context: unknown;
9
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => Pick<{}, K> | {} | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
10
10
  forceUpdate(callback?: (() => void) | undefined): void;
11
- readonly props: Readonly<{}> & Readonly<{
12
- children?: import("react").ReactNode;
13
- }>;
11
+ readonly props: Readonly<{}>;
14
12
  state: Readonly<{}>;
15
13
  refs: {
16
14
  [key: string]: import("react").ReactInstance;
17
15
  };
18
16
  shouldComponentUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): boolean;
19
17
  componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
20
- getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
18
+ getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any | null;
21
19
  componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
22
20
  componentWillMount?(): void;
23
21
  UNSAFE_componentWillMount?(): void;
@@ -30,20 +28,18 @@ declare const updateOnDirectionChange: (EnhancedComponent: ComponentType<any> |
30
28
  componentDidMount(): void;
31
29
  componentWillUnmount(): void;
32
30
  onDirectionChange: () => void;
33
- render(): JSX.Element;
34
- context: any;
35
- setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
31
+ render(): import("react/jsx-runtime").JSX.Element;
32
+ context: unknown;
33
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => Pick<{}, K> | {} | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
36
34
  forceUpdate(callback?: (() => void) | undefined): void;
37
- readonly props: Readonly<{}> & Readonly<{
38
- children?: import("react").ReactNode;
39
- }>;
35
+ readonly props: Readonly<{}>;
40
36
  state: Readonly<{}>;
41
37
  refs: {
42
38
  [key: string]: import("react").ReactInstance;
43
39
  };
44
40
  shouldComponentUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): boolean;
45
41
  componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
46
- getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
42
+ getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any | null;
47
43
  componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
48
44
  componentWillMount?(): void;
49
45
  UNSAFE_componentWillMount?(): void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare const _default: {
3
2
  new (props: Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
4
3
  onDateClick: ((date: Date) => void) | null;
@@ -28,8 +27,8 @@ declare const _default: {
28
27
  source: string;
29
28
  }) => void;
30
29
  handleDateKeyDown: (event: KeyboardEvent) => void;
31
- render(): JSX.Element;
32
- context: any;
30
+ render(): import("react/jsx-runtime").JSX.Element;
31
+ context: unknown;
33
32
  setState<K extends keyof {
34
33
  preventKeyboardFocus: boolean;
35
34
  focusedDate: Date;
@@ -47,13 +46,13 @@ declare const _default: {
47
46
  maxDate: Date;
48
47
  }> & {
49
48
  [rest: string]: any;
50
- }>) => {
49
+ }>) => Pick<{
51
50
  preventKeyboardFocus: boolean;
52
51
  focusedDate: Date;
53
- } | Pick<{
52
+ }, K> | {
54
53
  preventKeyboardFocus: boolean;
55
54
  focusedDate: Date;
56
- }, K> | null) | Pick<{
55
+ } | null) | Pick<{
57
56
  preventKeyboardFocus: boolean;
58
57
  focusedDate: Date;
59
58
  }, K> | null, callback?: (() => void) | undefined): void;
@@ -66,8 +65,6 @@ declare const _default: {
66
65
  maxDate: Date;
67
66
  }> & {
68
67
  [rest: string]: any;
69
- }> & Readonly<{
70
- children?: import("react").ReactNode;
71
68
  }>;
72
69
  state: Readonly<{
73
70
  preventKeyboardFocus: boolean;
@@ -102,7 +99,7 @@ declare const _default: {
102
99
  }>, prevState: Readonly<{
103
100
  preventKeyboardFocus: boolean;
104
101
  focusedDate: Date;
105
- }>): any;
102
+ }>): any | null;
106
103
  componentDidUpdate?(prevProps: Readonly<Omit<import("../../bpk-component-calendar/src/composeCalendar").Props & import("../../bpk-component-calendar/src/BpkCalendarContainer").Props, keyof {
107
104
  onDateClick: ((date: Date) => void) | null;
108
105
  onDateKeyDown: ((event: KeyboardEvent) => void) | null;
@@ -1,9 +1,8 @@
1
- /// <reference types="react" />
2
1
  import type { BpkCalendarDateProps } from '../../bpk-component-calendar';
3
2
  type Props = Partial<BpkCalendarDateProps> & {
4
3
  date: Date;
5
4
  isOutside?: boolean;
6
5
  [rest: string]: any;
7
6
  };
8
- declare const BpkScrollableCalendarDate: ({ isOutside, ...rest }: Props) => JSX.Element | null;
7
+ declare const BpkScrollableCalendarDate: ({ isOutside, ...rest }: Props) => import("react/jsx-runtime").JSX.Element | null;
9
8
  export default BpkScrollableCalendarDate;
@@ -1,11 +1,11 @@
1
- import type { ElementType } from 'react';
1
+ import type { ElementType, ReactNode } from 'react';
2
2
  import type { BpkCalendarGridProps } from '../../bpk-component-calendar';
3
3
  type Props = Partial<BpkCalendarGridProps> & {
4
4
  DateComponent: ElementType;
5
5
  month: Date;
6
6
  formatDateFull: (date: Date) => Date | string;
7
7
  weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
8
- formatMonth: (date: Date) => Date | string;
8
+ formatMonth: (date: Date) => ReactNode | string;
9
9
  };
10
- declare const BpkScrollableCalendarGrid: ({ className, formatMonth, ignoreOutsideDate, month, ...rest }: Props) => JSX.Element;
10
+ declare const BpkScrollableCalendarGrid: ({ className, formatMonth, ignoreOutsideDate, month, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
11
11
  export default BpkScrollableCalendarGrid;
@@ -1,4 +1,4 @@
1
- import type { ElementType } from 'react';
1
+ import type { ElementType, ReactNode } from 'react';
2
2
  import type { BpkCalendarGridProps, SelectionConfiguration } from '../../bpk-component-calendar';
3
3
  type Props = Partial<BpkCalendarGridProps> & {
4
4
  minDate: Date;
@@ -7,7 +7,7 @@ type Props = Partial<BpkCalendarGridProps> & {
7
7
  formatDateFull: (date: Date) => Date | string;
8
8
  month: Date;
9
9
  weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
10
- formatMonth: (date: Date) => Date | string;
10
+ formatMonth: (date: Date) => ReactNode | string;
11
11
  focusedDate?: Date | null;
12
12
  selectionConfiguration?: SelectionConfiguration;
13
13
  className?: string | null;
@@ -16,5 +16,5 @@ type Props = Partial<BpkCalendarGridProps> & {
16
16
  */
17
17
  customRowHeight?: number;
18
18
  };
19
- declare const BpkScrollableCalendarGridList: (props: Props) => JSX.Element;
19
+ declare const BpkScrollableCalendarGridList: (props: Props) => import("react/jsx-runtime").JSX.Element;
20
20
  export default BpkScrollableCalendarGridList;
@@ -10,5 +10,5 @@ type Props = {
10
10
  button?: ReactNode;
11
11
  type?: SectionType;
12
12
  };
13
- declare const BpkSectionHeader: ({ button, description, title, type, }: Props) => JSX.Element;
13
+ declare const BpkSectionHeader: ({ button, description, title, type, }: Props) => import("react/jsx-runtime").JSX.Element;
14
14
  export default BpkSectionHeader;
@@ -13,5 +13,5 @@ export type Props = {
13
13
  selectedIndex: number;
14
14
  shadow?: boolean;
15
15
  };
16
- declare const BpkSegmentedControl: ({ buttonContents, onItemClick, selectedIndex, shadow, type, }: Props) => JSX.Element;
16
+ declare const BpkSegmentedControl: ({ buttonContents, onItemClick, selectedIndex, shadow, type, }: Props) => import("react/jsx-runtime").JSX.Element;
17
17
  export default BpkSegmentedControl;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  type Props = {
3
2
  skeletonStyle: string;
4
3
  styleObj?: {
@@ -1,8 +1,7 @@
1
- /// <reference types="react" />
2
1
  import type { CUSTOM_SIZE_TYPE } from './common-types';
3
2
  type Props = {
4
3
  skeletonStyle: string;
5
4
  styleObj?: CUSTOM_SIZE_TYPE;
6
5
  };
7
- declare const BpkBaseSkeleton: ({ skeletonStyle, styleObj, }: Props) => JSX.Element;
6
+ declare const BpkBaseSkeleton: ({ skeletonStyle, styleObj, }: Props) => import("react/jsx-runtime").JSX.Element;
8
7
  export default BpkBaseSkeleton;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ComponentProps } from './common-types';
3
2
  declare const BpkSkeleton: (props: ComponentProps) => JSX.Element;
4
3
  export default BpkSkeleton;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { ComponentProps } from './common-types';
3
- declare const BpkSkeleton: (props: ComponentProps) => JSX.Element;
2
+ declare const BpkSkeleton: (props: ComponentProps) => import("react/jsx-runtime").JSX.Element;
4
3
  export default BpkSkeleton;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export type Props = {
3
2
  max: number;
4
3
  min: number;
@@ -9,7 +8,10 @@ export type Props = {
9
8
  value: number[] | number;
10
9
  ariaLabel: string[];
11
10
  ariaValuetext?: string[];
11
+ inputProps?: [{
12
+ [key: string]: any;
13
+ }];
12
14
  [rest: string]: any;
13
15
  };
14
- declare const BpkSlider: ({ ariaLabel, ariaValuetext, max, min, minDistance, onAfterChange, onChange, step, value, ...rest }: Props) => JSX.Element;
16
+ declare const BpkSlider: ({ ariaLabel, ariaValuetext, inputProps, max, min, minDistance, onAfterChange, onChange, step, value, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
15
17
  export default BpkSlider;
@@ -15,15 +15,18 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
-
18
+ import { forwardRef, useRef, useEffect } from 'react';
19
+ import { useComposedRefs } from '@radix-ui/react-compose-refs';
19
20
  import * as Slider from '@radix-ui/react-slider';
20
- import { cssModules, isRTL } from "../../bpk-react-utils";
21
+ import { usePrevious } from '@radix-ui/react-use-previous';
22
+ import { cssModules, isRTL, setNativeValue } from "../../bpk-react-utils";
21
23
  import STYLES from "./BpkSlider.module.css";
22
24
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
25
  const getClassName = cssModules(STYLES);
24
26
  const BpkSlider = ({
25
27
  ariaLabel,
26
28
  ariaValuetext,
29
+ inputProps,
27
30
  max,
28
31
  min,
29
32
  minDistance,
@@ -67,8 +70,53 @@ const BpkSlider = ({
67
70
  "aria-label": ariaLabel[index],
68
71
  "aria-valuetext": ariaValuetext ? ariaValuetext[index] : val.toString(),
69
72
  className: getClassName('bpk-slider__thumb'),
70
- "aria-valuenow": currentValue[index]
73
+ "aria-valuenow": currentValue[index],
74
+ asChild: true,
75
+ children: /*#__PURE__*/_jsx("span", {
76
+ children: /*#__PURE__*/_jsx(BubbleInput, {
77
+ value: currentValue[index],
78
+ ...(inputProps && inputProps[index])
79
+ })
80
+ })
71
81
  }, ariaLabel[index]))]
72
82
  });
73
83
  };
84
+
85
+ // Work around until radix-ui/react-slider is updated to accept an inputRef prop https://github.com/radix-ui/primitives/pull/3033
86
+ const BubbleInput = /*#__PURE__*/forwardRef((props, forwardedRef) => {
87
+ const {
88
+ value,
89
+ ...inputProps
90
+ } = props;
91
+ const ref = useRef();
92
+ const composedRefs = useComposedRefs(forwardedRef, ref);
93
+ const prevValue = usePrevious(value);
94
+
95
+ // Bubble value change to parents (e.g form change event)
96
+ useEffect(() => {
97
+ const input = ref.current;
98
+ if (prevValue !== value) {
99
+ setNativeValue(input, `${value}`);
100
+ }
101
+ }, [prevValue, value]);
102
+
103
+ /**
104
+ * We purposefully do not use `type="hidden"` here otherwise forms that
105
+ * wrap it will not be able to access its value via the FormData API.
106
+ *
107
+ * We purposefully do not add the `value` attribute here to allow the value
108
+ * to be set programatically and bubble to any parent form `onChange` event.
109
+ * Adding the `value` will cause React to consider the programatic
110
+ * dispatch a duplicate and it will get swallowed.
111
+ */
112
+ return /*#__PURE__*/_jsx("input", {
113
+ style: {
114
+ display: 'none'
115
+ },
116
+ ...inputProps,
117
+ ref: composedRefs,
118
+ type: "number",
119
+ defaultValue: value
120
+ });
121
+ });
74
122
  export default BpkSlider;
@@ -0,0 +1,3 @@
1
+ import BpkSnippet, { BODY_STYLE, BUTTON_STYLE, DESKTOP_LAYOUT, HEADLINE_STYLE, IMAGE_ORIENTATION } from './src/BpkSnippet';
2
+ export default BpkSnippet;
3
+ export { BODY_STYLE, BUTTON_STYLE, DESKTOP_LAYOUT, HEADLINE_STYLE, IMAGE_ORIENTATION, };
@@ -0,0 +1,21 @@
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 BpkSnippet, { BODY_STYLE, BUTTON_STYLE, DESKTOP_LAYOUT, HEADLINE_STYLE, IMAGE_ORIENTATION } from "./src/BpkSnippet";
20
+ export default BpkSnippet;
21
+ export { BODY_STYLE, BUTTON_STYLE, DESKTOP_LAYOUT, HEADLINE_STYLE, IMAGE_ORIENTATION };
@@ -0,0 +1,48 @@
1
+ import type { MouseEvent } from 'react';
2
+ export declare const BODY_STYLE: {
3
+ readonly bodyDefault: "body-default";
4
+ readonly bodyLongform: "body-longform";
5
+ };
6
+ export declare const BUTTON_STYLE: {
7
+ readonly primary: "primary";
8
+ readonly featured: "featured";
9
+ };
10
+ export declare const HEADLINE_STYLE: {
11
+ readonly heading1: "heading-1";
12
+ readonly heading2: "heading-2";
13
+ readonly heading3: "heading-3";
14
+ readonly heading4: "heading-4";
15
+ readonly heading5: "heading-5";
16
+ readonly hero1: "hero-1";
17
+ readonly hero2: "hero-2";
18
+ readonly hero3: "hero-3";
19
+ readonly hero4: "hero-4";
20
+ readonly hero5: "hero-5";
21
+ };
22
+ export declare const DESKTOP_LAYOUT: {
23
+ readonly imageLeft: "imageLeft";
24
+ readonly imageRight: "imageRight";
25
+ readonly vertical: "vertical";
26
+ };
27
+ export declare const IMAGE_ORIENTATION: {
28
+ readonly landscape: "landscape";
29
+ readonly portrait: "portrait";
30
+ readonly square: "square";
31
+ };
32
+ export type Props = {
33
+ src: string;
34
+ altText: string;
35
+ headline?: string | null;
36
+ subheading?: string | null;
37
+ bodyText?: string | null;
38
+ buttonText?: string | null;
39
+ bodyStyle?: (typeof BODY_STYLE)[keyof typeof BODY_STYLE];
40
+ buttonStyle?: (typeof BUTTON_STYLE)[keyof typeof BUTTON_STYLE];
41
+ headlineStyle?: (typeof HEADLINE_STYLE)[keyof typeof HEADLINE_STYLE];
42
+ desktopLayout?: (typeof DESKTOP_LAYOUT)[keyof typeof DESKTOP_LAYOUT];
43
+ imageOrientation?: (typeof IMAGE_ORIENTATION)[keyof typeof IMAGE_ORIENTATION];
44
+ imageRadius?: boolean;
45
+ onClick?: (event: MouseEvent<HTMLButtonElement & HTMLAnchorElement>) => void;
46
+ };
47
+ declare const BpkSnippet: ({ altText, bodyStyle, bodyText, buttonStyle, buttonText, desktopLayout, headline, headlineStyle, imageOrientation, imageRadius, onClick, src, subheading, }: Props) => import("react/jsx-runtime").JSX.Element;
48
+ export default BpkSnippet;