xrk-components 0.4.2-beta.3 → 0.4.2-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.esm.js CHANGED
@@ -1,6 +1,12 @@
1
1
  import { ref, watch, getCurrentScope, onScopeDispose, unref, getCurrentInstance, onMounted, nextTick, openBlock, createElementBlock, createElementVNode, warn, computed as computed$1, provide, inject, watchEffect, onBeforeUnmount, toRef, onUnmounted, isRef, onBeforeMount, defineComponent, mergeProps, renderSlot, useAttrs as useAttrs$1, useSlots, shallowRef, withDirectives, createCommentVNode, Fragment, normalizeClass, createBlock, withCtx, resolveDynamicComponent, withModifiers, createVNode, toDisplayString, normalizeStyle, vShow, Transition, reactive, onUpdated, cloneVNode, Text, Comment, Teleport, readonly, onDeactivated, renderList, createTextVNode, toRaw as toRaw$1, vModelCheckbox, toRefs, vModelRadio, withKeys, h as h$1, createSlots, triggerRef, resolveComponent, resolveDirective, vModelText, createApp, normalizeProps, render } from 'vue';
2
2
  import { check, base } from 'xrk-tools';
3
3
 
4
+ /*
5
+ * @Description:
6
+ * @Date: 2022-10-18 09:44:40
7
+ */
8
+ // 作用域问题导致无法使用inject方式在各组件内接收到defineProps。可通过修改当前app上下文处理,use-create-modal中已实现。
9
+ // import { inject, computed } from 'vue';
4
10
  var provideKey = 'defaultProps';
5
11
  var useSetGlobalDefaultProps = function (props) {
6
12
  window[provideKey] = props;
@@ -20440,7 +20446,7 @@ const inputEmits = {
20440
20446
 
20441
20447
  const _hoisted_1$y = ["role"];
20442
20448
  const _hoisted_2$m = ["id", "type", "disabled", "formatter", "parser", "readonly", "autocomplete", "tabindex", "aria-label", "placeholder", "form"];
20443
- const _hoisted_3$b = ["id", "tabindex", "disabled", "readonly", "autocomplete", "aria-label", "placeholder", "form"];
20449
+ const _hoisted_3$a = ["id", "tabindex", "disabled", "readonly", "autocomplete", "aria-label", "placeholder", "form"];
20444
20450
  const __default__$Q = defineComponent({
20445
20451
  name: "ElInput",
20446
20452
  inheritAttrs: false
@@ -20833,7 +20839,7 @@ const _sfc_main$K = /* @__PURE__ */ defineComponent({
20833
20839
  onBlur: handleBlur,
20834
20840
  onChange: handleChange,
20835
20841
  onKeydown: handleKeydown
20836
- }), null, 16, _hoisted_3$b),
20842
+ }), null, 16, _hoisted_3$a),
20837
20843
  unref(isWordLimitVisible) ? (openBlock(), createElementBlock("span", {
20838
20844
  key: 0,
20839
20845
  style: normalizeStyle(countStyle.value),
@@ -25934,7 +25940,7 @@ const useCheckbox = (props, slots) => {
25934
25940
 
25935
25941
  const _hoisted_1$t = ["tabindex", "role", "aria-checked"];
25936
25942
  const _hoisted_2$i = ["id", "aria-hidden", "name", "tabindex", "disabled", "true-value", "false-value"];
25937
- const _hoisted_3$a = ["id", "aria-hidden", "disabled", "value", "name", "tabindex"];
25943
+ const _hoisted_3$9 = ["id", "aria-hidden", "disabled", "value", "name", "tabindex"];
25938
25944
  const __default__$E = defineComponent({
25939
25945
  name: "ElCheckbox"
25940
25946
  });
@@ -26014,7 +26020,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
26014
26020
  onChange: _cache[5] || (_cache[5] = (...args) => unref(handleChange) && unref(handleChange)(...args)),
26015
26021
  onFocus: _cache[6] || (_cache[6] = ($event) => isFocused.value = true),
26016
26022
  onBlur: _cache[7] || (_cache[7] = ($event) => isFocused.value = false)
26017
- }, null, 42, _hoisted_3$a)), [
26023
+ }, null, 42, _hoisted_3$9)), [
26018
26024
  [vModelCheckbox, unref(model)]
26019
26025
  ]),
26020
26026
  createElementVNode("span", {
@@ -26871,7 +26877,7 @@ const _hoisted_2$g = {
26871
26877
  key: 0,
26872
26878
  scope: "col"
26873
26879
  };
26874
- const _hoisted_3$9 = ["aria-label"];
26880
+ const _hoisted_3$8 = ["aria-label"];
26875
26881
  const _hoisted_4$5 = ["aria-current", "aria-selected", "tabindex"];
26876
26882
  const _sfc_main$m = /* @__PURE__ */ defineComponent({
26877
26883
  __name: "basic-date-table",
@@ -27189,7 +27195,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
27189
27195
  key,
27190
27196
  scope: "col",
27191
27197
  "aria-label": unref(t)("el.datepicker.weeksFull." + week)
27192
- }, toDisplayString(unref(t)("el.datepicker.weeks." + week)), 9, _hoisted_3$9);
27198
+ }, toDisplayString(unref(t)("el.datepicker.weeks." + week)), 9, _hoisted_3$8);
27193
27199
  }), 128))
27194
27200
  ]),
27195
27201
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(rows), (row, rowKey) => {
@@ -27227,7 +27233,7 @@ const basicMonthTableProps = buildProps({
27227
27233
 
27228
27234
  const _hoisted_1$n = ["aria-label"];
27229
27235
  const _hoisted_2$f = ["aria-selected", "aria-label", "tabindex", "onKeydown"];
27230
- const _hoisted_3$8 = { class: "cell" };
27236
+ const _hoisted_3$7 = { class: "cell" };
27231
27237
  const _sfc_main$l = /* @__PURE__ */ defineComponent({
27232
27238
  __name: "basic-month-table",
27233
27239
  props: basicMonthTableProps,
@@ -27410,7 +27416,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
27410
27416
  ]
27411
27417
  }, [
27412
27418
  createElementVNode("div", null, [
27413
- createElementVNode("span", _hoisted_3$8, toDisplayString(unref(t)("el.datepicker.months." + months.value[cell.text])), 1)
27419
+ createElementVNode("span", _hoisted_3$7, toDisplayString(unref(t)("el.datepicker.months." + months.value[cell.text])), 1)
27414
27420
  ])
27415
27421
  ], 42, _hoisted_2$f);
27416
27422
  }), 128))
