@dbcdk/react-components 0.0.135 → 0.0.136

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.
@@ -11,7 +11,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
12
12
  var styles__default = /*#__PURE__*/_interopDefault(styles);
13
13
 
14
- function FileUpload({
14
+ const FileUpload = react.forwardRef(function FileUpload2({
15
15
  label,
16
16
  labelAction,
17
17
  error,
@@ -33,11 +33,20 @@ function FileUpload({
33
33
  disabled,
34
34
  className,
35
35
  ...inputProps
36
- }) {
36
+ }, ref) {
37
37
  const reactId = react.useId();
38
38
  const inputId = id != null ? id : `file-upload-${reactId}`;
39
39
  const inputRef = react.useRef(null);
40
40
  const [dragging, setDragging] = react.useState(false);
41
+ react.useImperativeHandle(
42
+ ref,
43
+ () => ({
44
+ clear() {
45
+ if (inputRef.current) inputRef.current.value = "";
46
+ }
47
+ }),
48
+ []
49
+ );
41
50
  function handleDragOver(e) {
42
51
  e.preventDefault();
43
52
  if (!disabled) setDragging(true);
@@ -112,6 +121,7 @@ function FileUpload({
112
121
  )
113
122
  }
114
123
  );
115
- }
124
+ });
125
+ FileUpload.displayName = "FileUpload";
116
126
 
117
127
  exports.FileUpload = FileUpload;
@@ -12,4 +12,7 @@ export interface FileUploadProps extends Omit<InputHTMLAttributes<HTMLInputEleme
12
12
  width?: string | number;
13
13
  maxWidth?: string | number;
14
14
  }
15
- export declare function FileUpload({ label, labelAction, error, helpText, helpTextAddition, orientation, labelWidth, fullWidth, required, modified, onChange, children, hint, height, minWidth, width, maxWidth, id, disabled, className, ...inputProps }: FileUploadProps): import("react/jsx-runtime").JSX.Element;
15
+ export type FileUploadHandle = {
16
+ clear(): void;
17
+ };
18
+ export declare const FileUpload: import("react").ForwardRefExoticComponent<FileUploadProps & import("react").RefAttributes<FileUploadHandle>>;
@@ -1,11 +1,11 @@
1
1
  'use client';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { UploadCloud } from 'lucide-react';
4
- import { useId, useRef, useState } from 'react';
4
+ import { forwardRef, useId, useRef, useState, useImperativeHandle } from 'react';
5
5
  import styles from './FileUpload.module.css';
6
6
  import { InputContainer } from '../input-container/InputContainer';
7
7
 
8
- function FileUpload({
8
+ const FileUpload = forwardRef(function FileUpload2({
9
9
  label,
10
10
  labelAction,
11
11
  error,
@@ -27,11 +27,20 @@ function FileUpload({
27
27
  disabled,
28
28
  className,
29
29
  ...inputProps
30
- }) {
30
+ }, ref) {
31
31
  const reactId = useId();
32
32
  const inputId = id != null ? id : `file-upload-${reactId}`;
33
33
  const inputRef = useRef(null);
34
34
  const [dragging, setDragging] = useState(false);
35
+ useImperativeHandle(
36
+ ref,
37
+ () => ({
38
+ clear() {
39
+ if (inputRef.current) inputRef.current.value = "";
40
+ }
41
+ }),
42
+ []
43
+ );
35
44
  function handleDragOver(e) {
36
45
  e.preventDefault();
37
46
  if (!disabled) setDragging(true);
@@ -106,6 +115,7 @@ function FileUpload({
106
115
  )
107
116
  }
108
117
  );
109
- }
118
+ });
119
+ FileUpload.displayName = "FileUpload";
110
120
 
111
121
  export { FileUpload };
@@ -141,7 +141,7 @@ function ExpandableSidebarItem({
141
141
  {
142
142
  id: `${href}-children`,
143
143
  onAnimationEnd: handleAnimationEnd,
144
- className: `${styles__default.default.childrenContainer} ${closing ? "animate--collapse" : expanded ? "animate--expand" : "visually-hidden"}`,
144
+ className: `${styles__default.default.childrenContainer} ${closing ? "animate--collapse" : ""}`,
145
145
  children: items.map((item, idx) => renderNavItem(item, `${href}-${idx}`))
146
146
  }
147
147
  )
@@ -135,7 +135,7 @@ function ExpandableSidebarItem({
135
135
  {
136
136
  id: `${href}-children`,
137
137
  onAnimationEnd: handleAnimationEnd,
138
- className: `${styles.childrenContainer} ${closing ? "animate--collapse" : expanded ? "animate--expand" : "visually-hidden"}`,
138
+ className: `${styles.childrenContainer} ${closing ? "animate--collapse" : ""}`,
139
139
  children: items.map((item, idx) => renderNavItem(item, `${href}-${idx}`))
140
140
  }
141
141
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbcdk/react-components",
3
- "version": "0.0.135",
3
+ "version": "0.0.136",
4
4
  "description": "Reusable React components for DBC projects",
5
5
  "license": "ISC",
6
6
  "author": "",