@workday/canvas-kit-labs-react 7.1.4 → 7.2.0-427-next.2

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 (207) hide show
  1. package/combobox/README.md +4 -4
  2. package/combobox/index.ts +0 -4
  3. package/combobox/lib/AutocompleteList.tsx +5 -8
  4. package/combobox/lib/Combobox.tsx +14 -20
  5. package/combobox/lib/Status.tsx +1 -3
  6. package/combobox/package.json +2 -1
  7. package/common/index.ts +0 -2
  8. package/common/lib/theming/index.ts +0 -1
  9. package/common/lib/theming/useThemeRTL.ts +14 -13
  10. package/common/package.json +2 -1
  11. package/dist/commonjs/combobox/index.d.ts +0 -3
  12. package/dist/commonjs/combobox/index.d.ts.map +1 -1
  13. package/dist/commonjs/combobox/index.js +0 -7
  14. package/dist/commonjs/combobox/lib/AutocompleteList.d.ts +4 -5
  15. package/dist/commonjs/combobox/lib/AutocompleteList.d.ts.map +1 -1
  16. package/dist/commonjs/combobox/lib/AutocompleteList.js +33 -53
  17. package/dist/commonjs/combobox/lib/Combobox.d.ts +4 -6
  18. package/dist/commonjs/combobox/lib/Combobox.d.ts.map +1 -1
  19. package/dist/commonjs/combobox/lib/Combobox.js +110 -142
  20. package/dist/commonjs/combobox/lib/Status.d.ts +1 -2
  21. package/dist/commonjs/combobox/lib/Status.d.ts.map +1 -1
  22. package/dist/commonjs/combobox/lib/Status.js +11 -11
  23. package/dist/commonjs/common/index.d.ts +0 -2
  24. package/dist/commonjs/common/index.d.ts.map +1 -1
  25. package/dist/commonjs/common/index.js +0 -5
  26. package/dist/commonjs/common/lib/theming/index.d.ts +0 -1
  27. package/dist/commonjs/common/lib/theming/index.d.ts.map +1 -1
  28. package/dist/commonjs/common/lib/theming/index.js +0 -1
  29. package/dist/commonjs/common/lib/theming/useThemeRTL.d.ts +3 -0
  30. package/dist/commonjs/common/lib/theming/useThemeRTL.d.ts.map +1 -1
  31. package/dist/commonjs/common/lib/theming/useThemeRTL.js +21 -46
  32. package/dist/commonjs/expandable/index.d.ts +3 -0
  33. package/dist/commonjs/expandable/index.d.ts.map +1 -0
  34. package/dist/commonjs/{drawer → expandable}/index.js +2 -10
  35. package/dist/commonjs/expandable/lib/Expandable.d.ts +108 -0
  36. package/dist/commonjs/expandable/lib/Expandable.d.ts.map +1 -0
  37. package/dist/commonjs/expandable/lib/Expandable.js +59 -0
  38. package/dist/commonjs/expandable/lib/ExpandableAvatar.d.ts +7 -0
  39. package/dist/commonjs/expandable/lib/ExpandableAvatar.d.ts.map +1 -0
  40. package/dist/commonjs/expandable/lib/ExpandableAvatar.js +23 -0
  41. package/dist/commonjs/expandable/lib/ExpandableContent.d.ts +21 -0
  42. package/dist/commonjs/expandable/lib/ExpandableContent.d.ts.map +1 -0
  43. package/dist/commonjs/expandable/lib/ExpandableContent.js +18 -0
  44. package/dist/commonjs/expandable/lib/ExpandableIcon.d.ts +29 -0
  45. package/dist/commonjs/expandable/lib/ExpandableIcon.d.ts.map +1 -0
  46. package/dist/commonjs/expandable/lib/ExpandableIcon.js +31 -0
  47. package/dist/commonjs/expandable/lib/ExpandableTarget.d.ts +33 -0
  48. package/dist/commonjs/expandable/lib/ExpandableTarget.d.ts.map +1 -0
  49. package/dist/commonjs/expandable/lib/ExpandableTarget.js +32 -0
  50. package/dist/commonjs/expandable/lib/ExpandableTitle.d.ts +11 -0
  51. package/dist/commonjs/expandable/lib/ExpandableTitle.d.ts.map +1 -0
  52. package/dist/commonjs/expandable/lib/ExpandableTitle.js +16 -0
  53. package/dist/commonjs/expandable/lib/hooks/index.d.ts +5 -0
  54. package/dist/commonjs/expandable/lib/hooks/index.d.ts.map +1 -0
  55. package/dist/commonjs/expandable/lib/hooks/index.js +16 -0
  56. package/dist/commonjs/expandable/lib/hooks/useExpandableContent.d.ts +18 -0
  57. package/dist/commonjs/expandable/lib/hooks/useExpandableContent.d.ts.map +1 -0
  58. package/dist/commonjs/expandable/lib/hooks/useExpandableContent.js +11 -0
  59. package/dist/commonjs/expandable/lib/hooks/useExpandableIcon.d.ts +13 -0
  60. package/dist/commonjs/expandable/lib/hooks/useExpandableIcon.d.ts.map +1 -0
  61. package/dist/commonjs/expandable/lib/hooks/useExpandableIcon.js +10 -0
  62. package/dist/commonjs/expandable/lib/hooks/useExpandableModel.d.ts +53 -0
  63. package/dist/commonjs/expandable/lib/hooks/useExpandableModel.d.ts.map +1 -0
  64. package/dist/commonjs/expandable/lib/hooks/useExpandableModel.js +22 -0
  65. package/dist/commonjs/expandable/lib/hooks/useExpandableTarget.d.ts +15 -0
  66. package/dist/commonjs/expandable/lib/hooks/useExpandableTarget.d.ts.map +1 -0
  67. package/dist/commonjs/expandable/lib/hooks/useExpandableTarget.js +19 -0
  68. package/dist/commonjs/index.d.ts +1 -2
  69. package/dist/commonjs/index.d.ts.map +1 -1
  70. package/dist/commonjs/index.js +1 -2
  71. package/dist/commonjs/search-form/lib/SearchForm.d.ts +7 -3
  72. package/dist/commonjs/search-form/lib/SearchForm.d.ts.map +1 -1
  73. package/dist/commonjs/search-form/lib/SearchForm.js +118 -145
  74. package/dist/commonjs/search-form/lib/themes.js +7 -8
  75. package/dist/es6/combobox/index.d.ts +0 -3
  76. package/dist/es6/combobox/index.d.ts.map +1 -1
  77. package/dist/es6/combobox/index.js +0 -3
  78. package/dist/es6/combobox/lib/AutocompleteList.d.ts +4 -5
  79. package/dist/es6/combobox/lib/AutocompleteList.d.ts.map +1 -1
  80. package/dist/es6/combobox/lib/AutocompleteList.js +26 -48
  81. package/dist/es6/combobox/lib/Combobox.d.ts +4 -6
  82. package/dist/es6/combobox/lib/Combobox.d.ts.map +1 -1
  83. package/dist/es6/combobox/lib/Combobox.js +98 -131
  84. package/dist/es6/combobox/lib/Status.d.ts +1 -2
  85. package/dist/es6/combobox/lib/Status.d.ts.map +1 -1
  86. package/dist/es6/combobox/lib/Status.js +6 -8
  87. package/dist/es6/common/index.d.ts +0 -2
  88. package/dist/es6/common/index.d.ts.map +1 -1
  89. package/dist/es6/common/index.js +0 -2
  90. package/dist/es6/common/lib/theming/index.d.ts +0 -1
  91. package/dist/es6/common/lib/theming/index.d.ts.map +1 -1
  92. package/dist/es6/common/lib/theming/index.js +0 -1
  93. package/dist/es6/common/lib/theming/useThemeRTL.d.ts +3 -0
  94. package/dist/es6/common/lib/theming/useThemeRTL.d.ts.map +1 -1
  95. package/dist/es6/common/lib/theming/useThemeRTL.js +19 -44
  96. package/dist/es6/expandable/index.d.ts +3 -0
  97. package/dist/es6/expandable/index.d.ts.map +1 -0
  98. package/dist/es6/expandable/index.js +2 -0
  99. package/dist/es6/expandable/lib/Expandable.d.ts +108 -0
  100. package/dist/es6/expandable/lib/Expandable.d.ts.map +1 -0
  101. package/dist/es6/expandable/lib/Expandable.js +53 -0
  102. package/dist/es6/expandable/lib/ExpandableAvatar.d.ts +7 -0
  103. package/dist/es6/expandable/lib/ExpandableAvatar.d.ts.map +1 -0
  104. package/dist/es6/expandable/lib/ExpandableAvatar.js +17 -0
  105. package/dist/es6/expandable/lib/ExpandableContent.d.ts +21 -0
  106. package/dist/es6/expandable/lib/ExpandableContent.d.ts.map +1 -0
  107. package/dist/es6/expandable/lib/ExpandableContent.js +12 -0
  108. package/dist/es6/expandable/lib/ExpandableIcon.d.ts +29 -0
  109. package/dist/es6/expandable/lib/ExpandableIcon.d.ts.map +1 -0
  110. package/dist/es6/expandable/lib/ExpandableIcon.js +25 -0
  111. package/dist/es6/expandable/lib/ExpandableTarget.d.ts +33 -0
  112. package/dist/es6/expandable/lib/ExpandableTarget.d.ts.map +1 -0
  113. package/dist/es6/expandable/lib/ExpandableTarget.js +26 -0
  114. package/dist/es6/expandable/lib/ExpandableTitle.d.ts +11 -0
  115. package/dist/es6/expandable/lib/ExpandableTitle.d.ts.map +1 -0
  116. package/dist/es6/expandable/lib/ExpandableTitle.js +10 -0
  117. package/dist/es6/expandable/lib/hooks/index.d.ts +5 -0
  118. package/dist/es6/expandable/lib/hooks/index.d.ts.map +1 -0
  119. package/dist/es6/expandable/lib/hooks/index.js +4 -0
  120. package/dist/es6/expandable/lib/hooks/useExpandableContent.d.ts +18 -0
  121. package/dist/es6/expandable/lib/hooks/useExpandableContent.d.ts.map +1 -0
  122. package/dist/es6/expandable/lib/hooks/useExpandableContent.js +8 -0
  123. package/dist/es6/expandable/lib/hooks/useExpandableIcon.d.ts +13 -0
  124. package/dist/es6/expandable/lib/hooks/useExpandableIcon.d.ts.map +1 -0
  125. package/dist/es6/expandable/lib/hooks/useExpandableIcon.js +7 -0
  126. package/dist/es6/expandable/lib/hooks/useExpandableModel.d.ts +53 -0
  127. package/dist/es6/expandable/lib/hooks/useExpandableModel.d.ts.map +1 -0
  128. package/dist/es6/expandable/lib/hooks/useExpandableModel.js +19 -0
  129. package/dist/es6/expandable/lib/hooks/useExpandableTarget.d.ts +15 -0
  130. package/dist/es6/expandable/lib/hooks/useExpandableTarget.d.ts.map +1 -0
  131. package/dist/es6/expandable/lib/hooks/useExpandableTarget.js +16 -0
  132. package/dist/es6/index.d.ts +1 -2
  133. package/dist/es6/index.d.ts.map +1 -1
  134. package/dist/es6/index.js +1 -2
  135. package/dist/es6/search-form/lib/SearchForm.d.ts +7 -3
  136. package/dist/es6/search-form/lib/SearchForm.d.ts.map +1 -1
  137. package/dist/es6/search-form/lib/SearchForm.js +108 -136
  138. package/dist/es6/search-form/lib/themes.js +5 -6
  139. package/{drawer → expandable}/LICENSE +2 -1
  140. package/expandable/README.md +11 -0
  141. package/expandable/index.ts +2 -0
  142. package/expandable/lib/Expandable.tsx +68 -0
  143. package/expandable/lib/ExpandableAvatar.tsx +26 -0
  144. package/expandable/lib/ExpandableContent.tsx +32 -0
  145. package/expandable/lib/ExpandableIcon.tsx +75 -0
  146. package/expandable/lib/ExpandableTarget.tsx +67 -0
  147. package/expandable/lib/ExpandableTitle.tsx +32 -0
  148. package/expandable/lib/hooks/index.ts +4 -0
  149. package/expandable/lib/hooks/useExpandableContent.ts +9 -0
  150. package/expandable/lib/hooks/useExpandableIcon.ts +8 -0
  151. package/expandable/lib/hooks/useExpandableModel.tsx +20 -0
  152. package/expandable/lib/hooks/useExpandableTarget.ts +16 -0
  153. package/expandable/package.json +6 -0
  154. package/index.ts +1 -2
  155. package/package.json +5 -5
  156. package/search-form/lib/SearchForm.tsx +13 -11
  157. package/search-form/package.json +2 -1
  158. package/common/lib/storybook-utils/ComponentStatesTable.tsx +0 -80
  159. package/common/lib/storybook-utils/permutateProps.ts +0 -47
  160. package/common/lib/storybook-utils/propTypes.ts +0 -15
  161. package/common/lib/theming/useThemedRing.ts +0 -82
  162. package/dist/commonjs/common/lib/storybook-utils/ComponentStatesTable.d.ts +0 -26
  163. package/dist/commonjs/common/lib/storybook-utils/ComponentStatesTable.d.ts.map +0 -1
  164. package/dist/commonjs/common/lib/storybook-utils/ComponentStatesTable.js +0 -48
  165. package/dist/commonjs/common/lib/storybook-utils/permutateProps.d.ts +0 -5
  166. package/dist/commonjs/common/lib/storybook-utils/permutateProps.d.ts.map +0 -1
  167. package/dist/commonjs/common/lib/storybook-utils/permutateProps.js +0 -47
  168. package/dist/commonjs/common/lib/storybook-utils/propTypes.d.ts +0 -15
  169. package/dist/commonjs/common/lib/storybook-utils/propTypes.d.ts.map +0 -1
  170. package/dist/commonjs/common/lib/storybook-utils/propTypes.js +0 -2
  171. package/dist/commonjs/common/lib/theming/useThemedRing.d.ts +0 -11
  172. package/dist/commonjs/common/lib/theming/useThemedRing.d.ts.map +0 -1
  173. package/dist/commonjs/common/lib/theming/useThemedRing.js +0 -67
  174. package/dist/commonjs/drawer/index.d.ts +0 -6
  175. package/dist/commonjs/drawer/index.d.ts.map +0 -1
  176. package/dist/commonjs/drawer/lib/Drawer.d.ts +0 -49
  177. package/dist/commonjs/drawer/lib/Drawer.d.ts.map +0 -1
  178. package/dist/commonjs/drawer/lib/Drawer.js +0 -124
  179. package/dist/commonjs/drawer/lib/DrawerHeader.d.ts +0 -38
  180. package/dist/commonjs/drawer/lib/DrawerHeader.d.ts.map +0 -1
  181. package/dist/commonjs/drawer/lib/DrawerHeader.js +0 -105
  182. package/dist/es6/common/lib/storybook-utils/ComponentStatesTable.d.ts +0 -26
  183. package/dist/es6/common/lib/storybook-utils/ComponentStatesTable.d.ts.map +0 -1
  184. package/dist/es6/common/lib/storybook-utils/ComponentStatesTable.js +0 -41
  185. package/dist/es6/common/lib/storybook-utils/permutateProps.d.ts +0 -5
  186. package/dist/es6/common/lib/storybook-utils/permutateProps.d.ts.map +0 -1
  187. package/dist/es6/common/lib/storybook-utils/permutateProps.js +0 -43
  188. package/dist/es6/common/lib/storybook-utils/propTypes.d.ts +0 -15
  189. package/dist/es6/common/lib/storybook-utils/propTypes.d.ts.map +0 -1
  190. package/dist/es6/common/lib/storybook-utils/propTypes.js +0 -1
  191. package/dist/es6/common/lib/theming/useThemedRing.d.ts +0 -11
  192. package/dist/es6/common/lib/theming/useThemedRing.d.ts.map +0 -1
  193. package/dist/es6/common/lib/theming/useThemedRing.js +0 -59
  194. package/dist/es6/drawer/index.d.ts +0 -6
  195. package/dist/es6/drawer/index.d.ts.map +0 -1
  196. package/dist/es6/drawer/index.js +0 -5
  197. package/dist/es6/drawer/lib/Drawer.d.ts +0 -49
  198. package/dist/es6/drawer/lib/Drawer.d.ts.map +0 -1
  199. package/dist/es6/drawer/lib/Drawer.js +0 -99
  200. package/dist/es6/drawer/lib/DrawerHeader.d.ts +0 -38
  201. package/dist/es6/drawer/lib/DrawerHeader.d.ts.map +0 -1
  202. package/dist/es6/drawer/lib/DrawerHeader.js +0 -81
  203. package/drawer/README.md +0 -35
  204. package/drawer/index.ts +0 -5
  205. package/drawer/lib/Drawer.tsx +0 -119
  206. package/drawer/lib/DrawerHeader.tsx +0 -105
  207. package/drawer/package.json +0 -5
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ createSubcomponent,
5
+ ExtractProps,
6
+ styled,
7
+ StyledType,
8
+ } from '@workday/canvas-kit-react/common';
9
+ import {chevronUpIcon, chevronDownIcon} from '@workday/canvas-system-icons-web';
10
+ import {CanvasSystemIcon} from '@workday/design-assets-types';
11
+ import {useExpandableIcon} from './hooks/useExpandableIcon';
12
+ import {SystemIcon} from '@workday/canvas-kit-react/icon';
13
+ import {IconPositions} from '@workday/canvas-kit-react/button';
14
+ import {colors, space} from '@workday/canvas-kit-react/tokens';
15
+
16
+ import {useExpandableModel} from './hooks/useExpandableModel';
17
+
18
+ export interface ExpandableIconProps extends Omit<ExtractProps<typeof SystemIcon, never>, 'icon'> {
19
+ /**
20
+ * Icon to display from `@workday/canvas-accent-icons-web`
21
+ * @default chevronUpIcon
22
+ */
23
+ icon?: CanvasSystemIcon;
24
+ /**
25
+ * Button icon positions can either be `start` or `end`.
26
+ * If no value is provided, it defaults to `start`.
27
+ * @default 'start'
28
+ */
29
+ iconPosition?: IconPositions;
30
+ }
31
+
32
+ const StyledEndIcon = styled(SystemIcon)<{visible: boolean} & StyledType>(
33
+ {
34
+ marginLeft: 'auto',
35
+ },
36
+ ({visible}) => ({
37
+ transform: !visible ? 'rotate(-180deg)' : undefined,
38
+ padding: !visible
39
+ ? `${space.xxxs} ${space.xs} ${space.xxxs} ${space.xxxs}`
40
+ : `${space.xxxs} ${space.xxxs} ${space.xxxs} ${space.xs}`,
41
+ })
42
+ );
43
+
44
+ const StyledStartIcon = styled(SystemIcon)<{visible: boolean} & StyledType>(
45
+ {
46
+ margin: `0 ${space.xxs} 0 0`,
47
+ padding: space.xxxs,
48
+ },
49
+ ({visible}) => ({
50
+ transform: !visible ? 'rotate(-90deg)' : undefined,
51
+ })
52
+ );
53
+
54
+ export const ExpandableIcon = createSubcomponent('span')({
55
+ modelHook: useExpandableModel,
56
+ elemPropsHook: useExpandableIcon,
57
+ })<ExpandableIconProps>(({icon, visible, iconPosition = 'start', ...elementProps}, Element) =>
58
+ iconPosition === 'end' ? (
59
+ <StyledEndIcon
60
+ as={Element}
61
+ fill={colors.licorice200}
62
+ icon={icon || chevronUpIcon}
63
+ visible={visible}
64
+ {...elementProps}
65
+ />
66
+ ) : (
67
+ <StyledStartIcon
68
+ as={Element}
69
+ fill={colors.licorice200}
70
+ icon={icon || chevronDownIcon}
71
+ visible={visible}
72
+ {...elementProps}
73
+ />
74
+ )
75
+ );
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ createSubcomponent,
5
+ ExtractProps,
6
+ focusRing,
7
+ hideMouseFocus,
8
+ styled,
9
+ StyledType,
10
+ } from '@workday/canvas-kit-react/common';
11
+ import {Flex} from '@workday/canvas-kit-react/layout';
12
+ import {colors} from '@workday/canvas-kit-react/tokens';
13
+
14
+ import {useExpandableTarget} from './hooks/useExpandableTarget';
15
+ import {useExpandableModel} from './hooks/useExpandableModel';
16
+
17
+ export interface ExpandableTargetProps extends ExtractProps<typeof Flex, never> {
18
+ /**
19
+ * Children of the `Expandable.Target`. Should contain `Target.Title`, an optional `Target.Avatar`
20
+ * and `Target.Icon` with an `iconPosition` prop that takes a value of either `start` or `end`.
21
+ * `Target.Icon` with `start` is meant to be placed before the `Target.Title` and `Target.Icon`
22
+ * `end` should be placed after.
23
+ */
24
+ children: React.ReactNode;
25
+ /**
26
+ * This specifies the semantic heading level that will wrap the `Expandable.Target`'s button. If not
27
+ * defined, then nothing will wrap the button.
28
+ */
29
+ headingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
30
+ }
31
+
32
+ const StyledButton = styled(Flex.as('button'))<StyledType>({
33
+ cursor: 'pointer',
34
+ '&:focus': {
35
+ ...focusRing(),
36
+ },
37
+ '&:hover': {
38
+ background: colors.soap300,
39
+ },
40
+ ...hideMouseFocus,
41
+ });
42
+
43
+ const Heading = styled('h1')<StyledType>({
44
+ margin: 0,
45
+ });
46
+
47
+ export const ExpandableTarget = createSubcomponent('button')({
48
+ modelHook: useExpandableModel,
49
+ elemPropsHook: useExpandableTarget,
50
+ })<ExpandableTargetProps>(({children, headingLevel, ...elementProps}, Element) => {
51
+ const button = (
52
+ <StyledButton
53
+ as={Element}
54
+ background="none"
55
+ border="none"
56
+ borderRadius="m"
57
+ flexDirection="row"
58
+ padding="xxs"
59
+ width="100%"
60
+ {...elementProps}
61
+ >
62
+ {children}
63
+ </StyledButton>
64
+ );
65
+
66
+ return !!headingLevel ? <Heading as={headingLevel}>{button}</Heading> : button;
67
+ });
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+
3
+ import {createComponent, ExtractProps} from '@workday/canvas-kit-react/common';
4
+ import {Box} from '@workday/canvas-kit-react/layout';
5
+ import {colors, space, type} from '@workday/canvas-kit-react/tokens';
6
+
7
+ export interface ExpandableTitleProps extends ExtractProps<typeof Box, never> {
8
+ /**
9
+ * Children of the `Expandable.Title`. This should contain a string for the title
10
+ */
11
+ children: React.ReactNode;
12
+ }
13
+
14
+ export const ExpandableTitle = createComponent('div')({
15
+ displayName: 'Expandable.Title',
16
+ Component: ({children, ...elemProps}: ExpandableTitleProps, ref, Element) => {
17
+ return (
18
+ <Box
19
+ as={Element}
20
+ ref={ref}
21
+ {...type.levels.body.medium}
22
+ fontWeight={type.properties.fontWeights.bold}
23
+ color={colors.blackPepper400}
24
+ padding={`2px ${space.zero} 2px`}
25
+ textAlign="left"
26
+ {...elemProps}
27
+ >
28
+ {children}
29
+ </Box>
30
+ );
31
+ },
32
+ });
@@ -0,0 +1,4 @@
1
+ export * from './useExpandableContent';
2
+ export * from './useExpandableIcon';
3
+ export * from './useExpandableModel';
4
+ export * from './useExpandableTarget';
@@ -0,0 +1,9 @@
1
+ import {createElemPropsHook} from '@workday/canvas-kit-react/common';
2
+ import {useExpandableModel} from './useExpandableModel';
3
+
4
+ export const useExpandableContent = createElemPropsHook(useExpandableModel)(({state}) => {
5
+ return {
6
+ style: state.visibility !== 'hidden' ? {} : {display: 'none'},
7
+ id: state.id,
8
+ };
9
+ });
@@ -0,0 +1,8 @@
1
+ import {createElemPropsHook} from '@workday/canvas-kit-react/common';
2
+ import {useExpandableModel} from './useExpandableModel';
3
+
4
+ export const useExpandableIcon = createElemPropsHook(useExpandableModel)(({state}) => {
5
+ return {
6
+ visible: state.visibility !== 'hidden',
7
+ };
8
+ });
@@ -0,0 +1,20 @@
1
+ import {createModelHook} from '@workday/canvas-kit-react/common';
2
+ import {useDisclosureModel} from '@workday/canvas-kit-react/disclosure';
3
+
4
+ /**
5
+ * The `ExpandableModel` extends the `DisclosureModel`
6
+ */
7
+ export const useExpandableModel = createModelHook({
8
+ defaultConfig: {
9
+ ...useDisclosureModel.defaultConfig,
10
+ },
11
+ })(config => {
12
+ const disclosure = useDisclosureModel(config);
13
+ const state = {
14
+ ...disclosure.state,
15
+ };
16
+ const events = {
17
+ ...disclosure.events,
18
+ };
19
+ return {state, events};
20
+ });
@@ -0,0 +1,16 @@
1
+ import {createElemPropsHook} from '@workday/canvas-kit-react/common';
2
+ import {useExpandableModel} from './useExpandableModel';
3
+
4
+ export const useExpandableTarget = createElemPropsHook(useExpandableModel)(({state, events}) => {
5
+ return {
6
+ 'aria-controls': state.id,
7
+ 'aria-expanded': state.visibility !== 'hidden',
8
+ onClick: (event: React.MouseEvent) => {
9
+ if (state.visibility !== 'hidden') {
10
+ events.hide(event);
11
+ } else {
12
+ events.show(event);
13
+ }
14
+ },
15
+ };
16
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../dist/commonjs/expandable",
3
+ "module": "../dist/es6/expandable",
4
+ "sideEffects": false,
5
+ "types": "../dist/es6/expandable"
6
+ }
package/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './combobox';
2
- export * from './common';
3
- export * from './drawer';
2
+ export * from './expandable';
4
3
  export * from './search-form';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-labs-react",
3
- "version": "7.1.4",
3
+ "version": "7.2.0-427-next.2+2c79134a",
4
4
  "description": "Canvas Kit Labs is an incubator for new and experimental components. Since we have a rather rigorous process for getting components in at a production level, it can be valuable to make them available earlier while we continuously iterate on the API/functionality. The Labs modules allow us to do that as needed.",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -41,14 +41,14 @@
41
41
  "workday"
42
42
  ],
