@teammodlr/ui-kit 3.0.0-beta.18 → 3.0.0-beta.19

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teammodlr/ui-kit",
3
- "version": "3.0.0-beta.18",
3
+ "version": "3.0.0-beta.19",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.es.js",
@@ -21,7 +21,7 @@
21
21
  @focus-outside="handleFocusOutside"
22
22
  @interact-outside.prevent
23
23
  >
24
- <FocusScope :trapped="focusTrap" :loop="focusTrap">
24
+ <FocusScope :trapped="activeFocusTrap" :loop="activeFocusTrap">
25
25
  <slot v-if="$slots.container" name="container" :close="close"></slot>
26
26
  <template v-else>
27
27
  <div :class="style.content">
@@ -136,6 +136,8 @@ export default defineComponent({
136
136
  const zIndex = ref(props.zIndex ?? nextZIndex());
137
137
  provide(ZINDEX, zIndex);
138
138
  const hasOpened = ref(false);
139
+ const focusTrapOverride = ref<boolean | null>(null);
140
+ const activeFocusTrap = computed(() => focusTrapOverride.value ?? props.focusTrap);
139
141
 
140
142
  const isDragging = ref<boolean>(false);
141
143
 
@@ -246,7 +248,7 @@ export default defineComponent({
246
248
  }
247
249
 
248
250
  function handleFocusOutside(event: Event) {
249
- if (!props.focusTrap) {
251
+ if (!activeFocusTrap.value) {
250
252
  return;
251
253
  }
252
254
 
@@ -351,8 +353,13 @@ export default defineComponent({
351
353
  { immediate: true }
352
354
  );
353
355
 
356
+ function setFocusTrap(value: boolean) {
357
+ focusTrapOverride.value = value;
358
+ }
359
+
354
360
  expose({
355
361
  close,
362
+ setFocusTrap,
356
363
  });
357
364
 
358
365
  return {
@@ -377,7 +384,8 @@ export default defineComponent({
377
384
  handleOpenChange,
378
385
  handleOpenAutoFocus,
379
386
  handleFocusOutside,
380
- isOpen: computed(() => props.open)
387
+ isOpen: computed(() => props.open),
388
+ activeFocusTrap,
381
389
  };
382
390
  },
383
391
  });
@@ -39,6 +39,10 @@ export default defineComponent({
39
39
  };
40
40
  }
41
41
 
42
+ function setFocusTrap(key: string, enabled: boolean) {
43
+ dialogRefs.value[key]?.setFocusTrap(enabled);
44
+ }
45
+
42
46
  function create(key: string, options: DialogOptions = {}): DialogReactive {
43
47
  if (dialogMap[key]) {
44
48
  // Merge new options into existing reactive options
@@ -72,6 +76,7 @@ export default defineComponent({
72
76
  handleClose(key);
73
77
  }
74
78
  },
79
+ setFocusTrap: (enabled: boolean) => setFocusTrap(key, enabled),
75
80
  };
76
81
 
77
82
  dialogMap[key] = dialog;
@@ -122,7 +127,8 @@ export default defineComponent({
122
127
  remove,
123
128
  hasOpenDialog: () => hasOpenDialog.value,
124
129
  openDialogCount: () => openDialogCount.value,
125
- openDialogKeys: () => openDialogKeys.value
130
+ openDialogKeys: () => openDialogKeys.value,
131
+ setFocusTrap,
126
132
  };
127
133
 
128
134
  provide('m-dialog', api);
@@ -19,6 +19,7 @@ export interface DialogReactive {
19
19
  options: DialogOptions;
20
20
  open: () => void;
21
21
  close: () => void;
22
+ setFocusTrap: (enabled: boolean) => void;
22
23
  }
23
24
 
24
25
  export interface DialogApiInjection {
@@ -27,4 +28,5 @@ export interface DialogApiInjection {
27
28
  hasOpenDialog: () => boolean;
28
29
  openDialogCount: () => number;
29
30
  openDialogKeys: () => string[];
31
+ setFocusTrap: (key: string, enabled: boolean) => void;
30
32
  }