@workday/canvas-kit-react 9.0.1 → 10.0.0-alpha.426-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.
@@ -19,6 +19,12 @@ export const useActionBarModel = createModelHook({
19
19
  */
20
20
  orientation: 'horizontal' as typeof useOverflowListModel.defaultConfig.orientation,
21
21
  menuConfig: {} as Partial<typeof useMenuModel.defaultConfig>,
22
+ /**
23
+ * The maximum number of actions that can be visible.
24
+ * Must be greater than 1 and less than items.length.
25
+ * @default 3
26
+ */
27
+ maximumVisible: 3,
22
28
  },
23
29
  requiredConfig: useOverflowListModel.requiredConfig,
24
30
  })(config => {
@@ -38,9 +44,20 @@ export const useActionBarModel = createModelHook({
38
44
  let nonInteractiveIds = model.state.nonInteractiveIds;
39
45
  const totalSize = model.state.items.length;
40
46
 
41
- // Only show a maximum of 3 buttons
42
- if (totalSize - hiddenIds.length >= 3) {
43
- hiddenIds = items.slice(3, totalSize).map(getId);
47
+ console.log(config.maximumVisible);
48
+
49
+ // Only show maximumVisible buttons
50
+ const maximumVisible: number =
51
+ !config.maximumVisible || config.maximumVisible < 1
52
+ ? 3 // should fallback to default value
53
+ : config.maximumVisible > totalSize
54
+ ? totalSize
55
+ : config.maximumVisible;
56
+
57
+ console.log('maximumVisible', maximumVisible);
58
+
59
+ if (totalSize - hiddenIds.length >= maximumVisible) {
60
+ hiddenIds = items.slice(maximumVisible, totalSize).map(getId);
44
61
  }
45
62
 
46
63
  // Always show the first button and make sure it is interactive
@@ -359,7 +359,7 @@ export const Checkbox = createComponent('input')({
359
359
  htmlFor={inputId}
360
360
  disabled={disabled}
361
361
  variant={variant}
362
- paddingInlineStart={checkboxLabelDistance}
362
+ paddingLeft={checkboxLabelDistance}
363
363
  >
364
364
  {label}
365
365
  </LabelText>
@@ -10,27 +10,15 @@ export const changeFocus = (element: unknown) => {
10
10
  return;
11
11
  }
12
12
 
13
- if (hasCallableProperty(element, 'focus')) {
13
+ if (element instanceof HTMLElement) {
14
14
  // Dispatch an unidentified keyboard event for an input provider prior to a focus change so that
15
15
  // the ring will appear.
16
- if (typeof KeyboardEvent === 'function' && hasCallableProperty(element, 'dispatchEvent')) {
16
+ if (typeof KeyboardEvent === 'function') {
17
17
  const event = new KeyboardEvent('keydown', {bubbles: true, key: 'Unidentified'});
18
+
18
19
  element.dispatchEvent(event);
19
20
  }
20
21
 
21
22
  element.focus();
22
23
  }
23
24
  };
24
-
25
- type Callable<K extends string> = {
26
- [P in K]: Function;
27
- };
28
-
29
- function hasCallableProperty<K extends string>(input: unknown, method: K): input is Callable<K> {
30
- return (
31
- !!input &&
32
- typeof input === 'object' &&
33
- method in input! &&
34
- typeof (input as any)[method] === 'function'
35
- );
36
- }