xrk-components 0.4.2-beta.2 → 0.4.2-beta.4

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;
@@ -38888,8 +38894,6 @@ var ElTableColumn$1 = defineComponent({
38888
38894
  column: {},
38889
38895
  $index: -1
38890
38896
  });
38891
- console.log(renderDefault,'renderDefault');
38892
-
38893
38897
  const children = [];
38894
38898
  if (Array.isArray(renderDefault)) {
38895
38899
  for (const childNode of renderDefault) {
@@ -41240,7 +41244,8 @@ var script$3 = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__$3
41240
41244
  defaultSort: { type: Object, required: false },
41241
41245
  useBaseClass: { type: Boolean, required: false, default: (function () {
41242
41246
  return useGetGlobalDefaultProp(propsKey$1, 'useBaseClass', true);
41243
- }) }
41247
+ }) },
41248
+ spanMethod: { type: null, required: false }
41244
41249
  }, emits: ["sort-change", "select", "select-all"], setup: function (__props, _a) {
41245
41250
  var expose = _a.expose, emits = _a.emit;
41246
41251
  setGlobalNamespace();
@@ -41281,6 +41286,7 @@ var script$3 = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__$3
41281
41286
  expandRowKeys: __props.expandRowKeys,
41282
41287
  defaultSort: __props.defaultSort,
41283
41288
  emptyText: __props.emptyText,
41289
+ spanMethod: __props.spanMethod,
41284
41290
  onSortChange: handleSortChange
41285
41291
  }, {
41286
41292
  empty: withCtx(function () { return [
@@ -41303,7 +41309,7 @@ var script$3 = /*#__PURE__*/ defineComponent(__assign(__assign({}, __default__$3
41303
41309
  }), 128 /* KEYED_FRAGMENT */))
41304
41310
  ]; }),
41305
41311
  _: 3 /* FORWARDED */
41306
- }, 8 /* PROPS */, ["class", "data", "height", "maxHeight", "stripe", "border", "size", "fit", "rowClassName", "rowStyle", "cellClassName", "cellStyle", "headerRowClassName", "headerRowStyle", "rowKey", "defaultExpandAll", "expandRowKeys", "defaultSort", "emptyText"]));
41312
+ }, 8 /* PROPS */, ["class", "data", "height", "maxHeight", "stripe", "border", "size", "fit", "rowClassName", "rowStyle", "cellClassName", "cellStyle", "headerRowClassName", "headerRowStyle", "rowKey", "defaultExpandAll", "expandRowKeys", "defaultSort", "emptyText", "spanMethod"]));
41307
41313
  };
41308
41314
  } }));
41309
41315
 
@@ -42084,19 +42090,39 @@ var createDialog = function (config) {
42084
42090
  container.classList.add('_xrk_create_dialog');
42085
42091
  container.style.position = 'relative';
42086
42092
  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
- }
42093
+ var _instance = null;
42094
+ var close = function () { return __awaiter(void 0, void 0, void 0, function () {
42095
+ var _a, _b;
42096
+ return __generator(this, function (_c) {
42097
+ switch (_c.label) {
42098
+ case 0: return [4 /*yield*/, ((_a = config === null || config === void 0 ? void 0 : config.onClose) === null || _a === void 0 ? void 0 : _a.call(config))];
42099
+ case 1:
42100
+ _c.sent();
42101
+ (_b = document.querySelector('body')) === null || _b === void 0 ? void 0 : _b.removeChild(container);
42102
+ _instance = null;
42103
+ return [2 /*return*/];
42104
+ }
42105
+ });
42106
+ }); };
42107
+ _instance = h$1(script, __assign({ modelValue: true, appendToBody: false, onClose: function () { return __awaiter(void 0, void 0, void 0, function () {
42108
+ return __generator(this, function (_a) {
42109
+ close();
42110
+ return [2 /*return*/];
42097
42111
  });
42098
- }); } })), container);
42112
+ }); } }, (config || {})));
42113
+ if (config && config.app) {
42114
+ _instance.appContext = config.app._context; // 承接上下文,用于inject,调用层需要使用app.provide
42115
+ }
42116
+ render(_instance, container);
42099
42117
  (_a = document.querySelector('body')) === null || _a === void 0 ? void 0 : _a.appendChild(container);
