@v1nt1248/3nclient-lib 0.0.28 → 0.0.30

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.0.28",
5
+ "version": "0.0.30",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "private": false,
8
8
  "type": "module",
@@ -2,6 +2,8 @@ import Ui3nIcon from './ui3n-icon.vue'
2
2
  import type { Ui3nIconProps, Ui3nIconEmits } from './ui3n-icon.vue'
3
3
  import Ui3nButton from './ui3n-button.vue'
4
4
  import type { Ui3nButtonProps, Ui3nButtonEmits } from './ui3n-button.vue'
5
+ import Ui3nChip from './ui3n-chip.vue'
6
+ import type { Ui3nChipProps, Ui3nChipEmits, Ui3nChipSlots } from './ui3n-chip.vue'
5
7
  import Ui3nDropFiles from './ui3n-drop-files.vue'
6
8
  import type { Ui3nDropFilesProps, Ui3nDropFilesEmits } from './ui3n-drop-files.vue'
7
9
  import Ui3nEmoji from './ui3n-emoji.vue'
@@ -35,6 +37,10 @@ export {
35
37
  Ui3nButton,
36
38
  Ui3nButtonProps,
37
39
  Ui3nButtonEmits,
40
+ Ui3nChip,
41
+ Ui3nChipProps,
42
+ Ui3nChipEmits,
43
+ Ui3nChipSlots,
38
44
  Ui3nDropFiles,
39
45
  Ui3nDropFilesProps,
40
46
  Ui3nDropFilesEmits,
@@ -0,0 +1,155 @@
1
+ <script lang="ts" setup>
2
+ import { computed, useSlots } from 'vue'
3
+ import Ui3nButton from './ui3n-button.vue'
4
+
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
6
+ export interface Ui3nChipProps {
7
+ height?: number | string;
8
+ maxWidth?: number | string;
9
+ plain?: boolean;
10
+ round?: boolean;
11
+ closeable?: boolean;
12
+ color?: string;
13
+ textSize?: number | string;
14
+ textColor?: string;
15
+ }
16
+ export interface Ui3nChipEmits {
17
+ (ev: 'close'): void;
18
+ }
19
+ export interface Ui3nChipSlots {
20
+ left: (props: { size: number; color: string }) => any;
21
+ default: () => any;
22
+ }
23
+
24
+ const props = withDefaults(
25
+ defineProps<Ui3nChipProps>(),
26
+ {
27
+ height: 24,
28
+ maxWidth: 200,
29
+ plain: false,
30
+ round: true,
31
+ closeable: false,
32
+ color: '#f2f2f2',
33
+ textSize: 10,
34
+ textColor: '#212121',
35
+ },
36
+ )
37
+ const emits = defineEmits<Ui3nChipEmits>()
38
+ defineSlots<Ui3nChipSlots>()
39
+
40
+ const slots = useSlots()
41
+
42
+ const height = computed(() => `${props.height}px`)
43
+ const iconHeight = computed(() => props.height ? Number(props.height) - 2 : Number(props.height))
44
+ const padding = computed(() => `${Math.round(Number(props.height) / 3)}px`)
45
+ const maxWidth = computed(() => `${props.maxWidth}px`)
46
+ const bgColor = computed(() => props.color)
47
+ const textSize = computed(() => `${props.textSize}px`)
48
+ const textColor = computed(() => props.textColor)
49
+ const hasLeftSlot = computed(() => !!slots.left)
50
+ </script>
51
+
52
+ <template>
53
+ <div
54
+ :class="[
55
+ 'ui3n-chip',
56
+ {
57
+ 'ui3n-chip--round': props.round,
58
+ 'ui3n-chip--plain': props.plain,
59
+ 'ui3n-chip--closeble': props.closeable,
60
+ 'ui3n-chip--with-icon': hasLeftSlot,
61
+ },
62
+ ]"
63
+ >
64
+ <div class="ui3n-chip__icon">
65
+ <slot
66
+ name="left"
67
+ :size="iconHeight"
68
+ :color="props.textColor"
69
+ />
70
+ </div>
71
+
72
+ <div class="ui3n-chip__body">
73
+ <slot />
74
+ </div>
75
+
76
+ <ui3n-button
77
+ v-if="props.closeable"
78
+ class="ui3n-chip__close"
79
+ round
80
+ color="transparent"
81
+ icon="close"
82
+ icon-size="12"
83
+ icon-color="#212121"
84
+ @click="emits('close')"
85
+ />
86
+ </div>
87
+ </template>
88
+
89
+ <style lang="scss" scoped>
90
+ @import "../assets/styles/mixins";
91
+
92
+ .ui3n-chip {
93
+ position: relative;
94
+ display: flex;
95
+ height: v-bind('height');
96
+ padding: 0 v-bind('padding');
97
+ width: max-content;
98
+ max-width: v-bind('maxWidth');
99
+ background-color: v-bind('bgColor');
100
+ display: flex;
101
+ justify-content: flex-start;
102
+ align-items: center;
103
+
104
+ &__body {
105
+ font-size: v-bind('textSize');
106
+ line-height: 1;
107
+ font-weight: 400;
108
+ color: v-bind('textColor');
109
+ overflow: hidden;
110
+ white-space: nowrap;
111
+ text-overflow: ellipsis;
112
+ }
113
+
114
+ &__close {
115
+ margin-left: var(--half-size, 4px);
116
+ }
117
+
118
+ &--with-icon {
119
+ .ui3n-chip__icon {
120
+ margin-right: 5px;
121
+ }
122
+ }
123
+
124
+ &--round {
125
+ border-radius: calc(v-bind('height') / 2);
126
+ }
127
+
128
+ &--closeble {
129
+ min-width: 24px;
130
+ padding-right: 0;
131
+ }
132
+
133
+ &--plain {
134
+ border: 1px solid v-bind('textColor');
135
+ }
136
+
137
+ &.ui3n-chip--closable:not(.ui3n-chip--with-icon) {
138
+ .ui3n-chip__body {
139
+ max-width: calc(100% - 24px);
140
+ }
141
+ }
142
+
143
+ &.ui3n-chip--with-icon:not(.ui3n-chip--closable) {
144
+ .ui3n-chip__body {
145
+ max-width: calc(100% - v-bind(height) - 5px);
146
+ }
147
+ }
148
+
149
+ &.ui3n-chip--closable.ui3n-chip--with-icon {
150
+ .ui3n-chip__body {
151
+ max-width: calc(100% - v-bind(height) - 29px);
152
+ }
153
+ }
154
+ }
155
+ </style>