@salt-ds/lab 1.0.0-alpha.23 → 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.
Files changed (42) hide show
  1. package/css/salt-lab.css +33 -74
  2. package/dist-cjs/color-chooser/ColorPicker.css.js +1 -1
  3. package/dist-cjs/color-chooser/ColorPicker.js +2 -2
  4. package/dist-cjs/color-chooser/ColorPicker.js.map +1 -1
  5. package/dist-cjs/file-drop-zone/FileDropZone.css.js +1 -1
  6. package/dist-cjs/file-drop-zone/FileDropZone.js +32 -132
  7. package/dist-cjs/file-drop-zone/FileDropZone.js.map +1 -1
  8. package/dist-cjs/file-drop-zone/FileDropZoneIcon.js +25 -0
  9. package/dist-cjs/file-drop-zone/FileDropZoneIcon.js.map +1 -0
  10. package/dist-cjs/file-drop-zone/FileDropZoneTrigger.js +52 -0
  11. package/dist-cjs/file-drop-zone/FileDropZoneTrigger.js.map +1 -0
  12. package/dist-cjs/file-drop-zone/internal/utils.js +4 -13
  13. package/dist-cjs/file-drop-zone/internal/utils.js.map +1 -1
  14. package/dist-cjs/index.js +4 -3
  15. package/dist-cjs/index.js.map +1 -1
  16. package/dist-cjs/tabs-next/TabstripNext.css.js +1 -1
  17. package/dist-es/color-chooser/ColorPicker.css.js +1 -1
  18. package/dist-es/color-chooser/ColorPicker.js +2 -2
  19. package/dist-es/color-chooser/ColorPicker.js.map +1 -1
  20. package/dist-es/file-drop-zone/FileDropZone.css.js +1 -1
  21. package/dist-es/file-drop-zone/FileDropZone.js +36 -136
  22. package/dist-es/file-drop-zone/FileDropZone.js.map +1 -1
  23. package/dist-es/file-drop-zone/FileDropZoneIcon.js +21 -0
  24. package/dist-es/file-drop-zone/FileDropZoneIcon.js.map +1 -0
  25. package/dist-es/file-drop-zone/FileDropZoneTrigger.js +48 -0
  26. package/dist-es/file-drop-zone/FileDropZoneTrigger.js.map +1 -0
  27. package/dist-es/file-drop-zone/internal/utils.js +5 -12
  28. package/dist-es/file-drop-zone/internal/utils.js.map +1 -1
  29. package/dist-es/index.js +2 -1
  30. package/dist-es/index.js.map +1 -1
  31. package/dist-es/tabs-next/TabstripNext.css.js +1 -1
  32. package/dist-types/file-drop-zone/FileDropZone.d.ts +7 -44
  33. package/dist-types/file-drop-zone/FileDropZoneIcon.d.ts +9 -0
  34. package/dist-types/file-drop-zone/FileDropZoneTrigger.d.ts +22 -0
  35. package/dist-types/file-drop-zone/index.d.ts +2 -1
  36. package/dist-types/file-drop-zone/internal/utils.d.ts +0 -6
  37. package/package.json +4 -4
  38. package/dist-cjs/file-drop-zone/validators.js +0 -38
  39. package/dist-cjs/file-drop-zone/validators.js.map +0 -1
  40. package/dist-es/file-drop-zone/validators.js +0 -29
  41. package/dist-es/file-drop-zone/validators.js.map +0 -1
  42. package/dist-types/file-drop-zone/validators.d.ts +0 -21
@@ -1,4 +1,4 @@
1
- var css_248z = "/* Component class applied to the root element */\n.saltTabstripNext {\n display: flex;\n flex-wrap: nowrap;\n justify-content: var(--tabstripNext-justifyContent);\n align-items: center;\n position: relative;\n background: transparent;\n width: 100%;\n padding-left: var(--salt-spacing-300);\n padding-right: var(--salt-spacing-300);\n\n font-family: var(--salt-text-fontFamily);\n font-size: var(--salt-text-fontSize);\n font-weight: var(--salt-text-fontWeight);\n line-height: var(--salt-text-lineHeight);\n}\n\n.saltTabstripNext-main::before {\n content: \"\";\n position: absolute;\n inset: auto 0 0 0;\n height: var(--salt-size-border);\n border-bottom: var(--salt-size-border) var(--salt-container-borderStyle) var(--salt-container-primary-borderColor);\n}\n\n.saltTabstripNext .saltTabNext-wrapper:not(:last-child) {\n padding-right: var(--salt-spacing-100);\n}\n";
1
+ var css_248z = "/* Component class applied to the root element */\n.saltTabstripNext {\n display: flex;\n flex-wrap: nowrap;\n justify-content: var(--tabstripNext-justifyContent);\n align-items: center;\n position: relative;\n background: transparent;\n width: 100%;\n\n font-family: var(--salt-text-fontFamily);\n font-size: var(--salt-text-fontSize);\n font-weight: var(--salt-text-fontWeight);\n line-height: var(--salt-text-lineHeight);\n}\n\n.saltTabstripNext-main {\n padding-left: var(--salt-spacing-300);\n padding-right: var(--salt-spacing-300);\n}\n\n.saltTabstripNext-main::before {\n content: \"\";\n position: absolute;\n inset: auto 0 0 0;\n height: var(--salt-size-border);\n border-bottom: var(--salt-size-border) var(--salt-container-borderStyle) var(--salt-container-primary-borderColor);\n}\n\n.saltTabstripNext .saltTabNext-wrapper:not(:last-child) {\n padding-right: var(--salt-spacing-100);\n}\n";
2
2
 
