@teammodlr/ui-kit 2.3.17 → 2.3.18

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": "2.3.17",
3
+ "version": "2.3.18",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.es.js",
@@ -11,10 +11,10 @@
11
11
 
12
12
  <template #footer>
13
13
  <div style="display: flex; flex-grow: 1; justify-content: end">
14
- <MButton :variant="okVariant" @click="handleOk">
14
+ <MButton ref="actionButton" :variant="okVariant" @click="handleOk">
15
15
  {{ okText ?? 'Okay' }}
16
16
  </MButton>
17
- <MButton style="margin-left: 8px" @click="handleCancel">
17
+ <MButton ref="cancelButton" style="margin-left: 8px" @click="handleCancel">
18
18
  {{ cancelText ?? 'Cancel' }}
19
19
  </MButton>
20
20
  </div>
@@ -24,8 +24,7 @@
24
24
  </template>
25
25
 
26
26
  <script lang="ts">
27
- import { defineComponent, onMounted, ref } from 'vue';
28
- import { useZIndex } from '../../composables/useZIndex';
27
+ import { defineComponent, onMounted, ref, nextTick } from 'vue';
29
28
  import { confirmProps } from './props';
30
29
  import MModal from '../modal/Modal.vue';
31
30
  import MButton from '../button/Button.vue';
@@ -33,10 +32,10 @@ import MButton from '../button/Button.vue';
33
32
  export default defineComponent({
34
33
  name: 'Confirm',
35
34
  props: confirmProps,
36
- setup(props, { slots }) {
35
+ setup(props) {
37
36
  const modal = ref();
38
-
39
- const { nextZIndex } = useZIndex();
37
+ const actionButton = ref();
38
+ const cancelButton = ref();
40
39
 
41
40
  async function handleCancel(event: MouseEvent) {
42
41
  modal.value?.close();
@@ -48,14 +47,24 @@ export default defineComponent({
48
47
  async function handleOk(event: MouseEvent) {
49
48
  modal.value?.close();
50
49
  if (props.onOk) {
51
- props.onOk(event);
50
+ await props.onOk(event);
52
51
  }
53
52
  }
54
- onMounted(() => {
53
+ onMounted(async () => {
55
54
  modal.value?.open(null);
55
+ await nextTick();
56
+ setTimeout(() => {
57
+ if (props.focusAction) {
58
+ actionButton.value.$el.focus();
59
+ return;
60
+ }
61
+ cancelButton.value.$el.focus();
62
+ }, 100);
56
63
  });
57
64
  return {
58
65
  modal,
66
+ actionButton,
67
+ cancelButton,
59
68
  handleOk,
60
69
  handleCancel
61
70
  };
@@ -18,6 +18,10 @@ export const confirmProps = {
18
18
  okVariant: {
19
19
  type: String as PropType<Variant>,
20
20
  default: 'primary'
21
+ },
22
+ focusAction: {
23
+ type: Boolean,
24
+ default: false
21
25
  }
22
26
  } as const;
23
27