@v1nt1248/3nclient-lib 0.3.51 → 0.4.1

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.
Files changed (68) hide show
  1. package/README.md +4 -0
  2. package/dist/chunks/{plugins-keys-DdadrIAg.js → plugins-keys-CjKqZeyH.js} +2 -2
  3. package/dist/chunks/ui3n-tooltip-BbbM2459.js +409 -0
  4. package/dist/src/components/ui3n-chip/ui3n-chip.d.ts +0 -5
  5. package/dist/src/components/ui3n-icon/ui3n-icon.d.ts +0 -1
  6. package/dist/src/components/ui3n-progress/ui3n-progress-circular.d.ts +0 -2
  7. package/dist/src/components/ui3n-progress/ui3n-progress-linear.d.ts +0 -2
  8. package/dist/src/components/ui3n-scrollbar-horizontal/ui3n-scrollbar-horizontal.d.ts +0 -7
  9. package/dist/src/components/ui3n-scrollbar-vertical/ui3n-scrollbar-vertical.d.ts +0 -7
  10. package/dist/src/components/ui3n-slider/ui3n-slider.d.ts +0 -5
  11. package/dist/src/components/ui3n-tabs/ui3n-tabs.d.ts +0 -4
  12. package/dist/src/components/ui3n-tooltip/types.d.ts +8 -2
  13. package/dist/src/components/ui3n-tooltip/ui3n-tooltip-container.d.ts +16 -0
  14. package/dist/src/components/ui3n-tooltip/ui3n-tooltip.d.ts +1 -5
  15. package/dist/src/constants/plugins-keys.d.ts +2 -0
  16. package/dist/src/index.d.ts +3 -0
  17. package/dist/src/plugins/index.d.ts +4 -1
  18. package/dist/src/plugins/tooltips/store-tooltips.d.ts +4 -0
  19. package/dist/src/plugins/tooltips/tooltips.d.ts +8 -0
  20. package/dist/src/plugins/tooltips/types.d.ts +34 -0
  21. package/dist/src/ui3n-plugins.d.ts +5 -3
  22. package/dist/style.css +1 -1
  23. package/dist/ui3n-components.js +1011 -1183
  24. package/dist/ui3n-plugins.js +169 -50
  25. package/dist/ui3n-utils.js +4 -4
  26. package/package.json +11 -4
  27. package/src/components/ui3n-autocomplete/ui3n-autocomplete.vue +28 -25
  28. package/src/components/ui3n-badge/ui3n-badge-simple.vue +18 -17
  29. package/src/components/ui3n-badge/ui3n-badge.vue +3 -2
  30. package/src/components/ui3n-breadcrumbs/ui3n-breadcrumb.vue +11 -10
  31. package/src/components/ui3n-breadcrumbs/ui3n-breadcrumbs.vue +4 -1
  32. package/src/components/ui3n-button/ui3n-button.vue +244 -158
  33. package/src/components/ui3n-checkbox/ui3n-checkbox.vue +22 -21
  34. package/src/components/ui3n-chip/ui3n-chip.vue +56 -40
  35. package/src/components/ui3n-dialog/ui3n-dialog-provider.vue +1 -0
  36. package/src/components/ui3n-dialog/ui3n-dialog.vue +19 -18
  37. package/src/components/ui3n-drop-files/ui3n-drop-files.vue +8 -7
  38. package/src/components/ui3n-editable/ui3n-content-editable.vue +11 -10
  39. package/src/components/ui3n-editable/ui3n-editable.vue +26 -25
  40. package/src/components/ui3n-emoji/ui3n-emoji.vue +7 -6
  41. package/src/components/ui3n-icon/ui3n-icon.vue +26 -16
  42. package/src/components/ui3n-input/ui3n-input.vue +36 -32
  43. package/src/components/ui3n-input-file/ui3n-input-file.vue +8 -5
  44. package/src/components/ui3n-list/ui3n-list.vue +8 -7
  45. package/src/components/ui3n-menu/ui3n-menu.vue +6 -5
  46. package/src/components/ui3n-mobile-menu/ui3n-mobile-menu.vue +4 -3
  47. package/src/components/ui3n-mobile-menu-item/ui3n-mobile-menu-item.vue +7 -6
  48. package/src/components/ui3n-notification/ui3n-notification-container.vue +1 -0
  49. package/src/components/ui3n-notification/ui3n-notification.vue +28 -26
  50. package/src/components/ui3n-progress/ui3n-progress-circular.vue +32 -19
  51. package/src/components/ui3n-progress/ui3n-progress-linear.vue +31 -18
  52. package/src/components/ui3n-radio-group/ui3n-radio-group.vue +4 -1
  53. package/src/components/ui3n-radio-group/ui3n-radio.vue +6 -5
  54. package/src/components/ui3n-scrollbar/ui3n-scrollbar.vue +94 -83
  55. package/src/components/ui3n-scrollbar-horizontal/ui3n-scrollbar-horizontal.vue +51 -39
  56. package/src/components/ui3n-scrollbar-vertical/ui3n-scrollbar-vertical.vue +51 -39
  57. package/src/components/ui3n-selector/ui3n-selector.vue +33 -28
  58. package/src/components/ui3n-slider/ui3n-slider.vue +53 -34
  59. package/src/components/ui3n-step-line-bar/ui3n-step-line-bar.vue +10 -6
  60. package/src/components/ui3n-switch/ui3n-switch.vue +23 -22
  61. package/src/components/ui3n-table/ui3n-table.vue +50 -48
  62. package/src/components/ui3n-tabs/ui3n-tabs.vue +38 -20
  63. package/src/components/ui3n-text/ui3n-text.vue +15 -14
  64. package/src/components/ui3n-tooltip/types.ts +8 -2
  65. package/src/components/ui3n-tooltip/ui3n-tooltip-container.vue +79 -0
  66. package/src/components/ui3n-tooltip/ui3n-tooltip.vue +140 -79
  67. package/dist/chunks/ui3n-notification-o0tuhTpO.js +0 -272
  68. package/src/components/ui3n-tooltip/ui3n-tooltip-old.vue +0 -198
