@zendeskgarden/react-theming 9.3.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/componentStyles.js +21 -0
- package/dist/esm/utils/retrieveComponentStyles.js +1 -1
- package/dist/index.cjs.js +16 -1
- package/dist/typings/index.d.ts +1 -0
- package/dist/typings/utils/componentStyles.d.ts +20 -0
- package/dist/typings/utils/retrieveComponentStyles.d.ts +5 -3
- package/package.json +2 -2
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';
|
|
@@ -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',
|
|
@@ -1480,6 +1494,7 @@ exports.SELECTOR_FOCUS_VISIBLE = SELECTOR_FOCUS_VISIBLE;
|
|
|
1480
1494
|
exports.StyledBaseIcon = StyledBaseIcon;
|
|
1481
1495
|
exports.ThemeProvider = ThemeProvider;
|
|
1482
1496
|
exports.arrowStyles = arrowStyles;
|
|
1497
|
+
exports.componentStyles = componentStyles;
|
|
1483
1498
|
exports.focusStyles = focusStyles;
|
|
1484
1499
|
exports.getArrowPosition = getArrowPosition;
|
|
1485
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';
|
|
@@ -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;
|
|
@@ -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>",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"zendeskgarden:src": "src/index.ts",
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "02e3f240b6f0c776fdae785254d6fe90cbfc37e4"
|
|
51
51
|
}
|