@majapisoftwares/ui 4.1.17 → 4.3.0
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/bootstrap/AppProps.d.ts +4 -5
- package/components/Accordion/Accordion.d.ts +1 -1
- package/components/Alert/Alert.d.ts +1 -1
- package/components/Alert/Alert.jsx +19 -19
- package/components/Autocomplete/Autocomplete.d.ts +1 -1
- package/components/Autocomplete/Autocomplete.jsx +3 -3
- package/components/Autocomplete/UnstyledAutocomplete.d.ts +2 -2
- package/components/Autocomplete/UnstyledAutocomplete.jsx +23 -24
- package/components/Badge/Badge.d.ts +1 -1
- package/components/Badge/Badge.jsx +10 -9
- package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/components/Button/Button.d.ts +2 -2
- package/components/Button/Button.jsx +5 -5
- package/components/Carousel/Carousel.d.ts +2 -2
- package/components/Carousel/Carousel.jsx +13 -13
- package/components/Checkbox/Checkbox.d.ts +1 -1
- package/components/Checkbox/Checkbox.jsx +12 -12
- package/components/Code/Code.d.ts +1 -1
- package/components/Code/Code.jsx +15 -15
- package/components/ConfirmationButton/ConfirmationButton.d.ts +3 -3
- package/components/ConfirmationButton/ConfirmationButton.jsx +10 -10
- package/components/ContextMenu/ContextMenu.d.ts +1 -1
- package/components/ContextMenu/ContextMenu.jsx +22 -22
- package/components/DateInput/DateInput.d.ts +1 -1
- package/components/DateInput/DateInput.jsx +1 -1
- package/components/DateInput/DateTimeInput.d.ts +1 -1
- package/components/DateInput/DateTimeInput.jsx +1 -1
- package/components/DateInput/useRefValue.d.ts +1 -1
- package/components/DatePicker/DatePicker.d.ts +3 -3
- package/components/DatePicker/DatePicker.jsx +8 -8
- package/components/DateRangePicker/DateRangePicker.d.ts +2 -2
- package/components/DateRangePicker/DateRangePicker.jsx +8 -8
- package/components/Dialog/Dialog.d.ts +2 -2
- package/components/Dialog/Dialog.jsx +23 -23
- package/components/Dialog/Dialogs.jsx +4 -4
- package/components/Dialog/dialogs.state.d.ts +2 -2
- package/components/Drawer/Drawer.d.ts +1 -1
- package/components/Drawer/Drawer.jsx +41 -41
- package/components/DropdownMenu/DropdownMenu.d.ts +1 -1
- package/components/DropdownMenu/DropdownMenu.jsx +23 -23
- package/components/ErrorBoundary/ErrorBoundary.d.ts +1 -1
- package/components/ErrorBoundary/ErrorBoundary.jsx +4 -4
- package/components/ErrorPage/ErrorPage.d.ts +1 -1
- package/components/ErrorPage/ErrorPage.jsx +16 -16
- package/components/FileInput/FileInput.d.ts +4 -4
- package/components/FileInput/FileInput.jsx +2 -2
- package/components/FileInput/PreviewFile.d.ts +2 -2
- package/components/FileSelect/FileSelect.d.ts +1 -1
- package/components/Footer/Footer.d.ts +1 -1
- package/components/Footer/Footer.jsx +22 -22
- package/components/GridPattern/GridPattern.d.ts +1 -1
- package/components/GridPattern/GridPattern.jsx +7 -7
- package/components/Header/Header.d.ts +1 -1
- package/components/Header/Header.jsx +2 -2
- package/components/ImageInput/ImageInput.d.ts +1 -1
- package/components/Input/Input.d.ts +1 -1
- package/components/Input/Input.jsx +7 -7
- package/components/Input/InputIcon.d.ts +1 -1
- package/components/Input/MultiSelectInput.d.ts +5 -4
- package/components/Input/MultiSelectInput.jsx +41 -21
- package/components/Input/NumericInput.d.ts +3 -3
- package/components/Input/NumericInput.jsx +1 -1
- package/components/Input/PatternInput.d.ts +3 -3
- package/components/Input/PatternInput.jsx +1 -1
- package/components/Input/SelectInput.d.ts +12 -0
- package/components/Input/SelectInput.jsx +25 -0
- package/components/Input/UnstyledInput.d.ts +1 -1
- package/components/Input/UnstyledInput.jsx +12 -12
- package/components/Input/useInputRefValue.d.ts +11 -0
- package/components/Input/useInputRefValue.jsx +51 -0
- package/components/Input2/InputWrapper.d.ts +1 -1
- package/components/Input2/InputWrapper.jsx +7 -7
- package/components/Link/Link.d.ts +1 -1
- package/components/Magnet/Magnet.d.ts +1 -1
- package/components/Markdown/Markdown.d.ts +1 -1
- package/components/Markdown/Markdown.jsx +1 -1
- package/components/Menu/Menu.d.ts +3 -3
- package/components/Menu/Menu.jsx +19 -19
- package/components/Modal/Modal.d.ts +1 -1
- package/components/Modal/Modal.jsx +26 -26
- package/components/ModeToggle/ModeToggle.d.ts +1 -1
- package/components/ModeToggle/ModeToggle.jsx +3 -3
- package/components/MultiSelect/MultiSelect.d.ts +2 -2
- package/components/MultiSelect/MultiSelect.jsx +2 -2
- package/components/MultiSelect/MultiSelectInput.d.ts +1 -1
- package/components/MultiText/MultiText.d.ts +1 -1
- package/components/MultiText/MultiText.jsx +0 -1
- package/components/NavigationDrawer/NavigationDrawer.d.ts +1 -1
- package/components/NavigationDrawer/NavigationDrawer.jsx +11 -11
- package/components/NavigationDrawer/NavigationItem.d.ts +1 -1
- package/components/NavigationDrawer/NavigationItem.jsx +2 -2
- package/components/NoSsr/NoSsr.d.ts +1 -1
- package/components/Notifications/Notifications.jsx +29 -29
- package/components/Notifications/notifications.state.d.ts +2 -2
- package/components/Notifications/notifications.state.js +1 -1
- package/components/Pagination/Pagination.jsx +15 -15
- package/components/Particles/Particles.jsx +55 -55
- package/components/PictureCropInput/PictureCropInput.d.ts +2 -2
- package/components/PictureCropInput/PictureCropInput.jsx +39 -39
- package/components/PictureCropInput/canvasPreview.d.ts +1 -1
- package/components/Popover/Popover.d.ts +1 -1
- package/components/Popover/Popover.jsx +6 -6
- package/components/Resizable/Resizable.d.ts +1 -1
- package/components/Resizable/Resizable.jsx +4 -4
- package/components/ScrollArea/ScrollArea.d.ts +1 -1
- package/components/ScrollArea/ScrollArea.jsx +11 -11
- package/components/Select/Select.d.ts +3 -2
- package/components/Select/Select.jsx +22 -22
- package/components/Skeleton/Skeleton.d.ts +1 -1
- package/components/StarBorder/StarBorder.d.ts +1 -2
- package/components/StarBorder/StarBorder.jsx +1 -1
- package/components/Switch/Switch.d.ts +2 -2
- package/components/Switch/Switch.jsx +9 -9
- package/components/Table/DataTable.d.ts +1 -1
- package/components/Table/DataTable.jsx +54 -54
- package/components/Table/Table.d.ts +1 -1
- package/components/Table/Table.jsx +7 -7
- package/components/Table/TableActionButton.d.ts +2 -2
- package/components/Table/TableActionButton.jsx +3 -3
- package/components/Table/TableBody.d.ts +1 -1
- package/components/Table/TableBody.jsx +4 -4
- package/components/Table/TableCell.d.ts +1 -1
- package/components/Table/TableCell.jsx +4 -4
- package/components/Table/TableFooter.d.ts +1 -1
- package/components/Table/TableFooter.jsx +2 -2
- package/components/Table/TableHead.d.ts +1 -1
- package/components/Table/TableHead.jsx +4 -4
- package/components/Table/TableHeader.d.ts +1 -1
- package/components/Table/TableHeader.jsx +10 -10
- package/components/Table/TableRow.d.ts +1 -1
- package/components/Table/TableRow.jsx +2 -2
- package/components/Tabs/Tabs.d.ts +2 -2
- package/components/Tabs/Tabs.jsx +6 -6
- package/components/TabsSwitcher/Tab.d.ts +1 -1
- package/components/TabsSwitcher/TabsSwitcher.d.ts +1 -1
- package/components/Text/Text.d.ts +1 -1
- package/components/Text/Text.jsx +1 -0
- package/components/Textarea/Textarea.d.ts +2 -2
- package/components/Textarea/Textarea.jsx +1 -1
- package/components/Tooltip/Tooltip.d.ts +1 -1
- package/components/Tooltip/Tooltip.jsx +12 -12
- package/components/VisibilityActivatedButton/VisibilityActivatedButton.d.ts +1 -1
- package/form.d.ts +4 -4
- package/form2.d.ts +1 -1
- package/form2.jsx +1 -0
- package/hooks/useDebounceEffect.d.ts +1 -1
- package/hooks/useDebouncedValue.d.ts +1 -1
- package/hooks/useDebouncedValue.js +1 -1
- package/hooks/useLagRadar.jsx +19 -19
- package/package.json +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/types.d.ts +1 -1
- package/types.js +1 -1
- package/utils/UseState.d.ts +2 -3
- package/utils/csvBlobToJson.d.ts +1 -1
- package/utils/csvBlobToJson.js +0 -1
- package/utils/ms.d.ts +1 -1
- package/utils/ms.js +6 -6
- package/utils/preventDefault.d.ts +2 -1
- package/utils/recursiveChildrenMap.d.ts +1 -1
- package/utils/smoothScrollToHref.d.ts +1 -1
- package/utils/smoothScrollToHref.js +7 -3
- package/utils/stopPropagation.d.ts +2 -2
- package/utils/xlsxBlobToJson.d.ts +1 -1
- package/utils/xlsxBlobToJson.js +3 -0
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { ComponentProps } from "react";
|
|
2
|
-
import { InputProps } from "./Input";
|
|
3
|
-
declare function MultiSelectInput({ options, value, onChange, emptyLabel, ref, ...props }: Omit<InputProps<undefined>, "value"
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { type InputProps } from "./Input";
|
|
3
|
+
declare function MultiSelectInput({ options, value, onChange, emptyLabel, ref, badgeClassName, name, onValueChange, ...props }: Omit<InputProps<undefined>, "value"> & {
|
|
4
4
|
options: {
|
|
5
5
|
value: string;
|
|
6
6
|
name: string;
|
|
7
7
|
}[];
|
|
8
8
|
value?: string[];
|
|
9
|
-
|
|
9
|
+
onValueChange?: (value: string[]) => void;
|
|
10
10
|
emptyLabel?: string;
|
|
11
|
+
badgeClassName?: string;
|
|
11
12
|
}): import("react").JSX.Element;
|
|
12
13
|
export type MultiSelectInputProps = ComponentProps<typeof MultiSelectInput>;
|
|
13
14
|
export default MultiSelectInput;
|
|
@@ -1,28 +1,48 @@
|
|
|
1
|
-
import Input from "./Input";
|
|
1
|
+
import Input, {} from "./Input";
|
|
2
2
|
import DropdownMenu from "../DropdownMenu";
|
|
3
3
|
import Button from "../Button";
|
|
4
4
|
import { ChevronDownIcon } from "@heroicons/react/16/solid";
|
|
5
5
|
import { xor } from "lodash-es";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
import clsx from "../../utils/clsx";
|
|
7
|
+
import Badge from "../Badge";
|
|
8
|
+
import useInputRefValue from "./useInputRefValue";
|
|
9
|
+
import { useDeepCompareEffect } from "react-use";
|
|
10
|
+
function MultiSelectInput({ options, value, onChange, emptyLabel = "None", ref, badgeClassName, name, onValueChange, ...props }) {
|
|
11
|
+
const { innerRef, innerValue, setInnerValue } = useInputRefValue({
|
|
12
|
+
value,
|
|
13
|
+
ref,
|
|
14
|
+
name,
|
|
15
|
+
onChange,
|
|
16
|
+
});
|
|
17
|
+
const isEmpty = !innerValue?.length;
|
|
18
|
+
useDeepCompareEffect(() => {
|
|
19
|
+
if (onValueChange) {
|
|
20
|
+
onValueChange(innerValue || []);
|
|
21
|
+
}
|
|
22
|
+
}, [innerValue]);
|
|
23
|
+
return (<DropdownMenu.Root>
|
|
24
|
+
<DropdownMenu.Trigger asChild>
|
|
25
|
+
<Input as={Button} {...props} name={name} onChange={onChange} ref={innerRef} trailing={<ChevronDownIcon className="h-5 w-5 shrink-0"/>} inputClassName={clsx("text-left dark:hover:bg-zinc-700/70 bg-white gap-1.5 flex justify-start flex-wrap", {
|
|
26
|
+
"text-zinc-500 dark:text-zinc-500": isEmpty,
|
|
27
|
+
"p-1.5": !isEmpty,
|
|
28
|
+
})}>
|
|
29
|
+
{isEmpty
|
|
30
|
+
? emptyLabel
|
|
31
|
+
: options
|
|
32
|
+
.filter((option) => innerValue.includes(option.value))
|
|
33
|
+
.map((option, index) => (<Badge key={index} className={badgeClassName} onActionClick={() => setInnerValue(xor(innerValue, [option.value]))}>
|
|
34
|
+
{option.name}
|
|
35
|
+
</Badge>))}
|
|
36
|
+
</Input>
|
|
37
|
+
</DropdownMenu.Trigger>
|
|
38
|
+
<DropdownMenu.Content>
|
|
39
|
+
<DropdownMenu.Item onClick={() => setInnerValue([])}>
|
|
40
|
+
{emptyLabel}
|
|
41
|
+
</DropdownMenu.Item>
|
|
42
|
+
{options.map((option) => (<DropdownMenu.CheckboxItem key={option.name} checked={innerValue?.includes(option.value)} onClick={() => setInnerValue(xor(value, [option.value]))}>
|
|
43
|
+
{option.name}
|
|
44
|
+
</DropdownMenu.CheckboxItem>))}
|
|
45
|
+
</DropdownMenu.Content>
|
|
26
46
|
</DropdownMenu.Root>);
|
|
27
47
|
}
|
|
28
48
|
export default MultiSelectInput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ComponentProps } from "react";
|
|
2
|
-
import { InputProps } from "./Input";
|
|
3
|
-
import { NumericFormatProps } from "react-number-format";
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { type InputProps } from "./Input";
|
|
3
|
+
import { type NumericFormatProps } from "react-number-format";
|
|
4
4
|
declare function NumericInput({ ref, ...props }: Omit<NumericFormatProps, "customInput"> & InputProps<undefined>): import("react").JSX.Element;
|
|
5
5
|
export type NumericInputProps = ComponentProps<typeof NumericInput>;
|
|
6
6
|
export default NumericInput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ComponentProps } from "react";
|
|
2
|
-
import { InputProps } from "./Input";
|
|
3
|
-
import { PatternFormatProps } from "react-number-format";
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { type InputProps } from "./Input";
|
|
3
|
+
import { type PatternFormatProps } from "react-number-format";
|
|
4
4
|
declare function PatternInput(props: Omit<PatternFormatProps, "customInput"> & InputProps<undefined>): import("react").JSX.Element;
|
|
5
5
|
export type PatternInputProps = ComponentProps<typeof PatternInput>;
|
|
6
6
|
export default PatternInput;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
+
import { type InputProps } from "./index";
|
|
3
|
+
declare function SelectInput({ options, onChange, ref, placeholder, inputClassName, value, name, ...props }: InputProps<false> & {
|
|
4
|
+
options: {
|
|
5
|
+
value: string;
|
|
6
|
+
name: ReactNode;
|
|
7
|
+
}[];
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export type SelectInputProps = ComponentProps<typeof SelectInput>;
|
|
12
|
+
export default SelectInput;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {} from "react";
|
|
2
|
+
import Input, {} from "./index";
|
|
3
|
+
import Select from "../Select/Select";
|
|
4
|
+
import clsx from "../../utils/clsx";
|
|
5
|
+
import useInputRefValue from "./useInputRefValue";
|
|
6
|
+
function SelectInput({ options, onChange, ref, placeholder, inputClassName, value, name, ...props }) {
|
|
7
|
+
const { innerRef, innerValue, setInnerValue } = useInputRefValue({
|
|
8
|
+
value,
|
|
9
|
+
ref,
|
|
10
|
+
name,
|
|
11
|
+
onChange,
|
|
12
|
+
});
|
|
13
|
+
return (<Input as={Select.Root} {...props} ref={innerRef} {...{
|
|
14
|
+
value: innerValue,
|
|
15
|
+
onValueChange: setInnerValue,
|
|
16
|
+
}}>
|
|
17
|
+
<Select.Trigger placeholder={placeholder} buttonClassName={clsx("bg-white dark:hover:bg-zinc-700/70 dark:bg-zinc-800 w-full justify-between", inputClassName)}/>
|
|
18
|
+
<Select.Content>
|
|
19
|
+
{options?.map((option) => (<Select.Item key={option.value} value={option.value}>
|
|
20
|
+
{option.name}
|
|
21
|
+
</Select.Item>))}
|
|
22
|
+
</Select.Content>
|
|
23
|
+
</Input>);
|
|
24
|
+
}
|
|
25
|
+
export default SelectInput;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentType, DetailedHTMLProps, InputHTMLAttributes, ReactNode } from "react";
|
|
1
|
+
import { type ComponentType, type DetailedHTMLProps, type InputHTMLAttributes, type ReactNode } from "react";
|
|
2
2
|
export type UnstyledInputCommonProps = {
|
|
3
3
|
label?: ReactNode;
|
|
4
4
|
inputClassName?: string;
|
|
@@ -9,20 +9,20 @@ function UnstyledInput({ id, label, className, inputClassName, labelClassName, h
|
|
|
9
9
|
}, trailingInputClassName && {
|
|
10
10
|
[trailingInputClassName]: !!trailing,
|
|
11
11
|
});
|
|
12
|
-
return (<div className={className}>
|
|
13
|
-
{label && (<label htmlFor={id} className={labelClassName}>
|
|
14
|
-
{label}
|
|
15
|
-
</label>)}
|
|
16
|
-
<div style={{ position: "relative" }} className={innerClassName}>
|
|
17
|
-
{leading && <div className={leadingClassName}>{leading}</div>}
|
|
12
|
+
return (<div className={className}>
|
|
13
|
+
{label && (<label htmlFor={id} className={labelClassName}>
|
|
14
|
+
{label}
|
|
15
|
+
</label>)}
|
|
16
|
+
<div style={{ position: "relative" }} className={innerClassName}>
|
|
17
|
+
{leading && <div className={leadingClassName}>{leading}</div>}
|
|
18
18
|
<Component
|
|
19
19
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
20
|
-
{...props} className={inputClassName} id={id} type={type} value={value}>
|
|
21
|
-
{children}
|
|
22
|
-
</Component>
|
|
23
|
-
{trailing && <div className={trailingClassName}>{trailing}</div>}
|
|
24
|
-
</div>
|
|
25
|
-
{helpText && <div className={helpTextClassName}>{helpText}</div>}
|
|
20
|
+
{...props} className={inputClassName} id={id} type={type} value={value}>
|
|
21
|
+
{children}
|
|
22
|
+
</Component>
|
|
23
|
+
{trailing && <div className={trailingClassName}>{trailing}</div>}
|
|
24
|
+
</div>
|
|
25
|
+
{helpText && <div className={helpTextClassName}>{helpText}</div>}
|
|
26
26
|
</div>);
|
|
27
27
|
}
|
|
28
28
|
export default UnstyledInput;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ChangeEvent, type Ref } from "react";
|
|
2
|
+
export default function useInputRefValue<T>({ value, ref, name, onChange, }: {
|
|
3
|
+
value?: T;
|
|
4
|
+
ref?: Ref<HTMLInputElement>;
|
|
5
|
+
name?: string;
|
|
6
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
7
|
+
}): {
|
|
8
|
+
innerRef: import("react").RefObject<HTMLInputElement>;
|
|
9
|
+
innerValue: T | undefined;
|
|
10
|
+
setInnerValue: import("react").Dispatch<import("react").SetStateAction<T | undefined>>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { useDeepCompareEffect } from "react-use";
|
|
3
|
+
import { isEqual } from "lodash-es";
|
|
4
|
+
export default function useInputRefValue({ value, ref, name, onChange, }) {
|
|
5
|
+
const [innerValue, setInnerValue] = useState(value);
|
|
6
|
+
useDeepCompareEffect(() => {
|
|
7
|
+
if (value && !isEqual(value, innerValue)) {
|
|
8
|
+
setInnerValue(value);
|
|
9
|
+
}
|
|
10
|
+
}, [{ value }]);
|
|
11
|
+
const innerRef = useRef({
|
|
12
|
+
get value() {
|
|
13
|
+
return innerValue;
|
|
14
|
+
},
|
|
15
|
+
set value(value) {
|
|
16
|
+
setInnerValue(value);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (ref) {
|
|
21
|
+
if (typeof ref === "function") {
|
|
22
|
+
ref(innerRef.current);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
try {
|
|
26
|
+
ref.current = innerRef.current;
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
// do nothing
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, [ref]);
|
|
35
|
+
useDeepCompareEffect(() => {
|
|
36
|
+
if (onChange) {
|
|
37
|
+
onChange({
|
|
38
|
+
target: {
|
|
39
|
+
name,
|
|
40
|
+
value: innerValue,
|
|
41
|
+
},
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}, [innerValue]);
|
|
46
|
+
return {
|
|
47
|
+
innerRef,
|
|
48
|
+
innerValue,
|
|
49
|
+
setInnerValue,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import clsx from "../../utils/clsx";
|
|
2
2
|
export default function InputWrapper({ children, className, label, id, helpText, error, required, }) {
|
|
3
|
-
return (<div className={clsx("ui-input-wrapper", className)} data-error={error ? "" : undefined}>
|
|
4
|
-
{label && (<label htmlFor={id} className="ui-input-wrapper-label">
|
|
5
|
-
{label}
|
|
6
|
-
{required && <span className="text-red-500"> *</span>}
|
|
7
|
-
</label>)}
|
|
8
|
-
{children}
|
|
9
|
-
{helpText && <div className="ui-input-wrapper-help-text">{helpText}</div>}
|
|
3
|
+
return (<div className={clsx("ui-input-wrapper", className)} data-error={error ? "" : undefined}>
|
|
4
|
+
{label && (<label htmlFor={id} className="ui-input-wrapper-label">
|
|
5
|
+
{label}
|
|
6
|
+
{required && <span className="text-red-500"> *</span>}
|
|
7
|
+
</label>)}
|
|
8
|
+
{children}
|
|
9
|
+
{helpText && <div className="ui-input-wrapper-help-text">{helpText}</div>}
|
|
10
10
|
</div>);
|
|
11
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ReactElement, ReactNode, Ref } from "react";
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactElement, type ReactNode, type Ref } from "react";
|
|
2
2
|
import Button from "../Button/Button";
|
|
3
|
-
import { UnstyledButtonProps } from "../Button/UnstyledButton";
|
|
4
|
-
import { TextProps } from "../Text";
|
|
3
|
+
import { type UnstyledButtonProps } from "../Button/UnstyledButton";
|
|
4
|
+
import { type TextProps } from "../Text";
|
|
5
5
|
export declare const defaultMenuItemsClassName = "z-10 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-hidden dark:bg-zinc-800";
|
|
6
6
|
export type MenuProps = {
|
|
7
7
|
className?: string;
|
package/components/Menu/Menu.jsx
CHANGED
|
@@ -3,21 +3,21 @@ import { Menu as HuiMenu, Transition } from "@headlessui/react";
|
|
|
3
3
|
import { ChevronDownIcon } from "@heroicons/react/20/solid";
|
|
4
4
|
import clsx from "../../utils/clsx";
|
|
5
5
|
import Button from "../Button/Button";
|
|
6
|
-
import UnstyledButton from "../Button/UnstyledButton";
|
|
7
|
-
import Text from "../Text";
|
|
6
|
+
import UnstyledButton, {} from "../Button/UnstyledButton";
|
|
7
|
+
import Text, {} from "../Text";
|
|
8
8
|
import { useMount } from "react-use";
|
|
9
9
|
export const defaultMenuItemsClassName = "z-10 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-hidden dark:bg-zinc-800";
|
|
10
10
|
const Item = function MenuItem({ className, icon, children, ...props }) {
|
|
11
|
-
return (<HuiMenu.Item>
|
|
11
|
+
return (<HuiMenu.Item>
|
|
12
12
|
{({ active }) => (<UnstyledButton {...props} type="button" className={clsx("flex w-full items-center text-left", active
|
|
13
13
|
? "bg-zinc-100 text-zinc-900 dark:bg-zinc-700/50 dark:text-zinc-100"
|
|
14
|
-
: "text-zinc-700 dark:text-zinc-200", "block px-4 py-2 text-sm", className)}>
|
|
14
|
+
: "text-zinc-700 dark:text-zinc-200", "block px-4 py-2 text-sm", className)}>
|
|
15
15
|
{icon &&
|
|
16
16
|
cloneElement(icon, {
|
|
17
17
|
className: clsx("w-5 mr-2", icon.props.className),
|
|
18
|
-
})}
|
|
19
|
-
{children}
|
|
20
|
-
</UnstyledButton>)}
|
|
18
|
+
})}
|
|
19
|
+
{children}
|
|
20
|
+
</UnstyledButton>)}
|
|
21
21
|
</HuiMenu.Item>);
|
|
22
22
|
};
|
|
23
23
|
const Label = function MenuLabel(props) {
|
|
@@ -27,16 +27,16 @@ const Menu = function Menu({ className, iconClassName, position = "right", child
|
|
|
27
27
|
useMount(() => {
|
|
28
28
|
console.warn("<Menu> was deprecated and should be replaced with <DropdownMenu>");
|
|
29
29
|
});
|
|
30
|
-
return (<HuiMenu as="div" className={clsx("relative inline-block text-left", className)} {...props}>
|
|
31
|
-
<div>
|
|
30
|
+
return (<HuiMenu as="div" className={clsx("relative inline-block text-left", className)} {...props}>
|
|
31
|
+
<div>
|
|
32
32
|
{button ? (<HuiMenu.Button as={Fragment}>{button}</HuiMenu.Button>) : (<HuiMenu.Button
|
|
33
33
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
34
|
-
as={Button} className={clsx("flex w-full", buttonProps?.className)} trailing={<ChevronDownIcon className={iconClassName}/>} {...buttonProps}>
|
|
35
|
-
{label}
|
|
36
|
-
</HuiMenu.Button>)}
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<Transition as={Fragment} enter="transition ease-out duration-100" enterFrom="transform opacity-0 scale-95" enterTo="transform opacity-100 scale-100" leave="transition ease-in duration-75" leaveFrom="transform opacity-100 scale-100" leaveTo="transform opacity-0 scale-95">
|
|
34
|
+
as={Button} className={clsx("flex w-full", buttonProps?.className)} trailing={<ChevronDownIcon className={iconClassName}/>} {...buttonProps}>
|
|
35
|
+
{label}
|
|
36
|
+
</HuiMenu.Button>)}
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<Transition as={Fragment} enter="transition ease-out duration-100" enterFrom="transform opacity-0 scale-95" enterTo="transform opacity-100 scale-100" leave="transition ease-in duration-75" leaveFrom="transform opacity-100 scale-100" leaveTo="transform opacity-0 scale-95">
|
|
40
40
|
<HuiMenu.Items unmount={unmount} className={clsx(defaultMenuItemsClassName, "absolute mt-2 min-w-[14rem]", {
|
|
41
41
|
"right-0": position.includes("right"),
|
|
42
42
|
"origin-top-right": position.includes("right") && !position.includes("bottom"),
|
|
@@ -45,10 +45,10 @@ const Menu = function Menu({ className, iconClassName, position = "right", child
|
|
|
45
45
|
"origin-bottom-left": position.includes("left") && position.includes("bottom"),
|
|
46
46
|
"left-0": position.includes("left"),
|
|
47
47
|
"bottom-0": position.includes("bottom"),
|
|
48
|
-
}, menuItemsClassName)}>
|
|
49
|
-
<div className="py-1">{children}</div>
|
|
50
|
-
</HuiMenu.Items>
|
|
51
|
-
</Transition>
|
|
48
|
+
}, menuItemsClassName)}>
|
|
49
|
+
<div className="py-1">{children}</div>
|
|
50
|
+
</HuiMenu.Items>
|
|
51
|
+
</Transition>
|
|
52
52
|
</HuiMenu>);
|
|
53
53
|
};
|
|
54
54
|
export default Object.assign(Menu, { Label, Item });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, CSSProperties, ReactElement, ReactNode } from "react";
|
|
1
|
+
import { type ComponentPropsWithoutRef, type CSSProperties, type ReactElement, type ReactNode } from "react";
|
|
2
2
|
import Button from "../Button";
|
|
3
3
|
declare function Modal({ open, onClose, children, overlayClassName, panelClassName, dialogClassName, dialogOuterPanelClassName, dialogOverflowClassName, style, }: {
|
|
4
4
|
open?: boolean;
|
|
@@ -7,40 +7,40 @@ import { XMarkIcon } from "@heroicons/react/24/solid";
|
|
|
7
7
|
import clsx from "../../utils/clsx";
|
|
8
8
|
export default function Modal({ open, onClose, children, overlayClassName, panelClassName, dialogClassName, dialogOuterPanelClassName, dialogOverflowClassName, style, }) {
|
|
9
9
|
const handleOnClose = useCallback(() => onClose?.(), [onClose]);
|
|
10
|
-
return (<Transition.Root show={open} as={Fragment}>
|
|
11
|
-
<Dialog as="div" className={clsx("relative z-10", dialogClassName)} onClose={handleOnClose} style={style}>
|
|
12
|
-
<Transition.Child as={Fragment} enter="ease-out duration-300" enterFrom="opacity-0" enterTo="opacity-100" leave="ease-in duration-200" leaveFrom="opacity-100" leaveTo="opacity-0">
|
|
13
|
-
<div className={clsx("fixed inset-0 bg-white/75 transition-opacity dark:bg-black/75", overlayClassName)}/>
|
|
14
|
-
</Transition.Child>
|
|
15
|
-
|
|
16
|
-
<div className={clsx("fixed inset-0 z-10 overflow-y-auto", dialogOverflowClassName)}>
|
|
17
|
-
<div className={clsx("flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0", dialogOuterPanelClassName)}>
|
|
18
|
-
<Transition.Child as={Fragment} enter="ease-out duration-300" enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" enterTo="opacity-100 translate-y-0 sm:scale-100" leave="ease-in duration-200" leaveFrom="opacity-100 translate-y-0 sm:scale-100" leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95">
|
|
19
|
-
<Dialog.Panel className={clsx("relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all dark:bg-zinc-900 dark:ring-1 dark:ring-white/5
|
|
20
|
-
{children}
|
|
21
|
-
</Dialog.Panel>
|
|
22
|
-
</Transition.Child>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
</Dialog>
|
|
10
|
+
return (<Transition.Root show={open} as={Fragment}>
|
|
11
|
+
<Dialog as="div" className={clsx("relative z-10", dialogClassName)} onClose={handleOnClose} style={style}>
|
|
12
|
+
<Transition.Child as={Fragment} enter="ease-out duration-300" enterFrom="opacity-0" enterTo="opacity-100" leave="ease-in duration-200" leaveFrom="opacity-100" leaveTo="opacity-0">
|
|
13
|
+
<div className={clsx("fixed inset-0 bg-white/75 transition-opacity dark:bg-black/75", overlayClassName)}/>
|
|
14
|
+
</Transition.Child>
|
|
15
|
+
|
|
16
|
+
<div className={clsx("fixed inset-0 z-10 overflow-y-auto", dialogOverflowClassName)}>
|
|
17
|
+
<div className={clsx("flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0", dialogOuterPanelClassName)}>
|
|
18
|
+
<Transition.Child as={Fragment} enter="ease-out duration-300" enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" enterTo="opacity-100 translate-y-0 sm:scale-100" leave="ease-in duration-200" leaveFrom="opacity-100 translate-y-0 sm:scale-100" leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95">
|
|
19
|
+
<Dialog.Panel className={clsx("relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-sm dark:bg-zinc-900 dark:ring-1 dark:ring-white/5", panelClassName)}>
|
|
20
|
+
{children}
|
|
21
|
+
</Dialog.Panel>
|
|
22
|
+
</Transition.Child>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</Dialog>
|
|
26
26
|
</Transition.Root>);
|
|
27
27
|
}
|
|
28
28
|
Modal.Container = ModalContainer;
|
|
29
29
|
function ModalContainer({ children, className, }) {
|
|
30
|
-
return (<Stack className={clsx("gap-4! px-4 pb-4
|
|
31
|
-
{children}
|
|
30
|
+
return (<Stack className={clsx("gap-4! px-4 pt-5 pb-4 sm:p-6", className)}>
|
|
31
|
+
{children}
|
|
32
32
|
</Stack>);
|
|
33
33
|
}
|
|
34
34
|
Modal.Title = ModalTitle;
|
|
35
35
|
function ModalTitle({ children, className, }) {
|
|
36
|
-
return (<Dialog.Title as="h3" className={clsx("text-center text-lg font-medium
|
|
37
|
-
{children}
|
|
36
|
+
return (<Dialog.Title as="h3" className={clsx("text-center text-lg leading-6 font-medium text-zinc-900 dark:text-zinc-100", className)}>
|
|
37
|
+
{children}
|
|
38
38
|
</Dialog.Title>);
|
|
39
39
|
}
|
|
40
40
|
Modal.Content = ModalContent;
|
|
41
41
|
function ModalContent({ children, className, }) {
|
|
42
|
-
return (<div className={clsx("text-center text-sm text-zinc-500 dark:text-zinc-400", className)}>
|
|
43
|
-
{children}
|
|
42
|
+
return (<div className={clsx("text-center text-sm text-zinc-500 dark:text-zinc-400", className)}>
|
|
43
|
+
{children}
|
|
44
44
|
</div>);
|
|
45
45
|
}
|
|
46
46
|
Modal.Actions = ModalActions;
|
|
@@ -49,17 +49,17 @@ function ModalActions({ children, className, }) {
|
|
|
49
49
|
}
|
|
50
50
|
Modal.Icon = ModalIcon;
|
|
51
51
|
function ModalIcon({ children, }) {
|
|
52
|
-
return (<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-800">
|
|
52
|
+
return (<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-800">
|
|
53
53
|
{children &&
|
|
54
54
|
cloneElement(children, {
|
|
55
55
|
className: "h-6 w-6 text-green-600 dark:text-green-400",
|
|
56
56
|
"aria-hidden": "true",
|
|
57
|
-
})}
|
|
57
|
+
})}
|
|
58
58
|
</div>);
|
|
59
59
|
}
|
|
60
60
|
Modal.CloseButton = ModalCloseButton;
|
|
61
61
|
function ModalCloseButton({ className, ...props }) {
|
|
62
|
-
return (<Button icon className={clsx("absolute
|
|
63
|
-
<XMarkIcon />
|
|
62
|
+
return (<Button icon className={clsx("absolute top-2 right-2", className)} variant="text" {...props}>
|
|
63
|
+
<XMarkIcon />
|
|
64
64
|
</Button>);
|
|
65
65
|
}
|
|
@@ -4,9 +4,9 @@ import clsx from "../../utils/clsx";
|
|
|
4
4
|
import useModeToggle from "./useModeToggle";
|
|
5
5
|
const ModeToggle = function ModeToggle({ ariaLabel = "Toggle dark mode", className, iconClassName, ref, }) {
|
|
6
6
|
const toggleMode = useModeToggle();
|
|
7
|
-
return (<Button ref={ref} icon variant="text" aria-label={ariaLabel} onClick={toggleMode} className={className}>
|
|
8
|
-
<SunIcon className={clsx("dark:hidden", iconClassName)}/>
|
|
9
|
-
<MoonIcon className={clsx("hidden dark:block", iconClassName)}/>
|
|
7
|
+
return (<Button ref={ref} icon variant="text" aria-label={ariaLabel} onClick={toggleMode} className={className}>
|
|
8
|
+
<SunIcon className={clsx("dark:hidden", iconClassName)}/>
|
|
9
|
+
<MoonIcon className={clsx("hidden dark:block", iconClassName)}/>
|
|
10
10
|
</Button>);
|
|
11
11
|
};
|
|
12
12
|
export default ModeToggle;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
import Input, { UnstyledInputProps } from "../Input";
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import Input, { type UnstyledInputProps } from "../Input";
|
|
3
3
|
export interface MultiSelectProps<T extends object | string> extends Omit<UnstyledInputProps<false>, "as" | "onSelect" | "inputClassName" | "innerClassName" | "value" | "onChange"> {
|
|
4
4
|
placeholder?: string;
|
|
5
5
|
emptyText?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Combobox } from "@headlessui/react";
|
|
2
2
|
import Loading from "../Loading";
|
|
3
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
|
-
import { defaultHelpTextClassName, defaultInputClassName, defaultLabelClassName, defaultLeadingInputClassName, defaultTrailingClassName, defaultTrailingInputClassName, UnstyledInput, } from "../Input";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useState, } from "react";
|
|
4
|
+
import Input, { defaultHelpTextClassName, defaultInputClassName, defaultLabelClassName, defaultLeadingInputClassName, defaultTrailingClassName, defaultTrailingInputClassName, UnstyledInput, } from "../Input";
|
|
5
5
|
import clsx from "../../utils/clsx";
|
|
6
6
|
import { isEqual, take } from "lodash-es";
|
|
7
7
|
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/20/solid";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
export declare function getValue<Id extends string | number, T extends object | string>(id: Id, item: T): string | number;
|
|
3
3
|
export declare function MultiSelectInput<Id extends string | number, T extends object | string>({ className, selectedItems, doRender, removeItem, valueProperty, readOnly, items, ...props }: {
|
|
4
4
|
className?: string;
|
|
@@ -58,7 +58,6 @@ function MultiText({ value, onChangeValue, onChange, onBlur, name, id, className
|
|
|
58
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
61
|
}, [innerValue]);
|
|
63
62
|
return (<InputWrapper id={id} className={className} helpText={(invalid ? invalidHelpText : undefined) || helpText} label={label} error={invalid || error} required={required}>
|
|
64
63
|
<div className="ui-multi-text" onClick={() => inputRef.current?.focus()} data-focused={innerFocused ? "" : undefined} data-error={invalid || error ? "" : undefined} data-loading={loading ? "" : undefined} data-readonly={readOnly ? "" : undefined}>
|
|
@@ -10,20 +10,20 @@ export default function NavigationDrawer({ children, navigationChildren, positio
|
|
|
10
10
|
navigationDrawerState.setOpen(open);
|
|
11
11
|
}
|
|
12
12
|
}, []);
|
|
13
|
-
return (<>
|
|
14
|
-
<Drawer open={isOpen} onChangeOpen={handleChangeOpen} className="lg:hidden" position={position} title={title} noPadding={noPadding} panelClassName={panelClassName}>
|
|
15
|
-
{navigationChildren}
|
|
16
|
-
</Drawer>
|
|
17
|
-
<div className={clsx("fixed
|
|
13
|
+
return (<>
|
|
14
|
+
<Drawer open={isOpen} onChangeOpen={handleChangeOpen} className="lg:hidden" position={position} title={title} noPadding={noPadding} panelClassName={panelClassName}>
|
|
15
|
+
{navigationChildren}
|
|
16
|
+
</Drawer>
|
|
17
|
+
<div className={clsx("fixed top-0 left-0 z-10 hidden h-full w-full max-w-xs flex-1 overflow-y-auto px-4 py-4 pt-20 lg:block", "bg-zinc-100/95 backdrop-blur-sm [@supports(backdrop-filter:blur(0))]:bg-zinc-100/75", "dark:bg-zinc-900/95 dark:[@supports(backdrop-filter:blur(0))]:bg-zinc-900/75", "transition-transform", {
|
|
18
18
|
"translate-x-0": isOpen,
|
|
19
19
|
"-translate-x-full": !isOpen,
|
|
20
|
-
}, panelClassName)}>
|
|
21
|
-
{navigationChildren}
|
|
22
|
-
</div>
|
|
20
|
+
}, panelClassName)}>
|
|
21
|
+
{navigationChildren}
|
|
22
|
+
</div>
|
|
23
23
|
<div className={clsx("flex min-h-screen flex-col ring-offset-zinc-100 transition-all duration-300", {
|
|
24
24
|
"lg:pl-80 lg:duration-150": isOpen,
|
|
25
|
-
})}>
|
|
26
|
-
{children}
|
|
27
|
-
</div>
|
|
25
|
+
})}>
|
|
26
|
+
{children}
|
|
27
|
+
</div>
|
|
28
28
|
</>);
|
|
29
29
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from "react";
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
2
|
export default function NavigationItem({ icon, children, href, exact, alternativeActiveHrefs, className, disabled, active, }: {
|
|
3
3
|
icon?: ReactElement<{
|
|
4
4
|
className?: string;
|