@@ -27432,7 +27438,7 @@ const basicYearTableProps = buildProps({
27432
27438
 
27433
27439
  const _hoisted_1$m = ["aria-label"];
27434
27440
  const _hoisted_2$e = ["aria-selected", "tabindex", "onKeydown"];
27435
- const _hoisted_3$7 = { class: "cell" };
27441
+ const _hoisted_3$6 = { class: "cell" };
27436
27442
  const _hoisted_4$4 = { key: 1 };
27437
27443
  const _sfc_main$k = /* @__PURE__ */ defineComponent({
27438
27444
  __name: "basic-year-table",
@@ -27517,7 +27523,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
27517
27523
  withKeys(withModifiers(handleYearTableClick, ["prevent", "stop"]), ["enter"])
27518
27524
  ]
27519
27525
  }, [
27520
- createElementVNode("span", _hoisted_3$7, toDisplayString(unref(startYear) + i * 4 + j), 1)
27526
+ createElementVNode("span", _hoisted_3$6, toDisplayString(unref(startYear) + i * 4 + j), 1)
27521
27527
  ], 42, _hoisted_2$e)) : (openBlock(), createElementBlock("td", _hoisted_4$4))
27522
27528
  ], 64);
27523
27529
  }), 64))
@@ -27532,7 +27538,7 @@ var YearTable = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__file", "/home/runn
27532
27538
 
27533
27539
  const _hoisted_1$l = ["onClick"];
27534
27540
  const _hoisted_2$d = ["aria-label"];
27535
- const _hoisted_3$6 = ["aria-label"];
27541
+ const _hoisted_3$5 = ["aria-label"];
27536
27542
  const _hoisted_4$3 = ["aria-label"];
27537
27543
  const _hoisted_5$3 = ["aria-label"];
27538
27544
  const _sfc_main$j = /* @__PURE__ */ defineComponent({
@@ -28020,7 +28026,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
28020
28026
  ]),
28021
28027
  _: 1
28022
28028
  })
28023
- ], 10, _hoisted_3$6), [
28029
+ ], 10, _hoisted_3$5), [
28024
28030
  [vShow, currentView.value === "date"]
28025
28031
  ])
28026
28032
  ], 2),
@@ -28259,7 +28265,7 @@ const useRangePicker = (props, {
28259
28265
 
28260
28266
  const _hoisted_1$k = ["onClick"];
28261
28267
  const _hoisted_2$c = ["disabled"];
28262
- const _hoisted_3$5 = ["disabled"];
28268
+ const _hoisted_3$4 = ["disabled"];
28263
28269
  const _hoisted_4$2 = ["disabled"];
28264
28270
  const _hoisted_5$2 = ["disabled"];
28265
28271
  const unit$1 = "month";
@@ -28775,7 +28781,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
28775
28781
  ]),
28776
28782
  _: 1
28777
28783
  })
28778
- ], 10, _hoisted_3$5)) : createCommentVNode("v-if", true),
28784
+ ], 10, _hoisted_3$4)) : createCommentVNode("v-if", true),
28779
28785
  createElementVNode("div", null, toDisplayString(unref(leftLabel)), 1)
28780
28786
  ], 2),
28781
28787
  createVNode(DateTable, {
@@ -28959,7 +28965,7 @@ const useMonthRangeHeader = ({
28959
28965
 
28960
28966
  const _hoisted_1$j = ["onClick"];
28961
28967
  const _hoisted_2$b = ["disabled"];
28962
- const _hoisted_3$4 = ["disabled"];
28968
+ const _hoisted_3$3 = ["disabled"];
28963
28969
  const unit = "year";
28964
28970
  const __default__$x = defineComponent({
28965
28971
  name: "DatePickerMonthRange"
@@ -29137,7 +29143,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
29137
29143
  ]),
29138
29144
  _: 1
29139
29145
  })
29140
- ], 10, _hoisted_3$4)) : createCommentVNode("v-if", true),
29146
+ ], 10, _hoisted_3$3)) : createCommentVNode("v-if", true),
29141
29147
  createElementVNode("button", {
29142
29148
  type: "button",
29143
29149
  class: normalizeClass([unref(ppNs).e("icon-btn"), "d-arrow-right"]),
@@ -33716,7 +33722,7 @@ const paginationPagerProps = buildProps({
33716
33722
 
33717
33723
  const _hoisted_1$a = ["onKeyup"];
33718
33724
  const _hoisted_2$6 = ["aria-current", "tabindex"];
33719
- const _hoisted_3$3 = ["tabindex"];
33725
+ const _hoisted_3$2 = ["tabindex"];
33720
33726
  const _hoisted_4$1 = ["aria-current", "tabindex"];
33721
33727
  const _hoisted_5$1 = ["tabindex"];
33722
33728
  const _hoisted_6 = ["aria-current", "tabindex"];
@@ -33873,7 +33879,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
33873
33879
  onBlur: _cache[3] || (_cache[3] = ($event) => quickPrevFocus.value = false)
33874
33880
  }, [
33875
33881
  quickPrevHover.value || quickPrevFocus.value ? (openBlock(), createBlock(unref(d_arrow_left_default), { key: 0 })) : (openBlock(), createBlock(unref(more_filled_default), { key: 1 }))
33876
- ], 42, _hoisted_3$3)) : createCommentVNode("v-if", true),
33882
+ ], 42, _hoisted_3$2)) : createCommentVNode("v-if", true),
33877
33883
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(pagers), (pager) => {
33878
33884
  return openBlock(), createElementBlock("li", {
33879
33885
  key: pager,
@@ -34259,7 +34265,7 @@ const switchEmits = {
34259
34265
 
34260
34266
  const _hoisted_1$9 = ["onClick"];
34261
34267
  const _hoisted_2$5 = ["id", "aria-checked", "aria-disabled", "name", "true-value", "false-value", "disabled", "tabindex", "onKeydown"];
34262
- const _hoisted_3$2 = ["aria-hidden"];
34268
+ const _hoisted_3$1 = ["aria-hidden"];
34263
34269
  const _hoisted_4 = ["aria-hidden"];
34264
34270
  const _hoisted_5 = ["aria-hidden"];
34265
34271
  const COMPONENT_NAME = "ElSwitch";
@@ -34420,7 +34426,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
34420
34426
  !_ctx.inactiveIcon && _ctx.inactiveText ? (openBlock(), createElementBlock("span", {
34421
34427
  key: 1,
34422
34428
  "aria-hidden": unref(checked)
34423
- }, toDisplayString(_ctx.inactiveText), 9, _hoisted_3$2)) : createCommentVNode("v-if", true)
34429
+ }, toDisplayString(_ctx.inactiveText), 9, _hoisted_3$1)) : createCommentVNode("v-if", true)
34424
34430
  ], 2)) : createCommentVNode("v-if", true),
