@majapisoftwares/ui 4.1.0 → 4.1.2

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.
@@ -3,25 +3,25 @@ import { useId } from "react";
3
3
  import * as RAccordion from "@radix-ui/react-accordion";
4
4
  import clsx from "../../utils/clsx";
5
5
  export default function Accordion({ children, className, type = "multiple", }) {
6
- return (<RAccordion.Root type={type} className={clsx("flex flex-col gap-2", className)} collapsible>
7
- {children}
6
+ return (<RAccordion.Root type={type} className={clsx("flex flex-col gap-2", className)} collapsible={type === "single" || undefined}>
7
+ {children}
8
8
  </RAccordion.Root>);
9
9
  }
10
10
  Accordion.Item = AccordionItem;
11
11
  function AccordionItem({ children, title, value, className, triggerClassName, contentClassName, contentInnerClassName, }) {
12
12
  const id = useId();
13
13
  value = value || id;
14
- return (<RAccordion.Item value={value} className={className}>
15
- <RAccordion.Header>
16
- <RAccordion.Trigger className={clsx("group focus-visible:ring-opacity-75 flex w-full justify-between rounded-lg bg-zinc-200 px-4 py-2 text-left text-sm font-medium transition hover:bg-zinc-300 focus:outline-hidden focus-visible:ring-3 focus-visible:ring-purple-500 dark:bg-zinc-800 dark:hover:bg-zinc-700", triggerClassName)}>
17
- {title}
18
- <ChevronUpIcon className="h-5 w-5 transition-transform duration-300 ease-[cubic-bezier(0.87,_0,_0.13,_1)] group-data-[state=open]:rotate-180"/>
19
- </RAccordion.Trigger>
20
- </RAccordion.Header>
21
- <RAccordion.Content className={clsx("data-[state=closed]:animate-slide-up data-[state=open]:animate-slide-down overflow-hidden", contentClassName)}>
22
- <div className={clsx("px-4 pt-2 pb-2", contentInnerClassName)}>
23
- {children}
24
- </div>
25
- </RAccordion.Content>
14
+ return (<RAccordion.Item value={value} className={className}>
15
+ <RAccordion.Header>
16
+ <RAccordion.Trigger className={clsx("group focus-visible:ring-opacity-75 flex w-full justify-between rounded-lg bg-zinc-200 px-4 py-2 text-left text-sm font-medium transition hover:bg-zinc-300 focus:outline-hidden focus-visible:ring-3 focus-visible:ring-purple-500 dark:bg-zinc-800 dark:hover:bg-zinc-700", triggerClassName)}>
17
+ {title}
18
+ <ChevronUpIcon className="h-5 w-5 transition-transform duration-300 ease-[cubic-bezier(0.87,_0,_0.13,_1)] group-data-[state=open]:rotate-180"/>
19
+ </RAccordion.Trigger>
20
+ </RAccordion.Header>
21
+ <RAccordion.Content className={clsx("data-[state=closed]:animate-slide-up data-[state=open]:animate-slide-down overflow-hidden", contentClassName)}>
22
+ <div className={clsx("px-4 pt-2 pb-2", contentInnerClassName)}>
23
+ {children}
24
+ </div>
25
+ </RAccordion.Content>
26
26
  </RAccordion.Item>);
27
27
  }
@@ -112,33 +112,32 @@ function FileInput({ error, className, helpText, onChange, name, limit, label, i
112
112
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
113
  });
114
114
  }
115
- // eslint-disable-next-line react-hooks/exhaustive-deps
116
115
  }, [innerValue]);
117
116
  const handleDeleteClick = useCallback((clickedFile) => () => {
118
117
  setInnerValue((value) => [
119
118
  ...value.filter((file) => file !== clickedFile),
120
119
  ]);
121
120
  }, []);
