@workday/canvas-kit-react 14.0.0-alpha.1254-next.0 → 14.0.0-alpha.1255-next.0

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 (160) hide show
  1. package/button/lib/BaseButton.tsx +0 -6
  2. package/button/lib/Button.tsx +27 -2
  3. package/button/lib/ToolbarDropdownButton.tsx +21 -2
  4. package/button/lib/ToolbarIconButton.tsx +11 -1
  5. package/button/lib/parts/ButtonLabelIcon.tsx +21 -3
  6. package/collection/lib/keyUtils.ts +4 -2
  7. package/collection/lib/useListItemRemoveable.ts +2 -3
  8. package/collection/lib/useListItemRovingFocus.tsx +2 -3
  9. package/collection/lib/useListKeyboardHandler.ts +2 -4
  10. package/combobox/lib/hooks/useComboboxListKeyboardHandler.ts +2 -4
  11. package/common/lib/theming/README.md +3 -48
  12. package/common/lib/theming/useIsRTL.ts +5 -1
  13. package/common/lib/utils/index.ts +1 -0
  14. package/common/lib/utils/isElementRTL.ts +27 -0
  15. package/dist/commonjs/avatar/lib/Avatar.js +7 -7
  16. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsItem.js +1 -1
  17. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsOverflowButton.js +1 -1
  18. package/dist/commonjs/button/lib/BaseButton.d.ts +0 -5
  19. package/dist/commonjs/button/lib/BaseButton.d.ts.map +1 -1
  20. package/dist/commonjs/button/lib/BaseButton.js +28 -28
  21. package/dist/commonjs/button/lib/Button.d.ts +14 -0
  22. package/dist/commonjs/button/lib/Button.d.ts.map +1 -1
  23. package/dist/commonjs/button/lib/Button.js +2 -2
  24. package/dist/commonjs/button/lib/DeleteButton.js +1 -1
  25. package/dist/commonjs/button/lib/ExternalHyperlink.js +1 -1
  26. package/dist/commonjs/button/lib/PrimaryButton.js +2 -2
  27. package/dist/commonjs/button/lib/SecondaryButton.js +2 -2
  28. package/dist/commonjs/button/lib/TertiaryButton.js +3 -3
  29. package/dist/commonjs/button/lib/ToolbarDropdownButton.d.ts +11 -0
  30. package/dist/commonjs/button/lib/ToolbarDropdownButton.d.ts.map +1 -1
  31. package/dist/commonjs/button/lib/ToolbarDropdownButton.js +6 -3
  32. package/dist/commonjs/button/lib/ToolbarIconButton.d.ts +1 -0
  33. package/dist/commonjs/button/lib/ToolbarIconButton.d.ts.map +1 -1
  34. package/dist/commonjs/button/lib/ToolbarIconButton.js +4 -4
  35. package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts +10 -1
  36. package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
  37. package/dist/commonjs/button/lib/parts/ButtonLabelIcon.js +2 -2
  38. package/dist/commonjs/collection/lib/keyUtils.d.ts +1 -1
  39. package/dist/commonjs/collection/lib/keyUtils.d.ts.map +1 -1
  40. package/dist/commonjs/collection/lib/keyUtils.js +3 -1
  41. package/dist/commonjs/collection/lib/useListItemRemoveable.d.ts.map +1 -1
  42. package/dist/commonjs/collection/lib/useListItemRemoveable.js +1 -2
  43. package/dist/commonjs/collection/lib/useListItemRovingFocus.d.ts.map +1 -1
  44. package/dist/commonjs/collection/lib/useListItemRovingFocus.js +1 -2
  45. package/dist/commonjs/collection/lib/useListKeyboardHandler.d.ts.map +1 -1
  46. package/dist/commonjs/collection/lib/useListKeyboardHandler.js +1 -2
  47. package/dist/commonjs/combobox/lib/hooks/useComboboxListKeyboardHandler.d.ts.map +1 -1
  48. package/dist/commonjs/combobox/lib/hooks/useComboboxListKeyboardHandler.js +1 -2
  49. package/dist/commonjs/common/lib/theming/useIsRTL.d.ts +5 -1
  50. package/dist/commonjs/common/lib/theming/useIsRTL.d.ts.map +1 -1
  51. package/dist/commonjs/common/lib/theming/useIsRTL.js +5 -1
  52. package/dist/commonjs/common/lib/utils/index.d.ts +1 -0
  53. package/dist/commonjs/common/lib/utils/index.d.ts.map +1 -1
  54. package/dist/commonjs/common/lib/utils/index.js +1 -0
  55. package/dist/commonjs/common/lib/utils/isElementRTL.d.ts +25 -0
  56. package/dist/commonjs/common/lib/utils/isElementRTL.d.ts.map +1 -0
  57. package/dist/commonjs/common/lib/utils/isElementRTL.js +31 -0
  58. package/dist/commonjs/expandable/lib/ExpandableIcon.d.ts +8 -4
  59. package/dist/commonjs/expandable/lib/ExpandableIcon.d.ts.map +1 -1
  60. package/dist/commonjs/icon/lib/AccentIcon.d.ts +8 -4
  61. package/dist/commonjs/icon/lib/AccentIcon.d.ts.map +1 -1
  62. package/dist/commonjs/icon/lib/AccentIcon.js +3 -2
  63. package/dist/commonjs/icon/lib/AppletIcon.d.ts +8 -5
  64. package/dist/commonjs/icon/lib/AppletIcon.d.ts.map +1 -1
  65. package/dist/commonjs/icon/lib/AppletIcon.js +2 -2
  66. package/dist/commonjs/icon/lib/Graphic.d.ts +8 -3
  67. package/dist/commonjs/icon/lib/Graphic.d.ts.map +1 -1
  68. package/dist/commonjs/icon/lib/Graphic.js +1 -1
  69. package/dist/commonjs/icon/lib/Svg.d.ts +17 -1
  70. package/dist/commonjs/icon/lib/Svg.d.ts.map +1 -1
  71. package/dist/commonjs/icon/lib/Svg.js +8 -5
  72. package/dist/commonjs/icon/lib/SystemIcon.d.ts +7 -0
  73. package/dist/commonjs/icon/lib/SystemIcon.d.ts.map +1 -1
  74. package/dist/commonjs/icon/lib/SystemIcon.js +1 -1
  75. package/dist/commonjs/icon/lib/SystemIconCircle.d.ts +10 -1
  76. package/dist/commonjs/icon/lib/SystemIconCircle.d.ts.map +1 -1
  77. package/dist/commonjs/icon/lib/SystemIconCircle.js +4 -4
  78. package/dist/commonjs/pagination/lib/Pagination/PageButton.js +2 -2
  79. package/dist/commonjs/popup/lib/hooks/usePopupStack.d.ts.map +1 -1
  80. package/dist/commonjs/popup/lib/hooks/usePopupStack.js +10 -7
  81. package/dist/commonjs/segmented-control/lib/SegmentedControlButton.js +1 -1
  82. package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -5
  83. package/dist/commonjs/tabs/lib/TabsItem.d.ts.map +1 -1
  84. package/dist/commonjs/tabs/lib/TabsItem.js +1 -1
  85. package/dist/es6/avatar/lib/Avatar.js +7 -7
  86. package/dist/es6/breadcrumbs/lib/BreadcrumbsItem.js +1 -1
  87. package/dist/es6/breadcrumbs/lib/BreadcrumbsOverflowButton.js +1 -1
  88. package/dist/es6/button/lib/BaseButton.d.ts +0 -5
  89. package/dist/es6/button/lib/BaseButton.d.ts.map +1 -1
  90. package/dist/es6/button/lib/BaseButton.js +28 -28
  91. package/dist/es6/button/lib/Button.d.ts +14 -0
  92. package/dist/es6/button/lib/Button.d.ts.map +1 -1
  93. package/dist/es6/button/lib/Button.js +2 -2
  94. package/dist/es6/button/lib/DeleteButton.js +1 -1
  95. package/dist/es6/button/lib/ExternalHyperlink.js +1 -1
  96. package/dist/es6/button/lib/PrimaryButton.js +2 -2
  97. package/dist/es6/button/lib/SecondaryButton.js +2 -2
  98. package/dist/es6/button/lib/TertiaryButton.js +3 -3
  99. package/dist/es6/button/lib/ToolbarDropdownButton.d.ts +11 -0
  100. package/dist/es6/button/lib/ToolbarDropdownButton.d.ts.map +1 -1
  101. package/dist/es6/button/lib/ToolbarDropdownButton.js +6 -3
  102. package/dist/es6/button/lib/ToolbarIconButton.d.ts +1 -0
  103. package/dist/es6/button/lib/ToolbarIconButton.d.ts.map +1 -1
  104. package/dist/es6/button/lib/ToolbarIconButton.js +4 -4
  105. package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts +10 -1
  106. package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
  107. package/dist/es6/button/lib/parts/ButtonLabelIcon.js +2 -2
  108. package/dist/es6/collection/lib/keyUtils.d.ts +1 -1
  109. package/dist/es6/collection/lib/keyUtils.d.ts.map +1 -1
  110. package/dist/es6/collection/lib/keyUtils.js +3 -1
  111. package/dist/es6/collection/lib/useListItemRemoveable.d.ts.map +1 -1
  112. package/dist/es6/collection/lib/useListItemRemoveable.js +2 -3
  113. package/dist/es6/collection/lib/useListItemRovingFocus.d.ts.map +1 -1
  114. package/dist/es6/collection/lib/useListItemRovingFocus.js +2 -3
  115. package/dist/es6/collection/lib/useListKeyboardHandler.d.ts.map +1 -1
  116. package/dist/es6/collection/lib/useListKeyboardHandler.js +2 -3
  117. package/dist/es6/combobox/lib/hooks/useComboboxListKeyboardHandler.d.ts.map +1 -1
  118. package/dist/es6/combobox/lib/hooks/useComboboxListKeyboardHandler.js +2 -3
  119. package/dist/es6/common/lib/theming/useIsRTL.d.ts +5 -1
  120. package/dist/es6/common/lib/theming/useIsRTL.d.ts.map +1 -1
  121. package/dist/es6/common/lib/theming/useIsRTL.js +5 -1
  122. package/dist/es6/common/lib/utils/index.d.ts +1 -0
  123. package/dist/es6/common/lib/utils/index.d.ts.map +1 -1
  124. package/dist/es6/common/lib/utils/index.js +1 -0
  125. package/dist/es6/common/lib/utils/isElementRTL.d.ts +25 -0
  126. package/dist/es6/common/lib/utils/isElementRTL.d.ts.map +1 -0
  127. package/dist/es6/common/lib/utils/isElementRTL.js +27 -0
  128. package/dist/es6/expandable/lib/ExpandableIcon.d.ts +8 -4
  129. package/dist/es6/expandable/lib/ExpandableIcon.d.ts.map +1 -1
  130. package/dist/es6/icon/lib/AccentIcon.d.ts +8 -4
  131. package/dist/es6/icon/lib/AccentIcon.d.ts.map +1 -1
  132. package/dist/es6/icon/lib/AccentIcon.js +3 -2
  133. package/dist/es6/icon/lib/AppletIcon.d.ts +8 -5
  134. package/dist/es6/icon/lib/AppletIcon.d.ts.map +1 -1
  135. package/dist/es6/icon/lib/AppletIcon.js +2 -2
  136. package/dist/es6/icon/lib/Graphic.d.ts +8 -3
  137. package/dist/es6/icon/lib/Graphic.d.ts.map +1 -1
  138. package/dist/es6/icon/lib/Graphic.js +1 -1
  139. package/dist/es6/icon/lib/Svg.d.ts +17 -1
  140. package/dist/es6/icon/lib/Svg.d.ts.map +1 -1
  141. package/dist/es6/icon/lib/Svg.js +8 -5
  142. package/dist/es6/icon/lib/SystemIcon.d.ts +7 -0
  143. package/dist/es6/icon/lib/SystemIcon.d.ts.map +1 -1
  144. package/dist/es6/icon/lib/SystemIcon.js +1 -1
  145. package/dist/es6/icon/lib/SystemIconCircle.d.ts +10 -1
  146. package/dist/es6/icon/lib/SystemIconCircle.d.ts.map +1 -1
  147. package/dist/es6/icon/lib/SystemIconCircle.js +4 -4
  148. package/dist/es6/pagination/lib/Pagination/PageButton.js +2 -2
  149. package/dist/es6/popup/lib/hooks/usePopupStack.d.ts.map +1 -1
  150. package/dist/es6/popup/lib/hooks/usePopupStack.js +11 -8
  151. package/dist/es6/segmented-control/lib/SegmentedControlButton.js +1 -1
  152. package/dist/es6/tabs/lib/TabsItem.d.ts +1 -5
  153. package/dist/es6/tabs/lib/TabsItem.d.ts.map +1 -1
  154. package/dist/es6/tabs/lib/TabsItem.js +1 -1
  155. package/icon/lib/AccentIcon.tsx +10 -1
  156. package/icon/lib/AppletIcon.tsx +3 -1
  157. package/icon/lib/Svg.tsx +23 -3
  158. package/icon/lib/SystemIconCircle.tsx +26 -3
  159. package/package.json +4 -4
  160. package/popup/lib/hooks/usePopupStack.ts +10 -7
