ikoncomponents 1.1.7 → 1.1.9
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/dist/ikoncomponents/alert-dialog/dialog-context.d.ts +21 -0
- package/dist/ikoncomponents/alert-dialog/dialog-context.js +30 -0
- package/dist/ikoncomponents/app-breadcrumb/BreadcrumbProvider.d.ts +16 -0
- package/dist/ikoncomponents/app-breadcrumb/BreadcrumbProvider.js +32 -0
- package/dist/ikoncomponents/app-breadcrumb/index.d.ts +5 -0
- package/dist/ikoncomponents/app-breadcrumb/index.js +57 -0
- package/dist/ikoncomponents/form-fields/combobox-input/index.d.ts +2 -0
- package/dist/ikoncomponents/form-fields/combobox-input/index.js +21 -0
- package/dist/ikoncomponents/form-fields/combobox-input-value/index.d.ts +18 -0
- package/dist/ikoncomponents/form-fields/combobox-input-value/index.js +25 -0
- package/dist/ikoncomponents/form-fields/date-input/index.d.ts +2 -0
- package/dist/ikoncomponents/form-fields/date-input/index.js +15 -0
- package/dist/ikoncomponents/form-fields/file-input/index.d.ts +1 -0
- package/dist/ikoncomponents/form-fields/file-input/index.js +4 -0
- package/dist/ikoncomponents/form-fields/input/index.d.ts +2 -0
- package/dist/ikoncomponents/form-fields/input/index.js +18 -0
- package/dist/ikoncomponents/form-fields/multi-combobox-input/index.d.ts +6 -0
- package/dist/ikoncomponents/form-fields/multi-combobox-input/index.js +381 -0
- package/dist/ikoncomponents/form-fields/otp-input/index.d.ts +2 -0
- package/dist/ikoncomponents/form-fields/otp-input/index.js +18 -0
- package/dist/ikoncomponents/form-fields/phone-input/index.d.ts +1 -0
- package/dist/ikoncomponents/form-fields/phone-input/index.js +4 -0
- package/dist/ikoncomponents/form-fields/textarea/index.d.ts +2 -0
- package/dist/ikoncomponents/form-fields/textarea/index.js +18 -0
- package/dist/ikoncomponents/form-fields/types/index.d.ts +36 -0
- package/dist/ikoncomponents/form-fields/types/index.js +1 -0
- package/dist/ikoncomponents/main-layout/SidebarNavContext.d.ts +27 -0
- package/dist/ikoncomponents/main-layout/SidebarNavContext.js +40 -0
- package/dist/ikoncomponents/main-layout/app-sidebar.d.ts +3 -0
- package/dist/ikoncomponents/main-layout/app-sidebar.js +19 -0
- package/dist/ikoncomponents/main-layout/footer.d.ts +1 -0
- package/dist/ikoncomponents/main-layout/footer.js +4 -0
- package/dist/ikoncomponents/main-layout/header.d.ts +1 -0
- package/dist/ikoncomponents/main-layout/header.js +10 -0
- package/dist/ikoncomponents/main-layout/index.d.ts +5 -0
- package/dist/ikoncomponents/main-layout/index.js +11 -0
- package/dist/ikoncomponents/main-layout/main-sidebar.d.ts +27 -0
- package/dist/ikoncomponents/main-layout/main-sidebar.js +74 -0
- package/dist/ikoncomponents/main-layout/nav-main.d.ts +8 -0
- package/dist/ikoncomponents/main-layout/nav-main.js +31 -0
- package/dist/ikoncomponents/resource/index.d.ts +19 -0
- package/dist/ikoncomponents/resource/index.js +89 -0
- package/dist/ikoncomponents/skeleton-loader/skeleton-table.d.ts +5 -0
- package/dist/ikoncomponents/skeleton-loader/skeleton-table.js +6 -0
- package/dist/ikoncomponents/skeleton-loader/skeleton-widget.d.ts +3 -0
- package/dist/ikoncomponents/skeleton-loader/skeleton-widget.js +5 -0
- package/dist/ikoncomponents/theme-toggle-btn/index.d.ts +1 -1
- package/dist/ikoncomponents/theme-toggle-btn/index.js +112 -4
- package/dist/ikoncomponents/upload-tab/index.d.ts +1 -0
- package/dist/ikoncomponents/upload-tab/index.js +92 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +33 -0
- package/dist/shadcn/aspect-ratio.d.ts +3 -0
- package/dist/shadcn/aspect-ratio.js +19 -0
- package/dist/shadcn/breadcrumb.d.ts +11 -0
- package/dist/shadcn/breadcrumb.js +45 -0
- package/dist/shadcn/button.d.ts +1 -1
- package/dist/shadcn/button.js +3 -2
- package/dist/shadcn/collapsible.d.ts +5 -0
- package/dist/shadcn/collapsible.js +27 -0
- package/dist/shadcn/drawer.d.ts +13 -0
- package/dist/shadcn/drawer.js +56 -0
- package/dist/shadcn/form.d.ts +24 -0
- package/dist/shadcn/form.js +70 -0
- package/dist/shadcn/input-otp.d.ts +34 -0
- package/dist/shadcn/input-otp.js +40 -0
- package/dist/shadcn/radio-group.js +2 -4
- package/dist/shadcn/table.js +1 -1
- package/dist/shadcn/tabs.js +1 -1
- package/dist/shadcn/toggle-group.d.ts +9 -0
- package/dist/shadcn/toggle-group.js +35 -0
- package/dist/shadcn/toggle.d.ts +9 -0
- package/dist/shadcn/toggle.js +38 -0
- package/dist/shadcn/tooltip.js +2 -2
- package/dist/styles.css +534 -41
- package/dist/utils/border-radius-provider.d.ts +11 -0
- package/dist/utils/border-radius-provider.js +35 -0
- package/dist/utils/font-provider.d.ts +11 -0
- package/dist/utils/font-provider.js +37 -0
- package/dist/utils/session/cookieSession.d.ts +8 -0
- package/dist/utils/session/cookieSession.js +33 -0
- package/dist/utils/token-management/index.d.ts +7 -0
- package/dist/utils/token-management/index.js +78 -0
- package/dist/utils/token-management/types.d.ts +6 -0
- package/dist/utils/token-management/types.js +1 -0
- package/package.json +98 -91
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
interface DialogContextProps {
|
|
3
|
+
openDialog: (options: DialogOptions) => void;
|
|
4
|
+
closeDialog: () => void;
|
|
5
|
+
}
|
|
6
|
+
interface DialogOptions {
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
onConfirm?: () => void;
|
|
10
|
+
onCancel?: () => void;
|
|
11
|
+
onThird?: () => void;
|
|
12
|
+
confirmText?: string;
|
|
13
|
+
cancelText?: string;
|
|
14
|
+
thirdOptionText?: string;
|
|
15
|
+
fontSize?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const useDialog: () => DialogContextProps;
|
|
18
|
+
export declare const DialogProvider: React.FC<{
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useState } from "react";
|
|
4
|
+
import { CustomAlertDialog } from "../alert-dialog";
|
|
5
|
+
const DialogContext = createContext(undefined);
|
|
6
|
+
export const useDialog = () => {
|
|
7
|
+
const context = useContext(DialogContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error("useDialog must be used within a DialogProvider");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
13
|
+
export const DialogProvider = ({ children }) => {
|
|
14
|
+
const [dialogOptions, setDialogOptions] = useState(null);
|
|
15
|
+
const openDialog = (options) => setDialogOptions(options);
|
|
16
|
+
const closeDialog = () => setDialogOptions(null);
|
|
17
|
+
return (_jsxs(DialogContext.Provider, { value: { openDialog, closeDialog }, children: [children, dialogOptions && (_jsx(CustomAlertDialog, { title: dialogOptions.title, description: dialogOptions.description, fontSize: dialogOptions.fontSize || "text-base", cancelText: dialogOptions.cancelText || "", confirmText: dialogOptions.confirmText || "", thirdOptionText: dialogOptions.thirdOptionText || "", onConfirm: () => {
|
|
18
|
+
if (dialogOptions.onConfirm)
|
|
19
|
+
dialogOptions.onConfirm();
|
|
20
|
+
closeDialog();
|
|
21
|
+
}, onCancel: () => {
|
|
22
|
+
if (dialogOptions.onCancel)
|
|
23
|
+
dialogOptions.onCancel();
|
|
24
|
+
closeDialog();
|
|
25
|
+
}, onThird: () => {
|
|
26
|
+
if (dialogOptions.onThird)
|
|
27
|
+
dialogOptions.onThird();
|
|
28
|
+
closeDialog();
|
|
29
|
+
} }))] }));
|
|
30
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface BreadcrumbItemProps {
|
|
3
|
+
title: string;
|
|
4
|
+
href?: string;
|
|
5
|
+
level: number;
|
|
6
|
+
}
|
|
7
|
+
interface BreadcrumbContextType {
|
|
8
|
+
breadcrumbItems: BreadcrumbItemProps[];
|
|
9
|
+
addBreadcrumb: (item: BreadcrumbItemProps) => void;
|
|
10
|
+
backBreadcrumb: (item: BreadcrumbItemProps) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function BreadcrumbProvider({ children }: {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function useBreadcrumb(): BreadcrumbContextType;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useState } from 'react';
|
|
4
|
+
// Create the context with a default value
|
|
5
|
+
const BreadcrumbContext = createContext(undefined);
|
|
6
|
+
// Create a provider component
|
|
7
|
+
export function BreadcrumbProvider({ children }) {
|
|
8
|
+
const [breadcrumbItems, setBreadcrumbItems] = useState([]);
|
|
9
|
+
// Function to add a breadcrumb item
|
|
10
|
+
const addBreadcrumb = (item) => {
|
|
11
|
+
setBreadcrumbItems((prevItems) => {
|
|
12
|
+
const filterState = prevItems.filter((e) => e.level < item.level);
|
|
13
|
+
return [...filterState, item];
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
// Function to go back in the breadcrumb
|
|
17
|
+
const backBreadcrumb = (item) => {
|
|
18
|
+
setBreadcrumbItems((prevItems) => {
|
|
19
|
+
const filterState = prevItems.filter((e) => e.level <= item.level);
|
|
20
|
+
return [...filterState];
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
return (_jsx(BreadcrumbContext.Provider, { value: { breadcrumbItems, addBreadcrumb, backBreadcrumb }, children: children }));
|
|
24
|
+
}
|
|
25
|
+
// Custom hook to use the BreadcrumbContext
|
|
26
|
+
export function useBreadcrumb() {
|
|
27
|
+
const context = useContext(BreadcrumbContext);
|
|
28
|
+
if (!context) {
|
|
29
|
+
throw new Error('useBreadcrumb must be used within a BreadcrumbProvider');
|
|
30
|
+
}
|
|
31
|
+
return context;
|
|
32
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BreadcrumbItemProps } from "./BreadcrumbProvider";
|
|
2
|
+
export declare function AppBreadcrumb(): import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
export declare function RenderAppBreadcrumb({ breadcrumb, }: {
|
|
4
|
+
breadcrumb: BreadcrumbItemProps;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
import { Fragment, useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { redirect } from "next/navigation";
|
|
6
|
+
import { useBreadcrumb } from "./BreadcrumbProvider";
|
|
7
|
+
import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "../../shadcn/breadcrumb";
|
|
8
|
+
import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, } from "../../shadcn/drawer";
|
|
9
|
+
import { Button } from "../../shadcn/button";
|
|
10
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "../../shadcn/dropdown-menu";
|
|
11
|
+
import { useIsMobile } from "../../hooks/use-mobile";
|
|
12
|
+
export function AppBreadcrumb() {
|
|
13
|
+
const { breadcrumbItems, backBreadcrumb } = useBreadcrumb();
|
|
14
|
+
const [open, setOpen] = useState(false);
|
|
15
|
+
const [itemToDisplay, setItemToDisplay] = useState(2);
|
|
16
|
+
const isMobile = useIsMobile();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (isMobile) {
|
|
19
|
+
setItemToDisplay(2);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
setItemToDisplay(4);
|
|
23
|
+
}
|
|
24
|
+
}, [isMobile]);
|
|
25
|
+
const breadcrumbObj = useMemo(() => {
|
|
26
|
+
return {
|
|
27
|
+
firstVisibleBreadcrumbList: breadcrumbItems.slice(0, 2),
|
|
28
|
+
hiddenBreadcrumbList: isMobile
|
|
29
|
+
? breadcrumbItems.slice(2)
|
|
30
|
+
: breadcrumbItems.slice(2, itemToDisplay),
|
|
31
|
+
lastVisibleBreadcrumbList: breadcrumbItems.length > 2
|
|
32
|
+
? breadcrumbItems.slice(2 -
|
|
33
|
+
(breadcrumbItems.length < itemToDisplay
|
|
34
|
+
? breadcrumbItems.length
|
|
35
|
+
: itemToDisplay))
|
|
36
|
+
: [],
|
|
37
|
+
};
|
|
38
|
+
}, [breadcrumbItems, itemToDisplay, isMobile]);
|
|
39
|
+
if (!breadcrumbObj || isMobile == undefined || itemToDisplay == null) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return (_jsx(Breadcrumb, { children: _jsxs(BreadcrumbList, { children: [breadcrumbObj.firstVisibleBreadcrumbList.map((item, index) => index < breadcrumbItems.length - 1 ? (_jsxs(Fragment, { children: [_jsx(BreadcrumbItem, { children: !item.href ? (_jsx(BreadcrumbPage, { className: "max-w-20 truncate md:max-w-none", children: item.title })) : (_jsx(BreadcrumbLink, { className: "max-w-20 truncate md:max-w-none cursor-pointer", onClick: () => {
|
|
43
|
+
backBreadcrumb(item);
|
|
44
|
+
redirect(item.href);
|
|
45
|
+
}, children: item.title })) }), _jsx(BreadcrumbSeparator, {}, "firstsep" + index)] }, "first" + index)) : (_jsx(BreadcrumbItem, { children: _jsx(BreadcrumbPage, { className: "max-w-20 truncate md:max-w-none", children: item.title }) }, "first" + index))), breadcrumbItems.length > itemToDisplay ? (_jsxs(_Fragment, { children: [_jsx(BreadcrumbItem, { children: !isMobile ? (_jsxs(DropdownMenu, { open: open, onOpenChange: setOpen, children: [_jsx(DropdownMenuTrigger, { className: "flex items-center gap-1", "aria-label": "Toggle menu", children: _jsx(BreadcrumbEllipsis, { className: "h-4 w-4" }) }), _jsx(DropdownMenuContent, { align: "start", children: breadcrumbObj.hiddenBreadcrumbList.map((item, index) => (_jsx(DropdownMenuItem, { children: !item.href ? (_jsx("span", { children: item.title })) : (_jsx(Link, { href: item.href ? item.href : "#", children: item.title })) }, index))) })] })) : (_jsxs(Drawer, { open: open, onOpenChange: setOpen, children: [_jsx(DrawerTrigger, { "aria-label": "Toggle Menu", children: _jsx(BreadcrumbEllipsis, { className: "h-4 w-4" }) }), _jsxs(DrawerContent, { children: [_jsxs(DrawerHeader, { className: "text-left", children: [_jsx(DrawerTitle, { children: "Navigate to" }), _jsx(DrawerDescription, { children: "Select a page to navigate to." })] }), _jsx("div", { className: "grid gap-1 px-2 lg:px-4", children: breadcrumbObj.hiddenBreadcrumbList.map((item, index) => (_jsx("div", { children: item.clickable == false ? (_jsx("span", { className: "py-1 text-sm", children: item.title })) : (_jsx(Link, { href: item.href ? item.href : "#", className: "py-1 text-sm", children: item.title })) }, index))) }), _jsx(DrawerFooter, { className: "pt-4", children: _jsx(DrawerClose, { asChild: true, children: _jsx(Button, { variant: "outline", children: "Close" }) }) })] })] })) }), !isMobile && _jsx(BreadcrumbSeparator, {})] })) : null, !isMobile &&
|
|
46
|
+
breadcrumbObj.lastVisibleBreadcrumbList.map((item, index) => index == breadcrumbObj.lastVisibleBreadcrumbList.length - 1 ? (_jsx(BreadcrumbItem, { children: _jsx(BreadcrumbPage, { className: "max-w-20 truncate md:max-w-none cursor-pointer", children: item.title }) }, "last" + index)) : (_jsxs(Fragment, { children: [_jsx(BreadcrumbItem, { children: !item.href ? (_jsx(BreadcrumbPage, { className: "max-w-20 truncate md:max-w-none", children: item.title })) : (_jsx(BreadcrumbLink, { className: "max-w-20 truncate md:max-w-none cursor-pointer", onClick: () => {
|
|
47
|
+
backBreadcrumb(item);
|
|
48
|
+
redirect(item.href);
|
|
49
|
+
}, children: item.title })) }), _jsx(BreadcrumbSeparator, {}, "lastsep" + index)] }, "last" + index)))] }, "BreadcrumbList1") }, "Breadcrumb1"));
|
|
50
|
+
}
|
|
51
|
+
export function RenderAppBreadcrumb({ breadcrumb, }) {
|
|
52
|
+
const { addBreadcrumb } = useBreadcrumb();
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
addBreadcrumb(breadcrumb);
|
|
55
|
+
}, [breadcrumb]);
|
|
56
|
+
return _jsx(_Fragment, {});
|
|
57
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "../../../shadcn/form";
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../../shadcn/popover";
|
|
4
|
+
import { Button } from "../../../shadcn/button";
|
|
5
|
+
import { cn } from "../../../utils/cn";
|
|
6
|
+
import { Check, ChevronsUpDown } from "lucide-react";
|
|
7
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "../../../shadcn/command";
|
|
8
|
+
export function FormComboboxInput({ formControl, name, label, placeholder, formDescription, items, disabled, onSelect, }) {
|
|
9
|
+
return (_jsx(_Fragment, { children: _jsx(FormField, { control: formControl, name: name, render: ({ field }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
return (_jsxs(FormItem, { className: "", children: [label && (_jsx(_Fragment, { children: _jsx(FormLabel, { children: label }) })), _jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, className: "w-full", children: _jsx(FormControl, { children: _jsxs(Button, { variant: "outline", role: "combobox", className: cn("justify-between", !field.value && "text-muted-foreground"), disabled: disabled == true ||
|
|
12
|
+
(disabled && disabled(...arguments)), children: [field.value
|
|
13
|
+
? ((_a = items.find((item) => item.value === field.value)) === null || _a === void 0 ? void 0 : _a.label) || field.value
|
|
14
|
+
: placeholder, _jsx(ChevronsUpDown, { className: "opacity-50" })] }) }) }), _jsx(PopoverContent, { className: "p-0", align: "start", children: _jsxs(Command, { children: [_jsx(CommandInput, { placeholder: "Search..." }), _jsxs(CommandList, { children: [_jsx(CommandEmpty, { children: "No items found." }), _jsx(CommandGroup, { children: items.map((item) => (_jsxs(CommandItem, { value: item.value, disabled: (item.disabled == true || (item.disabled && item.disabled(item))), onSelect: (value) => {
|
|
15
|
+
field.onChange(value);
|
|
16
|
+
onSelect && onSelect(value);
|
|
17
|
+
}, children: [(item === null || item === void 0 ? void 0 : item.label) || item.value, _jsx(Check, { className: cn("ml-auto", item.value === field.value
|
|
18
|
+
? "opacity-100"
|
|
19
|
+
: "opacity-0") })] }, item.value))) })] })] }) })] }), formDescription && (_jsx(FormDescription, { children: formDescription })), _jsx(FormMessage, {})] }));
|
|
20
|
+
} }) }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Control } from "react-hook-form";
|
|
2
|
+
export interface FormComboboxInputProps {
|
|
3
|
+
formControl: Control<any>;
|
|
4
|
+
name: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
formDescription?: string;
|
|
8
|
+
items: {
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
disabled?: boolean | ((item: any) => boolean);
|
|
12
|
+
}[];
|
|
13
|
+
disabled?: boolean | ((...args: any[]) => boolean);
|
|
14
|
+
onSelect?: (value: any) => void;
|
|
15
|
+
value?: string;
|
|
16
|
+
onChange?: (value: any) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function FormComboboxInputWithValue(props: FormComboboxInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useController } from "react-hook-form";
|
|
3
|
+
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "../../../shadcn/form";
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../../shadcn/popover";
|
|
5
|
+
import { Button } from "../../../shadcn/button";
|
|
6
|
+
import { cn } from "../../../utils/cn";
|
|
7
|
+
import { Check, ChevronsUpDown } from "lucide-react";
|
|
8
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "../../../shadcn/command";
|
|
9
|
+
export function FormComboboxInputWithValue(props) {
|
|
10
|
+
const { field } = useController({ name: props.name, control: props.formControl });
|
|
11
|
+
// Use the external value if provided, otherwise use the field's value.
|
|
12
|
+
const currentValue = props.value !== undefined ? props.value : field.value;
|
|
13
|
+
return (_jsx(FormField, { control: props.formControl, name: props.name, render: ({ field }) => {
|
|
14
|
+
var _a;
|
|
15
|
+
return (_jsxs(FormItem, { className: "", children: [props.label && (_jsxs(_Fragment, { children: [_jsx(FormLabel, { children: props.label }), _jsx("br", {})] })), _jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, className: "w-full", children: _jsx(FormControl, { children: _jsxs(Button, { variant: "outline", role: "combobox", className: cn("justify-between", !currentValue && "text-muted-foreground"), disabled: typeof props.disabled === "function" ? props.disabled() : props.disabled, children: [currentValue
|
|
16
|
+
? ((_a = props.items.find((item) => item.value === currentValue)) === null || _a === void 0 ? void 0 : _a.label) || currentValue
|
|
17
|
+
: props.placeholder, _jsx(ChevronsUpDown, { className: "opacity-50" })] }) }) }), _jsx(PopoverContent, { className: "p-0", align: "start", children: _jsxs(Command, { children: [_jsx(CommandInput, { placeholder: "Search..." }), _jsxs(CommandList, { children: [_jsx(CommandEmpty, { children: "No items found." }), _jsx(CommandGroup, { children: props.items.map((item) => (_jsxs(CommandItem, { value: item.value, disabled: typeof item.disabled === "function"
|
|
18
|
+
? item.disabled(item)
|
|
19
|
+
: item.disabled, onSelect: (value) => {
|
|
20
|
+
field.onChange(value);
|
|
21
|
+
props.onSelect && props.onSelect(value);
|
|
22
|
+
props.onChange && props.onChange(value);
|
|
23
|
+
}, children: [(item === null || item === void 0 ? void 0 : item.label) || item.value, _jsx(Check, { className: cn("ml-auto", item.value === currentValue ? "opacity-100" : "opacity-0") })] }, item.value))) })] })] }) })] }), props.formDescription && (_jsx(FormDescription, { children: props.formDescription })), _jsx(FormMessage, {})] }));
|
|
24
|
+
} }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "../../../shadcn/form";
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../../shadcn/popover";
|
|
4
|
+
import { Button } from "../../../shadcn/button";
|
|
5
|
+
import { cn } from "../../../utils/cn";
|
|
6
|
+
import { format } from "date-fns";
|
|
7
|
+
import { CalendarIcon } from "lucide-react";
|
|
8
|
+
import { Calendar } from "../../../shadcn/calendar";
|
|
9
|
+
export function FormDateInput({ formControl, name, label, placeholder, dateFormat, calendarDateDisabled, formDescription, disabled, }) {
|
|
10
|
+
return (_jsx(_Fragment, { children: _jsx(FormField, { control: formControl, name: name, render: ({ field }) => (_jsxs(FormItem, { children: [label && (_jsxs(_Fragment, { children: [_jsx(FormLabel, { children: label }), _jsx("br", {})] })), _jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, className: "w-full", children: _jsx(FormControl, { children: _jsxs(Button, { variant: "outline", className: cn(!field.value && "text-foreground/50"), disabled: disabled, children: [field.value ? (format(field.value, dateFormat || "PPP")) : (_jsx("span", { children: placeholder || "Pick a date" })), _jsx(CalendarIcon, { className: "ml-auto h-4 w-4 opacity-50" })] }) }) }), _jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: _jsx(Calendar, { mode: "single", selected: field.value, onSelect: field.onChange, disabled: calendarDateDisabled,
|
|
11
|
+
// disabled={(date) =>
|
|
12
|
+
// date > new Date() || date < new Date("1900-01-01")
|
|
13
|
+
// }
|
|
14
|
+
initialFocus: true }) })] }), formDescription && (_jsx(FormDescription, { children: formDescription })), _jsx(FormMessage, {})] })) }) }));
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function FormFileInput(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../../../shadcn/form';
|
|
14
|
+
import { Input } from '../../../shadcn/input';
|
|
15
|
+
export function FormInput(_a) {
|
|
16
|
+
var { formControl, label, formDescription, extraFormComponent, name } = _a, inputProps = __rest(_a, ["formControl", "label", "formDescription", "extraFormComponent", "name"]);
|
|
17
|
+
return (_jsx(_Fragment, { children: _jsx(FormField, { control: formControl, name: name, render: ({ field }) => (_jsxs(FormItem, { children: [label && _jsx(FormLabel, { children: label }), _jsx(FormControl, { children: _jsx(Input, Object.assign({}, field, inputProps)) }), extraFormComponent && extraFormComponent(field.value), formDescription && _jsx(FormDescription, { children: formDescription }), _jsx(FormMessage, {})] })) }) }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormComboboxInputProps as BaseFormComboboxInputProps } from "../../form-fields/types";
|
|
2
|
+
interface FormComboboxInputProps extends BaseFormComboboxInputProps {
|
|
3
|
+
defaultOptions?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function dFormMultiComboboxInput({ formControl, name, label, placeholder, formDescription, items, disabled, onSelect, defaultValue, defaultOptions, }: FormComboboxInputProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|