vue-markdown-design 0.3.1 → 0.3.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.
Files changed (72) hide show
  1. package/README.md +5 -1
  2. package/README.zh-CN.md +4 -0
  3. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.mjs +27 -0
  4. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.mjs +12 -0
  5. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.mjs +25 -0
  6. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.mjs +13 -0
  7. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.mjs +12 -0
  8. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.mjs +14 -0
  9. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.mjs +9 -0
  10. package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.mjs +11 -0
  11. package/es/hooks/use-element/index.mjs +21 -18
  12. package/es/hooks/use-scroll-element/index.mjs +44 -45
  13. package/es/index.mjs +7 -18
  14. package/es/markdown/Markdown.mjs +221 -316
  15. package/es/markdown/index.css +3 -0
  16. package/es/markdown/index2.mjs +6 -0
  17. package/es/render/Render.mjs +143 -173
  18. package/es/render/index.css +37 -21
  19. package/es/render/index2.mjs +6 -0
  20. package/es/search/Search.mjs +236 -285
  21. package/es/search/index.css +4 -0
  22. package/es/search/index2.mjs +6 -0
  23. package/es/sticky/Sticky.mjs +66 -99
  24. package/es/sticky/index2.mjs +6 -0
  25. package/es/toc/Toc.mjs +253 -347
  26. package/es/toc/index2.mjs +6 -0
  27. package/es/utils/constant.mjs +4 -4
  28. package/es/utils/dom.mjs +44 -68
  29. package/es/utils/format.mjs +33 -39
  30. package/es/utils/functions.mjs +5 -5
  31. package/es/utils/vue.mjs +10 -32
  32. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.js +27 -0
  33. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +12 -0
  34. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js +25 -0
  35. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js +13 -0
  36. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.js +12 -0
  37. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.js +14 -0
  38. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +9 -0
  39. package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.js +16 -0
  40. package/lib/_virtual/_rolldown/runtime.js +23 -0
  41. package/lib/hooks/use-element/index.js +23 -19
  42. package/lib/hooks/use-scroll-element/index.js +45 -45
  43. package/lib/index.js +24 -22
  44. package/lib/markdown/Markdown.js +224 -317
  45. package/lib/markdown/index.css +3 -0
  46. package/lib/markdown/index2.js +6 -0
  47. package/lib/render/Render.js +152 -176
  48. package/lib/render/index.css +37 -21
  49. package/lib/render/index2.js +6 -0
  50. package/lib/search/Search.js +242 -287
  51. package/lib/search/index.css +4 -0
  52. package/lib/search/index2.js +6 -0
  53. package/lib/sticky/Sticky.js +68 -99
  54. package/lib/sticky/index2.js +6 -0
  55. package/lib/toc/Toc.js +259 -349
  56. package/lib/toc/index2.js +6 -0
  57. package/lib/utils/constant.js +3 -3
  58. package/lib/utils/dom.js +46 -69
  59. package/lib/utils/format.js +33 -33
  60. package/lib/utils/functions.js +4 -4
  61. package/lib/utils/vue.js +10 -31
  62. package/package.json +4 -9
  63. package/es/markdown/index.mjs +0 -9
  64. package/es/render/index.mjs +0 -9
  65. package/es/search/index.mjs +0 -9
  66. package/es/sticky/index.mjs +0 -7
  67. package/es/toc/index.mjs +0 -9
  68. package/lib/markdown/index.js +0 -8
  69. package/lib/render/index.js +0 -8
  70. package/lib/search/index.js +0 -8
  71. package/lib/sticky/index.js +0 -7
  72. package/lib/toc/index.js +0 -8