@@ -1,17 +1,16 @@
1
1
  <script lang="ts" setup>
2
- import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
2
+ import { computed, onBeforeUnmount, onMounted, ref, useSlots, watch } from 'vue';
3
3
  import { arrow, autoUpdate, offset, useFloating } from '@floating-ui/vue';
4
+ import { toCssLength } from '../../utils/ui/to-css-length';
5
+ import { hasSlotContent } from '../../utils/ui/has-slot-content';
4
6
  import type { Nullable } from '../../types';
5
7
  import type { Ui3nTooltipProps, Ui3nTooltipEmits, Ui3nTooltipSlots } from './types';
6
8
 
7
- const baseOffset = 5;
9
+ const arrowSize = 8;
10
+ const arrowOffset = Math.round((arrowSize / 2) * Math.SQRT2);
8
11
 
9
12
  const props = withDefaults(defineProps<Ui3nTooltipProps>(), {
10
- maxContentWidth: 400,
11
- color: 'var(--color-bg-block-tritery-default)',
12
- textColor: 'var(--color-text-block-darkery-default)',
13
13
  placement: 'top',
14
- positionStrategy: 'absolute',
15
14
  offsetX: 0,
16
15
  offsetY: 0,
17
16
  trigger: 'hover',
@@ -19,6 +18,7 @@
19
18
  });
20
19
  const emits = defineEmits<Ui3nTooltipEmits>();
21
20
  defineSlots<Ui3nTooltipSlots>();
21
+ const slots = useSlots();
22
22
 
23
23
  const showTooltip = ref(false);
24
24
  const referenceContainer = ref<Nullable<HTMLElement>>(null);
@@ -26,6 +26,38 @@
26
26
  const floatingArrowEl = ref<Nullable<HTMLElement>>(null);
27
27
 
28
28
  const isClient = ref(false);
