@workday/canvas-kit-react 9.0.0 → 9.1.0-425-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