@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,96 @@
|
|
|
1
|
+
import { jsx as o, Fragment as j, jsxs as v } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as l, useCallback as E, useEffect as R, createElement as S } from "react";
|
|
3
|
+
import { SearchOutlined as _ } from "@ant-design/icons";
|
|
4
|
+
import { Form as N, Row as q, Col as w } from "antd";
|
|
5
|
+
import B from "./CrudField.es.js";
|
|
6
|
+
import M from "../util/CrudUtil.es.js";
|
|
7
|
+
import T from "../common/button/Button.es.js";
|
|
8
|
+
function I({
|
|
9
|
+
searchFields: t = [],
|
|
10
|
+
fields: u,
|
|
11
|
+
searchOnChange: d,
|
|
12
|
+
onSearch: i,
|
|
13
|
+
searchDefaultValues: g,
|
|
14
|
+
searchFieldsCustomColumnProps: b
|
|
15
|
+
}) {
|
|
16
|
+
const k = l(
|
|
17
|
+
() => t.map((n) => typeof n == "string" ? {
|
|
18
|
+
...u.find((p) => n === p.name),
|
|
19
|
+
required: !1
|
|
20
|
+
} : {
|
|
21
|
+
...u.find(
|
|
22
|
+
(e) => (n == null ? void 0 : n.name) === e.name
|
|
23
|
+
),
|
|
24
|
+
...n
|
|
25
|
+
}).filter((n) => n && !(n != null && n.hidden)),
|
|
26
|
+
[t, u]
|
|
27
|
+
), y = l(
|
|
28
|
+
() => 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 },
|
|
29
|
+
[t.length]
|
|
30
|
+
), a = l(
|
|
31
|
+
() => 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 },
|
|
32
|
+
[t.length]
|
|
33
|
+
), x = l(
|
|
34
|
+
() => 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 },
|
|
35
|
+
[t.length]
|
|
36
|
+
), [f] = N.useForm(), r = E(
|
|
37
|
+
async (n) => {
|
|
38
|
+
if ((n || d) && i) {
|
|
39
|
+
const m = await f.validateFields();
|
|
40
|
+
i(m);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
[f, i, d]
|
|
44
|
+
);
|
|
45
|
+
return R(() => {
|
|
46
|
+
g && (f.setFieldsValue(g), r(!0));
|
|
47
|
+
}, [f, g]), t != null && t.length ? /* @__PURE__ */ o(
|
|
48
|
+
N,
|
|
49
|
+
{
|
|
50
|
+
form: f,
|
|
51
|
+
onFinish: () => r(!0),
|
|
52
|
+
layout: "vertical",
|
|
53
|
+
className: "mb-2",
|
|
54
|
+
onChange: () => r(!1),
|
|
55
|
+
children: /* @__PURE__ */ v(q, { gutter: [4, 8], className: "w-100", children: [
|
|
56
|
+
k.map((n, m) => {
|
|
57
|
+
const e = (b == null ? void 0 : b[m]) ?? {
|
|
58
|
+
md: y.field,
|
|
59
|
+
sm: a.field,
|
|
60
|
+
xs: x.field
|
|
61
|
+
}, p = M.getRealName(n.name);
|
|
62
|
+
return /* @__PURE__ */ S(
|
|
63
|
+
w,
|
|
64
|
+
{
|
|
65
|
+
...e,
|
|
66
|
+
key: `search_field_${String(p)}`,
|
|
67
|
+
className: "align-self-end"
|
|
68
|
+
},
|
|
69
|
+
/* @__PURE__ */ o(B, { ...n, readonly: !1, fieldClassName: "mb-0" })
|
|
70
|
+
);
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ o(
|
|
73
|
+
w,
|
|
74
|
+
{
|
|
75
|
+
md: y.button,
|
|
76
|
+
sm: a.button,
|
|
77
|
+
xs: x.button,
|
|
78
|
+
style: { alignSelf: "end" },
|
|
79
|
+
children: /* @__PURE__ */ o(
|
|
80
|
+
T,
|
|
81
|
+
{
|
|
82
|
+
type: "primary",
|
|
83
|
+
htmlType: "submit",
|
|
84
|
+
block: !0,
|
|
85
|
+
icon: /* @__PURE__ */ o(_, {})
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
] })
|
|
91
|
+
}
|
|
92
|
+
) : /* @__PURE__ */ o(j, {});
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
I as default
|
|
96
|
+
};
|
|
@@ -0,0 +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"),h=require("antd"),j=require("../util/CrudUtil.cjs.js"),p=({onChange:t,label:r,required:s,rules:o,name:i,updatable:n=!0,...c})=>{const a=h.Form.useFormInstance(),l=j.getRealName(i,"upsertFieldName");if(c.rich)return u.jsx(T.RichTextEditor,{name:l,label:r,required:s,rules:o,disabled:!n});{const{placeholder:m,rows:x,cols:f,fieldClassName:N,fieldTooltip:q}=c;return u.jsx(C.default,{rules:o,placeholder:m,onChange:t?e=>{var d;return t((d=e==null?void 0:e.target)==null?void 0:d.value,a)}:void 0,tooltip:q,required:s,disabled:!n,name:i,label:r,className:N,rows:x,cols:f})}};module.exports=p;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InitialCrudField } from './CrudComponent';
|
|
2
|
+
import { FormInstance } from 'antd/lib';
|
|
3
|
+
interface InitialTextAreaProps<T> extends InitialCrudField<T> {
|
|
4
|
+
type: "textarea";
|
|
5
|
+
onChange?: (value: string, form: FormInstance<T>) => void;
|
|
6
|
+
/**
|
|
7
|
+
* number of lines to show. If false will not show truncated
|
|
8
|
+
* @default 2
|
|
9
|
+
*/
|
|
10
|
+
truncated?: boolean | number;
|
|
11
|
+
}
|
|
12
|
+
interface TextAreaProps<T> extends InitialTextAreaProps<T> {
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
rows?: number;
|
|
15
|
+
cols?: number;
|
|
16
|
+
}
|
|
17
|
+
interface RichTextAreaProps<T> extends InitialTextAreaProps<T> {
|
|
18
|
+
rich?: true;
|
|
19
|
+
}
|
|
20
|
+
export type TextAreaBasedFieldProps<T> = TextAreaProps<T> & RichTextAreaProps<T>;
|
|
21
|
+
declare const CrudTextAreaComponent: <T>({ onChange, label, required, rules, name, updatable, ...props }: TextAreaBasedFieldProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export default CrudTextAreaComponent;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as d } 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 h } from "antd";
|
|
5
|
+
import F from "../util/CrudUtil.es.js";
|
|
6
|
+
const E = ({
|
|
7
|
+
onChange: e,
|
|
8
|
+
label: t,
|
|
9
|
+
required: r,
|
|
10
|
+
rules: m,
|
|
11
|
+
name: i,
|
|
12
|
+
updatable: s = !0,
|
|
13
|
+
...a
|
|
14
|
+
}) => {
|
|
15
|
+
const c = h.useFormInstance(), f = F.getRealName(i, "upsertFieldName");
|
|
16
|
+
if (a.rich)
|
|
17
|
+
return /* @__PURE__ */ d(
|
|
18
|
+
T,
|
|
19
|
+
{
|
|
20
|
+
name: f,
|
|
21
|
+
label: t,
|
|
22
|
+
required: r,
|
|
23
|
+
rules: m,
|
|
24
|
+
disabled: !s
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
{
|
|
28
|
+
const { placeholder: l, rows: p, cols: u, fieldClassName: x, fieldTooltip: C } = a;
|
|
29
|
+
return /* @__PURE__ */ d(
|
|
30
|
+
N,
|
|
31
|
+
{
|
|
32
|
+
rules: m,
|
|
33
|
+
placeholder: l,
|
|
34
|
+
onChange: e ? (o) => {
|
|
35
|
+
var n;
|
|
36
|
+
return e((n = o == null ? void 0 : o.target) == null ? void 0 : n.value, c);
|
|
37
|
+
} : void 0,
|
|
38
|
+
tooltip: C,
|
|
39
|
+
required: r,
|
|
40
|
+
disabled: !s,
|
|
41
|
+
name: i,
|
|
42
|
+
label: t,
|
|
43
|
+
className: x,
|
|
44
|
+
rows: p,
|
|
45
|
+
cols: u
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
E as default
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime");;/* empty css */const d=require("@ant-design/icons"),F=require("antd"),N=require("mime"),c=require("react"),z=require("../locale/index.cjs.js"),G=require("../util/ValidationUtil.cjs.js"),p=require("../common/button/Button.cjs.js"),J=require("../common/layout/VerticalSpace.cjs.js"),K=require("../util/CrudUtil.cjs.js");function Q({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:P,rules:k,maxCount:q=1,block:E,fieldHelper:_,...$}){const f=F.Form.useFormInstance(),H=K.getRealName(n,"upsertFieldName"),x=F.Form.useWatch(H,f),[O,b]=c.useState(!1),[V,R]=c.useState(!1),A=c.useCallback(async r=>{var i,u;try{const{file:o}=r,g=o.name;b(!0),R(!0),a==null||a(!0);const C=g??"",S=C.split("."),W=S[S.length-1],B=s.generateFileName(C),M=`${await s.getInitialPath()}/${B}.${W}`;console.log({filePath:M});const D=await s.upload({...o,originFileObj:o},M);a==null||a(!1),f.setFieldValue(n,D),(i=r.onSuccess)==null||i.call(r,D)}catch(o){(u=r.onError)==null||u.call(r,o)}finally{b(!1)}},[f,n,a,s]),[w,I]=c.useState([]);c.useEffect(()=>{!V&&x&&Promise.all((Array.isArray(x)?x:[x]).map(async r=>{const i=N.getType(r),u=r.split("/").pop(),o=await s.getRealUrl(r);return{uid:r,url:o,type:i,name:u}})).then(r=>I(()=>{const i=r.map(({url:u,type:o,uid:g,name:C})=>({uid:g,url:u,type:o,response:g,thumbUrl:u,name:C}));return console.log(i),i}))},[x,V,O,s]);const L=c.useCallback(async r=>{const i=r.response,u=i||f.getFieldValue(n);await s.delete(u),h==null||h(),r&&f.setFieldsValue({[n]:null})},[f,n,h,s]);return t.jsxs(F.Form.Item,{label:e,required:l,name:n,className:j,rules:[...l?G.required(e):[],...k??[]],help:_,children:[t.jsx("input",{hidden:!0}),t.jsx(F.Upload,{...$,fileList:w,className:((w==null?void 0:w.length)??0)>=q?"hide-upload":"",maxCount:q,customRequest:A,onRemove:L,listType:"picture",onChange:({fileList:r})=>{I(r)},style:E?{width:"100%"}:void 0,children:t.jsx(p,{loading:O,children:"Upload File"})})]})}const X=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:N.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(U,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},U=({url:n,mimeType:e="",fileName:l})=>{const s=c.useMemo(()=>e!=null&&e.includes("image")?"image":e!=null&&e.includes("pdf")?"pdf":e!=null&&e.includes("word")?"word":e!=null&&e.includes("text")?"text":e!=null&&e.includes("presentation")?"presentation":e!=null&&e.includes("excel")||e!=null&&e.includes("spreadsheet")?"excel":"file",[e]),a=c.useMemo(()=>{switch(s){case"image":return t.jsx(d.FileImageOutlined,{});case"pdf":return t.jsx(d.FilePdfOutlined,{});case"word":return t.jsx(d.FileWordOutlined,{});case"text":return t.jsx(d.FileTextOutlined,{});case"excel":return t.jsx(d.FileExcelOutlined,{});case"presentation":return t.jsx(d.FilePptOutlined,{});default:return t.jsx(d.FileOutlined,{})}},[s]),[h,j]=c.useState(!1),{t:P}=z.useTranslationLib();return s!=="file"&&s!=="text"?t.jsxs(t.Fragment,{children:[t.jsx(F.Modal,{open:h,title:l,onCancel:()=>j(!1),footer:t.jsx(t.Fragment,{}),width:"100%",style:{top:"8px",minHeight:"700px"},destroyOnHidden:!0,children:t.jsxs(J,{children:[t.jsx(p,{tooltip:l,icon:t.jsx(d.ExportOutlined,{}),target:"_blank",href:n,style:{textDecoration:"none"},children:P("str.openInNewTab")}),s==="image"?t.jsx("img",{src:n,alt:l,style:{width:"100%"}}):s==="pdf"?t.jsxs("iframe",{title:l,src:n,width:"100%",height:"700px",children:["This browser does not support PDFs. Please download the PDF to view it:",t.jsx("a",{href:n,children:"Download PDF"})]}):t.jsxs("iframe",{title:l,src:`https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(n)}`,width:"100%",height:"700px",children:["This browser does not support open ",s.toUpperCase(),". Please download the",s.toUpperCase()," to view it:",t.jsxs("a",{href:n,children:["Download ",s.toUpperCase()]}),"."]})]})}),t.jsx(p,{tooltip:l,icon:a,shape:"circle",onClick:()=>j(!0)})]}):t.jsx(p,{tooltip:l,icon:a,target:"_blank",href:n,shape:"circle"})};exports.FileCellValue=U;exports.FileCrudCellValue=X;exports.default=Q;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { InitialCrudField } from './CrudComponent';
|
|
3
|
+
import { FileDownloadProvider, FileUploadProvider } from './ImageCrudField';
|
|
4
|
+
export interface FileCrudField<T> extends _FileCrudField<T> {
|
|
5
|
+
type: "file";
|
|
6
|
+
}
|
|
7
|
+
export interface _FileCrudField<T> extends InitialCrudField<T> {
|
|
8
|
+
provider: FileUploadProvider;
|
|
9
|
+
onUploading?: (isUploading: boolean) => void;
|
|
10
|
+
onRemoved?: () => void;
|
|
11
|
+
fieldClassName?: string;
|
|
12
|
+
accept?: string;
|
|
13
|
+
maxCount?: number;
|
|
14
|
+
block?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export default function FileCrudFieldComponent<T>({ name, label, required, provider, onUploading, onRemoved, fieldClassName, accept, rules, maxCount, block, fieldHelper: help, ...props }: Readonly<_FileCrudField<T>>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const FileCrudCellValue: FC<{
|
|
18
|
+
value: string;
|
|
19
|
+
provider: FileDownloadProvider;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const FileCellValue: FC<{
|
|
22
|
+
url: string;
|
|
23
|
+
mimeType?: string | null;
|
|
24
|
+
fileName: string;
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { jsxs as f, jsx as s, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { FileOutlined as K, FilePptOutlined as Q, FileExcelOutlined as X, FileTextOutlined as Y, FileWordOutlined as Z, FilePdfOutlined as v, FileImageOutlined as y, ExportOutlined as m } from "@ant-design/icons";
|
|
4
|
+
import { Form as P, Upload as T, Modal as tt } from "antd";
|
|
5
|
+
import H from "mime";
|
|
6
|
+
import { useState as p, useCallback as $, useEffect as S, useMemo as j } from "react";
|
|
7
|
+
import { useTranslationLib as et } from "../locale/index.es.js";
|
|
8
|
+
import st from "../util/ValidationUtil.es.js";
|
|
9
|
+
import C from "../common/button/Button.es.js";
|
|
10
|
+
import lt from "../common/layout/VerticalSpace.es.js";
|
|
11
|
+
import rt from "../util/CrudUtil.es.js";
|
|
12
|
+
function gt({
|
|
13
|
+
name: n,
|
|
14
|
+
label: t,
|
|
15
|
+
required: l,
|
|
16
|
+
provider: e,
|
|
17
|
+
onUploading: a,
|
|
18
|
+
onRemoved: u,
|
|
19
|
+
fieldClassName: F,
|
|
20
|
+
accept: b,
|
|
21
|
+
rules: A,
|
|
22
|
+
maxCount: I = 1,
|
|
23
|
+
block: L,
|
|
24
|
+
fieldHelper: W,
|
|
25
|
+
..._
|
|
26
|
+
}) {
|
|
27
|
+
const d = P.useFormInstance(), q = rt.getRealName(n, "upsertFieldName"), h = P.useWatch(q, d), [V, D] = p(!1), [N, B] = p(!1), R = $(
|
|
28
|
+
async (r) => {
|
|
29
|
+
var c, i;
|
|
30
|
+
try {
|
|
31
|
+
const { file: o } = r, g = o.name;
|
|
32
|
+
D(!0), B(!0), a == null || a(!0);
|
|
33
|
+
const x = g ?? "", k = x.split("."), G = k[k.length - 1], J = e.generateFileName(x), E = `${await e.getInitialPath()}/${J}.${G}`;
|
|
34
|
+
console.log({ filePath: E });
|
|
35
|
+
const M = await e.upload(
|
|
36
|
+
{ ...o, originFileObj: o },
|
|
37
|
+
E
|
|
38
|
+
);
|
|
39
|
+
a == null || a(!1), d.setFieldValue(n, M), (c = r.onSuccess) == null || c.call(r, M);
|
|
40
|
+
} catch (o) {
|
|
41
|
+
(i = r.onError) == null || i.call(r, o);
|
|
42
|
+
} finally {
|
|
43
|
+
D(!1);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
[d, n, a, e]
|
|
47
|
+
), [w, U] = p([]);
|
|
48
|
+
S(() => {
|
|
49
|
+
!N && h && Promise.all(
|
|
50
|
+
(Array.isArray(h) ? h : [h]).map(
|
|
51
|
+
async (r) => {
|
|
52
|
+
const c = H.getType(r), i = r.split("/").pop(), o = await e.getRealUrl(r);
|
|
53
|
+
return {
|
|
54
|
+
uid: r,
|
|
55
|
+
url: o,
|
|
56
|
+
type: c,
|
|
57
|
+
name: i
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
).then((r) => U(() => {
|
|
62
|
+
const c = r.map(({ url: i, type: o, uid: g, name: x }) => ({ uid: g, url: i, type: o, response: g, thumbUrl: i, name: x }));
|
|
63
|
+
return console.log(c), c;
|
|
64
|
+
}));
|
|
65
|
+
}, [h, N, V, e]);
|
|
66
|
+
const z = $(
|
|
67
|
+
async (r) => {
|
|
68
|
+
const c = r.response, i = c || d.getFieldValue(n);
|
|
69
|
+
await e.delete(i), u == null || u(), r && d.setFieldsValue({ [n]: null });
|
|
70
|
+
},
|
|
71
|
+
[d, n, u, e]
|
|
72
|
+
);
|
|
73
|
+
return /* @__PURE__ */ f(
|
|
74
|
+
P.Item,
|
|
75
|
+
{
|
|
76
|
+
label: t,
|
|
77
|
+
required: l,
|
|
78
|
+
name: n,
|
|
79
|
+
className: F,
|
|
80
|
+
rules: [
|
|
81
|
+
...l ? st.required(t) : [],
|
|
82
|
+
...A ?? []
|
|
83
|
+
],
|
|
84
|
+
help: W,
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ s("input", { hidden: !0 }),
|
|
87
|
+
/* @__PURE__ */ s(
|
|
88
|
+
T,
|
|
89
|
+
{
|
|
90
|
+
..._,
|
|
91
|
+
fileList: w,
|
|
92
|
+
className: ((w == null ? void 0 : w.length) ?? 0) >= I ? "hide-upload" : "",
|
|
93
|
+
maxCount: I,
|
|
94
|
+
customRequest: R,
|
|
95
|
+
onRemove: z,
|
|
96
|
+
listType: "picture",
|
|
97
|
+
onChange: ({ fileList: r }) => {
|
|
98
|
+
U(r);
|
|
99
|
+
},
|
|
100
|
+
style: L ? { width: "100%" } : void 0,
|
|
101
|
+
children: /* @__PURE__ */ s(C, { loading: V, children: "Upload File" })
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
const xt = ({ provider: n, value: t }) => {
|
|
109
|
+
const [l, e] = p();
|
|
110
|
+
return S(() => {
|
|
111
|
+
t && n.getRealUrl(t).then((a) => {
|
|
112
|
+
e({
|
|
113
|
+
mimeType: H.getType(t),
|
|
114
|
+
url: a,
|
|
115
|
+
fileName: t.split("/").pop() ?? t
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}, [n, t]), l ? /* @__PURE__ */ s(
|
|
119
|
+
nt,
|
|
120
|
+
{
|
|
121
|
+
fileName: l.fileName,
|
|
122
|
+
url: l == null ? void 0 : l.url,
|
|
123
|
+
mimeType: l == null ? void 0 : l.mimeType
|
|
124
|
+
}
|
|
125
|
+
) : /* @__PURE__ */ s(O, {});
|
|
126
|
+
}, nt = ({ url: n, mimeType: t = "", fileName: l }) => {
|
|
127
|
+
const e = j(() => t != null && t.includes("image") ? "image" : t != null && t.includes("pdf") ? "pdf" : t != null && t.includes("word") ? "word" : t != null && t.includes("text") ? "text" : t != null && t.includes("presentation") ? "presentation" : t != null && t.includes("excel") || t != null && t.includes("spreadsheet") ? "excel" : "file", [t]), a = j(() => {
|
|
128
|
+
switch (e) {
|
|
129
|
+
case "image":
|
|
130
|
+
return /* @__PURE__ */ s(y, {});
|
|
131
|
+
case "pdf":
|
|
132
|
+
return /* @__PURE__ */ s(v, {});
|
|
133
|
+
case "word":
|
|
134
|
+
return /* @__PURE__ */ s(Z, {});
|
|
135
|
+
case "text":
|
|
136
|
+
return /* @__PURE__ */ s(Y, {});
|
|
137
|
+
case "excel":
|
|
138
|
+
return /* @__PURE__ */ s(X, {});
|
|
139
|
+
case "presentation":
|
|
140
|
+
return /* @__PURE__ */ s(Q, {});
|
|
141
|
+
default:
|
|
142
|
+
return /* @__PURE__ */ s(K, {});
|
|
143
|
+
}
|
|
144
|
+
}, [e]), [u, F] = p(!1), { t: b } = et();
|
|
145
|
+
return e !== "file" && e !== "text" ? /* @__PURE__ */ f(O, { children: [
|
|
146
|
+
/* @__PURE__ */ s(
|
|
147
|
+
tt,
|
|
148
|
+
{
|
|
149
|
+
open: u,
|
|
150
|
+
title: l,
|
|
151
|
+
onCancel: () => F(!1),
|
|
152
|
+
footer: /* @__PURE__ */ s(O, {}),
|
|
153
|
+
width: "100%",
|
|
154
|
+
style: { top: "8px", minHeight: "700px" },
|
|
155
|
+
destroyOnHidden: !0,
|
|
156
|
+
children: /* @__PURE__ */ f(lt, { children: [
|
|
157
|
+
/* @__PURE__ */ s(
|
|
158
|
+
C,
|
|
159
|
+
{
|
|
160
|
+
tooltip: l,
|
|
161
|
+
icon: /* @__PURE__ */ s(m, {}),
|
|
162
|
+
target: "_blank",
|
|
163
|
+
href: n,
|
|
164
|
+
style: { textDecoration: "none" },
|
|
165
|
+
children: b("str.openInNewTab")
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
e === "image" ? /* @__PURE__ */ s("img", { src: n, alt: l, style: { width: "100%" } }) : e === "pdf" ? /* @__PURE__ */ f("iframe", { title: l, src: n, width: "100%", height: "700px", children: [
|
|
169
|
+
"This browser does not support PDFs. Please download the PDF to view it:",
|
|
170
|
+
/* @__PURE__ */ s("a", { href: n, children: "Download PDF" })
|
|
171
|
+
] }) : /* @__PURE__ */ f(
|
|
172
|
+
"iframe",
|
|
173
|
+
{
|
|
174
|
+
title: l,
|
|
175
|
+
src: `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
|
|
176
|
+
n
|
|
177
|
+
)}`,
|
|
178
|
+
width: "100%",
|
|
179
|
+
height: "700px",
|
|
180
|
+
children: [
|
|
181
|
+
"This browser does not support open ",
|
|
182
|
+
e.toUpperCase(),
|
|
183
|
+
". Please download the",
|
|
184
|
+
e.toUpperCase(),
|
|
185
|
+
" to view it:",
|
|
186
|
+
/* @__PURE__ */ f("a", { href: n, children: [
|
|
187
|
+
"Download ",
|
|
188
|
+
e.toUpperCase()
|
|
189
|
+
] }),
|
|
190
|
+
"."
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
] })
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
/* @__PURE__ */ s(
|
|
198
|
+
C,
|
|
199
|
+
{
|
|
200
|
+
tooltip: l,
|
|
201
|
+
icon: a,
|
|
202
|
+
shape: "circle",
|
|
203
|
+
onClick: () => F(!0)
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
] }) : /* @__PURE__ */ s(
|
|
207
|
+
C,
|
|
208
|
+
{
|
|
209
|
+
tooltip: l,
|
|
210
|
+
icon: a,
|
|
211
|
+
target: "_blank",
|
|
212
|
+
href: n,
|
|
213
|
+
shape: "circle"
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
export {
|
|
218
|
+
nt as FileCellValue,
|
|
219
|
+
xt as FileCrudCellValue,
|
|
220
|
+
gt as default
|
|
221
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var E=(e,a,t)=>a in e?p(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t;var F=(e,a,t)=>E(e,typeof a!="symbol"?a+"":a,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react/jsx-runtime");;/* empty css */const A=require("@ant-design/icons"),n=require("antd"),q=require("path-browserify"),i=require("react"),D=require("../util/NumberUtil.cjs.js"),M=require("../util/ValidationUtil.cjs.js"),H=require("uuid"),T=require("../common/picker/ImagePicker.cjs.js");class w{}class W extends w{constructor(t="",s=""){super();F(this,"rootPath");F(this,"subPath");this.rootPath=t,this.subPath=s}cloneFilePath(t){const s=q.parse(t),l=`${s.name}_cloned_${D.default.randInt(1e5)}`;return q.format({dir:s.dir,ext:s.ext,name:l})}generateFileName(t){return`${t.split(".")[0]}_${H.v4().replace("-","")}`}}function z({name:e,label:a,required:t,provider:s,onUploading:l,aspectRatio:P,onRemoved:o,fieldClassName:N,hideLabel:V=!1,listType:g,fieldHelper:y}){const c=n.Form.useFormInstance(),d=n.Form.useWatch(e,c),[I,$]=i.useState(!1),x=i.useCallback(async(r,b)=>{if(b){l==null||l(!0);const f=r.name,m=f.split("."),S=m[m.length-1],_=s.generateFileName(f),O=`${await s.getInitialPath()}/${_}.${S}`,k=await s.upload(r,O);$(!0),l==null||l(!1),c.setFieldValue(e,k)}else{console.log(r);const f=c.getFieldsValue(),m=await s.delete(f[e]);o==null||o(),m&&c.setFieldsValue({[e]:null})}},[c,e,o,l,s]),[h,j]=i.useState();return i.useEffect(()=>{!I&&d?s.getRealUrl(d).then(j):j(h)},[d,I,s,h]),u.jsxs(n.Form.Item,{rules:t?M.required(a):[],label:V?null:a,required:t,name:e,help:y,children:[u.jsx(T.default,{noStyle:!0,listType:g,aspectRatio:P,values:h,onRemove:r=>{r&&x(r,!1)},onAdd:async r=>{r&&await x(r,!0)},className:N}),u.jsx(n.Input,{hidden:!0})]})}const B=({provider:e,value:a})=>{const[t,s]=i.useState();return i.useEffect(()=>{a&&e.getRealUrl(a).then(s)},[e,a]),t?u.jsx(C,{url:t}):u.jsx(u.Fragment,{})},C=({url:e})=>u.jsx(n.Avatar,{className:"p-0",children:u.jsx(n.Image,{className:"m-0 p-0 position-relative",src:e,preview:{mask:u.jsx(A.EyeOutlined,{})}})});exports.FileDownloadProvider=w;exports.FileUploadProvider=W;exports.ImageCellValue=C;exports.ImageCrudCellValue=B;exports.default=z;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { UploadListType } from 'antd/es/upload/interface';
|
|
2
|
+
import { UploadFile } from 'antd/lib';
|
|
3
|
+
import { FC } from 'react';
|
|
4
|
+
import { InitialCrudField } from './CrudComponent';
|
|
5
|
+
export interface _ImageCrudField<T> extends InitialCrudField<T> {
|
|
6
|
+
provider: FileUploadProvider;
|
|
7
|
+
onUploading?: (isUploading: boolean) => void;
|
|
8
|
+
onRemoved?: () => void;
|
|
9
|
+
aspectRatio?: number;
|
|
10
|
+
fieldClassName?: string;
|
|
11
|
+
listType?: UploadListType;
|
|
12
|
+
}
|
|
13
|
+
export interface ImageCrudField<T> extends _ImageCrudField<T> {
|
|
14
|
+
type: "image";
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class FileDownloadProvider {
|
|
17
|
+
abstract getRealUrl(filePath?: string): Promise<string>;
|
|
18
|
+
}
|
|
19
|
+
export declare abstract class FileUploadProvider extends FileDownloadProvider {
|
|
20
|
+
rootPath: string;
|
|
21
|
+
subPath: string;
|
|
22
|
+
constructor(rootPath?: string, subPath?: string);
|
|
23
|
+
cloneFilePath(filePath: string): string;
|
|
24
|
+
abstract getInitialPath(): Promise<string>;
|
|
25
|
+
abstract upload(file: UploadFile<any>, filePath: string): Promise<string>;
|
|
26
|
+
abstract delete(filePath: string): Promise<boolean>;
|
|
27
|
+
abstract clone(filePath: string): Promise<string>;
|
|
28
|
+
abstract getRealUrl(filePath: string): Promise<string>;
|
|
29
|
+
generateFileName(initialFileName: string): string;
|
|
30
|
+
}
|
|
31
|
+
export default function ImageCrudFieldComponent<T>({ name, label, required, provider, onUploading, aspectRatio, onRemoved, fieldClassName, hideLabel, listType, fieldHelper: help, }: Readonly<_ImageCrudField<T>>): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export declare const ImageCrudCellValue: FC<{
|
|
33
|
+
value: string;
|
|
34
|
+
provider: FileDownloadProvider;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const ImageCellValue: FC<{
|
|
37
|
+
url: string;
|
|
38
|
+
}>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var E = (e, a, t) => a in e ? A(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
|
|
3
|
+
var h = (e, a, t) => E(e, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import { jsxs as S, jsx as i, Fragment as D } from "react/jsx-runtime";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import { EyeOutlined as H } from "@ant-design/icons";
|
|
7
|
+
import { Form as F, Input as W, Avatar as q, Image as z } from "antd";
|
|
8
|
+
import w from "path-browserify";
|
|
9
|
+
import { useState as P, useCallback as B, useEffect as V } from "react";
|
|
10
|
+
import G from "../util/NumberUtil.es.js";
|
|
11
|
+
import J from "../util/ValidationUtil.es.js";
|
|
12
|
+
import { v4 as K } from "uuid";
|
|
13
|
+
import L from "../common/picker/ImagePicker.es.js";
|
|
14
|
+
class M {
|
|
15
|
+
}
|
|
16
|
+
class le extends M {
|
|
17
|
+
constructor(t = "", s = "") {
|
|
18
|
+
super();
|
|
19
|
+
h(this, "rootPath");
|
|
20
|
+
h(this, "subPath");
|
|
21
|
+
this.rootPath = t, this.subPath = s;
|
|
22
|
+
}
|
|
23
|
+
cloneFilePath(t) {
|
|
24
|
+
const s = w.parse(t), l = `${s.name}_cloned_${G.randInt(1e5)}`;
|
|
25
|
+
return w.format({
|
|
26
|
+
dir: s.dir,
|
|
27
|
+
ext: s.ext,
|
|
28
|
+
name: l
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
generateFileName(t) {
|
|
32
|
+
return `${t.split(".")[0]}_${K().replace("-", "")}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function re({
|
|
36
|
+
name: e,
|
|
37
|
+
label: a,
|
|
38
|
+
required: t,
|
|
39
|
+
provider: s,
|
|
40
|
+
onUploading: l,
|
|
41
|
+
aspectRatio: p,
|
|
42
|
+
onRemoved: c,
|
|
43
|
+
fieldClassName: x,
|
|
44
|
+
hideLabel: y = !1,
|
|
45
|
+
listType: C,
|
|
46
|
+
fieldHelper: $
|
|
47
|
+
}) {
|
|
48
|
+
const n = F.useFormInstance(), u = F.useWatch(e, n), [I, g] = P(!1), N = B(
|
|
49
|
+
async (r, b) => {
|
|
50
|
+
if (b) {
|
|
51
|
+
l == null || l(!0);
|
|
52
|
+
const m = r.name, o = m.split("."), k = o[o.length - 1], O = s.generateFileName(m), _ = `${await s.getInitialPath()}/${O}.${k}`, j = await s.upload(r, _);
|
|
53
|
+
g(!0), l == null || l(!1), n.setFieldValue(e, j);
|
|
54
|
+
} else {
|
|
55
|
+
console.log(r);
|
|
56
|
+
const m = n.getFieldsValue(), o = await s.delete(m[e]);
|
|
57
|
+
c == null || c(), o && n.setFieldsValue({ [e]: null });
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
[n, e, c, l, s]
|
|
61
|
+
), [f, d] = P();
|
|
62
|
+
return V(() => {
|
|
63
|
+
!I && u ? s.getRealUrl(u).then(d) : d(f);
|
|
64
|
+
}, [u, I, s, f]), /* @__PURE__ */ S(
|
|
65
|
+
F.Item,
|
|
66
|
+
{
|
|
67
|
+
rules: t ? J.required(a) : [],
|
|
68
|
+
label: y ? null : a,
|
|
69
|
+
required: t,
|
|
70
|
+
name: e,
|
|
71
|
+
help: $,
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ i(
|
|
74
|
+
L,
|
|
75
|
+
{
|
|
76
|
+
noStyle: !0,
|
|
77
|
+
listType: C,
|
|
78
|
+
aspectRatio: p,
|
|
79
|
+
values: f,
|
|
80
|
+
onRemove: (r) => {
|
|
81
|
+
r && N(r, !1);
|
|
82
|
+
},
|
|
83
|
+
onAdd: async (r) => {
|
|
84
|
+
r && await N(r, !0);
|
|
85
|
+
},
|
|
86
|
+
className: x
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ i(W, { hidden: !0 })
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
const ie = ({ provider: e, value: a }) => {
|
|
95
|
+
const [t, s] = P();
|
|
96
|
+
return V(() => {
|
|
97
|
+
a && e.getRealUrl(a).then(s);
|
|
98
|
+
}, [e, a]), t ? /* @__PURE__ */ i(Q, { url: t }) : /* @__PURE__ */ i(D, {});
|
|
99
|
+
}, Q = ({ url: e }) => /* @__PURE__ */ i(q, { className: "p-0", children: /* @__PURE__ */ i(
|
|
100
|
+
z,
|
|
101
|
+
{
|
|
102
|
+
className: "m-0 p-0 position-relative",
|
|
103
|
+
src: e,
|
|
104
|
+
preview: {
|
|
105
|
+
mask: /* @__PURE__ */ i(H, {})
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
) });
|
|
109
|
+
export {
|
|
110
|
+
M as FileDownloadProvider,
|
|
111
|
+
le as FileUploadProvider,
|
|
112
|
+
Q as ImageCellValue,
|
|
113
|
+
ie as ImageCrudCellValue,
|
|
114
|
+
re as default
|
|
115
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const v=require("react/jsx-runtime"),Y=require("react"),A=require("../../common/button/CloneButtonTable.cjs.js"),H=require("../../common/button/DeleteButtonTable.cjs.js"),V=require("../../common/button/ExportButton.cjs.js"),s=require("../../common/button/HideButtonTable.cjs.js"),c=require("../../common/button/UpdateButtonTable.cjs.js"),r=require("../modal/index.cjs.js");function F({data:b,idField:j="id",extraAction:T,onUpdate:g,onClickUpdate:m,onClickClone:x,onDelete:h,onHide:z,onExport:E,isHiding:J,isDeleting:K,confirmHiding:Z,confirmDeleting:_,closeViewOnClickUpdate:$,recentUpdateOrDeleteId:L,setRecentUpdateOrDeleteId:q,setOpenView:G,inBuiltModalProps:f}){var S;const y=T==null?void 0:T(b),N=Y.useRef(null),Q=Y.useCallback((u,w=!0,W=!1)=>{var X;q==null||q(u[j]),f?(X=N.current)==null||X.update(u,w,W):W?x==null||x(u):m==null||m(u),$&&(G==null||G(void 0))},[f,m]);return console.log({onUpdate:g,onClickUpdate:m,onClickClone:x,onDelete:h}),(Array.isArray(y)?(S=y==null?void 0:y.filter(Boolean))!=null&&S.length:y)||g||m||f!=null&&f.onUpdate||x||f!=null&&f.onCreate||h||E||z?v.jsxs(v.Fragment,{children:[f&&v.jsx(r,{ref:N,...f}),y,(g||m||(f==null?void 0:f.onUpdate))&&v.jsx(c,{value:b,onClick:u=>Q(u)}),(x||(f==null?void 0:f.onCreate))&&v.jsx(A,{value:b,onClick:u=>Q(u,!1,!0)}),E&&v.jsx(V.ExportButton,{value:b,onClick:async u=>await E(u)}),z&&v.jsx(s,{value:b,disabled:J,shouldConfirm:Z,loading:J&&b[j]===L,onClick:async u=>{q==null||q(u[j]),await z({[j]:u[j]})}}),h&&v.jsx(H,{value:b,disabled:K,shouldConfirm:_,loading:K&&b[j]===L,onClick:async u=>{q==null||q(u[j]),await h({[j]:u[j]})}})]}):void 0}module.exports=F;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { default as IdProps } from '../../types/Id';
|
|
3
|
+
import { CrudModalProps } from '../modal';
|
|
4
|
+
export interface CrudActionsProps<T, FormType> {
|
|
5
|
+
idField?: string;
|
|
6
|
+
extraAction?: (t: T) => ReactElement | undefined | ReactElement[];
|
|
7
|
+
onUpdate?: (t: FormType & IdProps) => Promise<any>;
|
|
8
|
+
onClickUpdate?: (t: T) => void;
|
|
9
|
+
onClickClone?: (t: T) => Promise<any>;
|
|
10
|
+
onDelete?: (id: any) => Promise<any>;
|
|
11
|
+
onHide?: (id: any) => Promise<any>;
|
|
12
|
+
onExport?: (t: T) => Promise<any>;
|
|
13
|
+
isHiding?: boolean;
|
|
14
|
+
isDeleting?: boolean;
|
|
15
|
+
confirmHiding?: boolean;
|
|
16
|
+
confirmDeleting?: boolean;
|
|
17
|
+
closeViewOnClickUpdate?: boolean;
|
|
18
|
+
recentUpdateOrDeleteId?: string;
|
|
19
|
+
setRecentUpdateOrDeleteId?: (id: string) => void;
|
|
20
|
+
setOpenView?: (data: T | undefined) => void;
|
|
21
|
+
inBuiltModalProps?: CrudModalProps<T, FormType>;
|
|
22
|
+
}
|
|
23
|
+
declare function CrudActions<T, FormType>({ data, idField, extraAction, onUpdate, onClickUpdate, onClickClone, onDelete, onHide, onExport, isHiding, isDeleting, confirmHiding, confirmDeleting, closeViewOnClickUpdate, recentUpdateOrDeleteId, setRecentUpdateOrDeleteId, setOpenView, inBuiltModalProps, }: CrudActionsProps<T, FormType> & {
|
|
24
|
+
data: T;
|
|
25
|
+
}): import("react/jsx-runtime").JSX.Element | undefined;
|
|
26
|
+
export default CrudActions;
|