34425
34431
  createElementVNode("span", {
34426
34432
  ref_key: "core",
@@ -36256,7 +36262,7 @@ const _sfc_main$1 = defineComponent({
36256
36262
  });
36257
36263
  const _hoisted_1$8 = { key: 0 };
36258
36264
  const _hoisted_2$4 = ["disabled"];
36259
- const _hoisted_3$1 = ["label", "onClick"];
36265
+ const _hoisted_3 = ["label", "onClick"];
36260
36266
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
36261
36267
  const _component_el_checkbox = resolveComponent("el-checkbox");
36262
36268
  const _component_el_checkbox_group = resolveComponent("el-checkbox-group");
@@ -36345,7 +36351,7 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
36345
36351
  class: normalizeClass([_ctx.ns.e("list-item"), _ctx.ns.is("active", _ctx.isActive(filter))]),
36346
36352
  label: filter.value,
36347
36353
  onClick: ($event) => _ctx.handleSelect(filter.value)
36348
- }, toDisplayString(filter.text), 11, _hoisted_3$1);
36354
+ }, toDisplayString(filter.text), 11, _hoisted_3);
36349
36355
  }), 128))
36350
36356
  ], 2))
36351
36357
  ]),
@@ -41891,7 +41897,6 @@ var XrkTable = script$1;
41891
41897
 
41892
41898
  var _hoisted_1 = { key: 1 };
41893
41899
  var _hoisted_2 = { key: 1 };
41894
- var _hoisted_3 = { key: 1 };
41895
41900
  var __default__ = {
41896
41901
  name: 'base-dialog'
41897
41902
  };
@@ -42022,42 +42027,44 @@ var script = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__), {
42022
42027
  key: 0,
42023
42028
  render: __props.titleRender
42024
42029
  }, null, 8 /* PROPS */, ["render"]))
42025
- : (__props.title)
42026
- ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(__props.title), 1 /* TEXT */))
42027
- : renderSlot(_ctx.$slots, "header", { key: 2 })
42030
+ : renderSlot(_ctx.$slots, "header", { key: 1 }, function () { return [
42031
+ createTextVNode(toDisplayString(__props.title), 1 /* TEXT */)
42032
+ ]; })
42028
42033
  ]; }),
42029
42034
  footer: withCtx(function () { return [
42030
- (__props.footerRender)
42031
- ? (openBlock(), createBlock(unref(BaseDialogRender), {
42032
- key: 0,
42033
- render: __props.footerRender
42034
- }, null, 8 /* PROPS */, ["render"]))
42035
- : (__props.showFooter)
42036
- ? (openBlock(), createElementBlock("div", _hoisted_3, [
42037
- (__props.cancelBtnConfig.show)
42038
- ? (openBlock(), createBlock(unref(BaseButton), mergeProps({
42039
- key: 0,
42040
- size: "large"
42041
- }, __props.cancelBtnConfig, { click: handleCancelClick }), {
42042
- default: withCtx(function () { return [
42043
- createTextVNode(toDisplayString(__props.cancelBtnConfig.content), 1 /* TEXT */)
42044
- ]; }),
42045
- _: 1 /* STABLE */
42046
- }, 16 /* FULL_PROPS */))
42047
- : createCommentVNode("v-if", true),
42048
- (__props.confirmBtnConfig.show)
42049
- ? (openBlock(), createBlock(unref(BaseButton), mergeProps({
42050
- key: 1,
42051
- size: "large"
42052
- }, __props.confirmBtnConfig, { click: handleConfirmClick }), {
42053
- default: withCtx(function () { return [
42054
- createTextVNode(toDisplayString(__props.confirmBtnConfig.content), 1 /* TEXT */)
42055
- ]; }),
42056
- _: 1 /* STABLE */
42057
- }, 16 /* FULL_PROPS */))
42058
- : createCommentVNode("v-if", true)
42059
- ]))
42060
- : createCommentVNode("v-if", true)
42035
+ renderSlot(_ctx.$slots, "footer", {}, function () { return [
42036
+ (__props.footerRender)
42037
+ ? (openBlock(), createBlock(unref(BaseDialogRender), {
42038
+ key: 0,
42039
+ render: __props.footerRender
42040
+ }, null, 8 /* PROPS */, ["render"]))
42041
+ : (__props.showFooter)
42042
+ ? (openBlock(), createElementBlock("div", _hoisted_2, [
42043
+ (__props.cancelBtnConfig.show)
42044
+ ? (openBlock(), createBlock(unref(BaseButton), mergeProps({
42045
+ key: 0,
42046
+ size: "large"
42047
+ }, __props.cancelBtnConfig, { click: handleCancelClick }), {
42048
+ default: withCtx(function () { return [
42049
+ createTextVNode(toDisplayString(__props.cancelBtnConfig.content), 1 /* TEXT */)
42050
+ ]; }),
42051
+ _: 1 /* STABLE */
42052
+ }, 16 /* FULL_PROPS */))
42053
+ : createCommentVNode("v-if", true),
42054
+ (__props.confirmBtnConfig.show)
42055
+ ? (openBlock(), createBlock(unref(BaseButton), mergeProps({
42056
+ key: 1,
42057
+ size: "large"
42058
+ }, __props.confirmBtnConfig, { click: handleConfirmClick }), {
42059
+ default: withCtx(function () { return [
42060
+ createTextVNode(toDisplayString(__props.confirmBtnConfig.content), 1 /* TEXT */)
42061
+ ]; }),
42062
+ _: 1 /* STABLE */
42063
+ }, 16 /* FULL_PROPS */))
42064
+ : createCommentVNode("v-if", true)
42065
+ ]))
42066
+ : createCommentVNode("v-if", true)
42067
+ ]; })
42061
42068
  ]; }),
42062
42069
  default: withCtx(function () { return [
42063
42070
  (__props.contentRender)
@@ -42066,7 +42073,7 @@ var script = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__), {
42066
42073
  render: __props.contentRender
42067
42074
  }, null, 8 /* PROPS */, ["render"]))
42068
42075
  : (__props.content)
42069
- ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(__props.content), 1 /* TEXT */))
42076
+ ? (openBlock(), createElementBlock("div", _hoisted_1, toDisplayString(__props.content), 1 /* TEXT */))
42070
42077
  : renderSlot(_ctx.$slots, "default", { key: 2 })
42071
42078
  ]; }),
42072
42079
  _: 3 /* FORWARDED */
