@workday/canvas-kit-labs-react 7.0.0-alpha.0-next.6 → 7.0.0-alpha.79-next.7

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 (197) hide show
  1. package/combobox/README.md +1 -1
  2. package/combobox/lib/Combobox.tsx +7 -11
  3. package/common/index.ts +0 -8
  4. package/dist/commonjs/combobox/lib/Combobox.d.ts +3 -4
  5. package/dist/commonjs/combobox/lib/Combobox.d.ts.map +1 -1
  6. package/dist/commonjs/combobox/lib/Combobox.js +4 -7
  7. package/dist/commonjs/common/index.d.ts +0 -8
  8. package/dist/commonjs/common/index.d.ts.map +1 -1
  9. package/dist/commonjs/common/index.js +0 -1
  10. package/dist/commonjs/drawer/lib/DrawerHeader.js +2 -2
  11. package/dist/commonjs/index.d.ts +0 -1
  12. package/dist/commonjs/index.d.ts.map +1 -1
  13. package/dist/commonjs/index.js +0 -1
  14. package/dist/commonjs/search-form/lib/SearchForm.d.ts +7 -2
  15. package/dist/commonjs/search-form/lib/SearchForm.d.ts.map +1 -1
  16. package/dist/commonjs/search-form/lib/SearchForm.js +16 -22
  17. package/dist/es6/combobox/lib/Combobox.d.ts +3 -4
  18. package/dist/es6/combobox/lib/Combobox.d.ts.map +1 -1
  19. package/dist/es6/combobox/lib/Combobox.js +5 -8
  20. package/dist/es6/common/index.d.ts +0 -8
  21. package/dist/es6/common/index.d.ts.map +1 -1
  22. package/dist/es6/common/index.js +0 -1
  23. package/dist/es6/drawer/lib/DrawerHeader.js +3 -3
  24. package/dist/es6/index.d.ts +0 -1
  25. package/dist/es6/index.d.ts.map +1 -1
  26. package/dist/es6/index.js +0 -1
  27. package/dist/es6/search-form/lib/SearchForm.d.ts +7 -2
  28. package/dist/es6/search-form/lib/SearchForm.d.ts.map +1 -1
  29. package/dist/es6/search-form/lib/SearchForm.js +17 -23
  30. package/drawer/lib/DrawerHeader.tsx +3 -3
  31. package/index.ts +0 -1
  32. package/package.json +4 -6
  33. package/search-form/lib/SearchForm.tsx +25 -37
  34. package/ts3.5/dist/commonjs/combobox/lib/Combobox.d.ts +3 -4
  35. package/ts3.5/dist/commonjs/common/index.d.ts +0 -8
  36. package/ts3.5/dist/commonjs/index.d.ts +0 -1
  37. package/ts3.5/dist/commonjs/search-form/lib/SearchForm.d.ts +7 -2
  38. package/ts3.5/dist/es6/combobox/lib/Combobox.d.ts +3 -4
  39. package/ts3.5/dist/es6/common/index.d.ts +0 -8
  40. package/ts3.5/dist/es6/index.d.ts +0 -1
  41. package/ts3.5/dist/es6/search-form/lib/SearchForm.d.ts +7 -2
  42. package/common/lib/Box.tsx +0 -92
  43. package/common/lib/utils/border.ts +0 -263
  44. package/common/lib/utils/color.ts +0 -62
  45. package/common/lib/utils/depth.ts +0 -37
  46. package/common/lib/utils/flexItem.ts +0 -56
  47. package/common/lib/utils/layout.ts +0 -77
  48. package/common/lib/utils/other.ts +0 -20
  49. package/common/lib/utils/position.ts +0 -96
  50. package/common/lib/utils/space.ts +0 -207
  51. package/common/lib/utils/types.ts +0 -105
  52. package/dist/commonjs/common/lib/Box.d.ts +0 -31
  53. package/dist/commonjs/common/lib/Box.d.ts.map +0 -1
  54. package/dist/commonjs/common/lib/Box.js +0 -99
  55. package/dist/commonjs/common/lib/utils/border.d.ts +0 -103
  56. package/dist/commonjs/common/lib/utils/border.d.ts.map +0 -1
  57. package/dist/commonjs/common/lib/utils/border.js +0 -153
  58. package/dist/commonjs/common/lib/utils/color.d.ts +0 -26
  59. package/dist/commonjs/common/lib/utils/color.d.ts.map +0 -1
  60. package/dist/commonjs/common/lib/utils/color.js +0 -57
  61. package/dist/commonjs/common/lib/utils/depth.d.ts +0 -22
  62. package/dist/commonjs/common/lib/utils/depth.d.ts.map +0 -1
  63. package/dist/commonjs/common/lib/utils/depth.js +0 -29
  64. package/dist/commonjs/common/lib/utils/flexItem.d.ts +0 -33
  65. package/dist/commonjs/common/lib/utils/flexItem.d.ts.map +0 -1
  66. package/dist/commonjs/common/lib/utils/flexItem.js +0 -39
  67. package/dist/commonjs/common/lib/utils/layout.d.ts +0 -43
  68. package/dist/commonjs/common/lib/utils/layout.d.ts.map +0 -1
  69. package/dist/commonjs/common/lib/utils/layout.js +0 -43
  70. package/dist/commonjs/common/lib/utils/other.d.ts +0 -5
  71. package/dist/commonjs/common/lib/utils/other.d.ts.map +0 -1
  72. package/dist/commonjs/common/lib/utils/other.js +0 -19
  73. package/dist/commonjs/common/lib/utils/position.d.ts +0 -41
  74. package/dist/commonjs/common/lib/utils/position.d.ts.map +0 -1
  75. package/dist/commonjs/common/lib/utils/position.js +0 -78
  76. package/dist/commonjs/common/lib/utils/space.d.ts +0 -64
  77. package/dist/commonjs/common/lib/utils/space.d.ts.map +0 -1
  78. package/dist/commonjs/common/lib/utils/space.js +0 -161
  79. package/dist/commonjs/common/lib/utils/types.d.ts +0 -14
  80. package/dist/commonjs/common/lib/utils/types.d.ts.map +0 -1
  81. package/dist/commonjs/common/lib/utils/types.js +0 -2
  82. package/dist/commonjs/layout/index.d.ts +0 -5
  83. package/dist/commonjs/layout/index.d.ts.map +0 -1
  84. package/dist/commonjs/layout/index.js +0 -14
  85. package/dist/commonjs/layout/lib/Flex.d.ts +0 -26
  86. package/dist/commonjs/layout/lib/Flex.d.ts.map +0 -1
  87. package/dist/commonjs/layout/lib/Flex.js +0 -83
  88. package/dist/commonjs/layout/lib/Stack.d.ts +0 -27
  89. package/dist/commonjs/layout/lib/Stack.d.ts.map +0 -1
  90. package/dist/commonjs/layout/lib/Stack.js +0 -99
  91. package/dist/commonjs/layout/lib/utils/flex.d.ts +0 -36
  92. package/dist/commonjs/layout/lib/utils/flex.d.ts.map +0 -1
  93. package/dist/commonjs/layout/lib/utils/flex.js +0 -38
  94. package/dist/commonjs/layout/lib/utils/getValidChildren.d.ts +0 -3
  95. package/dist/commonjs/layout/lib/utils/getValidChildren.d.ts.map +0 -1
  96. package/dist/commonjs/layout/lib/utils/getValidChildren.js +0 -29
  97. package/dist/commonjs/layout/lib/utils/stack.d.ts +0 -26
  98. package/dist/commonjs/layout/lib/utils/stack.d.ts.map +0 -1
  99. package/dist/commonjs/layout/lib/utils/stack.js +0 -55
  100. package/dist/commonjs/layout/lib/utils/types.d.ts +0 -8
  101. package/dist/commonjs/layout/lib/utils/types.d.ts.map +0 -1
  102. package/dist/commonjs/layout/lib/utils/types.js +0 -2
  103. package/dist/es6/common/lib/Box.d.ts +0 -31
  104. package/dist/es6/common/lib/Box.d.ts.map +0 -1
  105. package/dist/es6/common/lib/Box.js +0 -74
  106. package/dist/es6/common/lib/utils/border.d.ts +0 -103
  107. package/dist/es6/common/lib/utils/border.d.ts.map +0 -1
  108. package/dist/es6/common/lib/utils/border.js +0 -149
  109. package/dist/es6/common/lib/utils/color.d.ts +0 -26
  110. package/dist/es6/common/lib/utils/color.d.ts.map +0 -1
  111. package/dist/es6/common/lib/utils/color.js +0 -53
  112. package/dist/es6/common/lib/utils/depth.d.ts +0 -22
  113. package/dist/es6/common/lib/utils/depth.d.ts.map +0 -1
  114. package/dist/es6/common/lib/utils/depth.js +0 -25
  115. package/dist/es6/common/lib/utils/flexItem.d.ts +0 -33
  116. package/dist/es6/common/lib/utils/flexItem.d.ts.map +0 -1
  117. package/dist/es6/common/lib/utils/flexItem.js +0 -35
  118. package/dist/es6/common/lib/utils/layout.d.ts +0 -43
  119. package/dist/es6/common/lib/utils/layout.d.ts.map +0 -1
  120. package/dist/es6/common/lib/utils/layout.js +0 -39
  121. package/dist/es6/common/lib/utils/other.d.ts +0 -5
  122. package/dist/es6/common/lib/utils/other.d.ts.map +0 -1
  123. package/dist/es6/common/lib/utils/other.js +0 -15
  124. package/dist/es6/common/lib/utils/position.d.ts +0 -41
  125. package/dist/es6/common/lib/utils/position.d.ts.map +0 -1
  126. package/dist/es6/common/lib/utils/position.js +0 -74
  127. package/dist/es6/common/lib/utils/space.d.ts +0 -64
  128. package/dist/es6/common/lib/utils/space.d.ts.map +0 -1
  129. package/dist/es6/common/lib/utils/space.js +0 -157
  130. package/dist/es6/common/lib/utils/types.d.ts +0 -14
  131. package/dist/es6/common/lib/utils/types.d.ts.map +0 -1
  132. package/dist/es6/common/lib/utils/types.js +0 -1
  133. package/dist/es6/layout/index.d.ts +0 -5
  134. package/dist/es6/layout/index.d.ts.map +0 -1
  135. package/dist/es6/layout/index.js +0 -2
  136. package/dist/es6/layout/lib/Flex.d.ts +0 -26
  137. package/dist/es6/layout/lib/Flex.d.ts.map +0 -1
  138. package/dist/es6/layout/lib/Flex.js +0 -58
  139. package/dist/es6/layout/lib/Stack.d.ts +0 -27
  140. package/dist/es6/layout/lib/Stack.d.ts.map +0 -1
  141. package/dist/es6/layout/lib/Stack.js +0 -74
  142. package/dist/es6/layout/lib/utils/flex.d.ts +0 -36
  143. package/dist/es6/layout/lib/utils/flex.d.ts.map +0 -1
  144. package/dist/es6/layout/lib/utils/flex.js +0 -34
  145. package/dist/es6/layout/lib/utils/getValidChildren.d.ts +0 -3
  146. package/dist/es6/layout/lib/utils/getValidChildren.d.ts.map +0 -1
  147. package/dist/es6/layout/lib/utils/getValidChildren.js +0 -6
  148. package/dist/es6/layout/lib/utils/stack.d.ts +0 -26
  149. package/dist/es6/layout/lib/utils/stack.d.ts.map +0 -1
  150. package/dist/es6/layout/lib/utils/stack.js +0 -51
  151. package/dist/es6/layout/lib/utils/types.d.ts +0 -8
  152. package/dist/es6/layout/lib/utils/types.d.ts.map +0 -1
  153. package/dist/es6/layout/lib/utils/types.js +0 -1
  154. package/layout/LICENSE +0 -52
  155. package/layout/README.md +0 -16
  156. package/layout/index.ts +0 -4
  157. package/layout/lib/Flex.tsx +0 -47
  158. package/layout/lib/Stack.tsx +0 -95
  159. package/layout/lib/utils/flex.ts +0 -65
  160. package/layout/lib/utils/getValidChildren.ts +0 -7
  161. package/layout/lib/utils/stack.ts +0 -78
  162. package/layout/lib/utils/types.ts +0 -45
  163. package/layout/package.json +0 -5
  164. package/ts3.5/dist/commonjs/common/lib/Box.d.ts +0 -31
  165. package/ts3.5/dist/commonjs/common/lib/utils/border.d.ts +0 -103
  166. package/ts3.5/dist/commonjs/common/lib/utils/color.d.ts +0 -26
  167. package/ts3.5/dist/commonjs/common/lib/utils/depth.d.ts +0 -22
  168. package/ts3.5/dist/commonjs/common/lib/utils/flexItem.d.ts +0 -33
  169. package/ts3.5/dist/commonjs/common/lib/utils/layout.d.ts +0 -43
  170. package/ts3.5/dist/commonjs/common/lib/utils/other.d.ts +0 -5
  171. package/ts3.5/dist/commonjs/common/lib/utils/position.d.ts +0 -41
  172. package/ts3.5/dist/commonjs/common/lib/utils/space.d.ts +0 -64
  173. package/ts3.5/dist/commonjs/common/lib/utils/types.d.ts +0 -14
  174. package/ts3.5/dist/commonjs/layout/index.d.ts +0 -5
  175. package/ts3.5/dist/commonjs/layout/lib/Flex.d.ts +0 -26
  176. package/ts3.5/dist/commonjs/layout/lib/Stack.d.ts +0 -27
  177. package/ts3.5/dist/commonjs/layout/lib/utils/flex.d.ts +0 -36
  178. package/ts3.5/dist/commonjs/layout/lib/utils/getValidChildren.d.ts +0 -3
  179. package/ts3.5/dist/commonjs/layout/lib/utils/stack.d.ts +0 -26
  180. package/ts3.5/dist/commonjs/layout/lib/utils/types.d.ts +0 -8
  181. package/ts3.5/dist/es6/common/lib/Box.d.ts +0 -31
  182. package/ts3.5/dist/es6/common/lib/utils/border.d.ts +0 -103
  183. package/ts3.5/dist/es6/common/lib/utils/color.d.ts +0 -26
  184. package/ts3.5/dist/es6/common/lib/utils/depth.d.ts +0 -22
  185. package/ts3.5/dist/es6/common/lib/utils/flexItem.d.ts +0 -33
  186. package/ts3.5/dist/es6/common/lib/utils/layout.d.ts +0 -43
  187. package/ts3.5/dist/es6/common/lib/utils/other.d.ts +0 -5
  188. package/ts3.5/dist/es6/common/lib/utils/position.d.ts +0 -41
  189. package/ts3.5/dist/es6/common/lib/utils/space.d.ts +0 -64
  190. package/ts3.5/dist/es6/common/lib/utils/types.d.ts +0 -14
  191. package/ts3.5/dist/es6/layout/index.d.ts +0 -5
  192. package/ts3.5/dist/es6/layout/lib/Flex.d.ts +0 -26
  193. package/ts3.5/dist/es6/layout/lib/Stack.d.ts +0 -27
  194. package/ts3.5/dist/es6/layout/lib/utils/flex.d.ts +0 -36
  195. package/ts3.5/dist/es6/layout/lib/utils/getValidChildren.d.ts +0 -3
  196. package/ts3.5/dist/es6/layout/lib/utils/stack.d.ts +0 -26
  197. package/ts3.5/dist/es6/layout/lib/utils/types.d.ts +0 -8