43
43
  "peerDependencies": {
44
- "react": "^16.8 || ^17.0"
44
+ "react": ">=16.14"
45
45
  },
46
46
  "dependencies": {
47
47
  "@emotion/react": "^11.7.1",
48
48
  "@emotion/styled": "^11.6.0",
49
- "@workday/canvas-kit-preview-react": "^7.1.4",
50
- "@workday/canvas-kit-react": "^7.1.4",
49
+ "@workday/canvas-kit-react": "^7.2.0-427-next.2+2c79134a",
51
50
  "@workday/canvas-system-icons-web": "^3.0.0",
51
+ "@workday/design-assets-types": "^0.2.8",
52
52
  "chroma-js": "^2.1.0",
53
53
  "lodash.flatten": "^4.4.0",
54
54
  "rtl-css-js": "^1.14.1"
@@ -56,5 +56,5 @@
56
56
  "devDependencies": {
57
57
  "@types/lodash.flatten": "^4.4.6"
58
58
  },
59
- "gitHead": "6c20e6b9755afa86a865f4e90c24a4a52ea9e481"
59
+ "gitHead": "2c79134aa48ef0efde9cdf883b529b8157337a28"
60
60
  }
@@ -7,7 +7,6 @@ import {searchIcon, xIcon} from '@workday/canvas-system-icons-web';
7
7
  import {FormField, FormFieldLabelPosition} from '@workday/canvas-kit-react/form-field';
