@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.
Files changed (38) hide show
  1. package/dist/common/rich/index.cjs.js +2 -2
  2. package/dist/common/rich/index.d.ts +1 -1
  3. package/dist/common/rich/index.es.js +119 -75
  4. package/dist/context/CrudComponentProvider.cjs.js +1 -1
  5. package/dist/context/CrudComponentProvider.d.ts +14 -0
  6. package/dist/context/CrudComponentProvider.es.js +22 -14
  7. package/dist/context/CrudNavigateContext.cjs.js +1 -0
  8. package/dist/context/CrudNavigateContext.d.ts +14 -0
  9. package/dist/context/CrudNavigateContext.es.js +29 -0
  10. package/dist/context/index.d.ts +1 -0
  11. package/dist/crud/CrudComponent.d.ts +1 -0
  12. package/dist/crud/CrudField.cjs.js +1 -1
  13. package/dist/crud/CrudField.es.js +92 -91
  14. package/dist/crud/CrudReportComponent.cjs.js +1 -1
  15. package/dist/crud/CrudReportComponent.d.ts +10 -1
  16. package/dist/crud/CrudReportComponent.es.js +193 -134
  17. package/dist/crud/CrudTextAreaComponent.cjs.js +1 -1
  18. package/dist/crud/CrudTextAreaComponent.d.ts +2 -1
  19. package/dist/crud/CrudTextAreaComponent.es.js +19 -17
  20. package/dist/crud/index.d.ts +1 -1
  21. package/dist/hooks/NavigatorHooks.cjs.js +1 -1
  22. package/dist/hooks/NavigatorHooks.d.ts +6 -1
  23. package/dist/hooks/NavigatorHooks.es.js +13 -6
  24. package/dist/index.d.ts +1 -1
  25. package/dist/navigator/CrudNextNavigateSync.cjs.js +1 -0
  26. package/dist/navigator/CrudNextNavigateSync.d.ts +20 -0
  27. package/dist/navigator/CrudNextNavigateSync.es.js +20 -0
  28. package/dist/navigator/CrudReactRouterNavigateSync.cjs.js +1 -0
  29. package/dist/navigator/CrudReactRouterNavigateSync.d.ts +18 -0
  30. package/dist/navigator/CrudReactRouterNavigateSync.es.js +10 -0
  31. package/dist/next.cjs.js +1 -0
  32. package/dist/next.d.ts +1 -0
  33. package/dist/next.es.js +4 -0
  34. package/dist/react-router.cjs.js +1 -0
  35. package/dist/react-router.d.ts +1 -0
  36. package/dist/react-router.es.js +4 -0
  37. package/dist/style.css +4 -3
  38. package/package.json +20 -3
