@v1nt1248/3nclient-lib 0.1.10 → 0.1.11

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.
@@ -0,0 +1,3 @@
1
+ export type ExtractComponentProps<TComponent> = TComponent extends new () => {
2
+ $props: infer P;
3
+ } ? P : never;
@@ -21,9 +21,9 @@ export interface Ui3nDialogProps {
21
21
  cancelButtonBackground?: string;
22
22
  closeOnClickOverlay?: boolean;
23
23
  }
24
- export interface Ui3nDialogComponentProps {
25
- component: Component;
26
- componentProps?: Record<string, any>;
24
+ export interface Ui3nDialogComponentProps<T extends Component, P extends Record<string, unknown>> {
25
+ component: T;
26
+ componentProps?: P;
27
27
  dialogProps?: Ui3nDialogProps;
28
28
  }
29
29
  export interface Ui3nDialogComponentEmits {
@@ -1,26 +1,31 @@
1
- import { Ui3nDialogComponentProps } from './types';
2
- declare const _default: import('vue').DefineComponent<__VLS_TypePropsToOption<Ui3nDialogComponentProps>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
3
- open: (value?: any) => void;
4
- "before-close": (value?: any) => void;
5
- close: (value?: any) => void;
6
- confirm: (value?: any) => void;
7
- cancel: (value?: any) => void;
8
- "click-overlay": (value?: any) => void;
9
- }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToOption<Ui3nDialogComponentProps>>> & {
10
- onClose?: ((value?: any) => any) | undefined;
11
- onConfirm?: ((value?: any) => any) | undefined;
12
- onCancel?: ((value?: any) => any) | undefined;
13
- onOpen?: ((value?: any) => any) | undefined;
14
- "onBefore-close"?: ((value?: any) => any) | undefined;
15
- "onClick-overlay"?: ((value?: any) => any) | undefined;
16
- }, {}, {}>;
17
- export default _default;
18
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
19
- type __VLS_TypePropsToOption<T> = {
20
- [K in keyof T]-?: {} extends Pick<T, K> ? {
21
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
22
- } : {
23
- type: import('vue').PropType<T[K]>;
24
- required: true;
25
- };
1
+ import { Component } from 'vue';
2
+ import { Ui3nDialogComponentProps, Ui3nDialogComponentEmits } from './types';
3
+ declare const _default: <T extends Component, P extends Record<string, unknown>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_Prettify<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
+ props: __VLS_Prettify<Pick<Partial<{}> & Omit<{
5
+ onClose?: ((value?: any) => any) | undefined;
6
+ onCancel?: ((value?: any) => any) | undefined;
7
+ onOpen?: ((value?: any) => any) | undefined;
8
+ "onBefore-close"?: ((value?: any) => any) | undefined;
9
+ onConfirm?: ((value?: any) => any) | undefined;
10
+ "onClick-overlay"?: ((value?: any) => any) | undefined;
11
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<import('vue').ExtractPropTypes<{}>> & {
12
+ onClose?: ((value?: any) => any) | undefined;
13
+ onCancel?: ((value?: any) => any) | undefined;
14
+ onOpen?: ((value?: any) => any) | undefined;
15
+ "onBefore-close"?: ((value?: any) => any) | undefined;
16
+ onConfirm?: ((value?: any) => any) | undefined;
17
+ "onClick-overlay"?: ((value?: any) => any) | undefined;
18
+ }, never>, "onClose" | "onCancel" | "onOpen" | "onBefore-close" | "onConfirm" | "onClick-overlay"> & Ui3nDialogComponentProps<T, P>> & import('vue').PublicProps;
19
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
20
+ attrs: any;
21
+ slots: ReturnType<() => {}>;
22
+ emit: Ui3nDialogComponentEmits & {};
23
+ }>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
24
+ [key: string]: any;
25
+ }> & {
26
+ __ctx?: Awaited<typeof __VLS_setup>;
26
27
  };
28
+ export default _default;
29
+ type __VLS_Prettify<T> = {
30
+ [K in keyof T]: T[K];
31
+ } & {};
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Component } from 'vue';
1
2
  import { default as Ui3nButton } from './components/ui3n-button/ui3n-button.vue';
