xrk-components 0.4.2-beta.3 → 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;
|
|
@@ -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
|
-
|
|
42088
|
-
|
|
42089
|
-
|
|
42090
|
-
|
|
42091
|
-
|
|
42092
|
-
|
|
42093
|
-
|
|
42094
|
-
|
|
42095
|
-
|
|
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
|
-
}); } }
|
|
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;
|
|
@@ -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
|
-
|
|
42091
|
-
|
|
42092
|
-
|
|
42093
|
-
|
|
42094
|
-
|
|
42095
|
-
|
|
42096
|
-
|
|
42097
|
-
|
|
42098
|
-
|
|
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
|
-
}); } }
|
|
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) =>
|
|
36
|
+
export declare const createDialog: (config?: BaseDialogProps) => ModalInstance;
|
|
37
|
+
export {};
|
|
@@ -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;
|
package/lib/packages/index.d.ts
CHANGED
|
@@ -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;
|