@@ -1,292 +1,247 @@
1
- "use strict";
2
- require('./index.css');var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __spreadValues = (a, b) => {
10
- for (var prop in b || (b = {}))
11
- if (__hasOwnProp.call(b, prop))
12
- __defNormalProp(a, prop, b[prop]);
13
- if (__getOwnPropSymbols)
14
- for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- }
18
- return a;
1
+ require('./index.css');const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ const require_objectSpread2 = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js");
3
+ const require_format = require("../utils/format.js");
4
+ ;/* empty css */
5
+ const require_index$1 = ;/* empty css */
6
+ const require_dom = require("../utils/dom.js");
7
+ const require_asyncToGenerator = require("../_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.js");
8
+ let lodash = require("lodash");
9
+ let vue = require("vue");
10
+ let mark_js = require("mark.js");
11
+ mark_js = require_runtime.__toESM(mark_js);
12
+ let _vueuse_core = require("@vueuse/core");
13
+ let _fortawesome_vue_fontawesome = require("@fortawesome/vue-fontawesome");
14
+ let _fortawesome_free_solid_svg_icons = require("@fortawesome/free-solid-svg-icons");
15
+ //#region src/search/Search.tsx
16
+ var inputId = 0;
17
+ var { name, addPrefix } = require_format.createNamespace("search");
18
+ var searchProps = {
19
+ modelValue: {
20
+ type: [String, Number],
21
+ default: ""
22
+ },
23
+ clearable: {
24
+ type: Boolean,
25
+ default: true
26
+ },
27
+ border: {
28
+ type: Boolean,
29
+ default: true
30
+ },
31
+ size: {
32
+ type: String,
33
+ default: "huge"
34
+ },
35
+ disabled: {
36
+ type: Boolean,
37
+ default: false
38
+ },
39
+ placeholder: String,
40
+ target: [
41
+ String,
42
+ Object,
43
+ Function
44
+ ],
45
+ offset: {
46
+ type: [
47
+ String,
48
+ Number,
49
+ Function
50
+ ],
51
+ default: "center"
52
+ },
53
+ smooth: Boolean,
54
+ closeIcon: {
55
+ type: Boolean,
56
+ default: true
57
+ },
58
+ inputAttrs: {
59
+ type: Object,
60
+ default: () => ({})
61
+ }
19
62
  };
