@kingteza/crud-component 1.32.1 → 1.34.0
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/common/rich/index.cjs.js +2 -2
- package/dist/common/rich/index.d.ts +1 -1
- package/dist/common/rich/index.es.js +119 -75
- package/dist/context/CrudComponentProvider.cjs.js +1 -1
- package/dist/context/CrudComponentProvider.d.ts +14 -0
- package/dist/context/CrudComponentProvider.es.js +22 -14
- package/dist/context/CrudNavigateContext.cjs.js +1 -0
- package/dist/context/CrudNavigateContext.d.ts +14 -0
- package/dist/context/CrudNavigateContext.es.js +29 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/crud/CrudComponent.d.ts +1 -0
- package/dist/crud/CrudField.cjs.js +1 -1
- package/dist/crud/CrudField.es.js +92 -91
- package/dist/crud/CrudReportComponent.cjs.js +1 -1
- package/dist/crud/CrudReportComponent.d.ts +10 -1
- package/dist/crud/CrudReportComponent.es.js +193 -134
- package/dist/crud/CrudTextAreaComponent.cjs.js +1 -1
- package/dist/crud/CrudTextAreaComponent.d.ts +2 -1
- package/dist/crud/CrudTextAreaComponent.es.js +19 -17
- package/dist/crud/index.d.ts +1 -1
- package/dist/hooks/NavigatorHooks.cjs.js +1 -1
- package/dist/hooks/NavigatorHooks.d.ts +6 -1
- package/dist/hooks/NavigatorHooks.es.js +13 -6
- package/dist/index.d.ts +1 -1
- package/dist/navigator/CrudNextNavigateSync.cjs.js +1 -0
- package/dist/navigator/CrudNextNavigateSync.d.ts +20 -0
- package/dist/navigator/CrudNextNavigateSync.es.js +20 -0
- package/dist/navigator/CrudReactRouterNavigateSync.cjs.js +1 -0
- package/dist/navigator/CrudReactRouterNavigateSync.d.ts +18 -0
- package/dist/navigator/CrudReactRouterNavigateSync.es.js +10 -0
- package/dist/next.cjs.js +1 -0
- package/dist/next.d.ts +1 -0
- package/dist/next.es.js +4 -0
- package/dist/react-router.cjs.js +1 -0
- package/dist/react-router.d.ts +1 -0
- package/dist/react-router.es.js +4 -0
- package/dist/style.css +4 -3
- package/package.json +20 -3
|
@@ -1,112 +1,141 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { FileExcelOutlined as
|
|
3
|
-
import { Form as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { SelectFieldInReport as
|
|
8
|
-
import { getRendererValueCrudViewer as
|
|
9
|
-
import { useTranslationLib as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { PrintButton as
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
fields:
|
|
16
|
-
data:
|
|
17
|
-
idField:
|
|
18
|
-
loadingData:
|
|
19
|
-
onSubmit:
|
|
20
|
-
paginateProps:
|
|
21
|
-
size:
|
|
22
|
-
onClickPrint:
|
|
23
|
-
onClickExcelExport:
|
|
24
|
-
minusHeight:
|
|
25
|
-
extraSearchFields:
|
|
26
|
-
searchOnMount:
|
|
27
|
-
summary:
|
|
28
|
-
showFieldsSelectingMode:
|
|
1
|
+
import { jsxs as b, jsx as r, Fragment as re } from "react/jsx-runtime";
|
|
2
|
+
import { FileExcelOutlined as le } from "@ant-design/icons";
|
|
3
|
+
import { Form as v, Space as $, Row as k, Col as w, Radio as I } from "antd";
|
|
4
|
+
import { useMemo as oe, useState as V, useCallback as z, useRef as se, useEffect as T } from "react";
|
|
5
|
+
import q from "./CrudField.es.js";
|
|
6
|
+
import ne from "./view/CrudViewer.es.js";
|
|
7
|
+
import { SelectFieldInReport as ie } from "../common/report/SelectFieldInReport.es.js";
|
|
8
|
+
import { getRendererValueCrudViewer as D } from "./view/CrudViewerUtil.es.js";
|
|
9
|
+
import { useTranslationLib as ae } from "../locale/index.es.js";
|
|
10
|
+
import de from "../common/select/SelectComponent.es.js";
|
|
11
|
+
import H from "../common/button/Button.es.js";
|
|
12
|
+
import { PrintButton as ue } from "../common/button/PrintButton.es.js";
|
|
13
|
+
const K = { lg: 6, md: 8, sm: 12, xs: 24 }, me = { lg: 12, md: 16, sm: 24, xs: 24 };
|
|
14
|
+
function ve({
|
|
15
|
+
fields: s,
|
|
16
|
+
data: o,
|
|
17
|
+
idField: u,
|
|
18
|
+
loadingData: n,
|
|
19
|
+
onSubmit: f,
|
|
20
|
+
paginateProps: R,
|
|
21
|
+
size: U,
|
|
22
|
+
onClickPrint: S,
|
|
23
|
+
onClickExcelExport: B,
|
|
24
|
+
minusHeight: W,
|
|
25
|
+
extraSearchFields: A,
|
|
26
|
+
searchOnMount: O,
|
|
27
|
+
summary: X,
|
|
28
|
+
showFieldsSelectingMode: Y = "checkbox",
|
|
29
|
+
cachedSearchProps: a
|
|
29
30
|
}) {
|
|
30
|
-
const { t:
|
|
31
|
-
var
|
|
32
|
-
const e = [],
|
|
33
|
-
let
|
|
34
|
-
for (const
|
|
35
|
-
|
|
36
|
-
id:
|
|
37
|
-
label:
|
|
38
|
-
lock: (
|
|
39
|
-
alreadySelected: (
|
|
31
|
+
const { t: Z } = ae(), { searchable: E, selectable: c, sortable: j, defaultSort: y } = oe(() => {
|
|
32
|
+
var g, p, h, G, _;
|
|
33
|
+
const e = [], t = [], l = [];
|
|
34
|
+
let m;
|
|
35
|
+
for (const i of s.filter((te) => !te.hidden))
|
|
36
|
+
i.type === "image" || !i.report || ((g = i.report) != null && g.searchable && e.push(i), (p = i.report) != null && p.sortable && (t.push(i), !m && ((h = i.report) != null && h.defaultSort) && (m = i)), i.hideInTable || l.push({
|
|
37
|
+
id: i.name,
|
|
38
|
+
label: i.label,
|
|
39
|
+
lock: (G = i.report) == null ? void 0 : G.lock,
|
|
40
|
+
alreadySelected: (_ = i.report) == null ? void 0 : _.alreadySelected
|
|
40
41
|
}));
|
|
41
42
|
return {
|
|
42
|
-
defaultSort:
|
|
43
|
+
defaultSort: m,
|
|
43
44
|
searchable: e,
|
|
44
|
-
sortable:
|
|
45
|
-
selectable:
|
|
45
|
+
sortable: t,
|
|
46
|
+
selectable: l
|
|
46
47
|
};
|
|
47
|
-
}, [
|
|
48
|
+
}, [s]), [N, L] = V(
|
|
48
49
|
[]
|
|
49
|
-
),
|
|
50
|
+
), F = z(
|
|
51
|
+
(e) => {
|
|
52
|
+
L(
|
|
53
|
+
s.filter((t) => e.includes(t.name)).map((t) => ({ ...t, hideInTable: !1 }))
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
[s]
|
|
57
|
+
), C = z(
|
|
50
58
|
async ({
|
|
51
59
|
sortBy: e,
|
|
52
|
-
sortByType:
|
|
53
|
-
showFields:
|
|
54
|
-
...
|
|
60
|
+
sortByType: t,
|
|
61
|
+
showFields: l = [],
|
|
62
|
+
...m
|
|
55
63
|
}) => {
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
var h;
|
|
65
|
+
const g = [];
|
|
66
|
+
e && g.push({
|
|
58
67
|
field: e,
|
|
59
|
-
sort:
|
|
60
|
-
}),
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
sort: t ?? "DESC"
|
|
69
|
+
}), F(l);
|
|
70
|
+
const p = { showFields: l, sortBy: g, ...m };
|
|
71
|
+
a && (ce(
|
|
72
|
+
a.key,
|
|
73
|
+
a.saveMode,
|
|
74
|
+
p
|
|
75
|
+
), (h = a.onSave) == null || h.call(a, p)), f(p);
|
|
63
76
|
},
|
|
64
|
-
[
|
|
65
|
-
), [
|
|
66
|
-
return
|
|
67
|
-
if (
|
|
77
|
+
[F, a, f]
|
|
78
|
+
), [d] = v.useForm(), M = se(!1), [J, P] = V(!1), [x, ee] = V(!0);
|
|
79
|
+
return T(() => {
|
|
80
|
+
if (O && x) {
|
|
68
81
|
const e = setTimeout(() => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}),
|
|
82
|
+
d.validateFields().then((t) => {
|
|
83
|
+
C(t);
|
|
84
|
+
}), ee(!1);
|
|
72
85
|
}, 200);
|
|
73
86
|
return () => clearTimeout(e);
|
|
74
87
|
}
|
|
75
|
-
}, [
|
|
76
|
-
var
|
|
77
|
-
!
|
|
78
|
-
sortBy:
|
|
79
|
-
sortByType: typeof ((
|
|
88
|
+
}, [C, d, x, O]), T(() => {
|
|
89
|
+
var t, l;
|
|
90
|
+
!d.getFieldValue("sortBy") && y && d.setFieldsValue({
|
|
91
|
+
sortBy: y.name,
|
|
92
|
+
sortByType: typeof ((t = y.report) == null ? void 0 : t.defaultSort) == "string" ? (l = y.report) == null ? void 0 : l.defaultSort : "ASC"
|
|
80
93
|
});
|
|
81
|
-
}, [
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
}, [y, d]), T(() => {
|
|
95
|
+
if (!a || M.current)
|
|
96
|
+
return;
|
|
97
|
+
M.current = !0;
|
|
98
|
+
const e = fe(
|
|
99
|
+
a.key,
|
|
100
|
+
a.saveMode
|
|
101
|
+
), t = {
|
|
102
|
+
...a.defaultValue ?? {},
|
|
103
|
+
...e ?? {}
|
|
104
|
+
};
|
|
105
|
+
if (Object.keys(t).length === 0)
|
|
106
|
+
return;
|
|
107
|
+
d.setFieldsValue(pe(t));
|
|
108
|
+
const l = t.showFields;
|
|
109
|
+
l != null && l.length && F(l);
|
|
110
|
+
}, [F, a, d]), T(() => {
|
|
111
|
+
if (J) {
|
|
112
|
+
const e = c.filter((t) => t.alreadySelected).map((t) => t.id);
|
|
113
|
+
L(
|
|
114
|
+
s.filter((t) => e.includes(t.name)).map((t) => ({ ...t, hideInTable: !1 }))
|
|
115
|
+
), P(!1);
|
|
87
116
|
}
|
|
88
|
-
}, [
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
|
|
92
|
-
var
|
|
93
|
-
return /* @__PURE__ */
|
|
94
|
-
|
|
117
|
+
}, [s, J, c]), /* @__PURE__ */ b($, { className: "w-100", direction: "vertical", children: [
|
|
118
|
+
/* @__PURE__ */ b(v, { form: d, layout: "vertical", onFinish: C, children: [
|
|
119
|
+
/* @__PURE__ */ b(k, { gutter: [8, 8], children: [
|
|
120
|
+
E.map((e) => {
|
|
121
|
+
var t, l, m;
|
|
122
|
+
return /* @__PURE__ */ r(
|
|
123
|
+
w,
|
|
95
124
|
{
|
|
96
|
-
...e.grid ??
|
|
125
|
+
...e.grid ?? K,
|
|
97
126
|
style: { alignSelf: "end" },
|
|
98
|
-
children: (
|
|
99
|
-
|
|
127
|
+
children: (t = e.report) != null && t.customRender ? e.report.customRender(d) : e.type === "date" ? /* @__PURE__ */ r(
|
|
128
|
+
q,
|
|
100
129
|
{
|
|
101
130
|
...e,
|
|
102
131
|
type: "date",
|
|
103
|
-
range: (
|
|
104
|
-
required: !!((
|
|
132
|
+
range: (l = e.report) == null ? void 0 : l.range,
|
|
133
|
+
required: !!((m = e.report) != null && m.required),
|
|
105
134
|
readonly: !1,
|
|
106
135
|
fieldClassName: "mb-0"
|
|
107
136
|
}
|
|
108
|
-
) : e.type === "select" ? /* @__PURE__ */
|
|
109
|
-
|
|
137
|
+
) : e.type === "select" ? /* @__PURE__ */ r(
|
|
138
|
+
q,
|
|
110
139
|
{
|
|
111
140
|
...e,
|
|
112
141
|
type: "select",
|
|
@@ -115,8 +144,8 @@ function ge({
|
|
|
115
144
|
readonly: !1,
|
|
116
145
|
fieldClassName: "mb-0"
|
|
117
146
|
}
|
|
118
|
-
) : /* @__PURE__ */
|
|
119
|
-
|
|
147
|
+
) : /* @__PURE__ */ r(
|
|
148
|
+
q,
|
|
120
149
|
{
|
|
121
150
|
...e,
|
|
122
151
|
readonly: !1,
|
|
@@ -128,37 +157,37 @@ function ge({
|
|
|
128
157
|
e.name
|
|
129
158
|
);
|
|
130
159
|
}),
|
|
131
|
-
!!(
|
|
132
|
-
|
|
160
|
+
!!(c != null && c.length) && /* @__PURE__ */ r(w, { ...me, children: /* @__PURE__ */ r(
|
|
161
|
+
ie,
|
|
133
162
|
{
|
|
134
|
-
items:
|
|
163
|
+
items: c,
|
|
135
164
|
name: "showFields",
|
|
136
165
|
mode: "multiple",
|
|
137
|
-
label:
|
|
166
|
+
label: Z("str.showFields"),
|
|
138
167
|
className: "mb-0",
|
|
139
|
-
selectingMode:
|
|
168
|
+
selectingMode: Y
|
|
140
169
|
}
|
|
141
170
|
) }),
|
|
142
|
-
!!
|
|
143
|
-
|
|
171
|
+
!!j.length && /* @__PURE__ */ r(w, { ...K, children: /* @__PURE__ */ r(
|
|
172
|
+
de,
|
|
144
173
|
{
|
|
145
174
|
label: "Sort By",
|
|
146
175
|
name: "sortBy",
|
|
147
|
-
items:
|
|
176
|
+
items: j.map((e) => ({ id: e.name, label: e.label })),
|
|
148
177
|
nameFieldInArray: "label",
|
|
149
178
|
fieldId: "id",
|
|
150
179
|
className: "mb-0",
|
|
151
|
-
dropdownRender: (e) => /* @__PURE__ */
|
|
180
|
+
dropdownRender: (e) => /* @__PURE__ */ b(re, { children: [
|
|
152
181
|
e,
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
|
|
182
|
+
/* @__PURE__ */ r(v.Item, { name: "sortByType", noStyle: !0, className: "mt-3", children: /* @__PURE__ */ r(
|
|
183
|
+
I.Group,
|
|
155
184
|
{
|
|
156
185
|
className: "w-100",
|
|
157
186
|
defaultValue: "DESC",
|
|
158
187
|
optionType: "button",
|
|
159
|
-
children: /* @__PURE__ */
|
|
160
|
-
/* @__PURE__ */
|
|
161
|
-
|
|
188
|
+
children: /* @__PURE__ */ b(k, { children: [
|
|
189
|
+
/* @__PURE__ */ r(w, { xs: 12, children: /* @__PURE__ */ r(
|
|
190
|
+
I,
|
|
162
191
|
{
|
|
163
192
|
className: "w-100",
|
|
164
193
|
style: {
|
|
@@ -169,8 +198,8 @@ function ge({
|
|
|
169
198
|
children: "Ascending"
|
|
170
199
|
}
|
|
171
200
|
) }),
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
|
|
201
|
+
/* @__PURE__ */ r(w, { xs: 12, children: /* @__PURE__ */ r(
|
|
202
|
+
I,
|
|
174
203
|
{
|
|
175
204
|
className: "w-100",
|
|
176
205
|
style: {
|
|
@@ -187,69 +216,99 @@ function ge({
|
|
|
187
216
|
] })
|
|
188
217
|
}
|
|
189
218
|
) }),
|
|
190
|
-
|
|
219
|
+
A ? A(d) : null
|
|
191
220
|
] }),
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
|
|
221
|
+
/* @__PURE__ */ r(
|
|
222
|
+
H,
|
|
194
223
|
{
|
|
195
224
|
className: "mt-3",
|
|
196
225
|
type: "primary",
|
|
197
226
|
block: !0,
|
|
198
227
|
htmlType: "submit",
|
|
199
|
-
disabled:
|
|
228
|
+
disabled: n,
|
|
200
229
|
children: "Submit"
|
|
201
230
|
}
|
|
202
231
|
)
|
|
203
232
|
] }),
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
!!
|
|
206
|
-
|
|
233
|
+
/* @__PURE__ */ b($, { children: [
|
|
234
|
+
!!S && /* @__PURE__ */ r(
|
|
235
|
+
ue,
|
|
207
236
|
{
|
|
208
|
-
disabled:
|
|
209
|
-
onClick: () =>
|
|
237
|
+
disabled: n || !o.length,
|
|
238
|
+
onClick: () => S == null ? void 0 : S({
|
|
210
239
|
tableId: "#crud-table table",
|
|
211
|
-
data:
|
|
212
|
-
fields:
|
|
240
|
+
data: o,
|
|
241
|
+
fields: N.map((e) => ({
|
|
213
242
|
...e,
|
|
214
|
-
render:
|
|
243
|
+
render: D(e)
|
|
215
244
|
}))
|
|
216
245
|
})
|
|
217
246
|
}
|
|
218
247
|
),
|
|
219
|
-
!!
|
|
220
|
-
|
|
248
|
+
!!B && /* @__PURE__ */ r(
|
|
249
|
+
H,
|
|
221
250
|
{
|
|
222
|
-
disabled:
|
|
223
|
-
onClick: () =>
|
|
251
|
+
disabled: n || !o.length,
|
|
252
|
+
onClick: () => B == null ? void 0 : B({
|
|
224
253
|
tableId: "#crud-table table",
|
|
225
|
-
data:
|
|
226
|
-
fields:
|
|
254
|
+
data: o,
|
|
255
|
+
fields: N.map((e) => ({
|
|
227
256
|
...e,
|
|
228
|
-
render:
|
|
257
|
+
render: D(e)
|
|
229
258
|
}))
|
|
230
259
|
}),
|
|
231
|
-
icon: /* @__PURE__ */
|
|
232
|
-
className: `group ${
|
|
260
|
+
icon: /* @__PURE__ */ r(le, {}),
|
|
261
|
+
className: `group ${n || !o.length ? "" : "crud-excel-export-btn"}`,
|
|
233
262
|
children: "Excel"
|
|
234
263
|
}
|
|
235
264
|
)
|
|
236
265
|
] }),
|
|
237
|
-
|
|
238
|
-
/* @__PURE__ */
|
|
239
|
-
|
|
266
|
+
X,
|
|
267
|
+
/* @__PURE__ */ r(
|
|
268
|
+
ne,
|
|
240
269
|
{
|
|
241
|
-
minusHeight:
|
|
242
|
-
data:
|
|
243
|
-
size:
|
|
244
|
-
fields:
|
|
245
|
-
idField:
|
|
246
|
-
loadingData:
|
|
247
|
-
paginateProps:
|
|
270
|
+
minusHeight: W,
|
|
271
|
+
data: o,
|
|
272
|
+
size: U,
|
|
273
|
+
fields: N,
|
|
274
|
+
idField: u,
|
|
275
|
+
loadingData: n,
|
|
276
|
+
paginateProps: R,
|
|
248
277
|
viewable: !1
|
|
249
278
|
}
|
|
250
279
|
)
|
|
251
280
|
] });
|
|
252
281
|
}
|
|
282
|
+
function Q(s) {
|
|
283
|
+
return typeof globalThis.window > "u" ? null : s === "local" ? globalThis.window.localStorage : globalThis.window.sessionStorage;
|
|
284
|
+
}
|
|
285
|
+
function fe(s, o) {
|
|
286
|
+
const u = Q(o);
|
|
287
|
+
if (!u)
|
|
288
|
+
return null;
|
|
289
|
+
try {
|
|
290
|
+
const n = u.getItem(s);
|
|
291
|
+
return n ? JSON.parse(n) : null;
|
|
292
|
+
} catch {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function ce(s, o, u) {
|
|
297
|
+
const n = Q(o);
|
|
298
|
+
if (n)
|
|
299
|
+
try {
|
|
300
|
+
n.setItem(s, JSON.stringify(u));
|
|
301
|
+
} catch {
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function pe(s) {
|
|
305
|
+
const { sortBy: o, showFields: u, ...n } = s, f = { ...n };
|
|
306
|
+
if (u !== void 0 && (f.showFields = u), o != null && o.length) {
|
|
307
|
+
const R = o[0];
|
|
308
|
+
f.sortBy = R.field, f.sortByType = R.sort;
|
|
309
|
+
}
|
|
310
|
+
return f;
|
|
311
|
+
}
|
|
253
312
|
export {
|
|
254
|
-
|
|
313
|
+
ve as default
|
|
255
314
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const u=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const u=require("react/jsx-runtime"),T=require("../common/text-field/TextArea.cjs.js"),j=require("../common/rich/index.cjs.js"),F=require("antd"),R=require("../util/CrudUtil.cjs.js"),g=({onChange:r,label:i,required:s,rules:n,name:o,updatable:c=!0,formLayoutProps:l,maxLength:a,...e})=>{const m=F.Form.useFormInstance(),x=R.getRealName(o,"upsertFieldName");if(e.rich)return u.jsx(j.RichTextEditor,{name:x,label:i,required:s,rules:n,disabled:!c,help:e.fieldHelper,formLayoutProps:l});{const{placeholder:f,rows:h,cols:N,fieldClassName:q,fieldTooltip:C}=e;return u.jsx(T.default,{...l,maxLength:a,rules:n,placeholder:f,onChange:r?t=>{var d;return r((d=t==null?void 0:t.target)==null?void 0:d.value,m)}:void 0,tooltip:C,required:s,disabled:!c,name:o,label:i,className:q,rows:h,cols:N,help:e.fieldHelper})}};module.exports=g;
|
|
@@ -3,6 +3,7 @@ import { FormInstance } from 'antd/lib';
|
|
|
3
3
|
import { Copyable } from '../util/CopyUtilComponent';
|
|
4
4
|
interface InitialTextAreaProps<T> extends InitialCrudField<T> {
|
|
5
5
|
type: "textarea";
|
|
6
|
+
maxLength?: number;
|
|
6
7
|
onChange?: (value: string, form: FormInstance<T>) => void;
|
|
7
8
|
/**
|
|
8
9
|
* number of lines to show. If false will not show truncated
|
|
@@ -19,5 +20,5 @@ interface RichTextAreaProps<T> extends InitialTextAreaProps<T> {
|
|
|
19
20
|
rich?: true;
|
|
20
21
|
}
|
|
21
22
|
export type TextAreaBasedFieldProps<T> = TextAreaProps<T> & RichTextAreaProps<T> & Copyable<false>;
|
|
22
|
-
declare const CrudTextAreaComponent: <T>({ onChange, label, required, rules, name, updatable, formLayoutProps, ...props }: TextAreaBasedFieldProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
declare const CrudTextAreaComponent: <T>({ onChange, label, required, rules, name, updatable, formLayoutProps, maxLength, ...props }: TextAreaBasedFieldProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
23
24
|
export default CrudTextAreaComponent;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { RichTextEditor as
|
|
4
|
-
import { Form as
|
|
5
|
-
import
|
|
6
|
-
const
|
|
2
|
+
import T from "../common/text-field/TextArea.es.js";
|
|
3
|
+
import { RichTextEditor as F } from "../common/rich/index.es.js";
|
|
4
|
+
import { Form as g } from "antd";
|
|
5
|
+
import A from "../util/CrudUtil.es.js";
|
|
6
|
+
const I = ({
|
|
7
7
|
onChange: o,
|
|
8
8
|
label: r,
|
|
9
9
|
required: i,
|
|
@@ -11,14 +11,15 @@ const E = ({
|
|
|
11
11
|
name: l,
|
|
12
12
|
updatable: d = !0,
|
|
13
13
|
formLayoutProps: s,
|
|
14
|
+
maxLength: f,
|
|
14
15
|
...e
|
|
15
16
|
}) => {
|
|
16
|
-
const
|
|
17
|
+
const c = g.useFormInstance(), p = A.getRealName(l, "upsertFieldName");
|
|
17
18
|
if (e.rich)
|
|
18
19
|
return /* @__PURE__ */ a(
|
|
19
|
-
|
|
20
|
+
F,
|
|
20
21
|
{
|
|
21
|
-
name:
|
|
22
|
+
name: p,
|
|
22
23
|
label: r,
|
|
23
24
|
required: i,
|
|
24
25
|
rules: m,
|
|
@@ -28,30 +29,31 @@ const E = ({
|
|
|
28
29
|
}
|
|
29
30
|
);
|
|
30
31
|
{
|
|
31
|
-
const { placeholder:
|
|
32
|
+
const { placeholder: h, rows: u, cols: x, fieldClassName: C, fieldTooltip: N } = e;
|
|
32
33
|
return /* @__PURE__ */ a(
|
|
33
|
-
|
|
34
|
+
T,
|
|
34
35
|
{
|
|
35
36
|
...s,
|
|
37
|
+
maxLength: f,
|
|
36
38
|
rules: m,
|
|
37
|
-
placeholder:
|
|
39
|
+
placeholder: h,
|
|
38
40
|
onChange: o ? (t) => {
|
|
39
41
|
var n;
|
|
40
|
-
return o((n = t == null ? void 0 : t.target) == null ? void 0 : n.value,
|
|
42
|
+
return o((n = t == null ? void 0 : t.target) == null ? void 0 : n.value, c);
|
|
41
43
|
} : void 0,
|
|
42
|
-
tooltip:
|
|
44
|
+
tooltip: N,
|
|
43
45
|
required: i,
|
|
44
46
|
disabled: !d,
|
|
45
47
|
name: l,
|
|
46
48
|
label: r,
|
|
47
|
-
className:
|
|
48
|
-
rows:
|
|
49
|
-
cols:
|
|
49
|
+
className: C,
|
|
50
|
+
rows: u,
|
|
51
|
+
cols: x,
|
|
50
52
|
help: e.fieldHelper
|
|
51
53
|
}
|
|
52
54
|
);
|
|
53
55
|
}
|
|
54
56
|
};
|
|
55
57
|
export {
|
|
56
|
-
|
|
58
|
+
I as default
|
|
57
59
|
};
|
package/dist/crud/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { CrudForm, CrudFormFields } from './CrudForm';
|
|
|
5
5
|
export type { CurdFormFieldsProps } from './CrudForm';
|
|
6
6
|
export { default as CrudFormWizard } from './CrudFormWizard';
|
|
7
7
|
export type { CrudFormWizardProps } from './CrudFormWizard';
|
|
8
|
-
export type { CrudReportComponentProps, CrudReportSubmitForm, ReportCrudFields, SearchOnlyFields, } from './CrudReportComponent';
|
|
8
|
+
export type { CrudReportComponentProps, CrudReportSubmitForm, ReportCrudFields, SearchOnlyFields, SearchPropsCacheProps, } from './CrudReportComponent';
|
|
9
9
|
export { default as CrudReportComponent } from './CrudReportComponent';
|
|
10
10
|
export { default as CrudSearchComponent } from './CrudSearchComponent';
|
|
11
11
|
export type { CrudSearchComponentProps, CrudSearchOption, } from './CrudSearchComponent';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),n=require("../context/CrudNavigateContext.cjs.js"),r=(e,t)=>{typeof process<"u"&&process.env.NODE_ENV!=="production"&&console.warn("[@kingteza/crud-component] No navigator configured. Pass `navigate` to CrudComponentProvider, or render CrudReactRouterNavigateSync / CrudNextNavigateSync from the optional entry points. Attempted navigation:",e,t)};function a(){const e=n.useCrudNavigateFromContext();return o.useMemo(()=>e??r,[e])}exports.useNavigateOptional=a;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { CrudNavigateFn } from '../context/CrudNavigateContext';
|
|
2
|
+
/**
|
|
3
|
+
* Returns `navigate` from `CrudComponentProvider` (prop or optional sync modules).
|
|
4
|
+
* Falls back to a no-op that warns in development when nothing is configured.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useNavigateOptional(): CrudNavigateFn;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useMemo as e } from "react";
|
|
2
|
+
import { useCrudNavigateFromContext as n } from "../context/CrudNavigateContext.es.js";
|
|
3
|
+
const r = (o, t) => {
|
|
4
|
+
typeof process < "u" && process.env.NODE_ENV !== "production" && console.warn(
|
|
5
|
+
"[@kingteza/crud-component] No navigator configured. Pass `navigate` to CrudComponentProvider, or render CrudReactRouterNavigateSync / CrudNextNavigateSync from the optional entry points. Attempted navigation:",
|
|
6
|
+
o,
|
|
7
|
+
t
|
|
8
|
+
);
|
|
9
|
+
};
|
|
10
|
+
function u() {
|
|
11
|
+
const o = n();
|
|
12
|
+
return e(() => o ?? r, [o]);
|
|
6
13
|
}
|
|
7
14
|
export {
|
|
8
|
-
|
|
15
|
+
u as useNavigateOptional
|
|
9
16
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { TRANSLATION_NAMESPACE } from './locale/hooks/translation-constants';
|
|
2
2
|
export { setupI18n, updateTranslations } from './locale';
|
|
3
|
-
export { CrudComponentProvider, type CrudComponentProviderProps } from './context';
|
|
3
|
+
export { CrudComponentProvider, type CrudComponentProviderProps, type CrudNavigateFn, } from './context';
|
|
4
4
|
export * from './crud';
|
|
5
5
|
export type * from './crud';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),i=require("next/navigation"),c=require("../context/CrudNavigateContext.cjs.js");function f(e){return typeof e=="string"?e:"pathname"in e&&typeof e.pathname=="string"?e.pathname:"/"}function s(){const e=i.useRouter(),t=c.useCrudNavigateRegister();return u.useLayoutEffect(()=>(t((r,n)=>{if(typeof r=="number"){r<0?e.back():r>0&&typeof e.forward=="function"&&e.forward();return}const a=f(r);n!=null&&n.replace?e.replace(a):e.push(a)}),()=>t(void 0)),[t,e]),null}exports.CrudNextNavigateSync=s;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers Next.js App Router navigation with {@link CrudComponentProvider}.
|
|
3
|
+
* Use in a client component, inside `CrudComponentProvider`, instead of installing `react-router-dom`.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* import { CrudComponentProvider } from "@kingteza/crud-component";
|
|
8
|
+
* import { CrudNextNavigateSync } from "@kingteza/crud-component/next";
|
|
9
|
+
*
|
|
10
|
+
* export default function RootLayout({ children }) {
|
|
11
|
+
* return (
|
|
12
|
+
* <CrudComponentProvider navigatorType="nextjs">
|
|
13
|
+
* <CrudNextNavigateSync />
|
|
14
|
+
* {children}
|
|
15
|
+
* </CrudComponentProvider>
|
|
16
|
+
* );
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function CrudNextNavigateSync(): null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useLayoutEffect as f } from "react";
|
|
2
|
+
import { useRouter as u } from "next/navigation";
|
|
3
|
+
import { useCrudNavigateRegister as i } from "../context/CrudNavigateContext.es.js";
|
|
4
|
+
function c(e) {
|
|
5
|
+
return typeof e == "string" ? e : "pathname" in e && typeof e.pathname == "string" ? e.pathname : "/";
|
|
6
|
+
}
|
|
7
|
+
function g() {
|
|
8
|
+
const e = u(), t = i();
|
|
9
|
+
return f(() => (t((r, n) => {
|
|
10
|
+
if (typeof r == "number") {
|
|
11
|
+
r < 0 ? e.back() : r > 0 && typeof e.forward == "function" && e.forward();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const a = c(r);
|
|
15
|
+
n != null && n.replace ? e.replace(a) : e.push(a);
|
|
16
|
+
}), () => t(void 0)), [t, e]), null;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
g as CrudNextNavigateSync
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),u=require("react-router-dom"),a=require("../context/CrudNavigateContext.cjs.js");function o(){const t=u.useNavigate(),e=a.useCrudNavigateRegister();return r.useLayoutEffect(()=>(e(t),()=>e(void 0)),[t,e]),null}exports.CrudReactRouterNavigateSync=o;
|