@zendeskgarden/react-theming 9.2.0 → 9.4.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/esm/index.js +1 -0
- package/dist/esm/utils/StyledBaseIcon.js +4 -3
- package/dist/esm/utils/componentStyles.js +21 -0
- package/dist/esm/utils/retrieveComponentStyles.js +1 -1
- package/dist/index.cjs.js +19 -3
- package/dist/typings/index.d.ts +2 -1
- package/dist/typings/types/index.d.ts +5 -1
- package/dist/typings/utils/StyledBaseIcon.d.ts +3 -2
- package/dist/typings/utils/arrowStyles.d.ts +1 -1
- package/dist/typings/utils/componentStyles.d.ts +20 -0
- package/dist/typings/utils/focusStyles.d.ts +1 -1
- package/dist/typings/utils/menuStyles.d.ts +1 -1
- package/dist/typings/utils/retrieveComponentStyles.d.ts +5 -3
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { ThemeProvider } from './elements/ThemeProvider.js';
|
|
|
8
8
|
export { default as DEFAULT_THEME } from './elements/theme/index.js';
|
|
9
9
|
export { default as PALETTE } from './elements/palette/index.js';
|
|
10
10
|
export { default as retrieveComponentStyles } from './utils/retrieveComponentStyles.js';
|
|
11
|
+
export { componentStyles } from './utils/componentStyles.js';
|
|
11
12
|
export { getArrowPosition } from './utils/getArrowPosition.js';
|
|
12
13
|
export { getCheckeredBackground } from './utils/getCheckeredBackground.js';
|
|
13
14
|
export { getColor } from './utils/getColor.js';
|
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
import styled from 'styled-components';
|
|
8
|
-
import
|
|
8
|
+
import { cloneElement, Children } from 'react';
|
|
9
9
|
|
|
10
|
-
const StyledBaseIcon = styled(
|
|
10
|
+
const StyledBaseIcon = styled(
|
|
11
|
+
_ref => {
|
|
11
12
|
let {
|
|
12
13
|
children,
|
|
13
14
|
theme,
|
|
14
15
|
...props
|
|
15
16
|
} = _ref;
|
|
16
|
-
return
|
|
17
|
+
return cloneElement(Children.only(children), props);
|
|
17
18
|
}).withConfig({
|
|
18
19
|
displayName: "StyledBaseIcon",
|
|
19
20
|
componentId: "sc-1moykgb-0"
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
const componentStyles = props => {
|
|
8
|
+
let retVal;
|
|
9
|
+
const components = props.theme.components;
|
|
10
|
+
const componentId = props.componentId || props['data-garden-id'];
|
|
11
|
+
if (components && componentId) {
|
|
12
|
+
retVal = components[componentId];
|
|
13
|
+
if (typeof retVal === 'function') {
|
|
14
|
+
const fn = retVal;
|
|
15
|
+
retVal = fn(props);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return retVal;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { componentStyles };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
function retrieveComponentStyles(componentId, props) {
|
|
8
|
-
const components = props.theme
|
|
8
|
+
const components = props.theme?.components;
|
|
9
9
|
if (!components) {
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
package/dist/index.cjs.js
CHANGED
|
@@ -512,7 +512,7 @@ const ThemeProvider = _ref => {
|
|
|
512
512
|
};
|
|
513
513
|
|
|
514
514
|
function retrieveComponentStyles(componentId, props) {
|
|
515
|
-
const components = props.theme
|
|
515
|
+
const components = props.theme?.components;
|
|
516
516
|
if (!components) {
|
|
517
517
|
return undefined;
|
|
518
518
|
}
|
|
@@ -523,6 +523,20 @@ function retrieveComponentStyles(componentId, props) {
|
|
|
523
523
|
return componentStyles;
|
|
524
524
|
}
|
|
525
525
|
|
|
526
|
+
const componentStyles = props => {
|
|
527
|
+
let retVal;
|
|
528
|
+
const components = props.theme.components;
|
|
529
|
+
const componentId = props.componentId || props['data-garden-id'];
|
|
530
|
+
if (components && componentId) {
|
|
531
|
+
retVal = components[componentId];
|
|
532
|
+
if (typeof retVal === 'function') {
|
|
533
|
+
const fn = retVal;
|
|
534
|
+
retVal = fn(props);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return retVal;
|
|
538
|
+
};
|
|
539
|
+
|
|
526
540
|
const POSITION_MAP = {
|
|
527
541
|
top: 'bottom',
|
|
528
542
|
'top-start': 'bottom-left',
|
|
@@ -1454,13 +1468,14 @@ const focusStyles = _ref => {
|
|
|
1454
1468
|
return styled.css(["&:focus{outline:none;}", "{outline:", ";outline-offset:", ";box-shadow:", ";", "}"], selector, outline, outlineOffset, _boxShadow, styles);
|
|
1455
1469
|
};
|
|
1456
1470
|
|
|
1457
|
-
const StyledBaseIcon = styled__default.default(
|
|
1471
|
+
const StyledBaseIcon = styled__default.default(
|
|
1472
|
+
_ref => {
|
|
1458
1473
|
let {
|
|
1459
1474
|
children,
|
|
1460
1475
|
theme,
|
|
1461
1476
|
...props
|
|
1462
1477
|
} = _ref;
|
|
1463
|
-
return
|
|
1478
|
+
return React.cloneElement(React.Children.only(children), props);
|
|
1464
1479
|
}).withConfig({
|
|
1465
1480
|
displayName: "StyledBaseIcon",
|
|
1466
1481
|
componentId: "sc-1moykgb-0"
|
|
@@ -1479,6 +1494,7 @@ exports.SELECTOR_FOCUS_VISIBLE = SELECTOR_FOCUS_VISIBLE;
|
|
|
1479
1494
|
exports.StyledBaseIcon = StyledBaseIcon;
|
|
1480
1495
|
exports.ThemeProvider = ThemeProvider;
|
|
1481
1496
|
exports.arrowStyles = arrowStyles;
|
|
1497
|
+
exports.componentStyles = componentStyles;
|
|
1482
1498
|
exports.focusStyles = focusStyles;
|
|
1483
1499
|
exports.getArrowPosition = getArrowPosition;
|
|
1484
1500
|
exports.getCheckeredBackground = getCheckeredBackground;
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { ThemeProvider } from './elements/ThemeProvider';
|
|
|
8
8
|
export { default as DEFAULT_THEME } from './elements/theme';
|
|
9
9
|
export { default as PALETTE } from './elements/palette';
|
|
10
10
|
export { default as retrieveComponentStyles } from './utils/retrieveComponentStyles';
|
|
11
|
+
export { componentStyles } from './utils/componentStyles';
|
|
11
12
|
export { getArrowPosition } from './utils/getArrowPosition';
|
|
12
13
|
export { getCheckeredBackground } from './utils/getCheckeredBackground';
|
|
13
14
|
export { getColor } from './utils/getColor';
|
|
@@ -24,4 +25,4 @@ export { useText } from './utils/useText';
|
|
|
24
25
|
export { default as menuStyles } from './utils/menuStyles';
|
|
25
26
|
export { focusStyles, SELECTOR_FOCUS_VISIBLE } from './utils/focusStyles';
|
|
26
27
|
export { StyledBaseIcon } from './utils/StyledBaseIcon';
|
|
27
|
-
export { ARROW_POSITION, MENU_POSITION, PLACEMENT, type IGardenTheme, type IThemeProviderProps, type ArrowPosition, type CheckeredBackgroundParameters, type ColorParameters, type FocusBoxShadowParameters, type FocusStylesParameters, type MenuPosition, type Placement } from './types';
|
|
28
|
+
export { ARROW_POSITION, MENU_POSITION, PLACEMENT, type IGardenTheme, type IStyledBaseIconProps, type IThemeProviderProps, type ArrowPosition, type CheckeredBackgroundParameters, type ColorParameters, type FocusBoxShadowParameters, type FocusStylesParameters, type MenuPosition, type Placement } from './types';
|
|
@@ -4,7 +4,8 @@
|
|
|
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
|
-
import {
|
|
7
|
+
import { PropsWithChildren, SVGAttributes } from 'react';
|
|
8
|
+
import { CSSObject, DefaultTheme, ThemeProviderProps } from 'styled-components';
|
|
8
9
|
export declare const ARROW_POSITION: readonly ["top", "top-left", "top-right", "right", "right-top", "right-bottom", "bottom", "bottom-left", "bottom-right", "left", "left-top", "left-bottom"];
|
|
9
10
|
export type ArrowPosition = (typeof ARROW_POSITION)[number];
|
|
10
11
|
export declare const MENU_POSITION: readonly ["top", "right", "bottom", "left"];
|
|
@@ -172,3 +173,6 @@ export interface IThemeProviderProps extends Partial<ThemeProviderProps<IGardenT
|
|
|
172
173
|
*/
|
|
173
174
|
theme?: IGardenTheme | ((theme: IGardenTheme) => IGardenTheme);
|
|
174
175
|
}
|
|
176
|
+
export interface IStyledBaseIconProps extends PropsWithChildren<SVGAttributes<SVGElement>> {
|
|
177
|
+
theme?: DefaultTheme;
|
|
178
|
+
}
|
|
@@ -4,5 +4,6 @@
|
|
|
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
|
-
import
|
|
8
|
-
|
|
7
|
+
import { ReactElement } from 'react';
|
|
8
|
+
import { IStyledBaseIconProps } from '../types';
|
|
9
|
+
export declare const StyledBaseIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<IStyledBaseIconProps, never>> & string & Omit<({ children, theme, ...props }: IStyledBaseIconProps) => ReactElement<any, string | import("react").JSXElementConstructor<any>>, keyof import("react").Component<any, {}, any>>;
|
|
@@ -45,5 +45,5 @@ type ArrowOptions = {
|
|
|
45
45
|
*
|
|
46
46
|
* @component
|
|
47
47
|
*/
|
|
48
|
-
export default function arrowStyles(position: ArrowPosition, options?: ArrowOptions): import("styled-components").
|
|
48
|
+
export default function arrowStyles(position: ArrowPosition, options?: ArrowOptions): import("styled-components").RuleSet<object>;
|
|
49
49
|
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* CSS for component customizations based on `theme.components[componentId]`.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} props.theme Provides `components` object use to resolve the given component ID
|
|
12
|
+
* @param {String} [props.componentId] Specifies the lookup id for * `theme.components` styles.
|
|
13
|
+
* The ID will be inferred from the `'data-garden-id'` attribute if not provided.
|
|
14
|
+
*
|
|
15
|
+
* @returns component CSS styles
|
|
16
|
+
*/
|
|
17
|
+
export declare const componentStyles: (props: {
|
|
18
|
+
theme: DefaultTheme;
|
|
19
|
+
componentId?: string;
|
|
20
|
+
}) => string | undefined;
|
|
@@ -36,4 +36,4 @@ export declare const SELECTOR_FOCUS_VISIBLE = "&:focus-visible";
|
|
|
36
36
|
* }
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
export declare const focusStyles: ({ condition, selector, shadowWidth, spacerWidth, styles: { boxShadow, ...styles }, theme, ...options }: FocusStylesParameters) => import("styled-components").
|
|
39
|
+
export declare const focusStyles: ({ condition, selector, shadowWidth, spacerWidth, styles: { boxShadow, ...styles }, theme, ...options }: FocusStylesParameters) => import("styled-components").RuleSet<object>;
|
|
@@ -33,5 +33,5 @@ type MenuOptions = {
|
|
|
33
33
|
* @param {string} [options.animationModifier] A CSS class or attribute selector
|
|
34
34
|
* which, when applied, animates the menu's appearance.
|
|
35
35
|
*/
|
|
36
|
-
export default function menuStyles(position: MenuPosition, options?: MenuOptions): import("styled-components").
|
|
36
|
+
export default function menuStyles(position: MenuPosition, options?: MenuOptions): import("styled-components").RuleSet<object>;
|
|
37
37
|
export {};
|
|
@@ -4,6 +4,8 @@
|
|
|
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
|
-
import {
|
|
8
|
-
/** @
|
|
9
|
-
export default function retrieveComponentStyles(componentId: string, props:
|
|
7
|
+
import { DefaultTheme } from 'styled-components';
|
|
8
|
+
/** @deprecated Use `componentStyles` instead. */
|
|
9
|
+
export default function retrieveComponentStyles(componentId: string, props: {
|
|
10
|
+
theme?: Partial<DefaultTheme>;
|
|
11
|
+
}): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-theming",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.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>",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
33
33
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
34
|
-
"styled-components": "^4.2.0 || ^5.3.1"
|
|
34
|
+
"styled-components": "^4.2.0 || ^5.3.1 || ^6.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/lodash.get": "4.4.9",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"zendeskgarden:src": "src/index.ts",
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "02e3f240b6f0c776fdae785254d6fe90cbfc37e4"
|
|
51
51
|
}
|