@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.
Files changed (34) hide show
  1. package/css/salt-lab.css +22 -65
  2. package/dist-cjs/file-drop-zone/FileDropZone.css.js +1 -1
  3. package/dist-cjs/file-drop-zone/FileDropZone.js +32 -132
  4. package/dist-cjs/file-drop-zone/FileDropZone.js.map +1 -1
  5. package/dist-cjs/file-drop-zone/FileDropZoneIcon.js +25 -0
  6. package/dist-cjs/file-drop-zone/FileDropZoneIcon.js.map +1 -0
  7. package/dist-cjs/file-drop-zone/FileDropZoneTrigger.js +52 -0
  8. package/dist-cjs/file-drop-zone/FileDropZoneTrigger.js.map +1 -0
  9. package/dist-cjs/file-drop-zone/internal/utils.js +4 -13
  10. package/dist-cjs/file-drop-zone/internal/utils.js.map +1 -1
  11. package/dist-cjs/index.js +4 -3
  12. package/dist-cjs/index.js.map +1 -1
  13. package/dist-es/file-drop-zone/FileDropZone.css.js +1 -1
  14. package/dist-es/file-drop-zone/FileDropZone.js +36 -136
  15. package/dist-es/file-drop-zone/FileDropZone.js.map +1 -1
  16. package/dist-es/file-drop-zone/FileDropZoneIcon.js +21 -0
  17. package/dist-es/file-drop-zone/FileDropZoneIcon.js.map +1 -0
  18. package/dist-es/file-drop-zone/FileDropZoneTrigger.js +48 -0
  19. package/dist-es/file-drop-zone/FileDropZoneTrigger.js.map +1 -0
  20. package/dist-es/file-drop-zone/internal/utils.js +5 -12
  21. package/dist-es/file-drop-zone/internal/utils.js.map +1 -1
  22. package/dist-es/index.js +2 -1
  23. package/dist-es/index.js.map +1 -1
  24. package/dist-types/file-drop-zone/FileDropZone.d.ts +7 -44
  25. package/dist-types/file-drop-zone/FileDropZoneIcon.d.ts +9 -0
  26. package/dist-types/file-drop-zone/FileDropZoneTrigger.d.ts +22 -0
  27. package/dist-types/file-drop-zone/index.d.ts +2 -1
  28. package/dist-types/file-drop-zone/internal/utils.d.ts +0 -6
  29. package/package.json +4 -4
  30. package/dist-cjs/file-drop-zone/validators.js +0 -38
  31. package/dist-cjs/file-drop-zone/validators.js.map +0 -1
  32. package/dist-es/file-drop-zone/validators.js +0 -29
  33. package/dist-es/file-drop-zone/validators.js.map +0 -1
  34. package/dist-types/file-drop-zone/validators.d.ts +0 -21
@@ -1,27 +1,22 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { makePrefixer, useId, Button } from '@salt-ds/core';
3
- import { ErrorIcon, UploadIcon } from '@salt-ds/icons';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { makePrefixer, useForkRef } from '@salt-ds/core';
4
3
  import { clsx } from 'clsx';
5
- import { forwardRef, useState, useRef, useEffect, useCallback } from 'react';
6
- import { containsFiles, extractFiles, validateFiles } from './internal/utils.js';
4
+ import { forwardRef, useState, useRef } from 'react';
5
+ import { containsFiles, extractFiles } from './internal/utils.js';
7
6
  import { useWindow } from '@salt-ds/window';
8
7
  import { useComponentCssInjection } from '@salt-ds/styles';
9
8
  import css_248z from './FileDropZone.css.js';
10
9
 
11
- const buttonLabel = "Browse files";
12
- const INVALID_DROP_TARGET = "Drop target doesn't contain any file.";
13
10
  const withBaseName = makePrefixer("saltFileDropZone");
