@workday/canvas-kit-react 8.0.0-alpha.208-next.1 → 8.0.0-alpha.216-next.4

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 (230) hide show
  1. package/common/lib/utils/elements.ts +4 -4
  2. package/dist/commonjs/card/lib/Card.d.ts +1 -1
  3. package/dist/commonjs/card/lib/CardBody.d.ts +1 -1
  4. package/dist/commonjs/card/lib/CardBody.d.ts.map +1 -1
  5. package/dist/commonjs/common/lib/utils/elements.d.ts +1 -1
  6. package/dist/commonjs/common/lib/utils/elements.d.ts.map +1 -1
  7. package/dist/commonjs/common/lib/utils/elements.js +3 -3
  8. package/dist/commonjs/dialog/lib/Dialog.d.ts +1 -1
  9. package/dist/commonjs/icon/lib/SystemIcon.d.ts +1 -1
  10. package/dist/commonjs/icon/lib/SystemIcon.d.ts.map +1 -1
  11. package/dist/commonjs/layout/index.d.ts +8 -4
  12. package/dist/commonjs/layout/index.d.ts.map +1 -1
  13. package/dist/commonjs/layout/index.js +10 -2
  14. package/dist/commonjs/layout/lib/Box.d.ts +6 -4
  15. package/dist/commonjs/layout/lib/Box.d.ts.map +1 -1
  16. package/dist/commonjs/layout/lib/Box.js +8 -9
  17. package/dist/commonjs/layout/lib/Flex.d.ts +5 -2
  18. package/dist/commonjs/layout/lib/Flex.d.ts.map +1 -1
  19. package/dist/commonjs/layout/lib/Flex.js +5 -1
  20. package/dist/commonjs/layout/lib/Grid.d.ts +5 -6
  21. package/dist/commonjs/layout/lib/Grid.d.ts.map +1 -1
  22. package/dist/commonjs/layout/lib/Grid.js +2 -2
  23. package/dist/commonjs/layout/lib/Stack.d.ts +4 -4
  24. package/dist/commonjs/layout/lib/utils/background.d.ts +44 -0
  25. package/dist/commonjs/layout/lib/utils/background.d.ts.map +1 -0
  26. package/dist/commonjs/layout/lib/utils/background.js +57 -0
  27. package/dist/commonjs/layout/lib/utils/border/color.d.ts +47 -0
  28. package/dist/commonjs/layout/lib/utils/border/color.d.ts.map +1 -0
  29. package/dist/commonjs/layout/lib/utils/border/color.js +42 -0
  30. package/dist/commonjs/layout/lib/utils/border/index.d.ts +26 -0
  31. package/dist/commonjs/layout/lib/utils/border/index.d.ts.map +1 -0
  32. package/dist/commonjs/layout/lib/utils/border/index.js +46 -0
  33. package/dist/commonjs/layout/lib/utils/border/lineStyle.d.ts +38 -0
  34. package/dist/commonjs/layout/lib/utils/border/lineStyle.d.ts.map +1 -0
  35. package/dist/commonjs/layout/lib/utils/border/lineStyle.js +52 -0
  36. package/dist/commonjs/layout/lib/utils/border/radius.d.ts +33 -0
  37. package/dist/commonjs/layout/lib/utils/border/radius.d.ts.map +1 -0
  38. package/dist/commonjs/layout/lib/utils/border/radius.js +32 -0
  39. package/dist/commonjs/layout/lib/utils/border/shorthand.d.ts +34 -0
  40. package/dist/commonjs/layout/lib/utils/border/shorthand.d.ts.map +1 -0
  41. package/dist/commonjs/layout/lib/utils/border/shorthand.js +42 -0
  42. package/dist/commonjs/layout/lib/utils/border/width.d.ts +34 -0
  43. package/dist/commonjs/layout/lib/utils/border/width.d.ts.map +1 -0
  44. package/dist/commonjs/layout/lib/utils/border/width.js +42 -0
  45. package/dist/commonjs/layout/lib/utils/buildStyleFns.d.ts +12 -0
  46. package/dist/commonjs/layout/lib/utils/buildStyleFns.d.ts.map +1 -0
  47. package/dist/commonjs/layout/lib/utils/buildStyleFns.js +90 -0
  48. package/dist/commonjs/layout/lib/utils/color.d.ts +23 -16
  49. package/dist/commonjs/layout/lib/utils/color.d.ts.map +1 -1
  50. package/dist/commonjs/layout/lib/utils/color.js +25 -49
  51. package/dist/commonjs/layout/lib/utils/depth.d.ts +17 -11
  52. package/dist/commonjs/layout/lib/utils/depth.d.ts.map +1 -1
  53. package/dist/commonjs/layout/lib/utils/depth.js +20 -20
  54. package/dist/commonjs/layout/lib/utils/flex.d.ts +31 -12
  55. package/dist/commonjs/layout/lib/utils/flex.d.ts.map +1 -1
  56. package/dist/commonjs/layout/lib/utils/flex.js +58 -25
  57. package/dist/commonjs/layout/lib/utils/flexItem.d.ts +18 -15
  58. package/dist/commonjs/layout/lib/utils/flexItem.d.ts.map +1 -1
  59. package/dist/commonjs/layout/lib/utils/flexItem.js +43 -26
  60. package/dist/commonjs/layout/lib/utils/grid.d.ts +40 -35
  61. package/dist/commonjs/layout/lib/utils/grid.d.ts.map +1 -1
  62. package/dist/commonjs/layout/lib/utils/grid.js +99 -72
  63. package/dist/commonjs/layout/lib/utils/gridItem.d.ts +17 -14
  64. package/dist/commonjs/layout/lib/utils/gridItem.d.ts.map +1 -1
  65. package/dist/commonjs/layout/lib/utils/gridItem.js +58 -30
  66. package/dist/commonjs/layout/lib/utils/layout.d.ts +47 -25
  67. package/dist/commonjs/layout/lib/utils/layout.d.ts.map +1 -1
  68. package/dist/commonjs/layout/lib/utils/layout.js +71 -33
  69. package/dist/commonjs/layout/lib/utils/other.d.ts +44 -2
  70. package/dist/commonjs/layout/lib/utils/other.d.ts.map +1 -1
  71. package/dist/commonjs/layout/lib/utils/other.js +101 -17
  72. package/dist/commonjs/layout/lib/utils/position.d.ts +37 -20
  73. package/dist/commonjs/layout/lib/utils/position.d.ts.map +1 -1
  74. package/dist/commonjs/layout/lib/utils/position.js +49 -66
  75. package/dist/commonjs/layout/lib/utils/space.d.ts +107 -51
  76. package/dist/commonjs/layout/lib/utils/space.d.ts.map +1 -1
  77. package/dist/commonjs/layout/lib/utils/space.js +98 -148
  78. package/dist/commonjs/layout/lib/utils/stack.d.ts +3 -6
  79. package/dist/commonjs/layout/lib/utils/stack.d.ts.map +1 -1
  80. package/dist/commonjs/layout/lib/utils/stack.js +13 -39
  81. package/dist/commonjs/layout/lib/utils/systemProps.d.ts +31 -0
  82. package/dist/commonjs/layout/lib/utils/systemProps.d.ts.map +1 -0
  83. package/dist/commonjs/layout/lib/utils/systemProps.js +2 -0
  84. package/dist/commonjs/layout/lib/utils/text.d.ts +33 -15
  85. package/dist/commonjs/layout/lib/utils/text.d.ts.map +1 -1
  86. package/dist/commonjs/layout/lib/utils/text.js +74 -38
  87. package/dist/commonjs/modal/lib/Modal.d.ts +1 -1
  88. package/dist/commonjs/popup/lib/Popup.d.ts +1 -1
  89. package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -1
  90. package/dist/commonjs/popup/lib/hooks/useReturnFocus.d.ts.map +1 -1
  91. package/dist/commonjs/popup/lib/hooks/useReturnFocus.js +72 -1
  92. package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
  93. package/dist/commonjs/tokens/lib/colors.types.d.ts +4 -6
  94. package/dist/commonjs/tokens/lib/colors.types.d.ts.map +1 -1
  95. package/dist/es6/card/lib/Card.d.ts +1 -1
  96. package/dist/es6/card/lib/CardBody.d.ts +1 -1
  97. package/dist/es6/card/lib/CardBody.d.ts.map +1 -1
  98. package/dist/es6/common/lib/utils/elements.d.ts +1 -1
  99. package/dist/es6/common/lib/utils/elements.d.ts.map +1 -1
  100. package/dist/es6/common/lib/utils/elements.js +3 -3
  101. package/dist/es6/dialog/lib/Dialog.d.ts +1 -1
  102. package/dist/es6/icon/lib/SystemIcon.d.ts +1 -1
  103. package/dist/es6/icon/lib/SystemIcon.d.ts.map +1 -1
  104. package/dist/es6/layout/index.d.ts +8 -4
  105. package/dist/es6/layout/index.d.ts.map +1 -1
  106. package/dist/es6/layout/index.js +7 -1
  107. package/dist/es6/layout/lib/Box.d.ts +6 -4
  108. package/dist/es6/layout/lib/Box.d.ts.map +1 -1
  109. package/dist/es6/layout/lib/Box.js +8 -9
  110. package/dist/es6/layout/lib/Flex.d.ts +5 -2
  111. package/dist/es6/layout/lib/Flex.d.ts.map +1 -1
  112. package/dist/es6/layout/lib/Flex.js +5 -1
  113. package/dist/es6/layout/lib/Grid.d.ts +5 -6
  114. package/dist/es6/layout/lib/Grid.d.ts.map +1 -1
  115. package/dist/es6/layout/lib/Grid.js +2 -2
  116. package/dist/es6/layout/lib/Stack.d.ts +4 -4
  117. package/dist/es6/layout/lib/utils/background.d.ts +44 -0
  118. package/dist/es6/layout/lib/utils/background.d.ts.map +1 -0
  119. package/dist/es6/layout/lib/utils/background.js +54 -0
  120. package/dist/es6/layout/lib/utils/border/color.d.ts +47 -0
  121. package/dist/es6/layout/lib/utils/border/color.d.ts.map +1 -0
  122. package/dist/es6/layout/lib/utils/border/color.js +39 -0
  123. package/dist/es6/layout/lib/utils/border/index.d.ts +26 -0
  124. package/dist/es6/layout/lib/utils/border/index.d.ts.map +1 -0
  125. package/dist/es6/layout/lib/utils/border/index.js +43 -0
  126. package/dist/es6/layout/lib/utils/border/lineStyle.d.ts +38 -0
  127. package/dist/es6/layout/lib/utils/border/lineStyle.d.ts.map +1 -0
  128. package/dist/es6/layout/lib/utils/border/lineStyle.js +49 -0
  129. package/dist/es6/layout/lib/utils/border/radius.d.ts +33 -0
  130. package/dist/es6/layout/lib/utils/border/radius.d.ts.map +1 -0
  131. package/dist/es6/layout/lib/utils/border/radius.js +29 -0
  132. package/dist/es6/layout/lib/utils/border/shorthand.d.ts +34 -0
  133. package/dist/es6/layout/lib/utils/border/shorthand.d.ts.map +1 -0
  134. package/dist/es6/layout/lib/utils/border/shorthand.js +39 -0
  135. package/dist/es6/layout/lib/utils/border/width.d.ts +34 -0
  136. package/dist/es6/layout/lib/utils/border/width.d.ts.map +1 -0
  137. package/dist/es6/layout/lib/utils/border/width.js +39 -0
  138. package/dist/es6/layout/lib/utils/buildStyleFns.d.ts +12 -0
  139. package/dist/es6/layout/lib/utils/buildStyleFns.d.ts.map +1 -0
  140. package/dist/es6/layout/lib/utils/buildStyleFns.js +85 -0
  141. package/dist/es6/layout/lib/utils/color.d.ts +23 -16
  142. package/dist/es6/layout/lib/utils/color.d.ts.map +1 -1
  143. package/dist/es6/layout/lib/utils/color.js +24 -47
  144. package/dist/es6/layout/lib/utils/depth.d.ts +17 -11
  145. package/dist/es6/layout/lib/utils/depth.d.ts.map +1 -1
  146. package/dist/es6/layout/lib/utils/depth.js +19 -18
  147. package/dist/es6/layout/lib/utils/flex.d.ts +31 -12
  148. package/dist/es6/layout/lib/utils/flex.d.ts.map +1 -1
  149. package/dist/es6/layout/lib/utils/flex.js +57 -23
  150. package/dist/es6/layout/lib/utils/flexItem.d.ts +18 -15
  151. package/dist/es6/layout/lib/utils/flexItem.d.ts.map +1 -1
  152. package/dist/es6/layout/lib/utils/flexItem.js +42 -24
  153. package/dist/es6/layout/lib/utils/grid.d.ts +40 -35
  154. package/dist/es6/layout/lib/utils/grid.d.ts.map +1 -1
  155. package/dist/es6/layout/lib/utils/grid.js +98 -70
  156. package/dist/es6/layout/lib/utils/gridItem.d.ts +17 -14
  157. package/dist/es6/layout/lib/utils/gridItem.d.ts.map +1 -1
  158. package/dist/es6/layout/lib/utils/gridItem.js +57 -28
  159. package/dist/es6/layout/lib/utils/layout.d.ts +47 -25
  160. package/dist/es6/layout/lib/utils/layout.d.ts.map +1 -1
  161. package/dist/es6/layout/lib/utils/layout.js +70 -31
  162. package/dist/es6/layout/lib/utils/other.d.ts +44 -2
  163. package/dist/es6/layout/lib/utils/other.d.ts.map +1 -1
  164. package/dist/es6/layout/lib/utils/other.js +100 -15
  165. package/dist/es6/layout/lib/utils/position.d.ts +37 -20
  166. package/dist/es6/layout/lib/utils/position.d.ts.map +1 -1
  167. package/dist/es6/layout/lib/utils/position.js +48 -64
  168. package/dist/es6/layout/lib/utils/space.d.ts +107 -51
  169. package/dist/es6/layout/lib/utils/space.d.ts.map +1 -1
  170. package/dist/es6/layout/lib/utils/space.js +97 -146
  171. package/dist/es6/layout/lib/utils/stack.d.ts +3 -6
  172. package/dist/es6/layout/lib/utils/stack.d.ts.map +1 -1
  173. package/dist/es6/layout/lib/utils/stack.js +13 -39
  174. package/dist/es6/layout/lib/utils/systemProps.d.ts +31 -0
  175. package/dist/es6/layout/lib/utils/systemProps.d.ts.map +1 -0
  176. package/dist/es6/layout/lib/utils/systemProps.js +1 -0
  177. package/dist/es6/layout/lib/utils/text.d.ts +33 -15
  178. package/dist/es6/layout/lib/utils/text.d.ts.map +1 -1
  179. package/dist/es6/layout/lib/utils/text.js +73 -36
  180. package/dist/es6/modal/lib/Modal.d.ts +1 -1
  181. package/dist/es6/popup/lib/Popup.d.ts +1 -1
  182. package/dist/es6/popup/lib/PopupBody.d.ts +1 -1
  183. package/dist/es6/popup/lib/hooks/useReturnFocus.d.ts.map +1 -1
  184. package/dist/es6/popup/lib/hooks/useReturnFocus.js +73 -2
  185. package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
  186. package/dist/es6/tokens/lib/colors.types.d.ts +4 -6
  187. package/dist/es6/tokens/lib/colors.types.d.ts.map +1 -1
  188. package/icon/lib/SystemIcon.tsx +1 -1
  189. package/layout/index.ts +8 -4
  190. package/layout/lib/Box.tsx +10 -36
  191. package/layout/lib/Flex.tsx +5 -1
  192. package/layout/lib/Grid.tsx +3 -4
  193. package/layout/lib/utils/background.ts +83 -0
  194. package/layout/lib/utils/border/color.ts +85 -0
  195. package/layout/lib/utils/border/index.ts +49 -0
  196. package/layout/lib/utils/border/lineStyle.ts +87 -0
  197. package/layout/lib/utils/border/radius.ts +61 -0
  198. package/layout/lib/utils/border/shorthand.ts +73 -0
  199. package/layout/lib/utils/border/width.ts +73 -0
  200. package/layout/lib/utils/buildStyleFns.ts +117 -0
  201. package/layout/lib/utils/color.ts +40 -55
  202. package/layout/lib/utils/depth.ts +28 -24
  203. package/layout/lib/utils/flex.ts +83 -32
  204. package/layout/lib/utils/flexItem.ts +54 -36
  205. package/layout/lib/utils/grid.ts +131 -94
  206. package/layout/lib/utils/gridItem.ts +69 -41
  207. package/layout/lib/utils/layout.ts +109 -50
  208. package/layout/lib/utils/other.ts +142 -15
  209. package/layout/lib/utils/position.ts +79 -73
  210. package/layout/lib/utils/space.ts +202 -196
  211. package/layout/lib/utils/stack.ts +19 -45
  212. package/layout/lib/utils/systemProps.ts +46 -0
  213. package/layout/lib/utils/text.ts +99 -34
  214. package/package.json +3 -3
  215. package/popup/lib/hooks/useReturnFocus.tsx +82 -3
  216. package/tokens/lib/colors.types.ts +4 -7
  217. package/dist/commonjs/layout/lib/utils/border.d.ts +0 -103
  218. package/dist/commonjs/layout/lib/utils/border.d.ts.map +0 -1
  219. package/dist/commonjs/layout/lib/utils/border.js +0 -153
  220. package/dist/commonjs/layout/lib/utils/font.d.ts +0 -29
  221. package/dist/commonjs/layout/lib/utils/font.d.ts.map +0 -1
  222. package/dist/commonjs/layout/lib/utils/font.js +0 -57
  223. package/dist/es6/layout/lib/utils/border.d.ts +0 -103
  224. package/dist/es6/layout/lib/utils/border.d.ts.map +0 -1
  225. package/dist/es6/layout/lib/utils/border.js +0 -149
  226. package/dist/es6/layout/lib/utils/font.d.ts +0 -29
  227. package/dist/es6/layout/lib/utils/font.d.ts.map +0 -1
  228. package/dist/es6/layout/lib/utils/font.js +0 -53
  229. package/layout/lib/utils/border.ts +0 -263
  230. package/layout/lib/utils/font.ts +0 -67
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.font = void 0;
15
- var tokens_1 = require("@workday/canvas-kit-react/tokens");
16
- var getFontFamily = function (value) { return ({
17
- fontFamily: tokens_1.type.properties.fontFamilies[value] || value,
18
- }); };
19
- var getFontSize = function (value) { return ({
20
- fontSize: tokens_1.type.properties.fontSizes[value] || value,
21
- }); };
22
- var getFontStyle = function (value) { return ({
23
- fontStyle: value,
24
- }); };
25
- var getFontWeight = function (value) { return ({
26
- fontWeight: tokens_1.type.properties.fontWeights[value] || value,
27
- }); };
28
- var fontProps = {
29
- fontFamily: getFontFamily,
30
- fontSize: getFontSize,
31
- fontWeight: getFontWeight,
32
- fontStyle: getFontStyle,
33
- };
34
- /**
35
- * A style prop function that takes components props and returns font styles from canvas token values.
36
- * If no `FontStyleProps` are found, it returns an empty object.
37
- *
38
- * @example
39
- * // You'll most likely use `font` with low-level, styled components
40
- * const BoxExample = () => (
41
- * <Box fontFamily="monospace" fontWeight="medium">Hello, fonts!</Box>
42
- * );
43
- *
44
- */
45
- function font(props) {
46
- var styles = {};
47
- for (var key in props) {
48
- if (key in fontProps) {
49
- var value = props[key];
50
- var fontFn = fontProps[key];
51
- var style = fontFn(value);
52
- styles = __assign(__assign({}, styles), style);
53
- }
54
- }
55
- return styles;
56
- }
57
- exports.font = font;
@@ -1,103 +0,0 @@
1
- import { CanvasBorderRadiusKeys, CanvasColor } from '@workday/canvas-kit-react/tokens';
2
- import { PartialEmotionCanvasTheme } from '@workday/canvas-kit-react/common';
3
- import { Property } from 'csstype';
4
- /** style props to set the border properties */
5
- export declare type BorderShorthandStyleProps = {
6
- /** sets `border` property */
7
- border?: string;
8
- /** sets `border-top` property */
9
- borderTop?: string;
10
- /** sets `border-right` property (no bidirectional support) */
11
- borderRight?: string;
12
- /** sets `border-bottom` property */
13
- borderBottom?: string;
14
- /** sets `border-left` property (no bidirectional support) */
15
- borderLeft?: string;
16
- };
17
- /** style props to set the border color properties */
18
- export declare type BorderColorStyleProps = {
19
- /** sets `border-color` property */
20
- borderColor?: CanvasColor | (string & {});
21
- /** sets `border-top-color` property */
22
- borderTopColor?: CanvasColor | (string & {});
23
- /** sets `border-right-color` property (no bidirectional support) */
24
- borderRightColor?: CanvasColor | (string & {});
25
- /** sets `border-bottom-color` property */
26
- borderBottomColor?: CanvasColor | (string & {});
27
- /** sets `border-left-color` property (no bidirectional support) */
28
- borderLeftColor?: CanvasColor | (string & {});
29
- };
30
- /** style props to set the border radius properties */
31
- export declare type BorderRadiusStyleProps = {
32
- /** sets `border-radius` property */
33
- borderRadius?: CanvasBorderRadiusKeys | number | (string & {});
34
- /** sets `border-top-left-radius` property */
35
- borderTopLeftRadius?: CanvasBorderRadiusKeys | number | (string & {});
36
- /** sets `border-top-right-radius` property */
37
- borderTopRightRadius?: CanvasBorderRadiusKeys | number | (string & {});
38
- /** sets `border-bottom-left-radius` property */
39
- borderBottomLeftRadius?: CanvasBorderRadiusKeys | number | (string & {});
40
- /** sets `border-bottom-right-radius` property */
41
- borderBottomRightRadius?: CanvasBorderRadiusKeys | number | (string & {});
42
- };
43
- /** style props to set the border style properties */
44
- export declare type BorderLineStyleProps = {
45
- /** sets `border-style` property */
46
- borderStyle?: Property.Border;
47
- /** sets `border-top-style` property */
48
- borderTopStyle?: Property.Border;
49
- /** sets `border-right-style` property (no bidirectional support) */
50
- borderRightStyle?: Property.Border;
51
- /** sets `border-bottom-style` property */
52
- borderBottomStyle?: Property.Border;
53
- /** sets `border-left-style` property (no bidirectional support) */
54
- borderLeftStyle?: Property.Border;
55
- };
56
- /** style props to set the border width properties */
57
- export declare type BorderWidthStyleProps = {
58
- /** sets `border-width` property */
59
- borderWidth?: string | number;
60
- /** sets `border-top-width` property */
61
- borderTopWidth?: string | number;
62
- /** sets `border-right-width` property (no bidirectional support) */
63
- borderRightWidth?: string | number;
64
- /** sets `border-bottom-width` property */
65
- borderBottomWidth?: string | number;
66
- /** sets `border-left-width` property (no bidirectional support) */
67
- borderLeftWidth?: string | number;
68
- };
69
- export declare type BorderLogicalStyleProps = {
70
- /** sets `border-left` property (bidirectional support) */
71
- borderInlineStart?: string;
72
- /** sets `border-left-color` property (bidirectional support) */
73
- borderInlineStartColor?: CanvasColor | (string & {});
74
- /** sets `border-left-style` property (bidirectional support) */
75
- borderInlineStartStyle?: Property.Border;
76
- /** sets `border-left-width` property (bidirectional support) */
77
- borderInlineStartWidth?: string | number;
78
- /** sets `border-right` property (bidirectional support) */
79
- borderInlineEnd?: string;
80
- /** sets `border-right-color` property (bidirectional support) */
81
- borderInlineEndColor?: CanvasColor | (string & {});
82
- /** sets `border-right-style` property (bidirectional support) */
83
- borderInlineEndStyle?: Property.Border;
84
- /** sets `border-right-width` property (bidirectional support) */
85
- borderInlineEndWidth?: string | number;
86
- };
87
- /** a collection style props for border properties */
88
- export declare type BorderStyleProps = BorderShorthandStyleProps & BorderColorStyleProps & BorderRadiusStyleProps & BorderLineStyleProps & BorderWidthStyleProps & BorderLogicalStyleProps;
89
- /**
90
- * A style prop function that takes components props and returns border styles. Some props, such as borderRadius and borderColor, are connected to our design tokens.
91
- * If no `BorderStyleProps` are found, it returns an empty object.
92
- *
93
- * @example
94
- * // You'll most likely use `border` with low-level, styled components
95
- * const BoxExample = () => (
96
- * <Box border={`solid 1px #333333 ${colors.blackPepper400}`}>Hello, border styles!</Box>
97
- * );
98
- *
99
- */
100
- export declare function border<P extends BorderStyleProps & {
101
- theme?: PartialEmotionCanvasTheme;
102
- }>(props: P): {};
103
- //# sourceMappingURL=border.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"border.d.ts","sourceRoot":"","sources":["../../../../../layout/lib/utils/border.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EAEtB,WAAW,EACZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,yBAAyB,EAE1B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEjC,+CAA+C;AAC/C,oBAAY,yBAAyB,GAAG;IACtC,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,qDAAqD;AACrD,oBAAY,qBAAqB,GAAG;IAClC,mCAAmC;IACnC,WAAW,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC1C,uCAAuC;IACvC,cAAc,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC7C,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC/C,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAChD,mEAAmE;IACnE,eAAe,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;CAC/C,CAAC;AAEF,sDAAsD;AACtD,oBAAY,sBAAsB,GAAG;IACnC,oCAAoC;IACpC,YAAY,CAAC,EAAE,sBAAsB,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC/D,6CAA6C;IAC7C,mBAAmB,CAAC,EAAE,sBAAsB,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACtE,8CAA8C;IAC9C,oBAAoB,CAAC,EAAE,sBAAsB,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACvE,gDAAgD;IAChD,sBAAsB,CAAC,EAAE,sBAAsB,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACzE,iDAAiD;IACjD,uBAAuB,CAAC,EAAE,sBAAsB,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;CAC3E,CAAC;AAEF,qDAAqD;AACrD,oBAAY,oBAAoB,GAAG;IACjC,mCAAmC;IACnC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;IAC9B,uCAAuC;IACvC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;IACjC,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;IACnC,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;IACpC,mEAAmE;IACnE,eAAe,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;CACnC,CAAC;AAEF,qDAAqD;AACrD,oBAAY,qBAAqB,GAAG;IAClC,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,uCAAuC;IACvC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC,CAAC;AAEF,oBAAY,uBAAuB,GAAG;IACpC,0DAA0D;IAC1D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,sBAAsB,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACrD,gEAAgE;IAChE,sBAAsB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;IACzC,gEAAgE;IAChE,sBAAsB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzC,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,oBAAoB,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACnD,iEAAiE;IACjE,oBAAoB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;IACvC,iEAAiE;IACjE,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxC,CAAC;AAEF,qDAAqD;AACrD,oBAAY,gBAAgB,GAAG,yBAAyB,GACtD,qBAAqB,GACrB,sBAAsB,GACtB,oBAAoB,GACpB,qBAAqB,GACrB,uBAAuB,CAAC;AA4D1B;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,gBAAgB,GAAG;IAAC,KAAK,CAAC,EAAE,yBAAyB,CAAA;CAAC,EAAE,KAAK,EAAE,CAAC,MAkFhG"}
@@ -1,149 +0,0 @@
1
- import { borderRadius as borderRadiusTokens, colors as colorTokens, } from '@workday/canvas-kit-react/tokens';
2
- import { ContentDirection, useTheme, } from '@workday/canvas-kit-react/common';
3
- // border logical prop handlers
4
- var borderInlineStart = function (isRTL) { return (isRTL ? 'borderRight' : 'borderLeft'); };
5
- var borderInlineEnd = function (isRTL) { return (isRTL ? 'borderLeft' : 'borderRight'); };
6
- var borderInlineStartColor = function (isRTL) { return (isRTL ? 'borderRightColor' : 'borderLeftColor'); };
7
- var borderInlineEndColor = function (isRTL) { return (isRTL ? 'borderLeftColor' : 'borderRightColor'); };
8
- var borderInlineStartStyle = function (isRTL) { return (isRTL ? 'borderRightStyle' : 'borderLeftStyle'); };
9
- var borderInlineEndStyle = function (isRTL) { return (isRTL ? 'borderLeftStyle' : 'borderRightStyle'); };
10
- var borderInlineStartWidth = function (isRTL) { return (isRTL ? 'borderRightWidth' : 'borderLeftWidth'); };
11
- var borderInlineEndWidth = function (isRTL) { return (isRTL ? 'borderLeftWidth' : 'borderRightWidth'); };
12
- var borderShorthandProps = {
13
- border: 'border',
14
- borderTop: 'borderTop',
15
- borderRight: 'borderRight',
16
- borderBottom: 'borderBottom',
17
- borderLeft: 'borderLeft',
18
- borderInlineStart: borderInlineStart,
19
- borderInlineEnd: borderInlineEnd,
20
- };
21
- var borderColors = {
22
- borderColor: 'borderColor',
23
- borderTopColor: 'borderTopColor',
24
- borderRightColor: 'borderRightColor',
25
- borderBottomColor: 'borderBottomColor',
26
- borderLeftColor: 'borderLeftColor',
27
- borderInlineStartColor: borderInlineStartColor,
28
- borderInlineEndColor: borderInlineEndColor,
29
- };
30
- var borderRadii = {
31
- borderRadius: 'borderRadius',
32
- borderTopLeftRadius: 'borderTopLeftRadius',
33
- borderTopRightRadius: 'borderTopRightRadius',
34
- borderBottomLeftRadius: 'borderBottomLeftRadius',
35
- borderBottomRightRadius: 'borderBottomRightRadius',
36
- };
37
- var borderStyles = {
38
- borderStyle: 'borderStyle',
39
- borderTopStyle: 'borderTopStyle',
40
- borderRightStyle: 'borderRightStyle',
41
- borderBottomStyle: 'borderBottomStyle',
42
- borderLeftStyle: 'borderLeftStyle',
43
- borderInlineStartStyle: borderInlineStartStyle,
44
- borderInlineEndStyle: borderInlineEndStyle,
45
- };
46
- var borderWidths = {
47
- borderWidth: 'borderWidth',
48
- borderTopWidth: 'borderTopWidth',
49
- borderRightWidth: 'borderRightWidth',
50
- borderBottomWidth: 'borderBottomWidth',
51
- borderLeftWidth: 'borderLeftWidth',
52
- borderInlineStartWidth: borderInlineStartWidth,
53
- borderInlineEndWidth: borderInlineEndWidth,
54
- };
55
- /**
56
- * A style prop function that takes components props and returns border styles. Some props, such as borderRadius and borderColor, are connected to our design tokens.
57
- * If no `BorderStyleProps` are found, it returns an empty object.
58
- *
59
- * @example
60
- * // You'll most likely use `border` with low-level, styled components
61
- * const BoxExample = () => (
62
- * <Box border={`solid 1px #333333 ${colors.blackPepper400}`}>Hello, border styles!</Box>
63
- * );
64
- *
65
- */
66
- export function border(props) {
67
- // border will always be used within the context of a component, but eslint doesn't know that
68
- // eslint-disable-next-line react-hooks/rules-of-hooks
69
- var canvas = useTheme(props.theme).canvas;
70
- var isRTL = canvas.direction === ContentDirection.RTL;
71
- var styles = {};
72
- for (var key in props) {
73
- if (props.hasOwnProperty(key)) {
74
- if (key in borderShorthandProps) {
75
- var value = props[key];
76
- var attr = void 0;
77
- if (key === 'borderInlineStart') {
78
- attr = borderInlineStart(isRTL);
79
- }
80
- else if (key === 'borderInlineEnd') {
81
- attr = borderInlineEnd(isRTL);
82
- }
83
- else {
84
- attr = borderShorthandProps[key];
85
- }
86
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
87
- styles[attr] = value;
88
- continue;
89
- }
90
- if (key in borderColors) {
91
- var propValue = props[key];
92
- var value = colorTokens[propValue] || propValue;
93
- var attr = void 0;
94
- if (key === 'borderInlineStartColor') {
95
- attr = borderInlineStartColor(isRTL);
96
- }
97
- else if (key === 'borderInlineEndColor') {
98
- attr = borderInlineEndColor(isRTL);
99
- }
100
- else {
101
- attr = borderColors[key];
102
- }
103
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
104
- styles[attr] = value;
105
- continue;
106
- }
107
- if (key in borderRadii) {
108
- var propValue = props[key];
109
- var value = borderRadiusTokens[propValue] || propValue;
110
- var attr = borderRadii[key];
111
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
112
- styles[attr] = value;
113
- continue;
114
- }
115
- if (key in borderStyles) {
116
- var value = props[key];
117
- var attr = void 0;
118
- if (key === 'borderInlineStartStyle') {
119
- attr = borderInlineStartStyle(isRTL);
120
- }
121
- else if (key === 'borderInlineEndStyle') {
122
- attr = borderInlineEndStyle(isRTL);
123
- }
124
- else {
125
- attr = borderStyles[key];
126
- }
127
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
128
- styles[attr] = value;
129
- continue;
130
- }
131
- if (key in borderWidths) {
132
- var value = props[key];
133
- var attr = void 0;
134
- if (key === 'borderInlineStartWidth') {
135
- attr = borderInlineStartWidth(isRTL);
136
- }
137
- else if (key === 'borderInlineEndWidth') {
138
- attr = borderInlineEndWidth(isRTL);
139
- }
140
- else {
141
- attr = borderWidths[key];
142
- }
143
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
144
- styles[attr] = value;
145
- }
146
- }
147
- }
148
- return styles;
149
- }
@@ -1,29 +0,0 @@
1
- import { Property } from 'csstype';
2
- import { CanvasTypeProperties } from '@workday/canvas-kit-react/tokens';
3
- export declare type FontFamilyTokens = keyof CanvasTypeProperties['fontFamilies'];
4
- export declare type FontSizeTokens = keyof CanvasTypeProperties['fontSizes'];
5
- export declare type FontWeightTokens = keyof CanvasTypeProperties['fontWeights'];
6
- /** style props to for color properties */
7
- export declare type FontStyleProps = {
8
- /** sets `font-family` property */
9
- fontFamily?: Property.FontFamily | FontFamilyTokens;
10
- /** sets `font-size` property */
11
- fontSize?: Property.FontSize | FontSizeTokens;
12
- /** sets `font-style` property */
13
- fontStyle?: Property.FontStyle;
14
- /** sets `font-weight` property */
15
- fontWeight?: Property.FontWeight | FontWeightTokens;
16
- };
17
- /**
18
- * A style prop function that takes components props and returns font styles from canvas token values.
19
- * If no `FontStyleProps` are found, it returns an empty object.
20
- *
21
- * @example
22
- * // You'll most likely use `font` with low-level, styled components
23
- * const BoxExample = () => (
24
- * <Box fontFamily="monospace" fontWeight="medium">Hello, fonts!</Box>
25
- * );
26
- *
27
- */
28
- export declare function font<P extends FontStyleProps>(props: P): {};
29
- //# sourceMappingURL=font.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../../../../layout/lib/utils/font.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACjC,OAAO,EAAO,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AAE5E,oBAAY,gBAAgB,GAAG,MAAM,oBAAoB,CAAC,cAAc,CAAC,CAAC;AAC1E,oBAAY,cAAc,GAAG,MAAM,oBAAoB,CAAC,WAAW,CAAC,CAAC;AACrE,oBAAY,gBAAgB,GAAG,MAAM,oBAAoB,CAAC,aAAa,CAAC,CAAC;AAGzE,0CAA0C;AAC1C,oBAAY,cAAc,GAAG;IAC3B,kCAAkC;IAClC,UAAU,CAAC,EAAE,QAAQ,CAAC,UAAU,GAAG,gBAAgB,CAAC;IACpD,gCAAgC;IAChC,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ,GAAG,cAAc,CAAC;IAC9C,iCAAiC;IACjC,SAAS,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;IAC/B,kCAAkC;IAClC,UAAU,CAAC,EAAE,QAAQ,CAAC,UAAU,GAAG,gBAAgB,CAAC;CACrD,CAAC;AAyBF;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,cAAc,EAAE,KAAK,EAAE,CAAC,MAYtD"}
@@ -1,53 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { type } from '@workday/canvas-kit-react/tokens';
13
- var getFontFamily = function (value) { return ({
14
- fontFamily: type.properties.fontFamilies[value] || value,
15
- }); };
16
- var getFontSize = function (value) { return ({
17
- fontSize: type.properties.fontSizes[value] || value,
18
- }); };
19
- var getFontStyle = function (value) { return ({
20
- fontStyle: value,
21
- }); };
22
- var getFontWeight = function (value) { return ({
23
- fontWeight: type.properties.fontWeights[value] || value,
24
- }); };
25
- var fontProps = {
26
- fontFamily: getFontFamily,
27
- fontSize: getFontSize,
28
- fontWeight: getFontWeight,
29
- fontStyle: getFontStyle,
30
- };
31
- /**
32
- * A style prop function that takes components props and returns font styles from canvas token values.
33
- * If no `FontStyleProps` are found, it returns an empty object.
34
- *
35
- * @example
36
- * // You'll most likely use `font` with low-level, styled components
37
- * const BoxExample = () => (
38
- * <Box fontFamily="monospace" fontWeight="medium">Hello, fonts!</Box>
39
- * );
40
- *
41
- */
42
- export function font(props) {
43
- var styles = {};
44
- for (var key in props) {
45
- if (key in fontProps) {
46
- var value = props[key];
47
- var fontFn = fontProps[key];
48
- var style = fontFn(value);
49
- styles = __assign(__assign({}, styles), style);
50
- }
51
- }
52
- return styles;
53
- }
@@ -1,263 +0,0 @@
1
- import {
2
- borderRadius as borderRadiusTokens,
3
- CanvasBorderRadiusKeys,
4
- colors as colorTokens,
5
- CanvasColor,
6
- } from '@workday/canvas-kit-react/tokens';
7
- import {
8
- ContentDirection,
9
- PartialEmotionCanvasTheme,
10
- useTheme,
11
- } from '@workday/canvas-kit-react/common';
12
-
13
- import {Property} from 'csstype';
14
-
15
- /** style props to set the border properties */
16
- export type BorderShorthandStyleProps = {
17
- /** sets `border` property */
18
- border?: string;
19
- /** sets `border-top` property */
20
- borderTop?: string;
21
- /** sets `border-right` property (no bidirectional support) */
22
- borderRight?: string;
23
- /** sets `border-bottom` property */
24
- borderBottom?: string;
25
- /** sets `border-left` property (no bidirectional support) */
26
- borderLeft?: string;
27
- };
28
-
29
- /** style props to set the border color properties */
30
- export type BorderColorStyleProps = {
31
- /** sets `border-color` property */
32
- borderColor?: CanvasColor | (string & {});
33
- /** sets `border-top-color` property */
34
- borderTopColor?: CanvasColor | (string & {});
35
- /** sets `border-right-color` property (no bidirectional support) */
36
- borderRightColor?: CanvasColor | (string & {});
37
- /** sets `border-bottom-color` property */
38
- borderBottomColor?: CanvasColor | (string & {});
39
- /** sets `border-left-color` property (no bidirectional support) */
40
- borderLeftColor?: CanvasColor | (string & {});
41
- };
42
-
43
- /** style props to set the border radius properties */
44
- export type BorderRadiusStyleProps = {
45
- /** sets `border-radius` property */
46
- borderRadius?: CanvasBorderRadiusKeys | number | (string & {});
47
- /** sets `border-top-left-radius` property */
48
- borderTopLeftRadius?: CanvasBorderRadiusKeys | number | (string & {});
49
- /** sets `border-top-right-radius` property */
50
- borderTopRightRadius?: CanvasBorderRadiusKeys | number | (string & {});
51
- /** sets `border-bottom-left-radius` property */
52
- borderBottomLeftRadius?: CanvasBorderRadiusKeys | number | (string & {});
53
- /** sets `border-bottom-right-radius` property */
54
- borderBottomRightRadius?: CanvasBorderRadiusKeys | number | (string & {});
55
- };
56
-
57
- /** style props to set the border style properties */
58
- export type BorderLineStyleProps = {
59
- /** sets `border-style` property */
60
- borderStyle?: Property.Border;
61
- /** sets `border-top-style` property */
62
- borderTopStyle?: Property.Border;
63
- /** sets `border-right-style` property (no bidirectional support) */
64
- borderRightStyle?: Property.Border;
65
- /** sets `border-bottom-style` property */
66
- borderBottomStyle?: Property.Border;
67
- /** sets `border-left-style` property (no bidirectional support) */
68
- borderLeftStyle?: Property.Border;
69
- };
70
-
71
- /** style props to set the border width properties */
72
- export type BorderWidthStyleProps = {
73
- /** sets `border-width` property */
74
- borderWidth?: string | number;
75
- /** sets `border-top-width` property */
76
- borderTopWidth?: string | number;
77
- /** sets `border-right-width` property (no bidirectional support) */
78
- borderRightWidth?: string | number;
79
- /** sets `border-bottom-width` property */
80
- borderBottomWidth?: string | number;
81
- /** sets `border-left-width` property (no bidirectional support) */
82
- borderLeftWidth?: string | number;
83
- };
84
-
85
- export type BorderLogicalStyleProps = {
86
- /** sets `border-left` property (bidirectional support) */
87
- borderInlineStart?: string;
88
- /** sets `border-left-color` property (bidirectional support) */
89
- borderInlineStartColor?: CanvasColor | (string & {});
90
- /** sets `border-left-style` property (bidirectional support) */
91
- borderInlineStartStyle?: Property.Border;
92
- /** sets `border-left-width` property (bidirectional support) */
93
- borderInlineStartWidth?: string | number;
94
- /** sets `border-right` property (bidirectional support) */
95
- borderInlineEnd?: string;
96
- /** sets `border-right-color` property (bidirectional support) */
97
- borderInlineEndColor?: CanvasColor | (string & {});
98
- /** sets `border-right-style` property (bidirectional support) */
99
- borderInlineEndStyle?: Property.Border;
100
- /** sets `border-right-width` property (bidirectional support) */
101
- borderInlineEndWidth?: string | number;
102
- };
103
-
104
- /** a collection style props for border properties */
105
- export type BorderStyleProps = BorderShorthandStyleProps &
106
- BorderColorStyleProps &
107
- BorderRadiusStyleProps &
108
- BorderLineStyleProps &
109
- BorderWidthStyleProps &
110
- BorderLogicalStyleProps;
111
-
112
- // border logical prop handlers
113
- const borderInlineStart = (isRTL: boolean) => (isRTL ? 'borderRight' : 'borderLeft');
114
- const borderInlineEnd = (isRTL: boolean) => (isRTL ? 'borderLeft' : 'borderRight');
115
- const borderInlineStartColor = (isRTL: boolean) => (isRTL ? 'borderRightColor' : 'borderLeftColor');
116
- const borderInlineEndColor = (isRTL: boolean) => (isRTL ? 'borderLeftColor' : 'borderRightColor');
117
- const borderInlineStartStyle = (isRTL: boolean) => (isRTL ? 'borderRightStyle' : 'borderLeftStyle');
118
- const borderInlineEndStyle = (isRTL: boolean) => (isRTL ? 'borderLeftStyle' : 'borderRightStyle');
119
- const borderInlineStartWidth = (isRTL: boolean) => (isRTL ? 'borderRightWidth' : 'borderLeftWidth');
120
- const borderInlineEndWidth = (isRTL: boolean) => (isRTL ? 'borderLeftWidth' : 'borderRightWidth');
121
-
122
- const borderShorthandProps = {
123
- border: 'border',
124
- borderTop: 'borderTop',
125
- borderRight: 'borderRight',
126
- borderBottom: 'borderBottom',
127
- borderLeft: 'borderLeft',
128
- borderInlineStart,
129
- borderInlineEnd,
130
- };
131
-
132
- const borderColors = {
133
- borderColor: 'borderColor',
134
- borderTopColor: 'borderTopColor',
135
- borderRightColor: 'borderRightColor',
136
- borderBottomColor: 'borderBottomColor',
137
- borderLeftColor: 'borderLeftColor',
138
- borderInlineStartColor,
139
- borderInlineEndColor,
140
- };
141
-
142
- const borderRadii = {
143
- borderRadius: 'borderRadius',
144
- borderTopLeftRadius: 'borderTopLeftRadius',
145
- borderTopRightRadius: 'borderTopRightRadius',
146
- borderBottomLeftRadius: 'borderBottomLeftRadius',
147
- borderBottomRightRadius: 'borderBottomRightRadius',
148
- };
149
-
150
- const borderStyles = {
151
- borderStyle: 'borderStyle',
152
- borderTopStyle: 'borderTopStyle',
153
- borderRightStyle: 'borderRightStyle',
154
- borderBottomStyle: 'borderBottomStyle',
155
- borderLeftStyle: 'borderLeftStyle',
156
- borderInlineStartStyle,
157
- borderInlineEndStyle,
158
- };
159
-
160
- const borderWidths = {
161
- borderWidth: 'borderWidth',
162
- borderTopWidth: 'borderTopWidth',
163
- borderRightWidth: 'borderRightWidth',
164
- borderBottomWidth: 'borderBottomWidth',
165
- borderLeftWidth: 'borderLeftWidth',
166
- borderInlineStartWidth,
167
- borderInlineEndWidth,
168
- };
169
-
170
- /**
171
- * A style prop function that takes components props and returns border styles. Some props, such as borderRadius and borderColor, are connected to our design tokens.
172
- * If no `BorderStyleProps` are found, it returns an empty object.
173
- *
174
- * @example
175
- * // You'll most likely use `border` with low-level, styled components
176
- * const BoxExample = () => (
177
- * <Box border={`solid 1px #333333 ${colors.blackPepper400}`}>Hello, border styles!</Box>
178
- * );
179
- *
180
- */
181
- export function border<P extends BorderStyleProps & {theme?: PartialEmotionCanvasTheme}>(props: P) {
182
- // border will always be used within the context of a component, but eslint doesn't know that
183
- // eslint-disable-next-line react-hooks/rules-of-hooks
184
- const {canvas} = useTheme(props.theme);
185
- const isRTL = canvas.direction === ContentDirection.RTL;
186
- const styles = {};
187
- for (const key in props) {
188
- if (props.hasOwnProperty(key)) {
189
- if (key in borderShorthandProps) {
190
- const value = props[key as keyof BorderShorthandStyleProps];
191
- let attr: string;
192
- if (key === 'borderInlineStart') {
193
- attr = borderInlineStart(isRTL);
194
- } else if (key === 'borderInlineEnd') {
195
- attr = borderInlineEnd(isRTL);
196
- } else {
197
- attr = borderShorthandProps[key as keyof BorderShorthandStyleProps];
198
- }
199
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
200
- styles[attr] = value;
201
- continue;
202
- }
203
-
204
- if (key in borderColors) {
205
- const propValue = props[key as keyof BorderColorStyleProps] as CanvasColor | string;
206
- const value = colorTokens[propValue as CanvasColor] || propValue;
207
- let attr: string;
208
- if (key === 'borderInlineStartColor') {
209
- attr = borderInlineStartColor(isRTL);
210
- } else if (key === 'borderInlineEndColor') {
211
- attr = borderInlineEndColor(isRTL);
212
- } else {
213
- attr = borderColors[key as keyof BorderColorStyleProps];
214
- }
215
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
216
- styles[attr] = value;
217
- continue;
218
- }
219
-
220
- if (key in borderRadii) {
221
- const propValue = props[key as keyof BorderRadiusStyleProps] as
222
- | CanvasBorderRadiusKeys
223
- | number
224
- | string;
225
- const value = borderRadiusTokens[propValue as CanvasBorderRadiusKeys] || propValue;
226
- const attr = borderRadii[key as keyof BorderRadiusStyleProps];
227
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
228
- styles[attr] = value;
229
- continue;
230
- }
231
-
232
- if (key in borderStyles) {
233
- const value = props[key as keyof BorderLineStyleProps];
234
- let attr: string;
235
- if (key === 'borderInlineStartStyle') {
236
- attr = borderInlineStartStyle(isRTL);
237
- } else if (key === 'borderInlineEndStyle') {
238
- attr = borderInlineEndStyle(isRTL);
239
- } else {
240
- attr = borderStyles[key as keyof BorderLineStyleProps];
241
- }
242
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
243
- styles[attr] = value;
244
- continue;
245
- }
246
-
247
- if (key in borderWidths) {
248
- const value = props[key as keyof BorderWidthStyleProps];
249
- let attr: string;
250
- if (key === 'borderInlineStartWidth') {
251
- attr = borderInlineStartWidth(isRTL);
252
- } else if (key === 'borderInlineEndWidth') {
253
- attr = borderInlineEndWidth(isRTL);
254
- } else {
255
- attr = borderWidths[key as keyof BorderWidthStyleProps];
256
- }
257
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
258
- styles[attr] = value;
259
- }
260
- }
261
- }
262
- return styles;
263
- }