@v1nt1248/3nclient-lib 0.0.6 → 0.0.8

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.
Files changed (35) hide show
  1. package/dist/components/index.d.ts +5 -0
  2. package/dist/components/ui3n-icon.vue.d.ts +16 -0
  3. package/dist/constants/index.d.ts +3 -0
  4. package/dist/constants/types.d.ts +31 -0
  5. package/dist/directives/index.d.ts +1 -0
  6. package/dist/index.d.ts +5 -18
  7. package/dist/plugins/index.d.ts +10 -0
  8. package/dist/plugins/notifications.d.ts +4 -0
  9. package/dist/plugins/store-vue-bus.d.ts +2 -9
  10. package/dist/plugins/vue-bus.d.ts +8 -4
  11. package/dist/style.css +1 -1
  12. package/dist/tools/index.d.ts +3 -0
  13. package/dist/types.d.ts +20 -60
  14. package/dist/ui-3n-lib.js +10676 -11045
  15. package/package.json +11 -10
  16. package/src/components/index.ts +13 -0
  17. package/src/components/ui3n-button.vue +156 -0
  18. package/src/components/ui3n-drop-files.vue +171 -0
  19. package/src/components/ui3n-emoji.vue +64 -0
  20. package/src/components/ui3n-icon.vue +51 -0
  21. package/src/components/ui3n-input.vue +282 -0
  22. package/src/components/ui3n-notification.vue +144 -0
  23. package/src/components/ui3n-table-sort-icon.vue +23 -0
  24. package/src/components/ui3n-table.vue +318 -0
  25. package/src/components/ui3n-text.vue +181 -0
  26. package/dist/components/ui3n-drop-files.vue.d.ts +0 -33
  27. package/dist/components/ui3n-emoji.vue.d.ts +0 -28
  28. package/dist/components/ui3n-input.vue.d.ts +0 -96
  29. package/dist/components/ui3n-table-sort-icon.vue.d.ts +0 -24
  30. package/dist/components/ui3n-table.vue.d.ts +0 -30
  31. package/dist/components/ui3n-text.vue.d.ts +0 -62
  32. package/dist/ui-3n-lib.umd.cjs +0 -72
  33. /package/dist/{helpers → tools}/common.helpers.d.ts +0 -0
  34. /package/dist/{helpers → tools}/textarea-max-rows.d.ts +0 -0
  35. /package/dist/{helpers → tools}/ui.helpers.d.ts +0 -0
