@v1nt1248/3nclient-lib 0.3.8 → 0.3.11
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/README.md +3 -2
- package/dist/components/ui3n-autocomplete/types.d.ts +100 -0
- package/dist/components/ui3n-badge/types.d.ts +14 -0
- package/dist/components/ui3n-badge/ui3n-badge.vue.d.ts +2 -4
- package/dist/components/ui3n-breadcrumbs/types.d.ts +50 -0
- package/dist/components/ui3n-breadcrumbs/ui3n-breadcrumbs.vue.d.ts +2 -4
- package/dist/components/ui3n-button/types.d.ts +21 -0
- package/dist/components/ui3n-button/ui3n-button.vue.d.ts +2 -4
- package/dist/components/ui3n-checkbox/types.d.ts +44 -0
- package/dist/components/ui3n-chip/types.d.ts +49 -0
- package/dist/components/ui3n-dialog/types.d.ts +103 -0
- package/dist/components/ui3n-drop-files/types.d.ts +31 -0
- package/dist/components/ui3n-editable/types.d.ts +102 -0
- package/dist/components/ui3n-emoji/types.d.ts +13 -0
- package/dist/components/ui3n-icon/types.d.ts +10 -0
- package/dist/components/ui3n-input/types.d.ts +85 -0
- package/dist/components/ui3n-input-file/types.d.ts +29 -0
- package/dist/components/ui3n-list/types.d.ts +35 -0
- package/dist/components/ui3n-menu/types.d.ts +89 -0
- package/dist/components/ui3n-notification/types.d.ts +28 -0
- package/dist/components/ui3n-progress/types.d.ts +49 -0
- package/dist/components/ui3n-radio-group/types.d.ts +78 -0
- package/dist/components/ui3n-selector/types.d.ts +95 -0
- package/dist/components/ui3n-slider/types.d.ts +51 -0
- package/dist/components/ui3n-step-line-bar/types.d.ts +12 -0
- package/dist/components/ui3n-switch/types.d.ts +31 -0
- package/dist/components/ui3n-table/types.d.ts +198 -0
- package/dist/components/ui3n-tabs/types.d.ts +38 -0
- package/dist/components/ui3n-text/types.d.ts +56 -0
- package/dist/components/ui3n-tooltip/types.d.ts +69 -0
- package/dist/components/ui3n-virtual-scroll/types.d.ts +18 -0
- package/dist/constants/general.d.ts +0 -1
- package/dist/constants/plugins-keys.d.ts +0 -2
- package/dist/index.d.ts +0 -8
- package/dist/plugins/index.d.ts +1 -4
- package/dist/style.css +1 -1
- package/dist/ui3n-components.js +14949 -14627
- package/dist/ui3n-plugins.d.ts +3 -11
- package/dist/ui3n-plugins.js +338 -367
- package/dist/ui3n-utils.js +422 -439
- package/dist/utils/copy-to-clipboard.d.ts +1 -0
- package/dist/utils/execute-function.d.ts +29 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/remove-whitespace-in-string.d.ts +1 -0
- package/dist/utils/ui/get-element-color.d.ts +1 -1
- package/package.json +29 -26
- package/src/components/ui3n-autocomplete/types.ts +100 -0
- package/src/components/ui3n-badge/types.ts +16 -0
- package/src/components/ui3n-badge/ui3n-badge-simple.vue +10 -9
- package/src/components/ui3n-badge/ui3n-badge.vue +37 -36
- package/src/components/ui3n-breadcrumbs/types.ts +51 -0
- package/src/components/ui3n-breadcrumbs/ui3n-breadcrumb.vue +69 -69
- package/src/components/ui3n-breadcrumbs/ui3n-breadcrumbs.vue +7 -8
- package/src/components/ui3n-button/types.ts +23 -0
- package/src/components/ui3n-button/ui3n-button.vue +27 -29
- package/src/components/ui3n-checkbox/types.ts +44 -0
- package/src/components/ui3n-checkbox/ui3n-checkbox.vue +16 -23
- package/src/components/ui3n-chip/types.ts +51 -0
- package/src/components/ui3n-dialog/types.ts +103 -0
- package/src/components/ui3n-drop-files/types.ts +31 -0
- package/src/components/ui3n-editable/types.ts +102 -0
- package/src/components/ui3n-editable/useContentEditable.ts +4 -2
- package/src/components/ui3n-emoji/types.ts +13 -0
- package/src/components/ui3n-icon/types.ts +10 -0
- package/src/components/ui3n-input/types.ts +85 -0
- package/src/components/ui3n-input/ui3n-input.vue +15 -3
- package/src/components/ui3n-input-file/types.ts +29 -0
- package/src/components/ui3n-list/types.ts +35 -0
- package/src/components/ui3n-menu/types.ts +89 -0
- package/src/components/ui3n-notification/types.ts +28 -0
- package/src/components/ui3n-progress/types.ts +49 -0
- package/src/components/ui3n-radio-group/types.ts +78 -0
- package/src/components/ui3n-selector/types.ts +96 -1
- package/src/components/ui3n-slider/types.ts +51 -0
- package/src/components/ui3n-step-line-bar/types.ts +12 -0
- package/src/components/ui3n-switch/types.ts +31 -0
- package/src/components/ui3n-table/types.ts +204 -0
- package/src/components/ui3n-tabs/types.ts +38 -0
- package/src/components/ui3n-text/types.ts +56 -0
- package/src/components/ui3n-tooltip/types.ts +69 -0
- package/src/components/ui3n-virtual-scroll/types.ts +18 -0
- package/dist/plugins/i18n/i18n.d.ts +0 -9
- package/dist/plugins/i18n/store-i18n.d.ts +0 -7
- package/dist/plugins/i18n/types.d.ts +0 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copyToClipboard(text: string): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type ExtractArgs<F> = F extends (signal: AbortSignal, ...args: infer P) => any ? P : F extends (...args: infer P) => any ? P : never;
|
|
2
|
+
export interface ExecuteFnBaseProps<F extends (...args: any[]) => any, V> {
|
|
3
|
+
fn: F;
|
|
4
|
+
fnArgs: ExtractArgs<F>;
|
|
5
|
+
timeoutValue?: number;
|
|
6
|
+
retryCount?: number;
|
|
7
|
+
retryDelay?: number;
|
|
8
|
+
errorText?: string;
|
|
9
|
+
actionIfError?: (err?: unknown) => void;
|
|
10
|
+
actionIfSuccess?: () => void;
|
|
11
|
+
actionInFinally?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export interface ExecuteFunctionPropsNoCatchError<F extends (...args: any[]) => any, V = Awaited<ReturnType<F>>> extends ExecuteFnBaseProps<F, V> {
|
|
14
|
+
doesErrorPropagateStop: true;
|
|
15
|
+
defaultValue: V;
|
|
16
|
+
}
|
|
17
|
+
export interface ExecuteFunctionPropsCatchError<F extends (...args: any[]) => any, V = Awaited<ReturnType<F>>> extends ExecuteFnBaseProps<F, V> {
|
|
18
|
+
doesErrorPropagateStop?: false;
|
|
19
|
+
defaultValue?: undefined;
|
|
20
|
+
}
|
|
21
|
+
export type ExecuteFunctionProps<F extends (...args: any[]) => any, V = Awaited<ReturnType<F>>> = ExecuteFunctionPropsCatchError<F, V> | ExecuteFunctionPropsNoCatchError<F, V>;
|
|
22
|
+
export declare class ExecuteFunctionError extends Error {
|
|
23
|
+
cause: unknown;
|
|
24
|
+
constructor(message: string, data?: {
|
|
25
|
+
cause?: unknown;
|
|
26
|
+
fnArgs?: unknown[];
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export declare function executeFunc<F extends (...args: any[]) => any, V = Awaited<ReturnType<F>>>(props: ExecuteFunctionProps<F, V>): Promise<V>;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export * from './round';
|
|
|
8
8
|
export * from './get-random-id';
|
|
9
9
|
export * from './textarea-max-rows';
|
|
10
10
|
export * from './for-web3n';
|
|
11
|
+
export * from './copy-to-clipboard';
|
|
12
|
+
export * from './execute-function';
|
|
13
|
+
export * from './remove-whitespace-in-string';
|
|
11
14
|
export * from './ui/selection';
|
|
12
15
|
export * from './ui/mark-search';
|
|
13
16
|
export * from './ui/has-slot-content';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function removeWhitespaceInString(str: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function generateColor(str: string): string;
|
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.3.
|
|
5
|
+
"version": "0.3.11",
|
|
6
6
|
"description": "Library for 3NWeb clients",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"files": [
|
|
@@ -51,63 +51,66 @@
|
|
|
51
51
|
"docs:preview": "vitepress preview docs"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@floating-ui/dom": "
|
|
54
|
+
"@floating-ui/dom": "1.7.6",
|
|
55
55
|
"@floating-ui/vue": "1.1.11",
|
|
56
56
|
"dayjs": "1.11.20",
|
|
57
|
-
"lodash": "4.
|
|
57
|
+
"lodash": "4.18.1",
|
|
58
58
|
"mitt": "3.0.1",
|
|
59
|
-
"sanitize-html": "2.17.
|
|
59
|
+
"sanitize-html": "2.17.3",
|
|
60
60
|
"vuedraggable": "4.1.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"pinia": "3.0.4",
|
|
64
|
-
"vue": "3.5.
|
|
64
|
+
"vue": "3.5.33"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@eslint/eslintrc": "
|
|
68
|
-
"@eslint/js": "
|
|
67
|
+
"@eslint/eslintrc": "3.3.5",
|
|
68
|
+
"@eslint/js": "10.0.1",
|
|
69
69
|
"@types/lodash": "4.17.24",
|
|
70
|
-
"@types/node": "
|
|
70
|
+
"@types/node": "24.12.2",
|
|
71
71
|
"@types/sanitize-html": "2.16.1",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
73
|
-
"@typescript-eslint/parser": "8.
|
|
74
|
-
"@vitejs/plugin-vue": "6.0.
|
|
75
|
-
"@vue/compiler-core": "3.5.
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "8.59.0",
|
|
73
|
+
"@typescript-eslint/parser": "8.59.0",
|
|
74
|
+
"@vitejs/plugin-vue": "6.0.6",
|
|
75
|
+
"@vue/compiler-core": "3.5.33",
|
|
76
76
|
"@vue/eslint-config-typescript": "14.7.0",
|
|
77
|
-
"@vue/runtime-core": "3.5.
|
|
77
|
+
"@vue/runtime-core": "3.5.33",
|
|
78
78
|
"@vuedx/typescript-plugin-vue": "0.7.6",
|
|
79
|
-
"eslint": "
|
|
79
|
+
"eslint": "10.2.1",
|
|
80
80
|
"eslint-config-prettier": "10.1.8",
|
|
81
81
|
"eslint-plugin-import": "2.32.0",
|
|
82
82
|
"eslint-plugin-node": "11.1.0",
|
|
83
83
|
"eslint-plugin-prettier": "5.5.5",
|
|
84
84
|
"eslint-plugin-promise": "7.2.1",
|
|
85
|
-
"eslint-plugin-vue": "10.
|
|
86
|
-
"globals": "17.
|
|
85
|
+
"eslint-plugin-vue": "10.9.0",
|
|
86
|
+
"globals": "17.5.0",
|
|
87
87
|
"jackspeak": "4.2.3",
|
|
88
88
|
"path": "0.12.7",
|
|
89
89
|
"pinia": "3.0.4",
|
|
90
90
|
"postcss-html": "1.8.1",
|
|
91
|
-
"prettier": "3.8.
|
|
92
|
-
"sass": "1.
|
|
93
|
-
"
|
|
94
|
-
"stylelint
|
|
91
|
+
"prettier": "3.8.3",
|
|
92
|
+
"sass": "1.99.0",
|
|
93
|
+
"shiki": "^4.0.2",
|
|
94
|
+
"stylelint": "17.9.0",
|
|
95
|
+
"stylelint-config-recommended-scss": "17.0.1",
|
|
95
96
|
"stylelint-config-recommended-vue": "1.6.1",
|
|
96
97
|
"stylelint-config-standard": "39.0.1",
|
|
97
98
|
"stylelint-scss": "7.0.0",
|
|
98
99
|
"tslib": "2.8.1",
|
|
99
100
|
"typescript": "5.9.3",
|
|
100
|
-
"typescript-eslint": "8.
|
|
101
|
-
"vite": "8.0.
|
|
101
|
+
"typescript-eslint": "8.59.0",
|
|
102
|
+
"vite": "8.0.10",
|
|
102
103
|
"vite-plugin-css-injected-by-js": "4.0.1",
|
|
103
104
|
"vite-plugin-dts": "4.5.4",
|
|
104
|
-
"vite-plugin-vue-devtools": "8.1.
|
|
105
|
+
"vite-plugin-vue-devtools": "8.1.1",
|
|
105
106
|
"vitepress": "1.6.4",
|
|
106
|
-
"vue": "3.5.
|
|
107
|
+
"vue": "3.5.33",
|
|
108
|
+
"vue-component-meta": "3.2.7",
|
|
109
|
+
"vue-docgen-api": "4.79.2",
|
|
107
110
|
"vue-eslint-parser": "10.4.0",
|
|
108
|
-
"vue-tsc": "3.2.
|
|
111
|
+
"vue-tsc": "3.2.7"
|
|
109
112
|
},
|
|
110
|
-
"packageManager": "pnpm@10.
|
|
113
|
+
"packageManager": "pnpm@10.33.0",
|
|
111
114
|
"pnpm": {
|
|
112
115
|
"peerDependencyRules": {
|
|
113
116
|
"ignoreMissing": [
|
|
@@ -1,43 +1,143 @@
|
|
|
1
1
|
import { VNode } from 'vue';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Base autocomplete option interface
|
|
5
|
+
*/
|
|
3
6
|
export interface Ui3nAutocompleteOptionBase {
|
|
7
|
+
/**
|
|
8
|
+
* Option ID
|
|
9
|
+
*/
|
|
4
10
|
id: string;
|
|
11
|
+
/**
|
|
12
|
+
* Option name
|
|
13
|
+
*/
|
|
5
14
|
name?: string;
|
|
6
15
|
}
|
|
7
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Autocomplete value type
|
|
19
|
+
*/
|
|
8
20
|
export type Ui3nAutocompleteValue<T extends Ui3nAutocompleteOptionBase> = {
|
|
9
21
|
[Property in keyof T]: T[Property];
|
|
10
22
|
};
|
|
11
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Autocomplete component properties
|
|
26
|
+
*/
|
|
12
27
|
export interface Ui3nAutocompleteProps<T extends Ui3nAutocompleteOptionBase> {
|
|
28
|
+
/**
|
|
29
|
+
* Whether to show chips
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
13
32
|
chips?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to clear input on select
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
14
37
|
clearOnSelect?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Custom filter function
|
|
40
|
+
*/
|
|
15
41
|
customFilter?: (value: T, query: string) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether autocomplete is disabled
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
16
46
|
disabled?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Filter keys
|
|
49
|
+
*/
|
|
17
50
|
filterKeys?: string[];
|
|
51
|
+
/**
|
|
52
|
+
* Whether to hide selected items
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
18
55
|
hideSelected?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Items to display
|
|
58
|
+
*/
|
|
19
59
|
items: T[];
|
|
60
|
+
/**
|
|
61
|
+
* Property to use as title
|
|
62
|
+
*/
|
|
20
63
|
itemTitle?: keyof T;
|
|
64
|
+
/**
|
|
65
|
+
* Property to use as value
|
|
66
|
+
*/
|
|
21
67
|
itemValue?: keyof T;
|
|
68
|
+
/**
|
|
69
|
+
* Current autocomplete value
|
|
70
|
+
*/
|
|
22
71
|
modelValue: T[] | Array<T[keyof T]>;
|
|
72
|
+
/**
|
|
73
|
+
* Whether to allow adding new values
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
23
76
|
addNewValue?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* New value validator function
|
|
79
|
+
*/
|
|
24
80
|
newValueValidator?: (value: string) => boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Whether to allow multiple selection
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
25
85
|
multiple?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Text to show when no data
|
|
88
|
+
*/
|
|
26
89
|
noDataText?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Placeholder text
|
|
92
|
+
*/
|
|
27
93
|
placeholder?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Whether to return the whole object or just the value
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
28
98
|
returnObject?: boolean;
|
|
29
99
|
}
|
|
30
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Autocomplete component emits
|
|
103
|
+
*/
|
|
31
104
|
export interface Ui3nAutocompleteEmits<T extends Ui3nAutocompleteOptionBase> {
|
|
105
|
+
/**
|
|
106
|
+
* Emitted when model value updates
|
|
107
|
+
*/
|
|
32
108
|
(event: 'update:modelValue', value: T[] | Array<T[keyof T]>): void;
|
|
109
|
+
/**
|
|
110
|
+
* Emitted when search value updates
|
|
111
|
+
*/
|
|
33
112
|
(event: 'update:search', value: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Emitted when focused state updates
|
|
115
|
+
*/
|
|
34
116
|
(event: 'update:focused', value: boolean): void;
|
|
117
|
+
/**
|
|
118
|
+
* Emitted when new value validation status updates
|
|
119
|
+
*/
|
|
35
120
|
(event: 'valid:new-value', value: boolean): void;
|
|
36
121
|
}
|
|
37
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Autocomplete component slots
|
|
125
|
+
*/
|
|
38
126
|
export interface Ui3nAutocompleteSlots<T extends Ui3nAutocompleteOptionBase> {
|
|
127
|
+
/**
|
|
128
|
+
* Item slot
|
|
129
|
+
*/
|
|
39
130
|
item: (props: { item: T; index: number; query?: string }) => VNode;
|
|
131
|
+
/**
|
|
132
|
+
* Chip slot
|
|
133
|
+
*/
|
|
40
134
|
chip: (props: { item: T | T[keyof T]; index: number }) => VNode;
|
|
135
|
+
/**
|
|
136
|
+
* No data text slot
|
|
137
|
+
*/
|
|
41
138
|
noDataText: () => VNode;
|
|
139
|
+
/**
|
|
140
|
+
* Selection slot
|
|
141
|
+
*/
|
|
42
142
|
selection: (props: { value: T[] | Array<T[keyof T]> }) => VNode;
|
|
43
143
|
}
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
+
import type { VNode } from 'vue';
|
|
2
|
+
|
|
1
3
|
export interface Ui3nBadgeSimpleProps {
|
|
4
|
+
/** For simple display as a circle */
|
|
2
5
|
dot?: boolean;
|
|
6
|
+
/** Text displayed inside the circle */
|
|
3
7
|
value?: string | number;
|
|
8
|
+
/** Background color */
|
|
4
9
|
color?: string;
|
|
10
|
+
/** Text color */
|
|
5
11
|
textColor?: string;
|
|
6
12
|
}
|
|
7
13
|
|
|
8
14
|
export interface Ui3nBadgeProps {
|
|
15
|
+
/** For simple display as a circle */
|
|
9
16
|
dot?: boolean;
|
|
17
|
+
/** Text displayed inside the circle */
|
|
10
18
|
value?: string | number;
|
|
19
|
+
/** Background color */
|
|
11
20
|
color?: string;
|
|
21
|
+
/** Text color */
|
|
12
22
|
textColor?: string;
|
|
23
|
+
/** Positioning of the circle */
|
|
13
24
|
position?: 'right-top' | 'right-bottom' | 'left-top' | 'left-bottom';
|
|
14
25
|
}
|
|
26
|
+
|
|
27
|
+
export interface Ui3nBadgeSlots {
|
|
28
|
+
/** Default slot */
|
|
29
|
+
default: () => VNode;
|
|
30
|
+
}
|
|
@@ -18,6 +18,15 @@ const emits = defineEmits<{
|
|
|
18
18
|
|
|
19
19
|
const element = ref<HTMLDivElement | null>(null);
|
|
20
20
|
|
|
21
|
+
function getElementSize() {
|
|
22
|
+
nextTick(() => {
|
|
23
|
+
if (element.value) {
|
|
24
|
+
emits('change:size', { width: element.value.offsetWidth, height: element.value.offsetHeight });
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
21
30
|
watch(
|
|
22
31
|
() => [props.value, props.dot],
|
|
23
32
|
() => getElementSize(),
|
|
@@ -26,14 +35,6 @@ watch(
|
|
|
26
35
|
onMounted(() => {
|
|
27
36
|
getElementSize();
|
|
28
37
|
});
|
|
29
|
-
|
|
30
|
-
function getElementSize() {
|
|
31
|
-
nextTick(() => {
|
|
32
|
-
if (element.value) {
|
|
33
|
-
emits('change:size', { width: element.value.offsetWidth, height: element.value.offsetHeight });
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
38
|
</script>
|
|
38
39
|
|
|
39
40
|
<template>
|
|
@@ -57,7 +58,7 @@ function getElementSize() {
|
|
|
57
58
|
position: relative;
|
|
58
59
|
box-sizing: border-box;
|
|
59
60
|
background-color: v-bind(color);
|
|
60
|
-
outline: 1px var(--
|
|
61
|
+
outline: 1px var(--color-bg-block-primary-default)solid;
|
|
61
62
|
|
|
62
63
|
&:not(.ui3nBadgeDot) {
|
|
63
64
|
min-height: var(--ui3n-badge-size);
|
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, ref, useSlots } from 'vue';
|
|
3
|
-
import get from 'lodash/get';
|
|
4
|
-
import Ui3nBadgeSimple from './ui3n-badge-simple.vue';
|
|
5
|
-
import type { Ui3nBadgeProps } from './types';
|
|
2
|
+
import { computed, ref, useSlots } from 'vue';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import Ui3nBadgeSimple from './ui3n-badge-simple.vue';
|
|
5
|
+
import type { Ui3nBadgeProps, Ui3nBadgeSlots } from './types';
|
|
6
6
|
|
|
7
|
-
const props = withDefaults(
|
|
8
|
-
defineProps<Ui3nBadgeProps>(),
|
|
9
|
-
{
|
|
7
|
+
const props = withDefaults(defineProps<Ui3nBadgeProps>(), {
|
|
10
8
|
dot: false,
|
|
11
9
|
value: '',
|
|
12
10
|
color: 'var(--color-bg-button-primary-default)',
|
|
13
11
|
textColor: 'var(--color-text-button-primary-default)',
|
|
14
12
|
position: 'right-top',
|
|
15
|
-
}
|
|
16
|
-
);
|
|
13
|
+
});
|
|
14
|
+
defineSlots<Ui3nBadgeSlots>();
|
|
17
15
|
|
|
18
|
-
const slots = useSlots();
|
|
19
|
-
const badgeElementSize = ref<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
const slots = useSlots();
|
|
17
|
+
const badgeElementSize = ref<
|
|
18
|
+
| {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}
|
|
22
|
+
| never
|
|
23
|
+
>();
|
|
23
24
|
|
|
24
|
-
const hasDefaultSlot = computed(() => !!slots.default);
|
|
25
|
-
const style = computed(() => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
25
|
+
const hasDefaultSlot = computed(() => !!slots.default);
|
|
26
|
+
const style = computed(() => {
|
|
27
|
+
const [xPosition, yPosition] = props.position.split('-');
|
|
28
|
+
return {
|
|
29
|
+
...(xPosition === 'right' && { right: `-${get(badgeElementSize.value, 'width', 0) / 2}px` }),
|
|
30
|
+
...(xPosition === 'left' && { left: `-${get(badgeElementSize.value, 'width', 0) / 2}px` }),
|
|
31
|
+
...(yPosition === 'top' && { top: `-${get(badgeElementSize.value, 'height', 0) / 2}px` }),
|
|
32
|
+
...(yPosition === 'bottom' && { bottom: `-${get(badgeElementSize.value, 'height', 0) / 2}px` }),
|
|
33
|
+
};
|
|
34
|
+
});
|
|
34
35
|
</script>
|
|
35
36
|
|
|
36
37
|
<template>
|
|
@@ -64,19 +65,19 @@ const style = computed(() => {
|
|
|
64
65
|
</template>
|
|
65
66
|
|
|
66
67
|
<style lang="scss" module>
|
|
67
|
-
.ui3nBadge {
|
|
68
|
-
|
|
68
|
+
.ui3nBadge {
|
|
69
|
+
--ui3n-badge-size: 20px;
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
}
|
|
71
|
+
position: relative;
|
|
72
|
+
}
|
|
72
73
|
|
|
73
|
-
.ui3nBadgeWrapper {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
74
|
+
.ui3nBadgeWrapper {
|
|
75
|
+
position: relative;
|
|
76
|
+
width: max-content;
|
|
77
|
+
}
|
|
77
78
|
|
|
78
|
-
.ui3nBadgeContent {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
79
|
+
.ui3nBadgeContent {
|
|
80
|
+
position: absolute;
|
|
81
|
+
z-index: 5;
|
|
82
|
+
}
|
|
82
83
|
</style>
|
|
@@ -1,21 +1,72 @@
|
|
|
1
1
|
import { VNode } from 'vue';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Breadcrumb component properties
|
|
5
|
+
*/
|
|
3
6
|
export interface Ui3nBreadcrumbProps {
|
|
7
|
+
/**
|
|
8
|
+
* Separator between breadcrumbs
|
|
9
|
+
* @default '/'
|
|
10
|
+
*/
|
|
4
11
|
separator?: string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the breadcrumb is active
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
5
16
|
isActive?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the breadcrumb is disabled
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
6
21
|
disabled?: boolean;
|
|
7
22
|
}
|
|
8
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Breadcrumb component emits
|
|
26
|
+
*/
|
|
9
27
|
export interface Ui3nBreadcrumbEmits {
|
|
28
|
+
/**
|
|
29
|
+
* Called when the breadcrumb is clicked
|
|
30
|
+
*/
|
|
10
31
|
(ev: 'click', value: Event): void;
|
|
11
32
|
}
|
|
12
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Breadcrumb component slots
|
|
36
|
+
*/
|
|
13
37
|
export interface Ui3nBreadcrumbSlots {
|
|
38
|
+
/**
|
|
39
|
+
* Separator slot
|
|
40
|
+
*/
|
|
14
41
|
separator: () => VNode;
|
|
42
|
+
/**
|
|
43
|
+
* Default slot
|
|
44
|
+
*/
|
|
15
45
|
default: () => VNode;
|
|
16
46
|
}
|
|
17
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Breadcrumbs component properties
|
|
50
|
+
*/
|
|
18
51
|
export interface Ui3nBreadcrumbsProps {
|
|
52
|
+
/**
|
|
53
|
+
* Separator between breadcrumbs
|
|
54
|
+
* @default '/'
|
|
55
|
+
*/
|
|
19
56
|
separator?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the breadcrumbs are disabled
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
20
61
|
disabled?: boolean;
|
|
21
62
|
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Breadcrumbs component slots
|
|
66
|
+
*/
|
|
67
|
+
export interface Ui3nBreadcrumbsSlots {
|
|
68
|
+
/**
|
|
69
|
+
* Default slot
|
|
70
|
+
*/
|
|
71
|
+
default: () => VNode;
|
|
72
|
+
}
|