@10x-media/form-builder 4.0.0-alpha.2 → 4.0.0-alpha.3

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/client/ByteSizeField.d.ts +1 -1
  3. package/dist/client/CalcExpressionBuilder.d.ts +1 -1
  4. package/dist/client/CalcExpressionBuilder.js +2 -2
  5. package/dist/client/CalcExpressionBuilder.js.map +1 -1
  6. package/dist/client/ClosePollButton.d.ts +1 -1
  7. package/dist/client/CondensedArray.d.ts +1 -1
  8. package/dist/client/ConditionBuilder.js +2 -2
  9. package/dist/client/ConditionBuilder.js.map +1 -1
  10. package/dist/client/ConsentBlockLabel.d.ts +1 -1
  11. package/dist/client/ConsentRetentionNotice.d.ts +1 -1
  12. package/dist/client/ConsentSourceRowLabel.d.ts +1 -1
  13. package/dist/client/EndpointOptionsSelect.d.ts +1 -1
  14. package/dist/client/FieldBlockLabel.d.ts +1 -1
  15. package/dist/client/FieldNameSelect.d.ts +1 -1
  16. package/dist/client/FieldNameSelect.js +2 -2
  17. package/dist/client/FieldNameSelect.js.map +1 -1
  18. package/dist/client/FlowBuilder.d.ts +1 -1
  19. package/dist/client/FlowBuilder.js +2 -2
  20. package/dist/client/FlowBuilder.js.map +1 -1
  21. package/dist/client/FormConditionField.d.ts +1 -1
  22. package/dist/client/RecipientsSelect.d.ts +1 -1
  23. package/dist/client/RecipientsSelect.js +2 -2
  24. package/dist/client/RecipientsSelect.js.map +1 -1
  25. package/dist/client/RuleDescription.d.ts +1 -1
  26. package/dist/collections/cells/FieldCountCell.d.ts +1 -1
  27. package/dist/collections/cells/FlowStepsCell.d.ts +1 -1
  28. package/dist/react/Form.d.ts +1 -1
  29. package/dist/react/FormControls.d.ts +1 -1
  30. package/dist/react/FormFields.d.ts +1 -1
  31. package/dist/react/FormLayout.d.ts +1 -1
  32. package/dist/react/FormSteps.d.ts +1 -1
  33. package/dist/react/Honeypot.d.ts +1 -1
  34. package/dist/react/Poll.d.ts +1 -1
  35. package/dist/react/captcha/HcaptchaCaptcha.d.ts +1 -1
  36. package/dist/react/captcha/RecaptchaCaptcha.d.ts +1 -1
  37. package/dist/react/captcha/TurnstileCaptcha.d.ts +1 -1
  38. package/dist/react/primitives/Checkbox.d.ts +1 -1
  39. package/dist/react/primitives/ChoiceGroup.d.ts +1 -1
  40. package/dist/react/primitives/FieldShell.d.ts +1 -1
  41. package/dist/react/primitives/Input.d.ts +1 -1
  42. package/dist/react/primitives/Select.d.ts +1 -1
  43. package/dist/react/primitives/Textarea.d.ts +1 -1
  44. package/dist/submissions/SubmissionAnswers.d.ts +1 -1
  45. package/package.json +14 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @10x-media/form-builder
2
2
 
3
+ ## 4.0.0-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - The admin builds on Payload `4.0.0-beta.10`: the condition, calculation, flow, field name and recipient pickers read the form through `getDataFromFormState`, which replaced `reduceFieldsToValues` in `payload/shared`.
8
+
9
+ - Requires Payload `4.0.0-beta.10`: the `payload` and `@payloadcms/*` peers are `^4.0.0-beta.10`, and the plugins are built and tested against it.
10
+
3
11
  ## 4.0.0-alpha.2
4
12
 
5
13
  ### Minor Changes
