vue-devui 1.5.13 → 1.5.14

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 (77) hide show
  1. package/auto-complete/index.es.js +3 -0
  2. package/auto-complete/index.umd.js +1 -1
  3. package/breadcrumb/index.es.js +3 -0
  4. package/breadcrumb/index.umd.js +1 -1
  5. package/checkbox/index.es.js +3 -0
  6. package/checkbox/index.umd.js +1 -1
  7. package/code-review/index.es.js +3 -0
  8. package/code-review/index.umd.js +1 -1
  9. package/date-picker-pro/index.es.js +3 -0
  10. package/date-picker-pro/index.umd.js +8 -8
  11. package/dropdown/index.es.js +3 -0
  12. package/dropdown/index.umd.js +1 -1
  13. package/editable-select/index.es.js +3 -0
  14. package/editable-select/index.umd.js +7 -7
  15. package/editor-md/index.es.js +1423 -1213
  16. package/editor-md/index.umd.js +45 -45
  17. package/editor-md/style.css +1 -1
  18. package/form/index.es.js +3 -0
  19. package/form/index.umd.js +1 -1
  20. package/git-graph/index.es.js +3 -0
  21. package/git-graph/index.umd.js +12 -12
  22. package/input/index.es.js +3 -0
  23. package/input/index.umd.js +6 -6
  24. package/input-number/index.es.js +3 -0
  25. package/input-number/index.umd.js +1 -1
  26. package/mention/index.es.js +3 -0
  27. package/mention/index.umd.js +1 -1
  28. package/modal/index.es.js +3 -0
  29. package/modal/index.umd.js +1 -1
  30. package/nuxt/components/checkbox.js +3 -0
  31. package/overlay/index.es.js +3 -0
  32. package/overlay/index.umd.js +1 -1
  33. package/package.json +1 -1
  34. package/pagination/index.es.js +155 -292
  35. package/pagination/index.umd.js +18 -18
  36. package/pagination/style.css +1 -1
  37. package/popover/index.es.js +3 -0
  38. package/popover/index.umd.js +6 -6
  39. package/radio/index.es.js +3 -0
  40. package/radio/index.umd.js +1 -1
  41. package/search/index.es.js +3 -0
  42. package/search/index.umd.js +1 -1
  43. package/select/index.es.js +119 -265
  44. package/select/index.umd.js +17 -17
  45. package/select/style.css +1 -1
  46. package/splitter/index.es.js +3 -0
  47. package/splitter/index.umd.js +1 -1
  48. package/style.css +1 -1
  49. package/switch/index.es.js +3 -0
  50. package/switch/index.umd.js +1 -1
  51. package/table/index.es.js +3 -0
  52. package/table/index.umd.js +1 -1
  53. package/textarea/index.es.js +3 -0
  54. package/textarea/index.umd.js +1 -1
  55. package/time-picker/index.es.js +3 -0
  56. package/time-picker/index.umd.js +1 -1
  57. package/time-select/index.es.js +119 -265
  58. package/time-select/index.umd.js +18 -18
  59. package/time-select/style.css +1 -1
  60. package/tooltip/index.es.js +3 -0
  61. package/tooltip/index.umd.js +4 -4
  62. package/tree/index.es.js +3 -0
  63. package/tree/index.umd.js +1 -1
  64. package/types/editor-md/index.d.ts +1 -0
  65. package/types/editor-md/src/components/md-render.d.ts +1 -1
  66. package/types/editor-md/src/composables/use-editor-md.d.ts +3 -0
  67. package/types/editor-md/src/editor-md-types.d.ts +9 -1
  68. package/types/editor-md/src/editor-md.d.ts +6 -3
  69. package/types/editor-md/src/plugins/checkbox.d.ts +1 -0
  70. package/types/pagination/src/pagination-types.d.ts +4 -13
  71. package/types/pagination/src/pagination.d.ts +218 -0
  72. package/types/select/src/select-types.d.ts +4 -23
  73. package/types/select/src/select.d.ts +1 -19
  74. package/types/select/src/use-select.d.ts +1 -1
  75. package/types/tag/src/tag.d.ts +2 -2
  76. package/vue-devui.es.js +229 -242
  77. package/vue-devui.umd.js +46 -46
@@ -1847,1084 +1847,6 @@ function refreshEditorCursor() {
1847
1847
  }
1848
1848
  window.dispatchEvent(event);
1849
1849
  }
