@payloadcms/ui 3.22.0 → 3.23.0-canary.8b7d68d
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/elements/DatePicker/types.d.ts +1 -1
- package/dist/elements/DatePicker/types.d.ts.map +1 -1
- package/dist/elements/DatePicker/types.js.map +1 -1
- package/dist/elements/TimezonePicker/index.d.ts +5 -0
- package/dist/elements/TimezonePicker/index.d.ts.map +1 -0
- package/dist/elements/TimezonePicker/index.js +50 -0
- package/dist/elements/TimezonePicker/index.js.map +1 -0
- package/dist/elements/TimezonePicker/index.scss +51 -0
- package/dist/elements/TimezonePicker/types.d.ts +8 -0
- package/dist/elements/TimezonePicker/types.d.ts.map +1 -0
- package/dist/elements/TimezonePicker/types.js +2 -0
- package/dist/elements/TimezonePicker/types.js.map +1 -0
- package/dist/elements/WhereBuilder/Condition/Select/formatOptions.d.ts +6 -0
- package/dist/elements/WhereBuilder/Condition/Select/formatOptions.d.ts.map +1 -0
- package/dist/elements/WhereBuilder/Condition/Select/formatOptions.js +12 -0
- package/dist/elements/WhereBuilder/Condition/Select/formatOptions.js.map +1 -0
- package/dist/elements/WhereBuilder/Condition/Select/index.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/Condition/Select/index.js +1 -9
- package/dist/elements/WhereBuilder/Condition/Select/index.js.map +1 -1
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +23 -23
- package/dist/exports/client/index.js.map +4 -4
- package/dist/fields/DateTime/index.d.ts +1 -2
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js +73 -8
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +5 -4
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { DateFieldValidation } from 'payload';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import './index.scss';
|
|
4
|
-
export declare const DateTimeField:
|
|
3
|
+
export declare const DateTimeField: import("react").FC<{
|
|
5
4
|
readonly path: string;
|
|
6
5
|
readonly validate?: DateFieldValidation;
|
|
7
6
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/DateTime/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA4B,mBAAmB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/DateTime/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA4B,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAe5E,OAAO,cAAc,CAAA;AA0KrB,eAAO,MAAM,aAAa;;;;;+EAAwC,CAAA"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { TZDateMini as TZDate } from '@date-fns/tz/date/mini';
|
|
4
5
|
import { getTranslation } from '@payloadcms/translations';
|
|
5
|
-
import
|
|
6
|
+
import { transpose } from 'date-fns';
|
|
7
|
+
import { useCallback, useMemo } from 'react';
|
|
6
8
|
import { DatePickerField } from '../../elements/DatePicker/index.js';
|
|
7
9
|
import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
|
|
10
|
+
import { TimezonePicker } from '../../elements/TimezonePicker/index.js';
|
|
8
11
|
import { FieldDescription } from '../../fields/FieldDescription/index.js';
|
|
9
12
|
import { FieldError } from '../../fields/FieldError/index.js';
|
|
10
13
|
import { FieldLabel } from '../../fields/FieldLabel/index.js';
|
|
14
|
+
import { useForm, useFormFields } from '../../forms/Form/context.js';
|
|
11
15
|
import { useField } from '../../forms/useField/index.js';
|
|
16
|
+
import './index.scss';
|
|
12
17
|
import { withCondition } from '../../forms/withCondition/index.js';
|
|
18
|
+
import { useConfig } from '../../providers/Config/index.js';
|
|
13
19
|
import { useTranslation } from '../../providers/Translation/index.js';
|
|
14
20
|
import { mergeFieldStyles } from '../mergeFieldStyles.js';
|
|
15
|
-
import './index.scss';
|
|
16
21
|
import { fieldBaseClass } from '../shared/index.js';
|
|
17
22
|
const baseClass = 'date-time-field';
|
|
18
23
|
const DateTimeFieldComponent = props => {
|
|
@@ -27,15 +32,25 @@ const DateTimeFieldComponent = props => {
|
|
|
27
32
|
} = {},
|
|
28
33
|
label,
|
|
29
34
|
localized,
|
|
30
|
-
required
|
|
35
|
+
required,
|
|
36
|
+
timezone
|
|
31
37
|
},
|
|
32
38
|
path,
|
|
33
39
|
readOnly,
|
|
34
40
|
validate
|
|
35
41
|
} = props;
|
|
42
|
+
// Get the user timezone so we can adjust the displayed value against it
|
|
43
|
+
const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
44
|
+
const {
|
|
45
|
+
config
|
|
46
|
+
} = useConfig();
|
|
36
47
|
const {
|
|
37
48
|
i18n
|
|
38
49
|
} = useTranslation();
|
|
50
|
+
const {
|
|
51
|
+
dispatchFields,
|
|
52
|
+
setModified
|
|
53
|
+
} = useForm();
|
|
39
54
|
const memoizedValidate = useCallback((value, options) => {
|
|
40
55
|
if (typeof validate === 'function') {
|
|
41
56
|
return validate(value, {
|
|
@@ -59,7 +74,52 @@ const DateTimeFieldComponent = props => {
|
|
|
59
74
|
path,
|
|
60
75
|
validate: memoizedValidate
|
|
61
76
|
});
|
|
77
|
+
const timezonePath = path + '_tz';
|
|
78
|
+
const timezoneField = useFormFields(([fields, _]) => fields?.[timezonePath]);
|
|
79
|
+
const supportedTimezones = config.admin.timezones.supportedTimezones;
|
|
80
|
+
const selectedTimezone = timezoneField?.value;
|
|
81
|
+
// The displayed value should be the original value, adjusted to the user's timezone
|
|
82
|
+
const displayedValue = useMemo(() => {
|
|
83
|
+
if (timezone && selectedTimezone && userTimezone && value_0) {
|
|
84
|
+
// Create TZDate instances for the selected timezone and the user's timezone
|
|
85
|
+
// These instances allow us to transpose the date between timezones while keeping the same time value
|
|
86
|
+
const DateWithOriginalTz = TZDate.tz(selectedTimezone);
|
|
87
|
+
const DateWithUserTz = TZDate.tz(userTimezone);
|
|
88
|
+
const modifiedDate = new TZDate(value_0).withTimeZone(selectedTimezone);
|
|
89
|
+
// Transpose the date to the selected timezone
|
|
90
|
+
const dateWithTimezone = transpose(modifiedDate, DateWithOriginalTz);
|
|
91
|
+
// Transpose the date to the user's timezone - this is necessary because the react-datepicker component insists on displaying the date in the user's timezone
|
|
92
|
+
const dateWithUserTimezone = transpose(dateWithTimezone, DateWithUserTz);
|
|
93
|
+
return dateWithUserTimezone.toISOString();
|
|
94
|
+
}
|
|
95
|
+
return value_0;
|
|
96
|
+
}, [timezone, selectedTimezone, value_0, userTimezone]);
|
|
62
97
|
const styles = useMemo(() => mergeFieldStyles(field), [field]);
|
|
98
|
+
const onChange = useCallback(incomingDate => {
|
|
99
|
+
if (!readOnly) {
|
|
100
|
+
if (timezone && selectedTimezone && incomingDate) {
|
|
101
|
+
// Create TZDate instances for the selected timezone
|
|
102
|
+
const tzDateWithUTC = TZDate.tz(selectedTimezone);
|
|
103
|
+
// Creates a TZDate instance for the user's timezone — this is default behaviour of TZDate as it wraps the Date constructor
|
|
104
|
+
const dateToUserTz = new TZDate(incomingDate);
|
|
105
|
+
// Transpose the date to the selected timezone
|
|
106
|
+
const dateWithTimezone_0 = transpose(dateToUserTz, tzDateWithUTC);
|
|
107
|
+
setValue(dateWithTimezone_0.toISOString() || null);
|
|
108
|
+
} else {
|
|
109
|
+
setValue(incomingDate?.toISOString() || null);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, [readOnly, setValue, timezone, selectedTimezone]);
|
|
113
|
+
const onChangeTimezone = useCallback(timezone_0 => {
|
|
114
|
+
if (timezonePath) {
|
|
115
|
+
dispatchFields({
|
|
116
|
+
type: 'UPDATE',
|
|
117
|
+
path: timezonePath,
|
|
118
|
+
value: timezone_0
|
|
119
|
+
});
|
|
120
|
+
setModified(true);
|
|
121
|
+
}
|
|
122
|
+
}, [dispatchFields, setModified, timezonePath]);
|
|
63
123
|
return /*#__PURE__*/_jsxs("div", {
|
|
64
124
|
className: [fieldBaseClass, baseClass, className, showError && `${baseClass}--has-error`, readOnly && 'read-only'].filter(Boolean).join(' '),
|
|
65
125
|
style: styles,
|
|
@@ -81,14 +141,19 @@ const DateTimeFieldComponent = props => {
|
|
|
81
141
|
})
|
|
82
142
|
}), BeforeInput, /*#__PURE__*/_jsx(DatePickerField, {
|
|
83
143
|
...datePickerProps,
|
|
84
|
-
onChange:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
144
|
+
onChange: onChange,
|
|
145
|
+
overrides: {
|
|
146
|
+
...datePickerProps?.overrides
|
|
88
147
|
},
|
|
89
148
|
placeholder: getTranslation(placeholder, i18n),
|
|
90
149
|
readOnly: readOnly,
|
|
91
|
-
value:
|
|
150
|
+
value: displayedValue
|
|
151
|
+
}), timezone && supportedTimezones.length > 0 && /*#__PURE__*/_jsx(TimezonePicker, {
|
|
152
|
+
id: `${path}-timezone-picker`,
|
|
153
|
+
onChange: onChangeTimezone,
|
|
154
|
+
options: supportedTimezones,
|
|
155
|
+
required: required,
|
|
156
|
+
selectedTimezone: selectedTimezone
|
|
92
157
|
}), AfterInput]
|
|
93
158
|
}), /*#__PURE__*/_jsx(RenderCustomComponent, {
|
|
94
159
|
CustomComponent: Description,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getTranslation","React","useCallback","useMemo","DatePickerField","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useField","withCondition","useTranslation","mergeFieldStyles","fieldBaseClass","baseClass","DateTimeFieldComponent","props","field","admin","className","date","datePickerProps","description","placeholder","label","localized","required","path","readOnly","validate","i18n","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","setValue","showError","styles","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","id","replace","onChange","incomingDate","toISOString","DateTimeField"],"sources":["../../../src/fields/DateTime/index.tsx"],"sourcesContent":["'use client'\nimport type { DateFieldClientComponent, DateFieldValidation } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback, useMemo } from 'react'\n\nimport { DatePickerField } from '../../elements/DatePicker/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport './index.scss'\nimport { fieldBaseClass } from '../shared/index.js'\n\nconst baseClass = 'date-time-field'\n\nconst DateTimeFieldComponent: DateFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { className, date: datePickerProps, description, placeholder } = {},\n label,\n localized,\n required,\n },\n path,\n readOnly,\n validate,\n } = props\n\n const { i18n } = useTranslation()\n\n const memoizedValidate: DateFieldValidation = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n setValue,\n showError,\n value,\n } = useField<Date>({\n path,\n validate: memoizedValidate,\n })\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && `${baseClass}--has-error`,\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={<FieldLabel label={label} localized={localized} required={required} />}\n />\n <div className={`${fieldBaseClass}__wrap`} id={`field-${path.replace(/\\./g, '__')}`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <DatePickerField\n {...datePickerProps}\n onChange={(incomingDate) => {\n if (!readOnly) {\n setValue(incomingDate?.toISOString() || null)\n }\n }}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={readOnly}\n value={value}\n />\n {AfterInput}\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const DateTimeField = withCondition(DateTimeFieldComponent)\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAE5C,SAASC,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ;AACjC,OAAO;AACP,SAASC,cAAc,QAAQ;AAE/B,MAAMC,SAAA,GAAY;AAElB,MAAMC,sBAAA,GAAoDC,KAAA;EACxD,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC,IAAA,EAAMC,eAAe;QAAEC,WAAW;QAAEC;MAAW,CAAE,GAAG,CAAC,CAAC;MAC1EC,KAAK;MACLC,SAAS;MACTC;IAAQ,CACT;IACDC,IAAI;IACJC,QAAQ;IACRC;EAAQ,CACT,GAAGb,KAAA;EAEJ,MAAM;IAAEc;EAAI,CAAE,GAAGnB,cAAA;EAEjB,MAAMoB,gBAAA,GAAwC7B,WAAA,CAC5C,CAAC8B,KAAA,EAAOC,OAAA;IACN,IAAI,OAAOJ,QAAA,KAAa,YAAY;MAClC,OAAOA,QAAA,CAASG,KAAA,EAAO;QAAE,GAAGC,OAAO;QAAEP;MAAS;IAChD;EACF,GACA,CAACG,QAAA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euB,WAAA,EAAaO,IAAA;QACzCF,QAAA,EAAUA,QAAA;QACVI,KAAA,EAAOA;UAERG,UAAA;qBAEHa,IAAA,CAAC3C,qBAAA;MACC4C,eAAA,EAAiBZ,WAAA;MACjBa,QAAA,eAAUF,IAAA,CAAC1C,gBAAA;QAAiBgB,WAAA,EAAaA,WAAA;QAAaK,IAAA,EAAMA;;;;AAIpE;AAEA,OAAO,MAAM6B,aAAA,GAAgB9C,aAAA,CAAcK,sBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["TZDateMini","TZDate","getTranslation","transpose","useCallback","useMemo","DatePickerField","RenderCustomComponent","TimezonePicker","FieldDescription","FieldError","FieldLabel","useForm","useFormFields","useField","withCondition","useConfig","useTranslation","mergeFieldStyles","fieldBaseClass","baseClass","DateTimeFieldComponent","props","field","admin","className","date","datePickerProps","description","placeholder","label","localized","required","timezone","path","readOnly","validate","userTimezone","Intl","DateTimeFormat","resolvedOptions","timeZone","config","i18n","dispatchFields","setModified","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","setValue","showError","timezonePath","timezoneField","fields","_","supportedTimezones","timezones","selectedTimezone","displayedValue","DateWithOriginalTz","tz","DateWithUserTz","modifiedDate","withTimeZone","dateWithTimezone","dateWithUserTimezone","toISOString","styles","onChange","incomingDate","tzDateWithUTC","dateToUserTz","onChangeTimezone","type","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","id","replace","overrides","length","DateTimeField"],"sources":["../../../src/fields/DateTime/index.tsx"],"sourcesContent":["'use client'\nimport type { DateFieldClientComponent, DateFieldValidation } from 'payload'\n\nimport { TZDateMini as TZDate } from '@date-fns/tz/date/mini'\nimport { getTranslation } from '@payloadcms/translations'\nimport { transpose } from 'date-fns'\nimport { useCallback, useMemo } from 'react'\n\nimport { DatePickerField } from '../../elements/DatePicker/index.js'\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { TimezonePicker } from '../../elements/TimezonePicker/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useForm, useFormFields } from '../../forms/Form/context.js'\nimport { useField } from '../../forms/useField/index.js'\nimport './index.scss'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport { fieldBaseClass } from '../shared/index.js'\n\nconst baseClass = 'date-time-field'\n\nconst DateTimeFieldComponent: DateFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { className, date: datePickerProps, description, placeholder } = {},\n label,\n localized,\n required,\n timezone,\n },\n path,\n readOnly,\n validate,\n } = props\n\n // Get the user timezone so we can adjust the displayed value against it\n const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone\n\n const { config } = useConfig()\n const { i18n } = useTranslation()\n const { dispatchFields, setModified } = useForm()\n\n const memoizedValidate: DateFieldValidation = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n setValue,\n showError,\n value,\n } = useField<Date>({\n path,\n validate: memoizedValidate,\n })\n\n const timezonePath = path + '_tz'\n const timezoneField = useFormFields(([fields, _]) => fields?.[timezonePath])\n const supportedTimezones = config.admin.timezones.supportedTimezones\n\n const selectedTimezone = timezoneField?.value as string\n\n // The displayed value should be the original value, adjusted to the user's timezone\n const displayedValue = useMemo(() => {\n if (timezone && selectedTimezone && userTimezone && value) {\n // Create TZDate instances for the selected timezone and the user's timezone\n // These instances allow us to transpose the date between timezones while keeping the same time value\n const DateWithOriginalTz = TZDate.tz(selectedTimezone)\n const DateWithUserTz = TZDate.tz(userTimezone)\n\n const modifiedDate = new TZDate(value).withTimeZone(selectedTimezone)\n\n // Transpose the date to the selected timezone\n const dateWithTimezone = transpose(modifiedDate, DateWithOriginalTz)\n\n // Transpose the date to the user's timezone - this is necessary because the react-datepicker component insists on displaying the date in the user's timezone\n const dateWithUserTimezone = transpose(dateWithTimezone, DateWithUserTz)\n\n return dateWithUserTimezone.toISOString()\n }\n\n return value\n }, [timezone, selectedTimezone, value, userTimezone])\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const onChange = useCallback(\n (incomingDate: Date) => {\n if (!readOnly) {\n if (timezone && selectedTimezone && incomingDate) {\n // Create TZDate instances for the selected timezone\n const tzDateWithUTC = TZDate.tz(selectedTimezone)\n\n // Creates a TZDate instance for the user's timezone — this is default behaviour of TZDate as it wraps the Date constructor\n const dateToUserTz = new TZDate(incomingDate)\n\n // Transpose the date to the selected timezone\n const dateWithTimezone = transpose(dateToUserTz, tzDateWithUTC)\n\n setValue(dateWithTimezone.toISOString() || null)\n } else {\n setValue(incomingDate?.toISOString() || null)\n }\n }\n },\n [readOnly, setValue, timezone, selectedTimezone],\n )\n\n const onChangeTimezone = useCallback(\n (timezone: string) => {\n if (timezonePath) {\n dispatchFields({\n type: 'UPDATE',\n path: timezonePath,\n value: timezone,\n })\n\n setModified(true)\n }\n },\n [dispatchFields, setModified, timezonePath],\n )\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && `${baseClass}--has-error`,\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={<FieldLabel label={label} localized={localized} required={required} />}\n />\n <div className={`${fieldBaseClass}__wrap`} id={`field-${path.replace(/\\./g, '__')}`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <DatePickerField\n {...datePickerProps}\n onChange={onChange}\n overrides={{\n ...datePickerProps?.overrides,\n }}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={readOnly}\n value={displayedValue}\n />\n {timezone && supportedTimezones.length > 0 && (\n <TimezonePicker\n id={`${path}-timezone-picker`}\n onChange={onChangeTimezone}\n options={supportedTimezones}\n required={required}\n selectedTimezone={selectedTimezone}\n />\n )}\n\n {AfterInput}\n </div>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const DateTimeField = withCondition(DateTimeFieldComponent)\n"],"mappings":"AAAA;;;AAGA,SAASA,UAAA,IAAcC,MAAM,QAAQ;AACrC,SAASC,cAAc,QAAQ;AAC/B,SAASC,SAAS,QAAQ;AAC1B,SAASC,WAAW,EAAEC,OAAO,QAAQ;AAErC,SAASC,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,OAAO,EAAEC,aAAa,QAAQ;AACvC,SAASC,QAAQ,QAAQ;AACzB,OAAO;AACP,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,MAAMC,SAAA,GAAY;AAElB,MAAMC,sBAAA,GAAoDC,KAAA;EACxD,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC,IAAA,EAAMC,eAAe;QAAEC,WAAW;QAAEC;MAAW,CAAE,GAAG,CAAC,CAAC;MAC1EC,KAAK;MACLC,SAAS;MACTC,QAAQ;MACRC;IAAQ,CACT;IACDC,IAAI;IACJC,QAAQ;IACRC;EAAQ,CACT,GAAGd,KAAA;EAEJ;EACA,MAAMe,YAAA,GAAeC,IAAA,CAAKC,cAAc,GAAGC,eAAe,GAAGC,QAAQ;EAErE,MAAM;IAAEC;EAAM,CAAE,GAAG1B,SAAA;EACnB,M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