@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
package/package.json CHANGED
@@ -3,26 +3,23 @@
3
3
  "private": false,
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "author": "v1nt1248",
6
- "version": "0.0.6",
6
+ "version": "0.0.8",
7
7
  "description": "Library for 3NWeb clients",
8
8
  "type": "module",
9
- "files": [
10
- "dist"
11
- ],
12
- "main": "./dist/ui-3n-lib.umd.cjs",
9
+ "files": ["dist", "src/components/"],
13
10
  "module": "./dist/ui-3n-lib.js",
14
- "types": "./dist/types.d.ts",
11
+ "types": "./dist/index.d.ts",
15
12
  "exports": {
16
13
  ".": {
17
- "import": "./dist/ui-3n-lib.js",
18
- "require": "./dist/ui-3n-lib.umd.cjs"
14
+ "import": "./dist/ui-3n-lib.js"
19
15
  },
20
16
  "./style.css": "./dist/style.css"
21
17
  },
22
18
  "scripts": {
23
19
  "dev": "vite",
24
20
  "generate:types": "vue-tsc --declaration --emitDeclarationOnly --outdir ./dist",
25
- "build": "vite build && yarn generate:types",
21
+ "copy:dts": "cp ./src/types.d.ts ./dist",
22
+ "build": "vite build && yarn copy:dts",
26
23
  "preview": "vite preview",
27
24
  "stylelint": "stylelint --config .stylelint.config.cjs 'src/**/*.{vue,scss}'",
28
25
  "stylelint:fix": "stylelint --config .stylelint.config.cjs --fix 'src/**/*.{vue,scss}'",
@@ -37,7 +34,9 @@
37
34
  "dayjs": "^1.11.9",
38
35
  "lodash": "^4.17.21",
39
36
  "mitt": "^3.0.1",
40
- "sanitize-html": "^2.11.0",
37
+ "sanitize-html": "^2.11.0"
38
+ },
39
+ "peerDependencies": {
41
40
  "vue": "^3.3.4"
42
41
  },
43
42
  "devDependencies": {
@@ -65,6 +64,8 @@
65
64
  "stylelint-scss": "^5.1.0",
66
65
  "typescript": "^5.2.2",
67
66
  "vite": "^4.4.5",
67
+ "vite-plugin-css-injected-by-js": "^3.3.0",
68
+ "vite-plugin-dts": "^3.5.3",
68
69
  "vue-tsc": "^1.8.5"
69
70
  }
70
71
  }
