@v1nt1248/3nclient-lib 0.1.22 → 0.1.24

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.
@@ -202,7 +202,7 @@
202
202
  --warning-content-disabled: var(--orange-30);
203
203
  --warning-outline-default: var(--orange-5);
204
204
  --warning-outline-hover: var(--orange-10);
205
- --warning-outline-focused: var(--orange-50);
205
+ --warning-outline-focused: var(--orange-70);
206
206
  --warning-outline-pressed: var(--orange-10);
207
207
  --warning-outline-disabled: var(--orange-5);
208
208
  --success-fill-default: var(--emerald-5);
@@ -217,7 +217,7 @@
217
217
  --success-content-disabled: var(--emerald-30);
218
218
  --success-outline-default: var(--emerald-5);
219
219
  --success-outline-hover: var(--emerald-10);
220
- --success-outline-focused: var(--emerald-50);
220
+ --success-outline-focused: var(--emerald-70);
221
221
  --success-outline-pressed: var(--emerald-10);
222
222
  --success-outline-disabled: var(--emerald-5);
223
223
  --error-fill-default: var(--red-5);
@@ -232,7 +232,7 @@
232
232
  --error-content-disabled: var(--red-30);
233
233
  --error-outline-default: var(--red-5);
234
234
  --error-outline-hover: var(--red-10);
235
- --error-outline-focused: var(--red-50);
235
+ --error-outline-focused: var(--red-70);
236
236
  --error-outline-pressed: var(--red-10);
237
237
  --error-outline-disabled: var(--red-5);
238
238
  --info-fill-default: var(--blue-5);
@@ -346,7 +346,7 @@
346
346
  --warning-content-disabled: var(--orange-30);
347
347
  --warning-outline-default: var(--orange-5);
348
348
  --warning-outline-hover: var(--orange-10);
349
- --warning-outline-focused: var(--orange-50);
349
+ --warning-outline-focused: var(--orange-70);
350
350
  --warning-outline-pressed: var(--orange-10);
351
351
  --warning-outline-disabled: var(--orange-5);
352
352
  --success-fill-default: var(--emerald-5);
@@ -361,7 +361,7 @@
361
361
  --success-content-disabled: var(--emerald-30);
362
362
  --success-outline-default: var(--emerald-5);
363
363
  --success-outline-hover: var(--emerald-10);
364
- --success-outline-focused: var(--emerald-50);
364
+ --success-outline-focused: var(--emerald-70);
365
365
  --success-outline-pressed: var(--emerald-10);
366
366
  --success-outline-disabled: var(--emerald-5);
367
367
  --error-fill-default: var(--red-5);
@@ -376,7 +376,7 @@
376
376
  --error-content-disabled: var(--red-30);
377
377
  --error-outline-default: var(--red-5);
378
378
  --error-outline-hover: var(--red-10);
379
- --error-outline-focused: var(--red-50);
379
+ --error-outline-focused: var(--red-70);
380
380
  --error-outline-pressed: var(--red-10);
381
381
  --error-outline-disabled: var(--red-5);
382
382
  --info-fill-default: var(--blue-5);
@@ -568,6 +568,9 @@
568
568
  --color-text-chat-bubble-other-sub: var(--default-hint-default);
569
569
  --color-text-chat-bubble-other-sub-selected: var(--accent-content-default);
570
570
  --color-text-chat-bubble-other-sub-quote: var(--default-hint-default);
571
+ --color-border-button-primary-focused: var(--accent-outline-focused);
572
+ --color-border-button-secondary-focused: var(--s-accent-outline-focused);
573
+ --color-border-button-tritery-focused: var(--s-default-outline-focused);
571
574
  --color-border-block-primary-default: var(--default-outline-default);
572
575
  --color-border-block-primary-hover: var(--default-outline-hover);
573
576
  --color-border-block-primary-focused: var(--default-outline-focused);
