@humu-tech/ui 0.1.11 → 0.1.12
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/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +106 -25
- package/dist/index.mjs +111 -30
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -237,7 +237,7 @@ type ConfirmDialogProps = {
|
|
|
237
237
|
};
|
|
238
238
|
declare function ConfirmDialog({ trigger, title, description, confirmLabel, cancelLabel, variant, onConfirm, disabled, }: ConfirmDialogProps): react.JSX.Element;
|
|
239
239
|
|
|
240
|
-
type DateInputProps = Omit<ComponentPropsWithoutRef<'
|
|
240
|
+
type DateInputProps = Omit<ComponentPropsWithoutRef<'input'>, 'value' | 'defaultValue' | 'onChange' | 'size'> & {
|
|
241
241
|
value?: Date;
|
|
242
242
|
defaultValue?: Date;
|
|
243
243
|
onValueChange?: (value: Date | undefined) => void;
|
|
@@ -254,7 +254,7 @@ type DateInputProps = Omit<ComponentPropsWithoutRef<'button'>, 'value' | 'defaul
|
|
|
254
254
|
locale?: typeof ptBR;
|
|
255
255
|
closeLabel?: string;
|
|
256
256
|
};
|
|
257
|
-
declare const DateInput: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.
|
|
257
|
+
declare const DateInput: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "size" | "defaultValue" | "onChange" | "value"> & {
|
|
258
258
|
value?: Date;
|
|
259
259
|
defaultValue?: Date;
|
|
260
260
|
onValueChange?: (value: Date | undefined) => void;
|
|
@@ -270,7 +270,7 @@ declare const DateInput: react.ForwardRefExoticComponent<Omit<Omit<react.Detaile
|
|
|
270
270
|
formatPattern?: string;
|
|
271
271
|
locale?: typeof ptBR;
|
|
272
272
|
closeLabel?: string;
|
|
273
|
-
} & react.RefAttributes<
|
|
273
|
+
} & react.RefAttributes<HTMLInputElement>>;
|
|
274
274
|
|
|
275
275
|
type DateRange = {
|
|
276
276
|
from?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -237,7 +237,7 @@ type ConfirmDialogProps = {
|
|
|
237
237
|
};
|
|
238
238
|
declare function ConfirmDialog({ trigger, title, description, confirmLabel, cancelLabel, variant, onConfirm, disabled, }: ConfirmDialogProps): react.JSX.Element;
|
|
239
239
|
|
|
240
|
-
type DateInputProps = Omit<ComponentPropsWithoutRef<'
|
|
240
|
+
type DateInputProps = Omit<ComponentPropsWithoutRef<'input'>, 'value' | 'defaultValue' | 'onChange' | 'size'> & {
|
|
241
241
|
value?: Date;
|
|
242
242
|
defaultValue?: Date;
|
|
243
243
|
onValueChange?: (value: Date | undefined) => void;
|
|
@@ -254,7 +254,7 @@ type DateInputProps = Omit<ComponentPropsWithoutRef<'button'>, 'value' | 'defaul
|
|
|
254
254
|
locale?: typeof ptBR;
|
|
255
255
|
closeLabel?: string;
|
|
256
256
|
};
|
|
257
|
-
declare const DateInput: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.
|
|
257
|
+
declare const DateInput: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "size" | "defaultValue" | "onChange" | "value"> & {
|
|
258
258
|
value?: Date;
|
|
259
259
|
defaultValue?: Date;
|
|
260
260
|
onValueChange?: (value: Date | undefined) => void;
|
|
@@ -270,7 +270,7 @@ declare const DateInput: react.ForwardRefExoticComponent<Omit<Omit<react.Detaile
|
|
|
270
270
|
formatPattern?: string;
|
|
271
271
|
locale?: typeof ptBR;
|
|
272
272
|
closeLabel?: string;
|
|
273
|
-
} & react.RefAttributes<
|
|
273
|
+
} & react.RefAttributes<HTMLInputElement>>;
|
|
274
274
|
|
|
275
275
|
type DateRange = {
|
|
276
276
|
from?: string;
|
package/dist/index.js
CHANGED
|
@@ -1803,6 +1803,28 @@ var import_DateInput = require("./DateInput-Y73Z32X6.css");
|
|
|
1803
1803
|
var import_DateRangeInput = require("./DateRangeInput-GFYTBAQ7.css");
|
|
1804
1804
|
var import_style = require("react-day-picker/dist/style.css");
|
|
1805
1805
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1806
|
+
var DEFAULT_PATTERN = "dd/MM/yyyy";
|
|
1807
|
+
function maskDefaultPattern(raw) {
|
|
1808
|
+
const digits = raw.replace(/\D/g, "").slice(0, 8);
|
|
1809
|
+
const parts = [];
|
|
1810
|
+
if (digits.length > 0) parts.push(digits.slice(0, 2));
|
|
1811
|
+
if (digits.length > 2) parts.push(digits.slice(2, 4));
|
|
1812
|
+
if (digits.length > 4) parts.push(digits.slice(4, 8));
|
|
1813
|
+
return parts.join("/");
|
|
1814
|
+
}
|
|
1815
|
+
function isWithinRange(date, fromDate, toDate) {
|
|
1816
|
+
if (fromDate) {
|
|
1817
|
+
const from = new Date(fromDate);
|
|
1818
|
+
from.setHours(0, 0, 0, 0);
|
|
1819
|
+
if (date < from) return false;
|
|
1820
|
+
}
|
|
1821
|
+
if (toDate) {
|
|
1822
|
+
const to = new Date(toDate);
|
|
1823
|
+
to.setHours(23, 59, 59, 999);
|
|
1824
|
+
if (date > to) return false;
|
|
1825
|
+
}
|
|
1826
|
+
return true;
|
|
1827
|
+
}
|
|
1806
1828
|
var DateInput = (0, import_react22.forwardRef)(
|
|
1807
1829
|
({
|
|
1808
1830
|
value: controlledValue,
|
|
@@ -1812,17 +1834,18 @@ var DateInput = (0, import_react22.forwardRef)(
|
|
|
1812
1834
|
helper,
|
|
1813
1835
|
error,
|
|
1814
1836
|
required,
|
|
1815
|
-
placeholder = "
|
|
1837
|
+
placeholder = "DD/MM/AAAA",
|
|
1816
1838
|
fromDate,
|
|
1817
1839
|
toDate,
|
|
1818
1840
|
disabledDates,
|
|
1819
1841
|
leftIcon,
|
|
1820
|
-
formatPattern =
|
|
1842
|
+
formatPattern = DEFAULT_PATTERN,
|
|
1821
1843
|
locale = import_locale.ptBR,
|
|
1822
1844
|
closeLabel = "Aplicar",
|
|
1823
1845
|
id,
|
|
1824
1846
|
className,
|
|
1825
1847
|
disabled,
|
|
1848
|
+
onBlur,
|
|
1826
1849
|
...props
|
|
1827
1850
|
}, ref) => {
|
|
1828
1851
|
const isControlled = controlledValue !== void 0;
|
|
@@ -1840,16 +1863,45 @@ var DateInput = (0, import_react22.forwardRef)(
|
|
|
1840
1863
|
const helperId = helper ? `${triggerId}-helper` : void 0;
|
|
1841
1864
|
const errorId = error ? `${triggerId}-error` : void 0;
|
|
1842
1865
|
const describedBy = [helperId, errorId].filter(Boolean).join(" ") || void 0;
|
|
1843
|
-
const
|
|
1866
|
+
const formatValue = (date) => (0, import_date_fns.format)(date, formatPattern, { locale });
|
|
1867
|
+
const [text, setText] = (0, import_react22.useState)(value ? formatValue(value) : "");
|
|
1868
|
+
(0, import_react22.useEffect)(() => {
|
|
1869
|
+
setText(value ? formatValue(value) : "");
|
|
1870
|
+
}, [value == null ? void 0 : value.getTime(), formatPattern]);
|
|
1871
|
+
const commitValue = (next) => {
|
|
1844
1872
|
if (!isControlled) setUncontrolled(next);
|
|
1845
1873
|
onValueChange == null ? void 0 : onValueChange(next);
|
|
1846
1874
|
};
|
|
1875
|
+
const handleSelect = (next) => {
|
|
1876
|
+
commitValue(next);
|
|
1877
|
+
};
|
|
1847
1878
|
const handleClear = () => {
|
|
1848
|
-
|
|
1849
|
-
|
|
1879
|
+
commitValue(void 0);
|
|
1880
|
+
setText("");
|
|
1850
1881
|
};
|
|
1851
|
-
const
|
|
1852
|
-
|
|
1882
|
+
const tryParseAndCommit = (raw) => {
|
|
1883
|
+
const trimmed = raw.trim();
|
|
1884
|
+
if (trimmed === "") {
|
|
1885
|
+
if (value !== void 0) commitValue(void 0);
|
|
1886
|
+
return;
|
|
1887
|
+
}
|
|
1888
|
+
const parsed = (0, import_date_fns.parse)(trimmed, formatPattern, /* @__PURE__ */ new Date(), { locale });
|
|
1889
|
+
if ((0, import_date_fns.isValid)(parsed) && formatValue(parsed) === trimmed && isWithinRange(parsed, fromDate, toDate)) {
|
|
1890
|
+
commitValue(parsed);
|
|
1891
|
+
setMonth(parsed);
|
|
1892
|
+
}
|
|
1893
|
+
};
|
|
1894
|
+
const handleTextChange = (event) => {
|
|
1895
|
+
const raw = event.target.value;
|
|
1896
|
+
const nextText = formatPattern === DEFAULT_PATTERN ? maskDefaultPattern(raw) : raw;
|
|
1897
|
+
setText(nextText);
|
|
1898
|
+
tryParseAndCommit(nextText);
|
|
1899
|
+
};
|
|
1900
|
+
const handleTextBlur = (event) => {
|
|
1901
|
+
setText(value ? formatValue(value) : "");
|
|
1902
|
+
onBlur == null ? void 0 : onBlur(event);
|
|
1903
|
+
};
|
|
1904
|
+
const hasValue = Boolean(value);
|
|
1853
1905
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
1854
1906
|
const dropdownFromYear = fromDate ? fromDate.getFullYear() : 1900;
|
|
1855
1907
|
const dropdownToYear = toDate ? toDate.getFullYear() : currentYear + 10;
|
|
@@ -1881,26 +1933,17 @@ var DateInput = (0, import_react22.forwardRef)(
|
|
|
1881
1933
|
}
|
|
1882
1934
|
},
|
|
1883
1935
|
children: [
|
|
1884
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.
|
|
1885
|
-
"
|
|
1936
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1937
|
+
"div",
|
|
1886
1938
|
{
|
|
1887
|
-
ref,
|
|
1888
|
-
type: "button",
|
|
1889
|
-
id: triggerId,
|
|
1890
|
-
"aria-invalid": !!error || void 0,
|
|
1891
|
-
"aria-describedby": describedBy,
|
|
1892
|
-
"aria-required": required || void 0,
|
|
1893
|
-
"aria-label": typeof label === "string" ? label : void 0,
|
|
1894
|
-
disabled,
|
|
1895
1939
|
className: cn(
|
|
1896
1940
|
"flex h-12 w-full items-center gap-2 rounded-v2-md border px-3 text-left text-v2-sm text-v2-fg-default transition-colors",
|
|
1897
|
-
"bg-v2-raised
|
|
1898
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
1899
|
-
error ? "border-v2-danger-500 focus-
|
|
1941
|
+
"bg-v2-raised focus-within:outline-none focus-within:ring-2 focus-within:ring-v2-focus-ring/30 hover:border-v2-action-primary",
|
|
1942
|
+
"has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",
|
|
1943
|
+
error ? "border-v2-danger-500 focus-within:ring-v2-danger-500" : "border-v2-border-default",
|
|
1900
1944
|
label && "pt-2",
|
|
1901
1945
|
className
|
|
1902
1946
|
),
|
|
1903
|
-
...props,
|
|
1904
1947
|
children: [
|
|
1905
1948
|
leftIcon ?? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1906
1949
|
import_react23.CalendarBlank,
|
|
@@ -1910,10 +1953,48 @@ var DateInput = (0, import_react22.forwardRef)(
|
|
|
1910
1953
|
className: "shrink-0 text-v2-fg-muted"
|
|
1911
1954
|
}
|
|
1912
1955
|
),
|
|
1913
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1956
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1957
|
+
"input",
|
|
1958
|
+
{
|
|
1959
|
+
ref,
|
|
1960
|
+
id: triggerId,
|
|
1961
|
+
type: "text",
|
|
1962
|
+
inputMode: "numeric",
|
|
1963
|
+
autoComplete: "off",
|
|
1964
|
+
value: text,
|
|
1965
|
+
onChange: handleTextChange,
|
|
1966
|
+
onBlur: handleTextBlur,
|
|
1967
|
+
placeholder,
|
|
1968
|
+
disabled,
|
|
1969
|
+
required,
|
|
1970
|
+
"aria-invalid": !!error || void 0,
|
|
1971
|
+
"aria-describedby": describedBy,
|
|
1972
|
+
"aria-required": required || void 0,
|
|
1973
|
+
"aria-label": typeof label === "string" ? label : void 0,
|
|
1974
|
+
className: cn(
|
|
1975
|
+
"min-w-0 flex-1 bg-transparent text-v2-sm text-v2-fg-default outline-none",
|
|
1976
|
+
"placeholder:text-v2-fg-subtle disabled:cursor-not-allowed"
|
|
1977
|
+
),
|
|
1978
|
+
...props
|
|
1979
|
+
}
|
|
1980
|
+
),
|
|
1981
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1982
|
+
"button",
|
|
1983
|
+
{
|
|
1984
|
+
type: "button",
|
|
1985
|
+
disabled,
|
|
1986
|
+
"aria-label": "Abrir calend\xE1rio",
|
|
1987
|
+
className: cn(
|
|
1988
|
+
"inline-flex shrink-0 items-center justify-center rounded-v2-sm p-0.5 text-v2-fg-muted transition-colors",
|
|
1989
|
+
"hover:text-v2-action-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-v2-focus-ring/30",
|
|
1990
|
+
"disabled:cursor-not-allowed"
|
|
1991
|
+
),
|
|
1992
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react23.CaretDown, { size: 16, "aria-hidden": "true" })
|
|
1993
|
+
}
|
|
1994
|
+
) })
|
|
1914
1995
|
]
|
|
1915
1996
|
}
|
|
1916
|
-
)
|
|
1997
|
+
),
|
|
1917
1998
|
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1918
1999
|
Label,
|
|
1919
2000
|
{
|
|
@@ -2000,8 +2081,8 @@ var DateInput = (0, import_react22.forwardRef)(
|
|
|
2000
2081
|
className: "rdp-v2-range rdp-v2-single p-3",
|
|
2001
2082
|
formatters: {
|
|
2002
2083
|
formatCaption: (caption) => {
|
|
2003
|
-
const
|
|
2004
|
-
return
|
|
2084
|
+
const text2 = (0, import_date_fns.format)(caption, "LLLL", { locale });
|
|
2085
|
+
return text2.charAt(0).toUpperCase() + text2.slice(1);
|
|
2005
2086
|
}
|
|
2006
2087
|
},
|
|
2007
2088
|
showOutsideDays: true
|
package/dist/index.mjs
CHANGED
|
@@ -1685,7 +1685,7 @@ import {
|
|
|
1685
1685
|
useRef as useRef2,
|
|
1686
1686
|
useState as useState6
|
|
1687
1687
|
} from "react";
|
|
1688
|
-
import { format } from "date-fns";
|
|
1688
|
+
import { format, isValid, parse } from "date-fns";
|
|
1689
1689
|
import { ptBR } from "date-fns/locale";
|
|
1690
1690
|
import { DayPicker } from "react-day-picker";
|
|
1691
1691
|
import { CalendarBlank, CaretDown as CaretDown2 } from "@phosphor-icons/react";
|
|
@@ -1693,6 +1693,28 @@ import "./DateInput-Y73Z32X6.css";
|
|
|
1693
1693
|
import "./DateRangeInput-GFYTBAQ7.css";
|
|
1694
1694
|
import "react-day-picker/dist/style.css";
|
|
1695
1695
|
import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1696
|
+
var DEFAULT_PATTERN = "dd/MM/yyyy";
|
|
1697
|
+
function maskDefaultPattern(raw) {
|
|
1698
|
+
const digits = raw.replace(/\D/g, "").slice(0, 8);
|
|
1699
|
+
const parts = [];
|
|
1700
|
+
if (digits.length > 0) parts.push(digits.slice(0, 2));
|
|
1701
|
+
if (digits.length > 2) parts.push(digits.slice(2, 4));
|
|
1702
|
+
if (digits.length > 4) parts.push(digits.slice(4, 8));
|
|
1703
|
+
return parts.join("/");
|
|
1704
|
+
}
|
|
1705
|
+
function isWithinRange(date, fromDate, toDate) {
|
|
1706
|
+
if (fromDate) {
|
|
1707
|
+
const from = new Date(fromDate);
|
|
1708
|
+
from.setHours(0, 0, 0, 0);
|
|
1709
|
+
if (date < from) return false;
|
|
1710
|
+
}
|
|
1711
|
+
if (toDate) {
|
|
1712
|
+
const to = new Date(toDate);
|
|
1713
|
+
to.setHours(23, 59, 59, 999);
|
|
1714
|
+
if (date > to) return false;
|
|
1715
|
+
}
|
|
1716
|
+
return true;
|
|
1717
|
+
}
|
|
1696
1718
|
var DateInput = forwardRef14(
|
|
1697
1719
|
({
|
|
1698
1720
|
value: controlledValue,
|
|
@@ -1702,17 +1724,18 @@ var DateInput = forwardRef14(
|
|
|
1702
1724
|
helper,
|
|
1703
1725
|
error,
|
|
1704
1726
|
required,
|
|
1705
|
-
placeholder = "
|
|
1727
|
+
placeholder = "DD/MM/AAAA",
|
|
1706
1728
|
fromDate,
|
|
1707
1729
|
toDate,
|
|
1708
1730
|
disabledDates,
|
|
1709
1731
|
leftIcon,
|
|
1710
|
-
formatPattern =
|
|
1732
|
+
formatPattern = DEFAULT_PATTERN,
|
|
1711
1733
|
locale = ptBR,
|
|
1712
1734
|
closeLabel = "Aplicar",
|
|
1713
1735
|
id,
|
|
1714
1736
|
className,
|
|
1715
1737
|
disabled,
|
|
1738
|
+
onBlur,
|
|
1716
1739
|
...props
|
|
1717
1740
|
}, ref) => {
|
|
1718
1741
|
const isControlled = controlledValue !== void 0;
|
|
@@ -1730,16 +1753,45 @@ var DateInput = forwardRef14(
|
|
|
1730
1753
|
const helperId = helper ? `${triggerId}-helper` : void 0;
|
|
1731
1754
|
const errorId = error ? `${triggerId}-error` : void 0;
|
|
1732
1755
|
const describedBy = [helperId, errorId].filter(Boolean).join(" ") || void 0;
|
|
1733
|
-
const
|
|
1756
|
+
const formatValue = (date) => format(date, formatPattern, { locale });
|
|
1757
|
+
const [text, setText] = useState6(value ? formatValue(value) : "");
|
|
1758
|
+
useEffect4(() => {
|
|
1759
|
+
setText(value ? formatValue(value) : "");
|
|
1760
|
+
}, [value == null ? void 0 : value.getTime(), formatPattern]);
|
|
1761
|
+
const commitValue = (next) => {
|
|
1734
1762
|
if (!isControlled) setUncontrolled(next);
|
|
1735
1763
|
onValueChange == null ? void 0 : onValueChange(next);
|
|
1736
1764
|
};
|
|
1765
|
+
const handleSelect = (next) => {
|
|
1766
|
+
commitValue(next);
|
|
1767
|
+
};
|
|
1737
1768
|
const handleClear = () => {
|
|
1738
|
-
|
|
1739
|
-
|
|
1769
|
+
commitValue(void 0);
|
|
1770
|
+
setText("");
|
|
1740
1771
|
};
|
|
1741
|
-
const
|
|
1742
|
-
|
|
1772
|
+
const tryParseAndCommit = (raw) => {
|
|
1773
|
+
const trimmed = raw.trim();
|
|
1774
|
+
if (trimmed === "") {
|
|
1775
|
+
if (value !== void 0) commitValue(void 0);
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
const parsed = parse(trimmed, formatPattern, /* @__PURE__ */ new Date(), { locale });
|
|
1779
|
+
if (isValid(parsed) && formatValue(parsed) === trimmed && isWithinRange(parsed, fromDate, toDate)) {
|
|
1780
|
+
commitValue(parsed);
|
|
1781
|
+
setMonth(parsed);
|
|
1782
|
+
}
|
|
1783
|
+
};
|
|
1784
|
+
const handleTextChange = (event) => {
|
|
1785
|
+
const raw = event.target.value;
|
|
1786
|
+
const nextText = formatPattern === DEFAULT_PATTERN ? maskDefaultPattern(raw) : raw;
|
|
1787
|
+
setText(nextText);
|
|
1788
|
+
tryParseAndCommit(nextText);
|
|
1789
|
+
};
|
|
1790
|
+
const handleTextBlur = (event) => {
|
|
1791
|
+
setText(value ? formatValue(value) : "");
|
|
1792
|
+
onBlur == null ? void 0 : onBlur(event);
|
|
1793
|
+
};
|
|
1794
|
+
const hasValue = Boolean(value);
|
|
1743
1795
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
1744
1796
|
const dropdownFromYear = fromDate ? fromDate.getFullYear() : 1900;
|
|
1745
1797
|
const dropdownToYear = toDate ? toDate.getFullYear() : currentYear + 10;
|
|
@@ -1771,26 +1823,17 @@ var DateInput = forwardRef14(
|
|
|
1771
1823
|
}
|
|
1772
1824
|
},
|
|
1773
1825
|
children: [
|
|
1774
|
-
/* @__PURE__ */
|
|
1775
|
-
"
|
|
1826
|
+
/* @__PURE__ */ jsxs12(
|
|
1827
|
+
"div",
|
|
1776
1828
|
{
|
|
1777
|
-
ref,
|
|
1778
|
-
type: "button",
|
|
1779
|
-
id: triggerId,
|
|
1780
|
-
"aria-invalid": !!error || void 0,
|
|
1781
|
-
"aria-describedby": describedBy,
|
|
1782
|
-
"aria-required": required || void 0,
|
|
1783
|
-
"aria-label": typeof label === "string" ? label : void 0,
|
|
1784
|
-
disabled,
|
|
1785
1829
|
className: cn(
|
|
1786
1830
|
"flex h-12 w-full items-center gap-2 rounded-v2-md border px-3 text-left text-v2-sm text-v2-fg-default transition-colors",
|
|
1787
|
-
"bg-v2-raised
|
|
1788
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
1789
|
-
error ? "border-v2-danger-500 focus-
|
|
1831
|
+
"bg-v2-raised focus-within:outline-none focus-within:ring-2 focus-within:ring-v2-focus-ring/30 hover:border-v2-action-primary",
|
|
1832
|
+
"has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",
|
|
1833
|
+
error ? "border-v2-danger-500 focus-within:ring-v2-danger-500" : "border-v2-border-default",
|
|
1790
1834
|
label && "pt-2",
|
|
1791
1835
|
className
|
|
1792
1836
|
),
|
|
1793
|
-
...props,
|
|
1794
1837
|
children: [
|
|
1795
1838
|
leftIcon ?? /* @__PURE__ */ jsx20(
|
|
1796
1839
|
CalendarBlank,
|
|
@@ -1800,10 +1843,48 @@ var DateInput = forwardRef14(
|
|
|
1800
1843
|
className: "shrink-0 text-v2-fg-muted"
|
|
1801
1844
|
}
|
|
1802
1845
|
),
|
|
1803
|
-
/* @__PURE__ */ jsx20(
|
|
1846
|
+
/* @__PURE__ */ jsx20(
|
|
1847
|
+
"input",
|
|
1848
|
+
{
|
|
1849
|
+
ref,
|
|
1850
|
+
id: triggerId,
|
|
1851
|
+
type: "text",
|
|
1852
|
+
inputMode: "numeric",
|
|
1853
|
+
autoComplete: "off",
|
|
1854
|
+
value: text,
|
|
1855
|
+
onChange: handleTextChange,
|
|
1856
|
+
onBlur: handleTextBlur,
|
|
1857
|
+
placeholder,
|
|
1858
|
+
disabled,
|
|
1859
|
+
required,
|
|
1860
|
+
"aria-invalid": !!error || void 0,
|
|
1861
|
+
"aria-describedby": describedBy,
|
|
1862
|
+
"aria-required": required || void 0,
|
|
1863
|
+
"aria-label": typeof label === "string" ? label : void 0,
|
|
1864
|
+
className: cn(
|
|
1865
|
+
"min-w-0 flex-1 bg-transparent text-v2-sm text-v2-fg-default outline-none",
|
|
1866
|
+
"placeholder:text-v2-fg-subtle disabled:cursor-not-allowed"
|
|
1867
|
+
),
|
|
1868
|
+
...props
|
|
1869
|
+
}
|
|
1870
|
+
),
|
|
1871
|
+
/* @__PURE__ */ jsx20(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx20(
|
|
1872
|
+
"button",
|
|
1873
|
+
{
|
|
1874
|
+
type: "button",
|
|
1875
|
+
disabled,
|
|
1876
|
+
"aria-label": "Abrir calend\xE1rio",
|
|
1877
|
+
className: cn(
|
|
1878
|
+
"inline-flex shrink-0 items-center justify-center rounded-v2-sm p-0.5 text-v2-fg-muted transition-colors",
|
|
1879
|
+
"hover:text-v2-action-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-v2-focus-ring/30",
|
|
1880
|
+
"disabled:cursor-not-allowed"
|
|
1881
|
+
),
|
|
1882
|
+
children: /* @__PURE__ */ jsx20(CaretDown2, { size: 16, "aria-hidden": "true" })
|
|
1883
|
+
}
|
|
1884
|
+
) })
|
|
1804
1885
|
]
|
|
1805
1886
|
}
|
|
1806
|
-
)
|
|
1887
|
+
),
|
|
1807
1888
|
label && /* @__PURE__ */ jsx20(
|
|
1808
1889
|
Label,
|
|
1809
1890
|
{
|
|
@@ -1890,8 +1971,8 @@ var DateInput = forwardRef14(
|
|
|
1890
1971
|
className: "rdp-v2-range rdp-v2-single p-3",
|
|
1891
1972
|
formatters: {
|
|
1892
1973
|
formatCaption: (caption) => {
|
|
1893
|
-
const
|
|
1894
|
-
return
|
|
1974
|
+
const text2 = format(caption, "LLLL", { locale });
|
|
1975
|
+
return text2.charAt(0).toUpperCase() + text2.slice(1);
|
|
1895
1976
|
}
|
|
1896
1977
|
},
|
|
1897
1978
|
showOutsideDays: true
|
|
@@ -1940,7 +2021,7 @@ DateInput.displayName = "DateInput";
|
|
|
1940
2021
|
|
|
1941
2022
|
// src/primitives/DateRangeInput/DateRangeInput.tsx
|
|
1942
2023
|
import { forwardRef as forwardRef15, useEffect as useEffect5, useId as useId7, useRef as useRef3, useState as useState7 } from "react";
|
|
1943
|
-
import { format as format2, parse, isValid } from "date-fns";
|
|
2024
|
+
import { format as format2, parse as parse2, isValid as isValid2 } from "date-fns";
|
|
1944
2025
|
import { ptBR as ptBR2 } from "date-fns/locale";
|
|
1945
2026
|
import { DayPicker as DayPicker2 } from "react-day-picker";
|
|
1946
2027
|
import { CalendarBlank as CalendarBlank2, CaretDown as CaretDown3 } from "@phosphor-icons/react";
|
|
@@ -1962,11 +2043,11 @@ var ISO_FORMAT = "yyyy-MM-dd";
|
|
|
1962
2043
|
var DISPLAY_FORMAT = "dd/MM/yyyy";
|
|
1963
2044
|
function isoToDate(iso) {
|
|
1964
2045
|
if (!iso) return void 0;
|
|
1965
|
-
const parsed =
|
|
1966
|
-
return
|
|
2046
|
+
const parsed = parse2(iso, ISO_FORMAT, /* @__PURE__ */ new Date());
|
|
2047
|
+
return isValid2(parsed) ? parsed : void 0;
|
|
1967
2048
|
}
|
|
1968
2049
|
function dateToIso(date) {
|
|
1969
|
-
if (!date || !
|
|
2050
|
+
if (!date || !isValid2(date)) return void 0;
|
|
1970
2051
|
return format2(date, ISO_FORMAT);
|
|
1971
2052
|
}
|
|
1972
2053
|
function formatDisplay(iso) {
|