@@ -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 {PropertyBorder} from './types';
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?: PropertyBorder;
61
- /** sets `border-top-style` property */
62
- borderTopStyle?: PropertyBorder;
63
- /** sets `border-right-style` property (no bidirectional support) */
64
- borderRightStyle?: PropertyBorder;
65
- /** sets `border-bottom-style` property */
66
- borderBottomStyle?: PropertyBorder;
67
- /** sets `border-left-style` property (no bidirectional support) */
68
- borderLeftStyle?: PropertyBorder;
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?: PropertyBorder;
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?: PropertyBorder;
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
- }
@@ -1,62 +0,0 @@
1
- import {colors as colorTokens, CanvasColor} from '@workday/canvas-kit-react/tokens';
2
-
3
- export type ColorTokens = typeof colorTokens;
4
-
5
- /** style props to for color properties */
6
- export type ColorStyleProps = {
7
- /** sets `background` property */
8
- background?: CanvasColor | (string & {});
9
- /** sets `background-color` property */
10
- backgroundColor?: CanvasColor | (string & {});
11
- /** sets `background-image` property */
12
- backgroundImage?: string;
13
- /** sets `color` property */
14
- color?: CanvasColor | (string & {});
15
- };
16
-
17
- const getBackground = (value: CanvasColor | string) => ({
18
- background: colorTokens[value] || value,
19
- });
20
-
21
- const getBackgroundColor = (value: CanvasColor | string) => ({
22
- backgroundColor: colorTokens[value] || value,
23
- });
24
-
25
- const getBackgroundImage = (value: string) => ({
26
- backgroundImage: value,
27
- });
28
-
29
- const getColor = (value: CanvasColor | string) => ({
30
- color: colorTokens[value] || value,
31
- });
32
-
33
- const colorProps = {
34
- background: getBackground,
35
- backgroundColor: getBackgroundColor,
36
- backgroundImage: getBackgroundImage,
37
- color: getColor,
38
- };
39
-
40
- /**
41
- * A style prop function that takes components props and returns color styles from canvas token values.
42
- * If no `ColorStyleProps` are found, it returns an empty object.
43
- *
44
- * @example
45
- * // You'll most likely use `color` with low-level, styled components
46
- * const BoxExample = () => (
47
- * <Box backgroundColor="blueberry500" color="frenchVanilla100">Hello, colors!</Box>
48
- * );
49
- *
50
- */
51
- export function color<P extends ColorStyleProps>(props: P) {
52
- let styles = {};
53
- for (const key in props) {
54
- if (key in colorProps) {
55
- const value = props[key as keyof ColorStyleProps] as CanvasColor | string;
56
- const colorFn = colorProps[key as keyof ColorStyleProps];
57
- const style = colorFn(value);
58
- styles = {...styles, ...style};
59
- }
60
- }
61
- return styles;
62
- }
@@ -1,37 +0,0 @@
1
- import {depth as depthTokens} from '@workday/canvas-kit-react/tokens';
2
-
3
- export type DepthTokens = typeof depthTokens;
4
- export type DepthTokenKeys = keyof DepthTokens;
5
- export type DepthTokenValues = DepthTokens[keyof DepthTokens];
6
-
7
- /** style props to for depth styles */
8
- export type DepthStyleProps = {
9
- /** sets depth styles (box-shadow & border) */
10
- depth?: DepthTokenKeys;
11
- };
12
-
13
- const depthProps = {
14
- depth: (token: DepthTokenKeys) => depthTokens[token],
15
- };
16
-
17
- /**
18
- * A style prop function that takes components props and returns depth styles from canvas token values.
19
- * If no `DepthStyleProps` are found, it returns an empty object.
20
- *
21
- * @example
22
- * // You'll mostly likely use `depth` with low-level, styled components
23
- * const BoxExample = () => (
24
- * <Box depth={3}>Hello, box shadows!</Box>
25
- * );
26
- *
27
- */
28
- export function depth<P extends DepthStyleProps>(props: P): DepthTokenValues {
29
- for (const key in props) {
30
- if (key in depthProps) {
31
- const token = props[key as keyof DepthStyleProps] as DepthTokenKeys;
32
- const depthFn = depthProps[key as keyof DepthStyleProps];
33
- return depthFn(token);
34
- }
35
- }
36
- return {} as DepthTokenValues;
37
- }
@@ -1,56 +0,0 @@
1
- import {PropertyJustifySelf, PropertyAlignSelf, PropertyOrder} from './types';
2
-
3
- /** style props to for flexbox item properties */
4
- export type FlexItemStyleProps = {
5
- /** sets `flex` property */
6
- flex?: number | string;
7
- /** sets `flex-grow` property */
8
- flexGrow?: number | string;
9
- /** sets `flex-shrink` property */
10
- flexShrink?: number | string;
11
- /** sets `flex-basis` property */
12
- flexBasis?: number | string;
13
- /** sets `justify-self` property */
14
- justifySelf?: PropertyJustifySelf;
15
- /** sets `align-self` property */
16
- alignSelf?: PropertyAlignSelf;
17
- /** sets `order` property */
18
- order?: PropertyOrder;
19
- };
20
-
21
- /** style props to for flexbox item properties */
22
- const flexItemProps = {
23
- flex: 'flex',
24
- flexGrow: 'flexGrow',
25
- flexShrink: 'flexShrink',
26
- flexBasis: 'flexBasis',
27
- justifySelf: 'justifySelf',
28
- alignSelf: 'alignSelf',
29
- order: 'order',
30
- };
31
-
32
- /**
33
- * A style prop function that takes component props and returns flexbox item styles.
34
- * If no `FlexItemStyleProps` are found, it returns an empty object.
35
- *
36
- * @example
37
- * // You'll most likely use `flexItem` with low-level, styled components
38
- * const FlexItemExample = () => (
39
- * <Box flex={1} flexBasis="auto" alignSelf={center}>
40
- * Hello, flex item!
41
- * </Box>
42
- * );
43
- *
44
- */
45
- export function flexItem<P extends FlexItemStyleProps>(props: P) {
46
- const styles = {};
47
- for (const key in props) {
48
- if (key in flexItemProps) {
49
- const attr = flexItemProps[key as keyof FlexItemStyleProps];
50
- const value = props[key];
51
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
52
- styles[attr] = value;
53
- }
54
- }
55
- return styles;
56
- }
@@ -1,77 +0,0 @@
1
- import {
2
- PropertyDisplay,
3
- PropertyListStyle,
4
- PropertyOverflow,
5
- PropertyOverflowX,
6
- PropertyOverflowY,
7
- PropertyVerticalAlign,
8
- } from './types';
9
-
10
- /** style props to for layout properties */
11
- export type LayoutStyleProps = {
12
- /** sets `display` property */
13
- display?: PropertyDisplay;
14
- /** sets `height` property */
15
- height?: number | string;
16
- /** sets `list-style property */
17
- listStyle?: PropertyListStyle;
18
- /** sets `max-height` property */
19
- maxHeight?: number | string;
20
- /** sets `max-width` property */
21
- maxWidth?: number | string;
22
- /** sets `min-height` property */
23
- minHeight?: number | string;
24
- /** sets `min-width` property */
25
- minWidth?: number | string;
26
- /** sets `overflow` property */
27
- overflow?: PropertyOverflow;
28
- /** sets `overflow-x` property */
29
- overflowX?: PropertyOverflowX;
30
- /** sets `overflow-y` property */
31
- overflowY?: PropertyOverflowY;
32
- /** sets `vertical-align` property */
33
- verticalAlign?: PropertyVerticalAlign;
34
- /** sets `width` property */
35
- width?: number | string;
36
- };
37
-
38
- const layoutProps = {
39
- display: 'display',
40
- height: 'height',
41
- listStyle: 'listStyle',
42
- maxHeight: 'maxHeight',
43
- maxWidth: 'maxWidth',
44
- minHeight: 'minHeight',
45
- minWidth: 'minWidth',
46
- overflow: 'overflow',
47
- overflowX: 'overflowX',
48
- overflowY: 'overflowY',
49
- verticalAlign: 'verticalAlign',
50
- width: 'width',
51
- };
52
-
53
- /**
54
- * A style prop function that takes components props and returns layout styles.
55
- * If no `LayoutStyleProps` are found, it returns an empty object.
56
- *
57
- * @example
58
- * // You'll most likely use `layout` with low-level, styled components
59
- * const BoxExample = () => (
60
- * <Box display="inline-block" height="50%">
61
- * Hello, positions!
62
- * </Box>
63
- * );
64
- *
65
- */
66
- export function layout<P extends LayoutStyleProps>(props: P) {
67
- const styles = {};
68
- for (const key in props) {
69
- if (key in layoutProps) {
70
- const attr = layoutProps[key as keyof LayoutStyleProps];
71
- const value = props[key];
72
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
73
- styles[attr] = value;
74
- }
75
- }
76
- return styles;
77
- }
@@ -1,20 +0,0 @@
1
- export type OtherStyleProps = {
2
- animation?: string;
3
- };
4
-
5
- const otherProps = {
6
- animation: (value: string) => {
7
- return {animation: value};
8
- },
9
- };
10
-
11
- export function other<P extends OtherStyleProps>(props: P) {
12
- for (const key in props) {
13
- if (key in otherProps) {
14
- const value = props[key as keyof OtherStyleProps] as keyof OtherStyleProps;
15
- const styleFn = otherProps[key as keyof OtherStyleProps];
16
- return styleFn(value);
17
- }
18
- }
19
- return {};
20
- }
@@ -1,96 +0,0 @@
1
- import {
2
- ContentDirection,
3
- PartialEmotionCanvasTheme,
4
- useTheme,
5
- } from '@workday/canvas-kit-react/common';
6
- import {PropertyPosition, PropertyZIndex} from './types';
7
-
8
- /** style props to for standard position properties */
9
- export type PositionStandardProps = {
10
- /** sets `position` property */
11
- position?: PropertyPosition;
12
- /** sets `zIndex` property */
13
- zIndex?: PropertyZIndex;
14
- /** sets `top` property */
15
- top?: number | string;
16
- /** sets `right` property (no bidirectional support) */
17
- right?: number | string;
18
- /** sets `bottom` property */
19
- bottom?: number | string;
20
- /** sets `left` property (no bidirectional support) */
21
- left?: number | string;
22
- };
23
-
24
- export type PositionLogicalProps = {
25
- /** sets `left` property (bidirectional support) */
26
- insetInlineStart?: number | string;
27
- /** sets `right` property (bidirectional support) */
28
- insetInlineEnd?: number | string;
29
- };
30
-
31
- const getInsetInlineStartStyle = (value: number | string, isRTL = false) => {
32
- const attr = isRTL ? 'right' : 'left';
33
- return {[attr]: value};
34
- };
35
-
36
- const getInsetInlineEndStyle = (value: number | string, isRTL = false) => {
37
- const attr = isRTL ? 'left' : 'right';
38
- return {[attr]: value};
39
- };
40
-
41
- const standardPositionProps = {
42
- position: 'position',
43
- zIndex: 'zIndex',
44
- top: 'top',
45
- right: 'right',
46
- bottom: 'bottom',
47
- left: 'left',
48
- };
49
-
50
- const logicalPositionProps = {
51
- insetInlineStart: getInsetInlineStartStyle,
52
- insetInlineEnd: getInsetInlineEndStyle,
53
- };
54
-
55
- export type PositionStyleProps = PositionStandardProps & PositionLogicalProps;
56
-
57
- /**
58
- * A style prop function that takes components props and returns position styles.
59
- * If no `PositionProps` are found, it returns an empty object.
60
- *
61
- * @example
62
- * // You'll most likely use `position` with low-level, styled components
63
- * const BoxExample = () => (
64
- * <Box position="absolute" top="50%">
65
- * Hello, positions!
66
- * </Box>
67
- * );
68
- *
69
- */
70
- export function position<P extends PositionStyleProps & {theme?: PartialEmotionCanvasTheme}>(
71
- props: P
72
- ) {
73
- // position will always be used within the context of a component, but eslint doesn't know that
74
- // eslint-disable-next-line react-hooks/rules-of-hooks
75
- const {canvas} = useTheme(props.theme);
76
- let styles = {};
77
- for (const key in props) {
78
- if (key in props) {
79
- if (key in standardPositionProps) {
80
- const value = props[key];
81
- const attr = standardPositionProps[key as keyof PositionStandardProps];
82
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
83
- styles[attr] = value;
84
- continue;
85
- }
86
- if (key in logicalPositionProps) {
87
- const value = props[key as keyof PositionLogicalProps] as string | number;
88
- const styleFn = logicalPositionProps[key as keyof PositionLogicalProps];
89
- const isRTL = canvas.direction === ContentDirection.RTL;
90
- const style = styleFn(value, isRTL);
91
- styles = {...styles, ...style};
92
- }
93
- }
94
- }
95
- return styles;
96
- }