Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
9.6 KiB
Plaintext
1 line
9.6 KiB
Plaintext
{"version":3,"file":"index.js","names":["getTranslation","React","useCallback","useMemo","RenderCustomComponent","FieldDescription","FieldError","FieldLabel","useField","withCondition","useTranslation","mergeFieldStyles","fieldBaseClass","baseClass","PointFieldComponent","props","field","admin","className","description","placeholder","step","label","localized","required","path","pathFromProps","readOnly","validate","i18n","t","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","setValue","showError","potentiallyStalePath","handleChange","e","index","val","parseFloat","target","Number","isNaN","coordinates","getCoordinateFieldLabel","type","suffix","fieldLabel","styles","_jsxs","filter","Boolean","join","style","_jsx","CustomComponent","Fallback","id","replace","name","onChange","PointField"],"sources":["../../../src/fields/Point/index.tsx"],"sourcesContent":["'use client'\nimport type { PointFieldClientComponent, PointFieldValidation } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport React, { useCallback, useMemo } from 'react'\n\nimport { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js'\nimport { FieldDescription } from '../../fields/FieldDescription/index.js'\nimport { FieldError } from '../../fields/FieldError/index.js'\nimport { FieldLabel } from '../../fields/FieldLabel/index.js'\nimport { useField } from '../../forms/useField/index.js'\nimport { withCondition } from '../../forms/withCondition/index.js'\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { mergeFieldStyles } from '../mergeFieldStyles.js'\nimport './index.scss'\nimport { fieldBaseClass } from '../shared/index.js'\n\nconst baseClass = 'point'\n\nexport const PointFieldComponent: PointFieldClientComponent = (props) => {\n const {\n field,\n field: {\n admin: { className, description, placeholder, step } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly,\n validate,\n } = props\n\n const { i18n, t } = useTranslation()\n\n const memoizedValidate: PointFieldValidation = useCallback(\n (value, options) => {\n if (typeof validate === 'function') {\n return validate(value, { ...options, required })\n }\n },\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n path,\n setValue,\n showError,\n value = [null, null],\n } = useField<[number, number]>({\n potentiallyStalePath: pathFromProps,\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 `${fieldLabel}${fieldLabel ? ' - ' : ''}${suffix}`\n }\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div\n className={[\n fieldBaseClass,\n baseClass,\n className,\n showError && 'error',\n (readOnly || disabled) && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n style={styles}\n >\n <ul className={`${baseClass}__wrap`}>\n <li>\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel\n label={getCoordinateFieldLabel('longitude')}\n localized={localized}\n path={path}\n required={required}\n />\n }\n />\n <div className=\"input-wrapper\">\n {BeforeInput}\n {/* disable eslint rule because the label is dynamic */}\n {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}\n <input\n disabled={readOnly || disabled}\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 <RenderCustomComponent\n CustomComponent={Label}\n Fallback={\n <FieldLabel\n label={getCoordinateFieldLabel('latitude')}\n localized={localized}\n path={path}\n required={required}\n />\n }\n />\n <div className=\"input-wrapper\">\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n {/* disable eslint rule because the label is dynamic */}\n {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}\n <input\n disabled={readOnly || disabled}\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 <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n )\n}\n\nexport const PointField = withCondition(PointFieldComponent)\n"],"mappings":"AAAA;;;AAGA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAE5C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,UAAU,QAAQ;AAC3B,SAASC,UAAU,QAAQ;AAC3B,SAASC,QAAQ,QAAQ;AACzB,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ;AACjC,OAAO;AACP,SAASC,cAAc,QAAQ;AAE/B,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,mBAAA,GAAkDC,KAAA;EAC7D,MAAM;IACJC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC,WAAW;QAAEC;MAAI,CAAE,GAAG,CAAC,CAAC;MACzDC,KAAK;MACLC,SAAS;MACTC;IAAQ,CACT;IACDC,IAAA,EAAMC,aAAa;IACnBC,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