29
+ let boundEl: HTMLElement | null = null;
30
+
31
+ const showWrapper = computed(() => !props.triggerElement || hasSlotContent(slots.default));
32
+
33
+ const positionStrategy = computed(() => {
34
+ if (props.positionStrategy) {
35
+ return props.positionStrategy;
36
+ }
37
+
38
+ return props.triggerElement ? 'fixed' : 'absolute';
39
+ });
40
+
41
+ const shouldTeleport = computed(() => !!props.triggerElement || positionStrategy.value === 'fixed');
42
+
43
+ const usedReference = computed(() => props.triggerElement || referenceContainer.value);
44
+
45
+ const nativeReferenceEl = computed<HTMLElement | null>(() => {
46
+ const trigger = usedReference.value;
47
+ if (!trigger) {
48
+ return null;
49
+ }
50
+
51
+ if (trigger instanceof HTMLElement) {
52
+ return trigger;
53
+ }
54
+
55
+ if ('contextElement' in trigger && trigger.contextElement instanceof HTMLElement) {
56
+ return trigger.contextElement;
57
+ }
58
+
59
+ return null;
60
+ });
29
61
 
30
62
  const mainPlacement = computed(() => {
31
63
  const [part1] = props.placement.split('-');
@@ -36,19 +68,19 @@
36
68
  const options = { mainAxis: 0, crossAxis: 0 };
37
69
  switch (mainPlacement.value) {
38
70
  case 'top':
39
- options.mainAxis = -1 * Number(props.offsetY) + baseOffset;
71
+ options.mainAxis = -1 * Number(props.offsetY) + arrowOffset;
40
72
  options.crossAxis = Number(props.offsetX);
41
73
  break;
42
74
  case 'bottom':
43
- options.mainAxis = Number(props.offsetY) + baseOffset;
75
+ options.mainAxis = Number(props.offsetY) + arrowOffset;
44
76
  options.crossAxis = Number(props.offsetX);
45
77
  break;
46
78
  case 'left':
47
- options.mainAxis = -1 * Number(props.offsetX) + baseOffset;
79
+ options.mainAxis = -1 * Number(props.offsetX) + arrowOffset;
48
80
  options.crossAxis = Number(props.offsetY);
49
81
  break;
50
82
  case 'right':
51
- options.mainAxis = Number(props.offsetX) + baseOffset;
83
+ options.mainAxis = Number(props.offsetX) + arrowOffset;
52
84
  options.crossAxis = Number(props.offsetY);
53
85
  break;
54
86
  }
@@ -60,28 +92,40 @@
60
92
  arrow({ element: floatingArrowEl, padding: 8 }),
61
93
  ]);
62
94
 