@@ -23,7 +23,7 @@ type ByteSizeFieldProps = {
23
23
  * number input that live-previews the value as a human-readable size ('= 2.5 MB') so authors are
24
24
  * not left decoding raw bytes. Stores the raw byte number unchanged.
25
25
  */
26
- declare const ByteSizeField: (props: ByteSizeFieldProps) => import("react/jsx-runtime").JSX.Element;
26
+ declare const ByteSizeField: (props: ByteSizeFieldProps) => import("react").JSX.Element;
27
27
  //#endregion
28
28
  export { ByteSizeField };
29
29
  //# sourceMappingURL=ByteSizeField.d.ts.map
@@ -14,7 +14,7 @@ type CalcExpressionBuilderProps = {
14
14
  * Storage shape is unchanged and `validateExpression` stays the server gate; the AST remains
15
15
  * authorable via the API.
16
16
  */
17
- declare const CalcExpressionBuilder: (props: CalcExpressionBuilderProps) => import("react/jsx-runtime").JSX.Element;
17
+ declare const CalcExpressionBuilder: (props: CalcExpressionBuilderProps) => import("react").JSX.Element;
18
18
  //#endregion
19
19
  export { CalcExpressionBuilder };
20
20
  //# sourceMappingURL=CalcExpressionBuilder.d.ts.map
@@ -5,7 +5,7 @@ import { normalizeCalc } from "../calc/normalizeCalc.js";
5
5
  import { formatCalc } from "../calc/formatCalc.js";
6
6
  import { useTranslation as useTranslation$1 } from "../translations/useTranslation.js";
7
7
  import { toStaticLabel } from "./toStaticLabel.js";
8
- import { reduceFieldsToValues } from "payload/shared";
8
+ import { getDataFromFormState } from "payload/shared";
9
9
  import { Button, CirclePlusIcon, FieldError, FieldLabel, LineIcon, ReactSelect, RenderCustomComponent, useField, useFormFields } from "@payloadcms/ui";
10
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
11
  import { useMemo, useState } from "react";
@@ -716,7 +716,7 @@ const CalcExpressionBuilder = (props) => {
716
716
  const match = /^fields\.(\d+)\./.exec(path);
717
717
  return match ? Number(match[1]) : Number.MAX_SAFE_INTEGER;
718
718
  }, [path]);
719
- const siblingsJson = useFormFields(([fields]) => JSON.stringify(siblingsFromData(reduceFieldsToValues(fields, true), selfIndex)));
719
+ const siblingsJson = useFormFields(([fields]) => JSON.stringify(siblingsFromData(getDataFromFormState(fields, true), selfIndex)));
720
720
  const siblings = useMemo(() => JSON.parse(siblingsJson), [siblingsJson]);
721
721
  const startOptions = [
722
722
  {
@@ -1 +1 @@
1
- {"version":3,"file":"CalcExpressionBuilder.js","names":["useTranslation"],"sources":["../../src/client/CalcExpressionBuilder.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tButton,\n\tCirclePlusIcon,\n\tFieldError,\n\tFieldLabel,\n\tLineIcon,\n\tReactSelect,\n\ttype ReactSelectOption,\n\tRenderCustomComponent,\n\tuseField,\n\tuseFormFields,\n} from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport { useMemo, useState } from 'react'\nimport { formatCalc } from '../calc/formatCalc'\nimport { normalizeCalc } from '../calc/normalizeCalc'\nimport {\n\tCALC_FNS,\n\tCALC_OPS,\n\ttype CalcExpression,\n\ttype CalcFn,\n\ttype CalcFnName,\n\ttype CalcOp,\n\tisCalcFn,\n} from '../calc/types'\nimport type { CalcSourceClientMeta } from '../fields/builtin/calculation'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport type { FieldRow } from './synthesizeClientField'\nimport { toStaticLabel } from './toStaticLabel'\nimport './admin.css'\n\nexport type CalcExpressionBuilderProps = {\n\tpath?: string\n\tfield?: { label?: unknown }\n\treadOnly?: boolean\n\t/** Registered calc-source metadata (key, label, modes), threaded as clientProps by `buildCalculationField`. */\n\tsources?: CalcSourceClientMeta[]\n\t/** Registered custom calc function names, so client-side normalization accepts what the server accepts. */\n\tfunctions?: string[]\n}\n\n/**\n * The editing view model: authors read and build expressions left-to-right, so the UI edits a\n * chain (first operand, then op+operand steps, then an optional wrapping unary function) and the\n * stored `CalcExpression` AST is derived by left-folding. The AST contract is untouched.\n */\nexport type CalcChain = { first: CalcOperand; steps: CalcChainStep[]; finish?: CalcFn }\nexport type CalcChainStep = { op: CalcOp; operand: CalcOperand }\nexport type CalcOperand =\n\t| { kind: 'ref'; field: string }\n\t| { kind: 'lit'; value: number }\n\t| { kind: 'weight'; field: string; weights?: Record<string, number>; source?: string }\n\t| { kind: 'source'; source: string }\n\t| { kind: 'group'; chain: CalcChain }\n\t| { kind: 'fn'; fn: CalcFnName; args: CalcChain[] }\n\t| { kind: 'neg'; operand: CalcOperand }\n\n/** Kinds a leaf operand card can switch between in place; containers come from Start with, loading, or JSON. */\ntype LeafKind = 'lit' | 'ref' | 'weight'\ntype StartKind = 'fn' | LeafKind\n\n/** The single-argument functions offered by the \"Then apply\" finisher; min/max are variadic and stay Function operands. */\nconst UNARY_FNS = CALC_FNS.filter((fn) => fn !== 'min' && fn !== 'max')\n\nconst seedOperand = (kind: LeafKind): CalcOperand => {\n\tswitch (kind) {\n\t\tcase 'ref':\n\t\t\treturn { kind: 'ref', field: '' }\n\t\tcase 'lit':\n\t\t\treturn { kind: 'lit', value: 0 }\n\t\tcase 'weight':\n\t\t\treturn { kind: 'weight', field: '', weights: {} }\n\t}\n}\n\nconst seedAst = (kind: StartKind): CalcExpression => {\n\tswitch (kind) {\n\t\tcase 'ref':\n\t\t\treturn { type: 'ref', field: '' }\n\t\tcase 'lit':\n\t\t\treturn { type: 'lit', value: 0 }\n\t\tcase 'weight':\n\t\t\treturn { type: 'weight', field: '', weights: {} }\n\t\tcase 'fn':\n\t\t\treturn { type: 'fn', fn: 'min', args: [{ type: 'lit', value: 0 }] }\n\t}\n}\n\nconst astToOperand = (node: CalcExpression): CalcOperand => {\n\tswitch (node.type) {\n\t\tcase 'ref':\n\t\t\treturn { kind: 'ref', field: node.field }\n\t\tcase 'lit':\n\t\t\treturn { kind: 'lit', value: node.value }\n\t\tcase 'source':\n\t\t\treturn { kind: 'source', source: node.source }\n\t\tcase 'weight':\n\t\t\treturn {\n\t\t\t\tkind: 'weight',\n\t\t\t\tfield: node.field,\n\t\t\t\t...(node.weights !== undefined ? { weights: node.weights } : {}),\n\t\t\t\t...(node.source !== undefined ? { source: node.source } : {}),\n\t\t\t}\n\t\tcase 'neg':\n\t\t\treturn { kind: 'neg', operand: astToOperand(node.operand) }\n\t\tcase 'fn':\n\t\t\treturn { kind: 'fn', fn: node.fn, args: node.args.map((arg) => toChain(arg, false)) }\n\t\tcase 'op':\n\t\t\treturn { kind: 'group', chain: toChain(node, false) }\n\t}\n}\n\nconst toChain = (expr: CalcExpression, allowFinish: boolean): CalcChain => {\n\tconst arg = expr.type === 'fn' ? expr.args[0] : undefined\n\tif (\n\t\tallowFinish &&\n\t\texpr.type === 'fn' &&\n\t\texpr.args.length === 1 &&\n\t\targ !== undefined &&\n\t\tisCalcFn(expr.fn) &&\n\t\t(UNARY_FNS as readonly CalcFn[]).includes(expr.fn)\n\t) {\n\t\treturn { ...toChain(arg, false), finish: expr.fn }\n\t}\n\tconst steps: CalcChainStep[] = []\n\tlet node = expr\n\twhile (node.type === 'op') {\n\t\tsteps.unshift({ op: node.op, operand: astToOperand(node.right) })\n\t\tnode = node.left\n\t}\n\treturn { first: astToOperand(node), steps }\n}\n\n/**\n * AST -> chain: the left spine of binary ops flattens into first + steps (a nested op on the right\n * becomes a `group`); a root unary fn wrapping the whole expression loads as `finish` (min/max stay\n * fn operands so the finisher select never holds a value it cannot offer). Total: every valid\n * `CalcExpression` loads without loss, and `chainToAst(astToChain(x))` is structurally `x`.\n */\nexport const astToChain = (expr: CalcExpression): CalcChain => toChain(expr, true)\n\nconst operandToAst = (operand: CalcOperand): CalcExpression => {\n\tswitch (operand.kind) {\n\t\tcase 'ref':\n\t\t\treturn { type: 'ref', field: operand.field }\n\t\tcase 'lit':\n\t\t\treturn { type: 'lit', value: operand.value }\n\t\tcase 'weight':\n\t\t\treturn {\n\t\t\t\ttype: 'weight',\n\t\t\t\tfield: operand.field,\n\t\t\t\t...(operand.weights !== undefined ? { weights: operand.weights } : {}),\n\t\t\t\t...(operand.source !== undefined ? { source: operand.source } : {}),\n\t\t\t}\n\t\tcase 'source':\n\t\t\treturn { type: 'source', source: operand.source }\n\t\tcase 'neg':\n\t\t\treturn { type: 'neg', operand: operandToAst(operand.operand) }\n\t\tcase 'fn':\n\t\t\treturn { type: 'fn', fn: operand.fn, args: operand.args.map(chainBodyToAst) }\n\t\tcase 'group':\n\t\t\treturn chainBodyToAst(operand.chain)\n\t}\n}\n\n/** Folds first + steps only. `finish` is root-only by design: nested chains (groups, fn args) never carry one, so it is deliberately ignored here. */\nconst chainBodyToAst = (chain: CalcChain): CalcExpression =>\n\tchain.steps.reduce<CalcExpression>(\n\t\t(left, step) => ({ type: 'op', op: step.op, left, right: operandToAst(step.operand) }),\n\t\toperandToAst(chain.first)\n\t)\n\n/** Chain -> AST: left-fold first + steps into the binary tree (left-assoc matches `-`/`/`/`%`), then wrap in `finish` when set. */\nexport const chainToAst = (chain: CalcChain): CalcExpression => {\n\tconst body = chainBodyToAst(chain)\n\treturn chain.finish ? { type: 'fn', fn: chain.finish, args: [body] } : body\n}\n\ntype ChoiceOption = { label: string; value: string }\ntype ChoiceSibling = { name: string; label: string; options: ChoiceOption[] }\ntype Siblings = {\n\tnumeric: ChoiceOption[]\n\tchoices: ChoiceSibling[]\n\tlabels: Record<string, string>\n}\n\nconst optionRows = (options: unknown): ChoiceOption[] => {\n\tif (!Array.isArray(options)) {\n\t\treturn []\n\t}\n\treturn options.flatMap((option) => {\n\t\tif (typeof option === 'string') {\n\t\t\treturn option.length > 0 ? [{ label: option, value: option }] : []\n\t\t}\n\t\tif (!option || typeof option !== 'object') {\n\t\t\treturn []\n\t\t}\n\t\tconst { label, value } = option as { label?: unknown; value?: unknown }\n\t\tif (typeof value !== 'string' || value.length === 0) {\n\t\t\treturn []\n\t\t}\n\t\treturn [{ label: typeof label === 'string' && label.length > 0 ? label : value, value }]\n\t})\n}\n\nconst siblingsFromData = (data: Record<string, unknown>, selfIndex: number): Siblings => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as unknown[]) : []\n\tconst siblings: Siblings = { numeric: [], choices: [], labels: {} }\n\trows.forEach((row, index) => {\n\t\tif (!row || typeof row !== 'object') {\n\t\t\treturn\n\t\t}\n\t\tconst { blockType, name, label, options } = row as FieldRow\n\t\tconst trimmed = typeof name === 'string' ? name.trim() : ''\n\t\tif (trimmed.length === 0) {\n\t\t\treturn\n\t\t}\n\t\tconst display = typeof label === 'string' && label.length > 0 ? label : trimmed\n\t\tsiblings.labels[trimmed] = display\n\t\t// Calculations fold in declaration order, so a calculation is only referenceable when it is\n\t\t// declared before this one; a forward (or self) reference would always evaluate to 0.\n\t\tconst referenceable =\n\t\t\tblockType === 'number' || (blockType === 'calculation' && index < selfIndex)\n\t\tif (referenceable) {\n\t\t\tsiblings.numeric.push({ label: display, value: trimmed })\n\t\t}\n\t\tif (blockType === 'select') {\n\t\t\tsiblings.choices.push({ name: trimmed, label: display, options: optionRows(options) })\n\t\t}\n\t})\n\treturn siblings\n}\n\nconst singleOption = (\n\tselected: ReactSelectOption | ReactSelectOption[] | null\n): ReactSelectOption | undefined => {\n\tconst chosen = Array.isArray(selected) ? selected[0] : selected\n\treturn chosen ?? undefined\n}\n\n/** Keeps a stored reference selectable even when it no longer matches any option, like FieldNameSelect. */\nconst withStored = (options: ChoiceOption[], stored: string): ChoiceOption[] =>\n\tstored.length > 0 && !options.some((option) => option.value === stored)\n\t\t? [...options, { label: stored, value: stored }]\n\t\t: options\n\ntype NumberInputProps = {\n\tvalue: number | undefined\n\tonCommit: (value: number) => void\n\tclassName: string\n\tid?: string\n\tdisabled?: boolean\n\t'aria-label'?: string\n}\n\n/**\n * Number input with a local draft: keystrokes commit only when the text parses to a finite number,\n * an invalid draft reverts to the committed value on blur, and an external value change resyncs\n * the draft.\n */\nconst NumberInput = ({\n\tvalue,\n\tonCommit,\n\tclassName,\n\tid,\n\tdisabled,\n\t'aria-label': ariaLabel,\n}: NumberInputProps) => {\n\tconst [draft, setDraft] = useState(value === undefined ? '' : String(value))\n\tconst [lastValue, setLastValue] = useState(value)\n\tif (value !== lastValue) {\n\t\tsetLastValue(value)\n\t\tif (draft.trim() === '' || Number(draft) !== value) {\n\t\t\tsetDraft(value === undefined ? '' : String(value))\n\t\t}\n\t}\n\treturn (\n\t\t<input\n\t\t\ttype=\"number\"\n\t\t\tclassName={className}\n\t\t\tid={id}\n\t\t\tdisabled={disabled}\n\t\t\taria-label={ariaLabel}\n\t\t\tvalue={draft}\n\t\t\tonChange={(event) => {\n\t\t\t\tconst text = event.target.value\n\t\t\t\tsetDraft(text)\n\t\t\t\tconst parsed = Number(text)\n\t\t\t\tif (text.trim() !== '' && Number.isFinite(parsed)) {\n\t\t\t\t\tonCommit(parsed)\n\t\t\t\t}\n\t\t\t}}\n\t\t\tonBlur={() => {\n\t\t\t\tconst parsed = Number(draft)\n\t\t\t\tif (draft.trim() === '' || !Number.isFinite(parsed)) {\n\t\t\t\t\tsetDraft(value === undefined ? '' : String(value))\n\t\t\t\t}\n\t\t\t}}\n\t\t/>\n\t)\n}\n\ntype BuilderCtx = {\n\tt: (key: TranslationKey) => string\n\tsiblings: Siblings\n\treadOnly: boolean\n\t/** Resolves a calc source key to its admin-locale display label (raw key when unregistered). */\n\tsourceLabelOf: (key: string) => string\n\t/** Scalar-capable sources as select options (`source:`-prefixed values). */\n\tscalarSourceOptions: ChoiceOption[]\n\t/** Weights-capable sources as select options (`source:`-prefixed values). */\n\tweightSourceOptions: ChoiceOption[]\n\t/** Registered custom calc function names, offered by the fn select after the built-ins. */\n\tcustomFnOptions: ChoiceOption[]\n}\n\nconst OP_OPTIONS: ChoiceOption[] = CALC_OPS.map((op) => ({ label: op, value: op }))\nconst FN_OPTIONS: ChoiceOption[] = CALC_FNS.map((fn) => ({ label: fn, value: fn }))\nconst UNARY_OPTIONS: ChoiceOption[] = UNARY_FNS.map((fn) => ({ label: fn, value: fn }))\n\n/** Source entries share kind/start selects with the fixed kinds, namespaced to avoid key collisions. */\nconst SOURCE_PREFIX = 'source:'\nconst sourceOptionValue = (key: string): string => `${SOURCE_PREFIX}${key}`\nconst sourceKeyOf = (value: string): string | undefined =>\n\tvalue.startsWith(SOURCE_PREFIX) ? value.slice(SOURCE_PREFIX.length) : undefined\n\n/** A source label is a plain string or a per-locale record; resolve it for the admin UI language. */\nconst resolveSourceLabel = (label: string | Record<string, string>, language: string): string =>\n\ttypeof label === 'string' ? label : (label[language] ?? label.en ?? Object.values(label)[0] ?? '')\n\ntype SelectOptionOrGroup = ChoiceOption | { label: string; options: ChoiceOption[] }\n\n/** Fixed kinds stay flat; sources join as a labeled group when any exist (react-select mixes both). */\nconst withSourceGroup = (\n\tbase: ChoiceOption[],\n\tsourceOptions: ChoiceOption[],\n\tgroupLabel: string\n): SelectOptionOrGroup[] =>\n\tsourceOptions.length > 0 ? [...base, { label: groupLabel, options: sourceOptions }] : base\n\ntype OperandCardProps = {\n\toperand: CalcOperand\n\tonChange: (next: CalcOperand) => void\n\tctx: BuilderCtx\n\tidPrefix: string\n}\n\nconst OperandCard = ({ operand, onChange, ctx, idPrefix }: OperandCardProps) => {\n\tconst { t, siblings, readOnly } = ctx\n\n\tif (operand.kind === 'group') {\n\t\treturn (\n\t\t\t<div className=\"fb-calc-operand fb-calc-operand--group\">\n\t\t\t\t<div className=\"fb-calc-operand__title\">{t(keys.calcBuilderGroup)}</div>\n\t\t\t\t<ChainEditor\n\t\t\t\t\tchain={operand.chain}\n\t\t\t\t\tonChange={(chain) => onChange({ ...operand, chain })}\n\t\t\t\t\tctx={ctx}\n\t\t\t\t\tidPrefix={`${idPrefix}-g`}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tif (operand.kind === 'fn') {\n\t\tconst fnOptions = withStored([...FN_OPTIONS, ...ctx.customFnOptions], operand.fn)\n\t\treturn (\n\t\t\t<div className=\"fb-calc-operand fb-calc-operand--fn\">\n\t\t\t\t<div className=\"fb-calc-operand__header\">\n\t\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idPrefix}-fn`}>\n\t\t\t\t\t\t{t(keys.calcBuilderFunction)}\n\t\t\t\t\t</label>\n\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\tclassName=\"fb-calc-operand__fn\"\n\t\t\t\t\t\tinputId={`${idPrefix}-fn`}\n\t\t\t\t\t\toptions={fnOptions}\n\t\t\t\t\t\tvalue={fnOptions.find((option) => option.value === operand.fn)}\n\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\tif (chosen) {\n\t\t\t\t\t\t\t\tonChange({ ...operand, fn: String(chosen.value) })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"fb-calc-fn__args\">\n\t\t\t\t\t{operand.args.map((arg, index) => (\n\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: args are positional and never reordered\n\t\t\t\t\t\t<div key={index} className=\"fb-calc-fn__arg\">\n\t\t\t\t\t\t\t<div className=\"fb-calc-fn__arg-chain\">\n\t\t\t\t\t\t\t\t<ChainEditor\n\t\t\t\t\t\t\t\t\tchain={arg}\n\t\t\t\t\t\t\t\t\tonChange={(next) =>\n\t\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\t\t...operand,\n\t\t\t\t\t\t\t\t\t\t\targs: operand.args.map((a, i) => (i === index ? next : a)),\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tctx={ctx}\n\t\t\t\t\t\t\t\t\tidPrefix={`${idPrefix}-a${index}`}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{operand.args.length > 1 ? (\n\t\t\t\t\t\t\t\t<div className=\"fb-calc-fn__arg-remove\">\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\t\t\t\t\ticon={<LineIcon size={24} />}\n\t\t\t\t\t\t\t\t\t\taria-label={t(keys.calcBuilderRemove)}\n\t\t\t\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\t\t\t...operand,\n\t\t\t\t\t\t\t\t\t\t\t\targs: operand.args.filter((_, i) => i !== index),\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t))}\n\t\t\t\t\t<div className=\"fb-calc-fn__add\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t...operand,\n\t\t\t\t\t\t\t\t\targs: [...operand.args, { first: { kind: 'lit', value: 0 }, steps: [] }],\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{t(keys.calcBuilderAddArgument)}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tif (operand.kind === 'neg') {\n\t\treturn (\n\t\t\t<div className=\"fb-calc-operand fb-calc-operand--neg\">\n\t\t\t\t<div className=\"fb-calc-operand__title\">{t(keys.calcBuilderNegate)}</div>\n\t\t\t\t<OperandCard\n\t\t\t\t\toperand={operand.operand}\n\t\t\t\t\tonChange={(next) => onChange({ kind: 'neg', operand: next })}\n\t\t\t\t\tctx={ctx}\n\t\t\t\t\tidPrefix={`${idPrefix}-n`}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tconst leafKindOptions: ChoiceOption[] = [\n\t\t{ label: t(keys.calcBuilderAnswer), value: 'ref' },\n\t\t{ label: t(keys.calcBuilderNumber), value: 'lit' },\n\t\t{ label: t(keys.calcBuilderWeights), value: 'weight' },\n\t]\n\tconst kindValue = operand.kind === 'source' ? sourceOptionValue(operand.source) : operand.kind\n\tconst kindSourceOptions =\n\t\toperand.kind === 'source' &&\n\t\t!ctx.scalarSourceOptions.some((option) => option.value === sourceOptionValue(operand.source))\n\t\t\t? [...ctx.scalarSourceOptions, { label: operand.source, value: kindValue }]\n\t\t\t: ctx.scalarSourceOptions\n\tconst kindFlat = [...leafKindOptions, ...kindSourceOptions]\n\tconst refOptions = operand.kind === 'ref' ? withStored(siblings.numeric, operand.field) : []\n\tconst choiceOptions =\n\t\toperand.kind === 'weight'\n\t\t\t? withStored(\n\t\t\t\t\tsiblings.choices.map((c) => ({ label: c.label, value: c.name })),\n\t\t\t\t\toperand.field\n\t\t\t\t)\n\t\t\t: []\n\tconst choice =\n\t\toperand.kind === 'weight' ? siblings.choices.find((c) => c.name === operand.field) : undefined\n\tconst weightSource = operand.kind === 'weight' ? operand.source : undefined\n\tconst weightValuesOptions: ChoiceOption[] = [\n\t\t{ label: t(keys.calcBuilderWeightManual), value: 'manual' },\n\t\t...(weightSource !== undefined &&\n\t\t!ctx.weightSourceOptions.some((option) => option.value === sourceOptionValue(weightSource))\n\t\t\t? [\n\t\t\t\t\t...ctx.weightSourceOptions,\n\t\t\t\t\t{ label: weightSource, value: sourceOptionValue(weightSource) },\n\t\t\t\t]\n\t\t\t: ctx.weightSourceOptions),\n\t]\n\n\treturn (\n\t\t<div className=\"fb-calc-operand\">\n\t\t\t<div className=\"fb-calc-operand__header\">\n\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idPrefix}-kind`}>\n\t\t\t\t\t{t(keys.calcBuilderKind)}\n\t\t\t\t</label>\n\t\t\t\t<ReactSelect\n\t\t\t\t\tclassName=\"fb-calc-operand__kind\"\n\t\t\t\t\tinputId={`${idPrefix}-kind`}\n\t\t\t\t\toptions={\n\t\t\t\t\t\twithSourceGroup(\n\t\t\t\t\t\t\tleafKindOptions,\n\t\t\t\t\t\t\tkindSourceOptions,\n\t\t\t\t\t\t\tt(keys.calcBuilderSourcesGroup)\n\t\t\t\t\t\t) as ReactSelectOption[]\n\t\t\t\t\t}\n\t\t\t\t\tvalue={kindFlat.find((option) => option.value === kindValue)}\n\t\t\t\t\tisClearable={false}\n\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\tif (!chosen || chosen.value === kindValue) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst sourceKey = sourceKeyOf(String(chosen.value))\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tsourceKey !== undefined\n\t\t\t\t\t\t\t\t? { kind: 'source', source: sourceKey }\n\t\t\t\t\t\t\t\t: seedOperand(chosen.value as LeafKind)\n\t\t\t\t\t\t)\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t{operand.kind === 'source' ? (\n\t\t\t\t\t<span className=\"fb-calc-operand__source\">{ctx.sourceLabelOf(operand.source)}</span>\n\t\t\t\t) : null}\n\t\t\t\t{operand.kind === 'ref' ? (\n\t\t\t\t\trefOptions.length === 0 ? (\n\t\t\t\t\t\t<p className=\"fb-calc-hint\">{t(keys.calcBuilderNoNumericFields)}</p>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idPrefix}-ref`}>\n\t\t\t\t\t\t\t\t{t(keys.calcBuilderPickField)}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-operand__ref\"\n\t\t\t\t\t\t\t\tinputId={`${idPrefix}-ref`}\n\t\t\t\t\t\t\t\toptions={refOptions}\n\t\t\t\t\t\t\t\tvalue={refOptions.find((option) => option.value === operand.field)}\n\t\t\t\t\t\t\t\tisClearable={!readOnly}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tplaceholder={t(keys.calcBuilderPickField)}\n\t\t\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\t\t\tonChange({ kind: 'ref', field: chosen ? String(chosen.value) : '' })\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)\n\t\t\t\t) : null}\n\t\t\t\t{operand.kind === 'lit' ? (\n\t\t\t\t\t<NumberInput\n\t\t\t\t\t\tclassName=\"form-input fb-calc-operand__number\"\n\t\t\t\t\t\tid={`${idPrefix}-number`}\n\t\t\t\t\t\taria-label={t(keys.calcBuilderNumber)}\n\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\tvalue={operand.value}\n\t\t\t\t\t\tonCommit={(value) => onChange({ kind: 'lit', value })}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t\t{operand.kind === 'weight' ? (\n\t\t\t\t\tchoiceOptions.length === 0 ? (\n\t\t\t\t\t\t<p className=\"fb-calc-hint\">{t(keys.calcBuilderNoChoiceFields)}</p>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idPrefix}-weight-field`}>\n\t\t\t\t\t\t\t\t{t(keys.calcBuilderPickField)}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-operand__weight-field\"\n\t\t\t\t\t\t\t\tinputId={`${idPrefix}-weight-field`}\n\t\t\t\t\t\t\t\toptions={choiceOptions}\n\t\t\t\t\t\t\t\tvalue={choiceOptions.find((option) => option.value === operand.field)}\n\t\t\t\t\t\t\t\tisClearable={!readOnly}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tplaceholder={t(keys.calcBuilderPickField)}\n\t\t\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\t\t\tconst field = chosen ? String(chosen.value) : ''\n\t\t\t\t\t\t\t\t\tif (field !== operand.field) {\n\t\t\t\t\t\t\t\t\t\t// Inline weights are per-option and reset with the field; a source keeps\n\t\t\t\t\t\t\t\t\t\t// resolving (its resolver receives the newly chosen field).\n\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\toperand.source !== undefined\n\t\t\t\t\t\t\t\t\t\t\t\t? { kind: 'weight', field, source: operand.source }\n\t\t\t\t\t\t\t\t\t\t\t\t: { kind: 'weight', field, weights: {} }\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t\t{operand.kind === 'weight' && ctx.weightSourceOptions.length > 0 ? (\n\t\t\t\t<div className=\"fb-calc-operand__weight-values-row\">\n\t\t\t\t\t<label className=\"fb-calc-operand__weight-values-label\" htmlFor={`${idPrefix}-wv`}>\n\t\t\t\t\t\t{t(keys.calcBuilderWeightValues)}\n\t\t\t\t\t</label>\n\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\tclassName=\"fb-calc-operand__weight-values\"\n\t\t\t\t\t\tinputId={`${idPrefix}-wv`}\n\t\t\t\t\t\toptions={weightValuesOptions}\n\t\t\t\t\t\tvalue={weightValuesOptions.find(\n\t\t\t\t\t\t\t(option) =>\n\t\t\t\t\t\t\t\toption.value ===\n\t\t\t\t\t\t\t\t(operand.source !== undefined ? sourceOptionValue(operand.source) : 'manual')\n\t\t\t\t\t\t)}\n\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\tif (!chosen) {\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst sourceKey = sourceKeyOf(String(chosen.value))\n\t\t\t\t\t\t\tif (sourceKey === undefined) {\n\t\t\t\t\t\t\t\tif (operand.source !== undefined) {\n\t\t\t\t\t\t\t\t\t// Back to Manual: drop the source, keep any inline weights (they were\n\t\t\t\t\t\t\t\t\t// preserved untouched while sourced) so the author's numbers return.\n\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\tkind: 'weight',\n\t\t\t\t\t\t\t\t\t\tfield: operand.field,\n\t\t\t\t\t\t\t\t\t\tweights: operand.weights ?? {},\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (sourceKey !== operand.source) {\n\t\t\t\t\t\t\t\tonChange({ ...operand, source: sourceKey })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t\t{operand.kind === 'weight' && operand.source !== undefined ? (\n\t\t\t\t<p className=\"fb-calc-hint\">{t(keys.calcBuilderWeightsFromSource)}</p>\n\t\t\t) : null}\n\t\t\t{operand.kind === 'weight' && operand.source === undefined && choice ? (\n\t\t\t\t<div className=\"fb-calc-operand__weights\">\n\t\t\t\t\t{choice.options.map((option) => (\n\t\t\t\t\t\t<div key={option.value} className=\"fb-calc-operand__weight-row\">\n\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-operand__weight-label\"\n\t\t\t\t\t\t\t\thtmlFor={`${idPrefix}-weight-${option.value}`}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{option.label}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<NumberInput\n\t\t\t\t\t\t\t\tclassName=\"form-input fb-calc-operand__weight\"\n\t\t\t\t\t\t\t\tid={`${idPrefix}-weight-${option.value}`}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tvalue={operand.weights?.[option.value]}\n\t\t\t\t\t\t\t\tonCommit={(value) =>\n\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\t...operand,\n\t\t\t\t\t\t\t\t\t\tweights: { ...(operand.weights ?? {}), [option.value]: value },\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t))}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t)\n}\n\ntype ChainEditorProps = {\n\tchain: CalcChain\n\tonChange: (next: CalcChain) => void\n\t/** Root only: called when the only row is removed, clearing the expression back to Start with. */\n\tonEmptied?: () => void\n\t/**\n\t * Honest-affordance rule: an X must actually remove. The root's only-row X clears the whole\n\t * expression, so it stays; a nested chain's only row (fn arg, group) would merely reseed, so\n\t * its X is not rendered at all.\n\t */\n\tisRoot?: boolean\n\tctx: BuilderCtx\n\tidPrefix: string\n}\n\nconst ChainEditor = ({ chain, onChange, onEmptied, isRoot, ctx, idPrefix }: ChainEditorProps) => {\n\tconst { t, readOnly } = ctx\n\n\tconst removeRow = (row: number) => {\n\t\tif (row === 0) {\n\t\t\tconst [promoted, ...rest] = chain.steps\n\t\t\tif (!promoted) {\n\t\t\t\tonEmptied?.()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tonChange({ ...chain, first: promoted.operand, steps: rest })\n\t\t\treturn\n\t\t}\n\t\tonChange({ ...chain, steps: chain.steps.filter((_, i) => i !== row - 1) })\n\t}\n\n\tconst rows: { op?: CalcOp; operand: CalcOperand }[] = [\n\t\t{ operand: chain.first },\n\t\t...chain.steps.map((step) => ({ op: step.op, operand: step.operand })),\n\t]\n\n\treturn (\n\t\t<div className=\"fb-calc-chain\">\n\t\t\t{rows.map((row, index) => (\n\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: rows are positional and never reordered\n\t\t\t\t<div key={index} className={index > 0 ? 'fb-calc-row fb-calc-row--divided' : 'fb-calc-row'}>\n\t\t\t\t\t{index === 0 ? <div className=\"fb-calc-row__op-spacer\" aria-hidden=\"true\" /> : null}\n\t\t\t\t\t{index > 0 ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idPrefix}-r${index}-op`}>\n\t\t\t\t\t\t\t\t{t(keys.calcBuilderMath)}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-row__op\"\n\t\t\t\t\t\t\t\tinputId={`${idPrefix}-r${index}-op`}\n\t\t\t\t\t\t\t\toptions={OP_OPTIONS}\n\t\t\t\t\t\t\t\tvalue={OP_OPTIONS.find((option) => option.value === row.op)}\n\t\t\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\t\t\tif (chosen) {\n\t\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\t\t...chain,\n\t\t\t\t\t\t\t\t\t\t\tsteps: chain.steps.map((step, i) =>\n\t\t\t\t\t\t\t\t\t\t\t\ti === index - 1 ? { ...step, op: chosen.value as CalcOp } : step\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : null}\n\t\t\t\t\t<div className=\"fb-calc-row__operand\">\n\t\t\t\t\t\t<OperandCard\n\t\t\t\t\t\t\toperand={row.operand}\n\t\t\t\t\t\t\tonChange={(operand) =>\n\t\t\t\t\t\t\t\tindex === 0\n\t\t\t\t\t\t\t\t\t? onChange({ ...chain, first: operand })\n\t\t\t\t\t\t\t\t\t: onChange({\n\t\t\t\t\t\t\t\t\t\t\t...chain,\n\t\t\t\t\t\t\t\t\t\t\tsteps: chain.steps.map((step, i) =>\n\t\t\t\t\t\t\t\t\t\t\t\ti === index - 1 ? { ...step, operand } : step\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tctx={ctx}\n\t\t\t\t\t\t\tidPrefix={`${idPrefix}-r${index}`}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{rows.length > 1 || isRoot ? (\n\t\t\t\t\t\t<div className=\"fb-calc-row__remove\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\t\t\ticon={<LineIcon size={24} />}\n\t\t\t\t\t\t\t\taria-label={t(keys.calcBuilderRemove)}\n\t\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tonClick={() => removeRow(index)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t))}\n\t\t\t<div className=\"fb-calc-chain__add\">\n\t\t\t\t<Button\n\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\tmargin={false}\n\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t...chain,\n\t\t\t\t\t\t\tsteps: [...chain.steps, { op: '*', operand: seedOperand('ref') }],\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{t(keys.calcBuilderAddStep)}\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\n/**\n * Visual editor for the calculation field's `expression` AST, presented as a left-to-right chain.\n * Storage shape is unchanged and `validateExpression` stays the server gate; the AST remains\n * authorable via the API.\n */\nexport const CalcExpressionBuilder = (props: CalcExpressionBuilderProps) => {\n\tconst {\n\t\tcustomComponents: { Error: ErrorComponent, Label } = {},\n\t\tdisabled,\n\t\tpath,\n\t\tsetValue,\n\t\tshowError,\n\t\tvalue,\n\t} = useField<unknown>({ path: props.path })\n\tconst { t, i18n } = useTranslation()\n\tconst label = toStaticLabel(props.field?.label)\n\tconst readOnly = props.readOnly === true || disabled === true\n\n\tconst sources = useMemo(() => props.sources ?? [], [props.sources])\n\t// Mirrors the server-side allowed sets, so the builder accepts exactly the expressions\n\t// `buildValidateExpression` accepts (a sourced expression must not read as \"stored invalid\").\n\tconst allowed = useMemo(\n\t\t() => ({\n\t\t\tsources: new Set(sources.map((source) => source.key)),\n\t\t\tfunctions: new Set(props.functions ?? []),\n\t\t}),\n\t\t[sources, props.functions]\n\t)\n\tconst sourceLabelOf = (key: string): string => {\n\t\tconst meta = sources.find((source) => source.key === key)\n\t\treturn meta ? resolveSourceLabel(meta.label, i18n.language) : key\n\t}\n\tconst scalarSourceOptions: ChoiceOption[] = sources\n\t\t.filter((source) => source.scalar)\n\t\t.map((source) => ({ label: sourceLabelOf(source.key), value: sourceOptionValue(source.key) }))\n\tconst weightSourceOptions: ChoiceOption[] = sources\n\t\t.filter((source) => source.weights)\n\t\t.map((source) => ({ label: sourceLabelOf(source.key), value: sourceOptionValue(source.key) }))\n\tconst customFnOptions: ChoiceOption[] = (props.functions ?? []).map((fn) => ({\n\t\tlabel: fn,\n\t\tvalue: fn,\n\t}))\n\n\tconst expression = useMemo(() => normalizeCalc(value, allowed), [value, allowed])\n\tconst chain = useMemo(() => (expression ? astToChain(expression) : undefined), [expression])\n\tconst storedInvalid = expression === undefined && value != null && value !== ''\n\n\t// The expression path is `fields.<row>.expression`; that row is the calculation block being\n\t// edited, so it bounds which calculation siblings are referenceable (see siblingsFromData).\n\t// An unparseable path (never expected) offers every calculation rather than none.\n\tconst selfIndex = useMemo(() => {\n\t\tconst match = /^fields\\.(\\d+)\\./.exec(path)\n\t\treturn match ? Number(match[1]) : Number.MAX_SAFE_INTEGER\n\t}, [path])\n\n\tconst siblingsJson = useFormFields(([fields]) =>\n\t\tJSON.stringify(siblingsFromData(reduceFieldsToValues(fields, true), selfIndex))\n\t)\n\tconst siblings = useMemo(() => JSON.parse(siblingsJson) as Siblings, [siblingsJson])\n\n\tconst startOptions: ChoiceOption[] = [\n\t\t{ label: t(keys.calcBuilderAnswer), value: 'ref' },\n\t\t{ label: t(keys.calcBuilderNumber), value: 'lit' },\n\t\t{ label: t(keys.calcBuilderWeights), value: 'weight' },\n\t\t{ label: t(keys.calcBuilderFunction), value: 'fn' },\n\t]\n\tconst startDescriptions: { key: string; label: string; description: string }[] = [\n\t\t{\n\t\t\tkey: 'ref',\n\t\t\tlabel: t(keys.calcBuilderAnswer),\n\t\t\tdescription: t(keys.calcBuilderFieldDescription),\n\t\t},\n\t\t{\n\t\t\tkey: 'lit',\n\t\t\tlabel: t(keys.calcBuilderNumber),\n\t\t\tdescription: t(keys.calcBuilderNumberDescription),\n\t\t},\n\t\t{\n\t\t\tkey: 'weight',\n\t\t\tlabel: t(keys.calcBuilderWeights),\n\t\t\tdescription: t(keys.calcBuilderWeightsDescription),\n\t\t},\n\t\t{\n\t\t\tkey: 'fn',\n\t\t\tlabel: t(keys.calcBuilderFunction),\n\t\t\tdescription: t(keys.calcBuilderFunctionDescription),\n\t\t},\n\t]\n\n\tconst commitChain = (next: CalcChain) => {\n\t\tif (!readOnly) {\n\t\t\tsetValue(chainToAst(next))\n\t\t}\n\t}\n\n\tconst clear = () => {\n\t\tif (!readOnly) {\n\t\t\tsetValue(null)\n\t\t}\n\t}\n\n\t// An unfilled slot (blank ref) previews as \"?\" so a partial chain reads \"Price × ?\" instead of\n\t// trailing off; formatCalc itself stays pure.\n\tconst labelOf = (field: string) => (field.trim() === '' ? '?' : (siblings.labels[field] ?? field))\n\n\tconst idBase = `calc-${path.replace(/\\./g, '__')}`\n\tconst ctx: BuilderCtx = {\n\t\tt,\n\t\tsiblings,\n\t\treadOnly,\n\t\tsourceLabelOf,\n\t\tscalarSourceOptions,\n\t\tweightSourceOptions,\n\t\tcustomFnOptions,\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName={['field-type', 'fb-calc-builder', showError && 'error', readOnly && 'read-only']\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ')}\n\t\t\tid={path ? `field-${path.replace(/\\./g, '__')}` : undefined}\n\t\t>\n\t\t\t<RenderCustomComponent\n\t\t\t\tCustomComponent={Label}\n\t\t\t\tFallback={<FieldLabel label={label} path={path} />}\n\t\t\t/>\n\t\t\t<div className=\"field-type__wrap\">\n\t\t\t\t<RenderCustomComponent\n\t\t\t\t\tCustomComponent={ErrorComponent}\n\t\t\t\t\tFallback={<FieldError path={path} showError={showError} />}\n\t\t\t\t/>\n\t\t\t\t{chain ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ChainEditor\n\t\t\t\t\t\t\tchain={chain}\n\t\t\t\t\t\t\tonChange={commitChain}\n\t\t\t\t\t\t\tonEmptied={clear}\n\t\t\t\t\t\t\tisRoot\n\t\t\t\t\t\t\tctx={ctx}\n\t\t\t\t\t\t\tidPrefix={idBase}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div className=\"fb-calc-finish\">\n\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-finish__label\"\n\t\t\t\t\t\t\t\thtmlFor={`${idBase}-finish`}\n\t\t\t\t\t\t\t\ttitle={t(keys.calcBuilderThenApply)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{t(keys.calcBuilderThenApply)}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-finish__select\"\n\t\t\t\t\t\t\t\tinputId={`${idBase}-finish`}\n\t\t\t\t\t\t\t\toptions={UNARY_OPTIONS}\n\t\t\t\t\t\t\t\tvalue={UNARY_OPTIONS.find((option) => option.value === chain.finish)}\n\t\t\t\t\t\t\t\tisClearable={!readOnly}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\t\t\tcommitChain({\n\t\t\t\t\t\t\t\t\t\t...chain,\n\t\t\t\t\t\t\t\t\t\tfinish: chosen ? (chosen.value as CalcFn) : undefined,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<div className=\"fb-calc-builder__empty\">\n\t\t\t\t\t\t{storedInvalid ? (\n\t\t\t\t\t\t\t<p className=\"fb-calc-builder__warning\">{t(keys.calcBuilderStoredInvalid)}</p>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t<p className=\"fb-calc-builder__hint\">{t(keys.calcBuilderAddExpression)}</p>\n\t\t\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idBase}-seed`}>\n\t\t\t\t\t\t\t{t(keys.calcBuilderStartWith)}\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\tclassName=\"fb-calc-builder__seed\"\n\t\t\t\t\t\t\tinputId={`${idBase}-seed`}\n\t\t\t\t\t\t\toptions={\n\t\t\t\t\t\t\t\twithSourceGroup(\n\t\t\t\t\t\t\t\t\tstartOptions,\n\t\t\t\t\t\t\t\t\tscalarSourceOptions,\n\t\t\t\t\t\t\t\t\tt(keys.calcBuilderSourcesGroup)\n\t\t\t\t\t\t\t\t) as ReactSelectOption[]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\tplaceholder={t(keys.calcBuilderStartWith)}\n\t\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\t\tif (!chosen || readOnly) {\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst sourceKey = sourceKeyOf(String(chosen.value))\n\t\t\t\t\t\t\t\tsetValue(\n\t\t\t\t\t\t\t\t\tsourceKey !== undefined\n\t\t\t\t\t\t\t\t\t\t? { type: 'source', source: sourceKey }\n\t\t\t\t\t\t\t\t\t\t: seedAst(chosen.value as StartKind)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ul className=\"fb-calc-builder__kinds\">\n\t\t\t\t\t\t\t{startDescriptions.map((entry) => (\n\t\t\t\t\t\t\t\t<li key={entry.key}>\n\t\t\t\t\t\t\t\t\t<span className=\"fb-calc-builder__kind-label\">{entry.label}</span>{' '}\n\t\t\t\t\t\t\t\t\t{entry.description}\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<p className=\"fb-calc-builder__preview\" aria-live=\"polite\">\n\t\t\t\t\t{expression ? formatCalc(expression, labelOf, sourceLabelOf) : ''}\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;AAiEA,MAAM,YAAY,SAAS,QAAQ,OAAO,OAAO,SAAS,OAAO,KAAK;AAEtE,MAAM,eAAe,SAAgC;CACpD,QAAQ,MAAR;EACC,KAAK,OACJ,OAAO;GAAE,MAAM;GAAO,OAAO;EAAG;EACjC,KAAK,OACJ,OAAO;GAAE,MAAM;GAAO,OAAO;EAAE;EAChC,KAAK,UACJ,OAAO;GAAE,MAAM;GAAU,OAAO;GAAI,SAAS,CAAC;EAAE;CAClD;AACD;AAEA,MAAM,WAAW,SAAoC;CACpD,QAAQ,MAAR;EACC,KAAK,OACJ,OAAO;GAAE,MAAM;GAAO,OAAO;EAAG;EACjC,KAAK,OACJ,OAAO;GAA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KAAK,uBAAuB,CAC/B;OAED,UAAU;OACV,aAAa,EAAE,KAAK,oBAAoB;OACxC,WAAW,aAAa;QACvB,MAAM,SAAS,aAAa,QAAQ;QACpC,IAAI,CAAC,UAAU,UACd;QAED,MAAM,YAAY,YAAY,OAAO,OAAO,KAAK,CAAC;QAClD,SACC,cAAc,KAAA,IACX;SAAE,MAAM;SAAU,QAAQ;QAAU,IACpC,QAAQ,OAAO,KAAkB,CACrC;OACD;MACA,CAAA;MACD,oBAAC,MAAD;OAAI,WAAU;iBACZ,kBAAkB,KAAK,UACvB,qBAAC,MAAD,EAAA,UAAA;QACC,oBAAC,QAAD;SAAM,WAAU;mBAA+B,MAAM;QAAY,CAAA;QAAE;QAClE,MAAM;OACJ,EAAA,GAHK,MAAM,GAGX,CACJ;MACE,CAAA;KACA;;IAEN,oBAAC,KAAD;KAAG,WAAU;KAA2B,aAAU;eAChD,aAAa,WAAW,YAAY,SAAS,aAAa,IAAI;IAC7D,CAAA;GACC;IACD;;AAEP"}
1
+ {"version":3,"file":"CalcExpressionBuilder.js","names":["useTranslation"],"sources":["../../src/client/CalcExpressionBuilder.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tButton,\n\tCirclePlusIcon,\n\tFieldError,\n\tFieldLabel,\n\tLineIcon,\n\tReactSelect,\n\ttype ReactSelectOption,\n\tRenderCustomComponent,\n\tuseField,\n\tuseFormFields,\n} from '@payloadcms/ui'\nimport { getDataFromFormState } from 'payload/shared'\nimport { useMemo, useState } from 'react'\nimport { formatCalc } from '../calc/formatCalc'\nimport { normalizeCalc } from '../calc/normalizeCalc'\nimport {\n\tCALC_FNS,\n\tCALC_OPS,\n\ttype CalcExpression,\n\ttype CalcFn,\n\ttype CalcFnName,\n\ttype CalcOp,\n\tisCalcFn,\n} from '../calc/types'\nimport type { CalcSourceClientMeta } from '../fields/builtin/calculation'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport type { FieldRow } from './synthesizeClientField'\nimport { toStaticLabel } from './toStaticLabel'\nimport './admin.css'\n\nexport type CalcExpressionBuilderProps = {\n\tpath?: string\n\tfield?: { label?: unknown }\n\treadOnly?: boolean\n\t/** Registered calc-source metadata (key, label, modes), threaded as clientProps by `buildCalculationField`. */\n\tsources?: CalcSourceClientMeta[]\n\t/** Registered custom calc function names, so client-side normalization accepts what the server accepts. */\n\tfunctions?: string[]\n}\n\n/**\n * The editing view model: authors read and build expressions left-to-right, so the UI edits a\n * chain (first operand, then op+operand steps, then an optional wrapping unary function) and the\n * stored `CalcExpression` AST is derived by left-folding. The AST contract is untouched.\n */\nexport type CalcChain = { first: CalcOperand; steps: CalcChainStep[]; finish?: CalcFn }\nexport type CalcChainStep = { op: CalcOp; operand: CalcOperand }\nexport type CalcOperand =\n\t| { kind: 'ref'; field: string }\n\t| { kind: 'lit'; value: number }\n\t| { kind: 'weight'; field: string; weights?: Record<string, number>; source?: string }\n\t| { kind: 'source'; source: string }\n\t| { kind: 'group'; chain: CalcChain }\n\t| { kind: 'fn'; fn: CalcFnName; args: CalcChain[] }\n\t| { kind: 'neg'; operand: CalcOperand }\n\n/** Kinds a leaf operand card can switch between in place; containers come from Start with, loading, or JSON. */\ntype LeafKind = 'lit' | 'ref' | 'weight'\ntype StartKind = 'fn' | LeafKind\n\n/** The single-argument functions offered by the \"Then apply\" finisher; min/max are variadic and stay Function operands. */\nconst UNARY_FNS = CALC_FNS.filter((fn) => fn !== 'min' && fn !== 'max')\n\nconst seedOperand = (kind: LeafKind): CalcOperand => {\n\tswitch (kind) {\n\t\tcase 'ref':\n\t\t\treturn { kind: 'ref', field: '' }\n\t\tcase 'lit':\n\t\t\treturn { kind: 'lit', value: 0 }\n\t\tcase 'weight':\n\t\t\treturn { kind: 'weight', field: '', weights: {} }\n\t}\n}\n\nconst seedAst = (kind: StartKind): CalcExpression => {\n\tswitch (kind) {\n\t\tcase 'ref':\n\t\t\treturn { type: 'ref', field: '' }\n\t\tcase 'lit':\n\t\t\treturn { type: 'lit', value: 0 }\n\t\tcase 'weight':\n\t\t\treturn { type: 'weight', field: '', weights: {} }\n\t\tcase 'fn':\n\t\t\treturn { type: 'fn', fn: 'min', args: [{ type: 'lit', value: 0 }] }\n\t}\n}\n\nconst astToOperand = (node: CalcExpression): CalcOperand => {\n\tswitch (node.type) {\n\t\tcase 'ref':\n\t\t\treturn { kind: 'ref', field: node.field }\n\t\tcase 'lit':\n\t\t\treturn { kind: 'lit', value: node.value }\n\t\tcase 'source':\n\t\t\treturn { kind: 'source', source: node.source }\n\t\tcase 'weight':\n\t\t\treturn {\n\t\t\t\tkind: 'weight',\n\t\t\t\tfield: node.field,\n\t\t\t\t...(node.weights !== undefined ? { weights: node.weights } : {}),\n\t\t\t\t...(node.source !== undefined ? { source: node.source } : {}),\n\t\t\t}\n\t\tcase 'neg':\n\t\t\treturn { kind: 'neg', operand: astToOperand(node.operand) }\n\t\tcase 'fn':\n\t\t\treturn { kind: 'fn', fn: node.fn, args: node.args.map((arg) => toChain(arg, false)) }\n\t\tcase 'op':\n\t\t\treturn { kind: 'group', chain: toChain(node, false) }\n\t}\n}\n\nconst toChain = (expr: CalcExpression, allowFinish: boolean): CalcChain => {\n\tconst arg = expr.type === 'fn' ? expr.args[0] : undefined\n\tif (\n\t\tallowFinish &&\n\t\texpr.type === 'fn' &&\n\t\texpr.args.length === 1 &&\n\t\targ !== undefined &&\n\t\tisCalcFn(expr.fn) &&\n\t\t(UNARY_FNS as readonly CalcFn[]).includes(expr.fn)\n\t) {\n\t\treturn { ...toChain(arg, false), finish: expr.fn }\n\t}\n\tconst steps: CalcChainStep[] = []\n\tlet node = expr\n\twhile (node.type === 'op') {\n\t\tsteps.unshift({ op: node.op, operand: astToOperand(node.right) })\n\t\tnode = node.left\n\t}\n\treturn { first: astToOperand(node), steps }\n}\n\n/**\n * AST -> chain: the left spine of binary ops flattens into first + steps (a nested op on the right\n * becomes a `group`); a root unary fn wrapping the whole expression loads as `finish` (min/max stay\n * fn operands so the finisher select never holds a value it cannot offer). Total: every valid\n * `CalcExpression` loads without loss, and `chainToAst(astToChain(x))` is structurally `x`.\n */\nexport const astToChain = (expr: CalcExpression): CalcChain => toChain(expr, true)\n\nconst operandToAst = (operand: CalcOperand): CalcExpression => {\n\tswitch (operand.kind) {\n\t\tcase 'ref':\n\t\t\treturn { type: 'ref', field: operand.field }\n\t\tcase 'lit':\n\t\t\treturn { type: 'lit', value: operand.value }\n\t\tcase 'weight':\n\t\t\treturn {\n\t\t\t\ttype: 'weight',\n\t\t\t\tfield: operand.field,\n\t\t\t\t...(operand.weights !== undefined ? { weights: operand.weights } : {}),\n\t\t\t\t...(operand.source !== undefined ? { source: operand.source } : {}),\n\t\t\t}\n\t\tcase 'source':\n\t\t\treturn { type: 'source', source: operand.source }\n\t\tcase 'neg':\n\t\t\treturn { type: 'neg', operand: operandToAst(operand.operand) }\n\t\tcase 'fn':\n\t\t\treturn { type: 'fn', fn: operand.fn, args: operand.args.map(chainBodyToAst) }\n\t\tcase 'group':\n\t\t\treturn chainBodyToAst(operand.chain)\n\t}\n}\n\n/** Folds first + steps only. `finish` is root-only by design: nested chains (groups, fn args) never carry one, so it is deliberately ignored here. */\nconst chainBodyToAst = (chain: CalcChain): CalcExpression =>\n\tchain.steps.reduce<CalcExpression>(\n\t\t(left, step) => ({ type: 'op', op: step.op, left, right: operandToAst(step.operand) }),\n\t\toperandToAst(chain.first)\n\t)\n\n/** Chain -> AST: left-fold first + steps into the binary tree (left-assoc matches `-`/`/`/`%`), then wrap in `finish` when set. */\nexport const chainToAst = (chain: CalcChain): CalcExpression => {\n\tconst body = chainBodyToAst(chain)\n\treturn chain.finish ? { type: 'fn', fn: chain.finish, args: [body] } : body\n}\n\ntype ChoiceOption = { label: string; value: string }\ntype ChoiceSibling = { name: string; label: string; options: ChoiceOption[] }\ntype Siblings = {\n\tnumeric: ChoiceOption[]\n\tchoices: ChoiceSibling[]\n\tlabels: Record<string, string>\n}\n\nconst optionRows = (options: unknown): ChoiceOption[] => {\n\tif (!Array.isArray(options)) {\n\t\treturn []\n\t}\n\treturn options.flatMap((option) => {\n\t\tif (typeof option === 'string') {\n\t\t\treturn option.length > 0 ? [{ label: option, value: option }] : []\n\t\t}\n\t\tif (!option || typeof option !== 'object') {\n\t\t\treturn []\n\t\t}\n\t\tconst { label, value } = option as { label?: unknown; value?: unknown }\n\t\tif (typeof value !== 'string' || value.length === 0) {\n\t\t\treturn []\n\t\t}\n\t\treturn [{ label: typeof label === 'string' && label.length > 0 ? label : value, value }]\n\t})\n}\n\nconst siblingsFromData = (data: Record<string, unknown>, selfIndex: number): Siblings => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as unknown[]) : []\n\tconst siblings: Siblings = { numeric: [], choices: [], labels: {} }\n\trows.forEach((row, index) => {\n\t\tif (!row || typeof row !== 'object') {\n\t\t\treturn\n\t\t}\n\t\tconst { blockType, name, label, options } = row as FieldRow\n\t\tconst trimmed = typeof name === 'string' ? name.trim() : ''\n\t\tif (trimmed.length === 0) {\n\t\t\treturn\n\t\t}\n\t\tconst display = typeof label === 'string' && label.length > 0 ? label : trimmed\n\t\tsiblings.labels[trimmed] = display\n\t\t// Calculations fold in declaration order, so a calculation is only referenceable when it is\n\t\t// declared before this one; a forward (or self) reference would always evaluate to 0.\n\t\tconst referenceable =\n\t\t\tblockType === 'number' || (blockType === 'calculation' && index < selfIndex)\n\t\tif (referenceable) {\n\t\t\tsiblings.numeric.push({ label: display, value: trimmed })\n\t\t}\n\t\tif (blockType === 'select') {\n\t\t\tsiblings.choices.push({ name: trimmed, label: display, options: optionRows(options) })\n\t\t}\n\t})\n\treturn siblings\n}\n\nconst singleOption = (\n\tselected: ReactSelectOption | ReactSelectOption[] | null\n): ReactSelectOption | undefined => {\n\tconst chosen = Array.isArray(selected) ? selected[0] : selected\n\treturn chosen ?? undefined\n}\n\n/** Keeps a stored reference selectable even when it no longer matches any option, like FieldNameSelect. */\nconst withStored = (options: ChoiceOption[], stored: string): ChoiceOption[] =>\n\tstored.length > 0 && !options.some((option) => option.value === stored)\n\t\t? [...options, { label: stored, value: stored }]\n\t\t: options\n\ntype NumberInputProps = {\n\tvalue: number | undefined\n\tonCommit: (value: number) => void\n\tclassName: string\n\tid?: string\n\tdisabled?: boolean\n\t'aria-label'?: string\n}\n\n/**\n * Number input with a local draft: keystrokes commit only when the text parses to a finite number,\n * an invalid draft reverts to the committed value on blur, and an external value change resyncs\n * the draft.\n */\nconst NumberInput = ({\n\tvalue,\n\tonCommit,\n\tclassName,\n\tid,\n\tdisabled,\n\t'aria-label': ariaLabel,\n}: NumberInputProps) => {\n\tconst [draft, setDraft] = useState(value === undefined ? '' : String(value))\n\tconst [lastValue, setLastValue] = useState(value)\n\tif (value !== lastValue) {\n\t\tsetLastValue(value)\n\t\tif (draft.trim() === '' || Number(draft) !== value) {\n\t\t\tsetDraft(value === undefined ? '' : String(value))\n\t\t}\n\t}\n\treturn (\n\t\t<input\n\t\t\ttype=\"number\"\n\t\t\tclassName={className}\n\t\t\tid={id}\n\t\t\tdisabled={disabled}\n\t\t\taria-label={ariaLabel}\n\t\t\tvalue={draft}\n\t\t\tonChange={(event) => {\n\t\t\t\tconst text = event.target.value\n\t\t\t\tsetDraft(text)\n\t\t\t\tconst parsed = Number(text)\n\t\t\t\tif (text.trim() !== '' && Number.isFinite(parsed)) {\n\t\t\t\t\tonCommit(parsed)\n\t\t\t\t}\n\t\t\t}}\n\t\t\tonBlur={() => {\n\t\t\t\tconst parsed = Number(draft)\n\t\t\t\tif (draft.trim() === '' || !Number.isFinite(parsed)) {\n\t\t\t\t\tsetDraft(value === undefined ? '' : String(value))\n\t\t\t\t}\n\t\t\t}}\n\t\t/>\n\t)\n}\n\ntype BuilderCtx = {\n\tt: (key: TranslationKey) => string\n\tsiblings: Siblings\n\treadOnly: boolean\n\t/** Resolves a calc source key to its admin-locale display label (raw key when unregistered). */\n\tsourceLabelOf: (key: string) => string\n\t/** Scalar-capable sources as select options (`source:`-prefixed values). */\n\tscalarSourceOptions: ChoiceOption[]\n\t/** Weights-capable sources as select options (`source:`-prefixed values). */\n\tweightSourceOptions: ChoiceOption[]\n\t/** Registered custom calc function names, offered by the fn select after the built-ins. */\n\tcustomFnOptions: ChoiceOption[]\n}\n\nconst OP_OPTIONS: ChoiceOption[] = CALC_OPS.map((op) => ({ label: op, value: op }))\nconst FN_OPTIONS: ChoiceOption[] = CALC_FNS.map((fn) => ({ label: fn, value: fn }))\nconst UNARY_OPTIONS: ChoiceOption[] = UNARY_FNS.map((fn) => ({ label: fn, value: fn }))\n\n/** Source entries share kind/start selects with the fixed kinds, namespaced to avoid key collisions. */\nconst SOURCE_PREFIX = 'source:'\nconst sourceOptionValue = (key: string): string => `${SOURCE_PREFIX}${key}`\nconst sourceKeyOf = (value: string): string | undefined =>\n\tvalue.startsWith(SOURCE_PREFIX) ? value.slice(SOURCE_PREFIX.length) : undefined\n\n/** A source label is a plain string or a per-locale record; resolve it for the admin UI language. */\nconst resolveSourceLabel = (label: string | Record<string, string>, language: string): string =>\n\ttypeof label === 'string' ? label : (label[language] ?? label.en ?? Object.values(label)[0] ?? '')\n\ntype SelectOptionOrGroup = ChoiceOption | { label: string; options: ChoiceOption[] }\n\n/** Fixed kinds stay flat; sources join as a labeled group when any exist (react-select mixes both). */\nconst withSourceGroup = (\n\tbase: ChoiceOption[],\n\tsourceOptions: ChoiceOption[],\n\tgroupLabel: string\n): SelectOptionOrGroup[] =>\n\tsourceOptions.length > 0 ? [...base, { label: groupLabel, options: sourceOptions }] : base\n\ntype OperandCardProps = {\n\toperand: CalcOperand\n\tonChange: (next: CalcOperand) => void\n\tctx: BuilderCtx\n\tidPrefix: string\n}\n\nconst OperandCard = ({ operand, onChange, ctx, idPrefix }: OperandCardProps) => {\n\tconst { t, siblings, readOnly } = ctx\n\n\tif (operand.kind === 'group') {\n\t\treturn (\n\t\t\t<div className=\"fb-calc-operand fb-calc-operand--group\">\n\t\t\t\t<div className=\"fb-calc-operand__title\">{t(keys.calcBuilderGroup)}</div>\n\t\t\t\t<ChainEditor\n\t\t\t\t\tchain={operand.chain}\n\t\t\t\t\tonChange={(chain) => onChange({ ...operand, chain })}\n\t\t\t\t\tctx={ctx}\n\t\t\t\t\tidPrefix={`${idPrefix}-g`}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tif (operand.kind === 'fn') {\n\t\tconst fnOptions = withStored([...FN_OPTIONS, ...ctx.customFnOptions], operand.fn)\n\t\treturn (\n\t\t\t<div className=\"fb-calc-operand fb-calc-operand--fn\">\n\t\t\t\t<div className=\"fb-calc-operand__header\">\n\t\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idPrefix}-fn`}>\n\t\t\t\t\t\t{t(keys.calcBuilderFunction)}\n\t\t\t\t\t</label>\n\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\tclassName=\"fb-calc-operand__fn\"\n\t\t\t\t\t\tinputId={`${idPrefix}-fn`}\n\t\t\t\t\t\toptions={fnOptions}\n\t\t\t\t\t\tvalue={fnOptions.find((option) => option.value === operand.fn)}\n\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\tif (chosen) {\n\t\t\t\t\t\t\t\tonChange({ ...operand, fn: String(chosen.value) })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"fb-calc-fn__args\">\n\t\t\t\t\t{operand.args.map((arg, index) => (\n\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: args are positional and never reordered\n\t\t\t\t\t\t<div key={index} className=\"fb-calc-fn__arg\">\n\t\t\t\t\t\t\t<div className=\"fb-calc-fn__arg-chain\">\n\t\t\t\t\t\t\t\t<ChainEditor\n\t\t\t\t\t\t\t\t\tchain={arg}\n\t\t\t\t\t\t\t\t\tonChange={(next) =>\n\t\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\t\t...operand,\n\t\t\t\t\t\t\t\t\t\t\targs: operand.args.map((a, i) => (i === index ? next : a)),\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tctx={ctx}\n\t\t\t\t\t\t\t\t\tidPrefix={`${idPrefix}-a${index}`}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{operand.args.length > 1 ? (\n\t\t\t\t\t\t\t\t<div className=\"fb-calc-fn__arg-remove\">\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\t\t\t\t\ticon={<LineIcon size={24} />}\n\t\t\t\t\t\t\t\t\t\taria-label={t(keys.calcBuilderRemove)}\n\t\t\t\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\t\t\t...operand,\n\t\t\t\t\t\t\t\t\t\t\t\targs: operand.args.filter((_, i) => i !== index),\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t))}\n\t\t\t\t\t<div className=\"fb-calc-fn__add\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t...operand,\n\t\t\t\t\t\t\t\t\targs: [...operand.args, { first: { kind: 'lit', value: 0 }, steps: [] }],\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{t(keys.calcBuilderAddArgument)}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tif (operand.kind === 'neg') {\n\t\treturn (\n\t\t\t<div className=\"fb-calc-operand fb-calc-operand--neg\">\n\t\t\t\t<div className=\"fb-calc-operand__title\">{t(keys.calcBuilderNegate)}</div>\n\t\t\t\t<OperandCard\n\t\t\t\t\toperand={operand.operand}\n\t\t\t\t\tonChange={(next) => onChange({ kind: 'neg', operand: next })}\n\t\t\t\t\tctx={ctx}\n\t\t\t\t\tidPrefix={`${idPrefix}-n`}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tconst leafKindOptions: ChoiceOption[] = [\n\t\t{ label: t(keys.calcBuilderAnswer), value: 'ref' },\n\t\t{ label: t(keys.calcBuilderNumber), value: 'lit' },\n\t\t{ label: t(keys.calcBuilderWeights), value: 'weight' },\n\t]\n\tconst kindValue = operand.kind === 'source' ? sourceOptionValue(operand.source) : operand.kind\n\tconst kindSourceOptions =\n\t\toperand.kind === 'source' &&\n\t\t!ctx.scalarSourceOptions.some((option) => option.value === sourceOptionValue(operand.source))\n\t\t\t? [...ctx.scalarSourceOptions, { label: operand.source, value: kindValue }]\n\t\t\t: ctx.scalarSourceOptions\n\tconst kindFlat = [...leafKindOptions, ...kindSourceOptions]\n\tconst refOptions = operand.kind === 'ref' ? withStored(siblings.numeric, operand.field) : []\n\tconst choiceOptions =\n\t\toperand.kind === 'weight'\n\t\t\t? withStored(\n\t\t\t\t\tsiblings.choices.map((c) => ({ label: c.label, value: c.name })),\n\t\t\t\t\toperand.field\n\t\t\t\t)\n\t\t\t: []\n\tconst choice =\n\t\toperand.kind === 'weight' ? siblings.choices.find((c) => c.name === operand.field) : undefined\n\tconst weightSource = operand.kind === 'weight' ? operand.source : undefined\n\tconst weightValuesOptions: ChoiceOption[] = [\n\t\t{ label: t(keys.calcBuilderWeightManual), value: 'manual' },\n\t\t...(weightSource !== undefined &&\n\t\t!ctx.weightSourceOptions.some((option) => option.value === sourceOptionValue(weightSource))\n\t\t\t? [\n\t\t\t\t\t...ctx.weightSourceOptions,\n\t\t\t\t\t{ label: weightSource, value: sourceOptionValue(weightSource) },\n\t\t\t\t]\n\t\t\t: ctx.weightSourceOptions),\n\t]\n\n\treturn (\n\t\t<div className=\"fb-calc-operand\">\n\t\t\t<div className=\"fb-calc-operand__header\">\n\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idPrefix}-kind`}>\n\t\t\t\t\t{t(keys.calcBuilderKind)}\n\t\t\t\t</label>\n\t\t\t\t<ReactSelect\n\t\t\t\t\tclassName=\"fb-calc-operand__kind\"\n\t\t\t\t\tinputId={`${idPrefix}-kind`}\n\t\t\t\t\toptions={\n\t\t\t\t\t\twithSourceGroup(\n\t\t\t\t\t\t\tleafKindOptions,\n\t\t\t\t\t\t\tkindSourceOptions,\n\t\t\t\t\t\t\tt(keys.calcBuilderSourcesGroup)\n\t\t\t\t\t\t) as ReactSelectOption[]\n\t\t\t\t\t}\n\t\t\t\t\tvalue={kindFlat.find((option) => option.value === kindValue)}\n\t\t\t\t\tisClearable={false}\n\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\tif (!chosen || chosen.value === kindValue) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst sourceKey = sourceKeyOf(String(chosen.value))\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tsourceKey !== undefined\n\t\t\t\t\t\t\t\t? { kind: 'source', source: sourceKey }\n\t\t\t\t\t\t\t\t: seedOperand(chosen.value as LeafKind)\n\t\t\t\t\t\t)\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t\t{operand.kind === 'source' ? (\n\t\t\t\t\t<span className=\"fb-calc-operand__source\">{ctx.sourceLabelOf(operand.source)}</span>\n\t\t\t\t) : null}\n\t\t\t\t{operand.kind === 'ref' ? (\n\t\t\t\t\trefOptions.length === 0 ? (\n\t\t\t\t\t\t<p className=\"fb-calc-hint\">{t(keys.calcBuilderNoNumericFields)}</p>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idPrefix}-ref`}>\n\t\t\t\t\t\t\t\t{t(keys.calcBuilderPickField)}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-operand__ref\"\n\t\t\t\t\t\t\t\tinputId={`${idPrefix}-ref`}\n\t\t\t\t\t\t\t\toptions={refOptions}\n\t\t\t\t\t\t\t\tvalue={refOptions.find((option) => option.value === operand.field)}\n\t\t\t\t\t\t\t\tisClearable={!readOnly}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tplaceholder={t(keys.calcBuilderPickField)}\n\t\t\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\t\t\tonChange({ kind: 'ref', field: chosen ? String(chosen.value) : '' })\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)\n\t\t\t\t) : null}\n\t\t\t\t{operand.kind === 'lit' ? (\n\t\t\t\t\t<NumberInput\n\t\t\t\t\t\tclassName=\"form-input fb-calc-operand__number\"\n\t\t\t\t\t\tid={`${idPrefix}-number`}\n\t\t\t\t\t\taria-label={t(keys.calcBuilderNumber)}\n\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\tvalue={operand.value}\n\t\t\t\t\t\tonCommit={(value) => onChange({ kind: 'lit', value })}\n\t\t\t\t\t/>\n\t\t\t\t) : null}\n\t\t\t\t{operand.kind === 'weight' ? (\n\t\t\t\t\tchoiceOptions.length === 0 ? (\n\t\t\t\t\t\t<p className=\"fb-calc-hint\">{t(keys.calcBuilderNoChoiceFields)}</p>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idPrefix}-weight-field`}>\n\t\t\t\t\t\t\t\t{t(keys.calcBuilderPickField)}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-operand__weight-field\"\n\t\t\t\t\t\t\t\tinputId={`${idPrefix}-weight-field`}\n\t\t\t\t\t\t\t\toptions={choiceOptions}\n\t\t\t\t\t\t\t\tvalue={choiceOptions.find((option) => option.value === operand.field)}\n\t\t\t\t\t\t\t\tisClearable={!readOnly}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tplaceholder={t(keys.calcBuilderPickField)}\n\t\t\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\t\t\tconst field = chosen ? String(chosen.value) : ''\n\t\t\t\t\t\t\t\t\tif (field !== operand.field) {\n\t\t\t\t\t\t\t\t\t\t// Inline weights are per-option and reset with the field; a source keeps\n\t\t\t\t\t\t\t\t\t\t// resolving (its resolver receives the newly chosen field).\n\t\t\t\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\t\t\t\toperand.source !== undefined\n\t\t\t\t\t\t\t\t\t\t\t\t? { kind: 'weight', field, source: operand.source }\n\t\t\t\t\t\t\t\t\t\t\t\t: { kind: 'weight', field, weights: {} }\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t\t{operand.kind === 'weight' && ctx.weightSourceOptions.length > 0 ? (\n\t\t\t\t<div className=\"fb-calc-operand__weight-values-row\">\n\t\t\t\t\t<label className=\"fb-calc-operand__weight-values-label\" htmlFor={`${idPrefix}-wv`}>\n\t\t\t\t\t\t{t(keys.calcBuilderWeightValues)}\n\t\t\t\t\t</label>\n\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\tclassName=\"fb-calc-operand__weight-values\"\n\t\t\t\t\t\tinputId={`${idPrefix}-wv`}\n\t\t\t\t\t\toptions={weightValuesOptions}\n\t\t\t\t\t\tvalue={weightValuesOptions.find(\n\t\t\t\t\t\t\t(option) =>\n\t\t\t\t\t\t\t\toption.value ===\n\t\t\t\t\t\t\t\t(operand.source !== undefined ? sourceOptionValue(operand.source) : 'manual')\n\t\t\t\t\t\t)}\n\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\tif (!chosen) {\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst sourceKey = sourceKeyOf(String(chosen.value))\n\t\t\t\t\t\t\tif (sourceKey === undefined) {\n\t\t\t\t\t\t\t\tif (operand.source !== undefined) {\n\t\t\t\t\t\t\t\t\t// Back to Manual: drop the source, keep any inline weights (they were\n\t\t\t\t\t\t\t\t\t// preserved untouched while sourced) so the author's numbers return.\n\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\tkind: 'weight',\n\t\t\t\t\t\t\t\t\t\tfield: operand.field,\n\t\t\t\t\t\t\t\t\t\tweights: operand.weights ?? {},\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (sourceKey !== operand.source) {\n\t\t\t\t\t\t\t\tonChange({ ...operand, source: sourceKey })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t\t{operand.kind === 'weight' && operand.source !== undefined ? (\n\t\t\t\t<p className=\"fb-calc-hint\">{t(keys.calcBuilderWeightsFromSource)}</p>\n\t\t\t) : null}\n\t\t\t{operand.kind === 'weight' && operand.source === undefined && choice ? (\n\t\t\t\t<div className=\"fb-calc-operand__weights\">\n\t\t\t\t\t{choice.options.map((option) => (\n\t\t\t\t\t\t<div key={option.value} className=\"fb-calc-operand__weight-row\">\n\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-operand__weight-label\"\n\t\t\t\t\t\t\t\thtmlFor={`${idPrefix}-weight-${option.value}`}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{option.label}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<NumberInput\n\t\t\t\t\t\t\t\tclassName=\"form-input fb-calc-operand__weight\"\n\t\t\t\t\t\t\t\tid={`${idPrefix}-weight-${option.value}`}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tvalue={operand.weights?.[option.value]}\n\t\t\t\t\t\t\t\tonCommit={(value) =>\n\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\t...operand,\n\t\t\t\t\t\t\t\t\t\tweights: { ...(operand.weights ?? {}), [option.value]: value },\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t))}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t)\n}\n\ntype ChainEditorProps = {\n\tchain: CalcChain\n\tonChange: (next: CalcChain) => void\n\t/** Root only: called when the only row is removed, clearing the expression back to Start with. */\n\tonEmptied?: () => void\n\t/**\n\t * Honest-affordance rule: an X must actually remove. The root's only-row X clears the whole\n\t * expression, so it stays; a nested chain's only row (fn arg, group) would merely reseed, so\n\t * its X is not rendered at all.\n\t */\n\tisRoot?: boolean\n\tctx: BuilderCtx\n\tidPrefix: string\n}\n\nconst ChainEditor = ({ chain, onChange, onEmptied, isRoot, ctx, idPrefix }: ChainEditorProps) => {\n\tconst { t, readOnly } = ctx\n\n\tconst removeRow = (row: number) => {\n\t\tif (row === 0) {\n\t\t\tconst [promoted, ...rest] = chain.steps\n\t\t\tif (!promoted) {\n\t\t\t\tonEmptied?.()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tonChange({ ...chain, first: promoted.operand, steps: rest })\n\t\t\treturn\n\t\t}\n\t\tonChange({ ...chain, steps: chain.steps.filter((_, i) => i !== row - 1) })\n\t}\n\n\tconst rows: { op?: CalcOp; operand: CalcOperand }[] = [\n\t\t{ operand: chain.first },\n\t\t...chain.steps.map((step) => ({ op: step.op, operand: step.operand })),\n\t]\n\n\treturn (\n\t\t<div className=\"fb-calc-chain\">\n\t\t\t{rows.map((row, index) => (\n\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: rows are positional and never reordered\n\t\t\t\t<div key={index} className={index > 0 ? 'fb-calc-row fb-calc-row--divided' : 'fb-calc-row'}>\n\t\t\t\t\t{index === 0 ? <div className=\"fb-calc-row__op-spacer\" aria-hidden=\"true\" /> : null}\n\t\t\t\t\t{index > 0 ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idPrefix}-r${index}-op`}>\n\t\t\t\t\t\t\t\t{t(keys.calcBuilderMath)}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-row__op\"\n\t\t\t\t\t\t\t\tinputId={`${idPrefix}-r${index}-op`}\n\t\t\t\t\t\t\t\toptions={OP_OPTIONS}\n\t\t\t\t\t\t\t\tvalue={OP_OPTIONS.find((option) => option.value === row.op)}\n\t\t\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\t\t\tif (chosen) {\n\t\t\t\t\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t\t\t\t\t...chain,\n\t\t\t\t\t\t\t\t\t\t\tsteps: chain.steps.map((step, i) =>\n\t\t\t\t\t\t\t\t\t\t\t\ti === index - 1 ? { ...step, op: chosen.value as CalcOp } : step\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : null}\n\t\t\t\t\t<div className=\"fb-calc-row__operand\">\n\t\t\t\t\t\t<OperandCard\n\t\t\t\t\t\t\toperand={row.operand}\n\t\t\t\t\t\t\tonChange={(operand) =>\n\t\t\t\t\t\t\t\tindex === 0\n\t\t\t\t\t\t\t\t\t? onChange({ ...chain, first: operand })\n\t\t\t\t\t\t\t\t\t: onChange({\n\t\t\t\t\t\t\t\t\t\t\t...chain,\n\t\t\t\t\t\t\t\t\t\t\tsteps: chain.steps.map((step, i) =>\n\t\t\t\t\t\t\t\t\t\t\t\ti === index - 1 ? { ...step, operand } : step\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tctx={ctx}\n\t\t\t\t\t\t\tidPrefix={`${idPrefix}-r${index}`}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{rows.length > 1 || isRoot ? (\n\t\t\t\t\t\t<div className=\"fb-calc-row__remove\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\t\t\ticon={<LineIcon size={24} />}\n\t\t\t\t\t\t\t\taria-label={t(keys.calcBuilderRemove)}\n\t\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tonClick={() => removeRow(index)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t))}\n\t\t\t<div className=\"fb-calc-chain__add\">\n\t\t\t\t<Button\n\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\tmargin={false}\n\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\tonClick={() =>\n\t\t\t\t\t\tonChange({\n\t\t\t\t\t\t\t...chain,\n\t\t\t\t\t\t\tsteps: [...chain.steps, { op: '*', operand: seedOperand('ref') }],\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{t(keys.calcBuilderAddStep)}\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\n/**\n * Visual editor for the calculation field's `expression` AST, presented as a left-to-right chain.\n * Storage shape is unchanged and `validateExpression` stays the server gate; the AST remains\n * authorable via the API.\n */\nexport const CalcExpressionBuilder = (props: CalcExpressionBuilderProps) => {\n\tconst {\n\t\tcustomComponents: { Error: ErrorComponent, Label } = {},\n\t\tdisabled,\n\t\tpath,\n\t\tsetValue,\n\t\tshowError,\n\t\tvalue,\n\t} = useField<unknown>({ path: props.path })\n\tconst { t, i18n } = useTranslation()\n\tconst label = toStaticLabel(props.field?.label)\n\tconst readOnly = props.readOnly === true || disabled === true\n\n\tconst sources = useMemo(() => props.sources ?? [], [props.sources])\n\t// Mirrors the server-side allowed sets, so the builder accepts exactly the expressions\n\t// `buildValidateExpression` accepts (a sourced expression must not read as \"stored invalid\").\n\tconst allowed = useMemo(\n\t\t() => ({\n\t\t\tsources: new Set(sources.map((source) => source.key)),\n\t\t\tfunctions: new Set(props.functions ?? []),\n\t\t}),\n\t\t[sources, props.functions]\n\t)\n\tconst sourceLabelOf = (key: string): string => {\n\t\tconst meta = sources.find((source) => source.key === key)\n\t\treturn meta ? resolveSourceLabel(meta.label, i18n.language) : key\n\t}\n\tconst scalarSourceOptions: ChoiceOption[] = sources\n\t\t.filter((source) => source.scalar)\n\t\t.map((source) => ({ label: sourceLabelOf(source.key), value: sourceOptionValue(source.key) }))\n\tconst weightSourceOptions: ChoiceOption[] = sources\n\t\t.filter((source) => source.weights)\n\t\t.map((source) => ({ label: sourceLabelOf(source.key), value: sourceOptionValue(source.key) }))\n\tconst customFnOptions: ChoiceOption[] = (props.functions ?? []).map((fn) => ({\n\t\tlabel: fn,\n\t\tvalue: fn,\n\t}))\n\n\tconst expression = useMemo(() => normalizeCalc(value, allowed), [value, allowed])\n\tconst chain = useMemo(() => (expression ? astToChain(expression) : undefined), [expression])\n\tconst storedInvalid = expression === undefined && value != null && value !== ''\n\n\t// The expression path is `fields.<row>.expression`; that row is the calculation block being\n\t// edited, so it bounds which calculation siblings are referenceable (see siblingsFromData).\n\t// An unparseable path (never expected) offers every calculation rather than none.\n\tconst selfIndex = useMemo(() => {\n\t\tconst match = /^fields\\.(\\d+)\\./.exec(path)\n\t\treturn match ? Number(match[1]) : Number.MAX_SAFE_INTEGER\n\t}, [path])\n\n\tconst siblingsJson = useFormFields(([fields]) =>\n\t\tJSON.stringify(siblingsFromData(getDataFromFormState(fields, true), selfIndex))\n\t)\n\tconst siblings = useMemo(() => JSON.parse(siblingsJson) as Siblings, [siblingsJson])\n\n\tconst startOptions: ChoiceOption[] = [\n\t\t{ label: t(keys.calcBuilderAnswer), value: 'ref' },\n\t\t{ label: t(keys.calcBuilderNumber), value: 'lit' },\n\t\t{ label: t(keys.calcBuilderWeights), value: 'weight' },\n\t\t{ label: t(keys.calcBuilderFunction), value: 'fn' },\n\t]\n\tconst startDescriptions: { key: string; label: string; description: string }[] = [\n\t\t{\n\t\t\tkey: 'ref',\n\t\t\tlabel: t(keys.calcBuilderAnswer),\n\t\t\tdescription: t(keys.calcBuilderFieldDescription),\n\t\t},\n\t\t{\n\t\t\tkey: 'lit',\n\t\t\tlabel: t(keys.calcBuilderNumber),\n\t\t\tdescription: t(keys.calcBuilderNumberDescription),\n\t\t},\n\t\t{\n\t\t\tkey: 'weight',\n\t\t\tlabel: t(keys.calcBuilderWeights),\n\t\t\tdescription: t(keys.calcBuilderWeightsDescription),\n\t\t},\n\t\t{\n\t\t\tkey: 'fn',\n\t\t\tlabel: t(keys.calcBuilderFunction),\n\t\t\tdescription: t(keys.calcBuilderFunctionDescription),\n\t\t},\n\t]\n\n\tconst commitChain = (next: CalcChain) => {\n\t\tif (!readOnly) {\n\t\t\tsetValue(chainToAst(next))\n\t\t}\n\t}\n\n\tconst clear = () => {\n\t\tif (!readOnly) {\n\t\t\tsetValue(null)\n\t\t}\n\t}\n\n\t// An unfilled slot (blank ref) previews as \"?\" so a partial chain reads \"Price × ?\" instead of\n\t// trailing off; formatCalc itself stays pure.\n\tconst labelOf = (field: string) => (field.trim() === '' ? '?' : (siblings.labels[field] ?? field))\n\n\tconst idBase = `calc-${path.replace(/\\./g, '__')}`\n\tconst ctx: BuilderCtx = {\n\t\tt,\n\t\tsiblings,\n\t\treadOnly,\n\t\tsourceLabelOf,\n\t\tscalarSourceOptions,\n\t\tweightSourceOptions,\n\t\tcustomFnOptions,\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName={['field-type', 'fb-calc-builder', showError && 'error', readOnly && 'read-only']\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ')}\n\t\t\tid={path ? `field-${path.replace(/\\./g, '__')}` : undefined}\n\t\t>\n\t\t\t<RenderCustomComponent\n\t\t\t\tCustomComponent={Label}\n\t\t\t\tFallback={<FieldLabel label={label} path={path} />}\n\t\t\t/>\n\t\t\t<div className=\"field-type__wrap\">\n\t\t\t\t<RenderCustomComponent\n\t\t\t\t\tCustomComponent={ErrorComponent}\n\t\t\t\t\tFallback={<FieldError path={path} showError={showError} />}\n\t\t\t\t/>\n\t\t\t\t{chain ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ChainEditor\n\t\t\t\t\t\t\tchain={chain}\n\t\t\t\t\t\t\tonChange={commitChain}\n\t\t\t\t\t\t\tonEmptied={clear}\n\t\t\t\t\t\t\tisRoot\n\t\t\t\t\t\t\tctx={ctx}\n\t\t\t\t\t\t\tidPrefix={idBase}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div className=\"fb-calc-finish\">\n\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-finish__label\"\n\t\t\t\t\t\t\t\thtmlFor={`${idBase}-finish`}\n\t\t\t\t\t\t\t\ttitle={t(keys.calcBuilderThenApply)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{t(keys.calcBuilderThenApply)}\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\tclassName=\"fb-calc-finish__select\"\n\t\t\t\t\t\t\t\tinputId={`${idBase}-finish`}\n\t\t\t\t\t\t\t\toptions={UNARY_OPTIONS}\n\t\t\t\t\t\t\t\tvalue={UNARY_OPTIONS.find((option) => option.value === chain.finish)}\n\t\t\t\t\t\t\t\tisClearable={!readOnly}\n\t\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\t\t\tcommitChain({\n\t\t\t\t\t\t\t\t\t\t...chain,\n\t\t\t\t\t\t\t\t\t\tfinish: chosen ? (chosen.value as CalcFn) : undefined,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<div className=\"fb-calc-builder__empty\">\n\t\t\t\t\t\t{storedInvalid ? (\n\t\t\t\t\t\t\t<p className=\"fb-calc-builder__warning\">{t(keys.calcBuilderStoredInvalid)}</p>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t<p className=\"fb-calc-builder__hint\">{t(keys.calcBuilderAddExpression)}</p>\n\t\t\t\t\t\t<label className=\"fb-visually-hidden\" htmlFor={`${idBase}-seed`}>\n\t\t\t\t\t\t\t{t(keys.calcBuilderStartWith)}\n\t\t\t\t\t\t</label>\n\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\tclassName=\"fb-calc-builder__seed\"\n\t\t\t\t\t\t\tinputId={`${idBase}-seed`}\n\t\t\t\t\t\t\toptions={\n\t\t\t\t\t\t\t\twithSourceGroup(\n\t\t\t\t\t\t\t\t\tstartOptions,\n\t\t\t\t\t\t\t\t\tscalarSourceOptions,\n\t\t\t\t\t\t\t\t\tt(keys.calcBuilderSourcesGroup)\n\t\t\t\t\t\t\t\t) as ReactSelectOption[]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\t\t\tplaceholder={t(keys.calcBuilderStartWith)}\n\t\t\t\t\t\t\tonChange={(selected) => {\n\t\t\t\t\t\t\t\tconst chosen = singleOption(selected)\n\t\t\t\t\t\t\t\tif (!chosen || readOnly) {\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst sourceKey = sourceKeyOf(String(chosen.value))\n\t\t\t\t\t\t\t\tsetValue(\n\t\t\t\t\t\t\t\t\tsourceKey !== undefined\n\t\t\t\t\t\t\t\t\t\t? { type: 'source', source: sourceKey }\n\t\t\t\t\t\t\t\t\t\t: seedAst(chosen.value as StartKind)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ul className=\"fb-calc-builder__kinds\">\n\t\t\t\t\t\t\t{startDescriptions.map((entry) => (\n\t\t\t\t\t\t\t\t<li key={entry.key}>\n\t\t\t\t\t\t\t\t\t<span className=\"fb-calc-builder__kind-label\">{entry.label}</span>{' '}\n\t\t\t\t\t\t\t\t\t{entry.description}\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t<p className=\"fb-calc-builder__preview\" aria-live=\"polite\">\n\t\t\t\t\t{expression ? formatCalc(expression, labelOf, sourceLabelOf) : ''}\n\t\t\t\t</p>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;AAiEA,MAAM,YAAY,SAAS,QAAQ,OAAO,OAAO,SAAS,OAAO,KAAK;AAEtE,MAAM,eAAe,SAAgC;CACpD,QAAQ,MAAR;EACC,KAAK,OACJ,OAAO;GAAE,MAAM;GAAO,OAAO;EAAG;EACjC,KAAK,OACJ,OAAO;GAAE,MAAM;GAAO,OAAO;EAAE;EAChC,KAAK,UACJ,OAAO;GAAE,MAAM;GAAU,OAAO;GAAI,SAAS,CAAC;EAAE;CAClD;AACD;AAEA,MAAM,WAAW,SAAoC;CACpD,QAAQ,MAAR;EACC,KAAK,OACJ,OAAO;GAAE,MAAM;GAAO,OAAO;EAAG;EACjC,KAAK,OACJ,OAAO;GAAE,MAAM;GAAO,OAAO;EAAE;EAChC,KAAK,UACJ,OAAO;GAAE,MAAM;GAAU,OAAO;GAAI,SAAS,CAAC;EAAE;EACjD,KAAK,MACJ,OAAO;GAAE,MAAM;GAAM,IAAI;GAAO,MAAM,CAAC;IAAE,MAAM;IAAO,OAAO;GAAE,CAAC;EAAE;CACpE;AACD;AAEA,MAAM,gBAAgB,SAAsC;CAC3D,QAAQ,KAAK,MAAb;EACC,KAAK,OACJ,OAAO;GAAE,MAAM;GAAO,OAAO,KAAK;EAAM;EACzC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AAkB,KAAK,UACvB,qBAAC,MAAD,EAAA,UAAA;QACC,oBAAC,QAAD;SAAM,WAAU;mBAA+B,MAAM;QAAY,CAAA;QAAE;QAClE,MAAM;OACJ,EAAA,GAHK,MAAM,GAGX,CACJ;MACE,CAAA;KACA;;IAEN,oBAAC,KAAD;KAAG,WAAU;KAA2B,aAAU;eAChD,aAAa,WAAW,YAAY,SAAS,aAAa,IAAI;IAC7D,CAAA;GACC;IACD;;AAEP"}
@@ -9,7 +9,7 @@
9
9
  * winner selected disables the button (there is nothing to record); `mostVoted`/`source` stay enabled
10
10
  * because the winner is server-computed. Disabled on an unsaved document (no id yet).
11
11
  */
12
- declare const ClosePollButton: () => import("react/jsx-runtime").JSX.Element;
12
+ declare const ClosePollButton: () => import("react").JSX.Element;
13
13
  //#endregion
14
14
  export { ClosePollButton };
15
15
  //# sourceMappingURL=ClosePollButton.d.ts.map
@@ -9,7 +9,7 @@ import { ArrayFieldClientProps } from "payload";
9
9
  * at `{path}.{index}` exactly as the native array does, so localization, validation, and descriptions
10
10
  * work natively. Placed by {@link departmentsField}.
11
11
  */
12
- declare const CondensedArray: (props: ArrayFieldClientProps) => import("react/jsx-runtime").JSX.Element;
12
+ declare const CondensedArray: (props: ArrayFieldClientProps) => import("react").JSX.Element;
13
13
  //#endregion
14
14
  export { CondensedArray };
15
15
  //# sourceMappingURL=CondensedArray.d.ts.map
@@ -4,7 +4,7 @@ import { firstOperatorFor } from "../conditions/fieldTypes.js";
4
4
  import { useTranslation as useTranslation$1 } from "../translations/useTranslation.js";
5
5
  import { operandFromRow } from "./synthesizeClientField.js";
6
6
  import { ConditionRow } from "./ConditionRow.js";
7
- import { reduceFieldsToValues, transformWhereQuery } from "payload/shared";
7
+ import { getDataFromFormState, transformWhereQuery } from "payload/shared";
8
8
  import { Button, CirclePlusIcon, useFormFields } from "@payloadcms/ui";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
10
  import { useMemo } from "react";
@@ -36,7 +36,7 @@ const operandsFromData = (data, conditionTypes, selfName) => {
36
36
  };
37
37
  const ConditionBuilder = ({ value, onChange, conditionTypes, selfName }) => {
38
38
  const { t } = useTranslation$1();
39
- const operandsJson = useFormFields(([fields]) => JSON.stringify(operandsFromData(reduceFieldsToValues(fields, true), conditionTypes, selfName)));
39
+ const operandsJson = useFormFields(([fields]) => JSON.stringify(operandsFromData(getDataFromFormState(fields, true), conditionTypes, selfName)));
40
40
  const operands = useMemo(() => JSON.parse(operandsJson), [operandsJson]);
41
41
  const groups = readGroups(value);
42
42
  const emit = (next) => onChange(writeGroups(next));
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.js","names":["useTranslation"],"sources":["../../src/client/ConditionBuilder.tsx"],"sourcesContent":["'use client'\n\nimport { Button, CirclePlusIcon, useFormFields } from '@payloadcms/ui'\nimport type { Operator, Where } from 'payload'\nimport { reduceFieldsToValues, transformWhereQuery } from 'payload/shared'\nimport { useMemo } from 'react'\nimport { type ConditionFieldType, firstOperatorFor } from '../conditions/fieldTypes'\nimport { keys } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport { ConditionRow, type RowCondition } from './ConditionRow'\nimport { type ConditionOperand, type FieldRow, operandFromRow } from './synthesizeClientField'\nimport './admin.css'\n\nexport type ConditionBuilderProps = {\n\tvalue?: Where\n\tonChange: (next: Where) => void\n\tconditionTypes: Record<string, ConditionFieldType>\n\t/** This field's own machine name, excluded from the operand list (a field cannot condition on itself). */\n\tselfName?: string\n}\n\nconst toRow = (constraint: Record<string, unknown>): RowCondition | null => {\n\tconst field = Object.keys(constraint)[0]\n\tif (!field) {\n\t\treturn null\n\t}\n\tconst ops = constraint[field] as Record<string, unknown>\n\tconst operator = Object.keys(ops)[0] as Operator | undefined\n\tif (!operator) {\n\t\treturn null\n\t}\n\treturn { field, operator, value: ops[operator] }\n}\n\nconst fromRow = (row: RowCondition): Where => ({ [row.field]: { [row.operator]: row.value } })\n\nconst readGroups = (value: Where | undefined): RowCondition[][] => {\n\tif (!value || Object.keys(value).length === 0) {\n\t\treturn []\n\t}\n\tconst canonical = transformWhereQuery(value)\n\tconst or = Array.isArray(canonical.or) ? canonical.or : []\n\treturn or.map((group) => {\n\t\tconst and = Array.isArray((group as Where).and) ? ((group as Where).and as Where[]) : []\n\t\treturn and\n\t\t\t.map((constraint) => toRow(constraint as Record<string, unknown>))\n\t\t\t.filter((row): row is RowCondition => row !== null)\n\t})\n}\n\nconst writeGroups = (groups: RowCondition[][]): Where => ({\n\tor: groups.filter((group) => group.length > 0).map((group) => ({ and: group.map(fromRow) })),\n})\n\nconst operandsFromData = (\n\tdata: Record<string, unknown>,\n\tconditionTypes: Record<string, ConditionFieldType>,\n\tselfName: string | undefined\n): ConditionOperand[] => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as FieldRow[]) : []\n\treturn rows\n\t\t.map((row) => operandFromRow(row, conditionTypes))\n\t\t.filter((operand): operand is ConditionOperand => operand !== null && operand.name !== selfName)\n}\n\nexport const ConditionBuilder = ({\n\tvalue,\n\tonChange,\n\tconditionTypes,\n\tselfName,\n}: ConditionBuilderProps) => {\n\tconst { t } = useTranslation()\n\t// Serialize the operand list so the builder re-renders only when operands actually change (a field\n\t// added, renamed, retyped, or its options edited), not on every unrelated form-state update.\n\tconst operandsJson = useFormFields(([fields]) =>\n\t\tJSON.stringify(operandsFromData(reduceFieldsToValues(fields, true), conditionTypes, selfName))\n\t)\n\tconst operands = useMemo(() => JSON.parse(operandsJson) as ConditionOperand[], [operandsJson])\n\n\tconst groups = readGroups(value)\n\tconst emit = (next: RowCondition[][]) => onChange(writeGroups(next))\n\n\tconst addCondition = (groupIndex: number) => {\n\t\tconst first = operands[0]\n\t\tif (!first) {\n\t\t\treturn\n\t\t}\n\t\tconst row: RowCondition = {\n\t\t\tfield: first.name,\n\t\t\toperator: firstOperatorFor(first.conditionType),\n\t\t\tvalue: undefined,\n\t\t}\n\t\temit(\n\t\t\tgroups.length === 0\n\t\t\t\t? [[row]]\n\t\t\t\t: groups.map((group, index) => (index === groupIndex ? [...group, row] : group))\n\t\t)\n\t}\n\n\tconst addOrGroup = () => {\n\t\tconst first = operands[0]\n\t\tif (!first) {\n\t\t\treturn\n\t\t}\n\t\temit([\n\t\t\t...groups,\n\t\t\t[{ field: first.name, operator: firstOperatorFor(first.conditionType), value: undefined }],\n\t\t])\n\t}\n\n\tconst updateRow = (groupIndex: number, rowIndex: number, row: RowCondition) =>\n\t\temit(\n\t\t\tgroups.map((group, index) =>\n\t\t\t\tindex === groupIndex\n\t\t\t\t\t? group.map((existing, position) => (position === rowIndex ? row : existing))\n\t\t\t\t\t: group\n\t\t\t)\n\t\t)\n\n\tconst removeRow = (groupIndex: number, rowIndex: number) =>\n\t\temit(\n\t\t\tgroups\n\t\t\t\t.map((group, index) =>\n\t\t\t\t\tindex === groupIndex ? group.filter((_, position) => position !== rowIndex) : group\n\t\t\t\t)\n\t\t\t\t.filter((group) => group.length > 0)\n\t\t)\n\n\tif (operands.length === 0) {\n\t\treturn <p className=\"fb-condition-builder__hint\">{t(keys.conditionNoFields)}</p>\n\t}\n\n\treturn (\n\t\t<div className=\"fb-condition-builder\">\n\t\t\t{groups.length === 0 ? (\n\t\t\t\t<p className=\"fb-condition-builder__hint\">{t(keys.conditionEmpty)}</p>\n\t\t\t) : (\n\t\t\t\tgroups.map((group, groupIndex) => (\n\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: groups are positional and never reordered\n\t\t\t\t\t<div key={groupIndex} className=\"fb-condition-builder__group\">\n\t\t\t\t\t\t{groupIndex > 0 ? (\n\t\t\t\t\t\t\t<div className=\"fb-condition-builder__or-label\">{t(keys.conditionOr)}</div>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{group.map((row, rowIndex) => (\n\t\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: rows are positional and never reordered\n\t\t\t\t\t\t\t<div key={rowIndex} className=\"fb-condition-builder__and-row\">\n\t\t\t\t\t\t\t\t{rowIndex > 0 ? (\n\t\t\t\t\t\t\t\t\t<span className=\"fb-condition-builder__and-label\">{t(keys.conditionAnd)}</span>\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t<ConditionRow\n\t\t\t\t\t\t\t\t\tcondition={row}\n\t\t\t\t\t\t\t\t\toperands={operands}\n\t\t\t\t\t\t\t\t\tonChange={(next) => updateRow(groupIndex, rowIndex, next)}\n\t\t\t\t\t\t\t\t\tonRemove={() => removeRow(groupIndex, rowIndex)}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t<div className=\"fb-condition-builder__add-condition\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\tonClick={() => addCondition(groupIndex)}\n\t\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{t(keys.conditionAddCondition)}\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t))\n\t\t\t)}\n\t\t\t<div className=\"fb-condition-builder__actions\">\n\t\t\t\t<Button\n\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\tonClick={() => (groups.length === 0 ? addCondition(0) : addOrGroup())}\n\t\t\t\t\tmargin={false}\n\t\t\t\t>\n\t\t\t\t\t{groups.length === 0 ? t(keys.conditionAddCondition) : t(keys.conditionAddOr)}\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,SAAS,eAA6D;CAC3E,MAAM,QAAQ,OAAO,KAAK,UAAU,EAAE;CACtC,IAAI,CAAC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,WAAW;IAAO,CAAA,IACvE;IACH,MAAM,KAAK,KAAK,aAEhB,qBAAC,OAAD;KAAoB,WAAU;eAA9B,CACE,WAAW,IACX,oBAAC,QAAD;MAAM,WAAU;gBAAmC,EAAE,KAAK,YAAY;KAAQ,CAAA,IAC3E,MACJ,oBAAC,cAAD;MACC,WAAW;MACD;MACV,WAAW,SAAS,UAAU,YAAY,UAAU,IAAI;MACxD,gBAAgB,UAAU,YAAY,QAAQ;KAC9C,CAAA,CACG;OAVK,QAUL,CACL;IACD,oBAAC,OAAD;KAAK,WAAU;eACd,oBAAC,QAAD;MACC,aAAY;MACZ,MAAM,oBAAC,gBAAD,EAAgB,MAAM,GAAK,CAAA;MACjC,cAAa;MACb,eAAe,aAAa,UAAU;MACtC,QAAQ;gBAEP,EAAE,KAAK,qBAAqB;KACtB,CAAA;IACJ,CAAA;GACD;KA7BK,UA6BL,CACL,GAEF,oBAAC,OAAD;GAAK,WAAU;aACd,oBAAC,QAAD;IACC,aAAY;IACZ,MAAM,oBAAC,gBAAD,EAAgB,MAAM,GAAK,CAAA;IACjC,cAAa;IACb,eAAgB,OAAO,WAAW,IAAI,aAAa,CAAC,IAAI,WAAW;IACnE,QAAQ;cAEP,OAAO,WAAW,IAAI,EAAE,KAAK,qBAAqB,IAAI,EAAE,KAAK,cAAc;GACrE,CAAA;EACJ,CAAA,CACD;;AAEP"}
1
+ {"version":3,"file":"ConditionBuilder.js","names":["useTranslation"],"sources":["../../src/client/ConditionBuilder.tsx"],"sourcesContent":["'use client'\n\nimport { Button, CirclePlusIcon, useFormFields } from '@payloadcms/ui'\nimport type { Operator, Where } from 'payload'\nimport { getDataFromFormState, transformWhereQuery } from 'payload/shared'\nimport { useMemo } from 'react'\nimport { type ConditionFieldType, firstOperatorFor } from '../conditions/fieldTypes'\nimport { keys } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport { ConditionRow, type RowCondition } from './ConditionRow'\nimport { type ConditionOperand, type FieldRow, operandFromRow } from './synthesizeClientField'\nimport './admin.css'\n\nexport type ConditionBuilderProps = {\n\tvalue?: Where\n\tonChange: (next: Where) => void\n\tconditionTypes: Record<string, ConditionFieldType>\n\t/** This field's own machine name, excluded from the operand list (a field cannot condition on itself). */\n\tselfName?: string\n}\n\nconst toRow = (constraint: Record<string, unknown>): RowCondition | null => {\n\tconst field = Object.keys(constraint)[0]\n\tif (!field) {\n\t\treturn null\n\t}\n\tconst ops = constraint[field] as Record<string, unknown>\n\tconst operator = Object.keys(ops)[0] as Operator | undefined\n\tif (!operator) {\n\t\treturn null\n\t}\n\treturn { field, operator, value: ops[operator] }\n}\n\nconst fromRow = (row: RowCondition): Where => ({ [row.field]: { [row.operator]: row.value } })\n\nconst readGroups = (value: Where | undefined): RowCondition[][] => {\n\tif (!value || Object.keys(value).length === 0) {\n\t\treturn []\n\t}\n\tconst canonical = transformWhereQuery(value)\n\tconst or = Array.isArray(canonical.or) ? canonical.or : []\n\treturn or.map((group) => {\n\t\tconst and = Array.isArray((group as Where).and) ? ((group as Where).and as Where[]) : []\n\t\treturn and\n\t\t\t.map((constraint) => toRow(constraint as Record<string, unknown>))\n\t\t\t.filter((row): row is RowCondition => row !== null)\n\t})\n}\n\nconst writeGroups = (groups: RowCondition[][]): Where => ({\n\tor: groups.filter((group) => group.length > 0).map((group) => ({ and: group.map(fromRow) })),\n})\n\nconst operandsFromData = (\n\tdata: Record<string, unknown>,\n\tconditionTypes: Record<string, ConditionFieldType>,\n\tselfName: string | undefined\n): ConditionOperand[] => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as FieldRow[]) : []\n\treturn rows\n\t\t.map((row) => operandFromRow(row, conditionTypes))\n\t\t.filter((operand): operand is ConditionOperand => operand !== null && operand.name !== selfName)\n}\n\nexport const ConditionBuilder = ({\n\tvalue,\n\tonChange,\n\tconditionTypes,\n\tselfName,\n}: ConditionBuilderProps) => {\n\tconst { t } = useTranslation()\n\t// Serialize the operand list so the builder re-renders only when operands actually change (a field\n\t// added, renamed, retyped, or its options edited), not on every unrelated form-state update.\n\tconst operandsJson = useFormFields(([fields]) =>\n\t\tJSON.stringify(operandsFromData(getDataFromFormState(fields, true), conditionTypes, selfName))\n\t)\n\tconst operands = useMemo(() => JSON.parse(operandsJson) as ConditionOperand[], [operandsJson])\n\n\tconst groups = readGroups(value)\n\tconst emit = (next: RowCondition[][]) => onChange(writeGroups(next))\n\n\tconst addCondition = (groupIndex: number) => {\n\t\tconst first = operands[0]\n\t\tif (!first) {\n\t\t\treturn\n\t\t}\n\t\tconst row: RowCondition = {\n\t\t\tfield: first.name,\n\t\t\toperator: firstOperatorFor(first.conditionType),\n\t\t\tvalue: undefined,\n\t\t}\n\t\temit(\n\t\t\tgroups.length === 0\n\t\t\t\t? [[row]]\n\t\t\t\t: groups.map((group, index) => (index === groupIndex ? [...group, row] : group))\n\t\t)\n\t}\n\n\tconst addOrGroup = () => {\n\t\tconst first = operands[0]\n\t\tif (!first) {\n\t\t\treturn\n\t\t}\n\t\temit([\n\t\t\t...groups,\n\t\t\t[{ field: first.name, operator: firstOperatorFor(first.conditionType), value: undefined }],\n\t\t])\n\t}\n\n\tconst updateRow = (groupIndex: number, rowIndex: number, row: RowCondition) =>\n\t\temit(\n\t\t\tgroups.map((group, index) =>\n\t\t\t\tindex === groupIndex\n\t\t\t\t\t? group.map((existing, position) => (position === rowIndex ? row : existing))\n\t\t\t\t\t: group\n\t\t\t)\n\t\t)\n\n\tconst removeRow = (groupIndex: number, rowIndex: number) =>\n\t\temit(\n\t\t\tgroups\n\t\t\t\t.map((group, index) =>\n\t\t\t\t\tindex === groupIndex ? group.filter((_, position) => position !== rowIndex) : group\n\t\t\t\t)\n\t\t\t\t.filter((group) => group.length > 0)\n\t\t)\n\n\tif (operands.length === 0) {\n\t\treturn <p className=\"fb-condition-builder__hint\">{t(keys.conditionNoFields)}</p>\n\t}\n\n\treturn (\n\t\t<div className=\"fb-condition-builder\">\n\t\t\t{groups.length === 0 ? (\n\t\t\t\t<p className=\"fb-condition-builder__hint\">{t(keys.conditionEmpty)}</p>\n\t\t\t) : (\n\t\t\t\tgroups.map((group, groupIndex) => (\n\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: groups are positional and never reordered\n\t\t\t\t\t<div key={groupIndex} className=\"fb-condition-builder__group\">\n\t\t\t\t\t\t{groupIndex > 0 ? (\n\t\t\t\t\t\t\t<div className=\"fb-condition-builder__or-label\">{t(keys.conditionOr)}</div>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t{group.map((row, rowIndex) => (\n\t\t\t\t\t\t\t// biome-ignore lint/suspicious/noArrayIndexKey: rows are positional and never reordered\n\t\t\t\t\t\t\t<div key={rowIndex} className=\"fb-condition-builder__and-row\">\n\t\t\t\t\t\t\t\t{rowIndex > 0 ? (\n\t\t\t\t\t\t\t\t\t<span className=\"fb-condition-builder__and-label\">{t(keys.conditionAnd)}</span>\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t<ConditionRow\n\t\t\t\t\t\t\t\t\tcondition={row}\n\t\t\t\t\t\t\t\t\toperands={operands}\n\t\t\t\t\t\t\t\t\tonChange={(next) => updateRow(groupIndex, rowIndex, next)}\n\t\t\t\t\t\t\t\t\tonRemove={() => removeRow(groupIndex, rowIndex)}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t\t<div className=\"fb-condition-builder__add-condition\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\tonClick={() => addCondition(groupIndex)}\n\t\t\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{t(keys.conditionAddCondition)}\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t))\n\t\t\t)}\n\t\t\t<div className=\"fb-condition-builder__actions\">\n\t\t\t\t<Button\n\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\tonClick={() => (groups.length === 0 ? addCondition(0) : addOrGroup())}\n\t\t\t\t\tmargin={false}\n\t\t\t\t>\n\t\t\t\t\t{groups.length === 0 ? t(keys.conditionAddCondition) : t(keys.conditionAddOr)}\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,SAAS,eAA6D;CAC3E,MAAM,QAAQ,OAAO,KAAK,UAAU,EAAE;CACtC,IAAI,CAAC,OACJ,OAAO;CAER,MAAM,MAAM,WAAW;CACvB,MAAM,WAAW,OAAO,KAAK,GAAG,EAAE;CAClC,IAAI,CAAC,UACJ,OAAO;CAER,OAAO;EAAE;EAAO;EAAU,OAAO,IAAI;CAAU;AAChD;AAEA,MAAM,WAAW,SAA8B,GAAG,IAAI,QAAQ,GAAG,IAAI,WAAW,IAAI,MAAM,EAAE;AAE5F,MAAM,cAAc,UAA+C;CAClE,IAAI,CAAC,SAAS,OAAO,KAAK,KAAK,EAAE,WAAW,GAC3C,OAAO,CAAC;CAET,MAAM,YAAY,oBAAoB,KAAK;CAE3C,QADW,MAAM,QAAQ,UAAU,EAAE,IAAI,UAAU,KAAK,CAAC,GAC/C,KAAK,UAAU;EAExB,QADY,MAAM,QAAS,MAAgB,GAAG,IAAM,MAAgB,MAAkB,CAAC,GAErF,KAAK,eAAe,MAAM,UAAqC,CAAC,EAChE,QAAQ,QAA6B,QAAQ,IAAI;CACpD,CAAC;AACF;AAEA,MAAM,eAAe,YAAqC,EACzD,IAAI,OAAO,QAAQ,UAAU,MAAM,SAAS,CAAC,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,IAAI,OAAO,EAAE,EAAE,EAC5F;AAEA,M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OAAO,WAAW,IAAI,EAAE,KAAK,qBAAqB,IAAI,EAAE,KAAK,cAAc;GACrE,CAAA;EACJ,CAAA,CACD;;AAEP"}
@@ -9,7 +9,7 @@ declare const ConsentBlockLabel: ({
9
9
  typeLabelKey
10
10
  }: {
11
11
  typeLabelKey?: string;
12
- }) => import("react/jsx-runtime").JSX.Element;
12
+ }) => import("react").JSX.Element;
13
13
  //#endregion
14
14
  export { ConsentBlockLabel };
15
15
  //# sourceMappingURL=ConsentBlockLabel.d.ts.map
@@ -5,7 +5,7 @@
5
5
  * the row, so the combination only makes sense when the consent record lives elsewhere. A banner,
6
6
  * not a save error, because that external-record setup is legitimate; it just must not be silent.
7
7
  */
8
- declare const ConsentRetentionNotice: () => import("react/jsx-runtime").JSX.Element;
8
+ declare const ConsentRetentionNotice: () => import("react").JSX.Element;
9
9
  //#endregion
10
10
  export { ConsentRetentionNotice };
11
11
  //# sourceMappingURL=ConsentRetentionNotice.d.ts.map
@@ -3,7 +3,7 @@
3
3
  * Row header for a consent source array row: shows the source `name` (e.g. "Privacy Policy") instead
4
4
  * of Payload's default "Consent source NN". Falls back to the singular label + number while unnamed.
5
5
  */
6
- declare const ConsentSourceRowLabel: () => import("react/jsx-runtime").JSX.Element;
6
+ declare const ConsentSourceRowLabel: () => import("react").JSX.Element;
7
7
  //#endregion
8
8
  export { ConsentSourceRowLabel };
9
9
  //# sourceMappingURL=ConsentSourceRowLabel.d.ts.map
@@ -50,7 +50,7 @@ type EndpointOptionsSelectProps = {
50
50
  * for it yet; request scope fetches immediately, create mode included, and ignores the id
51
51
  * entirely so the first save never re-fetches.
52
52
  */
53
- declare const EndpointOptionsSelect: (props: EndpointOptionsSelectProps) => import("react/jsx-runtime").JSX.Element;
53
+ declare const EndpointOptionsSelect: (props: EndpointOptionsSelectProps) => import("react").JSX.Element;
54
54
  //#endregion
55
55
  export { EndpointOptionsSelect };
56
56
  //# sourceMappingURL=EndpointOptionsSelect.d.ts.map
@@ -12,7 +12,7 @@ type FieldBlockLabelProps = {
12
12
  */
13
13
  declare const FieldBlockLabel: ({
14
14
  typeLabelKey
15
- }: FieldBlockLabelProps) => import("react/jsx-runtime").JSX.Element;
15
+ }: FieldBlockLabelProps) => import("react").JSX.Element;
16
16
  //#endregion
17
17
  export { FieldBlockLabel };
18
18
  //# sourceMappingURL=FieldBlockLabel.d.ts.map
@@ -32,7 +32,7 @@ type FieldNameSelectProps = {
32
32
  * stored value is kept selectable even if it no longer matches any field, so switching to this
33
33
  * component never silently drops data.
34
34
  */
35
- declare const FieldNameSelect: (props: FieldNameSelectProps) => import("react/jsx-runtime").JSX.Element;
35
+ declare const FieldNameSelect: (props: FieldNameSelectProps) => import("react").JSX.Element;
36
36
  //#endregion
37
37
  export { FieldNameSelect };
38
38
  //# sourceMappingURL=FieldNameSelect.d.ts.map
@@ -2,7 +2,7 @@
2
2
  import { fieldNames, fieldNamesOfType } from "../fields/fieldNamesOfType.js";
3
3
  import { useTranslation as useTranslation$1 } from "../translations/useTranslation.js";
4
4
  import { toStaticLabel } from "./toStaticLabel.js";
5
- import { reduceFieldsToValues } from "payload/shared";
5
+ import { getDataFromFormState } from "payload/shared";
6
6
  import { FieldDescription, FieldLabel, ReactSelect, useField, useFormFields } from "@payloadcms/ui";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  import { useMemo } from "react";
@@ -32,7 +32,7 @@ const FieldNameSelect = (props) => {
32
32
  const label = toStaticLabel(props.field?.label ?? props.label);
33
33
  const { t } = useTranslation$1();
34
34
  const description = props.descriptionKey ? t(props.descriptionKey) : toStaticLabel(props.field?.admin?.description);
35
- const optionsJson = useFormFields(([fields]) => JSON.stringify(optionsFromData(reduceFieldsToValues(fields, true), props.types)));
35
+ const optionsJson = useFormFields(([fields]) => JSON.stringify(optionsFromData(getDataFromFormState(fields, true), props.types)));
36
36
  const options = useMemo(() => JSON.parse(optionsJson), [optionsJson]);
37
37
  const allOptions = value && !options.some((option) => option.value === value) ? [...options, {
38
38
  label: value,
@@ -1 +1 @@
1
- {"version":3,"file":"FieldNameSelect.js","names":["useTranslation"],"sources":["../../src/client/FieldNameSelect.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tFieldDescription,\n\tFieldLabel,\n\tReactSelect,\n\ttype ReactSelectOption,\n\tuseField,\n\tuseFormFields,\n} from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport { type CSSProperties, useMemo } from 'react'\nimport { fieldNames, fieldNamesOfType } from '../fields/fieldNamesOfType'\nimport type { TranslationKey } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport type { FieldRow } from './synthesizeClientField'\nimport { toStaticLabel } from './toStaticLabel'\n\n/** Props: standard JSON/text field client props plus the `types` allow-list we pass via clientProps. */\nexport type FieldNameSelectProps = {\n\tpath?: string\n\tfield?: {\n\t\tlabel?: unknown\n\t\tlocalized?: boolean\n\t\tadmin?: { description?: unknown; width?: string }\n\t}\n\tlabel?: unknown\n\t/**\n\t * Sibling `fields` blocks whose `blockType` is in this list populate the select's options. Omit to\n\t * offer every named field regardless of type (a general field-target picker).\n\t */\n\ttypes?: string[]\n\t/**\n\t * Field description as a translation key, resolved client-side. Payload drops `admin.description`\n\t * functions from client fields, so a translated description must travel as a key; a static\n\t * `admin.description` string still renders when this is unset.\n\t */\n\tdescriptionKey?: TranslationKey\n}\n\nconst optionsFromData = (data: Record<string, unknown>, types?: string[]): ReactSelectOption[] => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as unknown[]) : []\n\tconst labels = new Map<string, string>()\n\tfor (const row of rows) {\n\t\tif (!row || typeof row !== 'object') {\n\t\t\tcontinue\n\t\t}\n\t\tconst { name, label } = row as FieldRow\n\t\tif (typeof name === 'string' && typeof label === 'string' && label.length > 0) {\n\t\t\tlabels.set(name.trim(), label)\n\t\t}\n\t}\n\tconst names = types ? fieldNamesOfType(data.fields, types) : fieldNames(data.fields)\n\treturn names.map((name) => ({\n\t\tlabel: labels.get(name) ?? name,\n\t\tvalue: name,\n\t}))\n}\n\n/**\n * The `Field` mounted on a text config field (e.g. an action's `toField`) that should be authored\n * by picking from the form's own fields rather than free-typing a name. Options come from the\n * sibling `fields` blocks array, filtered to `types` when given (every named field otherwise); the\n * stored value is kept selectable even if it no longer matches any field, so switching to this\n * component never silently drops data.\n */\nexport const FieldNameSelect = (props: FieldNameSelectProps) => {\n\tconst { path, setValue, value } = useField<string>({ path: props.path })\n\tconst label = toStaticLabel(props.field?.label ?? props.label)\n\tconst { t } = useTranslation()\n\tconst description = props.descriptionKey\n\t\t? t(props.descriptionKey)\n\t\t: toStaticLabel(props.field?.admin?.description)\n\n\tconst optionsJson = useFormFields(([fields]) =>\n\t\tJSON.stringify(optionsFromData(reduceFieldsToValues(fields, true), props.types))\n\t)\n\tconst options = useMemo(() => JSON.parse(optionsJson) as ReactSelectOption[], [optionsJson])\n\n\tconst allOptions =\n\t\tvalue && !options.some((option) => option.value === value)\n\t\t\t? [...options, { label: value, value }]\n\t\t\t: options\n\n\tconst handleChange = (selected: ReactSelectOption | ReactSelectOption[] | null) => {\n\t\tconst chosen = Array.isArray(selected) ? selected[0] : selected\n\t\tsetValue(chosen ? (chosen.value as string) : '')\n\t}\n\n\tconst fieldStyle = props.field?.admin?.width\n\t\t? ({ '--field-width': props.field.admin.width } as CSSProperties)\n\t\t: undefined\n\n\treturn (\n\t\t<div className=\"field-type\" style={fieldStyle}>\n\t\t\t<FieldLabel label={label} localized={props.field?.localized} path={path} />\n\t\t\t<ReactSelect\n\t\t\t\toptions={allOptions}\n\t\t\t\tvalue={allOptions.find((option) => option.value === value) ?? undefined}\n\t\t\t\tisClearable\n\t\t\t\tonChange={handleChange}\n\t\t\t/>\n\t\t\t<FieldDescription description={description} path={path} />\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;AAwCA,MAAM,mBAAmB,MAA+B,UAA0C;CACjG,MAAM,OAAO,MAAM,QAAQ,KAAK,MAAM,IAAK,KAAK,SAAuB,CAAC;CACxE,MAAM,yBAAS,IAA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AC,YAAD;IAAmB;IAAO,WAAW,MAAM,OAAO;IAAiB;GAAO,CAAA;GAC1E,oBAAC,aAAD;IACC,SAAS;IACT,OAAO,WAAW,MAAM,WAAW,OAAO,UAAU,KAAK,KAAK,KAAA;IAC9D,aAAA;IACA,UAAU;GACV,CAAA;GACD,oBAAC,kBAAD;IAA+B;IAAmB;GAAO,CAAA;EACrD;;AAEP"}
1
+ {"version":3,"file":"FieldNameSelect.js","names":["useTranslation"],"sources":["../../src/client/FieldNameSelect.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tFieldDescription,\n\tFieldLabel,\n\tReactSelect,\n\ttype ReactSelectOption,\n\tuseField,\n\tuseFormFields,\n} from '@payloadcms/ui'\nimport { getDataFromFormState } from 'payload/shared'\nimport { type CSSProperties, useMemo } from 'react'\nimport { fieldNames, fieldNamesOfType } from '../fields/fieldNamesOfType'\nimport type { TranslationKey } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport type { FieldRow } from './synthesizeClientField'\nimport { toStaticLabel } from './toStaticLabel'\n\n/** Props: standard JSON/text field client props plus the `types` allow-list we pass via clientProps. */\nexport type FieldNameSelectProps = {\n\tpath?: string\n\tfield?: {\n\t\tlabel?: unknown\n\t\tlocalized?: boolean\n\t\tadmin?: { description?: unknown; width?: string }\n\t}\n\tlabel?: unknown\n\t/**\n\t * Sibling `fields` blocks whose `blockType` is in this list populate the select's options. Omit to\n\t * offer every named field regardless of type (a general field-target picker).\n\t */\n\ttypes?: string[]\n\t/**\n\t * Field description as a translation key, resolved client-side. Payload drops `admin.description`\n\t * functions from client fields, so a translated description must travel as a key; a static\n\t * `admin.description` string still renders when this is unset.\n\t */\n\tdescriptionKey?: TranslationKey\n}\n\nconst optionsFromData = (data: Record<string, unknown>, types?: string[]): ReactSelectOption[] => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as unknown[]) : []\n\tconst labels = new Map<string, string>()\n\tfor (const row of rows) {\n\t\tif (!row || typeof row !== 'object') {\n\t\t\tcontinue\n\t\t}\n\t\tconst { name, label } = row as FieldRow\n\t\tif (typeof name === 'string' && typeof label === 'string' && label.length > 0) {\n\t\t\tlabels.set(name.trim(), label)\n\t\t}\n\t}\n\tconst names = types ? fieldNamesOfType(data.fields, types) : fieldNames(data.fields)\n\treturn names.map((name) => ({\n\t\tlabel: labels.get(name) ?? name,\n\t\tvalue: name,\n\t}))\n}\n\n/**\n * The `Field` mounted on a text config field (e.g. an action's `toField`) that should be authored\n * by picking from the form's own fields rather than free-typing a name. Options come from the\n * sibling `fields` blocks array, filtered to `types` when given (every named field otherwise); the\n * stored value is kept selectable even if it no longer matches any field, so switching to this\n * component never silently drops data.\n */\nexport const FieldNameSelect = (props: FieldNameSelectProps) => {\n\tconst { path, setValue, value } = useField<string>({ path: props.path })\n\tconst label = toStaticLabel(props.field?.label ?? props.label)\n\tconst { t } = useTranslation()\n\tconst description = props.descriptionKey\n\t\t? t(props.descriptionKey)\n\t\t: toStaticLabel(props.field?.admin?.description)\n\n\tconst optionsJson = useFormFields(([fields]) =>\n\t\tJSON.stringify(optionsFromData(getDataFromFormState(fields, true), props.types))\n\t)\n\tconst options = useMemo(() => JSON.parse(optionsJson) as ReactSelectOption[], [optionsJson])\n\n\tconst allOptions =\n\t\tvalue && !options.some((option) => option.value === value)\n\t\t\t? [...options, { label: value, value }]\n\t\t\t: options\n\n\tconst handleChange = (selected: ReactSelectOption | ReactSelectOption[] | null) => {\n\t\tconst chosen = Array.isArray(selected) ? selected[0] : selected\n\t\tsetValue(chosen ? (chosen.value as string) : '')\n\t}\n\n\tconst fieldStyle = props.field?.admin?.width\n\t\t? ({ '--field-width': props.field.admin.width } as CSSProperties)\n\t\t: undefined\n\n\treturn (\n\t\t<div className=\"field-type\" style={fieldStyle}>\n\t\t\t<FieldLabel label={label} localized={props.field?.localized} path={path} />\n\t\t\t<ReactSelect\n\t\t\t\toptions={allOptions}\n\t\t\t\tvalue={allOptions.find((option) => option.value === value) ?? undefined}\n\t\t\t\tisClearable\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,MAAM,SAAS,MAAM,QAAQ,QAAQ,IAAI,SAAS,KAAK;EACvD,SAAS,SAAU,OAAO,QAAmB,EAAE;CAChD;CAMA,OACC,qBAAC,OAAD;EAAK,WAAU;EAAa,OALV,MAAM,OAAO,OAAO,QACnC,EAAE,iBAAiB,MAAM,MAAM,MAAM,MAAM,IAC5C,KAAA;YAGF;GACC,oBAAC,YAAD;IAAmB;IAAO,WAAW,MAAM,OAAO;IAAiB;GAAO,CAAA;GAC1E,oBAAC,aAAD;IACC,SAAS;IACT,OAAO,WAAW,MAAM,WAAW,OAAO,UAAU,KAAK,KAAK,KAAA;IAC9D,aAAA;IACA,UAAU;GACV,CAAA;GACD,oBAAC,kBAAD;IAA+B;IAAmB;GAAO,CAAA;EACrD;;AAEP"}
@@ -9,7 +9,7 @@ type FlowBuilderProps = {
9
9
  conditionTypes: Record<string, ConditionFieldType>; /** Bare (nameless) block slugs to their display label: an i18n key or a literal. */
10
10
  bareTypeLabels?: Record<string, string>;
11
11
  };
12
- declare const FlowBuilder: (props: FlowBuilderProps) => import("react/jsx-runtime").JSX.Element;
12
+ declare const FlowBuilder: (props: FlowBuilderProps) => import("react").JSX.Element;
13
13
  //#endregion
14
14
  export { FlowBuilder };
15
15
  //# sourceMappingURL=FlowBuilder.d.ts.map
@@ -6,7 +6,7 @@ import { toStaticLabel } from "./toStaticLabel.js";
6
6
  import { ConditionBuilder } from "./ConditionBuilder.js";
7
7
  import { stepLabel } from "../flow/stepLabel.js";
8
8
  import { assignFieldToStep, fieldHolders, flowFieldEntries, nextFromSelectValue, nextSelectOptions, nextToSelectValue, otherStepSelectOptions, removeFieldFromStep, removeStepCascade, stepSelectOptions, unassignedEntries } from "./flowAuthoring.js";
9
- import { reduceFieldsToValues } from "payload/shared";
9
+ import { getDataFromFormState } from "payload/shared";
10
10
  import { Button, CheckboxInput, ChevronIcon, CirclePlusIcon, Collapsible, FieldLabel, LineIcon, MoreIcon, Popup, PopupList, ReactSelect, TextInput, useField, useFormFields } from "@payloadcms/ui";
11
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
12
  import { useMemo, useRef, useState } from "react";
@@ -303,7 +303,7 @@ const FlowBuilder = (props) => {
303
303
  const { t } = useTranslation$1();
304
304
  const label = toStaticLabel(props.field?.label ?? props.label);
305
305
  const [expandedKeys, setExpandedKeys] = useState(/* @__PURE__ */ new Set());
306
- const fieldRowsJson = useFormFields(([fields]) => JSON.stringify(extractFieldRows(reduceFieldsToValues(fields, true))));
306
+ const fieldRowsJson = useFormFields(([fields]) => JSON.stringify(extractFieldRows(getDataFromFormState(fields, true))));
307
307
  const translatedBareLabels = useMemo(() => Object.fromEntries(Object.entries(props.bareTypeLabels ?? {}).map(([type, label]) => [type, t(label)])), [props.bareTypeLabels, t]);
308
308
  const entries = useMemo(() => flowFieldEntries(JSON.parse(fieldRowsJson), translatedBareLabels), [fieldRowsJson, translatedBareLabels]);
309
309
  const steps = value?.steps ?? [];
@@ -1 +1 @@
1
- {"version":3,"file":"FlowBuilder.js","names":["useTranslation"],"sources":["../../src/client/FlowBuilder.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tButton,\n\tCheckboxInput,\n\tChevronIcon,\n\tCirclePlusIcon,\n\tCollapsible,\n\tFieldLabel,\n\tLineIcon,\n\tMoreIcon,\n\tPopup,\n\tPopupList,\n\tReactSelect,\n\ttype ReactSelectOption,\n\tTextInput,\n\tuseField,\n\tuseFormFields,\n} from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport type { ChangeEvent } from 'react'\nimport { useMemo, useRef, useState } from 'react'\nimport type { ConditionFieldType } from '../conditions/fieldTypes'\nimport type { FlowStep, FlowTransition, FormFlow } from '../flow/types'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport { resolveMessage } from '../validation/message'\nimport { ConditionBuilder } from './ConditionBuilder'\nimport {\n\tassignFieldToStep,\n\ttype FlowFieldEntry,\n\ttype FlowSelectOption,\n\tfieldHolders,\n\tflowFieldEntries,\n\tnextFromSelectValue,\n\tnextSelectOptions,\n\tnextToSelectValue,\n\totherStepSelectOptions,\n\tremoveFieldFromStep,\n\tremoveStepCascade,\n\tstepLabel,\n\tstepSelectOptions,\n\tunassignedEntries,\n} from './flowAuthoring'\nimport type { FieldRow } from './synthesizeClientField'\nimport { toStaticLabel } from './toStaticLabel'\nimport './admin.css'\n\nexport type FlowBuilderProps = {\n\tpath?: string\n\tfield?: { label?: unknown }\n\tlabel?: unknown\n\tconditionTypes: Record<string, ConditionFieldType>\n\t/** Bare (nameless) block slugs to their display label: an i18n key or a literal. */\n\tbareTypeLabels?: Record<string, string>\n}\n\n/** The row facets the flow builder keys and labels by, projected for a stable JSON identity. */\nconst extractFieldRows = (data: Record<string, unknown>): FieldRow[] => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as FieldRow[]) : []\n\treturn rows.map((row) => ({\n\t\tblockType: row.blockType,\n\t\tname: row.name,\n\t\tid: row.id,\n\t\tlabel: row.label,\n\t\tcontent: row.content,\n\t}))\n}\n\ntype TransitionRowProps = {\n\ttransition: FlowTransition\n\tstepOptions: FlowSelectOption[]\n\tconditionTypes: Record<string, ConditionFieldType>\n\tisFirst: boolean\n\tisLast: boolean\n\tonChange: (next: FlowTransition) => void\n\tonRemove: () => void\n\tonMoveUp: () => void\n\tonMoveDown: () => void\n}\n\nconst TransitionRow = ({\n\ttransition,\n\tstepOptions,\n\tconditionTypes,\n\tisFirst,\n\tisLast,\n\tonChange,\n\tonRemove,\n\tonMoveUp,\n\tonMoveDown,\n}: TransitionRowProps) => {\n\tconst { t } = useTranslation()\n\n\tconst handleGotoChange = (selected: ReactSelectOption | ReactSelectOption[]) => {\n\t\tconst chosen = Array.isArray(selected) ? selected[0] : selected\n\t\tif (chosen) onChange({ ...transition, to: chosen.value as string })\n\t}\n\n\treturn (\n\t\t<div className=\"fb-flow-transition\">\n\t\t\t<div className=\"fb-flow-transition__header\">\n\t\t\t\t<span className=\"fb-flow-transition__label\">{t(keys.flowGoTo)}</span>\n\t\t\t\t<div className=\"fb-flow-transition__goto\">\n\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\toptions={stepOptions}\n\t\t\t\t\t\tvalue={stepOptions.find((o) => o.value === transition.to) ?? undefined}\n\t\t\t\t\t\tplaceholder={t(keys.flowSelectStepPlaceholder)}\n\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\tonChange={handleGotoChange}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"fb-flow-transition__actions\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\ticon={<ChevronIcon direction=\"up\" size={24} />}\n\t\t\t\t\t\tonClick={onMoveUp}\n\t\t\t\t\t\tdisabled={isFirst}\n\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\taria-label={t(keys.flowMoveTransitionUp)}\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\ticon={<ChevronIcon direction=\"down\" size={24} />}\n\t\t\t\t\t\tonClick={onMoveDown}\n\t\t\t\t\t\tdisabled={isLast}\n\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\taria-label={t(keys.flowMoveTransitionDown)}\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\ticon={<LineIcon size={24} />}\n\t\t\t\t\t\tonClick={onRemove}\n\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\taria-label={t(keys.flowRemoveTransition)}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<span className=\"fb-flow-transition__when-label\">{t(keys.flowWhen)}</span>\n\t\t\t<div className=\"fb-flow-transition__condition\">\n\t\t\t\t<ConditionBuilder\n\t\t\t\t\tvalue={transition.when}\n\t\t\t\t\tonChange={(when) => onChange({ ...transition, when })}\n\t\t\t\t\tconditionTypes={conditionTypes}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\ntype StepCardProps = {\n\tstep: FlowStep\n\tstepKey: string\n\tstepIndex: number\n\tstepCount: number\n\totherStepOptions: FlowSelectOption[]\n\tholders: Map<string, number>\n\tstepLabels: string[]\n\tentries: FlowFieldEntry[]\n\tconditionTypes: Record<string, ConditionFieldType>\n\tisExpanded: boolean\n\tonToggle: () => void\n\tonChange: (next: FlowStep) => void\n\tonToggleField: (key: string, checked: boolean) => void\n\tonRemove: () => void\n\tonMoveUp: () => void\n\tonMoveDown: () => void\n\tonAddAbove: () => void\n\tonAddBelow: () => void\n}\n\nconst StepCard = ({\n\tstep,\n\tstepKey,\n\tstepIndex,\n\tstepCount,\n\totherStepOptions,\n\tholders,\n\tstepLabels,\n\tentries,\n\tconditionTypes,\n\tisExpanded,\n\tonToggle,\n\tonChange,\n\tonToggleField,\n\tonRemove,\n\tonMoveUp,\n\tonMoveDown,\n\tonAddAbove,\n\tonAddBelow,\n}: StepCardProps) => {\n\tconst { t } = useTranslation()\n\n\tconst nextOptions = nextSelectOptions({\n\t\tsequentialLabel: t(keys.flowNextSequential),\n\t\tterminalLabel: t(keys.flowNextTerminal),\n\t\totherSteps: otherStepOptions,\n\t})\n\n\tconst transitions = step.transitions ?? []\n\n\t// Stable per-transition keys, mirroring the step-level scheme so transition reorder/remove\n\t// reconciles by identity rather than array position.\n\tconst tKeysRef = useRef<string[]>([])\n\tif (tKeysRef.current.length !== transitions.length) {\n\t\ttKeysRef.current = transitions.map((_, i) => tKeysRef.current[i] ?? crypto.randomUUID())\n\t}\n\tconst tKeys = tKeysRef.current\n\n\tconst addTransition = () => {\n\t\tconst firstOtherStep = otherStepOptions[0]?.value\n\t\tif (firstOtherStep === undefined) return\n\t\ttKeysRef.current = [...tKeys, crypto.randomUUID()]\n\t\tonChange({\n\t\t\t...step,\n\t\t\ttransitions: [...transitions, { when: {}, to: firstOtherStep }],\n\t\t})\n\t}\n\n\tconst updateTransition = (index: number, next: FlowTransition) => {\n\t\tconst updated = [...transitions]\n\t\tupdated[index] = next\n\t\tonChange({ ...step, transitions: updated })\n\t}\n\n\tconst removeTransition = (index: number) => {\n\t\ttKeysRef.current = tKeys.filter((_, i) => i !== index)\n\t\tconst updated = transitions.filter((_, i) => i !== index)\n\t\tonChange({ ...step, transitions: updated.length > 0 ? updated : undefined })\n\t}\n\n\tconst moveTransition = (from: number, to: number) => {\n\t\tconst updated = [...transitions]\n\t\tconst [item] = updated.splice(from, 1)\n\t\tif (item !== undefined) updated.splice(to, 0, item)\n\t\tconst nextKeys = [...tKeys]\n\t\tconst [movedKey] = nextKeys.splice(from, 1)\n\t\tif (movedKey !== undefined) nextKeys.splice(to, 0, movedKey)\n\t\ttKeysRef.current = nextKeys\n\t\tonChange({ ...step, transitions: updated })\n\t}\n\n\tconst handleNextChange = (selected: ReactSelectOption | ReactSelectOption[]) => {\n\t\tconst chosen = Array.isArray(selected) ? selected[0] : selected\n\t\tif (chosen) onChange({ ...step, next: nextFromSelectValue(chosen.value as string) })\n\t}\n\n\tconst title = step.title?.trim() ?? ''\n\n\tconst stepHeader = (\n\t\t<div className=\"fb-flow-step__header-content\">\n\t\t\t<span className=\"fb-flow-step__index\">\n\t\t\t\t{resolveMessage(t(keys.flowStepFallbackTitle), { n: stepIndex + 1 })}\n\t\t\t</span>\n\t\t\t{title.length > 0 ? <span className=\"fb-flow-step__title\">{title}</span> : null}\n\t\t</div>\n\t)\n\n\treturn (\n\t\t<Collapsible\n\t\t\theader={stepHeader}\n\t\t\tactions={\n\t\t\t\t<Popup\n\t\t\t\t\tbutton={<MoreIcon />}\n\t\t\t\t\tbuttonType=\"default\"\n\t\t\t\t\thorizontalAlign=\"right\"\n\t\t\t\t\tsize=\"fit-content\"\n\t\t\t\t\tverticalAlign=\"bottom\"\n\t\t\t\t>\n\t\t\t\t\t<PopupList.ButtonGroup>\n\t\t\t\t\t\t<PopupList.Button onClick={onAddAbove}>{t(keys.flowAddAbove)}</PopupList.Button>\n\t\t\t\t\t\t<PopupList.Button onClick={onAddBelow}>{t(keys.flowAddBelow)}</PopupList.Button>\n\t\t\t\t\t\t<PopupList.Button onClick={onMoveUp} disabled={stepIndex === 0}>\n\t\t\t\t\t\t\tMove up\n\t\t\t\t\t\t</PopupList.Button>\n\t\t\t\t\t\t<PopupList.Button onClick={onMoveDown} disabled={stepIndex === stepCount - 1}>\n\t\t\t\t\t\t\tMove down\n\t\t\t\t\t\t</PopupList.Button>\n\t\t\t\t\t\t<PopupList.Button onClick={onRemove}>Remove</PopupList.Button>\n\t\t\t\t\t</PopupList.ButtonGroup>\n\t\t\t\t</Popup>\n\t\t\t}\n\t\t\tisCollapsed={!isExpanded}\n\t\t\tonToggle={() => onToggle()}\n\t\t\tclassName=\"fb-flow-step\"\n\t\t>\n\t\t\t<div className=\"fb-flow-step__body\">\n\t\t\t\t<TextInput\n\t\t\t\t\tpath={`fb-flow-step-${stepKey}-title`}\n\t\t\t\t\tlabel={t(keys.flowStepTitleLabel)}\n\t\t\t\t\tvalue={step.title ?? ''}\n\t\t\t\t\tonChange={(e: ChangeEvent<HTMLInputElement>) =>\n\t\t\t\t\t\tonChange({ ...step, title: e.target.value.length > 0 ? e.target.value : undefined })\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<div className=\"fb-flow-step__row\">\n\t\t\t\t\t<FieldLabel label={t(keys.flowFields)} />\n\t\t\t\t\t{entries.length === 0 ? (\n\t\t\t\t\t\t<p className=\"fb-flow-step__hint\">{t(keys.flowNoFields)}</p>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<div className=\"fb-flow-step__field-picker\">\n\t\t\t\t\t\t\t{entries.map((entry) => {\n\t\t\t\t\t\t\t\tconst holder = holders.get(entry.key)\n\t\t\t\t\t\t\t\tconst inOtherStep = holder !== undefined && holder !== stepIndex\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<div key={entry.key} className=\"fb-flow-step__field-option\">\n\t\t\t\t\t\t\t\t\t\t<CheckboxInput\n\t\t\t\t\t\t\t\t\t\t\tlabel={entry.label}\n\t\t\t\t\t\t\t\t\t\t\tchecked={step.fields.includes(entry.key) || inOtherStep}\n\t\t\t\t\t\t\t\t\t\t\treadOnly={inOtherStep}\n\t\t\t\t\t\t\t\t\t\t\tonToggle={(e) => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (inOtherStep) return\n\t\t\t\t\t\t\t\t\t\t\t\tonToggleField(entry.key, e.target.checked)\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t{inOtherStep ? (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fb-flow-step__field-hint\">\n\t\t\t\t\t\t\t\t\t\t\t\t{resolveMessage(t(keys.flowFieldInStep), {\n\t\t\t\t\t\t\t\t\t\t\t\t\tstep: stepLabels[holder] ?? '',\n\t\t\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\n\t\t\t\t<div className=\"fb-flow-step__row\">\n\t\t\t\t\t<FieldLabel label={t(keys.flowDefaultNext)} />\n\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\toptions={nextOptions}\n\t\t\t\t\t\tvalue={nextOptions.find((o) => o.value === nextToSelectValue(step.next)) ?? undefined}\n\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\tonChange={handleNextChange}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t\t<div className=\"fb-flow-step__transitions\">\n\t\t\t\t\t<div className=\"fb-flow-step__transitions-header\">\n\t\t\t\t\t\t<FieldLabel label={t(keys.flowConditionalTransitions)} />\n\t\t\t\t\t\t<span className=\"fb-flow-step__hint\">{t(keys.flowFirstMatchWins)}</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t{transitions.map((transition, tIndex) => {\n\t\t\t\t\t\tconst tKey = tKeys[tIndex]\n\t\t\t\t\t\tif (tKey === undefined) return null\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TransitionRow\n\t\t\t\t\t\t\t\tkey={tKey}\n\t\t\t\t\t\t\t\ttransition={transition}\n\t\t\t\t\t\t\t\tstepOptions={otherStepOptions}\n\t\t\t\t\t\t\t\tconditionTypes={conditionTypes}\n\t\t\t\t\t\t\t\tisFirst={tIndex === 0}\n\t\t\t\t\t\t\t\tisLast={tIndex === transitions.length - 1}\n\t\t\t\t\t\t\t\tonChange={(next) => updateTransition(tIndex, next)}\n\t\t\t\t\t\t\t\tonRemove={() => removeTransition(tIndex)}\n\t\t\t\t\t\t\t\tonMoveUp={() => moveTransition(tIndex, tIndex - 1)}\n\t\t\t\t\t\t\t\tonMoveDown={() => moveTransition(tIndex, tIndex + 1)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t\t<Button\n\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\tonClick={addTransition}\n\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t>\n\t\t\t\t\t\t{t(keys.flowAddTransition)}\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Collapsible>\n\t)\n}\n\nexport const FlowBuilder = (props: FlowBuilderProps) => {\n\tconst { setValue, value } = useField<FormFlow | undefined>()\n\tconst { t } = useTranslation()\n\tconst label = toStaticLabel(props.field?.label ?? props.label)\n\tconst [expandedKeys, setExpandedKeys] = useState<Set<string>>(new Set())\n\n\tconst fieldRowsJson = useFormFields(([fields]) =>\n\t\tJSON.stringify(extractFieldRows(reduceFieldsToValues(fields, true) as Record<string, unknown>))\n\t)\n\t// Registry labels may be host-registered keys or literals; Payload's `t` returns unknown keys unchanged.\n\tconst translatedBareLabels = useMemo(\n\t\t() =>\n\t\t\tObject.fromEntries(\n\t\t\t\tObject.entries(props.bareTypeLabels ?? {}).map(([type, label]) => [\n\t\t\t\t\ttype,\n\t\t\t\t\tt(label as TranslationKey),\n\t\t\t\t])\n\t\t\t),\n\t\t[props.bareTypeLabels, t]\n\t)\n\tconst entries = useMemo(\n\t\t() => flowFieldEntries(JSON.parse(fieldRowsJson) as FieldRow[], translatedBareLabels),\n\t\t[fieldRowsJson, translatedBareLabels]\n\t)\n\n\tconst steps = value?.steps ?? []\n\tconst fallbackTitle = t(keys.flowStepFallbackTitle)\n\tconst stepLabels = steps.map((step, index) => stepLabel(step, index, fallbackTitle))\n\tconst stepOptions = stepSelectOptions(steps, stepLabels)\n\tconst holders = fieldHolders(steps)\n\tconst unassigned = unassignedEntries(entries, steps)\n\n\t// Stable per-step React keys, independent of step ids. Reorder/insert/remove reconcile by\n\t// identity so focused inputs and each step's expand state stay with their step instead of\n\t// jumping to whichever step now sits at that array position.\n\tconst keysRef = useRef<string[]>([])\n\tif (keysRef.current.length !== steps.length) {\n\t\tkeysRef.current = steps.map((_, i) => keysRef.current[i] ?? crypto.randomUUID())\n\t}\n\tconst stepKeys = keysRef.current\n\n\tconst toggleExpanded = (key: string) => {\n\t\tsetExpandedKeys((prev) => {\n\t\t\tconst next = new Set(prev)\n\t\t\tif (next.has(key)) next.delete(key)\n\t\t\telse next.add(key)\n\t\t\treturn next\n\t\t})\n\t}\n\n\tconst emit = (nextSteps: FlowStep[], nextKeys: string[]) => {\n\t\tkeysRef.current = nextKeys\n\t\tsetValue({ steps: nextSteps } as FormFlow)\n\t}\n\n\tconst insertStep = (at: number) => {\n\t\tconst key = crypto.randomUUID()\n\t\tconst nextSteps = [...steps]\n\t\tnextSteps.splice(at, 0, { id: crypto.randomUUID(), fields: [] })\n\t\tconst nextKeys = [...stepKeys]\n\t\tnextKeys.splice(at, 0, key)\n\t\temit(nextSteps, nextKeys)\n\t\tsetExpandedKeys((prev) => new Set(prev).add(key))\n\t}\n\n\tconst addStep = () => insertStep(steps.length)\n\n\tconst updateStep = (index: number, next: FlowStep) => {\n\t\temit(\n\t\t\tsteps.map((s, i) => (i === index ? next : s)),\n\t\t\tstepKeys\n\t\t)\n\t}\n\n\tconst toggleField = (stepIndex: number, key: string, checked: boolean) => {\n\t\tconst nextSteps = checked\n\t\t\t? assignFieldToStep(steps, stepIndex, key)\n\t\t\t: removeFieldFromStep(steps, stepIndex, key)\n\t\temit(nextSteps, stepKeys)\n\t}\n\n\tconst assignUnassignedField = (key: string, stepId: string) => {\n\t\tconst targetIndex = steps.findIndex((s) => s.id === stepId)\n\t\tif (targetIndex === -1) return\n\t\temit(assignFieldToStep(steps, targetIndex, key), stepKeys)\n\t}\n\n\tconst removeStep = (index: number) => {\n\t\tconst removedKey = stepKeys[index]\n\t\temit(\n\t\t\tremoveStepCascade(steps, index),\n\t\t\tstepKeys.filter((_, i) => i !== index)\n\t\t)\n\t\tif (removedKey !== undefined) {\n\t\t\tsetExpandedKeys((prev) => {\n\t\t\t\tconst next = new Set(prev)\n\t\t\t\tnext.delete(removedKey)\n\t\t\t\treturn next\n\t\t\t})\n\t\t}\n\t}\n\n\tconst moveStep = (from: number, to: number) => {\n\t\tconst nextSteps = [...steps]\n\t\tconst [movedStep] = nextSteps.splice(from, 1)\n\t\tif (movedStep === undefined) return\n\t\tnextSteps.splice(to, 0, movedStep)\n\t\tconst nextKeys = [...stepKeys]\n\t\tconst [movedKey] = nextKeys.splice(from, 1)\n\t\tif (movedKey !== undefined) nextKeys.splice(to, 0, movedKey)\n\t\temit(nextSteps, nextKeys)\n\t}\n\n\treturn (\n\t\t<div className=\"field-type fb-flow-builder\">\n\t\t\t<header className=\"blocks-field__header\">\n\t\t\t\t<div className=\"blocks-field__header-wrap\">\n\t\t\t\t\t<div className=\"blocks-field__header-content\">\n\t\t\t\t\t\t<h3 className=\"blocks-field__title\">\n\t\t\t\t\t\t\t{typeof label === 'string' ? label : t(keys.flowFallbackTitle)}\n\t\t\t\t\t\t</h3>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</header>\n\t\t\t<p className=\"fb-flow-builder__description\">{t(keys.flowDescription)}</p>\n\t\t\t{steps.length === 0 ? (\n\t\t\t\t<p className=\"fb-flow-builder__hint\">{t(keys.flowNoSteps)}</p>\n\t\t\t) : (\n\t\t\t\t<div className=\"fb-flow-builder__steps\">\n\t\t\t\t\t{steps.map((step, index) => {\n\t\t\t\t\t\tconst key = stepKeys[index]\n\t\t\t\t\t\tif (key === undefined) return null\n\t\t\t\t\t\tconst otherStepOptions = otherStepSelectOptions(stepOptions, step.id)\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<StepCard\n\t\t\t\t\t\t\t\tkey={key}\n\t\t\t\t\t\t\t\tstepKey={key}\n\t\t\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\t\t\tstepIndex={index}\n\t\t\t\t\t\t\t\tstepCount={steps.length}\n\t\t\t\t\t\t\t\totherStepOptions={otherStepOptions}\n\t\t\t\t\t\t\t\tholders={holders}\n\t\t\t\t\t\t\t\tstepLabels={stepLabels}\n\t\t\t\t\t\t\t\tentries={entries}\n\t\t\t\t\t\t\t\tconditionTypes={props.conditionTypes}\n\t\t\t\t\t\t\t\tisExpanded={expandedKeys.has(key)}\n\t\t\t\t\t\t\t\tonToggle={() => toggleExpanded(key)}\n\t\t\t\t\t\t\t\tonChange={(next) => updateStep(index, next)}\n\t\t\t\t\t\t\t\tonToggleField={(fieldKey, checked) => toggleField(index, fieldKey, checked)}\n\t\t\t\t\t\t\t\tonRemove={() => removeStep(index)}\n\t\t\t\t\t\t\t\tonMoveUp={() => moveStep(index, index - 1)}\n\t\t\t\t\t\t\t\tonMoveDown={() => moveStep(index, index + 1)}\n\t\t\t\t\t\t\t\tonAddAbove={() => insertStep(index)}\n\t\t\t\t\t\t\t\tonAddBelow={() => insertStep(index + 1)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t\t{steps.length > 0 && unassigned.length > 0 ? (\n\t\t\t\t<div className=\"fb-flow-unassigned\">\n\t\t\t\t\t<FieldLabel label={t(keys.flowUnassigned)} />\n\t\t\t\t\t<div className=\"fb-flow-unassigned__rows\">\n\t\t\t\t\t\t{unassigned.map((entry) => (\n\t\t\t\t\t\t\t<div key={entry.key} className=\"fb-flow-unassigned__row\">\n\t\t\t\t\t\t\t\t<span className=\"fb-flow-unassigned__name\">{entry.label}</span>\n\t\t\t\t\t\t\t\t<div className=\"fb-flow-unassigned__select\">\n\t\t\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\t\t\toptions={stepOptions}\n\t\t\t\t\t\t\t\t\t\tplaceholder={t(keys.flowAssignToStep)}\n\t\t\t\t\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\t\t\t\t\tonChange={(selected: ReactSelectOption | ReactSelectOption[]) => {\n\t\t\t\t\t\t\t\t\t\t\tconst chosen = Array.isArray(selected) ? selected[0] : selected\n\t\t\t\t\t\t\t\t\t\t\tif (chosen) assignUnassignedField(entry.key, chosen.value as string)\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t\t<div className=\"fb-flow-builder__actions\">\n\t\t\t\t<Button\n\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\tonClick={addStep}\n\t\t\t\t\tmargin={false}\n\t\t\t\t>\n\t\t\t\t\tAdd step\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t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AY,YAAY,OAAO,UAAU,OAAO;MAC1E,gBAAgB,WAAW,KAAK;MAChC,gBAAgB,SAAS,OAAO,QAAQ,CAAC;MACzC,kBAAkB,SAAS,OAAO,QAAQ,CAAC;MAC3C,kBAAkB,WAAW,KAAK;MAClC,kBAAkB,WAAW,QAAQ,CAAC;KACtC,GAnBK,GAmBL;IAEH,CAAC;GACG,CAAA;GAEL,MAAM,SAAS,KAAK,WAAW,SAAS,IACxC,qBAAC,OAAD;IAAK,WAAU;cAAf,CACC,oBAAC,YAAD,EAAY,OAAO,EAAE,KAAK,cAAc,EAAI,CAAA,GAC5C,oBAAC,OAAD;KAAK,WAAU;eACb,WAAW,KAAK,UAChB,qBAAC,OAAD;MAAqB,WAAU;gBAA/B,CACC,oBAAC,QAAD;OAAM,WAAU;iBAA4B,MAAM;MAAY,CAAA,GAC9D,oBAAC,OAAD;OAAK,WAAU;iBACd,oBAAC,aAAD;QACC,SAAS;QACT,aAAa,EAAE,KAAK,gBAAgB;QACpC,aAAa;QACb,WAAW,aAAsD;SAChE,MAAM,SAAS,MAAM,QAAQ,QAAQ,IAAI,SAAS,KAAK;SACvD,IAAI,QAAQ,sBAAsB,MAAM,KAAK,OAAO,KAAe;QACpE;OACA,CAAA;MACG,CAAA,CACD;QAbK,MAAM,GAaX,CACL;IACG,CAAA,CACD;QACF;GACJ,oBAAC,OAAD;IAAK,WAAU;cACd,oBAAC,QAAD;KACC,aAAY;KACZ,MAAM,oBAAC,gBAAD,EAAgB,MAAM,GAAK,CAAA;KACjC,cAAa;KACb,SAAS;KACT,QAAQ;eACR;IAEO,CAAA;GACJ,CAAA;EACD;;AAEP"}
1
+ {"version":3,"file":"FlowBuilder.js","names":["useTranslation"],"sources":["../../src/client/FlowBuilder.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tButton,\n\tCheckboxInput,\n\tChevronIcon,\n\tCirclePlusIcon,\n\tCollapsible,\n\tFieldLabel,\n\tLineIcon,\n\tMoreIcon,\n\tPopup,\n\tPopupList,\n\tReactSelect,\n\ttype ReactSelectOption,\n\tTextInput,\n\tuseField,\n\tuseFormFields,\n} from '@payloadcms/ui'\nimport { getDataFromFormState } from 'payload/shared'\nimport type { ChangeEvent } from 'react'\nimport { useMemo, useRef, useState } from 'react'\nimport type { ConditionFieldType } from '../conditions/fieldTypes'\nimport type { FlowStep, FlowTransition, FormFlow } from '../flow/types'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport { resolveMessage } from '../validation/message'\nimport { ConditionBuilder } from './ConditionBuilder'\nimport {\n\tassignFieldToStep,\n\ttype FlowFieldEntry,\n\ttype FlowSelectOption,\n\tfieldHolders,\n\tflowFieldEntries,\n\tnextFromSelectValue,\n\tnextSelectOptions,\n\tnextToSelectValue,\n\totherStepSelectOptions,\n\tremoveFieldFromStep,\n\tremoveStepCascade,\n\tstepLabel,\n\tstepSelectOptions,\n\tunassignedEntries,\n} from './flowAuthoring'\nimport type { FieldRow } from './synthesizeClientField'\nimport { toStaticLabel } from './toStaticLabel'\nimport './admin.css'\n\nexport type FlowBuilderProps = {\n\tpath?: string\n\tfield?: { label?: unknown }\n\tlabel?: unknown\n\tconditionTypes: Record<string, ConditionFieldType>\n\t/** Bare (nameless) block slugs to their display label: an i18n key or a literal. */\n\tbareTypeLabels?: Record<string, string>\n}\n\n/** The row facets the flow builder keys and labels by, projected for a stable JSON identity. */\nconst extractFieldRows = (data: Record<string, unknown>): FieldRow[] => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as FieldRow[]) : []\n\treturn rows.map((row) => ({\n\t\tblockType: row.blockType,\n\t\tname: row.name,\n\t\tid: row.id,\n\t\tlabel: row.label,\n\t\tcontent: row.content,\n\t}))\n}\n\ntype TransitionRowProps = {\n\ttransition: FlowTransition\n\tstepOptions: FlowSelectOption[]\n\tconditionTypes: Record<string, ConditionFieldType>\n\tisFirst: boolean\n\tisLast: boolean\n\tonChange: (next: FlowTransition) => void\n\tonRemove: () => void\n\tonMoveUp: () => void\n\tonMoveDown: () => void\n}\n\nconst TransitionRow = ({\n\ttransition,\n\tstepOptions,\n\tconditionTypes,\n\tisFirst,\n\tisLast,\n\tonChange,\n\tonRemove,\n\tonMoveUp,\n\tonMoveDown,\n}: TransitionRowProps) => {\n\tconst { t } = useTranslation()\n\n\tconst handleGotoChange = (selected: ReactSelectOption | ReactSelectOption[]) => {\n\t\tconst chosen = Array.isArray(selected) ? selected[0] : selected\n\t\tif (chosen) onChange({ ...transition, to: chosen.value as string })\n\t}\n\n\treturn (\n\t\t<div className=\"fb-flow-transition\">\n\t\t\t<div className=\"fb-flow-transition__header\">\n\t\t\t\t<span className=\"fb-flow-transition__label\">{t(keys.flowGoTo)}</span>\n\t\t\t\t<div className=\"fb-flow-transition__goto\">\n\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\toptions={stepOptions}\n\t\t\t\t\t\tvalue={stepOptions.find((o) => o.value === transition.to) ?? undefined}\n\t\t\t\t\t\tplaceholder={t(keys.flowSelectStepPlaceholder)}\n\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\tonChange={handleGotoChange}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"fb-flow-transition__actions\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\ticon={<ChevronIcon direction=\"up\" size={24} />}\n\t\t\t\t\t\tonClick={onMoveUp}\n\t\t\t\t\t\tdisabled={isFirst}\n\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\taria-label={t(keys.flowMoveTransitionUp)}\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\ticon={<ChevronIcon direction=\"down\" size={24} />}\n\t\t\t\t\t\tonClick={onMoveDown}\n\t\t\t\t\t\tdisabled={isLast}\n\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\taria-label={t(keys.flowMoveTransitionDown)}\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\ticon={<LineIcon size={24} />}\n\t\t\t\t\t\tonClick={onRemove}\n\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t\taria-label={t(keys.flowRemoveTransition)}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<span className=\"fb-flow-transition__when-label\">{t(keys.flowWhen)}</span>\n\t\t\t<div className=\"fb-flow-transition__condition\">\n\t\t\t\t<ConditionBuilder\n\t\t\t\t\tvalue={transition.when}\n\t\t\t\t\tonChange={(when) => onChange({ ...transition, when })}\n\t\t\t\t\tconditionTypes={conditionTypes}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\ntype StepCardProps = {\n\tstep: FlowStep\n\tstepKey: string\n\tstepIndex: number\n\tstepCount: number\n\totherStepOptions: FlowSelectOption[]\n\tholders: Map<string, number>\n\tstepLabels: string[]\n\tentries: FlowFieldEntry[]\n\tconditionTypes: Record<string, ConditionFieldType>\n\tisExpanded: boolean\n\tonToggle: () => void\n\tonChange: (next: FlowStep) => void\n\tonToggleField: (key: string, checked: boolean) => void\n\tonRemove: () => void\n\tonMoveUp: () => void\n\tonMoveDown: () => void\n\tonAddAbove: () => void\n\tonAddBelow: () => void\n}\n\nconst StepCard = ({\n\tstep,\n\tstepKey,\n\tstepIndex,\n\tstepCount,\n\totherStepOptions,\n\tholders,\n\tstepLabels,\n\tentries,\n\tconditionTypes,\n\tisExpanded,\n\tonToggle,\n\tonChange,\n\tonToggleField,\n\tonRemove,\n\tonMoveUp,\n\tonMoveDown,\n\tonAddAbove,\n\tonAddBelow,\n}: StepCardProps) => {\n\tconst { t } = useTranslation()\n\n\tconst nextOptions = nextSelectOptions({\n\t\tsequentialLabel: t(keys.flowNextSequential),\n\t\tterminalLabel: t(keys.flowNextTerminal),\n\t\totherSteps: otherStepOptions,\n\t})\n\n\tconst transitions = step.transitions ?? []\n\n\t// Stable per-transition keys, mirroring the step-level scheme so transition reorder/remove\n\t// reconciles by identity rather than array position.\n\tconst tKeysRef = useRef<string[]>([])\n\tif (tKeysRef.current.length !== transitions.length) {\n\t\ttKeysRef.current = transitions.map((_, i) => tKeysRef.current[i] ?? crypto.randomUUID())\n\t}\n\tconst tKeys = tKeysRef.current\n\n\tconst addTransition = () => {\n\t\tconst firstOtherStep = otherStepOptions[0]?.value\n\t\tif (firstOtherStep === undefined) return\n\t\ttKeysRef.current = [...tKeys, crypto.randomUUID()]\n\t\tonChange({\n\t\t\t...step,\n\t\t\ttransitions: [...transitions, { when: {}, to: firstOtherStep }],\n\t\t})\n\t}\n\n\tconst updateTransition = (index: number, next: FlowTransition) => {\n\t\tconst updated = [...transitions]\n\t\tupdated[index] = next\n\t\tonChange({ ...step, transitions: updated })\n\t}\n\n\tconst removeTransition = (index: number) => {\n\t\ttKeysRef.current = tKeys.filter((_, i) => i !== index)\n\t\tconst updated = transitions.filter((_, i) => i !== index)\n\t\tonChange({ ...step, transitions: updated.length > 0 ? updated : undefined })\n\t}\n\n\tconst moveTransition = (from: number, to: number) => {\n\t\tconst updated = [...transitions]\n\t\tconst [item] = updated.splice(from, 1)\n\t\tif (item !== undefined) updated.splice(to, 0, item)\n\t\tconst nextKeys = [...tKeys]\n\t\tconst [movedKey] = nextKeys.splice(from, 1)\n\t\tif (movedKey !== undefined) nextKeys.splice(to, 0, movedKey)\n\t\ttKeysRef.current = nextKeys\n\t\tonChange({ ...step, transitions: updated })\n\t}\n\n\tconst handleNextChange = (selected: ReactSelectOption | ReactSelectOption[]) => {\n\t\tconst chosen = Array.isArray(selected) ? selected[0] : selected\n\t\tif (chosen) onChange({ ...step, next: nextFromSelectValue(chosen.value as string) })\n\t}\n\n\tconst title = step.title?.trim() ?? ''\n\n\tconst stepHeader = (\n\t\t<div className=\"fb-flow-step__header-content\">\n\t\t\t<span className=\"fb-flow-step__index\">\n\t\t\t\t{resolveMessage(t(keys.flowStepFallbackTitle), { n: stepIndex + 1 })}\n\t\t\t</span>\n\t\t\t{title.length > 0 ? <span className=\"fb-flow-step__title\">{title}</span> : null}\n\t\t</div>\n\t)\n\n\treturn (\n\t\t<Collapsible\n\t\t\theader={stepHeader}\n\t\t\tactions={\n\t\t\t\t<Popup\n\t\t\t\t\tbutton={<MoreIcon />}\n\t\t\t\t\tbuttonType=\"default\"\n\t\t\t\t\thorizontalAlign=\"right\"\n\t\t\t\t\tsize=\"fit-content\"\n\t\t\t\t\tverticalAlign=\"bottom\"\n\t\t\t\t>\n\t\t\t\t\t<PopupList.ButtonGroup>\n\t\t\t\t\t\t<PopupList.Button onClick={onAddAbove}>{t(keys.flowAddAbove)}</PopupList.Button>\n\t\t\t\t\t\t<PopupList.Button onClick={onAddBelow}>{t(keys.flowAddBelow)}</PopupList.Button>\n\t\t\t\t\t\t<PopupList.Button onClick={onMoveUp} disabled={stepIndex === 0}>\n\t\t\t\t\t\t\tMove up\n\t\t\t\t\t\t</PopupList.Button>\n\t\t\t\t\t\t<PopupList.Button onClick={onMoveDown} disabled={stepIndex === stepCount - 1}>\n\t\t\t\t\t\t\tMove down\n\t\t\t\t\t\t</PopupList.Button>\n\t\t\t\t\t\t<PopupList.Button onClick={onRemove}>Remove</PopupList.Button>\n\t\t\t\t\t</PopupList.ButtonGroup>\n\t\t\t\t</Popup>\n\t\t\t}\n\t\t\tisCollapsed={!isExpanded}\n\t\t\tonToggle={() => onToggle()}\n\t\t\tclassName=\"fb-flow-step\"\n\t\t>\n\t\t\t<div className=\"fb-flow-step__body\">\n\t\t\t\t<TextInput\n\t\t\t\t\tpath={`fb-flow-step-${stepKey}-title`}\n\t\t\t\t\tlabel={t(keys.flowStepTitleLabel)}\n\t\t\t\t\tvalue={step.title ?? ''}\n\t\t\t\t\tonChange={(e: ChangeEvent<HTMLInputElement>) =>\n\t\t\t\t\t\tonChange({ ...step, title: e.target.value.length > 0 ? e.target.value : undefined })\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<div className=\"fb-flow-step__row\">\n\t\t\t\t\t<FieldLabel label={t(keys.flowFields)} />\n\t\t\t\t\t{entries.length === 0 ? (\n\t\t\t\t\t\t<p className=\"fb-flow-step__hint\">{t(keys.flowNoFields)}</p>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<div className=\"fb-flow-step__field-picker\">\n\t\t\t\t\t\t\t{entries.map((entry) => {\n\t\t\t\t\t\t\t\tconst holder = holders.get(entry.key)\n\t\t\t\t\t\t\t\tconst inOtherStep = holder !== undefined && holder !== stepIndex\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<div key={entry.key} className=\"fb-flow-step__field-option\">\n\t\t\t\t\t\t\t\t\t\t<CheckboxInput\n\t\t\t\t\t\t\t\t\t\t\tlabel={entry.label}\n\t\t\t\t\t\t\t\t\t\t\tchecked={step.fields.includes(entry.key) || inOtherStep}\n\t\t\t\t\t\t\t\t\t\t\treadOnly={inOtherStep}\n\t\t\t\t\t\t\t\t\t\t\tonToggle={(e) => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (inOtherStep) return\n\t\t\t\t\t\t\t\t\t\t\t\tonToggleField(entry.key, e.target.checked)\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t{inOtherStep ? (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fb-flow-step__field-hint\">\n\t\t\t\t\t\t\t\t\t\t\t\t{resolveMessage(t(keys.flowFieldInStep), {\n\t\t\t\t\t\t\t\t\t\t\t\t\tstep: stepLabels[holder] ?? '',\n\t\t\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\n\t\t\t\t<div className=\"fb-flow-step__row\">\n\t\t\t\t\t<FieldLabel label={t(keys.flowDefaultNext)} />\n\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\toptions={nextOptions}\n\t\t\t\t\t\tvalue={nextOptions.find((o) => o.value === nextToSelectValue(step.next)) ?? undefined}\n\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\tonChange={handleNextChange}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t\t<div className=\"fb-flow-step__transitions\">\n\t\t\t\t\t<div className=\"fb-flow-step__transitions-header\">\n\t\t\t\t\t\t<FieldLabel label={t(keys.flowConditionalTransitions)} />\n\t\t\t\t\t\t<span className=\"fb-flow-step__hint\">{t(keys.flowFirstMatchWins)}</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t{transitions.map((transition, tIndex) => {\n\t\t\t\t\t\tconst tKey = tKeys[tIndex]\n\t\t\t\t\t\tif (tKey === undefined) return null\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TransitionRow\n\t\t\t\t\t\t\t\tkey={tKey}\n\t\t\t\t\t\t\t\ttransition={transition}\n\t\t\t\t\t\t\t\tstepOptions={otherStepOptions}\n\t\t\t\t\t\t\t\tconditionTypes={conditionTypes}\n\t\t\t\t\t\t\t\tisFirst={tIndex === 0}\n\t\t\t\t\t\t\t\tisLast={tIndex === transitions.length - 1}\n\t\t\t\t\t\t\t\tonChange={(next) => updateTransition(tIndex, next)}\n\t\t\t\t\t\t\t\tonRemove={() => removeTransition(tIndex)}\n\t\t\t\t\t\t\t\tonMoveUp={() => moveTransition(tIndex, tIndex - 1)}\n\t\t\t\t\t\t\t\tonMoveDown={() => moveTransition(tIndex, tIndex + 1)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t\t<Button\n\t\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\tonClick={addTransition}\n\t\t\t\t\t\tmargin={false}\n\t\t\t\t\t>\n\t\t\t\t\t\t{t(keys.flowAddTransition)}\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Collapsible>\n\t)\n}\n\nexport const FlowBuilder = (props: FlowBuilderProps) => {\n\tconst { setValue, value } = useField<FormFlow | undefined>()\n\tconst { t } = useTranslation()\n\tconst label = toStaticLabel(props.field?.label ?? props.label)\n\tconst [expandedKeys, setExpandedKeys] = useState<Set<string>>(new Set())\n\n\tconst fieldRowsJson = useFormFields(([fields]) =>\n\t\tJSON.stringify(extractFieldRows(getDataFromFormState(fields, true) as Record<string, unknown>))\n\t)\n\t// Registry labels may be host-registered keys or literals; Payload's `t` returns unknown keys unchanged.\n\tconst translatedBareLabels = useMemo(\n\t\t() =>\n\t\t\tObject.fromEntries(\n\t\t\t\tObject.entries(props.bareTypeLabels ?? {}).map(([type, label]) => [\n\t\t\t\t\ttype,\n\t\t\t\t\tt(label as TranslationKey),\n\t\t\t\t])\n\t\t\t),\n\t\t[props.bareTypeLabels, t]\n\t)\n\tconst entries = useMemo(\n\t\t() => flowFieldEntries(JSON.parse(fieldRowsJson) as FieldRow[], translatedBareLabels),\n\t\t[fieldRowsJson, translatedBareLabels]\n\t)\n\n\tconst steps = value?.steps ?? []\n\tconst fallbackTitle = t(keys.flowStepFallbackTitle)\n\tconst stepLabels = steps.map((step, index) => stepLabel(step, index, fallbackTitle))\n\tconst stepOptions = stepSelectOptions(steps, stepLabels)\n\tconst holders = fieldHolders(steps)\n\tconst unassigned = unassignedEntries(entries, steps)\n\n\t// Stable per-step React keys, independent of step ids. Reorder/insert/remove reconcile by\n\t// identity so focused inputs and each step's expand state stay with their step instead of\n\t// jumping to whichever step now sits at that array position.\n\tconst keysRef = useRef<string[]>([])\n\tif (keysRef.current.length !== steps.length) {\n\t\tkeysRef.current = steps.map((_, i) => keysRef.current[i] ?? crypto.randomUUID())\n\t}\n\tconst stepKeys = keysRef.current\n\n\tconst toggleExpanded = (key: string) => {\n\t\tsetExpandedKeys((prev) => {\n\t\t\tconst next = new Set(prev)\n\t\t\tif (next.has(key)) next.delete(key)\n\t\t\telse next.add(key)\n\t\t\treturn next\n\t\t})\n\t}\n\n\tconst emit = (nextSteps: FlowStep[], nextKeys: string[]) => {\n\t\tkeysRef.current = nextKeys\n\t\tsetValue({ steps: nextSteps } as FormFlow)\n\t}\n\n\tconst insertStep = (at: number) => {\n\t\tconst key = crypto.randomUUID()\n\t\tconst nextSteps = [...steps]\n\t\tnextSteps.splice(at, 0, { id: crypto.randomUUID(), fields: [] })\n\t\tconst nextKeys = [...stepKeys]\n\t\tnextKeys.splice(at, 0, key)\n\t\temit(nextSteps, nextKeys)\n\t\tsetExpandedKeys((prev) => new Set(prev).add(key))\n\t}\n\n\tconst addStep = () => insertStep(steps.length)\n\n\tconst updateStep = (index: number, next: FlowStep) => {\n\t\temit(\n\t\t\tsteps.map((s, i) => (i === index ? next : s)),\n\t\t\tstepKeys\n\t\t)\n\t}\n\n\tconst toggleField = (stepIndex: number, key: string, checked: boolean) => {\n\t\tconst nextSteps = checked\n\t\t\t? assignFieldToStep(steps, stepIndex, key)\n\t\t\t: removeFieldFromStep(steps, stepIndex, key)\n\t\temit(nextSteps, stepKeys)\n\t}\n\n\tconst assignUnassignedField = (key: string, stepId: string) => {\n\t\tconst targetIndex = steps.findIndex((s) => s.id === stepId)\n\t\tif (targetIndex === -1) return\n\t\temit(assignFieldToStep(steps, targetIndex, key), stepKeys)\n\t}\n\n\tconst removeStep = (index: number) => {\n\t\tconst removedKey = stepKeys[index]\n\t\temit(\n\t\t\tremoveStepCascade(steps, index),\n\t\t\tstepKeys.filter((_, i) => i !== index)\n\t\t)\n\t\tif (removedKey !== undefined) {\n\t\t\tsetExpandedKeys((prev) => {\n\t\t\t\tconst next = new Set(prev)\n\t\t\t\tnext.delete(removedKey)\n\t\t\t\treturn next\n\t\t\t})\n\t\t}\n\t}\n\n\tconst moveStep = (from: number, to: number) => {\n\t\tconst nextSteps = [...steps]\n\t\tconst [movedStep] = nextSteps.splice(from, 1)\n\t\tif (movedStep === undefined) return\n\t\tnextSteps.splice(to, 0, movedStep)\n\t\tconst nextKeys = [...stepKeys]\n\t\tconst [movedKey] = nextKeys.splice(from, 1)\n\t\tif (movedKey !== undefined) nextKeys.splice(to, 0, movedKey)\n\t\temit(nextSteps, nextKeys)\n\t}\n\n\treturn (\n\t\t<div className=\"field-type fb-flow-builder\">\n\t\t\t<header className=\"blocks-field__header\">\n\t\t\t\t<div className=\"blocks-field__header-wrap\">\n\t\t\t\t\t<div className=\"blocks-field__header-content\">\n\t\t\t\t\t\t<h3 className=\"blocks-field__title\">\n\t\t\t\t\t\t\t{typeof label === 'string' ? label : t(keys.flowFallbackTitle)}\n\t\t\t\t\t\t</h3>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</header>\n\t\t\t<p className=\"fb-flow-builder__description\">{t(keys.flowDescription)}</p>\n\t\t\t{steps.length === 0 ? (\n\t\t\t\t<p className=\"fb-flow-builder__hint\">{t(keys.flowNoSteps)}</p>\n\t\t\t) : (\n\t\t\t\t<div className=\"fb-flow-builder__steps\">\n\t\t\t\t\t{steps.map((step, index) => {\n\t\t\t\t\t\tconst key = stepKeys[index]\n\t\t\t\t\t\tif (key === undefined) return null\n\t\t\t\t\t\tconst otherStepOptions = otherStepSelectOptions(stepOptions, step.id)\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<StepCard\n\t\t\t\t\t\t\t\tkey={key}\n\t\t\t\t\t\t\t\tstepKey={key}\n\t\t\t\t\t\t\t\tstep={step}\n\t\t\t\t\t\t\t\tstepIndex={index}\n\t\t\t\t\t\t\t\tstepCount={steps.length}\n\t\t\t\t\t\t\t\totherStepOptions={otherStepOptions}\n\t\t\t\t\t\t\t\tholders={holders}\n\t\t\t\t\t\t\t\tstepLabels={stepLabels}\n\t\t\t\t\t\t\t\tentries={entries}\n\t\t\t\t\t\t\t\tconditionTypes={props.conditionTypes}\n\t\t\t\t\t\t\t\tisExpanded={expandedKeys.has(key)}\n\t\t\t\t\t\t\t\tonToggle={() => toggleExpanded(key)}\n\t\t\t\t\t\t\t\tonChange={(next) => updateStep(index, next)}\n\t\t\t\t\t\t\t\tonToggleField={(fieldKey, checked) => toggleField(index, fieldKey, checked)}\n\t\t\t\t\t\t\t\tonRemove={() => removeStep(index)}\n\t\t\t\t\t\t\t\tonMoveUp={() => moveStep(index, index - 1)}\n\t\t\t\t\t\t\t\tonMoveDown={() => moveStep(index, index + 1)}\n\t\t\t\t\t\t\t\tonAddAbove={() => insertStep(index)}\n\t\t\t\t\t\t\t\tonAddBelow={() => insertStep(index + 1)}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t})}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t\t{steps.length > 0 && unassigned.length > 0 ? (\n\t\t\t\t<div className=\"fb-flow-unassigned\">\n\t\t\t\t\t<FieldLabel label={t(keys.flowUnassigned)} />\n\t\t\t\t\t<div className=\"fb-flow-unassigned__rows\">\n\t\t\t\t\t\t{unassigned.map((entry) => (\n\t\t\t\t\t\t\t<div key={entry.key} className=\"fb-flow-unassigned__row\">\n\t\t\t\t\t\t\t\t<span className=\"fb-flow-unassigned__name\">{entry.label}</span>\n\t\t\t\t\t\t\t\t<div className=\"fb-flow-unassigned__select\">\n\t\t\t\t\t\t\t\t\t<ReactSelect\n\t\t\t\t\t\t\t\t\t\toptions={stepOptions}\n\t\t\t\t\t\t\t\t\t\tplaceholder={t(keys.flowAssignToStep)}\n\t\t\t\t\t\t\t\t\t\tisClearable={false}\n\t\t\t\t\t\t\t\t\t\tonChange={(selected: ReactSelectOption | ReactSelectOption[]) => {\n\t\t\t\t\t\t\t\t\t\t\tconst chosen = Array.isArray(selected) ? selected[0] : selected\n\t\t\t\t\t\t\t\t\t\t\tif (chosen) assignUnassignedField(entry.key, chosen.value as string)\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t\t<div className=\"fb-flow-builder__actions\">\n\t\t\t\t<Button\n\t\t\t\t\tbuttonStyle=\"ghost\"\n\t\t\t\t\ticon={<CirclePlusIcon size={24} />}\n\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\tonClick={addStep}\n\t\t\t\t\tmargin={false}\n\t\t\t\t>\n\t\t\t\t\tAdd step\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0DA,MAAM,oBAAoB,SAA8C;CAEvE,QADa,MAAM,QAAQ,KAAK,MAAM,IAAK,KAAK,SAAwB,CAAC,GAC7D,KAAK,SAAS;EACzB,WAAW,IAAI;EACf,MAAM,IAAI;EACV,IAAI,IAAI;EACR,OAAO,IAAI;EACX,SAAS,IAAI;CACd,EAAE;AACH;AAcA,MAAM,iBAAiB,EACtB,YACA,aACA,gBACA,SACA,QACA,UACA,UACA,UACA,iBACyB;CACzB,MAAM,EAAE,MAAMA,iBAAe;CAE7B,MAAM,oBAAoB,aAAsD;EAC/E,MAAM,SAAS,MAAM,QAAQ,QAAQ,IAAI,SAAS,KAAK;EACvD,IAAI,QAAQ,SAAS;GAAE,GAAG;GAAY,IAAI,OAAO;EAAgB,CAAC;CACnE;CAEA,OACC,qBAAC,OAAD;EAAK,WAAU;YAAf;GACC,qBAAC,OAAD;IAAK,WAAU;cAAf;KACC,oBAAC,QAAD;MAAM,WAAU;gBAA6B,EAAE,KAAK,QAAQ;KAAQ,CAAA;KACpE,oBAAC,OAAD;MAAK,WAAU;gBACd,oBAAC,aAAD;OACC,SAAS;OACT,OAAO,YAAY,MAAM,MAAM,EAAE,UAAU,WAAW,EAAE,KAAK,KAAA;OAC7D,aAAa,EAA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AAA,CACD;QACF;GACJ,oBAAC,OAAD;IAAK,WAAU;cACd,oBAAC,QAAD;KACC,aAAY;KACZ,MAAM,oBAAC,gBAAD,EAAgB,MAAM,GAAK,CAAA;KACjC,cAAa;KACb,SAAS;KACT,QAAQ;eACR;IAEO,CAAA;GACJ,CAAA;EACD;;AAEP"}
@@ -15,7 +15,7 @@ type FormConditionFieldProps = {
15
15
  * The `Field` mounted on a form field's `visibleWhen`/`validateWhen` json column. Binds the field's own
16
16
  * path with `useField<Where>()` (the QueryPresetsWhereField precedent) and renders the native builder.
17
17
  */
18
- declare const FormConditionField: (props: FormConditionFieldProps) => import("react/jsx-runtime").JSX.Element;
18
+ declare const FormConditionField: (props: FormConditionFieldProps) => import("react").JSX.Element;
19
19
  //#endregion
20
20
  export { FormConditionField };
21
21
  //# sourceMappingURL=FormConditionField.d.ts.map
@@ -32,7 +32,7 @@ type RecipientsSelectProps = {
32
32
  * (`allowCustom`). Renders as native Payload badges (drag-reorderable), stores a `string[]`, honors
33
33
  * `admin.width` and the standard field props. Unknown or legacy stored values stay selectable.
34
34
  */
35
- declare const RecipientsSelect: (props: RecipientsSelectProps) => import("react/jsx-runtime").JSX.Element;
35
+ declare const RecipientsSelect: (props: RecipientsSelectProps) => import("react").JSX.Element;
36
36
  //#endregion
37
37
  export { RecipientsSelect };
38
38
  //# sourceMappingURL=RecipientsSelect.d.ts.map
@@ -5,7 +5,7 @@ import { isPlausibleEmail } from "../actions/emailRecipients.js";
5
5
  import { useTranslation as useTranslation$1 } from "../translations/useTranslation.js";
6
6
  import { toStaticLabel } from "./toStaticLabel.js";
7
7
  import { buildEndpointOptionsUrl, parseEndpointOptions } from "./endpointOptions.js";
8
- import { reduceFieldsToValues } from "payload/shared";
8
+ import { getDataFromFormState } from "payload/shared";
9
9
  import { FieldDescription, FieldError, FieldLabel, ReactSelect, RenderCustomComponent, useConfig, useDocumentInfo, useField, useFormFields } from "@payloadcms/ui";
10
10
  import { jsx, jsxs } from "react/jsx-runtime";
11
11
  import { useEffect, useMemo, useState } from "react";
@@ -82,7 +82,7 @@ const RecipientsSelect = (props) => {
82
82
  props.endpoint
83
83
  ]);
84
84
  const presetOptions = state.status === "loaded" ? state.options : [];
85
- const tokenJson = useFormFields(([fields]) => fieldTokens ? JSON.stringify(tokenOptionsFromData(reduceFieldsToValues(fields, true), props.tokenFieldTypes)) : "[]");
85
+ const tokenJson = useFormFields(([fields]) => fieldTokens ? JSON.stringify(tokenOptionsFromData(getDataFromFormState(fields, true), props.tokenFieldTypes)) : "[]");
86
86
  const tokenOptions = useMemo(() => JSON.parse(tokenJson), [tokenJson]);
87
87
  const stored = Array.isArray(value) ? value.filter((entry) => typeof entry === "string" && entry.length > 0) : typeof value === "string" && value.length > 0 ? [value] : [];
88
88
  const byValue = useMemo(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"RecipientsSelect.js","names":["useTranslation"],"sources":["../../src/client/RecipientsSelect.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tReactSelect,\n\ttype ReactSelectOption,\n\tRenderCustomComponent,\n\tuseConfig,\n\tuseDocumentInfo,\n\tuseField,\n\tuseFormFields,\n} from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport { type CSSProperties, useEffect, useMemo, useState } from 'react'\nimport { isPlausibleEmail } from '../actions/emailRecipients'\nimport { fieldNames, fieldNamesOfType } from '../fields/fieldNamesOfType'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport {\n\tbuildEndpointOptionsUrl,\n\ttype EndpointOption,\n\ttype EndpointOptionsScope,\n\tparseEndpointOptions,\n} from './endpointOptions'\nimport type { FieldRow } from './synthesizeClientField'\nimport { toStaticLabel } from './toStaticLabel'\n\nexport type RecipientsSelectProps = {\n\tpath?: string\n\tfield?: {\n\t\tlabel?: unknown\n\t\tlocalized?: boolean\n\t\trequired?: boolean\n\t\tadmin?: { description?: unknown; width?: string }\n\t}\n\tlabel?: unknown\n\treadOnly?: boolean\n\t/** Endpoint subpath supplying preset address options (e.g. `'departments'`); omit for none. */\n\tendpoint?: string\n\t/** What the endpoint's options depend on; see {@link EndpointOptionsScope}. Default `'document'`. */\n\tscope?: EndpointOptionsScope\n\t/** Allow free-typed emails (default true). */\n\tallowCustom?: boolean\n\t/** Offer the form's own fields as recipient tokens (default true). */\n\tfieldTokens?: boolean\n\t/** Field types eligible as tokens (default `['email']`). */\n\ttokenFieldTypes?: string[]\n\t/** Registered recipient sources, offered as their own option group (labels resolved for the admin locale). */\n\tsources?: { value: string; label: string | Record<string, string> }[]\n\tdescriptionKey?: TranslationKey\n}\n\n/** A source label is a plain string or a per-locale record; resolve it for the admin UI language. */\nconst resolveSourceLabel = (label: string | Record<string, string>, language: string): string =>\n\ttypeof label === 'string' ? label : (label[language] ?? label.en ?? Object.values(label)[0] ?? '')\n\ntype FetchState =\n\t| { status: 'error' | 'idle' | 'loading' }\n\t| { status: 'loaded'; options: EndpointOption[] }\n\nconst tokenOptionsFromData = (\n\tdata: Record<string, unknown>,\n\ttypes?: string[]\n): ReactSelectOption[] => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as unknown[]) : []\n\tconst labels = new Map<string, string>()\n\tfor (const row of rows) {\n\t\tif (!row || typeof row !== 'object') {\n\t\t\tcontinue\n\t\t}\n\t\tconst { name, label } = row as FieldRow\n\t\tif (typeof name === 'string' && typeof label === 'string' && label.length > 0) {\n\t\t\tlabels.set(name.trim(), label)\n\t\t}\n\t}\n\tconst names =\n\t\ttypes && types.length > 0 ? fieldNamesOfType(data.fields, types) : fieldNames(data.fields)\n\treturn names.map((name) => ({ label: labels.get(name) ?? name, value: `{{${name}}}` }))\n}\n\n/**\n * A creatable, multi-value recipient field: pick a department (preset options from `endpoint`), pick a\n * form-field token (`{{field}}`, offered when `fieldTokens`), or type any email and press Enter\n * (`allowCustom`). Renders as native Payload badges (drag-reorderable), stores a `string[]`, honors\n * `admin.width` and the standard field props. Unknown or legacy stored values stay selectable.\n */\nexport const RecipientsSelect = (props: RecipientsSelectProps) => {\n\tconst allowCustom = props.allowCustom !== false\n\tconst fieldTokens = props.fieldTokens !== false\n\tconst {\n\t\tcustomComponents: { Description, Error: ErrorComponent, Label } = {},\n\t\tdisabled,\n\t\tpath,\n\t\tsetValue,\n\t\tshowError,\n\t\tvalue,\n\t} = useField<string[] | string>({ path: props.path })\n\tconst { t, i18n } = useTranslation()\n\tconst sourceOptions: ReactSelectOption[] = useMemo(\n\t\t() =>\n\t\t\t(props.sources ?? []).map((source) => ({\n\t\t\t\tvalue: source.value,\n\t\t\t\tlabel: resolveSourceLabel(source.label, i18n.language),\n\t\t\t})),\n\t\t[props.sources, i18n.language]\n\t)\n\tconst label = toStaticLabel(props.field?.label ?? props.label)\n\tconst description = props.descriptionKey\n\t\t? t(props.descriptionKey)\n\t\t: toStaticLabel(props.field?.admin?.description)\n\tconst { id, collectionSlug } = useDocumentInfo()\n\tconst { config } = useConfig()\n\tconst apiRoute = config.routes.api\n\tconst readOnly = props.readOnly === true || disabled === true\n\tconst [state, setState] = useState<FetchState>({ status: 'idle' })\n\n\tconst scope = props.scope ?? 'document'\n\t// Request scope never puts the id in the URL; deriving undefined here keeps the effect from\n\t// re-fetching when the first save assigns one.\n\tconst docId = scope === 'request' ? undefined : id\n\n\tuseEffect(() => {\n\t\tif (!props.endpoint || !collectionSlug || (scope === 'document' && docId == null)) {\n\t\t\treturn\n\t\t}\n\t\tconst controller = new AbortController()\n\t\tconst url = buildEndpointOptionsUrl({\n\t\t\tapiRoute,\n\t\t\tcollectionSlug,\n\t\t\tid: docId,\n\t\t\tscope,\n\t\t\tendpoint: props.endpoint,\n\t\t})\n\t\tsetState({ status: 'loading' })\n\t\tfetch(url, {\n\t\t\tcredentials: 'include',\n\t\t\theaders: { Accept: 'application/json' },\n\t\t\tsignal: controller.signal,\n\t\t})\n\t\t\t.then(async (response) => {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Options request failed with ${response.status}`)\n\t\t\t\t}\n\t\t\t\tsetState({ status: 'loaded', options: parseEndpointOptions(await response.json()) })\n\t\t\t})\n\t\t\t.catch(() => {\n\t\t\t\tif (!controller.signal.aborted) {\n\t\t\t\t\tsetState({ status: 'error' })\n\t\t\t\t}\n\t\t\t})\n\t\treturn () => controller.abort()\n\t}, [apiRoute, collectionSlug, docId, scope, props.endpoint])\n\n\tconst presetOptions: ReactSelectOption[] = state.status === 'loaded' ? state.options : []\n\n\tconst tokenJson = useFormFields(([fields]) =>\n\t\tfieldTokens\n\t\t\t? JSON.stringify(\n\t\t\t\t\ttokenOptionsFromData(reduceFieldsToValues(fields, true), props.tokenFieldTypes)\n\t\t\t\t)\n\t\t\t: '[]'\n\t)\n\tconst tokenOptions = useMemo(() => JSON.parse(tokenJson) as ReactSelectOption[], [tokenJson])\n\n\tconst stored: string[] = Array.isArray(value)\n\t\t? value.filter((entry): entry is string => typeof entry === 'string' && entry.length > 0)\n\t\t: typeof value === 'string' && value.length > 0\n\t\t\t? [value]\n\t\t\t: []\n\n\tconst byValue = useMemo(() => {\n\t\tconst map = new Map<string, ReactSelectOption>()\n\t\tfor (const option of [...presetOptions, ...tokenOptions, ...sourceOptions]) {\n\t\t\tmap.set(option.value as string, option)\n\t\t}\n\t\treturn map\n\t}, [presetOptions, tokenOptions, sourceOptions])\n\n\tconst selected = stored.map((entry) => byValue.get(entry) ?? { label: entry, value: entry })\n\n\tconst groupedOptions = useMemo(() => {\n\t\tconst groups: { label: string; options: ReactSelectOption[] }[] = []\n\t\tif (presetOptions.length > 0) {\n\t\t\tgroups.push({ label: t(keys.recipientsGroupDepartments), options: presetOptions })\n\t\t}\n\t\tif (tokenOptions.length > 0) {\n\t\t\tgroups.push({ label: t(keys.recipientsGroupFields), options: tokenOptions })\n\t\t}\n\t\tif (sourceOptions.length > 0) {\n\t\t\tgroups.push({ label: t(keys.recipientsGroupSources), options: sourceOptions })\n\t\t}\n\t\treturn groups\n\t}, [presetOptions, tokenOptions, sourceOptions, t])\n\n\tconst handleChange = (selection: ReactSelectOption | ReactSelectOption[] | null) => {\n\t\tif (readOnly) {\n\t\t\treturn\n\t\t}\n\t\tconst chosen = Array.isArray(selection) ? selection : selection ? [selection] : []\n\t\tconst entries = chosen\n\t\t\t.map((option) => String(option.value).trim())\n\t\t\t.filter((entry) => entry.length > 0 && (isPlausibleEmail(entry) || byValue.has(entry)))\n\t\tconst deduped = new Map<string, string>()\n\t\tfor (const entry of entries) {\n\t\t\tconst key = entry.toLowerCase()\n\t\t\tif (!deduped.has(key)) {\n\t\t\t\tdeduped.set(key, entry)\n\t\t\t}\n\t\t}\n\t\tsetValue(Array.from(deduped.values()))\n\t}\n\n\tconst fieldStyle = props.field?.admin?.width\n\t\t? ({ '--field-width': props.field.admin.width } as CSSProperties)\n\t\t: undefined\n\n\treturn (\n\t\t<div\n\t\t\tclassName={['field-type', showError && 'error', readOnly && 'read-only']\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ')}\n\t\t\tid={path ? `field-${path.replace(/\\./g, '__')}` : undefined}\n\t\t\tstyle={fieldStyle}\n\t\t>\n\t\t\t<RenderCustomComponent\n\t\t\t\tCustomComponent={Label}\n\t\t\t\tFallback={\n\t\t\t\t\t<FieldLabel\n\t\t\t\t\t\tlabel={label}\n\t\t\t\t\t\tlocalized={props.field?.localized}\n\t\t\t\t\t\tpath={path}\n\t\t\t\t\t\trequired={props.field?.required}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<div className=\"field-type__wrap\">\n\t\t\t\t<RenderCustomComponent\n\t\t\t\t\tCustomComponent={ErrorComponent}\n\t\t\t\t\tFallback={<FieldError path={path} showError={showError} />}\n\t\t\t\t/>\n\t\t\t\t<ReactSelect\n\t\t\t\t\toptions={groupedOptions}\n\t\t\t\t\tvalue={selected}\n\t\t\t\t\tisMulti\n\t\t\t\t\tisSortable\n\t\t\t\t\tisCreatable={allowCustom}\n\t\t\t\t\tisClearable={!readOnly}\n\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\tisLoading={state.status === 'loading'}\n\t\t\t\t\tshowError={showError}\n\t\t\t\t\tplaceholder={state.status === 'loading' ? t(keys.endpointOptionsLoading) : undefined}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tfilterOption={(option, rawInput) => {\n\t\t\t\t\t\tif (!option) {\n\t\t\t\t\t\t\treturn allowCustom && isPlausibleEmail(rawInput)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst query = rawInput.toLowerCase()\n\t\t\t\t\t\treturn `${option.label} ${option.value}`.toLowerCase().includes(query)\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<RenderCustomComponent\n\t\t\t\tCustomComponent={Description}\n\t\t\t\tFallback={\n\t\t\t\t\t<FieldDescription\n\t\t\t\t\t\tdescription={state.status === 'error' ? t(keys.endpointOptionsError) : description}\n\t\t\t\t\t\tpath={path}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;AAuDA,MAAM,sBAAsB,OAAwC,aACnE,OAAO,UAAU,WAAW,QAAS,MAAM,aAAa,MAAM,MAAM,OAAO,OAAO,KAAK,EAAE,MAAM;AAMhG,MAAM,wBACL,MACA,UACyB;CACzB,MAAM,OAAO,MAAM,QAAQ,KAAK,MAAM,IAAK,KAAK,SAAuB,CAAC;CACxE,MAAM,yBAAS,IAAI,IAAoB;CACvC,KAAK,MAAM,OAAO,MAAM;EACvB,IAAI,CAAC,OAAO,OAAO,QAAQ,UAC1B;EAED,MAAM,EAAE,MAAM,UAAU;EACxB,IAAI,OAAO,SAAS,YAAY,OAAO,UAAU,YAAY,MAAM,SAAS,GAC3E,OAAO,IAAI,KAAK,KAAK,GAAG,KAAK;CAE/B;CAGA,QADC,SAAS,MAAM,SAAS,IAAI,iBAAiB,KAAK,QAAQ,KAAK,IAAI,WAAW,KAAK,MAAM,GA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;GAEF,CAAA;GACD,qBAAC,OAAD;IAAK,WAAU;cAAf,CACC,oBAAC,uBAAD;KACC,iBAAiB;KACjB,UAAU,oBAAC,YAAD;MAAkB;MAAiB;KAAY,CAAA;IACzD,CAAA,GACD,oBAAC,aAAD;KACC,SAAS;KACT,OAAO;KACP,SAAA;KACA,YAAA;KACA,aAAa;KACb,aAAa,CAAC;KACd,UAAU;KACV,WAAW,MAAM,WAAW;KACjB;KACX,aAAa,MAAM,WAAW,YAAY,EAAE,KAAK,sBAAsB,IAAI,KAAA;KAC3E,UAAU;KACV,eAAe,QAAQ,aAAa;MACnC,IAAI,CAAC,QACJ,OAAO,eAAe,iBAAiB,QAAQ;MAEhD,MAAM,QAAQ,SAAS,YAAY;MACnC,OAAO,GAAG,OAAO,MAAM,GAAG,OAAO,QAAQ,YAAY,EAAE,SAAS,KAAK;KACtE;IACA,CAAA,CACG;;GACL,oBAAC,uBAAD;IACC,iBAAiB;IACjB,UACC,oBAAC,kBAAD;KACC,aAAa,MAAM,WAAW,UAAU,EAAE,KAAK,oBAAoB,IAAI;KACjE;IACN,CAAA;GAEF,CAAA;EACG;;AAEP"}
1
+ {"version":3,"file":"RecipientsSelect.js","names":["useTranslation"],"sources":["../../src/client/RecipientsSelect.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tFieldDescription,\n\tFieldError,\n\tFieldLabel,\n\tReactSelect,\n\ttype ReactSelectOption,\n\tRenderCustomComponent,\n\tuseConfig,\n\tuseDocumentInfo,\n\tuseField,\n\tuseFormFields,\n} from '@payloadcms/ui'\nimport { getDataFromFormState } from 'payload/shared'\nimport { type CSSProperties, useEffect, useMemo, useState } from 'react'\nimport { isPlausibleEmail } from '../actions/emailRecipients'\nimport { fieldNames, fieldNamesOfType } from '../fields/fieldNamesOfType'\nimport { keys, type TranslationKey } from '../translations/keys'\nimport { useTranslation } from '../translations/useTranslation'\nimport {\n\tbuildEndpointOptionsUrl,\n\ttype EndpointOption,\n\ttype EndpointOptionsScope,\n\tparseEndpointOptions,\n} from './endpointOptions'\nimport type { FieldRow } from './synthesizeClientField'\nimport { toStaticLabel } from './toStaticLabel'\n\nexport type RecipientsSelectProps = {\n\tpath?: string\n\tfield?: {\n\t\tlabel?: unknown\n\t\tlocalized?: boolean\n\t\trequired?: boolean\n\t\tadmin?: { description?: unknown; width?: string }\n\t}\n\tlabel?: unknown\n\treadOnly?: boolean\n\t/** Endpoint subpath supplying preset address options (e.g. `'departments'`); omit for none. */\n\tendpoint?: string\n\t/** What the endpoint's options depend on; see {@link EndpointOptionsScope}. Default `'document'`. */\n\tscope?: EndpointOptionsScope\n\t/** Allow free-typed emails (default true). */\n\tallowCustom?: boolean\n\t/** Offer the form's own fields as recipient tokens (default true). */\n\tfieldTokens?: boolean\n\t/** Field types eligible as tokens (default `['email']`). */\n\ttokenFieldTypes?: string[]\n\t/** Registered recipient sources, offered as their own option group (labels resolved for the admin locale). */\n\tsources?: { value: string; label: string | Record<string, string> }[]\n\tdescriptionKey?: TranslationKey\n}\n\n/** A source label is a plain string or a per-locale record; resolve it for the admin UI language. */\nconst resolveSourceLabel = (label: string | Record<string, string>, language: string): string =>\n\ttypeof label === 'string' ? label : (label[language] ?? label.en ?? Object.values(label)[0] ?? '')\n\ntype FetchState =\n\t| { status: 'error' | 'idle' | 'loading' }\n\t| { status: 'loaded'; options: EndpointOption[] }\n\nconst tokenOptionsFromData = (\n\tdata: Record<string, unknown>,\n\ttypes?: string[]\n): ReactSelectOption[] => {\n\tconst rows = Array.isArray(data.fields) ? (data.fields as unknown[]) : []\n\tconst labels = new Map<string, string>()\n\tfor (const row of rows) {\n\t\tif (!row || typeof row !== 'object') {\n\t\t\tcontinue\n\t\t}\n\t\tconst { name, label } = row as FieldRow\n\t\tif (typeof name === 'string' && typeof label === 'string' && label.length > 0) {\n\t\t\tlabels.set(name.trim(), label)\n\t\t}\n\t}\n\tconst names =\n\t\ttypes && types.length > 0 ? fieldNamesOfType(data.fields, types) : fieldNames(data.fields)\n\treturn names.map((name) => ({ label: labels.get(name) ?? name, value: `{{${name}}}` }))\n}\n\n/**\n * A creatable, multi-value recipient field: pick a department (preset options from `endpoint`), pick a\n * form-field token (`{{field}}`, offered when `fieldTokens`), or type any email and press Enter\n * (`allowCustom`). Renders as native Payload badges (drag-reorderable), stores a `string[]`, honors\n * `admin.width` and the standard field props. Unknown or legacy stored values stay selectable.\n */\nexport const RecipientsSelect = (props: RecipientsSelectProps) => {\n\tconst allowCustom = props.allowCustom !== false\n\tconst fieldTokens = props.fieldTokens !== false\n\tconst {\n\t\tcustomComponents: { Description, Error: ErrorComponent, Label } = {},\n\t\tdisabled,\n\t\tpath,\n\t\tsetValue,\n\t\tshowError,\n\t\tvalue,\n\t} = useField<string[] | string>({ path: props.path })\n\tconst { t, i18n } = useTranslation()\n\tconst sourceOptions: ReactSelectOption[] = useMemo(\n\t\t() =>\n\t\t\t(props.sources ?? []).map((source) => ({\n\t\t\t\tvalue: source.value,\n\t\t\t\tlabel: resolveSourceLabel(source.label, i18n.language),\n\t\t\t})),\n\t\t[props.sources, i18n.language]\n\t)\n\tconst label = toStaticLabel(props.field?.label ?? props.label)\n\tconst description = props.descriptionKey\n\t\t? t(props.descriptionKey)\n\t\t: toStaticLabel(props.field?.admin?.description)\n\tconst { id, collectionSlug } = useDocumentInfo()\n\tconst { config } = useConfig()\n\tconst apiRoute = config.routes.api\n\tconst readOnly = props.readOnly === true || disabled === true\n\tconst [state, setState] = useState<FetchState>({ status: 'idle' })\n\n\tconst scope = props.scope ?? 'document'\n\t// Request scope never puts the id in the URL; deriving undefined here keeps the effect from\n\t// re-fetching when the first save assigns one.\n\tconst docId = scope === 'request' ? undefined : id\n\n\tuseEffect(() => {\n\t\tif (!props.endpoint || !collectionSlug || (scope === 'document' && docId == null)) {\n\t\t\treturn\n\t\t}\n\t\tconst controller = new AbortController()\n\t\tconst url = buildEndpointOptionsUrl({\n\t\t\tapiRoute,\n\t\t\tcollectionSlug,\n\t\t\tid: docId,\n\t\t\tscope,\n\t\t\tendpoint: props.endpoint,\n\t\t})\n\t\tsetState({ status: 'loading' })\n\t\tfetch(url, {\n\t\t\tcredentials: 'include',\n\t\t\theaders: { Accept: 'application/json' },\n\t\t\tsignal: controller.signal,\n\t\t})\n\t\t\t.then(async (response) => {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Options request failed with ${response.status}`)\n\t\t\t\t}\n\t\t\t\tsetState({ status: 'loaded', options: parseEndpointOptions(await response.json()) })\n\t\t\t})\n\t\t\t.catch(() => {\n\t\t\t\tif (!controller.signal.aborted) {\n\t\t\t\t\tsetState({ status: 'error' })\n\t\t\t\t}\n\t\t\t})\n\t\treturn () => controller.abort()\n\t}, [apiRoute, collectionSlug, docId, scope, props.endpoint])\n\n\tconst presetOptions: ReactSelectOption[] = state.status === 'loaded' ? state.options : []\n\n\tconst tokenJson = useFormFields(([fields]) =>\n\t\tfieldTokens\n\t\t\t? JSON.stringify(\n\t\t\t\t\ttokenOptionsFromData(getDataFromFormState(fields, true), props.tokenFieldTypes)\n\t\t\t\t)\n\t\t\t: '[]'\n\t)\n\tconst tokenOptions = useMemo(() => JSON.parse(tokenJson) as ReactSelectOption[], [tokenJson])\n\n\tconst stored: string[] = Array.isArray(value)\n\t\t? value.filter((entry): entry is string => typeof entry === 'string' && entry.length > 0)\n\t\t: typeof value === 'string' && value.length > 0\n\t\t\t? [value]\n\t\t\t: []\n\n\tconst byValue = useMemo(() => {\n\t\tconst map = new Map<string, ReactSelectOption>()\n\t\tfor (const option of [...presetOptions, ...tokenOptions, ...sourceOptions]) {\n\t\t\tmap.set(option.value as string, option)\n\t\t}\n\t\treturn map\n\t}, [presetOptions, tokenOptions, sourceOptions])\n\n\tconst selected = stored.map((entry) => byValue.get(entry) ?? { label: entry, value: entry })\n\n\tconst groupedOptions = useMemo(() => {\n\t\tconst groups: { label: string; options: ReactSelectOption[] }[] = []\n\t\tif (presetOptions.length > 0) {\n\t\t\tgroups.push({ label: t(keys.recipientsGroupDepartments), options: presetOptions })\n\t\t}\n\t\tif (tokenOptions.length > 0) {\n\t\t\tgroups.push({ label: t(keys.recipientsGroupFields), options: tokenOptions })\n\t\t}\n\t\tif (sourceOptions.length > 0) {\n\t\t\tgroups.push({ label: t(keys.recipientsGroupSources), options: sourceOptions })\n\t\t}\n\t\treturn groups\n\t}, [presetOptions, tokenOptions, sourceOptions, t])\n\n\tconst handleChange = (selection: ReactSelectOption | ReactSelectOption[] | null) => {\n\t\tif (readOnly) {\n\t\t\treturn\n\t\t}\n\t\tconst chosen = Array.isArray(selection) ? selection : selection ? [selection] : []\n\t\tconst entries = chosen\n\t\t\t.map((option) => String(option.value).trim())\n\t\t\t.filter((entry) => entry.length > 0 && (isPlausibleEmail(entry) || byValue.has(entry)))\n\t\tconst deduped = new Map<string, string>()\n\t\tfor (const entry of entries) {\n\t\t\tconst key = entry.toLowerCase()\n\t\t\tif (!deduped.has(key)) {\n\t\t\t\tdeduped.set(key, entry)\n\t\t\t}\n\t\t}\n\t\tsetValue(Array.from(deduped.values()))\n\t}\n\n\tconst fieldStyle = props.field?.admin?.width\n\t\t? ({ '--field-width': props.field.admin.width } as CSSProperties)\n\t\t: undefined\n\n\treturn (\n\t\t<div\n\t\t\tclassName={['field-type', showError && 'error', readOnly && 'read-only']\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(' ')}\n\t\t\tid={path ? `field-${path.replace(/\\./g, '__')}` : undefined}\n\t\t\tstyle={fieldStyle}\n\t\t>\n\t\t\t<RenderCustomComponent\n\t\t\t\tCustomComponent={Label}\n\t\t\t\tFallback={\n\t\t\t\t\t<FieldLabel\n\t\t\t\t\t\tlabel={label}\n\t\t\t\t\t\tlocalized={props.field?.localized}\n\t\t\t\t\t\tpath={path}\n\t\t\t\t\t\trequired={props.field?.required}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<div className=\"field-type__wrap\">\n\t\t\t\t<RenderCustomComponent\n\t\t\t\t\tCustomComponent={ErrorComponent}\n\t\t\t\t\tFallback={<FieldError path={path} showError={showError} />}\n\t\t\t\t/>\n\t\t\t\t<ReactSelect\n\t\t\t\t\toptions={groupedOptions}\n\t\t\t\t\tvalue={selected}\n\t\t\t\t\tisMulti\n\t\t\t\t\tisSortable\n\t\t\t\t\tisCreatable={allowCustom}\n\t\t\t\t\tisClearable={!readOnly}\n\t\t\t\t\tdisabled={readOnly}\n\t\t\t\t\tisLoading={state.status === 'loading'}\n\t\t\t\t\tshowError={showError}\n\t\t\t\t\tplaceholder={state.status === 'loading' ? t(keys.endpointOptionsLoading) : undefined}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tfilterOption={(option, rawInput) => {\n\t\t\t\t\t\tif (!option) {\n\t\t\t\t\t\t\treturn allowCustom && isPlausibleEmail(rawInput)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst query = rawInput.toLowerCase()\n\t\t\t\t\t\treturn `${option.label} ${option.value}`.toLowerCase().includes(query)\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<RenderCustomComponent\n\t\t\t\tCustomComponent={Description}\n\t\t\t\tFallback={\n\t\t\t\t\t<FieldDescription\n\t\t\t\t\t\tdescription={state.status === 'error' ? t(keys.endpointOptionsError) : description}\n\t\t\t\t\t\tpath={path}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;AAuDA,MAAM,sBAAsB,OAAwC,aACnE,OAAO,UAAU,WAAW,QAAS,MAAM,aAAa,MAAM,MAAM,OAAO,OAAO,KAAK,EAAE,MAAM;AAMhG,MAAM,wBACL,MACA,UACyB;CACzB,MAAM,OAAO,MAAM,QAAQ,KAAK,MAAM,IAAK,KAAK,SAAuB,CAAC;CACxE,MAAM,yBAAS,IAAI,IAAoB;CACvC,KAAK,MAAM,OAAO,MAAM;EACvB,IAAI,CAAC,OAAO,OAAO,QAAQ,UAC1B;EAED,MAAM,EAAE,MAAM,UAAU;E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IAAI,OAAO,SAAS,KAAK,QAAQ,OAAO,IAAI,MAAM,KAAA;EAClD,OAAO;YALR;GAOC,oBAAC,uBAAD;IACC,iBAAiB;IACjB,UACC,oBAAC,YAAD;KACQ;KACP,WAAW,MAAM,OAAO;KAClB;KACN,UAAU,MAAM,OAAO;IACvB,CAAA;GAEF,CAAA;GACD,qBAAC,OAAD;IAAK,WAAU;cAAf,CACC,oBAAC,uBAAD;KACC,iBAAiB;KACjB,UAAU,oBAAC,YAAD;MAAkB;MAAiB;KAAY,CAAA;IACzD,CAAA,GACD,oBAAC,aAAD;KACC,SAAS;KACT,OAAO;KACP,SAAA;KACA,YAAA;KACA,aAAa;KACb,aAAa,CAAC;KACd,UAAU;KACV,WAAW,MAAM,WAAW;KACjB;KACX,aAAa,MAAM,WAAW,YAAY,EAAE,KAAK,sBAAsB,IAAI,KAAA;KAC3E,UAAU;KACV,eAAe,QAAQ,aAAa;MACnC,IAAI,CAAC,QACJ,OAAO,eAAe,iBAAiB,QAAQ;MAEhD,MAAM,QAAQ,SAAS,YAAY;MACnC,OAAO,GAAG,OAAO,MAAM,GAAG,OAAO,QAAQ,YAAY,EAAE,SAAS,KAAK;KACtE;IACA,CAAA,CACG;;GACL,oBAAC,uBAAD;IACC,iBAAiB;IACjB,UACC,oBAAC,kBAAD;KACC,aAAa,MAAM,WAAW,UAAU,EAAE,KAAK,oBAAoB,IAAI;KACjE;IACN,CAAA;GAEF,CAAA;EACG;;AAEP"}
@@ -15,7 +15,7 @@ type RuleDescriptionProps = {
15
15
  */
16
16
  declare const RuleDescription: ({
17
17
  descriptionKey
18
- }: RuleDescriptionProps) => import("react/jsx-runtime").JSX.Element;
18
+ }: RuleDescriptionProps) => import("react").JSX.Element;
19
19
  //#endregion
20
20
  export { RuleDescription };
21
21
  //# sourceMappingURL=RuleDescription.d.ts.map
@@ -9,7 +9,7 @@ type FieldCountCellProps = {
9
9
  */
10
10
  declare const FieldCountCell: ({
11
11
  cellData
12
- }: FieldCountCellProps) => import("react/jsx-runtime").JSX.Element;
12
+ }: FieldCountCellProps) => import("react").JSX.Element;
13
13
  //#endregion
14
14
  export { FieldCountCell };
15
15
  //# sourceMappingURL=FieldCountCell.d.ts.map
@@ -8,7 +8,7 @@ type FlowStepsCellProps = {
8
8
  /** List-view cell for the `flow` json field: a localized step count instead of raw JSON. */
9
9
  declare const FlowStepsCell: ({
10
10
  cellData
11
- }: FlowStepsCellProps) => import("react/jsx-runtime").JSX.Element;
11
+ }: FlowStepsCellProps) => import("react").JSX.Element;
12
12
  //#endregion
13
13
  export { FlowStepsCell };
14
14
  //# sourceMappingURL=FlowStepsCell.d.ts.map
@@ -164,7 +164,7 @@ declare const Form: ({
164
164
  nextButtonClassName,
165
165
  backButtonClassName,
166
166
  adapters
167
- }: FormProps) => import("react/jsx-runtime").JSX.Element;
167
+ }: FormProps) => import("react").JSX.Element;
168
168
  //#endregion
169
169
  export { Form, FormCollections, FormProps, FormSuccessResponse, FormSuccessResult };
170
170
  //# sourceMappingURL=Form.d.ts.map
@@ -49,7 +49,7 @@ declare const FormControls: ({
49
49
  renderBack,
50
50
  renderNext,
51
51
  renderSubmit
52
- }: FormControlsProps) => import("react/jsx-runtime").JSX.Element;
52
+ }: FormControlsProps) => import("react").JSX.Element;
53
53
  //#endregion
54
54
  export { BackButtonRenderProps, FormControls, FormControlsProps, NextButtonRenderProps, SubmitButtonRenderProps };
55
55
  //# sourceMappingURL=FormControls.d.ts.map
@@ -12,7 +12,7 @@ type FormFieldsProps = {
12
12
  declare const FormFields: ({
13
13
  layout,
14
14
  className
15
- }: FormFieldsProps) => import("react/jsx-runtime").JSX.Element;
15
+ }: FormFieldsProps) => import("react").JSX.Element;
16
16
  //#endregion
17
17
  export { FormFields, FormFieldsProps };
18
18
  //# sourceMappingURL=FormFields.d.ts.map
@@ -12,7 +12,7 @@ declare const FormLayout: ({
12
12
  children,
13
13
  enabled,
14
14
  className
15
- }: FormLayoutProps) => import("react/jsx-runtime").JSX.Element;
15
+ }: FormLayoutProps) => import("react").JSX.Element;
16
16
  /** Props to spread onto a field wrapper to declare its grid width. */
17
17
  declare const widthProps: (width: FieldWidth | undefined) => {
18
18
  'data-width': FieldWidth;
@@ -11,7 +11,7 @@ type FormStepsProps = {
11
11
  */
12
12
  declare const FormSteps: ({
13
13
  className
14
- }: FormStepsProps) => import("react/jsx-runtime").JSX.Element | null;
14
+ }: FormStepsProps) => import("react").JSX.Element | null;
15
15
  //#endregion
16
16
  export { FormSteps, FormStepsProps };
17
17
  //# sourceMappingURL=FormSteps.d.ts.map
@@ -16,7 +16,7 @@ type HoneypotProps = {
16
16
  declare const Honeypot: ({
17
17
  name,
18
18
  inputRef
19
- }: HoneypotProps) => import("react/jsx-runtime").JSX.Element;
19
+ }: HoneypotProps) => import("react").JSX.Element;
20
20
  //#endregion
21
21
  export { Honeypot, HoneypotProps };
22
22
  //# sourceMappingURL=Honeypot.d.ts.map
@@ -60,7 +60,7 @@ declare const Poll: ({
60
60
  currentVote,
61
61
  renderResults,
62
62
  ...formProps
63
- }: PollProps) => import("react/jsx-runtime").JSX.Element | null;
63
+ }: PollProps) => import("react").JSX.Element | null;
64
64
  //#endregion
65
65
  export { Poll, PollProps };
66
66
  //# sourceMappingURL=Poll.d.ts.map
@@ -25,7 +25,7 @@ declare const HcaptchaCaptcha: ({
25
25
  scriptSrc,
26
26
  adapters,
27
27
  ref
28
- }: HcaptchaCaptchaProps) => import("react/jsx-runtime").JSX.Element;
28
+ }: HcaptchaCaptchaProps) => import("react").JSX.Element;
29
29
  //#endregion
30
30
  export { HCAPTCHA_SCRIPT_URL, HcaptchaCaptcha, HcaptchaCaptchaProps };
31
31
  //# sourceMappingURL=HcaptchaCaptcha.d.ts.map
@@ -38,7 +38,7 @@ declare const RecaptchaCaptcha: ({
38
38
  scriptSrc,
39
39
  adapters,
40
40
  ref
41
- }: RecaptchaCaptchaProps) => import("react/jsx-runtime").JSX.Element;
41
+ }: RecaptchaCaptchaProps) => import("react").JSX.Element;
42
42
  //#endregion
43
43
  export { RECAPTCHA_SCRIPT_URL, RecaptchaCaptcha, RecaptchaCaptchaHandle, RecaptchaCaptchaProps };
44
44
  //# sourceMappingURL=RecaptchaCaptcha.d.ts.map
@@ -25,7 +25,7 @@ declare const TurnstileCaptcha: ({
25
25
  scriptSrc,
26
26
  adapters,
27
27
  ref
28
- }: TurnstileCaptchaProps) => import("react/jsx-runtime").JSX.Element;
28
+ }: TurnstileCaptchaProps) => import("react").JSX.Element;
29
29
  //#endregion