14
11
  const FileDropZone = forwardRef(
15
12
  function FileDropZone2({
16
- accept,
13
+ status,
17
14
  className,
18
15
  children,
19
- description,
20
16
  disabled,
21
- id: idProp,
22
- validate,
23
- onFilesAccepted,
24
- onFilesRejected,
17
+ onDragOver,
18
+ onDragLeave,
19
+ onDrop,
25
20
  ...restProps
26
21
  }, ref) {
27
22
  const targetWindow = useWindow();
@@ -30,158 +25,63 @@ const FileDropZone = forwardRef(
30
25
  css: css_248z,
31
26
  window: targetWindow
32
27
  });
33
- const id = useId(idProp);
34
- const iconId = `${id}-icon`;
35
- const buttonId = `${id}-button`;
36
- const descriptionId = `${id}-description`;
37
- const [dropResult, setDropResult] = useState(null);
38
28
  const [isActive, setActive] = useState(false);
39
- const [isRejected, setRejected] = useState(false);
40
- const buttonRef = useRef(null);
41
- const fileInputRef = useRef(null);
42
- useEffect(() => {
43
- if (!disabled && dropResult) {
44
- const { event, files, errors } = dropResult;
45
- if (errors && errors.length !== 0) {
46
- setRejected(true);
47
- if (!!onFilesRejected) {
48
- return onFilesRejected(errors, event);
49
- }
50
- }
51
- setRejected(false);
52
- return onFilesAccepted == null ? void 0 : onFilesAccepted(files, event);
53
- }
54
- }, [disabled, dropResult, onFilesAccepted, onFilesRejected]);
29
+ const regionRef = useRef(null);
30
+ const handleRef = useForkRef(ref, regionRef);
55
31
  const handleDragOver = (event) => {
56
32
  event.preventDefault();
57
33
  event.stopPropagation();
58
34
  if (disabled) {
59
- event.dataTransfer && (event.dataTransfer.dropEffect = "none");
35
+ if (event.dataTransfer) {
36
+ event.dataTransfer.dropEffect = "none";
37
+ }
60
38
  return;
61
- } else {
62
- event.dataTransfer && (event.dataTransfer.dropEffect = "copy");
39
+ }
40
+ if (event.dataTransfer) {
41
+ event.dataTransfer.dropEffect = "copy";
63
42
  }
64
43
  if (!isActive && containsFiles(event)) {
65
44
  setActive(true);
66
45
  }
46
+ onDragOver == null ? void 0 : onDragOver(event);
67
47
  };
68
- const handleDragLeave = () => setActive(false);
69
- const handleFilesDrop = (event) => {
70
- if (!containsFiles(event)) {
71
- return setDropResult({
72
- event,
73
- errors: [INVALID_DROP_TARGET]
74
- });
48
+ const handleDragLeave = (event) => {
49
+ if (disabled) {
50
+ return;
75
51
  }
76
- const files = extractFiles(event);
77
- if (files.length > 0) {
78
- return setDropResult({
79
- event,
80
- files,
81
- errors: validate ? validateFiles({ files, validate }) : []
82
- });
52
+ const region = regionRef == null ? void 0 : regionRef.current;
53
+ const eventTarget = event.relatedTarget;
54
+ if (eventTarget !== region && !(region == null ? void 0 : region.contains(eventTarget))) {
55
+ setActive(false);
83
56
  }
57
+ onDragLeave == null ? void 0 : onDragLeave(event);
84
58
  };
85
59
  const handleDrop = (event) => {
60
+ if (disabled) {
61
+ return;
62
+ }
86
63
  event.preventDefault();
87
- event.stopPropagation();
88
- handleFilesDrop(event);
64
+ const files = extractFiles(event);
89
65
  setActive(false);
66
+ onDrop == null ? void 0 : onDrop(event, files);
90
67
  };
91
- const handleInputChange = (event) => {
92
- event.stopPropagation();
93
- handleFilesDrop(event);
94
- };
95
- const handleInputFocus = useCallback(
96
- (event) => {
97
- event.stopPropagation();
98
- buttonRef.current && buttonRef.current.focus();
99
- },
100
- []
101
- );
102
- const handleInputClick = useCallback(
103
- (event) => {
104
- event.stopPropagation();
105
- fileInputRef.current && fileInputRef.current.click();
106
- },
107
- []
108
- );
109
- const handleKeyDown = useCallback(
110
- (event) => {
111
- if (["Enter", "Space"].indexOf(event.key) !== -1) {
112
- fileInputRef.current && fileInputRef.current.click();
113
- }
114
- },
115
- []
116
- );
117
- const fileDropZoneDescription = description ? /* @__PURE__ */ jsx("div", {
118
- className: "saltFileDropZone-description",
119
- id: descriptionId,
120
- children: description
121
- }) : null;
122
- const buttonLabelledBy = (isRejected ? [buttonId, iconId, descriptionId] : [buttonId, descriptionId]).join(" ");
123
- return /* @__PURE__ */ jsxs("div", {
124
- ...restProps,
68
+ return /* @__PURE__ */ jsx("div", {
125
69
  className: clsx(
126
70
  withBaseName(),
127
71
  {
128
- [withBaseName("error")]: isRejected,
72
+ [withBaseName(status)]: status,
129
73
  [withBaseName("active")]: isActive,
130
74
  [withBaseName("disabled")]: disabled
131
75
  },
132
76
  className
133
77
  ),
78
+ "aria-disabled": disabled,
134
79
  onDragLeave: handleDragLeave,
135
80
  onDragOver: handleDragOver,
136
81
  onDrop: handleDrop,
137
- ref,
138
- children: [
139
- /* @__PURE__ */ jsxs("div", {
140
- "aria-live": "polite",
141
- children: [
142
- isRejected ? /* @__PURE__ */ jsx(ErrorIcon, {
143
- "aria-label": "error!",
144
- className: withBaseName("icon"),
145
- size: 2
146
- }) : /* @__PURE__ */ jsx(UploadIcon, {
147
- className: withBaseName("icon"),
148
- size: 2
149
- }),
150
- isRejected && fileDropZoneDescription
151
- ]
152
- }),
153
- /* @__PURE__ */ jsx("div", {
154
- className: withBaseName("title"),
155
- children: children || "Drop files here or"
156
- }),
157
- /* @__PURE__ */ jsxs("label", {
158
- className: withBaseName("inputRoot"),
159
- children: [
160
- /* @__PURE__ */ jsx(Button, {
161
- "aria-labelledby": buttonLabelledBy,
162
- ref: buttonRef,
163
- className: withBaseName("inputButton"),
164
- "data-testid": "file-input-button",
165
- disabled,
166
- onKeyDown: handleKeyDown,
167
- onClick: handleInputClick,
168
- children: buttonLabel.toUpperCase()
169
- }),
170
- /* @__PURE__ */ jsx("input", {
171
- accept,
172
- className: "input-hidden",
173
- "data-testid": "file-input",
174
- disabled,
175
- multiple: true,
176
- onChange: handleInputChange,
177
- onFocus: handleInputFocus,
178
- ref: fileInputRef,
179
- type: "file"
180
- })
181
- ]
182
- }),
183
- !isRejected && fileDropZoneDescription
184
- ]
82
+ ref: handleRef,
83
+ ...restProps,
84
+ children
185
85
  });
186
86
  }
187
87
  );
@@ -1 +1 @@
1
- {"version":3,"file":"FileDropZone.js","sources":["../src/file-drop-zone/FileDropZone.tsx"],"sourcesContent":["import { Button, makePrefixer, useId } from \"@salt-ds/core\";\nimport { ErrorIcon, UploadIcon } from \"@salt-ds/icons\";\nimport { clsx } from \"clsx\";\nimport {\n ChangeEventHandler,\n DragEvent,\n DragEventHandler,\n FocusEvent,\n forwardRef,\n HTMLAttributes,\n KeyboardEvent,\n ReactNode,\n SyntheticEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { containsFiles, extractFiles, validateFiles } from \"./internal/utils\";\nimport { FilesValidator } from \"./validators\";\n\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nimport fileDropZoneCss from \"./FileDropZone.css\";\n\n// Recommended button label by ADA review\nconst buttonLabel = \"Browse files\";\nconst INVALID_DROP_TARGET = \"Drop target doesn't contain any file.\";\n\nexport type FilesAcceptedEventHandler = (\n files: ReadonlyArray<File>,\n event: SyntheticEvent\n) => void;\n\nexport type FilesRejectedEventHandler<ErrorType = string> = (\n errors: ReadonlyArray<ErrorType>,\n event: SyntheticEvent\n) => void;\n\n/**\n * Removed deprecated props\n *\n * - onDrop\n * - onFileTypeError\n * - showUploadButton\n */\n\nexport interface FileDropZoneProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * `accept` attribute for HTML <input>.\n *\n * A comma separated list of file types the user can pick from the file input dialog box.\n */\n accept?: string;\n\n /**\n * The text content of the drop area component.\n */\n children?: ReactNode;\n\n /**\n * Additional usage information.\n */\n description?: string;\n\n /**\n * If `true`, the file drop zone will be disabled.\n */\n disabled?: boolean;\n\n /**\n * This prop is used to help implement the accessibility logic.\n * If you don't provide this prop. It falls back to a randomly generated id.\n */\n id?: string;\n\n /**\n * Callback on successful file drop or selection.\n */\n onFilesAccepted?: FilesAcceptedEventHandler;\n\n /**\n * @see `validate` prop\n * Callback on drop or input in case of an error. A list of errors will be provided as input.\n */\n onFilesRejected?: FilesRejectedEventHandler;\n\n /**\n * A list of custom validation functions. Every function is provided with the entire file list as input\n * thus can perform validations on all files. Each function needs to return one or more errors in case of\n * a failed validation, or `undefined` in case of a successful one.\n *\n * All errors are collected in the end and returned as an array to `onFilesRejected`.\n */\n validate?: ReadonlyArray<FilesValidator<any>>;\n}\n\nconst withBaseName = makePrefixer(\"saltFileDropZone\");\n\nexport const FileDropZone = forwardRef<HTMLDivElement, FileDropZoneProps>(\n function FileDropZone(\n {\n accept,\n className,\n children,\n description,\n disabled,\n id: idProp,\n validate,\n onFilesAccepted,\n onFilesRejected,\n ...restProps\n },\n ref\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-file-drop-zone\",\n css: fileDropZoneCss,\n window: targetWindow,\n });\n\n const id = useId(idProp);\n\n const iconId = `${id}-icon`;\n const buttonId = `${id}-button`;\n const descriptionId = `${id}-description`;\n\n const [dropResult, setDropResult] = useState<null | {\n event: SyntheticEvent;\n files?: ReadonlyArray<File>;\n errors: string[];\n }>(null);\n const [isActive, setActive] = useState(false);\n const [isRejected, setRejected] = useState(false);\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (!disabled && dropResult) {\n const { event, files, errors } = dropResult;\n\n if (errors && errors.length !== 0) {\n setRejected(true);\n if (!!onFilesRejected) {\n return onFilesRejected(errors, event);\n }\n }\n\n setRejected(false);\n return onFilesAccepted?.(files!, event);\n }\n }, [disabled, dropResult, onFilesAccepted, onFilesRejected]);\n\n const handleDragOver: DragEventHandler<HTMLDivElement> = (event) => {\n // Need to cancel the default events to allow drop\n // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#droptargets\n event.preventDefault();\n event.stopPropagation();\n\n if (disabled) {\n event.dataTransfer && (event.dataTransfer.dropEffect = \"none\");\n return;\n } else {\n // Not using 'move', otherwise apps like Outlook will delete the item\n event.dataTransfer && (event.dataTransfer.dropEffect = \"copy\");\n }\n\n if (!isActive && containsFiles(event)) {\n setActive(true);\n }\n };\n\n const handleDragLeave = () => setActive(false);\n\n const handleFilesDrop = (event: SyntheticEvent) => {\n if (!containsFiles(event as DragEvent)) {\n return setDropResult({\n event,\n errors: [INVALID_DROP_TARGET],\n });\n }\n\n const files = extractFiles(event as DragEvent);\n\n if (files.length > 0) {\n return setDropResult({\n event,\n files,\n errors: validate ? validateFiles({ files, validate }) : [],\n });\n }\n };\n\n const handleDrop: DragEventHandler<HTMLDivElement> = (event) => {\n event.preventDefault();\n event.stopPropagation();\n\n handleFilesDrop(event);\n setActive(false);\n };\n\n const handleInputChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n event.stopPropagation();\n\n handleFilesDrop(event);\n };\n\n // As an ADA requirement when dialog is closed and the focus is returned to the input, we need to\n // move focus back on the button element so that all labels can be announced correctly\n const handleInputFocus = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n event.stopPropagation();\n buttonRef.current && buttonRef.current.focus();\n },\n []\n );\n\n const handleInputClick = useCallback(\n (event: SyntheticEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n fileInputRef.current && fileInputRef.current.click();\n },\n []\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLButtonElement>) => {\n if ([\"Enter\", \"Space\"].indexOf(event.key) !== -1) {\n fileInputRef.current && fileInputRef.current.click();\n }\n },\n []\n );\n\n const fileDropZoneDescription = description ? (\n <div className=\"saltFileDropZone-description\" id={descriptionId}>\n {description}\n </div>\n ) : null;\n\n const buttonLabelledBy = (\n isRejected ? [buttonId, iconId, descriptionId] : [buttonId, descriptionId]\n ).join(\" \");\n\n return (\n <div\n {...restProps}\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"error\")]: isRejected,\n [withBaseName(\"active\")]: isActive,\n [withBaseName(\"disabled\")]: disabled,\n },\n className\n )}\n onDragLeave={handleDragLeave}\n onDragOver={handleDragOver}\n onDrop={handleDrop}\n ref={ref}\n >\n {/* TODO: Check whether we want to replace this with aria announce */}\n <div aria-live=\"polite\">\n {/*\n * It is an ADA requirement to always display an input button.-\n */}\n {isRejected ? (\n <ErrorIcon\n aria-label=\"error!\"\n className={withBaseName(\"icon\")}\n size={2}\n />\n ) : (\n <UploadIcon className={withBaseName(\"icon\")} size={2} />\n )}\n {isRejected && fileDropZoneDescription}\n </div>\n <div className={withBaseName(\"title\")}>\n {children || \"Drop files here or\"}\n </div>\n <label className={withBaseName(\"inputRoot\")}>\n <Button\n aria-labelledby={buttonLabelledBy}\n ref={buttonRef}\n className={withBaseName(\"inputButton\")}\n data-testid=\"file-input-button\"\n disabled={disabled}\n onKeyDown={handleKeyDown}\n onClick={handleInputClick}\n >\n {/* TODO: expose this in props */}\n {buttonLabel.toUpperCase()}\n </Button>\n <input\n accept={accept}\n className=\"input-hidden\"\n data-testid=\"file-input\"\n disabled={disabled}\n multiple\n onChange={handleInputChange}\n onFocus={handleInputFocus}\n ref={fileInputRef}\n type=\"file\"\n />\n </label>\n {!isRejected && fileDropZoneDescription}\n </div>\n );\n }\n);\n"],"names":["FileDropZone","fileDropZoneCss"],"mappings":";;;;;;;;;;AA2BA,MAAM,WAAc,GAAA,cAAA,CAAA;AACpB,MAAM,mBAAsB,GAAA,uCAAA,CAAA;AAsE5B,MAAM,YAAA,GAAe,aAAa,kBAAkB,CAAA,CAAA;AAE7C,MAAM,YAAe,GAAA,UAAA;AAAA,EAC1B,SAASA,aACP,CAAA;AAAA,IACE,MAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,EAAI,EAAA,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,eAAA;AAAA,IACA,eAAA;AAAA,IACG,GAAA,SAAA;AAAA,KAEL,GACA,EAAA;AACA,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,qBAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAM,MAAA,EAAA,GAAK,MAAM,MAAM,CAAA,CAAA;AAEvB,IAAA,MAAM,SAAS,CAAG,EAAA,EAAA,CAAA,KAAA,CAAA,CAAA;AAClB,IAAA,MAAM,WAAW,CAAG,EAAA,EAAA,CAAA,OAAA,CAAA,CAAA;AACpB,IAAA,MAAM,gBAAgB,CAAG,EAAA,EAAA,CAAA,YAAA,CAAA,CAAA;AAEzB,IAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAIjC,IAAI,CAAA,CAAA;AACP,IAAA,MAAM,CAAC,QAAA,EAAU,SAAS,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AAC5C,IAAA,MAAM,CAAC,UAAA,EAAY,WAAW,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AAEhD,IAAM,MAAA,SAAA,G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,IAAA;AAAA,cACR,QAAU,EAAA,iBAAA;AAAA,cACV,OAAS,EAAA,gBAAA;AAAA,cACT,GAAK,EAAA,YAAA;AAAA,cACL,IAAK,EAAA,MAAA;AAAA,aACP,CAAA;AAAA,WAAA;AAAA,SACF,CAAA;AAAA,QACC,CAAC,UAAc,IAAA,uBAAA;AAAA,OAAA;AAAA,KAClB,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
1
+ {"version":3,"file":"FileDropZone.js","sources":["../src/file-drop-zone/FileDropZone.tsx"],"sourcesContent":["import { makePrefixer, useForkRef, ValidationStatus } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport {\n DragEventHandler,\n forwardRef,\n DragEvent,\n useRef,\n useState,\n ComponentPropsWithoutRef,\n} from \"react\";\nimport { containsFiles, extractFiles } from \"./internal/utils\";\n\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\n\nimport fileDropZoneCss from \"./FileDropZone.css\";\n\nexport interface FileDropZoneProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"onDrop\"> {\n /**\n * If `true`, the file drop zone will be disabled.\n */\n disabled?: boolean;\n /**\n * Status indicator to be displayed.\n */\n status?: Omit<ValidationStatus, \"info\" | \"warning\">;\n /**\n * Callback for on drop event\n */\n onDrop?: (event: DragEvent<HTMLDivElement>, files: File[]) => void;\n}\n\nconst withBaseName = makePrefixer(\"saltFileDropZone\");\n\nexport const FileDropZone = forwardRef<HTMLDivElement, FileDropZoneProps>(\n function FileDropZone(\n {\n status,\n className,\n children,\n disabled,\n onDragOver,\n onDragLeave,\n onDrop,\n ...restProps\n },\n ref\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-file-drop-zone\",\n css: fileDropZoneCss,\n window: targetWindow,\n });\n const [isActive, setActive] = useState(false);\n\n const regionRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(ref, regionRef);\n\n const handleDragOver: DragEventHandler<HTMLDivElement> = (event) => {\n // Need to cancel the default events to allow drop\n // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#droptargets\n\n event.preventDefault();\n event.stopPropagation();\n\n if (disabled) {\n if (event.dataTransfer) {\n event.dataTransfer.dropEffect = \"none\";\n }\n return;\n }\n if (event.dataTransfer) {\n event.dataTransfer.dropEffect = \"copy\";\n }\n if (!isActive && containsFiles(event)) {\n setActive(true);\n }\n onDragOver?.(event);\n };\n\n const handleDragLeave: DragEventHandler<HTMLDivElement> = (event) => {\n if (disabled) {\n return;\n }\n const region = regionRef?.current;\n const eventTarget = event.relatedTarget;\n if (eventTarget !== region && !region?.contains(eventTarget as Node)) {\n setActive(false);\n }\n onDragLeave?.(event);\n };\n\n const handleDrop: DragEventHandler<HTMLDivElement> = (event) => {\n if (disabled) {\n return;\n }\n event.preventDefault();\n const files = extractFiles(event);\n setActive(false);\n onDrop?.(event, files);\n };\n\n return (\n <div\n className={clsx(\n withBaseName(),\n {\n [withBaseName(status as string)]: status,\n [withBaseName(\"active\")]: isActive,\n [withBaseName(\"disabled\")]: disabled,\n },\n className\n )}\n aria-disabled={disabled}\n onDragLeave={handleDragLeave}\n onDragOver={handleDragOver}\n onDrop={handleDrop}\n ref={handleRef}\n {...restProps}\n >\n {children}\n </div>\n );\n }\n);\n"],"names":["FileDropZone","fileDropZoneCss"],"mappings":";;;;;;;;;AAiCA,MAAM,YAAA,GAAe,aAAa,kBAAkB,CAAA,CAAA;AAE7C,MAAM,YAAe,GAAA,UAAA;AAAA,EAC1B,SAASA,aACP,CAAA;AAAA,IACE,MAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAA;AAAA,IACG,GAAA,SAAA;AAAA,KAEL,GACA,EAAA;AACA,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EA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react';
4
+ import { UploadIcon } from '@salt-ds/icons';
5
+
6
+ const FileDropZoneIcon = forwardRef(function FileDropZoneIcon2({ status, size = 2, ...rest }, ref) {
7
+ const iconProps = {
8
+ ref,
9
+ size,
10
+ ...rest
11
+ };
12
+ return status ? /* @__PURE__ */ jsx(StatusIndicator, {
13
+ status,
14
+ ...iconProps
15
+ }) : /* @__PURE__ */ jsx(UploadIcon, {
16
+ ...iconProps
17
+ });
18
+ });
19
+
20
+ export { FileDropZoneIcon };
21
+ //# sourceMappingURL=FileDropZoneIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileDropZoneIcon.js","sources":["../src/file-drop-zone/FileDropZoneIcon.tsx"],"sourcesContent":["import { StatusIndicator, ValidationStatus } from \"@salt-ds/core\";\nimport { forwardRef } from \"react\";\nimport { IconProps, UploadIcon } from \"@salt-ds/icons\";\n\nexport interface FileDropZoneIconProps extends IconProps {\n /**\n * Status indicator to be displayed.\n */\n status?: ValidationStatus;\n}\n\nexport const FileDropZoneIcon = forwardRef<\n SVGSVGElement,\n FileDropZoneIconProps\n>(function FileDropZoneIcon({ status, size = 2, ...rest }, ref) {\n const iconProps = {\n ref,\n size,\n ...rest,\n };\n return status ? (\n <StatusIndicator status={status} {...iconProps} />\n ) : (\n <UploadIcon {...iconProps} />\n );\n});\n"],"names":["FileDropZoneIcon"],"mappings":";;;;;AAWa,MAAA,gBAAA,GAAmB,UAG9B,CAAA,SAASA,iBAAiB,CAAA,EAAE,QAAQ,IAAO,GAAA,CAAA,EAAA,GAAM,IAAK,EAAA,EAAG,GAAK,EAAA;AAC9D,EAAA,MAAM,SAAY,GAAA;AAAA,IAChB,GAAA;AAAA,IACA,IAAA;AAAA,IACA,GAAG,IAAA;AAAA,GACL,CAAA;AACA,EAAA,OAAO,yBACJ,GAAA,CAAA,eAAA,EAAA;AAAA,IAAgB,MAAA;AAAA,IAAiB,GAAG,SAAA;AAAA,GAAW,oBAE/C,GAAA,CAAA,UAAA,EAAA;AAAA,IAAY,GAAG,SAAA;AAAA,GAAW,CAAA,CAAA;AAE/B,CAAC;;;;"}
@@ -0,0 +1,48 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { useForkRef, Button } from '@salt-ds/core';
3
+ import { forwardRef, useRef } from 'react';
4
+
5
+ const FileDropZoneTrigger = forwardRef(function FileDropZoneTrigger2({ accept, children, disabled, multiple = false, onChange, ...rest }, ref) {
6
+ const buttonRef = useRef(null);
7
+ const fileInputRef = useRef(null);
8
+ const triggerRef = useForkRef(ref, buttonRef);
9
+ const handleFocus = (event) => {
10
+ var _a;
11
+ event.stopPropagation();
12
+ (_a = buttonRef.current) == null ? void 0 : _a.focus();
13
+ };
14
+ const handleClick = (event) => {
15
+ var _a;
16
+ event.stopPropagation();
17
+ (_a = fileInputRef.current) == null ? void 0 : _a.click();
18
+ };
19
+ const handleChange = (event) => {
20
+ var _a;
21
+ const files = Array.from((_a = event.target.files) != null ? _a : []);
22
+ onChange == null ? void 0 : onChange(event, files);
23
+ };
24
+ return /* @__PURE__ */ jsxs(Fragment, {
25
+ children: [
26
+ /* @__PURE__ */ jsx(Button, {
27
+ onClick: handleClick,
28
+ disabled,
29
+ ref: triggerRef,
30
+ ...rest,
31
+ children: children != null ? children : "Browse files"
32
+ }),
33
+ /* @__PURE__ */ jsx("input", {
34
+ accept,
35
+ className: "input-hidden",
36
+ disabled,
37
+ multiple,
38
+ onChange: handleChange,
39
+ onFocus: handleFocus,
40
+ ref: fileInputRef,
41
+ type: "file"
42
+ })
43
+ ]
44
+ });
45
+ });
46
+
47
+ export { FileDropZoneTrigger };
48
+ //# sourceMappingURL=FileDropZoneTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileDropZoneTrigger.js","sources":["../src/file-drop-zone/FileDropZoneTrigger.tsx"],"sourcesContent":["import { Button, useForkRef } from \"@salt-ds/core\";\nimport {\n FocusEvent,\n forwardRef,\n HTMLAttributes,\n SyntheticEvent,\n useRef,\n} from \"react\";\n\nexport interface FileDropZoneTriggerProps\n extends Omit<HTMLAttributes<HTMLButtonElement>, \"onChange\"> {\n /**\n * `accept` attribute for HTML <input>.\n *\n * A comma separated list of file types the user can pick from the file input dialog box.\n */\n accept?: string;\n /**\n * Disable all trigger elements.\n */\n disabled?: boolean;\n /**\n * Allows multiple files to be uploaded.\n */\n multiple?: boolean;\n /**\n * Callback for input change event\n */\n onChange?: (event: SyntheticEvent<HTMLInputElement>, files: File[]) => void;\n}\n\nexport const FileDropZoneTrigger = forwardRef<\n HTMLButtonElement,\n FileDropZoneTriggerProps\n>(function FileDropZoneTrigger(\n { accept, children, disabled, multiple = false, onChange, ...rest },\n ref\n) {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n const triggerRef = useForkRef(ref, buttonRef);\n\n // As an ADA requirement when dialog is closed and the focus is returned to the input, we need to\n // move focus back on the button element so that all labels can be announced correctly\n const handleFocus = (event: FocusEvent<HTMLInputElement>) => {\n event.stopPropagation();\n buttonRef.current?.focus();\n };\n\n const handleClick = (event: SyntheticEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n fileInputRef.current?.click();\n };\n\n const handleChange = (event: SyntheticEvent<HTMLInputElement>) => {\n const files = Array.from((event.target as HTMLInputElement).files ?? []);\n onChange?.(event, files);\n };\n return (\n <>\n <Button\n onClick={handleClick}\n disabled={disabled}\n ref={triggerRef}\n {...rest}\n >\n {children ?? \"Browse files\"}\n </Button>\n <input\n accept={accept}\n className=\"input-hidden\"\n disabled={disabled}\n multiple={multiple}\n onChange={handleChange}\n onFocus={handleFocus}\n ref={fileInputRef}\n type=\"file\"\n />\n </>\n );\n});\n"],"names":["FileDropZoneTrigger"],"mappings":";;;;AA+BO,MAAM,mBAAsB,GAAA,UAAA,CAGjC,SAASA,oBAAAA,CACT,EAAE,MAAA,EAAQ,QAAU,EAAA,QAAA,EAAU,QAAW,GAAA,KAAA,EAAO,QAAa,EAAA,GAAA,IAAA,IAC7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GAAG,IAAA;AAAA,QAEH,QAAY,EAAA,QAAA,IAAA,IAAA,GAAA,QAAA,GAAA,cAAA;AAAA,OACf,CAAA;AAAA,sBACC,GAAA,CAAA,OAAA,EAAA;AAAA,QACC,MAAA;AAAA,QACA,SAAU,EAAA,cAAA;AAAA,QACV,QAAA;AAAA,QACA,QAAA;AAAA,QACA,QAAU,EAAA,YAAA;AAAA,QACV,OAAS,EAAA,WAAA;AAAA,QACT,GAAK,EAAA,YAAA;AAAA,QACL,IAAK,EAAA,MAAA;AAAA,OACP,CAAA;AAAA,KAAA;AAAA,GACF,CAAA,CAAA;AAEJ,CAAC;;;;"}
@@ -1,8 +1,7 @@
1
- const toArray = (obj) => Object.keys(obj).map((key) => obj[key]);
2
1
  const containsFiles = (e) => {
3
2
  if (!e.dataTransfer) {
4
3
  const target = e.target;
5
- return target && target.files;
4
+ return target == null ? void 0 : target.files;
6
5
  }
7
6
  return Array.prototype.some.call(
8
7
  e.dataTransfer.types,
@@ -10,23 +9,17 @@ const containsFiles = (e) => {
10
9
  );
11
10
  };
12
11
  const extractFiles = (e) => {
12
+ var _a;
13
13
  if (containsFiles(e)) {
14
14
  if (e.dataTransfer) {
15
- return toArray(e.dataTransfer.files);
15
+ return Array.from(e.dataTransfer.files);
16
16
  }
17
17
  if (e.target) {
18
- return toArray(e.target.files);
18
+ return Array.from((_a = e.target.files) != null ? _a : []);
19
19
  }
20
20
  }
21
21
  return [];
22
22
  };
23
- const validateFiles = ({
24
- files = [],
25
- validate = []
26
- }) => validate.reduce(
27
- (result, validator) => result.concat(validator(files)),
28
- []
29
- ).filter(Boolean);
30
23
 
31
- export { containsFiles, extractFiles, toArray, validateFiles };
24
+ export { containsFiles, extractFiles };
32
25
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../src/file-drop-zone/internal/utils.ts"],"sourcesContent":["import { DragEvent } from \"react\";\nimport { FilesValidator } from \"../validators\";\n\nexport const toArray = (obj: any) => Object.keys(obj).map((key) => obj[key]);\n\nexport const containsFiles = (e: DragEvent) => {\n if (!e.dataTransfer) {\n const target = e.target as HTMLInputElement;\n return target && target.files;\n }\n\n return Array.prototype.some.call(\n e.dataTransfer.types,\n (type) => type === \"Files\"\n );\n};\n\nexport const extractFiles = (e: DragEvent): File[] => {\n if (containsFiles(e)) {\n if (e.dataTransfer) {\n return toArray(e.dataTransfer.files);\n }\n\n if (e.target) {\n return toArray((e.target as HTMLInputElement).files);\n }\n }\n\n return [];\n};\n\nexport const validateFiles = ({\n files = [],\n validate = [],\n}: {\n files: ReadonlyArray<File>;\n validate: ReadonlyArray<FilesValidator>;\n}) =>\n validate\n .reduce(\n (result, validator) => result.concat(validator(files)),\n [] as (string | undefined)[]\n )\n .filter(Boolean) as string[];\n"],"names":[],"mappings":"AAGa,MAAA,OAAA,GAAU,CAAC,GAAA,KAAa,MAAO,CAAA,IAAA,CAAK,GAAG,CAAA,CAAE,GAAI,CAAA,CAAC,GAAQ,KAAA,GAAA,CAAI,GAAI,CAAA,EAAA;AAE9D,MAAA,aAAA,GAAgB,CAAC,CAAiB,KAAA;AAC7C,EAAI,IAAA,CAAC,EAAE,YAAc,EAAA;AACnB,IAAA,MAAM,SAAS,CAAE,CAAA,MAAA,CAAA;AACjB,IAAA,OAAO,UAAU,MAAO,CAAA,KAAA,CAAA;AAAA,GAC1B;AAEA,EAAO,OAAA,KAAA,CAAM,UAAU,IAAK,CAAA,IAAA;AAAA,IAC1B,EAAE,YAAa,CAAA,KAAA;AAAA,IACf,CAAC,SAAS,IAAS,KAAA,OAAA;AAAA,GACrB,CAAA;AACF,EAAA;AAEa,MAAA,YAAA,GAAe,CAAC,CAAyB,KAAA;AACpD,EAAI,IAAA,aAAA,CAAc,CAAC,CAAG,EAAA;AACpB,IAAA,IAAI,EAAE,YAAc,EAAA;AAClB,MAAO,OAAA,OAAA,CAAQ,CAAE,CAAA,YAAA,CAAa,KAAK,CAAA,CAAA;AAAA,KACrC;AAEA,IAAA,IAAI,EAAE,MAAQ,EAAA;AACZ,MAAO,OAAA,OAAA,CAAS,CAAE,CAAA,MAAA,CAA4B,KAAK,CAAA,CAAA;AAAA,KACrD;AAAA,GACF;AAEA,EAAA,OAAO,EAAC,CAAA;AACV,EAAA;AAEO,MAAM,gBAAgB,CAAC;AAAA,EAC5B,QAAQ,EAAC;AAAA,EACT,WAAW,EAAC;AACd,CAAA,KAIE,QACG,CAAA,MAAA;AAAA,EACC,CAAC,MAAQ,EAAA,SAAA,KAAc,OAAO,MAAO,CAAA,SAAA,CAAU,KAAK,CAAC,CAAA;AAAA,EACrD,EAAC;AACH,CAAA,CACC,OAAO,OAAO;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../src/file-drop-zone/internal/utils.ts"],"sourcesContent":["import { DragEvent } from \"react\";\n\nexport const containsFiles = (e: DragEvent) => {\n if (!e.dataTransfer) {\n const target = e.target as HTMLInputElement;\n return target?.files;\n }\n\n return Array.prototype.some.call(\n e.dataTransfer.types,\n (type) => type === \"Files\"\n );\n};\n\nexport const extractFiles = (e: DragEvent): File[] => {\n if (containsFiles(e)) {\n if (e.dataTransfer) {\n return Array.from(e.dataTransfer.files);\n }\n\n if (e.target) {\n return Array.from((e.target as HTMLInputElement).files ?? []);\n }\n }\n\n return [];\n};\n"],"names":[],"mappings":"AAEa,MAAA,aAAA,GAAgB,CAAC,CAAiB,KAAA;AAC7C,EAAI,IAAA,CAAC,EAAE,YAAc,EAAA;AACnB,IAAA,MAAM,SAAS,CAAE,CAAA,MAAA,CAAA;AACjB,IAAA,OAAO,MAAQ,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,MAAA,CAAA,KAAA,CAAA;AAAA,GACjB;AAEA,EAAO,OAAA,KAAA,CAAM,UAAU,IAAK,CAAA,IAAA;AAAA,IAC1B,EAAE,YAAa,CAAA,KAAA;AAAA,IACf,CAAC,SAAS,IAAS,KAAA,OAAA;AAAA,GACrB,CAAA;AACF,EAAA;AAEa,MAAA,YAAA,GAAe,CAAC,CAAyB,KAAA;AAdtD,EAAA,IAAA,EAAA,CAAA;AAeE,EAAI,IAAA,aAAA,CAAc,CAAC,CAAG,EAAA;AACpB,IAAA,IAAI,EAAE,YAAc,EAAA;AAClB,MAAA,OAAO,KAAM,CAAA,IAAA,CAAK,CAAE,CAAA,YAAA,CAAa,KAAK,CAAA,CAAA;AAAA,KACxC;AAEA,IAAA,IAAI,EAAE,MAAQ,EAAA;AACZ,MAAA,OAAO,MAAM,IAAM,CAAA,CAAA,EAAA,GAAA,CAAA,CAAE,OAA4B,KAA9B,KAAA,IAAA,GAAA,EAAA,GAAuC,EAAE,CAAA,CAAA;AAAA,KAC9D;AAAA,GACF;AAEA,EAAA,OAAO,EAAC,CAAA;AACV;;;;"}
package/dist-es/index.js CHANGED
@@ -72,7 +72,8 @@ export { useDropdownBase } from './dropdown/useDropdownBase.js';
72
72
  export { DropdownNext } from './dropdown-next/DropdownNext.js';
73
73
  export { EditableLabel } from './editable-label/EditableLabel.js';
74
74
  export { FileDropZone } from './file-drop-zone/FileDropZone.js';
75
- export { createFileTypeValidator, createTotalSizeValidator } from './file-drop-zone/validators.js';
75
+ export { FileDropZoneIcon } from './file-drop-zone/FileDropZoneIcon.js';
76
+ export { FileDropZoneTrigger } from './file-drop-zone/FileDropZoneTrigger.js';
76
77
  export { FormFieldLegacy as FormField } from './form-field-legacy/FormFieldLegacy.js';
77
78
  export { FormLabel } from './form-field-legacy/FormLabel.js';
78
79
  export { FormFieldLegacyContext } from './form-field-context-legacy/FormFieldLegacyContext.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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.24",
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.2",
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.9.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