@@ -42084,19 +42091,39 @@ var createDialog = function (config) {
42084
42091
  container.classList.add('_xrk_create_dialog');
42085
42092
  container.style.position = 'relative';
42086
42093
  container.style.zIndex = "".concat(200 + customDialogCount);
42087
- render(h$1(script, __assign(__assign({ modelValue: true }, (config || {})), { appendToBody: false, onClose: function () { return __awaiter(void 0, void 0, void 0, function () {
42088
- var _a, _b;
42089
- return __generator(this, function (_c) {
42090
- switch (_c.label) {
42091
- case 0: return [4 /*yield*/, ((_a = config === null || config === void 0 ? void 0 : config.onClose) === null || _a === void 0 ? void 0 : _a.call(config))];
42092
- case 1:
42093
- _c.sent();
42094
- (_b = document.querySelector('body')) === null || _b === void 0 ? void 0 : _b.removeChild(container);
42095
- return [2 /*return*/];
42096
- }
42094
+ var _instance = null;
42095
+ var close = function () { return __awaiter(void 0, void 0, void 0, function () {
42096
+ var _a, _b;
42097
+ return __generator(this, function (_c) {
42098
+ switch (_c.label) {
42099
+ case 0: return [4 /*yield*/, ((_a = config === null || config === void 0 ? void 0 : config.onClose) === null || _a === void 0 ? void 0 : _a.call(config))];
42100
+ case 1:
42101
+ _c.sent();
42102
+ (_b = document.querySelector('body')) === null || _b === void 0 ? void 0 : _b.removeChild(container);
42103
+ _instance = null;
42104
+ return [2 /*return*/];
42105
+ }
42106
+ });
42107
+ }); };
42108
+ _instance = h$1(script, __assign({ modelValue: true, appendToBody: false, onClose: function () { return __awaiter(void 0, void 0, void 0, function () {
42109
+ return __generator(this, function (_a) {
42110
+ close();
42111
+ return [2 /*return*/];
42097
42112
  });
42098
- }); } })), container);
42113
+ }); } }, (config || {})));
42114
+ if (config && config.app) {
42115
+ _instance.appContext = config.app._context; // 承接上下文,用于inject,调用层需要使用app.provide
42116
+ }
42117
+ render(_instance, container);
42099
42118
  (_a = document.querySelector('body')) === null || _a === void 0 ? void 0 : _a.appendChild(container);
42119
+ _instance.component.ctx.close = close;
42120
+ _instance.component.ctx.$updateProps = function (props) {
42121
+ props &&
42122
+ Object.keys(props).forEach(function (k) {
42123
+ _instance.component.props[k] = props[k];
42124
+ });
42125
+ };
42126
+ return _instance.component.ctx;
42100
42127
  };
42101
42128
 
42102
42129
  /*
@@ -42157,6 +42184,46 @@ var useOtherComponents = function (otherComponents) {
42157
42184
  return otherComponents;
42158
42185
  };
42159
42186
 
42187
+ var useCreateModal = function (component, options, app) {
42188
+ var _a;
42189
+ console.log('useCreateModal app:', app);
42190
+ var _instance = null;
42191
+ var container = document.createElement('div');
42192
+ var remove = function () {
42193
+ container.remove();
42194
+ _instance = null;
42195
+ };
42196
+ _instance = createVNode(component, __assign({ remove: remove, close: remove, onRemove: function () {
42197
+ remove();
42198
+ },
42199
+ // 兼容base-dialog
42200
+ onClose: function () {
42201
+ remove();
42202
+ },
42203
+ // 兼容base-dialog,true会导致没有append到container容器中
42204
+ appendToBody: false }, options));
42205
+ // inject 函数调用组件导致内部inject无法接收到,需要使用app.provide(全局): https://github.com/vuejs/core/issues/6220
42206
+ // context createApp需要use插件,内部才能使用插件\库相关API。可以直接修改上下文: https://github.com/vuejs/core/issues/2097
42207
+ if (app) {
42208
+ _instance.appContext = app._context; // 承接上下文,用于inject,调用层需要使用app.provide
42209
+ }
42210
+ render(_instance, container);
42211
+ (_a = document.querySelector('body')) === null || _a === void 0 ? void 0 : _a.appendChild(container);
42212
+ // 在组件添加一个 remove 方法用来销毁组件
42213
+ // 组件内调用 currentInstance.ctx.remove()
42214
+ _instance.component.ctx.remove = remove;
42215
+ _instance.component.ctx.close = close;
42216
+ console.log(_instance, '组件_instance');
42217
+ // 更新props方法
42218
+ _instance.component.ctx.$updateProps = function (props) {
42219
+ props &&
42220
+ Object.keys(props).forEach(function (k) {
42221
+ _instance.component.props[k] = props[k];
42222
+ });
42223
+ };
42224
+ return _instance.component.ctx;
42225
+ };
42226
+
42160
42227
  /*
42161
42228
  * @Description:
42162
42229
  * @Date: 2022-06-30 22:57:28
@@ -42180,4 +42247,4 @@ var index = {
42180
42247
  install: install
42181
42248
  };
42182
42249
 
42183
- export { BaseButton, BaseCheckbox, BaseCheckboxButton, BaseCheckboxGroup, BaseDatePicker, BaseDialog, BaseForm, BaseFormItem, BaseInput, BasePagination, BaseRadio, BaseRadioButton, BaseRadioGroup, BaseSelect, BaseSwitch, BaseTable, BaseTag, BaseTagGroup, XrkSearch, XrkTable, createDialog, index as default, useDatePickerColumn, useInputColumn, useOtherComponents, useResetBtn, useSearchBtn, useSearchColumns, useSelectColumn, useTableColumn };
42250
+ export { BaseButton, BaseCheckbox, BaseCheckboxButton, BaseCheckboxGroup, BaseDatePicker, BaseDialog, BaseForm, BaseFormItem, BaseInput, BasePagination, BaseRadio, BaseRadioButton, BaseRadioGroup, BaseSelect, BaseSwitch, BaseTable, BaseTag, BaseTagGroup, XrkSearch, XrkTable, createDialog, index as default, useCreateModal, useDatePickerColumn, useInputColumn, useOtherComponents, useResetBtn, useSearchBtn, useSearchColumns, useSelectColumn, useTableColumn };
package/lib/index.umd.js CHANGED
@@ -4,6 +4,12 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Xrk = {}, global.vue, global.xrkTools));
5
5
  })(this, (function (exports, vue, xrkTools) { 'use strict';
6
6
 
7
+ /*
8
+ * @Description:
9
+ * @Date: 2022-10-18 09:44:40
10
+ */
11
+ // 作用域问题导致无法使用inject方式在各组件内接收到defineProps。可通过修改当前app上下文处理,use-create-modal中已实现。
12
+ // import { inject, computed } from 'vue';
7
13
  var provideKey = 'defaultProps';
8
14
  var useSetGlobalDefaultProps = function (props) {
9
15
  window[provideKey] = props;
@@ -20443,7 +20449,7 @@ usage: app.provide(ID_INJECTION_KEY, {
20443
20449
 
20444
20450
  const _hoisted_1$y = ["role"];
20445
20451
  const _hoisted_2$m = ["id", "type", "disabled", "formatter", "parser", "readonly", "autocomplete", "tabindex", "aria-label", "placeholder", "form"];
20446
- const _hoisted_3$b = ["id", "tabindex", "disabled", "readonly", "autocomplete", "aria-label", "placeholder", "form"];
20452
+ const _hoisted_3$a = ["id", "tabindex", "disabled", "readonly", "autocomplete", "aria-label", "placeholder", "form"];
20447
20453
  const __default__$Q = vue.defineComponent({
20448
20454
  name: "ElInput",
20449
20455
  inheritAttrs: false
@@ -20836,7 +20842,7 @@ usage: app.provide(ID_INJECTION_KEY, {
20836
20842
  onBlur: handleBlur,
20837
20843
  onChange: handleChange,
20838
20844
  onKeydown: handleKeydown
20839
- }), null, 16, _hoisted_3$b),
20845
+ }), null, 16, _hoisted_3$a),
20840
20846
  vue.unref(isWordLimitVisible) ? (vue.openBlock(), vue.createElementBlock("span", {
20841
20847
  key: 0,
20842
20848
  style: vue.normalizeStyle(countStyle.value),
@@ -25937,7 +25943,7 @@ usage: app.provide(ID_INJECTION_KEY, {
25937
25943
 
25938
25944
  const _hoisted_1$t = ["tabindex", "role", "aria-checked"];
25939
25945
  const _hoisted_2$i = ["id", "aria-hidden", "name", "tabindex", "disabled", "true-value", "false-value"];
25940
- const _hoisted_3$a = ["id", "aria-hidden", "disabled", "value", "name", "tabindex"];
25946
+ const _hoisted_3$9 = ["id", "aria-hidden", "disabled", "value", "name", "tabindex"];
25941
25947
  const __default__$E = vue.defineComponent({
25942
25948
  name: "ElCheckbox"
25943
25949
  });
@@ -26017,7 +26023,7 @@ usage: app.provide(ID_INJECTION_KEY, {
26017
26023
  onChange: _cache[5] || (_cache[5] = (...args) => vue.unref(handleChange) && vue.unref(handleChange)(...args)),
26018
26024
  onFocus: _cache[6] || (_cache[6] = ($event) => isFocused.value = true),
26019
26025
  onBlur: _cache[7] || (_cache[7] = ($event) => isFocused.value = false)
26020
- }, null, 42, _hoisted_3$a)), [
26026
+ }, null, 42, _hoisted_3$9)), [
26021
26027
  [vue.vModelCheckbox, vue.unref(model)]
26022
26028
  ]),
26023
26029
  vue.createElementVNode("span", {
@@ -26874,7 +26880,7 @@ usage: app.provide(ID_INJECTION_KEY, {
26874
26880
  key: 0,
26875
26881
  scope: "col"
26876
26882
  };
26877
- const _hoisted_3$9 = ["aria-label"];
26883
+ const _hoisted_3$8 = ["aria-label"];
26878
26884
  const _hoisted_4$5 = ["aria-current", "aria-selected", "tabindex"];
26879
26885
  const _sfc_main$m = /* @__PURE__ */ vue.defineComponent({
26880
26886
  __name: "basic-date-table",
@@ -27192,7 +27198,7 @@ usage: app.provide(ID_INJECTION_KEY, {
27192
27198
  key,
27193
27199
  scope: "col",
27194
27200
  "aria-label": vue.unref(t)("el.datepicker.weeksFull." + week)
27195
- }, vue.toDisplayString(vue.unref(t)("el.datepicker.weeks." + week)), 9, _hoisted_3$9);
27201
+ }, vue.toDisplayString(vue.unref(t)("el.datepicker.weeks." + week)), 9, _hoisted_3$8);
27196
27202
  }), 128))
27197
27203
  ]),
27198
27204
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(rows), (row, rowKey) => {
@@ -27230,7 +27236,7 @@ usage: app.provide(ID_INJECTION_KEY, {
27230
27236
 
27231
27237
  const _hoisted_1$n = ["aria-label"];
27232
27238
  const _hoisted_2$f = ["aria-selected", "aria-label", "tabindex", "onKeydown"];
27233
- const _hoisted_3$8 = { class: "cell" };
27239
+ const _hoisted_3$7 = { class: "cell" };
27234
27240
  const _sfc_main$l = /* @__PURE__ */ vue.defineComponent({
27235
27241
  __name: "basic-month-table",
27236
27242
  props: basicMonthTableProps,
@@ -27413,7 +27419,7 @@ usage: app.provide(ID_INJECTION_KEY, {
27413
27419
  ]
27414
27420
  }, [
27415
27421
  vue.createElementVNode("div", null, [
27416
- vue.createElementVNode("span", _hoisted_3$8, vue.toDisplayString(vue.unref(t)("el.datepicker.months." + months.value[cell.text])), 1)
27422
+ vue.createElementVNode("span", _hoisted_3$7, vue.toDisplayString(vue.unref(t)("el.datepicker.months." + months.value[cell.text])), 1)
27417
27423
  ])
27418
27424
  ], 42, _hoisted_2$f);
27419
27425
  }), 128))
@@ -27435,7 +27441,7 @@ usage: app.provide(ID_INJECTION_KEY, {
27435
27441
 
27436
27442
  const _hoisted_1$m = ["aria-label"];
27437
27443
  const _hoisted_2$e = ["aria-selected", "tabindex", "onKeydown"];
27438
- const _hoisted_3$7 = { class: "cell" };
27444
+ const _hoisted_3$6 = { class: "cell" };
27439
27445
  const _hoisted_4$4 = { key: 1 };
27440
27446
  const _sfc_main$k = /* @__PURE__ */ vue.defineComponent({
27441
27447
  __name: "basic-year-table",
@@ -27520,7 +27526,7 @@ usage: app.provide(ID_INJECTION_KEY, {
27520
27526
  vue.withKeys(vue.withModifiers(handleYearTableClick, ["prevent", "stop"]), ["enter"])
27521
27527
  ]
27522
27528
  }, [
27523
- vue.createElementVNode("span", _hoisted_3$7, vue.toDisplayString(vue.unref(startYear) + i * 4 + j), 1)
27529
+ vue.createElementVNode("span", _hoisted_3$6, vue.toDisplayString(vue.unref(startYear) + i * 4 + j), 1)
27524
27530
  ], 42, _hoisted_2$e)) : (vue.openBlock(), vue.createElementBlock("td", _hoisted_4$4))
27525
27531
  ], 64);
27526
27532
  }), 64))
