@7shifts/sous-chef 3.89.3 → 3.89.5

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/dist/index.js CHANGED
@@ -240,7 +240,9 @@ var COLORS = {
240
240
  'hover-lighten': 'var(--color-hover-lighten)',
241
241
  'hover-darken': 'var(--color-hover-darken)',
242
242
  'brand-neutrals-caviar-dynamic': 'var(--color-brand-neutrals-caviar-dynamic)',
243
- 'brand-neutrals-chefscoat-dynamic': 'var(--color-brand-neutrals-chefscoat-dynamic)'
243
+ 'brand-neutrals-chefscoat-dynamic': 'var(--color-brand-neutrals-chefscoat-dynamic)',
244
+ 'on-graphic-black': 'var(--color-on-graphic-black)',
245
+ 'on-graphic-white': 'var(--color-on-graphic-white)'
244
246
  };
245
247
 
246
248
  // This file is automatically generated by 'scripts/tokens/build-z-indexes.sh'
@@ -6446,6 +6448,28 @@ var useContainerBackgroundColorCheck = function useContainerBackgroundColorCheck
6446
6448
  return background;
6447
6449
  };
6448
6450
 
6451
+ var TIME_FORMAT = {
6452
+ FORMAT_24H: '24h',
6453
+ FORMAT_AMPM: 'ampm'
6454
+ };
6455
+
6456
+ var initialValue$1 = {
6457
+ // This country prop is currently used to configure the phone number field
6458
+ country: 'US',
6459
+ // This timeFormat prop is currently used to configure the time format for time fields
6460
+ timeFormat: TIME_FORMAT.FORMAT_AMPM,
6461
+ // Default theme is light, but it will be overridden by the useTheme hook in the SousChefProvider
6462
+ theme: 'light'
6463
+ };
6464
+ var ProviderConfigContext = React.createContext(initialValue$1);
6465
+ var useProviderConfig = function useProviderConfig() {
6466
+ var context = React.useContext(ProviderConfigContext);
6467
+ if (!context) {
6468
+ throw Error('The `<SousChefProvider>` is not set. Please wrap your application with `<SousChefProvider>`');
6469
+ }
6470
+ return context;
6471
+ };
6472
+
6449
6473
  var _excluded$t = ["href", "target", "theme", "onClick", "children"];
