@solidpb/ui-kit 0.1.1 → 0.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/README.md +17 -0
- package/dist/components/ActivityFeed/ActivityFeed.d.ts +16 -0
- package/dist/components/ActivityFeed/ActivityFeed.jsx +54 -0
- package/dist/components/ActivityFeed/index.d.ts +1 -0
- package/dist/components/ActivityFeed/index.js +1 -0
- package/dist/components/AlertDialog/AlertDialog.d.ts +27 -0
- package/dist/components/AlertDialog/AlertDialog.jsx +62 -0
- package/dist/components/AlertDialog/alertDialogContext.d.ts +9 -0
- package/dist/components/AlertDialog/alertDialogContext.js +2 -0
- package/dist/components/AlertDialog/index.d.ts +1 -0
- package/dist/components/AlertDialog/index.js +1 -0
- package/dist/components/Avatar/Avatar.d.ts +10 -0
- package/dist/components/Avatar/Avatar.jsx +30 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/BreadCrumbs/BreadCrumbs.d.ts +12 -0
- package/dist/components/BreadCrumbs/BreadCrumbs.jsx +26 -0
- package/dist/components/BreadCrumbs/index.d.ts +1 -0
- package/dist/components/BreadCrumbs/index.js +1 -0
- package/dist/components/Button/Button.d.ts +3 -3
- package/dist/components/Button/Button.jsx +1 -6
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Card/Card.jsx +5 -2
- package/dist/components/Checkbox/Checkbox.d.ts +6 -7
- package/dist/components/Checkbox/Checkbox.jsx +39 -22
- package/dist/components/ColorPicker/ColorPicker.d.ts +10 -0
- package/dist/components/ColorPicker/ColorPicker.jsx +61 -0
- package/dist/components/ColorPicker/index.d.ts +1 -0
- package/dist/components/ColorPicker/index.js +1 -0
- package/dist/components/Container/Container.d.ts +0 -1
- package/dist/components/Container/Container.jsx +2 -8
- package/dist/components/DateInput/DateInput.d.ts +5 -0
- package/dist/components/DateInput/DateInput.jsx +29 -8
- package/dist/components/Drawer/Drawer.d.ts +33 -0
- package/dist/components/Drawer/Drawer.jsx +49 -0
- package/dist/components/Drawer/drawerContext.d.ts +6 -0
- package/dist/components/Drawer/drawerContext.js +9 -0
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/Drawer/index.js +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +23 -7
- package/dist/components/DropdownMenu/DropdownMenu.jsx +41 -15
- package/dist/components/FileInput/FileInput.d.ts +7 -3
- package/dist/components/FileInput/FileInput.jsx +35 -9
- package/dist/components/FilterBar/AddFilter.d.ts +9 -0
- package/dist/components/FilterBar/AddFilter.jsx +14 -0
- package/dist/components/FilterBar/AddSortingDropdown.d.ts +9 -0
- package/dist/components/FilterBar/AddSortingDropdown.jsx +67 -0
- package/dist/components/FilterBar/EditFilters.d.ts +10 -0
- package/dist/components/FilterBar/EditFilters.jsx +12 -0
- package/dist/components/FilterBar/FilterBar.d.ts +54 -0
- package/dist/components/FilterBar/FilterBar.jsx +234 -0
- package/dist/components/FilterBar/FilterChip.d.ts +23 -0
- package/dist/components/FilterBar/FilterChip.jsx +220 -0
- package/dist/components/FilterBar/FilterEdit.d.ts +13 -0
- package/dist/components/FilterBar/FilterEdit.jsx +159 -0
- package/dist/components/FilterBar/FiltersEdit.d.ts +13 -0
- package/dist/components/FilterBar/FiltersEdit.jsx +45 -0
- package/dist/components/FilterBar/index.d.ts +1 -0
- package/dist/components/FilterBar/index.js +1 -0
- package/dist/components/Form/Form.d.ts +37 -2
- package/dist/components/Form/Form.jsx +102 -3
- package/dist/components/Form/formContext.d.ts +2 -0
- package/dist/components/Form/formContext.js +9 -0
- package/dist/components/Image/Image.d.ts +6 -7
- package/dist/components/Image/Image.jsx +74 -7
- package/dist/components/Input/Input.d.ts +4 -4
- package/dist/components/Input/Input.jsx +9 -35
- package/dist/components/Kanban/Kanban.d.ts +19 -0
- package/dist/components/Kanban/Kanban.jsx +68 -0
- package/dist/components/Kanban/KanbanCard.d.ts +11 -0
- package/dist/components/Kanban/KanbanCard.jsx +94 -0
- package/dist/components/Kanban/KanbanColumn.d.ts +18 -0
- package/dist/components/Kanban/KanbanColumn.jsx +251 -0
- package/dist/components/Kanban/index.d.ts +1 -0
- package/dist/components/Kanban/index.js +1 -0
- package/dist/components/Link/Link.d.ts +8 -6
- package/dist/components/Link/Link.jsx +17 -5
- package/dist/components/Modal/Modal.d.ts +17 -8
- package/dist/components/Modal/Modal.jsx +32 -39
- package/dist/components/Modal/modalContext.d.ts +2 -3
- package/dist/components/Navbar/Navbar.d.ts +26 -0
- package/dist/components/Navbar/Navbar.jsx +40 -0
- package/dist/components/Navbar/index.d.ts +1 -0
- package/dist/components/Navbar/index.js +1 -0
- package/dist/components/NumberInput/NumberInput.d.ts +8 -6
- package/dist/components/NumberInput/NumberInput.jsx +52 -7
- package/dist/components/Pagination/Pagination.d.ts +15 -0
- package/dist/components/Pagination/Pagination.jsx +67 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/Pagination/index.js +1 -0
- package/dist/components/SearchInput/SearchInput.d.ts +3 -0
- package/dist/components/SearchInput/SearchInput.jsx +38 -3
- package/dist/components/Select/Select.d.ts +13 -11
- package/dist/components/Select/Select.jsx +78 -32
- package/dist/components/Slider/Slider.d.ts +16 -0
- package/dist/components/Slider/Slider.jsx +60 -0
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Switch/Switch.d.ts +6 -8
- package/dist/components/Switch/Switch.jsx +38 -19
- package/dist/components/Table/Table.d.ts +27 -0
- package/dist/components/Table/Table.jsx +193 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Table/index.js +1 -0
- package/dist/components/Tabs/Tabs.d.ts +25 -1
- package/dist/components/Tabs/Tabs.jsx +42 -1
- package/dist/components/Tabs/tabContext.d.ts +9 -0
- package/dist/components/Tabs/tabContext.js +2 -0
- package/dist/components/Tag/Tag.d.ts +7 -5
- package/dist/components/Tag/Tag.jsx +40 -14
- package/dist/components/TagArea/TagArea.d.ts +6 -2
- package/dist/components/TagArea/TagArea.jsx +89 -35
- package/dist/components/TextArea/TextArea.d.ts +9 -8
- package/dist/components/TextArea/TextArea.jsx +54 -18
- package/dist/components/ThemeSwitch/ThemeSwitch.d.ts +11 -0
- package/dist/components/ThemeSwitch/ThemeSwitch.jsx +49 -0
- package/dist/components/ThemeSwitch/index.d.ts +1 -0
- package/dist/components/ThemeSwitch/index.js +1 -0
- package/dist/components/Toast/Toast.d.ts +1 -1
- package/dist/components/Toast/Toast.jsx +13 -10
- package/dist/components/Toast/Toaster.jsx +1 -2
- package/dist/components/Tooltip/Tooltip.d.ts +4 -3
- package/dist/components/Tooltip/Tooltip.jsx +19 -8
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +8 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.js +14 -2
- package/dist/methods/triggerFlash.d.ts +1 -0
- package/dist/methods/triggerFlash.js +7 -0
- package/package.json +3 -2
- package/dist/components/List/List.d.ts +0 -26
- package/dist/components/List/List.jsx +0 -120
- package/dist/components/List/index.d.ts +0 -1
- package/dist/components/List/index.js +0 -1
- package/dist/components/RelationPicker/RelationPicker.d.ts +0 -11
- package/dist/components/RelationPicker/RelationPicker.jsx +0 -13
- package/dist/components/RelationPicker/index.d.ts +0 -1
- package/dist/components/RelationPicker/index.js +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { JSXElement, Component, ParentComponent } from "solid-js";
|
|
2
|
+
export interface DrawerProps {
|
|
3
|
+
children?: JSXElement;
|
|
4
|
+
class?: string;
|
|
5
|
+
id: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DrawerMenuItemProps {
|
|
8
|
+
icon: JSXElement;
|
|
9
|
+
label: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface DrawerComponents {
|
|
13
|
+
Trigger: ParentComponent<{
|
|
14
|
+
class?: string;
|
|
15
|
+
}>;
|
|
16
|
+
Content: ParentComponent;
|
|
17
|
+
Drawer: ParentComponent<{
|
|
18
|
+
class?: string;
|
|
19
|
+
}>;
|
|
20
|
+
Menu: ParentComponent;
|
|
21
|
+
MenuItem: ParentComponent<DrawerMenuItemProps>;
|
|
22
|
+
}
|
|
23
|
+
export declare const Drawer: Component<DrawerProps> & DrawerComponents;
|
|
24
|
+
export declare const DrawerTrigger: ParentComponent<{
|
|
25
|
+
class?: string;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const DrawerContent: ParentComponent;
|
|
28
|
+
export declare const DrawerDrawer: ParentComponent<{
|
|
29
|
+
class?: string;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const DrawerMenu: ParentComponent;
|
|
32
|
+
export declare const DrawerMenuItem: Component<DrawerMenuItemProps>;
|
|
33
|
+
export default Drawer;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DrawerContext, useDrawer } from "./drawerContext";
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
export const Drawer = (props) => {
|
|
4
|
+
return (<DrawerContext.Provider value={{ id: props.id }}>
|
|
5
|
+
<div class="drawer lg:drawer-open">
|
|
6
|
+
<input id={props.id} type="checkbox" class="drawer-toggle"/>
|
|
7
|
+
{props.children}
|
|
8
|
+
</div>
|
|
9
|
+
</DrawerContext.Provider>);
|
|
10
|
+
};
|
|
11
|
+
const trigger = tv({
|
|
12
|
+
base: "",
|
|
13
|
+
});
|
|
14
|
+
export const DrawerTrigger = (props) => {
|
|
15
|
+
const { id } = useDrawer();
|
|
16
|
+
return (<label for={id} aria-label="open sidebar" class={trigger({ class: props.class })}>
|
|
17
|
+
{props.children}
|
|
18
|
+
</label>);
|
|
19
|
+
};
|
|
20
|
+
export const DrawerContent = (props) => {
|
|
21
|
+
return <div class="drawer-content">{props.children}</div>;
|
|
22
|
+
};
|
|
23
|
+
const drawer = tv({
|
|
24
|
+
base: "flex bg-base-200 min-h-full flex-col is-drawer-close:w-16 is-drawer-open:w-50 border-base-300 border-r pt-2",
|
|
25
|
+
});
|
|
26
|
+
export const DrawerDrawer = (props) => {
|
|
27
|
+
const { id } = useDrawer();
|
|
28
|
+
return (<div class="drawer-side is-drawer-close:overflow-visible">
|
|
29
|
+
<label class="drawer-overlay" aria-label="close sidebar" for={id}/>
|
|
30
|
+
<div class={drawer({ class: props.class })}>{props.children}</div>
|
|
31
|
+
</div>);
|
|
32
|
+
};
|
|
33
|
+
export const DrawerMenu = (props) => {
|
|
34
|
+
return <ul class="menu w-full grow">{props.children}</ul>;
|
|
35
|
+
};
|
|
36
|
+
export const DrawerMenuItem = (props) => {
|
|
37
|
+
return (<li>
|
|
38
|
+
<a href={props.href} class="is-drawer-close:tooltip is-drawer-close:tooltip-right" data-tip={props.label}>
|
|
39
|
+
{props.icon}
|
|
40
|
+
<span class="is-drawer-close:hidden text-nowrap">{props.label}</span>
|
|
41
|
+
</a>
|
|
42
|
+
</li>);
|
|
43
|
+
};
|
|
44
|
+
Drawer.Trigger = DrawerTrigger;
|
|
45
|
+
Drawer.Content = DrawerContent;
|
|
46
|
+
Drawer.Drawer = DrawerDrawer;
|
|
47
|
+
Drawer.Menu = DrawerMenu;
|
|
48
|
+
Drawer.MenuItem = DrawerMenuItem;
|
|
49
|
+
export default Drawer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext, useContext } from "solid-js";
|
|
2
|
+
export const DrawerContext = createContext();
|
|
3
|
+
export function useDrawer() {
|
|
4
|
+
const ctx = useContext(DrawerContext);
|
|
5
|
+
if (!ctx) {
|
|
6
|
+
throw new Error("useDrawer must be used inside Drawer");
|
|
7
|
+
}
|
|
8
|
+
return ctx;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Drawer";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Drawer";
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type DropdownMenuItemProps, type DropdownMenuRootProps as KDropdownMenuRootProps } from "@kobalte/core/dropdown-menu";
|
|
2
|
+
import { ParentComponent, ValidComponent } from "solid-js";
|
|
3
|
+
import { type ButtonProps } from "../Button";
|
|
4
|
+
import { PolymorphicProps } from "@kobalte/core";
|
|
2
5
|
interface DropdownMenuProps {
|
|
3
|
-
|
|
4
|
-
items: {
|
|
5
|
-
label: string;
|
|
6
|
-
onSelect: () => void;
|
|
7
|
-
}[];
|
|
6
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
8
7
|
class?: string;
|
|
9
8
|
}
|
|
10
|
-
|
|
9
|
+
type DropdownMenuRootProps<T extends ValidComponent = "div"> = PolymorphicProps<T, KDropdownMenuRootProps> & {
|
|
10
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
11
|
+
class?: string;
|
|
12
|
+
};
|
|
13
|
+
type DropDownMenuItemProps<T extends ValidComponent = "div"> = PolymorphicProps<T, DropdownMenuItemProps<T>> & {
|
|
14
|
+
onSelect: () => void;
|
|
15
|
+
};
|
|
16
|
+
interface DropdownMenuComponents {
|
|
17
|
+
MenuItem: ParentComponent<DropDownMenuItemProps>;
|
|
18
|
+
Trigger: ParentComponent<ButtonProps>;
|
|
19
|
+
Content: ParentComponent<DropdownMenuProps>;
|
|
20
|
+
}
|
|
21
|
+
export declare const DropdownMenu: ParentComponent<DropdownMenuRootProps> & DropdownMenuComponents;
|
|
22
|
+
export declare const DropdownMenuTrigger: ParentComponent<ButtonProps>;
|
|
23
|
+
export declare const DropdownMenuContent: ParentComponent<DropdownMenuProps>;
|
|
24
|
+
export declare const DropdownMenuItem: ParentComponent<{
|
|
25
|
+
onSelect: () => void;
|
|
26
|
+
}>;
|
|
11
27
|
export default DropdownMenu;
|
|
@@ -1,22 +1,48 @@
|
|
|
1
|
-
import { DropdownMenu as KDropdownMenu } from "@kobalte/core/dropdown-menu";
|
|
2
|
-
import {
|
|
1
|
+
import { DropdownMenu as KDropdownMenu, } from "@kobalte/core/dropdown-menu";
|
|
2
|
+
import { splitProps } from "solid-js";
|
|
3
3
|
import { tv } from "tailwind-variants";
|
|
4
|
+
import { Button } from "../Button";
|
|
4
5
|
const menu = tv({
|
|
5
|
-
base: "
|
|
6
|
+
base: "dropdown-content menu bg-base-100 shadow-sm mt-2 rounded-box z-50 border border-base-200 outline-none",
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
xs: "menu-xs",
|
|
10
|
+
sm: "menu-sm",
|
|
11
|
+
md: "menu-base",
|
|
12
|
+
lg: "menu-lg",
|
|
13
|
+
xl: "menu-xl",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
size: "sm",
|
|
18
|
+
},
|
|
6
19
|
});
|
|
7
20
|
const item = tv({
|
|
8
|
-
base: "
|
|
21
|
+
base: "cursor-pointer rounded w-full outline-none focus:bg-base-300 rounded-sm",
|
|
9
22
|
});
|
|
10
|
-
export const DropdownMenu = (props) =>
|
|
11
|
-
|
|
12
|
-
<KDropdownMenu.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
export const DropdownMenu = (props) => {
|
|
24
|
+
const [local, others] = splitProps(props, ["children"]);
|
|
25
|
+
return <KDropdownMenu {...others}>{local.children}</KDropdownMenu>;
|
|
26
|
+
};
|
|
27
|
+
export const DropdownMenuTrigger = (props) => {
|
|
28
|
+
const [local, others] = splitProps(props, ["children"]);
|
|
29
|
+
return (<KDropdownMenu.Trigger as={Button} {...others}>
|
|
30
|
+
{local.children}
|
|
31
|
+
</KDropdownMenu.Trigger>);
|
|
32
|
+
};
|
|
33
|
+
export const DropdownMenuContent = (props) => {
|
|
34
|
+
return (<KDropdownMenu.Portal>
|
|
35
|
+
<KDropdownMenu.Content as="ul" class={menu({ size: props.size, class: props.class })}>
|
|
36
|
+
{props.children}
|
|
19
37
|
</KDropdownMenu.Content>
|
|
20
|
-
</KDropdownMenu.Portal>
|
|
21
|
-
|
|
38
|
+
</KDropdownMenu.Portal>);
|
|
39
|
+
};
|
|
40
|
+
export const DropdownMenuItem = (props) => {
|
|
41
|
+
return (<KDropdownMenu.Item as="li" class={item()} {...props}>
|
|
42
|
+
{props.children}
|
|
43
|
+
</KDropdownMenu.Item>);
|
|
44
|
+
};
|
|
45
|
+
DropdownMenu.Trigger = DropdownMenuTrigger;
|
|
46
|
+
DropdownMenu.Content = DropdownMenuContent;
|
|
47
|
+
DropdownMenu.MenuItem = DropdownMenuItem;
|
|
22
48
|
export default DropdownMenu;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Component } from "solid-js";
|
|
2
|
-
interface FileInputProps {
|
|
1
|
+
import { Component, JSX } from "solid-js";
|
|
2
|
+
export interface FileInputProps extends Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "onChange"> {
|
|
3
3
|
label?: string;
|
|
4
|
-
onChange
|
|
4
|
+
onChange?: (files: FileList | null) => void;
|
|
5
5
|
accept?: string;
|
|
6
6
|
multiple?: boolean;
|
|
7
7
|
class?: string;
|
|
8
|
+
variant?: "ghost";
|
|
9
|
+
appearance?: "primary" | "secondary" | "success" | "warning" | "neutral" | "error" | "accent" | "info";
|
|
10
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
11
|
+
saveFunc?: (files: FileList | null) => Promise<void>;
|
|
8
12
|
}
|
|
9
13
|
export declare const FileInput: Component<FileInputProps>;
|
|
10
14
|
export default FileInput;
|
|
@@ -1,18 +1,44 @@
|
|
|
1
1
|
import { Show, splitProps } from "solid-js";
|
|
2
2
|
import { tv } from "tailwind-variants";
|
|
3
|
-
const root = tv({ base: "flex flex-col gap-1" });
|
|
4
3
|
const input = tv({
|
|
5
|
-
base: "
|
|
4
|
+
base: "file-input outline-offset-0",
|
|
5
|
+
variants: {
|
|
6
|
+
appearance: {
|
|
7
|
+
primary: "file-input-primary",
|
|
8
|
+
secondary: "file-input-secondary",
|
|
9
|
+
success: "file-input-success",
|
|
10
|
+
warning: "file-input-warning",
|
|
11
|
+
neutral: "file-input-neutral",
|
|
12
|
+
error: "file-input-error",
|
|
13
|
+
accent: "file-input-accent",
|
|
14
|
+
info: "file-input-info",
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
xs: "file-input-xs",
|
|
18
|
+
sm: "file-input-sm",
|
|
19
|
+
md: "file-input-md",
|
|
20
|
+
lg: "file-input-lg",
|
|
21
|
+
xl: "file-input-xl",
|
|
22
|
+
},
|
|
23
|
+
variant: {
|
|
24
|
+
ghost: "file-input-ghost",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
size: "sm",
|
|
29
|
+
},
|
|
6
30
|
});
|
|
7
31
|
export const FileInput = (props) => {
|
|
8
|
-
const [local, others] = splitProps(props, ["label", "class", "onChange"]);
|
|
9
|
-
|
|
32
|
+
const [local, others] = splitProps(props, ["label", "class", "onChange", "saveFunc"]);
|
|
33
|
+
const handleChange = (files) => {
|
|
34
|
+
local.onChange?.(files);
|
|
35
|
+
local.saveFunc?.(files);
|
|
36
|
+
};
|
|
37
|
+
return (<label class="flex flex-col gap-1 w-fit">
|
|
10
38
|
<Show when={local.label}>
|
|
11
|
-
<
|
|
12
|
-
{local.label}
|
|
13
|
-
</label>
|
|
39
|
+
<span class="label">{local.label}</span>
|
|
14
40
|
</Show>
|
|
15
|
-
<input type="file" class={input()} accept={props.accept} multiple={props.multiple}
|
|
16
|
-
</
|
|
41
|
+
<input {...others} type="file" class={input({ class: local.class })} accept={props.accept} multiple={props.multiple} onChange={(e) => handleChange(e.currentTarget.files)}/>
|
|
42
|
+
</label>);
|
|
17
43
|
};
|
|
18
44
|
export default FileInput;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Filter, FilterField } from "./FilterBar";
|
|
2
|
+
interface AddFilterProps<T> {
|
|
3
|
+
availableFields: FilterField<T>[];
|
|
4
|
+
onAddFilters: (filters: Filter<T>[]) => void;
|
|
5
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
6
|
+
setOpen: (v: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const AddFilter: <T>(props: AddFilterProps<T>) => import("solid-js").JSX.Element;
|
|
9
|
+
export default AddFilter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Plus from "lucide-solid/icons/plus";
|
|
2
|
+
import FiltersEdit from "./FiltersEdit";
|
|
3
|
+
export const AddFilter = (props) => {
|
|
4
|
+
const handleSaveFilters = (filters) => {
|
|
5
|
+
props.onAddFilters(filters);
|
|
6
|
+
props.setOpen(false);
|
|
7
|
+
};
|
|
8
|
+
return (<FiltersEdit addConditionTrigger={<>
|
|
9
|
+
<Plus class="h-[1em] w-[1em]"/> <span>Condition</span>
|
|
10
|
+
</>} saveTrigger={<>
|
|
11
|
+
<Plus class="h-[1em] w-[1em]"/> <span>Add</span>
|
|
12
|
+
</>} size={props.size} availableFields={props.availableFields} filters={[{}]} onSaveFilters={handleSaveFilters}/>);
|
|
13
|
+
};
|
|
14
|
+
export default AddFilter;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FilterField, SortOption } from "./FilterBar";
|
|
2
|
+
interface AddSortingDropDownProps<T> {
|
|
3
|
+
availableFields: FilterField<T>[];
|
|
4
|
+
sortBy?: SortOption<T>;
|
|
5
|
+
setSortBy: (sort?: SortOption<T>) => void;
|
|
6
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
7
|
+
}
|
|
8
|
+
export declare const AddSortingDropdown: <T>(props: AddSortingDropDownProps<T>) => import("solid-js").JSX.Element;
|
|
9
|
+
export default AddSortingDropdown;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createMemo, For, Match, Show, Switch } from "solid-js";
|
|
2
|
+
import CalendarArrowUp from "lucide-solid/icons/calendar-arrow-up";
|
|
3
|
+
import CalendarArrowDown from "lucide-solid/icons/calendar-arrow-down";
|
|
4
|
+
import ArrowDown01 from "lucide-solid/icons/arrow-down-0-1";
|
|
5
|
+
import ArrowUp01 from "lucide-solid/icons/arrow-up-0-1";
|
|
6
|
+
import ArrowDownAZ from "lucide-solid/icons/arrow-down-a-z";
|
|
7
|
+
import ArrowUpAZ from "lucide-solid/icons/arrow-up-a-z";
|
|
8
|
+
import { iconSize } from "../../constants";
|
|
9
|
+
import { DropdownMenu } from "../DropdownMenu";
|
|
10
|
+
export const AddSortingDropdown = (props) => {
|
|
11
|
+
const validFields = createMemo(() => props.availableFields.filter((f) => f.type !== "bool"));
|
|
12
|
+
return (<DropdownMenu.Content>
|
|
13
|
+
<For each={validFields()}>
|
|
14
|
+
{(field) => {
|
|
15
|
+
const fieldActive = createMemo(() => field.name === props.sortBy?.field);
|
|
16
|
+
const handleClick = () => {
|
|
17
|
+
const changingSameField = props.sortBy?.field === field.name;
|
|
18
|
+
if (!changingSameField) {
|
|
19
|
+
props.setSortBy({
|
|
20
|
+
direction: "desc",
|
|
21
|
+
field: field.name,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
props.setSortBy(props.sortBy?.direction === "asc"
|
|
26
|
+
? undefined
|
|
27
|
+
: {
|
|
28
|
+
// will also set to "desc" if no sortby exists
|
|
29
|
+
direction: props.sortBy?.direction === "desc" ? "asc" : "desc",
|
|
30
|
+
field: field.name,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return (<DropdownMenu.MenuItem onSelect={handleClick} closeOnSelect={false}>
|
|
35
|
+
<a class="flex justify-between">
|
|
36
|
+
<span>{field.label}</span>
|
|
37
|
+
<span style={{ opacity: fieldActive() ? 1 : 0.2 }}>
|
|
38
|
+
<Switch>
|
|
39
|
+
<Match when={field.type === "date"}>
|
|
40
|
+
<Show when={fieldActive() && props.sortBy?.direction === "asc"} fallback={<CalendarArrowDown size={iconSize[props.size ?? "sm"]}/>}>
|
|
41
|
+
<CalendarArrowUp size={iconSize[props.size ?? "sm"]}/>
|
|
42
|
+
</Show>
|
|
43
|
+
</Match>
|
|
44
|
+
<Match when={field.type === "text"}>
|
|
45
|
+
<Show when={fieldActive() && props.sortBy?.direction === "asc"} fallback={<ArrowDownAZ size={iconSize[props.size ?? "sm"]}/>}>
|
|
46
|
+
<ArrowUpAZ size={iconSize[props.size ?? "sm"]}/>
|
|
47
|
+
</Show>
|
|
48
|
+
</Match>
|
|
49
|
+
<Match when={field.type === "number"}>
|
|
50
|
+
<Show when={fieldActive() && props.sortBy?.direction === "asc"} fallback={<ArrowDown01 size={iconSize[props.size ?? "sm"]}/>}>
|
|
51
|
+
<ArrowUp01 size={iconSize[props.size ?? "sm"]}/>
|
|
52
|
+
</Show>
|
|
53
|
+
</Match>
|
|
54
|
+
<Match when={field.type === "select"}>
|
|
55
|
+
<Show when={fieldActive() && props.sortBy?.direction === "asc"} fallback={<ArrowDownAZ size={iconSize[props.size ?? "sm"]}/>}>
|
|
56
|
+
<ArrowUpAZ size={iconSize[props.size ?? "sm"]}/>
|
|
57
|
+
</Show>
|
|
58
|
+
</Match>
|
|
59
|
+
</Switch>
|
|
60
|
+
</span>
|
|
61
|
+
</a>
|
|
62
|
+
</DropdownMenu.MenuItem>);
|
|
63
|
+
}}
|
|
64
|
+
</For>
|
|
65
|
+
</DropdownMenu.Content>);
|
|
66
|
+
};
|
|
67
|
+
export default AddSortingDropdown;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Filter, FilterField } from "./FilterBar";
|
|
2
|
+
interface EditFiltersProps<T> {
|
|
3
|
+
availableFields: FilterField<T>[];
|
|
4
|
+
onSaveFilters: (filters: Filter<T>[]) => void;
|
|
5
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
6
|
+
setOpen: (v: boolean) => void;
|
|
7
|
+
currentFilters: Filter<T>[];
|
|
8
|
+
}
|
|
9
|
+
export declare const EditFilters: <T>(props: EditFiltersProps<T>) => import("solid-js").JSX.Element;
|
|
10
|
+
export default EditFilters;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Plus from "lucide-solid/icons/plus";
|
|
2
|
+
import FiltersEdit from "./FiltersEdit";
|
|
3
|
+
export const EditFilters = (props) => {
|
|
4
|
+
const handleSaveFilters = (filters) => {
|
|
5
|
+
props.onSaveFilters(filters);
|
|
6
|
+
props.setOpen(false);
|
|
7
|
+
};
|
|
8
|
+
return (<FiltersEdit addConditionTrigger={<>
|
|
9
|
+
<Plus class="h-[1em] w-[1em]"/> <span>Condition</span>
|
|
10
|
+
</>} saveTrigger={<span>Save</span>} size={props.size} availableFields={props.availableFields} filters={JSON.parse(JSON.stringify(props.currentFilters))} onSaveFilters={handleSaveFilters} filtersReady/>);
|
|
11
|
+
};
|
|
12
|
+
export default EditFilters;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { JSXElement } from "solid-js";
|
|
2
|
+
export type FieldType = "text" | "number" | "date" | "select" | "bool";
|
|
3
|
+
export type FilterOperator = "loose_contains" | "fuzzy_match" | "is" | "is_not" | "greater_than" | "less_than" | "between" | "in" | "not_in" | "is_set" | "is_not_set";
|
|
4
|
+
export declare const filterDefaults: Record<FieldType, FilterOperator>;
|
|
5
|
+
export declare const filterLabels: Record<FieldType, Partial<Record<FilterOperator, string>>>;
|
|
6
|
+
export type FilterSelectValue = {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
export type FilterDateValue = {
|
|
11
|
+
startDate: Date | null;
|
|
12
|
+
endDate: Date | null;
|
|
13
|
+
};
|
|
14
|
+
export type FilterValue = string | number | boolean | FilterSelectValue | FilterDateValue | null;
|
|
15
|
+
export interface Filter<T> {
|
|
16
|
+
field: FilterField<T>;
|
|
17
|
+
operator: FilterOperator;
|
|
18
|
+
value: FilterValue;
|
|
19
|
+
}
|
|
20
|
+
export interface FilterGroup<T> {
|
|
21
|
+
filters: Filter<T>[];
|
|
22
|
+
}
|
|
23
|
+
export interface FilterField<T> {
|
|
24
|
+
name: keyof T;
|
|
25
|
+
label: string;
|
|
26
|
+
type: FieldType;
|
|
27
|
+
options?: {
|
|
28
|
+
label: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}[];
|
|
31
|
+
}
|
|
32
|
+
export interface SortOption<T> {
|
|
33
|
+
field: keyof T;
|
|
34
|
+
direction: "asc" | "desc";
|
|
35
|
+
}
|
|
36
|
+
interface FilterBarProps<T> {
|
|
37
|
+
items?: (Filter<T> | FilterGroup<T>)[];
|
|
38
|
+
setItems?: (items: (Filter<T> | FilterGroup<T>)[]) => void;
|
|
39
|
+
availableFields?: FilterField<T>[];
|
|
40
|
+
leftAction?: JSXElement;
|
|
41
|
+
sortBy?: SortOption<T>;
|
|
42
|
+
setSortBy?: (sort?: SortOption<T>) => void;
|
|
43
|
+
onAddFilterGroup: (filters: Filter<T>[]) => void;
|
|
44
|
+
onUpdateFilterGroup: (ind: number, filters: Filter<T>[]) => void;
|
|
45
|
+
onFilterRemove: (ind: number, filter: Filter<T>) => void;
|
|
46
|
+
onGroupDrag: (sourceInd: number, targetInd: number, sourceFilterGroupInd?: number) => void;
|
|
47
|
+
value: string;
|
|
48
|
+
onChangeValue: (val: string) => void;
|
|
49
|
+
placeholder?: string;
|
|
50
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
51
|
+
class?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare const FilterBar: <T>(props: FilterBarProps<T>) => import("solid-js").JSX.Element;
|
|
54
|
+
export {};
|