30
30
  export { TURNSTILE_SCRIPT_URL, TurnstileCaptcha, TurnstileCaptchaProps };
31
31
  //# sourceMappingURL=TurnstileCaptcha.d.ts.map
@@ -24,7 +24,7 @@ declare const Checkbox: ({
24
24
  describedById,
25
25
  ariaLabel,
26
26
  variant
27
- }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
27
+ }: CheckboxProps) => import("react").JSX.Element;
28
28
  //#endregion
29
29
  export { Checkbox, CheckboxProps };
30
30
  //# sourceMappingURL=Checkbox.d.ts.map
@@ -34,7 +34,7 @@ declare const ChoiceGroup: ({
34
34
  describedById,
35
35
  labelledById,
36
36
  variant
37
- }: ChoiceGroupProps) => import("react/jsx-runtime").JSX.Element;
37
+ }: ChoiceGroupProps) => import("react").JSX.Element;
38
38
  //#endregion
39
39
  export { ChoiceGroup, ChoiceGroupProps, ChoiceOption };
40
40
  //# sourceMappingURL=ChoiceGroup.d.ts.map
@@ -33,7 +33,7 @@ declare const FieldShell: ({
33
33
  describedById,
34
34
  group,
35
35
  children
36
- }: FieldShellProps) => import("react/jsx-runtime").JSX.Element;
36
+ }: FieldShellProps) => import("react").JSX.Element;
37
37
  //#endregion
