@zendeskgarden/react-theming 9.0.0-next.7 → 9.0.0-next.9

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.
Files changed (34) hide show
  1. package/dist/esm/elements/ThemeProvider.js +24 -0
  2. package/dist/esm/elements/palette/index.js +259 -0
  3. package/dist/esm/elements/palette/v8.js +149 -0
  4. package/dist/esm/elements/theme/index.js +224 -0
  5. package/dist/esm/index.js +28 -0
  6. package/dist/esm/types/index.js +11 -0
  7. package/dist/esm/utils/StyledBaseIcon.js +22 -0
  8. package/dist/esm/utils/arrowStyles.js +64 -0
  9. package/dist/esm/utils/focusStyles.js +43 -0
  10. package/dist/esm/utils/getArrowPosition.js +35 -0
  11. package/dist/esm/utils/getCheckeredBackground.js +40 -0
  12. package/dist/esm/utils/getColor.js +153 -0
  13. package/dist/esm/utils/getColorV8.js +72 -0
  14. package/dist/esm/utils/getFloatingPlacements.js +58 -0
  15. package/dist/esm/utils/getFocusBoxShadow.js +45 -0
  16. package/dist/esm/utils/getLineHeight.js +22 -0
  17. package/dist/esm/utils/getMenuPosition.js +11 -0
  18. package/dist/esm/utils/mediaQuery.js +56 -0
  19. package/dist/esm/utils/menuStyles.js +63 -0
  20. package/dist/esm/utils/retrieveComponentStyles.js +19 -0
  21. package/dist/esm/utils/useDocument.js +21 -0
  22. package/dist/esm/utils/useText.js +29 -0
  23. package/dist/esm/utils/useWindow.js +21 -0
  24. package/dist/index.cjs.js +372 -262
  25. package/dist/typings/elements/palette/index.d.ts +0 -24
  26. package/dist/typings/index.d.ts +3 -1
  27. package/dist/typings/types/index.d.ts +43 -1
  28. package/dist/typings/utils/StyledBaseIcon.d.ts +8 -0
  29. package/dist/typings/utils/focusStyles.d.ts +1 -8
  30. package/dist/typings/utils/getCheckeredBackground.d.ts +20 -0
  31. package/dist/typings/utils/getColor.d.ts +3 -24
  32. package/dist/typings/utils/getFocusBoxShadow.d.ts +6 -20
  33. package/package.json +3 -3
  34. package/dist/index.esm.js +0 -1145
@@ -0,0 +1,63 @@
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 { css, keyframes } from 'styled-components';
8
+ import DEFAULT_THEME from '../elements/theme/index.js';
9
+ import { getColor } from './getColor.js';
10
+
11
+ const animationStyles = (position, options) => {
12
+ const theme = options.theme || DEFAULT_THEME;
13
+ let translateValue = `${theme.space.base * 5}px`;
14
+ let transformFunction;
15
+ if (position === 'top') {
16
+ transformFunction = 'translateY';
17
+ } else if (position === 'right') {
18
+ transformFunction = 'translateX';
19
+ translateValue = `-${translateValue}`;
20
+ } else if (position === 'bottom') {
21
+ transformFunction = 'translateY';
22
+ translateValue = `-${translateValue}`;
23
+ } else {
24
+ transformFunction = 'translateX';
25
+ }
26
+ const animationName = keyframes(["0%{transform:", "(", ");}"], transformFunction, translateValue);
27
+ return css(["&", " ", "{animation:0.2s cubic-bezier(0.15,0.85,0.35,1.2) ", ";}"], options.animationModifier, options.childSelector || '> *', animationName);
28
+ };
29
+ const hiddenStyles = options => {
30
+ const transition = 'opacity 0.2s ease-in-out, 0.2s visibility 0s linear';
31
+ return css(["transition:", ";visibility:hidden;opacity:0;"], options.animationModifier && transition);
32
+ };
33
+ function menuStyles(position) {
34
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
35
+ const theme = options.theme || DEFAULT_THEME;
36
+ let marginProperty;
37
+ if (position === 'top') {
38
+ marginProperty = 'margin-bottom';
39
+ } else if (position === 'right') {
40
+ marginProperty = 'margin-left';
41
+ } else if (position === 'bottom') {
42
+ marginProperty = 'margin-top';
43
+ } else {
44
+ marginProperty = 'margin-right';
45
+ }
46
+ 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;color:", ";font-size:", ";font-weight:", ";direction:", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, options.childSelector || '> *', theme.borders.sm, getColor({
47
+ theme,
48
+ variable: 'border.default'
49
+ }), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColor({
50
+ theme,
51
+ hue: 'chromeHue',
52
+ shade: 600,
53
+ transparency: 0.15
54
+ })), getColor({
55
+ theme,
56
+ variable: 'background.raised'
57
+ }), theme.rtl ? 'right' : 'left', getColor({
58
+ theme,
59
+ variable: 'foreground.default'
60
+ }), theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
61
+ }
62
+
63
+ export { menuStyles as default };
@@ -0,0 +1,19 @@
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
+ function retrieveComponentStyles(componentId, props) {
8
+ const components = props.theme && props.theme.components;
9
+ if (!components) {
10
+ return undefined;
11
+ }
12
+ const componentStyles = components[componentId];
13
+ if (typeof componentStyles === 'function') {
14
+ return componentStyles(props);
15
+ }
16
+ return componentStyles;
17
+ }
18
+
19
+ export { retrieveComponentStyles as default };
@@ -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
+ import { useState, useEffect } from 'react';
8
+
9
+ const useDocument = theme => {
10
+ const [controlledDocument, setControlledDocument] = useState();
11
+ useEffect(() => {
12
+ if (theme && theme.document) {
13
+ setControlledDocument(theme.document);
14
+ } else {
15
+ setControlledDocument(document);
16
+ }
17
+ }, [theme]);
18
+ return controlledDocument;
19
+ };
20
+
21
+ export { useDocument };
@@ -0,0 +1,29 @@
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 { useMemo } from 'react';
8
+
9
+ const useText = function (component, props, name, text) {
10
+ let condition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
11
+ const value = condition ? props[name] : undefined;
12
+ return useMemo(() => {
13
+ if (condition) {
14
+ if (name === 'children') {
15
+ throw new Error('Error: `children` is not a valid `useText` prop.');
16
+ } else if (value === null || value === '') {
17
+ 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.`);
18
+ } else if (value === undefined) {
19
+ if (process.env.NODE_ENV === 'development') {
20
+ 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.`);
21
+ }
22
+ return text;
23
+ }
24
+ }
25
+ return value;
26
+ }, [component.displayName, value, name, text, condition]);
27
+ };
28
+
29
+ export { useText };
@@ -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
+ import { useState, useEffect } from 'react';
8
+
9
+ const useWindow = theme => {
10
+ const [controlledWindow, setControlledWindow] = useState();
11
+ useEffect(() => {
12
+ if (theme && theme.window) {
13
+ setControlledWindow(theme.window);
14
+ } else {
15
+ setControlledWindow(window);
16
+ }
17
+ }, [theme]);
18
+ return controlledWindow;
19
+ };
20
+
21
+ export { useWindow };