20
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- var __async = (__this, __arguments, generator) => {
22
- return new Promise((resolve, reject) => {
23
- var fulfilled = (value) => {
24
- try {
25
- step(generator.next(value));
26
- } catch (e) {
27
- reject(e);
28
- }
29
- };
30
- var rejected = (value) => {
31
- try {
32
- step(generator.throw(value));
33
- } catch (e) {
34
- reject(e);
35
- }
36
- };
37
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
38
- step((generator = generator.apply(__this, __arguments)).next());
39
- });
63
+ var searchEmits = {
64
+ "update:modelValue": (payload) => (0, lodash.isString)(payload),
65
+ input: (payload) => payload instanceof Event,
66
+ blur: (payload) => payload instanceof FocusEvent,
67
+ focus: (payload) => payload instanceof FocusEvent,
68
+ change: (payload) => payload instanceof Event,
69
+ clear: () => true,
70
+ close: () => true,
71
+ stepClick: (payload) => ["prev", "next"].includes(payload),
72
+ totalChange: (payload) => (0, lodash.isNumber)(payload),
73
+ indexChange: (payload) => (0, lodash.isNumber)(payload)
40
74
  };
41
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
42
- const vue = require("vue");
43
- ;/* empty css */
44
- const Mark = require("mark.js");
45
- const format = require("../utils/format.js");
46
- const core = require("@vueuse/core");
47
- const lodash = require("lodash");
48
- const index = require("../hooks/use-element/index.js");
49
- const dom = require("../utils/dom.js");
50
- const vueFontawesome = require("@fortawesome/vue-fontawesome");
51
- const freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
52
- let inputId = 0;
53
- const {
54
- name,
55
- addPrefix
56
- } = format.createNamespace("search");
57
- const searchProps = {
58
- modelValue: {
59
- type: [String, Number],
60
- default: ""
61
- },
62
- clearable: {
63
- type: Boolean,
64
- default: true
65
- },
66
- border: {
67
- type: Boolean,
68
- default: true
69
- },
70
- size: {
71
- type: String,
72
- default: "huge"
73
- },
74
- disabled: {
75
- type: Boolean,
76
- default: false
77
- },
78
- placeholder: String,
79
- target: [String, Object, Function],
80
- offset: {
81
- type: [String, Number, Function],
82
- default: "center"
83
- },
84
- smooth: Boolean,
85
- closeIcon: {
86
- type: Boolean,
87
- default: true
88
- },
89
- inputAttrs: {
90
- type: Object,
91
- default: () => ({})
92
- }
93
- };
94
- const searchEmits = {
95
- "update:modelValue": (payload) => lodash.isString(payload),
96
- input: (payload) => payload instanceof Event,
97
- blur: (payload) => payload instanceof FocusEvent,
98
- focus: (payload) => payload instanceof FocusEvent,
99
- change: (payload) => payload instanceof Event,
100
- clear: () => true,
101
- close: () => true,
102
- stepClick: (payload) => ["prev", "next"].includes(payload),
103
- totalChange: (payload) => lodash.isNumber(payload),
104
- indexChange: (payload) => lodash.isNumber(payload)
105
- };
106
- const _Search = /* @__PURE__ */ vue.defineComponent({
107
- name,
108
- props: searchProps,
109
- emits: searchEmits,
110
- setup(props, {
111
- emit,
112
- expose,
113
- attrs
114
- }) {
115
- const modelValue = core.useVModel(props, "modelValue", emit, {
116
- passive: true
117
- });
118
- const rootClass = vue.computed(() => {
119
- const {
120
- size,
121
- disabled,
122
- border
123
- } = props;
124
- return [name, addPrefix(`--${size}`), {
125
- [addPrefix("--disabled")]: disabled,
126
- [addPrefix("--border")]: border
127
- }];
128
- });
129
- const id = `${name}-${inputId++}`;
130
- const eventAttrs = lodash.chain(["input", "blur", "focus", "change"]).map((key) => [`on${lodash.upperFirst(key)}`, (...arg) => emit(key, ...arg)]).fromPairs().value();
131
- const inputAttrs = vue.computed(() => {
132
- const {
133
- inputAttrs: inputAttrs2,
134
- disabled,
135
- placeholder
136
- } = props;
137
- return __spreadProps(__spreadValues(__spreadValues(__spreadValues({
138
- id
139
- }, lodash.omit(attrs, ["class", "style"])), inputAttrs2), eventAttrs), {
140
- disabled,
141
- placeholder
142
- });
143
- });
144
- const onClear = () => {
145
- if (props.disabled) return;
146
- modelValue.value = "";
147
- emit("clear");
148
- };
149
- const rawIndex = vue.ref(0);
150
- const markList = vue.ref([]);
151
- const escapedVal = vue.computed(() => lodash.escapeRegExp(String(modelValue.value)));
152
- const setMarkList = (el) => {
153
- const item = lodash.last(markList.value);
154
- const keyword = (item == null ? void 0 : item.map((item2) => item2.innerText).join("")) || "";
155
- const regexp = new RegExp(`^${escapedVal.value}$`, "i");
156
- !item || regexp.test(keyword) ? markList.value.push([el]) : item.push(el);
157
- };
158
- const total = vue.computed(() => markList.value.length);
159
- vue.watch(total, (val) => emit("totalChange", val));
160
- const matchesIndex = vue.computed(() => {
161
- return total.value && (rawIndex.value % total.value + total.value) % total.value;
162
- });
163
- vue.watch(matchesIndex, (val) => emit("indexChange", val));
164
- const matchesCount = vue.computed(
165
- // modelValue.value !== '' 不直接判断防止值为0的情况
166
- () => modelValue.value !== "" && total.value && `${matchesIndex.value + 1}/${total.value}`
167
- );
168
- const stepMap = /* @__PURE__ */ new Map([["prev", -1], ["next", 1]]);
169
- const toggle = (index2, ignoreDisabled = true) => {
170
- if (!ignoreDisabled && props.disabled) return;
171
- const offsetVal = stepMap.get(String(index2));
172
- rawIndex.value = offsetVal ? matchesIndex.value + offsetVal : Number(index2);
173
- };
174
- const onStepClick = (direction) => {
175
- if (props.disabled) return;
176
- toggle(direction);
177
- emit("stepClick", direction);
178
- };
179
- const onKeydown = vue.withKeys(
180
- (event) => {
181
- var _a;
182
- return !((_a = event.target) == null ? void 0 : _a.composing) && onStepClick("next");
183
- },
184
- // composing 此处的值为vue3源码中的赋值
185
- ["enter"]
186
- );
187
- const target = vue.computed(() => core.toValue(props.target));
188
- const {
189
- targetEl
190
- } = index.useElement(target);
191
- const markInstance = vue.computed(() => {
192
- return targetEl.value instanceof HTMLElement ? new Mark(targetEl.value) : void 0;
193
- });
194
- vue.watch(targetEl, (el) => {
195
- if (el && !(el instanceof HTMLElement)) {
196
- console.error("[vue-markdown-design] Target is not of the HTMLElement type.");
197
- }
198
- });
199
- const highlightClass = addPrefix("--highlight");
200
- vue.watchEffect(() => {
201
- var _a;
202
- (_a = targetEl.value) == null ? void 0 : _a.querySelectorAll(`.${highlightClass}`).forEach((el) => el.classList.remove(highlightClass));
203
- const currentMark = markList.value.find((_, index2) => index2 === matchesIndex.value);
204
- if (!currentMark) return;
205
- currentMark.forEach((el) => el.classList.add(highlightClass));
206
- const {
207
- offset,
208
- smooth
209
- } = props;
210
- dom.scrollToEl(currentMark[0], {
211
- offset,
212
- smooth,
213
- scrollMode: "if-needed"
214
- });
215
- });
216
- const resetMark = () => {
217
- var _a;
218
- (_a = markInstance.value) == null ? void 0 : _a.unmark();
219
- markList.value = [];
220
- };
221
- const setMark = lodash.debounce(() => {
222
- var _a;
223
- resetMark();
224
- if (!targetEl.value) return;
225
- const regexp = new RegExp(escapedVal.value, "gi");
226
- (_a = markInstance.value) == null ? void 0 : _a.markRegExp(regexp, {
227
- className: addPrefix("--mark"),
228
- acrossElements: true,
229
- each: setMarkList
230
- });
231
- }, 200);
232
- const resetAndMark = () => {
233
- rawIndex.value = 0;
234
- setMark();
235
- };
236
- vue.watch(modelValue, resetAndMark);
237
- vue.onBeforeUnmount(resetMark);
238
- const refresh = (resetIndex = true) => __async(this, null, function* () {
239
- yield vue.nextTick();
240
- resetIndex ? resetAndMark() : setMark();
241
- });
242
- vue.watch([targetEl, () => {
243
- var _a;
244
- return (_a = target.value) == null ? void 0 : _a.htmlStr;
245
- }], () => refresh(), {
246
- immediate: true
247
- });
248
- const inputRef = vue.shallowRef();
249
- expose(__spreadProps(__spreadValues({}, lodash.chain(["focus", "blur"]).map((key) => [key, () => {
250
- var _a;
251
- return (_a = inputRef.value) == null ? void 0 : _a[key]();
252
- }]).fromPairs().value()), {
253
- clear: onClear,
254
- toggle,
255
- refresh
256
- }));
257
- return () => vue.createVNode("div", {
258
- "class": rootClass.value
259
- }, [vue.withDirectives(vue.createVNode("input", vue.mergeProps(inputAttrs.value, {
260
- "onUpdate:modelValue": ($event) => modelValue.value = $event,
261
- "class": addPrefix("__input"),
262
- "ref": inputRef,
263
- "onKeydown": onKeydown
264
- }), null), [[vue.vModelText, modelValue.value]]), modelValue.value && vue.createVNode(vue.Fragment, null, [props.clearable && vue.createVNode("span", {
265
- "class": [addPrefix("__clearable"), addPrefix("__btn")],
266
- "onClick": onClear
267
- }, [vue.createVNode(vueFontawesome.FontAwesomeIcon, {
268
- "size": "xs",
269
- "icon": freeSolidSvgIcons.faCircleXmark
270
- }, null)]), vue.createVNode("span", {
271
- "class": addPrefix("__count")
272
- }, [matchesCount.value]), vue.createVNode("span", {
273
- "class": [addPrefix("__prev"), addPrefix("__btn")],
274
- "onClick": () => onStepClick("prev")
275
- }, [vue.createVNode(vueFontawesome.FontAwesomeIcon, {
276
- "icon": freeSolidSvgIcons.faAngleUp
277
- }, null)]), vue.createVNode("span", {
278
- "class": [addPrefix("__next"), addPrefix("__btn")],
279
- "onClick": () => onStepClick("next")
280
- }, [vue.createVNode(vueFontawesome.FontAwesomeIcon, {
281
- "icon": freeSolidSvgIcons.faAngleDown
282
- }, null)])]), props.closeIcon && vue.createVNode("span", {
283
- "class": [addPrefix("__close"), addPrefix("__btn")],
284
- "onClick": () => emit("close")
285
- }, [vue.createVNode(vueFontawesome.FontAwesomeIcon, {
286
- "icon": freeSolidSvgIcons.faXmark
287
- }, null)])]);
288
- }
75
+ var Search_default = /* @__PURE__ */ (0, vue.defineComponent)({
76
+ name,
77
+ props: searchProps,
78
+ emits: searchEmits,
79
+ setup(props, { emit, expose, attrs }) {
80
+ const modelValue = (0, _vueuse_core.useVModel)(props, "modelValue", emit, { passive: true });
81
+ const rootClass = (0, vue.computed)(() => {
82
+ const { size, disabled, border } = props;
83
+ return [
84
+ name,
85
+ addPrefix(`--${size}`),
86
+ {
87
+ [addPrefix("--disabled")]: disabled,
88
+ [addPrefix("--border")]: border
89
+ }
90
+ ];
91
+ });
92
+ const id = `${name}-${inputId++}`;
93
+ const eventAttrs = (0, lodash.chain)([
94
+ "input",
95
+ "blur",
96
+ "focus",
97
+ "change"
98
+ ]).map((key) => [`on${(0, lodash.upperFirst)(key)}`, (...arg) => emit(key, ...arg)]).fromPairs().value();
99
+ const inputAttrs = (0, vue.computed)(() => {
100
+ const { inputAttrs, disabled, placeholder } = props;
101
+ return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({ id }, (0, lodash.omit)(attrs, ["class", "style"])), inputAttrs), eventAttrs), {}, {
102
+ disabled,
103
+ placeholder
104
+ });
105
+ });
106
+ const onClear = () => {
107
+ if (props.disabled) return;
108
+ modelValue.value = "";
109
+ emit("clear");
110
+ };
111
+ const rawIndex = (0, vue.ref)(0);
112
+ const markList = (0, vue.ref)([]);
113
+ const escapedVal = (0, vue.computed)(() => (0, lodash.escapeRegExp)(String(modelValue.value)));
114
+ const setMarkList = (el) => {
115
+ const item = (0, lodash.last)(markList.value);
116
+ const keyword = (item === null || item === void 0 ? void 0 : item.map((item) => item.innerText).join("")) || "";
117
+ const regexp = new RegExp(`^${escapedVal.value}$`, "i");
118
+ !item || regexp.test(keyword) ? markList.value.push([el]) : item.push(el);
119
+ };
120
+ const total = (0, vue.computed)(() => markList.value.length);
121
+ (0, vue.watch)(total, (val) => emit("totalChange", val));
122
+ const matchesIndex = (0, vue.computed)(() => {
123
+ return total.value && (rawIndex.value % total.value + total.value) % total.value;
124
+ });
125
+ (0, vue.watch)(matchesIndex, (val) => emit("indexChange", val));
126
+ const matchesCount = (0, vue.computed)(() => modelValue.value !== "" && total.value && `${matchesIndex.value + 1}/${total.value}`);
127
+ const stepMap = new Map([["prev", -1], ["next", 1]]);
128
+ const toggle = (index, ignoreDisabled = true) => {
129
+ if (!ignoreDisabled && props.disabled) return;
130
+ const offsetVal = stepMap.get(String(index));
131
+ rawIndex.value = offsetVal ? matchesIndex.value + offsetVal : Number(index);
132
+ };
133
+ const onStepClick = (direction) => {
134
+ if (props.disabled) return;
135
+ toggle(direction);
136
+ emit("stepClick", direction);
137
+ };
138
+ const onKeydown = (0, vue.withKeys)((event) => {
139
+ var _event$target;
140
+ return !((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.composing) && onStepClick("next");
141
+ }, ["enter"]);
142
+ const target = (0, vue.computed)(() => (0, _vueuse_core.toValue)(props.target));
143
+ const { targetEl } = require_index$1.useElement(target);
144
+ const markInstance = (0, vue.computed)(() => {
145
+ return targetEl.value instanceof HTMLElement ? new mark_js.default(targetEl.value) : void 0;
146
+ });
147
+ (0, vue.watch)(targetEl, (el) => {
148
+ if (el && !(el instanceof HTMLElement)) console.error("[vue-markdown-design] Target is not of the HTMLElement type.");
149
+ });
150
+ const highlightClass = addPrefix("--highlight");
151
+ (0, vue.watchEffect)(() => {
152
+ var _targetEl$value;
153
+ (_targetEl$value = targetEl.value) === null || _targetEl$value === void 0 || _targetEl$value.querySelectorAll(`.${highlightClass}`).forEach((el) => el.classList.remove(highlightClass));
154
+ const currentMark = markList.value.find((_, index) => index === matchesIndex.value);
155
+ if (!currentMark) return;
156
+ currentMark.forEach((el) => el.classList.add(highlightClass));
157
+ const { offset, smooth } = props;
158
+ require_dom.scrollToEl(currentMark[0], {
159
+ offset,
160
+ smooth,
161
+ scrollMode: "if-needed"
162
+ });
163
+ });
164
+ const resetMark = () => {
165
+ var _markInstance$value;
166
+ (_markInstance$value = markInstance.value) === null || _markInstance$value === void 0 || _markInstance$value.unmark();
167
+ markList.value = [];
168
+ };
169
+ const setMark = (0, lodash.debounce)(() => {
170
+ var _markInstance$value2;
171
+ resetMark();
172
+ if (!targetEl.value) return;
173
+ const regexp = new RegExp(escapedVal.value, "gi");
174
+ (_markInstance$value2 = markInstance.value) === null || _markInstance$value2 === void 0 || _markInstance$value2.markRegExp(regexp, {
175
+ className: addPrefix("--mark"),
176
+ acrossElements: true,
177
+ each: setMarkList
178
+ });
179
+ }, 200);
180
+ const resetAndMark = () => {
181
+ rawIndex.value = 0;
182
+ setMark();
183
+ };
184
+ (0, vue.watch)(modelValue, resetAndMark);
185
+ (0, vue.onBeforeUnmount)(resetMark);
186
+ const refresh = function() {
187
+ var _ref = require_asyncToGenerator._asyncToGenerator(function* (resetIndex = true) {
188
+ yield (0, vue.nextTick)();
189
+ resetIndex ? resetAndMark() : setMark();
190
+ });
191
+ return function refresh() {
192
+ return _ref.apply(this, arguments);
193
+ };
194
+ }();
195
+ (0, vue.watch)([targetEl, () => {
196
+ var _target$value;
197
+ return (_target$value = target.value) === null || _target$value === void 0 ? void 0 : _target$value.htmlStr;
198
+ }], () => refresh(), { immediate: true });
199
+ const inputRef = (0, vue.shallowRef)();
200
+ expose(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, (0, lodash.chain)(["focus", "blur"]).map((key) => [key, () => {
201
+ var _inputRef$value;
202
+ return (_inputRef$value = inputRef.value) === null || _inputRef$value === void 0 ? void 0 : _inputRef$value[key]();
203
+ }]).fromPairs().value()), {}, {
204
+ clear: onClear,
205
+ toggle,
206
+ refresh
207
+ }));
208
+ return () => (0, vue.createVNode)("div", { "class": rootClass.value }, [
209
+ (0, vue.withDirectives)((0, vue.createVNode)("input", (0, vue.mergeProps)(inputAttrs.value, {
210
+ "onUpdate:modelValue": ($event) => modelValue.value = $event,
211
+ "class": addPrefix("__input"),
212
+ "ref": inputRef,
213
+ "onKeydown": onKeydown
214
+ }), null), [[vue.vModelText, modelValue.value]]),
215
+ modelValue.value && (0, vue.createVNode)(vue.Fragment, null, [
216
+ props.clearable && (0, vue.createVNode)("button", {
217
+ "aria-label": "Clear",
218
+ "class": [addPrefix("__clearable"), addPrefix("__btn")],
219
+ "onClick": onClear
220
+ }, [(0, vue.createVNode)(_fortawesome_vue_fontawesome.FontAwesomeIcon, {
221
+ "size": "xs",
222
+ "icon": _fortawesome_free_solid_svg_icons.faCircleXmark
223
+ }, null)]),
224
+ (0, vue.createVNode)("span", { "class": addPrefix("__count") }, [matchesCount.value]),
225
+ (0, vue.createVNode)("button", {
226
+ "aria-label": "Previous",
227
+ "class": [addPrefix("__prev"), addPrefix("__btn")],
228
+ "onClick": () => onStepClick("prev")
229
+ }, [(0, vue.createVNode)(_fortawesome_vue_fontawesome.FontAwesomeIcon, { "icon": _fortawesome_free_solid_svg_icons.faAngleUp }, null)]),
230
+ (0, vue.createVNode)("button", {
231
+ "aria-label": "Next",
232
+ "class": [addPrefix("__next"), addPrefix("__btn")],
233
+ "onClick": () => onStepClick("next")
234
+ }, [(0, vue.createVNode)(_fortawesome_vue_fontawesome.FontAwesomeIcon, { "icon": _fortawesome_free_solid_svg_icons.faAngleDown }, null)])
235
+ ]),
236
+ props.closeIcon && (0, vue.createVNode)("button", {
237
+ "aria-label": "Close",
238
+ "class": [addPrefix("__close"), addPrefix("__btn")],
239
+ "onClick": () => emit("close")
240
+ }, [(0, vue.createVNode)(_fortawesome_vue_fontawesome.FontAwesomeIcon, { "icon": _fortawesome_free_solid_svg_icons.faXmark }, null)])
241
+ ]);
242
+ }
289
243
  });
