Skip to content

Commit 4f2eb61

Browse files
committed
feat: add disabled prop to the button group
1 parent a3803b5 commit 4f2eb61

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

adminforth/spa/src/afcl/ButtonGroup.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="inline-flex rounded-md shadow-xs" role="group">
3-
<button v-for="button in buttons" :key="`${button}-button-controll`"
4-
class="inline-flex items-center text-sm font-medium border-t border-b border-r border-lightButtonGroupBorder focus:z-10 focus:ring-2 dark:border-darkButtonGroupBorder"
3+
<button v-for="button in buttons" :key="`${button}-button-controll`" :disabled="slotProps[button]?.disabled"
4+
class="inline-flex items-center text-sm font-medium border-t border-b border-r border-lightButtonGroupBorder focus:z-10 focus:ring-2 dark:border-darkButtonGroupBorder disabled:opacity-50 disabled:cursor-not-allowed"
55
:class="[
66
buttonsStyles[button] === 'rounded' ? 'border rounded-lg'
77
: buttonsStyles[button] === 'rounded-left' ? 'border rounded-s-lg'
@@ -24,6 +24,7 @@
2424
const buttons : Ref<string[]> = ref([]);
2525
const buttonsStyles : Ref<Record<string, string>> = ref({});
2626
const activeButton = ref('');
27+
const slotProps: Record<string, any> = ref({});
2728
2829
const emits = defineEmits([
2930
'update:activeButton',
@@ -49,6 +50,12 @@
4950
[button]: getButtonsClasses(button)
5051
}
5152
buttonsStyles.value = { ...buttonsStyles.value, ...temp };
53+
const slot = slots[`button:${button}`];
54+
if (slot && slot()[0]?.props) {
55+
slotProps[button] = slot()[0].props;
56+
} else {
57+
slotProps[button] = {};
58+
}
5259
}
5360
});
5461

0 commit comments

Comments
 (0)