@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.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var chunkQ4GFV3J3_cjs = require('./chunk-Q4GFV3J3.cjs');
|
|
4
4
|
var chunkGQ6Z5A4R_cjs = require('./chunk-GQ6Z5A4R.cjs');
|
|
5
5
|
var chunkI7WHASOO_cjs = require('./chunk-I7WHASOO.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkH4O6RXFK_cjs = require('./chunk-H4O6RXFK.cjs');
|
|
7
7
|
require('./chunk-Q7SFCCGT.cjs');
|
|
8
8
|
var React9 = require('react');
|
|
9
9
|
var AccordionPrimitive = require('@radix-ui/react-accordion');
|
|
@@ -37,7 +37,9 @@ var nextThemes = require('next-themes');
|
|
|
37
37
|
var sonner = require('sonner');
|
|
38
38
|
var SwitchPrimitive = require('@radix-ui/react-switch');
|
|
39
39
|
var TabsPrimitive = require('@radix-ui/react-tabs');
|
|
40
|
+
var zod = require('@hookform/resolvers/zod');
|
|
40
41
|
var reactI18next = require('react-i18next');
|
|
42
|
+
var z = require('zod');
|
|
41
43
|
var i18n = require('i18next');
|
|
42
44
|
|
|
43
45
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -82,6 +84,7 @@ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitiv
|
|
|
82
84
|
var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
|
|
83
85
|
var SwitchPrimitive__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitive);
|
|
84
86
|
var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
|
|
87
|
+
var z__namespace = /*#__PURE__*/_interopNamespace(z);
|
|
85
88
|
var i18n__default = /*#__PURE__*/_interopDefault(i18n);
|
|
86
89
|
|
|
87
90
|
function Accordion({
|
|
@@ -3808,6 +3811,113 @@ function Textarea({ className, ...props }) {
|
|
|
3808
3811
|
}
|
|
3809
3812
|
);
|
|
3810
3813
|
}
|
|
3814
|
+
function FieldGroup({ className, ...props }) {
|
|
3815
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3816
|
+
"div",
|
|
3817
|
+
{
|
|
3818
|
+
"data-slot": "field-group",
|
|
3819
|
+
className: chunkI7WHASOO_cjs.cn(
|
|
3820
|
+
"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",
|
|
3821
|
+
className
|
|
3822
|
+
),
|
|
3823
|
+
...props
|
|
3824
|
+
}
|
|
3825
|
+
);
|
|
3826
|
+
}
|
|
3827
|
+
var fieldVariants = classVarianceAuthority.cva(
|
|
3828
|
+
"group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
|
|
3829
|
+
{
|
|
3830
|
+
variants: {
|
|
3831
|
+
orientation: {
|
|
3832
|
+
vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
|
|
3833
|
+
horizontal: [
|
|
3834
|
+
"flex-row items-center",
|
|
3835
|
+
"[&>[data-slot=field-label]]:flex-auto",
|
|
3836
|
+
"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
|
|
3837
|
+
],
|
|
3838
|
+
responsive: [
|
|
3839
|
+
"flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto",
|
|
3840
|
+
"@md/field-group:[&>[data-slot=field-label]]:flex-auto",
|
|
3841
|
+
"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
|
|
3842
|
+
]
|
|
3843
|
+
}
|
|
3844
|
+
},
|
|
3845
|
+
defaultVariants: {
|
|
3846
|
+
orientation: "vertical"
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
);
|
|
3850
|
+
function Field({
|
|
3851
|
+
className,
|
|
3852
|
+
orientation = "vertical",
|
|
3853
|
+
...props
|
|
3854
|
+
}) {
|
|
3855
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3856
|
+
"div",
|
|
3857
|
+
{
|
|
3858
|
+
role: "group",
|
|
3859
|
+
"data-slot": "field",
|
|
3860
|
+
"data-orientation": orientation,
|
|
3861
|
+
className: chunkI7WHASOO_cjs.cn(fieldVariants({ orientation }), className),
|
|
3862
|
+
...props
|
|
3863
|
+
}
|
|
3864
|
+
);
|
|
3865
|
+
}
|
|
3866
|
+
function FieldLabel({
|
|
3867
|
+
className,
|
|
3868
|
+
...props
|
|
3869
|
+
}) {
|
|
3870
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3871
|
+
Label3,
|
|
3872
|
+
{
|
|
3873
|
+
"data-slot": "field-label",
|
|
3874
|
+
className: chunkI7WHASOO_cjs.cn(
|
|
3875
|
+
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
|
|
3876
|
+
"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",
|
|
3877
|
+
"has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",
|
|
3878
|
+
className
|
|
3879
|
+
),
|
|
3880
|
+
...props
|
|
3881
|
+
}
|
|
3882
|
+
);
|
|
3883
|
+
}
|
|
3884
|
+
function FieldError({
|
|
3885
|
+
className,
|
|
3886
|
+
children,
|
|
3887
|
+
errors,
|
|
3888
|
+
...props
|
|
3889
|
+
}) {
|
|
3890
|
+
const content = React9.useMemo(() => {
|
|
3891
|
+
if (children) {
|
|
3892
|
+
return children;
|
|
3893
|
+
}
|
|
3894
|
+
if (!errors?.length) {
|
|
3895
|
+
return null;
|
|
3896
|
+
}
|
|
3897
|
+
const uniqueErrors = [
|
|
3898
|
+
...new Map(errors.map((error) => [error?.message, error])).values()
|
|
3899
|
+
];
|
|
3900
|
+
if (uniqueErrors?.length == 1) {
|
|
3901
|
+
return uniqueErrors[0]?.message;
|
|
3902
|
+
}
|
|
3903
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "ml-4 flex list-disc flex-col gap-1", children: uniqueErrors.map(
|
|
3904
|
+
(error, index) => error?.message && /* @__PURE__ */ jsxRuntime.jsx("li", { children: error.message }, index)
|
|
3905
|
+
) });
|
|
3906
|
+
}, [children, errors]);
|
|
3907
|
+
if (!content) {
|
|
3908
|
+
return null;
|
|
3909
|
+
}
|
|
3910
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3911
|
+
"div",
|
|
3912
|
+
{
|
|
3913
|
+
role: "alert",
|
|
3914
|
+
"data-slot": "field-error",
|
|
3915
|
+
className: chunkI7WHASOO_cjs.cn("text-destructive text-sm font-normal", className),
|
|
3916
|
+
...props,
|
|
3917
|
+
children: content
|
|
3918
|
+
}
|
|
3919
|
+
);
|
|
3920
|
+
}
|
|
3811
3921
|
var appleIconVariants = classVarianceAuthority.cva("shrink-0 transition-all", {
|
|
3812
3922
|
variants: {
|
|
3813
3923
|
variant: {
|
|
@@ -4102,6 +4212,10 @@ function MicrosoftIcon({
|
|
|
4102
4212
|
}
|
|
4103
4213
|
);
|
|
4104
4214
|
}
|
|
4215
|
+
var createLoginFormSchema = (t) => z__namespace.object({
|
|
4216
|
+
email: z__namespace.email(t("loginForm.errors.invalidEmail")),
|
|
4217
|
+
password: z__namespace.string().min(1, t("loginForm.errors.passwordRequired"))
|
|
4218
|
+
});
|
|
4105
4219
|
var providerIcons = {
|
|
4106
4220
|
google: /* @__PURE__ */ jsxRuntime.jsx(GoogleIcon, { className: "size-4 p-0" }),
|
|
4107
4221
|
github: /* @__PURE__ */ jsxRuntime.jsx(GithubIcon, { className: "size-4 p-0" }),
|
|
@@ -4119,15 +4233,33 @@ function LoginForm({
|
|
|
4119
4233
|
showSignUp = true,
|
|
4120
4234
|
title,
|
|
4121
4235
|
description,
|
|
4122
|
-
|
|
4236
|
+
schema,
|
|
4123
4237
|
className
|
|
4124
4238
|
}) {
|
|
4125
4239
|
const { t } = reactI18next.useTranslation("ui");
|
|
4126
|
-
const [
|
|
4127
|
-
const [
|
|
4128
|
-
const
|
|
4129
|
-
|
|
4130
|
-
|
|
4240
|
+
const [error, setError] = React9.useState(null);
|
|
4241
|
+
const [isLoading, setIsLoading] = React9.useState(false);
|
|
4242
|
+
const [showPassword, setShowPassword] = React9.useState(false);
|
|
4243
|
+
const translatedSchema = createLoginFormSchema(t);
|
|
4244
|
+
const resolvedSchema = schema ?? translatedSchema;
|
|
4245
|
+
const form = reactHookForm.useForm({
|
|
4246
|
+
resolver: zod.zodResolver(resolvedSchema),
|
|
4247
|
+
defaultValues: {
|
|
4248
|
+
email: "",
|
|
4249
|
+
password: ""
|
|
4250
|
+
}
|
|
4251
|
+
});
|
|
4252
|
+
const handleFormSubmit = async (data) => {
|
|
4253
|
+
try {
|
|
4254
|
+
setError(null);
|
|
4255
|
+
setIsLoading(true);
|
|
4256
|
+
await onSubmit?.(data.email, data.password);
|
|
4257
|
+
} catch (err) {
|
|
4258
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
4259
|
+
setError(errorMessage);
|
|
4260
|
+
} finally {
|
|
4261
|
+
setIsLoading(false);
|
|
4262
|
+
}
|
|
4131
4263
|
};
|
|
4132
4264
|
const displayTitle = title ?? t("loginForm.title");
|
|
4133
4265
|
const displayDescription = description ?? t("loginForm.description");
|
|
@@ -4136,50 +4268,82 @@ function LoginForm({
|
|
|
4136
4268
|
/* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "text-xl", children: displayTitle }),
|
|
4137
4269
|
/* @__PURE__ */ jsxRuntime.jsx(CardDescription, { children: displayDescription })
|
|
4138
4270
|
] }),
|
|
4139
|
-
/* @__PURE__ */ jsxRuntime.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4140
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4141
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4142
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4143
|
-
chunkGQ6Z5A4R_cjs.Input,
|
|
4144
|
-
{
|
|
4145
|
-
id: "login-email",
|
|
4146
|
-
type: "email",
|
|
4147
|
-
placeholder: t("loginForm.emailPlaceholder"),
|
|
4148
|
-
value: email,
|
|
4149
|
-
onChange: (e) => setEmail(e.target.value),
|
|
4150
|
-
required: true,
|
|
4151
|
-
disabled: isLoading,
|
|
4152
|
-
autoComplete: "email"
|
|
4153
|
-
}
|
|
4154
|
-
)
|
|
4155
|
-
] }),
|
|
4156
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-2", children: [
|
|
4157
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
|
|
4158
|
-
/* @__PURE__ */ jsxRuntime.jsx(Label3, { htmlFor: "login-password", children: t("loginForm.password") }),
|
|
4159
|
-
showForgotPassword && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4160
|
-
"button",
|
|
4161
|
-
{
|
|
4162
|
-
type: "button",
|
|
4163
|
-
onClick: onForgotPassword,
|
|
4164
|
-
className: "text-muted-foreground hover:text-primary ml-auto text-sm underline-offset-4 hover:underline",
|
|
4165
|
-
disabled: isLoading,
|
|
4166
|
-
children: t("loginForm.forgotPassword")
|
|
4167
|
-
}
|
|
4168
|
-
)
|
|
4169
|
-
] }),
|
|
4170
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4171
|
-
chunkGQ6Z5A4R_cjs.Input,
|
|
4172
|
-
{
|
|
4173
|
-
id: "login-password",
|
|
4174
|
-
type: "password",
|
|
4175
|
-
value: password,
|
|
4176
|
-
onChange: (e) => setPassword(e.target.value),
|
|
4177
|
-
required: true,
|
|
4178
|
-
disabled: isLoading,
|
|
4179
|
-
autoComplete: "current-password"
|
|
4180
|
-
}
|
|
4181
|
-
)
|
|
4271
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardContent, { children: /* @__PURE__ */ jsxRuntime.jsx("form", { id: "login-form", onSubmit: form.handleSubmit(handleFormSubmit), children: /* @__PURE__ */ jsxRuntime.jsxs(FieldGroup, { className: "gap-6", children: [
|
|
4272
|
+
error && /* @__PURE__ */ jsxRuntime.jsxs(Alert, { variant: "destructive", children: [
|
|
4273
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleAlert, {}),
|
|
4274
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDescription, { children: error })
|
|
4182
4275
|
] }),
|
|
4276
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4277
|
+
reactHookForm.Controller,
|
|
4278
|
+
{
|
|
4279
|
+
name: "email",
|
|
4280
|
+
control: form.control,
|
|
4281
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsxs(Field, { "data-invalid": fieldState.invalid, children: [
|
|
4282
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { htmlFor: "login-email", children: t("loginForm.email") }),
|
|
4283
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4284
|
+
chunkGQ6Z5A4R_cjs.Input,
|
|
4285
|
+
{
|
|
4286
|
+
...field,
|
|
4287
|
+
id: "login-email",
|
|
4288
|
+
type: "email",
|
|
4289
|
+
placeholder: t("loginForm.emailPlaceholder"),
|
|
4290
|
+
disabled: isLoading,
|
|
4291
|
+
autoComplete: "email",
|
|
4292
|
+
"aria-invalid": fieldState.invalid
|
|
4293
|
+
}
|
|
4294
|
+
),
|
|
4295
|
+
fieldState.invalid && /* @__PURE__ */ jsxRuntime.jsx(FieldError, { errors: [fieldState.error] })
|
|
4296
|
+
] })
|
|
4297
|
+
}
|
|
4298
|
+
),
|
|
4299
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4300
|
+
reactHookForm.Controller,
|
|
4301
|
+
{
|
|
4302
|
+
name: "password",
|
|
4303
|
+
control: form.control,
|
|
4304
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsxs(Field, { "data-invalid": fieldState.invalid, children: [
|
|
4305
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
|
|
4306
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldLabel, { htmlFor: "login-password", children: t("loginForm.password") }),
|
|
4307
|
+
showForgotPassword && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4308
|
+
"button",
|
|
4309
|
+
{
|
|
4310
|
+
type: "button",
|
|
4311
|
+
onClick: onForgotPassword,
|
|
4312
|
+
className: "text-muted-foreground hover:text-primary ml-auto text-sm underline-offset-4 hover:underline",
|
|
4313
|
+
disabled: isLoading,
|
|
4314
|
+
children: t("loginForm.forgotPassword")
|
|
4315
|
+
}
|
|
4316
|
+
)
|
|
4317
|
+
] }),
|
|
4318
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
4319
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4320
|
+
chunkGQ6Z5A4R_cjs.Input,
|
|
4321
|
+
{
|
|
4322
|
+
...field,
|
|
4323
|
+
id: "login-password",
|
|
4324
|
+
type: showPassword ? "text" : "password",
|
|
4325
|
+
disabled: isLoading,
|
|
4326
|
+
autoComplete: "current-password",
|
|
4327
|
+
"aria-invalid": fieldState.invalid,
|
|
4328
|
+
className: "pr-10"
|
|
4329
|
+
}
|
|
4330
|
+
),
|
|
4331
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4332
|
+
"button",
|
|
4333
|
+
{
|
|
4334
|
+
type: "button",
|
|
4335
|
+
onClick: () => setShowPassword(!showPassword),
|
|
4336
|
+
className: "text-muted-foreground hover:text-foreground absolute top-1/2 right-3 -translate-y-1/2",
|
|
4337
|
+
disabled: isLoading,
|
|
4338
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
4339
|
+
children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { className: "size-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "size-4" })
|
|
4340
|
+
}
|
|
4341
|
+
)
|
|
4342
|
+
] }),
|
|
4343
|
+
fieldState.invalid && /* @__PURE__ */ jsxRuntime.jsx(FieldError, { errors: [fieldState.error] })
|
|
4344
|
+
] })
|
|
4345
|
+
}
|
|
4346
|
+
),
|
|
4183
4347
|
/* @__PURE__ */ jsxRuntime.jsx(chunkGQ6Z5A4R_cjs.Button, { type: "submit", className: "w-full", disabled: isLoading, children: isLoading ? t("loginForm.loggingIn") : t("loginForm.login") }),
|
|
4184
4348
|
providers.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4185
4349
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
@@ -4233,6 +4397,127 @@ function PreviousButton(props) {
|
|
|
4233
4397
|
t("previous")
|
|
4234
4398
|
] });
|
|
4235
4399
|
}
|
|
4400
|
+
function DateTimePicker({
|
|
4401
|
+
value,
|
|
4402
|
+
onChange,
|
|
4403
|
+
label,
|
|
4404
|
+
placeholder = "Select date and time",
|
|
4405
|
+
showClear = true,
|
|
4406
|
+
disabled = false,
|
|
4407
|
+
className,
|
|
4408
|
+
formatDateTime
|
|
4409
|
+
}) {
|
|
4410
|
+
const [open, setOpen] = React9.useState(false);
|
|
4411
|
+
const [date, setDate] = React9.useState(value);
|
|
4412
|
+
const handleClear = () => {
|
|
4413
|
+
setDate(void 0);
|
|
4414
|
+
onChange?.(void 0);
|
|
4415
|
+
};
|
|
4416
|
+
const handleDateChange = (newDate) => {
|
|
4417
|
+
if (!newDate) {
|
|
4418
|
+
setDate(void 0);
|
|
4419
|
+
onChange?.(void 0);
|
|
4420
|
+
return;
|
|
4421
|
+
}
|
|
4422
|
+
let updatedDate = newDate;
|
|
4423
|
+
if (date) {
|
|
4424
|
+
updatedDate = new Date(newDate);
|
|
4425
|
+
updatedDate.setHours(date.getHours());
|
|
4426
|
+
updatedDate.setMinutes(date.getMinutes());
|
|
4427
|
+
updatedDate.setSeconds(date.getSeconds());
|
|
4428
|
+
}
|
|
4429
|
+
setDate(updatedDate);
|
|
4430
|
+
onChange?.(updatedDate);
|
|
4431
|
+
};
|
|
4432
|
+
const handleTimeChange = (event) => {
|
|
4433
|
+
const timeValue = event.target.value;
|
|
4434
|
+
if (!timeValue) return;
|
|
4435
|
+
const [hours, minutes, seconds = "0"] = timeValue.split(":");
|
|
4436
|
+
const updatedDate = date ? new Date(date) : /* @__PURE__ */ new Date();
|
|
4437
|
+
updatedDate.setHours(parseInt(hours, 10));
|
|
4438
|
+
updatedDate.setMinutes(parseInt(minutes, 10));
|
|
4439
|
+
updatedDate.setSeconds(parseInt(seconds, 10));
|
|
4440
|
+
setDate(updatedDate);
|
|
4441
|
+
onChange?.(updatedDate);
|
|
4442
|
+
};
|
|
4443
|
+
const formatTimeValue = (date2) => {
|
|
4444
|
+
if (!date2) return "";
|
|
4445
|
+
const hours = date2.getHours().toString().padStart(2, "0");
|
|
4446
|
+
const minutes = date2.getMinutes().toString().padStart(2, "0");
|
|
4447
|
+
return `${hours}:${minutes}`;
|
|
4448
|
+
};
|
|
4449
|
+
const defaultFormatDateTime = (date2) => {
|
|
4450
|
+
const dateStr = date2.toLocaleDateString();
|
|
4451
|
+
const timeStr = date2.toLocaleTimeString(void 0, {
|
|
4452
|
+
hour: "2-digit",
|
|
4453
|
+
minute: "2-digit"
|
|
4454
|
+
});
|
|
4455
|
+
return `${dateStr} ${timeStr}`;
|
|
4456
|
+
};
|
|
4457
|
+
React9.useEffect(() => {
|
|
4458
|
+
setDate(value);
|
|
4459
|
+
}, [value]);
|
|
4460
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkI7WHASOO_cjs.cn("flex flex-col gap-3", className), children: [
|
|
4461
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(Label3, { htmlFor: "datetime-picker", className: "px-1", children: label }),
|
|
4462
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkGQ6Z5A4R_cjs.Popover, { open, onOpenChange: setOpen, children: [
|
|
4463
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkGQ6Z5A4R_cjs.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4464
|
+
chunkGQ6Z5A4R_cjs.Button,
|
|
4465
|
+
{
|
|
4466
|
+
variant: "outline",
|
|
4467
|
+
id: "datetime-picker",
|
|
4468
|
+
className: chunkI7WHASOO_cjs.cn(
|
|
4469
|
+
"w-full justify-start font-normal",
|
|
4470
|
+
!date && "text-muted-foreground"
|
|
4471
|
+
),
|
|
4472
|
+
disabled,
|
|
4473
|
+
children: [
|
|
4474
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "mr-2 size-4" }),
|
|
4475
|
+
date ? formatDateTime ? formatDateTime(date) : defaultFormatDateTime(date) : placeholder,
|
|
4476
|
+
showClear && date && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4477
|
+
"button",
|
|
4478
|
+
{
|
|
4479
|
+
type: "button",
|
|
4480
|
+
onClick: (e) => {
|
|
4481
|
+
e.stopPropagation();
|
|
4482
|
+
handleClear();
|
|
4483
|
+
},
|
|
4484
|
+
className: "hover:bg-accent -mr-1 ml-auto rounded-sm p-1",
|
|
4485
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { className: "size-3.5" })
|
|
4486
|
+
}
|
|
4487
|
+
)
|
|
4488
|
+
]
|
|
4489
|
+
}
|
|
4490
|
+
) }),
|
|
4491
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkGQ6Z5A4R_cjs.PopoverContent, { className: "w-auto p-0", align: "start", children: [
|
|
4492
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4493
|
+
Calendar,
|
|
4494
|
+
{
|
|
4495
|
+
mode: "single",
|
|
4496
|
+
selected: date,
|
|
4497
|
+
captionLayout: "dropdown",
|
|
4498
|
+
onSelect: handleDateChange,
|
|
4499
|
+
disabled
|
|
4500
|
+
}
|
|
4501
|
+
),
|
|
4502
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t p-3", children: [
|
|
4503
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label3, { htmlFor: "time-input", className: "mb-2 block text-xs", children: "Time" }),
|
|
4504
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4505
|
+
chunkGQ6Z5A4R_cjs.Input,
|
|
4506
|
+
{
|
|
4507
|
+
type: "time",
|
|
4508
|
+
id: "time-input",
|
|
4509
|
+
step: "60",
|
|
4510
|
+
value: formatTimeValue(date),
|
|
4511
|
+
onChange: handleTimeChange,
|
|
4512
|
+
disabled,
|
|
4513
|
+
className: "bg-background h-8 appearance-none [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none"
|
|
4514
|
+
}
|
|
4515
|
+
)
|
|
4516
|
+
] })
|
|
4517
|
+
] })
|
|
4518
|
+
] })
|
|
4519
|
+
] });
|
|
4520
|
+
}
|
|
4236
4521
|
function LocaleProvider({
|
|
4237
4522
|
children,
|
|
4238
4523
|
language,
|
|
@@ -4241,7 +4526,7 @@ function LocaleProvider({
|
|
|
4241
4526
|
const [isReady, setIsReady] = React9.useState(false);
|
|
4242
4527
|
const instance = React9.useMemo(() => i18n__default.default.createInstance(), []);
|
|
4243
4528
|
React9.useEffect(() => {
|
|
4244
|
-
const baseTranslations =
|
|
4529
|
+
const baseTranslations = chunkH4O6RXFK_cjs.locales_exports[language] ?? {};
|
|
4245
4530
|
const mergedTranslations = overrides ? { ...baseTranslations, ...overrides } : baseTranslations;
|
|
4246
4531
|
instance.use(reactI18next.initReactI18next).init({
|
|
4247
4532
|
lng: language,
|
|
@@ -4270,7 +4555,7 @@ function TranslationProvider({
|
|
|
4270
4555
|
}) {
|
|
4271
4556
|
const [isReady, setIsReady] = React9.useState(false);
|
|
4272
4557
|
React9.useEffect(() => {
|
|
4273
|
-
for (const [lng, resources] of Object.entries(
|
|
4558
|
+
for (const [lng, resources] of Object.entries(chunkH4O6RXFK_cjs.locales_exports)) {
|
|
4274
4559
|
const language = lng;
|
|
4275
4560
|
const languageOverrides = overrides?.[language];
|
|
4276
4561
|
if (i18n2.hasResourceBundle(language, "ui") && !languageOverrides) {
|
|
@@ -4280,7 +4565,7 @@ function TranslationProvider({
|
|
|
4280
4565
|
i18n2.addResourceBundle(language, "ui", mergedResources, true, true);
|
|
4281
4566
|
}
|
|
4282
4567
|
if (overrides) {
|
|
4283
|
-
const supportedLanguages = Object.keys(
|
|
4568
|
+
const supportedLanguages = Object.keys(chunkH4O6RXFK_cjs.locales_exports);
|
|
4284
4569
|
for (const [lng, resources] of Object.entries(overrides)) {
|
|
4285
4570
|
if (supportedLanguages.includes(lng)) continue;
|
|
4286
4571
|
i18n2.addResourceBundle(lng, "ui", resources, true, true);
|
|
@@ -4425,6 +4710,7 @@ exports.ContextMenuSub = ContextMenuSub;
|
|
|
4425
4710
|
exports.ContextMenuSubContent = ContextMenuSubContent;
|
|
4426
4711
|
exports.ContextMenuSubTrigger = ContextMenuSubTrigger;
|
|
4427
4712
|
exports.ContextMenuTrigger = ContextMenuTrigger;
|
|
4713
|
+
exports.DateTimePicker = DateTimePicker;
|
|
4428
4714
|
exports.Dialog = Dialog;
|
|
4429
4715
|
exports.DialogClose = DialogClose;
|
|
4430
4716
|
exports.DialogContent = DialogContent;
|