1850
- function useEditorMd(props, ctx) {
1851
- const {
1852
- imageUploadToServer,
1853
- hidePreviewView,
1854
- mode,
1855
- maxlength,
1856
- options,
1857
- toolbarConfig,
1858
- customToolbars,
1859
- customHintReplaceFn,
1860
- hintConfig,
1861
- disableChangeEvent,
1862
- modelValue
1863
- } = toRefs(props);
1864
- const toolbars = reactive(cloneDeep_1(DEFAULT_TOOLBARS));
1865
- const editorRef = ref();
1866
- const renderRef = ref();
1867
- const previewHtmlList = ref([]);
1868
- let editorIns;
1869
- let canPreviewScrollView = false;
1870
- let CodeMirror;
1871
- computed(() => {
1872
- const result = [];
1873
- for (const key in hintConfig == null ? void 0 : hintConfig.value) {
1874
- if (typeof (hintConfig == null ? void 0 : hintConfig.value[key]) === "function" || (hintConfig == null ? void 0 : hintConfig.value[key]) && typeof (hintConfig == null ? void 0 : hintConfig.value[key].handler) === "function") {
1875
- result.push(key);
1876
- }
1877
- }
1878
- return result;
1879
- });
1880
- const getEditorIns = () => editorIns;
1881
- const editorScroll = () => {
1882
- if (editorIns) {
1883
- const scrollInfo = editorIns.getScrollInfo();
1884
- const height = scrollInfo.height - scrollInfo.clientHeight;
1885
- const ratio = parseFloat(scrollInfo.top) / height;
1886
- const preview = renderRef.value.$el;
1887
- const move = (preview.scrollHeight - preview.clientHeight) * ratio;
1888
- preview.scrollTop = move;
1889
- }
1890
- };
1891
- const previewScroll = () => {
1892
- const preview = renderRef.value.$el;
1893
- const height = preview.scrollHeight - preview.clientHeight;
1894
- const ratio = parseFloat(preview.scrollTop) / height;
1895
- const move = (editorIns.getScrollInfo().height - editorIns.getScrollInfo().clientHeight) * ratio;
1896
- editorIns.scrollTo(0, move);
1897
- };
1898
- const previewContentChange = (html) => {
1899
- previewHtmlList.value = [];
1900
- const domList = parseHTMLStringToDomList(html);
1901
- domList.forEach((ele) => {
1902
- if (ele.outerHTML) {
1903
- previewHtmlList.value.push(ele.outerHTML);
1904
- }
1905
- });
1906
- setTimeout(() => {
1907
- editorScroll();
1908
- });
1909
- nextTick(() => {
1910
- ctx.emit("previewContentChange");
1911
- });
1912
- };
1913
- const onPreviewScroll = () => {
1914
- if (!canPreviewScrollView) {
1915
- return;
1916
- }
1917
- previewScroll();
1918
- };
1919
- const onPreviewMouseover = () => {
1920
- canPreviewScrollView = true;
1921
- };
1922
- const onPreviewMouseout = () => {
1923
- canPreviewScrollView = false;
1924
- };
1925
- const onChecked = (e) => {
1926
- ctx.emit("mdCheckedEvent", e);
1927
- };
1928
- const onChange = debounce(() => {
1929
- const content = editorIns.getValue();
1930
- if (!disableChangeEvent.value) {
1931
- ctx.emit("update:modelValue", content);
1932
- ctx.emit("contentChange", content);
1933
- }
1934
- if (!canPreviewScrollView) {
1935
- editorScroll();
1936
- }
1937
- }, disableChangeEvent.value ? 500 : 10, true);
1938
- const onScroll = () => {
1939
- if (!canPreviewScrollView) {
1940
- editorScroll();
1941
- }
1942
- };
1943
- const initEditor = () => {
1944
- var _a;
1945
- editorIns = CodeMirror.fromTextArea(editorRef.value, __spreadValues({
1946
- mode: "markdown",
1947
- lineNumbers: false,
1948
- lineWrapping: true
1949
- }, options.value));
1950
- if (maxlength.value) {
1951
- editorIns.setOption("maxLength", maxlength.value);
1952
- }
1953
- editorIns.setOption("readOnly", mode.value === "readonly");
1954
- const shortKeys = {};
1955
- const flatToolbarConfig = toolbarConfig.value.flat();
1956
- const tempToolbars = __spreadValues(__spreadValues({}, toolbars), customToolbars == null ? void 0 : customToolbars.value);
1957
- for (const key of Object.keys(tempToolbars)) {
1958
- const toolbarItem = tempToolbars[key];
1959
- if (toolbarItem.shortKey && flatToolbarConfig.includes(toolbarItem.id)) {
1960
- shortKeys[toolbarItem.shortKey.replace(/\+/g, "-")] = (_a = toolbarItem.handler) == null ? void 0 : _a.bind(null, editorIns, toolbarItem.params);
1961
- }
1962
- }
1963
- editorIns.setOption("extraKeys", shortKeys);
1964
- editorIns.on("beforeChange", _enforceMaxLength);
1965
- editorIns.setSize("auto", "100%");
1966
- refreshEditorCursor();
1967
- editorIns.setCursor(editorIns.lineCount(), 0);
1968
- ctx.emit("afterEditorInit", editorIns);
1969
- editorIns.on("change", onChange);
1970
- editorIns.on("scroll", onScroll);
1971
- setTimeout(() => {
1972
- ctx.emit("contentChange", editorIns.getValue());
1973
- }, 100);
1974
- };
1975
- const onPaste = (e) => {
1976
- const clipboardData = e.clipboardData;
1977
- if (!(clipboardData && clipboardData.items)) {
1978
- return;
1979
- }
1980
- if (clipboardData.items.length <= 3) {
1981
- for (let i = 0; i < clipboardData.items.length; i++) {
1982
- const item = clipboardData.items[i];
1983
- if (item.kind === "file" && item.type.indexOf("image") !== -1) {
1984
- const file = item.getAsFile();
1985
- if ((file == null ? void 0 : file.size) === 0) {
1986
- return;
1987
- }
1988
- if (imageUploadToServer.value) {
1989
- const callback = ({ name, imgUrl, title }) => {
1990
- editorIns.focus();
1991
- editorIns.replaceSelection(`![${name}](${imgUrl} '${title}')`);
1992
- };
1993
- ctx.emit("imageUpload", { file, callback });
1994
- }
1995
- }
1996
- }
1997
- }
1998
- };
1999
- onMounted(async () => {
2000
- await import("codemirror/addon/display/placeholder.js");
2001
- await import("codemirror/mode/markdown/markdown.js");
2002
- const module = await import("codemirror");
2003
- CodeMirror = module.default;
2004
- initEditor();
2005
- });
2006
- watch(modelValue, (val) => {
2007
- if (editorIns) {
2008
- if (val === editorIns.getValue()) {
2009
- return;
2010
- }
2011
- editorIns.setValue(val);
2012
- }
2013
- });
2014
- watch(imageUploadToServer, (val) => {
2015
- if (toolbars["image"].params) {
2016
- toolbars["image"].params.imageUploadToServer = val;
2017
- }
2018
- if (toolbars["image"].params && !toolbars["image"].params.imageUpload) {
2019
- toolbars["image"].params.imageUpload = (data) => {
2020
- ctx.emit("imageUpload", data);
2021
- };
2022
- }
2023
- }, { immediate: true });
2024
- watch(hidePreviewView, () => {
2025
- refreshEditorCursor();
2026
- });
2027
- watch(mode, (val) => {
2028
- setTimeout(() => {
2029
- if (editorIns) {
2030
- refreshEditorCursor();
2031
- editorIns.setOption("readOnly", val === "readonly");
2032
- }
2033
- });
2034
- });
2035
- watch(maxlength, (val) => {
2036
- if (editorIns) {
2037
- editorIns.setOption("maxLength", val);
2038
- }
2039
- });
2040
- return {
2041
- editorRef,
2042
- renderRef,
2043
- toolbars,
2044
- previewHtmlList,
2045
- getEditorIns,
2046
- onPaste,
2047
- previewContentChange,
2048
- onChecked,
2049
- onPreviewScroll,
2050
- onPreviewMouseout,
2051
- onPreviewMouseover
2052
- };
2053
- }
2054
- function useEditorMdTheme(callback) {
2055
- const isDarkMode = ref(false);
2056
- let themeService;
2057
- const themeChange = () => {
2058
- if (themeService) {
2059
- isDarkMode.value = themeService.currentTheme.id.indexOf("dark") !== -1;
2060
- callback();
2061
- }
2062
- };
2063
- onBeforeMount(() => {
2064
- themeService = window["devuiThemeService"];
2065
- });
2066
- onMounted(() => {
2067
- themeChange();
2068
- if (themeService && themeService.eventBus) {
2069
- themeService.eventBus.add("themeChanged", themeChange);
2070
- }
2071
- });
2072
- onBeforeUnmount(() => {
2073
- if (themeService && themeService.eventBus) {
2074
- themeService.eventBus.remove("themeChanged", themeChange);
2075
- }
2076
- });
2077
- return { isDarkMode };
2078
- }
2079
- const commonProps = {
2080
- baseUrl: {
2081
- type: String,
2082
- default: null
2083
- },
2084
- breaks: {
2085
- type: Boolean,
2086
- default: true
2087
- },
2088
- customParse: {
2089
- type: Function,
2090
- default: null
2091
- },
2092
- renderParse: {
2093
- type: Function,
2094
- default: null
2095
- },
2096
- mdRules: {
2097
- type: Object,
2098
- default: () => ({})
2099
- },
2100
- customRendererRules: {
2101
- type: Array,
2102
- default: () => []
2103
- },
2104
- customXssRules: {
2105
- type: Array,
2106
- default: () => []
2107
- },
2108
- mdPlugins: {
2109
- type: Array,
2110
- default: () => []
2111
- }
2112
- };
2113
- const editorMdProps = __spreadProps(__spreadValues({}, commonProps), {
2114
- modelValue: {
2115
- type: String,
2116
- default: ""
2117
- },
2118
- options: {
2119
- type: Object,
2120
- default: () => ({})
2121
- },
2122
- mode: {
2123
- type: String,
2124
- default: "normal"
2125
- },
2126
- customThemeConfig: {
2127
- type: Object
2128
- },
2129
- customToolbars: {
2130
- type: Object
2131
- },
2132
- disableChangeEvent: {
2133
- type: Boolean,
2134
- default: false
2135
- },
2136
- editorContainerHeight: {
2137
- type: Number
2138
- },
2139
- imageUploadToServer: {
2140
- type: Boolean,
2141
- default: false
2142
- },
2143
- hidePreviewView: {
2144
- type: Boolean,
2145
- default: false
2146
- },
2147
- maxlength: {
2148
- type: Number,
2149
- default: null
2150
- },
2151
- placeholder: {
2152
- type: String,
2153
- default: ""
2154
- },
2155
- toolbarConfig: {
2156
- type: Array,
2157
- default: () => DEFAULT_TOOLBAR_CONFIG
2158
- },
2159
- fullscreenZIndex: {
2160
- type: Number,
2161
- default: 10
2162
- },
2163
- hintConfig: {
2164
- type: Object
2165
- },
2166
- customHintReplaceFn: {
2167
- type: Function
2168
- }
2169
- });
2170
- const EditorMdInjectionKey = Symbol("d-editor-md");
2171
- const mdRenderProps = __spreadProps(__spreadValues({}, commonProps), {
2172
- content: {
2173
- type: String,
2174
- default: ""
2175
- },
2176
- disableRender: {
2177
- type: Boolean,
2178
- default: false
2179
- }
2180
- });
2181
- const mdToolbarItemProps = {
2182
- config: {
2183
- type: Object,
2184
- default: () => ({})
2185
- }
2186
- };
2187
- const dropdownProps = {
2188
- visible: {
2189
- type: Boolean,
2190
- default: false
2191
- },
2192
- trigger: {
2193
- type: String,
2194
- default: "click"
2195
- },
2196
- closeScope: {
2197
- type: String,
2198
- default: "all"
2199
- },
2200
- position: {
2201
- type: Array,
2202
- default: ["bottom"]
2203
- },
2204
- align: {
2205
- type: String,
2206
- default: null
2207
- },
2208
- offset: {
2209
- type: [Number, Object],
2210
- default: 4
2211
- },
2212
- shiftOffset: {
2213
- type: Number
2214
- },
2215
- closeOnMouseLeaveMenu: {
2216
- type: Boolean,
2217
- default: false
2218
- },
2219
- showAnimation: {
2220
- type: Boolean,
2221
- default: true
2222
- },
2223
- overlayClass: {
2224
- type: String,
2225
- default: ""
2226
- },
2227
- destroyOnHide: {
2228
- type: Boolean,
2229
- default: true
2230
- }
2231
- };
2232
- const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
2233
- const dropdownMap = /* @__PURE__ */ new Map();
2234
- function subscribeEvent(dom, type, callback) {
2235
- dom == null ? void 0 : dom.addEventListener(type, callback);
2236
- return () => {
2237
- dom == null ? void 0 : dom.removeEventListener(type, callback);
2238
- };
2239
- }
2240
- const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
2241
- let overlayEnter = false;
2242
- let originEnter = false;
2243
- const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
2244
- const toggle = (status) => {
2245
- isOpen.value = status;
2246
- emit("toggle", isOpen.value);
2247
- };
2248
- const handleLeave = async (elementType, closeAll) => {
2249
- await new Promise((resolve) => setTimeout(resolve, 50));
2250
- if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
2251
- return;
2252
- }
2253
- if (closeAll) {
2254
- [...dropdownMap.values()].reverse().forEach((item) => {
2255
- setTimeout(() => {
2256
- var _a;
2257
- (_a = item.toggle) == null ? void 0 : _a.call(item);
2258
- }, 0);
2259
- });
2260
- }
2261
- toggle(false);
2262
- };
2263
- watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
2264
- const originEl = getElement(originVal);
2265
- const subscriptions = [];
2266
- setTimeout(() => {
2267
- subscriptions.push(subscribeEvent(document, "click", (e) => {
2268
- e.stopPropagation();
2269
- const dropdownValues = [...dropdownMap.values()];
2270
- if (!isOpen.value || closeScope.value === "none" || (dropdownEl == null ? void 0 : dropdownEl.contains(e.target)) && closeScope.value === "blank" || dropdownValues.some((item) => {
2271
- var _a;
2272
- return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
2273
- }) && dropdownValues.some((item) => {
2274
- var _a;
2275
- return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
2276
- })) {
2277
- return;
2278
- }
2279
- [...dropdownMap.values()].reverse().forEach((item) => {
2280
- setTimeout(() => {
2281
- var _a, _b;
2282
- if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
2283
- (_b = item.toggle) == null ? void 0 : _b.call(item);
2284
- }
2285
- }, 0);
2286
- });
2287
- overlayEnter = false;
2288
- }));
2289
- }, 0);
2290
- if (triggerVal === "click") {
2291
- subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
2292
- var _a;
2293
- if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
2294
- handleLeave("dropdown", true);
2295
- }
2296
- }));
2297
- } else if (triggerVal === "hover") {
2298
- subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
2299
- originEnter = true;
2300
- toggle(true);
2301
- }), subscribeEvent(originEl, "mouseleave", () => {
2302
- originEnter = false;
2303
- handleLeave("origin");
2304
- }), subscribeEvent(dropdownEl, "mouseenter", () => {
2305
- overlayEnter = true;
2306
- isOpen.value = true;
2307
- }), subscribeEvent(dropdownEl, "mouseleave", (e) => {
2308
- var _a;
2309
- overlayEnter = false;
2310
- if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
2311
- return;
2312
- }
2313
- handleLeave("dropdown", true);
2314
- }));
2315
- }
2316
- onInvalidate(() => subscriptions.forEach((v) => v()));
2317
- });
2318
- };
2319
- function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
2320
- const calcPopDirection = (dropdownEl) => {
2321
- const elementHeight = dropdownEl.offsetHeight;
2322
- const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
2323
- const isBottomEnough = bottomDistance >= elementHeight;
2324
- if (!isBottomEnough) {
2325
- popDirection.value = "top";
2326
- } else {
2327
- popDirection.value = "bottom";
2328
- }
2329
- };
2330
- watch(visible, (newVal, oldVal) => {
2331
- if (oldVal === void 0) {
2332
- return;
2333
- }
2334
- isOpen.value = newVal;
2335
- emit("toggle", isOpen.value);
2336
- }, { immediate: true });
2337
- watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
2338
- var _a;
2339
- if (isOpenVal) {
2340
- dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
2341
- menuEl: dropdownEl,
2342
- toggle: () => {
2343
- isOpen.value = false;
2344
- emit("toggle", isOpen.value);
2345
- }
2346
- }));
2347
- for (const value of dropdownMap.values()) {
2348
- if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
2349
- value.child = dropdownEl;
2350
- }
2351
- }
2352
- }
2353
- if (dropdownEl) {
2354
- calcPopDirection(dropdownEl);
2355
- }
2356
- });
2357
- onMounted(() => {
2358
- dropdownMap.set(id, { toggleEl: origin.value });
2359
- });
2360
- onUnmounted(() => {
2361
- dropdownMap.delete(id);
2362
- });
2363
- }
2364
- function useOverlayProps(props, currentPosition, isOpen) {
2365
- const { showAnimation, overlayClass, destroyOnHide } = toRefs(props);
2366
- const overlayModelValue = ref(false);
2367
- const overlayShowValue = ref(false);
2368
- const styles = computed(() => ({
2369
- transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%",
2370
- zIndex: "var(--devui-z-index-dropdown, 1052)"
2371
- }));
2372
- const classes = computed(() => ({
2373
- "fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
2374
- "fade-in-top": showAnimation.value && isOpen.value && currentPosition.value === "top",
2375
- [`${overlayClass.value}`]: true
2376
- }));
2377
- const handlePositionChange = (pos) => {
2378
- currentPosition.value = pos.includes("top") || pos.includes("right-end") || pos.includes("left-end") ? "top" : "bottom";
2379
- };
2380
- watch(isOpen, (isOpenVal) => {
2381
- overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
2382
- overlayShowValue.value = isOpenVal;
2383
- });
2384
- return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
2385
- }
2386
- const fixedOverlayProps = {
2387
- modelValue: {
2388
- type: Boolean,
2389
- default: false
2390
- },
2391
- lockScroll: {
2392
- type: Boolean,
2393
- default: true
2394
- },
2395
- closeOnClickOverlay: {
2396
- type: Boolean,
2397
- default: true
2398
- }
2399
- };
2400
- function useFixedOverlay(props, ctx) {
2401
- let lockScrollCb;
2402
- const onClick = (event) => {
2403
- event.preventDefault();
2404
- ctx.emit("click", event);
2405
- if (props.closeOnClickOverlay) {
2406
- ctx.emit("update:modelValue", false);
2407
- }
2408
- };
2409
- const removeBodyAdditions = () => {
2410
- lockScrollCb == null ? void 0 : lockScrollCb();
2411
- };
2412
- watch(() => props.modelValue, (val) => {
2413
- if (val) {
2414
- props.lockScroll && (lockScrollCb = lockScroll());
2415
- } else {
2416
- removeBodyAdditions();
2417
- }
2418
- });
2419
- onUnmounted(removeBodyAdditions);
2420
- return { onClick };
2421
- }
2422
- function createBem(namespace, element, modifier) {
2423
- let cls = namespace;
2424
- if (element) {
2425
- cls += `__${element}`;
2426
- }
2427
- if (modifier) {
2428
- cls += `--${modifier}`;
2429
- }
2430
- return cls;
2431
- }
2432
- function useNamespace(block, needDot = false) {
2433
- const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
2434
- const b = () => createBem(namespace);
2435
- const e = (element) => element ? createBem(namespace, element) : "";
2436
- const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
2437
- const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
2438
- return {
2439
- b,
2440
- e,
2441
- m,
2442
- em
2443
- };
2444
- }
2445
- var fixedOverlay = "";
2446
- defineComponent({
2447
- name: "DFixedOverlay",
2448
- inheritAttrs: false,
2449
- props: fixedOverlayProps,
2450
- emits: ["update:modelValue", "click"],
2451
- setup(props, ctx) {
2452
- const {
2453
- modelValue
2454
- } = toRefs(props);
2455
- const ns2 = useNamespace("fixed-overlay");
2456
- const {
2457
- onClick
2458
- } = useFixedOverlay(props, ctx);
2459
- return () => createVNode(Transition, {
2460
- "name": ns2.m("fade")
2461
- }, {
2462
- default: () => {
2463
- var _a, _b;
2464
- return [modelValue.value && createVNode("div", mergeProps({
2465
- "class": ns2.b()
2466
- }, ctx.attrs, {
2467
- "onClick": onClick
2468
- }), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
2469
- }
2470
- });
2471
- }
2472
- });
2473
- const flexibleOverlayProps = {
2474
- modelValue: {
2475
- type: Boolean,
2476
- default: false
2477
- },
2478
- origin: {
2479
- type: Object,
2480
- require: true
2481
- },
2482
- position: {
2483
- type: Array,
2484
- default: ["bottom"]
2485
- },
2486
- offset: {
2487
- type: [Number, Object],
2488
- default: 8
2489
- },
2490
- shiftOffset: {
2491
- type: Number
2492
- },
2493
- align: {
2494
- type: String,
2495
- default: null
2496
- },
2497
- showArrow: {
2498
- type: Boolean,
2499
- default: false
2500
- },
2501
- isArrowCenter: {
2502
- type: Boolean,
2503
- default: true
2504
- },
2505
- clickEventBubble: {
2506
- type: Boolean,
2507
- default: false
2508
- }
2509
- };
2510
- function getScrollParent(element) {
2511
- const overflowRegex = /(auto|scroll|hidden)/;
2512
- for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
2513
- const style = window.getComputedStyle(parent);
2514
- if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
2515
- return parent;
2516
- }
2517
- }
2518
- return window;
2519
- }
2520
- function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
2521
- let { x, y } = point;
2522
- if (!isArrowCenter) {
2523
- const { width, height } = originRect;
2524
- if (x && placement.includes("start")) {
2525
- x = 12;
2526
- }
2527
- if (x && placement.includes("end")) {
2528
- x = Math.round(width - 24);
2529
- }
2530
- if (y && placement.includes("start")) {
2531
- y = 10;
2532
- }
2533
- if (y && placement.includes("end")) {
2534
- y = height - 14;
2535
- }
2536
- }
2537
- return { x, y };
2538
- }
2539
- function useOverlay(props, emit) {
2540
- const overlayRef = ref();
2541
- const arrowRef = ref();
2542
- let originParent = null;
2543
- const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
2544
- const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
2545
- const staticSide = {
2546
- top: "bottom",
2547
- right: "left",
2548
- bottom: "top",
2549
- left: "right"
2550
- }[placement.split("-")[0]];
2551
- Object.assign(arrowEl.style, {
2552
- left: x ? `${x}px` : "",
2553
- top: y ? `${y}px` : "",
2554
- right: "",
2555
- bottom: "",
2556
- [staticSide]: "-4px"
2557
- });
2558
- };
2559
- const updatePosition = async () => {
2560
- const hostEl = props.origin;
2561
- const overlayEl = unref(overlayRef.value);
2562
- const arrowEl = unref(arrowRef.value);
2563
- const middleware = [
2564
- offset(props.offset),
2565
- autoPlacement({
2566
- alignment: props.align,
2567
- allowedPlacements: props.position
2568
- })
2569
- ];
2570
- props.showArrow && middleware.push(arrow({ element: arrowEl }));
2571
- props.shiftOffset !== void 0 && middleware.push(shift());
2572
- const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
2573
- strategy: "fixed",
2574
- middleware
2575
- });
2576
- let applyX = x;
2577
- let applyY = y;
2578
- if (props.shiftOffset !== void 0) {
2579
- const { x: shiftX, y: shiftY } = middlewareData.shift;
2580
- shiftX < 0 && (applyX -= props.shiftOffset);
2581
- shiftX > 0 && (applyX += props.shiftOffset);
2582
- shiftY < 0 && (applyY -= props.shiftOffset);
2583
- shiftY > 0 && (applyY += props.shiftOffset);
2584
- }
2585
- emit("positionChange", placement);
2586
- Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
2587
- props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
2588
- };
2589
- watch(() => props.modelValue, () => {
2590
- if (props.modelValue && props.origin) {
2591
- originParent = getScrollParent(props.origin);
2592
- nextTick(updatePosition);
2593
- originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
2594
- originParent !== window && window.addEventListener("scroll", updatePosition);
2595
- window.addEventListener("resize", updatePosition);
2596
- } else {
2597
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
2598
- originParent !== window && window.removeEventListener("scroll", updatePosition);
2599
- window.removeEventListener("resize", updatePosition);
2600
- }
2601
- });
2602
- onUnmounted(() => {
2603
- originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
2604
- originParent !== window && window.removeEventListener("scroll", updatePosition);
2605
- window.removeEventListener("resize", updatePosition);
2606
- });
2607
- return { arrowRef, overlayRef, updatePosition };
2608
- }
2609
- var flexibleOverlay = "";
2610
- const FlexibleOverlay = defineComponent({
2611
- name: "DFlexibleOverlay",
2612
- inheritAttrs: false,
2613
- props: flexibleOverlayProps,
2614
- emits: ["update:modelValue", "positionChange"],
2615
- setup(props, {
2616
- slots,
2617
- attrs,
2618
- emit,
2619
- expose
2620
- }) {
2621
- const ns2 = useNamespace("flexible-overlay");
2622
- const {
2623
- clickEventBubble
2624
- } = toRefs(props);
2625
- const {
2626
- arrowRef,
2627
- overlayRef,
2628
- updatePosition
2629
- } = useOverlay(props, emit);
2630
- expose({
2631
- updatePosition
2632
- });
2633
- return () => {
2634
- var _a;
2635
- return props.modelValue && createVNode("div", mergeProps({
2636
- "ref": overlayRef,
2637
- "class": ns2.b()
2638
- }, attrs, {
2639
- "onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
2640
- "onPointerup": withModifiers(() => ({}), ["stop"])
2641
- }), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
2642
- "ref": arrowRef,
2643
- "class": ns2.e("arrow")
2644
- }, null)]);
2645
- };
2646
- }
2647
- });
2648
- const isObject = (val) => val !== null && typeof val === "object";
2649
- const ns = useNamespace("popper-trigger");
2650
- function wrapContent(content) {
2651
- return h("span", { class: ns.b() }, content);
2652
- }
2653
- function getFirstValidChild(nodes) {
2654
- for (const child of nodes) {
2655
- if (isObject(child)) {
2656
- if (child.type === Comment) {
2657
- continue;
2658
- }
2659
- if (child.type === "svg" || child.type === Text) {
2660
- return wrapContent(child);
2661
- }
2662
- if (child.type === Fragment) {
2663
- return getFirstValidChild(child.children);
2664
- }
2665
- return child;
2666
- }
2667
- return wrapContent(child);
2668
- }
2669
- return null;
2670
- }
2671
- var PopperTrigger = defineComponent({
2672
- name: "DPopperTrigger",
2673
- setup(_, ctx) {
2674
- const {
2675
- slots,
2676
- attrs
2677
- } = ctx;
2678
- return () => {
2679
- var _a;
2680
- const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
2681
- const triggerRef = inject(POPPER_TRIGGER_TOKEN);
2682
- if (!defaultSlot) {
2683
- return null;
2684
- }
2685
- const firstValidChild = getFirstValidChild(defaultSlot);
2686
- if (!firstValidChild) {
2687
- return null;
2688
- }
2689
- return withDirectives(cloneVNode(firstValidChild, attrs), [[{
2690
- mounted(el) {
2691
- triggerRef.value = el;
2692
- },
2693
- updated(el) {
2694
- triggerRef.value = el;
2695
- },
2696
- unmounted() {
2697
- triggerRef.value = null;
2698
- }
2699
- }]]);
2700
- };
2701
- }
2702
- });
2703
- var dropdown = "";
2704
- let dropdownId = 1;
2705
- var Dropdown = defineComponent({
2706
- name: "DDropdown",
2707
- inheritAttrs: false,
2708
- props: dropdownProps,
2709
- emits: ["toggle"],
2710
- setup(props, {
2711
- slots,
2712
- attrs,
2713
- emit,
2714
- expose
2715
- }) {
2716
- const {
2717
- visible,
2718
- position,
2719
- align,
2720
- offset: offset2,
2721
- destroyOnHide,
2722
- shiftOffset,
2723
- showAnimation
2724
- } = toRefs(props);
2725
- const origin = ref();
2726
- const dropdownRef = ref();
2727
- const overlayRef = ref();
2728
- const id = `dropdown_${dropdownId++}`;
2729
- const isOpen = ref(false);
2730
- const currentPosition = ref("bottom");
2731
- const ns2 = useNamespace("dropdown");
2732
- provide(POPPER_TRIGGER_TOKEN, origin);
2733
- useDropdownEvent({
2734
- id,
2735
- isOpen,
2736
- origin,
2737
- dropdownRef,
2738
- props,
2739
- emit
2740
- });
2741
- useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
2742
- const {
2743
- overlayModelValue,
2744
- overlayShowValue,
2745
- styles,
2746
- classes,
2747
- handlePositionChange
2748
- } = useOverlayProps(props, currentPosition, isOpen);
2749
- watch(overlayShowValue, (overlayShowValueVal) => {
2750
- nextTick(() => {
2751
- if (!destroyOnHide.value && overlayShowValueVal) {
2752
- overlayRef.value.updatePosition();
2753
- }
2754
- });
2755
- });
2756
- expose({
2757
- updatePosition: () => overlayRef.value.updatePosition()
2758
- });
2759
- return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
2760
- default: () => {
2761
- var _a;
2762
- return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
2763
- }
2764
- }), createVNode(Teleport, {
2765
- "to": "body"
2766
- }, {
2767
- default: () => [createVNode(Transition, {
2768
- "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
2769
- }, {
2770
- default: () => [withDirectives(createVNode(FlexibleOverlay, {
2771
- "modelValue": overlayModelValue.value,
2772
- "onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
2773
- "ref": overlayRef,
2774
- "origin": origin.value,
2775
- "position": position.value,
2776
- "align": align.value,
2777
- "offset": offset2.value,
2778
- "shiftOffset": shiftOffset == null ? void 0 : shiftOffset.value,
2779
- "onPositionChange": handlePositionChange,
2780
- "click-event-bubble": true,
2781
- "class": classes.value,
2782
- "style": styles.value
2783
- }, {
2784
- default: () => {
2785
- var _a;
2786
- return [createVNode("div", mergeProps({
2787
- "ref": dropdownRef,
2788
- "class": ns2.e("menu-wrap")
2789
- }, attrs), [(_a = slots.menu) == null ? void 0 : _a.call(slots)])];
2790
- }
2791
- }), [[vShow, overlayShowValue.value]])]
2792
- })]
2793
- })]);
2794
- }
2795
- });
2796
- const dropdownMenuProps = {
2797
- modelValue: {
2798
- type: Boolean,
2799
- default: false
2800
- },
2801
- origin: {
2802
- type: Object,
2803
- require: true
2804
- },
2805
- position: {
2806
- type: Array,
2807
- default: ["bottom"]
2808
- },
2809
- align: {
2810
- type: String,
2811
- default: null
2812
- },
2813
- offset: {
2814
- type: [Number, Object],
2815
- default: 4
2816
- },
2817
- clickOutside: {
2818
- type: Function,
2819
- default: () => true
2820
- },
2821
- showAnimation: {
2822
- type: Boolean,
2823
- default: true
2824
- },
2825
- overlayClass: {
2826
- type: String,
2827
- default: ""
2828
- }
2829
- };
2830
- defineComponent({
2831
- name: "DDropdownMenu",
2832
- inheritAttrs: false,
2833
- props: dropdownMenuProps,
2834
- emits: ["update:modelValue"],
2835
- setup(props, {
2836
- slots,
2837
- attrs,
2838
- emit
2839
- }) {
2840
- const {
2841
- modelValue,
2842
- origin,
2843
- position,
2844
- align,
2845
- offset: offset2,
2846
- clickOutside,
2847
- showAnimation,
2848
- overlayClass
2849
- } = toRefs(props);
2850
- const dropdownMenuRef = ref(null);
2851
- const ns2 = useNamespace("dropdown");
2852
- onClickOutside(dropdownMenuRef, (value) => {
2853
- var _a, _b;
2854
- if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
2855
- emit("update:modelValue", false);
2856
- }
2857
- });
2858
- const currentPosition = ref("bottom");
2859
- const handlePositionChange = (pos) => {
2860
- currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
2861
- };
2862
- const styles = computed(() => ({
2863
- transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
2864
- }));
2865
- return () => createVNode(Teleport, {
2866
- "to": "body"
2867
- }, {
2868
- default: () => [createVNode(Transition, {
2869
- "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
2870
- }, {
2871
- default: () => [createVNode(FlexibleOverlay, {
2872
- "modelValue": modelValue.value,
2873
- "onUpdate:modelValue": ($event) => modelValue.value = $event,
2874
- "origin": origin == null ? void 0 : origin.value,
2875
- "position": position.value,
2876
- "align": align.value,
2877
- "offset": offset2.value,
2878
- "onPositionChange": handlePositionChange,
2879
- "class": overlayClass.value,
2880
- "style": styles.value
2881
- }, {
2882
- default: () => {
2883
- var _a;
2884
- return [createVNode("div", mergeProps({
2885
- "ref": dropdownMenuRef,
2886
- "class": ns2.e("menu-wrap")
2887
- }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
2888
- }
2889
- })]
2890
- })]
2891
- });
2892
- }
2893
- });
2894
- const tooltipProps = {
2895
- content: {
2896
- type: String,
2897
- default: ""
2898
- },
2899
- position: {
2900
- type: [String, Array],
2901
- default: "top"
2902
- },
2903
- showAnimation: {
2904
- type: Boolean,
2905
- default: true
2906
- },
2907
- mouseEnterDelay: {
2908
- type: Number,
2909
- default: 150
2910
- },
2911
- mouseLeaveDelay: {
2912
- type: Number,
2913
- default: 100
2914
- },
2915
- enterable: {
2916
- type: Boolean,
2917
- default: true
2918
- },
2919
- disabled: {
2920
- type: Boolean,
2921
- default: false
2922
- },
2923
- hideAfter: {
2924
- type: Number,
2925
- default: 0
2926
- }
2927
- };
2928
1850
  var lodash = { exports: {} };
2929
1851
  /**
2930
1852
  * @license
@@ -8197,145 +7119,1327 @@ var lodash = { exports: {} };
8197
7119
  "iteratee": getIteratee(iteratee2, 3),
8198
7120
  "type": type
8199
7121
  });
8200
- result2.__filtered__ = result2.__filtered__ || isFilter;
8201
- return result2;
7122
+ result2.__filtered__ = result2.__filtered__ || isFilter;
7123
+ return result2;
7124
+ };
7125
+ });
7126
+ arrayEach2(["head", "last"], function(methodName, index2) {
7127
+ var takeName = "take" + (index2 ? "Right" : "");
7128
+ LazyWrapper.prototype[methodName] = function() {
7129
+ return this[takeName](1).value()[0];
7130
+ };
7131
+ });
7132
+ arrayEach2(["initial", "tail"], function(methodName, index2) {
7133
+ var dropName = "drop" + (index2 ? "" : "Right");
7134
+ LazyWrapper.prototype[methodName] = function() {
7135
+ return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
7136
+ };
7137
+ });
7138
+ LazyWrapper.prototype.compact = function() {
7139
+ return this.filter(identity);
7140
+ };
7141
+ LazyWrapper.prototype.find = function(predicate) {
7142
+ return this.filter(predicate).head();
7143
+ };
7144
+ LazyWrapper.prototype.findLast = function(predicate) {
7145
+ return this.reverse().find(predicate);
7146
+ };
7147
+ LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
7148
+ if (typeof path == "function") {
7149
+ return new LazyWrapper(this);
7150
+ }
7151
+ return this.map(function(value) {
7152
+ return baseInvoke(value, path, args);
7153
+ });
7154
+ });
7155
+ LazyWrapper.prototype.reject = function(predicate) {
7156
+ return this.filter(negate(getIteratee(predicate)));
7157
+ };
7158
+ LazyWrapper.prototype.slice = function(start, end) {
7159
+ start = toInteger(start);
7160
+ var result2 = this;
7161
+ if (result2.__filtered__ && (start > 0 || end < 0)) {
7162
+ return new LazyWrapper(result2);
7163
+ }
7164
+ if (start < 0) {
7165
+ result2 = result2.takeRight(-start);
7166
+ } else if (start) {
7167
+ result2 = result2.drop(start);
7168
+ }
7169
+ if (end !== undefined$1) {
7170
+ end = toInteger(end);
7171
+ result2 = end < 0 ? result2.dropRight(-end) : result2.take(end - start);
7172
+ }
7173
+ return result2;
7174
+ };
7175
+ LazyWrapper.prototype.takeRightWhile = function(predicate) {
7176
+ return this.reverse().takeWhile(predicate).reverse();
7177
+ };
7178
+ LazyWrapper.prototype.toArray = function() {
7179
+ return this.take(MAX_ARRAY_LENGTH);
7180
+ };
7181
+ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
7182
+ var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), isTaker = /^(?:head|last)$/.test(methodName), lodashFunc = lodash2[isTaker ? "take" + (methodName == "last" ? "Right" : "") : methodName], retUnwrapped = isTaker || /^find/.test(methodName);
7183
+ if (!lodashFunc) {
7184
+ return;
7185
+ }
7186
+ lodash2.prototype[methodName] = function() {
7187
+ var value = this.__wrapped__, args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee2 = args[0], useLazy = isLazy || isArray2(value);
7188
+ var interceptor = function(value2) {
7189
+ var result3 = lodashFunc.apply(lodash2, arrayPush2([value2], args));
7190
+ return isTaker && chainAll ? result3[0] : result3;
7191
+ };
7192
+ if (useLazy && checkIteratee && typeof iteratee2 == "function" && iteratee2.length != 1) {
7193
+ isLazy = useLazy = false;
7194
+ }
7195
+ var chainAll = this.__chain__, isHybrid = !!this.__actions__.length, isUnwrapped = retUnwrapped && !chainAll, onlyLazy = isLazy && !isHybrid;
7196
+ if (!retUnwrapped && useLazy) {
7197
+ value = onlyLazy ? value : new LazyWrapper(this);
7198
+ var result2 = func.apply(value, args);
7199
+ result2.__actions__.push({ "func": thru, "args": [interceptor], "thisArg": undefined$1 });
7200
+ return new LodashWrapper(result2, chainAll);
7201
+ }
7202
+ if (isUnwrapped && onlyLazy) {
7203
+ return func.apply(this, args);
7204
+ }
7205
+ result2 = this.thru(interceptor);
7206
+ return isUnwrapped ? isTaker ? result2.value()[0] : result2.value() : result2;
7207
+ };
7208
+ });
7209
+ arrayEach2(["pop", "push", "shift", "sort", "splice", "unshift"], function(methodName) {
7210
+ var func = arrayProto2[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:pop|shift)$/.test(methodName);
7211
+ lodash2.prototype[methodName] = function() {
7212
+ var args = arguments;
7213
+ if (retUnwrapped && !this.__chain__) {
7214
+ var value = this.value();
7215
+ return func.apply(isArray2(value) ? value : [], args);
7216
+ }
7217
+ return this[chainName](function(value2) {
7218
+ return func.apply(isArray2(value2) ? value2 : [], args);
7219
+ });
8202
7220
  };
8203
7221
  });
8204
- arrayEach2(["head", "last"], function(methodName, index2) {
8205
- var takeName = "take" + (index2 ? "Right" : "");
8206
- LazyWrapper.prototype[methodName] = function() {
8207
- return this[takeName](1).value()[0];
8208
- };
7222
+ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
7223
+ var lodashFunc = lodash2[methodName];
7224
+ if (lodashFunc) {
7225
+ var key = lodashFunc.name + "";
7226
+ if (!hasOwnProperty2.call(realNames, key)) {
7227
+ realNames[key] = [];
7228
+ }
7229
+ realNames[key].push({ "name": methodName, "func": lodashFunc });
7230
+ }
8209
7231
  });
8210
- arrayEach2(["initial", "tail"], function(methodName, index2) {
8211
- var dropName = "drop" + (index2 ? "" : "Right");
8212
- LazyWrapper.prototype[methodName] = function() {
8213
- return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
8214
- };
7232
+ realNames[createHybrid(undefined$1, WRAP_BIND_KEY_FLAG).name] = [{
7233
+ "name": "wrapper",
7234
+ "func": undefined$1
7235
+ }];
7236
+ LazyWrapper.prototype.clone = lazyClone;
7237
+ LazyWrapper.prototype.reverse = lazyReverse;
7238
+ LazyWrapper.prototype.value = lazyValue;
7239
+ lodash2.prototype.at = wrapperAt;
7240
+ lodash2.prototype.chain = wrapperChain;
7241
+ lodash2.prototype.commit = wrapperCommit;
7242
+ lodash2.prototype.next = wrapperNext;
7243
+ lodash2.prototype.plant = wrapperPlant;
7244
+ lodash2.prototype.reverse = wrapperReverse;
7245
+ lodash2.prototype.toJSON = lodash2.prototype.valueOf = lodash2.prototype.value = wrapperValue;
7246
+ lodash2.prototype.first = lodash2.prototype.head;
7247
+ if (symIterator) {
7248
+ lodash2.prototype[symIterator] = wrapperToIterator;
7249
+ }
7250
+ return lodash2;
7251
+ };
7252
+ var _ = runInContext();
7253
+ if (freeModule) {
7254
+ (freeModule.exports = _)._ = _;
7255
+ freeExports._ = _;
7256
+ } else {
7257
+ root2._ = _;
7258
+ }
7259
+ }).call(commonjsGlobal);
7260
+ })(lodash, lodash.exports);
7261
+ function useEditorMd(props, ctx) {
7262
+ const {
7263
+ imageUploadToServer,
7264
+ hidePreviewView,
7265
+ mode,
7266
+ maxlength,
7267
+ options,
7268
+ toolbarConfig,
7269
+ customToolbars,
7270
+ customHintReplaceFn,
7271
+ hintConfig,
7272
+ disableChangeEvent,
7273
+ modelValue
7274
+ } = toRefs(props);
7275
+ const toolbars = reactive(cloneDeep_1(DEFAULT_TOOLBARS));
7276
+ const editorRef = ref();
7277
+ const renderRef = ref();
7278
+ const overlayRef = ref();
7279
+ const cursorRef = ref();
7280
+ const isHintShow = ref();
7281
+ const previewHtmlList = ref([]);
7282
+ let editorIns;
7283
+ let canPreviewScrollView = false;
7284
+ let cursorHint = "";
7285
+ let cursorHintEnd = -1;
7286
+ let cursorHintStart = -1;
7287
+ let prefix;
7288
+ let hintShow = false;
7289
+ let CodeMirror;
7290
+ const prefixes = computed(() => {
7291
+ const result = [];
7292
+ for (const key in hintConfig == null ? void 0 : hintConfig.value) {
7293
+ if (typeof (hintConfig == null ? void 0 : hintConfig.value[key]) === "function" || (hintConfig == null ? void 0 : hintConfig.value[key]) && typeof (hintConfig == null ? void 0 : hintConfig.value[key].handler) === "function") {
7294
+ result.push(key);
7295
+ }
7296
+ }
7297
+ return result;
7298
+ });
7299
+ const getEditorIns = () => editorIns;
7300
+ const editorScroll = () => {
7301
+ if (editorIns) {
7302
+ const scrollInfo = editorIns.getScrollInfo();
7303
+ const height = scrollInfo.height - scrollInfo.clientHeight;
7304
+ const ratio = parseFloat(scrollInfo.top) / height;
7305
+ const preview = renderRef.value.$el;
7306
+ const move = (preview.scrollHeight - preview.clientHeight) * ratio;
7307
+ preview.scrollTop = move;
7308
+ }
7309
+ };
7310
+ const previewScroll = () => {
7311
+ const preview = renderRef.value.$el;
7312
+ const height = preview.scrollHeight - preview.clientHeight;
7313
+ const ratio = parseFloat(preview.scrollTop) / height;
7314
+ const move = (editorIns.getScrollInfo().height - editorIns.getScrollInfo().clientHeight) * ratio;
7315
+ editorIns.scrollTo(0, move);
7316
+ };
7317
+ const previewContentChange = (html) => {
7318
+ previewHtmlList.value = [];
7319
+ const domList = parseHTMLStringToDomList(html);
7320
+ domList.forEach((ele) => {
7321
+ if (ele.outerHTML) {
7322
+ previewHtmlList.value.push(ele.outerHTML);
7323
+ }
7324
+ });
7325
+ setTimeout(() => {
7326
+ editorScroll();
7327
+ });
7328
+ nextTick(() => {
7329
+ ctx.emit("previewContentChange");
7330
+ });
7331
+ };
7332
+ const onPreviewScroll = () => {
7333
+ if (!canPreviewScrollView) {
7334
+ return;
7335
+ }
7336
+ previewScroll();
7337
+ };
7338
+ const onPreviewMouseover = () => {
7339
+ canPreviewScrollView = true;
7340
+ };
7341
+ const onPreviewMouseout = () => {
7342
+ canPreviewScrollView = false;
7343
+ };
7344
+ const onChecked = (e) => {
7345
+ ctx.emit("checkedChange", e);
7346
+ };
7347
+ let timer;
7348
+ const attachOverlay = () => {
7349
+ timer = setTimeout(() => {
7350
+ var _a;
7351
+ cursorRef.value = ((_a = editorRef.value) == null ? void 0 : _a.parentNode.querySelector(".CodeMirror-cursor")) || void 0;
7352
+ overlayRef.value.updatePosition();
7353
+ isHintShow.value = true;
7354
+ hintShow = true;
7355
+ });
7356
+ };
7357
+ const hideHint = () => {
7358
+ clearTimeout(timer);
7359
+ isHintShow.value = false;
7360
+ };
7361
+ const showHint = () => {
7362
+ if (hintShow) {
7363
+ hideHint();
7364
+ }
7365
+ attachOverlay();
7366
+ };
7367
+ const getHintList = () => {
7368
+ let handler;
7369
+ if (typeof hintConfig.value[prefix] === "function") {
7370
+ handler = hintConfig.value[prefix];
7371
+ } else if (hintConfig.value[prefix] && typeof hintConfig.value[prefix].handler === "function") {
7372
+ handler = hintConfig.value[prefix].handler;
7373
+ }
7374
+ const callback = (replaceText) => {
7375
+ const cursor = editorIns.getCursor();
7376
+ const endCh = cursorHintEnd;
7377
+ const startCh = cursorHintStart;
7378
+ if (editorIns.getLine(cursor.line).length === cursor.ch) {
7379
+ editorIns.replaceRange(replaceText + " ", { line: cursor.line, ch: startCh }, { line: cursor.line, ch: endCh });
7380
+ } else {
7381
+ editorIns.replaceRange(replaceText, { line: cursor.line, ch: startCh }, { line: cursor.line, ch: endCh });
7382
+ editorIns.setCursor(cursor.line, editorIns.getCursor().ch + 1);
7383
+ }
7384
+ editorIns.focus();
7385
+ hideHint();
7386
+ };
7387
+ handler && handler({ prefix, cursorHint, callback });
7388
+ };
7389
+ const cursorActivityHandler = () => {
7390
+ const cursor = editorIns.getCursor();
7391
+ let i = prefixes.value.length;
7392
+ const value = editorIns.getLine(cursor.line).replace(/\t/g, " ");
7393
+ const selection = editorIns.getSelection();
7394
+ const isImgRegx = /^\!\[\S+/;
7395
+ if (selection) {
7396
+ return;
7397
+ }
7398
+ let nowPrefix = "";
7399
+ let hint = "";
7400
+ while (i >= 1) {
7401
+ i--;
7402
+ nowPrefix = prefixes.value[i];
7403
+ const startPos = value.lastIndexOf(nowPrefix, cursor.ch);
7404
+ const endPos = value.indexOf(" ", cursor.ch) > -1 ? value.indexOf(" ", cursor.ch) : value.length;
7405
+ hint = value.slice(startPos, cursor.ch);
7406
+ if (startPos > 0 && value[startPos - 1] !== " " || startPos < 0 || !hint.includes(nowPrefix) || hint.endsWith(" ") || isImgRegx.test(hint)) {
7407
+ cursorHint = "";
7408
+ cursorHintStart = -1;
7409
+ cursorHintEnd = -1;
7410
+ } else {
7411
+ prefix = prefixes.value[i];
7412
+ cursorHint = hint.slice(prefix.length);
7413
+ cursorHintStart = startPos;
7414
+ cursorHintEnd = endPos;
7415
+ break;
7416
+ }
7417
+ }
7418
+ if (cursorHintStart > -1 && hint[0]) {
7419
+ const spacePosition = value.lastIndexOf(" ", cursor.ch);
7420
+ if (spacePosition > cursorHintStart) {
7421
+ return;
7422
+ }
7423
+ setTimeout(() => {
7424
+ showHint();
7425
+ getHintList();
8215
7426
  });
8216
- LazyWrapper.prototype.compact = function() {
8217
- return this.filter(identity);
8218
- };
8219
- LazyWrapper.prototype.find = function(predicate) {
8220
- return this.filter(predicate).head();
8221
- };
8222
- LazyWrapper.prototype.findLast = function(predicate) {
8223
- return this.reverse().find(predicate);
7427
+ } else {
7428
+ hideHint();
7429
+ }
7430
+ };
7431
+ const onChange = debounce(() => {
7432
+ const content = editorIns.getValue();
7433
+ if (!disableChangeEvent.value) {
7434
+ ctx.emit("update:modelValue", content);
7435
+ ctx.emit("contentChange", content);
7436
+ }
7437
+ if (!canPreviewScrollView) {
7438
+ editorScroll();
7439
+ }
7440
+ }, disableChangeEvent.value ? 500 : 10, true);
7441
+ const onScroll = () => {
7442
+ if (!canPreviewScrollView) {
7443
+ editorScroll();
7444
+ }
7445
+ };
7446
+ const initEditor = () => {
7447
+ var _a;
7448
+ editorIns = CodeMirror.fromTextArea(editorRef.value, __spreadValues({
7449
+ mode: "markdown",
7450
+ lineNumbers: false,
7451
+ lineWrapping: true
7452
+ }, options.value));
7453
+ if (maxlength.value) {
7454
+ editorIns.setOption("maxLength", maxlength.value);
7455
+ }
7456
+ editorIns.setOption("readOnly", mode.value === "readonly");
7457
+ const shortKeys = {};
7458
+ const flatToolbarConfig = toolbarConfig.value.flat();
7459
+ const tempToolbars = __spreadValues(__spreadValues({}, toolbars), customToolbars == null ? void 0 : customToolbars.value);
7460
+ for (const key of Object.keys(tempToolbars)) {
7461
+ const toolbarItem = tempToolbars[key];
7462
+ if (toolbarItem.shortKey && flatToolbarConfig.includes(toolbarItem.id)) {
7463
+ shortKeys[toolbarItem.shortKey.replace(/\+/g, "-")] = (_a = toolbarItem.handler) == null ? void 0 : _a.bind(null, editorIns, toolbarItem.params);
7464
+ }
7465
+ }
7466
+ editorIns.setOption("extraKeys", Object.assign({
7467
+ Esc: () => {
7468
+ hideHint();
7469
+ }
7470
+ }), shortKeys);
7471
+ editorIns.on("beforeChange", _enforceMaxLength);
7472
+ editorIns.on("cursorActivity", lodash.exports.throttle(cursorActivityHandler, hintConfig.value && hintConfig.value.throttleTime || 300));
7473
+ editorIns.setSize("auto", "100%");
7474
+ refreshEditorCursor();
7475
+ editorIns.setCursor(editorIns.lineCount(), 0);
7476
+ ctx.emit("afterEditorInit", editorIns);
7477
+ editorIns.on("change", onChange);
7478
+ editorIns.on("scroll", onScroll);
7479
+ setTimeout(() => {
7480
+ ctx.emit("contentChange", editorIns.getValue());
7481
+ }, 100);
7482
+ };
7483
+ const onPaste = (e) => {
7484
+ const clipboardData = e.clipboardData;
7485
+ if (!(clipboardData && clipboardData.items)) {
7486
+ return;
7487
+ }
7488
+ if (clipboardData.items.length <= 3) {
7489
+ for (let i = 0; i < clipboardData.items.length; i++) {
7490
+ const item = clipboardData.items[i];
7491
+ if (item.kind === "file" && item.type.indexOf("image") !== -1) {
7492
+ const file = item.getAsFile();
7493
+ if ((file == null ? void 0 : file.size) === 0) {
7494
+ return;
7495
+ }
7496
+ if (imageUploadToServer.value) {
7497
+ const callback = ({ name, imgUrl, title }) => {
7498
+ editorIns.focus();
7499
+ editorIns.replaceSelection(`![${name}](${imgUrl} '${title}')`);
7500
+ };
7501
+ ctx.emit("imageUpload", { file, callback });
7502
+ }
7503
+ }
7504
+ }
7505
+ }
7506
+ };
7507
+ onMounted(async () => {
7508
+ await import("codemirror/addon/display/placeholder.js");
7509
+ await import("codemirror/mode/markdown/markdown.js");
7510
+ const module = await import("codemirror");
7511
+ CodeMirror = module.default;
7512
+ initEditor();
7513
+ });
7514
+ watch(modelValue, (val) => {
7515
+ if (editorIns) {
7516
+ if (val === editorIns.getValue()) {
7517
+ return;
7518
+ }
7519
+ editorIns.setValue(val);
7520
+ }
7521
+ });
7522
+ watch(imageUploadToServer, (val) => {
7523
+ if (toolbars["image"].params) {
7524
+ toolbars["image"].params.imageUploadToServer = val;
7525
+ }
7526
+ if (toolbars["image"].params && !toolbars["image"].params.imageUpload) {
7527
+ toolbars["image"].params.imageUpload = (data) => {
7528
+ ctx.emit("imageUpload", data);
8224
7529
  };
8225
- LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
8226
- if (typeof path == "function") {
8227
- return new LazyWrapper(this);
7530
+ }
7531
+ }, { immediate: true });
7532
+ watch(hidePreviewView, () => {
7533
+ refreshEditorCursor();
7534
+ });
7535
+ watch(mode, (val) => {
7536
+ setTimeout(() => {
7537
+ if (editorIns) {
7538
+ refreshEditorCursor();
7539
+ editorIns.setOption("readOnly", val === "readonly");
7540
+ }
7541
+ });
7542
+ });
7543
+ watch(maxlength, (val) => {
7544
+ if (editorIns) {
7545
+ editorIns.setOption("maxLength", val);
7546
+ }
7547
+ });
7548
+ return {
7549
+ editorRef,
7550
+ overlayRef,
7551
+ cursorRef,
7552
+ renderRef,
7553
+ toolbars,
7554
+ previewHtmlList,
7555
+ isHintShow,
7556
+ getEditorIns,
7557
+ onPaste,
7558
+ previewContentChange,
7559
+ onChecked,
7560
+ onPreviewScroll,
7561
+ onPreviewMouseout,
7562
+ onPreviewMouseover
7563
+ };
7564
+ }
7565
+ function useEditorMdTheme(callback) {
7566
+ const isDarkMode = ref(false);
7567
+ let themeService;
7568
+ const themeChange = () => {
7569
+ if (themeService) {
7570
+ isDarkMode.value = themeService.currentTheme.id.indexOf("dark") !== -1;
7571
+ callback();
7572
+ }
7573
+ };
7574
+ onBeforeMount(() => {
7575
+ themeService = window["devuiThemeService"];
7576
+ });
7577
+ onMounted(() => {
7578
+ themeChange();
7579
+ if (themeService && themeService.eventBus) {
7580
+ themeService.eventBus.add("themeChanged", themeChange);
7581
+ }
7582
+ });
7583
+ onBeforeUnmount(() => {
7584
+ if (themeService && themeService.eventBus) {
7585
+ themeService.eventBus.remove("themeChanged", themeChange);
7586
+ }
7587
+ });
7588
+ return { isDarkMode };
7589
+ }
7590
+ const commonProps = {
7591
+ baseUrl: {
7592
+ type: String,
7593
+ default: null
7594
+ },
7595
+ breaks: {
7596
+ type: Boolean,
7597
+ default: true
7598
+ },
7599
+ customParse: {
7600
+ type: Function,
7601
+ default: null
7602
+ },
7603
+ renderParse: {
7604
+ type: Function,
7605
+ default: null
7606
+ },
7607
+ mdRules: {
7608
+ type: Object,
7609
+ default: () => ({})
7610
+ },
7611
+ customRendererRules: {
7612
+ type: Array,
7613
+ default: () => []
7614
+ },
7615
+ customXssRules: {
7616
+ type: Array,
7617
+ default: () => []
7618
+ },
7619
+ mdPlugins: {
7620
+ type: Array,
7621
+ default: () => []
7622
+ }
7623
+ };
7624
+ const editorMdProps = __spreadProps(__spreadValues({}, commonProps), {
7625
+ modelValue: {
7626
+ type: String,
7627
+ default: ""
7628
+ },
7629
+ options: {
7630
+ type: Object,
7631
+ default: () => ({})
7632
+ },
7633
+ mode: {
7634
+ type: String,
7635
+ default: "normal"
7636
+ },
7637
+ customThemeConfig: {
7638
+ type: Object
7639
+ },
7640
+ customToolbars: {
7641
+ type: Object
7642
+ },
7643
+ disableChangeEvent: {
7644
+ type: Boolean,
7645
+ default: false
7646
+ },
7647
+ editorContainerHeight: {
7648
+ type: Number
7649
+ },
7650
+ imageUploadToServer: {
7651
+ type: Boolean,
7652
+ default: false
7653
+ },
7654
+ hidePreviewView: {
7655
+ type: Boolean,
7656
+ default: false
7657
+ },
7658
+ maxlength: {
7659
+ type: Number,
7660
+ default: null
7661
+ },
7662
+ placeholder: {
7663
+ type: String,
7664
+ default: ""
7665
+ },
7666
+ toolbarConfig: {
7667
+ type: Array,
7668
+ default: () => DEFAULT_TOOLBAR_CONFIG
7669
+ },
7670
+ fullscreenZIndex: {
7671
+ type: Number,
7672
+ default: 10
7673
+ },
7674
+ hintConfig: {
7675
+ type: Object,
7676
+ default: {}
7677
+ },
7678
+ customHintReplaceFn: {
7679
+ type: Function
7680
+ }
7681
+ });
7682
+ const EditorMdInjectionKey = Symbol("d-editor-md");
7683
+ const mdRenderProps = __spreadProps(__spreadValues({}, commonProps), {
7684
+ content: {
7685
+ type: String,
7686
+ default: ""
7687
+ },
7688
+ disableRender: {
7689
+ type: Boolean,
7690
+ default: false
7691
+ }
7692
+ });
7693
+ const mdToolbarItemProps = {
7694
+ config: {
7695
+ type: Object,
7696
+ default: () => ({})
7697
+ }
7698
+ };
7699
+ const dropdownProps = {
7700
+ visible: {
7701
+ type: Boolean,
7702
+ default: false
7703
+ },
7704
+ trigger: {
7705
+ type: String,
7706
+ default: "click"
7707
+ },
7708
+ closeScope: {
7709
+ type: String,
7710
+ default: "all"
7711
+ },
7712
+ position: {
7713
+ type: Array,
7714
+ default: ["bottom"]
7715
+ },
7716
+ align: {
7717
+ type: String,
7718
+ default: null
7719
+ },
7720
+ offset: {
7721
+ type: [Number, Object],
7722
+ default: 4
7723
+ },
7724
+ shiftOffset: {
7725
+ type: Number
7726
+ },
7727
+ closeOnMouseLeaveMenu: {
7728
+ type: Boolean,
7729
+ default: false
7730
+ },
7731
+ showAnimation: {
7732
+ type: Boolean,
7733
+ default: true
7734
+ },
7735
+ overlayClass: {
7736
+ type: String,
7737
+ default: ""
7738
+ },
7739
+ destroyOnHide: {
7740
+ type: Boolean,
7741
+ default: true
7742
+ }
7743
+ };
7744
+ const POPPER_TRIGGER_TOKEN = Symbol("popper-trigger");
7745
+ const dropdownMap = /* @__PURE__ */ new Map();
7746
+ function subscribeEvent(dom, type, callback) {
7747
+ dom == null ? void 0 : dom.addEventListener(type, callback);
7748
+ return () => {
7749
+ dom == null ? void 0 : dom.removeEventListener(type, callback);
7750
+ };
7751
+ }
7752
+ const useDropdownEvent = ({ id, isOpen, origin, dropdownRef, props, emit }) => {
7753
+ let overlayEnter = false;
7754
+ let originEnter = false;
7755
+ const { trigger, closeScope, closeOnMouseLeaveMenu } = toRefs(props);
7756
+ const toggle = (status) => {
7757
+ isOpen.value = status;
7758
+ emit("toggle", isOpen.value);
7759
+ };
7760
+ const handleLeave = async (elementType, closeAll) => {
7761
+ await new Promise((resolve) => setTimeout(resolve, 50));
7762
+ if (elementType === "origin" && overlayEnter || elementType === "dropdown" && originEnter) {
7763
+ return;
7764
+ }
7765
+ if (closeAll) {
7766
+ [...dropdownMap.values()].reverse().forEach((item) => {
7767
+ setTimeout(() => {
7768
+ var _a;
7769
+ (_a = item.toggle) == null ? void 0 : _a.call(item);
7770
+ }, 0);
7771
+ });
7772
+ }
7773
+ toggle(false);
7774
+ };
7775
+ watch([trigger, origin, dropdownRef], ([triggerVal, originVal, dropdownEl], ov, onInvalidate) => {
7776
+ const originEl = getElement(originVal);
7777
+ const subscriptions = [];
7778
+ setTimeout(() => {
7779
+ subscriptions.push(subscribeEvent(document, "click", (e) => {
7780
+ e.stopPropagation();
7781
+ const dropdownValues = [...dropdownMap.values()];
7782
+ if (!isOpen.value || closeScope.value === "none" || (dropdownEl == null ? void 0 : dropdownEl.contains(e.target)) && closeScope.value === "blank" || dropdownValues.some((item) => {
7783
+ var _a;
7784
+ return (_a = item.toggleEl) == null ? void 0 : _a.contains(e.target);
7785
+ }) && dropdownValues.some((item) => {
7786
+ var _a;
7787
+ return (_a = item.menuEl) == null ? void 0 : _a.contains(e.target);
7788
+ })) {
7789
+ return;
8228
7790
  }
8229
- return this.map(function(value) {
8230
- return baseInvoke(value, path, args);
7791
+ [...dropdownMap.values()].reverse().forEach((item) => {
7792
+ setTimeout(() => {
7793
+ var _a, _b;
7794
+ if (!((_a = item.toggleEl) == null ? void 0 : _a.contains(e.target))) {
7795
+ (_b = item.toggle) == null ? void 0 : _b.call(item);
7796
+ }
7797
+ }, 0);
8231
7798
  });
8232
- });
8233
- LazyWrapper.prototype.reject = function(predicate) {
8234
- return this.filter(negate(getIteratee(predicate)));
8235
- };
8236
- LazyWrapper.prototype.slice = function(start, end) {
8237
- start = toInteger(start);
8238
- var result2 = this;
8239
- if (result2.__filtered__ && (start > 0 || end < 0)) {
8240
- return new LazyWrapper(result2);
7799
+ overlayEnter = false;
7800
+ }));
7801
+ }, 0);
7802
+ if (triggerVal === "click") {
7803
+ subscriptions.push(subscribeEvent(originEl, "click", () => toggle(!isOpen.value)), subscribeEvent(dropdownEl, "mouseleave", (e) => {
7804
+ var _a;
7805
+ if (closeOnMouseLeaveMenu.value && !((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget))) {
7806
+ handleLeave("dropdown", true);
8241
7807
  }
8242
- if (start < 0) {
8243
- result2 = result2.takeRight(-start);
8244
- } else if (start) {
8245
- result2 = result2.drop(start);
7808
+ }));
7809
+ } else if (triggerVal === "hover") {
7810
+ subscriptions.push(subscribeEvent(originEl, "mouseenter", () => {
7811
+ originEnter = true;
7812
+ toggle(true);
7813
+ }), subscribeEvent(originEl, "mouseleave", () => {
7814
+ originEnter = false;
7815
+ handleLeave("origin");
7816
+ }), subscribeEvent(dropdownEl, "mouseenter", () => {
7817
+ overlayEnter = true;
7818
+ isOpen.value = true;
7819
+ }), subscribeEvent(dropdownEl, "mouseleave", (e) => {
7820
+ var _a;
7821
+ overlayEnter = false;
7822
+ if (e.relatedTarget && ((originEl == null ? void 0 : originEl.contains(e.relatedTarget)) || ((_a = dropdownMap.get(id).child) == null ? void 0 : _a.contains(e.relatedTarget)))) {
7823
+ return;
8246
7824
  }
8247
- if (end !== undefined$1) {
8248
- end = toInteger(end);
8249
- result2 = end < 0 ? result2.dropRight(-end) : result2.take(end - start);
7825
+ handleLeave("dropdown", true);
7826
+ }));
7827
+ }
7828
+ onInvalidate(() => subscriptions.forEach((v) => v()));
7829
+ });
7830
+ };
7831
+ function useDropdown(id, visible, isOpen, origin, dropdownRef, popDirection, emit) {
7832
+ const calcPopDirection = (dropdownEl) => {
7833
+ const elementHeight = dropdownEl.offsetHeight;
7834
+ const bottomDistance = window.innerHeight - origin.value.getBoundingClientRect().bottom;
7835
+ const isBottomEnough = bottomDistance >= elementHeight;
7836
+ if (!isBottomEnough) {
7837
+ popDirection.value = "top";
7838
+ } else {
7839
+ popDirection.value = "bottom";
7840
+ }
7841
+ };
7842
+ watch(visible, (newVal, oldVal) => {
7843
+ if (oldVal === void 0) {
7844
+ return;
7845
+ }
7846
+ isOpen.value = newVal;
7847
+ emit("toggle", isOpen.value);
7848
+ }, { immediate: true });
7849
+ watch([isOpen, dropdownRef], ([isOpenVal, dropdownEl]) => {
7850
+ var _a;
7851
+ if (isOpenVal) {
7852
+ dropdownMap.set(id, __spreadProps(__spreadValues({}, dropdownMap.get(id)), {
7853
+ menuEl: dropdownEl,
7854
+ toggle: () => {
7855
+ isOpen.value = false;
7856
+ emit("toggle", isOpen.value);
8250
7857
  }
8251
- return result2;
8252
- };
8253
- LazyWrapper.prototype.takeRightWhile = function(predicate) {
8254
- return this.reverse().takeWhile(predicate).reverse();
8255
- };
8256
- LazyWrapper.prototype.toArray = function() {
8257
- return this.take(MAX_ARRAY_LENGTH);
8258
- };
8259
- baseForOwn(LazyWrapper.prototype, function(func, methodName) {
8260
- var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), isTaker = /^(?:head|last)$/.test(methodName), lodashFunc = lodash2[isTaker ? "take" + (methodName == "last" ? "Right" : "") : methodName], retUnwrapped = isTaker || /^find/.test(methodName);
8261
- if (!lodashFunc) {
8262
- return;
7858
+ }));
7859
+ for (const value of dropdownMap.values()) {
7860
+ if ((_a = value.menuEl) == null ? void 0 : _a.contains(origin.value)) {
7861
+ value.child = dropdownEl;
7862
+ }
7863
+ }
7864
+ }
7865
+ if (dropdownEl) {
7866
+ calcPopDirection(dropdownEl);
7867
+ }
7868
+ });
7869
+ onMounted(() => {
7870
+ dropdownMap.set(id, { toggleEl: origin.value });
7871
+ });
7872
+ onUnmounted(() => {
7873
+ dropdownMap.delete(id);
7874
+ });
7875
+ }
7876
+ function useOverlayProps(props, currentPosition, isOpen) {
7877
+ const { showAnimation, overlayClass, destroyOnHide } = toRefs(props);
7878
+ const overlayModelValue = ref(false);
7879
+ const overlayShowValue = ref(false);
7880
+ const styles = computed(() => ({
7881
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%",
7882
+ zIndex: "var(--devui-z-index-dropdown, 1052)"
7883
+ }));
7884
+ const classes = computed(() => ({
7885
+ "fade-in-bottom": showAnimation.value && isOpen.value && currentPosition.value === "bottom",
7886
+ "fade-in-top": showAnimation.value && isOpen.value && currentPosition.value === "top",
7887
+ [`${overlayClass.value}`]: true
7888
+ }));
7889
+ const handlePositionChange = (pos) => {
7890
+ currentPosition.value = pos.includes("top") || pos.includes("right-end") || pos.includes("left-end") ? "top" : "bottom";
7891
+ };
7892
+ watch(isOpen, (isOpenVal) => {
7893
+ overlayModelValue.value = destroyOnHide.value ? isOpenVal : true;
7894
+ overlayShowValue.value = isOpenVal;
7895
+ });
7896
+ return { overlayModelValue, overlayShowValue, styles, classes, handlePositionChange };
7897
+ }
7898
+ const fixedOverlayProps = {
7899
+ modelValue: {
7900
+ type: Boolean,
7901
+ default: false
7902
+ },
7903
+ lockScroll: {
7904
+ type: Boolean,
7905
+ default: true
7906
+ },
7907
+ closeOnClickOverlay: {
7908
+ type: Boolean,
7909
+ default: true
7910
+ }
7911
+ };
7912
+ function useFixedOverlay(props, ctx) {
7913
+ let lockScrollCb;
7914
+ const onClick = (event) => {
7915
+ event.preventDefault();
7916
+ ctx.emit("click", event);
7917
+ if (props.closeOnClickOverlay) {
7918
+ ctx.emit("update:modelValue", false);
7919
+ }
7920
+ };
7921
+ const removeBodyAdditions = () => {
7922
+ lockScrollCb == null ? void 0 : lockScrollCb();
7923
+ };
7924
+ watch(() => props.modelValue, (val) => {
7925
+ if (val) {
7926
+ props.lockScroll && (lockScrollCb = lockScroll());
7927
+ } else {
7928
+ removeBodyAdditions();
7929
+ }
7930
+ });
7931
+ onUnmounted(removeBodyAdditions);
7932
+ return { onClick };
7933
+ }
7934
+ function createBem(namespace, element, modifier) {
7935
+ let cls = namespace;
7936
+ if (element) {
7937
+ cls += `__${element}`;
7938
+ }
7939
+ if (modifier) {
7940
+ cls += `--${modifier}`;
7941
+ }
7942
+ return cls;
7943
+ }
7944
+ function useNamespace(block, needDot = false) {
7945
+ const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
7946
+ const b = () => createBem(namespace);
7947
+ const e = (element) => element ? createBem(namespace, element) : "";
7948
+ const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
7949
+ const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
7950
+ return {
7951
+ b,
7952
+ e,
7953
+ m,
7954
+ em
7955
+ };
7956
+ }
7957
+ var fixedOverlay = "";
7958
+ defineComponent({
7959
+ name: "DFixedOverlay",
7960
+ inheritAttrs: false,
7961
+ props: fixedOverlayProps,
7962
+ emits: ["update:modelValue", "click"],
7963
+ setup(props, ctx) {
7964
+ const {
7965
+ modelValue
7966
+ } = toRefs(props);
7967
+ const ns2 = useNamespace("fixed-overlay");
7968
+ const {
7969
+ onClick
7970
+ } = useFixedOverlay(props, ctx);
7971
+ return () => createVNode(Transition, {
7972
+ "name": ns2.m("fade")
7973
+ }, {
7974
+ default: () => {
7975
+ var _a, _b;
7976
+ return [modelValue.value && createVNode("div", mergeProps({
7977
+ "class": ns2.b()
7978
+ }, ctx.attrs, {
7979
+ "onClick": onClick
7980
+ }), [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])];
7981
+ }
7982
+ });
7983
+ }
7984
+ });
7985
+ const flexibleOverlayProps = {
7986
+ modelValue: {
7987
+ type: Boolean,
7988
+ default: false
7989
+ },
7990
+ origin: {
7991
+ type: Object,
7992
+ require: true
7993
+ },
7994
+ position: {
7995
+ type: Array,
7996
+ default: ["bottom"]
7997
+ },
7998
+ offset: {
7999
+ type: [Number, Object],
8000
+ default: 8
8001
+ },
8002
+ shiftOffset: {
8003
+ type: Number
8004
+ },
8005
+ align: {
8006
+ type: String,
8007
+ default: null
8008
+ },
8009
+ showArrow: {
8010
+ type: Boolean,
8011
+ default: false
8012
+ },
8013
+ isArrowCenter: {
8014
+ type: Boolean,
8015
+ default: true
8016
+ },
8017
+ clickEventBubble: {
8018
+ type: Boolean,
8019
+ default: false
8020
+ }
8021
+ };
8022
+ function getScrollParent(element) {
8023
+ const overflowRegex = /(auto|scroll|hidden)/;
8024
+ for (let parent = element; parent = parent.parentElement; parent.parentElement !== document.body) {
8025
+ const style = window.getComputedStyle(parent);
8026
+ if (overflowRegex.test(style.overflow + style.overflowX + style.overflowY)) {
8027
+ return parent;
8028
+ }
8029
+ }
8030
+ return window;
8031
+ }
8032
+ function adjustArrowPosition(isArrowCenter, point, placement, originRect) {
8033
+ let { x, y } = point;
8034
+ if (!isArrowCenter) {
8035
+ const { width, height } = originRect;
8036
+ if (x && placement.includes("start")) {
8037
+ x = 12;
8038
+ }
8039
+ if (x && placement.includes("end")) {
8040
+ x = Math.round(width - 24);
8041
+ }
8042
+ if (y && placement.includes("start")) {
8043
+ y = 10;
8044
+ }
8045
+ if (y && placement.includes("end")) {
8046
+ y = height - 14;
8047
+ }
8048
+ }
8049
+ return { x, y };
8050
+ }
8051
+ function useOverlay(props, emit) {
8052
+ const overlayRef = ref();
8053
+ const arrowRef = ref();
8054
+ let originParent = null;
8055
+ const updateArrowPosition = (arrowEl, placement, point, overlayEl) => {
8056
+ const { x, y } = adjustArrowPosition(props.isArrowCenter, point, placement, overlayEl.getBoundingClientRect());
8057
+ const staticSide = {
8058
+ top: "bottom",
8059
+ right: "left",
8060
+ bottom: "top",
8061
+ left: "right"
8062
+ }[placement.split("-")[0]];
8063
+ Object.assign(arrowEl.style, {
8064
+ left: x ? `${x}px` : "",
8065
+ top: y ? `${y}px` : "",
8066
+ right: "",
8067
+ bottom: "",
8068
+ [staticSide]: "-4px"
8069
+ });
8070
+ };
8071
+ const updatePosition = async () => {
8072
+ const hostEl = props.origin;
8073
+ const overlayEl = unref(overlayRef.value);
8074
+ const arrowEl = unref(arrowRef.value);
8075
+ const middleware = [
8076
+ offset(props.offset),
8077
+ autoPlacement({
8078
+ alignment: props.align,
8079
+ allowedPlacements: props.position
8080
+ })
8081
+ ];
8082
+ props.showArrow && middleware.push(arrow({ element: arrowEl }));
8083
+ props.shiftOffset !== void 0 && middleware.push(shift());
8084
+ if (!overlayEl) {
8085
+ return;
8086
+ }
8087
+ const { x, y, placement, middlewareData } = await computePosition(hostEl, overlayEl, {
8088
+ strategy: "fixed",
8089
+ middleware
8090
+ });
8091
+ let applyX = x;
8092
+ let applyY = y;
8093
+ if (props.shiftOffset !== void 0) {
8094
+ const { x: shiftX, y: shiftY } = middlewareData.shift;
8095
+ shiftX < 0 && (applyX -= props.shiftOffset);
8096
+ shiftX > 0 && (applyX += props.shiftOffset);
8097
+ shiftY < 0 && (applyY -= props.shiftOffset);
8098
+ shiftY > 0 && (applyY += props.shiftOffset);
8099
+ }
8100
+ emit("positionChange", placement);
8101
+ Object.assign(overlayEl.style, { top: `${applyY}px`, left: `${applyX}px` });
8102
+ props.showArrow && updateArrowPosition(arrowEl, placement, middlewareData.arrow, overlayEl);
8103
+ };
8104
+ watch(() => props.modelValue, () => {
8105
+ if (props.modelValue && props.origin) {
8106
+ originParent = getScrollParent(props.origin);
8107
+ nextTick(updatePosition);
8108
+ originParent == null ? void 0 : originParent.addEventListener("scroll", updatePosition);
8109
+ originParent !== window && window.addEventListener("scroll", updatePosition);
8110
+ window.addEventListener("resize", updatePosition);
8111
+ } else {
8112
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
8113
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
8114
+ window.removeEventListener("resize", updatePosition);
8115
+ }
8116
+ });
8117
+ onUnmounted(() => {
8118
+ originParent == null ? void 0 : originParent.removeEventListener("scroll", updatePosition);
8119
+ originParent !== window && window.removeEventListener("scroll", updatePosition);
8120
+ window.removeEventListener("resize", updatePosition);
8121
+ });
8122
+ return { arrowRef, overlayRef, updatePosition };
8123
+ }
8124
+ var flexibleOverlay = "";
8125
+ const FlexibleOverlay = defineComponent({
8126
+ name: "DFlexibleOverlay",
8127
+ inheritAttrs: false,
8128
+ props: flexibleOverlayProps,
8129
+ emits: ["update:modelValue", "positionChange"],
8130
+ setup(props, {
8131
+ slots,
8132
+ attrs,
8133
+ emit,
8134
+ expose
8135
+ }) {
8136
+ const ns2 = useNamespace("flexible-overlay");
8137
+ const {
8138
+ clickEventBubble
8139
+ } = toRefs(props);
8140
+ const {
8141
+ arrowRef,
8142
+ overlayRef,
8143
+ updatePosition
8144
+ } = useOverlay(props, emit);
8145
+ expose({
8146
+ updatePosition
8147
+ });
8148
+ return () => {
8149
+ var _a;
8150
+ return props.modelValue && createVNode("div", mergeProps({
8151
+ "ref": overlayRef,
8152
+ "class": ns2.b()
8153
+ }, attrs, {
8154
+ "onClick": withModifiers(() => ({}), [clickEventBubble.value ? "" : "stop"]),
8155
+ "onPointerup": withModifiers(() => ({}), ["stop"])
8156
+ }), [(_a = slots.default) == null ? void 0 : _a.call(slots), props.showArrow && createVNode("div", {
8157
+ "ref": arrowRef,
8158
+ "class": ns2.e("arrow")
8159
+ }, null)]);
8160
+ };
8161
+ }
8162
+ });
8163
+ const isObject = (val) => val !== null && typeof val === "object";
8164
+ const ns = useNamespace("popper-trigger");
8165
+ function wrapContent(content) {
8166
+ return h("span", { class: ns.b() }, content);
8167
+ }
8168
+ function getFirstValidChild(nodes) {
8169
+ for (const child of nodes) {
8170
+ if (isObject(child)) {
8171
+ if (child.type === Comment) {
8172
+ continue;
8173
+ }
8174
+ if (child.type === "svg" || child.type === Text) {
8175
+ return wrapContent(child);
8176
+ }
8177
+ if (child.type === Fragment) {
8178
+ return getFirstValidChild(child.children);
8179
+ }
8180
+ return child;
8181
+ }
8182
+ return wrapContent(child);
8183
+ }
8184
+ return null;
8185
+ }
8186
+ var PopperTrigger = defineComponent({
8187
+ name: "DPopperTrigger",
8188
+ setup(_, ctx) {
8189
+ const {
8190
+ slots,
8191
+ attrs
8192
+ } = ctx;
8193
+ return () => {
8194
+ var _a;
8195
+ const defaultSlot = (_a = slots.default) == null ? void 0 : _a.call(slots, attrs);
8196
+ const triggerRef = inject(POPPER_TRIGGER_TOKEN);
8197
+ if (!defaultSlot) {
8198
+ return null;
8199
+ }
8200
+ const firstValidChild = getFirstValidChild(defaultSlot);
8201
+ if (!firstValidChild) {
8202
+ return null;
8203
+ }
8204
+ return withDirectives(cloneVNode(firstValidChild, attrs), [[{
8205
+ mounted(el) {
8206
+ triggerRef.value = el;
8207
+ },
8208
+ updated(el) {
8209
+ triggerRef.value = el;
8210
+ },
8211
+ unmounted() {
8212
+ triggerRef.value = null;
8263
8213
  }
8264
- lodash2.prototype[methodName] = function() {
8265
- var value = this.__wrapped__, args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee2 = args[0], useLazy = isLazy || isArray2(value);
8266
- var interceptor = function(value2) {
8267
- var result3 = lodashFunc.apply(lodash2, arrayPush2([value2], args));
8268
- return isTaker && chainAll ? result3[0] : result3;
8269
- };
8270
- if (useLazy && checkIteratee && typeof iteratee2 == "function" && iteratee2.length != 1) {
8271
- isLazy = useLazy = false;
8272
- }
8273
- var chainAll = this.__chain__, isHybrid = !!this.__actions__.length, isUnwrapped = retUnwrapped && !chainAll, onlyLazy = isLazy && !isHybrid;
8274
- if (!retUnwrapped && useLazy) {
8275
- value = onlyLazy ? value : new LazyWrapper(this);
8276
- var result2 = func.apply(value, args);
8277
- result2.__actions__.push({ "func": thru, "args": [interceptor], "thisArg": undefined$1 });
8278
- return new LodashWrapper(result2, chainAll);
8279
- }
8280
- if (isUnwrapped && onlyLazy) {
8281
- return func.apply(this, args);
8282
- }
8283
- result2 = this.thru(interceptor);
8284
- return isUnwrapped ? isTaker ? result2.value()[0] : result2.value() : result2;
8285
- };
8286
- });
8287
- arrayEach2(["pop", "push", "shift", "sort", "splice", "unshift"], function(methodName) {
8288
- var func = arrayProto2[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:pop|shift)$/.test(methodName);
8289
- lodash2.prototype[methodName] = function() {
8290
- var args = arguments;
8291
- if (retUnwrapped && !this.__chain__) {
8292
- var value = this.value();
8293
- return func.apply(isArray2(value) ? value : [], args);
8294
- }
8295
- return this[chainName](function(value2) {
8296
- return func.apply(isArray2(value2) ? value2 : [], args);
8297
- });
8298
- };
8299
- });
8300
- baseForOwn(LazyWrapper.prototype, function(func, methodName) {
8301
- var lodashFunc = lodash2[methodName];
8302
- if (lodashFunc) {
8303
- var key = lodashFunc.name + "";
8304
- if (!hasOwnProperty2.call(realNames, key)) {
8305
- realNames[key] = [];
8306
- }
8307
- realNames[key].push({ "name": methodName, "func": lodashFunc });
8214
+ }]]);
8215
+ };
8216
+ }
8217
+ });
8218
+ var dropdown = "";
8219
+ let dropdownId = 1;
8220
+ var Dropdown = defineComponent({
8221
+ name: "DDropdown",
8222
+ inheritAttrs: false,
8223
+ props: dropdownProps,
8224
+ emits: ["toggle"],
8225
+ setup(props, {
8226
+ slots,
8227
+ attrs,
8228
+ emit,
8229
+ expose
8230
+ }) {
8231
+ const {
8232
+ visible,
8233
+ position,
8234
+ align,
8235
+ offset: offset2,
8236
+ destroyOnHide,
8237
+ shiftOffset,
8238
+ showAnimation
8239
+ } = toRefs(props);
8240
+ const origin = ref();
8241
+ const dropdownRef = ref();
8242
+ const overlayRef = ref();
8243
+ const id = `dropdown_${dropdownId++}`;
8244
+ const isOpen = ref(false);
8245
+ const currentPosition = ref("bottom");
8246
+ const ns2 = useNamespace("dropdown");
8247
+ provide(POPPER_TRIGGER_TOKEN, origin);
8248
+ useDropdownEvent({
8249
+ id,
8250
+ isOpen,
8251
+ origin,
8252
+ dropdownRef,
8253
+ props,
8254
+ emit
8255
+ });
8256
+ useDropdown(id, visible, isOpen, origin, dropdownRef, currentPosition, emit);
8257
+ const {
8258
+ overlayModelValue,
8259
+ overlayShowValue,
8260
+ styles,
8261
+ classes,
8262
+ handlePositionChange
8263
+ } = useOverlayProps(props, currentPosition, isOpen);
8264
+ watch(overlayShowValue, (overlayShowValueVal) => {
8265
+ nextTick(() => {
8266
+ if (!destroyOnHide.value && overlayShowValueVal) {
8267
+ overlayRef.value.updatePosition();
8308
8268
  }
8309
8269
  });
8310
- realNames[createHybrid(undefined$1, WRAP_BIND_KEY_FLAG).name] = [{
8311
- "name": "wrapper",
8312
- "func": undefined$1
8313
- }];
8314
- LazyWrapper.prototype.clone = lazyClone;
8315
- LazyWrapper.prototype.reverse = lazyReverse;
8316
- LazyWrapper.prototype.value = lazyValue;
8317
- lodash2.prototype.at = wrapperAt;
8318
- lodash2.prototype.chain = wrapperChain;
8319
- lodash2.prototype.commit = wrapperCommit;
8320
- lodash2.prototype.next = wrapperNext;
8321
- lodash2.prototype.plant = wrapperPlant;
8322
- lodash2.prototype.reverse = wrapperReverse;
8323
- lodash2.prototype.toJSON = lodash2.prototype.valueOf = lodash2.prototype.value = wrapperValue;
8324
- lodash2.prototype.first = lodash2.prototype.head;
8325
- if (symIterator) {
8326
- lodash2.prototype[symIterator] = wrapperToIterator;
8270
+ });
8271
+ expose({
8272
+ updatePosition: () => overlayRef.value.updatePosition()
8273
+ });
8274
+ return () => createVNode(Fragment, null, [createVNode(PopperTrigger, null, {
8275
+ default: () => {
8276
+ var _a;
8277
+ return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
8327
8278
  }
8328
- return lodash2;
8279
+ }), createVNode(Teleport, {
8280
+ "to": "body"
8281
+ }, {
8282
+ default: () => [createVNode(Transition, {
8283
+ "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
8284
+ }, {
8285
+ default: () => [withDirectives(createVNode(FlexibleOverlay, {
8286
+ "modelValue": overlayModelValue.value,
8287
+ "onUpdate:modelValue": ($event) => overlayModelValue.value = $event,
8288
+ "ref": overlayRef,
8289
+ "origin": origin.value,
8290
+ "position": position.value,
8291
+ "align": align.value,
8292
+ "offset": offset2.value,
8293
+ "shiftOffset": shiftOffset == null ? void 0 : shiftOffset.value,
8294
+ "onPositionChange": handlePositionChange,
8295
+ "click-event-bubble": true,
8296
+ "class": classes.value,
8297
+ "style": styles.value
8298
+ }, {
8299
+ default: () => {
8300
+ var _a;
8301
+ return [createVNode("div", mergeProps({
8302
+ "ref": dropdownRef,
8303
+ "class": ns2.e("menu-wrap")
8304
+ }, attrs), [(_a = slots.menu) == null ? void 0 : _a.call(slots)])];
8305
+ }
8306
+ }), [[vShow, overlayShowValue.value]])]
8307
+ })]
8308
+ })]);
8309
+ }
8310
+ });
8311
+ const dropdownMenuProps = {
8312
+ modelValue: {
8313
+ type: Boolean,
8314
+ default: false
8315
+ },
8316
+ origin: {
8317
+ type: Object,
8318
+ require: true
8319
+ },
8320
+ position: {
8321
+ type: Array,
8322
+ default: ["bottom"]
8323
+ },
8324
+ align: {
8325
+ type: String,
8326
+ default: null
8327
+ },
8328
+ offset: {
8329
+ type: [Number, Object],
8330
+ default: 4
8331
+ },
8332
+ clickOutside: {
8333
+ type: Function,
8334
+ default: () => true
8335
+ },
8336
+ showAnimation: {
8337
+ type: Boolean,
8338
+ default: true
8339
+ },
8340
+ overlayClass: {
8341
+ type: String,
8342
+ default: ""
8343
+ }
8344
+ };
8345
+ defineComponent({
8346
+ name: "DDropdownMenu",
8347
+ inheritAttrs: false,
8348
+ props: dropdownMenuProps,
8349
+ emits: ["update:modelValue"],
8350
+ setup(props, {
8351
+ slots,
8352
+ attrs,
8353
+ emit
8354
+ }) {
8355
+ const {
8356
+ modelValue,
8357
+ origin,
8358
+ position,
8359
+ align,
8360
+ offset: offset2,
8361
+ clickOutside,
8362
+ showAnimation,
8363
+ overlayClass
8364
+ } = toRefs(props);
8365
+ const dropdownMenuRef = ref(null);
8366
+ const ns2 = useNamespace("dropdown");
8367
+ onClickOutside(dropdownMenuRef, (value) => {
8368
+ var _a, _b;
8369
+ if (((_a = clickOutside.value) == null ? void 0 : _a.call(clickOutside)) && !((_b = origin == null ? void 0 : origin.value) == null ? void 0 : _b.contains(value.target))) {
8370
+ emit("update:modelValue", false);
8371
+ }
8372
+ });
8373
+ const currentPosition = ref("bottom");
8374
+ const handlePositionChange = (pos) => {
8375
+ currentPosition.value = pos.split("-")[0] === "top" ? "top" : "bottom";
8329
8376
  };
8330
- var _ = runInContext();
8331
- if (freeModule) {
8332
- (freeModule.exports = _)._ = _;
8333
- freeExports._ = _;
8334
- } else {
8335
- root2._ = _;
8336
- }
8337
- }).call(commonjsGlobal);
8338
- })(lodash, lodash.exports);
8377
+ const styles = computed(() => ({
8378
+ transformOrigin: currentPosition.value === "top" ? "0% 100%" : "0% 0%"
8379
+ }));
8380
+ return () => createVNode(Teleport, {
8381
+ "to": "body"
8382
+ }, {
8383
+ default: () => [createVNode(Transition, {
8384
+ "name": showAnimation.value ? ns2.m(`fade-${currentPosition.value}`) : ""
8385
+ }, {
8386
+ default: () => [createVNode(FlexibleOverlay, {
8387
+ "modelValue": modelValue.value,
8388
+ "onUpdate:modelValue": ($event) => modelValue.value = $event,
8389
+ "origin": origin == null ? void 0 : origin.value,
8390
+ "position": position.value,
8391
+ "align": align.value,
8392
+ "offset": offset2.value,
8393
+ "onPositionChange": handlePositionChange,
8394
+ "class": overlayClass.value,
8395
+ "style": styles.value
8396
+ }, {
8397
+ default: () => {
8398
+ var _a;
8399
+ return [createVNode("div", mergeProps({
8400
+ "ref": dropdownMenuRef,
8401
+ "class": ns2.e("menu-wrap")
8402
+ }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)])];
8403
+ }
8404
+ })]
8405
+ })]
8406
+ });
8407
+ }
8408
+ });
8409
+ const tooltipProps = {
8410
+ content: {
8411
+ type: String,
8412
+ default: ""
8413
+ },
8414
+ position: {
8415
+ type: [String, Array],
8416
+ default: "top"
8417
+ },
8418
+ showAnimation: {
8419
+ type: Boolean,
8420
+ default: true
8421
+ },
8422
+ mouseEnterDelay: {
8423
+ type: Number,
8424
+ default: 150
8425
+ },
8426
+ mouseLeaveDelay: {
8427
+ type: Number,
8428
+ default: 100
8429
+ },
8430
+ enterable: {
8431
+ type: Boolean,
8432
+ default: true
8433
+ },
8434
+ disabled: {
8435
+ type: Boolean,
8436
+ default: false
8437
+ },
8438
+ hideAfter: {
8439
+ type: Number,
8440
+ default: 0
8441
+ }
8442
+ };
8339
8443
  const transformOriginMap = {
8340
8444
  top: "50% calc(100% + 8px)",
8341
8445
  bottom: "50% -8px",
@@ -8565,13 +8669,17 @@ var ToolbarItem = defineComponent({
8565
8669
  const editorIns = getEditorIns();
8566
8670
  if (config.id === "fullscreen") {
8567
8671
  showFullscreen.value = !showFullscreen.value;
8568
- } else {
8569
- (_a = config.handler) == null ? void 0 : _a.call(config, editorIns, config.params);
8672
+ if (window) {
8673
+ const event = new Event("resize");
8674
+ window.dispatchEvent(event);
8675
+ }
8570
8676
  }
8677
+ (_a = config.handler) == null ? void 0 : _a.call(config, editorIns, config.params);
8571
8678
  };
8572
8679
  return () => createVNode(Fragment, null, [config.type === "button" && createVNode(Tooltip, {
8573
8680
  "position": ["top", "bottom"],
8574
- "content": getTooltipContent(config.name, config.shortKey)
8681
+ "content": getTooltipContent(config.name, config.shortKey),
8682
+ "hide-after": 1e3
8575
8683
  }, {
8576
8684
  default: () => [createVNode("span", {
8577
8685
  "class": "md-toolbar-item",
@@ -8583,8 +8691,9 @@ var ToolbarItem = defineComponent({
8583
8691
  "align": "start"
8584
8692
  }, {
8585
8693
  default: () => createVNode("span", null, [createVNode(Tooltip, {
8586
- "position": ["top"],
8587
- "content": getTooltipContent(config.name)
8694
+ "position": showFullscreen.value ? ["right"] : ["top"],
8695
+ "content": getTooltipContent(config.name),
8696
+ "hide-after": 1e3
8588
8697
  }, {
8589
8698
  default: () => [createVNode("span", {
8590
8699
  "class": "md-toolbar-item",
@@ -9010,7 +9119,7 @@ function useEditorMdRender(props, ctx) {
9010
9119
  const result = previewRef.value.querySelectorAll("input");
9011
9120
  const index2 = [...result].filter((el) => el.type === "checkbox").findIndex((item) => item === e.target);
9012
9121
  const checkContent = setChecked(e.target.checked, index2);
9013
- ctx.emit("mdCheckedEvent", checkContent);
9122
+ ctx.emit("checkedChange", checkContent);
9014
9123
  }
9015
9124
  };
9016
9125
  return { previewRef, renderService, onPreviewClick, setContainerContent };
@@ -9064,7 +9173,7 @@ function useMdRenderWatcher(props, renderService, setContainerContent) {
9064
9173
  var MdRender = defineComponent({
9065
9174
  name: "DMdRender",
9066
9175
  props: mdRenderProps,
9067
- emits: ["mdRenderChange", "mdCheckedEvent"],
9176
+ emits: ["mdRenderChange", "checkedChange"],
9068
9177
  setup(props, ctx) {
9069
9178
  const {
9070
9179
  previewRef,
@@ -9090,7 +9199,7 @@ function _isSlot(s) {
9090
9199
  var EditorMd = defineComponent({
9091
9200
  name: "DEditorMd",
9092
9201
  props: editorMdProps,
9093
- emits: ["update:modelValue", "mdCheckedEvent", "selectHint", "afterEditorInit", "contentChange", "previewContentChange", "imageUpload"],
9202
+ emits: ["update:modelValue", "checkedChange", "selectHint", "afterEditorInit", "contentChange", "previewContentChange", "imageUpload"],
9094
9203
  setup(props, ctx) {
9095
9204
  const {
9096
9205
  mode,
@@ -9113,7 +9222,10 @@ var EditorMd = defineComponent({
9113
9222
  const showFullscreen = ref(false);
9114
9223
  const {
9115
9224
  editorRef,
9225
+ overlayRef,
9226
+ cursorRef,
9116
9227
  renderRef,
9228
+ isHintShow,
9117
9229
  toolbars,
9118
9230
  previewHtmlList,
9119
9231
  onPaste,
@@ -9163,7 +9275,19 @@ var EditorMd = defineComponent({
9163
9275
  }, [createVNode("textarea", {
9164
9276
  "ref": editorRef,
9165
9277
  "placeholder": placeholder.value
9166
- }, [modelValue.value]), Boolean(maxlength == null ? void 0 : maxlength.value) && createVNode("div", {
9278
+ }, [modelValue.value]), createVNode(FlexibleOverlay, {
9279
+ "ref": overlayRef,
9280
+ "modelValue": isHintShow.value,
9281
+ "onUpdate:modelValue": ($event) => isHintShow.value = $event,
9282
+ "origin": cursorRef.value || void 0,
9283
+ "align": "start",
9284
+ "position": ["bottom-start"]
9285
+ }, {
9286
+ default: () => {
9287
+ var _a, _b;
9288
+ return [(_b = (_a = ctx.slots) == null ? void 0 : _a.hintTemplate) == null ? void 0 : _b.call(_a)];
9289
+ }
9290
+ }), Boolean(maxlength == null ? void 0 : maxlength.value) && createVNode("div", {
9167
9291
  "class": "dp-md-count"
9168
9292
  }, [modelValue.value.length || 0, createTextVNode("/"), maxlength.value])]), createVNode(MdRender, {
9169
9293
  "ref": renderRef,
@@ -9178,7 +9302,7 @@ var EditorMd = defineComponent({
9178
9302
  "disable-render": true,
9179
9303
  "md-plugins": mdPlugins.value,
9180
9304
  "onMdRenderChange": previewContentChange,
9181
- "onMdCheckedEvent": onChecked,
9305
+ "onCheckedChange": onChecked,
9182
9306
  "onScroll": onPreviewScroll,
9183
9307
  "onMouseover": onPreviewMouseover,
9184
9308
  "onMouseout": onPreviewMouseout
@@ -9192,6 +9316,92 @@ var EditorMd = defineComponent({
9192
9316
  };
9193
9317
  }
9194
9318
  });
9319
+ const checkboxReplace = function(md, options) {
9320
+ let lastId;
9321
+ const arrReplaceAt = md.utils.arrayReplaceAt;
9322
+ lastId = 0;
9323
+ const defaults = {
9324
+ divWrap: false,
9325
+ divClass: "checkbox",
9326
+ idPrefix: "checkbox"
9327
+ };
9328
+ options = lodash.exports.extend(defaults, options);
9329
+ const pattern = /\[(X|\s|\_|\-)\]\s(.*)/i;
9330
+ const createTokens = function(checked, label, Token2) {
9331
+ let token;
9332
+ const nodes = [];
9333
+ if (options.divWrap) {
9334
+ token = new Token2("checkbox_open", "div", 1);
9335
+ token.attrs = [["class", "checkbox"]];
9336
+ nodes.push(token);
9337
+ }
9338
+ const id = options.idPrefix + lastId;
9339
+ lastId += 1;
9340
+ token = new Token2("checkbox_input", "input", 0);
9341
+ token.attrs = [
9342
+ ["type", "checkbox"],
9343
+ ["id", id]
9344
+ ];
9345
+ if (options.disabled) {
9346
+ token.attrs.push(["disabled", true]);
9347
+ }
9348
+ if (checked === true) {
9349
+ token.attrs.push(["checked", "true"]);
9350
+ }
9351
+ nodes.push(token);
9352
+ token = new Token2("label_open", "label", 1);
9353
+ token.attrs = [["for", id]];
9354
+ nodes.push(token);
9355
+ token = new Token2("text", "", 0);
9356
+ token.content = label;
9357
+ nodes.push(token);
9358
+ nodes.push(new Token2("label_close", "label", -1));
9359
+ if (options.divWrap) {
9360
+ nodes.push(new Token2("checkbox_close", "div", -1));
9361
+ }
9362
+ return nodes;
9363
+ };
9364
+ const splitTextToken = function(original, Token2) {
9365
+ let checked;
9366
+ const text = original.content;
9367
+ const matches = text.match(pattern);
9368
+ if (matches === null) {
9369
+ return original;
9370
+ }
9371
+ checked = false;
9372
+ const value = matches[1];
9373
+ const label = matches[2];
9374
+ if (value === "X" || value === "x") {
9375
+ checked = true;
9376
+ }
9377
+ return createTokens(checked, label, Token2);
9378
+ };
9379
+ return function(state) {
9380
+ let i, j, token, tokens;
9381
+ const blockTokens = state.tokens;
9382
+ j = 0;
9383
+ const l = blockTokens.length;
9384
+ while (j < l) {
9385
+ if (blockTokens[j].type !== "inline") {
9386
+ j++;
9387
+ continue;
9388
+ }
9389
+ tokens = blockTokens[j].children;
9390
+ i = tokens.length - 1;
9391
+ while (i >= 0) {
9392
+ token = tokens[i];
9393
+ if (token.type === "text" && pattern.test(token.content)) {
9394
+ blockTokens[j].children = tokens = arrReplaceAt(tokens, i, splitTextToken(token, state.Token));
9395
+ }
9396
+ i--;
9397
+ }
9398
+ j++;
9399
+ }
9400
+ };
9401
+ };
9402
+ function checkbox(md, options) {
9403
+ md.core.ruler.push("checkbox", checkboxReplace(md, options));
9404
+ }
9195
9405
  var index = {
9196
9406
  title: "Markdown MD\u7F16\u8F91\u5668",
9197
9407
  category: "\u6F14\u8FDB\u4E2D",
@@ -9201,4 +9411,4 @@ var index = {
9201
9411
  app.component(MdRender.name, MdRender);
9202
9412
  }
9203
9413
  };
9204
- export { EditorMd, EditorMdInjectionKey, MdRender, index as default, editorMdProps, mdRenderProps, mdToolbarItemProps };
9414
+ export { EditorMd, EditorMdInjectionKey, MdRender, checkbox, index as default, editorMdProps, mdRenderProps, mdToolbarItemProps };