@payloadcms/plugin-ecommerce 3.83.0-internal.ddc1147 → 3.83.0

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.
@@ -12,13 +12,13 @@ export const PriceCell = (args)=>{
12
12
  children: t('plugin-ecommerce:currencyNotSet')
13
13
  });
14
14
  }
15
- if ((!cellData || typeof cellData !== 'number') && 'enableVariants' in rowData && rowData.enableVariants) {
15
+ if ((cellData == null || typeof cellData !== 'number') && 'enableVariants' in rowData && rowData.enableVariants) {
16
16
  // @ts-expect-error - plugin translations are not typed yet
17
17
  return /*#__PURE__*/ _jsx("span", {
18
18
  children: t('plugin-ecommerce:priceSetInVariants')
19
19
  });
20
20
  }
21
- if (!cellData) {
21
+ if (cellData == null) {
22
22
  // @ts-expect-error - plugin translations are not typed yet
23
23
  return /*#__PURE__*/ _jsx("span", {
24
24
  children: t('plugin-ecommerce:priceNotSet')
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ui/PriceCell/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultCellComponentProps, TypedCollection } from 'payload'\n\nimport { useTranslation } from '@payloadcms/ui'\n\nimport type { CurrenciesConfig, Currency } from '../../types/index.js'\n\nimport { convertFromBaseValue } from '../utilities.js'\n\ntype Props = {\n cellData?: number\n currenciesConfig: CurrenciesConfig\n currency?: Currency\n path: string\n rowData: Partial<TypedCollection['products']>\n} & DefaultCellComponentProps\n\nexport const PriceCell: React.FC<Props> = (args) => {\n const { t } = useTranslation()\n const { cellData, currenciesConfig, currency: currencyFromProps, rowData } = args\n\n const currency = currencyFromProps || currenciesConfig.supportedCurrencies[0]\n\n if (!currency) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:currencyNotSet')}</span>\n }\n\n if (\n (!cellData || typeof cellData !== 'number') &&\n 'enableVariants' in rowData &&\n rowData.enableVariants\n ) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:priceSetInVariants')}</span>\n }\n\n if (!cellData) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:priceNotSet')}</span>\n }\n\n return (\n <span>\n {currency.symbol}\n {convertFromBaseValue({ baseValue: cellData, currency })}\n </span>\n )\n}\n"],"names":["useTranslation","convertFromBaseValue","PriceCell","args","t","cellData","currenciesConfig","currency","currencyFromProps","rowData","supportedCurrencies","span","enableVariants","symbol","baseValue"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,iBAAgB;AAI/C,SAASC,oBAAoB,QAAQ,kBAAiB;AAUtD,OAAO,MAAMC,YAA6B,CAACC;IACzC,MAAM,EAAEC,CAAC,EAAE,GAAGJ;IACd,MAAM,EAAEK,QAAQ,EAAEC,gBAAgB,EAAEC,UAAUC,iBAAiB,EAAEC,OAAO,EAAE,GAAGN;IAE7E,MAAMI,WAAWC,qBAAqBF,iBAAiBI,mBAAmB,CAAC,EAAE;IAE7E,IAAI,CAACH,UAAU;QACb,2DAA2D;QAC3D,qBAAO,KAACI;sBAAMP,EAAE;;IAClB;IAEA,IACE,AAAC,CAAA,CAACC,YAAY,OAAOA,aAAa,QAAO,KACzC,oBAAoBI,WACpBA,QAAQG,cAAc,EACtB;QACA,2DAA2D;QAC3D,qBAAO,KAACD;sBAAMP,EAAE;;IAClB;IAEA,IAAI,CAACC,UAAU;QACb,2DAA2D;QAC3D,qBAAO,KAACM;sBAAMP,EAAE;;IAClB;IAEA,qBACE,MAACO;;YACEJ,SAASM,MAAM;YACfZ,qBAAqB;gBAAEa,WAAWT;gBAAUE;YAAS;;;AAG5D,EAAC"}
1
+ {"version":3,"sources":["../../../src/ui/PriceCell/index.tsx"],"sourcesContent":["'use client'\nimport type { DefaultCellComponentProps, TypedCollection } from 'payload'\n\nimport { useTranslation } from '@payloadcms/ui'\n\nimport type { CurrenciesConfig, Currency } from '../../types/index.js'\n\nimport { convertFromBaseValue } from '../utilities.js'\n\ntype Props = {\n cellData?: number\n currenciesConfig: CurrenciesConfig\n currency?: Currency\n path: string\n rowData: Partial<TypedCollection['products']>\n} & DefaultCellComponentProps\n\nexport const PriceCell: React.FC<Props> = (args) => {\n const { t } = useTranslation()\n const { cellData, currenciesConfig, currency: currencyFromProps, rowData } = args\n\n const currency = currencyFromProps || currenciesConfig.supportedCurrencies[0]\n\n if (!currency) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:currencyNotSet')}</span>\n }\n\n if (\n (cellData == null || typeof cellData !== 'number') &&\n 'enableVariants' in rowData &&\n rowData.enableVariants\n ) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:priceSetInVariants')}</span>\n }\n\n if (cellData == null) {\n // @ts-expect-error - plugin translations are not typed yet\n return <span>{t('plugin-ecommerce:priceNotSet')}</span>\n }\n\n return (\n <span>\n {currency.symbol}\n {convertFromBaseValue({ baseValue: cellData, currency })}\n </span>\n )\n}\n"],"names":["useTranslation","convertFromBaseValue","PriceCell","args","t","cellData","currenciesConfig","currency","currencyFromProps","rowData","supportedCurrencies","span","enableVariants","symbol","baseValue"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,iBAAgB;AAI/C,SAASC,oBAAoB,QAAQ,kBAAiB;AAUtD,OAAO,MAAMC,YAA6B,CAACC;IACzC,MAAM,EAAEC,CAAC,EAAE,GAAGJ;IACd,MAAM,EAAEK,QAAQ,EAAEC,gBAAgB,EAAEC,UAAUC,iBAAiB,EAAEC,OAAO,EAAE,GAAGN;IAE7E,MAAMI,WAAWC,qBAAqBF,iBAAiBI,mBAAmB,CAAC,EAAE;IAE7E,IAAI,CAACH,UAAU;QACb,2DAA2D;QAC3D,qBAAO,KAACI;sBAAMP,EAAE;;IAClB;IAEA,IACE,AAACC,CAAAA,YAAY,QAAQ,OAAOA,aAAa,QAAO,KAChD,oBAAoBI,WACpBA,QAAQG,cAAc,EACtB;QACA,2DAA2D;QAC3D,qBAAO,KAACD;sBAAMP,EAAE;;IAClB;IAEA,IAAIC,YAAY,MAAM;QACpB,2DAA2D;QAC3D,qBAAO,KAACM;sBAAMP,EAAE;;IAClB;IAEA,qBACE,MAACO;;YACEJ,SAASM,MAAM;YACfZ,qBAAqB;gBAAEa,WAAWT;gBAAUE;YAAS;;;AAG5D,EAAC"}
@@ -10,6 +10,7 @@ interface Props {
10
10
  path: string;
11
11
  placeholder?: string;
12
12
  readOnly?: boolean;
13
+ required?: boolean;
13
14
  supportedCurrencies: Currency[];
14
15
  }
15
16
  export declare const FormattedInput: React.FC<Props>;
@@ -1 +1 @@
1
- {"version":3,"file":"FormattedInput.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceInput/FormattedInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAK7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAKpD,UAAU,KAAK;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,mBAAmB,EAAE,QAAQ,EAAE,CAAA;CAChC;AAID,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA0I1C,CAAA"}
1
+ {"version":3,"file":"FormattedInput.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceInput/FormattedInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAK7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAKpD,UAAU,KAAK;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,mBAAmB,EAAE,QAAQ,EAAE,CAAA;CAChC;AAID,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA2I1C,CAAA"}
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import { USD } from '../../currencies/index.js';
6
6
  import { convertFromBaseValue, convertToBaseValue } from '../utilities.js';
7
7
  const baseClass = 'formattedPrice';
8
- export const FormattedInput = ({ id: idFromProps, currency: currencyFromProps, description, disabled = false, label, path, placeholder = '0.00', readOnly, supportedCurrencies })=>{
8
+ export const FormattedInput = ({ id: idFromProps, currency: currencyFromProps, description, disabled = false, label, path, placeholder = '0.00', readOnly, required, supportedCurrencies })=>{
9
9
  const { setValue, value } = useField({
10
10
  path
11
11
  });
@@ -110,7 +110,8 @@ export const FormattedInput = ({ id: idFromProps, currency: currencyFromProps, d
110
110
  label && /*#__PURE__*/ _jsx(FieldLabel, {
111
111
  as: "label",
112
112
  htmlFor: id,
113
- label: label
113
+ label: label,
114
+ required: required
114
115
  }),
115
116
  /*#__PURE__*/ _jsxs("div", {
116
117
  className: `${baseClass}Container`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ui/PriceInput/FormattedInput.tsx"],"sourcesContent":["'use client'\n\nimport type { StaticDescription, StaticLabel } from 'payload'\n\nimport { FieldDescription, FieldLabel, useField, useFormFields } from '@payloadcms/ui'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { Currency } from '../../types/index.js'\n\nimport { USD } from '../../currencies/index.js'\nimport { convertFromBaseValue, convertToBaseValue } from '../utilities.js'\n\ninterface Props {\n currency?: Currency\n description?: StaticDescription\n disabled?: boolean\n error?: string\n id?: string\n label?: StaticLabel\n path: string\n placeholder?: string\n readOnly?: boolean\n supportedCurrencies: Currency[]\n}\n\nconst baseClass = 'formattedPrice'\n\nexport const FormattedInput: React.FC<Props> = ({\n id: idFromProps,\n currency: currencyFromProps,\n description,\n disabled = false,\n label,\n path,\n placeholder = '0.00',\n readOnly,\n supportedCurrencies,\n}) => {\n const { setValue, value } = useField<number>({ path })\n const [displayValue, setDisplayValue] = useState<string>('')\n\n const inputRef = useRef<HTMLInputElement>(null)\n const isFirstRender = useRef(true)\n const debounceTimer = useRef<NodeJS.Timeout | null>(null)\n\n const parentPath = path.split('.').slice(0, -1).join('.')\n const currencyPath = parentPath ? `${parentPath}.currency` : 'currency'\n\n const currencyFromSelectField = useFormFields(([fields, _]) => fields[currencyPath])\n\n const currencyCode = currencyFromProps?.code ?? (currencyFromSelectField?.value as string)\n const id = idFromProps || path\n\n const currency = useMemo<Currency>(() => {\n if (currencyCode && supportedCurrencies) {\n const foundCurrency = supportedCurrencies.find(\n (supportedCurrency) => supportedCurrency.code === currencyCode,\n )\n\n return foundCurrency ?? supportedCurrencies[0] ?? USD\n }\n\n return supportedCurrencies[0] ?? USD\n }, [currencyCode, supportedCurrencies])\n\n useEffect(() => {\n if (isFirstRender.current) {\n isFirstRender.current = false\n\n if (value === undefined || value === null) {\n setDisplayValue('')\n } else {\n setDisplayValue(convertFromBaseValue({ baseValue: value, currency }))\n }\n }\n }, [currency, value, currencyFromProps])\n\n const updateValue = useCallback(\n (inputValue: string) => {\n if (inputValue === '') {\n setValue(null)\n\n return\n }\n\n const baseValue = convertToBaseValue({ currency, displayValue: inputValue })\n\n setValue(baseValue)\n },\n [currency, setValue],\n )\n\n const handleInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const inputValue = e.target.value\n\n if (!/^\\d*(?:\\.\\d*)?$/.test(inputValue) && inputValue !== '') {\n return\n }\n\n setDisplayValue(inputValue)\n\n // Clear any existing timer\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current)\n }\n\n // Only update the base value after a delay to avoid formatting while typing\n debounceTimer.current = setTimeout(() => {\n updateValue(inputValue)\n }, 500)\n },\n [updateValue, setDisplayValue],\n )\n\n const handleInputBlur = useCallback(() => {\n if (displayValue === '') {\n return\n }\n\n // Clear any pending debounce\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current)\n debounceTimer.current = null\n }\n\n const baseValue = convertToBaseValue({ currency, displayValue })\n const formattedValue = convertFromBaseValue({ baseValue, currency })\n\n if (value != baseValue) {\n setValue(baseValue)\n }\n\n setDisplayValue(formattedValue)\n }, [currency, displayValue, setValue, value])\n\n return (\n <div className={`field-type number ${baseClass}`}>\n {label && <FieldLabel as=\"label\" htmlFor={id} label={label} />}\n\n <div className={`${baseClass}Container`}>\n <div className={`${baseClass}CurrencySymbol`}>\n <span>{currency.symbol}</span>\n </div>\n\n {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}\n <input\n className={`${baseClass}Input`}\n disabled={disabled || readOnly}\n id={id}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n placeholder={placeholder}\n ref={inputRef}\n type=\"text\"\n value={displayValue}\n />\n </div>\n <FieldDescription\n className={`${baseClass}Description`}\n description={description}\n path={path}\n />\n </div>\n )\n}\n"],"names":["FieldDescription","FieldLabel","useField","useFormFields","useCallback","useEffect","useMemo","useRef","useState","USD","convertFromBaseValue","convertToBaseValue","baseClass","FormattedInput","id","idFromProps","currency","currencyFromProps","description","disabled","label","path","placeholder","readOnly","supportedCurrencies","setValue","value","displayValue","setDisplayValue","inputRef","isFirstRender","debounceTimer","parentPath","split","slice","join","currencyPath","currencyFromSelectField","fields","_","currencyCode","code","foundCurrency","find","supportedCurrency","current","undefined","baseValue","updateValue","inputValue","handleInputChange","e","target","test","clearTimeout","setTimeout","handleInputBlur","formattedValue","div","className","as","htmlFor","span","symbol","input","onBlur","onChange","ref","type"],"mappings":"AAAA;;AAIA,SAASA,gBAAgB,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,iBAAgB;AACtF,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAIzE,SAASC,GAAG,QAAQ,4BAA2B;AAC/C,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,kBAAiB;AAe1E,MAAMC,YAAY;AAElB,OAAO,MAAMC,iBAAkC,CAAC,EAC9CC,IAAIC,WAAW,EACfC,UAAUC,iBAAiB,EAC3BC,WAAW,EACXC,WAAW,KAAK,EAChBC,KAAK,EACLC,IAAI,EACJC,cAAc,MAAM,EACpBC,QAAQ,EACRC,mBAAmB,EACpB;IACC,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGxB,SAAiB;QAAEmB;IAAK;IACpD,MAAM,CAACM,cAAcC,gBAAgB,GAAGpB,SAAiB;IAEzD,MAAMqB,WAAWtB,OAAyB;IAC1C,MAAMuB,gBAAgBvB,OAAO;IAC7B,MAAMwB,gBAAgBxB,OAA8B;IAEpD,MAAMyB,aAAaX,KAAKY,KAAK,CAAC,KAAKC,KAAK,CAAC,GAAG,CAAC,GAAGC,IAAI,CAAC;IACrD,MAAMC,eAAeJ,aAAa,GAAGA,WAAW,SAAS,CAAC,GAAG;IAE7D,MAAMK,0BAA0BlC,cAAc,CAAC,CAACmC,QAAQC,EAAE,GAAKD,MAAM,CAACF,aAAa;IAEnF,MAAMI,eAAevB,mBAAmBwB,QAASJ,yBAAyBX;IAC1E,MAAMZ,KAAKC,eAAeM;IAE1B,MAAML,WAAWV,QAAkB;QACjC,IAAIkC,gBAAgBhB,qBAAqB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,YAAYpC,mBAAmB;YAAEK;YAAUW;QAAa;QAC9D,MAAM8B,iBAAiB/C,qBAAqB;YAAEqC;YAAW/B;QAAS;QAElE,IAAIU,SAASqB,WAAW;YACtBtB,SAASsB;QACX;QAEAnB,gBAAgB6B;IAClB,GAAG;QAACzC;QAAUW;QAAcF;QAAUC;KAAM;IAE5C,qBACE,MAACgC;QAAIC,WAAW,CAAC,kBAAkB,EAAE/C,WAAW;;YAC7CQ,uBAAS,KAACnB;gBAAW2D,IAAG;gBAAQC,SAAS/C;gBAAIM,OAAOA;;0BAErD,MAACsC;gBAAIC,WAAW,GAAG/C,UAAU,SAAS,CAAC;;kCACrC,KAAC8C;wBAAIC,WAAW,GAAG/C,UAAU,cAAc,CAAC;kCAC1C,cAAA,KAACkD;sCAAM9C,SAAS+C,MAAM;;;kCAIxB,KAACC;wBACCL,WAAW,GAAG/C,UAAU,KAAK,CAAC;wBAC9BO,UAAUA,YAAYI;wBACtBT,IAAIA;wBACJmD,QAAQT;wBACRU,UAAUhB;wBACV5B,aAAaA;wBACb6C,KAAKtC;wBACLuC,MAAK;wBACL1C,OAAOC;;;;0BAGX,KAAC3B;gBACC2D,WAAW,GAAG/C,UAAU,WAAW,CAAC;gBACpCM,aAAaA;gBACbG,MAAMA;;;;AAId,EAAC"}
1
+ {"version":3,"sources":["../../../src/ui/PriceInput/FormattedInput.tsx"],"sourcesContent":["'use client'\n\nimport type { StaticDescription, StaticLabel } from 'payload'\n\nimport { FieldDescription, FieldLabel, useField, useFormFields } from '@payloadcms/ui'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { Currency } from '../../types/index.js'\n\nimport { USD } from '../../currencies/index.js'\nimport { convertFromBaseValue, convertToBaseValue } from '../utilities.js'\n\ninterface Props {\n currency?: Currency\n description?: StaticDescription\n disabled?: boolean\n error?: string\n id?: string\n label?: StaticLabel\n path: string\n placeholder?: string\n readOnly?: boolean\n required?: boolean\n supportedCurrencies: Currency[]\n}\n\nconst baseClass = 'formattedPrice'\n\nexport const FormattedInput: React.FC<Props> = ({\n id: idFromProps,\n currency: currencyFromProps,\n description,\n disabled = false,\n label,\n path,\n placeholder = '0.00',\n readOnly,\n required,\n supportedCurrencies,\n}) => {\n const { setValue, value } = useField<number>({ path })\n const [displayValue, setDisplayValue] = useState<string>('')\n\n const inputRef = useRef<HTMLInputElement>(null)\n const isFirstRender = useRef(true)\n const debounceTimer = useRef<NodeJS.Timeout | null>(null)\n\n const parentPath = path.split('.').slice(0, -1).join('.')\n const currencyPath = parentPath ? `${parentPath}.currency` : 'currency'\n\n const currencyFromSelectField = useFormFields(([fields, _]) => fields[currencyPath])\n\n const currencyCode = currencyFromProps?.code ?? (currencyFromSelectField?.value as string)\n const id = idFromProps || path\n\n const currency = useMemo<Currency>(() => {\n if (currencyCode && supportedCurrencies) {\n const foundCurrency = supportedCurrencies.find(\n (supportedCurrency) => supportedCurrency.code === currencyCode,\n )\n\n return foundCurrency ?? supportedCurrencies[0] ?? USD\n }\n\n return supportedCurrencies[0] ?? USD\n }, [currencyCode, supportedCurrencies])\n\n useEffect(() => {\n if (isFirstRender.current) {\n isFirstRender.current = false\n\n if (value === undefined || value === null) {\n setDisplayValue('')\n } else {\n setDisplayValue(convertFromBaseValue({ baseValue: value, currency }))\n }\n }\n }, [currency, value, currencyFromProps])\n\n const updateValue = useCallback(\n (inputValue: string) => {\n if (inputValue === '') {\n setValue(null)\n\n return\n }\n\n const baseValue = convertToBaseValue({ currency, displayValue: inputValue })\n\n setValue(baseValue)\n },\n [currency, setValue],\n )\n\n const handleInputChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n const inputValue = e.target.value\n\n if (!/^\\d*(?:\\.\\d*)?$/.test(inputValue) && inputValue !== '') {\n return\n }\n\n setDisplayValue(inputValue)\n\n // Clear any existing timer\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current)\n }\n\n // Only update the base value after a delay to avoid formatting while typing\n debounceTimer.current = setTimeout(() => {\n updateValue(inputValue)\n }, 500)\n },\n [updateValue, setDisplayValue],\n )\n\n const handleInputBlur = useCallback(() => {\n if (displayValue === '') {\n return\n }\n\n // Clear any pending debounce\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current)\n debounceTimer.current = null\n }\n\n const baseValue = convertToBaseValue({ currency, displayValue })\n const formattedValue = convertFromBaseValue({ baseValue, currency })\n\n if (value != baseValue) {\n setValue(baseValue)\n }\n\n setDisplayValue(formattedValue)\n }, [currency, displayValue, setValue, value])\n\n return (\n <div className={`field-type number ${baseClass}`}>\n {label && <FieldLabel as=\"label\" htmlFor={id} label={label} required={required} />}\n\n <div className={`${baseClass}Container`}>\n <div className={`${baseClass}CurrencySymbol`}>\n <span>{currency.symbol}</span>\n </div>\n\n {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}\n <input\n className={`${baseClass}Input`}\n disabled={disabled || readOnly}\n id={id}\n onBlur={handleInputBlur}\n onChange={handleInputChange}\n placeholder={placeholder}\n ref={inputRef}\n type=\"text\"\n value={displayValue}\n />\n </div>\n <FieldDescription\n className={`${baseClass}Description`}\n description={description}\n path={path}\n />\n </div>\n )\n}\n"],"names":["FieldDescription","FieldLabel","useField","useFormFields","useCallback","useEffect","useMemo","useRef","useState","USD","convertFromBaseValue","convertToBaseValue","baseClass","FormattedInput","id","idFromProps","currency","currencyFromProps","description","disabled","label","path","placeholder","readOnly","required","supportedCurrencies","setValue","value","displayValue","setDisplayValue","inputRef","isFirstRender","debounceTimer","parentPath","split","slice","join","currencyPath","currencyFromSelectField","fields","_","currencyCode","code","foundCurrency","find","supportedCurrency","current","undefined","baseValue","updateValue","inputValue","handleInputChange","e","target","test","clearTimeout","setTimeout","handleInputBlur","formattedValue","div","className","as","htmlFor","span","symbol","input","onBlur","onChange","ref","type"],"mappings":"AAAA;;AAIA,SAASA,gBAAgB,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,iBAAgB;AACtF,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO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AAS,KAACnB;gBAAW4D,IAAG;gBAAQC,SAAShD;gBAAIM,OAAOA;gBAAOI,UAAUA;;0BAEtE,MAACmC;gBAAIC,WAAW,GAAGhD,UAAU,SAAS,CAAC;;kCACrC,KAAC+C;wBAAIC,WAAW,GAAGhD,UAAU,cAAc,CAAC;kCAC1C,cAAA,KAACmD;sCAAM/C,SAASgD,MAAM;;;kCAIxB,KAACC;wBACCL,WAAW,GAAGhD,UAAU,KAAK,CAAC;wBAC9BO,UAAUA,YAAYI;wBACtBT,IAAIA;wBACJoD,QAAQT;wBACRU,UAAUhB;wBACV7B,aAAaA;wBACb8C,KAAKtC;wBACLuC,MAAK;wBACL1C,OAAOC;;;;0BAGX,KAAC5B;gBACC4D,WAAW,GAAGhD,UAAU,WAAW,CAAC;gBACpCM,aAAaA;gBACbG,MAAMA;;;;AAId,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAErD,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAItE,KAAK,KAAK,GAAG;IACX,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,sBAAsB,CAAA;AAE1B,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA6BtC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/PriceInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAErD,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAItE,KAAK,KAAK,GAAG;IACX,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,sBAAsB,CAAA;AAE1B,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA8BtC,CAAA"}
@@ -13,6 +13,7 @@ export const PriceInput = (args)=>{
13
13
  label: label,
14
14
  path: path,
15
15
  readOnly: readOnly,
16
+ required: field.required,
16
17
  supportedCurrencies: currenciesConfig?.supportedCurrencies
17
18
  });
18
19
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/ui/PriceInput/index.tsx"],"sourcesContent":["import type { NumberFieldServerProps } from 'payload'\n\nimport './index.css'\n\nimport type { CurrenciesConfig, Currency } from '../../types/index.js'\n\nimport { FormattedInput } from './FormattedInput.js'\n\ntype Props = {\n currenciesConfig: CurrenciesConfig\n currency?: Currency\n path: string\n} & NumberFieldServerProps\n\nexport const PriceInput: React.FC<Props> = (args) => {\n const {\n clientField: { label },\n currenciesConfig,\n currency: currencyFromProps,\n field,\n i18n: { t },\n i18n,\n path,\n readOnly,\n } = args\n\n const description = field.admin?.description\n ? typeof field.admin.description === 'function'\n ? // @ts-expect-error - weird type issue on 't' here\n field.admin.description({ i18n, t })\n : field.admin.description\n : undefined\n\n return (\n <FormattedInput\n currency={currencyFromProps}\n description={description}\n label={label}\n path={path}\n readOnly={readOnly}\n supportedCurrencies={currenciesConfig?.supportedCurrencies}\n />\n )\n}\n"],"names":["FormattedInput","PriceInput","args","clientField","label","currenciesConfig","currency","currencyFromProps","field","i18n","t","path","readOnly","description","admin","undefined","supportedCurrencies"],"mappings":";AAEA,OAAO,cAAa;AAIpB,SAASA,cAAc,QAAQ,sBAAqB;AAQpD,OAAO,MAAMC,aAA8B,CAACC;IAC1C,MAAM,EACJC,aAAa,EAAEC,KAAK,EAAE,EACtBC,gBAAgB,EAChBC,UAAUC,iBAAiB,EAC3BC,KAAK,EACLC,MAAM,EAAEC,CAAC,EAAE,EACXD,IAAI,EACJE,IAAI,EACJC,QAAQ,EACT,GAAGV;IAEJ,MAAMW,cAAcL,MAAMM,KAAK,EAAED,cAC7B,OAAOL,MAAMM,KAAK,CAACD,WAAW,KAAK,aAEjCL,MAAMM,KAAK,CAACD,WAAW,CAAC;QAAEJ;QAAMC;IAAE,KAClCF,MAAMM,KAAK,CAACD,WAAW,GACzBE;IAEJ,qBACE,KAACf;QACCM,UAAUC;QACVM,aAAaA;QACbT,OAAOA;QACPO,MAAMA;QACNC,UAAUA;QACVI,qBAAqBX,kBAAkBW;;AAG7C,EAAC"}
1
+ {"version":3,"sources":["../../../src/ui/PriceInput/index.tsx"],"sourcesContent":["import type { NumberFieldServerProps } from 'payload'\n\nimport './index.css'\n\nimport type { CurrenciesConfig, Currency } from '../../types/index.js'\n\nimport { FormattedInput } from './FormattedInput.js'\n\ntype Props = {\n currenciesConfig: CurrenciesConfig\n currency?: Currency\n path: string\n} & NumberFieldServerProps\n\nexport const PriceInput: React.FC<Props> = (args) => {\n const {\n clientField: { label },\n currenciesConfig,\n currency: currencyFromProps,\n field,\n i18n: { t },\n i18n,\n path,\n readOnly,\n } = args\n\n const description = field.admin?.description\n ? typeof field.admin.description === 'function'\n ? // @ts-expect-error - weird type issue on 't' here\n field.admin.description({ i18n, t })\n : field.admin.description\n : undefined\n\n return (\n <FormattedInput\n currency={currencyFromProps}\n description={description}\n label={label}\n path={path}\n readOnly={readOnly}\n required={field.required}\n supportedCurrencies={currenciesConfig?.supportedCurrencies}\n />\n )\n}\n"],"names":["FormattedInput","PriceInput","args","clientField","label","currenciesConfig","currency","currencyFromProps","field","i18n","t","path","readOnly","description","admin","undefined","required","supportedCurrencies"],"mappings":";AAEA,OAAO,cAAa;AAIpB,SAASA,cAAc,QAAQ,sBAAqB;AAQpD,OAAO,MAAMC,aAA8B,CAACC;IAC1C,MAAM,EACJC,aAAa,EAAEC,KAAK,EAAE,EACtBC,gBAAgB,EAChBC,UAAUC,iBAAiB,EAC3BC,KAAK,EACLC,MAAM,EAAEC,CAAC,EAAE,EACXD,IAAI,EACJE,IAAI,EACJC,QAAQ,EACT,GAAGV;IAEJ,MAAMW,cAAcL,MAAMM,KAAK,EAAED,cAC7B,OAAOL,MAAMM,KAAK,CAACD,WAAW,KAAK,aAEjCL,MAAMM,KAAK,CAACD,WAAW,CAAC;QAAEJ;QAAMC;IAAE,KAClCF,MAAMM,KAAK,CAACD,WAAW,GACzBE;IAEJ,qBACE,KAACf;QACCM,UAAUC;QACVM,aAAaA;QACbT,OAAOA;QACPO,MAAMA;QACNC,UAAUA;QACVI,UAAUR,MAAMQ,QAAQ;QACxBC,qBAAqBZ,kBAAkBY;;AAG7C,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-ecommerce",
3
- "version": "3.83.0-internal.ddc1147",
3
+ "version": "3.83.0",
4
4
  "description": "Ecommerce plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -74,8 +74,8 @@
74
74
  ],
75
75
  "dependencies": {
76
76
  "qs-esm": "8.0.1",
77
- "@payloadcms/translations": "3.83.0-internal.ddc1147",
78
- "@payloadcms/ui": "3.83.0-internal.ddc1147"
77
+ "@payloadcms/translations": "3.83.0",
78
+ "@payloadcms/ui": "3.83.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@types/json-schema": "7.0.15",
@@ -83,14 +83,14 @@
83
83
  "@types/react-dom": "19.2.3",
84
84
  "stripe": "18.3.0",
85
85
  "@payloadcms/eslint-config": "3.28.0",
86
- "@payloadcms/next": "3.83.0-internal.ddc1147",
87
- "@payloadcms/translations": "3.83.0-internal.ddc1147",
88
- "payload": "3.83.0-internal.ddc1147"
86
+ "@payloadcms/translations": "3.83.0",
87
+ "@payloadcms/next": "3.83.0",
88
+ "payload": "3.83.0"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
92
92
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
93
- "payload": "3.83.0-internal.ddc1147"
93
+ "payload": "3.83.0"
94
94
  },
95
95
  "publishConfig": {
96
96
  "registry": "https://registry.npmjs.org/"