vue-markdown-design 0.3.1 → 0.3.2-beta
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 +5 -1
- package/README.zh-CN.md +4 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.mjs +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.mjs +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.mjs +25 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.mjs +13 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.mjs +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.mjs +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.mjs +9 -0
- package/es/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.mjs +11 -0
- package/es/hooks/use-element/index.mjs +21 -18
- package/es/hooks/use-scroll-element/index.mjs +44 -45
- package/es/index.mjs +7 -18
- package/es/markdown/Markdown.mjs +221 -316
- package/es/markdown/index.css +3 -0
- package/es/markdown/index2.mjs +6 -0
- package/es/render/Render.mjs +143 -173
- package/es/render/index.css +37 -21
- package/es/render/index2.mjs +6 -0
- package/es/search/Search.mjs +236 -285
- package/es/search/index.css +4 -0
- package/es/search/index2.mjs +6 -0
- package/es/sticky/Sticky.mjs +66 -99
- package/es/sticky/index2.mjs +6 -0
- package/es/toc/Toc.mjs +253 -347
- package/es/toc/index2.mjs +6 -0
- package/es/utils/constant.mjs +4 -4
- package/es/utils/dom.mjs +44 -68
- package/es/utils/format.mjs +33 -39
- package/es/utils/functions.mjs +5 -5
- package/es/utils/vue.mjs +10 -32
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js +25 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js +13 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPrimitive.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +9 -0
- package/lib/_virtual/_@oxc-project_runtime@0.115.0/helpers/typeof.js +16 -0
- package/lib/_virtual/_rolldown/runtime.js +23 -0
- package/lib/hooks/use-element/index.js +23 -19
- package/lib/hooks/use-scroll-element/index.js +45 -45
- package/lib/index.js +24 -22
- package/lib/markdown/Markdown.js +224 -317
- package/lib/markdown/index.css +3 -0
- package/lib/markdown/index2.js +6 -0
- package/lib/render/Render.js +152 -176
- package/lib/render/index.css +37 -21
- package/lib/render/index2.js +6 -0
- package/lib/search/Search.js +242 -287
- package/lib/search/index.css +4 -0
- package/lib/search/index2.js +6 -0
- package/lib/sticky/Sticky.js +68 -99
- package/lib/sticky/index2.js +6 -0
- package/lib/toc/Toc.js +259 -349
- package/lib/toc/index2.js +6 -0
- package/lib/utils/constant.js +3 -3
- package/lib/utils/dom.js +46 -69
- package/lib/utils/format.js +33 -33
- package/lib/utils/functions.js +4 -4
- package/lib/utils/vue.js +10 -31
- package/package.json +4 -9
- package/es/markdown/index.mjs +0 -9
- package/es/render/index.mjs +0 -9
- package/es/search/index.mjs +0 -9
- package/es/sticky/index.mjs +0 -7
- package/es/toc/index.mjs +0 -9
- package/lib/markdown/index.js +0 -8
- package/lib/render/index.js +0 -8
- package/lib/search/index.js +0 -8
- package/lib/sticky/index.js +0 -7
- package/lib/toc/index.js +0 -8
package/lib/search/Search.js
CHANGED
|
@@ -1,292 +1,247 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
244
|
+
//#endregion
|
|
245
|
+
exports.default = Search_default;
|
|
291
246
|
exports.searchEmits = searchEmits;
|
|
292
247
|
exports.searchProps = searchProps;
|
package/lib/search/index.css
CHANGED
|
@@ -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);
|