290
- exports.default = _Search;
244
+ //#endregion
245
+ exports.default = Search_default;
291
246
  exports.searchEmits = searchEmits;
292
247
  exports.searchProps = searchProps;
@@ -16,6 +16,7 @@
16
16
  --vmd-search-clearable-color: var(--vmd-text-secondary-color);
17
17
  --vmd-search-count-font-size: 12px;
18
18
  --vmd-search-count-color: var(--vmd-text-secondary-color);
19
+ --vmd-search-btn-icon-size: 14px;
19
20
  --vmd-search-btn-hover-opacity: 0.5;
20
21
  --vmd-search-mark: mark;
21
22
  --vmd-search-highlight: orange;
@@ -77,6 +78,9 @@
77
78
  .vmd-search__btn {
78
79
  cursor: pointer;
79
80
  color: var(--vmd-icon-color);
81
+ background: none;
82
+ border: none;
83
+ font-size: var(--vmd-search-btn-icon-size);
80
84
  }
81
85
  .vmd-search__btn:hover {
82
86
  opacity: var(--vmd-search-btn-hover-opacity);
@@ -0,0 +1,6 @@
1
+ const require_vue = require("../utils/vue.js");
2
+ const require_Search = require("./Search.js");
3
+ //#region src/search/index.ts
4
+ var VmdSearch = require_vue.withInstall(require_Search.default);
5
+ //#endregion
6
+ exports.default = VmdSearch;