153
153
</KButton >
154
154
155
155
<button
156
- v-else
156
+ v-else-if = " typeof attrs.onClick === 'function' "
157
157
:class =" `x-action-appearance-${props.appearance}`"
158
158
data-testid =" x-action"
159
159
v-bind =" $attrs"
169
169
</template >
170
170
<span ><slot name =" default" /></span >
171
171
</button >
172
+ <template
173
+ v-else
174
+ >
175
+ <slot
176
+ name =" default"
177
+ :inactive =" true"
178
+ />
179
+ </template >
172
180
</template >
173
181
</template >
174
182
<script lang="ts" setup>
175
183
import { KUI_ICON_SIZE_40 } from ' @kong/design-tokens'
176
184
import { KDropdownItem , KButton } from ' @kong/kongponents'
177
- import { computed , watch , inject , provide } from ' vue'
185
+ import { computed , watch , inject , provide , useAttrs } from ' vue'
178
186
import { RouterLink , useRouter } from ' vue-router'
179
187
180
188
import { useProtocolHandler } from ' ../../'
@@ -189,6 +197,12 @@ type RouteLocationRawWithBooleanQuery = Omit<RouteLocationNamedRaw, 'query'> & {
189
197
const emit = defineEmits <{
190
198
(event : ' click' ): Event
191
199
}>()
200
+
201
+ defineSlots <{
202
+ default(props : {
203
+ inactive? : boolean
204
+ }): any
205
+ }>()
192
206
const props = withDefaults (defineProps <{
193
207
action? : ' default' | ' docs' | ' create' | ' copy' | ' action' | ' expand' | ' refresh' | ' progress'
194
208
appearance? : ' primary' | ' secondary' | ' tertiary' | ' danger' | ' anchor'
@@ -205,7 +219,8 @@ const props = withDefaults(defineProps<{
205
219
for: ' ' ,
206
220
})
207
221
208
- provide (' x-action' , {})
222
+ const attrs = useAttrs ()
223
+
209
224
const group = inject <{
210
225
expanded: boolean
211
226
} | undefined >(' x-action-group' , undefined )
@@ -217,6 +232,10 @@ const href = computed(() => props.href.includes('://') ? protocolHandler(props.h
217
232
const target = computed (() => props .href .length > 0 && props .href === href .value ? ' _blank' : undefined )
218
233
const rel = computed (() => target .value === ' _blank' ? ' noopener noreferrer' : href .value .length > 0 && props .href === href .value ? undefined : ' x-internal' )
219
234
235
+ if (href .value .length > 0 || typeof attrs .onClick === ' function' || props .for ) {
236
+ provide (' x-action' , {})
237
+ }
238
+
220
239
const query = computed (() => {
221
240
return Object .entries (props .to .query ?? {}).reduce <Record <string , string | number | null | undefined >>((prev , [key , value ]) => {
222
241
switch (true ) {
0 commit comments