42118
+ _instance.component.ctx.close = close;
42119
+ _instance.component.ctx.$updateProps = function (props) {
42120
+ props &&
42121
+ Object.keys(props).forEach(function (k) {
42122
+ _instance.component.props[k] = props[k];
42123
+ });
42124
+ };
42125
+ return _instance.component.ctx;
42100
42126
  };
42101
42127
 
42102
42128
  /*
@@ -42157,6 +42183,39 @@ var useOtherComponents = function (otherComponents) {
42157
42183
  return otherComponents;
42158
42184
  };
42159
42185
 
42186
+ var useCreateModal = function (component, options, app) {
42187
+ var _a;
42188
+ console.log('useCreateModal app:', app);
42189
+ var _instance = null;
42190
+ var container = document.createElement('div');
42191
+ var remove = function () {
42192
+ _instance = null;
42193
+ container.remove();
42194
+ };
42195
+ _instance = createVNode(component, __assign({ remove: remove, onRemove: function () {
42196
+ remove();
42197
+ } }, options));
42198
+ // inject 函数调用组件导致内部inject无法接收到,需要使用app.provide(全局): https://github.com/vuejs/core/issues/6220
42199
+ // context createApp需要use插件,内部才能使用插件\库相关API。可以直接修改上下文: https://github.com/vuejs/core/issues/2097
42200
+ if (app) {
42201
+ _instance.appContext = app._context; // 承接上下文,用于inject,调用层需要使用app.provide
42202
+ }
42203
+ render(_instance, container);
42204
+ (_a = document.querySelector('body')) === null || _a === void 0 ? void 0 : _a.appendChild(container);
42205
+ // 在组件添加一个 remove 方法用来销毁组件
42206
+ // 组件内调用 currentInstance.ctx.remove()
42207
+ _instance.component.ctx.remove = remove;
42208
+ console.log(_instance, '组件_instance');
42209
+ // 更新props方法
42210
+ _instance.component.ctx.$updateProps = function (props) {
42211
+ props &&
42212
+ Object.keys(props).forEach(function (k) {
42213
+ _instance.component.props[k] = props[k];
42214
+ });
42215
+ };
42216
+ return _instance.component.ctx;
42217
+ };
42218
+
42160
42219
  /*
42161
42220
  * @Description:
42162
42221
  * @Date: 2022-06-30 22:57:28
@@ -42180,4 +42239,4 @@ var index = {
42180
42239
  install: install
42181
42240
  };
42182
42241
 
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 };
42242
+ 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;
@@ -38891,8 +38897,6 @@ usage: app.provide(ID_INJECTION_KEY, {
38891
38897
  column: {},
38892
38898
  $index: -1
38893
38899
  });
38894
- console.log(renderDefault,'renderDefault');
38895
-
38896
38900
  const children = [];
38897
38901
  if (Array.isArray(renderDefault)) {
38898
38902
  for (const childNode of renderDefault) {
@@ -41243,7 +41247,8 @@ usage: app.provide(ID_INJECTION_KEY, {
41243
41247
  defaultSort: { type: Object, required: false },
41244
41248
  useBaseClass: { type: Boolean, required: false, default: (function () {
41245
41249
  return useGetGlobalDefaultProp(propsKey$1, 'useBaseClass', true);
41246
- }) }
41250
+ }) },
41251
+ spanMethod: { type: null, required: false }
41247
41252
  }, emits: ["sort-change", "select", "select-all"], setup: function (__props, _a) {
41248
41253
  var expose = _a.expose, emits = _a.emit;
41249
41254
  setGlobalNamespace();
@@ -41284,6 +41289,7 @@ usage: app.provide(ID_INJECTION_KEY, {
41284
41289
  expandRowKeys: __props.expandRowKeys,
41285
41290
  defaultSort: __props.defaultSort,
41286
41291
  emptyText: __props.emptyText,
41292
+ spanMethod: __props.spanMethod,
41287
41293
  onSortChange: handleSortChange
41288
41294
  }, {
41289
41295
  empty: vue.withCtx(function () { return [
@@ -41306,7 +41312,7 @@ usage: app.provide(ID_INJECTION_KEY, {
41306
41312
  }), 128 /* KEYED_FRAGMENT */))