@@ -1,112 +1,141 @@
1
- import { jsxs as c, jsx as t, Fragment as k } from "react/jsx-runtime";
2
- import { FileExcelOutlined as E } from "@ant-design/icons";
3
- import { Form as B, Space as G, Row as M, Col as b, Radio as R } from "antd";
4
- import { useMemo as P, useState as F, useCallback as ee, useEffect as w } from "react";
5
- import N from "./CrudField.es.js";
6
- import re from "./view/CrudViewer.es.js";
7
- import { SelectFieldInReport as te } from "../common/report/SelectFieldInReport.es.js";
8
- import { getRendererValueCrudViewer as O } from "./view/CrudViewerUtil.es.js";
9
- import { useTranslationLib as le } from "../locale/index.es.js";
10
- import oe from "../common/select/SelectComponent.es.js";
11
- import _ from "../common/button/Button.es.js";
12
- import { PrintButton as se } from "../common/button/PrintButton.es.js";
13
- const $ = { lg: 6, md: 8, sm: 12, xs: 24 }, ae = { lg: 12, md: 16, sm: 24, xs: 24 };
14
- function ge({
15
- fields: i,
16
- data: n,
17
- idField: z,
18
- loadingData: u,
19
- onSubmit: T,
20
- paginateProps: D,
21
- size: H,
22
- onClickPrint: h,
23
- onClickExcelExport: y,
24
- minusHeight: J,
25
- extraSearchFields: C,
26
- searchOnMount: I,
27
- summary: K,
28
- showFieldsSelectingMode: Q = "checkbox"
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: U } = le(), { searchable: W, selectable: d, sortable: v, defaultSort: p } = P(() => {
31
- var f, m, L, j, x;
32
- const e = [], r = [], o = [];
33
- let a;
34
- for (const l of i.filter((Z) => !Z.hidden))
35
- l.type === "image" || !l.report || ((f = l.report) != null && f.searchable && e.push(l), (m = l.report) != null && m.sortable && (r.push(l), !a && ((L = l.report) != null && L.defaultSort) && (a = l)), l.hideInTable || o.push({
36
- id: l.name,
37
- label: l.label,
38
- lock: (j = l.report) == null ? void 0 : j.lock,
39
- alreadySelected: (x = l.report) == null ? void 0 : x.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: a,
43
+ defaultSort: m,
43
44
  searchable: e,
44
- sortable: r,
45
- selectable: o
45
+ sortable: t,
46
+ selectable: l
46
47
  };
47
- }, [i]), [S, V] = F(
48
+ }, [s]), [N, L] = V(
48
49
  []
49
- ), g = ee(
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: r,
53
- showFields: o = [],
54
- ...a
60
+ sortByType: t,
61
+ showFields: l = [],
62
+ ...m
55
63
  }) => {
56
- const f = [];
57
- e && f.push({
64
+ var h;
65
+ const g = [];
66
+ e && g.push({
58
67
  field: e,
59
- sort: r ?? "DESC"
60
- }), V(
61
- i.filter((m) => o.includes(m.name)).map((m) => ({ ...m, hideInTable: !1 }))
62
- ), T({ showFields: o, sortBy: f, ...a });
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
- [i, T]
65
- ), [s] = B.useForm(), [q, X] = F(!1), [A, Y] = F(!0);
66
- return w(() => {
67
- if (I && A) {
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
- s.validateFields().then((r) => {
70
- g(r);
71
- }), Y(!1);
82
+ d.validateFields().then((t) => {
83
+ C(t);
84
+ }), ee(!1);
72
85
  }, 200);
73
86
  return () => clearTimeout(e);
74
87
  }
75
- }, [g, s, A, I]), w(() => {
76
- var r, o;
77
- !s.getFieldValue("sortBy") && p && s.setFieldsValue({
78
- sortBy: p.name,
79
- sortByType: typeof ((r = p.report) == null ? void 0 : r.defaultSort) == "string" ? (o = p.report) == null ? void 0 : o.defaultSort : "ASC"
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
- }, [p, s]), w(() => {
82
- if (q) {
83
- const e = d.filter((r) => r.alreadySelected).map((r) => r.id);
84
- V(
85
- i.filter((r) => e.includes(r.name)).map((r) => ({ ...r, hideInTable: !1 }))
86
- ), X(!1);
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
- }, [i, q, d]), /* @__PURE__ */ c(G, { className: "w-100", direction: "vertical", children: [
89
- /* @__PURE__ */ c(B, { form: s, layout: "vertical", onFinish: g, children: [
90
- /* @__PURE__ */ c(M, { gutter: [8, 8], children: [
91
- W.map((e) => {
92
- var r, o, a;
93
- return /* @__PURE__ */ t(
94
- b,
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: (r = e.report) != null && r.customRender ? e.report.customRender(s) : e.type === "date" ? /* @__PURE__ */ t(
99
- N,
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: (o = e.report) == null ? void 0 : o.range,
104
- required: !!((a = e.report) != null && a.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__ */ t(
109
- N,
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__ */ t(
119
- N,
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
- !!(d != null && d.length) && /* @__PURE__ */ t(b, { ...ae, children: /* @__PURE__ */ t(
132
- te,
160
+ !!(c != null && c.length) && /* @__PURE__ */ r(w, { ...me, children: /* @__PURE__ */ r(
161
+ ie,
133
162
  {
134
- items: d,
163
+ items: c,
135
164
  name: "showFields",
136
165
  mode: "multiple",
137
- label: U("str.showFields"),
166
+ label: Z("str.showFields"),
138
167
  className: "mb-0",
139
- selectingMode: Q
168
+ selectingMode: Y
140
169
  }
141
170
  ) }),
142
- !!v.length && /* @__PURE__ */ t(b, { ...$, children: /* @__PURE__ */ t(
143
- oe,
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: v.map((e) => ({ id: e.name, label: e.label })),
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__ */ c(k, { children: [
180
+ dropdownRender: (e) => /* @__PURE__ */ b(re, { children: [
152
181
  e,
153
- /* @__PURE__ */ t(B.Item, { name: "sortByType", noStyle: !0, className: "mt-3", children: /* @__PURE__ */ t(
154
- R.Group,
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__ */ c(M, { children: [
160
- /* @__PURE__ */ t(b, { xs: 12, children: /* @__PURE__ */ t(
161
- R,
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__ */ t(b, { xs: 12, children: /* @__PURE__ */ t(
173
- R,
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
- C ? C(s) : null
219
+ A ? A(d) : null
191
220
  ] }),
192
- /* @__PURE__ */ t(
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: u,
228
+ disabled: n,
200
229
  children: "Submit"
201
230
  }
202
231
  )
203
232
  ] }),
204
- /* @__PURE__ */ c(G, { children: [
205
- !!h && /* @__PURE__ */ t(
206
- se,
233
+ /* @__PURE__ */ b($, { children: [
234
+ !!S && /* @__PURE__ */ r(
235
+ ue,
207
236
  {
208
- disabled: u || !n.length,
209
- onClick: () => h == null ? void 0 : h({
237
+ disabled: n || !o.length,
238
+ onClick: () => S == null ? void 0 : S({
210
239
  tableId: "#crud-table table",
211
- data: n,
212
- fields: S.map((e) => ({
240
+ data: o,
241
+ fields: N.map((e) => ({
213
242
  ...e,
214
- render: O(e)
243
+ render: D(e)
215
244
  }))
216
245
  })
217
246
  }
218
247
  ),
219
- !!y && /* @__PURE__ */ t(
220
- _,
248
+ !!B && /* @__PURE__ */ r(
249
+ H,
221
250
  {
222
- disabled: u || !n.length,
223
- onClick: () => y == null ? void 0 : y({
251
+ disabled: n || !o.length,
252
+ onClick: () => B == null ? void 0 : B({
224
253
  tableId: "#crud-table table",
225
- data: n,
226
- fields: S.map((e) => ({
254
+ data: o,
255
+ fields: N.map((e) => ({
227
256
  ...e,
228
- render: O(e)
257
+ render: D(e)
229
258
  }))
230
259
  }),
231
- icon: /* @__PURE__ */ t(E, {}),
232
- className: `group ${u || !n.length ? "" : "crud-excel-export-btn"}`,
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
- K,
238
- /* @__PURE__ */ t(
239
- re,
266
+ X,
267
+ /* @__PURE__ */ r(
268
+ ne,
240
269
  {
241
- minusHeight: J,
242
- data: n,
243
- size: H,
244
- fields: S,
245
- idField: z,
246
- loadingData: u,
247
- paginateProps: D,
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
- ge as default
313
+ ve as default
255
314
  };
@@ -1 +1 @@
1
- "use strict";const u=require("react/jsx-runtime"),C=require("../common/text-field/TextArea.cjs.js"),T=require("../common/rich/index.cjs.js"),j=require("antd"),F=require("../util/CrudUtil.cjs.js"),R=({onChange:r,label:i,required:s,rules:n,name:o,updatable:c=!0,formLayoutProps:l,...e})=>{const a=j.Form.useFormInstance(),m=F.getRealName(o,"upsertFieldName");if(e.rich)return u.jsx(T.RichTextEditor,{name:m,label:i,required:s,rules:n,disabled:!c,help:e.fieldHelper,formLayoutProps:l});{const{placeholder:x,rows:f,cols:h,fieldClassName:N,fieldTooltip:q}=e;return u.jsx(C.default,{...l,rules:n,placeholder:x,onChange:r?t=>{var d;return r((d=t==null?void 0:t.target)==null?void 0:d.value,a)}:void 0,tooltip:q,required:s,disabled:!c,name:o,label:i,className:N,rows:f,cols:h,help:e.fieldHelper})}};module.exports=R;
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 N from "../common/text-field/TextArea.es.js";
3
- import { RichTextEditor as T } from "../common/rich/index.es.js";
4
- import { Form as F } from "antd";
5
- import g from "../util/CrudUtil.es.js";
6
- const E = ({
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 f = F.useFormInstance(), c = g.getRealName(l, "upsertFieldName");
17
+ const c = g.useFormInstance(), p = A.getRealName(l, "upsertFieldName");
17
18
  if (e.rich)
18
19
  return /* @__PURE__ */ a(
19
- T,
20
+ F,
20
21
  {
21
- name: c,
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: p, rows: h, cols: u, fieldClassName: x, fieldTooltip: C } = e;
32
+ const { placeholder: h, rows: u, cols: x, fieldClassName: C, fieldTooltip: N } = e;
32
33
  return /* @__PURE__ */ a(
33
- N,
34
+ T,
34
35
  {
35
36
  ...s,
37
+ maxLength: f,
36
38
  rules: m,
37
- placeholder: p,
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, f);
42
+ return o((n = t == null ? void 0 : t.target) == null ? void 0 : n.value, c);
41
43
  } : void 0,
42
- tooltip: C,
44
+ tooltip: N,
43
45
  required: i,
44
46
  disabled: !d,
45
47
  name: l,
46
48
  label: r,
47
- className: x,
48
- rows: h,
49
- cols: u,
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
- E as default
58
+ I as default
57
59
  };
@@ -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 e=require("react-router-dom");function o(){return e.useInRouterContext()?e.useNavigate():(t=>{console.warn("React router not found, navigating to",t)})}exports.useNavigateOptional=o;
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
- export declare function useNavigateOptional(): import('react-router-dom').NavigateFunction;
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 { useInRouterContext as e, useNavigate as n } from "react-router-dom";
2
- function r() {
3
- return e() ? n() : ((t) => {
4
- console.warn("React router not found, navigating to", t);
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
- r as useNavigateOptional
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;