2
3
  import { default as Ui3nChip } from './components/ui3n-chip/ui3n-chip.vue';
3
4
  import { default as Ui3nCheckbox } from './components/ui3n-checkbox/ui3n-checkbox.vue';
@@ -33,9 +34,10 @@ export * from './utils';
33
34
  export * from './plugins';
34
35
  export * from './directives';
35
36
  export * from './components';
37
+ export * from './components/types';
36
38
  declare module 'vue' {
37
39
  interface ComponentCustomProperties {
38
- $openDialog: (params: Ui3nDialogComponentProps) => DialogInstance | undefined;
40
+ $openDialog: <T extends Component, P extends Record<string, unknown>>(params: Ui3nDialogComponentProps<T, P>) => DialogInstance | undefined;
39
41
  $createNotice: (params: Ui3nNotificationProps) => void;
40
42
  $locale: string;
41
43
  $tr: (key: string, placeholders?: Record<string, string>) => string;
@@ -75,7 +77,7 @@ declare module 'vue' {
75
77
  }
76
78
  declare module 'pinia' {
77
79
  interface PiniaCustomProperties {
78
- $openDialog: (params: Ui3nDialogComponentProps) => DialogInstance | undefined;
80
+ $openDialog: <T extends Component, P extends Record<string, unknown>>(params: Ui3nDialogComponentProps<T, P>) => DialogInstance | undefined;
79
81
  $createNotice: (params: Ui3nNotificationProps) => void;
80
82
  $emitter: {
81
83
  on: (type: string | symbol, handler: CbFunction) => void;
@@ -4,6 +4,6 @@ import { DialogInstance } from './types';
4
4
  export declare const dialogs: Plugin;
5
5
  declare module '@vue/runtime-core' {
6
6
  interface ComponentCustomProperties {
7
- $openDialog: (params: Ui3nDialogComponentProps) => DialogInstance | undefined;
7
+ $openDialog: <T extends Component, P extends Record<string, unknown>>(params: Ui3nDialogComponentProps<T, P>) => DialogInstance | undefined;
8
8
  }
9
9
  }
@@ -1,4 +1,5 @@
1
+ import { Component } from 'vue';
1
2
  import { Ui3nDialogComponentProps } from '../../components/ui3n-dialog/types';
2
3
  export declare function storeDialogs(context: any): {
3
- $openDialog: (params: Ui3nDialogComponentProps) => void;
4
+ $openDialog: <T extends Component, P extends Record<string, unknown>>(params: Ui3nDialogComponentProps<T, P>) => void;
4
5
  };
@@ -1,4 +1,4 @@
1
- import { InjectionKey, VNode } from 'vue';
1
+ import { Component, InjectionKey, VNode } from 'vue';
2
2
  import { Ui3nDialogComponentProps } from '../../components/ui3n-dialog/types';
3
3
  export type DialogInstance = {
4
4
  id: string;
@@ -7,6 +7,6 @@ export type DialogInstance = {
7
7
  destroy: () => void;
8
8
  };
9
9
  export interface DialogsPlugin {
10
- $openDialog: (params: Ui3nDialogComponentProps) => DialogInstance | undefined;
10
+ $openDialog: <T extends Component, P extends Record<string, unknown>>(params: Ui3nDialogComponentProps<T, P>) => DialogInstance | undefined;
11
11
  }
12
12
  export declare const DIALOGS_KEY: InjectionKey<DialogsPlugin>;
@@ -27,6 +27,7 @@ import { default as Ui3nClickOutside } from './directives/ui3n-click-outside';
27
27
  import { default as Ui3nResize } from './directives/ui3n-resize';
28
28
  export * from './directives';
29
29
  export * from './components';
30
+ export * from './components/types';
30
31
  declare module 'vue' {
31
32
  interface GlobalComponents {
32
33
  Ui3nBadge: typeof Ui3nBadge;
@@ -14168,7 +14168,13 @@ const PM = /* @__PURE__ */ Eg({
14168
14168
  };
14169
14169
  }), w = DA(() => ({ width: `${a.value.width}px`, ...a.value.cssStyle }));
14170
14170
  iI(() => {
14171
- r.value && (r.value.style.setProperty("--dialog-confirm-button-color", a.value.confirmButtonColor), r.value.style.setProperty("--dialog-cancel-button-color", a.value.cancelButtonColor), r.value.style.setProperty("--dialog-confirm-background-color", a.value.confirmButtonBackground), r.value.style.setProperty("--dialog-cancel-background-color", a.value.cancelButtonBackground)), r.value && ya(() => {
14171
+ r.value && (r.value.style.setProperty("--dialog-confirm-button-color", a.value.confirmButtonColor), r.value.style.setProperty("--dialog-cancel-button-color", a.value.cancelButtonColor), r.value.style.setProperty(
14172
+ "--dialog-confirm-background-color",
14173
+ a.value.confirmButtonBackground
14174
+ ), r.value.style.setProperty(
14175
+ "--dialog-cancel-background-color",
14176
+ a.value.cancelButtonBackground
14177
+ )), r.value && ya(() => {
14172
14178
  r.value.focus();
14173
14179
  });
14174
14180
  });
@@ -14238,10 +14244,7 @@ const PM = /* @__PURE__ */ Eg({
14238
14244
  ], 6)) : ZA("", !0),
14239
14245
  a.value.confirmButton || a.value.cancelButton ? (oA(), uA("div", {
14240
14246
  key: 2,
14241
- class: BA([
14242
- k.$style.actions,
14243
- a.value.confirmButton && a.value.cancelButton && k.$style.bothBtns
14244
- ]),
14247
+ class: BA([k.$style.actions, a.value.confirmButton && a.value.cancelButton && k.$style.bothBtns]),
14245
14248
  onClick: y[8] || (y[8] = XQ(() => {
14246
14249
  }, ["stop"]))
14247
14250
  }, [
@@ -1,3 +1,4 @@
1
+ import { Component } from 'vue';
1
2
  import { i18n } from './plugins/i18n/i18n';
2
3
  import { storeI18n } from './plugins/i18n/store-i18n';
3
4
  import { I18N_KEY, I18nOptions, I18nPlugin } from './plugins/i18n/types';
@@ -15,7 +16,7 @@ import { storeVueBus } from './plugins/vue-bus/store-vue-bus';
15
16
  import { VUEBUS_KEY, CbFunction, VueEventBus, VueBusPlugin } from './plugins/vue-bus/types';
16
17
  declare module 'vue' {
17
18
  interface ComponentCustomProperties {
18
- $openDialog: (params: Ui3nDialogComponentProps) => DialogInstance | undefined;
19
+ $openDialog: <T extends Component, P extends Record<string, unknown>>(params: Ui3nDialogComponentProps<T, P>) => DialogInstance | undefined;
19
20
  $createNotice: (params: Ui3nNotificationProps) => void;
20
21
  $locale: string;
21
22
  $tr: (key: string, placeholders?: Record<string, string>) => string;
@@ -25,7 +26,7 @@ declare module 'vue' {
25
26
  }
26
27
  declare module 'pinia' {
27
28
  interface PiniaCustomProperties {
28
- $openDialog: (params: Ui3nDialogComponentProps) => DialogInstance | undefined;
29
+ $openDialog: <T extends Component, P extends Record<string, unknown>>(params: Ui3nDialogComponentProps<T, P>) => DialogInstance | undefined;
29
30
  $createNotice: (params: Ui3nNotificationProps) => void;
30
31
  $emitter: {
31
32
  on: (type: string | symbol, handler: CbFunction) => void;
@@ -5465,7 +5465,13 @@ const bv = /* @__PURE__ */ Te({
5465
5465
  };
5466
5466
  }), L = ts(() => ({ width: `${I.value.width}px`, ...I.value.cssStyle }));
5467
5467
  go(() => {
5468
- b.value && (b.value.style.setProperty("--dialog-confirm-button-color", I.value.confirmButtonColor), b.value.style.setProperty("--dialog-cancel-button-color", I.value.cancelButtonColor), b.value.style.setProperty("--dialog-confirm-background-color", I.value.confirmButtonBackground), b.value.style.setProperty("--dialog-cancel-background-color", I.value.cancelButtonBackground)), b.value && H0(() => {
5468
+ b.value && (b.value.style.setProperty("--dialog-confirm-button-color", I.value.confirmButtonColor), b.value.style.setProperty("--dialog-cancel-button-color", I.value.cancelButtonColor), b.value.style.setProperty(
5469
+ "--dialog-confirm-background-color",
5470
+ I.value.confirmButtonBackground
5471
+ ), b.value.style.setProperty(
5472
+ "--dialog-cancel-background-color",
5473
+ I.value.cancelButtonBackground
5474
+ )), b.value && H0(() => {
5469
5475
  b.value.focus();
5470
5476
  });
5471
5477
  });
@@ -5535,10 +5541,7 @@ const bv = /* @__PURE__ */ Te({
5535
5541
  ], 6)) : et("", !0),
5536
5542
  I.value.confirmButton || I.value.cancelButton ? (Ln(), xt("div", {
5537
5543
  key: 2,
5538
- class: Tn([
5539
- M.$style.actions,
5540
- I.value.confirmButton && I.value.cancelButton && M.$style.bothBtns
5541
- ]),
5544
+ class: Tn([M.$style.actions, I.value.confirmButton && I.value.cancelButton && M.$style.bothBtns]),
5542
5545
  onClick: S[8] || (S[8] = Ce(() => {
5543
5546
  }, ["stop"]))
5544
5547
  }, [
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.1.10",
5
+ "version": "0.1.11",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -0,0 +1,5 @@
1
+ export type ExtractComponentProps<TComponent> = TComponent extends new () => {
2
+ $props: infer P;
3
+ }
4
+ ? P
5
+ : never;
@@ -24,9 +24,9 @@ export interface Ui3nDialogProps {
24
24
  closeOnClickOverlay?: boolean;
25
25
  }
26
26
 
27
- export interface Ui3nDialogComponentProps {
28
- component: Component;
29
- componentProps?: Record<string, any>;
27
+ export interface Ui3nDialogComponentProps<T extends Component, P extends Record<string, unknown>> {
28
+ component: T;
29
+ componentProps?: P;
30
30
  dialogProps?: Ui3nDialogProps;
31
31
  }
32
32
 
@@ -1,10 +1,10 @@
1
- <script lang="ts" setup>
1
+ <script lang="ts" setup generic="T extends Component, P extends Record<string, unknown>">
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
- import { computed, nextTick, onMounted, ref } from 'vue';
3
+ import { type Component, computed, nextTick, onMounted, ref } from 'vue';
4
4
  import Ui3nButton from '../ui3n-button/ui3n-button.vue';
5
5
  import type { Ui3nDialogEvent, Ui3nDialogProps, Ui3nDialogComponentProps, Ui3nDialogComponentEmits } from './types';
6
6
 
7
- const props = defineProps<Ui3nDialogComponentProps>();
7
+ const props = defineProps<Ui3nDialogComponentProps<T, P>>();
8
8
  const emits = defineEmits<Ui3nDialogComponentEmits>();
9
9
 
10
10
  const show = ref(true);
@@ -36,8 +36,14 @@ onMounted(() => {
36
36
  if (dialogElement.value) {
37
37
  dialogElement.value.style.setProperty('--dialog-confirm-button-color', dialogProps.value.confirmButtonColor!);
38
38
  dialogElement.value.style.setProperty('--dialog-cancel-button-color', dialogProps.value.cancelButtonColor!);
39
- dialogElement.value.style.setProperty('--dialog-confirm-background-color', dialogProps.value.confirmButtonBackground!);
40
- dialogElement.value.style.setProperty('--dialog-cancel-background-color', dialogProps.value.cancelButtonBackground!);
39
+ dialogElement.value.style.setProperty(
40
+ '--dialog-confirm-background-color',
41
+ dialogProps.value.confirmButtonBackground!,
42
+ );
43
+ dialogElement.value.style.setProperty(
44
+ '--dialog-cancel-background-color',
45
+ dialogProps.value.cancelButtonBackground!,
46
+ );
41
47
  }
42
48
 
43
49
  if (dialogElement.value) {
@@ -49,11 +55,7 @@ onMounted(() => {
49
55
 
50
56
  const selectData = (value: any) => {
51
57
  data.value = value;
52
- if (
53
- !dialogProps.value.confirmButton
54
- && !dialogProps.value.cancelButton
55
- && props.dialogProps?.onConfirm
56
- ) {
58
+ if (!dialogProps.value.confirmButton && !dialogProps.value.cancelButton && props.dialogProps?.onConfirm) {
57
59
  props.dialogProps?.onConfirm(data.value);
58
60
  closeDialog();
59
61
  }
@@ -63,7 +65,7 @@ const validate = (value: boolean) => {
63
65
  isValid.value = value;
64
66
  };
65
67
 
66
- const closeDialog = (arg?: { ev?: Event, withAction?: boolean }) => {
68
+ const closeDialog = (arg?: { ev?: Event; withAction?: boolean }) => {
67
69
  const { ev, withAction = true } = arg || {};
68
70
  if (ev) {
69
71
  ev.stopImmediatePropagation();
@@ -112,10 +114,7 @@ const handleEvent = (event: Event, eventName: Ui3nDialogEvent) => {
112
114
  <div
113
115
  v-if="show"
114
116
  :class="$style.overlay"
115
- @click="dialogProps.closeOnClickOverlay
116
- ? closeDialog({ ev: $event })
117
- : startEmit('click-overlay')
118
- "
117
+ @click="dialogProps.closeOnClickOverlay ? closeDialog({ ev: $event }) : startEmit('click-overlay')"
119
118
  >
120
119
  <div
121
120
  ref="dialogElement"
@@ -123,7 +122,7 @@ const handleEvent = (event: Event, eventName: Ui3nDialogEvent) => {
123
122
  :class="[$style.dialog, ...dialogProps.cssClass]"
124
123
  :style="cssStyle"
125
124
  @keydown.esc.stop="startEmit('cancel')"
126
- @keydown.enter.stop=" isValid && startEmit('confirm')"
125
+ @keydown.enter.stop="isValid && startEmit('confirm')"
127
126
  >
128
127
  <div
129
128
  v-if="dialogProps.title"
@@ -150,9 +149,10 @@ const handleEvent = (event: Event, eventName: Ui3nDialogEvent) => {
150
149
  :style="dialogProps.contentCssStyle"
151
150
  @click.stop
152
151
  >
152
+ <!-- @vue-ignore -->
153
153
  <component
154
154
  :is="component"
155
- v-bind="componentProps"
155
+ v-bind="componentProps as Object"
156
156
  @select="selectData"
157
157
  @validate="validate"
158
158
  @close="closeDialog({ ev: $event })"
@@ -163,10 +163,7 @@ const handleEvent = (event: Event, eventName: Ui3nDialogEvent) => {
163
163
 
164
164
  <div
165
165
  v-if="dialogProps.confirmButton || dialogProps.cancelButton"
166
- :class="[
167
- $style.actions,
168
- dialogProps.confirmButton && dialogProps.cancelButton && $style.bothBtns,
169
- ]"
166
+ :class="[$style.actions, dialogProps.confirmButton && dialogProps.cancelButton && $style.bothBtns]"
170
167
  @click.stop
171
168
  >
172
169
  <ui3n-button
@@ -194,7 +191,7 @@ const handleEvent = (event: Event, eventName: Ui3nDialogEvent) => {
194
191
  </template>
195
192
 
196
193
  <style lang="scss" module>
197
- @import "../../assets/styles/mixins";
194
+ @import '../../assets/styles/mixins';
198
195
 
199
196
  .overlay {
200
197
  position: fixed;