38
38
  export { FieldShell, FieldShellProps };
39
39
  //# sourceMappingURL=FieldShell.d.ts.map
@@ -26,7 +26,7 @@ declare const Input: ({
26
26
  invalid,
27
27
  describedById,
28
28
  autoComplete
29
- }: InputProps) => import("react/jsx-runtime").JSX.Element;
29
+ }: InputProps) => import("react").JSX.Element;
30
30
  //#endregion
31
31
  export { Input, InputProps };
32
32
  //# sourceMappingURL=Input.d.ts.map
@@ -28,7 +28,7 @@ declare const Select: ({
28
28
  invalid,
29
29
  describedById,
30
30
  placeholder
31
- }: SelectProps) => import("react/jsx-runtime").JSX.Element;
31
+ }: SelectProps) => import("react").JSX.Element;
32
32
  //#endregion
33
33
  export { Select, SelectOption, SelectProps };
34
34
  //# sourceMappingURL=Select.d.ts.map
@@ -22,7 +22,7 @@ declare const Textarea: ({
22
22
  disabled,
23
23
  invalid,
24
24
  describedById
25
- }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
25
+ }: TextareaProps) => import("react").JSX.Element;
26
26
  //#endregion
27
27
  export { Textarea, TextareaProps };
28
28
  //# sourceMappingURL=Textarea.d.ts.map