8
8
  import {Combobox} from '@workday/canvas-kit-labs-react/combobox';
9
9
  import {TextInput} from '@workday/canvas-kit-react/text-input';
10
- import {MenuItemProps} from '@workday/canvas-kit-preview-react/menu';
11
10
  import {searchThemes, SearchTheme, SearchThemeAttributes} from './themes';
12
11
  import chroma from 'chroma-js';
13
12
 
@@ -28,7 +27,7 @@ export interface SearchFormProps extends GrowthBehavior, React.FormHTMLAttribute
28
27
  /**
29
28
  * The autocomplete items of the SearchForm. This array of menu items is shown under the search bar.
30
29
  */
31
- autocompleteItems?: React.ReactElement<MenuItemProps>[];
30
+ autocompleteItems?: React.ReactElement<any>[];
32
31
  /**
33
32
  * The theme of the header the search input is being rendered in.
34
33
  */
@@ -87,6 +86,11 @@ export interface SearchFormProps extends GrowthBehavior, React.FormHTMLAttribute
87
86
  * @default false
88
87
  */
89
88
  allowEmptyStringSearch?: boolean;
89
+ /**
90
+ * Sets the `id` for the label
91
+ * @default unique identifier
92
+ */
93
+ labelId?: string;
90
94
  }