@@ -27535,7 +27541,7 @@ usage: app.provide(ID_INJECTION_KEY, {
27535
27541
 
27536
27542
  const _hoisted_1$l = ["onClick"];
27537
27543
  const _hoisted_2$d = ["aria-label"];
27538
- const _hoisted_3$6 = ["aria-label"];
27544
+ const _hoisted_3$5 = ["aria-label"];
27539
27545
  const _hoisted_4$3 = ["aria-label"];
27540
27546
  const _hoisted_5$3 = ["aria-label"];
27541
27547
  const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
@@ -28023,7 +28029,7 @@ usage: app.provide(ID_INJECTION_KEY, {
28023
28029
  ]),
28024
28030
  _: 1
28025
28031
  })
28026
- ], 10, _hoisted_3$6), [
28032
+ ], 10, _hoisted_3$5), [
28027
28033
  [vue.vShow, currentView.value === "date"]
28028
28034
  ])
28029
28035
  ], 2),
@@ -28262,7 +28268,7 @@ usage: app.provide(ID_INJECTION_KEY, {
28262
28268
 
28263
28269
  const _hoisted_1$k = ["onClick"];
28264
28270
  const _hoisted_2$c = ["disabled"];
28265
- const _hoisted_3$5 = ["disabled"];
28271
+ const _hoisted_3$4 = ["disabled"];
28266
28272
  const _hoisted_4$2 = ["disabled"];
28267
28273
  const _hoisted_5$2 = ["disabled"];
28268
28274
  const unit$1 = "month";
@@ -28778,7 +28784,7 @@ usage: app.provide(ID_INJECTION_KEY, {
28778
28784
  ]),
28779
28785
  _: 1
28780
28786
  })