6450
6474
  var Link = function Link(_ref) {
6451
6475
  var _classNames;
@@ -6459,13 +6483,19 @@ var Link = function Link(_ref) {
6459
6483
  var _getDataProps = getDataProps(otherProps),
6460
6484
  dataProps = _getDataProps.dataProps;
6461
6485
  var ref = React__default["default"].useRef(null);
6486
+ var _useProviderConfig = useProviderConfig(),
6487
+ appTheme = _useProviderConfig.theme;
6462
6488
  var background = useContainerBackgroundColorCheck({
6463
6489
  ref: ref,
6464
6490
  // It only needs to check the background when theme is not provided
6465
6491
  shouldCheck: !theme
6466
6492
  });
6467
- // If there is no theme provided, determine it based on the container background
6468
- var currentTheme = theme || (background === 'dark' ? LINK_THEME.CONTRAST : LINK_THEME.PRIMARY);
6493
+ var defaultTheme = LINK_THEME.PRIMARY;
6494
+ // If it is light mode and the background is dark we want to use the contrast theme to make sure the link is visible
6495
+ if (appTheme === 'light' && background === 'dark') {
6496
+ defaultTheme = LINK_THEME.CONTRAST;
6497
+ }
6498
+ var currentTheme = theme || defaultTheme;
6469
6499
  return React__default["default"].createElement("a", _extends({}, dataProps, {
6470
6500
  className: classnames__default["default"](styles$1i['link'], (_classNames = {}, _classNames[styles$1i['link--primary']] = currentTheme === LINK_THEME.PRIMARY, _classNames[styles$1i['link--contrast']] = currentTheme === LINK_THEME.CONTRAST, _classNames)),
6471
6501
  href: href,
@@ -7111,11 +7141,6 @@ var AffixContainer = function AffixContainer(_ref) {
7111
7141
  }, suffix));
7112
7142
  };
7113
7143
 
7114
- var TIME_FORMAT = {
7115
- FORMAT_24H: '24h',
7116
- FORMAT_AMPM: 'ampm'
7117
- };
7118
-
7119
7144
  var TimeFieldInput = function TimeFieldInput(_ref) {
7120
7145
  var inputProps = _ref.inputProps,
7121
7146
  allOtherProps = _ref.allOtherProps,
@@ -8702,19 +8727,34 @@ var ToastContainer = function ToastContainer(_ref3) {
8702
8727
  });
8703
8728
  };
8704
8729
 
8705
- var initialValue$1 = {
8706
- // This country prop is currently used to configure the phone number field
8707
- country: 'US',
8708
- // This timeFormat prop is currently used to configure the time format for time fields
8709
- timeFormat: TIME_FORMAT.FORMAT_AMPM
8710
- };
8711
- var ProviderConfigContext = React.createContext(initialValue$1);
8712
- var useProviderConfig = function useProviderConfig() {
8713
- var context = React.useContext(ProviderConfigContext);
8714
- if (!context) {
8715
- throw Error('The `<SousChefProvider>` is not set. Please wrap your application with `<SousChefProvider>`');
8716
- }
8717
- return context;
8730
+ /**
8731
+ * Don't use this hook directly. This is meant to be used internally by the SousChefProvider
8732
+ * To access the current theme, use the useProviderConfig hook instead
8733
+ */
8734
+ var useTheme = function useTheme() {
8735
+ var _useState = React.useState(function () {
8736
+ var isDark = document.documentElement.classList.contains('theme-dark');
8737
+ return isDark ? 'dark' : 'light';
8738
+ }),
8739
+ theme = _useState[0],
8740
+ setTheme = _useState[1];
8741
+ React.useEffect(function () {
8742
+ var observer = new MutationObserver(function (mutations) {
8743
+ mutations.forEach(function (mutation) {
8744
+ if (mutation.attributeName === 'class') {
8745
+ var isDark = document.documentElement.classList.contains('theme-dark');
8746
+ setTheme(isDark ? 'dark' : 'light');
8747
+ }
8748
+ });
8749
+ });
8750
+ observer.observe(document.documentElement, {
8751
+ attributes: true
8752
+ });
8753
+ return function () {
8754
+ observer.disconnect();
8755
+ };
8756
+ }, []);
8757
+ return theme;
8718
8758
  };
8719
8759
 
8720
8760
  var SousChefProvider = function SousChefProvider(_ref) {
@@ -8725,10 +8765,12 @@ var SousChefProvider = function SousChefProvider(_ref) {
8725
8765
  country = _ref$country === void 0 ? 'US' : _ref$country,
8726
8766
  _ref$timeFormat = _ref.timeFormat,
8727
8767
  timeFormat = _ref$timeFormat === void 0 ? TIME_FORMAT.FORMAT_AMPM : _ref$timeFormat;
8768
+ var theme = useTheme();
8728
8769
  return React__default["default"].createElement(ProviderConfigContext.Provider, {
8729
8770
  value: {
8730
8771
  country: libphonenumberJs.isSupportedCountry(country) ? country : 'US',
8731
- timeFormat: timeFormat
8772
+ timeFormat: timeFormat,
8773
+ theme: theme
8732
8774
  }
8733
8775
  }, React__default["default"].createElement(TranslationsContext.Provider, {
8734
8776
  value: {
@@ -10560,6 +10602,11 @@ var getSelectStyles = function getSelectStyles(_ref) {
10560
10602
  } : 'none'
10561
10603
  });
10562
10604
  },
10605
+ input: function input(base) {
10606
+ return Object.assign({}, base, {
10607
+ color: COLORS['surface-on-color']
10608
+ });
10609
+ },
10563
10610
  indicatorSeparator: function indicatorSeparator() {
10564
10611
  return {
10565
10612
  display: 'none'