91
95
 
92
96
  export interface SearchFormState {
@@ -118,7 +122,7 @@ const StyledSearchForm = styled('form')<
118
122
  >(
119
123
  {
120
124
  position: 'relative',
121
- flex: `1 1 auto`, // Instead of just flex-grow: 1 for IE11, see https://github.com/philipwalton/flexbugs#flexbug-1
125
+ flexGrow: 1,
122
126
  display: 'flex',
123
127
  alignItems: 'center',
124
128
  marginLeft: space.m,
@@ -161,7 +165,6 @@ const SearchContainer = styled('div')<Pick<SearchFormProps, 'height'>>(
161
165
  },
162
166
  ({height}) => ({
163
167
  minHeight: height,
164
- height: height, // Needed to keep IE11 vertically centered
165
168
  })
166
169
  );
167
170
 
@@ -230,7 +233,6 @@ const SearchInput = styled(TextInput)<
230
233
  const collapseStyles: CSSObject = isCollapsed
231
234
  ? {
232
235
  fontSize: '20px',
233
- lineHeight: '20px', // For ie11, line-height needs to match font-size
234
236
  paddingLeft: spaceNumbers.xl + spaceNumbers.s,
235
237
  paddingRight: spaceNumbers.xl + spaceNumbers.s,
236
238
  maxWidth: 'none',
@@ -248,7 +250,6 @@ const SearchInput = styled(TextInput)<
248
250
  };
249
251
  return {
250
252
  fontSize: '14px',
251
- lineHeight: '14px', // For ie11, line-height needs to match font-size
252
253
  boxShadow: inputColors.boxShadow,
253
254
  color: inputColors.color,
254
255
  border: 'none',
@@ -280,7 +281,7 @@ export class SearchForm extends React.Component<SearchFormProps, SearchFormState
280
281
 
281
282
  private inputRef = React.createRef<HTMLInputElement>();
282
283
  private openRef = React.createRef<HTMLButtonElement>();
283
- private labelId = generateUniqueId();
284
+ private defaultLabelId = generateUniqueId();
284
285
 
285
286
  state: Readonly<SearchFormState> = {
286
287
  showForm: false,
@@ -385,6 +386,7 @@ export class SearchForm extends React.Component<SearchFormProps, SearchFormState
385
386
  submitAriaLabel = 'Search',
386
387
  openButtonAriaLabel = 'Open Search',
387
388
  closeButtonAriaLabel = 'Cancel',
389
+ labelId = this.defaultLabelId,
388
390
  showClearButton = true,
389
391
  height = 40,
390
392
  grow,
@@ -405,7 +407,7 @@ export class SearchForm extends React.Component<SearchFormProps, SearchFormState
405
407
  action="."
406
408
  rightAlign={rightAlign}
407
409
  grow={grow}
408
- aria-labelledby={this.labelId}
410
+ aria-labelledby={labelId}
409
411
  isCollapsed={isCollapsed}
410
412
  onSubmit={this.handleSubmit}
411
413
  showForm={this.state.showForm}
@@ -432,8 +434,8 @@ export class SearchForm extends React.Component<SearchFormProps, SearchFormState
432
434
  />
433
435
  <SearchField
434
436
  grow={grow}
435
- id={this.labelId}
436
- inputId={`input-${this.labelId}`}
437
+ id={labelId}
438
+ inputId={`input-${labelId}`}
437
439
  label={inputLabel}
438
440
  labelPosition={FormFieldLabelPosition.Hidden}
439
441
  useFieldset={false}
@@ -450,7 +452,7 @@ export class SearchForm extends React.Component<SearchFormProps, SearchFormState
450
452
  onBlur={this.handleBlur}
451
453
  showClearButton={!isCollapsed && showClearButton}
452
454
  clearButtonAriaLabel={clearButtonAriaLabel}
453
- labelId={this.labelId}
455
+ labelId={labelId}
454
456
  >
455
457
  <SearchInput
456
458
  ref={this.inputRef}
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "main": "../dist/commonjs/search-form",
3
3
  "module": "../dist/es6/search-form",
4
- "sideEffects": false
4
+ "sideEffects": false,
5
+ "types": "../dist/es6/search-form"
5
6
  }
@@ -1,80 +0,0 @@
1
- import React from 'react';
2
- import {styled} from '@workday/canvas-kit-react/common';
3
- import {PropCombination, Props} from './propTypes';
4
-
5
- /**
6
- * A helper to generate a table of all possible states for component visual testing.
7
- */
8
- export interface ComponentStatesTableProps {
9
- /**
10
- * The props that will be passed to the component when it is rendered and the corresponding
11
- * row label for that permutation. It is encouraged to use the result of permutateProps()
12
- * rather than passing in a list so we don't miss any combinations.
13
- */
14
- rowProps: PropCombination[];
15
- /**
16
- * The props that will be passed to the component when it is rendered and the corresponding
17
- * column label for that permutation. It is encouraged to use the result of permutateProps()
18
- * rather than passing in a list so we don't miss any combinations.
19
- */
20
- columnProps: PropCombination[];
21
- /**
22
- * The render function called to render the component in each cell of the table. This gives you
23
- * the ability to add extra styling or markup (a blue background for an inverse variant, for example).
24
- */
25
- children(props: Props): React.ReactNode;
26
- }
27
-
28
- const Table = styled('table')({
29
- width: '100%',
30
- thead: {
31
- textAlign: 'left',
32
- paddingBottom: 16,
33
- },
34
- 'td, th': {
35
- minWidth: 100,
36
- paddingBottom: 16,
37
- paddingRight: 16,
38
- textAlign: 'left',
39
- },
40
- });
41
-
42
- export const ComponentStatesTable = ({
43
- rowProps,
44
- columnProps,
45
- children,
46
- }: ComponentStatesTableProps) => {
47
- return (
48
- <Table>
49
- <thead>
50
- <tr>
51
- <th>Variants</th>
52
- {columnProps.map(col => (
53
- <th key={`component-table-heading-${col.label.toLowerCase().replace(' ', ',')}`}>
54
- {col.label}
55
- </th>
56
- ))}
57
- </tr>
58
- </thead>
59
- <tbody>
60
- {rowProps.map(row => {
61
- return (
62
- <tr key={row.label.toLowerCase().replace(' ', '-')}>
63
- <td>{row.label}</td>
64
- {columnProps.map(col => {
65
- return (
66
- <td key={col.label.toLowerCase().replace(' ', '-')}>
67
- {children({
68
- ...row.props,
69
- ...col.props,
70
- })}
71
- </td>
72
- );
73
- })}
74
- </tr>
75
- );
76
- })}
77
- </tbody>
78
- </Table>
79
- );
80
- };
@@ -1,47 +0,0 @@
1
- import {PropCombination, PropDeclaration, Props, PropsDeclaration} from './propTypes';
2
-
3
- export const permutateProps = (
4
- allProps: PropsDeclaration,
5
- filter?: (props: Props) => boolean,
6
- remainingProps: string[] = Object.keys(allProps),
7
- values: {[key: string]: PropDeclaration} = {}
8
- ): PropCombination[] => {
9
- // When there are no more props to combine with, return result
10
- const prop = remainingProps[0];
11
- if (!prop) {
12
- const props: Props = {};
13
- Object.keys(values).forEach(prop => {
14
- props[prop] = values?.[prop]?.value;
15
- });
16
-
17
- if (filter && !filter(props)) {
18
- return [];
19
- }
20
-
21
- const label = Object.keys(values)
22
- .map(prop => values?.[prop]?.label)
23
- .join(' ');
24
-
25
- return [
26
- {
27
- label,
28
- props,
29
- },
30
- ];
31
- }
32
- const possiblePropValues = allProps[prop];
33
-
34
- const permutations = possiblePropValues?.map((value: PropDeclaration) => {
35
- const newValues = {...values}; // Required so we don't overwrite previous references
36
- newValues[prop] = value;
37
-
38
- return permutateProps(
39
- allProps,
40
- filter,
41
- remainingProps!.slice(1, remainingProps!.length),
42
- newValues
43
- );
44
- });
45
-
46
- return (permutations as any).flat();
47
- };
@@ -1,15 +0,0 @@
1
- export type PropDeclaration = {
2
- value: any;
3
- label: string;
4
- };
5
-
6
- export type PropsDeclaration = {[key: string]: PropDeclaration[]};
7
-
8
- export type Props = {
9
- [key: string]: any;
10
- };
11
-
12
- export type PropCombination = {
13
- label: string;
14
- props: Props;
15
- };
@@ -1,82 +0,0 @@
1
- import {useThemeRTL} from './useThemeRTL';
2
- import {CanvasThemePalette, EmotionCanvasTheme} from '@workday/canvas-kit-react/common';
3
- import {colors, CSSProperties, inputColors, statusColors} from '@workday/canvas-kit-react/tokens';
4
- import chroma from 'chroma-js';
5
-
6
- type paletteSelection = Exclude<keyof EmotionCanvasTheme['canvas']['palette'], 'common'>;
7
- interface ContrastColors {
8
- outer?: string;
9
- inner?: string;
10
- }
11
-
12
- const isAccessible = (foreground: string, background: string = colors.frenchVanilla100) => {
13
- return chroma.contrast(foreground, background) >= 3;
14
- };
15
-
16
- const getPaletteColorsFromTheme = (
17
- palette: CanvasThemePalette,
18
- fallbackColors?: ContrastColors
19
- ): ContrastColors => {
20
- return {
21
- outer: isAccessible(palette.main)
22
- ? palette.main
23
- : isAccessible(palette.darkest)
24
- ? palette.darkest
25
- : fallbackColors?.outer,
26
- inner: fallbackColors?.inner ? fallbackColors.inner : palette.main,
27
- };
28
- };
29
-
30
- export function getPaletteColors(
31
- type: paletteSelection,
32
- theme: EmotionCanvasTheme
33
- ): ContrastColors {
34
- const palette = theme.canvas.palette[type];
35
-
36
- switch (type) {
37
- case 'error': {
38
- return getPaletteColorsFromTheme(palette, {outer: inputColors.error.border});
39
- }
40
- case 'alert': {
41
- return getPaletteColorsFromTheme(palette, {outer: colors.cantaloupe600});
42
- }
43
- case 'success': {
44
- return getPaletteColorsFromTheme(palette, {
45
- outer: colors.greenApple600,
46
- // The theme default for success.main is set to the darkest GreenApple
47
- // For our default ring, we need to override it so the inner ring is a bit lighter
48
- inner: palette.main === colors.greenApple600 ? statusColors.success : palette.main,
49
- });
50
- }
51
- default: {
52
- return getPaletteColorsFromTheme(palette);
53
- }
54
- }
55
- }
56
-
57
- export const useThemedRing = (type: paletteSelection): CSSProperties => {
58
- const {themeRTL, theme} = useThemeRTL();
59
-
60
- const paletteColors = getPaletteColors(type, theme);
61
- if (!(paletteColors?.outer || paletteColors?.inner)) {
62
- return {};
63
- }
64
- const errorBoxShadow = `inset 0 0 0 ${paletteColors.outer === paletteColors.inner ? 1 : 2}px ${
65
- paletteColors.inner
66
- }`;
67
-
68
- return themeRTL({
69
- borderColor: paletteColors.outer,
70
- transition: '100ms box-shadow',
71
- boxShadow: errorBoxShadow,
72
- '&:hover, &:disabled': {
73
- borderColor: paletteColors.outer,
74
- },
75
- '&:focus:not([disabled])': {
76
- borderColor: paletteColors.outer,
77
- boxShadow: `${errorBoxShadow},
78
- 0 0 0 2px ${colors.frenchVanilla100},
79
- 0 0 0 4px ${theme ? theme.canvas.palette.common.focusOutline : inputColors.focusBorder}`,
80
- },
81
- });
82
- };
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { PropCombination, Props } from './propTypes';
3
- /**
4
- * A helper to generate a table of all possible states for component visual testing.
5
- */
6
- export interface ComponentStatesTableProps {
7
- /**
8
- * The props that will be passed to the component when it is rendered and the corresponding
9
- * row label for that permutation. It is encouraged to use the result of permutateProps()
10
- * rather than passing in a list so we don't miss any combinations.
11
- */
12
- rowProps: PropCombination[];
13
- /**
14
- * The props that will be passed to the component when it is rendered and the corresponding
15
- * column label for that permutation. It is encouraged to use the result of permutateProps()
16
- * rather than passing in a list so we don't miss any combinations.
17
- */
18
- columnProps: PropCombination[];
19
- /**
20
- * The render function called to render the component in each cell of the table. This gives you
21
- * the ability to add extra styling or markup (a blue background for an inverse variant, for example).
22
- */
23
- children(props: Props): React.ReactNode;
24
- }
25
- export declare const ComponentStatesTable: ({ rowProps, columnProps, children, }: ComponentStatesTableProps) => JSX.Element;
26
- //# sourceMappingURL=ComponentStatesTable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ComponentStatesTable.d.ts","sourceRoot":"","sources":["../../../../../common/lib/storybook-utils/ComponentStatesTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,eAAe,EAAE,KAAK,EAAC,MAAM,aAAa,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B;;;;OAIG;IACH,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC;CACzC;AAgBD,eAAO,MAAM,oBAAoB,yCAI9B,yBAAyB,gBAkC3B,CAAC"}