@teammodlr/ui-kit 2.3.3 → 2.3.5

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/lib/index.es.js CHANGED
@@ -10696,7 +10696,7 @@ const S0 = /* @__PURE__ */ R({
10696
10696
  G(
10697
10697
  () => s.value,
10698
10698
  (h) => {
10699
- h && f();
10699
+ h && (f(), l.value = t());
10700
10700
  }
10701
10701
  );
10702
10702
  function v() {
@@ -11119,13 +11119,13 @@ const zl = /* @__PURE__ */ K(Y0, [["render", J0]]), Q0 = {
11119
11119
  MConfirm: zl
11120
11120
  },
11121
11121
  setup(e, { slots: t }) {
11122
- const n = w([]), o = {}, r = Aa(null, "m-confirm");
11122
+ const n = w([]), o = w({}), r = Aa(null, "m-confirm");
11123
11123
  function a(u) {
11124
11124
  const i = r, d = {
11125
11125
  ...u,
11126
11126
  key: i,
11127
11127
  destroy: () => {
11128
- o[i].hide();
11128
+ o.value[i].hide();
11129
11129
  }
11130
11130
  };
11131
11131
  return n.value.push(d), d;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teammodlr/ui-kit",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.es.js",
@@ -1,82 +1,82 @@
1
- <template>
2
- <slot />
3
- <template v-if="dialogList.length > 0">
4
- <Teleport :to="teleportTo ?? 'body'">
5
- <MConfirm
6
- v-for="dialog in dialogList"
7
- :key="dialog.key"
8
- :internalKey="dialog.key"
9
- :title="dialog.title"
10
- :content="dialog.content"
11
- :okText="dialog.okText"
12
- :cancelText="dialog.cancelText"
13
- :on-ok="dialog.onOk"
14
- :on-cancel="dialog.onCancel"
15
- :ok-variant="dialog.okVariant"
16
- ref="dialogRefs" />
17
- </Teleport>
18
- </template>
19
- </template>
20
-
21
- <script lang="ts">
22
- import { defineComponent, provide, ref } from 'vue';
23
- import { useId } from '../../composables/useCachedUid';
24
- import { providerProps } from './providerProps';
25
- import type { Confirm, ConfirmApiInjection, ConfirmOptions } from './types';
26
- import MConfirm from './Confirm.vue';
27
-
28
- interface PrivateConfirm extends Confirm {
29
- key: string;
30
- }
31
-
32
- interface PrivateConfirmRef extends Confirm {
33
- key: string;
34
- hide: () => void;
35
- }
36
-
37
- export default defineComponent({
38
- name: 'ConfirmProvider',
39
- props: providerProps,
40
- components: {
41
- MConfirm
42
- },
43
- setup(props, { slots }) {
44
- const dialogListRef = ref<PrivateConfirm[]>([]);
45
- const dialogRefs: Record<string, PrivateConfirmRef> = {};
46
- const id = useId(null, 'm-confirm');
47
- function create(options: ConfirmOptions): Confirm {
48
- const key = id;
49
- const dialog: PrivateConfirm = {
50
- ...options,
51
- key,
52
- destroy: () => {
53
- dialogRefs[key].hide();
54
- }
55
- };
56
-
57
- dialogListRef.value.push(dialog);
58
- return dialog;
59
- }
60
-
61
- function destroyAll(): void {
62
- // @ts-ignore
63
- Object.values(dialogRefs.value).forEach(dialog => {
64
- dialog.hide();
65
- });
66
- }
67
-
68
- const api: ConfirmApiInjection = {
69
- create,
70
- destroyAll
71
- } as const;
72
-
73
- provide('m-confirm', api);
74
-
75
- return {
76
- ...api,
77
- dialogRefs,
78
- dialogList: dialogListRef
79
- };
80
- }
81
- });
82
- </script>
1
+ <template>
2
+ <slot />
3
+ <template v-if="dialogList.length > 0">
4
+ <Teleport :to="teleportTo ?? 'body'">
5
+ <MConfirm
6
+ v-for="dialog in dialogList"
7
+ :key="dialog.key"
8
+ :internalKey="dialog.key"
9
+ :title="dialog.title"
10
+ :content="dialog.content"
11
+ :okText="dialog.okText"
12
+ :cancelText="dialog.cancelText"
13
+ :on-ok="dialog.onOk"
14
+ :on-cancel="dialog.onCancel"
15
+ :ok-variant="dialog.okVariant"
16
+ ref="dialogRefs" />
17
+ </Teleport>
18
+ </template>
19
+ </template>
20
+
21
+ <script lang="ts">
22
+ import { defineComponent, provide, ref, type Ref } from 'vue';
23
+ import { useId } from '../../composables/useCachedUid';
24
+ import { providerProps } from './providerProps';
25
+ import type { Confirm, ConfirmApiInjection, ConfirmOptions } from './types';
26
+ import MConfirm from './Confirm.vue';
27
+
28
+ interface PrivateConfirm extends Confirm {
29
+ key: string;
30
+ }
31
+
32
+ interface PrivateConfirmRef extends Confirm {
33
+ key: string;
34
+ hide: () => void;
35
+ }
36
+
37
+ export default defineComponent({
38
+ name: 'ConfirmProvider',
39
+ props: providerProps,
40
+ components: {
41
+ MConfirm
42
+ },
43
+ setup(props, { slots }) {
44
+ const dialogListRef = ref<PrivateConfirm[]>([]);
45
+ const dialogRefs: Ref<Record<string, PrivateConfirmRef>> = ref({});
46
+ const id = useId(null, 'm-confirm');
47
+ function create(options: ConfirmOptions): Confirm {
48
+ const key = id;
49
+ const dialog: PrivateConfirm = {
50
+ ...options,
51
+ key,
52
+ destroy: () => {
53
+ dialogRefs.value[key].hide();
54
+ }
55
+ };
56
+
57
+ dialogListRef.value.push(dialog);
58
+ return dialog;
59
+ }
60
+
61
+ function destroyAll(): void {
62
+ // @ts-ignore
63
+ Object.values(dialogRefs.value).forEach(dialog => {
64
+ dialog.hide();
65
+ });
66
+ }
67
+
68
+ const api: ConfirmApiInjection = {
69
+ create,
70
+ destroyAll
71
+ } as const;
72
+
73
+ provide('m-confirm', api);
74
+
75
+ return {
76
+ ...api,
77
+ dialogRefs,
78
+ dialogList: dialogListRef
79
+ };
80
+ }
81
+ });
82
+ </script>
@@ -1,214 +1,216 @@
1
- <template>
2
- <Primitive
3
- as-child
4
- v-bind="$attrs"
5
- @mouseenter="show"
6
- @mouseleave="hide"
7
- ref="wrapper">
8
- <TooltipTrigger ref="reference" >
9
- <slot/>
10
- </TooltipTrigger>
11
-
12
- <Teleport :to="transferTo">
13
- <Transition
14
- :enter-active-class="fade.enterActive"
15
- :leave-active-class="fade.leaveActive"
16
- :enter-from-class="fade.enterFrom"
17
- :leave-to-class="fade.leaveTo">
18
- <div
19
- role="tooltip"
20
- :class="computedClasses"
21
- ref="popper"
22
- v-if="isOpen"
23
- :style="{ zIndex: zIndex }">
24
- <slot :html="text" name="content">
25
- <span v-html="text" />
26
- </slot>
27
- </div>
28
- </Transition>
29
- </Teleport>
30
- </Primitive>
31
- </template>
32
-
33
- <script lang="ts">
34
- import {
35
- defineComponent,
36
- ref,
37
- toRef,
38
- type PropType,
39
- computed,
40
- watch,
41
- onUnmounted, type Ref
42
- } from 'vue';
43
- import {
44
- type Placement,
45
- placementWhileList,
46
- usePopper
47
- } from '../../composables/usePopper';
48
-
49
- import { fade } from '../../styles/transitions.css';
50
- import * as style from './style';
51
- import { useZIndex } from '../../composables/useZIndex';
52
- import {Primitive} from "../primative/primitive";
53
- import TooltipTrigger from "@/components/tooltip/TooltipTrigger.vue";
54
- import {createContext} from "../../utils/injection";
55
-
56
- interface TooltipContext {
57
- reference: Ref<HTMLElement | undefined>
58
- onReferenceChange: (element: HTMLElement | undefined) => void
59
- }
60
-
61
- export const [injectionTooltipContext, providerTooltipContext] = createContext<TooltipContext>('Tooltip');
62
-
63
- export default defineComponent({
64
- name: 'MTooltip',
65
- components: {TooltipTrigger, Primitive},
66
- props: {
67
- text: {
68
- type: String,
69
- default: ''
70
- },
71
- placement: {
72
- type: String as PropType<Placement>,
73
- default: 'top',
74
- validator: (value: Placement) => placementWhileList.includes(value)
75
- },
76
- transitionName: {
77
- type: String,
78
- default: 'scale'
79
- },
80
- reverse: {
81
- type: Boolean,
82
- default: false
83
- },
84
- transfer: {
85
- type: Boolean,
86
- default: false
87
- },
88
- zIndex: {
89
- type: Number
90
- },
91
- delay: {
92
- type: Number,
93
- default: 500
94
- }
95
- },
96
- setup(props) {
97
- const { nextZIndex } = useZIndex();
98
- const placement = toRef(props, 'placement');
99
- // @ts-ignore
100
- const transfer = toRef(props, 'transfer');
101
- const wrapper = ref<HTMLElement | null>(null);
102
- const reference = ref<HTMLElement>();
103
- const isOpen = ref(false);
104
- const zIndex = ref(props.zIndex ?? nextZIndex());
105
- const timeout = ref<ReturnType<typeof setTimeout> | null>(null);
106
- const offset = computed(() => {
107
- switch (placement.value) {
108
- case 'top':
109
- return [0, 8];
110
- case 'bottom':
111
- return [0, -8];
112
- case 'left':
113
- return [8, 0];
114
- case 'right':
115
- return [-8, 0];
116
- default:
117
- return [0, 0];
118
- }
119
- });
120
-
121
- providerTooltipContext({
122
- reference,
123
- onReferenceChange: element => reference.value = element
124
- });
125
-
126
- const { popper, transferTo, updatePopper } = usePopper({
127
- placement,
128
- transfer,
129
- reference,
130
- wrapper,
131
- // @ts-ignore
132
- offset: offset.value
133
- });
134
-
135
- const computedClasses = computed(() => {
136
- return [
137
- style.tooltip,
138
- {
139
- [style.reverse]: props.reverse
140
- }
141
- ];
142
- });
143
-
144
- watch(
145
- () => isOpen.value,
146
- (value: boolean) => {
147
- if (value) {
148
- updatePopper();
149
- }
150
- }
151
- );
152
-
153
- const toggle = () => {
154
- if (timeout.value) {
155
- clearTimeout(timeout.value);
156
- }
157
-
158
- if (props.delay && !isOpen.value) {
159
- timeout.value = setTimeout(() => {
160
- isOpen.value = !isOpen.value;
161
- }, props.delay);
162
- } else {
163
- isOpen.value = !isOpen.value;
164
- }
165
- };
166
-
167
- function show() {
168
- if (timeout.value) {
169
- clearTimeout(timeout.value);
170
- }
171
-
172
- if (props.delay) {
173
- timeout.value = setTimeout(() => {
174
- isOpen.value = true;
175
- }, props.delay);
176
- } else {
177
- isOpen.value = true;
178
- }
179
- }
180
-
181
- function hide() {
182
- if (timeout.value) {
183
- clearTimeout(timeout.value);
184
- }
185
-
186
- isOpen.value = false;
187
- }
188
-
189
- onUnmounted(() => {
190
- isOpen.value = false;
191
- if (timeout.value) {
192
- clearTimeout(timeout.value);
193
- }
194
- timeout.value = null;
195
- });
196
-
197
- return {
198
- reference,
199
- offset,
200
- popper,
201
- transferTo,
202
- isOpen,
203
- show,
204
- hide,
205
- computedClasses,
206
- zIndex,
207
- style,
208
- fade
209
- };
210
- }
211
- });
212
- </script>
213
-
214
- <style scoped></style>
1
+ <template>
2
+ <Primitive
3
+ as-child
4
+ v-bind="$attrs"
5
+ @mouseenter="show"
6
+ @mouseleave="hide"
7
+ ref="wrapper">
8
+ <TooltipTrigger ref="reference" >
9
+ <slot/>
10
+ </TooltipTrigger>
11
+
12
+ <Teleport :to="transferTo">
13
+ <Transition
14
+ :enter-active-class="fade.enterActive"
15
+ :leave-active-class="fade.leaveActive"
16
+ :enter-from-class="fade.enterFrom"
17
+ :leave-to-class="fade.leaveTo">
18
+ <div
19
+ role="tooltip"
20
+ :class="computedClasses"
21
+ ref="popper"
22
+ v-if="isOpen"
23
+ :style="{ zIndex: zIndex }">
24
+ <slot :html="text" name="content">
25
+ <span v-html="text" />
26
+ </slot>
27
+ </div>
28
+ </Transition>
29
+ </Teleport>
30
+ </Primitive>
31
+ </template>
32
+
33
+ <script lang="ts">
34
+ import {
35
+ defineComponent,
36
+ ref,
37
+ toRef,
38
+ type PropType,
39
+ computed,
40
+ watch,
41
+ onUnmounted, type Ref
42
+ } from 'vue';
43
+ import {
44
+ type Placement,
45
+ placementWhileList,
46
+ usePopper
47
+ } from '../../composables/usePopper';
48
+
49
+ import { fade } from '../../styles/transitions.css';
50
+ import * as style from './style';
51
+ import { useZIndex } from '../../composables/useZIndex';
52
+ import {Primitive} from "../primative/primitive";
53
+ import TooltipTrigger from "@/components/tooltip/TooltipTrigger.vue";
54
+ import {createContext} from "../../utils/injection";
55
+
56
+ interface TooltipContext {
57
+ reference: Ref<HTMLElement | undefined>
58
+ onReferenceChange: (element: HTMLElement | undefined) => void
59
+ }
60
+
61
+ export const [injectionTooltipContext, providerTooltipContext] = createContext<TooltipContext>('Tooltip');
62
+
63
+ export default defineComponent({
64
+ name: 'MTooltip',
65
+ components: {TooltipTrigger, Primitive},
66
+ props: {
67
+ text: {
68
+ type: String,
69
+ default: ''
70
+ },
71
+ placement: {
72
+ type: String as PropType<Placement>,
73
+ default: 'top',
74
+ validator: (value: Placement) => placementWhileList.includes(value)
75
+ },
76
+ transitionName: {
77
+ type: String,
78
+ default: 'scale'
79
+ },
80
+ reverse: {
81
+ type: Boolean,
82
+ default: false
83
+ },
84
+ transfer: {
85
+ type: Boolean,
86
+ default: false
87
+ },
88
+ zIndex: {
89
+ type: Number
90
+ },
91
+ delay: {
92
+ type: Number,
93
+ default: 500
94
+ }
95
+ },
96
+ setup(props) {
97
+ const { nextZIndex } = useZIndex();
98
+ const placement = toRef(props, 'placement');
99
+ // @ts-ignore
100
+ const transfer = toRef(props, 'transfer');
101
+ const wrapper = ref<HTMLElement | null>(null);
102
+ const reference = ref<HTMLElement>();
103
+ const isOpen = ref(false);
104
+ const zIndex = ref(props.zIndex ?? nextZIndex());
105
+ const timeout = ref<ReturnType<typeof setTimeout> | null>(null);
106
+ const offset = computed(() => {
107
+ switch (placement.value) {
108
+ case 'top':
109
+ return [0, 8];
110
+ case 'bottom':
111
+ return [0, -8];
112
+ case 'left':
113
+ return [8, 0];
114
+ case 'right':
115
+ return [-8, 0];
116
+ default:
117
+ return [0, 0];
118
+ }
119
+ });
120
+
121
+ providerTooltipContext({
122
+ reference,
123
+ onReferenceChange: element => reference.value = element
124
+ });
125
+
126
+ const { popper, transferTo, updatePopper } = usePopper({
127
+ placement,
128
+ transfer,
129
+ reference,
130
+ wrapper,
131
+ // @ts-ignore
132
+ offset: offset.value
133
+ });
134
+
135
+ const computedClasses = computed(() => {
136
+ return [
137
+ style.tooltip,
138
+ {
139
+ [style.reverse]: props.reverse
140
+ }
141
+ ];
142
+ });
143
+
144
+ watch(
145
+ () => isOpen.value,
146
+ (value: boolean) => {
147
+ if (value) {
148
+ updatePopper();
149
+
150
+ zIndex.value = nextZIndex();
151
+ }
152
+ }
153
+ );
154
+
155
+ const toggle = () => {
156
+ if (timeout.value) {
157
+ clearTimeout(timeout.value);
158
+ }
159
+
160
+ if (props.delay && !isOpen.value) {
161
+ timeout.value = setTimeout(() => {
162
+ isOpen.value = !isOpen.value;
163
+ }, props.delay);
164
+ } else {
165
+ isOpen.value = !isOpen.value;
166
+ }
167
+ };
168
+
169
+ function show() {
170
+ if (timeout.value) {
171
+ clearTimeout(timeout.value);
172
+ }
173
+
174
+ if (props.delay) {
175
+ timeout.value = setTimeout(() => {
176
+ isOpen.value = true;
177
+ }, props.delay);
178
+ } else {
179
+ isOpen.value = true;
180
+ }
181
+ }
182
+
183
+ function hide() {
184
+ if (timeout.value) {
185
+ clearTimeout(timeout.value);
186
+ }
187
+
188
+ isOpen.value = false;
189
+ }
190
+
191
+ onUnmounted(() => {
192
+ isOpen.value = false;
193
+ if (timeout.value) {
194
+ clearTimeout(timeout.value);
195
+ }
196
+ timeout.value = null;
197
+ });
198
+
199
+ return {
200
+ reference,
201
+ offset,
202
+ popper,
203
+ transferTo,
204
+ isOpen,
205
+ show,
206
+ hide,
207
+ computedClasses,
208
+ zIndex,
209
+ style,
210
+ fade
211
+ };
212
+ }
213
+ });
214
+ </script>
215
+
216
+ <style scoped></style>