|
3 | 3 | ref="containerNode", |
4 | 4 | v-if="selectMode", |
5 | 5 | ) |
6 | | - div(v-if="smallScreen", ref="smallScreenGroupNode") |
| 6 | + div(v-if="smallScreen") |
7 | 7 | div( |
8 | 8 | :class="smallScreenGroupClassName", |
9 | 9 | ref="smallScreenGroupNode", |
|
53 | 53 | span(v-if="paginatedSelectAllText && paginatedSelectAllAction", aria-live="polite") {{ paginatedSelectAllText }} |
54 | 54 | template(v-else) {{ paginatedSelectAllText }} |
55 | 55 | Button( |
56 | | - v-if="paginatedSelectAllAction", |
| 56 | + v-if="paginatedSelectAllAction && paginatedSelectAllAction.onAction", |
57 | 57 | plain, |
58 | 58 | :disabled="disabled", |
59 | 59 | @click="paginatedSelectAllAction.onAction", |
60 | 60 | ) {{ paginatedSelectAllAction.content }} |
61 | | - div( |
62 | | - v-else, |
63 | | - ref="largeScreenGroupNode", |
64 | | - ) |
| 61 | + |
| 62 | + div(v-else) |
65 | 63 | div( |
66 | 64 | :class="largeScreenGroupClassName", |
67 | 65 | ref="largeScreenGroupNode", |
68 | 66 | ) |
69 | 67 | EventListener(event="resize", :handler="handleResize") |
70 | 68 | div( |
71 | 69 | :class="styles.ButtonGroupWrapper", |
72 | | - ref="setLargeScreenButtonsNode", |
| 70 | + ref="largeScreenButtonsNode", |
73 | 71 | ) |
74 | 72 | ButtonGroup( |
75 | 73 | v-if="(promotedActions && numberOfPromotedActionsToRender > 0) || hasActionsPopover", |
76 | 74 | segmented, |
| 75 | + no-item-wrap, |
77 | 76 | ) |
78 | | - CheckableButton(v-bind="checkableButtonProps", @toggle="emits('toggle-all')") |
79 | | - template( |
| 77 | + ButtonGroupItem |
| 78 | + CheckableButton(v-bind="checkableButtonProps", @toggle-all="emits('toggle-all')") |
| 79 | + ButtonGroupItem( |
80 | 80 | v-if="promotedActions && numberOfPromotedActionsToRender > 0" |
81 | 81 | v-for="action, index in promotedActions.slice(0, numberOfPromotedActionsToRender)", |
82 | 82 | :key="index", |
|
92 | 92 | v-bind="action", |
93 | 93 | :handleMeasurement="handleMeasurement", |
94 | 94 | ) |
95 | | - div( |
96 | | - v-if="hasActionsPopover", |
97 | | - ref="moreActionsNode", |
98 | | - ) |
99 | | - Popover( |
100 | | - :active="largeScreenPopoverVisible", |
101 | | - @close="toggleLargeScreenPopover", |
102 | | - ) |
103 | | - template(#activator) |
104 | | - BulkActionButton( |
105 | | - disclosure, |
106 | | - :content="activatorLabel", |
107 | | - :disabled="disabled", |
108 | | - :indicator="isNewBadgeInBadgeActions", |
109 | | - @action="toggleLargeScreenPopover", |
110 | | - ) |
111 | | - template(#content) |
112 | | - ActionList( |
113 | | - :sections="combinedActions", |
114 | | - @action-any-item="toggleLargeScreenPopover", |
115 | | - ) |
116 | | - CheckableButton(v-else, v-bind="checkableButtonProps") |
| 95 | + ButtonGroupItem(v-if="hasActionsPopover") |
| 96 | + div(ref="moreActionsNode") |
| 97 | + Popover( |
| 98 | + :active="largeScreenPopoverVisible", |
| 99 | + @close="toggleLargeScreenPopover", |
| 100 | + ) |
| 101 | + template(#activator) |
| 102 | + BulkActionButton( |
| 103 | + disclosure, |
| 104 | + :content="activatorLabel", |
| 105 | + :disabled="disabled", |
| 106 | + :indicator="isNewBadgeInBadgeActions", |
| 107 | + @action="toggleLargeScreenPopover", |
| 108 | + ) |
| 109 | + template(#content) |
| 110 | + ActionList( |
| 111 | + :sections="combinedActions", |
| 112 | + @action-any-item="toggleLargeScreenPopover", |
| 113 | + ) |
| 114 | + CheckableButton(v-else, v-bind="checkableButtonProps", @toggle-all="emits('toggle-all')") |
117 | 115 | div( |
118 | 116 | v-if="paginatedSelectAllAction", |
119 | 117 | :class="styles.PaginatedSelectAll" |
120 | 118 | ) |
121 | 119 | span(v-if="paginatedSelectAllText && paginatedSelectAllAction", aria-live="polite") {{ paginatedSelectAllText }} |
122 | 120 | template(v-else) {{ paginatedSelectAllText }} |
123 | 121 | Button( |
124 | | - v-if="paginatedSelectAllAction", |
| 122 | + v-if="paginatedSelectAllAction && paginatedSelectAllAction.onAction", |
125 | 123 | plain, |
126 | 124 | :disabled="disabled", |
127 | 125 | @click="paginatedSelectAllAction.onAction", |
128 | 126 | ) {{ paginatedSelectAllAction.content }} |
129 | 127 | </template> |
130 | 128 |
|
131 | 129 | <script setup lang="ts"> |
132 | | -import { ref, computed, onMounted, watch } from 'vue'; |
| 130 | +import { ref, computed, watch } from 'vue'; |
133 | 131 | import { debounce } from 'polaris/polaris-react/src/utilities/debounce'; |
134 | | -import { tokens } from '@shopify/polaris-tokens'; |
135 | 132 | import { classNames } from 'polaris/polaris-react/src/utilities/css'; |
136 | 133 | import { clamp } from 'polaris/polaris-react/src/utilities/clamp'; |
137 | 134 | import type { MenuGroupDescriptor } from '@/components/ActionMenu/components/MenuGroup/utils'; |
138 | | -import type { ActionListSection } from '@/components/ActionList/utils'; |
139 | 135 | import type { Action } from '@/utilities/type'; |
140 | | -import type { DisableableAction, BadgeAction } from '@/utilities/interface'; |
141 | 136 | import { UseI18n } from '@/use'; |
142 | 137 | import styles from '@/classes/BulkActions.json'; |
143 | | -import { ActionList, Popover, Button, ButtonGroup, CheckableButton, EventListener } from '@/components'; |
| 138 | +import { ActionList, Popover, Button, ButtonGroup, ButtonGroupItem, CheckableButton, EventListener } from '@/components'; |
144 | 139 | import { BulkActionButton, BulkActionMenu } from './components'; |
145 | | -
|
146 | | -type BulkAction = DisableableAction & BadgeAction; |
147 | | -
|
148 | | -type BulkActionListSection = ActionListSection; |
149 | | -
|
150 | | -type TransitionStatus = 'entering' | 'entered' | 'exiting' | 'exited'; |
151 | | -
|
152 | | -const MAX_PROMOTED_ACTIONS = 2; |
| 140 | +import type { BulkAction, BulkActionListSection } from './utils'; |
153 | 141 |
|
154 | 142 | interface BulkActionsProps { |
155 | 143 | /** Visually hidden text for screen readers */ |
@@ -250,13 +238,6 @@ const numberOfPromotedActionsToRender = computed<number>(() => { |
250 | 238 | return clamp(counter, 0, props.promotedActions.length); |
251 | 239 | }); |
252 | 240 |
|
253 | | -const hasActions = computed(() => { |
254 | | - return Boolean( |
255 | | - (props.promotedActions && props.promotedActions.length > 0) || |
256 | | - (props.actions && props.actions.length > 0), |
257 | | - ); |
258 | | -}); |
259 | | -
|
260 | 241 | const actionSectionsHandler = (): BulkActionListSection[] | undefined => { |
261 | 242 | if (!props.actions || props.actions.length === 0) { |
262 | 243 | return; |
|
0 commit comments