@melv1c/ui-kit 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-RKE7ZPNV.cjs → chunk-H4O6RXFK.cjs} +26 -2
- package/dist/chunk-H4O6RXFK.cjs.map +1 -0
- package/dist/{chunk-5SGT7Y7J.js → chunk-PWXJ2ONW.js} +26 -2
- package/dist/chunk-PWXJ2ONW.js.map +1 -0
- package/dist/index.cjs +339 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -6
- package/dist/index.d.ts +47 -6
- package/dist/index.js +339 -55
- package/dist/index.js.map +1 -1
- package/dist/locales/index.cjs +7 -7
- package/dist/locales/index.d.cts +24 -0
- package/dist/locales/index.d.ts +24 -0
- package/dist/locales/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5SGT7Y7J.js.map +0 -1
- package/dist/chunk-RKE7ZPNV.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Skeleton } from './chunk-PYHBC3IQ.js';
|
|
2
2
|
export { Skeleton } from './chunk-PYHBC3IQ.js';
|
|
3
|
-
import { buttonVariants, Separator, Button, Input } from './chunk-WTLIXI2B.js';
|
|
3
|
+
import { buttonVariants, Separator, Button, Input, Popover, PopoverTrigger, PopoverContent } from './chunk-WTLIXI2B.js';
|
|
4
4
|
export { Button, Input, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Separator, Toggle, ToggleGroup, ToggleGroupItem, buttonVariants, toggleVariants } from './chunk-WTLIXI2B.js';
|
|
5
5
|
import { cn } from './chunk-WZ2GOU2J.js';
|
|
6
6
|
export { cn } from './chunk-WZ2GOU2J.js';
|
|
7
|
-
import { locales_exports } from './chunk-
|
|
7
|
+
import { locales_exports } from './chunk-PWXJ2ONW.js';
|
|
8
8
|
import './chunk-PZ5AY32C.js';
|
|
9
9
|
import * as React9 from 'react';
|
|
10
|
-
import { useState,
|
|
10
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
11
11
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
12
|
-
import { ChevronDownIcon, ChevronRight, MoreHorizontal, ChevronLeftIcon, ChevronRightIcon, ArrowLeft, ArrowRight, CheckIcon, XIcon, SearchIcon, CircleIcon, MoreHorizontalIcon, ChevronUpIcon, PanelLeftIcon, Loader2Icon, OctagonXIcon, TriangleAlertIcon, InfoIcon, CircleCheckIcon, ArrowRightIcon, ArrowLeftIcon } from 'lucide-react';
|
|
12
|
+
import { ChevronDownIcon, ChevronRight, MoreHorizontal, ChevronLeftIcon, ChevronRightIcon, ArrowLeft, ArrowRight, CheckIcon, XIcon, SearchIcon, CircleIcon, MoreHorizontalIcon, ChevronUpIcon, PanelLeftIcon, Loader2Icon, OctagonXIcon, TriangleAlertIcon, InfoIcon, CircleCheckIcon, CircleAlert, EyeOff, Eye, ArrowRightIcon, ArrowLeftIcon, CalendarIcon } from 'lucide-react';
|
|
13
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
14
|
import { cva } from 'class-variance-authority';
|
|
15
15
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
@@ -24,7 +24,7 @@ import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
|
24
24
|
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu';
|
|
25
25
|
import { Drawer as Drawer$1 } from 'vaul';
|
|
26
26
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
27
|
-
import { FormProvider, Controller, useFormContext, useFormState } from 'react-hook-form';
|
|
27
|
+
import { FormProvider, Controller, useFormContext, useFormState, useForm } from 'react-hook-form';
|
|
28
28
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
29
29
|
import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
|
|
30
30
|
import * as MenubarPrimitive from '@radix-ui/react-menubar';
|
|
@@ -39,7 +39,9 @@ import { useTheme } from 'next-themes';
|
|
|
39
39
|
import { Toaster as Toaster$1 } from 'sonner';
|
|
40
40
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
41
41
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
42
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
42
43
|
import { useTranslation, initReactI18next, I18nextProvider } from 'react-i18next';
|
|
44
|
+
import * as z from 'zod';
|
|
43
45
|
import i18n from 'i18next';
|
|
44
46
|
|
|
45
47
|
function Accordion({
|
|
@@ -3766,6 +3768,113 @@ function Textarea({ className, ...props }) {
|
|
|
3766
3768
|
}
|
|
3767
3769
|
);
|
|
3768
3770
|
}
|
|
3771
|
+
function FieldGroup({ className, ...props }) {
|
|
3772
|
+
return /* @__PURE__ */ jsx(
|
|
3773
|
+
"div",
|
|
3774
|
+
{
|
|
3775
|
+
"data-slot": "field-group",
|
|
3776
|
+
className: cn(
|
|
3777
|
+
"group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
|
|
3778
|
+
className
|
|
3779
|
+
),
|
|
3780
|
+
...props
|
|
3781
|
+
}
|
|
3782
|
+
);
|
|
3783
|
+
}
|
|
3784
|
+
var fieldVariants = cva(
|
|
3785
|
+
"group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
|
|
3786
|
+
{
|
|
3787
|
+
variants: {
|
|
3788
|
+
orientation: {
|
|
3789
|
+
vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
|
|
3790
|
+
horizontal: [
|
|
3791
|
+
"flex-row items-center",
|
|
3792
|
+
"[&>[data-slot=field-label]]:flex-auto",
|
|
3793
|
+
"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
|
|
3794
|
+
],
|
|
3795
|
+
responsive: [
|
|
3796
|
+
"flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto",
|
|
3797
|
+
"@md/field-group:[&>[data-slot=field-label]]:flex-auto",
|
|
3798
|
+
"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
|
|
3799
|
+
]
|
|
3800
|
+
}
|
|
3801
|
+
},
|
|
3802
|
+
defaultVariants: {
|
|
3803
|
+
orientation: "vertical"
|
|
3804
|
+
}
|
|
3805
|
+
}
|
|
3806
|
+
);
|
|
3807
|
+
function Field({
|
|
3808
|
+
className,
|
|
3809
|
+
orientation = "vertical",
|
|
3810
|
+
...props
|
|
3811
|
+
}) {
|
|
3812
|
+
return /* @__PURE__ */ jsx(
|
|
3813
|
+
"div",
|
|
3814
|
+
{
|
|
3815
|
+
role: "group",
|
|
3816
|
+
"data-slot": "field",
|
|
3817
|
+
"data-orientation": orientation,
|
|
3818
|
+
className: cn(fieldVariants({ orientation }), className),
|
|
3819
|
+
...props
|
|
3820
|
+
}
|
|
3821
|
+
);
|
|
3822
|
+
}
|
|
3823
|
+
function FieldLabel({
|
|
3824
|
+
className,
|
|
3825
|
+
...props
|
|
3826
|
+
}) {
|
|
3827
|
+
return /* @__PURE__ */ jsx(
|
|
3828
|
+
Label3,
|
|
3829
|
+
{
|
|
3830
|
+
"data-slot": "field-label",
|
|
3831
|
+
className: cn(
|
|
3832
|
+
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
|
|
3833
|
+
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4",
|
|
3834
|
+
"has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",
|
|
3835
|
+
className
|
|
3836
|
+
),
|
|
3837
|
+
...props
|
|
3838
|
+
}
|
|
3839
|
+
);
|
|
3840
|
+
}
|
|
3841
|
+
function FieldError({
|
|
3842
|
+
className,
|
|
3843
|
+
children,
|
|
3844
|
+
errors,
|
|
3845
|
+
...props
|
|
3846
|
+
}) {
|
|
3847
|
+
const content = useMemo(() => {
|
|
3848
|
+
if (children) {
|
|
3849
|
+
return children;
|
|
3850
|
+
}
|
|
3851
|
+
if (!errors?.length) {
|
|
3852
|
+
return null;
|
|
3853
|
+
}
|
|
3854
|
+
const uniqueErrors = [
|
|
3855
|
+
...new Map(errors.map((error) => [error?.message, error])).values()
|
|
3856
|
+
];
|
|
3857
|
+
if (uniqueErrors?.length == 1) {
|
|
3858
|
+
return uniqueErrors[0]?.message;
|
|
3859
|
+
}
|
|
3860
|
+
return /* @__PURE__ */ jsx("ul", { className: "ml-4 flex list-disc flex-col gap-1", children: uniqueErrors.map(
|
|
3861
|
+
(error, index) => error?.message && /* @__PURE__ */ jsx("li", { children: error.message }, index)
|
|
3862
|
+
) });
|
|
3863
|
+
}, [children, errors]);
|
|
3864
|
+
if (!content) {
|
|
3865
|
+
return null;
|
|
3866
|
+
}
|
|
3867
|
+
return /* @__PURE__ */ jsx(
|
|
3868
|
+
"div",
|
|
3869
|
+
{
|
|
3870
|
+
role: "alert",
|
|
3871
|
+
"data-slot": "field-error",
|
|
3872
|
+
className: cn("text-destructive text-sm font-normal", className),
|
|
3873
|
+
...props,
|
|
3874
|
+
children: content
|
|
3875
|
+
}
|
|
3876
|
+
);
|
|
3877
|
+
}
|
|
3769
3878
|
var appleIconVariants = cva("shrink-0 transition-all", {
|
|
3770
3879
|
variants: {
|
|
3771
3880
|
variant: {
|
|
@@ -4060,6 +4169,10 @@ function MicrosoftIcon({
|
|
|
4060
4169
|
}
|
|
4061
4170
|
);
|
|
4062
4171
|
}
|
|
4172
|
+
var createLoginFormSchema = (t) => z.object({
|
|
4173
|
+
email: z.email(t("loginForm.errors.invalidEmail")),
|
|
4174
|
+
password: z.string().min(1, t("loginForm.errors.passwordRequired"))
|
|
4175
|
+
});
|
|
4063
4176
|
var providerIcons = {
|
|
4064
4177
|
google: /* @__PURE__ */ jsx(GoogleIcon, { className: "size-4 p-0" }),
|
|
4065
4178
|
github: /* @__PURE__ */ jsx(GithubIcon, { className: "size-4 p-0" }),
|
|
@@ -4077,15 +4190,33 @@ function LoginForm({
|
|
|
4077
4190
|
showSignUp = true,
|
|
4078
4191
|
title,
|
|
4079
4192
|
description,
|
|
4080
|
-
|
|
4193
|
+
schema,
|
|
4081
4194
|
className
|
|
4082
4195
|
}) {
|
|
4083
4196
|
const { t } = useTranslation("ui");
|
|
4084
|
-
const [
|
|
4085
|
-
const [
|
|
4086
|
-
const
|
|
4087
|
-
|
|
4088
|
-
|
|
4197
|
+
const [error, setError] = useState(null);
|
|
4198
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
4199
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
4200
|
+
const translatedSchema = createLoginFormSchema(t);
|
|
4201
|
+
const resolvedSchema = schema ?? translatedSchema;
|
|
4202
|
+
const form = useForm({
|
|
4203
|
+
resolver: zodResolver(resolvedSchema),
|
|
4204
|
+
defaultValues: {
|
|
4205
|
+
email: "",
|
|
4206
|
+
password: ""
|
|
4207
|
+
}
|
|
4208
|
+
});
|
|
4209
|
+
const handleFormSubmit = async (data) => {
|
|
4210
|
+
try {
|
|
4211
|
+
setError(null);
|
|
4212
|
+
setIsLoading(true);
|
|
4213
|
+
await onSubmit?.(data.email, data.password);
|
|
4214
|
+
} catch (err) {
|
|
4215
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
4216
|
+
setError(errorMessage);
|
|
4217
|
+
} finally {
|
|
4218
|
+
setIsLoading(false);
|
|
4219
|
+
}
|
|
4089
4220
|
};
|
|
4090
4221
|
const displayTitle = title ?? t("loginForm.title");
|
|
4091
4222
|
const displayDescription = description ?? t("loginForm.description");
|
|
@@ -4094,50 +4225,82 @@ function LoginForm({
|
|
|
4094
4225
|
/* @__PURE__ */ jsx(CardTitle, { className: "text-xl", children: displayTitle }),
|
|
4095
4226
|
/* @__PURE__ */ jsx(CardDescription, { children: displayDescription })
|
|
4096
4227
|
] }),
|
|
4097
|
-
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsxs(
|
|
4098
|
-
/* @__PURE__ */ jsxs(
|
|
4099
|
-
/* @__PURE__ */ jsx(
|
|
4100
|
-
/* @__PURE__ */ jsx(
|
|
4101
|
-
Input,
|
|
4102
|
-
{
|
|
4103
|
-
id: "login-email",
|
|
4104
|
-
type: "email",
|
|
4105
|
-
placeholder: t("loginForm.emailPlaceholder"),
|
|
4106
|
-
value: email,
|
|
4107
|
-
onChange: (e) => setEmail(e.target.value),
|
|
4108
|
-
required: true,
|
|
4109
|
-
disabled: isLoading,
|
|
4110
|
-
autoComplete: "email"
|
|
4111
|
-
}
|
|
4112
|
-
)
|
|
4113
|
-
] }),
|
|
4114
|
-
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
4115
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
4116
|
-
/* @__PURE__ */ jsx(Label3, { htmlFor: "login-password", children: t("loginForm.password") }),
|
|
4117
|
-
showForgotPassword && /* @__PURE__ */ jsx(
|
|
4118
|
-
"button",
|
|
4119
|
-
{
|
|
4120
|
-
type: "button",
|
|
4121
|
-
onClick: onForgotPassword,
|
|
4122
|
-
className: "text-muted-foreground hover:text-primary ml-auto text-sm underline-offset-4 hover:underline",
|
|
4123
|
-
disabled: isLoading,
|
|
4124
|
-
children: t("loginForm.forgotPassword")
|
|
4125
|
-
}
|
|
4126
|
-
)
|
|
4127
|
-
] }),
|
|
4128
|
-
/* @__PURE__ */ jsx(
|
|
4129
|
-
Input,
|
|
4130
|
-
{
|
|
4131
|
-
id: "login-password",
|
|
4132
|
-
type: "password",
|
|
4133
|
-
value: password,
|
|
4134
|
-
onChange: (e) => setPassword(e.target.value),
|
|
4135
|
-
required: true,
|
|
4136
|
-
disabled: isLoading,
|
|
4137
|
-
autoComplete: "current-password"
|
|
4138
|
-
}
|
|
4139
|
-
)
|
|
4228
|
+
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("form", { id: "login-form", onSubmit: form.handleSubmit(handleFormSubmit), children: /* @__PURE__ */ jsxs(FieldGroup, { className: "gap-6", children: [
|
|
4229
|
+
error && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
|
|
4230
|
+
/* @__PURE__ */ jsx(CircleAlert, {}),
|
|
4231
|
+
/* @__PURE__ */ jsx(AlertDescription, { children: error })
|
|
4140
4232
|
] }),
|
|
4233
|
+
/* @__PURE__ */ jsx(
|
|
4234
|
+
Controller,
|
|
4235
|
+
{
|
|
4236
|
+
name: "email",
|
|
4237
|
+
control: form.control,
|
|
4238
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxs(Field, { "data-invalid": fieldState.invalid, children: [
|
|
4239
|
+
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: "login-email", children: t("loginForm.email") }),
|
|
4240
|
+
/* @__PURE__ */ jsx(
|
|
4241
|
+
Input,
|
|
4242
|
+
{
|
|
4243
|
+
...field,
|
|
4244
|
+
id: "login-email",
|
|
4245
|
+
type: "email",
|
|
4246
|
+
placeholder: t("loginForm.emailPlaceholder"),
|
|
4247
|
+
disabled: isLoading,
|
|
4248
|
+
autoComplete: "email",
|
|
4249
|
+
"aria-invalid": fieldState.invalid
|
|
4250
|
+
}
|
|
4251
|
+
),
|
|
4252
|
+
fieldState.invalid && /* @__PURE__ */ jsx(FieldError, { errors: [fieldState.error] })
|
|
4253
|
+
] })
|
|
4254
|
+
}
|
|
4255
|
+
),
|
|
4256
|
+
/* @__PURE__ */ jsx(
|
|
4257
|
+
Controller,
|
|
4258
|
+
{
|
|
4259
|
+
name: "password",
|
|
4260
|
+
control: form.control,
|
|
4261
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxs(Field, { "data-invalid": fieldState.invalid, children: [
|
|
4262
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
4263
|
+
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: "login-password", children: t("loginForm.password") }),
|
|
4264
|
+
showForgotPassword && /* @__PURE__ */ jsx(
|
|
4265
|
+
"button",
|
|
4266
|
+
{
|
|
4267
|
+
type: "button",
|
|
4268
|
+
onClick: onForgotPassword,
|
|
4269
|
+
className: "text-muted-foreground hover:text-primary ml-auto text-sm underline-offset-4 hover:underline",
|
|
4270
|
+
disabled: isLoading,
|
|
4271
|
+
children: t("loginForm.forgotPassword")
|
|
4272
|
+
}
|
|
4273
|
+
)
|
|
4274
|
+
] }),
|
|
4275
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
4276
|
+
/* @__PURE__ */ jsx(
|
|
4277
|
+
Input,
|
|
4278
|
+
{
|
|
4279
|
+
...field,
|
|
4280
|
+
id: "login-password",
|
|
4281
|
+
type: showPassword ? "text" : "password",
|
|
4282
|
+
disabled: isLoading,
|
|
4283
|
+
autoComplete: "current-password",
|
|
4284
|
+
"aria-invalid": fieldState.invalid,
|
|
4285
|
+
className: "pr-10"
|
|
4286
|
+
}
|
|
4287
|
+
),
|
|
4288
|
+
/* @__PURE__ */ jsx(
|
|
4289
|
+
"button",
|
|
4290
|
+
{
|
|
4291
|
+
type: "button",
|
|
4292
|
+
onClick: () => setShowPassword(!showPassword),
|
|
4293
|
+
className: "text-muted-foreground hover:text-foreground absolute top-1/2 right-3 -translate-y-1/2",
|
|
4294
|
+
disabled: isLoading,
|
|
4295
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
4296
|
+
children: showPassword ? /* @__PURE__ */ jsx(EyeOff, { className: "size-4" }) : /* @__PURE__ */ jsx(Eye, { className: "size-4" })
|
|
4297
|
+
}
|
|
4298
|
+
)
|
|
4299
|
+
] }),
|
|
4300
|
+
fieldState.invalid && /* @__PURE__ */ jsx(FieldError, { errors: [fieldState.error] })
|
|
4301
|
+
] })
|
|
4302
|
+
}
|
|
4303
|
+
),
|
|
4141
4304
|
/* @__PURE__ */ jsx(Button, { type: "submit", className: "w-full", disabled: isLoading, children: isLoading ? t("loginForm.loggingIn") : t("loginForm.login") }),
|
|
4142
4305
|
providers.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4143
4306
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
@@ -4191,6 +4354,127 @@ function PreviousButton(props) {
|
|
|
4191
4354
|
t("previous")
|
|
4192
4355
|
] });
|
|
4193
4356
|
}
|
|
4357
|
+
function DateTimePicker({
|
|
4358
|
+
value,
|
|
4359
|
+
onChange,
|
|
4360
|
+
label,
|
|
4361
|
+
placeholder = "Select date and time",
|
|
4362
|
+
showClear = true,
|
|
4363
|
+
disabled = false,
|
|
4364
|
+
className,
|
|
4365
|
+
formatDateTime
|
|
4366
|
+
}) {
|
|
4367
|
+
const [open, setOpen] = useState(false);
|
|
4368
|
+
const [date, setDate] = useState(value);
|
|
4369
|
+
const handleClear = () => {
|
|
4370
|
+
setDate(void 0);
|
|
4371
|
+
onChange?.(void 0);
|
|
4372
|
+
};
|
|
4373
|
+
const handleDateChange = (newDate) => {
|
|
4374
|
+
if (!newDate) {
|
|
4375
|
+
setDate(void 0);
|
|
4376
|
+
onChange?.(void 0);
|
|
4377
|
+
return;
|
|
4378
|
+
}
|
|
4379
|
+
let updatedDate = newDate;
|
|
4380
|
+
if (date) {
|
|
4381
|
+
updatedDate = new Date(newDate);
|
|
4382
|
+
updatedDate.setHours(date.getHours());
|
|
4383
|
+
updatedDate.setMinutes(date.getMinutes());
|
|
4384
|
+
updatedDate.setSeconds(date.getSeconds());
|
|
4385
|
+
}
|
|
4386
|
+
setDate(updatedDate);
|
|
4387
|
+
onChange?.(updatedDate);
|
|
4388
|
+
};
|
|
4389
|
+
const handleTimeChange = (event) => {
|
|
4390
|
+
const timeValue = event.target.value;
|
|
4391
|
+
if (!timeValue) return;
|
|
4392
|
+
const [hours, minutes, seconds = "0"] = timeValue.split(":");
|
|
4393
|
+
const updatedDate = date ? new Date(date) : /* @__PURE__ */ new Date();
|
|
4394
|
+
updatedDate.setHours(parseInt(hours, 10));
|
|
4395
|
+
updatedDate.setMinutes(parseInt(minutes, 10));
|
|
4396
|
+
updatedDate.setSeconds(parseInt(seconds, 10));
|
|
4397
|
+
setDate(updatedDate);
|
|
4398
|
+
onChange?.(updatedDate);
|
|
4399
|
+
};
|
|
4400
|
+
const formatTimeValue = (date2) => {
|
|
4401
|
+
if (!date2) return "";
|
|
4402
|
+
const hours = date2.getHours().toString().padStart(2, "0");
|
|
4403
|
+
const minutes = date2.getMinutes().toString().padStart(2, "0");
|
|
4404
|
+
return `${hours}:${minutes}`;
|
|
4405
|
+
};
|
|
4406
|
+
const defaultFormatDateTime = (date2) => {
|
|
4407
|
+
const dateStr = date2.toLocaleDateString();
|
|
4408
|
+
const timeStr = date2.toLocaleTimeString(void 0, {
|
|
4409
|
+
hour: "2-digit",
|
|
4410
|
+
minute: "2-digit"
|
|
4411
|
+
});
|
|
4412
|
+
return `${dateStr} ${timeStr}`;
|
|
4413
|
+
};
|
|
4414
|
+
useEffect(() => {
|
|
4415
|
+
setDate(value);
|
|
4416
|
+
}, [value]);
|
|
4417
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-3", className), children: [
|
|
4418
|
+
label && /* @__PURE__ */ jsx(Label3, { htmlFor: "datetime-picker", className: "px-1", children: label }),
|
|
4419
|
+
/* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
4420
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
4421
|
+
Button,
|
|
4422
|
+
{
|
|
4423
|
+
variant: "outline",
|
|
4424
|
+
id: "datetime-picker",
|
|
4425
|
+
className: cn(
|
|
4426
|
+
"w-full justify-start font-normal",
|
|
4427
|
+
!date && "text-muted-foreground"
|
|
4428
|
+
),
|
|
4429
|
+
disabled,
|
|
4430
|
+
children: [
|
|
4431
|
+
/* @__PURE__ */ jsx(CalendarIcon, { className: "mr-2 size-4" }),
|
|
4432
|
+
date ? formatDateTime ? formatDateTime(date) : defaultFormatDateTime(date) : placeholder,
|
|
4433
|
+
showClear && date && /* @__PURE__ */ jsx(
|
|
4434
|
+
"button",
|
|
4435
|
+
{
|
|
4436
|
+
type: "button",
|
|
4437
|
+
onClick: (e) => {
|
|
4438
|
+
e.stopPropagation();
|
|
4439
|
+
handleClear();
|
|
4440
|
+
},
|
|
4441
|
+
className: "hover:bg-accent -mr-1 ml-auto rounded-sm p-1",
|
|
4442
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "size-3.5" })
|
|
4443
|
+
}
|
|
4444
|
+
)
|
|
4445
|
+
]
|
|
4446
|
+
}
|
|
4447
|
+
) }),
|
|
4448
|
+
/* @__PURE__ */ jsxs(PopoverContent, { className: "w-auto p-0", align: "start", children: [
|
|
4449
|
+
/* @__PURE__ */ jsx(
|
|
4450
|
+
Calendar,
|
|
4451
|
+
{
|
|
4452
|
+
mode: "single",
|
|
4453
|
+
selected: date,
|
|
4454
|
+
captionLayout: "dropdown",
|
|
4455
|
+
onSelect: handleDateChange,
|
|
4456
|
+
disabled
|
|
4457
|
+
}
|
|
4458
|
+
),
|
|
4459
|
+
/* @__PURE__ */ jsxs("div", { className: "border-t p-3", children: [
|
|
4460
|
+
/* @__PURE__ */ jsx(Label3, { htmlFor: "time-input", className: "mb-2 block text-xs", children: "Time" }),
|
|
4461
|
+
/* @__PURE__ */ jsx(
|
|
4462
|
+
Input,
|
|
4463
|
+
{
|
|
4464
|
+
type: "time",
|
|
4465
|
+
id: "time-input",
|
|
4466
|
+
step: "60",
|
|
4467
|
+
value: formatTimeValue(date),
|
|
4468
|
+
onChange: handleTimeChange,
|
|
4469
|
+
disabled,
|
|
4470
|
+
className: "bg-background h-8 appearance-none [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none"
|
|
4471
|
+
}
|
|
4472
|
+
)
|
|
4473
|
+
] })
|
|
4474
|
+
] })
|
|
4475
|
+
] })
|
|
4476
|
+
] });
|
|
4477
|
+
}
|
|
4194
4478
|
function LocaleProvider({
|
|
4195
4479
|
children,
|
|
4196
4480
|
language,
|
|
@@ -4252,6 +4536,6 @@ function TranslationProvider({
|
|
|
4252
4536
|
return /* @__PURE__ */ jsx(I18nextProvider, { i18n: i18n2, children });
|
|
4253
4537
|
}
|
|
4254
4538
|
|
|
4255
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppleIcon, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FacebookIcon, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GithubIcon, GoogleIcon, HoverCard, HoverCardContent, HoverCardTrigger, Label3 as Label, LocaleProvider, LoginForm, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MicrosoftIcon, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NextButton, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PreviousButton, Progress, RadioGroup4 as RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Slider, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TranslationProvider, appleIconVariants, badgeVariants, buttonGroupVariants, facebookIconVariants, githubIconVariants, googleIconVariants, microsoftIconVariants, navigationMenuTriggerStyle, useFormField, useSidebar };
|
|
4539
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppleIcon, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DateTimePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FacebookIcon, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GithubIcon, GoogleIcon, HoverCard, HoverCardContent, HoverCardTrigger, Label3 as Label, LocaleProvider, LoginForm, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MicrosoftIcon, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NextButton, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PreviousButton, Progress, RadioGroup4 as RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Slider, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TranslationProvider, appleIconVariants, badgeVariants, buttonGroupVariants, facebookIconVariants, githubIconVariants, googleIconVariants, microsoftIconVariants, navigationMenuTriggerStyle, useFormField, useSidebar };
|
|
4256
4540
|
//# sourceMappingURL=index.js.map
|
|
4257
4541
|
//# sourceMappingURL=index.js.map
|