@@ -8,7 +8,7 @@ import { UIFieldServerProps } from "payload";
8
8
  declare const SubmissionAnswers: ({
9
9
  data,
10
10
  req
11
- }: UIFieldServerProps) => import("react/jsx-runtime").JSX.Element;
11
+ }: UIFieldServerProps) => import("react").JSX.Element;
12
12
  //#endregion
13
13
  export { SubmissionAnswers };
14
14
  //# sourceMappingURL=SubmissionAnswers.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@10x-media/form-builder",
3
- "version": "4.0.0-alpha.2",
3
+ "version": "4.0.0-alpha.3",
4
4
  "description": "End-to-end forms platform for Payload: author, validate, render, collect, aggregate, and act.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -67,9 +67,9 @@
67
67
  "LICENSE"
68
68
  ],
69
69
  "peerDependencies": {
70
- "@payloadcms/db-postgres": "^4.0.0-beta.7",
71
- "@payloadcms/ui": "^4.0.0-beta.7",
72
- "payload": "^4.0.0-beta.7",
70
+ "@payloadcms/db-postgres": "^4.0.0-beta.10",
71
+ "@payloadcms/ui": "^4.0.0-beta.10",
72
+ "payload": "^4.0.0-beta.10",
73
73
  "react": "^19.0.0",
74
74
  "react-dom": "^19.0.0"
75
75
  },
