@rainte/ant 0.0.67 → 0.0.70
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/dist/index.js +99 -57
- package/dist/index.umd.cjs +1 -1
- package/dist/types/lib.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { lazy as e, useContext as t, useEffect as n, useRef as r } from "react";
|
|
2
|
+
import i from "quill";
|
|
3
3
|
import "quill/dist/quill.snow.css";
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { BetaSchemaForm as
|
|
6
|
-
import { App as
|
|
7
|
-
import { AiOutlineUpload as
|
|
4
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
5
|
+
import { BetaSchemaForm as s, PageContainer as c, ProCard as l, ProForm as u, ProLayout as d, ProProvider as f, ProTable as p } from "@ant-design/pro-components";
|
|
6
|
+
import { App as m, Button as h, Space as g, Upload as _ } from "antd";
|
|
7
|
+
import { AiOutlineUpload as v } from "react-icons/ai";
|
|
8
|
+
import { Link as y, Navigate as b, Outlet as x, createHashRouter as S, useLocation as C } from "react-router";
|
|
8
9
|
// \0rolldown/runtime.js
|
|
9
|
-
var
|
|
10
|
+
var w = Object.defineProperty, T = (e, t) => {
|
|
10
11
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
12
|
+
for (var r in e) w(n, r, {
|
|
12
13
|
get: e[r],
|
|
13
14
|
enumerable: !0
|
|
14
15
|
});
|
|
15
|
-
return t ||
|
|
16
|
+
return t || w(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
17
|
};
|
|
17
18
|
// src/components/Editor/index.tsx
|
|
18
|
-
function
|
|
19
|
-
let { value:
|
|
20
|
-
return
|
|
19
|
+
function E(e) {
|
|
20
|
+
let { value: t, style: o, ...s } = e, c = r(null), l = r(null);
|
|
21
|
+
return n(() => {
|
|
21
22
|
let e = c.current, t = document.createElement("div");
|
|
22
23
|
Object.assign(t.style, o ?? {});
|
|
23
|
-
let n = new
|
|
24
|
+
let n = new i(e.appendChild(t), {
|
|
24
25
|
theme: "snow",
|
|
25
26
|
...s
|
|
26
27
|
});
|
|
27
28
|
l.current = n;
|
|
28
|
-
let
|
|
29
|
-
return n.on("text-change",
|
|
30
|
-
n.off("text-change",
|
|
29
|
+
let r = () => s.onChange?.(n.root.innerHTML || "");
|
|
30
|
+
return n.on("text-change", r), () => {
|
|
31
|
+
n.off("text-change", r), l.current = null, e.innerHTML = "";
|
|
31
32
|
};
|
|
32
|
-
}, []),
|
|
33
|
+
}, []), n(() => {
|
|
33
34
|
let e = l.current;
|
|
34
35
|
if (!e) return;
|
|
35
|
-
let
|
|
36
|
-
e.root.innerHTML !==
|
|
37
|
-
}, [
|
|
36
|
+
let n = t || "";
|
|
37
|
+
e.root.innerHTML !== n && e.clipboard.dangerouslyPasteHTML(n);
|
|
38
|
+
}, [t]), /* @__PURE__ */ a("div", {
|
|
38
39
|
ref: c,
|
|
39
40
|
style: { height: "100%" }
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
// src/components/Upload/index.tsx
|
|
43
|
-
var
|
|
44
|
+
var D = (e) => {
|
|
44
45
|
if (Array.isArray(e)) return e;
|
|
45
46
|
if (e && typeof e == "object" && "fileList" in e) return e.fileList;
|
|
46
47
|
};
|
|
47
|
-
function
|
|
48
|
-
let { value: t, onChange: n, maxCount: r = 1, multiple:
|
|
49
|
-
icon: /* @__PURE__ */
|
|
48
|
+
function O(e) {
|
|
49
|
+
let { value: t, onChange: n, maxCount: r = 1, multiple: i, listType: o, ...s } = e, c = D(t) ?? [], l = c.length >= r, u = o?.startsWith("picture-") ? /* @__PURE__ */ a(v, {}) : /* @__PURE__ */ a(h, {
|
|
50
|
+
icon: /* @__PURE__ */ a(v, {}),
|
|
50
51
|
children: "上传"
|
|
51
52
|
});
|
|
52
|
-
return /* @__PURE__ */
|
|
53
|
+
return /* @__PURE__ */ a(_, {
|
|
53
54
|
...s,
|
|
54
55
|
maxCount: r,
|
|
55
|
-
multiple:
|
|
56
|
+
multiple: i ?? r > 1,
|
|
56
57
|
listType: o,
|
|
57
58
|
showUploadList: s.showUploadList ?? !0,
|
|
58
59
|
fileList: c,
|
|
@@ -61,44 +62,68 @@ function y(e) {
|
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
// src/components/Provider/index.tsx
|
|
64
|
-
var
|
|
65
|
-
upload: { formItemRender: (e, t) => /* @__PURE__ */
|
|
66
|
-
editor: { formItemRender: (e, t) => /* @__PURE__ */
|
|
65
|
+
var k = {
|
|
66
|
+
upload: { formItemRender: (e, t) => /* @__PURE__ */ a(O, { ...t.fieldProps }) },
|
|
67
|
+
editor: { formItemRender: (e, t) => /* @__PURE__ */ a(E, { ...t.fieldProps }) }
|
|
67
68
|
};
|
|
68
|
-
function
|
|
69
|
-
let n =
|
|
70
|
-
return /* @__PURE__ */
|
|
69
|
+
function A({ children: e }) {
|
|
70
|
+
let n = t(f);
|
|
71
|
+
return /* @__PURE__ */ a(f.Provider, {
|
|
71
72
|
value: {
|
|
72
73
|
...n,
|
|
73
74
|
valueTypeMap: {
|
|
74
75
|
...n.valueTypeMap,
|
|
75
|
-
...
|
|
76
|
+
...k
|
|
76
77
|
}
|
|
77
78
|
},
|
|
78
|
-
children:
|
|
79
|
+
children: e
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
82
|
// src/components/Form/index.tsx
|
|
82
|
-
var
|
|
83
|
+
var j = () => u.useForm()[0], M = (e) => /* @__PURE__ */ a(A, { children: /* @__PURE__ */ a(s, {
|
|
83
84
|
layout: "horizontal",
|
|
84
85
|
colon: !1,
|
|
85
86
|
scrollToFirstError: !0,
|
|
86
|
-
submitter: { render: (e, t) => /* @__PURE__ */
|
|
87
|
+
submitter: { render: (e, t) => /* @__PURE__ */ a(u.Item, {
|
|
87
88
|
wrapperCol: {
|
|
88
89
|
offset: 4,
|
|
89
90
|
span: 8
|
|
90
91
|
},
|
|
91
|
-
children: /* @__PURE__ */
|
|
92
|
+
children: /* @__PURE__ */ a(g, { children: t })
|
|
92
93
|
}) },
|
|
93
94
|
...e
|
|
94
95
|
}) });
|
|
95
|
-
|
|
96
|
+
M.useForm = j;
|
|
97
|
+
// src/components/Layout/index.tsx
|
|
98
|
+
var N = (e, t) => /* @__PURE__ */ a(y, {
|
|
99
|
+
to: e.path || "/",
|
|
100
|
+
children: t
|
|
101
|
+
});
|
|
102
|
+
function P({ routes: e, ...t }) {
|
|
103
|
+
let n = C();
|
|
104
|
+
return /* @__PURE__ */ a(d, {
|
|
105
|
+
title: "Rainte",
|
|
106
|
+
token: { bgLayout: "#fff" },
|
|
107
|
+
menuItemRender: N,
|
|
108
|
+
...t,
|
|
109
|
+
route: {
|
|
110
|
+
path: "/",
|
|
111
|
+
...t.route,
|
|
112
|
+
...e === void 0 ? {} : { routes: e }
|
|
113
|
+
},
|
|
114
|
+
location: t.location ?? { pathname: n.pathname },
|
|
115
|
+
children: /* @__PURE__ */ a(c, {
|
|
116
|
+
title: !1,
|
|
117
|
+
children: /* @__PURE__ */ a(l, { children: /* @__PURE__ */ a(x, {}) })
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
}
|
|
96
121
|
// src/components/Table/index.tsx
|
|
97
|
-
function
|
|
98
|
-
return /* @__PURE__ */
|
|
122
|
+
function F(e) {
|
|
123
|
+
return /* @__PURE__ */ a(A, { children: /* @__PURE__ */ a(p, {
|
|
99
124
|
rowKey: "id",
|
|
100
125
|
pagination: { pageSize: 10 },
|
|
101
|
-
tableAlertRender: ({ selectedRowKeys: e }) => /* @__PURE__ */
|
|
126
|
+
tableAlertRender: ({ selectedRowKeys: e }) => /* @__PURE__ */ o(g, { children: [
|
|
102
127
|
"已选 ",
|
|
103
128
|
e.length,
|
|
104
129
|
" 项"
|
|
@@ -107,23 +132,23 @@ function w(e) {
|
|
|
107
132
|
}) });
|
|
108
133
|
}
|
|
109
134
|
// src/utils/antd.ts
|
|
110
|
-
var
|
|
111
|
-
AntdAppHolder: () =>
|
|
112
|
-
message: () =>
|
|
113
|
-
modal: () =>
|
|
114
|
-
notification: () =>
|
|
115
|
-
}),
|
|
116
|
-
let e =
|
|
117
|
-
return
|
|
118
|
-
},
|
|
119
|
-
return t === "confirm" ? (e) =>
|
|
135
|
+
var I = /* @__PURE__ */ T({
|
|
136
|
+
AntdAppHolder: () => B,
|
|
137
|
+
message: () => H,
|
|
138
|
+
modal: () => V,
|
|
139
|
+
notification: () => z
|
|
140
|
+
}), L, R, z, B = () => {
|
|
141
|
+
let e = m.useApp();
|
|
142
|
+
return L = e.message, R = e.modal, z = e.notification, null;
|
|
143
|
+
}, V = new Proxy({}, { get(e, t) {
|
|
144
|
+
return t === "confirm" ? (e) => R.confirm({
|
|
120
145
|
title: "提示",
|
|
121
146
|
content: "确认操作?",
|
|
122
147
|
...e
|
|
123
|
-
}) :
|
|
124
|
-
} }),
|
|
125
|
-
return t === "success" ? (e = "操作成功", t, n) =>
|
|
126
|
-
} }),
|
|
148
|
+
}) : R[t];
|
|
149
|
+
} }), H = new Proxy({}, { get(e, t) {
|
|
150
|
+
return t === "success" ? (e = "操作成功", t, n) => L.success(e, t, n) : L[t];
|
|
151
|
+
} }), U = /* @__PURE__ */ T({ onUpload: () => W }), W = async (e) => {
|
|
127
152
|
let { file: t, onProgress: n, onSuccess: r, onError: i } = e, a = URL.createObjectURL(t);
|
|
128
153
|
try {
|
|
129
154
|
await new Promise((e) => {
|
|
@@ -134,5 +159,22 @@ var T = /* @__PURE__ */ g({
|
|
|
134
159
|
} catch (e) {
|
|
135
160
|
URL.revokeObjectURL(a), i?.(e);
|
|
136
161
|
}
|
|
137
|
-
};
|
|
138
|
-
|
|
162
|
+
}, G = /* @__PURE__ */ T({ createRouter: () => K });
|
|
163
|
+
function K(t, n, r) {
|
|
164
|
+
let i = t.map((t) => ({
|
|
165
|
+
path: t.url,
|
|
166
|
+
Component: e(t.component)
|
|
167
|
+
})), o = /* @__PURE__ */ a(b, { to: n });
|
|
168
|
+
return S([{
|
|
169
|
+
path: "/",
|
|
170
|
+
Component: e(r),
|
|
171
|
+
children: [{
|
|
172
|
+
index: !0,
|
|
173
|
+
element: o
|
|
174
|
+
}, ...i]
|
|
175
|
+
}, {
|
|
176
|
+
path: "*",
|
|
177
|
+
element: o
|
|
178
|
+
}]);
|
|
179
|
+
}
|
|
180
|
+
export { E as Editor, M as Form, P as Layout, A as Provider, F as Table, O as Upload, I as antd, U as misc, G as router };
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("quill"),require("quill/dist/quill.snow.css"),require("react/jsx-runtime"),require("@ant-design/pro-components"),require("antd"),require("react-icons/ai")):typeof define==`function`&&define.amd?define([`exports`,`react`,`quill`,`quill/dist/quill.snow.css`,`react/jsx-runtime`,`@ant-design/pro-components`,`antd`,`react-icons/ai`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@rainte/ant`]={},e.React,e.Quill,e.QuillSnowCSS,e.ReactJSXRuntime,e.ProComponents,e.antd,e.ReactIconsAI))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("quill"),require("quill/dist/quill.snow.css"),require("react/jsx-runtime"),require("@ant-design/pro-components"),require("antd"),require("react-icons/ai"),require("react-router")):typeof define==`function`&&define.amd?define([`exports`,`react`,`quill`,`quill/dist/quill.snow.css`,`react/jsx-runtime`,`@ant-design/pro-components`,`antd`,`react-icons/ai`,`react-router`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@rainte/ant`]={},e.React,e.Quill,e.QuillSnowCSS,e.ReactJSXRuntime,e.ProComponents,e.antd,e.ReactIconsAI,e.ReactRouter))})(this,function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=Object.create,u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,p=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,h=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t||u(n,Symbol.toStringTag,{value:`Module`}),n},g=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=f(t),a=0,o=i.length,s;a<o;a++)s=i[a],!m.call(e,s)&&s!==n&&u(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=d(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:l(p(e)),g(u(n,`default`,{value:e,enumerable:!0}),e)))(n,1);function _(e){let{value:r,style:a,...o}=e,s=(0,t.useRef)(null),c=(0,t.useRef)(null);return(0,t.useEffect)(()=>{let e=s.current,t=document.createElement(`div`);Object.assign(t.style,a??{});let r=new n.default(e.appendChild(t),{theme:`snow`,...o});c.current=r;let i=()=>o.onChange?.(r.root.innerHTML||``);return r.on(`text-change`,i),()=>{r.off(`text-change`,i),c.current=null,e.innerHTML=``}},[]),(0,t.useEffect)(()=>{let e=c.current;if(!e)return;let t=r||``;e.root.innerHTML!==t&&e.clipboard.dangerouslyPasteHTML(t)},[r]),(0,i.jsx)(`div`,{ref:s,style:{height:`100%`}})}var v=e=>{if(Array.isArray(e))return e;if(e&&typeof e==`object`&&`fileList`in e)return e.fileList};function y(e){let{value:t,onChange:n,maxCount:r=1,multiple:a,listType:c,...l}=e,u=v(t)??[],d=u.length>=r,f=c?.startsWith(`picture-`)?(0,i.jsx)(s.AiOutlineUpload,{}):(0,i.jsx)(o.Button,{icon:(0,i.jsx)(s.AiOutlineUpload,{}),children:`上传`});return(0,i.jsx)(o.Upload,{...l,maxCount:r,multiple:a??r>1,listType:c,showUploadList:l.showUploadList??!0,fileList:u,onChange:e=>n?.(e.fileList),children:d?null:f})}var b={upload:{formItemRender:(e,t)=>(0,i.jsx)(y,{...t.fieldProps})},editor:{formItemRender:(e,t)=>(0,i.jsx)(_,{...t.fieldProps})}};function x({children:e}){let n=(0,t.useContext)(a.ProProvider);return(0,i.jsx)(a.ProProvider.Provider,{value:{...n,valueTypeMap:{...n.valueTypeMap,...b}},children:e})}var S=()=>a.ProForm.useForm()[0],C=e=>(0,i.jsx)(x,{children:(0,i.jsx)(a.BetaSchemaForm,{layout:`horizontal`,colon:!1,scrollToFirstError:!0,submitter:{render:(e,t)=>(0,i.jsx)(a.ProForm.Item,{wrapperCol:{offset:4,span:8},children:(0,i.jsx)(o.Space,{children:t})})},...e})});C.useForm=S;var w=(e,t)=>(0,i.jsx)(c.Link,{to:e.path||`/`,children:t});function T({routes:e,...t}){let n=(0,c.useLocation)();return(0,i.jsx)(a.ProLayout,{title:`Rainte`,token:{bgLayout:`#fff`},menuItemRender:w,...t,route:{path:`/`,...t.route,...e===void 0?{}:{routes:e}},location:t.location??{pathname:n.pathname},children:(0,i.jsx)(a.PageContainer,{title:!1,children:(0,i.jsx)(a.ProCard,{children:(0,i.jsx)(c.Outlet,{})})})})}function E(e){return(0,i.jsx)(x,{children:(0,i.jsx)(a.ProTable,{rowKey:`id`,pagination:{pageSize:10},tableAlertRender:({selectedRowKeys:e})=>(0,i.jsxs)(o.Space,{children:[`已选 `,e.length,` 项`]}),...e})})}var D=h({AntdAppHolder:()=>j,message:()=>N,modal:()=>M,notification:()=>A}),O,k,A,j=()=>{let e=o.App.useApp();return O=e.message,k=e.modal,A=e.notification,null},M=new Proxy({},{get(e,t){return t===`confirm`?e=>k.confirm({title:`提示`,content:`确认操作?`,...e}):k[t]}}),N=new Proxy({},{get(e,t){return t===`success`?(e=`操作成功`,t,n)=>O.success(e,t,n):O[t]}}),P=h({onUpload:()=>F}),F=async e=>{let{file:t,onProgress:n,onSuccess:r,onError:i}=e,a=URL.createObjectURL(t);try{await new Promise(e=>{let t=0,r=setInterval(()=>{t=Math.min(t+Math.floor(Math.random()*10)+1,99),n?.({percent:t}),t>=99&&(clearInterval(r),e())},100)}),n?.({percent:100}),t.url=a,r?.({url:a})}catch(e){URL.revokeObjectURL(a),i?.(e)}},I=h({createRouter:()=>L});function L(e,n,r){let a=e.map(e=>({path:e.url,Component:(0,t.lazy)(e.component)})),o=(0,i.jsx)(c.Navigate,{to:n});return(0,c.createHashRouter)([{path:`/`,Component:(0,t.lazy)(r),children:[{index:!0,element:o},...a]},{path:`*`,element:o}])}e.Editor=_,e.Form=C,e.Layout=T,e.Provider=x,e.Table=E,e.Upload=y,Object.defineProperty(e,"antd",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"misc",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"router",{enumerable:!0,get:function(){return I}})});
|
package/dist/types/lib.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { default as Editor } from './components/Editor';
|
|
|
2
2
|
export type { EditorProps } from './components/Editor';
|
|
3
3
|
export { default as Form } from './components/Form';
|
|
4
4
|
export type { FormProps } from './components/Form';
|
|
5
|
+
export { default as Layout } from './components/Layout';
|
|
6
|
+
export type { LayoutProps } from './components/Layout';
|
|
5
7
|
export { default as Provider } from './components/Provider';
|
|
6
8
|
export { default as Table } from './components/Table';
|
|
7
9
|
export type { TableProps } from './components/Table';
|
|
@@ -9,3 +11,4 @@ export { default as Upload } from './components/Upload';
|
|
|
9
11
|
export type { UploadProps } from './components/Upload';
|
|
10
12
|
export * as antd from './utils/antd';
|
|
11
13
|
export * as misc from './utils/misc';
|
|
14
|
+
export * as router from './utils/router';
|