+
+
+
+
diff --git a/src/compositions/groupable/groupable.ts b/src/compositions/groupable/groupable.ts
index bb2f0bf43d..c191488496 100644
--- a/src/compositions/groupable/groupable.ts
+++ b/src/compositions/groupable/groupable.ts
@@ -11,9 +11,9 @@ type GroupableInstance = {
* Used to make child item part of the group context. Needs to be used in a component that is a child
* of a component that has the `useGroupableParent` composition enabled
*/
-export function useGroupable(value?: string | number) {
+export function useGroupable(value?: string | number, group = 'item-group') {
// Injects the registration / toggle functions from the parent scope
- const parentFunctions = inject('item-group', null);
+ const parentFunctions = inject(group, null);
if (isEmpty(parentFunctions)) {
return {
@@ -65,7 +65,8 @@ type GroupableParentOptions = {
*/
export function useGroupableParent(
state: GroupableParentState = {},
- options: GroupableParentOptions = {}
+ options: GroupableParentOptions = {},
+ group = 'item-group'
) {
// References to the active state and value of the individual child items
const items = ref
([]);
@@ -95,7 +96,7 @@ export function useGroupableParent(
// Provide the needed functions to all children groupable components. Note: nested item groups
// will override the item-group namespace, making nested item groups possible.
- provide('item-group', { register, unregister, toggle });
+ provide(group, { register, unregister, toggle });
// Whenever the value of the selection changes, we have to update all the children's internal
// states. If not, you can have an activated item that's not actually active.
diff --git a/src/compositions/groupable/readme.md b/src/compositions/groupable/readme.md
index 120d928369..126215a892 100644
--- a/src/compositions/groupable/readme.md
+++ b/src/compositions/groupable/readme.md
@@ -8,7 +8,7 @@ the functionality of the `v-item-group` base component, and other groupable comp
Use the `useGroupableParent` function in a parent component that will contain one or more components
in it's slots (deeply nested or not) that use the `useGroupable` compositions.
-### `useGroupableParent(state: GroupableParentState, options: GroupableParentOptions): void`
+### `useGroupableParent(state: GroupableParentState, options: GroupableParentOptions, group: string): void`
The `useGroupableParent` composition accepts two paremeters: state and options.
State includes a `selection` key that can be used to pass an array of selected items, so you can
@@ -42,7 +42,10 @@ export default defineComponent({
});
```
-### `useGroupable(value: string | number): { active: Ref; toggle: () => void; }`
+The optional group parameter allows you to control to what group this parent is registered. This
+can be useful when you have complexly nested groups.
+
+### `useGroupable(value: string | number | undefined, group: string): { active: Ref; toggle: () => void; }`
Registers this component as a child of the first parent component that uses the `useGroupableParent`
component.
@@ -61,3 +64,6 @@ export default defineComponent({
}
});
```
+
+The optional group parameter allows you to control to what group this child is registered. This
+can be useful when you have complexly nested groups.