@lmb-it/kitsconcerto-native 0.1.271 → 0.1.273
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/components/Avatar/index.cjs +49 -3
- package/components/Avatar/index.cjs.map +1 -1
- package/components/Avatar/index.js +49 -3
- package/components/Avatar/index.js.map +1 -1
- package/components/Gallery/index.cjs +57 -1
- package/components/Gallery/index.cjs.map +1 -1
- package/components/Gallery/index.js +57 -1
- package/components/Gallery/index.js.map +1 -1
- package/form-renderer/components/FormRenderer/index.cjs +2 -1
- package/form-renderer/components/FormRenderer/index.cjs.map +1 -1
- package/form-renderer/components/FormRenderer/index.js +2 -1
- package/form-renderer/components/FormRenderer/index.js.map +1 -1
- package/form-renderer/components/fields/Group/index.cjs +3 -1
- package/form-renderer/components/fields/Group/index.cjs.map +1 -1
- package/form-renderer/components/fields/Group/index.js +3 -1
- package/form-renderer/components/fields/Group/index.js.map +1 -1
- package/form-renderer/components/fields/Object/index.cjs +5 -3
- package/form-renderer/components/fields/Object/index.cjs.map +1 -1
- package/form-renderer/components/fields/Object/index.js +5 -3
- package/form-renderer/components/fields/Object/index.js.map +1 -1
- package/form-renderer/hooks/useFieldLogic.cjs +0 -1
- package/form-renderer/hooks/useFieldLogic.cjs.map +1 -1
- package/form-renderer/hooks/useFieldLogic.js +0 -1
- package/form-renderer/hooks/useFieldLogic.js.map +1 -1
- package/index.d.ts +23 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFieldLogic.js","sources":["../../../../src/form-renderer/hooks/useFieldLogic.ts"],"sourcesContent":["import {useCallback, useEffect, useMemo, useRef} from 'react';\nimport {type FieldValues, useController, useFormContext, type UseFormReturn} from 'react-hook-form';\nimport {Schema} from 'yup';\n\n// Assuming your types are consolidated in a central file.\nimport type {\n IElementStyle,\n IFormElement,\n ILabelElement,\n ITextFieldProps,\n LogicFunction,\n UseFieldLogicProps,\n UseFieldLogicReturn\n} from '@lmb-it/kitsconcerto-types';\nimport {dynamicList} from \"../utils\";\nimport _ from \"lodash\";\n\n// --- Hook Return Value ---\n\n/**\n * The core logic engine for an individual form field.\n * This hook replaces LogicContext and FormFieldContext. It watches dependencies,\n * calculates all dynamic properties (visibility, disabled state, required status, etc.),\n * and provides the necessary props from react-hook-form.\n *\n * @param {UseFieldLogicProps<T>} props - The element definition and form control.\n * @returns {UseFieldLogicReturn<T>} An object containing all necessary props and states for rendering the field.\n */\nexport const useFieldLogic = <T extends FieldValues>({\n element: {onDepsChange, ...element},\n control,\n getValues,\n isFocused,\n groupField,\n watchedValues\n }: UseFieldLogicProps<T>): UseFieldLogicReturn<T> => {\n\n\n const formContext = useFormContext<T>()\n\n const prevDepsRef = useRef<string>(\"\");\n\n const watchedSig = useMemo(() => JSON.stringify(watchedValues), [watchedValues]);\n\n const allFormValues = useMemo(() => getValues(), [getValues, watchedSig]);\n\n /*const watchedObject = useMemo(() => {\n return dependencies.reduce((acc, dep, index) => {\n acc[dep] = watchedValues[index];\n return acc;\n }, {} as any)\n }, [watchedValues, dependencies])*/\n\n const childElements = useMemo(() => {\n if (!('elements' in element)) {\n return [];\n }\n const elements = element.elements;\n if (typeof elements === 'function') {\n return (elements as LogicFunction<T>)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return elements;\n /*\n * ⛔ `element` BELONGS HERE BECAUSE THE BODY READS IT. Without it this\n * memo returns the children captured on the FIRST render and never\n * looks at `element` again — so a container (Object, Group) freezes\n * its whole subtree at mount.\n *\n * What that cost: AlphaMatch's profile screen mounts with\n * `list: []` and is handed 250 nationalities about a second later.\n * The parent rebuilds its element array, the new array reaches the\n * container, and this memo hands the children the OLD one. The\n * device log says `items=250` and the picker draws nothing —\n * because the picker was still holding the empty list.\n *\n * ⚠️ A top-level Select never showed this. It is not a container, so\n * it does not come through here at all; its props are resolved per\n * render. Only a field nested in an Object or a Group was affected,\n * which is why a harness that put the Select at the top level\n * reported the case clear.\n */\n }, [element, watchedValues])\n\n const resolvedProps = useMemo(() => {\n const getDynamicProp = (propName: keyof IFormElement<T> | string) => {\n const propValue: LogicFunction<T> = (element as any)[propName];\n if (typeof propValue === 'function') {\n return propValue(watchedValues, allFormValues, formContext, groupField);\n }\n return propValue;\n };\n\n return {\n helperText: getDynamicProp('helperText'),\n leftAddon: getDynamicProp('leftAddon'),\n rightAddon: getDynamicProp('rightAddon'),\n keyFilter: getDynamicProp('keyFilter') as ITextFieldProps<T>['keyFilter'],\n withMask: getDynamicProp('withMask'),\n // ... resolve other dynamic props here\n };\n }, [watchedValues, allFormValues, element, control, getValues]);\n\n const lastListRef = useRef<T[] | undefined>(undefined);\n const lastElementRef = useRef<any>(null);\n const lastWatchedRef = useRef<any>(null);\n\n const list = useMemo(() => {\n if (!(\"list\" in element)) return undefined;\n\n const elementChanged = !_.isEqual(lastElementRef.current, element);\n const watchedChanged = !_.isEqual(lastWatchedRef.current, watchedValues);\n\n // ✅ nothing meaningful changed → reuse\n if (!elementChanged && !watchedChanged) {\n return lastListRef.current;\n }\n\n // 🔁 rebuild\n const nextList = dynamicList<T>(\n element,\n watchedValues,\n allFormValues,\n groupField,\n formContext\n );\n\n lastElementRef.current = element;\n lastWatchedRef.current = watchedValues;\n lastListRef.current = nextList;\n\n return nextList;\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n // 4. Centralize dynamic property calculations using memoization.\n const isShown = useMemo(() => {\n // console.log({watchedObject, allFormValues})\n const showLogic = element.show || element.logic?.show;\n if (typeof showLogic === 'function') {\n return (showLogic as LogicFunction<T>)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return true;\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n const isDisabled = useMemo(() => {\n const disableLogic = element.isDisabled || element.logic?.disable;\n if (typeof disableLogic === 'function') {\n return (disableLogic as LogicFunction<T, boolean>)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return !!disableLogic;\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n const isRequired = useMemo(() => {\n if (!('schema' in element) || !element.schema) return false;\n\n const schema = element.schema as Schema<any>;\n\n const checkRequired = (schema: Schema<any>, parentValues: any): boolean => {\n try {\n const type = (schema as any)._type;\n\n const testValue = (() => {\n switch (type) {\n case 'array':\n return [];\n case 'object':\n return {};\n case 'boolean':\n return undefined;\n case 'number':\n return undefined;\n case 'date':\n return undefined;\n default:\n return ''; // string or unknown\n }\n })();\n // Try validating an empty string\n schema.validateSync(\n testValue, // simulating the field is empty\n {\n context: parentValues,\n // @ts-ignore\n parent: parentValues,\n abortEarly: false,\n }\n );\n\n return false; // Passed even when empty => not required\n } catch (err: any) {\n // if (element.id === 'count/ries') {\n // console.log(err.inner || err);\n // }\n\n if (err?.inner?.length) {\n return err.inner.some(\n (e: any) =>\n e.type === 'required' ||\n e.message?.toLowerCase().includes('required')\n );\n }\n\n return (\n err?.type === 'required' ||\n err?.message?.toLowerCase().includes('required')\n );\n }\n };\n\n // Get the parent object (either group or full form)\n const parent = groupField && groupField.index !== undefined\n ? getValues?.()?.[groupField.name]?.[groupField.index]\n : getValues?.();\n\n return checkRequired(schema, parent);\n }, [element, watchedValues, allFormValues]);\n\n const label = useMemo(() => {\n if (typeof element.label === 'function') {\n return (element.label as LogicFunction<T, ILabelElement>)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return element.label;\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n const placeholder = useMemo(() => {\n if ('placeholder' in element && typeof element.placeholder === 'function') {\n return (element.placeholder as LogicFunction<T, string>)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return ('placeholder' in element ? element.placeholder : undefined) as string | undefined;\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n const resolvedStyle = useMemo(() => {\n const s = 'style' in element ? element.style : undefined;\n\n if (s && typeof s === 'function') {\n return s(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return s;\n }, [watchedValues, allFormValues, control, getValues, element])\n\n // ─────────────────────────────────────────────────────────────\n // Dev-mode deprecation warning for the legacy `style` prop.\n // Fires ONCE per field-instance mount (guarded by hasWarnedRef +\n // empty deps) so it does not re-fire on keystrokes / re-renders /\n // theme changes / etc. The bridge below remains functional —\n // this is a soft deprecation only; runtime removal is deferred\n // to the next major version.\n // ─────────────────────────────────────────────────────────────\n const hasWarnedDeprecatedStyleRef = useRef(false);\n useEffect(() => {\n // `process` is undeclared on native (no @types/node) but the\n // bundler statically replaces it on both platforms in production\n // builds. Reading it via globalThis sidesteps the TS lookup\n // without changing the runtime behaviour.\n const nodeEnv = (globalThis as any)?.process?.env?.NODE_ENV;\n if (nodeEnv === 'production') return;\n if (hasWarnedDeprecatedStyleRef.current) return;\n if (!('style' in element) || (element as any).style === undefined) return;\n\n hasWarnedDeprecatedStyleRef.current = true;\n // eslint-disable-next-line no-console\n console.warn(\n `[KitsConcerto] Field \"${(element as any).id}\": the \"style\" prop is deprecated. ` +\n `Use \"slots\" instead. Migration: ` +\n `style.input → slots.root.style, ` +\n `style.container → slots.container.style, ` +\n `style.label → slots.label.style, ` +\n `style.helperText → slots.helperText.style, ` +\n `style.errorMessage → slots.error.style. ` +\n `This prop will be removed in the next major version.`\n );\n // Empty deps: warn once on mount only — element identity may\n // change every render (form re-constructs configs), so we\n // cannot key on it without re-firing the warning.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n /**\n * Merge explicit `slots` with `style` sub-keys.\n * IElementStyle sub-keys are bridged into the slot system so they\n * flow through useComponentDefaults → elementStyles → KitsContainer.\n * Priority: style sub-keys (lowest) < explicit slots (highest).\n */\n const slots = useMemo(() => {\n // 1. Resolve explicit slots (DynamicValue)\n const rawSlots = 'slots' in element ? element.slots : undefined;\n let explicitSlots: Record<string, { props?: any; style?: any }> | undefined;\n if (rawSlots && typeof rawSlots === 'function') {\n explicitSlots = (rawSlots as any)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n } else {\n explicitSlots = rawSlots as any;\n }\n\n // 2. Bridge IElementStyle sub-keys into slot format\n if (!resolvedStyle && !explicitSlots) return undefined;\n if (!resolvedStyle) return explicitSlots;\n\n const STYLE_TO_SLOT: Record<string, string> = {\n input: 'root',\n container: 'container',\n label: 'label',\n helperText: 'helperText',\n errorMessage: 'error',\n };\n\n const result: Record<string, { props?: any; style?: any }> = {};\n\n // First layer: style sub-keys (lower priority)\n for (const [styleKey, slotKey] of Object.entries(STYLE_TO_SLOT)) {\n const val = (resolvedStyle as any)[styleKey];\n if (val) {\n result[slotKey] = { style: val };\n }\n }\n\n // Second layer: explicit slots override\n if (explicitSlots) {\n for (const [key, slot] of Object.entries(explicitSlots)) {\n if (!result[key]) {\n result[key] = slot;\n } else {\n result[key] = {\n ...slot,\n style: { ...result[key].style, ...(slot.style || {}) },\n };\n }\n }\n }\n\n return Object.keys(result).length > 0 ? result : undefined;\n }, [watchedValues, allFormValues, control, getValues, element, resolvedStyle])\n\n // 6. Calculate layout properties.\n const layout = useMemo(() => {\n const getDynamicProp = (prop: any) => typeof prop === 'function'\n ? prop(watchedValues, allFormValues, {control, getValues})\n : prop;\n\n return {\n colSpan: getDynamicProp(element.logic?.colSpan ?? element.colSpan) ?? 12,\n rowSpan: getDynamicProp(element.rowSpan),\n columnGap: getDynamicProp(element.columnGap),\n rowGap: getDynamicProp(element.rowGap),\n colOffset: getDynamicProp(element.colOffset),\n area: getDynamicProp(element.area),\n };\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n\n /*\n * ⛔ IT READ FIVE VALUES AND DEPENDED ON ONE. The dependency array here\n * was `[watchedValues]` while the body reads `onDepsChange`,\n * `allFormValues`, `formContext` and `groupField` as well — so every\n * one of those four was frozen at the render that first built this\n * callback, and a caller would have handed the consumer stale form\n * values under a fresh `watchedValues`.\n *\n * ⚠️ IT IS THE SAME DEFECT AS THE ONE FIXED IN 0.1.261 TWENTY LINES UP,\n * where the children memo read `element.elements` while depending on\n * `[watchedValues]` alone and froze every field nested in a container.\n * That one cost two days of hunting on the App's nationality picker.\n * This is the second instance in the same hook, found while reading the\n * first, and it is fixed here rather than left for someone to meet.\n *\n * ⛔ AND NOTHING CALLS IT TODAY — that is a fact about the blast radius,\n * not a reason to leave it wrong. `onWatchedValuesChange` is returned\n * from this hook and declared optional in `internal.types.ts`, and a\n * sweep of this repo and of the App, ClientPortal and Dashboard finds no\n * invocation anywhere. The real work is done by the effect below, which\n * already carries the full dependency list. So there is no user-visible\n * symptom to reproduce and no story to film; there is a loaded trap for\n * the first caller, and this disarms it.\n */\n const onWatchedValuesChange = useCallback(() => {\n if (onDepsChange) {\n onDepsChange(watchedValues, allFormValues, formContext as UseFormReturn<T>, groupField)\n }\n }, [onDepsChange, watchedValues, allFormValues, formContext, groupField])\n\n // 7. Get the field's state and methods from react-hook-form.\n // For Object elements, default to {} so react-hook-form treats the field\n // as a nested object — children register with dot-notation paths\n // (e.g. contactPhone.phoneNumber) and build the nested structure.\n const isObjectElement = element.type === 'Object';\n const {field, fieldState} = useController({\n name: element.id as any,\n control,\n shouldUnregister: !isShown,\n ...(isObjectElement ? {defaultValue: {} as any} : {}),\n });\n\n useEffect(() => {\n if (!onDepsChange) return;\n\n // Create a stable signature for watched values\n // (stringify is fine here because deps lists are small)\n const sig = JSON.stringify(watchedValues);\n\n if (sig === prevDepsRef.current) return; // ✅ no real change\n\n prevDepsRef.current = sig;\n\n onDepsChange(watchedValues, allFormValues, formContext as UseFormReturn<T>, groupField);\n }, [onDepsChange, watchedValues, allFormValues, formContext, groupField]);\n\n // 8. Return a single, clean object for the UI component.\n return {\n field: {\n ...field,\n onChange: (event) => {\n if ('onChangeValue' in element && element?.onChangeValue) {\n const value = event != null && typeof event === 'object' && 'target' in event\n ? event.target.value\n : event;\n element.onChangeValue(\n value,\n {...fieldState, isFocused: !!isFocused},\n formContext\n )\n }\n field.onChange(event)\n }\n },\n fieldState,\n watchedValues,\n onWatchedValuesChange,\n elements: childElements,\n isShown,\n isDisabled,\n isRequired,\n hideError: element.hideError,\n label,\n placeholder,\n formContext,\n layout,\n list,\n style: resolvedStyle as IElementStyle,\n slots,\n ...resolvedProps,\n localProps: 'localProps' in element ? element?.localProps : undefined,\n attached: element.attached,\n animation: element.animation,\n };\n }\n;\n"],"names":["schema"],"mappings":";;;;;;AA4BO,MAAM,gBAAgB,CAAwB;AAAA,EACI,OAAA,EAAS,EAAC,YAAA,EAAc,GAAG,OAAA,EAAO;AAAA,EAClC,OAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA;AACJ,CAAA,KAAqD;AAGlG,EAAA,MAAM,cAAc,cAAA,EAAkB;AAEtC,EAAA,MAAM,WAAA,GAAc,OAAe,EAAE,CAAA;AAErC,EAAA,MAAM,UAAA,GAAa,QAAQ,MAAM,IAAA,CAAK,UAAU,aAAa,CAAA,EAAG,CAAC,aAAa,CAAC,CAAA;AAE/E,EAAA,MAAM,aAAA,GAAgB,QAAQ,MAAM,SAAA,IAAa,CAAC,SAAA,EAAW,UAAU,CAAC,CAAA;AASxE,EAAA,MAAM,aAAA,GAAgB,QAAQ,MAAM;AAChC,IAAA,IAAI,EAAE,cAAc,OAAA,CAAA,EAAU;AAC1B,MAAA,OAAO,EAAC;AAAA,IACZ;AACA,IAAA,MAAM,WAAW,OAAA,CAAQ,QAAA;AACzB,IAAA,IAAI,OAAO,aAAa,UAAA,EAAY;AAChC,MAAA,OAAQ,QAAA,CAA8B,eAAe,aAAA,EAAe;AAAA,QAChE,OAAA;AAAA,QACA,SAAA;AAAA,QACA,UAAU,WAAA,CAAY;AAAA,SAChB,UAAU,CAAA;AAAA,IACxB;AACA,IAAA,OAAO,QAAA;AAAA,EAoBX,CAAA,EAAG,CAAC,OAAA,EAAS,aAAa,CAAC,CAAA;AAE3B,EAAA,MAAM,aAAA,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ACA,WAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,EAAO,aAAA;AAAA,IACP,KAAA;AAAA,IACA,GAAG,aAAA;AAAA,IACH,UAAA,EAAY,YAAA,IAAgB,OAAA,GAAU,OAAA,EAAS,UAAA,GAAa,MAAA;AAAA,IAC5D,UAAU,OAAA,CAAQ,QAAA;AAAA,IAClB,WAAW,OAAA,CAAQ;AAAA,GACvB;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"useFieldLogic.js","sources":["../../../../src/form-renderer/hooks/useFieldLogic.ts"],"sourcesContent":["import {useCallback, useEffect, useMemo, useRef} from 'react';\nimport {type FieldValues, useController, useFormContext, type UseFormReturn} from 'react-hook-form';\nimport {Schema} from 'yup';\n\n// Assuming your types are consolidated in a central file.\nimport type {\n IElementStyle,\n IFormElement,\n ILabelElement,\n ITextFieldProps,\n LogicFunction,\n UseFieldLogicProps,\n UseFieldLogicReturn\n} from '@lmb-it/kitsconcerto-types';\nimport {dynamicList} from \"../utils\";\nimport _ from \"lodash\";\n\n// --- Hook Return Value ---\n\n/**\n * The core logic engine for an individual form field.\n * This hook replaces LogicContext and FormFieldContext. It watches dependencies,\n * calculates all dynamic properties (visibility, disabled state, required status, etc.),\n * and provides the necessary props from react-hook-form.\n *\n * @param {UseFieldLogicProps<T>} props - The element definition and form control.\n * @returns {UseFieldLogicReturn<T>} An object containing all necessary props and states for rendering the field.\n */\nexport const useFieldLogic = <T extends FieldValues>({\n element: {onDepsChange, ...element},\n control,\n getValues,\n isFocused,\n groupField,\n watchedValues\n }: UseFieldLogicProps<T>): UseFieldLogicReturn<T> => {\n\n\n const formContext = useFormContext<T>()\n\n const prevDepsRef = useRef<string>(\"\");\n\n const watchedSig = useMemo(() => JSON.stringify(watchedValues), [watchedValues]);\n\n const allFormValues = useMemo(() => getValues(), [getValues, watchedSig]);\n\n /*const watchedObject = useMemo(() => {\n return dependencies.reduce((acc, dep, index) => {\n acc[dep] = watchedValues[index];\n return acc;\n }, {} as any)\n }, [watchedValues, dependencies])*/\n\n const childElements = useMemo(() => {\n if (!('elements' in element)) {\n return [];\n }\n const elements = element.elements;\n if (typeof elements === 'function') {\n return (elements as LogicFunction<T>)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return elements;\n /*\n * ⛔ `element` BELONGS HERE BECAUSE THE BODY READS IT. Without it this\n * memo returns the children captured on the FIRST render and never\n * looks at `element` again — so a container (Object, Group) freezes\n * its whole subtree at mount.\n *\n * What that cost: AlphaMatch's profile screen mounts with\n * `list: []` and is handed 250 nationalities about a second later.\n * The parent rebuilds its element array, the new array reaches the\n * container, and this memo hands the children the OLD one. The\n * device log says `items=250` and the picker draws nothing —\n * because the picker was still holding the empty list.\n *\n * ⚠️ A top-level Select never showed this. It is not a container, so\n * it does not come through here at all; its props are resolved per\n * render. Only a field nested in an Object or a Group was affected,\n * which is why a harness that put the Select at the top level\n * reported the case clear.\n */\n }, [element, watchedValues])\n\n const resolvedProps = useMemo(() => {\n const getDynamicProp = (propName: keyof IFormElement<T> | string) => {\n const propValue: LogicFunction<T> = (element as any)[propName];\n if (typeof propValue === 'function') {\n return propValue(watchedValues, allFormValues, formContext, groupField);\n }\n return propValue;\n };\n\n return {\n helperText: getDynamicProp('helperText'),\n leftAddon: getDynamicProp('leftAddon'),\n rightAddon: getDynamicProp('rightAddon'),\n keyFilter: getDynamicProp('keyFilter') as ITextFieldProps<T>['keyFilter'],\n withMask: getDynamicProp('withMask'),\n // ... resolve other dynamic props here\n };\n }, [watchedValues, allFormValues, element, control, getValues]);\n\n const lastListRef = useRef<T[] | undefined>(undefined);\n const lastElementRef = useRef<any>(null);\n const lastWatchedRef = useRef<any>(null);\n\n const list = useMemo(() => {\n if (!(\"list\" in element)) return undefined;\n\n const elementChanged = !_.isEqual(lastElementRef.current, element);\n const watchedChanged = !_.isEqual(lastWatchedRef.current, watchedValues);\n\n // ✅ nothing meaningful changed → reuse\n if (!elementChanged && !watchedChanged) {\n return lastListRef.current;\n }\n\n // 🔁 rebuild\n const nextList = dynamicList<T>(\n element,\n watchedValues,\n allFormValues,\n groupField,\n formContext\n );\n\n lastElementRef.current = element;\n lastWatchedRef.current = watchedValues;\n lastListRef.current = nextList;\n\n return nextList;\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n // 4. Centralize dynamic property calculations using memoization.\n const isShown = useMemo(() => {\n // console.log({watchedObject, allFormValues})\n const showLogic = element.show || element.logic?.show;\n if (typeof showLogic === 'function') {\n return (showLogic as LogicFunction<T>)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return true;\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n const isDisabled = useMemo(() => {\n const disableLogic = element.isDisabled || element.logic?.disable;\n if (typeof disableLogic === 'function') {\n return (disableLogic as LogicFunction<T, boolean>)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return !!disableLogic;\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n const isRequired = useMemo(() => {\n if (!('schema' in element) || !element.schema) return false;\n\n const schema = element.schema as Schema<any>;\n\n const checkRequired = (schema: Schema<any>, parentValues: any): boolean => {\n try {\n const type = (schema as any)._type;\n\n const testValue = (() => {\n switch (type) {\n case 'array':\n return [];\n case 'object':\n return {};\n case 'boolean':\n return undefined;\n case 'number':\n return undefined;\n case 'date':\n return undefined;\n default:\n return ''; // string or unknown\n }\n })();\n // Try validating an empty string\n schema.validateSync(\n testValue, // simulating the field is empty\n {\n context: parentValues,\n // @ts-ignore\n parent: parentValues,\n abortEarly: false,\n }\n );\n\n return false; // Passed even when empty => not required\n } catch (err: any) {\n // if (element.id === 'count/ries') {\n // console.log(err.inner || err);\n // }\n\n if (err?.inner?.length) {\n return err.inner.some(\n (e: any) =>\n e.type === 'required' ||\n e.message?.toLowerCase().includes('required')\n );\n }\n\n return (\n err?.type === 'required' ||\n err?.message?.toLowerCase().includes('required')\n );\n }\n };\n\n // Get the parent object (either group or full form)\n const parent = groupField && groupField.index !== undefined\n ? getValues?.()?.[groupField.name]?.[groupField.index]\n : getValues?.();\n\n return checkRequired(schema, parent);\n }, [element, watchedValues, allFormValues]);\n\n const label = useMemo(() => {\n if (typeof element.label === 'function') {\n return (element.label as LogicFunction<T, ILabelElement>)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return element.label;\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n const placeholder = useMemo(() => {\n if ('placeholder' in element && typeof element.placeholder === 'function') {\n return (element.placeholder as LogicFunction<T, string>)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return ('placeholder' in element ? element.placeholder : undefined) as string | undefined;\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n const resolvedStyle = useMemo(() => {\n const s = 'style' in element ? element.style : undefined;\n\n if (s && typeof s === 'function') {\n return s(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n }\n return s;\n }, [watchedValues, allFormValues, control, getValues, element])\n\n // ─────────────────────────────────────────────────────────────\n // Dev-mode deprecation warning for the legacy `style` prop.\n // Fires ONCE per field-instance mount (guarded by hasWarnedRef +\n // empty deps) so it does not re-fire on keystrokes / re-renders /\n // theme changes / etc. The bridge below remains functional —\n // this is a soft deprecation only; runtime removal is deferred\n // to the next major version.\n // ─────────────────────────────────────────────────────────────\n const hasWarnedDeprecatedStyleRef = useRef(false);\n useEffect(() => {\n // `process` is undeclared on native (no @types/node) but the\n // bundler statically replaces it on both platforms in production\n // builds. Reading it via globalThis sidesteps the TS lookup\n // without changing the runtime behaviour.\n const nodeEnv = (globalThis as any)?.process?.env?.NODE_ENV;\n if (nodeEnv === 'production') return;\n if (hasWarnedDeprecatedStyleRef.current) return;\n if (!('style' in element) || (element as any).style === undefined) return;\n\n hasWarnedDeprecatedStyleRef.current = true;\n // eslint-disable-next-line no-console\n console.warn(\n `[KitsConcerto] Field \"${(element as any).id}\": the \"style\" prop is deprecated. ` +\n `Use \"slots\" instead. Migration: ` +\n `style.input → slots.root.style, ` +\n `style.container → slots.container.style, ` +\n `style.label → slots.label.style, ` +\n `style.helperText → slots.helperText.style, ` +\n `style.errorMessage → slots.error.style. ` +\n `This prop will be removed in the next major version.`\n );\n // Empty deps: warn once on mount only — element identity may\n // change every render (form re-constructs configs), so we\n // cannot key on it without re-firing the warning.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n /**\n * Merge explicit `slots` with `style` sub-keys.\n * IElementStyle sub-keys are bridged into the slot system so they\n * flow through useComponentDefaults → elementStyles → KitsContainer.\n * Priority: style sub-keys (lowest) < explicit slots (highest).\n */\n const slots = useMemo(() => {\n // 1. Resolve explicit slots (DynamicValue)\n const rawSlots = 'slots' in element ? element.slots : undefined;\n let explicitSlots: Record<string, { props?: any; style?: any }> | undefined;\n if (rawSlots && typeof rawSlots === 'function') {\n explicitSlots = (rawSlots as any)(watchedValues, allFormValues, {\n control,\n getValues,\n setValue: formContext.setValue\n } as any, groupField);\n } else {\n explicitSlots = rawSlots as any;\n }\n\n // 2. Bridge IElementStyle sub-keys into slot format\n if (!resolvedStyle && !explicitSlots) return undefined;\n if (!resolvedStyle) return explicitSlots;\n\n const STYLE_TO_SLOT: Record<string, string> = {\n input: 'root',\n container: 'container',\n label: 'label',\n helperText: 'helperText',\n errorMessage: 'error',\n };\n\n const result: Record<string, { props?: any; style?: any }> = {};\n\n // First layer: style sub-keys (lower priority)\n for (const [styleKey, slotKey] of Object.entries(STYLE_TO_SLOT)) {\n const val = (resolvedStyle as any)[styleKey];\n if (val) {\n result[slotKey] = { style: val };\n }\n }\n\n // Second layer: explicit slots override\n if (explicitSlots) {\n for (const [key, slot] of Object.entries(explicitSlots)) {\n if (!result[key]) {\n result[key] = slot;\n } else {\n result[key] = {\n ...slot,\n style: { ...result[key].style, ...(slot.style || {}) },\n };\n }\n }\n }\n\n return Object.keys(result).length > 0 ? result : undefined;\n }, [watchedValues, allFormValues, control, getValues, element, resolvedStyle])\n\n // 6. Calculate layout properties.\n const layout = useMemo(() => {\n const getDynamicProp = (prop: any) => typeof prop === 'function'\n ? prop(watchedValues, allFormValues, {control, getValues})\n : prop;\n\n return {\n colSpan: getDynamicProp(element.logic?.colSpan ?? element.colSpan) ?? 12,\n rowSpan: getDynamicProp(element.rowSpan),\n columnGap: getDynamicProp(element.columnGap),\n colOffset: getDynamicProp(element.colOffset),\n area: getDynamicProp(element.area),\n };\n }, [watchedValues, allFormValues, control, getValues, element]);\n\n\n /*\n * ⛔ IT READ FIVE VALUES AND DEPENDED ON ONE. The dependency array here\n * was `[watchedValues]` while the body reads `onDepsChange`,\n * `allFormValues`, `formContext` and `groupField` as well — so every\n * one of those four was frozen at the render that first built this\n * callback, and a caller would have handed the consumer stale form\n * values under a fresh `watchedValues`.\n *\n * ⚠️ IT IS THE SAME DEFECT AS THE ONE FIXED IN 0.1.261 TWENTY LINES UP,\n * where the children memo read `element.elements` while depending on\n * `[watchedValues]` alone and froze every field nested in a container.\n * That one cost two days of hunting on the App's nationality picker.\n * This is the second instance in the same hook, found while reading the\n * first, and it is fixed here rather than left for someone to meet.\n *\n * ⛔ AND NOTHING CALLS IT TODAY — that is a fact about the blast radius,\n * not a reason to leave it wrong. `onWatchedValuesChange` is returned\n * from this hook and declared optional in `internal.types.ts`, and a\n * sweep of this repo and of the App, ClientPortal and Dashboard finds no\n * invocation anywhere. The real work is done by the effect below, which\n * already carries the full dependency list. So there is no user-visible\n * symptom to reproduce and no story to film; there is a loaded trap for\n * the first caller, and this disarms it.\n */\n const onWatchedValuesChange = useCallback(() => {\n if (onDepsChange) {\n onDepsChange(watchedValues, allFormValues, formContext as UseFormReturn<T>, groupField)\n }\n }, [onDepsChange, watchedValues, allFormValues, formContext, groupField])\n\n // 7. Get the field's state and methods from react-hook-form.\n // For Object elements, default to {} so react-hook-form treats the field\n // as a nested object — children register with dot-notation paths\n // (e.g. contactPhone.phoneNumber) and build the nested structure.\n const isObjectElement = element.type === 'Object';\n const {field, fieldState} = useController({\n name: element.id as any,\n control,\n shouldUnregister: !isShown,\n ...(isObjectElement ? {defaultValue: {} as any} : {}),\n });\n\n useEffect(() => {\n if (!onDepsChange) return;\n\n // Create a stable signature for watched values\n // (stringify is fine here because deps lists are small)\n const sig = JSON.stringify(watchedValues);\n\n if (sig === prevDepsRef.current) return; // ✅ no real change\n\n prevDepsRef.current = sig;\n\n onDepsChange(watchedValues, allFormValues, formContext as UseFormReturn<T>, groupField);\n }, [onDepsChange, watchedValues, allFormValues, formContext, groupField]);\n\n // 8. Return a single, clean object for the UI component.\n return {\n field: {\n ...field,\n onChange: (event) => {\n if ('onChangeValue' in element && element?.onChangeValue) {\n const value = event != null && typeof event === 'object' && 'target' in event\n ? event.target.value\n : event;\n element.onChangeValue(\n value,\n {...fieldState, isFocused: !!isFocused},\n formContext\n )\n }\n field.onChange(event)\n }\n },\n fieldState,\n watchedValues,\n onWatchedValuesChange,\n elements: childElements,\n isShown,\n isDisabled,\n isRequired,\n hideError: element.hideError,\n label,\n placeholder,\n formContext,\n layout,\n list,\n style: resolvedStyle as IElementStyle,\n slots,\n ...resolvedProps,\n localProps: 'localProps' in element ? element?.localProps : undefined,\n attached: element.attached,\n animation: element.animation,\n };\n }\n;\n"],"names":["schema"],"mappings":";;;;;;AA4BO,MAAM,gBAAgB,CAAwB;AAAA,EACI,OAAA,EAAS,EAAC,YAAA,EAAc,GAAG,OAAA,EAAO;AAAA,EAClC,OAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA;AACJ,CAAA,KAAqD;AAGlG,EAAA,MAAM,cAAc,cAAA,EAAkB;AAEtC,EAAA,MAAM,WAAA,GAAc,OAAe,EAAE,CAAA;AAErC,EAAA,MAAM,UAAA,GAAa,QAAQ,MAAM,IAAA,CAAK,UAAU,aAAa,CAAA,EAAG,CAAC,aAAa,CAAC,CAAA;AAE/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YAAY,QAAA,IAAY,KAAA,GAClE,KAAA,CAAM,MAAA,CAAO,KAAA,GACb,KAAA;AACN,UAAA,OAAA,CAAQ,aAAA;AAAA,YACJ,KAAA;AAAA,YACA,EAAC,GAAG,UAAA,EAAY,SAAA,EAAW,CAAC,CAAC,SAAA,EAAS;AAAA,YACtC;AAAA,WACJ;AAAA,QACJ;AACA,QAAA,KAAA,CAAM,SAAS,KAAK,CAAA;AAAA,MACxB;AAAA,KACJ;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA,qBAAA;AAAA,IACA,QAAA,EAAU,aAAA;AAAA,IACV,OAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAW,OAAA,CAAQ,SAAA;AAAA,IACnB,KAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA,EAAO,aAAA;AAAA,IACP,KAAA;AAAA,IACA,GAAG,aAAA;AAAA,IACH,UAAA,EAAY,YAAA,IAAgB,OAAA,GAAU,OAAA,EAAS,UAAA,GAAa,MAAA;AAAA,IAC5D,UAAU,OAAA,CAAQ,QAAA;AAAA,IAClB,WAAW,OAAA,CAAQ;AAAA,GACvB;AACJ;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1711,8 +1711,19 @@ export interface IElementBase<T extends FieldValues> {
|
|
|
1711
1711
|
colSpan?: DynamicValue<T, KitsResponsiveValue<string | number>>;
|
|
1712
1712
|
rowSpan?: DynamicValue<T, KitsResponsiveValue<string | number>>;
|
|
1713
1713
|
colOffset?: DynamicValue<T, KitsResponsiveValue<string | number>>;
|
|
1714
|
+
/**
|
|
1715
|
+
* ⚠️ `rowGap` USED TO SIT HERE AND IT WAS NEVER READ. `useFieldLogic`
|
|
1716
|
+
* computed it into `layout` and neither FieldWrapper consumed it — native
|
|
1717
|
+
* reads `colSpan`, web reads `colSpan`, `rowSpan`, `colOffset` and `area`.
|
|
1718
|
+
* An element could declare it, the value was resolved on every render, and
|
|
1719
|
+
* nothing moved. Removed 2 October 2026 after sweeping every consumer repo:
|
|
1720
|
+
* zero callers (the App's one hit is a comment, the Portal's two are the
|
|
1721
|
+
* Form's `grid` prop, the Dashboard's are slot `style` objects and direct
|
|
1722
|
+
* `<Grid>` use). The row gap is set on the FORM — see `IFormComponent.rowGap`.
|
|
1723
|
+
* ⛔ `columnGap` BELOW IS THE SAME DEAD LEVER and is kept pending a ruling,
|
|
1724
|
+
* recorded here rather than removed quietly.
|
|
1725
|
+
*/
|
|
1714
1726
|
columnGap?: DynamicValue<T, KitsResponsiveValue<string | number>>;
|
|
1715
|
-
rowGap?: DynamicValue<T, KitsResponsiveValue<string | number>>;
|
|
1716
1727
|
area?: DynamicValue<T, KitsResponsiveValue<string>>;
|
|
1717
1728
|
leftAddon?: DynamicValue<T, ReactElement | IconType | string>;
|
|
1718
1729
|
rightAddon?: DynamicValue<T, ReactElement | IconType | string>;
|
|
@@ -2117,6 +2128,17 @@ export type IFormComponent<T extends FieldValues> = UseFormManagerEvents<T> & (I
|
|
|
2117
2128
|
rowGap?: number;
|
|
2118
2129
|
};
|
|
2119
2130
|
export interface UseFieldLogicElementProps<T extends FieldValues> extends GroupFieldConfigs<T> {
|
|
2131
|
+
/**
|
|
2132
|
+
* The form's row gap, passed down so a field type that renders a NESTED
|
|
2133
|
+
* `FormRenderer` can carry it further.
|
|
2134
|
+
*
|
|
2135
|
+
* ⛔ ONLY `Object` AND `Group` READ IT, AND THAT IS THE POINT. They are the
|
|
2136
|
+
* two types whose children go through another renderer, and a renderer
|
|
2137
|
+
* handed nothing falls back to its own default — which is why a form that
|
|
2138
|
+
* set `rowGap` got it on its top-level rows and on nothing inside a card.
|
|
2139
|
+
* Every other field type receives it and ignores it.
|
|
2140
|
+
*/
|
|
2141
|
+
rowGap?: number;
|
|
2120
2142
|
element: IFormElement<T>;
|
|
2121
2143
|
control: Control<T>;
|
|
2122
2144
|
getValues: UseFormGetValues<T>;
|