@@ -0,0 +1,282 @@
1
+ <script lang="ts" setup>
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { computed, onMounted, ref, watch } from 'vue'
4
+ import Ui3nIcon from './ui3n-icon.vue'
5
+ import Ui3nButton from './ui3n-button.vue'
6
+
7
+ export interface Ui3nInputProps {
8
+ value: string;
9
+ label?: string;
10
+ placeholder?: string;
11
+ clearable?: boolean;
12
+ autofocus?: boolean;
13
+ rules?: Array<(v: string) => any>;
14
+ disabled?: boolean;
15
+ icon?: string;
16
+ iconColor?: string;
17
+ }
18
+
19
+ export interface Ui3nInputEmits {
20
+ (ev: 'input', value: string): void;
21
+ (ev: 'focus', value: Event): void;
22
+ (ev: 'blur', value: Event): void;
23
+ (ev: 'clear', value: string): void;
24
+ (ev: 'change', value: string): void;
25
+ (ev: 'update:value', value: string): void;
26
+ (ev: 'update:valid', value: boolean): void;
27
+ }
28
+
29
+ const props = defineProps<Ui3nInputProps>()
30
+ const emit = defineEmits<Ui3nInputEmits>()
31
+
32
+ const inputElement = ref<HTMLInputElement|null>(null)
33
+ const text = ref<string>('')
34
+ const isFocused = ref(false)
35
+ const errorMessage = ref('')
36
+
37
+ const isValid = computed(() => {
38
+ if (!text.value) {
39
+ return true
40
+ }
41
+
42
+ return !errorMessage.value
43
+ })
44
+
45
+ onMounted(() => {
46
+ if (props.autofocus && inputElement.value) {
47
+ inputElement.value.focus()
48
+ }
49
+ })
50
+
51
+ watch(
52
+ () => props.value,
53
+ val => text.value = val,
54
+ { immediate: true },
55
+ )
56
+
57
+ watch(
58
+ () => isValid.value,
59
+ val => emit('update:valid', val),
60
+ { immediate: true },
61
+ )
62
+
63
+ const onFocus = (event: Event) => {
64
+ isFocused.value = true
65
+ emit('focus', event)
66
+ }
67
+
68
+ const onBlur = (event: Event) => {
69
+ isFocused.value = false
70
+ emit('blur', event)
71
+ }
72
+
73
+ const onChange = (event: Event) => {
74
+ const value = (event.target as HTMLInputElement).value
75
+ validate(value)
76
+ emit('update:value', value)
77
+ emit('change', value)
78
+ }
79
+
80
+ const onInput = (ev: Event) => {
81
+ const value = (ev.target as HTMLInputElement).value
82
+ text.value = value
83
+ validate(value)
84
+ emit('update:value', value)
85
+ emit('input', value)
86
+ }
87
+
88
+ const clearValue = () => {
89
+ text.value = ''
90
+ validate('')
91
+ emit('update:value', '')
92
+ emit('input', '')
93
+ emit('change', '')
94
+ }
95
+
96
+ const validate = (text: string) => {
97
+ errorMessage.value = ''
98
+ if (props.rules && props.rules.length) {
99
+ for (const validateFunction of props.rules) {
100
+ if (typeof validateFunction === 'function') {
101
+ const res = validateFunction(text)
102
+ if (typeof res === 'string') {
103
+ errorMessage.value += res
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ </script>
110
+
111
+ <template>
112
+ <div
113
+ ref="wrapperElement"
114
+ :class="[
115
+ 'ui3n-input',
116
+ {
117
+ 'ui3n-input--with-label': props.label,
118
+ 'ui3n-input--with-icon': props.icon,
119
+ 'ui3n-input--clearable': props.clearable && !!text,
120
+ 'ui3n-input--disabled': props.disabled,
121
+ 'ui3n-input--error': !!errorMessage,
122
+ },
123
+ ]"
124
+ >
125
+ <label
126
+ v-if="props.label"
127
+ class="ui3n-input__label"
128
+ >
129
+ {{ props.label }}
130
+ </label>
131
+
132
+ <input
133
+ ref="inputElement"
134
+ :value="text"
135
+ :placeholder="props.placeholder"
136
+ :disabled="props.disabled"
137
+ class="ui3n-input__input"
138
+ @input="onInput"
139
+ @focusin="onFocus"
140
+ @focusout="onBlur"
141
+ @change="onChange"
142
+ >
143
+
144
+ <ui3n-icon
145
+ v-if="props.icon"
146
+ :icon="props.icon"
147
+ :width="16"
148
+ :height="16"
149
+ :color="props.iconColor || 'var(--black-30, #b3b3b3)'"
150
+ class="ui3n-input__icon"
151
+ />
152
+
153
+ <ui3n-button
154
+ v-if="props.clearable && !!text"
155
+ round
156
+ color="transparent"
157
+ icon="close"
158
+ icon-size="16"
159
+ icon-color="var(----black-30, #b3b3b3)"
160
+ class="ui3n-input__clear-btn"
161
+ @click="clearValue"
162
+ />
163
+
164
+ <div
165
+ v-if="errorMessage"
166
+ class="ui3n-input__error-text"
167
+ >
168
+ {{ errorMessage }}
169
+ </div>
170
+ </div>
171
+ </template>
172
+
173
+ <style lang="scss" scoped>
174
+ @import "../assets/styles/mixins";
175
+
176
+ .ui3n-input {
177
+ --ui3n-input-height: calc(var(--base-size, 8px) * 4);
178
+ --ui3n-input-padding-left: var(--base-size, 8px);
179
+ --ui3n-input-padding-right: var(--base-size, 8px);
180
+
181
+ position: relative;
182
+ width: 100%;
183
+
184
+ &__label {
185
+ display: block;
186
+ width: 100%;
187
+ font-size: var(--font-12, 12px);
188
+ font-weight: 600;
189
+ color: var(--black-90, #212121);
190
+ margin-bottom: calc(var(--base-size, 8px) / 2);
191
+ }
192
+
193
+ &__input {
194
+ display: block;
195
+ box-sizing: border-box;
196
+ width: 100%;
197
+ position: relative;
198
+ border: none;
199
+ outline: none;
200
+ height: var(--ui3n-input-height);
201
+ padding: 0 var(--ui3n-input-padding-right) 0 var(--ui3n-input-padding-left);
202
+ border-radius: var(--half-size, 4px);
203
+ background-color: var(--gray-50, #f2f2f2);
204
+ font-size: var(--font-13, 13px);
205
+ font-weight: 400;
206
+ line-height: 1;
207
+ color: var(--black-90, #212121);
208
+
209
+ &::placeholder {
210
+ color: var(--black-30, #b3b3b3);
211
+ font-style: italic;
212
+ font-size: var(--font-13, 13px);
213
+ font-weight: 400;
214
+ }
215
+
216
+ &:focus-within {
217
+ background-color: var(--blue-main-20, #d8edfd);
218
+ }
219
+ }
220
+
221
+ &__icon {
222
+ position: absolute;
223
+ left: var(--half-size, 4px);
224
+ top: var(--base-size, 8px);
225
+ }
226
+
227
+ &__clear-btn {
228
+ position: absolute;
229
+ right: 0;
230
+ top: var(--half-size, 4px);
231
+ }
232
+
233
+ &__error-text {
234
+ font-style: italic;
235
+ font-size: var(--font-10, 10px);
236
+ font-weight: 400;
237
+ line-height: 1.5;
238
+ color: var(--pear-100, #f75d53);
239
+ }
240
+
241
+ &--clearable {
242
+ --ui3n-input-padding-right: calc(var(--base-size, 8px) * 3);
243
+ }
244
+
245
+ &--with-icon {
246
+ --ui3n-input-padding-left: calc(var(--base-size, 8px) * 3);
247
+ }
248
+
249
+ &--error {
250
+ --ui3n-input-padding-left: calc(var(--base-size, 8px) - 1px);
251
+ --ui3n-input-padding-right: calc(var(--base-size, 8px) - 1px);
252
+
253
+ .ui3n-input__input {
254
+ border: 1px solid var(--pear-100, #f75d53)
255
+ }
256
+
257
+ &.ui3n-input--clearable {
258
+ --ui3n-input-padding-right: calc(var(--base-size, 8px) * 2 - 1px);
259
+ }
260
+
261
+ &.ui3n-input--with-icon {
262
+ --ui3n-input-padding-left: calc(var(--base-size, 8px) * 2 - 1px);
263
+ }
264
+ }
265
+
266
+ &--disabled {
267
+ pointer-events: none;
268
+ user-select: none;
269
+ opacity: 0.5;
270
+ }
271
+
272
+ &--with-label {
273
+ .ui3n-input__icon {
274
+ top: calc(var(--base-size) * 3.5 + 1px);
275
+ }
276
+
277
+ .ui3n-input__clear-btn {
278
+ top: calc(var(--base-size) * 3 + 1px);
279
+ }
280
+ }
281
+ }
282
+ </style>
@@ -0,0 +1,144 @@
1
+ ui<script lang="ts" setup>
2
+ import { computed } from 'vue'
3
+ import Ui3nIcon from './ui3n-icon.vue'
4
+ import Ui3nButton from './ui3n-button.vue'
5
+
6
+ const props = defineProps<{
7
+ id?: string;
8
+ type?: 'success' | 'warning' | 'info' | 'error';
9
+ content: string;
10
+ icon?: string;
11
+ iconSize?: string | number;
12
+ iconColor?: string;
13
+ position?: 'left' | 'center' | 'right';
14
+ duration?: number;
15
+ teleport?: string;
16
+ onOpen?: () => void;
17
+ onClose?: () => void;
18
+ }>()
19
+ const params = computed(() => {
20
+ const {
21
+ id,
22
+ type = 'info',
23
+ content,
24
+ icon,
25
+ iconSize = '16',
26
+ iconColor = 'var(--black-30, #b3b3b3)',
27
+ position = 'center',
28
+ duration = 0,
29
+ onOpen = () => void(0),
30
+ onClose = () => void(0),
31
+ } = props
32
+ return { id, type, content, icon, iconSize, iconColor, position, duration, onOpen, onClose }
33
+ })
34
+
35
+ const closeNotification = () => {
36
+ params.value.onClose()
37
+ }
38
+ </script>
39
+
40
+ <template>
41
+ <div
42
+ :id="params.id"
43
+ :class="[
44
+ 'ui3n-notification',
45
+ `ui3n-notification--${params.type}`,
46
+ `ui3n-notification--${params.position}`,
47
+ {
48
+ 'ui3n-notification--with-icon': params.icon,
49
+ },
50
+ ]"
51
+ >
52
+ <ui3n-icon
53
+ v-if="params.icon"
54
+ :icon="params.icon"
55
+ :width="params.iconSize"
56
+ :height="params.iconSize"
57
+ :color="params.iconColor"
58
+ />
59
+
60
+ <div class="ui3n-notification__content">
61
+ {{ params.content }}
62
+ </div>
63
+
64
+ <ui3n-button
65
+ v-if="!props.duration"
66
+ round
67
+ color="transparent"
68
+ icon="close"
69
+ icon-size="12"
70
+ icon-color="var(--system-white, #fff)"
71
+ class="ui3n-notification__close"
72
+ @click="closeNotification"
73
+ />
74
+ </div>
75
+ </template>
76
+
77
+ <style lang="scss" scoped>
78
+ .ui3n-notification {
79
+ display: flex;
80
+ position: relative;
81
+ z-index: 5000;
82
+ border-radius: var(--half-size, 4px);
83
+ padding: var(--base-size, 8px);
84
+ max-width: 400px;
85
+ margin-bottom: var(--base-size);
86
+
87
+ &--with-icon {
88
+ display: flex;
89
+ justify-content: flex-start;
90
+ align-items: center;
91
+
92
+ .ui3n-notification__content {
93
+ padding-left: var(--base-size, 8px);
94
+ }
95
+ }
96
+
97
+ &__content {
98
+ position: relative;
99
+ flex-grow: 2;
100
+ font-size: var(--font-13, 13px);
101
+ font-weight: 400;
102
+ line-height: 1.5;
103
+ color: var(--system-white, #fff);
104
+ }
105
+
106
+ &__close {
107
+ position: absolute;
108
+ z-index: 1;
109
+ top: 0;
110
+ right: 0;
111
+ }
112
+
113
+ &--success {
114
+ background-color: rgb(16, 196, 143);
115
+ }
116
+
117
+ &--warning {
118
+ background-color: rgb(255, 136,0);
119
+ }
120
+
121
+ &--info {
122
+ background-color: rgb(16, 175, 239);
123
+ }
124
+
125
+ &--error {
126
+ background-color: rgb(239, 83, 80);
127
+ }
128
+
129
+ &--left {
130
+ margin-left: 0;
131
+ margin-right: auto;
132
+ }
133
+
134
+ &--center {
135
+ margin-left: auto;
136
+ margin-right: auto;
137
+ }
138
+
139
+ &--right {
140
+ margin-left: auto;
141
+ margin-right: 0;
142
+ }
143
+ }
144
+ </style>
@@ -0,0 +1,23 @@
1
+ <script lang="ts" setup>
2
+ import { computed } from 'vue'
3
+ import Ui3nIcon from './ui3n-icon.vue'
4
+
5
+ const props = defineProps<{
6
+ size?: string | number;
7
+ color?: string;
8
+ value: 'asc' | 'desc';
9
+ }>()
10
+
11
+ const iconSize = computed(() => props.size ? +props.size : 16)
12
+ const iconColor = computed(() => props.color || 'var(--black-90, #212121)')
13
+ </script>
14
+
15
+ <template>
16
+ <ui3n-icon
17
+ :icon="props.value === 'asc' ? 'arrow-downward' : 'arrow-upward'"
18
+ :width="iconSize"
19
+ :height="iconSize"
20
+ :color="iconColor"
21
+ class="ui3n-table-sort-icon"
22
+ />
23
+ </template>