@payloadcms/ui 3.0.0-beta.86 → 3.0.0-beta.88
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/Banner/index.d.ts +2 -2
- package/dist/elements/Banner/index.d.ts.map +1 -1
- package/dist/elements/Banner/index.js.map +1 -1
- package/dist/elements/FieldSelect/index.js +1 -0
- package/dist/elements/FieldSelect/index.js.map +1 -1
- package/dist/elements/ListDrawer/DrawerContent.js +1 -0
- package/dist/elements/ListDrawer/DrawerContent.js.map +1 -1
- package/dist/elements/Table/DefaultCell/index.js +1 -1
- package/dist/elements/Table/DefaultCell/index.js.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.js +1 -0
- package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
- package/dist/elements/Upload/index.js +1 -0
- package/dist/elements/Upload/index.js.map +1 -1
- package/dist/elements/ViewDescription/index.d.ts +5 -5
- package/dist/elements/ViewDescription/index.d.ts.map +1 -1
- package/dist/elements/ViewDescription/index.js +1 -1
- package/dist/elements/ViewDescription/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 +19 -19
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +3 -3
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +3 -0
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js +3 -0
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Checkbox/Input.d.ts +5 -3
- package/dist/fields/Checkbox/Input.d.ts.map +1 -1
- package/dist/fields/Checkbox/Input.js +2 -0
- package/dist/fields/Checkbox/Input.js.map +1 -1
- package/dist/fields/Checkbox/index.d.ts.map +1 -1
- package/dist/fields/Checkbox/index.js +2 -0
- package/dist/fields/Checkbox/index.js.map +1 -1
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js +3 -0
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/fields/Collapsible/index.js +1 -0
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/ConfirmPassword/index.d.ts.map +1 -1
- package/dist/fields/ConfirmPassword/index.js +2 -0
- package/dist/fields/ConfirmPassword/index.js.map +1 -1
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js +3 -0
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Email/index.d.ts.map +1 -1
- package/dist/fields/Email/index.js +4 -1
- package/dist/fields/Email/index.js.map +1 -1
- package/dist/fields/FieldDescription/index.d.ts +2 -3
- package/dist/fields/FieldDescription/index.d.ts.map +1 -1
- package/dist/fields/FieldDescription/index.js.map +1 -1
- package/dist/fields/FieldError/index.d.ts +2 -3
- package/dist/fields/FieldError/index.d.ts.map +1 -1
- package/dist/fields/FieldError/index.js.map +1 -1
- package/dist/fields/FieldLabel/index.d.ts +2 -3
- package/dist/fields/FieldLabel/index.d.ts.map +1 -1
- package/dist/fields/FieldLabel/index.js.map +1 -1
- package/dist/fields/Group/index.d.ts.map +1 -1
- package/dist/fields/Group/index.js +1 -0
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +3 -0
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Number/index.d.ts.map +1 -1
- package/dist/fields/Number/index.js +3 -0
- package/dist/fields/Number/index.js.map +1 -1
- package/dist/fields/Password/input.d.ts.map +1 -1
- package/dist/fields/Password/input.js +33 -29
- package/dist/fields/Password/input.js.map +1 -1
- package/dist/fields/Password/types.d.ts +7 -3
- package/dist/fields/Password/types.d.ts.map +1 -1
- package/dist/fields/Password/types.js.map +1 -1
- package/dist/fields/Point/index.d.ts.map +1 -1
- package/dist/fields/Point/index.js +3 -0
- package/dist/fields/Point/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.d.ts.map +1 -1
- package/dist/fields/RadioGroup/index.js +3 -0
- package/dist/fields/RadioGroup/index.js.map +1 -1
- package/dist/fields/Relationship/index.d.ts.map +1 -1
- package/dist/fields/Relationship/index.js +3 -0
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/Select/Input.d.ts +3 -1
- package/dist/fields/Select/Input.d.ts.map +1 -1
- package/dist/fields/Select/Input.js +60 -55
- package/dist/fields/Select/Input.js.map +1 -1
- package/dist/fields/Select/index.d.ts.map +1 -1
- package/dist/fields/Select/index.js +1 -0
- package/dist/fields/Select/index.js.map +1 -1
- package/dist/fields/Tabs/index.js +2 -1
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/Text/Input.d.ts.map +1 -1
- package/dist/fields/Text/Input.js +45 -40
- package/dist/fields/Text/Input.js.map +1 -1
- package/dist/fields/Text/index.d.ts.map +1 -1
- package/dist/fields/Text/index.js +1 -0
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Text/types.d.ts +3 -1
- package/dist/fields/Text/types.d.ts.map +1 -1
- package/dist/fields/Text/types.js.map +1 -1
- package/dist/fields/Textarea/Input.d.ts.map +1 -1
- package/dist/fields/Textarea/Input.js +39 -34
- package/dist/fields/Textarea/Input.js.map +1 -1
- package/dist/fields/Textarea/index.d.ts.map +1 -1
- package/dist/fields/Textarea/index.js +6 -0
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/Textarea/types.d.ts +6 -4
- package/dist/fields/Textarea/types.d.ts.map +1 -1
- package/dist/fields/Textarea/types.js.map +1 -1
- package/dist/fields/Upload/Input.d.ts +6 -4
- package/dist/fields/Upload/Input.d.ts.map +1 -1
- package/dist/fields/Upload/Input.js +58 -52
- package/dist/fields/Upload/Input.js.map +1 -1
- package/dist/fields/Upload/index.d.ts.map +1 -1
- package/dist/fields/Upload/index.js +6 -0
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/forms/RowLabel/types.d.ts +2 -2
- package/dist/forms/RowLabel/types.d.ts.map +1 -1
- package/dist/forms/RowLabel/types.js.map +1 -1
- package/dist/providers/Config/createClientConfig/collections.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/collections.js +12 -4
- package/dist/providers/Config/createClientConfig/collections.js.map +1 -1
- package/dist/providers/Config/createClientConfig/fields.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/fields.js +19 -14
- package/dist/providers/Config/createClientConfig/fields.js.map +1 -1
- package/dist/providers/Config/createClientConfig/getCreateMappedComponent.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/getCreateMappedComponent.js +10 -4
- package/dist/providers/Config/createClientConfig/getCreateMappedComponent.js.map +1 -1
- package/dist/providers/Config/createClientConfig/globals.d.ts.map +1 -1
- package/dist/providers/Config/createClientConfig/globals.js +6 -2
- package/dist/providers/Config/createClientConfig/globals.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","useCallback","useEffect","useState","useFieldProps","useField","withCondition","useConfig","useLocale","isFieldRTL","TextInput","TextFieldComponent","props","$","field","t0","inputRef","readOnly","readOnlyFromTopLevelProps","validate","name","_path","pathFromProps","admin","t1","hasMany","label","localized","maxLength","maxRows","minLength","minRows","required","t2","undefined","className","description","placeholder","readOnlyFromAdmin","rtl","style","width","readOnlyFromProps","locale","config","t3","localization","localizationConfig","t4","value","options","memoizedValidate","path","pathFromContext","readOnlyFromContext","t5","t6","formInitializing","formProcessing","setValue","showError","value_0","disabled","renderRTL","fieldLocalized","fieldRTL","t7","Symbol","for","valueToRender","setValueToRender","t8","selectedOption","newValue","Array","isArray","map","option","handleHasManyChange","t9","t10","val","index","id","toString","t11","e","target","_jsx","Description","components","Error","Label","afterInput","beforeInput","onChange","TextField"],"sources":["../../../src/fields/Text/index.tsx"],"sourcesContent":["'use client'\nimport type { TextFieldProps } from 'payload'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { TextInputProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextInput } from './Input.js'\nimport './index.scss'\n\nexport { TextInput, TextInputProps }\n\nconst TextFieldComponent: React.FC<TextFieldProps> = (props) => {\n const {\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n rtl,\n style,\n width,\n } = {},\n hasMany,\n label,\n localized,\n maxLength,\n maxRows,\n minLength,\n minRows,\n required,\n },\n inputRef,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const locale = useLocale()\n\n const {\n config: { localization: localizationConfig },\n } = useConfig()\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, minLength, maxLength, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const renderRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localizationConfig || undefined,\n })\n\n const [valueToRender, setValueToRender] = useState<\n { id: string; label: string; value: { value: number } }[]\n >([]) // Only for hasMany\n\n const handleHasManyChange = useCallback(\n (selectedOption) => {\n if (!disabled) {\n let newValue\n if (!selectedOption) {\n newValue = []\n } else if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => option.value?.value || option.value)\n } else {\n newValue = [selectedOption.value?.value || selectedOption.value]\n }\n\n setValue(newValue)\n }\n },\n [disabled, setValue],\n )\n\n // useEffect update valueToRender:\n useEffect(() => {\n if (hasMany && Array.isArray(value)) {\n setValueToRender(\n value.map((val, index) => {\n return {\n id: `${val}${index}`, // append index to avoid duplicate keys but allow duplicate numbers\n label: `${val}`,\n value: {\n // React-select automatically uses \"label-value\" as a key, so we will get that react duplicate key warning if we just pass in the value as multiple values can be the same. So we need to append the index to the toString() of the value to avoid that warning, as it uses that as the key.\n toString: () => `${val}${index}`,\n value: val?.value || val,\n },\n }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <TextInput\n Description={field?.admin?.components?.Description}\n Error={field?.admin?.components?.Error}\n Label={field?.admin?.components?.Label}\n afterInput={field?.admin?.components?.afterInput}\n beforeInput={field?.admin?.components?.beforeInput}\n className={className}\n description={description}\n hasMany={hasMany}\n inputRef={inputRef}\n label={label}\n maxRows={maxRows}\n minRows={minRows}\n onChange={\n hasMany\n ? handleHasManyChange\n : (e) => {\n setValue(e.target.value)\n }\n }\n path={path}\n placeholder={placeholder}\n readOnly={disabled}\n required={required}\n rtl={renderRTL}\n showError={showError}\n style={style}\n value={(value as string) || ''}\n valueToRender={valueToRender as Option[]}\n width={width}\n />\n )\n}\n\nexport const TextField = withCondition(TextFieldComponent)\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAKxD,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,UAAU,QAAQ;AAC3B,SAASC,SAAS,QAAQ;AAC1B,OAAO;A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AoB,aAAA;IAAA5B;EAAA,C;CAKlC;AAEA,OAAO,MAAMuD,SAAA,GAAY1F,aAAA,CAAcK,kBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","useCallback","useEffect","useState","useFieldProps","useField","withCondition","useConfig","useLocale","isFieldRTL","TextInput","TextFieldComponent","props","$","field","t0","inputRef","readOnly","readOnlyFromTopLevelProps","validate","name","_path","pathFromProps","admin","t1","hasMany","label","localized","maxLength","maxRows","minLength","minRows","required","t2","undefined","className","description","placeholder","readOnlyFromAdmin","rtl","style","width","readOnlyFromProps","locale","config","t3","localization","localizationConfig","t4","value","options","memoizedValidate","path","pathFromContext","readOnlyFromContext","t5","t6","formInitializing","formProcessing","setValue","showError","value_0","disabled","renderRTL","fieldLocalized","fieldRTL","t7","Symbol","for","valueToRender","setValueToRender","t8","selectedOption","newValue","Array","isArray","map","option","handleHasManyChange","t9","t10","val","index","id","toString","t11","e","target","_jsx","Description","components","Error","Label","afterInput","beforeInput","onChange","TextField"],"sources":["../../../src/fields/Text/index.tsx"],"sourcesContent":["'use client'\nimport type { TextFieldProps } from 'payload'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { TextInputProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useLocale } from '../../providers/Locale/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextInput } from './Input.js'\nimport './index.scss'\n\nexport { TextInput, TextInputProps }\n\nconst TextFieldComponent: React.FC<TextFieldProps> = (props) => {\n const {\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n rtl,\n style,\n width,\n } = {},\n hasMany,\n label,\n localized,\n maxLength,\n maxRows,\n minLength,\n minRows,\n required,\n },\n inputRef,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const locale = useLocale()\n\n const {\n config: { localization: localizationConfig },\n } = useConfig()\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, minLength, maxLength, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const renderRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localizationConfig || undefined,\n })\n\n const [valueToRender, setValueToRender] = useState<\n { id: string; label: string; value: { value: number } }[]\n >([]) // Only for hasMany\n\n const handleHasManyChange = useCallback(\n (selectedOption) => {\n if (!disabled) {\n let newValue\n if (!selectedOption) {\n newValue = []\n } else if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => option.value?.value || option.value)\n } else {\n newValue = [selectedOption.value?.value || selectedOption.value]\n }\n\n setValue(newValue)\n }\n },\n [disabled, setValue],\n )\n\n // useEffect update valueToRender:\n useEffect(() => {\n if (hasMany && Array.isArray(value)) {\n setValueToRender(\n value.map((val, index) => {\n return {\n id: `${val}${index}`, // append index to avoid duplicate keys but allow duplicate numbers\n label: `${val}`,\n value: {\n // React-select automatically uses \"label-value\" as a key, so we will get that react duplicate key warning if we just pass in the value as multiple values can be the same. So we need to append the index to the toString() of the value to avoid that warning, as it uses that as the key.\n toString: () => `${val}${index}`,\n value: val?.value || val,\n },\n }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <TextInput\n Description={field?.admin?.components?.Description}\n Error={field?.admin?.components?.Error}\n Label={field?.admin?.components?.Label}\n afterInput={field?.admin?.components?.afterInput}\n beforeInput={field?.admin?.components?.beforeInput}\n className={className}\n description={description}\n field={field}\n hasMany={hasMany}\n inputRef={inputRef}\n label={label}\n maxRows={maxRows}\n minRows={minRows}\n onChange={\n hasMany\n ? handleHasManyChange\n : (e) => {\n setValue(e.target.value)\n }\n }\n path={path}\n placeholder={placeholder}\n readOnly={disabled}\n required={required}\n rtl={renderRTL}\n showError={showError}\n style={style}\n value={(value as string) || ''}\n valueToRender={valueToRender as Option[]}\n width={width}\n />\n )\n}\n\nexport const TextField = withCondition(TextFieldComponent)\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ;AAKxD,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,SAASC,SAAS,QAAQ;AAC1B,SAASC,UAAU,QAAQ;AAC3B,SAASC,SAAS,QAAQ;AAC1B,OAAO;AAEP,SAASA,SAAS;AAElB,MAAMC,kBAAA,GAA+CC,KAAA;EAAA,MAAAC,CAAA,GAAAd,EAAA;EACnD;IAAAe,KAAA;IAAAA,KAAA,EAAAC,EAAA;IAAAC,QAAA;IAAAC,QAAA,EAAAC,yBAAA;IAAAC;EAAA,IA0BIP,KAAA;EAxBK;IAAAQ,IAAA;IAAAC,KAAA,EAAAC,aAAA;IAAAC,KAAA,EAAAC,EAAA;IAAAC,OAAA;IAAAC,KAAA;IAAAC,SAAA;IAAAC,SAAA;IAAAC,OAAA;IAAAC,SAAA;IAAAC,OAAA;IAAAC;EAAA,IAAAjB,EAoBN;EAAA,IAAAkB,EAAA;EAAA,IAAApB,CAAA,QAAAW,EAAA;IAjBQS,EAAA,GAAAT,EAQD,KAAAU,SAAA,QARCV,EAQD;IAAAX,CAAA,MAAAW,EAAA;IAAAX,CAAA,MAAAoB,EAAA;EAAA;IAAAA,EA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AAA;EAAA;EAAA,OAnBR2E,IAAA,CAAA9E,SAAA;IAAA+E,WAAA,EACe3E,KAAA,EAAAS,KAAA,EAAAmE,UAAA,EAAAD,WAAA;IAAAE,KAAA,EACN7E,KAAA,EAAAS,KAAA,EAAAmE,UAAA,EAAAC,KAAA;IAAAC,KAAA,EACA9E,KAAA,EAAAS,KAAA,EAAAmE,UAAA,EAAAE,KAAA;IAAAC,UAAA,EACK/E,KAAA,EAAAS,KAAA,EAAAmE,UAAA,EAAAG,UAAA;IAAAC,WAAA,EACChF,KAAA,EAAAS,KAAA,EAAAmE,UAAA,EAAAI,WAAA;IAAA3D,SAAA;IAAAC,WAAA;IAAAtB,KAAA;IAAAW,OAAA;IAAAT,QAAA;IAAAU,KAAA;IAAAG,OAAA;IAAAE,OAAA;IAAAgE,QAAA,EAUXV,GAII;IAAAjC,IAAA;IAAAf,WAAA;IAAApB,QAAA,EAII6C,QAAA;IAAA9B,QAAA;IAAAO,GAAA,EAELwB,SAAA;IAAAH,SAAA;IAAApB,KAAA;IAAAS,KAAA,EAGEA,OAAC,IAAoB;IAAAoB,aAAA;IAAA5B;EAAA,C;CAKlC;AAEA,OAAO,MAAMuD,SAAA,GAAY1F,aAAA,CAAcK,kBAAA","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { MappedComponent, StaticDescription, StaticLabel } from 'payload';
|
|
1
|
+
import type { MappedComponent, StaticDescription, StaticLabel, TextFieldClient } from 'payload';
|
|
2
2
|
import type { ChangeEvent } from 'react';
|
|
3
3
|
import type React from 'react';
|
|
4
|
+
import type { MarkOptional } from 'ts-essentials';
|
|
4
5
|
import type { Option, ReactSelectAdapterProps } from '../../elements/ReactSelect/types.js';
|
|
5
6
|
export type SharedTextFieldProps = {
|
|
6
7
|
readonly hasMany?: false;
|
|
@@ -19,6 +20,7 @@ export type TextInputProps = {
|
|
|
19
20
|
readonly description?: StaticDescription;
|
|
20
21
|
readonly descriptionProps?: Record<string, unknown>;
|
|
21
22
|
readonly errorProps?: Record<string, unknown>;
|
|
23
|
+
readonly field?: MarkOptional<TextFieldClient, 'type'>;
|
|
22
24
|
readonly inputRef?: React.RefObject<HTMLInputElement>;
|
|
23
25
|
readonly label: StaticLabel;
|
|
24
26
|
readonly labelProps?: Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Text/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Text/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAE1F,MAAM,MAAM,oBAAoB,GAC5B;IACE,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAA;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;CAC/D,GACD;IACE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAA;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,uBAAuB,CAAC,UAAU,CAAC,CAAA;CACxD,CAAA;AAEL,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,CAAA;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAA;IACh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5B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB,GAAG,oBAAoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/fields/Text/types.ts"],"sourcesContent":["import type { MappedComponent, StaticDescription, StaticLabel } from 'payload'\nimport type { ChangeEvent } from 'react'\nimport type React from 'react'\n\nimport type { Option, ReactSelectAdapterProps } from '../../elements/ReactSelect/types.js'\n\nexport type SharedTextFieldProps =\n | {\n readonly hasMany?: false\n readonly onChange?: (e: ChangeEvent<HTMLInputElement>) => void\n }\n | {\n readonly hasMany?: true\n readonly onChange?: ReactSelectAdapterProps['onChange']\n }\n\nexport type TextInputProps = {\n readonly Description?: MappedComponent\n readonly Error?: MappedComponent\n readonly Label?: MappedComponent\n readonly afterInput?: MappedComponent[]\n readonly beforeInput?: MappedComponent[]\n readonly className?: string\n readonly description?: StaticDescription\n readonly descriptionProps?: Record<string, unknown>\n readonly errorProps?: Record<string, unknown>\n readonly inputRef?: React.RefObject<HTMLInputElement>\n readonly label: StaticLabel\n readonly labelProps?: Record<string, unknown>\n readonly maxRows?: number\n readonly minRows?: number\n readonly onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>\n readonly path: string\n readonly placeholder?: Record<string, string> | string\n readonly readOnly?: boolean\n readonly required?: boolean\n readonly rtl?: boolean\n readonly showError?: boolean\n readonly style?: React.CSSProperties\n readonly value?: string\n readonly valueToRender?: Option[]\n readonly width?: string\n} & SharedTextFieldProps\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/fields/Text/types.ts"],"sourcesContent":["import type { MappedComponent, StaticDescription, StaticLabel, TextFieldClient } from 'payload'\nimport type { ChangeEvent } from 'react'\nimport type React from 'react'\nimport type { MarkOptional } from 'ts-essentials'\n\nimport type { Option, ReactSelectAdapterProps } from '../../elements/ReactSelect/types.js'\n\nexport type SharedTextFieldProps =\n | {\n readonly hasMany?: false\n readonly onChange?: (e: ChangeEvent<HTMLInputElement>) => void\n }\n | {\n readonly hasMany?: true\n readonly onChange?: ReactSelectAdapterProps['onChange']\n }\n\nexport type TextInputProps = {\n readonly Description?: MappedComponent\n readonly Error?: MappedComponent\n readonly Label?: MappedComponent\n readonly afterInput?: MappedComponent[]\n readonly beforeInput?: MappedComponent[]\n readonly className?: string\n readonly description?: StaticDescription\n readonly descriptionProps?: Record<string, unknown>\n readonly errorProps?: Record<string, unknown>\n readonly field?: MarkOptional<TextFieldClient, 'type'>\n readonly inputRef?: React.RefObject<HTMLInputElement>\n readonly label: StaticLabel\n readonly labelProps?: Record<string, unknown>\n readonly maxRows?: number\n readonly minRows?: number\n readonly onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>\n readonly path: string\n readonly placeholder?: Record<string, string> | string\n readonly readOnly?: boolean\n readonly required?: boolean\n readonly rtl?: boolean\n readonly showError?: boolean\n readonly style?: React.CSSProperties\n readonly value?: string\n readonly valueToRender?: Option[]\n readonly width?: string\n} & SharedTextFieldProps\n"],"mappings":"AAiBA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQpD,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQpD,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAiFtD,CAAA"}
|
|
@@ -12,7 +12,7 @@ import { FieldLabel } from '../FieldLabel/index.js';
|
|
|
12
12
|
import { fieldBaseClass } from '../shared/index.js';
|
|
13
13
|
import './index.scss';
|
|
14
14
|
export const TextareaInput = props => {
|
|
15
|
-
const $ = _c(
|
|
15
|
+
const $ = _c(34);
|
|
16
16
|
const {
|
|
17
17
|
Description,
|
|
18
18
|
Error,
|
|
@@ -23,6 +23,7 @@ export const TextareaInput = props => {
|
|
|
23
23
|
description,
|
|
24
24
|
descriptionProps,
|
|
25
25
|
errorProps,
|
|
26
|
+
field,
|
|
26
27
|
label,
|
|
27
28
|
labelProps,
|
|
28
29
|
onChange,
|
|
@@ -54,30 +55,30 @@ export const TextareaInput = props => {
|
|
|
54
55
|
}
|
|
55
56
|
const t3 = t2.join(" ");
|
|
56
57
|
let t4;
|
|
57
|
-
if ($[4] !== style || $[5] !== width || $[6] !== labelProps || $[7] !== Label || $[8] !==
|
|
58
|
+
if ($[4] !== style || $[5] !== width || $[6] !== labelProps || $[7] !== Label || $[8] !== field || $[9] !== label || $[10] !== required || $[11] !== errorProps || $[12] !== Error || $[13] !== path || $[14] !== beforeInput || $[15] !== value || $[16] !== placeholder || $[17] !== i18n || $[18] !== rtl || $[19] !== readOnly || $[20] !== onChange || $[21] !== rows || $[22] !== afterInput || $[23] !== descriptionProps || $[24] !== Description || $[25] !== description || $[26] !== t3) {
|
|
58
59
|
let t5;
|
|
59
|
-
if ($[
|
|
60
|
+
if ($[28] !== labelProps) {
|
|
60
61
|
t5 = labelProps || {};
|
|
61
|
-
$[
|
|
62
|
-
$[
|
|
62
|
+
$[28] = labelProps;
|
|
63
|
+
$[29] = t5;
|
|
63
64
|
} else {
|
|
64
|
-
t5 = $[
|
|
65
|
+
t5 = $[29];
|
|
65
66
|
}
|
|
66
67
|
let t6;
|
|
67
|
-
if ($[
|
|
68
|
+
if ($[30] !== errorProps) {
|
|
68
69
|
t6 = errorProps || {};
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
70
|
+
$[30] = errorProps;
|
|
71
|
+
$[31] = t6;
|
|
71
72
|
} else {
|
|
72
|
-
t6 = $[
|
|
73
|
+
t6 = $[31];
|
|
73
74
|
}
|
|
74
75
|
let t7;
|
|
75
|
-
if ($[
|
|
76
|
+
if ($[32] !== descriptionProps) {
|
|
76
77
|
t7 = descriptionProps || {};
|
|
77
|
-
$[
|
|
78
|
-
$[
|
|
78
|
+
$[32] = descriptionProps;
|
|
79
|
+
$[33] = t7;
|
|
79
80
|
} else {
|
|
80
|
-
t7 = $[
|
|
81
|
+
t7 = $[33];
|
|
81
82
|
}
|
|
82
83
|
t4 = _jsxs("div", {
|
|
83
84
|
className: t3,
|
|
@@ -87,6 +88,7 @@ export const TextareaInput = props => {
|
|
|
87
88
|
},
|
|
88
89
|
children: [_jsx(FieldLabel, {
|
|
89
90
|
Label,
|
|
91
|
+
field,
|
|
90
92
|
label,
|
|
91
93
|
required,
|
|
92
94
|
...t5
|
|
@@ -94,6 +96,7 @@ export const TextareaInput = props => {
|
|
|
94
96
|
className: `${fieldBaseClass}__wrap`,
|
|
95
97
|
children: [_jsx(FieldError, {
|
|
96
98
|
CustomError: Error,
|
|
99
|
+
field,
|
|
97
100
|
path,
|
|
98
101
|
...t6
|
|
99
102
|
}), _jsx(RenderComponent, {
|
|
@@ -123,6 +126,7 @@ export const TextareaInput = props => {
|
|
|
123
126
|
}), _jsx(FieldDescription, {
|
|
124
127
|
Description,
|
|
125
128
|
description,
|
|
129
|
+
field,
|
|
126
130
|
...t7
|
|
127
131
|
})]
|
|
128
132
|
})]
|
|
@@ -131,27 +135,28 @@ export const TextareaInput = props => {
|
|
|
131
135
|
$[5] = width;
|
|
132
136
|
$[6] = labelProps;
|
|
133
137
|
$[7] = Label;
|
|
134
|
-
$[8] =
|
|
135
|
-
$[9] =
|
|
136
|
-
$[10] =
|
|
137
|
-
$[11] =
|
|
138
|
-
$[12] =
|
|
139
|
-
$[13] =
|
|
140
|
-
$[14] =
|
|
141
|
-
$[15] =
|
|
142
|
-
$[16] =
|
|
143
|
-
$[17] =
|
|
144
|
-
$[18] =
|
|
145
|
-
$[19] =
|
|
146
|
-
$[20] =
|
|
147
|
-
$[21] =
|
|
148
|
-
$[22] =
|
|
149
|
-
$[23] =
|
|
150
|
-
$[24] =
|
|
151
|
-
$[25] =
|
|
152
|
-
$[26] =
|
|
138
|
+
$[8] = field;
|
|
139
|
+
$[9] = label;
|
|
140
|
+
$[10] = required;
|
|
141
|
+
$[11] = errorProps;
|
|
142
|
+
$[12] = Error;
|
|
143
|
+
$[13] = path;
|
|
144
|
+
$[14] = beforeInput;
|
|
145
|
+
$[15] = value;
|
|
146
|
+
$[16] = placeholder;
|
|
147
|
+
$[17] = i18n;
|
|
148
|
+
$[18] = rtl;
|
|
149
|
+
$[19] = readOnly;
|
|
150
|
+
$[20] = onChange;
|
|
151
|
+
$[21] = rows;
|
|
152
|
+
$[22] = afterInput;
|
|
153
|
+
$[23] = descriptionProps;
|
|
154
|
+
$[24] = Description;
|
|
155
|
+
$[25] = description;
|
|
156
|
+
$[26] = t3;
|
|
157
|
+
$[27] = t4;
|
|
153
158
|
} else {
|
|
154
|
-
t4 = $[
|
|
159
|
+
t4 = $[27];
|
|
155
160
|
}
|
|
156
161
|
return t4;
|
|
157
162
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","names":["c","_c","getTranslation","React","RenderComponent","useTranslation","FieldDescription","FieldError","FieldLabel","fieldBaseClass","TextareaInput","props","$","Description","Error","Label","afterInput","beforeInput","className","description","descriptionProps","errorProps","label","labelProps","onChange","path","placeholder","readOnly","required","rows","rtl","showError","style","value","width","i18n","t0","t1","t2","filter","Boolean","t3","join","t4","t5","t6","t7","_jsxs","children","_jsx","CustomError","mappedComponent","htmlFor","replace","disabled","id","name"],"sources":["../../../src/fields/Textarea/Input.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { TextAreaInputProps } from './types.js'\n\nimport { RenderComponent } from '../../providers/Config/RenderComponent.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport const TextareaInput: React.FC<TextAreaInputProps> = (props) => {\n const {\n Description,\n Error,\n Label,\n afterInput,\n beforeInput,\n className,\n description,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n onChange,\n path,\n placeholder,\n readOnly,\n required,\n rows,\n rtl,\n showError,\n style,\n value,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'textarea',\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel
|
|
1
|
+
{"version":3,"file":"Input.js","names":["c","_c","getTranslation","React","RenderComponent","useTranslation","FieldDescription","FieldError","FieldLabel","fieldBaseClass","TextareaInput","props","$","Description","Error","Label","afterInput","beforeInput","className","description","descriptionProps","errorProps","field","label","labelProps","onChange","path","placeholder","readOnly","required","rows","rtl","showError","style","value","width","i18n","t0","t1","t2","filter","Boolean","t3","join","t4","t5","t6","t7","_jsxs","children","_jsx","CustomError","mappedComponent","htmlFor","replace","disabled","id","name"],"sources":["../../../src/fields/Textarea/Input.tsx"],"sourcesContent":["'use client'\nimport { getTranslation } from '@payloadcms/translations'\nimport React from 'react'\n\nimport type { TextAreaInputProps } from './types.js'\n\nimport { RenderComponent } from '../../providers/Config/RenderComponent.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nexport const TextareaInput: React.FC<TextAreaInputProps> = (props) => {\n const {\n Description,\n Error,\n Label,\n afterInput,\n beforeInput,\n className,\n description,\n descriptionProps,\n errorProps,\n field,\n label,\n labelProps,\n onChange,\n path,\n placeholder,\n readOnly,\n required,\n rows,\n rtl,\n showError,\n style,\n value,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'textarea',\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n Label={Label}\n field={field}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <FieldError CustomError={Error} field={field} path={path} {...(errorProps || {})} />\n <RenderComponent mappedComponent={beforeInput} />\n <label className=\"textarea-outer\" htmlFor={`field-${path.replace(/\\./g, '__')}`}>\n <div className=\"textarea-inner\">\n <div className=\"textarea-clone\" data-value={value || placeholder || ''} />\n <textarea\n className=\"textarea-element\"\n data-rtl={rtl}\n disabled={readOnly}\n id={`field-${path.replace(/\\./g, '__')}`}\n name={path}\n onChange={onChange}\n placeholder={getTranslation(placeholder, i18n)}\n rows={rows}\n value={value || ''}\n />\n </div>\n </label>\n <RenderComponent mappedComponent={afterInput} />\n <FieldDescription\n Description={Description}\n description={description}\n field={field}\n {...(descriptionProps || {})}\n />\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,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,EAAE,MAAM,YAAY,CAAA;AAQpD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAA2B,MAAM,SAAS,CAAA;AAG1E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAQpD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAA;AA8F5C,eAAO,MAAM,aAAa,8BAAwC,CAAA"}
|
|
@@ -16,8 +16,11 @@ export { TextareaInput };
|
|
|
16
16
|
const TextareaFieldComponent = props => {
|
|
17
17
|
const $ = _c(12);
|
|
18
18
|
const {
|
|
19
|
+
descriptionProps,
|
|
20
|
+
errorProps,
|
|
19
21
|
field,
|
|
20
22
|
field: t0,
|
|
23
|
+
labelProps,
|
|
21
24
|
locale,
|
|
22
25
|
readOnly: readOnlyFromTopLevelProps,
|
|
23
26
|
validate
|
|
@@ -131,7 +134,10 @@ const TextareaFieldComponent = props => {
|
|
|
131
134
|
beforeInput: field?.admin?.components?.beforeInput,
|
|
132
135
|
className,
|
|
133
136
|
description,
|
|
137
|
+
descriptionProps,
|
|
138
|
+
errorProps,
|
|
134
139
|
label,
|
|
140
|
+
labelProps,
|
|
135
141
|
onChange: t7,
|
|
136
142
|
path,
|
|
137
143
|
placeholder: getTranslation(placeholder, i18n),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","getTranslation","React","useCallback","useFieldProps","useField","withCondition","useConfig","useTranslation","isFieldRTL","TextareaInput","TextareaFieldComponent","props","$","field","t0","locale","readOnly","readOnlyFromTopLevelProps","validate","name","_path","pathFromProps","admin","t1","label","localized","maxLength","minLength","required","t2","undefined","className","description","placeholder","readOnlyFromAdmin","rows","rtl","style","width","readOnlyFromProps","i18n","config","t3","localization","isRTL","fieldLocalized","fieldRTL","localizationConfig","t4","value","options","memoizedValidate","path","pathFromContext","readOnlyFromContext","t5","t6","formInitializing","formProcessing","setValue","showError","value_0","disabled","t7","e","target","_jsx","Description","components","Error","Label","afterInput","beforeInput","onChange","TextareaField"],"sources":["../../../src/fields/Textarea/index.tsx"],"sourcesContent":["'use client'\nimport type { TextareaFieldProps, TextareaFieldValidation } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport type { TextAreaInputProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextareaInput } from './Input.js'\nimport './index.scss'\n\nexport { TextAreaInputProps, TextareaInput }\n\nconst TextareaFieldComponent: React.FC<TextareaFieldProps> = (props) => {\n const {\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n rows,\n rtl,\n style,\n width,\n } = {},\n label,\n localized,\n maxLength,\n minLength,\n required,\n },\n locale,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const { i18n } = useTranslation()\n\n const {\n config: { localization },\n } = useConfig()\n\n const isRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localization || undefined,\n })\n\n const memoizedValidate: TextareaFieldValidation = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, required, maxLength, minLength],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField<string>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <TextareaInput\n Description={field?.admin?.components?.Description}\n Error={field?.admin?.components?.Error}\n Label={field?.admin?.components?.Label}\n afterInput={field?.admin?.components?.afterInput}\n beforeInput={field?.admin?.components?.beforeInput}\n className={className}\n description={description}\n label={label}\n onChange={(e) => {\n setValue(e.target.value)\n }}\n path={path}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={disabled}\n required={required}\n rows={rows}\n rtl={isRTL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n}\n\nexport const TextareaField = withCondition(TextareaFieldComponent)\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,QAAQ;AAInC,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,aAAa,QAAQ;AAC9B,OAAO;AAEP,SAA6BA,aAAa;AAE1C,MAAMC,sBAAA,GAAuDC,KAAA;EAAA,MAAAC,CAAA,GAAAb,EAAA;EAC3D;IAAAc,KAAA;IAAAA,KAAA,EAAAC,EAAA;IAAAC,MAAA;IAAAC,QAAA,EAAAC,yBAAA;IAAAC;EAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","getTranslation","React","useCallback","useFieldProps","useField","withCondition","useConfig","useTranslation","isFieldRTL","TextareaInput","TextareaFieldComponent","props","$","descriptionProps","errorProps","field","t0","labelProps","locale","readOnly","readOnlyFromTopLevelProps","validate","name","_path","pathFromProps","admin","t1","label","localized","maxLength","minLength","required","t2","undefined","className","description","placeholder","readOnlyFromAdmin","rows","rtl","style","width","readOnlyFromProps","i18n","config","t3","localization","isRTL","fieldLocalized","fieldRTL","localizationConfig","t4","value","options","memoizedValidate","path","pathFromContext","readOnlyFromContext","t5","t6","formInitializing","formProcessing","setValue","showError","value_0","disabled","t7","e","target","_jsx","Description","components","Error","Label","afterInput","beforeInput","onChange","TextareaField"],"sources":["../../../src/fields/Textarea/index.tsx"],"sourcesContent":["'use client'\nimport type { TextareaFieldProps, TextareaFieldValidation } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport type { TextAreaInputProps } from './types.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { isFieldRTL } from '../shared/index.js'\nimport { TextareaInput } from './Input.js'\nimport './index.scss'\n\nexport { TextAreaInputProps, TextareaInput }\n\nconst TextareaFieldComponent: React.FC<TextareaFieldProps> = (props) => {\n const {\n descriptionProps,\n errorProps,\n field,\n field: {\n name,\n _path: pathFromProps,\n admin: {\n className,\n description,\n placeholder,\n readOnly: readOnlyFromAdmin,\n rows,\n rtl,\n style,\n width,\n } = {},\n label,\n localized,\n maxLength,\n minLength,\n required,\n },\n labelProps,\n locale,\n readOnly: readOnlyFromTopLevelProps,\n validate,\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const { i18n } = useTranslation()\n\n const {\n config: { localization },\n } = useConfig()\n\n const isRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localization || undefined,\n })\n\n const memoizedValidate: TextareaFieldValidation = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, maxLength, minLength, required })\n },\n [validate, required, maxLength, minLength],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField<string>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <TextareaInput\n Description={field?.admin?.components?.Description}\n Error={field?.admin?.components?.Error}\n Label={field?.admin?.components?.Label}\n afterInput={field?.admin?.components?.afterInput}\n beforeInput={field?.admin?.components?.beforeInput}\n className={className}\n description={description}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n label={label}\n labelProps={labelProps}\n onChange={(e) => {\n setValue(e.target.value)\n }}\n path={path}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={disabled}\n required={required}\n rows={rows}\n rtl={isRTL}\n showError={showError}\n style={style}\n value={value}\n width={width}\n />\n )\n}\n\nexport const TextareaField = withCondition(TextareaFieldComponent)\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,QAAQ;AAInC,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,SAAS,QAAQ;AAC1B,SAASC,cAAc,QAAQ;AAC/B,SAASC,UAAU,QAAQ;AAC3B,SAASC,aAAa,QAAQ;AAC9B,OAAO;AAEP,SAA6BA,aAAa;AAE1C,MAAMC,sBAAA,GAAuDC,KAAA;EAAA,MAAAC,CAAA,GAAAb,EAAA;EAC3D;IAAAc,gBAAA;IAAAC,UAAA;IAAAC,KAAA;IAAAA,KAAA,EAAAC,EAAA;IAAAC,UAAA;IAAAC,MAAA;IAAAC,QAAA,EAAAC,yBAAA;IAAAC;EAAA,IA2BIV,KAAA;EAvBK;IAAAW,IAAA;IAAA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,EACK3D,KAAA,EAAAU,KAAA,EAAA8C,UAAA,EAAAG,UAAA;IAAAC,WAAA,EACC5D,KAAA,EAAAU,KAAA,EAAA8C,UAAA,EAAAI,WAAA;IAAAzC,SAAA;IAAAC,WAAA;IAAAtB,gBAAA;IAAAC,UAAA;IAAAa,KAAA;IAAAV,UAAA;IAAA2D,QAAA,EAOHV,EAEV;IAAAX,IAAA;IAAAnB,WAAA,EAEapC,cAAA,CAAeoC,WAAA,EAAaO,IAAA;IAAAxB,QAAA,EAC/B8C,QAAA;IAAAlC,QAAA;IAAAO,IAAA;IAAAC,GAAA,EAGLQ,KAAA;IAAAgB,SAAA;IAAAvB,KAAA;IAAAY,KAAA,EAGEA,OAAA;IAAAX;EAAA,C;CAIb;AAEA,OAAO,MAAMoC,aAAA,GAAgBxE,aAAA,CAAcK,sBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { MappedComponent, StaticDescription, StaticLabel } from 'payload';
|
|
1
|
+
import type { FieldDescriptionClientProps, FieldErrorClientProps, FieldLabelClientProps, MappedComponent, StaticDescription, StaticLabel, TextareaFieldClient } from 'payload';
|
|
2
2
|
import type React from 'react';
|
|
3
|
+
import type { MarkOptional } from 'ts-essentials';
|
|
3
4
|
import { type ChangeEvent } from 'react';
|
|
4
5
|
export type TextAreaInputProps = {
|
|
5
6
|
readonly Description?: MappedComponent;
|
|
@@ -9,11 +10,12 @@ export type TextAreaInputProps = {
|
|
|
9
10
|
readonly beforeInput?: MappedComponent[];
|
|
10
11
|
readonly className?: string;
|
|
11
12
|
readonly description?: StaticDescription;
|
|
12
|
-
readonly descriptionProps?:
|
|
13
|
-
readonly errorProps?:
|
|
13
|
+
readonly descriptionProps?: FieldDescriptionClientProps<MarkOptional<TextareaFieldClient, 'type'>>;
|
|
14
|
+
readonly errorProps?: FieldErrorClientProps<MarkOptional<TextareaFieldClient, 'type'>>;
|
|
15
|
+
readonly field?: MarkOptional<TextareaFieldClient, 'type'>;
|
|
14
16
|
readonly inputRef?: React.RefObject<HTMLInputElement>;
|
|
15
17
|
readonly label: StaticLabel;
|
|
16
|
-
readonly labelProps?:
|
|
18
|
+
readonly labelProps?: FieldLabelClientProps<MarkOptional<TextareaFieldClient, 'type'>>;
|
|
17
19
|
readonly onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
18
20
|
readonly onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
|
|
19
21
|
readonly path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACpB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAA;AAExC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,CAAA;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAA;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAA;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,EAAE,CAAA;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,EAAE,CAAA;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAA;IACxC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,2BAA2B,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
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/fields/Textarea/types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/fields/Textarea/types.ts"],"sourcesContent":["import type {\n FieldDescriptionClientProps,\n FieldErrorClientProps,\n FieldLabelClientProps,\n MappedComponent,\n StaticDescription,\n StaticLabel,\n TextareaFieldClient,\n} from 'payload'\nimport type React from 'react'\nimport type { MarkOptional } from 'ts-essentials'\n\nimport { type ChangeEvent } from 'react'\n\nexport type TextAreaInputProps = {\n readonly Description?: MappedComponent\n readonly Error?: MappedComponent\n readonly Label?: MappedComponent\n readonly afterInput?: MappedComponent[]\n readonly beforeInput?: MappedComponent[]\n readonly className?: string\n readonly description?: StaticDescription\n readonly descriptionProps?: FieldDescriptionClientProps<MarkOptional<TextareaFieldClient, 'type'>>\n readonly errorProps?: FieldErrorClientProps<MarkOptional<TextareaFieldClient, 'type'>>\n readonly field?: MarkOptional<TextareaFieldClient, 'type'>\n readonly inputRef?: React.RefObject<HTMLInputElement>\n readonly label: StaticLabel\n readonly labelProps?: FieldLabelClientProps<MarkOptional<TextareaFieldClient, 'type'>>\n readonly onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void\n readonly onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>\n readonly path: string\n readonly placeholder?: string\n readonly readOnly?: boolean\n readonly required?: boolean\n readonly rows?: number\n readonly rtl?: boolean\n readonly showError?: boolean\n readonly style?: React.CSSProperties\n readonly value?: string\n readonly valueToRender?: string\n readonly width?: string\n}\n"],"mappings":"AAcA","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ClientCollectionConfig, FilterOptionsResult, MappedComponent, StaticDescription, StaticLabel, UploadField } from 'payload';
|
|
1
|
+
import type { ClientCollectionConfig, FieldDescriptionClientProps, FieldErrorClientProps, FieldLabelClientProps, FilterOptionsResult, MappedComponent, StaticDescription, StaticLabel, UploadField, UploadFieldClient } from 'payload';
|
|
2
|
+
import type { MarkOptional } from 'ts-essentials';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import './index.scss';
|
|
4
5
|
export type UploadInputProps = {
|
|
@@ -14,11 +15,12 @@ export type UploadInputProps = {
|
|
|
14
15
|
readonly collection?: ClientCollectionConfig;
|
|
15
16
|
readonly customUploadActions?: React.ReactNode[];
|
|
16
17
|
readonly description?: StaticDescription;
|
|
17
|
-
readonly descriptionProps?:
|
|
18
|
-
readonly errorProps?:
|
|
18
|
+
readonly descriptionProps?: FieldDescriptionClientProps<MarkOptional<UploadFieldClient, 'type'>>;
|
|
19
|
+
readonly errorProps?: FieldErrorClientProps<MarkOptional<UploadFieldClient, 'type'>>;
|
|
20
|
+
readonly field?: MarkOptional<UploadFieldClient, 'type'>;
|
|
19
21
|
readonly filterOptions?: FilterOptionsResult;
|
|
20
22
|
readonly label: StaticLabel;
|
|
21
|
-
readonly labelProps?:
|
|
23
|
+
readonly labelProps?: FieldLabelClientProps<MarkOptional<UploadFieldClient, 'type'>>;
|
|
22
24
|
readonly onChange?: (e: any) => void;
|
|
23
25
|
readonly readOnly?: boolean;
|
|
24
26
|
readonly relationTo?: UploadField['relationTo'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Upload/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,WAAW,
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/fields/Upload/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,iBAAiB,EAClB,MAAM,SAAS,CAAA;AACh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AE,OAAO,CAAA;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAuKlD,CAAA"}
|
|
@@ -16,7 +16,7 @@ import { fieldBaseClass } from '../shared/index.js';
|
|
|
16
16
|
import './index.scss';
|
|
17
17
|
const baseClass = 'upload';
|
|
18
18
|
export const UploadInput = props => {
|
|
19
|
-
const $ = _c(
|
|
19
|
+
const $ = _c(78);
|
|
20
20
|
const {
|
|
21
21
|
Description,
|
|
22
22
|
Error,
|
|
@@ -28,6 +28,7 @@ export const UploadInput = props => {
|
|
|
28
28
|
customUploadActions,
|
|
29
29
|
descriptionProps,
|
|
30
30
|
errorProps,
|
|
31
|
+
field,
|
|
31
32
|
filterOptions,
|
|
32
33
|
label,
|
|
33
34
|
labelProps,
|
|
@@ -180,25 +181,25 @@ export const UploadInput = props => {
|
|
|
180
181
|
}
|
|
181
182
|
const t15 = t14.join(" ");
|
|
182
183
|
let t16;
|
|
183
|
-
if ($[29] !== style || $[30] !== width || $[31] !== labelProps || $[32] !== Label || $[33] !==
|
|
184
|
+
if ($[29] !== style || $[30] !== width || $[31] !== labelProps || $[32] !== Label || $[33] !== field || $[34] !== label || $[35] !== required || $[36] !== errorProps || $[37] !== Error || $[38] !== collection || $[39] !== fileDoc || $[40] !== missingFile || $[41] !== readOnly || $[42] !== onChange || $[43] !== relationTo || $[44] !== customUploadActions || $[45] !== allowNewUpload || $[46] !== i18n || $[47] !== t || $[48] !== DocumentDrawerToggler || $[49] !== ListDrawerToggler || $[50] !== descriptionProps || $[51] !== Description || $[52] !== onSave || $[53] !== DocumentDrawer || $[54] !== onSelect || $[55] !== ListDrawer || $[56] !== t15) {
|
|
184
185
|
let t17;
|
|
185
|
-
if ($[
|
|
186
|
+
if ($[58] !== labelProps) {
|
|
186
187
|
t17 = labelProps || {};
|
|
187
|
-
$[
|
|
188
|
-
$[
|
|
188
|
+
$[58] = labelProps;
|
|
189
|
+
$[59] = t17;
|
|
189
190
|
} else {
|
|
190
|
-
t17 = $[
|
|
191
|
+
t17 = $[59];
|
|
191
192
|
}
|
|
192
193
|
let t18;
|
|
193
|
-
if ($[
|
|
194
|
+
if ($[60] !== errorProps) {
|
|
194
195
|
t18 = errorProps || {};
|
|
195
|
-
$[
|
|
196
|
-
$[
|
|
196
|
+
$[60] = errorProps;
|
|
197
|
+
$[61] = t18;
|
|
197
198
|
} else {
|
|
198
|
-
t18 = $[
|
|
199
|
+
t18 = $[61];
|
|
199
200
|
}
|
|
200
201
|
let t19;
|
|
201
|
-
if ($[
|
|
202
|
+
if ($[62] !== collection || $[63] !== fileDoc || $[64] !== missingFile || $[65] !== readOnly || $[66] !== onChange || $[67] !== relationTo || $[68] !== customUploadActions || $[69] !== allowNewUpload || $[70] !== i18n || $[71] !== t || $[72] !== DocumentDrawerToggler || $[73] !== ListDrawerToggler || $[74] !== descriptionProps || $[75] !== Description || $[76] !== field) {
|
|
202
203
|
t19 = collection?.upload && _jsxs(React.Fragment, {
|
|
203
204
|
children: [fileDoc && !missingFile && _jsx(FileDetails, {
|
|
204
205
|
collectionSlug: relationTo,
|
|
@@ -236,26 +237,28 @@ export const UploadInput = props => {
|
|
|
236
237
|
})
|
|
237
238
|
}), _jsx(FieldDescription, {
|
|
238
239
|
Description,
|
|
240
|
+
field,
|
|
239
241
|
...(descriptionProps || {})
|
|
240
242
|
})]
|
|
241
243
|
});
|
|
242
|
-
$[
|
|
243
|
-
$[
|
|
244
|
-
$[
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
251
|
-
$[
|
|
252
|
-
$[
|
|
253
|
-
$[
|
|
254
|
-
$[
|
|
255
|
-
$[
|
|
256
|
-
$[
|
|
244
|
+
$[62] = collection;
|
|
245
|
+
$[63] = fileDoc;
|
|
246
|
+
$[64] = missingFile;
|
|
247
|
+
$[65] = readOnly;
|
|
248
|
+
$[66] = onChange;
|
|
249
|
+
$[67] = relationTo;
|
|
250
|
+
$[68] = customUploadActions;
|
|
251
|
+
$[69] = allowNewUpload;
|
|
252
|
+
$[70] = i18n;
|
|
253
|
+
$[71] = t;
|
|
254
|
+
$[72] = DocumentDrawerToggler;
|
|
255
|
+
$[73] = ListDrawerToggler;
|
|
256
|
+
$[74] = descriptionProps;
|
|
257
|
+
$[75] = Description;
|
|
258
|
+
$[76] = field;
|
|
259
|
+
$[77] = t19;
|
|
257
260
|
} else {
|
|
258
|
-
t19 = $[
|
|
261
|
+
t19 = $[77];
|
|
259
262
|
}
|
|
260
263
|
t16 = _jsxs("div", {
|
|
261
264
|
className: t15,
|
|
@@ -265,6 +268,7 @@ export const UploadInput = props => {
|
|
|
265
268
|
},
|
|
266
269
|
children: [_jsx(FieldLabel, {
|
|
267
270
|
Label,
|
|
271
|
+
field,
|
|
268
272
|
label,
|
|
269
273
|
required,
|
|
270
274
|
...t17
|
|
@@ -272,6 +276,7 @@ export const UploadInput = props => {
|
|
|
272
276
|
className: `${fieldBaseClass}__wrap`,
|
|
273
277
|
children: [_jsx(FieldError, {
|
|
274
278
|
CustomError: Error,
|
|
279
|
+
field,
|
|
275
280
|
...t18
|
|
276
281
|
}), t19, !readOnly && _jsx(DocumentDrawer, {
|
|
277
282
|
onSave
|
|
@@ -284,32 +289,33 @@ export const UploadInput = props => {
|
|
|
284
289
|
$[30] = width;
|
|
285
290
|
$[31] = labelProps;
|
|
286
291
|
$[32] = Label;
|
|
287
|
-
$[33] =
|
|
288
|
-
$[34] =
|
|
289
|
-
$[35] =
|
|
290
|
-
$[36] =
|
|
291
|
-
$[37] =
|
|
292
|
-
$[38] =
|
|
293
|
-
$[39] =
|
|
294
|
-
$[40] =
|
|
295
|
-
$[41] =
|
|
296
|
-
$[42] =
|
|
297
|
-
$[43] =
|
|
298
|
-
$[44] =
|
|
299
|
-
$[45] =
|
|
300
|
-
$[46] =
|
|
301
|
-
$[47] =
|
|
302
|
-
$[48] =
|
|
303
|
-
$[49] =
|
|
304
|
-
$[50] =
|
|
305
|
-
$[51] =
|
|
306
|
-
$[52] =
|
|
307
|
-
$[53] =
|
|
308
|
-
$[54] =
|
|
309
|
-
$[55] =
|
|
310
|
-
$[56] =
|
|
292
|
+
$[33] = field;
|
|
293
|
+
$[34] = label;
|
|
294
|
+
$[35] = required;
|
|
295
|
+
$[36] = errorProps;
|
|
296
|
+
$[37] = Error;
|
|
297
|
+
$[38] = collection;
|
|
298
|
+
$[39] = fileDoc;
|
|
299
|
+
$[40] = missingFile;
|
|
300
|
+
$[41] = readOnly;
|
|
301
|
+
$[42] = onChange;
|
|
302
|
+
$[43] = relationTo;
|
|
303
|
+
$[44] = customUploadActions;
|
|
304
|
+
$[45] = allowNewUpload;
|
|
305
|
+
$[46] = i18n;
|
|
306
|
+
$[47] = t;
|
|
307
|
+
$[48] = DocumentDrawerToggler;
|
|
308
|
+
$[49] = ListDrawerToggler;
|
|
309
|
+
$[50] = descriptionProps;
|
|
310
|
+
$[51] = Description;
|
|
311
|
+
$[52] = onSave;
|
|
312
|
+
$[53] = DocumentDrawer;
|
|
313
|
+
$[54] = onSelect;
|
|
314
|
+
$[55] = ListDrawer;
|
|
315
|
+
$[56] = t15;
|
|
316
|
+
$[57] = t16;
|
|
311
317
|
} else {
|
|
312
|
-
t16 = $[
|
|
318
|
+
t16 = $[57];
|
|
313
319
|
}
|
|
314
320
|
return t16;
|
|
315
321
|
}
|