@kingteza/crud-component 1.0.66 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +21 -11
- package/release.config.cjs +27 -0
- package/App.d.ts +0 -151
- package/Play.d.ts +0 -2
- package/common/appearance/Hider.cjs.js +0 -1
- package/common/appearance/Hider.d.ts +0 -6
- package/common/appearance/Hider.es.js +0 -5
- package/common/appearance/index.d.ts +0 -1
- package/common/button/Button.cjs.js +0 -1
- package/common/button/Button.d.ts +0 -11
- package/common/button/Button.es.js +0 -57
- package/common/button/CloneButtonTable.cjs.js +0 -1
- package/common/button/CloneButtonTable.d.ts +0 -6
- package/common/button/CloneButtonTable.es.js +0 -19
- package/common/button/DeleteButtonTable.cjs.js +0 -1
- package/common/button/DeleteButtonTable.d.ts +0 -13
- package/common/button/DeleteButtonTable.es.js +0 -64
- package/common/button/ExportButton.cjs.js +0 -1
- package/common/button/ExportButton.d.ts +0 -4
- package/common/button/ExportButton.es.js +0 -26
- package/common/button/HideButtonTable.cjs.js +0 -1
- package/common/button/HideButtonTable.d.ts +0 -13
- package/common/button/HideButtonTable.es.js +0 -67
- package/common/button/ImportButton.cjs.js +0 -1
- package/common/button/ImportButton.d.ts +0 -9
- package/common/button/ImportButton.es.js +0 -55
- package/common/button/NewButton.cjs.js +0 -1
- package/common/button/NewButton.d.ts +0 -12
- package/common/button/NewButton.es.js +0 -23
- package/common/button/PrintButton.cjs.js +0 -1
- package/common/button/PrintButton.d.ts +0 -12
- package/common/button/PrintButton.es.js +0 -25
- package/common/button/RefreshButton.cjs.js +0 -1
- package/common/button/RefreshButton.d.ts +0 -11
- package/common/button/RefreshButton.es.js +0 -23
- package/common/button/UnHideButton.cjs.js +0 -1
- package/common/button/UnHideButton.d.ts +0 -14
- package/common/button/UnHideButton.es.js +0 -69
- package/common/button/UpdateButtonTable.cjs.js +0 -1
- package/common/button/UpdateButtonTable.d.ts +0 -6
- package/common/button/UpdateButtonTable.es.js +0 -19
- package/common/button/ViewButtonTable.cjs.js +0 -1
- package/common/button/ViewButtonTable.d.ts +0 -6
- package/common/button/ViewButtonTable.es.js +0 -19
- package/common/button/index.d.ts +0 -14
- package/common/check-box/CheckBox.cjs.js +0 -1
- package/common/check-box/CheckBox.d.ts +0 -9
- package/common/check-box/CheckBox.es.js +0 -40
- package/common/check-box/index.d.ts +0 -2
- package/common/date-picker/DatePicker.cjs.js +0 -1
- package/common/date-picker/DatePicker.d.ts +0 -37
- package/common/date-picker/DatePicker.es.js +0 -87
- package/common/date-picker/TimePicker.cjs.js +0 -1
- package/common/date-picker/TimePicker.d.ts +0 -34
- package/common/date-picker/TimePicker.es.js +0 -77
- package/common/date-picker/index.d.ts +0 -3
- package/common/description/DescList.cjs.js +0 -1
- package/common/description/DescList.d.ts +0 -18
- package/common/description/DescList.es.js +0 -16
- package/common/description/DescriptionComponent.d.ts +0 -7
- package/common/description/index.d.ts +0 -3
- package/common/icon/KIcon.cjs.js +0 -1
- package/common/icon/KIcon.d.ts +0 -9
- package/common/icon/KIcon.es.js +0 -11
- package/common/index.cjs.js +0 -1
- package/common/index.d.ts +0 -20
- package/common/index.es.js +0 -78
- package/common/layout/VerticalSpace.cjs.js +0 -1
- package/common/layout/VerticalSpace.d.ts +0 -5
- package/common/layout/VerticalSpace.es.js +0 -6
- package/common/layout/index.d.ts +0 -2
- package/common/loading/LoadingIndicator.cjs.js +0 -1
- package/common/loading/LoadingIndicator.d.ts +0 -6
- package/common/loading/LoadingIndicator.es.js +0 -23
- package/common/loading/index.d.ts +0 -2
- package/common/picker/ImagePicker.cjs.js +0 -1
- package/common/picker/ImagePicker.d.ts +0 -56
- package/common/picker/ImagePicker.es.js +0 -320
- package/common/picker/index.d.ts +0 -2
- package/common/radio/RadioGroupComponent.cjs.js +0 -1
- package/common/radio/RadioGroupComponent.d.ts +0 -18
- package/common/radio/RadioGroupComponent.es.js +0 -19
- package/common/radio/index.d.ts +0 -2
- package/common/report/SelectFieldInReport.cjs.js +0 -1
- package/common/report/SelectFieldInReport.d.ts +0 -16
- package/common/report/SelectFieldInReport.es.js +0 -30
- package/common/report/index.d.ts +0 -3
- package/common/rich/index.cjs.js +0 -1
- package/common/rich/index.d.ts +0 -10
- package/common/rich/index.es.js +0 -66
- package/common/select/CustomSelectOption.cjs.js +0 -1
- package/common/select/CustomSelectOption.d.ts +0 -7
- package/common/select/CustomSelectOption.es.js +0 -13
- package/common/select/SelectComponent.cjs.js +0 -1
- package/common/select/SelectComponent.d.ts +0 -21
- package/common/select/SelectComponent.es.js +0 -85
- package/common/select/index.d.ts +0 -3
- package/common/show-more/index.cjs.js +0 -1
- package/common/show-more/index.d.ts +0 -4
- package/common/show-more/index.es.js +0 -8
- package/common/tab/TabViewWithRoute.cjs.js +0 -1
- package/common/tab/TabViewWithRoute.d.ts +0 -13
- package/common/tab/TabViewWithRoute.es.js +0 -38
- package/common/tab/index.d.ts +0 -2
- package/common/table/index.d.ts +0 -3
- package/common/table/table.cjs.js +0 -1
- package/common/table/table.d.ts +0 -19
- package/common/table/table.es.js +0 -40
- package/common/tag/StatusTag.cjs.js +0 -1
- package/common/tag/StatusTag.d.ts +0 -14
- package/common/tag/StatusTag.es.js +0 -29
- package/common/tag/index.d.ts +0 -2
- package/common/text/index.cjs.js +0 -1
- package/common/text/index.d.ts +0 -3
- package/common/text/index.es.js +0 -5
- package/common/text/title/TitleWithHeadTitle.d.ts +0 -7
- package/common/text/title/index.cjs.js +0 -1
- package/common/text/title/index.d.ts +0 -1
- package/common/text/title/index.es.js +0 -5
- package/common/text-field/NumberField.cjs.js +0 -1
- package/common/text-field/NumberField.d.ts +0 -13
- package/common/text-field/NumberField.es.js +0 -82
- package/common/text-field/PhoneNumberField.cjs.js +0 -1
- package/common/text-field/PhoneNumberField.d.ts +0 -4
- package/common/text-field/PhoneNumberField.es.js +0 -18
- package/common/text-field/TextArea.cjs.js +0 -1
- package/common/text-field/TextArea.d.ts +0 -17
- package/common/text-field/TextArea.es.js +0 -46
- package/common/text-field/TextField.cjs.js +0 -1
- package/common/text-field/TextField.d.ts +0 -27
- package/common/text-field/TextField.es.js +0 -72
- package/common/text-field/index.d.ts +0 -5
- package/common/tooltip/TooltipComponent.cjs.js +0 -1
- package/common/tooltip/TooltipComponent.d.ts +0 -5
- package/common/tooltip/TooltipComponent.es.js +0 -9
- package/common/tooltip/index.d.ts +0 -2
- package/common/wizard/WizardResult.cjs.js +0 -1
- package/common/wizard/WizardResult.d.ts +0 -16
- package/common/wizard/WizardResult.es.js +0 -58
- package/common/wizard/WizardViewForm.cjs.js +0 -1
- package/common/wizard/WizardViewForm.d.ts +0 -24
- package/common/wizard/WizardViewForm.es.js +0 -74
- package/common/wizard/index.d.ts +0 -3
- package/crud/CrudComponent.cjs.js +0 -1
- package/crud/CrudComponent.d.ts +0 -244
- package/crud/CrudComponent.es.js +0 -123
- package/crud/CrudField.cjs.js +0 -1
- package/crud/CrudField.d.ts +0 -4
- package/crud/CrudField.es.js +0 -449
- package/crud/CrudForm.cjs.js +0 -1
- package/crud/CrudForm.d.ts +0 -14
- package/crud/CrudForm.es.js +0 -103
- package/crud/CrudFormWizard.cjs.js +0 -1
- package/crud/CrudFormWizard.d.ts +0 -14
- package/crud/CrudFormWizard.es.js +0 -140
- package/crud/CrudReportComponent.cjs.js +0 -4
- package/crud/CrudReportComponent.d.ts +0 -44
- package/crud/CrudReportComponent.es.js +0 -255
- package/crud/CrudSearchComponent.cjs.js +0 -1
- package/crud/CrudSearchComponent.d.ts +0 -21
- package/crud/CrudSearchComponent.es.js +0 -96
- package/crud/CrudTextAreaComponent.cjs.js +0 -1
- package/crud/CrudTextAreaComponent.d.ts +0 -22
- package/crud/CrudTextAreaComponent.es.js +0 -52
- package/crud/FileCrudField.cjs.js +0 -1
- package/crud/FileCrudField.d.ts +0 -25
- package/crud/FileCrudField.es.js +0 -219
- package/crud/ImageCrudField.cjs.js +0 -1
- package/crud/ImageCrudField.d.ts +0 -38
- package/crud/ImageCrudField.es.js +0 -113
- package/crud/actions/index.cjs.js +0 -1
- package/crud/actions/index.d.ts +0 -26
- package/crud/actions/index.es.js +0 -88
- package/crud/import/CrudImportButton.cjs.js +0 -1
- package/crud/import/CrudImportButton.d.ts +0 -3
- package/crud/import/CrudImportButton.es.js +0 -30
- package/crud/import/CrudImportComponent.cjs.js +0 -2
- package/crud/import/CrudImportComponent.d.ts +0 -14
- package/crud/import/CrudImportComponent.es.js +0 -222
- package/crud/index.d.ts +0 -23
- package/crud/modal/index.cjs.js +0 -1
- package/crud/modal/index.d.ts +0 -24
- package/crud/modal/index.es.js +0 -146
- package/crud/view/CrudDecListView.cjs.js +0 -1
- package/crud/view/CrudDecListView.d.ts +0 -15
- package/crud/view/CrudDecListView.es.js +0 -57
- package/crud/view/CrudViewer.cjs.js +0 -1
- package/crud/view/CrudViewer.d.ts +0 -43
- package/crud/view/CrudViewer.es.js +0 -304
- package/crud/view/CrudViewerUtil.cjs.js +0 -1
- package/crud/view/CrudViewerUtil.d.ts +0 -2
- package/crud/view/CrudViewerUtil.es.js +0 -98
- package/crud/view/index.d.ts +0 -5
- package/hooks/NavigatorHooks.cjs.js +0 -1
- package/hooks/NavigatorHooks.d.ts +0 -1
- package/hooks/NavigatorHooks.es.js +0 -9
- package/icons/FlipHIcon.cjs.js +0 -1
- package/icons/FlipHIcon.d.ts +0 -3
- package/icons/FlipHIcon.es.js +0 -28
- package/icons/FlipVIcon.cjs.js +0 -1
- package/icons/FlipVIcon.d.ts +0 -3
- package/icons/FlipVIcon.es.js +0 -28
- package/index.cjs.js +0 -1
- package/index.d.ts +0 -4
- package/index.es.js +0 -46
- package/locale/hooks/translation-constants.cjs.js +0 -1
- package/locale/hooks/translation-constants.d.ts +0 -1
- package/locale/hooks/translation-constants.es.js +0 -4
- package/locale/index.cjs.js +0 -1
- package/locale/index.d.ts +0 -85
- package/locale/index.es.js +0 -57
- package/locale/translations/en.cjs.js +0 -1
- package/locale/translations/en.d.ts +0 -63
- package/locale/translations/en.es.js +0 -65
- package/main.d.ts +0 -0
- package/types/DialogComponentProp.d.ts +0 -8
- package/types/Id.d.ts +0 -10
- package/util/CrudUtil.cjs.js +0 -1
- package/util/CrudUtil.d.ts +0 -5
- package/util/CrudUtil.es.js +0 -8
- package/util/DateUtil.cjs.js +0 -1
- package/util/DateUtil.d.ts +0 -7
- package/util/DateUtil.es.js +0 -18
- package/util/ImageUtil.cjs.js +0 -1
- package/util/ImageUtil.d.ts +0 -14
- package/util/ImageUtil.es.js +0 -63
- package/util/NumberUtil.cjs.js +0 -1
- package/util/NumberUtil.d.ts +0 -17
- package/util/NumberUtil.es.js +0 -60
- package/util/ValidationUtil.cjs.js +0 -1
- package/util/ValidationUtil.d.ts +0 -14
- package/util/ValidationUtil.es.js +0 -63
- package/util/index.cjs.js +0 -1
- package/util/index.d.ts +0 -4
- package/util/index.es.js +0 -10
- package/vite-env.d.ts +0 -1
|
@@ -1,96 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,52 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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"),B=require("../locale/index.cjs.js"),z=require("../util/ValidationUtil.cjs.js"),p=require("../common/button/Button.cjs.js"),G=require("../common/layout/VerticalSpace.cjs.js"),J=require("../util/CrudUtil.cjs.js");function K({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:P,rules:k,maxCount:q=1,block:E,..._}){const f=F.Form.useFormInstance(),$=J.getRealName(n,"upsertFieldName"),x=F.Form.useWatch($,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("."),L=S[S.length-1],W=s.generateFileName(C),M=`${await s.getInitialPath()}/${W}.${L}`;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 H=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?z.required(e):[],...k??[]],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:H,listType:"picture",onChange:({fileList:r})=>{I(r)},style:E?{width:"100%"}:void 0,children:t.jsx(p,{loading:O,children:"Upload File"})})]})}const Q=({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}=B.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(G,{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=Q;exports.default=K;
|
package/crud/FileCrudField.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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, ...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
|
-
}>;
|
package/crud/FileCrudField.es.js
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { jsxs as f, jsx as s, Fragment as O } from "react/jsx-runtime";
|
|
2
|
-
/* empty css */
|
|
3
|
-
import { FileOutlined as J, FilePptOutlined as K, FileExcelOutlined as Q, FileTextOutlined as X, FileWordOutlined as Y, FilePdfOutlined as Z, FileImageOutlined as v, ExportOutlined as y } from "@ant-design/icons";
|
|
4
|
-
import { Form as P, Upload as m, Modal as T } from "antd";
|
|
5
|
-
import S from "mime";
|
|
6
|
-
import { useState as p, useCallback as $, useEffect as A, useMemo as j } from "react";
|
|
7
|
-
import { useTranslationLib as tt } from "../locale/index.es.js";
|
|
8
|
-
import et from "../util/ValidationUtil.es.js";
|
|
9
|
-
import C from "../common/button/Button.es.js";
|
|
10
|
-
import st from "../common/layout/VerticalSpace.es.js";
|
|
11
|
-
import rt from "../util/CrudUtil.es.js";
|
|
12
|
-
function wt({
|
|
13
|
-
name: n,
|
|
14
|
-
label: t,
|
|
15
|
-
required: r,
|
|
16
|
-
provider: e,
|
|
17
|
-
onUploading: a,
|
|
18
|
-
onRemoved: u,
|
|
19
|
-
fieldClassName: F,
|
|
20
|
-
accept: b,
|
|
21
|
-
rules: H,
|
|
22
|
-
maxCount: I = 1,
|
|
23
|
-
block: L,
|
|
24
|
-
...W
|
|
25
|
-
}) {
|
|
26
|
-
const d = P.useFormInstance(), _ = rt.getRealName(n, "upsertFieldName"), h = P.useWatch(_, d), [V, D] = p(!1), [N, q] = p(!1), B = $(
|
|
27
|
-
async (l) => {
|
|
28
|
-
var c, i;
|
|
29
|
-
try {
|
|
30
|
-
const { file: o } = l, g = o.name;
|
|
31
|
-
D(!0), q(!0), a == null || a(!0);
|
|
32
|
-
const x = g ?? "", k = x.split("."), z = k[k.length - 1], G = e.generateFileName(x), E = `${await e.getInitialPath()}/${G}.${z}`;
|
|
33
|
-
console.log({ filePath: E });
|
|
34
|
-
const M = await e.upload(
|
|
35
|
-
{ ...o, originFileObj: o },
|
|
36
|
-
E
|
|
37
|
-
);
|
|
38
|
-
a == null || a(!1), d.setFieldValue(n, M), (c = l.onSuccess) == null || c.call(l, M);
|
|
39
|
-
} catch (o) {
|
|
40
|
-
(i = l.onError) == null || i.call(l, o);
|
|
41
|
-
} finally {
|
|
42
|
-
D(!1);
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
[d, n, a, e]
|
|
46
|
-
), [w, U] = p([]);
|
|
47
|
-
A(() => {
|
|
48
|
-
!N && h && Promise.all(
|
|
49
|
-
(Array.isArray(h) ? h : [h]).map(
|
|
50
|
-
async (l) => {
|
|
51
|
-
const c = S.getType(l), i = l.split("/").pop(), o = await e.getRealUrl(l);
|
|
52
|
-
return {
|
|
53
|
-
uid: l,
|
|
54
|
-
url: o,
|
|
55
|
-
type: c,
|
|
56
|
-
name: i
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
)
|
|
60
|
-
).then((l) => U(() => {
|
|
61
|
-
const c = l.map(({ url: i, type: o, uid: g, name: x }) => ({ uid: g, url: i, type: o, response: g, thumbUrl: i, name: x }));
|
|
62
|
-
return console.log(c), c;
|
|
63
|
-
}));
|
|
64
|
-
}, [h, N, V, e]);
|
|
65
|
-
const R = $(
|
|
66
|
-
async (l) => {
|
|
67
|
-
const c = l.response, i = c || d.getFieldValue(n);
|
|
68
|
-
await e.delete(i), u == null || u(), l && d.setFieldsValue({ [n]: null });
|
|
69
|
-
},
|
|
70
|
-
[d, n, u, e]
|
|
71
|
-
);
|
|
72
|
-
return /* @__PURE__ */ f(
|
|
73
|
-
P.Item,
|
|
74
|
-
{
|
|
75
|
-
label: t,
|
|
76
|
-
required: r,
|
|
77
|
-
name: n,
|
|
78
|
-
className: F,
|
|
79
|
-
rules: [
|
|
80
|
-
...r ? et.required(t) : [],
|
|
81
|
-
...H ?? []
|
|
82
|
-
],
|
|
83
|
-
children: [
|
|
84
|
-
/* @__PURE__ */ s("input", { hidden: !0 }),
|
|
85
|
-
/* @__PURE__ */ s(
|
|
86
|
-
m,
|
|
87
|
-
{
|
|
88
|
-
...W,
|
|
89
|
-
fileList: w,
|
|
90
|
-
className: ((w == null ? void 0 : w.length) ?? 0) >= I ? "hide-upload" : "",
|
|
91
|
-
maxCount: I,
|
|
92
|
-
customRequest: B,
|
|
93
|
-
onRemove: R,
|
|
94
|
-
listType: "picture",
|
|
95
|
-
onChange: ({ fileList: l }) => {
|
|
96
|
-
U(l);
|
|
97
|
-
},
|
|
98
|
-
style: L ? { width: "100%" } : void 0,
|
|
99
|
-
children: /* @__PURE__ */ s(C, { loading: V, children: "Upload File" })
|
|
100
|
-
}
|
|
101
|
-
)
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
const gt = ({ provider: n, value: t }) => {
|
|
107
|
-
const [r, e] = p();
|
|
108
|
-
return A(() => {
|
|
109
|
-
t && n.getRealUrl(t).then((a) => {
|
|
110
|
-
e({
|
|
111
|
-
mimeType: S.getType(t),
|
|
112
|
-
url: a,
|
|
113
|
-
fileName: t.split("/").pop() ?? t
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
}, [n, t]), r ? /* @__PURE__ */ s(
|
|
117
|
-
lt,
|
|
118
|
-
{
|
|
119
|
-
fileName: r.fileName,
|
|
120
|
-
url: r == null ? void 0 : r.url,
|
|
121
|
-
mimeType: r == null ? void 0 : r.mimeType
|
|
122
|
-
}
|
|
123
|
-
) : /* @__PURE__ */ s(O, {});
|
|
124
|
-
}, lt = ({ url: n, mimeType: t = "", fileName: r }) => {
|
|
125
|
-
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(() => {
|
|
126
|
-
switch (e) {
|
|
127
|
-
case "image":
|
|
128
|
-
return /* @__PURE__ */ s(v, {});
|
|
129
|
-
case "pdf":
|
|
130
|
-
return /* @__PURE__ */ s(Z, {});
|
|
131
|
-
case "word":
|
|
132
|
-
return /* @__PURE__ */ s(Y, {});
|
|
133
|
-
case "text":
|
|
134
|
-
return /* @__PURE__ */ s(X, {});
|
|
135
|
-
case "excel":
|
|
136
|
-
return /* @__PURE__ */ s(Q, {});
|
|
137
|
-
case "presentation":
|
|
138
|
-
return /* @__PURE__ */ s(K, {});
|
|
139
|
-
default:
|
|
140
|
-
return /* @__PURE__ */ s(J, {});
|
|
141
|
-
}
|
|
142
|
-
}, [e]), [u, F] = p(!1), { t: b } = tt();
|
|
143
|
-
return e !== "file" && e !== "text" ? /* @__PURE__ */ f(O, { children: [
|
|
144
|
-
/* @__PURE__ */ s(
|
|
145
|
-
T,
|
|
146
|
-
{
|
|
147
|
-
open: u,
|
|
148
|
-
title: r,
|
|
149
|
-
onCancel: () => F(!1),
|
|
150
|
-
footer: /* @__PURE__ */ s(O, {}),
|
|
151
|
-
width: "100%",
|
|
152
|
-
style: { top: "8px", minHeight: "700px" },
|
|
153
|
-
destroyOnHidden: !0,
|
|
154
|
-
children: /* @__PURE__ */ f(st, { children: [
|
|
155
|
-
/* @__PURE__ */ s(
|
|
156
|
-
C,
|
|
157
|
-
{
|
|
158
|
-
tooltip: r,
|
|
159
|
-
icon: /* @__PURE__ */ s(y, {}),
|
|
160
|
-
target: "_blank",
|
|
161
|
-
href: n,
|
|
162
|
-
style: { textDecoration: "none" },
|
|
163
|
-
children: b("str.openInNewTab")
|
|
164
|
-
}
|
|
165
|
-
),
|
|
166
|
-
e === "image" ? /* @__PURE__ */ s("img", { src: n, alt: r, style: { width: "100%" } }) : e === "pdf" ? /* @__PURE__ */ f("iframe", { title: r, src: n, width: "100%", height: "700px", children: [
|
|
167
|
-
"This browser does not support PDFs. Please download the PDF to view it:",
|
|
168
|
-
/* @__PURE__ */ s("a", { href: n, children: "Download PDF" })
|
|
169
|
-
] }) : /* @__PURE__ */ f(
|
|
170
|
-
"iframe",
|
|
171
|
-
{
|
|
172
|
-
title: r,
|
|
173
|
-
src: `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
|
|
174
|
-
n
|
|
175
|
-
)}`,
|
|
176
|
-
width: "100%",
|
|
177
|
-
height: "700px",
|
|
178
|
-
children: [
|
|
179
|
-
"This browser does not support open ",
|
|
180
|
-
e.toUpperCase(),
|
|
181
|
-
". Please download the",
|
|
182
|
-
e.toUpperCase(),
|
|
183
|
-
" to view it:",
|
|
184
|
-
/* @__PURE__ */ f("a", { href: n, children: [
|
|
185
|
-
"Download ",
|
|
186
|
-
e.toUpperCase()
|
|
187
|
-
] }),
|
|
188
|
-
"."
|
|
189
|
-
]
|
|
190
|
-
}
|
|
191
|
-
)
|
|
192
|
-
] })
|
|
193
|
-
}
|
|
194
|
-
),
|
|
195
|
-
/* @__PURE__ */ s(
|
|
196
|
-
C,
|
|
197
|
-
{
|
|
198
|
-
tooltip: r,
|
|
199
|
-
icon: a,
|
|
200
|
-
shape: "circle",
|
|
201
|
-
onClick: () => F(!0)
|
|
202
|
-
}
|
|
203
|
-
)
|
|
204
|
-
] }) : /* @__PURE__ */ s(
|
|
205
|
-
C,
|
|
206
|
-
{
|
|
207
|
-
tooltip: r,
|
|
208
|
-
icon: a,
|
|
209
|
-
target: "_blank",
|
|
210
|
-
href: n,
|
|
211
|
-
shape: "circle"
|
|
212
|
-
}
|
|
213
|
-
);
|
|
214
|
-
};
|
|
215
|
-
export {
|
|
216
|
-
lt as FileCellValue,
|
|
217
|
-
gt as FileCrudCellValue,
|
|
218
|
-
wt as default
|
|
219
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var E=(e,a,t)=>a in e?k(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 p=require("@ant-design/icons"),n=require("antd"),q=require("path-browserify"),i=require("react"),A=require("../util/NumberUtil.cjs.js"),D=require("../util/ValidationUtil.cjs.js"),M=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_${A.default.randInt(1e5)}`;return q.format({dir:s.dir,ext:s.ext,name:l})}generateFileName(t){return`${t.split(".")[0]}_${M.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}){const c=n.Form.useFormInstance(),h=n.Form.useWatch(e,c),[I,y]=i.useState(!1),x=i.useCallback(async(r,$)=>{if($){l==null||l(!0);const f=r.name,m=f.split("."),b=m[m.length-1],S=s.generateFileName(f),_=`${await s.getInitialPath()}/${S}.${b}`,O=await s.upload(r,_);y(!0),l==null||l(!1),c.setFieldValue(e,O)}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]),[d,j]=i.useState();return i.useEffect(()=>{!I&&h?s.getRealUrl(h).then(j):j(d)},[h,I,s,d]),u.jsxs(n.Form.Item,{rules:t?D.required(a):[],label:V?null:a,required:t,name:e,children:[u.jsx(T.default,{noStyle:!0,listType:g,aspectRatio:P,values:d,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(p.EyeOutlined,{})}})});exports.FileDownloadProvider=w;exports.FileUploadProvider=W;exports.ImageCellValue=C;exports.ImageCrudCellValue=B;exports.default=z;
|
package/crud/ImageCrudField.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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, }: 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
|
-
}>;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
var j = Object.defineProperty;
|
|
2
|
-
var A = (e, a, t) => a in e ? j(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
|
|
3
|
-
var h = (e, a, t) => A(e, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
-
import { jsxs as E, jsx as n, Fragment as S } from "react/jsx-runtime";
|
|
5
|
-
/* empty css */
|
|
6
|
-
import { EyeOutlined as D } from "@ant-design/icons";
|
|
7
|
-
import { Form as F, Input as W, Avatar as q, Image as z } from "antd";
|
|
8
|
-
import d 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 H from "../util/ValidationUtil.es.js";
|
|
12
|
-
import { v4 as J } from "uuid";
|
|
13
|
-
import K from "../common/picker/ImagePicker.es.js";
|
|
14
|
-
class L {
|
|
15
|
-
}
|
|
16
|
-
class ae extends L {
|
|
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 = d.parse(t), l = `${s.name}_cloned_${G.randInt(1e5)}`;
|
|
25
|
-
return d.format({
|
|
26
|
-
dir: s.dir,
|
|
27
|
-
ext: s.ext,
|
|
28
|
-
name: l
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
generateFileName(t) {
|
|
32
|
-
return `${t.split(".")[0]}_${J().replace("-", "")}`;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function le({
|
|
36
|
-
name: e,
|
|
37
|
-
label: a,
|
|
38
|
-
required: t,
|
|
39
|
-
provider: s,
|
|
40
|
-
onUploading: l,
|
|
41
|
-
aspectRatio: I,
|
|
42
|
-
onRemoved: c,
|
|
43
|
-
fieldClassName: x,
|
|
44
|
-
hideLabel: y = !1,
|
|
45
|
-
listType: C
|
|
46
|
-
}) {
|
|
47
|
-
const i = F.useFormInstance(), u = F.useWatch(e, i), [p, $] = P(!1), N = B(
|
|
48
|
-
async (r, g) => {
|
|
49
|
-
if (g) {
|
|
50
|
-
l == null || l(!0);
|
|
51
|
-
const m = r.name, o = m.split("."), b = o[o.length - 1], k = s.generateFileName(m), O = `${await s.getInitialPath()}/${k}.${b}`, _ = await s.upload(r, O);
|
|
52
|
-
$(!0), l == null || l(!1), i.setFieldValue(e, _);
|
|
53
|
-
} else {
|
|
54
|
-
console.log(r);
|
|
55
|
-
const m = i.getFieldsValue(), o = await s.delete(m[e]);
|
|
56
|
-
c == null || c(), o && i.setFieldsValue({ [e]: null });
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
[i, e, c, l, s]
|
|
60
|
-
), [f, w] = P();
|
|
61
|
-
return V(() => {
|
|
62
|
-
!p && u ? s.getRealUrl(u).then(w) : w(f);
|
|
63
|
-
}, [u, p, s, f]), /* @__PURE__ */ E(
|
|
64
|
-
F.Item,
|
|
65
|
-
{
|
|
66
|
-
rules: t ? H.required(a) : [],
|
|
67
|
-
label: y ? null : a,
|
|
68
|
-
required: t,
|
|
69
|
-
name: e,
|
|
70
|
-
children: [
|
|
71
|
-
/* @__PURE__ */ n(
|
|
72
|
-
K,
|
|
73
|
-
{
|
|
74
|
-
noStyle: !0,
|
|
75
|
-
listType: C,
|
|
76
|
-
aspectRatio: I,
|
|
77
|
-
values: f,
|
|
78
|
-
onRemove: (r) => {
|
|
79
|
-
r && N(r, !1);
|
|
80
|
-
},
|
|
81
|
-
onAdd: async (r) => {
|
|
82
|
-
r && await N(r, !0);
|
|
83
|
-
},
|
|
84
|
-
className: x
|
|
85
|
-
}
|
|
86
|
-
),
|
|
87
|
-
/* @__PURE__ */ n(W, { hidden: !0 })
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
const re = ({ provider: e, value: a }) => {
|
|
93
|
-
const [t, s] = P();
|
|
94
|
-
return V(() => {
|
|
95
|
-
a && e.getRealUrl(a).then(s);
|
|
96
|
-
}, [e, a]), t ? /* @__PURE__ */ n(M, { url: t }) : /* @__PURE__ */ n(S, {});
|
|
97
|
-
}, M = ({ url: e }) => /* @__PURE__ */ n(q, { className: "p-0", children: /* @__PURE__ */ n(
|
|
98
|
-
z,
|
|
99
|
-
{
|
|
100
|
-
className: "m-0 p-0 position-relative",
|
|
101
|
-
src: e,
|
|
102
|
-
preview: {
|
|
103
|
-
mask: /* @__PURE__ */ n(D, {})
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
) });
|
|
107
|
-
export {
|
|
108
|
-
L as FileDownloadProvider,
|
|
109
|
-
ae as FileUploadProvider,
|
|
110
|
-
M as ImageCellValue,
|
|
111
|
-
re as ImageCrudCellValue,
|
|
112
|
-
le as default
|
|
113
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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;
|
package/crud/actions/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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;
|