@zendeskgarden/react-theming 8.64.0 → 8.66.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/dist/index.cjs.js CHANGED
@@ -12,10 +12,12 @@ var styledComponents = require('styled-components');
12
12
  var containerFocusvisible = require('@zendeskgarden/container-focusvisible');
13
13
  var containerUtilities = require('@zendeskgarden/container-utilities');
14
14
  var polished = require('polished');
15
+ var memoize = require('lodash.memoize');
15
16
 
16
17
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
17
18
 
18
19
  var React__default = /*#__PURE__*/_interopDefault(React);
20
+ var memoize__default = /*#__PURE__*/_interopDefault(memoize);
19
21
 
20
22
  function _extends() {
21
23
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -249,10 +251,12 @@ const palette = {
249
251
  };
250
252
  delete palette.product;
251
253
  const shadowWidths = {
254
+ xs: '1px',
252
255
  sm: '2px',
253
256
  md: '3px'
254
257
  };
255
258
  const shadows = {
259
+ xs: color => `0 0 0 ${shadowWidths.xs} ${color}`,
256
260
  sm: color => `0 0 0 ${shadowWidths.sm} ${color}`,
257
261
  md: color => `0 0 0 ${shadowWidths.md} ${color}`,
258
262
  lg: (offsetY, blurRadius, color) => `0 ${offsetY} ${blurRadius} 0 ${color}`
@@ -364,7 +368,7 @@ const adjust = (color, expected, actual) => {
364
368
  }
365
369
  return color;
366
370
  };
367
- function getColor(hue) {
371
+ const getColor = memoize__default.default(function (hue) {
368
372
  let shade = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_SHADE;
369
373
  let theme = arguments.length > 2 ? arguments[2] : undefined;
370
374
  let transparency = arguments.length > 3 ? arguments[3] : undefined;
@@ -398,7 +402,32 @@ function getColor(hue) {
398
402
  retVal = polished.rgba(retVal, transparency);
399
403
  }
400
404
  return retVal;
401
- }
405
+ }, (hue, shade, theme, transparency) => JSON.stringify({
406
+ hue,
407
+ shade,
408
+ palette: theme?.palette,
409
+ colors: theme?.colors,
410
+ transparency
411
+ }));
412
+
413
+ const getFocusBoxShadow = _ref => {
414
+ let {
415
+ inset = false,
416
+ hue = 'primaryHue',
417
+ shade = DEFAULT_SHADE,
418
+ shadowWidth = 'md',
419
+ spacerWidth = 'xs',
420
+ theme = DEFAULT_THEME
421
+ } = _ref;
422
+ const color = getColor(hue, shade, theme);
423
+ const shadow = theme.shadows[shadowWidth](color);
424
+ if (spacerWidth === null) {
425
+ return `${inset ? 'inset' : ''} ${shadow}`;
426
+ }
427
+ return `
428
+ ${inset ? 'inset' : ''} ${theme.shadows[spacerWidth](theme.colors.background)},
429
+ ${inset ? 'inset' : ''} ${shadow}`;
430
+ };
402
431
 
403
432
  function getLineHeight(height, fontSize) {
404
433
  const [heightValue, heightUnit] = polished.getValueAndUnit(height.toString());
@@ -513,21 +542,36 @@ function arrowStyles(position) {
513
542
  return styledComponents.css(["position:relative;&::before{border-width:inherit;border-style:inherit;border-color:transparent;background-clip:content-box;}&::after{z-index:-1;border:inherit;box-shadow:inherit;}&::before,&::after{position:absolute;transform:rotate(45deg);background-color:inherit;box-sizing:inherit;width:", ";height:", ";content:'';}", ";", ";"], squareSize, squareSize, positionStyles(position, squareSize, inset), options.animationModifier && animationStyles$1(position, options.animationModifier));
514
543
  }
515
544
 
516
- const useText = (component, props, name, text) => {
517
- const value = props[name];
545
+ const useWindow = theme => {
546
+ const [controlledWindow, setControlledWindow] = React.useState();
547
+ React.useEffect(() => {
548
+ if (theme && theme.window) {
549
+ setControlledWindow(theme.window);
550
+ } else {
551
+ setControlledWindow(window);
552
+ }
553
+ }, [theme]);
554
+ return controlledWindow;
555
+ };
556
+
557
+ const useText = function (component, props, name, text) {
558
+ let condition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
559
+ const value = condition ? props[name] : undefined;
518
560
  return React.useMemo(() => {
519
- if (name === 'children') {
520
- throw new Error('Error: `children` is not a valid `getText` prop.');
521
- } else if (value === null || value === '') {
522
- throw new Error(component.displayName ? `Error: you must provide a valid \`${name}\` text value for <${component.displayName}>.` : `Error: you must provide a valid \`${name}\` text value.`);
523
- } else if (value === undefined) {
524
- if (process.env.NODE_ENV === 'development') {
525
- console.warn(component.displayName ? `Warning: you did not provide a customized/translated \`${name}\` text value for <${component.displayName}>. Zendesk Garden is rendering <${component.displayName} ${name}="${text}"> by default.` : `Warning: you did not provide a customized/translated \`${name}\` text value. Zendesk Garden is rendering ${name}="${text}" by default.`);
561
+ if (condition) {
562
+ if (name === 'children') {
563
+ throw new Error('Error: `children` is not a valid `useText` prop.');
564
+ } else if (value === null || value === '') {
565
+ throw new Error(component.displayName ? `Error: you must provide a valid \`${name}\` text value for <${component.displayName}>.` : `Error: you must provide a valid \`${name}\` text value.`);
566
+ } else if (value === undefined) {
567
+ if (process.env.NODE_ENV === 'development') {
568
+ console.warn(component.displayName ? `Warning: you did not provide a customized/translated \`${name}\` text value for <${component.displayName}>. Zendesk Garden is rendering <${component.displayName} ${name}="${text}"> by default.` : `Warning: you did not provide a customized/translated \`${name}\` text value. Zendesk Garden is rendering ${name}="${text}" by default.`);
569
+ }
570
+ return text;
526
571
  }
527
- return text;
528
572
  }
529
573
  return value;
530
- }, [component.displayName, value, name, text]);
574
+ }, [component.displayName, value, name, text, condition]);
531
575
  };
532
576
 
533
577
  const animationStyles = (position, options) => {
@@ -568,6 +612,34 @@ function menuStyles(position) {
568
612
  return styledComponents.css(["position:absolute;z-index:", ";", ":", ";line-height:0;font-size:0.01px;& ", "{display:inline-block;position:relative;margin:0;box-sizing:border-box;border:", " ", ";border-radius:", ";box-shadow:", ";background-color:", ";cursor:default;padding:0;text-align:", ";white-space:normal;font-size:", ";font-weight:", ";direction:", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, options.childSelector || '> *', theme.borders.sm, getColor('neutralHue', 300, theme), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColor('chromeHue', 600, theme, 0.15)), theme.colors.background, theme.rtl ? 'right' : 'left', theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
569
613
  }
570
614
 
615
+ const SELECTOR_FOCUS_VISIBLE = '&:focus-visible, &[data-garden-focus-visible="true"]';
616
+ const focusStyles = _ref => {
617
+ let {
618
+ condition = true,
619
+ selector = SELECTOR_FOCUS_VISIBLE,
620
+ shadowWidth = 'md',
621
+ spacerWidth = 'xs',
622
+ styles,
623
+ theme,
624
+ ...options
625
+ } = _ref;
626
+ const boxShadow = condition ? getFocusBoxShadow({
627
+ shadowWidth,
628
+ spacerWidth,
629
+ theme,
630
+ ...options
631
+ }) : undefined;
632
+ let outline;
633
+ let outlineOffset;
634
+ if (spacerWidth === null) {
635
+ outline = theme.shadowWidths[shadowWidth];
636
+ } else {
637
+ outline = `${polished.math(`${theme.shadowWidths[shadowWidth]} - ${theme.shadowWidths[spacerWidth]}`)} solid transparent`;
638
+ outlineOffset = theme.shadowWidths[spacerWidth];
639
+ }
640
+ return styledComponents.css(["&:focus{outline:none;}", "{outline:", ";outline-offset:", ";box-shadow:", ";", "}"], selector, outline, outlineOffset, boxShadow, styles);
641
+ };
642
+
571
643
  const ARROW_POSITION = ['top', 'top-left', 'top-right', 'right', 'right-top', 'right-bottom', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom'];
572
644
  const MENU_POSITION = ['top', 'right', 'bottom', 'left'];
573
645
 
@@ -575,10 +647,13 @@ exports.ARRAY_ARROW_POSITION = ARROW_POSITION;
575
647
  exports.ARRAY_MENU_POSITION = MENU_POSITION;
576
648
  exports.DEFAULT_THEME = DEFAULT_THEME;
577
649
  exports.PALETTE = PALETTE;
650
+ exports.SELECTOR_FOCUS_VISIBLE = SELECTOR_FOCUS_VISIBLE;
578
651
  exports.ThemeProvider = ThemeProvider;
579
652
  exports.arrowStyles = arrowStyles;
653
+ exports.focusStyles = focusStyles;
580
654
  exports.getColor = getColor;
581
655
  exports.getDocument = getDocument;
656
+ exports.getFocusBoxShadow = getFocusBoxShadow;
582
657
  exports.getLineHeight = getLineHeight;
583
658
  exports.isRtl = isRtl;
584
659
  exports.mediaQuery = mediaQuery;
@@ -587,4 +662,5 @@ exports.retrieveComponentStyles = retrieveComponentStyles;
587
662
  exports.retrieveTheme = retrieveComponentStyles;
588
663
  exports.useDocument = useDocument;
589
664
  exports.useText = useText;
665
+ exports.useWindow = useWindow;
590
666
  exports.withTheme = withTheme;
package/dist/index.esm.js CHANGED
@@ -10,6 +10,7 @@ import { ThemeProvider as ThemeProvider$1, withTheme as withTheme$1, css, keyfra
10
10
  import { useFocusVisible } from '@zendeskgarden/container-focusvisible';
11
11
  import { getControlledValue } from '@zendeskgarden/container-utilities';
12
12
  import { rgba, darken, lighten, getValueAndUnit, math } from 'polished';
13
+ import memoize from 'lodash.memoize';
13
14
 
14
15
  function _extends() {
15
16
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -243,10 +244,12 @@ const palette = {
243
244
  };
244
245
  delete palette.product;
245
246
  const shadowWidths = {
247
+ xs: '1px',
246
248
  sm: '2px',
247
249
  md: '3px'
248
250
  };
249
251
  const shadows = {
252
+ xs: color => `0 0 0 ${shadowWidths.xs} ${color}`,
250
253
  sm: color => `0 0 0 ${shadowWidths.sm} ${color}`,
251
254
  md: color => `0 0 0 ${shadowWidths.md} ${color}`,
252
255
  lg: (offsetY, blurRadius, color) => `0 ${offsetY} ${blurRadius} 0 ${color}`
@@ -358,7 +361,7 @@ const adjust = (color, expected, actual) => {
358
361
  }
359
362
  return color;
360
363
  };
361
- function getColor(hue) {
364
+ const getColor = memoize(function (hue) {
362
365
  let shade = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_SHADE;
363
366
  let theme = arguments.length > 2 ? arguments[2] : undefined;
364
367
  let transparency = arguments.length > 3 ? arguments[3] : undefined;
@@ -392,7 +395,32 @@ function getColor(hue) {
392
395
  retVal = rgba(retVal, transparency);
393
396
  }
394
397
  return retVal;
395
- }
398
+ }, (hue, shade, theme, transparency) => JSON.stringify({
399
+ hue,
400
+ shade,
401
+ palette: theme?.palette,
402
+ colors: theme?.colors,
403
+ transparency
404
+ }));
405
+
406
+ const getFocusBoxShadow = _ref => {
407
+ let {
408
+ inset = false,
409
+ hue = 'primaryHue',
410
+ shade = DEFAULT_SHADE,
411
+ shadowWidth = 'md',
412
+ spacerWidth = 'xs',
413
+ theme = DEFAULT_THEME
414
+ } = _ref;
415
+ const color = getColor(hue, shade, theme);
416
+ const shadow = theme.shadows[shadowWidth](color);
417
+ if (spacerWidth === null) {
418
+ return `${inset ? 'inset' : ''} ${shadow}`;
419
+ }
420
+ return `
421
+ ${inset ? 'inset' : ''} ${theme.shadows[spacerWidth](theme.colors.background)},
422
+ ${inset ? 'inset' : ''} ${shadow}`;
423
+ };
396
424
 
397
425
  function getLineHeight(height, fontSize) {
398
426
  const [heightValue, heightUnit] = getValueAndUnit(height.toString());
@@ -507,21 +535,36 @@ function arrowStyles(position) {
507
535
  return css(["position:relative;&::before{border-width:inherit;border-style:inherit;border-color:transparent;background-clip:content-box;}&::after{z-index:-1;border:inherit;box-shadow:inherit;}&::before,&::after{position:absolute;transform:rotate(45deg);background-color:inherit;box-sizing:inherit;width:", ";height:", ";content:'';}", ";", ";"], squareSize, squareSize, positionStyles(position, squareSize, inset), options.animationModifier && animationStyles$1(position, options.animationModifier));
508
536
  }
509
537
 
510
- const useText = (component, props, name, text) => {
511
- const value = props[name];
538
+ const useWindow = theme => {
539
+ const [controlledWindow, setControlledWindow] = useState();
540
+ useEffect(() => {
541
+ if (theme && theme.window) {
542
+ setControlledWindow(theme.window);
543
+ } else {
544
+ setControlledWindow(window);
545
+ }
546
+ }, [theme]);
547
+ return controlledWindow;
548
+ };
549
+
550
+ const useText = function (component, props, name, text) {
551
+ let condition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
552
+ const value = condition ? props[name] : undefined;
512
553
  return useMemo(() => {
513
- if (name === 'children') {
514
- throw new Error('Error: `children` is not a valid `getText` prop.');
515
- } else if (value === null || value === '') {
516
- throw new Error(component.displayName ? `Error: you must provide a valid \`${name}\` text value for <${component.displayName}>.` : `Error: you must provide a valid \`${name}\` text value.`);
517
- } else if (value === undefined) {
518
- if (process.env.NODE_ENV === 'development') {
519
- console.warn(component.displayName ? `Warning: you did not provide a customized/translated \`${name}\` text value for <${component.displayName}>. Zendesk Garden is rendering <${component.displayName} ${name}="${text}"> by default.` : `Warning: you did not provide a customized/translated \`${name}\` text value. Zendesk Garden is rendering ${name}="${text}" by default.`);
554
+ if (condition) {
555
+ if (name === 'children') {
556
+ throw new Error('Error: `children` is not a valid `useText` prop.');
557
+ } else if (value === null || value === '') {
558
+ throw new Error(component.displayName ? `Error: you must provide a valid \`${name}\` text value for <${component.displayName}>.` : `Error: you must provide a valid \`${name}\` text value.`);
559
+ } else if (value === undefined) {
560
+ if (process.env.NODE_ENV === 'development') {
561
+ console.warn(component.displayName ? `Warning: you did not provide a customized/translated \`${name}\` text value for <${component.displayName}>. Zendesk Garden is rendering <${component.displayName} ${name}="${text}"> by default.` : `Warning: you did not provide a customized/translated \`${name}\` text value. Zendesk Garden is rendering ${name}="${text}" by default.`);
562
+ }
563
+ return text;
520
564
  }
521
- return text;
522
565
  }
523
566
  return value;
524
- }, [component.displayName, value, name, text]);
567
+ }, [component.displayName, value, name, text, condition]);
525
568
  };
526
569
 
527
570
  const animationStyles = (position, options) => {
@@ -562,7 +605,35 @@ function menuStyles(position) {
562
605
  return css(["position:absolute;z-index:", ";", ":", ";line-height:0;font-size:0.01px;& ", "{display:inline-block;position:relative;margin:0;box-sizing:border-box;border:", " ", ";border-radius:", ";box-shadow:", ";background-color:", ";cursor:default;padding:0;text-align:", ";white-space:normal;font-size:", ";font-weight:", ";direction:", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, options.childSelector || '> *', theme.borders.sm, getColor('neutralHue', 300, theme), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColor('chromeHue', 600, theme, 0.15)), theme.colors.background, theme.rtl ? 'right' : 'left', theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
563
606
  }
564
607
 
608
+ const SELECTOR_FOCUS_VISIBLE = '&:focus-visible, &[data-garden-focus-visible="true"]';
609
+ const focusStyles = _ref => {
610
+ let {
611
+ condition = true,
612
+ selector = SELECTOR_FOCUS_VISIBLE,
613
+ shadowWidth = 'md',
614
+ spacerWidth = 'xs',
615
+ styles,
616
+ theme,
617
+ ...options
618
+ } = _ref;
619
+ const boxShadow = condition ? getFocusBoxShadow({
620
+ shadowWidth,
621
+ spacerWidth,
622
+ theme,
623
+ ...options
624
+ }) : undefined;
625
+ let outline;
626
+ let outlineOffset;
627
+ if (spacerWidth === null) {
628
+ outline = theme.shadowWidths[shadowWidth];
629
+ } else {
630
+ outline = `${math(`${theme.shadowWidths[shadowWidth]} - ${theme.shadowWidths[spacerWidth]}`)} solid transparent`;
631
+ outlineOffset = theme.shadowWidths[spacerWidth];
632
+ }
633
+ return css(["&:focus{outline:none;}", "{outline:", ";outline-offset:", ";box-shadow:", ";", "}"], selector, outline, outlineOffset, boxShadow, styles);
634
+ };
635
+
565
636
  const ARROW_POSITION = ['top', 'top-left', 'top-right', 'right', 'right-top', 'right-bottom', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom'];
566
637
  const MENU_POSITION = ['top', 'right', 'bottom', 'left'];
567
638
 
568
- export { ARROW_POSITION as ARRAY_ARROW_POSITION, MENU_POSITION as ARRAY_MENU_POSITION, DEFAULT_THEME, PALETTE, ThemeProvider, arrowStyles, getColor, getDocument, getLineHeight, isRtl, mediaQuery, menuStyles, retrieveComponentStyles, retrieveComponentStyles as retrieveTheme, useDocument, useText, withTheme };
639
+ export { ARROW_POSITION as ARRAY_ARROW_POSITION, MENU_POSITION as ARRAY_MENU_POSITION, DEFAULT_THEME, PALETTE, SELECTOR_FOCUS_VISIBLE, ThemeProvider, arrowStyles, focusStyles, getColor, getDocument, getFocusBoxShadow, getLineHeight, isRtl, mediaQuery, menuStyles, retrieveComponentStyles, retrieveComponentStyles as retrieveTheme, useDocument, useText, useWindow, withTheme };
@@ -13,12 +13,15 @@ export { default as retrieveComponentStyles,
13
13
  default as retrieveTheme } from './utils/retrieveComponentStyles';
14
14
  export { default as withTheme } from './utils/withTheme';
15
15
  export { default as getDocument } from './utils/getDocument';
16
- export { default as getColor } from './utils/getColor';
16
+ export { getColor } from './utils/getColor';
17
+ export { getFocusBoxShadow } from './utils/getFocusBoxShadow';
17
18
  export { default as getLineHeight } from './utils/getLineHeight';
18
19
  export { default as mediaQuery } from './utils/mediaQuery';
19
20
  export { default as arrowStyles } from './utils/arrowStyles';
20
21
  export { useDocument } from './utils/useDocument';
22
+ export { useWindow } from './utils/useWindow';
21
23
  export { useText } from './utils/useText';
22
24
  export { default as menuStyles } from './utils/menuStyles';
25
+ export { focusStyles, SELECTOR_FOCUS_VISIBLE } from './utils/focusStyles';
23
26
  export { ARROW_POSITION as ARRAY_ARROW_POSITION, MENU_POSITION as ARRAY_MENU_POSITION } from './types';
24
27
  export type { IGardenTheme, IThemeProviderProps, ArrowPosition as ARROW_POSITION, MenuPosition as MENU_POSITION } from './types';
@@ -13,6 +13,7 @@ type Hue = Record<number | string, string> | string;
13
13
  export interface IGardenTheme {
14
14
  rtl: boolean;
15
15
  document?: any;
16
+ window?: any;
16
17
  borders: {
17
18
  sm: string;
18
19
  md: string;
@@ -85,10 +86,12 @@ export interface IGardenTheme {
85
86
  xxxl: string;
86
87
  };
87
88
  shadowWidths: {
89
+ xs: string;
88
90
  sm: string;
89
91
  md: string;
90
92
  };
91
93
  shadows: {
94
+ xs: (color: string) => string;
92
95
  sm: (color: string) => string;
93
96
  md: (color: string) => string;
94
97
  lg: (offsetY: string, blurRadius: string, color: string) => string;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { CSSObject } from 'styled-components';
8
+ import { FocusBoxShadowParameters } from './getFocusBoxShadow';
9
+ export declare const SELECTOR_FOCUS_VISIBLE = "&:focus-visible, &[data-garden-focus-visible=\"true\"]";
10
+ type FocusStylesParameters = FocusBoxShadowParameters & {
11
+ condition?: boolean;
12
+ selector?: string;
13
+ styles?: CSSObject;
14
+ };
15
+ /**
16
+ * Garden standard `box-shadow` focus styling.
17
+ *
18
+ * @param {boolean} [options.condition=true] Supplies an optional condition that can be used to prevent the focus `box-shadow`
19
+ * @param {boolean} [options.inset=false] Determines whether the `box-shadow` is inset
20
+ * @param {string|Object} [options.hue='primaryHue'] Provides a theme object `palette` hue or `color` key, or any valid CSS color notation
21
+ * @param {string} [options.selector=SELECTOR_FOCUS_VISIBLE] Provides a subsitute `:focus-visible` pseudo-class CSS selector.
22
+ * @param {number} [options.shade=600] Selects a shade for the given hue
23
+ * @param {string} [options.shadowWidth='md'] Provides a theme object `shadowWidth` key for the cumulative width of the `box-shadow`
24
+ * @param {string} [options.spacerWidth='xs'] Provides a theme object `shadowWidth` for the white spacer, or `null` to remove
25
+ * @param {Object} [options.styles] Adds CSS property values to be rendered with `:focus-visible`
26
+ * @param {Object} options.theme Provides values used to resolve the desired color
27
+ *
28
+ * @returns CSS structured as follows, with `{values}` determined by the options provided:
29
+ * ```css
30
+ * :focus {
31
+ * outline: none;
32
+ * }
33
+ *
34
+ * :focus-visible,
35
+ * [data-garden-focus-visible='true'] {
36
+ * box-shadow: 0 0 0 {1px} #fff,
37
+ * 0 0 0 {3px} {blue};
38
+ * outline: {2px} solid transparent;
39
+ * outline-offset: {1px};
40
+ * // additional {styles} here...
41
+ * }
42
+ * ```
43
+ */
44
+ export declare const focusStyles: ({ condition, selector, shadowWidth, spacerWidth, styles, theme, ...options }: FocusStylesParameters) => import("styled-components").FlattenSimpleInterpolation;
45
+ export {};
@@ -4,8 +4,10 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
+ /// <reference types="lodash" />
7
8
  import { DefaultTheme } from 'styled-components';
8
- type Hue = Record<number | string, string> | string;
9
+ export type Hue = Record<number | string, string> | string;
10
+ export declare const DEFAULT_SHADE = 600;
9
11
  /**
10
12
  * Get the palette color for the given hue, shade, and theme.
11
13
  *
@@ -19,8 +21,5 @@ type Hue = Record<number | string, string> | string;
19
21
  * @param {number} [shade=DEFAULT_SHADE] A hue shade.
20
22
  * @param {Object} theme Context `theme` object.
21
23
  * @param {Number} [transparency] An alpha-channel value between 0 and 1.
22
- *
23
- * @component
24
24
  */
25
- export default function getColor(hue: Hue, shade?: number, theme?: DefaultTheme, transparency?: number): string | undefined;
26
- export {};
25
+ export declare const getColor: ((hue: Hue, shade?: number, theme?: DefaultTheme, transparency?: number) => string | undefined) & import("lodash").MemoizedFunction;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { IGardenTheme } from '../types';
8
+ import { Hue } from './getColor';
9
+ export type FocusBoxShadowParameters = {
10
+ inset?: boolean;
11
+ hue?: Hue;
12
+ shade?: number;
13
+ shadowWidth?: 'sm' | 'md';
14
+ spacerWidth?: null | 'xs' | 'sm';
15
+ theme: IGardenTheme;
16
+ };
17
+ /**
18
+ * Get a CSS `box-shadow` property value for focus state styling. The `hue` and
19
+ * `shade` are used to determine the color of the focus ring.
20
+ *
21
+ * @param {boolean} [options.inset=false] Determines whether the `box-shadow` is inset
22
+ * @param {string|Object} [options.hue='primaryHue'] Provides a theme object `palette` hue or `color` key, or any valid CSS color notation
23
+ * @param {number} [options.shade=600] Selects a shade for the given hue
24
+ * @param {string} [options.shadowWidth='md'] Provides a theme object `shadowWidth` key for the cumulative width of the `box-shadow`
25
+ * @param {string} [options.spacerWidth='xs'] Provides a theme object `shadowWidth` for the white spacer, or `null` to remove
26
+ * @param {Object} options.theme Provides values used to resolve the desired color
27
+ *
28
+ * @returns A `box-shadow` property value for the given options. Default is a
29
+ * 3px `blue[600]` ring with a 1px white spacer overlay.
30
+ */
31
+ export declare const getFocusBoxShadow: ({ inset, hue, shade, shadowWidth, spacerWidth, theme }: FocusBoxShadowParameters) => string;
@@ -14,5 +14,6 @@ import { FC } from 'react';
14
14
  * @param props The component props to check for `name`
15
15
  * @param name The name of the component prop to set default text on
16
16
  * @param text The default text to apply if the value of `props[name]` is undefined
17
+ * @param condition An optional condition that can be used to prevent evaluation
17
18
  */
18
- export declare const useText: (component: Pick<FC, 'displayName'>, props: Record<string, any>, name: string, text: string) => string;
19
+ export declare const useText: (component: Pick<FC, 'displayName'>, props: Record<string, any>, name: string, text: string, condition?: boolean) => string | undefined;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { DefaultTheme } from 'styled-components';
8
+ export declare const useWindow: (theme?: Partial<DefaultTheme>) => Window | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-theming",
3
- "version": "8.64.0",
3
+ "version": "8.66.0",
4
4
  "description": "Theming utilities and components within the Garden Design System",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Zendesk Garden <garden@zendesk.com>",
@@ -23,6 +23,7 @@
23
23
  "dependencies": {
24
24
  "@zendeskgarden/container-focusvisible": "^1.0.0",
25
25
  "@zendeskgarden/container-utilities": "^1.0.0",
26
+ "lodash.memoize": "^4.1.2",
26
27
  "polished": "^4.0.0",
27
28
  "prop-types": "^15.5.7"
28
29
  },
@@ -31,6 +32,9 @@
31
32
  "react-dom": ">=16.8.0",
32
33
  "styled-components": "^4.2.0 || ^5.0.0"
33
34
  },
35
+ "devDependencies": {
36
+ "@types/lodash.memoize": "4.1.7"
37
+ },
34
38
  "keywords": [
35
39
  "components",
36
40
  "garden",
@@ -41,5 +45,5 @@
41
45
  "access": "public"
42
46
  },
43
47
  "zendeskgarden:src": "src/index.ts",
44
- "gitHead": "c0cfa3666c7a2e72ec8a9e0af8d530bb3312da86"
48
+ "gitHead": "40df9b49f68b69878186a66e9c14efb00eca051f"
45
49
  }