28781
- ], 10, _hoisted_3$5)) : vue.createCommentVNode("v-if", true),
28787
+ ], 10, _hoisted_3$4)) : vue.createCommentVNode("v-if", true),
28782
28788
  vue.createElementVNode("div", null, vue.toDisplayString(vue.unref(leftLabel)), 1)
28783
28789
  ], 2),
28784
28790
  vue.createVNode(DateTable, {
@@ -28962,7 +28968,7 @@ usage: app.provide(ID_INJECTION_KEY, {
28962
28968
 
28963
28969
  const _hoisted_1$j = ["onClick"];
28964
28970
  const _hoisted_2$b = ["disabled"];
28965
- const _hoisted_3$4 = ["disabled"];
28971
+ const _hoisted_3$3 = ["disabled"];
28966
28972
  const unit = "year";
28967
28973
  const __default__$x = vue.defineComponent({
28968
28974
  name: "DatePickerMonthRange"
@@ -29140,7 +29146,7 @@ usage: app.provide(ID_INJECTION_KEY, {
29140
29146
  ]),
29141
29147
  _: 1
29142
29148
  })
29143
- ], 10, _hoisted_3$4)) : vue.createCommentVNode("v-if", true),
29149
+ ], 10, _hoisted_3$3)) : vue.createCommentVNode("v-if", true),
29144
29150
  vue.createElementVNode("button", {
29145
29151
  type: "button",
29146
29152
  class: vue.normalizeClass([vue.unref(ppNs).e("icon-btn"), "d-arrow-right"]),
@@ -33719,7 +33725,7 @@ usage: app.provide(ID_INJECTION_KEY, {
33719
33725
 
33720
33726
  const _hoisted_1$a = ["onKeyup"];
33721
33727
  const _hoisted_2$6 = ["aria-current", "tabindex"];
33722
- const _hoisted_3$3 = ["tabindex"];
33728
+ const _hoisted_3$2 = ["tabindex"];
33723
33729
  const _hoisted_4$1 = ["aria-current", "tabindex"];
33724
33730
  const _hoisted_5$1 = ["tabindex"];
33725
33731
  const _hoisted_6 = ["aria-current", "tabindex"];
@@ -33876,7 +33882,7 @@ usage: app.provide(ID_INJECTION_KEY, {
33876
33882
  onBlur: _cache[3] || (_cache[3] = ($event) => quickPrevFocus.value = false)
33877
33883
  }, [
33878
33884
  quickPrevHover.value || quickPrevFocus.value ? (vue.openBlock(), vue.createBlock(vue.unref(d_arrow_left_default), { key: 0 })) : (vue.openBlock(), vue.createBlock(vue.unref(more_filled_default), { key: 1 }))
33879
- ], 42, _hoisted_3$3)) : vue.createCommentVNode("v-if", true),
33885
+ ], 42, _hoisted_3$2)) : vue.createCommentVNode("v-if", true),
33880
33886
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(pagers), (pager) => {
33881
33887
  return vue.openBlock(), vue.createElementBlock("li", {
33882
33888
  key: pager,
@@ -34262,7 +34268,7 @@ usage: app.provide(ID_INJECTION_KEY, {
34262
34268
 
34263
34269
  const _hoisted_1$9 = ["onClick"];
34264
34270
  const _hoisted_2$5 = ["id", "aria-checked", "aria-disabled", "name", "true-value", "false-value", "disabled", "tabindex", "onKeydown"];
34265
- const _hoisted_3$2 = ["aria-hidden"];
34271
+ const _hoisted_3$1 = ["aria-hidden"];
34266
34272
  const _hoisted_4 = ["aria-hidden"];
34267
34273
  const _hoisted_5 = ["aria-hidden"];
34268
34274
  const COMPONENT_NAME = "ElSwitch";
@@ -34423,7 +34429,7 @@ usage: app.provide(ID_INJECTION_KEY, {
34423
34429
  !_ctx.inactiveIcon && _ctx.inactiveText ? (vue.openBlock(), vue.createElementBlock("span", {
34424
34430
  key: 1,
34425
34431
  "aria-hidden": vue.unref(checked)
34426
- }, vue.toDisplayString(_ctx.inactiveText), 9, _hoisted_3$2)) : vue.createCommentVNode("v-if", true)
34432
+ }, vue.toDisplayString(_ctx.inactiveText), 9, _hoisted_3$1)) : vue.createCommentVNode("v-if", true)
34427
34433
  ], 2)) : vue.createCommentVNode("v-if", true),
34428
34434
  vue.createElementVNode("span", {
34429
34435
  ref_key: "core",
@@ -36259,7 +36265,7 @@ usage: app.provide(ID_INJECTION_KEY, {
36259
36265
  });
36260
36266
  const _hoisted_1$8 = { key: 0 };
36261
36267
  const _hoisted_2$4 = ["disabled"];
36262
- const _hoisted_3$1 = ["label", "onClick"];
36268
+ const _hoisted_3 = ["label", "onClick"];
36263
36269
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
36264
36270
  const _component_el_checkbox = vue.resolveComponent("el-checkbox");
36265
36271
  const _component_el_checkbox_group = vue.resolveComponent("el-checkbox-group");
@@ -36348,7 +36354,7 @@ usage: app.provide(ID_INJECTION_KEY, {
36348
36354
  class: vue.normalizeClass([_ctx.ns.e("list-item"), _ctx.ns.is("active", _ctx.isActive(filter))]),
36349
36355
  label: filter.value,
36350
36356
  onClick: ($event) => _ctx.handleSelect(filter.value)
36351
- }, vue.toDisplayString(filter.text), 11, _hoisted_3$1);
36357
+ }, vue.toDisplayString(filter.text), 11, _hoisted_3);
36352
36358
  }), 128))
36353
36359
  ], 2))