@@ -84,31 +84,31 @@
84
84
  },
85
85
  "devDependencies": {
86
86
  "@axe-core/playwright": "^4.11.3",
87
- "@payloadcms/db-mongodb": "4.0.0-beta.7",
88
- "@payloadcms/db-postgres": "4.0.0-beta.7",
89
- "@payloadcms/richtext-lexical": "4.0.0-beta.7",
90
- "@payloadcms/ui": "4.0.0-beta.7",
87
+ "@payloadcms/db-mongodb": "4.0.0-beta.10",
88
+ "@payloadcms/db-postgres": "4.0.0-beta.10",
89
+ "@payloadcms/richtext-lexical": "4.0.0-beta.10",
90
+ "@payloadcms/ui": "4.0.0-beta.10",
91
91
  "@playwright/test": "1.60.0",
92
92
  "@testing-library/jest-dom": "^6.6.3",
93
93
  "@testing-library/react": "^16.1.0",
94
94
  "@types/node": "24.19.2",
95
- "@types/react": "19.2.15",
96
- "@types/react-dom": "19.2.3",
95
+ "@types/react": "19.3.0",
96
+ "@types/react-dom": "19.3.0",
97
97
  "@types/to-snake-case": "1.0.0",
98
98
  "axe-core": "^4.12.1",
99
99
  "jsdom": "^25.0.1",
100
100
  "msw": "^2.14.6",
101
- "payload": "4.0.0-beta.7",
101
+ "payload": "4.0.0-beta.10",
102
102
  "playwright": "1.60.0",
103
- "react": "19.2.6",
104
- "react-dom": "19.2.6",
103
+ "react": "19.3.1",
104
+ "react-dom": "19.3.1",
105
105
  "shadcn": "^2.4.0",
106
106
  "tsdown": "0.22.1",
107
107
  "typescript": "5.9.3",
108
108
  "vitest": "4.1.7",
109
109
  "@10x-media/payload-test-harness": "0.0.0",
110
- "@10x-media/tsdown-config": "0.0.0",
111
110
  "@10x-media/tsconfig": "0.0.0",
111
+ "@10x-media/tsdown-config": "0.0.0",
112
112
  "@10x-media/vitest-config": "0.0.0"
113
113
  },
114
114
  "publishConfig": {