@@ -40,11 +40,6 @@ export interface ButtonContainerProps extends Partial<SystemIconProps>, GrowthBe
40
40
  * @default 'start'
41
41
  */
42
42
  iconPosition?: IconPositions;
43
- /**
44
- * If set to `true`, transform the icon's x-axis to mirror the graphic
45
- * @default false
46
- */
47
- shouldMirrorIcon?: boolean;
48
43
  children?: React.ReactNode;
49
44
  }
50
45
 
@@ -406,7 +401,6 @@ export const BaseButton = createComponent('button')({
406
401
  iconPosition,
407
402
  icon,
408
403
  colors,
409
- shouldMirrorIcon = false,
410
404
  ...elemProps
411
405
  }: ButtonContainerProps,
412
406
  ref,
@@ -14,6 +14,20 @@ export interface ButtonProps extends Omit<ButtonContainerProps, 'ref'> {
14
14
  * @default 'start'
15
15
  */
16
16
  iconPosition?: 'start' | 'end';
17
+ /**
18
+ * If set to `true`, transform the icon's x-axis to mirror the graphic. Use this if you want to
19
+ * always mirror the icon regardless of the content direction. If the icon should mirror only when
20
+ * in an right-to-left language, use `shouldMirrorIconInRTL` instead.
21
+ * @default false
22
+ */
23
+ shouldMirrorIcon?: boolean;
24
+ /**
25
+ * If set to `true`, transform the icon's x-axis to mirror the graphic when the content direction
26
+ * is `rtl`. Icons don't have enough context to know if they should be mirrored in all cases.
27
+ * Setting this to `true` indicates the icon should be mirrored in right-to-left languages.
28
+ * @default false
29
+ */
30
+ shouldMirrorIconInRTL?: boolean;
17
31
  }
18
32
 
19
33
  export const Button = createComponent('button')({
@@ -25,6 +39,7 @@ export const Button = createComponent('button')({
25
39
  colors,
26
40
  iconPosition,
27
41
  shouldMirrorIcon,
42
+ shouldMirrorIconInRTL,
28
43
  size = 'medium',
29
44
  ...elemProps
30
45
  }: ButtonProps,
@@ -50,12 +65,22 @@ export const Button = createComponent('button')({
50
65
  {...elemProps}
51
66
  >
52
67
  {icon && baseIconPosition === 'start' && (
53
- <BaseButton.Icon size={size} icon={icon} shouldMirrorIcon={shouldMirrorIcon} />
68
+ <BaseButton.Icon
69
+ size={size}
70
+ icon={icon}
71
+ shouldMirrorIcon={shouldMirrorIcon}
72
+ shouldMirrorIconInRTL={shouldMirrorIconInRTL}
73
+ />
54
74
  )}
55
75
  {children && <BaseButton.Label>{children}</BaseButton.Label>}
56
76
 
57
77
  {icon && baseIconPosition && ['only', 'end'].includes(baseIconPosition) && (
58
- <BaseButton.Icon size={size} icon={icon} shouldMirrorIcon={shouldMirrorIcon} />
78
+ <BaseButton.Icon
79
+ size={size}
80
+ icon={icon}
81
+ shouldMirrorIcon={shouldMirrorIcon}
82
+ shouldMirrorIconInRTL={shouldMirrorIconInRTL}
83
+ />
59
84
  )}
60
85
  </BaseButton>
61
86
  );
@@ -68,13 +68,27 @@ export const toolbarDropdownButtonStencil = createStencil({
68
68
  },
69
69
  }),
70
70
  },
71
+ shouldMirrorIconInRTL: {
72
+ true: ({customIconPart}) => ({
73
+ [`&:dir(rtl) ${customIconPart}`]: {
74
+ marginInlineEnd: 0,
75
+ marginInlineStart: px2rem(2),
76
+ },
77
+ }),
78
+ },
71
79
  },
72
80
  });
