vant 4.7.3 → 4.8.1
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 +14 -0
- package/es/calendar/Calendar.mjs +20 -17
- package/es/checkbox/Checker.mjs +7 -1
- package/es/col/Col.mjs +11 -3
- package/es/config-provider/types.d.ts +1 -1
- package/es/highlight/Highlight.d.ts +96 -0
- package/es/highlight/Highlight.mjs +122 -0
- package/es/highlight/index.css +1 -0
- package/es/highlight/index.d.ts +73 -0
- package/es/highlight/index.mjs +10 -0
- package/es/highlight/style/index.d.ts +1 -0
- package/es/highlight/style/index.mjs +2 -0
- package/es/highlight/types.d.ts +3 -0
- package/es/highlight/types.mjs +0 -0
- package/es/image-preview/ImagePreview.mjs +10 -0
- package/es/image-preview/ImagePreviewItem.d.ts +27 -1
- package/es/image-preview/ImagePreviewItem.mjs +17 -12
- package/es/image-preview/types.d.ts +7 -0
- package/es/index.d.ts +2 -1
- package/es/index.mjs +4 -1
- package/es/row/Row.d.ts +8 -4
- package/es/row/Row.mjs +35 -4
- package/es/row/index.d.ts +3 -3
- package/es/text-ellipsis/TextEllipsis.mjs +10 -5
- package/es/text-ellipsis/index.d.ts +1 -1
- package/es/text-ellipsis/types.d.ts +6 -0
- package/lib/calendar/Calendar.js +20 -17
- package/lib/checkbox/Checker.js +7 -1
- package/lib/col/Col.js +10 -2
- package/lib/config-provider/types.d.ts +1 -1
- package/lib/highlight/Highlight.d.ts +96 -0
- package/lib/highlight/Highlight.js +141 -0
- package/lib/highlight/index.css +1 -0
- package/lib/highlight/index.d.ts +73 -0
- package/lib/highlight/index.js +39 -0
- package/lib/highlight/style/index.d.ts +1 -0
- package/lib/highlight/style/index.js +2 -0
- package/lib/highlight/types.d.ts +3 -0
- package/lib/highlight/types.js +15 -0
- package/lib/image-preview/ImagePreview.js +10 -0
- package/lib/image-preview/ImagePreviewItem.d.ts +27 -1
- package/lib/image-preview/ImagePreviewItem.js +17 -12
- package/lib/image-preview/types.d.ts +7 -0
- package/lib/index.css +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -1
- package/lib/row/Row.d.ts +8 -4
- package/lib/row/Row.js +34 -3
- package/lib/row/index.d.ts +3 -3
- package/lib/text-ellipsis/TextEllipsis.js +9 -4
- package/lib/text-ellipsis/index.d.ts +1 -1
- package/lib/text-ellipsis/types.d.ts +6 -0
- package/lib/vant.cjs.js +783 -597
- package/lib/vant.es.js +783 -597
- package/lib/vant.js +783 -597
- package/lib/vant.min.js +1 -1
- package/lib/web-types.json +1 -1
- package/package.json +3 -3
package/es/index.mjs
CHANGED
@@ -40,6 +40,7 @@ import { FloatingPanel } from "./floating-panel/index.mjs";
|
|
40
40
|
import { Form } from "./form/index.mjs";
|
41
41
|
import { Grid } from "./grid/index.mjs";
|
42
42
|
import { GridItem } from "./grid-item/index.mjs";
|
43
|
+
import { Highlight } from "./highlight/index.mjs";
|
43
44
|
import { Icon } from "./icon/index.mjs";
|
44
45
|
import { Image } from "./image/index.mjs";
|
45
46
|
import { ImagePreview } from "./image-preview/index.mjs";
|
@@ -98,7 +99,7 @@ import { Toast } from "./toast/index.mjs";
|
|
98
99
|
import { TreeSelect } from "./tree-select/index.mjs";
|
99
100
|
import { Uploader } from "./uploader/index.mjs";
|
100
101
|
import { Watermark } from "./watermark/index.mjs";
|
101
|
-
const version = "4.
|
102
|
+
const version = "4.8.1";
|
102
103
|
function install(app) {
|
103
104
|
const components = [
|
104
105
|
ActionBar,
|
@@ -143,6 +144,7 @@ function install(app) {
|
|
143
144
|
Form,
|
144
145
|
Grid,
|
145
146
|
GridItem,
|
147
|
+
Highlight,
|
146
148
|
Icon,
|
147
149
|
Image,
|
148
150
|
ImagePreview,
|
@@ -252,6 +254,7 @@ export * from "./floating-panel/index.mjs";
|
|
252
254
|
export * from "./form/index.mjs";
|
253
255
|
export * from "./grid/index.mjs";
|
254
256
|
export * from "./grid-item/index.mjs";
|
257
|
+
export * from "./highlight/index.mjs";
|
255
258
|
export * from "./icon/index.mjs";
|
256
259
|
export * from "./image/index.mjs";
|
257
260
|
export * from "./image-preview/index.mjs";
|
package/es/row/Row.d.ts
CHANGED
@@ -3,8 +3,12 @@ export type RowSpaces = {
|
|
3
3
|
left?: number;
|
4
4
|
right: number;
|
5
5
|
}[];
|
6
|
+
export type VerticalSpaces = {
|
7
|
+
bottom?: number;
|
8
|
+
}[];
|
6
9
|
export type RowProvide = {
|
7
10
|
spaces: ComputedRef<RowSpaces>;
|
11
|
+
verticalSpaces: ComputedRef<VerticalSpaces>;
|
8
12
|
};
|
9
13
|
export declare const ROW_KEY: InjectionKey<RowProvide>;
|
10
14
|
export type RowAlign = 'top' | 'center' | 'bottom';
|
@@ -20,7 +24,7 @@ export declare const rowProps: {
|
|
20
24
|
};
|
21
25
|
align: PropType<RowAlign>;
|
22
26
|
gutter: {
|
23
|
-
type: (
|
27
|
+
type: PropType<string | number | (string | number)[]>;
|
24
28
|
default: number;
|
25
29
|
};
|
26
30
|
justify: PropType<RowJustify>;
|
@@ -37,7 +41,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
37
41
|
};
|
38
42
|
align: PropType<RowAlign>;
|
39
43
|
gutter: {
|
40
|
-
type: (
|
44
|
+
type: PropType<string | number | (string | number)[]>;
|
41
45
|
default: number;
|
42
46
|
};
|
43
47
|
justify: PropType<RowJustify>;
|
@@ -52,13 +56,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
52
56
|
};
|
53
57
|
align: PropType<RowAlign>;
|
54
58
|
gutter: {
|
55
|
-
type: (
|
59
|
+
type: PropType<string | number | (string | number)[]>;
|
56
60
|
default: number;
|
57
61
|
};
|
58
62
|
justify: PropType<RowJustify>;
|
59
63
|
}>>, {
|
60
64
|
tag: keyof HTMLElementTagNameMap;
|
61
65
|
wrap: boolean;
|
62
|
-
gutter: string | number;
|
66
|
+
gutter: string | number | (string | number)[];
|
63
67
|
}, {}>;
|
64
68
|
export default _default;
|
package/es/row/Row.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { createVNode as _createVNode } from "vue";
|
2
2
|
import { computed, defineComponent } from "vue";
|
3
|
-
import { truthProp, makeStringProp,
|
3
|
+
import { truthProp, makeStringProp, createNamespace } from "../utils/index.mjs";
|
4
4
|
import { useChildren } from "@vant/use";
|
5
5
|
const [name, bem] = createNamespace("row");
|
6
6
|
const ROW_KEY = Symbol(name);
|
@@ -8,7 +8,10 @@ const rowProps = {
|
|
8
8
|
tag: makeStringProp("div"),
|
9
9
|
wrap: truthProp,
|
10
10
|
align: String,
|
11
|
-
gutter:
|
11
|
+
gutter: {
|
12
|
+
type: [String, Number, Array],
|
13
|
+
default: 0
|
14
|
+
},
|
12
15
|
justify: String
|
13
16
|
};
|
14
17
|
var stdin_default = defineComponent({
|
@@ -36,7 +39,12 @@ var stdin_default = defineComponent({
|
|
36
39
|
return groups2;
|
37
40
|
});
|
38
41
|
const spaces = computed(() => {
|
39
|
-
|
42
|
+
let gutter = 0;
|
43
|
+
if (Array.isArray(props.gutter)) {
|
44
|
+
gutter = Number(props.gutter[0]) || 0;
|
45
|
+
} else {
|
46
|
+
gutter = Number(props.gutter);
|
47
|
+
}
|
40
48
|
const spaces2 = [];
|
41
49
|
if (!gutter) {
|
42
50
|
return spaces2;
|
@@ -60,8 +68,31 @@ var stdin_default = defineComponent({
|
|
60
68
|
});
|
61
69
|
return spaces2;
|
62
70
|
});
|
71
|
+
const verticalSpaces = computed(() => {
|
72
|
+
const {
|
73
|
+
gutter
|
74
|
+
} = props;
|
75
|
+
const spaces2 = [];
|
76
|
+
if (Array.isArray(gutter) && gutter.length > 1) {
|
77
|
+
const bottom = Number(gutter[1]) || 0;
|
78
|
+
if (bottom <= 0) {
|
79
|
+
return spaces2;
|
80
|
+
}
|
81
|
+
groups.value.forEach((group, index) => {
|
82
|
+
if (index === groups.value.length - 1)
|
83
|
+
return;
|
84
|
+
group.forEach(() => {
|
85
|
+
spaces2.push({
|
86
|
+
bottom
|
87
|
+
});
|
88
|
+
});
|
89
|
+
});
|
90
|
+
}
|
91
|
+
return spaces2;
|
92
|
+
});
|
63
93
|
linkChildren({
|
64
|
-
spaces
|
94
|
+
spaces,
|
95
|
+
verticalSpaces
|
65
96
|
});
|
66
97
|
return () => {
|
67
98
|
const {
|
package/es/row/index.d.ts
CHANGED
@@ -9,7 +9,7 @@ export declare const Row: import("../utils").WithInstall<import("vue").DefineCom
|
|
9
9
|
};
|
10
10
|
align: import("vue").PropType<import("./Row").RowAlign>;
|
11
11
|
gutter: {
|
12
|
-
type: (
|
12
|
+
type: import("vue").PropType<string | number | (string | number)[]>;
|
13
13
|
default: number;
|
14
14
|
};
|
15
15
|
justify: import("vue").PropType<import("./Row").RowJustify>;
|
@@ -24,14 +24,14 @@ export declare const Row: import("../utils").WithInstall<import("vue").DefineCom
|
|
24
24
|
};
|
25
25
|
align: import("vue").PropType<import("./Row").RowAlign>;
|
26
26
|
gutter: {
|
27
|
-
type: (
|
27
|
+
type: import("vue").PropType<string | number | (string | number)[]>;
|
28
28
|
default: number;
|
29
29
|
};
|
30
30
|
justify: import("vue").PropType<import("./Row").RowJustify>;
|
31
31
|
}>>, {
|
32
32
|
tag: keyof HTMLElementTagNameMap;
|
33
33
|
wrap: boolean;
|
34
|
-
gutter: string | number;
|
34
|
+
gutter: string | number | (string | number)[];
|
35
35
|
}, {}>>;
|
36
36
|
export default Row;
|
37
37
|
export { rowProps } from './Row';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { createVNode as _createVNode } from "vue";
|
2
2
|
import { ref, watch, computed, onMounted, defineComponent } from "vue";
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { makeNumericProp, makeStringProp, createNamespace, windowWidth } from "../utils/index.mjs";
|
4
|
+
import { useExpose } from "../composables/use-expose.mjs";
|
5
5
|
const [name, bem] = createNamespace("text-ellipsis");
|
6
6
|
const textEllipsisProps = {
|
7
7
|
rows: makeNumericProp(1),
|
@@ -117,8 +117,11 @@ var stdin_default = defineComponent({
|
|
117
117
|
}
|
118
118
|
document.body.removeChild(container);
|
119
119
|
};
|
120
|
+
const toggle = (isExpanded = !expanded.value) => {
|
121
|
+
expanded.value = isExpanded;
|
122
|
+
};
|
120
123
|
const onClickAction = (event) => {
|
121
|
-
|
124
|
+
toggle();
|
122
125
|
emit("clickAction", event);
|
123
126
|
};
|
124
127
|
const renderAction = () => _createVNode("span", {
|
@@ -126,8 +129,10 @@ var stdin_default = defineComponent({
|
|
126
129
|
"onClick": onClickAction
|
127
130
|
}, [actionText.value]);
|
128
131
|
onMounted(calcEllipsised);
|
129
|
-
watch(() => [props.content, props.rows, props.position], calcEllipsised);
|
130
|
-
|
132
|
+
watch([windowWidth, () => [props.content, props.rows, props.position]], calcEllipsised);
|
133
|
+
useExpose({
|
134
|
+
toggle
|
135
|
+
});
|
131
136
|
return () => _createVNode("div", {
|
132
137
|
"ref": root,
|
133
138
|
"class": bem()
|
@@ -61,7 +61,7 @@ export declare const TextEllipsis: import("../utils").WithInstall<import("vue").
|
|
61
61
|
export default TextEllipsis;
|
62
62
|
export { textEllipsisProps } from './TextEllipsis';
|
63
63
|
export type { TextEllipsisProps } from './TextEllipsis';
|
64
|
-
export type { TextEllipsisThemeVars } from './types';
|
64
|
+
export type { TextEllipsisInstance, TextEllipsisThemeVars } from './types';
|
65
65
|
declare module 'vue' {
|
66
66
|
interface GlobalComponents {
|
67
67
|
VanTextEllipsis: typeof TextEllipsis;
|
@@ -1,3 +1,9 @@
|
|
1
|
+
import type { ComponentPublicInstance } from 'vue';
|
2
|
+
import type { TextEllipsisProps } from './TextEllipsis';
|
3
|
+
export type TextEllipsisExpose = {
|
4
|
+
toggle: (expanded?: boolean) => void;
|
5
|
+
};
|
6
|
+
export type TextEllipsisInstance = ComponentPublicInstance<TextEllipsisProps, TextEllipsisExpose>;
|
1
7
|
export type TextEllipsisThemeVars = {
|
2
8
|
textEllipsisActionColor?: string;
|
3
9
|
};
|
package/lib/calendar/Calendar.js
CHANGED
@@ -140,7 +140,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
140
140
|
let bodyHeight;
|
141
141
|
const bodyRef = (0, import_vue2.ref)();
|
142
142
|
const subtitle = (0, import_vue2.ref)({
|
143
|
-
|
143
|
+
textFn: () => "",
|
144
144
|
date: void 0
|
145
145
|
});
|
146
146
|
const currentDate = (0, import_vue2.ref)(getInitialDate());
|
@@ -204,7 +204,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
204
204
|
});
|
205
205
|
if (currentMonth) {
|
206
206
|
subtitle.value = {
|
207
|
-
|
207
|
+
textFn: currentMonth.getTitle,
|
208
208
|
date: currentMonth.date
|
209
209
|
};
|
210
210
|
}
|
@@ -394,21 +394,24 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
394
394
|
"van-safe-area-bottom": props.safeAreaInsetBottom
|
395
395
|
}]
|
396
396
|
}, [renderFooterButton()]);
|
397
|
-
const renderCalendar = () =>
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
"
|
410
|
-
|
411
|
-
|
397
|
+
const renderCalendar = () => {
|
398
|
+
const subTitle = subtitle.value.textFn();
|
399
|
+
return (0, import_vue.createVNode)("div", {
|
400
|
+
"class": (0, import_utils2.bem)()
|
401
|
+
}, [(0, import_vue.createVNode)(import_CalendarHeader.default, {
|
402
|
+
"date": subtitle.value.date,
|
403
|
+
"title": props.title,
|
404
|
+
"subtitle": subTitle,
|
405
|
+
"showTitle": props.showTitle,
|
406
|
+
"showSubtitle": props.showSubtitle,
|
407
|
+
"firstDayOfWeek": dayOffset.value,
|
408
|
+
"onClickSubtitle": (event) => emit("clickSubtitle", event)
|
409
|
+
}, (0, import_utils.pick)(slots, ["title", "subtitle"])), (0, import_vue.createVNode)("div", {
|
410
|
+
"ref": bodyRef,
|
411
|
+
"class": (0, import_utils2.bem)("body"),
|
412
|
+
"onScroll": onScroll
|
413
|
+
}, [months.value.map(renderMonth)]), renderFooter()]);
|
414
|
+
};
|
412
415
|
(0, import_vue2.watch)(() => props.show, init);
|
413
416
|
(0, import_vue2.watch)(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
|
414
417
|
(0, import_vue2.watch)(() => props.defaultDate, (value = null) => {
|
package/lib/checkbox/Checker.js
CHANGED
@@ -131,12 +131,18 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
131
131
|
}, null)]);
|
132
132
|
};
|
133
133
|
const renderLabel = () => {
|
134
|
+
const {
|
135
|
+
checked
|
136
|
+
} = props;
|
134
137
|
if (slots.default) {
|
135
138
|
return (0, import_vue.createVNode)("span", {
|
136
139
|
"class": props.bem("label", [props.labelPosition, {
|
137
140
|
disabled: disabled.value
|
138
141
|
}])
|
139
|
-
}, [slots.default(
|
142
|
+
}, [slots.default({
|
143
|
+
checked,
|
144
|
+
disabled: disabled.value
|
145
|
+
})]);
|
140
146
|
}
|
141
147
|
};
|
142
148
|
return () => {
|
package/lib/col/Col.js
CHANGED
@@ -47,18 +47,26 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
47
47
|
return;
|
48
48
|
}
|
49
49
|
const {
|
50
|
-
spaces
|
50
|
+
spaces,
|
51
|
+
verticalSpaces
|
51
52
|
} = parent;
|
53
|
+
let styles = {};
|
52
54
|
if (spaces && spaces.value && spaces.value[index.value]) {
|
53
55
|
const {
|
54
56
|
left,
|
55
57
|
right
|
56
58
|
} = spaces.value[index.value];
|
57
|
-
|
59
|
+
styles = {
|
58
60
|
paddingLeft: left ? `${left}px` : null,
|
59
61
|
paddingRight: right ? `${right}px` : null
|
60
62
|
};
|
61
63
|
}
|
64
|
+
const {
|
65
|
+
bottom
|
66
|
+
} = verticalSpaces.value[index.value] || {};
|
67
|
+
return (0, import_utils.extend)(styles, {
|
68
|
+
marginBottom: bottom ? `${bottom}px` : null
|
69
|
+
});
|
62
70
|
});
|
63
71
|
return () => {
|
64
72
|
const {
|
@@ -57,5 +57,5 @@ type BaseThemeVars = {
|
|
57
57
|
radiusLg?: string;
|
58
58
|
radiusMax?: string;
|
59
59
|
};
|
60
|
-
export type ConfigProviderThemeVars = BaseThemeVars & import('../action-bar').ActionBarThemeVars & import('../action-bar-button').ActionBarButtonThemeVars & import('../action-bar-icon').ActionBarIconThemeVars & import('../action-sheet').ActionSheetThemeVars & import('../address-edit').AddressEditThemeVars & import('../address-list').AddressListThemeVars & import('../back-top').BackTopThemeVars & import('../badge').BadgeThemeVars & import('../barrage').BarrageThemeVars & import('../button').ButtonThemeVars & import('../calendar').CalendarThemeVars & import('../card').CardThemeVars & import('../cascader').CascaderThemeVars & import('../cell').CellThemeVars & import('../cell-group').CellGroupThemeVars & import('../checkbox').CheckboxThemeVars & import('../circle').CircleThemeVars & import('../collapse-item').CollapseItemThemeVars & import('../contact-card').ContactCardThemeVars & import('../contact-edit').ContactEditThemeVars & import('../contact-list').ContactListThemeVars & import('../count-down').CountDownThemeVars & import('../coupon').CouponThemeVars & import('../coupon-cell').CouponCellThemeVars & import('../coupon-list').CouponListThemeVars & import('../dialog').DialogThemeVars & import('../divider').DividerThemeVars & import('../dropdown-item').DropdownItemThemeVars & import('../dropdown-menu').DropdownMenuThemeVars & import('../empty').EmptyThemeVars & import('../field').FieldThemeVars & import('../floating-bubble').FloatingBubbleThemeVars & import('../floating-panel').FloatingPanelThemeVars & import('../grid-item').GridItemThemeVars & import('../image').ImageThemeVars & import('../image-preview').ImagePreviewThemeVars & import('../index-anchor').IndexAnchorThemeVars & import('../index-bar').IndexBarThemeVars & import('../list').ListThemeVars & import('../loading').LoadingThemeVars & import('../nav-bar').NavBarThemeVars & import('../notice-bar').NoticeBarThemeVars & import('../notify').NotifyThemeVars & import('../number-keyboard').NumberKeyboardThemeVars & import('../overlay').OverlayThemeVars & import('../pagination').PaginationThemeVars & import('../password-input').PasswordInputThemeVars & import('../picker').PickerThemeVars & import('../picker-group').PickerGroupThemeVars & import('../popover').PopoverThemeVars & import('../popup').PopupThemeVars & import('../progress').ProgressThemeVars & import('../pull-refresh').PullRefreshThemeVars & import('../radio').RadioThemeVars & import('../rate').RateThemeVars & import('../rolling-text').RollingTextThemeVars & import('../search').SearchThemeVars & import('../share-sheet').ShareSheetThemeVars & import('../sidebar').SidebarThemeVars & import('../sidebar-item').SidebarItemThemeVars & import('../signature').SignatureThemeVars & import('../skeleton').SkeletonThemeVars & import('../slider').SliderThemeVars & import('../step').StepThemeVars & import('../stepper').StepperThemeVars & import('../steps').StepsThemeVars & import('../sticky').StickyThemeVars & import('../submit-bar').SubmitBarThemeVars & import('../swipe').SwipeThemeVars & import('../switch').SwitchThemeVars & import('../tabbar').TabbarThemeVars & import('../tabbar-item').TabbarItemThemeVars & import('../tabs').TabsThemeVars & import('../tag').TagThemeVars & import('../toast').ToastThemeVars & import('../tree-select').TreeSelectThemeVars & import('../uploader').UploaderThemeVars & import('../watermark').WatermarkThemeVars;
|
60
|
+
export type ConfigProviderThemeVars = BaseThemeVars & import('../action-bar').ActionBarThemeVars & import('../action-bar-button').ActionBarButtonThemeVars & import('../action-bar-icon').ActionBarIconThemeVars & import('../action-sheet').ActionSheetThemeVars & import('../address-edit').AddressEditThemeVars & import('../address-list').AddressListThemeVars & import('../back-top').BackTopThemeVars & import('../badge').BadgeThemeVars & import('../barrage').BarrageThemeVars & import('../button').ButtonThemeVars & import('../calendar').CalendarThemeVars & import('../card').CardThemeVars & import('../cascader').CascaderThemeVars & import('../cell').CellThemeVars & import('../cell-group').CellGroupThemeVars & import('../checkbox').CheckboxThemeVars & import('../circle').CircleThemeVars & import('../collapse-item').CollapseItemThemeVars & import('../contact-card').ContactCardThemeVars & import('../contact-edit').ContactEditThemeVars & import('../contact-list').ContactListThemeVars & import('../count-down').CountDownThemeVars & import('../coupon').CouponThemeVars & import('../coupon-cell').CouponCellThemeVars & import('../coupon-list').CouponListThemeVars & import('../dialog').DialogThemeVars & import('../divider').DividerThemeVars & import('../dropdown-item').DropdownItemThemeVars & import('../dropdown-menu').DropdownMenuThemeVars & import('../empty').EmptyThemeVars & import('../highlight').HighlightThemeVars & import('../field').FieldThemeVars & import('../floating-bubble').FloatingBubbleThemeVars & import('../floating-panel').FloatingPanelThemeVars & import('../grid-item').GridItemThemeVars & import('../image').ImageThemeVars & import('../image-preview').ImagePreviewThemeVars & import('../index-anchor').IndexAnchorThemeVars & import('../index-bar').IndexBarThemeVars & import('../list').ListThemeVars & import('../loading').LoadingThemeVars & import('../nav-bar').NavBarThemeVars & import('../notice-bar').NoticeBarThemeVars & import('../notify').NotifyThemeVars & import('../number-keyboard').NumberKeyboardThemeVars & import('../overlay').OverlayThemeVars & import('../pagination').PaginationThemeVars & import('../password-input').PasswordInputThemeVars & import('../picker').PickerThemeVars & import('../picker-group').PickerGroupThemeVars & import('../popover').PopoverThemeVars & import('../popup').PopupThemeVars & import('../progress').ProgressThemeVars & import('../pull-refresh').PullRefreshThemeVars & import('../radio').RadioThemeVars & import('../rate').RateThemeVars & import('../rolling-text').RollingTextThemeVars & import('../search').SearchThemeVars & import('../share-sheet').ShareSheetThemeVars & import('../sidebar').SidebarThemeVars & import('../sidebar-item').SidebarItemThemeVars & import('../signature').SignatureThemeVars & import('../skeleton').SkeletonThemeVars & import('../slider').SliderThemeVars & import('../step').StepThemeVars & import('../stepper').StepperThemeVars & import('../steps').StepsThemeVars & import('../sticky').StickyThemeVars & import('../submit-bar').SubmitBarThemeVars & import('../swipe').SwipeThemeVars & import('../switch').SwitchThemeVars & import('../tabbar').TabbarThemeVars & import('../tabbar-item').TabbarItemThemeVars & import('../tabs').TabsThemeVars & import('../tag').TagThemeVars & import('../toast').ToastThemeVars & import('../tree-select').TreeSelectThemeVars & import('../uploader').UploaderThemeVars & import('../watermark').WatermarkThemeVars;
|
61
61
|
export {};
|
@@ -0,0 +1,96 @@
|
|
1
|
+
import { type ExtractPropTypes, type PropType } from 'vue';
|
2
|
+
export declare const highlightProps: {
|
3
|
+
autoEscape: {
|
4
|
+
type: BooleanConstructor;
|
5
|
+
default: true;
|
6
|
+
};
|
7
|
+
caseSensitive: BooleanConstructor;
|
8
|
+
highlightClass: StringConstructor;
|
9
|
+
highlightTag: {
|
10
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
11
|
+
default: keyof HTMLElementTagNameMap;
|
12
|
+
};
|
13
|
+
keywords: {
|
14
|
+
type: PropType<string | string[]>;
|
15
|
+
required: true;
|
16
|
+
};
|
17
|
+
sourceString: {
|
18
|
+
type: PropType<string>;
|
19
|
+
default: string;
|
20
|
+
};
|
21
|
+
tag: {
|
22
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
23
|
+
default: keyof HTMLElementTagNameMap;
|
24
|
+
};
|
25
|
+
unhighlightClass: StringConstructor;
|
26
|
+
unhighlightTag: {
|
27
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
28
|
+
default: keyof HTMLElementTagNameMap;
|
29
|
+
};
|
30
|
+
};
|
31
|
+
export type HighlightProps = ExtractPropTypes<typeof highlightProps>;
|
32
|
+
declare const _default: import("vue").DefineComponent<{
|
33
|
+
autoEscape: {
|
34
|
+
type: BooleanConstructor;
|
35
|
+
default: true;
|
36
|
+
};
|
37
|
+
caseSensitive: BooleanConstructor;
|
38
|
+
highlightClass: StringConstructor;
|
39
|
+
highlightTag: {
|
40
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
41
|
+
default: keyof HTMLElementTagNameMap;
|
42
|
+
};
|
43
|
+
keywords: {
|
44
|
+
type: PropType<string | string[]>;
|
45
|
+
required: true;
|
46
|
+
};
|
47
|
+
sourceString: {
|
48
|
+
type: PropType<string>;
|
49
|
+
default: string;
|
50
|
+
};
|
51
|
+
tag: {
|
52
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
53
|
+
default: keyof HTMLElementTagNameMap;
|
54
|
+
};
|
55
|
+
unhighlightClass: StringConstructor;
|
56
|
+
unhighlightTag: {
|
57
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
58
|
+
default: keyof HTMLElementTagNameMap;
|
59
|
+
};
|
60
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
|
61
|
+
autoEscape: {
|
62
|
+
type: BooleanConstructor;
|
63
|
+
default: true;
|
64
|
+
};
|
65
|
+
caseSensitive: BooleanConstructor;
|
66
|
+
highlightClass: StringConstructor;
|
67
|
+
highlightTag: {
|
68
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
69
|
+
default: keyof HTMLElementTagNameMap;
|
70
|
+
};
|
71
|
+
keywords: {
|
72
|
+
type: PropType<string | string[]>;
|
73
|
+
required: true;
|
74
|
+
};
|
75
|
+
sourceString: {
|
76
|
+
type: PropType<string>;
|
77
|
+
default: string;
|
78
|
+
};
|
79
|
+
tag: {
|
80
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
81
|
+
default: keyof HTMLElementTagNameMap;
|
82
|
+
};
|
83
|
+
unhighlightClass: StringConstructor;
|
84
|
+
unhighlightTag: {
|
85
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
86
|
+
default: keyof HTMLElementTagNameMap;
|
87
|
+
};
|
88
|
+
}>>, {
|
89
|
+
tag: keyof HTMLElementTagNameMap;
|
90
|
+
autoEscape: boolean;
|
91
|
+
caseSensitive: boolean;
|
92
|
+
highlightTag: keyof HTMLElementTagNameMap;
|
93
|
+
sourceString: string;
|
94
|
+
unhighlightTag: keyof HTMLElementTagNameMap;
|
95
|
+
}, {}>;
|
96
|
+
export default _default;
|
@@ -0,0 +1,141 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name2 in all)
|
7
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var stdin_exports = {};
|
19
|
+
__export(stdin_exports, {
|
20
|
+
default: () => stdin_default,
|
21
|
+
highlightProps: () => highlightProps
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(stdin_exports);
|
24
|
+
var import_vue = require("vue");
|
25
|
+
var import_vue2 = require("vue");
|
26
|
+
var import_utils = require("../utils");
|
27
|
+
const [name, bem] = (0, import_utils.createNamespace)("highlight");
|
28
|
+
const highlightProps = {
|
29
|
+
autoEscape: import_utils.truthProp,
|
30
|
+
caseSensitive: Boolean,
|
31
|
+
highlightClass: String,
|
32
|
+
highlightTag: (0, import_utils.makeStringProp)("span"),
|
33
|
+
keywords: (0, import_utils.makeRequiredProp)([String, Array]),
|
34
|
+
sourceString: (0, import_utils.makeStringProp)(""),
|
35
|
+
tag: (0, import_utils.makeStringProp)("div"),
|
36
|
+
unhighlightClass: String,
|
37
|
+
unhighlightTag: (0, import_utils.makeStringProp)("span")
|
38
|
+
};
|
39
|
+
var stdin_default = (0, import_vue2.defineComponent)({
|
40
|
+
name,
|
41
|
+
props: highlightProps,
|
42
|
+
setup(props) {
|
43
|
+
const highlightChunks = (0, import_vue2.computed)(() => {
|
44
|
+
const {
|
45
|
+
autoEscape,
|
46
|
+
caseSensitive,
|
47
|
+
keywords,
|
48
|
+
sourceString
|
49
|
+
} = props;
|
50
|
+
const flags = caseSensitive ? "g" : "gi";
|
51
|
+
const _keywords = Array.isArray(keywords) ? keywords : [keywords];
|
52
|
+
let chunks = _keywords.filter((keyword) => keyword).reduce((chunks2, keyword) => {
|
53
|
+
if (autoEscape) {
|
54
|
+
keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
55
|
+
}
|
56
|
+
const regex = new RegExp(keyword, flags);
|
57
|
+
let match;
|
58
|
+
while (match = regex.exec(sourceString)) {
|
59
|
+
const start = match.index;
|
60
|
+
const end = regex.lastIndex;
|
61
|
+
if (start >= end) {
|
62
|
+
regex.lastIndex++;
|
63
|
+
continue;
|
64
|
+
}
|
65
|
+
chunks2.push({
|
66
|
+
start,
|
67
|
+
end,
|
68
|
+
highlight: true
|
69
|
+
});
|
70
|
+
}
|
71
|
+
return chunks2;
|
72
|
+
}, []);
|
73
|
+
chunks = chunks.sort((a, b) => a.start - b.start).reduce((chunks2, currentChunk) => {
|
74
|
+
const prevChunk = chunks2[chunks2.length - 1];
|
75
|
+
if (!prevChunk || currentChunk.start > prevChunk.end) {
|
76
|
+
const unhighlightStart = prevChunk ? prevChunk.end : 0;
|
77
|
+
const unhighlightEnd = currentChunk.start;
|
78
|
+
if (unhighlightStart !== unhighlightEnd) {
|
79
|
+
chunks2.push({
|
80
|
+
start: unhighlightStart,
|
81
|
+
end: unhighlightEnd,
|
82
|
+
highlight: false
|
83
|
+
});
|
84
|
+
}
|
85
|
+
chunks2.push(currentChunk);
|
86
|
+
} else {
|
87
|
+
prevChunk.end = Math.max(prevChunk.end, currentChunk.end);
|
88
|
+
}
|
89
|
+
return chunks2;
|
90
|
+
}, []);
|
91
|
+
const lastChunk = chunks[chunks.length - 1];
|
92
|
+
if (lastChunk && lastChunk.end < sourceString.length) {
|
93
|
+
chunks.push({
|
94
|
+
start: lastChunk.end,
|
95
|
+
end: sourceString.length,
|
96
|
+
highlight: false
|
97
|
+
});
|
98
|
+
}
|
99
|
+
return chunks;
|
100
|
+
});
|
101
|
+
const renderContent = () => {
|
102
|
+
const {
|
103
|
+
sourceString,
|
104
|
+
highlightClass,
|
105
|
+
unhighlightClass,
|
106
|
+
highlightTag,
|
107
|
+
unhighlightTag
|
108
|
+
} = props;
|
109
|
+
return highlightChunks.value.map((chunk) => {
|
110
|
+
const {
|
111
|
+
start,
|
112
|
+
end,
|
113
|
+
highlight
|
114
|
+
} = chunk;
|
115
|
+
const text = sourceString.slice(start, end);
|
116
|
+
if (highlight) {
|
117
|
+
return (0, import_vue.createVNode)(highlightTag, {
|
118
|
+
"class": [bem("tag"), highlightClass]
|
119
|
+
}, {
|
120
|
+
default: () => [text]
|
121
|
+
});
|
122
|
+
}
|
123
|
+
return (0, import_vue.createVNode)(unhighlightTag, {
|
124
|
+
"class": unhighlightClass
|
125
|
+
}, {
|
126
|
+
default: () => [text]
|
127
|
+
});
|
128
|
+
});
|
129
|
+
};
|
130
|
+
return () => {
|
131
|
+
const {
|
132
|
+
tag
|
133
|
+
} = props;
|
134
|
+
return (0, import_vue.createVNode)(tag, {
|
135
|
+
"class": bem()
|
136
|
+
}, {
|
137
|
+
default: () => [renderContent()]
|
138
|
+
});
|
139
|
+
};
|
140
|
+
}
|
141
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
:root{--van-highlight-tag-color: var(--van-primary-color)}.van-highlight__tag{color:var(--van-highlight-tag-color)}
|