dgz-ui-shared 1.2.20 → 1.2.22

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.
Files changed (52) hide show
  1. package/dist/chunks/DateRangePicker-CUv-qznZ.cjs.js +2 -0
  2. package/dist/chunks/DateRangePicker-CUv-qznZ.cjs.js.map +1 -0
  3. package/dist/chunks/{DateRangePicker-BEguo3VF.es.js → DateRangePicker-DeoV3xqL.es.js} +59 -59
  4. package/dist/chunks/DateRangePicker-DeoV3xqL.es.js.map +1 -0
  5. package/dist/chunks/MyInput-DOJNbPnV.cjs.js +2 -0
  6. package/dist/chunks/MyInput-DOJNbPnV.cjs.js.map +1 -0
  7. package/dist/chunks/MyInput-VyzguJnO.es.js +51 -0
  8. package/dist/chunks/MyInput-VyzguJnO.es.js.map +1 -0
  9. package/dist/chunks/MySelect-C7tnOKUF.cjs.js +2 -0
  10. package/dist/chunks/{MySelect-Ovb1pK5c.cjs.js.map → MySelect-C7tnOKUF.cjs.js.map} +1 -1
  11. package/dist/chunks/MySelect-DzvUAkVs.es.js +56 -0
  12. package/dist/chunks/MySelect-DzvUAkVs.es.js.map +1 -0
  13. package/dist/chunks/{PasswordConfirm-maMQqARK.cjs.js → PasswordConfirm-C8_4iAeF.cjs.js} +2 -2
  14. package/dist/chunks/{PasswordConfirm-maMQqARK.cjs.js.map → PasswordConfirm-C8_4iAeF.cjs.js.map} +1 -1
  15. package/dist/chunks/{PasswordConfirm-15FLlQ8Y.es.js → PasswordConfirm-CU25xH0G.es.js} +2 -2
  16. package/dist/chunks/{PasswordConfirm-15FLlQ8Y.es.js.map → PasswordConfirm-CU25xH0G.es.js.map} +1 -1
  17. package/dist/chunks/{Search-BDXQ3bSp.cjs.js → Search-6BG3dnM9.cjs.js} +2 -2
  18. package/dist/chunks/{Search-BDXQ3bSp.cjs.js.map → Search-6BG3dnM9.cjs.js.map} +1 -1
  19. package/dist/chunks/{Search-I3lwE0J6.es.js → Search-Y51oT-uZ.es.js} +3 -3
  20. package/dist/chunks/{Search-I3lwE0J6.es.js.map → Search-Y51oT-uZ.es.js.map} +1 -1
  21. package/dist/components/confirm/index.cjs.js +1 -1
  22. package/dist/components/confirm/index.es.js +1 -1
  23. package/dist/components/datatable/index.cjs.js +1 -1
  24. package/dist/components/datatable/index.es.js +1 -1
  25. package/dist/components/datepicker/index.cjs.js +1 -1
  26. package/dist/components/datepicker/index.es.js +1 -1
  27. package/dist/components/filters/index.cjs.js +1 -1
  28. package/dist/components/filters/index.es.js +1 -1
  29. package/dist/components/form/index.cjs.js +1 -1
  30. package/dist/components/form/index.cjs.js.map +1 -1
  31. package/dist/components/form/index.es.js +188 -187
  32. package/dist/components/form/index.es.js.map +1 -1
  33. package/dist/hooks/index.cjs.js +1 -1
  34. package/dist/hooks/index.cjs.js.map +1 -1
  35. package/dist/hooks/index.es.js +1 -1
  36. package/dist/hooks/index.es.js.map +1 -1
  37. package/dist/styles.css +1 -1
  38. package/dist/types/App.d.ts.map +1 -1
  39. package/dist/types/components/form/MyDatePicker.d.ts +1 -0
  40. package/dist/types/components/form/MyDatePicker.d.ts.map +1 -1
  41. package/dist/types/components/form/MyMaskInput.d.ts.map +1 -1
  42. package/package.json +7 -5
  43. package/dist/chunks/DateRangePicker-BEguo3VF.es.js.map +0 -1
  44. package/dist/chunks/DateRangePicker-lHqe5Mb6.cjs.js +0 -2
  45. package/dist/chunks/DateRangePicker-lHqe5Mb6.cjs.js.map +0 -1
  46. package/dist/chunks/MyInput-C9PNyYby.cjs.js +0 -2
  47. package/dist/chunks/MyInput-C9PNyYby.cjs.js.map +0 -1
  48. package/dist/chunks/MyInput-Wb0DSWo_.es.js +0 -51
  49. package/dist/chunks/MyInput-Wb0DSWo_.es.js.map +0 -1
  50. package/dist/chunks/MySelect-D8ML7nhM.es.js +0 -56
  51. package/dist/chunks/MySelect-D8ML7nhM.es.js.map +0 -1
  52. package/dist/chunks/MySelect-Ovb1pK5c.cjs.js +0 -2
