vant 4.7.3 → 4.8.0

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 (51) hide show
  1. package/es/calendar/Calendar.mjs +20 -17
  2. package/es/checkbox/Checker.mjs +7 -1
  3. package/es/col/Col.mjs +11 -3
  4. package/es/config-provider/types.d.ts +1 -1
  5. package/es/highlight/Highlight.d.ts +96 -0
  6. package/es/highlight/Highlight.mjs +122 -0
  7. package/es/highlight/index.css +1 -0
  8. package/es/highlight/index.d.ts +73 -0
  9. package/es/highlight/index.mjs +10 -0
  10. package/es/highlight/style/index.d.ts +1 -0
  11. package/es/highlight/style/index.mjs +2 -0
  12. package/es/highlight/types.d.ts +3 -0
  13. package/es/highlight/types.mjs +0 -0
  14. package/es/image-preview/ImagePreview.mjs +10 -0
  15. package/es/image-preview/ImagePreviewItem.d.ts +27 -1
  16. package/es/image-preview/ImagePreviewItem.mjs +17 -12
  17. package/es/image-preview/types.d.ts +7 -0
  18. package/es/index.d.ts +2 -1
  19. package/es/index.mjs +4 -1
  20. package/es/row/Row.d.ts +8 -4
  21. package/es/row/Row.mjs +35 -4
  22. package/es/row/index.d.ts +3 -3
  23. package/lib/calendar/Calendar.js +20 -17
  24. package/lib/checkbox/Checker.js +7 -1
  25. package/lib/col/Col.js +10 -2
  26. package/lib/config-provider/types.d.ts +1 -1
  27. package/lib/highlight/Highlight.d.ts +96 -0
  28. package/lib/highlight/Highlight.js +141 -0
  29. package/lib/highlight/index.css +1 -0
  30. package/lib/highlight/index.d.ts +73 -0
  31. package/lib/highlight/index.js +39 -0
  32. package/lib/highlight/style/index.d.ts +1 -0
  33. package/lib/highlight/style/index.js +2 -0
  34. package/lib/highlight/types.d.ts +3 -0
  35. package/lib/highlight/types.js +15 -0
  36. package/lib/image-preview/ImagePreview.js +10 -0
  37. package/lib/image-preview/ImagePreviewItem.d.ts +27 -1
  38. package/lib/image-preview/ImagePreviewItem.js +17 -12
  39. package/lib/image-preview/types.d.ts +7 -0
  40. package/lib/index.css +1 -1
  41. package/lib/index.d.ts +2 -1
  42. package/lib/index.js +4 -1
  43. package/lib/row/Row.d.ts +8 -4
  44. package/lib/row/Row.js +34 -3
  45. package/lib/row/index.d.ts +3 -3
  46. package/lib/vant.cjs.js +775 -594
  47. package/lib/vant.es.js +775 -594
  48. package/lib/vant.js +775 -594
  49. package/lib/vant.min.js +1 -1
  50. package/lib/web-types.json +1 -1
  51. package/package.json +2 -2
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: (NumberConstructor | StringConstructor)[];
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: (NumberConstructor | StringConstructor)[];
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: (NumberConstructor | StringConstructor)[];
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, makeNumericProp, createNamespace } from "../utils/index.mjs";
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: makeNumericProp(0),
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
- const gutter = Number(props.gutter);
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: (NumberConstructor | StringConstructor)[];
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: (NumberConstructor | StringConstructor)[];
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';
@@ -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
- text: "",
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
- text: currentMonth.getTitle(),
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 = () => (0, import_vue.createVNode)("div", {
398
- "class": (0, import_utils2.bem)()
399
- }, [(0, import_vue.createVNode)(import_CalendarHeader.default, {
400
- "date": subtitle.value.date,
401
- "title": props.title,
402
- "subtitle": subtitle.value.text,
403
- "showTitle": props.showTitle,
404
- "showSubtitle": props.showSubtitle,
405
- "firstDayOfWeek": dayOffset.value,
406
- "onClickSubtitle": (event) => emit("clickSubtitle", event)
407
- }, (0, import_utils.pick)(slots, ["title", "subtitle"])), (0, import_vue.createVNode)("div", {
408
- "ref": bodyRef,
409
- "class": (0, import_utils2.bem)("body"),
410
- "onScroll": onScroll
411
- }, [months.value.map(renderMonth)]), renderFooter()]);
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) => {
@@ -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
- return {
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)}
@@ -0,0 +1,73 @@
1
+ export declare const Highlight: import("../utils").WithInstall<import("vue").DefineComponent<{
2
+ autoEscape: {
3
+ type: BooleanConstructor;
4
+ default: true;
5
+ };
6
+ caseSensitive: BooleanConstructor;
7
+ highlightClass: StringConstructor;
8
+ highlightTag: {
9
+ type: import("vue").PropType<keyof HTMLElementTagNameMap>;
10
+ default: keyof HTMLElementTagNameMap;
11
+ };
12
+ keywords: {
13
+ type: import("vue").PropType<string | string[]>;
14
+ required: true;
15
+ };
16
+ sourceString: {
17
+ type: import("vue").PropType<string>;
18
+ default: string;
19
+ };
20
+ tag: {
21
+ type: import("vue").PropType<keyof HTMLElementTagNameMap>;
22
+ default: keyof HTMLElementTagNameMap;
23
+ };
24
+ unhighlightClass: StringConstructor;
25
+ unhighlightTag: {
26
+ type: import("vue").PropType<keyof HTMLElementTagNameMap>;
27
+ default: keyof HTMLElementTagNameMap;
28
+ };
29
+ }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
30
+ autoEscape: {
31
+ type: BooleanConstructor;
32
+ default: true;
33
+ };
34
+ caseSensitive: BooleanConstructor;
35
+ highlightClass: StringConstructor;
36
+ highlightTag: {
37
+ type: import("vue").PropType<keyof HTMLElementTagNameMap>;
38
+ default: keyof HTMLElementTagNameMap;
39
+ };
40
+ keywords: {
41
+ type: import("vue").PropType<string | string[]>;
42
+ required: true;
43
+ };
44
+ sourceString: {
45
+ type: import("vue").PropType<string>;
46
+ default: string;
47
+ };
48
+ tag: {
49
+ type: import("vue").PropType<keyof HTMLElementTagNameMap>;
50
+ default: keyof HTMLElementTagNameMap;
51
+ };
52
+ unhighlightClass: StringConstructor;
53
+ unhighlightTag: {
54
+ type: import("vue").PropType<keyof HTMLElementTagNameMap>;
55
+ default: keyof HTMLElementTagNameMap;
56
+ };
57
+ }>>, {
58
+ tag: keyof HTMLElementTagNameMap;
59
+ autoEscape: boolean;
60
+ caseSensitive: boolean;
61
+ highlightTag: keyof HTMLElementTagNameMap;
62
+ sourceString: string;
63
+ unhighlightTag: keyof HTMLElementTagNameMap;
64
+ }, {}>>;
65
+ export default Highlight;
66
+ export { highlightProps } from './Highlight';
67
+ export type { HighlightProps } from './Highlight';
68
+ export type { HighlightThemeVars } from './types';
69
+ declare module 'vue' {
70
+ interface GlobalComponents {
71
+ vanHighlight: typeof Highlight;
72
+ }
73
+ }
@@ -0,0 +1,39 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var stdin_exports = {};
29
+ __export(stdin_exports, {
30
+ Highlight: () => Highlight,
31
+ default: () => stdin_default,
32
+ highlightProps: () => import_Highlight2.highlightProps
33
+ });
34
+ module.exports = __toCommonJS(stdin_exports);
35
+ var import_utils = require("../utils");
36
+ var import_Highlight = __toESM(require("./Highlight"));
37
+ var import_Highlight2 = require("./Highlight");
38
+ const Highlight = (0, import_utils.withInstall)(import_Highlight.default);
39
+ var stdin_default = Highlight;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ require("../../style/base.css");
2
+ require("../index.css");
@@ -0,0 +1,3 @@
1
+ export type HighlightThemeVars = {
2
+ highlightTagColor?: string;
3
+ };
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var stdin_exports = {};
15
+ module.exports = __toCommonJS(stdin_exports);