36354
36360
  ]),
@@ -41894,7 +41900,6 @@ usage: app.provide(ID_INJECTION_KEY, {
41894
41900
 
41895
41901
  var _hoisted_1 = { key: 1 };
41896
41902
  var _hoisted_2 = { key: 1 };
41897
- var _hoisted_3 = { key: 1 };
41898
41903
  var __default__ = {
41899
41904
  name: 'base-dialog'
41900
41905
  };
@@ -42025,42 +42030,44 @@ usage: app.provide(ID_INJECTION_KEY, {
42025
42030
  key: 0,
42026
42031
  render: __props.titleRender
42027
42032
  }, null, 8 /* PROPS */, ["render"]))
42028
- : (__props.title)
42029
- ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1, vue.toDisplayString(__props.title), 1 /* TEXT */))
42030
- : vue.renderSlot(_ctx.$slots, "header", { key: 2 })
42033
+ : vue.renderSlot(_ctx.$slots, "header", { key: 1 }, function () { return [
42034
+ vue.createTextVNode(vue.toDisplayString(__props.title), 1 /* TEXT */)
42035
+ ]; })
42031
42036
  ]; }),
42032
42037
  footer: vue.withCtx(function () { return [
42033
- (__props.footerRender)
42034
- ? (vue.openBlock(), vue.createBlock(vue.unref(BaseDialogRender), {
42035
- key: 0,
42036
- render: __props.footerRender
42037
- }, null, 8 /* PROPS */, ["render"]))
42038
- : (__props.showFooter)
42039
- ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, [
42040
- (__props.cancelBtnConfig.show)
42041
- ? (vue.openBlock(), vue.createBlock(vue.unref(BaseButton), vue.mergeProps({
42042
- key: 0,
42043
- size: "large"
42044
- }, __props.cancelBtnConfig, { click: handleCancelClick }), {
42045
- default: vue.withCtx(function () { return [
42046
- vue.createTextVNode(vue.toDisplayString(__props.cancelBtnConfig.content), 1 /* TEXT */)
42047
- ]; }),
42048
- _: 1 /* STABLE */
42049
- }, 16 /* FULL_PROPS */))
42050
- : vue.createCommentVNode("v-if", true),
42051
- (__props.confirmBtnConfig.show)
42052
- ? (vue.openBlock(), vue.createBlock(vue.unref(BaseButton), vue.mergeProps({
42053
- key: 1,
42054
- size: "large"
42055
- }, __props.confirmBtnConfig, { click: handleConfirmClick }), {
42056
- default: vue.withCtx(function () { return [
42057
- vue.createTextVNode(vue.toDisplayString(__props.confirmBtnConfig.content), 1 /* TEXT */)
42058
- ]; }),
42059
- _: 1 /* STABLE */
42060
- }, 16 /* FULL_PROPS */))
42061
- : vue.createCommentVNode("v-if", true)
42062
- ]))
42063
- : vue.createCommentVNode("v-if", true)
42038
+ vue.renderSlot(_ctx.$slots, "footer", {}, function () { return [
42039
+ (__props.footerRender)
42040
+ ? (vue.openBlock(), vue.createBlock(vue.unref(BaseDialogRender), {
42041
+ key: 0,
42042
+ render: __props.footerRender
42043
+ }, null, 8 /* PROPS */, ["render"]))
42044
+ : (__props.showFooter)
42045
+ ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, [
42046
+ (__props.cancelBtnConfig.show)
42047
+ ? (vue.openBlock(), vue.createBlock(vue.unref(BaseButton), vue.mergeProps({
42048
+ key: 0,
42049
+ size: "large"
42050
+ }, __props.cancelBtnConfig, { click: handleCancelClick }), {
42051
+ default: vue.withCtx(function () { return [
42052
+ vue.createTextVNode(vue.toDisplayString(__props.cancelBtnConfig.content), 1 /* TEXT */)
42053
+ ]; }),
42054
+ _: 1 /* STABLE */
42055
+ }, 16 /* FULL_PROPS */))
42056
+ : vue.createCommentVNode("v-if", true),
42057
+ (__props.confirmBtnConfig.show)
42058
+ ? (vue.openBlock(), vue.createBlock(vue.unref(BaseButton), vue.mergeProps({
42059
+ key: 1,
42060
+ size: "large"
42061
+ }, __props.confirmBtnConfig, { click: handleConfirmClick }), {
42062
+ default: vue.withCtx(function () { return [
42063
+ vue.createTextVNode(vue.toDisplayString(__props.confirmBtnConfig.content), 1 /* TEXT */)
42064
+ ]; }),
42065
+ _: 1 /* STABLE */
42066
+ }, 16 /* FULL_PROPS */))
42067
+ : vue.createCommentVNode("v-if", true)
42068
+ ]))
42069
+ : vue.createCommentVNode("v-if", true)
42070
+ ]; })
42064
42071
  ]; }),
42065
42072
  default: vue.withCtx(function () { return [
42066
42073
  (__props.contentRender)
@@ -42069,7 +42076,7 @@ usage: app.provide(ID_INJECTION_KEY, {
42069
42076
  render: __props.contentRender
42070
42077
  }, null, 8 /* PROPS */, ["render"]))
42071
42078
  : (__props.content)
42072
- ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, vue.toDisplayString(__props.content), 1 /* TEXT */))
42079
+ ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, vue.toDisplayString(__props.content), 1 /* TEXT */))
42073
42080
  : vue.renderSlot(_ctx.$slots, "default", { key: 2 })
42074
42081
  ]; }),
42075
42082
  _: 3 /* FORWARDED */
