@tulip-systems/core 0.5.7 → 0.5.8
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/components/common/icons.d.mts +52 -52
- package/dist/components/common/status.d.mts +3 -3
- package/dist/components/editor/components/content.client.d.mts +2 -2
- package/dist/components/editor/components/editor.client.d.mts +5 -5
- package/dist/components/editor/components/editor.client.d.mts.map +1 -1
- package/dist/components/editor/components/menu.client.d.mts +3 -3
- package/dist/components/editor/lib/constants.d.mts +27 -27
- package/dist/components/header/back-button.client.d.mts +2 -2
- package/dist/components/header/bottom-bar.client.d.mts +3 -3
- package/dist/components/header/breadcrumbs.client.d.mts +7 -7
- package/dist/components/header/header.client.d.mts +2 -2
- package/dist/components/header/header.client.d.mts.map +1 -1
- package/dist/components/header/mobile-nav-switcher.client.d.mts +2 -2
- package/dist/components/header/mobile-nav-switcher.client.d.mts.map +1 -1
- package/dist/components/header/top-bar.client.d.mts +4 -4
- package/dist/components/header/top-bar.client.d.mts.map +1 -1
- package/dist/components/layouts/admin-content.client.d.mts +2 -2
- package/dist/components/layouts/admin-content.client.d.mts.map +1 -1
- package/dist/components/layouts/admin-layout.d.mts +2 -2
- package/dist/components/layouts/admin-loading.d.mts +2 -2
- package/dist/components/layouts/empty-page.d.mts +4 -4
- package/dist/components/layouts/error-page.d.mts +3 -3
- package/dist/components/layouts/list-layout.d.mts +2 -2
- package/dist/components/layouts/not-allowed-page.d.mts +2 -2
- package/dist/components/layouts/not-found-page.d.mts +3 -3
- package/dist/components/layouts/providers.client.d.mts +2 -2
- package/dist/components/layouts/providers.client.d.mts.map +1 -1
- package/dist/components/layouts/root-layout.server.d.mts +2 -2
- package/dist/components/layouts/root-loading.d.mts +2 -2
- package/dist/components/layouts/tab-layout.d.mts +2 -2
- package/dist/components/lists/data-list.d.mts +5 -5
- package/dist/components/lists/data-stack.d.mts +8 -8
- package/dist/components/navigation/admin-sidebar-paths.client.d.mts +10 -10
- package/dist/components/ui/accordion.d.mts +5 -5
- package/dist/components/ui/alert-dialog.d.mts +12 -12
- package/dist/components/ui/alert.d.mts +4 -4
- package/dist/components/ui/aspect-ratio.d.mts +2 -2
- package/dist/components/ui/avatar.client.d.mts +4 -4
- package/dist/components/ui/badge.d.mts +2 -2
- package/dist/components/ui/breadcrumb.d.mts +8 -8
- package/dist/components/ui/button.d.mts +3 -3
- package/dist/components/ui/calendar.d.mts +3 -3
- package/dist/components/ui/card.d.mts +7 -7
- package/dist/components/ui/carousel.d.mts +6 -6
- package/dist/components/ui/chart.client.d.mts +5 -5
- package/dist/components/ui/checkbox.d.mts +2 -2
- package/dist/components/ui/collapsible.client.d.mts +4 -4
- package/dist/components/ui/color-picker.client.d.mts +2 -2
- package/dist/components/ui/combobox-dropdown.client.d.mts +2 -2
- package/dist/components/ui/combobox.client.d.mts +2 -2
- package/dist/components/ui/command.d.mts +10 -10
- package/dist/components/ui/context-menu.d.mts +16 -16
- package/dist/components/ui/date-picker.client.d.mts +2 -2
- package/dist/components/ui/dialog.client.d.mts +11 -11
- package/dist/components/ui/drawer.client.d.mts +11 -11
- package/dist/components/ui/dropdown-menu.d.mts +18 -18
- package/dist/components/ui/dropdown-menu.d.mts.map +1 -1
- package/dist/components/ui/dropdown-menu.mjs +2 -2
- package/dist/components/ui/dropdown-menu.mjs.map +1 -1
- package/dist/components/ui/form.client.d.mts +7 -7
- package/dist/components/ui/hover-card.client.d.mts +4 -4
- package/dist/components/ui/input-recipient.d.mts +2 -2
- package/dist/components/ui/input.d.mts +2 -2
- package/dist/components/ui/label.d.mts +2 -2
- package/dist/components/ui/navigation-menu.d.mts +9 -9
- package/dist/components/ui/pagination.d.mts +8 -8
- package/dist/components/ui/popover.d.mts +5 -5
- package/dist/components/ui/progress.client.d.mts +2 -2
- package/dist/components/ui/radio-group.d.mts +3 -3
- package/dist/components/ui/resizable.client.d.mts +4 -4
- package/dist/components/ui/scroll-area.d.mts +3 -3
- package/dist/components/ui/select.client.d.mts +11 -11
- package/dist/components/ui/separator.d.mts +2 -2
- package/dist/components/ui/sheet.client.d.mts +9 -9
- package/dist/components/ui/sidebar.client.d.mts +26 -26
- package/dist/components/ui/skeleton.d.mts +2 -2
- package/dist/components/ui/slider.d.mts +2 -2
- package/dist/components/ui/sonner.client.d.mts +2 -2
- package/dist/components/ui/switch.d.mts +2 -2
- package/dist/components/ui/tabs.d.mts +5 -5
- package/dist/components/ui/textarea.d.mts +2 -2
- package/dist/components/ui/time-input.client.d.mts +2 -2
- package/dist/components/ui/toggle-group.client.d.mts +3 -3
- package/dist/components/ui/toggle.d.mts +4 -4
- package/dist/components/ui/toggle.d.mts.map +1 -1
- package/dist/components/ui/tooltip.client.d.mts +5 -5
- package/dist/components/ui/tooltip.client.d.mts.map +1 -1
- package/dist/data-tables/client.d.mts +2 -6
- package/dist/data-tables/client.mjs +2 -6
- package/dist/lib/hooks/use-action.d.mts +2 -2
- package/dist/lib/hooks/use-indicator.d.mts +2 -2
- package/dist/modules/auth/components/allowed.client.d.mts +2 -2
- package/dist/modules/auth/components/auth-layout.server.d.mts +2 -2
- package/dist/modules/auth/components/auth-loading.d.mts +2 -2
- package/dist/modules/auth/components/create-first-user-page.client.d.mts +2 -2
- package/dist/modules/auth/components/forget-password-page.client.d.mts +2 -2
- package/dist/modules/auth/components/guard-first-user.server.d.mts +2 -2
- package/dist/modules/auth/components/guard.server.d.mts +2 -2
- package/dist/modules/auth/components/login-page.client.d.mts +2 -2
- package/dist/modules/auth/components/reset-password-page.client.d.mts +2 -2
- package/dist/modules/auth/components/update-password-command.d.mts +2 -2
- package/dist/modules/auth/handler/client.client.d.mts +143 -143
- package/dist/modules/auth/handler/client.client.d.mts.map +1 -1
- package/dist/modules/auth/handler/init.d.mts +131 -131
- package/dist/modules/auth/handler/init.d.mts.map +1 -1
- package/dist/modules/auth/hooks/use-permission.d.mts +3 -3
- package/dist/modules/auth/hooks/use-session.d.mts +4 -4
- package/dist/modules/auth/lib/helpers.server.d.mts +2 -2
- package/dist/modules/auth/lib/helpers.server.d.mts.map +1 -1
- package/dist/modules/auth/lib/validators.d.mts +2 -2
- package/dist/modules/auth/lib/validators.d.mts.map +1 -1
- package/dist/modules/commands/components/alert-dialog-command.client.d.mts +10 -10
- package/dist/modules/commands/components/alert-dialog-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/click-command.client.d.mts +2 -2
- package/dist/modules/commands/components/click-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/command-trigger.client.d.mts +4 -4
- package/dist/modules/commands/components/command-trigger.client.d.mts.map +1 -1
- package/dist/modules/commands/components/dialog-command.client.d.mts +8 -8
- package/dist/modules/commands/components/dropdown-command.client.d.mts +5 -5
- package/dist/modules/commands/components/dropdown-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/empty-command.client.d.mts +2 -2
- package/dist/modules/commands/components/form-dialog-command.client.d.mts +11 -11
- package/dist/modules/commands/menus/context-menu.client.d.mts +2 -2
- package/dist/modules/commands/menus/dropdown-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/inline-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/responsive-menu.client.d.mts +3 -3
- package/dist/modules/commands/utils/archive-command.client.d.mts +3 -3
- package/dist/modules/commands/utils/delete-command.client.d.mts +3 -3
- package/dist/modules/data-tables/components/cell/common.client.d.mts +5 -5
- package/dist/modules/data-tables/components/cell/common.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/column-header.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/combobox.client.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/combobox.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/filters/slider.client.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/slider.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/header.d.mts +4 -4
- package/dist/modules/data-tables/components/layout.d.mts +2 -2
- package/dist/modules/data-tables/components/search-input.client.d.mts +2 -2
- package/dist/modules/data-tables/components/search-input.client.d.mts.map +1 -1
- package/dist/modules/data-tables/components/skeleton.d.mts +2 -2
- package/dist/modules/data-tables/components/table.d.mts +7 -7
- package/dist/modules/data-tables/components/toolbar.d.mts +3 -3
- package/dist/modules/data-tables/hooks/use-context.client.d.mts +2 -2
- package/dist/modules/data-tables/hooks/use-context.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/data-table/components/table.d.mts +2 -2
- package/dist/modules/data-tables/tables/data-table/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/{inputs → cells}/read-only.d.mts +3 -3
- package/dist/modules/data-tables/tables/inline-table/components/cells/read-only.d.mts.map +1 -0
- package/dist/modules/data-tables/tables/inline-table/components/{inputs → cells}/read-only.mjs +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/cells/read-only.mjs.map +1 -0
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/table.mjs +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/combobox.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/date-input.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/date-picker.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/editor.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/input-recipient.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/input-toggle.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/input.client.d.mts +4 -4
- package/dist/modules/inline-edit/components/select.client.d.mts +6 -6
- package/dist/modules/inline-edit/components/switch.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/toggle.client.d.mts +2 -2
- package/dist/modules/inline-edit/hooks/context.client.d.mts +2 -2
- package/dist/modules/inline-edit/lib/variants.d.mts +2 -2
- package/dist/modules/router/handler/init.server.d.mts +6 -6
- package/dist/modules/router/handler/init.server.d.mts.map +1 -1
- package/dist/modules/router/lib/query-client.server.d.mts +2 -2
- package/dist/modules/router/lib/query-client.server.d.mts.map +1 -1
- package/dist/modules/storage/components/dropzone-context.client.d.mts +2 -2
- package/dist/modules/storage/components/dropzone-context.client.d.mts.map +1 -1
- package/dist/modules/storage/components/dropzone.client.d.mts +5 -5
- package/dist/modules/storage/components/dropzone.client.d.mts.map +1 -1
- package/dist/modules/storage/components/image-grid.client.d.mts +3 -3
- package/dist/modules/storage/components/image-grid.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.d.mts +2 -2
- package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -1
- package/dist/modules/storage/lib/router.server.d.mts +2344 -2344
- package/dist/modules/storage/lib/router.server.d.mts.map +1 -1
- package/dist/modules/storage/lib/schema.d.mts +92 -92
- package/dist/modules/storage/lib/schema.d.mts.map +1 -1
- package/dist/modules/storage/lib/service.server.d.mts +15 -15
- package/dist/modules/storage/lib/service.server.mjs +1 -1
- package/dist/modules/storage/lib/service.server.mjs.map +1 -1
- package/dist/modules/storage/lib/validators.d.mts +88 -88
- package/dist/modules/storage/lib/validators.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/modules/data-tables/entry.client.ts +1 -5
- package/src/modules/storage/lib/service.server.ts +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts +0 -29
- package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.mjs +0 -52
- package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.mjs.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts +0 -27
- package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.mjs +0 -29
- package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.mjs.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts +0 -39
- package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.mjs +0 -71
- package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.mjs.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.mts.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.mjs.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts +0 -33
- package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.mjs +0 -52
- package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.mjs.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/use-input.client.d.mts +0 -17
- package/dist/modules/data-tables/tables/inline-table/hooks/use-input.client.d.mts.map +0 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/use-input.client.mjs +0 -53
- package/dist/modules/data-tables/tables/inline-table/hooks/use-input.client.mjs.map +0 -1
- package/src/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.tsx +0 -90
- package/src/modules/data-tables/tables/inline-table/components/inputs/combobox.client.tsx +0 -109
- package/src/modules/data-tables/tables/inline-table/components/inputs/input.client.tsx +0 -108
- package/src/modules/data-tables/tables/inline-table/components/inputs/select.client.tsx +0 -102
- package/src/modules/data-tables/tables/inline-table/hooks/use-input.client.ts +0 -65
- /package/src/modules/data-tables/tables/inline-table/components/{inputs → cells}/read-only.tsx +0 -0
package/src/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.tsx
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { Icons } from "@/components/common/icons";
|
|
4
|
-
import {
|
|
5
|
-
DropdownMenuContent,
|
|
6
|
-
DropdownMenuItem,
|
|
7
|
-
DropdownMenuTrigger,
|
|
8
|
-
} from "@/components/ui/dropdown-menu";
|
|
9
|
-
import { cn } from "@/lib/utils/cn";
|
|
10
|
-
import { DropdownMenu } from "@radix-ui/react-dropdown-menu";
|
|
11
|
-
import { useInlineTableContext } from "../../hooks/context.client";
|
|
12
|
-
import {
|
|
13
|
-
useInlineDataTableInput,
|
|
14
|
-
UseInlineDataTableInputParams,
|
|
15
|
-
} from "../../hooks/use-input.client";
|
|
16
|
-
|
|
17
|
-
export type AdvancedSelectItem = {
|
|
18
|
-
id: string;
|
|
19
|
-
label: string;
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type InlineDataTableAdvancedSelectProps<TData, TValue> = UseInlineDataTableInputParams<
|
|
24
|
-
TData,
|
|
25
|
-
TValue
|
|
26
|
-
> & {
|
|
27
|
-
options: AdvancedSelectItem[];
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
className?: string;
|
|
30
|
-
autoSelect?: boolean;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export function InlineDataTableAdvancedSelect<TData extends { id: string }, TValue>({
|
|
34
|
-
context,
|
|
35
|
-
action,
|
|
36
|
-
permission,
|
|
37
|
-
options,
|
|
38
|
-
disabled,
|
|
39
|
-
autoSelect,
|
|
40
|
-
className,
|
|
41
|
-
}: InlineDataTableAdvancedSelectProps<TData, TValue>) {
|
|
42
|
-
const { disabledColumns } = useInlineTableContext();
|
|
43
|
-
|
|
44
|
-
const { value, setValue, isAllowed } = useInlineDataTableInput({ context, action, permission });
|
|
45
|
-
|
|
46
|
-
const isDisabled = disabled || disabledColumns?.[context.column.id] || !isAllowed;
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div className="flex h-full">
|
|
50
|
-
<input
|
|
51
|
-
type="text"
|
|
52
|
-
value={(value as string) ?? ""}
|
|
53
|
-
data-input
|
|
54
|
-
disabled={isDisabled}
|
|
55
|
-
onFocus={(e) => {
|
|
56
|
-
if (autoSelect) e.target.select();
|
|
57
|
-
}}
|
|
58
|
-
onChange={(e) => {
|
|
59
|
-
setValue(e.target.value as TValue);
|
|
60
|
-
}}
|
|
61
|
-
className={cn(
|
|
62
|
-
"h- placeholder:text-primary-foreground read-only:bg-muted/50 flex w-full bg-transparent px-3 py-0.5 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
63
|
-
className,
|
|
64
|
-
)}
|
|
65
|
-
/>
|
|
66
|
-
|
|
67
|
-
<DropdownMenu>
|
|
68
|
-
<DropdownMenuTrigger
|
|
69
|
-
disabled={isDisabled}
|
|
70
|
-
className="bg-muted/30 flex aspect-square h-full items-center justify-center rounded-none border-none outline-none ring-0 focus:border-0 focus:outline-none focus:ring-0 focus:ring-offset-0 focus-visible:outline-none"
|
|
71
|
-
>
|
|
72
|
-
<Icons.chevronDown className="size-4 opacity-50" />
|
|
73
|
-
</DropdownMenuTrigger>
|
|
74
|
-
|
|
75
|
-
<DropdownMenuContent className="w-56">
|
|
76
|
-
{options.map((item) => (
|
|
77
|
-
<DropdownMenuItem
|
|
78
|
-
disabled={item.disabled}
|
|
79
|
-
className="cursor-pointer"
|
|
80
|
-
key={item.id}
|
|
81
|
-
onSelect={() => setValue(item.id as TValue)}
|
|
82
|
-
>
|
|
83
|
-
{item.label}
|
|
84
|
-
</DropdownMenuItem>
|
|
85
|
-
))}
|
|
86
|
-
</DropdownMenuContent>
|
|
87
|
-
</DropdownMenu>
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { Combobox } from "@/components/ui/combobox.client";
|
|
4
|
-
import { useInlineTableContext } from "../../hooks/context.client";
|
|
5
|
-
import {
|
|
6
|
-
useInlineDataTableInput,
|
|
7
|
-
UseInlineDataTableInputParams,
|
|
8
|
-
} from "../../hooks/use-input.client";
|
|
9
|
-
|
|
10
|
-
export type ComboboxItem = {
|
|
11
|
-
id: string;
|
|
12
|
-
label: string;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type InlineDataTableComboboxProps<TData, TValue> = UseInlineDataTableInputParams<TData, TValue> & {
|
|
17
|
-
options: ComboboxItem[];
|
|
18
|
-
emptyMessage?: string;
|
|
19
|
-
placeholder?: string;
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export function InlineDataTableCombobox<TData extends { id: string }, TValue>({
|
|
24
|
-
context,
|
|
25
|
-
action,
|
|
26
|
-
permission,
|
|
27
|
-
disabled,
|
|
28
|
-
...props
|
|
29
|
-
}: InlineDataTableComboboxProps<TData, TValue>) {
|
|
30
|
-
const { disabledColumns } = useInlineTableContext();
|
|
31
|
-
|
|
32
|
-
const { value, setValue, mutate, isAllowed } = useInlineDataTableInput({
|
|
33
|
-
context,
|
|
34
|
-
action,
|
|
35
|
-
permission,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const isDisabled = disabled || disabledColumns?.[context.column.id] || !isAllowed;
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<Combobox
|
|
42
|
-
{...props}
|
|
43
|
-
value={value}
|
|
44
|
-
disabled={isDisabled}
|
|
45
|
-
onSelect={setValue}
|
|
46
|
-
onBlur={(e) => mutate(e.target.value as TValue)}
|
|
47
|
-
className="rounded-none border-none shadow-none"
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
// return (
|
|
52
|
-
// <Popover open={open} onOpenChange={setOpen}>
|
|
53
|
-
// <Command className="text-foreground bg-transparent">
|
|
54
|
-
// <PopoverAnchor asChild>
|
|
55
|
-
// <CommandPrimitive.Input
|
|
56
|
-
// data-input
|
|
57
|
-
// value={value?.toString() ?? ""}
|
|
58
|
-
// placeholder={placeholder}
|
|
59
|
-
// disabled={isDisabled}
|
|
60
|
-
// onValueChange={(value) => setValue(value as TValue)}
|
|
61
|
-
// onKeyDown={(e) => setOpen(e.key !== "Escape")}
|
|
62
|
-
// onMouseDown={() => setOpen((open) => !!value || !open)}
|
|
63
|
-
// onBlur={(e) => {
|
|
64
|
-
// setOpen(false);
|
|
65
|
-
// mutate(e.target.value as TValue);
|
|
66
|
-
// }}
|
|
67
|
-
// onFocus={() => setOpen(true)}
|
|
68
|
-
// className="read-only:bg-muted/50 h-full w-full bg-transparent px-3 py-0.5 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"
|
|
69
|
-
// />
|
|
70
|
-
// </PopoverAnchor>
|
|
71
|
-
|
|
72
|
-
// {!open && <CommandList aria-hidden="true" className="hidden" />}
|
|
73
|
-
|
|
74
|
-
// <PopoverContent
|
|
75
|
-
// asChild
|
|
76
|
-
// onOpenAutoFocus={(e) => e.preventDefault()}
|
|
77
|
-
// onInteractOutside={(e) => {
|
|
78
|
-
// if (e.target instanceof Element && e.target.hasAttribute("cmdk-input")) {
|
|
79
|
-
// e.preventDefault();
|
|
80
|
-
// }
|
|
81
|
-
// }}
|
|
82
|
-
// className="w-[var(--radix-popover-trigger-width)] p-0"
|
|
83
|
-
// >
|
|
84
|
-
// <CommandList>
|
|
85
|
-
// {options.length > 0 && (
|
|
86
|
-
// <CommandGroup>
|
|
87
|
-
// {options.map((option) => (
|
|
88
|
-
// <CommandItem
|
|
89
|
-
// key={option.id}
|
|
90
|
-
// value={option.id}
|
|
91
|
-
// onMouseDown={(e) => e.preventDefault()}
|
|
92
|
-
// onSelect={(id) => {
|
|
93
|
-
// setValue(id as TValue);
|
|
94
|
-
// setOpen(false);
|
|
95
|
-
// }}
|
|
96
|
-
// >
|
|
97
|
-
// {option.label}
|
|
98
|
-
// </CommandItem>
|
|
99
|
-
// ))}
|
|
100
|
-
// </CommandGroup>
|
|
101
|
-
// )}
|
|
102
|
-
|
|
103
|
-
// <CommandEmpty className="px-3 py-1">{emptyMessage}</CommandEmpty>
|
|
104
|
-
// </CommandList>
|
|
105
|
-
// </PopoverContent>
|
|
106
|
-
// </Command>
|
|
107
|
-
// </Popover>
|
|
108
|
-
// );
|
|
109
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import type { Input } from "@/components/ui/input";
|
|
4
|
-
import { cn } from "@/lib/utils/cn";
|
|
5
|
-
import { ComponentProps } from "react";
|
|
6
|
-
import { useInlineTableContext } from "../../hooks/context.client";
|
|
7
|
-
import {
|
|
8
|
-
useInlineDataTableInput,
|
|
9
|
-
UseInlineDataTableInputParams,
|
|
10
|
-
} from "../../hooks/use-input.client";
|
|
11
|
-
|
|
12
|
-
export type InlineDataTableInputProps<TData, TValue> = Omit<ComponentProps<typeof Input>, "type"> &
|
|
13
|
-
UseInlineDataTableInputParams<TData, TValue> & { autoSelect?: boolean };
|
|
14
|
-
|
|
15
|
-
export function InlineDataTableStringInput<TData extends { id: string }, TValue>({
|
|
16
|
-
context,
|
|
17
|
-
action,
|
|
18
|
-
permission,
|
|
19
|
-
onChange,
|
|
20
|
-
onBlur,
|
|
21
|
-
onFocus,
|
|
22
|
-
autoSelect,
|
|
23
|
-
disabled,
|
|
24
|
-
className,
|
|
25
|
-
...props
|
|
26
|
-
}: InlineDataTableInputProps<TData, TValue>) {
|
|
27
|
-
const { disabledColumns } = useInlineTableContext();
|
|
28
|
-
|
|
29
|
-
const { value, setValue, mutate, isAllowed } = useInlineDataTableInput({
|
|
30
|
-
context,
|
|
31
|
-
action,
|
|
32
|
-
permission,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const isDisabled = disabled || disabledColumns?.[context.column.id] || !isAllowed;
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<input
|
|
39
|
-
{...props}
|
|
40
|
-
key={`${context.row.id}-${context.column.id}`}
|
|
41
|
-
type="text"
|
|
42
|
-
value={value as string}
|
|
43
|
-
data-input
|
|
44
|
-
disabled={isDisabled}
|
|
45
|
-
onFocus={(e) => {
|
|
46
|
-
if (autoSelect) e.target.select();
|
|
47
|
-
onFocus?.(e);
|
|
48
|
-
}}
|
|
49
|
-
onChange={(e) => {
|
|
50
|
-
setValue(e.target.value as TValue);
|
|
51
|
-
onChange?.(e);
|
|
52
|
-
}}
|
|
53
|
-
onBlur={(e) => {
|
|
54
|
-
mutate(e.target.value as TValue);
|
|
55
|
-
onBlur?.(e);
|
|
56
|
-
}}
|
|
57
|
-
className={cn(
|
|
58
|
-
"placeholder:text-primary-foreground read-only:bg-muted/50 flex h-full w-full bg-transparent px-3 py-0.5 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
59
|
-
className,
|
|
60
|
-
)}
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function InlineDataTableNumberInput<TData extends { id: string }, TValue>({
|
|
66
|
-
context,
|
|
67
|
-
action,
|
|
68
|
-
onChange,
|
|
69
|
-
onFocus,
|
|
70
|
-
onBlur,
|
|
71
|
-
autoSelect,
|
|
72
|
-
disabled,
|
|
73
|
-
className,
|
|
74
|
-
...props
|
|
75
|
-
}: InlineDataTableInputProps<TData, TValue>) {
|
|
76
|
-
const { disabledColumns } = useInlineTableContext();
|
|
77
|
-
|
|
78
|
-
const { value, setValue, mutate, isAllowed } = useInlineDataTableInput({ context, action });
|
|
79
|
-
|
|
80
|
-
const isDisabled = disabled || disabledColumns?.[context.column.id] || !isAllowed;
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<input
|
|
84
|
-
{...props}
|
|
85
|
-
type="number"
|
|
86
|
-
value={value as number}
|
|
87
|
-
data-input
|
|
88
|
-
disabled={isDisabled}
|
|
89
|
-
onFocus={(e) => {
|
|
90
|
-
if (autoSelect) e.target.select();
|
|
91
|
-
onFocus?.(e);
|
|
92
|
-
}}
|
|
93
|
-
onChange={(e) => {
|
|
94
|
-
setValue(e.target.valueAsNumber as TValue);
|
|
95
|
-
onChange?.(e);
|
|
96
|
-
}}
|
|
97
|
-
onBlur={(e) => {
|
|
98
|
-
mutate(e.target.value as TValue);
|
|
99
|
-
onBlur?.(e);
|
|
100
|
-
}}
|
|
101
|
-
className={cn(
|
|
102
|
-
"placeholder:text-primary-foreground read-only:bg-muted/50 flex h-full w-full bg-transparent px-3 py-0.5 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
103
|
-
"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
|
104
|
-
className,
|
|
105
|
-
)}
|
|
106
|
-
/>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { Select, SelectContent, SelectItem, SelectTrigger } from "@/components/ui/select.client";
|
|
4
|
-
import { cn } from "@/lib/utils/cn";
|
|
5
|
-
import React from "react";
|
|
6
|
-
import { useInlineTableContext } from "../../hooks/context.client";
|
|
7
|
-
import {
|
|
8
|
-
useInlineDataTableInput,
|
|
9
|
-
UseInlineDataTableInputParams,
|
|
10
|
-
} from "../../hooks/use-input.client";
|
|
11
|
-
|
|
12
|
-
export type SelectItem = {
|
|
13
|
-
id: string;
|
|
14
|
-
value: string;
|
|
15
|
-
label?: React.ReactNode;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type InlineDataTableSelectProps<TData, TValue> = UseInlineDataTableInputParams<
|
|
20
|
-
TData,
|
|
21
|
-
TValue
|
|
22
|
-
> & {
|
|
23
|
-
placeholder?: React.ReactNode;
|
|
24
|
-
options: SelectItem[];
|
|
25
|
-
renderSelectedItem?: (selectedItem: SelectItem) => React.ReactNode;
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
className?: string;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export function InlineDataTableSelect<TData extends { id: string }, TValue>({
|
|
31
|
-
context,
|
|
32
|
-
action,
|
|
33
|
-
permission,
|
|
34
|
-
placeholder,
|
|
35
|
-
options,
|
|
36
|
-
renderSelectedItem,
|
|
37
|
-
disabled,
|
|
38
|
-
className,
|
|
39
|
-
}: InlineDataTableSelectProps<TData, TValue>) {
|
|
40
|
-
const { disabledColumns } = useInlineTableContext();
|
|
41
|
-
|
|
42
|
-
const { value, setValue, mutate, isAllowed } = useInlineDataTableInput({
|
|
43
|
-
context,
|
|
44
|
-
action,
|
|
45
|
-
permission,
|
|
46
|
-
});
|
|
47
|
-
const incomingSelectedItem = options.find((item) => item.id === value);
|
|
48
|
-
|
|
49
|
-
const [open, setOpen] = React.useState(false);
|
|
50
|
-
const [internalSelectedItem, setInternalSelectedItem] = React.useState<SelectItem | undefined>();
|
|
51
|
-
|
|
52
|
-
const selectedItem = incomingSelectedItem ?? internalSelectedItem;
|
|
53
|
-
|
|
54
|
-
const isDisabled = disabled || disabledColumns?.[context.column.id] || !isAllowed;
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<Select
|
|
58
|
-
open={open}
|
|
59
|
-
defaultValue={value as string}
|
|
60
|
-
onOpenChange={setOpen}
|
|
61
|
-
onValueChange={(id) => {
|
|
62
|
-
const foundItem = options.find((item) => item.id === id);
|
|
63
|
-
|
|
64
|
-
if (!foundItem) return;
|
|
65
|
-
|
|
66
|
-
setValue(foundItem.id as TValue);
|
|
67
|
-
mutate(foundItem.id as TValue);
|
|
68
|
-
setInternalSelectedItem(foundItem);
|
|
69
|
-
setOpen(false);
|
|
70
|
-
}}
|
|
71
|
-
>
|
|
72
|
-
<SelectTrigger
|
|
73
|
-
disabled={isDisabled}
|
|
74
|
-
className={cn(
|
|
75
|
-
"h-full w-full border-none outline-none ring-0 focus:border-0 focus:outline-none focus:ring-0 focus:ring-offset-0 focus-visible:outline-none",
|
|
76
|
-
className,
|
|
77
|
-
)}
|
|
78
|
-
>
|
|
79
|
-
{selectedItem ? (
|
|
80
|
-
<div className="flex items-center">
|
|
81
|
-
{renderSelectedItem?.(selectedItem) ?? selectedItem.label ?? selectedItem.value}
|
|
82
|
-
</div>
|
|
83
|
-
) : (
|
|
84
|
-
(placeholder ?? "Kies een optie...")
|
|
85
|
-
)}
|
|
86
|
-
</SelectTrigger>
|
|
87
|
-
|
|
88
|
-
<SelectContent>
|
|
89
|
-
{options.map((item) => (
|
|
90
|
-
<SelectItem
|
|
91
|
-
disabled={item.disabled}
|
|
92
|
-
className="cursor-pointer"
|
|
93
|
-
key={item.id}
|
|
94
|
-
value={item.id}
|
|
95
|
-
>
|
|
96
|
-
{item.label ?? item.value}
|
|
97
|
-
</SelectItem>
|
|
98
|
-
))}
|
|
99
|
-
</SelectContent>
|
|
100
|
-
</Select>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import "client-only";
|
|
2
|
-
|
|
3
|
-
import { useAction } from "@/lib/hooks/use-action";
|
|
4
|
-
import { Permission } from "@/modules/auth/entry";
|
|
5
|
-
import { usePermission } from "@/modules/auth/hooks/use-permission";
|
|
6
|
-
import { InlineEditSchema } from "@/modules/inline-edit/entry";
|
|
7
|
-
import { type CellContext } from "@tanstack/react-table";
|
|
8
|
-
import { useEffect, useState } from "react";
|
|
9
|
-
import { toast } from "sonner";
|
|
10
|
-
|
|
11
|
-
export type UseInlineDataTableInputParams<TData, TValue> = {
|
|
12
|
-
context: CellContext<TData, TValue>;
|
|
13
|
-
action: (params: InlineEditSchema<TValue>) => Promise<void> | void;
|
|
14
|
-
permission?: Permission;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Inline form table input
|
|
19
|
-
*/
|
|
20
|
-
export function useInlineDataTableInput<TData extends { id: string }, TValue>({
|
|
21
|
-
context,
|
|
22
|
-
action,
|
|
23
|
-
permission,
|
|
24
|
-
}: UseInlineDataTableInputParams<TData, TValue>) {
|
|
25
|
-
const initialValue = context.getValue();
|
|
26
|
-
|
|
27
|
-
const [value, setValue] = useState(initialValue);
|
|
28
|
-
|
|
29
|
-
useEffect(() => setValue(initialValue), [initialValue]);
|
|
30
|
-
|
|
31
|
-
const permissionData = usePermission(permission ?? {});
|
|
32
|
-
const isAllowed = permissionData.data?.success;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Update value mutation
|
|
36
|
-
*/
|
|
37
|
-
const { mutate } = useAction({
|
|
38
|
-
mutationFn: async (value: TValue) => {
|
|
39
|
-
if (initialValue === value) return;
|
|
40
|
-
|
|
41
|
-
const { id } = context.row.original as TData;
|
|
42
|
-
await action({ id, value });
|
|
43
|
-
},
|
|
44
|
-
onError: () => {
|
|
45
|
-
setValue(initialValue);
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Handle the update of the value.
|
|
51
|
-
*/
|
|
52
|
-
const handleUpdate = (value: TValue) => {
|
|
53
|
-
if (!isAllowed) {
|
|
54
|
-
toast.error("Je hebt geen toestemming om dit te bewerken");
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// If the value is the same as the initial value, do nothing
|
|
59
|
-
if (value === initialValue) return;
|
|
60
|
-
|
|
61
|
-
return mutate(value);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
return { value, setValue, mutate: handleUpdate, isAllowed };
|
|
65
|
-
}
|
/package/src/modules/data-tables/tables/inline-table/components/{inputs → cells}/read-only.tsx
RENAMED
|
File without changes
|