@@ -744,3 +747,21 @@ div {
744
747
  .fade-leave-active {
745
748
  opacity: 0;
746
749
  }
750
+
751
+ @keyframes ripple {
752
+ to {
753
+ transform: scale(4);
754
+ opacity: 0;
755
+ }
756
+ }
757
+
758
+ .ui3n-ripple {
759
+ --ui3n-ripple-duration: 400ms;
760
+ --ui3n-ripple-bg-color: rgba(255, 255, 255, 0.7);
761
+
762
+ position: absolute;
763
+ border-radius: 50%;
764
+ transform: scale(0);
765
+ animation: ripple var(--ui3n-ripple-duration) linear;
766
+ background-color: var(--ui3n-ripple-bg-color);
767
+ }
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.22",
5
+ "version": "0.1.24",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -15,6 +15,9 @@ export interface Ui3nButtonProps {
15
15
  export interface Ui3nButtonEmits {
16
16
  (ev: 'init', value: HTMLButtonElement): void;
17
17
  (ev: 'click', value: Event): void;
18
+ (ev: 'enter', value: HTMLButtonElement): void;
18
19
  (ev: 'focus', value: Event): void;
19
20
  (ev: 'blur', value: Event): void;
20
21
  }
22
+
23
+ export type Ui3nButtonEventName = 'init' | 'click' | 'enter' | 'focus' | 'blur';
@@ -1,7 +1,10 @@
1
1
  <script lang="ts" setup>
2
2
  import { onMounted, ref, watch } from 'vue';
3
3
  import Ui3nIcon from '../ui3n-icon/ui3n-icon.vue';
4
- import type { Ui3nButtonEmits, Ui3nButtonProps } from './types';
4
+ import Ui3nRipple from '../..//directives/ui3n-ripple';
5
+ import type { Ui3nButtonEmits, Ui3nButtonProps, Ui3nButtonEventName } from './types';
6
+
7
+ const vUi3nRipple = Ui3nRipple;
5
8
 
6
9
  const props = withDefaults(
7
10
  defineProps<Ui3nButtonProps>(),
@@ -16,6 +19,16 @@ const emits = defineEmits<Ui3nButtonEmits>();
16
19
 
17
20
  const buttonEl = ref<HTMLButtonElement | null>(null);
18
21
 
22
+ async function handleButtonEvent(eventName: Ui3nButtonEventName, value?: Event ) {
23
+ if (['init', 'enter'].includes(eventName)) {
24
+ // @ts-ignore
25
+ emits(eventName, buttonEl.value);
26
+ } else {
27
+ // @ts-ignore
28
+ emits(eventName, value!);
29
+ }
30
+ }
31
+
19
32
  watch(
20
33
  [() => props.color, () => props.textColor],
21
34
  (newValue: [string | undefined, string | undefined], prevValue: [string | undefined, string | undefined]) => {
@@ -41,26 +54,28 @@ onMounted(() => {
41
54
 
42
55
  props.type === 'custom' && props.textColor && buttonEl.value.style.setProperty('--ui3n-button-text-color-custom', props.textColor);
43
56
 
44
- emits('init', buttonEl.value);
57
+ handleButtonEvent('init');
45
58
  });
46
59
  </script>
47
60
 
48
61
  <template>
49
62
  <button
50
63
  ref="buttonEl"
64
+ v-ui3n-ripple
51
65
  :class="[
52
66
  $style.button,
53
- $style[size],
54
- $style[type],
67
+ $style[size!],
68
+ $style[type!],
55
69
  block && type !== 'icon' && $style.block,
56
70
  icon && $style[`withIcon-${iconPosition}`],
57
71
  elevation && $style.elevation,
58
72
  ]"
59
73
  type="button"
60
74
  :disabled="disabled"
61
- @click="emits('click', $event)"
62
- @focusin="emits('focus', $event)"
63
- @focusout="emits('blur', $event)"
75
+ @click="handleButtonEvent('click', $event)"
76
+ @focusin="handleButtonEvent('focus', $event)"
77
+ @focusout="handleButtonEvent('blur', $event)"
78
+ @keydown.enter="handleButtonEvent('enter')"
64
79
  >
65
80
  <ui3n-icon
66
81
  v-if="icon"
@@ -86,6 +101,8 @@ onMounted(() => {
86
101
  --ui3n-button-text-color-custom: var(--color-text-button-primary-default);
87
102
  --ui3n-button-bg-color-custom: var(--color-bg-button-primary-default);
88
103
 
104
+ position: relative;
105
+ width: max-content;
89
106
  display: flex;
90
107
  justify-content: center;
91
108
  align-items: center;
@@ -97,6 +114,11 @@ onMounted(() => {
97
114
  font-weight: 600;
98
115
  line-height: calc(var(--ui3n-button-text-size) * 1.25);
99
116
  user-select: none;
117
+ overflow: hidden;
118
+
119
+ &:not([disabled]) {
120
+ cursor: pointer;
121
+ }
100
122
  }
101
123
 
102
124
  .regular {
@@ -136,7 +158,10 @@ onMounted(() => {
136
158
  &:hover {
137
159
  background: var(--color-bg-button-primary-hover);
138
160
  color: var(--color-text-button-primary-hover);
139
- @include ripple(var(--color-bg-button-primary-hover));
161
+ }
162
+
163
+ &:focus {
164
+ outline: 1px solid var(--color-border-button-primary-focused);
140
165
  }
141
166
 
142
167
  &[disabled] {
@@ -153,7 +178,10 @@ onMounted(() => {
153
178
  &:hover {
154
179
  background: var(--color-bg-button-secondary-hover);
155
180
  color: var(--color-text-button-secondary-hover);
156
- @include ripple(var(--color-bg-button-secondary-hover));
181
+ }
182
+
183
+ &:focus {
184
+ outline: 1px solid var(--color-border-button-secondary-focused);
157
185
  }
158
186
 
159
187
  &[disabled] {
@@ -175,6 +203,10 @@ onMounted(() => {
175
203
  cursor: pointer;
176
204
  }
177
205
 
206
+ &:focus {
207
+ outline: 1px solid var(--color-border-button-secondary-focused);
208
+ }
209
+
178
210
  &[disabled] {
179
211
  background: transparent;
180
212
  color: var(--color-text-button-secondary-disabled);
@@ -203,7 +235,10 @@ onMounted(() => {
203
235
 
204
236
  &:hover {
205
237
  background: var(--ui3n-button-icon-bg-color);
206
- @include ripple(var(--ui3n-button-icon-bg-color));
238
+ }
239
+
240
+ &:focus {
241
+ outline: 1px solid hsl(from var(--ui3n-button-icon-bg-color) h s calc(l - 10));
207
242
  }
208
243
 
209
244
  &[disabled] {
@@ -220,7 +255,10 @@ onMounted(() => {
220
255
 
221
256
  &:hover {
222
257
  background: var(--ui3n-button-custom-bg-color);
223
- @include ripple(var(--ui3n-button-custom-bg-color));
258
+ }
259
+
260
+ &:focus {
261
+ outline: 1px solid hsl(from var(--ui3n-button-custom-bg-color) h s calc(l - 10));
224
262
  }
225
263
 
226
264
  &[disabled] {
@@ -15,12 +15,20 @@ export interface Ui3nInputProps {
15
15
  }
16
16
 
17
17
  export interface Ui3nInputEmits {
18
- (ev: 'init', value: HTMLInputElement): void;
19
- (ev: 'input', value: string): void;
20
- (ev: 'focus', value: Event): void;
21
- (ev: 'blur', value: Event): void;
22
- (ev: 'clear'): void;
23
- (ev: 'change', value: string): void;
24
- (ev: 'update:modelValue', value: string): void;
25
- (ev: 'update:valid', value: boolean): void;
18
+ (event: 'init', value: HTMLInputElement): void;
19
+ (event: 'input', value: string): void;
20
+ (event: 'focus', value: Event): void;
21
+ (event: 'blur', value: Event): void;
22
+ (event: 'clear'): void;
23
+ (event: 'change', value: string): void;
24
+ (event: 'enter', value: {
25
+ value: string;
26
+ altKey: boolean;
27
+ ctrlKey: boolean;
28
+ shiftKey: boolean;
29
+ metaKey: boolean;
30
+ }): void;
31
+ (event: 'escape', value: Event): void;
32
+ (event: 'update:modelValue', value: string): void;
33
+ (event: 'update:valid', value: boolean): void;
26
34
  }
@@ -77,6 +77,21 @@ function onInput(ev: Event) {
77
77
  emits('input', value);
78
78
  }
79
79
 
80
+ function onEnterKeydown(event: KeyboardEvent) {
81
+ const { altKey, ctrlKey, metaKey, shiftKey, target } = event;
82
+ const value = (target as HTMLInputElement).value;
83
+ validate(value);
84
+ emits('update:modelValue', value);
85
+ emits('enter', { value , altKey, ctrlKey, metaKey, shiftKey });
86
+ }
87
+
88
+ function onEscapeKeydown(event: KeyboardEvent) {
89
+ const value = (event.target as HTMLInputElement).value;
90
+ validate(value);
91
+ emits('update:modelValue', value);
92
+ emits('escape', event);
93
+ }
94
+
80
95
  function clearValue() {
81
96
  text.value = '';
82
97
  validate('');
@@ -127,6 +142,8 @@ function validate(text: string) {
127
142
  :disabled="disabled"
128
143
  :class="$style.field"
129
144
  @input="onInput"
145
+ @keydown.enter="onEnterKeydown"
146
+ @keydown.escape="onEscapeKeydown"
130
147
  @focusin="onFocus"
131
148
  @focusout="onBlur"
132
149
  @change="onChange"
@@ -9,10 +9,19 @@ export interface Ui3nTextProps {
9
9
  }
10
10
 
11
11
  export interface Ui3nTextEmits {
12
- (ev: 'init', value: HTMLTextAreaElement): void;
13
- (ev: 'input', value: string): void;
14
- (ev: 'focus', value: Event): void;
15
- (ev: 'blur', value: Event): void;
16
- (ev: 'update:text', value: string): void;
17
- (ev: 'update:valid', value: boolean): void;
12
+ (event: 'init', value: HTMLTextAreaElement): void;
13
+ (event: 'input', value: string): void;
14
+ (event: 'change', value: string): void;
15
+ (event: 'enter', value: {
16
+ value: string;
17
+ altKey: boolean;
18
+ ctrlKey: boolean;
19
+ shiftKey: boolean;
20
+ metaKey: boolean;
21
+ }): void;
22
+ (event: 'escape', value: Event): void;
23
+ (event: 'focus', value: Event): void;
24
+ (event: 'blur', value: Event): void;
25
+ (event: 'update:text', value: string): void;
26
+ (event: 'update:valid', value: boolean): void;
18
27
  }
@@ -40,7 +40,7 @@ watch(
40
40
  { immediate: true },
41
41
  );
42
42
 
43
- const validate = (text: string) => {
43
+ function validate(text: string) {
44
44
  errorMessage.value = '';
45
45
  if (props.rules && props.rules.length) {
46
46
  for (const validateFunction of props.rules) {
@@ -52,24 +52,45 @@ const validate = (text: string) => {
52
52
  }
53
53
  }
54
54
  }
55
- };
55
+ }
56
56
 
57
- const onFocus = (event: Event) => {
57
+ function onFocus(event: Event) {
58
58
  isFocused.value = true;
59
59
  emit('focus', event);
60
- };
60
+ }
61
61
 
62
- const onBlur = (event: Event) => {
62
+ function onBlur(event: Event) {
63
63
  isFocused.value = false;
64
+ const value = (event.target as HTMLInputElement).value;
65
+ validate(value);
64
66
  emit('blur', event);
65
- };
67
+ emit('change', value);
68
+ emit('update:text', value);
69
+ }
66
70
 
67
- const onInput = (ev: Event) => {
68
- const value = (ev.target as HTMLInputElement).value;
71
+ function onInput(event: Event) {
72
+ console.log('onInput!');
73
+ const value = (event.target as HTMLInputElement).value;
69
74
  validate(value);
70
75
  emit('update:text', value);
71
76
  emit('input', value);
72
- };
77
+ }
78
+
79
+ function onEnterKeydown(event: KeyboardEvent) {
80
+ console.log('onEnterKeydown: ', event);
81
+ const { altKey, ctrlKey, shiftKey, metaKey, target } = event;
82
+ const value = (target as HTMLInputElement).value;
83
+ validate(value);
84
+ emit('update:text', value);
85
+ emit('enter', { value , altKey, ctrlKey, shiftKey, metaKey });
86
+ }
87
+
88
+ function onEscapeKeydown(event: KeyboardEvent) {
89
+ const value = (event.target as HTMLInputElement).value;
90
+ validate(value);
91
+ emit('update:text', value);
92
+ emit('escape', event);
93
+ }
73
94
  </script>
74
95
 
75
96
  <template>
@@ -89,6 +110,8 @@ const onInput = (ev: Event) => {
89
110
  :disabled="disabled"
90
111
  v-bind="$attrs"
91
112
  @input="onInput"
113
+ @keydown.enter="onEnterKeydown"
114
+ @keydown.escape="onEscapeKeydown"
92
115
  @focusin="onFocus"
93
116
  @focusout="onBlur"
94
117
  />