63
- const { floatingStyles, isPositioned, middlewareData } = useFloating(referenceContainer, floatingEl, {
95
+ const { floatingStyles, isPositioned, middlewareData, update } = useFloating(usedReference, floatingEl, {
64
96
  open: showTooltip,
65
- placement: props.placement,
66
- strategy: props.positionStrategy,
97
+ placement: () => props.placement,
98
+ strategy: positionStrategy,
67
99
  middleware: middlewareComputed,
68
- whileElementsMounted: props.positionStrategy === 'fixed' ? autoUpdate : undefined,
100
+ whileElementsMounted: (reference, floating, onUpdate) => {
101
+ if (positionStrategy.value === 'fixed' || props.triggerElement) {
102
+ return autoUpdate(reference, floating, onUpdate);
103
+ }
104
+
105
+ onUpdate();
106
+ return () => undefined;
107
+ },
69
108
  });
70
109
 
71
110
  const tooltipStylesComputed = computed(() => {
72
- const maxWidth =
73
- typeof props.maxContentWidth === 'number' || !isNaN(Number(props.maxContentWidth))
74
- ? `${props.maxContentWidth}px`
75
- : String(props.maxContentWidth);
76
-
77
- return {
111
+ const styles: Record<string, string> = {
78
112
  ...floatingStyles.value,
79
- '--ui3n-tooltip-bg-color': props.color,
80
- '--ui3n-tooltip-text-color': props.textColor,
81
- '--ui3n-tooltip-max-width': maxWidth,
82
- '--ui3n-tooltip-arrow-size': `${baseOffset}px`,
83
- '--ui3n-tooltip-base-offset': `${-baseOffset}px`,
113
+ '--ui3n-tooltip-arrow-size': `${arrowSize}px`,
84
114
  };
115
+
116
+ if (props.color) {
117
+ styles['--ui3n-tooltip-bg-color'] = props.color;
118
+ }
119
+
120
+ if (props.textColor) {
121
+ styles['--ui3n-tooltip-text-color'] = props.textColor;
122
+ }
123
+
124
+ if (props.maxContentWidth !== undefined) {
125
+ styles['--ui3n-tooltip-max-width'] = toCssLength(props.maxContentWidth);
126
+ }
127
+
128
+ return styles;
85
129
  });
86
130
 
87
131
  function onMouseenter() {
@@ -117,26 +161,29 @@
117
161
  }
118
162
 
119
163
  function removeEventListeners() {
120
- if (!referenceContainer.value) {
164
+ if (!boundEl) {
121
165
  return;
122
166
  }
123
167
 
124
- referenceContainer.value.removeEventListener('mouseenter', onMouseenter);
125
- referenceContainer.value.removeEventListener('mouseleave', onMouseleave);
126
- referenceContainer.value.removeEventListener('click', onClick);
168
+ boundEl.removeEventListener('mouseenter', onMouseenter);
169
+ boundEl.removeEventListener('mouseleave', onMouseleave);
170
+ boundEl.removeEventListener('click', onClick);
171
+ boundEl = null;
127
172
  }
128
173
 
129
174
  function setupEventListeners() {
130
175
  removeEventListeners();
131
- if (!referenceContainer.value || props.disabled) {
176
+ if (!nativeReferenceEl.value || props.disabled) {
132
177
  return;
133
178
  }
134
179
 
180
+ boundEl = nativeReferenceEl.value;
181
+
135
182
  if (props.trigger === 'hover') {
136
- referenceContainer.value.addEventListener('mouseenter', onMouseenter);
137
- referenceContainer.value.addEventListener('mouseleave', onMouseleave);
183
+ boundEl.addEventListener('mouseenter', onMouseenter);
184
+ boundEl.addEventListener('mouseleave', onMouseleave);
138
185
  } else if (props.trigger === 'click') {
139
- referenceContainer.value.addEventListener('click', onClick);
186
+ boundEl.addEventListener('click', onClick);
140
187
  }
141
188
  }
142
189
 
@@ -149,10 +196,19 @@
149
196
  removeEventListeners();
150
197
  });
151
198
 
152
- watch([() => props.trigger, () => props.disabled], () => {
153
- setupEventListeners();
199
+ watch([() => props.trigger, () => props.disabled, nativeReferenceEl], () => {
200
+ if (isClient.value) {
201
+ setupEventListeners();
202
+ }
154
203
  });
155
204
 
205
+ watch(
206
+ () => props.triggerElement,
207
+ () => {
208
+ update();
209
+ },
210
+ );
211
+
156
212
  watch(
157
213
  () => props.modelValue,
158
214
  val => props.trigger === 'manual' && (showTooltip.value = val),
@@ -166,32 +222,40 @@
166
222
 
167
223
  <template>
168
224
  <div
225
+ v-if="showWrapper"
169
226
  ref="referenceContainer"
227
+ data-ui3n="tooltip"
170
228
  :class="$style.container"
171
229
  >
172
230
  <slot />
173
231
  </div>
174
232
 
175
- <div
176
- v-if="showTooltip"
177
- ref="floatingEl"
178
- :class="$style.floating"
179
- :style="tooltipStylesComputed"
233
+ <Teleport
234
+ to="body"
235
+ :disabled="!isClient || !shouldTeleport"
180
236
  >
181
- <slot name="content">
182
- <div :class="$style.content">
183
- {{ content }}
237
+ <div
238
+ v-if="showTooltip"
239
+ ref="floatingEl"
240
+ data-ui3n="tooltip-content"
241
+ :class="[$style.floating, shouldTeleport && $style.floatingTeleported]"
242
+ :style="tooltipStylesComputed"
243
+ >
244
+ <slot name="content">
184
245
  <div
185
246
  ref="floatingArrowEl"
186
247
  :class="[$style.arrow, $style[`arrow-${mainPlacement}`]]"
187
248
  :style="{
188
- left: middlewareData.arrow?.x != null ? `${middlewareData.arrow?.x}px` : '',
189
- top: middlewareData.arrow?.y != null ? `${middlewareData.arrow?.y}px` : '',
249
+ left: middlewareData.arrow?.x != null ? `${middlewareData.arrow.x}px` : '',
250
+ top: middlewareData.arrow?.y != null ? `${middlewareData.arrow.y}px` : '',
190
251
  }"
191
252
  />
192
- </div>
193
- </slot>
194
- </div>
253
+ <div :class="$style.content">
254
+ {{ content }}
255
+ </div>
256
+ </slot>
257
+ </div>
258
+ </Teleport>
195
259
  </template>
196
260
 
197
261
  <style lang="scss" module>
@@ -202,59 +266,56 @@
202
266
  }
203
267
 
204
268
  .floating {
269
+ --_tooltip-bg-color: var(--ui3n-tooltip-bg-color, var(--color-bg-block-tritery-default));
270
+ --_tooltip-text-color: var(--ui3n-tooltip-text-color, var(--color-text-block-darkery-default));
271
+ --_tooltip-max-width: var(--ui3n-tooltip-max-width, 400px);
272
+
205
273
  width: max-content;
274
+ overflow: visible;
206
275
  z-index: 5;
207
276
  }
208
277
 
278
+ .floatingTeleported {
279
+ z-index: 2000;
280
+ }
281
+
209
282
  .arrow {
210
283
  position: absolute;
211
- width: 0;
212
- height: 0;
213
-
214
- &-top,
215
- &-bottom {
216
- border-style: solid;
217
- border-width: 0 var(--ui3n-tooltip-arrow-size) var(--ui3n-tooltip-arrow-size) var(--ui3n-tooltip-arrow-size);
218
- border-color: transparent transparent var(--ui3n-tooltip-bg-color) transparent;
219
- }
284
+ width: var(--ui3n-tooltip-arrow-size, 8px);
285
+ height: var(--ui3n-tooltip-arrow-size, 8px);
286
+ background-color: var(--_tooltip-bg-color);
287
+ border-radius: 2px;
288
+ transform: rotate(45deg);
289
+ z-index: 0;
220
290
 
221
291
  &-top {
222
- bottom: var(--ui3n-tooltip-base-offset);
223
- transform: rotate(180deg);
292
+ bottom: calc(var(--ui3n-tooltip-arrow-size, 8px) / -2);
224
293
  }
225
294
 
226
295
  &-bottom {
227
- top: var(--ui3n-tooltip-base-offset);
228
- transform: rotate(0deg);
229
- }
230
-
231
- &-left,
232
- &-right {
233
- border-style: solid;
234
- border-width: var(--ui3n-tooltip-arrow-size) 0 var(--ui3n-tooltip-arrow-size) var(--ui3n-tooltip-arrow-size);
235
- border-color: transparent transparent transparent var(--ui3n-tooltip-bg-color);
296
+ top: calc(var(--ui3n-tooltip-arrow-size, 8px) / -2);
236
297
  }
237
298
 
238
299
  &-left {
239
- right: var(--ui3n-tooltip-base-offset);
240
- transform: rotate(0deg);
300
+ right: calc(var(--ui3n-tooltip-arrow-size, 8px) / -2);
241
301
  }
242
302
 
243
303
  &-right {
244
- left: var(--ui3n-tooltip-base-offset);
245
- transform: rotate(180deg);
304
+ left: calc(var(--ui3n-tooltip-arrow-size, 8px) / -2);
246
305
  }
247
306
  }
248
307
 
249
308
  .content {
250
309
  position: relative;
251
- max-width: var(--ui3n-tooltip-max-width);
252
- padding: 6px var(--spacing-s);
253
- border-radius: 6px;
254
- font-size: var(--font-11);
255
- line-height: var(--font-12);
310
+ z-index: 1;
311
+ overflow: visible;
312
+ max-width: var(--_tooltip-max-width);
313
+ padding: var(--ui3n-tooltip-padding, 6px 8px);
314
+ border-radius: var(--ui3n-tooltip-border-radius, 6px);
315
+ font-size: var(--ui3n-tooltip-font-size, 11px);
316
+ line-height: var(--ui3n-tooltip-line-height, 12px);
256
317
  font-weight: 400;
257
- background-color: var(--ui3n-tooltip-bg-color);
258
- color: var(--ui3n-tooltip-text-color);
318
+ background-color: var(--_tooltip-bg-color);
319
+ color: var(--_tooltip-text-color);
259
320
  }
260
321
  </style>
@@ -1,272 +0,0 @@
1
- import { b as e } from "./plugins-keys-DdadrIAg.js";
2
- import { computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, mergeProps as c, normalizeClass as l, normalizeStyle as u, onBeforeUnmount as d, onMounted as f, openBlock as p, ref as m, renderSlot as h, toDisplayString as g, unref as _, useCssModule as v, watch as y, withDirectives as b, withKeys as x } from "vue";
3
- //#region src/directives/ui3n-ripple.ts
4
- var S = /* @__PURE__ */ new WeakMap();
5
- function C(e, t, n) {
6
- let r = document.createElement("div"), i = Math.max(e.clientWidth, e.clientHeight), a = i / 2;
7
- r.style.width = r.style.height = `${i}px`, r.style.left = `${Math.round(e.clientWidth / 2 - a)}px`, r.style.top = `${Math.round(e.clientHeight / 2 - a)}px`, r.classList.add("ui3n-ripple"), t && r.style.setProperty("--ui3n-ripple-bg-color", t), n && r.style.setProperty("--ui3n-ripple-duration", `${n}ms`);
8
- let o = e.getElementsByClassName("ui3n-ripple")[0];
9
- o && o.remove(), e.appendChild(r);
10
- }
11
- function w(e, t) {
12
- S.get(e)?.controller.abort();
13
- let { color: n, duration: r, eventsTriggers: i = [], disabled: a = !1 } = t.value || {};
14
- if (a) {
15
- S.delete(e);
16
- return;
17
- }
18
- let o = new AbortController(), s = { signal: o.signal };
19
- (!i.length || i.includes("click")) && e.addEventListener("click", () => C(e, n, r), s), i.length && i.includes("enter") && e.addEventListener("keydown", (t) => {
20
- t.key === "Enter" && C(e, n, r);
21
- }, s), S.set(e, { controller: o });
22
- }
23
- var T = {
24
- mounted(e, t) {
25
- w(e, t);
26
- },
27
- updated(e, t) {
28
- w(e, t);
29
- },
30
- beforeUnmount(e) {
31
- S.get(e)?.controller.abort(), S.delete(e);
32
- }
33
- }, E = ["id", "title"], D = /* @__PURE__ */ s({
34
- __name: "ui3n-icon",
35
- props: {
36
- id: {},
37
- icon: {},
38
- title: { default: "" },
39
- size: {},
40
- width: {},
41
- height: {},
42
- color: { default: "var(--color-icon-control-primary-default)" },
43
- horizontalFlip: { type: Boolean },
44
- verticalFlip: { type: Boolean },
45
- rotate: { default: 0 }
46
- },
47
- emits: ["click"],
48
- setup(e, { emit: n }) {
49
- let r = e, a = n, o = t(() => r.size || r.width || 16), s = t(() => r.size || r.height || 16), l = t(() => {
50
- let e = {
51
- "--ui3n-icon-width": u(o.value),
52
- "--ui3n-icon-height": u(s.value),
53
- "--ui3n-icon-color": r.color
54
- }, t = [];
55
- return r.horizontalFlip && t.push("rotateY(180deg)"), r.verticalFlip && t.push("rotateX(180deg)"), r.rotate && t.push(`rotate(${r.rotate}deg)`), t.length && (e.transform = t.join(" ")), e;
56
- });
57
- function u(e) {
58
- return isNaN(Number(e)) ? String(e) : `${e}px`;
59
- }
60
- return (t, n) => (p(), i("div", c({
61
- id: e.id,
62
- class: t.$style.ui3nIcon,
63
- title: e.title,
64
- style: l.value
65
- }, { "data-icon": e.icon }, { onClick: n[0] ||= (e) => a("click", e) }), null, 16, E));
66
- }
67
- }), O = { ui3nIcon: "_ui3nIcon_10yhz_1" }, k = (e, t) => {
68
- let n = e.__vccOpts || e;
69
- for (let [e, r] of t) n[e] = r;
70
- return n;
71
- }, A = /* @__PURE__ */ k(D, [["__cssModules", { $style: O }]]), j = {
72
- small: 12,
73
- regular: 16,
74
- large: 24
75
- }, M = ["id", "disabled"], N = /* @__PURE__ */ k(/* @__PURE__ */ s({
76
- __name: "ui3n-button",
77
- props: {
78
- id: {},
79
- type: { default: "primary" },
80
- size: { default: "regular" },
81
- square: { type: Boolean },
82
- block: { type: Boolean },
83
- textColor: {},
84
- color: {},
85
- elevation: { type: Boolean },
86
- icon: {},
87
- iconSize: {},
88
- iconColor: {},
89
- iconPosition: { default: "right" },
90
- disabled: {
91
- type: Boolean,
92
- default: !1
93
- }
94
- },
95
- emits: [
96
- "init",
97
- "click",
98
- "enter",
99
- "focus",
100
- "blur"
101
- ],
102
- setup(e, { emit: a }) {
103
- let o = T, s = e, c = a, u = v(), d = m(null), g = t(() => {
104
- let e = [
105
- u.ui3nButton,
106
- u[s.size],
107
- u[s.type]
108
- ];
109
- return s.block && s.type !== "icon" && e.push(u.block), s.square && e.push(u.square), s.icon && e.push(u[`withIcon-${s.iconPosition}`]), s.elevation && e.push(u.elevation), e;
110
- }), S = t(() => s.iconSize ? s.iconSize : j[s.size]), C = t(() => s.iconColor ? s.iconColor : "inherit");
111
- async function w(e, t) {
112
- ["init", "enter"].includes(e) ? c(e, d.value) : c(e, t);
113
- }
114
- return y([() => s.color, () => s.textColor], (e, t) => {
115
- if (!d.value) return;
116
- let [n, r] = t, [i, a] = e;
117
- (s.type === "custom" || s.type === "icon") && i !== n && d.value.style.setProperty("--ui3n-button-bg-color", i ?? "var(--color-bg-button-primary-default)"), (s.type === "custom" || s.type === "icon") && a !== r && d.value.style.setProperty("--ui3n-button-text-color", a ?? "var(--color-text-button-primary-default)");
118
- }), f(() => {
119
- d.value && ((s.type === "custom" || s.type === "icon") && s.color && d.value.style.setProperty("--ui3n-button-bg-color", s.color), s.type === "custom" && s.textColor && d.value.style.setProperty("--ui3n-button-text-color", s.textColor), w("init"));
120
- }), (t, a) => b((p(), i("button", {
121
- ref_key: "buttonEl",
122
- ref: d,
123
- id: e.id,
124
- class: l(g.value),
125
- type: "button",
126
- disabled: e.disabled,
127
- onClick: a[0] ||= (e) => w("click", e),
128
- onFocusin: a[1] ||= (e) => w("focus", e),
129
- onFocusout: a[2] ||= (e) => w("blur", e),
130
- onKeydown: a[3] ||= x((e) => w("enter"), ["enter"])
131
- }, [e.icon ? (p(), n(A, {
132
- key: 0,
133
- class: l(t.$style.buttonIcon),
134
- icon: e.icon,
135
- size: S.value,
136
- color: C.value
137
- }, null, 8, [
138
- "class",
139
- "icon",
140
- "size",
141
- "color"
142
- ])) : r("", !0), e.type === "icon" ? r("", !0) : (p(), i("span", {
143
- key: 1,
144
- class: l(t.$style.text)
145
- }, [h(t.$slots, "default")], 2))], 42, M)), [[_(o)]]);
146
- }
147
- }), [["__cssModules", { $style: {
148
- ui3nButton: "_ui3nButton_5lm0q_3",
149
- "withIcon-left": "_withIcon-left_5lm0q_35",
150
- "withIcon-right": "_withIcon-right_5lm0q_38",
151
- square: "_square_5lm0q_41",
152
- regular: "_regular_5lm0q_48",
153
- small: "_small_5lm0q_55",
154
- large: "_large_5lm0q_62",
155
- block: "_block_5lm0q_69",
156
- primary: "_primary_5lm0q_73",
157
- elevation: "_elevation_5lm0q_96",
158
- text: "_text_5lm0q_101",
159
- secondary: "_secondary_5lm0q_133",
160
- tertiary: "_tertiary_5lm0q_187",
161
- outline: "_outline_5lm0q_242",
162
- icon: "_icon_5lm0q_270",
163
- custom: "_custom_5lm0q_290",
164
- buttonIcon: "_buttonIcon_5lm0q_319"
165
- } }]]), P = ["id"], F = /* @__PURE__ */ k(/* @__PURE__ */ s({
166
- __name: "ui3n-notification",
167
- props: {
168
- id: {},
169
- type: { default: "info" },
170
- content: {},
171
- position: { default: "center" },
172
- duration: { default: 0 },
173
- withIcon: {
174
- type: Boolean,
175
- default: !0
176
- },
177
- borderRadius: { default: 8 },
178
- onOpen: {
179
- type: Function,
180
- default: () => {}
181
- },
182
- onClose: {
183
- type: Function,
184
- default: () => {}
185
- }
186
- },
187
- setup(s) {
188
- let c = s, m = null, h = v(), y = t(() => ({
189
- success: {
190
- icon: "round-check-circle",
191
- iconColor: "var(--success-fill-default)",
192
- iconRotate: 0
193
- },
194
- warning: {
195
- icon: "round-warning",
196
- iconColor: "var(--warning-fill-default)",
197
- iconRotate: 0
198
- },
199
- info: {
200
- icon: "round-info",
201
- iconColor: "var(--info-fill-default)",
202
- iconRotate: 180
203
- },
204
- error: {
205
- icon: "round-info",
206
- iconColor: "var(--error-fill-default)",
207
- iconRotate: 180
208
- }
209
- })[c.type || "info"]), b = t(() => {
210
- let e = [
211
- h.ui3nNotification,
212
- h[`${c.type}Type`],
213
- h[`${c.position}Position`]
214
- ];
215
- return c.withIcon && e.push(h.withIcon), e;
216
- }), x = t(() => ({ "--ui3n-notification-border-radius": e(c.borderRadius, "8px") }));
217
- function S() {
218
- c.onClose && c.onClose();
219
- }
220
- return f(() => {
221
- c.onOpen && c.onOpen(), c.duration > 0 && (m = setTimeout(() => {
222
- S();
223
- }, c.duration));
224
- }), d(() => {
225
- m && clearTimeout(m);
226
- }), (e, t) => (p(), i("div", {
227
- id: s.id,
228
- class: l(b.value),
229
- style: u(x.value)
230
- }, [
231
- s.withIcon ? (p(), i("div", {
232
- key: 0,
233
- class: l(_(h).ui3nNotificationIcon)
234
- }, [o(A, {
235
- icon: y.value.icon,
236
- size: "16",
237
- rotate: y.value.iconRotate,
238
- color: y.value.iconColor
239
- }, null, 8, [
240
- "icon",
241
- "rotate",
242
- "color"
243
- ])], 2)) : r("", !0),
244
- a("div", { class: l(_(h).ui3nNotificationContent) }, g(s.content), 3),
245
- s.duration ? r("", !0) : (p(), n(N, {
246
- key: 1,
247
- type: "icon",
248
- size: "small",
249
- color: "transparent",
250
- icon: "round-close",
251
- "icon-size": "16",
252
- class: l(_(h).closeBtn),
253
- onClick: S
254
- }, null, 8, ["class"]))
255
- ], 14, P));
256
- }
257
- }), [["__cssModules", { $style: {
258
- ui3nNotification: "_ui3nNotification_1pr9s_1",
259
- withIcon: "_withIcon_1pr9s_23",
260
- ui3nNotificationIcon: "_ui3nNotificationIcon_1pr9s_27",
261
- ui3nNotificationContent: "_ui3nNotificationContent_1pr9s_40",
262
- closeBtn: "_closeBtn_1pr9s_50",
263
- infoType: "_infoType_1pr9s_58",
264
- successType: "_successType_1pr9s_69",
265
- warningType: "_warningType_1pr9s_80",
266
- errorType: "_errorType_1pr9s_91",
267
- leftPosition: "_leftPosition_1pr9s_102",
268
- centerPosition: "_centerPosition_1pr9s_107",
269
- rightPosition: "_rightPosition_1pr9s_112"
270
- } }]]);
271
- //#endregion
272
- export { T as a, k as i, N as n, A as r, F as t };