@10x-media/form-builder 4.0.0-alpha.1 → 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.
- package/CHANGELOG.md +20 -0
- package/README.md +1 -1
- package/dist/client/ByteSizeField.d.ts +1 -1
- package/dist/client/CalcExpressionBuilder.d.ts +1 -1
- package/dist/client/CalcExpressionBuilder.js +2 -2
- package/dist/client/CalcExpressionBuilder.js.map +1 -1
- package/dist/client/ClosePollButton.d.ts +1 -1
- package/dist/client/CondensedArray.d.ts +1 -1
- package/dist/client/ConditionBuilder.js +2 -2
- package/dist/client/ConditionBuilder.js.map +1 -1
- package/dist/client/ConsentBlockLabel.d.ts +1 -1
- package/dist/client/ConsentRetentionNotice.d.ts +1 -1
- package/dist/client/ConsentSourceRowLabel.d.ts +1 -1
- package/dist/client/EndpointOptionsSelect.d.ts +1 -1
- package/dist/client/FieldBlockLabel.d.ts +1 -1
- package/dist/client/FieldNameSelect.d.ts +1 -1
- package/dist/client/FieldNameSelect.js +2 -2
- package/dist/client/FieldNameSelect.js.map +1 -1
- package/dist/client/FlowBuilder.d.ts +1 -1
- package/dist/client/FlowBuilder.js +2 -2
- package/dist/client/FlowBuilder.js.map +1 -1
- package/dist/client/FormConditionField.d.ts +1 -1
- package/dist/client/RecipientsSelect.d.ts +1 -1
- package/dist/client/RecipientsSelect.js +2 -2
- package/dist/client/RecipientsSelect.js.map +1 -1
- package/dist/client/RuleDescription.d.ts +1 -1
- package/dist/collections/cells/FieldCountCell.d.ts +1 -1
- package/dist/collections/cells/FlowStepsCell.d.ts +1 -1
- package/dist/exports/shared.d.ts +21 -0
- package/dist/exports/shared.js +18 -0
- package/dist/form/toFormDocument.d.ts +10 -6
- package/dist/form/toFormDocument.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/options.d.ts +6 -0
- package/dist/react/Form.d.ts +1 -1
- package/dist/react/FormControls.d.ts +1 -1
- package/dist/react/FormFields.d.ts +1 -1
- package/dist/react/FormLayout.d.ts +1 -1
- package/dist/react/FormSteps.d.ts +1 -1
- package/dist/react/Honeypot.d.ts +1 -1
- package/dist/react/Poll.d.ts +1 -1
- package/dist/react/captcha/HcaptchaCaptcha.d.ts +1 -1
- package/dist/react/captcha/RecaptchaCaptcha.d.ts +1 -1
- package/dist/react/captcha/TurnstileCaptcha.d.ts +1 -1
- package/dist/react/primitives/Checkbox.d.ts +1 -1
- package/dist/react/primitives/ChoiceGroup.d.ts +1 -1
- package/dist/react/primitives/FieldShell.d.ts +1 -1
- package/dist/react/primitives/Input.d.ts +1 -1
- package/dist/react/primitives/Select.d.ts +1 -1
- package/dist/react/primitives/Textarea.d.ts +1 -1
- package/dist/submissions/SubmissionAnswers.d.ts +1 -1
- package/package.json +19 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
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
|
+
|
|
11
|
+
## 4.0.0-alpha.2
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- The plugin takes an `order` option, so a host can move it when another plugin has to run on the other side of it, as content-lock already allowed. admin-wiki keeps `order: 1000` by default; lowering it lets a plugin on the default order see `wiki-pages` and `wiki-media` (a storage adapter, document-preview), at the cost of the config walk no longer seeing that plugin's collections and fields. form-builder keeps `50` and webhooks `10`.
|
|
16
|
+
|
|
17
|
+
- A new `./shared` entry exports the helpers with no server and no React dependency (key formats and parsers, constants, error names and guards, formatters), for a host module that both server code and client components import. On Payload 4 the browser build of `payload` is `payload/shared`, so a client bundle that reaches the root fails on `definePlugin` and the Local API, and a server caller of a `'use client'` entry gets a client reference instead of the function. The root and the client entries keep exporting the same helpers.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- `toFormDocument` accepts a generated form type whose blocks set an `interfaceName`, with no cast. Its `fields` parameter had an index signature, which no generated block interface satisfies.
|
|
22
|
+
|
|
3
23
|
## 4.0.0-alpha.1
|
|
4
24
|
|
|
5
25
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
An end-to-end forms platform for Payload: author forms in the admin, validate server-side, render headless on your frontend, collect typed submissions, aggregate results, and act on them. Simple by default for editors, with a definition seam (`defineFormField`, `defineValidationRule`, `defineAction`, and friends) wherever developers need depth, and 100% native to Payload.
|
|
11
11
|
|
|
12
|
-
[](https://www.npmjs.com/package/@10x-media/form-builder)
|
|
12
|
+
[](https://www.npmjs.com/package/@10x-media/form-builder)
|
|
13
13
|
|
|
14
14
|
Part of the [@10x-media Payload plugins](https://github.com/10x-media/payload-plugins) collection. In alpha on this branch: published under the `alpha` dist-tag until Payload 4 is stable.
|
|
15
15
|
|
|
@@ -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
|
|
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
|
|
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 {
|
|
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(
|
|
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;G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C,SAAD;OAAO,WAAU;OAAqB,SAAS,GAAG,OAAO;iBACvD,EAAE,KAAK,oBAAoB;MACtB,CAAA;MACP,oBAAC,aAAD;OACC,WAAU;OACV,SAAS,GAAG,OAAO;OACnB,SACC,gBACC,cACA,qBACA,EAAE,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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,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"}
|
|
@@ -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
|
|
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
|
|
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 {
|
|
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(
|
|
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 {
|
|
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,E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QAAQ;cAEP,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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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(
|
|
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 {
|
|
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\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,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;CAEA,QADc,QAAQ,iBAAiB,KAAK,QAAQ,KAAK,IAAI,WAAW,KAAK,MAAM,GACtE,KAAK,UAAU;EAC3B,OAAO,OAAO,IAAI,IAAI,KAAK;EAC3B,OAAO;CACR,EAAE;AACH;;;;;;;;AASA,MAAa,mBAAmB,UAAgC;CAC/D,MAAM,EAAE,MAAM,UAAU,UAAU,SAAiB,EAAE,MAAM,MAAM,KAAK,CAAC;CACvE,MAAM,QAAQ,cAAc,MAAM,OAAO,SAAS,MAAM,KAAK;CAC7D,MAAM,EAAE,MAAMA,iBAAe;CAC7B,MAAM,cAAc,MAAM,iBACvB,EAAE,MAAM,cAAc,IACtB,cAAc,MAAM,OAAO,OAAO,WAAW;CAEhD,MAAM,cAAc,eAAe,CAAC,YACnC,KAAK,UAAU,gBAAgB,qBAAqB,QAAQ,IAAI,GAAG,MAAM,KAAK,CAAC,CAChF;CACA,MAAM,UAAU,cAAc,KAAK,MAAM,WAAW,GAA0B,CAAC,WAAW,CAAC;CAE3F,MAAM,aACL,SAAS,CAAC,QAAQ,MAAM,WAAW,OAAO,UAAU,KAAK,IACtD,CAAC,GAAG,SAAS;EAAE,OAAO;EAAO;CAAM,CAAC,IACpC;CAEJ,MAAM,gBAAgB,aAA6D;EAClF,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
|
|
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 {
|
|
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(
|
|
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 ?? [];
|