@reykjavik/hanna-react 0.10.87 → 0.10.89
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/CHANGELOG.md +8 -0
- package/FileInput/_FileInputFileList.d.ts +2 -2
- package/FileInput.js +7 -7
- package/Selectbox.d.ts +2 -3
- package/_abstract/_TogglerGroup.d.ts +2 -1
- package/esm/FileInput/_FileInputFileList.d.ts +2 -2
- package/esm/FileInput.js +1 -1
- package/esm/Selectbox.d.ts +2 -3
- package/esm/_abstract/_TogglerGroup.d.ts +2 -1
- package/esm/utils.d.ts +7 -0
- package/package.json +5 -5
- package/utils.d.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.10.88 – 0.10.89
|
|
8
|
+
|
|
9
|
+
_2023-05-25_
|
|
10
|
+
|
|
11
|
+
- feat(ts): Export utility type `HtmlProps` from `utils` module — for adding
|
|
12
|
+
HTML attributes (including `data-*`) to React components.
|
|
13
|
+
- fix: Update dependencies to fix import resolution errors in node@>=18
|
|
14
|
+
|
|
7
15
|
## 0.10.87
|
|
8
16
|
|
|
9
17
|
_2023-05-19_
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { formatBytes } from './_FileInput.utils';
|
|
2
|
-
import { CustomFile } from './_FileInput.utils';
|
|
1
|
+
import type { formatBytes } from './_FileInput.utils.js';
|
|
2
|
+
import { CustomFile } from './_FileInput.utils.js';
|
|
3
3
|
export type FileListProps = {
|
|
4
4
|
files: Array<CustomFile>;
|
|
5
5
|
showFileSize?: boolean;
|
package/FileInput.js
CHANGED
|
@@ -7,7 +7,7 @@ const react_dropzone_1 = require("react-dropzone"); // https://react-dropzone.js
|
|
|
7
7
|
const hooks_1 = require("@hugsmidjan/react/hooks");
|
|
8
8
|
const getBemClass_1 = tslib_1.__importDefault(require("@hugsmidjan/react/utils/getBemClass"));
|
|
9
9
|
const i18n_1 = require("@reykjavik/hanna-utils/i18n");
|
|
10
|
-
const
|
|
10
|
+
const _FileInput_utils_js_1 = require("./FileInput/_FileInput.utils.js");
|
|
11
11
|
const _FileInputFileList_js_1 = require("./FileInput/_FileInputFileList.js");
|
|
12
12
|
const FormField_js_1 = tslib_1.__importDefault(require("./FormField.js"));
|
|
13
13
|
const defaultRemoveFileText = {
|
|
@@ -40,7 +40,7 @@ const FileInput = (props) => {
|
|
|
40
40
|
const { getRootProps, getInputProps, isDragReject, inputRef } = (0, react_dropzone_1.useDropzone)({
|
|
41
41
|
onDrop: (acceptedFiles) => {
|
|
42
42
|
acceptedFiles = acceptedFiles.map((file) => {
|
|
43
|
-
(0,
|
|
43
|
+
(0, _FileInput_utils_js_1.addPreview)(file);
|
|
44
44
|
return file;
|
|
45
45
|
});
|
|
46
46
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
@@ -67,14 +67,14 @@ const FileInput = (props) => {
|
|
|
67
67
|
});
|
|
68
68
|
// Synchronoyusly add previews on incoming files
|
|
69
69
|
// (NOTE: `addPreview` ignores files that already have preview.)
|
|
70
|
-
files.forEach(
|
|
70
|
+
files.forEach(_FileInput_utils_js_1.addPreview);
|
|
71
71
|
(0, react_1.useEffect)(() => {
|
|
72
72
|
if (fileInput.current) {
|
|
73
73
|
fileInput.current.files = arrayToFileList(files);
|
|
74
74
|
}
|
|
75
75
|
return () => {
|
|
76
76
|
// Make sure to revoke the data uris on unmount to avoid memory leaks
|
|
77
|
-
files.forEach(
|
|
77
|
+
files.forEach(_FileInput_utils_js_1.releasePreview);
|
|
78
78
|
};
|
|
79
79
|
}, [files]);
|
|
80
80
|
const removeFile = (removeTarget) => {
|
|
@@ -85,7 +85,7 @@ const FileInput = (props) => {
|
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
87
87
|
deleted.push(file);
|
|
88
|
-
(0,
|
|
88
|
+
(0, _FileInput_utils_js_1.releasePreview)(file);
|
|
89
89
|
return false;
|
|
90
90
|
});
|
|
91
91
|
if (fileInput.current) {
|
|
@@ -94,7 +94,7 @@ const FileInput = (props) => {
|
|
|
94
94
|
onFilesUpdated(fileList, { deleted });
|
|
95
95
|
};
|
|
96
96
|
const addFiles = (added) => {
|
|
97
|
-
const { fileList, diff } = (0,
|
|
97
|
+
const { fileList, diff } = (0, _FileInput_utils_js_1.getFileListUpdate)(files, added, !multiple);
|
|
98
98
|
if (fileInput.current) {
|
|
99
99
|
fileInput.current.files = arrayToFileList(fileList);
|
|
100
100
|
}
|
|
@@ -126,7 +126,7 @@ const FileInput = (props) => {
|
|
|
126
126
|
showImagePreviews,
|
|
127
127
|
removeFileText,
|
|
128
128
|
removeFile,
|
|
129
|
-
formatBytes:
|
|
129
|
+
formatBytes: _FileInput_utils_js_1.formatBytes,
|
|
130
130
|
})))));
|
|
131
131
|
} }));
|
|
132
132
|
};
|
package/Selectbox.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { SelectboxProps as _SelectboxProps } from '@hugsmidjan/react/Selectbox';
|
|
1
|
+
import type { OptionOrValue, SelectboxProps as _SelectboxProps } from '@hugsmidjan/react/Selectbox';
|
|
2
2
|
import { FormFieldWrappingProps } from './FormField.js';
|
|
3
3
|
export { type SelectboxOption, type SelectboxOptions as SelectboxOptionList,
|
|
4
4
|
/** @deprecated Use `SelectboxOptionList` instead (Will be removed in v0.11) */
|
|
5
5
|
type SelectboxOptions, } from '@hugsmidjan/react/Selectbox';
|
|
6
|
-
type OptionOrValue = _SelectboxProps['options'][0];
|
|
7
6
|
export type SelectboxProps<O extends OptionOrValue = OptionOrValue> = FormFieldWrappingProps & Omit<_SelectboxProps<O>, 'bem'> & {
|
|
8
7
|
small?: boolean;
|
|
9
8
|
};
|
|
10
|
-
export declare const Selectbox: <O extends
|
|
9
|
+
export declare const Selectbox: <O extends OptionOrValue>(props: SelectboxProps<O>) => JSX.Element;
|
|
11
10
|
export default Selectbox;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FormFieldInputProps } from '../FormField.js';
|
|
2
|
+
import { HTMLProps } from '../utils.js';
|
|
2
3
|
import { TogglerInputProps } from './_TogglerInput.js';
|
|
3
4
|
export type TogglerGroupOption = {
|
|
4
5
|
value: string;
|
|
@@ -7,7 +8,7 @@ export type TogglerGroupOption = {
|
|
|
7
8
|
id?: string;
|
|
8
9
|
};
|
|
9
10
|
export type TogglerGroupOptions = Array<TogglerGroupOption>;
|
|
10
|
-
type RestrictedInputProps = Omit<
|
|
11
|
+
type RestrictedInputProps = Omit<HTMLProps<'input'>, 'type' | 'value' | 'defaultValue' | 'checked' | 'defaultChecked' | 'className' | 'id' | 'name' | 'children'>;
|
|
11
12
|
export type TogglerGroupProps = {
|
|
12
13
|
options: TogglerGroupOptions;
|
|
13
14
|
className?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { formatBytes } from './_FileInput.utils';
|
|
2
|
-
import { CustomFile } from './_FileInput.utils';
|
|
1
|
+
import type { formatBytes } from './_FileInput.utils.js';
|
|
2
|
+
import { CustomFile } from './_FileInput.utils.js';
|
|
3
3
|
export type FileListProps = {
|
|
4
4
|
files: Array<CustomFile>;
|
|
5
5
|
showFileSize?: boolean;
|
package/esm/FileInput.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useDropzone } from 'react-dropzone'; // https://react-dropzone.js.org/#
|
|
|
4
4
|
import { useDomid } from '@hugsmidjan/react/hooks';
|
|
5
5
|
import getBemClass from '@hugsmidjan/react/utils/getBemClass';
|
|
6
6
|
import { DEFAULT_LANG } from '@reykjavik/hanna-utils/i18n';
|
|
7
|
-
import { addPreview, formatBytes, getFileListUpdate, releasePreview, } from './FileInput/_FileInput.utils';
|
|
7
|
+
import { addPreview, formatBytes, getFileListUpdate, releasePreview, } from './FileInput/_FileInput.utils.js';
|
|
8
8
|
import { DefaultFileList } from './FileInput/_FileInputFileList.js';
|
|
9
9
|
import FormField from './FormField.js';
|
|
10
10
|
const defaultRemoveFileText = {
|
package/esm/Selectbox.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { SelectboxProps as _SelectboxProps } from '@hugsmidjan/react/Selectbox';
|
|
1
|
+
import type { OptionOrValue, SelectboxProps as _SelectboxProps } from '@hugsmidjan/react/Selectbox';
|
|
2
2
|
import { FormFieldWrappingProps } from './FormField.js';
|
|
3
3
|
export { type SelectboxOption, type SelectboxOptions as SelectboxOptionList,
|
|
4
4
|
/** @deprecated Use `SelectboxOptionList` instead (Will be removed in v0.11) */
|
|
5
5
|
type SelectboxOptions, } from '@hugsmidjan/react/Selectbox';
|
|
6
|
-
type OptionOrValue = _SelectboxProps['options'][0];
|
|
7
6
|
export type SelectboxProps<O extends OptionOrValue = OptionOrValue> = FormFieldWrappingProps & Omit<_SelectboxProps<O>, 'bem'> & {
|
|
8
7
|
small?: boolean;
|
|
9
8
|
};
|
|
10
|
-
export declare const Selectbox: <O extends
|
|
9
|
+
export declare const Selectbox: <O extends OptionOrValue>(props: SelectboxProps<O>) => JSX.Element;
|
|
11
10
|
export default Selectbox;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FormFieldInputProps } from '../FormField.js';
|
|
2
|
+
import { HTMLProps } from '../utils.js';
|
|
2
3
|
import { TogglerInputProps } from './_TogglerInput.js';
|
|
3
4
|
export type TogglerGroupOption = {
|
|
4
5
|
value: string;
|
|
@@ -7,7 +8,7 @@ export type TogglerGroupOption = {
|
|
|
7
8
|
id?: string;
|
|
8
9
|
};
|
|
9
10
|
export type TogglerGroupOptions = Array<TogglerGroupOption>;
|
|
10
|
-
type RestrictedInputProps = Omit<
|
|
11
|
+
type RestrictedInputProps = Omit<HTMLProps<'input'>, 'type' | 'value' | 'defaultValue' | 'checked' | 'defaultChecked' | 'className' | 'id' | 'name' | 'children'>;
|
|
11
12
|
export type TogglerGroupProps = {
|
|
12
13
|
options: TogglerGroupOptions;
|
|
13
14
|
className?: string;
|
package/esm/utils.d.ts
CHANGED
|
@@ -6,3 +6,10 @@ export * from './utils/useFormatMonitor.js';
|
|
|
6
6
|
export * from './utils/useGetSVGtext.js';
|
|
7
7
|
export * from './utils/useMixedControlState.js';
|
|
8
8
|
export * from './utils/useScrollbarWidthCSSVar.js';
|
|
9
|
+
/**
|
|
10
|
+
* Helper type to add HTML element props to a component, **including**
|
|
11
|
+
* `data-*` attributes
|
|
12
|
+
*/
|
|
13
|
+
export type HTMLProps<T extends keyof JSX.IntrinsicElements> = JSX.IntrinsicElements[T] & {
|
|
14
|
+
[dataAttr: `data-${string}`]: unknown;
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reykjavik/hanna-react",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.89",
|
|
4
4
|
"author": "Reykjavík (http://www.reykjavik.is)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Hugsmiðjan ehf (http://www.hugsmidjan.is)",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@floating-ui/react": "^0.19.2",
|
|
17
|
-
"@hugsmidjan/qj": "^4.
|
|
18
|
-
"@hugsmidjan/react": "^0.4.
|
|
19
|
-
"@reykjavik/hanna-css": "^0.4.
|
|
20
|
-
"@reykjavik/hanna-utils": "^0.2.
|
|
17
|
+
"@hugsmidjan/qj": "^4.18.0",
|
|
18
|
+
"@hugsmidjan/react": "^0.4.30",
|
|
19
|
+
"@reykjavik/hanna-css": "^0.4.2",
|
|
20
|
+
"@reykjavik/hanna-utils": "^0.2.5",
|
|
21
21
|
"@types/react": "^17.0.24",
|
|
22
22
|
"@types/react-autosuggest": "^10.1.0",
|
|
23
23
|
"@types/react-datepicker": "^4.8.0",
|
package/utils.d.ts
CHANGED
|
@@ -6,3 +6,10 @@ export * from './utils/useFormatMonitor.js';
|
|
|
6
6
|
export * from './utils/useGetSVGtext.js';
|
|
7
7
|
export * from './utils/useMixedControlState.js';
|
|
8
8
|
export * from './utils/useScrollbarWidthCSSVar.js';
|
|
9
|
+
/**
|
|
10
|
+
* Helper type to add HTML element props to a component, **including**
|
|
11
|
+
* `data-*` attributes
|
|
12
|
+
*/
|
|
13
|
+
export type HTMLProps<T extends keyof JSX.IntrinsicElements> = JSX.IntrinsicElements[T] & {
|
|
14
|
+
[dataAttr: `data-${string}`]: unknown;
|
|
15
|
+
};
|