inl-ui 0.0.20 → 0.0.21

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.
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var iconsVue = require('@ant-design/icons-vue');
7
+
8
+ const config = {
9
+ prefix: "inl",
10
+ requestOmitParams: ["createDt", "createUser", "updateDt", "updateUser"]
11
+ };
12
+
13
+ const {
14
+ prefix
15
+ } = config;
16
+ function installComponent(component, name, withPrefix = true) {
17
+ component.install = app => {
18
+ name = withPrefix ? `${prefix}-${name}` : name;
19
+ app.component(name, component);
20
+ };
21
+ return component;
22
+ }
23
+
24
+ const Demo = vue.defineComponent({
25
+ props: {
26
+ name: {
27
+ type: String,
28
+ default: "\u5F20\u4E09"
29
+ }
30
+ },
31
+ setup(props) {
32
+ return () => vue.createVNode("div", {
33
+ "class": "Demo"
34
+ }, ["\u6211\u662Fdemo, ", props.name]);
35
+ }
36
+ });
37
+ var index$1 = installComponent(Demo, "demo");
38
+
39
+ const IconFont = iconsVue.createFromIconfontCN();
40
+ var index = installComponent(IconFont, "icon-font", false);
41
+
42
+ exports.Demo = index$1;
43
+ exports.IconFont = index;
@@ -0,0 +1,20 @@
1
+ import * as vue from 'vue';
2
+ import * as _ant_design_icons_vue_lib_components_IconFont from '@ant-design/icons-vue/lib/components/IconFont';
3
+
4
+ declare const _default$1: vue.DefineComponent<{
5
+ name: {
6
+ type: StringConstructor;
7
+ default: string;
8
+ };
9
+ }, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
10
+ name: {
11
+ type: StringConstructor;
12
+ default: string;
13
+ };
14
+ }>>, {
15
+ name: string;
16
+ }>;
17
+
18
+ declare const _default: vue.FunctionalComponent<_ant_design_icons_vue_lib_components_IconFont.IconFontProps, {}>;
19
+
20
+ export { _default$1 as Demo, _default as IconFont };
@@ -0,0 +1,38 @@
1
+ import { defineComponent, createVNode } from 'vue';
2
+ import { createFromIconfontCN } from '@ant-design/icons-vue';
3
+
4
+ const config = {
5
+ prefix: "inl",
6
+ requestOmitParams: ["createDt", "createUser", "updateDt", "updateUser"]
7
+ };
8
+
9
+ const {
10
+ prefix
11
+ } = config;
12
+ function installComponent(component, name, withPrefix = true) {
13
+ component.install = app => {
14
+ name = withPrefix ? `${prefix}-${name}` : name;
15
+ app.component(name, component);
16
+ };
17
+ return component;
18
+ }
19
+
20
+ const Demo = defineComponent({
21
+ props: {
22
+ name: {
23
+ type: String,
24
+ default: "\u5F20\u4E09"
25
+ }
26
+ },
27
+ setup(props) {
28
+ return () => createVNode("div", {
29
+ "class": "Demo"
30
+ }, ["\u6211\u662Fdemo, ", props.name]);
31
+ }
32
+ });
33
+ var index$1 = installComponent(Demo, "demo");
34
+
35
+ const IconFont = createFromIconfontCN();
36
+ var index = installComponent(IconFont, "icon-font", false);
37
+
38
+ export { index$1 as Demo, index as IconFont };
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const focusDirective = {
6
+ mounted(el, {
7
+ value
8
+ }) {
9
+ if (value !== false) {
10
+ el.focus();
11
+ }
12
+ }
13
+ };
14
+
15
+ const autoScroll = {
16
+ mounted(el, {
17
+ value = "ant-table-body",
18
+ modifiers
19
+ }) {
20
+ let timer;
21
+ let timer2;
22
+ let hover = false;
23
+ let wait = false;
24
+ const {
25
+ self
26
+ } = modifiers;
27
+ const _baseWidth = window.innerWidth / window.innerHeight > 2 ? 7200 : 2880;
28
+ const step = Math.ceil(_baseWidth / window.innerWidth);
29
+ const onmouseenter = () => hover = true;
30
+ const onmouseleave = () => hover = false;
31
+ const scrollEl = self ? el : el.querySelector(`.${value}`);
32
+ if (!scrollEl) return;
33
+ const startScroll = () => {
34
+ if (!document.contains(el)) {
35
+ timer && clearInterval(timer);
36
+ el.removeEventListener("mouseenter", onmouseenter);
37
+ el.removeEventListener("mouseleave", onmouseleave);
38
+ return;
39
+ }
40
+ if (hover) return;
41
+ const scrollElHeight = scrollEl.getBoundingClientRect().height;
42
+ if (scrollElHeight >= scrollEl.scrollHeight) {
43
+ return;
44
+ }
45
+ if (!hover && scrollEl.scrollTop + scrollElHeight > scrollEl.scrollHeight - step) {
46
+ if (timer2) return;
47
+ timer2 = setTimeout(() => {
48
+ if (!hover) {
49
+ scrollEl.scrollTop = 0;
50
+ }
51
+ setTimeout(() => {
52
+ if (!hover) {
53
+ wait = false;
54
+ }
55
+ }, 1e3);
56
+ timer2 = null;
57
+ }, 1e3);
58
+ wait = true;
59
+ } else {
60
+ if (!wait) {
61
+ scrollEl.scrollTo({
62
+ top: scrollEl.scrollTop + step
63
+ });
64
+ }
65
+ }
66
+ };
67
+ timer = setInterval(startScroll, 100);
68
+ el.addEventListener("mouseenter", onmouseenter);
69
+ el.addEventListener("mouseleave", onmouseleave);
70
+ }
71
+ };
72
+
73
+ exports.autoScroll = autoScroll;
74
+ exports.focusDirective = focusDirective;
@@ -0,0 +1,15 @@
1
+ import { Directive } from 'vue';
2
+
3
+ /**
4
+ * 输入框自动获取焦点
5
+ */
6
+ declare const focusDirective: Directive;
7
+
8
+ /**
9
+ * 列表自动滚动
10
+ * 用法 v-autoScroll={'class'} class: 需要滚动的类名,必须是指令所在元素的子元素
11
+ * 修饰符: self:作用在v-autoScoll本身的元素上
12
+ */
13
+ declare const autoScroll: Directive;
14
+
15
+ export { autoScroll, focusDirective };
@@ -0,0 +1,69 @@
1
+ const focusDirective = {
2
+ mounted(el, {
3
+ value
4
+ }) {
5
+ if (value !== false) {
6
+ el.focus();
7
+ }
8
+ }
9
+ };
10
+
11
+ const autoScroll = {
12
+ mounted(el, {
13
+ value = "ant-table-body",
14
+ modifiers
15
+ }) {
16
+ let timer;
17
+ let timer2;
18
+ let hover = false;
19
+ let wait = false;
20
+ const {
21
+ self
22
+ } = modifiers;
23
+ const _baseWidth = window.innerWidth / window.innerHeight > 2 ? 7200 : 2880;
24
+ const step = Math.ceil(_baseWidth / window.innerWidth);
25
+ const onmouseenter = () => hover = true;
26
+ const onmouseleave = () => hover = false;
27
+ const scrollEl = self ? el : el.querySelector(`.${value}`);
28
+ if (!scrollEl) return;
29
+ const startScroll = () => {
30
+ if (!document.contains(el)) {
31
+ timer && clearInterval(timer);
32
+ el.removeEventListener("mouseenter", onmouseenter);
33
+ el.removeEventListener("mouseleave", onmouseleave);
34
+ return;
35
+ }
36
+ if (hover) return;
37
+ const scrollElHeight = scrollEl.getBoundingClientRect().height;
38
+ if (scrollElHeight >= scrollEl.scrollHeight) {
39
+ return;
40
+ }
41
+ if (!hover && scrollEl.scrollTop + scrollElHeight > scrollEl.scrollHeight - step) {
42
+ if (timer2) return;
43
+ timer2 = setTimeout(() => {
44
+ if (!hover) {
45
+ scrollEl.scrollTop = 0;
46
+ }
47
+ setTimeout(() => {
48
+ if (!hover) {
49
+ wait = false;
50
+ }
51
+ }, 1e3);
52
+ timer2 = null;
53
+ }, 1e3);
54
+ wait = true;
55
+ } else {
56
+ if (!wait) {
57
+ scrollEl.scrollTo({
58
+ top: scrollEl.scrollTop + step
59
+ });
60
+ }
61
+ }
62
+ };
63
+ timer = setInterval(startScroll, 100);
64
+ el.addEventListener("mouseenter", onmouseenter);
65
+ el.addEventListener("mouseleave", onmouseleave);
66
+ }
67
+ };
68
+
69
+ export { autoScroll, focusDirective };
@@ -0,0 +1,133 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vue = require('vue');
6
+ var core = require('@vueuse/core');
7
+ var dayjs = require('dayjs');
8
+ var _ = require('lodash');
9
+
10
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
+
12
+ var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
13
+ var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
14
+
15
+ function useNow(pattern) {
16
+ const now = vue.ref();
17
+ const updateNow = () => {
18
+ const nowDayjs = dayjs__default["default"]();
19
+ now.value = pattern ? nowDayjs.format(pattern) : nowDayjs;
20
+ };
21
+ core.useIntervalFn(updateNow, 1e3, {
22
+ immediate: false,
23
+ immediateCallback: true
24
+ });
25
+ return now;
26
+ }
27
+
28
+ function useTableList(getData, listProp, totalName = "totalCount") {
29
+ const tableList = vue.ref([]);
30
+ const isLoading = vue.ref(false);
31
+ const total = vue.ref(0);
32
+ const refresh = async () => {
33
+ isLoading.value = true;
34
+ try {
35
+ const {
36
+ data
37
+ } = await getData();
38
+ if (listProp) {
39
+ tableList.value = data[listProp];
40
+ total.value = data[totalName];
41
+ } else {
42
+ tableList.value = data;
43
+ }
44
+ } finally {
45
+ isLoading.value = false;
46
+ }
47
+ };
48
+ const refreshDebounced = _.debounce(refresh, 200);
49
+ const currPage = vue.ref(1);
50
+ const handlePageChange = page => {
51
+ currPage.value = page;
52
+ refresh();
53
+ };
54
+ vue.watch(total, () => {
55
+ const pageCount = Math.ceil(total.value / pageSize.value);
56
+ if (currPage.value > 1 && currPage.value > pageCount) {
57
+ currPage.value = pageCount;
58
+ refresh();
59
+ }
60
+ });
61
+ const pageSize = vue.ref(10);
62
+ const hanldePageSizeChange = size => {
63
+ currPage.value = 1;
64
+ pageSize.value = size;
65
+ refresh();
66
+ };
67
+ const pagination = vue.reactive({
68
+ current: currPage,
69
+ pageSize,
70
+ total,
71
+ showSizeChanger: true,
72
+ showQuickJumper: true,
73
+ showTotal: total2 => `\u5171 ${total2} \u6761`,
74
+ "onUpdate:current": handlePageChange,
75
+ "onUpdate:pageSize": hanldePageSizeChange
76
+ });
77
+ return {
78
+ isLoading,
79
+ tableList,
80
+ currPage,
81
+ handlePageChange,
82
+ pageSize,
83
+ hanldePageSizeChange,
84
+ total,
85
+ refresh: refreshDebounced,
86
+ pagination
87
+ };
88
+ }
89
+
90
+ function useModalVisible(defaultVisible = false) {
91
+ const visible = vue.ref(defaultVisible);
92
+ const record = vue.ref();
93
+ const onToggle = r => {
94
+ if (r) {
95
+ record.value = r;
96
+ }
97
+ visible.value = !visible.value;
98
+ };
99
+ return [visible, onToggle, record];
100
+ }
101
+
102
+ function useQianKunState(action) {
103
+ let isSync = false;
104
+ const state = vue.ref({});
105
+ if (___default["default"].isEmpty(action)) {
106
+ return state;
107
+ }
108
+ const {
109
+ onGlobalStateChange,
110
+ offGlobalStateChange,
111
+ setGlobalState
112
+ } = action;
113
+ const handleGlobalStateChange = value => {
114
+ isSync = true;
115
+ state.value = value;
116
+ vue.nextTick(() => isSync = false);
117
+ };
118
+ vue.watch(state, val => {
119
+ if (!isSync) {
120
+ setGlobalState(val);
121
+ }
122
+ }, {
123
+ deep: true
124
+ });
125
+ vue.onMounted(() => onGlobalStateChange(handleGlobalStateChange, true));
126
+ vue.onBeforeUnmount(() => offGlobalStateChange());
127
+ return state;
128
+ }
129
+
130
+ exports.useModalVisible = useModalVisible;
131
+ exports.useNow = useNow;
132
+ exports.useQianKunState = useQianKunState;
133
+ exports.useTableList = useTableList;
@@ -0,0 +1,50 @@
1
+ import * as vue from 'vue';
2
+ import { Ref } from 'vue';
3
+ import { Dayjs } from 'dayjs';
4
+ import * as lodash from 'lodash';
5
+
6
+ declare function useNow(): Ref<Dayjs>;
7
+ declare function useNow(pattern: string): Ref<string>;
8
+
9
+ /**
10
+ * 通用表格查询hook
11
+ * @param getData 获取数据的函数 返回Promise
12
+ * @param listProp 数据列表在data中的属性 不传代表不分页
13
+ * @param totalName 总数在data中的属性 默认为totalCount
14
+ */
15
+ declare function useTableList(getData: () => Promise<any>, listProp?: string, totalName?: string): {
16
+ isLoading: vue.Ref<boolean>;
17
+ tableList: any;
18
+ currPage: vue.Ref<number>;
19
+ handlePageChange: (page: number) => void;
20
+ pageSize: vue.Ref<number>;
21
+ hanldePageSizeChange: (size: number) => void;
22
+ total: vue.Ref<number>;
23
+ refresh: lodash.DebouncedFunc<() => Promise<void>>;
24
+ pagination: {
25
+ current: number;
26
+ pageSize: number;
27
+ total: number;
28
+ showSizeChanger: boolean;
29
+ showQuickJumper: boolean;
30
+ showTotal: (total: number) => string;
31
+ "onUpdate:current": (page: number) => void;
32
+ "onUpdate:pageSize": (size: number) => void;
33
+ };
34
+ };
35
+
36
+ /**
37
+ * 控制是否展示对话框
38
+ * @param defaultVisible 默认是否展示
39
+ * @returns {[boolean, function, object]} [是否显示,处理点击(传入row),传入的对象]
40
+ */
41
+ declare function useModalVisible<T = any>(defaultVisible?: boolean): [Ref<Boolean>, (r?: T) => void, Ref<T | undefined>];
42
+
43
+ /**
44
+ * 获取qiankun的state 父/子应用通用
45
+ * 只能在App中使用,获取到的state用provide共享给自组件
46
+ * @param action qiankun的全局状态action
47
+ */
48
+ declare function useQianKunState(action: any): vue.Ref<{}>;
49
+
50
+ export { useModalVisible, useNow, useQianKunState, useTableList };
@@ -0,0 +1,121 @@
1
+ import { ref, watch, reactive, onMounted, onBeforeUnmount, nextTick } from 'vue';
2
+ import { useIntervalFn } from '@vueuse/core';
3
+ import dayjs from 'dayjs';
4
+ import _, { debounce } from 'lodash';
5
+
6
+ function useNow(pattern) {
7
+ const now = ref();
8
+ const updateNow = () => {
9
+ const nowDayjs = dayjs();
10
+ now.value = pattern ? nowDayjs.format(pattern) : nowDayjs;
11
+ };
12
+ useIntervalFn(updateNow, 1e3, {
13
+ immediate: false,
14
+ immediateCallback: true
15
+ });
16
+ return now;
17
+ }
18
+
19
+ function useTableList(getData, listProp, totalName = "totalCount") {
20
+ const tableList = ref([]);
21
+ const isLoading = ref(false);
22
+ const total = ref(0);
23
+ const refresh = async () => {
24
+ isLoading.value = true;
25
+ try {
26
+ const {
27
+ data
28
+ } = await getData();
29
+ if (listProp) {
30
+ tableList.value = data[listProp];
31
+ total.value = data[totalName];
32
+ } else {
33
+ tableList.value = data;
34
+ }
35
+ } finally {
36
+ isLoading.value = false;
37
+ }
38
+ };
39
+ const refreshDebounced = debounce(refresh, 200);
40
+ const currPage = ref(1);
41
+ const handlePageChange = page => {
42
+ currPage.value = page;
43
+ refresh();
44
+ };
45
+ watch(total, () => {
46
+ const pageCount = Math.ceil(total.value / pageSize.value);
47
+ if (currPage.value > 1 && currPage.value > pageCount) {
48
+ currPage.value = pageCount;
49
+ refresh();
50
+ }
51
+ });
52
+ const pageSize = ref(10);
53
+ const hanldePageSizeChange = size => {
54
+ currPage.value = 1;
55
+ pageSize.value = size;
56
+ refresh();
57
+ };
58
+ const pagination = reactive({
59
+ current: currPage,
60
+ pageSize,
61
+ total,
62
+ showSizeChanger: true,
63
+ showQuickJumper: true,
64
+ showTotal: total2 => `\u5171 ${total2} \u6761`,
65
+ "onUpdate:current": handlePageChange,
66
+ "onUpdate:pageSize": hanldePageSizeChange
67
+ });
68
+ return {
69
+ isLoading,
70
+ tableList,
71
+ currPage,
72
+ handlePageChange,
73
+ pageSize,
74
+ hanldePageSizeChange,
75
+ total,
76
+ refresh: refreshDebounced,
77
+ pagination
78
+ };
79
+ }
80
+
81
+ function useModalVisible(defaultVisible = false) {
82
+ const visible = ref(defaultVisible);
83
+ const record = ref();
84
+ const onToggle = r => {
85
+ if (r) {
86
+ record.value = r;
87
+ }
88
+ visible.value = !visible.value;
89
+ };
90
+ return [visible, onToggle, record];
91
+ }
92
+
93
+ function useQianKunState(action) {
94
+ let isSync = false;
95
+ const state = ref({});
96
+ if (_.isEmpty(action)) {
97
+ return state;
98
+ }
99
+ const {
100
+ onGlobalStateChange,
101
+ offGlobalStateChange,
102
+ setGlobalState
103
+ } = action;
104
+ const handleGlobalStateChange = value => {
105
+ isSync = true;
106
+ state.value = value;
107
+ nextTick(() => isSync = false);
108
+ };
109
+ watch(state, val => {
110
+ if (!isSync) {
111
+ setGlobalState(val);
112
+ }
113
+ }, {
114
+ deep: true
115
+ });
116
+ onMounted(() => onGlobalStateChange(handleGlobalStateChange, true));
117
+ onBeforeUnmount(() => offGlobalStateChange());
118
+ return state;
119
+ }
120
+
121
+ export { useModalVisible, useNow, useQianKunState, useTableList };