@zendeskgarden/react-theming 8.51.0 → 8.53.1
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 +21 -0
- package/dist/index.esm.js +21 -1
- package/dist/typings/index.d.ts +1 -0
- package/dist/typings/utils/useText.d.ts +18 -0
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -688,6 +688,26 @@ function arrowStyles(position) {
|
|
|
688
688
|
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));
|
|
689
689
|
}
|
|
690
690
|
|
|
691
|
+
var useText = function useText(component, props, name, text) {
|
|
692
|
+
var _useState = React.useState(props[name]),
|
|
693
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
694
|
+
value = _useState2[0],
|
|
695
|
+
setValue = _useState2[1];
|
|
696
|
+
React.useEffect(function () {
|
|
697
|
+
if (name === 'children') {
|
|
698
|
+
throw new Error('Error: `children` is not a valid `getText` prop.');
|
|
699
|
+
} else if (value === null || value === '') {
|
|
700
|
+
throw new Error(component.displayName ? "Error: you must provide a valid `".concat(name, "` text value for <").concat(component.displayName, ">.") : "Error: you must provide a valid `".concat(name, "` text value."));
|
|
701
|
+
} else if (value === undefined) {
|
|
702
|
+
if (process.env.NODE_ENV === 'development') {
|
|
703
|
+
console.warn(component.displayName ? "Warning: you did not provide a customized/translated `".concat(name, "` text value for <").concat(component.displayName, ">. Zendesk Garden is rendering <").concat(component.displayName, " ").concat(name, "=\"").concat(text, "\"> by default.") : "Warning: you did not provide a customized/translated `".concat(name, "` text value. Zendesk Garden is rendering ").concat(name, "=\"").concat(text, "\" by default."));
|
|
704
|
+
}
|
|
705
|
+
setValue(text);
|
|
706
|
+
}
|
|
707
|
+
}, [name, value, component.displayName, text]);
|
|
708
|
+
return value;
|
|
709
|
+
};
|
|
710
|
+
|
|
691
711
|
var animationStyles = function animationStyles(position, options) {
|
|
692
712
|
var theme = options.theme || DEFAULT_THEME;
|
|
693
713
|
var translateValue = "".concat(theme.space.base * 5, "px");
|
|
@@ -744,4 +764,5 @@ exports.menuStyles = menuStyles;
|
|
|
744
764
|
exports.retrieveComponentStyles = retrieveComponentStyles;
|
|
745
765
|
exports.retrieveTheme = retrieveComponentStyles;
|
|
746
766
|
exports.useDocument = useDocument;
|
|
767
|
+
exports.useText = useText;
|
|
747
768
|
exports.withTheme = withTheme;
|
package/dist/index.esm.js
CHANGED
|
@@ -680,6 +680,26 @@ function arrowStyles(position) {
|
|
|
680
680
|
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));
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
+
var useText = function useText(component, props, name, text) {
|
|
684
|
+
var _useState = useState(props[name]),
|
|
685
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
686
|
+
value = _useState2[0],
|
|
687
|
+
setValue = _useState2[1];
|
|
688
|
+
useEffect(function () {
|
|
689
|
+
if (name === 'children') {
|
|
690
|
+
throw new Error('Error: `children` is not a valid `getText` prop.');
|
|
691
|
+
} else if (value === null || value === '') {
|
|
692
|
+
throw new Error(component.displayName ? "Error: you must provide a valid `".concat(name, "` text value for <").concat(component.displayName, ">.") : "Error: you must provide a valid `".concat(name, "` text value."));
|
|
693
|
+
} else if (value === undefined) {
|
|
694
|
+
if (process.env.NODE_ENV === 'development') {
|
|
695
|
+
console.warn(component.displayName ? "Warning: you did not provide a customized/translated `".concat(name, "` text value for <").concat(component.displayName, ">. Zendesk Garden is rendering <").concat(component.displayName, " ").concat(name, "=\"").concat(text, "\"> by default.") : "Warning: you did not provide a customized/translated `".concat(name, "` text value. Zendesk Garden is rendering ").concat(name, "=\"").concat(text, "\" by default."));
|
|
696
|
+
}
|
|
697
|
+
setValue(text);
|
|
698
|
+
}
|
|
699
|
+
}, [name, value, component.displayName, text]);
|
|
700
|
+
return value;
|
|
701
|
+
};
|
|
702
|
+
|
|
683
703
|
var animationStyles = function animationStyles(position, options) {
|
|
684
704
|
var theme = options.theme || DEFAULT_THEME;
|
|
685
705
|
var translateValue = "".concat(theme.space.base * 5, "px");
|
|
@@ -721,4 +741,4 @@ function menuStyles(position) {
|
|
|
721
741
|
var ARROW_POSITION = ['top', 'top-left', 'top-right', 'right', 'right-top', 'right-bottom', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-top', 'left-bottom'];
|
|
722
742
|
var MENU_POSITION = ['top', 'right', 'bottom', 'left'];
|
|
723
743
|
|
|
724
|
-
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, withTheme };
|
|
744
|
+
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 };
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { default as getLineHeight } from './utils/getLineHeight';
|
|
|
18
18
|
export { default as mediaQuery } from './utils/mediaQuery';
|
|
19
19
|
export { default as arrowStyles } from './utils/arrowStyles';
|
|
20
20
|
export { useDocument } from './utils/useDocument';
|
|
21
|
+
export { useText } from './utils/useText';
|
|
21
22
|
export { default as menuStyles } from './utils/menuStyles';
|
|
22
23
|
export { ARROW_POSITION as ARRAY_ARROW_POSITION, MENU_POSITION as ARRAY_MENU_POSITION } from './types';
|
|
23
24
|
export type { IGardenTheme, IThemeProviderProps, ArrowPosition as ARROW_POSITION, MenuPosition as MENU_POSITION } from './types';
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { FC } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* Provides default text for a11y (i.e. aria-label) or other critical attribute
|
|
10
|
+
* strings. If necessary, a development mode console warning prompts the
|
|
11
|
+
* consumer to provide customized, translated text.
|
|
12
|
+
*
|
|
13
|
+
* @param component The React component to which the `props` belong
|
|
14
|
+
* @param props The component props to check for `name`
|
|
15
|
+
* @param name The name of the component prop to set default text on
|
|
16
|
+
* @param text The default text to apply if the value of `props[name]` is undefined
|
|
17
|
+
*/
|
|
18
|
+
export declare const useText: (component: Pick<FC, 'displayName'>, props: Record<string, any>, name: string, text: string) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-theming",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.53.1",
|
|
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>",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"zendeskgarden:src": "src/index.ts",
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "79dee8e82b6f082e8d4a72ba95a5fb3982d63040"
|
|
45
45
|
}
|