41307
41313
  ]; }),
41308
41314
  _: 3 /* FORWARDED */
41309
- }, 8 /* PROPS */, ["class", "data", "height", "maxHeight", "stripe", "border", "size", "fit", "rowClassName", "rowStyle", "cellClassName", "cellStyle", "headerRowClassName", "headerRowStyle", "rowKey", "defaultExpandAll", "expandRowKeys", "defaultSort", "emptyText"]));
41315
+ }, 8 /* PROPS */, ["class", "data", "height", "maxHeight", "stripe", "border", "size", "fit", "rowClassName", "rowStyle", "cellClassName", "cellStyle", "headerRowClassName", "headerRowStyle", "rowKey", "defaultExpandAll", "expandRowKeys", "defaultSort", "emptyText", "spanMethod"]));
41310
41316
  };
41311
41317
  } }));
41312
41318
 
@@ -42087,19 +42093,39 @@ usage: app.provide(ID_INJECTION_KEY, {
42087
42093
  container.classList.add('_xrk_create_dialog');
42088
42094
  container.style.position = 'relative';
42089
42095
  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
- }
42096
+ var _instance = null;
42097
+ var close = function () { return __awaiter(void 0, void 0, void 0, function () {
42098
+ var _a, _b;
42099
+ return __generator(this, function (_c) {
42100
+ switch (_c.label) {
42101
+ case 0: return [4 /*yield*/, ((_a = config === null || config === void 0 ? void 0 : config.onClose) === null || _a === void 0 ? void 0 : _a.call(config))];
42102
+ case 1:
42103
+ _c.sent();
42104
+ (_b = document.querySelector('body')) === null || _b === void 0 ? void 0 : _b.removeChild(container);
42105
+ _instance = null;
42106
+ return [2 /*return*/];
42107
+ }
42108
+ });
42109
+ }); };
42110
+ _instance = vue.h(script, __assign({ modelValue: true, appendToBody: false, onClose: function () { return __awaiter(void 0, void 0, void 0, function () {
42111
+ return __generator(this, function (_a) {
42112
+ close();
42113
+ return [2 /*return*/];
42100
42114
  });
42101
- }); } })), container);
42115
+ }); } }, (config || {})));
42116
+ if (config && config.app) {
42117
+ _instance.appContext = config.app._context; // 承接上下文,用于inject,调用层需要使用app.provide
42118
+ }
42119
+ vue.render(_instance, container);
42102
42120
  (_a = document.querySelector('body')) === null || _a === void 0 ? void 0 : _a.appendChild(container);
42121
+ _instance.component.ctx.close = close;
42122
+ _instance.component.ctx.$updateProps = function (props) {
42123
+ props &&
42124
+ Object.keys(props).forEach(function (k) {
42125
+ _instance.component.props[k] = props[k];
42126
+ });
42127
+ };
42128
+ return _instance.component.ctx;
42103
42129
  };
42104
42130
 