73
81
 
74
82
  export const ToolbarDropdownButton = createComponent('button')({
75
83
  displayName: 'ToolbarDropdownButton',
76
84
  Component: (
77
- {icon, shouldMirrorIcon = false, children, ...elemProps}: ToolbarDropdownButtonProps,
85
+ {
86
+ icon,
87
+ shouldMirrorIcon = false,
88
+ shouldMirrorIconInRTL = false,
89
+ children,
90
+ ...elemProps
91
+ }: ToolbarDropdownButtonProps,
78
92
  ref,
79
93
  Element
80
94
  ) => {
@@ -83,13 +97,17 @@ export const ToolbarDropdownButton = createComponent('button')({
83
97
  ref={ref}
84
98
  as={Element}
85
99
  size="small"
86
- {...handleCsProp(elemProps, toolbarDropdownButtonStencil({shouldMirrorIcon}))}
100
+ {...handleCsProp(
101
+ elemProps,
102
+ toolbarDropdownButtonStencil({shouldMirrorIcon, shouldMirrorIconInRTL})
103
+ )}
87
104
  >
88
105
  {icon ? (
89
106
  <BaseButton.Icon
90
107
  className="wdc-toolbar-dropdown-btn-custom-icon"
91
108
  icon={icon}
92
109
  shouldMirrorIcon={shouldMirrorIcon}
110
+ shouldMirrorIconInRTL={shouldMirrorIconInRTL}
93
111
  {...toolbarDropdownButtonStencil.parts.customIcon}
94
112
  />
95
113
  ) : (
@@ -99,6 +117,7 @@ export const ToolbarDropdownButton = createComponent('button')({
99
117
  className="wdc-toolbar-dropdown-btn-arrow"
100
118
  icon={chevronDownSmallIcon}
101
119
  shouldMirrorIcon={shouldMirrorIcon}
120
+ shouldMirrorIconInRTL={shouldMirrorIconInRTL}
102
121
  {...toolbarDropdownButtonStencil.parts.chevron}
103
122
  />
104
123
  </BaseButton>
@@ -10,6 +10,7 @@ export interface ToolbarIconButtonProps extends Omit<TertiaryButtonProps, 'size'
10
10
  onToggleChange?: (toggled: boolean | undefined) => void;
11
11
  toggled?: boolean;
12
12
  shouldMirrorIcon?: boolean;
13
+ shouldMirrorIconInRTL?: boolean;
13
14
  }
14
15
 
15
16
  export const toolbarIconButtonStencil = createStencil({
@@ -74,6 +75,7 @@ export const ToolbarIconButton = createComponent('button')({
74
75
  onToggleChange,
75
76
  icon,
76
77
  shouldMirrorIcon = false,
78
+ shouldMirrorIconInRTL = false,
77
79
  toggled,
78
80
  children,
79
81
  ...elemProps
@@ -101,7 +103,15 @@ export const ToolbarIconButton = createComponent('button')({
101
103
  aria-pressed={toggled}
102
104
  {...handleCsProp(elemProps, toolbarIconButtonStencil())}
103
105
  >
104
- {icon ? <BaseButton.Icon icon={icon} shouldMirrorIcon={shouldMirrorIcon} /> : children}
106
+ {icon ? (
107
+ <BaseButton.Icon
108
+ icon={icon}
109
+ shouldMirrorIcon={shouldMirrorIcon}
110
+ shouldMirrorIconInRTL={shouldMirrorIconInRTL}
111
+ />
112
+ ) : (
113
+ children
114
+ )}
105
115
  </BaseButton>
106
116
  );
107
117
  },
@@ -11,10 +11,19 @@ export interface ButtonLabelIconProps extends Partial<SystemIconProps> {
11
11
  */
12
12
  size?: ButtonSizes;
13
13
  /**
14
- * If set to `true`, transform the icon's x-axis to mirror the graphic
14
+ * If set to `true`, transform the icon's x-axis to mirror the graphic. Use this if you want to
15
+ * always mirror the icon regardless of the content direction. If the icon should mirror only when
16
+ * in an right-to-left language, use `shouldMirrorIconInRTL` instead.
15
17
  * @default false
16
18
  */
17
19
  shouldMirrorIcon?: boolean;
20
+ /**
21
+ * If set to `true`, transform the icon's x-axis to mirror the graphic when the content direction
22
+ * is `rtl`. Icons don't have enough context to know if they should be mirrored in all cases.
23
+ * Setting this to `true` indicates the icon should be mirrored in right-to-left languages.
24
+ * @default false
25
+ */
26
+ shouldMirrorIconInRTL?: boolean;
18
27
  }
19
28
 
20
29
  const iconSizes: Record<ButtonSizes, number> = {
@@ -26,7 +35,13 @@ const iconSizes: Record<ButtonSizes, number> = {
26
35
 
27
36
  export const ButtonLabelIcon = createComponent('span')({
28
37
  Component: (
29
- {icon, size = 'medium', shouldMirrorIcon = false, ...elemProps}: ButtonLabelIconProps,
38
+ {
39
+ icon,
40
+ size = 'medium',
41
+ shouldMirrorIcon = false,
42
+ shouldMirrorIconInRTL = false,
43
+ ...elemProps
44
+ }: ButtonLabelIconProps,
30
45
  ref,
31
46
  Element
32
47
  ) => {
@@ -38,12 +53,15 @@ export const ButtonLabelIcon = createComponent('span')({
38
53
 
39
54
  return (
40
55
  <SystemIcon
56
+ ref={ref}
57
+ as={Element}
41
58
  size={iconSize}
42
59
  icon={icon}
43
- shouldMirror={shouldMirrorIcon}
44
60
  width={px2rem(iconSize)}
45
61
  height={px2rem(iconSize)}
46
62
  display="inline-block"
63
+ shouldMirror={shouldMirrorIcon}
64
+ shouldMirrorInRTL={shouldMirrorIconInRTL}
47
65
  {...elemProps}
48
66
  />
49
67
  );
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import {useCursorListModel} from './useCursorListModel';
3
3
 
4
+ import {isElementRTL} from '@workday/canvas-kit-react/common';
5
+
4
6
  export const orientationKeyMap = {
5
7
  horizontal: {
6
8
  ArrowLeft: 'goToPrevious',
@@ -56,8 +58,7 @@ const hasOwnKey = <T extends object>(obj: T, key: any): key is keyof T => obj.ha
56
58
 
57
59
  export function keyboardEventToCursorEvents(
58
60
  event: React.KeyboardEvent,
59
- model: ReturnType<typeof useCursorListModel>,
60
- isRTL: boolean
61
+ model: ReturnType<typeof useCursorListModel>
61
62
  ): boolean {
62
63
  // Test ctrl key first
63
64
  if (event.ctrlKey) {
@@ -72,6 +73,7 @@ export function keyboardEventToCursorEvents(
72
73
  }
73
74
  // Try regular keys
74
75
  const map = model.state.columnCount > 0 ? gridKeyMap : orientationKeyMap[model.state.orientation];
76
+ const isRTL = isElementRTL(event.currentTarget);
75
77
  for (const key in map) {
76
78
  if (hasOwnKey(map, key)) {
77
79
  if (isRTL ? event.key === rightToLeftMap[key] : event.key === key) {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import {useIsRTL, createElemPropsHook, slugify} from '@workday/canvas-kit-react/common';
2
+ import {createElemPropsHook, slugify} from '@workday/canvas-kit-react/common';
3
3
 
4
4
  import {getCursor, isCursor, useCursorListModel} from './useCursorListModel';
5
5
  import {keyboardEventToCursorEvents} from './keyUtils';
@@ -36,7 +36,6 @@ export const useListItemRemove = createElemPropsHook(useCursorListModel)(
36
36
  stateRef.current = model.state;
37
37
 
38
38
  const keyElementRef = React.useRef<Element | null>(null);
39
- const isRTL = useIsRTL();
40
39
 
41
40
  React.useEffect(() => {
42
41
  if (keyElementRef.current) {
@@ -81,7 +80,7 @@ export const useListItemRemove = createElemPropsHook(useCursorListModel)(
81
80
 
82
81
  return {
83
82
  onKeyDown(event: React.KeyboardEvent) {
84
- const handled = keyboardEventToCursorEvents(event, model, isRTL);
83
+ const handled = keyboardEventToCursorEvents(event, model);
85
84
  if (handled) {
86
85
  event.preventDefault();
87
86
  keyElementRef.current = event.currentTarget;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import {useIsRTL, createElemPropsHook, slugify} from '@workday/canvas-kit-react/common';
2
+ import {createElemPropsHook, slugify} from '@workday/canvas-kit-react/common';
3
3
 
4
4
  import {getCursor, isCursor} from './useCursorListModel';
5
5
  import {keyboardEventToCursorEvents} from './keyUtils';
@@ -29,7 +29,6 @@ export const useListItemRovingFocus = createElemPropsHook(useListModel)(
29
29
  stateRef.current = model.state;
30
30
 
31
31
  const keyElementRef = React.useRef<HTMLElement | null>(null);
32
- const isRTL = useIsRTL();
33
32
 
34
33
  React.useEffect(() => {
35
34
  // If the cursor change was triggered by this hook, we should change focus
@@ -53,7 +52,7 @@ export const useListItemRovingFocus = createElemPropsHook(useListModel)(
53
52
 
54
53
  return {
55
54
  onKeyDown(event: React.KeyboardEvent<HTMLElement>) {
56
- const handled = keyboardEventToCursorEvents(event, model, isRTL);
55
+ const handled = keyboardEventToCursorEvents(event, model);
57
56
  if (handled) {
58
57
  event.preventDefault();
59
58
  keyElementRef.current = event.currentTarget;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import {useIsRTL, createElemPropsHook} from '@workday/canvas-kit-react/common';
2
+ import {createElemPropsHook} from '@workday/canvas-kit-react/common';
3
3
 
4
4
  import {useCursorListModel} from './useCursorListModel';
5
5
  import {keyboardEventToCursorEvents} from './keyUtils';
@@ -15,11 +15,9 @@ import {keyboardEventToCursorEvents} from './keyUtils';
15
15
  ```
16
16
  */
17
17
  export const useListKeyboardHandler = createElemPropsHook(useCursorListModel)(model => {
18
- const isRTL = useIsRTL();
19
-
20
18
  return {
21
19
  onKeyDown(event: React.KeyboardEvent) {
22
- const handled = keyboardEventToCursorEvents(event, model, isRTL);
20
+ const handled = keyboardEventToCursorEvents(event, model);
23
21
  if (handled) {
24
22
  event.preventDefault();
25
23
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import {createElemPropsHook, useIsRTL} from '@workday/canvas-kit-react/common';
2
+ import {createElemPropsHook} from '@workday/canvas-kit-react/common';
3
3
  import {keyboardEventToCursorEvents} from '@workday/canvas-kit-react/collection';
4
4
 
5
5
  import {useComboboxModel} from './useComboboxModel';
@@ -8,12 +8,10 @@ import {useComboboxModel} from './useComboboxModel';
8
8
  * `useComboboxListKeyboardHandler` handle calling keyboard events like ArrowUp and ArrowDown only when the menu is visible.
9
9
  */
10
10
  export const useComboboxListKeyboardHandler = createElemPropsHook(useComboboxModel)(model => {
11
- const isRTL = useIsRTL();
12
-
13
11
  return {
14
12
  onKeyDown(event: React.KeyboardEvent) {
15
13
  if (model.state.visibility === 'visible') {
16
- const handled = keyboardEventToCursorEvents(event, model, isRTL);
14
+ const handled = keyboardEventToCursorEvents(event, model);
17
15
  if (handled) {
18
16
  event.preventDefault();
19
17
  }
@@ -145,32 +145,9 @@ const theme: EmotionCanvasTheme = {
145
145
 
146
146
  ### Bidirectionality
147
147
 
148
- The `CanvasProvider` also provides support for bidirectionality, useful for RTL languages. The
149
- direction, part of the theme, is set using `ContentDirection.LTR` or `ContentDirection.RTL`.
150
-
151
- You can nest `CanvasProvider` if you need to set a different direction for some components in your
152
- React tree (See below: Nesting CanvasProvider components).
153
-
154
- `CanvasProvider` wraps your components with a `bdo` element that has the `dir` attribute set to the
155
- value of the theme direction. Styled components using the
156
- [Canvas `styled` function](https://github.com/Workday/canvas-kit/blob/master/modules/common/react/lib/theming/styled.ts)
157
- will have their styles automatically flipped if dictated by the closest theme object.
158
-
159
- ```tsx
160
- import {
161
- CanvasProvider,
162
- ContentDirection,
163
- EmotionCanvasTheme,
164
- } from '@workday/canvas-kit-react/common';
165
-
166
- const rtlTheme: EmotionCanvasTheme = {
167
- canvas: {
168
- direction: ContentDirection.RTL,
169
- },
170
- };
171
-
172
- <CanvasProvider theme={rtlTheme}>{/* Your app with Canvas components */}</CanvasProvider>;
173
- ```
148
+ We strongly encourage the use of
149
+ [CSS logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties)
150
+ for styling. All previous bidirectionality in the Canvas theme have been deprecated.
174
151
 
175
152
  ### Nesting CanvasProvider components
176
153
 
@@ -547,25 +524,3 @@ const styles = {
547
524
  },
548
525
  };
549
526
  ```
550
-
551
- ## useIsRTL Hook
552
-
553
- `useIsRTL` is a small hook to support right-to-left logic. If a theme exists in React context, the
554
- component will use it automatically, or you can explicitly provide a theme object.
555
-
556
- ### Usage
557
-
558
- ```ts
559
- // this will automatically pull the theme from context if it exists.
560
- const isRTL = useIsRTL();
561
- ```
562
-
563
- ```ts
564
- // or you can explicitly provide a (partial) theme object.
565
- const RTLTheme = {
566
- canvas: {
567
- direction: ContentDirection.RTL,
568
- },
569
- };
570
- const isRTL = useIsRTL(RTLTheme);
571
- ```
@@ -9,8 +9,12 @@ function useDefaultTheme<T, C>(theme: T | undefined, config: C, fn: (config: C)
9
9
  /**
10
10
  * This is a small hook to support right-to-left logic.
11
11
  * It returns a boolean
12
- * @example
12
+ *
13
+ * ```ts
13
14
  * const isRTL = useIsRTL();
15
+ * ```
16
+ *
17
+ * @deprecated Use isElementRTL instead.
14
18
  */
15
19
 
16
20
  export const useIsRTL = (partialTheme?: PartialEmotionCanvasTheme) => {
@@ -1,5 +1,6 @@
1
1
  export * from './colorUtils';
2
2
  export * from './getTranslateFromOrigin';
3
+ export * from './isElementRTL';
3
4
  export * from './dispatchInputEvent';
4
5
  export * from './changeFocus';
5
6
  export * from './makeMq';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Returns true if element has a right-to-left content direction. This is most useful to get
3
+ * direction from a JavaScript event. If you desire to get a direction for styling, use [CSS Logical
4
+ * Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties)
5
+ *
6
+ * The performance cost of getting the direction from an element is negligible, but it is intended
7
+ * to be used in event handlers and not a part of render functions.
8
+ *
9
+ * ```ts
10
+ * onKeyDown(e) {
11
+ * const isRTL = isElementRTL(e.currentTarget);
12
+ *
13
+ * if (e.key === 'ArrowRight') {
14
+ * if (isRTL) {
15
+ * // Right arrow moves to the right even on RTL languages, but "right" doesn't mean
16
+ * //"advance" in RTL. Previous is to the right of the current in RTL.
17
+ * model.events.goToPreviousRow();
18
+ * } else {
19
+ * model.events.goToNextRow();
20
+ * }
21
+ * }
22
+ * ```
23
+ */
24
+ export const isElementRTL = (element: Element): boolean => {
25
+ const direction = getComputedStyle(element).direction;
26
+ return direction === 'rtl';
27
+ };
@@ -52,19 +52,19 @@ exports.avatarStencil = (0, canvas_kit_styling_1.createStencil)({
52
52
  icon: 'avatar-icon',
53
53
  image: 'avatar-image',
54
54
  },
55
- base: { name: "15gazi", styles: "box-sizing:border-box;background:var(--cnvs-sys-color-bg-caution-default);position:relative;display:flex;align-items:center;justify-content:center;padding:0;border:0;overflow:hidden;cursor:default;pointer-events:none;border-radius:var(--cnvs-sys-shape-round);width:var(--size-avatar-a7d274);height:var(--size-avatar-a7d274);&:focus-visible, &.focus{outline:none;box-shadow:0 0 0 2px var(--cnvs-sys-color-border-inverse, rgba(255,255,255,1)), 0 0 0 4px var(--cnvs-brand-common-focus-outline, rgba(8,117,225,1));}:is(button){cursor:pointer;pointer-events:auto;}&:disabled, &.disabled{opacity:var(--cnvs-sys-opacity-disabled);}[data-part=\"avatar-icon\"]{transition:opacity 150ms linear;display:flex;align-items:center;justify-content:center;--size-svg-728c60:calc(var(--size-avatar-a7d274) * 0.625);opacity:1;}[data-part=\"avatar-image\"]{position:absolute;width:100%;height:100%;border-radius:999px;transition:opacity 150ms linear;opacity:0;}" },
55
+ base: { name: "15gazi", styles: "box-sizing:border-box;background:var(--cnvs-sys-color-bg-caution-default);position:relative;display:flex;align-items:center;justify-content:center;padding:0;border:0;overflow:hidden;cursor:default;pointer-events:none;border-radius:var(--cnvs-sys-shape-round);width:var(--size-avatar-a7d274);height:var(--size-avatar-a7d274);&:focus-visible, &.focus{outline:none;box-shadow:0 0 0 2px var(--cnvs-sys-color-border-inverse, rgba(255,255,255,1)), 0 0 0 4px var(--cnvs-brand-common-focus-outline, rgba(8,117,225,1));}:is(button){cursor:pointer;pointer-events:auto;}&:disabled, &.disabled{opacity:var(--cnvs-sys-opacity-disabled);}[data-part=\"avatar-icon\"]{transition:opacity 150ms linear;display:flex;align-items:center;justify-content:center;--size-svg-8fcab8:calc(var(--size-avatar-a7d274) * 0.625);opacity:1;}[data-part=\"avatar-image\"]{position:absolute;width:100%;height:100%;border-radius:999px;transition:opacity 150ms linear;opacity:0;}" },
56
56
  modifiers: {
57
57
  variant: {
58
58
  light: { name: "gsirr", styles: "background-color:var(--cnvs-sys-color-bg-alt-default);[data-part=\"avatar-icon\"]{--color-system-icon-3a4847:var(--cnvs-sys-color-fg-default);}" },
59
59
  dark: { name: "4bycmc", styles: "background-color:var(--cnvs-sys-color-bg-primary-default);[data-part=\"avatar-icon\"]{--color-system-icon-3a4847:var(--cnvs-sys-color-fg-inverse);}" }
60
60
  },
61
61
  size: {
62
- extraSmall: { name: "3iw4vg", styles: "width:var(--cnvs-sys-space-x4);height:var(--cnvs-sys-space-x4);[data-part=\"avatar-icon\"]{--size-svg-728c60:calc(var(--cnvs-sys-space-x4) * 0.625);}" },
63
- small: { name: "1gplfi", styles: "width:var(--cnvs-sys-space-x6);height:var(--cnvs-sys-space-x6);[data-part=\"avatar-icon\"]{--size-svg-728c60:calc(var(--cnvs-sys-space-x6) * 0.625);}" },
64
- medium: { name: "q509p", styles: "width:var(--cnvs-sys-space-x8);height:var(--cnvs-sys-space-x8);[data-part=\"avatar-icon\"]{--size-svg-728c60:calc(var(--cnvs-sys-space-x8) * 0.625);}" },
65
- large: { name: "b96gk", styles: "width:var(--cnvs-sys-space-x10);height:var(--cnvs-sys-space-x10);[data-part=\"avatar-icon\"]{--size-svg-728c60:calc(var(--cnvs-sys-space-x10) * 0.625);}" },
66
- extraLarge: { name: "2yj8lk", styles: "width:var(--cnvs-sys-space-x16);height:var(--cnvs-sys-space-x16);[data-part=\"avatar-icon\"]{--size-svg-728c60:calc(var(--cnvs-sys-space-x16) * 0.625);}" },
67
- extraExtraLarge: { name: "4ezdpg", styles: "width:calc(var(--cnvs-sys-space-x10) * 3);height:calc(var(--cnvs-sys-space-x10) * 3);[data-part=\"avatar-icon\"]{--size-svg-728c60:calc(calc(var(--cnvs-sys-space-x10) * 3) * 0.625);}" }
62
+ extraSmall: { name: "3iw4vg", styles: "width:var(--cnvs-sys-space-x4);height:var(--cnvs-sys-space-x4);[data-part=\"avatar-icon\"]{--size-svg-8fcab8:calc(var(--cnvs-sys-space-x4) * 0.625);}" },
63
+ small: { name: "1gplfi", styles: "width:var(--cnvs-sys-space-x6);height:var(--cnvs-sys-space-x6);[data-part=\"avatar-icon\"]{--size-svg-8fcab8:calc(var(--cnvs-sys-space-x6) * 0.625);}" },
64
+ medium: { name: "q509p", styles: "width:var(--cnvs-sys-space-x8);height:var(--cnvs-sys-space-x8);[data-part=\"avatar-icon\"]{--size-svg-8fcab8:calc(var(--cnvs-sys-space-x8) * 0.625);}" },
65
+ large: { name: "b96gk", styles: "width:var(--cnvs-sys-space-x10);height:var(--cnvs-sys-space-x10);[data-part=\"avatar-icon\"]{--size-svg-8fcab8:calc(var(--cnvs-sys-space-x10) * 0.625);}" },
66
+ extraLarge: { name: "2yj8lk", styles: "width:var(--cnvs-sys-space-x16);height:var(--cnvs-sys-space-x16);[data-part=\"avatar-icon\"]{--size-svg-8fcab8:calc(var(--cnvs-sys-space-x16) * 0.625);}" },
67
+ extraExtraLarge: { name: "4ezdpg", styles: "width:calc(var(--cnvs-sys-space-x10) * 3);height:calc(var(--cnvs-sys-space-x10) * 3);[data-part=\"avatar-icon\"]{--size-svg-8fcab8:calc(calc(var(--cnvs-sys-space-x10) * 3) * 0.625);}" }
68
68
  },
69
69
  objectFit: {
70
70
  contain: { name: "3140on", styles: "[data-part=\"avatar-image\"]{object-fit:contain;}" },
@@ -15,7 +15,7 @@ exports.breadcrumbsItemStencil = (0, canvas_kit_styling_1.createStencil)({
15
15
  parts: {
16
16
  chevronRightIcon: 'breadcrumbs-item-chevron-right-icon',
17
17
  },
18
- base: { name: "tpjo7", styles: "box-sizing:border-box;align-items:center;display:inline-flex;white-space:nowrap;--size-svg-728c60:1.25rem;--color-system-icon-3a4847:var(--cnvs-sys-color-icon-default);[data-part=\"breadcrumbs-item-chevron-right-icon\"]{height:var(--cnvs-sys-space-x8);width:var(--cnvs-sys-space-x8);justify-content:center;align-items:center;display:inline-flex;:dir(rtl){transform:scaleX(-1);}}" }
18
+ base: { name: "tpjo7", styles: "box-sizing:border-box;align-items:center;display:inline-flex;white-space:nowrap;--size-svg-8fcab8:1.25rem;--color-system-icon-3a4847:var(--cnvs-sys-color-icon-default);[data-part=\"breadcrumbs-item-chevron-right-icon\"]{height:var(--cnvs-sys-space-x8);width:var(--cnvs-sys-space-x8);justify-content:center;align-items:center;display:inline-flex;:dir(rtl){transform:scaleX(-1);}}" }
19
19
  }, "breadcrumbs-item-3a0e6d");
20
20
  exports.useBreadcrumbsItem = (0, common_1.composeHooks)(collection_1.useOverflowListItemMeasure, collection_1.useListItemRegister);
21
21
  exports.BreadcrumbsItem = (0, common_1.createSubcomponent)('li')({
@@ -16,7 +16,7 @@ exports.breadcrumbsOverflowButtonStencil = (0, canvas_kit_styling_1.createStenci
16
16
  overflowButton: 'breadcrumbs-overflow-button',
17
17
  chevronRightIcon: 'breadcrumbs-overflow-button-chevron-right-icon',
18
18
  },
19
- base: { name: "a78su", styles: "box-sizing:border-box;align-items:center;display:flex;--color-system-icon-3a4847:var(--cnvs-sys-color-icon-default);--size-svg-728c60:1.25rem;[data-part=\"breadcrumbs-overflow-button-chevron-right-icon\"]{height:var(--cnvs-sys-space-x8);width:var(--cnvs-sys-space-x8);justify-content:center;align-items:center;display:inline-flex;:dir(rtl){transform:scaleX(-1);}}" }
19
+ base: { name: "a78su", styles: "box-sizing:border-box;align-items:center;display:flex;--color-system-icon-3a4847:var(--cnvs-sys-color-icon-default);--size-svg-8fcab8:1.25rem;[data-part=\"breadcrumbs-overflow-button-chevron-right-icon\"]{height:var(--cnvs-sys-space-x8);width:var(--cnvs-sys-space-x8);justify-content:center;align-items:center;display:inline-flex;:dir(rtl){transform:scaleX(-1);}}" }
20
20
  }, "breadcrumbs-overflow-button-9c6f83");
21
21
  exports.useBreadcrumbsOverflowButton = (0, common_1.composeHooks)((0, common_1.createElemPropsHook)(useBreadcrumbsModel_1.useBreadcrumbsModel)(() => ({
22
22
  'aria-haspopup': true,
@@ -32,11 +32,6 @@ export interface ButtonContainerProps extends Partial<SystemIconProps>, GrowthBe
32
32
  * @default 'start'
33
33
  */
34
34
  iconPosition?: IconPositions;
35
- /**
36
- * If set to `true`, transform the icon's x-axis to mirror the graphic
37
- * @default false
38
- */
39
- shouldMirrorIcon?: boolean;
40
35
  children?: React.ReactNode;
41
36
  }
42
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"BaseButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/BaseButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAkB,cAAc,EAAY,MAAM,kCAAkC,CAAC;AAE5F,OAAO,EAAC,eAAe,EAAoB,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAG9D,MAAM,WAAW,oBAAqB,SAAQ,OAAO,CAAC,eAAe,CAAC,EAAE,cAAc;IACpF;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC;CAAG;AAE7E;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;CAmD/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa;IA6ItB;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAiIL,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,UAAU;;;CAsCrB,CAAC"}
1
+ {"version":3,"file":"BaseButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/BaseButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAkB,cAAc,EAAY,MAAM,kCAAkC,CAAC;AAE5F,OAAO,EAAC,eAAe,EAAoB,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAG9D,MAAM,WAAW,oBAAqB,SAAQ,OAAO,CAAC,eAAe,CAAC,EAAE,cAAc;IACpF;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC;CAAG;AAE7E;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;CAmD/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa;IA6ItB;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAiIL,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,UAAU;;;CAqCrB,CAAC"}