@v-c/tabs 0.0.2
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/LICENSE +21 -0
- package/dist/TabContext.cjs +11 -0
- package/dist/TabContext.d.ts +8 -0
- package/dist/TabContext.js +9 -0
- package/dist/TabNavList/AddButton.cjs +4 -0
- package/dist/TabNavList/AddButton.js +3 -0
- package/dist/TabNavList/AddButton.vue_vue_type_script_setup_true_lang.cjs +36 -0
- package/dist/TabNavList/AddButton.vue_vue_type_script_setup_true_lang.js +35 -0
- package/dist/TabNavList/ExtraContent.cjs +4 -0
- package/dist/TabNavList/ExtraContent.js +3 -0
- package/dist/TabNavList/ExtraContent.vue_vue_type_script_setup_true_lang.cjs +51 -0
- package/dist/TabNavList/ExtraContent.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/TabNavList/OperationNode.cjs +4 -0
- package/dist/TabNavList/OperationNode.js +3 -0
- package/dist/TabNavList/OperationNode.vue_vue_type_script_setup_true_lang.cjs +210 -0
- package/dist/TabNavList/OperationNode.vue_vue_type_script_setup_true_lang.js +205 -0
- package/dist/TabNavList/TabNode.cjs +4 -0
- package/dist/TabNavList/TabNode.js +3 -0
- package/dist/TabNavList/TabNode.vue_vue_type_script_setup_true_lang.cjs +129 -0
- package/dist/TabNavList/TabNode.vue_vue_type_script_setup_true_lang.js +127 -0
- package/dist/TabNavList/Wrapper.cjs +4 -0
- package/dist/TabNavList/Wrapper.js +3 -0
- package/dist/TabNavList/Wrapper.vue_vue_type_script_setup_true_lang.cjs +54 -0
- package/dist/TabNavList/Wrapper.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/TabNavList/index.cjs +4 -0
- package/dist/TabNavList/index.js +3 -0
- package/dist/TabNavList/index.vue_vue_type_script_setup_true_lang.cjs +516 -0
- package/dist/TabNavList/index.vue_vue_type_script_setup_true_lang.js +513 -0
- package/dist/TabPanelList/TabPane.cjs +4 -0
- package/dist/TabPanelList/TabPane.js +3 -0
- package/dist/TabPanelList/TabPane.vue_vue_type_script_setup_true_lang.cjs +85 -0
- package/dist/TabPanelList/TabPane.vue_vue_type_script_setup_true_lang.js +83 -0
- package/dist/TabPanelList/index.cjs +4 -0
- package/dist/TabPanelList/index.js +3 -0
- package/dist/TabPanelList/index.vue_vue_type_script_setup_true_lang.cjs +105 -0
- package/dist/TabPanelList/index.vue_vue_type_script_setup_true_lang.js +103 -0
- package/dist/Tabs.cjs +4 -0
- package/dist/Tabs.js +3 -0
- package/dist/Tabs.vue_vue_type_script_setup_true_lang.cjs +194 -0
- package/dist/Tabs.vue_vue_type_script_setup_true_lang.js +190 -0
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/hooks/useAnimateConfig.cjs +28 -0
- package/dist/hooks/useAnimateConfig.d.ts +2 -0
- package/dist/hooks/useAnimateConfig.js +26 -0
- package/dist/hooks/useIndicator.cjs +68 -0
- package/dist/hooks/useIndicator.d.ts +11 -0
- package/dist/hooks/useIndicator.js +65 -0
- package/dist/hooks/useOffsets.cjs +39 -0
- package/dist/hooks/useOffsets.d.ts +18 -0
- package/dist/hooks/useOffsets.js +37 -0
- package/dist/hooks/useTouchMove.cjs +119 -0
- package/dist/hooks/useTouchMove.d.ts +2 -0
- package/dist/hooks/useTouchMove.js +117 -0
- package/dist/hooks/useVisibleRange.cjs +51 -0
- package/dist/hooks/useVisibleRange.d.ts +17 -0
- package/dist/hooks/useVisibleRange.js +49 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/dist/interface.cjs +0 -0
- package/dist/interface.d.ts +195 -0
- package/dist/interface.js +0 -0
- package/dist/utils.cjs +33 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.js +27 -0
- package/package.json +44 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { DropdownProps } from '@v-c/dropdown';
|
|
2
|
+
import { FocusEventHandler, KeyboardEventHandler, MouseEventHandler } from '@v-c/util/dist/EventInterface';
|
|
3
|
+
import { VueNode } from '@v-c/util/dist/type';
|
|
4
|
+
import { CSSMotionProps } from '@v-c/util/dist/utils/transition';
|
|
5
|
+
import { CSSProperties } from 'vue';
|
|
6
|
+
export type SizeInfo = [width: number, height: number];
|
|
7
|
+
export interface EditableConfig {
|
|
8
|
+
onEdit: (type: 'add' | 'remove', info: {
|
|
9
|
+
key?: string;
|
|
10
|
+
event: MouseEvent | KeyboardEvent;
|
|
11
|
+
}) => void;
|
|
12
|
+
showAdd?: boolean;
|
|
13
|
+
removeIcon?: VueNode;
|
|
14
|
+
addIcon?: VueNode;
|
|
15
|
+
}
|
|
16
|
+
export interface AnimatedConfig {
|
|
17
|
+
inkBar?: boolean;
|
|
18
|
+
tabPane?: boolean;
|
|
19
|
+
tabPaneMotion?: CSSMotionProps;
|
|
20
|
+
}
|
|
21
|
+
export interface TabsLocale {
|
|
22
|
+
dropdownAriaLabel?: string;
|
|
23
|
+
removeAriaLabel?: string;
|
|
24
|
+
addAriaLabel?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AddButtonProps {
|
|
27
|
+
prefixCls: string;
|
|
28
|
+
editable?: EditableConfig;
|
|
29
|
+
locale?: TabsLocale;
|
|
30
|
+
style?: CSSProperties;
|
|
31
|
+
}
|
|
32
|
+
export type OnTabScroll = (info: {
|
|
33
|
+
direction: 'left' | 'right' | 'top' | 'bottom';
|
|
34
|
+
}) => void;
|
|
35
|
+
export type TabBarExtraPosition = 'left' | 'right';
|
|
36
|
+
export type TabBarExtraMap = Partial<Record<TabBarExtraPosition, VueNode>>;
|
|
37
|
+
export type TabBarExtraContent = VueNode | TabBarExtraMap;
|
|
38
|
+
export interface ExtraContentProps {
|
|
39
|
+
position: TabBarExtraPosition;
|
|
40
|
+
prefixCls: string;
|
|
41
|
+
extra?: TabBarExtraContent;
|
|
42
|
+
}
|
|
43
|
+
export interface TabPaneProps {
|
|
44
|
+
tab?: VueNode;
|
|
45
|
+
className?: unknown;
|
|
46
|
+
style?: CSSProperties;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
children?: VueNode;
|
|
49
|
+
forceRender?: boolean;
|
|
50
|
+
closable?: boolean;
|
|
51
|
+
closeIcon?: VueNode;
|
|
52
|
+
icon?: VueNode;
|
|
53
|
+
prefixCls?: string;
|
|
54
|
+
tabKey?: string;
|
|
55
|
+
id?: string | null;
|
|
56
|
+
animated?: boolean;
|
|
57
|
+
active?: boolean;
|
|
58
|
+
destroyOnHidden?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface Tab extends Omit<TabPaneProps, 'tab' | 'children' | 'className'> {
|
|
61
|
+
key: string;
|
|
62
|
+
label: VueNode;
|
|
63
|
+
class?: string;
|
|
64
|
+
style?: CSSProperties;
|
|
65
|
+
content?: VueNode;
|
|
66
|
+
}
|
|
67
|
+
export type moreIcon = VueNode;
|
|
68
|
+
export type MoreProps = {
|
|
69
|
+
icon?: moreIcon;
|
|
70
|
+
} & Omit<DropdownProps, 'children'>;
|
|
71
|
+
export interface OperationNodeProps {
|
|
72
|
+
prefixCls: string;
|
|
73
|
+
className?: unknown;
|
|
74
|
+
style?: CSSProperties;
|
|
75
|
+
id: string | null;
|
|
76
|
+
tabs: Tab[];
|
|
77
|
+
rtl: boolean;
|
|
78
|
+
tabBarGutter?: number;
|
|
79
|
+
activeKey: string;
|
|
80
|
+
mobile: boolean;
|
|
81
|
+
more?: MoreProps;
|
|
82
|
+
editable?: EditableConfig;
|
|
83
|
+
locale?: TabsLocale;
|
|
84
|
+
removeAriaLabel?: string;
|
|
85
|
+
onTabClick: (key: string, e: MouseEvent | KeyboardEvent) => void;
|
|
86
|
+
tabMoving?: boolean;
|
|
87
|
+
getPopupContainer?: (node: HTMLElement) => HTMLElement;
|
|
88
|
+
popupClassName?: string;
|
|
89
|
+
popupStyle?: CSSProperties;
|
|
90
|
+
}
|
|
91
|
+
export interface TabNodeProps {
|
|
92
|
+
id: string | null;
|
|
93
|
+
prefixCls: string;
|
|
94
|
+
tab: Tab;
|
|
95
|
+
active: boolean;
|
|
96
|
+
focus: boolean;
|
|
97
|
+
closable?: boolean;
|
|
98
|
+
editable?: EditableConfig;
|
|
99
|
+
onClick?: (e: MouseEvent | KeyboardEvent) => void;
|
|
100
|
+
onResize?: (width: number, height: number, left: number, top: number) => void;
|
|
101
|
+
renderWrapper?: (node: VueNode) => VueNode;
|
|
102
|
+
removeAriaLabel?: string;
|
|
103
|
+
tabCount: number;
|
|
104
|
+
currentPosition: number;
|
|
105
|
+
removeIcon?: VueNode;
|
|
106
|
+
onKeyDown: KeyboardEventHandler;
|
|
107
|
+
onMouseDown: MouseEventHandler;
|
|
108
|
+
onMouseUp: MouseEventHandler;
|
|
109
|
+
onFocus: FocusEventHandler;
|
|
110
|
+
onBlur: FocusEventHandler;
|
|
111
|
+
style?: CSSProperties;
|
|
112
|
+
className?: string;
|
|
113
|
+
}
|
|
114
|
+
export type TabPosition = 'left' | 'right' | 'top' | 'bottom';
|
|
115
|
+
export type GetIndicatorSize = number | ((origin: number) => number);
|
|
116
|
+
export type SemanticName = string;
|
|
117
|
+
export type RenderTabBar = (props: Record<string, any>, TabNavListComponent: any) => VueNode;
|
|
118
|
+
export interface IndicatorConfig {
|
|
119
|
+
size?: GetIndicatorSize;
|
|
120
|
+
align?: 'start' | 'center' | 'end';
|
|
121
|
+
}
|
|
122
|
+
export interface TabNavListProps {
|
|
123
|
+
id: string | null;
|
|
124
|
+
tabPosition: TabPosition;
|
|
125
|
+
activeKey: string;
|
|
126
|
+
rtl: boolean;
|
|
127
|
+
animated?: AnimatedConfig;
|
|
128
|
+
extra?: TabBarExtraContent;
|
|
129
|
+
editable?: EditableConfig;
|
|
130
|
+
more?: MoreProps;
|
|
131
|
+
mobile: boolean;
|
|
132
|
+
tabBarGutter?: number;
|
|
133
|
+
renderTabBar?: RenderTabBar;
|
|
134
|
+
className?: unknown;
|
|
135
|
+
style?: CSSProperties;
|
|
136
|
+
locale?: TabsLocale;
|
|
137
|
+
onTabClick: (activeKey: string, e: MouseEvent | KeyboardEvent) => void;
|
|
138
|
+
onTabScroll?: OnTabScroll;
|
|
139
|
+
children?: (node: VueNode) => VueNode;
|
|
140
|
+
getPopupContainer?: (node: HTMLElement) => HTMLElement;
|
|
141
|
+
popupClassName?: string;
|
|
142
|
+
indicator?: IndicatorConfig;
|
|
143
|
+
classNames?: Partial<Record<SemanticName, string>>;
|
|
144
|
+
styles?: Partial<Record<SemanticName, CSSProperties>>;
|
|
145
|
+
}
|
|
146
|
+
export type TabNavListWrapperProps = Omit<TabNavListProps, 'children' | 'className'> & TabNavListProps;
|
|
147
|
+
export interface TabPaneProps {
|
|
148
|
+
tab?: VueNode;
|
|
149
|
+
className?: unknown;
|
|
150
|
+
style?: CSSProperties;
|
|
151
|
+
disabled?: boolean;
|
|
152
|
+
children?: VueNode;
|
|
153
|
+
forceRender?: boolean;
|
|
154
|
+
closable?: boolean;
|
|
155
|
+
closeIcon?: VueNode;
|
|
156
|
+
icon?: VueNode;
|
|
157
|
+
prefixCls?: string;
|
|
158
|
+
tabKey?: string;
|
|
159
|
+
id?: string | null;
|
|
160
|
+
animated?: boolean;
|
|
161
|
+
active?: boolean;
|
|
162
|
+
destroyOnHidden?: boolean;
|
|
163
|
+
}
|
|
164
|
+
export interface TabsProps {
|
|
165
|
+
prefixCls?: string;
|
|
166
|
+
className?: string;
|
|
167
|
+
style?: CSSProperties;
|
|
168
|
+
classNames?: Partial<Record<SemanticName, string>>;
|
|
169
|
+
styles?: Partial<Record<SemanticName, CSSProperties>>;
|
|
170
|
+
id?: string | null;
|
|
171
|
+
items?: Tab[];
|
|
172
|
+
activeKey?: string;
|
|
173
|
+
defaultActiveKey?: string;
|
|
174
|
+
direction?: 'ltr' | 'rtl';
|
|
175
|
+
animated?: boolean | AnimatedConfig;
|
|
176
|
+
renderTabBar?: RenderTabBar;
|
|
177
|
+
tabBarExtraContent?: TabBarExtraContent;
|
|
178
|
+
tabBarGutter?: number;
|
|
179
|
+
tabBarStyle?: CSSProperties;
|
|
180
|
+
tabPosition?: TabPosition;
|
|
181
|
+
destroyOnHidden?: boolean;
|
|
182
|
+
onChange?: (activeKey: string) => void;
|
|
183
|
+
onTabClick?: (activeKey: string, e: KeyboardEvent | MouseEvent) => void;
|
|
184
|
+
onTabScroll?: OnTabScroll;
|
|
185
|
+
editable?: EditableConfig;
|
|
186
|
+
getPopupContainer?: (node: HTMLElement) => HTMLElement;
|
|
187
|
+
locale?: TabsLocale;
|
|
188
|
+
more?: MoreProps;
|
|
189
|
+
/** @private Internal usage. Not promise will rename in future */
|
|
190
|
+
popupClassName?: string;
|
|
191
|
+
indicator?: {
|
|
192
|
+
size?: GetIndicatorSize;
|
|
193
|
+
align?: 'start' | 'center' | 'end';
|
|
194
|
+
};
|
|
195
|
+
}
|
|
File without changes
|
package/dist/utils.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
2
|
+
let __v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
|
|
3
|
+
const tabsGlobal = { uuid: 0 };
|
|
4
|
+
function setUUid(uuid) {
|
|
5
|
+
tabsGlobal.uuid = uuid;
|
|
6
|
+
}
|
|
7
|
+
function getUUid() {
|
|
8
|
+
return tabsGlobal.uuid;
|
|
9
|
+
}
|
|
10
|
+
function stringify(obj) {
|
|
11
|
+
let tgt;
|
|
12
|
+
if (obj instanceof Map) {
|
|
13
|
+
tgt = {};
|
|
14
|
+
obj.forEach((v, k) => {
|
|
15
|
+
tgt[k] = v;
|
|
16
|
+
});
|
|
17
|
+
} else tgt = obj;
|
|
18
|
+
return JSON.stringify(tgt);
|
|
19
|
+
}
|
|
20
|
+
function getRemovable(closable, closeIcon, editable, disabled) {
|
|
21
|
+
if (!editable || disabled || closable === false || closable === void 0 && ((0, __v_c_util_dist_props_util.isEmptyElement)(closeIcon) || closeIcon === null)) return false;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
var VC_TABS_DOUBLE_QUOTE = "TABS_DQ";
|
|
25
|
+
function genDataNodeKey(key) {
|
|
26
|
+
return String(key).replace(/"/g, VC_TABS_DOUBLE_QUOTE);
|
|
27
|
+
}
|
|
28
|
+
exports.genDataNodeKey = genDataNodeKey;
|
|
29
|
+
exports.getRemovable = getRemovable;
|
|
30
|
+
exports.getUUid = getUUid;
|
|
31
|
+
exports.setUUid = setUUid;
|
|
32
|
+
exports.stringify = stringify;
|
|
33
|
+
exports.tabsGlobal = tabsGlobal;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Key, VueNode } from '@v-c/util/dist/type';
|
|
2
|
+
import { EditableConfig } from './interface';
|
|
3
|
+
export declare const tabsGlobal: {
|
|
4
|
+
uuid: number;
|
|
5
|
+
};
|
|
6
|
+
export declare function setUUid(uuid: number): void;
|
|
7
|
+
export declare function getUUid(): number;
|
|
8
|
+
/**
|
|
9
|
+
* We trade Map as deps which may change with same value but different ref object.
|
|
10
|
+
* We should make it as hash for deps
|
|
11
|
+
*/
|
|
12
|
+
export declare function stringify<K extends PropertyKey, V>(obj: Record<K, V> | Map<K, V>): string;
|
|
13
|
+
export declare function getRemovable(closable?: boolean, closeIcon?: VueNode, editable?: EditableConfig, disabled?: boolean): boolean;
|
|
14
|
+
export declare function genDataNodeKey(key: Key): string;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isEmptyElement } from "@v-c/util/dist/props-util";
|
|
2
|
+
const tabsGlobal = { uuid: 0 };
|
|
3
|
+
function setUUid(uuid) {
|
|
4
|
+
tabsGlobal.uuid = uuid;
|
|
5
|
+
}
|
|
6
|
+
function getUUid() {
|
|
7
|
+
return tabsGlobal.uuid;
|
|
8
|
+
}
|
|
9
|
+
function stringify(obj) {
|
|
10
|
+
let tgt;
|
|
11
|
+
if (obj instanceof Map) {
|
|
12
|
+
tgt = {};
|
|
13
|
+
obj.forEach((v, k) => {
|
|
14
|
+
tgt[k] = v;
|
|
15
|
+
});
|
|
16
|
+
} else tgt = obj;
|
|
17
|
+
return JSON.stringify(tgt);
|
|
18
|
+
}
|
|
19
|
+
function getRemovable(closable, closeIcon, editable, disabled) {
|
|
20
|
+
if (!editable || disabled || closable === false || closable === void 0 && (isEmptyElement(closeIcon) || closeIcon === null)) return false;
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
var VC_TABS_DOUBLE_QUOTE = "TABS_DQ";
|
|
24
|
+
function genDataNodeKey(key) {
|
|
25
|
+
return String(key).replace(/"/g, VC_TABS_DOUBLE_QUOTE);
|
|
26
|
+
}
|
|
27
|
+
export { genDataNodeKey, getRemovable, getUUid, setUUid, stringify, tabsGlobal };
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@v-c/tabs",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"description": "tabs ui component for react",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"decimal"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"package.json"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./dist/*": "./dist/*",
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"main": "index.js",
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"vue": "^3.0.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@v-c/dropdown": "^1.0.0",
|
|
33
|
+
"@v-c/overflow": "^1.0.0",
|
|
34
|
+
"@v-c/menu": "^1.0.0",
|
|
35
|
+
"@v-c/util": "^1.0.1",
|
|
36
|
+
"@v-c/resize-observer": "^1.0.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "vite build",
|
|
40
|
+
"prepublish": "pnpm build",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"bump": "bumpp --release patch"
|
|
43
|
+
}
|
|
44
|
+
}
|