42105
42131
  /*
@@ -42160,6 +42186,39 @@ usage: app.provide(ID_INJECTION_KEY, {
42160
42186
  return otherComponents;
42161
42187
  };
42162
42188
 
42189
+ var useCreateModal = function (component, options, app) {
42190
+ var _a;
42191
+ console.log('useCreateModal app:', app);
42192
+ var _instance = null;
42193
+ var container = document.createElement('div');
42194
+ var remove = function () {
42195
+ _instance = null;
42196
+ container.remove();
42197
+ };
42198
+ _instance = vue.createVNode(component, __assign({ remove: remove, onRemove: function () {
42199
+ remove();
42200
+ } }, options));
42201
+ // inject 函数调用组件导致内部inject无法接收到,需要使用app.provide(全局): https://github.com/vuejs/core/issues/6220
42202
+ // context createApp需要use插件,内部才能使用插件\库相关API。可以直接修改上下文: https://github.com/vuejs/core/issues/2097
42203
+ if (app) {
42204
+ _instance.appContext = app._context; // 承接上下文,用于inject,调用层需要使用app.provide
42205
+ }
42206
+ vue.render(_instance, container);
42207
+ (_a = document.querySelector('body')) === null || _a === void 0 ? void 0 : _a.appendChild(container);
42208
+ // 在组件添加一个 remove 方法用来销毁组件
42209
+ // 组件内调用 currentInstance.ctx.remove()
42210
+ _instance.component.ctx.remove = remove;
42211
+ console.log(_instance, '组件_instance');
42212
+ // 更新props方法
42213
+ _instance.component.ctx.$updateProps = function (props) {
42214
+ props &&
42215
+ Object.keys(props).forEach(function (k) {
42216
+ _instance.component.props[k] = props[k];
42217
+ });
42218
+ };
42219
+ return _instance.component.ctx;
42220
+ };
42221
+
42163
42222
  /*
42164
42223
  * @Description:
42165
42224
  * @Date: 2022-06-30 22:57:28
@@ -42205,6 +42264,7 @@ usage: app.provide(ID_INJECTION_KEY, {
42205
42264
  exports.XrkTable = XrkTable;
42206
42265
  exports.createDialog = createDialog;
42207
42266
  exports["default"] = index;
42267
+ exports.useCreateModal = useCreateModal;
42208
42268
  exports.useDatePickerColumn = useDatePickerColumn;
42209
42269
  exports.useInputColumn = useInputColumn;
42210
42270
  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 {};
@@ -91,6 +91,10 @@ declare const _default: import("vue").DefineComponent<{
91
91
  required: false;
92
92
  default: any;
93
93
  };
94
+ spanMethod: {
95
+ type: null;
96
+ required: false;
97
+ };
94
98
  }, (_ctx: any, _cache: any) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
95
99
  [key: string]: any;
96
100
  }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("sort-change" | "select" | "select-all")[], "sort-change" | "select" | "select-all", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
@@ -186,6 +190,10 @@ declare const _default: import("vue").DefineComponent<{
186
190
  required: false;
187
191
  default: any;
188
192
  };
193
+ spanMethod: {
194
+ type: null;
195
+ required: false;
196
+ };
189
197
  }>> & {
190
198
  "onSort-change"?: ((...args: any[]) => any) | undefined;
191
199
  onSelect?: ((...args: any[]) => any) | undefined;
@@ -25,6 +25,15 @@ export declare type BaseTableSortInfoType = {
25
25
  prop: string;
26
26
  order: 'ascending' | 'descending' | null;
27
27
  };
28
+ export declare type SpanMethod = (data: {
29
+ row: any;
30
+ rowIndex: number;
31
+ column: TableColumnCtx<any>;
32
+ columnIndex: number;
33
+ }) => number[] | {
34
+ rowspan: number;
35
+ colspan: number;
36
+ } | undefined;
28
37
  export declare type BaseTableProps = {
29
38
  data: Array<Record<string, any>>;
30
39
  columns: Array<BaseTableColumnProps>;
@@ -50,6 +59,7 @@ export declare type BaseTableProps = {
50
59
  prop: string;
51
60
  order: 'ascending' | 'descending';
52
61
  };
62
+ spanMethod?: SpanMethod;
53
63
  onSortChange?: (info: BaseTableSortInfoType) => void;
54
64
  onSelect?: (selection: any, row: any) => void;
55
65
  onSelectAll?: (selection: any) => void;
@@ -0,0 +1,9 @@
1
+ import { App, Component } from 'vue';
2
+ declare type anyObj = Record<string, any>;
3
+ interface ModalInstance {
4
+ remove(): void;
5
+ $updateProps(props: anyObj): void;
6
+ }
7
+ export declare const useCreateModal: (component: Component, options?: anyObj, app?: App) => ModalInstance;
8
+ declare const install: (app: App, component: Component, options: anyObj) => void;
9
+ 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.2",
3
+ "version": "0.4.2-beta.4",
4
4
  "description": "",
5
5
  "main": "lib/index.esm.js",
6
6
  "typings": "lib/packages/index.d.ts",