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