@payloadcms/ui 3.0.0-canary.8223f17 → 3.0.0-canary.8b49db7
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/EditUpload/index.d.ts.map +1 -1
- package/dist/elements/EditUpload/index.js +28 -11
- package/dist/elements/EditUpload/index.js.map +1 -1
- package/dist/elements/HydrateClientUser/index.d.ts +0 -1
- package/dist/elements/HydrateClientUser/index.d.ts.map +1 -1
- package/dist/elements/ListControls/getTextFieldsToBeSearched.d.ts.map +1 -1
- package/dist/elements/ReactSelect/DropdownIndicator/index.js +1 -1
- package/dist/elements/ReactSelect/DropdownIndicator/index.js.map +1 -1
- package/dist/elements/ReactSelect/types.d.ts +0 -1
- package/dist/elements/ReactSelect/types.d.ts.map +1 -1
- package/dist/elements/StepNav/SetStepNav.d.ts +0 -1
- package/dist/elements/StepNav/SetStepNav.d.ts.map +1 -1
- package/dist/elements/StepNav/index.d.ts.map +1 -1
- package/dist/elements/StepNav/index.js +1 -1
- package/dist/elements/StepNav/index.js.map +1 -1
- package/dist/elements/Table/DefaultCell/fields/index.d.ts +4 -5
- package/dist/elements/Table/DefaultCell/fields/index.d.ts.map +1 -1
- package/dist/elements/TableColumns/filterFields.d.ts.map +1 -1
- package/dist/elements/TableColumns/getInitialColumns.d.ts.map +1 -1
- package/dist/elements/WhereBuilder/validateWhereQuery.d.ts.map +1 -1
- package/dist/exports/client/index.d.ts +31 -24
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +26 -18
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/shared/index.d.ts +2 -1
- package/dist/exports/shared/index.d.ts.map +1 -1
- package/dist/exports/shared/index.js +2 -2
- package/dist/exports/shared/index.js.map +4 -4
- package/dist/fields/Checkbox/index.d.ts +1 -1
- package/dist/fields/Checkbox/index.d.ts.map +1 -1
- package/dist/fields/Checkbox/index.js +2 -2
- package/dist/fields/Checkbox/index.js.map +1 -1
- package/dist/fields/Code/index.d.ts +1 -1
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js +2 -2
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts +1 -1
- package/dist/fields/Collapsible/index.d.ts.map +1 -1
- package/dist/fields/Collapsible/index.js +2 -2
- package/dist/fields/Collapsible/index.js.map +1 -1
- package/dist/fields/ConfirmPassword/index.d.ts +1 -1
- package/dist/fields/ConfirmPassword/index.d.ts.map +1 -1
- package/dist/fields/ConfirmPassword/index.js +1 -1
- package/dist/fields/ConfirmPassword/index.js.map +1 -1
- package/dist/fields/DateTime/index.d.ts +1 -1
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js +2 -2
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Email/index.d.ts +1 -1
- package/dist/fields/Email/index.d.ts.map +1 -1
- package/dist/fields/Email/index.js +2 -2
- package/dist/fields/Email/index.js.map +1 -1
- package/dist/fields/Group/index.d.ts +2 -1
- package/dist/fields/Group/index.d.ts.map +1 -1
- package/dist/fields/Group/index.js +2 -2
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/{HiddenInput → Hidden}/index.d.ts +1 -1
- package/dist/fields/Hidden/index.d.ts.map +1 -0
- package/dist/fields/{HiddenInput → Hidden}/index.js +2 -2
- package/dist/fields/Hidden/index.js.map +1 -0
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js +2 -2
- 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 +2 -2
- package/dist/fields/Number/index.js.map +1 -1
- package/dist/fields/Password/index.d.ts +1 -1
- package/dist/fields/Password/index.d.ts.map +1 -1
- package/dist/fields/Password/index.js +2 -2
- package/dist/fields/Password/index.js.map +1 -1
- package/dist/fields/Point/index.d.ts +2 -1
- package/dist/fields/Point/index.d.ts.map +1 -1
- package/dist/fields/Point/index.js +2 -2
- package/dist/fields/Point/index.js.map +1 -1
- package/dist/fields/RadioGroup/index.d.ts +1 -1
- package/dist/fields/RadioGroup/index.d.ts.map +1 -1
- package/dist/fields/RadioGroup/index.js +2 -2
- package/dist/fields/RadioGroup/index.js.map +1 -1
- package/dist/fields/Relationship/index.d.ts +1 -1
- package/dist/fields/Relationship/index.d.ts.map +1 -1
- package/dist/fields/Relationship/index.js +2 -2
- package/dist/fields/Relationship/index.js.map +1 -1
- package/dist/fields/RichText/index.d.ts +1 -1
- package/dist/fields/RichText/index.d.ts.map +1 -1
- package/dist/fields/RichText/index.js +1 -1
- package/dist/fields/RichText/index.js.map +1 -1
- package/dist/fields/Row/index.d.ts +2 -1
- package/dist/fields/Row/index.d.ts.map +1 -1
- package/dist/fields/Row/index.js +2 -2
- package/dist/fields/Row/index.js.map +1 -1
- package/dist/fields/Select/index.d.ts +1 -1
- package/dist/fields/Select/index.d.ts.map +1 -1
- package/dist/fields/Select/index.js +6 -4
- package/dist/fields/Select/index.js.map +1 -1
- package/dist/fields/Tabs/index.d.ts +1 -1
- package/dist/fields/Tabs/index.d.ts.map +1 -1
- package/dist/fields/Tabs/index.js +2 -2
- package/dist/fields/Tabs/index.js.map +1 -1
- package/dist/fields/Text/index.d.ts +1 -1
- package/dist/fields/Text/index.d.ts.map +1 -1
- package/dist/fields/Text/index.js +2 -2
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Textarea/index.d.ts +1 -1
- package/dist/fields/Textarea/index.d.ts.map +1 -1
- package/dist/fields/Textarea/index.js +2 -2
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/UI/index.d.ts +1 -1
- package/dist/fields/UI/index.d.ts.map +1 -1
- package/dist/fields/UI/index.js +1 -1
- package/dist/fields/UI/index.js.map +1 -1
- package/dist/fields/Upload/index.d.ts +1 -1
- package/dist/fields/Upload/index.d.ts.map +1 -1
- package/dist/fields/Upload/index.js +1 -1
- package/dist/fields/Upload/index.js.map +1 -1
- package/dist/fields/index.js +48 -48
- package/dist/fields/index.js.map +1 -1
- package/dist/fields/shared/index.d.ts +0 -1
- package/dist/fields/shared/index.d.ts.map +1 -1
- package/dist/forms/Form/context.d.ts +0 -1
- package/dist/forms/Form/context.d.ts.map +1 -1
- package/dist/forms/Form/getDataByPath.d.ts.map +1 -1
- package/dist/forms/Form/getDataByPath.js +1 -2
- package/dist/forms/Form/getDataByPath.js.map +1 -1
- package/dist/forms/Form/getSiblingData.d.ts.map +1 -1
- package/dist/forms/Form/getSiblingData.js +2 -5
- package/dist/forms/Form/getSiblingData.js.map +1 -1
- package/dist/forms/NullifyField/index.js +2 -2
- package/dist/forms/NullifyField/index.js.map +1 -1
- package/dist/forms/RenderFields/RenderField.js +2 -2
- package/dist/forms/RenderFields/RenderField.js.map +1 -1
- package/dist/forms/RowLabel/Context/index.d.ts.map +1 -1
- package/dist/forms/WatchChildErrors/buildPathSegments.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/addFieldStatePromise.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/index.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/iterateFields.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/calculateDefaultValues/promise.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/getFilterOptionsQuery.d.ts +1 -1
- package/dist/forms/buildStateFromSchema/getFilterOptionsQuery.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/index.d.ts.map +1 -1
- package/dist/forms/buildStateFromSchema/iterateFields.d.ts.map +1 -1
- package/dist/forms/useField/index.d.ts.map +1 -1
- package/dist/forms/withCondition/index.d.ts.map +1 -1
- package/dist/hooks/useDelay.d.ts.map +1 -1
- package/dist/hooks/useIntersect.d.ts +0 -1
- package/dist/hooks/useIntersect.d.ts.map +1 -1
- package/dist/hooks/usePayloadAPI.d.ts +0 -1
- package/dist/hooks/usePayloadAPI.d.ts.map +1 -1
- package/dist/hooks/useThrottledEffect.d.ts +0 -1
- package/dist/hooks/useThrottledEffect.d.ts.map +1 -1
- package/dist/hooks/useUseAsTitle.d.ts.map +1 -1
- package/dist/providers/Auth/index.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/collections.d.ts +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/collections.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/fields.js +2 -2
- package/dist/providers/ComponentMap/buildComponentMap/fields.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/globals.d.ts +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/globals.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/index.d.ts +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/index.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/types.d.ts +1 -2
- package/dist/providers/ComponentMap/buildComponentMap/types.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/types.js.map +1 -1
- package/dist/providers/FormQueryParams/index.d.ts.map +1 -1
- package/dist/providers/ScrollInfo/index.d.ts +0 -1
- package/dist/providers/ScrollInfo/index.d.ts.map +1 -1
- package/dist/providers/Translation/index.d.ts.map +1 -1
- package/dist/providers/WindowInfo/index.d.ts +0 -1
- package/dist/providers/WindowInfo/index.d.ts.map +1 -1
- package/dist/utilities/api.d.ts.map +1 -1
- package/dist/utilities/buildFieldSchemaMap/index.d.ts.map +1 -1
- package/dist/utilities/buildFormState.d.ts.map +1 -1
- package/dist/utilities/buildFormState.js.map +1 -1
- package/dist/utilities/flattenFieldMap.d.ts.map +1 -1
- package/dist/utilities/formatDocTitle.d.ts +1 -1
- package/dist/utilities/formatDocTitle.d.ts.map +1 -1
- package/dist/utilities/getFormState.d.ts +2 -2
- package/dist/utilities/getFormState.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToValues.js +2 -5
- package/dist/utilities/reduceFieldsToValues.js.map +1 -1
- package/dist/utilities/reduceFieldsToValuesWithValidation.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToValuesWithValidation.js +2 -5
- package/dist/utilities/reduceFieldsToValuesWithValidation.js.map +1 -1
- package/dist/utilities/setsAreEqual.d.ts.map +1 -1
- package/dist/utilities/unflatten.d.ts +9 -0
- package/dist/utilities/unflatten.d.ts.map +1 -0
- package/dist/utilities/unflatten.js +58 -0
- package/dist/utilities/unflatten.js.map +1 -0
- package/package.json +46 -56
- package/dist/fields/HiddenInput/index.d.ts.map +0 -1
- package/dist/fields/HiddenInput/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/DateTime/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate, DateField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport { DatePickerField } from '../../elements/DatePicker/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'date-time-field'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\n\nexport type DateFieldProps = FormFieldBase & {\n date?: DateField['admin']['date']\n name?: string\n path?: string\n placeholder?: DateField['admin']['placeholder'] | string\n width?: string\n}\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/DateTime/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate, DateField } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport { DatePickerField } from '../../elements/DatePicker/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'date-time-field'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\n\nexport type DateFieldProps = FormFieldBase & {\n date?: DateField['admin']['date']\n name?: string\n path?: string\n placeholder?: DateField['admin']['placeholder'] | string\n width?: string\n}\n\nconst _DateTimeField: React.FC<DateFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n date: datePickerProps,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField<Date>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && `${baseClass}--has-error`,\n disabled && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`} id={`field-${path.replace(/\\./g, '__')}`}>\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n {BeforeInput}\n <DatePickerField\n {...datePickerProps}\n onChange={(incomingDate) => {\n if (!disabled) setValue(incomingDate?.toISOString() || null)\n }}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </div>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const DateTimeField = withCondition(_DateTimeField)\n"],"names":["getTranslation","React","useCallback","DatePickerField","useField","useTranslation","FieldLabel","fieldBaseClass","baseClass","useFieldProps","withCondition","FieldDescription","FieldError","_DateTimeField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","date","datePickerProps","descriptionProps","errorProps","label","labelProps","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","style","validate","width","i18n","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","div","filter","Boolean","join","id","replace","onChange","incomingDate","toISOString","undefined","DateTimeField"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAE1C,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAIlB,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,UAAU,QAAQ,yBAAwB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AO,CAAC,OAAO,MAAM,CAAC;;kCACjF,KAACzC;wBAAWO,aAAaA;wBAAaS,MAAMA;wBAAO,GAAIH,cAAc,CAAC,CAAC;;oBACtER;kCACD,KAACd;wBACE,GAAGoB,eAAe;wBACnB+B,UAAU,CAACC;4BACT,IAAI,CAACR,UAAUF,SAASU,cAAcC,iBAAiB;wBACzD;wBACA1B,aAAa9B,eAAe8B,aAAaO;wBACzCN,UAAUgB;wBACVR,OAAOA;;oBAERvB;;;YAEFE,sBAAsBuC,YACrBvC,kCAEA,KAACP;gBAAkB,GAAIa,oBAAoB,CAAC,CAAC;;;;AAIrD;AAEA,OAAO,MAAMkC,gBAAgBhD,cAAcG,gBAAe"}
|
|
@@ -9,5 +9,5 @@ export type EmailFieldProps = FormFieldBase & {
|
|
|
9
9
|
placeholder?: EmailFieldType['admin']['placeholder'];
|
|
10
10
|
width?: string;
|
|
11
11
|
};
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const EmailField: React.FC<EmailFieldProps>;
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Email/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,UAAU,IAAI,cAAc,EAAE,MAAM,SAAS,CAAA;AAG3E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAUvD,OAAO,cAAc,CAAA;AAErB,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAA;IACpD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAqFD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Email/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,UAAU,IAAI,cAAc,EAAE,MAAM,SAAS,CAAA;AAG3E,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAUvD,OAAO,cAAc,CAAA;AAErB,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAA;IACpD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAqFD,eAAO,MAAM,UAAU,2BAA6B,CAAA"}
|
|
@@ -11,7 +11,7 @@ import { FieldError } from '../FieldError/index.js';
|
|
|
11
11
|
import { FieldLabel } from '../FieldLabel/index.js';
|
|
12
12
|
import { fieldBaseClass } from '../shared/index.js';
|
|
13
13
|
import './index.scss';
|
|
14
|
-
const
|
|
14
|
+
const _EmailField = (props)=>{
|
|
15
15
|
const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, autoComplete, className, descriptionProps, errorProps, label, labelProps, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, style, validate, width } = props;
|
|
16
16
|
const { i18n } = useTranslation();
|
|
17
17
|
const memoizedValidate = useCallback((value, options)=>{
|
|
@@ -78,6 +78,6 @@ const EmailField = (props)=>{
|
|
|
78
78
|
]
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
|
-
export const
|
|
81
|
+
export const EmailField = withCondition(_EmailField);
|
|
82
82
|
|
|
83
83
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Email/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate, EmailField as EmailFieldType } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.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 type EmailFieldProps = FormFieldBase & {\n autoComplete?: string\n name?: string\n path?: string\n placeholder?: EmailFieldType['admin']['placeholder']\n width?: string\n}\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Email/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate, EmailField as EmailFieldType } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.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 type EmailFieldProps = FormFieldBase & {\n autoComplete?: string\n name?: string\n path?: string\n placeholder?: EmailFieldType['admin']['placeholder']\n width?: string\n}\n\nconst _EmailField: React.FC<EmailFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n autoComplete,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, 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 return (\n <div\n className={[fieldBaseClass, 'email', className, showError && 'error', disabled && 'read-only']\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n {BeforeInput}\n <input\n autoComplete={autoComplete}\n disabled={disabled}\n id={`field-${path.replace(/\\./g, '__')}`}\n name={path}\n onChange={setValue}\n placeholder={getTranslation(placeholder, i18n)}\n type=\"email\"\n value={(value as string) || ''}\n />\n {AfterInput}\n </div>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const EmailField = withCondition(_EmailField)\n"],"names":["getTranslation","React","useCallback","useFieldProps","useField","withCondition","useTranslation","FieldDescription","FieldError","FieldLabel","fieldBaseClass","_EmailField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","autoComplete","className","descriptionProps","errorProps","label","labelProps","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","style","validate","width","i18n","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","div","filter","Boolean","join","input","id","replace","onChange","type","undefined","EmailField"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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BU,uBAAuBE,kBAAkBD;IAE/E,qBACE,MAACK;QACCzB,WAAW;YAACV;YAAgB;YAASU;YAAWuB,aAAa;YAASC,YAAY;SAAY,CAC3FE,MAAM,CAACC,SACPC,IAAI,CAAC;QACRjB,OAAO;YACL,GAAGA,KAAK;YACRE;QACF;;0BAEA,KAACxB;gBACCS,aAAaA;gBACbK,OAAOA;gBACPO,UAAUA;gBACT,GAAIN,cAAc,CAAC,CAAC;;0BAEvB,MAACqB;gBAAIzB,WAAW,CAAC,EAAEV,eAAe,MAAM,CAAC;;kCACvC,KAACF;wBAAWS,aAAaA;wBAAaQ,MAAMA;wBAAO,GAAIH,cAAc,CAAC,CAAC;;oBACtEP;kCACD,KAACkC;wBACC9B,cAAcA;wBACdyB,UAAUA;wBACVM,IAAI,CAAC,MAAM,EAAEzB,KAAK0B,OAAO,CAAC,OAAO,MAAM,CAAC;wBACxCtC,MAAMY;wBACN2B,UAAUV;wBACVf,aAAa3B,eAAe2B,aAAaO;wBACzCmB,MAAK;wBACLjB,OAAO,AAACA,SAAoB;;oBAE7BtB;;;YAEFE,sBAAsBsC,YACrBtC,kCAEA,KAACT;gBAAkB,GAAIc,oBAAoB,CAAC,CAAC;;;;AAIrD;AAEA,OAAO,MAAMkC,aAAalD,cAAcM,aAAY"}
|
|
@@ -10,6 +10,7 @@ export type GroupFieldProps = FormFieldBase & {
|
|
|
10
10
|
name?: string;
|
|
11
11
|
width?: string;
|
|
12
12
|
};
|
|
13
|
+
export declare const _GroupField: React.FC<GroupFieldProps>;
|
|
13
14
|
export { GroupProvider, useGroup };
|
|
14
|
-
export declare const
|
|
15
|
+
export declare const GroupField: React.FC<GroupFieldProps>;
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Group/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAkBvD,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Group/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAA;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAkBvD,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,QAAQ,EAAE,QAAQ,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqFjD,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAElC,eAAO,MAAM,UAAU,2BAA6B,CAAA"}
|
|
@@ -17,7 +17,7 @@ import { fieldBaseClass } from '../shared/index.js';
|
|
|
17
17
|
import './index.scss';
|
|
18
18
|
import { GroupProvider, useGroup } from './provider.js';
|
|
19
19
|
const baseClass = 'group-field';
|
|
20
|
-
const
|
|
20
|
+
export const _GroupField = (props)=>{
|
|
21
21
|
const { CustomDescription, CustomLabel, className, descriptionProps, fieldMap, hideGutter, label, readOnly: readOnlyFromProps, style, width } = props;
|
|
22
22
|
const { path, permissions, readOnly: readOnlyFromContext, schemaPath } = useFieldProps();
|
|
23
23
|
const { i18n } = useTranslation();
|
|
@@ -94,6 +94,6 @@ const GroupField = (props)=>{
|
|
|
94
94
|
});
|
|
95
95
|
};
|
|
96
96
|
export { GroupProvider, useGroup };
|
|
97
|
-
export const
|
|
97
|
+
export const GroupField = withCondition(_GroupField);
|
|
98
98
|
|
|
99
99
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { Fragment } from 'react'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport {\n useFormInitializing,\n useFormProcessing,\n useFormSubmitted,\n} from '../../forms/Form/context.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { useRow } from '../Row/provider.js'\nimport { useTabs } from '../Tabs/provider.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { GroupProvider, useGroup } from './provider.js'\n\nconst baseClass = 'group-field'\n\nexport type GroupFieldProps = FormFieldBase & {\n fieldMap: FieldMap\n forceRender?: boolean\n hideGutter?: boolean\n name?: string\n width?: string\n}\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Group/index.tsx"],"sourcesContent":["'use client'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { Fragment } from 'react'\n\nimport type { FieldMap } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useCollapsible } from '../../elements/Collapsible/provider.js'\nimport { ErrorPill } from '../../elements/ErrorPill/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport {\n useFormInitializing,\n useFormProcessing,\n useFormSubmitted,\n} from '../../forms/Form/context.js'\nimport { RenderFields } from '../../forms/RenderFields/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { useRow } from '../Row/provider.js'\nimport { useTabs } from '../Tabs/provider.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\nimport { GroupProvider, useGroup } from './provider.js'\n\nconst baseClass = 'group-field'\n\nexport type GroupFieldProps = FormFieldBase & {\n fieldMap: FieldMap\n forceRender?: boolean\n hideGutter?: boolean\n name?: string\n width?: string\n}\n\nexport const _GroupField: React.FC<GroupFieldProps> = (props) => {\n const {\n CustomDescription,\n CustomLabel,\n className,\n descriptionProps,\n fieldMap,\n hideGutter,\n label,\n readOnly: readOnlyFromProps,\n style,\n width,\n } = props\n\n const { path, permissions, readOnly: readOnlyFromContext, schemaPath } = useFieldProps()\n const { i18n } = useTranslation()\n const { isWithinCollapsible } = useCollapsible()\n const isWithinGroup = useGroup()\n const isWithinRow = useRow()\n const isWithinTab = useTabs()\n const { errorPaths } = useField({ path })\n const formInitializing = useFormInitializing()\n const formProcessing = useFormProcessing()\n const submitted = useFormSubmitted()\n const errorCount = errorPaths.length\n const fieldHasErrors = submitted && errorCount > 0\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const isTopLevel = !(isWithinCollapsible || isWithinGroup || isWithinRow)\n\n return (\n <Fragment>\n <div\n className={[\n fieldBaseClass,\n baseClass,\n isTopLevel && `${baseClass}--top-level`,\n isWithinCollapsible && `${baseClass}--within-collapsible`,\n isWithinGroup && `${baseClass}--within-group`,\n isWithinRow && `${baseClass}--within-row`,\n isWithinTab && `${baseClass}--within-tab`,\n !hideGutter && isWithinGroup && `${baseClass}--gutter`,\n fieldHasErrors && `${baseClass}--has-error`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path?.replace(/\\./g, '__')}`}\n style={{\n ...style,\n width,\n }}\n >\n <GroupProvider>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__header`}>\n {(CustomLabel || CustomDescription || label) && (\n <header>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : label ? (\n <h3 className={`${baseClass}__title`}>{getTranslation(label, i18n)}</h3>\n ) : null}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </header>\n )}\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n <RenderFields\n fieldMap={fieldMap}\n margins=\"small\"\n path={path}\n permissions={permissions?.fields}\n readOnly={disabled}\n schemaPath={schemaPath}\n />\n </div>\n </GroupProvider>\n </div>\n </Fragment>\n )\n}\n\nexport { GroupProvider, useGroup }\n\nexport const GroupField = withCondition(_GroupField)\n"],"names":["getTranslation","React","Fragment","useCollapsible","ErrorPill","useFieldProps","useFormInitializing","useFormProcessing","useFormSubmitted","RenderFields","useField","withCondition","useTranslation","FieldDescription","useRow","useTabs","fieldBaseClass","GroupProvider","useGroup","baseClass","_GroupField","props","CustomDescription","CustomLabel","className","descriptionProps","fieldMap","hideGutter","label","readOnly","readOnlyFromProps","style","width","path","permissions","readOnlyFromContext","schemaPath","i18n","isWithinCollapsible","isWithinGroup","isWithinRow","isWithinTab","errorPaths","formInitializing","formProcessing","submitted","errorCount","length","fieldHasErrors","disabled","isTopLevel","div","filter","Boolean","join","id","replace","header","undefined","h3","count","withMessage","margins","fields","GroupField"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAKvC,SAASC,cAAc,QAAQ,yCAAwC;AACvE,SAASC,SAAS,QAAQ,oCAAmC;AAC7D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,gBAAgB,QACX,8BAA6B;AACpC,SAASC,YAAY,QAAQ,oCAAmC;AAChE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,MAAM,QAAQ,qBAAoB;AAC3C,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AACrB,SAASC,aAAa,EAAEC,QAAQ,QAAQ,gBAAe;AAEvD,MAAMC,YAAY;AAUlB,OAAO,MAAMC,cAAyC,CAACC;IACrD,MAAM,EACJC,iBAAiB,EACjBC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,KAAK,EACLC,UAAUC,iBAAiB,EAC3BC,KAAK,EACLC,KAAK,EACN,GAAGX;IAEJ,MAAM,EAAEY,IAAI,EAAEC,WAAW,EAAEL,UAAUM,mBAAmB,EAAEC,UAAU,EAAE,GAAG/B;IACzE,MAAM,EAAEgC,IAAI,EAAE,GAAGzB;IACjB,MAAM,EAAE0B,mBAAmB,EAAE,GAAGnC;IAChC,MAAMoC,gBAAgBrB;IACtB,MAAM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AAO,CAAC;sDAAGnB,eAAe4B,OAAOS;6CAC3D;wCACHf,sBAAsBoC,YACrBpC,kCAEA,KAACT;4CAAkB,GAAIY,oBAAoB,CAAC,CAAC;;;;gCAIlDuB,gCAAkB,KAAC5C;oCAAUwD,OAAOd;oCAAYT,MAAMA;oCAAMwB,WAAW;;;;sCAE1E,KAACpD;4BACCiB,UAAUA;4BACVoC,SAAQ;4BACR7B,MAAMA;4BACNC,aAAaA,aAAa6B;4BAC1BlC,UAAUoB;4BACVb,YAAYA;;;;;;;AAO1B,EAAC;AAED,SAASnB,aAAa,EAAEC,QAAQ,GAAE;AAElC,OAAO,MAAM8C,aAAarD,cAAcS,aAAY"}
|
|
@@ -7,5 +7,5 @@ export type HiddenInputFieldProps = FormFieldBase & {
|
|
|
7
7
|
path?: string;
|
|
8
8
|
value?: unknown;
|
|
9
9
|
};
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const HiddenField: React.FC<HiddenInputFieldProps>;
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Hidden/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAExC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAMhD,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG;IAClD,oBAAoB,CAAC,EAAE,KAAK,CAAA;IAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAsCD,eAAO,MAAM,WAAW,iCAA8B,CAAA"}
|
|
@@ -7,7 +7,7 @@ import { withCondition } from '../../forms/withCondition/index.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* This is mainly used to save a value on the form that is not visible to the user.
|
|
9
9
|
* For example, this sets the `ìd` property of a block in the Blocks field.
|
|
10
|
-
*/ const
|
|
10
|
+
*/ const _HiddenField = (props)=>{
|
|
11
11
|
const { name, disableModifyingForm = true, forceUsePathFromProps, path: pathFromProps, value: valueFromProps } = props;
|
|
12
12
|
const { path: pathFromContext } = useFieldProps();
|
|
13
13
|
const { path, setValue, value } = useField({
|
|
@@ -30,6 +30,6 @@ import { withCondition } from '../../forms/withCondition/index.js';
|
|
|
30
30
|
value: value || ''
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
|
-
export const
|
|
33
|
+
export const HiddenField = withCondition(_HiddenField);
|
|
34
34
|
|
|
35
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Hidden/index.tsx"],"sourcesContent":["'use client'\nimport React, { useEffect } from 'react'\n\nimport type { FormFieldBase } from '../index.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\n\nexport type HiddenInputFieldProps = FormFieldBase & {\n disableModifyingForm?: false\n forceUsePathFromProps?: boolean\n name?: string\n path?: string\n value?: unknown\n}\n\n/**\n * This is mainly used to save a value on the form that is not visible to the user.\n * For example, this sets the `ìd` property of a block in the Blocks field.\n */\nconst _HiddenField: React.FC<HiddenInputFieldProps> = (props) => {\n const {\n name,\n disableModifyingForm = true,\n forceUsePathFromProps,\n path: pathFromProps,\n value: valueFromProps,\n } = props\n\n const { path: pathFromContext } = useFieldProps()\n\n const { path, setValue, value } = useField({\n path: (!forceUsePathFromProps ? pathFromContext : null) || pathFromProps || name,\n })\n\n useEffect(() => {\n if (valueFromProps !== undefined) {\n setValue(valueFromProps, disableModifyingForm)\n }\n }, [valueFromProps, setValue, disableModifyingForm])\n\n return (\n <input\n id={`field-${path?.replace(/\\./g, '__')}`}\n name={path}\n onChange={setValue}\n type=\"hidden\"\n value={(value as string) || ''}\n />\n )\n}\n\nexport const HiddenField = withCondition(_HiddenField)\n"],"names":["React","useEffect","useFieldProps","useField","withCondition","_HiddenField","props","name","disableModifyingForm","forceUsePathFromProps","path","pathFromProps","value","valueFromProps","pathFromContext","setValue","undefined","input","id","replace","onChange","type","HiddenField"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AACA,OAAOA,SAASC,SAAS,QAAQ,QAAO;AAIxC,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAUlE;;;CAGC,GACD,MAAMC,eAAgD,CAACC;IACrD,MAAM,EACJC,IAAI,EACJC,uBAAuB,IAAI,EAC3BC,qBAAqB,EACrBC,MAAMC,aAAa,EACnBC,OAAOC,cAAc,EACtB,GAAGP;IAEJ,MAAM,EAAEI,MAAMI,eAAe,EAAE,GAAGZ;IAElC,MAAM,EAAEQ,IAAI,EAAEK,QAAQ,EAAEH,KAAK,EAAE,GAAGT,SAAS;QACzCO,MAAM,AAAC,CAAA,CAACD,wBAAwBK,kBAAkB,IAAG,KAAMH,iBAAiBJ;IAC9E;IAEAN,UAAU;QACR,IAAIY,mBAAmBG,WAAW;YAChCD,SAASF,gBAAgBL;QAC3B;IACF,GAAG;QAACK;QAAgBE;QAAUP;KAAqB;IAEnD,qBACE,KAACS;QACCC,IAAI,CAAC,MAAM,EAAER,MAAMS,QAAQ,OAAO,MAAM,CAAC;QACzCZ,MAAMG;QACNU,UAAUL;QACVM,MAAK;QACLT,OAAO,AAACA,SAAoB;;AAGlC;AAEA,OAAO,MAAMU,cAAclB,cAAcC,cAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,SAAS,IAAI,aAAa,EAAE,MAAM,SAAS,CAAA;AAEzE,OAAO,KAA2C,MAAM,OAAO,CAAA;AAO/D,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMvD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,aAAa,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAyID,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/JSON/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,SAAS,IAAI,aAAa,EAAE,MAAM,SAAS,CAAA;AAEzE,OAAO,KAA2C,MAAM,OAAO,CAAA;AAO/D,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMvD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,aAAa,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAyID,eAAO,MAAM,SAAS,0BAA4B,CAAA"}
|
|
@@ -11,7 +11,7 @@ const baseClass = 'json-field';
|
|
|
11
11
|
import { useFieldProps } from '../../forms/FieldPropsProvider/index.js';
|
|
12
12
|
import { FieldDescription } from '../FieldDescription/index.js';
|
|
13
13
|
import { FieldError } from '../FieldError/index.js';
|
|
14
|
-
const
|
|
14
|
+
const _JSONField = (props)=>{
|
|
15
15
|
const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, editorOptions, errorProps, jsonSchema, label, labelProps, path: pathFromProps, readOnly: readOnlyFromProps, required, style, validate, width } = props;
|
|
16
16
|
const [stringValue, setStringValue] = useState();
|
|
17
17
|
const [jsonError, setJsonError] = useState();
|
|
@@ -125,6 +125,6 @@ const JSONFieldComponent = (props)=>{
|
|
|
125
125
|
]
|
|
126
126
|
});
|
|
127
127
|
};
|
|
128
|
-
export const JSONField = withCondition(
|
|
128
|
+
export const JSONField = withCondition(_JSONField);
|
|
129
129
|
|
|
130
130
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate, JSONField as JSONFieldType } from 'payload'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'json-field'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\n\nexport type JSONFieldProps = FormFieldBase & {\n editorOptions?: JSONFieldType['admin']['editorOptions']\n jsonSchema?: Record<string, unknown>\n name?: string\n path?: string\n width?: string\n}\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/JSON/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate, JSONField as JSONFieldType } from 'payload'\n\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport { CodeEditor } from '../../elements/CodeEditor/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'json-field'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\n\nexport type JSONFieldProps = FormFieldBase & {\n editorOptions?: JSONFieldType['admin']['editorOptions']\n jsonSchema?: Record<string, unknown>\n name?: string\n path?: string\n width?: string\n}\n\nconst _JSONField: React.FC<JSONFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n editorOptions,\n errorProps,\n jsonSchema,\n label,\n labelProps,\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n required,\n style,\n validate,\n width,\n } = props\n\n const [stringValue, setStringValue] = useState<string>()\n const [jsonError, setJsonError] = useState<string>()\n const [hasLoadedValue, setHasLoadedValue] = useState(false)\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function')\n return validate(value, { ...options, jsonError, required })\n },\n [validate, required, jsonError],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, initialValue, path, setValue, showError, value } =\n useField<string>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const handleMount = useCallback(\n (editor, monaco) => {\n if (!jsonSchema) return\n\n const existingSchemas = monaco.languages.json.jsonDefaults.diagnosticsOptions.schemas || []\n const modelUri = monaco.Uri.parse(jsonSchema.uri)\n\n const model = monaco.editor.createModel(JSON.stringify(value, null, 2), 'json', modelUri)\n monaco.languages.json.jsonDefaults.setDiagnosticsOptions({\n enableSchemaRequest: true,\n schemas: [...existingSchemas, jsonSchema],\n validate: true,\n })\n\n editor.setModel(model)\n },\n [jsonSchema, value],\n )\n\n const handleChange = useCallback(\n (val) => {\n if (disabled) return\n setStringValue(val)\n\n try {\n setValue(val ? JSON.parse(val) : null)\n setJsonError(undefined)\n } catch (e) {\n setValue(val ? val : null)\n setJsonError(e)\n }\n },\n [disabled, setValue, setStringValue],\n )\n\n useEffect(() => {\n if (hasLoadedValue || value === undefined) return\n\n setStringValue(\n value || initialValue ? JSON.stringify(value ? value : initialValue, null, 2) : '',\n )\n\n setHasLoadedValue(true)\n }, [initialValue, value, hasLoadedValue])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n disabled && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n <div className={`${fieldBaseClass}__wrap`}>\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n {BeforeInput}\n <CodeEditor\n defaultLanguage=\"json\"\n onChange={handleChange}\n onMount={handleMount}\n options={editorOptions}\n readOnly={disabled}\n value={stringValue}\n />\n {AfterInput}\n </div>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const JSONField = withCondition(_JSONField)\n"],"names":["React","useCallback","useEffect","useState","CodeEditor","useField","withCondition","FieldLabel","fieldBaseClass","baseClass","useFieldProps","FieldDescription","FieldError","_JSONField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","editorOptions","errorProps","jsonSchema","label","labelProps","path","pathFromProps","readOnly","readOnlyFromProps","required","style","validate","width","stringValue","setStringValue","jsonError","setJsonError","hasLoadedValue","setHasLoadedValue","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","initialValue","setValue","showError","disabled","handleMount","editor","monaco","existingSchemas","languages","json","jsonDefaults","diagnosticsOptions","schemas","modelUri","Uri","parse","uri","model","createModel","JSON","stringify","setDiagnosticsOptions","enableSchemaRequest","setModel","handleChange","val","undefined","e","div","filter","Boolean","join","defaultLanguage","onChange","onMount","JSONField"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,OAAOA,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAE/D,SAASC,UAAU,QAAQ,qCAAoC;AAC/D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAIlB,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,UAAU,QAAQ,yBAAwB;AAUnD,MAAMC,aAAuC,CAACC;IAC5C,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,aAAa,EACbC,UAAU,EACVC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,MAAMC,aAAa,EACnBC,UAAUC,iBAAiB,EAC3BC,QAAQ,EACRC,KAAK,EACLC,QAAQ,EACRC,KAAK,EACN,GAAGrB;IAEJ,MAAM,CAACsB,aAAaC,eAAe,GAAGlC;IACtC,MAAM,CAACmC,WAAWC,aAAa,GAAGpC;IAClC,MAAM,CAACqC,gBAAgBC,kBAAkB,GAAGtC,SAAS;IAErD,MAAMuC,mBAAmCzC,YACvC,CAAC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QAAUF;QAAUb;KAAe;IAGtCnC,UAAU;QACR,IAAIsC,kBAAkBG,UAAUgC,WAAW;QAE3CtC,eACEM,SAASM,eAAemB,KAAKC,SAAS,CAAC1B,QAAQA,QAAQM,cAAc,MAAM,KAAK;QAGlFR,kBAAkB;IACpB,GAAG;QAACQ;QAAcN;QAAOH;KAAe;IAExC,qBACE,MAACqC;QACCxD,WAAW;YACTb;YACAC;YACAY;YACA8B,aAAa;YACbC,YAAY;SACb,CACE0B,MAAM,CAACC,SACPC,IAAI,CAAC;QACR/C,OAAO;YACL,GAAGA,KAAK;YACRE;QACF;;0BAEA,KAAC5B;gBACCa,aAAaA;gBACbM,OAAOA;gBACPM,UAAUA;gBACT,GAAIL,cAAc,CAAC,CAAC;;0BAEvB,KAACf;gBAAWO,aAAaA;gBAAaS,MAAMA;gBAAO,GAAIJ,cAAc,CAAC,CAAC;;0BACvE,MAACqD;gBAAIxD,WAAW,CAAC,EAAEb,eAAe,MAAM,CAAC;;kCACvC,KAACI;wBAAWO,aAAaA;wBAAaS,MAAMA;wBAAO,GAAIJ,cAAc,CAAC,CAAC;;oBACtEP;kCACD,KAACb;wBACC6E,iBAAgB;wBAChBC,UAAUT;wBACVU,SAAS9B;wBACTT,SAASrB;wBACTO,UAAUsB;wBACVT,OAAOP;;oBAERpB;;;YAEFE,sBAAsByD,YACrBzD,kCAEA,KAACP;gBAAkB,GAAIW,oBAAoB,CAAC,CAAC;;;;AAIrD;AAEA,OAAO,MAAM8D,YAAY9E,cAAcO,YAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Number/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,SAAS,CAAA;AAI7D,OAAO,KAA2C,MAAM,OAAO,CAAA;AAG/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAWvD,OAAO,cAAc,CA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AAC,EAAE,MAAM,CAAA;CACf,CAAA;AAmMD,eAAO,MAAM,WAAW,4BAA8B,CAAA"}
|
|
@@ -13,7 +13,7 @@ import { FieldError } from '../FieldError/index.js';
|
|
|
13
13
|
import { FieldLabel } from '../FieldLabel/index.js';
|
|
14
14
|
import { fieldBaseClass } from '../shared/index.js';
|
|
15
15
|
import './index.scss';
|
|
16
|
-
const
|
|
16
|
+
const _NumberField = (props)=>{
|
|
17
17
|
const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, hasMany = false, label, labelProps, max = Infinity, maxRows = Infinity, min = -Infinity, onChange: onChangeFromProps, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, step = 1, style, validate, width } = props;
|
|
18
18
|
const { i18n, t } = useTranslation();
|
|
19
19
|
const memoizedValidate = useCallback((value, options)=>{
|
|
@@ -176,6 +176,6 @@ const NumberFieldComponent = (props)=>{
|
|
|
176
176
|
]
|
|
177
177
|
});
|
|
178
178
|
};
|
|
179
|
-
export const NumberField = withCondition(
|
|
179
|
+
export const NumberField = withCondition(_NumberField);
|
|
180
180
|
|
|
181
181
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Number/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { NumberField as NumberFieldType } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { isNumber } from 'payload/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.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 type NumberFieldProps = FormFieldBase & {\n hasMany?: boolean\n max?: number\n maxRows?: number\n min?: number\n name?: string\n onChange?: (e: number) => void\n path?: string\n placeholder?: NumberFieldType['admin']['placeholder']\n step?: number\n width?: string\n}\n\nconst NumberFieldComponent: React.FC<NumberFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany = false,\n label,\n labelProps,\n max = Infinity,\n maxRows = Infinity,\n min = -Infinity,\n onChange: onChangeFromProps,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n step = 1,\n style,\n validate,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, max, min, required })\n }\n },\n [validate, min, max, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField<\n number | number[]\n >({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const handleChange = useCallback(\n (e) => {\n const val = parseFloat(e.target.value)\n let newVal = val\n\n if (Number.isNaN(val)) {\n newVal = undefined\n }\n\n if (typeof onChangeFromProps === 'function') {\n onChangeFromProps(newVal)\n }\n\n setValue(newVal)\n },\n [onChangeFromProps, setValue],\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) => Number(option.value?.value || option.value))\n } else {\n newValue = [Number(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 toString: () => `${val}${index}`,\n value: (val as unknown as Record<string, number>)?.value || val,\n }, // You're probably wondering, why the hell is this done that way? Well, 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 }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'number',\n className,\n showError && 'error',\n disabled && 'read-only',\n hasMany && 'has-many',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n {hasMany ? (\n <ReactSelect\n className={`field-${path.replace(/\\./g, '__')}`}\n disabled={disabled}\n filterOption={(_, rawInput) => {\n // eslint-disable-next-line no-restricted-globals\n const isOverHasMany = Array.isArray(value) && value.length >= maxRows\n return isNumber(rawInput) && !isOverHasMany\n }}\n isClearable\n isCreatable\n isMulti\n isSortable\n noOptionsMessage={() => {\n const isOverHasMany = Array.isArray(value) && value.length >= maxRows\n if (isOverHasMany) {\n return t('validation:limitReached', { max: maxRows, value: value.length + 1 })\n }\n return null\n }}\n // numberOnly\n onChange={handleHasManyChange}\n options={[]}\n placeholder={t('general:enterAValue')}\n showError={showError}\n value={valueToRender as Option[]}\n />\n ) : (\n <div>\n {BeforeInput}\n <input\n disabled={disabled}\n id={`field-${path.replace(/\\./g, '__')}`}\n max={max}\n min={min}\n name={path}\n onChange={handleChange}\n onWheel={(e) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n e.target.blur()\n }}\n placeholder={getTranslation(placeholder, i18n)}\n step={step}\n type=\"number\"\n value={typeof value === 'number' ? value : ''}\n />\n {AfterInput}\n </div>\n )}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n </div>\n )\n}\n\nexport const NumberField = withCondition(NumberFieldComponent)\n"],"names":["getTranslation","isNumber","React","useCallback","useEffect","useState","ReactSelect","useFieldProps","useField","withCondition","useTranslation","FieldDescription","FieldError","FieldLabel","fieldBaseClass","NumberFieldComponent","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","label","labelProps","max","Infinity","maxRows","min","onChange","onChangeFromProps","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","step","style","validate","width","i18n","t","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","handleChange","e","val","parseFloat","target","newVal","Number","isNaN","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","index","id","toString","div","filter","Boolean","join","replace","filterOption","_","rawInput","isOverHasMany","length","isClearable","isCreatable","isMulti","isSortable","noOptionsMessage","input","onWheel","blur","type","NumberField"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,QAAQ,QAAQ,iBAAgB;AACzC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D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CACLf,MAAMkB;gCACNF,UAAUwB;gCACVqC,SAAS,CAACpC;oCACR,6DAA6D;oCAC7D,mBAAmB;oCACnBA,EAAEG,MAAM,CAACkC,IAAI;gCACf;gCACA1D,aAAarC,eAAeqC,aAAaQ;gCACzCJ,MAAMA;gCACNuD,MAAK;gCACLhD,OAAO,OAAOA,UAAU,WAAWA,QAAQ;;4BAE5C9B;;;oBAGJE,sBAAsB6C,YACrB7C,kCAEA,KAACT;wBAAkB,GAAIa,oBAAoB,CAAC,CAAC;;;;;;AAKvD;AAEA,OAAO,MAAMyE,cAAcxF,cAAcM,sBAAqB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Number/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { NumberField as NumberFieldType } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { isNumber } from 'payload/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.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 type NumberFieldProps = FormFieldBase & {\n hasMany?: boolean\n max?: number\n maxRows?: number\n min?: number\n name?: string\n onChange?: (e: number) => void\n path?: string\n placeholder?: NumberFieldType['admin']['placeholder']\n step?: number\n width?: string\n}\n\nconst _NumberField: React.FC<NumberFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany = false,\n label,\n labelProps,\n max = Infinity,\n maxRows = Infinity,\n min = -Infinity,\n onChange: onChangeFromProps,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n step = 1,\n style,\n validate,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const memoizedValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, max, min, required })\n }\n },\n [validate, min, max, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField<\n number | number[]\n >({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || readOnlyFromContext || formProcessing || formInitializing\n\n const handleChange = useCallback(\n (e) => {\n const val = parseFloat(e.target.value)\n let newVal = val\n\n if (Number.isNaN(val)) {\n newVal = undefined\n }\n\n if (typeof onChangeFromProps === 'function') {\n onChangeFromProps(newVal)\n }\n\n setValue(newVal)\n },\n [onChangeFromProps, setValue],\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) => Number(option.value?.value || option.value))\n } else {\n newValue = [Number(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 toString: () => `${val}${index}`,\n value: (val as unknown as Record<string, number>)?.value || val,\n }, // You're probably wondering, why the hell is this done that way? Well, 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 }\n }),\n )\n }\n }, [value, hasMany])\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'number',\n className,\n showError && 'error',\n disabled && 'read-only',\n hasMany && 'has-many',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n {hasMany ? (\n <ReactSelect\n className={`field-${path.replace(/\\./g, '__')}`}\n disabled={disabled}\n filterOption={(_, rawInput) => {\n // eslint-disable-next-line no-restricted-globals\n const isOverHasMany = Array.isArray(value) && value.length >= maxRows\n return isNumber(rawInput) && !isOverHasMany\n }}\n isClearable\n isCreatable\n isMulti\n isSortable\n noOptionsMessage={() => {\n const isOverHasMany = Array.isArray(value) && value.length >= maxRows\n if (isOverHasMany) {\n return t('validation:limitReached', { max: maxRows, value: value.length + 1 })\n }\n return null\n }}\n // numberOnly\n onChange={handleHasManyChange}\n options={[]}\n placeholder={t('general:enterAValue')}\n showError={showError}\n value={valueToRender as Option[]}\n />\n ) : (\n <div>\n {BeforeInput}\n <input\n disabled={disabled}\n id={`field-${path.replace(/\\./g, '__')}`}\n max={max}\n min={min}\n name={path}\n onChange={handleChange}\n onWheel={(e) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n e.target.blur()\n }}\n placeholder={getTranslation(placeholder, i18n)}\n step={step}\n type=\"number\"\n value={typeof value === 'number' ? value : ''}\n />\n {AfterInput}\n </div>\n )}\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n </div>\n )\n}\n\nexport const NumberField = withCondition(_NumberField)\n"],"names":["getTranslation","isNumber","React","useCallback","useEffect","useState","ReactSelect","useFieldProps","useField","withCondition","useTranslation","FieldDescription","FieldError","FieldLabel","fieldBaseClass","_NumberField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","label","labelProps","max","Infinity","maxRows","min","onChange","onChangeFromProps","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","step","style","validate","width","i18n","t","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formInitializing","formProcessing","setValue","showError","disabled","handleChange","e","val","parseFloat","target","newVal","Number","isNaN","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","index","id","toString","div","filter","Boolean","join","replace","filterOption","_","rawInput","isOverHasMany","length","isClearable","isCreatable","isMulti","isSortable","noOptionsMessage","input","onWheel","blur","type","NumberField"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,QAAQ,QAAQ,iBAAgB;AACzC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,aAAa,QAAQ,0CAAyC;AACvE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AAerB,MAAMC,eAA2C,CAACC;IAChD,MAAM,EACJC,IAAI,EACJC,UAAU,E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 -14,5 +14,5 @@ export type PasswordFieldProps = FormFieldBase & {
|
|
|
14
14
|
validate?: Validate;
|
|
15
15
|
width?: string;
|
|
16
16
|
};
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const PasswordField: React.FC<PasswordFieldProps>;
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Password/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEpE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAOvD,OAAO,cAAc,CAAA;AAErB,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA0ED,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Password/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEpE,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAOvD,OAAO,cAAc,CAAA;AAErB,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA0ED,eAAO,MAAM,aAAa,8BAAgC,CAAA"}
|
|
@@ -7,7 +7,7 @@ import { FieldError } from '../FieldError/index.js';
|
|
|
7
7
|
import { FieldLabel } from '../FieldLabel/index.js';
|
|
8
8
|
import { fieldBaseClass } from '../shared/index.js';
|
|
9
9
|
import './index.scss';
|
|
10
|
-
const
|
|
10
|
+
const _PasswordField = (props)=>{
|
|
11
11
|
const { name, CustomError, CustomLabel, autoComplete, className, disabled: disabledFromProps, errorProps, label, labelProps, path: pathFromProps, required, style, validate, width } = props;
|
|
12
12
|
const memoizedValidate = useCallback((value, options)=>{
|
|
13
13
|
if (typeof validate === 'function') {
|
|
@@ -66,6 +66,6 @@ const PasswordField = (props)=>{
|
|
|
66
66
|
]
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
|
-
export const
|
|
69
|
+
export const PasswordField = withCondition(_PasswordField);
|
|
70
70
|
|
|
71
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Password/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate, Description, Validate } from 'payload'\n\nimport React, { useCallback } from 'react'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/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 type PasswordFieldProps = FormFieldBase & {\n autoComplete?: string\n className?: string\n description?: Description\n disabled?: boolean\n name: string\n path?: string\n required?: boolean\n style?: React.CSSProperties\n validate?: Validate\n width?: string\n}\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Password/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate, Description, Validate } from 'payload'\n\nimport React, { useCallback } from 'react'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/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 type PasswordFieldProps = FormFieldBase & {\n autoComplete?: string\n className?: string\n description?: Description\n disabled?: boolean\n name: string\n path?: string\n required?: boolean\n style?: React.CSSProperties\n validate?: Validate\n width?: string\n}\n\nconst _PasswordField: React.FC<PasswordFieldProps> = (props) => {\n const {\n name,\n CustomError,\n CustomLabel,\n autoComplete,\n className,\n disabled: disabledFromProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n required,\n style,\n validate,\n width,\n } = props\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const { formInitializing, formProcessing, path, setValue, showError, value } = useField({\n path: pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const disabled = disabledFromProps || formInitializing || formProcessing\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'password',\n className,\n showError && 'error',\n disabled && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n <input\n autoComplete={autoComplete}\n disabled={disabled}\n id={`field-${path.replace(/\\./g, '__')}`}\n name={path}\n onChange={setValue}\n type=\"password\"\n value={(value as string) || ''}\n />\n </div>\n </div>\n )\n}\n\nexport const PasswordField = withCondition(_PasswordField)\n"],"names":["React","useCallback","useField","withCondition","FieldError","FieldLabel","fieldBaseClass","_PasswordField","props","name","CustomError","CustomLabel","autoComplete","className","disabled","disabledFromProps","errorProps","label","labelProps","path","pathFromProps","required","style","validate","width","memoizedValidate","value","options","formInitializing","formProcessing","setValue","showError","div","filter","Boolean","join","input","id","replace","onChange","type","PasswordField"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;;AAGA,OAAOA,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,OAAO,eAAc;AAerB,MAAMC,iBAA+C,CAACC;IACpD,MAAM,EACJC,IAAI,EACJC,WAAW,EACXC,WAAW,EACXC,YAAY,EACZC,SAAS,EACTC,UAAUC,iBAAiB,EAC3BC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,MAAMC,aAAa,EACnBC,QAAQ,EACRC,KAAK,EACLC,QAAQ,EACRC,KAAK,EACN,GAAGhB;IAEJ,MAAMiB,mBAAmCxB,YACvC,CAACyB,OAAOC;QACN,IAAI,OAAOJ,aAAa,YAAY;YAClC,OAAOA,SAASG,OAAO;gBAAE,GAAGC,OAAO;gBAAEN;YAAS;QAChD;IACF,GACA;QAACE;QAAUF;KAAS;IAGtB,MAAM,EAAEO,gBAAgB,EAAEC,cAAc,EAAEV,IAAI,EAAEW,QAAQ,EAAEC,SAAS,EAAEL,KAAK,EAAE,GAAGxB,SAAS;QACtFiB,MAAMC,iBAAiBX;QACvBc,UAAUE;IACZ;IAEA,MAAMX,WAAWC,qBAAqBa,oBAAoBC;IAE1D,qBACE,MAACG;QACCnB,WAAW;YACTP;YACA;YACAO;YACAkB,aAAa;YACbjB,YAAY;SACb,CACEmB,MAAM,CAACC,SACPC,IAAI,CAAC;QACRb,OAAO;YACL,GAAGA,KAAK;YACRE;QACF;;0BAEA,KAACnB;gBACCM,aAAaA;gBACbM,OAAOA;gBACPI,UAAUA;gBACT,GAAIH,cAAc,CAAC,CAAC;;0BAEvB,MAACc;gBAAInB,WAAW,CAAC,EAAEP,eAAe,MAAM,CAAC;;kCACvC,KAACF;wBAAWM,aAAaA;wBAAaS,MAAMA;wBAAO,GAAIH,cAAc,CAAC,CAAC;;kCACvE,KAACoB;wBACCxB,cAAcA;wBACdE,UAAUA;wBACVuB,IAAI,CAAC,MAAM,EAAElB,KAAKmB,OAAO,CAAC,OAAO,MAAM,CAAC;wBACxC7B,MAAMU;wBACNoB,UAAUT;wBACVU,MAAK;wBACLd,OAAO,AAACA,SAAoB;;;;;;AAKtC;AAEA,OAAO,MAAMe,gBAAgBtC,cAAcI,gBAAe"}
|
|
@@ -8,5 +8,6 @@ export type PointFieldProps = FormFieldBase & {
|
|
|
8
8
|
step?: number;
|
|
9
9
|
width?: string;
|
|
10
10
|
};
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const _PointField: React.FC<PointFieldProps>;
|
|
12
|
+
export declare const PointField: React.FC<PointFieldProps>;
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Point/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAM1C,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAOvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Point/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAM1C,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAOvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA0IjD,CAAA;AAED,eAAO,MAAM,UAAU,2BAA6B,CAAA"}
|
|
@@ -12,7 +12,7 @@ import { useFieldProps } from '../../forms/FieldPropsProvider/index.js';
|
|
|
12
12
|
import { FieldDescription } from '../FieldDescription/index.js';
|
|
13
13
|
import { FieldError } from '../FieldError/index.js';
|
|
14
14
|
import { FieldLabel } from '../FieldLabel/index.js';
|
|
15
|
-
const
|
|
15
|
+
export const _PointField = (props)=>{
|
|
16
16
|
const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, label, labelProps, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, step, style, validate, width } = props;
|
|
17
17
|
const { i18n, t } = useTranslation();
|
|
18
18
|
const memoizedValidate = useCallback((value, options)=>{
|
|
@@ -134,6 +134,6 @@ const PointField = (props)=>{
|
|
|
134
134
|
]
|
|
135
135
|
});
|
|
136
136
|
};
|
|
137
|
-
export const
|
|
137
|
+
export const PointField = withCondition(_PointField);
|
|
138
138
|
|
|
139
139
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Point/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'point'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\n\nexport type PointFieldProps = FormFieldBase & {\n name?: string\n path?: string\n placeholder?: string\n step?: number\n width?: string\n}\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Point/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback } from 'react'\n\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport './index.scss'\n\nconst baseClass = 'point'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { useFieldProps } from '../../forms/FieldPropsProvider/index.js'\nimport { FieldDescription } from '../FieldDescription/index.js'\nimport { FieldError } from '../FieldError/index.js'\nimport { FieldLabel } from '../FieldLabel/index.js'\n\nexport type PointFieldProps = FormFieldBase & {\n name?: string\n path?: string\n placeholder?: string\n step?: number\n width?: string\n}\n\nexport const _PointField: React.FC<PointFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n step,\n style,\n validate,\n width,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const {\n path,\n setValue,\n showError,\n value = [null, null],\n } = useField<[number, number]>({\n path: pathFromContext ?? pathFromProps ?? name,\n validate: memoizedValidate,\n })\n\n const handleChange = useCallback(\n (e, index: 0 | 1) => {\n let val = parseFloat(e.target.value)\n if (Number.isNaN(val)) {\n val = e.target.value\n }\n const coordinates = [...value]\n coordinates[index] = val\n setValue(coordinates)\n },\n [setValue, value],\n )\n\n const getCoordinateFieldLabel = (type: 'latitude' | 'longitude') => {\n const suffix = type === 'longitude' ? t('fields:longitude') : t('fields:latitude')\n const fieldLabel = label ? getTranslation(label, i18n) : ''\n\n return {\n ...labelProps,\n label: `${fieldLabel}${fieldLabel ? ' - ' : ''}${suffix}`,\n }\n }\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n <ul className={`${baseClass}__wrap`}>\n <li>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : (\n <FieldLabel {...getCoordinateFieldLabel('longitude')} />\n )}\n <div className=\"input-wrapper\">\n {BeforeInput}\n <input\n disabled={readOnly}\n id={`field-longitude-${path.replace(/\\./g, '__')}`}\n name={`${path}.longitude`}\n onChange={(e) => handleChange(e, 0)}\n placeholder={getTranslation(placeholder, i18n)}\n step={step}\n type=\"number\"\n value={value && typeof value[0] === 'number' ? value[0] : ''}\n />\n {AfterInput}\n </div>\n </li>\n <li>\n {CustomLabel !== undefined ? (\n CustomLabel\n ) : (\n <FieldLabel {...getCoordinateFieldLabel('latitude')} />\n )}\n <div className=\"input-wrapper\">\n {BeforeInput}\n <input\n disabled={readOnly}\n id={`field-latitude-${path.replace(/\\./g, '__')}`}\n name={`${path}.latitude`}\n onChange={(e) => handleChange(e, 1)}\n placeholder={getTranslation(placeholder, i18n)}\n step={step}\n type=\"number\"\n value={value && typeof value[1] === 'number' ? value[1] : ''}\n />\n {AfterInput}\n </div>\n </li>\n </ul>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const PointField = withCondition(_PointField)\n"],"names":["getTranslation","React","useCallback","useField","withCondition","useTranslation","fieldBaseClass","baseClass","useFieldProps","FieldDescription","FieldError","FieldLabel","_PointField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","step","style","validate","width","i18n","t","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","setValue","showError","handleChange","e","index","val","parseFloat","target","Number","isNaN","coordinates","getCoordinateFieldLabel","type","suffix","fieldLabel","div","filter","Boolean","join","ul","li","undefined","input","disabled","id","replace","onChange","PointField"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD;;AAGA,SAASA,cA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E,KAAK,WAAWA,KAAK,CAAC,EAAE,GAAG;;oCAE3DvB;;;;;kCAGL,MAAC+C;;4BACE3C,gBAAgB4C,YACf5C,4BAEA,KAACR;gCAAY,GAAG0C,wBAAwB,WAAW;;0CAErD,MAACI;gCAAIrC,WAAU;;oCACZJ;kDACD,KAACgD;wCACCC,UAAUrC;wCACVsC,IAAI,CAAC,eAAe,EAAEzC,KAAK0C,OAAO,CAAC,OAAO,MAAM,CAAC;wCACjDrD,MAAM,CAAC,EAAEW,KAAK,SAAS,CAAC;wCACxB2C,UAAU,CAACvB,IAAMD,aAAaC,GAAG;wCACjClB,aAAa3B,eAAe2B,aAAaQ;wCACzCJ,MAAMA;wCACNuB,MAAK;wCACLhB,OAAOA,SAAS,OAAOA,KAAK,CAAC,EAAE,KAAK,WAAWA,KAAK,CAAC,EAAE,GAAG;;oCAE3DvB;;;;;;;YAINE,sBAAsB8C,YACrB9C,kCAEA,KAACR;gBAAkB,GAAIY,oBAAoB,CAAC,CAAC;;;;AAIrD,EAAC;AAED,OAAO,MAAMgD,aAAajE,cAAcQ,aAAY"}
|
|
@@ -12,5 +12,5 @@ export type RadioFieldProps = FormFieldBase & {
|
|
|
12
12
|
width?: string;
|
|
13
13
|
};
|
|
14
14
|
export type OnChange<T = string> = (value: T) => void;
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const RadioGroupField: React.FC<RadioFieldProps>;
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/RadioGroup/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC,OAAO,KAAsB,MAAM,OAAO,CAAA;AAQ1C,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;AA8HrD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/RadioGroup/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC,OAAO,KAAsB,MAAM,OAAO,CAAA;AAQ1C,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMvD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;AA8HrD,eAAO,MAAM,eAAe,2BAAkC,CAAA"}
|
|
@@ -13,7 +13,7 @@ const baseClass = 'radio-group';
|
|
|
13
13
|
import { useFieldProps } from '../../forms/FieldPropsProvider/index.js';
|
|
14
14
|
import { FieldDescription } from '../FieldDescription/index.js';
|
|
15
15
|
import { FieldError } from '../FieldError/index.js';
|
|
16
|
-
const
|
|
16
|
+
const _RadioGroupField = (props)=>{
|
|
17
17
|
const { name, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, label, labelProps, layout = 'horizontal', onChange: onChangeFromProps, options = [], path: pathFromProps, readOnly: readOnlyFromProps, required, style, validate, value: valueFromProps, width } = props;
|
|
18
18
|
const { uuid } = useForm();
|
|
19
19
|
const memoizedValidate = useCallback((value, validationOptions)=>{
|
|
@@ -105,6 +105,6 @@ const RadioGroupField = (props)=>{
|
|
|
105
105
|
]
|
|
106
106
|
});
|
|
107
107
|
};
|
|
108
|
-
export const
|
|
108
|
+
export const RadioGroupField = withCondition(_RadioGroupField);
|
|
109
109
|
|
|
110
110
|
//# sourceMappingURL=index.js.map
|