@shopgate/engage 7.32.0-beta.7 → 7.32.0-beta.9

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 (188) hide show
  1. package/account/components/Profile/Profile.provider.d.ts +1 -1
  2. package/account/components/Profile/ProfileAddressBook.d.ts.map +1 -1
  3. package/account/components/Profile/ProfileAddressBook.js +13 -22
  4. package/account/components/Profile/ProfileAddressCard.d.ts.map +1 -1
  5. package/account/components/Profile/ProfileAddressCard.js +8 -18
  6. package/account/components/Profile/ProfileForm.d.ts.map +1 -1
  7. package/account/components/Profile/ProfileForm.js +15 -42
  8. package/account/components/ProfileContact/ProfileContact.js +13 -21
  9. package/admin-preview/components/FrontendSettingsPreviewBridge/FrontendSettingsPreviewBridge.d.ts.map +1 -1
  10. package/admin-preview/components/FrontendSettingsPreviewBridge/FrontendSettingsPreviewBridge.js +41 -7
  11. package/admin-preview/components/FrontendSettingsPreviewBridge/types.d.ts +7 -0
  12. package/admin-preview/components/FrontendSettingsPreviewBridge/types.d.ts.map +1 -1
  13. package/admin-preview/initialization/_internal/initialFrontendSettings.d.ts +32 -0
  14. package/admin-preview/initialization/_internal/initialFrontendSettings.d.ts.map +1 -0
  15. package/admin-preview/initialization/_internal/initialFrontendSettings.js +43 -0
  16. package/admin-preview/initialization/awaitInitialFrontendSettings.d.ts +22 -0
  17. package/admin-preview/initialization/awaitInitialFrontendSettings.d.ts.map +1 -0
  18. package/admin-preview/initialization/awaitInitialFrontendSettings.js +84 -0
  19. package/back-in-stock/components/BackInStockButton/index.js +5 -5
  20. package/cart/components/CartItem/CartItemProductLayout.js +1 -0
  21. package/cart/components/CartItem/CartItemProductLayoutWideRemoveItem.js +7 -14
  22. package/cart/components/CartItem/CartItemQuantityPicker.js +1 -0
  23. package/cart/components/CartItems/CartItemCardReservationLabelChangeStore.js +6 -24
  24. package/cart/components/CartSummaryWide/CartSummaryWide.js +2 -2
  25. package/cart/components/CartSummaryWide/CartSummaryWideCheckoutButton.js +9 -23
  26. package/cart/components/PaymentBar/PaymentBarCheckoutButton.js +8 -30
  27. package/cart/components/PaymentBar/testUtils/mockFactories.js +4 -11
  28. package/category/components/CategoryImage/index.js +13 -2
  29. package/checkout/components/AddressBook/AddressList.js +14 -23
  30. package/checkout/components/Checkout/CheckoutActions.js +4 -3
  31. package/checkout/components/Checkout/CheckoutAddress.js +8 -0
  32. package/checkout/components/Checkout/CheckoutSection.js +6 -2
  33. package/checkout/components/CheckoutConfirmation/CheckoutConfirmation.js +6 -7
  34. package/checkout/components/ResponsiveBackButton/ResponsiveBackButton.js +7 -17
  35. package/components/Badge/spec.js +6 -29
  36. package/components/Card/Card.js +1 -1
  37. package/components/ChipLayout/index.js +2 -4
  38. package/components/NavigationHandler/connector.js +1 -1
  39. package/components/NavigationHandler/index.d.ts +2 -2
  40. package/components/NavigationHandler/spec.js +10 -1
  41. package/components/Paper/Paper.d.ts +1 -2
  42. package/components/Paper/Paper.d.ts.map +1 -1
  43. package/components/Paper/spec.js +5 -22
  44. package/components/Tabs/components/Tab.d.ts.map +1 -1
  45. package/components/Tabs/components/Tab.js +14 -16
  46. package/components/Typography/Typography.d.ts +1 -1
  47. package/components/v2/Button/Button.d.ts +24 -13
  48. package/components/v2/Button/Button.d.ts.map +1 -1
  49. package/components/v2/Button/Button.js +139 -41
  50. package/components/v2/ButtonBase/ButtonBase.d.ts +50 -10
  51. package/components/v2/ButtonBase/ButtonBase.d.ts.map +1 -1
  52. package/components/v2/ButtonBase/ButtonBase.js +192 -17
  53. package/components/v2/ButtonBase/hooks.d.ts +0 -1
  54. package/components/v2/ButtonBase/hooks.d.ts.map +1 -1
  55. package/components/v2/ButtonBase/hooks.js +36 -12
  56. package/components/v2/ButtonGroup/ButtonGroup.d.ts +11 -5
  57. package/components/v2/ButtonGroup/ButtonGroup.d.ts.map +1 -1
  58. package/components/v2/ButtonGroup/ButtonGroup.js +49 -26
  59. package/components/v2/CircularProgress/CircularProgress.d.ts.map +1 -1
  60. package/components/v2/CircularProgress/CircularProgress.js +10 -5
  61. package/core/hooks/useNavigation.d.ts +10 -2
  62. package/core/hooks/useNavigation.d.ts.map +1 -1
  63. package/core/hooks/useNavigation.js +1 -2
  64. package/core/initialization/index.d.ts.map +1 -1
  65. package/core/initialization/index.js +24 -5
  66. package/core/router/conductor.d.ts +9 -0
  67. package/core/router/helpers.d.ts +28 -15
  68. package/core/router/helpers.d.ts.map +1 -1
  69. package/core/router/helpers.js +8 -8
  70. package/development/components/DevelopmentSettings/DevelopmentSettings.js +3 -3
  71. package/favorites/components/FavoriteButtonWide/FavoriteButtonWide.js +7 -17
  72. package/favorites/components/List/List.d.ts.map +1 -1
  73. package/favorites/components/List/List.js +0 -1
  74. package/favorites/components/List/ListContent.js +4 -5
  75. package/favorites/components/Lists/Lists.js +4 -5
  76. package/filter/components/FilterPageContent/components/ApplyButton/index.js +8 -10
  77. package/filter/components/FilterPageContent/components/ResetButton/index.js +8 -6
  78. package/locations/components/ChangeLocationButton/ChangeLocationButton.js +10 -14
  79. package/locations/components/FulfillmentSlotSwitcher/FulfillmentSlotDialog.js +4 -8
  80. package/locations/components/FulfillmentSlotSwitcher/FulfillmentSlotSwitcher.js +1 -1
  81. package/locations/components/FulfillmentSlotSwitcher/FulfillmentSlotSwitcherBar.js +8 -13
  82. package/locations/components/FulfillmentSlotSwitcher/FulfillmentSlotSwitcherDefault.js +10 -10
  83. package/locations/components/GlobalLocationSwitcher/GlobalLocationSwitcherBar.js +8 -14
  84. package/locations/components/GlobalLocationSwitcher/GlobalLocationSwitcherDefault.js +9 -10
  85. package/locations/components/ReserveForm/ReserveForm.js +6 -7
  86. package/locations/components/StoreDetails/components/GetDirectionsButton.js +2 -4
  87. package/locations/components/StoreDetails/components/StoreDetails.js +5 -10
  88. package/locations/components/StoreDetails/components/StoresNearbyListItem.js +13 -21
  89. package/locations/components/StoreFinder/StoreFinderSelectLocationButton.js +5 -11
  90. package/locations/components/StoreFinder/StoreFinderStoreInfoButton.js +5 -11
  91. package/locations/components/StoreList/StoreListSearch.js +1 -0
  92. package/locations/components/StoreList/StoreSelectLocationButton.js +5 -11
  93. package/login/components/ForgotPassword/ForgotPassword.js +11 -23
  94. package/orders/components/OrderDetails/OrderDetailsAuthenticate.js +5 -7
  95. package/package.json +7 -7
  96. package/page/components/NotFound.d.ts.map +1 -1
  97. package/page/components/NotFound.js +7 -6
  98. package/page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.d.ts +1 -1
  99. package/page/components/ResponsiveWidgetImage/ResponsiveWidgetImage.js +2 -2
  100. package/page/components/WidgetVideo/WidgetVideo.d.ts +1 -1
  101. package/page/components/WidgetVideo/WidgetVideo.d.ts.map +1 -1
  102. package/page/helpers/index.d.ts +5 -2
  103. package/page/helpers/index.d.ts.map +1 -1
  104. package/page/helpers/index.js +8 -5
  105. package/page/widgets/Button/Button.js +2 -3
  106. package/page/widgets/NestedCategoryFilter/NestedCategoryFilter.js +8 -8
  107. package/page/widgets/ProductList/ProductList.js +18 -14
  108. package/page/widgets/Video/hooks.d.ts +2 -2
  109. package/product/components/ProductCard/index.js +7 -1
  110. package/product/components/ProductGrid/components/Item/components/ItemDetails/index.js +6 -1
  111. package/product/components/ProductGrid/components/Item/components/ItemImage/index.js +1 -11
  112. package/product/components/ProductGrid/components/Item/index.js +3 -2
  113. package/product/components/ProductGrid/components/Layout/index.js +2 -1
  114. package/product/components/ProductGridPrice/index.js +0 -1
  115. package/product/components/ProductImage/ProductImage.d.ts.map +1 -1
  116. package/product/components/ProductImage/ProductImage.js +7 -2
  117. package/product/components/ProductImage/ProductImagePlaceholder.js +3 -3
  118. package/product/components/ProductSlider/index.js +1 -1
  119. package/product/components/UnitQuantityPicker/UnitQuantityPicker.d.ts.map +1 -1
  120. package/product/components/UnitQuantityPicker/UnitQuantityPicker.js +15 -33
  121. package/push-opt-in/components/PushOptInModal/index.js +4 -4
  122. package/registration/components/Registration/RegistrationFormActions.js +4 -4
  123. package/reviews/components/Reviews/components/AllReviewsLink/index.js +6 -6
  124. package/reviews/components/Reviews/components/Header/components/WriteReviewLink/index.js +4 -3
  125. package/reviews/components/Reviews/components/Header/components/WriteReviewLink/spec.js +28 -22
  126. package/reviews/components/Reviews/spec.js +5 -6
  127. package/settings/reducers/appSettings.d.ts.map +1 -1
  128. package/settings/reducers/appSettings.js +18 -2
  129. package/settings/selectors/appSettings.d.ts +37 -2
  130. package/settings/selectors/appSettings.d.ts.map +1 -1
  131. package/settings/selectors/appSettings.js +30 -1
  132. package/settings/types/appSettings.d.ts +42 -2
  133. package/settings/types/appSettings.d.ts.map +1 -1
  134. package/settings/types/appSettings.js +124 -1
  135. package/styles/helpers/index.d.ts +1 -0
  136. package/styles/helpers/index.js +1 -0
  137. package/styles/helpers/loadFontCss.d.ts +22 -0
  138. package/styles/helpers/loadFontCss.d.ts.map +1 -0
  139. package/styles/helpers/loadFontCss.js +138 -0
  140. package/styles/helpers/loadThemeCss.d.ts.map +1 -1
  141. package/styles/helpers/loadThemeCss.js +11 -0
  142. package/styles/index.d.ts +1 -1
  143. package/styles/index.d.ts.map +1 -1
  144. package/styles/theme/createDefaultThemeOptions/index.d.ts.map +1 -1
  145. package/styles/theme/createDefaultThemeOptions/index.js +94 -3
  146. package/styles/theme/createTheme/createComponents.types.d.ts +25 -0
  147. package/styles/theme/createTheme/createComponents.types.d.ts.map +1 -1
  148. package/styles/theme/createTheme/createComponents.types.js +28 -3
  149. package/styles/theme/createTheme/createShape.d.ts +2 -3
  150. package/styles/theme/createTheme/createShape.d.ts.map +1 -1
  151. package/styles/theme/createTheme/createShape.js +1 -2
  152. package/styles/theme/createTheme/createThemeFromColorScheme.d.ts +3 -1
  153. package/styles/theme/createTheme/createThemeFromColorScheme.d.ts.map +1 -1
  154. package/styles/theme/createTheme/createThemeFromColorScheme.js +4 -2
  155. package/styles/theme/createTheme/createTypography.d.ts +2 -1
  156. package/styles/theme/createTheme/createTypography.js +58 -18
  157. package/styles/theme/createTheme/index.d.ts +2 -2
  158. package/styles/theme/createTheme/index.d.ts.map +1 -1
  159. package/styles/theme/createTheme/index.js +2 -2
  160. package/styles/theme/createTheme/types.d.ts +9 -2
  161. package/styles/theme/createTheme/types.d.ts.map +1 -1
  162. package/styles/theme/createTheme/types.js +6 -0
  163. package/styles/theme/hooks/useColorScheme.d.ts +2 -2
  164. package/styles/theme/hooks/useColorScheme.d.ts.map +1 -1
  165. package/styles/theme/hooks/useColorScheme.js +1 -1
  166. package/styles/theme/hooks/useMediaQuery.d.ts +7 -0
  167. package/styles/theme/hooks/useMediaQuery.d.ts.map +1 -1
  168. package/styles/theme/hooks/useMediaQuery.js +5 -5
  169. package/styles/theme/hooks/useTheme.js +1 -1
  170. package/styles/theme/index.d.ts +3 -1
  171. package/styles/theme/index.d.ts.map +1 -1
  172. package/styles/theme/providers/ColorSchemeContext.d.ts +30 -9
  173. package/styles/theme/providers/ColorSchemeContext.d.ts.map +1 -1
  174. package/styles/theme/providers/ColorSchemeContext.js +8 -0
  175. package/styles/theme/providers/ThemeContext.d.ts +3 -0
  176. package/styles/theme/providers/ThemeContext.d.ts.map +1 -0
  177. package/styles/theme/providers/ThemeContext.js +2 -0
  178. package/styles/theme/providers/ThemeProvider.d.ts +2 -2
  179. package/styles/theme/providers/ThemeProvider.d.ts.map +1 -1
  180. package/styles/theme/providers/ThemeProvider.js +58 -16
  181. package/styles/theme/utils/color.d.ts +12 -12
  182. package/styles/theme/utils/color.d.ts.map +1 -1
  183. package/tracking/components/CookieConsentModal/index.js +3 -4
  184. package/tracking/components/PrivacySettings/index.js +3 -3
  185. package/cart/components/PaymentBar/PaymentBarReserveButton.connector.js +0 -6
  186. package/cart/components/PaymentBar/PaymentBarReserveButton.js +0 -71
  187. package/locations/components/StoreFinder/StoreFinderGetDirectionsButton.connector.js +0 -16
  188. package/locations/components/StoreFinder/StoreFinderGetDirectionsButton.js +0 -52