122
- return (<div data-input-name={name} data-error={error ? "" : undefined} data-loading={loading ? "" : undefined} className={clsx("relative data-loading:animate-pulse", className)} onMouseOver={onMouseOver} onMouseOut={onMouseOut}>
123
- {label && (<label htmlFor={id} className={defaultLabelClassName}>
124
- {label}
125
- {required && (<>
126
- {" "}
127
- <span className="text-red-500">*</span>
128
- </>)}
129
- </label>)}
121
+ return (<div data-input-name={name} data-error={error ? "" : undefined} data-loading={loading ? "" : undefined} className={clsx("relative data-loading:animate-pulse", className)} onMouseOver={onMouseOver} onMouseOut={onMouseOut}>
122
+ {label && (<label htmlFor={id} className={defaultLabelClassName}>
123
+ {label}
124
+ {required && (<>
125
+ {" "}
126
+ <span className="text-red-500">*</span>
127
+ </>)}
128
+ </label>)}
130
129
  <div className={clsx("grid grid-cols-1 gap-4", {
131
130
  "md:grid-cols-2": !!innerValue.length,
132
131
  "min-h-[140px]": !!innerValue.length || !readOnly,
133
- })}>
134
- {paginatedValue.map((file, index) => (<PreviewFile key={index} file={file} readOnly={readOnly} handleDeleteClick={handleDeleteClick(file)} downloadText={downloadText} display={fileDisplay} openText={openText} additionalInfo={fileAdditionalInfo} index={index} className={previewFileClassName}/>))}
135
- {innerValue.length > filesPerPage && (<Pagination className="col-span-2 mx-auto" currentPage={currentPage} totalItems={innerValue.length} onChangePage={setCurrentPage} itemsPerPage={filesPerPage}/>)}
136
- {readOnly && !innerValue.length && (<Text variant="secondary">{emptyText}</Text>)}
137
- {!readOnly && (!limit || innerValue.length < limit) && (<FileSelect {...props} className={fileSelectClassName} id={id} onAcceptFiles={handleAcceptFiles} limit={limit ? limit - innerValue.length : undefined} uploading={uploading} onRejectFiles={onRejectFiles} error={error}/>)}
138
- </div>
139
- {helpText && (<div className={clsx(defaultHelpTextClassName, "in-data-error:text-error-500")}>
140
- {helpText}
141
- </div>)}
132
+ })}>
133
+ {paginatedValue.map((file, index) => (<PreviewFile key={index} file={file} readOnly={readOnly} handleDeleteClick={handleDeleteClick(file)} downloadText={downloadText} display={fileDisplay} openText={openText} additionalInfo={fileAdditionalInfo} index={index} className={previewFileClassName} filesPerPage={filesPerPage} currentPage={currentPage}/>))}
134
+ {innerValue.length > filesPerPage && (<Pagination className="col-span-2 mx-auto" currentPage={currentPage} totalItems={innerValue.length} onChangePage={setCurrentPage} itemsPerPage={filesPerPage}/>)}
135
+ {readOnly && !innerValue.length && (<Text variant="secondary">{emptyText}</Text>)}
136
+ {!readOnly && (!limit || innerValue.length < limit) && (<FileSelect {...props} className={fileSelectClassName} id={id} onAcceptFiles={handleAcceptFiles} limit={limit ? limit - innerValue.length : undefined} uploading={uploading} onRejectFiles={onRejectFiles} error={error}/>)}
137
+ </div>
138
+ {helpText && (<div className={clsx(defaultHelpTextClassName, "in-data-error:text-error-500")}>
139
+ {helpText}
140
+ </div>)}
142
141
  </div>);
143
142
  }
144
143
  export default FileInput;
@@ -1,6 +1,6 @@
1
1
  import { FileInputFile } from "./FileInput";
2
2
  import { ReactNode } from "react";
3
- export declare function PreviewFile({ file, readOnly, handleDeleteClick, downloadText, openText, display, additionalInfo, index, className, }: {
3
+ export declare function PreviewFile({ file, readOnly, handleDeleteClick, downloadText, openText, display, additionalInfo, index, className, filesPerPage, currentPage, }: {
4
4
  file: FileInputFile;
5
5
  readOnly?: boolean;
6
6
  handleDeleteClick: () => void;
@@ -10,4 +10,6 @@ export declare function PreviewFile({ file, readOnly, handleDeleteClick, downloa
10
10
  additionalInfo?: (file: FileInputFile, index: number) => ReactNode;
11
11
  index: number;
12
12
  className?: string;
13
+ filesPerPage: number;
14
+ currentPage: number;
13
15
  }): import("react").JSX.Element;
@@ -8,7 +8,7 @@ import { ArrowTopRightOnSquareIcon, TrashIcon, } from "@heroicons/react/20/solid
8
8
  import clsx from "../../utils/clsx";
9
9
  const videoExtensions = [".mp4"];
10
10
  const imageExtensions = [".png", ".jpg", ".jpeg", ".webp"];
11
- export function PreviewFile({ file, readOnly, handleDeleteClick, downloadText, openText, display = "info", additionalInfo, index, className, }) {
11
+ export function PreviewFile({ file, readOnly, handleDeleteClick, downloadText, openText, display = "info", additionalInfo, index, className, filesPerPage, currentPage, }) {
12
12
  const url = file.file
13
13
  ? URL.createObjectURL(file.file)
14
14
  : file.url;
@@ -45,7 +45,9 @@ export function PreviewFile({ file, readOnly, handleDeleteClick, downloadText, o
45
45
  </Button>
46
46
  </Group>)}
47
47
  </Stack>
48
- {additionalInfo && additionalInfo(file, index)}
48
+ {additionalInfo &&
49
+ additionalInfo(file, index + (currentPage - 1) * filesPerPage)}
50
+ {/*{additionalInfo && additionalInfo(file, index)}*/}
49
51
  </Stack>
50
52
  </Group>)}
51
53
  {!readOnly && (<Button icon variant="filled" color="default" className="absolute top-2 right-2 group-hover:opacity-100 sm:opacity-0" onClick={handleDeleteClick}>
package/package.json CHANGED
@@ -4,6 +4,6 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/majapisoftwares/ui.git"
6
6
  },
7
- "version": "4.1.0",
7
+ "version": "4.1.2",
8
8
  "type": "module"
9
9
  }