3
3
  export { css_248z as default };
4
4
  //# sourceMappingURL=TabstripNext.css.js.map
@@ -1,54 +1,17 @@
1
- import { HTMLAttributes, ReactNode, SyntheticEvent } from "react";
2
- import { FilesValidator } from "./validators";
3
- export declare type FilesAcceptedEventHandler = (files: ReadonlyArray<File>, event: SyntheticEvent) => void;
4
- export declare type FilesRejectedEventHandler<ErrorType = string> = (errors: ReadonlyArray<ErrorType>, event: SyntheticEvent) => void;
5
- /**
6
- * Removed deprecated props
7
- *
8
- * - onDrop
9
- * - onFileTypeError
10
- * - showUploadButton
11
- */
12
- export interface FileDropZoneProps extends HTMLAttributes<HTMLDivElement> {
13
- /**
14
- * `accept` attribute for HTML <input>.
15
- *
16
- * A comma separated list of file types the user can pick from the file input dialog box.
17
- */
18
- accept?: string;
19
- /**
20
- * The text content of the drop area component.
21
- */
22
- children?: ReactNode;
23
- /**
24
- * Additional usage information.
25
- */
26
- description?: string;
1
+ import { ValidationStatus } from "@salt-ds/core";
2
+ import { DragEvent, ComponentPropsWithoutRef } from "react";
3
+ export interface FileDropZoneProps extends Omit<ComponentPropsWithoutRef<"div">, "onDrop"> {
27
4
  /**
28
5
  * If `true`, the file drop zone will be disabled.
29
6
  */
30
7
  disabled?: boolean;
31
8
  /**
32
- * This prop is used to help implement the accessibility logic.
33
- * If you don't provide this prop. It falls back to a randomly generated id.
34
- */
35
- id?: string;
36
- /**
37
- * Callback on successful file drop or selection.
38
- */
39
- onFilesAccepted?: FilesAcceptedEventHandler;
40
- /**
41
- * @see `validate` prop
42
- * Callback on drop or input in case of an error. A list of errors will be provided as input.
9
+ * Status indicator to be displayed.
43
10
  */
44
- onFilesRejected?: FilesRejectedEventHandler;
11
+ status?: Omit<ValidationStatus, "info" | "warning">;
45
12
  /**
46
- * A list of custom validation functions. Every function is provided with the entire file list as input
47
- * thus can perform validations on all files. Each function needs to return one or more errors in case of
48
- * a failed validation, or `undefined` in case of a successful one.
49
- *
50
- * All errors are collected in the end and returned as an array to `onFilesRejected`.
13
+ * Callback for on drop event
51
14
  */
52
- validate?: ReadonlyArray<FilesValidator<any>>;
15
+ onDrop?: (event: DragEvent<HTMLDivElement>, files: File[]) => void;
53
16
  }
54
17
  export declare const FileDropZone: import("react").ForwardRefExoticComponent<FileDropZoneProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,9 @@
1
+ import { ValidationStatus } from "@salt-ds/core";
2
+ import { IconProps } from "@salt-ds/icons";
3
+ export interface FileDropZoneIconProps extends IconProps {
4
+ /**
5
+ * Status indicator to be displayed.
6
+ */
7
+ status?: ValidationStatus;
8
+ }
9
+ export declare const FileDropZoneIcon: import("react").ForwardRefExoticComponent<FileDropZoneIconProps & import("react").RefAttributes<SVGSVGElement>>;
@@ -0,0 +1,22 @@
1
+ import { HTMLAttributes, SyntheticEvent } from "react";
2
+ export interface FileDropZoneTriggerProps extends Omit<HTMLAttributes<HTMLButtonElement>, "onChange"> {
3
+ /**
4
+ * `accept` attribute for HTML <input>.
5
+ *
6
+ * A comma separated list of file types the user can pick from the file input dialog box.
7
+ */
8
+ accept?: string;
9
+ /**
10
+ * Disable all trigger elements.
11
+ */
12
+ disabled?: boolean;
13
+ /**
14
+ * Allows multiple files to be uploaded.
15
+ */
16
+ multiple?: boolean;
17
+ /**
18
+ * Callback for input change event
19
+ */
20
+ onChange?: (event: SyntheticEvent<HTMLInputElement>, files: File[]) => void;
21
+ }
22
+ export declare const FileDropZoneTrigger: import("react").ForwardRefExoticComponent<FileDropZoneTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -1,2 +1,3 @@
1
1
  export * from "./FileDropZone";
2
- export * from "./validators";
2
+ export * from "./FileDropZoneIcon";
3
+ export * from "./FileDropZoneTrigger";
@@ -1,9 +1,3 @@
1
1
  import { DragEvent } from "react";
2
- import { FilesValidator } from "../validators";
3
- export declare const toArray: (obj: any) => any[];
4
2
  export declare const containsFiles: (e: DragEvent) => boolean | FileList | null;
5
3
  export declare const extractFiles: (e: DragEvent) => File[];
6
- export declare const validateFiles: ({ files, validate, }: {
7
- files: ReadonlyArray<File>;
8
- validate: ReadonlyArray<FilesValidator>;
9
- }) => string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salt-ds/lab",
3
- "version": "1.0.0-alpha.23",
3
+ "version": "1.0.0-alpha.25",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,10 +26,10 @@
26
26
  "react-window": "^1.8.6",
27
27
  "rifm": "^0.12.0",
28
28
  "tinycolor2": "^1.4.2",
29
- "@salt-ds/core": "^1.13.1",
29
+ "@salt-ds/core": "^1.13.3",
30
30
  "@salt-ds/window": "^0.1.1",
31
- "@salt-ds/styles": "^0.2.0",
32
- "@salt-ds/icons": "^1.8.0"
31
+ "@salt-ds/styles": "^0.2.1",
32
+ "@salt-ds/icons": "^1.9.1"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@types/react": ">=16.14.0",
@@ -1,38 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var accepts = require('attr-accept');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var accepts__default = /*#__PURE__*/_interopDefaultLegacy(accepts);
10
-
11
- function createFileTypeValidator({
12
- accept,
13
- getError
14
- }) {
15
- return (files) => {
16
- const validate = (file) => {
17
- if (!accepts__default["default"](file, accept)) {
18
- return getError ? getError(file) : `File ${file.name} does not have an accepted type.`;
19
- }
20
- };
21
- return files.map(validate);
22
- };
23
- }
24
- function createTotalSizeValidator({
25
- maxSize,
26
- getError
27
- }) {
28
- return (files) => {
29
- const totalSize = files.reduce((size, file) => size + file.size, 0);
30
- if (totalSize > maxSize) {
31
- return getError ? getError(totalSize) : `The file/s exceed the maximum upload limit of ${maxSize} bytes.`;
32
- }
33
- };
34
- }
35
-
36
- exports.createFileTypeValidator = createFileTypeValidator;
37
- exports.createTotalSizeValidator = createTotalSizeValidator;
38
- //# sourceMappingURL=validators.js.map
@@ -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":["accepts"],"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,CAACA,2BAAA,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,29 +0,0 @@
1
- import accepts from 'attr-accept';
2
-
3
- function createFileTypeValidator({
4
- accept,
5
- getError
6
- }) {
7
- return (files) => {
8
- const validate = (file) => {
9
- if (!accepts(file, accept)) {
10
- return getError ? getError(file) : `File ${file.name} does not have an accepted type.`;
11
- }
12
- };
13
- return files.map(validate);
14
- };
15
- }
16
- function createTotalSizeValidator({
17
- maxSize,
18
- getError
19
- }) {
20
- return (files) => {
21
- const totalSize = files.reduce((size, file) => size + file.size, 0);
22
- if (totalSize > maxSize) {
23
- return getError ? getError(totalSize) : `The file/s exceed the maximum upload limit of ${maxSize} bytes.`;
24
- }
25
- };
26
- }
27
-
28
- export { createFileTypeValidator, createTotalSizeValidator };
29
- //# sourceMappingURL=validators.js.map
@@ -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>;