@v1nt1248/3nclient-lib 0.3.5 → 0.3.7

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
@@ -2,7 +2,7 @@
2
2
  "name": "@v1nt1248/3nclient-lib",
3
3
  "license": "AGPL-3.0-or-later",
4
4
  "author": "v1nt1248",
5
- "version": "0.3.5",
5
+ "version": "0.3.7",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -1,7 +1,9 @@
1
1
  import type { VNode } from 'vue';
2
2
  import type { Ui3nIconField } from '@/types';
3
3
 
4
- export type Ui3nDialogEvent = 'close' | 'confirm' | 'cancel' | 'click-overlay';
4
+ export type Ui3nDialogEventBase = 'close' | 'confirm' | 'cancel' | 'click-overlay';
5
+
6
+ export type Ui3nDialogEvent<E extends string = never> = Ui3nDialogEventBase | E;
5
7
 
6
8
  export interface Ui3nDialogComponentProps<V> {
7
9
  id?: string;
@@ -28,8 +30,8 @@ export interface Ui3nDialogComponentProps<V> {
28
30
  isValid?: boolean;
29
31
  }
30
32
 
31
- export interface Ui3nDialogComponentEmits<V> {
32
- (event: 'action', value: { event: Ui3nDialogEvent; data?: V }): void;
33
+ export interface Ui3nDialogComponentEmits<V, E extends string = never> {
34
+ (event: 'action', value: { event: Ui3nDialogEvent<E>; data?: V }): void;
33
35
  }
34
36
 
35
37
  export interface Ui3nDialogComponentSlots {
@@ -1,4 +1,4 @@
1
- <script lang="ts" setup generic="V extends any">
1
+ <script lang="ts" setup generic="V extends any, E extends string = never">
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  import { type Component, inject } from 'vue';
4
4
  import type { DialogsPlugin } from '@/plugins';
@@ -12,12 +12,12 @@
12
12
  if (
13
13
  (modalProps as Ui3nDialogComponentProps<any>).closeOnClickOverlay ||
14
14
  ((modalProps as any).dialogProps as Ui3nDialogComponentProps<any>)?.closeOnClickOverlay
15
- ) {
15
+ ) {
16
16
  dialogs.$closeDialog(id, { event: 'click-overlay' });
17
17
  }
18
18
  }
19
19
 
20
- function onAction(id: string, value: { event: Ui3nDialogEvent; data?: V }) {
20
+ function onAction(id: string, value: { event: Ui3nDialogEvent<E>; data?: V }) {
21
21
  dialogs.$closeDialog(id, value);
22
22
  }
23
23
  </script>
@@ -1,4 +1,4 @@
1
- <script lang="ts" setup generic="V extends any">
1
+ <script lang="ts" setup generic="V extends any, E extends string = never">
2
2
  import { computed, nextTick, onMounted, ref, useTemplateRef } from 'vue';
3
3
  import omit from 'lodash/omit';
4
4
  import { determineWindowWidth } from './util';
@@ -6,24 +6,22 @@
6
6
  import Ui3nButton from '../ui3n-button/ui3n-button.vue';
7
7
  import Ui3nIcon from '../ui3n-icon/ui3n-icon.vue';
8
8
 
9
- const props = withDefaults(
10
- defineProps<Ui3nDialogComponentProps<V>>(), {
11
- cssClass: () => [],
12
- cssStyle: () => ({}),
13
- contentCssClass: () => [],
14
- contentCssStyle: () => ({}),
15
- confirmButton: true,
16
- cancelButton: true,
17
- confirmButtonText: 'Done',
18
- cancelButtonText: 'Cancel',
19
- confirmButtonColor: 'var(--color-text-button-primary-default)',
20
- cancelButtonColor: 'var(--color-text-button-secondary-default)',
21
- confirmButtonBackground: 'var(--color-bg-button-primary-default)',
22
- cancelButtonBackground: 'var(--color-bg-button-secondary-default)',
23
- isValid: true,
24
- },
25
- );
26
- const emits = defineEmits<Ui3nDialogComponentEmits<V>>();
9
+ const props = withDefaults(defineProps<Ui3nDialogComponentProps<V>>(), {
10
+ cssClass: () => [],
11
+ cssStyle: () => ({}),
12
+ contentCssClass: () => [],
13
+ contentCssStyle: () => ({}),
14
+ confirmButton: true,
15
+ cancelButton: true,
16
+ confirmButtonText: 'Done',
17
+ cancelButtonText: 'Cancel',
18
+ confirmButtonColor: 'var(--color-text-button-primary-default)',
19
+ cancelButtonColor: 'var(--color-text-button-secondary-default)',
20
+ confirmButtonBackground: 'var(--color-bg-button-primary-default)',
21
+ cancelButtonBackground: 'var(--color-bg-button-secondary-default)',
22
+ isValid: true,
23
+ });
24
+ const emits = defineEmits<Ui3nDialogComponentEmits<V, E>>();
27
25
  defineSlots<Ui3nDialogComponentSlots>();
28
26
 
29
27
  const dialogElement = useTemplateRef('dialog-el');
@@ -105,22 +103,13 @@
105
103
 
106
104
  onMounted(() => {
107
105
  if (dialogElement.value) {
108
- dialogElement.value.style.setProperty(
109
- '--ui3n-dialog-confirm-button-color',
110
- props.confirmButtonColor,
111
- );
112
- dialogElement.value.style.setProperty(
113
- '--ui3n-dialog-cancel-button-color',
114
- props.cancelButtonColor,
115
- );
106
+ dialogElement.value.style.setProperty('--ui3n-dialog-confirm-button-color', props.confirmButtonColor);
107
+ dialogElement.value.style.setProperty('--ui3n-dialog-cancel-button-color', props.cancelButtonColor);
116
108
  dialogElement.value.style.setProperty(
117
109
  '--ui3n-dialog-confirm-background-color',
118
110
  props.confirmButtonBackground,
119
111
  );
120
- dialogElement.value.style.setProperty(
121
- '--ui3n-dialog-cancel-background-color',
122
- props.cancelButtonBackground,
123
- );
112
+ dialogElement.value.style.setProperty('--ui3n-dialog-cancel-background-color', props.cancelButtonBackground);
124
113
 
125
114
  nextTick(() => {
126
115
  dialogElement.value!.focus();
@@ -145,12 +134,12 @@
145
134
  v-on="
146
135
  draggable
147
136
  ? {
148
- dragstart: onDragstart,
149
- mousedown: onMousedown,
150
- mouseup: onMouseup,
151
- mousemove: onMousemove,
152
- keydown: onKeydown,
153
- }
137
+ dragstart: onDragstart,
138
+ mousedown: onMousedown,
139
+ mouseup: onMouseup,
140
+ mousemove: onMousemove,
141
+ keydown: onKeydown,
142
+ }
154
143
  : { keydown: onKeydown }
155
144
  "
156
145
  >