@v1nt1248/3nclient-lib 0.1.19 → 0.1.21

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.
@@ -1,3 +1,11 @@
1
1
  export declare function getRandomId(numOfChars: number): string;
2
2
  export declare function getDeliveryErrors(progress: web3n.asmail.DeliveryProgress): Record<string, string>;
3
3
  export declare function transformFileToWeb3NFile(file: File): Promise<web3n.files.File | undefined>;
4
+ /**
5
+ * функция округления с заданной точностью
6
+ * @param num {number} - округляемое число
7
+ * @param precision {number} - точность округления (количество знаков после запятой
8
+ * указывается со знаком "-")
9
+ * @return {number} - скорректированная округленная десятичная дробь
10
+ */
11
+ export declare function round(num: number, precision: number): number;
@@ -109,6 +109,7 @@
109
109
  }
110
110
 
111
111
  .default-theme {
112
+ --global-default: var(--grey-5);
112
113
  --default-fill-default: var(--white-0);
113
114
  --default-fill-hover: var(--grey-10);
114
115
  --default-fill-focused: var(--white-0);
@@ -175,12 +176,12 @@
175
176
  --s-accent-fill-default: var(--white-0);
176
177
  --s-accent-fill-hover: var(--blue-10);
177
178
  --s-accent-fill-focused: var(--white-0);
178
- --s-accent-fill-pressed: var(--blue-20);
179
+ --s-accent-fill-pressed: var(--blue-70);
179
180
  --s-accent-fill-disabled: var(--blue-0);
180
181
  --s-accent-content-default: var(--blue-50);
181
182
  --s-accent-content-hover: var(--blue-50);
182
183
  --s-accent-content-focused: var(--blue-50);
183
- --s-accent-content-pressed: var(--blue-60);
184
+ --s-accent-content-pressed: var(--blue-50);
184
185
  --s-accent-content-disabled: var(--blue-20);
185
186
  --s-accent-content-selected: var(--blue-50);
186
187
  --s-accent-content-unselected: var(--blue-30);
@@ -252,16 +253,17 @@
252
253
  }
253
254
 
