@ostack.tech/ui-kform 0.16.3 → 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/chunks/{en-CKrk2smU.js → en-CBhjKaFE.js} +2 -1
  2. package/dist/chunks/{en-CKrk2smU.js.map → en-CBhjKaFE.js.map} +1 -1
  3. package/dist/locales/en-GB.js +1 -1
  4. package/dist/locales/en-US.js +1 -1
  5. package/dist/locales/fr-FR.js +1 -0
  6. package/dist/locales/fr-FR.js.map +1 -1
  7. package/dist/locales/pt-PT.js +1 -0
  8. package/dist/locales/pt-PT.js.map +1 -1
  9. package/dist/ostack-ui-kform.css +17 -1
  10. package/dist/ostack-ui-kform.js +349 -185
  11. package/dist/ostack-ui-kform.js.map +1 -1
  12. package/package.json +2 -2
  13. package/scss/components/Annexes/_Annexes.scss +6 -0
  14. package/scss/components/TopBar/_TopBar.scss +13 -1
  15. package/types/components/FileControl/FileControl.d.ts +1 -1
  16. package/types/components/LoadAction/LoadAction.d.ts +2 -5
  17. package/types/components/PathLink/PathLink.d.ts +22 -1
  18. package/types/components/PrintAction/PrintAction.d.ts +2 -5
  19. package/types/components/ResetOnChange/ResetOnChange.d.ts +40 -0
  20. package/types/components/ResetOnChange/ResetOnChangeContext.d.ts +7 -0
  21. package/types/components/ResetOnChange/index.d.ts +3 -0
  22. package/types/components/ResetOnChange/useResetOnChange.d.ts +96 -0
  23. package/types/components/SaveAction/SaveAction.d.ts +8 -10
  24. package/types/components/SubmitAction/SubmitAction.d.ts +2 -4
  25. package/types/components/TableControl/TableControl.d.ts +4 -1
  26. package/types/components/TableControl/TableControlAddRowTrigger.d.ts +2 -4
  27. package/types/components/TableControl/TableControlColumnFns.d.ts +8 -28
  28. package/types/components/TableControl/TableControlContent.d.ts +1 -1
  29. package/types/components/TableControl/TableControlRemoveRowTrigger.d.ts +11 -21
  30. package/types/components/TopBar/TopBarActions.d.ts +4 -4
  31. package/types/components/TopBar/TopBarActionsSecondary.d.ts +6 -0
  32. package/types/components/TopBar/index.d.ts +1 -0
  33. package/types/components/ValidateAction/ValidateAction.d.ts +2 -5
  34. package/types/index.d.ts +1 -1
  35. package/types/providers/LocalizationProvider/LocalizationObject.d.ts +2 -1
  36. package/types/utils/extractConfirmDialogOptions.d.ts +13 -0
  37. package/types/utils/useResetOnChange.d.ts +0 -98
@@ -1 +1 @@
1
- {"version":3,"file":"ostack-ui-kform.js","names":[],"sources":["../src/providers/PrefixSuffixProvider/defaultPrefixSuffix.ts","../src/providers/PrefixSuffixProvider/PrefixSuffixContext.ts","../src/providers/PrefixSuffixProvider/PrefixSuffixProvider.tsx","../src/providers/PrefixSuffixProvider/usePrefix.ts","../src/providers/ActivePathProvider/ActivePathContext.ts","../src/providers/ActivePathProvider/ActivePathProvider.tsx","../src/providers/LocalizationProvider/LocalizationContext.ts","../src/providers/LocalizationProvider/LocalizationProvider.tsx","../src/providers/LocalizationProvider/useLocale.ts","../src/utils/pathSpecificity.ts","../src/utils/useEqualityFn.ts","../src/components/FormApp/FormAppContext.ts","../src/components/IssueMessage/IssueMessage.tsx","../src/utils/useControlAutofocus.ts","../src/components/FormApp/FormAppAutoFocus.tsx","../src/components/FormApp/FormAppElement.tsx","../src/components/FormApp/FormAppIssueMessages.tsx","../src/components/FormApp/FormApp.tsx","../src/components/FormApp/FormAppStatus.tsx","../src/utils/mostSpecificPath.ts","../src/components/Annexes/AnnexesContext.ts","../src/components/Annexes/Annex.tsx","../src/utils/useFormLoader.tsx","../src/components/Annexes/AnnexRegistrar.tsx","../src/components/Annexes/RepetitiveAnnexRegistrar.tsx","../src/components/Annexes/Annexes.tsx","../src/utils/useReportValidationFailures.ts","../src/components/ControlField/ControlFieldContext.ts","../src/components/ControlField/ControlField.tsx","../src/components/IssueMessages/IssueMessages.tsx","../src/components/IssuesPopover/IssuesPopover.tsx","../src/utils/displayStatusConversions.ts","../src/utils/promiseUtils.ts","../src/components/TopBar/TopBarContext.tsx","../src/components/TopBar/TopBar.tsx","../src/components/TopBar/TopBarActions.tsx","../src/components/Annexes/AnnexesMenu.tsx","../src/components/Annexes/AnnexTab.tsx","../src/components/Annexes/AnnexesTabList.tsx","../src/components/Annexes/AnnexesManager.tsx","../src/utils/useControlIssues.tsx","../src/utils/useRegisterControl.tsx","../src/components/DebugInfo/DebugInfo.tsx","../src/components/DebugInfo/DebugInfoControlAddonTrigger.tsx","../src/components/CheckboxControl/CheckboxControl.tsx","../src/utils/selectionTransformations.tsx","../src/components/UnknownValue/UnknownValue.tsx","../src/components/CheckboxGroupControl/CheckboxGroupControlItem.tsx","../src/components/CheckboxGroupControl/CheckboxGroupControl.tsx","../src/utils/dateRestrictions.ts","../src/utils/useTemporalStringTransformer.ts","../src/components/DateControl/DateControl.tsx","../src/components/DateRangeControl/DateRangeControl.tsx","../src/components/FileControl/FileControlDownloadAddon.tsx","../src/components/FileControl/FileControlViewAddon.tsx","../src/components/FileControl/FileControl.tsx","../src/components/FormPages/FormPagesContext.ts","../src/components/FormPages/FormPageHeader.tsx","../src/components/FormPages/FormPage.tsx","../src/components/FormPages/FormPageRegistrar.tsx","../src/components/FormPages/FormPages.tsx","../src/components/FormPages/FormPagesSelectOption.tsx","../src/components/FormPages/FormPagesSelect.tsx","../src/components/FormPages/FormPageSidebarItem.tsx","../src/components/FormPages/FormPagesSidebar.tsx","../src/components/FormPages/FormPagesNavigation.tsx","../src/components/FormStepper/FormStepperContext.ts","../src/components/FormStepper/FormStep.tsx","../src/components/FormStepper/FormStepButton.tsx","../src/components/FormStepper/FormStepList.tsx","../src/components/FormStepper/FormStepRegistrar.tsx","../src/components/FormStepper/FormStepper.tsx","../src/components/FormStepper/FormStepperFinishTrigger.tsx","../src/components/FormStepper/FormStepperNextTrigger.tsx","../src/components/FormStepper/FormStepperPreviousTrigger.tsx","../src/components/IssuesAlert/IssuesAlert.tsx","../src/utils/useFormValidator.ts","../src/components/IssuesPanel/IssuesPanelControls.tsx","../src/components/IssuesPanel/IssuesPanelMessagesCard.tsx","../src/components/IssuesPanel/IssuesPanelSummaryCard.tsx","../src/components/IssuesPanel/IssuesPanel.tsx","../src/components/LoadAction/LoadAction.tsx","../src/components/NumericControl/NumericControl.tsx","../src/components/PathLink/PathLink.tsx","../src/components/PrintAction/PrintAction.tsx","../src/components/RadioGroupControl/RadioGroupControlItem.tsx","../src/components/RadioGroupControl/RadioGroupControl.tsx","../src/utils/useFormSaver.tsx","../src/components/SaveAction/SaveAction.tsx","../src/components/SelectControl/SelectControlItem.tsx","../src/components/SelectControl/SelectControlItemGroup.tsx","../src/components/SelectControl/SelectControl.tsx","../src/components/SelectMultipleControl/SelectMultipleControlItem.tsx","../src/components/SelectMultipleControl/SelectMultipleControlItemGroup.tsx","../src/components/SelectMultipleControl/SelectMultipleControl.tsx","../src/components/SubmitAction/SubmitAction.tsx","../src/components/TableControl/TableControlContext.ts","../src/components/TableControl/TableControlCell.tsx","../src/components/TableControl/TableControlColumn.tsx","../src/components/TableControl/TableControlColumnGroup.tsx","../src/components/TableControl/TableControlColumns.tsx","../src/components/TableControl/TableControlRow.tsx","../src/components/TableControl/TableControl.tsx","../src/components/TableControl/TableControlActionsColumnLabel.tsx","../src/components/TableControl/TableControlIndexColumnLabel.tsx","../src/components/TableControl/TableControlRemoveRowTrigger.tsx","../src/components/TableControl/TableControlColumnFns.tsx","../src/components/TableControl/TableControlActionsColumn.tsx","../src/components/TableControl/TableControlAddRowTrigger.tsx","../src/components/TableControl/TableControlApi.ts","../src/components/TableControl/TableControlContent.tsx","../src/components/TableControl/TableControlIndexColumn.tsx","../src/components/TableControl/TableControlPagination.tsx","../src/components/TableControl/TableControlRowsPerPage.tsx","../src/components/TextControl/TextControl.tsx","../src/components/ValidateAction/ValidateAction.tsx","../src/utils/useResetOnChange.tsx"],"sourcesContent":["import { createStore } from \"zustand\";\n\n/** Initial default library prefix-suffix. */\nconst DEFAULT_PREFIX_SUFFIX = \"kform-\";\n\n/** Store holding the default prefix-suffix. */\nexport const defaultPrefixSuffixStore = createStore(() => ({\n defaultPrefixSuffix: DEFAULT_PREFIX_SUFFIX,\n}));\n\n/**\n * Function used to set the default library's prefix-suffix. The default library\n * prefix-suffix can be overridden by providing a `prefixSuffix` property to the\n * `PrefixSuffixProvider` or `FormApp` components.\n *\n * @param defaultPrefixSuffix Prefix-suffix to set as the library's default.\n */\nexport function setDefaultPrefixSuffix(defaultPrefixSuffix: string) {\n defaultPrefixSuffixStore.setState({ defaultPrefixSuffix });\n}\n","import { createContext } from \"react\";\n\n/** Prefix-suffix context. */\nexport const PrefixSuffixContext = createContext<string | null>(null);\n","import type { ReactNode } from \"react\";\n\nimport { PrefixSuffixContext } from \"./PrefixSuffixContext.ts\";\n\n/** Properties of the prefix-suffix provider. */\nexport interface PrefixSuffixProviderProps {\n /** Suffix to add to ostack/UI's prefix. */\n prefixSuffix?: string;\n children: ReactNode;\n}\n\n/** Prefix-suffix provider. */\nexport function PrefixSuffixProvider({\n prefixSuffix,\n children,\n}: PrefixSuffixProviderProps) {\n return prefixSuffix === undefined ? (\n children\n ) : (\n <PrefixSuffixContext.Provider value={prefixSuffix}>\n {children}\n </PrefixSuffixContext.Provider>\n );\n}\n","import { type PrefixFn, usePrefix as useUiPrefix } from \"@ostack.tech/ui\";\nimport { useCallback, useContext } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { defaultPrefixSuffixStore } from \"./defaultPrefixSuffix.ts\";\nimport { PrefixSuffixContext } from \"./PrefixSuffixContext.ts\";\n\n/**\n * Hook which returns a function which can be used to prefix a string with the\n * current prefix.\n */\nexport function usePrefix(): PrefixFn {\n const prefix = useUiPrefix();\n const defaultPrefixSuffix = useStore(\n defaultPrefixSuffixStore,\n ({ defaultPrefixSuffix }) => defaultPrefixSuffix,\n );\n const prefixSuffix = useContext(PrefixSuffixContext) ?? defaultPrefixSuffix;\n return useCallback(\n (toPrefix = \"\") => prefix(`${prefixSuffix}${toPrefix}`),\n [prefix, prefixSuffix],\n );\n}\n","import type { AbsolutePath } from \"@ostack.tech/kform\";\nimport { createContext, useContext } from \"react\";\n\n/** Value of the active path context. */\nexport interface ActivePathContextValue {\n activePath: AbsolutePath;\n onActivePathChange: (activePath: AbsolutePath | string | null) => void;\n}\n\n/** Active path context. */\nexport const ActivePathContext = createContext<ActivePathContextValue | null>(\n null,\n);\n\n/** Hook providing access to the active path context. */\nexport function useActivePathContext(): ActivePathContextValue {\n const activePathContext = useContext(ActivePathContext);\n if (!activePathContext) {\n throw new Error(\"Active path context not in scope\");\n }\n return activePathContext;\n}\n","import {\n AbsolutePath,\n AbsolutePathFragment,\n type Path,\n} from \"@ostack.tech/kform\";\nimport { useResolvedPath } from \"@ostack.tech/kform-react\";\nimport { useControllableState, useLatestRef } from \"@ostack.tech/ui\";\nimport { type ReactNode, useCallback, useMemo } from \"react\";\n\nimport { ActivePathContext } from \"./ActivePathContext.ts\";\n\n/**\n * Navigation options to use when controlling the active path via the browser's\n * URL.\n */\nexport interface OnActivePathChangeNavigationOptions {\n /** Whether to replace the current history entry. */\n replace: boolean;\n}\n\n/** Properties of the active path provider. */\nexport interface ActivePathProviderProps {\n /** Uncontrolled default active path to use. */\n defaultActivePath?: string | Path;\n /** Controlled active path to use. */\n activePath?: string | Path;\n /**\n * Callback called whenever the active path is changed.\n *\n * @param activePath New active path.\n * @param options Navigation options to use when controlling the active path\n * via the browser's URL.\n */\n onActivePathChange?: (\n activePath: AbsolutePath,\n options: OnActivePathChangeNavigationOptions,\n ) => void;\n children?: ReactNode;\n}\n\n/** Provider which controls the active path in a section of a form. */\nexport function ActivePathProvider({\n defaultActivePath,\n activePath: controlledActivePath,\n onActivePathChange,\n children,\n}: ActivePathProviderProps) {\n const [activePath, setActivePath] = useControllableState(\n defaultActivePath,\n controlledActivePath,\n );\n const resolvedActivePath = useResolvedPath(activePath);\n\n const latestRef = useLatestRef({ resolvedActivePath, onActivePathChange });\n const handleActivePathChange = useCallback(\n (newActivePath: AbsolutePath | string | null) => {\n const activePath = latestRef.current.resolvedActivePath;\n if (typeof newActivePath === \"string\") {\n newActivePath = new AbsolutePath(newActivePath);\n } else {\n newActivePath ??= AbsolutePath.ROOT;\n }\n\n // Ignore when new path is equal to or an ancestor of the old one\n if (\n !activePath.equals(newActivePath) &&\n !newActivePath\n .append(AbsolutePathFragment.RecursiveWildcard)\n .contains(activePath)\n ) {\n // Replace when the old path is an ancestor of the new one\n const replace = activePath\n .append(AbsolutePathFragment.RecursiveWildcard)\n .contains(newActivePath);\n setActivePath(newActivePath);\n latestRef.current.onActivePathChange?.(newActivePath, { replace });\n }\n },\n [latestRef, setActivePath],\n );\n\n return (\n <ActivePathContext.Provider\n value={useMemo(\n () => ({\n activePath: resolvedActivePath,\n onActivePathChange: handleActivePathChange,\n }),\n [handleActivePathChange, resolvedActivePath],\n )}\n >\n {children}\n </ActivePathContext.Provider>\n );\n}\n","import { createContext } from \"react\";\n\nimport type { LocalizationObject } from \"./LocalizationObject.ts\";\n\n/** Value of the localisation context. */\nexport interface LocalizationContextValue {\n locale: LocalizationObject;\n setLocale: (locale: LocalizationObject) => void;\n}\n\n/** Localisation context. */\nexport const LocalizationContext =\n createContext<LocalizationContextValue | null>(null);\n","import {\n combineEventHandlers,\n LocalizationProvider as UiLocalizationProvider,\n useControllableState,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { LocalizationContext } from \"./LocalizationContext.ts\";\nimport type { LocalizationObject } from \"./LocalizationObject.ts\";\n\n/** Properties of the localisation provider. */\nexport interface LocalizationProviderProps {\n /** Uncontrolled locale to use. */\n defaultLocale?: LocalizationObject;\n /** Controlled locale to use. */\n locale?: LocalizationObject;\n /**\n * Function called when the locale changes.\n *\n * @param locale New locale.\n */\n onLocaleChange?: (locale: LocalizationObject) => void;\n children: ReactNode;\n}\n\n/**\n * Localisation provider (also sets the `@ostack.tech/ui` localisation\n * provider).\n */\nexport function LocalizationProvider({\n defaultLocale,\n locale: controlledLocale,\n onLocaleChange,\n children,\n}: LocalizationProviderProps) {\n const [locale, setLocale] = useControllableState(\n defaultLocale,\n controlledLocale,\n );\n\n return locale === undefined ? (\n children\n ) : (\n <LocalizationContext.Provider\n value={{\n locale,\n setLocale: combineEventHandlers(setLocale, onLocaleChange),\n }}\n >\n <UiLocalizationProvider locale={locale.baseLocale}>\n {children}\n </UiLocalizationProvider>\n </LocalizationContext.Provider>\n );\n}\n","import { useContext, useMemo } from \"react\";\n\nimport { LocalizationContext } from \"./LocalizationContext.ts\";\nimport type { LocalizationObject } from \"./LocalizationObject.ts\";\n\n/** Hook used to get and set the current locale. */\nexport function useLocale(): [\n LocalizationObject,\n (locale: LocalizationObject) => void,\n] {\n const localizationContext = useContext(LocalizationContext);\n if (localizationContext === null)\n throw new Error(\n \"No locale has been provided. Please provide a locale via the \" +\n \"`FormApp` or `LocalizationProvider` components.\",\n );\n return useMemo(\n () => [localizationContext.locale, localizationContext.setLocale],\n [localizationContext.locale, localizationContext.setLocale],\n );\n}\n","import { type AbsolutePath, AbsolutePathFragment } from \"@ostack.tech/kform\";\n\ntype PathSpecificity = [number, number, number];\n\n/**\n * Given two paths, returns a number > 0 if the first path is more specific than\n * the second, a number < 0 if the first path is less specific than the second,\n * or 0 if both paths have the same specificity.\n *\n * Specificity is not incredibly well specified (and may change over time if a\n * need arises), but the idea is that wildcards make paths less specific, so\n * `/a/∗` is less specific than `/a/b`, and `/∗∗` is the least specific path.\n *\n * Both `/a` and `/a/b/c` have the same specificity since both paths uniquely\n * identify a resource.\n *\n * @param path1 First path to compare.\n * @param path2 Second path to compare.\n * @returns Number representing which path is more specific.\n */\nexport function comparePathsBySpecificity(\n path1: AbsolutePath,\n path2: AbsolutePath,\n) {\n const [ids1, wildcards1, recursiveWildcards1] = pathSpecificity(path1);\n const [ids2, wildcards2, recursiveWildcards2] = pathSpecificity(path2);\n // When neither path has recursive wildcards, the most specific one is the one\n // with the least non-recursive wildcards\n if (recursiveWildcards1 === 0 && recursiveWildcards2 === 0) {\n return wildcards2 - wildcards1;\n }\n // When one path has recursive wildcards but the other one doesn't, the most\n // specific one is the one without recursive wildcards\n if (recursiveWildcards1 === 0 || recursiveWildcards2 === 0) {\n return recursiveWildcards2 - recursiveWildcards1;\n }\n // When both paths have recursive wildcards, the most specific one is the one\n // with the most identifiers; if the number of identifiers is the same, then\n // the one with the most non-recursive wildcards\n return ids1 - ids2 || wildcards1 - wildcards2;\n}\n\nfunction pathSpecificity(path: AbsolutePath): PathSpecificity {\n const specificity: PathSpecificity = [0, 0, 0];\n for (const fragment of path.fragments) {\n if (fragment instanceof AbsolutePathFragment.Id) {\n ++specificity[0];\n } else if (fragment === AbsolutePathFragment.Wildcard) {\n ++specificity[1];\n } else if (fragment === AbsolutePathFragment.RecursiveWildcard) {\n ++specificity[2];\n }\n }\n return specificity;\n}\n","import { useRef } from \"react\";\n\nconst INITIAL = Symbol();\n\n// TODO: This is repeated both here and in `@ostack.tech/kform-react`, it might\n// make sense to either export and use the `@ostack.tech/kform-react` version\n// or upstream it instead\nexport function useEqualityFn<TState, TResult>(\n selector: (state: TState) => TResult,\n equalityFn: (v1: TResult, v2: TResult) => boolean = Object.is,\n): (state: TState) => TResult {\n const latest = useRef<TResult | typeof INITIAL>(INITIAL);\n return (state) => {\n const next = selector(state);\n return latest.current !== INITIAL && equalityFn(latest.current, next)\n ? latest.current\n : (latest.current = next);\n };\n}\n","import {\n AbsolutePath,\n AbsolutePathFragment,\n type Path,\n PathMultimap,\n type PathMultimapEntryId,\n type SealedLocatedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport { type Controller, equals } from \"@ostack.tech/kform-react\";\nimport { useConstant, useLatestRef, usePrinting } from \"@ostack.tech/ui\";\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n} from \"react\";\nimport { createStore, useStore } from \"zustand\";\nimport { subscribeWithSelector } from \"zustand/middleware\";\nimport { useShallow } from \"zustand/react/shallow\";\nimport { shallow } from \"zustand/shallow\";\n\nimport { comparePathsBySpecificity } from \"../../utils/pathSpecificity.ts\";\nimport { useEqualityFn } from \"../../utils/useEqualityFn.ts\";\nimport type { IssueMessagesByCode, IssueMessageValue } from \"../IssueMessages\";\nimport type { IssuesDisplayMode } from \"./FormApp.tsx\";\n\n/** Value of the form app context. */\nexport interface FormAppContextValue<T = unknown> {\n formTitle?: string;\n disabled: boolean;\n readOnly: boolean;\n issuesDisplayMode: IssuesDisplayMode;\n displayIssueCodes: boolean;\n issueMessagesDataKey: string;\n formAppElement: HTMLFormElement | null;\n store: FormAppStore<T>;\n debug: boolean;\n}\n\n/** State of the form app. */\nexport interface FormAppState<T> {\n controller: Controller<T>;\n focusedPath: AbsolutePath | null;\n focusCounter: number;\n issuesPanelPath: AbsolutePath | null;\n topBarHeight: number;\n leftSidebarWidth: number;\n bottomPanelHeight: number;\n startIssuesNavigation?: () => void;\n latestInteraction: AbsolutePath;\n // State below is wrapped in an array in order to trigger state updates by\n // simply changing the identity of the wrapper without creating new multimap\n // instances\n registeredControllers: [PathMultimap<Controller>];\n registeredIssueMessages: [\n PathMultimap<{ messages: IssueMessagesByCode; priority: number }>,\n ];\n deferredIssueMessageRemovalEntryIds: PathMultimapEntryId[];\n registeredLabels: [PathMultimap<{ label: ReactNode; priority: number }>];\n deferredLabelRemovalEntryIds: PathMultimapEntryId[];\n actions: FormAppActions;\n}\n\n/** Item of a breadcrumb. */\nexport interface BreadcrumbItem {\n path: AbsolutePath;\n label: ReactNode;\n}\n\n/** Actions of the form app. */\nexport interface FormAppActions {\n setIssuesPanelPath: (path: AbsolutePath | null) => void;\n focus: (path: string | Path) => void;\n resetFocus: () => void;\n registerController: (\n path: AbsolutePath,\n controller?: Controller<any> | null,\n ) => (() => void) | void;\n isRegistered: (path: AbsolutePath) => boolean;\n setLatestInteraction: (path: AbsolutePath) => void;\n registerIssueMessages: (\n basePath: AbsolutePath,\n issueMessages?: Record<string, IssueMessagesByCode>,\n priority?: number,\n ) => (() => void) | void;\n getRegisteredIssueMessage: (\n path: AbsolutePath,\n code: string,\n ) => IssueMessageValue;\n registerLabel: (\n path: AbsolutePath,\n label: ReactNode,\n priority?: number,\n ) => (() => void) | void;\n getRegisteredLabel: (path: AbsolutePath) => ReactNode;\n getActiveIssuesPanelBreadcrumb: () => BreadcrumbItem[] | null;\n startIssuesNavigation: (options?: {\n validate?: boolean;\n setTouched?: boolean;\n }) => PromiseLike<void>;\n}\n\n/** Form app store. */\nexport type FormAppStore<T> = ReturnType<\n typeof useCreateFormAppContext<T>\n>[\"store\"];\n\n/** Form app context. */\nexport const FormAppContext = createContext<FormAppContextValue | null>(null);\n\n/** Options used to create the data table context value. */\nexport interface UseCreateFormAppContextOptions<T> extends Omit<\n FormAppContextValue<T>,\n \"store\"\n> {\n controller: Controller<T>;\n onPathFocus?: (path: AbsolutePath) => void;\n}\n\n/** Hook which creates the form app context. */\nexport function useCreateFormAppContext<T>({\n formTitle,\n controller,\n disabled,\n readOnly,\n issuesDisplayMode,\n displayIssueCodes,\n issueMessagesDataKey,\n formAppElement,\n onPathFocus,\n debug,\n}: UseCreateFormAppContextOptions<T>) {\n const latestRef = useLatestRef({ printing: usePrinting(), onPathFocus });\n const store = useConstant(() =>\n createStore<FormAppState<T>>()(\n subscribeWithSelector((set, get) => ({\n controller,\n focusedPath: null,\n focusCounter: 0,\n issuesPanelPath: null,\n topBarHeight: 0,\n leftSidebarWidth: 0,\n bottomPanelHeight: 0,\n startIssuesNavigation: undefined,\n latestInteraction: AbsolutePath.ROOT,\n registeredControllers: [new PathMultimap()],\n registeredIssueMessages: [new PathMultimap()],\n deferredIssueMessageRemovalEntryIds: [],\n registeredLabels: [new PathMultimap()],\n deferredLabelRemovalEntryIds: [],\n actions: {\n setIssuesPanelPath: (path: AbsolutePath | null) => {\n if (latestRef.current.printing) {\n return;\n }\n\n // Remove entries whose removal was deferred\n const {\n deferredIssueMessageRemovalEntryIds,\n deferredLabelRemovalEntryIds,\n } = get();\n if (deferredIssueMessageRemovalEntryIds.length > 0) {\n const [registeredIssueMessages] = get().registeredIssueMessages;\n for (const entryId of deferredIssueMessageRemovalEntryIds) {\n registeredIssueMessages.removeEntry(entryId);\n }\n set({ registeredIssueMessages: [registeredIssueMessages] });\n }\n if (deferredLabelRemovalEntryIds.length > 0) {\n const [registeredLabels] = get().registeredLabels;\n for (const entryId of deferredLabelRemovalEntryIds) {\n registeredLabels.removeEntry(entryId);\n }\n set({ registeredLabels: [registeredLabels] });\n }\n\n set({ issuesPanelPath: path });\n },\n getActiveIssuesPanelBreadcrumb: () => {\n const { issuesPanelPath, actions } = get();\n if (issuesPanelPath === null) {\n return null;\n }\n const breadcrumbParts: BreadcrumbItem[] = [];\n for (let i = 0; i <= issuesPanelPath.size; ++i) {\n const path =\n i === 0\n ? AbsolutePath.ROOT\n : i === issuesPanelPath.size\n ? issuesPanelPath\n : new AbsolutePath(issuesPanelPath.fragments.slice(0, i));\n const breadcrumb = actions.getRegisteredLabel(path);\n // if (!breadcrumb && DEV) {\n // warnOnce(`No label registered for path '${path.toString()}'.`);\n // }\n breadcrumbParts.push({\n path,\n label:\n breadcrumb ??\n (\n issuesPanelPath.fragment(\n i - 1,\n ) as AbsolutePathFragment.Id | null\n )?.id,\n });\n }\n return breadcrumbParts;\n },\n focus: (path: string | Path) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const { focusedPath } = get();\n const absolutePath =\n path instanceof AbsolutePath ? path : new AbsolutePath(path);\n // Refuse non-existent paths\n if (\n !get().controller.getState().formManager.isValidPath(absolutePath)\n ) {\n throw new Error(`Invalid path: '${absolutePath.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n absolutePath.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Path to focus must only contain ids.\");\n }\n\n const focusPathChanged = !equals(focusedPath, absolutePath);\n set(({ focusedPath, focusCounter }) => ({\n focusedPath: focusPathChanged ? absolutePath : focusedPath,\n focusCounter: focusCounter + 1,\n }));\n if (focusPathChanged) {\n latestRef.current.onPathFocus?.(absolutePath);\n }\n },\n resetFocus: () => {\n if (!latestRef.current.printing) {\n set({ focusedPath: null });\n }\n },\n registerController: (\n path: AbsolutePath,\n controller?: Controller | null,\n ) => {\n if (controller == null) {\n return;\n }\n\n const [registeredControllers] = get().registeredControllers;\n const addedEntry = registeredControllers.put(path, controller);\n set(() => ({ registeredControllers: [registeredControllers] }));\n\n return () => {\n registeredControllers.removeEntry(addedEntry);\n set(() => ({ registeredControllers: [registeredControllers] }));\n };\n },\n isRegistered: (path: AbsolutePath) =>\n get().registeredControllers[0].containsPath(path),\n setLatestInteraction: (path: AbsolutePath) => {\n if (!latestRef.current.printing) {\n set({ latestInteraction: path });\n }\n },\n registerIssueMessages: (\n basePath: AbsolutePath,\n issueMessages?: Record<string, IssueMessagesByCode>,\n priority = 0,\n ) => {\n if (issueMessages == null) {\n return;\n }\n\n const [registeredIssueMessages] = get().registeredIssueMessages;\n const addedEntryIds: PathMultimapEntryId[] = [];\n for (const [path, issueMessagesByCode] of Object.entries(\n issueMessages,\n )) {\n addedEntryIds.push(\n registeredIssueMessages.put(basePath.resolve(path), {\n messages: issueMessagesByCode,\n priority,\n }),\n );\n }\n set(() => ({\n registeredIssueMessages: [registeredIssueMessages],\n }));\n\n return () => {\n const { issuesPanelPath } = get();\n for (const entryId of addedEntryIds) {\n // If the message being unregistered is currently in use by the\n // issues panel, defer its removal\n if (\n issuesPanelPath &&\n registeredIssueMessages\n .getEntry(entryId)!\n .path.append(AbsolutePathFragment.RecursiveWildcard)\n .contains(issuesPanelPath)\n ) {\n get().deferredIssueMessageRemovalEntryIds.push(entryId);\n } else {\n registeredIssueMessages.removeEntry(entryId);\n }\n }\n set(() => ({\n registeredIssueMessages: [registeredIssueMessages],\n }));\n };\n },\n getRegisteredIssueMessage: (path: AbsolutePath, code: string) => {\n const [registeredIssueMessages] = get().registeredIssueMessages;\n\n // Find the match with the most specific path\n let bestMatch = null;\n for (const entry of registeredIssueMessages.entries(path)) {\n if (entry.value.messages[code] == null) {\n continue;\n }\n\n const diff =\n bestMatch &&\n comparePathsBySpecificity(bestMatch.path, entry.path);\n if (\n bestMatch == null ||\n diff! < 0 ||\n // Larger priority wins\n (diff === 0 &&\n entry.value.priority > bestMatch.value.priority) ||\n // Last inserted wins\n (diff === 0 &&\n entry.value.priority === bestMatch.value.priority &&\n entry.id > bestMatch.id)\n ) {\n bestMatch = entry;\n }\n }\n return bestMatch?.value.messages[code] ?? null;\n },\n registerLabel: (\n path: AbsolutePath,\n label: ReactNode,\n priority = 0,\n ) => {\n if (!label) {\n return;\n }\n\n const [registeredLabels] = get().registeredLabels;\n const addedEntry = registeredLabels.put(path, { label, priority });\n set(() => ({ registeredLabels: [registeredLabels] }));\n\n return () => {\n const { issuesPanelPath } = get();\n // If the label being unregistered is currently in use by the\n // issues panel, defer its removal\n if (\n issuesPanelPath &&\n registeredLabels\n .getEntry(addedEntry)!\n .path.append(AbsolutePathFragment.RecursiveWildcard)\n .contains(issuesPanelPath)\n ) {\n get().deferredLabelRemovalEntryIds.push(addedEntry);\n } else {\n registeredLabels.removeEntry(addedEntry);\n }\n set(() => ({ registeredLabels: [registeredLabels] }));\n };\n },\n getRegisteredLabel: (path: AbsolutePath) => {\n const [registeredLabels] = get().registeredLabels;\n\n // Find the match with the most specific path\n let bestMatch = null;\n for (const entry of registeredLabels.entries(path)) {\n const diff =\n bestMatch &&\n comparePathsBySpecificity(bestMatch.path, entry.path);\n if (\n bestMatch == null ||\n diff! < 0 ||\n // Larger priority wins\n (diff === 0 &&\n entry.value.priority > bestMatch.value.priority) ||\n // Last inserted wins\n (diff === 0 &&\n entry.value.priority === bestMatch.value.priority &&\n entry.id > bestMatch.id)\n ) {\n bestMatch = entry;\n }\n }\n return bestMatch?.value.label ?? null;\n },\n startIssuesNavigation: async ({\n validate = true,\n setTouched = validate,\n } = {}) => {\n const formManager = get().controller.getState().formManager;\n if (setTouched) {\n await formManager.setTouched();\n }\n let issues: SealedLocatedValidationIssue[] | undefined;\n if (validate && formManager.autoValidationStatus === \"inactive\") {\n issues = await formManager.validate();\n }\n if (get().startIssuesNavigation) {\n get().startIssuesNavigation!();\n } else {\n const firstIssue = issues\n ? issues[0]\n : (await formManager.validate())[0];\n if (firstIssue) {\n get().actions.focus(firstIssue.path);\n }\n }\n },\n },\n })),\n ),\n );\n\n // Update store when params change\n useEffect(() => {\n store.setState({ controller });\n }, [controller, store]);\n\n return useMemo(\n () => ({\n formTitle,\n disabled,\n readOnly,\n issuesDisplayMode,\n displayIssueCodes,\n issueMessagesDataKey,\n formAppElement,\n debug,\n store,\n }),\n [\n debug,\n disabled,\n displayIssueCodes,\n formAppElement,\n formTitle,\n issueMessagesDataKey,\n issuesDisplayMode,\n readOnly,\n store,\n ],\n );\n}\n\n/** Returns the context of the form app. */\nexport function useFormAppContext<T = unknown>(): FormAppContextValue<T> {\n const formAppContext = useContext(FormAppContext);\n if (!formAppContext) {\n throw new Error(\"Form app context not in scope.\");\n }\n return formAppContext as FormAppContextValue<T>;\n}\n\n/** Returns the title of the form, if provided to the `FormApp` component. */\nexport function useFormTitle(): string | undefined {\n return useFormAppContext().formTitle;\n}\n\n/** Returns a boolean representing whether the form is disabled. */\nexport function useFormIsDisabled(): boolean {\n return useFormAppContext().disabled;\n}\n\n/** Returns a boolean representing whether the form is read-only. */\nexport function useFormIsReadOnly(): boolean {\n return useFormAppContext().readOnly;\n}\n\n/** Returns the form app's display mode for issue messages. */\nexport function useIssuesDisplayMode(): IssuesDisplayMode {\n return useFormAppContext().issuesDisplayMode;\n}\n\n/**\n * Returns whether issue codes should be displayed (by default) within issue\n * messages.\n */\nexport function useDisplayIssueCodesInIssueMessages(): boolean {\n return useFormAppContext().displayIssueCodes;\n}\n\n/** Hook providing access to the form app's HTML form element. */\nexport function useFormAppElement(): HTMLFormElement {\n return useFormAppContext().formAppElement!;\n}\n\n/** Returns whether the form is in debug mode. */\nexport function useFormInDebugMode(): boolean {\n return useFormAppContext().debug;\n}\n\n/**\n * Hook exposing a function that can be used to specify the height of the form\n * app's top bar.\n */\nexport function useSetTopBarHeight(): (height?: number) => void {\n const { store } = useFormAppContext();\n const printing = usePrinting();\n return useCallback(\n (height?: number) =>\n !printing && store.setState({ topBarHeight: height ?? 0 }),\n [printing, store],\n );\n}\n\n/**\n * Hook exposing a function that can be used to specify the width of the form\n * app's left panel.\n */\nexport function useSetLeftSidebarWidth(): (width?: number) => void {\n const { store } = useFormAppContext();\n const printing = usePrinting();\n return useCallback(\n (width?: number) =>\n !printing && store.setState({ leftSidebarWidth: width ?? 0 }),\n [printing, store],\n );\n}\n\n/**\n * Hook exposing a function that can be used to specify the height of the form\n * app's bottom panel.\n */\nexport function useSetBottomPanelHeight(): (height?: number) => void {\n const { store } = useFormAppContext();\n const printing = usePrinting();\n return useCallback(\n (height?: number) =>\n !printing && store.setState({ bottomPanelHeight: height ?? 0 }),\n [printing, store],\n );\n}\n\n/**\n * Returns the current issues panel path of the form app and a function that can\n * be used to set it, ala `useState`.\n */\nexport function useIssuesPanelPath(): [\n AbsolutePath | null,\n FormAppActions[\"setIssuesPanelPath\"],\n] {\n return useStore(\n useFormAppContext().store,\n useShallow((state) => [\n state.issuesPanelPath,\n state.actions.setIssuesPanelPath,\n ]),\n );\n}\n\n/** Hook exposing a function that can be used to focus a path within a form app. */\nexport function useFocus(): FormAppActions[\"focus\"] {\n return useStore(useFormAppContext().store, (state) => state.actions.focus);\n}\n\n/** Hook exposing a function that can be used to reset the focus. */\nexport function useResetFocus(): FormAppActions[\"resetFocus\"] {\n return useStore(\n useFormAppContext().store,\n (state) => state.actions.resetFocus,\n );\n}\n\n/**\n * Hook used to register a controller within the form app. This makes the form\n * app aware that a controller of a certain path is currently being rendered.\n */\nexport function useRegisterController(controller: Controller<any>) {\n const store = useFormAppContext().store;\n const path = controller.usePath();\n const printing = usePrinting();\n useEffect(() => {\n if (!printing) {\n return store.getState().actions.registerController(path, controller);\n }\n }, [store, controller, path, printing]);\n}\n\n/** Hook to check whether there is a registered controller for the provided path. */\nexport function useIsRegistered(path?: AbsolutePath | null): boolean {\n return useStore(\n useFormAppContext().store,\n (state) => path != null && state.actions.isRegistered(path),\n );\n}\n\n/** Hook exposing the latest path that the user has interacted with. */\nexport function useLatestInteraction(): AbsolutePath {\n return useStore(\n useFormAppContext().store,\n (state) => state.latestInteraction,\n );\n}\n\n/** Hook exposing a function to set the latest path the user has interacted with. */\nexport function useSetLatestInteraction(): FormAppActions[\"setLatestInteraction\"] {\n return useStore(\n useFormAppContext().store,\n (state) => state.actions.setLatestInteraction,\n );\n}\n\n/** Hook used to register issue messages within the form app. */\nexport function useRegisterIssueMessages(\n path: AbsolutePath | null | undefined,\n issueMessages?: Record<string, IssueMessagesByCode>,\n priority?: number,\n) {\n const store = useFormAppContext().store;\n const printing = usePrinting();\n useEffect(() => {\n if (!printing && path != null) {\n return store\n .getState()\n .actions.registerIssueMessages(path, issueMessages, priority);\n }\n }, [path, issueMessages, priority, store, printing]);\n}\n\n/** Hook used to get the issue message value for the provided path and code. */\nexport function useRegisteredIssueMessage(\n path: AbsolutePath | null | undefined,\n code: string,\n): IssueMessageValue {\n return useStore(useFormAppContext().store, (state) =>\n path == null ? null : state.actions.getRegisteredIssueMessage(path, code),\n );\n}\n\n/** Hook used to register a label within the form app. */\nexport function useRegisterLabel(\n path: AbsolutePath | null | undefined,\n label: ReactNode,\n priority = 0,\n) {\n const store = useFormAppContext().store;\n const printing = usePrinting();\n useEffect(() => {\n if (!printing && path != null) {\n return store.getState().actions.registerLabel(path, label, priority);\n }\n }, [store, path, label, priority, printing]);\n}\n\n/**\n * Hook used to get the label parts associated with the active issues panel\n * path.\n */\nexport function useActiveIssuesPanelBreadcrumb(): BreadcrumbItem[] | null {\n return useStore(\n useFormAppContext().store,\n useEqualityFn(\n (state) => state.actions.getActiveIssuesPanelBreadcrumb(),\n equalBreadcrumbItems,\n ),\n );\n}\nfunction equalBreadcrumbItems(\n breadcrumbs1: BreadcrumbItem[] | null,\n breadcrumbs2: BreadcrumbItem[] | null,\n) {\n if (breadcrumbs1 == null || breadcrumbs2 == null) {\n return breadcrumbs1 === breadcrumbs2;\n }\n return (\n breadcrumbs1.length === breadcrumbs2.length &&\n breadcrumbs1.every((breadcrumb1, i) => {\n const breadcrumb2 = breadcrumbs2[i];\n return (\n breadcrumb1.path.toString() === breadcrumb2.path.toString() &&\n Object.is(breadcrumb1.label, breadcrumb2.label)\n );\n })\n );\n}\n\n/**\n * Hook exposing a function that can be used to start navigating through the\n * form app's issues.\n */\nexport function useStartIssuesNavigation(): FormAppActions[\"startIssuesNavigation\"] {\n return useStore(\n useFormAppContext().store,\n (state) => state.actions.startIssuesNavigation,\n );\n}\n\n/** Options available to the {@link useOnPathFocus} hook. */\nexport interface UseOnFocusedPathChangeOptions {\n /**\n * Whether to enable the hook.\n *\n * @default true\n */\n enabled?: boolean;\n /**\n * Whether to run the callback immediately with the current focused path.\n *\n * @default true\n */\n fireImmediately?: boolean;\n}\n\n/**\n * Hook used to run a given function whenever the form app's focused path\n * changes.\n *\n * @param cb Function to run when the focused path changes. This function should\n * hopefully not change on every render (i.e. it should be memoised via\n * `useCallback` or be defined externally).\n * @param options Hook options.\n */\nexport function useOnPathFocus(\n cb: (focusedPath: AbsolutePath) => void,\n {\n enabled = true,\n fireImmediately = true,\n }: UseOnFocusedPathChangeOptions = {},\n) {\n const { store } = useFormAppContext();\n const printing = usePrinting();\n useEffect(() => {\n if (enabled && !printing) {\n return store.subscribe(\n ({ focusedPath, focusCounter }) => ({ focusedPath, focusCounter }),\n ({ focusedPath }) => focusedPath && cb(focusedPath),\n { fireImmediately, equalityFn: shallow },\n );\n }\n }, [cb, enabled, fireImmediately, printing, store]);\n}\n\n/** Hook used to set the function which starts issue navigation. */\nexport function useSetStartIssuesNavigation(fn: () => void) {\n const { store } = useFormAppContext();\n const printing = usePrinting();\n useEffect(() => {\n if (!printing) {\n store.setState({ startIssuesNavigation: fn });\n return () => store.setState({ startIssuesNavigation: undefined });\n }\n }, [fn, printing, store]);\n}\n","import type {\n AbsolutePath,\n Schema,\n SealedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport { CurrentPath } from \"@ostack.tech/kform-react\";\nimport { VisuallyHidden } from \"@ostack.tech/ui\";\nimport type { ComponentProps } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport {\n useDisplayIssueCodesInIssueMessages,\n useRegisteredIssueMessage,\n} from \"../FormApp\";\nimport { useFormAppContext } from \"../FormApp/FormAppContext.ts\";\nimport type { IssueMessagesProps, IssueMessageValue } from \"../IssueMessages\";\n\n/** Default data key where to check for an issue message. */\nexport const DEFAULT_ISSUE_MESSAGE_DATA_KEY = \"message\";\n\n/** Properties of the issue message component. */\nexport interface IssueMessageProps extends Pick<\n IssueMessagesProps,\n | \"visuallyHiddenErrorCodePrefix\"\n | \"visuallyHiddenWarningCodePrefix\"\n | \"unknownErrorMessage\"\n | \"unknownWarningMessage\"\n> {\n displayIssueCode?: boolean;\n messageDataKey?: string;\n path: AbsolutePath;\n issue: SealedValidationIssue;\n schema: Schema;\n issueCodeProps?: ComponentProps<\"span\">;\n}\n\n/** Single issue message within the issue messages or issues panel components. */\nexport function IssueMessage({\n path,\n issue,\n schema,\n displayIssueCode,\n messageDataKey,\n visuallyHiddenErrorCodePrefix,\n visuallyHiddenWarningCodePrefix,\n unknownErrorMessage,\n unknownWarningMessage,\n issueCodeProps,\n}: IssueMessageProps) {\n const { issueMessagesDataKey } = useFormAppContext();\n messageDataKey ??= issueMessagesDataKey;\n\n const [locale] = useLocale();\n visuallyHiddenErrorCodePrefix ??=\n locale.IssueMessages.visuallyHiddenErrorCodePrefix;\n visuallyHiddenWarningCodePrefix ??=\n locale.IssueMessages.visuallyHiddenWarningCodePrefix;\n unknownErrorMessage ??= locale.IssueMessages.unknownErrorMessage;\n unknownWarningMessage ??= locale.IssueMessages.unknownWarningMessage;\n\n let message: IssueMessageValue =\n useRegisteredIssueMessage(path, issue.code) ?? issue.data[messageDataKey];\n const unknownMessage = message == null;\n if (unknownMessage) {\n message =\n issue.severity === \"error\" ? unknownErrorMessage : unknownWarningMessage;\n // if (DEV) {\n // warnOnce(\n // `At '${path.toString()}': no message found for ` +\n // `issue with code: '${issue.code}'.`,\n // );\n // }\n }\n\n const globalDisplayIssueCodes = useDisplayIssueCodesInIssueMessages();\n displayIssueCode ??= globalDisplayIssueCodes;\n\n return (\n <CurrentPath path={path}>\n {typeof message === \"function\"\n ? message(issue.data ?? {}, schema, path)\n : message}\n {(displayIssueCode || unknownMessage) && (\n <span {...issueCodeProps}>\n {\" \"}\n (\n {issue.severity === \"error\" && visuallyHiddenErrorCodePrefix && (\n <VisuallyHidden>{visuallyHiddenErrorCodePrefix} </VisuallyHidden>\n )}\n {issue.severity === \"warning\" && visuallyHiddenWarningCodePrefix && (\n <VisuallyHidden>{visuallyHiddenWarningCodePrefix} </VisuallyHidden>\n )}\n {issue.code})\n </span>\n )}\n </CurrentPath>\n );\n}\n","import type { Controller } from \"@ostack.tech/kform-react\";\nimport { NATIVE_CONTROLS, useCssVars, useSpacing } from \"@ostack.tech/ui\";\nimport { type RefObject, useCallback, useRef } from \"react\";\n\nimport { useOnPathFocus } from \"../components/FormApp\";\nimport { useResetFocus } from \"../components/FormApp/FormAppContext.ts\";\nimport { usePrefix } from \"../providers/PrefixSuffixProvider\";\n\nconst FOCUSABLE_ELEMENTS = [\"INPUT\", \"SELECT\", \"TEXTAREA\"];\n\n/**\n * Function used to scroll an element into view.\n *\n * @param el Element to scroll into view.\n * @param options Scroll into view options.\n */\nexport type ScrollIntoViewFn = (\n el: HTMLElement,\n options?: ScrollIntoViewOptions,\n) => void;\n\n/**\n * Hook used to autofocus a control when the active path changes, given the\n * control's path.\n *\n * @param controller Control's controller.\n * @param enabled Whether to enable the auto-focus behaviour.\n * @returns Reference that should be set on the focusable element of the\n * control.\n */\nexport function useControlAutofocus<\n T = unknown,\n TElem extends HTMLElement = HTMLElement,\n>(\n { usePath, useExists }: Controller<T>,\n enabled = true,\n): RefObject<TElem | null> {\n const controlRef = useRef<TElem | null>(null);\n const path = usePath();\n const exists = useExists();\n const resetFocus = useResetFocus();\n const scrollIntoView = useScrollIntoView();\n\n const timeoutId = useRef<number>(undefined);\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n const control = controlRef.current;\n if (enabled && control && exists && path.equals(focusedPath)) {\n clearTimeout(timeoutId.current);\n timeoutId.current = window.setTimeout(() => {\n scrollIntoView(control);\n visiblyFocus(control);\n resetFocus();\n }, 50);\n }\n },\n [enabled, exists, path, resetFocus, scrollIntoView],\n ),\n );\n\n return controlRef;\n}\n\n/**\n * Visibly focuses the provided element.\n *\n * @param el Element to visibly focus.\n * @param options Focus options.\n */\nexport function visiblyFocus(el: HTMLElement, options?: FocusOptions) {\n const focusOptions: FocusOptions = {\n preventScroll: true,\n // This option is experimental, but works well in Firefox, so might as well\n // use it\n focusVisible: true,\n ...options,\n };\n\n if (FOCUSABLE_ELEMENTS.includes(el.tagName)) {\n el.focus(focusOptions);\n } else {\n // XXX: Trick browser into triggering `:focus-visible`\n const contentEditable = el.contentEditable;\n el.contentEditable = \"true\";\n el.focus(focusOptions);\n el.contentEditable = contentEditable;\n }\n}\n\n/**\n * Returns a function used the scroll an element into view, taking into account\n * the form app's sticky elements, so that elements don't end up hidden behind\n * them.\n */\nexport function useScrollIntoView(): ScrollIntoViewFn {\n const prefix = usePrefix();\n const spacing = useSpacing();\n const { cssVar } = useCssVars({ prefix });\n\n return useCallback(\n (el: HTMLElement, options?: ScrollIntoViewOptions) => {\n const scrollableParent = getScrollableParent(el);\n const scrollMarginBlockStart = el.style.scrollMarginBlockStart;\n const scrollMarginBlockEnd = el.style.scrollMarginBlockEnd;\n el.style.scrollMarginBlockStart = `calc(${cssVar(\"top-bar-height\")} + ${cssVar(\n \"form-pages-page-header-height\",\n )} + ${spacing(4)})`;\n el.style.scrollMarginBlockEnd = `calc(${cssVar(\"bottom-panel-height\")} + ${spacing(4)})`;\n const shouldCenter =\n !NATIVE_CONTROLS.has(el.tagName) ||\n scrollableParent !==\n (document.scrollingElement ?? document.documentElement);\n el.scrollIntoView({\n block: shouldCenter ? \"center\" : \"nearest\",\n inline: shouldCenter ? \"center\" : \"nearest\",\n behavior: \"smooth\",\n ...options,\n });\n el.style.scrollMarginBlockStart = scrollMarginBlockStart;\n el.style.scrollMarginBlockEnd = scrollMarginBlockEnd;\n },\n [cssVar, spacing],\n );\n}\n\n/**\n * Gets the nearest scrollable parent.\n *\n * @param el Element for which to get the nearest scrollable parent.\n */\nfunction getScrollableParent(el: Element): Element {\n let current = el.parentNode;\n while (current instanceof Element) {\n const overflow = getComputedStyle(current, null).getPropertyValue(\n \"overflow\",\n );\n if (overflow.includes(\"scroll\") || overflow.includes(\"auto\")) {\n return current;\n }\n current = current.parentNode;\n }\n return document.scrollingElement ?? document.documentElement;\n}\n","import { useFormController } from \"@ostack.tech/kform-react\";\nimport { useCallback } from \"react\";\n\nimport {\n useScrollIntoView,\n visiblyFocus,\n} from \"../../utils/useControlAutofocus.ts\";\nimport {\n useFormAppElement,\n useIssuesDisplayMode,\n useOnPathFocus,\n useResetFocus,\n} from \"./FormAppContext.ts\";\n\n/** Component enabling support for auto-focusing the form app via `focus(\"/\")`. */\nexport function FormAppAutoFocus() {\n const initialized = useFormController().useInitialized();\n const formAppEl = useFormAppElement();\n const scrollIntoView = useScrollIntoView();\n\n const issuesDisplayMode = useIssuesDisplayMode();\n const resetFocus = useResetFocus();\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n if (initialized && focusedPath.isRoot) {\n // In inline mode an issues popover should get focused instead\n if (issuesDisplayMode === \"panel\") {\n scrollIntoView(formAppEl);\n visiblyFocus(formAppEl);\n }\n resetFocus();\n }\n },\n [initialized, issuesDisplayMode, resetFocus, scrollIntoView, formAppEl],\n ),\n );\n return null;\n}\n","import {\n cx,\n useCombinedRef,\n useCssVars,\n useResponsiveValues,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type Dispatch,\n type SetStateAction,\n useEffect,\n} from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport type { FormAppProps } from \"./FormApp.tsx\";\nimport { useFormAppContext, useFormTitle } from \"./FormAppContext.ts\";\n\n/** Properties of the form application element component. */\nexport interface FormAppElementProps\n extends\n Omit<ComponentProps<\"form\">, \"onSubmit\" | \"onReset\">,\n Pick<FormAppProps, \"minHeight\"> {\n formAppElement: HTMLFormElement | null;\n setFormAppElement: Dispatch<SetStateAction<HTMLFormElement | null>>;\n}\n\n/** Form application element. */\nexport function FormAppElement({\n formAppElement,\n setFormAppElement,\n minHeight,\n className,\n style,\n children,\n ref,\n ...otherProps\n}: FormAppElementProps) {\n const prefix = usePrefix();\n const { cssVarName } = useCssVars({ prefix });\n const { responsiveValueToCssVarsAndDataAttrs } = useResponsiveValues({\n prefix,\n });\n const { store } = useFormAppContext();\n const formTitle = useFormTitle();\n\n // Top-bar height\n useEffect(\n () =>\n store.subscribe(\n ({ topBarHeight }) => topBarHeight,\n (height) =>\n formAppElement?.style.setProperty(\n cssVarName(\"top-bar-height\"),\n `${height}px`,\n ),\n { fireImmediately: true },\n ),\n [cssVarName, formAppElement, store],\n );\n\n // Left sidebar width\n useEffect(\n () =>\n store.subscribe(\n ({ leftSidebarWidth }) => leftSidebarWidth,\n (width) =>\n formAppElement?.style.setProperty(\n cssVarName(\"left-sidebar-width\"),\n `${width}px`,\n ),\n { fireImmediately: true },\n ),\n [cssVarName, formAppElement, store],\n );\n\n // Bottom panel height\n useEffect(\n () =>\n store.subscribe(\n ({ bottomPanelHeight }) => bottomPanelHeight,\n (height) =>\n formAppElement?.style.setProperty(\n cssVarName(\"bottom-panel-height\"),\n `${height}px`,\n ),\n { fireImmediately: true },\n ),\n [cssVarName, formAppElement, store],\n );\n\n // Form app min height\n const { cssVars, dataAttrs } = responsiveValueToCssVarsAndDataAttrs(\n \"form-app\",\n \"min-height\",\n minHeight,\n (v) => (typeof v === \"number\" ? `${v}px` : v),\n );\n\n const combinedFormAppRef = useCombinedRef(setFormAppElement, ref);\n return (\n <form\n className={cx(prefix(\"form-app\"), className)}\n style={{ ...cssVars, ...style }}\n aria-label={formTitle}\n tabIndex={-1}\n {...dataAttrs}\n {...otherProps}\n ref={combinedFormAppRef}\n >\n {children}\n </form>\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport { useResolvedPath } from \"@ostack.tech/kform-react\";\nimport type { ReactNode } from \"react\";\n\nimport type { IssueMessagesByCode } from \"../IssueMessages\";\nimport { useRegisterIssueMessages } from \"./FormAppContext.ts\";\n\n/** Properties of the form app issue messages component. */\nexport interface FormAppIssueMessagesProps {\n /** Base path for the paths used in `messages`. */\n path?: string | Path;\n /**\n * Mapping of issue messages from the path of the field with issues to the\n * issue messages of said field (which are themselves grouped by their code).\n *\n * Provided paths may contain wildcards, which will have a lower priority when\n * matched against.\n *\n * These messages are used by the `IssueMessages` and `IssuesPanel`\n * components.\n *\n * Example value:\n *\n * ```tsx\n * {\n * \"/**\": {\n * \"valueMissing\": \"Field is required.\"\n * },\n * \"/my/field\": {\n * \"valueMissing\": \"My field cannot be left empty!\",\n * \"someOtherError\": \"Text of the other error.\"\n * }\n * }\n * ```\n */\n issueMessages?: Record<string, IssueMessagesByCode>;\n /**\n * Priority to use when registering issue messages.\n *\n * When multiple issue messages are associated with the same path, then the\n * one registered with the highest priority \"wins\".\n *\n * @default 0\n */\n priority?: number;\n children: ReactNode;\n}\n\n/** Component used to register new issue messages within the form app. */\nexport function FormAppIssueMessages({\n path,\n issueMessages,\n priority,\n children,\n}: FormAppIssueMessagesProps) {\n const absolutePath = useResolvedPath(path);\n useRegisterIssueMessages(absolutePath, issueMessages, priority);\n return children;\n}\n","import {\n AbsolutePath,\n type Path,\n type Schema,\n type SchemaKt,\n} from \"@ostack.tech/kform\";\nimport {\n type Controller,\n FormContext,\n type FormOptions,\n useForm,\n} from \"@ostack.tech/kform-react\";\nimport {\n PrefixProvider,\n type Responsive,\n Root,\n type RootProps,\n useIsInRoot,\n usePrintInProgress,\n warnOnce,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from \"react\";\nimport { useStore } from \"zustand\";\n\nimport {\n ActivePathProvider,\n type OnActivePathChangeNavigationOptions,\n} from \"../../providers/ActivePathProvider\";\nimport type { LocalizationObject } from \"../../providers/LocalizationProvider\";\nimport {\n LocalizationContext,\n LocalizationProvider,\n} from \"../../providers/LocalizationProvider\";\nimport { PrefixSuffixProvider } from \"../../providers/PrefixSuffixProvider\";\nimport { DEFAULT_ISSUE_MESSAGE_DATA_KEY } from \"../IssueMessage\";\nimport type { IssueMessagesByCode } from \"../IssueMessages\";\nimport { FormAppAutoFocus } from \"./FormAppAutoFocus.tsx\";\nimport { FormAppContext, useCreateFormAppContext } from \"./FormAppContext.ts\";\nimport { FormAppElement } from \"./FormAppElement.tsx\";\nimport { FormAppIssueMessages } from \"./FormAppIssueMessages.tsx\";\n\n/** Mode of displaying issue messages. */\nexport type IssuesDisplayMode = \"inline\" | \"panel\";\n\n/** Properties of the form app component. */\nexport interface FormAppProps<T = any>\n extends\n Pick<\n RootProps,\n | \"enableErrorReporting\"\n | \"reportError\"\n | \"errorReportingUrl\"\n | \"errorReportingMethod\"\n | \"encodeErrorReport\"\n | \"encodedErrorReportMimeType\"\n | \"errorReportingOptions\"\n | \"baseDocumentTitle\"\n | \"documentTitleBaseSeparator\"\n | \"documentTitleBreadcrumbsSeparator\"\n | \"portalsContainer\"\n | \"tooltipsDelayDuration\"\n | \"tooltipsSkipDelayDuration\"\n | \"disableTooltipsHoverableContent\"\n | \"toastsLabel\"\n | \"toastsDuration\"\n | \"toastsSwipeDirection\"\n | \"toastsSwipeThreshold\"\n | \"toastViewportPosition\"\n | \"toastViewportHotkey\"\n | \"toastViewportLabel\"\n | \"toastViewportProps\"\n | \"errorBoundaryProps\"\n >,\n FormOptions<T>,\n Omit<ComponentProps<\"form\">, \"onSubmit\" | \"onReset\"> {\n /** Schema of the form. */\n schema: Schema<T> | SchemaKt;\n /** Title of the form. */\n formTitle?: string;\n /**\n * Label to use in the issues panel when displaying issues associated with the\n * form app. Defaults to the `formTitle`.\n */\n issuesPanelLabel?: ReactNode;\n /** Whether to disable the whole form. */\n disabled?: boolean;\n /** Whether to set the whole form as read-only. */\n readOnly?: boolean;\n /**\n * Custom suffix to add to the ostack/UI's prefix when prefixing all component\n * classes, styles, etc.\n *\n * This prefix-suffix should match the `$prefix-suffix` SCSS variable.\n */\n prefixSuffix?: string;\n /** Uncontrolled form app locale. */\n defaultLocale?: LocalizationObject;\n /** Controlled form app locale. */\n locale?: LocalizationObject;\n /**\n * Function called when the locale changes.\n *\n * @param locale New locale.\n */\n onLocaleChange?: (locale: LocalizationObject) => void;\n /**\n * Mapping of issue messages from the path of the field with issues to the\n * issue messages of said field (which are themselves grouped by their code).\n *\n * Provided paths may contain wildcards, which will have a lower priority when\n * matched against.\n *\n * These messages are used by the `IssueMessages` component.\n *\n * > **Note:** Changes to `issueMessages` are handled correctly, but are not\n * > efficient. Please make sure that the identity of the provided value doesn't\n * > change at every render.\n *\n * Example value:\n *\n * ```tsx\n * {\n * \"/**\": {\n * \"valueMissing\": \"Field is required.\"\n * },\n * \"/my/field\": {\n * \"valueMissing\": \"My field cannot be left empty!\",\n * \"someOtherError\": \"Text of the other error.\"\n * }\n * }\n * ```\n */\n issueMessages?: Record<string, IssueMessagesByCode>;\n /**\n * Mode of displaying issues:\n *\n * - `inline` mode dispays issue messages near the component containing the\n * issues. In this mode the bottom issues panel only functions as an aid for\n * navigating issues.\n * - `panel` mode displays issue messages within the bottom issues panel.\n *\n * @default \"inline\"\n */\n issuesDisplayMode?: IssuesDisplayMode;\n /**\n * Global setting which specifies whether issue codes should be added to each\n * issue message.\n *\n * @default false\n */\n displayIssueCodes?: boolean;\n /**\n * Name of the key in the data object of validation issues that possibly\n * contains the issue message to display. This message is only used if no\n * matching message is otherwise found.\n *\n * @default \"message\"\n */\n issueMessagesDataKey?: string;\n /** Uncontrolled default active path to use. */\n defaultActivePath?: string | Path;\n /** Controlled active path to use. */\n activePath?: string | Path;\n /**\n * Callback called whenever the active path changes.\n *\n * @param activePath New active path.\n * @param options Navigation options to use when controlling the active path\n * via the browser's URL.\n */\n onActivePathChange?: (\n activePath: AbsolutePath,\n options: OnActivePathChangeNavigationOptions,\n ) => void;\n /**\n * Function called when a form path is focused.\n *\n * @param path Focused path.\n */\n onPathFocus?: (path: AbsolutePath) => void;\n /**\n * Minimum height of the form app. Values should **not** be percentages.\n *\n * @default \"100dvh\"\n */\n minHeight?: Responsive<number | string>;\n /**\n * Show debug information for all form controls. This property has no effect\n * in production builds.\n */\n debug?: boolean;\n /** Reference to the form app's API. */\n apiRef?: Ref<FormAppApi<T> | undefined>;\n}\n\n/** Imperative form app API. */\nexport type FormAppApi<T = any> = Controller<T> & {\n /**\n * Focuses the form element at the provided path.\n *\n * @param path Path of element to focus.\n */\n focus: (path: string | Path) => void;\n /**\n * Starts issues navigation (when an `IssuesPanel` component exists within).\n *\n * @param options Options used when starting issues navigation.\n * @returns Promise which returns with whether issues navigation was started\n * (whether an `IssuesPanel` component exists within).\n */\n startIssuesNavigation: (options: {\n validate?: boolean;\n setTouched?: boolean;\n }) => PromiseLike<void>;\n};\n\n/**\n * Root component of a form application. Built on top of the\n * ostack/KForm-React's `useForm` hook.\n *\n * The `FormApp` component automatically renders the ostack/UI's `Root`\n * component when not rendered within one, in which case all `Root` component\n * properties are supported. The ostack/UI's `locale` is automatically provided\n * to the ostack/UI `Root` component from the provided `FormApp` `locale`.\n *\n * Example usage:\n *\n * ```tsx\n * import { Button, Field, Label, Stack } from \"@ostack.tech/ui\";\n * import { FormApp, TextControl } from \"@ostack.tech/ui-kform\";\n *\n * export function SignInForm() {\n * return (\n * <FormApp schema={SignInFormSchema} onSubmit={signIn} minHeight={0}>\n * <Stack>\n * <Field>\n * <Label>Email</Label>\n * <TextControl path=\"/email\" type=\"email\" />\n * </Field>\n * <Field>\n * <Label>Password</Label>\n * <TextControl path=\"/password\" type=\"password\" />\n * </Field>\n * <Button color=\"primary\" type=\"submit\">\n * Sign in\n * </Button>\n * </Stack>\n * </FormApp>\n * );\n * }\n * ```\n */\nexport function FormApp<T = any>({\n enableErrorReporting,\n reportError,\n errorReportingUrl,\n errorReportingMethod,\n encodeErrorReport,\n encodedErrorReportMimeType,\n errorReportingOptions,\n baseDocumentTitle,\n documentTitleBaseSeparator,\n documentTitleBreadcrumbsSeparator,\n portalsContainer,\n tooltipsDelayDuration,\n tooltipsSkipDelayDuration,\n disableTooltipsHoverableContent,\n toastsLabel,\n toastsDuration,\n toastsSwipeDirection,\n toastsSwipeThreshold,\n toastViewportPosition,\n toastViewportHotkey,\n toastViewportLabel,\n toastViewportProps,\n errorBoundaryProps,\n schema,\n initialValue,\n formTitle,\n issuesPanelLabel,\n disabled = false,\n readOnly = false,\n prefix: newPrefix,\n prefixSuffix,\n defaultLocale,\n locale: controlledLocale,\n onLocaleChange,\n issueMessages,\n issuesDisplayMode = \"inline\",\n displayIssueCodes = false,\n issueMessagesDataKey = DEFAULT_ISSUE_MESSAGE_DATA_KEY,\n defaultActivePath,\n activePath,\n onActivePathChange,\n onPathFocus,\n minHeight,\n debug = false,\n apiRef,\n externalContexts,\n validationMode = readOnly ? \"manual\" : \"auto\",\n confirmUnloadWhenDirty,\n confirmUnloadMessage,\n onSubmit,\n onInvalidSubmit,\n onSuccessfulSubmit,\n onFailedSubmit,\n validateOnSubmit,\n setTouchedOnSubmit,\n setPristineOnSuccessfulSubmit,\n convertExternalIssuesTableRowIndicesToIds,\n onReset,\n onInitialized,\n onUninitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n ...otherProps\n}: FormAppProps<T>) {\n const isInRoot = useIsInRoot();\n const rootProps = {\n enableErrorReporting,\n reportError,\n errorReportingUrl,\n errorReportingMethod,\n encodeErrorReport,\n encodedErrorReportMimeType,\n errorReportingOptions,\n baseDocumentTitle,\n documentTitleBaseSeparator,\n documentTitleBreadcrumbsSeparator,\n portalsContainer,\n tooltipsDelayDuration,\n tooltipsSkipDelayDuration,\n disableTooltipsHoverableContent,\n toastsLabel,\n toastsDuration,\n toastsSwipeDirection,\n toastsSwipeThreshold,\n toastViewportPosition,\n toastViewportHotkey,\n toastViewportLabel,\n toastViewportProps,\n errorBoundaryProps,\n };\n if (isInRoot && Object.values(rootProps).some((prop) => prop !== undefined)) {\n warnOnce(\n `FormApp: Properties ${Object.keys(rootProps)\n .map((prop) => `\\`${prop}\\``)\n .join(\", \")} have no effect when the \\`FormApp\\` is already ` +\n \"inside an ostack/UI's `Root` component. Please set any of these \" +\n \"properties on the `Root` component directly instead.\",\n );\n }\n\n const contextLocale = useContext(LocalizationContext)?.locale;\n const locale = controlledLocale ?? defaultLocale ?? contextLocale;\n if (locale == null) {\n throw new Error(\n \"FormApp: No locale has been provided. Either provide a \" +\n \"`defaultLocale`/`locale` property or wrap the component in a \" +\n \"`LocalizationProvider`.\",\n );\n }\n formTitle ??= locale.FormApp.formTitle;\n issuesPanelLabel ??= locale.FormApp.issuesPanelLabel ?? formTitle;\n confirmUnloadMessage ??= locale.FormApp.confirmUnloadMessage;\n\n const controller = useForm<T>(schema, {\n initialValue,\n externalContexts,\n validationMode,\n confirmUnloadWhenDirty,\n confirmUnloadMessage,\n onSubmit,\n onInvalidSubmit: async (issues, event) => {\n await startIssuesNavigation({ validate: false });\n onInvalidSubmit?.(issues, event);\n },\n onSuccessfulSubmit,\n onFailedSubmit,\n validateOnSubmit,\n setTouchedOnSubmit,\n setPristineOnSuccessfulSubmit,\n convertExternalIssuesTableRowIndicesToIds,\n onReset,\n onInitialized,\n onUninitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n } as FormOptions<T>);\n const { formProps } = controller;\n\n // Reference to the form app element (used to scroll into view on page\n // changes, since scrolling a page itself into view hides elements under the\n // top-bar)\n const [formAppElement, setFormAppElement] = useState<HTMLFormElement | null>(\n null,\n );\n\n const formManager = controller.useFormManager();\n const formContext = useMemo(\n () => ({\n formManager,\n currentPath: AbsolutePath.ROOT,\n controller,\n }),\n [controller, formManager],\n );\n\n const printInProgress = usePrintInProgress();\n const displayDisabled =\n controller.useSubmitting() || disabled || printInProgress;\n const formAppContextValue = useCreateFormAppContext<T>({\n formTitle,\n disabled: displayDisabled,\n readOnly,\n issuesDisplayMode,\n displayIssueCodes,\n issueMessagesDataKey,\n controller,\n onPathFocus,\n formAppElement,\n debug,\n });\n const { store } = formAppContextValue;\n\n useEffect(\n () =>\n store\n .getState()\n .actions.registerController(AbsolutePath.ROOT, controller),\n [controller, store],\n );\n\n const absolutePath = controller.usePath();\n useEffect(\n () =>\n store.getState().actions.registerLabel(absolutePath, issuesPanelLabel),\n [absolutePath, issuesPanelLabel, store],\n );\n\n // Expose the control's API via `apiRef`\n const { focus, startIssuesNavigation } = useStore(\n store,\n (state) => state.actions,\n );\n useImperativeHandle(\n apiRef,\n () => ({\n ...controller,\n focus,\n startIssuesNavigation,\n }),\n [focus, controller, startIssuesNavigation],\n );\n\n const formAppEl = (\n <FormAppElement\n minHeight={minHeight}\n formAppElement={formAppElement}\n setFormAppElement={setFormAppElement}\n {...formProps}\n {...otherProps}\n />\n );\n\n return (\n <PrefixProvider prefix={newPrefix}>\n <PrefixSuffixProvider prefixSuffix={prefixSuffix}>\n <LocalizationProvider\n defaultLocale={defaultLocale}\n locale={controlledLocale}\n onLocaleChange={onLocaleChange}\n >\n <FormContext.Provider value={formContext}>\n <FormAppContext.Provider value={formAppContextValue as never}>\n <ActivePathProvider\n defaultActivePath={defaultActivePath}\n activePath={activePath}\n onActivePathChange={onActivePathChange}\n >\n <FormAppIssueMessages\n issueMessages={locale.FormApp.issueMessages}\n priority={-1}\n >\n <FormAppIssueMessages issueMessages={issueMessages}>\n <FormAppAutoFocus />\n\n {isInRoot ? (\n formAppEl\n ) : (\n <Root asChild {...rootProps}>\n {formAppEl}\n </Root>\n )}\n </FormAppIssueMessages>\n </FormAppIssueMessages>\n </ActivePathProvider>\n </FormAppContext.Provider>\n </FormContext.Provider>\n </LocalizationProvider>\n </PrefixSuffixProvider>\n </PrefixProvider>\n );\n}\n","import { type ReactNode, useMemo } from \"react\";\n\nimport { FormAppContext, useFormAppContext } from \"./FormAppContext.ts\";\n\n/** Properties of the form app status component. */\nexport interface FormAppStatusProps {\n /**\n * Whether to mark the form app as disabled for children of this component.\n *\n * This property has no effect when set to `false`.\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Whether to mark the form app as read-only for children of this component.\n *\n * This property has no effect when set to `false`.\n *\n * @default false\n */\n readOnly?: boolean;\n children: ReactNode;\n}\n\n/** Component used to apply a different form app status to part of the form. */\nexport function FormAppStatus({\n disabled = false,\n readOnly = false,\n children,\n}: FormAppStatusProps) {\n const formAppContext = useFormAppContext();\n return (\n <FormAppContext.Provider\n value={useMemo(\n () => ({\n ...formAppContext,\n disabled: formAppContext.disabled || disabled,\n readOnly: formAppContext.readOnly || readOnly,\n }),\n [disabled, formAppContext, readOnly],\n )}\n >\n {children}\n </FormAppContext.Provider>\n );\n}\n","import { AbsolutePath, AbsolutePathFragment } from \"@ostack.tech/kform\";\n\n/**\n * Function which selects the most \"specific\" path from a list of paths, given a\n * path to match. `currentActivePath` contains the path that is currently\n * active.\n *\n * The list of paths may contain paths with a single trailing wildcard.\n *\n * This function is used by the `Annexes`, `FormPages`, and `FormStepper`\n * components to select the next path that should be focused when the focused\n * path changes.\n */\nexport function mostSpecificPath(\n toMatch: AbsolutePath | null,\n paths: AbsolutePath[],\n currentActivePath: AbsolutePath | null,\n): AbsolutePath | null {\n if (!toMatch || paths.length === 0) {\n return null;\n }\n\n // Filter paths containing the focused path and pick the one with the most\n // specific (longest) path\n const mostSpecific = paths\n .filter((path) =>\n path.append(AbsolutePathFragment.RecursiveWildcard).contains(toMatch),\n )\n .reduce(\n (mostSpecific: AbsolutePath | null, path) =>\n mostSpecific === null || path.size > mostSpecific.size\n ? // Replace wildcard with the id of the path to match\n path.lastFragment === AbsolutePathFragment.Wildcard\n ? new AbsolutePath(toMatch.fragments.slice(0, path.size))\n : path\n : mostSpecific,\n null,\n );\n if (mostSpecific) {\n return mostSpecific;\n }\n\n // Return the currently active path when it is still one of the provided paths\n if (\n currentActivePath &&\n paths.some((path) => path.contains(currentActivePath))\n ) {\n return currentActivePath;\n }\n\n // Fallback to the first path\n return paths[0];\n}\n","import {\n AbsolutePath,\n AbsolutePathFragment,\n type DisplayStatus,\n type FormManager,\n type Path,\n type Schema,\n type SealedValidationIssue,\n sliceTableRows,\n type Table,\n type TableRowId,\n tableSize,\n} from \"@ostack.tech/kform\";\nimport {\n computed,\n useConstant,\n useLatestRef,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport {\n createContext,\n type ReactNode,\n startTransition,\n useCallback,\n useContext,\n useEffect,\n} from \"react\";\nimport { createStore, useStore } from \"zustand\";\nimport { subscribeWithSelector } from \"zustand/middleware\";\n\nimport { useActivePathContext } from \"../../providers/ActivePathProvider\";\nimport { mostSpecificPath } from \"../../utils/mostSpecificPath.ts\";\nimport { useOnPathFocus } from \"../FormApp\";\nimport { useSetLatestInteraction } from \"../FormApp/FormAppContext.ts\";\nimport type { AnnexObject } from \"./Annex.tsx\";\nimport type { AnnexesProps } from \"./Annexes.tsx\";\n\n/** Value of the annexes' context. */\nexport type AnnexesContextValue = AnnexesStore;\n\n/** Resolved annex object. */\nexport interface ResolvedAnnexObject extends AnnexObject {\n path: AbsolutePath;\n}\n\n/** Annex state. */\nexport interface AnnexState {\n path: AbsolutePath;\n title: ReactNode;\n subtitle?: ReactNode;\n description?: ReactNode;\n documentTitle?: string | null;\n isRepetitive: boolean;\n schema: Schema;\n isNull: boolean;\n dirty: boolean | undefined;\n deferredDisplayStatus: DisplayStatus | undefined;\n deferredIssuesToDisplay: SealedValidationIssue[];\n}\n\n/** Repetitive annex state. */\nexport type RepetitiveAnnexState = Pick<\n ResolvedAnnexObject,\n \"path\" | \"maxAnnexes\"\n> & {\n rowIds?: TableRowId[];\n schema: Schema;\n deferredIssuesToDisplay: SealedValidationIssue[];\n};\n\n/** State of the annexes. */\nexport interface AnnexesState {\n annexes: ResolvedAnnexObject[];\n activeAnnex: AbsolutePath | null;\n nextActiveAnnex: AbsolutePath | null;\n activeAnnexIndex: () => number;\n // State below is wrapped in an array in order to trigger state updates by\n // simply changing the identity of the wrapper without creating new object\n // instances\n annexStates: [Record<string, AnnexState | null>];\n repetitiveAnnexStates: [Record<string, RepetitiveAnnexState | null>];\n tabStates: () => AnnexState[];\n tablessStates: () => (AnnexState | RepetitiveAnnexState)[];\n waitingRegistration: () => AbsolutePath[];\n actions: AnnexesActions;\n}\n\n/** Actions of the annexes. */\nexport interface AnnexesActions {\n getAnnexState: (path: AbsolutePath) => AnnexState | null;\n getRepetitiveAnnexState: (path: AbsolutePath) => RepetitiveAnnexState | null;\n setAnnexes: (annexes: ResolvedAnnexObject[]) => void;\n buildAnnexStates: (\n annexes?: ResolvedAnnexObject[],\n ) => Record<string, AnnexState | null>;\n buildRepetitiveAnnexStates: (\n annexes?: ResolvedAnnexObject[],\n ) => Record<string, RepetitiveAnnexState | null>;\n setActiveAnnex: (activeAnnex: string | Path | null) => void;\n updateActiveAnnex: (oldActiveAnnexIndex: number) => void;\n registerAnnexState: (path: AbsolutePath, state: AnnexState) => void;\n registerRepetitiveAnnexState: (\n path: AbsolutePath,\n state: RepetitiveAnnexState,\n ) => void;\n addAnnex: (path: AbsolutePath, toAdd: unknown) => Promise<AbsolutePath>;\n removeAnnex: (path: AbsolutePath, isRepetitive: boolean) => Promise<void>;\n}\n\n/** Annexes' store. */\nexport type AnnexesStore = ReturnType<typeof useCreateAnnexesContext>;\n\n/** Annexes' context. */\nexport const AnnexesContext = createContext<AnnexesContextValue | null>(null);\n\n/** Options used to create the annexes' context. */\nexport interface UseCreateAnnexesContextOptions extends Pick<\n AnnexesProps,\n | \"defaultActiveAnnex\"\n | \"activeAnnex\"\n | \"onActiveAnnexChange\"\n | \"onAnnexAdd\"\n | \"onAnnexRemove\"\n> {\n formManager: FormManager;\n basePath: AbsolutePath;\n resolvedAnnexes: ResolvedAnnexObject[];\n}\n\n/** Hook used to create the annexes' context. */\nexport function useCreateAnnexesContext({\n formManager,\n basePath,\n resolvedAnnexes,\n defaultActiveAnnex,\n activeAnnex,\n onActiveAnnexChange,\n onAnnexAdd,\n onAnnexRemove,\n}: UseCreateAnnexesContextOptions) {\n const setLatestInteraction = useSetLatestInteraction();\n const { activePath, onActivePathChange } = useActivePathContext();\n activeAnnex ??= activePath;\n\n const latestRef = useLatestRef({\n printing: usePrinting(),\n formManager,\n onActivePathChange,\n onActiveAnnexChange,\n onAnnexAdd,\n onAnnexRemove,\n });\n const store = useConstant(() =>\n createStore<AnnexesState>()(\n subscribeWithSelector((set, get) => ({\n annexes: resolvedAnnexes,\n activeAnnex:\n activeAnnex === undefined\n ? defaultActiveAnnex == null\n ? null\n : basePath.resolve(defaultActiveAnnex)\n : activeAnnex === null\n ? null\n : basePath.resolve(activeAnnex),\n nextActiveAnnex: null,\n activeAnnexIndex: computed(\n () => [get().activeAnnex, get().tabStates()],\n (activeAnnex, tabStates) =>\n activeAnnex === null\n ? -1\n : tabStates.findIndex((state) => state.path.equals(activeAnnex)),\n ),\n annexStates: [{}],\n repetitiveAnnexStates: [{}],\n tabStates: computed(\n () => [get().annexes, get().annexStates, get().repetitiveAnnexStates],\n (annexes, [annexStates], [repetitiveAnnexStates]) => {\n const tabStates: AnnexState[] = [];\n const pushAnnexState = (path: AbsolutePath) => {\n const state = annexStates[path.toString()];\n if (state != null && !state.isNull) {\n tabStates.push(state);\n }\n };\n for (const annex of annexes) {\n if (annex.path.lastFragment === AbsolutePathFragment.Wildcard) {\n const parentPath = annex.path.parent();\n const state = repetitiveAnnexStates[parentPath.toString()];\n if (state?.rowIds) {\n for (const rowId of state.rowIds) {\n pushAnnexState(\n parentPath.append(new AbsolutePathFragment.Id(rowId)),\n );\n }\n }\n } else {\n pushAnnexState(annex.path);\n }\n }\n return tabStates;\n },\n ),\n tablessStates: computed(\n () => [get().annexes, get().annexStates, get().repetitiveAnnexStates],\n (annexes, [annexStates], [repetitiveAnnexStates]) => {\n const tablessStates: (AnnexState | RepetitiveAnnexState)[] = [];\n for (const annex of annexes) {\n let tablessState: AnnexState | RepetitiveAnnexState | null = null;\n if (annex.path.lastFragment === AbsolutePathFragment.Wildcard) {\n tablessState =\n repetitiveAnnexStates[annex.path.parent().toString()];\n } else {\n const state = annexStates[annex.path.toString()];\n if (state?.isNull) {\n tablessState = state;\n }\n }\n if (tablessState) {\n tablessStates.push(tablessState);\n }\n }\n return tablessStates;\n },\n ),\n waitingRegistration: computed(\n () => [get().annexes, get().annexStates, get().repetitiveAnnexStates],\n (annexes, [annexStates], [repetitiveAnnexStates]) => {\n const waitingRegistration: AbsolutePath[] = [];\n const pushWaitingRegistration = (path: AbsolutePath) => {\n const state = annexStates[path.toString()];\n if (state == null) {\n waitingRegistration.push(path);\n }\n };\n for (const annex of annexes) {\n if (annex.path.lastFragment === AbsolutePathFragment.Wildcard) {\n const parentPath = annex.path.parent();\n const state = repetitiveAnnexStates[parentPath.toString()];\n if (!state?.rowIds) {\n waitingRegistration.push(annex.path);\n } else {\n for (const rowId of state.rowIds) {\n pushWaitingRegistration(\n parentPath.append(new AbsolutePathFragment.Id(rowId)),\n );\n }\n }\n } else {\n pushWaitingRegistration(annex.path);\n }\n }\n return waitingRegistration;\n },\n ),\n actions: {\n getAnnexState: (path) =>\n get().annexStates[0][path.toString()] ?? null,\n getRepetitiveAnnexState: (path) =>\n get().repetitiveAnnexStates[0][path.toString()] ?? null,\n setAnnexes: (annexes: ResolvedAnnexObject[]) => {\n const oldActiveAnnexIndex = get().activeAnnexIndex();\n set({\n annexes,\n annexStates: [get().actions.buildAnnexStates(annexes)],\n repetitiveAnnexStates: [\n get().actions.buildRepetitiveAnnexStates(annexes),\n ],\n });\n get().actions.updateActiveAnnex(oldActiveAnnexIndex);\n },\n buildAnnexStates: (\n annexes: ResolvedAnnexObject[] = get().annexes,\n ) => {\n const { getAnnexState, getRepetitiveAnnexState } = get().actions;\n const newAnnexStates: Record<string, AnnexState | null> = {};\n for (const annex of annexes) {\n if (annex.path.lastFragment === AbsolutePathFragment.Wildcard) {\n const tablePath = annex.path.parent();\n for (const rowId of getRepetitiveAnnexState(tablePath)\n ?.rowIds ?? []) {\n const rowPath = tablePath.append(\n new AbsolutePathFragment.Id(rowId),\n );\n newAnnexStates[rowPath.toString()] = getAnnexState(rowPath);\n }\n } else {\n newAnnexStates[annex.path.toString()] = getAnnexState(\n annex.path,\n );\n }\n }\n return newAnnexStates;\n },\n buildRepetitiveAnnexStates: (\n annexes: ResolvedAnnexObject[] = get().annexes,\n ) => {\n const { getRepetitiveAnnexState } = get().actions;\n const newRepetitiveAnnexStates: Record<\n string,\n RepetitiveAnnexState | null\n > = {};\n\n for (const annex of annexes) {\n if (annex.path.lastFragment === AbsolutePathFragment.Wildcard) {\n const tablePath = annex.path.parent();\n newRepetitiveAnnexStates[tablePath.toString()] =\n getRepetitiveAnnexState(tablePath);\n }\n }\n return newRepetitiveAnnexStates;\n },\n setActiveAnnex: (path: string | Path | null) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const newActiveAnnex =\n path === null || path instanceof AbsolutePath\n ? path\n : new AbsolutePath(path);\n const oldActiveAnnex = get().activeAnnex;\n if (!oldActiveAnnex?.equals(newActiveAnnex)) {\n startTransition(() => {\n set({ activeAnnex: newActiveAnnex });\n if (newActiveAnnex != null) {\n setLatestInteraction(newActiveAnnex);\n }\n latestRef.current.onActivePathChange(newActiveAnnex);\n latestRef.current.onActiveAnnexChange?.(newActiveAnnex);\n });\n }\n },\n updateActiveAnnex: (oldActiveAnnexIndex: number) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const tabStates = get().tabStates();\n const nextActiveAnnex = get().nextActiveAnnex;\n if (\n nextActiveAnnex !== null &&\n tabStates.some((state) => state.path.equals(nextActiveAnnex))\n ) {\n set({ nextActiveAnnex: null });\n get().actions.setActiveAnnex(nextActiveAnnex);\n return;\n }\n\n if (\n get().activeAnnex !== null &&\n (tabStates.some((state) =>\n state.path.equals(get().activeAnnex),\n ) ||\n get()\n .waitingRegistration()\n .some((path) => path.contains(get().activeAnnex!)))\n ) {\n return;\n }\n\n get().actions.setActiveAnnex(\n tabStates[\n Math.max(0, Math.min(oldActiveAnnexIndex, tabStates.length - 1))\n ]?.path ?? null,\n );\n },\n registerAnnexState: (path, state) => {\n const oldActiveAnnexIndex = get().activeAnnexIndex();\n const annexStates = get().annexStates[0];\n annexStates[path.toString()] = state;\n set({ annexStates: [annexStates] });\n get().actions.updateActiveAnnex(oldActiveAnnexIndex);\n },\n registerRepetitiveAnnexState: (path, state) => {\n const oldActiveAnnexIndex = get().activeAnnexIndex();\n const repetitiveAnnexStates = get().repetitiveAnnexStates[0];\n repetitiveAnnexStates[path.toString()] = state;\n set({\n annexStates: [get().actions.buildAnnexStates()],\n repetitiveAnnexStates: [repetitiveAnnexStates],\n });\n get().actions.updateActiveAnnex(oldActiveAnnexIndex);\n },\n addAnnex: async (path, toAdd) => {\n const { formManager, onAnnexAdd } = latestRef.current;\n const isRepetitive =\n path.lastFragment === AbsolutePathFragment.Wildcard;\n const setPromise = formManager.set(\n isRepetitive\n ? path.parent().append(AbsolutePathFragment.CollectionEnd)\n : path,\n toAdd,\n );\n\n let addedPath: AbsolutePath;\n if (isRepetitive) {\n addedPath = await formManager.get(path.parent(), (value: Table) =>\n path\n .parent()\n .append(\n new AbsolutePathFragment.Id(\n sliceTableRows(value, tableSize(value) - 1)[0][0],\n ),\n ),\n );\n } else {\n addedPath = path;\n }\n set({ nextActiveAnnex: addedPath });\n await setPromise;\n onAnnexAdd?.(addedPath);\n return addedPath;\n },\n removeAnnex: async (path, isRepetitive) => {\n const { formManager, onAnnexRemove } = latestRef.current;\n if (isRepetitive) {\n await formManager.remove(path);\n } else {\n await formManager.set(path, null);\n }\n onAnnexRemove?.(path);\n },\n },\n })),\n ),\n );\n\n // Update store when params change\n useEffect(() => {\n store.getState().actions.setAnnexes(resolvedAnnexes);\n if (activeAnnex !== undefined) {\n const {\n activeAnnex: oldActiveAnnex,\n tabStates,\n waitingRegistration,\n } = store.getState();\n const newActiveAnnex =\n mostSpecificPath(\n activeAnnex === null ? null : basePath.resolve(activeAnnex),\n [...tabStates().map((tab) => tab.path), ...waitingRegistration()],\n oldActiveAnnex,\n ) ?? null;\n store.getState().actions.setActiveAnnex(newActiveAnnex);\n }\n }, [resolvedAnnexes, activeAnnex, basePath, store]);\n\n // Set (possibly new) active annex when focused path changes\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n const { activeAnnex, tabStates, waitingRegistration, actions } =\n store.getState();\n actions.setActiveAnnex(\n mostSpecificPath(\n focusedPath,\n [...tabStates().map((tab) => tab.path), ...waitingRegistration()],\n activeAnnex,\n ) ?? null,\n );\n },\n [store],\n ),\n );\n\n return store;\n}\n\n/** Returns the annexes' context. */\nexport function useAnnexesContext(): AnnexesContextValue {\n const annexesContext = useContext(AnnexesContext);\n if (!annexesContext) {\n throw new Error(\"Annexes context not in scope.\");\n }\n return annexesContext;\n}\n\nexport function useAnnexState<T>(\n path: AbsolutePath,\n selector: (state: AnnexState | null) => T,\n): T {\n return useStore(useAnnexesContext(), (state) =>\n selector(state.actions.getAnnexState(path)),\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n useCurrentPath,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport {\n cx,\n DocumentTitle,\n ErrorBoundary,\n type ErrorBoundaryProps,\n Spinner,\n TabContent,\n type TabContentProps,\n usePrinting,\n warnOnce,\n} from \"@ostack.tech/ui\";\nimport { type ComponentProps, type ReactNode, Suspense } from \"react\";\nimport { useStore } from \"zustand\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { FormAppIssueMessages, FormAppStatus } from \"../FormApp\";\nimport type { IssueMessagesByCode } from \"../IssueMessages\";\nimport { useAnnexesContext, useAnnexState } from \"./AnnexesContext.ts\";\n\n/** Object representation of an annex. */\nexport interface AnnexObject<T = any> {\n /**\n * Annex path. This path may contain a single wildcard (`*`) at the end, when\n * the elements of a collection should be counted as annexes. Otherwise, the\n * path may contain no other wildcards.\n */\n path?: string | Path;\n /** Annex's title. */\n title?: ReactNode | ((value: T) => ReactNode);\n /** Annex's subtitle. */\n subtitle?: ReactNode | ((value: T, index?: number) => ReactNode);\n /** Annex's description. */\n description?: ReactNode;\n /**\n * Annex's label in the issues panel. The `title` and `subtitle` are used by\n * default.\n */\n issuesPanelLabel?: ReactNode | ((value: T) => ReactNode);\n /**\n * Title of an annex within a collection of annexes. The `title` is used by\n * default.\n */\n itemTitle?: ReactNode | ((value: T, index: number) => ReactNode);\n /**\n * Issues panel label for each annex of a collection of annexes. The\n * `subtitle` and index of the item are used by default.\n */\n itemIssuesPanelLabel?: ReactNode | ((value: T, index: number) => ReactNode);\n /**\n * Title of the annex as a string to display in the document's title.\n *\n * Defaults to the `title` together with the `subtitle` (if it exists) when\n * they are strings.\n *\n * A warning is printed if either the title or the subtitle are defined but\n * aren't strings and `documentTitle` is not provided.\n */\n documentTitle?: string | null | ((value: T, index?: number) => string | null);\n /**\n * Maximum number of annexes matching this path that can be added, when\n * counting collection elements as annexes. By default, if the collection has\n * a `MaxSize` validation, then its value is used.\n */\n maxAnnexes?: number;\n /**\n * Function called when an annex matching this path is being added to choose\n * the value that should be added.\n *\n * The default value being added is provided as an argument and may be edited\n * if required.\n *\n * The value to be added should be returned, or a promise that resolves with\n * said value.\n *\n * To prevent an annex from being added, return `undefined`/`null` (or a\n * promise which resolves with `undefined`/`null`).\n *\n * @param value - Value being added, can be edited.\n * @returns Value to be added, `undefined`/`null` if the annex shouldn't be\n * added (or a promise that resolves with said values).\n */\n getValue?: (\n value: T,\n ) => T | null | undefined | PromiseLike<T | null | undefined>;\n}\n\n/** Properties of the annex component. */\nexport interface AnnexProps\n extends AnnexObject, Omit<TabContentProps, \"value\" | \"title\" | \"children\"> {\n /** Sets the annex as disabled. */\n disabled?: boolean;\n /** Sets the annex as read-only. */\n readOnly?: boolean;\n /**\n * Mapping of issue messages from the path of the field with issues to the\n * issue messages of said field (which are themselves grouped by their code).\n *\n * Provided paths are relative to the annex's path and may contain wildcards,\n * which will have a lower priority when matched against.\n *\n * These messages are used by the `IssueMessages` component.\n *\n * > **Note:** Changes to `issueMessages` are handled correctly, but are not\n * > efficient. Please make sure that the identity of the provided value doesn't\n * > change at every render.\n *\n * Example value:\n *\n * ```tsx\n * {\n * \"**\": {\n * \"valueMissing\": \"Field is required.\"\n * },\n * \"field\": {\n * \"valueMissing\": \"My field cannot be left empty!\",\n * \"someOtherError\": \"Text of the other error.\"\n * }\n * }\n * ```\n */\n issueMessages?: Record<string, IssueMessagesByCode>;\n /** Properties to pass to the container element. */\n containerProps?: ComponentProps<\"div\">;\n /** Properties to pass to the `ErrorBoundary` component. */\n errorBoundaryProps?: ErrorBoundaryProps;\n children?: ReactNode;\n}\n\n/** Component containing the content of an annex. */\nexport function Annex({\n path,\n // `AnnexObject` props\n title: _title,\n subtitle: _subtitle,\n description: _description,\n issuesPanelLabel: _issuesPanelLabel,\n itemTitle: _itemTitle,\n itemIssuesPanelLabel: _itemIssuesPanelLabel,\n documentTitle: _documentTitle,\n maxAnnexes: _maxAnnexes,\n getValue: _getValue,\n ref,\n ...otherProps\n}: AnnexProps) {\n const annexPath = useResolvedPath(path);\n const store = useAnnexesContext();\n const activeAnnex = useStore(store, (state) => state.activeAnnex);\n const tabStates = useStore(\n store,\n useShallow((state) =>\n state.tabStates().filter((state) => annexPath.contains(state.path)),\n ),\n );\n\n return tabStates.map((state) => {\n const pathStr = state.path.toString();\n return (\n <CurrentPath key={pathStr} path={state.path}>\n <AnnexTabContent\n {...otherProps}\n ref={state.path.equals(activeAnnex) ? ref : undefined}\n />\n </CurrentPath>\n );\n });\n}\n\ninterface AnnexTabContentProps extends Omit<AnnexProps, keyof AnnexObject> {}\n\nfunction AnnexTabContent({\n disabled = false,\n readOnly = false,\n issueMessages,\n children,\n className,\n containerProps,\n tabContentLabelProps,\n errorBoundaryProps,\n ...otherProps\n}: AnnexTabContentProps) {\n const prefix = usePrefix();\n const printing = usePrinting();\n const annexPath = useCurrentPath();\n const documentTitle = useAnnexState(annexPath, (state) =>\n state === null ? null : state.documentTitle,\n );\n\n if (documentTitle === undefined) {\n warnOnce(\n `Annex: At '${annexPath.toString()}': \\`documentTitle\\` ` +\n \"should be set manually since either `title` or `subtitle` is not a \" +\n \"string.\",\n );\n }\n\n return (\n <div\n {...containerProps}\n className={cx(\n prefix(\"annexes__annex-container\"),\n containerProps?.className,\n )}\n >\n <TabContent\n className={cx(prefix(\"annexes__annex\"), className)}\n value={annexPath.toString()}\n tabContentLabelProps={{\n ...tabContentLabelProps,\n className: cx(\n prefix(\"annexes__annex-label\"),\n tabContentLabelProps?.className,\n ),\n }}\n {...otherProps}\n >\n <ErrorBoundary {...errorBoundaryProps}>\n <DocumentTitle\n title={printing ? undefined : (documentTitle ?? undefined)}\n >\n <FormAppStatus disabled={disabled} readOnly={readOnly}>\n <FormAppIssueMessages issueMessages={issueMessages}>\n <Suspense fallback={<Spinner size=\"xl\" color=\"primary\" />}>\n {children}\n </Suspense>\n </FormAppIssueMessages>\n </FormAppStatus>\n </DocumentTitle>\n </ErrorBoundary>\n </TabContent>\n </div>\n );\n}\n","import { AbsolutePath, AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { useFormController, useFormManager } from \"@ostack.tech/kform-react\";\nimport { useToastManager } from \"@ostack.tech/ui\";\nimport {\n fileOpen,\n type FileSystemHandle,\n type FileWithHandle,\n supported,\n type WellKnownDirectory,\n} from \"browser-fs-access\";\nimport { DEV } from \"esm-env\";\nimport { type ReactNode, useMemo } from \"react\";\n\nimport { useFormTitle, useStartIssuesNavigation } from \"../components/FormApp\";\nimport { useLocale } from \"../providers/LocalizationProvider\";\n\n/**\n * Options that can be passed to the {@link useFormLoader} hook, or to its\n * resulting `load` function.\n */\nexport interface FormLoaderOptions<T = unknown> {\n /**\n * Function used to decode the form, given its file.\n *\n * If decoding a text-based format, one may use `await file.text()` to get the\n * content of the file as a string.\n *\n * @param file File containing the form to decode.\n * @returns Decoded form value.\n */\n decode?: (file: FileWithHandle) => PromiseLike<T>;\n /**\n * Path of the value being loaded.\n *\n * @default AbsolutePath.ROOT\n */\n path?: string | AbsolutePath;\n /** Acceptable file extensions. */\n extensions?: string[];\n /** Acceptable MIME types. */\n mimeTypes?: string[];\n /** Suggested file description. */\n description?: string;\n /** Directory to present when starting to load. */\n startIn?: WellKnownDirectory | FileSystemHandle;\n /**\n * By specifying an ID, the user agent can remember different directories for\n * different IDs.\n */\n id?: string;\n /**\n * Whether to set the form as pristine when it is loaded.\n *\n * @default true\n */\n setPristineOnLoad?: boolean;\n /**\n * Whether to set the form as touched when it is loaded.\n *\n * @defalut true\n */\n setTouchedOnLoad?: boolean;\n /**\n * Whether to validate the form (and show the issues panel) when it is loaded.\n *\n * @default true\n */\n validateOnLoad?: boolean;\n /**\n * Message to show in a toast when successfully loading a form from a file.\n * Can be set to `null` to not show any message.\n *\n * @param file Loaded file.\n * @returns Message to show in a toast.\n */\n successMessage?: ReactNode | ((file: FileWithHandle) => ReactNode);\n /**\n * Message to show in a toast when an error occurs while loading the form from\n * a file. Can be set to `null` to not show any message.\n *\n * @param file File from which the load was attempted (or `null` if the file\n * could not be accessed).\n * @param error Error that occurred.\n * @returns Message to show in a toast.\n */\n errorMessage?:\n ReactNode | ((file: FileWithHandle | null, error: unknown) => ReactNode);\n}\n\n/** Result of the {@link useFormLoader} hook. */\nexport interface FormLoaderResult<T> {\n /**\n * Function used to load the form.\n *\n * @param options Options used for loading the form.\n * @returns Promise which resolves once the form has been loaded.\n */\n load: (options?: FormLoaderOptions<T>) => Promise<void>;\n /** Whether the browser supports modern file system APIs used for loading. */\n supportsFileSystemAPIs: boolean;\n}\n\n/** Hook exposing a function used to load the form from a file. */\nexport function useFormLoader<T = unknown>({\n decode,\n path,\n extensions,\n mimeTypes,\n description,\n startIn,\n id,\n setPristineOnLoad,\n setTouchedOnLoad,\n validateOnLoad,\n successMessage,\n errorMessage,\n}: FormLoaderOptions<T> = {}): FormLoaderResult<T> {\n const [locale] = useLocale();\n const formManager = useFormManager();\n const { _setState } = useFormController();\n const { addToast } = useToastManager();\n const startIssuesNavigation = useStartIssuesNavigation();\n const formTitle = useFormTitle();\n const defaultId = useMemo(\n () => formTitle?.replace(/[^a-zA-Z0-9-_]/g, \"\").substring(0, 32) ?? \"\",\n [formTitle],\n );\n\n return useMemo(() => {\n async function load({\n decode,\n path = AbsolutePath.ROOT,\n extensions,\n mimeTypes,\n description,\n startIn,\n id = defaultId,\n setPristineOnLoad = true,\n setTouchedOnLoad = true,\n validateOnLoad = true,\n successMessage = locale.LoadAction.successMessage,\n errorMessage = locale.LoadAction.errorMessage,\n }: FormLoaderOptions<T>) {\n if (!decode) {\n throw new Error(\"No `decode` function was provided.\");\n }\n\n const validationModeIsAuto =\n formManager.autoValidationStatus !== \"inactive\";\n let file: FileWithHandle | null = null;\n try {\n file = await fileOpen({\n extensions,\n mimeTypes,\n description,\n startIn,\n id,\n });\n\n _setState({ loading: true } as any);\n const formValue = await decode(file);\n\n // Set validation mode as manual prior to loading the file\n if (validationModeIsAuto) {\n await formManager.setValidationMode(\"manual\");\n }\n\n await formManager.set(path, formValue);\n if (setPristineOnLoad || setTouchedOnLoad) {\n const pathWithDescendants = (\n path instanceof AbsolutePath ? path : new AbsolutePath(path)\n ).append(AbsolutePathFragment.RecursiveWildcard);\n await Promise.all([\n setPristineOnLoad && formManager.setPristine(path),\n setTouchedOnLoad && formManager.setTouched(pathWithDescendants),\n validateOnLoad && formManager.validate(pathWithDescendants),\n ]);\n }\n if (validateOnLoad) {\n await startIssuesNavigation({ validate: false });\n }\n\n _setState(\n (state: any) =>\n ({\n latestFileHandles: {\n ...state.latestFileHandles,\n [id]: file!.handle ?? null,\n },\n }) as any,\n );\n\n const message =\n typeof successMessage === \"function\"\n ? successMessage(file)\n : successMessage;\n if (message != null) {\n addToast(message, { severity: \"success\" });\n }\n } catch (error) {\n // User aborted\n if (error instanceof DOMException && error.name === \"AbortError\") {\n return;\n }\n\n if (DEV) {\n console.error(error);\n }\n const message =\n typeof errorMessage === \"function\"\n ? errorMessage(file, error)\n : errorMessage;\n if (message != null) {\n addToast(message, { severity: \"danger\" });\n }\n } finally {\n // Reset validation mode\n if (validationModeIsAuto) {\n await formManager.setValidationMode(\"auto\");\n }\n\n _setState({ loading: false } as any);\n }\n }\n\n return {\n load: (options = {}) =>\n load({\n decode,\n path,\n extensions,\n mimeTypes,\n description,\n startIn,\n id,\n setPristineOnLoad,\n setTouchedOnLoad,\n validateOnLoad,\n successMessage,\n errorMessage,\n ...options,\n }),\n supportsFileSystemAPIs: supported,\n };\n }, [\n defaultId,\n locale.LoadAction.successMessage,\n locale.LoadAction.errorMessage,\n formManager,\n _setState,\n startIssuesNavigation,\n addToast,\n decode,\n path,\n extensions,\n mimeTypes,\n description,\n startIn,\n id,\n setPristineOnLoad,\n setTouchedOnLoad,\n validateOnLoad,\n successMessage,\n errorMessage,\n ]);\n}\n\n/** Hook exposing whether the form is currently being loaded. */\nexport function useFormIsLoading() {\n return useFormController().useState((state) => (state as any).loading);\n}\n","import { AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { CurrentPath, useFormattedValue } from \"@ostack.tech/kform-react\";\nimport { usePrinting, useStartPrintingTask } from \"@ostack.tech/ui\";\nimport {\n type ReactNode,\n useCallback,\n useDeferredValue,\n useEffect,\n} from \"react\";\nimport { shallow } from \"zustand/shallow\";\n\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterController, useRegisterLabel } from \"../FormApp\";\nimport {\n type ResolvedAnnexObject,\n useAnnexesContext,\n} from \"./AnnexesContext.ts\";\n\n/** Properties of the `AnnexRegistrar` component. */\nexport interface AnnexRegistrarProps extends ResolvedAnnexObject {\n index?: number;\n}\n\n/** Component used to register a form annex. */\nexport function AnnexRegistrar({\n path,\n title,\n subtitle,\n description,\n issuesPanelLabel,\n itemTitle,\n itemIssuesPanelLabel,\n index,\n documentTitle,\n}: AnnexRegistrarProps) {\n const store = useAnnexesContext();\n\n const printing = usePrinting();\n const finishPrintingTask = useStartPrintingTask();\n const observeDescendants =\n typeof itemTitle === \"function\" ||\n typeof title === \"function\" ||\n typeof subtitle === \"function\" ||\n typeof documentTitle === \"function\";\n const [isNull = true, controller] = useFormattedValue(\n observeDescendants\n ? path.append(AbsolutePathFragment.RecursiveWildcard)\n : path,\n {\n enabled: !useFormIsLoading(),\n onInitialized: finishPrintingTask,\n format: useCallback((value: unknown) => value === null, []),\n },\n );\n const isRepetitive = index != null;\n const absolutePath = controller.usePath();\n const schema = controller.useSchema();\n const exists = controller.useState(\n (state) => state.initialized && state.exists,\n );\n const dirty = controller.useDirty();\n const value = controller.useValue();\n const deferredValue = useDeferredValue(value);\n const relevantValue = printing ? value : deferredValue;\n const deferredIssuesToDisplay = useDeferredValue(\n controller.useState((state) => (state.touched ? state.issues : []), {\n equalityFn: shallow,\n }),\n );\n const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());\n\n const actualTitle = isRepetitive\n ? typeof itemTitle === \"function\"\n ? relevantValue === undefined\n ? null\n : itemTitle(relevantValue, index)\n : itemTitle === undefined\n ? (title as ReactNode)\n : itemTitle\n : typeof title === \"function\"\n ? relevantValue === undefined\n ? null\n : title(relevantValue)\n : title;\n const actualSubtitle =\n typeof subtitle === \"function\"\n ? relevantValue === undefined\n ? null\n : subtitle(relevantValue, index)\n : subtitle;\n const actualDocumentTitle =\n typeof documentTitle === \"function\"\n ? relevantValue === undefined\n ? null\n : documentTitle(relevantValue, index)\n : documentTitle === undefined\n ? (actualTitle === null || typeof actualTitle === \"string\") &&\n (actualSubtitle == null || typeof actualSubtitle === \"string\")\n ? [actualTitle, actualSubtitle].filter((s) => s).join(\" — \")\n : undefined\n : documentTitle;\n\n useEffect(() => {\n if (exists) {\n const { registerAnnexState } = store.getState().actions;\n registerAnnexState(absolutePath, {\n path: absolutePath,\n schema,\n isNull,\n dirty,\n deferredIssuesToDisplay,\n deferredDisplayStatus,\n isRepetitive,\n title: actualTitle,\n subtitle: actualSubtitle,\n documentTitle: actualDocumentTitle,\n description,\n });\n }\n }, [\n absolutePath,\n deferredDisplayStatus,\n deferredIssuesToDisplay,\n description,\n dirty,\n exists,\n isNull,\n isRepetitive,\n actualSubtitle,\n actualTitle,\n schema,\n store,\n subtitle,\n title,\n actualDocumentTitle,\n ]);\n\n useRegisterController(controller);\n useRegisterLabel(\n absolutePath,\n <CurrentPath path={absolutePath}>\n {isRepetitive ? (\n typeof itemIssuesPanelLabel === \"function\" ? (\n deferredValue === undefined ? null : (\n itemIssuesPanelLabel(deferredValue, index)\n )\n ) : itemIssuesPanelLabel === undefined ? (\n (actualSubtitle ?? index + 1)\n ) : (\n itemIssuesPanelLabel\n )\n ) : issuesPanelLabel ? (\n typeof issuesPanelLabel === \"function\" ? (\n deferredValue === undefined ? null : (\n issuesPanelLabel(deferredValue)\n )\n ) : (\n issuesPanelLabel\n )\n ) : (\n <>\n {actualTitle}\n {actualSubtitle && <> — {actualSubtitle}</>}\n </>\n )}\n </CurrentPath>,\n );\n\n return null;\n}\n","import {\n AbsolutePathFragment,\n type Table,\n tableIdsToArray,\n type TableRowId,\n} from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n InvalidPathError,\n useFormattedValue,\n} from \"@ostack.tech/kform-react\";\nimport { useStartPrintingTask } from \"@ostack.tech/ui\";\nimport { useCallback, useDeferredValue, useEffect } from \"react\";\nimport { shallow } from \"zustand/shallow\";\n\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterController, useRegisterLabel } from \"../FormApp\";\nimport {\n type ResolvedAnnexObject,\n useAnnexesContext,\n} from \"./AnnexesContext.ts\";\nimport { AnnexRegistrar } from \"./AnnexRegistrar.tsx\";\n\n/** Properties of the `RepetitiveAnnexRegistrar` component. */\nexport interface RepetitiveAnnexRegistrarProps extends ResolvedAnnexObject {}\n\n/** Component used to register a repetitive form annex. */\nexport function RepetitiveAnnexRegistrar({\n path,\n maxAnnexes,\n ...annexProps\n}: RepetitiveAnnexRegistrarProps) {\n const store = useAnnexesContext();\n\n const finishPrintingTask = useStartPrintingTask();\n const [rowIds, controller] = useFormattedValue(path.parent(), {\n enabled: !useFormIsLoading(),\n onInitialized: finishPrintingTask,\n format: useCallback(\n (value?: Table | null): TableRowId[] =>\n value ? tableIdsToArray(value) : [],\n [],\n ),\n });\n const schema = controller.useSchema();\n const absolutePath = controller.usePath();\n const deferredIssuesToDisplay = useDeferredValue(\n controller.useState((state) => (state.touched ? state.issues : []), {\n equalityFn: shallow,\n }),\n );\n const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());\n\n if (schema.typeInfo.name !== \"Table\") {\n throw new InvalidPathError(\n absolutePath,\n \"Unsupported schema: Expected (possibly nullable) table schema, \" +\n \"but got schema representing values of type \" +\n `'${schema.typeInfo.toString()}'.`,\n );\n }\n\n useEffect(() => {\n const { registerRepetitiveAnnexState } = store.getState().actions;\n registerRepetitiveAnnexState(absolutePath, {\n rowIds,\n maxAnnexes,\n path: absolutePath,\n schema,\n deferredIssuesToDisplay,\n });\n }, [\n absolutePath,\n deferredDisplayStatus,\n deferredIssuesToDisplay,\n maxAnnexes,\n rowIds,\n schema,\n store,\n ]);\n\n if (\n typeof annexProps.title === \"function\" ||\n typeof annexProps.issuesPanelLabel === \"function\"\n ) {\n throw new Error(\n \"Repetitive annexes must not set `title` or `issuesPanelLabel` as a \" +\n \"function. Use `itemTitle` or `itemIssuesPanelLabel` instead.\",\n );\n }\n\n const actualIssuesPanelLabel = annexProps.issuesPanelLabel\n ? annexProps.issuesPanelLabel\n : annexProps.title;\n\n useRegisterController(controller);\n useRegisterLabel(\n absolutePath,\n <CurrentPath path={absolutePath}>{actualIssuesPanelLabel}</CurrentPath>,\n );\n\n return rowIds?.map((rowId, i) => (\n <AnnexRegistrar\n key={rowId}\n path={absolutePath.append(new AbsolutePathFragment.Id(rowId))}\n index={i}\n {...annexProps}\n />\n ));\n}\n","import {\n type AbsolutePath,\n AbsolutePathFragment,\n Path,\n} from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n useFormManager,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport { cx, parseChildren, Tabs, type TabsProps } from \"@ostack.tech/ui\";\nimport { type ReactNode, useCallback, useMemo } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { Annex, type AnnexObject } from \"./Annex.tsx\";\nimport { AnnexesContext, useCreateAnnexesContext } from \"./AnnexesContext.ts\";\nimport { AnnexRegistrar } from \"./AnnexRegistrar.tsx\";\nimport { RepetitiveAnnexRegistrar } from \"./RepetitiveAnnexRegistrar.tsx\";\n\n/** Properties of the annexes component. */\nexport interface AnnexesProps extends Omit<\n TabsProps,\n \"defaultValue\" | \"value\" | \"onValueChange\" | \"showAllTabsWhilePrinting\"\n> {\n /** Base path for all declared annexes. */\n path?: string | Path;\n /**\n * List of all annexes. When not provided, the list of annexes is obtained\n * from the direct children `Annex` components.\n */\n annexes?: AnnexObject[];\n /** Default active annex. */\n defaultActiveAnnex?: string | Path;\n /** Controlled active annex. */\n activeAnnex?: string | Path;\n /**\n * Function called whenever the active annex changes.\n *\n * @param activeAnnex Path of the new active annex.\n */\n onActiveAnnexChange?: (activeAnnexPath: AbsolutePath | null) => void;\n /**\n * Function called when a new annex is added.\n *\n * @param newAnnexPath Path of the new annex.\n */\n onAnnexAdd?: (newAnnexPath: AbsolutePath) => void;\n /**\n * Function called when an annex is removed.\n *\n * @param removedAnnexPath Path of the removed annex.\n */\n onAnnexRemove?: (removedAnnexPath: AbsolutePath) => void;\n children?: ReactNode;\n}\n\n/**\n * The annexes component can be used to split parts of a form into separate\n * annexes (tabs), while providing means of managing and navigating between\n * them. Although not strictly mandatory, each annex (tab) is typically\n * represented by its own class, with its own schema and distinct path.\n *\n * It further supports optional annexes (via\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html)\n * schemas), as well as repetitive ones (via schemas of type\n * [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)\n * or\n * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)).\n *\n * The following built-in KForm validations affect annexes:\n *\n * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):\n * Sets the `maxAnnexes` property of repetitive annexes.\n *\n * It composes the following subcomponents:\n *\n * - `AnnexesManager`: Component used to manage and navigate between annexes\n * (tabs).\n * - `Annex`: Content of a single annex (tab) of the form.\n *\n * Example usage:\n *\n * ```tsx\n * import { Annex, Annexes, AnnexesManager } from \"@ostack.tech/ui-kform\";\n *\n * function TaxDeclarationsAnnexes() {\n * return (\n * <Annexes>\n * <AnnexesManager />\n * <Annex path=\"/cover\" title=\"Cover\" subtitle=\"Income sources\">\n * Cover content…\n * </Annex>\n * <Annex path=\"/annexA\" title=\"Annex A\" subtitle=\"Foreign assets\">\n * Annex A content…\n * </Annex>\n * </Annexes>\n * );\n * }\n * ```\n */\nexport function Annexes({\n path,\n annexes,\n defaultActiveAnnex,\n activeAnnex,\n onActiveAnnexChange,\n onAnnexAdd,\n onAnnexRemove,\n variant = \"annexes\",\n className,\n children,\n ...otherProps\n}: AnnexesProps) {\n const prefix = usePrefix();\n const formManager = useFormManager();\n const absolutePath = useResolvedPath(path);\n\n // Get annexes from children if not provided as prop\n annexes ??= parseChildren(children, Annex, {\n renderUnknownComponents: false,\n });\n\n // Provided annexes but with absolute paths\n const resolvedAnnexes = useMemo(\n () =>\n annexes.map((annex) => ({\n ...annex,\n path: absolutePath.resolve(annex.path ?? Path.CURRENT),\n })),\n [absolutePath, annexes],\n );\n\n // Refuse non-existent paths\n if (!formManager.isValidPath(absolutePath)) {\n throw new Error(`Invalid path: '${absolutePath.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n absolutePath.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Annexes base path must only contain ids.\");\n }\n // Validate annex paths\n for (const annex of resolvedAnnexes) {\n // Refuse non-existent paths\n if (!formManager.isValidPath(annex.path)) {\n throw new Error(`Invalid path: '${annex.path.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only, or identifiers\n // followed by a wildcard\n if (\n annex.path.fragments.some(\n (frag, i, { length }) =>\n !(frag instanceof AbsolutePathFragment.Id) &&\n (frag !== AbsolutePathFragment.Wildcard || i !== length - 1),\n )\n ) {\n throw new Error(\n \"Annex path must either only contain ids, or ids followed by a \" +\n \"single wildcard at the end.\",\n );\n }\n }\n\n const store = useCreateAnnexesContext({\n formManager,\n basePath: absolutePath,\n resolvedAnnexes,\n defaultActiveAnnex,\n activeAnnex,\n onActiveAnnexChange,\n onAnnexAdd,\n onAnnexRemove,\n });\n\n const activeAnnexString = useStore(\n store,\n (state) => state.activeAnnex?.toString() ?? \"\",\n );\n const handleValueChange = useCallback(\n (value: string) => store.getState().actions.setActiveAnnex(value),\n [store],\n );\n\n return (\n <CurrentPath path={absolutePath}>\n <AnnexesContext.Provider value={store}>\n {resolvedAnnexes.map((annex) =>\n annex.path.lastFragment === AbsolutePathFragment.Wildcard ? (\n <RepetitiveAnnexRegistrar key={annex.path.toString()} {...annex} />\n ) : (\n <AnnexRegistrar key={annex.path.toString()} {...annex} />\n ),\n )}\n\n <Tabs\n className={cx(prefix(\"annexes\"), className)}\n variant={variant}\n activationMode=\"manual\"\n value={activeAnnexString}\n onValueChange={handleValueChange}\n showAllTabsWhilePrinting\n {...otherProps}\n >\n {children}\n </Tabs>\n </AnnexesContext.Provider>\n </CurrentPath>\n );\n}\n","import { type AbsolutePath, ValidationFailure } from \"@ostack.tech/kform\";\nimport {\n AtPathError,\n type LocatedValidationInfo,\n} from \"@ostack.tech/kform-react\";\nimport { useErrorReporter } from \"@ostack.tech/ui\";\nimport { useEffect } from \"react\";\n\ntype ReportValidationFailuresInfo = Pick<\n LocatedValidationInfo,\n \"path\" | \"issues\"\n>;\n\nclass ValidationFailureError extends AtPathError {\n constructor(path: AbsolutePath, issue: ValidationFailure) {\n super(path, `Failed to run validation '${issue.validation}'`);\n this.name = this.constructor.name;\n this.stack += `\\nCaused by: ${issue.stackTrace}`;\n }\n}\n\n/** Hook used to report validation failures that occur. */\nexport function useReportValidationFailures(\n info?: ReportValidationFailuresInfo[],\n) {\n const reportError = useErrorReporter();\n useEffect(() => {\n if (info) {\n for (const { path, issues } of info) {\n for (const issue of issues) {\n if (issue instanceof ValidationFailure) {\n reportError(new ValidationFailureError(path, issue));\n }\n }\n }\n }\n }, [info, reportError]);\n}\n","import type {\n AbsolutePath,\n FormManager,\n Schema,\n SealedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport type { Controller } from \"@ostack.tech/kform-react\";\nimport { EMPTY_STORE, useConstant } from \"@ostack.tech/ui\";\nimport { createContext, useContext, useEffect } from \"react\";\nimport { createStore, useStore } from \"zustand\";\n\n/** Value of the control field context. */\nexport type ControlFieldContextValue = ControlFieldStore;\n\n/** State of the control field. */\nexport interface ControlFieldState {\n controlStates: Record<string, ControlState>;\n}\n\n/** State of a control accessible to the whole field. */\nexport interface ControlState {\n formManager: FormManager;\n schema: Schema;\n path: AbsolutePath;\n exists: boolean;\n deferredIssuesToDisplay: SealedValidationIssue[];\n}\n\n/** Control field store. */\nexport type ControlFieldStore = ReturnType<typeof useCreateControlFieldContext>;\n\n/** Control field context. */\nexport const ControlFieldContext =\n createContext<ControlFieldContextValue | null>(null);\n\n/** Hook which creates the control field context value. */\nexport function useCreateControlFieldContext() {\n return useConstant(() =>\n createStore<ControlFieldState>(() => ({\n controlStates: {},\n })),\n );\n}\n\n/** Hook returning the control field's context value. */\nfunction useControlFieldContext(): ControlFieldContextValue | null {\n return useContext(ControlFieldContext);\n}\n\n/** Hook that returns access to the control field's store. */\nexport function useControlFieldStore<T>(\n selector: (state: Partial<ControlFieldState>) => T,\n): T {\n return useStore(useControlFieldContext() ?? EMPTY_STORE, selector);\n}\n\n/** Hook exposing whether a component is being rendered within a control field. */\nexport function useIsInControlField(): boolean {\n return useControlFieldContext() !== null;\n}\n\n/**\n * Hook that makes a control field aware of a controller.\n *\n * The passed `controller` object should not be different on every render.\n */\nexport function useRegisterControllerWithinControlField<T = unknown>(\n controller: Controller<T>,\n deferredIssuesToDisplay: SealedValidationIssue[],\n) {\n const store = useControlFieldContext();\n const formManager = controller.useFormManager();\n const path = controller.usePath();\n const schema = controller.useSchema();\n const exists = controller.useState(\n (state) => state.initialized && state.exists,\n );\n useEffect(() => {\n if (store) {\n const pathStr = path.toString();\n store.setState((state) => ({\n controlStates: {\n ...state.controlStates,\n [pathStr]: {\n formManager,\n schema,\n path,\n exists,\n deferredIssuesToDisplay,\n },\n },\n }));\n return () => {\n store.setState(\n ({ controlStates: { [pathStr]: _, ...controlStates } }) => ({\n controlStates,\n }),\n );\n };\n }\n }, [deferredIssuesToDisplay, exists, formManager, path, schema, store]);\n}\n","import { Path } from \"@ostack.tech/kform\";\nimport { CurrentPath, useFormManager } from \"@ostack.tech/kform-react\";\nimport { Field, type FieldProps } from \"@ostack.tech/ui\";\nimport { useEffect } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport {\n ControlFieldContext,\n useCreateControlFieldContext,\n} from \"./ControlFieldContext.ts\";\n\n/** Properties of the control field component. */\nexport interface ControlFieldProps extends FieldProps {\n /** Path of the field; inner control paths will be relative to this path. */\n path?: string | Path;\n /**\n * Whether to show the control field.\n *\n * The component will, by default, automatically reset its inner controls when\n * the control field becomes hidden.\n *\n * @default true\n */\n shown?: boolean;\n /**\n * Whether to reset the inner controls when the control field becomes hidden.\n *\n * @default true\n */\n resetOnHide?: boolean;\n /**\n * Whether to set inner controls as untouched when the control field becomes\n * hidden.\n *\n * @default resetOnHide\n */\n setUntouchedOnHide?: boolean;\n /**\n * Whether to set inner controls as pristine when the control field becomes\n * hidden.\n *\n * @default resetOnHide\n */\n setPristineOnHide?: boolean;\n}\n\n/**\n * Component used to group controls with a label, helper text, and/or feedback.\n *\n * The component can be conditionally shown via the `shown` property which, by\n * default, when changing from `true` to `false` will reset its inner controls.\n *\n * Added labels automatically \"point\" to the control and are set to \"required\"\n * when requested by the control.\n *\n * Aria descriptions and error messages are set on the control based on the\n * provided helper texts or feedbacks.\n */\n// TODO: deprecate after introduction of `ResetOnChange` component:\n// @deprecated Use the `@ostack.tech/ui` {@link Field} component instead. Set the\n// `path` on the control directly instead. If using `resetOnHide`, use the\n// `ResetOnChange` component or the `useResetOnChange` hook instead on the\n// control that causes the resetting instead to mimic similar behaviour.\nexport function ControlField({\n path = Path.CURRENT,\n shown = true,\n resetOnHide = true,\n setUntouchedOnHide = resetOnHide,\n setPristineOnHide = resetOnHide,\n ...otherProps\n}: ControlFieldProps) {\n const formManager = useFormManager();\n\n // Controllers registered within the control field\n const store = useCreateControlFieldContext();\n\n // Reset registered controllers when `shown` becomes `false`\n const controlStates = useStore(store, (state) => state.controlStates);\n useEffect(() => {\n if (!shown) {\n for (const controlState of Object.values(controlStates)) {\n const { formManager, path, exists } = controlState;\n if (exists) {\n if (resetOnHide) {\n void formManager.reset(path);\n }\n if (setUntouchedOnHide) {\n void formManager.setUntouched(path);\n }\n if (setPristineOnHide) {\n void formManager.setPristine(path);\n }\n }\n }\n }\n }, [\n controlStates,\n formManager,\n resetOnHide,\n setPristineOnHide,\n setUntouchedOnHide,\n shown,\n store,\n ]);\n\n return (\n shown && (\n <CurrentPath path={path}>\n <ControlFieldContext.Provider value={store}>\n <Field {...otherProps} />\n </ControlFieldContext.Provider>\n </CurrentPath>\n )\n );\n}\n","import type {\n AbsolutePath,\n Path,\n Schema,\n SealedValidationIssue,\n ValidationIssueData,\n} from \"@ostack.tech/kform\";\nimport {\n useFormManager,\n useIssuesTracker,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport {\n Feedback,\n FeedbackList,\n type FeedbackListProps,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, useDeferredValue, useMemo } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useReportValidationFailures } from \"../../utils/useReportValidationFailures.ts\";\nimport { useIsInControlField } from \"../ControlField\";\nimport { useControlFieldStore } from \"../ControlField/ControlFieldContext.ts\";\nimport { FormAppIssueMessages } from \"../FormApp\";\nimport { IssueMessage } from \"../IssueMessage\";\n\n/** Value of an issue message. */\nexport type IssueMessageValue =\n | ReactNode\n | ((\n issueData: ValidationIssueData,\n schema: Schema,\n path: AbsolutePath,\n ) => ReactNode);\n\n/** Mapping of issue message codes to their respective message. */\nexport type IssueMessagesByCode = Record<string, IssueMessageValue>;\n\n/** Properties of the issue messages component. */\nexport interface IssueMessagesProps extends FeedbackListProps {\n /** Path of the value for which to show issues. */\n path?: string | Path;\n /**\n * Issues to show, associated with the provided path. If not provided, the\n * component will query the issues from the form manager.\n */\n issues?: SealedValidationIssue[];\n /** Mapping from an issue's code to its message. */\n messages?: IssueMessagesByCode;\n /**\n * Whether to display issue codes together with each issue message.\n *\n * This property can also be set globally via the `displayIssueCodes` property\n * of the `FormApp`.\n */\n displayIssueCodes?: boolean;\n /**\n * Name of the key in a validation issue's data object that possibly contains\n * the issue message. This message is only used if no matching message is\n * otherwise found.\n *\n * @default \"message\"\n */\n messagesDataKey?: string;\n /** Accessible prefix for error codes when `displayIssueCodes` is set. */\n visuallyHiddenErrorCodePrefix?: ReactNode;\n /** Accessible prefix for warning codes when `displayIssueCodes` is set. */\n visuallyHiddenWarningCodePrefix?: ReactNode;\n /**\n * Message to show for an error that does not have an associated message.\n *\n * This message will always automatically include the code of the issue in\n * question.\n */\n unknownErrorMessage?: ReactNode;\n /**\n * Message to show for a warning that does not have an associated message.\n *\n * This message will always automatically include the code of the issue in\n * question.\n */\n unknownWarningMessage?: ReactNode;\n /**\n * Whether to render the issue messages \"unwrapped\", i.e. outside a containing\n * `FeedbackList`.\n *\n * This is useful together with components such as the `DateRangeControl`\n * where you might want to show issues for multiple paths, all within the same\n * `FeedbackList`:\n *\n * ```tsx\n * <FeedbackList>\n * <IssueMessages path=\"startDate\" unwrapped />\n * <IssueMessages path=\"endDate\" unwrapped />\n * </FeedbackList>;\n * ```\n */\n unwrapped?: boolean;\n}\n\n/**\n * Component used to display all issues associated with the relevant path.\n *\n * Issue messages are automatically read from the scope (typically provided by\n * setting the `issueMessages` property of a `FormApp`, `Annex`, or\n * `FormPage`).\n *\n * Messages may also be passed directly to this component via the `messages`\n * property.\n *\n * If `path` contains an issue without an associated issue message, a generic\n * message is displayed together with a console warning.\n */\nexport function IssueMessages({\n path,\n issues,\n messages,\n displayIssueCodes,\n messagesDataKey,\n visuallyHiddenErrorCodePrefix,\n visuallyHiddenWarningCodePrefix,\n unknownErrorMessage,\n unknownWarningMessage,\n unwrapped,\n ...otherProps\n}: IssueMessagesProps) {\n const prefix = usePrefix();\n const isInControlField = useIsInControlField();\n const formManager = useFormManager();\n const absolutePath = useResolvedPath(path);\n const { info } = useIssuesTracker(absolutePath, {\n enabled: !issues && !isInControlField,\n });\n const messagesToRegister = useMemo(\n () => messages && { [absolutePath.toString()]: messages },\n [absolutePath, messages],\n );\n\n const relevantControlState = useControlFieldStore((state) =>\n isInControlField ? state.controlStates?.[absolutePath.toString()] : null,\n );\n const deferredTrackedIssues = useDeferredValue(\n useMemo(() => info?.flatMap((info) => info.issues) ?? [], [info]),\n );\n const deferredIssuesToDisplay = useMemo(\n () =>\n issues ??\n (isInControlField\n ? (relevantControlState?.deferredIssuesToDisplay ?? [])\n : deferredTrackedIssues),\n [\n deferredTrackedIssues,\n isInControlField,\n issues,\n relevantControlState?.deferredIssuesToDisplay,\n ],\n );\n useReportValidationFailures(\n useMemo(\n () => [{ path: absolutePath, issues: deferredIssuesToDisplay }],\n [absolutePath, deferredIssuesToDisplay],\n ),\n );\n\n const schema = useMemo(\n () => relevantControlState?.schema ?? formManager.schema(absolutePath),\n [absolutePath, formManager, relevantControlState?.schema],\n );\n\n const feedbackNodes = useMemo(\n () =>\n deferredIssuesToDisplay.map((issue, i) => (\n <Feedback key={i} type={issue.severity}>\n <IssueMessage\n path={absolutePath}\n issue={issue}\n schema={schema}\n displayIssueCode={displayIssueCodes}\n messageDataKey={messagesDataKey}\n visuallyHiddenErrorCodePrefix={visuallyHiddenErrorCodePrefix}\n visuallyHiddenWarningCodePrefix={visuallyHiddenWarningCodePrefix}\n unknownErrorMessage={unknownErrorMessage}\n unknownWarningMessage={unknownWarningMessage}\n issueCodeProps={{ className: prefix(\"issue-messages__issue-code\") }}\n />\n </Feedback>\n )),\n [\n deferredIssuesToDisplay,\n absolutePath,\n schema,\n displayIssueCodes,\n messagesDataKey,\n visuallyHiddenErrorCodePrefix,\n visuallyHiddenWarningCodePrefix,\n unknownErrorMessage,\n unknownWarningMessage,\n prefix,\n ],\n );\n\n return (\n <FormAppIssueMessages issueMessages={messagesToRegister}>\n {unwrapped ? (\n feedbackNodes\n ) : (\n <FeedbackList {...otherProps}>{feedbackNodes}</FeedbackList>\n )}\n </FormAppIssueMessages>\n );\n}\n","import { AbsolutePath, type Path } from \"@ostack.tech/kform\";\nimport { CurrentPath, useResolvedPath } from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackPopover,\n type FeedbackPopoverProps,\n useControllableState,\n} from \"@ostack.tech/ui\";\nimport { useCallback } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { useIsInControlField } from \"../ControlField\";\nimport { useOnPathFocus } from \"../FormApp\";\n\n/** Properties of the issues popover component. */\nexport interface IssuesPopoverProps extends FeedbackPopoverProps {\n path?: string | Path;\n /**\n * Paths relevant to this issues popover. When one of the relevant paths\n * becomes active, the popover will automatically open. Defaults to `[path]`\n * (or `[<current path>]` if no `path` is provided).\n */\n relevantPaths?: (string | Path)[];\n}\n\n/** Component used to display issues within a popover. */\nexport function IssuesPopover({\n path,\n relevantPaths,\n defaultOpen,\n open: controlledOpen,\n onOpenChange,\n label,\n ...otherProps\n}: IssuesPopoverProps) {\n const [locale] = useLocale();\n label ??= locale.IssuesPopover.label;\n\n const absolutePath = useResolvedPath(path);\n const [open, setOpen] = useControllableState(defaultOpen, controlledOpen);\n const isInControlField = useIsInControlField();\n\n // Open popover when active path matches the popover's path (unneeded when\n // within a control field)\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n if (\n (relevantPaths ?? [absolutePath]).some((path) =>\n focusedPath.equals(new AbsolutePath(path)),\n )\n ) {\n setOpen(true);\n }\n },\n [relevantPaths, absolutePath, setOpen],\n ),\n { enabled: !isInControlField },\n );\n\n return (\n <CurrentPath path={absolutePath}>\n <FeedbackPopover\n open={open}\n onOpenChange={combineEventHandlers(onOpenChange, setOpen)}\n label={label}\n {...otherProps}\n />\n </CurrentPath>\n );\n}\n","import type { DisplayStatus } from \"@ostack.tech/kform\";\nimport type { ControlStatus } from \"@ostack.tech/ui\";\n\n/** Transforms ostack/KForm's display status into ostack/UI's control status. */\nexport function displayStatusToControlStatus(\n displayStatus: DisplayStatus | undefined,\n): ControlStatus | undefined {\n switch (displayStatus) {\n case \"error\":\n return \"invalid\";\n case \"warning\":\n return \"warned\";\n default:\n return undefined;\n }\n}\n\n/** Transforms ostack/KForm's display status into a \"danger\" or \"warning\" colour. */\nexport function displayStatusToColor(\n displayStatus: DisplayStatus | undefined,\n): \"danger\" | \"warning\" | undefined {\n switch (displayStatus) {\n case \"error\":\n return \"danger\";\n case \"warning\":\n return \"warning\";\n default:\n return undefined;\n }\n}\n","/**\n * Whether a given value is [promise-like]{@link PromiseLike}.\n *\n * @param value Value to check if it is promise-like.\n * @returns Whether the provided value is like a promise.\n */\nexport function isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return typeof (value as any)?.then === \"function\";\n}\n","import { createContext, useContext } from \"react\";\n\n/** Value of the top bar context. */\nexport interface TopBarContextValue {\n topBarEl: HTMLElement | null;\n}\n\n/** Context of the top bar component. */\nexport const TopBarContext = createContext<TopBarContextValue | null>(null);\n\n/** Provides access to the top bar element within the context. */\nexport function useTopBarElement() {\n return useContext(TopBarContext)?.topBarEl ?? null;\n}\n","import {\n cx,\n Layer,\n useCombinedRef,\n useMeasure,\n usePrintClassNames,\n} from \"@ostack.tech/ui\";\nimport { type ComponentProps, useCallback, useState } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useSetTopBarHeight } from \"../FormApp\";\nimport { TopBarContext } from \"./TopBarContext.tsx\";\n\n/** Properties of the top bar component. */\nexport interface TopBarProps extends ComponentProps<\"div\"> {}\n\n/** Top bar component. */\nexport function TopBar({ className, ref, ...otherProps }: TopBarProps) {\n const prefix = usePrefix();\n const { printHidden } = usePrintClassNames();\n const setTopBarHeight = useSetTopBarHeight();\n\n const [topBarEl, setTopBarEl] = useState<HTMLDivElement | null>(null);\n useMeasure(\n topBarEl,\n useCallback(\n (measurement) => setTopBarHeight(measurement?.height),\n [setTopBarHeight],\n ),\n );\n\n const combinedTopBarRef = useCombinedRef(setTopBarEl, ref);\n return (\n <TopBarContext.Provider value={{ topBarEl }}>\n <Layer zIndex=\"sticky\">\n <div\n className={cx(prefix(\"top-bar\"), printHidden, className)}\n {...otherProps}\n ref={combinedTopBarRef}\n />\n </Layer>\n </TopBarContext.Provider>\n );\n}\n","import { cx, Stack, type StackProps } from \"@ostack.tech/ui\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useIssuesDisplayMode } from \"../FormApp\";\nimport { IssueMessages } from \"../IssueMessages\";\nimport { IssuesPopover } from \"../IssuesPopover\";\n\n/** Properties of the top bar actions component. */\nexport interface TopBarActionsProps extends StackProps {}\n\n/** Container used to display actions within the top bar. */\nexport function TopBarActions({\n className,\n children,\n ...otherProps\n}: TopBarActionsProps) {\n const prefix = usePrefix();\n const issuesDisplayMode = useIssuesDisplayMode();\n\n return (\n <Stack\n className={cx(prefix(\"top-bar__actions\"), className)}\n direction=\"row\"\n gap={2}\n justifyContent=\"flex-end\"\n {...otherProps}\n >\n {/* Global issues */}\n {issuesDisplayMode === \"inline\" && (\n <IssuesPopover>\n <IssueMessages />\n </IssuesPopover>\n )}\n\n {children}\n </Stack>\n );\n}\n","import {\n faChevronDown,\n faChevronUp,\n faTrash,\n} from \"@fortawesome/free-solid-svg-icons\";\nimport {\n AbsolutePath,\n AbsolutePathFragment,\n nullableSchemaInnerSchema,\n} from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n FormContext,\n useFormContext,\n useFormManager,\n} from \"@ostack.tech/kform-react\";\nimport {\n Button,\n type ButtonProps,\n combineEventHandlers,\n controlStatusToAccent,\n cx,\n DropdownMenu,\n DropdownMenuContent,\n type DropdownMenuContentProps,\n DropdownMenuGroup,\n DropdownMenuItem,\n type DropdownMenuProps,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n IconButton,\n useAlertDialog,\n useCombinedRef,\n useControllableState,\n useMediaBreakpointUp,\n VisuallyHidden,\n} from \"@ostack.tech/ui\";\nimport {\n type Dispatch,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useStore } from \"zustand\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { isPromiseLike } from \"../../utils/promiseUtils.ts\";\nimport { visiblyFocus } from \"../../utils/useControlAutofocus.ts\";\nimport {\n useFocus,\n useFormIsDisabled,\n useFormIsReadOnly,\n useIssuesDisplayMode,\n useOnPathFocus,\n useResetFocus,\n} from \"../FormApp\";\nimport { useTopBarElement } from \"../TopBar\";\nimport {\n type ResolvedAnnexObject,\n useAnnexesContext,\n useAnnexState,\n} from \"./AnnexesContext.ts\";\nimport type { AnnexesManagerProps } from \"./AnnexesManager.tsx\";\n\n/** Properties of the annexes' menu. */\nexport interface AnnexesMenuProps\n extends\n Pick<\n AnnexesManagerProps,\n | \"menuButtonText\"\n | \"menuButtonLabel\"\n | \"addAnnexText\"\n | \"removeAnnexButtonLabel\"\n | \"removeAnnexKeyboardHint\"\n | \"removeAnnexConfirmDialogTitle\"\n | \"removeAnnexConfirmDialogMessage\"\n | \"removeAnnexConfirmDialogOkText\"\n | \"removeAnnexConfirmDialogCancelText\"\n >,\n DropdownMenuProps {\n menuTriggerProps?: Omit<ButtonProps, \"icon\">;\n menuContentProps?: DropdownMenuContentProps;\n}\n\n/** Component that allows to navigate between, add, and remove annexes. */\nexport function AnnexesMenu({\n menuButtonText,\n menuButtonLabel,\n addAnnexText,\n removeAnnexButtonLabel,\n removeAnnexKeyboardHint,\n removeAnnexConfirmDialogTitle,\n removeAnnexConfirmDialogMessage,\n removeAnnexConfirmDialogOkText,\n removeAnnexConfirmDialogCancelText,\n defaultOpen = false,\n open: controlledOpen,\n onOpenChange,\n menuTriggerProps,\n menuContentProps,\n ...otherProps\n}: AnnexesMenuProps) {\n const prefix = usePrefix();\n const formIsReadOnly = useFormIsReadOnly();\n const store = useAnnexesContext();\n const isLargeScreen = useMediaBreakpointUp(\"sm\");\n const issuesDisplayMode = useIssuesDisplayMode();\n const [open, setOpen] = useControllableState(defaultOpen, controlledOpen);\n const menuTriggerRef = useRef<HTMLButtonElement | null>(null);\n const topBarEl = useTopBarElement();\n\n const activeAnnex = useStore(store, (state) => state.activeAnnex);\n const handleRadioGroupValueChange = useCallback(\n (value: string) =>\n store.getState().actions.setActiveAnnex(new AbsolutePath(value)),\n [store],\n );\n\n const annexes = useStore(store, (state) => state.annexes);\n const addedAnnexPathRef = useRef<AbsolutePath | null>(null);\n const newItems = useMemo(\n () =>\n annexes.map((annex) => (\n <AnnexesMenuNewItem\n key={annex.path.toString()}\n annex={annex}\n addedAnnexPathRef={addedAnnexPathRef}\n />\n )),\n [annexes],\n );\n const tabStates = useStore(\n store,\n useShallow((state) => state.tabStates()),\n );\n\n // Focus menu trigger when focusing an annex that doesn't exist\n const resetFocus = useResetFocus();\n useOnPathFocus(\n useCallback(\n (focusedPath: AbsolutePath) => {\n if (\n issuesDisplayMode === \"panel\" &&\n menuTriggerRef.current &&\n store\n .getState()\n .tablessStates()\n .some((state) => state.path.equals(focusedPath))\n ) {\n visiblyFocus(menuTriggerRef.current);\n resetFocus();\n }\n },\n [issuesDisplayMode, resetFocus, store],\n ),\n );\n\n // Auto-focus newly added annex on close\n const focus = useFocus();\n const handleCloseAutoFocus = useCallback(\n (evt: Event) => {\n if (addedAnnexPathRef.current) {\n evt.preventDefault();\n focus(addedAnnexPathRef.current);\n addedAnnexPathRef.current = null;\n }\n },\n [focus],\n );\n\n const combinedMenuTriggerRef = useCombinedRef(\n menuTriggerRef,\n menuTriggerProps?.ref as never,\n );\n return (\n <DropdownMenu\n open={open}\n onOpenChange={combineEventHandlers(onOpenChange, setOpen)}\n modal={false}\n {...otherProps}\n >\n <DropdownMenuTrigger>\n <Button\n variant=\"ghost\"\n iconPlacement=\"end\"\n aria-label={menuButtonLabel}\n {...menuTriggerProps}\n className={cx(\n prefix(\"annexes__menu-trigger\"),\n menuTriggerProps?.className,\n )}\n icon={open ? faChevronUp : faChevronDown}\n iconProps={{ size: \"2xs\", ...menuTriggerProps?.iconProps }}\n ref={combinedMenuTriggerRef}\n >\n {menuTriggerProps?.children ?? menuButtonText}\n </Button>\n </DropdownMenuTrigger>\n\n <DropdownMenuContent\n variant=\"subtle\"\n showArrow={false}\n sideOffset={-1}\n avoidCollisions={false}\n align=\"start\"\n {...menuContentProps}\n className={cx(prefix(\"annexes__menu\"), menuContentProps?.className)}\n onCloseAutoFocus={combineEventHandlers(\n menuContentProps?.onCloseAutoFocus,\n // eslint-disable-next-line react-hooks/refs\n handleCloseAutoFocus,\n )}\n portalProps={{\n container: topBarEl ?? undefined,\n ...menuContentProps?.portalProps,\n }}\n >\n <DropdownMenuRadioGroup\n value={activeAnnex?.toString()}\n onValueChange={handleRadioGroupValueChange}\n >\n {tabStates.map((state) => (\n <AnnexesMenuItem\n key={state.path.toString()}\n removeAnnexButtonLabel={removeAnnexButtonLabel}\n removeAnnexKeyboardHint={removeAnnexKeyboardHint}\n removeAnnexConfirmDialogTitle={removeAnnexConfirmDialogTitle}\n removeAnnexConfirmDialogMessage={removeAnnexConfirmDialogMessage}\n removeAnnexConfirmDialogOkText={removeAnnexConfirmDialogOkText}\n removeAnnexConfirmDialogCancelText={\n removeAnnexConfirmDialogCancelText\n }\n path={state.path}\n setOpen={setOpen}\n menuRef={menuTriggerRef}\n />\n ))}\n </DropdownMenuRadioGroup>\n {!formIsReadOnly && (\n <DropdownMenuGroup label={isLargeScreen ? undefined : addAnnexText}>\n {isLargeScreen ? (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger\n className={prefix(\"annexes__menu-add-annex\")}\n >\n {addAnnexText}\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className={prefix(\"annexes__menu-new\")}>\n {newItems}\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n ) : (\n newItems\n )}\n </DropdownMenuGroup>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** Properties of an item in the annexes' menu. */\ninterface AnnexesMenuItemProps extends Pick<\n AnnexesManagerProps,\n | \"removeAnnexButtonLabel\"\n | \"removeAnnexKeyboardHint\"\n | \"removeAnnexConfirmDialogTitle\"\n | \"removeAnnexConfirmDialogMessage\"\n | \"removeAnnexConfirmDialogOkText\"\n | \"removeAnnexConfirmDialogCancelText\"\n> {\n path: AbsolutePath;\n setOpen: Dispatch<boolean>;\n menuRef: RefObject<HTMLButtonElement | null>;\n}\n\n/** Item in the annexes' menu. */\nfunction AnnexesMenuItem({\n removeAnnexButtonLabel,\n removeAnnexKeyboardHint,\n removeAnnexConfirmDialogTitle,\n removeAnnexConfirmDialogMessage,\n removeAnnexConfirmDialogOkText,\n removeAnnexConfirmDialogCancelText,\n path,\n setOpen,\n menuRef,\n}: AnnexesMenuItemProps) {\n const prefix = usePrefix();\n const store = useAnnexesContext();\n const formContext = useFormContext();\n const formIsDisabled = useFormIsDisabled();\n const formIsReadOnly = useFormIsReadOnly();\n const { confirm } = useAlertDialog();\n\n const deferredDisplayStatus = useAnnexState(\n path,\n (state) => state?.deferredDisplayStatus,\n );\n const isRemovable = useAnnexState(\n path,\n (state) =>\n state != null && (state.schema.typeInfo.nullable || state.isRepetitive),\n );\n const title = useAnnexState(path, (state) => state?.title);\n const subtitle = useAnnexState(path, (state) => state?.subtitle);\n const nonRepetitiveDescription = useAnnexState(\n path,\n (state) => state && !state.isRepetitive && state.description,\n );\n\n const removeAnnex = async () => {\n const { getAnnexState, removeAnnex } = store.getState().actions;\n const state = getAnnexState(path);\n if (!state) {\n return;\n }\n\n if (\n !state.dirty ||\n (await confirm(\n // The form context will typically not be in the scope of the alert\n // dialog, so we need to provide it\n <FormContext.Provider value={{ ...formContext, currentPath: path }}>\n {removeAnnexConfirmDialogMessage?.(\n <strong>\n {state.title}\n {state.subtitle && <> — {state.subtitle}</>}\n </strong>,\n )}\n </FormContext.Provider>,\n {\n title: removeAnnexConfirmDialogTitle,\n color: \"danger\",\n okText: removeAnnexConfirmDialogOkText,\n cancelText: removeAnnexConfirmDialogCancelText,\n triggerElement: menuRef.current,\n },\n ))\n ) {\n void removeAnnex(state.path, state.isRepetitive);\n setOpen(false);\n }\n };\n\n const handleItemKeyDown = (evt: KeyboardEvent) => {\n if (\n isRemovable &&\n !formIsDisabled &&\n !formIsReadOnly &&\n evt.key === \"Delete\"\n ) {\n void removeAnnex();\n }\n };\n const handleRemoveButtonClick = (evt: MouseEvent) => {\n evt.stopPropagation();\n void removeAnnex();\n };\n\n return (\n <DropdownMenuRadioItem\n color=\"primary\"\n data-status={displayStatusToControlStatus(deferredDisplayStatus)}\n data-accent={controlStatusToAccent(\n displayStatusToControlStatus(deferredDisplayStatus),\n )}\n showRadio={false}\n value={path.toString()}\n className={prefix(\"annexes__menu-annex\")}\n actionProps={{\n className: prefix(\"annexes__menu-annex-action\"),\n }}\n contentProps={{\n className: prefix(\"annexes__menu-annex-content\"),\n }}\n onKeyDown={handleItemKeyDown}\n >\n <CurrentPath path={path}>\n <div className={prefix(\"annexes__menu-annex-content-container\")}>\n <div className={prefix(\"annexes__menu-annex-title\")}>\n {title}\n {subtitle && (\n <span className={prefix(\"annexes__menu-annex-subtitle\")}>\n <VisuallyHidden>, </VisuallyHidden>\n {subtitle}\n </span>\n )}\n </div>\n {nonRepetitiveDescription && (\n <div className={prefix(\"annexes__menu-annex-description\")}>\n <VisuallyHidden>, </VisuallyHidden>\n {nonRepetitiveDescription}\n </div>\n )}\n </div>\n {isRemovable && !formIsReadOnly && (\n <>\n {removeAnnexKeyboardHint && (\n <VisuallyHidden>{removeAnnexKeyboardHint}</VisuallyHidden>\n )}\n <IconButton\n className={prefix(\"annexes__menu-annex-remove\")}\n icon={faTrash}\n label={removeAnnexButtonLabel ?? \"\"}\n color=\"danger\"\n circle\n disabled={formIsDisabled}\n onClick={handleRemoveButtonClick}\n tabIndex={-1}\n />\n </>\n )}\n </CurrentPath>\n </DropdownMenuRadioItem>\n );\n}\n\n/** Properties of a new item in the annexes' menu. */\ninterface AnnexManagerNewItemProps extends Pick<\n AnnexesManagerProps,\n \"addAnnexSuccessMessage\"\n> {\n annex: ResolvedAnnexObject;\n addedAnnexPathRef: RefObject<AbsolutePath | null>;\n}\n\n/** New item in the annexes' menu. */\nfunction AnnexesMenuNewItem({\n annex,\n addedAnnexPathRef,\n}: AnnexManagerNewItemProps) {\n const prefix = usePrefix();\n const formIsDisabled = useFormIsDisabled();\n const formManager = useFormManager();\n const store = useAnnexesContext();\n\n const isRepetitive =\n annex.path.lastFragment === AbsolutePathFragment.Wildcard;\n const title = useStore(store, (state) =>\n isRepetitive\n ? (annex.title as ReactNode)\n : state.actions.getAnnexState(annex.path)?.title,\n );\n\n const canBeAdded = useStore(store, (state) => {\n if (isRepetitive) {\n const annexState = state.actions.getRepetitiveAnnexState(\n annex.path.parent(),\n );\n if (!annexState) {\n return false;\n }\n let maxSize = annexState.maxAnnexes;\n // Read max size from the schema restrictions if not defined\n if (maxSize == null) {\n const { restrictions } = annexState.schema.typeInfo;\n if (typeof restrictions.maxSize === \"number\") {\n maxSize = restrictions.maxSize;\n }\n }\n return (\n maxSize == null ||\n (annexState.rowIds != null && annexState.rowIds.length < maxSize)\n );\n } else {\n const annexState = state.actions.getAnnexState(annex.path);\n return annexState?.isNull ?? false;\n }\n });\n\n const [gettingValue, setGettingValue] = useState(false);\n const handleItemSelect = useCallback(async () => {\n const schema = formManager.schema(annex.path);\n const initialValue = schema.typeInfo.nullable\n ? nullableSchemaInnerSchema(schema).initialValue\n : schema.initialValue;\n\n let toAdd = initialValue;\n if (annex.getValue) {\n const clonedValue = await schema.clone(initialValue);\n setGettingValue(true);\n try {\n const getValueResult = annex.getValue(clonedValue);\n toAdd = isPromiseLike(getValueResult)\n ? await getValueResult\n : getValueResult;\n } finally {\n setGettingValue(false);\n }\n }\n\n if (toAdd == null) {\n return;\n }\n\n // Add new annex\n addedAnnexPathRef.current = await store\n .getState()\n .actions.addAnnex(annex.path, toAdd);\n }, [addedAnnexPathRef, annex, formManager, store]);\n\n return (\n <DropdownMenuItem\n color=\"primary\"\n className={prefix(\"annexes__menu-new-annex\")}\n disabled={formIsDisabled || !canBeAdded || gettingValue}\n onSelect={handleItemSelect}\n contentProps={{\n className: prefix(\"annexes__menu-new-annex-content\"),\n }}\n >\n <CurrentPath path={isRepetitive ? annex.path.parent() : annex.path}>\n <div className={prefix(\"annexes__menu-new-annex-title\")}>{title}</div>\n {annex.description && (\n <div className={prefix(\"annexes__menu-new-annex-description\")}>\n <VisuallyHidden>, </VisuallyHidden>\n {annex.description}\n </div>\n )}\n </CurrentPath>\n </DropdownMenuItem>\n );\n}\n","import type { AbsolutePath } from \"@ostack.tech/kform\";\nimport { CurrentPath } from \"@ostack.tech/kform-react\";\nimport { boolDataAttr, Tab, VisuallyHidden } from \"@ostack.tech/ui\";\nimport { useCallback, useId, useRef, useState } from \"react\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { visiblyFocus } from \"../../utils/useControlAutofocus.ts\";\nimport { useIssuesDisplayMode, useOnPathFocus } from \"../FormApp\";\nimport { useResetFocus } from \"../FormApp/FormAppContext.ts\";\nimport { IssueMessages } from \"../IssueMessages\";\nimport { IssuesPopover } from \"../IssuesPopover\";\nimport { useAnnexState } from \"./AnnexesContext.ts\";\n\nexport interface AnnexTabProps {\n path: AbsolutePath;\n}\n\nexport function AnnexTab({ path }: AnnexTabProps) {\n const prefix = usePrefix();\n const issuesDisplayMode = useIssuesDisplayMode();\n const deferredIssuesToDisplay = useAnnexState(\n path,\n useShallow((state) => state?.deferredIssuesToDisplay ?? []),\n );\n const hasIssues = deferredIssuesToDisplay.length > 0;\n const deferredDisplayStatus = useAnnexState(\n path,\n (state) => state?.deferredDisplayStatus,\n );\n const title = useAnnexState(path, (state) => state?.title);\n const subtitle = useAnnexState(path, (state) => state?.subtitle);\n\n const tabRef = useRef<HTMLButtonElement | null>(null);\n const resetFocus = useResetFocus();\n useOnPathFocus(\n useCallback(\n (focusedPath: AbsolutePath) => {\n if (tabRef.current && path.equals(focusedPath)) {\n visiblyFocus(tabRef.current);\n // Let the annex be opened before resetting focus\n setTimeout(() => resetFocus());\n }\n },\n [path, resetFocus],\n ),\n );\n\n // Manage issues popover\n const generatedId = useId();\n const issueMessagesId = prefix(`annexes-annex-issue-messages-${generatedId}`);\n const [issuesPopoverOpen, setIssuesPopoverOpen] = useState(false);\n const [tabFocused, setTabFocused] = useState(false);\n const handleTabFocus = useCallback(() => {\n setTabFocused(true);\n }, []);\n const handleTabBlur = useCallback(() => {\n setTabFocused(false);\n }, []);\n const handleIssuesPopoverOpenAutoFocus = useCallback(\n (evt: Event) => {\n if (tabFocused) {\n evt.preventDefault();\n }\n },\n [tabFocused],\n );\n\n return (\n <>\n <Tab\n className={prefix(\"annexes__tab\")}\n value={path.toString()}\n status={displayStatusToControlStatus(deferredDisplayStatus)}\n onFocus={handleTabFocus}\n onBlur={handleTabBlur}\n data-has-issues={boolDataAttr(\n issuesDisplayMode === \"inline\" && hasIssues,\n )}\n tabInnerProps={{ className: prefix(\"annexes__tab-inner\") }}\n tabTextProps={{ className: prefix(\"annexes__tab-text\") }}\n aria-describedby={hasIssues ? issueMessagesId : undefined}\n ref={tabRef}\n >\n <CurrentPath path={path}>\n <span className={prefix(\"annexes__tab-title\")}>{title}</span>\n {subtitle && (\n <span className={prefix(\"annexes__tab-subtitle\")}>\n <VisuallyHidden>, </VisuallyHidden>\n {subtitle}\n </span>\n )}\n </CurrentPath>\n </Tab>\n\n {hasIssues && issuesDisplayMode === \"panel\" && (\n <IssueMessages\n hidden\n id={issueMessagesId}\n path={path}\n issues={deferredIssuesToDisplay}\n />\n )}\n\n {issuesDisplayMode === \"inline\" && (\n <IssuesPopover\n path={path}\n open={hasIssues && (tabFocused || issuesPopoverOpen)}\n onOpenChange={setIssuesPopoverOpen}\n onOpenAutoFocus={handleIssuesPopoverOpenAutoFocus}\n buttonContainerProps={{\n className: prefix(\"annexes__tab-issues-popover-button-container\"),\n }}\n iconButtonProps={{\n className: prefix(\"annexes__tab-issues-popover-button\"),\n tabIndex: -1,\n }}\n >\n <IssueMessages\n id={issueMessagesId}\n issues={deferredIssuesToDisplay}\n />\n </IssuesPopover>\n )}\n </>\n );\n}\n","import {\n cx,\n TabList,\n type TabListProps,\n useMediaBreakpointUp,\n} from \"@ostack.tech/ui\";\nimport { useStore } from \"zustand\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useAnnexesContext } from \"./AnnexesContext.ts\";\nimport { AnnexTab } from \"./AnnexTab.tsx\";\n\n/** Properties of the annex tab list component. */\nexport interface AnnexTabListProps extends TabListProps {\n hideNonActiveOnSmallScreens: boolean;\n}\n\n/** List of annex tabs. */\nexport function AnnexesTabList({\n hideNonActiveOnSmallScreens,\n rootProps,\n className,\n ...otherProps\n}: AnnexTabListProps) {\n const prefix = usePrefix();\n const store = useAnnexesContext();\n const activeAnnex = useStore(store, (state) => state.activeAnnex);\n const tabStates = useStore(\n store,\n useShallow((state) => state.tabStates()),\n );\n const isLargeScreen = useMediaBreakpointUp(\"sm\");\n\n return (\n <TabList\n className={cx(prefix(\"annexes__tab-list\"), className)}\n rootProps={{\n ...rootProps,\n className: cx(prefix(\"annexes__tab-list-root\"), rootProps?.className),\n }}\n {...otherProps}\n >\n {tabStates.map((state) =>\n !hideNonActiveOnSmallScreens ||\n isLargeScreen ||\n state.path.equals(activeAnnex) ? (\n <AnnexTab key={state.path.toString()} {...state} />\n ) : null,\n )}\n </TabList>\n );\n}\n","import { AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { useFormManager } from \"@ostack.tech/kform-react\";\nimport {\n type ButtonProps,\n combineAriaIds,\n combineEventHandlers,\n cx,\n type DropdownMenuContentProps,\n type DropdownMenuProps,\n FeedbackList,\n type TabListProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type ReactNode,\n useCallback,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useIssuesDisplayMode } from \"../FormApp\";\nimport { IssueMessages } from \"../IssueMessages\";\nimport { IssuesPopover } from \"../IssuesPopover\";\nimport {\n type AnnexState,\n type RepetitiveAnnexState,\n useAnnexesContext,\n} from \"./AnnexesContext.ts\";\nimport { AnnexesMenu } from \"./AnnexesMenu.tsx\";\nimport { AnnexesTabList } from \"./AnnexesTabList.tsx\";\n\n/** Properties of the annexes' manager component. */\nexport interface AnnexesManagerProps extends ComponentProps<\"nav\"> {\n /**\n * Whether to show the annexes manager menu. This defaults to `true` if there\n * is at least one optional or repetitive annex, and `false` otherwise.\n */\n showMenu?: boolean;\n /** Text of the menu button. */\n menuButtonText?: ReactNode;\n /** Accessible label of the menu button. */\n menuButtonLabel?: string;\n /** Text of the \"add annex\" item. */\n addAnnexText?: ReactNode;\n /** Message read to assistive technologies when an annex is successfully added. */\n addAnnexSuccessMessage?: (annexName: ReactNode) => ReactNode;\n /** Label of the remove annex button, announced by assistive technologies. */\n removeAnnexButtonLabel?: string;\n /**\n * Hint on how to remove an annex via keyboard, announced by assistive\n * technologies.\n */\n removeAnnexKeyboardHint?: string;\n /** Title of the \"remove annex\" confirm dialog. */\n removeAnnexConfirmDialogTitle?: ReactNode;\n /**\n * Function that should return the message of the \"remove annex\" confirm\n * dialog, given a node with the name of the annex.\n *\n * @param annexName Node containing the name of the annex.\n */\n removeAnnexConfirmDialogMessage?: (annexName: ReactNode) => ReactNode;\n /** Text of the \"remove annex\" confirm dialog OK button. */\n removeAnnexConfirmDialogOkText?: ReactNode;\n /** Text of the \"remove annex\" confirm dialog cancel button. */\n removeAnnexConfirmDialogCancelText?: ReactNode;\n /** Properties to pass to the menu container element. */\n menuContainerProps?: ComponentProps<\"div\">;\n /** Properties to pass to the menu trigger component. */\n menuTriggerProps?: Omit<ButtonProps, \"icon\">;\n /** Properties to pass to the menu content component. */\n menuContentProps?: DropdownMenuContentProps;\n /** Properties to pass to the menu component. */\n menuProps?: DropdownMenuProps;\n /** Properties to pass to the tab-list container element. */\n tabListContainerProps?: ComponentProps<\"div\">;\n /** Properties to pass to the tab-list component. */\n tabListProps?: TabListProps;\n}\n\n/**\n * Component used to manage the form's annexes. Provides a menu that allows\n * changing, adding, and removing annexes, as well as a list of tabs for each\n * existing annex.\n */\nexport function AnnexesManager({\n showMenu,\n menuButtonText,\n menuButtonLabel,\n addAnnexText,\n removeAnnexButtonLabel,\n removeAnnexKeyboardHint,\n removeAnnexConfirmDialogTitle,\n removeAnnexConfirmDialogMessage,\n removeAnnexConfirmDialogOkText,\n removeAnnexConfirmDialogCancelText,\n className,\n \"aria-label\": ariaLabel,\n menuContainerProps,\n menuTriggerProps,\n menuContentProps,\n menuProps,\n tabListContainerProps,\n tabListProps,\n ref,\n ...otherProps\n}: AnnexesManagerProps) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n ariaLabel ??= locale.AnnexesManager[\"aria-label\"];\n menuButtonText ??= locale.AnnexesManager.menuButtonText;\n menuButtonLabel ??= locale.AnnexesManager.menuButtonLabel;\n addAnnexText ??= locale.AnnexesManager.addAnnexText;\n removeAnnexButtonLabel ??= locale.AnnexesManager.removeAnnexButtonLabel;\n removeAnnexKeyboardHint ??= locale.AnnexesManager.removeAnnexKeyboardHint;\n removeAnnexConfirmDialogTitle ??=\n locale.AnnexesManager.removeAnnexConfirmDialogTitle;\n removeAnnexConfirmDialogMessage ??=\n locale.AnnexesManager.removeAnnexConfirmDialogMessage;\n removeAnnexConfirmDialogOkText ??=\n locale.AnnexesManager.removeAnnexConfirmDialogOkText;\n removeAnnexConfirmDialogCancelText ??=\n locale.AnnexesManager.removeAnnexConfirmDialogCancelText;\n\n const managerRef = useRef<HTMLElement | null>(null);\n const store = useAnnexesContext();\n const issuesDisplayMode = useIssuesDisplayMode();\n const tablessStates: (AnnexState | RepetitiveAnnexState)[] = useStore(\n store,\n (state) => state.tablessStates(),\n );\n const tablessPaths = useMemo(\n () => tablessStates.map((state) => state.path),\n [tablessStates],\n );\n const deferredTablessIssuesToDisplay = useMemo(\n () => tablessStates.map((state) => state.deferredIssuesToDisplay || []),\n [tablessStates],\n );\n const hasIssues = useMemo(\n () => deferredTablessIssuesToDisplay.some((issues) => issues.length > 0),\n [deferredTablessIssuesToDisplay],\n );\n const hasErrors = useMemo(\n () =>\n deferredTablessIssuesToDisplay.some((issues) =>\n issues.some((issue) => issue.severity === \"error\"),\n ),\n [deferredTablessIssuesToDisplay],\n );\n const formManager = useFormManager();\n const shouldShowMenu = useStore(\n store,\n (state) =>\n showMenu ??\n state.annexes.some(\n (annex) =>\n annex.path.lastFragment === AbsolutePathFragment.Wildcard ||\n formManager.schema(annex.path).typeInfo.nullable,\n ),\n );\n\n // Ensure that the `<nav>` aria-owns the content of the dropdown menu, so that\n // a SR user doesn't \"exit navigation\" when navigating to it\n const generatedId = useId();\n const menuContentId =\n menuContentProps?.id ?? prefix(`annexes-menu-content-${generatedId}`);\n const handleAnnexesMenuOpenChange = useCallback(\n (open: boolean) => {\n const managerEl = managerRef.current;\n if (managerEl) {\n const oldAriaOwns =\n managerEl.getAttribute(\"aria-owns\")?.split(\" \") ?? [];\n let newAriaOwns: string[];\n if (open) {\n newAriaOwns = [...oldAriaOwns, menuContentId];\n } else {\n newAriaOwns = oldAriaOwns.filter((id) => id !== menuContentId);\n }\n if (newAriaOwns.length > 0) {\n managerEl.setAttribute(\"aria-owns\", newAriaOwns.join(\" \"));\n } else {\n managerEl.removeAttribute(\"aria-owns\");\n }\n }\n },\n [menuContentId],\n );\n\n // Manage issues popover\n const issueMessagesId = prefix(`annexes-issue-messages-${generatedId}`);\n const [issuesPopoverOpen, setIssuesPopoverOpen] = useState(false);\n const [menuTriggerFocused, setMenuTriggerFocused] = useState(false);\n const handleMenuTriggerFocus = useCallback(() => {\n setMenuTriggerFocused(true);\n }, []);\n const handleMenuTriggerBlur = useCallback(() => {\n setMenuTriggerFocused(false);\n }, []);\n const handleIssuesPopoverOpenAutoFocus = useCallback(\n (evt: Event) => {\n if (menuTriggerFocused) {\n evt.preventDefault();\n }\n },\n [menuTriggerFocused],\n );\n\n const feedbackList = (\n <FeedbackList id={issueMessagesId} hidden={issuesDisplayMode === \"panel\"}>\n {tablessStates.map((state, i) => (\n <IssueMessages\n key={state.path.toString()}\n path={state.path}\n issues={deferredTablessIssuesToDisplay[i] ?? []}\n unwrapped\n />\n ))}\n </FeedbackList>\n );\n\n const combinedManagerRef = useCombinedRef(managerRef, ref);\n return (\n <nav\n className={cx(prefix(\"annexes__manager\"), className)}\n aria-label={ariaLabel}\n {...otherProps}\n ref={combinedManagerRef}\n >\n {shouldShowMenu && (\n <div\n {...menuContainerProps}\n className={cx(\n prefix(\"annexes__menu-container\"),\n menuContainerProps?.className,\n )}\n >\n <AnnexesMenu\n menuButtonText={menuButtonText}\n menuButtonLabel={menuButtonLabel}\n addAnnexText={addAnnexText}\n removeAnnexButtonLabel={removeAnnexButtonLabel}\n removeAnnexKeyboardHint={removeAnnexKeyboardHint}\n removeAnnexConfirmDialogTitle={removeAnnexConfirmDialogTitle}\n removeAnnexConfirmDialogMessage={removeAnnexConfirmDialogMessage}\n removeAnnexConfirmDialogOkText={removeAnnexConfirmDialogOkText}\n removeAnnexConfirmDialogCancelText={\n removeAnnexConfirmDialogCancelText\n }\n {...menuProps}\n onOpenChange={combineEventHandlers(\n menuProps?.onOpenChange,\n // eslint-disable-next-line react-hooks/refs\n handleAnnexesMenuOpenChange,\n )}\n menuTriggerProps={{\n \"aria-invalid\": hasErrors || undefined,\n ...menuTriggerProps,\n \"aria-describedby\": combineAriaIds(\n menuTriggerProps?.[\"aria-describedby\"],\n issueMessagesId,\n ),\n onFocus: combineEventHandlers(\n menuTriggerProps?.onFocus,\n handleMenuTriggerFocus,\n ),\n onBlur: combineEventHandlers(\n menuTriggerProps?.onBlur,\n handleMenuTriggerBlur,\n ),\n }}\n menuContentProps={{ ...menuContentProps, id: menuContentId }}\n />\n </div>\n )}\n\n {shouldShowMenu &&\n issuesDisplayMode === \"panel\" &&\n hasIssues &&\n feedbackList}\n\n {shouldShowMenu && issuesDisplayMode === \"inline\" && (\n <IssuesPopover\n open={hasIssues && (menuTriggerFocused || issuesPopoverOpen)}\n onOpenChange={setIssuesPopoverOpen}\n onOpenAutoFocus={handleIssuesPopoverOpenAutoFocus}\n buttonContainerProps={{\n className: prefix(\"annexes__issues-popover-container\"),\n }}\n iconButtonProps={{ tabIndex: -1 }}\n relevantPaths={tablessPaths}\n >\n {feedbackList}\n </IssuesPopover>\n )}\n\n <div\n {...tabListContainerProps}\n className={cx(\n prefix(\"annexes__tab-list-container\"),\n tabListContainerProps?.className,\n )}\n >\n <AnnexesTabList\n hideNonActiveOnSmallScreens={shouldShowMenu}\n {...tabListProps}\n />\n </div>\n </nav>\n );\n}\n","import type { SealedValidationIssue } from \"@ostack.tech/kform\";\nimport {\n type ControlVariant,\n FeedbackList,\n useIsInTableCell,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { useIssuesDisplayMode } from \"../components/FormApp\";\nimport {\n IssueMessages,\n type IssueMessagesByCode,\n type IssueMessagesProps,\n} from \"../components/IssueMessages\";\nimport { IssuesPopover } from \"../components/IssuesPopover\";\n\n/** Options of the `useControlIssues` hook. */\nexport interface UseControlIssuesOptions {\n /** Mapping from path to issues to display. */\n issuesToDisplay: Record<string, SealedValidationIssue[]>;\n /** Mapping from path to issue messages by code. */\n issueMessages?: Record<string, IssueMessagesByCode | undefined>;\n /** Whether issues should be displayed. */\n displayIssues?: boolean;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n /** Variant of the control. */\n variant?: ControlVariant;\n}\n\n/** Result of the `useControlIssues` hook. */\nexport interface UseControlIssuesResult {\n /**\n * Node that should be rendered when the issues are to appear inline. This\n * will be `null` if the issues should not appear inline.\n */\n inlineIssues: ReactNode;\n /**\n * Node that should be rendered when the issues are to appear within a\n * popover. This will be `null` if the issues should not appear in a popover.\n */\n popoverIssues: ReactNode;\n}\n\n/** Hook which helps a control component render its issues. */\nexport function useControlIssues({\n issuesToDisplay,\n issueMessages,\n displayIssues = true,\n issueMessagesProps,\n variant,\n}: UseControlIssuesOptions): UseControlIssuesResult {\n const issuesDisplayMode = useIssuesDisplayMode();\n const isInTableCell = useIsInTableCell();\n const showInPopover =\n variant === \"cell\" || (variant === undefined && isInTableCell);\n\n const {\n displayIssueCodes,\n unknownErrorMessage,\n unknownWarningMessage,\n ...feedbackListProps\n } = issueMessagesProps ?? {};\n const issuesNode = displayIssues && (\n <FeedbackList {...feedbackListProps} hidden={issuesDisplayMode === \"panel\"}>\n {Object.entries(issuesToDisplay).map(([path, issues], i) => (\n <IssueMessages\n key={i}\n path={path}\n issues={issues}\n messages={issueMessages?.[path]}\n displayIssueCodes={displayIssueCodes}\n unknownErrorMessage={unknownErrorMessage}\n unknownWarningMessage={unknownWarningMessage}\n unwrapped\n />\n ))}\n </FeedbackList>\n );\n if (issuesDisplayMode === \"panel\") {\n return { inlineIssues: issuesNode, popoverIssues: null };\n }\n return {\n inlineIssues: showInPopover ? null : issuesNode,\n popoverIssues: showInPopover ? (\n <IssuesPopover>{issuesNode}</IssuesPopover>\n ) : null,\n };\n}\n","import type {\n AbsolutePath,\n DisplayStatus,\n SealedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport type { Controller } from \"@ostack.tech/kform-react\";\nimport {\n useDataTableColumnLabel,\n useOnLabelChange,\n usePrinting,\n useStartPrintingTask,\n} from \"@ostack.tech/ui\";\nimport {\n type FocusEvent,\n type ReactNode,\n type Ref,\n type RefObject,\n useCallback,\n useDeferredValue,\n useEffect,\n useImperativeHandle,\n useMemo,\n} from \"react\";\nimport { shallow } from \"zustand/shallow\";\n\nimport { useRegisterControllerWithinControlField } from \"../components/ControlField\";\nimport {\n useFormIsDisabled,\n useFormIsReadOnly,\n useRegisterController,\n useRegisterLabel,\n} from \"../components/FormApp\";\nimport {\n useFormAppContext,\n useSetLatestInteraction,\n} from \"../components/FormApp/FormAppContext.ts\";\nimport { useControlAutofocus } from \"./useControlAutofocus.ts\";\n\n/** Options when registering the control. */\nexport interface UseRegisterControlOptions<T> {\n controller: Controller<T>;\n issuesPanelLabel?: ReactNode;\n ariaLabel?: string;\n issuesPanelLabelSuffix?: ReactNode;\n preventAutoFocus?: boolean;\n apiRef?: Ref<Controller<T> | undefined>;\n}\n\n/** Result of registering the control. */\nexport interface UseRegisterControlResult<TElem> {\n displayLoading: boolean;\n displayDisabled: boolean;\n displayReadOnly: boolean;\n displayStatusToDisplay: DisplayStatus | undefined;\n displayValidating: boolean;\n issuesToDisplay: SealedValidationIssue[];\n autofocusRef: RefObject<TElem | null>;\n handleFocus: (event: FocusEvent) => void;\n}\n\n/** Hook used to register a control within the form app. */\nexport function useRegisterControl<T, TElem extends HTMLElement = HTMLElement>({\n controller,\n issuesPanelLabel,\n ariaLabel,\n issuesPanelLabelSuffix,\n preventAutoFocus,\n apiRef,\n}: UseRegisterControlOptions<T>): UseRegisterControlResult<TElem> {\n const printing = usePrinting();\n const { useState, usePath, useInitialized, useDisplayStatus } = controller;\n const path = usePath();\n const formIsDisabled = useFormIsDisabled();\n const displayReadOnly = useFormIsReadOnly();\n const initialized = useInitialized();\n const displayStatusToDisplay = useDeferredValue(useDisplayStatus());\n const displayValidating = useDeferredValue(\n useState((state) => state.validationStatus === \"validating\"),\n );\n const issuesToDisplay = useDeferredValue(\n useState((state) => (state.touched ? state.issues : []), {\n equalityFn: shallow,\n }),\n );\n\n // Start a printing task until the control is initialised\n const finishPrintingTask = useStartPrintingTask();\n useEffect(() => {\n if (initialized) {\n finishPrintingTask();\n }\n }, [finishPrintingTask, initialized]);\n\n // Register the issues panel label\n const columnLabel = useDataTableColumnLabel();\n useRegisterLabel(\n path,\n issuesPanelLabel || columnLabel || ariaLabel,\n issuesPanelLabel ? 1 : -1,\n );\n useRegisterFieldLabel(path, issuesPanelLabelSuffix);\n\n // Register the controller within its control field\n useRegisterControllerWithinControlField(controller, issuesToDisplay);\n\n // Register the controller in the form app\n useRegisterController(controller);\n\n // Expose the control's API via `apiRef`\n useImperativeHandle(apiRef, () => controller, [controller]);\n\n // Autofocus control when the active path changes\n const autofocusRef = useControlAutofocus<T, TElem>(\n controller,\n !preventAutoFocus && !printing,\n );\n\n // Handle control focus\n const setLatestInteraction = useSetLatestInteraction();\n const handleFocus = useCallback(\n (event: FocusEvent) => {\n if (\n !printing &&\n event.target === event.currentTarget &&\n !event.defaultPrevented\n ) {\n setLatestInteraction(controller.getState().path);\n }\n },\n [controller, printing, setLatestInteraction],\n );\n\n return useMemo(\n () => ({\n displayLoading: printing ? false : !initialized,\n displayDisabled: printing ? false : formIsDisabled,\n displayReadOnly: printing ? false : displayReadOnly,\n displayStatusToDisplay: printing ? undefined : displayStatusToDisplay,\n displayValidating: printing ? false : displayValidating,\n issuesToDisplay: printing ? [] : issuesToDisplay,\n autofocusRef,\n handleFocus,\n }),\n [\n printing,\n initialized,\n formIsDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n ],\n );\n}\n\n/** Hook used to register a label for all control field's controls. */\nfunction useRegisterFieldLabel(\n path: AbsolutePath,\n issuesPanelLabelSuffix?: ReactNode,\n) {\n const { store: formAppStore } = useFormAppContext();\n useOnLabelChange(\n useCallback(\n (label) =>\n formAppStore.getState().actions.registerLabel(\n path,\n label && issuesPanelLabelSuffix ? (\n <>\n {label}\n {issuesPanelLabelSuffix}\n </>\n ) : (\n label\n ),\n ),\n [formAppStore, issuesPanelLabelSuffix, path],\n ),\n );\n}\n","import { faBug } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n AbsolutePathFragment,\n isKtList,\n isTable,\n Path,\n tableRowsToArray,\n} from \"@ostack.tech/kform\";\nimport {\n FormattedValue,\n type FormatterControllerState,\n} from \"@ostack.tech/kform-react\";\nimport {\n Code,\n DescriptionList,\n DescriptionListItem,\n IconButton,\n type IconButtonProps,\n Popover,\n PopoverContent,\n PopoverTrigger,\n Spinner,\n useCssVars,\n usePrinting,\n useSpacing,\n} from \"@ostack.tech/ui\";\nimport { Fragment, type ReactElement, type ReactNode } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToColor } from \"../../utils/displayStatusConversions.ts\";\n\n/** Properties of the debug info component. */\nexport interface DebugInfoProps<\n T = unknown,\n TFormatted extends ReactNode = string,\n> extends Partial<IconButtonProps> {\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** Path of the value to debug. */\n path?: string | Path;\n /**\n * Format function that transforms the form manager value to debug into a\n * value to be output. The passed {@link value} is `undefined` when the form\n * manager value does not exist.\n *\n * @param value Form manager value to transform.\n * @param state Controller's state.\n * @returns Transformed value.\n */\n format?: (\n value: T | undefined,\n state: FormatterControllerState<T, TFormatted>,\n ) => TFormatted;\n /** Trigger used to toggle the debug info popover. */\n children?: ReactElement;\n}\n\n/** Debug information. */\nexport function DebugInfo<T = unknown, TFormatted extends ReactNode = string>({\n defaultOpen,\n open,\n onOpenChange,\n path = Path.CURRENT_DEEP,\n format = defaultFormat as never,\n children,\n label,\n ...otherProps\n}: DebugInfoProps<T, TFormatted>) {\n const [locale] = useLocale();\n label ??= locale.DebugInfo?.label;\n\n const spacing = useSpacing();\n const { cssVar } = useCssVars();\n const printing = usePrinting();\n\n const empty = <span style={{ color: cssVar(\"neutral-a9\") }}>—</span>;\n\n if (printing) {\n return null;\n }\n return (\n <Popover defaultOpen={defaultOpen} open={open} onOpenChange={onOpenChange}>\n <PopoverTrigger>\n {children ?? (\n <IconButton\n icon={faBug}\n color=\"danger\"\n variant=\"ghost\"\n label={label}\n {...otherProps}\n />\n )}\n </PopoverTrigger>\n\n <PopoverContent style={{ width: 550 }}>\n <FormattedValue<T, TFormatted> path={path} format={format}>\n {({\n schema,\n path,\n observingDescendants,\n initialized,\n formattedValue,\n dirty,\n touched,\n issues,\n validationStatus,\n displayStatus,\n }) =>\n initialized ? (\n <DescriptionList gap={3} style={{ margin: spacing(-1, 1, 3) }}>\n <DescriptionListItem xs={6} term=\"Path\">\n <Code>\n {(observingDescendants\n ? path.append(AbsolutePathFragment.RecursiveWildcard)\n : path\n ).toString()}\n </Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Schema type\">\n <Code>{schema.typeInfo.toString()}</Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Validations\">\n {schema.validations.length > 0\n ? schema.validations.map((validation, i) => (\n <Fragment key={i}>\n {i !== 0 && \", \"}\n <Code>{validation.toString()}</Code>\n </Fragment>\n ))\n : empty}\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Value\">\n <Code>{formattedValue}</Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Dirty\">\n <Code>{JSON.stringify(dirty)}</Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Touched\">\n <Code>{JSON.stringify(touched)}</Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Issues\">\n {issues && issues.length > 0\n ? issues.map((issue, i) => (\n <Fragment key={i}>\n {i !== 0 && \", \"}\n <Code\n color={\n issue.severity === \"error\" ? \"danger\" : \"warning\"\n }\n >\n {issue.code}\n </Code>\n </Fragment>\n ))\n : empty}\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Validation status\">\n <Code>{validationStatus}</Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Display status\">\n <Code color={displayStatusToColor(displayStatus)}>\n {displayStatus}\n </Code>\n </DescriptionListItem>\n </DescriptionList>\n ) : (\n <Spinner />\n )\n }\n </FormattedValue>\n </PopoverContent>\n </Popover>\n );\n}\n\n/** Default format function. */\nfunction defaultFormat(value: unknown): string {\n if (value === undefined) {\n return \"undefined\";\n }\n if (value === null) {\n return \"null\";\n }\n if (typeof value === \"string\") {\n return JSON.stringify(value);\n }\n if (isKtList(value)) {\n return `[${value.asJsReadonlyArrayView().map(defaultFormat).join(\", \")}]`;\n }\n if (isTable(value)) {\n return `[${tableRowsToArray(value)\n .map(([id, v]) => `${id}=${defaultFormat(v)}`)\n .join(\", \")}]`;\n }\n if (\n typeof value === \"object\" &&\n [null, Object.prototype].includes(Object.getPrototypeOf(value))\n ) {\n return `{${Object.entries(value)\n .map(([k, v]) => `${k}: ${defaultFormat(v)}`)\n .join(\", \")}}`;\n }\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n return String(value);\n}\n","import { faBug } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n ControlAddon,\n type ControlAddonProps,\n Icon,\n Tooltip,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\n\n/** Properties of the debug info control addon trigger component. */\nexport interface DebugInfoControlAddonTriggerProps extends Partial<\n ControlAddonProps<\"button\">\n> {\n /** Label of the button used to trigger the debug information. */\n label?: ReactNode;\n}\n\n/** Debug info trigger as a control addon. */\nexport function DebugInfoControlAddonTrigger({\n label,\n ...otherProps\n}: DebugInfoControlAddonTriggerProps) {\n const [locale] = useLocale();\n label ??= locale.DebugInfo?.label;\n\n return (\n <Tooltip content={label}>\n <ControlAddon as=\"button\" {...otherProps} aria-describedby={undefined}>\n <Icon icon={faBug} label={label} color=\"danger\" />\n </ControlAddon>\n </Tooltip>\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type FormatterControllerState,\n type InputController,\n type InputOptions,\n InvalidPathError,\n useInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n Checkbox,\n type CheckboxChecked,\n type CheckboxProps,\n combineEventHandlers,\n FeedbackProvider,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type Dispatch,\n type ReactNode,\n type Ref,\n useState,\n} from \"react\";\n\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\n\n/** Properties of the checkbox control component. */\nexport interface CheckboxControlProps<T extends boolean | null = boolean | null>\n extends\n Omit<\n InputOptions<T, CheckboxChecked, ComponentRef<typeof Checkbox>>,\n \"enabled\" | \"format\" | \"parse\"\n >,\n Omit<\n CheckboxProps,\n \"defaultChecked\" | \"checked\" | \"status\" | \"validate\" | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | InputController<T, CheckboxChecked, ComponentRef<typeof Checkbox>>\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The checkbox control component is a KForm form control for values with\n * (possibly\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`BooleanSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-boolean-schema/index.html).\n * It is built on top of the [`Checkbox`](/docs/ostack-ui-forms-checkbox--docs)\n * component.\n *\n * The following built-in KForm validation affects this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n *\n * Example usage:\n *\n * ```tsx\n * import { CheckboxControl } from \"@ostack.tech/ui-kform\";\n *\n * function TermsControl() {\n * return (\n * <CheckboxControl path=\"/terms\">\n * Accept terms and conditions\n * </CheckboxControl>\n * );\n * }\n * ```\n */\nexport function CheckboxControl<T extends boolean | null = boolean | null>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n loading,\n showSpinner,\n disabled,\n readOnly,\n endAdornment,\n onFocus,\n onCheckedChange,\n onBlurToOutside,\n debug,\n ref,\n ...otherProps\n}: CheckboxControlProps<T>) {\n const [formattedValue, setFormattedValue] = useState<CheckboxChecked>(false);\n const controller = useInput<\n T,\n CheckboxChecked,\n ComponentRef<typeof Checkbox>\n >(path, {\n enabled: !useFormIsLoading(),\n parse: parseCheckboxValue,\n format: formatToCheckboxValue,\n setFormattedValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLButtonElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n if (schema.typeInfo.name !== \"Boolean\") {\n throw new InvalidPathError(\n absolutePath,\n \"Unsupported schema: Expected schema representing (possibly nullable) \" +\n \"booleans, but got schema representing values of type \" +\n `'${schema.typeInfo.toString()}'.`,\n );\n }\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedCheckboxRef = useCombinedRef(inputProps.ref, autofocusRef, ref);\n return (\n <FeedbackProvider>\n <Checkbox\n checked={formattedValue}\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath} />\n )}\n </>\n }\n onCheckedChange={combineEventHandlers(\n onCheckedChange,\n combineEventHandlers(\n inputProps.onChange,\n setFormattedValue as Dispatch<CheckboxChecked>,\n ),\n )}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedCheckboxRef}\n />\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n\n/** Parses a checkbox control formatted value. */\nfunction parseCheckboxValue<T extends boolean | null>(\n formattedValue: CheckboxChecked,\n state: FormatterControllerState<T, CheckboxChecked>,\n): T {\n return (\n formattedValue === \"indeterminate\"\n ? state.schema.typeInfo.nullable\n ? null\n : state.schema.initialValue\n : formattedValue\n ) as T;\n}\n\n/** Formats a checkbox control value. */\nfunction formatToCheckboxValue<T extends boolean | null>(\n value: T | undefined,\n): CheckboxChecked {\n return value === undefined ? false : (value ?? \"indeterminate\");\n}\n","import type { Schema } from \"@ostack.tech/kform\";\nimport { equals, type Listable } from \"@ostack.tech/kform-react\";\nimport { Option, OptionsGroup } from \"@ostack.tech/ui\";\nimport type { JSX } from \"react\";\n\nimport type {\n SelectControlItemGroupObject,\n SelectControlItemObject,\n} from \"../components/SelectControl\";\n\n/** Whether the provided value isn't a known option. */\nexport function isUnknownValue<T>(\n value: T | null | undefined,\n options: { value: T }[],\n) {\n return (\n value != null &&\n value !== \"\" &&\n options.every((opt) => !equals(opt.value, value))\n );\n}\n\n/**\n * Parses a selection value from the (string) index of an option (or empty\n * string).\n */\nexport function parseSelectionValueFromOptionIndex<T>(\n formattedValue: string,\n schema: Schema<T>,\n options: { value: T }[],\n unknownValues: readonly T[],\n): T {\n if (formattedValue === \"\") {\n return schema.typeInfo.nullable ? (null as T) : schema.initialValue;\n } else if (formattedValue.startsWith(\"-\")) {\n return unknownValues[-+formattedValue - 1];\n }\n return options[+formattedValue].value;\n}\n\n/**\n * Formats a selection value as the (string) index of an option (or empty\n * string).\n */\nexport function formatSelectionValueAsOptionIndex<T>(\n value: T | undefined,\n options: { value: T }[],\n): string {\n const idx = options.findIndex((option) => equals(option.value, value));\n return idx === -1\n ? value == null || value === \"\"\n ? \"\"\n : \"-1\"\n : idx.toString();\n}\n\n/** Values that aren't known options. */\nexport function getUnknownValues<T>(\n arrayValue: readonly T[] | null | undefined,\n options: { value: T }[],\n): T[] {\n const unknownValues: T[] = [];\n for (const v of arrayValue ?? []) {\n if (\n options.every((opt) => !equals(opt.value, v)) &&\n unknownValues.every((u) => !equals(u, v))\n ) {\n unknownValues.push(v);\n }\n }\n return unknownValues;\n}\n\n/** Parses an array of selection values from an array of (string) option indices. */\nexport function parseSelectionValuesFromOptionIndices<\n T,\n TListable extends Listable<T> | null,\n>(\n formattedValue: string[],\n schema: Schema<TListable>,\n options: { value: T }[],\n unknownValues: readonly T[],\n): T[] | null {\n return formattedValue.length === 0\n ? schema.typeInfo.nullable\n ? null\n : []\n : formattedValue.map((v) =>\n v.startsWith(\"-\") ? unknownValues[-+v - 1] : options[+v].value,\n );\n}\n\n/** Formats an array of selection values as an array of (string) option indices. */\nexport function formatSelectionValuesAsOptionIndices<T>(\n arrayValue: readonly T[] | null | undefined,\n options: { value: T }[],\n unknownValues: readonly T[],\n): string[] {\n return (\n arrayValue?.map((v) => {\n const idx = options.findIndex((option) => equals(option.value, v));\n return idx === -1\n ? (-unknownValues.findIndex((u) => equals(u, v)) - 1).toString()\n : idx.toString();\n }) ?? []\n );\n}\n\n/**\n * Transforms selection item objects into React nodes.\n *\n * @param items Item objects.\n * @returns React nodes representing the objects.\n */\nexport function selectionItemObjectsToNodes<T>(\n items: (SelectControlItemObject<T> | SelectControlItemGroupObject<T>)[],\n): JSX.Element[] {\n let optionIndex = 0;\n return items.map(({ key, ...optionOrGroup }, i) =>\n \"options\" in optionOrGroup ? (\n <OptionsGroup key={key ?? i} {...optionOrGroup}>\n {optionOrGroup.options.map(\n ({ key, value, text, ...optionProps }, i) => (\n <Option key={key ?? i} value={optionIndex++} {...optionProps}>\n {text ?? value?.toString() ?? \"\"}\n </Option>\n ),\n )}\n </OptionsGroup>\n ) : (\n <Option key={key ?? i} {...optionOrGroup} value={optionIndex++}>\n {optionOrGroup.text ?? optionOrGroup.value?.toString() ?? \"\"}\n </Option>\n ),\n );\n}\n","import type { ReactNode } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\n\n/** Properties of the unknown value component. */\nexport interface UnknownValueProps<T = unknown> {\n value?: T;\n /** Label shown when a value isn't one of the existing options. */\n label?: ReactNode;\n}\n\n/** Representation of an unknown value. */\nexport function UnknownValue<T = unknown>({\n value,\n label,\n}: UnknownValueProps<T>) {\n const [locale] = useLocale();\n label ??= locale.UnknownValue.label;\n\n const prefix = usePrefix();\n\n const valueStr = value == null ? \"\" : String(value);\n return (\n <>\n {valueStr && (\n <>\n “<span className={prefix(\"unknown-value\")}>{valueStr}</span>”\n </>\n )}\n {valueStr && label && <>&nbsp;</>}\n {label && (\n <span className={prefix(\"unknown-value__label\")}>({label})</span>\n )}\n </>\n );\n}\n","import type { CheckboxProps } from \"@ostack.tech/ui\";\nimport type { Key, ReactNode } from \"react\";\n\n/** @deprecated Use {@link CheckboxGroupControlItemObject} instead. */\nexport type CheckboxObject<T = unknown> = CheckboxGroupControlItemObject<T>;\n\n/** Checkbox group control item in object notation. */\nexport interface CheckboxGroupControlItemObject<T = unknown> extends Omit<\n CheckboxProps,\n \"defaultChecked\" | \"checked\" | \"value\" | \"children\"\n> {\n /** Item value. */\n value: T;\n /** Item's rendered text. */\n text?: ReactNode;\n /** Item's unique key. */\n key?: Key;\n}\n\n/** Properties of the checkbox group control item component. */\nexport interface CheckboxGroupControlItemProps<T = unknown> extends Omit<\n CheckboxGroupControlItemObject<T>,\n \"text\"\n> {\n /** Item's rendered text. */\n children?: ReactNode;\n}\n\n/**\n * Definition of a checkbox group control item.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `CheckboxGroupControl` component to automatically create the `options`\n * array.\n */\nexport function CheckboxGroupControlItem(\n _props: CheckboxGroupControlItemProps,\n) {\n return null;\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type Listable,\n type ListableInputController,\n type ListableInputOptions,\n useListableInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n Checkbox,\n CheckboxGroup,\n type CheckboxGroupProps,\n combineEventHandlers,\n FeedbackProvider,\n parseChildren,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport {\n formatSelectionValuesAsOptionIndices,\n getUnknownValues,\n parseSelectionValuesFromOptionIndices,\n} from \"../../utils/selectionTransformations.tsx\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { UnknownValue } from \"../UnknownValue\";\nimport {\n CheckboxGroupControlItem,\n type CheckboxGroupControlItemObject,\n} from \"./CheckboxGroupControlItem.tsx\";\n\n/** Properties of the checkbox group control component. */\nexport interface CheckboxGroupControlProps<\n T = unknown,\n TListable extends Listable<T> | null = Listable<T> | null,\n>\n extends\n Omit<\n ListableInputOptions<\n T,\n TListable,\n readonly T[] | null,\n ComponentRef<typeof CheckboxGroup>\n >,\n \"enabled\" | \"formatFromArray\" | \"parseToArray\"\n >,\n Omit<\n CheckboxGroupProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"children\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /** Checkbox group control options. */\n options?: CheckboxGroupControlItemObject<T>[];\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /** Label shown when a value of the control isn't one of the existing options. */\n unknownValueLabel?: ReactNode;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /** Checkbox group control children. */\n children?: ReactNode;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | ListableInputController<\n T,\n TListable,\n string[],\n ComponentRef<typeof CheckboxGroup>\n >\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The checkbox group control component is a KForm form control for values with\n * (possibly\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)\n * or\n * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)\n * and items of any type. It is built on top of the\n * [`CheckboxGroup`](/docs/ostack-ui-forms-checkbox-group--docs) component.\n *\n * It composes the following subcomponent:\n *\n * - `CheckboxGroupControlItem`: Component used to define an item of the checkbox\n * group control.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MinSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):\n * Sets the `minChecked` and/or `maxChecked` properties.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * CheckboxGroupControl,\n * CheckboxGroupControlItem,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function SpokenLanguagesControl() {\n * return (\n * <CheckboxGroupControl path=\"/spokenLanguages\">\n * <CheckboxGroupControlItem value=\"en\">\n * English\n * </CheckboxGroupControlItem>\n * <CheckboxGroupControlItem value=\"fr\">\n * French\n * </CheckboxGroupControlItem>\n * <CheckboxGroupControlItem value=\"pt\">\n * Portuguese\n * </CheckboxGroupControlItem>\n * <CheckboxGroupControlItem value=\"es\">\n * Spanish\n * </CheckboxGroupControlItem>\n * </CheckboxGroupControl>\n * );\n * }\n * ```\n */\nexport function CheckboxGroupControl<\n T = unknown,\n TListable extends Listable<T> | null = Listable<T> | null,\n>({\n path,\n options,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n unknownValueLabel,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n minChecked,\n maxChecked,\n loading,\n showSpinner,\n disabled,\n readOnly,\n endAdornment,\n onFocus,\n onBlurToOutside,\n children,\n debug,\n ref,\n ...otherProps\n}: CheckboxGroupControlProps<T, TListable>) {\n const [locale] = useLocale();\n unknownValueLabel ??= locale.SelectMultipleControl.unknownValueLabel;\n\n options ??= parseChildren(children, CheckboxGroupControlItem, {\n transformChildObject: ({ children, ...otherProps }) => ({\n text: children,\n ...otherProps,\n }),\n });\n\n const [arrayValue, setArrayValue] = useState<readonly T[] | null>(null);\n const unknownValues = useMemo(\n () => getUnknownValues(arrayValue, options),\n [options, arrayValue],\n );\n const formattedValue = useMemo(\n () =>\n formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues),\n [options, unknownValues, arrayValue],\n );\n const controller = useListableInput<\n T,\n TListable,\n readonly T[] | null,\n ComponentRef<typeof CheckboxGroup>\n >(path, {\n enabled: !useFormIsLoading(),\n parseToArray: useCallback(\n (formattedValue: readonly T[] | null) =>\n formattedValue && [...formattedValue],\n [],\n ),\n formatFromArray: useCallback(\n (arrayValue: readonly T[] | null) => arrayValue && [...arrayValue],\n [],\n ),\n setFormattedValue: setArrayValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const { restrictions } = schema.typeInfo;\n const absolutePath = usePath();\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<TListable, HTMLDivElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const { onChange: inputOnChange } = inputProps;\n const handleValueChange = useCallback(\n (formattedValue: string[]) => {\n const newValue = parseSelectionValuesFromOptionIndices(\n formattedValue,\n schema,\n options,\n unknownValues,\n );\n inputOnChange(newValue);\n setArrayValue(newValue);\n },\n [inputOnChange, options, schema, unknownValues],\n );\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedCheckboxGroupRef = useCombinedRef(\n inputProps.ref,\n autofocusRef,\n ref,\n );\n return (\n <FeedbackProvider>\n <CheckboxGroup\n value={formattedValue}\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n minChecked={\n minChecked ??\n (typeof restrictions.minSize === \"number\"\n ? restrictions.minSize\n : undefined)\n }\n maxChecked={\n maxChecked ??\n (typeof restrictions.maxSize === \"number\"\n ? restrictions.maxSize\n : undefined)\n }\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath} />\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedCheckboxGroupRef}\n >\n {/* Unknown values */}\n {unknownValues.map((v, i) => (\n <Checkbox key={i} value={-i - 1} status=\"invalid\">\n <UnknownValue value={v} label={unknownValueLabel} />\n </Checkbox>\n ))}\n {options.map(({ value, text, key, ...checkboxProps }, i) => (\n <Checkbox key={key ?? i} value={i} {...checkboxProps}>\n {text ?? value?.toString() ?? \"\"}\n </Checkbox>\n ))}\n </CheckboxGroup>\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import type { Schema } from \"@ostack.tech/kform\";\nimport {\n formatTemporalAsString,\n type Temporal,\n} from \"@ostack.tech/kform-react\";\nimport { addDays, max, min, parseISO } from \"date-fns\";\n\n/** Returns the minimum date allowed based on a temporal schema's restrictions. */\nexport function minDateRestriction<T extends Temporal | null>(\n schema: Schema<T>,\n): Date | undefined {\n const { restrictions } = schema.typeInfo;\n const min = temporalRestrictionToDate(restrictions.min, schema);\n const exclusiveMin = temporalRestrictionToDate(\n restrictions.exclusiveMin,\n schema,\n );\n const minFromMinExclusive = exclusiveMin && addDays(exclusiveMin, 1);\n return min != null && minFromMinExclusive != null\n ? max([min, minFromMinExclusive])\n : (min ?? minFromMinExclusive);\n}\n\n/** Returns the maximum date allowed based on a temporal schema's restrictions. */\nexport function maxDateRestriction<T extends Temporal | null>(\n schema: Schema<T>,\n): Date | undefined {\n const { restrictions } = schema.typeInfo;\n const max = temporalRestrictionToDate(restrictions.max, schema);\n const exclusiveMax = temporalRestrictionToDate(\n restrictions.exclusiveMax,\n schema,\n );\n const maxFromMaxExclusive = exclusiveMax && addDays(exclusiveMax, -1);\n return max != null && maxFromMaxExclusive != null\n ? min([max, maxFromMaxExclusive])\n : (max ?? maxFromMaxExclusive);\n}\n\n/** Transforms a temporal restriction in a JS date. */\nfunction temporalRestrictionToDate<T extends Temporal | null>(\n restriction: unknown,\n schema: Schema<T>,\n) {\n return restriction == null\n ? undefined\n : parseISO(formatTemporalAsString(restriction as T, schema));\n}\n","import type { Schema } from \"@ostack.tech/kform\";\nimport type { Temporal } from \"@ostack.tech/kform-react\";\nimport {\n type DateFormatterOptions,\n type DateParserOptions,\n type DateTransformerOptions,\n useDateTransformer,\n} from \"@ostack.tech/ui\";\nimport { format as fnsFormat, parseISO } from \"date-fns\";\nimport { useMemo } from \"react\";\n\n/** Temporal string transformer. */\nexport interface TemporalStringTransformer {\n /**\n * Function used to parse a formatted date as exposed by a date input as a\n * temporal string.\n */\n parse: <T extends Temporal | null = Temporal | null>(\n formattedDate: string,\n schema: Schema<T>,\n options?: DateParserOptions,\n ) => string;\n /**\n * Function used to format a temporal string as a string accepted by a date\n * input.\n */\n format: <T extends Temporal | null = Temporal | null>(\n temporalString: string,\n schema: Schema<T>,\n options?: DateFormatterOptions,\n ) => string;\n}\n\n/**\n * Hook exposing functions to transform a temporal string value from/into a\n * string representation of a date accepted by a date input.\n */\nexport function useTemporalStringTransformer(\n dateTransformerOptions?: DateTransformerOptions,\n): TemporalStringTransformer {\n const { format, parse } = useDateTransformer(dateTransformerOptions);\n\n return useMemo(\n () => ({\n parse: <T extends Temporal | null = Temporal | null>(\n formattedDate: string,\n schema: Schema<T>,\n options?: DateParserOptions,\n ) => {\n const date = parse(formattedDate, options);\n if (date === null) {\n return \"\";\n }\n\n const dateString = fnsFormat(date, \"yyyy-MM-dd\");\n switch (schema.typeInfo.name) {\n case \"Instant\":\n return `${dateString}T00:00:00.000Z`;\n case \"LocalDateTime\":\n return `${dateString}T00:00:00`;\n default: // `LocalDate` or JavaScript `Date`\n return dateString;\n }\n },\n format: <T extends Temporal | null = Temporal | null>(\n temporalString: string,\n _schema: Schema<T>,\n options?: DateFormatterOptions,\n ) => temporalString && format(parseISO(temporalString), options),\n }),\n [format, parse],\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type FormatterControllerState,\n type Temporal,\n type TemporalInputController,\n type TemporalInputOptions,\n useTemporalInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n DateInput,\n type DateInputProps,\n type DateValueRepresentations,\n FeedbackProvider,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useState,\n} from \"react\";\n\nimport {\n maxDateRestriction,\n minDateRestriction,\n} from \"../../utils/dateRestrictions.ts\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { useTemporalStringTransformer } from \"../../utils/useTemporalStringTransformer.ts\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\n\n/** Properties of the date control component. */\nexport interface DateControlProps<T extends Temporal | null = Temporal | null>\n extends\n Omit<\n TemporalInputOptions<T, string, ComponentRef<typeof DateInput>>,\n \"enabled\" | \"formatFromString\" | \"parseToString\"\n >,\n Omit<\n DateInputProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | TemporalInputController<T, string, ComponentRef<typeof DateInput>>\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The date control component is a KForm form control for values with (typically\n * nullable) schemas of type\n * [`LocalDateSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-local-date-schema/index.html)\n * or\n * [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).\n * It is built on top of the\n * [`DateInput`](/docs/ostack-ui-forms-date-input--docs) component.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Min`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min/index.html)/[`Max`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max/index.html)/[`ExclusiveMin`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-min/index.html)/[`ExclusiveMax`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-max/index.html):\n * Sets the `minDate`/`maxDate` properties.\n *\n * Example usage:\n *\n * ```tsx\n * import { DateControl } from \"@ostack.tech/ui-kform\";\n *\n * function ProjectDueDateControl() {\n * return <DateControl path=\"/dueDate\" />;\n * }\n * ```\n */\nexport function DateControl<T extends Temporal | null = Temporal | null>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n format: dateFormat,\n required,\n minDate,\n maxDate,\n loading,\n showSpinner,\n disabled,\n readOnly,\n onFocus,\n onBlurToOutside,\n endAdornment,\n debug,\n ref,\n ...otherProps\n}: DateControlProps<T>) {\n const { format, parse } = useTemporalStringTransformer({\n format: dateFormat,\n });\n\n const [formattedValue, setFormattedValue] = useState(\"\");\n const controller = useTemporalInput<\n T,\n string,\n ComponentRef<typeof DateInput>\n >(path, {\n enabled: !useFormIsLoading(),\n parseToString: useCallback(\n (formattedValue: string, state: FormatterControllerState<T, string>) =>\n parse(formattedValue, state.schema),\n [parse],\n ),\n formatFromString: useCallback(\n (temporalString: string, state: FormatterControllerState<T, string>) =>\n format(temporalString, state.schema),\n [format],\n ),\n setFormattedValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLInputElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const handleValueChange = useCallback(\n ({ formattedValue }: DateValueRepresentations) => {\n setFormattedValue(formattedValue);\n inputProps.onChange(formattedValue);\n },\n [inputProps],\n );\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedDateInputRef = useCombinedRef(\n inputProps.ref,\n autofocusRef,\n ref,\n );\n return (\n <FeedbackProvider>\n <DateInput\n value={formattedValue}\n name={inputProps.name}\n format={dateFormat}\n required={required ?? restrictions.required === true}\n minDate={minDate ?? minDateRestriction(schema)}\n maxDate={maxDate ?? maxDateRestriction(schema)}\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedDateInputRef}\n />\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type FormatterControllerState,\n type Temporal,\n type TemporalInputController,\n type TemporalInputOptions,\n useTemporalInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n DateRangeInput,\n type DateRangeInputProps,\n type DateRangeValueRepresentations,\n FeedbackProvider,\n type FormattedRange,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport { type ReactNode, type Ref, useCallback, useState } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport {\n maxDateRestriction,\n minDateRestriction,\n} from \"../../utils/dateRestrictions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { useTemporalStringTransformer } from \"../../utils/useTemporalStringTransformer.ts\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\n\n/** Properties of the date-range control component. */\nexport interface DateRangeControlProps<\n TStart extends Temporal | null = Temporal | null,\n TEnd extends Temporal | null = TStart,\n> extends Omit<\n DateRangeInputProps,\n \"defaultValue\" | \"value\" | \"validate\" | \"validationMode\"\n> {\n /** Path to the start value. */\n startPath: string | Path;\n /** Path to the end value. */\n endPath: string | Path;\n /**\n * Issue messages of this control's start.\n *\n * Mapping from an issue's code to its message.\n */\n startIssueMessages?: IssueMessagesByCode;\n /**\n * Issue messages of this control's end.\n *\n * Mapping from an issue's code to its message.\n */\n endIssueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Label suffix to use in the issues panel when displaying issues associated\n * with this field's start date.\n */\n issuesPanelStartLabelSuffix?: ReactNode;\n /**\n * Label suffix to use in the issues panel when displaying issues associated\n * with this field's end date.\n */\n issuesPanelEndLabelSuffix?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the start control's API. */\n startApiRef?: Ref<TemporalInputController<TStart> | undefined>;\n /** Reference to the end control's API. */\n endApiRef?: Ref<TemporalInputController<TEnd> | undefined>;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n onStartInitialized?: TemporalInputOptions<TStart>[\"onInitialized\"];\n onStartFormManagerEvent?: TemporalInputOptions<TStart>[\"onFormManagerEvent\"];\n onStartValueChange?: TemporalInputOptions<TStart>[\"onValueChange\"];\n onStartValidationStatusChange?: TemporalInputOptions<TStart>[\"onValidationStatusChange\"];\n onStartDisplayStatusChange?: TemporalInputOptions<TStart>[\"onDisplayStatusChange\"];\n onStartDirtyStatusChange?: TemporalInputOptions<TStart>[\"onDirtyStatusChange\"];\n onStartTouchedStatusChange?: TemporalInputOptions<TStart>[\"onTouchedStatusChange\"];\n onEndInitialized?: TemporalInputOptions<TEnd>[\"onInitialized\"];\n onEndFormManagerEvent?: TemporalInputOptions<TEnd>[\"onFormManagerEvent\"];\n onEndValueChange?: TemporalInputOptions<TEnd>[\"onValueChange\"];\n onEndValidationStatusChange?: TemporalInputOptions<TEnd>[\"onValidationStatusChange\"];\n onEndDisplayStatusChange?: TemporalInputOptions<TEnd>[\"onDisplayStatusChange\"];\n onEndDirtyStatusChange?: TemporalInputOptions<TEnd>[\"onDirtyStatusChange\"];\n onEndTouchedStatusChange?: TemporalInputOptions<TEnd>[\"onTouchedStatusChange\"];\n}\n\n/**\n * The date-range control component is a KForm form control for pairs of values\n * (start and end dates) with (typically nullable) schemas of type\n * [`LocalDateSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-local-date-schema/index.html)\n * or\n * [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).\n * It is built on top of the\n * [`DateRangeInput`](/docs/ostack-ui-forms-date-range-input--docs) component.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Min`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min/index.html)/[`Max`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max/index.html)/[`ExclusiveMin`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-min/index.html)/[`ExclusiveMax`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-max/index.html):\n * Sets the `minDate`/`maxDate` properties.\n *\n * Example usage:\n *\n * ```tsx\n * import { DateRangeControl } from \"@ostack.tech/ui-kform\";\n *\n * function ReservationDatesControl() {\n * return (\n * <DateRangeControl startPath=\"/checkInDate\" endPath=\"/checkOutDate\" />\n * );\n * }\n * ```\n */\nexport function DateRangeControl<\n TStart extends Temporal | null = Temporal | null,\n TEnd extends Temporal | null = TStart,\n>({\n startPath,\n endPath,\n startIssueMessages,\n endIssueMessages,\n issuesPanelLabel,\n issuesPanelStartLabelSuffix,\n issuesPanelEndLabelSuffix,\n displayIssues = true,\n preventAutoFocus,\n startApiRef,\n endApiRef,\n issueMessagesProps,\n required,\n minDate,\n maxDate,\n loading,\n showSpinners = loading,\n showStartSpinner = showSpinners,\n showEndSpinner = showSpinners,\n disabled,\n readOnly,\n startInputProps,\n endInputProps,\n onStartInitialized,\n onStartFormManagerEvent,\n onStartValueChange,\n onStartValidationStatusChange,\n onStartDisplayStatusChange,\n onStartDirtyStatusChange,\n onStartTouchedStatusChange,\n onEndInitialized,\n onEndFormManagerEvent,\n onEndValueChange,\n onEndValidationStatusChange,\n onEndDisplayStatusChange,\n onEndDirtyStatusChange,\n onEndTouchedStatusChange,\n onValueChange,\n format: dateFormat,\n onBlurToOutside,\n startMiddleAdornment,\n endAdornment,\n debug,\n ...otherProps\n}: DateRangeControlProps<TStart, TEnd>) {\n const [locale] = useLocale();\n issuesPanelStartLabelSuffix ??=\n locale.DateRangeControl.issuesPanelStartLabelSuffix;\n issuesPanelEndLabelSuffix ??=\n locale.DateRangeControl.issuesPanelEndLabelSuffix;\n\n const { format, parse } = useTemporalStringTransformer({\n format: dateFormat,\n });\n\n const [formattedValue, setFormattedValue] = useState<FormattedRange>({\n start: \"\",\n end: \"\",\n });\n const parseToString = useCallback(\n (\n formattedValue: string,\n state: FormatterControllerState<TStart | TEnd, string>,\n ) => parse(formattedValue, state.schema),\n [parse],\n );\n const formatFromString = useCallback(\n (\n stringValue: string,\n state: FormatterControllerState<TStart | TEnd, string>,\n ) => format(stringValue, state.schema),\n [format],\n );\n const formIsLoading = useFormIsLoading();\n const startController = useTemporalInput<TStart, string>(startPath, {\n enabled: !formIsLoading,\n parseToString,\n formatFromString,\n setFormattedValue: useCallback(\n (formattedValue: string) =>\n setFormattedValue(({ end }) => ({ start: formattedValue, end })),\n [],\n ),\n onInitialized: onStartInitialized,\n onFormManagerEvent: onStartFormManagerEvent,\n onValueChange: onStartValueChange,\n onValidationStatusChange: onStartValidationStatusChange,\n onDisplayStatusChange: onStartDisplayStatusChange,\n onDirtyStatusChange: onStartDirtyStatusChange,\n onTouchedStatusChange: onStartTouchedStatusChange,\n });\n const endController = useTemporalInput<TEnd, string, HTMLInputElement>(\n endPath,\n {\n enabled: !formIsLoading,\n parseToString,\n formatFromString,\n setFormattedValue: useCallback(\n (formattedValue: string) =>\n setFormattedValue(({ start }) => ({ start, end: formattedValue })),\n [],\n ),\n onInitialized: onEndInitialized,\n onFormManagerEvent: onEndFormManagerEvent,\n onValueChange: onEndValueChange,\n onValidationStatusChange: onEndValidationStatusChange,\n onDisplayStatusChange: onEndDisplayStatusChange,\n onDirtyStatusChange: onEndDirtyStatusChange,\n onTouchedStatusChange: onEndTouchedStatusChange,\n },\n );\n const { inputProps: startControllerInputProps } = startController;\n const startSchema = startController.useSchema();\n const startAbsolutePath = startController.usePath();\n const { restrictions: startRestrictions } = startSchema.typeInfo;\n const { inputProps: endControllerInputProps } = endController;\n const endSchema = endController.useSchema();\n const endAbsolutePath = endController.usePath();\n const { restrictions: endRestrictions } = endSchema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the start control\n const {\n displayLoading: displayStartLoading,\n displayDisabled: displayStartDisabled,\n displayReadOnly: displayStartReadOnly,\n displayStatusToDisplay: startDisplayStatusToDisplay,\n displayValidating: displayStartValidating,\n issuesToDisplay: startIssuesToDisplay,\n autofocusRef: startAutofocusRef,\n handleFocus: handleStartFocus,\n } = useRegisterControl<TStart, HTMLInputElement>({\n controller: startController,\n issuesPanelLabel,\n ariaLabel: startInputProps?.[\"aria-label\"],\n issuesPanelLabelSuffix: issuesPanelStartLabelSuffix,\n preventAutoFocus,\n apiRef: startApiRef,\n });\n // Register the end control\n const {\n displayLoading: displayEndLoading,\n displayDisabled: displayEndDisabled,\n displayReadOnly: displayEndReadOnly,\n displayStatusToDisplay: endDisplayStatusToDisplay,\n displayValidating: displayEndValidating,\n issuesToDisplay: endIssuesToDisplay,\n autofocusRef: endAutofocusRef,\n handleFocus: handleEndFocus,\n } = useRegisterControl<TEnd, HTMLInputElement>({\n controller: endController,\n issuesPanelLabel,\n ariaLabel: endInputProps?.[\"aria-label\"],\n issuesPanelLabelSuffix: issuesPanelEndLabelSuffix,\n preventAutoFocus,\n apiRef: endApiRef,\n });\n\n const handleValueChange = useCallback(\n ({ formattedValue: newFormattedValue }: DateRangeValueRepresentations) => {\n setFormattedValue(newFormattedValue);\n if (newFormattedValue.start !== formattedValue.start) {\n startControllerInputProps.onChange(newFormattedValue.start);\n }\n if (newFormattedValue.end !== formattedValue.end) {\n endControllerInputProps.onChange(newFormattedValue.end);\n }\n },\n [\n endControllerInputProps,\n formattedValue.end,\n formattedValue.start,\n startControllerInputProps,\n ],\n );\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: {\n [startAbsolutePath.toString()]: startIssuesToDisplay,\n [endAbsolutePath.toString()]: endIssuesToDisplay,\n },\n issueMessages: {\n [startAbsolutePath.toString()]: startIssueMessages,\n [endAbsolutePath.toString()]: endIssueMessages,\n },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n return (\n <FeedbackProvider>\n <DateRangeInput\n value={formattedValue}\n format={dateFormat}\n required={\n required ??\n (startRestrictions.required === true ||\n endRestrictions.required === true)\n }\n minDate={minDate ?? minDateRestriction(startSchema)}\n maxDate={maxDate ?? maxDateRestriction(endSchema)}\n loading={displayStartLoading || displayEndLoading || loading}\n showStartSpinner={displayStartValidating || showStartSpinner}\n showEndSpinner={displayEndValidating || showEndSpinner}\n disabled={\n (displayStartDisabled && displayEndDisabled) ||\n disabled ||\n (startInputProps?.disabled && endInputProps?.disabled)\n }\n readOnly={\n (displayStartReadOnly && displayEndReadOnly) ||\n readOnly ||\n (startInputProps?.readOnly && endInputProps?.readOnly)\n }\n status={\n startDisplayStatusToDisplay === \"error\" ||\n endDisplayStatusToDisplay === \"error\"\n ? \"invalid\"\n : startDisplayStatusToDisplay === \"warning\" ||\n endDisplayStatusToDisplay === \"warning\"\n ? \"warned\"\n : undefined\n }\n onValueChange={combineEventHandlers(onValueChange, handleValueChange)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n combineEventHandlers(\n startControllerInputProps.onBlur,\n endControllerInputProps.onBlur,\n ),\n )}\n startInputProps={{\n name: startControllerInputProps.name,\n ...startInputProps,\n disabled: displayStartDisabled || startInputProps?.disabled,\n readOnly: displayStartReadOnly || startInputProps?.readOnly,\n onFocus: combineEventHandlers(\n startInputProps?.onFocus,\n handleStartFocus,\n ),\n ref: useCombinedRef(\n startControllerInputProps?.ref,\n useCombinedRef(startAutofocusRef, startInputProps?.ref),\n ),\n }}\n endInputProps={{\n name: endControllerInputProps.name,\n ...endInputProps,\n disabled: displayEndDisabled || endInputProps?.disabled,\n readOnly: displayEndReadOnly || endInputProps?.readOnly,\n onFocus: combineEventHandlers(endInputProps?.onFocus, handleEndFocus),\n ref: useCombinedRef(\n endControllerInputProps?.ref,\n useCombinedRef(endAutofocusRef, endInputProps?.ref),\n ),\n }}\n startMiddleAdornment={\n <>\n {startMiddleAdornment}\n\n {/* Start debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<TStart> path={startAbsolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* End debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<TEnd> path={endAbsolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n {...otherProps}\n />\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import { faDownload } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n ControlAddon,\n Icon,\n Tooltip,\n usePrintClassNames,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, useMemo } from \"react\";\n\n/** Properties of the file control download addon. */\nexport interface FileControlDownloadAddonProps {\n file: File;\n label: ReactNode;\n}\n\n/** Control addon used to download a file. */\nexport function FileControlDownloadAddon({\n file,\n label,\n}: FileControlDownloadAddonProps) {\n const { printHidden } = usePrintClassNames();\n const dataURL = useMemo(() => URL.createObjectURL(file), [file]);\n\n return (\n <Tooltip content={label}>\n <ControlAddon\n as=\"a\"\n className={printHidden}\n href={dataURL}\n download={file.name}\n >\n <Icon icon={faDownload} />\n </ControlAddon>\n </Tooltip>\n );\n}\n","import { faDownload, faFileLines } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n Alert,\n ControlAddon,\n Dialog,\n DialogBody,\n DialogContent,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n Icon,\n IconButton,\n Tooltip,\n usePrintClassNames,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, useMemo } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\n\n/** Properties of the file control view addon. */\nexport interface FileControlViewAddonProps {\n file: File;\n viewLabel: ReactNode;\n downloadLabel: ReactNode;\n fallbackText: ReactNode;\n}\n\n/** Control addon used to view a file. */\nexport function FileControlViewAddon({\n file,\n viewLabel,\n downloadLabel,\n fallbackText,\n}: FileControlViewAddonProps) {\n const prefix = usePrefix();\n const { printHidden } = usePrintClassNames();\n const dataURL = useMemo(() => URL.createObjectURL(file), [file]);\n\n return (\n <Dialog>\n <Tooltip content={viewLabel}>\n <DialogTrigger>\n <ControlAddon as=\"button\" className={printHidden}>\n <Icon icon={faFileLines} />\n </ControlAddon>\n </DialogTrigger>\n </Tooltip>\n\n <DialogContent\n variant=\"subtle\"\n className={prefix(\"file-control__viewer-dialog\")}\n aria-describedby={undefined}\n >\n <DialogHeader>\n <DialogTitle className={prefix(\"file-control__viewer-dialog-title\")}>\n {file.name}\n </DialogTitle>\n\n {/* Download file */}\n <IconButton\n variant=\"ghost\"\n className={prefix(\"file-control__viewer-download\")}\n asChild\n icon={faDownload}\n label={downloadLabel}\n >\n <a href={dataURL} download={file.name} />\n </IconButton>\n </DialogHeader>\n\n <DialogBody className={prefix(\"file-control__viewer-dialog-body\")}>\n {/* File viewer */}\n <object\n className={prefix(\"file-control__viewer-object\")}\n type={file.type || undefined}\n data={dataURL}\n aria-label={file.name}\n >\n <Alert\n className={prefix(\"file-control__viewer-fallback\")}\n severity=\"warning\"\n >\n {fallbackText}\n </Alert>\n </object>\n </DialogBody>\n </DialogContent>\n </Dialog>\n );\n}\n","import type { File as KFormFile, Path } from \"@ostack.tech/kform\";\nimport {\n type FileInputController,\n type FileInputOptions,\n toFileList,\n useFileInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n Input,\n type InputProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ChangeEvent,\n type ComponentRef,\n type KeyboardEvent,\n type ReactNode,\n type Ref,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { FileControlDownloadAddon } from \"./FileControlDownloadAddon.tsx\";\nimport { FileControlViewAddon } from \"./FileControlViewAddon.tsx\";\n\n/**\n * File control's interaction with the selected file:\n *\n * - `view`: A button is added which opens a dialog to view and optionally\n * download the file. A fallback alert is displayed when the file cannot be\n * viewed.\n * - `download`: A button is added to download the file. Useful if you know that\n * the accepted file types aren't viewable in the browser.\n * - `none`: No interaction with the selected file is added.\n */\nexport type FileControlFileInteraction = \"view\" | \"download\" | \"none\";\n\n/** Properties of the file control component. */\nexport interface FileControlProps<T extends KFormFile | null = KFormFile | null>\n extends\n Omit<\n FileInputOptions<T, File | null, ComponentRef<typeof Input>>,\n \"enabled\" | \"formatFromJsFile\" | \"parseToJsFile\"\n >,\n Omit<\n InputProps,\n // TODO: Support `multiple`\n | \"type\"\n | \"multiple\"\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"status\"\n | \"align\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n FileInputController<T, File | null, ComponentRef<typeof Input>> | undefined\n >;\n /**\n * Type of interaction with the selected file.\n *\n * @default view\n */\n fileInteraction?: FileControlFileInteraction;\n /** Label of the button used to open the file viewer. */\n viewFileButtonLabel?: ReactNode;\n /** Label of the button used to download the file. */\n downloadFileButtonLabel?: ReactNode;\n /** Text displayed when the file cannot be viewed. */\n fallbackText?: ReactNode;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The file control component is a KForm form control for values with (typically\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`FileSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-file-schema/index.html).\n * It is built on top of the [`Input`](/docs/ostack-ui-forms-input--docs)\n * component.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Accepts`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-accepts/index.html):\n * Sets the `accept` property.\n *\n * Example usage:\n *\n * ```tsx\n * import { FileControl } from \"@ostack.tech/ui-kform\";\n *\n * function IdProofControl() {\n * return <FileControl path=\"/idProof\" />;\n * }\n * ```\n */\nexport function FileControl<T extends KFormFile | null = KFormFile | null>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n fileInteraction = \"view\",\n viewFileButtonLabel,\n downloadFileButtonLabel,\n fallbackText,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n accept,\n loading,\n showSpinner,\n disabled,\n readOnly,\n showClearButton,\n clearDescription,\n endAdornment,\n onChange,\n onKeyDown,\n onFocus,\n onBlurToOutside,\n debug,\n clearButtonProps,\n ref,\n ...otherProps\n}: FileControlProps<T>) {\n const [locale] = useLocale();\n clearDescription ??= locale.FileControl.clearDescription;\n viewFileButtonLabel ??= locale.FileControl.viewFileButtonLabel;\n downloadFileButtonLabel ??= locale.FileControl.downloadFileButtonLabel;\n fallbackText ??= locale.FileControl.fallbackText;\n\n // Keep track of the latest file to work around some browsers clearing the\n // input on \"cancel\"\n const latestFile = useRef<File | null>(null);\n const [file, setFile] = useState<File | null>(null);\n const controller = useFileInput<T, File | null, ComponentRef<typeof Input>>(\n path,\n {\n enabled: !useFormIsLoading(),\n formManager,\n formatFromJsFile: useCallback((fileValue: File | null) => {\n setFile(fileValue);\n latestFile.current = fileValue;\n return fileValue;\n }, []),\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n },\n );\n const { useSchema, usePath, inputProps } = controller;\n const { nullable, restrictions } = useSchema().typeInfo;\n const absolutePath = usePath();\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLInputElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n showClearButton ??= nullable ? file !== null : false;\n // Prevent browsers from clearing the input on \"cancel\" by undoing clearings\n // that didn't originate from a click on the clear button or via\n // delete/backspace. This undoing is done by setting the input's `files` to\n // the latest seen file.\n const isClearing = useRef(false);\n const handleClearButtonClick = useCallback(() => {\n isClearing.current = true;\n }, []);\n const handleChange = useCallback(\n (evt: ChangeEvent<HTMLInputElement>) => {\n if (evt.target.files!.length > 0 || isClearing.current) {\n isClearing.current = false;\n onChange?.(evt);\n inputProps.onChange(evt);\n } else {\n evt.target.files = toFileList(latestFile.current);\n }\n },\n [inputProps, onChange],\n );\n\n // Clear file when pressing 'Delete' or 'Backspace'\n const clearButtonRef = useRef<HTMLButtonElement | null>(null);\n const handleKeyDown = useCallback((evt: KeyboardEvent) => {\n if (evt.code === \"Delete\" || evt.code === \"Backspace\") {\n clearButtonRef.current?.click();\n }\n }, []);\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n });\n\n const combinedInputRef = useCombinedRef(inputProps.ref, autofocusRef, ref);\n return (\n <FeedbackProvider>\n <Input\n type=\"file\"\n name={inputProps.name}\n required={required ?? restrictions.required == true}\n accept={\n accept ??\n (Array.isArray(restrictions.acceptedFileTypes)\n ? restrictions.acceptedFileTypes.join()\n : undefined)\n }\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n showClearButton={showClearButton}\n clearDescription={clearDescription}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n onChange={handleChange}\n onKeyDown={combineEventHandlers(\n onKeyDown,\n // eslint-disable-next-line react-hooks/refs\n handleKeyDown,\n { checkDefaultPrevented: true },\n )}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n clearButtonProps={{\n ...clearButtonProps,\n onClick: combineEventHandlers(\n clearButtonProps?.onClick,\n // eslint-disable-next-line react-hooks/refs\n handleClearButtonClick,\n ),\n ref: useCombinedRef(clearButtonProps?.ref, clearButtonRef),\n }}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* View file adornment */}\n {fileInteraction === \"view\" && file && (\n <FileControlViewAddon\n file={file}\n viewLabel={viewFileButtonLabel}\n downloadLabel={downloadFileButtonLabel}\n fallbackText={fallbackText}\n />\n )}\n\n {/* File download adornment */}\n {fileInteraction === \"download\" && file && (\n <FileControlDownloadAddon\n file={file}\n label={downloadFileButtonLabel}\n />\n )}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n {...otherProps}\n ref={combinedInputRef}\n />\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import {\n AbsolutePath,\n type DisplayStatus,\n type Path,\n type SealedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport {\n computed,\n useConstant,\n useLatestRef,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport {\n createContext,\n type ReactNode,\n startTransition,\n useCallback,\n useContext,\n useEffect,\n} from \"react\";\nimport { createStore, useStore } from \"zustand\";\nimport { subscribeWithSelector } from \"zustand/middleware\";\n\nimport { useActivePathContext } from \"../../providers/ActivePathProvider\";\nimport { mostSpecificPath } from \"../../utils/mostSpecificPath.ts\";\nimport { useOnPathFocus } from \"../FormApp\";\nimport { useSetLatestInteraction } from \"../FormApp/FormAppContext.ts\";\nimport type { FormPageObject } from \"./FormPage.tsx\";\nimport type { FormPagesProps } from \"./FormPages.tsx\";\n\n/** Value of the form pages context. */\nexport type FormPagesContextValue = FormPagesStore;\n\n/** Resolved form page object. */\nexport interface ResolvedFormPageObject extends FormPageObject {\n path: AbsolutePath;\n}\n\n/** Form page state. */\nexport interface FormPageState {\n path: AbsolutePath;\n exists: boolean;\n deferredDisplayStatus: DisplayStatus | undefined;\n deferredIssuesToDisplay: SealedValidationIssue[];\n title?: ReactNode;\n documentTitle?: string | null;\n code?: ReactNode;\n visuallyHiddenCodePrefix?: ReactNode;\n}\n\n/** State of the form pages. */\nexport interface FormPagesState {\n pages: ResolvedFormPageObject[];\n activePage: AbsolutePath | null;\n activePageIndex: () => number;\n // State below is wrapped in an array in order to trigger state updates by\n // simply changing the identity of the wrapper without creating new object\n // instances\n pageStates: [Record<string, FormPageState | null>];\n pageHeaderHeights: [Map<string, number>];\n navigationSelectHeight: number;\n actions: FormPagesActions;\n}\n\n/** Actions of the form pages. */\nexport interface FormPagesActions {\n getPageState: (path: AbsolutePath) => FormPageState | null;\n setPages: (pages: ResolvedFormPageObject[]) => void;\n setActivePage: (activePage: string | Path | null) => void;\n updateActivePage: (oldActivePageIndex: number) => void;\n registerPageState: (path: AbsolutePath, state: FormPageState) => void;\n setPageHeaderHeight: (path: AbsolutePath, height: number | null) => void;\n}\n\n/** Form pages store. */\nexport type FormPagesStore = ReturnType<typeof useCreateFormPagesContext>;\n\n/** Form pages context. */\nexport const FormPagesContext = createContext<FormPagesContextValue | null>(\n null,\n);\n\n/** Options used to create the form pages context. */\nexport interface UseCreateFormPagesContextOptions extends Pick<\n FormPagesProps,\n \"defaultActivePage\" | \"activePage\" | \"onActivePageChange\"\n> {\n basePath: AbsolutePath;\n resolvedPages: ResolvedFormPageObject[];\n}\n\n/** Hook used to create the form pages context. */\nexport function useCreateFormPagesContext({\n basePath,\n resolvedPages,\n defaultActivePage,\n activePage,\n onActivePageChange,\n}: UseCreateFormPagesContextOptions) {\n const setLatestInteraction = useSetLatestInteraction();\n const { activePath, onActivePathChange } = useActivePathContext();\n activePage ??= activePath;\n\n const latestRef = useLatestRef({\n printing: usePrinting(),\n onActivePathChange,\n onActivePageChange,\n });\n const store = useConstant(() =>\n createStore<FormPagesState>()(\n subscribeWithSelector((set, get) => ({\n pages: resolvedPages,\n activePage:\n activePage === undefined\n ? defaultActivePage == null\n ? null\n : basePath.resolve(defaultActivePage)\n : activePage === null\n ? null\n : basePath.resolve(activePage),\n activePageIndex: computed(\n () => [get().pages, get().activePage],\n (pages, activePage) =>\n activePage === null\n ? -1\n : pages.findIndex((page) => page.path.equals(activePage)),\n ),\n pageStates: [{}],\n pageHeaderHeights: [new Map()],\n navigationSelectHeight: 0,\n actions: {\n getPageState: (path) => get().pageStates[0][path.toString()] ?? null,\n setPages: (pages) => {\n const oldActivePageIndex = get().activePageIndex();\n const newPageStates: Record<string, FormPageState | null> = {};\n for (const page of pages) {\n newPageStates[page.path.toString()] = get().actions.getPageState(\n page.path,\n );\n }\n set({ pages, pageStates: [newPageStates] });\n get().actions.updateActivePage(oldActivePageIndex);\n },\n setActivePage: (path: string | Path | null) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const newActivePage =\n path === null || path instanceof AbsolutePath\n ? path\n : new AbsolutePath(path);\n const oldActivePage = get().activePage;\n if (!oldActivePage?.equals(newActivePage)) {\n startTransition(() => {\n set({ activePage: newActivePage });\n if (newActivePage != null) {\n setLatestInteraction(newActivePage);\n }\n latestRef.current.onActivePathChange(newActivePage);\n latestRef.current.onActivePageChange?.(newActivePage);\n });\n }\n },\n updateActivePage: (oldActivePageIndex: number) => {\n if (\n latestRef.current.printing ||\n (get().activePage !== null &&\n get().pages.some((page) => page.path.equals(get().activePage)))\n ) {\n return;\n }\n\n get().actions.setActivePage(\n get().pages[\n Math.max(\n 0,\n Math.min(oldActivePageIndex, get().pages.length - 1),\n )\n ]?.path ?? null,\n );\n },\n registerPageState: (path, state) => {\n const oldActivePageIndex = get().activePageIndex();\n const pageStates = get().pageStates[0];\n pageStates[path.toString()] = state;\n set({ pageStates: [pageStates] });\n get().actions.updateActivePage(oldActivePageIndex);\n },\n setPageHeaderHeight: (path, height) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const {\n pageHeaderHeights: [pageHeaderHeights],\n } = get();\n if (height != null) {\n pageHeaderHeights.set(path.toString(), height);\n } else {\n pageHeaderHeights.delete(path.toString());\n }\n set({ pageHeaderHeights: [pageHeaderHeights] });\n },\n },\n })),\n ),\n );\n\n // Update store when params change\n useEffect(() => {\n store.getState().actions.setPages(resolvedPages);\n if (activePage !== undefined) {\n const { pages, activePage: oldActivePage } = store.getState();\n store.getState().actions.setActivePage(\n mostSpecificPath(\n activePage === null ? null : basePath.resolve(activePage),\n pages.map((page) => page.path),\n oldActivePage,\n ) ?? null,\n );\n }\n }, [resolvedPages, activePage, basePath, store]);\n\n // Set (possibly new) active page when focused path changes\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n const { pages, activePage, actions } = store.getState();\n actions.setActivePage(\n mostSpecificPath(\n focusedPath,\n pages.map((page) => page.path),\n activePage,\n ) ?? null,\n );\n },\n [store],\n ),\n );\n\n return store;\n}\n\nexport function useFormPagesContext(): FormPagesContextValue {\n const formPagesContext = useContext(FormPagesContext);\n if (!formPagesContext) {\n throw new Error(\"Form pages context not in scope.\");\n }\n return formPagesContext;\n}\n\nexport function useFormPageState<T>(\n path: AbsolutePath,\n selector: (state: FormPageState | null) => T,\n): T {\n return useStore(useFormPagesContext(), (state) =>\n selector(state.actions.getPageState(path)),\n );\n}\n","import { faCircleQuestion } from \"@fortawesome/free-solid-svg-icons\";\nimport { useCurrentPath } from \"@ostack.tech/kform-react\";\nimport {\n boolDataAttr,\n controlStatusToAccent,\n cx,\n IconButton,\n Layer,\n Popover,\n PopoverContent,\n PopoverTrigger,\n Stack,\n usePrinting,\n VisuallyHidden,\n} from \"@ostack.tech/ui\";\nimport type { ComponentProps } from \"react\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useIssuesDisplayMode } from \"../FormApp\";\nimport { IssueMessages } from \"../IssueMessages\";\nimport { IssuesPopover } from \"../IssuesPopover\";\nimport type { FormPageProps } from \"./FormPage.tsx\";\nimport { useFormPageState } from \"./FormPagesContext.ts\";\n\n/** Properties of the form page header. */\nexport interface FormPageHeaderProps\n extends\n ComponentProps<\"div\">,\n Pick<\n FormPageProps,\n | \"helperText\"\n | \"helperButtonLabel\"\n | \"ownIssueMessages\"\n | \"codeProps\"\n | \"titleProps\"\n | \"headerPopoverContainerProps\"\n | \"issuesPopoverProps\"\n | \"issueMessagesProps\"\n | \"helperButtonProps\"\n | \"helperPopoverProps\"\n | \"helperPopoverContentProps\"\n > {}\n\n/** Form page header. */\nexport function FormPageHeader({\n helperText,\n helperButtonLabel,\n ownIssueMessages,\n codeProps,\n titleProps,\n headerPopoverContainerProps,\n issuesPopoverProps,\n issueMessagesProps,\n helperButtonProps,\n helperPopoverProps,\n helperPopoverContentProps,\n className,\n ...otherProps\n}: FormPageHeaderProps) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n const printing = usePrinting();\n const currentPath = useCurrentPath();\n const issuesDisplayMode = useIssuesDisplayMode();\n\n const deferredIssuesToDisplay =\n useFormPageState(\n currentPath,\n useShallow(\n (state) =>\n (!printing &&\n issuesDisplayMode === \"inline\" &&\n state?.deferredIssuesToDisplay) ||\n [],\n ),\n ) ?? [];\n const deferredDisplayStatus = useFormPageState(currentPath, (state) =>\n printing ? undefined : state?.deferredDisplayStatus,\n );\n const code = useFormPageState(currentPath, (state) => state?.code);\n const title = useFormPageState(currentPath, (state) => state?.title);\n const visuallyHiddenCodePrefix = useFormPageState(\n currentPath,\n (state) =>\n state?.visuallyHiddenCodePrefix ??\n locale.FormPage.visuallyHiddenCodePrefix,\n );\n\n return (\n <Layer zIndex={[\"sticky\", -2]}>\n <div\n className={cx(prefix(\"form-pages__page-header\"), className)}\n {...otherProps}\n data-has-popovers={boolDataAttr(\n helperText != null || deferredIssuesToDisplay.length > 0,\n )}\n >\n {/* Form page title */}\n <h2\n tabIndex={-1}\n {...titleProps}\n className={cx(\n prefix(\"form-pages__page-title\"),\n titleProps?.className,\n )}\n >\n {/* Form page code */}\n <span\n {...codeProps}\n className={cx(\n prefix(\"form-pages__page-code\"),\n codeProps?.className,\n )}\n data-status={displayStatusToControlStatus(deferredDisplayStatus)}\n data-accent={controlStatusToAccent(\n displayStatusToControlStatus(deferredDisplayStatus),\n )}\n >\n {code != null && typeof code !== \"boolean\" && (\n <>\n {visuallyHiddenCodePrefix && (\n <VisuallyHidden>{visuallyHiddenCodePrefix} </VisuallyHidden>\n )}\n {code}\n <VisuallyHidden>, </VisuallyHidden>\n </>\n )}\n </span>\n\n {title}\n </h2>\n\n {/* Form page issues */}\n {!printing && (\n <Stack\n direction=\"row\"\n gap={0}\n {...headerPopoverContainerProps}\n className={cx(\n prefix(\"form-pages__page-header-popovers\"),\n headerPopoverContainerProps?.className,\n )}\n >\n {issuesDisplayMode === \"inline\" && (\n <IssuesPopover\n side=\"bottom\"\n {...issuesPopoverProps}\n iconButtonProps={{\n className: cx(\n prefix(\"form-pages__page-issues-popover-button\"),\n issuesPopoverProps?.iconButtonProps?.className,\n ),\n ...issuesPopoverProps?.iconButtonProps,\n }}\n >\n <IssueMessages\n issues={deferredIssuesToDisplay}\n messages={ownIssueMessages}\n {...issueMessagesProps}\n />\n </IssuesPopover>\n )}\n\n {/* Form page helper text */}\n {helperText && (\n <Popover modal={false} {...helperPopoverProps}>\n <PopoverTrigger>\n <IconButton\n circle\n color=\"primary\"\n variant=\"ghost\"\n icon={faCircleQuestion}\n label={helperButtonLabel ?? \"\"}\n {...helperButtonProps}\n tooltipProps={{\n side: \"bottom\",\n ...helperButtonProps?.tooltipProps,\n }}\n className={cx(\n prefix(\"form-pages__page-helper-button\"),\n helperButtonProps?.className,\n )}\n />\n </PopoverTrigger>\n\n <PopoverContent\n {...helperPopoverContentProps}\n className={cx(\n prefix(\"form-pages__page-helper-popover\"),\n helperPopoverContentProps?.className,\n )}\n >\n {helperText}\n </PopoverContent>\n </Popover>\n )}\n </Stack>\n )}\n </div>\n </Layer>\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport { CurrentPath, useResolvedPath } from \"@ostack.tech/kform-react\";\nimport {\n Container,\n type ContainerProps,\n cx,\n DocumentTitle,\n ErrorBoundary,\n type ErrorBoundaryProps,\n type IconButtonProps,\n type PopoverContentProps,\n type PopoverProps,\n Spinner,\n type StackProps,\n useCombinedRef,\n useMeasure,\n usePrinting,\n warnOnce,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type ReactNode,\n Suspense,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport {\n FormAppIssueMessages,\n FormAppStatus,\n useFormAppElement,\n} from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport type { IssuesPopoverProps } from \"../IssuesPopover\";\nimport { FormPageHeader } from \"./FormPageHeader.tsx\";\nimport { useFormPagesContext, useFormPageState } from \"./FormPagesContext.ts\";\n\n/** Object representation of a form page. */\nexport interface FormPageObject<T = any> {\n /** Form page path. */\n path?: string | Path;\n /** Form page's title */\n title?: ReactNode | ((value: T) => ReactNode);\n /**\n * Title of the form page as a string to display in the document's title.\n *\n * Defaults to `title` when it is a string. A warning is printed if `title` is\n * not a string and `documentTitle` is not provided.\n */\n documentTitle?: string | null | ((value: T) => string | null);\n /** Form page's code. */\n code?: ReactNode;\n /** Form page's label in the issues panel. The `title` is used by default. */\n issuesPanelLabel?: ReactNode | ((value: T) => ReactNode);\n}\n\n/** Properties of the form page component. */\nexport interface FormPageProps\n extends\n FormPageObject,\n Omit<ComponentProps<\"section\">, \"title\" | \"children\"> {\n /** Sets the form page as disabled. */\n disabled?: boolean;\n /** Sets the form page as read-only. */\n readOnly?: boolean;\n /** Form page helper text, displayed as a popover triggered by an icon button. */\n helperText?: ReactNode;\n /**\n * Mapping of issue messages from the path of the field with issues to the\n * issue messages of said field (which are themselves grouped by their code).\n *\n * Provided paths are relative to the form page's path and may contain\n * wildcards, which will have a lower priority when matched against.\n *\n * These messages are used by the `IssueMessages` component.\n *\n * > **Note:** Changes to `issueMessages` are handled correctly, but are not\n * > efficient. Please make sure that the identity of the provided value doesn't\n * > change at every render.\n *\n * Example value:\n *\n * ```tsx\n * {\n * \"**\": {\n * \"valueMissing\": \"Field is required.\"\n * },\n * \"field\": {\n * \"valueMissing\": \"My field cannot be left empty!\",\n * \"someOtherError\": \"Text of the other error.\"\n * }\n * }\n * ```\n */\n issueMessages?: Record<string, IssueMessagesByCode>;\n /**\n * Issue messages of the form page itself.\n *\n * These messages can also be provided via the `issueMessages` property using\n * a path of \"`.`\".\n */\n ownIssueMessages?: IssueMessagesByCode;\n /** Properties to pass to the header element. */\n headerProps?: ComponentProps<\"div\">;\n /** Label of the helper button announced to assistive technologies. */\n helperButtonLabel?: string;\n /**\n * Visually hidden prefix added to the form page code announced to assistive\n * technologies.\n */\n visuallyHiddenCodePrefix?: ReactNode;\n /** Properties to pass to the code element. */\n codeProps?: ComponentProps<\"div\">;\n /** Properties to pass to the title element. */\n titleProps?: ComponentProps<\"h2\">;\n /**\n * Properties to pass to the element containing the popover components in the\n * header.\n */\n headerPopoverContainerProps?: StackProps;\n /** Properties to pass to the form page's issues popover component. */\n issuesPopoverProps?: IssuesPopoverProps;\n /** Properties to pass to the form page's issue messages component. */\n issueMessagesProps?: Omit<IssueMessagesProps, \"messages\">;\n /** Properties to pass to the content element. */\n contentProps?: ComponentProps<\"div\">;\n /** Properties to pass to the container component. */\n containerProps?: ContainerProps;\n /** Properties to pass to the `ErrorBoundary` component. */\n errorBoundaryProps?: ErrorBoundaryProps;\n /** Properties to pass to the helper button component. */\n helperButtonProps?: Omit<IconButtonProps, \"icon\">;\n /** Properties to pass to the helper popover component. */\n helperPopoverProps?: PopoverProps;\n /** Properties to pass to the helper popover content component. */\n helperPopoverContentProps?: PopoverContentProps;\n children?: ReactNode;\n}\n\n/** Component representing a single form page. */\nexport function FormPage({\n path,\n // `FormPageObject` props\n title: _title,\n documentTitle: _documentTitle,\n code: _code,\n issuesPanelLabel: _issuesPanelLabel,\n disabled = false,\n readOnly = false,\n className,\n helperText,\n helperButtonLabel,\n visuallyHiddenCodePrefix: _visuallyHiddenCodePrefix,\n issueMessages,\n ownIssueMessages,\n headerProps,\n codeProps,\n titleProps,\n headerPopoverContainerProps,\n issuesPopoverProps,\n issueMessagesProps,\n contentProps,\n containerProps,\n errorBoundaryProps,\n helperButtonProps,\n helperPopoverProps,\n helperPopoverContentProps,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...otherProps\n}: FormPageProps) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n helperButtonLabel ??= locale.FormPage.helperButtonLabel;\n const printing = usePrinting();\n\n const generatedId = useId();\n const titleId = titleProps?.id ?? prefix(`form-page-title-${generatedId}`);\n\n const store = useFormPagesContext();\n const pagePath = useResolvedPath(path);\n\n const activePage = useStore(store, (state) => state.activePage);\n const shouldDisplay = useFormPageState(pagePath, (state) =>\n state?.path.equals(activePage),\n );\n const documentTitle = useFormPageState(pagePath, (state) =>\n state === null ? null : state.documentTitle,\n );\n\n if (documentTitle === undefined) {\n warnOnce(\n `FormPage: At '${pagePath.toString()}': \\`documentTitle\\` ` +\n \"should be set manually since the form page's `title` is not a string.\",\n );\n }\n\n // Keep track of the page header's height\n const [headerEl, setHeaderEl] = useState<HTMLDivElement | null>(null);\n useMeasure(\n headerEl,\n useCallback(\n (measurement) => {\n store\n .getState()\n .actions.setPageHeaderHeight(pagePath, measurement?.height ?? null);\n },\n [pagePath, store],\n ),\n );\n\n // Scroll to the top of the form app whenever we change into a new page (but\n // only if we've scrolled past the top of the form app)\n const formAppEl = useFormAppElement();\n const prevShouldDisplayRef = useRef(shouldDisplay);\n useEffect(() => {\n if (printing) {\n return;\n }\n if (\n shouldDisplay &&\n !prevShouldDisplayRef.current &&\n formAppEl.getBoundingClientRect().top < 0\n ) {\n formAppEl.scrollIntoView(true);\n }\n prevShouldDisplayRef.current = shouldDisplay;\n }, [formAppEl, printing, shouldDisplay]);\n\n const combinedHeaderRef = useCombinedRef(setHeaderEl, headerProps?.ref);\n if (!shouldDisplay && !printing) {\n return null;\n }\n return (\n <CurrentPath path={pagePath}>\n <DocumentTitle\n title={printing ? undefined : (documentTitle ?? undefined)}\n >\n <section\n className={cx(prefix(\"form-pages__page\"), className)}\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy ?? (ariaLabel === undefined ? titleId : undefined)\n }\n {...otherProps}\n >\n <FormAppStatus disabled={disabled} readOnly={readOnly}>\n <FormAppIssueMessages issueMessages={issueMessages}>\n <FormPageHeader\n helperText={helperText}\n helperButtonLabel={helperButtonLabel}\n ownIssueMessages={ownIssueMessages}\n codeProps={codeProps}\n titleProps={{ ...titleProps, id: titleId }}\n headerPopoverContainerProps={headerPopoverContainerProps}\n issuesPopoverProps={issuesPopoverProps}\n issueMessagesProps={issueMessagesProps}\n helperButtonProps={helperButtonProps}\n helperPopoverProps={helperPopoverProps}\n helperPopoverContentProps={helperPopoverContentProps}\n {...headerProps}\n ref={combinedHeaderRef}\n />\n\n <div\n {...contentProps}\n className={cx(\n prefix(\"form-pages__page-content\"),\n contentProps?.className,\n )}\n >\n <Container fluid=\"xxl\" gutter={0} {...containerProps}>\n <ErrorBoundary {...errorBoundaryProps}>\n <Suspense fallback={<Spinner size=\"xl\" color=\"primary\" />}>\n {children}\n </Suspense>\n </ErrorBoundary>\n </Container>\n </div>\n </FormAppIssueMessages>\n </FormAppStatus>\n </section>\n </DocumentTitle>\n </CurrentPath>\n );\n}\n","import { AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { CurrentPath, useController } from \"@ostack.tech/kform-react\";\nimport { usePrinting, useStartPrintingTask } from \"@ostack.tech/ui\";\nimport { useDeferredValue, useEffect } from \"react\";\nimport { shallow } from \"zustand/shallow\";\n\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterController, useRegisterLabel } from \"../FormApp\";\nimport {\n type ResolvedFormPageObject,\n useFormPagesContext,\n} from \"./FormPagesContext.ts\";\n\n/** Properties of the `FormPageRegistrar` component. */\nexport interface FormPageRegistrarProps extends ResolvedFormPageObject {}\n\n/** Component used to register a form page. */\nexport function FormPageRegistrar({\n path,\n title,\n documentTitle,\n code,\n issuesPanelLabel,\n}: FormPageRegistrarProps) {\n const store = useFormPagesContext();\n\n const printing = usePrinting();\n const finishPrintingTask = useStartPrintingTask();\n const observeDescendants =\n typeof title === \"function\" || typeof documentTitle === \"function\";\n const controller = useController(\n observeDescendants\n ? path.append(AbsolutePathFragment.RecursiveWildcard)\n : path,\n { enabled: !useFormIsLoading(), onInitialized: finishPrintingTask },\n );\n const absolutePath = controller.usePath();\n const exists = controller.useState(\n (state) => state.initialized && state.exists,\n );\n const value = controller.useValue();\n const deferredValue = useDeferredValue(value);\n const relevantValue = printing ? value : deferredValue;\n const deferredIssuesToDisplay = useDeferredValue(\n controller.useState((state) => (state.touched ? state.issues : []), {\n equalityFn: shallow,\n }),\n );\n const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());\n\n const actualTitle =\n typeof title === \"function\"\n ? relevantValue === undefined\n ? null\n : title(relevantValue)\n : title;\n const actualDocumentTitle =\n typeof documentTitle === \"function\"\n ? relevantValue === undefined\n ? null\n : documentTitle(relevantValue)\n : documentTitle === undefined\n ? actualTitle === null || typeof actualTitle === \"string\"\n ? actualTitle\n : undefined\n : documentTitle;\n\n useEffect(() => {\n const { registerPageState } = store.getState().actions;\n registerPageState(absolutePath, {\n exists,\n path: absolutePath,\n deferredIssuesToDisplay,\n deferredDisplayStatus,\n title: actualTitle,\n documentTitle: actualDocumentTitle,\n code,\n });\n }, [\n absolutePath,\n actualDocumentTitle,\n actualTitle,\n code,\n deferredDisplayStatus,\n deferredIssuesToDisplay,\n exists,\n store,\n title,\n ]);\n\n useRegisterController(controller);\n useRegisterLabel(\n absolutePath,\n <CurrentPath path={absolutePath}>\n {typeof issuesPanelLabel === \"function\"\n ? deferredValue === undefined\n ? null\n : issuesPanelLabel(deferredValue)\n : issuesPanelLabel || actualTitle}\n </CurrentPath>,\n );\n\n return null;\n}\n","import {\n type AbsolutePath,\n AbsolutePathFragment,\n Path,\n} from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n useFormManager,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport {\n cx,\n parseChildren,\n useCombinedRef,\n useCssVars,\n useMediaBreakpointUp,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { FormPage, type FormPageObject } from \"./FormPage.tsx\";\nimport { FormPageRegistrar } from \"./FormPageRegistrar.tsx\";\nimport {\n FormPagesContext,\n useCreateFormPagesContext,\n} from \"./FormPagesContext.ts\";\n\n/** Properties of the form page component. */\nexport interface FormPagesProps extends ComponentProps<\"div\"> {\n /** Base path for all declared form pages. */\n path?: string | Path;\n /**\n * List of all form pages. When not provided, the list of pages is obtained\n * from the direct children `FormPage` components.\n */\n pages?: FormPageObject[];\n /** Default path of the active form page. */\n defaultActivePage?: string | Path;\n /** Controlled path of the active form page. */\n activePage?: string | Path;\n /**\n * Function called whenever the active form page changes.\n *\n * @param activePagePath Path of the new active form page.\n */\n onActivePageChange?: (activePagePath: AbsolutePath | null) => void;\n children?: ReactNode;\n}\n\n/**\n * The form pages component can be used to split parts of a form into separate\n * pages, while providing means of navigating between them. Although not\n * strictly mandatory, each page is typically represented by its own class, with\n * its own schema and distinct path.\n *\n * It composes the following subcomponents:\n *\n * - `FormPagesNavigation`: Component used to navigate between form pages.\n * - `FormPage`: The content of a single page of the form.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * FormPage,\n * FormPages,\n * FormPagesNavigation,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function TaxWithholdingPages() {\n * return (\n * <FormPages>\n * <FormPagesNavigation />\n * <FormPage path=\"/fillingInfo\" title=\"Filing information\" code=\"0\">\n * Filing information page…\n * </FormPage>\n * <FormPage\n * path=\"/exemptions\"\n * title=\"Exemptions & declarations\"\n * code=\"1\"\n * >\n * Exemptions & declarations page…\n * </FormPage>\n * </FormPages>\n * );\n * }\n * ```\n */\nexport function FormPages({\n path,\n pages,\n defaultActivePage,\n activePage,\n onActivePageChange,\n className,\n children,\n ref,\n ...otherProps\n}: FormPagesProps) {\n const prefix = usePrefix();\n const { cssVarName } = useCssVars({ prefix });\n const formManager = useFormManager();\n const absolutePath = useResolvedPath(path);\n const isLargeScreen = useMediaBreakpointUp(\"sm\");\n\n // Get form pages from children if not provided as prop\n pages ??= parseChildren(children, FormPage, {\n renderUnknownComponents: false,\n });\n\n // Provided pages but with absolute paths\n const resolvedPages = useMemo(\n () =>\n pages.map((page) => ({\n ...page,\n path: absolutePath.resolve(page.path ?? Path.CURRENT),\n })),\n [absolutePath, pages],\n );\n\n // Refuse non-existent paths\n if (!formManager.isValidPath(absolutePath)) {\n throw new Error(`Invalid path: '${absolutePath.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n absolutePath.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Form pages base path must only contain ids.\");\n }\n // Validate form page paths\n for (const page of resolvedPages) {\n // Refuse non-existent paths\n if (!formManager.isValidPath(page.path)) {\n throw new Error(`Invalid path: '${page.path.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n page.path.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Form page path must only contain ids.\");\n }\n }\n\n const store = useCreateFormPagesContext({\n basePath: absolutePath,\n resolvedPages,\n defaultActivePage,\n activePage,\n onActivePageChange,\n });\n\n const formPagesRef = useRef<HTMLDivElement | null>(null);\n\n // Active page header height\n useEffect(\n () =>\n store.subscribe(\n ({ activePage, pageHeaderHeights: [pageHeaderHeights] }) =>\n (activePage && pageHeaderHeights.get(activePage.toString())) ?? 0,\n (height) =>\n formPagesRef.current?.style.setProperty(\n cssVarName(\"form-pages-page-header-height\"),\n `${height}px`,\n ),\n { fireImmediately: true },\n ),\n [cssVarName, prefix, store],\n );\n\n // Navigation select height\n useEffect(\n () =>\n store.subscribe(\n ({ navigationSelectHeight }) => navigationSelectHeight,\n (height) =>\n formPagesRef.current?.style.setProperty(\n cssVarName(\"form-pages-navigation-select-height\"),\n `${height}px`,\n ),\n { fireImmediately: true },\n ),\n [cssVarName, prefix, store],\n );\n\n const combinedFormPagesRef = useCombinedRef(formPagesRef, ref);\n return (\n <CurrentPath path={absolutePath}>\n <FormPagesContext.Provider value={store}>\n {resolvedPages.map((page) => (\n <FormPageRegistrar key={page.path.toString()} {...page} />\n ))}\n\n <div\n className={cx(prefix(\"form-pages\"), className)}\n data-navigation-mode={isLargeScreen ? \"sidebar\" : \"select\"}\n {...otherProps}\n ref={combinedFormPagesRef}\n >\n {children}\n </div>\n </FormPagesContext.Provider>\n </CurrentPath>\n );\n}\n","import type { AbsolutePath } from \"@ostack.tech/kform\";\nimport { CurrentPath } from \"@ostack.tech/kform-react\";\nimport { controlStatusToAccent, Option } from \"@ostack.tech/ui\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useFormPageState } from \"./FormPagesContext.ts\";\n\ninterface FormPagesSelectOptionProps {\n path: AbsolutePath;\n}\n\nexport function FormPagesSelectOption({ path }: FormPagesSelectOptionProps) {\n const prefix = usePrefix();\n const disabled = useFormPageState(path, (state) => !state?.exists);\n const deferredDisplayStatus = useFormPageState(\n path,\n (state) => state?.deferredDisplayStatus,\n );\n const code = useFormPageState(path, (state) => state?.code);\n const title = useFormPageState(path, (state) => state?.title);\n const controlStatus = displayStatusToControlStatus(deferredDisplayStatus);\n const accent = controlStatusToAccent(controlStatus, \"primary\");\n\n return (\n <CurrentPath path={path}>\n <Option\n value={path.toString()}\n keywords={[\n ...(typeof code === \"string\" ? [code] : []),\n ...(typeof title === \"string\" ? [title] : []),\n ]}\n className={prefix(\"form-pages__select-option\")}\n color={accent}\n disabled={disabled}\n iconProps={{\n className: prefix(\"form-pages__select-option-indicator\"),\n }}\n >\n <span\n className={prefix(\"form-pages__select-option-code\")}\n data-status={controlStatus}\n data-accent={accent}\n >\n {code}\n </span>\n {title}\n </Option>\n </CurrentPath>\n );\n}\n","import { AbsolutePath } from \"@ostack.tech/kform\";\nimport {\n cx,\n Select,\n type SelectSingleProps,\n useCombinedRef,\n useMeasure,\n} from \"@ostack.tech/ui\";\nimport { useCallback, useState } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useFormPagesContext } from \"./FormPagesContext.ts\";\nimport { FormPagesSelectOption } from \"./FormPagesSelectOption.tsx\";\n\n/** Properties of the form pages select component. */\nexport interface FormPagesSelectProps extends Omit<\n SelectSingleProps,\n \"defaultValue\" | \"value\" | \"onValueChange\" | \"showClearButton\"\n> {}\n\n/** Select component allowing the navigation between form pages. */\nexport function FormPagesSelect({\n rootProps,\n containerProps,\n valueProps,\n arrowProps,\n popoverProps,\n commandMenuProps,\n className,\n ...otherProps\n}: FormPagesSelectProps) {\n const prefix = usePrefix();\n const store = useFormPagesContext();\n const activePage = useStore(store, (state) => state.activePage);\n\n // Keep track of the select root's height\n const [selectRootEl, setSelectRootEl] = useState<HTMLDivElement | null>(null);\n useMeasure(\n selectRootEl,\n useCallback(\n (measurement) => {\n store.setState({ navigationSelectHeight: measurement?.height ?? 0 });\n },\n [store],\n ),\n );\n\n const handleValueChange = useCallback(\n (value: string) =>\n value && store.getState().actions.setActivePage(new AbsolutePath(value)),\n [store],\n );\n\n const pages = useStore(store, (state) => state.pages);\n return (\n <Select\n className={cx(prefix(\"form-pages__select\"), className)}\n value={activePage?.toString() ?? \"\"}\n onValueChange={handleValueChange}\n showClearButton={false}\n rootProps={{\n ...rootProps,\n ref: useCombinedRef(\n setSelectRootEl as (el: HTMLDivElement) => void,\n rootProps?.ref,\n ),\n }}\n containerProps={{\n ...containerProps,\n className: cx(\n prefix(\"form-pages__select-container\"),\n containerProps?.className,\n ),\n }}\n valueProps={{\n ...valueProps,\n className: cx(\n prefix(\"form-pages__select-value\"),\n valueProps?.className,\n ),\n }}\n arrowProps={{\n ...arrowProps,\n className: cx(\n prefix(\"form-pages__select-arrow\"),\n arrowProps?.className,\n ),\n }}\n popoverProps={{\n ...popoverProps,\n className: cx(\n prefix(\"form-pages__select-popover\"),\n popoverProps?.className,\n ),\n }}\n commandMenuProps={{ variant: \"subtle\", ...commandMenuProps }}\n {...otherProps}\n >\n {pages.map((page) => (\n <FormPagesSelectOption key={page.path.toString()} path={page.path} />\n ))}\n </Select>\n );\n}\n","import type { AbsolutePath } from \"@ostack.tech/kform\";\nimport { CurrentPath } from \"@ostack.tech/kform-react\";\nimport {\n boolDataAttr,\n controlStatusToAccent,\n MenuListItem,\n VisuallyHidden,\n} from \"@ostack.tech/ui\";\nimport { useCallback, useRef } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { visiblyFocus } from \"../../utils/useControlAutofocus.ts\";\nimport { useIssuesDisplayMode, useOnPathFocus } from \"../FormApp\";\nimport { useResetFocus } from \"../FormApp/FormAppContext.ts\";\nimport { useFormPagesContext, useFormPageState } from \"./FormPagesContext.ts\";\n\ninterface FormPageSidebarItemProps {\n path: AbsolutePath;\n}\n\nexport function FormPageSidebarItem({ path }: FormPageSidebarItemProps) {\n const [locale] = useLocale();\n const prefix = usePrefix();\n const store = useFormPagesContext();\n const activePage = useStore(store, (state) => state.activePage);\n\n const handleClick = () => store.getState().actions.setActivePage(path);\n\n const disabled = useFormPageState(path, (state) => !state?.exists);\n const deferredDisplayStatus = useFormPageState(\n path,\n (state) => state?.deferredDisplayStatus,\n );\n const code = useFormPageState(path, (state) => state?.code);\n const title = useFormPageState(path, (state) => state?.title);\n const visuallyHiddenCodePrefix = useFormPageState(\n path,\n (state) =>\n state?.visuallyHiddenCodePrefix ??\n locale.FormPage.visuallyHiddenCodePrefix,\n );\n\n const issuesDisplayMode = useIssuesDisplayMode();\n const itemActionRef = useRef<HTMLButtonElement | null>(null);\n const resetFocus = useResetFocus();\n useOnPathFocus(\n useCallback(\n (focusedPath: AbsolutePath) => {\n if (itemActionRef.current && path.equals(focusedPath)) {\n // In inline mode the issues popover should get focused instead\n if (issuesDisplayMode === \"panel\") {\n visiblyFocus(itemActionRef.current);\n }\n // Let the form page be opened before resetting focus\n setTimeout(() => resetFocus());\n }\n },\n [issuesDisplayMode, path, resetFocus],\n ),\n );\n\n const isSelected = activePage?.equals(path);\n return (\n <MenuListItem\n className={prefix(\"form-pages__sidebar-item\")}\n selected={isSelected}\n disabled={disabled}\n onSelect={handleClick}\n color=\"primary\"\n contentProps={{ className: prefix(\"form-pages__sidebar-item-content\") }}\n actionProps={{\n \"aria-current\": isSelected ? \"page\" : undefined,\n \"aria-invalid\": deferredDisplayStatus === \"error\" || undefined,\n ref: itemActionRef,\n }}\n >\n <CurrentPath path={path}>\n <span\n className={prefix(\"form-pages__sidebar-item-code\")}\n data-selected={boolDataAttr(isSelected)}\n data-status={displayStatusToControlStatus(deferredDisplayStatus)}\n data-accent={controlStatusToAccent(\n displayStatusToControlStatus(deferredDisplayStatus),\n )}\n >\n {code != null && typeof code !== \"boolean\" && (\n <>\n {visuallyHiddenCodePrefix && (\n <VisuallyHidden>{visuallyHiddenCodePrefix} </VisuallyHidden>\n )}\n {code}\n <VisuallyHidden>, </VisuallyHidden>\n </>\n )}\n </span>\n {title}\n </CurrentPath>\n </MenuListItem>\n );\n}\n","import { AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { useFormContext } from \"@ostack.tech/kform-react\";\nimport { cx, MenuList, useCombinedRef, useMeasure } from \"@ostack.tech/ui\";\nimport { type ComponentProps, useCallback, useState } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useSetLeftSidebarWidth } from \"../FormApp\";\nimport { useFormPagesContext } from \"./FormPagesContext.ts\";\nimport { FormPageSidebarItem } from \"./FormPageSidebarItem.tsx\";\n\n/** Properties of the form pages sidebar component. */\nexport interface FormPagesSidebarProps extends ComponentProps<\"div\"> {}\n\n/** Sidebar component allowing the navigation between form pages. */\nexport function FormPagesSidebar({\n className,\n ref,\n ...otherProps\n}: FormPagesSidebarProps) {\n const prefix = usePrefix();\n const store = useFormPagesContext();\n const { currentPath } = useFormContext();\n const activePage = useStore(store, (state) => state.activePage);\n const setLeftSidebarWidth = useSetLeftSidebarWidth();\n\n // Inform form app of \"active\" form pages navigation components (affect the\n // positioning of the issues panel when the sidebar is visible)\n const [sidebarEl, setSidebarEl] = useState<HTMLDivElement | null>(null);\n useMeasure(\n sidebarEl,\n useCallback(\n (measurement) => {\n if (\n activePage &&\n currentPath\n .append(AbsolutePathFragment.RecursiveWildcard)\n .contains(activePage)\n ) {\n setLeftSidebarWidth(measurement?.width);\n }\n },\n [activePage, currentPath, setLeftSidebarWidth],\n ),\n );\n\n const pages = useStore(store, (state) => state.pages);\n const combinedSidebarRef = useCombinedRef(setSidebarEl, ref);\n return (\n <div\n className={cx(prefix(\"form-pages__sidebar\"), className)}\n {...otherProps}\n ref={combinedSidebarRef}\n >\n <MenuList>\n {pages.map((page) => (\n <FormPageSidebarItem key={page.path.toString()} path={page.path} />\n ))}\n </MenuList>\n </div>\n );\n}\n","import {\n cx,\n Layer,\n useMediaBreakpointUp,\n usePrintClassNames,\n} from \"@ostack.tech/ui\";\nimport type { ComponentProps } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport {\n FormPagesSelect,\n type FormPagesSelectProps,\n} from \"./FormPagesSelect.tsx\";\nimport {\n FormPagesSidebar,\n type FormPagesSidebarProps,\n} from \"./FormPagesSidebar.tsx\";\n\n/** Properties of the form pages navigation component. */\nexport interface FormPagesNavigationProps extends ComponentProps<\"nav\"> {\n /** Properties to pass to the sidebar component. */\n sidebarProps?: FormPagesSidebarProps;\n /** Properties to pass to the select component. */\n selectProps?: FormPagesSelectProps;\n}\n\n/**\n * Component allowing navigation between form pages. Renders as a sidebar in\n * large screens and as a select for smaller ones.\n */\nexport function FormPagesNavigation({\n sidebarProps,\n selectProps,\n className,\n \"aria-label\": ariaLabel,\n ...otherProps\n}: FormPagesNavigationProps) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n ariaLabel ??= locale.FormPagesNavigation[\"aria-label\"];\n const { printHidden } = usePrintClassNames();\n const isLargeScreen = useMediaBreakpointUp(\"sm\");\n\n return (\n <Layer zIndex={isLargeScreen ? undefined : [\"sticky\", -1]}>\n <nav\n className={cx(prefix(\"form-pages__navigation\"), printHidden, className)}\n data-navigation-mode={isLargeScreen ? \"sidebar\" : \"select\"}\n aria-label={ariaLabel}\n {...otherProps}\n >\n {isLargeScreen ? (\n <Layer zIndex=\"docked\">\n <FormPagesSidebar {...sidebarProps} />\n </Layer>\n ) : (\n <FormPagesSelect {...selectProps} />\n )}\n </nav>\n </Layer>\n );\n}\n","import {\n type AbsolutePath,\n AbsolutePathFragment,\n type DisplayStatus,\n type FormManager,\n} from \"@ostack.tech/kform\";\nimport { useConstant, useLatestRef, usePrinting } from \"@ostack.tech/ui\";\nimport {\n createContext,\n type ReactNode,\n startTransition,\n useCallback,\n useContext,\n useEffect,\n} from \"react\";\nimport { createStore, useStore } from \"zustand\";\nimport { subscribeWithSelector } from \"zustand/middleware\";\n\nimport { useActivePathContext } from \"../../providers/ActivePathProvider\";\nimport { mostSpecificPath } from \"../../utils/mostSpecificPath.ts\";\nimport { useFocus, useOnPathFocus } from \"../FormApp\";\nimport { useSetLatestInteraction } from \"../FormApp/FormAppContext.ts\";\nimport type { FormStepObject } from \"./FormStep.tsx\";\nimport type { FormStepperProps } from \"./FormStepper.tsx\";\n\n/** Value of the form stepper context. */\nexport type FormStepperContextValue = FormStepperStore;\n\n/** Resolved form step object. */\nexport interface ResolvedFormStepObject extends FormStepObject {\n path: AbsolutePath;\n index: number;\n}\n\n/** Form step state. */\nexport interface FormStepState {\n path: AbsolutePath;\n index: number;\n exists: boolean;\n deferredDisplayStatus: DisplayStatus | undefined;\n title?: ReactNode;\n documentTitle?: string | null;\n}\n\n/** State of the form stepper. */\nexport interface FormStepperState {\n steps: ResolvedFormStepObject[];\n activeStep: ResolvedFormStepObject | null;\n // State below is wrapped in an array in order to trigger state updates by\n // simply changing the identity of the wrapper without creating new map\n // instances\n stepStates: [Record<string, FormStepState | null>];\n actions: FormStepperActions;\n}\n\n/** Actions of the form stepper. */\nexport interface FormStepperActions {\n getStepState: (path: AbsolutePath) => FormStepState | null;\n setSteps: (steps: ResolvedFormStepObject[]) => void;\n setActiveStep: (\n activeStep: ResolvedFormStepObject | null,\n callListener?: boolean,\n ) => void;\n updateActiveStep: () => void;\n registerStepState: (path: AbsolutePath, state: FormStepState) => void;\n goToStep: (index: number) => Promise<void>;\n}\n\n/** Form stepper store. */\nexport type FormStepperStore = ReturnType<typeof useCreateFormStepperContext>;\n\n/** Form stepper context. */\nexport const FormStepperContext = createContext<FormStepperContextValue | null>(\n null,\n);\n\n/** Options used to create the form stepper context. */\nexport interface UseCreateFormStepperContextOptions extends Pick<\n FormStepperProps,\n | \"defaultActiveStep\"\n | \"activeStep\"\n | \"onActiveStepChange\"\n | \"onStepValidation\"\n | \"skipStepValidationOnForwardNavigation\"\n | \"allowForwardNavigationOnError\"\n | \"preventFocusOnError\"\n> {\n formManager: FormManager;\n basePath: AbsolutePath;\n resolvedSteps: ResolvedFormStepObject[];\n}\n\n/** Hook used to create the form stepper context. */\nexport function useCreateFormStepperContext({\n formManager,\n basePath,\n resolvedSteps,\n defaultActiveStep,\n activeStep,\n onActiveStepChange,\n onStepValidation,\n skipStepValidationOnForwardNavigation,\n allowForwardNavigationOnError,\n preventFocusOnError,\n}: UseCreateFormStepperContextOptions) {\n const focus = useFocus();\n const setLatestInteraction = useSetLatestInteraction();\n const { activePath, onActivePathChange } = useActivePathContext();\n activeStep ??= activePath;\n\n const latestRef = useLatestRef({\n printing: usePrinting(),\n formManager,\n onActivePathChange,\n onActiveStepChange,\n onStepValidation,\n skipStepValidationOnForwardNavigation,\n allowForwardNavigationOnError,\n preventFocusOnError,\n });\n const store = useConstant(() =>\n createStore<FormStepperState>()(\n subscribeWithSelector((set, get) => ({\n steps: resolvedSteps,\n activeStep:\n activeStep === undefined\n ? defaultActiveStep == null\n ? null\n : (resolvedSteps.find((data) =>\n data.path.equals(basePath.resolve(defaultActiveStep)),\n ) ?? null)\n : activeStep === null\n ? null\n : (resolvedSteps.find((data) =>\n data.path.equals(basePath.resolve(activeStep)),\n ) ?? null),\n stepStates: [{}],\n actions: {\n getStepState: (path) => get().stepStates[0][path.toString()] ?? null,\n setSteps: (steps) => {\n const newStepStates: Record<string, FormStepState | null> = {};\n for (const step of steps) {\n newStepStates[step.path.toString()] = get().actions.getStepState(\n step.path,\n );\n }\n set({\n steps,\n stepStates: [newStepStates],\n });\n get().actions.updateActiveStep();\n },\n setActiveStep: (\n step: ResolvedFormStepObject | null,\n callListener = true,\n ) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const oldActiveStep = get().activeStep;\n if (\n !oldActiveStep?.path.equals(step?.path) ||\n oldActiveStep?.index !== step?.index\n ) {\n startTransition(() => {\n set({ activeStep: step });\n if (step != null) {\n setLatestInteraction(step.path);\n }\n latestRef.current.onActivePathChange(step?.path ?? null);\n if (callListener) {\n latestRef.current.onActiveStepChange?.(\n step?.path ?? null,\n step?.index ?? -1,\n );\n }\n });\n }\n },\n updateActiveStep: () => {\n if (\n latestRef.current.printing ||\n (get().activeStep !== null &&\n get().steps.some((step) =>\n step.path.equals(get().activeStep!.path),\n ))\n ) {\n return;\n }\n\n get().actions.setActiveStep(\n get().steps[\n Math.max(\n 0,\n Math.min(\n get().activeStep?.index ?? -1,\n get().steps.length - 1,\n ),\n )\n ] ?? null,\n );\n },\n registerStepState: (path, state) => {\n const stepStates = get().stepStates[0];\n stepStates[path.toString()] = state;\n set({ stepStates: [stepStates] });\n get().actions.updateActiveStep();\n },\n goToStep: async (newStepIndex: number) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const oldActiveStep = get().activeStep;\n const newActiveStep = get().steps[newStepIndex];\n if (\n (oldActiveStep?.path != newActiveStep?.path &&\n (oldActiveStep?.path == null || newActiveStep?.path == null)) ||\n (oldActiveStep?.path != null &&\n newActiveStep?.path != null &&\n !newActiveStep.path.contains(oldActiveStep.path))\n ) {\n const {\n formManager,\n allowForwardNavigationOnError,\n skipStepValidationOnForwardNavigation,\n onStepValidation,\n preventFocusOnError,\n } = latestRef.current;\n\n // Mark steps as touched and validate them prior to moving to the\n // following step (when `skipStepValidationOnForwardNavigation` is\n // not set)\n let shouldChangeActiveStep = true;\n if (\n !skipStepValidationOnForwardNavigation &&\n oldActiveStep &&\n newActiveStep &&\n oldActiveStep.index < newActiveStep.index\n ) {\n const touchAndValidateStep = async (i: number) => {\n const stepPathRecursive = get().steps[i].path.append(\n AbsolutePathFragment.RecursiveWildcard,\n );\n await formManager.setTouched(stepPathRecursive);\n const issues = await formManager.validate(stepPathRecursive);\n onStepValidation?.(issues);\n return issues;\n };\n\n for (\n let i = oldActiveStep.index;\n i < newActiveStep.index;\n ++i\n ) {\n // Unless `allowForwardNavigationOnError` is set, focus the first\n // error we find after validating the form, and don't allow\n // navigating further\n if (allowForwardNavigationOnError) {\n void touchAndValidateStep(i);\n } else {\n const issues = await touchAndValidateStep(i);\n const firstError = issues.find(\n (issue) => issue.severity === \"error\",\n );\n if (firstError) {\n shouldChangeActiveStep = false;\n if (!preventFocusOnError) {\n setTimeout(() => focus(firstError.path));\n }\n break;\n }\n }\n }\n }\n\n if (shouldChangeActiveStep) {\n get().actions.setActiveStep(newActiveStep);\n }\n }\n },\n },\n })),\n ),\n );\n\n // Update store when params change\n useEffect(() => {\n store.getState().actions.setSteps(resolvedSteps);\n if (activeStep !== undefined) {\n const { steps, activeStep: oldActiveStep } = store.getState();\n const specificPath = mostSpecificPath(\n activeStep === null ? null : basePath.resolve(activeStep),\n steps.map((step) => step.path),\n oldActiveStep?.path ?? null,\n );\n store\n .getState()\n .actions.setActiveStep(\n steps.find((step) => step.path.equals(specificPath)) ?? null,\n false,\n );\n }\n }, [resolvedSteps, activeStep, basePath, store]);\n\n // Set (possibly new) active step when focused path changes\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n const { steps, activeStep, actions } = store.getState();\n const specificPath = mostSpecificPath(\n focusedPath,\n steps.map((step) => step.path),\n activeStep?.path ?? null,\n );\n actions.setActiveStep(\n steps.find((step) => step.path.equals(specificPath)) ?? null,\n );\n },\n [store],\n ),\n );\n\n return store;\n}\n\nexport function useFormStepperContext(): FormStepperContextValue {\n const formStepperContext = useContext(FormStepperContext);\n if (!formStepperContext) {\n throw new Error(\"Form stepper context not in scope.\");\n }\n return formStepperContext;\n}\n\nexport function useFormStepState<T>(\n path: AbsolutePath,\n selector: (state: FormStepState | null) => T,\n): T {\n return useStore(useFormStepperContext(), (state) =>\n selector(state.actions.getStepState(path)),\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport { CurrentPath, useResolvedPath } from \"@ostack.tech/kform-react\";\nimport {\n cx,\n DocumentTitle,\n ErrorBoundary,\n type ErrorBoundaryProps,\n Spinner,\n StepContent,\n type StepContentProps,\n warnOnce,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, Suspense } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { FormAppIssueMessages, FormAppStatus } from \"../FormApp\";\nimport type { IssueMessagesByCode } from \"../IssueMessages\";\nimport { useFormStepState } from \"./FormStepperContext.ts\";\n\n/** Object representation of a form step. */\nexport interface FormStepObject<T = any> {\n /** Form step path. */\n path?: string | Path;\n /** Form step's title. */\n title: ReactNode | ((value: T) => ReactNode);\n /**\n * Title of the form step as a string to display in the document's title.\n *\n * Defaults to `title` when it is a string. A warning is printed if `title` is\n * not a string and `documentTitle` is not provided.\n */\n documentTitle?: string | null | ((value: T) => string | null);\n /** Label of the form step in the issues panel. Uses the `title` by default. */\n issuesPanelLabel?: ReactNode | ((value: T) => ReactNode);\n}\n\n/** Properties of the form step component. */\nexport interface FormStepProps\n extends FormStepObject, Omit<StepContentProps, \"index\" | \"title\"> {\n /** Sets the step as disabled. */\n disabled?: boolean;\n /** Sets the step as read-only. */\n readOnly?: boolean;\n /**\n * Mapping of issue messages from the path of the field with issues to the\n * issue messages of said field (which are themselves grouped by their code).\n *\n * Provided paths are relative to the form step's path and may contain\n * wildcards, which will have a lower priority when matched against.\n *\n * These messages are used by the `IssueMessages` component.\n *\n * > **Note:** Changes to `issueMessages` are handled correctly, but are not\n * > efficient. Please make sure that the identity of the provided value doesn't\n * > change at every render.\n *\n * Example value:\n *\n * ```tsx\n * {\n * \"**\": {\n * \"valueMissing\": \"Field is required.\"\n * },\n * \"field\": {\n * \"valueMissing\": \"My field cannot be left empty!\",\n * \"someOtherError\": \"Text of the other error.\"\n * }\n * }\n * ```\n */\n issueMessages?: Record<string, IssueMessagesByCode>;\n /** Properties to pass to the `ErrorBoundary` component. */\n errorBoundaryProps?: ErrorBoundaryProps;\n}\n\n/** Single form step. */\nexport function FormStep({\n path,\n // `FormStepObject` props\n title: _title,\n documentTitle: _documentTitle,\n issuesPanelLabel: _issuesPanelLabel,\n disabled = false,\n readOnly = false,\n issueMessages,\n errorBoundaryProps,\n className,\n children,\n ...otherProps\n}: FormStepProps) {\n const prefix = usePrefix();\n const stepPath = useResolvedPath(path);\n const index = useFormStepState(stepPath, (controller) => controller?.index);\n const documentTitle = useFormStepState(stepPath, (state) =>\n state === null ? null : state.documentTitle,\n );\n\n if (documentTitle === undefined) {\n warnOnce(\n `FormStep: At '${stepPath.toString()}': \\`documentTitle\\` ` +\n \"should be set manually since the form step's `title` is not a string.\",\n );\n }\n\n return (\n index != null && (\n <CurrentPath path={stepPath}>\n <StepContent\n index={index}\n className={cx(prefix(\"form-stepper__step-content\"), className)}\n {...otherProps}\n >\n <DocumentTitle title={documentTitle ?? undefined}>\n <FormAppStatus disabled={disabled} readOnly={readOnly}>\n <FormAppIssueMessages issueMessages={issueMessages}>\n <ErrorBoundary {...errorBoundaryProps}>\n <Suspense fallback={<Spinner size=\"xl\" color=\"primary\" />}>\n {children}\n </Suspense>\n </ErrorBoundary>\n </FormAppIssueMessages>\n </FormAppStatus>\n </DocumentTitle>\n </StepContent>\n </CurrentPath>\n )\n );\n}\n\n/** @deprecated Use `FormStep` instead. */\nexport const FormStepContent = FormStep;\n","import type { AbsolutePath } from \"@ostack.tech/kform\";\nimport { CurrentPath } from \"@ostack.tech/kform-react\";\nimport { Step } from \"@ostack.tech/ui\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useFormStepState } from \"./FormStepperContext.ts\";\n\n/** Properties of the form step button component. */\nexport interface FormStepButtonProps {\n path: AbsolutePath;\n index: number;\n}\n\n/** Form step button. */\nexport function FormStepButton({ path, index }: FormStepButtonProps) {\n const prefix = usePrefix();\n const deferredDisplayStatus = useFormStepState(\n path,\n (state) => state?.deferredDisplayStatus,\n );\n const disabled = useFormStepState(path, (state) => !state?.exists);\n const title = useFormStepState(path, (state) => state?.title);\n\n return (\n <Step\n index={index}\n status={displayStatusToControlStatus(deferredDisplayStatus)}\n disabled={disabled}\n className={prefix(\"form-stepper__step\")}\n >\n <CurrentPath path={path}>{title}</CurrentPath>\n </Step>\n );\n}\n","import { cx, StepList, type StepListProps } from \"@ostack.tech/ui\";\nimport { useStore } from \"zustand\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { FormStepButton } from \"./FormStepButton.tsx\";\nimport { useFormStepperContext } from \"./FormStepperContext.ts\";\n\n/** Properties of the form steps sidebar component. */\nexport interface FormStepListProps extends StepListProps {}\n\n/** Component displaying all form steps in a list. */\nexport function FormStepList({ className, ...otherProps }: FormStepListProps) {\n const prefix = usePrefix();\n const steps = useStore(useFormStepperContext(), (state) => state.steps);\n\n return (\n <StepList\n className={cx(prefix(\"form-stepper__step-list\"), className)}\n {...otherProps}\n >\n {steps.map((step) => (\n <FormStepButton\n key={step.path.toString()}\n path={step.path}\n index={step.index}\n />\n ))}\n </StepList>\n );\n}\n","import { AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { CurrentPath, useController } from \"@ostack.tech/kform-react\";\nimport { usePrinting, useStartPrintingTask } from \"@ostack.tech/ui\";\nimport { useDeferredValue, useEffect } from \"react\";\n\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterController, useRegisterLabel } from \"../FormApp\";\nimport {\n type ResolvedFormStepObject,\n useFormStepperContext,\n} from \"./FormStepperContext.ts\";\n\n/** Properties of the `FormStepRegistrar` component. */\nexport interface FormStepRegistrarProps extends ResolvedFormStepObject {}\n\n/** Component used to register a form step. */\nexport function FormStepRegistrar({\n index,\n path,\n title,\n documentTitle,\n issuesPanelLabel,\n}: FormStepRegistrarProps) {\n const store = useFormStepperContext();\n\n const printing = usePrinting();\n const finishPrintingTask = useStartPrintingTask();\n const observeDescendants =\n typeof title === \"function\" || typeof documentTitle === \"function\";\n const controller = useController(\n observeDescendants\n ? path.append(AbsolutePathFragment.RecursiveWildcard)\n : path,\n { enabled: !useFormIsLoading(), onInitialized: finishPrintingTask },\n );\n const absolutePath = controller.usePath();\n const exists = controller.useState(\n (state) => state.initialized && state.exists,\n );\n const value = controller.useValue();\n const deferredValue = useDeferredValue(value);\n const relevantValue = printing ? value : deferredValue;\n const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());\n\n const actualTitle =\n typeof title === \"function\"\n ? relevantValue === undefined\n ? null\n : title(relevantValue)\n : title;\n const actualDocumentTitle =\n typeof documentTitle === \"function\"\n ? relevantValue === undefined\n ? null\n : documentTitle(relevantValue)\n : documentTitle === undefined\n ? actualTitle === null || typeof actualTitle === \"string\"\n ? actualTitle\n : undefined\n : documentTitle;\n\n useEffect(() => {\n const { registerStepState } = store.getState().actions;\n registerStepState(absolutePath, {\n exists,\n path: absolutePath,\n deferredDisplayStatus,\n index,\n title: actualTitle,\n documentTitle: actualDocumentTitle,\n });\n }, [\n absolutePath,\n actualDocumentTitle,\n actualTitle,\n deferredDisplayStatus,\n exists,\n index,\n store,\n title,\n ]);\n\n useRegisterController(controller);\n useRegisterLabel(\n absolutePath,\n <CurrentPath path={absolutePath}>\n {typeof issuesPanelLabel === \"function\"\n ? deferredValue === undefined\n ? null\n : issuesPanelLabel(deferredValue)\n : issuesPanelLabel || actualTitle}\n </CurrentPath>,\n );\n\n return null;\n}\n","import {\n type AbsolutePath,\n AbsolutePathFragment,\n Path,\n type SealedLocatedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n useFormManager,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport { cx, parseChildren, Stepper, type StepperProps } from \"@ostack.tech/ui\";\nimport { useMemo } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { FormStep, type FormStepObject } from \"./FormStep.tsx\";\nimport {\n FormStepperContext,\n useCreateFormStepperContext,\n} from \"./FormStepperContext.ts\";\nimport { FormStepRegistrar } from \"./FormStepRegistrar.tsx\";\n\n/** Properties of the form stepper component. */\nexport interface FormStepperProps extends Omit<\n StepperProps,\n \"defaultActiveStep\" | \"activeStep\" | \"onActiveStepChange\"\n> {\n /** Base path for all declared form steps. */\n path?: string | Path;\n /** List of all form steps. */\n steps?: FormStepObject[];\n /** Default active form step. */\n defaultActiveStep?: string | Path;\n /** Controlled active form step. */\n activeStep?: string | Path;\n /**\n * Function called whenever the active form step changes.\n *\n * @param activeStepPath Path of the new active form step.\n * @param activeStepIndex Index of the new active form step.\n */\n onActiveStepChange?: (\n activeStepPath: AbsolutePath | null,\n activeStepIndex: number,\n ) => void;\n /**\n * Function called when a step is touched and validated due to a navigation to\n * a following step. This function is never called when\n * `skipStepValidationOnForwardNavigation` is `true`.\n *\n * @param issues Issues present in the step.\n */\n onStepValidation?: (issues: SealedLocatedValidationIssue[]) => void;\n /**\n * Whether to skip marking a step as touched and validating it when navigating\n * to a following step.\n *\n * @default false\n */\n skipStepValidationOnForwardNavigation?: boolean;\n /**\n * Whether to allow navigation to a following step when a previous step\n * contains errors. This is always `true` when\n * `skipStepValidationOnForwardNavigation` is also `true`.\n *\n * @default false\n */\n allowForwardNavigationOnError?: boolean;\n /**\n * Whether to prevent the focus of an invalid field when a step was validated\n * and an error was found. This is always `true` if either\n * `skipStepValidationOnForwardNavigation` or `allowForwardNavigationOnError`\n * are `true`.\n *\n * @default false\n */\n preventFocusOnError?: boolean;\n}\n\n/**\n * The form stepper component can be used to split parts of a form into separate\n * steps. It is built on top of the\n * [`Stepper`](/docs/ostack-ui-disclosure-stepper--docs) component. Although not\n * strictly mandatory, each page is typically represented by its own class, with\n * its own schema and distinct path.\n *\n * It composes the following subcomponents:\n *\n * - `FormStepList`: Component used to navigate between form pages.\n * - `FormStep`: The content of a single step of the form.\n * - `FormStepperPreviousTrigger`: Trigger to navigate to the previous step.\n * - `FormStepperNextTrigger`: Trigger to navigate to the next step.\n * - `FormStepperFinishTrigger`: Trigger to finish the form stepper.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * FormStep,\n * FormStepList,\n * FormStepper,\n * FormStepperFinishTrigger,\n * FormStepperNextTrigger,\n * FormStepperPreviousTrigger,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function AccountSetupStepper() {\n * return (\n * <FormStepper>\n * <FormStepList />\n * <FormStep path=\"/profile\" title=\"Personal profile\">\n * Provide identification…\n * </FormStep>\n * <FormStep path=\"/preferences\" title=\"Preferences\">\n * Select preferences…\n * </FormStep>\n * <FormStep path=\"/terms\" title=\"Terms & authorization\">\n * Accept terms…\n * </FormStep>\n * <FormStepperPreviousTrigger />\n * <FormStepperNextTrigger />\n * <FormStepperFinishTrigger />\n * </FormStepper>\n * );\n * }\n * ```\n */\nexport function FormStepper({\n path,\n steps,\n defaultActiveStep,\n activeStep,\n onActiveStepChange,\n onStepValidation,\n skipStepValidationOnForwardNavigation,\n allowForwardNavigationOnError,\n preventFocusOnError,\n className,\n children,\n ...otherProps\n}: FormStepperProps) {\n const prefix = usePrefix();\n const formManager = useFormManager();\n const absolutePath = useResolvedPath(path);\n\n // Get form steps from children if not provided as prop\n steps ??= parseChildren(children, FormStep, {\n renderUnknownComponents: false,\n });\n\n // Provided steps but with absolute paths and indices\n const resolvedSteps = useMemo(\n () =>\n steps.map((step, i) => ({\n ...step,\n index: i,\n path: absolutePath.resolve(step.path ?? Path.CURRENT),\n })),\n [absolutePath, steps],\n );\n\n // Refuse non-existent paths\n if (!formManager.isValidPath(absolutePath)) {\n throw new Error(`Invalid path: '${absolutePath.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n absolutePath.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Form stepper base path must only contain ids.\");\n }\n // Validate form step paths\n for (const step of resolvedSteps) {\n // Refuse non-existent paths\n if (!formManager.isValidPath(step.path)) {\n throw new Error(`Invalid path: '${step.path.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n step.path.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Form step path must only contain ids.\");\n }\n }\n\n const store = useCreateFormStepperContext({\n formManager,\n basePath: absolutePath,\n resolvedSteps,\n defaultActiveStep,\n activeStep,\n onActiveStepChange,\n onStepValidation,\n skipStepValidationOnForwardNavigation,\n allowForwardNavigationOnError,\n preventFocusOnError,\n });\n const activeIndex = useStore(store, (state) => state.activeStep?.index ?? -1);\n const { goToStep } = useStore(store, (state) => state.actions);\n\n return (\n <CurrentPath path={absolutePath}>\n <FormStepperContext.Provider value={store}>\n {resolvedSteps.map((step) => (\n <FormStepRegistrar key={step.path.toString()} {...step} />\n ))}\n\n <Stepper\n className={cx(prefix(\"form-stepper\"), className)}\n activeStep={activeIndex}\n onActiveStepChange={goToStep}\n {...otherProps}\n >\n {children}\n </Stepper>\n </FormStepperContext.Provider>\n </CurrentPath>\n );\n}\n","import {\n StepperFinishTrigger,\n type StepperFinishTriggerProps,\n} from \"@ostack.tech/ui\";\n\n/** Properties of the form stepper finish trigger component. */\nexport type FormStepperFinishTriggerProps = StepperFinishTriggerProps;\n\n/** Trigger used to conclude the form stepper. */\nexport const FormStepperFinishTrigger = StepperFinishTrigger;\n","import {\n StepperNextTrigger,\n type StepperNextTriggerProps,\n} from \"@ostack.tech/ui\";\n\n/** Properties of the form stepper next trigger component. */\nexport type FormStepperNextTriggerProps = StepperNextTriggerProps;\n\n/** Trigger used to go to the next step of the form stepper. */\nexport const FormStepperNextTrigger = StepperNextTrigger;\n","import {\n StepperPreviousTrigger,\n type StepperPreviousTriggerProps,\n} from \"@ostack.tech/ui\";\n\n/** Properties of the form stepper previous trigger component. */\nexport type FormStepperPreviousTriggerProps = StepperPreviousTriggerProps;\n\n/** Trigger used to go to the previous step of the form stepper. */\nexport const FormStepperPreviousTrigger = StepperPreviousTrigger;\n","import {\n useFormManager,\n useIssuesTracker,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport {\n Alert,\n type AlertProps,\n cx,\n Feedback,\n FeedbackList,\n usePrevious,\n} from \"@ostack.tech/ui\";\nimport { useDeferredValue, useMemo } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useReportValidationFailures } from \"../../utils/useReportValidationFailures.ts\";\nimport { FormAppIssueMessages } from \"../FormApp\";\nimport { IssueMessage } from \"../IssueMessage\";\nimport type { IssueMessagesProps } from \"../IssueMessages\";\n\n/** Properties of the issues alert component. */\nexport interface IssuesAlertProps\n extends\n Omit<AlertProps, \"open\" | \"defaultOpen\" | \"severity\" | \"children\">,\n Pick<\n IssueMessagesProps,\n | \"path\"\n | \"issues\"\n | \"messages\"\n | \"displayIssueCodes\"\n | \"messagesDataKey\"\n | \"visuallyHiddenErrorCodePrefix\"\n | \"visuallyHiddenWarningCodePrefix\"\n | \"unknownErrorMessage\"\n | \"unknownWarningMessage\"\n > {}\n\n/** Component used to display an issue alert. */\nexport function IssuesAlert({\n variant = \"solid\",\n path,\n issues,\n messages,\n displayIssueCodes,\n messagesDataKey,\n visuallyHiddenErrorCodePrefix,\n visuallyHiddenWarningCodePrefix,\n unknownErrorMessage,\n unknownWarningMessage,\n className,\n ...otherProps\n}: IssuesAlertProps) {\n const prefix = usePrefix();\n const formManager = useFormManager();\n const absolutePath = useResolvedPath(path);\n const { info } = useIssuesTracker(absolutePath, {\n enabled: !issues,\n });\n const messagesToRegister = useMemo(\n () => messages && { [absolutePath.toString()]: messages },\n [absolutePath, messages],\n );\n\n const deferredTrackedIssues = useDeferredValue(\n useMemo(() => info?.flatMap((info) => info.issues) ?? [], [info]),\n );\n const deferredIssuesToDisplay = issues ?? deferredTrackedIssues;\n useReportValidationFailures(\n useMemo(\n () => [{ path: absolutePath, issues: deferredIssuesToDisplay }],\n [absolutePath, deferredIssuesToDisplay],\n ),\n );\n const severity = useMemo(\n () =>\n deferredIssuesToDisplay.length === 0\n ? undefined\n : deferredIssuesToDisplay.every((issue) => issue.severity === \"warning\")\n ? \"warning\"\n : \"danger\",\n [deferredIssuesToDisplay],\n );\n // Use previous severity as fallback while the alert is hiding, when there are\n // no more issues\n const prevSeverity = usePrevious(severity);\n\n const schema = useMemo(\n () => formManager.schema(absolutePath),\n [absolutePath, formManager],\n );\n\n return (\n <Alert\n className={cx(prefix(\"issues-alert\"), className)}\n open={deferredIssuesToDisplay.length > 0}\n variant={variant}\n {...otherProps}\n severity={severity ?? prevSeverity}\n >\n <FormAppIssueMessages issueMessages={messagesToRegister}>\n <FeedbackList>\n {deferredIssuesToDisplay.map((issue, i) => (\n <Feedback key={i} type={issue.severity}>\n <IssueMessage\n path={absolutePath}\n issue={issue}\n schema={schema}\n displayIssueCode={displayIssueCodes}\n messageDataKey={messagesDataKey}\n visuallyHiddenErrorCodePrefix={visuallyHiddenErrorCodePrefix}\n visuallyHiddenWarningCodePrefix={\n visuallyHiddenWarningCodePrefix\n }\n unknownErrorMessage={unknownErrorMessage}\n unknownWarningMessage={unknownWarningMessage}\n issueCodeProps={{\n className: prefix(\"issue-messages__issue-code\"),\n }}\n />\n </Feedback>\n ))}\n </FeedbackList>\n </FormAppIssueMessages>\n </Alert>\n );\n}\n","import { useFormController } from \"@ostack.tech/kform-react\";\nimport { useCallback, useMemo } from \"react\";\n\nimport { useStartIssuesNavigation } from \"../components/FormApp\";\n\n/** Result of the {@link useFormValidator} hook. */\nexport interface FormValidatorResult {\n /**\n * Function used to validate the form.\n *\n * @returns Promise which resolves once the form has been validated.\n */\n validate: () => Promise<void>;\n}\n\n/** Hook exposing a function used to validate the form. */\nexport function useFormValidator(): FormValidatorResult {\n const startIssuesNavigation = useStartIssuesNavigation();\n const { _setState } = useFormController();\n\n const validate = useCallback(async () => {\n _setState({ validating: true } as any);\n try {\n await startIssuesNavigation();\n } finally {\n _setState({ validating: false } as any);\n }\n }, [_setState, startIssuesNavigation]);\n\n return useMemo(() => ({ validate }), [validate]);\n}\n\n/** Result of the {@link useFormIsValidating} hook. */\nexport interface FormIsValidatingResult {\n /**\n * Whether form is being validated automatically (due to validating mode being\n * set to `\"auto\"`).\n */\n validatingAutomatically: boolean;\n /**\n * Whether form is being validated manually (due to an explicit `validate`\n * call).\n */\n validatingManually: boolean;\n /** Whether form is being validated (either automatically or manually). */\n validating: boolean;\n}\n\n/** Hook exposing whether the form is currently being validated. */\nexport function useFormIsValidating(): FormIsValidatingResult {\n const validatingAutomatically =\n useFormController().useAutoValidationStatus() === \"activeRunning\";\n const validatingManually = useFormController().useState(\n (state) => (state as any).validating,\n );\n\n return useMemo(\n () => ({\n validatingAutomatically,\n validatingManually,\n validating: validatingAutomatically || validatingManually,\n }),\n [validatingAutomatically, validatingManually],\n );\n}\n","import {\n faAngleLeft,\n faAngleRight,\n faAnglesLeft,\n faAnglesRight,\n faArrowsToDot,\n} from \"@fortawesome/free-solid-svg-icons\";\nimport type { AbsolutePath } from \"@ostack.tech/kform\";\nimport type { Controller } from \"@ostack.tech/kform-react\";\nimport {\n CloseButton,\n combineEventHandlers,\n cx,\n IconButton,\n type IconButtonColor,\n Spinner,\n useKeyboardShortcut,\n VisuallyHidden,\n} from \"@ostack.tech/ui\";\nimport { useCallback, useDeferredValue } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useFormIsValidating } from \"../../utils/useFormValidator.ts\";\nimport { useFocus, useFormAppElement, useFormIsDisabled } from \"../FormApp\";\nimport type { IssuesPanelProps } from \"./IssuesPanel.tsx\";\n\n/** Properties of the issues panel controls component. */\nexport interface IssuesPanelControlsProps extends Pick<\n IssuesPanelProps,\n | \"focusButtonLabel\"\n | \"focusKeybinds\"\n | \"previousIssueButtonLabel\"\n | \"previousIssueKeybinds\"\n | \"nextIssueButtonLabel\"\n | \"nextIssueKeybinds\"\n | \"firstIssueButtonLabel\"\n | \"firstIssueKeybinds\"\n | \"lastIssueButtonLabel\"\n | \"lastIssueKeybinds\"\n | \"paginationLabel\"\n | \"validatingSpinnerProps\"\n | \"paginationProps\"\n | \"focusButtonProps\"\n | \"previousIssueButtonProps\"\n | \"nextIssueButtonProps\"\n | \"firstIssueButtonProps\"\n | \"lastIssueButtonProps\"\n | \"closeButtonProps\"\n> {\n currentPagePath: AbsolutePath | null;\n currentPageIndex: number;\n currentPageController: Controller;\n nPages: number;\n goToPreviousPage: () => void;\n goToNextPage: () => void;\n goToFirstPage: () => void;\n goToLastPage: () => void;\n buttonsColor?: IconButtonColor;\n closePanel: () => void;\n}\n\n/** Controls of the issues panel. */\nexport function IssuesPanelControls({\n currentPagePath,\n nPages,\n currentPageIndex,\n currentPageController,\n goToPreviousPage,\n goToNextPage,\n goToFirstPage,\n goToLastPage,\n buttonsColor,\n closePanel,\n focusButtonLabel,\n focusKeybinds,\n previousIssueButtonLabel,\n previousIssueKeybinds,\n nextIssueButtonLabel,\n nextIssueKeybinds,\n firstIssueButtonLabel,\n firstIssueKeybinds,\n lastIssueButtonLabel,\n lastIssueKeybinds,\n paginationLabel,\n validatingSpinnerProps,\n paginationProps,\n focusButtonProps,\n previousIssueButtonProps,\n nextIssueButtonProps,\n firstIssueButtonProps,\n lastIssueButtonProps,\n closeButtonProps,\n}: IssuesPanelControlsProps) {\n const prefix = usePrefix();\n const formIsDisabled = useFormIsDisabled();\n const { validating } = useFormIsValidating();\n const deferredValidating = useDeferredValue(validating);\n const currentPageInitialized = currentPageController.useInitialized();\n const currentPageExists = currentPageController.useExists();\n\n const focus = useFocus();\n const handleFocus = useCallback(\n () => focus(currentPagePath!),\n [currentPagePath, focus],\n );\n\n const focusButtonLoading = !currentPageInitialized;\n const focusButtonDisabled = formIsDisabled || !currentPageExists;\n const firstIssueButtonDisabled =\n formIsDisabled || firstIssueButtonProps?.disabled || currentPageIndex === 0;\n const previousIssueButtonDisabled =\n formIsDisabled ||\n previousIssueButtonProps?.disabled ||\n currentPageIndex === 0;\n const nextIssueButtonDisabled =\n formIsDisabled ||\n nextIssueButtonProps?.disabled ||\n currentPageIndex === nPages - 1;\n const lastIssueButtonDisabled =\n formIsDisabled ||\n lastIssueButtonProps?.disabled ||\n currentPageIndex === nPages - 1;\n\n // Set-up keyboard shortcuts\n const formAppEl = useFormAppElement();\n useKeyboardShortcut(focusKeybinds, handleFocus, {\n disabled: focusButtonLoading || focusButtonDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n useKeyboardShortcut(firstIssueKeybinds, goToFirstPage, {\n disabled: firstIssueButtonDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n useKeyboardShortcut(previousIssueKeybinds, goToPreviousPage, {\n disabled: previousIssueButtonDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n useKeyboardShortcut(nextIssueKeybinds, goToNextPage, {\n disabled: nextIssueButtonDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n useKeyboardShortcut(lastIssueKeybinds, goToLastPage, {\n disabled: lastIssueButtonDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n\n return (\n <div className={prefix(\"issues-panel__controls\")}>\n {nPages > 0 && (\n <>\n {/* Validating spinner. */}\n {deferredValidating && (\n <Spinner\n {...validatingSpinnerProps}\n className={cx(\n prefix(\"issues-panel__validating-spinner\"),\n validatingSpinnerProps?.className,\n )}\n />\n )}\n\n {/* Pagination. */}\n <div\n role=\"status\"\n {...paginationProps}\n className={cx(\n prefix(\"issues-panel__pagination\"),\n paginationProps?.className,\n )}\n >\n {paginationLabel && currentPageIndex !== -1 && (\n <VisuallyHidden>\n {paginationLabel(currentPageIndex + 1, nPages)}\n </VisuallyHidden>\n )}\n <span aria-hidden>\n {currentPageIndex === -1 ? \"-\" : currentPageIndex + 1} / {nPages}\n </span>\n </div>\n\n {/* Focus button. */}\n <IconButton\n color={buttonsColor}\n icon={faArrowsToDot}\n {...focusButtonProps}\n className={cx(\n prefix(\"issues-panel__action\"),\n prefix(\"issues-panel__focus\"),\n focusButtonProps?.className,\n )}\n label={focusButtonLabel}\n keybinds={focusKeybinds}\n loading={focusButtonLoading}\n disabled={focusButtonDisabled}\n onClick={combineEventHandlers(\n focusButtonProps?.onClick,\n handleFocus,\n )}\n />\n\n {/* First issue button. */}\n <IconButton\n color={buttonsColor}\n icon={faAnglesLeft}\n {...firstIssueButtonProps}\n className={cx(\n prefix(\"issues-panel__action\"),\n prefix(\"issues-panel__first\"),\n firstIssueButtonProps?.className,\n )}\n label={firstIssueButtonLabel}\n keybinds={firstIssueKeybinds}\n disabled={firstIssueButtonDisabled}\n onClick={combineEventHandlers(\n firstIssueButtonProps?.onClick,\n goToFirstPage,\n )}\n />\n\n {/* Previous issue button. */}\n <IconButton\n color={buttonsColor}\n icon={faAngleLeft}\n {...previousIssueButtonProps}\n className={cx(\n prefix(\"issues-panel__action\"),\n prefix(\"issues-panel__previous\"),\n previousIssueButtonProps?.className,\n )}\n label={previousIssueButtonLabel}\n keybinds={previousIssueKeybinds}\n disabled={previousIssueButtonDisabled}\n onClick={combineEventHandlers(\n previousIssueButtonProps?.onClick,\n goToPreviousPage,\n )}\n />\n\n {/* Next issue button. */}\n <IconButton\n color={buttonsColor}\n icon={faAngleRight}\n {...nextIssueButtonProps}\n className={cx(\n prefix(\"issues-panel__action\"),\n prefix(\"issues-panel__next\"),\n nextIssueButtonProps?.className,\n )}\n label={nextIssueButtonLabel}\n keybinds={nextIssueKeybinds}\n disabled={nextIssueButtonDisabled}\n onClick={combineEventHandlers(\n nextIssueButtonProps?.onClick,\n goToNextPage,\n )}\n />\n\n {/* Last issue button. */}\n <IconButton\n color={buttonsColor}\n icon={faAnglesRight}\n {...lastIssueButtonProps}\n className={cx(\n prefix(\"issues-panel__action\"),\n prefix(\"issues-panel__last\"),\n lastIssueButtonProps?.className,\n )}\n label={lastIssueButtonLabel}\n keybinds={lastIssueKeybinds}\n disabled={lastIssueButtonDisabled}\n onClick={combineEventHandlers(\n lastIssueButtonProps?.onClick,\n goToLastPage,\n )}\n />\n </>\n )}\n\n {/* Close button. */}\n <CloseButton\n color={buttonsColor}\n {...closeButtonProps}\n className={cx(\n prefix(\"issues-panel__close-button\"),\n closeButtonProps?.className,\n )}\n onClick={combineEventHandlers(closeButtonProps?.onClick, closePanel, {\n checkDefaultPrevented: true,\n })}\n />\n </div>\n );\n}\n","import {\n faCircleCheck,\n faCircleExclamation,\n faTriangleExclamation,\n} from \"@fortawesome/free-solid-svg-icons\";\nimport type { AbsolutePath, ValidationIssueSeverity } from \"@ostack.tech/kform\";\nimport {\n type Controller,\n CurrentPath,\n type IssuesTrackerResult,\n useFormManager,\n} from \"@ostack.tech/kform-react\";\nimport {\n Card,\n CardBody,\n CardHeader,\n type CardProps,\n CardTitle,\n cx,\n Icon,\n type IconButtonColor,\n Layer,\n setBoolDataAttr,\n Spinner,\n useCombinedRef,\n useScrollPosition,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, useCallback, useMemo, useRef, useState } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useActiveIssuesPanelBreadcrumb, useIsRegistered } from \"../FormApp\";\nimport { IssueMessage } from \"../IssueMessage\";\nimport type { IssuesPanelProps } from \"./IssuesPanel.tsx\";\n\nexport interface IssuesPanelMessagesCardProps\n extends\n CardProps,\n Pick<\n IssuesPanelProps,\n | \"displayIssueCodes\"\n | \"unknownErrorMessage\"\n | \"unknownWarningMessage\"\n | \"errorsLabel\"\n | \"warningsLabel\"\n | \"noIssuesMessage\"\n | \"resolvedTitle\"\n | \"resolvedMessage\"\n | \"headerProps\"\n | \"bodyProps\"\n | \"loadingSpinnerProps\"\n | \"titleProps\"\n | \"iconProps\"\n > {\n currentPagePath: AbsolutePath | null;\n currentPageController: Controller;\n issuesTrackerResult: IssuesTrackerResult;\n currentPageIndex: number;\n renderControls: (buttonsColor?: IconButtonColor) => ReactNode;\n}\n\nexport function IssuesPanelMessagesCard({\n currentPagePath,\n currentPageController,\n issuesTrackerResult,\n currentPageIndex,\n errorsLabel,\n warningsLabel,\n noIssuesMessage,\n resolvedTitle,\n resolvedMessage,\n displayIssueCodes,\n unknownErrorMessage,\n unknownWarningMessage,\n renderControls,\n headerProps,\n bodyProps,\n loadingSpinnerProps,\n titleProps,\n iconProps,\n className,\n ref,\n ...otherProps\n}: IssuesPanelMessagesCardProps) {\n const prefix = usePrefix();\n const { initialized, info } = issuesTrackerResult;\n const nPages = info?.length ?? 0;\n const currentInfo = currentPageIndex === -1 ? null : info![currentPageIndex];\n const currentPageExists = currentPageController.useExists();\n\n // Relevant icon and colour\n const relevantIcon = initialized\n ? !currentInfo\n ? faCircleCheck\n : currentInfo.localDisplayStatus === \"error\"\n ? faCircleExclamation\n : faTriangleExclamation\n : undefined;\n const relevantColor = initialized\n ? nPages === 0\n ? \"success\"\n : !currentInfo\n ? \"primary\"\n : currentInfo.localDisplayStatus === \"error\"\n ? \"danger\"\n : \"warning\"\n : undefined;\n\n const hasErrors = currentInfo?.localDisplayStatus === \"error\";\n const hasWarnings =\n currentInfo?.localDisplayStatus === \"warning\" ||\n (currentInfo?.localDisplayStatus === \"error\" &&\n currentInfo.issues.some((issue) => issue.severity === \"warning\"));\n\n const formManager = useFormManager();\n const schema = useMemo(\n () => currentInfo && formManager.schema(currentInfo.path),\n [currentInfo, formManager],\n );\n\n // Whether the active issues panel path has been registered at all\n const isRegistered = useIsRegistered(currentPagePath);\n const [lastRegisteredPath, setLastRegisteredPath] =\n useState<AbsolutePath | null>(isRegistered ? currentPagePath : null);\n if (isRegistered && !lastRegisteredPath?.equals(currentPagePath)) {\n setLastRegisteredPath(currentPagePath);\n }\n const isOrWasLastRegistered =\n isRegistered || lastRegisteredPath?.equals(currentPagePath);\n\n // Sticky style for card header\n const [cardEl, setCardEl] = useState<HTMLDivElement | null>(null);\n const headerRef = useRef<HTMLDivElement | null>(null);\n useScrollPosition(\n cardEl,\n useCallback(\n (scrollPosition) =>\n setBoolDataAttr(\n headerRef.current,\n \"stuck\",\n (scrollPosition?.top ?? 0) > 0,\n ),\n [],\n ),\n );\n\n const renderIssuesList = (severity: ValidationIssueSeverity) =>\n (severity === \"error\" ? hasErrors : hasWarnings) && (\n <>\n <h3 className={prefix(\"issues-panel__issues-list-title\")}>\n {severity === \"error\" ? errorsLabel?.() : warningsLabel?.()}\n </h3>\n\n <ul className={prefix(\"issues-panel__issues-list\")}>\n {currentInfo!.issues\n .filter((issue) => issue.severity === severity)\n .map((issue, i) => (\n <li\n key={i}\n className={prefix(\"issues-panel__issue\")}\n data-severity={issue.severity}\n >\n <IssueMessage\n path={currentInfo!.path}\n issue={issue}\n schema={schema!}\n displayIssueCode={displayIssueCodes}\n unknownErrorMessage={unknownErrorMessage}\n unknownWarningMessage={unknownWarningMessage}\n issueCodeProps={{\n className: prefix(\"issues-panel__issue-code\"),\n }}\n />\n </li>\n ))}\n </ul>\n </>\n );\n\n const combinedCardRef = useCombinedRef(setCardEl, ref);\n const combinedHeaderRef = useCombinedRef(headerRef, headerProps?.ref);\n return (\n <Card\n variant=\"subtle\"\n mergeSections\n className={cx(\n prefix(\"issues-panel\"),\n prefix(\"issues-panel--messages\"),\n className,\n )}\n {...otherProps}\n color={relevantColor ?? \"neutral\"}\n ref={combinedCardRef}\n >\n <Layer zIndex=\"sticky\">\n <CardHeader\n {...headerProps}\n className={cx(prefix(\"issues-panel__header\"), headerProps?.className)}\n ref={combinedHeaderRef}\n >\n {renderControls(relevantColor ?? \"primary\")}\n\n {/* Initialisation spinner. */}\n {!initialized && (\n <Spinner\n size=\"lg\"\n {...loadingSpinnerProps}\n className={cx(\n prefix(\"issues-panel__loading-spinner\"),\n loadingSpinnerProps?.className,\n )}\n />\n )}\n\n {initialized && (\n <>\n {/* Panel icon. */}\n <Icon\n color={relevantColor}\n size=\"lg\"\n {...iconProps}\n className={cx(\n prefix(\"issues-panel__icon\"),\n iconProps?.className,\n )}\n icon={relevantIcon!}\n />\n\n <CardTitle\n {...titleProps}\n className={cx(\n prefix(\"issues-panel__title\"),\n titleProps?.className,\n )}\n >\n {nPages === 0 ? (\n noIssuesMessage\n ) : isOrWasLastRegistered ? (\n currentPageExists ? (\n <Breadcrumb />\n ) : (\n resolvedTitle\n )\n ) : (\n <Spinner\n size=\"lg\"\n {...loadingSpinnerProps}\n className={cx(\n prefix(\"issues-panel__loading-spinner\"),\n loadingSpinnerProps?.className,\n )}\n />\n )}\n </CardTitle>\n </>\n )}\n </CardHeader>\n </Layer>\n\n <CardBody\n {...bodyProps}\n className={cx(prefix(\"issues-panel__body\"), bodyProps?.className)}\n >\n {currentInfo && isOrWasLastRegistered && renderIssuesList(\"error\")}\n {currentInfo && isOrWasLastRegistered && renderIssuesList(\"warning\")}\n {!currentInfo && nPages > 0 && (\n <div className={prefix(\"issues-panel__resolved-message\")}>\n {resolvedMessage}\n </div>\n )}\n </CardBody>\n </Card>\n );\n}\n\nfunction Breadcrumb() {\n const prefix = usePrefix();\n const breadcrumb = useActiveIssuesPanelBreadcrumb();\n\n return (\n breadcrumb &&\n (breadcrumb.length === 1 ? breadcrumb : breadcrumb.slice(1)).map(\n ({ path, label }) => (\n <CurrentPath key={path.toString()} path={path}>\n <span className={prefix(\"issues-panel__breadcrumb-item\")}>\n {label}\n </span>\n </CurrentPath>\n ),\n )\n );\n}\n","import {\n faCircleCheck,\n faCircleExclamation,\n faTriangleExclamation,\n} from \"@fortawesome/free-solid-svg-icons\";\nimport type { IssuesTrackerResult } from \"@ostack.tech/kform-react\";\nimport {\n Card,\n CardHeader,\n type CardProps,\n CardTitle,\n cx,\n Icon,\n type IconButtonColor,\n Layer,\n Spinner,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport type { IssuesPanelProps } from \"./IssuesPanel.tsx\";\n\nexport interface IssuesPanelSummaryCardProps\n extends\n CardProps,\n Pick<\n IssuesPanelProps,\n | \"errorsLabel\"\n | \"warningsLabel\"\n | \"noIssuesMessage\"\n | \"headerProps\"\n | \"loadingSpinnerProps\"\n | \"titleProps\"\n | \"iconProps\"\n > {\n issuesTrackerResult: IssuesTrackerResult;\n renderControls: (buttonsColor?: IconButtonColor) => ReactNode;\n}\n\nexport function IssuesPanelSummaryCard({\n issuesTrackerResult,\n errorsLabel,\n warningsLabel,\n noIssuesMessage,\n renderControls,\n headerProps,\n loadingSpinnerProps,\n titleProps,\n iconProps,\n className,\n ...otherProps\n}: IssuesPanelSummaryCardProps) {\n const prefix = usePrefix();\n const { initialized, info, errors, warnings } = issuesTrackerResult;\n const nPages = info?.length ?? 0;\n\n // Relevant icon and colour\n const relevantIcon = initialized\n ? errors > 0\n ? faCircleExclamation\n : warnings > 0\n ? faTriangleExclamation\n : faCircleCheck\n : undefined;\n const relevantColor = initialized\n ? errors > 0\n ? \"danger\"\n : warnings > 0\n ? \"warning\"\n : \"success\"\n : undefined;\n\n return (\n <Card\n variant=\"subtle\"\n mergeSections\n className={cx(\n prefix(\"issues-panel\"),\n prefix(\"issues-panel--summary\"),\n className,\n )}\n {...otherProps}\n color={initialized ? relevantColor : \"neutral\"}\n >\n <Layer zIndex=\"sticky\">\n <CardHeader\n {...headerProps}\n className={cx(prefix(\"issues-panel__header\"), headerProps?.className)}\n >\n {/* Initialisation spinner. */}\n {!initialized && (\n <Spinner\n size=\"lg\"\n {...loadingSpinnerProps}\n className={cx(\n prefix(\"issues-panel__loading-spinner\"),\n loadingSpinnerProps?.className,\n )}\n />\n )}\n\n {initialized && (\n <>\n {/* Panel icon. */}\n <Icon\n color={relevantColor}\n size=\"lg\"\n {...iconProps}\n className={cx(\n prefix(\"issues-panel__icon\"),\n iconProps?.className,\n )}\n icon={relevantIcon!}\n />\n\n <CardTitle\n role=\"status\"\n {...titleProps}\n className={cx(\n prefix(\"issues-panel__title\"),\n titleProps?.className,\n )}\n >\n {nPages === 0 && noIssuesMessage}\n {nPages > 0 && (\n <>\n {errors > 0 && errorsLabel?.(errors)}\n {errors > 0 && warnings > 0 && \", \"}\n {warnings > 0 && warningsLabel?.(warnings)}\n </>\n )}\n </CardTitle>\n </>\n )}\n\n {renderControls(relevantColor)}\n </CardHeader>\n </Layer>\n </Card>\n );\n}\n","import {\n AbsolutePath,\n AbsolutePathFragment,\n compareSchemaPaths,\n type Schema,\n} from \"@ostack.tech/kform\";\nimport {\n type IssuesTrackerOptions,\n type LocatedValidationInfo,\n useController,\n useFormManager,\n useIssuesTracker,\n} from \"@ostack.tech/kform-react\";\nimport {\n type CardBodyProps,\n type CardHeaderProps,\n type CardProps,\n type CardTitleProps,\n type CloseButtonProps,\n Container,\n cx,\n type IconButtonColor,\n type IconButtonProps,\n type IconProps,\n Layer,\n setBoolDataAttr,\n type SpinnerProps,\n useCombinedRef,\n useControllableState,\n useIntersectionObserver,\n useLatestRef,\n useMeasure,\n usePrevious,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type ReactNode,\n useCallback,\n useDeferredValue,\n useEffect,\n useEffectEvent,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useReportValidationFailures } from \"../../utils/useReportValidationFailures.ts\";\nimport {\n useFocus,\n useFormAppElement,\n useIssuesDisplayMode,\n useSetBottomPanelHeight,\n} from \"../FormApp\";\nimport {\n useIssuesPanelPath,\n useLatestInteraction,\n useSetStartIssuesNavigation,\n} from \"../FormApp/FormAppContext.ts\";\nimport { IssuesPanelControls } from \"./IssuesPanelControls.tsx\";\nimport { IssuesPanelMessagesCard } from \"./IssuesPanelMessagesCard.tsx\";\nimport { IssuesPanelSummaryCard } from \"./IssuesPanelSummaryCard.tsx\";\n\n/** Default “focus” keybinds. */\nexport const DEFAULT_FOCUS_KEYBINDS = \"Alt+Shift+F\";\n/** Default “previous issue” keybinds. */\nexport const DEFAULT_PREVIOUS_ISSUE_KEYBINDS = \"Alt+Shift+ArrowLeft\";\n/** Default “next issue” keybinds. */\nexport const DEFAULT_NEXT_ISSUE_KEYBINDS = \"Alt+Shift+ArrowRight\";\n/** Default “first issue” keybinds. */\nexport const DEFAULT_FIRST_ISSUE_KEYBINDS = \"Alt+Shift+Home\";\n/** Default “last issue” keybinds. */\nexport const DEFAULT_LAST_ISSUE_KEYBINDS = \"Alt+Shift+End\";\n\n/** Properties of the issues navigation component. */\nexport interface IssuesPanelProps\n extends\n Pick<IssuesTrackerOptions, \"issuesOrderCompareFn\">,\n Omit<CardProps, \"children\" | \"variant\" | \"color\"> {\n /** Default open state of the issues navigation panel. */\n defaultOpen?: boolean;\n /** Controlled open state of the issues navigation panel. */\n open?: boolean;\n /**\n * Function called whenever the open state of the issues navigation panel\n * changes.\n *\n * @param open New open state.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Whether to display issue codes together with each issue message.\n *\n * This property can also be set globally via the `displayIssueCodes` property\n * of the `FormApp`.\n */\n displayIssueCodes?: boolean;\n /**\n * Message to show for an error that does not have an associated message.\n *\n * This message will always automatically include the code of the issue in\n * question.\n */\n unknownErrorMessage?: ReactNode;\n /**\n * Message to show for a warning that does not have an associated message.\n *\n * This message will always automatically include the code of the issue in\n * question.\n */\n unknownWarningMessage?: ReactNode;\n /**\n * Errors label.\n *\n * @param errors Number of errors. If undefined, the function should return a\n * generic label with no number.\n */\n errorsLabel?: (errors?: number) => ReactNode;\n /**\n * Warnings label.\n *\n * @param warnings Number of warnings. If undefined, the function should\n * return a generic label with no number.\n */\n warningsLabel?: (warnings?: number) => ReactNode;\n /** Label of the focus button. */\n focusButtonLabel?: string;\n /** Keybinds to trigger the \"focus\" button. */\n focusKeybinds?: string | string[] | null;\n /** Label of the \"previous issue\" button. */\n previousIssueButtonLabel?: string;\n /** Keybinds to trigger the \"previous issue\" button. */\n previousIssueKeybinds?: string | string[] | null;\n /** Label of the \"next issue\" button. */\n nextIssueButtonLabel?: string;\n /** Keybinds to trigger the \"next issue\" button. */\n nextIssueKeybinds?: string | string[] | null;\n /** Label of the \"first issue\" button. */\n firstIssueButtonLabel?: string;\n /** Keybinds to trigger the \"first issue\" button. */\n firstIssueKeybinds?: string | string[] | null;\n /** Label of the \"last issue\" button. */\n lastIssueButtonLabel?: string;\n /** Keybinds to trigger the \"last issue\" button. */\n lastIssueKeybinds?: string | string[] | null;\n /**\n * Text announced to assistive technologies with the current page out of the\n * total number of pages.\n *\n * @param currentPage Current page.\n * @param totalPages Total number of pages.\n */\n paginationLabel?: (currentPage: number, totalPages: number) => ReactNode;\n /** Message to display when there are no issues to report. */\n noIssuesMessage?: ReactNode;\n /** Title to display when all issues of the active path have been resolved. */\n resolvedTitle?: ReactNode;\n /** Message to display when all issues of the active path have been resolved. */\n resolvedMessage?: ReactNode;\n /** Properties to pass to the container element. */\n containerProps?: ComponentProps<\"div\">;\n /** Properties to pass to the card header component. */\n headerProps?: CardHeaderProps;\n /** Properties to pass to the card body component. */\n bodyProps?: CardBodyProps;\n /** Properties to pass to the loading `Spinner` component. */\n loadingSpinnerProps?: SpinnerProps;\n /** Properties to pass to the validating `Spinner` component. */\n validatingSpinnerProps?: SpinnerProps;\n /** Properties to pass to the pagination element. */\n paginationProps?: ComponentProps<\"div\">;\n /** Properties to pass to the \"focus\" button component. */\n focusButtonProps?: Omit<IconButtonProps, \"label\">;\n /** Properties to pass to the \"previous issue\" button component. */\n previousIssueButtonProps?: Omit<IconButtonProps, \"label\">;\n /** Properties to pass to the \"next issue\" button component. */\n nextIssueButtonProps?: Omit<IconButtonProps, \"label\">;\n /** Properties to pass to the \"first issue\" button component. */\n firstIssueButtonProps?: Omit<IconButtonProps, \"label\">;\n /** Properties to pass to the \"last issue\" button component. */\n lastIssueButtonProps?: Omit<IconButtonProps, \"label\">;\n /** Properties to pass to the icon component. */\n iconProps?: Omit<IconProps, \"icon\">;\n /** Properties to pass to the title component. */\n titleProps?: CardTitleProps;\n /** Properties to pass to the close button component. */\n closeButtonProps?: CloseButtonProps;\n}\n\n/** Component used to navigate through the issues of the form. */\nexport function IssuesPanel({\n defaultOpen = false,\n open: controlledOpen,\n onOpenChange,\n displayIssueCodes,\n issuesOrderCompareFn,\n unknownErrorMessage,\n unknownWarningMessage,\n errorsLabel,\n warningsLabel,\n focusButtonLabel,\n focusKeybinds: focusKeybindsProp,\n previousIssueButtonLabel,\n previousIssueKeybinds: previousIssueKeybindsProp,\n nextIssueButtonLabel,\n nextIssueKeybinds: nextIssueKeybindsProp,\n firstIssueButtonLabel,\n firstIssueKeybinds: firstIssueKeybindsProp,\n lastIssueButtonLabel,\n lastIssueKeybinds: lastIssueKeybindsProp,\n paginationLabel,\n noIssuesMessage,\n resolvedTitle,\n resolvedMessage,\n containerProps,\n headerProps,\n bodyProps,\n loadingSpinnerProps,\n validatingSpinnerProps,\n paginationProps,\n focusButtonProps,\n previousIssueButtonProps,\n nextIssueButtonProps,\n firstIssueButtonProps,\n lastIssueButtonProps,\n titleProps,\n iconProps,\n closeButtonProps,\n ...otherProps\n}: IssuesPanelProps) {\n const prefix = usePrefix();\n const printing = usePrinting();\n const [locale] = useLocale();\n errorsLabel ??= locale.IssuesPanel.errorsLabel;\n warningsLabel ??= locale.IssuesPanel.warningsLabel;\n focusButtonLabel ??= locale.IssuesPanel.focusButtonLabel;\n const focusKeybinds =\n focusKeybindsProp === undefined\n ? (locale.IssuesPanel.focusKeybinds ?? DEFAULT_FOCUS_KEYBINDS)\n : focusKeybindsProp;\n previousIssueButtonLabel ??= locale.IssuesPanel.previousIssueButtonLabel;\n const previousIssueKeybinds =\n previousIssueKeybindsProp === undefined\n ? (locale.IssuesPanel.previousIssueKeybinds ??\n DEFAULT_PREVIOUS_ISSUE_KEYBINDS)\n : previousIssueKeybindsProp;\n nextIssueButtonLabel ??= locale.IssuesPanel.nextIssueButtonLabel;\n const nextIssueKeybinds =\n nextIssueKeybindsProp === undefined\n ? (locale.IssuesPanel.nextIssueKeybinds ?? DEFAULT_NEXT_ISSUE_KEYBINDS)\n : nextIssueKeybindsProp;\n firstIssueButtonLabel ??= locale.IssuesPanel.firstIssueButtonLabel;\n const firstIssueKeybinds =\n firstIssueKeybindsProp === undefined\n ? (locale.IssuesPanel.firstIssueKeybinds ?? DEFAULT_FIRST_ISSUE_KEYBINDS)\n : firstIssueKeybindsProp;\n lastIssueButtonLabel ??= locale.IssuesPanel.lastIssueButtonLabel;\n const lastIssueKeybinds =\n lastIssueKeybindsProp === undefined\n ? (locale.IssuesPanel.lastIssueKeybinds ?? DEFAULT_LAST_ISSUE_KEYBINDS)\n : lastIssueKeybindsProp;\n paginationLabel ??= locale.IssuesPanel.paginationLabel;\n noIssuesMessage ??= locale.IssuesPanel.noIssuesMessage;\n resolvedTitle ??= locale.IssuesPanel.resolvedTitle;\n resolvedMessage ??= locale.IssuesPanel.resolvedMessage;\n\n const [open, setOpen] = useControllableState(defaultOpen, controlledOpen);\n const formIsLoading = useFormIsLoading();\n const issuesTrackerResult = useIssuesTracker(AbsolutePath.MATCH_ALL, {\n enabled: open && !formIsLoading && !printing,\n issuesOrderCompareFn,\n });\n useReportValidationFailures(issuesTrackerResult.info);\n const latestInteraction = useLatestInteraction();\n const deferredIssuesTrackerResult = useDeferredValue(issuesTrackerResult);\n const { info } = deferredIssuesTrackerResult;\n const nPages = info?.length ?? 0;\n\n const [currentPagePath, setCurrentPagePath] = useIssuesPanelPath();\n const currentPageController = useController(\n currentPagePath ?? AbsolutePath.ROOT,\n { enabled: open && !formIsLoading && currentPagePath !== null },\n );\n\n // Set the current page path as the latest interaction when going from \"no\n // issues\" to \"issues exist\"\n const prevIssuesTrackerResultInfoLength = usePrevious(\n issuesTrackerResult.info?.length,\n );\n const handleNewIssues = useEffectEvent(() => {\n setCurrentPagePath(latestInteraction);\n });\n useEffect(() => {\n if (\n prevIssuesTrackerResultInfoLength === 0 &&\n issuesTrackerResult.initialized &&\n issuesTrackerResult.info.length > 0\n ) {\n handleNewIssues();\n }\n }, [\n issuesTrackerResult.info?.length,\n issuesTrackerResult.initialized,\n prevIssuesTrackerResultInfoLength,\n ]);\n\n // Index of the page with the current path\n const currentPageIndex = useMemo(\n () =>\n currentPagePath\n ? (info?.findIndex(({ path }) => currentPagePath.equals(path)) ?? -1)\n : -1,\n [currentPagePath, info],\n );\n // Keep track of the last existing page index that we've visited\n const lastExistingPageIndex = useRef<number | null>(null);\n useEffect(() => {\n if (currentPageIndex !== -1) {\n lastExistingPageIndex.current = currentPageIndex;\n }\n }, [currentPageIndex]);\n\n // Go to a specified page and focus its respective field\n const focus = useFocus();\n const goToPath = useCallback(\n (path: AbsolutePath | null) => {\n setCurrentPagePath(path);\n if (path) {\n focus(path);\n }\n },\n [focus, setCurrentPagePath],\n );\n const goToPage = useCallback(\n (page: number) => {\n if (nPages > 0) {\n const clampedPage = Math.max(0, Math.min(page, nPages - 1));\n const newCurrentPath = info![clampedPage].path ?? null;\n goToPath(newCurrentPath);\n }\n },\n [goToPath, info, nPages],\n );\n const goToPreviousPage = useCallback(() => {\n if (currentPageIndex !== -1) {\n goToPage(currentPageIndex - 1);\n } else {\n goToPage((lastExistingPageIndex.current ?? 1) - 1);\n }\n }, [currentPageIndex, goToPage]);\n const goToNextPage = useCallback(() => {\n if (currentPageIndex !== -1) {\n goToPage(currentPageIndex + 1);\n } else {\n goToPage(lastExistingPageIndex.current ?? 0);\n }\n }, [currentPageIndex, goToPage]);\n const goToFirstPage = useCallback(() => goToPage(0), [goToPage]);\n const goToLastPage = useCallback(\n () => goToPage(nPages - 1),\n [goToPage, nPages],\n );\n\n const formManager = useFormManager();\n const formSchema = useMemo(() => formManager.schema(), [formManager]);\n const latestRef = useLatestRef({ issuesOrderCompareFn, onOpenChange });\n\n // Focus initial issue when starting\n const [starting, setStarting] = useState(false);\n useEffect(() => {\n if (issuesTrackerResult.initialized && starting) {\n if (issuesTrackerResult.info.length > 0) {\n goToPath(\n mostRelevantIssuePath(\n issuesTrackerResult.info,\n latestInteraction,\n formSchema,\n latestRef.current.issuesOrderCompareFn,\n ),\n );\n }\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setStarting(false);\n }\n }, [\n formSchema,\n goToPath,\n issuesTrackerResult.info,\n issuesTrackerResult.initialized,\n latestInteraction,\n latestRef,\n starting,\n ]);\n\n // Starts the issues navigation\n const start = useCallback(() => {\n if (!open) {\n setOpen(true);\n latestRef.current.onOpenChange?.(true);\n }\n setCurrentPagePath(null);\n setStarting(true);\n lastExistingPageIndex.current = null;\n }, [latestRef, open, setCurrentPagePath, setOpen]);\n\n // Expose the `start` function to the form app\n useSetStartIssuesNavigation(start);\n\n // Keep track of the container's height\n const [containerEl, setContainerEl] = useState<HTMLDivElement | null>(null);\n const setBottomPanelHeight = useSetBottomPanelHeight();\n useMeasure(\n containerEl,\n useCallback(\n (measurement) => setBottomPanelHeight(measurement?.height),\n [setBottomPanelHeight],\n ),\n );\n\n // Sticky style for panel\n const formAppEl = useFormAppElement();\n useIntersectionObserver(\n containerEl,\n useCallback(\n (e) => setBoolDataAttr(containerEl, \"stuck\", e.intersectionRatio === 1),\n [containerEl],\n ),\n useMemo(\n () => ({\n root: formAppEl,\n rootMargin: `0px 0px -1px 0px`,\n threshold: [1],\n }),\n [formAppEl],\n ),\n );\n\n // Hides the issues panel\n const close = useCallback(() => {\n if (open) {\n setOpen(false);\n latestRef.current.onOpenChange?.(false);\n }\n }, [latestRef, open, setOpen]);\n\n const renderControls = (buttonsColor?: IconButtonColor) => (\n <IssuesPanelControls\n nPages={nPages}\n currentPagePath={currentPagePath}\n currentPageIndex={currentPageIndex}\n currentPageController={currentPageController}\n goToPreviousPage={goToPreviousPage}\n goToNextPage={goToNextPage}\n goToFirstPage={goToFirstPage}\n goToLastPage={goToLastPage}\n buttonsColor={buttonsColor}\n closePanel={close}\n focusButtonLabel={focusButtonLabel}\n focusKeybinds={focusKeybinds}\n previousIssueButtonLabel={previousIssueButtonLabel}\n previousIssueKeybinds={previousIssueKeybinds}\n nextIssueButtonLabel={nextIssueButtonLabel}\n nextIssueKeybinds={nextIssueKeybinds}\n firstIssueButtonLabel={firstIssueButtonLabel}\n firstIssueKeybinds={firstIssueKeybinds}\n lastIssueButtonLabel={lastIssueButtonLabel}\n lastIssueKeybinds={lastIssueKeybinds}\n paginationLabel={paginationLabel}\n validatingSpinnerProps={validatingSpinnerProps}\n paginationProps={paginationProps}\n focusButtonProps={focusButtonProps}\n previousIssueButtonProps={previousIssueButtonProps}\n nextIssueButtonProps={nextIssueButtonProps}\n firstIssueButtonProps={firstIssueButtonProps}\n lastIssueButtonProps={lastIssueButtonProps}\n closeButtonProps={closeButtonProps}\n />\n );\n\n const displayMode = useIssuesDisplayMode();\n const combinedContainerRef = useCombinedRef(\n setContainerEl,\n containerProps?.ref,\n );\n return (\n open &&\n !printing && (\n <Layer zIndex={[\"docked\", 1]}>\n <div\n {...containerProps}\n className={cx(\n prefix(\"issues-panel__container\"),\n containerProps?.className,\n )}\n ref={combinedContainerRef}\n >\n <Container asChild fluid=\"md\">\n {displayMode === \"inline\" ? (\n <IssuesPanelSummaryCard\n issuesTrackerResult={deferredIssuesTrackerResult}\n renderControls={renderControls}\n errorsLabel={errorsLabel}\n warningsLabel={warningsLabel}\n noIssuesMessage={noIssuesMessage}\n headerProps={headerProps}\n loadingSpinnerProps={loadingSpinnerProps}\n titleProps={titleProps}\n iconProps={iconProps}\n {...otherProps}\n />\n ) : (\n <IssuesPanelMessagesCard\n currentPagePath={currentPagePath}\n currentPageController={currentPageController}\n issuesTrackerResult={deferredIssuesTrackerResult}\n currentPageIndex={currentPageIndex}\n displayIssueCodes={displayIssueCodes}\n unknownErrorMessage={unknownErrorMessage}\n unknownWarningMessage={unknownWarningMessage}\n renderControls={renderControls}\n errorsLabel={errorsLabel}\n warningsLabel={warningsLabel}\n noIssuesMessage={noIssuesMessage}\n resolvedTitle={resolvedTitle}\n resolvedMessage={resolvedMessage}\n headerProps={headerProps}\n bodyProps={bodyProps}\n loadingSpinnerProps={loadingSpinnerProps}\n titleProps={titleProps}\n iconProps={iconProps}\n {...otherProps}\n />\n )}\n </Container>\n </div>\n </Layer>\n )\n );\n}\n\n/**\n * Function attempting to return the \"most relevant\" issue, given the list of\n * issue information, the path of the current page, and the path the user last\n * interacted with.\n */\nfunction mostRelevantIssuePath(\n info: LocatedValidationInfo[],\n latestInteraction: AbsolutePath,\n formSchema: Schema,\n issuesOrderCompareFn: IssuesTrackerOptions[\"issuesOrderCompareFn\"],\n): AbsolutePath {\n // Try to match the latest interaction exactly when a custom\n // `issuesOrderCompareFn` is provided, since we have no guarantee that the\n // first issue >= latest interaction will be the latest interaction itself\n // when it has an issue\n if (issuesOrderCompareFn) {\n for (const infoIssues of info) {\n if (latestInteraction.equals(infoIssues.path)) {\n return latestInteraction;\n }\n }\n }\n\n // Find index of first issues path >= latest interaction; if no such path\n // exists, set this index to the size of the info\n let indexOfInfoPathGteActivePath = info.findIndex(\n (issuesInfo) =>\n (issuesOrderCompareFn?.(issuesInfo.path, latestInteraction) ||\n compareSchemaPaths(formSchema, issuesInfo.path, latestInteraction)) >=\n 0,\n );\n if (indexOfInfoPathGteActivePath === -1) {\n indexOfInfoPathGteActivePath = info.length;\n }\n\n // Match a descendant of the latest interaction, or a descendant of one of its\n // ancestors\n let curPath = latestInteraction;\n while (!curPath.isRoot) {\n const curPathWithDescendants = curPath.append(\n AbsolutePathFragment.RecursiveWildcard,\n );\n for (let i = indexOfInfoPathGteActivePath; i < info.length; ++i) {\n if (curPathWithDescendants.matches(info[i].path)) {\n return info[i].path;\n }\n }\n for (let i = indexOfInfoPathGteActivePath - 1; i >= 0; --i) {\n if (curPathWithDescendants.matches(info[i].path)) {\n return info[i].path;\n }\n }\n curPath = curPath.parent();\n }\n return info[0].path;\n}\n","import { faFolderOpen } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n Button,\n type ButtonProps,\n combineEventHandlers,\n useKeyboardShortcut,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport {\n type FormLoaderOptions,\n useFormIsLoading,\n useFormLoader,\n} from \"../../utils/useFormLoader.tsx\";\nimport {\n useFormAppElement,\n useFormIsDisabled,\n useFormIsReadOnly,\n} from \"../FormApp\";\n\n/** Default “load” keybinds. */\nexport const DEFAULT_LOAD_KEYBINDS = \"$mod+O\";\n\n/** Properties of the load action. */\nexport interface LoadActionProps<T = unknown>\n extends Omit<ButtonProps, \"children\">, Omit<FormLoaderOptions<T>, \"id\"> {\n /** Action's label. */\n label?: ReactNode;\n /**\n * Keybinds for triggering the action. Set to `null` to disable the keyboard\n * shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * {@link DEFAULT_LOAD_KEYBINDS}.\n */\n keybinds?: string | string[] | null;\n /**\n * Whether to show the load action when the form is read-only.\n *\n * @default false\n */\n showWhenReadOnly?: boolean;\n /**\n * By specifying a filesystem ID, the user agent can remember different\n * directories for different IDs.\n */\n fileSystemId?: string;\n}\n\n/**\n * Form action used to load the form from a file. Built on top of the [`Button`\n * component](/docs/ostack-ui-forms-button--docs) and `useFormLoader` hook.\n *\n * Example usage:\n *\n * ```tsx\n * import { LoadAction } from \"@ostack.tech/ui-kform\";\n *\n * function LoadForm() {\n * return (\n * <LoadAction\n * decode={async (file) => decodeFormFromJSON(await file.text())}\n * mimeTypes={[\"application/json\"]}\n * extensions={[\".json\"]}\n * />\n * );\n * }\n * ```\n */\nexport function LoadAction<T = unknown>({\n label,\n keybinds,\n showWhenReadOnly,\n fileSystemId,\n loading,\n disabled,\n onClick,\n decode,\n path,\n extensions,\n mimeTypes,\n description,\n startIn,\n setPristineOnLoad,\n validateOnLoad,\n successMessage,\n errorMessage,\n ...otherProps\n}: LoadActionProps<T>) {\n const [locale] = useLocale();\n label ??= locale.LoadAction.label;\n if (keybinds === undefined) {\n keybinds = locale.LoadAction.keybinds ?? DEFAULT_LOAD_KEYBINDS;\n }\n\n const { load } = useFormLoader({\n decode,\n path,\n extensions,\n mimeTypes,\n description,\n startIn,\n id: fileSystemId,\n setPristineOnLoad,\n validateOnLoad,\n successMessage,\n errorMessage,\n });\n const formIsDisabled = useFormIsDisabled();\n const formIsReadOnly = useFormIsReadOnly();\n const formIsLoading = useFormIsLoading();\n\n const showAction = !formIsReadOnly || showWhenReadOnly;\n const showDisabled = disabled || formIsDisabled;\n const showLoading = loading || formIsLoading;\n\n // Set-up keyboard shortcut\n const formAppEl = useFormAppElement();\n useKeyboardShortcut(keybinds, () => load(), {\n disabled: !showAction || showDisabled || showLoading,\n target: formAppEl,\n preventDefault: true,\n });\n\n return (\n showAction && (\n <Button\n vertical\n variant=\"subtle\"\n icon={faFolderOpen}\n {...otherProps}\n onClick={combineEventHandlers(() => load(), onClick as never)}\n disabled={showDisabled}\n loading={showLoading}\n keybinds={keybinds}\n >\n {label}\n </Button>\n )\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n formatNumericAsString,\n type Numeric,\n type NumericInputController,\n type NumericInputOptions,\n useNumericInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n NumericInput,\n type NumericInputProps,\n type NumericValueRepresentations,\n useCombinedRef,\n useLatestRef,\n warnOnce,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useState,\n} from \"react\";\n\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\n\n/** Kotlin integer types. */\nconst INTEGER_TYPES = [\"Byte\", \"Char\", \"Short\", \"Int\", \"Long\", \"BigInteger\"];\n\n/** Properties of the numeric control component. */\nexport interface NumericControlProps<T extends Numeric | null = Numeric | null>\n extends\n Omit<\n NumericInputOptions<T, string, ComponentRef<typeof NumericInput>>,\n \"enabled\" | \"formatFromString\" | \"parseToString\"\n >,\n Omit<\n NumericInputProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"valueIsUnformattedString\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | NumericInputController<T, string, ComponentRef<typeof NumericInput>>\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The numeric control component is a KForm form control for values with\n * (typically nullable) numeric schemas. It is built on top of the\n * [`NumericInput`](/docs/ostack-ui-forms-numeric-input--docs) component.\n *\n * The following (typically\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * KForm schemas are supported:\n * [`ByteSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-byte-schema/index.html),\n * [`CharSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-char-schema/index.html),\n * [`ShortSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-short-schema/index.html),\n * [`IntSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-int-schema/index.html),\n * [`LongSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-long-schema/index.html),\n * [`FloatSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-float-schema/index.html),\n * [`DoubleSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-double-schema/index.html),\n * [`BigIntegerSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-big-integer-schema/index.html),\n * [`BigDecimalSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-big-decimal-schema/index.html),\n * and\n * [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Min`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min/index.html)/[`Max`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max/index.html)/[`ExclusiveMin`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-min/index.html)/[`ExclusiveMax`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-max/index.html):\n * Sets the `min`/`max`/`minExclusive`/`maxExclusive` properties.\n * - [`Scale`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-scale/index.html)/[`MaxScale`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-scale/index.html):\n * Sets the `scale` property.\n *\n * The `valueIsInteger` property is further automatically set for integer\n * schemas (`Byte`, `Char`, `Short`, `Int`, `Long`, and `BigInteger`).\n *\n * Example usage:\n *\n * ```tsx\n * import { NumericControl } from \"@ostack.tech/ui-kform\";\n *\n * function QuantityControl() {\n * return (\n * <NumericControl path=\"/quantity\" placeholder=\"Number of items…\" />\n * );\n * }\n * ```\n */\nexport function NumericControl<T extends Numeric | null = Numeric | null>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n valueIsInteger,\n scale,\n required,\n min,\n max,\n exclusiveMin,\n exclusiveMax,\n loading,\n showSpinner,\n disabled,\n readOnly,\n endAdornment,\n onFocus,\n onBlurToOutside,\n debug,\n ref,\n ...otherProps\n}: NumericControlProps<T>) {\n const [stringValue, setStringValue] = useState(\"\");\n const controller = useNumericInput<\n T,\n string,\n ComponentRef<typeof NumericInput>\n >(path, {\n enabled: !useFormIsLoading(),\n setFormattedValue: setStringValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLInputElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const latestRef = useLatestRef({ stringValue });\n const handleValueChange = useCallback(\n ({ stringValue }: NumericValueRepresentations) => {\n if (stringValue !== latestRef.current.stringValue) {\n inputProps.onChange(stringValue);\n setStringValue(stringValue);\n }\n },\n [inputProps, latestRef],\n );\n\n const schemaIsInteger = INTEGER_TYPES.includes(schema.typeInfo.name);\n if (schemaIsInteger && valueIsInteger !== undefined) {\n warnOnce(\n `NumericControl: At '${absolutePath.toString()}': Property ` +\n \"`valueIsInteger` has no effect (it will always be `true`) when the \" +\n \"control's schema is one of the integer types.\",\n );\n }\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedNumericInputRef = useCombinedRef(\n inputProps.ref,\n autofocusRef,\n ref,\n );\n return (\n <FeedbackProvider>\n <NumericInput\n value={stringValue}\n valueIsUnformattedString\n valueIsInteger={schemaIsInteger || valueIsInteger}\n scale={\n scale ??\n (restrictions.maxScale == null\n ? undefined\n : (restrictions.maxScale as number))\n }\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n min={\n min ??\n (restrictions.min == null\n ? undefined\n : formatNumericAsString(restrictions.min as T, schema))\n }\n max={\n max ??\n (restrictions.max == null\n ? undefined\n : formatNumericAsString(restrictions.max as T, schema))\n }\n exclusiveMin={\n exclusiveMin ??\n (restrictions.exclusiveMin == null\n ? undefined\n : formatNumericAsString(restrictions.exclusiveMin as T, schema))\n }\n exclusiveMax={\n exclusiveMax ??\n (restrictions.exclusiveMax == null\n ? undefined\n : formatNumericAsString(restrictions.exclusiveMax as T, schema))\n }\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedNumericInputRef}\n />\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport { useResolvedPath } from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n Link,\n type LinkAs,\n type LinkOwnProps,\n type PolymorphicProps,\n} from \"@ostack.tech/ui\";\nimport type { MouseEvent } from \"react\";\n\nimport { useFocus } from \"../FormApp\";\n\n/** Elements a path link can be rendered as. */\nexport type PathLinkAs = LinkAs;\n\n/** Properties of the path link component. */\nexport type PathLinkProps<TAs extends PathLinkAs = \"button\"> = PolymorphicProps<\n PathLinkAs,\n TAs,\n \"button\",\n PathLinkOwnProps\n>;\n\n/** Own properties of the path link component. */\nexport interface PathLinkOwnProps extends LinkOwnProps {\n /** KForm path to link to. */\n to: string | Path;\n}\n\n/** Link to a KForm path. */\nexport function PathLink<TAs extends PathLinkAs = \"button\">({\n as = \"button\" as never,\n to,\n onClick,\n ...otherProps\n}: PathLinkProps<TAs>) {\n const focus = useFocus();\n const path = useResolvedPath(to);\n\n const handleClick = (evt: MouseEvent) => {\n evt.preventDefault();\n focus(path);\n };\n\n return (\n <Link\n as={as}\n {...(otherProps as any)}\n onClick={combineEventHandlers(onClick as never, handleClick, {\n checkDefaultPrevented: true,\n })}\n />\n );\n}\n","import { faPrint } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n Button,\n type ButtonProps,\n combineEventHandlers,\n PrinterTrigger,\n useKeyboardShortcut,\n usePrint,\n usePrinterDocumentTitle,\n usePrintInProgress,\n} from \"@ostack.tech/ui\";\nimport type { MouseEvent, ReactNode } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport {\n useFormAppElement,\n useFormIsDisabled,\n useFormIsReadOnly,\n useFormTitle,\n} from \"../FormApp\";\n\n/** Default “print” keybinds. */\nexport const DEFAULT_PRINT_KEYBINDS = \"$mod+P\";\n\n/** Properties of the print action. */\nexport interface PrintActionProps extends Omit<ButtonProps, \"children\"> {\n /** Action's label. */\n label?: ReactNode;\n /**\n * Keybinds for triggering the action. Set to `null` to disable the keyboard\n * shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * `DEFAULT_PRINT_KEYBINDS`.\n */\n keybinds?: string | string[] | null;\n /**\n * Whether to show the print action when the form is read-only.\n *\n * @default true\n */\n showWhenReadOnly?: boolean;\n}\n\n/**\n * Form action used to print the form application. Built on top of the\n * [`Button`](/docs/ostack-ui-forms-button--docs) and\n * [`PrinterTrigger`](/docs/ostack-ui-utilities-printer--docs) components.\n *\n * To print a whole form application, requires the `<FormApp>` component to be\n * wrapped within a `<Printer>`, and for the `<PrinterContent>` to wrap all\n * annexes, pages, and form controls.\n *\n * Example usage:\n *\n * ```tsx\n * import { Printer, PrinterContent } from \"@ostack.tech/ui\";\n * import {\n * FormApp,\n * PrintAction,\n * TopBar,\n * TopBarActions,\n * } from \"@ostack.tech/ui-kform\";\n *\n * export function App() {\n * return (\n * <Printer>\n * <FormApp schema={…}>\n * <PrinterContent>\n * <TopBar>\n * …\n * <TopBarActions>\n * …\n * <PrintAction />\n * </TopBarActions>\n * </TopBar>\n * …\n * </PrinterContent>\n * </FormApp>\n * </Printer>\n * );\n * }\n * ```\n */\nexport function PrintAction({\n label,\n keybinds,\n showWhenReadOnly = true,\n disabled,\n loading,\n onClick,\n ...otherProps\n}: PrintActionProps) {\n const [locale] = useLocale();\n label ??= locale.PrintAction.label;\n if (keybinds === undefined) {\n keybinds = locale.PrintAction.keybinds ?? DEFAULT_PRINT_KEYBINDS;\n }\n\n const printInProgress = usePrintInProgress();\n const formIsDisabled = useFormIsDisabled();\n const formIsReadOnly = useFormIsReadOnly();\n const formIsLoading = useFormIsLoading();\n\n const showAction = !formIsReadOnly || showWhenReadOnly;\n const showDisabled = disabled || formIsDisabled || formIsLoading;\n const showLoading = loading || printInProgress;\n\n // Set-up keyboard shortcut\n const formAppEl = useFormAppElement();\n const formTitle = useFormTitle();\n const print = usePrint();\n\n // Only provide a default `documentTitle` if the one is not provided in the\n // `Printer` component\n const printerHasDocumentTitle = Boolean(usePrinterDocumentTitle());\n const handlePrint = (evt: MouseEvent | KeyboardEvent) => {\n evt.preventDefault();\n void print(\n printerHasDocumentTitle ? undefined : { documentTitle: formTitle },\n );\n };\n\n useKeyboardShortcut(keybinds, handlePrint, {\n disabled: !showAction || showDisabled || showLoading,\n target: formAppEl,\n preventDefault: true,\n });\n\n return (\n showAction && (\n <PrinterTrigger\n onClick={combineEventHandlers(onClick, handlePrint, {\n checkDefaultPrevented: true,\n })}\n >\n <Button\n vertical\n variant=\"subtle\"\n icon={faPrint}\n {...otherProps}\n disabled={showDisabled}\n loading={showLoading}\n keybinds={keybinds}\n >\n {label}\n </Button>\n </PrinterTrigger>\n )\n );\n}\n","import type { RadioProps } from \"@ostack.tech/ui\";\nimport type { Key, ReactNode } from \"react\";\n\n/** @deprecated Use {@link RadioGroupControlItemObject} instead. */\nexport type RadioOption<T = unknown> = RadioGroupControlItemObject<T>;\n\n/** Radio group control item in object notation. */\nexport interface RadioGroupControlItemObject<T = unknown> extends Omit<\n RadioProps,\n \"value\" | \"children\"\n> {\n /** Item value. */\n value: T;\n /** Item's rendered text. */\n text?: ReactNode;\n /** Item's unique key. */\n key?: Key;\n}\n\n/** Properties of the radio group control item component. */\nexport interface RadioGroupControlItemProps<T = unknown> extends Omit<\n RadioGroupControlItemObject<T>,\n \"text\"\n> {\n /** Item's rendered text. */\n children?: ReactNode;\n}\n\n/**\n * Definition of a radio group control item.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `RadioGroupControl` component to automatically create the `options` array.\n */\nexport function RadioGroupControlItem(_props: RadioGroupControlItemProps) {\n return null;\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n equals,\n type InputController,\n type InputOptions,\n useInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n parseChildren,\n Radio,\n RadioGroup,\n type RadioGroupProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport {\n formatSelectionValueAsOptionIndex,\n isUnknownValue,\n parseSelectionValueFromOptionIndex,\n} from \"../../utils/selectionTransformations.tsx\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { UnknownValue } from \"../UnknownValue\";\nimport {\n RadioGroupControlItem,\n type RadioGroupControlItemObject,\n} from \"./RadioGroupControlItem.tsx\";\n\n/** Properties of the radio group control component. */\nexport interface RadioGroupControlProps<T = unknown>\n extends\n Omit<\n InputOptions<T, T, ComponentRef<typeof RadioGroup>>,\n \"enabled\" | \"format\" | \"parse\"\n >,\n Omit<\n RadioGroupProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"children\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /** Radio group control options. */\n options?: RadioGroupControlItemObject<T>[];\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /** Label shown when the control's value isn't one of the existing options. */\n unknownValueLabel?: ReactNode;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /** Radio group control children. */\n children?: ReactNode;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n InputController<T, string, ComponentRef<typeof RadioGroup>> | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The radio group control component is a KForm form control for values with any\n * type of (typically\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schema. It is built on top of the\n * [`RadioGroup`](/docs/ostack-ui-forms-radio-group--docs) component.\n *\n * It composes the following subcomponent:\n *\n * - `RadioGroupControlItem`: Component used to define an item of the radio group\n * control.\n *\n * The following built-in KForm validation affects this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * RadioGroupControl,\n * RadioGroupControlItem,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function ShirtSizeControl() {\n * return (\n * <RadioGroupControl path=\"/shirtSize\">\n * <RadioGroupControlItem value=\"sm\">Small</RadioGroupControlItem>\n * <RadioGroupControlItem value=\"md\">Medium</RadioGroupControlItem>\n * <RadioGroupControlItem value=\"lg\">Large</RadioGroupControlItem>\n * <RadioGroupControlItem value=\"xl\">X-Large</RadioGroupControlItem>\n * </RadioGroupControl>\n * );\n * }\n * ```\n */\nexport function RadioGroupControl<T = unknown>({\n path,\n options,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n unknownValueLabel,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n loading,\n showSpinner,\n disabled,\n readOnly,\n showClearButton = false,\n endAdornment,\n onFocus,\n onBlurToOutside,\n children,\n debug,\n ref,\n ...otherProps\n}: RadioGroupControlProps<T>) {\n const [locale] = useLocale();\n unknownValueLabel ??= locale.RadioGroupControl.unknownValueLabel;\n\n options ??= parseChildren(children, RadioGroupControlItem, {\n transformChildObject: ({ children, ...otherProps }) => ({\n text: children,\n ...otherProps,\n }),\n });\n\n const [value, setValue] = useState<T>();\n const isUnknown = useMemo(\n () => isUnknownValue(value, options),\n [options, value],\n );\n const formattedValue = useMemo(\n () => formatSelectionValueAsOptionIndex(value, options),\n [options, value],\n );\n const controller = useInput<T, T, ComponentRef<typeof RadioGroup>>(path, {\n enabled: !useFormIsLoading(),\n setFormattedValue: setValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { nullable, restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLDivElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const { onChange: inputOnChange } = inputProps;\n const handleValueChange = useCallback(\n (formattedValue: string | null) => {\n const newValue = parseSelectionValueFromOptionIndex(\n formattedValue ?? \"\",\n schema,\n options,\n isUnknown ? [value!] : [],\n );\n inputOnChange(newValue);\n setValue(newValue);\n },\n [inputOnChange, isUnknown, options, schema, value],\n );\n\n // Get representation of the value that the control will be cleared to. When\n // `showClearButton` is \"auto\", we hide the button if the current value is\n // the same as the \"cleared value\".\n const clearedValue = nullable ? null : schema.initialValue;\n const clearedIdx = useMemo(\n () => options.findIndex((option) => equals(option.value, clearedValue)),\n [clearedValue, options],\n );\n const clearedFormattedValue = clearedIdx === -1 ? \"\" : clearedIdx.toString();\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedRadioGroupRef = useCombinedRef(\n inputProps.ref,\n autofocusRef,\n ref,\n );\n return (\n <FeedbackProvider>\n <RadioGroup\n value={formattedValue}\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n showClearButton={\n showClearButton === \"auto\"\n ? formattedValue !== clearedFormattedValue\n : showClearButton\n }\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath} />\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedRadioGroupRef}\n >\n {/* Unknown value */}\n {isUnknown && (\n <Radio value={-1} status=\"invalid\">\n <UnknownValue value={value} label={unknownValueLabel} />\n </Radio>\n )}\n {options.map(({ value, text, key, ...radioProps }, i) => (\n <Radio key={key ?? i} value={i} {...radioProps}>\n {text ?? value?.toString() ?? \"\"}\n </Radio>\n ))}\n </RadioGroup>\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import { AbsolutePath } from \"@ostack.tech/kform\";\nimport { useFormController, useFormManager } from \"@ostack.tech/kform-react\";\nimport { useToastManager } from \"@ostack.tech/ui\";\nimport {\n fileSave,\n type FileSystemHandle,\n supported,\n type WellKnownDirectory,\n} from \"browser-fs-access\";\nimport { formatISO } from \"date-fns\";\nimport { DEV } from \"esm-env\";\nimport { type ReactNode, useMemo } from \"react\";\n\nimport { useFormTitle } from \"../components/FormApp\";\nimport { useLocale } from \"../providers/LocalizationProvider\";\n\n/**\n * Options that can be passed to the {@link useFormSaver} hook, or to its\n * resulting `save`/`saveAs` functions.\n */\nexport interface FormSaverOptions<T = unknown> {\n /**\n * When set, if modern file system APIs are available and the form has been\n * previously loaded or saved, then the file will be written over the\n * previously saved/loaded file.\n *\n * @default false\n */\n overwrite?: boolean;\n /**\n * Function used to encode the form, given its value.\n *\n * Note that when returning a string, the string is converted into a `Blob`\n * using the first provided mime type in `mimeTypes` as its type, i.e. it is\n * converted as `new Blob([encodedValue], { type: mimeTypes?.[0] })`.\n *\n * @param formValue Value of the form.\n * @returns Encoded form value as a string, blob, response, or a promise to\n * either type.\n */\n encode?: (\n formValue: T,\n ) => string | Blob | Response | PromiseLike<string | Blob | Response>;\n /**\n * Path of the value being saved.\n *\n * @default AbsolutePath.ROOT\n */\n path?: string | AbsolutePath;\n /**\n * Suggested file name.\n *\n * A function may be provided which will be called with the form value right\n * before invoking the save.\n */\n fileName?: string | ((formValue: T) => string | PromiseLike<string>);\n /**\n * Acceptable file extensions. Extensions should include the leading dot.\n *\n * E.g. `[\".json\", \".txt\"]`\n *\n * @default [\"\"]\n */\n extensions?: string[];\n /**\n * Acceptable MIME types.\n *\n * E.g. `[\"application/json\", \"text/plain\"]`\n *\n * @default [ ]\n */\n mimeTypes?: string[];\n /**\n * Suggested file description.\n *\n * @default \"\"\n */\n description?: string;\n /** Directory to present when starting to save. */\n startIn?: WellKnownDirectory | FileSystemHandle;\n /** Excludes the \"accept all\" option. */\n excludeAcceptAllOption?: boolean;\n /**\n * By specifying an ID, the user agent can remember different directories for\n * different IDs.\n */\n id?: string;\n /**\n * Whether to set the form as pristine when saving.\n *\n * @default true\n */\n setPristineOnSave?: boolean;\n /**\n * Message to show in a toast when successfully saving the form to a file. Can\n * be set to `null` to not show any message.\n *\n * @param fileHandle Handle to the saved file.\n * @returns Message to show in a toast.\n */\n successMessage?:\n ReactNode | ((fileHandle: FileSystemFileHandle) => ReactNode);\n /**\n * Message to show in a toast when an error occurs while saving the form to a\n * file. Can be set to `null` to not show any message.\n *\n * @param fileHandle Handle of the file over which the save was attempted, or\n * `null` if no such file exists.\n * @param error Error that occurred.\n * @returns Message to show in a toast.\n */\n errorMessage?:\n | ReactNode\n | ((fileHandle: FileSystemFileHandle | null, error: unknown) => ReactNode);\n}\n\n/** Result of the {@link useFormSaver} hook. */\nexport interface FormSaverResult<T> {\n /**\n * Function used to save the form.\n *\n * @param options Options used for saving the form.\n * @returns Promise which resolves once the form has been saved.\n */\n save: (options?: FormSaverOptions<T>) => Promise<void>;\n /** Whether the browser supports modern file system APIs used for saving. */\n supportsFileSystemAPIs: boolean;\n}\n\n/** Hook exposing functions used to save the form to a file. */\nexport function useFormSaver<T = unknown>({\n overwrite,\n path,\n encode,\n fileName,\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n id,\n setPristineOnSave,\n successMessage,\n errorMessage,\n}: FormSaverOptions<T> = {}): FormSaverResult<T> {\n const [locale] = useLocale();\n const formManager = useFormManager();\n const { getState, _setState } = useFormController();\n const { addToast } = useToastManager();\n const formTitle = useFormTitle();\n const defaultId = useMemo(\n () => formTitle?.replace(/[^a-zA-Z0-9-_]/g, \"\").substring(0, 32) ?? \"\",\n [formTitle],\n );\n\n return useMemo(() => {\n async function save<T = unknown>({\n overwrite,\n path = AbsolutePath.ROOT,\n encode,\n fileName,\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n id = defaultId,\n setPristineOnSave = true,\n successMessage = locale.SaveAction.successMessage,\n errorMessage = locale.SaveAction.errorMessage,\n }: FormSaverOptions<T>) {\n if (!encode) {\n throw new Error(\"No `encode` function was provided.\");\n }\n\n _setState({ saving: true } as any);\n let fileHandle: FileSystemFileHandle | null =\n (getState() as any).latestFileHandles?.[id] ?? null;\n try {\n const [encodedForm, suggestedFileName] = await formManager.get<\n T,\n [string | Blob | Response, string | undefined]\n >(path, (value) =>\n Promise.all([\n encode(value),\n fileHandle\n ? fileHandle.name\n : typeof fileName === \"function\"\n ? fileName(value)\n : fileName,\n ]),\n );\n\n fileHandle = await fileSave(\n typeof encodedForm === \"string\"\n ? new Blob([encodedForm], { type: mimeTypes?.[0] })\n : encodedForm,\n {\n fileName:\n suggestedFileName || defaultFileName(formTitle, extensions?.[0]),\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n id,\n },\n overwrite ? fileHandle : null,\n );\n\n if (setPristineOnSave) {\n await formManager.setPristine(path);\n }\n\n _setState(\n (state: any) =>\n ({\n latestFileHandles: {\n ...state.latestFileHandles,\n [id]: fileHandle,\n },\n }) as any,\n );\n\n // When modern file system APIs aren't available, the browser will show\n // a notification for the downloaded file so the toast is unnecessary\n if (supported) {\n const message =\n typeof successMessage == \"function\"\n ? successMessage(fileHandle!)\n : successMessage;\n if (message != null) {\n addToast(message, { severity: \"success\" });\n }\n }\n } catch (error) {\n // User aborted\n if (error instanceof DOMException && error.name === \"AbortError\") {\n return;\n }\n\n if (DEV) {\n console.error(error);\n }\n const message =\n typeof errorMessage == \"function\"\n ? errorMessage(fileHandle, error)\n : errorMessage;\n if (message != null) {\n addToast(message, { severity: \"danger\" });\n }\n } finally {\n _setState({ saving: false } as any);\n }\n }\n\n return {\n save: (options = {}) =>\n save({\n overwrite,\n path,\n encode,\n fileName,\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n id,\n setPristineOnSave,\n successMessage,\n errorMessage,\n ...options,\n }),\n supportsFileSystemAPIs: supported,\n };\n }, [\n _setState,\n addToast,\n defaultId,\n description,\n encode,\n errorMessage,\n excludeAcceptAllOption,\n extensions,\n fileName,\n formManager,\n formTitle,\n getState,\n id,\n locale.SaveAction.errorMessage,\n locale.SaveAction.successMessage,\n mimeTypes,\n overwrite,\n path,\n setPristineOnSave,\n startIn,\n successMessage,\n ]);\n}\n\n/** Hook exposing whether the form is currently being saved. */\nexport function useFormIsSaving() {\n return useFormController().useState((state) => (state as any).saving);\n}\n\n/** Default file name when one is not provided. */\nfunction defaultFileName(formTitle?: string, extension?: string) {\n const date = formatISO(new Date(), { representation: \"date\" });\n return [[formTitle, date].filter(Boolean).join(\" \"), extension]\n .filter(Boolean)\n .join(\"\");\n}\n","import { faCaretDown, faFloppyDisk } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n Button,\n ButtonGroup,\n type ButtonProps,\n combineEventHandlers,\n DropdownMenu,\n DropdownMenuContent,\n type DropdownMenuContentProps,\n DropdownMenuItem,\n DropdownMenuTrigger,\n IconButton,\n type IconButtonProps,\n useKeyboardShortcut,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport {\n type FormSaverOptions,\n useFormIsSaving,\n useFormSaver,\n} from \"../../utils/useFormSaver.tsx\";\nimport { useFormAppElement, useFormIsReadOnly } from \"../FormApp\";\n\n/** Default “save” keybinds. */\nexport const DEFAULT_SAVE_KEYBINDS = \"$mod+S\";\n/** Default “save as” keybinds. */\nexport const DEFAULT_SAVE_AS_KEYBINDS = \"$mod+Shift+S\";\n\n/** Properties of the save action. */\nexport interface SaveActionProps<T = unknown>\n extends\n Omit<ButtonProps, \"children\">,\n Omit<FormSaverOptions<T>, \"id\" | \"overwrite\"> {\n /** Action's label. */\n label?: ReactNode;\n /**\n * Keybinds for triggering the action. Set to `null` to disable the keyboard\n * shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * `DEFAULT_SAVE_KEYBINDS`.\n */\n keybinds?: string | string[] | null;\n /**\n * Whether to show the save action when the form is read-only.\n *\n * @default true\n */\n showWhenReadOnly?: boolean;\n /**\n * By specifying a filesystem ID, the user agent can remember different\n * directories for different IDs.\n */\n fileSystemId?: string;\n /**\n * Whether to disable the overwriting behaviour of the “save” button. When\n * set, the “save” button will function as the “save as” button and the “save\n * as” button will not be rendered.\n *\n * This property only affects browsers that support modern file system APIs,\n * since other browsers already function in the above-mentioned way.\n *\n * Defaults to `true` when the form is read-only and `false` otherwise.\n */\n disableOverwrite?: boolean;\n /** Label of the save options button. */\n saveOptionsLabel?: ReactNode;\n /** Label of the action's \"save as\" sub-action. */\n saveAsLabel?: ReactNode;\n /**\n * Keybinds for triggering the \"save as\" sub-action. Set to `null` to disable\n * the keyboard shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * `DEFAULT_SAVE_AS_KEYBINDS`.\n */\n saveAsKeybinds?: string | string[] | null;\n /** Properties to pass to the save options button component. */\n saveOptionsProps?: Omit<Partial<IconButtonProps>, \"label\">;\n /** Properties to pass to the save options dropdown menu component. */\n dropdownMenuProps?: DropdownMenuContentProps;\n}\n\n/**\n * Form action used to save the form to a file, supporting both overwriting and\n * non-overwriting behaviours (i.e. supporting both “save” and “save as”). Built\n * on top of the [`ButtonGroup`](/docs/ostack-ui-layout-button-group--docs),\n * [`Button`](/docs/ostack-ui-forms-button--docs), and\n * [`DropdownMenu`](/docs/ostack-ui-overlay-dropdown-menu--docs) components, as\n * well as the `useFormSaver` hook.\n *\n * Example usage:\n *\n * ```tsx\n * import { SaveAction } from \"@ostack.tech/ui-kform\";\n *\n * function SaveForm() {\n * return (\n * <SaveAction\n * encode={(formValue) =>\n * encodeFormToJSON(formValue, { pretty: true })\n * }\n * mimeTypes={[\"application/json\"]}\n * extensions={[\".json\"]}\n * />\n * );\n * }\n * ```\n */\nexport function SaveAction<T = unknown>({\n label,\n keybinds,\n showWhenReadOnly = true,\n fileSystemId,\n disableOverwrite,\n saveOptionsLabel,\n saveAsLabel,\n saveAsKeybinds,\n loading,\n disabled,\n onClick,\n variant = \"subtle\",\n color,\n path,\n encode,\n fileName,\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n successMessage,\n errorMessage,\n saveOptionsProps,\n dropdownMenuProps,\n ...otherProps\n}: SaveActionProps<T>) {\n const [locale] = useLocale();\n label ??= locale.SaveAction.label;\n if (keybinds === undefined) {\n keybinds = locale.SaveAction.keybinds ?? DEFAULT_SAVE_KEYBINDS;\n }\n saveOptionsLabel ??= locale.SaveAction.saveOptionsLabel;\n saveAsLabel ??= locale.SaveAction.saveAsLabel;\n if (saveAsKeybinds === undefined) {\n saveAsKeybinds =\n locale.SaveAction.saveAsKeybinds ?? DEFAULT_SAVE_AS_KEYBINDS;\n }\n\n const { save, supportsFileSystemAPIs } = useFormSaver({\n path,\n encode,\n fileName,\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n id: fileSystemId,\n successMessage,\n errorMessage,\n });\n const formIsReadOnly = useFormIsReadOnly();\n const formIsSaving = useFormIsSaving();\n const formIsLoading = useFormIsLoading();\n\n const showAction = !formIsReadOnly || showWhenReadOnly;\n const showDisabled = disabled || formIsLoading;\n const showLoading = loading || formIsSaving;\n\n // Disable overwrite by default when the form is read-only\n disableOverwrite ??= formIsReadOnly;\n\n // Set-up keyboard shortcuts\n const formAppEl = useFormAppElement();\n const shortcutsDisabled = !showAction || showDisabled || showLoading;\n useKeyboardShortcut(keybinds, () => save({ overwrite: !disableOverwrite }), {\n disabled: shortcutsDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n useKeyboardShortcut(saveAsKeybinds, () => save(), {\n disabled: shortcutsDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n\n const saveButton = (\n <Button\n vertical\n variant={variant}\n color={color}\n icon={faFloppyDisk}\n {...otherProps}\n onClick={combineEventHandlers(\n () => save({ overwrite: !disableOverwrite }),\n onClick as never,\n )}\n disabled={showDisabled}\n loading={showLoading}\n keybinds={keybinds}\n >\n {label}\n </Button>\n );\n\n return (\n showAction &&\n (supportsFileSystemAPIs && !disableOverwrite ? (\n <ButtonGroup>\n {saveButton}\n <DropdownMenu>\n <DropdownMenuTrigger>\n <IconButton\n variant={variant}\n color={color}\n icon={faCaretDown}\n {...saveOptionsProps}\n label={saveOptionsLabel}\n disabled={showDisabled || saveOptionsProps?.disabled}\n style={{ minWidth: 20, ...saveOptionsProps?.style }}\n />\n </DropdownMenuTrigger>\n\n <DropdownMenuContent align=\"end\" {...dropdownMenuProps}>\n <DropdownMenuItem\n onClick={() => save()}\n disabled={showDisabled}\n loading={showLoading}\n keybinds={saveAsKeybinds}\n >\n {saveAsLabel}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </ButtonGroup>\n ) : (\n saveButton\n ))\n );\n}\n","import type { OptionProps } from \"@ostack.tech/ui\";\nimport type { Key, ReactNode } from \"react\";\n\n/** Select control item in object notation. */\nexport interface SelectControlItemObject<T = unknown> extends Omit<\n OptionProps,\n \"value\" | \"children\"\n> {\n /** Item value. */\n value: T;\n /** Item's rendered text. */\n text?: ReactNode;\n /** Item's unique key. */\n key?: Key;\n}\n\n/** Properties of the select control item component. */\nexport interface SelectControlItemProps<T = unknown> extends Omit<\n SelectControlItemObject<T>,\n \"text\"\n> {\n /** Item's rendered text. */\n children?: ReactNode;\n}\n\n/**\n * Definition of a select control item.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `SelectControl` component to automatically create the `options` array.\n */\nexport function SelectControlItem(_props: SelectControlItemProps) {\n return null;\n}\n","import type { OptionProps } from \"@ostack.tech/ui\";\nimport type { Key, ReactNode } from \"react\";\n\nimport type { SelectControlItemObject } from \"./SelectControlItem.tsx\";\n\n/** Select control item group in object notation. */\nexport interface SelectControlItemGroupObject<T = unknown> extends Omit<\n OptionProps,\n \"value\" | \"children\"\n> {\n /** Group's options. */\n options: SelectControlItemObject<T>[];\n /** Group's unique key. */\n key?: Key;\n}\n\n/** Properties of the select control item group component. */\nexport interface SelectControlItemGroupProps<T = unknown> extends Omit<\n SelectControlItemGroupObject<T>,\n \"options\"\n> {\n /** Group's children. */\n children?: ReactNode;\n}\n\n/**\n * Definition of a select control item group.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `SelectControl` component to automatically create groups of items in the\n * `options` array.\n */\nexport function SelectControlItemGroup(_props: SelectControlItemGroupProps) {\n return null;\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n equals,\n type InputController,\n type InputOptions,\n useInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n Option,\n parseChildren,\n Select,\n type SelectProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport {\n formatSelectionValueAsOptionIndex,\n isUnknownValue,\n parseSelectionValueFromOptionIndex,\n selectionItemObjectsToNodes,\n} from \"../../utils/selectionTransformations.tsx\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { UnknownValue } from \"../UnknownValue\";\nimport {\n SelectControlItem,\n type SelectControlItemObject,\n} from \"./SelectControlItem.tsx\";\nimport {\n SelectControlItemGroup,\n type SelectControlItemGroupObject,\n} from \"./SelectControlItemGroup.tsx\";\n\n/** Properties of the select control component. */\nexport interface SelectControlProps<T = unknown>\n extends\n Omit<\n InputOptions<T, T, ComponentRef<typeof Select>>,\n \"enabled\" | \"format\" | \"parse\"\n >,\n Omit<\n SelectProps,\n | \"multiple\"\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"maxSelected\"\n | \"children\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /** Select control options. */\n options?: (SelectControlItemGroupObject<T> | SelectControlItemObject<T>)[];\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /** Label shown when the control's value isn't one of the existing options. */\n unknownValueLabel?: ReactNode;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /** Select control children. */\n children?: ReactNode;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n InputController<T, string, ComponentRef<typeof Select>> | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The select control component is a KForm form control for values with any type\n * of (typically\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schema. It is built on top of the\n * [`Select`](/docs/ostack-ui-forms-select--docs) component.\n *\n * It composes the following subcomponents:\n *\n * - `SelectControlItem`: Component used to define an item of the select control.\n * - `SelectControlItemGroup`: Component used to define a group of items of the\n * select control.\n *\n * The following built-in KForm validation affects this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n *\n * Example usage:\n *\n * ```tsx\n * import { SelectControl, SelectControlItem } from \"@ostack.tech/ui-kform\";\n *\n * function ShirtSizeControl() {\n * return (\n * <SelectControl\n * path=\"/shirtSize\"\n * placeholder=\"Select your shirt size…\"\n * >\n * <SelectControlItem value=\"sm\">Small</SelectControlItem>\n * <SelectControlItem value=\"md\">Medium</SelectControlItem>\n * <SelectControlItem value=\"lg\">Large</SelectControlItem>\n * <SelectControlItem value=\"xl\">X-Large</SelectControlItem>\n * </SelectControl>\n * );\n * }\n * ```\n */\nexport function SelectControl<T = unknown>({\n path,\n options: groupedOptions,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n unknownValueLabel,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n loading,\n showSpinner,\n disabled,\n readOnly,\n showClearButton,\n endAdornment,\n onFocus,\n onBlurToOutside,\n children,\n debug,\n ref,\n ...otherProps\n}: SelectControlProps<T>) {\n const [locale] = useLocale();\n unknownValueLabel ??= locale.SelectControl.unknownValueLabel;\n\n groupedOptions ??= parseChildren(children, SelectControlItem, {\n groupType: SelectControlItemGroup,\n groupProp: \"options\",\n transformChildObject: ({ children, ...otherProps }) => ({\n text: children,\n ...otherProps,\n }),\n });\n\n const options = useMemo(\n () =>\n groupedOptions.reduce(\n (options: SelectControlItemObject<T>[], optionOrGroup) => {\n if (\"options\" in optionOrGroup) {\n options.push(...optionOrGroup.options);\n } else {\n options.push(optionOrGroup);\n }\n return options;\n },\n [],\n ),\n [groupedOptions],\n );\n const [value, setValue] = useState<T>();\n const isUnknown = useMemo(\n () => isUnknownValue(value, options),\n [options, value],\n );\n const formattedValue = useMemo(\n () => formatSelectionValueAsOptionIndex(value, options),\n [options, value],\n );\n const controller = useInput<T, T, ComponentRef<typeof Select>>(path, {\n enabled: !useFormIsLoading(),\n setFormattedValue: setValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { nullable, restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLButtonElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const { onChange: inputOnChange } = inputProps;\n const handleValueChange = useCallback(\n (formattedValue: string) => {\n const newValue = parseSelectionValueFromOptionIndex(\n formattedValue,\n schema,\n options,\n isUnknown ? [value!] : [],\n );\n inputOnChange(newValue);\n setValue(newValue);\n },\n [inputOnChange, isUnknown, options, schema, value],\n );\n\n // Get representation of the value that the control will be cleared to. When\n // `showClearButton` is \"auto\", we hide the button if the current value is\n // the same as the \"cleared value\".\n showClearButton ??= nullable ? \"auto\" : false;\n const clearedValue = nullable ? null : schema.initialValue;\n const clearedIdx = useMemo(\n () => options.findIndex((option) => equals(option.value, clearedValue)),\n [clearedValue, options],\n );\n const clearedFormattedValue = clearedIdx === -1 ? \"\" : clearedIdx.toString();\n\n const optionNodes = useMemo(\n () => selectionItemObjectsToNodes(groupedOptions),\n [groupedOptions],\n );\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedSelectRef = useCombinedRef(inputProps.ref, autofocusRef, ref);\n return (\n <FeedbackProvider>\n <Select\n value={formattedValue}\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n showClearButton={\n showClearButton === \"auto\"\n ? formattedValue !== clearedFormattedValue\n : showClearButton\n }\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedSelectRef}\n >\n {/* Unknown value */}\n {isUnknown && (\n <Option value={-1} color=\"danger\" keywords={[String(value)]}>\n <UnknownValue value={value} label={unknownValueLabel} />\n </Option>\n )}\n {optionNodes}\n </Select>\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import type {\n SelectControlItemObject,\n SelectControlItemProps,\n} from \"../SelectControl\";\n\n/** Select multiple control item in object notation. */\nexport type SelectMultipleControlItemObject<T = unknown> =\n SelectControlItemObject<T>;\n\n/** Properties of the select multiple control item component. */\nexport type SelectMultipleControlItemProps<T = unknown> =\n SelectControlItemProps<T>;\n\n/**\n * Definition of a select multiple control item.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `SelectMultipleControl` component to automatically create the `options`\n * array.\n */\nexport function SelectMultipleControlItem(\n _props: SelectMultipleControlItemProps,\n) {\n return null;\n}\n","import type {\n SelectControlItemGroupObject,\n SelectControlItemGroupProps,\n} from \"../SelectControl\";\n\n/** Select multiple control item group in object notation. */\nexport type SelectMultipleControlItemGroupObject<T = unknown> =\n SelectControlItemGroupObject<T>;\n\n/** Properties of the select multiple control item group component. */\nexport type SelectMultipleControlItemGroupProps<T = unknown> =\n SelectControlItemGroupProps<T>;\n\n/**\n * Definition of a select multiple control item group.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `SelectMultipleControl` component to automatically create groups of items in\n * the `options` array.\n */\nexport function SelectMultipleControlItemGroup(\n _props: SelectMultipleControlItemGroupProps,\n) {\n return null;\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type Listable,\n type ListableInputController,\n type ListableInputOptions,\n useListableInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n Option,\n parseChildren,\n Select,\n type SelectProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport {\n formatSelectionValuesAsOptionIndices,\n getUnknownValues,\n parseSelectionValuesFromOptionIndices,\n selectionItemObjectsToNodes,\n} from \"../../utils/selectionTransformations.tsx\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { UnknownValue } from \"../UnknownValue\";\nimport {\n SelectMultipleControlItem,\n type SelectMultipleControlItemObject,\n} from \"./SelectMultipleControlItem.tsx\";\nimport {\n SelectMultipleControlItemGroup,\n type SelectMultipleControlItemGroupObject,\n} from \"./SelectMultipleControlItemGroup.tsx\";\n\n/** Properties of the select multiple control component. */\nexport interface SelectMultipleControlProps<\n T = unknown,\n TListable extends Listable<T> | null = Listable<T> | null,\n>\n extends\n Omit<\n ListableInputOptions<\n T,\n TListable,\n readonly T[] | null,\n ComponentRef<typeof Select>\n >,\n \"enabled\" | \"formatFromArray\" | \"parseToArray\"\n >,\n Omit<\n SelectProps,\n | \"multiple\"\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"children\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /** Select multiple control options. */\n options?: (\n SelectMultipleControlItemGroupObject<T> | SelectMultipleControlItemObject<T>\n )[];\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /** Label shown when a value of the control isn't one of the existing options. */\n unknownValueLabel?: ReactNode;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /** Select multiple control children. */\n children?: ReactNode;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | ListableInputController<\n T,\n TListable,\n string[],\n ComponentRef<typeof Select>\n >\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The select multiple control component is a KForm form control for values with\n * (possibly\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)\n * or\n * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)\n * and items of any type. It is built on top of the\n * [`Select`](/docs/ostack-ui-forms-select--docs) component with the `multiple`\n * property set.\n *\n * It composes the following subcomponents:\n *\n * - `SelectMultipleControlItem`: Component used to define an item of the select\n * multiple control.\n * - `SelectMultipleControlItemGroup`: Component used to define a group of items\n * of the select multiple control.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):\n * Sets the `maxSelected` property.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * SelectMultipleControl,\n * SelectMultipleControlItem,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function SpokenLanguagesControl() {\n * return (\n * <SelectMultipleControl\n * path=\"/spokenLanguages\"\n * placeholder=\"Select your spoken languages…\"\n * >\n * <SelectMultipleControlItem value=\"en\">\n * English\n * </SelectMultipleControlItem>\n * <SelectMultipleControlItem value=\"fr\">\n * French\n * </SelectMultipleControlItem>\n * <SelectMultipleControlItem value=\"pt\">\n * Portuguese\n * </SelectMultipleControlItem>\n * <SelectMultipleControlItem value=\"es\">\n * Spanish\n * </SelectMultipleControlItem>\n * </SelectMultipleControl>\n * );\n * }\n * ```\n */\nexport function SelectMultipleControl<\n T = unknown,\n TListable extends Listable<T> | null = Listable<T> | null,\n>({\n path,\n options: groupedOptions,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n unknownValueLabel,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n maxSelected,\n loading,\n showSpinner,\n disabled,\n readOnly,\n endAdornment,\n onFocus,\n onBlurToOutside,\n children,\n debug,\n ref,\n ...otherProps\n}: SelectMultipleControlProps<T, TListable>) {\n const [locale] = useLocale();\n unknownValueLabel ??= locale.SelectMultipleControl.unknownValueLabel;\n\n groupedOptions ??= parseChildren(children, SelectMultipleControlItem, {\n groupType: SelectMultipleControlItemGroup,\n groupProp: \"options\",\n transformChildObject: ({ children, ...otherProps }) => ({\n text: children,\n ...otherProps,\n }),\n });\n\n const options = useMemo(\n () =>\n groupedOptions.reduce(\n (options: SelectMultipleControlItemObject<T>[], optionOrGroup) => {\n if (\"options\" in optionOrGroup) {\n options.push(...optionOrGroup.options);\n } else {\n options.push(optionOrGroup);\n }\n return options;\n },\n [],\n ),\n [groupedOptions],\n );\n const [arrayValue, setArrayValue] = useState<readonly T[] | null>(null);\n const unknownValues = useMemo(\n () => getUnknownValues(arrayValue, options),\n [options, arrayValue],\n );\n const formattedValue = useMemo(\n () =>\n formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues),\n [options, unknownValues, arrayValue],\n );\n const controller = useListableInput<\n T,\n TListable,\n readonly T[] | null,\n ComponentRef<typeof Select>\n >(path, {\n enabled: !useFormIsLoading(),\n parseToArray: useCallback(\n (formattedValue: readonly T[] | null) =>\n formattedValue && [...formattedValue],\n [],\n ),\n formatFromArray: useCallback(\n (arrayValue: readonly T[] | null) => arrayValue && [...arrayValue],\n [],\n ),\n setFormattedValue: setArrayValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const { restrictions } = schema.typeInfo;\n const absolutePath = usePath();\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<TListable, HTMLButtonElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const { onChange: inputOnChange } = inputProps;\n const handleValueChange = useCallback(\n (formattedValue: string[]) => {\n const newValue = parseSelectionValuesFromOptionIndices(\n formattedValue,\n schema,\n options,\n unknownValues,\n );\n inputOnChange(newValue);\n setArrayValue(newValue);\n },\n [inputOnChange, options, schema, unknownValues],\n );\n\n const optionNodes = useMemo(\n () => selectionItemObjectsToNodes(groupedOptions),\n [groupedOptions],\n );\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedSelectRef = useCombinedRef(inputProps.ref, autofocusRef, ref);\n return (\n <FeedbackProvider>\n <Select\n multiple\n value={formattedValue}\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n maxSelected={\n maxSelected ??\n (typeof restrictions.maxSize === \"number\"\n ? restrictions.maxSize\n : undefined)\n }\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedSelectRef}\n >\n {/* Unknown values */}\n {unknownValues.map((v, i) => (\n <Option\n key={i}\n value={-i - 1}\n color=\"danger\"\n keywords={v == null ? [] : [String(v)]}\n >\n <UnknownValue value={v} label={unknownValueLabel} />\n </Option>\n ))}\n {optionNodes}\n </Select>\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import { faArrowRight } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n type FormManager,\n type LocatedValidationWarning,\n PromiseCancellationException,\n type SealedLocatedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport {\n type SubmitOptions,\n useFormController,\n} from \"@ostack.tech/kform-react\";\nimport {\n Alert,\n AlertDialog,\n AlertDialogAction,\n AlertDialogBody,\n type AlertDialogBodyProps,\n AlertDialogCancel,\n AlertDialogContent,\n type AlertDialogContentProps,\n AlertDialogDescription,\n type AlertDialogDescriptionProps,\n AlertDialogFooter,\n type AlertDialogFooterProps,\n AlertDialogHeader,\n type AlertDialogHeaderProps,\n AlertDialogTitle,\n type AlertDialogTitleProps,\n AlertDialogTrigger,\n type AlertProps,\n Button,\n type ButtonProps,\n Checkbox,\n type CheckboxChecked,\n type CheckboxProps,\n combineEventHandlers,\n cx,\n useKeyboardShortcut,\n useToastManager,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport { type MouseEvent, type ReactNode, useRef, useState } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport {\n useFormAppElement,\n useFormIsDisabled,\n useFormIsReadOnly,\n useStartIssuesNavigation,\n} from \"../FormApp\";\n\n/** Default “submit” keybinds. */\nexport const DEFAULT_SUBMIT_KEYBINDS = \"$mod+Enter\";\n\n/** Properties of the submit action. */\nexport interface SubmitActionProps<T = unknown, TSubmitResult = unknown>\n extends\n Omit<ButtonProps, \"children\" | \"onSubmit\">,\n Pick<Required<SubmitOptions<T, TSubmitResult>>, \"onSubmit\">,\n Omit<SubmitOptions<T, TSubmitResult>, \"onSubmit\"> {\n /** Action's label. */\n label?: ReactNode;\n /**\n * Keybinds for triggering the action. Set to `null` to disable the keyboard\n * shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * `DEFAULT_SUBMIT_KEYBINDS`.\n */\n keybinds?: string | string[] | null;\n /**\n * Whether to show the submit action when the form is read-only.\n *\n * @default false\n */\n showWhenReadOnly?: boolean;\n /**\n * Whether users should confirm (by ticking a checkbox) that the submission\n * should proceed whenever the form contains warnings.\n *\n * @default true\n */\n confirmWarnings?: boolean;\n /** Title of the confirmation dialog which appears when submitting the form. */\n dialogTitle?:\n | ReactNode\n | ((formValue: T, warnings?: LocatedValidationWarning[]) => ReactNode);\n /**\n * Description of the confirmation dialog which appears when submitting the\n * form.\n */\n dialogDescription?:\n | ReactNode\n | ((formValue: T, warnings?: LocatedValidationWarning[]) => ReactNode);\n /**\n * Body of the confirmation dialog which appears when submitting the form.\n *\n * This property can be used to display a summary of the data being submitted\n * and will be displayed between the description and the “confirm warnings\n * alert”, when it exists.\n */\n dialogBody?:\n | ReactNode\n | ((formValue: T, warnings?: LocatedValidationWarning[]) => ReactNode);\n /**\n * Label of the checkbox which prompts users to confirm that they intend to\n * proceed with submission in the event of warnings in the form.\n */\n confirmWarningsCheckboxLabel?: ReactNode;\n /**\n * Text of the OK button in the confirmation dialog which appears when\n * submitting the form.\n */\n dialogOkText?: ReactNode;\n /**\n * Text of the cancel button in the confirmation dialog which appears when\n * submitting the form.\n */\n dialogCancelText?: ReactNode;\n /**\n * Message to show in a toast after a successful submission. Can be set to\n * `null` to not show any message.\n *\n * @param submitResult Result of `onSubmit`.\n * @returns Message to show in a toast.\n */\n successMessage?: ReactNode | ((submitResult: TSubmitResult) => ReactNode);\n /**\n * Message to show in a toast when an error occurs while submitting the form.\n * Can be set to `null` to not show any message.\n *\n * @param error Error that occurred.\n * @returns Message to show in a toast.\n */\n errorMessage?: ReactNode | ((error: unknown) => ReactNode);\n /** Properties to pass to the confirmation dialog content component. */\n dialogContentProps?: Omit<AlertDialogContentProps, \"children\">;\n /** Properties to pass to the confirmation dialog header component. */\n dialogHeaderProps?: Omit<AlertDialogHeaderProps, \"children\">;\n /** Properties to pass to the confirmation dialog title component. */\n dialogTitleProps?: Omit<AlertDialogTitleProps, \"children\">;\n /** Properties to pass to the confirmation dialog body component. */\n dialogBodyProps?: Omit<AlertDialogBodyProps, \"children\">;\n /** Properties to pass to the confirmation dialog description component. */\n dialogDescriptionProps?: Omit<AlertDialogDescriptionProps, \"children\">;\n /** Properties to pass to the confirmation dialog footer component. */\n dialogFooterProps?: Omit<AlertDialogFooterProps, \"children\">;\n /** Properties to pass to the confirmation dialog OK button component. */\n dialogOkButtonProps?: Omit<ButtonProps, \"children\">;\n /** Properties to pass to the confirmation dialog cancel button component. */\n dialogCancelButtonProps?: Omit<ButtonProps, \"children\">;\n /** Properties to pass to the alert used to confirm warnings. */\n confirmWarningsAlertProps?: Omit<AlertProps, \"children\">;\n /** Properties to pass to the checkbox used to confirm warnings. */\n confirmWarningsCheckboxProps?: Omit<\n CheckboxProps,\n \"checked\" | \"onCheckedChange\" | \"children\"\n >;\n}\n\n/**\n * Type of external issues accepted by the form manager's `addExternalIssues`\n * method.\n */\ntype ExternalValidationIssues = Parameters<FormManager[\"addExternalIssues\"]>[0];\n\n/** An object which is event-like. */\ntype EventLike = Pick<Event, \"preventDefault\" | \"defaultPrevented\">;\n\n/** Information about a submission. */\ninterface SubmissionInfo<T = unknown, TSubmitResult = unknown> {\n value: T;\n warnings?: LocatedValidationWarning[];\n resolve: (value: ExternalValidationIssues | TSubmitResult) => void;\n reject: (reason?: any) => void;\n}\n\n/**\n * Form action used to submit a form, supporting all submission-related\n * properties available in a\n * [`FormApp`](/docs/ostack-ui-kform-layout-form-app--docs). Built on top of the\n * [Button](/docs/ostack-ui-forms-button--docs) and\n * [AlertDialog](/docs/ostack-ui-overlay-alert-dialog--docs) components.\n *\n * Example usage:\n *\n * ```tsx\n * import { SubmitAction } from \"@ostack.tech/ui-kform\";\n *\n * function SubmitForm() {\n * return (\n * <SubmitAction\n * onSubmit={async (formValue, warnings) => {\n * const response = await submitForm(formValue, warnings);\n * if (response instanceof FormSubmitSuccess) {\n * return response.redirectTo;\n * } else if (response instanceof FormSubmitValidationError) {\n * return response.issues;\n * } else {\n * throw new Error(response.errorMessage);\n * }\n * }}\n * onSuccessfulSubmit={(redirectTo) => navigate(redirectTo)}\n * />\n * );\n * }\n * ```\n */\nexport function SubmitAction<T = unknown, TSubmitResult = unknown>({\n onSubmit,\n onInvalidSubmit,\n onSuccessfulSubmit,\n onFailedSubmit,\n setTouchedOnSubmit,\n validateOnSubmit,\n setPristineOnSuccessfulSubmit,\n convertExternalIssuesTableRowIndicesToIds,\n label,\n keybinds,\n showWhenReadOnly,\n confirmWarnings = true,\n loading,\n disabled,\n onClick,\n dialogTitle,\n dialogDescription,\n dialogBody,\n confirmWarningsCheckboxLabel,\n dialogOkText,\n dialogCancelText,\n successMessage: successMessageProp,\n errorMessage: errorMessageProp,\n dialogContentProps,\n dialogHeaderProps,\n dialogTitleProps,\n dialogBodyProps,\n dialogDescriptionProps,\n dialogFooterProps,\n dialogOkButtonProps,\n dialogCancelButtonProps,\n confirmWarningsAlertProps,\n confirmWarningsCheckboxProps,\n ...otherProps\n}: SubmitActionProps<T, TSubmitResult>) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n label ??= locale.SubmitAction.label;\n if (keybinds === undefined) {\n keybinds = locale.SubmitAction.keybinds ?? DEFAULT_SUBMIT_KEYBINDS;\n }\n dialogTitle ??= locale.SubmitAction.dialogTitle;\n dialogDescription ??= locale.SubmitAction.dialogDescription;\n dialogBody ??= locale.SubmitAction.dialogBody;\n confirmWarningsCheckboxLabel ??=\n locale.SubmitAction.confirmWarningsCheckboxLabel;\n dialogOkText ??= locale.SubmitAction.dialogOkText ?? label;\n dialogCancelText ??= locale.SubmitAction.dialogCancelText;\n const successMessage =\n successMessageProp === undefined\n ? locale.SubmitAction.successMessage\n : successMessageProp;\n const errorMessage =\n errorMessageProp === undefined\n ? locale.SubmitAction.errorMessage\n : errorMessageProp;\n\n const [confirmingSubmission, setConfirmingSubmission] = useState(false);\n const startIssuesNavigation = useStartIssuesNavigation();\n const { addToast } = useToastManager();\n const { submit, useSubmitting } = useFormController<T>();\n const submitting = useSubmitting();\n const [runningOnSubmit, setRunningOnSubmit] = useState(false);\n const formIsDisabled = useFormIsDisabled();\n const formIsReadOnly = useFormIsReadOnly();\n const formIsLoading = useFormIsLoading();\n const formAppEl = useFormAppElement();\n\n const showAction = !formIsReadOnly || showWhenReadOnly;\n const showDisabled = disabled || formIsDisabled || formIsLoading;\n const showLoading = loading || submitting;\n\n const [submissionInfo, setSubmissionInfo] = useState<SubmissionInfo<\n T,\n TSubmitResult\n > | null>(null);\n const [checkedWarnings, setCheckedWarnings] = useState<\n LocatedValidationWarning[]\n >([]);\n const allWarningsChecked =\n !submissionInfo?.warnings ||\n submissionInfo.warnings.every((warning) =>\n checkedWarnings.some((checkedWarning) => warning.equals(checkedWarning)),\n );\n\n const handleSubmit = (\n value: T,\n warnings?: LocatedValidationWarning[],\n event?: EventLike,\n ) => {\n event?.preventDefault?.();\n return new Promise<ExternalValidationIssues | TSubmitResult>(\n (resolve, reject) => {\n setConfirmingSubmission(true);\n setSubmissionInfo({ value, warnings, resolve, reject });\n },\n );\n };\n\n const handleOpenChange = (open: boolean) => {\n if (!open && !runningOnSubmit) {\n submissionInfo?.reject(\n new PromiseCancellationException(\"Submission cancelled\"),\n );\n setSubmissionInfo(null);\n setConfirmingSubmission(false);\n }\n };\n\n // Prevent autofocus of the trigger when submitting fails due to the form\n // being invalid, since we want to focus the first field with errors instead\n const preventCloseAutoFocus = useRef(false);\n const handleInvalidSubmit = async (\n issues: SealedLocatedValidationIssue[],\n event?: EventLike,\n ) => {\n preventCloseAutoFocus.current = true;\n await startIssuesNavigation({ validate: false });\n onInvalidSubmit?.(issues, event);\n };\n const handleCloseAutoFocus = (event: EventLike) => {\n if (preventCloseAutoFocus.current) {\n event.preventDefault();\n }\n preventCloseAutoFocus.current = false;\n };\n\n const handleSuccessfulSubmit = (\n submitResult: TSubmitResult,\n event?: EventLike,\n ) => {\n const message =\n typeof successMessage === \"function\"\n ? successMessage(submitResult)\n : successMessage;\n if (message != null) {\n addToast(message, { severity: \"success\" });\n }\n onSuccessfulSubmit?.(submitResult, event);\n };\n\n const handleFailedSubmit = (error: unknown, event?: EventLike) => {\n if (error instanceof PromiseCancellationException) {\n return;\n }\n\n if (DEV) {\n console.error(error);\n }\n const message =\n typeof errorMessage === \"function\" ? errorMessage(error) : errorMessage;\n if (message != null) {\n addToast(message, { severity: \"danger\" });\n }\n onFailedSubmit?.(error, event);\n };\n\n const handleConfirmSubmit = async (event: MouseEvent) => {\n event.preventDefault();\n if (!submissionInfo) {\n return;\n }\n\n const { value, warnings, resolve, reject } = submissionInfo;\n try {\n setRunningOnSubmit(true);\n resolve(await onSubmit(value, warnings, event));\n } catch (err) {\n reject(err);\n } finally {\n setRunningOnSubmit(false);\n handleOpenChange(false);\n }\n };\n\n const handleOnCheckedChange = (checked: CheckboxChecked) => {\n setCheckedWarnings(checked ? (submissionInfo?.warnings ?? []) : []);\n };\n\n const handleAction = (event: EventLike) =>\n submit(event, {\n onSubmit: handleSubmit,\n onInvalidSubmit: handleInvalidSubmit,\n onSuccessfulSubmit: handleSuccessfulSubmit,\n onFailedSubmit: handleFailedSubmit,\n setTouchedOnSubmit,\n validateOnSubmit,\n setPristineOnSuccessfulSubmit,\n convertExternalIssuesTableRowIndicesToIds,\n });\n\n // Set-up keyboard shortcut\n useKeyboardShortcut(keybinds, handleAction, {\n disabled: !showAction || showDisabled || showLoading,\n target: formAppEl,\n preventDefault: true,\n });\n\n return (\n showAction && (\n <AlertDialog open={confirmingSubmission} onOpenChange={handleOpenChange}>\n <AlertDialogTrigger>\n <Button\n type=\"submit\"\n color=\"success\"\n icon={faArrowRight}\n iconPlacement=\"end\"\n {...otherProps}\n onClick={combineEventHandlers(\n onClick,\n // eslint-disable-next-line react-hooks/refs\n handleAction,\n )}\n disabled={showDisabled}\n loading={showLoading}\n keybinds={keybinds}\n >\n {label}\n </Button>\n </AlertDialogTrigger>\n\n <AlertDialogContent\n color=\"primary\"\n {...dialogContentProps}\n onCloseAutoFocus={combineEventHandlers(\n dialogContentProps?.onCloseAutoFocus,\n // eslint-disable-next-line react-hooks/refs\n handleCloseAutoFocus,\n { checkDefaultPrevented: true },\n )}\n portalProps={{\n container: formAppEl,\n ...dialogContentProps?.portalProps,\n }}\n >\n {submissionInfo && (\n <>\n <AlertDialogHeader {...dialogHeaderProps}>\n <AlertDialogTitle {...dialogTitleProps}>\n {typeof dialogTitle === \"function\"\n ? dialogTitle(submissionInfo.value, submissionInfo.warnings)\n : dialogTitle}\n </AlertDialogTitle>\n </AlertDialogHeader>\n\n <AlertDialogBody {...dialogBodyProps}>\n {dialogDescription && (\n <AlertDialogDescription\n {...dialogDescriptionProps}\n className={cx(\n prefix(\"submit-action__dialog-description\"),\n dialogDescriptionProps?.className,\n )}\n >\n {typeof dialogDescription === \"function\"\n ? dialogDescription(\n submissionInfo.value,\n submissionInfo.warnings,\n )\n : dialogDescription}\n </AlertDialogDescription>\n )}\n\n {typeof dialogBody === \"function\"\n ? dialogBody(submissionInfo.value, submissionInfo.warnings)\n : dialogBody}\n\n {confirmWarnings &&\n (submissionInfo.warnings?.length ?? 0) > 0 && (\n <Alert\n severity=\"warning\"\n {...confirmWarningsAlertProps}\n containerProps={{\n ...confirmWarningsAlertProps?.containerProps,\n className: cx(\n prefix(\n \"submit-action__confirm-warnings-alert-container\",\n ),\n confirmWarningsAlertProps?.containerProps?.className,\n ),\n }}\n >\n <Checkbox\n status=\"warned\"\n {...confirmWarningsCheckboxProps}\n checked={allWarningsChecked}\n onCheckedChange={handleOnCheckedChange}\n >\n {confirmWarningsCheckboxLabel}\n </Checkbox>\n </Alert>\n )}\n </AlertDialogBody>\n\n <AlertDialogFooter {...dialogFooterProps}>\n <AlertDialogCancel disabled={runningOnSubmit}>\n <Button variant=\"subtle\" {...dialogCancelButtonProps}>\n {dialogCancelText}\n </Button>\n </AlertDialogCancel>\n\n <AlertDialogAction onClick={handleConfirmSubmit}>\n <Button\n type=\"submit\"\n color=\"primary\"\n icon={faArrowRight}\n iconPlacement=\"end\"\n {...dialogOkButtonProps}\n loading={runningOnSubmit || dialogOkButtonProps?.loading}\n disabled={\n (confirmWarnings && !allWarningsChecked) ||\n dialogOkButtonProps?.disabled\n }\n >\n {dialogOkText}\n </Button>\n </AlertDialogAction>\n </AlertDialogFooter>\n </>\n )}\n </AlertDialogContent>\n </AlertDialog>\n )\n );\n}\n","import type { AbsolutePath, Table, TableRowId } from \"@ostack.tech/kform\";\nimport type { FormatterController } from \"@ostack.tech/kform-react\";\nimport { createContext, type Ref, useContext } from \"react\";\n\nimport type { UseRegisterControlResult } from \"../../utils/useRegisterControl.tsx\";\nimport type { TableControlRowController } from \"./TableControlRow.tsx\";\n\n/** Value of the table control context. */\nexport interface TableControlContextValue<\n T = any,\n TTable extends Table<T> | null = Table<T> | null,\n> {\n controller: TableControlController<T, TTable>;\n autofocusRef: Ref<HTMLDivElement>;\n handleFocus: UseRegisterControlResult<HTMLDivElement>[\"handleFocus\"];\n size?: number;\n maxRows?: number;\n debug?: boolean;\n}\n\n/** Controller of the table control. */\nexport type TableControlController<\n T = any,\n TTable extends Table<T> | null = Table<T> | null,\n> = FormatterController<TTable, TableRowId[]> & {\n addRow: () => PromiseLike<void> | void;\n removeRow: (path: AbsolutePath) => PromiseLike<void> | void;\n};\n\n/** Table control context. */\nexport const TableControlContext =\n createContext<TableControlContextValue | null>(null);\n\n/** Hook providing access to the table control context. */\nexport function useTableControlContext<\n T = unknown,\n TTable extends Table<T> | null = Table<T> | null,\n>(): TableControlContextValue<T, TTable> {\n const tableControlContext = useContext(TableControlContext);\n if (!tableControlContext) {\n throw new Error(\"Table control context not in scope.\");\n }\n return tableControlContext as unknown as TableControlContextValue<T, TTable>;\n}\n\n/** Table control row context. */\nexport const TableControlRowContext =\n createContext<TableControlRowController | null>(null);\n\n/** Hook providing access to the table control row context. */\nexport function useTableControlRowContext<T>(): TableControlRowController<T> {\n const tableControlRowContext = useContext(TableControlRowContext);\n if (!tableControlRowContext) {\n throw new Error(\"Table control row context not in scope.\");\n }\n return tableControlRowContext as TableControlRowController<T>;\n}\n","import {\n DataTableCell,\n type DataTableCellProps,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport { useDeferredValue } from \"react\";\n\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useTableControlRowContext } from \"./TableControlContext.ts\";\n\n/** Properties of the table control cell. */\nexport interface TableControlCellProps extends DataTableCellProps {}\n\n/** Cell of the table control. */\nexport function TableControlCell({\n variant,\n ...otherProps\n}: TableControlCellProps) {\n const printing = usePrinting();\n const { useDisplayStatus } = useTableControlRowContext();\n const deferredDisplayStatus = useDeferredValue(useDisplayStatus());\n\n return (\n <DataTableCell\n variant={variant}\n // When the cell has a \"header\" variant, set its status from the row's\n // display status\n status={\n !printing && variant === \"header\"\n ? displayStatusToControlStatus(deferredDisplayStatus)\n : undefined\n }\n {...otherProps}\n />\n );\n}\n","import type { DataTableColumnObject } from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport type { TableControlRowController } from \"./TableControlRow.tsx\";\n\n/** Object representation of a table control column. */\nexport interface TableControlColumnObject<\n T = unknown,\n TValue = any,\n> extends Omit<\n DataTableColumnObject<T, TValue>,\n | \"getValue\"\n | \"format\"\n | \"render\"\n | \"compare\"\n | \"filterable\"\n | \"sortable\"\n | \"footer\"\n> {\n /** Rendering of the cell content. */\n render?:\n ReactNode | ((rowController: TableControlRowController<T>) => ReactNode);\n /** Optional footer content to be rendered in the column footer. */\n footer?: ReactNode;\n /**\n * Whether this column should be shown when the table control is in read-only\n * mode.\n */\n showWhenReadOnly?: boolean;\n}\n\n/** Properties of the table control column component. */\nexport interface TableControlColumnProps<T = any, TValue = any> extends Omit<\n TableControlColumnObject<T, TValue>,\n \"subColumns\"\n> {\n /**\n * Rendering of the cell content. If both `render` and `children` are\n * provided, `render` takes priority.\n */\n children?:\n ReactNode | ((rowController: TableControlRowController<T>) => ReactNode);\n}\n\n/**\n * Definition of a table control column.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `TableControl` component to automatically create the `columns` object.\n */\nexport function TableControlColumn<T = any, TValue = any>(\n _props: TableControlColumnProps<T, TValue>,\n) {\n return null;\n}\n","import type { DataTableColumnGroupObject } from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport type { TableControlColumnObjects } from \"./TableControl.tsx\";\n\n/** Object representation of a table control column. */\nexport interface TableControlColumnGroupObject<T = unknown> extends Omit<\n DataTableColumnGroupObject,\n \"subColumns\"\n> {\n /** Sub columns of this column group. */\n subColumns?: TableControlColumnObjects<T>;\n /**\n * Whether this column group should be shown when the table control is in\n * read-only mode.\n */\n showWhenReadOnly?: boolean;\n}\n\n/** Properties of the table control column component. */\nexport interface TableControlColumnGroupProps extends Omit<\n TableControlColumnGroupObject,\n \"subColumns\"\n> {\n /** Sub-columns of this table control column. */\n children?: ReactNode;\n}\n\n/**\n * Definition of a table control column group.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `TableControl` component to automatically create the `columns` object.\n */\nexport function TableControlColumnGroup(_props: TableControlColumnGroupProps) {\n return null;\n}\n","import type { ReactNode } from \"react\";\n\n/** Properties of the table control columns component. */\nexport interface TableControlColumnsProps {\n /** Table control columns. */\n children: ReactNode;\n}\n\n/**\n * Container for the definition of all table control columns. This component\n * must be a direct child of the `TableControl` component.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `TableControl` component to automatically create the `columns` object.\n */\nexport function TableControlColumns(_props: TableControlColumnsProps) {\n return null;\n}\n","import type { TableRowId } from \"@ostack.tech/kform\";\nimport {\n type Controller,\n CurrentPath,\n useController,\n} from \"@ostack.tech/kform-react\";\nimport {\n DataTableRow,\n type DataTableRowProps,\n useStartPrintingTask,\n} from \"@ostack.tech/ui\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterController, useRegisterLabel } from \"../FormApp\";\nimport { TableControlRowContext } from \"./TableControlContext.ts\";\n\n/** Controller of a table row. */\nexport type TableControlRowController<T = unknown> = Controller<T> & {\n /** Row index. */\n index: number;\n};\n\n/** Properties of the table control row. */\nexport interface TableControlRowProps extends DataTableRowProps {\n row: TableRowId;\n}\n\n/** Row of a table control. */\nexport function TableControlRow({\n row,\n index,\n ...otherProps\n}: TableControlRowProps) {\n const controller = useController(row?.toString(), {\n enabled: !useFormIsLoading() && row != null,\n });\n const tableControlRowController = useMemo(\n () => ({ index, ...controller }),\n [controller, index],\n );\n const path = controller.usePath();\n useRegisterController(controller);\n useRegisterLabel(path, row == null ? null : index + 1);\n\n // Start a printing task until the row is initialised\n const initialized = controller.useInitialized();\n const finishPrintingTask = useStartPrintingTask({ enabled: row != null });\n useEffect(() => {\n if (initialized) {\n finishPrintingTask();\n }\n }, [finishPrintingTask, initialized]);\n\n return (\n <CurrentPath path={path}>\n <TableControlRowContext.Provider value={tableControlRowController}>\n <DataTableRow row={row} index={index} {...otherProps} />\n </TableControlRowContext.Provider>\n </CurrentPath>\n );\n}\n","import {\n AbsolutePath,\n AbsolutePathFragment,\n arrayToTable,\n type CancellablePromise,\n isComputedSchema,\n type Path,\n type Schema,\n type Table,\n tableIdsToArray,\n type TableRowId,\n} from \"@ostack.tech/kform\";\nimport {\n type ControllerOptions,\n CurrentPath,\n InvalidPathError,\n useFormatter,\n} from \"@ostack.tech/kform-react\";\nimport {\n cx,\n DataTable,\n type DataTableColumnsObject,\n type DataTableProps,\n type DataTableScrollToOptions,\n FeedbackProvider,\n parseChildren,\n useDataTableApiRef,\n} from \"@ostack.tech/ui\";\nimport {\n Children,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useImperativeHandle,\n useMemo,\n useState,\n} from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { isPromiseLike } from \"../../utils/promiseUtils.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { FormAppStatus, useFormInDebugMode, useOnPathFocus } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport type { TableControlApi } from \"./TableControlApi.ts\";\nimport { TableControlCell } from \"./TableControlCell.tsx\";\nimport {\n TableControlColumn,\n type TableControlColumnObject,\n} from \"./TableControlColumn.tsx\";\nimport {\n TableControlColumnGroup,\n type TableControlColumnGroupObject,\n} from \"./TableControlColumnGroup.tsx\";\nimport {\n TableControlColumns,\n type TableControlColumnsProps,\n} from \"./TableControlColumns.tsx\";\nimport {\n TableControlContext,\n useTableControlRowContext,\n} from \"./TableControlContext.ts\";\nimport {\n TableControlRow,\n type TableControlRowController,\n} from \"./TableControlRow.tsx\";\n\n/** Array of table control columns. */\nexport type TableControlColumnObjects<T = unknown> = (\n TableControlColumnObject<T> | TableControlColumnGroupObject<T>\n)[];\n\n/** Properties of the table control component. */\nexport interface TableControlProps<\n T = unknown,\n TTable extends Table<T> | null = Table<T> | null,\n>\n extends\n Omit<\n DataTableProps,\n | \"columns\"\n | \"rows\"\n | \"onVisibleRowsChange\"\n | \"onProcessedRowsChange\"\n | \"getRows\"\n | \"rowKey\"\n | \"loading\"\n | \"defaultFilter\"\n | \"filter\"\n | \"onFilterChange\"\n | \"defaultSortBy\"\n | \"sortBy\"\n | \"defaultSortDirection\"\n | \"sortDirection\"\n | \"onSort\"\n | \"showSelectionColumn\"\n | \"selectionMode\"\n | \"defaultSelectedRows\"\n | \"selectedRows\"\n | \"onSelectedRowsChange\"\n | \"selectAllChecked\"\n | \"onSelectAll\"\n | \"showAllRowsWhilePrinting\"\n | \"apiRef\"\n >,\n Omit<ControllerOptions<TTable>, \"enabled\"> {\n /** Control's path. */\n path?: string | Path;\n /** Table control columns in object notation. */\n columns?: TableControlColumnObjects<T>;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this table.\n *\n * This label has priority over the table's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Sets the maximum number of rows that the table can have. By default, if the\n * table's schema has a `Size` or `MaxSize` validation, then its value is\n * used.\n */\n maxRows?: number;\n /**\n * Function called when a row is being added to choose the value that should\n * be added.\n *\n * The default value being added is provided as an argument and may be edited\n * if required.\n *\n * The value to be added should be returned, or a promise that resolves with\n * said value.\n *\n * To prevent a row from being added, return `undefined`/`null` (or a promise\n * which resolves with `undefined`/`null`).\n *\n * @param value - Value being added, can be edited.\n * @returns Value to be added, `undefined`/`null` if the row shouldn't be\n * added (or a promise that resolves with said values).\n */\n getRowValue?: (\n value: T,\n ) => T | null | undefined | PromiseLike<T | null | undefined>;\n /** Sets the table control as disabled. */\n disabled?: boolean;\n /** Sets the table control as read-only. */\n readOnly?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<TableControlApi<T, TTable> | undefined>;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The table control component is a KForm form control for values with (possibly\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)\n * and items of any type. It is built on top of the\n * [`DataTable`](/docs/ostack-ui-data-display-data-table--docs) component.\n *\n * It composes the following subcomponents:\n *\n * - `TableControlColumns`: Container for the definition of all table control\n * columns and their groups.\n * - `TableControlColumn`: Component used to define a column of the table control.\n * - `TableControlColumnGroup`: Component used to define a column group of the\n * table control.\n * - `TableControlContent`: Main content of the table control, containing the\n * table itself.\n * - `TableControlAddRowTrigger`: Trigger used to add a new row to the table.\n * - `TableControlRemoveRowTrigger`: Trigger used to remove a row from the table.\n * - `DataTablePagination`: Optional pagination component of the table control,\n * showing the current scroll progress in the default `scrolled` mode and\n * allowing the selection of the current page in `paged` mode.\n * - `TableControlRowsPerPage`: Optional component allowing the selection of the\n * number of rows to display per page.\n * - `TableControlIndexColumn`: Built-in column displaying the number of each row.\n * - `TableControlActionsColumn`: Built-in column displaying actions that can be\n * performed on each row; displays a `TableControlRemoveRowTrigger` by\n * default.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):\n * Sets the `maxRows` properties.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * NumericControl,\n * TableControl,\n * TableControlActionsColumn,\n * TableControlAddRowTrigger,\n * TableControlColumn,\n * TableControlContent,\n * TextControl,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function InventoryControl() {\n * return (\n * <TableControl path=\"/inventory\">\n * <TableControlColumns>\n * <TableControlColumn label=\"Description\">\n * <TextControl path=\"description\" />\n * </TableControlColumn>\n * <TableControlColumn label=\"Quantity\">\n * <NumericControl path=\"quantity\" />\n * </TableControlColumn>\n * <TableControlActionsColumn removeRowLabel=\"Remove item\" />\n * </TableControlColumns>\n * <TableControlAddRowTrigger label=\"Add item\" />\n * <TableControlContent caption=\"Inventory\" />\n * </TableControl>\n * );\n * }\n * ```\n */\nexport function TableControl<\n T = unknown,\n TTable extends Table<T> | null = Table<T> | null,\n>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n columns: columnsProp,\n required,\n maxRows,\n getRowValue,\n disabled = false,\n readOnly = false,\n className,\n debug,\n children,\n ...otherProps\n}: TableControlProps<T, TTable>) {\n const prefix = usePrefix();\n const [ids, setIds] = useState<TableRowId[] | undefined>(undefined);\n const size = ids?.length;\n const dataTableApiRef = useDataTableApiRef();\n\n const controller = useFormatter<TTable, TableRowId[]>(path, {\n enabled: !useFormIsLoading(),\n format: useCallback(\n (value?: TTable) => (value ? tableIdsToArray(value) : []),\n [],\n ),\n setFormattedValue: setIds,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n\n const { useSchema, usePath, useInitialized, useExists } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const initialized = useInitialized();\n const exists = useExists();\n const { restrictions } = schema.typeInfo;\n const maxRowsRestriction =\n maxRows ??\n (typeof restrictions.maxSize === \"number\"\n ? restrictions.maxSize\n : undefined);\n const elementsSchema: Schema<T> = controller.useState((state) =>\n state.formManager.schema(state.path.append(AbsolutePathFragment.Wildcard)),\n );\n const showDebugInfo = useFormInDebugMode() || debug;\n\n if (schema.typeInfo.name !== \"Table\") {\n throw new InvalidPathError(\n absolutePath,\n \"Unsupported schema: Expected (possibly nullable) table schema, \" +\n \"but got schema representing values of type \" +\n `'${schema.typeInfo.toString()}'.`,\n );\n }\n\n const ownController = useMemo(\n () => ({\n addRow: async () => {\n const { schema, initialized, exists, touched, dirty } =\n controller.getState();\n if (\n !initialized ||\n !exists ||\n (maxRowsRestriction != null && size! >= maxRowsRestriction)\n ) {\n return;\n }\n\n let toAdd: T | null | undefined = elementsSchema.initialValue;\n if (getRowValue) {\n const clonedValue = await elementsSchema.clone(toAdd);\n controller._setState({ gettingRowValue: true } as any);\n try {\n const getRowValueResult = getRowValue(clonedValue);\n toAdd = isPromiseLike(getRowValueResult)\n ? await getRowValueResult\n : getRowValueResult;\n } finally {\n controller._setState({ gettingRowValue: false } as any);\n }\n }\n if (toAdd == null) {\n return;\n }\n\n const setPromise: CancellablePromise<void> =\n schema.typeInfo.nullable && size === 0\n ? controller.set(arrayToTable([toAdd]) as TTable)\n : controller.set(\"-\", toAdd);\n setPromise.then(() =>\n queueMicrotask(() => dataTableApiRef.current?.goTo(size!)),\n );\n\n if (!touched) {\n void controller.setTouched();\n }\n if (!dirty) {\n void controller.setDirty();\n }\n return setPromise;\n },\n removeRow: (path: AbsolutePath) => {\n const { formManager, schema, initialized, exists, touched, dirty } =\n controller.getState();\n if (!initialized || !exists) {\n return;\n }\n\n const removePromise =\n schema.typeInfo.nullable && size === 1\n ? controller.set(null as TTable)\n : formManager.remove(path);\n\n if (!touched) {\n void controller.setTouched();\n }\n if (!dirty) {\n void controller.setDirty();\n }\n return removePromise;\n },\n }),\n [\n controller,\n maxRowsRestriction,\n size,\n elementsSchema,\n getRowValue,\n dataTableApiRef,\n ],\n );\n\n // Expose the control's API via `apiRef`\n const goToIndex = useCallback(\n (index: number, scrollOptions?: DataTableScrollToOptions) => {\n dataTableApiRef.current?.goTo(index, scrollOptions);\n },\n [dataTableApiRef],\n );\n const goToId = useCallback(\n (id: number, scrollOptions?: DataTableScrollToOptions) => {\n const idx = ids?.indexOf(id) ?? -1;\n if (idx !== -1) {\n dataTableApiRef.current?.goTo(idx, scrollOptions);\n }\n },\n [dataTableApiRef, ids],\n );\n\n // Register the control\n const {\n displayDisabled,\n displayReadOnly,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<TTable, HTMLDivElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n });\n const controlIsDisabled =\n displayDisabled || disabled || (initialized && !exists);\n const controlIsReadOnly =\n displayReadOnly || readOnly || isComputedSchema(schema);\n\n useImperativeHandle(\n apiRef,\n () => ({\n ...controller,\n goToIndex,\n goToId,\n }),\n [controller, goToId, goToIndex],\n );\n\n // Go to row with active path when it changes\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n if (\n exists &&\n ids &&\n focusedPath &&\n absolutePath.resolve(AbsolutePath.DESCENDANTS).contains(focusedPath)\n ) {\n const rowId = focusedPath.fragments[absolutePath.size];\n if (rowId instanceof AbsolutePathFragment.Id) {\n queueMicrotask(() =>\n goToId(+rowId.id, { align: \"center\", behavior: \"smooth\" }),\n );\n }\n }\n },\n [absolutePath, exists, goToId, ids],\n ),\n );\n\n // Parse columns from children\n let columns = columnsProp;\n if (!columns) {\n const columnsElem = Children.toArray(children).find(\n (child) => isValidElement(child) && child.type === TableControlColumns,\n ) as ReactElement<TableControlColumnsProps, typeof TableControlColumns>;\n columns = parseChildren(columnsElem.props.children, TableControlColumn, {\n groupType: TableControlColumnGroup,\n groupProp: \"subColumns\",\n allowNestedGroups: true,\n transformChildObject: ({ children, render, ...otherProps }) => ({\n render: render ?? children,\n ...otherProps,\n }),\n });\n }\n\n const dataTableColumns: DataTableColumnsObject<TableRowId> = useMemo(\n () => tableControlToDataTableColumns(columns, controlIsReadOnly),\n [columns, controlIsReadOnly],\n );\n\n const tableControlController = useMemo(\n () => ({ ...controller, ...ownController }),\n [controller, ownController],\n );\n\n const { inlineIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n });\n\n return (\n <FormAppStatus disabled={controlIsDisabled} readOnly={controlIsReadOnly}>\n <TableControlContext.Provider\n value={{\n controller: tableControlController as never,\n autofocusRef,\n handleFocus,\n size,\n maxRows: maxRowsRestriction,\n debug: showDebugInfo,\n }}\n >\n <CurrentPath path={absolutePath}>\n <FeedbackProvider>\n <DataTable\n className={cx(prefix(\"table-control\"), className)}\n displayMode=\"scrolled\"\n columns={dataTableColumns}\n rows={ids}\n rowKey={(id: TableRowId) => id}\n required={required ?? restrictions.required === true}\n loading={!initialized}\n renderRow={(props) => <TableControlRow {...props} />}\n renderCell={(props) => <TableControlCell {...props} />}\n showAllRowsWhilePrinting\n apiRef={dataTableApiRef}\n {...otherProps}\n >\n {children}\n </DataTable>\n {inlineIssues}\n </FeedbackProvider>\n </CurrentPath>\n </TableControlContext.Provider>\n </FormAppStatus>\n );\n}\n\nfunction tableControlToDataTableColumns<T>(\n columns: TableControlColumnObjects<T>,\n readOnly: boolean,\n columnIdPrefix = \"col\",\n): DataTableColumnsObject<TableRowId> {\n return columns.reduce(\n (columns: DataTableColumnsObject<TableRowId>, column, i) => {\n const {\n subColumns,\n render,\n showWhenReadOnly = true,\n ...otherColumn\n } = column as TableControlColumnObject<T>;\n if (readOnly && !showWhenReadOnly) {\n return columns;\n }\n const columnId = `${columnIdPrefix}-${i}`;\n if (subColumns) {\n columns[columnId] = {\n ...otherColumn,\n subColumns: tableControlToDataTableColumns(\n subColumns,\n readOnly,\n columnId,\n ),\n };\n } else {\n columns[columnId] = {\n ...otherColumn,\n sortable: false,\n filterable: false,\n render:\n typeof render === \"function\"\n ? () => <TableControlCellRenderer render={render} />\n : render,\n };\n }\n return columns;\n },\n {},\n );\n}\n\n/** Properties of the table control cell renderer. */\nexport interface TableControlCellRendererProps<T = unknown> {\n render: (rowController: TableControlRowController<T>) => ReactNode;\n}\n\n/** Renderer of a table control cell. */\nexport function TableControlCellRenderer<T = unknown>({\n render,\n}: TableControlCellRendererProps<T>) {\n return render(useTableControlRowContext<T>());\n}\n","import { useLocale } from \"../../providers/LocalizationProvider\";\n\n/** Default label of the table control's actions column. */\nexport function TableControlActionsColumnLabel() {\n const [locale] = useLocale();\n return locale.TableControlActionsColumn.label;\n}\n","import { useLocale } from \"../../providers/LocalizationProvider\";\n\n/** Default label of the table control's index column. */\nexport function TableControlIndexColumnLabel() {\n const [locale] = useLocale();\n return locale.TableControlIndexColumn.label ?? \"#\";\n}\n","import { faTrash } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n combineEventHandlers,\n IconButton,\n type IconButtonProps,\n Slot,\n useAlertDialog,\n} from \"@ostack.tech/ui\";\nimport { type ComponentProps, type ReactNode, useState } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { useFormIsDisabled, useFormIsReadOnly } from \"../FormApp\";\nimport { useSetLatestInteraction } from \"../FormApp/FormAppContext.ts\";\nimport {\n useTableControlContext,\n useTableControlRowContext,\n} from \"./TableControlContext.ts\";\n\n/** Properties of the table control remove row trigger component. */\nexport type TableControlRemoveRowTriggerProps =\n | TableControlRemoveRowTriggerChildlessProps\n | TableControlRemoveRowTriggerChildrenProps;\n\n/** Base properties of the table control remove row trigger component. */\nexport interface TableControlRemoveRowTriggerChildlessPropsBase {\n /**\n * Whether to show a confirmation message when removing a row.\n *\n * @default false\n */\n showConfirmation?: boolean;\n /**\n * Function called after confirmation that the row is to be removed (this\n * function is called even if `showConfirmation` is not set).\n */\n onConfirmRowRemoval?: () => void;\n /** Function called after the row has been removed. */\n onRowRemoved?: () => void;\n /** Title of the confirmation dialog when `showConfirmation` is `true`. */\n confirmDialogTitle?: ReactNode;\n /**\n * Message of the confirmation dialog when `showConfirmation` is `true`.\n *\n * @param index Index of the row being removed.\n */\n confirmDialogMessage?: (index: number) => ReactNode;\n /**\n * Ok button text of the confirmation dialog when `showConfirmation` is\n * `true`.\n */\n confirmDialogOkText?: ReactNode;\n /**\n * Cancel button text of the confirmation dialog when `showConfirmation` is\n * `true`.\n */\n confirmDialogCancelText?: ReactNode;\n /**\n * Whether to show the trigger when the table is read-only.\n *\n * @default false\n */\n showWhenReadOnly?: boolean;\n}\n\n/**\n * Base properties of the table control remove row trigger component when\n * rendered without children.\n */\nexport interface TableControlRemoveRowTriggerChildlessProps\n extends\n TableControlRemoveRowTriggerChildlessPropsBase,\n Omit<Partial<IconButtonProps>, \"asChild\" | \"children\"> {\n /**\n * Label of the icon button.\n *\n * @deprecated Use `label` instead.\n */\n defaultButtonLabel?: ReactNode;\n children?: never;\n}\n\n/**\n * Base properties of the table control remove row trigger component when\n * rendered with children.\n */\nexport interface TableControlRemoveRowTriggerChildrenProps\n extends\n TableControlRemoveRowTriggerChildlessPropsBase,\n Partial<ComponentProps<\"button\">> {\n children: ReactNode;\n}\n\n/**\n * Trigger used to remove a row of a table controlled by a table control.\n *\n * By default, it renders an icon button with label `defaultButtonLabel`,\n * however, this can be overriden by providing `children`.\n */\nexport function TableControlRemoveRowTrigger({\n showConfirmation,\n onConfirmRowRemoval,\n onRowRemoved,\n confirmDialogTitle,\n confirmDialogMessage,\n confirmDialogOkText,\n confirmDialogCancelText,\n showWhenReadOnly,\n disabled,\n onClick,\n children,\n ...otherProps\n}: TableControlRemoveRowTriggerProps) {\n const [locale] = useLocale();\n const {\n defaultButtonLabel,\n label = defaultButtonLabel ?? locale.TableControlRemoveRowTrigger.label,\n ...iconButtonProps\n } = otherProps as TableControlRemoveRowTriggerChildlessProps;\n confirmDialogTitle ??=\n locale.TableControlRemoveRowTrigger.confirmDialogTitle ?? label;\n confirmDialogMessage ??=\n locale.TableControlRemoveRowTrigger.confirmDialogMessage;\n confirmDialogOkText ??=\n locale.TableControlRemoveRowTrigger.confirmDialogOkText;\n confirmDialogCancelText ??=\n locale.TableControlRemoveRowTrigger.confirmDialogCancelText;\n\n const { confirm } = useAlertDialog();\n const { controller } = useTableControlContext();\n const controlIsDisabled = useFormIsDisabled();\n const controlIsReadOnly = useFormIsReadOnly();\n const { getState, index, useInitialized, useExists } =\n useTableControlRowContext();\n const initialized = useInitialized();\n const exists = useExists();\n const setLatestInteraction = useSetLatestInteraction();\n\n const [removing, setRemoving] = useState(false);\n const handleClick = async () => {\n setLatestInteraction(controller.getState().path);\n const { path, dirty } = getState();\n if (\n removing ||\n (showConfirmation &&\n dirty &&\n !(await confirm(confirmDialogMessage!(index), {\n title: confirmDialogTitle,\n color: \"danger\",\n okText: confirmDialogOkText,\n cancelText: confirmDialogCancelText,\n })))\n ) {\n return;\n }\n\n setRemoving(true);\n try {\n onConfirmRowRemoval?.();\n await controller.removeRow(path);\n onRowRemoved?.();\n } catch {\n setRemoving(false);\n }\n };\n\n if (!showWhenReadOnly && controlIsReadOnly) {\n return null;\n }\n\n const commonProps = {\n disabled:\n !initialized ||\n !exists ||\n controlIsDisabled ||\n disabled ||\n controlIsReadOnly ||\n (removing && children !== undefined),\n onClick: combineEventHandlers(onClick, handleClick, {\n checkDefaultPrevented: true,\n }),\n };\n if (children === undefined) {\n return (\n <IconButton\n icon={faTrash}\n label={label}\n color=\"danger\"\n loading={!initialized || removing}\n circle\n {...iconButtonProps}\n {...commonProps}\n />\n );\n }\n return (\n <Slot {...otherProps} {...commonProps}>\n {children}\n </Slot>\n );\n}\n","import type { ReactNode } from \"react\";\n\nimport { TableControlActionsColumnLabel } from \"./TableControlActionsColumnLabel.tsx\";\nimport type { TableControlColumnObject } from \"./TableControlColumn.tsx\";\nimport { TableControlIndexColumnLabel } from \"./TableControlIndexColumnLabel.tsx\";\nimport {\n TableControlRemoveRowTrigger,\n type TableControlRemoveRowTriggerProps,\n} from \"./TableControlRemoveRowTrigger.tsx\";\n\n/** Properties used to configure the `tableControlIndexColumn` function. */\nexport interface TableControlIndexColumnFnProps<\n T = unknown,\n TValue = any,\n> extends TableControlColumnObject<T, TValue> {}\n\n/**\n * Pre-configured column used to display the index of each row. By default, it\n * sticks to left of the table.\n *\n * @param props Column properties to override the defaults.\n * @returns Table control column used to display the index of each row.\n */\nexport function tableControlIndexColumn<T = unknown, TValue = any>({\n render,\n ...otherProps\n}: TableControlIndexColumnFnProps<T, TValue> = {}): TableControlColumnObject<\n T,\n TValue\n> {\n return {\n label: <TableControlIndexColumnLabel />,\n header: true,\n sticky: \"left\",\n width: 65,\n fixed: true,\n align: \"center\",\n render: render ?? (({ index }) => index + 1),\n ...otherProps,\n };\n}\n\n/** Properties used to configure the `tableControlActionsColumn` function. */\nexport interface TableControlActionsColumnFnProps<\n T = unknown,\n TValue = any,\n> extends TableControlColumnObject<T, TValue> {\n /**\n * Set the `label` property of the `TableControlRemoveRowTrigger` component\n * rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n removeRowLabel?: ReactNode;\n /**\n * Sets the `showConfirmation` property of the `TableControlRemoveRowTrigger`\n * component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n showRowRemovalConfirmation?: boolean;\n /**\n * Sets the `onConfirmRowRemoval` property of the\n * `TableControlRemoveRowTrigger` component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n onConfirmRowRemoval?: () => void;\n /**\n * Sets the `onRowRemoved` property of the `TableControlRemoveRowTrigger`\n * component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n onRowRemoved?: () => void;\n /**\n * Sets the `confirmDialogTitle` property of the\n * `TableControlRemoveRowTrigger` component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n confirmRowRemovalDialogTitle?: ReactNode;\n /**\n * Sets the `confirmDialogMessage` property of the\n * `TableControlRemoveRowTrigger` component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n confirmRowRemovalDialogMessage?: (index: number) => ReactNode;\n /**\n * Sets the `confirmDialogOkText` property of the\n * `TableControlRemoveRowTrigger` component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n confirmRowRemovalDialogOkText?: ReactNode;\n /**\n * Sets the `confirmDialogCancelText` property of the\n * `TableControlRemoveRowTrigger` component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n confirmRowRemovalDialogCancelText?: ReactNode;\n /**\n * Properties to pass to the `TableControlRemoveRowTrigger` component rendered\n * by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n removeRowProps?: TableControlRemoveRowTriggerProps;\n}\n\n/**\n * Pre-configured column used to display row actions. By default, it sticks to\n * the right of the table and renders the `TableControlRemoveRowTrigger`\n * component.\n *\n * Its configuration can be overridden to show other actions, for example, an\n * edit button:\n *\n * ```tsx\n * tableControlActionsColumn({\n * width: 100,\n * render: () => (\n * <>\n * <IconButton label=\"Edit row\" icon={faPencil} />\n * <TableControlRemoveRowTrigger />\n * </>\n * ),\n * });\n * ```\n *\n * @param overrides Column properties used to display the actions of each row.\n * @returns Table control column used to display the actions of each row.\n */\nexport function tableControlActionsColumn<T = unknown, TValue = any>({\n removeRowLabel,\n showRowRemovalConfirmation,\n onConfirmRowRemoval,\n onRowRemoved,\n confirmRowRemovalDialogTitle,\n confirmRowRemovalDialogMessage,\n confirmRowRemovalDialogOkText,\n confirmRowRemovalDialogCancelText,\n removeRowProps,\n render,\n ...otherProps\n}: TableControlActionsColumnFnProps<T, TValue> = {}): TableControlColumnObject<\n T,\n TValue\n> {\n return {\n label: <TableControlActionsColumnLabel />,\n sticky: \"right\",\n width: 50,\n fixed: true,\n align: \"center\",\n showWhilePrinting: false,\n showWhenReadOnly: false,\n render: render ?? (\n <TableControlRemoveRowTrigger\n label={removeRowLabel}\n showConfirmation={showRowRemovalConfirmation}\n onConfirmRowRemoval={onConfirmRowRemoval}\n onRowRemoved={onRowRemoved}\n confirmDialogTitle={confirmRowRemovalDialogTitle}\n confirmDialogMessage={confirmRowRemovalDialogMessage}\n confirmDialogOkText={confirmRowRemovalDialogOkText}\n confirmDialogCancelText={confirmRowRemovalDialogCancelText}\n {...removeRowProps}\n />\n ),\n ...otherProps,\n };\n}\n","import {\n TableControlColumn,\n type TableControlColumnObject,\n type TableControlColumnProps,\n} from \"./TableControlColumn.tsx\";\nimport {\n tableControlActionsColumn,\n type TableControlActionsColumnFnProps,\n} from \"./TableControlColumnFns.tsx\";\n\n/** Properties of the table control actions column. */\nexport interface TableControlActionsColumnProps\n extends\n TableControlColumnProps,\n Omit<TableControlActionsColumnFnProps, keyof TableControlColumnObject> {}\n\n/**\n * Pre-configured column used to display row actions. By default, it sticks to\n * the right of the table and renders the `TableControlRemoveRowTrigger`\n * component.\n *\n * Its configuration can be overridden to show other actions, e.g. an edit\n * button:\n *\n * ```tsx\n * <TableControlActionsColumn width={100}>\n * <IconButton label=\"Edit item\" icon={faPencil} />\n * <TableControlRemoveRowTrigger label=\"Remove item\" />\n * </TableControlActionsColumn>;\n * ```\n */\nexport function TableControlActionsColumn({\n render,\n children,\n ...otherProps\n}: TableControlActionsColumnProps) {\n return (\n <TableControlColumn\n {...tableControlActionsColumn({\n ...otherProps,\n render: render ?? children,\n })}\n />\n );\n}\n","import { faPlus } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n boolDataAttr,\n Button,\n type ButtonProps,\n combineEventHandlers,\n cx,\n Slot,\n usePrintClassNames,\n} from \"@ostack.tech/ui\";\nimport { type ComponentProps, type ReactNode, useState } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useFormIsDisabled, useFormIsReadOnly } from \"../FormApp\";\nimport { useSetLatestInteraction } from \"../FormApp/FormAppContext.ts\";\nimport { useTableControlContext } from \"./TableControlContext.ts\";\n\n/** Properties of the table control add row trigger component. */\nexport type TableControlAddRowTriggerProps =\n | TableControlAddRowTriggerChildlessProps\n | TableControlAddRowTriggerChildrenProps;\n\n/** Base properties of the table control add row trigger component. */\nexport interface TableControlAddRowTriggerPropsBase {\n /**\n * Whether to disable the trigger (and show a loading button by default) while\n * a row is being added.\n *\n * @default false\n */\n disableWhileAdding?: boolean;\n /** Function called after the row has been added. */\n onRowAdded?: () => void;\n /**\n * Whether the component should preferably be aligned to the right. This only\n * has an effect when the component is nested directly under the `DataTable`.\n *\n * @default true\n */\n preferRightAlignment?: boolean;\n /**\n * Whether to show the trigger when the table is read-only.\n *\n * @default false\n */\n showWhenReadOnly?: boolean;\n /**\n * Whether to show the trigger when it is being printed.\n *\n * @default false\n */\n showWhilePrinting?: boolean;\n}\n\n/**\n * Properties of the table control add row trigger component when rendered\n * without children.\n */\nexport interface TableControlAddRowTriggerChildlessProps\n extends\n TableControlAddRowTriggerPropsBase,\n Omit<ButtonProps, \"asChild\" | \"children\"> {\n /** Label displayed on the button. */\n label?: ReactNode;\n /**\n * Label displayed on the button.\n *\n * @deprecated Use `label` instead.\n */\n defaultButtonText?: ReactNode;\n children?: never;\n}\n\n/**\n * Properties of the table control add row trigger component when rendered with\n * children.\n */\nexport interface TableControlAddRowTriggerChildrenProps\n extends TableControlAddRowTriggerPropsBase, ComponentProps<\"button\"> {\n children: ReactNode;\n}\n\n/** Trigger used to add a new row to a table control. */\nexport function TableControlAddRowTrigger({\n disableWhileAdding,\n onRowAdded,\n preferRightAlignment = true,\n showWhenReadOnly,\n showWhilePrinting,\n disabled,\n onClick,\n className,\n children,\n ...otherProps\n}: TableControlAddRowTriggerProps) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n\n const { printHidden } = usePrintClassNames();\n const { controller, size, maxRows } = useTableControlContext();\n const controlIsDisabled = useFormIsDisabled();\n const controlIsReadOnly = useFormIsReadOnly();\n const setLatestInteraction = useSetLatestInteraction();\n\n const gettingRowValue = controller.useState(\n (state: any) => state.gettingRowValue,\n );\n const [adding, setAdding] = useState(false);\n\n const handleClick = async () => {\n setLatestInteraction(controller.getState().path);\n setAdding(true);\n try {\n await controller.addRow();\n onRowAdded?.();\n } finally {\n setAdding(false);\n }\n };\n\n const shouldDisable = controller.useState(\n ({ initialized, exists }) =>\n !initialized ||\n !exists ||\n controlIsDisabled ||\n disabled ||\n controlIsReadOnly ||\n (gettingRowValue && children !== undefined) ||\n (adding && disableWhileAdding && children !== undefined) ||\n (maxRows != null && size! >= maxRows),\n );\n\n if (!showWhenReadOnly && controlIsReadOnly) {\n return null;\n }\n\n const commonProps = {\n className: cx(\n prefix(\"table-control__add-row-trigger\"),\n showWhilePrinting || printHidden,\n className,\n ),\n disabled: shouldDisable,\n onClick: combineEventHandlers(onClick, handleClick, {\n checkDefaultPrevented: true,\n }),\n \"data-prefer-right-alignment\": boolDataAttr(preferRightAlignment),\n };\n\n if (children === undefined) {\n const {\n defaultButtonText,\n label = defaultButtonText ?? locale.TableControlAddRowTrigger.label,\n ...buttonProps\n } = otherProps as TableControlAddRowTriggerChildlessProps;\n return (\n <Button\n icon={faPlus}\n color=\"primary\"\n loading={gettingRowValue || (adding && disableWhileAdding)}\n showSpinner={adding && !disableWhileAdding}\n {...buttonProps}\n {...commonProps}\n >\n {label}\n </Button>\n );\n }\n return (\n <Slot {...otherProps} {...commonProps}>\n {children}\n </Slot>\n );\n}\n","import type { Table, TableRowId } from \"@ostack.tech/kform\";\nimport type { Controller } from \"@ostack.tech/kform-react\";\nimport type { DataTableScrollToOptions } from \"@ostack.tech/ui\";\nimport { type RefObject, useRef } from \"react\";\n\n/** Imperative table control API. */\nexport type TableControlApi<\n T = unknown,\n TTable extends Table<T> | null = Table<T> | null,\n> = Controller<TTable> & {\n /**\n * Navigates to the row with the provided index.\n *\n * @param index Index of row to navigate to.\n * @param scrollOptions Options used to configure to scrolling to the row\n * (only relevant in scrolled display mode).\n */\n goToIndex: (index: number, scrollOptions?: DataTableScrollToOptions) => void;\n /**\n * Navigates to the row with the provided id.\n *\n * @param id Id of row to navigate to.\n * @param scrollOptions Options used to configure to scrolling to the row\n * (only relevant in scrolled display mode).\n */\n goToId: (id: TableRowId, scrollOptions?: DataTableScrollToOptions) => void;\n};\n\n/** Hook used to access the table control API. */\nexport function useTableControlApiRef<\n T = unknown,\n TTable extends Table<T> | null = Table<T> | null,\n>(): RefObject<TableControlApi<T, TTable> | null> {\n return useRef<TableControlApi<T, TTable>>(null);\n}\n","import {\n combineEventHandlers,\n DataTableContent,\n type DataTableContentProps,\n useCombinedRef,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport { useCallback, useDeferredValue } from \"react\";\n\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { DebugInfo } from \"../DebugInfo\";\nimport { useTableControlContext } from \"./TableControlContext.ts\";\n\n/** Properties of the table control content component. */\nexport interface TableControlContentProps extends Omit<\n DataTableContentProps,\n \"status\"\n> {}\n\n/** Component containing the content of the table control. */\nexport function TableControlContent({\n scrollableProps,\n ...otherProps\n}: TableControlContentProps) {\n const { autofocusRef, handleFocus, controller, debug } =\n useTableControlContext();\n const printing = usePrinting();\n const absolutePath = controller.usePath();\n const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());\n\n const handleContainerOnBlur = useCallback(() => {\n const { initialized, exists, touched } = controller.getState();\n if (initialized && exists && !touched) {\n void controller.setTouched();\n }\n }, [controller]);\n\n return (\n <>\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && debug && (\n <DebugInfo path={absolutePath} data-prefer-right-alignment=\"\" />\n )}\n\n <DataTableContent\n editable\n variant=\"control\"\n status={\n printing\n ? undefined\n : displayStatusToControlStatus(deferredDisplayStatus)\n }\n scrollableProps={{\n onFocus: combineEventHandlers(scrollableProps?.onFocus, handleFocus),\n onBlur: combineEventHandlers(\n scrollableProps?.onBlur,\n handleContainerOnBlur,\n ),\n ref: useCombinedRef(autofocusRef, scrollableProps?.ref),\n }}\n {...otherProps}\n />\n </>\n );\n}\n","import {\n TableControlColumn,\n type TableControlColumnObject,\n type TableControlColumnProps,\n} from \"./TableControlColumn.tsx\";\nimport {\n tableControlIndexColumn,\n type TableControlIndexColumnFnProps,\n} from \"./TableControlColumnFns.tsx\";\n\n/** Properties of the table control index column. */\nexport interface TableControlIndexColumnProps\n extends\n TableControlColumnProps,\n Omit<TableControlIndexColumnFnProps, keyof TableControlColumnObject> {}\n\n/**\n * Pre-configured column used to display the index of each row. By default, it\n * sticks to left of the table.\n */\nexport function TableControlIndexColumn({\n render,\n children,\n ...otherProps\n}: TableControlIndexColumnProps) {\n return (\n <TableControlColumn\n {...tableControlIndexColumn({\n ...otherProps,\n render: render ?? children,\n })}\n />\n );\n}\n","import {\n DataTablePagination,\n type DataTablePaginationProps,\n} from \"@ostack.tech/ui\";\n\n/** Properties of the table control pagination component. */\nexport type TableControlPaginationProps = DataTablePaginationProps;\n\n/** Table control pagination. */\nexport const TableControlPagination = DataTablePagination;\n","import {\n DataTableRowsPerPage,\n type DataTableRowsPerPageProps,\n} from \"@ostack.tech/ui\";\n\n/** Properties of the table control rows per page component. */\nexport type TableControlRowsPerPageProps = DataTableRowsPerPageProps;\n\n/** Table control rows per page. */\nexport const TableControlRowsPerPage = DataTableRowsPerPage;\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type FormatterControllerState,\n type InputController,\n type InputOptions,\n InvalidPathError,\n useInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n Input,\n type InputProps,\n TextArea,\n type TextAreaProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport { type ComponentRef, type ReactNode, type Ref, useState } from \"react\";\n\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\n\n/** Properties of the text control component. */\nexport type TextControlProps<T extends string | null = string | null> =\n TextControlInputProps<T> | TextControlTextAreaProps<T>;\n\n/** Base properties of the text control component. */\nexport type TextControlPropsBase<T extends string | null = string | null> =\n Omit<\n InputOptions<T, string, ComponentRef<typeof Input | typeof TextArea>>,\n \"enabled\" | \"format\" | \"parse\"\n > & {\n /** Path to the value. */\n path?: string | Path;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control\n * to be focused when the form app's `focus` is called with this control's\n * path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /** Whether to render a multiline text control. */\n multiline?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | InputController<T, string, ComponentRef<typeof Input | typeof TextArea>>\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\"\n >;\n };\n\n/** Properties of the text control component when `multiline` is **not** set. */\nexport type TextControlInputProps<T extends string | null = string | null> =\n Omit<\n InputProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > &\n TextControlPropsBase<T> & {\n multiline?: false;\n };\n\n/** Properties of the text control component when `multiline` is set. */\nexport type TextControlTextAreaProps<T extends string | null = string | null> =\n Omit<\n TextAreaProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > &\n TextControlPropsBase<T> & {\n multiline: true;\n pattern?: never;\n };\n\n/**\n * The text control component is a KForm form control for values with (possibly\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).\n * It supports both single and multiline text editing, being built on top of the\n * [`Input`](/docs/ostack-ui-forms-input--docs) (for single-line) or\n * [`TextArea`](/docs/ostack-ui-forms-text-area--docs) (for multiline)\n * components.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Length`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-length/index.html)/[`MinLength`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min-length/index.html)/[`MaxLength`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-length/index.html):\n * Sets the `minLength` and/or `maxLength` properties.\n * - [`Matches`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-matches/index.html):\n * Sets the `pattern` property.\n *\n * Example usage:\n *\n * ```tsx\n * import { TextControl } from \"@ostack.tech/ui-kform\";\n *\n * function UsernameControl() {\n * return <TextControl path=\"/username\" placeholder=\"Enter username…\" />;\n * }\n * ```\n */\nexport function TextControl<T extends string | null = string | null>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n multiline = false,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n minLength,\n maxLength,\n pattern,\n loading,\n showSpinner,\n disabled,\n readOnly,\n endAdornment,\n onChange,\n onFocus,\n onBlurToOutside,\n debug,\n ref,\n ...otherProps\n}: TextControlProps<T>) {\n const controller = useInput<\n T,\n string,\n ComponentRef<typeof Input | typeof TextArea>\n >(path, {\n enabled: !useFormIsLoading(),\n parse: parseText,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n if (schema.typeInfo.name !== \"String\") {\n throw new InvalidPathError(\n absolutePath,\n \"Unsupported schema: Expected schema representing (possibly nullable) \" +\n \"strings, but got schema representing values of type \" +\n `'${schema.typeInfo.toString()}'.`,\n );\n }\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const [wasMultiline] = useState(multiline);\n if (multiline !== wasMultiline) {\n throw new Error(\n \"The `multiline` property cannot not be changed at runtime.\",\n );\n }\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const commonProps: InputProps | TextAreaProps = {\n name: inputProps.name,\n required: required ?? restrictions.required === true,\n minLength:\n minLength ??\n (typeof restrictions.minLength === \"number\"\n ? restrictions.minLength\n : undefined),\n maxLength:\n maxLength ??\n (typeof restrictions.maxLength === \"number\"\n ? restrictions.maxLength\n : undefined),\n pattern:\n pattern ??\n (typeof restrictions.pattern === \"string\"\n ? restrictions.pattern\n : undefined),\n loading: displayLoading || loading,\n showSpinner: displayValidating || showSpinner,\n disabled: displayDisabled || disabled || inputProps.disabled,\n readOnly: displayReadOnly || readOnly || inputProps.readOnly,\n status: displayStatusToControlStatus(displayStatusToDisplay),\n endAdornment: (\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n ),\n onChange: combineEventHandlers(onChange as never, inputProps.onChange),\n onFocus: combineEventHandlers(onFocus as never, handleFocus),\n onBlurToOutside: combineEventHandlers(\n onBlurToOutside as never,\n inputProps.onBlur,\n ),\n ref: useCombinedRef(\n inputProps.ref,\n useCombinedRef(autofocusRef, ref),\n ) as never,\n ...(otherProps as any),\n };\n return (\n <FeedbackProvider>\n {multiline ? (\n <TextArea {...(commonProps as TextAreaProps)} />\n ) : (\n <Input {...(commonProps as InputProps)} />\n )}\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n\n/** Parses a text control formatted value. */\nfunction parseText<T extends string | null>(\n formattedValue: string,\n state: FormatterControllerState<T, string>,\n): T {\n return (\n state.schema.typeInfo.nullable ? formattedValue || null : formattedValue\n ) as T;\n}\n","import { faCircleCheck } from \"@fortawesome/free-regular-svg-icons\";\nimport {\n Button,\n type ButtonProps,\n combineEventHandlers,\n useKeyboardShortcut,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, useDeferredValue } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport {\n useFormIsValidating,\n useFormValidator,\n} from \"../../utils/useFormValidator.ts\";\nimport {\n useFormAppElement,\n useFormIsDisabled,\n useFormIsReadOnly,\n} from \"../FormApp\";\n\n/** Default “validate” keybinds. */\nexport const DEFAULT_VALIDATE_KEYBINDS = \"Alt+Shift+V\";\n\n/** Properties of the validate action. */\nexport interface ValidateActionProps extends Omit<ButtonProps, \"children\"> {\n /** Action's label. */\n label?: ReactNode;\n /**\n * Keybinds for triggering the action. Set to `null` to disable the keyboard\n * shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * `DEFAULT_VALIDATE_KEYBINDS`.\n */\n keybinds?: string | string[] | null;\n /**\n * Whether to show the validate action when the form is read-only.\n *\n * @default false\n */\n showWhenReadOnly?: boolean;\n}\n\n/**\n * Form action used to validate the form. Built on top of the [`Button`\n * component](/docs/ostack-ui-forms-button--docs) and `useFormValidator` hook.\n *\n * If the form contains an `IssuesPanel` component, it is shown as a result of\n * triggering the action.\n *\n * Example usage:\n *\n * ```tsx\n * import { ValidateAction } from \"@ostack.tech/ui-kform\";\n *\n * function ValidateForm() {\n * return <ValidateAction />;\n * }\n * ```\n */\nexport function ValidateAction({\n label,\n keybinds,\n showWhenReadOnly,\n loading,\n disabled,\n onClick,\n ...otherProps\n}: ValidateActionProps) {\n const [locale] = useLocale();\n label ??= locale.ValidateAction.label;\n if (keybinds === undefined) {\n keybinds = locale.ValidateAction.keybinds ?? DEFAULT_VALIDATE_KEYBINDS;\n }\n\n const { validate } = useFormValidator();\n const { validatingAutomatically, validatingManually } = useFormIsValidating();\n const deferredValidatingAutomatically = useDeferredValue(\n validatingAutomatically,\n );\n const formIsDisabled = useFormIsDisabled();\n const formIsReadOnly = useFormIsReadOnly();\n const formIsLoading = useFormIsLoading();\n\n const showAction = !formIsReadOnly || showWhenReadOnly;\n const showDisabled = disabled || formIsDisabled || formIsLoading;\n const showLoading = loading || validatingManually;\n\n // Set-up keyboard shortcut\n const formAppEl = useFormAppElement();\n useKeyboardShortcut(keybinds, validate, {\n disabled: !showAction || showDisabled || showLoading,\n target: formAppEl,\n preventDefault: true,\n });\n\n return (\n showAction && (\n <Button\n color=\"primary\"\n icon={faCircleCheck}\n vertical\n {...otherProps}\n onClick={combineEventHandlers(validate, onClick as never)}\n disabled={showDisabled}\n loading={showLoading}\n showSpinner={deferredValidatingAutomatically}\n keybinds={keybinds}\n >\n {label}\n </Button>\n )\n );\n}\n","import type {\n AbsolutePath,\n FormManager,\n Path,\n SealedValueEvent,\n} from \"@ostack.tech/kform\";\nimport { useCurrentPath, useFormManager } from \"@ostack.tech/kform-react\";\nimport {\n type AlertDialogContentColor,\n type ConfirmDialogOptions,\n useAlertDialog,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, useRef } from \"react\";\n\n// eslint-disable-next-line react-refresh/only-export-components\nconst ALWAYS_RESET = () => true;\n\n/** Options of the reset confirmation dialog. */\nexport interface ResetConfirmDialogOption extends ConfirmDialogOptions {\n /** Message of the confirmation dialog. */\n message: ReactNode;\n /**\n * Confirmation dialog content color.\n *\n * @default \"warning\"\n */\n color?: AlertDialogContentColor;\n}\n\n/** Options of the `useResetOnChange` hook. */\nexport interface UseResetOnChangeOptions<T = unknown> {\n /**\n * Function which determines whether to reset the fields when the value\n * changes. By default, fields are reset whenever the value changes.\n *\n * @param event Value event.\n */\n when?: (event: SealedValueEvent<T>) => boolean;\n /**\n * Fields in `toReset` that should be excluded from being reset (relative to\n * the current path). This is useful when using wildcards in `toReset` and you\n * want to exclude some of the fields that match the wildcard.\n *\n * E.g. `{ toReset: [\"/a/*\"], excludeFromReset: [\"/a/b\"] }` will reset all\n * children of `/a` except `/a/b`.\n */\n exclude?: string | Path | (string | Path)[];\n /**\n * Confirmation dialog options. When provided, a confirmation dialog will be\n * presented to the user before resetting the fields.\n *\n * If this option is **not** provided, the fields will be reset without\n * confirmation.\n */\n confirmation?: ResetConfirmDialogOption;\n /**\n * Whether to set the fields as untouched when resetting.\n *\n * @default true\n */\n setUntouched?: boolean;\n /**\n * Whether to set the fields as pristine when resetting.\n *\n * @default true\n */\n setPristine?: boolean;\n}\n\n/** Event handler returned by the `useResetOnChange` hook. */\nexport type UseResetOnChangeResult = (event: SealedValueEvent<any>) => void;\n\n/**\n * Hook which returns an `onValueChange` event handler which resets the fields\n * at the provided `toReset` paths to their initial value when the value changes\n * (according to the `when` function).\n *\n * Optionally requests user-confirmation via dialog if `confirmation` is\n * provided.\n *\n * When using wildcards in `toReset`, certain fields may be excluded via\n * `exclude`.\n *\n * Example usage:\n *\n * ```tsx\n * function NoTransactionsControl() {\n * const handleOnChange = useResetOnChange(\"/transactions/*\", {\n * when: ({ value }) => value,\n * confirmation: {\n * title: \"Confirm no transactions\",\n * message: (\n * <>\n * By checking this box, all fields in section “Transactions” will\n * be cleared. Are you sure you want to continue?\n * </>\n * ),\n * okText: \"Confirm\",\n * },\n * });\n *\n * return (\n * <CheckboxControl\n * path=\"noTransactions\"\n * onValueChange={handleOnChange}\n * />\n * );\n * }\n * ```\n *\n * @param toReset Paths to reset up when the value changes (relative to the\n * current path). Wildcards in paths (`*` or `**`) are supported.\n * @param options Hook options. See {@link UseResetOnChangeOptions}.\n */\nexport function useResetOnChange<T = unknown>(\n toReset: string | Path | (string | Path)[],\n {\n when = ALWAYS_RESET,\n exclude,\n confirmation,\n setUntouched = true,\n setPristine = true,\n }: UseResetOnChangeOptions<T> = {},\n): UseResetOnChangeResult {\n const { confirm } = useAlertDialog();\n const formManager = useFormManager();\n const currentPath = useCurrentPath();\n const resettingValue = useRef(false);\n\n // The event listener mustn't be blocked by the operations performed, so we\n // separate the handler into two functions\n const handleValueChange = async (event: SealedValueEvent<T>) => {\n if (!resettingValue.current && when(event)) {\n let resolvedToReset = (Array.isArray(toReset) ? toReset : [toReset]).map(\n (path) => currentPath.resolve(path),\n );\n\n if (exclude) {\n const resolvedExclude = (\n Array.isArray(exclude) ? exclude : [exclude]\n ).map((path) => currentPath.resolve(path));\n resolvedToReset = excludePaths(\n formManager,\n resolvedToReset,\n resolvedExclude,\n );\n }\n\n if (confirmation) {\n const { message, ...confirmOptions } = confirmation;\n if (\n (await someIsDirty(formManager, resolvedToReset)) &&\n !(await confirm(message, { color: \"warning\", ...confirmOptions }))\n ) {\n resettingValue.current = true;\n formManager\n .set(event.path, event.oldValue)\n .finally(() => (resettingValue.current = false));\n return;\n }\n }\n\n await resetAll(formManager, resolvedToReset, setUntouched, setPristine);\n }\n };\n return (event: SealedValueEvent<T>) => void handleValueChange(event);\n}\n\n/**\n * Returns an \"expanded\" (without wildcards) list of all paths in `path` that\n * **do not** match those in `toExclude`.\n */\nfunction excludePaths(\n formManager: FormManager,\n paths: (string | Path)[],\n exclude: (string | Path)[],\n): AbsolutePath[] {\n return paths\n .flatMap((path) =>\n Array.from(formManager.schemaInfo(path)).map((info) => info.path),\n )\n .filter((path) => !exclude.some((toIgnore) => path.matches(toIgnore)));\n}\n\n/**\n * Returns a promise that resolves with whether at least one of the provided\n * paths is dirty.\n */\nasync function someIsDirty(\n formManager: FormManager,\n paths: (string | Path)[],\n): Promise<boolean> {\n const dirtyStatuses = await Promise.all(\n paths.map((path) => formManager.isDirty(path)),\n );\n return dirtyStatuses.some((isDirty) => isDirty);\n}\n\n/**\n * Resets all the provided paths by calling `reset`, `setPristine` and\n * `setUntouched` on them.\n */\nasync function resetAll(\n formManager: FormManager,\n toReset: (string | Path)[],\n setPristine: boolean,\n setUntouched: boolean,\n): Promise<void> {\n await Promise.all(\n // eslint-disable-next-line @typescript-eslint/await-thenable\n toReset.flatMap((path) => [\n formManager.reset(path),\n setPristine && formManager.setPristine(path),\n setUntouched && formManager.setUntouched(path),\n ]),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,IAAM,wBAAwB;;AAG9B,IAAa,2BAA2B,mBAAmB,EACzD,qBAAqB,sBACvB,EAAE;;;;;;;;AASF,SAAgB,uBAAuB,qBAA6B;CAClE,yBAAyB,SAAS,EAAE,oBAAoB,CAAC;AAC3D;;;;AChBA,IAAa,sBAAsB,cAA6B,IAAI;;;;ACSpE,SAAgB,qBAAqB,EACnC,cACA,YAC4B;CAC5B,OAAO,iBAAiB,KAAA,IACtB,WAEA,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;EAClC;CAC2B,CAAA;AAElC;;;;;;;ACZA,SAAgB,YAAsB;CACpC,MAAM,SAAS,YAAY;CAC3B,MAAM,sBAAsB,SAC1B,2BACC,EAAE,0BAA0B,mBAC/B;CACA,MAAM,eAAe,WAAW,mBAAmB,KAAK;CACxD,OAAO,aACJ,WAAW,OAAO,OAAO,GAAG,eAAe,UAAU,GACtD,CAAC,QAAQ,YAAY,CACvB;AACF;;;;ACZA,IAAa,oBAAoB,cAC/B,IACF;;AAGA,SAAgB,uBAA+C;CAC7D,MAAM,oBAAoB,WAAW,iBAAiB;CACtD,IAAI,CAAC,mBACH,MAAM,IAAI,MAAM,kCAAkC;CAEpD,OAAO;AACT;;;;ACoBA,SAAgB,mBAAmB,EACjC,mBACA,YAAY,sBACZ,oBACA,YAC0B;CAC1B,MAAM,CAAC,YAAY,iBAAiB,qBAClC,mBACA,oBACF;CACA,MAAM,qBAAqB,gBAAgB,UAAU;CAErD,MAAM,YAAY,aAAa;EAAE;EAAoB;CA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UAA+B,KAAK,kBAAkB,KAAK;AACrE;;;;;AAMA,SAAS,aACP,aACA,OACA,SACgB;CAChB,OAAO,MACJ,SAAS,SACR,MAAM,KAAK,YAAY,WAAW,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,KAAK,IAAI,CAClE,CAAC,CACA,QAAQ,SAAS,CAAC,QAAQ,MAAM,aAAa,KAAK,QAAQ,QAAQ,CAAC,CAAC;AACzE;;;;;AAMA,eAAe,YACb,aACA,OACkB;CAIlB,QAAO,MAHqB,QAAQ,IAClC,MAAM,KAAK,SAAS,YAAY,QAAQ,IAAI,CAAC,CAC/C,EAAA,CACqB,MAAM,YAAY,OAAO;AAChD;;;;;AAMA,eAAe,SACb,aACA,SACA,aACA,cACe;CACf,MAAM,QAAQ,IAEZ,QAAQ,SAAS,SAAS;EACxB,YAAY,MAAM,IAAI;EACtB,eAAe,YAAY,YAAY,IAAI;EAC3C,gBAAgB,YAAY,aAAa,IAAI;CAC/C,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"ostack-ui-kform.js","names":[],"sources":["../src/providers/PrefixSuffixProvider/defaultPrefixSuffix.ts","../src/providers/PrefixSuffixProvider/PrefixSuffixContext.ts","../src/providers/PrefixSuffixProvider/PrefixSuffixProvider.tsx","../src/providers/PrefixSuffixProvider/usePrefix.ts","../src/providers/ActivePathProvider/ActivePathContext.ts","../src/providers/ActivePathProvider/ActivePathProvider.tsx","../src/providers/LocalizationProvider/LocalizationContext.ts","../src/providers/LocalizationProvider/LocalizationProvider.tsx","../src/providers/LocalizationProvider/useLocale.ts","../src/utils/pathSpecificity.ts","../src/utils/useEqualityFn.ts","../src/components/FormApp/FormAppContext.ts","../src/components/IssueMessage/IssueMessage.tsx","../src/utils/useControlAutofocus.ts","../src/components/FormApp/FormAppAutoFocus.tsx","../src/components/FormApp/FormAppElement.tsx","../src/components/FormApp/FormAppIssueMessages.tsx","../src/components/FormApp/FormApp.tsx","../src/components/FormApp/FormAppStatus.tsx","../src/utils/mostSpecificPath.ts","../src/components/Annexes/AnnexesContext.ts","../src/components/Annexes/Annex.tsx","../src/utils/useFormLoader.tsx","../src/components/Annexes/AnnexRegistrar.tsx","../src/components/Annexes/RepetitiveAnnexRegistrar.tsx","../src/components/Annexes/Annexes.tsx","../src/utils/useReportValidationFailures.ts","../src/components/ControlField/ControlFieldContext.ts","../src/components/ControlField/ControlField.tsx","../src/components/IssueMessages/IssueMessages.tsx","../src/components/IssuesPopover/IssuesPopover.tsx","../src/utils/displayStatusConversions.ts","../src/utils/promiseUtils.ts","../src/components/TopBar/TopBarContext.tsx","../src/components/TopBar/TopBar.tsx","../src/components/TopBar/TopBarActions.tsx","../src/components/TopBar/TopBarActionsSecondary.tsx","../src/components/Annexes/AnnexesMenu.tsx","../src/components/Annexes/AnnexTab.tsx","../src/components/Annexes/AnnexesTabList.tsx","../src/components/Annexes/AnnexesManager.tsx","../src/utils/useControlIssues.tsx","../src/utils/useRegisterControl.tsx","../src/components/DebugInfo/DebugInfo.tsx","../src/components/DebugInfo/DebugInfoControlAddonTrigger.tsx","../src/components/ResetOnChange/ResetOnChangeContext.ts","../src/utils/extractConfirmDialogOptions.ts","../src/components/ResetOnChange/useResetOnChange.tsx","../src/components/ResetOnChange/ResetOnChange.tsx","../src/components/CheckboxControl/CheckboxControl.tsx","../src/utils/selectionTransformations.tsx","../src/components/UnknownValue/UnknownValue.tsx","../src/components/CheckboxGroupControl/CheckboxGroupControlItem.tsx","../src/components/CheckboxGroupControl/CheckboxGroupControl.tsx","../src/utils/dateRestrictions.ts","../src/utils/useTemporalStringTransformer.ts","../src/components/DateControl/DateControl.tsx","../src/components/DateRangeControl/DateRangeControl.tsx","../src/components/FileControl/FileControlDownloadAddon.tsx","../src/components/FileControl/FileControlViewAddon.tsx","../src/components/FileControl/FileControl.tsx","../src/components/FormPages/FormPagesContext.ts","../src/components/FormPages/FormPageHeader.tsx","../src/components/FormPages/FormPage.tsx","../src/components/FormPages/FormPageRegistrar.tsx","../src/components/FormPages/FormPages.tsx","../src/components/FormPages/FormPagesSelectOption.tsx","../src/components/FormPages/FormPagesSelect.tsx","../src/components/FormPages/FormPageSidebarItem.tsx","../src/components/FormPages/FormPagesSidebar.tsx","../src/components/FormPages/FormPagesNavigation.tsx","../src/components/FormStepper/FormStepperContext.ts","../src/components/FormStepper/FormStep.tsx","../src/components/FormStepper/FormStepButton.tsx","../src/components/FormStepper/FormStepList.tsx","../src/components/FormStepper/FormStepRegistrar.tsx","../src/components/FormStepper/FormStepper.tsx","../src/components/FormStepper/FormStepperFinishTrigger.tsx","../src/components/FormStepper/FormStepperNextTrigger.tsx","../src/components/FormStepper/FormStepperPreviousTrigger.tsx","../src/components/IssuesAlert/IssuesAlert.tsx","../src/utils/useFormValidator.ts","../src/components/IssuesPanel/IssuesPanelControls.tsx","../src/components/IssuesPanel/IssuesPanelMessagesCard.tsx","../src/components/IssuesPanel/IssuesPanelSummaryCard.tsx","../src/components/IssuesPanel/IssuesPanel.tsx","../src/components/LoadAction/LoadAction.tsx","../src/components/NumericControl/NumericControl.tsx","../src/components/PathLink/PathLink.tsx","../src/components/PrintAction/PrintAction.tsx","../src/components/RadioGroupControl/RadioGroupControlItem.tsx","../src/components/RadioGroupControl/RadioGroupControl.tsx","../src/utils/useFormSaver.tsx","../src/components/SaveAction/SaveAction.tsx","../src/components/SelectControl/SelectControlItem.tsx","../src/components/SelectControl/SelectControlItemGroup.tsx","../src/components/SelectControl/SelectControl.tsx","../src/components/SelectMultipleControl/SelectMultipleControlItem.tsx","../src/components/SelectMultipleControl/SelectMultipleControlItemGroup.tsx","../src/components/SelectMultipleControl/SelectMultipleControl.tsx","../src/components/SubmitAction/SubmitAction.tsx","../src/components/TableControl/TableControlContext.ts","../src/components/TableControl/TableControlCell.tsx","../src/components/TableControl/TableControlColumn.tsx","../src/components/TableControl/TableControlColumnGroup.tsx","../src/components/TableControl/TableControlColumns.tsx","../src/components/TableControl/TableControlRow.tsx","../src/components/TableControl/TableControl.tsx","../src/components/TableControl/TableControlActionsColumnLabel.tsx","../src/components/TableControl/TableControlIndexColumnLabel.tsx","../src/components/TableControl/TableControlRemoveRowTrigger.tsx","../src/components/TableControl/TableControlColumnFns.tsx","../src/components/TableControl/TableControlActionsColumn.tsx","../src/components/TableControl/TableControlAddRowTrigger.tsx","../src/components/TableControl/TableControlApi.ts","../src/components/TableControl/TableControlContent.tsx","../src/components/TableControl/TableControlIndexColumn.tsx","../src/components/TableControl/TableControlPagination.tsx","../src/components/TableControl/TableControlRowsPerPage.tsx","../src/components/TextControl/TextControl.tsx","../src/components/ValidateAction/ValidateAction.tsx"],"sourcesContent":["import { createStore } from \"zustand\";\n\n/** Initial default library prefix-suffix. */\nconst DEFAULT_PREFIX_SUFFIX = \"kform-\";\n\n/** Store holding the default prefix-suffix. */\nexport const defaultPrefixSuffixStore = createStore(() => ({\n defaultPrefixSuffix: DEFAULT_PREFIX_SUFFIX,\n}));\n\n/**\n * Function used to set the default library's prefix-suffix. The default library\n * prefix-suffix can be overridden by providing a `prefixSuffix` property to the\n * `PrefixSuffixProvider` or `FormApp` components.\n *\n * @param defaultPrefixSuffix Prefix-suffix to set as the library's default.\n */\nexport function setDefaultPrefixSuffix(defaultPrefixSuffix: string) {\n defaultPrefixSuffixStore.setState({ defaultPrefixSuffix });\n}\n","import { createContext } from \"react\";\n\n/** Prefix-suffix context. */\nexport const PrefixSuffixContext = createContext<string | null>(null);\n","import type { ReactNode } from \"react\";\n\nimport { PrefixSuffixContext } from \"./PrefixSuffixContext.ts\";\n\n/** Properties of the prefix-suffix provider. */\nexport interface PrefixSuffixProviderProps {\n /** Suffix to add to ostack/UI's prefix. */\n prefixSuffix?: string;\n children: ReactNode;\n}\n\n/** Prefix-suffix provider. */\nexport function PrefixSuffixProvider({\n prefixSuffix,\n children,\n}: PrefixSuffixProviderProps) {\n return prefixSuffix === undefined ? (\n children\n ) : (\n <PrefixSuffixContext.Provider value={prefixSuffix}>\n {children}\n </PrefixSuffixContext.Provider>\n );\n}\n","import { type PrefixFn, usePrefix as useUiPrefix } from \"@ostack.tech/ui\";\nimport { useCallback, useContext } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { defaultPrefixSuffixStore } from \"./defaultPrefixSuffix.ts\";\nimport { PrefixSuffixContext } from \"./PrefixSuffixContext.ts\";\n\n/**\n * Hook which returns a function which can be used to prefix a string with the\n * current prefix.\n */\nexport function usePrefix(): PrefixFn {\n const prefix = useUiPrefix();\n const defaultPrefixSuffix = useStore(\n defaultPrefixSuffixStore,\n ({ defaultPrefixSuffix }) => defaultPrefixSuffix,\n );\n const prefixSuffix = useContext(PrefixSuffixContext) ?? defaultPrefixSuffix;\n return useCallback(\n (toPrefix = \"\") => prefix(`${prefixSuffix}${toPrefix}`),\n [prefix, prefixSuffix],\n );\n}\n","import type { AbsolutePath } from \"@ostack.tech/kform\";\nimport { createContext, useContext } from \"react\";\n\n/** Value of the active path context. */\nexport interface ActivePathContextValue {\n activePath: AbsolutePath;\n onActivePathChange: (activePath: AbsolutePath | string | null) => void;\n}\n\n/** Active path context. */\nexport const ActivePathContext = createContext<ActivePathContextValue | null>(\n null,\n);\n\n/** Hook providing access to the active path context. */\nexport function useActivePathContext(): ActivePathContextValue {\n const activePathContext = useContext(ActivePathContext);\n if (!activePathContext) {\n throw new Error(\"Active path context not in scope\");\n }\n return activePathContext;\n}\n","import {\n AbsolutePath,\n AbsolutePathFragment,\n type Path,\n} from \"@ostack.tech/kform\";\nimport { useResolvedPath } from \"@ostack.tech/kform-react\";\nimport { useControllableState, useLatestRef } from \"@ostack.tech/ui\";\nimport { type ReactNode, useCallback, useMemo } from \"react\";\n\nimport { ActivePathContext } from \"./ActivePathContext.ts\";\n\n/**\n * Navigation options to use when controlling the active path via the browser's\n * URL.\n */\nexport interface OnActivePathChangeNavigationOptions {\n /** Whether to replace the current history entry. */\n replace: boolean;\n}\n\n/** Properties of the active path provider. */\nexport interface ActivePathProviderProps {\n /** Uncontrolled default active path to use. */\n defaultActivePath?: string | Path;\n /** Controlled active path to use. */\n activePath?: string | Path;\n /**\n * Callback called whenever the active path is changed.\n *\n * @param activePath New active path.\n * @param options Navigation options to use when controlling the active path\n * via the browser's URL.\n */\n onActivePathChange?: (\n activePath: AbsolutePath,\n options: OnActivePathChangeNavigationOptions,\n ) => void;\n children?: ReactNode;\n}\n\n/** Provider which controls the active path in a section of a form. */\nexport function ActivePathProvider({\n defaultActivePath,\n activePath: controlledActivePath,\n onActivePathChange,\n children,\n}: ActivePathProviderProps) {\n const [activePath, setActivePath] = useControllableState(\n defaultActivePath,\n controlledActivePath,\n );\n const resolvedActivePath = useResolvedPath(activePath);\n\n const latestRef = useLatestRef({ resolvedActivePath, onActivePathChange });\n const handleActivePathChange = useCallback(\n (newActivePath: AbsolutePath | string | null) => {\n const activePath = latestRef.current.resolvedActivePath;\n if (typeof newActivePath === \"string\") {\n newActivePath = new AbsolutePath(newActivePath);\n } else {\n newActivePath ??= AbsolutePath.ROOT;\n }\n\n // Ignore when new path is equal to or an ancestor of the old one\n if (\n !activePath.equals(newActivePath) &&\n !newActivePath\n .append(AbsolutePathFragment.RecursiveWildcard)\n .contains(activePath)\n ) {\n // Replace when the old path is an ancestor of the new one\n const replace = activePath\n .append(AbsolutePathFragment.RecursiveWildcard)\n .contains(newActivePath);\n setActivePath(newActivePath);\n latestRef.current.onActivePathChange?.(newActivePath, { replace });\n }\n },\n [latestRef, setActivePath],\n );\n\n return (\n <ActivePathContext.Provider\n value={useMemo(\n () => ({\n activePath: resolvedActivePath,\n onActivePathChange: handleActivePathChange,\n }),\n [handleActivePathChange, resolvedActivePath],\n )}\n >\n {children}\n </ActivePathContext.Provider>\n );\n}\n","import { createContext } from \"react\";\n\nimport type { LocalizationObject } from \"./LocalizationObject.ts\";\n\n/** Value of the localisation context. */\nexport interface LocalizationContextValue {\n locale: LocalizationObject;\n setLocale: (locale: LocalizationObject) => void;\n}\n\n/** Localisation context. */\nexport const LocalizationContext =\n createContext<LocalizationContextValue | null>(null);\n","import {\n combineEventHandlers,\n LocalizationProvider as UiLocalizationProvider,\n useControllableState,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { LocalizationContext } from \"./LocalizationContext.ts\";\nimport type { LocalizationObject } from \"./LocalizationObject.ts\";\n\n/** Properties of the localisation provider. */\nexport interface LocalizationProviderProps {\n /** Uncontrolled locale to use. */\n defaultLocale?: LocalizationObject;\n /** Controlled locale to use. */\n locale?: LocalizationObject;\n /**\n * Function called when the locale changes.\n *\n * @param locale New locale.\n */\n onLocaleChange?: (locale: LocalizationObject) => void;\n children: ReactNode;\n}\n\n/**\n * Localisation provider (also sets the `@ostack.tech/ui` localisation\n * provider).\n */\nexport function LocalizationProvider({\n defaultLocale,\n locale: controlledLocale,\n onLocaleChange,\n children,\n}: LocalizationProviderProps) {\n const [locale, setLocale] = useControllableState(\n defaultLocale,\n controlledLocale,\n );\n\n return locale === undefined ? (\n children\n ) : (\n <LocalizationContext.Provider\n value={{\n locale,\n setLocale: combineEventHandlers(setLocale, onLocaleChange),\n }}\n >\n <UiLocalizationProvider locale={locale.baseLocale}>\n {children}\n </UiLocalizationProvider>\n </LocalizationContext.Provider>\n );\n}\n","import { useContext, useMemo } from \"react\";\n\nimport { LocalizationContext } from \"./LocalizationContext.ts\";\nimport type { LocalizationObject } from \"./LocalizationObject.ts\";\n\n/** Hook used to get and set the current locale. */\nexport function useLocale(): [\n LocalizationObject,\n (locale: LocalizationObject) => void,\n] {\n const localizationContext = useContext(LocalizationContext);\n if (localizationContext === null)\n throw new Error(\n \"No locale has been provided. Please provide a locale via the \" +\n \"`FormApp` or `LocalizationProvider` components.\",\n );\n return useMemo(\n () => [localizationContext.locale, localizationContext.setLocale],\n [localizationContext.locale, localizationContext.setLocale],\n );\n}\n","import { type AbsolutePath, AbsolutePathFragment } from \"@ostack.tech/kform\";\n\ntype PathSpecificity = [number, number, number];\n\n/**\n * Given two paths, returns a number > 0 if the first path is more specific than\n * the second, a number < 0 if the first path is less specific than the second,\n * or 0 if both paths have the same specificity.\n *\n * Specificity is not incredibly well specified (and may change over time if a\n * need arises), but the idea is that wildcards make paths less specific, so\n * `/a/∗` is less specific than `/a/b`, and `/∗∗` is the least specific path.\n *\n * Both `/a` and `/a/b/c` have the same specificity since both paths uniquely\n * identify a resource.\n *\n * @param path1 First path to compare.\n * @param path2 Second path to compare.\n * @returns Number representing which path is more specific.\n */\nexport function comparePathsBySpecificity(\n path1: AbsolutePath,\n path2: AbsolutePath,\n) {\n const [ids1, wildcards1, recursiveWildcards1] = pathSpecificity(path1);\n const [ids2, wildcards2, recursiveWildcards2] = pathSpecificity(path2);\n // When neither path has recursive wildcards, the most specific one is the one\n // with the least non-recursive wildcards\n if (recursiveWildcards1 === 0 && recursiveWildcards2 === 0) {\n return wildcards2 - wildcards1;\n }\n // When one path has recursive wildcards but the other one doesn't, the most\n // specific one is the one without recursive wildcards\n if (recursiveWildcards1 === 0 || recursiveWildcards2 === 0) {\n return recursiveWildcards2 - recursiveWildcards1;\n }\n // When both paths have recursive wildcards, the most specific one is the one\n // with the most identifiers; if the number of identifiers is the same, then\n // the one with the most non-recursive wildcards\n return ids1 - ids2 || wildcards1 - wildcards2;\n}\n\nfunction pathSpecificity(path: AbsolutePath): PathSpecificity {\n const specificity: PathSpecificity = [0, 0, 0];\n for (const fragment of path.fragments) {\n if (fragment instanceof AbsolutePathFragment.Id) {\n ++specificity[0];\n } else if (fragment === AbsolutePathFragment.Wildcard) {\n ++specificity[1];\n } else if (fragment === AbsolutePathFragment.RecursiveWildcard) {\n ++specificity[2];\n }\n }\n return specificity;\n}\n","import { useRef } from \"react\";\n\nconst INITIAL = Symbol();\n\n// TODO: This is repeated both here and in `@ostack.tech/kform-react`, it might\n// make sense to either export and use the `@ostack.tech/kform-react` version\n// or upstream it instead\nexport function useEqualityFn<TState, TResult>(\n selector: (state: TState) => TResult,\n equalityFn: (v1: TResult, v2: TResult) => boolean = Object.is,\n): (state: TState) => TResult {\n const latest = useRef<TResult | typeof INITIAL>(INITIAL);\n return (state) => {\n const next = selector(state);\n return latest.current !== INITIAL && equalityFn(latest.current, next)\n ? latest.current\n : (latest.current = next);\n };\n}\n","import {\n AbsolutePath,\n AbsolutePathFragment,\n type Path,\n PathMultimap,\n type PathMultimapEntryId,\n type SealedLocatedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport { type Controller, equals } from \"@ostack.tech/kform-react\";\nimport { useConstant, useLatestRef, usePrinting } from \"@ostack.tech/ui\";\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n} from \"react\";\nimport { createStore, useStore } from \"zustand\";\nimport { subscribeWithSelector } from \"zustand/middleware\";\nimport { useShallow } from \"zustand/react/shallow\";\nimport { shallow } from \"zustand/shallow\";\n\nimport { comparePathsBySpecificity } from \"../../utils/pathSpecificity.ts\";\nimport { useEqualityFn } from \"../../utils/useEqualityFn.ts\";\nimport type { IssueMessagesByCode, IssueMessageValue } from \"../IssueMessages\";\nimport type { IssuesDisplayMode } from \"./FormApp.tsx\";\n\n/** Value of the form app context. */\nexport interface FormAppContextValue<T = unknown> {\n formTitle?: string;\n disabled: boolean;\n readOnly: boolean;\n issuesDisplayMode: IssuesDisplayMode;\n displayIssueCodes: boolean;\n issueMessagesDataKey: string;\n formAppElement: HTMLFormElement | null;\n store: FormAppStore<T>;\n debug: boolean;\n}\n\n/** State of the form app. */\nexport interface FormAppState<T> {\n controller: Controller<T>;\n focusedPath: AbsolutePath | null;\n focusCounter: number;\n issuesPanelPath: AbsolutePath | null;\n topBarHeight: number;\n leftSidebarWidth: number;\n bottomPanelHeight: number;\n startIssuesNavigation?: () => void;\n latestInteraction: AbsolutePath;\n // State below is wrapped in an array in order to trigger state updates by\n // simply changing the identity of the wrapper without creating new multimap\n // instances\n registeredControllers: [PathMultimap<Controller>];\n registeredIssueMessages: [\n PathMultimap<{ messages: IssueMessagesByCode; priority: number }>,\n ];\n deferredIssueMessageRemovalEntryIds: PathMultimapEntryId[];\n registeredLabels: [PathMultimap<{ label: ReactNode; priority: number }>];\n deferredLabelRemovalEntryIds: PathMultimapEntryId[];\n actions: FormAppActions;\n}\n\n/** Item of a breadcrumb. */\nexport interface BreadcrumbItem {\n path: AbsolutePath;\n label: ReactNode;\n}\n\n/** Actions of the form app. */\nexport interface FormAppActions {\n setIssuesPanelPath: (path: AbsolutePath | null) => void;\n focus: (path: string | Path) => void;\n resetFocus: () => void;\n registerController: (\n path: AbsolutePath,\n controller?: Controller<any> | null,\n ) => (() => void) | void;\n isRegistered: (path: AbsolutePath) => boolean;\n setLatestInteraction: (path: AbsolutePath) => void;\n registerIssueMessages: (\n basePath: AbsolutePath,\n issueMessages?: Record<string, IssueMessagesByCode>,\n priority?: number,\n ) => (() => void) | void;\n getRegisteredIssueMessage: (\n path: AbsolutePath,\n code: string,\n ) => IssueMessageValue;\n registerLabel: (\n path: AbsolutePath,\n label: ReactNode,\n priority?: number,\n ) => (() => void) | void;\n getRegisteredLabel: (path: AbsolutePath) => ReactNode;\n getActiveIssuesPanelBreadcrumb: () => BreadcrumbItem[] | null;\n startIssuesNavigation: (options?: {\n validate?: boolean;\n setTouched?: boolean;\n }) => PromiseLike<void>;\n}\n\n/** Form app store. */\nexport type FormAppStore<T> = ReturnType<\n typeof useCreateFormAppContext<T>\n>[\"store\"];\n\n/** Form app context. */\nexport const FormAppContext = createContext<FormAppContextValue | null>(null);\n\n/** Options used to create the data table context value. */\nexport interface UseCreateFormAppContextOptions<T> extends Omit<\n FormAppContextValue<T>,\n \"store\"\n> {\n controller: Controller<T>;\n onPathFocus?: (path: AbsolutePath) => void;\n}\n\n/** Hook which creates the form app context. */\nexport function useCreateFormAppContext<T>({\n formTitle,\n controller,\n disabled,\n readOnly,\n issuesDisplayMode,\n displayIssueCodes,\n issueMessagesDataKey,\n formAppElement,\n onPathFocus,\n debug,\n}: UseCreateFormAppContextOptions<T>) {\n const latestRef = useLatestRef({ printing: usePrinting(), onPathFocus });\n const store = useConstant(() =>\n createStore<FormAppState<T>>()(\n subscribeWithSelector((set, get) => ({\n controller,\n focusedPath: null,\n focusCounter: 0,\n issuesPanelPath: null,\n topBarHeight: 0,\n leftSidebarWidth: 0,\n bottomPanelHeight: 0,\n startIssuesNavigation: undefined,\n latestInteraction: AbsolutePath.ROOT,\n registeredControllers: [new PathMultimap()],\n registeredIssueMessages: [new PathMultimap()],\n deferredIssueMessageRemovalEntryIds: [],\n registeredLabels: [new PathMultimap()],\n deferredLabelRemovalEntryIds: [],\n actions: {\n setIssuesPanelPath: (path: AbsolutePath | null) => {\n if (latestRef.current.printing) {\n return;\n }\n\n // Remove entries whose removal was deferred\n const {\n deferredIssueMessageRemovalEntryIds,\n deferredLabelRemovalEntryIds,\n } = get();\n if (deferredIssueMessageRemovalEntryIds.length > 0) {\n const [registeredIssueMessages] = get().registeredIssueMessages;\n for (const entryId of deferredIssueMessageRemovalEntryIds) {\n registeredIssueMessages.removeEntry(entryId);\n }\n set({ registeredIssueMessages: [registeredIssueMessages] });\n }\n if (deferredLabelRemovalEntryIds.length > 0) {\n const [registeredLabels] = get().registeredLabels;\n for (const entryId of deferredLabelRemovalEntryIds) {\n registeredLabels.removeEntry(entryId);\n }\n set({ registeredLabels: [registeredLabels] });\n }\n\n set({ issuesPanelPath: path });\n },\n getActiveIssuesPanelBreadcrumb: () => {\n const { issuesPanelPath, actions } = get();\n if (issuesPanelPath === null) {\n return null;\n }\n const breadcrumbParts: BreadcrumbItem[] = [];\n for (let i = 0; i <= issuesPanelPath.size; ++i) {\n const path =\n i === 0\n ? AbsolutePath.ROOT\n : i === issuesPanelPath.size\n ? issuesPanelPath\n : new AbsolutePath(issuesPanelPath.fragments.slice(0, i));\n const breadcrumb = actions.getRegisteredLabel(path);\n // if (!breadcrumb && DEV) {\n // warnOnce(`No label registered for path '${path.toString()}'.`);\n // }\n breadcrumbParts.push({\n path,\n label:\n breadcrumb ??\n (\n issuesPanelPath.fragment(\n i - 1,\n ) as AbsolutePathFragment.Id | null\n )?.id,\n });\n }\n return breadcrumbParts;\n },\n focus: (path: string | Path) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const { focusedPath } = get();\n const absolutePath =\n path instanceof AbsolutePath ? path : new AbsolutePath(path);\n // Refuse non-existent paths\n if (\n !get().controller.getState().formManager.isValidPath(absolutePath)\n ) {\n throw new Error(`Invalid path: '${absolutePath.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n absolutePath.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Path to focus must only contain ids.\");\n }\n\n const focusPathChanged = !equals(focusedPath, absolutePath);\n set(({ focusedPath, focusCounter }) => ({\n focusedPath: focusPathChanged ? absolutePath : focusedPath,\n focusCounter: focusCounter + 1,\n }));\n if (focusPathChanged) {\n latestRef.current.onPathFocus?.(absolutePath);\n }\n },\n resetFocus: () => {\n if (!latestRef.current.printing) {\n set({ focusedPath: null });\n }\n },\n registerController: (\n path: AbsolutePath,\n controller?: Controller | null,\n ) => {\n if (controller == null) {\n return;\n }\n\n const [registeredControllers] = get().registeredControllers;\n const addedEntry = registeredControllers.put(path, controller);\n set(() => ({ registeredControllers: [registeredControllers] }));\n\n return () => {\n registeredControllers.removeEntry(addedEntry);\n set(() => ({ registeredControllers: [registeredControllers] }));\n };\n },\n isRegistered: (path: AbsolutePath) =>\n get().registeredControllers[0].containsPath(path),\n setLatestInteraction: (path: AbsolutePath) => {\n if (!latestRef.current.printing) {\n set({ latestInteraction: path });\n }\n },\n registerIssueMessages: (\n basePath: AbsolutePath,\n issueMessages?: Record<string, IssueMessagesByCode>,\n priority = 0,\n ) => {\n if (issueMessages == null) {\n return;\n }\n\n const [registeredIssueMessages] = get().registeredIssueMessages;\n const addedEntryIds: PathMultimapEntryId[] = [];\n for (const [path, issueMessagesByCode] of Object.entries(\n issueMessages,\n )) {\n addedEntryIds.push(\n registeredIssueMessages.put(basePath.resolve(path), {\n messages: issueMessagesByCode,\n priority,\n }),\n );\n }\n set(() => ({\n registeredIssueMessages: [registeredIssueMessages],\n }));\n\n return () => {\n const { issuesPanelPath } = get();\n for (const entryId of addedEntryIds) {\n // If the message being unregistered is currently in use by the\n // issues panel, defer its removal\n if (\n issuesPanelPath &&\n registeredIssueMessages\n .getEntry(entryId)!\n .path.append(AbsolutePathFragment.RecursiveWildcard)\n .contains(issuesPanelPath)\n ) {\n get().deferredIssueMessageRemovalEntryIds.push(entryId);\n } else {\n registeredIssueMessages.removeEntry(entryId);\n }\n }\n set(() => ({\n registeredIssueMessages: [registeredIssueMessages],\n }));\n };\n },\n getRegisteredIssueMessage: (path: AbsolutePath, code: string) => {\n const [registeredIssueMessages] = get().registeredIssueMessages;\n\n // Find the match with the most specific path\n let bestMatch = null;\n for (const entry of registeredIssueMessages.entries(path)) {\n if (entry.value.messages[code] == null) {\n continue;\n }\n\n const diff =\n bestMatch &&\n comparePathsBySpecificity(bestMatch.path, entry.path);\n if (\n bestMatch == null ||\n diff! < 0 ||\n // Larger priority wins\n (diff === 0 &&\n entry.value.priority > bestMatch.value.priority) ||\n // Last inserted wins\n (diff === 0 &&\n entry.value.priority === bestMatch.value.priority &&\n entry.id > bestMatch.id)\n ) {\n bestMatch = entry;\n }\n }\n return bestMatch?.value.messages[code] ?? null;\n },\n registerLabel: (\n path: AbsolutePath,\n label: ReactNode,\n priority = 0,\n ) => {\n if (!label) {\n return;\n }\n\n const [registeredLabels] = get().registeredLabels;\n const addedEntry = registeredLabels.put(path, { label, priority });\n set(() => ({ registeredLabels: [registeredLabels] }));\n\n return () => {\n const { issuesPanelPath } = get();\n // If the label being unregistered is currently in use by the\n // issues panel, defer its removal\n if (\n issuesPanelPath &&\n registeredLabels\n .getEntry(addedEntry)!\n .path.append(AbsolutePathFragment.RecursiveWildcard)\n .contains(issuesPanelPath)\n ) {\n get().deferredLabelRemovalEntryIds.push(addedEntry);\n } else {\n registeredLabels.removeEntry(addedEntry);\n }\n set(() => ({ registeredLabels: [registeredLabels] }));\n };\n },\n getRegisteredLabel: (path: AbsolutePath) => {\n const [registeredLabels] = get().registeredLabels;\n\n // Find the match with the most specific path\n let bestMatch = null;\n for (const entry of registeredLabels.entries(path)) {\n const diff =\n bestMatch &&\n comparePathsBySpecificity(bestMatch.path, entry.path);\n if (\n bestMatch == null ||\n diff! < 0 ||\n // Larger priority wins\n (diff === 0 &&\n entry.value.priority > bestMatch.value.priority) ||\n // Last inserted wins\n (diff === 0 &&\n entry.value.priority === bestMatch.value.priority &&\n entry.id > bestMatch.id)\n ) {\n bestMatch = entry;\n }\n }\n return bestMatch?.value.label ?? null;\n },\n startIssuesNavigation: async ({\n validate = true,\n setTouched = validate,\n } = {}) => {\n const formManager = get().controller.getState().formManager;\n if (setTouched) {\n await formManager.setTouched();\n }\n let issues: SealedLocatedValidationIssue[] | undefined;\n if (validate && formManager.autoValidationStatus === \"inactive\") {\n issues = await formManager.validate();\n }\n if (get().startIssuesNavigation) {\n get().startIssuesNavigation!();\n } else {\n const firstIssue = issues\n ? issues[0]\n : (await formManager.validate())[0];\n if (firstIssue) {\n get().actions.focus(firstIssue.path);\n }\n }\n },\n },\n })),\n ),\n );\n\n // Update store when params change\n useEffect(() => {\n store.setState({ controller });\n }, [controller, store]);\n\n return useMemo(\n () => ({\n formTitle,\n disabled,\n readOnly,\n issuesDisplayMode,\n displayIssueCodes,\n issueMessagesDataKey,\n formAppElement,\n debug,\n store,\n }),\n [\n debug,\n disabled,\n displayIssueCodes,\n formAppElement,\n formTitle,\n issueMessagesDataKey,\n issuesDisplayMode,\n readOnly,\n store,\n ],\n );\n}\n\n/** Returns the context of the form app. */\nexport function useFormAppContext<T = unknown>(): FormAppContextValue<T> {\n const formAppContext = useContext(FormAppContext);\n if (!formAppContext) {\n throw new Error(\"Form app context not in scope.\");\n }\n return formAppContext as FormAppContextValue<T>;\n}\n\n/** Returns the title of the form, if provided to the `FormApp` component. */\nexport function useFormTitle(): string | undefined {\n return useFormAppContext().formTitle;\n}\n\n/** Returns a boolean representing whether the form is disabled. */\nexport function useFormIsDisabled(): boolean {\n return useFormAppContext().disabled;\n}\n\n/** Returns a boolean representing whether the form is read-only. */\nexport function useFormIsReadOnly(): boolean {\n return useFormAppContext().readOnly;\n}\n\n/** Returns the form app's display mode for issue messages. */\nexport function useIssuesDisplayMode(): IssuesDisplayMode {\n return useFormAppContext().issuesDisplayMode;\n}\n\n/**\n * Returns whether issue codes should be displayed (by default) within issue\n * messages.\n */\nexport function useDisplayIssueCodesInIssueMessages(): boolean {\n return useFormAppContext().displayIssueCodes;\n}\n\n/** Hook providing access to the form app's HTML form element. */\nexport function useFormAppElement(): HTMLFormElement {\n return useFormAppContext().formAppElement!;\n}\n\n/** Returns whether the form is in debug mode. */\nexport function useFormInDebugMode(): boolean {\n return useFormAppContext().debug;\n}\n\n/**\n * Hook exposing a function that can be used to specify the height of the form\n * app's top bar.\n */\nexport function useSetTopBarHeight(): (height?: number) => void {\n const { store } = useFormAppContext();\n const printing = usePrinting();\n return useCallback(\n (height?: number) =>\n !printing && store.setState({ topBarHeight: height ?? 0 }),\n [printing, store],\n );\n}\n\n/**\n * Hook exposing a function that can be used to specify the width of the form\n * app's left panel.\n */\nexport function useSetLeftSidebarWidth(): (width?: number) => void {\n const { store } = useFormAppContext();\n const printing = usePrinting();\n return useCallback(\n (width?: number) =>\n !printing && store.setState({ leftSidebarWidth: width ?? 0 }),\n [printing, store],\n );\n}\n\n/**\n * Hook exposing a function that can be used to specify the height of the form\n * app's bottom panel.\n */\nexport function useSetBottomPanelHeight(): (height?: number) => void {\n const { store } = useFormAppContext();\n const printing = usePrinting();\n return useCallback(\n (height?: number) =>\n !printing && store.setState({ bottomPanelHeight: height ?? 0 }),\n [printing, store],\n );\n}\n\n/**\n * Returns the current issues panel path of the form app and a function that can\n * be used to set it, ala `useState`.\n */\nexport function useIssuesPanelPath(): [\n AbsolutePath | null,\n FormAppActions[\"setIssuesPanelPath\"],\n] {\n return useStore(\n useFormAppContext().store,\n useShallow((state) => [\n state.issuesPanelPath,\n state.actions.setIssuesPanelPath,\n ]),\n );\n}\n\n/** Hook exposing a function that can be used to focus a path within a form app. */\nexport function useFocus(): FormAppActions[\"focus\"] {\n return useStore(useFormAppContext().store, (state) => state.actions.focus);\n}\n\n/** Hook exposing a function that can be used to reset the focus. */\nexport function useResetFocus(): FormAppActions[\"resetFocus\"] {\n return useStore(\n useFormAppContext().store,\n (state) => state.actions.resetFocus,\n );\n}\n\n/**\n * Hook used to register a controller within the form app. This makes the form\n * app aware that a controller of a certain path is currently being rendered.\n */\nexport function useRegisterController(controller: Controller<any>) {\n const store = useFormAppContext().store;\n const path = controller.usePath();\n const printing = usePrinting();\n useEffect(() => {\n if (!printing) {\n return store.getState().actions.registerController(path, controller);\n }\n }, [store, controller, path, printing]);\n}\n\n/** Hook to check whether there is a registered controller for the provided path. */\nexport function useIsRegistered(path?: AbsolutePath | null): boolean {\n return useStore(\n useFormAppContext().store,\n (state) => path != null && state.actions.isRegistered(path),\n );\n}\n\n/** Hook exposing the latest path that the user has interacted with. */\nexport function useLatestInteraction(): AbsolutePath {\n return useStore(\n useFormAppContext().store,\n (state) => state.latestInteraction,\n );\n}\n\n/** Hook exposing a function to set the latest path the user has interacted with. */\nexport function useSetLatestInteraction(): FormAppActions[\"setLatestInteraction\"] {\n return useStore(\n useFormAppContext().store,\n (state) => state.actions.setLatestInteraction,\n );\n}\n\n/** Hook used to register issue messages within the form app. */\nexport function useRegisterIssueMessages(\n path: AbsolutePath | null | undefined,\n issueMessages?: Record<string, IssueMessagesByCode>,\n priority?: number,\n) {\n const store = useFormAppContext().store;\n const printing = usePrinting();\n useEffect(() => {\n if (!printing && path != null) {\n return store\n .getState()\n .actions.registerIssueMessages(path, issueMessages, priority);\n }\n }, [path, issueMessages, priority, store, printing]);\n}\n\n/** Hook used to get the issue message value for the provided path and code. */\nexport function useRegisteredIssueMessage(\n path: AbsolutePath | null | undefined,\n code: string,\n): IssueMessageValue {\n return useStore(useFormAppContext().store, (state) =>\n path == null ? null : state.actions.getRegisteredIssueMessage(path, code),\n );\n}\n\n/** Hook used to register a label within the form app. */\nexport function useRegisterLabel(\n path: AbsolutePath | null | undefined,\n label: ReactNode,\n priority = 0,\n) {\n const store = useFormAppContext().store;\n const printing = usePrinting();\n useEffect(() => {\n if (!printing && path != null) {\n return store.getState().actions.registerLabel(path, label, priority);\n }\n }, [store, path, label, priority, printing]);\n}\n\n/**\n * Hook used to get the label parts associated with the active issues panel\n * path.\n */\nexport function useActiveIssuesPanelBreadcrumb(): BreadcrumbItem[] | null {\n return useStore(\n useFormAppContext().store,\n useEqualityFn(\n (state) => state.actions.getActiveIssuesPanelBreadcrumb(),\n equalBreadcrumbItems,\n ),\n );\n}\nfunction equalBreadcrumbItems(\n breadcrumbs1: BreadcrumbItem[] | null,\n breadcrumbs2: BreadcrumbItem[] | null,\n) {\n if (breadcrumbs1 == null || breadcrumbs2 == null) {\n return breadcrumbs1 === breadcrumbs2;\n }\n return (\n breadcrumbs1.length === breadcrumbs2.length &&\n breadcrumbs1.every((breadcrumb1, i) => {\n const breadcrumb2 = breadcrumbs2[i];\n return (\n breadcrumb1.path.toString() === breadcrumb2.path.toString() &&\n Object.is(breadcrumb1.label, breadcrumb2.label)\n );\n })\n );\n}\n\n/**\n * Hook exposing a function that can be used to start navigating through the\n * form app's issues.\n */\nexport function useStartIssuesNavigation(): FormAppActions[\"startIssuesNavigation\"] {\n return useStore(\n useFormAppContext().store,\n (state) => state.actions.startIssuesNavigation,\n );\n}\n\n/** Options available to the {@link useOnPathFocus} hook. */\nexport interface UseOnFocusedPathChangeOptions {\n /**\n * Whether to enable the hook.\n *\n * @default true\n */\n enabled?: boolean;\n /**\n * Whether to run the callback immediately with the current focused path.\n *\n * @default true\n */\n fireImmediately?: boolean;\n}\n\n/**\n * Hook used to run a given function whenever the form app's focused path\n * changes.\n *\n * @param cb Function to run when the focused path changes. This function should\n * hopefully not change on every render (i.e. it should be memoised via\n * `useCallback` or be defined externally).\n * @param options Hook options.\n */\nexport function useOnPathFocus(\n cb: (focusedPath: AbsolutePath) => void,\n {\n enabled = true,\n fireImmediately = true,\n }: UseOnFocusedPathChangeOptions = {},\n) {\n const { store } = useFormAppContext();\n const printing = usePrinting();\n useEffect(() => {\n if (enabled && !printing) {\n return store.subscribe(\n ({ focusedPath, focusCounter }) => ({ focusedPath, focusCounter }),\n ({ focusedPath }) => focusedPath && cb(focusedPath),\n { fireImmediately, equalityFn: shallow },\n );\n }\n }, [cb, enabled, fireImmediately, printing, store]);\n}\n\n/** Hook used to set the function which starts issue navigation. */\nexport function useSetStartIssuesNavigation(fn: () => void) {\n const { store } = useFormAppContext();\n const printing = usePrinting();\n useEffect(() => {\n if (!printing) {\n store.setState({ startIssuesNavigation: fn });\n return () => store.setState({ startIssuesNavigation: undefined });\n }\n }, [fn, printing, store]);\n}\n","import type {\n AbsolutePath,\n Schema,\n SealedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport { CurrentPath } from \"@ostack.tech/kform-react\";\nimport { VisuallyHidden } from \"@ostack.tech/ui\";\nimport type { ComponentProps } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport {\n useDisplayIssueCodesInIssueMessages,\n useRegisteredIssueMessage,\n} from \"../FormApp\";\nimport { useFormAppContext } from \"../FormApp/FormAppContext.ts\";\nimport type { IssueMessagesProps, IssueMessageValue } from \"../IssueMessages\";\n\n/** Default data key where to check for an issue message. */\nexport const DEFAULT_ISSUE_MESSAGE_DATA_KEY = \"message\";\n\n/** Properties of the issue message component. */\nexport interface IssueMessageProps extends Pick<\n IssueMessagesProps,\n | \"visuallyHiddenErrorCodePrefix\"\n | \"visuallyHiddenWarningCodePrefix\"\n | \"unknownErrorMessage\"\n | \"unknownWarningMessage\"\n> {\n displayIssueCode?: boolean;\n messageDataKey?: string;\n path: AbsolutePath;\n issue: SealedValidationIssue;\n schema: Schema;\n issueCodeProps?: ComponentProps<\"span\">;\n}\n\n/** Single issue message within the issue messages or issues panel components. */\nexport function IssueMessage({\n path,\n issue,\n schema,\n displayIssueCode,\n messageDataKey,\n visuallyHiddenErrorCodePrefix,\n visuallyHiddenWarningCodePrefix,\n unknownErrorMessage,\n unknownWarningMessage,\n issueCodeProps,\n}: IssueMessageProps) {\n const { issueMessagesDataKey } = useFormAppContext();\n messageDataKey ??= issueMessagesDataKey;\n\n const [locale] = useLocale();\n visuallyHiddenErrorCodePrefix ??=\n locale.IssueMessages.visuallyHiddenErrorCodePrefix;\n visuallyHiddenWarningCodePrefix ??=\n locale.IssueMessages.visuallyHiddenWarningCodePrefix;\n unknownErrorMessage ??= locale.IssueMessages.unknownErrorMessage;\n unknownWarningMessage ??= locale.IssueMessages.unknownWarningMessage;\n\n let message: IssueMessageValue =\n useRegisteredIssueMessage(path, issue.code) ?? issue.data[messageDataKey];\n const unknownMessage = message == null;\n if (unknownMessage) {\n message =\n issue.severity === \"error\" ? unknownErrorMessage : unknownWarningMessage;\n // if (DEV) {\n // warnOnce(\n // `At '${path.toString()}': no message found for ` +\n // `issue with code: '${issue.code}'.`,\n // );\n // }\n }\n\n const globalDisplayIssueCodes = useDisplayIssueCodesInIssueMessages();\n displayIssueCode ??= globalDisplayIssueCodes;\n\n return (\n <CurrentPath path={path}>\n {typeof message === \"function\"\n ? message(issue.data ?? {}, schema, path)\n : message}\n {(displayIssueCode || unknownMessage) && (\n <span {...issueCodeProps}>\n {\" \"}\n (\n {issue.severity === \"error\" && visuallyHiddenErrorCodePrefix && (\n <VisuallyHidden>{visuallyHiddenErrorCodePrefix} </VisuallyHidden>\n )}\n {issue.severity === \"warning\" && visuallyHiddenWarningCodePrefix && (\n <VisuallyHidden>{visuallyHiddenWarningCodePrefix} </VisuallyHidden>\n )}\n {issue.code})\n </span>\n )}\n </CurrentPath>\n );\n}\n","import type { Controller } from \"@ostack.tech/kform-react\";\nimport { NATIVE_CONTROLS, useCssVars, useSpacing } from \"@ostack.tech/ui\";\nimport { type RefObject, useCallback, useRef } from \"react\";\n\nimport { useOnPathFocus } from \"../components/FormApp\";\nimport { useResetFocus } from \"../components/FormApp/FormAppContext.ts\";\nimport { usePrefix } from \"../providers/PrefixSuffixProvider\";\n\nconst FOCUSABLE_ELEMENTS = [\"INPUT\", \"SELECT\", \"TEXTAREA\"];\n\n/**\n * Function used to scroll an element into view.\n *\n * @param el Element to scroll into view.\n * @param options Scroll into view options.\n */\nexport type ScrollIntoViewFn = (\n el: HTMLElement,\n options?: ScrollIntoViewOptions,\n) => void;\n\n/**\n * Hook used to autofocus a control when the active path changes, given the\n * control's path.\n *\n * @param controller Control's controller.\n * @param enabled Whether to enable the auto-focus behaviour.\n * @returns Reference that should be set on the focusable element of the\n * control.\n */\nexport function useControlAutofocus<\n T = unknown,\n TElem extends HTMLElement = HTMLElement,\n>(\n { usePath, useExists }: Controller<T>,\n enabled = true,\n): RefObject<TElem | null> {\n const controlRef = useRef<TElem | null>(null);\n const path = usePath();\n const exists = useExists();\n const resetFocus = useResetFocus();\n const scrollIntoView = useScrollIntoView();\n\n const timeoutId = useRef<number>(undefined);\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n const control = controlRef.current;\n if (enabled && control && exists && path.equals(focusedPath)) {\n clearTimeout(timeoutId.current);\n timeoutId.current = window.setTimeout(() => {\n scrollIntoView(control);\n visiblyFocus(control);\n resetFocus();\n }, 50);\n }\n },\n [enabled, exists, path, resetFocus, scrollIntoView],\n ),\n );\n\n return controlRef;\n}\n\n/**\n * Visibly focuses the provided element.\n *\n * @param el Element to visibly focus.\n * @param options Focus options.\n */\nexport function visiblyFocus(el: HTMLElement, options?: FocusOptions) {\n const focusOptions: FocusOptions = {\n preventScroll: true,\n // This option is experimental, but works well in Firefox, so might as well\n // use it\n focusVisible: true,\n ...options,\n };\n\n if (FOCUSABLE_ELEMENTS.includes(el.tagName)) {\n el.focus(focusOptions);\n } else {\n // XXX: Trick browser into triggering `:focus-visible`\n const contentEditable = el.contentEditable;\n el.contentEditable = \"true\";\n el.focus(focusOptions);\n el.contentEditable = contentEditable;\n }\n}\n\n/**\n * Returns a function used the scroll an element into view, taking into account\n * the form app's sticky elements, so that elements don't end up hidden behind\n * them.\n */\nexport function useScrollIntoView(): ScrollIntoViewFn {\n const prefix = usePrefix();\n const spacing = useSpacing();\n const { cssVar } = useCssVars({ prefix });\n\n return useCallback(\n (el: HTMLElement, options?: ScrollIntoViewOptions) => {\n const scrollableParent = getScrollableParent(el);\n const scrollMarginBlockStart = el.style.scrollMarginBlockStart;\n const scrollMarginBlockEnd = el.style.scrollMarginBlockEnd;\n el.style.scrollMarginBlockStart = `calc(${cssVar(\"top-bar-height\")} + ${cssVar(\n \"form-pages-page-header-height\",\n )} + ${spacing(4)})`;\n el.style.scrollMarginBlockEnd = `calc(${cssVar(\"bottom-panel-height\")} + ${spacing(4)})`;\n const shouldCenter =\n !NATIVE_CONTROLS.has(el.tagName) ||\n scrollableParent !==\n (document.scrollingElement ?? document.documentElement);\n el.scrollIntoView({\n block: shouldCenter ? \"center\" : \"nearest\",\n inline: shouldCenter ? \"center\" : \"nearest\",\n behavior: \"smooth\",\n ...options,\n });\n el.style.scrollMarginBlockStart = scrollMarginBlockStart;\n el.style.scrollMarginBlockEnd = scrollMarginBlockEnd;\n },\n [cssVar, spacing],\n );\n}\n\n/**\n * Gets the nearest scrollable parent.\n *\n * @param el Element for which to get the nearest scrollable parent.\n */\nfunction getScrollableParent(el: Element): Element {\n let current = el.parentNode;\n while (current instanceof Element) {\n const overflow = getComputedStyle(current, null).getPropertyValue(\n \"overflow\",\n );\n if (overflow.includes(\"scroll\") || overflow.includes(\"auto\")) {\n return current;\n }\n current = current.parentNode;\n }\n return document.scrollingElement ?? document.documentElement;\n}\n","import { useFormController } from \"@ostack.tech/kform-react\";\nimport { useCallback } from \"react\";\n\nimport {\n useScrollIntoView,\n visiblyFocus,\n} from \"../../utils/useControlAutofocus.ts\";\nimport {\n useFormAppElement,\n useIssuesDisplayMode,\n useOnPathFocus,\n useResetFocus,\n} from \"./FormAppContext.ts\";\n\n/** Component enabling support for auto-focusing the form app via `focus(\"/\")`. */\nexport function FormAppAutoFocus() {\n const initialized = useFormController().useInitialized();\n const formAppEl = useFormAppElement();\n const scrollIntoView = useScrollIntoView();\n\n const issuesDisplayMode = useIssuesDisplayMode();\n const resetFocus = useResetFocus();\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n if (initialized && focusedPath.isRoot) {\n // In inline mode an issues popover should get focused instead\n if (issuesDisplayMode === \"panel\") {\n scrollIntoView(formAppEl);\n visiblyFocus(formAppEl);\n }\n resetFocus();\n }\n },\n [initialized, issuesDisplayMode, resetFocus, scrollIntoView, formAppEl],\n ),\n );\n return null;\n}\n","import {\n cx,\n useCombinedRef,\n useCssVars,\n useResponsiveValues,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type Dispatch,\n type SetStateAction,\n useEffect,\n} from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport type { FormAppProps } from \"./FormApp.tsx\";\nimport { useFormAppContext, useFormTitle } from \"./FormAppContext.ts\";\n\n/** Properties of the form application element component. */\nexport interface FormAppElementProps\n extends\n Omit<ComponentProps<\"form\">, \"onSubmit\" | \"onReset\">,\n Pick<FormAppProps, \"minHeight\"> {\n formAppElement: HTMLFormElement | null;\n setFormAppElement: Dispatch<SetStateAction<HTMLFormElement | null>>;\n}\n\n/** Form application element. */\nexport function FormAppElement({\n formAppElement,\n setFormAppElement,\n minHeight,\n className,\n style,\n children,\n ref,\n ...otherProps\n}: FormAppElementProps) {\n const prefix = usePrefix();\n const { cssVarName } = useCssVars({ prefix });\n const { responsiveValueToCssVarsAndDataAttrs } = useResponsiveValues({\n prefix,\n });\n const { store } = useFormAppContext();\n const formTitle = useFormTitle();\n\n // Top-bar height\n useEffect(\n () =>\n store.subscribe(\n ({ topBarHeight }) => topBarHeight,\n (height) =>\n formAppElement?.style.setProperty(\n cssVarName(\"top-bar-height\"),\n `${height}px`,\n ),\n { fireImmediately: true },\n ),\n [cssVarName, formAppElement, store],\n );\n\n // Left sidebar width\n useEffect(\n () =>\n store.subscribe(\n ({ leftSidebarWidth }) => leftSidebarWidth,\n (width) =>\n formAppElement?.style.setProperty(\n cssVarName(\"left-sidebar-width\"),\n `${width}px`,\n ),\n { fireImmediately: true },\n ),\n [cssVarName, formAppElement, store],\n );\n\n // Bottom panel height\n useEffect(\n () =>\n store.subscribe(\n ({ bottomPanelHeight }) => bottomPanelHeight,\n (height) =>\n formAppElement?.style.setProperty(\n cssVarName(\"bottom-panel-height\"),\n `${height}px`,\n ),\n { fireImmediately: true },\n ),\n [cssVarName, formAppElement, store],\n );\n\n // Form app min height\n const { cssVars, dataAttrs } = responsiveValueToCssVarsAndDataAttrs(\n \"form-app\",\n \"min-height\",\n minHeight,\n (v) => (typeof v === \"number\" ? `${v}px` : v),\n );\n\n const combinedFormAppRef = useCombinedRef(setFormAppElement, ref);\n return (\n <form\n className={cx(prefix(\"form-app\"), className)}\n style={{ ...cssVars, ...style }}\n aria-label={formTitle}\n tabIndex={-1}\n {...dataAttrs}\n {...otherProps}\n ref={combinedFormAppRef}\n >\n {children}\n </form>\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport { useResolvedPath } from \"@ostack.tech/kform-react\";\nimport type { ReactNode } from \"react\";\n\nimport type { IssueMessagesByCode } from \"../IssueMessages\";\nimport { useRegisterIssueMessages } from \"./FormAppContext.ts\";\n\n/** Properties of the form app issue messages component. */\nexport interface FormAppIssueMessagesProps {\n /** Base path for the paths used in `messages`. */\n path?: string | Path;\n /**\n * Mapping of issue messages from the path of the field with issues to the\n * issue messages of said field (which are themselves grouped by their code).\n *\n * Provided paths may contain wildcards, which will have a lower priority when\n * matched against.\n *\n * These messages are used by the `IssueMessages` and `IssuesPanel`\n * components.\n *\n * Example value:\n *\n * ```tsx\n * {\n * \"/**\": {\n * \"valueMissing\": \"Field is required.\"\n * },\n * \"/my/field\": {\n * \"valueMissing\": \"My field cannot be left empty!\",\n * \"someOtherError\": \"Text of the other error.\"\n * }\n * }\n * ```\n */\n issueMessages?: Record<string, IssueMessagesByCode>;\n /**\n * Priority to use when registering issue messages.\n *\n * When multiple issue messages are associated with the same path, then the\n * one registered with the highest priority \"wins\".\n *\n * @default 0\n */\n priority?: number;\n children: ReactNode;\n}\n\n/** Component used to register new issue messages within the form app. */\nexport function FormAppIssueMessages({\n path,\n issueMessages,\n priority,\n children,\n}: FormAppIssueMessagesProps) {\n const absolutePath = useResolvedPath(path);\n useRegisterIssueMessages(absolutePath, issueMessages, priority);\n return children;\n}\n","import {\n AbsolutePath,\n type Path,\n type Schema,\n type SchemaKt,\n} from \"@ostack.tech/kform\";\nimport {\n type Controller,\n FormContext,\n type FormOptions,\n useForm,\n} from \"@ostack.tech/kform-react\";\nimport {\n PrefixProvider,\n type Responsive,\n Root,\n type RootProps,\n useIsInRoot,\n usePrintInProgress,\n warnOnce,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type ReactNode,\n type Ref,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from \"react\";\nimport { useStore } from \"zustand\";\n\nimport {\n ActivePathProvider,\n type OnActivePathChangeNavigationOptions,\n} from \"../../providers/ActivePathProvider\";\nimport type { LocalizationObject } from \"../../providers/LocalizationProvider\";\nimport {\n LocalizationContext,\n LocalizationProvider,\n} from \"../../providers/LocalizationProvider\";\nimport { PrefixSuffixProvider } from \"../../providers/PrefixSuffixProvider\";\nimport { DEFAULT_ISSUE_MESSAGE_DATA_KEY } from \"../IssueMessage\";\nimport type { IssueMessagesByCode } from \"../IssueMessages\";\nimport { FormAppAutoFocus } from \"./FormAppAutoFocus.tsx\";\nimport { FormAppContext, useCreateFormAppContext } from \"./FormAppContext.ts\";\nimport { FormAppElement } from \"./FormAppElement.tsx\";\nimport { FormAppIssueMessages } from \"./FormAppIssueMessages.tsx\";\n\n/** Mode of displaying issue messages. */\nexport type IssuesDisplayMode = \"inline\" | \"panel\";\n\n/** Properties of the form app component. */\nexport interface FormAppProps<T = any>\n extends\n Pick<\n RootProps,\n | \"enableErrorReporting\"\n | \"reportError\"\n | \"errorReportingUrl\"\n | \"errorReportingMethod\"\n | \"encodeErrorReport\"\n | \"encodedErrorReportMimeType\"\n | \"errorReportingOptions\"\n | \"baseDocumentTitle\"\n | \"documentTitleBaseSeparator\"\n | \"documentTitleBreadcrumbsSeparator\"\n | \"portalsContainer\"\n | \"tooltipsDelayDuration\"\n | \"tooltipsSkipDelayDuration\"\n | \"disableTooltipsHoverableContent\"\n | \"toastsLabel\"\n | \"toastsDuration\"\n | \"toastsSwipeDirection\"\n | \"toastsSwipeThreshold\"\n | \"toastViewportPosition\"\n | \"toastViewportHotkey\"\n | \"toastViewportLabel\"\n | \"toastViewportProps\"\n | \"errorBoundaryProps\"\n >,\n FormOptions<T>,\n Omit<ComponentProps<\"form\">, \"onSubmit\" | \"onReset\"> {\n /** Schema of the form. */\n schema: Schema<T> | SchemaKt;\n /** Title of the form. */\n formTitle?: string;\n /**\n * Label to use in the issues panel when displaying issues associated with the\n * form app. Defaults to the `formTitle`.\n */\n issuesPanelLabel?: ReactNode;\n /** Whether to disable the whole form. */\n disabled?: boolean;\n /** Whether to set the whole form as read-only. */\n readOnly?: boolean;\n /**\n * Custom suffix to add to the ostack/UI's prefix when prefixing all component\n * classes, styles, etc.\n *\n * This prefix-suffix should match the `$prefix-suffix` SCSS variable.\n */\n prefixSuffix?: string;\n /** Uncontrolled form app locale. */\n defaultLocale?: LocalizationObject;\n /** Controlled form app locale. */\n locale?: LocalizationObject;\n /**\n * Function called when the locale changes.\n *\n * @param locale New locale.\n */\n onLocaleChange?: (locale: LocalizationObject) => void;\n /**\n * Mapping of issue messages from the path of the field with issues to the\n * issue messages of said field (which are themselves grouped by their code).\n *\n * Provided paths may contain wildcards, which will have a lower priority when\n * matched against.\n *\n * These messages are used by the `IssueMessages` component.\n *\n * > **Note:** Changes to `issueMessages` are handled correctly, but are not\n * > efficient. Please make sure that the identity of the provided value doesn't\n * > change at every render.\n *\n * Example value:\n *\n * ```tsx\n * {\n * \"/**\": {\n * \"valueMissing\": \"Field is required.\"\n * },\n * \"/my/field\": {\n * \"valueMissing\": \"My field cannot be left empty!\",\n * \"someOtherError\": \"Text of the other error.\"\n * }\n * }\n * ```\n */\n issueMessages?: Record<string, IssueMessagesByCode>;\n /**\n * Mode of displaying issues:\n *\n * - `inline` mode dispays issue messages near the component containing the\n * issues. In this mode the bottom issues panel only functions as an aid for\n * navigating issues.\n * - `panel` mode displays issue messages within the bottom issues panel.\n *\n * @default \"inline\"\n */\n issuesDisplayMode?: IssuesDisplayMode;\n /**\n * Global setting which specifies whether issue codes should be added to each\n * issue message.\n *\n * @default false\n */\n displayIssueCodes?: boolean;\n /**\n * Name of the key in the data object of validation issues that possibly\n * contains the issue message to display. This message is only used if no\n * matching message is otherwise found.\n *\n * @default \"message\"\n */\n issueMessagesDataKey?: string;\n /** Uncontrolled default active path to use. */\n defaultActivePath?: string | Path;\n /** Controlled active path to use. */\n activePath?: string | Path;\n /**\n * Callback called whenever the active path changes.\n *\n * @param activePath New active path.\n * @param options Navigation options to use when controlling the active path\n * via the browser's URL.\n */\n onActivePathChange?: (\n activePath: AbsolutePath,\n options: OnActivePathChangeNavigationOptions,\n ) => void;\n /**\n * Function called when a form path is focused.\n *\n * @param path Focused path.\n */\n onPathFocus?: (path: AbsolutePath) => void;\n /**\n * Minimum height of the form app. Values should **not** be percentages.\n *\n * @default \"100dvh\"\n */\n minHeight?: Responsive<number | string>;\n /**\n * Show debug information for all form controls. This property has no effect\n * in production builds.\n */\n debug?: boolean;\n /** Reference to the form app's API. */\n apiRef?: Ref<FormAppApi<T> | undefined>;\n}\n\n/** Imperative form app API. */\nexport type FormAppApi<T = any> = Controller<T> & {\n /**\n * Focuses the form element at the provided path.\n *\n * @param path Path of element to focus.\n */\n focus: (path: string | Path) => void;\n /**\n * Starts issues navigation (when an `IssuesPanel` component exists within).\n *\n * @param options Options used when starting issues navigation.\n * @returns Promise which returns with whether issues navigation was started\n * (whether an `IssuesPanel` component exists within).\n */\n startIssuesNavigation: (options: {\n validate?: boolean;\n setTouched?: boolean;\n }) => PromiseLike<void>;\n};\n\n/**\n * Root component of a form application. Built on top of the\n * ostack/KForm-React's `useForm` hook.\n *\n * The `FormApp` component automatically renders the ostack/UI's `Root`\n * component when not rendered within one, in which case all `Root` component\n * properties are supported. The ostack/UI's `locale` is automatically provided\n * to the ostack/UI `Root` component from the provided `FormApp` `locale`.\n *\n * Example usage:\n *\n * ```tsx\n * import { Button, Field, Label, Stack } from \"@ostack.tech/ui\";\n * import { FormApp, TextControl } from \"@ostack.tech/ui-kform\";\n *\n * export function SignInForm() {\n * return (\n * <FormApp schema={SignInFormSchema} onSubmit={signIn} minHeight={0}>\n * <Stack>\n * <Field>\n * <Label>Email</Label>\n * <TextControl path=\"/email\" type=\"email\" />\n * </Field>\n * <Field>\n * <Label>Password</Label>\n * <TextControl path=\"/password\" type=\"password\" />\n * </Field>\n * <Button color=\"primary\" type=\"submit\">\n * Sign in\n * </Button>\n * </Stack>\n * </FormApp>\n * );\n * }\n * ```\n */\nexport function FormApp<T = any>({\n enableErrorReporting,\n reportError,\n errorReportingUrl,\n errorReportingMethod,\n encodeErrorReport,\n encodedErrorReportMimeType,\n errorReportingOptions,\n baseDocumentTitle,\n documentTitleBaseSeparator,\n documentTitleBreadcrumbsSeparator,\n portalsContainer,\n tooltipsDelayDuration,\n tooltipsSkipDelayDuration,\n disableTooltipsHoverableContent,\n toastsLabel,\n toastsDuration,\n toastsSwipeDirection,\n toastsSwipeThreshold,\n toastViewportPosition,\n toastViewportHotkey,\n toastViewportLabel,\n toastViewportProps,\n errorBoundaryProps,\n schema,\n initialValue,\n formTitle,\n issuesPanelLabel,\n disabled = false,\n readOnly = false,\n prefix: newPrefix,\n prefixSuffix,\n defaultLocale,\n locale: controlledLocale,\n onLocaleChange,\n issueMessages,\n issuesDisplayMode = \"inline\",\n displayIssueCodes = false,\n issueMessagesDataKey = DEFAULT_ISSUE_MESSAGE_DATA_KEY,\n defaultActivePath,\n activePath,\n onActivePathChange,\n onPathFocus,\n minHeight,\n debug = false,\n apiRef,\n externalContexts,\n validationMode = readOnly ? \"manual\" : \"auto\",\n confirmUnloadWhenDirty,\n confirmUnloadMessage,\n onSubmit,\n onInvalidSubmit,\n onSuccessfulSubmit,\n onFailedSubmit,\n validateOnSubmit,\n setTouchedOnSubmit,\n setPristineOnSuccessfulSubmit,\n convertExternalIssuesTableRowIndicesToIds,\n onReset,\n onInitialized,\n onUninitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n ...otherProps\n}: FormAppProps<T>) {\n const isInRoot = useIsInRoot();\n const rootProps = {\n enableErrorReporting,\n reportError,\n errorReportingUrl,\n errorReportingMethod,\n encodeErrorReport,\n encodedErrorReportMimeType,\n errorReportingOptions,\n baseDocumentTitle,\n documentTitleBaseSeparator,\n documentTitleBreadcrumbsSeparator,\n portalsContainer,\n tooltipsDelayDuration,\n tooltipsSkipDelayDuration,\n disableTooltipsHoverableContent,\n toastsLabel,\n toastsDuration,\n toastsSwipeDirection,\n toastsSwipeThreshold,\n toastViewportPosition,\n toastViewportHotkey,\n toastViewportLabel,\n toastViewportProps,\n errorBoundaryProps,\n };\n if (isInRoot && Object.values(rootProps).some((prop) => prop !== undefined)) {\n warnOnce(\n `FormApp: Properties ${Object.keys(rootProps)\n .map((prop) => `\\`${prop}\\``)\n .join(\", \")} have no effect when the \\`FormApp\\` is already ` +\n \"inside an ostack/UI's `Root` component. Please set any of these \" +\n \"properties on the `Root` component directly instead.\",\n );\n }\n\n const contextLocale = useContext(LocalizationContext)?.locale;\n const locale = controlledLocale ?? defaultLocale ?? contextLocale;\n if (locale == null) {\n throw new Error(\n \"FormApp: No locale has been provided. Either provide a \" +\n \"`defaultLocale`/`locale` property or wrap the component in a \" +\n \"`LocalizationProvider`.\",\n );\n }\n formTitle ??= locale.FormApp.formTitle;\n issuesPanelLabel ??= locale.FormApp.issuesPanelLabel ?? formTitle;\n confirmUnloadMessage ??= locale.FormApp.confirmUnloadMessage;\n\n const controller = useForm<T>(schema, {\n initialValue,\n externalContexts,\n validationMode,\n confirmUnloadWhenDirty,\n confirmUnloadMessage,\n onSubmit,\n onInvalidSubmit: async (issues, event) => {\n await startIssuesNavigation({ validate: false });\n onInvalidSubmit?.(issues, event);\n },\n onSuccessfulSubmit,\n onFailedSubmit,\n validateOnSubmit,\n setTouchedOnSubmit,\n setPristineOnSuccessfulSubmit,\n convertExternalIssuesTableRowIndicesToIds,\n onReset,\n onInitialized,\n onUninitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n } as FormOptions<T>);\n const { formProps } = controller;\n\n // Reference to the form app element (used to scroll into view on page\n // changes, since scrolling a page itself into view hides elements under the\n // top-bar)\n const [formAppElement, setFormAppElement] = useState<HTMLFormElement | null>(\n null,\n );\n\n const formManager = controller.useFormManager();\n const formContext = useMemo(\n () => ({\n formManager,\n currentPath: AbsolutePath.ROOT,\n controller,\n }),\n [controller, formManager],\n );\n\n const printInProgress = usePrintInProgress();\n const displayDisabled =\n controller.useSubmitting() || disabled || printInProgress;\n const formAppContextValue = useCreateFormAppContext<T>({\n formTitle,\n disabled: displayDisabled,\n readOnly,\n issuesDisplayMode,\n displayIssueCodes,\n issueMessagesDataKey,\n controller,\n onPathFocus,\n formAppElement,\n debug,\n });\n const { store } = formAppContextValue;\n\n useEffect(\n () =>\n store\n .getState()\n .actions.registerController(AbsolutePath.ROOT, controller),\n [controller, store],\n );\n\n const absolutePath = controller.usePath();\n useEffect(\n () =>\n store.getState().actions.registerLabel(absolutePath, issuesPanelLabel),\n [absolutePath, issuesPanelLabel, store],\n );\n\n // Expose the control's API via `apiRef`\n const { focus, startIssuesNavigation } = useStore(\n store,\n (state) => state.actions,\n );\n useImperativeHandle(\n apiRef,\n () => ({\n ...controller,\n focus,\n startIssuesNavigation,\n }),\n [focus, controller, startIssuesNavigation],\n );\n\n const formAppEl = (\n <FormAppElement\n minHeight={minHeight}\n formAppElement={formAppElement}\n setFormAppElement={setFormAppElement}\n {...formProps}\n {...otherProps}\n />\n );\n\n return (\n <PrefixProvider prefix={newPrefix}>\n <PrefixSuffixProvider prefixSuffix={prefixSuffix}>\n <LocalizationProvider\n defaultLocale={defaultLocale}\n locale={controlledLocale}\n onLocaleChange={onLocaleChange}\n >\n <FormContext.Provider value={formContext}>\n <FormAppContext.Provider value={formAppContextValue as never}>\n <ActivePathProvider\n defaultActivePath={defaultActivePath}\n activePath={activePath}\n onActivePathChange={onActivePathChange}\n >\n <FormAppIssueMessages\n issueMessages={locale.FormApp.issueMessages}\n priority={-1}\n >\n <FormAppIssueMessages issueMessages={issueMessages}>\n <FormAppAutoFocus />\n\n {isInRoot ? (\n formAppEl\n ) : (\n <Root asChild {...rootProps}>\n {formAppEl}\n </Root>\n )}\n </FormAppIssueMessages>\n </FormAppIssueMessages>\n </ActivePathProvider>\n </FormAppContext.Provider>\n </FormContext.Provider>\n </LocalizationProvider>\n </PrefixSuffixProvider>\n </PrefixProvider>\n );\n}\n","import { type ReactNode, useMemo } from \"react\";\n\nimport { FormAppContext, useFormAppContext } from \"./FormAppContext.ts\";\n\n/** Properties of the form app status component. */\nexport interface FormAppStatusProps {\n /**\n * Whether to mark the form app as disabled for children of this component.\n *\n * This property has no effect when set to `false`.\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Whether to mark the form app as read-only for children of this component.\n *\n * This property has no effect when set to `false`.\n *\n * @default false\n */\n readOnly?: boolean;\n children: ReactNode;\n}\n\n/** Component used to apply a different form app status to part of the form. */\nexport function FormAppStatus({\n disabled = false,\n readOnly = false,\n children,\n}: FormAppStatusProps) {\n const formAppContext = useFormAppContext();\n return (\n <FormAppContext.Provider\n value={useMemo(\n () => ({\n ...formAppContext,\n disabled: formAppContext.disabled || disabled,\n readOnly: formAppContext.readOnly || readOnly,\n }),\n [disabled, formAppContext, readOnly],\n )}\n >\n {children}\n </FormAppContext.Provider>\n );\n}\n","import { AbsolutePath, AbsolutePathFragment } from \"@ostack.tech/kform\";\n\n/**\n * Function which selects the most \"specific\" path from a list of paths, given a\n * path to match. `currentActivePath` contains the path that is currently\n * active.\n *\n * The list of paths may contain paths with a single trailing wildcard.\n *\n * This function is used by the `Annexes`, `FormPages`, and `FormStepper`\n * components to select the next path that should be focused when the focused\n * path changes.\n */\nexport function mostSpecificPath(\n toMatch: AbsolutePath | null,\n paths: AbsolutePath[],\n currentActivePath: AbsolutePath | null,\n): AbsolutePath | null {\n if (!toMatch || paths.length === 0) {\n return null;\n }\n\n // Filter paths containing the focused path and pick the one with the most\n // specific (longest) path\n const mostSpecific = paths\n .filter((path) =>\n path.append(AbsolutePathFragment.RecursiveWildcard).contains(toMatch),\n )\n .reduce(\n (mostSpecific: AbsolutePath | null, path) =>\n mostSpecific === null || path.size > mostSpecific.size\n ? // Replace wildcard with the id of the path to match\n path.lastFragment === AbsolutePathFragment.Wildcard\n ? new AbsolutePath(toMatch.fragments.slice(0, path.size))\n : path\n : mostSpecific,\n null,\n );\n if (mostSpecific) {\n return mostSpecific;\n }\n\n // Return the currently active path when it is still one of the provided paths\n if (\n currentActivePath &&\n paths.some((path) => path.contains(currentActivePath))\n ) {\n return currentActivePath;\n }\n\n // Fallback to the first path\n return paths[0];\n}\n","import {\n AbsolutePath,\n AbsolutePathFragment,\n type DisplayStatus,\n type FormManager,\n type Path,\n type Schema,\n type SealedValidationIssue,\n sliceTableRows,\n type Table,\n type TableRowId,\n tableSize,\n} from \"@ostack.tech/kform\";\nimport {\n computed,\n useConstant,\n useLatestRef,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport {\n createContext,\n type ReactNode,\n startTransition,\n useCallback,\n useContext,\n useEffect,\n} from \"react\";\nimport { createStore, useStore } from \"zustand\";\nimport { subscribeWithSelector } from \"zustand/middleware\";\n\nimport { useActivePathContext } from \"../../providers/ActivePathProvider\";\nimport { mostSpecificPath } from \"../../utils/mostSpecificPath.ts\";\nimport { useOnPathFocus } from \"../FormApp\";\nimport { useSetLatestInteraction } from \"../FormApp/FormAppContext.ts\";\nimport type { AnnexObject } from \"./Annex.tsx\";\nimport type { AnnexesProps } from \"./Annexes.tsx\";\n\n/** Value of the annexes' context. */\nexport type AnnexesContextValue = AnnexesStore;\n\n/** Resolved annex object. */\nexport interface ResolvedAnnexObject extends AnnexObject {\n path: AbsolutePath;\n}\n\n/** Annex state. */\nexport interface AnnexState {\n path: AbsolutePath;\n title: ReactNode;\n subtitle?: ReactNode;\n description?: ReactNode;\n documentTitle?: string | null;\n isRepetitive: boolean;\n schema: Schema;\n isNull: boolean;\n dirty: boolean | undefined;\n deferredDisplayStatus: DisplayStatus | undefined;\n deferredIssuesToDisplay: SealedValidationIssue[];\n}\n\n/** Repetitive annex state. */\nexport type RepetitiveAnnexState = Pick<\n ResolvedAnnexObject,\n \"path\" | \"maxAnnexes\"\n> & {\n rowIds?: TableRowId[];\n schema: Schema;\n deferredIssuesToDisplay: SealedValidationIssue[];\n};\n\n/** State of the annexes. */\nexport interface AnnexesState {\n annexes: ResolvedAnnexObject[];\n activeAnnex: AbsolutePath | null;\n nextActiveAnnex: AbsolutePath | null;\n activeAnnexIndex: () => number;\n // State below is wrapped in an array in order to trigger state updates by\n // simply changing the identity of the wrapper without creating new object\n // instances\n annexStates: [Record<string, AnnexState | null>];\n repetitiveAnnexStates: [Record<string, RepetitiveAnnexState | null>];\n tabStates: () => AnnexState[];\n tablessStates: () => (AnnexState | RepetitiveAnnexState)[];\n waitingRegistration: () => AbsolutePath[];\n actions: AnnexesActions;\n}\n\n/** Actions of the annexes. */\nexport interface AnnexesActions {\n getAnnexState: (path: AbsolutePath) => AnnexState | null;\n getRepetitiveAnnexState: (path: AbsolutePath) => RepetitiveAnnexState | null;\n setAnnexes: (annexes: ResolvedAnnexObject[]) => void;\n buildAnnexStates: (\n annexes?: ResolvedAnnexObject[],\n ) => Record<string, AnnexState | null>;\n buildRepetitiveAnnexStates: (\n annexes?: ResolvedAnnexObject[],\n ) => Record<string, RepetitiveAnnexState | null>;\n setActiveAnnex: (activeAnnex: string | Path | null) => void;\n updateActiveAnnex: (oldActiveAnnexIndex: number) => void;\n registerAnnexState: (path: AbsolutePath, state: AnnexState) => void;\n registerRepetitiveAnnexState: (\n path: AbsolutePath,\n state: RepetitiveAnnexState,\n ) => void;\n addAnnex: (path: AbsolutePath, toAdd: unknown) => Promise<AbsolutePath>;\n removeAnnex: (path: AbsolutePath, isRepetitive: boolean) => Promise<void>;\n}\n\n/** Annexes' store. */\nexport type AnnexesStore = ReturnType<typeof useCreateAnnexesContext>;\n\n/** Annexes' context. */\nexport const AnnexesContext = createContext<AnnexesContextValue | null>(null);\n\n/** Options used to create the annexes' context. */\nexport interface UseCreateAnnexesContextOptions extends Pick<\n AnnexesProps,\n | \"defaultActiveAnnex\"\n | \"activeAnnex\"\n | \"onActiveAnnexChange\"\n | \"onAnnexAdd\"\n | \"onAnnexRemove\"\n> {\n formManager: FormManager;\n basePath: AbsolutePath;\n resolvedAnnexes: ResolvedAnnexObject[];\n}\n\n/** Hook used to create the annexes' context. */\nexport function useCreateAnnexesContext({\n formManager,\n basePath,\n resolvedAnnexes,\n defaultActiveAnnex,\n activeAnnex,\n onActiveAnnexChange,\n onAnnexAdd,\n onAnnexRemove,\n}: UseCreateAnnexesContextOptions) {\n const setLatestInteraction = useSetLatestInteraction();\n const { activePath, onActivePathChange } = useActivePathContext();\n activeAnnex ??= activePath;\n\n const latestRef = useLatestRef({\n printing: usePrinting(),\n formManager,\n onActivePathChange,\n onActiveAnnexChange,\n onAnnexAdd,\n onAnnexRemove,\n });\n const store = useConstant(() =>\n createStore<AnnexesState>()(\n subscribeWithSelector((set, get) => ({\n annexes: resolvedAnnexes,\n activeAnnex:\n activeAnnex === undefined\n ? defaultActiveAnnex == null\n ? null\n : basePath.resolve(defaultActiveAnnex)\n : activeAnnex === null\n ? null\n : basePath.resolve(activeAnnex),\n nextActiveAnnex: null,\n activeAnnexIndex: computed(\n () => [get().activeAnnex, get().tabStates()],\n (activeAnnex, tabStates) =>\n activeAnnex === null\n ? -1\n : tabStates.findIndex((state) => state.path.equals(activeAnnex)),\n ),\n annexStates: [{}],\n repetitiveAnnexStates: [{}],\n tabStates: computed(\n () => [get().annexes, get().annexStates, get().repetitiveAnnexStates],\n (annexes, [annexStates], [repetitiveAnnexStates]) => {\n const tabStates: AnnexState[] = [];\n const pushAnnexState = (path: AbsolutePath) => {\n const state = annexStates[path.toString()];\n if (state != null && !state.isNull) {\n tabStates.push(state);\n }\n };\n for (const annex of annexes) {\n if (annex.path.lastFragment === AbsolutePathFragment.Wildcard) {\n const parentPath = annex.path.parent();\n const state = repetitiveAnnexStates[parentPath.toString()];\n if (state?.rowIds) {\n for (const rowId of state.rowIds) {\n pushAnnexState(\n parentPath.append(new AbsolutePathFragment.Id(rowId)),\n );\n }\n }\n } else {\n pushAnnexState(annex.path);\n }\n }\n return tabStates;\n },\n ),\n tablessStates: computed(\n () => [get().annexes, get().annexStates, get().repetitiveAnnexStates],\n (annexes, [annexStates], [repetitiveAnnexStates]) => {\n const tablessStates: (AnnexState | RepetitiveAnnexState)[] = [];\n for (const annex of annexes) {\n let tablessState: AnnexState | RepetitiveAnnexState | null = null;\n if (annex.path.lastFragment === AbsolutePathFragment.Wildcard) {\n tablessState =\n repetitiveAnnexStates[annex.path.parent().toString()];\n } else {\n const state = annexStates[annex.path.toString()];\n if (state?.isNull) {\n tablessState = state;\n }\n }\n if (tablessState) {\n tablessStates.push(tablessState);\n }\n }\n return tablessStates;\n },\n ),\n waitingRegistration: computed(\n () => [get().annexes, get().annexStates, get().repetitiveAnnexStates],\n (annexes, [annexStates], [repetitiveAnnexStates]) => {\n const waitingRegistration: AbsolutePath[] = [];\n const pushWaitingRegistration = (path: AbsolutePath) => {\n const state = annexStates[path.toString()];\n if (state == null) {\n waitingRegistration.push(path);\n }\n };\n for (const annex of annexes) {\n if (annex.path.lastFragment === AbsolutePathFragment.Wildcard) {\n const parentPath = annex.path.parent();\n const state = repetitiveAnnexStates[parentPath.toString()];\n if (!state?.rowIds) {\n waitingRegistration.push(annex.path);\n } else {\n for (const rowId of state.rowIds) {\n pushWaitingRegistration(\n parentPath.append(new AbsolutePathFragment.Id(rowId)),\n );\n }\n }\n } else {\n pushWaitingRegistration(annex.path);\n }\n }\n return waitingRegistration;\n },\n ),\n actions: {\n getAnnexState: (path) =>\n get().annexStates[0][path.toString()] ?? null,\n getRepetitiveAnnexState: (path) =>\n get().repetitiveAnnexStates[0][path.toString()] ?? null,\n setAnnexes: (annexes: ResolvedAnnexObject[]) => {\n const oldActiveAnnexIndex = get().activeAnnexIndex();\n set({\n annexes,\n annexStates: [get().actions.buildAnnexStates(annexes)],\n repetitiveAnnexStates: [\n get().actions.buildRepetitiveAnnexStates(annexes),\n ],\n });\n get().actions.updateActiveAnnex(oldActiveAnnexIndex);\n },\n buildAnnexStates: (\n annexes: ResolvedAnnexObject[] = get().annexes,\n ) => {\n const { getAnnexState, getRepetitiveAnnexState } = get().actions;\n const newAnnexStates: Record<string, AnnexState | null> = {};\n for (const annex of annexes) {\n if (annex.path.lastFragment === AbsolutePathFragment.Wildcard) {\n const tablePath = annex.path.parent();\n for (const rowId of getRepetitiveAnnexState(tablePath)\n ?.rowIds ?? []) {\n const rowPath = tablePath.append(\n new AbsolutePathFragment.Id(rowId),\n );\n newAnnexStates[rowPath.toString()] = getAnnexState(rowPath);\n }\n } else {\n newAnnexStates[annex.path.toString()] = getAnnexState(\n annex.path,\n );\n }\n }\n return newAnnexStates;\n },\n buildRepetitiveAnnexStates: (\n annexes: ResolvedAnnexObject[] = get().annexes,\n ) => {\n const { getRepetitiveAnnexState } = get().actions;\n const newRepetitiveAnnexStates: Record<\n string,\n RepetitiveAnnexState | null\n > = {};\n\n for (const annex of annexes) {\n if (annex.path.lastFragment === AbsolutePathFragment.Wildcard) {\n const tablePath = annex.path.parent();\n newRepetitiveAnnexStates[tablePath.toString()] =\n getRepetitiveAnnexState(tablePath);\n }\n }\n return newRepetitiveAnnexStates;\n },\n setActiveAnnex: (path: string | Path | null) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const newActiveAnnex =\n path === null || path instanceof AbsolutePath\n ? path\n : new AbsolutePath(path);\n const oldActiveAnnex = get().activeAnnex;\n if (!oldActiveAnnex?.equals(newActiveAnnex)) {\n startTransition(() => {\n set({ activeAnnex: newActiveAnnex });\n if (newActiveAnnex != null) {\n setLatestInteraction(newActiveAnnex);\n }\n latestRef.current.onActivePathChange(newActiveAnnex);\n latestRef.current.onActiveAnnexChange?.(newActiveAnnex);\n });\n }\n },\n updateActiveAnnex: (oldActiveAnnexIndex: number) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const tabStates = get().tabStates();\n const nextActiveAnnex = get().nextActiveAnnex;\n if (\n nextActiveAnnex !== null &&\n tabStates.some((state) => state.path.equals(nextActiveAnnex))\n ) {\n set({ nextActiveAnnex: null });\n get().actions.setActiveAnnex(nextActiveAnnex);\n return;\n }\n\n if (\n get().activeAnnex !== null &&\n (tabStates.some((state) =>\n state.path.equals(get().activeAnnex),\n ) ||\n get()\n .waitingRegistration()\n .some((path) => path.contains(get().activeAnnex!)))\n ) {\n return;\n }\n\n get().actions.setActiveAnnex(\n tabStates[\n Math.max(0, Math.min(oldActiveAnnexIndex, tabStates.length - 1))\n ]?.path ?? null,\n );\n },\n registerAnnexState: (path, state) => {\n const oldActiveAnnexIndex = get().activeAnnexIndex();\n const annexStates = get().annexStates[0];\n annexStates[path.toString()] = state;\n set({ annexStates: [annexStates] });\n get().actions.updateActiveAnnex(oldActiveAnnexIndex);\n },\n registerRepetitiveAnnexState: (path, state) => {\n const oldActiveAnnexIndex = get().activeAnnexIndex();\n const repetitiveAnnexStates = get().repetitiveAnnexStates[0];\n repetitiveAnnexStates[path.toString()] = state;\n set({\n annexStates: [get().actions.buildAnnexStates()],\n repetitiveAnnexStates: [repetitiveAnnexStates],\n });\n get().actions.updateActiveAnnex(oldActiveAnnexIndex);\n },\n addAnnex: async (path, toAdd) => {\n const { formManager, onAnnexAdd } = latestRef.current;\n const isRepetitive =\n path.lastFragment === AbsolutePathFragment.Wildcard;\n const setPromise = formManager.set(\n isRepetitive\n ? path.parent().append(AbsolutePathFragment.CollectionEnd)\n : path,\n toAdd,\n );\n\n let addedPath: AbsolutePath;\n if (isRepetitive) {\n addedPath = await formManager.get(path.parent(), (value: Table) =>\n path\n .parent()\n .append(\n new AbsolutePathFragment.Id(\n sliceTableRows(value, tableSize(value) - 1)[0][0],\n ),\n ),\n );\n } else {\n addedPath = path;\n }\n set({ nextActiveAnnex: addedPath });\n await setPromise;\n onAnnexAdd?.(addedPath);\n return addedPath;\n },\n removeAnnex: async (path, isRepetitive) => {\n const { formManager, onAnnexRemove } = latestRef.current;\n if (isRepetitive) {\n await formManager.remove(path);\n } else {\n await formManager.set(path, null);\n }\n onAnnexRemove?.(path);\n },\n },\n })),\n ),\n );\n\n // Update store when params change\n useEffect(() => {\n store.getState().actions.setAnnexes(resolvedAnnexes);\n if (activeAnnex !== undefined) {\n const {\n activeAnnex: oldActiveAnnex,\n tabStates,\n waitingRegistration,\n } = store.getState();\n const newActiveAnnex =\n mostSpecificPath(\n activeAnnex === null ? null : basePath.resolve(activeAnnex),\n [...tabStates().map((tab) => tab.path), ...waitingRegistration()],\n oldActiveAnnex,\n ) ?? null;\n store.getState().actions.setActiveAnnex(newActiveAnnex);\n }\n }, [resolvedAnnexes, activeAnnex, basePath, store]);\n\n // Set (possibly new) active annex when focused path changes\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n const { activeAnnex, tabStates, waitingRegistration, actions } =\n store.getState();\n actions.setActiveAnnex(\n mostSpecificPath(\n focusedPath,\n [...tabStates().map((tab) => tab.path), ...waitingRegistration()],\n activeAnnex,\n ) ?? null,\n );\n },\n [store],\n ),\n );\n\n return store;\n}\n\n/** Returns the annexes' context. */\nexport function useAnnexesContext(): AnnexesContextValue {\n const annexesContext = useContext(AnnexesContext);\n if (!annexesContext) {\n throw new Error(\"Annexes context not in scope.\");\n }\n return annexesContext;\n}\n\nexport function useAnnexState<T>(\n path: AbsolutePath,\n selector: (state: AnnexState | null) => T,\n): T {\n return useStore(useAnnexesContext(), (state) =>\n selector(state.actions.getAnnexState(path)),\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n useCurrentPath,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport {\n cx,\n DocumentTitle,\n ErrorBoundary,\n type ErrorBoundaryProps,\n Spinner,\n TabContent,\n type TabContentProps,\n usePrinting,\n warnOnce,\n} from \"@ostack.tech/ui\";\nimport { type ComponentProps, type ReactNode, Suspense } from \"react\";\nimport { useStore } from \"zustand\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { FormAppIssueMessages, FormAppStatus } from \"../FormApp\";\nimport type { IssueMessagesByCode } from \"../IssueMessages\";\nimport { useAnnexesContext, useAnnexState } from \"./AnnexesContext.ts\";\n\n/** Object representation of an annex. */\nexport interface AnnexObject<T = any> {\n /**\n * Annex path. This path may contain a single wildcard (`*`) at the end, when\n * the elements of a collection should be counted as annexes. Otherwise, the\n * path may contain no other wildcards.\n */\n path?: string | Path;\n /** Annex's title. */\n title?: ReactNode | ((value: T) => ReactNode);\n /** Annex's subtitle. */\n subtitle?: ReactNode | ((value: T, index?: number) => ReactNode);\n /** Annex's description. */\n description?: ReactNode;\n /**\n * Annex's label in the issues panel. The `title` and `subtitle` are used by\n * default.\n */\n issuesPanelLabel?: ReactNode | ((value: T) => ReactNode);\n /**\n * Title of an annex within a collection of annexes. The `title` is used by\n * default.\n */\n itemTitle?: ReactNode | ((value: T, index: number) => ReactNode);\n /**\n * Issues panel label for each annex of a collection of annexes. The\n * `subtitle` and index of the item are used by default.\n */\n itemIssuesPanelLabel?: ReactNode | ((value: T, index: number) => ReactNode);\n /**\n * Title of the annex as a string to display in the document's title.\n *\n * Defaults to the `title` together with the `subtitle` (if it exists) when\n * they are strings.\n *\n * A warning is printed if either the title or the subtitle are defined but\n * aren't strings and `documentTitle` is not provided.\n */\n documentTitle?: string | null | ((value: T, index?: number) => string | null);\n /**\n * Maximum number of annexes matching this path that can be added, when\n * counting collection elements as annexes. By default, if the collection has\n * a `MaxSize` validation, then its value is used.\n */\n maxAnnexes?: number;\n /**\n * Function called when an annex matching this path is being added to choose\n * the value that should be added.\n *\n * The default value being added is provided as an argument and may be edited\n * if required.\n *\n * The value to be added should be returned, or a promise that resolves with\n * said value.\n *\n * To prevent an annex from being added, return `undefined`/`null` (or a\n * promise which resolves with `undefined`/`null`).\n *\n * @param value - Value being added, can be edited.\n * @returns Value to be added, `undefined`/`null` if the annex shouldn't be\n * added (or a promise that resolves with said values).\n */\n getValue?: (\n value: T,\n ) => T | null | undefined | PromiseLike<T | null | undefined>;\n}\n\n/** Properties of the annex component. */\nexport interface AnnexProps\n extends AnnexObject, Omit<TabContentProps, \"value\" | \"title\" | \"children\"> {\n /** Sets the annex as disabled. */\n disabled?: boolean;\n /** Sets the annex as read-only. */\n readOnly?: boolean;\n /**\n * Mapping of issue messages from the path of the field with issues to the\n * issue messages of said field (which are themselves grouped by their code).\n *\n * Provided paths are relative to the annex's path and may contain wildcards,\n * which will have a lower priority when matched against.\n *\n * These messages are used by the `IssueMessages` component.\n *\n * > **Note:** Changes to `issueMessages` are handled correctly, but are not\n * > efficient. Please make sure that the identity of the provided value doesn't\n * > change at every render.\n *\n * Example value:\n *\n * ```tsx\n * {\n * \"**\": {\n * \"valueMissing\": \"Field is required.\"\n * },\n * \"field\": {\n * \"valueMissing\": \"My field cannot be left empty!\",\n * \"someOtherError\": \"Text of the other error.\"\n * }\n * }\n * ```\n */\n issueMessages?: Record<string, IssueMessagesByCode>;\n /** Properties to pass to the container element. */\n containerProps?: ComponentProps<\"div\">;\n /** Properties to pass to the `ErrorBoundary` component. */\n errorBoundaryProps?: ErrorBoundaryProps;\n children?: ReactNode;\n}\n\n/** Component containing the content of an annex. */\nexport function Annex({\n path,\n // `AnnexObject` props\n title: _title,\n subtitle: _subtitle,\n description: _description,\n issuesPanelLabel: _issuesPanelLabel,\n itemTitle: _itemTitle,\n itemIssuesPanelLabel: _itemIssuesPanelLabel,\n documentTitle: _documentTitle,\n maxAnnexes: _maxAnnexes,\n getValue: _getValue,\n ref,\n ...otherProps\n}: AnnexProps) {\n const annexPath = useResolvedPath(path);\n const store = useAnnexesContext();\n const activeAnnex = useStore(store, (state) => state.activeAnnex);\n const tabStates = useStore(\n store,\n useShallow((state) =>\n state.tabStates().filter((state) => annexPath.contains(state.path)),\n ),\n );\n\n return tabStates.map((state) => {\n const pathStr = state.path.toString();\n return (\n <CurrentPath key={pathStr} path={state.path}>\n <AnnexTabContent\n {...otherProps}\n ref={state.path.equals(activeAnnex) ? ref : undefined}\n />\n </CurrentPath>\n );\n });\n}\n\ninterface AnnexTabContentProps extends Omit<AnnexProps, keyof AnnexObject> {}\n\nfunction AnnexTabContent({\n disabled = false,\n readOnly = false,\n issueMessages,\n children,\n className,\n containerProps,\n tabContentLabelProps,\n errorBoundaryProps,\n ...otherProps\n}: AnnexTabContentProps) {\n const prefix = usePrefix();\n const printing = usePrinting();\n const annexPath = useCurrentPath();\n const documentTitle = useAnnexState(annexPath, (state) =>\n state === null ? null : state.documentTitle,\n );\n\n if (documentTitle === undefined) {\n warnOnce(\n `Annex: At '${annexPath.toString()}': \\`documentTitle\\` ` +\n \"should be set manually since either `title` or `subtitle` is not a \" +\n \"string.\",\n );\n }\n\n return (\n <div\n {...containerProps}\n className={cx(\n prefix(\"annexes__annex-container\"),\n containerProps?.className,\n )}\n >\n <TabContent\n className={cx(prefix(\"annexes__annex\"), className)}\n value={annexPath.toString()}\n tabContentLabelProps={{\n ...tabContentLabelProps,\n className: cx(\n prefix(\"annexes__annex-label\"),\n tabContentLabelProps?.className,\n ),\n }}\n {...otherProps}\n >\n <ErrorBoundary {...errorBoundaryProps}>\n <DocumentTitle\n title={printing ? undefined : (documentTitle ?? undefined)}\n >\n <FormAppStatus disabled={disabled} readOnly={readOnly}>\n <FormAppIssueMessages issueMessages={issueMessages}>\n <Suspense fallback={<Spinner size=\"xl\" color=\"primary\" />}>\n {children}\n </Suspense>\n </FormAppIssueMessages>\n </FormAppStatus>\n </DocumentTitle>\n </ErrorBoundary>\n </TabContent>\n </div>\n );\n}\n","import { AbsolutePath, AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { useFormController, useFormManager } from \"@ostack.tech/kform-react\";\nimport { useToastManager } from \"@ostack.tech/ui\";\nimport {\n fileOpen,\n type FileSystemHandle,\n type FileWithHandle,\n supported,\n type WellKnownDirectory,\n} from \"browser-fs-access\";\nimport { DEV } from \"esm-env\";\nimport { type ReactNode, useMemo } from \"react\";\n\nimport { useFormTitle, useStartIssuesNavigation } from \"../components/FormApp\";\nimport { useLocale } from \"../providers/LocalizationProvider\";\n\n/**\n * Options that can be passed to the {@link useFormLoader} hook, or to its\n * resulting `load` function.\n */\nexport interface FormLoaderOptions<T = unknown> {\n /**\n * Function used to decode the form, given its file.\n *\n * If decoding a text-based format, one may use `await file.text()` to get the\n * content of the file as a string.\n *\n * @param file File containing the form to decode.\n * @returns Decoded form value.\n */\n decode?: (file: FileWithHandle) => PromiseLike<T>;\n /**\n * Path of the value being loaded.\n *\n * @default AbsolutePath.ROOT\n */\n path?: string | AbsolutePath;\n /** Acceptable file extensions. */\n extensions?: string[];\n /** Acceptable MIME types. */\n mimeTypes?: string[];\n /** Suggested file description. */\n description?: string;\n /** Directory to present when starting to load. */\n startIn?: WellKnownDirectory | FileSystemHandle;\n /**\n * By specifying an ID, the user agent can remember different directories for\n * different IDs.\n */\n id?: string;\n /**\n * Whether to set the form as pristine when it is loaded.\n *\n * @default true\n */\n setPristineOnLoad?: boolean;\n /**\n * Whether to set the form as touched when it is loaded.\n *\n * @defalut true\n */\n setTouchedOnLoad?: boolean;\n /**\n * Whether to validate the form (and show the issues panel) when it is loaded.\n *\n * @default true\n */\n validateOnLoad?: boolean;\n /**\n * Message to show in a toast when successfully loading a form from a file.\n * Can be set to `null` to not show any message.\n *\n * @param file Loaded file.\n * @returns Message to show in a toast.\n */\n successMessage?: ReactNode | ((file: FileWithHandle) => ReactNode);\n /**\n * Message to show in a toast when an error occurs while loading the form from\n * a file. Can be set to `null` to not show any message.\n *\n * @param file File from which the load was attempted (or `null` if the file\n * could not be accessed).\n * @param error Error that occurred.\n * @returns Message to show in a toast.\n */\n errorMessage?:\n ReactNode | ((file: FileWithHandle | null, error: unknown) => ReactNode);\n}\n\n/** Result of the {@link useFormLoader} hook. */\nexport interface FormLoaderResult<T> {\n /**\n * Function used to load the form.\n *\n * @param options Options used for loading the form.\n * @returns Promise which resolves once the form has been loaded.\n */\n load: (options?: FormLoaderOptions<T>) => Promise<void>;\n /** Whether the browser supports modern file system APIs used for loading. */\n supportsFileSystemAPIs: boolean;\n}\n\n/** Hook exposing a function used to load the form from a file. */\nexport function useFormLoader<T = unknown>({\n decode,\n path,\n extensions,\n mimeTypes,\n description,\n startIn,\n id,\n setPristineOnLoad,\n setTouchedOnLoad,\n validateOnLoad,\n successMessage,\n errorMessage,\n}: FormLoaderOptions<T> = {}): FormLoaderResult<T> {\n const [locale] = useLocale();\n const formManager = useFormManager();\n const { _setState } = useFormController();\n const { addToast } = useToastManager();\n const startIssuesNavigation = useStartIssuesNavigation();\n const formTitle = useFormTitle();\n const defaultId = useMemo(\n () => formTitle?.replace(/[^a-zA-Z0-9-_]/g, \"\").substring(0, 32) ?? \"\",\n [formTitle],\n );\n\n return useMemo(() => {\n async function load({\n decode,\n path = AbsolutePath.ROOT,\n extensions,\n mimeTypes,\n description,\n startIn,\n id = defaultId,\n setPristineOnLoad = true,\n setTouchedOnLoad = true,\n validateOnLoad = true,\n successMessage = locale.LoadAction.successMessage,\n errorMessage = locale.LoadAction.errorMessage,\n }: FormLoaderOptions<T>) {\n if (!decode) {\n throw new Error(\"No `decode` function was provided.\");\n }\n\n const validationModeIsAuto =\n formManager.autoValidationStatus !== \"inactive\";\n let file: FileWithHandle | null = null;\n try {\n file = await fileOpen({\n extensions,\n mimeTypes,\n description,\n startIn,\n id,\n });\n\n _setState({ loading: true } as any);\n const formValue = await decode(file);\n\n // Set validation mode as manual prior to loading the file\n if (validationModeIsAuto) {\n await formManager.setValidationMode(\"manual\");\n }\n\n await formManager.set(path, formValue);\n if (setPristineOnLoad || setTouchedOnLoad) {\n const pathWithDescendants = (\n path instanceof AbsolutePath ? path : new AbsolutePath(path)\n ).append(AbsolutePathFragment.RecursiveWildcard);\n await Promise.all([\n setPristineOnLoad && formManager.setPristine(path),\n setTouchedOnLoad && formManager.setTouched(pathWithDescendants),\n validateOnLoad && formManager.validate(pathWithDescendants),\n ]);\n }\n if (validateOnLoad) {\n await startIssuesNavigation({ validate: false });\n }\n\n _setState(\n (state: any) =>\n ({\n latestFileHandles: {\n ...state.latestFileHandles,\n [id]: file!.handle ?? null,\n },\n }) as any,\n );\n\n const message =\n typeof successMessage === \"function\"\n ? successMessage(file)\n : successMessage;\n if (message != null) {\n addToast(message, { severity: \"success\" });\n }\n } catch (error) {\n // User aborted\n if (error instanceof DOMException && error.name === \"AbortError\") {\n return;\n }\n\n if (DEV) {\n console.error(error);\n }\n const message =\n typeof errorMessage === \"function\"\n ? errorMessage(file, error)\n : errorMessage;\n if (message != null) {\n addToast(message, { severity: \"danger\" });\n }\n } finally {\n // Reset validation mode\n if (validationModeIsAuto) {\n await formManager.setValidationMode(\"auto\");\n }\n\n _setState({ loading: false } as any);\n }\n }\n\n return {\n load: (options = {}) =>\n load({\n decode,\n path,\n extensions,\n mimeTypes,\n description,\n startIn,\n id,\n setPristineOnLoad,\n setTouchedOnLoad,\n validateOnLoad,\n successMessage,\n errorMessage,\n ...options,\n }),\n supportsFileSystemAPIs: supported,\n };\n }, [\n defaultId,\n locale.LoadAction.successMessage,\n locale.LoadAction.errorMessage,\n formManager,\n _setState,\n startIssuesNavigation,\n addToast,\n decode,\n path,\n extensions,\n mimeTypes,\n description,\n startIn,\n id,\n setPristineOnLoad,\n setTouchedOnLoad,\n validateOnLoad,\n successMessage,\n errorMessage,\n ]);\n}\n\n/** Hook exposing whether the form is currently being loaded. */\nexport function useFormIsLoading() {\n return useFormController().useState((state) => (state as any).loading);\n}\n","import { AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { CurrentPath, useFormattedValue } from \"@ostack.tech/kform-react\";\nimport { usePrinting, useStartPrintingTask } from \"@ostack.tech/ui\";\nimport {\n type ReactNode,\n useCallback,\n useDeferredValue,\n useEffect,\n} from \"react\";\nimport { shallow } from \"zustand/shallow\";\n\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterController, useRegisterLabel } from \"../FormApp\";\nimport {\n type ResolvedAnnexObject,\n useAnnexesContext,\n} from \"./AnnexesContext.ts\";\n\n/** Properties of the `AnnexRegistrar` component. */\nexport interface AnnexRegistrarProps extends ResolvedAnnexObject {\n index?: number;\n}\n\n/** Component used to register a form annex. */\nexport function AnnexRegistrar({\n path,\n title,\n subtitle,\n description,\n issuesPanelLabel,\n itemTitle,\n itemIssuesPanelLabel,\n index,\n documentTitle,\n}: AnnexRegistrarProps) {\n const store = useAnnexesContext();\n\n const printing = usePrinting();\n const finishPrintingTask = useStartPrintingTask();\n const observeDescendants =\n typeof itemTitle === \"function\" ||\n typeof title === \"function\" ||\n typeof subtitle === \"function\" ||\n typeof documentTitle === \"function\";\n const [isNull = true, controller] = useFormattedValue(\n observeDescendants\n ? path.append(AbsolutePathFragment.RecursiveWildcard)\n : path,\n {\n enabled: !useFormIsLoading(),\n onInitialized: finishPrintingTask,\n format: useCallback((value: unknown) => value === null, []),\n },\n );\n const isRepetitive = index != null;\n const absolutePath = controller.usePath();\n const schema = controller.useSchema();\n const exists = controller.useState(\n (state) => state.initialized && state.exists,\n );\n const dirty = controller.useDirty();\n const value = controller.useValue();\n const deferredValue = useDeferredValue(value);\n const relevantValue = printing ? value : deferredValue;\n const deferredIssuesToDisplay = useDeferredValue(\n controller.useState((state) => (state.touched ? state.issues : []), {\n equalityFn: shallow,\n }),\n );\n const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());\n\n const actualTitle = isRepetitive\n ? typeof itemTitle === \"function\"\n ? relevantValue === undefined\n ? null\n : itemTitle(relevantValue, index)\n : itemTitle === undefined\n ? (title as ReactNode)\n : itemTitle\n : typeof title === \"function\"\n ? relevantValue === undefined\n ? null\n : title(relevantValue)\n : title;\n const actualSubtitle =\n typeof subtitle === \"function\"\n ? relevantValue === undefined\n ? null\n : subtitle(relevantValue, index)\n : subtitle;\n const actualDocumentTitle =\n typeof documentTitle === \"function\"\n ? relevantValue === undefined\n ? null\n : documentTitle(relevantValue, index)\n : documentTitle === undefined\n ? (actualTitle === null || typeof actualTitle === \"string\") &&\n (actualSubtitle == null || typeof actualSubtitle === \"string\")\n ? [actualTitle, actualSubtitle].filter((s) => s).join(\" — \")\n : undefined\n : documentTitle;\n\n useEffect(() => {\n if (exists) {\n const { registerAnnexState } = store.getState().actions;\n registerAnnexState(absolutePath, {\n path: absolutePath,\n schema,\n isNull,\n dirty,\n deferredIssuesToDisplay,\n deferredDisplayStatus,\n isRepetitive,\n title: actualTitle,\n subtitle: actualSubtitle,\n documentTitle: actualDocumentTitle,\n description,\n });\n }\n }, [\n absolutePath,\n deferredDisplayStatus,\n deferredIssuesToDisplay,\n description,\n dirty,\n exists,\n isNull,\n isRepetitive,\n actualSubtitle,\n actualTitle,\n schema,\n store,\n subtitle,\n title,\n actualDocumentTitle,\n ]);\n\n useRegisterController(controller);\n useRegisterLabel(\n absolutePath,\n <CurrentPath path={absolutePath}>\n {isRepetitive ? (\n typeof itemIssuesPanelLabel === \"function\" ? (\n deferredValue === undefined ? null : (\n itemIssuesPanelLabel(deferredValue, index)\n )\n ) : itemIssuesPanelLabel === undefined ? (\n (actualSubtitle ?? index + 1)\n ) : (\n itemIssuesPanelLabel\n )\n ) : issuesPanelLabel ? (\n typeof issuesPanelLabel === \"function\" ? (\n deferredValue === undefined ? null : (\n issuesPanelLabel(deferredValue)\n )\n ) : (\n issuesPanelLabel\n )\n ) : (\n <>\n {actualTitle}\n {actualSubtitle && <> — {actualSubtitle}</>}\n </>\n )}\n </CurrentPath>,\n );\n\n return null;\n}\n","import {\n AbsolutePathFragment,\n type Table,\n tableIdsToArray,\n type TableRowId,\n} from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n InvalidPathError,\n useFormattedValue,\n} from \"@ostack.tech/kform-react\";\nimport { useStartPrintingTask } from \"@ostack.tech/ui\";\nimport { useCallback, useDeferredValue, useEffect } from \"react\";\nimport { shallow } from \"zustand/shallow\";\n\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterController, useRegisterLabel } from \"../FormApp\";\nimport {\n type ResolvedAnnexObject,\n useAnnexesContext,\n} from \"./AnnexesContext.ts\";\nimport { AnnexRegistrar } from \"./AnnexRegistrar.tsx\";\n\n/** Properties of the `RepetitiveAnnexRegistrar` component. */\nexport interface RepetitiveAnnexRegistrarProps extends ResolvedAnnexObject {}\n\n/** Component used to register a repetitive form annex. */\nexport function RepetitiveAnnexRegistrar({\n path,\n maxAnnexes,\n ...annexProps\n}: RepetitiveAnnexRegistrarProps) {\n const store = useAnnexesContext();\n\n const finishPrintingTask = useStartPrintingTask();\n const [rowIds, controller] = useFormattedValue(path.parent(), {\n enabled: !useFormIsLoading(),\n onInitialized: finishPrintingTask,\n format: useCallback(\n (value?: Table | null): TableRowId[] =>\n value ? tableIdsToArray(value) : [],\n [],\n ),\n });\n const schema = controller.useSchema();\n const absolutePath = controller.usePath();\n const deferredIssuesToDisplay = useDeferredValue(\n controller.useState((state) => (state.touched ? state.issues : []), {\n equalityFn: shallow,\n }),\n );\n const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());\n\n if (schema.typeInfo.name !== \"Table\") {\n throw new InvalidPathError(\n absolutePath,\n \"Unsupported schema: Expected (possibly nullable) table schema, \" +\n \"but got schema representing values of type \" +\n `'${schema.typeInfo.toString()}'.`,\n );\n }\n\n useEffect(() => {\n const { registerRepetitiveAnnexState } = store.getState().actions;\n registerRepetitiveAnnexState(absolutePath, {\n rowIds,\n maxAnnexes,\n path: absolutePath,\n schema,\n deferredIssuesToDisplay,\n });\n }, [\n absolutePath,\n deferredDisplayStatus,\n deferredIssuesToDisplay,\n maxAnnexes,\n rowIds,\n schema,\n store,\n ]);\n\n if (\n typeof annexProps.title === \"function\" ||\n typeof annexProps.issuesPanelLabel === \"function\"\n ) {\n throw new Error(\n \"Repetitive annexes must not set `title` or `issuesPanelLabel` as a \" +\n \"function. Use `itemTitle` or `itemIssuesPanelLabel` instead.\",\n );\n }\n\n const actualIssuesPanelLabel = annexProps.issuesPanelLabel\n ? annexProps.issuesPanelLabel\n : annexProps.title;\n\n useRegisterController(controller);\n useRegisterLabel(\n absolutePath,\n <CurrentPath path={absolutePath}>{actualIssuesPanelLabel}</CurrentPath>,\n );\n\n return rowIds?.map((rowId, i) => (\n <AnnexRegistrar\n key={rowId}\n path={absolutePath.append(new AbsolutePathFragment.Id(rowId))}\n index={i}\n {...annexProps}\n />\n ));\n}\n","import {\n type AbsolutePath,\n AbsolutePathFragment,\n Path,\n} from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n useFormManager,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport { cx, parseChildren, Tabs, type TabsProps } from \"@ostack.tech/ui\";\nimport { type ReactNode, useCallback, useMemo } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { Annex, type AnnexObject } from \"./Annex.tsx\";\nimport { AnnexesContext, useCreateAnnexesContext } from \"./AnnexesContext.ts\";\nimport { AnnexRegistrar } from \"./AnnexRegistrar.tsx\";\nimport { RepetitiveAnnexRegistrar } from \"./RepetitiveAnnexRegistrar.tsx\";\n\n/** Properties of the annexes component. */\nexport interface AnnexesProps extends Omit<\n TabsProps,\n \"defaultValue\" | \"value\" | \"onValueChange\" | \"showAllTabsWhilePrinting\"\n> {\n /** Base path for all declared annexes. */\n path?: string | Path;\n /**\n * List of all annexes. When not provided, the list of annexes is obtained\n * from the direct children `Annex` components.\n */\n annexes?: AnnexObject[];\n /** Default active annex. */\n defaultActiveAnnex?: string | Path;\n /** Controlled active annex. */\n activeAnnex?: string | Path;\n /**\n * Function called whenever the active annex changes.\n *\n * @param activeAnnex Path of the new active annex.\n */\n onActiveAnnexChange?: (activeAnnexPath: AbsolutePath | null) => void;\n /**\n * Function called when a new annex is added.\n *\n * @param newAnnexPath Path of the new annex.\n */\n onAnnexAdd?: (newAnnexPath: AbsolutePath) => void;\n /**\n * Function called when an annex is removed.\n *\n * @param removedAnnexPath Path of the removed annex.\n */\n onAnnexRemove?: (removedAnnexPath: AbsolutePath) => void;\n children?: ReactNode;\n}\n\n/**\n * The annexes component can be used to split parts of a form into separate\n * annexes (tabs), while providing means of managing and navigating between\n * them. Although not strictly mandatory, each annex (tab) is typically\n * represented by its own class, with its own schema and distinct path.\n *\n * It further supports optional annexes (via\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html)\n * schemas), as well as repetitive ones (via schemas of type\n * [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)\n * or\n * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)).\n *\n * The following built-in KForm validations affect annexes:\n *\n * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):\n * Sets the `maxAnnexes` property of repetitive annexes.\n *\n * It composes the following subcomponents:\n *\n * - `AnnexesManager`: Component used to manage and navigate between annexes\n * (tabs).\n * - `Annex`: Content of a single annex (tab) of the form.\n *\n * Example usage:\n *\n * ```tsx\n * import { Annex, Annexes, AnnexesManager } from \"@ostack.tech/ui-kform\";\n *\n * function TaxDeclarationsAnnexes() {\n * return (\n * <Annexes>\n * <AnnexesManager />\n * <Annex path=\"/cover\" title=\"Cover\" subtitle=\"Income sources\">\n * Cover content…\n * </Annex>\n * <Annex path=\"/annexA\" title=\"Annex A\" subtitle=\"Foreign assets\">\n * Annex A content…\n * </Annex>\n * </Annexes>\n * );\n * }\n * ```\n */\nexport function Annexes({\n path,\n annexes,\n defaultActiveAnnex,\n activeAnnex,\n onActiveAnnexChange,\n onAnnexAdd,\n onAnnexRemove,\n variant = \"annexes\",\n className,\n children,\n ...otherProps\n}: AnnexesProps) {\n const prefix = usePrefix();\n const formManager = useFormManager();\n const absolutePath = useResolvedPath(path);\n\n // Get annexes from children if not provided as prop\n annexes ??= parseChildren(children, Annex, {\n renderUnknownComponents: false,\n });\n\n // Provided annexes but with absolute paths\n const resolvedAnnexes = useMemo(\n () =>\n annexes.map((annex) => ({\n ...annex,\n path: absolutePath.resolve(annex.path ?? Path.CURRENT),\n })),\n [absolutePath, annexes],\n );\n\n // Refuse non-existent paths\n if (!formManager.isValidPath(absolutePath)) {\n throw new Error(`Invalid path: '${absolutePath.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n absolutePath.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Annexes base path must only contain ids.\");\n }\n // Validate annex paths\n for (const annex of resolvedAnnexes) {\n // Refuse non-existent paths\n if (!formManager.isValidPath(annex.path)) {\n throw new Error(`Invalid path: '${annex.path.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only, or identifiers\n // followed by a wildcard\n if (\n annex.path.fragments.some(\n (frag, i, { length }) =>\n !(frag instanceof AbsolutePathFragment.Id) &&\n (frag !== AbsolutePathFragment.Wildcard || i !== length - 1),\n )\n ) {\n throw new Error(\n \"Annex path must either only contain ids, or ids followed by a \" +\n \"single wildcard at the end.\",\n );\n }\n }\n\n const store = useCreateAnnexesContext({\n formManager,\n basePath: absolutePath,\n resolvedAnnexes,\n defaultActiveAnnex,\n activeAnnex,\n onActiveAnnexChange,\n onAnnexAdd,\n onAnnexRemove,\n });\n\n const activeAnnexString = useStore(\n store,\n (state) => state.activeAnnex?.toString() ?? \"\",\n );\n const handleValueChange = useCallback(\n (value: string) => store.getState().actions.setActiveAnnex(value),\n [store],\n );\n\n return (\n <CurrentPath path={absolutePath}>\n <AnnexesContext.Provider value={store}>\n {resolvedAnnexes.map((annex) =>\n annex.path.lastFragment === AbsolutePathFragment.Wildcard ? (\n <RepetitiveAnnexRegistrar key={annex.path.toString()} {...annex} />\n ) : (\n <AnnexRegistrar key={annex.path.toString()} {...annex} />\n ),\n )}\n\n <Tabs\n className={cx(prefix(\"annexes\"), className)}\n variant={variant}\n activationMode=\"manual\"\n value={activeAnnexString}\n onValueChange={handleValueChange}\n showAllTabsWhilePrinting\n {...otherProps}\n >\n {children}\n </Tabs>\n </AnnexesContext.Provider>\n </CurrentPath>\n );\n}\n","import { type AbsolutePath, ValidationFailure } from \"@ostack.tech/kform\";\nimport {\n AtPathError,\n type LocatedValidationInfo,\n} from \"@ostack.tech/kform-react\";\nimport { useErrorReporter } from \"@ostack.tech/ui\";\nimport { useEffect } from \"react\";\n\ntype ReportValidationFailuresInfo = Pick<\n LocatedValidationInfo,\n \"path\" | \"issues\"\n>;\n\nclass ValidationFailureError extends AtPathError {\n constructor(path: AbsolutePath, issue: ValidationFailure) {\n super(path, `Failed to run validation '${issue.validation}'`);\n this.name = this.constructor.name;\n this.stack += `\\nCaused by: ${issue.stackTrace}`;\n }\n}\n\n/** Hook used to report validation failures that occur. */\nexport function useReportValidationFailures(\n info?: ReportValidationFailuresInfo[],\n) {\n const reportError = useErrorReporter();\n useEffect(() => {\n if (info) {\n for (const { path, issues } of info) {\n for (const issue of issues) {\n if (issue instanceof ValidationFailure) {\n reportError(new ValidationFailureError(path, issue));\n }\n }\n }\n }\n }, [info, reportError]);\n}\n","import type {\n AbsolutePath,\n FormManager,\n Schema,\n SealedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport type { Controller } from \"@ostack.tech/kform-react\";\nimport { EMPTY_STORE, useConstant } from \"@ostack.tech/ui\";\nimport { createContext, useContext, useEffect } from \"react\";\nimport { createStore, useStore } from \"zustand\";\n\n/** Value of the control field context. */\nexport type ControlFieldContextValue = ControlFieldStore;\n\n/** State of the control field. */\nexport interface ControlFieldState {\n controlStates: Record<string, ControlState>;\n}\n\n/** State of a control accessible to the whole field. */\nexport interface ControlState {\n formManager: FormManager;\n schema: Schema;\n path: AbsolutePath;\n exists: boolean;\n deferredIssuesToDisplay: SealedValidationIssue[];\n}\n\n/** Control field store. */\nexport type ControlFieldStore = ReturnType<typeof useCreateControlFieldContext>;\n\n/** Control field context. */\nexport const ControlFieldContext =\n createContext<ControlFieldContextValue | null>(null);\n\n/** Hook which creates the control field context value. */\nexport function useCreateControlFieldContext() {\n return useConstant(() =>\n createStore<ControlFieldState>(() => ({\n controlStates: {},\n })),\n );\n}\n\n/** Hook returning the control field's context value. */\nfunction useControlFieldContext(): ControlFieldContextValue | null {\n return useContext(ControlFieldContext);\n}\n\n/** Hook that returns access to the control field's store. */\nexport function useControlFieldStore<T>(\n selector: (state: Partial<ControlFieldState>) => T,\n): T {\n return useStore(useControlFieldContext() ?? EMPTY_STORE, selector);\n}\n\n/** Hook exposing whether a component is being rendered within a control field. */\nexport function useIsInControlField(): boolean {\n return useControlFieldContext() !== null;\n}\n\n/**\n * Hook that makes a control field aware of a controller.\n *\n * The passed `controller` object should not be different on every render.\n */\nexport function useRegisterControllerWithinControlField<T = unknown>(\n controller: Controller<T>,\n deferredIssuesToDisplay: SealedValidationIssue[],\n) {\n const store = useControlFieldContext();\n const formManager = controller.useFormManager();\n const path = controller.usePath();\n const schema = controller.useSchema();\n const exists = controller.useState(\n (state) => state.initialized && state.exists,\n );\n useEffect(() => {\n if (store) {\n const pathStr = path.toString();\n store.setState((state) => ({\n controlStates: {\n ...state.controlStates,\n [pathStr]: {\n formManager,\n schema,\n path,\n exists,\n deferredIssuesToDisplay,\n },\n },\n }));\n return () => {\n store.setState(\n ({ controlStates: { [pathStr]: _, ...controlStates } }) => ({\n controlStates,\n }),\n );\n };\n }\n }, [deferredIssuesToDisplay, exists, formManager, path, schema, store]);\n}\n","import { Path } from \"@ostack.tech/kform\";\nimport { CurrentPath, useFormManager } from \"@ostack.tech/kform-react\";\nimport { Field, type FieldProps } from \"@ostack.tech/ui\";\nimport { useEffect } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport {\n ControlFieldContext,\n useCreateControlFieldContext,\n} from \"./ControlFieldContext.ts\";\n\n/** Properties of the control field component. */\nexport interface ControlFieldProps extends FieldProps {\n /** Path of the field; inner control paths will be relative to this path. */\n path?: string | Path;\n /**\n * Whether to show the control field.\n *\n * The component will, by default, automatically reset its inner controls when\n * the control field becomes hidden.\n *\n * @default true\n */\n shown?: boolean;\n /**\n * Whether to reset the inner controls when the control field becomes hidden.\n *\n * @default true\n */\n resetOnHide?: boolean;\n /**\n * Whether to set inner controls as untouched when the control field becomes\n * hidden.\n *\n * @default resetOnHide\n */\n setUntouchedOnHide?: boolean;\n /**\n * Whether to set inner controls as pristine when the control field becomes\n * hidden.\n *\n * @default resetOnHide\n */\n setPristineOnHide?: boolean;\n}\n\n/**\n * Component used to group controls with a label, helper text, and/or feedback.\n *\n * The component can be conditionally shown via the `shown` property which, by\n * default, when changing from `true` to `false` will reset its inner controls.\n *\n * Added labels automatically \"point\" to the control and are set to \"required\"\n * when requested by the control.\n *\n * Aria descriptions and error messages are set on the control based on the\n * provided helper texts or feedbacks.\n */\n// TODO: deprecate after introduction of `ResetOnChange` component:\n// @deprecated Use the `@ostack.tech/ui` {@link Field} component instead. Set the\n// `path` on the control directly instead. If using `resetOnHide`, use the\n// `ResetOnChange` component or the `useResetOnChange` hook instead on the\n// control that causes the resetting instead to mimic similar behaviour.\nexport function ControlField({\n path = Path.CURRENT,\n shown = true,\n resetOnHide = true,\n setUntouchedOnHide = resetOnHide,\n setPristineOnHide = resetOnHide,\n ...otherProps\n}: ControlFieldProps) {\n const formManager = useFormManager();\n\n // Controllers registered within the control field\n const store = useCreateControlFieldContext();\n\n // Reset registered controllers when `shown` becomes `false`\n const controlStates = useStore(store, (state) => state.controlStates);\n useEffect(() => {\n if (!shown) {\n for (const controlState of Object.values(controlStates)) {\n const { formManager, path, exists } = controlState;\n if (exists) {\n if (resetOnHide) {\n void formManager.reset(path);\n }\n if (setUntouchedOnHide) {\n void formManager.setUntouched(path);\n }\n if (setPristineOnHide) {\n void formManager.setPristine(path);\n }\n }\n }\n }\n }, [\n controlStates,\n formManager,\n resetOnHide,\n setPristineOnHide,\n setUntouchedOnHide,\n shown,\n store,\n ]);\n\n return (\n shown && (\n <CurrentPath path={path}>\n <ControlFieldContext.Provider value={store}>\n <Field {...otherProps} />\n </ControlFieldContext.Provider>\n </CurrentPath>\n )\n );\n}\n","import type {\n AbsolutePath,\n Path,\n Schema,\n SealedValidationIssue,\n ValidationIssueData,\n} from \"@ostack.tech/kform\";\nimport {\n useFormManager,\n useIssuesTracker,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport {\n Feedback,\n FeedbackList,\n type FeedbackListProps,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, useDeferredValue, useMemo } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useReportValidationFailures } from \"../../utils/useReportValidationFailures.ts\";\nimport { useIsInControlField } from \"../ControlField\";\nimport { useControlFieldStore } from \"../ControlField/ControlFieldContext.ts\";\nimport { FormAppIssueMessages } from \"../FormApp\";\nimport { IssueMessage } from \"../IssueMessage\";\n\n/** Value of an issue message. */\nexport type IssueMessageValue =\n | ReactNode\n | ((\n issueData: ValidationIssueData,\n schema: Schema,\n path: AbsolutePath,\n ) => ReactNode);\n\n/** Mapping of issue message codes to their respective message. */\nexport type IssueMessagesByCode = Record<string, IssueMessageValue>;\n\n/** Properties of the issue messages component. */\nexport interface IssueMessagesProps extends FeedbackListProps {\n /** Path of the value for which to show issues. */\n path?: string | Path;\n /**\n * Issues to show, associated with the provided path. If not provided, the\n * component will query the issues from the form manager.\n */\n issues?: SealedValidationIssue[];\n /** Mapping from an issue's code to its message. */\n messages?: IssueMessagesByCode;\n /**\n * Whether to display issue codes together with each issue message.\n *\n * This property can also be set globally via the `displayIssueCodes` property\n * of the `FormApp`.\n */\n displayIssueCodes?: boolean;\n /**\n * Name of the key in a validation issue's data object that possibly contains\n * the issue message. This message is only used if no matching message is\n * otherwise found.\n *\n * @default \"message\"\n */\n messagesDataKey?: string;\n /** Accessible prefix for error codes when `displayIssueCodes` is set. */\n visuallyHiddenErrorCodePrefix?: ReactNode;\n /** Accessible prefix for warning codes when `displayIssueCodes` is set. */\n visuallyHiddenWarningCodePrefix?: ReactNode;\n /**\n * Message to show for an error that does not have an associated message.\n *\n * This message will always automatically include the code of the issue in\n * question.\n */\n unknownErrorMessage?: ReactNode;\n /**\n * Message to show for a warning that does not have an associated message.\n *\n * This message will always automatically include the code of the issue in\n * question.\n */\n unknownWarningMessage?: ReactNode;\n /**\n * Whether to render the issue messages \"unwrapped\", i.e. outside a containing\n * `FeedbackList`.\n *\n * This is useful together with components such as the `DateRangeControl`\n * where you might want to show issues for multiple paths, all within the same\n * `FeedbackList`:\n *\n * ```tsx\n * <FeedbackList>\n * <IssueMessages path=\"startDate\" unwrapped />\n * <IssueMessages path=\"endDate\" unwrapped />\n * </FeedbackList>;\n * ```\n */\n unwrapped?: boolean;\n}\n\n/**\n * Component used to display all issues associated with the relevant path.\n *\n * Issue messages are automatically read from the scope (typically provided by\n * setting the `issueMessages` property of a `FormApp`, `Annex`, or\n * `FormPage`).\n *\n * Messages may also be passed directly to this component via the `messages`\n * property.\n *\n * If `path` contains an issue without an associated issue message, a generic\n * message is displayed together with a console warning.\n */\nexport function IssueMessages({\n path,\n issues,\n messages,\n displayIssueCodes,\n messagesDataKey,\n visuallyHiddenErrorCodePrefix,\n visuallyHiddenWarningCodePrefix,\n unknownErrorMessage,\n unknownWarningMessage,\n unwrapped,\n ...otherProps\n}: IssueMessagesProps) {\n const prefix = usePrefix();\n const isInControlField = useIsInControlField();\n const formManager = useFormManager();\n const absolutePath = useResolvedPath(path);\n const { info } = useIssuesTracker(absolutePath, {\n enabled: !issues && !isInControlField,\n });\n const messagesToRegister = useMemo(\n () => messages && { [absolutePath.toString()]: messages },\n [absolutePath, messages],\n );\n\n const relevantControlState = useControlFieldStore((state) =>\n isInControlField ? state.controlStates?.[absolutePath.toString()] : null,\n );\n const deferredTrackedIssues = useDeferredValue(\n useMemo(() => info?.flatMap((info) => info.issues) ?? [], [info]),\n );\n const deferredIssuesToDisplay = useMemo(\n () =>\n issues ??\n (isInControlField\n ? (relevantControlState?.deferredIssuesToDisplay ?? [])\n : deferredTrackedIssues),\n [\n deferredTrackedIssues,\n isInControlField,\n issues,\n relevantControlState?.deferredIssuesToDisplay,\n ],\n );\n useReportValidationFailures(\n useMemo(\n () => [{ path: absolutePath, issues: deferredIssuesToDisplay }],\n [absolutePath, deferredIssuesToDisplay],\n ),\n );\n\n const schema = useMemo(\n () => relevantControlState?.schema ?? formManager.schema(absolutePath),\n [absolutePath, formManager, relevantControlState?.schema],\n );\n\n const feedbackNodes = useMemo(\n () =>\n deferredIssuesToDisplay.map((issue, i) => (\n <Feedback key={i} type={issue.severity}>\n <IssueMessage\n path={absolutePath}\n issue={issue}\n schema={schema}\n displayIssueCode={displayIssueCodes}\n messageDataKey={messagesDataKey}\n visuallyHiddenErrorCodePrefix={visuallyHiddenErrorCodePrefix}\n visuallyHiddenWarningCodePrefix={visuallyHiddenWarningCodePrefix}\n unknownErrorMessage={unknownErrorMessage}\n unknownWarningMessage={unknownWarningMessage}\n issueCodeProps={{ className: prefix(\"issue-messages__issue-code\") }}\n />\n </Feedback>\n )),\n [\n deferredIssuesToDisplay,\n absolutePath,\n schema,\n displayIssueCodes,\n messagesDataKey,\n visuallyHiddenErrorCodePrefix,\n visuallyHiddenWarningCodePrefix,\n unknownErrorMessage,\n unknownWarningMessage,\n prefix,\n ],\n );\n\n return (\n <FormAppIssueMessages issueMessages={messagesToRegister}>\n {unwrapped ? (\n feedbackNodes\n ) : (\n <FeedbackList {...otherProps}>{feedbackNodes}</FeedbackList>\n )}\n </FormAppIssueMessages>\n );\n}\n","import { AbsolutePath, type Path } from \"@ostack.tech/kform\";\nimport { CurrentPath, useResolvedPath } from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackPopover,\n type FeedbackPopoverProps,\n useControllableState,\n} from \"@ostack.tech/ui\";\nimport { useCallback } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { useIsInControlField } from \"../ControlField\";\nimport { useOnPathFocus } from \"../FormApp\";\n\n/** Properties of the issues popover component. */\nexport interface IssuesPopoverProps extends FeedbackPopoverProps {\n path?: string | Path;\n /**\n * Paths relevant to this issues popover. When one of the relevant paths\n * becomes active, the popover will automatically open. Defaults to `[path]`\n * (or `[<current path>]` if no `path` is provided).\n */\n relevantPaths?: (string | Path)[];\n}\n\n/** Component used to display issues within a popover. */\nexport function IssuesPopover({\n path,\n relevantPaths,\n defaultOpen,\n open: controlledOpen,\n onOpenChange,\n label,\n ...otherProps\n}: IssuesPopoverProps) {\n const [locale] = useLocale();\n label ??= locale.IssuesPopover.label;\n\n const absolutePath = useResolvedPath(path);\n const [open, setOpen] = useControllableState(defaultOpen, controlledOpen);\n const isInControlField = useIsInControlField();\n\n // Open popover when active path matches the popover's path (unneeded when\n // within a control field)\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n if (\n (relevantPaths ?? [absolutePath]).some((path) =>\n focusedPath.equals(new AbsolutePath(path)),\n )\n ) {\n setOpen(true);\n }\n },\n [relevantPaths, absolutePath, setOpen],\n ),\n { enabled: !isInControlField },\n );\n\n return (\n <CurrentPath path={absolutePath}>\n <FeedbackPopover\n open={open}\n onOpenChange={combineEventHandlers(onOpenChange, setOpen)}\n label={label}\n {...otherProps}\n />\n </CurrentPath>\n );\n}\n","import type { DisplayStatus } from \"@ostack.tech/kform\";\nimport type { ControlStatus } from \"@ostack.tech/ui\";\n\n/** Transforms ostack/KForm's display status into ostack/UI's control status. */\nexport function displayStatusToControlStatus(\n displayStatus: DisplayStatus | undefined,\n): ControlStatus | undefined {\n switch (displayStatus) {\n case \"error\":\n return \"invalid\";\n case \"warning\":\n return \"warned\";\n default:\n return undefined;\n }\n}\n\n/** Transforms ostack/KForm's display status into a \"danger\" or \"warning\" colour. */\nexport function displayStatusToColor(\n displayStatus: DisplayStatus | undefined,\n): \"danger\" | \"warning\" | undefined {\n switch (displayStatus) {\n case \"error\":\n return \"danger\";\n case \"warning\":\n return \"warning\";\n default:\n return undefined;\n }\n}\n","/**\n * Whether a given value is [promise-like]{@link PromiseLike}.\n *\n * @param value Value to check if it is promise-like.\n * @returns Whether the provided value is like a promise.\n */\nexport function isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return typeof (value as any)?.then === \"function\";\n}\n","import { createContext, useContext } from \"react\";\n\n/** Value of the top bar context. */\nexport interface TopBarContextValue {\n topBarEl: HTMLElement | null;\n}\n\n/** Context of the top bar component. */\nexport const TopBarContext = createContext<TopBarContextValue | null>(null);\n\n/** Provides access to the top bar element within the context. */\nexport function useTopBarElement() {\n return useContext(TopBarContext)?.topBarEl ?? null;\n}\n","import {\n cx,\n Layer,\n useCombinedRef,\n useMeasure,\n usePrintClassNames,\n} from \"@ostack.tech/ui\";\nimport { type ComponentProps, useCallback, useState } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useSetTopBarHeight } from \"../FormApp\";\nimport { TopBarContext } from \"./TopBarContext.tsx\";\n\n/** Properties of the top bar component. */\nexport interface TopBarProps extends ComponentProps<\"div\"> {}\n\n/** Top bar component. */\nexport function TopBar({ className, ref, ...otherProps }: TopBarProps) {\n const prefix = usePrefix();\n const { printHidden } = usePrintClassNames();\n const setTopBarHeight = useSetTopBarHeight();\n\n const [topBarEl, setTopBarEl] = useState<HTMLDivElement | null>(null);\n useMeasure(\n topBarEl,\n useCallback(\n (measurement) => setTopBarHeight(measurement?.height),\n [setTopBarHeight],\n ),\n );\n\n const combinedTopBarRef = useCombinedRef(setTopBarEl, ref);\n return (\n <TopBarContext.Provider value={{ topBarEl }}>\n <Layer zIndex=\"sticky\">\n <div\n className={cx(prefix(\"top-bar\"), printHidden, className)}\n {...otherProps}\n ref={combinedTopBarRef}\n />\n </Layer>\n </TopBarContext.Provider>\n );\n}\n","import { Actions, type ActionsProps, cx } from \"@ostack.tech/ui\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useIssuesDisplayMode } from \"../FormApp\";\nimport { IssueMessages } from \"../IssueMessages\";\nimport { IssuesPopover } from \"../IssuesPopover\";\n\n/** Properties of the top bar actions component. */\nexport interface TopBarActionsProps extends ActionsProps {}\n\n/** Container of the top bar actions. */\nexport function TopBarActions({\n className,\n containerProps,\n children,\n ...otherProps\n}: TopBarActionsProps) {\n const prefix = usePrefix();\n const issuesDisplayMode = useIssuesDisplayMode();\n\n return (\n <Actions\n className={cx(prefix(\"top-bar__actions\"), className)}\n primaryLayout={{ xs: [\"horizontal\", \"vertical\"], sm: \"horizontal\" }}\n secondaryLayout={{ xs: \"dropdown\", md: [\"vertical\", \"dropdown\"] }}\n containerProps={{\n ...containerProps,\n className: cx(\n prefix(\"top-bar__actions-container\"),\n containerProps?.className,\n ),\n }}\n {...otherProps}\n >\n {/* Global issues */}\n {issuesDisplayMode === \"inline\" && (\n <IssuesPopover>\n <IssueMessages />\n </IssuesPopover>\n )}\n\n {children}\n </Actions>\n );\n}\n","import { ActionsSecondary, type ActionsSecondaryProps } from \"@ostack.tech/ui\";\n\n/** Properties of the top bar secondary actions component. */\nexport interface TopBarActionsSecondaryProps extends ActionsSecondaryProps {}\n\n/** Container of the secondary top bar actions. */\nexport function TopBarActionsSecondary(props: TopBarActionsSecondaryProps) {\n return <ActionsSecondary color=\"success\" {...props} />;\n}\n","import {\n faChevronDown,\n faChevronUp,\n faTrash,\n} from \"@fortawesome/free-solid-svg-icons\";\nimport {\n AbsolutePath,\n AbsolutePathFragment,\n nullableSchemaInnerSchema,\n} from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n FormContext,\n useFormContext,\n useFormManager,\n} from \"@ostack.tech/kform-react\";\nimport {\n Button,\n type ButtonProps,\n combineEventHandlers,\n controlStatusToAccent,\n cx,\n DropdownMenu,\n DropdownMenuContent,\n type DropdownMenuContentProps,\n DropdownMenuGroup,\n DropdownMenuItem,\n type DropdownMenuProps,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n IconButton,\n useAlertDialog,\n useCombinedRef,\n useControllableState,\n useMediaBreakpointUp,\n VisuallyHidden,\n} from \"@ostack.tech/ui\";\nimport {\n type Dispatch,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useStore } from \"zustand\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { isPromiseLike } from \"../../utils/promiseUtils.ts\";\nimport { visiblyFocus } from \"../../utils/useControlAutofocus.ts\";\nimport {\n useFocus,\n useFormIsDisabled,\n useFormIsReadOnly,\n useIssuesDisplayMode,\n useOnPathFocus,\n useResetFocus,\n} from \"../FormApp\";\nimport { useTopBarElement } from \"../TopBar\";\nimport {\n type ResolvedAnnexObject,\n useAnnexesContext,\n useAnnexState,\n} from \"./AnnexesContext.ts\";\nimport type { AnnexesManagerProps } from \"./AnnexesManager.tsx\";\n\n/** Properties of the annexes' menu. */\nexport interface AnnexesMenuProps\n extends\n Pick<\n AnnexesManagerProps,\n | \"menuButtonText\"\n | \"menuButtonLabel\"\n | \"addAnnexText\"\n | \"removeAnnexButtonLabel\"\n | \"removeAnnexKeyboardHint\"\n | \"removeAnnexConfirmDialogTitle\"\n | \"removeAnnexConfirmDialogMessage\"\n | \"removeAnnexConfirmDialogOkText\"\n | \"removeAnnexConfirmDialogCancelText\"\n >,\n DropdownMenuProps {\n menuTriggerProps?: Omit<ButtonProps, \"icon\">;\n menuContentProps?: DropdownMenuContentProps;\n}\n\n/** Component that allows to navigate between, add, and remove annexes. */\nexport function AnnexesMenu({\n menuButtonText,\n menuButtonLabel,\n addAnnexText,\n removeAnnexButtonLabel,\n removeAnnexKeyboardHint,\n removeAnnexConfirmDialogTitle,\n removeAnnexConfirmDialogMessage,\n removeAnnexConfirmDialogOkText,\n removeAnnexConfirmDialogCancelText,\n defaultOpen = false,\n open: controlledOpen,\n onOpenChange,\n menuTriggerProps,\n menuContentProps,\n ...otherProps\n}: AnnexesMenuProps) {\n const prefix = usePrefix();\n const formIsReadOnly = useFormIsReadOnly();\n const store = useAnnexesContext();\n const isLargeScreen = useMediaBreakpointUp(\"sm\");\n const issuesDisplayMode = useIssuesDisplayMode();\n const [open, setOpen] = useControllableState(defaultOpen, controlledOpen);\n const menuTriggerRef = useRef<HTMLButtonElement | null>(null);\n const topBarEl = useTopBarElement();\n\n const activeAnnex = useStore(store, (state) => state.activeAnnex);\n const handleRadioGroupValueChange = useCallback(\n (value: string) =>\n store.getState().actions.setActiveAnnex(new AbsolutePath(value)),\n [store],\n );\n\n const annexes = useStore(store, (state) => state.annexes);\n const addedAnnexPathRef = useRef<AbsolutePath | null>(null);\n const newItems = useMemo(\n () =>\n annexes.map((annex) => (\n <AnnexesMenuNewItem\n key={annex.path.toString()}\n annex={annex}\n addedAnnexPathRef={addedAnnexPathRef}\n />\n )),\n [annexes],\n );\n const tabStates = useStore(\n store,\n useShallow((state) => state.tabStates()),\n );\n\n // Focus menu trigger when focusing an annex that doesn't exist\n const resetFocus = useResetFocus();\n useOnPathFocus(\n useCallback(\n (focusedPath: AbsolutePath) => {\n if (\n issuesDisplayMode === \"panel\" &&\n menuTriggerRef.current &&\n store\n .getState()\n .tablessStates()\n .some((state) => state.path.equals(focusedPath))\n ) {\n visiblyFocus(menuTriggerRef.current);\n resetFocus();\n }\n },\n [issuesDisplayMode, resetFocus, store],\n ),\n );\n\n // Auto-focus newly added annex on close\n const focus = useFocus();\n const handleCloseAutoFocus = useCallback(\n (evt: Event) => {\n if (addedAnnexPathRef.current) {\n evt.preventDefault();\n focus(addedAnnexPathRef.current);\n addedAnnexPathRef.current = null;\n }\n },\n [focus],\n );\n\n const combinedMenuTriggerRef = useCombinedRef(\n menuTriggerRef,\n menuTriggerProps?.ref as never,\n );\n return (\n <DropdownMenu\n open={open}\n onOpenChange={combineEventHandlers(onOpenChange, setOpen)}\n modal={false}\n {...otherProps}\n >\n <DropdownMenuTrigger>\n <Button\n variant=\"ghost\"\n iconPlacement=\"end\"\n aria-label={menuButtonLabel}\n {...menuTriggerProps}\n className={cx(\n prefix(\"annexes__menu-trigger\"),\n menuTriggerProps?.className,\n )}\n icon={open ? faChevronUp : faChevronDown}\n iconProps={{ size: \"2xs\", ...menuTriggerProps?.iconProps }}\n ref={combinedMenuTriggerRef}\n >\n {menuTriggerProps?.children ?? menuButtonText}\n </Button>\n </DropdownMenuTrigger>\n\n <DropdownMenuContent\n variant=\"subtle\"\n showArrow={false}\n sideOffset={-1}\n avoidCollisions={false}\n align=\"start\"\n {...menuContentProps}\n className={cx(prefix(\"annexes__menu\"), menuContentProps?.className)}\n onCloseAutoFocus={combineEventHandlers(\n menuContentProps?.onCloseAutoFocus,\n // eslint-disable-next-line react-hooks/refs\n handleCloseAutoFocus,\n )}\n portalProps={{\n container: topBarEl ?? undefined,\n ...menuContentProps?.portalProps,\n }}\n >\n <DropdownMenuRadioGroup\n value={activeAnnex?.toString()}\n onValueChange={handleRadioGroupValueChange}\n >\n {tabStates.map((state) => (\n <AnnexesMenuItem\n key={state.path.toString()}\n removeAnnexButtonLabel={removeAnnexButtonLabel}\n removeAnnexKeyboardHint={removeAnnexKeyboardHint}\n removeAnnexConfirmDialogTitle={removeAnnexConfirmDialogTitle}\n removeAnnexConfirmDialogMessage={removeAnnexConfirmDialogMessage}\n removeAnnexConfirmDialogOkText={removeAnnexConfirmDialogOkText}\n removeAnnexConfirmDialogCancelText={\n removeAnnexConfirmDialogCancelText\n }\n path={state.path}\n setOpen={setOpen}\n menuRef={menuTriggerRef}\n />\n ))}\n </DropdownMenuRadioGroup>\n {!formIsReadOnly && (\n <DropdownMenuGroup label={isLargeScreen ? undefined : addAnnexText}>\n {isLargeScreen ? (\n <DropdownMenuSub>\n <DropdownMenuSubTrigger\n className={prefix(\"annexes__menu-add-annex\")}\n >\n {addAnnexText}\n </DropdownMenuSubTrigger>\n <DropdownMenuSubContent className={prefix(\"annexes__menu-new\")}>\n {newItems}\n </DropdownMenuSubContent>\n </DropdownMenuSub>\n ) : (\n newItems\n )}\n </DropdownMenuGroup>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\n/** Properties of an item in the annexes' menu. */\ninterface AnnexesMenuItemProps extends Pick<\n AnnexesManagerProps,\n | \"removeAnnexButtonLabel\"\n | \"removeAnnexKeyboardHint\"\n | \"removeAnnexConfirmDialogTitle\"\n | \"removeAnnexConfirmDialogMessage\"\n | \"removeAnnexConfirmDialogOkText\"\n | \"removeAnnexConfirmDialogCancelText\"\n> {\n path: AbsolutePath;\n setOpen: Dispatch<boolean>;\n menuRef: RefObject<HTMLButtonElement | null>;\n}\n\n/** Item in the annexes' menu. */\nfunction AnnexesMenuItem({\n removeAnnexButtonLabel,\n removeAnnexKeyboardHint,\n removeAnnexConfirmDialogTitle,\n removeAnnexConfirmDialogMessage,\n removeAnnexConfirmDialogOkText,\n removeAnnexConfirmDialogCancelText,\n path,\n setOpen,\n menuRef,\n}: AnnexesMenuItemProps) {\n const prefix = usePrefix();\n const store = useAnnexesContext();\n const formContext = useFormContext();\n const formIsDisabled = useFormIsDisabled();\n const formIsReadOnly = useFormIsReadOnly();\n const { confirm } = useAlertDialog();\n\n const deferredDisplayStatus = useAnnexState(\n path,\n (state) => state?.deferredDisplayStatus,\n );\n const isRemovable = useAnnexState(\n path,\n (state) =>\n state != null && (state.schema.typeInfo.nullable || state.isRepetitive),\n );\n const title = useAnnexState(path, (state) => state?.title);\n const subtitle = useAnnexState(path, (state) => state?.subtitle);\n const nonRepetitiveDescription = useAnnexState(\n path,\n (state) => state && !state.isRepetitive && state.description,\n );\n\n const removeAnnex = async () => {\n const { getAnnexState, removeAnnex } = store.getState().actions;\n const state = getAnnexState(path);\n if (!state) {\n return;\n }\n\n if (\n !state.dirty ||\n (await confirm(\n // The form context will typically not be in the scope of the alert\n // dialog, so we need to provide it\n <FormContext.Provider value={{ ...formContext, currentPath: path }}>\n {removeAnnexConfirmDialogMessage?.(\n <strong>\n {state.title}\n {state.subtitle && <> — {state.subtitle}</>}\n </strong>,\n )}\n </FormContext.Provider>,\n {\n title: removeAnnexConfirmDialogTitle,\n color: \"danger\",\n okText: removeAnnexConfirmDialogOkText,\n cancelText: removeAnnexConfirmDialogCancelText,\n triggerElement: menuRef.current,\n },\n ))\n ) {\n void removeAnnex(state.path, state.isRepetitive);\n setOpen(false);\n }\n };\n\n const handleItemKeyDown = (evt: KeyboardEvent) => {\n if (\n isRemovable &&\n !formIsDisabled &&\n !formIsReadOnly &&\n evt.key === \"Delete\"\n ) {\n void removeAnnex();\n }\n };\n const handleRemoveButtonClick = (evt: MouseEvent) => {\n evt.stopPropagation();\n void removeAnnex();\n };\n\n return (\n <DropdownMenuRadioItem\n color=\"primary\"\n data-status={displayStatusToControlStatus(deferredDisplayStatus)}\n data-accent={controlStatusToAccent(\n displayStatusToControlStatus(deferredDisplayStatus),\n )}\n showRadio={false}\n value={path.toString()}\n className={prefix(\"annexes__menu-annex\")}\n actionProps={{\n className: prefix(\"annexes__menu-annex-action\"),\n }}\n contentProps={{\n className: prefix(\"annexes__menu-annex-content\"),\n }}\n onKeyDown={handleItemKeyDown}\n >\n <CurrentPath path={path}>\n <div className={prefix(\"annexes__menu-annex-content-container\")}>\n <div className={prefix(\"annexes__menu-annex-title\")}>\n {title}\n {subtitle && (\n <span className={prefix(\"annexes__menu-annex-subtitle\")}>\n <VisuallyHidden>, </VisuallyHidden>\n {subtitle}\n </span>\n )}\n </div>\n {nonRepetitiveDescription && (\n <div className={prefix(\"annexes__menu-annex-description\")}>\n <VisuallyHidden>, </VisuallyHidden>\n {nonRepetitiveDescription}\n </div>\n )}\n </div>\n {isRemovable && !formIsReadOnly && (\n <>\n {removeAnnexKeyboardHint && (\n <VisuallyHidden>{removeAnnexKeyboardHint}</VisuallyHidden>\n )}\n <IconButton\n className={prefix(\"annexes__menu-annex-remove\")}\n icon={faTrash}\n label={removeAnnexButtonLabel ?? \"\"}\n color=\"danger\"\n circle\n disabled={formIsDisabled}\n onClick={handleRemoveButtonClick}\n tabIndex={-1}\n />\n </>\n )}\n </CurrentPath>\n </DropdownMenuRadioItem>\n );\n}\n\n/** Properties of a new item in the annexes' menu. */\ninterface AnnexManagerNewItemProps extends Pick<\n AnnexesManagerProps,\n \"addAnnexSuccessMessage\"\n> {\n annex: ResolvedAnnexObject;\n addedAnnexPathRef: RefObject<AbsolutePath | null>;\n}\n\n/** New item in the annexes' menu. */\nfunction AnnexesMenuNewItem({\n annex,\n addedAnnexPathRef,\n}: AnnexManagerNewItemProps) {\n const prefix = usePrefix();\n const formIsDisabled = useFormIsDisabled();\n const formManager = useFormManager();\n const store = useAnnexesContext();\n\n const isRepetitive =\n annex.path.lastFragment === AbsolutePathFragment.Wildcard;\n const title = useStore(store, (state) =>\n isRepetitive\n ? (annex.title as ReactNode)\n : state.actions.getAnnexState(annex.path)?.title,\n );\n\n const canBeAdded = useStore(store, (state) => {\n if (isRepetitive) {\n const annexState = state.actions.getRepetitiveAnnexState(\n annex.path.parent(),\n );\n if (!annexState) {\n return false;\n }\n let maxSize = annexState.maxAnnexes;\n // Read max size from the schema restrictions if not defined\n if (maxSize == null) {\n const { restrictions } = annexState.schema.typeInfo;\n if (typeof restrictions.maxSize === \"number\") {\n maxSize = restrictions.maxSize;\n }\n }\n return (\n maxSize == null ||\n (annexState.rowIds != null && annexState.rowIds.length < maxSize)\n );\n } else {\n const annexState = state.actions.getAnnexState(annex.path);\n return annexState?.isNull ?? false;\n }\n });\n\n const [gettingValue, setGettingValue] = useState(false);\n const handleItemSelect = useCallback(async () => {\n const schema = formManager.schema(annex.path);\n const initialValue = schema.typeInfo.nullable\n ? nullableSchemaInnerSchema(schema).initialValue\n : schema.initialValue;\n\n let toAdd = initialValue;\n if (annex.getValue) {\n const clonedValue = await schema.clone(initialValue);\n setGettingValue(true);\n try {\n const getValueResult = annex.getValue(clonedValue);\n toAdd = isPromiseLike(getValueResult)\n ? await getValueResult\n : getValueResult;\n } finally {\n setGettingValue(false);\n }\n }\n\n if (toAdd == null) {\n return;\n }\n\n // Add new annex\n addedAnnexPathRef.current = await store\n .getState()\n .actions.addAnnex(annex.path, toAdd);\n }, [addedAnnexPathRef, annex, formManager, store]);\n\n return (\n <DropdownMenuItem\n color=\"primary\"\n className={prefix(\"annexes__menu-new-annex\")}\n disabled={formIsDisabled || !canBeAdded || gettingValue}\n onSelect={handleItemSelect}\n contentProps={{\n className: prefix(\"annexes__menu-new-annex-content\"),\n }}\n >\n <CurrentPath path={isRepetitive ? annex.path.parent() : annex.path}>\n <div className={prefix(\"annexes__menu-new-annex-title\")}>{title}</div>\n {annex.description && (\n <div className={prefix(\"annexes__menu-new-annex-description\")}>\n <VisuallyHidden>, </VisuallyHidden>\n {annex.description}\n </div>\n )}\n </CurrentPath>\n </DropdownMenuItem>\n );\n}\n","import type { AbsolutePath } from \"@ostack.tech/kform\";\nimport { CurrentPath } from \"@ostack.tech/kform-react\";\nimport { boolDataAttr, Tab, VisuallyHidden } from \"@ostack.tech/ui\";\nimport { useCallback, useId, useRef, useState } from \"react\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { visiblyFocus } from \"../../utils/useControlAutofocus.ts\";\nimport {\n useIssuesDisplayMode,\n useOnPathFocus,\n useResetFocus,\n} from \"../FormApp\";\nimport { IssueMessages } from \"../IssueMessages\";\nimport { IssuesPopover } from \"../IssuesPopover\";\nimport { useAnnexState } from \"./AnnexesContext.ts\";\n\nexport interface AnnexTabProps {\n path: AbsolutePath;\n}\n\nexport function AnnexTab({ path }: AnnexTabProps) {\n const prefix = usePrefix();\n const issuesDisplayMode = useIssuesDisplayMode();\n const deferredIssuesToDisplay = useAnnexState(\n path,\n useShallow((state) => state?.deferredIssuesToDisplay ?? []),\n );\n const hasIssues = deferredIssuesToDisplay.length > 0;\n const deferredDisplayStatus = useAnnexState(\n path,\n (state) => state?.deferredDisplayStatus,\n );\n const title = useAnnexState(path, (state) => state?.title);\n const subtitle = useAnnexState(path, (state) => state?.subtitle);\n\n const tabRef = useRef<HTMLButtonElement | null>(null);\n const resetFocus = useResetFocus();\n useOnPathFocus(\n useCallback(\n (focusedPath: AbsolutePath) => {\n if (tabRef.current && path.equals(focusedPath)) {\n visiblyFocus(tabRef.current);\n // Let the annex be opened before resetting focus\n setTimeout(() => resetFocus());\n }\n },\n [path, resetFocus],\n ),\n );\n\n // Manage issues popover\n const generatedId = useId();\n const issueMessagesId = prefix(`annexes-annex-issue-messages-${generatedId}`);\n const [issuesPopoverOpen, setIssuesPopoverOpen] = useState(false);\n const [tabFocused, setTabFocused] = useState(false);\n const handleTabFocus = useCallback(() => {\n setTabFocused(true);\n }, []);\n const handleTabBlur = useCallback(() => {\n setTabFocused(false);\n }, []);\n const handleIssuesPopoverOpenAutoFocus = useCallback(\n (evt: Event) => {\n if (tabFocused) {\n evt.preventDefault();\n }\n },\n [tabFocused],\n );\n\n return (\n <>\n <Tab\n className={prefix(\"annexes__tab\")}\n value={path.toString()}\n status={displayStatusToControlStatus(deferredDisplayStatus)}\n onFocus={handleTabFocus}\n onBlur={handleTabBlur}\n data-has-issues={boolDataAttr(\n issuesDisplayMode === \"inline\" && hasIssues,\n )}\n tabInnerProps={{ className: prefix(\"annexes__tab-inner\") }}\n tabTextProps={{ className: prefix(\"annexes__tab-text\") }}\n aria-describedby={hasIssues ? issueMessagesId : undefined}\n ref={tabRef}\n >\n <CurrentPath path={path}>\n <span className={prefix(\"annexes__tab-title\")}>{title}</span>\n {subtitle && (\n <span className={prefix(\"annexes__tab-subtitle\")}>\n <VisuallyHidden>, </VisuallyHidden>\n {subtitle}\n </span>\n )}\n </CurrentPath>\n </Tab>\n\n {hasIssues && issuesDisplayMode === \"panel\" && (\n <IssueMessages\n hidden\n id={issueMessagesId}\n path={path}\n issues={deferredIssuesToDisplay}\n />\n )}\n\n {issuesDisplayMode === \"inline\" && (\n <IssuesPopover\n path={path}\n open={hasIssues && (tabFocused || issuesPopoverOpen)}\n onOpenChange={setIssuesPopoverOpen}\n onOpenAutoFocus={handleIssuesPopoverOpenAutoFocus}\n buttonContainerProps={{\n className: prefix(\"annexes__tab-issues-popover-button-container\"),\n }}\n iconButtonProps={{\n className: prefix(\"annexes__tab-issues-popover-button\"),\n tabIndex: -1,\n }}\n >\n <IssueMessages\n id={issueMessagesId}\n issues={deferredIssuesToDisplay}\n />\n </IssuesPopover>\n )}\n </>\n );\n}\n","import {\n cx,\n TabList,\n type TabListProps,\n useMediaBreakpointUp,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport { useStore } from \"zustand\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useAnnexesContext } from \"./AnnexesContext.ts\";\nimport { AnnexTab } from \"./AnnexTab.tsx\";\n\n/** Properties of the annex tab list component. */\nexport interface AnnexTabListProps extends TabListProps {\n hideNonActiveOnSmallScreens: boolean;\n}\n\n/** List of annex tabs. */\nexport function AnnexesTabList({\n hideNonActiveOnSmallScreens,\n rootProps,\n className,\n ...otherProps\n}: AnnexTabListProps) {\n const prefix = usePrefix();\n const store = useAnnexesContext();\n const activeAnnex = useStore(store, (state) => state.activeAnnex);\n const tabStates = useStore(\n store,\n useShallow((state) => state.tabStates()),\n );\n const printing = usePrinting();\n const isLargeScreen = useMediaBreakpointUp(\"sm\");\n\n return (\n <TabList\n className={cx(prefix(\"annexes__tab-list\"), className)}\n rootProps={{\n ...rootProps,\n className: cx(prefix(\"annexes__tab-list-root\"), rootProps?.className),\n }}\n {...otherProps}\n >\n {tabStates.map((state) =>\n printing ||\n !hideNonActiveOnSmallScreens ||\n isLargeScreen ||\n state.path.equals(activeAnnex) ? (\n <AnnexTab key={state.path.toString()} {...state} />\n ) : null,\n )}\n </TabList>\n );\n}\n","import { AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { useFormManager } from \"@ostack.tech/kform-react\";\nimport {\n type ButtonProps,\n combineAriaIds,\n combineEventHandlers,\n cx,\n type DropdownMenuContentProps,\n type DropdownMenuProps,\n FeedbackList,\n type TabListProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type ReactNode,\n useCallback,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useIssuesDisplayMode } from \"../FormApp\";\nimport { IssueMessages } from \"../IssueMessages\";\nimport { IssuesPopover } from \"../IssuesPopover\";\nimport {\n type AnnexState,\n type RepetitiveAnnexState,\n useAnnexesContext,\n} from \"./AnnexesContext.ts\";\nimport { AnnexesMenu } from \"./AnnexesMenu.tsx\";\nimport { AnnexesTabList } from \"./AnnexesTabList.tsx\";\n\n/** Properties of the annexes' manager component. */\nexport interface AnnexesManagerProps extends ComponentProps<\"nav\"> {\n /**\n * Whether to show the annexes manager menu. This defaults to `true` if there\n * is at least one optional or repetitive annex, and `false` otherwise.\n */\n showMenu?: boolean;\n /** Text of the menu button. */\n menuButtonText?: ReactNode;\n /** Accessible label of the menu button. */\n menuButtonLabel?: string;\n /** Text of the \"add annex\" item. */\n addAnnexText?: ReactNode;\n /** Message read to assistive technologies when an annex is successfully added. */\n addAnnexSuccessMessage?: (annexName: ReactNode) => ReactNode;\n /** Label of the remove annex button, announced by assistive technologies. */\n removeAnnexButtonLabel?: string;\n /**\n * Hint on how to remove an annex via keyboard, announced by assistive\n * technologies.\n */\n removeAnnexKeyboardHint?: string;\n /** Title of the \"remove annex\" confirm dialog. */\n removeAnnexConfirmDialogTitle?: ReactNode;\n /**\n * Function that should return the message of the \"remove annex\" confirm\n * dialog, given a node with the name of the annex.\n *\n * @param annexName Node containing the name of the annex.\n */\n removeAnnexConfirmDialogMessage?: (annexName: ReactNode) => ReactNode;\n /** Text of the \"remove annex\" confirm dialog OK button. */\n removeAnnexConfirmDialogOkText?: ReactNode;\n /** Text of the \"remove annex\" confirm dialog cancel button. */\n removeAnnexConfirmDialogCancelText?: ReactNode;\n /** Properties to pass to the menu container element. */\n menuContainerProps?: ComponentProps<\"div\">;\n /** Properties to pass to the menu trigger component. */\n menuTriggerProps?: Omit<ButtonProps, \"icon\">;\n /** Properties to pass to the menu content component. */\n menuContentProps?: DropdownMenuContentProps;\n /** Properties to pass to the menu component. */\n menuProps?: DropdownMenuProps;\n /** Properties to pass to the tab-list container element. */\n tabListContainerProps?: ComponentProps<\"div\">;\n /** Properties to pass to the tab-list component. */\n tabListProps?: TabListProps;\n}\n\n/**\n * Component used to manage the form's annexes. Provides a menu that allows\n * changing, adding, and removing annexes, as well as a list of tabs for each\n * existing annex.\n */\nexport function AnnexesManager({\n showMenu,\n menuButtonText,\n menuButtonLabel,\n addAnnexText,\n removeAnnexButtonLabel,\n removeAnnexKeyboardHint,\n removeAnnexConfirmDialogTitle,\n removeAnnexConfirmDialogMessage,\n removeAnnexConfirmDialogOkText,\n removeAnnexConfirmDialogCancelText,\n className,\n \"aria-label\": ariaLabel,\n menuContainerProps,\n menuTriggerProps,\n menuContentProps,\n menuProps,\n tabListContainerProps,\n tabListProps,\n ref,\n ...otherProps\n}: AnnexesManagerProps) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n ariaLabel ??= locale.AnnexesManager[\"aria-label\"];\n menuButtonText ??= locale.AnnexesManager.menuButtonText;\n menuButtonLabel ??= locale.AnnexesManager.menuButtonLabel;\n addAnnexText ??= locale.AnnexesManager.addAnnexText;\n removeAnnexButtonLabel ??= locale.AnnexesManager.removeAnnexButtonLabel;\n removeAnnexKeyboardHint ??= locale.AnnexesManager.removeAnnexKeyboardHint;\n removeAnnexConfirmDialogTitle ??=\n locale.AnnexesManager.removeAnnexConfirmDialogTitle;\n removeAnnexConfirmDialogMessage ??=\n locale.AnnexesManager.removeAnnexConfirmDialogMessage;\n removeAnnexConfirmDialogOkText ??=\n locale.AnnexesManager.removeAnnexConfirmDialogOkText;\n removeAnnexConfirmDialogCancelText ??=\n locale.AnnexesManager.removeAnnexConfirmDialogCancelText;\n\n const managerRef = useRef<HTMLElement | null>(null);\n const store = useAnnexesContext();\n const issuesDisplayMode = useIssuesDisplayMode();\n const tablessStates: (AnnexState | RepetitiveAnnexState)[] = useStore(\n store,\n (state) => state.tablessStates(),\n );\n const tablessPaths = useMemo(\n () => tablessStates.map((state) => state.path),\n [tablessStates],\n );\n const deferredTablessIssuesToDisplay = useMemo(\n () => tablessStates.map((state) => state.deferredIssuesToDisplay || []),\n [tablessStates],\n );\n const hasIssues = useMemo(\n () => deferredTablessIssuesToDisplay.some((issues) => issues.length > 0),\n [deferredTablessIssuesToDisplay],\n );\n const hasErrors = useMemo(\n () =>\n deferredTablessIssuesToDisplay.some((issues) =>\n issues.some((issue) => issue.severity === \"error\"),\n ),\n [deferredTablessIssuesToDisplay],\n );\n const formManager = useFormManager();\n const shouldShowMenu = useStore(\n store,\n (state) =>\n showMenu ??\n state.annexes.some(\n (annex) =>\n annex.path.lastFragment === AbsolutePathFragment.Wildcard ||\n formManager.schema(annex.path).typeInfo.nullable,\n ),\n );\n\n // Ensure that the `<nav>` aria-owns the content of the dropdown menu, so that\n // a SR user doesn't \"exit navigation\" when navigating to it\n const generatedId = useId();\n const menuContentId =\n menuContentProps?.id ?? prefix(`annexes-menu-content-${generatedId}`);\n const handleAnnexesMenuOpenChange = useCallback(\n (open: boolean) => {\n const managerEl = managerRef.current;\n if (managerEl) {\n const oldAriaOwns =\n managerEl.getAttribute(\"aria-owns\")?.split(\" \") ?? [];\n let newAriaOwns: string[];\n if (open) {\n newAriaOwns = [...oldAriaOwns, menuContentId];\n } else {\n newAriaOwns = oldAriaOwns.filter((id) => id !== menuContentId);\n }\n if (newAriaOwns.length > 0) {\n managerEl.setAttribute(\"aria-owns\", newAriaOwns.join(\" \"));\n } else {\n managerEl.removeAttribute(\"aria-owns\");\n }\n }\n },\n [menuContentId],\n );\n\n // Manage issues popover\n const issueMessagesId = prefix(`annexes-issue-messages-${generatedId}`);\n const [issuesPopoverOpen, setIssuesPopoverOpen] = useState(false);\n const [menuTriggerFocused, setMenuTriggerFocused] = useState(false);\n const handleMenuTriggerFocus = useCallback(() => {\n setMenuTriggerFocused(true);\n }, []);\n const handleMenuTriggerBlur = useCallback(() => {\n setMenuTriggerFocused(false);\n }, []);\n const handleIssuesPopoverOpenAutoFocus = useCallback(\n (evt: Event) => {\n if (menuTriggerFocused) {\n evt.preventDefault();\n }\n },\n [menuTriggerFocused],\n );\n\n const feedbackList = (\n <FeedbackList id={issueMessagesId} hidden={issuesDisplayMode === \"panel\"}>\n {tablessStates.map((state, i) => (\n <IssueMessages\n key={state.path.toString()}\n path={state.path}\n issues={deferredTablessIssuesToDisplay[i] ?? []}\n unwrapped\n />\n ))}\n </FeedbackList>\n );\n\n const combinedManagerRef = useCombinedRef(managerRef, ref);\n return (\n <nav\n className={cx(prefix(\"annexes__manager\"), className)}\n aria-label={ariaLabel}\n {...otherProps}\n ref={combinedManagerRef}\n >\n {shouldShowMenu && (\n <div\n {...menuContainerProps}\n className={cx(\n prefix(\"annexes__menu-container\"),\n menuContainerProps?.className,\n )}\n >\n <AnnexesMenu\n menuButtonText={menuButtonText}\n menuButtonLabel={menuButtonLabel}\n addAnnexText={addAnnexText}\n removeAnnexButtonLabel={removeAnnexButtonLabel}\n removeAnnexKeyboardHint={removeAnnexKeyboardHint}\n removeAnnexConfirmDialogTitle={removeAnnexConfirmDialogTitle}\n removeAnnexConfirmDialogMessage={removeAnnexConfirmDialogMessage}\n removeAnnexConfirmDialogOkText={removeAnnexConfirmDialogOkText}\n removeAnnexConfirmDialogCancelText={\n removeAnnexConfirmDialogCancelText\n }\n {...menuProps}\n onOpenChange={combineEventHandlers(\n menuProps?.onOpenChange,\n // eslint-disable-next-line react-hooks/refs\n handleAnnexesMenuOpenChange,\n )}\n menuTriggerProps={{\n \"aria-invalid\": hasErrors || undefined,\n ...menuTriggerProps,\n \"aria-describedby\": combineAriaIds(\n menuTriggerProps?.[\"aria-describedby\"],\n issueMessagesId,\n ),\n onFocus: combineEventHandlers(\n menuTriggerProps?.onFocus,\n handleMenuTriggerFocus,\n ),\n onBlur: combineEventHandlers(\n menuTriggerProps?.onBlur,\n handleMenuTriggerBlur,\n ),\n }}\n menuContentProps={{ ...menuContentProps, id: menuContentId }}\n />\n </div>\n )}\n\n {shouldShowMenu &&\n issuesDisplayMode === \"panel\" &&\n hasIssues &&\n feedbackList}\n\n {shouldShowMenu && issuesDisplayMode === \"inline\" && (\n <IssuesPopover\n open={hasIssues && (menuTriggerFocused || issuesPopoverOpen)}\n onOpenChange={setIssuesPopoverOpen}\n onOpenAutoFocus={handleIssuesPopoverOpenAutoFocus}\n buttonContainerProps={{\n className: prefix(\"annexes__issues-popover-container\"),\n }}\n iconButtonProps={{ tabIndex: -1 }}\n relevantPaths={tablessPaths}\n >\n {feedbackList}\n </IssuesPopover>\n )}\n\n <div\n {...tabListContainerProps}\n className={cx(\n prefix(\"annexes__tab-list-container\"),\n tabListContainerProps?.className,\n )}\n >\n <AnnexesTabList\n hideNonActiveOnSmallScreens={shouldShowMenu}\n {...tabListProps}\n />\n </div>\n </nav>\n );\n}\n","import type { SealedValidationIssue } from \"@ostack.tech/kform\";\nimport {\n type ControlVariant,\n FeedbackList,\n useIsInTableCell,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { useIssuesDisplayMode } from \"../components/FormApp\";\nimport {\n IssueMessages,\n type IssueMessagesByCode,\n type IssueMessagesProps,\n} from \"../components/IssueMessages\";\nimport { IssuesPopover } from \"../components/IssuesPopover\";\n\n/** Options of the `useControlIssues` hook. */\nexport interface UseControlIssuesOptions {\n /** Mapping from path to issues to display. */\n issuesToDisplay: Record<string, SealedValidationIssue[]>;\n /** Mapping from path to issue messages by code. */\n issueMessages?: Record<string, IssueMessagesByCode | undefined>;\n /** Whether issues should be displayed. */\n displayIssues?: boolean;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n /** Variant of the control. */\n variant?: ControlVariant;\n}\n\n/** Result of the `useControlIssues` hook. */\nexport interface UseControlIssuesResult {\n /**\n * Node that should be rendered when the issues are to appear inline. This\n * will be `null` if the issues should not appear inline.\n */\n inlineIssues: ReactNode;\n /**\n * Node that should be rendered when the issues are to appear within a\n * popover. This will be `null` if the issues should not appear in a popover.\n */\n popoverIssues: ReactNode;\n}\n\n/** Hook which helps a control component render its issues. */\nexport function useControlIssues({\n issuesToDisplay,\n issueMessages,\n displayIssues = true,\n issueMessagesProps,\n variant,\n}: UseControlIssuesOptions): UseControlIssuesResult {\n const issuesDisplayMode = useIssuesDisplayMode();\n const isInTableCell = useIsInTableCell();\n const showInPopover =\n variant === \"cell\" || (variant === undefined && isInTableCell);\n\n const {\n displayIssueCodes,\n unknownErrorMessage,\n unknownWarningMessage,\n ...feedbackListProps\n } = issueMessagesProps ?? {};\n const issuesNode = displayIssues && (\n <FeedbackList {...feedbackListProps} hidden={issuesDisplayMode === \"panel\"}>\n {Object.entries(issuesToDisplay).map(([path, issues], i) => (\n <IssueMessages\n key={i}\n path={path}\n issues={issues}\n messages={issueMessages?.[path]}\n displayIssueCodes={displayIssueCodes}\n unknownErrorMessage={unknownErrorMessage}\n unknownWarningMessage={unknownWarningMessage}\n unwrapped\n />\n ))}\n </FeedbackList>\n );\n if (issuesDisplayMode === \"panel\") {\n return { inlineIssues: issuesNode, popoverIssues: null };\n }\n return {\n inlineIssues: showInPopover ? null : issuesNode,\n popoverIssues: showInPopover ? (\n <IssuesPopover>{issuesNode}</IssuesPopover>\n ) : null,\n };\n}\n","import type {\n AbsolutePath,\n DisplayStatus,\n SealedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport type { Controller } from \"@ostack.tech/kform-react\";\nimport {\n useDataTableColumnLabel,\n useOnLabelChange,\n usePrinting,\n useStartPrintingTask,\n} from \"@ostack.tech/ui\";\nimport {\n type FocusEvent,\n type ReactNode,\n type Ref,\n type RefObject,\n useCallback,\n useDeferredValue,\n useEffect,\n useImperativeHandle,\n useMemo,\n} from \"react\";\nimport { shallow } from \"zustand/shallow\";\n\nimport { useRegisterControllerWithinControlField } from \"../components/ControlField\";\nimport {\n useFormIsDisabled,\n useFormIsReadOnly,\n useRegisterController,\n useRegisterLabel,\n} from \"../components/FormApp\";\nimport {\n useFormAppContext,\n useSetLatestInteraction,\n} from \"../components/FormApp/FormAppContext.ts\";\nimport { useControlAutofocus } from \"./useControlAutofocus.ts\";\n\n/** Options when registering the control. */\nexport interface UseRegisterControlOptions<T> {\n controller: Controller<T>;\n issuesPanelLabel?: ReactNode;\n ariaLabel?: string;\n issuesPanelLabelSuffix?: ReactNode;\n preventAutoFocus?: boolean;\n apiRef?: Ref<Controller<T> | undefined>;\n}\n\n/** Result of registering the control. */\nexport interface UseRegisterControlResult<TElem> {\n displayLoading: boolean;\n displayDisabled: boolean;\n displayReadOnly: boolean;\n displayStatusToDisplay: DisplayStatus | undefined;\n displayValidating: boolean;\n issuesToDisplay: SealedValidationIssue[];\n autofocusRef: RefObject<TElem | null>;\n handleFocus: (event: FocusEvent) => void;\n}\n\n/** Hook used to register a control within the form app. */\nexport function useRegisterControl<T, TElem extends HTMLElement = HTMLElement>({\n controller,\n issuesPanelLabel,\n ariaLabel,\n issuesPanelLabelSuffix,\n preventAutoFocus,\n apiRef,\n}: UseRegisterControlOptions<T>): UseRegisterControlResult<TElem> {\n const printing = usePrinting();\n const { useState, usePath, useInitialized, useDisplayStatus } = controller;\n const path = usePath();\n const formIsDisabled = useFormIsDisabled();\n const displayReadOnly = useFormIsReadOnly();\n const initialized = useInitialized();\n const displayStatusToDisplay = useDeferredValue(useDisplayStatus());\n const displayValidating = useDeferredValue(\n useState((state) => state.validationStatus === \"validating\"),\n );\n const issuesToDisplay = useDeferredValue(\n useState((state) => (state.touched ? state.issues : []), {\n equalityFn: shallow,\n }),\n );\n\n // Start a printing task until the control is initialised\n const finishPrintingTask = useStartPrintingTask();\n useEffect(() => {\n if (initialized) {\n finishPrintingTask();\n }\n }, [finishPrintingTask, initialized]);\n\n // Register the issues panel label\n const columnLabel = useDataTableColumnLabel();\n useRegisterLabel(\n path,\n issuesPanelLabel || columnLabel || ariaLabel,\n issuesPanelLabel ? 1 : -1,\n );\n useRegisterFieldLabel(path, issuesPanelLabelSuffix);\n\n // Register the controller within its control field\n useRegisterControllerWithinControlField(controller, issuesToDisplay);\n\n // Register the controller in the form app\n useRegisterController(controller);\n\n // Expose the control's API via `apiRef`\n useImperativeHandle(apiRef, () => controller, [controller]);\n\n // Autofocus control when the active path changes\n const autofocusRef = useControlAutofocus<T, TElem>(\n controller,\n !preventAutoFocus && !printing,\n );\n\n // Handle control focus\n const setLatestInteraction = useSetLatestInteraction();\n const handleFocus = useCallback(\n (event: FocusEvent) => {\n if (\n !printing &&\n event.target === event.currentTarget &&\n !event.defaultPrevented\n ) {\n setLatestInteraction(controller.getState().path);\n }\n },\n [controller, printing, setLatestInteraction],\n );\n\n return useMemo(\n () => ({\n displayLoading: printing ? false : !initialized,\n displayDisabled: printing ? false : formIsDisabled,\n displayReadOnly: printing ? false : displayReadOnly,\n displayStatusToDisplay: printing ? undefined : displayStatusToDisplay,\n displayValidating: printing ? false : displayValidating,\n issuesToDisplay: printing ? [] : issuesToDisplay,\n autofocusRef,\n handleFocus,\n }),\n [\n printing,\n initialized,\n formIsDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n ],\n );\n}\n\n/** Hook used to register a label for all control field's controls. */\nfunction useRegisterFieldLabel(\n path: AbsolutePath,\n issuesPanelLabelSuffix?: ReactNode,\n) {\n const { store: formAppStore } = useFormAppContext();\n useOnLabelChange(\n useCallback(\n (label) =>\n formAppStore.getState().actions.registerLabel(\n path,\n label && issuesPanelLabelSuffix ? (\n <>\n {label}\n {issuesPanelLabelSuffix}\n </>\n ) : (\n label\n ),\n ),\n [formAppStore, issuesPanelLabelSuffix, path],\n ),\n );\n}\n","import { faBug } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n AbsolutePathFragment,\n isKtList,\n isTable,\n Path,\n tableRowsToArray,\n} from \"@ostack.tech/kform\";\nimport {\n FormattedValue,\n type FormatterControllerState,\n} from \"@ostack.tech/kform-react\";\nimport {\n Code,\n DescriptionList,\n DescriptionListItem,\n IconButton,\n type IconButtonProps,\n Popover,\n PopoverContent,\n PopoverTrigger,\n Spinner,\n useCssVars,\n usePrinting,\n useSpacing,\n} from \"@ostack.tech/ui\";\nimport { Fragment, type ReactElement, type ReactNode } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToColor } from \"../../utils/displayStatusConversions.ts\";\n\n/** Properties of the debug info component. */\nexport interface DebugInfoProps<\n T = unknown,\n TFormatted extends ReactNode = string,\n> extends Partial<IconButtonProps> {\n defaultOpen?: boolean;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** Path of the value to debug. */\n path?: string | Path;\n /**\n * Format function that transforms the form manager value to debug into a\n * value to be output. The passed {@link value} is `undefined` when the form\n * manager value does not exist.\n *\n * @param value Form manager value to transform.\n * @param state Controller's state.\n * @returns Transformed value.\n */\n format?: (\n value: T | undefined,\n state: FormatterControllerState<T, TFormatted>,\n ) => TFormatted;\n /** Trigger used to toggle the debug info popover. */\n children?: ReactElement;\n}\n\n/** Debug information. */\nexport function DebugInfo<T = unknown, TFormatted extends ReactNode = string>({\n defaultOpen,\n open,\n onOpenChange,\n path = Path.CURRENT_DEEP,\n format = defaultFormat as never,\n children,\n label,\n ...otherProps\n}: DebugInfoProps<T, TFormatted>) {\n const [locale] = useLocale();\n label ??= locale.DebugInfo?.label;\n\n const spacing = useSpacing();\n const { cssVar } = useCssVars();\n const printing = usePrinting();\n\n const empty = <span style={{ color: cssVar(\"neutral-a9\") }}>—</span>;\n\n if (printing) {\n return null;\n }\n return (\n <Popover defaultOpen={defaultOpen} open={open} onOpenChange={onOpenChange}>\n <PopoverTrigger>\n {children ?? (\n <IconButton\n icon={faBug}\n color=\"danger\"\n variant=\"ghost\"\n label={label}\n {...otherProps}\n />\n )}\n </PopoverTrigger>\n\n <PopoverContent style={{ width: 550 }}>\n <FormattedValue<T, TFormatted> path={path} format={format}>\n {({\n schema,\n path,\n observingDescendants,\n initialized,\n formattedValue,\n dirty,\n touched,\n issues,\n validationStatus,\n displayStatus,\n }) =>\n initialized ? (\n <DescriptionList gap={3} style={{ margin: spacing(-1, 1, 3) }}>\n <DescriptionListItem xs={6} term=\"Path\">\n <Code>\n {(observingDescendants\n ? path.append(AbsolutePathFragment.RecursiveWildcard)\n : path\n ).toString()}\n </Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Schema type\">\n <Code>{schema.typeInfo.toString()}</Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Validations\">\n {schema.validations.length > 0\n ? schema.validations.map((validation, i) => (\n <Fragment key={i}>\n {i !== 0 && \", \"}\n <Code>{validation.toString()}</Code>\n </Fragment>\n ))\n : empty}\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Value\">\n <Code>{formattedValue}</Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Dirty\">\n <Code>{JSON.stringify(dirty)}</Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Touched\">\n <Code>{JSON.stringify(touched)}</Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Issues\">\n {issues && issues.length > 0\n ? issues.map((issue, i) => (\n <Fragment key={i}>\n {i !== 0 && \", \"}\n <Code\n color={\n issue.severity === \"error\" ? \"danger\" : \"warning\"\n }\n >\n {issue.code}\n </Code>\n </Fragment>\n ))\n : empty}\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Validation status\">\n <Code>{validationStatus}</Code>\n </DescriptionListItem>\n\n <DescriptionListItem xs={6} term=\"Display status\">\n <Code color={displayStatusToColor(displayStatus)}>\n {displayStatus}\n </Code>\n </DescriptionListItem>\n </DescriptionList>\n ) : (\n <Spinner />\n )\n }\n </FormattedValue>\n </PopoverContent>\n </Popover>\n );\n}\n\n/** Default format function. */\nfunction defaultFormat(value: unknown): string {\n if (value === undefined) {\n return \"undefined\";\n }\n if (value === null) {\n return \"null\";\n }\n if (typeof value === \"string\") {\n return JSON.stringify(value);\n }\n if (isKtList(value)) {\n return `[${value.asJsReadonlyArrayView().map(defaultFormat).join(\", \")}]`;\n }\n if (isTable(value)) {\n return `[${tableRowsToArray(value)\n .map(([id, v]) => `${id}=${defaultFormat(v)}`)\n .join(\", \")}]`;\n }\n if (\n typeof value === \"object\" &&\n [null, Object.prototype].includes(Object.getPrototypeOf(value))\n ) {\n return `{${Object.entries(value)\n .map(([k, v]) => `${k}: ${defaultFormat(v)}`)\n .join(\", \")}}`;\n }\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n return String(value);\n}\n","import { faBug } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n ControlAddon,\n type ControlAddonProps,\n Icon,\n Tooltip,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\n\n/** Properties of the debug info control addon trigger component. */\nexport interface DebugInfoControlAddonTriggerProps extends Partial<\n ControlAddonProps<\"button\">\n> {\n /** Label of the button used to trigger the debug information. */\n label?: ReactNode;\n}\n\n/** Debug info trigger as a control addon. */\nexport function DebugInfoControlAddonTrigger({\n label,\n ...otherProps\n}: DebugInfoControlAddonTriggerProps) {\n const [locale] = useLocale();\n label ??= locale.DebugInfo?.label;\n\n return (\n <Tooltip content={label}>\n <ControlAddon as=\"button\" {...otherProps} aria-describedby={undefined}>\n <Icon icon={faBug} label={label} color=\"danger\" />\n </ControlAddon>\n </Tooltip>\n );\n}\n","import { createContext, useContext } from \"react\";\n\nimport type { UseResetOnChangeResult } from \"./useResetOnChange.tsx\";\n\n/** Value of the reset on change context. */\nexport type ResetOnChangeContextValue = UseResetOnChangeResult;\n\n/** Reset on change context. */\nexport const ResetOnChangeContext = createContext<\n ResetOnChangeContextValue | undefined\n>(undefined);\n\n/** Function providing access to the reset on change context value. */\nexport function useResetOnChangeContext():\n ResetOnChangeContextValue | undefined {\n return useContext(ResetOnChangeContext);\n}\n","import type { ConfirmDialogOptions } from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\n/** Confirm dialog options with a prefix. */\nexport type PrefixedConfirmDialogOptions<\n TPrefix extends string = \"confirmDialog\",\n> = {\n [\n K in keyof ConfirmDialogOptions as `${TPrefix}${Capitalize<string & K>}`\n ]: ConfirmDialogOptions[K];\n} & Partial<Record<`${TPrefix}Message`, ReactNode>>;\n\n/** Result of the {@link extractConfirmDialogOptions} function. */\nexport type ExtractConfirmDialogOptionsResult<\n TOptions extends PrefixedConfirmDialogOptions<TPrefix>,\n TPrefix extends string = \"confirmDialog\",\n TNewPrefix extends string = \"\",\n> = [\n TNewPrefix extends \"\"\n ? ConfirmDialogOptions\n : PrefixedConfirmDialogOptions<TNewPrefix>,\n Omit<TOptions, keyof PrefixedConfirmDialogOptions<TPrefix>>,\n];\n\n/** Function used to extract confirm dialog options with a given prefix. */\nexport function extractConfirmDialogOptions<\n TOptions extends PrefixedConfirmDialogOptions<TPrefix>,\n TPrefix extends string = \"confirmDialog\",\n TNewPrefix extends string = \"\",\n>(\n options: TOptions,\n prefix: TPrefix = \"confirmDialog\" as never,\n newPrefix: TNewPrefix = \"\" as never,\n): ExtractConfirmDialogOptionsResult<TOptions, TPrefix, TNewPrefix> {\n const confirmDialogOptions: Record<string, any> = {};\n const otherOptions: Record<string, any> = {};\n for (const k in options) {\n const v = options[k];\n if (k.startsWith(prefix)) {\n const unprefixed = k.slice(prefix.length);\n const opt = newPrefix\n ? newPrefix + unprefixed\n : unprefixed.charAt(0).toLowerCase() + unprefixed.slice(1);\n confirmDialogOptions[opt] = v;\n } else {\n otherOptions[k] = v;\n }\n }\n return [\n confirmDialogOptions,\n otherOptions,\n ] as ExtractConfirmDialogOptionsResult<TOptions, TPrefix, TNewPrefix>;\n}\n","import {\n type AbsolutePath,\n type FormManager,\n type Path,\n type SealedValueEvent,\n ValueEvent,\n} from \"@ostack.tech/kform\";\nimport { useCurrentPath, useFormManager } from \"@ostack.tech/kform-react\";\nimport { useAlertDialog } from \"@ostack.tech/ui\";\nimport { useMemo, useRef } from \"react\";\n\nimport {\n extractConfirmDialogOptions,\n type PrefixedConfirmDialogOptions,\n} from \"../../utils/extractConfirmDialogOptions.ts\";\n\n// eslint-disable-next-line react-refresh/only-export-components\nconst ALWAYS_RESET = () => true;\n\n/** Options of the `useResetOnChange` hook. */\nexport interface UseResetOnChangeOptions<\n T = unknown,\n> extends PrefixedConfirmDialogOptions {\n /**\n * Function which determines whether to reset the fields when the value\n * changes. By default, fields are reset whenever the value changes.\n *\n * @param event Value event.\n */\n when?: (event: SealedValueEvent<T>) => boolean;\n /**\n * Fields in `toReset` that should be excluded from being reset (relative to\n * the current path). This is useful when using wildcards in `toReset` and you\n * want to exclude some of the fields that match the wildcard.\n *\n * E.g. `{ toReset: [\"/a/*\"], excludeFromReset: [\"/a/b\"] }` will reset all\n * children of `/a` except `/a/b`.\n */\n exclude?: string | Path | (string | Path)[];\n /**\n * Whether to show a confirmation message before performing the reset.\n *\n * If the confirmation is cancelled, the event which caused the reset in the\n * first place is undone.\n *\n * This property is `false` by default, but is automatically set to `true` if\n * a `confirmDialogMessage` is provided.\n */\n showConfirmation?: boolean;\n /**\n * Whether to set the fields as untouched when resetting.\n *\n * @default true\n */\n setUntouched?: boolean;\n /**\n * Whether to set the fields as pristine when resetting.\n *\n * @default true\n */\n setPristine?: boolean;\n /** Function used to undo the change when the user cancels the confirmation. */\n undo?: (\n formManager: FormManager,\n event: SealedValueEvent<T>,\n ) => PromiseLike<void>;\n}\n\n/** Event handler returned by the `useResetOnChange` hook. */\nexport type UseResetOnChangeResult = (event: SealedValueEvent<any>) => void;\n\n/**\n * Hook which returns an `onValueChange` event handler which resets the fields\n * at the provided `reset` path(s) to their initial value when a value changes\n * (according to the `when` function).\n *\n * Optionally requests user-confirmation via alert dialog if `showConfirmation`\n * is provided.\n *\n * When using wildcards in `reset`, certain fields may be excluded via\n * `exclude`.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * CheckboxControl,\n * useResetOnChange,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function NoTransactionsControl() {\n * const handleOnChange = useResetOnChange(\"/transactions\", {\n * when: ({ value }) => Boolean(value),\n * confirmDialogTitle: \"Confirm no transactions\",\n * confirmDialogMessage: (\n * <>\n * By checking this box, the “Itemised transactions” table will be\n * cleared. Are you sure you want to continue?\n * </>\n * ),\n * confirmDialogOkText: \"Confirm\",\n * });\n *\n * return (\n * <CheckboxControl\n * path=\"/noTransactions\"\n * onValueChange={handleOnChange}\n * >\n * I declare that no taxable transactions were performed during this\n * filing period.\n * </CheckboxControl>\n * );\n * }\n * ```\n *\n * @param reset Path(s) to reset when the value changes (relative to the current\n * path). Wildcards in paths (`*` or `**`) are supported.\n * @param options Hook options. See {@link UseResetOnChangeOptions}.\n */\nexport function useResetOnChange<T = unknown>(\n reset: string | Path | (string | Path)[],\n {\n when = ALWAYS_RESET,\n exclude,\n confirmDialogMessage,\n showConfirmation = Boolean(confirmDialogMessage),\n setUntouched = true,\n setPristine = true,\n undo = undoValueChange,\n ...confirmDialogOptions\n }: UseResetOnChangeOptions<T> = {},\n): UseResetOnChangeResult {\n const [unprefixedConfirmDialogOptions] =\n extractConfirmDialogOptions(confirmDialogOptions);\n const { confirm } = useAlertDialog();\n const formManager = useFormManager();\n const currentPath = useCurrentPath();\n const undoing = useRef(false);\n\n // Resolved paths in `reset`, excluding those in `exclude`\n const toReset = useMemo(() => {\n let resolvedReset = (Array.isArray(reset) ? reset : [reset]).map((path) =>\n currentPath.resolve(path),\n );\n if (exclude) {\n const resolvedExclude = (\n Array.isArray(exclude) ? exclude : [exclude]\n ).map((path) => currentPath.resolve(path));\n resolvedReset = excludePaths(formManager, resolvedReset, resolvedExclude);\n }\n return resolvedReset;\n }, [currentPath, exclude, formManager, reset]);\n\n // The event listener mustn't be blocked by the operations performed, so we\n // separate the handler into two functions\n const handleValueChange = async (event: SealedValueEvent<T>) => {\n if (!undoing.current && when(event)) {\n if (showConfirmation) {\n if (\n (await someIsDirty(formManager, toReset)) &&\n !(await confirm(confirmDialogMessage, {\n color: \"warning\",\n ...unprefixedConfirmDialogOptions,\n }))\n ) {\n undoing.current = true;\n void Promise.resolve(undo(formManager, event)).finally(\n () => (undoing.current = false),\n );\n return;\n }\n }\n\n await resetAll(formManager, toReset, setUntouched, setPristine);\n }\n };\n return (event: SealedValueEvent<T>) => void handleValueChange(event);\n}\n\n/** `undoChange` implementation which sets the old value onto the storage. */\nfunction undoValueChange<T>(\n formManager: FormManager,\n event: SealedValueEvent<T>,\n) {\n if (!(event instanceof ValueEvent.Change)) {\n throw new Error(\n \"Unable to undo change. Please provide a custom `undo` function.\",\n );\n }\n return formManager.set(event.path, event.oldValue);\n}\n\n/**\n * Returns an \"expanded\" (without wildcards) list of all paths in `path` that\n * **do not** match those in `toExclude`.\n */\nfunction excludePaths(\n formManager: FormManager,\n paths: (string | Path)[],\n exclude: (string | Path)[],\n): AbsolutePath[] {\n return paths\n .flatMap((path) =>\n Array.from(formManager.schemaInfo(path)).map((info) => info.path),\n )\n .filter((path) => !exclude.some((toIgnore) => path.matches(toIgnore)));\n}\n\n/**\n * Returns a promise that resolves with whether at least one of the provided\n * paths is dirty.\n */\nasync function someIsDirty(\n formManager: FormManager,\n paths: (string | Path)[],\n): Promise<boolean> {\n const dirtyStatuses = await Promise.all(\n paths.map((path) => formManager.isDirty(path)),\n );\n return dirtyStatuses.some((isDirty) => isDirty);\n}\n\n/**\n * Resets all the provided paths by calling `reset`, `setPristine` and\n * `setUntouched` on them.\n */\nasync function resetAll(\n formManager: FormManager,\n toReset: (string | Path)[],\n setPristine: boolean,\n setUntouched: boolean,\n): Promise<void> {\n await Promise.all(\n // eslint-disable-next-line @typescript-eslint/await-thenable\n toReset.flatMap((path) => [\n formManager.reset(path),\n setPristine && formManager.setPristine(path),\n setUntouched && formManager.setUntouched(path),\n ]),\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport type { ReactNode } from \"react\";\n\nimport { ResetOnChangeContext } from \"./ResetOnChangeContext.ts\";\nimport {\n useResetOnChange,\n type UseResetOnChangeOptions,\n} from \"./useResetOnChange.tsx\";\n\n/** Properties of the reset on change component. */\nexport interface ResetOnChangeProps extends UseResetOnChangeOptions {\n /** Paths to reset. */\n reset: string | Path | (string | Path)[];\n children?: ReactNode;\n}\n\n/**\n * Component used to reset path(s) to their initial value when the value of\n * controls within it change (according to the `when` function). Built on top of\n * the `useResetOnChange` hook.\n *\n * Optionally requests user-confirmation via alert dialog if `showConfirmation`\n * is provided.\n *\n * When using wildcards in `reset`, certain fields may be excluded via\n * `exclude`.\n *\n * Example usage:\n *\n * ```tsx\n * import { CheckboxControl, ResetOnChange } from \"@ostack.tech/ui-kform\";\n *\n * function SameAddressControl() {\n * return (\n * <ResetOnChange\n * reset=\"/mailingAddress\"\n * when={({ value }) => Boolean(value)}\n * >\n * <CheckboxControl path=\"/sameAddress\">\n * Same as residential address\n * </CheckboxControl>\n * </ResetOnChange>\n * );\n * }\n * ```\n */\nexport function ResetOnChange({\n reset,\n children,\n ...otherProps\n}: ResetOnChangeProps) {\n const resetOnChange = useResetOnChange(reset, otherProps);\n return (\n <ResetOnChangeContext value={resetOnChange}>\n {children}\n </ResetOnChangeContext>\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type FormatterControllerState,\n type InputController,\n type InputOptions,\n InvalidPathError,\n useInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n Checkbox,\n type CheckboxChecked,\n type CheckboxProps,\n combineEventHandlers,\n FeedbackProvider,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type Dispatch,\n type ReactNode,\n type Ref,\n useState,\n} from \"react\";\n\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\n\n/** Properties of the checkbox control component. */\nexport interface CheckboxControlProps<T extends boolean | null = boolean | null>\n extends\n Omit<\n InputOptions<T, CheckboxChecked, ComponentRef<typeof Checkbox>>,\n \"enabled\" | \"format\" | \"parse\"\n >,\n Omit<\n CheckboxProps,\n \"defaultChecked\" | \"checked\" | \"status\" | \"validate\" | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | InputController<T, CheckboxChecked, ComponentRef<typeof Checkbox>>\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The checkbox control component is a KForm form control for values with\n * (possibly\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`BooleanSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-boolean-schema/index.html).\n * It is built on top of the [`Checkbox`](/docs/ostack-ui-forms-checkbox--docs)\n * component.\n *\n * The following built-in KForm validation affects this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n *\n * Example usage:\n *\n * ```tsx\n * import { CheckboxControl } from \"@ostack.tech/ui-kform\";\n *\n * function TermsControl() {\n * return (\n * <CheckboxControl path=\"/terms\">\n * Accept terms and conditions\n * </CheckboxControl>\n * );\n * }\n * ```\n */\nexport function CheckboxControl<T extends boolean | null = boolean | null>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n loading,\n showSpinner,\n disabled,\n readOnly,\n endAdornment,\n onFocus,\n onCheckedChange,\n onBlurToOutside,\n debug,\n ref,\n ...otherProps\n}: CheckboxControlProps<T>) {\n const [formattedValue, setFormattedValue] = useState<CheckboxChecked>(false);\n const controller = useInput<\n T,\n CheckboxChecked,\n ComponentRef<typeof Checkbox>\n >(path, {\n enabled: !useFormIsLoading(),\n parse: parseCheckboxValue,\n format: formatToCheckboxValue,\n setFormattedValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange: combineEventHandlers(\n onValueChange,\n useResetOnChangeContext(),\n ),\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLButtonElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n if (schema.typeInfo.name !== \"Boolean\") {\n throw new InvalidPathError(\n absolutePath,\n \"Unsupported schema: Expected schema representing (possibly nullable) \" +\n \"booleans, but got schema representing values of type \" +\n `'${schema.typeInfo.toString()}'.`,\n );\n }\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedCheckboxRef = useCombinedRef(inputProps.ref, autofocusRef, ref);\n return (\n <FeedbackProvider>\n <Checkbox\n checked={formattedValue}\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath} />\n )}\n </>\n }\n onCheckedChange={combineEventHandlers(\n onCheckedChange,\n combineEventHandlers(\n inputProps.onChange,\n setFormattedValue as Dispatch<CheckboxChecked>,\n ),\n )}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedCheckboxRef}\n />\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n\n/** Parses a checkbox control formatted value. */\nfunction parseCheckboxValue<T extends boolean | null>(\n formattedValue: CheckboxChecked,\n state: FormatterControllerState<T, CheckboxChecked>,\n): T {\n return (\n formattedValue === \"indeterminate\"\n ? state.schema.typeInfo.nullable\n ? null\n : state.schema.initialValue\n : formattedValue\n ) as T;\n}\n\n/** Formats a checkbox control value. */\nfunction formatToCheckboxValue<T extends boolean | null>(\n value: T | undefined,\n): CheckboxChecked {\n return value === undefined ? false : (value ?? \"indeterminate\");\n}\n","import type { Schema } from \"@ostack.tech/kform\";\nimport { equals, type Listable } from \"@ostack.tech/kform-react\";\nimport { Option, OptionsGroup } from \"@ostack.tech/ui\";\nimport type { JSX } from \"react\";\n\nimport type {\n SelectControlItemGroupObject,\n SelectControlItemObject,\n} from \"../components/SelectControl\";\n\n/** Whether the provided value isn't a known option. */\nexport function isUnknownValue<T>(\n value: T | null | undefined,\n options: { value: T }[],\n) {\n return (\n value != null &&\n value !== \"\" &&\n options.every((opt) => !equals(opt.value, value))\n );\n}\n\n/**\n * Parses a selection value from the (string) index of an option (or empty\n * string).\n */\nexport function parseSelectionValueFromOptionIndex<T>(\n formattedValue: string,\n schema: Schema<T>,\n options: { value: T }[],\n unknownValues: readonly T[],\n): T {\n if (formattedValue === \"\") {\n return schema.typeInfo.nullable ? (null as T) : schema.initialValue;\n } else if (formattedValue.startsWith(\"-\")) {\n return unknownValues[-+formattedValue - 1];\n }\n return options[+formattedValue].value;\n}\n\n/**\n * Formats a selection value as the (string) index of an option (or empty\n * string).\n */\nexport function formatSelectionValueAsOptionIndex<T>(\n value: T | undefined,\n options: { value: T }[],\n): string {\n const idx = options.findIndex((option) => equals(option.value, value));\n return idx === -1\n ? value == null || value === \"\"\n ? \"\"\n : \"-1\"\n : idx.toString();\n}\n\n/** Values that aren't known options. */\nexport function getUnknownValues<T>(\n arrayValue: readonly T[] | null | undefined,\n options: { value: T }[],\n): T[] {\n const unknownValues: T[] = [];\n for (const v of arrayValue ?? []) {\n if (\n options.every((opt) => !equals(opt.value, v)) &&\n unknownValues.every((u) => !equals(u, v))\n ) {\n unknownValues.push(v);\n }\n }\n return unknownValues;\n}\n\n/** Parses an array of selection values from an array of (string) option indices. */\nexport function parseSelectionValuesFromOptionIndices<\n T,\n TListable extends Listable<T> | null,\n>(\n formattedValue: string[],\n schema: Schema<TListable>,\n options: { value: T }[],\n unknownValues: readonly T[],\n): T[] | null {\n return formattedValue.length === 0\n ? schema.typeInfo.nullable\n ? null\n : []\n : formattedValue.map((v) =>\n v.startsWith(\"-\") ? unknownValues[-+v - 1] : options[+v].value,\n );\n}\n\n/** Formats an array of selection values as an array of (string) option indices. */\nexport function formatSelectionValuesAsOptionIndices<T>(\n arrayValue: readonly T[] | null | undefined,\n options: { value: T }[],\n unknownValues: readonly T[],\n): string[] {\n return (\n arrayValue?.map((v) => {\n const idx = options.findIndex((option) => equals(option.value, v));\n return idx === -1\n ? (-unknownValues.findIndex((u) => equals(u, v)) - 1).toString()\n : idx.toString();\n }) ?? []\n );\n}\n\n/**\n * Transforms selection item objects into React nodes.\n *\n * @param items Item objects.\n * @returns React nodes representing the objects.\n */\nexport function selectionItemObjectsToNodes<T>(\n items: (SelectControlItemObject<T> | SelectControlItemGroupObject<T>)[],\n): JSX.Element[] {\n let optionIndex = 0;\n return items.map(({ key, ...optionOrGroup }, i) =>\n \"options\" in optionOrGroup ? (\n <OptionsGroup key={key ?? i} {...optionOrGroup}>\n {optionOrGroup.options.map(\n ({ key, value, text, ...optionProps }, i) => (\n <Option key={key ?? i} value={optionIndex++} {...optionProps}>\n {text ?? value?.toString() ?? \"\"}\n </Option>\n ),\n )}\n </OptionsGroup>\n ) : (\n <Option key={key ?? i} {...optionOrGroup} value={optionIndex++}>\n {optionOrGroup.text ?? optionOrGroup.value?.toString() ?? \"\"}\n </Option>\n ),\n );\n}\n","import type { ReactNode } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\n\n/** Properties of the unknown value component. */\nexport interface UnknownValueProps<T = unknown> {\n value?: T;\n /** Label shown when a value isn't one of the existing options. */\n label?: ReactNode;\n}\n\n/** Representation of an unknown value. */\nexport function UnknownValue<T = unknown>({\n value,\n label,\n}: UnknownValueProps<T>) {\n const [locale] = useLocale();\n label ??= locale.UnknownValue.label;\n\n const prefix = usePrefix();\n\n const valueStr = value == null ? \"\" : String(value);\n return (\n <>\n {valueStr && (\n <>\n “<span className={prefix(\"unknown-value\")}>{valueStr}</span>”\n </>\n )}\n {valueStr && label && <>&nbsp;</>}\n {label && (\n <span className={prefix(\"unknown-value__label\")}>({label})</span>\n )}\n </>\n );\n}\n","import type { CheckboxProps } from \"@ostack.tech/ui\";\nimport type { Key, ReactNode } from \"react\";\n\n/** @deprecated Use {@link CheckboxGroupControlItemObject} instead. */\nexport type CheckboxObject<T = unknown> = CheckboxGroupControlItemObject<T>;\n\n/** Checkbox group control item in object notation. */\nexport interface CheckboxGroupControlItemObject<T = unknown> extends Omit<\n CheckboxProps,\n \"defaultChecked\" | \"checked\" | \"value\" | \"children\"\n> {\n /** Item value. */\n value: T;\n /** Item's rendered text. */\n text?: ReactNode;\n /** Item's unique key. */\n key?: Key;\n}\n\n/** Properties of the checkbox group control item component. */\nexport interface CheckboxGroupControlItemProps<T = unknown> extends Omit<\n CheckboxGroupControlItemObject<T>,\n \"text\"\n> {\n /** Item's rendered text. */\n children?: ReactNode;\n}\n\n/**\n * Definition of a checkbox group control item.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `CheckboxGroupControl` component to automatically create the `options`\n * array.\n */\nexport function CheckboxGroupControlItem(\n _props: CheckboxGroupControlItemProps,\n) {\n return null;\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type Listable,\n type ListableInputController,\n type ListableInputOptions,\n useListableInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n Checkbox,\n CheckboxGroup,\n type CheckboxGroupProps,\n combineEventHandlers,\n FeedbackProvider,\n parseChildren,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport {\n formatSelectionValuesAsOptionIndices,\n getUnknownValues,\n parseSelectionValuesFromOptionIndices,\n} from \"../../utils/selectionTransformations.tsx\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\nimport { UnknownValue } from \"../UnknownValue\";\nimport {\n CheckboxGroupControlItem,\n type CheckboxGroupControlItemObject,\n} from \"./CheckboxGroupControlItem.tsx\";\n\n/** Properties of the checkbox group control component. */\nexport interface CheckboxGroupControlProps<\n T = unknown,\n TListable extends Listable<T> | null = Listable<T> | null,\n>\n extends\n Omit<\n ListableInputOptions<\n T,\n TListable,\n readonly T[] | null,\n ComponentRef<typeof CheckboxGroup>\n >,\n \"enabled\" | \"formatFromArray\" | \"parseToArray\"\n >,\n Omit<\n CheckboxGroupProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"children\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /** Checkbox group control options. */\n options?: CheckboxGroupControlItemObject<T>[];\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /** Label shown when a value of the control isn't one of the existing options. */\n unknownValueLabel?: ReactNode;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /** Checkbox group control children. */\n children?: ReactNode;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | ListableInputController<\n T,\n TListable,\n string[],\n ComponentRef<typeof CheckboxGroup>\n >\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The checkbox group control component is a KForm form control for values with\n * (possibly\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)\n * or\n * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)\n * and items of any type. It is built on top of the\n * [`CheckboxGroup`](/docs/ostack-ui-forms-checkbox-group--docs) component.\n *\n * It composes the following subcomponent:\n *\n * - `CheckboxGroupControlItem`: Component used to define an item of the checkbox\n * group control.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MinSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):\n * Sets the `minChecked` and/or `maxChecked` properties.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * CheckboxGroupControl,\n * CheckboxGroupControlItem,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function SpokenLanguagesControl() {\n * return (\n * <CheckboxGroupControl path=\"/spokenLanguages\">\n * <CheckboxGroupControlItem value=\"en\">\n * English\n * </CheckboxGroupControlItem>\n * <CheckboxGroupControlItem value=\"fr\">\n * French\n * </CheckboxGroupControlItem>\n * <CheckboxGroupControlItem value=\"pt\">\n * Portuguese\n * </CheckboxGroupControlItem>\n * <CheckboxGroupControlItem value=\"es\">\n * Spanish\n * </CheckboxGroupControlItem>\n * </CheckboxGroupControl>\n * );\n * }\n * ```\n */\nexport function CheckboxGroupControl<\n T = unknown,\n TListable extends Listable<T> | null = Listable<T> | null,\n>({\n path,\n options,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n unknownValueLabel,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n minChecked,\n maxChecked,\n loading,\n showSpinner,\n disabled,\n readOnly,\n endAdornment,\n onFocus,\n onBlurToOutside,\n children,\n debug,\n ref,\n ...otherProps\n}: CheckboxGroupControlProps<T, TListable>) {\n const [locale] = useLocale();\n unknownValueLabel ??= locale.SelectMultipleControl.unknownValueLabel;\n\n options ??= parseChildren(children, CheckboxGroupControlItem, {\n transformChildObject: ({ children, ...otherProps }) => ({\n text: children,\n ...otherProps,\n }),\n });\n\n const [arrayValue, setArrayValue] = useState<readonly T[] | null>(null);\n const unknownValues = useMemo(\n () => getUnknownValues(arrayValue, options),\n [options, arrayValue],\n );\n const formattedValue = useMemo(\n () =>\n formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues),\n [options, unknownValues, arrayValue],\n );\n const controller = useListableInput<\n T,\n TListable,\n readonly T[] | null,\n ComponentRef<typeof CheckboxGroup>\n >(path, {\n enabled: !useFormIsLoading(),\n parseToArray: useCallback(\n (formattedValue: readonly T[] | null) =>\n formattedValue && [...formattedValue],\n [],\n ),\n formatFromArray: useCallback(\n (arrayValue: readonly T[] | null) => arrayValue && [...arrayValue],\n [],\n ),\n setFormattedValue: setArrayValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange: combineEventHandlers(\n onValueChange,\n useResetOnChangeContext(),\n ),\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const { restrictions } = schema.typeInfo;\n const absolutePath = usePath();\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<TListable, HTMLDivElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const { onChange: inputOnChange } = inputProps;\n const handleValueChange = useCallback(\n (formattedValue: string[]) => {\n const newValue = parseSelectionValuesFromOptionIndices(\n formattedValue,\n schema,\n options,\n unknownValues,\n );\n inputOnChange(newValue);\n setArrayValue(newValue);\n },\n [inputOnChange, options, schema, unknownValues],\n );\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedCheckboxGroupRef = useCombinedRef(\n inputProps.ref,\n autofocusRef,\n ref,\n );\n return (\n <FeedbackProvider>\n <CheckboxGroup\n value={formattedValue}\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n minChecked={\n minChecked ??\n (typeof restrictions.minSize === \"number\"\n ? restrictions.minSize\n : undefined)\n }\n maxChecked={\n maxChecked ??\n (typeof restrictions.maxSize === \"number\"\n ? restrictions.maxSize\n : undefined)\n }\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath} />\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedCheckboxGroupRef}\n >\n {/* Unknown values */}\n {unknownValues.map((v, i) => (\n <Checkbox key={i} value={-i - 1} status=\"invalid\">\n <UnknownValue value={v} label={unknownValueLabel} />\n </Checkbox>\n ))}\n {options.map(({ value, text, key, ...checkboxProps }, i) => (\n <Checkbox key={key ?? i} value={i} {...checkboxProps}>\n {text ?? value?.toString() ?? \"\"}\n </Checkbox>\n ))}\n </CheckboxGroup>\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import type { Schema } from \"@ostack.tech/kform\";\nimport {\n formatTemporalAsString,\n type Temporal,\n} from \"@ostack.tech/kform-react\";\nimport { addDays, max, min, parseISO } from \"date-fns\";\n\n/** Returns the minimum date allowed based on a temporal schema's restrictions. */\nexport function minDateRestriction<T extends Temporal | null>(\n schema: Schema<T>,\n): Date | undefined {\n const { restrictions } = schema.typeInfo;\n const min = temporalRestrictionToDate(restrictions.min, schema);\n const exclusiveMin = temporalRestrictionToDate(\n restrictions.exclusiveMin,\n schema,\n );\n const minFromMinExclusive = exclusiveMin && addDays(exclusiveMin, 1);\n return min != null && minFromMinExclusive != null\n ? max([min, minFromMinExclusive])\n : (min ?? minFromMinExclusive);\n}\n\n/** Returns the maximum date allowed based on a temporal schema's restrictions. */\nexport function maxDateRestriction<T extends Temporal | null>(\n schema: Schema<T>,\n): Date | undefined {\n const { restrictions } = schema.typeInfo;\n const max = temporalRestrictionToDate(restrictions.max, schema);\n const exclusiveMax = temporalRestrictionToDate(\n restrictions.exclusiveMax,\n schema,\n );\n const maxFromMaxExclusive = exclusiveMax && addDays(exclusiveMax, -1);\n return max != null && maxFromMaxExclusive != null\n ? min([max, maxFromMaxExclusive])\n : (max ?? maxFromMaxExclusive);\n}\n\n/** Transforms a temporal restriction in a JS date. */\nfunction temporalRestrictionToDate<T extends Temporal | null>(\n restriction: unknown,\n schema: Schema<T>,\n) {\n return restriction == null\n ? undefined\n : parseISO(formatTemporalAsString(restriction as T, schema));\n}\n","import type { Schema } from \"@ostack.tech/kform\";\nimport type { Temporal } from \"@ostack.tech/kform-react\";\nimport {\n type DateFormatterOptions,\n type DateParserOptions,\n type DateTransformerOptions,\n useDateTransformer,\n} from \"@ostack.tech/ui\";\nimport { format as fnsFormat, parseISO } from \"date-fns\";\nimport { useMemo } from \"react\";\n\n/** Temporal string transformer. */\nexport interface TemporalStringTransformer {\n /**\n * Function used to parse a formatted date as exposed by a date input as a\n * temporal string.\n */\n parse: <T extends Temporal | null = Temporal | null>(\n formattedDate: string,\n schema: Schema<T>,\n options?: DateParserOptions,\n ) => string;\n /**\n * Function used to format a temporal string as a string accepted by a date\n * input.\n */\n format: <T extends Temporal | null = Temporal | null>(\n temporalString: string,\n schema: Schema<T>,\n options?: DateFormatterOptions,\n ) => string;\n}\n\n/**\n * Hook exposing functions to transform a temporal string value from/into a\n * string representation of a date accepted by a date input.\n */\nexport function useTemporalStringTransformer(\n dateTransformerOptions?: DateTransformerOptions,\n): TemporalStringTransformer {\n const { format, parse } = useDateTransformer(dateTransformerOptions);\n\n return useMemo(\n () => ({\n parse: <T extends Temporal | null = Temporal | null>(\n formattedDate: string,\n schema: Schema<T>,\n options?: DateParserOptions,\n ) => {\n const date = parse(formattedDate, options);\n if (date === null) {\n return \"\";\n }\n\n const dateString = fnsFormat(date, \"yyyy-MM-dd\");\n switch (schema.typeInfo.name) {\n case \"Instant\":\n return `${dateString}T00:00:00.000Z`;\n case \"LocalDateTime\":\n return `${dateString}T00:00:00`;\n default: // `LocalDate` or JavaScript `Date`\n return dateString;\n }\n },\n format: <T extends Temporal | null = Temporal | null>(\n temporalString: string,\n _schema: Schema<T>,\n options?: DateFormatterOptions,\n ) => temporalString && format(parseISO(temporalString), options),\n }),\n [format, parse],\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type FormatterControllerState,\n type Temporal,\n type TemporalInputController,\n type TemporalInputOptions,\n useTemporalInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n DateInput,\n type DateInputProps,\n type DateValueRepresentations,\n FeedbackProvider,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useState,\n} from \"react\";\n\nimport {\n maxDateRestriction,\n minDateRestriction,\n} from \"../../utils/dateRestrictions.ts\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { useTemporalStringTransformer } from \"../../utils/useTemporalStringTransformer.ts\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\n\n/** Properties of the date control component. */\nexport interface DateControlProps<T extends Temporal | null = Temporal | null>\n extends\n Omit<\n TemporalInputOptions<T, string, ComponentRef<typeof DateInput>>,\n \"enabled\" | \"formatFromString\" | \"parseToString\"\n >,\n Omit<\n DateInputProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | TemporalInputController<T, string, ComponentRef<typeof DateInput>>\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The date control component is a KForm form control for values with (typically\n * nullable) schemas of type\n * [`LocalDateSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-local-date-schema/index.html)\n * or\n * [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).\n * It is built on top of the\n * [`DateInput`](/docs/ostack-ui-forms-date-input--docs) component.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Min`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min/index.html)/[`Max`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max/index.html)/[`ExclusiveMin`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-min/index.html)/[`ExclusiveMax`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-max/index.html):\n * Sets the `minDate`/`maxDate` properties.\n *\n * Example usage:\n *\n * ```tsx\n * import { DateControl } from \"@ostack.tech/ui-kform\";\n *\n * function ProjectDueDateControl() {\n * return <DateControl path=\"/dueDate\" />;\n * }\n * ```\n */\nexport function DateControl<T extends Temporal | null = Temporal | null>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n format: dateFormat,\n required,\n minDate,\n maxDate,\n loading,\n showSpinner,\n disabled,\n readOnly,\n onFocus,\n onBlurToOutside,\n endAdornment,\n debug,\n ref,\n ...otherProps\n}: DateControlProps<T>) {\n const { format, parse } = useTemporalStringTransformer({\n format: dateFormat,\n });\n\n const [formattedValue, setFormattedValue] = useState(\"\");\n const controller = useTemporalInput<\n T,\n string,\n ComponentRef<typeof DateInput>\n >(path, {\n enabled: !useFormIsLoading(),\n parseToString: useCallback(\n (formattedValue: string, state: FormatterControllerState<T, string>) =>\n parse(formattedValue, state.schema),\n [parse],\n ),\n formatFromString: useCallback(\n (temporalString: string, state: FormatterControllerState<T, string>) =>\n format(temporalString, state.schema),\n [format],\n ),\n setFormattedValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange: combineEventHandlers(\n onValueChange,\n useResetOnChangeContext(),\n ),\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLInputElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const handleValueChange = useCallback(\n ({ formattedValue }: DateValueRepresentations) => {\n setFormattedValue(formattedValue);\n inputProps.onChange(formattedValue);\n },\n [inputProps],\n );\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedDateInputRef = useCombinedRef(\n inputProps.ref,\n autofocusRef,\n ref,\n );\n return (\n <FeedbackProvider>\n <DateInput\n value={formattedValue}\n name={inputProps.name}\n format={dateFormat}\n required={required ?? restrictions.required === true}\n minDate={minDate ?? minDateRestriction(schema)}\n maxDate={maxDate ?? maxDateRestriction(schema)}\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedDateInputRef}\n />\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type FormatterControllerState,\n type Temporal,\n type TemporalInputController,\n type TemporalInputOptions,\n useTemporalInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n DateRangeInput,\n type DateRangeInputProps,\n type DateRangeValueRepresentations,\n FeedbackProvider,\n type FormattedRange,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport { type ReactNode, type Ref, useCallback, useState } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport {\n maxDateRestriction,\n minDateRestriction,\n} from \"../../utils/dateRestrictions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { useTemporalStringTransformer } from \"../../utils/useTemporalStringTransformer.ts\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\n\n/** Properties of the date-range control component. */\nexport interface DateRangeControlProps<\n TStart extends Temporal | null = Temporal | null,\n TEnd extends Temporal | null = TStart,\n> extends Omit<\n DateRangeInputProps,\n \"defaultValue\" | \"value\" | \"validate\" | \"validationMode\"\n> {\n /** Path to the start value. */\n startPath: string | Path;\n /** Path to the end value. */\n endPath: string | Path;\n /**\n * Issue messages of this control's start.\n *\n * Mapping from an issue's code to its message.\n */\n startIssueMessages?: IssueMessagesByCode;\n /**\n * Issue messages of this control's end.\n *\n * Mapping from an issue's code to its message.\n */\n endIssueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Label suffix to use in the issues panel when displaying issues associated\n * with this field's start date.\n */\n issuesPanelStartLabelSuffix?: ReactNode;\n /**\n * Label suffix to use in the issues panel when displaying issues associated\n * with this field's end date.\n */\n issuesPanelEndLabelSuffix?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the start control's API. */\n startApiRef?: Ref<TemporalInputController<TStart> | undefined>;\n /** Reference to the end control's API. */\n endApiRef?: Ref<TemporalInputController<TEnd> | undefined>;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n onStartInitialized?: TemporalInputOptions<TStart>[\"onInitialized\"];\n onStartFormManagerEvent?: TemporalInputOptions<TStart>[\"onFormManagerEvent\"];\n onStartValueChange?: TemporalInputOptions<TStart>[\"onValueChange\"];\n onStartValidationStatusChange?: TemporalInputOptions<TStart>[\"onValidationStatusChange\"];\n onStartDisplayStatusChange?: TemporalInputOptions<TStart>[\"onDisplayStatusChange\"];\n onStartDirtyStatusChange?: TemporalInputOptions<TStart>[\"onDirtyStatusChange\"];\n onStartTouchedStatusChange?: TemporalInputOptions<TStart>[\"onTouchedStatusChange\"];\n onEndInitialized?: TemporalInputOptions<TEnd>[\"onInitialized\"];\n onEndFormManagerEvent?: TemporalInputOptions<TEnd>[\"onFormManagerEvent\"];\n onEndValueChange?: TemporalInputOptions<TEnd>[\"onValueChange\"];\n onEndValidationStatusChange?: TemporalInputOptions<TEnd>[\"onValidationStatusChange\"];\n onEndDisplayStatusChange?: TemporalInputOptions<TEnd>[\"onDisplayStatusChange\"];\n onEndDirtyStatusChange?: TemporalInputOptions<TEnd>[\"onDirtyStatusChange\"];\n onEndTouchedStatusChange?: TemporalInputOptions<TEnd>[\"onTouchedStatusChange\"];\n}\n\n/**\n * The date-range control component is a KForm form control for pairs of values\n * (start and end dates) with (typically nullable) schemas of type\n * [`LocalDateSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-local-date-schema/index.html)\n * or\n * [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).\n * It is built on top of the\n * [`DateRangeInput`](/docs/ostack-ui-forms-date-range-input--docs) component.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Min`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min/index.html)/[`Max`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max/index.html)/[`ExclusiveMin`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-min/index.html)/[`ExclusiveMax`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-max/index.html):\n * Sets the `minDate`/`maxDate` properties.\n *\n * Example usage:\n *\n * ```tsx\n * import { DateRangeControl } from \"@ostack.tech/ui-kform\";\n *\n * function ReservationDatesControl() {\n * return (\n * <DateRangeControl startPath=\"/checkInDate\" endPath=\"/checkOutDate\" />\n * );\n * }\n * ```\n */\nexport function DateRangeControl<\n TStart extends Temporal | null = Temporal | null,\n TEnd extends Temporal | null = TStart,\n>({\n startPath,\n endPath,\n startIssueMessages,\n endIssueMessages,\n issuesPanelLabel,\n issuesPanelStartLabelSuffix,\n issuesPanelEndLabelSuffix,\n displayIssues = true,\n preventAutoFocus,\n startApiRef,\n endApiRef,\n issueMessagesProps,\n required,\n minDate,\n maxDate,\n loading,\n showSpinners = loading,\n showStartSpinner = showSpinners,\n showEndSpinner = showSpinners,\n disabled,\n readOnly,\n startInputProps,\n endInputProps,\n onStartInitialized,\n onStartFormManagerEvent,\n onStartValueChange,\n onStartValidationStatusChange,\n onStartDisplayStatusChange,\n onStartDirtyStatusChange,\n onStartTouchedStatusChange,\n onEndInitialized,\n onEndFormManagerEvent,\n onEndValueChange,\n onEndValidationStatusChange,\n onEndDisplayStatusChange,\n onEndDirtyStatusChange,\n onEndTouchedStatusChange,\n onValueChange,\n format: dateFormat,\n onBlurToOutside,\n startMiddleAdornment,\n endAdornment,\n debug,\n ...otherProps\n}: DateRangeControlProps<TStart, TEnd>) {\n const [locale] = useLocale();\n issuesPanelStartLabelSuffix ??=\n locale.DateRangeControl.issuesPanelStartLabelSuffix;\n issuesPanelEndLabelSuffix ??=\n locale.DateRangeControl.issuesPanelEndLabelSuffix;\n\n const { format, parse } = useTemporalStringTransformer({\n format: dateFormat,\n });\n\n const [formattedValue, setFormattedValue] = useState<FormattedRange>({\n start: \"\",\n end: \"\",\n });\n const parseToString = useCallback(\n (\n formattedValue: string,\n state: FormatterControllerState<TStart | TEnd, string>,\n ) => parse(formattedValue, state.schema),\n [parse],\n );\n const formatFromString = useCallback(\n (\n stringValue: string,\n state: FormatterControllerState<TStart | TEnd, string>,\n ) => format(stringValue, state.schema),\n [format],\n );\n const formIsLoading = useFormIsLoading();\n const resetOnChange = useResetOnChangeContext();\n const startController = useTemporalInput<TStart, string>(startPath, {\n enabled: !formIsLoading,\n parseToString,\n formatFromString,\n setFormattedValue: useCallback(\n (formattedValue: string) =>\n setFormattedValue(({ end }) => ({ start: formattedValue, end })),\n [],\n ),\n onInitialized: onStartInitialized,\n onFormManagerEvent: onStartFormManagerEvent,\n onValueChange: combineEventHandlers(onStartValueChange, resetOnChange),\n onValidationStatusChange: onStartValidationStatusChange,\n onDisplayStatusChange: onStartDisplayStatusChange,\n onDirtyStatusChange: onStartDirtyStatusChange,\n onTouchedStatusChange: onStartTouchedStatusChange,\n });\n const endController = useTemporalInput<TEnd, string, HTMLInputElement>(\n endPath,\n {\n enabled: !formIsLoading,\n parseToString,\n formatFromString,\n setFormattedValue: useCallback(\n (formattedValue: string) =>\n setFormattedValue(({ start }) => ({ start, end: formattedValue })),\n [],\n ),\n onInitialized: onEndInitialized,\n onFormManagerEvent: onEndFormManagerEvent,\n onValueChange: combineEventHandlers(onEndValueChange, resetOnChange),\n onValidationStatusChange: onEndValidationStatusChange,\n onDisplayStatusChange: onEndDisplayStatusChange,\n onDirtyStatusChange: onEndDirtyStatusChange,\n onTouchedStatusChange: onEndTouchedStatusChange,\n },\n );\n const { inputProps: startControllerInputProps } = startController;\n const startSchema = startController.useSchema();\n const startAbsolutePath = startController.usePath();\n const { restrictions: startRestrictions } = startSchema.typeInfo;\n const { inputProps: endControllerInputProps } = endController;\n const endSchema = endController.useSchema();\n const endAbsolutePath = endController.usePath();\n const { restrictions: endRestrictions } = endSchema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the start control\n const {\n displayLoading: displayStartLoading,\n displayDisabled: displayStartDisabled,\n displayReadOnly: displayStartReadOnly,\n displayStatusToDisplay: startDisplayStatusToDisplay,\n displayValidating: displayStartValidating,\n issuesToDisplay: startIssuesToDisplay,\n autofocusRef: startAutofocusRef,\n handleFocus: handleStartFocus,\n } = useRegisterControl<TStart, HTMLInputElement>({\n controller: startController,\n issuesPanelLabel,\n ariaLabel: startInputProps?.[\"aria-label\"],\n issuesPanelLabelSuffix: issuesPanelStartLabelSuffix,\n preventAutoFocus,\n apiRef: startApiRef,\n });\n // Register the end control\n const {\n displayLoading: displayEndLoading,\n displayDisabled: displayEndDisabled,\n displayReadOnly: displayEndReadOnly,\n displayStatusToDisplay: endDisplayStatusToDisplay,\n displayValidating: displayEndValidating,\n issuesToDisplay: endIssuesToDisplay,\n autofocusRef: endAutofocusRef,\n handleFocus: handleEndFocus,\n } = useRegisterControl<TEnd, HTMLInputElement>({\n controller: endController,\n issuesPanelLabel,\n ariaLabel: endInputProps?.[\"aria-label\"],\n issuesPanelLabelSuffix: issuesPanelEndLabelSuffix,\n preventAutoFocus,\n apiRef: endApiRef,\n });\n\n const handleValueChange = useCallback(\n ({ formattedValue: newFormattedValue }: DateRangeValueRepresentations) => {\n setFormattedValue(newFormattedValue);\n if (newFormattedValue.start !== formattedValue.start) {\n startControllerInputProps.onChange(newFormattedValue.start);\n }\n if (newFormattedValue.end !== formattedValue.end) {\n endControllerInputProps.onChange(newFormattedValue.end);\n }\n },\n [\n endControllerInputProps,\n formattedValue.end,\n formattedValue.start,\n startControllerInputProps,\n ],\n );\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: {\n [startAbsolutePath.toString()]: startIssuesToDisplay,\n [endAbsolutePath.toString()]: endIssuesToDisplay,\n },\n issueMessages: {\n [startAbsolutePath.toString()]: startIssueMessages,\n [endAbsolutePath.toString()]: endIssueMessages,\n },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n return (\n <FeedbackProvider>\n <DateRangeInput\n value={formattedValue}\n format={dateFormat}\n required={\n required ??\n (startRestrictions.required === true ||\n endRestrictions.required === true)\n }\n minDate={minDate ?? minDateRestriction(startSchema)}\n maxDate={maxDate ?? maxDateRestriction(endSchema)}\n loading={displayStartLoading || displayEndLoading || loading}\n showStartSpinner={displayStartValidating || showStartSpinner}\n showEndSpinner={displayEndValidating || showEndSpinner}\n disabled={\n (displayStartDisabled && displayEndDisabled) ||\n disabled ||\n (startInputProps?.disabled && endInputProps?.disabled)\n }\n readOnly={\n (displayStartReadOnly && displayEndReadOnly) ||\n readOnly ||\n (startInputProps?.readOnly && endInputProps?.readOnly)\n }\n status={\n startDisplayStatusToDisplay === \"error\" ||\n endDisplayStatusToDisplay === \"error\"\n ? \"invalid\"\n : startDisplayStatusToDisplay === \"warning\" ||\n endDisplayStatusToDisplay === \"warning\"\n ? \"warned\"\n : undefined\n }\n onValueChange={combineEventHandlers(onValueChange, handleValueChange)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n combineEventHandlers(\n startControllerInputProps.onBlur,\n endControllerInputProps.onBlur,\n ),\n )}\n startInputProps={{\n name: startControllerInputProps.name,\n ...startInputProps,\n disabled: displayStartDisabled || startInputProps?.disabled,\n readOnly: displayStartReadOnly || startInputProps?.readOnly,\n onFocus: combineEventHandlers(\n startInputProps?.onFocus,\n handleStartFocus,\n ),\n ref: useCombinedRef(\n startControllerInputProps?.ref,\n useCombinedRef(startAutofocusRef, startInputProps?.ref),\n ),\n }}\n endInputProps={{\n name: endControllerInputProps.name,\n ...endInputProps,\n disabled: displayEndDisabled || endInputProps?.disabled,\n readOnly: displayEndReadOnly || endInputProps?.readOnly,\n onFocus: combineEventHandlers(endInputProps?.onFocus, handleEndFocus),\n ref: useCombinedRef(\n endControllerInputProps?.ref,\n useCombinedRef(endAutofocusRef, endInputProps?.ref),\n ),\n }}\n startMiddleAdornment={\n <>\n {startMiddleAdornment}\n\n {/* Start debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<TStart> path={startAbsolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* End debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<TEnd> path={endAbsolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n {...otherProps}\n />\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import { faDownload } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n ControlAddon,\n Icon,\n Tooltip,\n usePrintClassNames,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, useMemo } from \"react\";\n\n/** Properties of the file control download addon. */\nexport interface FileControlDownloadAddonProps {\n file: File;\n label: ReactNode;\n}\n\n/** Control addon used to download a file. */\nexport function FileControlDownloadAddon({\n file,\n label,\n}: FileControlDownloadAddonProps) {\n const { printHidden } = usePrintClassNames();\n const dataURL = useMemo(() => URL.createObjectURL(file), [file]);\n\n return (\n <Tooltip content={label}>\n <ControlAddon\n as=\"a\"\n className={printHidden}\n href={dataURL}\n download={file.name}\n >\n <Icon icon={faDownload} />\n </ControlAddon>\n </Tooltip>\n );\n}\n","import { faDownload, faFileLines } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n Alert,\n ControlAddon,\n Dialog,\n DialogBody,\n DialogContent,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n Icon,\n IconButton,\n Tooltip,\n usePrintClassNames,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, useMemo } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\n\n/** Properties of the file control view addon. */\nexport interface FileControlViewAddonProps {\n file: File;\n viewLabel: ReactNode;\n downloadLabel: ReactNode;\n fallbackText: ReactNode;\n}\n\n/** Control addon used to view a file. */\nexport function FileControlViewAddon({\n file,\n viewLabel,\n downloadLabel,\n fallbackText,\n}: FileControlViewAddonProps) {\n const prefix = usePrefix();\n const { printHidden } = usePrintClassNames();\n const dataURL = useMemo(() => URL.createObjectURL(file), [file]);\n\n return (\n <Dialog>\n <Tooltip content={viewLabel}>\n <DialogTrigger>\n <ControlAddon as=\"button\" className={printHidden}>\n <Icon icon={faFileLines} />\n </ControlAddon>\n </DialogTrigger>\n </Tooltip>\n\n <DialogContent\n variant=\"subtle\"\n className={prefix(\"file-control__viewer-dialog\")}\n aria-describedby={undefined}\n >\n <DialogHeader>\n <DialogTitle className={prefix(\"file-control__viewer-dialog-title\")}>\n {file.name}\n </DialogTitle>\n\n {/* Download file */}\n <IconButton\n variant=\"ghost\"\n className={prefix(\"file-control__viewer-download\")}\n asChild\n icon={faDownload}\n label={downloadLabel}\n >\n <a href={dataURL} download={file.name} />\n </IconButton>\n </DialogHeader>\n\n <DialogBody className={prefix(\"file-control__viewer-dialog-body\")}>\n {/* File viewer */}\n <object\n className={prefix(\"file-control__viewer-object\")}\n type={file.type || undefined}\n data={dataURL}\n aria-label={file.name}\n >\n <Alert\n className={prefix(\"file-control__viewer-fallback\")}\n severity=\"warning\"\n >\n {fallbackText}\n </Alert>\n </object>\n </DialogBody>\n </DialogContent>\n </Dialog>\n );\n}\n","import type { File as KFormFile, Path } from \"@ostack.tech/kform\";\nimport {\n type FileInputController,\n type FileInputOptions,\n toFileList,\n useFileInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n Input,\n type InputProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ChangeEvent,\n type ComponentRef,\n type KeyboardEvent,\n type ReactNode,\n type Ref,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\nimport { FileControlDownloadAddon } from \"./FileControlDownloadAddon.tsx\";\nimport { FileControlViewAddon } from \"./FileControlViewAddon.tsx\";\n\n/**\n * File control's interaction with the selected file:\n *\n * - `view`: A button is added which opens a dialog to view and optionally\n * download the file. A fallback alert is displayed when the file cannot be\n * viewed.\n * - `download`: A button is added to download the file. Useful if you know that\n * the accepted file types aren't viewable in the browser.\n * - `none`: No interaction with the selected file is added.\n */\nexport type FileControlFileInteraction = \"view\" | \"download\" | \"none\";\n\n/** Properties of the file control component. */\nexport interface FileControlProps<T extends KFormFile | null = KFormFile | null>\n extends\n Omit<\n FileInputOptions<T, File | null, ComponentRef<typeof Input>>,\n \"enabled\" | \"formatFromJsFile\" | \"parseToJsFile\"\n >,\n Omit<\n InputProps,\n // TODO: Support `multiple`\n | \"type\"\n | \"multiple\"\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"status\"\n | \"align\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n FileInputController<T, File | null, ComponentRef<typeof Input>> | undefined\n >;\n /**\n * Type of interaction with the selected file.\n *\n * @default \"view\"\n */\n fileInteraction?: FileControlFileInteraction;\n /** Label of the button used to open the file viewer. */\n viewFileButtonLabel?: ReactNode;\n /** Label of the button used to download the file. */\n downloadFileButtonLabel?: ReactNode;\n /** Text displayed when the file cannot be viewed. */\n fallbackText?: ReactNode;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The file control component is a KForm form control for values with (typically\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`FileSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-file-schema/index.html).\n * It is built on top of the [`Input`](/docs/ostack-ui-forms-input--docs)\n * component.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Accepts`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-accepts/index.html):\n * Sets the `accept` property.\n *\n * Example usage:\n *\n * ```tsx\n * import { FileControl } from \"@ostack.tech/ui-kform\";\n *\n * function IdProofControl() {\n * return <FileControl path=\"/idProof\" />;\n * }\n * ```\n */\nexport function FileControl<T extends KFormFile | null = KFormFile | null>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n fileInteraction = \"view\",\n viewFileButtonLabel,\n downloadFileButtonLabel,\n fallbackText,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n accept,\n loading,\n showSpinner,\n disabled,\n readOnly,\n showClearButton,\n clearDescription,\n endAdornment,\n onChange,\n onKeyDown,\n onFocus,\n onBlurToOutside,\n debug,\n clearButtonProps,\n ref,\n ...otherProps\n}: FileControlProps<T>) {\n const [locale] = useLocale();\n clearDescription ??= locale.FileControl.clearDescription;\n viewFileButtonLabel ??= locale.FileControl.viewFileButtonLabel;\n downloadFileButtonLabel ??= locale.FileControl.downloadFileButtonLabel;\n fallbackText ??= locale.FileControl.fallbackText;\n\n // Keep track of the latest file to work around some browsers clearing the\n // input on \"cancel\"\n const latestFile = useRef<File | null>(null);\n const [file, setFile] = useState<File | null>(null);\n const controller = useFileInput<T, File | null, ComponentRef<typeof Input>>(\n path,\n {\n enabled: !useFormIsLoading(),\n formManager,\n formatFromJsFile: useCallback((fileValue: File | null) => {\n setFile(fileValue);\n latestFile.current = fileValue;\n return fileValue;\n }, []),\n onInitialized,\n onFormManagerEvent,\n onValueChange: combineEventHandlers(\n onValueChange,\n useResetOnChangeContext(),\n ),\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n },\n );\n const { useSchema, usePath, inputProps } = controller;\n const { nullable, restrictions } = useSchema().typeInfo;\n const absolutePath = usePath();\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLInputElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n showClearButton ??= nullable ? file !== null : false;\n // Prevent browsers from clearing the input on \"cancel\" by undoing clearings\n // that didn't originate from a click on the clear button or via\n // delete/backspace. This undoing is done by setting the input's `files` to\n // the latest seen file.\n const isClearing = useRef(false);\n const handleClearButtonClick = useCallback(() => {\n isClearing.current = true;\n }, []);\n const handleChange = useCallback(\n (evt: ChangeEvent<HTMLInputElement>) => {\n if (evt.target.files!.length > 0 || isClearing.current) {\n isClearing.current = false;\n onChange?.(evt);\n inputProps.onChange(evt);\n } else {\n evt.target.files = toFileList(latestFile.current);\n }\n },\n [inputProps, onChange],\n );\n\n // Clear file when pressing 'Delete' or 'Backspace'\n const clearButtonRef = useRef<HTMLButtonElement | null>(null);\n const handleKeyDown = useCallback((evt: KeyboardEvent) => {\n if (evt.code === \"Delete\" || evt.code === \"Backspace\") {\n clearButtonRef.current?.click();\n }\n }, []);\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n });\n\n const combinedInputRef = useCombinedRef(inputProps.ref, autofocusRef, ref);\n return (\n <FeedbackProvider>\n <Input\n type=\"file\"\n name={inputProps.name}\n required={required ?? restrictions.required == true}\n accept={\n accept ??\n (Array.isArray(restrictions.acceptedFileTypes)\n ? restrictions.acceptedFileTypes.join()\n : undefined)\n }\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n showClearButton={showClearButton}\n clearDescription={clearDescription}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n onChange={handleChange}\n onKeyDown={combineEventHandlers(\n onKeyDown,\n // eslint-disable-next-line react-hooks/refs\n handleKeyDown,\n { checkDefaultPrevented: true },\n )}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n clearButtonProps={{\n ...clearButtonProps,\n onClick: combineEventHandlers(\n clearButtonProps?.onClick,\n // eslint-disable-next-line react-hooks/refs\n handleClearButtonClick,\n ),\n ref: useCombinedRef(clearButtonProps?.ref, clearButtonRef),\n }}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* View file adornment */}\n {fileInteraction === \"view\" && file && (\n <FileControlViewAddon\n file={file}\n viewLabel={viewFileButtonLabel}\n downloadLabel={downloadFileButtonLabel}\n fallbackText={fallbackText}\n />\n )}\n\n {/* File download adornment */}\n {fileInteraction === \"download\" && file && (\n <FileControlDownloadAddon\n file={file}\n label={downloadFileButtonLabel}\n />\n )}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n {...otherProps}\n ref={combinedInputRef}\n />\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import {\n AbsolutePath,\n type DisplayStatus,\n type Path,\n type SealedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport {\n computed,\n useConstant,\n useLatestRef,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport {\n createContext,\n type ReactNode,\n startTransition,\n useCallback,\n useContext,\n useEffect,\n} from \"react\";\nimport { createStore, useStore } from \"zustand\";\nimport { subscribeWithSelector } from \"zustand/middleware\";\n\nimport { useActivePathContext } from \"../../providers/ActivePathProvider\";\nimport { mostSpecificPath } from \"../../utils/mostSpecificPath.ts\";\nimport { useOnPathFocus } from \"../FormApp\";\nimport { useSetLatestInteraction } from \"../FormApp/FormAppContext.ts\";\nimport type { FormPageObject } from \"./FormPage.tsx\";\nimport type { FormPagesProps } from \"./FormPages.tsx\";\n\n/** Value of the form pages context. */\nexport type FormPagesContextValue = FormPagesStore;\n\n/** Resolved form page object. */\nexport interface ResolvedFormPageObject extends FormPageObject {\n path: AbsolutePath;\n}\n\n/** Form page state. */\nexport interface FormPageState {\n path: AbsolutePath;\n exists: boolean;\n deferredDisplayStatus: DisplayStatus | undefined;\n deferredIssuesToDisplay: SealedValidationIssue[];\n title?: ReactNode;\n documentTitle?: string | null;\n code?: ReactNode;\n visuallyHiddenCodePrefix?: ReactNode;\n}\n\n/** State of the form pages. */\nexport interface FormPagesState {\n pages: ResolvedFormPageObject[];\n activePage: AbsolutePath | null;\n activePageIndex: () => number;\n // State below is wrapped in an array in order to trigger state updates by\n // simply changing the identity of the wrapper without creating new object\n // instances\n pageStates: [Record<string, FormPageState | null>];\n pageHeaderHeights: [Map<string, number>];\n navigationSelectHeight: number;\n actions: FormPagesActions;\n}\n\n/** Actions of the form pages. */\nexport interface FormPagesActions {\n getPageState: (path: AbsolutePath) => FormPageState | null;\n setPages: (pages: ResolvedFormPageObject[]) => void;\n setActivePage: (activePage: string | Path | null) => void;\n updateActivePage: (oldActivePageIndex: number) => void;\n registerPageState: (path: AbsolutePath, state: FormPageState) => void;\n setPageHeaderHeight: (path: AbsolutePath, height: number | null) => void;\n}\n\n/** Form pages store. */\nexport type FormPagesStore = ReturnType<typeof useCreateFormPagesContext>;\n\n/** Form pages context. */\nexport const FormPagesContext = createContext<FormPagesContextValue | null>(\n null,\n);\n\n/** Options used to create the form pages context. */\nexport interface UseCreateFormPagesContextOptions extends Pick<\n FormPagesProps,\n \"defaultActivePage\" | \"activePage\" | \"onActivePageChange\"\n> {\n basePath: AbsolutePath;\n resolvedPages: ResolvedFormPageObject[];\n}\n\n/** Hook used to create the form pages context. */\nexport function useCreateFormPagesContext({\n basePath,\n resolvedPages,\n defaultActivePage,\n activePage,\n onActivePageChange,\n}: UseCreateFormPagesContextOptions) {\n const setLatestInteraction = useSetLatestInteraction();\n const { activePath, onActivePathChange } = useActivePathContext();\n activePage ??= activePath;\n\n const latestRef = useLatestRef({\n printing: usePrinting(),\n onActivePathChange,\n onActivePageChange,\n });\n const store = useConstant(() =>\n createStore<FormPagesState>()(\n subscribeWithSelector((set, get) => ({\n pages: resolvedPages,\n activePage:\n activePage === undefined\n ? defaultActivePage == null\n ? null\n : basePath.resolve(defaultActivePage)\n : activePage === null\n ? null\n : basePath.resolve(activePage),\n activePageIndex: computed(\n () => [get().pages, get().activePage],\n (pages, activePage) =>\n activePage === null\n ? -1\n : pages.findIndex((page) => page.path.equals(activePage)),\n ),\n pageStates: [{}],\n pageHeaderHeights: [new Map()],\n navigationSelectHeight: 0,\n actions: {\n getPageState: (path) => get().pageStates[0][path.toString()] ?? null,\n setPages: (pages) => {\n const oldActivePageIndex = get().activePageIndex();\n const newPageStates: Record<string, FormPageState | null> = {};\n for (const page of pages) {\n newPageStates[page.path.toString()] = get().actions.getPageState(\n page.path,\n );\n }\n set({ pages, pageStates: [newPageStates] });\n get().actions.updateActivePage(oldActivePageIndex);\n },\n setActivePage: (path: string | Path | null) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const newActivePage =\n path === null || path instanceof AbsolutePath\n ? path\n : new AbsolutePath(path);\n const oldActivePage = get().activePage;\n if (!oldActivePage?.equals(newActivePage)) {\n startTransition(() => {\n set({ activePage: newActivePage });\n if (newActivePage != null) {\n setLatestInteraction(newActivePage);\n }\n latestRef.current.onActivePathChange(newActivePage);\n latestRef.current.onActivePageChange?.(newActivePage);\n });\n }\n },\n updateActivePage: (oldActivePageIndex: number) => {\n if (\n latestRef.current.printing ||\n (get().activePage !== null &&\n get().pages.some((page) => page.path.equals(get().activePage)))\n ) {\n return;\n }\n\n get().actions.setActivePage(\n get().pages[\n Math.max(\n 0,\n Math.min(oldActivePageIndex, get().pages.length - 1),\n )\n ]?.path ?? null,\n );\n },\n registerPageState: (path, state) => {\n const oldActivePageIndex = get().activePageIndex();\n const pageStates = get().pageStates[0];\n pageStates[path.toString()] = state;\n set({ pageStates: [pageStates] });\n get().actions.updateActivePage(oldActivePageIndex);\n },\n setPageHeaderHeight: (path, height) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const {\n pageHeaderHeights: [pageHeaderHeights],\n } = get();\n if (height != null) {\n pageHeaderHeights.set(path.toString(), height);\n } else {\n pageHeaderHeights.delete(path.toString());\n }\n set({ pageHeaderHeights: [pageHeaderHeights] });\n },\n },\n })),\n ),\n );\n\n // Update store when params change\n useEffect(() => {\n store.getState().actions.setPages(resolvedPages);\n if (activePage !== undefined) {\n const { pages, activePage: oldActivePage } = store.getState();\n store.getState().actions.setActivePage(\n mostSpecificPath(\n activePage === null ? null : basePath.resolve(activePage),\n pages.map((page) => page.path),\n oldActivePage,\n ) ?? null,\n );\n }\n }, [resolvedPages, activePage, basePath, store]);\n\n // Set (possibly new) active page when focused path changes\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n const { pages, activePage, actions } = store.getState();\n actions.setActivePage(\n mostSpecificPath(\n focusedPath,\n pages.map((page) => page.path),\n activePage,\n ) ?? null,\n );\n },\n [store],\n ),\n );\n\n return store;\n}\n\nexport function useFormPagesContext(): FormPagesContextValue {\n const formPagesContext = useContext(FormPagesContext);\n if (!formPagesContext) {\n throw new Error(\"Form pages context not in scope.\");\n }\n return formPagesContext;\n}\n\nexport function useFormPageState<T>(\n path: AbsolutePath,\n selector: (state: FormPageState | null) => T,\n): T {\n return useStore(useFormPagesContext(), (state) =>\n selector(state.actions.getPageState(path)),\n );\n}\n","import { faCircleQuestion } from \"@fortawesome/free-solid-svg-icons\";\nimport { useCurrentPath } from \"@ostack.tech/kform-react\";\nimport {\n boolDataAttr,\n controlStatusToAccent,\n cx,\n IconButton,\n Layer,\n Popover,\n PopoverContent,\n PopoverTrigger,\n Stack,\n usePrinting,\n VisuallyHidden,\n} from \"@ostack.tech/ui\";\nimport type { ComponentProps } from \"react\";\nimport { useShallow } from \"zustand/react/shallow\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useIssuesDisplayMode } from \"../FormApp\";\nimport { IssueMessages } from \"../IssueMessages\";\nimport { IssuesPopover } from \"../IssuesPopover\";\nimport type { FormPageProps } from \"./FormPage.tsx\";\nimport { useFormPageState } from \"./FormPagesContext.ts\";\n\n/** Properties of the form page header. */\nexport interface FormPageHeaderProps\n extends\n ComponentProps<\"div\">,\n Pick<\n FormPageProps,\n | \"helperText\"\n | \"helperButtonLabel\"\n | \"ownIssueMessages\"\n | \"codeProps\"\n | \"titleProps\"\n | \"headerPopoverContainerProps\"\n | \"issuesPopoverProps\"\n | \"issueMessagesProps\"\n | \"helperButtonProps\"\n | \"helperPopoverProps\"\n | \"helperPopoverContentProps\"\n > {}\n\n/** Form page header. */\nexport function FormPageHeader({\n helperText,\n helperButtonLabel,\n ownIssueMessages,\n codeProps,\n titleProps,\n headerPopoverContainerProps,\n issuesPopoverProps,\n issueMessagesProps,\n helperButtonProps,\n helperPopoverProps,\n helperPopoverContentProps,\n className,\n ...otherProps\n}: FormPageHeaderProps) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n const printing = usePrinting();\n const currentPath = useCurrentPath();\n const issuesDisplayMode = useIssuesDisplayMode();\n\n const deferredIssuesToDisplay =\n useFormPageState(\n currentPath,\n useShallow(\n (state) =>\n (!printing &&\n issuesDisplayMode === \"inline\" &&\n state?.deferredIssuesToDisplay) ||\n [],\n ),\n ) ?? [];\n const deferredDisplayStatus = useFormPageState(currentPath, (state) =>\n printing ? undefined : state?.deferredDisplayStatus,\n );\n const code = useFormPageState(currentPath, (state) => state?.code);\n const title = useFormPageState(currentPath, (state) => state?.title);\n const visuallyHiddenCodePrefix = useFormPageState(\n currentPath,\n (state) =>\n state?.visuallyHiddenCodePrefix ??\n locale.FormPage.visuallyHiddenCodePrefix,\n );\n\n return (\n <Layer zIndex={[\"sticky\", -2]}>\n <div\n className={cx(prefix(\"form-pages__page-header\"), className)}\n {...otherProps}\n data-has-popovers={boolDataAttr(\n helperText != null || deferredIssuesToDisplay.length > 0,\n )}\n >\n {/* Form page title */}\n <h2\n tabIndex={-1}\n {...titleProps}\n className={cx(\n prefix(\"form-pages__page-title\"),\n titleProps?.className,\n )}\n >\n {/* Form page code */}\n <span\n {...codeProps}\n className={cx(\n prefix(\"form-pages__page-code\"),\n codeProps?.className,\n )}\n data-status={displayStatusToControlStatus(deferredDisplayStatus)}\n data-accent={controlStatusToAccent(\n displayStatusToControlStatus(deferredDisplayStatus),\n )}\n >\n {code != null && typeof code !== \"boolean\" && (\n <>\n {visuallyHiddenCodePrefix && (\n <VisuallyHidden>{visuallyHiddenCodePrefix} </VisuallyHidden>\n )}\n {code}\n <VisuallyHidden>, </VisuallyHidden>\n </>\n )}\n </span>\n\n {title}\n </h2>\n\n {/* Form page issues */}\n {!printing && (\n <Stack\n direction=\"row\"\n gap={0}\n {...headerPopoverContainerProps}\n className={cx(\n prefix(\"form-pages__page-header-popovers\"),\n headerPopoverContainerProps?.className,\n )}\n >\n {issuesDisplayMode === \"inline\" && (\n <IssuesPopover\n side=\"bottom\"\n {...issuesPopoverProps}\n iconButtonProps={{\n className: cx(\n prefix(\"form-pages__page-issues-popover-button\"),\n issuesPopoverProps?.iconButtonProps?.className,\n ),\n ...issuesPopoverProps?.iconButtonProps,\n }}\n >\n <IssueMessages\n issues={deferredIssuesToDisplay}\n messages={ownIssueMessages}\n {...issueMessagesProps}\n />\n </IssuesPopover>\n )}\n\n {/* Form page helper text */}\n {helperText && (\n <Popover modal={false} {...helperPopoverProps}>\n <PopoverTrigger>\n <IconButton\n circle\n color=\"primary\"\n variant=\"ghost\"\n icon={faCircleQuestion}\n label={helperButtonLabel ?? \"\"}\n {...helperButtonProps}\n tooltipProps={{\n side: \"bottom\",\n ...helperButtonProps?.tooltipProps,\n }}\n className={cx(\n prefix(\"form-pages__page-helper-button\"),\n helperButtonProps?.className,\n )}\n />\n </PopoverTrigger>\n\n <PopoverContent\n {...helperPopoverContentProps}\n className={cx(\n prefix(\"form-pages__page-helper-popover\"),\n helperPopoverContentProps?.className,\n )}\n >\n {helperText}\n </PopoverContent>\n </Popover>\n )}\n </Stack>\n )}\n </div>\n </Layer>\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport { CurrentPath, useResolvedPath } from \"@ostack.tech/kform-react\";\nimport {\n Container,\n type ContainerProps,\n cx,\n DocumentTitle,\n ErrorBoundary,\n type ErrorBoundaryProps,\n type IconButtonProps,\n type PopoverContentProps,\n type PopoverProps,\n Spinner,\n type StackProps,\n useCombinedRef,\n useMeasure,\n usePrinting,\n warnOnce,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type ReactNode,\n Suspense,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport {\n FormAppIssueMessages,\n FormAppStatus,\n useFormAppElement,\n} from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport type { IssuesPopoverProps } from \"../IssuesPopover\";\nimport { FormPageHeader } from \"./FormPageHeader.tsx\";\nimport { useFormPagesContext, useFormPageState } from \"./FormPagesContext.ts\";\n\n/** Object representation of a form page. */\nexport interface FormPageObject<T = any> {\n /** Form page path. */\n path?: string | Path;\n /** Form page's title */\n title?: ReactNode | ((value: T) => ReactNode);\n /**\n * Title of the form page as a string to display in the document's title.\n *\n * Defaults to `title` when it is a string. A warning is printed if `title` is\n * not a string and `documentTitle` is not provided.\n */\n documentTitle?: string | null | ((value: T) => string | null);\n /** Form page's code. */\n code?: ReactNode;\n /** Form page's label in the issues panel. The `title` is used by default. */\n issuesPanelLabel?: ReactNode | ((value: T) => ReactNode);\n}\n\n/** Properties of the form page component. */\nexport interface FormPageProps\n extends\n FormPageObject,\n Omit<ComponentProps<\"section\">, \"title\" | \"children\"> {\n /** Sets the form page as disabled. */\n disabled?: boolean;\n /** Sets the form page as read-only. */\n readOnly?: boolean;\n /** Form page helper text, displayed as a popover triggered by an icon button. */\n helperText?: ReactNode;\n /**\n * Mapping of issue messages from the path of the field with issues to the\n * issue messages of said field (which are themselves grouped by their code).\n *\n * Provided paths are relative to the form page's path and may contain\n * wildcards, which will have a lower priority when matched against.\n *\n * These messages are used by the `IssueMessages` component.\n *\n * > **Note:** Changes to `issueMessages` are handled correctly, but are not\n * > efficient. Please make sure that the identity of the provided value doesn't\n * > change at every render.\n *\n * Example value:\n *\n * ```tsx\n * {\n * \"**\": {\n * \"valueMissing\": \"Field is required.\"\n * },\n * \"field\": {\n * \"valueMissing\": \"My field cannot be left empty!\",\n * \"someOtherError\": \"Text of the other error.\"\n * }\n * }\n * ```\n */\n issueMessages?: Record<string, IssueMessagesByCode>;\n /**\n * Issue messages of the form page itself.\n *\n * These messages can also be provided via the `issueMessages` property using\n * a path of \"`.`\".\n */\n ownIssueMessages?: IssueMessagesByCode;\n /** Properties to pass to the header element. */\n headerProps?: ComponentProps<\"div\">;\n /** Label of the helper button announced to assistive technologies. */\n helperButtonLabel?: string;\n /**\n * Visually hidden prefix added to the form page code announced to assistive\n * technologies.\n */\n visuallyHiddenCodePrefix?: ReactNode;\n /** Properties to pass to the code element. */\n codeProps?: ComponentProps<\"div\">;\n /** Properties to pass to the title element. */\n titleProps?: ComponentProps<\"h2\">;\n /**\n * Properties to pass to the element containing the popover components in the\n * header.\n */\n headerPopoverContainerProps?: StackProps;\n /** Properties to pass to the form page's issues popover component. */\n issuesPopoverProps?: IssuesPopoverProps;\n /** Properties to pass to the form page's issue messages component. */\n issueMessagesProps?: Omit<IssueMessagesProps, \"messages\">;\n /** Properties to pass to the content element. */\n contentProps?: ComponentProps<\"div\">;\n /** Properties to pass to the container component. */\n containerProps?: ContainerProps;\n /** Properties to pass to the `ErrorBoundary` component. */\n errorBoundaryProps?: ErrorBoundaryProps;\n /** Properties to pass to the helper button component. */\n helperButtonProps?: Omit<IconButtonProps, \"icon\">;\n /** Properties to pass to the helper popover component. */\n helperPopoverProps?: PopoverProps;\n /** Properties to pass to the helper popover content component. */\n helperPopoverContentProps?: PopoverContentProps;\n children?: ReactNode;\n}\n\n/** Component representing a single form page. */\nexport function FormPage({\n path,\n // `FormPageObject` props\n title: _title,\n documentTitle: _documentTitle,\n code: _code,\n issuesPanelLabel: _issuesPanelLabel,\n disabled = false,\n readOnly = false,\n className,\n helperText,\n helperButtonLabel,\n visuallyHiddenCodePrefix: _visuallyHiddenCodePrefix,\n issueMessages,\n ownIssueMessages,\n headerProps,\n codeProps,\n titleProps,\n headerPopoverContainerProps,\n issuesPopoverProps,\n issueMessagesProps,\n contentProps,\n containerProps,\n errorBoundaryProps,\n helperButtonProps,\n helperPopoverProps,\n helperPopoverContentProps,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n ...otherProps\n}: FormPageProps) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n helperButtonLabel ??= locale.FormPage.helperButtonLabel;\n const printing = usePrinting();\n\n const generatedId = useId();\n const titleId = titleProps?.id ?? prefix(`form-page-title-${generatedId}`);\n\n const store = useFormPagesContext();\n const pagePath = useResolvedPath(path);\n\n const activePage = useStore(store, (state) => state.activePage);\n const shouldDisplay = useFormPageState(pagePath, (state) =>\n state?.path.equals(activePage),\n );\n const documentTitle = useFormPageState(pagePath, (state) =>\n state === null ? null : state.documentTitle,\n );\n\n if (documentTitle === undefined) {\n warnOnce(\n `FormPage: At '${pagePath.toString()}': \\`documentTitle\\` ` +\n \"should be set manually since the form page's `title` is not a string.\",\n );\n }\n\n // Keep track of the page header's height\n const [headerEl, setHeaderEl] = useState<HTMLDivElement | null>(null);\n useMeasure(\n headerEl,\n useCallback(\n (measurement) => {\n store\n .getState()\n .actions.setPageHeaderHeight(pagePath, measurement?.height ?? null);\n },\n [pagePath, store],\n ),\n );\n\n // Scroll to the top of the form app whenever we change into a new page (but\n // only if we've scrolled past the top of the form app)\n const formAppEl = useFormAppElement();\n const prevShouldDisplayRef = useRef(shouldDisplay);\n useEffect(() => {\n if (printing) {\n return;\n }\n if (\n shouldDisplay &&\n !prevShouldDisplayRef.current &&\n formAppEl.getBoundingClientRect().top < 0\n ) {\n formAppEl.scrollIntoView(true);\n }\n prevShouldDisplayRef.current = shouldDisplay;\n }, [formAppEl, printing, shouldDisplay]);\n\n const combinedHeaderRef = useCombinedRef(setHeaderEl, headerProps?.ref);\n if (!shouldDisplay && !printing) {\n return null;\n }\n return (\n <CurrentPath path={pagePath}>\n <DocumentTitle\n title={printing ? undefined : (documentTitle ?? undefined)}\n >\n <section\n className={cx(prefix(\"form-pages__page\"), className)}\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy ?? (ariaLabel === undefined ? titleId : undefined)\n }\n {...otherProps}\n >\n <FormAppStatus disabled={disabled} readOnly={readOnly}>\n <FormAppIssueMessages issueMessages={issueMessages}>\n <FormPageHeader\n helperText={helperText}\n helperButtonLabel={helperButtonLabel}\n ownIssueMessages={ownIssueMessages}\n codeProps={codeProps}\n titleProps={{ ...titleProps, id: titleId }}\n headerPopoverContainerProps={headerPopoverContainerProps}\n issuesPopoverProps={issuesPopoverProps}\n issueMessagesProps={issueMessagesProps}\n helperButtonProps={helperButtonProps}\n helperPopoverProps={helperPopoverProps}\n helperPopoverContentProps={helperPopoverContentProps}\n {...headerProps}\n ref={combinedHeaderRef}\n />\n\n <div\n {...contentProps}\n className={cx(\n prefix(\"form-pages__page-content\"),\n contentProps?.className,\n )}\n >\n <Container fluid=\"xxl\" gutter={0} {...containerProps}>\n <ErrorBoundary {...errorBoundaryProps}>\n <Suspense fallback={<Spinner size=\"xl\" color=\"primary\" />}>\n {children}\n </Suspense>\n </ErrorBoundary>\n </Container>\n </div>\n </FormAppIssueMessages>\n </FormAppStatus>\n </section>\n </DocumentTitle>\n </CurrentPath>\n );\n}\n","import { AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { CurrentPath, useController } from \"@ostack.tech/kform-react\";\nimport { usePrinting, useStartPrintingTask } from \"@ostack.tech/ui\";\nimport { useDeferredValue, useEffect } from \"react\";\nimport { shallow } from \"zustand/shallow\";\n\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterController, useRegisterLabel } from \"../FormApp\";\nimport {\n type ResolvedFormPageObject,\n useFormPagesContext,\n} from \"./FormPagesContext.ts\";\n\n/** Properties of the `FormPageRegistrar` component. */\nexport interface FormPageRegistrarProps extends ResolvedFormPageObject {}\n\n/** Component used to register a form page. */\nexport function FormPageRegistrar({\n path,\n title,\n documentTitle,\n code,\n issuesPanelLabel,\n}: FormPageRegistrarProps) {\n const store = useFormPagesContext();\n\n const printing = usePrinting();\n const finishPrintingTask = useStartPrintingTask();\n const observeDescendants =\n typeof title === \"function\" || typeof documentTitle === \"function\";\n const controller = useController(\n observeDescendants\n ? path.append(AbsolutePathFragment.RecursiveWildcard)\n : path,\n { enabled: !useFormIsLoading(), onInitialized: finishPrintingTask },\n );\n const absolutePath = controller.usePath();\n const exists = controller.useState(\n (state) => state.initialized && state.exists,\n );\n const value = controller.useValue();\n const deferredValue = useDeferredValue(value);\n const relevantValue = printing ? value : deferredValue;\n const deferredIssuesToDisplay = useDeferredValue(\n controller.useState((state) => (state.touched ? state.issues : []), {\n equalityFn: shallow,\n }),\n );\n const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());\n\n const actualTitle =\n typeof title === \"function\"\n ? relevantValue === undefined\n ? null\n : title(relevantValue)\n : title;\n const actualDocumentTitle =\n typeof documentTitle === \"function\"\n ? relevantValue === undefined\n ? null\n : documentTitle(relevantValue)\n : documentTitle === undefined\n ? actualTitle === null || typeof actualTitle === \"string\"\n ? actualTitle\n : undefined\n : documentTitle;\n\n useEffect(() => {\n const { registerPageState } = store.getState().actions;\n registerPageState(absolutePath, {\n exists,\n path: absolutePath,\n deferredIssuesToDisplay,\n deferredDisplayStatus,\n title: actualTitle,\n documentTitle: actualDocumentTitle,\n code,\n });\n }, [\n absolutePath,\n actualDocumentTitle,\n actualTitle,\n code,\n deferredDisplayStatus,\n deferredIssuesToDisplay,\n exists,\n store,\n title,\n ]);\n\n useRegisterController(controller);\n useRegisterLabel(\n absolutePath,\n <CurrentPath path={absolutePath}>\n {typeof issuesPanelLabel === \"function\"\n ? deferredValue === undefined\n ? null\n : issuesPanelLabel(deferredValue)\n : issuesPanelLabel || actualTitle}\n </CurrentPath>,\n );\n\n return null;\n}\n","import {\n type AbsolutePath,\n AbsolutePathFragment,\n Path,\n} from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n useFormManager,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport {\n cx,\n parseChildren,\n useCombinedRef,\n useCssVars,\n useMediaBreakpointUp,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { FormPage, type FormPageObject } from \"./FormPage.tsx\";\nimport { FormPageRegistrar } from \"./FormPageRegistrar.tsx\";\nimport {\n FormPagesContext,\n useCreateFormPagesContext,\n} from \"./FormPagesContext.ts\";\n\n/** Properties of the form page component. */\nexport interface FormPagesProps extends ComponentProps<\"div\"> {\n /** Base path for all declared form pages. */\n path?: string | Path;\n /**\n * List of all form pages. When not provided, the list of pages is obtained\n * from the direct children `FormPage` components.\n */\n pages?: FormPageObject[];\n /** Default path of the active form page. */\n defaultActivePage?: string | Path;\n /** Controlled path of the active form page. */\n activePage?: string | Path;\n /**\n * Function called whenever the active form page changes.\n *\n * @param activePagePath Path of the new active form page.\n */\n onActivePageChange?: (activePagePath: AbsolutePath | null) => void;\n children?: ReactNode;\n}\n\n/**\n * The form pages component can be used to split parts of a form into separate\n * pages, while providing means of navigating between them. Although not\n * strictly mandatory, each page is typically represented by its own class, with\n * its own schema and distinct path.\n *\n * It composes the following subcomponents:\n *\n * - `FormPagesNavigation`: Component used to navigate between form pages.\n * - `FormPage`: The content of a single page of the form.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * FormPage,\n * FormPages,\n * FormPagesNavigation,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function TaxWithholdingPages() {\n * return (\n * <FormPages>\n * <FormPagesNavigation />\n * <FormPage path=\"/fillingInfo\" title=\"Filing information\" code=\"0\">\n * Filing information page…\n * </FormPage>\n * <FormPage\n * path=\"/exemptions\"\n * title=\"Exemptions & declarations\"\n * code=\"1\"\n * >\n * Exemptions & declarations page…\n * </FormPage>\n * </FormPages>\n * );\n * }\n * ```\n */\nexport function FormPages({\n path,\n pages,\n defaultActivePage,\n activePage,\n onActivePageChange,\n className,\n children,\n ref,\n ...otherProps\n}: FormPagesProps) {\n const prefix = usePrefix();\n const { cssVarName } = useCssVars({ prefix });\n const formManager = useFormManager();\n const absolutePath = useResolvedPath(path);\n const isLargeScreen = useMediaBreakpointUp(\"sm\");\n\n // Get form pages from children if not provided as prop\n pages ??= parseChildren(children, FormPage, {\n renderUnknownComponents: false,\n });\n\n // Provided pages but with absolute paths\n const resolvedPages = useMemo(\n () =>\n pages.map((page) => ({\n ...page,\n path: absolutePath.resolve(page.path ?? Path.CURRENT),\n })),\n [absolutePath, pages],\n );\n\n // Refuse non-existent paths\n if (!formManager.isValidPath(absolutePath)) {\n throw new Error(`Invalid path: '${absolutePath.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n absolutePath.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Form pages base path must only contain ids.\");\n }\n // Validate form page paths\n for (const page of resolvedPages) {\n // Refuse non-existent paths\n if (!formManager.isValidPath(page.path)) {\n throw new Error(`Invalid path: '${page.path.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n page.path.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Form page path must only contain ids.\");\n }\n }\n\n const store = useCreateFormPagesContext({\n basePath: absolutePath,\n resolvedPages,\n defaultActivePage,\n activePage,\n onActivePageChange,\n });\n\n const formPagesRef = useRef<HTMLDivElement | null>(null);\n\n // Active page header height\n useEffect(\n () =>\n store.subscribe(\n ({ activePage, pageHeaderHeights: [pageHeaderHeights] }) =>\n (activePage && pageHeaderHeights.get(activePage.toString())) ?? 0,\n (height) =>\n formPagesRef.current?.style.setProperty(\n cssVarName(\"form-pages-page-header-height\"),\n `${height}px`,\n ),\n { fireImmediately: true },\n ),\n [cssVarName, prefix, store],\n );\n\n // Navigation select height\n useEffect(\n () =>\n store.subscribe(\n ({ navigationSelectHeight }) => navigationSelectHeight,\n (height) =>\n formPagesRef.current?.style.setProperty(\n cssVarName(\"form-pages-navigation-select-height\"),\n `${height}px`,\n ),\n { fireImmediately: true },\n ),\n [cssVarName, prefix, store],\n );\n\n const combinedFormPagesRef = useCombinedRef(formPagesRef, ref);\n return (\n <CurrentPath path={absolutePath}>\n <FormPagesContext.Provider value={store}>\n {resolvedPages.map((page) => (\n <FormPageRegistrar key={page.path.toString()} {...page} />\n ))}\n\n <div\n className={cx(prefix(\"form-pages\"), className)}\n data-navigation-mode={isLargeScreen ? \"sidebar\" : \"select\"}\n {...otherProps}\n ref={combinedFormPagesRef}\n >\n {children}\n </div>\n </FormPagesContext.Provider>\n </CurrentPath>\n );\n}\n","import type { AbsolutePath } from \"@ostack.tech/kform\";\nimport { CurrentPath } from \"@ostack.tech/kform-react\";\nimport { controlStatusToAccent, Option } from \"@ostack.tech/ui\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useFormPageState } from \"./FormPagesContext.ts\";\n\ninterface FormPagesSelectOptionProps {\n path: AbsolutePath;\n}\n\nexport function FormPagesSelectOption({ path }: FormPagesSelectOptionProps) {\n const prefix = usePrefix();\n const disabled = useFormPageState(path, (state) => !state?.exists);\n const deferredDisplayStatus = useFormPageState(\n path,\n (state) => state?.deferredDisplayStatus,\n );\n const code = useFormPageState(path, (state) => state?.code);\n const title = useFormPageState(path, (state) => state?.title);\n const controlStatus = displayStatusToControlStatus(deferredDisplayStatus);\n const accent = controlStatusToAccent(controlStatus, \"primary\");\n\n return (\n <CurrentPath path={path}>\n <Option\n value={path.toString()}\n keywords={[\n ...(typeof code === \"string\" ? [code] : []),\n ...(typeof title === \"string\" ? [title] : []),\n ]}\n className={prefix(\"form-pages__select-option\")}\n color={accent}\n disabled={disabled}\n iconProps={{\n className: prefix(\"form-pages__select-option-indicator\"),\n }}\n >\n <span\n className={prefix(\"form-pages__select-option-code\")}\n data-status={controlStatus}\n data-accent={accent}\n >\n {code}\n </span>\n {title}\n </Option>\n </CurrentPath>\n );\n}\n","import { AbsolutePath } from \"@ostack.tech/kform\";\nimport {\n cx,\n Select,\n type SelectSingleProps,\n useCombinedRef,\n useMeasure,\n} from \"@ostack.tech/ui\";\nimport { useCallback, useState } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useFormPagesContext } from \"./FormPagesContext.ts\";\nimport { FormPagesSelectOption } from \"./FormPagesSelectOption.tsx\";\n\n/** Properties of the form pages select component. */\nexport interface FormPagesSelectProps extends Omit<\n SelectSingleProps,\n \"defaultValue\" | \"value\" | \"onValueChange\" | \"showClearButton\"\n> {}\n\n/** Select component allowing the navigation between form pages. */\nexport function FormPagesSelect({\n rootProps,\n containerProps,\n valueProps,\n arrowProps,\n popoverProps,\n commandMenuProps,\n className,\n ...otherProps\n}: FormPagesSelectProps) {\n const prefix = usePrefix();\n const store = useFormPagesContext();\n const activePage = useStore(store, (state) => state.activePage);\n\n // Keep track of the select root's height\n const [selectRootEl, setSelectRootEl] = useState<HTMLDivElement | null>(null);\n useMeasure(\n selectRootEl,\n useCallback(\n (measurement) => {\n store.setState({ navigationSelectHeight: measurement?.height ?? 0 });\n },\n [store],\n ),\n );\n\n const handleValueChange = useCallback(\n (value: string) =>\n value && store.getState().actions.setActivePage(new AbsolutePath(value)),\n [store],\n );\n\n const pages = useStore(store, (state) => state.pages);\n return (\n <Select\n className={cx(prefix(\"form-pages__select\"), className)}\n value={activePage?.toString() ?? \"\"}\n onValueChange={handleValueChange}\n showClearButton={false}\n rootProps={{\n ...rootProps,\n ref: useCombinedRef(\n setSelectRootEl as (el: HTMLDivElement) => void,\n rootProps?.ref,\n ),\n }}\n containerProps={{\n ...containerProps,\n className: cx(\n prefix(\"form-pages__select-container\"),\n containerProps?.className,\n ),\n }}\n valueProps={{\n ...valueProps,\n className: cx(\n prefix(\"form-pages__select-value\"),\n valueProps?.className,\n ),\n }}\n arrowProps={{\n ...arrowProps,\n className: cx(\n prefix(\"form-pages__select-arrow\"),\n arrowProps?.className,\n ),\n }}\n popoverProps={{\n ...popoverProps,\n className: cx(\n prefix(\"form-pages__select-popover\"),\n popoverProps?.className,\n ),\n }}\n commandMenuProps={{ variant: \"subtle\", ...commandMenuProps }}\n {...otherProps}\n >\n {pages.map((page) => (\n <FormPagesSelectOption key={page.path.toString()} path={page.path} />\n ))}\n </Select>\n );\n}\n","import type { AbsolutePath } from \"@ostack.tech/kform\";\nimport { CurrentPath } from \"@ostack.tech/kform-react\";\nimport {\n boolDataAttr,\n controlStatusToAccent,\n MenuListItem,\n VisuallyHidden,\n} from \"@ostack.tech/ui\";\nimport { useCallback, useRef } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { visiblyFocus } from \"../../utils/useControlAutofocus.ts\";\nimport { useIssuesDisplayMode, useOnPathFocus } from \"../FormApp\";\nimport { useResetFocus } from \"../FormApp/FormAppContext.ts\";\nimport { useFormPagesContext, useFormPageState } from \"./FormPagesContext.ts\";\n\ninterface FormPageSidebarItemProps {\n path: AbsolutePath;\n}\n\nexport function FormPageSidebarItem({ path }: FormPageSidebarItemProps) {\n const [locale] = useLocale();\n const prefix = usePrefix();\n const store = useFormPagesContext();\n const activePage = useStore(store, (state) => state.activePage);\n\n const handleClick = () => store.getState().actions.setActivePage(path);\n\n const disabled = useFormPageState(path, (state) => !state?.exists);\n const deferredDisplayStatus = useFormPageState(\n path,\n (state) => state?.deferredDisplayStatus,\n );\n const code = useFormPageState(path, (state) => state?.code);\n const title = useFormPageState(path, (state) => state?.title);\n const visuallyHiddenCodePrefix = useFormPageState(\n path,\n (state) =>\n state?.visuallyHiddenCodePrefix ??\n locale.FormPage.visuallyHiddenCodePrefix,\n );\n\n const issuesDisplayMode = useIssuesDisplayMode();\n const itemActionRef = useRef<HTMLButtonElement | null>(null);\n const resetFocus = useResetFocus();\n useOnPathFocus(\n useCallback(\n (focusedPath: AbsolutePath) => {\n if (itemActionRef.current && path.equals(focusedPath)) {\n // In inline mode the issues popover should get focused instead\n if (issuesDisplayMode === \"panel\") {\n visiblyFocus(itemActionRef.current);\n }\n // Let the form page be opened before resetting focus\n setTimeout(() => resetFocus());\n }\n },\n [issuesDisplayMode, path, resetFocus],\n ),\n );\n\n const isSelected = activePage?.equals(path);\n return (\n <MenuListItem\n className={prefix(\"form-pages__sidebar-item\")}\n selected={isSelected}\n disabled={disabled}\n onSelect={handleClick}\n color=\"primary\"\n contentProps={{ className: prefix(\"form-pages__sidebar-item-content\") }}\n actionProps={{\n \"aria-current\": isSelected ? \"page\" : undefined,\n \"aria-invalid\": deferredDisplayStatus === \"error\" || undefined,\n ref: itemActionRef,\n }}\n >\n <CurrentPath path={path}>\n <span\n className={prefix(\"form-pages__sidebar-item-code\")}\n data-selected={boolDataAttr(isSelected)}\n data-status={displayStatusToControlStatus(deferredDisplayStatus)}\n data-accent={controlStatusToAccent(\n displayStatusToControlStatus(deferredDisplayStatus),\n )}\n >\n {code != null && typeof code !== \"boolean\" && (\n <>\n {visuallyHiddenCodePrefix && (\n <VisuallyHidden>{visuallyHiddenCodePrefix} </VisuallyHidden>\n )}\n {code}\n <VisuallyHidden>, </VisuallyHidden>\n </>\n )}\n </span>\n {title}\n </CurrentPath>\n </MenuListItem>\n );\n}\n","import { AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { useFormContext } from \"@ostack.tech/kform-react\";\nimport { cx, MenuList, useCombinedRef, useMeasure } from \"@ostack.tech/ui\";\nimport { type ComponentProps, useCallback, useState } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useSetLeftSidebarWidth } from \"../FormApp\";\nimport { useFormPagesContext } from \"./FormPagesContext.ts\";\nimport { FormPageSidebarItem } from \"./FormPageSidebarItem.tsx\";\n\n/** Properties of the form pages sidebar component. */\nexport interface FormPagesSidebarProps extends ComponentProps<\"div\"> {}\n\n/** Sidebar component allowing the navigation between form pages. */\nexport function FormPagesSidebar({\n className,\n ref,\n ...otherProps\n}: FormPagesSidebarProps) {\n const prefix = usePrefix();\n const store = useFormPagesContext();\n const { currentPath } = useFormContext();\n const activePage = useStore(store, (state) => state.activePage);\n const setLeftSidebarWidth = useSetLeftSidebarWidth();\n\n // Inform form app of \"active\" form pages navigation components (affect the\n // positioning of the issues panel when the sidebar is visible)\n const [sidebarEl, setSidebarEl] = useState<HTMLDivElement | null>(null);\n useMeasure(\n sidebarEl,\n useCallback(\n (measurement) => {\n if (\n activePage &&\n currentPath\n .append(AbsolutePathFragment.RecursiveWildcard)\n .contains(activePage)\n ) {\n setLeftSidebarWidth(measurement?.width);\n }\n },\n [activePage, currentPath, setLeftSidebarWidth],\n ),\n );\n\n const pages = useStore(store, (state) => state.pages);\n const combinedSidebarRef = useCombinedRef(setSidebarEl, ref);\n return (\n <div\n className={cx(prefix(\"form-pages__sidebar\"), className)}\n {...otherProps}\n ref={combinedSidebarRef}\n >\n <MenuList>\n {pages.map((page) => (\n <FormPageSidebarItem key={page.path.toString()} path={page.path} />\n ))}\n </MenuList>\n </div>\n );\n}\n","import {\n cx,\n Layer,\n useMediaBreakpointUp,\n usePrintClassNames,\n} from \"@ostack.tech/ui\";\nimport type { ComponentProps } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport {\n FormPagesSelect,\n type FormPagesSelectProps,\n} from \"./FormPagesSelect.tsx\";\nimport {\n FormPagesSidebar,\n type FormPagesSidebarProps,\n} from \"./FormPagesSidebar.tsx\";\n\n/** Properties of the form pages navigation component. */\nexport interface FormPagesNavigationProps extends ComponentProps<\"nav\"> {\n /** Properties to pass to the sidebar component. */\n sidebarProps?: FormPagesSidebarProps;\n /** Properties to pass to the select component. */\n selectProps?: FormPagesSelectProps;\n}\n\n/**\n * Component allowing navigation between form pages. Renders as a sidebar in\n * large screens and as a select for smaller ones.\n */\nexport function FormPagesNavigation({\n sidebarProps,\n selectProps,\n className,\n \"aria-label\": ariaLabel,\n ...otherProps\n}: FormPagesNavigationProps) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n ariaLabel ??= locale.FormPagesNavigation[\"aria-label\"];\n const { printHidden } = usePrintClassNames();\n const isLargeScreen = useMediaBreakpointUp(\"sm\");\n\n return (\n <Layer zIndex={isLargeScreen ? undefined : [\"sticky\", -1]}>\n <nav\n className={cx(prefix(\"form-pages__navigation\"), printHidden, className)}\n data-navigation-mode={isLargeScreen ? \"sidebar\" : \"select\"}\n aria-label={ariaLabel}\n {...otherProps}\n >\n {isLargeScreen ? (\n <Layer zIndex=\"docked\">\n <FormPagesSidebar {...sidebarProps} />\n </Layer>\n ) : (\n <FormPagesSelect {...selectProps} />\n )}\n </nav>\n </Layer>\n );\n}\n","import {\n type AbsolutePath,\n AbsolutePathFragment,\n type DisplayStatus,\n type FormManager,\n} from \"@ostack.tech/kform\";\nimport { useConstant, useLatestRef, usePrinting } from \"@ostack.tech/ui\";\nimport {\n createContext,\n type ReactNode,\n startTransition,\n useCallback,\n useContext,\n useEffect,\n} from \"react\";\nimport { createStore, useStore } from \"zustand\";\nimport { subscribeWithSelector } from \"zustand/middleware\";\n\nimport { useActivePathContext } from \"../../providers/ActivePathProvider\";\nimport { mostSpecificPath } from \"../../utils/mostSpecificPath.ts\";\nimport { useFocus, useOnPathFocus } from \"../FormApp\";\nimport { useSetLatestInteraction } from \"../FormApp/FormAppContext.ts\";\nimport type { FormStepObject } from \"./FormStep.tsx\";\nimport type { FormStepperProps } from \"./FormStepper.tsx\";\n\n/** Value of the form stepper context. */\nexport type FormStepperContextValue = FormStepperStore;\n\n/** Resolved form step object. */\nexport interface ResolvedFormStepObject extends FormStepObject {\n path: AbsolutePath;\n index: number;\n}\n\n/** Form step state. */\nexport interface FormStepState {\n path: AbsolutePath;\n index: number;\n exists: boolean;\n deferredDisplayStatus: DisplayStatus | undefined;\n title?: ReactNode;\n documentTitle?: string | null;\n}\n\n/** State of the form stepper. */\nexport interface FormStepperState {\n steps: ResolvedFormStepObject[];\n activeStep: ResolvedFormStepObject | null;\n // State below is wrapped in an array in order to trigger state updates by\n // simply changing the identity of the wrapper without creating new map\n // instances\n stepStates: [Record<string, FormStepState | null>];\n actions: FormStepperActions;\n}\n\n/** Actions of the form stepper. */\nexport interface FormStepperActions {\n getStepState: (path: AbsolutePath) => FormStepState | null;\n setSteps: (steps: ResolvedFormStepObject[]) => void;\n setActiveStep: (\n activeStep: ResolvedFormStepObject | null,\n callListener?: boolean,\n ) => void;\n updateActiveStep: () => void;\n registerStepState: (path: AbsolutePath, state: FormStepState) => void;\n goToStep: (index: number) => Promise<void>;\n}\n\n/** Form stepper store. */\nexport type FormStepperStore = ReturnType<typeof useCreateFormStepperContext>;\n\n/** Form stepper context. */\nexport const FormStepperContext = createContext<FormStepperContextValue | null>(\n null,\n);\n\n/** Options used to create the form stepper context. */\nexport interface UseCreateFormStepperContextOptions extends Pick<\n FormStepperProps,\n | \"defaultActiveStep\"\n | \"activeStep\"\n | \"onActiveStepChange\"\n | \"onStepValidation\"\n | \"skipStepValidationOnForwardNavigation\"\n | \"allowForwardNavigationOnError\"\n | \"preventFocusOnError\"\n> {\n formManager: FormManager;\n basePath: AbsolutePath;\n resolvedSteps: ResolvedFormStepObject[];\n}\n\n/** Hook used to create the form stepper context. */\nexport function useCreateFormStepperContext({\n formManager,\n basePath,\n resolvedSteps,\n defaultActiveStep,\n activeStep,\n onActiveStepChange,\n onStepValidation,\n skipStepValidationOnForwardNavigation,\n allowForwardNavigationOnError,\n preventFocusOnError,\n}: UseCreateFormStepperContextOptions) {\n const focus = useFocus();\n const setLatestInteraction = useSetLatestInteraction();\n const { activePath, onActivePathChange } = useActivePathContext();\n activeStep ??= activePath;\n\n const latestRef = useLatestRef({\n printing: usePrinting(),\n formManager,\n onActivePathChange,\n onActiveStepChange,\n onStepValidation,\n skipStepValidationOnForwardNavigation,\n allowForwardNavigationOnError,\n preventFocusOnError,\n });\n const store = useConstant(() =>\n createStore<FormStepperState>()(\n subscribeWithSelector((set, get) => ({\n steps: resolvedSteps,\n activeStep:\n activeStep === undefined\n ? defaultActiveStep == null\n ? null\n : (resolvedSteps.find((data) =>\n data.path.equals(basePath.resolve(defaultActiveStep)),\n ) ?? null)\n : activeStep === null\n ? null\n : (resolvedSteps.find((data) =>\n data.path.equals(basePath.resolve(activeStep)),\n ) ?? null),\n stepStates: [{}],\n actions: {\n getStepState: (path) => get().stepStates[0][path.toString()] ?? null,\n setSteps: (steps) => {\n const newStepStates: Record<string, FormStepState | null> = {};\n for (const step of steps) {\n newStepStates[step.path.toString()] = get().actions.getStepState(\n step.path,\n );\n }\n set({\n steps,\n stepStates: [newStepStates],\n });\n get().actions.updateActiveStep();\n },\n setActiveStep: (\n step: ResolvedFormStepObject | null,\n callListener = true,\n ) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const oldActiveStep = get().activeStep;\n if (\n !oldActiveStep?.path.equals(step?.path) ||\n oldActiveStep?.index !== step?.index\n ) {\n startTransition(() => {\n set({ activeStep: step });\n if (step != null) {\n setLatestInteraction(step.path);\n }\n latestRef.current.onActivePathChange(step?.path ?? null);\n if (callListener) {\n latestRef.current.onActiveStepChange?.(\n step?.path ?? null,\n step?.index ?? -1,\n );\n }\n });\n }\n },\n updateActiveStep: () => {\n if (\n latestRef.current.printing ||\n (get().activeStep !== null &&\n get().steps.some((step) =>\n step.path.equals(get().activeStep!.path),\n ))\n ) {\n return;\n }\n\n get().actions.setActiveStep(\n get().steps[\n Math.max(\n 0,\n Math.min(\n get().activeStep?.index ?? -1,\n get().steps.length - 1,\n ),\n )\n ] ?? null,\n );\n },\n registerStepState: (path, state) => {\n const stepStates = get().stepStates[0];\n stepStates[path.toString()] = state;\n set({ stepStates: [stepStates] });\n get().actions.updateActiveStep();\n },\n goToStep: async (newStepIndex: number) => {\n if (latestRef.current.printing) {\n return;\n }\n\n const oldActiveStep = get().activeStep;\n const newActiveStep = get().steps[newStepIndex];\n if (\n (oldActiveStep?.path != newActiveStep?.path &&\n (oldActiveStep?.path == null || newActiveStep?.path == null)) ||\n (oldActiveStep?.path != null &&\n newActiveStep?.path != null &&\n !newActiveStep.path.contains(oldActiveStep.path))\n ) {\n const {\n formManager,\n allowForwardNavigationOnError,\n skipStepValidationOnForwardNavigation,\n onStepValidation,\n preventFocusOnError,\n } = latestRef.current;\n\n // Mark steps as touched and validate them prior to moving to the\n // following step (when `skipStepValidationOnForwardNavigation` is\n // not set)\n let shouldChangeActiveStep = true;\n if (\n !skipStepValidationOnForwardNavigation &&\n oldActiveStep &&\n newActiveStep &&\n oldActiveStep.index < newActiveStep.index\n ) {\n const touchAndValidateStep = async (i: number) => {\n const stepPathRecursive = get().steps[i].path.append(\n AbsolutePathFragment.RecursiveWildcard,\n );\n await formManager.setTouched(stepPathRecursive);\n const issues = await formManager.validate(stepPathRecursive);\n onStepValidation?.(issues);\n return issues;\n };\n\n for (\n let i = oldActiveStep.index;\n i < newActiveStep.index;\n ++i\n ) {\n // Unless `allowForwardNavigationOnError` is set, focus the first\n // error we find after validating the form, and don't allow\n // navigating further\n if (allowForwardNavigationOnError) {\n void touchAndValidateStep(i);\n } else {\n const issues = await touchAndValidateStep(i);\n const firstError = issues.find(\n (issue) => issue.severity === \"error\",\n );\n if (firstError) {\n shouldChangeActiveStep = false;\n if (!preventFocusOnError) {\n setTimeout(() => focus(firstError.path));\n }\n break;\n }\n }\n }\n }\n\n if (shouldChangeActiveStep) {\n get().actions.setActiveStep(newActiveStep);\n }\n }\n },\n },\n })),\n ),\n );\n\n // Update store when params change\n useEffect(() => {\n store.getState().actions.setSteps(resolvedSteps);\n if (activeStep !== undefined) {\n const { steps, activeStep: oldActiveStep } = store.getState();\n const specificPath = mostSpecificPath(\n activeStep === null ? null : basePath.resolve(activeStep),\n steps.map((step) => step.path),\n oldActiveStep?.path ?? null,\n );\n store\n .getState()\n .actions.setActiveStep(\n steps.find((step) => step.path.equals(specificPath)) ?? null,\n false,\n );\n }\n }, [resolvedSteps, activeStep, basePath, store]);\n\n // Set (possibly new) active step when focused path changes\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n const { steps, activeStep, actions } = store.getState();\n const specificPath = mostSpecificPath(\n focusedPath,\n steps.map((step) => step.path),\n activeStep?.path ?? null,\n );\n actions.setActiveStep(\n steps.find((step) => step.path.equals(specificPath)) ?? null,\n );\n },\n [store],\n ),\n );\n\n return store;\n}\n\nexport function useFormStepperContext(): FormStepperContextValue {\n const formStepperContext = useContext(FormStepperContext);\n if (!formStepperContext) {\n throw new Error(\"Form stepper context not in scope.\");\n }\n return formStepperContext;\n}\n\nexport function useFormStepState<T>(\n path: AbsolutePath,\n selector: (state: FormStepState | null) => T,\n): T {\n return useStore(useFormStepperContext(), (state) =>\n selector(state.actions.getStepState(path)),\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport { CurrentPath, useResolvedPath } from \"@ostack.tech/kform-react\";\nimport {\n cx,\n DocumentTitle,\n ErrorBoundary,\n type ErrorBoundaryProps,\n Spinner,\n StepContent,\n type StepContentProps,\n warnOnce,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, Suspense } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { FormAppIssueMessages, FormAppStatus } from \"../FormApp\";\nimport type { IssueMessagesByCode } from \"../IssueMessages\";\nimport { useFormStepState } from \"./FormStepperContext.ts\";\n\n/** Object representation of a form step. */\nexport interface FormStepObject<T = any> {\n /** Form step path. */\n path?: string | Path;\n /** Form step's title. */\n title: ReactNode | ((value: T) => ReactNode);\n /**\n * Title of the form step as a string to display in the document's title.\n *\n * Defaults to `title` when it is a string. A warning is printed if `title` is\n * not a string and `documentTitle` is not provided.\n */\n documentTitle?: string | null | ((value: T) => string | null);\n /** Label of the form step in the issues panel. Uses the `title` by default. */\n issuesPanelLabel?: ReactNode | ((value: T) => ReactNode);\n}\n\n/** Properties of the form step component. */\nexport interface FormStepProps\n extends FormStepObject, Omit<StepContentProps, \"index\" | \"title\"> {\n /** Sets the step as disabled. */\n disabled?: boolean;\n /** Sets the step as read-only. */\n readOnly?: boolean;\n /**\n * Mapping of issue messages from the path of the field with issues to the\n * issue messages of said field (which are themselves grouped by their code).\n *\n * Provided paths are relative to the form step's path and may contain\n * wildcards, which will have a lower priority when matched against.\n *\n * These messages are used by the `IssueMessages` component.\n *\n * > **Note:** Changes to `issueMessages` are handled correctly, but are not\n * > efficient. Please make sure that the identity of the provided value doesn't\n * > change at every render.\n *\n * Example value:\n *\n * ```tsx\n * {\n * \"**\": {\n * \"valueMissing\": \"Field is required.\"\n * },\n * \"field\": {\n * \"valueMissing\": \"My field cannot be left empty!\",\n * \"someOtherError\": \"Text of the other error.\"\n * }\n * }\n * ```\n */\n issueMessages?: Record<string, IssueMessagesByCode>;\n /** Properties to pass to the `ErrorBoundary` component. */\n errorBoundaryProps?: ErrorBoundaryProps;\n}\n\n/** Single form step. */\nexport function FormStep({\n path,\n // `FormStepObject` props\n title: _title,\n documentTitle: _documentTitle,\n issuesPanelLabel: _issuesPanelLabel,\n disabled = false,\n readOnly = false,\n issueMessages,\n errorBoundaryProps,\n className,\n children,\n ...otherProps\n}: FormStepProps) {\n const prefix = usePrefix();\n const stepPath = useResolvedPath(path);\n const index = useFormStepState(stepPath, (controller) => controller?.index);\n const documentTitle = useFormStepState(stepPath, (state) =>\n state === null ? null : state.documentTitle,\n );\n\n if (documentTitle === undefined) {\n warnOnce(\n `FormStep: At '${stepPath.toString()}': \\`documentTitle\\` ` +\n \"should be set manually since the form step's `title` is not a string.\",\n );\n }\n\n return (\n index != null && (\n <CurrentPath path={stepPath}>\n <StepContent\n index={index}\n className={cx(prefix(\"form-stepper__step-content\"), className)}\n {...otherProps}\n >\n <DocumentTitle title={documentTitle ?? undefined}>\n <FormAppStatus disabled={disabled} readOnly={readOnly}>\n <FormAppIssueMessages issueMessages={issueMessages}>\n <ErrorBoundary {...errorBoundaryProps}>\n <Suspense fallback={<Spinner size=\"xl\" color=\"primary\" />}>\n {children}\n </Suspense>\n </ErrorBoundary>\n </FormAppIssueMessages>\n </FormAppStatus>\n </DocumentTitle>\n </StepContent>\n </CurrentPath>\n )\n );\n}\n\n/** @deprecated Use `FormStep` instead. */\nexport const FormStepContent = FormStep;\n","import type { AbsolutePath } from \"@ostack.tech/kform\";\nimport { CurrentPath } from \"@ostack.tech/kform-react\";\nimport { Step } from \"@ostack.tech/ui\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useFormStepState } from \"./FormStepperContext.ts\";\n\n/** Properties of the form step button component. */\nexport interface FormStepButtonProps {\n path: AbsolutePath;\n index: number;\n}\n\n/** Form step button. */\nexport function FormStepButton({ path, index }: FormStepButtonProps) {\n const prefix = usePrefix();\n const deferredDisplayStatus = useFormStepState(\n path,\n (state) => state?.deferredDisplayStatus,\n );\n const disabled = useFormStepState(path, (state) => !state?.exists);\n const title = useFormStepState(path, (state) => state?.title);\n\n return (\n <Step\n index={index}\n status={displayStatusToControlStatus(deferredDisplayStatus)}\n disabled={disabled}\n className={prefix(\"form-stepper__step\")}\n >\n <CurrentPath path={path}>{title}</CurrentPath>\n </Step>\n );\n}\n","import { cx, StepList, type StepListProps } from \"@ostack.tech/ui\";\nimport { useStore } from \"zustand\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { FormStepButton } from \"./FormStepButton.tsx\";\nimport { useFormStepperContext } from \"./FormStepperContext.ts\";\n\n/** Properties of the form steps sidebar component. */\nexport interface FormStepListProps extends StepListProps {}\n\n/** Component displaying all form steps in a list. */\nexport function FormStepList({ className, ...otherProps }: FormStepListProps) {\n const prefix = usePrefix();\n const steps = useStore(useFormStepperContext(), (state) => state.steps);\n\n return (\n <StepList\n className={cx(prefix(\"form-stepper__step-list\"), className)}\n {...otherProps}\n >\n {steps.map((step) => (\n <FormStepButton\n key={step.path.toString()}\n path={step.path}\n index={step.index}\n />\n ))}\n </StepList>\n );\n}\n","import { AbsolutePathFragment } from \"@ostack.tech/kform\";\nimport { CurrentPath, useController } from \"@ostack.tech/kform-react\";\nimport { usePrinting, useStartPrintingTask } from \"@ostack.tech/ui\";\nimport { useDeferredValue, useEffect } from \"react\";\n\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterController, useRegisterLabel } from \"../FormApp\";\nimport {\n type ResolvedFormStepObject,\n useFormStepperContext,\n} from \"./FormStepperContext.ts\";\n\n/** Properties of the `FormStepRegistrar` component. */\nexport interface FormStepRegistrarProps extends ResolvedFormStepObject {}\n\n/** Component used to register a form step. */\nexport function FormStepRegistrar({\n index,\n path,\n title,\n documentTitle,\n issuesPanelLabel,\n}: FormStepRegistrarProps) {\n const store = useFormStepperContext();\n\n const printing = usePrinting();\n const finishPrintingTask = useStartPrintingTask();\n const observeDescendants =\n typeof title === \"function\" || typeof documentTitle === \"function\";\n const controller = useController(\n observeDescendants\n ? path.append(AbsolutePathFragment.RecursiveWildcard)\n : path,\n { enabled: !useFormIsLoading(), onInitialized: finishPrintingTask },\n );\n const absolutePath = controller.usePath();\n const exists = controller.useState(\n (state) => state.initialized && state.exists,\n );\n const value = controller.useValue();\n const deferredValue = useDeferredValue(value);\n const relevantValue = printing ? value : deferredValue;\n const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());\n\n const actualTitle =\n typeof title === \"function\"\n ? relevantValue === undefined\n ? null\n : title(relevantValue)\n : title;\n const actualDocumentTitle =\n typeof documentTitle === \"function\"\n ? relevantValue === undefined\n ? null\n : documentTitle(relevantValue)\n : documentTitle === undefined\n ? actualTitle === null || typeof actualTitle === \"string\"\n ? actualTitle\n : undefined\n : documentTitle;\n\n useEffect(() => {\n const { registerStepState } = store.getState().actions;\n registerStepState(absolutePath, {\n exists,\n path: absolutePath,\n deferredDisplayStatus,\n index,\n title: actualTitle,\n documentTitle: actualDocumentTitle,\n });\n }, [\n absolutePath,\n actualDocumentTitle,\n actualTitle,\n deferredDisplayStatus,\n exists,\n index,\n store,\n title,\n ]);\n\n useRegisterController(controller);\n useRegisterLabel(\n absolutePath,\n <CurrentPath path={absolutePath}>\n {typeof issuesPanelLabel === \"function\"\n ? deferredValue === undefined\n ? null\n : issuesPanelLabel(deferredValue)\n : issuesPanelLabel || actualTitle}\n </CurrentPath>,\n );\n\n return null;\n}\n","import {\n type AbsolutePath,\n AbsolutePathFragment,\n Path,\n type SealedLocatedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport {\n CurrentPath,\n useFormManager,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport { cx, parseChildren, Stepper, type StepperProps } from \"@ostack.tech/ui\";\nimport { useMemo } from \"react\";\nimport { useStore } from \"zustand\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { FormStep, type FormStepObject } from \"./FormStep.tsx\";\nimport {\n FormStepperContext,\n useCreateFormStepperContext,\n} from \"./FormStepperContext.ts\";\nimport { FormStepRegistrar } from \"./FormStepRegistrar.tsx\";\n\n/** Properties of the form stepper component. */\nexport interface FormStepperProps extends Omit<\n StepperProps,\n \"defaultActiveStep\" | \"activeStep\" | \"onActiveStepChange\"\n> {\n /** Base path for all declared form steps. */\n path?: string | Path;\n /** List of all form steps. */\n steps?: FormStepObject[];\n /** Default active form step. */\n defaultActiveStep?: string | Path;\n /** Controlled active form step. */\n activeStep?: string | Path;\n /**\n * Function called whenever the active form step changes.\n *\n * @param activeStepPath Path of the new active form step.\n * @param activeStepIndex Index of the new active form step.\n */\n onActiveStepChange?: (\n activeStepPath: AbsolutePath | null,\n activeStepIndex: number,\n ) => void;\n /**\n * Function called when a step is touched and validated due to a navigation to\n * a following step. This function is never called when\n * `skipStepValidationOnForwardNavigation` is `true`.\n *\n * @param issues Issues present in the step.\n */\n onStepValidation?: (issues: SealedLocatedValidationIssue[]) => void;\n /**\n * Whether to skip marking a step as touched and validating it when navigating\n * to a following step.\n *\n * @default false\n */\n skipStepValidationOnForwardNavigation?: boolean;\n /**\n * Whether to allow navigation to a following step when a previous step\n * contains errors. This is always `true` when\n * `skipStepValidationOnForwardNavigation` is also `true`.\n *\n * @default false\n */\n allowForwardNavigationOnError?: boolean;\n /**\n * Whether to prevent the focus of an invalid field when a step was validated\n * and an error was found. This is always `true` if either\n * `skipStepValidationOnForwardNavigation` or `allowForwardNavigationOnError`\n * are `true`.\n *\n * @default false\n */\n preventFocusOnError?: boolean;\n}\n\n/**\n * The form stepper component can be used to split parts of a form into separate\n * steps. It is built on top of the\n * [`Stepper`](/docs/ostack-ui-disclosure-stepper--docs) component. Although not\n * strictly mandatory, each page is typically represented by its own class, with\n * its own schema and distinct path.\n *\n * It composes the following subcomponents:\n *\n * - `FormStepList`: Component used to navigate between form pages.\n * - `FormStep`: The content of a single step of the form.\n * - `FormStepperPreviousTrigger`: Trigger to navigate to the previous step.\n * - `FormStepperNextTrigger`: Trigger to navigate to the next step.\n * - `FormStepperFinishTrigger`: Trigger to finish the form stepper.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * FormStep,\n * FormStepList,\n * FormStepper,\n * FormStepperFinishTrigger,\n * FormStepperNextTrigger,\n * FormStepperPreviousTrigger,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function AccountSetupStepper() {\n * return (\n * <FormStepper>\n * <FormStepList />\n * <FormStep path=\"/profile\" title=\"Personal profile\">\n * Provide identification…\n * </FormStep>\n * <FormStep path=\"/preferences\" title=\"Preferences\">\n * Select preferences…\n * </FormStep>\n * <FormStep path=\"/terms\" title=\"Terms & authorization\">\n * Accept terms…\n * </FormStep>\n * <FormStepperPreviousTrigger />\n * <FormStepperNextTrigger />\n * <FormStepperFinishTrigger />\n * </FormStepper>\n * );\n * }\n * ```\n */\nexport function FormStepper({\n path,\n steps,\n defaultActiveStep,\n activeStep,\n onActiveStepChange,\n onStepValidation,\n skipStepValidationOnForwardNavigation,\n allowForwardNavigationOnError,\n preventFocusOnError,\n className,\n children,\n ...otherProps\n}: FormStepperProps) {\n const prefix = usePrefix();\n const formManager = useFormManager();\n const absolutePath = useResolvedPath(path);\n\n // Get form steps from children if not provided as prop\n steps ??= parseChildren(children, FormStep, {\n renderUnknownComponents: false,\n });\n\n // Provided steps but with absolute paths and indices\n const resolvedSteps = useMemo(\n () =>\n steps.map((step, i) => ({\n ...step,\n index: i,\n path: absolutePath.resolve(step.path ?? Path.CURRENT),\n })),\n [absolutePath, steps],\n );\n\n // Refuse non-existent paths\n if (!formManager.isValidPath(absolutePath)) {\n throw new Error(`Invalid path: '${absolutePath.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n absolutePath.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Form stepper base path must only contain ids.\");\n }\n // Validate form step paths\n for (const step of resolvedSteps) {\n // Refuse non-existent paths\n if (!formManager.isValidPath(step.path)) {\n throw new Error(`Invalid path: '${step.path.toString()}'`);\n }\n // Refuse paths that don't consist of identifiers only\n if (\n step.path.fragments.some(\n (frag) => !(frag instanceof AbsolutePathFragment.Id),\n )\n ) {\n throw new Error(\"Form step path must only contain ids.\");\n }\n }\n\n const store = useCreateFormStepperContext({\n formManager,\n basePath: absolutePath,\n resolvedSteps,\n defaultActiveStep,\n activeStep,\n onActiveStepChange,\n onStepValidation,\n skipStepValidationOnForwardNavigation,\n allowForwardNavigationOnError,\n preventFocusOnError,\n });\n const activeIndex = useStore(store, (state) => state.activeStep?.index ?? -1);\n const { goToStep } = useStore(store, (state) => state.actions);\n\n return (\n <CurrentPath path={absolutePath}>\n <FormStepperContext.Provider value={store}>\n {resolvedSteps.map((step) => (\n <FormStepRegistrar key={step.path.toString()} {...step} />\n ))}\n\n <Stepper\n className={cx(prefix(\"form-stepper\"), className)}\n activeStep={activeIndex}\n onActiveStepChange={goToStep}\n {...otherProps}\n >\n {children}\n </Stepper>\n </FormStepperContext.Provider>\n </CurrentPath>\n );\n}\n","import {\n StepperFinishTrigger,\n type StepperFinishTriggerProps,\n} from \"@ostack.tech/ui\";\n\n/** Properties of the form stepper finish trigger component. */\nexport type FormStepperFinishTriggerProps = StepperFinishTriggerProps;\n\n/** Trigger used to conclude the form stepper. */\nexport const FormStepperFinishTrigger = StepperFinishTrigger;\n","import {\n StepperNextTrigger,\n type StepperNextTriggerProps,\n} from \"@ostack.tech/ui\";\n\n/** Properties of the form stepper next trigger component. */\nexport type FormStepperNextTriggerProps = StepperNextTriggerProps;\n\n/** Trigger used to go to the next step of the form stepper. */\nexport const FormStepperNextTrigger = StepperNextTrigger;\n","import {\n StepperPreviousTrigger,\n type StepperPreviousTriggerProps,\n} from \"@ostack.tech/ui\";\n\n/** Properties of the form stepper previous trigger component. */\nexport type FormStepperPreviousTriggerProps = StepperPreviousTriggerProps;\n\n/** Trigger used to go to the previous step of the form stepper. */\nexport const FormStepperPreviousTrigger = StepperPreviousTrigger;\n","import {\n useFormManager,\n useIssuesTracker,\n useResolvedPath,\n} from \"@ostack.tech/kform-react\";\nimport {\n Alert,\n type AlertProps,\n cx,\n Feedback,\n FeedbackList,\n usePrevious,\n} from \"@ostack.tech/ui\";\nimport { useDeferredValue, useMemo } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useReportValidationFailures } from \"../../utils/useReportValidationFailures.ts\";\nimport { FormAppIssueMessages } from \"../FormApp\";\nimport { IssueMessage } from \"../IssueMessage\";\nimport type { IssueMessagesProps } from \"../IssueMessages\";\n\n/** Properties of the issues alert component. */\nexport interface IssuesAlertProps\n extends\n Omit<AlertProps, \"open\" | \"defaultOpen\" | \"severity\" | \"children\">,\n Pick<\n IssueMessagesProps,\n | \"path\"\n | \"issues\"\n | \"messages\"\n | \"displayIssueCodes\"\n | \"messagesDataKey\"\n | \"visuallyHiddenErrorCodePrefix\"\n | \"visuallyHiddenWarningCodePrefix\"\n | \"unknownErrorMessage\"\n | \"unknownWarningMessage\"\n > {}\n\n/** Component used to display an issue alert. */\nexport function IssuesAlert({\n variant = \"solid\",\n path,\n issues,\n messages,\n displayIssueCodes,\n messagesDataKey,\n visuallyHiddenErrorCodePrefix,\n visuallyHiddenWarningCodePrefix,\n unknownErrorMessage,\n unknownWarningMessage,\n className,\n ...otherProps\n}: IssuesAlertProps) {\n const prefix = usePrefix();\n const formManager = useFormManager();\n const absolutePath = useResolvedPath(path);\n const { info } = useIssuesTracker(absolutePath, {\n enabled: !issues,\n });\n const messagesToRegister = useMemo(\n () => messages && { [absolutePath.toString()]: messages },\n [absolutePath, messages],\n );\n\n const deferredTrackedIssues = useDeferredValue(\n useMemo(() => info?.flatMap((info) => info.issues) ?? [], [info]),\n );\n const deferredIssuesToDisplay = issues ?? deferredTrackedIssues;\n useReportValidationFailures(\n useMemo(\n () => [{ path: absolutePath, issues: deferredIssuesToDisplay }],\n [absolutePath, deferredIssuesToDisplay],\n ),\n );\n const severity = useMemo(\n () =>\n deferredIssuesToDisplay.length === 0\n ? undefined\n : deferredIssuesToDisplay.every((issue) => issue.severity === \"warning\")\n ? \"warning\"\n : \"danger\",\n [deferredIssuesToDisplay],\n );\n // Use previous severity as fallback while the alert is hiding, when there are\n // no more issues\n const prevSeverity = usePrevious(severity);\n\n const schema = useMemo(\n () => formManager.schema(absolutePath),\n [absolutePath, formManager],\n );\n\n return (\n <Alert\n className={cx(prefix(\"issues-alert\"), className)}\n open={deferredIssuesToDisplay.length > 0}\n variant={variant}\n {...otherProps}\n severity={severity ?? prevSeverity}\n >\n <FormAppIssueMessages issueMessages={messagesToRegister}>\n <FeedbackList>\n {deferredIssuesToDisplay.map((issue, i) => (\n <Feedback key={i} type={issue.severity}>\n <IssueMessage\n path={absolutePath}\n issue={issue}\n schema={schema}\n displayIssueCode={displayIssueCodes}\n messageDataKey={messagesDataKey}\n visuallyHiddenErrorCodePrefix={visuallyHiddenErrorCodePrefix}\n visuallyHiddenWarningCodePrefix={\n visuallyHiddenWarningCodePrefix\n }\n unknownErrorMessage={unknownErrorMessage}\n unknownWarningMessage={unknownWarningMessage}\n issueCodeProps={{\n className: prefix(\"issue-messages__issue-code\"),\n }}\n />\n </Feedback>\n ))}\n </FeedbackList>\n </FormAppIssueMessages>\n </Alert>\n );\n}\n","import { useFormController } from \"@ostack.tech/kform-react\";\nimport { useCallback, useMemo } from \"react\";\n\nimport { useStartIssuesNavigation } from \"../components/FormApp\";\n\n/** Result of the {@link useFormValidator} hook. */\nexport interface FormValidatorResult {\n /**\n * Function used to validate the form.\n *\n * @returns Promise which resolves once the form has been validated.\n */\n validate: () => Promise<void>;\n}\n\n/** Hook exposing a function used to validate the form. */\nexport function useFormValidator(): FormValidatorResult {\n const startIssuesNavigation = useStartIssuesNavigation();\n const { _setState } = useFormController();\n\n const validate = useCallback(async () => {\n _setState({ validating: true } as any);\n try {\n await startIssuesNavigation();\n } finally {\n _setState({ validating: false } as any);\n }\n }, [_setState, startIssuesNavigation]);\n\n return useMemo(() => ({ validate }), [validate]);\n}\n\n/** Result of the {@link useFormIsValidating} hook. */\nexport interface FormIsValidatingResult {\n /**\n * Whether form is being validated automatically (due to validating mode being\n * set to `\"auto\"`).\n */\n validatingAutomatically: boolean;\n /**\n * Whether form is being validated manually (due to an explicit `validate`\n * call).\n */\n validatingManually: boolean;\n /** Whether form is being validated (either automatically or manually). */\n validating: boolean;\n}\n\n/** Hook exposing whether the form is currently being validated. */\nexport function useFormIsValidating(): FormIsValidatingResult {\n const validatingAutomatically =\n useFormController().useAutoValidationStatus() === \"activeRunning\";\n const validatingManually = useFormController().useState(\n (state) => (state as any).validating,\n );\n\n return useMemo(\n () => ({\n validatingAutomatically,\n validatingManually,\n validating: validatingAutomatically || validatingManually,\n }),\n [validatingAutomatically, validatingManually],\n );\n}\n","import {\n faAngleLeft,\n faAngleRight,\n faAnglesLeft,\n faAnglesRight,\n faArrowsToDot,\n} from \"@fortawesome/free-solid-svg-icons\";\nimport type { AbsolutePath } from \"@ostack.tech/kform\";\nimport type { Controller } from \"@ostack.tech/kform-react\";\nimport {\n CloseButton,\n combineEventHandlers,\n cx,\n IconButton,\n type IconButtonColor,\n Spinner,\n useKeyboardShortcut,\n VisuallyHidden,\n} from \"@ostack.tech/ui\";\nimport { useCallback, useDeferredValue } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useFormIsValidating } from \"../../utils/useFormValidator.ts\";\nimport { useFocus, useFormAppElement, useFormIsDisabled } from \"../FormApp\";\nimport type { IssuesPanelProps } from \"./IssuesPanel.tsx\";\n\n/** Properties of the issues panel controls component. */\nexport interface IssuesPanelControlsProps extends Pick<\n IssuesPanelProps,\n | \"focusButtonLabel\"\n | \"focusKeybinds\"\n | \"previousIssueButtonLabel\"\n | \"previousIssueKeybinds\"\n | \"nextIssueButtonLabel\"\n | \"nextIssueKeybinds\"\n | \"firstIssueButtonLabel\"\n | \"firstIssueKeybinds\"\n | \"lastIssueButtonLabel\"\n | \"lastIssueKeybinds\"\n | \"paginationLabel\"\n | \"validatingSpinnerProps\"\n | \"paginationProps\"\n | \"focusButtonProps\"\n | \"previousIssueButtonProps\"\n | \"nextIssueButtonProps\"\n | \"firstIssueButtonProps\"\n | \"lastIssueButtonProps\"\n | \"closeButtonProps\"\n> {\n currentPagePath: AbsolutePath | null;\n currentPageIndex: number;\n currentPageController: Controller;\n nPages: number;\n goToPreviousPage: () => void;\n goToNextPage: () => void;\n goToFirstPage: () => void;\n goToLastPage: () => void;\n buttonsColor?: IconButtonColor;\n closePanel: () => void;\n}\n\n/** Controls of the issues panel. */\nexport function IssuesPanelControls({\n currentPagePath,\n nPages,\n currentPageIndex,\n currentPageController,\n goToPreviousPage,\n goToNextPage,\n goToFirstPage,\n goToLastPage,\n buttonsColor,\n closePanel,\n focusButtonLabel,\n focusKeybinds,\n previousIssueButtonLabel,\n previousIssueKeybinds,\n nextIssueButtonLabel,\n nextIssueKeybinds,\n firstIssueButtonLabel,\n firstIssueKeybinds,\n lastIssueButtonLabel,\n lastIssueKeybinds,\n paginationLabel,\n validatingSpinnerProps,\n paginationProps,\n focusButtonProps,\n previousIssueButtonProps,\n nextIssueButtonProps,\n firstIssueButtonProps,\n lastIssueButtonProps,\n closeButtonProps,\n}: IssuesPanelControlsProps) {\n const prefix = usePrefix();\n const formIsDisabled = useFormIsDisabled();\n const { validating } = useFormIsValidating();\n const deferredValidating = useDeferredValue(validating);\n const currentPageInitialized = currentPageController.useInitialized();\n const currentPageExists = currentPageController.useExists();\n\n const focus = useFocus();\n const handleFocus = useCallback(\n () => focus(currentPagePath!),\n [currentPagePath, focus],\n );\n\n const focusButtonLoading = !currentPageInitialized;\n const focusButtonDisabled = formIsDisabled || !currentPageExists;\n const firstIssueButtonDisabled =\n formIsDisabled || firstIssueButtonProps?.disabled || currentPageIndex === 0;\n const previousIssueButtonDisabled =\n formIsDisabled ||\n previousIssueButtonProps?.disabled ||\n currentPageIndex === 0;\n const nextIssueButtonDisabled =\n formIsDisabled ||\n nextIssueButtonProps?.disabled ||\n currentPageIndex === nPages - 1;\n const lastIssueButtonDisabled =\n formIsDisabled ||\n lastIssueButtonProps?.disabled ||\n currentPageIndex === nPages - 1;\n\n // Set-up keyboard shortcuts\n const formAppEl = useFormAppElement();\n useKeyboardShortcut(focusKeybinds, handleFocus, {\n disabled: focusButtonLoading || focusButtonDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n useKeyboardShortcut(firstIssueKeybinds, goToFirstPage, {\n disabled: firstIssueButtonDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n useKeyboardShortcut(previousIssueKeybinds, goToPreviousPage, {\n disabled: previousIssueButtonDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n useKeyboardShortcut(nextIssueKeybinds, goToNextPage, {\n disabled: nextIssueButtonDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n useKeyboardShortcut(lastIssueKeybinds, goToLastPage, {\n disabled: lastIssueButtonDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n\n return (\n <div className={prefix(\"issues-panel__controls\")}>\n {nPages > 0 && (\n <>\n {/* Validating spinner. */}\n {deferredValidating && (\n <Spinner\n {...validatingSpinnerProps}\n className={cx(\n prefix(\"issues-panel__validating-spinner\"),\n validatingSpinnerProps?.className,\n )}\n />\n )}\n\n {/* Pagination. */}\n <div\n role=\"status\"\n {...paginationProps}\n className={cx(\n prefix(\"issues-panel__pagination\"),\n paginationProps?.className,\n )}\n >\n {paginationLabel && currentPageIndex !== -1 && (\n <VisuallyHidden>\n {paginationLabel(currentPageIndex + 1, nPages)}\n </VisuallyHidden>\n )}\n <span aria-hidden>\n {currentPageIndex === -1 ? \"-\" : currentPageIndex + 1} / {nPages}\n </span>\n </div>\n\n {/* Focus button. */}\n <IconButton\n color={buttonsColor}\n icon={faArrowsToDot}\n {...focusButtonProps}\n className={cx(\n prefix(\"issues-panel__action\"),\n prefix(\"issues-panel__focus\"),\n focusButtonProps?.className,\n )}\n label={focusButtonLabel}\n keybinds={focusKeybinds}\n loading={focusButtonLoading}\n disabled={focusButtonDisabled}\n onClick={combineEventHandlers(\n focusButtonProps?.onClick,\n handleFocus,\n )}\n />\n\n {/* First issue button. */}\n <IconButton\n color={buttonsColor}\n icon={faAnglesLeft}\n {...firstIssueButtonProps}\n className={cx(\n prefix(\"issues-panel__action\"),\n prefix(\"issues-panel__first\"),\n firstIssueButtonProps?.className,\n )}\n label={firstIssueButtonLabel}\n keybinds={firstIssueKeybinds}\n disabled={firstIssueButtonDisabled}\n onClick={combineEventHandlers(\n firstIssueButtonProps?.onClick,\n goToFirstPage,\n )}\n />\n\n {/* Previous issue button. */}\n <IconButton\n color={buttonsColor}\n icon={faAngleLeft}\n {...previousIssueButtonProps}\n className={cx(\n prefix(\"issues-panel__action\"),\n prefix(\"issues-panel__previous\"),\n previousIssueButtonProps?.className,\n )}\n label={previousIssueButtonLabel}\n keybinds={previousIssueKeybinds}\n disabled={previousIssueButtonDisabled}\n onClick={combineEventHandlers(\n previousIssueButtonProps?.onClick,\n goToPreviousPage,\n )}\n />\n\n {/* Next issue button. */}\n <IconButton\n color={buttonsColor}\n icon={faAngleRight}\n {...nextIssueButtonProps}\n className={cx(\n prefix(\"issues-panel__action\"),\n prefix(\"issues-panel__next\"),\n nextIssueButtonProps?.className,\n )}\n label={nextIssueButtonLabel}\n keybinds={nextIssueKeybinds}\n disabled={nextIssueButtonDisabled}\n onClick={combineEventHandlers(\n nextIssueButtonProps?.onClick,\n goToNextPage,\n )}\n />\n\n {/* Last issue button. */}\n <IconButton\n color={buttonsColor}\n icon={faAnglesRight}\n {...lastIssueButtonProps}\n className={cx(\n prefix(\"issues-panel__action\"),\n prefix(\"issues-panel__last\"),\n lastIssueButtonProps?.className,\n )}\n label={lastIssueButtonLabel}\n keybinds={lastIssueKeybinds}\n disabled={lastIssueButtonDisabled}\n onClick={combineEventHandlers(\n lastIssueButtonProps?.onClick,\n goToLastPage,\n )}\n />\n </>\n )}\n\n {/* Close button. */}\n <CloseButton\n color={buttonsColor}\n {...closeButtonProps}\n className={cx(\n prefix(\"issues-panel__close-button\"),\n closeButtonProps?.className,\n )}\n onClick={combineEventHandlers(closeButtonProps?.onClick, closePanel, {\n checkDefaultPrevented: true,\n })}\n />\n </div>\n );\n}\n","import {\n faCircleCheck,\n faCircleExclamation,\n faTriangleExclamation,\n} from \"@fortawesome/free-solid-svg-icons\";\nimport type { AbsolutePath, ValidationIssueSeverity } from \"@ostack.tech/kform\";\nimport {\n type Controller,\n CurrentPath,\n type IssuesTrackerResult,\n useFormManager,\n} from \"@ostack.tech/kform-react\";\nimport {\n Card,\n CardBody,\n CardHeader,\n type CardProps,\n CardTitle,\n cx,\n Icon,\n type IconButtonColor,\n Layer,\n setBoolDataAttr,\n Spinner,\n useCombinedRef,\n useScrollPosition,\n} from \"@ostack.tech/ui\";\nimport { type ReactNode, useCallback, useMemo, useRef, useState } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useActiveIssuesPanelBreadcrumb, useIsRegistered } from \"../FormApp\";\nimport { IssueMessage } from \"../IssueMessage\";\nimport type { IssuesPanelProps } from \"./IssuesPanel.tsx\";\n\nexport interface IssuesPanelMessagesCardProps\n extends\n CardProps,\n Pick<\n IssuesPanelProps,\n | \"displayIssueCodes\"\n | \"unknownErrorMessage\"\n | \"unknownWarningMessage\"\n | \"errorsLabel\"\n | \"warningsLabel\"\n | \"noIssuesMessage\"\n | \"resolvedTitle\"\n | \"resolvedMessage\"\n | \"headerProps\"\n | \"bodyProps\"\n | \"loadingSpinnerProps\"\n | \"titleProps\"\n | \"iconProps\"\n > {\n currentPagePath: AbsolutePath | null;\n currentPageController: Controller;\n issuesTrackerResult: IssuesTrackerResult;\n currentPageIndex: number;\n renderControls: (buttonsColor?: IconButtonColor) => ReactNode;\n}\n\nexport function IssuesPanelMessagesCard({\n currentPagePath,\n currentPageController,\n issuesTrackerResult,\n currentPageIndex,\n errorsLabel,\n warningsLabel,\n noIssuesMessage,\n resolvedTitle,\n resolvedMessage,\n displayIssueCodes,\n unknownErrorMessage,\n unknownWarningMessage,\n renderControls,\n headerProps,\n bodyProps,\n loadingSpinnerProps,\n titleProps,\n iconProps,\n className,\n ref,\n ...otherProps\n}: IssuesPanelMessagesCardProps) {\n const prefix = usePrefix();\n const { initialized, info } = issuesTrackerResult;\n const nPages = info?.length ?? 0;\n const currentInfo = currentPageIndex === -1 ? null : info![currentPageIndex];\n const currentPageExists = currentPageController.useExists();\n\n // Relevant icon and colour\n const relevantIcon = initialized\n ? !currentInfo\n ? faCircleCheck\n : currentInfo.localDisplayStatus === \"error\"\n ? faCircleExclamation\n : faTriangleExclamation\n : undefined;\n const relevantColor = initialized\n ? nPages === 0\n ? \"success\"\n : !currentInfo\n ? \"primary\"\n : currentInfo.localDisplayStatus === \"error\"\n ? \"danger\"\n : \"warning\"\n : undefined;\n\n const hasErrors = currentInfo?.localDisplayStatus === \"error\";\n const hasWarnings =\n currentInfo?.localDisplayStatus === \"warning\" ||\n (currentInfo?.localDisplayStatus === \"error\" &&\n currentInfo.issues.some((issue) => issue.severity === \"warning\"));\n\n const formManager = useFormManager();\n const schema = useMemo(\n () => currentInfo && formManager.schema(currentInfo.path),\n [currentInfo, formManager],\n );\n\n // Whether the active issues panel path has been registered at all\n const isRegistered = useIsRegistered(currentPagePath);\n const [lastRegisteredPath, setLastRegisteredPath] =\n useState<AbsolutePath | null>(isRegistered ? currentPagePath : null);\n if (isRegistered && !lastRegisteredPath?.equals(currentPagePath)) {\n setLastRegisteredPath(currentPagePath);\n }\n const isOrWasLastRegistered =\n isRegistered || lastRegisteredPath?.equals(currentPagePath);\n\n // Sticky style for card header\n const [cardEl, setCardEl] = useState<HTMLDivElement | null>(null);\n const headerRef = useRef<HTMLDivElement | null>(null);\n useScrollPosition(\n cardEl,\n useCallback(\n (scrollPosition) =>\n setBoolDataAttr(\n headerRef.current,\n \"stuck\",\n (scrollPosition?.top ?? 0) > 0,\n ),\n [],\n ),\n );\n\n const renderIssuesList = (severity: ValidationIssueSeverity) =>\n (severity === \"error\" ? hasErrors : hasWarnings) && (\n <>\n <h3 className={prefix(\"issues-panel__issues-list-title\")}>\n {severity === \"error\" ? errorsLabel?.() : warningsLabel?.()}\n </h3>\n\n <ul className={prefix(\"issues-panel__issues-list\")}>\n {currentInfo!.issues\n .filter((issue) => issue.severity === severity)\n .map((issue, i) => (\n <li\n key={i}\n className={prefix(\"issues-panel__issue\")}\n data-severity={issue.severity}\n >\n <IssueMessage\n path={currentInfo!.path}\n issue={issue}\n schema={schema!}\n displayIssueCode={displayIssueCodes}\n unknownErrorMessage={unknownErrorMessage}\n unknownWarningMessage={unknownWarningMessage}\n issueCodeProps={{\n className: prefix(\"issues-panel__issue-code\"),\n }}\n />\n </li>\n ))}\n </ul>\n </>\n );\n\n const combinedCardRef = useCombinedRef(setCardEl, ref);\n const combinedHeaderRef = useCombinedRef(headerRef, headerProps?.ref);\n return (\n <Card\n variant=\"subtle\"\n mergeSections\n className={cx(\n prefix(\"issues-panel\"),\n prefix(\"issues-panel--messages\"),\n className,\n )}\n {...otherProps}\n color={relevantColor ?? \"neutral\"}\n ref={combinedCardRef}\n >\n <Layer zIndex=\"sticky\">\n <CardHeader\n {...headerProps}\n className={cx(prefix(\"issues-panel__header\"), headerProps?.className)}\n ref={combinedHeaderRef}\n >\n {renderControls(relevantColor ?? \"primary\")}\n\n {/* Initialisation spinner. */}\n {!initialized && (\n <Spinner\n size=\"lg\"\n {...loadingSpinnerProps}\n className={cx(\n prefix(\"issues-panel__loading-spinner\"),\n loadingSpinnerProps?.className,\n )}\n />\n )}\n\n {initialized && (\n <>\n {/* Panel icon. */}\n <Icon\n color={relevantColor}\n size=\"lg\"\n {...iconProps}\n className={cx(\n prefix(\"issues-panel__icon\"),\n iconProps?.className,\n )}\n icon={relevantIcon!}\n />\n\n <CardTitle\n {...titleProps}\n className={cx(\n prefix(\"issues-panel__title\"),\n titleProps?.className,\n )}\n >\n {nPages === 0 ? (\n noIssuesMessage\n ) : isOrWasLastRegistered ? (\n currentPageExists ? (\n <Breadcrumb />\n ) : (\n resolvedTitle\n )\n ) : (\n <Spinner\n size=\"lg\"\n {...loadingSpinnerProps}\n className={cx(\n prefix(\"issues-panel__loading-spinner\"),\n loadingSpinnerProps?.className,\n )}\n />\n )}\n </CardTitle>\n </>\n )}\n </CardHeader>\n </Layer>\n\n <CardBody\n {...bodyProps}\n className={cx(prefix(\"issues-panel__body\"), bodyProps?.className)}\n >\n {currentInfo && isOrWasLastRegistered && renderIssuesList(\"error\")}\n {currentInfo && isOrWasLastRegistered && renderIssuesList(\"warning\")}\n {!currentInfo && nPages > 0 && (\n <div className={prefix(\"issues-panel__resolved-message\")}>\n {resolvedMessage}\n </div>\n )}\n </CardBody>\n </Card>\n );\n}\n\nfunction Breadcrumb() {\n const prefix = usePrefix();\n const breadcrumb = useActiveIssuesPanelBreadcrumb();\n\n return (\n breadcrumb &&\n (breadcrumb.length === 1 ? breadcrumb : breadcrumb.slice(1)).map(\n ({ path, label }) => (\n <CurrentPath key={path.toString()} path={path}>\n <span className={prefix(\"issues-panel__breadcrumb-item\")}>\n {label}\n </span>\n </CurrentPath>\n ),\n )\n );\n}\n","import {\n faCircleCheck,\n faCircleExclamation,\n faTriangleExclamation,\n} from \"@fortawesome/free-solid-svg-icons\";\nimport type { IssuesTrackerResult } from \"@ostack.tech/kform-react\";\nimport {\n Card,\n CardHeader,\n type CardProps,\n CardTitle,\n cx,\n Icon,\n type IconButtonColor,\n Layer,\n Spinner,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport type { IssuesPanelProps } from \"./IssuesPanel.tsx\";\n\nexport interface IssuesPanelSummaryCardProps\n extends\n CardProps,\n Pick<\n IssuesPanelProps,\n | \"errorsLabel\"\n | \"warningsLabel\"\n | \"noIssuesMessage\"\n | \"headerProps\"\n | \"loadingSpinnerProps\"\n | \"titleProps\"\n | \"iconProps\"\n > {\n issuesTrackerResult: IssuesTrackerResult;\n renderControls: (buttonsColor?: IconButtonColor) => ReactNode;\n}\n\nexport function IssuesPanelSummaryCard({\n issuesTrackerResult,\n errorsLabel,\n warningsLabel,\n noIssuesMessage,\n renderControls,\n headerProps,\n loadingSpinnerProps,\n titleProps,\n iconProps,\n className,\n ...otherProps\n}: IssuesPanelSummaryCardProps) {\n const prefix = usePrefix();\n const { initialized, info, errors, warnings } = issuesTrackerResult;\n const nPages = info?.length ?? 0;\n\n // Relevant icon and colour\n const relevantIcon = initialized\n ? errors > 0\n ? faCircleExclamation\n : warnings > 0\n ? faTriangleExclamation\n : faCircleCheck\n : undefined;\n const relevantColor = initialized\n ? errors > 0\n ? \"danger\"\n : warnings > 0\n ? \"warning\"\n : \"success\"\n : undefined;\n\n return (\n <Card\n variant=\"subtle\"\n mergeSections\n className={cx(\n prefix(\"issues-panel\"),\n prefix(\"issues-panel--summary\"),\n className,\n )}\n {...otherProps}\n color={initialized ? relevantColor : \"neutral\"}\n >\n <Layer zIndex=\"sticky\">\n <CardHeader\n {...headerProps}\n className={cx(prefix(\"issues-panel__header\"), headerProps?.className)}\n >\n {/* Initialisation spinner. */}\n {!initialized && (\n <Spinner\n size=\"lg\"\n {...loadingSpinnerProps}\n className={cx(\n prefix(\"issues-panel__loading-spinner\"),\n loadingSpinnerProps?.className,\n )}\n />\n )}\n\n {initialized && (\n <>\n {/* Panel icon. */}\n <Icon\n color={relevantColor}\n size=\"lg\"\n {...iconProps}\n className={cx(\n prefix(\"issues-panel__icon\"),\n iconProps?.className,\n )}\n icon={relevantIcon!}\n />\n\n <CardTitle\n role=\"status\"\n {...titleProps}\n className={cx(\n prefix(\"issues-panel__title\"),\n titleProps?.className,\n )}\n >\n {nPages === 0 && noIssuesMessage}\n {nPages > 0 && (\n <>\n {errors > 0 && errorsLabel?.(errors)}\n {errors > 0 && warnings > 0 && \", \"}\n {warnings > 0 && warningsLabel?.(warnings)}\n </>\n )}\n </CardTitle>\n </>\n )}\n\n {renderControls(relevantColor)}\n </CardHeader>\n </Layer>\n </Card>\n );\n}\n","import {\n AbsolutePath,\n AbsolutePathFragment,\n compareSchemaPaths,\n type Schema,\n} from \"@ostack.tech/kform\";\nimport {\n type IssuesTrackerOptions,\n type LocatedValidationInfo,\n useController,\n useFormManager,\n useIssuesTracker,\n} from \"@ostack.tech/kform-react\";\nimport {\n type CardBodyProps,\n type CardHeaderProps,\n type CardProps,\n type CardTitleProps,\n type CloseButtonProps,\n Container,\n cx,\n type IconButtonColor,\n type IconButtonProps,\n type IconProps,\n Layer,\n setBoolDataAttr,\n type SpinnerProps,\n useCombinedRef,\n useControllableState,\n useIntersectionObserver,\n useLatestRef,\n useMeasure,\n usePrevious,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport {\n type ComponentProps,\n type ReactNode,\n useCallback,\n useDeferredValue,\n useEffect,\n useEffectEvent,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useReportValidationFailures } from \"../../utils/useReportValidationFailures.ts\";\nimport {\n useFocus,\n useFormAppElement,\n useIssuesDisplayMode,\n useSetBottomPanelHeight,\n} from \"../FormApp\";\nimport {\n useIssuesPanelPath,\n useLatestInteraction,\n useSetStartIssuesNavigation,\n} from \"../FormApp/FormAppContext.ts\";\nimport { IssuesPanelControls } from \"./IssuesPanelControls.tsx\";\nimport { IssuesPanelMessagesCard } from \"./IssuesPanelMessagesCard.tsx\";\nimport { IssuesPanelSummaryCard } from \"./IssuesPanelSummaryCard.tsx\";\n\n/** Default “focus” keybinds. */\nexport const DEFAULT_FOCUS_KEYBINDS = \"Alt+Shift+F\";\n/** Default “previous issue” keybinds. */\nexport const DEFAULT_PREVIOUS_ISSUE_KEYBINDS = \"Alt+Shift+ArrowLeft\";\n/** Default “next issue” keybinds. */\nexport const DEFAULT_NEXT_ISSUE_KEYBINDS = \"Alt+Shift+ArrowRight\";\n/** Default “first issue” keybinds. */\nexport const DEFAULT_FIRST_ISSUE_KEYBINDS = \"Alt+Shift+Home\";\n/** Default “last issue” keybinds. */\nexport const DEFAULT_LAST_ISSUE_KEYBINDS = \"Alt+Shift+End\";\n\n/** Properties of the issues navigation component. */\nexport interface IssuesPanelProps\n extends\n Pick<IssuesTrackerOptions, \"issuesOrderCompareFn\">,\n Omit<CardProps, \"children\" | \"variant\" | \"color\"> {\n /** Default open state of the issues navigation panel. */\n defaultOpen?: boolean;\n /** Controlled open state of the issues navigation panel. */\n open?: boolean;\n /**\n * Function called whenever the open state of the issues navigation panel\n * changes.\n *\n * @param open New open state.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Whether to display issue codes together with each issue message.\n *\n * This property can also be set globally via the `displayIssueCodes` property\n * of the `FormApp`.\n */\n displayIssueCodes?: boolean;\n /**\n * Message to show for an error that does not have an associated message.\n *\n * This message will always automatically include the code of the issue in\n * question.\n */\n unknownErrorMessage?: ReactNode;\n /**\n * Message to show for a warning that does not have an associated message.\n *\n * This message will always automatically include the code of the issue in\n * question.\n */\n unknownWarningMessage?: ReactNode;\n /**\n * Errors label.\n *\n * @param errors Number of errors. If undefined, the function should return a\n * generic label with no number.\n */\n errorsLabel?: (errors?: number) => ReactNode;\n /**\n * Warnings label.\n *\n * @param warnings Number of warnings. If undefined, the function should\n * return a generic label with no number.\n */\n warningsLabel?: (warnings?: number) => ReactNode;\n /** Label of the focus button. */\n focusButtonLabel?: string;\n /** Keybinds to trigger the \"focus\" button. */\n focusKeybinds?: string | string[] | null;\n /** Label of the \"previous issue\" button. */\n previousIssueButtonLabel?: string;\n /** Keybinds to trigger the \"previous issue\" button. */\n previousIssueKeybinds?: string | string[] | null;\n /** Label of the \"next issue\" button. */\n nextIssueButtonLabel?: string;\n /** Keybinds to trigger the \"next issue\" button. */\n nextIssueKeybinds?: string | string[] | null;\n /** Label of the \"first issue\" button. */\n firstIssueButtonLabel?: string;\n /** Keybinds to trigger the \"first issue\" button. */\n firstIssueKeybinds?: string | string[] | null;\n /** Label of the \"last issue\" button. */\n lastIssueButtonLabel?: string;\n /** Keybinds to trigger the \"last issue\" button. */\n lastIssueKeybinds?: string | string[] | null;\n /**\n * Text announced to assistive technologies with the current page out of the\n * total number of pages.\n *\n * @param currentPage Current page.\n * @param totalPages Total number of pages.\n */\n paginationLabel?: (currentPage: number, totalPages: number) => ReactNode;\n /** Message to display when there are no issues to report. */\n noIssuesMessage?: ReactNode;\n /** Title to display when all issues of the active path have been resolved. */\n resolvedTitle?: ReactNode;\n /** Message to display when all issues of the active path have been resolved. */\n resolvedMessage?: ReactNode;\n /** Properties to pass to the container element. */\n containerProps?: ComponentProps<\"div\">;\n /** Properties to pass to the card header component. */\n headerProps?: CardHeaderProps;\n /** Properties to pass to the card body component. */\n bodyProps?: CardBodyProps;\n /** Properties to pass to the loading `Spinner` component. */\n loadingSpinnerProps?: SpinnerProps;\n /** Properties to pass to the validating `Spinner` component. */\n validatingSpinnerProps?: SpinnerProps;\n /** Properties to pass to the pagination element. */\n paginationProps?: ComponentProps<\"div\">;\n /** Properties to pass to the \"focus\" button component. */\n focusButtonProps?: Omit<IconButtonProps, \"label\">;\n /** Properties to pass to the \"previous issue\" button component. */\n previousIssueButtonProps?: Omit<IconButtonProps, \"label\">;\n /** Properties to pass to the \"next issue\" button component. */\n nextIssueButtonProps?: Omit<IconButtonProps, \"label\">;\n /** Properties to pass to the \"first issue\" button component. */\n firstIssueButtonProps?: Omit<IconButtonProps, \"label\">;\n /** Properties to pass to the \"last issue\" button component. */\n lastIssueButtonProps?: Omit<IconButtonProps, \"label\">;\n /** Properties to pass to the icon component. */\n iconProps?: Omit<IconProps, \"icon\">;\n /** Properties to pass to the title component. */\n titleProps?: CardTitleProps;\n /** Properties to pass to the close button component. */\n closeButtonProps?: CloseButtonProps;\n}\n\n/** Component used to navigate through the issues of the form. */\nexport function IssuesPanel({\n defaultOpen = false,\n open: controlledOpen,\n onOpenChange,\n displayIssueCodes,\n issuesOrderCompareFn,\n unknownErrorMessage,\n unknownWarningMessage,\n errorsLabel,\n warningsLabel,\n focusButtonLabel,\n focusKeybinds: focusKeybindsProp,\n previousIssueButtonLabel,\n previousIssueKeybinds: previousIssueKeybindsProp,\n nextIssueButtonLabel,\n nextIssueKeybinds: nextIssueKeybindsProp,\n firstIssueButtonLabel,\n firstIssueKeybinds: firstIssueKeybindsProp,\n lastIssueButtonLabel,\n lastIssueKeybinds: lastIssueKeybindsProp,\n paginationLabel,\n noIssuesMessage,\n resolvedTitle,\n resolvedMessage,\n containerProps,\n headerProps,\n bodyProps,\n loadingSpinnerProps,\n validatingSpinnerProps,\n paginationProps,\n focusButtonProps,\n previousIssueButtonProps,\n nextIssueButtonProps,\n firstIssueButtonProps,\n lastIssueButtonProps,\n titleProps,\n iconProps,\n closeButtonProps,\n ...otherProps\n}: IssuesPanelProps) {\n const prefix = usePrefix();\n const printing = usePrinting();\n const [locale] = useLocale();\n errorsLabel ??= locale.IssuesPanel.errorsLabel;\n warningsLabel ??= locale.IssuesPanel.warningsLabel;\n focusButtonLabel ??= locale.IssuesPanel.focusButtonLabel;\n const focusKeybinds =\n focusKeybindsProp === undefined\n ? (locale.IssuesPanel.focusKeybinds ?? DEFAULT_FOCUS_KEYBINDS)\n : focusKeybindsProp;\n previousIssueButtonLabel ??= locale.IssuesPanel.previousIssueButtonLabel;\n const previousIssueKeybinds =\n previousIssueKeybindsProp === undefined\n ? (locale.IssuesPanel.previousIssueKeybinds ??\n DEFAULT_PREVIOUS_ISSUE_KEYBINDS)\n : previousIssueKeybindsProp;\n nextIssueButtonLabel ??= locale.IssuesPanel.nextIssueButtonLabel;\n const nextIssueKeybinds =\n nextIssueKeybindsProp === undefined\n ? (locale.IssuesPanel.nextIssueKeybinds ?? DEFAULT_NEXT_ISSUE_KEYBINDS)\n : nextIssueKeybindsProp;\n firstIssueButtonLabel ??= locale.IssuesPanel.firstIssueButtonLabel;\n const firstIssueKeybinds =\n firstIssueKeybindsProp === undefined\n ? (locale.IssuesPanel.firstIssueKeybinds ?? DEFAULT_FIRST_ISSUE_KEYBINDS)\n : firstIssueKeybindsProp;\n lastIssueButtonLabel ??= locale.IssuesPanel.lastIssueButtonLabel;\n const lastIssueKeybinds =\n lastIssueKeybindsProp === undefined\n ? (locale.IssuesPanel.lastIssueKeybinds ?? DEFAULT_LAST_ISSUE_KEYBINDS)\n : lastIssueKeybindsProp;\n paginationLabel ??= locale.IssuesPanel.paginationLabel;\n noIssuesMessage ??= locale.IssuesPanel.noIssuesMessage;\n resolvedTitle ??= locale.IssuesPanel.resolvedTitle;\n resolvedMessage ??= locale.IssuesPanel.resolvedMessage;\n\n const [open, setOpen] = useControllableState(defaultOpen, controlledOpen);\n const formIsLoading = useFormIsLoading();\n const issuesTrackerResult = useIssuesTracker(AbsolutePath.MATCH_ALL, {\n enabled: open && !formIsLoading && !printing,\n issuesOrderCompareFn,\n });\n useReportValidationFailures(issuesTrackerResult.info);\n const latestInteraction = useLatestInteraction();\n const deferredIssuesTrackerResult = useDeferredValue(issuesTrackerResult);\n const { info } = deferredIssuesTrackerResult;\n const nPages = info?.length ?? 0;\n\n const [currentPagePath, setCurrentPagePath] = useIssuesPanelPath();\n const currentPageController = useController(\n currentPagePath ?? AbsolutePath.ROOT,\n { enabled: open && !formIsLoading && currentPagePath !== null },\n );\n\n // Set the current page path as the latest interaction when going from \"no\n // issues\" to \"issues exist\"\n const prevIssuesTrackerResultInfoLength = usePrevious(\n issuesTrackerResult.info?.length,\n );\n const handleNewIssues = useEffectEvent(() => {\n setCurrentPagePath(latestInteraction);\n });\n useEffect(() => {\n if (\n prevIssuesTrackerResultInfoLength === 0 &&\n issuesTrackerResult.initialized &&\n issuesTrackerResult.info.length > 0\n ) {\n handleNewIssues();\n }\n }, [\n issuesTrackerResult.info?.length,\n issuesTrackerResult.initialized,\n prevIssuesTrackerResultInfoLength,\n ]);\n\n // Index of the page with the current path\n const currentPageIndex = useMemo(\n () =>\n currentPagePath\n ? (info?.findIndex(({ path }) => currentPagePath.equals(path)) ?? -1)\n : -1,\n [currentPagePath, info],\n );\n // Keep track of the last existing page index that we've visited\n const lastExistingPageIndex = useRef<number | null>(null);\n useEffect(() => {\n if (currentPageIndex !== -1) {\n lastExistingPageIndex.current = currentPageIndex;\n }\n }, [currentPageIndex]);\n\n // Go to a specified page and focus its respective field\n const focus = useFocus();\n const goToPath = useCallback(\n (path: AbsolutePath | null) => {\n setCurrentPagePath(path);\n if (path) {\n focus(path);\n }\n },\n [focus, setCurrentPagePath],\n );\n const goToPage = useCallback(\n (page: number) => {\n if (nPages > 0) {\n const clampedPage = Math.max(0, Math.min(page, nPages - 1));\n const newCurrentPath = info![clampedPage].path ?? null;\n goToPath(newCurrentPath);\n }\n },\n [goToPath, info, nPages],\n );\n const goToPreviousPage = useCallback(() => {\n if (currentPageIndex !== -1) {\n goToPage(currentPageIndex - 1);\n } else {\n goToPage((lastExistingPageIndex.current ?? 1) - 1);\n }\n }, [currentPageIndex, goToPage]);\n const goToNextPage = useCallback(() => {\n if (currentPageIndex !== -1) {\n goToPage(currentPageIndex + 1);\n } else {\n goToPage(lastExistingPageIndex.current ?? 0);\n }\n }, [currentPageIndex, goToPage]);\n const goToFirstPage = useCallback(() => goToPage(0), [goToPage]);\n const goToLastPage = useCallback(\n () => goToPage(nPages - 1),\n [goToPage, nPages],\n );\n\n const formManager = useFormManager();\n const formSchema = useMemo(() => formManager.schema(), [formManager]);\n const latestRef = useLatestRef({ issuesOrderCompareFn, onOpenChange });\n\n // Focus initial issue when starting\n const [starting, setStarting] = useState(false);\n useEffect(() => {\n if (issuesTrackerResult.initialized && starting) {\n if (issuesTrackerResult.info.length > 0) {\n goToPath(\n mostRelevantIssuePath(\n issuesTrackerResult.info,\n latestInteraction,\n formSchema,\n latestRef.current.issuesOrderCompareFn,\n ),\n );\n }\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setStarting(false);\n }\n }, [\n formSchema,\n goToPath,\n issuesTrackerResult.info,\n issuesTrackerResult.initialized,\n latestInteraction,\n latestRef,\n starting,\n ]);\n\n // Starts the issues navigation\n const start = useCallback(() => {\n if (!open) {\n setOpen(true);\n latestRef.current.onOpenChange?.(true);\n }\n setCurrentPagePath(null);\n setStarting(true);\n lastExistingPageIndex.current = null;\n }, [latestRef, open, setCurrentPagePath, setOpen]);\n\n // Expose the `start` function to the form app\n useSetStartIssuesNavigation(start);\n\n // Keep track of the container's height\n const [containerEl, setContainerEl] = useState<HTMLDivElement | null>(null);\n const setBottomPanelHeight = useSetBottomPanelHeight();\n useMeasure(\n containerEl,\n useCallback(\n (measurement) => setBottomPanelHeight(measurement?.height),\n [setBottomPanelHeight],\n ),\n );\n\n // Sticky style for panel\n const formAppEl = useFormAppElement();\n useIntersectionObserver(\n containerEl,\n useCallback(\n (e) => setBoolDataAttr(containerEl, \"stuck\", e.intersectionRatio === 1),\n [containerEl],\n ),\n useMemo(\n () => ({\n root: formAppEl,\n rootMargin: `0px 0px -1px 0px`,\n threshold: [1],\n }),\n [formAppEl],\n ),\n );\n\n // Hides the issues panel\n const close = useCallback(() => {\n if (open) {\n setOpen(false);\n latestRef.current.onOpenChange?.(false);\n }\n }, [latestRef, open, setOpen]);\n\n const renderControls = (buttonsColor?: IconButtonColor) => (\n <IssuesPanelControls\n nPages={nPages}\n currentPagePath={currentPagePath}\n currentPageIndex={currentPageIndex}\n currentPageController={currentPageController}\n goToPreviousPage={goToPreviousPage}\n goToNextPage={goToNextPage}\n goToFirstPage={goToFirstPage}\n goToLastPage={goToLastPage}\n buttonsColor={buttonsColor}\n closePanel={close}\n focusButtonLabel={focusButtonLabel}\n focusKeybinds={focusKeybinds}\n previousIssueButtonLabel={previousIssueButtonLabel}\n previousIssueKeybinds={previousIssueKeybinds}\n nextIssueButtonLabel={nextIssueButtonLabel}\n nextIssueKeybinds={nextIssueKeybinds}\n firstIssueButtonLabel={firstIssueButtonLabel}\n firstIssueKeybinds={firstIssueKeybinds}\n lastIssueButtonLabel={lastIssueButtonLabel}\n lastIssueKeybinds={lastIssueKeybinds}\n paginationLabel={paginationLabel}\n validatingSpinnerProps={validatingSpinnerProps}\n paginationProps={paginationProps}\n focusButtonProps={focusButtonProps}\n previousIssueButtonProps={previousIssueButtonProps}\n nextIssueButtonProps={nextIssueButtonProps}\n firstIssueButtonProps={firstIssueButtonProps}\n lastIssueButtonProps={lastIssueButtonProps}\n closeButtonProps={closeButtonProps}\n />\n );\n\n const displayMode = useIssuesDisplayMode();\n const combinedContainerRef = useCombinedRef(\n setContainerEl,\n containerProps?.ref,\n );\n return (\n open &&\n !printing && (\n <Layer zIndex={[\"docked\", 1]}>\n <div\n {...containerProps}\n className={cx(\n prefix(\"issues-panel__container\"),\n containerProps?.className,\n )}\n ref={combinedContainerRef}\n >\n <Container asChild fluid=\"md\">\n {displayMode === \"inline\" ? (\n <IssuesPanelSummaryCard\n issuesTrackerResult={deferredIssuesTrackerResult}\n renderControls={renderControls}\n errorsLabel={errorsLabel}\n warningsLabel={warningsLabel}\n noIssuesMessage={noIssuesMessage}\n headerProps={headerProps}\n loadingSpinnerProps={loadingSpinnerProps}\n titleProps={titleProps}\n iconProps={iconProps}\n {...otherProps}\n />\n ) : (\n <IssuesPanelMessagesCard\n currentPagePath={currentPagePath}\n currentPageController={currentPageController}\n issuesTrackerResult={deferredIssuesTrackerResult}\n currentPageIndex={currentPageIndex}\n displayIssueCodes={displayIssueCodes}\n unknownErrorMessage={unknownErrorMessage}\n unknownWarningMessage={unknownWarningMessage}\n renderControls={renderControls}\n errorsLabel={errorsLabel}\n warningsLabel={warningsLabel}\n noIssuesMessage={noIssuesMessage}\n resolvedTitle={resolvedTitle}\n resolvedMessage={resolvedMessage}\n headerProps={headerProps}\n bodyProps={bodyProps}\n loadingSpinnerProps={loadingSpinnerProps}\n titleProps={titleProps}\n iconProps={iconProps}\n {...otherProps}\n />\n )}\n </Container>\n </div>\n </Layer>\n )\n );\n}\n\n/**\n * Function attempting to return the \"most relevant\" issue, given the list of\n * issue information, the path of the current page, and the path the user last\n * interacted with.\n */\nfunction mostRelevantIssuePath(\n info: LocatedValidationInfo[],\n latestInteraction: AbsolutePath,\n formSchema: Schema,\n issuesOrderCompareFn: IssuesTrackerOptions[\"issuesOrderCompareFn\"],\n): AbsolutePath {\n // Try to match the latest interaction exactly when a custom\n // `issuesOrderCompareFn` is provided, since we have no guarantee that the\n // first issue >= latest interaction will be the latest interaction itself\n // when it has an issue\n if (issuesOrderCompareFn) {\n for (const infoIssues of info) {\n if (latestInteraction.equals(infoIssues.path)) {\n return latestInteraction;\n }\n }\n }\n\n // Find index of first issues path >= latest interaction; if no such path\n // exists, set this index to the size of the info\n let indexOfInfoPathGteActivePath = info.findIndex(\n (issuesInfo) =>\n (issuesOrderCompareFn?.(issuesInfo.path, latestInteraction) ||\n compareSchemaPaths(formSchema, issuesInfo.path, latestInteraction)) >=\n 0,\n );\n if (indexOfInfoPathGteActivePath === -1) {\n indexOfInfoPathGteActivePath = info.length;\n }\n\n // Match a descendant of the latest interaction, or a descendant of one of its\n // ancestors\n let curPath = latestInteraction;\n while (!curPath.isRoot) {\n const curPathWithDescendants = curPath.append(\n AbsolutePathFragment.RecursiveWildcard,\n );\n for (let i = indexOfInfoPathGteActivePath; i < info.length; ++i) {\n if (curPathWithDescendants.matches(info[i].path)) {\n return info[i].path;\n }\n }\n for (let i = indexOfInfoPathGteActivePath - 1; i >= 0; --i) {\n if (curPathWithDescendants.matches(info[i].path)) {\n return info[i].path;\n }\n }\n curPath = curPath.parent();\n }\n return info[0].path;\n}\n","import { faFolderOpen } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n Action,\n type ActionButtonProps,\n combineEventHandlers,\n useActionsContext,\n useKeyboardShortcut,\n} from \"@ostack.tech/ui\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport {\n type FormLoaderOptions,\n useFormIsLoading,\n useFormLoader,\n} from \"../../utils/useFormLoader.tsx\";\nimport {\n useFormAppElement,\n useFormIsDisabled,\n useFormIsReadOnly,\n} from \"../FormApp\";\n\n/** Default “load” keybinds. */\nexport const DEFAULT_LOAD_KEYBINDS = \"$mod+O\";\n\n/** Properties of the load action. */\nexport interface LoadActionProps<T = unknown>\n extends Partial<ActionButtonProps>, Omit<FormLoaderOptions<T>, \"id\"> {\n /**\n * Keybinds for triggering the action. Set to `null` to disable the keyboard\n * shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * {@link DEFAULT_LOAD_KEYBINDS}.\n */\n keybinds?: string | string[] | null;\n /**\n * Whether to show the load action when the form is read-only.\n *\n * @default false\n */\n showWhenReadOnly?: boolean;\n /**\n * By specifying a filesystem ID, the user agent can remember different\n * directories for different IDs.\n */\n fileSystemId?: string;\n}\n\n/**\n * Form action used to load the form from a file. Built on top of the [`Button`\n * component](/docs/ostack-ui-forms-button--docs) and `useFormLoader` hook.\n *\n * Example usage:\n *\n * ```tsx\n * import { LoadAction } from \"@ostack.tech/ui-kform\";\n *\n * function LoadForm() {\n * return (\n * <LoadAction\n * decode={async (file) => decodeFormFromJSON(await file.text())}\n * mimeTypes={[\"application/json\"]}\n * extensions={[\".json\"]}\n * />\n * );\n * }\n * ```\n */\nexport function LoadAction<T = unknown>({\n label,\n keybinds,\n showWhenReadOnly,\n fileSystemId,\n loading,\n disabled,\n onClick,\n decode,\n path,\n extensions,\n mimeTypes,\n description,\n startIn,\n setPristineOnLoad,\n validateOnLoad,\n successMessage,\n errorMessage,\n ...otherProps\n}: LoadActionProps<T>) {\n const [locale] = useLocale();\n label ??= locale.LoadAction.label;\n if (keybinds === undefined) {\n keybinds = locale.LoadAction.keybinds ?? DEFAULT_LOAD_KEYBINDS;\n }\n\n const { load } = useFormLoader({\n decode,\n path,\n extensions,\n mimeTypes,\n description,\n startIn,\n id: fileSystemId,\n setPristineOnLoad,\n validateOnLoad,\n successMessage,\n errorMessage,\n });\n const formIsDisabled = useFormIsDisabled();\n const formIsReadOnly = useFormIsReadOnly();\n const formIsLoading = useFormIsLoading();\n\n const showAction = !formIsReadOnly || showWhenReadOnly;\n const showDisabled = disabled || formIsDisabled;\n const showLoading = loading || formIsLoading;\n\n // Set-up keyboard shortcut\n const formAppEl = useFormAppElement();\n useKeyboardShortcut(keybinds, () => load(), {\n disabled: !showAction || showDisabled || showLoading,\n target: formAppEl,\n preventDefault: true,\n });\n\n const { secondary } = useActionsContext() ?? {};\n return (\n showAction && (\n <Action\n layout={secondary ? undefined : \"vertical\"}\n label={label}\n variant=\"subtle\"\n icon={faFolderOpen}\n {...otherProps}\n onClick={combineEventHandlers(() => load(), onClick as never)}\n disabled={showDisabled}\n loading={showLoading}\n keybinds={keybinds}\n />\n )\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n formatNumericAsString,\n type Numeric,\n type NumericInputController,\n type NumericInputOptions,\n useNumericInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n NumericInput,\n type NumericInputProps,\n type NumericValueRepresentations,\n useCombinedRef,\n useLatestRef,\n warnOnce,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useState,\n} from \"react\";\n\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\n\n/** Kotlin integer types. */\nconst INTEGER_TYPES = [\"Byte\", \"Char\", \"Short\", \"Int\", \"Long\", \"BigInteger\"];\n\n/** Properties of the numeric control component. */\nexport interface NumericControlProps<T extends Numeric | null = Numeric | null>\n extends\n Omit<\n NumericInputOptions<T, string, ComponentRef<typeof NumericInput>>,\n \"enabled\" | \"formatFromString\" | \"parseToString\"\n >,\n Omit<\n NumericInputProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"valueIsUnformattedString\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | NumericInputController<T, string, ComponentRef<typeof NumericInput>>\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The numeric control component is a KForm form control for values with\n * (typically nullable) numeric schemas. It is built on top of the\n * [`NumericInput`](/docs/ostack-ui-forms-numeric-input--docs) component.\n *\n * The following (typically\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * KForm schemas are supported:\n * [`ByteSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-byte-schema/index.html),\n * [`CharSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-char-schema/index.html),\n * [`ShortSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-short-schema/index.html),\n * [`IntSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-int-schema/index.html),\n * [`LongSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-long-schema/index.html),\n * [`FloatSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-float-schema/index.html),\n * [`DoubleSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-double-schema/index.html),\n * [`BigIntegerSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-big-integer-schema/index.html),\n * [`BigDecimalSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-big-decimal-schema/index.html),\n * and\n * [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Min`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min/index.html)/[`Max`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max/index.html)/[`ExclusiveMin`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-min/index.html)/[`ExclusiveMax`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-max/index.html):\n * Sets the `min`/`max`/`minExclusive`/`maxExclusive` properties.\n * - [`Scale`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-scale/index.html)/[`MaxScale`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-scale/index.html):\n * Sets the `scale` property.\n *\n * The `valueIsInteger` property is further automatically set for integer\n * schemas (`Byte`, `Char`, `Short`, `Int`, `Long`, and `BigInteger`).\n *\n * Example usage:\n *\n * ```tsx\n * import { NumericControl } from \"@ostack.tech/ui-kform\";\n *\n * function QuantityControl() {\n * return (\n * <NumericControl path=\"/quantity\" placeholder=\"Number of items…\" />\n * );\n * }\n * ```\n */\nexport function NumericControl<T extends Numeric | null = Numeric | null>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n valueIsInteger,\n scale,\n required,\n min,\n max,\n exclusiveMin,\n exclusiveMax,\n loading,\n showSpinner,\n disabled,\n readOnly,\n endAdornment,\n onFocus,\n onBlurToOutside,\n debug,\n ref,\n ...otherProps\n}: NumericControlProps<T>) {\n const [stringValue, setStringValue] = useState(\"\");\n const controller = useNumericInput<\n T,\n string,\n ComponentRef<typeof NumericInput>\n >(path, {\n enabled: !useFormIsLoading(),\n setFormattedValue: setStringValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange: combineEventHandlers(\n onValueChange,\n useResetOnChangeContext(),\n ),\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLInputElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const latestRef = useLatestRef({ stringValue });\n const handleValueChange = useCallback(\n ({ stringValue }: NumericValueRepresentations) => {\n if (stringValue !== latestRef.current.stringValue) {\n inputProps.onChange(stringValue);\n setStringValue(stringValue);\n }\n },\n [inputProps, latestRef],\n );\n\n const schemaIsInteger = INTEGER_TYPES.includes(schema.typeInfo.name);\n if (schemaIsInteger && valueIsInteger !== undefined) {\n warnOnce(\n `NumericControl: At '${absolutePath.toString()}': Property ` +\n \"`valueIsInteger` has no effect (it will always be `true`) when the \" +\n \"control's schema is one of the integer types.\",\n );\n }\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedNumericInputRef = useCombinedRef(\n inputProps.ref,\n autofocusRef,\n ref,\n );\n return (\n <FeedbackProvider>\n <NumericInput\n value={stringValue}\n valueIsUnformattedString\n valueIsInteger={schemaIsInteger || valueIsInteger}\n scale={\n scale ??\n (restrictions.maxScale == null\n ? undefined\n : (restrictions.maxScale as number))\n }\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n min={\n min ??\n (restrictions.min == null\n ? undefined\n : formatNumericAsString(restrictions.min as T, schema))\n }\n max={\n max ??\n (restrictions.max == null\n ? undefined\n : formatNumericAsString(restrictions.max as T, schema))\n }\n exclusiveMin={\n exclusiveMin ??\n (restrictions.exclusiveMin == null\n ? undefined\n : formatNumericAsString(restrictions.exclusiveMin as T, schema))\n }\n exclusiveMax={\n exclusiveMax ??\n (restrictions.exclusiveMax == null\n ? undefined\n : formatNumericAsString(restrictions.exclusiveMax as T, schema))\n }\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedNumericInputRef}\n />\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport { useResolvedPath } from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n Link,\n type LinkAs,\n type LinkOwnProps,\n type PolymorphicProps,\n} from \"@ostack.tech/ui\";\nimport type { MouseEvent } from \"react\";\n\nimport { useFocus } from \"../FormApp\";\n\n/** Elements a path link can be rendered as. */\nexport type PathLinkAs = LinkAs;\n\n/** Properties of the path link component. */\nexport type PathLinkProps<TAs extends PathLinkAs = \"button\"> = PolymorphicProps<\n PathLinkAs,\n TAs,\n \"button\",\n PathLinkOwnProps\n>;\n\n/** Own properties of the path link component. */\nexport interface PathLinkOwnProps extends LinkOwnProps {\n /** KForm path to link to. */\n to: string | Path;\n}\n\n/**\n * The path link component creates a link (although typically rendered as a\n * `<button>`) to a part of the form identified by the provided path. It is\n * built on top of the [`Link`\n * component](/docs/ostack-ui-typography-link--docs).\n *\n * Example usage:\n *\n * ```tsx\n * import { Alert } from \"@ostack.tech/ui\";\n * import { PathLink } from \"@ostack.tech/ui-kform\";\n *\n * function ProfileNotice() {\n * return (\n * <Alert>\n * Your profile URL will be generated using your handle. To change it,\n * update your <PathLink to=\"/username\">username</PathLink>.\n * </Alert>\n * );\n * }\n * ```\n */\nexport function PathLink<TAs extends PathLinkAs = \"button\">({\n as = \"button\" as never,\n to,\n onClick,\n ...otherProps\n}: PathLinkProps<TAs>) {\n const focus = useFocus();\n const path = useResolvedPath(to);\n\n const handleClick = (evt: MouseEvent) => {\n evt.preventDefault();\n focus(path);\n };\n\n return (\n <Link\n as={as}\n {...(otherProps as any)}\n onClick={combineEventHandlers(onClick as never, handleClick, {\n checkDefaultPrevented: true,\n })}\n />\n );\n}\n","import { faPrint } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n Action,\n type ActionButtonProps,\n combineEventHandlers,\n PrinterTrigger,\n useActionsContext,\n useKeyboardShortcut,\n usePrint,\n usePrinterDocumentTitle,\n usePrintInProgress,\n} from \"@ostack.tech/ui\";\nimport type { MouseEvent } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport {\n useFormAppElement,\n useFormIsDisabled,\n useFormIsReadOnly,\n useFormTitle,\n} from \"../FormApp\";\n\n/** Default “print” keybinds. */\nexport const DEFAULT_PRINT_KEYBINDS = \"$mod+P\";\n\n/** Properties of the print action. */\nexport interface PrintActionProps extends Partial<ActionButtonProps> {\n /**\n * Keybinds for triggering the action. Set to `null` to disable the keyboard\n * shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * `DEFAULT_PRINT_KEYBINDS`.\n */\n keybinds?: string | string[] | null;\n /**\n * Whether to show the print action when the form is read-only.\n *\n * @default true\n */\n showWhenReadOnly?: boolean;\n}\n\n/**\n * Form action used to print the form application. Built on top of the\n * [`Button`](/docs/ostack-ui-forms-button--docs) and\n * [`PrinterTrigger`](/docs/ostack-ui-utilities-printer--docs) components.\n *\n * To print a whole form application, requires the `<FormApp>` component to be\n * wrapped within a `<Printer>`, and for the `<PrinterContent>` to wrap all\n * annexes, pages, and form controls.\n *\n * Example usage:\n *\n * ```tsx\n * import { Printer, PrinterContent } from \"@ostack.tech/ui\";\n * import {\n * FormApp,\n * PrintAction,\n * TopBar,\n * TopBarActions,\n * } from \"@ostack.tech/ui-kform\";\n *\n * export function App() {\n * return (\n * <Printer>\n * <FormApp schema={…}>\n * <PrinterContent>\n * <TopBar>\n * …\n * <TopBarActions>\n * …\n * <PrintAction />\n * </TopBarActions>\n * </TopBar>\n * …\n * </PrinterContent>\n * </FormApp>\n * </Printer>\n * );\n * }\n * ```\n */\nexport function PrintAction({\n label,\n keybinds,\n showWhenReadOnly = true,\n disabled,\n loading,\n onClick,\n ...otherProps\n}: PrintActionProps) {\n const [locale] = useLocale();\n label ??= locale.PrintAction.label;\n if (keybinds === undefined) {\n keybinds = locale.PrintAction.keybinds ?? DEFAULT_PRINT_KEYBINDS;\n }\n\n const printInProgress = usePrintInProgress();\n const formIsDisabled = useFormIsDisabled();\n const formIsReadOnly = useFormIsReadOnly();\n const formIsLoading = useFormIsLoading();\n\n const showAction = !formIsReadOnly || showWhenReadOnly;\n const showDisabled = disabled || formIsDisabled || formIsLoading;\n const showLoading = loading || printInProgress;\n\n // Set-up keyboard shortcut\n const formAppEl = useFormAppElement();\n const formTitle = useFormTitle();\n const print = usePrint();\n\n // Only provide a default `documentTitle` if the one is not provided in the\n // `Printer` component\n const printerHasDocumentTitle = Boolean(usePrinterDocumentTitle());\n const handlePrint = (evt: MouseEvent | KeyboardEvent) => {\n evt.preventDefault();\n void print(\n printerHasDocumentTitle ? undefined : { documentTitle: formTitle },\n );\n };\n\n useKeyboardShortcut(keybinds, handlePrint, {\n disabled: !showAction || showDisabled || showLoading,\n target: formAppEl,\n preventDefault: true,\n });\n\n const { secondary } = useActionsContext() ?? {};\n return (\n showAction && (\n <PrinterTrigger\n onClick={combineEventHandlers(onClick, handlePrint, {\n checkDefaultPrevented: true,\n })}\n >\n <Action\n label={label}\n layout={secondary ? undefined : \"vertical\"}\n variant=\"subtle\"\n icon={faPrint}\n {...otherProps}\n disabled={showDisabled}\n loading={showLoading}\n keybinds={keybinds}\n />\n </PrinterTrigger>\n )\n );\n}\n","import type { RadioProps } from \"@ostack.tech/ui\";\nimport type { Key, ReactNode } from \"react\";\n\n/** @deprecated Use {@link RadioGroupControlItemObject} instead. */\nexport type RadioOption<T = unknown> = RadioGroupControlItemObject<T>;\n\n/** Radio group control item in object notation. */\nexport interface RadioGroupControlItemObject<T = unknown> extends Omit<\n RadioProps,\n \"value\" | \"children\"\n> {\n /** Item value. */\n value: T;\n /** Item's rendered text. */\n text?: ReactNode;\n /** Item's unique key. */\n key?: Key;\n}\n\n/** Properties of the radio group control item component. */\nexport interface RadioGroupControlItemProps<T = unknown> extends Omit<\n RadioGroupControlItemObject<T>,\n \"text\"\n> {\n /** Item's rendered text. */\n children?: ReactNode;\n}\n\n/**\n * Definition of a radio group control item.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `RadioGroupControl` component to automatically create the `options` array.\n */\nexport function RadioGroupControlItem(_props: RadioGroupControlItemProps) {\n return null;\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n equals,\n type InputController,\n type InputOptions,\n useInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n parseChildren,\n Radio,\n RadioGroup,\n type RadioGroupProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport {\n formatSelectionValueAsOptionIndex,\n isUnknownValue,\n parseSelectionValueFromOptionIndex,\n} from \"../../utils/selectionTransformations.tsx\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\nimport { UnknownValue } from \"../UnknownValue\";\nimport {\n RadioGroupControlItem,\n type RadioGroupControlItemObject,\n} from \"./RadioGroupControlItem.tsx\";\n\n/** Properties of the radio group control component. */\nexport interface RadioGroupControlProps<T = unknown>\n extends\n Omit<\n InputOptions<T, T, ComponentRef<typeof RadioGroup>>,\n \"enabled\" | \"format\" | \"parse\"\n >,\n Omit<\n RadioGroupProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"children\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /** Radio group control options. */\n options?: RadioGroupControlItemObject<T>[];\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /** Label shown when the control's value isn't one of the existing options. */\n unknownValueLabel?: ReactNode;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /** Radio group control children. */\n children?: ReactNode;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n InputController<T, string, ComponentRef<typeof RadioGroup>> | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The radio group control component is a KForm form control for values with any\n * type of (typically\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schema. It is built on top of the\n * [`RadioGroup`](/docs/ostack-ui-forms-radio-group--docs) component.\n *\n * It composes the following subcomponent:\n *\n * - `RadioGroupControlItem`: Component used to define an item of the radio group\n * control.\n *\n * The following built-in KForm validation affects this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * RadioGroupControl,\n * RadioGroupControlItem,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function ShirtSizeControl() {\n * return (\n * <RadioGroupControl path=\"/shirtSize\">\n * <RadioGroupControlItem value=\"sm\">Small</RadioGroupControlItem>\n * <RadioGroupControlItem value=\"md\">Medium</RadioGroupControlItem>\n * <RadioGroupControlItem value=\"lg\">Large</RadioGroupControlItem>\n * <RadioGroupControlItem value=\"xl\">X-Large</RadioGroupControlItem>\n * </RadioGroupControl>\n * );\n * }\n * ```\n */\nexport function RadioGroupControl<T = unknown>({\n path,\n options,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n unknownValueLabel,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n loading,\n showSpinner,\n disabled,\n readOnly,\n showClearButton = false,\n endAdornment,\n onFocus,\n onBlurToOutside,\n children,\n debug,\n ref,\n ...otherProps\n}: RadioGroupControlProps<T>) {\n const [locale] = useLocale();\n unknownValueLabel ??= locale.RadioGroupControl.unknownValueLabel;\n\n options ??= parseChildren(children, RadioGroupControlItem, {\n transformChildObject: ({ children, ...otherProps }) => ({\n text: children,\n ...otherProps,\n }),\n });\n\n const [value, setValue] = useState<T>();\n const isUnknown = useMemo(\n () => isUnknownValue(value, options),\n [options, value],\n );\n const formattedValue = useMemo(\n () => formatSelectionValueAsOptionIndex(value, options),\n [options, value],\n );\n const controller = useInput<T, T, ComponentRef<typeof RadioGroup>>(path, {\n enabled: !useFormIsLoading(),\n setFormattedValue: setValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange: combineEventHandlers(\n onValueChange,\n useResetOnChangeContext(),\n ),\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { nullable, restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLDivElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const { onChange: inputOnChange } = inputProps;\n const handleValueChange = useCallback(\n (formattedValue: string | null) => {\n const newValue = parseSelectionValueFromOptionIndex(\n formattedValue ?? \"\",\n schema,\n options,\n isUnknown ? [value!] : [],\n );\n inputOnChange(newValue);\n setValue(newValue);\n },\n [inputOnChange, isUnknown, options, schema, value],\n );\n\n // Get representation of the value that the control will be cleared to. When\n // `showClearButton` is \"auto\", we hide the button if the current value is\n // the same as the \"cleared value\".\n const clearedValue = nullable ? null : schema.initialValue;\n const clearedIdx = useMemo(\n () => options.findIndex((option) => equals(option.value, clearedValue)),\n [clearedValue, options],\n );\n const clearedFormattedValue = clearedIdx === -1 ? \"\" : clearedIdx.toString();\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedRadioGroupRef = useCombinedRef(\n inputProps.ref,\n autofocusRef,\n ref,\n );\n return (\n <FeedbackProvider>\n <RadioGroup\n value={formattedValue}\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n showClearButton={\n showClearButton === \"auto\"\n ? formattedValue !== clearedFormattedValue\n : showClearButton\n }\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath} />\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedRadioGroupRef}\n >\n {/* Unknown value */}\n {isUnknown && (\n <Radio value={-1} status=\"invalid\">\n <UnknownValue value={value} label={unknownValueLabel} />\n </Radio>\n )}\n {options.map(({ value, text, key, ...radioProps }, i) => (\n <Radio key={key ?? i} value={i} {...radioProps}>\n {text ?? value?.toString() ?? \"\"}\n </Radio>\n ))}\n </RadioGroup>\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import { AbsolutePath } from \"@ostack.tech/kform\";\nimport { useFormController, useFormManager } from \"@ostack.tech/kform-react\";\nimport { useToastManager } from \"@ostack.tech/ui\";\nimport {\n fileSave,\n type FileSystemHandle,\n supported,\n type WellKnownDirectory,\n} from \"browser-fs-access\";\nimport { formatISO } from \"date-fns\";\nimport { DEV } from \"esm-env\";\nimport { type ReactNode, useMemo } from \"react\";\n\nimport { useFormTitle } from \"../components/FormApp\";\nimport { useLocale } from \"../providers/LocalizationProvider\";\n\n/**\n * Options that can be passed to the {@link useFormSaver} hook, or to its\n * resulting `save`/`saveAs` functions.\n */\nexport interface FormSaverOptions<T = unknown> {\n /**\n * When set, if modern file system APIs are available and the form has been\n * previously loaded or saved, then the file will be written over the\n * previously saved/loaded file.\n *\n * @default false\n */\n overwrite?: boolean;\n /**\n * Function used to encode the form, given its value.\n *\n * Note that when returning a string, the string is converted into a `Blob`\n * using the first provided mime type in `mimeTypes` as its type, i.e. it is\n * converted as `new Blob([encodedValue], { type: mimeTypes?.[0] })`.\n *\n * @param formValue Value of the form.\n * @returns Encoded form value as a string, blob, response, or a promise to\n * either type.\n */\n encode?: (\n formValue: T,\n ) => string | Blob | Response | PromiseLike<string | Blob | Response>;\n /**\n * Path of the value being saved.\n *\n * @default AbsolutePath.ROOT\n */\n path?: string | AbsolutePath;\n /**\n * Suggested file name.\n *\n * A function may be provided which will be called with the form value right\n * before invoking the save.\n */\n fileName?: string | ((formValue: T) => string | PromiseLike<string>);\n /**\n * Acceptable file extensions. Extensions should include the leading dot.\n *\n * E.g. `[\".json\", \".txt\"]`\n *\n * @default [\"\"]\n */\n extensions?: string[];\n /**\n * Acceptable MIME types.\n *\n * E.g. `[\"application/json\", \"text/plain\"]`\n *\n * @default [ ]\n */\n mimeTypes?: string[];\n /**\n * Suggested file description.\n *\n * @default \"\"\n */\n description?: string;\n /** Directory to present when starting to save. */\n startIn?: WellKnownDirectory | FileSystemHandle;\n /** Excludes the \"accept all\" option. */\n excludeAcceptAllOption?: boolean;\n /**\n * By specifying an ID, the user agent can remember different directories for\n * different IDs.\n */\n id?: string;\n /**\n * Whether to set the form as pristine when saving.\n *\n * @default true\n */\n setPristineOnSave?: boolean;\n /**\n * Message to show in a toast when successfully saving the form to a file. Can\n * be set to `null` to not show any message.\n *\n * @param fileHandle Handle to the saved file.\n * @returns Message to show in a toast.\n */\n successMessage?:\n ReactNode | ((fileHandle: FileSystemFileHandle) => ReactNode);\n /**\n * Message to show in a toast when an error occurs while saving the form to a\n * file. Can be set to `null` to not show any message.\n *\n * @param fileHandle Handle of the file over which the save was attempted, or\n * `null` if no such file exists.\n * @param error Error that occurred.\n * @returns Message to show in a toast.\n */\n errorMessage?:\n | ReactNode\n | ((fileHandle: FileSystemFileHandle | null, error: unknown) => ReactNode);\n}\n\n/** Result of the {@link useFormSaver} hook. */\nexport interface FormSaverResult<T> {\n /**\n * Function used to save the form.\n *\n * @param options Options used for saving the form.\n * @returns Promise which resolves once the form has been saved.\n */\n save: (options?: FormSaverOptions<T>) => Promise<void>;\n /** Whether the browser supports modern file system APIs used for saving. */\n supportsFileSystemAPIs: boolean;\n}\n\n/** Hook exposing functions used to save the form to a file. */\nexport function useFormSaver<T = unknown>({\n overwrite,\n path,\n encode,\n fileName,\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n id,\n setPristineOnSave,\n successMessage,\n errorMessage,\n}: FormSaverOptions<T> = {}): FormSaverResult<T> {\n const [locale] = useLocale();\n const formManager = useFormManager();\n const { getState, _setState } = useFormController();\n const { addToast } = useToastManager();\n const formTitle = useFormTitle();\n const defaultId = useMemo(\n () => formTitle?.replace(/[^a-zA-Z0-9-_]/g, \"\").substring(0, 32) ?? \"\",\n [formTitle],\n );\n\n return useMemo(() => {\n async function save<T = unknown>({\n overwrite,\n path = AbsolutePath.ROOT,\n encode,\n fileName,\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n id = defaultId,\n setPristineOnSave = true,\n successMessage = locale.SaveAction.successMessage,\n errorMessage = locale.SaveAction.errorMessage,\n }: FormSaverOptions<T>) {\n if (!encode) {\n throw new Error(\"No `encode` function was provided.\");\n }\n\n _setState({ saving: true } as any);\n let fileHandle: FileSystemFileHandle | null =\n (getState() as any).latestFileHandles?.[id] ?? null;\n try {\n const [encodedForm, suggestedFileName] = await formManager.get<\n T,\n [string | Blob | Response, string | undefined]\n >(path, (value) =>\n Promise.all([\n encode(value),\n fileHandle\n ? fileHandle.name\n : typeof fileName === \"function\"\n ? fileName(value)\n : fileName,\n ]),\n );\n\n fileHandle = await fileSave(\n typeof encodedForm === \"string\"\n ? new Blob([encodedForm], { type: mimeTypes?.[0] })\n : encodedForm,\n {\n fileName:\n suggestedFileName || defaultFileName(formTitle, extensions?.[0]),\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n id,\n },\n overwrite ? fileHandle : null,\n );\n\n if (setPristineOnSave) {\n await formManager.setPristine(path);\n }\n\n _setState(\n (state: any) =>\n ({\n latestFileHandles: {\n ...state.latestFileHandles,\n [id]: fileHandle,\n },\n }) as any,\n );\n\n // When modern file system APIs aren't available, the browser will show\n // a notification for the downloaded file so the toast is unnecessary\n if (supported) {\n const message =\n typeof successMessage == \"function\"\n ? successMessage(fileHandle!)\n : successMessage;\n if (message != null) {\n addToast(message, { severity: \"success\" });\n }\n }\n } catch (error) {\n // User aborted\n if (error instanceof DOMException && error.name === \"AbortError\") {\n return;\n }\n\n if (DEV) {\n console.error(error);\n }\n const message =\n typeof errorMessage == \"function\"\n ? errorMessage(fileHandle, error)\n : errorMessage;\n if (message != null) {\n addToast(message, { severity: \"danger\" });\n }\n } finally {\n _setState({ saving: false } as any);\n }\n }\n\n return {\n save: (options = {}) =>\n save({\n overwrite,\n path,\n encode,\n fileName,\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n id,\n setPristineOnSave,\n successMessage,\n errorMessage,\n ...options,\n }),\n supportsFileSystemAPIs: supported,\n };\n }, [\n _setState,\n addToast,\n defaultId,\n description,\n encode,\n errorMessage,\n excludeAcceptAllOption,\n extensions,\n fileName,\n formManager,\n formTitle,\n getState,\n id,\n locale.SaveAction.errorMessage,\n locale.SaveAction.successMessage,\n mimeTypes,\n overwrite,\n path,\n setPristineOnSave,\n startIn,\n successMessage,\n ]);\n}\n\n/** Hook exposing whether the form is currently being saved. */\nexport function useFormIsSaving() {\n return useFormController().useState((state) => (state as any).saving);\n}\n\n/** Default file name when one is not provided. */\nfunction defaultFileName(formTitle?: string, extension?: string) {\n const date = formatISO(new Date(), { representation: \"date\" });\n return [[formTitle, date].filter(Boolean).join(\" \"), extension]\n .filter(Boolean)\n .join(\"\");\n}\n","import { faFloppyDisk } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n Action,\n type ActionButtonProps,\n type ActionProps,\n ActionSplit,\n type ActionSplitProps,\n combineEventHandlers,\n useActionsContext,\n useKeyboardShortcut,\n} from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport {\n type FormSaverOptions,\n useFormIsSaving,\n useFormSaver,\n} from \"../../utils/useFormSaver.tsx\";\nimport { useFormAppElement, useFormIsReadOnly } from \"../FormApp\";\n\n/** Default “save” keybinds. */\nexport const DEFAULT_SAVE_KEYBINDS = \"$mod+S\";\n/** Default “save as” keybinds. */\nexport const DEFAULT_SAVE_AS_KEYBINDS = \"$mod+Shift+S\";\n\n/** Properties of the save action. */\nexport interface SaveActionProps<T = unknown>\n extends\n Partial<ActionButtonProps>,\n Pick<\n ActionSplitProps,\n | \"groupCollapsed\"\n | \"buttonGroupProps\"\n | \"dropdownMenuGroupProps\"\n | \"defaultOpen\"\n | \"open\"\n | \"onOpenChange\"\n | \"modal\"\n | \"dropdownMenuContentProps\"\n | \"groupLabel\"\n >,\n Omit<FormSaverOptions<T>, \"id\" | \"overwrite\"> {\n /**\n * Keybinds for triggering the action. Set to `null` to disable the keyboard\n * shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * `DEFAULT_SAVE_KEYBINDS`.\n */\n keybinds?: string | string[] | null;\n /**\n * Whether to show the save action when the form is read-only.\n *\n * @default true\n */\n showWhenReadOnly?: boolean;\n /**\n * By specifying a filesystem ID, the user agent can remember different\n * directories for different IDs.\n */\n fileSystemId?: string;\n /**\n * Whether to disable the overwriting behaviour of the “save” button. When\n * set, the “save” button will function as the “save as” button and the “save\n * as” button will not be rendered.\n *\n * This property only affects browsers that support modern file system APIs,\n * since other browsers already function in the above-mentioned way.\n *\n * Defaults to `true` when the form is read-only and `false` otherwise.\n */\n disableOverwrite?: boolean;\n /** Label of the action's \"save as\" sub-action. */\n saveAsLabel?: ReactNode;\n /** Label of the save options button. */\n saveOptionsLabel?: ReactNode;\n /** Placement of the save options button. */\n saveOptionsPlacement?: ActionSplitProps[\"splitPlacement\"];\n /**\n * Keybinds for triggering the \"save as\" sub-action. Set to `null` to disable\n * the keyboard shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * `DEFAULT_SAVE_AS_KEYBINDS`.\n */\n saveAsKeybinds?: string | string[] | null;\n /** Properties to pass to the save options button component. */\n saveOptionsProps?: Omit<ActionButtonProps, \"label\">;\n}\n\n/**\n * Form action used to save the form to a file, supporting both overwriting and\n * non-overwriting behaviours (i.e. supporting both “save” and “save as”). Built\n * on top of the [`ButtonGroup`](/docs/ostack-ui-layout-button-group--docs),\n * [`Button`](/docs/ostack-ui-forms-button--docs), and\n * [`DropdownMenu`](/docs/ostack-ui-overlay-dropdown-menu--docs) components, as\n * well as the `useFormSaver` hook.\n *\n * Example usage:\n *\n * ```tsx\n * import { SaveAction } from \"@ostack.tech/ui-kform\";\n *\n * function SaveForm() {\n * return (\n * <SaveAction\n * encode={(formValue) =>\n * encodeFormToJSON(formValue, { pretty: true })\n * }\n * mimeTypes={[\"application/json\"]}\n * extensions={[\".json\"]}\n * />\n * );\n * }\n * ```\n */\nexport function SaveAction<T = unknown>({\n label,\n keybinds,\n showWhenReadOnly = true,\n fileSystemId,\n disableOverwrite,\n saveOptionsLabel,\n saveAsLabel,\n saveAsKeybinds,\n loading,\n disabled,\n onClick,\n variant = \"subtle\",\n color,\n path,\n encode,\n fileName,\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n successMessage,\n errorMessage,\n groupCollapsed,\n defaultOpen,\n open,\n onOpenChange,\n modal,\n groupLabel,\n saveOptionsPlacement,\n buttonGroupProps,\n saveOptionsProps,\n dropdownMenuGroupProps,\n dropdownMenuContentProps,\n ...otherProps\n}: SaveActionProps<T>) {\n const [locale] = useLocale();\n label ??= locale.SaveAction.label;\n if (keybinds === undefined) {\n keybinds = locale.SaveAction.keybinds ?? DEFAULT_SAVE_KEYBINDS;\n }\n saveOptionsLabel ??= locale.SaveAction.saveOptionsLabel;\n saveAsLabel ??= locale.SaveAction.saveAsLabel;\n if (saveAsKeybinds === undefined) {\n saveAsKeybinds =\n locale.SaveAction.saveAsKeybinds ?? DEFAULT_SAVE_AS_KEYBINDS;\n }\n\n const { save, supportsFileSystemAPIs } = useFormSaver({\n path,\n encode,\n fileName,\n extensions,\n description,\n mimeTypes,\n startIn,\n excludeAcceptAllOption,\n id: fileSystemId,\n successMessage,\n errorMessage,\n });\n const formIsReadOnly = useFormIsReadOnly();\n const formIsSaving = useFormIsSaving();\n const formIsLoading = useFormIsLoading();\n\n const showAction = !formIsReadOnly || showWhenReadOnly;\n const showDisabled = disabled || formIsLoading;\n const showLoading = loading || formIsSaving;\n\n // Disable overwrite by default when the form is read-only\n disableOverwrite ??= formIsReadOnly;\n\n // Set-up keyboard shortcuts\n const formAppEl = useFormAppElement();\n const shortcutsDisabled = !showAction || showDisabled || showLoading;\n useKeyboardShortcut(keybinds, () => save({ overwrite: !disableOverwrite }), {\n disabled: shortcutsDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n useKeyboardShortcut(saveAsKeybinds, () => save(), {\n disabled: shortcutsDisabled,\n target: formAppEl,\n preventDefault: true,\n });\n\n const { secondary } = useActionsContext() ?? {};\n const saveActionProps: ActionProps = {\n layout: secondary ? undefined : \"vertical\",\n variant,\n color,\n icon: faFloppyDisk,\n ...otherProps,\n onClick: combineEventHandlers(\n () => save({ overwrite: !disableOverwrite }),\n onClick as never,\n ),\n disabled: showDisabled,\n loading: showLoading,\n keybinds,\n label,\n };\n\n return (\n showAction &&\n (supportsFileSystemAPIs && !disableOverwrite ? (\n <ActionSplit\n {...saveActionProps}\n groupCollapsed={groupCollapsed}\n defaultOpen={defaultOpen}\n open={open}\n onOpenChange={onOpenChange}\n modal={modal}\n groupLabel={groupLabel}\n splitPlacement={saveOptionsPlacement}\n buttonGroupProps={buttonGroupProps}\n dropdownMenuGroupProps={dropdownMenuGroupProps}\n splitLabel={saveOptionsLabel}\n splitProps={{\n ...saveOptionsProps,\n disabled: showDisabled || saveOptionsProps?.disabled,\n }}\n dropdownMenuContentProps={{ align: \"end\", ...dropdownMenuContentProps }}\n >\n <Action\n label={saveAsLabel}\n // icon={faFloppyDisk}\n onClick={() => save()}\n disabled={showDisabled}\n loading={showLoading}\n keybinds={saveAsKeybinds}\n />\n </ActionSplit>\n ) : (\n <Action {...saveActionProps} />\n ))\n );\n}\n","import type { OptionProps } from \"@ostack.tech/ui\";\nimport type { Key, ReactNode } from \"react\";\n\n/** Select control item in object notation. */\nexport interface SelectControlItemObject<T = unknown> extends Omit<\n OptionProps,\n \"value\" | \"children\"\n> {\n /** Item value. */\n value: T;\n /** Item's rendered text. */\n text?: ReactNode;\n /** Item's unique key. */\n key?: Key;\n}\n\n/** Properties of the select control item component. */\nexport interface SelectControlItemProps<T = unknown> extends Omit<\n SelectControlItemObject<T>,\n \"text\"\n> {\n /** Item's rendered text. */\n children?: ReactNode;\n}\n\n/**\n * Definition of a select control item.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `SelectControl` component to automatically create the `options` array.\n */\nexport function SelectControlItem(_props: SelectControlItemProps) {\n return null;\n}\n","import type { OptionProps } from \"@ostack.tech/ui\";\nimport type { Key, ReactNode } from \"react\";\n\nimport type { SelectControlItemObject } from \"./SelectControlItem.tsx\";\n\n/** Select control item group in object notation. */\nexport interface SelectControlItemGroupObject<T = unknown> extends Omit<\n OptionProps,\n \"value\" | \"children\"\n> {\n /** Group's options. */\n options: SelectControlItemObject<T>[];\n /** Group's unique key. */\n key?: Key;\n}\n\n/** Properties of the select control item group component. */\nexport interface SelectControlItemGroupProps<T = unknown> extends Omit<\n SelectControlItemGroupObject<T>,\n \"options\"\n> {\n /** Group's children. */\n children?: ReactNode;\n}\n\n/**\n * Definition of a select control item group.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `SelectControl` component to automatically create groups of items in the\n * `options` array.\n */\nexport function SelectControlItemGroup(_props: SelectControlItemGroupProps) {\n return null;\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n equals,\n type InputController,\n type InputOptions,\n useInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n Option,\n parseChildren,\n Select,\n type SelectProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport {\n formatSelectionValueAsOptionIndex,\n isUnknownValue,\n parseSelectionValueFromOptionIndex,\n selectionItemObjectsToNodes,\n} from \"../../utils/selectionTransformations.tsx\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\nimport { UnknownValue } from \"../UnknownValue\";\nimport {\n SelectControlItem,\n type SelectControlItemObject,\n} from \"./SelectControlItem.tsx\";\nimport {\n SelectControlItemGroup,\n type SelectControlItemGroupObject,\n} from \"./SelectControlItemGroup.tsx\";\n\n/** Properties of the select control component. */\nexport interface SelectControlProps<T = unknown>\n extends\n Omit<\n InputOptions<T, T, ComponentRef<typeof Select>>,\n \"enabled\" | \"format\" | \"parse\"\n >,\n Omit<\n SelectProps,\n | \"multiple\"\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"maxSelected\"\n | \"children\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /** Select control options. */\n options?: (SelectControlItemGroupObject<T> | SelectControlItemObject<T>)[];\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /** Label shown when the control's value isn't one of the existing options. */\n unknownValueLabel?: ReactNode;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /** Select control children. */\n children?: ReactNode;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n InputController<T, string, ComponentRef<typeof Select>> | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The select control component is a KForm form control for values with any type\n * of (typically\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schema. It is built on top of the\n * [`Select`](/docs/ostack-ui-forms-select--docs) component.\n *\n * It composes the following subcomponents:\n *\n * - `SelectControlItem`: Component used to define an item of the select control.\n * - `SelectControlItemGroup`: Component used to define a group of items of the\n * select control.\n *\n * The following built-in KForm validation affects this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n *\n * Example usage:\n *\n * ```tsx\n * import { SelectControl, SelectControlItem } from \"@ostack.tech/ui-kform\";\n *\n * function ShirtSizeControl() {\n * return (\n * <SelectControl\n * path=\"/shirtSize\"\n * placeholder=\"Select your shirt size…\"\n * >\n * <SelectControlItem value=\"sm\">Small</SelectControlItem>\n * <SelectControlItem value=\"md\">Medium</SelectControlItem>\n * <SelectControlItem value=\"lg\">Large</SelectControlItem>\n * <SelectControlItem value=\"xl\">X-Large</SelectControlItem>\n * </SelectControl>\n * );\n * }\n * ```\n */\nexport function SelectControl<T = unknown>({\n path,\n options: groupedOptions,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n unknownValueLabel,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n loading,\n showSpinner,\n disabled,\n readOnly,\n showClearButton,\n endAdornment,\n onFocus,\n onBlurToOutside,\n children,\n debug,\n ref,\n ...otherProps\n}: SelectControlProps<T>) {\n const [locale] = useLocale();\n unknownValueLabel ??= locale.SelectControl.unknownValueLabel;\n\n groupedOptions ??= parseChildren(children, SelectControlItem, {\n groupType: SelectControlItemGroup,\n groupProp: \"options\",\n transformChildObject: ({ children, ...otherProps }) => ({\n text: children,\n ...otherProps,\n }),\n });\n\n const options = useMemo(\n () =>\n groupedOptions.reduce(\n (options: SelectControlItemObject<T>[], optionOrGroup) => {\n if (\"options\" in optionOrGroup) {\n options.push(...optionOrGroup.options);\n } else {\n options.push(optionOrGroup);\n }\n return options;\n },\n [],\n ),\n [groupedOptions],\n );\n const [value, setValue] = useState<T>();\n const isUnknown = useMemo(\n () => isUnknownValue(value, options),\n [options, value],\n );\n const formattedValue = useMemo(\n () => formatSelectionValueAsOptionIndex(value, options),\n [options, value],\n );\n const controller = useInput<T, T, ComponentRef<typeof Select>>(path, {\n enabled: !useFormIsLoading(),\n setFormattedValue: setValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange: combineEventHandlers(\n onValueChange,\n useResetOnChangeContext(),\n ),\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { nullable, restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<T, HTMLButtonElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const { onChange: inputOnChange } = inputProps;\n const handleValueChange = useCallback(\n (formattedValue: string) => {\n const newValue = parseSelectionValueFromOptionIndex(\n formattedValue,\n schema,\n options,\n isUnknown ? [value!] : [],\n );\n inputOnChange(newValue);\n setValue(newValue);\n },\n [inputOnChange, isUnknown, options, schema, value],\n );\n\n // Get representation of the value that the control will be cleared to. When\n // `showClearButton` is \"auto\", we hide the button if the current value is\n // the same as the \"cleared value\".\n showClearButton ??= nullable ? \"auto\" : false;\n const clearedValue = nullable ? null : schema.initialValue;\n const clearedIdx = useMemo(\n () => options.findIndex((option) => equals(option.value, clearedValue)),\n [clearedValue, options],\n );\n const clearedFormattedValue = clearedIdx === -1 ? \"\" : clearedIdx.toString();\n\n const optionNodes = useMemo(\n () => selectionItemObjectsToNodes(groupedOptions),\n [groupedOptions],\n );\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedSelectRef = useCombinedRef(inputProps.ref, autofocusRef, ref);\n return (\n <FeedbackProvider>\n <Select\n value={formattedValue}\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n showClearButton={\n showClearButton === \"auto\"\n ? formattedValue !== clearedFormattedValue\n : showClearButton\n }\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedSelectRef}\n >\n {/* Unknown value */}\n {isUnknown && (\n <Option value={-1} color=\"danger\" keywords={[String(value)]}>\n <UnknownValue value={value} label={unknownValueLabel} />\n </Option>\n )}\n {optionNodes}\n </Select>\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import type {\n SelectControlItemObject,\n SelectControlItemProps,\n} from \"../SelectControl\";\n\n/** Select multiple control item in object notation. */\nexport type SelectMultipleControlItemObject<T = unknown> =\n SelectControlItemObject<T>;\n\n/** Properties of the select multiple control item component. */\nexport type SelectMultipleControlItemProps<T = unknown> =\n SelectControlItemProps<T>;\n\n/**\n * Definition of a select multiple control item.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `SelectMultipleControl` component to automatically create the `options`\n * array.\n */\nexport function SelectMultipleControlItem(\n _props: SelectMultipleControlItemProps,\n) {\n return null;\n}\n","import type {\n SelectControlItemGroupObject,\n SelectControlItemGroupProps,\n} from \"../SelectControl\";\n\n/** Select multiple control item group in object notation. */\nexport type SelectMultipleControlItemGroupObject<T = unknown> =\n SelectControlItemGroupObject<T>;\n\n/** Properties of the select multiple control item group component. */\nexport type SelectMultipleControlItemGroupProps<T = unknown> =\n SelectControlItemGroupProps<T>;\n\n/**\n * Definition of a select multiple control item group.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `SelectMultipleControl` component to automatically create groups of items in\n * the `options` array.\n */\nexport function SelectMultipleControlItemGroup(\n _props: SelectMultipleControlItemGroupProps,\n) {\n return null;\n}\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type Listable,\n type ListableInputController,\n type ListableInputOptions,\n useListableInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n Option,\n parseChildren,\n Select,\n type SelectProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport {\n type ComponentRef,\n type ReactNode,\n type Ref,\n useCallback,\n useMemo,\n useState,\n} from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport {\n formatSelectionValuesAsOptionIndices,\n getUnknownValues,\n parseSelectionValuesFromOptionIndices,\n selectionItemObjectsToNodes,\n} from \"../../utils/selectionTransformations.tsx\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\nimport { UnknownValue } from \"../UnknownValue\";\nimport {\n SelectMultipleControlItem,\n type SelectMultipleControlItemObject,\n} from \"./SelectMultipleControlItem.tsx\";\nimport {\n SelectMultipleControlItemGroup,\n type SelectMultipleControlItemGroupObject,\n} from \"./SelectMultipleControlItemGroup.tsx\";\n\n/** Properties of the select multiple control component. */\nexport interface SelectMultipleControlProps<\n T = unknown,\n TListable extends Listable<T> | null = Listable<T> | null,\n>\n extends\n Omit<\n ListableInputOptions<\n T,\n TListable,\n readonly T[] | null,\n ComponentRef<typeof Select>\n >,\n \"enabled\" | \"formatFromArray\" | \"parseToArray\"\n >,\n Omit<\n SelectProps,\n | \"multiple\"\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"children\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > {\n /** Path to the value. */\n path?: string | Path;\n /** Select multiple control options. */\n options?: (\n SelectMultipleControlItemGroupObject<T> | SelectMultipleControlItemObject<T>\n )[];\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /** Label shown when a value of the control isn't one of the existing options. */\n unknownValueLabel?: ReactNode;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /** Select multiple control children. */\n children?: ReactNode;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | ListableInputController<\n T,\n TListable,\n string[],\n ComponentRef<typeof Select>\n >\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The select multiple control component is a KForm form control for values with\n * (possibly\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)\n * or\n * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)\n * and items of any type. It is built on top of the\n * [`Select`](/docs/ostack-ui-forms-select--docs) component with the `multiple`\n * property set.\n *\n * It composes the following subcomponents:\n *\n * - `SelectMultipleControlItem`: Component used to define an item of the select\n * multiple control.\n * - `SelectMultipleControlItemGroup`: Component used to define a group of items\n * of the select multiple control.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):\n * Sets the `maxSelected` property.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * SelectMultipleControl,\n * SelectMultipleControlItem,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function SpokenLanguagesControl() {\n * return (\n * <SelectMultipleControl\n * path=\"/spokenLanguages\"\n * placeholder=\"Select your spoken languages…\"\n * >\n * <SelectMultipleControlItem value=\"en\">\n * English\n * </SelectMultipleControlItem>\n * <SelectMultipleControlItem value=\"fr\">\n * French\n * </SelectMultipleControlItem>\n * <SelectMultipleControlItem value=\"pt\">\n * Portuguese\n * </SelectMultipleControlItem>\n * <SelectMultipleControlItem value=\"es\">\n * Spanish\n * </SelectMultipleControlItem>\n * </SelectMultipleControl>\n * );\n * }\n * ```\n */\nexport function SelectMultipleControl<\n T = unknown,\n TListable extends Listable<T> | null = Listable<T> | null,\n>({\n path,\n options: groupedOptions,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n unknownValueLabel,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n maxSelected,\n loading,\n showSpinner,\n disabled,\n readOnly,\n endAdornment,\n onFocus,\n onBlurToOutside,\n children,\n debug,\n ref,\n ...otherProps\n}: SelectMultipleControlProps<T, TListable>) {\n const [locale] = useLocale();\n unknownValueLabel ??= locale.SelectMultipleControl.unknownValueLabel;\n\n groupedOptions ??= parseChildren(children, SelectMultipleControlItem, {\n groupType: SelectMultipleControlItemGroup,\n groupProp: \"options\",\n transformChildObject: ({ children, ...otherProps }) => ({\n text: children,\n ...otherProps,\n }),\n });\n\n const options = useMemo(\n () =>\n groupedOptions.reduce(\n (options: SelectMultipleControlItemObject<T>[], optionOrGroup) => {\n if (\"options\" in optionOrGroup) {\n options.push(...optionOrGroup.options);\n } else {\n options.push(optionOrGroup);\n }\n return options;\n },\n [],\n ),\n [groupedOptions],\n );\n const [arrayValue, setArrayValue] = useState<readonly T[] | null>(null);\n const unknownValues = useMemo(\n () => getUnknownValues(arrayValue, options),\n [options, arrayValue],\n );\n const formattedValue = useMemo(\n () =>\n formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues),\n [options, unknownValues, arrayValue],\n );\n const controller = useListableInput<\n T,\n TListable,\n readonly T[] | null,\n ComponentRef<typeof Select>\n >(path, {\n enabled: !useFormIsLoading(),\n parseToArray: useCallback(\n (formattedValue: readonly T[] | null) =>\n formattedValue && [...formattedValue],\n [],\n ),\n formatFromArray: useCallback(\n (arrayValue: readonly T[] | null) => arrayValue && [...arrayValue],\n [],\n ),\n setFormattedValue: setArrayValue,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange: combineEventHandlers(\n onValueChange,\n useResetOnChangeContext(),\n ),\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const { restrictions } = schema.typeInfo;\n const absolutePath = usePath();\n const showDebugInfo = useFormInDebugMode() || debug;\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<TListable, HTMLButtonElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const { onChange: inputOnChange } = inputProps;\n const handleValueChange = useCallback(\n (formattedValue: string[]) => {\n const newValue = parseSelectionValuesFromOptionIndices(\n formattedValue,\n schema,\n options,\n unknownValues,\n );\n inputOnChange(newValue);\n setArrayValue(newValue);\n },\n [inputOnChange, options, schema, unknownValues],\n );\n\n const optionNodes = useMemo(\n () => selectionItemObjectsToNodes(groupedOptions),\n [groupedOptions],\n );\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const combinedSelectRef = useCombinedRef(inputProps.ref, autofocusRef, ref);\n return (\n <FeedbackProvider>\n <Select\n multiple\n value={formattedValue}\n name={inputProps.name}\n required={required ?? restrictions.required === true}\n maxSelected={\n maxSelected ??\n (typeof restrictions.maxSize === \"number\"\n ? restrictions.maxSize\n : undefined)\n }\n loading={displayLoading || loading}\n showSpinner={displayValidating || showSpinner}\n disabled={displayDisabled || disabled || inputProps.disabled}\n readOnly={displayReadOnly || readOnly || inputProps.readOnly}\n status={displayStatusToControlStatus(displayStatusToDisplay)}\n endAdornment={\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n }\n onValueChange={handleValueChange}\n onFocus={combineEventHandlers(onFocus, handleFocus)}\n onBlurToOutside={combineEventHandlers(\n onBlurToOutside,\n inputProps.onBlur,\n )}\n {...otherProps}\n ref={combinedSelectRef}\n >\n {/* Unknown values */}\n {unknownValues.map((v, i) => (\n <Option\n key={i}\n value={-i - 1}\n color=\"danger\"\n keywords={v == null ? [] : [String(v)]}\n >\n <UnknownValue value={v} label={unknownValueLabel} />\n </Option>\n ))}\n {optionNodes}\n </Select>\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n","import { faArrowRight } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n type FormManager,\n type LocatedValidationWarning,\n PromiseCancellationException,\n type SealedLocatedValidationIssue,\n} from \"@ostack.tech/kform\";\nimport {\n type SubmitOptions,\n useFormController,\n} from \"@ostack.tech/kform-react\";\nimport {\n Action,\n type ActionButtonProps,\n Alert,\n AlertDialog,\n AlertDialogAction,\n AlertDialogBody,\n type AlertDialogBodyProps,\n AlertDialogCancel,\n AlertDialogContent,\n type AlertDialogContentProps,\n AlertDialogDescription,\n type AlertDialogDescriptionProps,\n AlertDialogFooter,\n type AlertDialogFooterProps,\n AlertDialogHeader,\n type AlertDialogHeaderProps,\n AlertDialogTitle,\n type AlertDialogTitleProps,\n AlertDialogTrigger,\n type AlertProps,\n Button,\n type ButtonProps,\n Checkbox,\n type CheckboxChecked,\n type CheckboxProps,\n combineEventHandlers,\n cx,\n useKeyboardShortcut,\n useToastManager,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport { type MouseEvent, type ReactNode, useRef, useState } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport {\n useFormAppElement,\n useFormIsDisabled,\n useFormIsReadOnly,\n useStartIssuesNavigation,\n} from \"../FormApp\";\n\n/** Default “submit” keybinds. */\nexport const DEFAULT_SUBMIT_KEYBINDS = \"$mod+Enter\";\n\n/** Properties of the submit action. */\nexport interface SubmitActionProps<T = unknown, TSubmitResult = unknown>\n extends\n Omit<Partial<ActionButtonProps>, \"onSubmit\">,\n Pick<Required<SubmitOptions<T, TSubmitResult>>, \"onSubmit\">,\n Omit<SubmitOptions<T, TSubmitResult>, \"onSubmit\"> {\n /**\n * Keybinds for triggering the action. Set to `null` to disable the keyboard\n * shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * `DEFAULT_SUBMIT_KEYBINDS`.\n */\n keybinds?: string | string[] | null;\n /**\n * Whether to show the submit action when the form is read-only.\n *\n * @default false\n */\n showWhenReadOnly?: boolean;\n /**\n * Whether users should confirm (by ticking a checkbox) that the submission\n * should proceed whenever the form contains warnings.\n *\n * @default true\n */\n confirmWarnings?: boolean;\n /** Title of the confirmation dialog which appears when submitting the form. */\n dialogTitle?:\n | ReactNode\n | ((formValue: T, warnings?: LocatedValidationWarning[]) => ReactNode);\n /**\n * Description of the confirmation dialog which appears when submitting the\n * form.\n */\n dialogDescription?:\n | ReactNode\n | ((formValue: T, warnings?: LocatedValidationWarning[]) => ReactNode);\n /**\n * Body of the confirmation dialog which appears when submitting the form.\n *\n * This property can be used to display a summary of the data being submitted\n * and will be displayed between the description and the “confirm warnings\n * alert”, when it exists.\n */\n dialogBody?:\n | ReactNode\n | ((formValue: T, warnings?: LocatedValidationWarning[]) => ReactNode);\n /**\n * Label of the checkbox which prompts users to confirm that they intend to\n * proceed with submission in the event of warnings in the form.\n */\n confirmWarningsCheckboxLabel?: ReactNode;\n /**\n * Text of the OK button in the confirmation dialog which appears when\n * submitting the form.\n */\n dialogOkText?: ReactNode;\n /**\n * Text of the cancel button in the confirmation dialog which appears when\n * submitting the form.\n */\n dialogCancelText?: ReactNode;\n /**\n * Message to show in a toast after a successful submission. Can be set to\n * `null` to not show any message.\n *\n * @param submitResult Result of `onSubmit`.\n * @returns Message to show in a toast.\n */\n successMessage?: ReactNode | ((submitResult: TSubmitResult) => ReactNode);\n /**\n * Message to show in a toast when an error occurs while submitting the form.\n * Can be set to `null` to not show any message.\n *\n * @param error Error that occurred.\n * @returns Message to show in a toast.\n */\n errorMessage?: ReactNode | ((error: unknown) => ReactNode);\n /** Properties to pass to the confirmation dialog content component. */\n dialogContentProps?: Omit<AlertDialogContentProps, \"children\">;\n /** Properties to pass to the confirmation dialog header component. */\n dialogHeaderProps?: Omit<AlertDialogHeaderProps, \"children\">;\n /** Properties to pass to the confirmation dialog title component. */\n dialogTitleProps?: Omit<AlertDialogTitleProps, \"children\">;\n /** Properties to pass to the confirmation dialog body component. */\n dialogBodyProps?: Omit<AlertDialogBodyProps, \"children\">;\n /** Properties to pass to the confirmation dialog description component. */\n dialogDescriptionProps?: Omit<AlertDialogDescriptionProps, \"children\">;\n /** Properties to pass to the confirmation dialog footer component. */\n dialogFooterProps?: Omit<AlertDialogFooterProps, \"children\">;\n /** Properties to pass to the confirmation dialog OK button component. */\n dialogOkButtonProps?: Omit<ButtonProps, \"children\">;\n /** Properties to pass to the confirmation dialog cancel button component. */\n dialogCancelButtonProps?: Omit<ButtonProps, \"children\">;\n /** Properties to pass to the alert used to confirm warnings. */\n confirmWarningsAlertProps?: Omit<AlertProps, \"children\">;\n /** Properties to pass to the checkbox used to confirm warnings. */\n confirmWarningsCheckboxProps?: Omit<\n CheckboxProps,\n \"checked\" | \"onCheckedChange\" | \"children\"\n >;\n}\n\n/**\n * Type of external issues accepted by the form manager's `addExternalIssues`\n * method.\n */\ntype ExternalValidationIssues = Parameters<FormManager[\"addExternalIssues\"]>[0];\n\n/** An object which is event-like. */\ntype EventLike = Pick<Event, \"preventDefault\" | \"defaultPrevented\">;\n\n/** Information about a submission. */\ninterface SubmissionInfo<T = unknown, TSubmitResult = unknown> {\n value: T;\n warnings?: LocatedValidationWarning[];\n resolve: (value: ExternalValidationIssues | TSubmitResult) => void;\n reject: (reason?: any) => void;\n}\n\n/**\n * Form action used to submit a form, supporting all submission-related\n * properties available in a\n * [`FormApp`](/docs/ostack-ui-kform-layout-form-app--docs). Built on top of the\n * [Button](/docs/ostack-ui-forms-button--docs) and\n * [AlertDialog](/docs/ostack-ui-overlay-alert-dialog--docs) components.\n *\n * Example usage:\n *\n * ```tsx\n * import { SubmitAction } from \"@ostack.tech/ui-kform\";\n *\n * function SubmitForm() {\n * return (\n * <SubmitAction\n * onSubmit={async (formValue, warnings) => {\n * const response = await submitForm(formValue, warnings);\n * if (response instanceof FormSubmitSuccess) {\n * return response.redirectTo;\n * } else if (response instanceof FormSubmitValidationError) {\n * return response.issues;\n * } else {\n * throw new Error(response.errorMessage);\n * }\n * }}\n * onSuccessfulSubmit={(redirectTo) => navigate(redirectTo)}\n * />\n * );\n * }\n * ```\n */\nexport function SubmitAction<T = unknown, TSubmitResult = unknown>({\n onSubmit,\n onInvalidSubmit,\n onSuccessfulSubmit,\n onFailedSubmit,\n setTouchedOnSubmit,\n validateOnSubmit,\n setPristineOnSuccessfulSubmit,\n convertExternalIssuesTableRowIndicesToIds,\n label,\n keybinds,\n showWhenReadOnly,\n confirmWarnings = true,\n loading,\n disabled,\n onClick,\n dialogTitle,\n dialogDescription,\n dialogBody,\n confirmWarningsCheckboxLabel,\n dialogOkText,\n dialogCancelText,\n successMessage: successMessageProp,\n errorMessage: errorMessageProp,\n dialogContentProps,\n dialogHeaderProps,\n dialogTitleProps,\n dialogBodyProps,\n dialogDescriptionProps,\n dialogFooterProps,\n dialogOkButtonProps,\n dialogCancelButtonProps,\n confirmWarningsAlertProps,\n confirmWarningsCheckboxProps,\n ...otherProps\n}: SubmitActionProps<T, TSubmitResult>) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n label ??= locale.SubmitAction.label;\n if (keybinds === undefined) {\n keybinds = locale.SubmitAction.keybinds ?? DEFAULT_SUBMIT_KEYBINDS;\n }\n dialogTitle ??= locale.SubmitAction.dialogTitle;\n dialogDescription ??= locale.SubmitAction.dialogDescription;\n dialogBody ??= locale.SubmitAction.dialogBody;\n confirmWarningsCheckboxLabel ??=\n locale.SubmitAction.confirmWarningsCheckboxLabel;\n dialogOkText ??= locale.SubmitAction.dialogOkText ?? label;\n dialogCancelText ??= locale.SubmitAction.dialogCancelText;\n const successMessage =\n successMessageProp === undefined\n ? locale.SubmitAction.successMessage\n : successMessageProp;\n const errorMessage =\n errorMessageProp === undefined\n ? locale.SubmitAction.errorMessage\n : errorMessageProp;\n\n const [confirmingSubmission, setConfirmingSubmission] = useState(false);\n const startIssuesNavigation = useStartIssuesNavigation();\n const { addToast } = useToastManager();\n const { submit, useSubmitting } = useFormController<T>();\n const submitting = useSubmitting();\n const [runningOnSubmit, setRunningOnSubmit] = useState(false);\n const formIsDisabled = useFormIsDisabled();\n const formIsReadOnly = useFormIsReadOnly();\n const formIsLoading = useFormIsLoading();\n const formAppEl = useFormAppElement();\n\n const showAction = !formIsReadOnly || showWhenReadOnly;\n const showDisabled = disabled || formIsDisabled || formIsLoading;\n const showLoading = loading || submitting;\n\n const [submissionInfo, setSubmissionInfo] = useState<SubmissionInfo<\n T,\n TSubmitResult\n > | null>(null);\n const [checkedWarnings, setCheckedWarnings] = useState<\n LocatedValidationWarning[]\n >([]);\n const allWarningsChecked =\n !submissionInfo?.warnings ||\n submissionInfo.warnings.every((warning) =>\n checkedWarnings.some((checkedWarning) => warning.equals(checkedWarning)),\n );\n\n const handleSubmit = (\n value: T,\n warnings?: LocatedValidationWarning[],\n event?: EventLike,\n ) => {\n event?.preventDefault?.();\n return new Promise<ExternalValidationIssues | TSubmitResult>(\n (resolve, reject) => {\n setConfirmingSubmission(true);\n setSubmissionInfo({ value, warnings, resolve, reject });\n },\n );\n };\n\n const handleOpenChange = (open: boolean) => {\n if (!open && !runningOnSubmit) {\n submissionInfo?.reject(\n new PromiseCancellationException(\"Submission cancelled\"),\n );\n setSubmissionInfo(null);\n setConfirmingSubmission(false);\n }\n };\n\n // Prevent autofocus of the trigger when submitting fails due to the form\n // being invalid, since we want to focus the first field with errors instead\n const preventCloseAutoFocus = useRef(false);\n const handleInvalidSubmit = async (\n issues: SealedLocatedValidationIssue[],\n event?: EventLike,\n ) => {\n preventCloseAutoFocus.current = true;\n await startIssuesNavigation({ validate: false });\n onInvalidSubmit?.(issues, event);\n };\n const handleCloseAutoFocus = (event: EventLike) => {\n if (preventCloseAutoFocus.current) {\n event.preventDefault();\n }\n preventCloseAutoFocus.current = false;\n };\n\n const handleSuccessfulSubmit = (\n submitResult: TSubmitResult,\n event?: EventLike,\n ) => {\n const message =\n typeof successMessage === \"function\"\n ? successMessage(submitResult)\n : successMessage;\n if (message != null) {\n addToast(message, { severity: \"success\" });\n }\n onSuccessfulSubmit?.(submitResult, event);\n };\n\n const handleFailedSubmit = (error: unknown, event?: EventLike) => {\n if (error instanceof PromiseCancellationException) {\n return;\n }\n\n if (DEV) {\n console.error(error);\n }\n const message =\n typeof errorMessage === \"function\" ? errorMessage(error) : errorMessage;\n if (message != null) {\n addToast(message, { severity: \"danger\" });\n }\n onFailedSubmit?.(error, event);\n };\n\n const handleConfirmSubmit = async (event: MouseEvent) => {\n event.preventDefault();\n if (!submissionInfo) {\n return;\n }\n\n const { value, warnings, resolve, reject } = submissionInfo;\n try {\n setRunningOnSubmit(true);\n resolve(await onSubmit(value, warnings, event));\n } catch (err) {\n reject(err);\n } finally {\n setRunningOnSubmit(false);\n handleOpenChange(false);\n }\n };\n\n const handleOnCheckedChange = (checked: CheckboxChecked) => {\n setCheckedWarnings(checked ? (submissionInfo?.warnings ?? []) : []);\n };\n\n const handleAction = (event: EventLike) =>\n submit(event, {\n onSubmit: handleSubmit,\n onInvalidSubmit: handleInvalidSubmit,\n onSuccessfulSubmit: handleSuccessfulSubmit,\n onFailedSubmit: handleFailedSubmit,\n setTouchedOnSubmit,\n validateOnSubmit,\n setPristineOnSuccessfulSubmit,\n convertExternalIssuesTableRowIndicesToIds,\n });\n\n // Set-up keyboard shortcut\n useKeyboardShortcut(keybinds, handleAction, {\n disabled: !showAction || showDisabled || showLoading,\n target: formAppEl,\n preventDefault: true,\n });\n\n return (\n showAction && (\n <AlertDialog open={confirmingSubmission} onOpenChange={handleOpenChange}>\n <AlertDialogTrigger>\n <Action\n label={label}\n type=\"submit\"\n color=\"success\"\n icon={faArrowRight}\n iconPlacement=\"end\"\n {...otherProps}\n onClick={combineEventHandlers(\n onClick,\n // eslint-disable-next-line react-hooks/refs\n handleAction,\n )}\n disabled={showDisabled}\n loading={showLoading}\n keybinds={keybinds}\n />\n </AlertDialogTrigger>\n\n <AlertDialogContent\n color=\"primary\"\n {...dialogContentProps}\n onCloseAutoFocus={combineEventHandlers(\n dialogContentProps?.onCloseAutoFocus,\n // eslint-disable-next-line react-hooks/refs\n handleCloseAutoFocus,\n { checkDefaultPrevented: true },\n )}\n portalProps={{\n container: formAppEl,\n ...dialogContentProps?.portalProps,\n }}\n >\n {submissionInfo && (\n <>\n <AlertDialogHeader {...dialogHeaderProps}>\n <AlertDialogTitle {...dialogTitleProps}>\n {typeof dialogTitle === \"function\"\n ? dialogTitle(submissionInfo.value, submissionInfo.warnings)\n : dialogTitle}\n </AlertDialogTitle>\n </AlertDialogHeader>\n\n <AlertDialogBody {...dialogBodyProps}>\n {dialogDescription && (\n <AlertDialogDescription\n {...dialogDescriptionProps}\n className={cx(\n prefix(\"submit-action__dialog-description\"),\n dialogDescriptionProps?.className,\n )}\n >\n {typeof dialogDescription === \"function\"\n ? dialogDescription(\n submissionInfo.value,\n submissionInfo.warnings,\n )\n : dialogDescription}\n </AlertDialogDescription>\n )}\n\n {typeof dialogBody === \"function\"\n ? dialogBody(submissionInfo.value, submissionInfo.warnings)\n : dialogBody}\n\n {confirmWarnings &&\n (submissionInfo.warnings?.length ?? 0) > 0 && (\n <Alert\n severity=\"warning\"\n {...confirmWarningsAlertProps}\n containerProps={{\n ...confirmWarningsAlertProps?.containerProps,\n className: cx(\n prefix(\n \"submit-action__confirm-warnings-alert-container\",\n ),\n confirmWarningsAlertProps?.containerProps?.className,\n ),\n }}\n >\n <Checkbox\n status=\"warned\"\n {...confirmWarningsCheckboxProps}\n checked={allWarningsChecked}\n onCheckedChange={handleOnCheckedChange}\n >\n {confirmWarningsCheckboxLabel}\n </Checkbox>\n </Alert>\n )}\n </AlertDialogBody>\n\n <AlertDialogFooter {...dialogFooterProps}>\n <AlertDialogCancel disabled={runningOnSubmit}>\n <Button variant=\"subtle\" {...dialogCancelButtonProps}>\n {dialogCancelText}\n </Button>\n </AlertDialogCancel>\n\n <AlertDialogAction onClick={handleConfirmSubmit}>\n <Button\n type=\"submit\"\n color=\"primary\"\n icon={faArrowRight}\n iconPlacement=\"end\"\n {...dialogOkButtonProps}\n loading={runningOnSubmit || dialogOkButtonProps?.loading}\n disabled={\n (confirmWarnings && !allWarningsChecked) ||\n dialogOkButtonProps?.disabled\n }\n >\n {dialogOkText}\n </Button>\n </AlertDialogAction>\n </AlertDialogFooter>\n </>\n )}\n </AlertDialogContent>\n </AlertDialog>\n )\n );\n}\n","import type { AbsolutePath, Table, TableRowId } from \"@ostack.tech/kform\";\nimport type { FormatterController } from \"@ostack.tech/kform-react\";\nimport { createContext, type Ref, useContext } from \"react\";\n\nimport type { UseRegisterControlResult } from \"../../utils/useRegisterControl.tsx\";\nimport type { TableControlRowController } from \"./TableControlRow.tsx\";\n\n/** Value of the table control context. */\nexport interface TableControlContextValue<\n T = any,\n TTable extends Table<T> | null = Table<T> | null,\n> {\n controller: TableControlController<T, TTable>;\n autofocusRef: Ref<HTMLDivElement>;\n handleFocus: UseRegisterControlResult<HTMLDivElement>[\"handleFocus\"];\n size?: number;\n maxRows?: number;\n debug?: boolean;\n}\n\n/** Controller of the table control. */\nexport type TableControlController<\n T = any,\n TTable extends Table<T> | null = Table<T> | null,\n> = FormatterController<TTable, TableRowId[]> & {\n addRow: () => PromiseLike<void> | void;\n removeRow: (path: AbsolutePath) => PromiseLike<void> | void;\n};\n\n/** Table control context. */\nexport const TableControlContext =\n createContext<TableControlContextValue | null>(null);\n\n/** Hook providing access to the table control context. */\nexport function useTableControlContext<\n T = unknown,\n TTable extends Table<T> | null = Table<T> | null,\n>(): TableControlContextValue<T, TTable> {\n const tableControlContext = useContext(TableControlContext);\n if (!tableControlContext) {\n throw new Error(\"Table control context not in scope.\");\n }\n return tableControlContext as unknown as TableControlContextValue<T, TTable>;\n}\n\n/** Table control row context. */\nexport const TableControlRowContext =\n createContext<TableControlRowController | null>(null);\n\n/** Hook providing access to the table control row context. */\nexport function useTableControlRowContext<T>(): TableControlRowController<T> {\n const tableControlRowContext = useContext(TableControlRowContext);\n if (!tableControlRowContext) {\n throw new Error(\"Table control row context not in scope.\");\n }\n return tableControlRowContext as TableControlRowController<T>;\n}\n","import {\n DataTableCell,\n type DataTableCellProps,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport { useDeferredValue } from \"react\";\n\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useTableControlRowContext } from \"./TableControlContext.ts\";\n\n/** Properties of the table control cell. */\nexport interface TableControlCellProps extends DataTableCellProps {}\n\n/** Cell of the table control. */\nexport function TableControlCell({\n variant,\n ...otherProps\n}: TableControlCellProps) {\n const printing = usePrinting();\n const { useDisplayStatus } = useTableControlRowContext();\n const deferredDisplayStatus = useDeferredValue(useDisplayStatus());\n\n return (\n <DataTableCell\n variant={variant}\n // When the cell has a \"header\" variant, set its status from the row's\n // display status\n status={\n !printing && variant === \"header\"\n ? displayStatusToControlStatus(deferredDisplayStatus)\n : undefined\n }\n {...otherProps}\n />\n );\n}\n","import type { DataTableColumnObject } from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport type { TableControlRowController } from \"./TableControlRow.tsx\";\n\n/** Object representation of a table control column. */\nexport interface TableControlColumnObject<\n T = unknown,\n TValue = any,\n> extends Omit<\n DataTableColumnObject<T, TValue>,\n | \"getValue\"\n | \"format\"\n | \"render\"\n | \"compare\"\n | \"filterable\"\n | \"sortable\"\n | \"footer\"\n> {\n /** Rendering of the cell content. */\n render?:\n ReactNode | ((rowController: TableControlRowController<T>) => ReactNode);\n /** Optional footer content to be rendered in the column footer. */\n footer?: ReactNode;\n /**\n * Whether this column should be shown when the table control is in read-only\n * mode.\n */\n showWhenReadOnly?: boolean;\n}\n\n/** Properties of the table control column component. */\nexport interface TableControlColumnProps<T = any, TValue = any> extends Omit<\n TableControlColumnObject<T, TValue>,\n \"subColumns\"\n> {\n /**\n * Rendering of the cell content. If both `render` and `children` are\n * provided, `render` takes priority.\n */\n children?:\n ReactNode | ((rowController: TableControlRowController<T>) => ReactNode);\n}\n\n/**\n * Definition of a table control column.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `TableControl` component to automatically create the `columns` object.\n */\nexport function TableControlColumn<T = any, TValue = any>(\n _props: TableControlColumnProps<T, TValue>,\n) {\n return null;\n}\n","import type { DataTableColumnGroupObject } from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport type { TableControlColumnObjects } from \"./TableControl.tsx\";\n\n/** Object representation of a table control column. */\nexport interface TableControlColumnGroupObject<T = unknown> extends Omit<\n DataTableColumnGroupObject,\n \"subColumns\"\n> {\n /** Sub columns of this column group. */\n subColumns?: TableControlColumnObjects<T>;\n /**\n * Whether this column group should be shown when the table control is in\n * read-only mode.\n */\n showWhenReadOnly?: boolean;\n}\n\n/** Properties of the table control column component. */\nexport interface TableControlColumnGroupProps extends Omit<\n TableControlColumnGroupObject,\n \"subColumns\"\n> {\n /** Sub-columns of this table control column. */\n children?: ReactNode;\n}\n\n/**\n * Definition of a table control column group.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `TableControl` component to automatically create the `columns` object.\n */\nexport function TableControlColumnGroup(_props: TableControlColumnGroupProps) {\n return null;\n}\n","import type { ReactNode } from \"react\";\n\n/** Properties of the table control columns component. */\nexport interface TableControlColumnsProps {\n /** Table control columns. */\n children: ReactNode;\n}\n\n/**\n * Container for the definition of all table control columns. This component\n * must be a direct child of the `TableControl` component.\n *\n * This component doesn't actually render anything by itself; it is used by the\n * `TableControl` component to automatically create the `columns` object.\n */\nexport function TableControlColumns(_props: TableControlColumnsProps) {\n return null;\n}\n","import type { TableRowId } from \"@ostack.tech/kform\";\nimport {\n type Controller,\n CurrentPath,\n useController,\n} from \"@ostack.tech/kform-react\";\nimport {\n DataTableRow,\n type DataTableRowProps,\n useStartPrintingTask,\n} from \"@ostack.tech/ui\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterController, useRegisterLabel } from \"../FormApp\";\nimport { TableControlRowContext } from \"./TableControlContext.ts\";\n\n/** Controller of a table row. */\nexport type TableControlRowController<T = unknown> = Controller<T> & {\n /** Row index. */\n index: number;\n};\n\n/** Properties of the table control row. */\nexport interface TableControlRowProps extends DataTableRowProps {\n row: TableRowId;\n}\n\n/** Row of a table control. */\nexport function TableControlRow({\n row,\n index,\n ...otherProps\n}: TableControlRowProps) {\n const controller = useController(row?.toString(), {\n enabled: !useFormIsLoading() && row != null,\n });\n const tableControlRowController = useMemo(\n () => ({ index, ...controller }),\n [controller, index],\n );\n const path = controller.usePath();\n useRegisterController(controller);\n useRegisterLabel(path, row == null ? null : index + 1);\n\n // Start a printing task until the row is initialised\n const initialized = controller.useInitialized();\n const finishPrintingTask = useStartPrintingTask({ enabled: row != null });\n useEffect(() => {\n if (initialized) {\n finishPrintingTask();\n }\n }, [finishPrintingTask, initialized]);\n\n return (\n <CurrentPath path={path}>\n <TableControlRowContext.Provider value={tableControlRowController}>\n <DataTableRow row={row} index={index} {...otherProps} />\n </TableControlRowContext.Provider>\n </CurrentPath>\n );\n}\n","import {\n AbsolutePath,\n AbsolutePathFragment,\n arrayToTable,\n type CancellablePromise,\n isComputedSchema,\n type Path,\n type Schema,\n type Table,\n tableIdsToArray,\n type TableRowId,\n} from \"@ostack.tech/kform\";\nimport {\n type ControllerOptions,\n CurrentPath,\n InvalidPathError,\n useFormatter,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n cx,\n DataTable,\n type DataTableColumnsObject,\n type DataTableProps,\n type DataTableScrollToOptions,\n FeedbackProvider,\n parseChildren,\n useDataTableApiRef,\n} from \"@ostack.tech/ui\";\nimport {\n Children,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useImperativeHandle,\n useMemo,\n useState,\n} from \"react\";\n\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { isPromiseLike } from \"../../utils/promiseUtils.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { FormAppStatus, useFormInDebugMode, useOnPathFocus } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\nimport type { TableControlApi } from \"./TableControlApi.ts\";\nimport { TableControlCell } from \"./TableControlCell.tsx\";\nimport {\n TableControlColumn,\n type TableControlColumnObject,\n} from \"./TableControlColumn.tsx\";\nimport {\n TableControlColumnGroup,\n type TableControlColumnGroupObject,\n} from \"./TableControlColumnGroup.tsx\";\nimport {\n TableControlColumns,\n type TableControlColumnsProps,\n} from \"./TableControlColumns.tsx\";\nimport {\n TableControlContext,\n useTableControlRowContext,\n} from \"./TableControlContext.ts\";\nimport {\n TableControlRow,\n type TableControlRowController,\n} from \"./TableControlRow.tsx\";\n\n/** Array of table control columns. */\nexport type TableControlColumnObjects<T = unknown> = (\n TableControlColumnObject<T> | TableControlColumnGroupObject<T>\n)[];\n\n/** Properties of the table control component. */\nexport interface TableControlProps<\n T = unknown,\n TTable extends Table<T> | null = Table<T> | null,\n>\n extends\n Omit<\n DataTableProps,\n | \"columns\"\n | \"rows\"\n | \"onVisibleRowsChange\"\n | \"onProcessedRowsChange\"\n | \"getRows\"\n | \"rowKey\"\n | \"loading\"\n | \"defaultFilter\"\n | \"filter\"\n | \"onFilterChange\"\n | \"defaultSortBy\"\n | \"sortBy\"\n | \"defaultSortDirection\"\n | \"sortDirection\"\n | \"onSort\"\n | \"showSelectionColumn\"\n | \"selectionMode\"\n | \"defaultSelectedRows\"\n | \"selectedRows\"\n | \"onSelectedRowsChange\"\n | \"selectAllChecked\"\n | \"onSelectAll\"\n | \"showAllRowsWhilePrinting\"\n | \"apiRef\"\n >,\n Omit<ControllerOptions<TTable>, \"enabled\"> {\n /** Control's path. */\n path?: string | Path;\n /** Table control columns in object notation. */\n columns?: TableControlColumnObjects<T>;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this table.\n *\n * This label has priority over the table's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Sets the maximum number of rows that the table can have. By default, if the\n * table's schema has a `Size` or `MaxSize` validation, then its value is\n * used.\n */\n maxRows?: number;\n /**\n * Function called when a row is being added to choose the value that should\n * be added.\n *\n * The default value being added is provided as an argument and may be edited\n * if required.\n *\n * The value to be added should be returned, or a promise that resolves with\n * said value.\n *\n * To prevent a row from being added, return `undefined`/`null` (or a promise\n * which resolves with `undefined`/`null`).\n *\n * @param value - Value being added, can be edited.\n * @returns Value to be added, `undefined`/`null` if the row shouldn't be\n * added (or a promise that resolves with said values).\n */\n getRowValue?: (\n value: T,\n ) => T | null | undefined | PromiseLike<T | null | undefined>;\n /** Sets the table control as disabled. */\n disabled?: boolean;\n /** Sets the table control as read-only. */\n readOnly?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control to\n * be focused when the form app's `focus` is called with this control's path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<TableControlApi<T, TTable> | undefined>;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\" | \"unwrapped\"\n >;\n}\n\n/**\n * The table control component is a KForm form control for values with (possibly\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)\n * and items of any type. It is built on top of the\n * [`DataTable`](/docs/ostack-ui-data-display-data-table--docs) component.\n *\n * It composes the following subcomponents:\n *\n * - `TableControlColumns`: Container for the definition of all table control\n * columns and their groups.\n * - `TableControlColumn`: Component used to define a column of the table control.\n * - `TableControlColumnGroup`: Component used to define a column group of the\n * table control.\n * - `TableControlContent`: Main content of the table control, containing the\n * table itself.\n * - `TableControlAddRowTrigger`: Trigger used to add a new row to the table.\n * - `TableControlRemoveRowTrigger`: Trigger used to remove a row from the table.\n * - `DataTablePagination`: Optional pagination component of the table control,\n * showing the current scroll progress in the default `scrolled` mode and\n * allowing the selection of the current page in `paged` mode.\n * - `TableControlRowsPerPage`: Optional component allowing the selection of the\n * number of rows to display per page.\n * - `TableControlIndexColumn`: Built-in column displaying the number of each row.\n * - `TableControlActionsColumn`: Built-in column displaying actions that can be\n * performed on each row; displays a `TableControlRemoveRowTrigger` by\n * default.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):\n * Sets the `maxRows` properties.\n *\n * Example usage:\n *\n * ```tsx\n * import {\n * NumericControl,\n * TableControl,\n * TableControlActionsColumn,\n * TableControlAddRowTrigger,\n * TableControlColumn,\n * TableControlContent,\n * TextControl,\n * } from \"@ostack.tech/ui-kform\";\n *\n * function InventoryControl() {\n * return (\n * <TableControl path=\"/inventory\">\n * <TableControlColumns>\n * <TableControlColumn label=\"Description\">\n * <TextControl path=\"description\" />\n * </TableControlColumn>\n * <TableControlColumn label=\"Quantity\">\n * <NumericControl path=\"quantity\" />\n * </TableControlColumn>\n * <TableControlActionsColumn removeRowLabel=\"Remove item\" />\n * </TableControlColumns>\n * <TableControlAddRowTrigger label=\"Add item\" />\n * <TableControlContent\n * caption=\"Inventory\"\n * emptyMessage=\"No items added.\"\n * />\n * </TableControl>\n * );\n * }\n * ```\n */\nexport function TableControl<\n T = unknown,\n TTable extends Table<T> | null = Table<T> | null,\n>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n apiRef,\n issueMessagesProps,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n columns: columnsProp,\n required,\n maxRows,\n getRowValue,\n disabled = false,\n readOnly = false,\n className,\n debug,\n children,\n ...otherProps\n}: TableControlProps<T, TTable>) {\n const prefix = usePrefix();\n const [ids, setIds] = useState<TableRowId[] | undefined>(undefined);\n const size = ids?.length;\n const dataTableApiRef = useDataTableApiRef();\n\n const controller = useFormatter<TTable, TableRowId[]>(path, {\n enabled: !useFormIsLoading(),\n format: useCallback(\n (value?: TTable) => (value ? tableIdsToArray(value) : []),\n [],\n ),\n setFormattedValue: setIds,\n onInitialized,\n onFormManagerEvent,\n onValueChange: combineEventHandlers(\n onValueChange,\n useResetOnChangeContext(),\n ),\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n\n const { useSchema, usePath, useInitialized, useExists } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const initialized = useInitialized();\n const exists = useExists();\n const { restrictions } = schema.typeInfo;\n const maxRowsRestriction =\n maxRows ??\n (typeof restrictions.maxSize === \"number\"\n ? restrictions.maxSize\n : undefined);\n const elementsSchema: Schema<T> = controller.useState((state) =>\n state.formManager.schema(state.path.append(AbsolutePathFragment.Wildcard)),\n );\n const showDebugInfo = useFormInDebugMode() || debug;\n\n if (schema.typeInfo.name !== \"Table\") {\n throw new InvalidPathError(\n absolutePath,\n \"Unsupported schema: Expected (possibly nullable) table schema, \" +\n \"but got schema representing values of type \" +\n `'${schema.typeInfo.toString()}'.`,\n );\n }\n\n const ownController = useMemo(\n () => ({\n addRow: async () => {\n const { schema, initialized, exists, touched, dirty } =\n controller.getState();\n if (\n !initialized ||\n !exists ||\n (maxRowsRestriction != null && size! >= maxRowsRestriction)\n ) {\n return;\n }\n\n let toAdd: T | null | undefined = elementsSchema.initialValue;\n if (getRowValue) {\n const clonedValue = await elementsSchema.clone(toAdd);\n controller._setState({ gettingRowValue: true } as any);\n try {\n const getRowValueResult = getRowValue(clonedValue);\n toAdd = isPromiseLike(getRowValueResult)\n ? await getRowValueResult\n : getRowValueResult;\n } finally {\n controller._setState({ gettingRowValue: false } as any);\n }\n }\n if (toAdd == null) {\n return;\n }\n\n const setPromise: CancellablePromise<void> =\n schema.typeInfo.nullable && size === 0\n ? controller.set(arrayToTable([toAdd]) as TTable)\n : controller.set(\"-\", toAdd);\n setPromise.then(() =>\n queueMicrotask(() => dataTableApiRef.current?.goTo(size!)),\n );\n\n if (!touched) {\n void controller.setTouched();\n }\n if (!dirty) {\n void controller.setDirty();\n }\n return setPromise;\n },\n removeRow: (path: AbsolutePath) => {\n const { formManager, schema, initialized, exists, touched, dirty } =\n controller.getState();\n if (!initialized || !exists) {\n return;\n }\n\n const removePromise =\n schema.typeInfo.nullable && size === 1\n ? controller.set(null as TTable)\n : formManager.remove(path);\n\n if (!touched) {\n void controller.setTouched();\n }\n if (!dirty) {\n void controller.setDirty();\n }\n return removePromise;\n },\n }),\n [\n controller,\n maxRowsRestriction,\n size,\n elementsSchema,\n getRowValue,\n dataTableApiRef,\n ],\n );\n\n // Expose the control's API via `apiRef`\n const goToIndex = useCallback(\n (index: number, scrollOptions?: DataTableScrollToOptions) => {\n dataTableApiRef.current?.goTo(index, scrollOptions);\n },\n [dataTableApiRef],\n );\n const goToId = useCallback(\n (id: number, scrollOptions?: DataTableScrollToOptions) => {\n const idx = ids?.indexOf(id) ?? -1;\n if (idx !== -1) {\n dataTableApiRef.current?.goTo(idx, scrollOptions);\n }\n },\n [dataTableApiRef, ids],\n );\n\n // Register the control\n const {\n displayDisabled,\n displayReadOnly,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl<TTable, HTMLDivElement>({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n });\n const controlIsDisabled =\n displayDisabled || disabled || (initialized && !exists);\n const controlIsReadOnly =\n displayReadOnly || readOnly || isComputedSchema(schema);\n\n useImperativeHandle(\n apiRef,\n () => ({\n ...controller,\n goToIndex,\n goToId,\n }),\n [controller, goToId, goToIndex],\n );\n\n // Go to row with active path when it changes\n useOnPathFocus(\n useCallback(\n (focusedPath) => {\n if (\n exists &&\n ids &&\n focusedPath &&\n absolutePath.resolve(AbsolutePath.DESCENDANTS).contains(focusedPath)\n ) {\n const rowId = focusedPath.fragments[absolutePath.size];\n if (rowId instanceof AbsolutePathFragment.Id) {\n queueMicrotask(() =>\n goToId(+rowId.id, { align: \"center\", behavior: \"smooth\" }),\n );\n }\n }\n },\n [absolutePath, exists, goToId, ids],\n ),\n );\n\n // Parse columns from children\n let columns = columnsProp;\n if (!columns) {\n const columnsElem = Children.toArray(children).find(\n (child) => isValidElement(child) && child.type === TableControlColumns,\n ) as ReactElement<TableControlColumnsProps, typeof TableControlColumns>;\n columns = parseChildren(columnsElem.props.children, TableControlColumn, {\n groupType: TableControlColumnGroup,\n groupProp: \"subColumns\",\n allowNestedGroups: true,\n transformChildObject: ({ children, render, ...otherProps }) => ({\n render: render ?? children,\n ...otherProps,\n }),\n });\n }\n\n const dataTableColumns: DataTableColumnsObject<TableRowId> = useMemo(\n () => tableControlToDataTableColumns(columns, controlIsReadOnly),\n [columns, controlIsReadOnly],\n );\n\n const tableControlController = useMemo(\n () => ({ ...controller, ...ownController }),\n [controller, ownController],\n );\n\n const { inlineIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n });\n\n return (\n <FormAppStatus disabled={controlIsDisabled} readOnly={controlIsReadOnly}>\n <TableControlContext.Provider\n value={{\n controller: tableControlController as never,\n autofocusRef,\n handleFocus,\n size,\n maxRows: maxRowsRestriction,\n debug: showDebugInfo,\n }}\n >\n <CurrentPath path={absolutePath}>\n <FeedbackProvider>\n <DataTable\n className={cx(prefix(\"table-control\"), className)}\n displayMode=\"scrolled\"\n columns={dataTableColumns}\n rows={ids}\n rowKey={(id: TableRowId) => id}\n required={required ?? restrictions.required === true}\n loading={!initialized}\n renderRow={(props) => <TableControlRow {...props} />}\n renderCell={(props) => <TableControlCell {...props} />}\n showAllRowsWhilePrinting\n apiRef={dataTableApiRef}\n {...otherProps}\n >\n {children}\n </DataTable>\n {inlineIssues}\n </FeedbackProvider>\n </CurrentPath>\n </TableControlContext.Provider>\n </FormAppStatus>\n );\n}\n\nfunction tableControlToDataTableColumns<T>(\n columns: TableControlColumnObjects<T>,\n readOnly: boolean,\n columnIdPrefix = \"col\",\n): DataTableColumnsObject<TableRowId> {\n return columns.reduce(\n (columns: DataTableColumnsObject<TableRowId>, column, i) => {\n const {\n subColumns,\n render,\n showWhenReadOnly = true,\n ...otherColumn\n } = column as TableControlColumnObject<T>;\n if (readOnly && !showWhenReadOnly) {\n return columns;\n }\n const columnId = `${columnIdPrefix}-${i}`;\n if (subColumns) {\n columns[columnId] = {\n ...otherColumn,\n subColumns: tableControlToDataTableColumns(\n subColumns,\n readOnly,\n columnId,\n ),\n };\n } else {\n columns[columnId] = {\n ...otherColumn,\n sortable: false,\n filterable: false,\n render:\n typeof render === \"function\"\n ? () => <TableControlCellRenderer render={render} />\n : render,\n };\n }\n return columns;\n },\n {},\n );\n}\n\n/** Properties of the table control cell renderer. */\nexport interface TableControlCellRendererProps<T = unknown> {\n render: (rowController: TableControlRowController<T>) => ReactNode;\n}\n\n/** Renderer of a table control cell. */\nexport function TableControlCellRenderer<T = unknown>({\n render,\n}: TableControlCellRendererProps<T>) {\n return render(useTableControlRowContext<T>());\n}\n","import { useLocale } from \"../../providers/LocalizationProvider\";\n\n/** Default label of the table control's actions column. */\nexport function TableControlActionsColumnLabel() {\n const [locale] = useLocale();\n return locale.TableControlActionsColumn.label;\n}\n","import { useLocale } from \"../../providers/LocalizationProvider\";\n\n/** Default label of the table control's index column. */\nexport function TableControlIndexColumnLabel() {\n const [locale] = useLocale();\n return locale.TableControlIndexColumn.label ?? \"#\";\n}\n","import { faTrash } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n Action,\n type ActionButtonProps,\n combineEventHandlers,\n Slot,\n useActionsContext,\n useAlertDialog,\n} from \"@ostack.tech/ui\";\nimport { type ComponentProps, type ReactNode, useState } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport {\n extractConfirmDialogOptions,\n type PrefixedConfirmDialogOptions,\n} from \"../../utils/extractConfirmDialogOptions.ts\";\nimport { useFormIsDisabled, useFormIsReadOnly } from \"../FormApp\";\nimport { useSetLatestInteraction } from \"../FormApp/FormAppContext.ts\";\nimport {\n useTableControlContext,\n useTableControlRowContext,\n} from \"./TableControlContext.ts\";\n\n/** Properties of the table control remove row trigger component. */\nexport type TableControlRemoveRowTriggerProps =\n | TableControlRemoveRowTriggerChildlessProps\n | TableControlRemoveRowTriggerChildrenProps;\n\n/** Base properties of the table control remove row trigger component. */\nexport interface TableControlRemoveRowTriggerPropsBase extends Omit<\n PrefixedConfirmDialogOptions,\n \"confirmDialogMessage\"\n> {\n /**\n * Whether to show a confirmation message when removing a row.\n *\n * Defaults to `false` unless `confirmDialogMessage` is set, in which case\n * defaults to `true`.\n */\n showConfirmation?: boolean;\n /**\n * Function called after confirmation that the row is to be removed (this\n * function is called even if `showConfirmation` is `false`).\n */\n onConfirmRowRemoval?: () => void;\n /** Function called after the row has been removed. */\n onRowRemoved?: () => void;\n /**\n * Message of the confirmation dialog.\n *\n * @param index Index of the row being removed.\n */\n confirmDialogMessage?: ReactNode | ((index: number) => ReactNode);\n /**\n * Whether to show the trigger when the table is read-only.\n *\n * @default false\n */\n showWhenReadOnly?: boolean;\n}\n\n/**\n * Base properties of the table control remove row trigger component when\n * rendered without children.\n */\nexport interface TableControlRemoveRowTriggerChildlessProps\n extends\n TableControlRemoveRowTriggerPropsBase,\n Omit<Partial<ActionButtonProps>, \"asChild\" | \"children\"> {\n /**\n * Label of the icon button.\n *\n * @deprecated Use `label` instead.\n */\n defaultButtonLabel?: ReactNode;\n children?: never;\n}\n\n/**\n * Base properties of the table control remove row trigger component when\n * rendered with children.\n */\nexport interface TableControlRemoveRowTriggerChildrenProps\n extends\n TableControlRemoveRowTriggerPropsBase,\n Partial<ComponentProps<\"button\">> {\n children: ReactNode;\n}\n\n/**\n * Trigger used to remove a row of a table controlled by a table control.\n *\n * By default, it renders an icon button with label `defaultButtonLabel`,\n * however, this can be overriden by providing `children`.\n */\nexport function TableControlRemoveRowTrigger({\n onConfirmRowRemoval,\n onRowRemoved,\n confirmDialogMessage,\n confirmDialogTitle,\n confirmDialogOkText,\n confirmDialogCancelText,\n showConfirmation = Boolean(confirmDialogMessage),\n showWhenReadOnly,\n disabled,\n onClick,\n children,\n ...otherProps\n}: TableControlRemoveRowTriggerProps) {\n const [locale] = useLocale();\n const [confirmDialogOptions, nonConfirmDialogProps] =\n extractConfirmDialogOptions(otherProps);\n const {\n defaultButtonLabel,\n label = defaultButtonLabel ?? locale.TableControlRemoveRowTrigger.label,\n ...iconButtonProps\n } = nonConfirmDialogProps as TableControlRemoveRowTriggerChildlessProps;\n confirmDialogTitle ??=\n locale.TableControlRemoveRowTrigger.confirmDialogTitle ?? label;\n confirmDialogMessage ??=\n locale.TableControlRemoveRowTrigger.confirmDialogMessage;\n confirmDialogOkText ??=\n locale.TableControlRemoveRowTrigger.confirmDialogOkText;\n confirmDialogCancelText ??=\n locale.TableControlRemoveRowTrigger.confirmDialogCancelText;\n\n const { confirm } = useAlertDialog();\n const { controller } = useTableControlContext();\n const controlIsDisabled = useFormIsDisabled();\n const controlIsReadOnly = useFormIsReadOnly();\n const { getState, index, useInitialized, useExists } =\n useTableControlRowContext();\n const initialized = useInitialized();\n const exists = useExists();\n const setLatestInteraction = useSetLatestInteraction();\n const actionsContext = useActionsContext();\n\n const [removing, setRemoving] = useState(false);\n const handleClick = async () => {\n setLatestInteraction(controller.getState().path);\n const { path, dirty } = getState();\n if (\n removing ||\n (showConfirmation &&\n dirty &&\n !(await confirm(\n typeof confirmDialogMessage === \"function\"\n ? confirmDialogMessage(index)\n : confirmDialogMessage,\n {\n title: confirmDialogTitle,\n color: \"danger\",\n okText: confirmDialogOkText,\n cancelText: confirmDialogCancelText,\n ...confirmDialogOptions,\n },\n )))\n ) {\n return;\n }\n\n setRemoving(true);\n try {\n onConfirmRowRemoval?.();\n await controller.removeRow(path);\n onRowRemoved?.();\n } catch {\n setRemoving(false);\n }\n };\n\n if (!showWhenReadOnly && controlIsReadOnly) {\n return null;\n }\n\n const commonProps = {\n disabled:\n !initialized ||\n !exists ||\n controlIsDisabled ||\n disabled ||\n controlIsReadOnly ||\n (removing && children !== undefined),\n onClick: combineEventHandlers(onClick, handleClick, {\n checkDefaultPrevented: true,\n }),\n };\n if (children === undefined) {\n return (\n <Action\n layout={actionsContext ? undefined : \"icon\"}\n label={label}\n icon={faTrash}\n color=\"danger\"\n loading={!initialized || removing}\n circle\n {...iconButtonProps}\n {...commonProps}\n />\n );\n }\n return (\n <Slot {...nonConfirmDialogProps} {...commonProps}>\n {children}\n </Slot>\n );\n}\n","import { Actions, type ActionsProps } from \"@ostack.tech/ui\";\nimport type { ReactNode } from \"react\";\n\nimport {\n extractConfirmDialogOptions,\n type PrefixedConfirmDialogOptions,\n} from \"../../utils/extractConfirmDialogOptions.ts\";\nimport { TableControlActionsColumnLabel } from \"./TableControlActionsColumnLabel.tsx\";\nimport type { TableControlColumnObject } from \"./TableControlColumn.tsx\";\nimport { TableControlIndexColumnLabel } from \"./TableControlIndexColumnLabel.tsx\";\nimport {\n TableControlRemoveRowTrigger,\n type TableControlRemoveRowTriggerProps,\n type TableControlRemoveRowTriggerPropsBase,\n} from \"./TableControlRemoveRowTrigger.tsx\";\n\n/** Properties used to configure the `tableControlIndexColumn` function. */\nexport interface TableControlIndexColumnFnProps<\n T = unknown,\n TValue = any,\n> extends TableControlColumnObject<T, TValue> {}\n\n/**\n * Pre-configured column used to display the index of each row. By default, it\n * sticks to left of the table.\n *\n * @param props Column properties to override the defaults.\n * @returns Table control column used to display the index of each row.\n */\nexport function tableControlIndexColumn<T = unknown, TValue = any>({\n render,\n ...otherProps\n}: TableControlIndexColumnFnProps<T, TValue> = {}): TableControlColumnObject<\n T,\n TValue\n> {\n return {\n label: <TableControlIndexColumnLabel />,\n header: true,\n sticky: \"left\",\n width: 65,\n fixed: true,\n align: \"center\",\n render: render ?? (({ index }) => index + 1),\n ...otherProps,\n };\n}\n\n/** Properties used to configure the `tableControlActionsColumn` function. */\nexport interface TableControlActionsColumnFnProps<T = unknown, TValue = any>\n extends\n TableControlColumnObject<T, TValue>,\n Omit<\n PrefixedConfirmDialogOptions<\"confirmRowRemovalDialog\">,\n \"confirmRowRemovalDialogMessage\"\n > {\n /**\n * Set the `label` property of the `TableControlRemoveRowTrigger` component\n * rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n removeRowLabel?: ReactNode;\n /**\n * Sets the `showConfirmation` property of the `TableControlRemoveRowTrigger`\n * component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n showRowRemovalConfirmation?: boolean;\n /**\n * Sets the `onConfirmRowRemoval` property of the\n * `TableControlRemoveRowTrigger` component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n onConfirmRowRemoval?: () => void;\n /**\n * Sets the `onRowRemoved` property of the `TableControlRemoveRowTrigger`\n * component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n onRowRemoved?: () => void;\n /**\n * Sets the `confirmDialogMessage` property of the\n * `TableControlRemoveRowTrigger` component rendered by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n confirmRowRemovalDialogMessage?: TableControlRemoveRowTriggerPropsBase[\"confirmDialogMessage\"];\n /**\n * Properties to pass to the `TableControlRemoveRowTrigger` component rendered\n * by default.\n *\n * **Note:** This property has no effect if the column's `render` function is\n * overridden.\n */\n removeRowProps?: TableControlRemoveRowTriggerProps;\n /** Properties to pass to the `Actions` component. */\n actionsProps?: ActionsProps;\n}\n\n/**\n * Pre-configured column used to display row actions. By default, it sticks to\n * the right of the table and renders the `TableControlRemoveRowTrigger`\n * component.\n *\n * Its configuration can be overridden to show other actions, for example, an\n * edit button:\n *\n * ```tsx\n * tableControlActionsColumn({\n * width: 100,\n * render: () => (\n * <>\n * <IconButton label=\"Edit row\" icon={faPencil} />\n * <TableControlRemoveRowTrigger />\n * </>\n * ),\n * });\n * ```\n *\n * @param overrides Column properties used to display the actions of each row.\n * @returns Table control column used to display the actions of each row.\n */\nexport function tableControlActionsColumn<T = unknown, TValue = any>({\n removeRowLabel,\n showRowRemovalConfirmation,\n onConfirmRowRemoval,\n onRowRemoved,\n confirmRowRemovalDialogMessage,\n removeRowProps,\n render,\n actionsProps,\n ...otherProps\n}: TableControlActionsColumnFnProps<T, TValue> = {}): TableControlColumnObject<\n T,\n TValue\n> {\n const [confirmRowRemovalDialogProps, columnProps] =\n extractConfirmDialogOptions(\n otherProps,\n \"confirmRowRemovalDialog\",\n \"confirmDialog\",\n );\n return {\n label: <TableControlActionsColumnLabel />,\n sticky: \"right\",\n width: 50,\n fixed: true,\n align: \"center\",\n showWhilePrinting: false,\n showWhenReadOnly: false,\n render: (...args) => {\n const removeRowTrigger = (\n <TableControlRemoveRowTrigger\n label={removeRowLabel}\n showConfirmation={showRowRemovalConfirmation}\n onConfirmRowRemoval={onConfirmRowRemoval}\n onRowRemoved={onRowRemoved}\n confirmDialogMessage={confirmRowRemovalDialogMessage}\n {...confirmRowRemovalDialogProps}\n {...removeRowProps}\n />\n );\n return render ? (\n <Actions\n primaryLayout=\"icon\"\n secondaryLayout=\"dropdown\"\n gap={1}\n {...actionsProps}\n containerProps={{\n ...actionsProps?.containerProps,\n style: {\n justifyContent: \"center\",\n ...actionsProps?.containerProps?.style,\n },\n }}\n >\n {typeof render === \"function\" ? render(...args) : render}\n </Actions>\n ) : (\n removeRowTrigger\n );\n },\n ...columnProps,\n };\n}\n","import {\n TableControlColumn,\n type TableControlColumnObject,\n type TableControlColumnProps,\n} from \"./TableControlColumn.tsx\";\nimport {\n tableControlActionsColumn,\n type TableControlActionsColumnFnProps,\n} from \"./TableControlColumnFns.tsx\";\n\n/** Properties of the table control actions column. */\nexport interface TableControlActionsColumnProps\n extends\n TableControlColumnProps,\n Omit<TableControlActionsColumnFnProps, keyof TableControlColumnObject> {}\n\n/**\n * Pre-configured column used to display row actions. By default, it sticks to\n * the right of the table and renders the `TableControlRemoveRowTrigger`\n * component.\n *\n * Its configuration can be overridden to show other actions, e.g. an edit\n * button:\n *\n * ```tsx\n * <TableControlActionsColumn width={100}>\n * <IconButton label=\"Edit item\" icon={faPencil} />\n * <TableControlRemoveRowTrigger label=\"Remove item\" />\n * </TableControlActionsColumn>;\n * ```\n */\nexport function TableControlActionsColumn({\n render,\n children,\n ...otherProps\n}: TableControlActionsColumnProps) {\n return (\n <TableControlColumn\n {...tableControlActionsColumn({\n ...otherProps,\n render: render ?? children,\n })}\n />\n );\n}\n","import { faPlus } from \"@fortawesome/free-solid-svg-icons\";\nimport {\n Action,\n type ActionButtonProps,\n boolDataAttr,\n combineEventHandlers,\n cx,\n Slot,\n useActionsContext,\n usePrintClassNames,\n} from \"@ostack.tech/ui\";\nimport { type ComponentProps, type ReactNode, useState } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { usePrefix } from \"../../providers/PrefixSuffixProvider\";\nimport { useFormIsDisabled, useFormIsReadOnly } from \"../FormApp\";\nimport { useSetLatestInteraction } from \"../FormApp/FormAppContext.ts\";\nimport { useTableControlContext } from \"./TableControlContext.ts\";\n\n/** Properties of the table control add row trigger component. */\nexport type TableControlAddRowTriggerProps =\n | TableControlAddRowTriggerChildlessProps\n | TableControlAddRowTriggerChildrenProps;\n\n/** Base properties of the table control add row trigger component. */\nexport interface TableControlAddRowTriggerPropsBase {\n /**\n * Whether to disable the trigger (and show a loading button by default) while\n * a row is being added.\n *\n * @default false\n */\n disableWhileAdding?: boolean;\n /** Function called after the row has been added. */\n onRowAdded?: () => void;\n /**\n * Whether the component should preferably be aligned to the right. This only\n * has an effect when the component is nested directly under the `DataTable`.\n *\n * @default true\n */\n preferRightAlignment?: boolean;\n /**\n * Whether to show the trigger when the table is read-only.\n *\n * @default false\n */\n showWhenReadOnly?: boolean;\n /**\n * Whether to show the trigger when it is being printed.\n *\n * @default false\n */\n showWhilePrinting?: boolean;\n}\n\n/**\n * Properties of the table control add row trigger component when rendered\n * without children.\n */\nexport interface TableControlAddRowTriggerChildlessProps\n extends\n TableControlAddRowTriggerPropsBase,\n Omit<Partial<ActionButtonProps>, \"asChild\" | \"children\"> {\n /**\n * Label displayed on the button.\n *\n * @deprecated Use `label` instead.\n */\n defaultButtonText?: ReactNode;\n children?: never;\n}\n\n/**\n * Properties of the table control add row trigger component when rendered with\n * children.\n */\nexport interface TableControlAddRowTriggerChildrenProps\n extends TableControlAddRowTriggerPropsBase, ComponentProps<\"button\"> {\n children: ReactNode;\n}\n\n/** Trigger used to add a new row to a table control. */\nexport function TableControlAddRowTrigger({\n disableWhileAdding,\n onRowAdded,\n preferRightAlignment = true,\n showWhenReadOnly,\n showWhilePrinting,\n disabled,\n onClick,\n className,\n children,\n ...otherProps\n}: TableControlAddRowTriggerProps) {\n const prefix = usePrefix();\n const [locale] = useLocale();\n\n const { printHidden } = usePrintClassNames();\n const { controller, size, maxRows } = useTableControlContext();\n const controlIsDisabled = useFormIsDisabled();\n const controlIsReadOnly = useFormIsReadOnly();\n const setLatestInteraction = useSetLatestInteraction();\n const actionsContext = useActionsContext();\n\n const gettingRowValue = controller.useState(\n (state: any) => state.gettingRowValue,\n );\n const [adding, setAdding] = useState(false);\n\n const handleClick = async () => {\n setLatestInteraction(controller.getState().path);\n setAdding(true);\n try {\n await controller.addRow();\n onRowAdded?.();\n } finally {\n setAdding(false);\n }\n };\n\n const shouldDisable = controller.useState(\n ({ initialized, exists }) =>\n !initialized ||\n !exists ||\n controlIsDisabled ||\n disabled ||\n controlIsReadOnly ||\n (gettingRowValue && children !== undefined) ||\n (adding && disableWhileAdding && children !== undefined) ||\n (maxRows != null && size! >= maxRows),\n );\n\n if (!showWhenReadOnly && controlIsReadOnly) {\n return null;\n }\n\n const commonProps = {\n className: cx(\n prefix(\"table-control__add-row-trigger\"),\n showWhilePrinting || printHidden,\n className,\n ),\n disabled: shouldDisable,\n onClick: combineEventHandlers(onClick, handleClick, {\n checkDefaultPrevented: true,\n }),\n \"data-prefer-right-alignment\": boolDataAttr(preferRightAlignment),\n };\n\n if (children === undefined) {\n const {\n defaultButtonText,\n label = defaultButtonText ?? locale.TableControlAddRowTrigger.label,\n ...buttonProps\n } = otherProps as TableControlAddRowTriggerChildlessProps;\n return (\n <Action\n layout={\n actionsContext ? undefined : { xs: \"vertical\", sm: \"horizontal\" }\n }\n label={label}\n icon={faPlus}\n color=\"primary\"\n loading={gettingRowValue || (adding && disableWhileAdding)}\n showSpinner={adding && !disableWhileAdding}\n {...buttonProps}\n {...commonProps}\n />\n );\n }\n return (\n <Slot {...otherProps} {...commonProps}>\n {children}\n </Slot>\n );\n}\n","import type { Table, TableRowId } from \"@ostack.tech/kform\";\nimport type { Controller } from \"@ostack.tech/kform-react\";\nimport type { DataTableScrollToOptions } from \"@ostack.tech/ui\";\nimport { type RefObject, useRef } from \"react\";\n\n/** Imperative table control API. */\nexport type TableControlApi<\n T = unknown,\n TTable extends Table<T> | null = Table<T> | null,\n> = Controller<TTable> & {\n /**\n * Navigates to the row with the provided index.\n *\n * @param index Index of row to navigate to.\n * @param scrollOptions Options used to configure to scrolling to the row\n * (only relevant in scrolled display mode).\n */\n goToIndex: (index: number, scrollOptions?: DataTableScrollToOptions) => void;\n /**\n * Navigates to the row with the provided id.\n *\n * @param id Id of row to navigate to.\n * @param scrollOptions Options used to configure to scrolling to the row\n * (only relevant in scrolled display mode).\n */\n goToId: (id: TableRowId, scrollOptions?: DataTableScrollToOptions) => void;\n};\n\n/** Hook used to access the table control API. */\nexport function useTableControlApiRef<\n T = unknown,\n TTable extends Table<T> | null = Table<T> | null,\n>(): RefObject<TableControlApi<T, TTable> | null> {\n return useRef<TableControlApi<T, TTable>>(null);\n}\n","import {\n combineEventHandlers,\n DataTableContent,\n type DataTableContentProps,\n useCombinedRef,\n usePrinting,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport { useCallback, useDeferredValue } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { DebugInfo } from \"../DebugInfo\";\nimport { useTableControlContext } from \"./TableControlContext.ts\";\n\n/** Properties of the table control content component. */\nexport interface TableControlContentProps extends Omit<\n DataTableContentProps,\n \"status\"\n> {}\n\n/** Component containing the content of the table control. */\nexport function TableControlContent({\n emptyMessage,\n scrollableProps,\n ...otherProps\n}: TableControlContentProps) {\n const [locale] = useLocale();\n emptyMessage ??= locale.TableControlContent.emptyMessage;\n\n const { autofocusRef, handleFocus, controller, debug } =\n useTableControlContext();\n const printing = usePrinting();\n const absolutePath = controller.usePath();\n const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());\n\n const handleContainerOnBlur = useCallback(() => {\n const { initialized, exists, touched } = controller.getState();\n if (initialized && exists && !touched) {\n void controller.setTouched();\n }\n }, [controller]);\n\n return (\n <>\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && debug && (\n <DebugInfo path={absolutePath} data-prefer-right-alignment=\"\" />\n )}\n\n <DataTableContent\n editable\n variant=\"control\"\n status={\n printing\n ? undefined\n : displayStatusToControlStatus(deferredDisplayStatus)\n }\n emptyMessage={emptyMessage}\n scrollableProps={{\n onFocus: combineEventHandlers(scrollableProps?.onFocus, handleFocus),\n onBlur: combineEventHandlers(\n scrollableProps?.onBlur,\n handleContainerOnBlur,\n ),\n ref: useCombinedRef(autofocusRef, scrollableProps?.ref),\n }}\n {...otherProps}\n />\n </>\n );\n}\n","import {\n TableControlColumn,\n type TableControlColumnObject,\n type TableControlColumnProps,\n} from \"./TableControlColumn.tsx\";\nimport {\n tableControlIndexColumn,\n type TableControlIndexColumnFnProps,\n} from \"./TableControlColumnFns.tsx\";\n\n/** Properties of the table control index column. */\nexport interface TableControlIndexColumnProps\n extends\n TableControlColumnProps,\n Omit<TableControlIndexColumnFnProps, keyof TableControlColumnObject> {}\n\n/**\n * Pre-configured column used to display the index of each row. By default, it\n * sticks to left of the table.\n */\nexport function TableControlIndexColumn({\n render,\n children,\n ...otherProps\n}: TableControlIndexColumnProps) {\n return (\n <TableControlColumn\n {...tableControlIndexColumn({\n ...otherProps,\n render: render ?? children,\n })}\n />\n );\n}\n","import {\n DataTablePagination,\n type DataTablePaginationProps,\n} from \"@ostack.tech/ui\";\n\n/** Properties of the table control pagination component. */\nexport type TableControlPaginationProps = DataTablePaginationProps;\n\n/** Table control pagination. */\nexport const TableControlPagination = DataTablePagination;\n","import {\n DataTableRowsPerPage,\n type DataTableRowsPerPageProps,\n} from \"@ostack.tech/ui\";\n\n/** Properties of the table control rows per page component. */\nexport type TableControlRowsPerPageProps = DataTableRowsPerPageProps;\n\n/** Table control rows per page. */\nexport const TableControlRowsPerPage = DataTableRowsPerPage;\n","import type { Path } from \"@ostack.tech/kform\";\nimport {\n type FormatterControllerState,\n type InputController,\n type InputOptions,\n InvalidPathError,\n useInput,\n} from \"@ostack.tech/kform-react\";\nimport {\n combineEventHandlers,\n FeedbackProvider,\n Input,\n type InputProps,\n TextArea,\n type TextAreaProps,\n useCombinedRef,\n} from \"@ostack.tech/ui\";\nimport { DEV } from \"esm-env\";\nimport { type ComponentRef, type ReactNode, type Ref, useState } from \"react\";\n\nimport { displayStatusToControlStatus } from \"../../utils/displayStatusConversions.ts\";\nimport { useControlIssues } from \"../../utils/useControlIssues.tsx\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport { useRegisterControl } from \"../../utils/useRegisterControl.tsx\";\nimport { DebugInfo, DebugInfoControlAddonTrigger } from \"../DebugInfo\";\nimport { useFormInDebugMode } from \"../FormApp\";\nimport type { IssueMessagesByCode, IssueMessagesProps } from \"../IssueMessages\";\nimport { useResetOnChangeContext } from \"../ResetOnChange\";\n\n/** Properties of the text control component. */\nexport type TextControlProps<T extends string | null = string | null> =\n TextControlInputProps<T> | TextControlTextAreaProps<T>;\n\n/** Base properties of the text control component. */\nexport type TextControlPropsBase<T extends string | null = string | null> =\n Omit<\n InputOptions<T, string, ComponentRef<typeof Input | typeof TextArea>>,\n \"enabled\" | \"format\" | \"parse\"\n > & {\n /** Path to the value. */\n path?: string | Path;\n /**\n * Issue messages of this control.\n *\n * Mapping from an issue's code to its message.\n */\n issueMessages?: IssueMessagesByCode;\n /**\n * Label to use in the issues panel when displaying issues associated with\n * this field.\n *\n * This label has priority over the field's `Label`.\n */\n issuesPanelLabel?: ReactNode;\n /**\n * Whether to display the issues associated with this control.\n *\n * @default true\n */\n displayIssues?: boolean;\n /**\n * Whether to prevent the auto-focusing behaviour that causes this control\n * to be focused when the form app's `focus` is called with this control's\n * path.\n *\n * Preventing this behaviour is useful when multiple controls for the same\n * path are rendered at once, and only one of them should be focused.\n *\n * @default false\n */\n preventAutoFocus?: boolean;\n /** Whether to render a multiline text control. */\n multiline?: boolean;\n /**\n * Whether to show debug information. This property has no effect in\n * production builds.\n */\n debug?: boolean;\n /** Reference to the control's API. */\n apiRef?: Ref<\n | InputController<T, string, ComponentRef<typeof Input | typeof TextArea>>\n | undefined\n >;\n /** Properties to pass to the `IssueMessages` component. */\n issueMessagesProps?: Omit<\n IssueMessagesProps,\n \"path\" | \"issues\" | \"messages\"\n >;\n };\n\n/** Properties of the text control component when `multiline` is **not** set. */\nexport type TextControlInputProps<T extends string | null = string | null> =\n Omit<\n InputProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > &\n TextControlPropsBase<T> & {\n multiline?: false;\n };\n\n/** Properties of the text control component when `multiline` is set. */\nexport type TextControlTextAreaProps<T extends string | null = string | null> =\n Omit<\n TextAreaProps,\n | \"defaultValue\"\n | \"value\"\n | \"onValueChange\"\n | \"status\"\n | \"validate\"\n | \"validationMode\"\n > &\n TextControlPropsBase<T> & {\n multiline: true;\n pattern?: never;\n };\n\n/**\n * The text control component is a KForm form control for values with (possibly\n * [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))\n * schemas of type\n * [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).\n * It supports both single and multiline text editing, being built on top of the\n * [`Input`](/docs/ostack-ui-forms-input--docs) (for single-line) or\n * [`TextArea`](/docs/ostack-ui-forms-text-area--docs) (for multiline)\n * components.\n *\n * The following built-in KForm validations affect this control:\n *\n * - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):\n * Sets the `required` property.\n * - [`Length`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-length/index.html)/[`MinLength`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min-length/index.html)/[`MaxLength`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-length/index.html):\n * Sets the `minLength` and/or `maxLength` properties.\n * - [`Matches`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-matches/index.html):\n * Sets the `pattern` property.\n *\n * Example usage:\n *\n * ```tsx\n * import { TextControl } from \"@ostack.tech/ui-kform\";\n *\n * function UsernameControl() {\n * return <TextControl path=\"/username\" placeholder=\"Enter username…\" />;\n * }\n * ```\n */\nexport function TextControl<T extends string | null = string | null>({\n path,\n issueMessages,\n issuesPanelLabel,\n displayIssues = true,\n preventAutoFocus,\n multiline = false,\n apiRef,\n issueMessagesProps,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange,\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n required,\n minLength,\n maxLength,\n pattern,\n loading,\n showSpinner,\n disabled,\n readOnly,\n endAdornment,\n onChange,\n onFocus,\n onBlurToOutside,\n debug,\n ref,\n ...otherProps\n}: TextControlProps<T>) {\n const controller = useInput<\n T,\n string,\n ComponentRef<typeof Input | typeof TextArea>\n >(path, {\n enabled: !useFormIsLoading(),\n parse: parseText,\n formManager,\n onInitialized,\n onFormManagerEvent,\n onValueChange: combineEventHandlers(\n onValueChange,\n useResetOnChangeContext(),\n ),\n onValidationStatusChange,\n onDisplayStatusChange,\n onDirtyStatusChange,\n onTouchedStatusChange,\n });\n const { useSchema, usePath, inputProps } = controller;\n const schema = useSchema();\n const absolutePath = usePath();\n const { restrictions } = schema.typeInfo;\n const showDebugInfo = useFormInDebugMode() || debug;\n\n if (schema.typeInfo.name !== \"String\") {\n throw new InvalidPathError(\n absolutePath,\n \"Unsupported schema: Expected schema representing (possibly nullable) \" +\n \"strings, but got schema representing values of type \" +\n `'${schema.typeInfo.toString()}'.`,\n );\n }\n\n // Register the control\n const {\n displayLoading,\n displayDisabled,\n displayReadOnly,\n displayStatusToDisplay,\n displayValidating,\n issuesToDisplay,\n autofocusRef,\n handleFocus,\n } = useRegisterControl({\n controller,\n issuesPanelLabel,\n ariaLabel: otherProps[\"aria-label\"],\n preventAutoFocus,\n apiRef,\n });\n\n const [wasMultiline] = useState(multiline);\n if (multiline !== wasMultiline) {\n throw new Error(\n \"The `multiline` property cannot not be changed at runtime.\",\n );\n }\n\n const { inlineIssues, popoverIssues } = useControlIssues({\n issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },\n issueMessages: { [absolutePath.toString()]: issueMessages },\n displayIssues,\n issueMessagesProps,\n variant: otherProps.variant,\n });\n\n const commonProps: InputProps | TextAreaProps = {\n name: inputProps.name,\n required: required ?? restrictions.required === true,\n minLength:\n minLength ??\n (typeof restrictions.minLength === \"number\"\n ? restrictions.minLength\n : undefined),\n maxLength:\n maxLength ??\n (typeof restrictions.maxLength === \"number\"\n ? restrictions.maxLength\n : undefined),\n pattern:\n pattern ??\n (typeof restrictions.pattern === \"string\"\n ? restrictions.pattern\n : undefined),\n loading: displayLoading || loading,\n showSpinner: displayValidating || showSpinner,\n disabled: displayDisabled || disabled || inputProps.disabled,\n readOnly: displayReadOnly || readOnly || inputProps.readOnly,\n status: displayStatusToControlStatus(displayStatusToDisplay),\n endAdornment: (\n <>\n {popoverIssues}\n {endAdornment}\n\n {/* Debug info */}\n {(DEV || import.meta.env.STORYBOOK) && showDebugInfo && (\n <DebugInfo<T> path={absolutePath}>\n <DebugInfoControlAddonTrigger />\n </DebugInfo>\n )}\n </>\n ),\n onChange: combineEventHandlers(onChange as never, inputProps.onChange),\n onFocus: combineEventHandlers(onFocus as never, handleFocus),\n onBlurToOutside: combineEventHandlers(\n onBlurToOutside as never,\n inputProps.onBlur,\n ),\n ref: useCombinedRef(\n inputProps.ref,\n useCombinedRef(autofocusRef, ref),\n ) as never,\n ...(otherProps as any),\n };\n return (\n <FeedbackProvider>\n {multiline ? (\n <TextArea {...(commonProps as TextAreaProps)} />\n ) : (\n <Input {...(commonProps as InputProps)} />\n )}\n {inlineIssues}\n </FeedbackProvider>\n );\n}\n\n/** Parses a text control formatted value. */\nfunction parseText<T extends string | null>(\n formattedValue: string,\n state: FormatterControllerState<T, string>,\n): T {\n return (\n state.schema.typeInfo.nullable ? formattedValue || null : formattedValue\n ) as T;\n}\n","import { faCircleCheck } from \"@fortawesome/free-regular-svg-icons\";\nimport {\n Action,\n type ActionButtonProps,\n combineEventHandlers,\n useActionsContext,\n useKeyboardShortcut,\n} from \"@ostack.tech/ui\";\nimport { useDeferredValue } from \"react\";\n\nimport { useLocale } from \"../../providers/LocalizationProvider\";\nimport { useFormIsLoading } from \"../../utils/useFormLoader.tsx\";\nimport {\n useFormIsValidating,\n useFormValidator,\n} from \"../../utils/useFormValidator.ts\";\nimport {\n useFormAppElement,\n useFormIsDisabled,\n useFormIsReadOnly,\n} from \"../FormApp\";\n\n/** Default “validate” keybinds. */\nexport const DEFAULT_VALIDATE_KEYBINDS = \"Alt+Shift+V\";\n\n/** Properties of the validate action. */\nexport interface ValidateActionProps extends Partial<ActionButtonProps> {\n /**\n * Keybinds for triggering the action. Set to `null` to disable the keyboard\n * shortcut.\n *\n * Keyboard handling is built on top of the\n * [`tinykeys`](https://jamiebuilds.github.io/tinykeys) library. For\n * information on keybinding syntax, read the [`tinykeys`\n * documentation](https://github.com/jamiebuilds/tinykeys).\n *\n * Defaults to the keybinds defined by the current locale or to\n * `DEFAULT_VALIDATE_KEYBINDS`.\n */\n keybinds?: string | string[] | null;\n /**\n * Whether to show the validate action when the form is read-only.\n *\n * @default false\n */\n showWhenReadOnly?: boolean;\n}\n\n/**\n * Form action used to validate the form. Built on top of the [`Button`\n * component](/docs/ostack-ui-forms-button--docs) and `useFormValidator` hook.\n *\n * If the form contains an `IssuesPanel` component, it is shown as a result of\n * triggering the action.\n *\n * Example usage:\n *\n * ```tsx\n * import { ValidateAction } from \"@ostack.tech/ui-kform\";\n *\n * function ValidateForm() {\n * return <ValidateAction />;\n * }\n * ```\n */\nexport function ValidateAction({\n label,\n keybinds,\n showWhenReadOnly,\n loading,\n disabled,\n onClick,\n ...otherProps\n}: ValidateActionProps) {\n const [locale] = useLocale();\n label ??= locale.ValidateAction.label;\n if (keybinds === undefined) {\n keybinds = locale.ValidateAction.keybinds ?? DEFAULT_VALIDATE_KEYBINDS;\n }\n\n const { validate } = useFormValidator();\n const { validatingAutomatically, validatingManually } = useFormIsValidating();\n const deferredValidatingAutomatically = useDeferredValue(\n validatingAutomatically,\n );\n const formIsDisabled = useFormIsDisabled();\n const formIsReadOnly = useFormIsReadOnly();\n const formIsLoading = useFormIsLoading();\n\n const showAction = !formIsReadOnly || showWhenReadOnly;\n const showDisabled = disabled || formIsDisabled || formIsLoading;\n const showLoading = loading || validatingManually;\n\n // Set-up keyboard shortcut\n const formAppEl = useFormAppElement();\n useKeyboardShortcut(keybinds, validate, {\n disabled: !showAction || showDisabled || showLoading,\n target: formAppEl,\n preventDefault: true,\n });\n\n const { secondary } = useActionsContext() ?? {};\n return (\n showAction && (\n <Action\n layout={secondary ? undefined : \"vertical\"}\n label={label}\n variant=\"solid\"\n color=\"primary\"\n icon={faCircleCheck}\n {...otherProps}\n onClick={combineEventHandlers(validate, onClick as never)}\n disabled={showDisabled}\n loading={showLoading}\n showSpinner={deferredValidatingAutomatically}\n keybinds={keybinds}\n />\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,IAAM,wBAAwB;;AAG9B,IAAa,2BAA2B,mBAAmB,EACzD,qBAAqB,sBACvB,EAAE;;;;;;;;AASF,SAAgB,uBAAuB,qBAA6B;CAClE,yBAAyB,SAAS,EAAE,oBAAoB,CAAC;AAC3D;;;;AChBA,IAAa,sBAAsB,cAA6B,IAAI;;;;ACSpE,SAAgB,qBAAqB,EACnC,cACA,YAC4B;CAC5B,OAAO,iBAAiB,KAAA,IACtB,WAEA,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;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