@@ -0,0 +1,2 @@
1
+ "use strict";const e=require("react/jsx-runtime"),k=require("dgz-ui/button"),u=require("dgz-ui/calendar"),L=require("dgz-ui/form"),h=require("dgz-ui/popover"),a=require("dgz-ui/utils"),v=require("lucide-react"),c=require("react"),P=require("react-i18next"),w=({className:j,format:f=u.DATE,selected:s,timezone:y,onRangeSelected:i=()=>{},placeholder:O,disabled:l,error:T,inputProps:q,...b})=>{const{t:r}=P.useTranslation(),[N,D]=c.useState(!1),[t,m]=c.useState();c.useEffect(()=>{m(s)},[s]);const C=c.useMemo(()=>{const o=a.dayjs().endOf("day");return[{from:o.startOf("week").toDate(),to:o.endOf("week").toDate(),label:r("This week")},{from:o.startOf("month").toDate(),to:o.endOf("month").toDate(),label:r("This month")},{from:o.startOf("year").toDate(),to:o.endOf("year").toDate(),label:r("This year")},{from:o.subtract(7,"day").startOf("day").toDate(),to:o.toDate(),label:r("Last 7 days")},{from:o.subtract(30,"day").startOf("day").toDate(),to:o.toDate(),label:r("Last 30 days")},{from:o.subtract(3,"month").startOf("day").toDate(),to:o.toDate(),label:r("Last 3 months")},{from:o.subtract(6,"month").startOf("day").toDate(),to:o.toDate(),label:r("Last 6 months")},{from:o.subtract(12,"month").startOf("day").toDate(),to:o.toDate(),label:r("Last 12 months")}].map(n=>{var p,x;return{...n,isActive:((p=s==null?void 0:s.from)==null?void 0:p.getTime())===n.from.getTime()&&((x=s==null?void 0:s.to)==null?void 0:x.getTime())===n.to.getTime()}})},[r,s]),d=o=>{m(o),o!=null&&o.from&&(o!=null&&o.to)&&(i(o),D(!1))};return e.jsxs(h.Popover,{open:N,onOpenChange:D,children:[e.jsx(h.PopoverTrigger,{asChild:!0,className:"m-0!",disabled:l,children:e.jsxs("div",{className:"relative",children:[e.jsx(L.Input,{variant:T?"failure":"default",...q,readOnly:!0,value:t!=null&&t.from?t.to?`${a.dayjs(t.from).format(f)}-${a.dayjs(t.to).format(f)}`:a.dayjs(t.from).format(f):"",placeholder:O,disabled:l,className:a.cn(j)}),t&&e.jsx(v.XIcon,{onClick:()=>{m(void 0),i==null||i(void 0)},className:a.cn("text-secondary absolute top-3 right-8 size-4 cursor-pointer",l&&"pointer-events-none opacity-50")}),e.jsx(v.Calendar1,{className:a.cn("text-secondary absolute top-2.5 right-2 size-5",l&&"pointer-events-none opacity-50")})]})}),e.jsxs(h.PopoverContent,{className:"flex w-auto p-0",align:"end",side:"bottom",children:[e.jsx("div",{className:"border-border-alpha-light flex flex-col space-y-1 border-e p-2",children:C.map((o,n)=>e.jsx(k.Button,{size:"xs",variant:o.isActive?"default":"ghost",className:"justify-start",onClick:()=>d(o),children:o.label},n))}),e.jsx(u.Calendar,{...b,className:"border-border-alpha-light border-e",mode:"single",endMonth:t==null?void 0:t.to,selected:t==null?void 0:t.from,selectedToDate:t==null?void 0:t.to,selectedFromDate:t==null?void 0:t.from,timeZone:y,disabled:t!=null&&t.to?{after:t.to}:void 0,onSelect:o=>{m({...t,from:o})}}),e.jsx(u.Calendar,{...b,mode:"single",startMonth:t==null?void 0:t.from,selected:t==null?void 0:t.to,timeZone:y,disabled:t!=null&&t.from?{before:t.from}:void 0,selectedToDate:t==null?void 0:t.to,selectedFromDate:t==null?void 0:t.from,onSelect:o=>{t&&d({...t,to:o})}})]})]})};exports.DateRangePicker=w;
2
+ //# sourceMappingURL=DateRangePicker-CUv-qznZ.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateRangePicker-CUv-qznZ.cjs.js","sources":["../../src/components/datepicker/DateRangePicker.tsx"],"sourcesContent":["import { Button } from 'dgz-ui/button';\nimport { Calendar, type CalendarProps, DATE } from 'dgz-ui/calendar';\nimport { Input, type InputProps } from 'dgz-ui/form';\nimport { Popover, PopoverContent, PopoverTrigger } from 'dgz-ui/popover';\nimport { cn, dayjs } from 'dgz-ui/utils';\nimport { Calendar1, XIcon } from 'lucide-react';\nimport { type ReactNode, useEffect, useMemo, useState } from 'react';\nimport { type DateRange } from 'react-day-picker';\nimport { useTranslation } from 'react-i18next';\n\n/**\n * Props for the DateRangePicker component.\n */\nexport type DateRangePickerProps = Omit<\n CalendarProps,\n 'mode' | 'disabled' | 'selected'\n> & {\n /** The date format string (e.g., 'YYYY-MM-DD'). */\n format?: string;\n /** Placeholder text when no date is selected. */\n placeholder?: string;\n /** The currently selected date range. */\n selected?: DateRange;\n /** Timezone for date calculations. */\n timezone?: string;\n /** Error message to display (modifies styling). */\n error?: string;\n /** Callback function when a date range is selected. */\n onRangeSelected?: (value?: DateRange) => void;\n inputProps?: InputProps;\n disabled?: boolean;\n};\n\n/**\n * Type definition for a date range preset configuration.\n */\ntype PresetType = DateRange & {\n /** Label for the preset (e.g., \"Last 7 days\"). */\n label: ReactNode;\n isActive?: boolean;\n};\n\n/**\n * DateRangePicker displays a two-month range picker with helpful presets.\n *\n * @param props.format - Display date format.\n * @param props.selected - Currently selected date range.\n * @param props.timezone - Time zone for date calculations.\n * @param props.onRangeSelected - Callback when a full range is selected.\n * @param props.placeholder - Placeholder when no date selected.\n * @param props.error - Optional error message that adjusts styling.\n * @param props.inputProps - Props passed to the underlying Input component.\n * @param props.disabled - Whether the date range picker is disabled.\n * @returns A date range picker component.\n */\nexport const DateRangePicker = ({\n className,\n format = DATE,\n selected,\n timezone,\n onRangeSelected = () => {},\n placeholder,\n disabled,\n error,\n inputProps,\n ...props\n}: DateRangePickerProps) => {\n const { t } = useTranslation();\n const [open, setOpen] = useState(false);\n const [date, setDate] = useState<DateRange | undefined>();\n\n useEffect(() => {\n setDate(selected);\n }, [selected]);\n\n const presets: PresetType[] = useMemo(() => {\n const today = dayjs().endOf('day');\n return [\n {\n from: today.startOf('week').toDate(),\n to: today.endOf('week').toDate(),\n label: t('This week'),\n },\n {\n from: today.startOf('month').toDate(),\n to: today.endOf('month').toDate(),\n label: t('This month'),\n },\n {\n from: today.startOf('year').toDate(),\n to: today.endOf('year').toDate(),\n label: t('This year'),\n },\n {\n from: today.subtract(7, 'day').startOf('day').toDate(),\n to: today.toDate(),\n label: t('Last 7 days'),\n },\n {\n from: today.subtract(30, 'day').startOf('day').toDate(),\n to: today.toDate(),\n label: t('Last 30 days'),\n },\n {\n from: today.subtract(3, 'month').startOf('day').toDate(),\n to: today.toDate(),\n label: t('Last 3 months'),\n },\n {\n from: today.subtract(6, 'month').startOf('day').toDate(),\n to: today.toDate(),\n label: t('Last 6 months'),\n },\n {\n from: today.subtract(12, 'month').startOf('day').toDate(),\n to: today.toDate(),\n label: t('Last 12 months'),\n },\n ].map((item) => ({\n ...item,\n isActive:\n selected?.from?.getTime() === item.from.getTime() &&\n selected?.to?.getTime() === item.to.getTime(),\n }));\n }, [t, selected]);\n\n const handleRangeSelect = (range: DateRange) => {\n setDate(range);\n if (range?.from && range?.to) {\n onRangeSelected(range);\n setOpen(false);\n }\n };\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild className={'m-0!'} disabled={disabled}>\n <div className={'relative'}>\n <Input\n variant={error ? 'failure' : 'default'}\n {...inputProps}\n readOnly\n value={\n date?.from\n ? date.to\n ? `${dayjs(date.from).format(format)}-${dayjs(date.to).format(format)}`\n : dayjs(date.from).format(format)\n : ''\n }\n placeholder={placeholder}\n disabled={disabled}\n className={cn(className)}\n />\n {date && (\n <XIcon\n onClick={() => {\n setDate(undefined);\n onRangeSelected?.(undefined);\n }}\n className={cn(\n 'text-secondary absolute top-3 right-8 size-4 cursor-pointer',\n disabled && 'pointer-events-none opacity-50'\n )}\n />\n )}\n <Calendar1\n className={cn(\n 'text-secondary absolute top-2.5 right-2 size-5',\n disabled && 'pointer-events-none opacity-50'\n )}\n />\n </div>\n </PopoverTrigger>\n <PopoverContent className=\"flex w-auto p-0\" align=\"end\" side={'bottom'}>\n <div\n className={\n 'border-border-alpha-light flex flex-col space-y-1 border-e p-2'\n }\n >\n {presets.map((preset, index) => (\n <Button\n size={'xs'}\n key={index}\n variant={preset.isActive ? 'default' : 'ghost'}\n className={'justify-start'}\n onClick={() => handleRangeSelect(preset)}\n >\n {preset.label}\n </Button>\n ))}\n </div>\n <Calendar\n {...props}\n className={'border-border-alpha-light border-e'}\n mode=\"single\"\n endMonth={date?.to}\n selected={date?.from}\n selectedToDate={date?.to}\n selectedFromDate={date?.from}\n timeZone={timezone}\n disabled={\n date?.to\n ? {\n after: date.to,\n }\n : undefined\n }\n onSelect={(from) => {\n setDate({ ...date, from: from as Date | undefined });\n }}\n />\n <Calendar\n {...props}\n mode=\"single\"\n startMonth={date?.from}\n selected={date?.to}\n timeZone={timezone}\n disabled={\n date?.from\n ? {\n before: date.from,\n }\n : undefined\n }\n selectedToDate={date?.to}\n selectedFromDate={date?.from}\n onSelect={(to) => {\n if (date) {\n handleRangeSelect({ ...date, to: to as Date | undefined });\n }\n }}\n />\n </PopoverContent>\n </Popover>\n );\n};\n"],"names":["DateRangePicker","className","format","DATE","selected","timezone","onRangeSelected","placeholder","disabled","error","inputProps","props","t","useTranslation","open","setOpen","useState","date","setDate","useEffect","presets","useMemo","today","dayjs","item","_a","_b","handleRangeSelect","range","jsxs","Popover","jsx","PopoverTrigger","Input","cn","XIcon","Calendar1","PopoverContent","preset","index","Button","Calendar","from","to"],"mappings":"iQAuDaA,EAAkB,CAAC,CAC9B,UAAAC,EACA,OAAAC,EAASC,EAAAA,KACT,SAAAC,EACA,SAAAC,EACA,gBAAAC,EAAkB,IAAM,CAAC,EACzB,YAAAC,EACA,SAAAC,EACA,MAAAC,EACA,WAAAC,EACA,GAAGC,CACL,IAA4B,CAC1B,KAAM,CAAA,EAAEC,CAAA,EAAMC,iBAAA,EACR,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAS,EAAK,EAChC,CAACC,EAAMC,CAAO,EAAIF,WAAA,EAExBG,EAAAA,UAAU,IAAM,CACdD,EAAQd,CAAQ,CAClB,EAAG,CAACA,CAAQ,CAAC,EAEb,MAAMgB,EAAwBC,EAAAA,QAAQ,IAAM,CAC1C,MAAMC,EAAQC,EAAAA,QAAQ,MAAM,KAAK,EACjC,MAAO,CACL,CACE,KAAMD,EAAM,QAAQ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,KAAM,KAEN,QAASF,EAAO,SAAW,UAAY,QACvC,UAAW,gBACX,QAAS,IAAMX,EAAkBW,CAAM,EAEtC,SAAAA,EAAO,KAAA,EALHC,CAAA,CAOR,CAAA,CAAA,EAEHR,EAAAA,IAACU,EAAAA,SAAA,CACE,GAAG9B,EACJ,UAAW,qCACX,KAAK,SACL,SAAUM,GAAA,YAAAA,EAAM,GAChB,SAAUA,GAAA,YAAAA,EAAM,KAChB,eAAgBA,GAAA,YAAAA,EAAM,GACtB,iBAAkBA,GAAA,YAAAA,EAAM,KACxB,SAAUZ,EACV,SACEY,GAAA,MAAAA,EAAM,GACF,CACE,MAAOA,EAAK,EAAA,EAEd,OAEN,SAAWyB,GAAS,CAClBxB,EAAQ,CAAE,GAAGD,EAAM,KAAAyB,EAAgC,CACrD,CAAA,CAAA,EAEFX,EAAAA,IAACU,EAAAA,SAAA,CACE,GAAG9B,EACJ,KAAK,SACL,WAAYM,GAAA,YAAAA,EAAM,KAClB,SAAUA,GAAA,YAAAA,EAAM,GAChB,SAAUZ,EACV,SACEY,GAAA,MAAAA,EAAM,KACF,CACE,OAAQA,EAAK,IAAA,EAEf,OAEN,eAAgBA,GAAA,YAAAA,EAAM,GACtB,iBAAkBA,GAAA,YAAAA,EAAM,KACxB,SAAW0B,GAAO,CACZ1B,GACFU,EAAkB,CAAE,GAAGV,EAAM,GAAA0B,EAA4B,CAE7D,CAAA,CAAA,CACF,CAAA,CACF,CAAA,EACF,CAEJ"}
@@ -1,31 +1,31 @@
1
- import { jsxs as n, jsx as s } from "react/jsx-runtime";
2
- import { Button as k } from "dgz-ui/button";
3
- import { DATE as L, Calendar as d } from "dgz-ui/calendar";
4
- import { Input as w } from "dgz-ui/form";
5
- import { Popover as P, PopoverTrigger as A, PopoverContent as M } from "dgz-ui/popover";
6
- import { cn as c } from "dgz-ui/utils";
7
- import { XIcon as z, Calendar1 as E } from "lucide-react";
8
- import { useState as v, useEffect as F, useMemo as I } from "react";
9
- import { useTranslation as Z } from "react-i18next";
10
- const Q = ({
11
- className: O,
12
- format: l = L,
1
+ import { jsxs as c, jsx as e } from "react/jsx-runtime";
2
+ import { Button as j } from "dgz-ui/button";
3
+ import { DATE as w, Calendar as O } from "dgz-ui/calendar";
4
+ import { Input as P } from "dgz-ui/form";
5
+ import { Popover as A, PopoverTrigger as M, PopoverContent as z } from "dgz-ui/popover";
6
+ import { dayjs as l, cn as h } from "dgz-ui/utils";
7
+ import { XIcon as E, Calendar1 as F } from "lucide-react";
8
+ import { useState as d, useEffect as I, useMemo as Z } from "react";
9
+ import { useTranslation as $ } from "react-i18next";
10
+ const U = ({
11
+ className: T,
12
+ format: n = w,
13
13
  selected: r,
14
- timezone: h,
14
+ timezone: p,
15
15
  onRangeSelected: m = () => {
16
16
  },
17
- placeholder: T,
17
+ placeholder: x,
18
18
  disabled: i,
19
- error: x,
20
- inputProps: N,
21
- ...p
19
+ error: N,
20
+ inputProps: C,
21
+ ...u
22
22
  }) => {
23
- const { t: a } = Z(), [j, y] = v(!1), [t, f] = v();
24
- F(() => {
23
+ const { t: a } = $(), [k, D] = d(!1), [t, f] = d();
24
+ I(() => {
25
25
  f(r);
26
26
  }, [r]);
27
- const C = I(() => {
28
- const o = dayjs().endOf("day");
27
+ const L = Z(() => {
28
+ const o = l().endOf("day");
29
29
  return [
30
30
  {
31
31
  from: o.startOf("week").toDate(),
@@ -67,81 +67,81 @@ const Q = ({
67
67
  to: o.toDate(),
68
68
  label: a("Last 12 months")
69
69
  }
70
- ].map((e) => {
71
- var D, b;
70
+ ].map((s) => {
71
+ var y, v;
72
72
  return {
73
- ...e,
74
- isActive: ((D = r == null ? void 0 : r.from) == null ? void 0 : D.getTime()) === e.from.getTime() && ((b = r == null ? void 0 : r.to) == null ? void 0 : b.getTime()) === e.to.getTime()
73
+ ...s,
74
+ isActive: ((y = r == null ? void 0 : r.from) == null ? void 0 : y.getTime()) === s.from.getTime() && ((v = r == null ? void 0 : r.to) == null ? void 0 : v.getTime()) === s.to.getTime()
75
75
  };
76
76
  });
77
- }, [a, r]), u = (o) => {
78
- f(o), o != null && o.from && (o != null && o.to) && (m(o), y(!1));
77
+ }, [a, r]), b = (o) => {
78
+ f(o), o != null && o.from && (o != null && o.to) && (m(o), D(!1));
79
79
  };
80
- return /* @__PURE__ */ n(P, { open: j, onOpenChange: y, children: [
81
- /* @__PURE__ */ s(A, { asChild: !0, className: "m-0!", disabled: i, children: /* @__PURE__ */ n("div", { className: "relative", children: [
82
- /* @__PURE__ */ s(
83
- w,
80
+ return /* @__PURE__ */ c(A, { open: k, onOpenChange: D, children: [
81
+ /* @__PURE__ */ e(M, { asChild: !0, className: "m-0!", disabled: i, children: /* @__PURE__ */ c("div", { className: "relative", children: [
82
+ /* @__PURE__ */ e(
83
+ P,
84
84
  {
85
- variant: x ? "failure" : "default",
86
- ...N,
85
+ variant: N ? "failure" : "default",
86
+ ...C,
87
87
  readOnly: !0,
88
- value: t != null && t.from ? t.to ? `${dayjs(t.from).format(l)}-${dayjs(t.to).format(l)}` : dayjs(t.from).format(l) : "",
89
- placeholder: T,
88
+ value: t != null && t.from ? t.to ? `${l(t.from).format(n)}-${l(t.to).format(n)}` : l(t.from).format(n) : "",
89
+ placeholder: x,
90
90
  disabled: i,
91
- className: c(O)
91
+ className: h(T)
92
92
  }
93
93
  ),
94
- t && /* @__PURE__ */ s(
95
- z,
94
+ t && /* @__PURE__ */ e(
95
+ E,
96
96
  {
97
97
  onClick: () => {
98
98
  f(void 0), m == null || m(void 0);
99
99
  },
100
- className: c(
100
+ className: h(
101
101
  "text-secondary absolute top-3 right-8 size-4 cursor-pointer",
102
102
  i && "pointer-events-none opacity-50"
103
103
  )
104
104
  }
105
105
  ),
106
- /* @__PURE__ */ s(
107
- E,
106
+ /* @__PURE__ */ e(
107
+ F,
108
108
  {
109
- className: c(
109
+ className: h(
110
110
  "text-secondary absolute top-2.5 right-2 size-5",
111
111
  i && "pointer-events-none opacity-50"
112
112
  )
113
113
  }
114
114
  )
115
115
  ] }) }),
116
- /* @__PURE__ */ n(M, { className: "flex w-auto p-0", align: "end", side: "bottom", children: [
117
- /* @__PURE__ */ s(
116
+ /* @__PURE__ */ c(z, { className: "flex w-auto p-0", align: "end", side: "bottom", children: [
117
+ /* @__PURE__ */ e(
118
118
  "div",
119
119
  {
120
120
  className: "border-border-alpha-light flex flex-col space-y-1 border-e p-2",
121
- children: C.map((o, e) => /* @__PURE__ */ s(
122
- k,
121
+ children: L.map((o, s) => /* @__PURE__ */ e(
122
+ j,
123
123
  {
124
124
  size: "xs",
125
125
  variant: o.isActive ? "default" : "ghost",
126
126
  className: "justify-start",
127
- onClick: () => u(o),
127
+ onClick: () => b(o),
128
128
  children: o.label
129
129
  },
130
- e
130
+ s
131
131
  ))
132
132
  }
133
133
  ),
134
- /* @__PURE__ */ s(
135
- d,
134
+ /* @__PURE__ */ e(
135
+ O,
136
136
  {
137
- ...p,
137
+ ...u,
138
138
  className: "border-border-alpha-light border-e",
139
139
  mode: "single",
140
140
  endMonth: t == null ? void 0 : t.to,
141
141
  selected: t == null ? void 0 : t.from,
142
142
  selectedToDate: t == null ? void 0 : t.to,
143
143
  selectedFromDate: t == null ? void 0 : t.from,
144
- timeZone: h,
144
+ timeZone: p,
145
145
  disabled: t != null && t.to ? {
146
146
  after: t.to
147
147
  } : void 0,
@@ -150,21 +150,21 @@ const Q = ({
150
150
  }
151
151
  }
152
152
  ),
153
- /* @__PURE__ */ s(
154
- d,
153
+ /* @__PURE__ */ e(
154
+ O,
155
155
  {
156
- ...p,
156
+ ...u,
157
157
  mode: "single",
158
158
  startMonth: t == null ? void 0 : t.from,
159
159
  selected: t == null ? void 0 : t.to,
160
- timeZone: h,
160
+ timeZone: p,
161
161
  disabled: t != null && t.from ? {
162
162
  before: t.from
163
163
  } : void 0,
164
164
  selectedToDate: t == null ? void 0 : t.to,
165
165
  selectedFromDate: t == null ? void 0 : t.from,
166
166
  onSelect: (o) => {
167
- t && u({ ...t, to: o });
167
+ t && b({ ...t, to: o });
168
168
  }
169
169
  }
170
170
  )
@@ -172,6 +172,6 @@ const Q = ({
172
172
  ] });
173
173
  };
174
174
  export {
175
- Q as D
175
+ U as D
176
176
  };
177
- //# sourceMappingURL=DateRangePicker-BEguo3VF.es.js.map
177
+ //# sourceMappingURL=DateRangePicker-DeoV3xqL.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateRangePicker-DeoV3xqL.es.js","sources":["../../src/components/datepicker/DateRangePicker.tsx"],"sourcesContent":["import { Button } from 'dgz-ui/button';\nimport { Calendar, type CalendarProps, DATE } from 'dgz-ui/calendar';\nimport { Input, type InputProps } from 'dgz-ui/form';\nimport { Popover, PopoverContent, PopoverTrigger } from 'dgz-ui/popover';\nimport { cn, dayjs } from 'dgz-ui/utils';\nimport { Calendar1, XIcon } from 'lucide-react';\nimport { type ReactNode, useEffect, useMemo, useState } from 'react';\nimport { type DateRange } from 'react-day-picker';\nimport { useTranslation } from 'react-i18next';\n\n/**\n * Props for the DateRangePicker component.\n */\nexport type DateRangePickerProps = Omit<\n CalendarProps,\n 'mode' | 'disabled' | 'selected'\n> & {\n /** The date format string (e.g., 'YYYY-MM-DD'). */\n format?: string;\n /** Placeholder text when no date is selected. */\n placeholder?: string;\n /** The currently selected date range. */\n selected?: DateRange;\n /** Timezone for date calculations. */\n timezone?: string;\n /** Error message to display (modifies styling). */\n error?: string;\n /** Callback function when a date range is selected. */\n onRangeSelected?: (value?: DateRange) => void;\n inputProps?: InputProps;\n disabled?: boolean;\n};\n\n/**\n * Type definition for a date range preset configuration.\n */\ntype PresetType = DateRange & {\n /** Label for the preset (e.g., \"Last 7 days\"). */\n label: ReactNode;\n isActive?: boolean;\n};\n\n/**\n * DateRangePicker displays a two-month range picker with helpful presets.\n *\n * @param props.format - Display date format.\n * @param props.selected - Currently selected date range.\n * @param props.timezone - Time zone for date calculations.\n * @param props.onRangeSelected - Callback when a full range is selected.\n * @param props.placeholder - Placeholder when no date selected.\n * @param props.error - Optional error message that adjusts styling.\n * @param props.inputProps - Props passed to the underlying Input component.\n * @param props.disabled - Whether the date range picker is disabled.\n * @returns A date range picker component.\n */\nexport const DateRangePicker = ({\n className,\n format = DATE,\n selected,\n timezone,\n onRangeSelected = () => {},\n placeholder,\n disabled,\n error,\n inputProps,\n ...props\n}: DateRangePickerProps) => {\n const { t } = useTranslation();\n const [open, setOpen] = useState(false);\n const [date, setDate] = useState<DateRange | undefined>();\n\n useEffect(() => {\n setDate(selected);\n }, [selected]);\n\n const presets: PresetType[] = useMemo(() => {\n const today = dayjs().endOf('day');\n return [\n {\n from: today.startOf('week').toDate(),\n to: today.endOf('week').toDate(),\n label: t('This week'),\n },\n {\n from: today.startOf('month').toDate(),\n to: today.endOf('month').toDate(),\n label: t('This month'),\n },\n {\n from: today.startOf('year').toDate(),\n to: today.endOf('year').toDate(),\n label: t('This year'),\n },\n {\n from: today.subtract(7, 'day').startOf('day').toDate(),\n to: today.toDate(),\n label: t('Last 7 days'),\n },\n {\n from: today.subtract(30, 'day').startOf('day').toDate(),\n to: today.toDate(),\n label: t('Last 30 days'),\n },\n {\n from: today.subtract(3, 'month').startOf('day').toDate(),\n to: today.toDate(),\n label: t('Last 3 months'),\n },\n {\n from: today.subtract(6, 'month').startOf('day').toDate(),\n to: today.toDate(),\n label: t('Last 6 months'),\n },\n {\n from: today.subtract(12, 'month').startOf('day').toDate(),\n to: today.toDate(),\n label: t('Last 12 months'),\n },\n ].map((item) => ({\n ...item,\n isActive:\n selected?.from?.getTime() === item.from.getTime() &&\n selected?.to?.getTime() === item.to.getTime(),\n }));\n }, [t, selected]);\n\n const handleRangeSelect = (range: DateRange) => {\n setDate(range);\n if (range?.from && range?.to) {\n onRangeSelected(range);\n setOpen(false);\n }\n };\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild className={'m-0!'} disabled={disabled}>\n <div className={'relative'}>\n <Input\n variant={error ? 'failure' : 'default'}\n {...inputProps}\n readOnly\n value={\n date?.from\n ? date.to\n ? `${dayjs(date.from).format(format)}-${dayjs(date.to).format(format)}`\n : dayjs(date.from).format(format)\n : ''\n }\n placeholder={placeholder}\n disabled={disabled}\n className={cn(className)}\n />\n {date && (\n <XIcon\n onClick={() => {\n setDate(undefined);\n onRangeSelected?.(undefined);\n }}\n className={cn(\n 'text-secondary absolute top-3 right-8 size-4 cursor-pointer',\n disabled && 'pointer-events-none opacity-50'\n )}\n />\n )}\n <Calendar1\n className={cn(\n 'text-secondary absolute top-2.5 right-2 size-5',\n disabled && 'pointer-events-none opacity-50'\n )}\n />\n </div>\n </PopoverTrigger>\n <PopoverContent className=\"flex w-auto p-0\" align=\"end\" side={'bottom'}>\n <div\n className={\n 'border-border-alpha-light flex flex-col space-y-1 border-e p-2'\n }\n >\n {presets.map((preset, index) => (\n <Button\n size={'xs'}\n key={index}\n variant={preset.isActive ? 'default' : 'ghost'}\n className={'justify-start'}\n onClick={() => handleRangeSelect(preset)}\n >\n {preset.label}\n </Button>\n ))}\n </div>\n <Calendar\n {...props}\n className={'border-border-alpha-light border-e'}\n mode=\"single\"\n endMonth={date?.to}\n selected={date?.from}\n selectedToDate={date?.to}\n selectedFromDate={date?.from}\n timeZone={timezone}\n disabled={\n date?.to\n ? {\n after: date.to,\n }\n : undefined\n }\n onSelect={(from) => {\n setDate({ ...date, from: from as Date | undefined });\n }}\n />\n <Calendar\n {...props}\n mode=\"single\"\n startMonth={date?.from}\n selected={date?.to}\n timeZone={timezone}\n disabled={\n date?.from\n ? {\n before: date.from,\n }\n : undefined\n }\n selectedToDate={date?.to}\n selectedFromDate={date?.from}\n onSelect={(to) => {\n if (date) {\n handleRangeSelect({ ...date, to: to as Date | undefined });\n }\n }}\n />\n </PopoverContent>\n </Popover>\n );\n};\n"],"names":["DateRangePicker","className","format","DATE","selected","timezone","onRangeSelected","placeholder","disabled","error","inputProps","props","t","useTranslation","open","setOpen","useState","date","setDate","useEffect","presets","useMemo","today","dayjs","item","_a","_b","handleRangeSelect","range","jsxs","Popover","jsx","PopoverTrigger","Input","cn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.js"),g=({control:o,name:r,label:a,required:c,className:i,rules:m,floatingError:x,...u})=>r&&o&&e.jsx(s.FormField,{control:o,name:r,rules:m,render:({field:t,formState:d})=>e.jsxs(s.FormItem,{children:[a&&e.jsxs(s.FormLabel,{className:"block",children:[a," ",c&&e.jsx("span",{className:"text-red-600",children:"*"})]}),e.jsx(s.FormControl,{children:e.jsx(s.Input,{variant:j.lodashExports.get(d.errors,`${r}.message`)?"failure":"default",...u,...t,onChange:h=>{const n=h.target.value;u.type==="number"?t.onChange(n?Number(n):void 0):t.onChange(n)},className:l.cn(i)})}),e.jsx(s.FormMessage,{className:l.cn(x&&"absolute -bottom-5")})]})})||null;exports.MyInput=g;
2
+ //# sourceMappingURL=MyInput-DOJNbPnV.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MyInput-DOJNbPnV.cjs.js","sources":["../../src/components/form/MyInput.tsx"],"sourcesContent":["import {\n FormControl,\n FormField,\n FormItem,\n type FormItemProps,\n FormLabel,\n FormMessage,\n Input,\n type InputProps,\n} from 'dgz-ui/form';\nimport { cn } from 'dgz-ui/utils';\nimport { get } from 'lodash';\nimport type { FieldPath, FieldValues } from 'react-hook-form';\n\n/**\n * Props for the MyInput component.\n * @template TFieldValues - The type of the form values.\n */\nexport type MyInputProps<TFieldValues extends FieldValues> =\n FormItemProps<TFieldValues> & InputProps;\n\n/**\n * MyInput is a form-aware input field that integrates with react-hook-form.\n * Works in both controlled (with control/name) and uncontrolled modes.\n *\n * @template TFieldValues - Form values type used by react-hook-form.\n * @param control - The `react-hook-form` control object.\n * @param name - The name of the field in `react-hook-form`.\n * @param label - The label to display for the input.\n * @param required - Whether the field is required.\n * @param className - Custom CSS class name.\n * @param rules - The `react-hook-form` validation rules.\n * @param floatingError - Whether to show the error message in a floating container.\n * @param props - Input and form item props.\n */\nexport const MyInput = <TFieldValues extends FieldValues>({\n control,\n name,\n label,\n required,\n className,\n rules,\n floatingError,\n ...props\n}: MyInputProps<TFieldValues>) => {\n return (\n (name && control && (\n <FormField<TFieldValues, FieldPath<TFieldValues>>\n control={control}\n name={name}\n rules={rules}\n render={({ field, formState }) => (\n <FormItem>\n {label && (\n <FormLabel className={'block'}>\n {label} {required && <span className={'text-red-600'}>*</span>}\n </FormLabel>\n )}\n <FormControl>\n <Input\n variant={\n get(formState.errors, `${name}.message`)\n ? 'failure'\n : 'default'\n }\n {...props}\n {...field}\n onChange={(event) => {\n const value = event.target.value;\n if (props.type === 'number') {\n field.onChange(value ? Number(value) : undefined);\n } else {\n field.onChange(value);\n }\n }}\n className={cn(className)}\n />\n </FormControl>\n <FormMessage\n className={cn(floatingError && 'absolute -bottom-5')}\n />\n </FormItem>\n )}\n />\n )) ||\n null\n );\n};\n"],"names":["MyInput","control","name","label","required","className","rules","floatingError","props","jsx","FormField","field","formState","FormItem","jsxs","FormLabel","FormControl","Input","get","event","value","cn","FormMessage"],"mappings":"2IAmCaA,EAAU,CAAmC,CACxD,QAAAC,EACA,KAAAC,EACA,MAAAC,EACA,SAAAC,EACA,UAAAC,EACA,MAAAC,EACA,cAAAC,EACA,GAAGC,CACL,IAEKN,GAAQD,GACPQ,EAAAA,IAACC,EAAAA,UAAA,CACC,QAAAT,EACA,KAAAC,EACA,MAAAI,EACA,OAAQ,CAAC,CAAE,MAAAK,EAAO,UAAAC,CAAA,WACfC,EAAAA,SAAA,CACE,SAAA,CAAAV,GACCW,EAAAA,KAACC,EAAAA,UAAA,CAAU,UAAW,QACnB,SAAA,CAAAZ,EAAM,IAAEC,GAAYK,EAAAA,IAAC,OAAA,CAAK,UAAW,eAAgB,SAAA,GAAA,CAAC,CAAA,EACzD,QAEDO,EAAAA,YAAA,CACC,SAAAP,EAAAA,IAACQ,EAAAA,MAAA,CACC,QACEC,EAAAA,cAAAA,IAAIN,EAAU,OAAQ,GAAGV,CAAI,UAAU,EACnC,UACA,UAEL,GAAGM,EACH,GAAGG,EACJ,SAAWQ,GAAU,CACnB,MAAMC,EAAQD,EAAM,OAAO,MACvBX,EAAM,OAAS,SACjBG,EAAM,SAASS,EAAQ,OAAOA,CAAK,EAAI,MAAS,EAEhDT,EAAM,SAASS,CAAK,CAExB,EACA,UAAWC,EAAAA,GAAGhB,CAAS,CAAA,CAAA,EAE3B,EACAI,EAAAA,IAACa,EAAAA,YAAA,CACC,UAAWD,EAAAA,GAAGd,GAAiB,oBAAoB,CAAA,CAAA,CACrD,CAAA,CACF,CAAA,CAAA,GAIN"}
@@ -0,0 +1,51 @@
1
+ import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
+ import { FormField as g, FormItem as F, FormLabel as b, FormControl as f, Input as x, FormMessage as N } from "dgz-ui/form";
3
+ import { cn as l } from "dgz-ui/utils";
4
+ import { l as v } from "./lodash-CRDOWzbs.es.js";
5
+ const y = ({
6
+ control: a,
7
+ name: r,
8
+ label: t,
9
+ required: c,
10
+ className: i,
11
+ rules: u,
12
+ floatingError: d,
13
+ ...m
14
+ }) => r && a && /* @__PURE__ */ e(
15
+ g,
16
+ {
17
+ control: a,
18
+ name: r,
19
+ rules: u,
20
+ render: ({ field: o, formState: h }) => /* @__PURE__ */ n(F, { children: [
21
+ t && /* @__PURE__ */ n(b, { className: "block", children: [
22
+ t,
23
+ " ",
24
+ c && /* @__PURE__ */ e("span", { className: "text-red-600", children: "*" })
25
+ ] }),
26
+ /* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(
27
+ x,
28
+ {
29
+ variant: v.get(h.errors, `${r}.message`) ? "failure" : "default",
30
+ ...m,
31
+ ...o,
32
+ onChange: (p) => {
33
+ const s = p.target.value;
34
+ m.type === "number" ? o.onChange(s ? Number(s) : void 0) : o.onChange(s);
35
+ },
36
+ className: l(i)
37
+ }
38
+ ) }),
39
+ /* @__PURE__ */ e(
40
+ N,
41
+ {
42
+ className: l(d && "absolute -bottom-5")
43
+ }
44
+ )
45
+ ] })
46
+ }
47
+ ) || null;
48
+ export {
49
+ y as M
50
+ };
51
+ //# sourceMappingURL=MyInput-VyzguJnO.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MyInput-VyzguJnO.es.js","sources":["../../src/components/form/MyInput.tsx"],"sourcesContent":["import {\n FormControl,\n FormField,\n FormItem,\n type FormItemProps,\n FormLabel,\n FormMessage,\n Input,\n type InputProps,\n} from 'dgz-ui/form';\nimport { cn } from 'dgz-ui/utils';\nimport { get } from 'lodash';\nimport type { FieldPath, FieldValues } from 'react-hook-form';\n\n/**\n * Props for the MyInput component.\n * @template TFieldValues - The type of the form values.\n */\nexport type MyInputProps<TFieldValues extends FieldValues> =\n FormItemProps<TFieldValues> & InputProps;\n\n/**\n * MyInput is a form-aware input field that integrates with react-hook-form.\n * Works in both controlled (with control/name) and uncontrolled modes.\n *\n * @template TFieldValues - Form values type used by react-hook-form.\n * @param control - The `react-hook-form` control object.\n * @param name - The name of the field in `react-hook-form`.\n * @param label - The label to display for the input.\n * @param required - Whether the field is required.\n * @param className - Custom CSS class name.\n * @param rules - The `react-hook-form` validation rules.\n * @param floatingError - Whether to show the error message in a floating container.\n * @param props - Input and form item props.\n */\nexport const MyInput = <TFieldValues extends FieldValues>({\n control,\n name,\n label,\n required,\n className,\n rules,\n floatingError,\n ...props\n}: MyInputProps<TFieldValues>) => {\n return (\n (name && control && (\n <FormField<TFieldValues, FieldPath<TFieldValues>>\n control={control}\n name={name}\n rules={rules}\n render={({ field, formState }) => (\n <FormItem>\n {label && (\n <FormLabel className={'block'}>\n {label} {required && <span className={'text-red-600'}>*</span>}\n </FormLabel>\n )}\n <FormControl>\n <Input\n variant={\n get(formState.errors, `${name}.message`)\n ? 'failure'\n : 'default'\n }\n {...props}\n {...field}\n onChange={(event) => {\n const value = event.target.value;\n if (props.type === 'number') {\n field.onChange(value ? Number(value) : undefined);\n } else {\n field.onChange(value);\n }\n }}\n className={cn(className)}\n />\n </FormControl>\n <FormMessage\n className={cn(floatingError && 'absolute -bottom-5')}\n />\n </FormItem>\n )}\n />\n )) ||\n null\n );\n};\n"],"names":["MyInput","control","name","label","required","className","rules","floatingError","props","jsx","FormField","field","formState","FormItem","jsxs","FormLabel","FormControl","Input","get","event","value","cn","FormMessage"],"mappings":";;;;AAmCO,MAAMA,IAAU,CAAmC;AAAA,EACxD,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,eAAAC;AAAA,EACA,GAAGC;AACL,MAEKN,KAAQD,KACP,gBAAAQ;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,SAAAT;AAAA,IACA,MAAAC;AAAA,IACA,OAAAI;AAAA,IACA,QAAQ,CAAC,EAAE,OAAAK,GAAO,WAAAC,EAAA,wBACfC,GAAA,EACE,UAAA;AAAA,MAAAV,KACC,gBAAAW,EAACC,GAAA,EAAU,WAAW,SACnB,UAAA;AAAA,QAAAZ;AAAA,QAAM;AAAA,QAAEC,KAAY,gBAAAK,EAAC,QAAA,EAAK,WAAW,gBAAgB,UAAA,IAAA,CAAC;AAAA,MAAA,GACzD;AAAA,wBAEDO,GAAA,EACC,UAAA,gBAAAP;AAAA,QAACQ;AAAA,QAAA;AAAA,UACC,SACEC,EAAAA,IAAIN,EAAU,QAAQ,GAAGV,CAAI,UAAU,IACnC,YACA;AAAA,UAEL,GAAGM;AAAA,UACH,GAAGG;AAAA,UACJ,UAAU,CAACQ,MAAU;AACnB,kBAAMC,IAAQD,EAAM,OAAO;AAC3B,YAAIX,EAAM,SAAS,WACjBG,EAAM,SAASS,IAAQ,OAAOA,CAAK,IAAI,MAAS,IAEhDT,EAAM,SAASS,CAAK;AAAA,UAExB;AAAA,UACA,WAAWC,EAAGhB,CAAS;AAAA,QAAA;AAAA,MAAA,GAE3B;AAAA,MACA,gBAAAI;AAAA,QAACa;AAAA,QAAA;AAAA,UACC,WAAWD,EAAGd,KAAiB,oBAAoB;AAAA,QAAA;AAAA,MAAA;AAAA,IACrD,EAAA,CACF;AAAA,EAAA;AAAA,KAIN;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const e=require("react/jsx-runtime"),s=require("dgz-ui/form"),a=require("dgz-ui/utils"),g=require("./lodash-BjH0kD7j.cjs.js"),q=({control:t,name:r,label:o,required:i,className:m,rules:u,options:x=[],onChange:c,floatingError:d,...h})=>r&&t&&e.jsx(s.FormField,{control:t,name:r,rules:u,render:({field:n,formState:j})=>{const F=l=>{n.onChange(l),c&&c(l)};return e.jsxs(s.FormItem,{children:[o&&e.jsxs(s.FormLabel,{className:"block",children:[o," ",i&&e.jsx("span",{className:"text-red-600",children:"*"})]}),e.jsx(s.FormControl,{children:e.jsx(s.ReactSelect,{className:a.cn(m),...h,...n,onChange:F,options:x,error:!!g.lodashExports.get(j.errors,`${r}`)})}),e.jsx(s.FormMessage,{className:a.cn(d&&"absolute -bottom-5")})]})}})||null;exports.MySelect=q;
2
+ //# sourceMappingURL=MySelect-C7tnOKUF.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MySelect-Ovb1pK5c.cjs.js","sources":["../../src/components/form/MySelect.tsx"],"sourcesContent":["import {\n FormControl,\n FormField,\n FormItem,\n type FormItemProps,\n FormLabel,\n FormMessage,\n ReactSelect,\n type ReactSelectProps,\n} from 'dgz-ui/form';\nimport { cn } from 'dgz-ui/utils';\nimport { get } from 'lodash';\nimport type { FieldPath, FieldValues } from 'react-hook-form';\n\n/**\n * Props for the MySelect component.\n * @template TFieldValues - The type of the form values.\n */\nexport type MySelectProps<TFieldValues extends FieldValues> =\n FormItemProps<TFieldValues> &\n ReactSelectProps & {\n /** Optional callback for change events. */\n onChange?: (value: unknown) => void;\n };\n\n/**\n * MySelect wraps a ReactSelect with react-hook-form support.\n * Can also be used standalone when no control/name are provided.\n *\n * @template TFieldValues - Form values type used by react-hook-form.\n * @param control - The `react-hook-form` control object.\n * @param name - The name of the field in `react-hook-form`.\n * @param label - The label to display for the select.\n * @param required - Whether the field is required.\n * @param className - Custom CSS class name.\n * @param rules - The `react-hook-form` validation rules.\n * @param options - The options to display in the select.\n * @param onChange - Optional callback for change events.\n * @param floatingError - Whether to show the error message in a floating container.\n * @param props - Select and form item props.\n * @returns A select component integrated with react-hook-form.\n */\nexport const MySelect = <TFieldValues extends FieldValues>({\n control,\n name,\n label,\n required,\n className,\n rules,\n options = [],\n onChange,\n floatingError,\n ...props\n}: MySelectProps<TFieldValues>) => {\n return (\n (name && control && (\n <FormField<TFieldValues, FieldPath<TFieldValues>>\n control={control}\n name={name}\n rules={rules}\n render={({ field, formState }) => {\n const handleChange = (value: unknown) => {\n field.onChange(value);\n if (onChange) {\n onChange(value);\n }\n };\n\n return (\n <FormItem className={cn(floatingError && 'space-y-0')}>\n {label && (\n <FormLabel className={'block'}>\n {label}{' '}\n {required && <span className={'text-red-600'}>*</span>}\n </FormLabel>\n )}\n <FormControl>\n <ReactSelect\n className={cn(className)}\n {...props}\n {...field}\n onChange={handleChange}\n options={options}\n error={!!get(formState.errors, `${name}`)}\n />\n </FormControl>\n <FormMessage\n className={cn(floatingError && 'absolute -bottom-5')}\n />\n </FormItem>\n );\n }}\n />\n )) ||\n null\n );\n};\n"],"names":["MySelect","control","name","label","required","className","rules","options","onChange","floatingError","props","jsx","FormField","field","formState","handleChange","value","FormItem","cn","jsxs","FormLabel","FormControl","ReactSelect","get","FormMessage"],"mappings":"2IA0CaA,EAAW,CAAmC,CACzD,QAAAC,EACA,KAAAC,EACA,MAAAC,EACA,SAAAC,EACA,UAAAC,EACA,MAAAC,EACA,QAAAC,EAAU,CAAA,EACV,SAAAC,EACA,cAAAC,EACA,GAAGC,CACL,IAEKR,GAAQD,GACPU,EAAAA,IAACC,EAAAA,UAAA,CACC,QAAAX,EACA,KAAAC,EACA,MAAAI,EACA,OAAQ,CAAC,CAAE,MAAAO,EAAO,UAAAC,KAAgB,CAChC,MAAMC,EAAgBC,GAAmB,CACvCH,EAAM,SAASG,CAAK,EAChBR,GACFA,EAASQ,CAAK,CAElB,EAEA,cACGC,EAAAA,SAAA,CAAS,UAAWC,EAAAA,GAAGT,GAAiB,WAAW,EACjD,SAAA,CAAAN,GACCgB,EAAAA,KAACC,EAAAA,UAAA,CAAU,UAAW,QACnB,SAAA,CAAAjB,EAAO,IACPC,GAAYO,EAAAA,IAAC,OAAA,CAAK,UAAW,eAAgB,SAAA,GAAA,CAAC,CAAA,EACjD,QAEDU,EAAAA,YAAA,CACC,SAAAV,EAAAA,IAACW,EAAAA,YAAA,CACC,UAAWJ,EAAAA,GAAGb,CAAS,EACtB,GAAGK,EACH,GAAGG,EACJ,SAAUE,EACV,QAAAR,EACA,MAAO,CAAC,CAACgB,oBAAIT,EAAU,OAAQ,GAAGZ,CAAI,EAAE,CAAA,CAAA,EAE5C,EACAS,EAAAA,IAACa,EAAAA,YAAA,CACC,UAAWN,EAAAA,GAAGT,GAAiB,oBAAoB,CAAA,CAAA,CACrD,EACF,CAEJ,CAAA,CAAA,GAGJ"}
1
+ {"version":3,"file":"MySelect-C7tnOKUF.cjs.js","sources":["../../src/components/form/MySelect.tsx"],"sourcesContent":["import {\n FormControl,\n FormField,\n FormItem,\n type FormItemProps,\n FormLabel,\n FormMessage,\n ReactSelect,\n type ReactSelectProps,\n} from 'dgz-ui/form';\nimport { cn } from 'dgz-ui/utils';\nimport { get } from 'lodash';\nimport type { FieldPath, FieldValues } from 'react-hook-form';\n\n/**\n * Props for the MySelect component.\n * @template TFieldValues - The type of the form values.\n */\nexport type MySelectProps<TFieldValues extends FieldValues> =\n FormItemProps<TFieldValues> &\n ReactSelectProps & {\n /** Optional callback for change events. */\n onChange?: (value: unknown) => void;\n };\n\n/**\n * MySelect wraps a ReactSelect with react-hook-form support.\n * Can also be used standalone when no control/name are provided.\n *\n * @template TFieldValues - Form values type used by react-hook-form.\n * @param control - The `react-hook-form` control object.\n * @param name - The name of the field in `react-hook-form`.\n * @param label - The label to display for the select.\n * @param required - Whether the field is required.\n * @param className - Custom CSS class name.\n * @param rules - The `react-hook-form` validation rules.\n * @param options - The options to display in the select.\n * @param onChange - Optional callback for change events.\n * @param floatingError - Whether to show the error message in a floating container.\n * @param props - Select and form item props.\n * @returns A select component integrated with react-hook-form.\n */\nexport const MySelect = <TFieldValues extends FieldValues>({\n control,\n name,\n label,\n required,\n className,\n rules,\n options = [],\n onChange,\n floatingError,\n ...props\n}: MySelectProps<TFieldValues>) => {\n return (\n (name && control && (\n <FormField<TFieldValues, FieldPath<TFieldValues>>\n control={control}\n name={name}\n rules={rules}\n render={({ field, formState }) => {\n const handleChange = (value: unknown) => {\n field.onChange(value);\n if (onChange) {\n onChange(value);\n }\n };\n\n return (\n <FormItem>\n {label && (\n <FormLabel className={'block'}>\n {label}{' '}\n {required && <span className={'text-red-600'}>*</span>}\n </FormLabel>\n )}\n <FormControl>\n <ReactSelect\n className={cn(className)}\n {...props}\n {...field}\n onChange={handleChange}\n options={options}\n error={!!get(formState.errors, `${name}`)}\n />\n </FormControl>\n <FormMessage\n className={cn(floatingError && 'absolute -bottom-5')}\n />\n </FormItem>\n );\n }}\n />\n )) ||\n null\n );\n};\n"],"names":["MySelect","control","name","label","required","className","rules","options","onChange","floatingError","props","jsx","FormField","field","formState","handleChange","value","FormItem","jsxs","FormLabel","FormControl","ReactSelect","cn","get","FormMessage"],"mappings":"2IA0CaA,EAAW,CAAmC,CACzD,QAAAC,EACA,KAAAC,EACA,MAAAC,EACA,SAAAC,EACA,UAAAC,EACA,MAAAC,EACA,QAAAC,EAAU,CAAA,EACV,SAAAC,EACA,cAAAC,EACA,GAAGC,CACL,IAEKR,GAAQD,GACPU,EAAAA,IAACC,EAAAA,UAAA,CACC,QAAAX,EACA,KAAAC,EACA,MAAAI,EACA,OAAQ,CAAC,CAAE,MAAAO,EAAO,UAAAC,KAAgB,CAChC,MAAMC,EAAgBC,GAAmB,CACvCH,EAAM,SAASG,CAAK,EAChBR,GACFA,EAASQ,CAAK,CAElB,EAEA,cACGC,WAAA,CACE,SAAA,CAAAd,GACCe,EAAAA,KAACC,EAAAA,UAAA,CAAU,UAAW,QACnB,SAAA,CAAAhB,EAAO,IACPC,GAAYO,EAAAA,IAAC,OAAA,CAAK,UAAW,eAAgB,SAAA,GAAA,CAAC,CAAA,EACjD,QAEDS,EAAAA,YAAA,CACC,SAAAT,EAAAA,IAACU,EAAAA,YAAA,CACC,UAAWC,EAAAA,GAAGjB,CAAS,EACtB,GAAGK,EACH,GAAGG,EACJ,SAAUE,EACV,QAAAR,EACA,MAAO,CAAC,CAACgB,oBAAIT,EAAU,OAAQ,GAAGZ,CAAI,EAAE,CAAA,CAAA,EAE5C,EACAS,EAAAA,IAACa,EAAAA,YAAA,CACC,UAAWF,EAAAA,GAAGb,GAAiB,oBAAoB,CAAA,CAAA,CACrD,EACF,CAEJ,CAAA,CAAA,GAGJ"}
@@ -0,0 +1,56 @@
1
+ import { jsx as r, jsxs as l } from "react/jsx-runtime";
2
+ import { FormField as g, FormItem as N, FormLabel as b, FormControl as u, ReactSelect as C, FormMessage as M } from "dgz-ui/form";
3
+ import { cn as c } from "dgz-ui/utils";
4
+ import { l as j } from "./lodash-CRDOWzbs.es.js";
5
+ const I = ({
6
+ control: o,
7
+ name: e,
8
+ label: s,
9
+ required: n,
10
+ className: i,
11
+ rules: d,
12
+ options: h = [],
13
+ onChange: t,
14
+ floatingError: p,
15
+ ...F
16
+ }) => e && o && /* @__PURE__ */ r(
17
+ g,
18
+ {
19
+ control: o,
20
+ name: e,
21
+ rules: d,
22
+ render: ({ field: m, formState: x }) => {
23
+ const f = (a) => {
24
+ m.onChange(a), t && t(a);
25
+ };
26
+ return /* @__PURE__ */ l(N, { children: [
27
+ s && /* @__PURE__ */ l(b, { className: "block", children: [
28
+ s,
29
+ " ",
30
+ n && /* @__PURE__ */ r("span", { className: "text-red-600", children: "*" })
31
+ ] }),
32
+ /* @__PURE__ */ r(u, { children: /* @__PURE__ */ r(
33
+ C,
34
+ {
35
+ className: c(i),
36
+ ...F,
37
+ ...m,
38
+ onChange: f,
39
+ options: h,
40
+ error: !!j.get(x.errors, `${e}`)
41
+ }
42
+ ) }),
43
+ /* @__PURE__ */ r(
44
+ M,
45
+ {
46
+ className: c(p && "absolute -bottom-5")
47
+ }
48
+ )
49
+ ] });
50
+ }
51
+ }
52
+ ) || null;
53
+ export {
54
+ I as M
55
+ };
56
+ //# sourceMappingURL=MySelect-DzvUAkVs.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MySelect-DzvUAkVs.es.js","sources":["../../src/components/form/MySelect.tsx"],"sourcesContent":["import {\n FormControl,\n FormField,\n FormItem,\n type FormItemProps,\n FormLabel,\n FormMessage,\n ReactSelect,\n type ReactSelectProps,\n} from 'dgz-ui/form';\nimport { cn } from 'dgz-ui/utils';\nimport { get } from 'lodash';\nimport type { FieldPath, FieldValues } from 'react-hook-form';\n\n/**\n * Props for the MySelect component.\n * @template TFieldValues - The type of the form values.\n */\nexport type MySelectProps<TFieldValues extends FieldValues> =\n FormItemProps<TFieldValues> &\n ReactSelectProps & {\n /** Optional callback for change events. */\n onChange?: (value: unknown) => void;\n };\n\n/**\n * MySelect wraps a ReactSelect with react-hook-form support.\n * Can also be used standalone when no control/name are provided.\n *\n * @template TFieldValues - Form values type used by react-hook-form.\n * @param control - The `react-hook-form` control object.\n * @param name - The name of the field in `react-hook-form`.\n * @param label - The label to display for the select.\n * @param required - Whether the field is required.\n * @param className - Custom CSS class name.\n * @param rules - The `react-hook-form` validation rules.\n * @param options - The options to display in the select.\n * @param onChange - Optional callback for change events.\n * @param floatingError - Whether to show the error message in a floating container.\n * @param props - Select and form item props.\n * @returns A select component integrated with react-hook-form.\n */\nexport const MySelect = <TFieldValues extends FieldValues>({\n control,\n name,\n label,\n required,\n className,\n rules,\n options = [],\n onChange,\n floatingError,\n ...props\n}: MySelectProps<TFieldValues>) => {\n return (\n (name && control && (\n <FormField<TFieldValues, FieldPath<TFieldValues>>\n control={control}\n name={name}\n rules={rules}\n render={({ field, formState }) => {\n const handleChange = (value: unknown) => {\n field.onChange(value);\n if (onChange) {\n onChange(value);\n }\n };\n\n return (\n <FormItem>\n {label && (\n <FormLabel className={'block'}>\n {label}{' '}\n {required && <span className={'text-red-600'}>*</span>}\n </FormLabel>\n )}\n <FormControl>\n <ReactSelect\n className={cn(className)}\n {...props}\n {...field}\n onChange={handleChange}\n options={options}\n error={!!get(formState.errors, `${name}`)}\n />\n </FormControl>\n <FormMessage\n className={cn(floatingError && 'absolute -bottom-5')}\n />\n </FormItem>\n );\n }}\n />\n )) ||\n null\n );\n};\n"],"names":["MySelect","control","name","label","required","className","rules","options","onChange","floatingError","props","jsx","FormField","field","formState","handleChange","value","FormItem","jsxs","FormLabel","FormControl","ReactSelect","cn","get","FormMessage"],"mappings":";;;;AA0CO,MAAMA,IAAW,CAAmC;AAAA,EACzD,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC,IAAU,CAAA;AAAA,EACV,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,GAAGC;AACL,MAEKR,KAAQD,KACP,gBAAAU;AAAA,EAACC;AAAA,EAAA;AAAA,IACC,SAAAX;AAAA,IACA,MAAAC;AAAA,IACA,OAAAI;AAAA,IACA,QAAQ,CAAC,EAAE,OAAAO,GAAO,WAAAC,QAAgB;AAChC,YAAMC,IAAe,CAACC,MAAmB;AACvC,QAAAH,EAAM,SAASG,CAAK,GAChBR,KACFA,EAASQ,CAAK;AAAA,MAElB;AAEA,+BACGC,GAAA,EACE,UAAA;AAAA,QAAAd,KACC,gBAAAe,EAACC,GAAA,EAAU,WAAW,SACnB,UAAA;AAAA,UAAAhB;AAAA,UAAO;AAAA,UACPC,KAAY,gBAAAO,EAAC,QAAA,EAAK,WAAW,gBAAgB,UAAA,IAAA,CAAC;AAAA,QAAA,GACjD;AAAA,0BAEDS,GAAA,EACC,UAAA,gBAAAT;AAAA,UAACU;AAAA,UAAA;AAAA,YACC,WAAWC,EAAGjB,CAAS;AAAA,YACtB,GAAGK;AAAA,YACH,GAAGG;AAAA,YACJ,UAAUE;AAAA,YACV,SAAAR;AAAA,YACA,OAAO,CAAC,CAACgB,MAAIT,EAAU,QAAQ,GAAGZ,CAAI,EAAE;AAAA,UAAA;AAAA,QAAA,GAE5C;AAAA,QACA,gBAAAS;AAAA,UAACa;AAAA,UAAA;AAAA,YACC,WAAWF,EAAGb,KAAiB,oBAAoB;AAAA,UAAA;AAAA,QAAA;AAAA,MACrD,GACF;AAAA,IAEJ;AAAA,EAAA;AAAA,KAGJ;"}