@payloadcms/ui 3.0.0-beta.27 → 3.0.0-beta.29
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/FieldSelect/index.d.ts.map +1 -1
- package/dist/elements/FieldSelect/index.js +4 -1
- package/dist/elements/FieldSelect/index.js.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.d.ts.map +1 -1
- package/dist/elements/TableColumns/buildColumnState.js +2 -1
- package/dist/elements/TableColumns/buildColumnState.js.map +1 -1
- package/dist/{providers/ComponentMap/buildComponentMap/WithServerSideProps.d.ts → elements/WithServerSideProps/index.d.ts} +1 -1
- package/dist/elements/WithServerSideProps/index.d.ts.map +1 -0
- package/dist/{providers/ComponentMap/buildComponentMap/WithServerSideProps.js → elements/WithServerSideProps/index.js} +3 -3
- package/dist/elements/WithServerSideProps/index.js.map +1 -0
- package/dist/fields/Array/index.d.ts +0 -2
- package/dist/fields/Array/index.d.ts.map +1 -1
- package/dist/fields/Array/index.js +1 -1
- package/dist/fields/Array/index.js.map +1 -1
- package/dist/fields/Blocks/index.d.ts +1 -2
- package/dist/fields/Blocks/index.d.ts.map +1 -1
- package/dist/fields/Blocks/index.js.map +1 -1
- package/dist/fields/Checkbox/Input.d.ts +3 -3
- package/dist/fields/Checkbox/Input.d.ts.map +1 -1
- package/dist/fields/Checkbox/Input.js.map +1 -1
- package/dist/fields/Checkbox/types.d.ts +0 -2
- package/dist/fields/Checkbox/types.d.ts.map +1 -1
- package/dist/fields/Checkbox/types.js.map +1 -1
- package/dist/fields/Code/index.d.ts +1 -2
- package/dist/fields/Code/index.d.ts.map +1 -1
- package/dist/fields/Code/index.js.map +1 -1
- package/dist/fields/Collapsible/index.d.ts +0 -2
- 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/DateTime/index.d.ts +1 -2
- package/dist/fields/DateTime/index.d.ts.map +1 -1
- package/dist/fields/DateTime/index.js.map +1 -1
- package/dist/fields/Email/index.d.ts +1 -2
- package/dist/fields/Email/index.d.ts.map +1 -1
- package/dist/fields/Email/index.js.map +1 -1
- package/dist/fields/Group/index.d.ts +0 -2
- package/dist/fields/Group/index.d.ts.map +1 -1
- package/dist/fields/Group/index.js +3 -3
- package/dist/fields/Group/index.js.map +1 -1
- package/dist/fields/JSON/index.d.ts +1 -2
- package/dist/fields/JSON/index.d.ts.map +1 -1
- package/dist/fields/JSON/index.js.map +1 -1
- package/dist/fields/Number/index.d.ts +1 -2
- package/dist/fields/Number/index.d.ts.map +1 -1
- package/dist/fields/Number/index.js.map +1 -1
- package/dist/fields/Password/index.d.ts +0 -1
- package/dist/fields/Password/index.d.ts.map +1 -1
- package/dist/fields/Password/index.js.map +1 -1
- package/dist/fields/Point/index.d.ts +0 -2
- 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 -2
- package/dist/fields/RadioGroup/index.d.ts.map +1 -1
- package/dist/fields/RadioGroup/index.js.map +1 -1
- package/dist/fields/Relationship/types.d.ts +1 -2
- package/dist/fields/Relationship/types.d.ts.map +1 -1
- package/dist/fields/Relationship/types.js.map +1 -1
- package/dist/fields/RichText/index.d.ts +0 -2
- package/dist/fields/RichText/index.d.ts.map +1 -1
- package/dist/fields/RichText/index.js.map +1 -1
- package/dist/fields/Select/index.d.ts +1 -2
- package/dist/fields/Select/index.d.ts.map +1 -1
- package/dist/fields/Select/index.js.map +1 -1
- package/dist/fields/Text/index.d.ts.map +1 -1
- package/dist/fields/Text/index.js +2 -1
- package/dist/fields/Text/index.js.map +1 -1
- package/dist/fields/Text/types.d.ts +1 -2
- package/dist/fields/Text/types.d.ts.map +1 -1
- package/dist/fields/Text/types.js.map +1 -1
- package/dist/fields/Textarea/index.d.ts.map +1 -1
- package/dist/fields/Textarea/index.js +2 -1
- package/dist/fields/Textarea/index.js.map +1 -1
- package/dist/fields/Textarea/types.d.ts +1 -2
- package/dist/fields/Textarea/types.d.ts.map +1 -1
- package/dist/fields/Textarea/types.js.map +1 -1
- package/dist/fields/Upload/types.d.ts +0 -1
- package/dist/fields/Upload/types.d.ts.map +1 -1
- package/dist/fields/Upload/types.js.map +1 -1
- package/dist/fields/shared/index.d.ts +3 -2
- package/dist/fields/shared/index.d.ts.map +1 -1
- package/dist/fields/shared/index.js.map +1 -1
- package/dist/forms/RowLabel/types.d.ts +2 -3
- package/dist/forms/RowLabel/types.d.ts.map +1 -1
- package/dist/forms/RowLabel/types.js +1 -4
- package/dist/forms/RowLabel/types.js.map +1 -1
- package/dist/graphics/Account/index.js +0 -9
- package/dist/graphics/Account/index.js.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/collections.js +16 -4
- package/dist/providers/ComponentMap/buildComponentMap/collections.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/fields.js +41 -36
- 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/globals.js +16 -4
- package/dist/providers/ComponentMap/buildComponentMap/globals.js.map +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/index.js +1 -1
- package/dist/providers/ComponentMap/buildComponentMap/index.js.map +1 -1
- package/dist/providers/ComponentMap/index.d.ts +0 -1
- package/dist/providers/ComponentMap/index.d.ts.map +1 -1
- package/dist/providers/ComponentMap/index.js +0 -1
- package/dist/providers/ComponentMap/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/providers/ComponentMap/buildComponentMap/WithServerSideProps.d.ts.map +0 -1
- package/dist/providers/ComponentMap/buildComponentMap/WithServerSideProps.js.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Option } from 'payload/types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import './index.scss';
|
|
4
4
|
import type { FormFieldBase } from '../shared/index.js';
|
|
5
5
|
export type RadioFieldProps = FormFieldBase & {
|
|
6
|
-
label?: FieldBase['label'];
|
|
7
6
|
layout?: 'horizontal' | 'vertical';
|
|
8
7
|
name?: string;
|
|
9
8
|
onChange?: OnChange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/RadioGroup/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/RadioGroup/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAG3C,OAAO,KAAsB,MAAM,OAAO,CAAA;AAQ1C,OAAO,cAAc,CAAA;AAQrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,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;AAyHrD,eAAO,MAAM,UAAU,2BAAiC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/RadioGroup/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n/* eslint-disable react-hooks/exhaustive-deps */\n'use client'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/RadioGroup/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n/* eslint-disable react-hooks/exhaustive-deps */\n'use client'\nimport type { Option } from 'payload/types'\n\nimport { optionIsObject } from 'payload/types'\nimport React, { useCallback } from 'react'\n\nimport { FieldLabel } from '../../forms/FieldLabel/index.js'\nimport { useForm } from '../../forms/Form/context.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { fieldBaseClass } from '../shared/index.js'\nimport { Radio } from './Radio/index.js'\nimport './index.scss'\n\nconst baseClass = 'radio-group'\n\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type RadioFieldProps = FormFieldBase & {\n layout?: 'horizontal' | 'vertical'\n name?: string\n onChange?: OnChange\n options?: Option[]\n path?: string\n value?: string\n width?: string\n}\n\nexport type OnChange<T = string> = (value: T) => void\n\nconst RadioGroupField: React.FC<RadioFieldProps> = (props) => {\n const {\n name,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n label,\n labelProps,\n layout = 'horizontal',\n onChange: onChangeFromProps,\n options = [],\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n required,\n style,\n validate,\n value: valueFromProps,\n width,\n } = props\n\n const { uuid } = useForm()\n\n const memoizedValidate = useCallback(\n (value, validationOptions) => {\n if (typeof validate === 'function')\n return validate(value, { ...validationOptions, options, required })\n },\n [validate, options, 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: valueFromContext,\n } = useField<string>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n const value = valueFromContext || valueFromProps\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n `${baseClass}--layout-${layout}`,\n showError && 'error',\n readOnly && `${baseClass}--read-only`,\n ]\n .filter(Boolean)\n .join(' ')}\n style={{\n ...style,\n width,\n }}\n >\n <div className={`${baseClass}__error-wrap`}>\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n </div>\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <ul className={`${baseClass}--group`} id={`field-${path.replace(/\\./g, '__')}`}>\n {options.map((option) => {\n let optionValue = ''\n\n if (optionIsObject(option)) {\n optionValue = option.value\n } else {\n optionValue = option\n }\n\n const isSelected = String(optionValue) === String(value)\n\n const id = `field-${path}-${optionValue}${uuid ? `-${uuid}` : ''}`\n\n return (\n <li key={`${path} - ${optionValue}`}>\n <Radio\n id={id}\n isSelected={isSelected}\n onChange={() => {\n if (typeof onChangeFromProps === 'function') {\n onChangeFromProps(optionValue)\n }\n\n if (!readOnly) {\n setValue(optionValue)\n }\n }}\n option={optionIsObject(option) ? option : { label: option, value: option }}\n path={path}\n uuid={uuid}\n />\n </li>\n )\n })}\n </ul>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const RadioGroup = withCondition(RadioGroupField)\n"],"names":["optionIsObject","React","useCallback","FieldLabel","useForm","useField","withCondition","fieldBaseClass","Radio","baseClass","FieldDescription","FieldError","useFieldProps","RadioGroupField","props","name","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","layout","onChange","onChangeFromProps","options","path","pathFromProps","readOnly","readOnlyFromProps","required","style","validate","value","valueFromProps","width","uuid","memoizedValidate","validationOptions","pathFromContext","readOnlyFromContext","setValue","showError","valueFromContext","div","filter","Boolean","join","ul","id","replace","map","option","optionValue","isSelected","String","li","key","undefined","RadioGroup"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD,8CAA8C,GAC9C;AAGA,SAASA,cAAc,QAAQ,gBAAe;AAC9C,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAE1C,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,OAAO,QAAQ,8BAA6B;AACrD,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,KAAK,QAAQ,mBAAkB;AAGxC,MAAMC,YAAY;AAElB,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AAgBvE,MAAMC,kBAA6C,CAACC;IAClD,MAAM,EACJC,IAAI,EACJC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,SAAS,YAAY,EACrBC,UAAUC,iBAAiB,EAC3BC,UAAU,EAAE,EACZC,MAAMC,aAAa,EACnBC,UAAUC,iBAAiB,EAC3BC,QAAQ,EACRC,KAAK,EACLC,QAAQ,EACRC,OAAOC,cAAc,EACrBC,KAAK,EACN,GAAGvB;IAEJ,MAAM,EAAEwB,IAAI,EAAE,GAAGlC;IAEjB,MAAMmC,mBAAmBrC,YACvB,CAACiC,OAAOK;QACN,IAAI,OAAON,aAAa,YACtB,OAAOA,SAASC,OAAO;YAAE,GAAGK,iBAAiB;YAAEb;YAASK;QAAS;IACrE,GACA;QAACE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C;QAElE,qBACE,oBAACoB;YAAGC,KAAK,CAAC,EAAE/B,KAAK,GAAG,EAAE2B,YAAY,CAAC;yBACjC,oBAAC/C;YACC2C,IAAIA;YACJK,YAAYA;YACZ/B,UAAU;gBACR,IAAI,OAAOC,sBAAsB,YAAY;oBAC3CA,kBAAkB6B;gBACpB;gBAEA,IAAI,CAACzB,UAAU;oBACba,SAASY;gBACX;YACF;YACAD,QAAQtD,eAAesD,UAAUA,SAAS;gBAAEhC,OAAOgC;gBAAQnB,OAAOmB;YAAO;YACzE1B,MAAMA;YACNU,MAAMA;;IAId,KAEDtB,sBAAsB4C,YACrB5C,kCAEA,oBAACN,kBAAsBU,oBAAoB,CAAC;AAIpD;AAEA,OAAO,MAAMyC,aAAavD,cAAcO,iBAAgB"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { I18n } from '@payloadcms/translations';
|
|
2
|
-
import type { ClientCollectionConfig,
|
|
2
|
+
import type { ClientCollectionConfig, RelationshipField } from 'payload/types';
|
|
3
3
|
import type { SanitizedConfig } from 'payload/types';
|
|
4
4
|
import type { FormFieldBase } from '../shared/index.js';
|
|
5
5
|
export type RelationshipFieldProps = FormFieldBase & {
|
|
6
6
|
allowCreate?: RelationshipField['admin']['allowCreate'];
|
|
7
7
|
hasMany?: boolean;
|
|
8
8
|
isSortable?: boolean;
|
|
9
|
-
label?: FieldBase['label'];
|
|
10
9
|
name: string;
|
|
11
10
|
relationTo?: RelationshipField['relationTo'];
|
|
12
11
|
sortOptions?: RelationshipField['admin']['sortOptions'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Relationship/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Relationship/types.ts"],"names":[],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E,sBAAsB,CAAA;IAClC,MAAM,EAAE,eAAe,CAAA;IACvB,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,QAAQ,CAAA;CACf,CAAA;AAED,KAAK,GAAG,GAAG;IACT,UAAU,EAAE,sBAAsB,CAAA;IAClC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,IAAI,EAAE,IAAI,CAAA;IACV,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,EAAE,KAAK,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,MAAM,CAAA;AAEzC,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE;IAC9B,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,CAAA;CACxB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Relationship/types.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { ClientCollectionConfig, FieldBase, RelationshipField } from 'payload/types'\nimport type { SanitizedConfig } from 'payload/types'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type RelationshipFieldProps = FormFieldBase & {\n allowCreate?: RelationshipField['admin']['allowCreate']\n hasMany?: boolean\n isSortable?: boolean\n
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Relationship/types.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { ClientCollectionConfig, FieldBase, RelationshipField } from 'payload/types'\nimport type { SanitizedConfig } from 'payload/types'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type RelationshipFieldProps = FormFieldBase & {\n allowCreate?: RelationshipField['admin']['allowCreate']\n hasMany?: boolean\n isSortable?: boolean\n name: string\n relationTo?: RelationshipField['relationTo']\n sortOptions?: RelationshipField['admin']['sortOptions']\n width?: string\n}\n\nexport type Option = {\n label: string\n options?: Option[]\n relationTo?: string\n value: number | string\n}\n\nexport type OptionGroup = {\n label: string\n options: Option[]\n}\n\nexport type ValueWithRelation = {\n relationTo: string\n value: number | string\n}\n\nexport type Value = ValueWithRelation | number | string\n\ntype CLEAR = {\n type: 'CLEAR'\n}\n\ntype UPDATE = {\n collection: ClientCollectionConfig\n config: SanitizedConfig\n doc: any\n i18n: I18n\n type: 'UPDATE'\n}\n\ntype ADD = {\n collection: ClientCollectionConfig\n config: SanitizedConfig\n docs: any[]\n i18n: I18n\n ids?: (number | string)[]\n sort?: boolean\n type: 'ADD'\n}\n\nexport type Action = ADD | CLEAR | UPDATE\n\nexport type GetResults = (args: {\n lastFullyLoadedRelation?: number\n lastLoadedPage: Record<string, number>\n onSuccess?: () => void\n search?: string\n sort?: boolean\n value?: Value | Value[]\n}) => Promise<void>\n"],"names":[],"rangeMappings":"","mappings":"AA2DA,WAOmB"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { FieldBase } from 'payload/types';
|
|
2
1
|
import type React from 'react';
|
|
3
2
|
import type { MappedField } from '../../providers/ComponentMap/buildComponentMap/types.js';
|
|
4
3
|
import type { FormFieldBase } from '../shared/index.js';
|
|
5
4
|
export type RichTextFieldProps = FormFieldBase & {
|
|
6
|
-
label?: FieldBase['label'];
|
|
7
5
|
name: string;
|
|
8
6
|
richTextComponentMap?: Map<string, MappedField[] | React.ReactNode>;
|
|
9
7
|
width?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/RichText/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/RichText/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yDAAyD,CAAA;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,IAAI,EAAE,MAAM,CAAA;IACZ,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,CAAA;IACnE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAEjD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/RichText/index.tsx"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/RichText/index.tsx"],"sourcesContent":["import type React from 'react'\n\nimport type { MappedField } from '../../providers/ComponentMap/buildComponentMap/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type RichTextFieldProps = FormFieldBase & {\n name: string\n richTextComponentMap?: Map<string, MappedField[] | React.ReactNode>\n width?: string\n}\n\nexport const RichText: React.FC<RichTextFieldProps> = () => {\n return null\n}\n"],"names":["RichText"],"rangeMappings":";;","mappings":"AAWA,OAAO,MAAMA,WAAyC;IACpD,OAAO;AACT,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Option } from 'payload/types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { FormFieldBase } from '../shared/index.js';
|
|
4
4
|
import './index.scss';
|
|
@@ -6,7 +6,6 @@ export type SelectFieldProps = FormFieldBase & {
|
|
|
6
6
|
hasMany?: boolean;
|
|
7
7
|
isClearable?: boolean;
|
|
8
8
|
isSortable?: boolean;
|
|
9
|
-
label?: FieldBase['label'];
|
|
10
9
|
name?: string;
|
|
11
10
|
onChange?: (e: string) => void;
|
|
12
11
|
options?: Option[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Select/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Select/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,MAAM,EAAgB,MAAM,eAAe,CAAA;AAOzE,OAAO,KAAgC,MAAM,OAAO,CAAA;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAOvD,OAAO,cAAc,CAAA;AAErB,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,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;AA0JD,eAAO,MAAM,MAAM,4BAA6B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Select/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate,
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Select/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate, Option, OptionObject } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { FieldDescription } from '@payloadcms/ui/forms/FieldDescription'\nimport { FieldError } from '@payloadcms/ui/forms/FieldError'\nimport { FieldLabel } from '@payloadcms/ui/forms/FieldLabel'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport React, { useCallback, useState } from 'react'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nimport { ReactSelect } from '../../elements/ReactSelect/index.js'\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\nexport type SelectFieldProps = FormFieldBase & {\n hasMany?: boolean\n isClearable?: boolean\n isSortable?: boolean\n name?: string\n onChange?: (e: string) => void\n options?: Option[]\n path?: string\n value?: string\n width?: string\n}\n\nconst formatOptions = (options: Option[]): OptionObject[] =>\n options.map((option) => {\n if (typeof option === 'object' && (option.value || option.value === '')) {\n return option\n }\n\n return {\n label: option,\n value: option,\n } as OptionObject\n })\n\nconst SelectField: React.FC<SelectFieldProps> = (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 isClearable = true,\n isSortable = true,\n label,\n labelProps,\n onChange: onChangeFromProps,\n options: optionsFromProps = [],\n path: pathFromProps,\n readOnly: readOnlyFromProps,\n required,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const [options] = useState(formatOptions(optionsFromProps))\n\n const memoizedValidate: ClientValidate = useCallback(\n (value, validationOptions) => {\n if (typeof validate === 'function')\n return validate(value, { ...validationOptions, hasMany, options, required })\n },\n [validate, required, hasMany, options],\n )\n\n const { path: pathFromContext, readOnly: readOnlyFromContext } = useFieldProps()\n const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { path, setValue, showError, value } = useField({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n let valueToRender\n\n if (hasMany && Array.isArray(value)) {\n valueToRender = value.map((val) => {\n const matchingOption = options.find((option) => option.value === val)\n return {\n label: matchingOption ? getTranslation(matchingOption.label, i18n) : val,\n value: matchingOption?.value ?? val,\n }\n })\n } else if (value) {\n const matchingOption = options.find((option) => option.value === value)\n valueToRender = {\n label: matchingOption ? getTranslation(matchingOption.label, i18n) : value,\n value: matchingOption?.value ?? value,\n }\n }\n\n const onChange = useCallback(\n (selectedOption) => {\n if (!readOnly) {\n let newValue\n if (!selectedOption) {\n newValue = null\n } else if (hasMany) {\n if (Array.isArray(selectedOption)) {\n newValue = selectedOption.map((option) => option.value)\n } else {\n newValue = []\n }\n } else {\n newValue = selectedOption.value\n }\n\n if (typeof onChangeFromProps === 'function') {\n onChangeFromProps(newValue)\n }\n\n setValue(newValue)\n }\n },\n [readOnly, hasMany, setValue, onChangeFromProps],\n )\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'select',\n className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n id={`field-${path.replace(/\\./g, '__')}`}\n style={{\n ...style,\n width,\n }}\n >\n <FieldError CustomError={CustomError} path={path} {...(errorProps || {})} />\n <FieldLabel\n CustomLabel={CustomLabel}\n label={label}\n required={required}\n {...(labelProps || {})}\n />\n <div>\n {BeforeInput}\n <ReactSelect\n disabled={readOnly}\n isClearable={isClearable}\n isMulti={hasMany}\n isSortable={isSortable}\n onChange={onChange}\n options={options.map((option) => ({\n ...option,\n label: getTranslation(option.label, i18n),\n }))}\n showError={showError}\n value={valueToRender as OptionObject}\n />\n {AfterInput}\n </div>\n {CustomDescription !== undefined ? (\n CustomDescription\n ) : (\n <FieldDescription {...(descriptionProps || {})} />\n )}\n </div>\n )\n}\n\nexport const Select = withCondition(SelectField)\n"],"names":["getTranslation","FieldDescription","FieldError","FieldLabel","useFieldProps","React","useCallback","useState","ReactSelect","useField","withCondition","useTranslation","fieldBaseClass","formatOptions","options","map","option","value","label","SelectField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","isClearable","isSortable","labelProps","onChange","onChangeFromProps","optionsFromProps","path","pathFromProps","readOnly","readOnlyFromProps","required","style","validate","width","i18n","memoizedValidate","validationOptions","pathFromContext","readOnlyFromContext","setValue","showError","valueToRender","Array","isArray","val","matchingOption","find","selectedOption","newValue","div","filter","Boolean","join","id","replace","disabled","isMulti","undefined","Select"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,wCAAuC;AACxE,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,UAAU,QAAQ,kCAAiC;AAC5D,SAASC,aAAa,QAAQ,0CAAyC;AACvE,OAAOC,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAO;AAIpD,SAASC,WAAW,QAAQ,sCAAqC;AACjE,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,qBAAoB;AAenD,MAAMC,gBAAgB,CAACC,UACrBA,QAAQC,GAAG,CAAC,CAACC;QACX,IAAI,OAAOA,WAAW,YAAaA,CAAAA,OAAOC,KAAK,IAAID,OAAOC,KAAK,KAAK,EAAC,GAAI;YACvE,OAAOD;QACT;QAEA,OAAO;YACLE,OAAOF;YACPC,OAAOD;QACT;IACF;AAEF,MAAMG,cAA0C,CAACC;IAC/C,MAAM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AAGA,MAAM;gBACTE,OAAOlB,eAAegB,OAAOE,KAAK,EAAE2B;YACtC,CAAA;QACAM,WAAWA;QACXlC,OAAOmC;QAER9B,aAEFE,sBAAsB4C,YACrB5C,kCAEA,oBAACvB,kBAAsB2B,oBAAoB,CAAC;AAIpD;AAEA,OAAO,MAAMyC,SAAS3D,cAAcS,aAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Text/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAOhE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Text/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAOhE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,CAAA;AAyIpD,eAAO,MAAM,IAAI,0BAA2B,CAAA"}
|
|
@@ -9,7 +9,7 @@ import { isFieldRTL } from '../shared/index.js';
|
|
|
9
9
|
import { TextInput } from './Input.js';
|
|
10
10
|
export { TextInput };
|
|
11
11
|
const TextField = (props)=>{
|
|
12
|
-
const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, hasMany, inputRef, labelProps, localized, maxLength, maxRows, minLength, minRows, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, rtl, style, validate, width } = props;
|
|
12
|
+
const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, hasMany, inputRef, label, labelProps, localized, maxLength, maxRows, minLength, minRows, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, rtl, style, validate, width } = props;
|
|
13
13
|
const locale = useLocale();
|
|
14
14
|
const { localization: localizationConfig } = useConfig();
|
|
15
15
|
const memoizedValidate = useCallback((value, options)=>{
|
|
@@ -87,6 +87,7 @@ const TextField = (props)=>{
|
|
|
87
87
|
errorProps: errorProps,
|
|
88
88
|
hasMany: hasMany,
|
|
89
89
|
inputRef: inputRef,
|
|
90
|
+
label: label,
|
|
90
91
|
labelProps: labelProps,
|
|
91
92
|
maxRows: maxRows,
|
|
92
93
|
minRows: minRows,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Text/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate } from 'payload/types'\nimport type {} from 'payload/types'\n\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { TextFieldProps, TextInputProps } from './types.js'\n\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 { TextFieldProps, TextInput, TextInputProps }\n\nconst TextField: React.FC<TextFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany,\n inputRef,\n labelProps,\n localized,\n maxLength,\n maxRows,\n minLength,\n minRows,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const locale = useLocale()\n\n const { localization: localizationConfig } = useConfig()\n\n const memoizedValidate: ClientValidate = 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 const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { formProcessing, path, setValue, showError, value } = useField({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\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 (!readOnly) {\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 [readOnly, 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 AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n hasMany={hasMany}\n inputRef={inputRef}\n labelProps={labelProps}\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={formProcessing || readOnly}\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 Text = withCondition(TextField)\n"],"names":["useFieldProps","React","useCallback","useEffect","useState","useField","withCondition","useConfig","useLocale","isFieldRTL","TextInput","TextField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","inputRef","labelProps","localized","maxLength","maxRows","minLength","minRows","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rtl","style","validate","width","locale","localization","localizationConfig","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formProcessing","setValue","showError","renderRTL","fieldLocalized","fieldRTL","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","val","index","id","
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Text/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientValidate } from 'payload/types'\nimport type {} from 'payload/types'\n\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport React, { useCallback, useEffect, useState } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { TextFieldProps, TextInputProps } from './types.js'\n\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 { TextFieldProps, TextInput, TextInputProps }\n\nconst TextField: React.FC<TextFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n hasMany,\n inputRef,\n label,\n labelProps,\n localized,\n maxLength,\n maxRows,\n minLength,\n minRows,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const locale = useLocale()\n\n const { localization: localizationConfig } = useConfig()\n\n const memoizedValidate: ClientValidate = 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 const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { formProcessing, path, setValue, showError, value } = useField({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\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 (!readOnly) {\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 [readOnly, 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 AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n hasMany={hasMany}\n inputRef={inputRef}\n label={label}\n labelProps={labelProps}\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={formProcessing || readOnly}\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 Text = withCondition(TextField)\n"],"names":["useFieldProps","React","useCallback","useEffect","useState","useField","withCondition","useConfig","useLocale","isFieldRTL","TextInput","TextField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","hasMany","inputRef","label","labelProps","localized","maxLength","maxRows","minLength","minRows","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rtl","style","validate","width","locale","localization","localizationConfig","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","formProcessing","setValue","showError","renderRTL","fieldLocalized","fieldRTL","undefined","valueToRender","setValueToRender","handleHasManyChange","selectedOption","newValue","Array","isArray","map","option","val","index","id","toString","onChange","e","target","Text"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAIA,SAASA,aAAa,QAAQ,0CAAyC;AACvE,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAK/D,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,SAAS,QAAQ,aAAY;AAGtC,SAAyBA,SAAS,GAAkB;AAEpD,MAAMC,YAAsC,CAACC;IAC3C,MAAM,EACJC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CC,WAAWD,eAAeI,GAAG,CAAC,CAACC,SAAWA,OAAOnB,KAAK,EAAEA,SAASmB,OAAOnB,KAAK;YAC/E,OAAO;gBACLe,WAAW;oBAACD,eAAed,KAAK,EAAEA,SAASc,eAAed,KAAK;iBAAC;YAClE;YAEAK,SAASU;QACX;IACF,GACA;QAAC1B;QAAUgB;KAAS;IAGtB,kCAAkC;IAClC/C,UAAU;QACR,IAAImB,WAAWuC,MAAMC,OAAO,CAACjB,QAAQ;YACnCY,iBACEZ,MAAMkB,GAAG,CAAC,CAACE,KAAKC;gBACd,OAAO;oBACLC,IAAI,CAAC,EAAEF,IAAI,EAAEC,MAAM,CAAC;oBACpB1C,OAAO,CAAC,EAAEyC,IAAI,CAAC;oBACfpB,OAAO;wBACL,4RAA4R;wBAC5RuB,UAAU,IAAM,CAAC,EAAEH,IAAI,EAAEC,MAAM,CAAC;wBAChCrB,OAAOoB,KAAKpB,SAASoB;oBACvB;gBACF;YACF;QAEJ;IACF,GAAG;QAACpB;QAAOvB;KAAQ;IAEnB,qBACE,oBAACZ;QACCI,YAAYA;QACZC,aAAaA;QACbC,mBAAmBA;QACnBC,aAAaA;QACbC,aAAaA;QACbC,WAAWA;QACXC,kBAAkBA;QAClBC,YAAYA;QACZC,SAASA;QACTC,UAAUA;QACVC,OAAOA;QACPC,YAAYA;QACZG,SAASA;QACTE,SAASA;QACTuC,UACE/C,UACIoC,sBACA,CAACY;YACCpB,SAASoB,EAAEC,MAAM,CAAC1B,KAAK;QACzB;QAENd,MAAMA;QACNE,aAAaA;QACbC,UAAUe,kBAAkBf;QAC5BE,UAAUA;QACVC,KAAKe;QACLD,WAAWA;QACXb,OAAOA;QACPO,OAAO,AAACA,SAAoB;QAC5BW,eAAeA;QACfhB,OAAOA;;AAGb;AAEA,OAAO,MAAMgC,OAAOlE,cAAcK,WAAU"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TextField } from 'payload/types';
|
|
2
2
|
import type { ChangeEvent } from 'react';
|
|
3
3
|
import type { Option } from '../../elements/ReactSelect/types.js';
|
|
4
4
|
import type { FormFieldBase } from '../shared/index.js';
|
|
5
5
|
export type TextFieldProps = FormFieldBase & {
|
|
6
6
|
hasMany?: boolean;
|
|
7
7
|
inputRef?: React.MutableRefObject<HTMLInputElement>;
|
|
8
|
-
label?: FieldBase['label'];
|
|
9
8
|
maxLength?: number;
|
|
10
9
|
maxRows?: number;
|
|
11
10
|
minLength?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Text/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Text/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAExC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAA;IACnD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAA;IACxD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAA;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,GAAG;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAA;IACnD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IACrD,SAAS,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAA;IACxD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Text/types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Text/types.ts"],"sourcesContent":["import type { TextField } from 'payload/types'\nimport type { ChangeEvent } from 'react'\n\nimport type { Option } from '../../elements/ReactSelect/types.js'\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type TextFieldProps = FormFieldBase & {\n hasMany?: boolean\n inputRef?: React.MutableRefObject<HTMLInputElement>\n maxLength?: number\n maxRows?: number\n minLength?: number\n minRows?: number\n name?: string\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>\n path?: string\n placeholder?: TextField['admin']['placeholder']\n width?: string\n}\n\nexport type TextInputProps = Omit<TextFieldProps, 'type'> & {\n hasMany?: boolean\n inputRef?: React.MutableRefObject<HTMLInputElement>\n maxRows?: number\n minRows?: number\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>\n showError?: boolean\n value?: string\n valueToRender?: Option[]\n}\n"],"names":[],"rangeMappings":"","mappings":"AAoBA,WAUC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAOxE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAOxE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAA;AAsFhE,eAAO,MAAM,QAAQ,8BAA+B,CAAA"}
|
|
@@ -10,7 +10,7 @@ import { isFieldRTL } from '../shared/index.js';
|
|
|
10
10
|
import { TextareaInput } from './Input.js';
|
|
11
11
|
export { TextareaInput };
|
|
12
12
|
const TextareaField = (props)=>{
|
|
13
|
-
const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, labelProps, locale, localized, maxLength, minLength, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, rows, rtl, style, validate, width } = props;
|
|
13
|
+
const { name, AfterInput, BeforeInput, CustomDescription, CustomError, CustomLabel, className, descriptionProps, errorProps, label, labelProps, locale, localized, maxLength, minLength, path: pathFromProps, placeholder, readOnly: readOnlyFromProps, required, rows, rtl, style, validate, width } = props;
|
|
14
14
|
const { i18n } = useTranslation();
|
|
15
15
|
const { localization } = useConfig();
|
|
16
16
|
const isRTL = isFieldRTL({
|
|
@@ -47,6 +47,7 @@ const TextareaField = (props)=>{
|
|
|
47
47
|
className: className,
|
|
48
48
|
descriptionProps: descriptionProps,
|
|
49
49
|
errorProps: errorProps,
|
|
50
|
+
label: label,
|
|
50
51
|
labelProps: labelProps,
|
|
51
52
|
onChange: (e)=>{
|
|
52
53
|
setValue(e.target.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Textarea/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport React, { useCallback } from 'react'\n\nimport type { TextAreaInputProps, TextareaFieldProps } from './types.js'\n\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, TextareaFieldProps, TextareaInput }\n\nconst TextareaField: React.FC<TextareaFieldProps> = (props) => {\n const {\n name,\n AfterInput,\n BeforeInput,\n CustomDescription,\n CustomError,\n CustomLabel,\n className,\n descriptionProps,\n errorProps,\n labelProps,\n locale,\n localized,\n maxLength,\n minLength,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rows,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const { localization } = useConfig()\n\n const isRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localization || undefined,\n })\n\n const memoizedValidate: ClientValidate = 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 const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n return (\n <TextareaInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n labelProps={labelProps}\n onChange={(e) => {\n setValue(e.target.value)\n }}\n path={path}\n placeholder={getTranslation(placeholder, i18n)}\n readOnly={readOnly}\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 Textarea = withCondition(TextareaField)\n"],"names":["getTranslation","useFieldProps","React","useCallback","useField","withCondition","useConfig","useTranslation","isFieldRTL","TextareaInput","TextareaField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","labelProps","locale","localized","maxLength","minLength","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rows","rtl","style","validate","width","i18n","localization","isRTL","fieldLocalized","fieldRTL","localizationConfig","undefined","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","setValue","showError","onChange","e","target","Textarea"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Textarea/index.tsx"],"sourcesContent":["/* eslint-disable react/destructuring-assignment */\n'use client'\nimport type { ClientValidate } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport React, { useCallback } from 'react'\n\nimport type { TextAreaInputProps, TextareaFieldProps } from './types.js'\n\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, TextareaFieldProps, TextareaInput }\n\nconst TextareaField: React.FC<TextareaFieldProps> = (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 locale,\n localized,\n maxLength,\n minLength,\n path: pathFromProps,\n placeholder,\n readOnly: readOnlyFromProps,\n required,\n rows,\n rtl,\n style,\n validate,\n width,\n } = props\n\n const { i18n } = useTranslation()\n\n const { localization } = useConfig()\n\n const isRTL = isFieldRTL({\n fieldLocalized: localized,\n fieldRTL: rtl,\n locale,\n localizationConfig: localization || undefined,\n })\n\n const memoizedValidate: ClientValidate = 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 const readOnly = readOnlyFromProps || readOnlyFromContext\n\n const { path, setValue, showError, value } = useField<string>({\n path: pathFromContext || pathFromProps || name,\n validate: memoizedValidate,\n })\n\n return (\n <TextareaInput\n AfterInput={AfterInput}\n BeforeInput={BeforeInput}\n CustomDescription={CustomDescription}\n CustomError={CustomError}\n CustomLabel={CustomLabel}\n className={className}\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={readOnly}\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 Textarea = withCondition(TextareaField)\n"],"names":["getTranslation","useFieldProps","React","useCallback","useField","withCondition","useConfig","useTranslation","isFieldRTL","TextareaInput","TextareaField","props","name","AfterInput","BeforeInput","CustomDescription","CustomError","CustomLabel","className","descriptionProps","errorProps","label","labelProps","locale","localized","maxLength","minLength","path","pathFromProps","placeholder","readOnly","readOnlyFromProps","required","rows","rtl","style","validate","width","i18n","localization","isRTL","fieldLocalized","fieldRTL","localizationConfig","undefined","memoizedValidate","value","options","pathFromContext","readOnlyFromContext","setValue","showError","onChange","e","target","Textarea"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,iDAAiD,GACjD;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,aAAa,QAAQ,0CAAyC;AACvE,OAAOC,SAASC,WAAW,QAAQ,QAAO;AAI1C,SAASC,QAAQ,QAAQ,gCAA+B;AACxD,SAASC,aAAa,QAAQ,qCAAoC;AAClE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,aAAa,QAAQ,aAAY;AAG1C,SAAiDA,aAAa,GAAE;AAEhE,MAAMC,gBAA8C,CAACC;IACnD,MAAM,EACJC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,MAAMC,aAAa,EACnBC,WAAW,EACXC,UAAUC,iBAAiB,EAC3BC,QAAQ,EACRC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,QAAQ,EACRC,KAAK,EACN,GAAG1B;IAEJ,MAAM,EAAE2B,IAAI,EAAE,GAAG/B;IAEjB,MAAM,EAAEgC,YAAY,EAAE,GAAGjC;IAEzB,MAAMkC,QAAQhC,WAAW;QACvBiC,gBAAgBjB;QAChBkB,UAAUR;QACVX;QACAoB,oBAAoBJ,gBAAgBK;IACtC;IAEA,MAAMC,mBAAmC1C,YACvC,CAAC2C,OAAOC;QACN,IAAI,OAAOX,aAAa,YACtB,OAAOA,SAASU,OAAO;YAAE,GAAGC,OAAO;YAAEtB;YAAWC;YAAWM;QAAS;IACxE,GACA;QAACI;QAAUJ;QAAUP;QAAWC;KAAU;IAG5C,MAAM,EAAEC,MAAMqB,eAAe,EAAElB,UAAUmB,mBAAmB,EAAE,GAAGhD;IACjE,MAAM6B,WAAWC,qBAAqBkB;IAEtC,MAAM,EAAEtB,IAAI,EAAEuB,QAAQ,EAAEC,SAAS,EAAEL,KAAK,EAAE,GAAG1C,SAAiB;QAC5DuB,MAAMqB,mBAAmBpB,iBAAiBhB;QAC1CwB,UAAUS;IACZ;IAEA,qBACE,oBAACpC;QACCI,YAAYA;QACZC,aAAaA;QACbC,mBAAmBA;QACnBC,aAAaA;QACbC,aAAaA;QACbC,WAAWA;QACXC,kBAAkBA;QAClBC,YAAYA;QACZC,OAAOA;QACPC,YAAYA;QACZ8B,UAAU,CAACC;YACTH,SAASG,EAAEC,MAAM,CAACR,KAAK;QACzB;QACAnB,MAAMA;QACNE,aAAa7B,eAAe6B,aAAaS;QACzCR,UAAUA;QACVE,UAAUA;QACVC,MAAMA;QACNC,KAAKM;QACLW,WAAWA;QACXhB,OAAOA;QACPW,OAAOA;QACPT,OAAOA;;AAGb;AAEA,OAAO,MAAMkB,WAAWlD,cAAcK,eAAc"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TextareaField as TextareaFieldType } from 'payload/types';
|
|
2
2
|
import { type ChangeEvent } from 'react';
|
|
3
3
|
import type { FormFieldBase } from '../shared/index.js';
|
|
4
4
|
export type TextareaFieldProps = FormFieldBase & {
|
|
5
|
-
label?: FieldBase['label'];
|
|
6
5
|
maxLength?: number;
|
|
7
6
|
minLength?: number;
|
|
8
7
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Textarea/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAEvE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAA;AAExC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAA;IACvD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG;IACpD,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAAA;IACxD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Textarea/types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Textarea/types.ts"],"sourcesContent":["import type { TextareaField as TextareaFieldType } from 'payload/types'\n\nimport { type ChangeEvent } from 'react'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type TextareaFieldProps = FormFieldBase & {\n maxLength?: number\n minLength?: number\n name?: string\n path?: string\n placeholder?: TextareaFieldType['admin']['placeholder']\n rows?: number\n width?: string\n}\n\nexport type TextAreaInputProps = TextareaFieldProps & {\n onChange?: (e: ChangeEvent<HTMLTextAreaElement>) => void\n rows?: number\n showError?: boolean\n value?: string\n}\n"],"names":[],"rangeMappings":"","mappings":"AAgBA,WAKC"}
|
|
@@ -2,7 +2,6 @@ import type { UploadField } from 'payload/types';
|
|
|
2
2
|
import type { FormFieldBase } from '../shared/index.js';
|
|
3
3
|
export type UploadFieldProps = FormFieldBase & {
|
|
4
4
|
filterOptions?: UploadField['filterOptions'];
|
|
5
|
-
label?: UploadField['label'];
|
|
6
5
|
name?: string;
|
|
7
6
|
path?: string;
|
|
8
7
|
relationTo?: UploadField['relationTo'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Upload/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,aAAa,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAA;IAC5C,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/Upload/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,aAAa,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAA;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;IACtC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/Upload/types.ts"],"sourcesContent":["import type { UploadField } from 'payload/types'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type UploadFieldProps = FormFieldBase & {\n filterOptions?: UploadField['filterOptions']\n
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/Upload/types.ts"],"sourcesContent":["import type { UploadField } from 'payload/types'\n\nimport type { FormFieldBase } from '../shared/index.js'\n\nexport type UploadFieldProps = FormFieldBase & {\n filterOptions?: UploadField['filterOptions']\n name?: string\n path?: string\n relationTo?: UploadField['relationTo']\n width?: string\n}\n"],"names":[],"rangeMappings":"","mappings":"AAIA,WAMC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
2
|
import type { User } from 'payload/auth';
|
|
3
3
|
import type { Locale, SanitizedLocalizationConfig } from 'payload/config';
|
|
4
|
-
import type { DocumentPreferences, ErrorProps, FieldDescriptionProps, LabelProps, Validate } from 'payload/types';
|
|
4
|
+
import type { DocumentPreferences, ErrorProps, FieldDescriptionProps, LabelProps, SanitizedLabelProps, Validate } from 'payload/types';
|
|
5
5
|
export declare const fieldBaseClass = "field-type";
|
|
6
6
|
export type FormFieldBase = {
|
|
7
7
|
AfterInput?: React.ReactNode;
|
|
@@ -15,7 +15,8 @@ export type FormFieldBase = {
|
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
docPreferences?: DocumentPreferences;
|
|
17
17
|
errorProps?: ErrorProps;
|
|
18
|
-
|
|
18
|
+
label?: LabelProps['label'];
|
|
19
|
+
labelProps?: SanitizedLabelProps;
|
|
19
20
|
locale?: Locale;
|
|
20
21
|
localized?: boolean;
|
|
21
22
|
path?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/shared/index.tsx"],"names":[],"mappings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tsx"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { Locale, SanitizedLocalizationConfig } from 'payload/config'\nimport type {\n DocumentPreferences,\n ErrorProps,\n FieldDescriptionProps,\n LabelProps,\n Validate,\n} from 'payload/types'\n\nexport const fieldBaseClass = 'field-type'\n\nexport type FormFieldBase = {\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n CustomDescription?: React.ReactNode\n CustomError?: React.ReactNode\n CustomLabel?: React.ReactNode\n className?: string\n custom?: Record<string, any>\n descriptionProps?: FieldDescriptionProps\n disabled?: boolean\n docPreferences?: DocumentPreferences\n errorProps?: ErrorProps\n
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/shared/index.tsx"],"sourcesContent":["import type { User } from 'payload/auth'\nimport type { Locale, SanitizedLocalizationConfig } from 'payload/config'\nimport type {\n DocumentPreferences,\n ErrorProps,\n FieldDescriptionProps,\n LabelProps,\n SanitizedLabelProps,\n Validate,\n} from 'payload/types'\n\nexport const fieldBaseClass = 'field-type'\n\nexport type FormFieldBase = {\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n CustomDescription?: React.ReactNode\n CustomError?: React.ReactNode\n CustomLabel?: React.ReactNode\n className?: string\n custom?: Record<string, any>\n descriptionProps?: FieldDescriptionProps\n disabled?: boolean\n docPreferences?: DocumentPreferences\n errorProps?: ErrorProps\n label?: LabelProps['label']\n labelProps?: SanitizedLabelProps\n locale?: Locale\n localized?: boolean\n path?: string\n readOnly?: boolean\n required?: boolean\n rtl?: boolean\n style?: React.CSSProperties\n user?: User\n validate?: Validate\n}\n\n/**\n * Determines whether a field should be displayed as right-to-left (RTL) based on its configuration, payload's localization configuration and the adming user's currently enabled locale.\n\n * @returns Whether the field should be displayed as RTL.\n */\nexport function isFieldRTL({\n fieldLocalized,\n fieldRTL,\n locale,\n localizationConfig,\n}: {\n fieldLocalized: boolean\n fieldRTL: boolean\n locale: Locale\n localizationConfig?: SanitizedLocalizationConfig\n}) {\n const hasMultipleLocales =\n locale &&\n localizationConfig &&\n localizationConfig.locales &&\n localizationConfig.locales.length > 1\n\n const isCurrentLocaleDefaultLocale = locale?.code === localizationConfig?.defaultLocale\n\n return (\n (fieldRTL !== false &&\n locale?.rtl === true &&\n (fieldLocalized ||\n (!fieldLocalized && !hasMultipleLocales) || // If there is only one locale which is also rtl, that field is rtl too\n (!fieldLocalized && isCurrentLocaleDefaultLocale))) || // If the current locale is the default locale, but the field is not localized, that field is rtl too\n fieldRTL === true\n ) // If fieldRTL is true. This should be useful for when no localization is set at all in the payload config, but you still want fields to be rtl.\n}\n"],"names":["fieldBaseClass","isFieldRTL","fieldLocalized","fieldRTL","locale","localizationConfig","hasMultipleLocales","locales","length","isCurrentLocaleDefaultLocale","code","defaultLocale","rtl"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAWA,OAAO,MAAMA,iBAAiB,aAAY;AA2B1C;;;;CAIC,GACD,OAAO,SAASC,WAAW,EACzBC,cAAc,EACdC,QAAQ,EACRC,MAAM,EACNC,kBAAkB,EAMnB;IACC,MAAMC,qBACJF,UACAC,sBACAA,mBAAmBE,OAAO,IAC1BF,mBAAmBE,OAAO,CAACC,MAAM,GAAG;IAEtC,MAAMC,+BAA+BL,QAAQM,SAASL,oBAAoBM;IAE1E,OACE,AAACR,aAAa,SACZC,QAAQQ,QAAQ,QACfV,CAAAA,kBACE,CAACA,kBAAkB,CAACI,sBAAuB,uEAAuE;IAClH,CAACJ,kBAAkBO,4BAA4B,KAAO,qGAAqG;IAChKN,aAAa,KACb,gJAAgJ;;AACpJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { I18n } from '@payloadcms/translations';
|
|
2
|
-
import type { LabelProps
|
|
3
|
-
import React from 'react';
|
|
2
|
+
import type { LabelProps } from 'payload/types';
|
|
3
|
+
import type React from 'react';
|
|
4
4
|
export type Props = {
|
|
5
5
|
RowLabelComponent?: React.ReactNode;
|
|
6
6
|
className?: string;
|
|
@@ -9,5 +9,4 @@ export type Props = {
|
|
|
9
9
|
rowLabel?: LabelProps['label'];
|
|
10
10
|
rowNumber?: number;
|
|
11
11
|
};
|
|
12
|
-
export declare function isComponent(label: RowLabel): label is RowLabelComponent;
|
|
13
12
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forms/RowLabel/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/forms/RowLabel/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,MAAM,KAAK,GAAG;IAClB,iBAAiB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACnC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/RowLabel/types.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { LabelProps
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/RowLabel/types.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { LabelProps } from 'payload/types'\nimport type React from 'react'\n\nexport type Props = {\n RowLabelComponent?: React.ReactNode\n className?: string\n i18n: I18n\n path: string\n rowLabel?: LabelProps['label']\n rowNumber?: number\n}\n"],"names":[],"rangeMappings":"","mappings":"AAIA,WAOC"}
|
|
@@ -23,14 +23,5 @@ export const Account = ()=>{
|
|
|
23
23
|
active: isOnAccountPage
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
function isClassComponent(component) {
|
|
27
|
-
return typeof component === 'function' && !!component.prototype.isReactComponent;
|
|
28
|
-
}
|
|
29
|
-
function isFunctionComponent(component) {
|
|
30
|
-
return typeof component === 'function' && String(component).includes('return React.createElement');
|
|
31
|
-
}
|
|
32
|
-
function isReactComponent(component) {
|
|
33
|
-
return isClassComponent(component) || isFunctionComponent(component);
|
|
34
|
-
}
|
|
35
26
|
|
|
36
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/graphics/Account/index.tsx"],"sourcesContent":["'use client'\nimport { usePathname } from 'next/navigation.js'\nimport React from 'react'\n\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { DefaultAccountIcon } from './Default/index.js'\nexport { DefaultAccountIcon } from './Default/index.js'\nimport { GravatarAccountIcon } from './Gravatar/index.js'\nexport { GravatarAccountIcon } from './Gravatar/index.js'\n\nexport const Account = () => {\n const {\n admin: { avatar: Avatar },\n routes: { admin: adminRoute },\n } = useConfig()\n const { user } = useAuth()\n const pathname = usePathname()\n\n const isOnAccountPage = pathname === `${adminRoute}/account`\n\n if (!user?.email || Avatar === 'default') return <DefaultAccountIcon active={isOnAccountPage} />\n if (Avatar === 'gravatar') return <GravatarAccountIcon />\n if (Avatar) return <Avatar active={isOnAccountPage} />\n return <DefaultAccountIcon active={isOnAccountPage} />\n}\n
|
|
1
|
+
{"version":3,"sources":["../../../src/graphics/Account/index.tsx"],"sourcesContent":["'use client'\nimport { usePathname } from 'next/navigation.js'\nimport React from 'react'\n\nimport { useAuth } from '../../providers/Auth/index.js'\nimport { useConfig } from '../../providers/Config/index.js'\nimport { DefaultAccountIcon } from './Default/index.js'\nexport { DefaultAccountIcon } from './Default/index.js'\nimport { GravatarAccountIcon } from './Gravatar/index.js'\nexport { GravatarAccountIcon } from './Gravatar/index.js'\n\nexport const Account = () => {\n const {\n admin: { avatar: Avatar },\n routes: { admin: adminRoute },\n } = useConfig()\n const { user } = useAuth()\n const pathname = usePathname()\n\n const isOnAccountPage = pathname === `${adminRoute}/account`\n\n if (!user?.email || Avatar === 'default') return <DefaultAccountIcon active={isOnAccountPage} />\n if (Avatar === 'gravatar') return <GravatarAccountIcon />\n if (Avatar) return <Avatar active={isOnAccountPage} />\n return <DefaultAccountIcon active={isOnAccountPage} />\n}\n"],"names":["usePathname","React","useAuth","useConfig","DefaultAccountIcon","GravatarAccountIcon","Account","admin","avatar","Avatar","routes","adminRoute","user","pathname","isOnAccountPage","email","active"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,WAAW,QAAQ,qBAAoB;AAChD,OAAOC,WAAW,QAAO;AAEzB,SAASC,OAAO,QAAQ,gCAA+B;AACvD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASA,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,mBAAmB,QAAQ,sBAAqB;AACzD,SAASA,mBAAmB,QAAQ,sBAAqB;AAEzD,OAAO,MAAMC,UAAU;IACrB,MAAM,EACJC,OAAO,EAAEC,QAAQC,MAAM,EAAE,EACzBC,QAAQ,EAAEH,OAAOI,UAAU,EAAE,EAC9B,GAAGR;IACJ,MAAM,EAAES,IAAI,EAAE,GAAGV;IACjB,MAAMW,WAAWb;IAEjB,MAAMc,kBAAkBD,aAAa,CAAC,EAAEF,WAAW,QAAQ,CAAC;IAE5D,IAAI,CAACC,MAAMG,SAASN,WAAW,WAAW,qBAAO,oBAACL;QAAmBY,QAAQF;;IAC7E,IAAIL,WAAW,YAAY,qBAAO,oBAACJ;IACnC,IAAII,QAAQ,qBAAO,oBAACA;QAAOO,QAAQF;;IACnC,qBAAO,oBAACV;QAAmBY,QAAQF;;AACrC,EAAC"}
|
|
@@ -2,7 +2,7 @@ import type { I18n } from '@payloadcms/translations';
|
|
|
2
2
|
import type { AdminViewProps, EditViewProps, SanitizedCollectionConfig, SanitizedConfig, WithServerSideProps as WithServerSidePropsType } from 'payload/types';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import type { CollectionComponentMap } from './types.js';
|
|
5
|
-
export declare const mapCollections: (
|
|
5
|
+
export declare const mapCollections: (args: {
|
|
6
6
|
DefaultEditView: React.FC<EditViewProps>;
|
|
7
7
|
DefaultListView: React.FC<AdminViewProps>;
|
|
8
8
|
WithServerSideProps: WithServerSidePropsType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../../src/providers/ComponentMap/buildComponentMap/collections.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../../src/providers/ComponentMap/buildComponentMap/collections.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,yBAAyB,EACzB,eAAe,EACf,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAKxD,eAAO,MAAM,cAAc,SAAU;IACnC,eAAe,EAAE,MAAM,EAAE,CAAC,aAAa,CAAC,CAAA;IACxC,eAAe,EAAE,MAAM,EAAE,CAAC,cAAc,CAAC,CAAA;IACzC,mBAAmB,EAAE,uBAAuB,CAAA;IAC5C,WAAW,EAAE,yBAAyB,EAAE,CAAA;IACxC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,IAAI,CAAA;IACV,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,KAAG;IACF,CAAC,GAAG,EAAE,yBAAyB,CAAC,MAAM,CAAC,GAAG,sBAAsB,CAAA;CAiKjE,CAAA"}
|