@servicetitan/form 23.0.2 → 23.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/demo/file-uploader.d.ts.map +1 -1
- package/dist/demo/file-uploader.js +7 -3
- package/dist/demo/file-uploader.js.map +1 -1
- package/dist/file-uploader/config.d.ts +1 -0
- package/dist/file-uploader/config.d.ts.map +1 -1
- package/dist/file-uploader/config.js.map +1 -1
- package/dist/file-uploader/file-uploader.d.ts.map +1 -1
- package/dist/file-uploader/file-uploader.js +1 -1
- package/dist/file-uploader/file-uploader.js.map +1 -1
- package/dist/file-uploader/uploader.d.ts.map +1 -1
- package/dist/file-uploader/uploader.js +4 -1
- package/dist/file-uploader/uploader.js.map +1 -1
- package/package.json +11 -11
- package/src/demo/file-uploader.tsx +28 -11
- package/src/file-uploader/config.tsx +1 -0
- package/src/file-uploader/file-uploader.tsx +1 -2
- package/src/file-uploader/uploader.ts +8 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"file-uploader.d.ts","sourceRoot":"","sources":["../../src/demo/file-uploader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,EAAE,EAAE,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"file-uploader.d.ts","sourceRoot":"","sources":["../../src/demo/file-uploader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,EAAE,EAAE,MAAM,OAAO,CAAC;AAW7C,eAAO,MAAM,mBAAmB,EAAE,EA8EhC,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
2
|
import { useRef, Fragment } from 'react';
|
3
3
|
import { observer } from 'mobx-react';
|
4
|
-
import {
|
4
|
+
import { BodyText } from '@servicetitan/design-system';
|
5
5
|
import { FileUploader, FileUploaderConfigurationProvider } from '..';
|
6
6
|
import { FieldState } from 'formstate';
|
7
7
|
function useFilesField(initial) {
|
@@ -16,10 +16,14 @@ export const FileUploaderExample = observer(() => {
|
|
16
16
|
]);
|
17
17
|
const displayField = useFilesField([{ file: 'display.png' }]);
|
18
18
|
const customField = useFilesField([]);
|
19
|
-
|
19
|
+
const withExtensionValidation = useFilesField([]);
|
20
|
+
return (_jsxs(Fragment, { children: [_jsx(BodyText, Object.assign({ size: "large", className: "m-b-half" }, { children: "Default" })), _jsx(FileUploader, { value: defaultField.value, onChange: defaultField.onChange, folderName: "test" }), _jsx(BodyText, Object.assign({ size: "large", className: "m-t-4 m-b-half" }, { children: "Multiple mode" })), _jsx(FileUploader, { value: multipleField.value, onChange: multipleField.onChange, folderName: "test", multiple: true }), _jsx(BodyText, Object.assign({ size: "large", className: "m-t-4 m-b-half" }, { children: "Display mode" })), _jsx(FileUploader, { value: displayField.value, folderName: "test", multiple: true }), _jsx(BodyText, Object.assign({ size: "large", className: "m-t-4 m-b-half" }, { children: "Custom configuration" })), _jsx(FileUploaderConfigurationProvider, Object.assign({ value: {
|
20
21
|
target: '/Custom/Upload/Url',
|
21
22
|
} }, { children: _jsx(FileUploader, { value: customField.value, onChange: customField.onChange, folderName: "test", multiple: true, config: {
|
22
23
|
simultaneousUploads: 3,
|
23
|
-
} }) }))] }))
|
24
|
+
} }) })), _jsxs(BodyText, Object.assign({ size: "large", className: "m-t-4 m-b-half" }, { children: ["With file extension validation", ' ', _jsx(BodyText, Object.assign({ inline: true, el: "span" }, { children: "Try uploading not png" }))] })), _jsx(FileUploader, { value: withExtensionValidation.value, onChange: withExtensionValidation.onChange, folderName: "test", multiple: true, config: {
|
25
|
+
simultaneousUploads: 3,
|
26
|
+
fileType: ['png'],
|
27
|
+
} })] }));
|
24
28
|
});
|
25
29
|
//# sourceMappingURL=file-uploader.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"file-uploader.js","sourceRoot":"","sources":["../../src/demo/file-uploader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAM,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"file-uploader.js","sourceRoot":"","sources":["../../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EACX,KAAC,YAAY,IACT,KAAK,EAAE,aAAa,CAAC,KAAK,EAC1B,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAChC,UAAU,EAAC,MAAM,EACjB,QAAQ,SACV,EAEF,KAAC,QAAQ,kBAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,gBAAgB,kCAEtC,EACX,KAAC,YAAY,IAAC,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,UAAU,EAAC,MAAM,EAAC,QAAQ,SAAG,EAEtE,KAAC,QAAQ,kBAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,gBAAgB,0CAEtC,EACX,KAAC,iCAAiC,kBAC9B,KAAK,EAAE;oBACH,MAAM,EAAE,oBAAoB;iBAC/B,gBAED,KAAC,YAAY,IACT,KAAK,EAAE,WAAW,CAAC,KAAK,EACxB,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAC9B,UAAU,EAAC,MAAM,EACjB,QAAQ,QACR,MAAM,EAAE;wBACJ,mBAAmB,EAAE,CAAC;qBACzB,GACH,IAC8B,EAEpC,MAAC,QAAQ,kBAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,gBAAgB,mDACd,GAAG,EAClC,KAAC,QAAQ,kBAAC,MAAM,QAAC,EAAE,EAAC,MAAM,2CAEf,KACJ,EAEX,KAAC,YAAY,IACT,KAAK,EAAE,uBAAuB,CAAC,KAAK,EACpC,QAAQ,EAAE,uBAAuB,CAAC,QAAQ,EAC1C,UAAU,EAAC,MAAM,EACjB,QAAQ,QACR,MAAM,EAAE;oBACJ,mBAAmB,EAAE,CAAC;oBACtB,QAAQ,EAAE,CAAC,KAAK,CAAC;iBACpB,GACH,IACK,CACd,CAAC;AACN,CAAC,CAAC,CAAC"}
|
@@ -8,6 +8,7 @@ export interface FileUploaderConfig {
|
|
8
8
|
simultaneousUploads?: number;
|
9
9
|
headers?: Record<string, string>;
|
10
10
|
permanentErrors?: number[];
|
11
|
+
fileType?: string[];
|
11
12
|
errorParser?(error?: string): string;
|
12
13
|
}
|
13
14
|
export declare const FILE_UPLOADER_CONFIGURATION_TOKEN: import("@servicetitan/react-ioc").SymbolToken<FileUploaderConfig>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/file-uploader/config.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxC;AAED,eAAO,MAAM,iCAAiC,mEAE7C,CAAC;AAEF,UAAU,sCAAsC;IAC5C,KAAK,EAAE,kBAAkB,CAAC;CAC7B;AAED,eAAO,MAAM,iCAAiC,EAAE,EAAE,CAAC,sCAAsC,CAOxF,CAAC"}
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/file-uploader/config.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAI3B,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxC;AAED,eAAO,MAAM,iCAAiC,mEAE7C,CAAC;AAEF,UAAU,sCAAsC;IAC5C,KAAK,EAAE,kBAAkB,CAAC;CAC7B;AAED,eAAO,MAAM,iCAAiC,EAAE,EAAE,CAAC,sCAAsC,CAOxF,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/file-uploader/config.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/file-uploader/config.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAehE,MAAM,CAAC,MAAM,iCAAiC,GAAG,WAAW,CACxD,mCAAmC,CACtC,CAAC;AAMF,MAAM,CAAC,MAAM,iCAAiC,GAA+C,CAAC,EAC1F,KAAK,EACL,QAAQ,GACX,EAAE,EAAE,CAAC,CACF,KAAC,QAAQ,kBAAC,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,iCAAiC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,gBAClF,QAAQ,IACF,CACd,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"file-uploader.d.ts","sourceRoot":"","sources":["../../src/file-uploader/file-uploader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgB,MAAM,OAAO,CAAC;AAOhD,OAAO,EAAc,cAAc,EAAU,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGlG,OAA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B,cAAc,SAAU,cAAc,UAWpC;IAEF,cAAc,UAAW,QAAQ,UAa/B;IAEF,aAAa;cAAyC,cAAc;iBAAW,IAAI;eAgBjF;IAEF,YAAY,aAAc,cAAc,UAQtC;IAEF,iBAAiB,aAEf;IAEF,MAAM;CAwDT"}
|
@@ -118,7 +118,6 @@ let FileUploader = class FileUploader extends Component {
|
|
118
118
|
if (!this.props.onChange) {
|
119
119
|
return;
|
120
120
|
}
|
121
|
-
this.uploader.upload(files);
|
122
121
|
this.props.onChange([
|
123
122
|
...this.props.value,
|
124
123
|
...Array.from(files).map(file => ({
|
@@ -126,6 +125,7 @@ let FileUploader = class FileUploader extends Component {
|
|
126
125
|
uploadProgress: 0,
|
127
126
|
})),
|
128
127
|
]);
|
128
|
+
this.uploader.upload(files);
|
129
129
|
}
|
130
130
|
});
|
131
131
|
Object.defineProperty(this, "handleReplace", {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"file-uploader.js","sourceRoot":"","sources":["../../src/file-uploader/file-uploader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAM,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAkB,MAAM,EAAmB,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAsB,iCAAiC,EAAE,MAAM,UAAU,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,SAAS,eAAe,CAAI,G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ACI,YAAY,CA2NxB;SA3NY,YAAY"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/file-uploader/uploader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAsB9C,qBAAa,QAAQ;IACjB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAGlC,MAAM,GAAE,kBAAuB,EAC/B,QAAQ,GAAE;QACN,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9C,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7C,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACzC,EACN,UAAU,SAAY;
|
1
|
+
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/file-uploader/uploader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAsB9C,qBAAa,QAAQ;IACjB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAGlC,MAAM,GAAE,kBAAuB,EAC/B,QAAQ,GAAE;QACN,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9C,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7C,KAAK,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACzC,EACN,UAAU,SAAY;IA4D1B,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ;IAU9B,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI;CAYrB"}
|
@@ -20,7 +20,10 @@ export class Uploader {
|
|
20
20
|
value: void 0
|
21
21
|
});
|
22
22
|
const { errorParser } = config, configuration = __rest(config, ["errorParser"]);
|
23
|
-
const resumable = new Resumable(Object.assign({ target: `/app/api/fileuploader/folders/${folderName}/files`, testChunks: false, simultaneousUploads: 1, headers: { 'X-Requested-With': 'XMLHttpRequest' }, permanentErrors: [302, 400, 404, 415, 500, 501], generateUniqueIdentifier: () => uuid()
|
23
|
+
const resumable = new Resumable(Object.assign({ target: `/app/api/fileuploader/folders/${folderName}/files`, testChunks: false, simultaneousUploads: 1, headers: { 'X-Requested-With': 'XMLHttpRequest' }, permanentErrors: [302, 400, 404, 415, 500, 501], generateUniqueIdentifier: () => uuid(), fileTypeErrorCallback: (file) => {
|
24
|
+
var _a, _b, _c;
|
25
|
+
(_a = handlers.error) === null || _a === void 0 ? void 0 : _a.call(handlers, file, `File type not allowed. Please provide file of type ${(_c = (_b = configuration.fileType) === null || _b === void 0 ? void 0 : _b.map(ext => `.${ext}`)) === null || _c === void 0 ? void 0 : _c.join(', ')}.`);
|
26
|
+
} }, configuration));
|
24
27
|
resumable.on('fileAdded', () => {
|
25
28
|
resumable.upload();
|
26
29
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../src/file-uploader/uploader.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAIlC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAoBzC,MAAM,OAAO,QAAQ;IAGjB,YACI,SAA6B,EAAE,EAC/B,WAII,EAAE,EACN,UAAU,GAAG,SAAS;QAT1B;;;;;WAAsC;QAWlC,MAAM,EAAE,WAAW,KAAuB,MAAM,EAAxB,aAAa,UAAK,MAAM,EAA1C,eAAiC,CAAS,CAAC;QAEjD,MAAM,SAAS,GAAc,IAAI,SAAS,iBACtC,MA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AAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,MAAuB;QAC1B,IAAI,MAAM,YAAY,IAAI,EAAE;YACxB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAClC;aAAM;YACH,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBACnC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAChC;SACJ;IACL,CAAC;IAED,MAAM,CAAC,IAAW;QACd,IAAI,IAAI,EAAE;YACN,KAAK,MAAM,aAAa,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;gBAC9C,IAAI,aAAa,CAAC,IAAI,KAAK,IAAI,EAAE;oBAC7B,aAAa,CAAC,MAAM,EAAE,CAAC;oBACvB,MAAM;iBACT;aACJ;SACJ;aAAM;YACH,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;SAC3B;IACL,CAAC;CACJ"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@servicetitan/form",
|
3
|
-
"version": "23.0.
|
3
|
+
"version": "23.0.4",
|
4
4
|
"description": "",
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/form",
|
6
6
|
"repository": {
|
@@ -16,10 +16,10 @@
|
|
16
16
|
"src"
|
17
17
|
],
|
18
18
|
"devDependencies": {
|
19
|
-
"@servicetitan/confirm": "^23.0.
|
20
|
-
"@servicetitan/culture": "^23.0.
|
19
|
+
"@servicetitan/confirm": "^23.0.4",
|
20
|
+
"@servicetitan/culture": "^23.0.4",
|
21
21
|
"@servicetitan/design-system": ">=12.4.1",
|
22
|
-
"@servicetitan/form-state": "^23.0.
|
22
|
+
"@servicetitan/form-state": "^23.0.4",
|
23
23
|
"@servicetitan/react-ioc": "^21.6.0",
|
24
24
|
"@servicetitan/tokens": ">=12.1.11",
|
25
25
|
"@types/react": "~17.0.38",
|
@@ -35,10 +35,10 @@
|
|
35
35
|
"resumablejs": "~1.0.2"
|
36
36
|
},
|
37
37
|
"peerDependencies": {
|
38
|
-
"@servicetitan/confirm": "^23.0.
|
39
|
-
"@servicetitan/culture": "^23.0.
|
38
|
+
"@servicetitan/confirm": "^23.0.4",
|
39
|
+
"@servicetitan/culture": "^23.0.4",
|
40
40
|
"@servicetitan/design-system": ">=12.4.1",
|
41
|
-
"@servicetitan/form-state": "^23.0.
|
41
|
+
"@servicetitan/form-state": "^23.0.4",
|
42
42
|
"@servicetitan/react-ioc": ">21.0.0",
|
43
43
|
"@servicetitan/tokens": ">=12.1.11",
|
44
44
|
"accounting": "~0.4.1",
|
@@ -51,9 +51,9 @@
|
|
51
51
|
"resumablejs": "~1.0.2"
|
52
52
|
},
|
53
53
|
"dependencies": {
|
54
|
-
"@progress/kendo-licensing": "
|
55
|
-
"@progress/kendo-react-dateinputs": "
|
56
|
-
"@progress/kendo-react-intl": "
|
54
|
+
"@progress/kendo-licensing": "^1.2.0",
|
55
|
+
"@progress/kendo-react-dateinputs": "^5.5.0",
|
56
|
+
"@progress/kendo-react-intl": "^5.5.0",
|
57
57
|
"classnames": "^2.3.1",
|
58
58
|
"debounce": "^1.2.1",
|
59
59
|
"react-input-mask": "~2.0.4",
|
@@ -66,5 +66,5 @@
|
|
66
66
|
"less": true,
|
67
67
|
"webpack": false
|
68
68
|
},
|
69
|
-
"gitHead": "
|
69
|
+
"gitHead": "98782d1348803ce04b82c11d9de3b8ad134ed5a6"
|
70
70
|
}
|
@@ -1,8 +1,6 @@
|
|
1
1
|
import { useRef, Fragment, FC } from 'react';
|
2
|
-
|
3
2
|
import { observer } from 'mobx-react';
|
4
|
-
|
5
|
-
import { Text } from '@servicetitan/design-system';
|
3
|
+
import { BodyText } from '@servicetitan/design-system';
|
6
4
|
import { FileUploader, FileUploaderConfigurationProvider, FileDescriptor } from '..';
|
7
5
|
|
8
6
|
import { FieldState } from 'formstate';
|
@@ -23,21 +21,22 @@ export const FileUploaderExample: FC = observer(() => {
|
|
23
21
|
const displayField = useFilesField([{ file: 'display.png' }]);
|
24
22
|
|
25
23
|
const customField = useFilesField([]);
|
24
|
+
const withExtensionValidation = useFilesField([]);
|
26
25
|
|
27
26
|
return (
|
28
27
|
<Fragment>
|
29
|
-
<
|
28
|
+
<BodyText size="large" className="m-b-half">
|
30
29
|
Default
|
31
|
-
</
|
30
|
+
</BodyText>
|
32
31
|
<FileUploader
|
33
32
|
value={defaultField.value}
|
34
33
|
onChange={defaultField.onChange}
|
35
34
|
folderName="test"
|
36
35
|
/>
|
37
36
|
|
38
|
-
<
|
37
|
+
<BodyText size="large" className="m-t-4 m-b-half">
|
39
38
|
Multiple mode
|
40
|
-
</
|
39
|
+
</BodyText>
|
41
40
|
<FileUploader
|
42
41
|
value={multipleField.value}
|
43
42
|
onChange={multipleField.onChange}
|
@@ -45,14 +44,14 @@ export const FileUploaderExample: FC = observer(() => {
|
|
45
44
|
multiple
|
46
45
|
/>
|
47
46
|
|
48
|
-
<
|
47
|
+
<BodyText size="large" className="m-t-4 m-b-half">
|
49
48
|
Display mode
|
50
|
-
</
|
49
|
+
</BodyText>
|
51
50
|
<FileUploader value={displayField.value} folderName="test" multiple />
|
52
51
|
|
53
|
-
<
|
52
|
+
<BodyText size="large" className="m-t-4 m-b-half">
|
54
53
|
Custom configuration
|
55
|
-
</
|
54
|
+
</BodyText>
|
56
55
|
<FileUploaderConfigurationProvider
|
57
56
|
value={{
|
58
57
|
target: '/Custom/Upload/Url',
|
@@ -68,6 +67,24 @@ export const FileUploaderExample: FC = observer(() => {
|
|
68
67
|
}}
|
69
68
|
/>
|
70
69
|
</FileUploaderConfigurationProvider>
|
70
|
+
|
71
|
+
<BodyText size="large" className="m-t-4 m-b-half">
|
72
|
+
With file extension validation{' '}
|
73
|
+
<BodyText inline el="span">
|
74
|
+
Try uploading not png
|
75
|
+
</BodyText>
|
76
|
+
</BodyText>
|
77
|
+
|
78
|
+
<FileUploader
|
79
|
+
value={withExtensionValidation.value}
|
80
|
+
onChange={withExtensionValidation.onChange}
|
81
|
+
folderName="test"
|
82
|
+
multiple
|
83
|
+
config={{
|
84
|
+
simultaneousUploads: 3,
|
85
|
+
fileType: ['png'],
|
86
|
+
}}
|
87
|
+
/>
|
71
88
|
</Fragment>
|
72
89
|
);
|
73
90
|
});
|
@@ -182,8 +182,6 @@ export class FileUploader extends Component<FileUploaderProps> {
|
|
182
182
|
return;
|
183
183
|
}
|
184
184
|
|
185
|
-
this.uploader.upload(files);
|
186
|
-
|
187
185
|
this.props.onChange([
|
188
186
|
...this.props.value,
|
189
187
|
...Array.from(files).map(file => ({
|
@@ -191,6 +189,7 @@ export class FileUploader extends Component<FileUploaderProps> {
|
|
191
189
|
uploadProgress: 0,
|
192
190
|
})),
|
193
191
|
]);
|
192
|
+
this.uploader.upload(files);
|
194
193
|
};
|
195
194
|
|
196
195
|
handleReplace = ({ file: { file }, newFile }: { file: FileDescriptor; newFile: File }) => {
|
@@ -43,6 +43,14 @@ export class Uploader {
|
|
43
43
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
44
44
|
permanentErrors: [302, 400, 404, 415, 500, 501],
|
45
45
|
generateUniqueIdentifier: () => uuid(),
|
46
|
+
fileTypeErrorCallback: (file: File) => {
|
47
|
+
handlers.error?.(
|
48
|
+
file,
|
49
|
+
`File type not allowed. Please provide file of type ${configuration.fileType
|
50
|
+
?.map(ext => `.${ext}`)
|
51
|
+
?.join(', ')}.`
|
52
|
+
);
|
53
|
+
},
|
46
54
|
...configuration,
|
47
55
|
});
|
48
56
|
|