@kingteza/crud-component 1.2.0 → 1.2.2
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/Play.d.ts +2 -0
- package/dist/README.md +89 -0
- package/dist/common/appearance/Hider.cjs.js +1 -0
- package/dist/common/appearance/Hider.d.ts +6 -0
- package/dist/common/appearance/Hider.es.js +5 -0
- package/dist/common/appearance/index.d.ts +1 -0
- package/dist/common/button/Button.cjs.js +1 -0
- package/dist/common/button/Button.d.ts +11 -0
- package/dist/common/button/Button.es.js +57 -0
- package/dist/common/button/CloneButtonTable.cjs.js +1 -0
- package/dist/common/button/CloneButtonTable.d.ts +6 -0
- package/dist/common/button/CloneButtonTable.es.js +19 -0
- package/dist/common/button/DeleteButtonTable.cjs.js +1 -0
- package/dist/common/button/DeleteButtonTable.d.ts +13 -0
- package/dist/common/button/DeleteButtonTable.es.js +64 -0
- package/dist/common/button/ExportButton.cjs.js +1 -0
- package/dist/common/button/ExportButton.d.ts +4 -0
- package/dist/common/button/ExportButton.es.js +26 -0
- package/dist/common/button/HideButtonTable.cjs.js +1 -0
- package/dist/common/button/HideButtonTable.d.ts +13 -0
- package/dist/common/button/HideButtonTable.es.js +67 -0
- package/dist/common/button/ImportButton.cjs.js +1 -0
- package/dist/common/button/ImportButton.d.ts +9 -0
- package/dist/common/button/ImportButton.es.js +55 -0
- package/dist/common/button/NewButton.cjs.js +1 -0
- package/dist/common/button/NewButton.d.ts +12 -0
- package/dist/common/button/NewButton.es.js +23 -0
- package/dist/common/button/PrintButton.cjs.js +1 -0
- package/dist/common/button/PrintButton.d.ts +12 -0
- package/dist/common/button/PrintButton.es.js +25 -0
- package/dist/common/button/RefreshButton.cjs.js +1 -0
- package/dist/common/button/RefreshButton.d.ts +11 -0
- package/dist/common/button/RefreshButton.es.js +23 -0
- package/dist/common/button/UnHideButton.cjs.js +1 -0
- package/dist/common/button/UnHideButton.d.ts +14 -0
- package/dist/common/button/UnHideButton.es.js +69 -0
- package/dist/common/button/UpdateButtonTable.cjs.js +1 -0
- package/dist/common/button/UpdateButtonTable.d.ts +6 -0
- package/dist/common/button/UpdateButtonTable.es.js +19 -0
- package/dist/common/button/ViewButtonTable.cjs.js +1 -0
- package/dist/common/button/ViewButtonTable.d.ts +6 -0
- package/dist/common/button/ViewButtonTable.es.js +19 -0
- package/dist/common/button/index.d.ts +14 -0
- package/dist/common/check-box/CheckBox.cjs.js +1 -0
- package/dist/common/check-box/CheckBox.d.ts +9 -0
- package/dist/common/check-box/CheckBox.es.js +40 -0
- package/dist/common/check-box/index.d.ts +2 -0
- package/dist/common/date-picker/DatePicker.cjs.js +1 -0
- package/dist/common/date-picker/DatePicker.d.ts +37 -0
- package/dist/common/date-picker/DatePicker.es.js +87 -0
- package/dist/common/date-picker/TimePicker.cjs.js +1 -0
- package/dist/common/date-picker/TimePicker.d.ts +34 -0
- package/dist/common/date-picker/TimePicker.es.js +77 -0
- package/dist/common/date-picker/index.d.ts +3 -0
- package/dist/common/description/DescList.cjs.js +1 -0
- package/dist/common/description/DescList.d.ts +18 -0
- package/dist/common/description/DescList.es.js +16 -0
- package/dist/common/description/DescriptionComponent.d.ts +7 -0
- package/dist/common/description/index.d.ts +3 -0
- package/dist/common/icon/KIcon.cjs.js +1 -0
- package/dist/common/icon/KIcon.d.ts +9 -0
- package/dist/common/icon/KIcon.es.js +11 -0
- package/dist/common/index.cjs.js +1 -0
- package/dist/common/index.d.ts +20 -0
- package/dist/common/index.es.js +78 -0
- package/dist/common/layout/VerticalSpace.cjs.js +1 -0
- package/dist/common/layout/VerticalSpace.d.ts +5 -0
- package/dist/common/layout/VerticalSpace.es.js +6 -0
- package/dist/common/layout/index.d.ts +2 -0
- package/dist/common/loading/LoadingIndicator.cjs.js +1 -0
- package/dist/common/loading/LoadingIndicator.d.ts +6 -0
- package/dist/common/loading/LoadingIndicator.es.js +23 -0
- package/dist/common/loading/index.d.ts +2 -0
- package/dist/common/picker/ImagePicker.cjs.js +1 -0
- package/dist/common/picker/ImagePicker.d.ts +56 -0
- package/dist/common/picker/ImagePicker.es.js +320 -0
- package/dist/common/picker/index.d.ts +2 -0
- package/dist/common/radio/RadioGroupComponent.cjs.js +1 -0
- package/dist/common/radio/RadioGroupComponent.d.ts +18 -0
- package/dist/common/radio/RadioGroupComponent.es.js +19 -0
- package/dist/common/radio/index.d.ts +2 -0
- package/dist/common/report/SelectFieldInReport.cjs.js +1 -0
- package/dist/common/report/SelectFieldInReport.d.ts +16 -0
- package/dist/common/report/SelectFieldInReport.es.js +30 -0
- package/dist/common/report/index.d.ts +3 -0
- package/dist/common/rich/index.cjs.js +1 -0
- package/dist/common/rich/index.d.ts +10 -0
- package/dist/common/rich/index.es.js +66 -0
- package/dist/common/select/CustomSelectOption.cjs.js +1 -0
- package/dist/common/select/CustomSelectOption.d.ts +7 -0
- package/dist/common/select/CustomSelectOption.es.js +13 -0
- package/dist/common/select/SelectComponent.cjs.js +1 -0
- package/dist/common/select/SelectComponent.d.ts +21 -0
- package/dist/common/select/SelectComponent.es.js +85 -0
- package/dist/common/select/index.d.ts +3 -0
- package/dist/common/show-more/index.cjs.js +1 -0
- package/dist/common/show-more/index.d.ts +4 -0
- package/dist/common/show-more/index.es.js +8 -0
- package/dist/common/tab/TabViewWithRoute.cjs.js +1 -0
- package/dist/common/tab/TabViewWithRoute.d.ts +13 -0
- package/dist/common/tab/TabViewWithRoute.es.js +38 -0
- package/dist/common/tab/index.d.ts +2 -0
- package/dist/common/table/index.d.ts +3 -0
- package/dist/common/table/table.cjs.js +1 -0
- package/dist/common/table/table.d.ts +19 -0
- package/dist/common/table/table.es.js +40 -0
- package/dist/common/tag/StatusTag.cjs.js +1 -0
- package/dist/common/tag/StatusTag.d.ts +14 -0
- package/dist/common/tag/StatusTag.es.js +29 -0
- package/dist/common/tag/index.d.ts +2 -0
- package/dist/common/text/index.cjs.js +1 -0
- package/dist/common/text/index.d.ts +3 -0
- package/dist/common/text/index.es.js +5 -0
- package/dist/common/text/title/TitleWithHeadTitle.d.ts +7 -0
- package/dist/common/text/title/index.cjs.js +1 -0
- package/dist/common/text/title/index.d.ts +1 -0
- package/dist/common/text/title/index.es.js +5 -0
- package/dist/common/text-field/NumberField.cjs.js +1 -0
- package/dist/common/text-field/NumberField.d.ts +13 -0
- package/dist/common/text-field/NumberField.es.js +83 -0
- package/dist/common/text-field/PhoneNumberField.cjs.js +1 -0
- package/dist/common/text-field/PhoneNumberField.d.ts +4 -0
- package/dist/common/text-field/PhoneNumberField.es.js +18 -0
- package/dist/common/text-field/TextArea.cjs.js +1 -0
- package/dist/common/text-field/TextArea.d.ts +17 -0
- package/dist/common/text-field/TextArea.es.js +46 -0
- package/dist/common/text-field/TextField.cjs.js +1 -0
- package/dist/common/text-field/TextField.d.ts +27 -0
- package/dist/common/text-field/TextField.es.js +72 -0
- package/dist/common/text-field/index.d.ts +5 -0
- package/dist/common/tooltip/TooltipComponent.cjs.js +1 -0
- package/dist/common/tooltip/TooltipComponent.d.ts +5 -0
- package/dist/common/tooltip/TooltipComponent.es.js +9 -0
- package/dist/common/tooltip/index.d.ts +2 -0
- package/dist/common/wizard/WizardResult.cjs.js +1 -0
- package/dist/common/wizard/WizardResult.d.ts +16 -0
- package/dist/common/wizard/WizardResult.es.js +58 -0
- package/dist/common/wizard/WizardViewForm.cjs.js +1 -0
- package/dist/common/wizard/WizardViewForm.d.ts +24 -0
- package/dist/common/wizard/WizardViewForm.es.js +74 -0
- package/dist/common/wizard/index.d.ts +3 -0
- package/dist/context/WindowDimension.cjs.js +1 -0
- package/dist/context/WindowDimension.d.ts +4 -0
- package/dist/context/WindowDimension.es.js +8 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/crud/CrudComponent.cjs.js +1 -0
- package/dist/crud/CrudComponent.d.ts +245 -0
- package/dist/crud/CrudComponent.es.js +123 -0
- package/dist/crud/CrudField.cjs.js +1 -0
- package/dist/crud/CrudField.d.ts +4 -0
- package/dist/crud/CrudField.es.js +461 -0
- package/dist/crud/CrudForm.cjs.js +1 -0
- package/dist/crud/CrudForm.d.ts +14 -0
- package/dist/crud/CrudForm.es.js +103 -0
- package/dist/crud/CrudFormWizard.cjs.js +1 -0
- package/dist/crud/CrudFormWizard.d.ts +14 -0
- package/dist/crud/CrudFormWizard.es.js +140 -0
- package/dist/crud/CrudReportComponent.cjs.js +4 -0
- package/dist/crud/CrudReportComponent.d.ts +44 -0
- package/dist/crud/CrudReportComponent.es.js +255 -0
- package/dist/crud/CrudSearchComponent.cjs.js +1 -0
- package/dist/crud/CrudSearchComponent.d.ts +21 -0
- package/dist/crud/CrudSearchComponent.es.js +96 -0
- package/dist/crud/CrudTextAreaComponent.cjs.js +1 -0
- package/dist/crud/CrudTextAreaComponent.d.ts +22 -0
- package/dist/crud/CrudTextAreaComponent.es.js +52 -0
- package/dist/crud/FileCrudField.cjs.js +1 -0
- package/dist/crud/FileCrudField.d.ts +25 -0
- package/dist/crud/FileCrudField.es.js +221 -0
- package/dist/crud/ImageCrudField.cjs.js +1 -0
- package/dist/crud/ImageCrudField.d.ts +38 -0
- package/dist/crud/ImageCrudField.es.js +115 -0
- package/dist/crud/actions/index.cjs.js +1 -0
- package/dist/crud/actions/index.d.ts +26 -0
- package/dist/crud/actions/index.es.js +88 -0
- package/dist/crud/import/CrudImportButton.cjs.js +1 -0
- package/dist/crud/import/CrudImportButton.d.ts +3 -0
- package/dist/crud/import/CrudImportButton.es.js +30 -0
- package/dist/crud/import/CrudImportComponent.cjs.js +2 -0
- package/dist/crud/import/CrudImportComponent.d.ts +14 -0
- package/dist/crud/import/CrudImportComponent.es.js +222 -0
- package/dist/crud/index.d.ts +23 -0
- package/dist/crud/modal/index.cjs.js +1 -0
- package/dist/crud/modal/index.d.ts +24 -0
- package/dist/crud/modal/index.es.js +146 -0
- package/dist/crud/view/CrudDecListView.cjs.js +1 -0
- package/dist/crud/view/CrudDecListView.d.ts +15 -0
- package/dist/crud/view/CrudDecListView.es.js +57 -0
- package/dist/crud/view/CrudViewer.cjs.js +1 -0
- package/dist/crud/view/CrudViewer.d.ts +43 -0
- package/dist/crud/view/CrudViewer.es.js +304 -0
- package/dist/crud/view/CrudViewerUtil.cjs.js +1 -0
- package/dist/crud/view/CrudViewerUtil.d.ts +2 -0
- package/dist/crud/view/CrudViewerUtil.es.js +98 -0
- package/dist/crud/view/index.d.ts +5 -0
- package/dist/crud-component.css +6 -0
- package/dist/hooks/NavigatorHooks.cjs.js +1 -0
- package/dist/hooks/NavigatorHooks.d.ts +1 -0
- package/dist/hooks/NavigatorHooks.es.js +9 -0
- package/dist/icons/FlipHIcon.cjs.js +1 -0
- package/dist/icons/FlipHIcon.d.ts +3 -0
- package/dist/icons/FlipHIcon.es.js +28 -0
- package/dist/icons/FlipVIcon.cjs.js +1 -0
- package/dist/icons/FlipVIcon.d.ts +3 -0
- package/dist/icons/FlipVIcon.es.js +28 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +46 -0
- package/dist/locale/hooks/translation-constants.cjs.js +1 -0
- package/dist/locale/hooks/translation-constants.d.ts +1 -0
- package/dist/locale/hooks/translation-constants.es.js +4 -0
- package/dist/locale/index.cjs.js +1 -0
- package/dist/locale/index.d.ts +85 -0
- package/dist/locale/index.es.js +57 -0
- package/dist/locale/translations/en.cjs.js +1 -0
- package/dist/locale/translations/en.d.ts +63 -0
- package/dist/locale/translations/en.es.js +65 -0
- package/dist/package.json +122 -0
- package/dist/types/DialogComponentProp.d.ts +8 -0
- package/dist/types/Id.d.ts +10 -0
- package/dist/util/CrudUtil.cjs.js +1 -0
- package/dist/util/CrudUtil.d.ts +5 -0
- package/dist/util/CrudUtil.es.js +8 -0
- package/dist/util/DateUtil.cjs.js +1 -0
- package/dist/util/DateUtil.d.ts +7 -0
- package/dist/util/DateUtil.es.js +18 -0
- package/dist/util/ImageUtil.cjs.js +1 -0
- package/dist/util/ImageUtil.d.ts +14 -0
- package/dist/util/ImageUtil.es.js +63 -0
- package/dist/util/NumberUtil.cjs.js +1 -0
- package/dist/util/NumberUtil.d.ts +17 -0
- package/dist/util/NumberUtil.es.js +60 -0
- package/dist/util/ValidationUtil.cjs.js +1 -0
- package/dist/util/ValidationUtil.d.ts +14 -0
- package/dist/util/ValidationUtil.es.js +63 -0
- package/dist/util/index.cjs.js +1 -0
- package/dist/util/index.d.ts +4 -0
- package/dist/util/index.es.js +10 -0
- package/dist/vite-env.d.ts +1 -0
- package/package.json +5 -12
- package/release.config.cjs +0 -27
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx as a, Fragment as y, jsxs as v } from "react/jsx-runtime";
|
|
2
|
+
import S, { useMemo as N, createElement as p, useCallback as j } from "react";
|
|
3
|
+
import { Form as k, Col as w, Input as A, Row as H } from "antd";
|
|
4
|
+
import l from "./CrudField.es.js";
|
|
5
|
+
import C from "../util/CrudUtil.es.js";
|
|
6
|
+
function z({
|
|
7
|
+
form: d,
|
|
8
|
+
purpose: g = "new",
|
|
9
|
+
...c
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ a(k, { form: d, layout: "vertical", children: /* @__PURE__ */ a(I, { ...c, purpose: g }) });
|
|
12
|
+
}
|
|
13
|
+
function I({
|
|
14
|
+
fields: d,
|
|
15
|
+
formBuilder: g,
|
|
16
|
+
grid: c,
|
|
17
|
+
onDeleteFile: m,
|
|
18
|
+
onUploadFile: e,
|
|
19
|
+
purpose: u
|
|
20
|
+
}) {
|
|
21
|
+
const h = N(
|
|
22
|
+
() => d.filter((r) => !r.readonly).map((r) => {
|
|
23
|
+
const i = {
|
|
24
|
+
onUploading: r.type === "image" || r.type === "file" ? (t) => {
|
|
25
|
+
var n;
|
|
26
|
+
r.onUploading && ((n = r.onUploading) == null || n.call(r, t)), e == null || e(t);
|
|
27
|
+
} : void 0,
|
|
28
|
+
onDelete: r.type === "image" || r.type === "file" ? (t) => {
|
|
29
|
+
var n;
|
|
30
|
+
r.onUploading && ((n = r.onDelete) == null || n.call(r, t)), m == null || m(t);
|
|
31
|
+
} : void 0
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ a(S.Fragment, { children: r.grid && c ? /* @__PURE__ */ a(w, { ...r.grid, children: /* @__PURE__ */ p(
|
|
34
|
+
l,
|
|
35
|
+
{
|
|
36
|
+
...r,
|
|
37
|
+
...i,
|
|
38
|
+
key: typeof r.name == "string" ? r.name : String(r.name),
|
|
39
|
+
updatable: u !== "update" ? !0 : r.updatable
|
|
40
|
+
}
|
|
41
|
+
) }) : /* @__PURE__ */ p(
|
|
42
|
+
l,
|
|
43
|
+
{
|
|
44
|
+
...r,
|
|
45
|
+
...i,
|
|
46
|
+
key: typeof r.name == "string" ? r.name : String(r.name),
|
|
47
|
+
updatable: u !== "update" ? !0 : r.updatable
|
|
48
|
+
}
|
|
49
|
+
) }, r.name);
|
|
50
|
+
}),
|
|
51
|
+
[d, c, m, e, u]
|
|
52
|
+
), R = j(
|
|
53
|
+
(r, i = {}) => {
|
|
54
|
+
const t = d.find((n) => C.getRealName(n.name) === r);
|
|
55
|
+
if (t != null && t.hidden) return /* @__PURE__ */ a(y, {});
|
|
56
|
+
if (t) {
|
|
57
|
+
const n = {
|
|
58
|
+
onUploading: t.type === "image" || t.type === "file" ? (o) => {
|
|
59
|
+
var f;
|
|
60
|
+
t.onUploading && ((f = t.onUploading) == null || f.call(t, o)), e == null || e(o);
|
|
61
|
+
} : void 0,
|
|
62
|
+
onDelete: t.type === "image" || t.type === "file" ? (o) => {
|
|
63
|
+
var f;
|
|
64
|
+
t.onUploading && ((f = t.onDelete) == null || f.call(t, o)), m == null || m(o);
|
|
65
|
+
} : void 0
|
|
66
|
+
}, s = C.getRealName(t.name), b = /* @__PURE__ */ p(
|
|
67
|
+
l,
|
|
68
|
+
{
|
|
69
|
+
...t,
|
|
70
|
+
...i,
|
|
71
|
+
...n,
|
|
72
|
+
key: typeof s == "string" ? s : String(s),
|
|
73
|
+
updatable: u !== "update" ? !0 : t.updatable
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
return i.render ? i.render(b) : b;
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ a(y, {});
|
|
79
|
+
},
|
|
80
|
+
[d, u]
|
|
81
|
+
);
|
|
82
|
+
return /* @__PURE__ */ a(y, { children: g ? /* @__PURE__ */ v(y, { children: [
|
|
83
|
+
g(R, {
|
|
84
|
+
isAnyFieldHidden(...r) {
|
|
85
|
+
const i = Array.isArray(r) ? r : [r];
|
|
86
|
+
return d.filter((n) => i.includes(n.name)).some((n) => n.hidden);
|
|
87
|
+
},
|
|
88
|
+
isAllFieldsHidden(...r) {
|
|
89
|
+
const i = Array.isArray(r) ? r : [r];
|
|
90
|
+
return d.filter((n) => i.includes(n.name)).every((n) => n.hidden);
|
|
91
|
+
},
|
|
92
|
+
purpose: u
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ v(k.Item, { hidden: !0, noStyle: !0, children: [
|
|
95
|
+
/* @__PURE__ */ a(A, { name: "id" }),
|
|
96
|
+
/* @__PURE__ */ a(A, {})
|
|
97
|
+
] })
|
|
98
|
+
] }) : c ? /* @__PURE__ */ a(H, { gutter: [8, 8], children: h }) : h });
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
z as CrudForm,
|
|
102
|
+
I as CrudFormFields
|
|
103
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),j=require("@ant-design/icons"),u=require("antd"),F=require("react"),y=require("../locale/index.cjs.js"),R=require("./CrudForm.cjs.js"),S=require("../common/wizard/WizardViewForm.cjs.js"),b=require("../util/CrudUtil.cjs.js"),C=require("../common/button/Button.cjs.js");function v({fields:d,className:m,onDeleteFile:h,onUploadFile:i,purpose:l,wizard:r=[],updatingValue:f,onSave:x,submitting:g}){const c=F.useMemo(()=>r.map(n=>{let t=!0;const o=d.filter(s=>n.fields.includes(b.getRealName(s.name)));return o.forEach(s=>t&&(t=s.hidden??!1)),{...n,hidden:t,fieldThatShouldShowing:o}}),[d,r]),a=F.useMemo(()=>c.filter(n=>!n.hidden),[c]);return e.jsx(S,{onSubmit:(n,t)=>{console.log(t),x(t)},className:m,pages:a.map(({title:n,icon:t,fieldThatShouldShowing:o,hidden:s},q)=>({title:n,icon:t,hidden:s,component:k=>e.jsx(N,{fields:o,onDeleteFile:h,onUploadFile:i,purpose:l,i:q,updatingValue:f,backward:k.backward,forward:k.forward,wizard:a,submitting:g},q)}))})}function N({fields:d,onDeleteFile:m,onUploadFile:h,purpose:i,wizard:l=[],i:r,forward:f,backward:x,submitting:g,updatingValue:c}){const a=l[r],{t:n}=y.useTranslationLib(),[t]=u.Form.useForm();return F.useEffect(()=>{if(c&&(i==="update"||i==="clone")){const o={};for(const s of d)o[b.getRealName(s.name,"upsertFieldName")]=c[b.getRealName(s.name,"upsertFieldName")];t.setFieldsValue(o)}},[d,t,i,c]),e.jsxs(u.Form,{name:String(r),form:t,layout:"vertical",children:[e.jsx(R.CrudFormFields,{fields:d,formBuilder:a.formBuilder,grid:a.grid,onDeleteFile:m,onUploadFile:h,purpose:i}),e.jsx(u.Divider,{}),e.jsxs(u.Row,{gutter:[8,8],children:[r>0&&e.jsx(u.Col,{md:12,children:e.jsx(C,{block:!0,icon:e.jsx(j.LeftOutlined,{}),htmlType:"button",type:"default",size:"large",onClick:()=>x(),children:n("str.back")})}),e.jsx(u.Col,{md:r>0?12:24,children:e.jsx(C,{block:!0,icon:l.length-1===r?e.jsx(j.SaveOutlined,{}):e.jsx(j.RightOutlined,{}),htmlType:"submit",type:"primary",loading:g,size:"large",onClick:()=>{t.validateFields().then(o=>{f(o,l.length-1===r,l.length-1===r)})},children:l.length-1===r?n("str."+(i==="update"?"update":"save")):n("str.next")})})]})]})}module.exports=v;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CrudFieldProps, CrudPurpose, CrudWizardProp } from './CrudComponent';
|
|
2
|
+
export interface CrudFormWizardProps<T> {
|
|
3
|
+
onDeleteFile?: (e: any) => void;
|
|
4
|
+
onUploadFile?: (e: any) => void;
|
|
5
|
+
fields: CrudFieldProps<T>[];
|
|
6
|
+
purpose?: CrudPurpose;
|
|
7
|
+
wizard?: CrudWizardProp<T>[];
|
|
8
|
+
className?: string;
|
|
9
|
+
onSave: (e: T) => void;
|
|
10
|
+
updatingValue?: T;
|
|
11
|
+
submitting?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare function CrudFormWizard<T>({ fields, className, onDeleteFile, onUploadFile, purpose, wizard, updatingValue, onSave, submitting, }: Readonly<CrudFormWizardProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default CrudFormWizard;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsx as o, jsxs as k } from "react/jsx-runtime";
|
|
2
|
+
import { LeftOutlined as N, SaveOutlined as R, RightOutlined as w } from "@ant-design/icons";
|
|
3
|
+
import { Form as y, Divider as x, Row as T, Col as C } from "antd";
|
|
4
|
+
import { useMemo as S, useEffect as W } from "react";
|
|
5
|
+
import { useTranslationLib as j } from "../locale/index.es.js";
|
|
6
|
+
import { CrudFormFields as z } from "./CrudForm.es.js";
|
|
7
|
+
import B from "../common/wizard/WizardViewForm.es.js";
|
|
8
|
+
import p from "../util/CrudUtil.es.js";
|
|
9
|
+
import v from "../common/button/Button.es.js";
|
|
10
|
+
function H({
|
|
11
|
+
fields: d,
|
|
12
|
+
className: u,
|
|
13
|
+
onDeleteFile: f,
|
|
14
|
+
onUploadFile: l,
|
|
15
|
+
purpose: m,
|
|
16
|
+
wizard: t = [],
|
|
17
|
+
updatingValue: s,
|
|
18
|
+
onSave: h,
|
|
19
|
+
submitting: g
|
|
20
|
+
}) {
|
|
21
|
+
const a = S(() => t.map((r) => {
|
|
22
|
+
let e = !0;
|
|
23
|
+
const n = d.filter(
|
|
24
|
+
(i) => r.fields.includes(p.getRealName(i.name))
|
|
25
|
+
);
|
|
26
|
+
return n.forEach((i) => e && (e = i.hidden ?? !1)), {
|
|
27
|
+
...r,
|
|
28
|
+
hidden: e,
|
|
29
|
+
fieldThatShouldShowing: n
|
|
30
|
+
};
|
|
31
|
+
}), [d, t]), c = S(
|
|
32
|
+
() => a.filter((r) => !r.hidden),
|
|
33
|
+
[a]
|
|
34
|
+
);
|
|
35
|
+
return /* @__PURE__ */ o(
|
|
36
|
+
B,
|
|
37
|
+
{
|
|
38
|
+
onSubmit: (r, e) => {
|
|
39
|
+
console.log(e), h(e);
|
|
40
|
+
},
|
|
41
|
+
className: u,
|
|
42
|
+
pages: c.map(
|
|
43
|
+
({ title: r, icon: e, fieldThatShouldShowing: n, hidden: i }, b) => ({
|
|
44
|
+
title: r,
|
|
45
|
+
icon: e,
|
|
46
|
+
hidden: i,
|
|
47
|
+
component: (F) => /* @__PURE__ */ o(
|
|
48
|
+
O,
|
|
49
|
+
{
|
|
50
|
+
fields: n,
|
|
51
|
+
onDeleteFile: f,
|
|
52
|
+
onUploadFile: l,
|
|
53
|
+
purpose: m,
|
|
54
|
+
i: b,
|
|
55
|
+
updatingValue: s,
|
|
56
|
+
backward: F.backward,
|
|
57
|
+
forward: F.forward,
|
|
58
|
+
wizard: c,
|
|
59
|
+
submitting: g
|
|
60
|
+
},
|
|
61
|
+
b
|
|
62
|
+
)
|
|
63
|
+
})
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function O({
|
|
69
|
+
fields: d,
|
|
70
|
+
onDeleteFile: u,
|
|
71
|
+
onUploadFile: f,
|
|
72
|
+
purpose: l,
|
|
73
|
+
wizard: m = [],
|
|
74
|
+
i: t,
|
|
75
|
+
forward: s,
|
|
76
|
+
backward: h,
|
|
77
|
+
submitting: g,
|
|
78
|
+
updatingValue: a
|
|
79
|
+
}) {
|
|
80
|
+
const c = m[t], { t: r } = j(), [e] = y.useForm();
|
|
81
|
+
return W(() => {
|
|
82
|
+
if (a && (l === "update" || l === "clone")) {
|
|
83
|
+
const n = {};
|
|
84
|
+
for (const i of d)
|
|
85
|
+
n[p.getRealName(i.name, "upsertFieldName")] = a[p.getRealName(i.name, "upsertFieldName")];
|
|
86
|
+
e.setFieldsValue(n);
|
|
87
|
+
}
|
|
88
|
+
}, [d, e, l, a]), /* @__PURE__ */ k(y, { name: String(t), form: e, layout: "vertical", children: [
|
|
89
|
+
/* @__PURE__ */ o(
|
|
90
|
+
z,
|
|
91
|
+
{
|
|
92
|
+
fields: d,
|
|
93
|
+
formBuilder: c.formBuilder,
|
|
94
|
+
grid: c.grid,
|
|
95
|
+
onDeleteFile: u,
|
|
96
|
+
onUploadFile: f,
|
|
97
|
+
purpose: l
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
/* @__PURE__ */ o(x, {}),
|
|
101
|
+
/* @__PURE__ */ k(T, { gutter: [8, 8], children: [
|
|
102
|
+
t > 0 && /* @__PURE__ */ o(C, { md: 12, children: /* @__PURE__ */ o(
|
|
103
|
+
v,
|
|
104
|
+
{
|
|
105
|
+
block: !0,
|
|
106
|
+
icon: /* @__PURE__ */ o(N, {}),
|
|
107
|
+
htmlType: "button",
|
|
108
|
+
type: "default",
|
|
109
|
+
size: "large",
|
|
110
|
+
onClick: () => h(),
|
|
111
|
+
children: r("str.back")
|
|
112
|
+
}
|
|
113
|
+
) }),
|
|
114
|
+
/* @__PURE__ */ o(C, { md: t > 0 ? 12 : 24, children: /* @__PURE__ */ o(
|
|
115
|
+
v,
|
|
116
|
+
{
|
|
117
|
+
block: !0,
|
|
118
|
+
icon: m.length - 1 === t ? /* @__PURE__ */ o(R, {}) : /* @__PURE__ */ o(w, {}),
|
|
119
|
+
htmlType: "submit",
|
|
120
|
+
type: "primary",
|
|
121
|
+
loading: g,
|
|
122
|
+
size: "large",
|
|
123
|
+
onClick: () => {
|
|
124
|
+
e.validateFields().then((n) => {
|
|
125
|
+
s(
|
|
126
|
+
n,
|
|
127
|
+
m.length - 1 === t,
|
|
128
|
+
m.length - 1 === t
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
children: m.length - 1 === t ? r("str." + (l === "update" ? "update" : "save")) : r("str.next")
|
|
133
|
+
}
|
|
134
|
+
) })
|
|
135
|
+
] })
|
|
136
|
+
] });
|
|
137
|
+
}
|
|
138
|
+
export {
|
|
139
|
+
H as default
|
|
140
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),J=require("@ant-design/icons"),s=require("antd"),d=require("react"),j=require("./CrudField.cjs.js"),K=require("./view/CrudViewer.cjs.js"),M=require("../common/report/SelectFieldInReport.cjs.js"),v=require("./view/CrudViewerUtil.cjs.js"),Q=require("../common/select/SelectComponent.cjs.js"),V=require("../common/button/Button.cjs.js"),W=require("../common/button/PrintButton.cjs.js"),A={lg:6,md:8,sm:12,xs:24},X={lg:12,md:16,sm:24,xs:24};function Y({fields:i,data:u,idField:L,loadingData:p,onSubmit:x,paginateProps:G,size:O,onClickPrint:h,onClickExcelExport:y,minusHeight:U,extraSearchFields:R,searchOnMount:B,summary:_}){const{searchable:$,selectable:c,sortable:w,defaultSort:m}=d.useMemo(()=>{var b,f,N,I,T;const e=[],t=[],o=[];let a;for(const l of i.filter(H=>!H.hidden))l.type==="image"||!l.report||((b=l.report)!=null&&b.searchable&&e.push(l),(f=l.report)!=null&&f.sortable&&(t.push(l),!a&&((N=l.report)!=null&&N.defaultSort)&&(a=l)),l.hideInTable||o.push({id:l.name,label:l.label,lock:(I=l.report)==null?void 0:I.lock,alreadySelected:(T=l.report)==null?void 0:T.alreadySelected}));return{defaultSort:a,searchable:e,sortable:t,selectable:o}},[i]),[S,F]=d.useState([]),g=d.useCallback(async({sortBy:e,sortByType:t,showFields:o=[],...a})=>{const b=[];e&&b.push({field:e,sort:t??"DESC"}),F(i.filter(f=>o.includes(f.name)).map(f=>({...f,hideInTable:!1}))),x({showFields:o,sortBy:b,...a})},[i,x]),[n]=s.Form.useForm(),[q,z]=d.useState(!1),[C,D]=d.useState(!0);return d.useEffect(()=>{if(B&&C){const e=setTimeout(()=>{n.validateFields().then(t=>{g(t)}),D(!1)},200);return()=>clearTimeout(e)}},[g,n,C,B]),d.useEffect(()=>{var t,o,a;!n.getFieldValue("sortBy")&&m&&(console.log((t=m.report)==null?void 0:t.defaultSort),n.setFieldsValue({sortBy:m.name,sortByType:typeof((o=m.report)==null?void 0:o.defaultSort)=="string"?(a=m.report)==null?void 0:a.defaultSort:"ASC"}))},[m,n]),d.useEffect(()=>{if(q){const e=c.filter(t=>t.alreadySelected).map(t=>t.id);F(i.filter(t=>e.includes(t.name)).map(t=>({...t,hideInTable:!1}))),z(!1)}},[i,q,c]),r.jsxs(s.Space,{className:"w-100",direction:"vertical",children:[r.jsxs(s.Form,{form:n,layout:"vertical",onFinish:g,children:[r.jsxs(s.Row,{gutter:[8,8],children:[$.map(e=>{var t,o,a;return r.jsx(s.Col,{...e.grid??A,style:{alignSelf:"end"},children:(t=e.report)!=null&&t.customRender?e.report.customRender(n):e.type==="date"?r.jsx(j.default,{...e,type:"date",range:(o=e.report)==null?void 0:o.range,required:!!((a=e.report)!=null&&a.required),readonly:!1,fieldClassName:"mb-0"}):e.type==="select"?r.jsx(j.default,{...e,type:"select",multiple:!0,required:!1,readonly:!1,fieldClassName:"mb-0"}):r.jsx(j.default,{...e,readonly:!1,required:!1,fieldClassName:"mb-0"})},e.name)}),!!(c!=null&&c.length)&&r.jsx(s.Col,{...X,children:r.jsx(M.SelectFieldInReport,{items:c,name:"showFields",mode:"multiple",label:"Show Fields",className:"mb-0"})}),!!w.length&&r.jsx(s.Col,{...A,children:r.jsx(Q,{label:"Sort By",name:"sortBy",items:w.map(e=>({id:e.name,label:e.label})),nameFieldInArray:"label",fieldId:"id",className:"mb-0",dropdownRender:e=>r.jsxs(r.Fragment,{children:[e,r.jsx(s.Form.Item,{name:"sortByType",noStyle:!0,className:"mt-3",children:r.jsx(s.Radio.Group,{className:"w-100",defaultValue:"DESC",optionType:"button",children:r.jsxs(s.Row,{children:[r.jsx(s.Col,{xs:12,children:r.jsx(s.Radio,{className:"w-100",style:{borderTopRightRadius:0,borderBottomRightRadius:0},value:"ASC",children:"Ascending"})}),r.jsx(s.Col,{xs:12,children:r.jsx(s.Radio,{className:"w-100",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0},value:"DESC",children:"Descending"})})]})})})]})})}),R?R(n):null]}),r.jsx(V,{className:"mt-3",type:"primary",block:!0,htmlType:"submit",disabled:p,children:"Submit"})]}),r.jsxs(s.Space,{children:[!!h&&r.jsx(W.PrintButton,{disabled:p||!u.length,onClick:()=>h==null?void 0:h({tableId:"#crud-table table",data:u,fields:S.map(e=>({...e,render:v.getRendererValueCrudViewer(e)}))})}),!!y&&r.jsx(V,{disabled:p||!u.length,onClick:()=>y==null?void 0:y({tableId:"#crud-table table",data:u,fields:S.map(e=>({...e,render:v.getRendererValueCrudViewer(e)}))}),icon:r.jsx(J.FileExcelOutlined,{}),className:`group
|
|
2
|
+
${p||!u.length?"":"!bg-green-700 hover:!bg-green-600 !text-white !border-green-700 hover:!border-green-600"}
|
|
3
|
+
|
|
4
|
+
`,children:"Excel"})]}),_,r.jsx(K,{minusHeight:U,data:u,size:O,fields:S,idField:L,loadingData:p,paginateProps:G,viewable:!1})]})}module.exports=Y;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
2
|
+
import { FormInstance } from 'antd/lib';
|
|
3
|
+
import { default as React, ReactElement } from 'react';
|
|
4
|
+
import { CrudFieldProps, CrudPaginateProps } from './CrudComponent';
|
|
5
|
+
export type CrudReportSubmitForm<T> = {
|
|
6
|
+
sortBy: {
|
|
7
|
+
field: keyof T;
|
|
8
|
+
sort: "ASC" | "DESC";
|
|
9
|
+
}[];
|
|
10
|
+
showFields: string[];
|
|
11
|
+
} & T;
|
|
12
|
+
export type SearchOnlyFields<F> = CrudFieldProps<F> & {
|
|
13
|
+
hideInTable: true;
|
|
14
|
+
};
|
|
15
|
+
export type ReportCrudFields<T, F> = CrudFieldProps<T> | SearchOnlyFields<F>;
|
|
16
|
+
export interface CrudReportComponentProps<T_Data, F_Search> {
|
|
17
|
+
summary?: React.ReactNode;
|
|
18
|
+
fields: ReportCrudFields<T_Data, F_Search>[];
|
|
19
|
+
onSubmit: (value: CrudReportSubmitForm<F_Search>) => void;
|
|
20
|
+
data: T_Data[];
|
|
21
|
+
idField?: string;
|
|
22
|
+
loadingData?: boolean;
|
|
23
|
+
size?: SizeType;
|
|
24
|
+
paginateProps?: CrudPaginateProps;
|
|
25
|
+
onClickPrint?: (props: {
|
|
26
|
+
fields: CrudFieldProps<T_Data>[] & {
|
|
27
|
+
render: (value: any, obj: T_Data, index: number) => any;
|
|
28
|
+
}[];
|
|
29
|
+
data: T_Data[];
|
|
30
|
+
tableId: string;
|
|
31
|
+
}) => void;
|
|
32
|
+
onClickExcelExport?: (props: {
|
|
33
|
+
fields: CrudFieldProps<T_Data>[] & {
|
|
34
|
+
render: (value: any, obj: T_Data, index: number) => any;
|
|
35
|
+
}[];
|
|
36
|
+
data: T_Data[];
|
|
37
|
+
tableId: string;
|
|
38
|
+
}) => void;
|
|
39
|
+
minusHeight?: string;
|
|
40
|
+
extraSearchFields?: (form: FormInstance<any>) => ReactElement;
|
|
41
|
+
searchOnMount?: boolean;
|
|
42
|
+
}
|
|
43
|
+
declare function CrudReportComponent<T, F = T>({ fields, data, idField, loadingData, onSubmit, paginateProps, size, onClickPrint, onClickExcelExport, minusHeight, extraSearchFields, searchOnMount, summary, }: Readonly<CrudReportComponentProps<T, F>>): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export default CrudReportComponent;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { jsxs as c, jsx as t, Fragment as Z } from "react/jsx-runtime";
|
|
2
|
+
import { FileExcelOutlined as x } from "@ant-design/icons";
|
|
3
|
+
import { Form as B, Space as O, Row as _, Col as b, Radio as R } from "antd";
|
|
4
|
+
import { useMemo as k, useState as w, useCallback as E, useEffect as F } from "react";
|
|
5
|
+
import N from "./CrudField.es.js";
|
|
6
|
+
import P from "./view/CrudViewer.es.js";
|
|
7
|
+
import { SelectFieldInReport as ee } from "../common/report/SelectFieldInReport.es.js";
|
|
8
|
+
import { getRendererValueCrudViewer as $ } from "./view/CrudViewerUtil.es.js";
|
|
9
|
+
import re from "../common/select/SelectComponent.es.js";
|
|
10
|
+
import z from "../common/button/Button.es.js";
|
|
11
|
+
import { PrintButton as te } from "../common/button/PrintButton.es.js";
|
|
12
|
+
const D = { lg: 6, md: 8, sm: 12, xs: 24 }, le = { lg: 12, md: 16, sm: 24, xs: 24 };
|
|
13
|
+
function be({
|
|
14
|
+
fields: n,
|
|
15
|
+
data: d,
|
|
16
|
+
idField: H,
|
|
17
|
+
loadingData: p,
|
|
18
|
+
onSubmit: T,
|
|
19
|
+
paginateProps: J,
|
|
20
|
+
size: K,
|
|
21
|
+
onClickPrint: h,
|
|
22
|
+
onClickExcelExport: y,
|
|
23
|
+
minusHeight: M,
|
|
24
|
+
extraSearchFields: v,
|
|
25
|
+
searchOnMount: C,
|
|
26
|
+
summary: Q
|
|
27
|
+
}) {
|
|
28
|
+
const { searchable: U, selectable: i, sortable: I, defaultSort: m } = k(() => {
|
|
29
|
+
var f, u, j, L, G;
|
|
30
|
+
const e = [], r = [], o = [];
|
|
31
|
+
let s;
|
|
32
|
+
for (const l of n.filter((Y) => !Y.hidden))
|
|
33
|
+
l.type === "image" || !l.report || ((f = l.report) != null && f.searchable && e.push(l), (u = l.report) != null && u.sortable && (r.push(l), !s && ((j = l.report) != null && j.defaultSort) && (s = l)), l.hideInTable || o.push({
|
|
34
|
+
id: l.name,
|
|
35
|
+
label: l.label,
|
|
36
|
+
lock: (L = l.report) == null ? void 0 : L.lock,
|
|
37
|
+
alreadySelected: (G = l.report) == null ? void 0 : G.alreadySelected
|
|
38
|
+
}));
|
|
39
|
+
return {
|
|
40
|
+
defaultSort: s,
|
|
41
|
+
searchable: e,
|
|
42
|
+
sortable: r,
|
|
43
|
+
selectable: o
|
|
44
|
+
};
|
|
45
|
+
}, [n]), [g, V] = w(
|
|
46
|
+
[]
|
|
47
|
+
), S = E(
|
|
48
|
+
async ({
|
|
49
|
+
sortBy: e,
|
|
50
|
+
sortByType: r,
|
|
51
|
+
showFields: o = [],
|
|
52
|
+
...s
|
|
53
|
+
}) => {
|
|
54
|
+
const f = [];
|
|
55
|
+
e && f.push({
|
|
56
|
+
field: e,
|
|
57
|
+
sort: r ?? "DESC"
|
|
58
|
+
}), V(
|
|
59
|
+
n.filter((u) => o.includes(u.name)).map((u) => ({ ...u, hideInTable: !1 }))
|
|
60
|
+
), T({ showFields: o, sortBy: f, ...s });
|
|
61
|
+
},
|
|
62
|
+
[n, T]
|
|
63
|
+
), [a] = B.useForm(), [q, W] = w(!1), [A, X] = w(!0);
|
|
64
|
+
return F(() => {
|
|
65
|
+
if (C && A) {
|
|
66
|
+
const e = setTimeout(() => {
|
|
67
|
+
a.validateFields().then((r) => {
|
|
68
|
+
S(r);
|
|
69
|
+
}), X(!1);
|
|
70
|
+
}, 200);
|
|
71
|
+
return () => clearTimeout(e);
|
|
72
|
+
}
|
|
73
|
+
}, [S, a, A, C]), F(() => {
|
|
74
|
+
var r, o, s;
|
|
75
|
+
!a.getFieldValue("sortBy") && m && (console.log((r = m.report) == null ? void 0 : r.defaultSort), a.setFieldsValue({
|
|
76
|
+
sortBy: m.name,
|
|
77
|
+
sortByType: typeof ((o = m.report) == null ? void 0 : o.defaultSort) == "string" ? (s = m.report) == null ? void 0 : s.defaultSort : "ASC"
|
|
78
|
+
}));
|
|
79
|
+
}, [m, a]), F(() => {
|
|
80
|
+
if (q) {
|
|
81
|
+
const e = i.filter((r) => r.alreadySelected).map((r) => r.id);
|
|
82
|
+
V(
|
|
83
|
+
n.filter((r) => e.includes(r.name)).map((r) => ({ ...r, hideInTable: !1 }))
|
|
84
|
+
), W(!1);
|
|
85
|
+
}
|
|
86
|
+
}, [n, q, i]), /* @__PURE__ */ c(O, { className: "w-100", direction: "vertical", children: [
|
|
87
|
+
/* @__PURE__ */ c(B, { form: a, layout: "vertical", onFinish: S, children: [
|
|
88
|
+
/* @__PURE__ */ c(_, { gutter: [8, 8], children: [
|
|
89
|
+
U.map((e) => {
|
|
90
|
+
var r, o, s;
|
|
91
|
+
return /* @__PURE__ */ t(
|
|
92
|
+
b,
|
|
93
|
+
{
|
|
94
|
+
...e.grid ?? D,
|
|
95
|
+
style: { alignSelf: "end" },
|
|
96
|
+
children: (r = e.report) != null && r.customRender ? e.report.customRender(a) : e.type === "date" ? /* @__PURE__ */ t(
|
|
97
|
+
N,
|
|
98
|
+
{
|
|
99
|
+
...e,
|
|
100
|
+
type: "date",
|
|
101
|
+
range: (o = e.report) == null ? void 0 : o.range,
|
|
102
|
+
required: !!((s = e.report) != null && s.required),
|
|
103
|
+
readonly: !1,
|
|
104
|
+
fieldClassName: "mb-0"
|
|
105
|
+
}
|
|
106
|
+
) : e.type === "select" ? /* @__PURE__ */ t(
|
|
107
|
+
N,
|
|
108
|
+
{
|
|
109
|
+
...e,
|
|
110
|
+
type: "select",
|
|
111
|
+
multiple: !0,
|
|
112
|
+
required: !1,
|
|
113
|
+
readonly: !1,
|
|
114
|
+
fieldClassName: "mb-0"
|
|
115
|
+
}
|
|
116
|
+
) : /* @__PURE__ */ t(
|
|
117
|
+
N,
|
|
118
|
+
{
|
|
119
|
+
...e,
|
|
120
|
+
readonly: !1,
|
|
121
|
+
required: !1,
|
|
122
|
+
fieldClassName: "mb-0"
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
},
|
|
126
|
+
e.name
|
|
127
|
+
);
|
|
128
|
+
}),
|
|
129
|
+
!!(i != null && i.length) && /* @__PURE__ */ t(b, { ...le, children: /* @__PURE__ */ t(
|
|
130
|
+
ee,
|
|
131
|
+
{
|
|
132
|
+
items: i,
|
|
133
|
+
name: "showFields",
|
|
134
|
+
mode: "multiple",
|
|
135
|
+
label: "Show Fields",
|
|
136
|
+
className: "mb-0"
|
|
137
|
+
}
|
|
138
|
+
) }),
|
|
139
|
+
!!I.length && /* @__PURE__ */ t(b, { ...D, children: /* @__PURE__ */ t(
|
|
140
|
+
re,
|
|
141
|
+
{
|
|
142
|
+
label: "Sort By",
|
|
143
|
+
name: "sortBy",
|
|
144
|
+
items: I.map((e) => ({ id: e.name, label: e.label })),
|
|
145
|
+
nameFieldInArray: "label",
|
|
146
|
+
fieldId: "id",
|
|
147
|
+
className: "mb-0",
|
|
148
|
+
dropdownRender: (e) => /* @__PURE__ */ c(Z, { children: [
|
|
149
|
+
e,
|
|
150
|
+
/* @__PURE__ */ t(B.Item, { name: "sortByType", noStyle: !0, className: "mt-3", children: /* @__PURE__ */ t(
|
|
151
|
+
R.Group,
|
|
152
|
+
{
|
|
153
|
+
className: "w-100",
|
|
154
|
+
defaultValue: "DESC",
|
|
155
|
+
optionType: "button",
|
|
156
|
+
children: /* @__PURE__ */ c(_, { children: [
|
|
157
|
+
/* @__PURE__ */ t(b, { xs: 12, children: /* @__PURE__ */ t(
|
|
158
|
+
R,
|
|
159
|
+
{
|
|
160
|
+
className: "w-100",
|
|
161
|
+
style: {
|
|
162
|
+
borderTopRightRadius: 0,
|
|
163
|
+
borderBottomRightRadius: 0
|
|
164
|
+
},
|
|
165
|
+
value: "ASC",
|
|
166
|
+
children: "Ascending"
|
|
167
|
+
}
|
|
168
|
+
) }),
|
|
169
|
+
/* @__PURE__ */ t(b, { xs: 12, children: /* @__PURE__ */ t(
|
|
170
|
+
R,
|
|
171
|
+
{
|
|
172
|
+
className: "w-100",
|
|
173
|
+
style: {
|
|
174
|
+
borderTopLeftRadius: 0,
|
|
175
|
+
borderBottomLeftRadius: 0
|
|
176
|
+
},
|
|
177
|
+
value: "DESC",
|
|
178
|
+
children: "Descending"
|
|
179
|
+
}
|
|
180
|
+
) })
|
|
181
|
+
] })
|
|
182
|
+
}
|
|
183
|
+
) })
|
|
184
|
+
] })
|
|
185
|
+
}
|
|
186
|
+
) }),
|
|
187
|
+
v ? v(a) : null
|
|
188
|
+
] }),
|
|
189
|
+
/* @__PURE__ */ t(
|
|
190
|
+
z,
|
|
191
|
+
{
|
|
192
|
+
className: "mt-3",
|
|
193
|
+
type: "primary",
|
|
194
|
+
block: !0,
|
|
195
|
+
htmlType: "submit",
|
|
196
|
+
disabled: p,
|
|
197
|
+
children: "Submit"
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] }),
|
|
201
|
+
/* @__PURE__ */ c(O, { children: [
|
|
202
|
+
!!h && /* @__PURE__ */ t(
|
|
203
|
+
te,
|
|
204
|
+
{
|
|
205
|
+
disabled: p || !d.length,
|
|
206
|
+
onClick: () => h == null ? void 0 : h({
|
|
207
|
+
tableId: "#crud-table table",
|
|
208
|
+
data: d,
|
|
209
|
+
fields: g.map((e) => ({
|
|
210
|
+
...e,
|
|
211
|
+
render: $(e)
|
|
212
|
+
}))
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
),
|
|
216
|
+
!!y && /* @__PURE__ */ t(
|
|
217
|
+
z,
|
|
218
|
+
{
|
|
219
|
+
disabled: p || !d.length,
|
|
220
|
+
onClick: () => y == null ? void 0 : y({
|
|
221
|
+
tableId: "#crud-table table",
|
|
222
|
+
data: d,
|
|
223
|
+
fields: g.map((e) => ({
|
|
224
|
+
...e,
|
|
225
|
+
render: $(e)
|
|
226
|
+
}))
|
|
227
|
+
}),
|
|
228
|
+
icon: /* @__PURE__ */ t(x, {}),
|
|
229
|
+
className: `group
|
|
230
|
+
${p || !d.length ? "" : "!bg-green-700 hover:!bg-green-600 !text-white !border-green-700 hover:!border-green-600"}
|
|
231
|
+
|
|
232
|
+
`,
|
|
233
|
+
children: "Excel"
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
] }),
|
|
237
|
+
Q,
|
|
238
|
+
/* @__PURE__ */ t(
|
|
239
|
+
P,
|
|
240
|
+
{
|
|
241
|
+
minusHeight: M,
|
|
242
|
+
data: d,
|
|
243
|
+
size: K,
|
|
244
|
+
fields: g,
|
|
245
|
+
idField: H,
|
|
246
|
+
loadingData: p,
|
|
247
|
+
paginateProps: J,
|
|
248
|
+
viewable: !1
|
|
249
|
+
}
|
|
250
|
+
)
|
|
251
|
+
] });
|
|
252
|
+
}
|
|
253
|
+
export {
|
|
254
|
+
be as default
|
|
255
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),p=require("@ant-design/icons"),l=require("antd"),N=require("./CrudField.cjs.js"),w=require("../util/CrudUtil.cjs.js"),M=require("../common/button/Button.cjs.js");function R({searchFields:t=[],fields:g,searchOnChange:y,onSearch:m,searchDefaultValues:b,searchFieldsCustomColumnProps:r}){const c=o.useMemo(()=>t.map(n=>typeof n=="string"?{...g.find(x=>n===x.name),required:!1}:{...g.find(i=>(n==null?void 0:n.name)===i.name),...n}).filter(n=>n&&!(n!=null&&n.hidden)),[t,g]),j=o.useMemo(()=>t.length===1?{field:22,button:2}:t.length===2?{field:11,button:2}:t.length===3?{field:6,button:6}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),q=o.useMemo(()=>t.length===1?{field:22,button:2}:t.length===2?{field:11,button:2}:t.length===3?{field:6,button:6}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),a=o.useMemo(()=>t.length===1?{field:21,button:3}:t.length===2?{field:11,button:2}:t.length===3?{field:24,button:24}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),[u]=l.Form.useForm(),d=o.useCallback(async n=>{if((n||y)&&m){const f=await u.validateFields();m(f)}},[u,m,y]);return o.useEffect(()=>{b&&(u.setFieldsValue(b),d(!0))},[u,b]),t!=null&&t.length?e.jsx(l.Form,{form:u,onFinish:()=>d(!0),layout:"vertical",className:"mb-2",onChange:()=>d(!1),children:e.jsxs(l.Row,{gutter:[4,8],className:"w-100",children:[c.map((n,f)=>{const i=(r==null?void 0:r[f])??{md:j.field,sm:q.field,xs:a.field},x=w.getRealName(n.name);return o.createElement(l.Col,{...i,key:`search_field_${String(x)}`,className:"align-self-end"},e.jsx(N.default,{...n,readonly:!1,fieldClassName:"mb-0"}))}),e.jsx(l.Col,{md:j.button,sm:q.button,xs:a.button,style:{alignSelf:"end"},children:e.jsx(M,{type:"primary",htmlType:"submit",block:!0,icon:e.jsx(p.SearchOutlined,{})})})]})}):e.jsx(e.Fragment,{})}module.exports=R;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ColProps } from 'antd/lib';
|
|
2
|
+
import { CrudFieldProps } from './CrudComponent';
|
|
3
|
+
export type CrudSearchOption<T> = {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
} & ({
|
|
6
|
+
type: "text";
|
|
7
|
+
name: keyof T;
|
|
8
|
+
} | {
|
|
9
|
+
type: "select";
|
|
10
|
+
name: keyof T;
|
|
11
|
+
multiple?: boolean;
|
|
12
|
+
});
|
|
13
|
+
export interface CrudSearchComponentProps<T, FormType> {
|
|
14
|
+
searchFields?: Array<keyof T | CrudSearchOption<T>>;
|
|
15
|
+
fields: CrudFieldProps<T>[];
|
|
16
|
+
searchOnChange?: boolean;
|
|
17
|
+
searchDefaultValues?: FormType;
|
|
18
|
+
onSearch?: (values: Partial<FormType>) => void;
|
|
19
|
+
searchFieldsCustomColumnProps?: ColProps[];
|
|
20
|
+
}
|
|
21
|
+
export default function CrudSearchComponent<T, FormType>({ searchFields, fields, searchOnChange, onSearch, searchDefaultValues, searchFieldsCustomColumnProps, }: Readonly<CrudSearchComponentProps<T, FormType>>): import("react/jsx-runtime").JSX.Element;
|