254
255
  .dark-theme {
256
+ --global-default: var(--blue-90);
255
257
  --default-fill-default: var(--blue-100);
256
258
  --default-fill-hover: var(--blue-85);
257
259
  --default-fill-focused: var(--blue-100);
258
260
  --default-fill-pressed: var(--grey-70);
259
261
  --default-fill-disabled: var(--blue-100);
260
- --default-content-default: var(--grey-0);
261
- --default-content-hover: var(--grey-0);
262
- --default-content-focused: var(--grey-0);
263
- --default-content-pressed: var(--grey-0);
264
- --default-content-disabled: var(--grey-20);
262
+ --default-content-default: var(--blue-0);
263
+ --default-content-hover: var(--blue-0);
264
+ --default-content-focused: var(--blue-0);
265
+ --default-content-pressed: var(--blue-0);
266
+ --default-content-disabled: var(--blue-20);
265
267
  --default-hint-default: var(--grey-40);
266
268
  --default-hint-hover: var(--grey-40);
267
269
  --default-hint-focused: var(--grey-40);
@@ -273,21 +275,21 @@
273
275
  --default-outline-pressed: var(--blue-80);
274
276
  --default-outline-disabled: var(--blue-90);
275
277
  --default-outline-ghost: var(--white-inf);
276
- --s-default-fill-default: var(--grey-80);
277
- --s-default-fill-hover: var(--grey-70);
278
- --s-default-fill-focused: var(--grey-100);
279
- --s-default-fill-pressed: var(--grey-50);
280
- --s-default-fill-disabled: var(--grey-80);
278
+ --s-default-fill-default: var(--blue-90);
279
+ --s-default-fill-hover: var(--blue-85);
280
+ --s-default-fill-focused: var(--blue-100);
281
+ --s-default-fill-pressed: var(--blue-70);
282
+ --s-default-fill-disabled: var(--blue-90);
281
283
  --s-default-content-default: var(--blue-0);
282
284
  --s-default-content-hover: var(--blue-0);
283
285
  --s-default-content-focused: var(--blue-0);
284
286
  --s-default-content-pressed: var(--blue-0);
285
287
  --s-default-content-disabled: var(--blue-20);
286
- --s-default-outline-default: var(--grey-70);
287
- --s-default-outline-hover: var(--grey-60);
288
- --s-default-outline-focused: var(--grey-30);
289
- --s-default-outline-pressed: var(--grey-60);
290
- --s-default-outline-disabled: var(--grey-70);
288
+ --s-default-outline-default: var(--blue-85);
289
+ --s-default-outline-hover: var(--blue-80);
290
+ --s-default-outline-focused: var(--blue-50);
291
+ --s-default-outline-pressed: var(--blue-80);
292
+ --s-default-outline-disabled: var(--blue-85);
291
293
  --accent-fill-default: var(--blue-50);
292
294
  --accent-fill-hover: var(--blue-60);
293
295
  --accent-fill-focused: var(--blue-50);
@@ -318,12 +320,12 @@
318
320
  --s-accent-fill-default: var(--blue-100);
319
321
  --s-accent-fill-hover: var(--blue-70);
320
322
  --s-accent-fill-focused: var(--blue-100);
321
- --s-accent-fill-pressed: var(--blue-60);
323
+ --s-accent-fill-pressed: var(--blue-85);
322
324
  --s-accent-fill-disabled: var(--blue-100);
323
325
  --s-accent-content-default: var(--blue-50);
324
326
  --s-accent-content-hover: var(--blue-50);
325
327
  --s-accent-content-focused: var(--blue-50);
326
- --s-accent-content-pressed: var(--blue-60);
328
+ --s-accent-content-pressed: var(--blue-50);
327
329
  --s-accent-content-disabled: var(--blue-20);
328
330
  --s-accent-content-selected: var(--blue-50);
329
331
  --s-accent-content-unselected: var(--blue-30);
@@ -456,7 +458,7 @@
456
458
  --color-bg-table-header-disabled: var(--s-default-fill-disabled);
457
459
  --color-bg-table-header-selected: var(--s-accent-fill-hover);
458
460
  --color-bg-table-header-unselected: var(--s-accent-fill-hover);
459
- --color-bg-chat-bubble-general-bg: var(--accent-content-pressed);
461
+ --color-bg-chat-bubble-general-bg: var(--global-default);
460
462
  --color-bg-chat-bubble-user-default: var(--s-accent-fill-hover);
461
463
  --color-bg-chat-bubble-user-quote: var(--s-accent-fill-hover);
462
464
  --color-bg-chat-bubble-user-selected: var(--accent-fill-pressed);
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.19",
5
+ "version": "0.1.21",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -69,14 +69,14 @@ import type { Ui3nProgressCircularProps, Ui3nProgressLinearProps } from './ui3n-
69
69
  import Ui3nTooltip from './ui3n-tooltip/ui3n-tooltip.vue';
70
70
  import type { Ui3nTooltipEmits, Ui3nTooltipProps, Ui3nTooltipSlots, Ui3nTooltipPlacement } from './ui3n-tooltip/types';
71
71
  import Ui3nRadio from './ui3n-radio-group/ui3n-radio.vue';
72
- // import Ui3nRadioGroup from './ui3n-radio-group/ui3n-radio-group.vue';
72
+ import Ui3nRadioGroup from './ui3n-radio-group/ui3n-radio-group.vue';
73
73
  import type {
74
74
  Ui3nRadioEmits,
75
75
  Ui3nRadioProps,
76
76
  Ui3nRadioSlots,
77
- // Ui3nRadioGroupEmits,
77
+ Ui3nRadioGroupEmits,
78
78
  Ui3nRadioGroupProps,
79
- // Ui3nRadioGroupSlots,
79
+ Ui3nRadioGroupSlots,
80
80
  Ui3nRadioValue,
81
81
  } from './ui3n-radio-group/types';
82
82
 
@@ -170,12 +170,12 @@ export {
170
170
  Ui3nTooltipSlots,
171
171
  Ui3nTooltipPlacement,
172
172
  Ui3nRadio,
173
- // Ui3nRadioGroup,
173
+ Ui3nRadioGroup,
174
174
  Ui3nRadioValue,
175
175
  Ui3nRadioEmits,
176
176
  Ui3nRadioProps,
177
177
  Ui3nRadioSlots,
178
- // Ui3nRadioGroupEmits,
178
+ Ui3nRadioGroupEmits,
179
179
  Ui3nRadioGroupProps,
180
- // Ui3nRadioGroupSlots,
180
+ Ui3nRadioGroupSlots,
181
181
  };
@@ -3,3 +3,5 @@ export type ExtractComponentProps<TComponent> = TComponent extends new () => {
3
3
  }
4
4
  ? P
5
5
  : never;
6
+
7
+ export type Nullable<T> = T | null;
@@ -23,16 +23,17 @@ export interface Ui3nRadioSlots {
23
23
  }
24
24
 
25
25
  export interface Ui3nRadioGroupProps {
26
+ name: string;
26
27
  modelValue?: Ui3nRadioValue;
27
28
  direction?: 'horizontal' | 'vertical';
28
29
  disabled?: boolean;
29
30
  }
30
- //
31
- // export interface Ui3nRadioGroupEmits {
32
- // (ev: 'change', value: Ui3nRadioValue): void;
33
- // (ev: 'update:modelValue', value: Ui3nRadioValue): void;
34
- // }
35
- //
36
- // export interface Ui3nRadioGroupSlots {
37
- // default: () => VNode;
38
- // }
31
+
32
+ export interface Ui3nRadioGroupEmits {
33
+ (ev: 'change', value: Ui3nRadioValue): void;
34
+ (ev: 'update:modelValue', value: Ui3nRadioValue): void;
35
+ }
36
+
37
+ export interface Ui3nRadioGroupSlots {
38
+ default: () => VNode;
39
+ }
@@ -1,42 +1,49 @@
1
- <script lang="ts" setup>
2
- import { onMounted, ref, SetupContext, useSlots } from 'vue';
3
- // import { isEmpty } from 'lodash';
1
+ <script setup lang="ts">
2
+ import { provide, ref, watch } from 'vue';
4
3
  import type {
5
- // Ui3nRadioGroupEmits,
6
4
  Ui3nRadioGroupProps,
7
- // Ui3nRadioGroupSlots,
8
- // Ui3nRadioValue,
5
+ Ui3nRadioGroupEmits,
6
+ Ui3nRadioGroupSlots,
7
+ Ui3nRadioValue,
9
8
  } from './types';
10
9
 
11
- const props = withDefaults(
12
- defineProps<Ui3nRadioGroupProps>(),
13
- {
14
- modelValue: false,
15
- direction: 'horizontal',
16
- disabled: false,
17
- },
18
- );
10
+ const props = withDefaults(defineProps<Ui3nRadioGroupProps>(), {
11
+ modelValue: false,
12
+ direction: 'vertical',
13
+ disabled: false,
14
+ });
15
+ const emits = defineEmits<Ui3nRadioGroupEmits>();
16
+ defineSlots<Ui3nRadioGroupSlots>();
19
17
 
20
- const slots: SetupContext['slots'] = useSlots();
21
- const contentSlot = ref();
22
- const children = ref([]);
18
+ const groupValue = ref<Ui3nRadioValue>(props.modelValue);
23
19
 
24
- function onClick(ev: MouseEvent) {
25
- console.log('EV: ', ev);
20
+ function updateGroupValue(value: Ui3nRadioValue): void {
21
+ groupValue.value = value;
22
+ emits('update:modelValue', value);
23
+ emits('change', value);
26
24
  }
27
25
 
28
- onMounted(() => {
29
- // @ts-ignore
30
- children.value = slots.default();
31
- console.log('CH: ', children.value);
26
+ provide(`radio-group-${props.name}`, {
27
+ groupValue,
28
+ updateGroupValue,
32
29
  });
30
+
31
+ watch(
32
+ () => props.modelValue,
33
+ (val: Ui3nRadioValue) => {
34
+ if (val !== groupValue.value) {
35
+ groupValue.value = val;
36
+ }
37
+ },
38
+ );
33
39
  </script>
34
40
 
35
41
  <template>
36
42
  <div
37
- ref="contentSlot"
38
- :class="$style.radioGroup"
39
- v-on="disabled ? {} : { click: onClick }"
43
+ :class="[
44
+ $style.radioGroup,
45
+ direction === 'horizontal' && $style.horizontal,
46
+ ]"
40
47
  >
41
48
  <slot />
42
49
  </div>
@@ -46,9 +53,14 @@ onMounted(() => {
46
53
  .radioGroup {
47
54
  position: relative;
48
55
  display: flex;
49
- width: max-content;
50
- justify-content: center;
51
- align-items: center;
52
- gap: var(--spacing-s);
56
+ flex-direction: column;
57
+ justify-content: flex-start;
58
+ align-items: flex-start;
59
+ gap: 4px;
60
+
61
+ &.horizontal {
62
+ flex-direction: row;
63
+ column-gap: 8px;
64
+ }
53
65
  }
54
- </style>
66
+ </style>
@@ -2,12 +2,15 @@
2
2
  import {
3
3
  computed,
4
4
  getCurrentInstance,
5
+ inject,
5
6
  onBeforeMount,
6
7
  onMounted,
7
8
  ref,
8
9
  useSlots,
9
10
  watch,
10
11
  } from 'vue';
12
+ import type { Ref } from 'vue';
13
+ import type { Nullable } from '../types';
11
14
  import type {
12
15
  Ui3nRadioEmits,
13
16
  Ui3nRadioProps,
@@ -30,15 +33,40 @@ const emits = defineEmits<Ui3nRadioEmits>();
30
33
  defineSlots<Ui3nRadioSlots>();
31
34
 
32
35
  const slots = useSlots();
33
- const radioEl = ref<HTMLDivElement | null>(null);
34
- const val = ref<Ui3nRadioValue>(props.uncheckedValue || false);
36
+
35
37
  const instance = getCurrentInstance();
38
+ const isComponentPartOfGroup = instance?.parent?.type.__name === 'Ui3nRadioGroup' || instance?.parent?.type.__name === 'ui3n-radio-group';
39
+ const groupName = isComponentPartOfGroup ? instance?.parent?.props.name : '';
36
40
 
37
- const radioValue = computed(() => {
38
- return val.value === props.checkedValue
39
- ? 'checked'
40
- : 'unchecked';
41
- });
41
+ const radioEl = ref<HTMLDivElement | null>(null);
42
+
43
+ const {
44
+ groupValue,
45
+ updateGroupValue,
46
+ }: {
47
+ groupValue: Nullable<Ref<Ui3nRadioValue>>;
48
+ updateGroupValue: Nullable<(value: Ui3nRadioValue) => void>;
49
+ } = groupName
50
+ ? inject(`radio-group-${groupName}`)!
51
+ : {
52
+ groupValue: null,
53
+ updateGroupValue: null,
54
+ };
55
+
56
+ const val = ref<Ui3nRadioValue>(groupName ? groupValue!.value : props.modelValue);
57
+
58
+ const isOn = computed(() => val.value === props.checkedValue);
59
+
60
+ function change() {
61
+ val.value = isOn.value ? props.uncheckedValue : props.checkedValue;
62
+
63
+ if (groupName) {
64
+ isOn.value && updateGroupValue!(val.value);
65
+ } else {
66
+ emits('change', val.value);
67
+ emits('update:modelValue', val.value);
68
+ }
69
+ };
42
70
 
43
71
  onBeforeMount(() => {
44
72
  if (
@@ -47,24 +75,6 @@ onBeforeMount(() => {
47
75
  ) {
48
76
  throw Error('[Ui3nRadio] Both checkedIcon and uncheckedIcon slots must have values ​​defined.');
49
77
  }
50
-
51
- if (instance?.parent?.type.__name !== 'ui3n-radio-group') {
52
- const checkedValueType = typeof props.checkedValue;
53
- const uncheckedValueType = typeof props.uncheckedValue;
54
- const valueType = typeof props.modelValue;
55
- if (
56
- checkedValueType !== uncheckedValueType
57
- || checkedValueType !== valueType
58
- || uncheckedValueType !== valueType
59
- ) {
60
- throw Error('[Ui3nRadio] types of "value", "checkedValue" and "uncheckedValue" are different');
61
- }
62
- } else {
63
- const groupModelValue = instance?.parent.props.modelValue;
64
- if (groupModelValue === props.checkedValue) {
65
- val.value = groupModelValue as Ui3nRadioValue;
66
- }
67
- }
68
78
  });
69
79
 
70
80
  onMounted(() => {
@@ -76,8 +86,11 @@ onMounted(() => {
76
86
 
77
87
  watch(
78
88
  () => props.modelValue,
79
- newValue => val.value = newValue,
80
- { immediate: true },
89
+ newValue => {
90
+ if (newValue !== val.value) {
91
+ val.value = newValue;
92
+ }
93
+ },
81
94
  );
82
95
 
83
96
  watch(
@@ -98,17 +111,14 @@ watch(
98
111
  },
99
112
  );
100
113
 
101
-
102
- function change() {
103
- val.value = radioValue.value !== 'unchecked'
104
- ? props.uncheckedValue
105
- : props.checkedValue;
106
-
107
- emits('change', val.value);
108
- emits('update:modelValue', val.value);
109
- };
110
-
111
- defineExpose({ change, radioEl });
114
+ watch(
115
+ () => groupValue?.value,
116
+ newVal => {
117
+ if (groupName) {
118
+ val.value = newVal === props.checkedValue ? props.checkedValue : props.uncheckedValue;
119
+ }
120
+ },
121
+ );
112
122
  </script>
113
123
 
114
124
  <template>
@@ -121,19 +131,19 @@ defineExpose({ change, radioEl });
121
131
  ]"
122
132
  >
123
133
  <div
124
- :class="$style.body"
134
+ :class="[$style.body, disabled && $style.bodyDisabled]"
125
135
  @click="change"
126
136
  >
127
137
  <slot
128
- v-if="radioValue === 'checked'
129
- "name="checkedIcon"
138
+ v-if="isOn"
139
+ name="checkedIcon"
130
140
  >
131
141
  <svg
132
142
  xmlns="http://www.w3.org/2000/svg"
133
143
  :width="Number(size) - 4"
134
144
  :height="Number(size) - 4"
135
145
  viewBox="0 0 24 24"
136
- :class="$style.icon"
146
+ :class="[$style.icon, disabled && $style.iconDisabled]"
137
147
  >
138
148
  <path
139
149
  fill="currentColor"
@@ -151,7 +161,7 @@ defineExpose({ change, radioEl });
151
161
  :width="Number(size) - 4"
152
162
  :height="Number(size) - 4"
153
163
  viewBox="0 0 24 24"
154
- :class="$style.icon"
164
+ :class="[$style.icon, disabled && $style.iconDisabled]"
155
165
  >
156
166
  <path
157
167
  fill="currentColor"
@@ -227,7 +237,15 @@ defineExpose({ change, radioEl });
227
237
  .icon {
228
238
  color: var(--ui3n-radio-color);
229
239
  min-height: calc(var(--ui3n-radion-size) - 2px);
240
+ height: calc(var(--ui3n-radion-size) - 2px);
230
241
  min-width: calc(var(--ui3n-checkbox-size) - 2px);
242
+ width: calc(var(--ui3n-radion-size) - 2px);
231
243
  cursor: pointer;
232
244
  }
245
+
246
+ .bodyDisabled,
247
+ .iconDisabled {
248
+ filter: grayscale(1);
249
+ opacity: 0.5;
250
+ }
233
251
  </style>