@@ -42087,19 +42094,39 @@ usage: app.provide(ID_INJECTION_KEY, {
42087
42094
  container.classList.add('_xrk_create_dialog');
42088
42095
  container.style.position = 'relative';
42089
42096
  container.style.zIndex = "".concat(200 + customDialogCount);
42090
- vue.render(vue.h(script, __assign(__assign({ modelValue: true }, (config || {})), { appendToBody: false, onClose: function () { return __awaiter(void 0, void 0, void 0, function () {
42091
- var _a, _b;
42092
- return __generator(this, function (_c) {
42093
- switch (_c.label) {
42094
- case 0: return [4 /*yield*/, ((_a = config === null || config === void 0 ? void 0 : config.onClose) === null || _a === void 0 ? void 0 : _a.call(config))];
42095
- case 1:
42096
- _c.sent();
42097
- (_b = document.querySelector('body')) === null || _b === void 0 ? void 0 : _b.removeChild(container);
42098
- return [2 /*return*/];
42099
- }
42097
+ var _instance = null;
42098
+ var close = function () { return __awaiter(void 0, void 0, void 0, function () {
42099
+ var _a, _b;
42100
+ return __generator(this, function (_c) {
42101
+ switch (_c.label) {
42102
+ case 0: return [4 /*yield*/, ((_a = config === null || config === void 0 ? void 0 : config.onClose) === null || _a === void 0 ? void 0 : _a.call(config))];
42103
+ case 1:
42104
+ _c.sent();
42105
+ (_b = document.querySelector('body')) === null || _b === void 0 ? void 0 : _b.removeChild(container);
42106
+ _instance = null;
42107
+ return [2 /*return*/];
42108
+ }
42109
+ });
42110
+ }); };
42111
+ _instance = vue.h(script, __assign({ modelValue: true, appendToBody: false, onClose: function () { return __awaiter(void 0, void 0, void 0, function () {
42112
+ return __generator(this, function (_a) {
42113
+ close();
42114
+ return [2 /*return*/];
42100
42115
  });
42101
- }); } })), container);
42116
+ }); } }, (config || {})));
42117
+ if (config && config.app) {
42118
+ _instance.appContext = config.app._context; // 承接上下文,用于inject,调用层需要使用app.provide
42119
+ }
42120
+ vue.render(_instance, container);
42102
42121
  (_a = document.querySelector('body')) === null || _a === void 0 ? void 0 : _a.appendChild(container);
42122
+ _instance.component.ctx.close = close;
42123
+ _instance.component.ctx.$updateProps = function (props) {
42124
+ props &&
42125
+ Object.keys(props).forEach(function (k) {
42126
+ _instance.component.props[k] = props[k];
42127
+ });
42128
+ };
42129
+ return _instance.component.ctx;
42103
42130
  };
42104
42131
 
42105
42132
  /*
@@ -42160,6 +42187,46 @@ usage: app.provide(ID_INJECTION_KEY, {
42160
42187
  return otherComponents;
42161
42188
  };
42162
42189
 
42190
+ var useCreateModal = function (component, options, app) {
42191
+ var _a;
42192
+ console.log('useCreateModal app:', app);
42193
+ var _instance = null;
42194
+ var container = document.createElement('div');
42195
+ var remove = function () {
42196
+ container.remove();
42197
+ _instance = null;
42198
+ };
42199
+ _instance = vue.createVNode(component, __assign({ remove: remove, close: remove, onRemove: function () {
42200
+ remove();
42201
+ },
42202
+ // 兼容base-dialog
42203
+ onClose: function () {
42204
+ remove();
42205
+ },
42206
+ // 兼容base-dialog,true会导致没有append到container容器中
42207
+ appendToBody: false }, options));
42208
+ // inject 函数调用组件导致内部inject无法接收到,需要使用app.provide(全局): https://github.com/vuejs/core/issues/6220
42209
+ // context createApp需要use插件,内部才能使用插件\库相关API。可以直接修改上下文: https://github.com/vuejs/core/issues/2097
42210
+ if (app) {
42211
+ _instance.appContext = app._context; // 承接上下文,用于inject,调用层需要使用app.provide
42212
+ }
42213
+ vue.render(_instance, container);
42214
+ (_a = document.querySelector('body')) === null || _a === void 0 ? void 0 : _a.appendChild(container);
42215
+ // 在组件添加一个 remove 方法用来销毁组件
42216
+ // 组件内调用 currentInstance.ctx.remove()
42217
+ _instance.component.ctx.remove = remove;
42218
+ _instance.component.ctx.close = close;
42219
+ console.log(_instance, '组件_instance');
42220
+ // 更新props方法
42221
+ _instance.component.ctx.$updateProps = function (props) {
42222
+ props &&
42223
+ Object.keys(props).forEach(function (k) {
42224
+ _instance.component.props[k] = props[k];
42225
+ });
42226
+ };
42227
+ return _instance.component.ctx;
42228
+ };
42229
+
42163
42230
  /*
42164
42231
  * @Description:
42165
42232
  * @Date: 2022-06-30 22:57:28
@@ -42205,6 +42272,7 @@ usage: app.provide(ID_INJECTION_KEY, {
42205
42272
  exports.XrkTable = XrkTable;
42206
42273
  exports.createDialog = createDialog;
42207
42274
  exports["default"] = index;
42275
+ exports.useCreateModal = useCreateModal;
42208
42276
  exports.useDatePickerColumn = useDatePickerColumn;
42209
42277
  exports.useInputColumn = useInputColumn;
42210
42278
  exports.useOtherComponents = useOtherComponents;
@@ -1,5 +1,9 @@
1
- import { Component, DefineComponent } from 'vue';
1
+ import { Component, DefineComponent, App } from 'vue';
2
2
  import { BaseButtonProps } from '../button';
3
+ interface ModalInstance {
4
+ close(): void;
5
+ $updateProps(props: Record<string, any>): void;
6
+ }
3
7
  export declare type BaseDialogProps = {
4
8
  modelValue?: boolean;
5
9
  closeOnClickModal?: boolean;
@@ -21,6 +25,7 @@ export declare type BaseDialogProps = {
21
25
  footerRender?: (done: Function) => Component;
22
26
  confirmBtnConfig?: DialogBtnConfigProps;
23
27
  cancelBtnConfig?: DialogBtnConfigProps;
28
+ app?: App;
24
29
  onClose?: () => Promise<void> | void;
25
30
  };
26
31
  export interface DialogBtnConfigProps extends BaseButtonProps {
@@ -28,4 +33,5 @@ export interface DialogBtnConfigProps extends BaseButtonProps {
28
33
  content?: string;
29
34
  }
30
35
  export declare const BaseDialog: DefineComponent<BaseDialogProps, {}, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<BaseDialogProps>, {}>;
31
- export declare const createDialog: (config?: BaseDialogProps) => void;
36
+ export declare const createDialog: (config?: BaseDialogProps) => ModalInstance;
37
+ export {};
@@ -0,0 +1,10 @@
1
+ import { App, Component } from 'vue';
2
+ declare type anyObj = Record<string, any>;
3
+ interface ModalInstance {
4
+ remove(): void;
5
+ close(): void;
6
+ $updateProps(props: anyObj): void;
7
+ }
8
+ export declare const useCreateModal: (component: Component, options?: anyObj, app?: App) => ModalInstance;
9
+ declare const install: (app: App, component: Component, options: anyObj) => void;
10
+ export default install;
@@ -4,6 +4,7 @@ import { DefaultProps } from './hooks/use-default-props';
4
4
  export * from './components';
5
5
  export * from './functions';
6
6
  export * from './types';
7
+ export { useCreateModal } from './hooks/use-create-modal';
7
8
  declare const _default: {
8
9
  version: any;
9
10
  useSetGlobalDefaultProps: (props: DefaultProps) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xrk-components",
3
- "version": "0.4.2-beta.3",
3
+ "version": "0.4.2-beta.5",
4
4
  "description": "",
5
5
  "main": "lib/index.esm.js",
6
6
  "typings": "lib/packages/index.d.ts",