@citizenplane/pimp 9.5.1 → 9.5.3

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.
@@ -1,12 +1,12 @@
1
1
  <template>
2
2
  <div class="cpItemActions" :class="componentDynamicClasses">
3
- <cp-button-group>
3
+ <cp-button-group v-if="hasActions" class="cpItemActions__buttonGroup">
4
4
  <cp-menu-item
5
5
  v-for="(action, index) in slicedActions"
6
6
  v-bind="action"
7
7
  :key="index"
8
8
  hide-label
9
- @click="action.command"
9
+ @click.stop="action.command"
10
10
  />
11
11
  </cp-button-group>
12
12
  <cp-contextual-menu
@@ -46,11 +46,13 @@ const defaultAction = {
46
46
  command: (event: MouseEvent) => showContextualMenu(event),
47
47
  }
48
48
 
49
+ const hasActions = computed(() => !!props.actions.length)
50
+
49
51
  const slicedActions = computed(() => {
50
52
  const actionsCopy = [...props.actions]
51
53
 
52
54
  if (actionsCopy.length <= props.quickOptionsLimit) {
53
- return [...actionsCopy]
55
+ return [...actionsCopy, defaultAction]
54
56
  }
55
57
 
56
58
  const firstActions = actionsCopy.slice(0, props.quickOptionsLimit)
@@ -68,6 +70,10 @@ const slicedActions = computed(() => {
68
70
  transform 150ms ease,
69
71
  opacity 150ms ease;
70
72
 
73
+ &__buttonGroup {
74
+ background-color: colors.$neutral-light;
75
+ }
76
+
71
77
  .cpMenuItem__button {
72
78
  padding: sp.$space-xs sp.$space-sm;
73
79
  }
@@ -83,8 +89,8 @@ const slicedActions = computed(() => {
83
89
  pointer-events: none;
84
90
  }
85
91
 
86
- [cp-item-actions-trigger]:has(.cpItemActions--isDropdownOpen) > .cpItemActions,
87
- [cp-item-actions-trigger]:is(:focus-within, :focus-visible, :hover) > .cpItemActions {
92
+ [cp-item-actions-trigger]:has(.cpItemActions--isDropdownOpen) .cpItemActions,
93
+ [cp-item-actions-trigger]:is(:focus-within, :focus-visible, :hover) .cpItemActions {
88
94
  opacity: 1;
89
95
  transform: translate3d(0, -50%, 0);
90
96
  pointer-events: auto;
@@ -51,12 +51,14 @@ export const Default: Story = {
51
51
  marginBottom: '16px',
52
52
  }
53
53
 
54
- return { actions, listItemStyle, listItems }
54
+ const parentClick = () => alert('Parent clicked')
55
+
56
+ return { actions, listItemStyle, listItems, parentClick }
55
57
  },
56
58
  template: `
57
59
  <div style="padding: 20px; display: flex; flex-direction: column; gap: 16px; min-width: 400px;">
58
60
  <ul>
59
- <li v-for="(item, index) in listItems" :key="item" :style="listItemStyle" cp-item-actions-trigger>
61
+ <li v-for="(item, index) in listItems" :key="item" :style="listItemStyle" @click="parentClick" cp-item-actions-trigger>
60
62
  <p>Item {{ index + 1 }}</p>
61
63
  <CpItemActions
62
64
  size="xs"