@@ -0,0 +1,13 @@
1
+ import Ui3nIcon from './ui3n-icon.vue'
2
+ import type { Ui3nIconProps, Ui3nIconEmits } from './ui3n-icon.vue'
3
+ import Ui3nButton from './ui3n-button.vue'
4
+ import type { Ui3nButtonProps, Ui3nButtonEmits } from './ui3n-button.vue'
5
+
6
+ export {
7
+ Ui3nIcon,
8
+ Ui3nIconProps,
9
+ Ui3nIconEmits,
10
+ Ui3nButton,
11
+ Ui3nButtonProps,
12
+ Ui3nButtonEmits,
13
+ }
@@ -0,0 +1,156 @@
1
+ <script lang="ts" setup>
2
+ import { computed, onMounted, ref, useSlots } from 'vue'
3
+ import { hasSlotContent } from '../tools/ui.helpers'
4
+ import Ui3nIcon from './ui3n-icon.vue'
5
+
6
+ export interface Ui3nButtonProps {
7
+ textColor?: string;
8
+ color?: string;
9
+ round?: boolean;
10
+ elevation?: boolean;
11
+ icon?: string;
12
+ iconSize?: string | number;
13
+ iconColor?: string;
14
+ disabled?: boolean;
15
+ }
16
+
17
+ export interface Ui3nButtonEmits {
18
+ (ev: 'click', value: Event): void;
19
+ (ev: 'focus', value: Event): void;
20
+ (ev: 'blur', value: Event): void;
21
+ }
22
+
23
+ const slots = useSlots()
24
+ const props = defineProps<Ui3nButtonProps>()
25
+ const emit = defineEmits<Ui3nButtonEmits>()
26
+
27
+ const buttonEl = ref<HTMLButtonElement | null>(null)
28
+ const isSlotEmpty = computed(() => !hasSlotContent(slots['default']))
29
+
30
+ onMounted(() => {
31
+ if (buttonEl.value) {
32
+ if (props.color) {
33
+ buttonEl.value.style.setProperty('--ui3n-button-background', props.color)
34
+ }
35
+ if (props.textColor) {
36
+ buttonEl.value.style.setProperty('--ui3n-button-text-color', props.textColor)
37
+ }
38
+ }
39
+ })
40
+ </script>
41
+
42
+ <template>
43
+ <button
44
+ ref="buttonEl"
45
+ :class="[
46
+ 'ui3n-button',
47
+ { 'ui3n-button--round': props.round, 'ui3n-button--elevation': props.elevation },
48
+ ]"
49
+ type="button"
50
+ :disabled="props.disabled"
51
+ @click="emit('click', $event)"
52
+ @focusin="emit('focus', $event)"
53
+ @focusout="emit('blur', $event)"
54
+ >
55
+ <ui3n-icon
56
+ v-if="props.icon"
57
+ class="ui3n-button__icon"
58
+ :icon="props.icon"
59
+ :width="props.iconSize"
60
+ :height="props.iconSize"
61
+ :color="props.iconColor || 'var(--ui3n-button-text-color)'"
62
+ />
63
+ <span
64
+ :class="[
65
+ 'ui3n-button__text',
66
+ { 'ui3n-button__text--margin': !isSlotEmpty && props.icon },
67
+ ]"
68
+ >
69
+ <slot />
70
+ </span>
71
+ </button>
72
+ </template>
73
+
74
+ <style lang="scss" scoped>
75
+ .ui3n-button {
76
+ --ui3n-button-text-size: 12px;
77
+ --ui3n-button-text-height: 16px;
78
+ --ui3n-button-text-color: var(--system-white, #fff);
79
+ --ui3n-button-background: var(--blue-main, #0090ec);
80
+ --ui3n-button-padding-vert: 8px;
81
+ --ui3n-button-padding-horiz: 16px;
82
+
83
+ display: flex;
84
+ align-items: center;
85
+ border: none;
86
+ outline: none;
87
+ padding: var(--ui3n-button-padding-vert) var(--ui3n-button-padding-horiz);
88
+ border-radius: 4px;
89
+ background: var(--ui3n-button-background);
90
+ font-size: var(--ui3n-button-text-size);
91
+ line-height: var(--ui3n-button-text-height);
92
+ font-weight: 600;
93
+ color: var(--ui3n-button-text-color);
94
+ background-position: center;
95
+ transition: background 0.5s ease-in-out;
96
+
97
+ &--round {
98
+ --ui3n-button-padding-vert: 4px;
99
+ --ui3n-button-padding-horiz: 4px;
100
+
101
+ border-radius: 50%;
102
+ }
103
+
104
+ &--elevation {
105
+ box-shadow:
106
+ rgba(0, 0, 0, 0.2) 0px 3px 1px -2px
107
+ rgba(0, 0, 0, 0.14) 0px 2px 2px 0px
108
+ rgba(0, 0, 0, 0.12) 0px 1px 5px 0px;
109
+ }
110
+
111
+ &:not([disabled]) {
112
+ cursor: pointer;
113
+
114
+ &:hover {
115
+ background:
116
+ var(--ui3n-button-background)
117
+ radial-gradient(circle, transparent 1%, var(--ui3n-button-background) 1%)
118
+ center/15000%;
119
+
120
+ .ui3n-button {
121
+ &__icon,
122
+ &__text {
123
+ opacity: 1;
124
+ }
125
+ }
126
+ }
127
+
128
+ &:active {
129
+ opacity: 1;
130
+ background-color: var(--gray-90, #444);
131
+ background-size: 100%;
132
+ transition: background 0s;
133
+ }
134
+ }
135
+
136
+ &__icon {
137
+ opacity: 0.85;
138
+ transition: opacity 0.2s ease-in-out;
139
+ }
140
+
141
+ &__text {
142
+ display: block;
143
+ opacity: 0.85;
144
+ transition: opacity 0.2s ease-in-out;
145
+
146
+ &--margin {
147
+ margin-left: 4px;
148
+ }
149
+ }
150
+
151
+ &[disabled] {
152
+ opacity: 0.7;
153
+ }
154
+ }
155
+ </style>
156
+ ../tools/ui.helpers
@@ -0,0 +1,171 @@
1
+ <script lang="ts" setup>
2
+ import { computed, ref } from 'vue'
3
+
4
+ const props = defineProps<{
5
+ title?: string;
6
+ text?: string;
7
+ additionalText?: string;
8
+ }>()
9
+ const emit = defineEmits<{
10
+ (e: 'select', fileList: FileList): void;
11
+ }>()
12
+
13
+ const isOverDropPlace = ref(false)
14
+ const isOverDropZone = ref(false)
15
+ const params = computed(() => {
16
+ const {
17
+ title = 'Upload',
18
+ } = props
19
+
20
+ return {
21
+ title,
22
+ }
23
+ })
24
+
25
+ const onDragenter = (ev: MouseEvent) => {
26
+ ev.preventDefault()
27
+ isOverDropPlace.value = true
28
+ }
29
+ const onDragleave = (ev: MouseEvent) => {
30
+ ev.preventDefault()
31
+ isOverDropPlace.value = false
32
+ }
33
+ const onDropzoneDragover = (ev: MouseEvent) => {
34
+ ev.preventDefault()
35
+ ev.stopPropagation()
36
+ }
37
+ const onDropzoneDragenter = (ev: MouseEvent) => {
38
+ ev.preventDefault()
39
+ isOverDropZone.value = true
40
+ }
41
+ const onDropzoneDragleave = (ev: MouseEvent) => {
42
+ ev.preventDefault()
43
+ isOverDropZone.value = false
44
+ }
45
+ const onDrop = (ev: DragEvent) => {
46
+ ev.stopPropagation()
47
+ ev.preventDefault()
48
+ if (ev.dataTransfer!.files) {
49
+ emit('select', ev.dataTransfer!.files)
50
+ }
51
+ isOverDropPlace.value = false
52
+ isOverDropZone.value = false
53
+ }
54
+ </script>
55
+
56
+ <template>
57
+ <!-- eslint-disable max-len -->
58
+ <div
59
+ class="ui3n-drop-files"
60
+ @dragenter="onDragenter"
61
+ @dragleave="onDragleave"
62
+ >
63
+ <slot />
64
+
65
+ <div
66
+ v-if="isOverDropPlace || isOverDropZone"
67
+ class="ui3n-drop-files__dropzone"
68
+ @dragenter="onDropzoneDragenter"
69
+ @dragover="onDropzoneDragover"
70
+ @dragleave="onDropzoneDragleave"
71
+ @drop="onDrop"
72
+ >
73
+ <div class="ui3n-drop-files__dropzone-border" />
74
+ <h3 class="ui3n-drop-files__dropzone-title">
75
+ {{ params.title }}
76
+ </h3>
77
+ <div class="ui3n-drop-files__dropzone-icon">
78
+ <svg
79
+ width="192"
80
+ height="192"
81
+ viewBox="0 0 192 192"
82
+ fill="none"
83
+ xmlns="http://www.w3.org/2000/svg"
84
+ >
85
+ <path
86
+ d="M51 152C47.9333 152 45.3333 150.934 43.2 148.8C41.0667 146.667 40 144.067 40 141V119.8H46.2V141C46.2 142.2 46.7 143.3 47.7 144.3C48.7 145.3 49.8 145.8 51 145.8H141C142.2 145.8 143.3 145.3 144.3 144.3C145.3 143.3 145.8 142.2 145.8 141V119.8H152V141C152 144.067 150.933 146.667 148.8 148.8C146.667 150.934 144.067 152 141 152H51ZM93 122.4V49.2002L72.8 69.2002L68.4 65.0002L96 37.2002L123.6 65.0002L119.2 69.2002L99 49.2002V122.4H93Z"
87
+ fill="#212121"
88
+ />
89
+ </svg>
90
+ </div>
91
+ <div
92
+ v-if="props.text"
93
+ class="ui3n-drop-files__dropzone-text"
94
+ >
95
+ {{ props.text }}
96
+ </div>
97
+ <div
98
+ v-if="props.additionalText"
99
+ class="ui3n-drop-files__dropzone-additional"
100
+ >
101
+ {{ props.additionalText }}
102
+ </div>
103
+ </div>
104
+ </div>
105
+ </template>
106
+
107
+ <style lang="scss" scoped>
108
+ .ui3n-drop-files {
109
+ position: relative;
110
+ width: 100%;
111
+ height: 100%;
112
+
113
+ &__dropzone {
114
+ position: absolute;
115
+ background-color: var(--system-white, #fff);
116
+ display: flex;
117
+ flex-direction: column;
118
+ justify-content: center;
119
+ align-items: center;
120
+ inset: var(--half-size, 4px) var(--base-size, 8px);
121
+ border-radius: var(--base-size, 8px);
122
+ z-index: 5;
123
+
124
+ &-border {
125
+ position: absolute;
126
+ width: calc(100% - calc(var(--base-size, 8px) * 2));
127
+ height: calc(100% - calc(var(--base-size, 8px) * 2));
128
+ top: var(--base-size, 8px);
129
+ left: var(--base-size, 8px);
130
+ border-radius: var(--base-size, 8px);
131
+ border: 2px dashed var(--gray-50, #f2f2f2);
132
+ pointer-events: none;
133
+ }
134
+
135
+ &-title {
136
+ margin: 0 0 24px;
137
+ font-size: var(--font-24, 24px);
138
+ font-weight: 600;
139
+ color: var(--black-30, #b3b3b3);
140
+ pointer-events: none;
141
+ }
142
+
143
+ &-icon {
144
+ position: relative;
145
+ width: 160px;
146
+ height: 160px;
147
+ border-radius: 50%;
148
+ background-color: var(--gray-50, #f2f2f2);
149
+ display: flex;
150
+ justify-content: center;
151
+ align-items: center;
152
+ pointer-events: none;
153
+ }
154
+
155
+ &-text {
156
+ margin-top: calc(var(--base-size, 8px) * 3);
157
+ font-size: var(--font-12, 12px);
158
+ line-height: var(--font-16, 16px);
159
+ font-weight: 400;
160
+ color: var(--black-30, #b3b3b3);
161
+ }
162
+
163
+ &-additional {
164
+ margin-top: var(--half-size, 4px);
165
+ font-size: var(--font-12, 12px);
166
+ font-weight: 500;
167
+ color: var(--black-90, #212121);
168
+ }
169
+ }
170
+ }
171
+ </style>
@@ -0,0 +1,64 @@
1
+ <script lang="ts" setup>
2
+ import { computed, onMounted, ref } from 'vue'
3
+
4
+ const props = defineProps<{
5
+ emoji: string;
6
+ size?: string | number;
7
+ readonly?: boolean;
8
+ }>()
9
+ const emit = defineEmits<{
10
+ (ev: 'click', value: Event): void;
11
+ }>()
12
+
13
+ const emojiElement = ref<HTMLDivElement | null>(null)
14
+ const params = computed(() => {
15
+ const {
16
+ emoji,
17
+ size = 16,
18
+ readonly = false,
19
+ } = props
20
+
21
+ return { emoji, size, readonly }
22
+ })
23
+
24
+ onMounted(() => {
25
+ if (emojiElement.value) {
26
+ emojiElement.value.style.setProperty('--emoji-size', `${params.value.size}px`)
27
+ }
28
+ })
29
+
30
+ const onClick = (ev: Event) => {
31
+ ev.stopImmediatePropagation()
32
+ emit('click', ev)
33
+ }
34
+ </script>
35
+
36
+ <template>
37
+ <div
38
+ ref="emojiElement"
39
+ :class="[
40
+ 'ui3n-emoji',
41
+ { 'ui3n-emoji--readonly': params.readonly },
42
+ ]"
43
+ v-on="readonly ? {} : { 'click': onClick }"
44
+ >
45
+ {{ emoji }}
46
+ </div>
47
+ </template>
48
+
49
+ <style lang="scss" scoped>
50
+ .ui3n-emoji {
51
+ --emoji-size: 16px;
52
+
53
+ display: flex;
54
+ width: var(--emoji-size);
55
+ height: var(--emoji-size);
56
+ justify-content: center;
57
+ align-items: center;
58
+ cursor: pointer;
59
+
60
+ &--readonly {
61
+ cursor: default;
62
+ }
63
+ }
64
+ </style>
@@ -0,0 +1,51 @@
1
+ <script lang="ts" setup>
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { Icon } from '@iconify/vue'
4
+
5
+ export interface Ui3nIconProps {
6
+ icon: string;
7
+ title?: string;
8
+ inline?: boolean;
9
+ width?: string | number;
10
+ height?: string | number;
11
+ horizontalFlip?: boolean;
12
+ verticalFlip?: boolean;
13
+ flip?: string;
14
+ rotate?: number;
15
+ color?: string;
16
+ onLoad?: Function;
17
+ }
18
+
19
+ export interface Ui3nIconEmits {
20
+ (ev: 'click', value: Event): void;
21
+ }
22
+
23
+ const props = defineProps<Ui3nIconProps>()
24
+ const emit = defineEmits<Ui3nIconEmits>()
25
+
26
+ const onLoad = (value: any) => {
27
+ if (props.onLoad) {
28
+ props.onLoad(value)
29
+ }
30
+ }
31
+ const onClick = (ev: Event) => {
32
+ emit('click', ev)
33
+ }
34
+ </script>
35
+
36
+ <template>
37
+ <icon
38
+ :icon="props.icon"
39
+ :title="props.title || ''"
40
+ :inline="props.inline"
41
+ :width="props.width || 16"
42
+ :height="props.height || 16"
43
+ :horizontal-flip="props.horizontalFlip"
44
+ :vertical-flip="props.verticalFlip"
45
+ :flip="props.flip"
46
+ :rotate="props.rotate || 0"
47
+ :color="props.color || 'var(--gray-90, #444)'"
48
+ :on-load="onLoad"
49
+ @click="onClick"
50
+ />
51
+ </template>