@@ -2,7 +2,7 @@ import React, { useRef, useEffect, useMemo, useCallback, memo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import debounce from 'lodash/debounce';
4
4
  import { I18n } from '@shopgate/engage/components';
5
- import RippleButton from '@shopgate/pwa-ui-shared/RippleButton';
5
+ import { ButtonBase } from '@shopgate/engage/components/v2';
6
6
  import { makeStyles, useTheme } from '@shopgate/engage/styles';
7
7
 
8
8
  /**
@@ -147,9 +147,7 @@ const ChipLayout = ({
147
147
  }), /*#__PURE__*/_jsx("div", {
148
148
  ref: moreButtonRef,
149
149
  className: classes.moreButtonWrapper,
150
- children: /*#__PURE__*/_jsx(RippleButton, {
151
- fill: true,
152
- type: "plain",
150
+ children: /*#__PURE__*/_jsx(ButtonBase, {
153
151
  className: moreButtonClassName,
154
152
  onClick: handleMoreButton,
155
153
  children: /*#__PURE__*/_jsx(I18n.Text, {
@@ -11,7 +11,7 @@ import { historyReset } from '@shopgate/pwa-common/actions/router/historyReset';
11
11
  function mapDispatchToProps(dispatch) {
12
12
  return {
13
13
  push: params => dispatch(historyPush(params)),
14
- pop: () => dispatch(historyPop()),
14
+ pop: params => dispatch(historyPop(params)),
15
15
  replace: params => dispatch(historyReplace(params)),
16
16
  reset: () => dispatch(historyReset())
17
17
  };
@@ -1,15 +1,15 @@
1
1
  declare const _default: import("react-redux").ConnectedComponent<typeof NavigationHandler, {
2
- children: NonNullable<PropTypes.ReactNodeLike>;
3
2
  pop?: ((...args: any[]) => any) | null | undefined;
4
3
  push?: ((...args: any[]) => any) | null | undefined;
4
+ children: NonNullable<PropTypes.ReactNodeLike>;
5
5
  reset?: ((...args: any[]) => any) | null | undefined;
6
6
  replace?: ((...args: any[]) => any) | null | undefined;
7
7
  context?: import("react-redux/es/components/Context").ReactReduxContextInstance | undefined;
8
8
  store?: import("redux").Store | undefined;
9
9
  } | {
10
- children: NonNullable<PropTypes.ReactNodeLike>;
11
10
  pop?: ((...args: any[]) => any) | null | undefined;
12
11
  push?: ((...args: any[]) => any) | null | undefined;
12
+ children: NonNullable<PropTypes.ReactNodeLike>;
13
13
  reset?: ((...args: any[]) => any) | null | undefined;
14
14
  replace?: ((...args: any[]) => any) | null | undefined;
15
15
  store?: import("redux").Store | undefined;
@@ -45,7 +45,16 @@ describe('<NavigationHandler />', () => {
45
45
  });
46
46
  it('should trigger the pop() callbacks on navigation.pop event', async () => {
47
47
  await pop();
48
- expect(UIEvents.emit).toBeCalledWith(NAVIGATION_POP);
48
+ expect(UIEvents.emit).toBeCalledWith(NAVIGATION_POP, undefined);
49
+ UIEvents.emit.mockClear();
50
+ });
51
+ it('should forward pop() params so that multiple routes can be popped', async () => {
52
+ await pop({
53
+ steps: 2
54
+ });
55
+ expect(UIEvents.emit).toBeCalledWith(NAVIGATION_POP, {
56
+ steps: 2
57
+ });
49
58
  UIEvents.emit.mockClear();
50
59
  });
51
60
  it('should trigger the replace() callbacks on navigation.replace event', async () => {
@@ -14,8 +14,7 @@ export interface PaperOwnProps {
14
14
  /** Removes the rounded corners. @default false */
15
15
  square?: boolean;
16
16
  /**
17
- * Corner radius. The theme carries a dedicated value per surface `shape.cardsBorderRadius` for
18
- * cards. Ignored when `square`.
17
+ * Corner radius per surface, e.g. `components.cards.borderRadius`. Ignored when `square`.
19
18
  * @default theme.shape.borderRadius
20
19
  */
21
20
  borderRadius?: number | string;
@@ -1 +1 @@
1
- {"version":3,"file":"Paper.d.ts","sourceRoot":"","sources":["../../../components/Paper/Paper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,UAAU,CAAC;AAEpD,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IAC9B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAChC,oFAAoF;IACpF,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,kDAAkD;IAClD,MAAM,CAAC,EAAE,O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AG,YAAY,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACpF;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,UAAU,GACpB,aAAa,GACX,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,aAAa,CAAC,GAC5D;IAAE,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,CAAA;CAAE,CAAC;AA2BxC;;;GAGG;AACH,QAAA,MAAM,KAAK;;qCAkCT,CAAC;AAIH,eAAe,KAAK,CAAC"}
@@ -1,28 +1,11 @@
1
1
  import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import '@testing-library/jest-dom';
4
- import { ThemeProvider, createTheme } from '@shopgate/engage/styles';
5
4
  import Paper from "./Paper";
6
5
 
7
- // ThemeProvider resolves the active breakpoint via matchMedia, which jsdom doesn't implement.
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- Object.defineProperty(window, 'matchMedia', {
10
- writable: true,
11
- value: query => ({
12
- matches: false,
13
- media: query,
14
- addEventListener: jest.fn(),
15
- removeEventListener: jest.fn()
16
- })
17
- });
18
- const theme = createTheme();
19
- const renderWithTheme = ui => render(/*#__PURE__*/_jsx(ThemeProvider, {
20
- theme: theme,
21
- children: ui
22
- }));
23
-
24
6
  // tss keeps injected rules in the document across tests, so assertions have to be scoped to the
25
7
  // element under test — a global sweep would also match rules another test left behind.
8
+ import { jsx as _jsx } from "react/jsx-runtime";
26
9
  const styleTextFor = element => Array.from(document.styleSheets).flatMap(sheet => {
27
10
  try {
28
11
  return Array.from(sheet.cssRules);
@@ -31,12 +14,12 @@ const styleTextFor = element => Array.from(document.styleSheets).flatMap(sheet =
31
14
  }
32
15
  }).filter(rule => rule instanceof CSSStyleRule && element.matches(rule.selectorText)).map(rule => rule.cssText).join('');
33
16
  const renderPaper = ui => {
34
- renderWithTheme(ui);
17
+ render(ui);
35
18
  return styleTextFor(screen.getByTestId('paper'));
36
19
  };
37
20
  describe('<Paper />', () => {
38
21
  it('renders children and the engage__paper class next to a caller className', () => {
39
- renderWithTheme(/*#__PURE__*/_jsx(Paper, {
22
+ render(/*#__PURE__*/_jsx(Paper, {
40
23
  className: "custom",
41
24
  "data-testid": "paper",
42
25
  children: "content"
@@ -47,7 +30,7 @@ describe('<Paper />', () => {
47
30
  expect(el).toHaveClass('custom');
48
31
  });
49
32
  it('renders as the given component', () => {
50
- renderWithTheme(/*#__PURE__*/_jsx(Paper, {
33
+ render(/*#__PURE__*/_jsx(Paper, {
51
34
  component: "section",
52
35
  "data-testid": "paper",
53
36
  children: "x"
@@ -55,7 +38,7 @@ describe('<Paper />', () => {
55
38
  expect(screen.getByTestId('paper').tagName).toBe('SECTION');
56
39
  });
57
40
  it('passes data attributes through to the element', () => {
58
- renderWithTheme(/*#__PURE__*/_jsx(Paper, {
41
+ render(/*#__PURE__*/_jsx(Paper, {
59
42
  "data-testid": "paper",
60
43
  "data-foo": "bar",
61
44
  children: "x"
@@ -1 +1 @@
1
- {"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../../components/Tabs/components/Tab.jsx"],"names":[],"mappings":";AAqCA;;;;GAIG;AACH,4BAHW,MAAM,GACJ,GAAG,CA0Df;;;;;;;;;;;;;;;;;;;;;;;sBAjGqB,YAAY"}
1
+ {"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../../components/Tabs/components/Tab.jsx"],"names":[],"mappings":";AAmCA;;;;GAIG;AACH,4BAHW,MAAM,GACJ,GAAG,CA0Df;;;;;;;;;;;;;;;;;;;;;;;sBA/FqB,YAAY"}
@@ -1,24 +1,22 @@
1
1
  import React, { useContext } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { makeStyles, responsiveMediaQuery } from '@shopgate/engage/styles';
4
- import Button from '@shopgate/pwa-ui-shared/Button';
4
+ import { Button } from '@shopgate/engage/components/v2';
5
5
  import { ViewContext } from "../../View";
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  const useStyles = makeStyles()({
8
8
  root: {
9
- '&&': {
10
- maxWidth: 200,
11
- minWidth: 72,
12
- position: 'relative',
13
- boxSizing: 'border-box',
14
- minHeight: 48,
15
- flexShrink: 0,
16
- flexGrow: 1,
17
- padding: '6px 6px',
18
- overflow: 'hidden',
19
- whiteSpace: 'normal',
20
- textAlign: 'center'
21
- },
9
+ maxWidth: 200,
10
+ minWidth: 72,
11
+ position: 'relative',
12
+ boxSizing: 'border-box',
13
+ minHeight: 48,
14
+ flexShrink: 0,
15
+ flexGrow: 1,
16
+ padding: '6px 6px',
17
+ overflow: 'hidden',
18
+ whiteSpace: 'normal',
19
+ textAlign: 'center',
22
20
  [responsiveMediaQuery('<=xs', {
23
21
  appAlways: true
24
22
  })]: {
@@ -84,8 +82,8 @@ const Tab = props => {
84
82
  }
85
83
  };
86
84
  return /*#__PURE__*/_jsxs(Button, {
87
- flat: true,
88
- type: selected ? 'secondary' : 'regular',
85
+ variant: "text",
86
+ color: selected ? 'primary' : 'inherit',
89
87
  className: cx(classes.root, className),
90
88
  role: "tab",
91
89
  "aria-selected": selected,
@@ -9,7 +9,7 @@ declare const useStyles: (params: void, muiStyleOverridesParams?: {
9
9
  props: Record<string, unknown>;
10
10
  ownerState?: Record<string, unknown> | undefined;
11
11
  } | undefined) => {
12
- classes: Record<"button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "root" | "gutterBottom" | "noWrap" | "paragraph" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | "fontWeightLight" | "fontWeightRegular" | "fontWeightMedium" | "fontWeightBold" | "srOnly" | "alignLeft" | "alignCenter" | "alignRight" | "alignJustify" | "colorInherit" | "colorPrimary" | "colorSecondary" | "colorTextPrimary" | "colorTextSecondary" | "colorError" | "colorWarning" | "colorSuccess" | "displayInline" | "displayBlock", string>;
12
+ classes: Record<"h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "subtitle1" | "subtitle2" | "body1" | "body2" | "caption" | "button" | "overline" | "root" | "fontWeightLight" | "fontWeightRegular" | "fontWeightMedium" | "fontWeightBold" | "gutterBottom" | "noWrap" | "paragraph" | "srOnly" | "alignLeft" | "alignCenter" | "alignRight" | "alignJustify" | "colorInherit" | "colorPrimary" | "colorSecondary" | "colorTextPrimary" | "colorTextSecondary" | "colorError" | "colorWarning" | "colorSuccess" | "displayInline" | "displayBlock", string>;
13
13
  theme: import("@shopgate/engage/styles").Theme;
14
14
  css: import("tss-react").Css;
15
15
  cx: import("tss-react").Cx;
@@ -1,36 +1,38 @@
1
1
  import React from 'react';
2
2
  import type { PaletteColorsWithMain } from '@shopgate/engage/styles';
3
3
  import type { ButtonBaseProps } from '../ButtonBase';
4
- /**
5
- * The Button component is a versatile UI element that can be used to trigger actions or navigate users.
6
- * It supports multiple variants, colors, and sizes, making it suitable for a wide range of use cases.
7
- */
8
- declare const Button: React.ForwardRefExoticComponent<ButtonOwnProps & import("../ButtonBase").ButtonBaseOwnProps & React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
9
4
  declare const useStyles: (params: ButtonOwnProps, muiStyleOverridesParams?: {
10
5
  props: Record<string, unknown>;
11
6
  ownerState?: Record<string, unknown> | undefined;
12
7
  } | undefined) => {
13
- classes: Record<"text" | "icon" | "small" | "large" | "label" | "root" | "disabled" | "outlined" | "contained" | "disableElevation" | "fullWidth" | "startIcon" | "endIcon" | "loader" | "loadingPlaceholder" | "loadingIndicator", string>;
8
+ classes: Record<"small" | "large" | "text" | "icon" | "label" | "link" | "root" | "disabled" | "dense" | "denseSmall" | "denseLarge" | "outlined" | "contained" | "enableElevation" | "fullWidth" | "startIcon" | "endIcon" | "loader" | "loadingPlaceholder" | "loadingIndicator", string>;
14
9
  theme: import("@shopgate/engage/styles").Theme;
15
10
  css: import("tss-react").Css;
16
11
  cx: import("tss-react").Cx;
17
12
  };
18
13
  export interface ButtonOwnProps {
19
14
  /**
20
- * The variant to use.
15
+ * The variant to use. `link` renders a sentence case button without padding or decoration, and
16
+ * dims on press instead of showing a ripple.
21
17
  * @default 'contained'
22
18
  */
23
- variant?: 'contained' | 'outlined' | 'text';
19
+ variant?: 'contained' | 'outlined' | 'text' | 'link';
20
+ /**
21
+ * If true, the ripple effect is disabled. Defaults to true for `variant="link"`, which dims on
22
+ * press instead.
23
+ * @default false
24
+ */
25
+ disableRipple?: boolean;
24
26
  /**
25
27
  * The color of the component.
26
28
  * @default 'inherit'
27
29
  */
28
- color?: PaletteColorsWithMain | 'inherit';
30
+ color?: PaletteColorsWithMain | 'inherit' | 'cta';
29
31
  /**
30
- * If `true`, no elevation is used for contained buttons.
32
+ * If `true`, a drop shadow is added to the button. Buttons are flat by default.
31
33
  * @default false
32
34
  */
33
- disableElevation?: boolean;
35
+ enableElevation?: boolean;
34
36
  /**
35
37
  * Element placed before the children.
36
38
  */
@@ -64,11 +66,20 @@ export interface ButtonOwnProps {
64
66
  * @default 'medium'
65
67
  */
66
68
  size?: 'small' | 'medium' | 'large';
69
+ /**
70
+ * If `true`, the button uses reduced padding. Combines with `size`, which keeps controlling the
71
+ * font size.
72
+ * @default false
73
+ */
74
+ dense?: boolean;
67
75
  /**
68
76
  * Override or extend the styles applied to the component.
69
77
  */
70
78
  classes?: Partial<ReturnType<typeof useStyles>['classes']>;
71
79
  }
72
- export type ButtonProps = ButtonOwnProps & ButtonBaseProps;
73
- export default Button;
80
+ export type ButtonProps<C extends React.ElementType = 'button'> = ButtonOwnProps & ButtonBaseProps<C>;
81
+ declare const _default: <C extends React.ElementType = "button">(props: ButtonProps<C> & {
82
+ ref?: React.ComponentPropsWithRef<C>["ref"];
83
+ }) => React.ReactElement | null;
84
+ export default _default;
74
85
  //# sourceMappingURL=Button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../components/v2/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB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AAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;CAAE,KACpE,KAAK,CAAC,YAAY,GAAG,IAAI;AAF9B,wBAE+B"}
@@ -7,7 +7,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  * The Button component is a versatile UI element that can be used to trigger actions or navigate users.
8
8
  * It supports multiple variants, colors, and sizes, making it suitable for a wide range of use cases.
9
9
  */
10
- const Button = /*#__PURE__*/forwardRef((props, ref) => {
10
+ function Button(props, ref) {
11
11
  const {
12
12
  variant = 'contained',
13
13
  color = 'inherit',
@@ -17,10 +17,13 @@ const Button = /*#__PURE__*/forwardRef((props, ref) => {
17
17
  loadingPosition = 'center',
18
18
  loadingIndicator: loadingIndicatorProp,
19
19
  size = 'medium',
20
+ dense = false,
20
21
  disabled = false,
22
+ disableRipple = variant === 'link',
21
23
  fullWidth = false,
22
- disableElevation = false,
24
+ enableElevation = false,
23
25
  className,
26
+ classes: classesProp,
24
27
  children,
25
28
  ...other
26
29
  } = props;
@@ -36,9 +39,10 @@ const Button = /*#__PURE__*/forwardRef((props, ref) => {
36
39
  fullWidth
37
40
  }, {
38
41
  props: {
39
- classes: props.classes
42
+ classes: classesProp
40
43
  }
41
44
  });
45
+ const staticClassNames = ['engage__button', 'common__button', 'ui-shared__button', !disableRipple && 'ui-shared__ripple-button'].filter(Boolean).join(' ');
42
46
  const loadingIndicator = loadingIndicatorProp ?? /*#__PURE__*/_jsx(CircularProgress, {
43
47
  color: "inherit",
44
48
  size: 16
@@ -70,16 +74,29 @@ const Button = /*#__PURE__*/forwardRef((props, ref) => {
70
74
  }) : null;
71
75
  return /*#__PURE__*/_jsx(ButtonBase, {
72
76
  ref: ref,
73
- className: cx(classes.root, className, {
77
+ className: cx(classes.root, {
74
78
  [classes.text]: variant === 'text',
75
79
  [classes.outlined]: variant === 'outlined',
76
80
  [classes.contained]: variant === 'contained',
77
81
  [classes.small]: size === 'small',
78
82
  [classes.large]: size === 'large',
83
+ [classes.dense]: dense && size === 'medium',
84
+ [classes.denseSmall]: dense && size === 'small',
85
+ [classes.denseLarge]: dense && size === 'large',
86
+ [classes.link]: variant === 'link',
79
87
  [classes.disabled]: disabled || loading,
80
88
  [classes.fullWidth]: fullWidth,
81
- [classes.disableElevation]: disableElevation
82
- }),
89
+ [classes.enableElevation]: enableElevation
90
+ }, staticClassNames, className),
91
+ disableRipple: disableRipple,
92
+ disableBaseClassName: true,
93
+ "data-variant": variant,
94
+ "data-color": color,
95
+ "data-size": size,
96
+ "data-dense": dense || undefined,
97
+ "data-full-width": fullWidth || undefined,
98
+ "data-enable-elevation": enableElevation || undefined,
99
+ "data-loading": loading || undefined,
83
100
  disabled: disabled || loading,
84
101
  ...other,
85
102
  children: /*#__PURE__*/_jsxs("span", {
@@ -87,7 +104,23 @@ const Button = /*#__PURE__*/forwardRef((props, ref) => {
87
104
  children: [startIcon, loadingPosition !== 'end' && loader, children, loadingPosition === 'end' && loader, endIcon]
88
105
  })
89
106
  });
90
- });
107
+ }
108
+
109
+ /**
110
+ * Opacity of the overlay that the text and outlined variants tint themselves with on hover. The
111
+ * dark scheme needs more of it: the overlay takes the color of the label, and a light tint over a
112
+ * dark surface reads as a far smaller change than a dark tint over a light one.
113
+ */
114
+ const HOVER_OVERLAY_OPACITY = 0.1;
115
+ const HOVER_OVERLAY_OPACITY_DARK = 0.28;
116
+
117
+ /**
118
+ * Opacity the outlined border rests at, leaving it somewhere to go on hover where it returns to the
119
+ * full color. The dark scheme keeps more of it: fading toward a dark backdrop cuts the brightness
120
+ * of the border, where fading toward a light one mostly cuts its saturation.
121
+ */
122
+ const OUTLINED_BORDER_OPACITY = 0.5;
123
+ const OUTLINED_BORDER_OPACITY_DARK = 0.7;
91
124
  const useStyles = makeStyles({
92
125
  name: 'Button'
93
126
  })((theme, props) => {
@@ -101,113 +134,174 @@ const useStyles = makeStyles({
101
134
  } = props;
102
135
  let cssColor = '';
103
136
  let contrastText = '';
104
- if (color !== 'inherit') {
137
+ let darkCssColor = '';
138
+ if (color === 'cta') {
139
+ // The call to action color is not part of the palette. It's a component token so that merchants
140
+ // can configure it separately from the primary color via `--color-button-cta`.
141
+ cssColor = theme.components.ctaButton.background;
142
+ contrastText = theme.components.ctaButton.color;
143
+ } else if (color !== 'inherit') {
105
144
  cssColor = color && theme.palette?.[color]?.main ? theme.palette[color].main : theme.palette.primary.main;
106
145
  contrastText = color && theme.palette?.[color]?.contrastText ? theme.palette[color].contrastText : theme.palette.primary.contrastText;
107
146
  } else if (variant === 'contained') {
147
+ // The numeric grey scale is absolute rather than per scheme, so it stays light in both. The
148
+ // light value is kept as it is and only the dark scheme swaps in a surface that its inherited
149
+ // text color can be read on.
108
150
  // eslint-disable-next-line prefer-destructuring
109
151
  cssColor = theme.palette.grey[200];
152
+ darkCssColor = theme.palette.background.emphasized;
110
153
  contrastText = 'inherit';
111
154
  } else {
112
155
  cssColor = 'currentColor';
113
156
  }
114
157
  return {
115
158
  root: {
159
+ // The `components.button` vars are override hooks for CSS injection and are intentionally
160
+ // left unseeded, so these fallbacks are what render by default. Don't "fix" the empty values
161
+ // by skipping their generation - that would also drop them from `theme.vars`, which would
162
+ // turn these into `var(undefined, ...)`.
116
163
  '--button-color': `var(${theme.vars.components.button.color}, ${cssColor})`,
117
164
  '--text-color': `var(${theme.vars.components.button.textColor}, ${contrastText})`,
118
- '--border-radius': `var(${theme.vars.components.button.borderRadius}, ${theme.shape.borderRadius})`,
165
+ // A single `applyStyles` call for the whole scheme. A second one would land on the same
166
+ // object key and quietly replace this one.
167
+ ...theme.applyStyles('dark', {
168
+ ...(darkCssColor ? {
169
+ '--button-color': `var(${theme.vars.components.button.color}, ${darkCssColor})`
170
+ } : {}),
171
+ '--variant-outlinedBorder': theme.alpha('var(--button-color)', OUTLINED_BORDER_OPACITY_DARK)
172
+ }),
173
+ '--border-radius': theme.components.button.borderRadius,
119
174
  '--font-size': theme.typography.button.fontSize,
120
175
  '--variant-textColor': 'var(--button-color)',
121
176
  '--variant-textDisabledColor': theme.palette.action.disabled,
122
177
  '--variant-outlinedColor': 'var(--button-color)',
123
- '--variant-outlinedBorder': 'var(--button-color)',
178
+ '--variant-outlinedBorder': theme.alpha('var(--button-color)', OUTLINED_BORDER_OPACITY),
124
179
  '--variant-outlinedDisabledColor': theme.palette.action.disabled,
125
180
  '--variant-outlinedDisabledBorder': theme.palette.action.disabled,
126
181
  '--variant-containedColor': 'var(--text-color)',
127
182
  '--variant-containedBg': 'var(--button-color)',
128
183
  '--variant-containedDisabledColor': theme.palette.action.disabled,
129
184
  '--variant-containedDisabledBg': theme.palette.action.disabledBackground,
130
- '--icon-size': theme.vars.typography.button.fontSize,
131
185
  ...theme.typography.button,
132
186
  fontSize: 'var(--font-size)',
133
187
  boxSizing: 'border-box',
134
188
  minWidth: 64,
135
- padding: '6px 16px',
189
+ // Every variant reserves the same 1px border box, so that an outlined button doesn't render
190
+ // 2px larger than a contained one. The paddings are 1px smaller than they look because of it.
191
+ border: '1px solid transparent',
192
+ padding: '5px 15px',
136
193
  transition: theme.transitions.create(['background-color', 'box-shadow', 'border'], {
137
194
  duration: theme.transitions.duration.short
138
195
  }),
139
196
  borderRadius: 'var(--border-radius)',
140
197
  '&:hover': {
141
- '--variant-textBg': theme.alpha(cssColor, 0.1),
142
- '--variant-outlinedBg': theme.alpha(cssColor, 0.1),
143
198
  textDecoration: 'none',
144
- '&:disabled': {
145
- backgroundColor: 'transparent'
146
- },
147
199
  // Reset on touch devices, it doesn't add specificity
148
200
  '@media (hover: none)': {
149
201
  backgroundColor: 'transparent'
150
202
  }
151
203
  },
152
- ...(loading && loadingPosition === 'center' && {})
204
+ // A disabled button keeps taking pointer events so that it can show a not-allowed cursor,
205
+ // which leaves it matching `:hover`. Its hover backgrounds stay unset instead, so the colors
206
+ // the variants give it while disabled are what remains visible.
207
+ '&:hover:not(:disabled):not([aria-disabled="true"])': {
208
+ '--variant-textBg': theme.alpha(cssColor, HOVER_OVERLAY_OPACITY),
209
+ '--variant-outlinedBg': theme.alpha(cssColor, HOVER_OVERLAY_OPACITY),
210
+ // The resting border sits at a fraction of the color, so hover brings it back to the full
211
+ // one. The root transition covers `border`, which carries the change over.
212
+ '--variant-outlinedBorder': 'var(--button-color)',
213
+ ...theme.applyStyles('dark', {
214
+ '--variant-textBg': theme.alpha(cssColor, HOVER_OVERLAY_OPACITY_DARK),
215
+ '--variant-outlinedBg': theme.alpha(cssColor, HOVER_OVERLAY_OPACITY_DARK)
216
+ }),
217
+ '@media (hover: none)': {
218
+ '--variant-outlinedBorder': theme.alpha('var(--button-color)', OUTLINED_BORDER_OPACITY),
219
+ ...theme.applyStyles('dark', {
220
+ '--variant-outlinedBorder': theme.alpha('var(--button-color)', OUTLINED_BORDER_OPACITY_DARK)
221
+ })
222
+ }
223
+ }
153
224
  },
154
225
  small: {
155
226
  '--font-size': `calc(${theme.typography.button.fontSize} * 0.875)`,
156
- padding: '4px 10px'
227
+ padding: '4px 9px'
157
228
  },
158
229
  large: {
159
230
  '--font-size': `calc(${theme.typography.button.fontSize} * 1.125)`,
160
- padding: '8px 22px'
231
+ padding: '7px 21px'
232
+ },
233
+ // The dense paddings roughly halve the regular ones. They are applied after the size classes,
234
+ // so they win by declaration order without needing extra specificity.
235
+ dense: {
236
+ padding: '2px 7px'
237
+ },
238
+ denseSmall: {
239
+ padding: '2px 4px'
240
+ },
241
+ denseLarge: {
242
+ padding: '3px 10px'
243
+ },
244
+ link: {
245
+ padding: 0,
246
+ minWidth: 0,
247
+ border: 0,
248
+ textTransform: 'none',
249
+ color: 'var(--variant-textColor)',
250
+ // Scoped like the hover backgrounds are: a disabled button stays hit testable for its
251
+ // not-allowed cursor, so it would otherwise dim on press like an operable one.
252
+ '&:active:not(:disabled):not([aria-disabled="true"])': {
253
+ opacity: 0.5
254
+ },
255
+ '&:disabled, &[aria-disabled="true"]': {
256
+ color: 'var(--variant-textDisabledColor)'
257
+ }
161
258
  },
162
259
  disabled: {},
163
260
  text: {
164
261
  color: 'var(--variant-textColor)',
165
262
  background: 'var(--variant-textBg)',
166
- '&:disabled': {
263
+ '&:disabled, &[aria-disabled="true"]': {
167
264
  color: 'var(--variant-textDisabledColor)'
168
265
  }
169
266
  },
170
267
  outlined: {
171
268
  color: 'var(--variant-outlinedColor)',
172
- border: '1px solid var(--variant-outlinedBorder)',
269
+ borderColor: 'var(--variant-outlinedBorder)',
173
270
  background: 'var(--variant-outlinedBg)',
174
- '&:disabled': {
175
- border: '1px solid var(--variant-outlinedDisabledBorder)',
271
+ '&:disabled, &[aria-disabled="true"]': {
272
+ borderColor: 'var(--variant-outlinedDisabledBorder)',
176
273
  color: 'var(--variant-outlinedDisabledColor)'
177
274
  }
178
275
  },
179
276
  contained: {
180
277
  color: 'var(--variant-containedColor)',
181
278
  background: 'var(--variant-containedBg)',
182
- boxShadow: theme.shadows[2],
183
279
  '&:hover': {
184
280
  background: theme.darken('var(--variant-containedBg)'),
185
- boxShadow: theme.shadows[4],
186
281
  // Reset on touch devices, it doesn't add specificity
187
282
  '@media (hover: none)': {
188
- background: 'var(--variant-containedBg)',
189
- boxShadow: theme.shadows[2]
283
+ background: 'var(--variant-containedBg)'
190
284
  }
191
285
  },
192
- '&:active': {
193
- boxShadow: theme.shadows[6]
194
- },
195
- '&:disabled': {
286
+ '&:disabled, &[aria-disabled="true"]': {
196
287
  color: 'var(--variant-containedDisabledColor)',
197
- backgroundColor: 'var(--variant-containedDisabledBg)',
198
- boxShadow: theme.shadows[0]
288
+ backgroundColor: 'var(--variant-containedDisabledBg)'
199
289
  }
200
290
  },
201
- disableElevation: {
202
- boxShadow: 'none',
291
+ enableElevation: {
292
+ boxShadow: theme.shadows[2],
203
293
  '&:hover': {
204
- boxShadow: 'none'
294
+ boxShadow: theme.shadows[4],
295
+ // Reset on touch devices, it doesn't add specificity
296
+ '@media (hover: none)': {
297
+ boxShadow: theme.shadows[2]
298
+ }
205
299
  },
206
300
  '&:active': {
207
- boxShadow: 'none'
301
+ boxShadow: theme.shadows[6]
208
302
  },
209
- '&$disabled': {
210
- boxShadow: 'none'
303
+ '&:disabled, &[aria-disabled="true"]': {
304
+ boxShadow: theme.shadows[0]
211
305
  }
212
306
  },
213
307
  label: {
@@ -311,4 +405,8 @@ const useStyles = makeStyles({
311
405
  }
312
406
  };
313
407
  });
314
- export default Button;
408
+ const ButtonWithRef = /*#__PURE__*/forwardRef(Button);
409
+ ButtonWithRef.displayName = 'Button';
410
+
411
+ // `forwardRef` erases the generic, so the call signature is restored with a cast.
412
+ export default ButtonWithRef;