@g4rcez/components 2.0.9 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/form/date-picker.d.ts.map +1 -1
- package/dist/components/form/date-picker.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +360 -364
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +12 -12
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAI9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC,EAAE,UAAU,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAI9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC,EAAE,UAAU,CAAC,CAAA;AAiDf,eAAO,MAAM,UAAU,uGA8GtB,CAAC"}
|
|
@@ -28,10 +28,10 @@ const placeholders = {
|
|
|
28
28
|
};
|
|
29
29
|
const partValues = {
|
|
30
30
|
literal: (_, str) => str,
|
|
31
|
-
hour: (date) => date.getHours().toString(),
|
|
32
31
|
year: (date) => date.getFullYear().toString(),
|
|
33
|
-
minute: (date) => date.getMinutes().toString(),
|
|
34
32
|
day: (date) => date.getDate().toString().padStart(2, "0"),
|
|
33
|
+
hour: (date) => date.getHours().toString().padStart(2, "0"),
|
|
34
|
+
minute: (date) => date.getMinutes().toString().padStart(2, "0"),
|
|
35
35
|
month: (date) => (date.getMonth() + 1).toString().padStart(2, "0"),
|
|
36
36
|
};
|
|
37
37
|
const formatParts = (datetimeFormat, date) => {
|
|
@@ -47,14 +47,13 @@ const formatParts = (datetimeFormat, date) => {
|
|
|
47
47
|
return [];
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
+
const DATE_TIME_FORMAT = { day: "numeric", month: "numeric", year: "numeric", hour: "numeric", minute: "numeric" };
|
|
51
|
+
const DATE_FORMAT = { day: "numeric", month: "numeric", year: "numeric" };
|
|
50
52
|
export const DatePicker = forwardRef(({ date, locale: inputLocal, disabledDate, onChange, markToday, clickToClose, type, ...props }, externalRef) => {
|
|
51
|
-
console.log(props.datetimeTitle, props);
|
|
52
53
|
const locale = useLocale(inputLocal);
|
|
53
54
|
const labelId = useId();
|
|
54
55
|
const translation = useTranslations();
|
|
55
|
-
const datetimeFormat = useMemo(() => new Intl.DateTimeFormat(locale, type === "datetime"
|
|
56
|
-
? { day: "numeric", month: "numeric", year: "numeric", hour: "numeric", minute: "numeric" }
|
|
57
|
-
: { day: "numeric", month: "numeric", year: "numeric" }), [locale, type]);
|
|
56
|
+
const datetimeFormat = useMemo(() => new Intl.DateTimeFormat(locale, type === "datetime" ? DATE_TIME_FORMAT : DATE_FORMAT), [locale, type]);
|
|
58
57
|
const [innerDate, setInnerDate] = useState(date || undefined);
|
|
59
58
|
const [open, setOpen] = useState(false);
|
|
60
59
|
const mask = formatParts(datetimeFormat, fixedDate).flatMap((x) => (Is.keyof(parts, x.type) ? parts[x.type](x.value) : []));
|