@v1nt1248/3nclient-lib 0.1.10 → 0.1.12

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.1.10",
5
+ "version": "0.1.12",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -37,6 +37,7 @@
37
37
  "build:plugins": "LIB_NAME=plugins vite build",
38
38
  "build:utils": "LIB_NAME=utils vite build",
39
39
  "build": "pnpm run clean:dist && pnpm run build:components && pnpm run build:plugins && pnpm run build:utils && pnpm run copy:css",
40
+ "pack": "pnpm run build && npm pack && cp *.tgz ./dist && rm *.tgz",
40
41
  "preview": "vite preview",
41
42
  "stylelint": "stylelint --config .stylelint.config.cjs 'src/**/*.{vue,scss}'",
42
43
  "stylelint:fix": "stylelint --config .stylelint.config.cjs --fix 'src/**/*.{vue,scss}'",
@@ -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;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { computed } from 'vue';
3
3
  import { Icon } from '@iconify/vue';
4
4
  import type { Ui3nIconEmits, Ui3nIconProps } from './types';
5
5
 
@@ -15,20 +15,23 @@ const props = withDefaults(
15
15
  );
16
16
  const emits = defineEmits<Ui3nIconEmits>();
17
17
 
18
- const onLoad = (value: any) => {
18
+ const iconName = computed(() => `ic:${props.icon}`);
19
+
20
+ function onLoad(value: unknown) {
19
21
  if (props.onLoad) {
20
22
  props.onLoad(value);
21
23
  }
22
- };
23
- const onClick = (ev: Event) => {
24
+ }
25
+
26
+ function onClick(ev: Event) {
24
27
  emits('click', ev);
25
- };
28
+ }
26
29
  </script>
27
30
 
28
31
  <template>
29
32
  <icon
30
33
  :class="$style.icon"
31
- :icon="icon"
34
+ :icon="iconName"
32
35
  :title="title"
33
36
  :inline="inline"
34
37
  :width="width"
@@ -149,7 +149,7 @@ const validate = (text: string) => {
149
149
 
150
150
  <ui3n-icon
151
151
  v-if="displayStateMode === 'success' && displayStateWithIcon && !isFocused"
152
- icon="check-circle-outline"
152
+ icon="sharp-check-circle-outline"
153
153
  :width="16"
154
154
  :height="16"
155
155
  color="var(--success-content-default)"
@@ -19,25 +19,25 @@ const props = withDefaults(
19
19
  const stylesByTypes = {
20
20
  success: {
21
21
  color: 'var(--success-content-default)',
22
- icon: 'warning',
22
+ icon: 'round-warning',
23
23
  iconColor: 'var(--success-fill-default)',
24
24
  iconRotate: 0,
25
25
  },
26
26
  warning: {
27
27
  color: 'var(--warning-content-default)',
28
- icon: 'warning',
28
+ icon: 'round-warning',
29
29
  iconColor: 'var(--warning-fill-default)',
30
30
  iconRotate: 0,
31
31
  },
32
32
  info: {
33
33
  color: 'var(--info-content-default)',
34
- icon: 'info',
34
+ icon: 'round-info',
35
35
  iconColor: 'var(--info-fill-default)',
36
36
  iconRotate: 90,
37
37
  },
38
38
  error: {
39
39
  color: 'var(--error-content-default)',
40
- icon: 'info',
40
+ icon: 'round-info',
41
41
  iconColor: 'var(--error-fill-default)',
42
42
  iconRotate: 90,
43
43
  },
@@ -12,8 +12,8 @@
12
12
  <template>
13
13
  <transition mode="out-in" name="fade">
14
14
  <ui3n-icon
15
- :key="value === 'asc' ? 'arrow-downward' : 'arrow-upward'"
16
- :icon="value === 'asc' ? 'arrow-downward' : 'arrow-upward'"
15
+ :key="value === 'asc' ? 'baseline-arrow-downward' : 'baseline-arrow-upward'"
16
+ :icon="value === 'asc' ? 'baseline-arrow-downward' : 'baseline-arrow-upward'"
17
17
  :width="iconSize"
18
18
  :height="iconSize"
19
19
  :color="iconColor"
@@ -1,2 +0,0 @@
1
- import { Plugin } from 'vue';
2
- export declare const useIcons: Plugin;