@salt-ds/lab 1.0.0-alpha.24 → 1.0.0-alpha.25
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/css/salt-lab.css +22 -65
- package/dist-cjs/file-drop-zone/FileDropZone.css.js +1 -1
- package/dist-cjs/file-drop-zone/FileDropZone.js +32 -132
- package/dist-cjs/file-drop-zone/FileDropZone.js.map +1 -1
- package/dist-cjs/file-drop-zone/FileDropZoneIcon.js +25 -0
- package/dist-cjs/file-drop-zone/FileDropZoneIcon.js.map +1 -0
- package/dist-cjs/file-drop-zone/FileDropZoneTrigger.js +52 -0
- package/dist-cjs/file-drop-zone/FileDropZoneTrigger.js.map +1 -0
- package/dist-cjs/file-drop-zone/internal/utils.js +4 -13
- package/dist-cjs/file-drop-zone/internal/utils.js.map +1 -1
- package/dist-cjs/index.js +4 -3
- package/dist-cjs/index.js.map +1 -1
- package/dist-es/file-drop-zone/FileDropZone.css.js +1 -1
- package/dist-es/file-drop-zone/FileDropZone.js +36 -136
- package/dist-es/file-drop-zone/FileDropZone.js.map +1 -1
- package/dist-es/file-drop-zone/FileDropZoneIcon.js +21 -0
- package/dist-es/file-drop-zone/FileDropZoneIcon.js.map +1 -0
- package/dist-es/file-drop-zone/FileDropZoneTrigger.js +48 -0
- package/dist-es/file-drop-zone/FileDropZoneTrigger.js.map +1 -0
- package/dist-es/file-drop-zone/internal/utils.js +5 -12
- package/dist-es/file-drop-zone/internal/utils.js.map +1 -1
- package/dist-es/index.js +2 -1
- package/dist-es/index.js.map +1 -1
- package/dist-types/file-drop-zone/FileDropZone.d.ts +7 -44
- package/dist-types/file-drop-zone/FileDropZoneIcon.d.ts +9 -0
- package/dist-types/file-drop-zone/FileDropZoneTrigger.d.ts +22 -0
- package/dist-types/file-drop-zone/index.d.ts +2 -1
- package/dist-types/file-drop-zone/internal/utils.d.ts +0 -6
- package/package.json +4 -4
- package/dist-cjs/file-drop-zone/validators.js +0 -38
- package/dist-cjs/file-drop-zone/validators.js.map +0 -1
- package/dist-es/file-drop-zone/validators.js +0 -29
- package/dist-es/file-drop-zone/validators.js.map +0 -1
- package/dist-types/file-drop-zone/validators.d.ts +0 -21
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sources":["../src/file-drop-zone/validators.ts"],"sourcesContent":["// TODO: verify whether we still needs to this library\n// HTML5's `accept` should be ok for the browsers we want to support.\nimport accepts from \"attr-accept\";\n\nexport type FilesValidator<ErrorType = string> = (\n files: ReadonlyArray<File>\n) =>\n | ReadonlyArray<ErrorType | string | undefined>\n | ErrorType\n | string\n | undefined;\n\n/**\n * Factory method for creating a common file type validator.\n *\n * @param {string} accept - It is the same as 'accept' attribute for HTML <input>.\n * @param {function} getError - A callback function for generating a customised user error.\n */\nexport function createFileTypeValidator<ErrorType = string>({\n accept,\n getError,\n}: {\n accept: string;\n getError?: (file: File) => ErrorType;\n}): FilesValidator<ErrorType> {\n return (files) => {\n const validate = (file: File) => {\n if (!accepts(file, accept)) {\n return getError\n ? getError(file)\n : `File ${file.name} does not have an accepted type.`;\n }\n };\n\n return files.map(validate);\n };\n}\n\n/**\n * Factory method for creating a common total selection size validator.\n *\n * @param {number} maxSize - Max selection size in bytes.\n * @param {function} getError - A callback function for generating a customised user error.\n */\nexport function createTotalSizeValidator<ErrorType = string>({\n maxSize,\n getError,\n}: {\n maxSize: number;\n getError?: (totalSize: number) => ErrorType;\n}): FilesValidator<ErrorType> {\n return (files) => {\n const totalSize = files.reduce((size, file) => size + file.size, 0);\n\n if (totalSize > maxSize) {\n return getError\n ? getError(totalSize)\n : `The file/s exceed the maximum upload limit of ${maxSize} bytes.`;\n }\n };\n}\n"],"names":[],"mappings":";;AAkBO,SAAS,uBAA4C,CAAA;AAAA,EAC1D,MAAA;AAAA,EACA,QAAA;AACF,CAG8B,EAAA;AAC5B,EAAA,OAAO,CAAC,KAAU,KAAA;AAChB,IAAM,MAAA,QAAA,GAAW,CAAC,IAAe,KAAA;AAC/B,MAAA,IAAI,CAAC,OAAA,CAAQ,IAAM,EAAA,MAAM,CAAG,EAAA;AAC1B,QAAA,OAAO,QACH,GAAA,QAAA,CAAS,IAAI,CAAA,GACb,QAAQ,IAAK,CAAA,IAAA,CAAA,gCAAA,CAAA,CAAA;AAAA,OACnB;AAAA,KACF,CAAA;AAEA,IAAO,OAAA,KAAA,CAAM,IAAI,QAAQ,CAAA,CAAA;AAAA,GAC3B,CAAA;AACF,CAAA;AAQO,SAAS,wBAA6C,CAAA;AAAA,EAC3D,OAAA;AAAA,EACA,QAAA;AACF,CAG8B,EAAA;AAC5B,EAAA,OAAO,CAAC,KAAU,KAAA;AAChB,IAAM,MAAA,SAAA,GAAY,MAAM,MAAO,CAAA,CAAC,MAAM,IAAS,KAAA,IAAA,GAAO,IAAK,CAAA,IAAA,EAAM,CAAC,CAAA,CAAA;AAElE,IAAA,IAAI,YAAY,OAAS,EAAA;AACvB,MAAA,OAAO,QACH,GAAA,QAAA,CAAS,SAAS,CAAA,GAClB,CAAiD,8CAAA,EAAA,OAAA,CAAA,OAAA,CAAA,CAAA;AAAA,KACvD;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare type FilesValidator<ErrorType = string> = (files: ReadonlyArray<File>) => ReadonlyArray<ErrorType | string | undefined> | ErrorType | string | undefined;
|
|
2
|
-
/**
|
|
3
|
-
* Factory method for creating a common file type validator.
|
|
4
|
-
*
|
|
5
|
-
* @param {string} accept - It is the same as 'accept' attribute for HTML <input>.
|
|
6
|
-
* @param {function} getError - A callback function for generating a customised user error.
|
|
7
|
-
*/
|
|
8
|
-
export declare function createFileTypeValidator<ErrorType = string>({ accept, getError, }: {
|
|
9
|
-
accept: string;
|
|
10
|
-
getError?: (file: File) => ErrorType;
|
|
11
|
-
}): FilesValidator<ErrorType>;
|
|
12
|
-
/**
|
|
13
|
-
* Factory method for creating a common total selection size validator.
|
|
14
|
-
*
|
|
15
|
-
* @param {number} maxSize - Max selection size in bytes.
|
|
16
|
-
* @param {function} getError - A callback function for generating a customised user error.
|
|
17
|
-
*/
|
|
18
|
-
export declare function createTotalSizeValidator<ErrorType = string>({ maxSize, getError, }: {
|
|
19
|
-
maxSize: number;
|
|
20
|
-
getError?: (totalSize: number) => ErrorType;
|
|
21
|
-
}): FilesValidator<ErrorType>;
|